diff --git a/l10n_es_ticketbai_pos/README.rst b/l10n_es_ticketbai_pos/README.rst new file mode 100644 index 00000000000..aa1b96511a4 --- /dev/null +++ b/l10n_es_ticketbai_pos/README.rst @@ -0,0 +1,86 @@ +========================= +TicketBAI - Point of Sale +========================= + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fl10n--spain-lightgray.png?logo=github + :target: https://github.com/OCA/l10n-spain/tree/11.0/l10n_es_ticketbai_pos + :alt: OCA/l10n-spain + +|badge1| |badge2| |badge3| + +Módulo de TPV para la declaración de todas las operaciones de venta realizadas por las personas y entidades +que desarrollan actividades económicas +https://www.euskadi.eus/contenidos/informacion/ticketbai/es_14815/adjuntos/TicketBAI_Especificaciones_v_1_1.pdf + +**Table of contents** + +.. contents:: + :local: + +Installation +============ + +Para instalar éste módulo necesita: + +#. Los módulos l10n_es_pos, pos_order_mgmt y l10n_es_ticketbai. + + +Usage +===== + +* Factura simplificada/Ticket de cliente + + * Se genera el fichero y se firma al validar la factura/ticket. + +* Es posible utilizar un certificado específico por cada TPV, se debe crear en el menú `TicketBAI Certificados`, accesible desde la configuración de punto de venta y se establece en la configuración de cada TPV, si no se establece dicho certificado, se utiliza el definido en la compañía. + + * Es importante recordar, de cara a la seguridad, la importancia de generar un certificado de dispositivo (Izempe) ya que este se gestiona en el cliente y con dichos certificados no puede hacerse ninguna acción fuera del dispositivo. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Binovo IT Human Project S.L. + +Contributors +~~~~~~~~~~~~ + +* Victor Laskurain +* Luis J. Salvatierra +* Miquel Alzanillas +* Adrián Cifuentes + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +This module is part of the `OCA/l10n-spain `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/l10n_es_ticketbai_pos/__init__.py b/l10n_es_ticketbai_pos/__init__.py new file mode 100644 index 00000000000..b046ff82fc3 --- /dev/null +++ b/l10n_es_ticketbai_pos/__init__.py @@ -0,0 +1 @@ +from . import models, wizard diff --git a/l10n_es_ticketbai_pos/__manifest__.py b/l10n_es_ticketbai_pos/__manifest__.py new file mode 100644 index 00000000000..34a215fed55 --- /dev/null +++ b/l10n_es_ticketbai_pos/__manifest__.py @@ -0,0 +1,39 @@ +# Copyright 2021 Binovo IT Human Project SL +# Copyright 2022 Landoo Sistemas de Informacion SL +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "TicketBAI - Point of Sale - " + "declaración de todas las operaciones de venta realizadas por las personas " + "y entidades que desarrollan actividades económicas", + "version": "16.0.1.0.0", + "category": "Accounting & Finance", + "website": "https://github.com/OCA/l10n-spain", + "author": "Binovo," "Odoo Community Association (OCA)", + "license": "AGPL-3", + "application": False, + "installable": True, + "auto_install": False, + "development_status": "Beta", + "maintainers": ["ao-landoo"], + "depends": ["l10n_es_pos", "l10n_es_ticketbai"], + "data": [ + "security/ir.model.access.csv", + "views/pos_order_views.xml", + "views/ticketbai_certificate_views.xml", + "wizard/res_config_settings_views.xml", + ], + "assets": { + "point_of_sale.assets": [ + "l10n_es_ticketbai_pos/static/src/xml/pos.xml", + "l10n_es_ticketbai_pos/static/lib/qrcode.js", + "l10n_es_ticketbai_pos/static/lib/tbai.js", + "l10n_es_ticketbai_pos/static/src/js/models.js", + "l10n_es_ticketbai_pos/static/src/js/tbai_models.js", + "l10n_es_ticketbai_pos/static/src/js/db.js", + "l10n_es_ticketbai_pos/static/src/js/Screens/ClientListScreen/ClientListScreen.js", + "l10n_es_ticketbai_pos/static/src/js/Screens/PaymentScreen/PaymentScreen.js", + "l10n_es_ticketbai_pos/static/src/js/Screens/ProductScreen/ProductScreen.js", + ], + }, +} diff --git a/l10n_es_ticketbai_pos/i18n/es.po b/l10n_es_ticketbai_pos/i18n/es.po new file mode 100644 index 00000000000..a77a29d5ec1 --- /dev/null +++ b/l10n_es_ticketbai_pos/i18n/es.po @@ -0,0 +1,276 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_es_ticketbai_pos +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2022-06-13 07:00+0000\n" +"PO-Revision-Date: 2023-10-12 12:38+0000\n" +"Last-Translator: Ivorra78 \n" +"Language-Team: \n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: l10n_es_ticketbai_pos +#: model_terms:ir.ui.view,arch_db:l10n_es_ticketbai_pos.view_pos_config_form_inherit +msgid "" +"" +msgstr "" +"" + +#. module: l10n_es_ticketbai_pos +#. openerp-web +#: code:addons/l10n_es_ticketbai_pos/static/src/js/Screens/PaymentScreen/PaymentScreen.js:0 +#, python-format +msgid "At least one product does not have a tax." +msgstr "Al menos un producto no tiene establecido el impuesto." + +#. module: l10n_es_ticketbai_pos +#: model_terms:ir.ui.view,arch_db:l10n_es_ticketbai_pos.view_pos_config_form_inherit +msgid "Certificate" +msgstr "Certificado" + +#. module: l10n_es_ticketbai_pos +#: model:ir.model.fields,field_description:l10n_es_ticketbai_pos.field_pos_config__tbai_device_serial_number +#: model_terms:ir.ui.view,arch_db:l10n_es_ticketbai_pos.view_pos_config_form_inherit +msgid "Device Serial Number" +msgstr "Número de serie de dispositivo" + +#. module: l10n_es_ticketbai_pos +#: model:ir.model.fields,field_description:l10n_es_ticketbai_pos.field_pos_config__tbai_enabled +#: model:ir.model.fields,field_description:l10n_es_ticketbai_pos.field_pos_order__tbai_enabled +msgid "Enable TicketBAI" +msgstr "Habilitar TicketBAI" + +#. module: l10n_es_ticketbai_pos +#: model_terms:ir.ui.view,arch_db:l10n_es_ticketbai_pos.view_pos_pos_form_inherit +msgid "Files Sent" +msgstr "Ficheros enviados" + +#. module: l10n_es_ticketbai_pos +#: model:ir.model,name:l10n_es_ticketbai_pos.model_account_move +msgid "Journal Entry" +msgstr "Entrada diaria" + +#. module: l10n_es_ticketbai_pos +#: model:ir.model.fields,field_description:l10n_es_ticketbai_pos.field_pos_config__tbai_last_invoice_id +msgid "Last TicketBAI Invoice sent" +msgstr "Última factura de TicketBAI enviada" + +#. module: l10n_es_ticketbai_pos +#: model:ir.model.fields,help:l10n_es_ticketbai_pos.field_account_bank_statement_line__tbai_substitution_pos_order_id +#: model:ir.model.fields,help:l10n_es_ticketbai_pos.field_account_move__tbai_substitution_pos_order_id +#: model:ir.model.fields,help:l10n_es_ticketbai_pos.field_account_payment__tbai_substitution_pos_order_id +msgid "Link between a validated Customer Invoice and its substitute." +msgstr "Relación entre la factura de cliente validada y su sustituta." + +#. module: l10n_es_ticketbai_pos +#: model_terms:ir.ui.view,arch_db:l10n_es_ticketbai_pos.view_pos_pos_form_inherit +msgid "Messages" +msgstr "Mensajes" + +#. module: l10n_es_ticketbai_pos +#. openerp-web +#: code:addons/l10n_es_ticketbai_pos/static/src/js/Screens/ClientListScreen/ClientListScreen.js:0 +#: code:addons/l10n_es_ticketbai_pos/static/src/js/Screens/PaymentScreen/PaymentScreen.js:0 +#, python-format +msgid "Non spanish customers are not supported for Simplified Invoice." +msgstr "" +"Los clientes no nacionales no están soportados en factura simplificada." + +#. module: l10n_es_ticketbai_pos +#: model_terms:ir.ui.view,arch_db:l10n_es_ticketbai_pos.view_pos_pos_form_inherit +msgid "Orders" +msgstr "Pedidos" + +#. module: l10n_es_ticketbai_pos +#. openerp-web +#: code:addons/l10n_es_ticketbai_pos/static/src/xml/pos.xml:0 +#, python-format +msgid "PRO FORMA" +msgstr "FORMA PRO" + +#. module: l10n_es_ticketbai_pos +#. openerp-web +#: code:addons/l10n_es_ticketbai_pos/static/src/js/Screens/PaymentScreen/PaymentScreen.js:0 +#, python-format +msgid "Please set Company VAT." +msgstr "Por favor, establezca el NIF de la compañía." + +#. module: l10n_es_ticketbai_pos +#. openerp-web +#: code:addons/l10n_es_ticketbai_pos/static/src/js/Screens/ClientListScreen/ClientListScreen.js:0 +#, python-format +msgid "Please set Country for customer %s." +msgstr "Por favor, establezca el país para el cliente %s." + +#. module: l10n_es_ticketbai_pos +#. openerp-web +#: code:addons/l10n_es_ticketbai_pos/static/src/js/Screens/PaymentScreen/PaymentScreen.js:0 +#, python-format +msgid "Please set VAT Regime Key for fiscal position %s." +msgstr "" +"Por favor, establezca la clave de regímenes de IVA para la posición fiscal " +"%s." + +#. module: l10n_es_ticketbai_pos +#. openerp-web +#: code:addons/l10n_es_ticketbai_pos/static/src/js/Screens/ClientListScreen/ClientListScreen.js:0 +#, python-format +msgid "" +"Please set VAT or TicketBAI Partner Identification Number for customer %s." +msgstr "" +"Por favor, establezca el NIF o el número de identificación TicketBAI para el " +"cliente %s." + +#. module: l10n_es_ticketbai_pos +#. openerp-web +#: code:addons/l10n_es_ticketbai_pos/static/src/js/Screens/PaymentScreen/PaymentScreen.js:0 +#, python-format +msgid "Please set VAT or TicketBAI Partner Identification Number for customer." +msgstr "" +"Por favor, establezca el NIF o el número de identificación TicketBAI para el " +"cliente." + +#. module: l10n_es_ticketbai_pos +#. openerp-web +#: code:addons/l10n_es_ticketbai_pos/static/src/js/Screens/ProductScreen/ProductScreen.js:0 +#: code:addons/l10n_es_ticketbai_pos/static/src/js/models.js:0 +#, python-format +msgid "Please set a tax for product %s." +msgstr "Por favor, establezca un impuesto para el producto %s." + +#. module: l10n_es_ticketbai_pos +#: model_terms:ir.ui.view,arch_db:l10n_es_ticketbai_pos.view_pos_config_form_inherit +msgid "PoS Device Serial Number. As of TicketBAI v1.1, is not required." +msgstr "" +"Número de serie del dispositivo TPV. En TicketBAI v1.1 no es requerido." + +#. module: l10n_es_ticketbai_pos +#: model:ir.model,name:l10n_es_ticketbai_pos.model_pos_config +msgid "Point of Sale Configuration" +msgstr "Configuración del TPV" + +#. module: l10n_es_ticketbai_pos +#: model:ir.model,name:l10n_es_ticketbai_pos.model_pos_order +msgid "Point of Sale Orders" +msgstr "Pedidos del TPV" + +#. module: l10n_es_ticketbai_pos +#: model:ir.model.fields,field_description:l10n_es_ticketbai_pos.field_tbai_invoice__pos_order_id +msgid "Pos Order" +msgstr "Pedidos del TPV" + +#. module: l10n_es_ticketbai_pos +#: model:ir.model.fields,field_description:l10n_es_ticketbai_pos.field_pos_order__tbai_response_ids +#: model_terms:ir.ui.view,arch_db:l10n_es_ticketbai_pos.view_pos_pos_form_inherit +msgid "Responses" +msgstr "Respuestas" + +#. module: l10n_es_ticketbai_pos +#: code:addons/l10n_es_ticketbai_pos/models/pos_config.py:0 +#, python-format +msgid "Simplified Invoice IDs Sequence is required" +msgstr "Secuencia de factura simplificada requerida" + +#. module: l10n_es_ticketbai_pos +#: code:addons/l10n_es_ticketbai_pos/models/pos_order.py:0 +#, python-format +msgid "Simplified Invoice Number Prefix %s is not part of Number %%!" +msgstr "" +"¡Número de factura simplificado El prefijo %s no forma parte del número %%!" + +#. module: l10n_es_ticketbai_pos +#: model:ir.model.fields,field_description:l10n_es_ticketbai_pos.field_account_bank_statement_line__tbai_substitution_pos_order_id +#: model:ir.model.fields,field_description:l10n_es_ticketbai_pos.field_account_move__tbai_substitution_pos_order_id +#: model:ir.model.fields,field_description:l10n_es_ticketbai_pos.field_account_payment__tbai_substitution_pos_order_id +msgid "Tbai Substitution Pos Order" +msgstr "Pedido TPV de sustitución Tbai" + +#. module: l10n_es_ticketbai_pos +#. openerp-web +#: code:addons/l10n_es_ticketbai_pos/static/src/js/Screens/ClientListScreen/ClientListScreen.js:0 +#: code:addons/l10n_es_ticketbai_pos/static/src/js/Screens/PaymentScreen/PaymentScreen.js:0 +#: code:addons/l10n_es_ticketbai_pos/static/src/js/Screens/ProductScreen/ProductScreen.js:0 +#: code:addons/l10n_es_ticketbai_pos/static/src/js/models.js:0 +#: code:addons/l10n_es_ticketbai_pos/static/src/js/tbai_models.js:0 +#: model_terms:ir.ui.view,arch_db:l10n_es_ticketbai_pos.view_pos_config_form_inherit +#: model_terms:ir.ui.view,arch_db:l10n_es_ticketbai_pos.view_pos_pos_form_inherit +#, python-format +msgid "TicketBAI" +msgstr "TiquetBAI" + +#. module: l10n_es_ticketbai_pos +#: model:ir.model.fields,field_description:l10n_es_ticketbai_pos.field_pos_config__tbai_certificate_id +msgid "TicketBAI Certificate" +msgstr "Certificado TicketBAI" + +#. module: l10n_es_ticketbai_pos +#: model_terms:ir.ui.view,arch_db:l10n_es_ticketbai_pos.view_pos_config_form_inherit +msgid "" +"TicketBAI Certificate (optional). If not set, the certificate from the " +"company is used instead." +msgstr "" +"Certificado TicketBAI (opcional). Si no se establece se utiliza el " +"certificado de la compañía." + +#. module: l10n_es_ticketbai_pos +#: model:ir.ui.menu,name:l10n_es_ticketbai_pos.menu_pos_tbai_certificates +msgid "TicketBAI Certificates" +msgstr "TicketBAI Certificados" + +#. module: l10n_es_ticketbai_pos +#. openerp-web +#: code:addons/l10n_es_ticketbai_pos/static/src/js/Screens/PaymentScreen/PaymentScreen.js:0 +#, python-format +msgid "TicketBAI Invoice not built yet. Please try again." +msgstr "Factura TicketBAI no construida aún. Por favor inténtelo de nuevo." + +#. module: l10n_es_ticketbai_pos +#: model:ir.model,name:l10n_es_ticketbai_pos.model_tbai_invoice +#: model:ir.model.fields,field_description:l10n_es_ticketbai_pos.field_pos_order__tbai_invoice_ids +msgid "TicketBAI Invoices" +msgstr "TicketBAI Facturas" + +#. module: l10n_es_ticketbai_pos +#: model:ir.model.fields,field_description:l10n_es_ticketbai_pos.field_pos_order__tbai_invoice_id +msgid "TicketBAI PoS Order" +msgstr "Pedido de TPV TicketBAI" + +#. module: l10n_es_ticketbai_pos +#. openerp-web +#: code:addons/l10n_es_ticketbai_pos/static/src/js/Screens/PaymentScreen/PaymentScreen.js:0 +#, python-format +msgid "TicketBAI certificate not loaded!" +msgstr "¡Error: Certificado TicketBAI no cargado!" + +#. module: l10n_es_ticketbai_pos +#: model:ir.model.fields,field_description:l10n_es_ticketbai_pos.field_pos_config__iface_l10n_es_simplified_invoice +msgid "Use simplified invoices for this POS" +msgstr "Usar Facturas Simplificadas en este Punto de Venta" + +#. module: l10n_es_ticketbai_pos +#: model:ir.model.fields,field_description:l10n_es_ticketbai_pos.field_pos_order__tbai_vat_regime_key +msgid "VAT Regime Key" +msgstr "Clave de regímenes de IVA" + +#. module: l10n_es_ticketbai_pos +#: model_terms:ir.ui.view,arch_db:l10n_es_ticketbai_pos.view_pos_pos_form_inherit +msgid "VAT Regimes" +msgstr "Claves de regímenes de IVA" + +#~ msgid "Journal Entries" +#~ msgstr "Asientos contables" + +#, python-format +#~ msgid "Simplified Invoice Number Prefix %s is not part of Number %s!" +#~ msgstr "" +#~ "El prefijo para facturas simplificadas %s no es parte del número %s!" diff --git a/l10n_es_ticketbai_pos/i18n/eu.po b/l10n_es_ticketbai_pos/i18n/eu.po new file mode 100644 index 00000000000..b45aaad753d --- /dev/null +++ b/l10n_es_ticketbai_pos/i18n/eu.po @@ -0,0 +1,279 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_es_ticketbai_pos +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2022-08-30 11:07+0000\n" +"Last-Translator: olatzavanzosc \n" +"Language-Team: none\n" +"Language: eu\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.3.2\n" + +#. module: l10n_es_ticketbai_pos +#: model_terms:ir.ui.view,arch_db:l10n_es_ticketbai_pos.view_pos_config_form_inherit +msgid "" +"" +msgstr "" +"" + +#. module: l10n_es_ticketbai_pos +#. openerp-web +#: code:addons/l10n_es_ticketbai_pos/static/src/js/Screens/PaymentScreen/PaymentScreen.js:0 +#, python-format +msgid "At least one product does not have a tax." +msgstr "Gutxienez produktu batek ez du zergarik." + +#. module: l10n_es_ticketbai_pos +#: model_terms:ir.ui.view,arch_db:l10n_es_ticketbai_pos.view_pos_config_form_inherit +msgid "Certificate" +msgstr "Ziurtagiria" + +#. module: l10n_es_ticketbai_pos +#: model:ir.model.fields,field_description:l10n_es_ticketbai_pos.field_pos_config__tbai_device_serial_number +#: model_terms:ir.ui.view,arch_db:l10n_es_ticketbai_pos.view_pos_config_form_inherit +msgid "Device Serial Number" +msgstr "Gailuaren serie zenbakia" + +#. module: l10n_es_ticketbai_pos +#: model:ir.model.fields,field_description:l10n_es_ticketbai_pos.field_pos_config__tbai_enabled +#: model:ir.model.fields,field_description:l10n_es_ticketbai_pos.field_pos_order__tbai_enabled +msgid "Enable TicketBAI" +msgstr "Gaitu TicketBAI" + +#. module: l10n_es_ticketbai_pos +#: model_terms:ir.ui.view,arch_db:l10n_es_ticketbai_pos.view_pos_pos_form_inherit +msgid "Files Sent" +msgstr "Bidalitako fitxategiak" + +#. module: l10n_es_ticketbai_pos +#: model:ir.model,name:l10n_es_ticketbai_pos.model_account_move +msgid "Journal Entry" +msgstr "Egunkari Sarrera" + +#. module: l10n_es_ticketbai_pos +#: model:ir.model.fields,field_description:l10n_es_ticketbai_pos.field_pos_config__tbai_last_invoice_id +msgid "Last TicketBAI Invoice sent" +msgstr "Bidalitako azken TicketBAI faktura" + +#. module: l10n_es_ticketbai_pos +#: model:ir.model.fields,help:l10n_es_ticketbai_pos.field_account_bank_statement_line__tbai_substitution_pos_order_id +#: model:ir.model.fields,help:l10n_es_ticketbai_pos.field_account_move__tbai_substitution_pos_order_id +#: model:ir.model.fields,help:l10n_es_ticketbai_pos.field_account_payment__tbai_substitution_pos_order_id +msgid "Link between a validated Customer Invoice and its substitute." +msgstr "" +"Balidatutako Bezeroaren faktura baten eta haren ordezkoaren arteko lotura." + +#. module: l10n_es_ticketbai_pos +#: model_terms:ir.ui.view,arch_db:l10n_es_ticketbai_pos.view_pos_pos_form_inherit +msgid "Messages" +msgstr "Mezuak" + +#. module: l10n_es_ticketbai_pos +#. openerp-web +#: code:addons/l10n_es_ticketbai_pos/static/src/js/Screens/ClientListScreen/ClientListScreen.js:0 +#: code:addons/l10n_es_ticketbai_pos/static/src/js/Screens/PaymentScreen/PaymentScreen.js:0 +#, python-format +msgid "Non spanish customers are not supported for Simplified Invoice." +msgstr "" +"Espainiakoak ez diren bezeroak ez dira onartzen Faktura Sinplifikatuan." + +#. module: l10n_es_ticketbai_pos +#: model_terms:ir.ui.view,arch_db:l10n_es_ticketbai_pos.view_pos_pos_form_inherit +msgid "Orders" +msgstr "Aginduak" + +#. module: l10n_es_ticketbai_pos +#. openerp-web +#: code:addons/l10n_es_ticketbai_pos/static/src/xml/pos.xml:0 +#, python-format +msgid "PRO FORMA" +msgstr "PRO FORMA" + +#. module: l10n_es_ticketbai_pos +#. openerp-web +#: code:addons/l10n_es_ticketbai_pos/static/src/js/Screens/PaymentScreen/PaymentScreen.js:0 +#, python-format +msgid "Please set Company VAT." +msgstr "Mesedez, ezarri Enpresaren IFZa." + +#. module: l10n_es_ticketbai_pos +#. openerp-web +#: code:addons/l10n_es_ticketbai_pos/static/src/js/Screens/ClientListScreen/ClientListScreen.js:0 +#, python-format +msgid "Please set Country for customer %s." +msgstr "Mesedez, ezarri Herrialdea %s bezeroarentzat." + +#. module: l10n_es_ticketbai_pos +#. openerp-web +#: code:addons/l10n_es_ticketbai_pos/static/src/js/Screens/PaymentScreen/PaymentScreen.js:0 +#, python-format +msgid "Please set VAT Regime Key for fiscal position %s." +msgstr "Ezarri BEZaren erregimen gakoa %s posizio fiskalarentzat." + +#. module: l10n_es_ticketbai_pos +#. openerp-web +#: code:addons/l10n_es_ticketbai_pos/static/src/js/Screens/ClientListScreen/ClientListScreen.js:0 +#, python-format +msgid "" +"Please set VAT or TicketBAI Partner Identification Number for customer %s." +msgstr "" +"Ezarri BEZa edo TicketBAI Bazkidearen Identifikazio Zenbakia %s " +"bezeroarentzat." + +#. module: l10n_es_ticketbai_pos +#. openerp-web +#: code:addons/l10n_es_ticketbai_pos/static/src/js/Screens/PaymentScreen/PaymentScreen.js:0 +#, python-format +msgid "Please set VAT or TicketBAI Partner Identification Number for customer." +msgstr "" +"Ezarri IFZa edo TicketBAI Bazkidearen Identifikazio Zenbakia bezeroarentzat." + +#. module: l10n_es_ticketbai_pos +#. openerp-web +#: code:addons/l10n_es_ticketbai_pos/static/src/js/Screens/ProductScreen/ProductScreen.js:0 +#: code:addons/l10n_es_ticketbai_pos/static/src/js/models.js:0 +#, python-format +msgid "Please set a tax for product %s." +msgstr "Ezarri zerga bat %s produktuari." + +#. module: l10n_es_ticketbai_pos +#: model_terms:ir.ui.view,arch_db:l10n_es_ticketbai_pos.view_pos_config_form_inherit +msgid "PoS Device Serial Number. As of TicketBAI v1.1, is not required." +msgstr "" +"PoS gailuaren serie zenbakia. TicketBAI v1.1etik aurrera, ez da beharrezkoa." + +#. module: l10n_es_ticketbai_pos +#: model:ir.model,name:l10n_es_ticketbai_pos.model_pos_config +msgid "Point of Sale Configuration" +msgstr "Salmenta puntuaren konfigurazioa" + +#. module: l10n_es_ticketbai_pos +#: model:ir.model,name:l10n_es_ticketbai_pos.model_pos_order +msgid "Point of Sale Orders" +msgstr "Salmenta puntuko eskaerak" + +#. module: l10n_es_ticketbai_pos +#: model:ir.model.fields,field_description:l10n_es_ticketbai_pos.field_tbai_invoice__pos_order_id +msgid "Pos Order" +msgstr "Pos Agindua" + +#. module: l10n_es_ticketbai_pos +#: model:ir.model.fields,field_description:l10n_es_ticketbai_pos.field_pos_order__tbai_response_ids +#: model_terms:ir.ui.view,arch_db:l10n_es_ticketbai_pos.view_pos_pos_form_inherit +msgid "Responses" +msgstr "Erantzunak" + +#. module: l10n_es_ticketbai_pos +#: code:addons/l10n_es_ticketbai_pos/models/pos_config.py:0 +#, python-format +msgid "Simplified Invoice IDs Sequence is required" +msgstr "Faktura sinplifikatuaren IDaren sekuentzia beharrezkoa da" + +#. module: l10n_es_ticketbai_pos +#: code:addons/l10n_es_ticketbai_pos/models/pos_order.py:0 +#, python-format +msgid "Simplified Invoice Number Prefix %s is not part of Number %%!" +msgstr "" + +#. module: l10n_es_ticketbai_pos +#: model:ir.model.fields,field_description:l10n_es_ticketbai_pos.field_account_bank_statement_line__tbai_substitution_pos_order_id +#: model:ir.model.fields,field_description:l10n_es_ticketbai_pos.field_account_move__tbai_substitution_pos_order_id +#: model:ir.model.fields,field_description:l10n_es_ticketbai_pos.field_account_payment__tbai_substitution_pos_order_id +msgid "Tbai Substitution Pos Order" +msgstr "Tbai Ordezkapen Pos Agindua" + +#. module: l10n_es_ticketbai_pos +#. openerp-web +#: code:addons/l10n_es_ticketbai_pos/static/src/js/Screens/ClientListScreen/ClientListScreen.js:0 +#: code:addons/l10n_es_ticketbai_pos/static/src/js/Screens/PaymentScreen/PaymentScreen.js:0 +#: code:addons/l10n_es_ticketbai_pos/static/src/js/Screens/ProductScreen/ProductScreen.js:0 +#: code:addons/l10n_es_ticketbai_pos/static/src/js/models.js:0 +#: code:addons/l10n_es_ticketbai_pos/static/src/js/tbai_models.js:0 +#: model_terms:ir.ui.view,arch_db:l10n_es_ticketbai_pos.view_pos_config_form_inherit +#: model_terms:ir.ui.view,arch_db:l10n_es_ticketbai_pos.view_pos_pos_form_inherit +#, python-format +msgid "TicketBAI" +msgstr "TicketBAI" + +#. module: l10n_es_ticketbai_pos +#: model:ir.model.fields,field_description:l10n_es_ticketbai_pos.field_pos_config__tbai_certificate_id +msgid "TicketBAI Certificate" +msgstr "TicketBAI Ziurtagiria" + +#. module: l10n_es_ticketbai_pos +#: model_terms:ir.ui.view,arch_db:l10n_es_ticketbai_pos.view_pos_config_form_inherit +msgid "" +"TicketBAI Certificate (optional). If not set, the certificate from the " +"company is used instead." +msgstr "" +"TicketBAI Ziurtagiria (aukerakoa). Ezarri ez bada, enpresaren ziurtagiria " +"erabiltzen da." + +#. module: l10n_es_ticketbai_pos +#: model:ir.ui.menu,name:l10n_es_ticketbai_pos.menu_pos_tbai_certificates +msgid "TicketBAI Certificates" +msgstr "TicketBAI Ziurtagiriak" + +#. module: l10n_es_ticketbai_pos +#. openerp-web +#: code:addons/l10n_es_ticketbai_pos/static/src/js/Screens/PaymentScreen/PaymentScreen.js:0 +#, python-format +msgid "TicketBAI Invoice not built yet. Please try again." +msgstr "TicketBAI faktura ez da eraiki oraindik. Saiatu berriro mesedez." + +#. module: l10n_es_ticketbai_pos +#: model:ir.model,name:l10n_es_ticketbai_pos.model_tbai_invoice +#: model:ir.model.fields,field_description:l10n_es_ticketbai_pos.field_pos_order__tbai_invoice_ids +msgid "TicketBAI Invoices" +msgstr "TicketBAI Fakturak" + +#. module: l10n_es_ticketbai_pos +#: model:ir.model.fields,field_description:l10n_es_ticketbai_pos.field_pos_order__tbai_invoice_id +msgid "TicketBAI PoS Order" +msgstr "TicketBAI PoS Agindua" + +#. module: l10n_es_ticketbai_pos +#. openerp-web +#: code:addons/l10n_es_ticketbai_pos/static/src/js/Screens/PaymentScreen/PaymentScreen.js:0 +#, python-format +msgid "TicketBAI certificate not loaded!" +msgstr "TicketBAI ziurtagiria ez da kargatu!" + +#. module: l10n_es_ticketbai_pos +#: model:ir.model.fields,field_description:l10n_es_ticketbai_pos.field_pos_config__iface_l10n_es_simplified_invoice +msgid "Use simplified invoices for this POS" +msgstr "Erabili faktura sinplifikatuak POS honetarako" + +#. module: l10n_es_ticketbai_pos +#: model:ir.model.fields,field_description:l10n_es_ticketbai_pos.field_pos_order__tbai_vat_regime_key +msgid "VAT Regime Key" +msgstr "IFZaren erregimenaren gakoa" + +#. module: l10n_es_ticketbai_pos +#: model_terms:ir.ui.view,arch_db:l10n_es_ticketbai_pos.view_pos_pos_form_inherit +msgid "VAT Regimes" +msgstr "IFZaren erregimenak" + +#~ msgid "Display Name" +#~ msgstr "Bistaratutako izena" + +#~ msgid "ID" +#~ msgstr "ID" + +#~ msgid "Last Modified on" +#~ msgstr "Azken aldaketa eguna" + +#, python-format +#~ msgid "Simplified Invoice Number Prefix %s is not part of Number %s!" +#~ msgstr "" +#~ "Sinplifikatutako faktura-zenbakiaren %s aurrizkia ez da %s zenbakiaren " +#~ "parte!" diff --git a/l10n_es_ticketbai_pos/i18n/l10n_es_ticketbai_pos.pot b/l10n_es_ticketbai_pos/i18n/l10n_es_ticketbai_pos.pot new file mode 100644 index 00000000000..a696181990d --- /dev/null +++ b/l10n_es_ticketbai_pos/i18n/l10n_es_ticketbai_pos.pot @@ -0,0 +1,256 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_es_ticketbai_pos +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: l10n_es_ticketbai_pos +#: model_terms:ir.ui.view,arch_db:l10n_es_ticketbai_pos.view_pos_config_form_inherit +msgid "" +"" +msgstr "" + +#. module: l10n_es_ticketbai_pos +#. openerp-web +#: code:addons/l10n_es_ticketbai_pos/static/src/js/Screens/PaymentScreen/PaymentScreen.js:0 +#, python-format +msgid "At least one product does not have a tax." +msgstr "" + +#. module: l10n_es_ticketbai_pos +#: model_terms:ir.ui.view,arch_db:l10n_es_ticketbai_pos.view_pos_config_form_inherit +msgid "Certificate" +msgstr "" + +#. module: l10n_es_ticketbai_pos +#: model:ir.model.fields,field_description:l10n_es_ticketbai_pos.field_pos_config__tbai_device_serial_number +#: model_terms:ir.ui.view,arch_db:l10n_es_ticketbai_pos.view_pos_config_form_inherit +msgid "Device Serial Number" +msgstr "" + +#. module: l10n_es_ticketbai_pos +#: model:ir.model.fields,field_description:l10n_es_ticketbai_pos.field_pos_config__tbai_enabled +#: model:ir.model.fields,field_description:l10n_es_ticketbai_pos.field_pos_order__tbai_enabled +msgid "Enable TicketBAI" +msgstr "" + +#. module: l10n_es_ticketbai_pos +#: model_terms:ir.ui.view,arch_db:l10n_es_ticketbai_pos.view_pos_pos_form_inherit +msgid "Files Sent" +msgstr "" + +#. module: l10n_es_ticketbai_pos +#: model:ir.model,name:l10n_es_ticketbai_pos.model_account_move +msgid "Journal Entry" +msgstr "" + +#. module: l10n_es_ticketbai_pos +#: model:ir.model.fields,field_description:l10n_es_ticketbai_pos.field_pos_config__tbai_last_invoice_id +msgid "Last TicketBAI Invoice sent" +msgstr "" + +#. module: l10n_es_ticketbai_pos +#: model:ir.model.fields,help:l10n_es_ticketbai_pos.field_account_bank_statement_line__tbai_substitution_pos_order_id +#: model:ir.model.fields,help:l10n_es_ticketbai_pos.field_account_move__tbai_substitution_pos_order_id +#: model:ir.model.fields,help:l10n_es_ticketbai_pos.field_account_payment__tbai_substitution_pos_order_id +msgid "Link between a validated Customer Invoice and its substitute." +msgstr "" + +#. module: l10n_es_ticketbai_pos +#: model_terms:ir.ui.view,arch_db:l10n_es_ticketbai_pos.view_pos_pos_form_inherit +msgid "Messages" +msgstr "" + +#. module: l10n_es_ticketbai_pos +#. openerp-web +#: code:addons/l10n_es_ticketbai_pos/static/src/js/Screens/ClientListScreen/ClientListScreen.js:0 +#: code:addons/l10n_es_ticketbai_pos/static/src/js/Screens/PaymentScreen/PaymentScreen.js:0 +#, python-format +msgid "Non spanish customers are not supported for Simplified Invoice." +msgstr "" + +#. module: l10n_es_ticketbai_pos +#: model_terms:ir.ui.view,arch_db:l10n_es_ticketbai_pos.view_pos_pos_form_inherit +msgid "Orders" +msgstr "" + +#. module: l10n_es_ticketbai_pos +#. openerp-web +#: code:addons/l10n_es_ticketbai_pos/static/src/xml/pos.xml:0 +#, python-format +msgid "PRO FORMA" +msgstr "" + +#. module: l10n_es_ticketbai_pos +#. openerp-web +#: code:addons/l10n_es_ticketbai_pos/static/src/js/Screens/PaymentScreen/PaymentScreen.js:0 +#, python-format +msgid "Please set Company VAT." +msgstr "" + +#. module: l10n_es_ticketbai_pos +#. openerp-web +#: code:addons/l10n_es_ticketbai_pos/static/src/js/Screens/ClientListScreen/ClientListScreen.js:0 +#, python-format +msgid "Please set Country for customer %s." +msgstr "" + +#. module: l10n_es_ticketbai_pos +#. openerp-web +#: code:addons/l10n_es_ticketbai_pos/static/src/js/Screens/PaymentScreen/PaymentScreen.js:0 +#, python-format +msgid "Please set VAT Regime Key for fiscal position %s." +msgstr "" + +#. module: l10n_es_ticketbai_pos +#. openerp-web +#: code:addons/l10n_es_ticketbai_pos/static/src/js/Screens/ClientListScreen/ClientListScreen.js:0 +#, python-format +msgid "" +"Please set VAT or TicketBAI Partner Identification Number for customer %s." +msgstr "" + +#. module: l10n_es_ticketbai_pos +#. openerp-web +#: code:addons/l10n_es_ticketbai_pos/static/src/js/Screens/PaymentScreen/PaymentScreen.js:0 +#, python-format +msgid "" +"Please set VAT or TicketBAI Partner Identification Number for customer." +msgstr "" + +#. module: l10n_es_ticketbai_pos +#. openerp-web +#: code:addons/l10n_es_ticketbai_pos/static/src/js/Screens/ProductScreen/ProductScreen.js:0 +#: code:addons/l10n_es_ticketbai_pos/static/src/js/models.js:0 +#, python-format +msgid "Please set a tax for product %s." +msgstr "" + +#. module: l10n_es_ticketbai_pos +#: model_terms:ir.ui.view,arch_db:l10n_es_ticketbai_pos.view_pos_config_form_inherit +msgid "PoS Device Serial Number. As of TicketBAI v1.1, is not required." +msgstr "" + +#. module: l10n_es_ticketbai_pos +#: model:ir.model,name:l10n_es_ticketbai_pos.model_pos_config +msgid "Point of Sale Configuration" +msgstr "" + +#. module: l10n_es_ticketbai_pos +#: model:ir.model,name:l10n_es_ticketbai_pos.model_pos_order +msgid "Point of Sale Orders" +msgstr "" + +#. module: l10n_es_ticketbai_pos +#: model:ir.model.fields,field_description:l10n_es_ticketbai_pos.field_tbai_invoice__pos_order_id +msgid "Pos Order" +msgstr "" + +#. module: l10n_es_ticketbai_pos +#: model:ir.model.fields,field_description:l10n_es_ticketbai_pos.field_pos_order__tbai_response_ids +#: model_terms:ir.ui.view,arch_db:l10n_es_ticketbai_pos.view_pos_pos_form_inherit +msgid "Responses" +msgstr "" + +#. module: l10n_es_ticketbai_pos +#: code:addons/l10n_es_ticketbai_pos/models/pos_config.py:0 +#: code:addons/l10n_es_ticketbai_pos/models/pos_config.py:0 +#: code:addons/l10n_es_ticketbai_pos/models/pos_config.py:0 +#, python-format +msgid "Simplified Invoice IDs Sequence is required" +msgstr "" + +#. module: l10n_es_ticketbai_pos +#: code:addons/l10n_es_ticketbai_pos/models/pos_order.py:0 +#, python-format +msgid "Simplified Invoice Number Prefix %s is not part of Number %%!" +msgstr "" + +#. module: l10n_es_ticketbai_pos +#: model:ir.model.fields,field_description:l10n_es_ticketbai_pos.field_account_bank_statement_line__tbai_substitution_pos_order_id +#: model:ir.model.fields,field_description:l10n_es_ticketbai_pos.field_account_move__tbai_substitution_pos_order_id +#: model:ir.model.fields,field_description:l10n_es_ticketbai_pos.field_account_payment__tbai_substitution_pos_order_id +msgid "Tbai Substitution Pos Order" +msgstr "" + +#. module: l10n_es_ticketbai_pos +#. openerp-web +#: code:addons/l10n_es_ticketbai_pos/static/src/js/Screens/ClientListScreen/ClientListScreen.js:0 +#: code:addons/l10n_es_ticketbai_pos/static/src/js/Screens/ClientListScreen/ClientListScreen.js:0 +#: code:addons/l10n_es_ticketbai_pos/static/src/js/Screens/ClientListScreen/ClientListScreen.js:0 +#: code:addons/l10n_es_ticketbai_pos/static/src/js/Screens/PaymentScreen/PaymentScreen.js:0 +#: code:addons/l10n_es_ticketbai_pos/static/src/js/Screens/ProductScreen/ProductScreen.js:0 +#: code:addons/l10n_es_ticketbai_pos/static/src/js/models.js:0 +#: code:addons/l10n_es_ticketbai_pos/static/src/js/tbai_models.js:0 +#: model_terms:ir.ui.view,arch_db:l10n_es_ticketbai_pos.view_pos_config_form_inherit +#: model_terms:ir.ui.view,arch_db:l10n_es_ticketbai_pos.view_pos_pos_form_inherit +#, python-format +msgid "TicketBAI" +msgstr "" + +#. module: l10n_es_ticketbai_pos +#: model:ir.model.fields,field_description:l10n_es_ticketbai_pos.field_pos_config__tbai_certificate_id +msgid "TicketBAI Certificate" +msgstr "" + +#. module: l10n_es_ticketbai_pos +#: model_terms:ir.ui.view,arch_db:l10n_es_ticketbai_pos.view_pos_config_form_inherit +msgid "" +"TicketBAI Certificate (optional). If not set, the certificate from the " +"company is used instead." +msgstr "" + +#. module: l10n_es_ticketbai_pos +#: model:ir.ui.menu,name:l10n_es_ticketbai_pos.menu_pos_tbai_certificates +msgid "TicketBAI Certificates" +msgstr "" + +#. module: l10n_es_ticketbai_pos +#. openerp-web +#: code:addons/l10n_es_ticketbai_pos/static/src/js/Screens/PaymentScreen/PaymentScreen.js:0 +#, python-format +msgid "TicketBAI Invoice not built yet. Please try again." +msgstr "" + +#. module: l10n_es_ticketbai_pos +#: model:ir.model,name:l10n_es_ticketbai_pos.model_tbai_invoice +#: model:ir.model.fields,field_description:l10n_es_ticketbai_pos.field_pos_order__tbai_invoice_ids +msgid "TicketBAI Invoices" +msgstr "" + +#. module: l10n_es_ticketbai_pos +#: model:ir.model.fields,field_description:l10n_es_ticketbai_pos.field_pos_order__tbai_invoice_id +msgid "TicketBAI PoS Order" +msgstr "" + +#. module: l10n_es_ticketbai_pos +#. openerp-web +#: code:addons/l10n_es_ticketbai_pos/static/src/js/Screens/PaymentScreen/PaymentScreen.js:0 +#, python-format +msgid "TicketBAI certificate not loaded!" +msgstr "" + +#. module: l10n_es_ticketbai_pos +#: model:ir.model.fields,field_description:l10n_es_ticketbai_pos.field_pos_config__iface_l10n_es_simplified_invoice +msgid "Use simplified invoices for this POS" +msgstr "" + +#. module: l10n_es_ticketbai_pos +#: model:ir.model.fields,field_description:l10n_es_ticketbai_pos.field_pos_order__tbai_vat_regime_key +msgid "VAT Regime Key" +msgstr "" + +#. module: l10n_es_ticketbai_pos +#: model_terms:ir.ui.view,arch_db:l10n_es_ticketbai_pos.view_pos_pos_form_inherit +msgid "VAT Regimes" +msgstr "" diff --git a/l10n_es_ticketbai_pos/models/__init__.py b/l10n_es_ticketbai_pos/models/__init__.py new file mode 100644 index 00000000000..767b0eaa8e9 --- /dev/null +++ b/l10n_es_ticketbai_pos/models/__init__.py @@ -0,0 +1,4 @@ +from . import account_move +from . import pos_config +from . import pos_order +from . import ticketbai_invoice diff --git a/l10n_es_ticketbai_pos/models/account_move.py b/l10n_es_ticketbai_pos/models/account_move.py new file mode 100644 index 00000000000..f40884db08f --- /dev/null +++ b/l10n_es_ticketbai_pos/models/account_move.py @@ -0,0 +1,64 @@ +# Copyright 2021 Binovo IT Human Project SL +# Copyright 2022 Landoo Sistemas de Informacion SL +# Copyright 2022 Advanced Programming Solutions SL +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import fields, models + + +class AccountMove(models.Model): + _inherit = "account.move" + + tbai_substitution_pos_order_id = fields.Many2one( + comodel_name="pos.order", + copy=False, + help="Link between a validated Customer Invoice and its substitute.", + ) + + def tbai_prepare_invoice_values(self): + res = super().tbai_prepare_invoice_values() + if not res.get("vat_regime_key", False): + res["vat_regime_key"] = ( + self.env["tbai.vat.regime.key"] + .search([("code", "=", "01")], limit=1) + .code + ) + if self.tbai_substitute_simplified_invoice: + refunded_pos_order = self.tbai_substitution_pos_order_id + res.update( + { + "is_invoice_refund": False, + "tbai_invoice_refund_ids": [ + ( + 0, + 0, + { + "number_prefix": ( + refunded_pos_order.tbai_get_value_serie_factura() + ), + "number": ( + refunded_pos_order.tbai_get_value_num_factura() + ), + "expedition_date": ( + refunded_pos_order.tbai_get_value_fecha_expedicion_factura() + ), + }, + ) + ], + } + ) + return res + + # For Ticketbai is mandatory to specify origin invoice in refunds + def _post(self, soft=True): + def set_reverse_entries(self): + for invoice in self: + pos_order_ids = invoice.sudo().pos_order_ids + for pos_order in pos_order_ids: + pos_refunded_orders = pos_order.refunded_order_ids + for refunded_order_id in pos_refunded_orders: + refunded_invoice_id = refunded_order_id.account_move + invoice.reversed_entry_id = refunded_invoice_id.id + + set_reverse_entries(self) + res = super()._post(soft) + return res diff --git a/l10n_es_ticketbai_pos/models/pos_config.py b/l10n_es_ticketbai_pos/models/pos_config.py new file mode 100644 index 00000000000..95654fe8128 --- /dev/null +++ b/l10n_es_ticketbai_pos/models/pos_config.py @@ -0,0 +1,90 @@ +# Copyright 2021 Binovo IT Human Project SL +# Copyright 2022 Landoo Sistemas de Informacion SL +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +import base64 +import logging + +from odoo import _, api, exceptions, fields, models + +_logger = logging.getLogger(__name__) + + +try: + from cryptography.hazmat.primitives.serialization import ( + BestAvailableEncryption, + NoEncryption, + pkcs12, + ) +except (ImportError, IOError) as err: + _logger.error(err) + + +class PosConfig(models.Model): + _inherit = "pos.config" + + tbai_enabled = fields.Boolean(related="company_id.tbai_enabled", readonly=True) + tbai_device_serial_number = fields.Char(string="Device Serial Number") + tbai_last_invoice_id = fields.Many2one( + string="Last TicketBAI Invoice sent", comodel_name="tbai.invoice", copy=False + ) + tbai_certificate_id = fields.Many2one( + comodel_name="tbai.certificate", + string="TicketBAI Certificate", + domain="[('company_id', '=', company_id)]", + copy=False, + ) + iface_l10n_es_simplified_invoice = fields.Boolean(default=True) + + def get_tbai_p12_and_friendlyname(self): + self.ensure_one() + record = self.sudo() + if record.tbai_enabled: + if record.tbai_certificate_id: + # Serialize new PKCS12 unencrypted object + p12 = record.tbai_certificate_id.get_p12() + p12_priv_key = p12[0] + p12_cert = p12[1] + p12_friendlyname = record.tbai_certificate_id.name.encode("utf-8") + p12_password = record.tbai_certificate_id.password.encode() + p12_encryption = BestAvailableEncryption(p12_password) + certificate = pkcs12.serialize_key_and_certificates( + p12_friendlyname, p12_priv_key, p12_cert, None, p12_encryption + ) + + tbai_p12 = base64.b64encode(certificate) + tbai_p12_friendlyname = p12_friendlyname + else: + p12 = record.company_id.tbai_aeat_certificate_id.get_p12() + p12_priv_key = p12[0] + p12_cert = p12[1] + p12_friendlyname = ( + record.company_id.tbai_aeat_certificate_id.name.encode("utf-8") + ) + p12_encryption = NoEncryption() + p12_password = False + certificate = pkcs12.serialize_key_and_certificates( + p12_friendlyname, p12_priv_key, p12_cert, None, p12_encryption + ) + tbai_p12 = base64.b64encode(certificate) + tbai_p12_friendlyname = p12_friendlyname + else: + tbai_p12 = None + tbai_p12_friendlyname = None + return tbai_p12, tbai_p12_friendlyname, p12_password + + @api.constrains("tbai_enabled", "is_simplified_config") + def _check_tbai(self): + if self.tbai_enabled and not self.is_simplified_config: + raise exceptions.ValidationError( + _("Simplified Invoice IDs Sequence is required") + ) + + def _check_before_creating_new_session(self): + res = super()._check_before_creating_new_session() + self._check_tbai() + return res + + def open_existing_session_cb(self): + self.ensure_one() + self._check_tbai() + return super().open_existing_session_cb() diff --git a/l10n_es_ticketbai_pos/models/pos_order.py b/l10n_es_ticketbai_pos/models/pos_order.py new file mode 100644 index 00000000000..00edf54f260 --- /dev/null +++ b/l10n_es_ticketbai_pos/models/pos_order.py @@ -0,0 +1,275 @@ +# Copyright 2021 Binovo IT Human Project SL +# Copyright 2022 Landoo Sistemas de Informacion SL +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +import base64 + +from odoo import _, api, exceptions, fields, models +from odoo.tools import DEFAULT_SERVER_DATE_FORMAT + +from odoo.addons.l10n_es_ticketbai_api.models.ticketbai_invoice import ( + SiNoType, + TicketBaiInvoiceState, +) +from odoo.addons.l10n_es_ticketbai_api.models.ticketbai_invoice_tax import ( + NotExemptedType, +) +from odoo.addons.l10n_es_ticketbai_api.ticketbai.xml_schema import TicketBaiSchema + + +class PosOrder(models.Model): + _inherit = "pos.order" + + tbai_enabled = fields.Boolean(related="company_id.tbai_enabled", readonly=True) + tbai_invoice_id = fields.Many2one( + comodel_name="tbai.invoice", string="TicketBAI PoS Order", copy=False + ) + tbai_invoice_ids = fields.One2many( + comodel_name="tbai.invoice", + inverse_name="pos_order_id", + string="TicketBAI Invoices", + ) + tbai_response_ids = fields.Many2many( + comodel_name="tbai.response", + compute="_compute_tbai_response_ids", + string="Responses", + ) + tbai_vat_regime_key = fields.Many2one( + comodel_name="tbai.vat.regime.key", string="VAT Regime Key", copy=True + ) + + @api.depends("tbai_invoice_ids", "tbai_invoice_ids.state") + def _compute_tbai_response_ids(self): + for record in self: + record.tbai_response_ids = [ + (6, 0, record.tbai_invoice_ids.mapped("tbai_response_ids").ids) + ] + + @api.model + def _order_fields(self, ui_order): + res = super()._order_fields(ui_order) + session = self.env["pos.session"].browse(ui_order["pos_session_id"]) + if session.config_id.tbai_enabled and not ui_order.get("to_invoice", False): + res["tbai_vat_regime_key"] = ui_order.get("tbai_vat_regime_key", False) + return res + + def tbai_prepare_invoice_values(self, pos_order=None): + self.ensure_one() + partner = self.partner_id + prefix = self.tbai_get_value_serie_factura() + number = self.tbai_get_value_num_factura() + expedition_date = self.tbai_get_value_fecha_expedicion_factura() + expedition_hour = self.tbai_get_value_hora_expedicion_factura() + vals = { + "schema": TicketBaiSchema.TicketBai.value, + "company_id": self.company_id.id, + "simplified_invoice": SiNoType.S.value, + "pos_order_id": self.id, + "name": self.l10n_es_unique_id, + "number_prefix": prefix, + "number": number, + "expedition_date": expedition_date, + "expedition_hour": expedition_hour, + "description": "/", + "amount_total": "%.2f" % self.amount_total, + "vat_regime_key": self.tbai_vat_regime_key.code, + "state": TicketBaiInvoiceState.pending.value, + } + if partner: + vals["tbai_customer_ids"] = [ + ( + 0, + 0, + { + "name": partner.tbai_get_value_apellidos_nombre_razon_social(), + "country_code": partner._parse_aeat_vat_info()[0], + "nif": partner.tbai_get_value_nif(), + "identification_number": partner.tbai_partner_identification_number + or partner.vat, + "idtype": partner.tbai_partner_idtype, + "address": partner.tbai_get_value_direccion(), + "zip": partner.zip, + }, + ) + ] + if pos_order is None: + vals["previous_tbai_invoice_id"] = self.config_id.tbai_last_invoice_id.id + else: + previous_order_pos_reference = pos_order.get( + "tbai_previous_order_pos_reference", False + ) + if previous_order_pos_reference: + tbai_previous_order = self.search( + [("l10n_es_unique_id", "=", previous_order_pos_reference)] + ) + vals[ + "previous_tbai_invoice_id" + ] = tbai_previous_order.tbai_invoice_id.id + datas = base64.b64encode(pos_order["data"]["tbai_datas"].encode("utf-8")) + vals.update( + { + "datas": datas, + "datas_fname": "%s.xsig" % self.l10n_es_unique_id.replace("/", "-"), + "file_size": len(datas), + "signature_value": pos_order["data"]["tbai_signature_value"], + } + ) + gipuzkoa_tax_agency = self.env.ref( + "l10n_es_ticketbai_api.tbai_tax_agency_gipuzkoa" + ) + araba_tax_agency = self.env.ref("l10n_es_ticketbai_api.tbai_tax_agency_araba") + tax_agency = self.company_id.tbai_tax_agency_id + is_gipuzkoa_tax_agency = tax_agency == gipuzkoa_tax_agency + is_araba_tax_agency = tax_agency == araba_tax_agency + taxes = {} + lines = [] + for line in self.lines: + for tax in line.tax_ids_after_fiscal_position: + taxes.setdefault( + tax.id, + { + "is_subject_to": True, + "is_exempted": False, + "not_exempted_type": NotExemptedType.S1.value, + "base": 0.0, + "amount": tax.amount, + "amount_total": 0.0, + }, + ) + price = line.price_unit * (1 - (line.discount or 0.0) / 100.0) + computed_tax = tax.compute_all( + price, + self.pricelist_id.currency_id, + line.qty, + product=line.product_id, + partner=partner, + ) + amount_total = ( + computed_tax["total_included"] - computed_tax["total_excluded"] + ) + taxes[tax.id]["base"] += computed_tax["total_excluded"] + taxes[tax.id]["amount_total"] += amount_total + if is_gipuzkoa_tax_agency or is_araba_tax_agency: + lines.append( + ( + 0, + 0, + { + "description": line.name, + "quantity": "%.2f" % line.qty, + "price_unit": "%.8f" % line.price_unit, + "discount_amount": "%.2f" + % (line.qty * line.price_unit * line.discount / 100.0), + "amount_total": "%.2f" % line.price_subtotal_incl, + }, + ) + ) + vals["tbai_tax_ids"] = [] + for _tax_id, tax_values in taxes.items(): + tax_values["base"] = "%.2f" % tax_values["base"] + tax_values["amount"] = "%.2f" % tax_values["amount"] + tax_values["amount_total"] = "%.2f" % tax_values["amount_total"] + vals["tbai_tax_ids"].append((0, 0, tax_values)) + if is_gipuzkoa_tax_agency or is_araba_tax_agency: + vals["tbai_invoice_line_ids"] = lines + return vals + + def _tbai_build_invoice(self): + for record in self: + vals = record.tbai_prepare_invoice_values() + tbai_invoice = self.env["tbai.invoice"].create(vals) + tbai_invoice.build_tbai_simplified_invoice() + record.tbai_invoice_id = tbai_invoice.id + + @api.model + def _process_order(self, pos_order, draft, existing_order): + if draft: + return super()._process_order(pos_order, draft, existing_order) + if pos_order["data"].get("tbai_vat_regime_key", False) and isinstance( + pos_order["data"]["tbai_vat_regime_key"], str + ): + regime_key = pos_order["data"]["tbai_vat_regime_key"] + pos_order["data"]["tbai_vat_regime_key"] = ( + self.env["tbai.vat.regime.key"] + .search([("code", "=", regime_key)], limit=1) + .id + ) + order_id = super()._process_order(pos_order, draft, existing_order) + order = self.env["pos.order"].browse(order_id) + if order.config_id.tbai_enabled and not pos_order.get("to_invoice", False): + vals = order.tbai_prepare_invoice_values(pos_order) + order.tbai_invoice_id = self.env["tbai.invoice"].sudo().create(vals) + order.config_id.tbai_last_invoice_id = order.tbai_invoice_id + return order.id + + def _export_for_ui(self, order): + res = super()._export_for_ui(order) + tbai_invoice_id = order.tbai_invoice_id + if tbai_invoice_id: + res["tbai_identifier"] = tbai_invoice_id.tbai_identifier + res["tbai_qr_src"] = "data:image/png;base64," + str( + order.tbai_invoice_id.qr.decode("UTF-8") + ) + return res + + def _prepare_invoice_vals(self): + res = super(PosOrder, self)._prepare_invoice_vals() + if self.tbai_enabled: + vat_regime_key_id = False + if self.tbai_vat_regime_key: + vat_regime_key_id = self.tbai_vat_regime_key.id + elif self.fiscal_position_id: + vat_regime_key_id = self.fiscal_position_id.tbai_vat_regime_key.id + elif self.partner_id: + fp = self.env["account.fiscal.position"].get_fiscal_position( + self.partner_id.id + ) + vat_regime_key_id = fp.tbai_vat_regime_key.id + if not vat_regime_key_id: + vat_regime_key_id = self.env.ref( + "l10n_es_ticketbai.tbai_vat_regime_01" + ).id + res.update({"tbai_vat_regime_key": vat_regime_key_id}) + if self.tbai_invoice_id: + res.update( + { + "tbai_substitute_simplified_invoice": True, + "tbai_substitution_pos_order_id": self.id, + } + ) + return res + + def tbai_get_value_serie_factura(self): + if hasattr(self.config_id, "pos_sequence_by_device") and self.pos_device_id: + sequence = self.pos_device_id.sequence + else: + sequence = self.config_id.l10n_es_simplified_invoice_sequence_id + date = fields.Datetime.context_timestamp( + self, fields.Datetime.from_string(self.date_order) + ).strftime(DEFAULT_SERVER_DATE_FORMAT) + prefix, suffix = sequence.with_context( + ir_sequence_date=date, ir_sequence_date_range=date + )._get_prefix_suffix() + return prefix + + def tbai_get_value_num_factura(self): + invoice_number_prefix = self.tbai_get_value_serie_factura() + if invoice_number_prefix and not self.l10n_es_unique_id.startswith( + invoice_number_prefix + ): + raise exceptions.ValidationError( + _("Simplified Invoice Number Prefix %s is not part of Number %%!") + % (invoice_number_prefix, self.l10n_es_unique_id) + ) + return self.l10n_es_unique_id[len(invoice_number_prefix) :] + + def tbai_get_value_fecha_expedicion_factura(self): + date = fields.Datetime.context_timestamp( + self, fields.Datetime.from_string(self.date_order) + ) + return date.strftime("%d-%m-%Y") + + def tbai_get_value_hora_expedicion_factura(self): + date = fields.Datetime.context_timestamp( + self, fields.Datetime.from_string(self.date_order) + ) + return date.strftime("%H:%M:%S") diff --git a/l10n_es_ticketbai_pos/models/ticketbai_invoice.py b/l10n_es_ticketbai_pos/models/ticketbai_invoice.py new file mode 100644 index 00000000000..bfef70ace48 --- /dev/null +++ b/l10n_es_ticketbai_pos/models/ticketbai_invoice.py @@ -0,0 +1,39 @@ +# Copyright 2021 Binovo IT Human Project SL +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +import base64 + +from lxml import etree + +from odoo import fields, models + +from odoo.addons.l10n_es_ticketbai_api.ticketbai.xml_schema import TicketBaiSchema + + +class TicketBAIInvoice(models.Model): + _inherit = "tbai.invoice" + + pos_order_id = fields.Many2one(comodel_name="pos.order") + + def send(self, **kwargs): + self.ensure_one() + if TicketBaiSchema.TicketBai.value == self.schema and self.pos_order_id: + res = super().send(pos_order_id=self.pos_order_id.id, **kwargs) + else: + res = super().send(**kwargs) + return res + + def build_tbai_simplified_invoice(self): + self.ensure_one() + if self.schema == TicketBaiSchema.TicketBai.value: + self.previous_tbai_invoice_id = ( + self.pos_order_id.config_id.tbai_last_invoice_id + ) + root, signature_value = self.get_tbai_xml_signed_and_signature_value() + root_str = etree.tostring(root, xml_declaration=True, encoding="utf-8") + self.datas = base64.b64encode(root_str) + self.datas_fname = "%s.xsig" % self.name.replace("/", "-") + self.file_size = len(self.datas) + self.signature_value = signature_value + self.mark_as_pending() + if self.schema == TicketBaiSchema.TicketBai.value: + self.pos_order_id.config_id.tbai_last_invoice_id = self diff --git a/l10n_es_ticketbai_pos/security/ir.model.access.csv b/l10n_es_ticketbai_pos/security/ir.model.access.csv new file mode 100644 index 00000000000..ed16df968f5 --- /dev/null +++ b/l10n_es_ticketbai_pos/security/ir.model.access.csv @@ -0,0 +1,5 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_tbai_invoice_pos_user,tbai.invoice pos.user,l10n_es_ticketbai_api.model_tbai_invoice,point_of_sale.group_pos_user,1,0,1,0 +access_tbai_response_pos_user,tbai.response pos.user,l10n_es_ticketbai_api.model_tbai_response,point_of_sale.group_pos_user,1,0,0,0 +access_tbai_response_message_pos_user,tbai.response.message pos.user,l10n_es_ticketbai_api.model_tbai_response_message,point_of_sale.group_pos_user,1,0,0,0 +access_tbai_certificate_pos_manager,tbai.certificate point_of_sale.group_pos_manager,l10n_es_ticketbai_api.model_tbai_certificate,point_of_sale.group_pos_manager,1,1,1,1 diff --git a/l10n_es_ticketbai_pos/static/description/icon.png b/l10n_es_ticketbai_pos/static/description/icon.png new file mode 100644 index 00000000000..ae809b43462 Binary files /dev/null and b/l10n_es_ticketbai_pos/static/description/icon.png differ diff --git a/l10n_es_ticketbai_pos/static/lib/qrcode.js b/l10n_es_ticketbai_pos/static/lib/qrcode.js new file mode 100644 index 00000000000..830fa9ebcf2 --- /dev/null +++ b/l10n_es_ticketbai_pos/static/lib/qrcode.js @@ -0,0 +1,2 @@ +!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r;r="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,r.QRCode=t()}}(function(){return function(){function t(r,e,n){function o(u,a){if(!e[u]){if(!r[u]){var f="function"==typeof require&&require;if(!a&&f)return f(u,!0);if(i)return i(u,!0);var s=new Error("Cannot find module '"+u+"'");throw s.code="MODULE_NOT_FOUND",s}var h=e[u]={exports:{}};r[u][0].call(h.exports,function(t){return o(r[u][1][t]||t)},h,h.exports,t,r,e,n)}return e[u].exports}for(var i="function"==typeof require&&require,u=0;u>>7-t%8&1)},put:function(t,r){for(var e=0;e>>r-e-1&1))},getLengthInBits:function(){return this.length},putBit:function(t){var r=Math.floor(this.length/8);this.buffer.length<=r&&this.buffer.push(0),t&&(this.buffer[r]|=128>>>this.length%8),this.length++}},r.exports=n},{}],5:[function(t,r,e){function n(t){if(!t||t<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=t,this.data=o.alloc(t*t),this.reservedBit=o.alloc(t*t)}var o=t("../utils/buffer");n.prototype.set=function(t,r,e,n){var o=t*this.size+r;this.data[o]=e,n&&(this.reservedBit[o]=!0)},n.prototype.get=function(t,r){return this.data[t*this.size+r]},n.prototype.xor=function(t,r,e){this.data[t*this.size+r]^=e},n.prototype.isReserved=function(t,r){return this.reservedBit[t*this.size+r]},r.exports=n},{"../utils/buffer":28}],6:[function(t,r,e){function n(t){this.mode=i.BYTE,this.data=o.from(t)}var o=t("../utils/buffer"),i=t("./mode");n.getBitsLength=function(t){return 8*t},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(t){for(var r=0,e=this.data.length;r=0&&t.bit<4},e.from=function(t,r){if(e.isValid(t))return t;try{return n(t)}catch(t){return r}}},{}],9:[function(t,r,e){var n=t("./utils").getSymbolSize;e.getPositions=function(t){var r=n(t);return[[0,0],[r-7,0],[0,r-7]]}},{"./utils":21}],10:[function(t,r,e){var n=t("./utils"),o=n.getBCHDigit(1335);e.getEncodedBits=function(t,r){for(var e=t.bit<<3|r,i=e<<10;n.getBCHDigit(i)-o>=0;)i^=1335<=33088&&e<=40956)e-=33088;else{if(!(e>=57408&&e<=60351))throw new Error("Invalid SJIS character: "+this.data[r]+"\nMake sure your charset is UTF-8");e-=49472}e=192*(e>>>8&255)+(255&e),t.put(e,13)}},r.exports=n},{"./mode":14,"./utils":21}],13:[function(t,r,e){function n(t,r,n){switch(t){case e.Patterns.PATTERN000:return(r+n)%2==0;case e.Patterns.PATTERN001:return r%2==0;case e.Patterns.PATTERN010:return n%3==0;case e.Patterns.PATTERN011:return(r+n)%3==0;case e.Patterns.PATTERN100:return(Math.floor(r/2)+Math.floor(n/3))%2==0;case e.Patterns.PATTERN101:return r*n%2+r*n%3==0;case e.Patterns.PATTERN110:return(r*n%2+r*n%3)%2==0;case e.Patterns.PATTERN111:return(r*n%3+(r+n)%2)%2==0;default:throw new Error("bad maskPattern:"+t)}}e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var o={N1:3,N2:3,N3:40,N4:10};e.isValid=function(t){return null!=t&&""!==t&&!isNaN(t)&&t>=0&&t<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(t){for(var r=t.size,e=0,n=0,i=0,u=null,a=null,f=0;f=5&&(e+=o.N1+(n-5)),u=h,n=1),h=t.get(s,f),h===a?i++:(i>=5&&(e+=o.N1+(i-5)),a=h,i=1)}n>=5&&(e+=o.N1+(n-5)),i>=5&&(e+=o.N1+(i-5))}return e},e.getPenaltyN2=function(t){for(var r=t.size,e=0,n=0;n=10&&(1488===n||93===n)&&e++,i=i<<1&2047|t.get(a,u),a>=10&&(1488===i||93===i)&&e++}return e*o.N3},e.getPenaltyN4=function(t){for(var r=0,e=t.data.length,n=0;n=1&&r<10?t.ccBits[0]:r<27?t.ccBits[1]:t.ccBits[2]},e.getBestModeForData=function(t){return i.testNumeric(t)?e.NUMERIC:i.testAlphanumeric(t)?e.ALPHANUMERIC:i.testKanji(t)?e.KANJI:e.BYTE},e.toString=function(t){if(t&&t.id)return t.id;throw new Error("Invalid mode")},e.isValid=function(t){return t&&t.bit&&t.ccBits},e.from=function(t,r){if(e.isValid(t))return t;try{return n(t)}catch(t){return r}}},{"./regex":19,"./version-check":22}],15:[function(t,r,e){function n(t){this.mode=o.NUMERIC,this.data=t.toString()}var o=t("./mode");n.getBitsLength=function(t){return 10*Math.floor(t/3)+(t%3?t%3*3+1:0)},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(t){var r,e,n;for(r=0;r+3<=this.data.length;r+=3)e=this.data.substr(r,3),n=parseInt(e,10),t.put(n,10);var o=this.data.length-r;o>0&&(e=this.data.substr(r),n=parseInt(e,10),t.put(n,3*o+1))},r.exports=n},{"./mode":14}],16:[function(t,r,e){var n=t("../utils/buffer"),o=t("./galois-field");e.mul=function(t,r){for(var e=n.alloc(t.length+r.length-1),i=0;i=0;){for(var i=e[0],u=0;u=0&&a<=6&&(0===f||6===f)||f>=0&&f<=6&&(0===a||6===a)||a>=2&&a<=4&&f>=2&&f<=4?t.set(i+a,u+f,!0,!0):t.set(i+a,u+f,!1,!0))}function o(t){for(var r=t.size,e=8;e>a&1),t.set(e,n,o,!0),t.set(n,e,o,!0)}function a(t,r,e){var n,o,i=t.size,u=B.getEncodedBits(r,e);for(n=0;n<15;n++)o=1==(u>>n&1),n<6?t.set(n,8,o,!0):n<8?t.set(n+1,8,o,!0):t.set(i-15+n,8,o,!0),n<8?t.set(8,i-n-1,o,!0):n<9?t.set(8,15-n-1+1,o,!0):t.set(8,15-n-1,o,!0);t.set(i-8,8,1,!0)}function f(t,r){for(var e=t.size,n=-1,o=e-1,i=7,u=0,a=e-1;a>0;a-=2)for(6===a&&a--;;){for(var f=0;f<2;f++)if(!t.isReserved(o,a-f)){var s=!1;u>>i&1)),t.set(o,a-f,s),i--,-1===i&&(u++,i=7)}if((o+=n)<0||e<=o){o-=n,n=-n;break}}}function s(t,r,e){var n=new d;e.forEach(function(r){n.put(r.mode.bit,4),n.put(r.getLength(),T.getCharCountIndicator(r.mode,t)),r.write(n)});var o=g.getSymbolTotalCodewords(t),i=b.getTotalCodewordsCount(t,r),u=8*(o-i);for(n.getLengthInBits()+4<=u&&n.put(0,4);n.getLengthInBits()%8!=0;)n.putBit(0);for(var a=(u-n.getLengthInBits())/8,f=0;f=7&&u(b,r),f(b,v),isNaN(h)&&(h=m.getBestMask(b,a.bind(null,b,e))),m.applyMask(h,b),a(b,e,h),{modules:b,version:r,errorCorrectionLevel:e,maskPattern:h,segments:c}}var l=t("../utils/buffer"),g=t("./utils"),p=t("./error-correction-level"),d=t("./bit-buffer"),y=t("./bit-matrix"),v=t("./alignment-pattern"),w=t("./finder-pattern"),m=t("./mask-pattern"),b=t("./error-correction-code"),E=t("./reed-solomon-encoder"),A=t("./version"),B=t("./format-info"),T=t("./mode"),R=t("./segments"),C=t("isarray");e.create=function(t,r){if(void 0===t||""===t)throw new Error("No input text");var e,n,o=p.M;return void 0!==r&&(o=p.from(r.errorCorrectionLevel,p.M),e=A.from(r.version),n=m.from(r.maskPattern),r.toSJISFunc&&g.setToSJISFunction(r.toSJISFunc)),c(t,e,o,n)}},{"../utils/buffer":28,"./alignment-pattern":2,"./bit-buffer":4,"./bit-matrix":5,"./error-correction-code":7,"./error-correction-level":8,"./finder-pattern":9,"./format-info":10,"./mask-pattern":13,"./mode":14,"./reed-solomon-encoder":18,"./segments":20,"./utils":21,"./version":23,isarray:33}],18:[function(t,r,e){function n(t){this.genPoly=void 0,this.degree=t,this.degree&&this.initialize(this.degree)}var o=t("../utils/buffer"),i=t("./polynomial"),u=t("buffer").Buffer;n.prototype.initialize=function(t){this.degree=t,this.genPoly=i.generateECPolynomial(this.degree)},n.prototype.encode=function(t){if(!this.genPoly)throw new Error("Encoder not initialized");var r=o.alloc(this.degree),e=u.concat([t,r],t.length+this.degree),n=i.mod(e,this.genPoly),a=this.degree-n.length;if(a>0){var f=o.alloc(this.degree);return n.copy(f,a),f}return n},r.exports=n},{"../utils/buffer":28,"./polynomial":16,buffer:30}],19:[function(t,r,e){var n="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";n=n.replace(/u/g,"\\u");var o="(?:(?![A-Z0-9 $%*+\\-./:]|"+n+")(?:.|[\r\n]))+";e.KANJI=new RegExp(n,"g"),e.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),e.BYTE=new RegExp(o,"g"),e.NUMERIC=new RegExp("[0-9]+","g"),e.ALPHANUMERIC=new RegExp("[A-Z $%*+\\-./:]+","g");var i=new RegExp("^"+n+"$"),u=new RegExp("^[0-9]+$"),a=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");e.testKanji=function(t){return i.test(t)},e.testNumeric=function(t){return u.test(t)},e.testAlphanumeric=function(t){return a.test(t)}},{}],20:[function(t,r,e){function n(t){return unescape(encodeURIComponent(t)).length}function o(t,r,e){for(var n,o=[];null!==(n=t.exec(e));)o.push({data:n[0],index:n.index,mode:r,length:n[0].length});return o}function i(t){var r,e,n=o(y.NUMERIC,c.NUMERIC,t),i=o(y.ALPHANUMERIC,c.ALPHANUMERIC,t);return v.isKanjiModeEnabled()?(r=o(y.BYTE,c.BYTE,t),e=o(y.KANJI,c.KANJI,t)):(r=o(y.BYTE_KANJI,c.BYTE,t),e=[]),n.concat(i,r,e).sort(function(t,r){return t.index-r.index}).map(function(t){return{data:t.data,mode:t.mode,length:t.length}})}function u(t,r){switch(r){case c.NUMERIC:return l.getBitsLength(t);case c.ALPHANUMERIC:return g.getBitsLength(t);case c.KANJI:return d.getBitsLength(t);case c.BYTE:return p.getBitsLength(t)}}function a(t){return t.reduce(function(t,r){var e=t.length-1>=0?t[t.length-1]:null;return e&&e.mode===r.mode?(t[t.length-1].data+=r.data,t):(t.push(r),t)},[])}function f(t){for(var r=[],e=0;e40)throw new Error('"version" should be in range from 1 to 40');return 4*t+17},e.getSymbolTotalCodewords=function(t){return o[t]},e.getBCHDigit=function(t){for(var r=0;0!==t;)r++,t>>>=1;return r},e.setToSJISFunction=function(t){if("function"!=typeof t)throw new Error('"toSJISFunc" is not a valid function.');n=t},e.isKanjiModeEnabled=function(){return void 0!==n},e.toSJIS=function(t){return n(t)}},{}],22:[function(t,r,e){e.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40}},{}],23:[function(t,r,e){function n(t,r,n){for(var o=1;o<=40;o++)if(r<=e.getCapacity(o,n,t))return o}function o(t,r){return h.getCharCountIndicator(t,r)+4}function i(t,r){var e=0;return t.forEach(function(t){var n=o(t.mode,r);e+=n+t.getBitsLength()}),e}function u(t,r){for(var n=1;n<=40;n++){if(i(t,n)<=e.getCapacity(n,r,h.MIXED))return n}}var a=t("./utils"),f=t("./error-correction-code"),s=t("./error-correction-level"),h=t("./mode"),c=t("./version-check"),l=t("isarray"),g=a.getBCHDigit(7973);e.from=function(t,r){return c.isValid(t)?parseInt(t,10):r},e.getCapacity=function(t,r,e){if(!c.isValid(t))throw new Error("Invalid QR Code version");void 0===e&&(e=h.BYTE);var n=a.getSymbolTotalCodewords(t),i=f.getTotalCodewordsCount(t,r),u=8*(n-i);if(e===h.MIXED)return u;var s=u-o(e,t);switch(e){case h.NUMERIC:return Math.floor(s/10*3);case h.ALPHANUMERIC:return Math.floor(s/11*2);case h.KANJI:return Math.floor(s/13);case h.BYTE:default:return Math.floor(s/8)}},e.getBestVersionForData=function(t,r){var e,o=s.from(r,s.M);if(l(t)){if(t.length>1)return u(t,o);if(0===t.length)return 1;e=t[0]}else e=t;return n(e.mode,e.getLength(),o)},e.getEncodedBits=function(t){if(!c.isValid(t)||t<7)throw new Error("Invalid QR Code version");for(var r=t<<12;a.getBCHDigit(r)-g>=0;)r^=7973<0&&s>0&&t[f-1]||(n+=u?o("M",s+e,.5+h+e):o("m",i,0),i=0,u=!1),s+1':"",c="',l='viewBox="0 0 '+s+" "+s+'"',g=o.width?'width="'+o.width+'" height="'+o.width+'" ':"",p=''+h+c+"\n";return"function"==typeof e&&e(null,p),p}},{"./utils":27}],27:[function(t,r,e){function n(t){if("number"==typeof t&&(t=t.toString()),"string"!=typeof t)throw new Error("Color should be defined as hex string");var r=t.slice().replace("#","").split("");if(r.length<3||5===r.length||r.length>8)throw new Error("Invalid hex color: "+t);3!==r.length&&4!==r.length||(r=Array.prototype.concat.apply([],r.map(function(t){return[t,t]}))),6===r.length&&r.push("F","F");var e=parseInt(r.join(""),16);return{r:e>>24&255,g:e>>16&255,b:e>>8&255,a:255&e,hex:"#"+r.slice(0,6).join("")}}e.getOptions=function(t){t||(t={}),t.color||(t.color={});var r=void 0===t.margin||null===t.margin||t.margin<0?4:t.margin,e=t.width&&t.width>=21?t.width:void 0,o=t.scale||4;return{width:e,scale:e?4:o,margin:r,color:{dark:n(t.color.dark||"#000000ff"),light:n(t.color.light||"#ffffffff")},type:t.type,rendererOpts:t.rendererOpts||{}}},e.getScale=function(t,r){return r.width&&r.width>=t+2*r.margin?r.width/(t+2*r.margin):r.scale},e.getImageWidth=function(t,r){var n=e.getScale(t,r);return Math.floor((t+2*r.margin)*n)},e.qrToImageData=function(t,r,n){for(var o=r.modules.size,i=r.modules.data,u=e.getScale(o,n),a=Math.floor((o+2*n.margin)*u),f=n.margin*u,s=[n.color.light,n.color.dark],h=0;h=f&&c>=f&&h=w)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+w.toString(16)+" bytes");return 0|t}function i(t){return t!==t}function u(t,r){var e;return n.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(r),e.__proto__=n.prototype):(e=t,null===e&&(e=new n(r)),e.length=r),e}function a(t,r){var e=u(t,r<0?0:0|o(r));if(!n.TYPED_ARRAY_SUPPORT)for(var i=0;i55295&&e<57344){if(!o){if(e>56319){(r-=3)>-1&&i.push(239,191,189);continue}if(u+1===n){(r-=3)>-1&&i.push(239,191,189);continue}o=e;continue}if(e<56320){(r-=3)>-1&&i.push(239,191,189),o=e;continue}e=65536+(o-55296<<10|e-56320)}else o&&(r-=3)>-1&&i.push(239,191,189);if(o=null,e<128){if((r-=1)<0)break;i.push(e)}else if(e<2048){if((r-=2)<0)break;i.push(e>>6|192,63&e|128)}else if(e<65536){if((r-=3)<0)break;i.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(e<1114112))throw new Error("Invalid code point");if((r-=4)<0)break;i.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return i}function g(t){return n.isBuffer(t)?t.length:"undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer)?t.byteLength:("string"!=typeof t&&(t=""+t),0===t.length?0:l(t).length)}function p(t,r,e,n){for(var o=0;o=r.length||o>=t.length);++o)r[o+e]=t[o];return o}function d(t,r,e,n){return p(l(r,t.length-e),t,e,n)}function y(t,r,e,n){if("number"==typeof r)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&r instanceof ArrayBuffer?h(t,r,e,n):"string"==typeof r?f(t,r,e):c(t,r)}var v=t("isarray");n.TYPED_ARRAY_SUPPORT=function(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()}catch(t){return!1}}();var w=n.TYPED_ARRAY_SUPPORT?2147483647:1073741823;n.TYPED_ARRAY_SUPPORT&&(n.prototype.__proto__=Uint8Array.prototype,n.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&n[Symbol.species]===n&&Object.defineProperty(n,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1})),n.prototype.write=function(t,r,e){void 0===r?(e=this.length,r=0):void 0===e&&"string"==typeof r?(e=this.length,r=0):isFinite(r)&&(r|=0,isFinite(e)?e|=0:e=void 0);var n=this.length-r;if((void 0===e||e>n)&&(e=n),t.length>0&&(e<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");return d(this,t,r,e)},n.prototype.slice=function(t,r){var e=this.length;t=~~t,r=void 0===r?e:~~r,t<0?(t+=e)<0&&(t=0):t>e&&(t=e),r<0?(r+=e)<0&&(r=0):r>e&&(r=e),r=t.length&&(r=t.length),r||(r=0),o>0&&o=this.length)throw new RangeError("sourceStart out of bounds");if(o<0)throw new RangeError("sourceEnd out of bounds");o>this.length&&(o=this.length),t.length-r=0;--i)t[i+r]=this[i+e];else if(u<1e3||!n.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,e=void 0===e?this.length:e>>>0,t||(t=0);var i;if("number"==typeof t)for(i=r;i0)throw new Error("Invalid string. Length must be a multiple of 4");var e=t.indexOf("=");return-1===e&&(e=r),[e,e===r?0:4-e%4]}function o(t){var r=n(t),e=r[0],o=r[1];return 3*(e+o)/4-o}function i(t,r,e){return 3*(r+e)/4-e}function u(t){var r,e,o=n(t),u=o[0],a=o[1],f=new l(i(t,u,a)),s=0,h=a>0?u-4:u;for(e=0;e>16&255,f[s++]=r>>8&255,f[s++]=255&r;return 2===a&&(r=c[t.charCodeAt(e)]<<2|c[t.charCodeAt(e+1)]>>4,f[s++]=255&r),1===a&&(r=c[t.charCodeAt(e)]<<10|c[t.charCodeAt(e+1)]<<4|c[t.charCodeAt(e+2)]>>2,f[s++]=r>>8&255,f[s++]=255&r),f}function a(t){return h[t>>18&63]+h[t>>12&63]+h[t>>6&63]+h[63&t]}function f(t,r,e){for(var n,o=[],i=r;iu?u:i+16383));return 1===n?(r=t[e-1],o.push(h[r>>2]+h[r<<4&63]+"==")):2===n&&(r=(t[e-2]<<8)+t[e-1],o.push(h[r>>10]+h[r>>4&63]+h[r<<2&63]+"=")),o.join("")}e.byteLength=o,e.toByteArray=u,e.fromByteArray=s +;for(var h=[],c=[],l="undefined"!=typeof Uint8Array?Uint8Array:Array,g="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",p=0,d=g.length;p$)throw new RangeError('The value "'+t+'" is invalid for option "size"');var r=new Uint8Array(t);return Object.setPrototypeOf(r,o.prototype),r}function o(t,r,e){if("number"==typeof t){if("string"==typeof r)throw new TypeError('The "string" argument must be of type string. Received type number');return f(t)}return i(t,r,e)}function i(t,r,e){if("string"==typeof t)return s(t,r);if(ArrayBuffer.isView(t))return h(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(J(t,ArrayBuffer)||t&&J(t.buffer,ArrayBuffer))return c(t,r,e);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');var n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return o.from(n,r,e);var i=l(t);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return o.from(t[Symbol.toPrimitive]("string"),r,e);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function u(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function a(t,r,e){return u(t),t<=0?n(t):void 0!==r?"string"==typeof e?n(t).fill(r,e):n(t).fill(r):n(t)}function f(t){return u(t),n(t<0?0:0|g(t))}function s(t,r){if("string"==typeof r&&""!==r||(r="utf8"),!o.isEncoding(r))throw new TypeError("Unknown encoding: "+r);var e=0|d(t,r),i=n(e),u=i.write(t,r);return u!==e&&(i=i.slice(0,u)),i}function h(t){for(var r=t.length<0?0:0|g(t.length),e=n(r),o=0;o=$)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+$.toString(16)+" bytes");return 0|t}function p(t){return+t!=t&&(t=0),o.alloc(+t)}function d(t,r){if(o.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||J(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var e=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===e)return 0;for(var i=!1;;)switch(r){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":return D(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*e;case"hex":return e>>>1;case"base64":return z(t).length;default:if(i)return n?-1:D(t).length;r=(""+r).toLowerCase(),i=!0}}function y(t,r,e){var n=!1;if((void 0===r||r<0)&&(r=0),r>this.length)return"";if((void 0===e||e>this.length)&&(e=this.length),e<=0)return"";if(e>>>=0,r>>>=0,e<=r)return"";for(t||(t="utf8");;)switch(t){case"hex":return N(this,r,e);case"utf8":case"utf-8":return P(this,r,e);case"ascii":return M(this,r,e);case"latin1":case"binary":return U(this,r,e);case"base64":return C(this,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,r,e);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function v(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}function w(t,r,e,n,i){if(0===t.length)return-1;if("string"==typeof e?(n=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,K(e)&&(e=i?0:t.length-1),e<0&&(e=t.length+e),e>=t.length){if(i)return-1;e=t.length-1}else if(e<0){if(!i)return-1;e=0}if("string"==typeof r&&(r=o.from(r,n)),o.isBuffer(r))return 0===r.length?-1:m(t,r,e,n,i);if("number"==typeof r)return r&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,r,e):Uint8Array.prototype.lastIndexOf.call(t,r,e):m(t,[r],e,n,i);throw new TypeError("val must be string, number or Buffer")}function m(t,r,e,n,o){function i(t,r){return 1===u?t[r]:t.readUInt16BE(r*u)}var u=1,a=t.length,f=r.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||r.length<2)return-1;u=2,a/=2,f/=2,e/=2}var s;if(o){var h=-1;for(s=e;sa&&(e=a-f),s=e;s>=0;s--){for(var c=!0,l=0;lo&&(n=o):n=o;var i=r.length;n>i/2&&(n=i/2);for(var u=0;u239?4:i>223?3:i>191?2:1;if(o+a<=e){var f,s,h,c;switch(a){case 1:i<128&&(u=i);break;case 2:f=t[o+1],128==(192&f)&&(c=(31&i)<<6|63&f)>127&&(u=c);break;case 3:f=t[o+1],s=t[o+2],128==(192&f)&&128==(192&s)&&(c=(15&i)<<12|(63&f)<<6|63&s)>2047&&(c<55296||c>57343)&&(u=c);break;case 4:f=t[o+1],s=t[o+2],h=t[o+3],128==(192&f)&&128==(192&s)&&128==(192&h)&&(c=(15&i)<<18|(63&f)<<12|(63&s)<<6|63&h)>65535&&c<1114112&&(u=c)}}null===u?(u=65533,a=1):u>65535&&(u-=65536,n.push(u>>>10&1023|55296),u=56320|1023&u),n.push(u),o+=a}return I(n)}function I(t){var r=t.length;if(r<=X)return String.fromCharCode.apply(String,t);for(var e="",n=0;nn)&&(e=n);for(var o="",i=r;ie)throw new RangeError("Trying to access beyond buffer length")}function x(t,r,e,n,i,u){if(!o.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>i||rt.length)throw new RangeError("Index out of range")}function _(t,r,e,n,o,i){if(e+n>t.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function k(t,r,e,n,o){return r=+r,e>>>=0,o||_(t,r,e,4,3.4028234663852886e38,-3.4028234663852886e38),V.write(t,r,e,n,23,4),e+4}function O(t,r,e,n,o){return r=+r,e>>>=0,o||_(t,r,e,8,1.7976931348623157e308,-1.7976931348623157e308),V.write(t,r,e,n,52,8),e+8}function Y(t){if(t=t.split("=")[0],t=t.trim().replace(Z,""),t.length<2)return"";for(;t.length%4!=0;)t+="=";return t}function D(t,r){r=r||1/0;for(var e,n=t.length,o=null,i=[],u=0;u55295&&e<57344){if(!o){if(e>56319){(r-=3)>-1&&i.push(239,191,189);continue}if(u+1===n){(r-=3)>-1&&i.push(239,191,189);continue}o=e;continue}if(e<56320){(r-=3)>-1&&i.push(239,191,189),o=e;continue}e=65536+(o-55296<<10|e-56320)}else o&&(r-=3)>-1&&i.push(239,191,189);if(o=null,e<128){if((r-=1)<0)break;i.push(e)}else if(e<2048){if((r-=2)<0)break;i.push(e>>6|192,63&e|128)}else if(e<65536){if((r-=3)<0)break;i.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(e<1114112))throw new Error("Invalid code point");if((r-=4)<0)break;i.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return i}function j(t){for(var r=[],e=0;e>8,o=e%256,i.push(o),i.push(n);return i}function z(t){return q.toByteArray(Y(t))}function H(t,r,e,n){for(var o=0;o=r.length||o>=t.length);++o)r[o+e]=t[o];return o}function J(t,r){return t instanceof r||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===r.name}function K(t){return t!==t}var q=t("base64-js"),V=t("ieee754"),Q="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=o,e.SlowBuffer=p,e.INSPECT_MAX_BYTES=50;var $=2147483647;e.kMaxLength=$,o.TYPED_ARRAY_SUPPORT=function(){try{var t=new Uint8Array(1),r={foo:function(){return 42}};return Object.setPrototypeOf(r,Uint8Array.prototype),Object.setPrototypeOf(t,r),42===t.foo()}catch(t){return!1}}(),o.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(o.prototype,"parent",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.buffer}}),Object.defineProperty(o.prototype,"offset",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.byteOffset}}),"undefined"!=typeof Symbol&&null!=Symbol.species&&o[Symbol.species]===o&&Object.defineProperty(o,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),o.poolSize=8192,o.from=function(t,r,e){return i(t,r,e)},Object.setPrototypeOf(o.prototype,Uint8Array.prototype),Object.setPrototypeOf(o,Uint8Array),o.alloc=function(t,r,e){return a(t,r,e)},o.allocUnsafe=function(t){return f(t)},o.allocUnsafeSlow=function(t){return f(t)},o.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==o.prototype},o.compare=function(t,r){if(J(t,Uint8Array)&&(t=o.from(t,t.offset,t.byteLength)),J(r,Uint8Array)&&(r=o.from(r,r.offset,r.byteLength)),!o.isBuffer(t)||!o.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===r)return 0;for(var e=t.length,n=r.length,i=0,u=Math.min(e,n);ir&&(t+=" ... "),""},Q&&(o.prototype[Q]=o.prototype.inspect),o.prototype.compare=function(t,r,e,n,i){if(J(t,Uint8Array)&&(t=o.from(t,t.offset,t.byteLength)),!o.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===r&&(r=0),void 0===e&&(e=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),r<0||e>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&r>=e)return 0;if(n>=i)return-1;if(r>=e)return 1;if(r>>>=0,e>>>=0,n>>>=0,i>>>=0,this===t)return 0;for(var u=i-n,a=e-r,f=Math.min(u,a),s=this.slice(n,i),h=t.slice(r,e),c=0;c>>=0,isFinite(e)?(e>>>=0,void 0===n&&(n="utf8")):(n=e,e=void 0)}var o=this.length-r;if((void 0===e||e>o)&&(e=o),t.length>0&&(e<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return b(this,t,r,e);case"utf8":case"utf-8":return E(this,t,r,e);case"ascii":return A(this,t,r,e);case"latin1":case"binary":return B(this,t,r,e);case"base64":return T(this,t,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,t,r,e);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var X=4096;o.prototype.slice=function(t,r){var e=this.length;t=~~t,r=void 0===r?e:~~r,t<0?(t+=e)<0&&(t=0):t>e&&(t=e),r<0?(r+=e)<0&&(r=0):r>e&&(r=e),r>>=0,r>>>=0,e||L(t,r,this.length);for(var n=this[t],o=1,i=0;++i>>=0,r>>>=0,e||L(t,r,this.length);for(var n=this[t+--r],o=1;r>0&&(o*=256);)n+=this[t+--r]*o;return n},o.prototype.readUInt8=function(t,r){return t>>>=0,r||L(t,1,this.length),this[t]},o.prototype.readUInt16LE=function(t,r){return t>>>=0,r||L(t,2,this.length),this[t]|this[t+1]<<8},o.prototype.readUInt16BE=function(t,r){return t>>>=0,r||L(t,2,this.length),this[t]<<8|this[t+1]},o.prototype.readUInt32LE=function(t,r){return t>>>=0,r||L(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},o.prototype.readUInt32BE=function(t,r){return t>>>=0,r||L(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},o.prototype.readIntLE=function(t,r,e){t>>>=0,r>>>=0,e||L(t,r,this.length);for(var n=this[t],o=1,i=0;++i=o&&(n-=Math.pow(2,8*r)),n},o.prototype.readIntBE=function(t,r,e){t>>>=0,r>>>=0,e||L(t,r,this.length);for(var n=r,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*r)),i},o.prototype.readInt8=function(t,r){return t>>>=0,r||L(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},o.prototype.readInt16LE=function(t,r){t>>>=0,r||L(t,2,this.length);var e=this[t]|this[t+1]<<8;return 32768&e?4294901760|e:e},o.prototype.readInt16BE=function(t,r){t>>>=0,r||L(t,2,this.length);var e=this[t+1]|this[t]<<8;return 32768&e?4294901760|e:e},o.prototype.readInt32LE=function(t,r){return t>>>=0,r||L(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},o.prototype.readInt32BE=function(t,r){return t>>>=0,r||L(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},o.prototype.readFloatLE=function(t,r){return t>>>=0,r||L(t,4,this.length),V.read(this,t,!0,23,4)},o.prototype.readFloatBE=function(t,r){return t>>>=0,r||L(t,4,this.length),V.read(this,t,!1,23,4)},o.prototype.readDoubleLE=function(t,r){return t>>>=0,r||L(t,8,this.length),V.read(this,t,!0,52,8)},o.prototype.readDoubleBE=function(t,r){return t>>>=0,r||L(t,8,this.length),V.read(this,t,!1,52,8)},o.prototype.writeUIntLE=function(t,r,e,n){if(t=+t,r>>>=0,e>>>=0,!n){x(this,t,r,e,Math.pow(2,8*e)-1,0)}var o=1,i=0;for(this[r]=255&t;++i>>=0,e>>>=0,!n){x(this,t,r,e,Math.pow(2,8*e)-1,0)}var o=e-1,i=1;for(this[r+o]=255&t;--o>=0&&(i*=256);)this[r+o]=t/i&255;return r+e},o.prototype.writeUInt8=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,1,255,0),this[r]=255&t,r+1},o.prototype.writeUInt16LE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,2,65535,0),this[r]=255&t,this[r+1]=t>>>8,r+2},o.prototype.writeUInt16BE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=255&t,r+2},o.prototype.writeUInt32LE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,4,4294967295,0),this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=255&t,r+4},o.prototype.writeUInt32BE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,4,4294967295,0),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},o.prototype.writeIntLE=function(t,r,e,n){if(t=+t,r>>>=0,!n){var o=Math.pow(2,8*e-1);x(this,t,r,e,o-1,-o)}var i=0,u=1,a=0;for(this[r]=255&t;++i>0)-a&255;return r+e},o.prototype.writeIntBE=function(t,r,e,n){if(t=+t,r>>>=0,!n){var o=Math.pow(2,8*e-1);x(this,t,r,e,o-1,-o)}var i=e-1,u=1,a=0;for(this[r+i]=255&t;--i>=0&&(u*=256);)t<0&&0===a&&0!==this[r+i+1]&&(a=1),this[r+i]=(t/u>>0)-a&255;return r+e},o.prototype.writeInt8=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=255&t,r+1},o.prototype.writeInt16LE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,2,32767,-32768),this[r]=255&t,this[r+1]=t>>>8,r+2},o.prototype.writeInt16BE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=255&t,r+2},o.prototype.writeInt32LE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,4,2147483647,-2147483648),this[r]=255&t,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24,r+4},o.prototype.writeInt32BE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},o.prototype.writeFloatLE=function(t,r,e){return k(this,t,r,!0,e)},o.prototype.writeFloatBE=function(t,r,e){return k(this,t,r,!1,e)},o.prototype.writeDoubleLE=function(t,r,e){return O(this,t,r,!0,e)},o.prototype.writeDoubleBE=function(t,r,e){return O(this,t,r,!1,e)},o.prototype.copy=function(t,r,e,n){if(!o.isBuffer(t))throw new TypeError("argument should be a Buffer");if(e||(e=0),n||0===n||(n=this.length),r>=t.length&&(r=t.length),r||(r=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-r=0;--u)t[u+r]=this[u+e];else Uint8Array.prototype.set.call(t,this.subarray(e,n),r);return i},o.prototype.fill=function(t,r,e,n){if("string"==typeof t){if("string"==typeof r?(n=r,r=0,e=this.length):"string"==typeof e&&(n=e,e=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!o.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var i=t.charCodeAt(0);("utf8"===n&&i<128||"latin1"===n)&&(t=i)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(r<0||this.length>>=0,e=void 0===e?this.length:e>>>0,t||(t=0);var u;if("number"==typeof t)for(u=r;ug)&&(i[s]=g,u.push(s,g),o[s]=f))}if(void 0!==e&&void 0===i[e]){var d=["Could not find a path from ",r," to ",e,"."].join("");throw new Error(d)}return o},extract_shortest_path_from_predecessor_list:function(t,r){for(var e=[],n=r;n;)e.push(n),t[n],n=t[n];return e.reverse(),e},find_path:function(t,r,e){var o=n.single_source_shortest_paths(t,r,e);return n.extract_shortest_path_from_predecessor_list(o,e)},PriorityQueue:{make:function(t){var r,e=n.PriorityQueue,o={};t=t||{};for(r in e)e.hasOwnProperty(r)&&(o[r]=e[r]);return o.queue=[],o.sorter=t.sorter||e.default_sorter,o},default_sorter:function(t,r){return t.cost-r.cost},push:function(t,r){var e={value:t,cost:r};this.queue.push(e),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return 0===this.queue.length}}};void 0!==r&&(r.exports=n)},{}],32:[function(t,r,e){e.read=function(t,r,e,n,o){var i,u,a=8*o-n-1,f=(1<>1,h=-7,c=e?o-1:0,l=e?-1:1,g=t[r+c];for(c+=l,i=g&(1<<-h)-1,g>>=-h,h+=a;h>0;i=256*i+t[r+c],c+=l,h-=8);for(u=i&(1<<-h)-1,i>>=-h,h+=n;h>0;u=256*u+t[r+c],c+=l,h-=8);if(0===i)i=1-s;else{if(i===f)return u?NaN:1/0*(g?-1:1);u+=Math.pow(2,n),i-=s}return(g?-1:1)*u*Math.pow(2,i-n)},e.write=function(t,r,e,n,o,i){var u,a,f,s=8*i-o-1,h=(1<>1,l=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,g=n?0:i-1,p=n?1:-1,d=r<0||0===r&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(a=isNaN(r)?1:0,u=h):(u=Math.floor(Math.log(r)/Math.LN2),r*(f=Math.pow(2,-u))<1&&(u--,f*=2),r+=u+c>=1?l/f:l*Math.pow(2,1-c),r*f>=2&&(u++,f/=2),u+c>=h?(a=0,u=h):u+c>=1?(a=(r*f-1)*Math.pow(2,o),u+=c):(a=r*Math.pow(2,c-1)*Math.pow(2,o),u=0));o>=8;t[e+g]=255&a,g+=p,a/=256,o-=8);for(u=u<0;t[e+g]=255&u,g+=p,u/=256,s-=8);t[e+g-p]|=128*d}},{}],33:[function(t,r,e){var n={}.toString;r.exports=Array.isArray||function(t){return"[object Array]"==n.call(t)}},{}]},{},[24])(24)}); diff --git a/l10n_es_ticketbai_pos/static/lib/tbai.js b/l10n_es_ticketbai_pos/static/lib/tbai.js new file mode 100644 index 00000000000..35c28bd9066 --- /dev/null +++ b/l10n_es_ticketbai_pos/static/lib/tbai.js @@ -0,0 +1,1803 @@ +(function(){/* + The buffer module from node.js, for the browser. + + @author Feross Aboukhadijeh + @license MIT + ***************************************************************************** +Copyright (c) Microsoft Corporation. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +**************************************************************************** ieee754. BSD-3-Clause License. Feross Aboukhadijeh */ +'use strict';var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.arrayIteratorImpl=function(Q){var E=0;return function(){return EE||1342177279>>=1)C+=C;return u}},"es6","es3");$jscomp.stringPadding=function(Q,E){Q=void 0!==Q?String(Q):" ";return 0C&&(C=Math.max(0,I+C));if(null==u||u>I)u=I;u=Number(u);0>u&&(u=Math.max(0,I+u));for(C=Number(C||0);C=V}},"es6","es3"); +(function(Q,E){"object"===typeof exports&&"object"===typeof module?module.exports=E():"function"===typeof define&&define.amd?define([],E):"object"===typeof exports?exports.tbai=E():Q.tbai=E()})(window,function(){return function(Q){function E(u){if(C[u])return C[u].exports;var I=C[u]={i:u,l:!1,exports:{}};Q[u].call(I.exports,I,I.exports,E);I.l=!0;return I.exports}var C={};E.m=Q;E.c=C;E.d=function(u,I,V){E.o(u,I)||Object.defineProperty(u,I,{enumerable:!0,get:V})};E.r=function(u){"undefined"!==typeof Symbol&& +Symbol.toStringTag&&Object.defineProperty(u,Symbol.toStringTag,{value:"Module"});Object.defineProperty(u,"__esModule",{value:!0})};E.t=function(u,I){I&1&&(u=E(u));if(I&8||I&4&&"object"===typeof u&&u&&u.__esModule)return u;var V=Object.create(null);E.r(V);Object.defineProperty(V,"default",{enumerable:!0,value:u});if(I&2&&"string"!=typeof u)for(var q in u)E.d(V,q,function(f){return u[f]}.bind(null,q));return V};E.n=function(u){var I=u&&u.__esModule?function(){return u["default"]}:function(){return u}; +E.d(I,"a",I);return I};E.o=function(u,I){return Object.prototype.hasOwnProperty.call(u,I)};E.p="";return E(E.s=84)}([function(Q,E,C){function u(p,T,aa){return!1===p instanceof Object?aa:T in p?p[T]:aa}function I(p,T,aa,ma){T=void 0===T?0:T;aa=void 0===aa?p.byteLength-T:aa;ma=void 0===ma?!1:ma;var sa="";p=$jscomp.makeIterator(new Uint8Array(p,T,aa));for(T=p.next();!T.done;T=p.next())T=T.value.toString(16).toUpperCase(),1===T.length&&(sa+="0"),sa+=T,ma&&(sa+=" ");return sa.trim()}function V(p,T,aa, +ma){return!1===T instanceof ArrayBuffer?(p.error='Wrong parameter: inputBuffer must be "ArrayBuffer"',!1):0===T.byteLength?(p.error="Wrong parameter: inputBuffer has zero length",!1):0>aa?(p.error="Wrong parameter: inputOffset less than zero",!1):0>ma?(p.error="Wrong parameter: inputLength less than zero",!1):0>T.byteLength-aa-ma?(p.error="End of input reached before message was fully decoded (inconsistent offset and length values)",!1):!0}function q(p,T){var aa=0;if(1===p.length)return p[0];for(var ma= +p.length-1;0<=ma;ma--)aa+=p[p.length-1-ma]*Math.pow(2,T*ma);return aa}function f(p,T,aa){var ma=void 0===aa?-1:aa;aa=p;for(var sa=Math.pow(2,T),Ca=1;8>Ca;Ca++){if(pma)p=new ArrayBuffer(Ca),ma=Ca;else{if(ma=T.valueBlock.value.length){if(!1===aa.valueBlock.value[Ta].optional)return T= +{verified:!1,result:p},p.error="Inconsistent length between ASN.1 data and schema",aa.hasOwnProperty("name")&&(aa.name=aa.name.replace(/^\s+|\s+$/g,""),""!==aa.name&&(delete p[aa.name],T.name=aa.name)),T}else if(aa.valueBlock.value[0]instanceof $a){sa=x(p,T.valueBlock.value[Ta],aa.valueBlock.value[0].value);if(!1===sa.verified)if(!0===aa.valueBlock.value[0].optional)ma++;else return aa.hasOwnProperty("name")&&(aa.name=aa.name.replace(/^\s+|\s+$/g,""),""!==aa.name&&delete p[aa.name]),sa;if("name"in +aa.valueBlock.value[0]&&0this.tagNumber&&!this.isHexOnly){var aa=new ArrayBuffer(1);var ma=new Uint8Array(aa);p||(ma[0]=T|this.tagNumber&31);return aa}if(!1===this.isHexOnly){aa=f(this.tagNumber,7);var sa=new Uint8Array(aa),Ca=aa.byteLength;aa=new ArrayBuffer(Ca+1);ma=new Uint8Array(aa);ma[0]=T|31;if(!p){for(p=0;p=ma.length)return this.error="End of input reached before message was fully decoded",-1;if(p===sa){sa+=255;var Ca=new ArrayBuffer(sa);Ca=new Uint8Array(Ca);for(var Ta=0;Ta=this.blockLength?this.tagNumber=q(aa,7):(this.isHexOnly=!0,this.warnings.push("Tag too long, represented as hex-coded"))}if(1===this.tagClass&&this.isConstructed)switch(this.tagNumber){case 1:case 2:case 5:case 6:case 9:case 13:case 14:case 23:case 24:case 31:case 32:case 33:case 34:return this.error= +"Constructed encoding used for primitive type",-1}return T+this.blockLength};l.prototype.toJSON=function(){var p={};try{p=P.prototype.toJSON.call(this)}catch(T){}p.blockName=this.constructor.blockName();p.tagClass=this.tagClass;p.tagNumber=this.tagNumber;p.isConstructed=this.isConstructed;return p};var e=function(p){p=void 0===p?{}:p;var T=m.call(this)||this;"lenBlock"in p?(T.isIndefiniteForm=u(p.lenBlock,"isIndefiniteForm",!1),T.longFormUsed=u(p.lenBlock,"longFormUsed",!1),T.length=u(p.lenBlock, +"length",0)):(T.isIndefiniteForm=!1,T.longFormUsed=!1,T.length=0);return T};$jscomp.inherits(e,m);e.blockName=function(){return"lengthBlock"};e.prototype.fromBER=function(p,T,aa){if(!1===V(this,p,T,aa))return-1;p=new Uint8Array(p,T,aa);if(0===p.length)return this.error="Zero buffer length",-1;if(255===p[0])return this.error="Length block 0xFF is reserved by standard",-1;this.isIndefiniteForm=128===p[0];if(!0===this.isIndefiniteForm)return this.blockLength=1,T+this.blockLength;this.longFormUsed=!!(p[0]& +128);if(!1===this.longFormUsed)return this.length=p[0],this.blockLength=1,T+this.blockLength;aa=p[0]&127;if(8p.length)return this.error="End of input reached before message was fully decoded",-1;for(var ma=new Uint8Array(aa),sa=0;sa=this.length&&this.warnings.push("Unnecessary usage of long length form");this.blockLength= +aa+1;return T+this.blockLength};e.prototype.toBER=function(p){p=void 0===p?!1:p;127p.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)", +-1):T+aa};r.prototype.toBER=function(p){p=void 0===p?!1:p;var T=new ArrayBuffer(2);if(!0===p)return T;p=new Uint8Array(T);p[0]=5;p[1]=0;return T};r.prototype.toString=function(){return""+this.constructor.blockName()};var n=Q(G),v=function(p){p=void 0===p?{}:p;var T=n.call(this,p)||this;T.isConstructed=u(p,"isConstructed",!1);return T};$jscomp.inherits(v,n);v.prototype.fromBER=function(p,T,aa){if(!0===this.isConstructed){this.isHexOnly=!1;p=G.prototype.fromBER.call(this,p,T,aa);if(-1===p)return p; +for(aa=0;aa=eb.length:eb=d(new Uint8Array([Ab%10]),eb);break;default:eb[Ya-cb]=Ab%10}}0=z.length)for(var eb=z.length;eb<=Ya;eb++){for(var pb=new Uint8Array([0]),Xa=z[eb-1].slice(0),ub=Xa.length-1;0<=ub;ub--){var Ab=new Uint8Array([(Xa[ub]<<1)+pb[0]]);pb[0]=Ab[0]/10; +Xa[ub]=Ab[0]%10}0Xa:pb=1;eb[Ya-cb]=Xa+10;break;default:pb=0,eb[Ya-cb]=Xa}if(0Xa)pb=1,eb[Ya-cb]=Xa+10;else{eb[Ya-cb]=Xa;break}return eb.slice()}for(var ma=8*this._valueHex.byteLength-1, +sa=new Uint8Array(8*this._valueHex.byteLength/3),Ca=0,Ta,ib=new Uint8Array(this._valueHex),Yb="",ic=!1,jc=this._valueHex.byteLength-1;0<=jc;jc--){Ta=ib[jc];for(var xb=0;8>xb;xb++){if(1===(Ta&1))switch(Ca){case ma:sa=aa(T(Ca),sa);Yb="-";break;default:sa=p(sa,T(Ca))}Ca++;Ta>>=1}}for(ma=0;map?-1*p:p,aa=128,ma=1;8>ma;ma++){if(T<=aa){if(0>p){p=f(aa-T,8,ma);(new Uint8Array(p))[0]|=128;break a}p=f(T,8,ma);T=new Uint8Array(p);if(T[0]&128){aa=p.slice(0);ma=new Uint8Array(aa); +p=new ArrayBuffer(p.byteLength+1);T=new Uint8Array(p);for(var sa=0;sa=this.blockLength?this.valueDec=q(ma,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only"));return T+this.blockLength};ta.prototype.toBER=function(p){p=void 0===p?!1:p;if(this.isHexOnly){if(!0===p)return new ArrayBuffer(this.valueHex.byteLength); +var T=new Uint8Array(this.valueHex);var aa=new ArrayBuffer(this.blockLength);p=new Uint8Array(aa);for(var ma=0;ma=this.valueDec?p="0.":79>=this.valueDec?(p="1.",T-=40):(p="2.",T-=80);p+=T.toString()}else p=this.valueDec.toString();return p};ta.prototype.toJSON=function(){var p={};try{p=za.prototype.toJSON.call(this)}catch(T){}p.valueDec=this.valueDec;p.isFirstSid=this.isFirstSid;return p};$jscomp.global.Object.defineProperties(ta.prototype,{valueBigInt:{configurable:!0, +enumerable:!0,set:function(p){W();for(p=BigInt(p).toString(2);p.length%7;)p="0"+p;for(var T=new Uint8Array(p.length/7),aa=0;aaNumber.MAX_SAFE_INTEGER)W(),Ca.valueBigInt=BigInt(sa);else if(Ca.valueDec=parseInt(sa,10),isNaN(Ca.valueDec))break;0===this.value.length&&(aa=Ca.isFirstSid=!0);this.value.push(Ca)}}while(-1!==ma);return!0};c.prototype.toString=function(){for(var p="",T,aa=0;aa=this.blockLength?this.valueDec=q(ma,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only"));return T+this.blockLength};Ha.prototype.toBER=function(p){p=void 0===p?!1:p;if(this.isHexOnly){if(!0===p)return new ArrayBuffer(this.valueHex.byteLength);var T=new Uint8Array(this.valueHex);var aa=new ArrayBuffer(this.blockLength);p=new Uint8Array(aa);for(var ma=0;mathis.year?this.year-1900:this.year-2E3,2);p[1]=A(this.month,2);p[2]=A(this.day,2);p[3]=A(this.hour,2);p[4]=A(this.minute,2);p[5]=A(this.second,2);p[6]="Z";return p.join("")};Oa.blockName=function(){return"UTCTime"};Oa.prototype.toJSON=function(){var p={};try{p=oa.prototype.toJSON.call(this)}catch(T){}p.year=this.year;p.month= +this.month;p.day=this.day;p.hour=this.hour;p.minute=this.minute;p.second=this.second;return p};var Pa=function(p){p=void 0===p?{}:p;var T=oa.call(this,p)||this;T.year=0;T.month=0;T.day=0;T.hour=0;T.minute=0;T.second=0;T.millisecond=0;if("value"in p){T.fromString(p.value);T.valueBlock.valueHex=new ArrayBuffer(p.value.length);for(var aa=new Uint8Array(T.valueBlock.valueHex),ma=0;mae;e++){if(xP)x=new ArrayBuffer(e),P=e;else{if(P=x.length&&(e=1);var G=x.charCodeAt(l++);l>=x.length&&(w=1);h=x.charCodeAt(l++);P=y>>2;y=(y&3)<<4|G>>4;G=(G&15)<<2|h>>6;h&=63;1===e?G=h=64:1===w&&(h=64);J=m?64===G?J+(""+z.charAt(P)+z.charAt(y)):64===h?J+(""+z.charAt(P)+z.charAt(y)+z.charAt(G)):J+(""+z.charAt(P)+z.charAt(y)+z.charAt(G)+z.charAt(h)):J+(""+z.charAt(P)+z.charAt(y)+z.charAt(G)+z.charAt(h))}return J}function g(x,z,m){function P(S){for(var Z= +0;64>Z;Z++)if(l.charAt(Z)===S)return Z;return 64}m=void 0===m?!1:m;var l=(void 0===z?0:z)?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=":"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",e=0;for(z="";e=x.length?0:P(x.charAt(e++)),h=e>=x.length?0:P(x.charAt(e++)),y=e>=x.length?0:P(x.charAt(e++)),G=((64===J?0:J)&15)<<4|(64===h?0:h)>>2,M=((64===h?0:h)&3)<<6|(64===y?0:y);z+=String.fromCharCode((64===w?0:w)<<2|(64===J?0:J)>> +4);64!==h&&(z+=String.fromCharCode(G));64!==y&&(z+=String.fromCharCode(M))}if(m){x=-1;for(m=z.length-1;0<=m;m--)if(0!==z.charCodeAt(m)){x=m;break}z=-1!==x?z.slice(0,x+1):""}return z}function t(x){var z="";x=new Uint8Array(x);x=$jscomp.makeIterator(x);for(var m=x.next();!m.done;m=x.next())z+=String.fromCharCode(m.value);return z}function A(x){for(var z=x.length,m=new ArrayBuffer(z),P=new Uint8Array(m),l=0;lU.length;)U="0"+U;this.message=D+U+": "+v;this.stack=Error(this.message).stack}, +w;(function(r){r[r.NONE=0]="NONE";r[r.NULL_REFERENCE=1]="NULL_REFERENCE";r[r.NULL_PARAM=2]="NULL_PARAM";r[r.DECORATOR_NULL_PARAM=3]="DECORATOR_NULL_PARAM";r[r.COLLECTION_LIMIT=4]="COLLECTION_LIMIT";r[r.METHOD_NOT_IMPLEMENTED=5]="METHOD_NOT_IMPLEMENTED";r[r.METHOD_NOT_SUPPORTED=6]="METHOD_NOT_SUPPORTED";r[r.PARAM_REQUIRED=7]="PARAM_REQUIRED";r[r.CONVERTER_UNSUPPORTED=8]="CONVERTER_UNSUPPORTED";r[r.ELEMENT_MALFORMED=9]="ELEMENT_MALFORMED";r[r.ELEMENT_MISSING=10]="ELEMENT_MISSING";r[r.ATTRIBUTE_MISSING= +11]="ATTRIBUTE_MISSING";r[r.CONTENT_MISSING=12]="CONTENT_MISSING";r[r.CRYPTOGRAPHIC=13]="CRYPTOGRAPHIC";r[r.CRYPTOGRAPHIC_NO_MODULE=14]="CRYPTOGRAPHIC_NO_MODULE";r[r.CRYPTOGRAPHIC_UNKNOWN_TRANSFORM=15]="CRYPTOGRAPHIC_UNKNOWN_TRANSFORM";r[r.ALGORITHM_NOT_SUPPORTED=16]="ALGORITHM_NOT_SUPPORTED";r[r.ALGORITHM_WRONG_NAME=17]="ALGORITHM_WRONG_NAME";r[r.XML_EXCEPTION=18]="XML_EXCEPTION"})(w||(w={}));var J={};J[w.NONE]="No description";J[w.NULL_REFERENCE]="Null reference";J[w.NULL_PARAM]="'%1' has empty '%2' object"; +J[w.DECORATOR_NULL_PARAM]="Decorator '%1' has empty '%2' parameter";J[w.COLLECTION_LIMIT]="Collection of '%1' in element '%2' has wrong amount of items";J[w.METHOD_NOT_IMPLEMENTED]="Method is not implemented";J[w.METHOD_NOT_SUPPORTED]="Method is not supported";J[w.PARAM_REQUIRED]="Required parameter is missing '%1'";J[w.CONVERTER_UNSUPPORTED]="Converter is not supported";J[w.ELEMENT_MALFORMED]="Malformed element '%1'";J[w.ELEMENT_MISSING]="Element '%1' is missing in '%2'";J[w.ATTRIBUTE_MISSING]="Attribute '%1' is missing in '%2'"; +J[w.CONTENT_MISSING]="Content is missing in '%1'";J[w.CRYPTOGRAPHIC]="Cryptographic error: %1";J[w.CRYPTOGRAPHIC_NO_MODULE]="WebCrypto module is not found";J[w.CRYPTOGRAPHIC_UNKNOWN_TRANSFORM]="Unknown transform %1";J[w.ALGORITHM_NOT_SUPPORTED]="Algorithm is not supported '%1'";J[w.ALGORITHM_WRONG_NAME]="Algorithm wrong name in use '%1'";J[w.XML_EXCEPTION]="XML exception: %1";var h=function(){};h.ToString=function(r,n){n=void 0===n?"utf8":n;r=new Uint8Array(r);switch(n.toLowerCase()){case "utf8":return this.ToUtf8String(r); +case "binary":return this.ToBinary(r);case "hex":return this.ToHex(r);case "base64":return this.ToBase64(r);case "base64url":return this.ToBase64Url(r);default:throw new e(w.CONVERTER_UNSUPPORTED);}};h.FromString=function(r,n){switch((void 0===n?"utf8":n).toLowerCase()){case "utf8":return this.FromUtf8String(r);case "binary":return this.FromBinary(r);case "hex":return this.FromHex(r);case "base64":return this.FromBase64(r);case "base64url":return this.FromBase64Url(r);default:throw new e(w.CONVERTER_UNSUPPORTED); +}};h.ToBase64=function(r){if("undefined"!==typeof btoa)return r=this.ToString(r,"binary"),btoa(r);if("undefined"!==typeof u)return u.from(r).toString("base64");throw new e(w.CONVERTER_UNSUPPORTED);};h.FromBase64=function(r){r=r.replace(/\n/g,"").replace(/\r/g,"").replace(/\t/g,"").replace(/\s/g,"");if("undefined"!==typeof atob)return this.FromBinary(atob(r));if("undefined"!==typeof u)return new Uint8Array(u.from(r,"base64"));throw new e(w.CONVERTER_UNSUPPORTED);};h.FromBase64Url=function(r){return this.FromBase64(this.Base64Padding(r.replace(/\-/g, +"+").replace(/_/g,"/")))};h.ToBase64Url=function(r){return this.ToBase64(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")};h.FromUtf8String=function(r){r=unescape(encodeURIComponent(r));for(var n=new Uint8Array(r.length),v=0;vn)for(var v=0;v","application/xml")};ea.GetChildren=function(r,n,v){r=P(r)?r.documentElement:r;for(var D=[],U=0;UO.maxOccurs)throw new e(w.COLLECTION_LIMIT,N.localName,v.localName);pa.forEach(function(za){return n.appendChild(za.cloneNode(!0))})}else{if(K.childNodes.lengthO.maxOccurs)throw new e(w.COLLECTION_LIMIT,N.localName,v.localName);n.appendChild(K)}}}this.OnGetXml(n);return this.element=n};ea.prototype.LoadXml=function(r){r= +"string"===typeof r?W(r).documentElement:r;if(!r)throw new e(w.PARAM_REQUIRED,"element");var n=this.GetStatic(),v=this.localName;if(r.localName!==v||r.namespaceURI!=this.NamespaceURI)throw new e(w.ELEMENT_MALFORMED,v);if(n.items)for(var D in n.items)if(n.items.hasOwnProperty(D)){var U=n.items[D];switch(U.type){case "content":if(U.required&&!r.textContent)throw new e(w.CONTENT_MISSING,v);r.textContent?(U=U.converter?U.converter.set(r.textContent):r.textContent,this[D]=U):this[D]=U.defaultValue;break; +case "attribute":if(!U.localName)throw new e(w.PARAM_REQUIRED,"localName");if(U.namespaceURI){var N=r.hasAttributeNS.bind(r,U.namespaceURI,U.localName);var O=r.getAttributeNS.bind(r,U.namespaceURI,U.localName)}else N=r.hasAttribute.bind(r,U.localName),O=r.getAttribute.bind(r,U.localName);if(U.required&&!N())throw new e(w.ATTRIBUTE_MISSING,U.localName,v);N()?(U=U.converter?U.converter.set(O()):O(),this[D]=U):this[D]=U.defaultValue;break;case "element":if(U.noRoot){if(!U.parser)throw new e(w.XML_EXCEPTION, +"Schema for '"+U.localName+"' with flag noRoot must have 'parser'");N=new U.parser;if(!(N instanceof ia))throw new e(w.XML_EXCEPTION,"Schema for '"+U.localName+"' with flag noRoot must have 'parser' like instance of XmlCollection");N.OnLoadXml(r);delete N.element;if(N.CountU.maxOccurs)throw new e(w.COLLECTION_LIMIT,U.parser.localName,v);this[D]=N}else{N=null;for(O=0;Ov&&(n=v);0<=n;n--)if(v=this.items[n],v.prefix===r)return v;return null};na.prototype.GetNamespace=function(r,n){n=void 0===n?this.Count-1:n;var v=this.Count-1;r=r||"";for(n>v&&(n=v);0<=n;n--)if(v=this.items[n],v.namespace=== +r)return v;return null}}).call(this,C(6).Buffer,C(18))},function(Q,E,C){C.d(E,"a",function(){return V});var u=C(0),I=C(1),V=function(q){q=void 0===q?{}:q;this.algorithmId=Object(I.e)(q,"algorithmId",V.defaultValues("algorithmId"));"algorithmParams"in q&&(this.algorithmParams=Object(I.e)(q,"algorithmParams",V.defaultValues("algorithmParams")));"schema"in q&&this.fromSchema(q.schema)};V.defaultValues=function(q){switch(q){case "algorithmId":return"";case "algorithmParams":return new u.a;default:throw Error("Invalid member name for AlgorithmIdentifier class: "+ +q);}};V.compareWithDefault=function(q,f){switch(q){case "algorithmId":return""===f;case "algorithmParams":return f instanceof u.a;default:throw Error("Invalid member name for AlgorithmIdentifier class: "+q);}};V.schema=function(q){q=void 0===q?{}:q;q=Object(I.e)(q,"names",{});return new u.v({name:q.blockName||"",optional:q.optional||!1,value:[new u.p({name:q.algorithmIdentifier||""}),new u.a({name:q.algorithmParams||"",optional:!0})]})};V.prototype.fromSchema=function(q){Object(I.c)(q,["algorithm", +"params"]);q=u.D(q,q,V.schema({names:{algorithmIdentifier:"algorithm",algorithmParams:"params"}}));if(!1===q.verified)throw Error("Object's schema was not verified against input data for AlgorithmIdentifier");this.algorithmId=q.result.algorithm.valueBlock.toString();"params"in q.result&&(this.algorithmParams=q.result.params)};V.prototype.toSchema=function(){var q=[];q.push(new u.p({value:this.algorithmId}));"algorithmParams"in this&&!1===this.algorithmParams instanceof u.a&&q.push(this.algorithmParams); +return new u.v({value:q})};V.prototype.toJSON=function(){var q={algorithmId:this.algorithmId};"algorithmParams"in this&&!1===this.algorithmParams instanceof u.a&&(q.algorithmParams=this.algorithmParams.toJSON());return q};V.prototype.isEqual=function(q){return!1===q instanceof V||this.algorithmId!==q.algorithmId?!1:"algorithmParams"in this?"algorithmParams"in q?JSON.stringify(this.algorithmParams)===JSON.stringify(q.algorithmParams):!1:"algorithmParams"in q?!1:!0}},function(Q,E,C){(function(u,I){function V(l, +e,w){if("undefined"!==typeof u&&"pid"in u&&"undefined"!==typeof I&&"undefined"===typeof window){if("undefined"===typeof I[u.pid])I[u.pid]={};else if("object"!==typeof I[u.pid])throw Error("Name global."+u.pid+" already exists and it is not an object");if("undefined"===typeof I[u.pid].pkijs)I[u.pid].pkijs={};else if("object"!==typeof I[u.pid].pkijs)throw Error("Name global."+u.pid+".pkijs already exists and it is not an object");I[u.pid].pkijs.engine={name:l,crypto:e,subtle:w}}else P.name!==l&&(P= +{name:l,crypto:e,subtle:w})}function q(){if("undefined"!==typeof u&&"pid"in u&&"undefined"!==typeof I&&"undefined"===typeof window){try{var l=I[u.pid].pkijs.engine}catch(e){throw Error('Please call "setEngine" before call to "getEngine"');}return l}return P}function f(){var l=q();if(null!==l.subtle)return l.subtle}function k(l){return q().subtle.getRandomValues(l)}function d(l){return q().subtle.getOIDByAlgorithm(l)}function g(l){if(0!==l.byteLength%2)return new ArrayBuffer(0);var e=l.byteLength/ +2,w=new ArrayBuffer(e);(new Uint8Array(w)).set(new Uint8Array(l,0,e));w=new x.m({valueHex:w});var J=new ArrayBuffer(e);(new Uint8Array(J)).set(new Uint8Array(l,e,e));l=new x.m({valueHex:J});return(new x.v({value:[w.convertToDER(),l.convertToDER()]})).toBER(!1)}function t(l){var e=!1,w="";l=l.trim();for(var J=0;Jl.valueBlock.valueHex.byteLength:if(1!==e.valueBlock.valueHex.byteLength-l.valueBlock.valueHex.byteLength)throw Error("Incorrect DER integer decoding");w=e.valueBlock.valueHex.byteLength;l=new Uint8Array(l.valueBlock.valueHex);w=new ArrayBuffer(w);J=new Uint8Array(w);J.set(l,1);J[0]=0;return Object(z.j)(e.valueBlock.valueHex,w);default:if(e.valueBlock.valueHex.byteLength%2){w=e.valueBlock.valueHex.byteLength+1;J=new Uint8Array(e.valueBlock.valueHex); +e=new ArrayBuffer(w);var h=new Uint8Array(e);h.set(J,1);h[0]=0;l=new Uint8Array(l.valueBlock.valueHex);w=new ArrayBuffer(w);J=new Uint8Array(w);J.set(l,1);J[0]=0;return Object(z.j)(e,w)}}return Object(z.j)(e.valueBlock.valueHex,l.valueBlock.valueHex)}function W(l){return q().subtle.getAlgorithmByOID(l)}function F(l,e,w,J){switch(l.toUpperCase()){case "SHA-1":case "SHA-256":case "SHA-384":case "SHA-512":break;default:return Promise.reject("Unknown hash function: "+l)}if(!1===e instanceof ArrayBuffer)return Promise.reject('Please set "Zbuffer" as "ArrayBuffer"'); +if(0===e.byteLength)return Promise.reject('"Zbuffer" has zero length, error');if(!1===J instanceof ArrayBuffer)return Promise.reject('Please set "SharedInfo" as "ArrayBuffer"');if(255>=3;if(S.byteLength>w){M=new ArrayBuffer(w);Z=new Uint8Array(M);S=new Uint8Array(S);for(ca=0;caD||v.byteLengthn)throw new RangeError('"size" argument must not be negative');}function d(n,v){k(v);n=V(n,0>v?0:A(v)|0);if(!q.TYPED_ARRAY_SUPPORT)for(var D=0;Dv.length?0:A(v.length)|0;n=V(n,D);for(var U=0;U=(q.TYPED_ARRAY_SUPPORT?2147483647:1073741823))throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+(q.TYPED_ARRAY_SUPPORT?2147483647:1073741823).toString(16)+" bytes");return n|0}function W(n,v){if(q.isBuffer(n))return n.length;if("undefined"!==typeof ArrayBuffer&&"function"===typeof ArrayBuffer.isView&&(ArrayBuffer.isView(n)||n instanceof ArrayBuffer))return n.byteLength;"string"!==typeof n&&(n=""+n);var D=n.length;if(0===D)return 0;for(var U=!1;;)switch(v){case "ascii":case "latin1":case "binary":return D; +case "utf8":case "utf-8":case void 0:return G(n).length;case "ucs2":case "ucs-2":case "utf16le":case "utf-16le":return 2*D;case "hex":return D>>>1;case "base64":return S(n).length;default:if(U)return G(n).length;v=(""+v).toLowerCase();U=!0}}function F(n,v,D){var U=!1;if(void 0===v||0>v)v=0;if(v>this.length)return"";if(void 0===D||D>this.length)D=this.length;if(0>=D)return"";D>>>=0;v>>>=0;if(D<=v)return"";for(n||(n="utf8");;)switch(n){case "hex":n=v;v=D;D=this.length;if(!n||0>n)n=0;if(!v||0>v||v>D)v= +D;U="";for(D=n;DU?"0"+U.toString(16):U.toString(16),U=n+U;return U;case "utf8":case "utf-8":return m(this,v,D);case "ascii":n="";for(D=Math.min(this.length,D);vD&&(D=-2147483648);D=+D;isNaN(D)&&(D=N?0:n.length-1);0>D&&(D=n.length+D);if(D>=n.length){if(N)return-1;D=n.length-1}else if(0>D)if(N)D=0;else return-1;"string"=== +typeof v&&(v=q.from(v,U));if(q.isBuffer(v))return 0===v.length?-1:z(n,v,D,U,N);if("number"===typeof v)return v&=255,q.TYPED_ARRAY_SUPPORT&&"function"===typeof Uint8Array.prototype.indexOf?N?Uint8Array.prototype.indexOf.call(n,v,D):Uint8Array.prototype.lastIndexOf.call(n,v,D):z(n,[v],D,U,N);throw new TypeError("val must be string, number or Buffer");}function z(n,v,D,U,N){function O(ua,za){return 1===K?ua[za]:ua.readUInt16BE(za*K)}var K=1,pa=n.length,xa=v.length;if(void 0!==U&&(U=String(U).toLowerCase(), +"ucs2"===U||"ucs-2"===U||"utf16le"===U||"utf-16le"===U)){if(2>n.length||2>v.length)return-1;K=2;pa/=2;xa/=2;D/=2}if(N)for(U=-1;Dpa&&(D=pa-xa);0<=D;D--){pa=!0;for(U=0;UN&&(O=N);break; +case 2:var pa=n[v+1];128===(pa&192)&&(N=(N&31)<<6|pa&63,127N||57343N&&(O=N))}null===O?(O=65533,K=1):65535>>10&1023|55296),O=56320|O&1023);U.push(O);v+=K}n=U.length;if(n<=na)U=String.fromCharCode.apply(String, +U);else{D="";for(v=0;vn)throw new RangeError("offset is not uint");if(n+v>D)throw new RangeError("Trying to access beyond buffer length");}function l(n,v,D,U,N,O){if(!q.isBuffer(n))throw new TypeError('"buffer" argument must be a Buffer instance');if(v>N||vn.length)throw new RangeError("Index out of range");}function e(n,v,D,U){0> +v&&(v=65535+v+1);for(var N=0,O=Math.min(n.length-D,2);N>>8*(U?N:1-N)}function w(n,v,D,U){0>v&&(v=4294967295+v+1);for(var N=0,O=Math.min(n.length-D,4);N>>8*(U?N:3-N)&255}function J(n,v,D,U,N,O){if(D+U>n.length)throw new RangeError("Index out of range");if(0>D)throw new RangeError("Index out of range");}function h(n,v,D,U,N){N||J(n,v,D,4,3.4028234663852886E38,-3.4028234663852886E38);ea.write(n,v,D,U,23,4);return D+4}function y(n,v,D,U,N){N||J(n,v,D, +8,1.7976931348623157E308,-1.7976931348623157E308);ea.write(n,v,D,U,52,8);return D+8}function G(n,v){v=v||Infinity;for(var D,U=n.length,N=null,O=[],K=0;KD){if(!N){if(56319D){-1<(v-=3)&&O.push(239,191,189);N=D;continue}D=(N-55296<<10|D-56320)+65536}else N&&-1<(v-=3)&&O.push(239,191,189);N=null;if(128>D){if(0>--v)break;O.push(D)}else if(2048> +D){if(0>(v-=2))break;O.push(D>>6|192,D&63|128)}else if(65536>D){if(0>(v-=3))break;O.push(D>>12|224,D>>6&63|128,D&63|128)}else if(1114112>D){if(0>(v-=4))break;O.push(D>>18|240,D>>12&63|128,D>>6&63|128,D&63|128)}else throw Error("Invalid code point");}return O}function M(n){for(var v=[],D=0;Dn.length)n="";else for(;0!==n.length%4;)n+="=";return D.call(v, +n)}function Z(n,v,D,U){for(var N=0;N=v.length||N>=n.length);++N)v[N+D]=n[N];return N}var ca=C(64),ea=C(65),ia=C(66);E.Buffer=q;E.SlowBuffer=function(n){+n!=n&&(n=0);return q.alloc(+n)};E.INSPECT_MAX_BYTES=50;q.TYPED_ARRAY_SUPPORT=void 0!==u.TYPED_ARRAY_SUPPORT?u.TYPED_ARRAY_SUPPORT:I();E.kMaxLength=q.TYPED_ARRAY_SUPPORT?2147483647:1073741823;q.poolSize=8192;q._augment=function(n){n.__proto__=q.prototype;return n};q.from=function(n,v,D){return f(null,n,v,D)};q.TYPED_ARRAY_SUPPORT&&(q.prototype.__proto__= +Uint8Array.prototype,q.__proto__=Uint8Array,"undefined"!==typeof Symbol&&Symbol.species&&q[Symbol.species]===q&&Object.defineProperty(q,Symbol.species,{value:null,configurable:!0}));q.alloc=function(n,v,D){k(n);n=0>=n?V(null,n):void 0!==v?"string"===typeof D?V(null,n).fill(v,D):V(null,n).fill(v):V(null,n);return n};q.allocUnsafe=function(n){return d(null,n)};q.allocUnsafeSlow=function(n){return d(null,n)};q.isBuffer=function(n){return!(null==n||!n._isBuffer)};q.compare=function(n,v){if(!q.isBuffer(n)|| +!q.isBuffer(v))throw new TypeError("Arguments must be Buffers");if(n===v)return 0;for(var D=n.length,U=v.length,N=0,O=Math.min(D,U);Nv&&(n+=" ... "));return""};q.prototype.compare=function(n,v,D,U,N){if(!q.isBuffer(n))throw new TypeError("Argument must be a Buffer");void 0===v&&(v=0);void 0===D&&(D=n?n.length:0);void 0===U&& +(U=0);void 0===N&&(N=this.length);if(0>v||D>n.length||0>U||N>this.length)throw new RangeError("out of range index");if(U>=N&&v>=D)return 0;if(U>=N)return-1;if(v>=D)return 1;v>>>=0;D>>>=0;U>>>=0;N>>>=0;if(this===n)return 0;var O=N-U,K=D-v,pa=Math.min(O,K);U=this.slice(U,N);n=n.slice(v,D);for(v=0;vN)D=N;if(0D||0>v)||v>this.length)throw new RangeError("Attempt to write outside buffer bounds"); +U||(U="utf8");for(N=!1;;)switch(U){case "hex":a:{v=Number(v)||0;U=this.length-v;D?(D=Number(D),D>U&&(D=U)):D=U;U=n.length;if(0!==U%2)throw new TypeError("Invalid hex string");D>U/2&&(D=U/2);for(U=0;U(N-=2));++K){var pa=U.charCodeAt(K);n=pa>>8;pa%=256;O.push(pa);O.push(n)}return Z(O,this,v,D);default:if(N)throw new TypeError("Unknown encoding: "+U);U=(""+U).toLowerCase();N=!0}};q.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var na=4096;q.prototype.slice=function(n,v){var D=this.length;n=~~n;v=void 0===v?D:~~v;0>n?(n+=D,0>n&&(n=0)):n>D&&(n=D);0>v?(v+=D,0>v&&(v=0)):v>D&&(v=D);v=128*U&&(D-=Math.pow(2,8*v));return D};q.prototype.readIntBE=function(n,v,D){n|=0;v|=0;D||P(n,v,this.length);D=v;for(var U=1,N=this[n+--D];0=128*U&&(N-=Math.pow(2,8*v));return N};q.prototype.readInt8=function(n,v){v||P(n,1,this.length);return this[n]&128?-1*(255-this[n]+1):this[n]};q.prototype.readInt16LE=function(n,v){v||P(n,2,this.length);n=this[n]|this[n+1]<<8;return n&32768?n|4294901760:n};q.prototype.readInt16BE=function(n,v){v||P(n,2,this.length); +n=this[n+1]|this[n]<<8;return n&32768?n|4294901760:n};q.prototype.readInt32LE=function(n,v){v||P(n,4,this.length);return this[n]|this[n+1]<<8|this[n+2]<<16|this[n+3]<<24};q.prototype.readInt32BE=function(n,v){v||P(n,4,this.length);return this[n]<<24|this[n+1]<<16|this[n+2]<<8|this[n+3]};q.prototype.readFloatLE=function(n,v){v||P(n,4,this.length);return ea.read(this,n,!0,23,4)};q.prototype.readFloatBE=function(n,v){v||P(n,4,this.length);return ea.read(this,n,!1,23,4)};q.prototype.readDoubleLE=function(n, +v){v||P(n,8,this.length);return ea.read(this,n,!0,52,8)};q.prototype.readDoubleBE=function(n,v){v||P(n,8,this.length);return ea.read(this,n,!1,52,8)};q.prototype.writeUIntLE=function(n,v,D,U){n=+n;v|=0;D|=0;U||l(this,n,v,D,Math.pow(2,8*D)-1,0);U=1;var N=0;for(this[v]=n&255;++N>>8):e(this,n,v,!0);return v+2};q.prototype.writeUInt16BE=function(n,v,D){n=+n;v|=0;D||l(this,n,v,2,65535,0);q.TYPED_ARRAY_SUPPORT?(this[v]=n>>>8,this[v+1]=n&255):e(this,n,v,!1);return v+2};q.prototype.writeUInt32LE=function(n,v,D){n=+n;v|=0;D||l(this,n,v,4,4294967295, +0);q.TYPED_ARRAY_SUPPORT?(this[v+3]=n>>>24,this[v+2]=n>>>16,this[v+1]=n>>>8,this[v]=n&255):w(this,n,v,!0);return v+4};q.prototype.writeUInt32BE=function(n,v,D){n=+n;v|=0;D||l(this,n,v,4,4294967295,0);q.TYPED_ARRAY_SUPPORT?(this[v]=n>>>24,this[v+1]=n>>>16,this[v+2]=n>>>8,this[v+3]=n&255):w(this,n,v,!1);return v+4};q.prototype.writeIntLE=function(n,v,D,U){n=+n;v|=0;U||(U=Math.pow(2,8*D-1),l(this,n,v,D,U-1,-U));U=0;var N=1,O=0;for(this[v]=n&255;++Un&&0===O&&0!==this[v+U-1]&&(O=1),this[v+ +U]=(n/N>>0)-O&255;return v+D};q.prototype.writeIntBE=function(n,v,D,U){n=+n;v|=0;U||(U=Math.pow(2,8*D-1),l(this,n,v,D,U-1,-U));U=D-1;var N=1,O=0;for(this[v+U]=n&255;0<=--U&&(N*=256);)0>n&&0===O&&0!==this[v+U+1]&&(O=1),this[v+U]=(n/N>>0)-O&255;return v+D};q.prototype.writeInt8=function(n,v,D){n=+n;v|=0;D||l(this,n,v,1,127,-128);q.TYPED_ARRAY_SUPPORT||(n=Math.floor(n));0>n&&(n=255+n+1);this[v]=n&255;return v+1};q.prototype.writeInt16LE=function(n,v,D){n=+n;v|=0;D||l(this,n,v,2,32767,-32768);q.TYPED_ARRAY_SUPPORT? +(this[v]=n&255,this[v+1]=n>>>8):e(this,n,v,!0);return v+2};q.prototype.writeInt16BE=function(n,v,D){n=+n;v|=0;D||l(this,n,v,2,32767,-32768);q.TYPED_ARRAY_SUPPORT?(this[v]=n>>>8,this[v+1]=n&255):e(this,n,v,!1);return v+2};q.prototype.writeInt32LE=function(n,v,D){n=+n;v|=0;D||l(this,n,v,4,2147483647,-2147483648);q.TYPED_ARRAY_SUPPORT?(this[v]=n&255,this[v+1]=n>>>8,this[v+2]=n>>>16,this[v+3]=n>>>24):w(this,n,v,!0);return v+4};q.prototype.writeInt32BE=function(n,v,D){n=+n;v|=0;D||l(this,n,v,4,2147483647, +-2147483648);0>n&&(n=4294967295+n+1);q.TYPED_ARRAY_SUPPORT?(this[v]=n>>>24,this[v+1]=n>>>16,this[v+2]=n>>>8,this[v+3]=n&255):w(this,n,v,!1);return v+4};q.prototype.writeFloatLE=function(n,v,D){return h(this,n,v,!0,D)};q.prototype.writeFloatBE=function(n,v,D){return h(this,n,v,!1,D)};q.prototype.writeDoubleLE=function(n,v,D){return y(this,n,v,!0,D)};q.prototype.writeDoubleBE=function(n,v,D){return y(this,n,v,!1,D)};q.prototype.copy=function(n,v,D,U){D||(D=0);U||0===U||(U=this.length);v>=n.length&& +(v=n.length);v||(v=0);0v)throw new RangeError("targetStart out of bounds");if(0>D||D>=this.length)throw new RangeError("sourceStart out of bounds");if(0>U)throw new RangeError("sourceEnd out of bounds");U>this.length&&(U=this.length);n.length-vN||!q.TYPED_ARRAY_SUPPORT)for(U=0;UN&&(n=N)}if(void 0!==U&&"string"!==typeof U)throw new TypeError("encoding must be a string");if("string"===typeof U&&!q.isEncoding(U))throw new TypeError("Unknown encoding: "+U);}else"number"===typeof n&&(n&=255);if(0>v||this.length>>=0;D=void 0===D?this.length:D>>>0;n||(n=0);if("number"===typeof n)for(U=v;U=this.length()};t.ByteStringBuffer.prototype.putByte=function(e){return this.putBytes(String.fromCharCode(e))};t.ByteStringBuffer.prototype.fillWithByte=function(e,w){e=String.fromCharCode(e);for(var J=this.data;0>>=1,0>8&255)+String.fromCharCode(e&255))};t.ByteStringBuffer.prototype.putInt24=function(e){return this.putBytes(String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(e& +255))};t.ByteStringBuffer.prototype.putInt32=function(e){return this.putBytes(String.fromCharCode(e>>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(e&255))};t.ByteStringBuffer.prototype.putInt16Le=function(e){return this.putBytes(String.fromCharCode(e&255)+String.fromCharCode(e>>8&255))};t.ByteStringBuffer.prototype.putInt24Le=function(e){return this.putBytes(String.fromCharCode(e&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255))};t.ByteStringBuffer.prototype.putInt32Le= +function(e){return this.putBytes(String.fromCharCode(e&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>24&255))};t.ByteStringBuffer.prototype.putInt=function(e,w){f(w);var J="";do w-=8,J+=String.fromCharCode(e>>w&255);while(0e&&(e+=2<=e&&(w-=e<<1);return w};t.ByteStringBuffer.prototype.getBytes=function(e){if(e){e=Math.min(this.length(),e);var w=this.data.slice(this.read,this.read+ +e);this.read+=e}else 0===e?w="":(w=0===this.read?this.data:this.data.slice(this.read),this.clear());return w};t.ByteStringBuffer.prototype.bytes=function(e){return"undefined"===typeof e?this.data.slice(this.read):this.data.slice(this.read,this.read+e)};t.ByteStringBuffer.prototype.at=function(e){return this.data.charCodeAt(this.read+e)};t.ByteStringBuffer.prototype.setAt=function(e,w){this.data=this.data.substr(0,this.read+e)+String.fromCharCode(w)+this.data.substr(this.read+e+1);return this};t.ByteStringBuffer.prototype.last= +function(){return this.data.charCodeAt(this.data.length-1)};t.ByteStringBuffer.prototype.copy=function(){var e=t.createBuffer(this.data);e.read=this.read;return e};t.ByteStringBuffer.prototype.compact=function(){0J&&(e+="0");e+=J.toString(16)}return e};t.ByteStringBuffer.prototype.toString=function(){return t.decodeUtf8(this.bytes())};t.DataBuffer=function(e,w){w=w||{};this.read=w.readOffset||0;this.growSize=w.growSize||1024;var J=t.isArrayBuffer(e),h=t.isArrayBufferView(e);J||h?(this.data=J?new DataView(e):new DataView(e.buffer,e.byteOffset,e.byteLength),this.write= +"writeOffset"in w?w.writeOffset:this.data.byteLength):(this.data=new DataView(new ArrayBuffer(0)),this.write=0,null!==e&&void 0!==e&&this.putBytes(e),"writeOffset"in w&&(this.write=w.writeOffset))};t.DataBuffer.prototype.length=function(){return this.write-this.read};t.DataBuffer.prototype.isEmpty=function(){return 0>=this.length()};t.DataBuffer.prototype.accommodate=function(e,w){if(this.length()>=e)return this;w=Math.max(w||this.growSize,e);e=new Uint8Array(this.data.buffer,this.data.byteOffset, +this.data.byteLength);w=new Uint8Array(this.length()+w);w.set(e);this.data=new DataView(w.buffer);return this};t.DataBuffer.prototype.putByte=function(e){this.accommodate(1);this.data.setUint8(this.write++,e);return this};t.DataBuffer.prototype.fillWithByte=function(e,w){this.accommodate(w);for(var J=0;J>8&65535);this.data.setInt8(this.write,e>>16&255);this.write+=3;return this};t.DataBuffer.prototype.putInt32=function(e){this.accommodate(4);this.data.setInt32(this.write,e);this.write+=4;return this};t.DataBuffer.prototype.putInt16Le=function(e){this.accommodate(2);this.data.setInt16(this.write, +e,!0);this.write+=2;return this};t.DataBuffer.prototype.putInt24Le=function(e){this.accommodate(3);this.data.setInt8(this.write,e>>16&255);this.data.setInt16(this.write,e>>8&65535,!0);this.write+=3;return this};t.DataBuffer.prototype.putInt32Le=function(e){this.accommodate(4);this.data.setInt32(this.write,e,!0);this.write+=4;return this};t.DataBuffer.prototype.putInt=function(e,w){f(w);this.accommodate(w/8);do w-=8,this.data.setInt8(this.write++,e>>w&255);while(0e&&(e+=2<=e&&(w-=e<<1);return w};t.DataBuffer.prototype.getBytes=function(e){if(e){e=Math.min(this.length(),e);var w=this.data.slice(this.read,this.read+e);this.read+=e}else 0===e?w="":(w=0===this.read?this.data:this.data.slice(this.read),this.clear());return w};t.DataBuffer.prototype.bytes=function(e){return"undefined"===typeof e?this.data.slice(this.read):this.data.slice(this.read,this.read+e)};t.DataBuffer.prototype.at=function(e){return this.data.getUint8(this.read+ +e)};t.DataBuffer.prototype.setAt=function(e,w){this.data.setUint8(e,w);return this};t.DataBuffer.prototype.last=function(){return this.data.getUint8(this.write-1)};t.DataBuffer.prototype.copy=function(){return new t.DataBuffer(this)};t.DataBuffer.prototype.compact=function(){if(0J&&(e+="0");e+=J.toString(16)}return e};t.DataBuffer.prototype.toString=function(e){var w=new Uint8Array(this.data,this.read,this.length());e=e||"utf8";if("binary"===e||"raw"=== +e)return t.binary.raw.encode(w);if("hex"===e)return t.binary.hex.encode(w);if("base64"===e)return t.binary.base64.encode(w);if("utf8"===e)return t.text.utf8.decode(w);if("utf16"===e)return t.text.utf16.decode(w);throw Error("Invalid encoding: "+e);};t.createBuffer=function(e,w){void 0!==e&&"utf8"===(w||"raw")&&(e=t.encodeUtf8(e));return new t.ByteBuffer(e)};t.fillString=function(e,w){for(var J="";0>>=1,0>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(e&255)}; +var A=[62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,64,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51];t.encode64=function(e,w){for(var J="",h="",y,G,M,S=0;S>2),J+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt((y& +3)<<4|G>>4),isNaN(G)?J+="==":(J+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt((G&15)<<2|M>>6),J+=isNaN(M)?"=":"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(M&63)),w&&J.length>w&&(h+=J.substr(0,w)+"\r\n",J=J.substr(w));return h+J};t.decode64=function(e){e=e.replace(/[^A-Za-z0-9\+\/=]/g,"");for(var w="",J,h,y,G,M=0;M>4),64!==y&&(w+=String.fromCharCode((h&15)<<4|y>>2),64!==G&&(w+=String.fromCharCode((y&3)<<6|G)));return w};t.encodeUtf8=function(e){return unescape(encodeURIComponent(e))};t.decodeUtf8=function(e){return decodeURIComponent(escape(e))};t.binary={raw:{},hex:{},base64:{},base58:{},baseN:{encode:g.encode,decode:g.decode}};t.binary.raw.encode=function(e){return String.fromCharCode.apply(null,e)};t.binary.raw.decode=function(e,w,J){var h=w;h||(h=new Uint8Array(e.length));for(var y=J=J||0,G=0;G>2),J+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt((y& +3)<<4|G>>4),isNaN(G)?J+="==":(J+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt((G&15)<<2|M>>6),J+=isNaN(M)?"=":"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(M&63)),w&&J.length>w&&(h+=J.substr(0,w)+"\r\n",J=J.substr(w));return h+J};t.binary.base64.decode=function(e,w,J){var h=w;h||(h=new Uint8Array(3*Math.ceil(e.length/4)));e=e.replace(/[^A-Za-z0-9\+\/=]/g,"");J=J||0;for(var y,G,M,S,Z=0,ca=J;Z>4,64!==M&&(h[ca++]=(G&15)<<4|M>>2,64!==S&&(h[ca++]=(M&3)<<6|S));return w?ca-J:h.subarray(0,ca)};t.binary.base58.encode=function(e,w){return t.binary.baseN.encode(e,"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",w)};t.binary.base58.decode=function(e,w){return t.binary.baseN.decode(e,"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",w)};t.text={utf8:{},utf16:{}};t.text.utf8.encode=function(e,w,J){e=t.encodeUtf8(e); +var h=w;h||(h=new Uint8Array(e.length));for(var y=J=J||0,G=0;G");break;case "%":G.push("%");break;default:G.push("<%"+J+"?>")}G.push(e.substring(h)); +return G.join("")};t.formatNumber=function(e,w,J,h){var y=isNaN(w=Math.abs(w))?2:w;w=void 0===J?",":J;h=void 0===h?".":h;J=0>e?"-":"";var G=parseInt(e=Math.abs(+e||0).toFixed(y),10)+"",M=3y;++y)if(e[y]&&0!==e[y].length){var G=t.hexToBytes(e[y]);2>G.length&&h.putByte(0);h.putBytes(G)}else h.fillWithByte(0,J),J=0;return h.getBytes()};t.bytesToIP=function(e){return 4===e.length?t.bytesToIPv4(e):16===e.length?t.bytesToIPv6(e):null};t.bytesToIPv4=function(e){if(4!==e.length)return null;for(var w=[],J=0;JJ[h].end-J[h].start&&(h=J.length-1)):J.push({start:S,end:S})}w.push(G)}0r.st&&ea.stea.st&&r.stthis.encryptedContent.valueBlock.valueHex.byteLength?this.encryptedContent.valueBlock.valueHex.byteLength-d:1024),A=new ArrayBuffer(t.length),W=new Uint8Array(A),F=0;Fd){var t=Error("Too few bytes to parse DER.");t.available=k.length();t.remaining=d;t.requested=g;throw t;}}function I(k,d,g,t){u(k,d,2);var A=k.getByte();d--;var W=A&192,F=A&31;var H=k.length();var x=d;var z=k.getByte();x--;if(128===z)x=void 0;else if(z&128?(z&=127,u(k,x,z),x=k.getInt(z<<3)):x=z,0>x)throw Error("Negative length: "+x);d-=H-k.length();if(void 0!==x&&x>d){if(t.strict)throw g=Error("Too few bytes to read ASN.1 value."),g.available=k.length(),g.remaining= +d,g.requested=x,g;x=d}var m;if(A=32===(A&32)){var P=[];if(void 0===x)for(;;){u(k,d,2);if(k.bytes(2)===String.fromCharCode(0,0)){k.getBytes(2);d-=2;break}H=k.length();P.push(I(k,d,g+1,t));d-=H-k.length()}else for(;0=t.length())d.putByte(t.length()& +127);else{g=t.length();k="";do k+=String.fromCharCode(g&255),g>>>=8;while(0>>=7,g||(W|=128),t.push(W),g=!1;while(0g[k].length&&(d+="0"),d+=g[k];return d+"Z"};q.dateToGeneralizedTime=function(k){if("string"===typeof k)return k;var d="",g=[];g.push(""+k.getUTCFullYear());g.push(""+(k.getUTCMonth()+1));g.push(""+k.getUTCDate());g.push(""+k.getUTCHours());g.push(""+k.getUTCMinutes());g.push(""+k.getUTCSeconds());for(k=0;kg[k].length&&(d+="0"),d+=g[k];return d+"Z"};q.integerToDer=function(k){var d=V.util.createBuffer();if(-128<= +k&&128>k)return d.putSignedInt(k,8);if(-32768<=k&&32768>k)return d.putSignedInt(k,16);if(-8388608<=k&&8388608>k)return d.putSignedInt(k,24);if(-2147483648<=k&&2147483648>k)return d.putSignedInt(k,32);d=Error("Integer too large; max is 32-bits.");d.integer=k;throw d;};q.derToInteger=function(k){"string"===typeof k&&(k=V.util.createBuffer(k));var d=8*k.length();if(32k.bitStringContents.length)g[d.captureBitStringValue]="";else{if(0!==k.bitStringContents.charCodeAt(0))throw Error("captureBitStringValue only supported for zero unused bits"); +g[d.captureBitStringValue]=k.bitStringContents.slice(1)}}else t&&t.push("["+d.name+'] Expected constructed "'+d.constructed+'", got "'+k.constructed+'"');return A};var f=/[^\\u0000-\\u00ff]/;q.prettyPrint=function(k,d,g){var t="";d=d||0;g=g||2;0z;++z)x[z]=z<<1,x[z+128]=z+128<<1^283;t=Array(256);A=Array(256);F=Array(4);H=Array(4);for(z=0;4>z;++z)F[z]=Array(256),H[z]=Array(256);var m=0,P=0;for(z=0;256>z;++z){var l=P^P<<1^P<<2^P<<3^P<<4;l=l>>8^l&255^99;t[m]=l;A[l]=m;var e=x[l];var w=x[m];var J=x[w];var h=x[J];e^=e<<24^l<<16^l<<8^l;J=(w^J^h)<<24^(m^h)<<16^(m^J^h)<<8^m^w^ +h;for(var y=0;4>y;++y)F[y][m]=e,H[y][l]=J,e=e<<24|e>>>8,J=J<<24|J>>>8;0===m?m=P=1:(m=w^x[x[x[w^h]]],P^=x[x[P]])}}function V(x,z){x=x.slice(0);for(var m,P=1,l=x.length,e=g*(l+6+1),w=l;w>>16&255]<<24^t[m>>>8&255]<<16^t[m&255]<<8^t[m>>>24]^W[P]<<24,P++):6>>24]<<24^t[m>>>16&255]<<16^t[m>>>8&255]<<8^t[m&255]),x[w]=x[w-l]^m;if(z){m=H[0];P=H[1];l=H[2];var J=H[3],h=x.slice(0);e=x.length;w=0;for(var y=e-g;w>>24]]^P[t[z>>>16&255]]^l[t[z>>>8&255]]^J[t[z&255]];x=h}return x}function q(x,z,m,P){var l=x.length/4-1;if(P){var e=H[0];var w=H[1];var J=H[2];var h=H[3];var y=A}else e=F[0],w=F[1],J=F[2],h=F[3],y=t;var G=z[0]^x[0];var M=z[P?3:1]^x[1];var S=z[2]^x[2];z=z[P?1:3]^x[3];for(var Z=3,ca=1;ca>>24]^w[M>>>16&255]^J[S>>>8&255]^h[z&255]^x[++Z];var ia=e[M>>>24]^w[S>>>16&255]^J[z>>>8&255]^h[G&255]^x[++Z];var na= +e[S>>>24]^w[z>>>16&255]^J[G>>>8&255]^h[M&255]^x[++Z];z=e[z>>>24]^w[G>>>16&255]^J[M>>>8&255]^h[S&255]^x[++Z];G=ea;M=ia;S=na}m[0]=y[G>>>24]<<24^y[M>>>16&255]<<16^y[S>>>8&255]<<8^y[z&255]^x[++Z];m[P?3:1]=y[M>>>24]<<24^y[S>>>16&255]<<16^y[z>>>8&255]<<8^y[G&255]^x[++Z];m[2]=y[S>>>24]<<24^y[z>>>16&255]<<16^y[G>>>8&255]<<8^y[M&255]^x[++Z];m[P?1:3]=y[z>>>24]<<24^y[G>>>16&255]<<16^y[M>>>8&255]<<8^y[S&255]^x[++Z]}function f(x){x=x||{};var z="AES-"+(x.mode||"CBC").toUpperCase();var m=x.decrypt?k.cipher.createDecipher(z, +x.key):k.cipher.createCipher(z,x.key);var P=m.start;m.start=function(l,e){var w=null;e instanceof k.util.ByteBuffer&&(w=e,e={});e=e||{};e.output=w;e.iv=l;P.call(m,e)};return m}var k=C(5);C(37);C(48);C(7);Q.exports=k.aes=k.aes||{};k.aes.startEncrypting=function(x,z,m,P){x=f({key:x,output:m,decrypt:!1,mode:P});x.start(z);return x};k.aes.createEncryptionCipher=function(x,z){return f({key:x,output:null,decrypt:!1,mode:z})};k.aes.startDecrypting=function(x,z,m,P){x=f({key:x,output:m,decrypt:!0,mode:P}); +x.start(z);return x};k.aes.createDecryptionCipher=function(x,z){return f({key:x,output:null,decrypt:!0,mode:z})};k.aes.Algorithm=function(x,z){d||I();var m=this;m.name=x;m.mode=new z({blockSize:16,cipher:{encrypt:function(P,l){return q(m._w,P,l,!1)},decrypt:function(P,l){return q(m._w,P,l,!0)}}});m._init=!1};k.aes.Algorithm.prototype.initialize=function(x){if(!this._init){var z=x.key;if("string"===typeof z&&(16===z.length||24===z.length||32===z.length))z=k.util.createBuffer(z);else if(k.util.isArray(z)&& +(16===z.length||24===z.length||32===z.length)){var m=z;z=k.util.createBuffer();for(var P=0;P>>=2,P=0;Pd)for(var g=0;gI.blockLength&&(I.start(),I.update(d.bytes()),d=I.digest());V=u.util.createBuffer();q=u.util.createBuffer();t=d.length();for(g=0;gz;++z)g=d.getInt32(),k[z]=g,x=F^A&(W^F),g=(t<<5|t>>>27)+x+H+1518500249+g,H=F,F=W,W=(A<<30|A>>>2)>>>0,A=t,t=g;for(;20>z;++z)g=k[z-3]^k[z-8]^k[z-14]^k[z-16],g=g<<1|g>>>31,k[z]=g,x=F^A&(W^F),g=(t<<5|t>>>27)+x+H+1518500249+g,H=F,F=W,W=(A<<30|A>>>2)>>>0,A=t,t=g;for(;32>z;++z)g=k[z-3]^k[z-8]^k[z-14]^k[z-16],g=g<<1|g>>>31,k[z]=g,x=A^W^F,g=(t<<5|t>>>27)+x+H+1859775393+ +g,H=F,F=W,W=(A<<30|A>>>2)>>>0,A=t,t=g;for(;40>z;++z)g=k[z-6]^k[z-16]^k[z-28]^k[z-32],g=g<<2|g>>>30,k[z]=g,x=A^W^F,g=(t<<5|t>>>27)+x+H+1859775393+g,H=F,F=W,W=(A<<30|A>>>2)>>>0,A=t,t=g;for(;60>z;++z)g=k[z-6]^k[z-16]^k[z-28]^k[z-32],g=g<<2|g>>>30,k[z]=g,x=A&W|F&(A^W),g=(t<<5|t>>>27)+x+H+2400959708+g,H=F,F=W,W=(A<<30|A>>>2)>>>0,A=t,t=g;for(;80>z;++z)g=k[z-6]^k[z-16]^k[z-28]^k[z-32],g=g<<2|g>>>30,k[z]=g,x=A^W^F,g=(t<<5|t>>>27)+x+H+3395469782+g,H=F,F=W,W=(A<<30|A>>>2)>>>0,A=t,t=g;f.h0=f.h0+t|0;f.h1=f.h1+ +A|0;f.h2=f.h2+W|0;f.h3=f.h3+F|0;f.h4=f.h4+H|0;m-=64}}var I=C(5);C(16);C(7);Q=Q.exports=I.sha1=I.sha1||{};I.md.sha1=I.md.algorithms.sha1=Q;Q.create=function(){q||(V=String.fromCharCode(128),V+=I.util.fillString(String.fromCharCode(0),64),q=!0);var f=null,k=I.util.createBuffer(),d=Array(80),g={algorithm:"sha1",blockLength:64,digestLength:20,messageLength:0,fullMessageLength:null,messageLengthSize:8,start:function(){g.messageLength=0;g.fullMessageLength=g.messageLength64=[];for(var t=g.messageLengthSize/ +4,A=0;A>>0,A>>>0];for(var W=g.fullMessageLength.length-1;0<=W;--W)g.fullMessageLength[W]+=A[1],A[1]=A[0]+(g.fullMessageLength[W]/4294967296>>>0),g.fullMessageLength[W]>>>=0,A[0]=A[1]/4294967296>>>0;k.putBytes(t);u(f,d,k);(2048>>0,F+=W,t.putInt32(F>>>0),F=A>>>0;t.putInt32(F);A={h0:f.h0,h1:f.h1,h2:f.h2,h3:f.h3,h4:f.h4};u(A,d,t);t=I.util.createBuffer();t.putInt32(A.h0);t.putInt32(A.h1);t.putInt32(A.h2); +t.putInt32(A.h3);t.putInt32(A.h4);return t};return g};var V=null,q=!1},function(Q,E,C){C.d(E,"a",function(){return V});var u=C(0),I=C(1),V=function(q){q=void 0===q?{}:q;this.modulus=Object(I.e)(q,"modulus",V.defaultValues("modulus"));this.publicExponent=Object(I.e)(q,"publicExponent",V.defaultValues("publicExponent"));"schema"in q&&this.fromSchema(q.schema);"json"in q&&this.fromJSON(q.json)};V.defaultValues=function(q){switch(q){case "modulus":return new u.m;case "publicExponent":return new u.m;default:throw Error("Invalid member name for RSAPublicKey class: "+ +q);}};V.schema=function(q){q=void 0===q?{}:q;q=Object(I.e)(q,"names",{});return new u.v({name:q.blockName||"",value:[new u.m({name:q.modulus||""}),new u.m({name:q.publicExponent||""})]})};V.prototype.fromSchema=function(q){Object(I.c)(q,["modulus","publicExponent"]);q=u.D(q,q,V.schema({names:{modulus:"modulus",publicExponent:"publicExponent"}}));if(!1===q.verified)throw Error("Object's schema was not verified against input data for RSAPublicKey");this.modulus=q.result.modulus.convertFromDER(256); +this.publicExponent=q.result.publicExponent};V.prototype.toSchema=function(){return new u.v({value:[this.modulus.convertToDER(),this.publicExponent]})};V.prototype.toJSON=function(){return{n:Object(I.i)(Object(I.a)(this.modulus.valueBlock.valueHex),!0,!0,!0),e:Object(I.i)(Object(I.a)(this.publicExponent.valueBlock.valueHex),!0,!0,!0)}};V.prototype.fromJSON=function(q){if("n"in q){var f=Object(I.h)(Object(I.d)(q.n,!0));this.modulus=new u.m({valueHex:f.slice(0,Math.pow(2,Object(I.g)(f.byteLength)))})}else throw Error('Absent mandatory parameter "n"'); +if("e"in q)this.publicExponent=new u.m({valueHex:Object(I.h)(Object(I.d)(q.e,!0)).slice(0,3)});else throw Error('Absent mandatory parameter "e"');}},function(Q,E,C){C.d(E,"a",function(){return q});var u=C(0),I=C(1),V=C(12),q=function(f){f=void 0===f?{}:f;this.version=Object(I.e)(f,"version",q.defaultValues("version"));this.privateKey=Object(I.e)(f,"privateKey",q.defaultValues("privateKey"));"namedCurve"in f&&(this.namedCurve=Object(I.e)(f,"namedCurve",q.defaultValues("namedCurve")));"publicKey"in +f&&(this.publicKey=Object(I.e)(f,"publicKey",q.defaultValues("publicKey")));"schema"in f&&this.fromSchema(f.schema);"json"in f&&this.fromJSON(f.json)};q.defaultValues=function(f){switch(f){case "version":return 1;case "privateKey":return new u.q;case "namedCurve":return"";case "publicKey":return new V.a;default:throw Error("Invalid member name for ECCPrivateKey class: "+f);}};q.compareWithDefault=function(f,k){switch(f){case "version":return k===q.defaultValues(f);case "privateKey":return k.isEqual(q.defaultValues(f)); +case "namedCurve":return""===k;case "publicKey":return V.a.compareWithDefault("namedCurve",k.namedCurve)&&V.a.compareWithDefault("x",k.x)&&V.a.compareWithDefault("y",k.y);default:throw Error("Invalid member name for ECCPrivateKey class: "+f);}};q.schema=function(f){f=void 0===f?{}:f;f=Object(I.e)(f,"names",{});return new u.v({name:f.blockName||"",value:[new u.m({name:f.version||""}),new u.q({name:f.privateKey||""}),new u.g({optional:!0,idBlock:{tagClass:3,tagNumber:0},value:[new u.p({name:f.namedCurve|| +""})]}),new u.g({optional:!0,idBlock:{tagClass:3,tagNumber:1},value:[new u.b({name:f.publicKey||""})]})]})};q.prototype.fromSchema=function(f){Object(I.c)(f,["version","privateKey","namedCurve","publicKey"]);f=u.D(f,f,q.schema({names:{version:"version",privateKey:"privateKey",namedCurve:"namedCurve",publicKey:"publicKey"}}));if(!1===f.verified)throw Error("Object's schema was not verified against input data for ECPrivateKey");this.version=f.result.version.valueBlock.valueDec;this.privateKey=f.result.privateKey; +"namedCurve"in f.result&&(this.namedCurve=f.result.namedCurve.valueBlock.toString());"publicKey"in f.result&&(f={schema:f.result.publicKey.valueBlock.valueHex},"namedCurve"in this&&(f.namedCurve=this.namedCurve),this.publicKey=new V.a(f))};q.prototype.toSchema=function(){var f=[new u.m({value:this.version}),this.privateKey];"namedCurve"in this&&f.push(new u.g({idBlock:{tagClass:3,tagNumber:0},value:[new u.p({value:this.namedCurve})]}));"publicKey"in this&&f.push(new u.g({idBlock:{tagClass:3,tagNumber:1}, +value:[new u.b({valueHex:this.publicKey.toSchema().toBER(!1)})]}));return new u.v({value:f})};q.prototype.toJSON=function(){if(!1==="namedCurve"in this||q.compareWithDefault("namedCurve",this.namedCurve))throw Error('Not enough information for making JSON: absent "namedCurve" value');var f="";switch(this.namedCurve){case "1.2.840.10045.3.1.7":f="P-256";break;case "1.3.132.0.34":f="P-384";break;case "1.3.132.0.35":f="P-521"}f={crv:f,d:Object(I.i)(Object(I.a)(this.privateKey.valueBlock.valueHex),!0, +!0,!1)};if("publicKey"in this){var k=this.publicKey.toJSON();f.x=k.x;f.y=k.y}return f};q.prototype.fromJSON=function(f){var k=0;if("crv"in f)switch(f.crv.toUpperCase()){case "P-256":this.namedCurve="1.2.840.10045.3.1.7";k=32;break;case "P-384":this.namedCurve="1.3.132.0.34";k=48;break;case "P-521":this.namedCurve="1.3.132.0.35",k=66}else throw Error('Absent mandatory parameter "crv"');if("d"in f){var d=Object(I.h)(Object(I.d)(f.d,!0));if(d.byteLength>>4^e)&252645135;e^=x;l^=x<<4;x=(l>>>16^e)&65535;e^=x;l^=x<<16;x=(e>>>2^l)&858993459;l^=x;e^=x<<2;x=(e>>>8^l)&16711935;l^=x;e^=x<<8;x=(l>>>1^e)&1431655765;e^=x;l^=x<<1;l=l<<1|l>>>31;e=e<<1|e>>>31;for(var w=0;w>>4|e<<28)^H[y+1];x=l;l=e;e=x^(k[G>>>24&63]|g[G>>>16&63]|A[G>>>8&63]|F[G&63]|f[M>>>24&63]|d[M>>>16&63]|t[M>>>8&63]|W[M&63])}x=l;l=e;e=x}l=l>>>1|l<<31;e=e>>>1|e<<31;x=(l>>>1^e)&1431655765;e^=x;l^=x<<1;x=(e>>>8^l)&16711935;l^=x;e^=x<<8;x=(e>>>2^l)&858993459;l^=x;e^=x<<2;x=(l>>>16^e)&65535;e^=x;l^=x<<16;x=(l>>>4^e)&252645135;z[0]=l^x<<4;z[1]=e^x}function V(H){H=H||{};var x="DES-"+(H.mode||"CBC").toUpperCase();var z=H.decrypt?q.cipher.createDecipher(x,H.key):q.cipher.createCipher(x, +H.key);var m=z.start;z.start=function(P,l){var e=null;l instanceof q.util.ByteBuffer&&(e=l,l={});l=l||{};l.output=e;l.iv=P;m.call(z,l)};return z}var q=C(5);C(37);C(48);C(7);Q.exports=q.des=q.des||{};q.des.startEncrypting=function(H,x,z,m){H=V({key:H,output:z,decrypt:!1,mode:m||(null===x?"ECB":"CBC")});H.start(x);return H};q.des.createEncryptionCipher=function(H,x){return V({key:H,output:null,decrypt:!1,mode:x})};q.des.startDecrypting=function(H,x,z,m){H=V({key:H,output:z,decrypt:!0,mode:m||(null=== +x?"ECB":"CBC")});H.start(x);return H};q.des.createDecryptionCipher=function(H,x){return V({key:H,output:null,decrypt:!0,mode:x})};q.des.Algorithm=function(H,x){var z=this;z.name=H;z.mode=new x({blockSize:8,cipher:{encrypt:function(m,P){return I(z._keys,m,P,!1)},decrypt:function(m,P){return I(z._keys,m,P,!0)}}});z._init=!1};q.des.Algorithm.prototype.initialize=function(H){if(!this._init){H=q.util.createBuffer(H.key);if(0===this.name.indexOf("3DES")&&24!==H.length())throw Error("Invalid Triple-DES key size: "+ +8*H.length());for(var x=[0,4,536870912,536870916,65536,65540,536936448,536936452,512,516,536871424,536871428,66048,66052,536936960,536936964],z=[0,1,1048576,1048577,67108864,67108865,68157440,68157441,256,257,1048832,1048833,67109120,67109121,68157696,68157697],m=[0,8,2048,2056,16777216,16777224,16779264,16779272,0,8,2048,2056,16777216,16777224,16779264,16779272],P=[0,2097152,134217728,136314880,8192,2105344,134225920,136323072,131072,2228224,134348800,136445952,139264,2236416,134356992,136454144], +l=[0,262144,16,262160,0,262144,16,262160,4096,266240,4112,266256,4096,266240,4112,266256],e=[0,1024,32,1056,0,1024,32,1056,33554432,33555456,33554464,33555488,33554432,33555456,33554464,33555488],w=[0,268435456,524288,268959744,2,268435458,524290,268959746,0,268435456,524288,268959744,2,268435458,524290,268959746],J=[0,65536,2048,67584,536870912,536936448,536872960,536938496,131072,196608,133120,198656,537001984,537067520,537004032,537069568],h=[0,262144,0,262144,2,262146,2,262146,33554432,33816576, +33554432,33816576,33554434,33816578,33554434,33816578],y=[0,268435456,8,268435464,0,268435456,8,268435464,1024,268436480,1032,268436488,1024,268436480,1032,268436488],G=[0,32,0,32,1048576,1048608,1048576,1048608,8192,8224,8192,8224,1056768,1056800,1056768,1056800],M=[0,16777216,512,16777728,2097152,18874368,2097664,18874880,67108864,83886080,67109376,83886592,69206016,85983232,69206528,85983744],S=[0,4096,134217728,134221824,524288,528384,134742016,134746112,16,4112,134217744,134221840,524304,528400, +134742032,134746128],Z=[0,4,256,260,0,4,256,260,1,5,257,261,1,5,257,261],ca=8>>4^D)&252645135;D^=r;v^=r<<4;r=(D>>>-16^v)&65535;v^=r;D^=r<<-16;r=(v>>>2^D)&858993459;D^=r;v^=r<<2;r=(D>>>-16^v)&65535;v^=r;D^=r<<-16;r=(v>>>1^D)&1431655765;D^=r;v^=r<<1;r=(D>>>8^v)&16711935;v^=r;D^=r<<8;r=(v>>>1^D)&1431655765;D^=r;v^=r<<1;r=v<<8|D>>>20&240;v=D<<24|D<<8&16711680|D>>>8&65280|D>>>24&240;D= +r;for(var U=0;U>>26,D=D<<2|D>>>26):(v=v<<1|v>>>27,D=D<<1|D>>>27);v&=-15;D&=-15;var N=x[v>>>28]|z[v>>>24&15]|m[v>>>20&15]|P[v>>>16&15]|l[v>>>12&15]|e[v>>>8&15]|w[v>>>4&15],O=J[D>>>28]|h[D>>>24&15]|y[D>>>20&15]|G[D>>>16&15]|M[D>>>12&15]|S[D>>>8&15]|Z[D>>>4&15];r=(O>>>16^N)&65535;ea[na++]=N^r;ea[na++]=O^r<<16}}this._keys=ea;this._init=!0}};u("DES-ECB",q.cipher.modes.ecb);u("DES-CBC",q.cipher.modes.cbc);u("DES-CFB",q.cipher.modes.cfb);u("DES-OFB",q.cipher.modes.ofb);u("DES-CTR", +q.cipher.modes.ctr);u("3DES-ECB",q.cipher.modes.ecb);u("3DES-CBC",q.cipher.modes.cbc);u("3DES-CFB",q.cipher.modes.cfb);u("3DES-OFB",q.cipher.modes.ofb);u("3DES-CTR",q.cipher.modes.ctr);var f=[16843776,0,65536,16843780,16842756,66564,4,65536,1024,16843776,16843780,1024,16778244,16842756,16777216,4,1028,16778240,16778240,66560,66560,16842752,16842752,16778244,65540,16777220,16777220,65540,0,1028,66564,16777216,65536,16843780,4,16842752,16843776,16777216,16777216,1024,16842756,65536,66560,16777220,1024, +4,16778244,66564,16843780,65540,16842752,16778244,16777220,1028,66564,16843776,1028,16778240,16778240,0,65540,66560,0,16842756],k=[-2146402272,-2147450880,32768,1081376,1048576,32,-2146435040,-2147450848,-2147483616,-2146402272,-2146402304,-2147483648,-2147450880,1048576,32,-2146435040,1081344,1048608,-2147450848,0,-2147483648,32768,1081376,-2146435072,1048608,-2147483616,0,1081344,32800,-2146402304,-2146435072,32800,0,1081376,-2146435040,1048576,-2147450848,-2146435072,-2146402304,32768,-2146435072, +-2147450880,32,-2146402272,1081376,32,32768,-2147483648,32800,-2146402304,1048576,-2147483616,1048608,-2147450848,-2147483616,1048608,1081344,0,-2147450880,32800,-2147483648,-2146435040,-2146402272,1081344],d=[520,134349312,0,134348808,134218240,0,131592,134218240,131080,134217736,134217736,131072,134349320,131080,134348800,520,134217728,8,134349312,512,131584,134348800,134348808,131592,134218248,131584,131072,134218248,8,134349320,512,134217728,134349312,134217728,131080,520,131072,134349312,134218240, +0,512,131080,134349320,134218240,134217736,512,0,134348808,134218248,131072,134217728,134349320,8,131592,131584,134217736,134348800,134218248,520,134348800,131592,8,134348808,131584],g=[8396801,8321,8321,128,8396928,8388737,8388609,8193,0,8396800,8396800,8396929,129,0,8388736,8388609,1,8192,8388608,8396801,128,8388608,8193,8320,8388737,1,8320,8388736,8192,8396928,8396929,129,8388736,8388609,8396800,8396929,129,0,0,8396800,8320,8388736,8388737,1,8396801,8321,8321,128,8396929,129,1,8192,8388609,8193, +8396928,8388737,8193,8320,8388608,8396801,128,8388608,8192,8396928],t=[256,34078976,34078720,1107296512,524288,256,1073741824,34078720,1074266368,524288,33554688,1074266368,1107296512,1107820544,524544,1073741824,33554432,1074266112,1074266112,0,1073742080,1107820800,1107820800,33554688,1107820544,1073742080,0,1107296256,34078976,33554432,1107296256,524544,524288,1107296512,256,33554432,1073741824,34078720,1107296512,1074266368,33554688,1073741824,1107820544,34078976,1074266368,256,33554432,1107820544, +1107820800,524544,1107296256,1107820800,34078720,0,1074266112,1107296256,524544,33554688,1073742080,524288,0,1074266112,34078976,1073742080],A=[536870928,541065216,16384,541081616,541065216,16,541081616,4194304,536887296,4210704,4194304,536870928,4194320,536887296,536870912,16400,0,4194320,536887312,16384,4210688,536887312,16,541065232,541065232,0,4210704,541081600,16400,4210688,541081600,536870912,536887296,16,541065232,4210688,541081616,4194304,16400,536870928,4194304,536887296,536870912,16400, +536870928,541081616,4210688,541065216,4210704,541081600,0,541065232,16,16384,541065216,4210704,16384,4194320,536887312,0,541081600,536870912,4194320,536887312],W=[2097152,69206018,67110914,0,2048,67110914,2099202,69208064,69208066,2097152,0,67108866,2,67108864,69206018,2050,67110912,2099202,2097154,67110912,67108866,69206016,69208064,2097154,69206016,2048,2050,69208066,2099200,2,67108864,2099200,67108864,2099200,2097152,67110914,67110914,69206018,69206018,2,2097154,67108864,67110912,2097152,69208064, +2050,2099202,69208064,2050,67108866,69208066,69206016,2099200,0,2,69208066,0,2099202,69206016,2048,67108866,67110912,2048,2097154],F=[268439616,4096,262144,268701760,268435456,268439616,64,268435456,262208,268697600,268701760,266240,268701696,266304,4096,64,268697600,268435520,268439552,4160,266240,262208,268697664,268701696,4160,0,0,268697664,268435520,268439552,266304,262144,266304,262144,268701696,4096,64,268697664,4096,266304,268439552,64,268435520,268697600,268697664,268435456,262144,268439616, +0,268701760,262208,268435520,268697600,268439552,268439616,0,268701760,266240,266240,4160,4160,262208,268435456,268701696]},function(Q,E,C){function u(h,y,G){var M=t.util.createBuffer();y=Math.ceil(y.n.bitLength()/8);if(h.length>y-11)throw M=Error("Message is too long for PKCS#1 v1.5 padding."),M.length=h.length,M.max=y-11,M;M.putByte(0);M.putByte(G);y=y-3-h.length;if(0===G||1===G){G=0===G?0:255;for(var S=0;Sh.p.compareTo(h.q)&&(ea=h.p,h.p=h.q,h.q=ea);0!==h.p.subtract(A.ONE).gcd(h.e).compareTo(A.ONE)?(h.p=null,M()):0!==h.q.subtract(A.ONE).gcd(h.e).compareTo(A.ONE)? +(h.q=null,S(h.qBits,Z)):(h.p1=h.p.subtract(A.ONE),h.q1=h.q.subtract(A.ONE),h.phi=h.p1.multiply(h.q1),0!==h.phi.gcd(h.e).compareTo(A.ONE)?(h.p=h.q=null,M()):(h.n=h.p.multiply(h.q),h.n.bitLength()!==h.bits?(h.q=null,S(h.qBits,Z)):(ea=h.e.modInverse(h.phi),h.keys={privateKey:x.rsa.setPrivateKey(h.n,h.e,ea,h.p,h.q,ea.mod(h.p1),ea.mod(h.q1),h.q.modInverse(h.p)),publicKey:x.rsa.setPublicKey(h.n,h.e)},G(null,h.keys))))}"function"===typeof y&&(G=y,y={});y=y||{};var ca={algorithm:{name:y.algorithm||"PRIMEINC", +options:{workers:y.workers||2,workLoad:y.workLoad||100,workerScript:y.workerScript}}};"prng"in y&&(ca.prng=y.prng);M()}function q(h){h=h.toString(16);"8"<=h[0]&&(h="00"+h);h=t.util.hexToBytes(h);return 1=h?27:150>=h?18:200>=h?15:250>=h?12:300>=h?9:350>=h?8:400>=h?7:500>=h?6:600>=h?5:800>=h?4:1250>=h?3:2}function k(h){return"undefined"!==typeof H.globalScope&& +"object"===typeof H.globalScope.crypto&&"object"===typeof H.globalScope.crypto.subtle&&"function"===typeof H.globalScope.crypto.subtle[h]}function d(h){return"undefined"!==typeof H.globalScope&&"object"===typeof H.globalScope.msCrypto&&"object"===typeof H.globalScope.msCrypto.subtle&&"function"===typeof H.globalScope.msCrypto.subtle[h]}function g(h){h=t.util.hexToBytes(h.toString(16));for(var y=new Uint8Array(h.length),G=0;GM.compareTo(h);)M=M.add(y.p);h=M.subtract(h).multiply(y.qInv).mod(y.p).multiply(y.q).add(h);return h= +h.multiply(G.modInverse(y.n)).mod(y.n)};x.rsa.encrypt=function(h,y,G){var M=G,S=Math.ceil(y.n.bitLength()/8);!1!==G&&!0!==G?(M=2===G,G=u(h,y,G)):(G=t.util.createBuffer(),G.putBytes(h));h=new A(G.toHex(),16);y=J(h,y,M).toString(16);M=t.util.createBuffer();for(S-=Math.ceil(y.length/2);0>1,pBits:h-(h>>1),pqState:0,num:null,keys:null},h.e.fromInt(h.eInt);else throw Error("Invalid key generation algorithm: "+G);return h};x.rsa.stepKeyPairGenerationState=function(h,y){"algorithm"in h||(h.algorithm="PRIMEINC");var G=new A(null);G.fromInt(30);for(var M=0,S=function(na,r){return na|r},Z=+new Date,ca,ea=0;null=== +h.keys&&(0>=y||eaca?h.pqState=0:h.num.isProbablePrime(f(h.num.bitLength()))?++h.pqState:h.num.dAddOffset(z[M++%8],0):2===h.pqState?h.pqState=0===h.num.subtract(A.ONE).gcd(h.e).compareTo(A.ONE)?3:0:3===h.pqState&&(h.pqState=0,null===h.p?h.p= +h.num:h.q=h.num,null!==h.p&&null!==h.q&&++h.state,h.num=null)}else 1===h.state?(0>h.p.compareTo(h.q)&&(h.num=h.p,h.p=h.q,h.q=h.num),++h.state):2===h.state?(h.p1=h.p.subtract(A.ONE),h.q1=h.q.subtract(A.ONE),h.phi=h.p1.multiply(h.q1),++h.state):3===h.state?0===h.phi.gcd(h.e).compareTo(A.ONE)?++h.state:(h.p=null,h.q=null,h.state=0):4===h.state?(h.n=h.p.multiply(h.q),h.n.bitLength()===h.bits?++h.state:(h.q=null,h.state=0)):5===h.state&&(ca=h.e.modInverse(h.phi),h.keys={privateKey:x.rsa.setPrivateKey(h.n, +h.e,ca,h.p,h.q,ca.mod(h.p1),ca.mod(h.q1),h.q.modInverse(h.p)),publicKey:x.rsa.setPublicKey(h.n,h.e)});ca=+new Date;ea+=ca-Z;Z=ca}return null!==h.keys};x.rsa.generateKeyPair=function(h,y,G,M){1===arguments.length?"object"===typeof h?(G=h,h=void 0):"function"===typeof h&&(M=h,h=void 0):2===arguments.length?"number"===typeof h?"function"===typeof y?(M=y,y=void 0):"number"!==typeof y&&(G=y,y=void 0):(G=h,M=y,y=h=void 0):3===arguments.length&&("number"===typeof y?"function"===typeof G&&(M=G,G=void 0): +(M=G,G=y,y=void 0));G=G||{};void 0===h&&(h=G.bits||2048);void 0===y&&(y=G.e||65537);if(!t.options.usePureJavaScript&&!G.prng&&256<=h&&16384>=h&&(65537===y||3===y))if(M){if(t.util.isNodejs&&"function"===typeof W.generateKeyPair)return W.generateKeyPair("rsa",{modulusLength:h,publicExponent:y,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}},function(Z,ca,ea){if(Z)return M(Z);M(null,{privateKey:x.privateKeyFromPem(ea),publicKey:x.publicKeyFromPem(ca)})});if(k("generateKey")&& +k("exportKey"))return H.globalScope.crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:h,publicExponent:g(y),hash:{name:"SHA-256"}},!0,["sign","verify"]).then(function(Z){return H.globalScope.crypto.subtle.exportKey("pkcs8",Z.privateKey)}).then(void 0,function(Z){M(Z)}).then(function(Z){Z&&(Z=x.privateKeyFromAsn1(F.fromDer(t.util.createBuffer(Z))),M(null,{privateKey:Z,publicKey:x.setRsaPublicKey(Z.n,Z.e)}))});if(d("generateKey")&&d("exportKey")){var S=H.globalScope.msCrypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5", +modulusLength:h,publicExponent:g(y),hash:{name:"SHA-256"}},!0,["sign","verify"]);S.oncomplete=function(Z){Z=H.globalScope.msCrypto.subtle.exportKey("pkcs8",Z.target.result.privateKey);Z.oncomplete=function(ca){ca=x.privateKeyFromAsn1(F.fromDer(t.util.createBuffer(ca.target.result)));M(null,{privateKey:ca,publicKey:x.setRsaPublicKey(ca.n,ca.e)})};Z.onerror=function(ca){M(ca)}};S.onerror=function(Z){M(Z)};return}}else if(t.util.isNodejs&&"function"===typeof W.generateKeyPairSync)return S=W.generateKeyPairSync("rsa", +{modulusLength:h,publicExponent:y,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}}),{privateKey:x.privateKeyFromPem(S.privateKey),publicKey:x.publicKeyFromPem(S.publicKey)};S=x.rsa.createKeyPairGenerationState(h,y,G);if(!M)return x.rsa.stepKeyPairGenerationState(S,0),S.keys;V(S,G,M)};x.setRsaPublicKey=x.rsa.setPublicKey=function(h,y){var G={n:h,e:y,encrypt:function(M,S,Z){"string"===typeof S?S=S.toUpperCase():void 0===S&&(S="RSAES-PKCS1-V1_5");if("RSAES-PKCS1-V1_5"=== +S)S={encode:function(ca,ea,ia){return u(ca,ea,2).getBytes()}};else if("RSA-OAEP"===S||"RSAES-OAEP"===S)S={encode:function(ca,ea){return t.pkcs1.encode_rsa_oaep(ea,ca,Z)}};else if(-1!==["RAW","NONE","NULL",null].indexOf(S))S={encode:function(ca){return ca}};else if("string"===typeof S)throw Error('Unsupported encryption scheme: "'+S+'".');M=S.encode(M,G,!0);return x.rsa.encrypt(M,G,!0)},verify:function(M,S,Z){"string"===typeof Z?Z=Z.toUpperCase():void 0===Z&&(Z="RSASSA-PKCS1-V1_5");if("RSASSA-PKCS1-V1_5"=== +Z)Z={verify:function(ca,ea){ea=I(ea,G,!0);ea=F.fromDer(ea);return ca===ea.value[1].value}};else if("NONE"===Z||"NULL"===Z||null===Z)Z={verify:function(ca,ea){ea=I(ea,G,!0);return ca===ea}};S=x.rsa.decrypt(S,G,!0,!1);return Z.verify(M,S,G.n.bitLength())}};return G};x.setRsaPrivateKey=x.rsa.setPrivateKey=function(h,y,G,M,S,Z,ca,ea){var ia={n:h,e:y,d:G,p:M,q:S,dP:Z,dQ:ca,qInv:ea,decrypt:function(na,r,n){"string"===typeof r?r=r.toUpperCase():void 0===r&&(r="RSAES-PKCS1-V1_5");na=x.rsa.decrypt(na,ia,!1, +!1);if("RSAES-PKCS1-V1_5"===r)r={decode:I};else if("RSA-OAEP"===r||"RSAES-OAEP"===r)r={decode:function(v,D){return t.pkcs1.decode_rsa_oaep(D,v,n)}};else if(-1!==["RAW","NONE","NULL",null].indexOf(r))r={decode:function(v){return v}};else throw Error('Unsupported encryption scheme: "'+r+'".');return r.decode(na,ia,!1)},sign:function(na,r){var n=!1;"string"===typeof r&&(r=r.toUpperCase());if(void 0===r||"RSASSA-PKCS1-V1_5"===r)r={encode:w},n=1;else if("NONE"===r||"NULL"===r||null===r)r={encode:function(){return na}}, +n=1;r=r.encode(na,ia.n.bitLength());return x.rsa.encrypt(r,ia,n)}};return ia};x.wrapRsaPrivateKey=function(h){return F.create(F.Class.UNIVERSAL,F.Type.SEQUENCE,!0,[F.create(F.Class.UNIVERSAL,F.Type.INTEGER,!1,F.integerToDer(0).getBytes()),F.create(F.Class.UNIVERSAL,F.Type.SEQUENCE,!0,[F.create(F.Class.UNIVERSAL,F.Type.OID,!1,F.oidToDer(x.oids.rsaEncryption).getBytes()),F.create(F.Class.UNIVERSAL,F.Type.NULL,!1,"")]),F.create(F.Class.UNIVERSAL,F.Type.OCTETSTRING,!1,F.toDer(h).getBytes())])};x.privateKeyFromAsn1= +function(h){var y={},G=[];F.validate(h,m,y,G)&&(h=F.fromDer(t.util.createBuffer(y.privateKey)));y={};G=[];if(!F.validate(h,P,y,G))throw y=Error("Cannot read private key. ASN.1 object does not contain an RSAPrivateKey."),y.errors=G,y;G=t.util.createBuffer(y.privateKeyModulus).toHex();h=t.util.createBuffer(y.privateKeyPublicExponent).toHex();var M=t.util.createBuffer(y.privateKeyPrivateExponent).toHex();var S=t.util.createBuffer(y.privateKeyPrime1).toHex();var Z=t.util.createBuffer(y.privateKeyPrime2).toHex(); +var ca=t.util.createBuffer(y.privateKeyExponent1).toHex();var ea=t.util.createBuffer(y.privateKeyExponent2).toHex();y=t.util.createBuffer(y.privateKeyCoefficient).toHex();return x.setRsaPrivateKey(new A(G,16),new A(h,16),new A(M,16),new A(S,16),new A(Z,16),new A(ca,16),new A(ea,16),new A(y,16))};x.privateKeyToAsn1=x.privateKeyToRSAPrivateKey=function(h){return F.create(F.Class.UNIVERSAL,F.Type.SEQUENCE,!0,[F.create(F.Class.UNIVERSAL,F.Type.INTEGER,!1,F.integerToDer(0).getBytes()),F.create(F.Class.UNIVERSAL, +F.Type.INTEGER,!1,q(h.n)),F.create(F.Class.UNIVERSAL,F.Type.INTEGER,!1,q(h.e)),F.create(F.Class.UNIVERSAL,F.Type.INTEGER,!1,q(h.d)),F.create(F.Class.UNIVERSAL,F.Type.INTEGER,!1,q(h.p)),F.create(F.Class.UNIVERSAL,F.Type.INTEGER,!1,q(h.q)),F.create(F.Class.UNIVERSAL,F.Type.INTEGER,!1,q(h.dP)),F.create(F.Class.UNIVERSAL,F.Type.INTEGER,!1,q(h.dQ)),F.create(F.Class.UNIVERSAL,F.Type.INTEGER,!1,q(h.qInv))])};x.publicKeyFromAsn1=function(h){var y={},G=[];if(F.validate(h,e,y,G)){G=F.derToOid(y.publicKeyOid); +if(G!==x.oids.rsaEncryption)throw y=Error("Cannot read public key. Unknown OID."),y.oid=G,y;h=y.rsaPublicKey}G=[];if(!F.validate(h,l,y,G))throw y=Error("Cannot read public key. ASN.1 object does not contain an RSAPublicKey."),y.errors=G,y;G=t.util.createBuffer(y.publicKeyModulus).toHex();y=t.util.createBuffer(y.publicKeyExponent).toHex();return x.setRsaPublicKey(new A(G,16),new A(y,16))};x.publicKeyToAsn1=x.publicKeyToSubjectPublicKeyInfo=function(h){return F.create(F.Class.UNIVERSAL,F.Type.SEQUENCE, +!0,[F.create(F.Class.UNIVERSAL,F.Type.SEQUENCE,!0,[F.create(F.Class.UNIVERSAL,F.Type.OID,!1,F.oidToDer(x.oids.rsaEncryption).getBytes()),F.create(F.Class.UNIVERSAL,F.Type.NULL,!1,"")]),F.create(F.Class.UNIVERSAL,F.Type.BITSTRING,!1,[x.publicKeyToRSAPublicKey(h)])])};x.publicKeyToRSAPublicKey=function(h){return F.create(F.Class.UNIVERSAL,F.Type.SEQUENCE,!0,[F.create(F.Class.UNIVERSAL,F.Type.INTEGER,!1,q(h.n)),F.create(F.Class.UNIVERSAL,F.Type.INTEGER,!1,q(h.e))])}},function(Q,E,C){function u(h,y,G){this.data= +[];null!=h&&("number"==typeof h?this.fromNumber(h,y,G):null==y&&"string"!=typeof h?this.fromString(h,256):this.fromString(h,y))}function I(){return new u(null)}function V(h,y,G,M,S,Z){for(;0<=--Z;){var ca=y*this.data[h++]+G.data[M]+S;S=Math.floor(ca/67108864);G.data[M++]=ca&67108863}return S}function q(h,y,G,M,S,Z){var ca=y&32767;for(y>>=15;0<=--Z;){var ea=this.data[h]&32767,ia=this.data[h++]>>15,na=y*ea+ia*ca;ea=ca*ea+((na&32767)<<15)+G.data[M]+(S&1073741823);S=(ea>>>30)+(na>>>15)+y*ia+(S>>>30); +G.data[M++]=ea&1073741823}return S}function f(h,y,G,M,S,Z){var ca=y&16383;for(y>>=14;0<=--Z;){var ea=this.data[h]&16383,ia=this.data[h++]>>14,na=y*ea+ia*ca;ea=ca*ea+((na&16383)<<14)+G.data[M]+S;S=(ea>>28)+(na>>14)+y*ia;G.data[M++]=ea&268435455}return S}function k(h,y){h=e[h.charCodeAt(y)];return null==h?-1:h}function d(h){var y=I();y.fromInt(h);return y}function g(h){var y=1,G;0!=(G=h>>>16)&&(h=G,y+=16);0!=(G=h>>8)&&(h=G,y+=8);0!=(G=h>>4)&&(h=G,y+=4);0!=(G=h>>2)&&(h=G,y+=2);0!=h>>1&&(y+=1);return y} +function t(h){this.m=h}function A(h){this.m=h;this.mp=h.invDigit();this.mpl=this.mp&32767;this.mph=this.mp>>15;this.um=(1<=E;++E)e[Q++]=E;Q=97;for(E=10;36>E;++E)e[Q++]=E;Q=65;for(E=10;36>E;++E)e[Q++]=E;t.prototype.convert= +function(h){return 0>h.s||0<=h.compareTo(this.m)?h.mod(this.m):h};t.prototype.revert=function(h){return h};t.prototype.reduce=function(h){h.divRemTo(this.m,null,h)};t.prototype.mulTo=function(h,y,G){h.multiplyTo(y,G);this.reduce(G)};t.prototype.sqrTo=function(h,y){h.squareTo(y);this.reduce(y)};A.prototype.convert=function(h){var y=I();h.abs().dlShiftTo(this.m.t,y);y.divRemTo(this.m,null,y);0>h.s&&0>15)*this.mpl&this.um)<<15)&h.DM;G=y+this.m.t;for(h.data[G]+=this.m.am(0,M,h,y,0,this.m.t);h.data[G]>=h.DV;)h.data[G]-=h.DV,h.data[++G]++}h.clamp();h.drShiftTo(this.m.t,h);0<=h.compareTo(this.m)&&h.subTo(this.m,h)};A.prototype.mulTo=function(h,y,G){h.multiplyTo(y,G);this.reduce(G)};A.prototype.sqrTo=function(h,y){h.squareTo(y); +this.reduce(y)};u.prototype.copyTo=function(h){for(var y=this.t-1;0<=y;--y)h.data[y]=this.data[y];h.t=this.t;h.s=this.s};u.prototype.fromInt=function(h){this.t=1;this.s=0>h?-1:0;0h?this.data[0]=h+this.DV:this.t=0};u.prototype.fromString=function(h,y){if(16==y)y=4;else if(8==y)y=3;else if(256==y)y=8;else if(2==y)y=1;else if(32==y)y=5;else if(4==y)y=2;else{this.fromRadix(h,y);return}this.s=this.t=0;for(var G=h.length,M=!1,S=0;0<=--G;){var Z=8==y?h[G]&255:k(h,G);0>Z?"-"==h.charAt(G)&& +(M=!0):(M=!1,0==S?this.data[this.t++]=Z:S+y>this.DB?(this.data[this.t-1]|=(Z&(1<>this.DB-S):this.data[this.t-1]|=Z<=this.DB&&(S-=this.DB))}8==y&&0!=(h[0]&128)&&(this.s=-1,0>M|Z,Z=(this.data[ca]&S)<=this.t)y.t=0;else{h%=this.DB;var M=this.DB-h,S=(1<>h;for(var Z=G+1;Z>h;0>=this.DB;if(h.t>=this.DB; +M+=this.s}else{for(M+=this.s;G>=this.DB;M-=h.s}y.s=0>M?-1:0;-1>M?y.data[G++]=this.DV+M:0=y.DV&&(h.data[G+y.t]-=y.DV,h.data[G+y.t+1]=1)}0=M.t)){var S=this.abs();if(S.t>this.F2:0),na=this.FV/ia;ia=(1<ca&&u.ZERO.subTo(G,G)}}}};u.prototype.invDigit=function(){if(1>this.t)return 0;var h=this.data[0];if(0==(h&1))return 0;var y=h&3;y=y*(2-(h&15)*y)&15;y=y*(2-(h&255)*y)&255;y=y*(2-((h&65535)*y&65535))&65535;y=y*(2-h*y%this.DV)%this.DV;return 0h)return u.ONE;var G=I(),M=I(),S=y.convert(this),Z=g(h)-1;for(S.copyTo(G);0<=--Z;)if(y.sqrTo(G, +M),0<(h&1<this.s)return"-"+this.negate().toString(h);if(16==h)h=4;else if(8==h)h=3;else if(2==h)h=1;else if(32==h)h=5;else if(4==h)h=2;else return this.toRadix(h);var y=(1<>ca)&&(M=!0,S="0123456789abcdefghijklmnopqrstuvwxyz".charAt(G));0<=Z;)ca>(ca+=this.DB- +h)):(G=this.data[Z]>>(ca-=h)&y,0>=ca&&(ca+=this.DB,--Z)),0this.s?this.negate():this};u.prototype.compareTo=function(h){var y=this.s-h.s;if(0!=y)return y;var G=this.t;y=G-h.t;if(0!=y)return 0>this.s?-y:y;for(;0<=--G;)if(0!=(y=this.data[G]-h.data[G]))return y;return 0};u.prototype.bitLength=function(){return 0>= +this.t?0:this.DB*(this.t-1)+g(this.data[this.t-1]^this.s&this.DM)};u.prototype.mod=function(h){var y=I();this.abs().divRemTo(h,null,y);0>this.s&&0h||y.isEven()?new t(y):new A(y);return this.exp(h,y)};u.ZERO=d(0);u.ONE=d(1);z.prototype.convert=m;z.prototype.revert=m;z.prototype.mulTo=function(h,y,G){h.multiplyTo(y,G)};z.prototype.sqrTo=function(h,y){h.squareTo(y)};P.prototype.convert=function(h){if(0>h.s||h.t>2* +this.m.t)return h.mod(this.m);if(0>h.compareTo(this.m))return h;var y=I();h.copyTo(y);this.reduce(y);return y};P.prototype.revert=function(h){return h};P.prototype.reduce=function(h){h.drShiftTo(this.m.t-1,this.r2);h.t>this.m.t+1&&(h.t=this.m.t+1,h.clamp());this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3);for(this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);0>h.compareTo(this.r2);)h.dAddOffset(1,this.m.t+1);for(h.subTo(this.r2,h);0<=h.compareTo(this.m);)h.subTo(this.m,h)};P.prototype.mulTo=function(h, +y,G){h.multiplyTo(y,G);this.reduce(G)};P.prototype.sqrTo=function(h,y){h.squareTo(y);this.reduce(y)};var w=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509],J=67108864/w[w.length-1];u.prototype.chunkSize= +function(h){return Math.floor(Math.LN2*this.DB/Math.log(h))};u.prototype.toRadix=function(h){null==h&&(h=10);if(0==this.signum()||2>h||36ia?"-"==h.charAt(ea)&&0==this.signum()&&(S=!0):(ca=y*ca+ia,++Z>=G&&(this.dMultiply(M),this.dAddOffset(ca,0),ca=Z=0))}0h)this.fromInt(1);else for(this.fromNumber(h,G),this.testBit(h-1)||this.bitwiseTo(u.ONE.shiftLeft(h-1),F,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(y);)this.dAddOffset(2,0),this.bitLength()>h&&this.subTo(u.ONE.shiftLeft(h- +1),this);else{G=[];var M=h&7;G.length=(h>>3)+1;y.nextBytes(G);G[0]=0>=this.DB;if(h.t>=this.DB;M+=this.s}else{for(M+=this.s;G>=this.DB;M+=h.s}y.s=0>M?-1:0;0M&&(y.data[G++]=this.DV+M);y.t=G;y.clamp()};u.prototype.dMultiply=function(h){this.data[this.t]=this.am(0,h-1,this,0,0,this.t);++this.t;this.clamp()}; +u.prototype.dAddOffset=function(h,y){if(0!=h){for(;this.t<=y;)this.data[this.t++]=0;for(this.data[y]+=h;this.data[y]>=this.DV;)this.data[y]-=this.DV,++y>=this.t&&(this.data[this.t++]=0),++this.data[y]}};u.prototype.multiplyLowerTo=function(h,y,G){var M=Math.min(this.t+h.t,y);G.s=0;for(G.t=M;0=h)return 0;var y=this.DV%h,G=0>this.s?h-1:0;if(0=G)return!1;for(var M=y.shiftRight(G),S=l(), +Z,ca=0;ca=Z.compareTo(u.ONE)||0<=Z.compareTo(y));Z=Z.modPow(M,this);if(0!=Z.compareTo(u.ONE)&&0!=Z.compareTo(y)){for(var ea=1;ea++this.s){if(1==this.t)return this.data[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this.data[0]; +if(0==this.t)return 0}return(this.data[1]&(1<<32-this.DB)-1)<>24};u.prototype.shortValue=function(){return 0==this.t?this.s:this.data[0]<<16>>16};u.prototype.signum=function(){return 0>this.s?-1:0>=this.t||1==this.t&&0>=this.data[0]?0:1};u.prototype.toByteArray=function(){var h=this.t,y=[];y[0]=this.s;var G=this.DB-h*this.DB%8,M,S=0;if(0>G)!=(this.s&this.DM)>>G&&(y[S++]= +M|this.s<G?(M=(this.data[h]&(1<>(G+=this.DB-8)):(M=this.data[h]>>(G-=8)&255,0>=G&&(G+=this.DB,--h)),0!=(M&128)&&(M|=-256),0==S&&(this.s&128)!=(M&128)&&++S,0this.compareTo(h)?this:h};u.prototype.max=function(h){return 0h?this.rShiftTo(-h,y):this.lShiftTo(h,y);return y};u.prototype.shiftRight=function(h){var y=I();0>h?this.lShiftTo(-h,y):this.rShiftTo(h, +y);return y};u.prototype.getLowestSetBit=function(){for(var h=0;h>=16,G+=16);0==(h&255)&&(h>>=8,G+=8);0==(h&15)&&(h>>=4,G+=4);0==(h&3)&&(h>>=2,G+=2);0==(h&1)&&++G;h=G}return y+h}return 0>this.s?this.t*this.DB:-1};u.prototype.bitCount=function(){for(var h=0,y=this.s&this.DM,G=0;G=this.t?0!=this.s:0!=(this.data[y]&1<=G)return M;var S=18>G?1:48>G?3:144>G?4:768>G?5:6;y=8>G?new t(y):y.isEven()?new P(y):new A(y);var Z=[],ca=3,ea=S-1,ia=(1<=ea)var v=h.data[na]>>G-ea&ia;else v=(h.data[na]&(1<>this.DB+G-ea);for(ca=S;0==(v&1);)v>>=1,--ca;0>(G-=ca)&&(G+=this.DB,--na);if(r)Z[v].copyTo(M),r=!1;else{for(;1--G&&(G=this.DB-1,--na)}return y.revert(M)};u.prototype.modInverse=function(h){var y=h.isEven();if(this.isEven()&& +y||0==h.signum())return u.ZERO;for(var G=h.clone(),M=this.clone(),S=d(1),Z=d(0),ca=d(0),ea=d(1);0!=G.signum();){for(;G.isEven();)G.rShiftTo(1,G),y?(S.isEven()&&Z.isEven()||(S.addTo(this,S),Z.subTo(h,Z)),S.rShiftTo(1,S)):Z.isEven()||Z.subTo(h,Z),Z.rShiftTo(1,Z);for(;M.isEven();)M.rShiftTo(1,M),y?(ca.isEven()&&ea.isEven()||(ca.addTo(this,ca),ea.subTo(h,ea)),ca.rShiftTo(1,ca)):ea.isEven()||ea.subTo(h,ea),ea.rShiftTo(1,ea);0<=G.compareTo(M)?(G.subTo(M,G),y&&S.subTo(ca,S),Z.subTo(ea,Z)):(M.subTo(G,M), +y&&ca.subTo(S,ca),ea.subTo(Z,ea))}if(0!=M.compareTo(u.ONE))return u.ZERO;if(0<=ea.compareTo(h))return ea.subtract(h);if(0>ea.signum())ea.addTo(h,ea);else return ea;return 0>ea.signum()?ea.add(h):ea};u.prototype.pow=function(h){return this.exp(h,new z)};u.prototype.gcd=function(h){var y=0>this.s?this.negate():this.clone();h=0>h.s?h.negate():h.clone();if(0>y.compareTo(h)){var G=y;y=h;h=G}G=y.getLowestSetBit();var M=h.getLowestSetBit();if(0>M)return y;G>3)/w);m=Promise.resolve(na);for(h=0;h<=w;h++){m=m.then(function(n){n=new ArrayBuffer(M.byteLength+n.byteLength); +var v=new Uint8Array(n);v.set(S);v.set(r,S.length);return n});for(y=0;yna.byteLength&&(K=na.byteLength-O);for(var ua=511,za=v.byteLength-1;0<=za;za--)ua>>=8,ua+=D[za]+xa[za],xa[za]=ua&255; +N.push.apply(N,$jscomp.arrayFromIterable(xa))}na=new ArrayBuffer(N.length);r=new Uint8Array(na);r.set(N);e.push.apply(e,$jscomp.arrayFromIterable(new Uint8Array(n)));return na})}return m=m.then(function(){var n=new ArrayBuffer(z>>3);(new Uint8Array(n)).set((new Uint8Array(e)).slice(0,z>>3));return n})}C.d(E,"a",function(){return F});var I=C(0),V=C(1),q=C(4),f=C(10),k=C(14),d=C(3),g=C(9),t=C(23),A=C(17),W=C(30),F=function(H){H=void 0===H?{}:H;this.crypto=Object(V.e)(H,"crypto",{});this.subtle=Object(V.e)(H, +"subtle",{});this.name=Object(V.e)(H,"name","")};F.prototype.importKey=function(H,x,z,m,P){var l=this,e={};x instanceof Uint8Array&&(x=x.buffer);switch(H.toLowerCase()){case "raw":return this.subtle.importKey("raw",x,z,m,P);case "spki":x=I.E(x);if(-1===x.offset)return Promise.reject("Incorrect keyData");H=new f.a;try{H.fromSchema(x.result)}catch(J){return Promise.reject("Incorrect keyData")}switch(z.name.toUpperCase()){case "RSA-PSS":switch(z.hash.name.toUpperCase()){case "SHA-1":e.alg="PS1";break; +case "SHA-256":e.alg="PS256";break;case "SHA-384":e.alg="PS384";break;case "SHA-512":e.alg="PS512";break;default:return Promise.reject("Incorrect hash algorithm: "+z.hash.name.toUpperCase())}case "RSASSA-PKCS1-V1_5":P=["verify"];e.kty="RSA";e.ext=m;e.key_ops=P;if("1.2.840.113549.1.1.1"!==H.algorithm.algorithmId)return Promise.reject("Incorrect public key algorithm: "+H.algorithm.algorithmId);if(!1==="alg"in e)switch(z.hash.name.toUpperCase()){case "SHA-1":e.alg="RS1";break;case "SHA-256":e.alg="RS256"; +break;case "SHA-384":e.alg="RS384";break;case "SHA-512":e.alg="RS512";break;default:return Promise.reject("Incorrect hash algorithm: "+z.hash.name.toUpperCase())}H=H.toJSON();var w=$jscomp.makeIterator(Object.keys(H));for(x=w.next();!x.done;x=w.next())x=x.value,e[x]=H[x];break;case "ECDSA":P=["verify"];case "ECDH":e={kty:"EC",ext:m,key_ops:P};if("1.2.840.10045.2.1"!==H.algorithm.algorithmId)return Promise.reject("Incorrect public key algorithm: "+H.algorithm.algorithmId);H=H.toJSON();w=$jscomp.makeIterator(Object.keys(H)); +for(x=w.next();!x.done;x=w.next())x=x.value,e[x]=H[x];break;case "RSA-OAEP":e.kty="RSA";e.ext=m;e.key_ops=P;if("safari"===this.name.toLowerCase())e.alg="RSA-OAEP";else switch(z.hash.name.toUpperCase()){case "SHA-1":e.alg="RSA-OAEP";break;case "SHA-256":e.alg="RSA-OAEP-256";break;case "SHA-384":e.alg="RSA-OAEP-384";break;case "SHA-512":e.alg="RSA-OAEP-512";break;default:return Promise.reject("Incorrect hash algorithm: "+z.hash.name.toUpperCase())}H=H.toJSON();w=$jscomp.makeIterator(Object.keys(H)); +for(x=w.next();!x.done;x=w.next())x=x.value,e[x]=H[x];break;case "RSAES-PKCS1-V1_5":e.kty="RSA";e.ext=m;e.key_ops=P;e.alg="PS1";H=H.toJSON();w=$jscomp.makeIterator(Object.keys(H));for(x=w.next();!x.done;x=w.next())x=x.value,e[x]=H[x];break;default:return Promise.reject("Incorrect algorithm name: "+z.name.toUpperCase())}break;case "pkcs8":H=new k.a;x=I.E(x);if(-1===x.offset)return Promise.reject("Incorrect keyData");try{H.fromSchema(x.result)}catch(J){return Promise.reject("Incorrect keyData")}if(!1=== +"parsedKey"in H)return Promise.reject("Incorrect keyData");switch(z.name.toUpperCase()){case "RSA-PSS":switch(z.hash.name.toUpperCase()){case "SHA-1":e.alg="PS1";break;case "SHA-256":e.alg="PS256";break;case "SHA-384":e.alg="PS384";break;case "SHA-512":e.alg="PS512";break;default:return Promise.reject("Incorrect hash algorithm: "+z.hash.name.toUpperCase())}case "RSASSA-PKCS1-V1_5":P=["sign"];e.kty="RSA";e.ext=m;e.key_ops=P;if("1.2.840.113549.1.1.1"!==H.privateKeyAlgorithm.algorithmId)return Promise.reject("Incorrect private key algorithm: "+ +H.privateKeyAlgorithm.algorithmId);if(!1==="alg"in e)switch(z.hash.name.toUpperCase()){case "SHA-1":e.alg="RS1";break;case "SHA-256":e.alg="RS256";break;case "SHA-384":e.alg="RS384";break;case "SHA-512":e.alg="RS512";break;default:return Promise.reject("Incorrect hash algorithm: "+z.hash.name.toUpperCase())}H=H.toJSON();w=$jscomp.makeIterator(Object.keys(H));for(x=w.next();!x.done;x=w.next())x=x.value,e[x]=H[x];break;case "ECDSA":P=["sign"];case "ECDH":e={kty:"EC",ext:m,key_ops:P};if("1.2.840.10045.2.1"!== +H.privateKeyAlgorithm.algorithmId)return Promise.reject("Incorrect algorithm: "+H.privateKeyAlgorithm.algorithmId);H=H.toJSON();w=$jscomp.makeIterator(Object.keys(H));for(x=w.next();!x.done;x=w.next())x=x.value,e[x]=H[x];break;case "RSA-OAEP":e.kty="RSA";e.ext=m;e.key_ops=P;if("safari"===this.name.toLowerCase())e.alg="RSA-OAEP";else switch(z.hash.name.toUpperCase()){case "SHA-1":e.alg="RSA-OAEP";break;case "SHA-256":e.alg="RSA-OAEP-256";break;case "SHA-384":e.alg="RSA-OAEP-384";break;case "SHA-512":e.alg= +"RSA-OAEP-512";break;default:return Promise.reject("Incorrect hash algorithm: "+z.hash.name.toUpperCase())}H=H.toJSON();w=$jscomp.makeIterator(Object.keys(H));for(x=w.next();!x.done;x=w.next())x=x.value,e[x]=H[x];break;case "RSAES-PKCS1-V1_5":P=["decrypt"];e.kty="RSA";e.ext=m;e.key_ops=P;e.alg="PS1";H=H.toJSON();w=$jscomp.makeIterator(Object.keys(H));for(x=w.next();!x.done;x=w.next())x=x.value,e[x]=H[x];break;default:return Promise.reject("Incorrect algorithm name: "+z.name.toUpperCase())}break;case "jwk":e= +x;break;default:return Promise.reject("Incorrect format: "+H)}return"safari"===this.name.toLowerCase()?Promise.resolve().then(function(){return l.subtle.importKey("jwk",Object(V.h)(JSON.stringify(e)),z,m,P)}).then(function(J){return J},function(){return l.subtle.importKey("jwk",e,z,m,P)}):this.subtle.importKey("jwk",e,z,m,P)};F.prototype.exportKey=function(H,x){var z=this.subtle.exportKey("jwk",x);"safari"===this.name.toLowerCase()&&(z=z.then(function(m){return m instanceof ArrayBuffer?JSON.parse(Object(V.a)(m)): +m}));switch(H.toLowerCase()){case "raw":return this.subtle.exportKey("raw",x);case "spki":z=z.then(function(m){var P=new f.a;try{P.fromJSON(m)}catch(l){return Promise.reject("Incorrect key data")}return P.toSchema().toBER(!1)});break;case "pkcs8":z=z.then(function(m){var P=new k.a;try{P.fromJSON(m)}catch(l){return Promise.reject("Incorrect key data")}return P.toSchema().toBER(!1)});break;case "jwk":break;default:return Promise.reject("Incorrect format: "+H)}return z};F.prototype.convert=function(H, +x,z,m,P,l){var e=this;switch(H.toLowerCase()){case "raw":switch(x.toLowerCase()){case "raw":return Promise.resolve(z);case "spki":return Promise.resolve().then(function(){return e.importKey("raw",z,m,P,l)}).then(function(w){return e.exportKey("spki",w)});case "pkcs8":return Promise.resolve().then(function(){return e.importKey("raw",z,m,P,l)}).then(function(w){return e.exportKey("pkcs8",w)});case "jwk":return Promise.resolve().then(function(){return e.importKey("raw",z,m,P,l)}).then(function(w){return e.exportKey("jwk", +w)});default:return Promise.reject("Incorrect outputFormat: "+x)}case "spki":switch(x.toLowerCase()){case "raw":return Promise.resolve().then(function(){return e.importKey("spki",z,m,P,l)}).then(function(w){return e.exportKey("raw",w)});case "spki":return Promise.resolve(z);case "pkcs8":return Promise.reject("Impossible to convert between SPKI/PKCS8");case "jwk":return Promise.resolve().then(function(){return e.importKey("spki",z,m,P,l)}).then(function(w){return e.exportKey("jwk",w)});default:return Promise.reject("Incorrect outputFormat: "+ +x)}case "pkcs8":switch(x.toLowerCase()){case "raw":return Promise.resolve().then(function(){return e.importKey("pkcs8",z,m,P,l)}).then(function(w){return e.exportKey("raw",w)});case "spki":return Promise.reject("Impossible to convert between SPKI/PKCS8");case "pkcs8":return Promise.resolve(z);case "jwk":return Promise.resolve().then(function(){return e.importKey("pkcs8",z,m,P,l)}).then(function(w){return e.exportKey("jwk",w)});default:return Promise.reject("Incorrect outputFormat: "+x)}case "jwk":switch(x.toLowerCase()){case "raw":return Promise.resolve().then(function(){return e.importKey("jwk", +z,m,P,l)}).then(function(w){return e.exportKey("raw",w)});case "spki":return Promise.resolve().then(function(){return e.importKey("jwk",z,m,P,l)}).then(function(w){return e.exportKey("spki",w)});case "pkcs8":return Promise.resolve().then(function(){return e.importKey("jwk",z,m,P,l)}).then(function(w){return e.exportKey("pkcs8",w)});case "jwk":return Promise.resolve(z);default:return Promise.reject("Incorrect outputFormat: "+x)}default:return Promise.reject("Incorrect inputFormat: "+H)}};F.prototype.encrypt= +function(H){for(var x=[],z=0;zt;++t)d[t]=Math.floor(4294967296*Math.abs(Math.sin(t+1)));g=!0}function I(t,A,W){for(var F,H,x,z,m,P,l,e=W.length();64<=e;){H=t.h0;x=t.h1;z=t.h2;m=t.h3;for(l=0;16>l;++l)A[l]=W.getInt32Le(),F=m^x&(z^m),F=H+F+d[l]+A[l],P=k[l],H=m,m=z,z=x,x+=F<>>32-P;for(;32>l;++l)F=z^m&(x^z),F=H+F+d[l]+A[f[l]],P=k[l],H=m,m=z,z=x,x+=F<>>32-P;for(;48>l;++l)F=x^z^m,F=H+F+d[l]+A[f[l]],P=k[l],H=m,m=z,z=x,x+=F<>>32-P;for(;64>l;++l)F=z^(x|~m),F= +H+F+d[l]+A[f[l]],P=k[l],H=m,m=z,z=x,x+=F<>>32-P;t.h0=t.h0+H|0;t.h1=t.h1+x|0;t.h2=t.h2+z|0;t.h3=t.h3+m|0;e-=64}}var V=C(5);C(16);C(7);Q=Q.exports=V.md5=V.md5||{};V.md.md5=V.md.algorithms.md5=Q;Q.create=function(){g||u();var t=null,A=V.util.createBuffer(),W=Array(16),F={algorithm:"md5",blockLength:64,digestLength:16,messageLength:0,fullMessageLength:null,messageLengthSize:8,start:function(){F.messageLength=0;F.fullMessageLength=F.messageLength64=[];for(var H=F.messageLengthSize/4,x=0;x>>0,x>>>0];for(var z=F.fullMessageLength.length-1;0<=z;--z)F.fullMessageLength[z]+=x[1],x[1]=x[0]+(F.fullMessageLength[z]/4294967296>>>0),F.fullMessageLength[z]>>>=0,x[0]=x[1]/4294967296>>>0;A.putBytes(H);I(t,W,A);(2048>>0,H.putInt32Le(x>>>0);x={h0:t.h0,h1:t.h1,h2:t.h2,h3:t.h3};I(x,W,H);H=V.util.createBuffer();H.putInt32Le(x.h0);H.putInt32Le(x.h1);H.putInt32Le(x.h2);H.putInt32Le(x.h3);return H};return F};var q=null,f=null,k=null,d=null,g=!1},function(Q, +E,C){(function(u){var I=C(5);C(25);C(16);C(7);var V=I.pkcs5=I.pkcs5||{},q;I.util.isNodejs&&!I.options.usePureJavaScript&&(q=C(40));Q.exports=I.pbkdf2=V.pbkdf2=function(f,k,d,g,t,A){function W(){if(e>x)return A(null,P);m.start(null,null);m.update(k);m.update(I.util.int32ToBytes(e));w=l=m.digest().getBytes();J=2;F()}function F(){if(J<=d)return m.start(null,null),m.update(l),h=m.digest().getBytes(),w=I.util.xorBytes(w,h,H),l=h,++J,I.util.setImmediate(F);P+=e4294967295*H){f=Error("Derived key is too long.");if(A)return A(f);throw f;}var x=Math.ceil(g/H),z=g-(x-1)*H,m=I.hmac.create();m.start(t,f);var P="",l;if(!A){for(var e=1;e<=x;++e){m.start(null,null);m.update(k);m.update(I.util.int32ToBytes(e));var w=l=m.digest().getBytes();for(var J=2;J<=d;++J){m.start(null,null);m.update(l); +var h=m.digest().getBytes();w=I.util.xorBytes(w,h,H);l=h}P+=el.comment.length||128=m&&lJ.length)throw Error("Cannot read notBefore/notAfter validity times; they were not provided as either UTCTime or GeneralizedTime.");h.validity.notBefore=J[0];h.validity.notAfter=J[1];h.tbsCertificate=w.tbsCertificate; +if(e){h.md=null;if(h.signatureOid in A)switch(J=A[h.signatureOid],J){case "sha1WithRSAEncryption":h.md=d.md.sha1.create();break;case "md5WithRSAEncryption":h.md=d.md.md5.create();break;case "sha256WithRSAEncryption":h.md=d.md.sha256.create();break;case "sha384WithRSAEncryption":h.md=d.md.sha384.create();break;case "sha512WithRSAEncryption":h.md=d.md.sha512.create();break;case "RSASSA-PSS":h.md=d.md.sha256.create()}if(null===h.md)throw w=Error("Could not compute certificate digest. Unknown signature OID."), +w.signatureOid=h.signatureOid,w;e=g.toDer(h.tbsCertificate);h.md.update(e.getBytes())}e=d.md.sha1.create();h.issuer.getField=function(y){return u(h.issuer,y)};h.issuer.addField=function(y){V([y]);h.issuer.attributes.push(y)};h.issuer.attributes=t.RDNAttributesAsArray(w.certIssuer,e);w.certIssuerUniqueId&&(h.issuer.uniqueId=w.certIssuerUniqueId);h.issuer.hash=e.digest().toHex();e=d.md.sha1.create();h.subject.getField=function(y){return u(h.subject,y)};h.subject.addField=function(y){V([y]);h.subject.attributes.push(y)}; +h.subject.attributes=t.RDNAttributesAsArray(w.certSubject,e);w.certSubjectUniqueId&&(h.subject.uniqueId=w.certSubjectUniqueId);h.subject.hash=e.digest().toHex();h.extensions=w.certExtensions?t.certificateExtensionsFromAsn1(w.certExtensions):[];h.publicKey=t.publicKeyFromAsn1(w.subjectPublicKeyInfo);return h};t.certificateExtensionsFromAsn1=function(l){for(var e=[],w=0;wS.validity.notAfter)&&(G={message:"Certificate is not valid yet or has expired.",error:t.certificateError.certificate_expired,notBefore:S.validity.notBefore,notAfter:S.validity.notAfter,now:h});if(null===G){Z=e[0]||l.getIssuer(S);null===Z&&S.isIssuer(S)&&(ca=!0,Z=S);if(Z){var ea= +Z;d.util.isArray(ea)||(ea=[ea]);for(var ia=!1;!ia&&0y.pathLenConstraint&&(G={message:"Certificate basicConstraints pathLenConstraint violated.",error:t.certificateError.bad_certificate}));S=null===G?!0:G.error;y=w.verify?w.verify(S,M,J):S;if(!0===y)G=null;else{!0===S&&(G={message:"The application rejected the certificate.", +error:t.certificateError.bad_certificate});if(y||0===y)"object"!==typeof y||d.util.isArray(y)?"string"===typeof y&&(G.error=y):(y.message&&(G.message=y.message),y.error&&(G.error=y.error));throw G;}y=!1;++M}while(0>8*W-A&255;F=String.fromCharCode(F.charCodeAt(0)&~A)+F.substr(1);return F+t+String.fromCharCode(188)},verify:function(t,A,W){var F=W-1;W=Math.ceil(F/8);A=A.substr(-W);if(W>8*W-F&255;if(0!==(x.charCodeAt(0)&z))throw Error("Bits beyond keysize not zero as expected.");var m=q.generate(A,H),P="";for(F=0;Fha?B:null===Y?Y=Object.getOwnPropertyDescriptor(B,L):Y,Aa;if("object"===typeof Reflect&&"function"===typeof Reflect.decorate)qa=Reflect.decorate(a,B,L,Y);else for(var Ea=a.length-1;0<=Ea;Ea--)if(Aa=a[Ea])qa=(3>ha?Aa(qa):3B.prefix?1:0:1:-1:1:-1}function V(a,B){if(!a.namespaceURI&&B.namespaceURI)return-1;if(!B.namespaceURI&&a.namespaceURI)return 1;a=a.namespaceURI+a.localName;B=B.namespaceURI+B.localName;return a===B?0:aha?B:null===Y?Y=Object.getOwnPropertyDescriptor(B,L):Y,Aa;if("object"===typeof Reflect&&"function"===typeof Reflect.decorate)qa=Reflect.decorate(a,B,L,Y);else for(var Ea=a.length-1;0<=Ea;Ea--)if(Aa=a[Ea])qa=(3>ha?Aa(qa):3Ja?Db.timeNames[0]:Db.timeNames[1],tt:12>Ja?Db.timeNames[2]:Db.timeNames[3],T:12>Ja?Db.timeNames[4]:Db.timeNames[5],TT:12>Ja?Db.timeNames[6]:Db.timeNames[7],Z:Y?"GMT":L?"UTC":(String(a).match(Gg)||[""]).pop().replace(Hg,""),o:(0=this.view.length|| +0>a)a=0;if(B>=this.view.length||0>B)B=this.view.length-a;for(var Y=a;Y>1);this.view=new Uint8Array(this.buffer);var L=new Map;L.set("0",0);L.set("1",1);L.set("2",2);L.set("3",3);L.set("4",4);L.set("5",5);L.set("6",6);L.set("7",7);L.set("8",8);L.set("9",9);L.set("A",10);L.set("a",10);L.set("B",11);L.set("b",11);L.set("C",12);L.set("c",12);L.set("D",13);L.set("d", +13);L.set("E",14);L.set("e",14);L.set("F",15);L.set("f",15);for(var Y=0,ha=0,qa=0;qa=this.view.length||0>a)a=0;if(B>=this.view.length||0>B)B=this.view.length-a;for(var Y=a;Ya||a>this._buffer.byteLength-1)throw Error("Wrong start position: "+a);var L=new ja;L._buffer=this._buffer.slice(a,a+B);L._view=new Uint8Array(L._buffer);return L};ja.prototype.slice=function(a,B){a=void 0===a?0:a;B=void 0===B?this._buffer.byteLength:B;if(0===a&&0===this._buffer.byteLength)return new ja;if(0>a||a>this._buffer.byteLength-1)throw Error("Wrong start position: "+a);var L=new ja;L._buffer= +this._buffer.slice(a,B);L._view=new Uint8Array(L._buffer);return L};ja.prototype.realloc=function(a){var B=new ArrayBuffer(a),L=new Uint8Array(B);a>this._view.length?L.set(this._view):L.set(new Uint8Array(this._buffer,0,a));this._buffer=B.slice(0);this._view=new Uint8Array(this._buffer)};ja.prototype.append=function(a){var B=this._buffer.byteLength,L=a._buffer.byteLength;a=a._view.slice();this.realloc(B+L);this._view.set(a,B)};ja.prototype.insert=function(a,B,L){B=void 0===B?0:B;L=void 0===L?this._buffer.byteLength- +B:L;if(B>this._buffer.byteLength-1)return!1;L>this._buffer.byteLength-B&&(L=this._buffer.byteLength-B);L>a._buffer.byteLength&&(L=a._buffer.byteLength);L==a._buffer.byteLength?this._view.set(a._view,B):this._view.set(a._view.slice(0,L),B);return!0};ja.prototype.isEqual=function(a){if(this._buffer.byteLength!=a._buffer.byteLength)return!1;for(var B=0;Bthis.buffer.byteLength&&(B=this.buffer.byteLength);Y?(null==L&&(L=B),L>B&&(L=B)):(null==L&&(L=this.buffer.byteLength-B),L>this.buffer.byteLength-B&&(L=this.buffer.byteLength-B));var ha=a.buffer.byteLength;if(ha>L)return-1;for(var qa=[],Aa=0;Aathis.buffer.byteLength&&(B=this.buffer.byteLength);Y?(null==L&&(L=B),L>B&&(L=B)):(null==L&&(L=this.buffer.byteLength-B),L>this.buffer.byteLength-B&&(L=this.buffer.byteLength-B));for(var ha={id:-1,position:Y?0:B+L,length:0},qa=0;qa=ha.position-ha.length&&(Ea=!0):Aa-Ga<=ha.position-ha.length&&(Ea=!0);Ea&&(ha.position=Aa,ha.id=qa,ha.length=Ga)}}return ha};ja.prototype.findAllIn=function(a,B,L){B=void 0===B?0:B;L=void 0===L?this.buffer.byteLength-B:L;var Y=[];null==B&&(B=0);if(B>this.buffer.byteLength-1)return Y;null==L&&(L=this.buffer.byteLength-B);L>this.buffer.byteLength-B&&(L=this.buffer.byteLength-B);B={id:-1,position:B};do{var ha=B.position;B=this.findFirstIn(a, +B.position,L);if(-1==B.id)break;L-=B.position-ha;Y.push({id:B.id,position:B.position})}while(1);return Y};ja.prototype.findAllPatternIn=function(a,B,L){B=void 0===B?0:B;L=void 0===L?this.buffer.byteLength-B:L;null==B&&(B=0);B>this.buffer.byteLength&&(B=this.buffer.byteLength);null==L&&(L=this.buffer.byteLength-B);L>this.buffer.byteLength-B&&(L=this.buffer.byteLength-B);var Y=[],ha=a.buffer.byteLength;if(ha>L)return-1;a=Array.from(a.view);for(var qa=0;qa<=L-ha;qa++){for(var Aa=!0,Ea=B+qa,Ga=0;Gathis.buffer.byteLength&&(B=this.buffer.byteLength);Y?(null==L&&(L=B),L>B&&(L=B)):(null==L&&(L=this.buffer.byteLength-B),L>this.buffer.byteLength-B&&(L=this.buffer.byteLength-B));for(var ha={left:{id:-1,position:B},right:{id:-1,position:0},value:new ja},qa=L;0this.buffer.byteLength-1)return Y;null==L&&(L=this.buffer.byteLength-B);L>this.buffer.byteLength-B&&(L=this.buffer.byteLength-B);B={left:{id:-1,position:B},right:{id:-1, +position:B},value:new ja};do{var ha=B.right.position;B=this.findFirstNotIn(a,B.right.position,L);L-=B.right.position-ha;Y.push({left:{id:B.left.id,position:B.left.position},right:{id:B.right.id,position:B.right.position},value:B.value})}while(-1!=B.right.id);return Y};ja.prototype.findFirstSequence=function(a,B,L,Y){B=void 0===B?null:B;L=void 0===L?null:L;Y=void 0===Y?!1:Y;null==B&&(B=Y?this.buffer.byteLength:0);B>this.buffer.byteLength&&(B=this.buffer.byteLength);Y?(null==L&&(L=B),L>B&&(L=B)):(null== +L&&(L=this.buffer.byteLength-B),L>this.buffer.byteLength-B&&(L=this.buffer.byteLength-B));var ha=this.skipNotPatterns(a,B,L,Y);if(-1==ha)return{position:-1,value:new ja};a=this.skipPatterns(a,ha,L-(Y?B-ha:ha-B),Y);Y?(B=a,L=ha-a):(B=ha,L=a-ha);Y=new ja;Y._buffer=this._buffer.slice(B,B+L);Y._view=new Uint8Array(Y._buffer);return{position:a,value:Y}};ja.prototype.findAllSequences=function(a,B,L){B=void 0===B?null:B;L=void 0===L?null:L;var Y=[];null==B&&(B=0);if(B>this.buffer.byteLength-1)return Y;null== +L&&(L=this.buffer.byteLength-B);L>this.buffer.byteLength-B&&(L=this.buffer.byteLength-B);B={position:B,value:new ja};do{var ha=B.position;B=this.findFirstSequence(a,B.position,L);-1!=B.position&&(L-=B.position-ha,Y.push({position:B.position,value:B.value}))}while(-1!=B.position);return Y};ja.prototype.findPairedPatterns=function(a,B,L,Y){L=void 0===L?null:L;Y=void 0===Y?null:Y;var ha=[];if(a.isEqual(B))return ha;null==L&&(L=0);if(L>this.buffer.byteLength-1)return ha;null==Y&&(Y=this.buffer.byteLength- +L);Y>this.buffer.byteLength-L&&(Y=this.buffer.byteLength-L);var qa=0;a=this.findAllPatternIn(a,L,Y);if(0==a.length)return ha;B=this.findAllPatternIn(B,L,Y);if(0==B.length)return ha;for(;qaB[0])break;for(;a[qa]=a.length););ha.push({left:a[qa-1],right:B[0]});a.splice(qa-1,1);B.splice(0,1);qa=0}ha.sort(function(Aa,Ea){return Aa.left-Ea.left});return ha};ja.prototype.findPairedArrays= +function(a,B,L,Y){L=void 0===L?null:L;Y=void 0===Y?null:Y;var ha=[];null==L&&(L=0);if(L>this.buffer.byteLength-1)return ha;null==Y&&(Y=this.buffer.byteLength-L);Y>this.buffer.byteLength-L&&(Y=this.buffer.byteLength-L);var qa=0;a=this.findAllIn(a,L,Y);if(0==a.length)return ha;B=this.findAllIn(B,L,Y);if(0==B.length)return ha;for(;qaB[0].position)break;for(;a[qa].position< +B[0].position&&!(qa++,qa>=a.length););ha.push({left:a[qa-1],right:B[0]});a.splice(qa-1,1);B.splice(0,1);qa=0}ha.sort(function(Aa,Ea){return Aa.left.position-Ea.left.position});return ha};ja.prototype.replacePattern=function(a,B,L,Y,ha){L=void 0===L?null:L;Y=void 0===Y?null:Y;ha=void 0===ha?null:ha;var qa={status:-1,searchPatternPositions:[],replacePatternPositions:[]};null==L&&(L=0);if(L>this.buffer.byteLength-1)return!1;null==Y&&(Y=this.buffer.byteLength-L);Y>this.buffer.byteLength-L&&(Y=this.buffer.byteLength- +L);if(null==ha){if(Y=this.findAllIn([a],L,Y),0==Y.length)return qa}else Y=ha;qa.searchPatternPositions.push.apply(qa.searchPatternPositions,$jscomp.arrayFromIterable(Array.from(Y,function(Qa){return Qa.position})));var Aa=a.buffer.byteLength-B.buffer.byteLength,Ea=new ArrayBuffer(this.view.length-Y.length*Aa),Ga=new Uint8Array(Ea);Ga.set(new Uint8Array(this.buffer,0,L));for(ha=0;hathis.buffer.byteLength&&(B=this.buffer.byteLength);Y?(null==L&&(L=B),L>B&&(L=B)):(null==L&&(L=this.buffer.byteLength-B),L>this.buffer.byteLength-B&&(L=this.buffer.byteLength-B));for(var ha=B,qa=0;qa=ha)break}else if(ha+=Aa,ha>=B+L)break}return ha};ja.prototype.skipNotPatterns=function(a,B,L,Y){B=void 0===B?null:B;L=void 0===L?null: +L;Y=void 0===Y?!1:Y;null==B&&(B=Y?this.buffer.byteLength:0);B>this.buffer.byteLength&&(B=this.buffer.byteLength);Y?(null==L&&(L=B),L>B&&(L=B)):(null==L&&(L=this.buffer.byteLength-B),L>this.buffer.byteLength-B&&(L=this.buffer.byteLength-B));for(var ha=-1,qa=0;qathis.length)B=this.length;var L=this.stream.findPattern(a,this.start,this.length,this.backward); +if(-1==L)return L;if(this.backward){if(Lthis.start+a.buffer.byteLength+B)return-1;return this.start=L};la.prototype.findFirstIn=function(a,B){B=void 0===B?null:B;if(null==B||B>this.length)B=this.length;var L=this.stream.findFirstIn(a,this.start,this.length,this.backward);if(-1==L.id)return L;if(this.backward){if(L.positionthis.start+ +a[L.id].buffer.byteLength+B)return{id:-1,position:this.backward?0:this.start+this.length};this.start=L.position;return L};la.prototype.findAllIn=function(a){return this.stream.findAllIn(a,this.backward?this.start-this.length:this.start,this.length)};la.prototype.findFirstNotIn=function(a,B){B=void 0===B?null:B;if(null==B||B>this._length)B=this._length;var L=this._stream.findFirstNotIn(a,this._start,this._length,this.backward);if(-1==L.left.id&&-1==L.right.id)return L;if(this.backward){if(-1!=L.right.id&& +L.right.positionthis._start+a[L.left.id]._buffer.byteLength+B)return{left:{id:-1,position:this._start},right:{id:-1,position:0},value:new ja};this.start=this.backward?-1==L.left.id?0:L.left.position:-1==L.right.id?this._start+this._length:L.right.position;return L};la.prototype.findAllNotIn=function(a){return this._stream.findAllNotIn(a, +this.backward?this._start-this._length:this._start,this._length)};la.prototype.findFirstSequence=function(a,B,L){B=void 0===B?null:B;L=void 0===L?null:L;if(null==B||B>this._length)B=this._length;if(null==L||L>B)L=B;a=this._stream.findFirstSequence(a,this._start,B,this.backward);if(0==a.value.buffer.byteLength)return a;if(this.backward){if(a.positionthis._start+a.value._buffer.byteLength+L)return{position:-1, +value:new ja};this.start=a.position;return a};la.prototype.findAllSequences=function(a){return this.stream.findAllSequences(a,this.backward?this.start-this.length:this.start,this.length)};la.prototype.findPairedPatterns=function(a,B,L){L=void 0===L?null:L;if(null==L||L>this.length)L=this.length;var Y=this.stream.findPairedPatterns(a,B,this.backward?this.start-this.length:this.start,this.length);if(Y.length)if(this.backward){if(Y[0].right +this.start+a.buffer.byteLength+L)return[];return Y};la.prototype.findPairedArrays=function(a,B,L){L=void 0===L?null:L;if(null==L||L>this.length)L=this.length;var Y=this.stream.findPairedArrays(a,B,this.backward?this.start-this.length:this.start,this.length);if(Y.length)if(this.backward){if(Y[0].right.positionthis.start+a[Y[0].left.id].buffer.byteLength+L)return[];return Y};la.prototype.replacePattern=function(a,B){return this.stream.replacePattern(a, +B,this.backward?this.start-this.length:this.start,this.length)};la.prototype.skipPatterns=function(a){return this.start=a=this.stream.skipPatterns(a,this.start,this.length,this.backward)};la.prototype.skipNotPatterns=function(a){a=this.stream.skipNotPatterns(a,this.start,this.length,this.backward);return-1==a?-1:this.start=a};la.prototype.append=function(a){this._start+a._buffer.byteLength>this._stream._buffer.byteLength&&(a._buffer.byteLength>this.appendBlock&&(this.appendBlock=a._buffer.byteLength+ +1E3),this._stream.realloc(this._stream._buffer.byteLength+this.appendBlock));this._stream._view.set(a._view,this._start);this._length+=2*a._buffer.byteLength;this.start=this._start+a._buffer.byteLength;this.prevLength-=2*a._buffer.byteLength};la.prototype.appendView=function(a){this._start+a.length>this._stream._buffer.byteLength&&(a.length>this.appendBlock&&(this.appendBlock=a.length+1E3),this._stream.realloc(this._stream._buffer.byteLength+this.appendBlock));this._stream._view.set(a,this._start); +this._length+=2*a.length;this.start=this._start+a.length;this.prevLength-=2*a.length};la.prototype.appendChar=function(a){this._start+1>this._stream._buffer.byteLength&&(1>this.appendBlock&&(this.appendBlock=1E3),this._stream.realloc(this._stream._buffer.byteLength+this.appendBlock));this._stream._view[this._start]=a;this._length+=2;this.start=this._start+1;this.prevLength-=2};la.prototype.appendUint16=function(a){this._start+2>this._stream._buffer.byteLength&&(2>this.appendBlock&&(this.appendBlock= +1E3),this._stream.realloc(this._stream._buffer.byteLength+this.appendBlock));a=new Uint16Array([a]);a=new Uint8Array(a.buffer);this._stream._view[this._start]=a[1];this._stream._view[this._start+1]=a[0];this._length+=4;this.start=this._start+2;this.prevLength-=4};la.prototype.appendUint24=function(a){this._start+3>this._stream._buffer.byteLength&&(3>this.appendBlock&&(this.appendBlock=1E3),this._stream.realloc(this._stream._buffer.byteLength+this.appendBlock));a=new Uint32Array([a]);a=new Uint8Array(a.buffer); +this._stream._view[this._start]=a[2];this._stream._view[this._start+1]=a[1];this._stream._view[this._start+2]=a[0];this._length+=6;this.start=this._start+3;this.prevLength-=6};la.prototype.appendUint32=function(a){this._start+4>this._stream._buffer.byteLength&&(4>this.appendBlock&&(this.appendBlock=1E3),this._stream.realloc(this._stream._buffer.byteLength+this.appendBlock));a=new Uint32Array([a]);a=new Uint8Array(a.buffer);this._stream._view[this._start]=a[3];this._stream._view[this._start+1]=a[2]; +this._stream._view[this._start+2]=a[1];this._stream._view[this._start+3]=a[0];this._length+=8;this.start=this._start+4;this.prevLength-=8};la.prototype.getBlock=function(a,B){B=void 0===B?!0:B;if(0>=this._length)return[];this._lengtha.length)return 0;var B=new Uint16Array(1),L=new Uint8Array(B.buffer);L[0]=a[1];L[1]=a[0];return B[0]};la.prototype.getInt16=function(a){a=this.getBlock(2,void 0===a?!0:a);if(2>a.length)return 0;var B=new Int16Array(1),L=new Uint8Array(B.buffer);L[0]=a[1];L[1]=a[0];return B[0]};la.prototype.getUint24=function(a){a=this.getBlock(3,void 0===a?!0:a);if(3>a.length)return 0;for(var B= +new Uint32Array(1),L=new Uint8Array(B.buffer),Y=3;1<=Y;Y--)L[3-Y]=a[Y-1];return B[0]};la.prototype.getUint32=function(a){a=this.getBlock(4,void 0===a?!0:a);if(4>a.length)return 0;for(var B=new Uint32Array(1),L=new Uint8Array(B.buffer),Y=3;0<=Y;Y--)L[3-Y]=a[Y];return B[0]};la.prototype.getInt32=function(a){a=this.getBlock(4,void 0===a?!0:a);if(4>a.length)return 0;for(var B=new Int32Array(1),L=new Uint8Array(B.buffer),Y=3;0<=Y;Y--)L[3-Y]=a[Y];return B[0]};$jscomp.global.Object.defineProperties(la.prototype, +{stream:{configurable:!0,enumerable:!0,set:function(a){this._stream=a;this.prevLength=this._length;this._length=a._buffer.byteLength;this.prevStart=this._start;this._start=0},get:function(){return this._stream}},length:{configurable:!0,enumerable:!0,set:function(a){this.prevLength=this._length;this._length=a},get:function(){return this.appendBlock?this.start:this._length}},start:{configurable:!0,enumerable:!0,set:function(a){a>this.stream.buffer.byteLength||(this.prevStart=this._start,this.prevLength= +this._length,this._length-=this.backward?this._start-a:a-this._start,this._start=a)},get:function(){return this._start}},buffer:{configurable:!0,enumerable:!0,get:function(){return this._stream._buffer.slice(0,this._length)}}});var Ba=function(a){a=void 0===a?{}:a;this.version=Object(e.e)(a,"version",Ba.defaultValues("version"));this.logID=Object(e.e)(a,"logID",Ba.defaultValues("logID"));this.timestamp=Object(e.e)(a,"timestamp",Ba.defaultValues("timestamp"));this.extensions=Object(e.e)(a,"extensions", +Ba.defaultValues("extensions"));this.hashAlgorithm=Object(e.e)(a,"hashAlgorithm",Ba.defaultValues("hashAlgorithm"));this.signatureAlgorithm=Object(e.e)(a,"signatureAlgorithm",Ba.defaultValues("signatureAlgorithm"));this.signature=Object(e.e)(a,"signature",Ba.defaultValues("signature"));"schema"in a&&this.fromSchema(a.schema);"stream"in a&&this.fromStream(a.stream)};Ba.defaultValues=function(a){switch(a){case "version":return 0;case "logID":case "extensions":return new ArrayBuffer(0);case "timestamp":return new Date(0); +case "hashAlgorithm":case "signatureAlgorithm":return"";case "signature":return new l.a;default:throw Error("Invalid member name for SignedCertificateTimestamp class: "+a);}};Ba.prototype.fromSchema=function(a){if(!1===a instanceof l.t)throw Error("Object's schema was not verified against input data for SignedCertificateTimestamp");a=new la({stream:new ja({buffer:a.data})});this.fromStream(a)};Ba.prototype.fromStream=function(a){var B=a.getUint16();this.version=a.getBlock(1)[0];if(0===this.version){this.logID= +(new Uint8Array(a.getBlock(32))).buffer.slice(0);this.timestamp=new Date(Object(e.k)(new Uint8Array(a.getBlock(8)),8));var L=a.getUint16();this.extensions=(new Uint8Array(a.getBlock(L))).buffer.slice(0);switch(a.getBlock(1)[0]){case 0:this.hashAlgorithm="none";break;case 1:this.hashAlgorithm="md5";break;case 2:this.hashAlgorithm="sha1";break;case 3:this.hashAlgorithm="sha224";break;case 4:this.hashAlgorithm="sha256";break;case 5:this.hashAlgorithm="sha384";break;case 6:this.hashAlgorithm="sha512"; +break;default:throw Error("Object's stream was not correct for SignedCertificateTimestamp");}switch(a.getBlock(1)[0]){case 0:this.signatureAlgorithm="anonymous";break;case 1:this.signatureAlgorithm="rsa";break;case 2:this.signatureAlgorithm="dsa";break;case 3:this.signatureAlgorithm="ecdsa";break;default:throw Error("Object's stream was not correct for SignedCertificateTimestamp");}var Y=a.getUint16();a=(new Uint8Array(a.getBlock(Y))).buffer.slice(0);a=l.E(a);if(-1===a.offset)throw Error("Object's stream was not correct for SignedCertificateTimestamp"); +this.signature=a.result;if(B!==47+L+Y)throw Error("Object's stream was not correct for SignedCertificateTimestamp");}};Ba.prototype.toSchema=function(){var a=this.toStream();return new l.t({data:a.stream.buffer})};Ba.prototype.toStream=function(){var a=new la;a.appendUint16(47+this.extensions.byteLength+this.signature.valueBeforeDecode.byteLength);a.appendChar(this.version);a.appendView(new Uint8Array(this.logID));var B=new ArrayBuffer(8);B=new Uint8Array(B);var L=Object(e.l)(this.timestamp.valueOf(), +8);B.set(new Uint8Array(L),8-L.byteLength);a.appendView(B);a.appendUint16(this.extensions.byteLength);this.extensions.byteLength&&a.appendView(new Uint8Array(this.extensions));switch(this.hashAlgorithm.toLowerCase()){case "none":B=0;break;case "md5":B=1;break;case "sha1":B=2;break;case "sha224":B=3;break;case "sha256":B=4;break;case "sha384":B=5;break;case "sha512":B=6;break;default:throw Error("Incorrect data for hashAlgorithm: "+this.hashAlgorithm);}a.appendChar(B);switch(this.signatureAlgorithm.toLowerCase()){case "anonymous":B= +0;break;case "rsa":B=1;break;case "dsa":B=2;break;case "ecdsa":B=3;break;default:throw Error("Incorrect data for signatureAlgorithm: "+this.signatureAlgorithm);}a.appendChar(B);B=this.signature.toBER(!1);a.appendUint16(B.byteLength);a.appendView(new Uint8Array(B));return a};Ba.prototype.toJSON=function(){return{version:this.version,logID:Object(e.b)(this.logID),timestamp:this.timestamp,extensions:Object(e.b)(this.extensions),hashAlgorithm:this.hashAlgorithm,signatureAlgorithm:this.signatureAlgorithm, +signature:this.signature.toJSON()}};Ba.prototype.verify=function(a,B,L){L=void 0===L?0:L;var Y=this,ha,qa,Aa,Ea,Ga,Ja,Qa,Wa,jb,kb,lb;return $jscomp.asyncExecutePromiseGeneratorProgram(function(hb){ha=Object(e.i)(Object(e.a)(Y.logID));qa=null;Ea=new la;Ga=$jscomp.makeIterator(a);for(Ja=Ga.next();!Ja.done;Ja=Ga.next())if(Qa=Ja.value,Qa.log_id===ha){qa=Qa.key;break}if(null===qa)throw Error("Public key not found for CT with logId: "+ha);Wa=l.E(Object(e.h)(Object(e.d)(qa)));if(-1===Wa.offset)throw Error("Incorrect key value for CT Log with logId: "+ +ha);Aa=new ea.a({schema:Wa.result});Ea.appendChar(0);Ea.appendChar(0);jb=new ArrayBuffer(8);kb=new Uint8Array(jb);lb=Object(e.l)(Y.timestamp.valueOf(),8);kb.set(new Uint8Array(lb),8-lb.byteLength);Ea.appendView(kb);Ea.appendUint16(L);0===L&&Ea.appendUint24(B.byteLength);Ea.appendView(new Uint8Array(B));Ea.appendUint16(Y.extensions.byteLength);0!==Y.extensions.byteLength&&Ea.appendView(new Uint8Array(Y.extensions));return hb.return(Object(P.e)().subtle.verifyWithPublicKey(Ea._stream._buffer.slice(0, +Ea._length),{valueBlock:{valueHex:Y.signature.toBER(!1)}},Aa,{algorithmId:""},"SHA-256"))})};var Ha=function(a){a=void 0===a?{}:a;this.timestamps=Object(e.e)(a,"timestamps",Ha.defaultValues("timestamps"));"schema"in a&&this.fromSchema(a.schema)};Ha.defaultValues=function(a){switch(a){case "timestamps":return[];default:throw Error("Invalid member name for SignedCertificateTimestampList class: "+a);}};Ha.compareWithDefault=function(a,B){switch(a){case "timestamps":return 0===B.length;default:throw Error("Invalid member name for SignedCertificateTimestampList class: "+ +a);}};Ha.schema=function(a){a=void 0===a?{}:a;a=Object(e.e)(a,"names",{});!1==="optional"in a&&(a.optional=!1);return new l.q({name:a.blockName||"SignedCertificateTimestampList",optional:a.optional})};Ha.prototype.fromSchema=function(a){if(!1===a instanceof l.q)throw Error("Object's schema was not verified against input data for SignedCertificateTimestampList");a=new la({stream:new ja({buffer:a.valueBlock.valueHex})});if(a.getUint16()!==a.length)throw Error("Object's schema was not verified against input data for SignedCertificateTimestampList"); +for(;a.length;)this.timestamps.push(new Ba({stream:a}))};Ha.prototype.toSchema=function(){for(var a=new la,B=0,L=[],Y=$jscomp.makeIterator(this.timestamps),ha=Y.next();!ha.done;ha=Y.next())ha=ha.value.toStream(),L.push(ha),B+=ha.stream.buffer.byteLength;a.appendUint16(B);B=$jscomp.makeIterator(L);for(ha=B.next();!ha.done;ha=B.next())a.appendView(ha.value.stream.view);return new l.q({valueHex:a.stream.buffer.slice(0)})};Ha.prototype.toJSON=function(){return{timestamps:Array.from(this.timestamps,function(a){return a.toJSON()})}}; +var Ma=function(a){a=void 0===a?{}:a;this.templateID=Object(e.e)(a,"templateID",Ma.defaultValues("templateID"));"templateMajorVersion"in a&&(this.templateMajorVersion=Object(e.e)(a,"templateMajorVersion",Ma.defaultValues("templateMajorVersion")));"templateMinorVersion"in a&&(this.templateMinorVersion=Object(e.e)(a,"templateMinorVersion",Ma.defaultValues("templateMinorVersion")));"schema"in a&&this.fromSchema(a.schema)};Ma.defaultValues=function(a){switch(a){case "templateID":return"";case "templateMajorVersion":case "templateMinorVersion":return 0; +default:throw Error("Invalid member name for CertificateTemplate class: "+a);}};Ma.schema=function(a){a=void 0===a?{}:a;a=Object(e.e)(a,"names",{});return new l.v({name:a.blockName||"",value:[new l.p({name:a.templateID||""}),new l.m({name:a.templateMajorVersion||"",optional:!0}),new l.m({name:a.templateMinorVersion||"",optional:!0})]})};Ma.prototype.fromSchema=function(a){Object(e.c)(a,["templateID","templateMajorVersion","templateMinorVersion"]);a=l.D(a,a,Ma.schema({names:{templateID:"templateID", +templateMajorVersion:"templateMajorVersion",templateMinorVersion:"templateMinorVersion"}}));if(!1===a.verified)throw Error("Object's schema was not verified against input data for CertificateTemplate");this.templateID=a.result.templateID.valueBlock.toString();"templateMajorVersion"in a.result&&(this.templateMajorVersion=a.result.templateMajorVersion.valueBlock.valueDec);"templateMinorVersion"in a.result&&(this.templateMinorVersion=a.result.templateMinorVersion.valueBlock.valueDec)};Ma.prototype.toSchema= +function(){var a=[];a.push(new l.p({value:this.templateID}));"templateMajorVersion"in this&&a.push(new l.m({value:this.templateMajorVersion}));"templateMinorVersion"in this&&a.push(new l.m({value:this.templateMinorVersion}));return new l.v({value:a})};Ma.prototype.toJSON=function(){var a={extnID:this.templateID};"templateMajorVersion"in this&&(a.templateMajorVersion=this.templateMajorVersion);"templateMinorVersion"in this&&(a.templateMinorVersion=this.templateMinorVersion);return a};var Sa=function(a){a= +void 0===a?{}:a;this.certificateIndex=Object(e.e)(a,"certificateIndex",Sa.defaultValues("certificateIndex"));this.keyIndex=Object(e.e)(a,"keyIndex",Sa.defaultValues("keyIndex"));"schema"in a&&this.fromSchema(a.schema)};Sa.defaultValues=function(a){switch(a){case "certificateIndex":case "keyIndex":return 0;default:throw Error("Invalid member name for CAVersion class: "+a);}};Sa.schema=function(a){return new l.m};Sa.prototype.fromSchema=function(a){if(a.constructor.blockName()!==l.m.blockName())throw Error("Object's schema was not verified against input data for CAVersion"); +a=a.valueBlock.valueHex.slice(0);var B=new Uint8Array(a);switch(!0){case 4>a.byteLength:var L=new ArrayBuffer(4);(new Uint8Array(L)).set(B,4-a.byteLength);a=L.slice(0);break;case 4\n"):this.result.push("?>"))};Ya.prototype.WriteElementNode=function(a){var B=this.state;this.state===xb.BeforeDocElement&&(this.state=xb.InsideDocElement);this.result.push("<");this.result.push(a.nodeName);var L=this.WriteNamespacesAxis(a);this.WriteAttributesAxis(a);this.result.push(">");for(var Y=a.firstChild;null!=Y;Y=Y.nextSibling)this.WriteNode(Y);this.result.push("");B===xb.BeforeDocElement&&(this.state=xb.AfterDocElement);for(;L--;)this.visibleNamespaces.Pop()};Ya.prototype.WriteNamespacesAxis=function(a){for(var B=this,L=[],Y=0,ha=0;ha"===ha&&this.IsTextNode(B)?L.push(">"):"&"!==ha||B!==m.n.Attribute&&!this.IsTextNode(B)?'"'===ha&&B===m.n.Attribute?L.push("""):"\t"===ha&&B===m.n.Attribute?L.push(" "):"\n"===ha&&B===m.n.Attribute? +L.push(" "):"\r"===ha?L.push(" "):L.push(ha):L.push("&"):L.push("<")}return L.join("")};Ya.prototype.IsTextNode=function(a){switch(a){case m.n.Text:case m.n.CDATA:case m.n.SignificantWhitespace:case m.n.Whitespace:return!0}return!1};Ya.prototype.IsNamespaceInclusive=function(a,B){B=B||null;return a.prefix===B?!1:-1!==this.inclusiveNamespacesPrefixList.indexOf(B||"")};Ya.prototype.IsNamespaceRendered=function(a,B){a=a||"";B=B||"";return!a&&!B||"xml"===a&&"http://www.w3.org/XML/1998/namespace"=== +B?!0:(a=this.visibleNamespaces.GetPrefix(a))?a.namespace===B:!1};$jscomp.global.Object.defineProperties(Ya.prototype,{InclusiveNamespacesPrefixList:{configurable:!0,enumerable:!0,get:function(){return this.inclusiveNamespacesPrefixList.join(" ")},set:function(a){this.inclusiveNamespacesPrefixList=a.split(" ")}}});var eb=m.p,pb=function(){return eb.apply(this,arguments)||this};$jscomp.inherits(pb,eb);var Xa=pb;Xa=u([Object(m.l)({localName:"xmldsig",namespaceURI:"http://www.w3.org/2000/09/xmldsig#", +prefix:"ds"})],Xa);var ub=m.j,Ab=function(){return ub.apply(this,arguments)||this};$jscomp.inherits(Ab,ub);var cb=Ab;cb=u([Object(m.l)({localName:"xmldsig_collection",namespaceURI:"http://www.w3.org/2000/09/xmldsig#",prefix:"ds"})],cb);var sb=function(){return Xa.apply(this,arguments)||this};$jscomp.inherits(sb,Xa);var te=function(){return Xa.apply(this,arguments)||this};$jscomp.inherits(te,Xa);var kc=te;u([Object(m.g)({localName:"Algorithm",required:!0,defaultValue:"http://www.w3.org/TR/2001/REC-xml-c14n-20010315"})], +kc.prototype,"Algorithm",void 0);kc=u([Object(m.l)({localName:"CanonicalizationMethod"})],kc);var ue=function(){return Xa.apply(this,arguments)||this};$jscomp.inherits(ue,Xa);var $b=ue;u([Object(m.g)({localName:"Id",defaultValue:""})],$b.prototype,"Id",void 0);u([Object(m.g)({localName:"MimeType",defaultValue:""})],$b.prototype,"MimeType",void 0);u([Object(m.g)({localName:"Encoding",defaultValue:""})],$b.prototype,"Encoding",void 0);$b=u([Object(m.l)({localName:"Object"})],$b);var ve=function(){return cb.apply(this, +arguments)||this};$jscomp.inherits(ve,cb);var ie=ve;ie=u([Object(m.l)({localName:"xmldsig_objects",parser:$b})],ie);var we=function(a){var B=Xa.call(this)||this;a&&(B.Algorithm=a);return B};$jscomp.inherits(we,Xa);var Eb=we;u([Object(m.g)({localName:"Algorithm",required:!0,defaultValue:"http://www.w3.org/2001/04/xmlenc#sha256"})],Eb.prototype,"Algorithm",void 0);Eb=u([Object(m.l)({localName:"DigestMethod"})],Eb);var je=function(){return cb.apply(this,arguments)||this};$jscomp.inherits(je,cb);je.prototype.OnLoadXml= +function(a){for(var B=0;BAa.length||"("!==Aa[0]||")"!==Aa[Aa.length-1]?"":Aa.substring(1,Aa.length-1),6NIF");var ca=H(Z,"FechaExpedicionFactura").replace(/(..)-(..)-..(..)/g, +"$1$2$3");Z=H(Z,"SignatureValue").substr(0,13);S=["TBAI",S,ca,Z,""].join("-");return S+("000"+Object(y.a)(S)).slice(-3)}function P(S){S="string"===typeof S?F(S):S;var Z=H(S,"FechaExpedicionFactura"),ca=H(S,"HoraExpedicionFactura");Z={issuedTime:new Date(Z.split("-").reverse().join("-")+" "+ca),number:H(S,"CabeceraFactura>NumFactura"),hash:H(S,"SignatureValue").substr(0,100)};if(S=x(S,"CabeceraFactura>SerieFactura",""))Z.serie=S;return Z}function l(S,Z){S="string"===typeof S?F(S):S;S={id:m(S),s:x(S, +"SerieFactura",""),nf:H(S,"NumFactura"),i:H(S,"ImporteTotalFactura")};Z+=function(ca){return"?"+Object.keys(ca).reduce(function(ea,ia){ea.push(ia+"="+encodeURIComponent(ca[ia]));return ea},[]).join("&")}(S);return Z+"&cr="+("000"+Object(y.a)(Z)).slice(-3)}function e(S,Z){return l(S,[["https://ticketbai.araba.eus/TBAI/QRTBAI","https://batuz.eus/QRTBAI/","https://tbai.egoitza.gipuzkoa.eus/qr/"],["https://pruebas-ticketbai.araba.eus/tbai/qrtbai/","https://batuz.eus/QRTBAI/","https://tbai.prep.gipuzkoa.eus/qr/"]][2< +arguments.length&&void 0!==arguments[2]&&arguments[2]?1:0][Z])}C.d(E,"d",function(){return m});C.d(E,"c",function(){return P});C.d(E,"a",function(){return G});C.d(E,"f",function(){return l});C.d(E,"e",function(){return e});C.d(E,"b",function(){return M});var w=C(45);C.n(w);var J=C(43),h=C(11);C.n(h);var y=C(63),G;(function(S){S[S.ARABA=0]="ARABA";S[S.BIZKAIA=1]="BIZKAIA";S[S.GIPUZKOA=2]="GIPUZKOA"})(G||(G={}));var M=function(){function S(Z,ca,ea,ia,na){if(!(this instanceof S))throw new TypeError("Cannot call a class as a function"); +q(this,"privateKey",void 0);q(this,"publicKey",void 0);q(this,"cert",void 0);q(this,"crypto",void 0);q(this,"hash",void 0);this.privateKey=Z;this.publicKey=ca;this.cert=ea;this.crypto=ia;this.hash=na}V(S,[{key:"sign",value:function(){var Z=k(regeneratorRuntime.mark(function ia(ea){var na,r,n,v,D,U=arguments;return regeneratorRuntime.wrap(function(N){for(;;)switch(N.prev=N.next){case 0:return na=1\n'+n.toString());case 9:case "end":return N.stop()}},ia,this)}));return function(ea){return Z.apply(this,arguments)}}()}],[{key:"fromBuffer",value:function(){var Z=k(regeneratorRuntime.mark(function r(ea,ia,na){var n,v,D,U=arguments;return regeneratorRuntime.wrap(function(N){for(;;)switch(N.prev=N.next){case 0:return n=3"==da&&">"||"&"==da&&"&"||'"'==da&&"""||"&#"+da.charCodeAt()+";"}function l(da,fa){if(fa(da))return!0;if(da=da.firstChild){do if(l(da,fa))return!0;while(da=da.nextSibling)}} +function e(){}function w(da,fa,wa){if(da&&da._inc)if(da._inc++,da=fa.childNodes,wa)da[da.length++]=wa;else{fa=fa.firstChild;for(wa=0;fa;)da[wa++]=fa,fa=fa.nextSibling;da.length=wa;delete da[da.length]}}function J(da,fa){var wa=fa.previousSibling,ya=fa.nextSibling;wa?wa.nextSibling=ya:da.firstChild=ya;ya?ya.previousSibling=wa:da.lastChild=wa;fa.parentNode=null;fa.previousSibling=null;fa.nextSibling=null;w(da.ownerDocument,da);return fa}function h(da,fa,wa){var ya=fa.parentNode;ya&&ya.removeChild(fa); +if(fa.nodeType===Sa){ya=fa.firstChild;if(null==ya)return fa;var b=fa.lastChild}else ya=b=fa;var R=wa?wa.previousSibling:da.lastChild;ya.previousSibling=R;b.nextSibling=wa;R?R.nextSibling=ya:da.firstChild=ya;null==wa?da.lastChild=b:wa.previousSibling=b;do ya.parentNode=da;while(ya!==b&&(ya=ya.nextSibling));w(da.ownerDocument||da,da);fa.nodeType==Sa&&(fa.firstChild=fa.lastChild=null);return fa}function y(){this._nsMap={}}function G(){}function M(){}function S(){}function Z(){}function ca(){}function ea(){} +function ia(){}function na(){}function r(){}function n(){}function v(){}function D(){}function U(da,fa){var wa=[],ya=9==this.nodeType&&this.documentElement||this,b=ya.prefix,R=ya.namespaceURI;if(R&&null==b&&(b=ya.lookupPrefix(R),null==b))var ba=[{namespace:R,prefix:null}];K(this,wa,da,fa,ba);return wa.join("")}function N(da,fa,wa){fa=da.prefix||"";da=da.namespaceURI;if(!da||"xml"===fa&&da===za.XML||da===za.XMLNS)return!1;for(var ya=wa.length;ya--;){var b=wa[ya];if(b.prefix===fa)return b.namespace!== +da}return!0}function O(da,fa,wa){da.push(" ",fa,'="',wa.replace(/[<&"\t\n\r]/g,P),'"')}function K(da,fa,wa,ya,b){b||(b=[]);if(ya)if(da=ya(da)){if("string"==typeof da){fa.push(da);return}}else return;switch(da.nodeType){case ta:var R=da.attributes,ba=R.length,ra=da.firstChild,oa=da.tagName;wa=za.isHTML(da.namespaceURI)||wa;var Da=oa;if(!wa&&!da.prefix&&da.namespaceURI){for(var Fa,Oa=0;Oa");if(wa&&/^script$/i.test(oa))for(;ra;)ra.data?fa.push(ra.data):K(ra,fa,wa,ya,b.slice()),ra=ra.nextSibling;else for(;ra;)K(ra,fa,wa,ya,b.slice()),ra=ra.nextSibling;fa.push("")}else fa.push("/>");break;case Ha:case Sa:for(ra=da.firstChild;ra;)K(ra, +fa,wa,ya,b.slice()),ra=ra.nextSibling;break;case c:return O(fa,da.name,da.value);case X:return fa.push(da.data.replace(/[<&]/g,P).replace(/]]\x3e/g,"]]>"));case ka:return fa.push("")):ya&&"."!=ya?fa.push(" SYSTEM ",ya,">"):((da=da.internalSubset)&&fa.push(" [",da,"]"),fa.push(">"));break; +case la:return fa.push("");case ja:return fa.push("&",da.nodeName,";");default:fa.push("??",da.nodeName)}}function pa(da,fa,wa){switch(fa.nodeType){case ta:var ya=fa.cloneNode(!1);ya.ownerDocument=da;case Sa:break;case c:wa=!0}ya||(ya=fa.cloneNode(!1));ya.ownerDocument=da;ya.parentNode=null;if(wa)for(fa=fa.firstChild;fa;)ya.appendChild(pa(da,fa,wa)),fa=fa.nextSibling;return ya}function xa(da,fa,wa){var ya=new fa.constructor;for(R in fa){var b=fa[R];"object"!=typeof b&& +b!=ya[R]&&(ya[R]=b)}fa.childNodes&&(ya.childNodes=new g);ya.ownerDocument=da;switch(ya.nodeType){case ta:var R=fa.attributes;var ba=ya.attributes=new W;b=R.length;ba._ownerElement=ya;for(ba=0;bara){for(;ba>ra;)b=b.parentNode||b.ownerElement,ba--;if(b===R)return 1}else if(ra>ba){for(;ra>ba;)R=R.parentNode||R.ownerElement,ra--;if(b===R)return-1}ba=b.parentNode||b.ownerElement;for(ra=R.parentNode||R.ownerElement;ba!==ra;)b=ba,R=ra,ba=b.parentNode||b.ownerElement,ra=R.parentNode||R.ownerElement;ra=fa.isAttribute(b);oa=fa.isAttribute(R);if(ra&&!oa)return-1; +if(!ra&&oa)return 1;if(ba)for(ba=ra?ba.attributes:ba.childNodes,ra=ba.length,oa=0;oa +Da||9 >>>>>>>>> >>>>>>> >> >> { 1 . +*)(' # \" { 1 . +*)(' # \" {Q QQQQQQQQQ QQQQQQQ QQ aQ {V VVVVVVVVV VVVVVVV VV aV {T TTTTTTTTT TTTTTTT TT T {@ @@@@@@@@@ @@@@@@@ @@ @@ { \u0087 {[ [[[[[[[[[ [[[[[[[ [[ [[ {D DDDDDDDDD DDDDDDD DD DD { HH { \u0088 { F\u0089 {# T# ## # {% V %% U %% % {' 'ZY'' 'XW '' ' {( (ZY(( (XW (( ( {+ +++++ +++\\[ ++ + {* ***** ***\\[ ** * {- ----- ---\\[ -- - {, ,,,,, ,,,\\[ ,, , {0 00000_^] 00000 00 0 {/ /////_^] ///// // / {2 22222222 22222 22 2 {3 33333333 33333 33 3 {4 44444444 44444 44 4 {8 88888888 888888 88 8 { ^ { \u008a {; f;;;;;;;; ;;;;;;e ;; ; {< f<<<<<<<< <<<<<=b.length)break;if("("==oa)R.push(f.LEFTPARENTHESIS),ba.push(oa),oa=b.charAt(ra++);else if(")"==oa)R.push(f.RIGHTPARENTHESIS),ba.push(oa),oa=b.charAt(ra++);else if("["==oa)R.push(f.LEFTBRACKET),ba.push(oa),oa=b.charAt(ra++);else if("]"==oa)R.push(f.RIGHTBRACKET),ba.push(oa),oa=b.charAt(ra++);else if("@"==oa)R.push(f.AT),ba.push(oa),oa=b.charAt(ra++);else if(","==oa)R.push(f.COMMA),ba.push(oa),oa=b.charAt(ra++);else if("|"==oa)R.push(f.BAR), +ba.push(oa),oa=b.charAt(ra++);else if("+"==oa)R.push(f.PLUS),ba.push(oa),oa=b.charAt(ra++);else if("-"==oa)R.push(f.MINUS),ba.push(oa),oa=b.charAt(ra++);else if("="==oa)R.push(f.EQUALS),ba.push(oa),oa=b.charAt(ra++);else if("$"==oa)R.push(f.DOLLAR),ba.push(oa),oa=b.charAt(ra++);else if("."==oa)if(oa=b.charAt(ra++),"."==oa)R.push(f.DOUBLEDOT),ba.push(".."),oa=b.charAt(ra++);else if("0"<=oa&&"9">=oa){var Da="."+oa;for(oa=b.charAt(ra++);"0"<=oa&&"9">=oa;)Da+=oa,oa=b.charAt(ra++);R.push(f.NUMBER);ba.push(Da)}else R.push(f.DOT), +ba.push(".");else if("'"==oa||'"'==oa){Da=oa;for(var Fa="";ra=oa){Da=oa;for(oa=b.charAt(ra++);"0"<=oa&&"9">=oa;)Da+=oa,oa=b.charAt(ra++);if("."==oa&&"0"<=b.charAt(ra)&&"9">=b.charAt(ra))for(Da+=oa,Da+=b.charAt(ra++),oa=b.charAt(ra++);"0"<=oa&&"9">=oa;)Da+=oa,oa=b.charAt(ra++);R.push(f.NUMBER);ba.push(Da)}else if("*"== +oa){if(0"==oa)"="==b.charAt(ra)?(R.push(f.GREATERTHANOREQUAL),ba.push(">="), +ra++):(R.push(f.GREATERTHAN),ba.push(">")),oa=b.charAt(ra++);else if("_"==oa||fa.isLetter(oa.charCodeAt(0))){Fa=oa;for(oa=b.charAt(ra++);fa.isNCNameChar(oa.charCodeAt(0));)Fa+=oa,oa=b.charAt(ra++);if(0"};d.prototype.evaluate=function(b){throw Error("Could not evaluate expression.");};g.prototype=new d;g.prototype.constructor=g;g.superclass=d.prototype;g.prototype.init=function(b){this.rhs=b};t.prototype=new g;t.prototype.constructor=t;t.superclass=g.prototype;t.prototype.init=function(b){t.superclass.init.call(this,b)};t.prototype.evaluate=function(b){return this.rhs.evaluate(b).number().negate()}; +t.prototype.toString=function(){return"-"+this.rhs.toString()};A.prototype=new d;A.prototype.constructor=A;A.superclass=d.prototype;A.prototype.init=function(b,R){this.lhs=b;this.rhs=R};W.prototype=new A;W.prototype.constructor=W;W.superclass=A.prototype;W.prototype.init=function(b,R){W.superclass.init.call(this,b,R)};W.prototype.toString=function(){return"("+this.lhs.toString()+" or "+this.rhs.toString()+")"};W.prototype.evaluate=function(b){var R=this.lhs.evaluate(b).bool();return R.booleanValue()? +R:this.rhs.evaluate(b).bool()};F.prototype=new A;F.prototype.constructor=F;F.superclass=A.prototype;F.prototype.init=function(b,R){F.superclass.init.call(this,b,R)};F.prototype.toString=function(){return"("+this.lhs.toString()+" and "+this.rhs.toString()+")"};F.prototype.evaluate=function(b){var R=this.lhs.evaluate(b).bool();return R.booleanValue()?this.rhs.evaluate(b).bool():R};H.prototype=new A;H.prototype.constructor=H;H.superclass=A.prototype;H.prototype.init=function(b,R){H.superclass.init.call(this, +b,R)};H.prototype.toString=function(){return"("+this.lhs.toString()+" = "+this.rhs.toString()+")"};H.prototype.evaluate=function(b){return this.lhs.evaluate(b).equals(this.rhs.evaluate(b))};x.prototype=new A;x.prototype.constructor=x;x.superclass=A.prototype;x.prototype.init=function(b,R){x.superclass.init.call(this,b,R)};x.prototype.toString=function(){return"("+this.lhs.toString()+" != "+this.rhs.toString()+")"};x.prototype.evaluate=function(b){return this.lhs.evaluate(b).notequal(this.rhs.evaluate(b))}; +z.prototype=new A;z.prototype.constructor=z;z.superclass=A.prototype;z.prototype.init=function(b,R){z.superclass.init.call(this,b,R)};z.prototype.evaluate=function(b){return this.lhs.evaluate(b).lessthan(this.rhs.evaluate(b))};z.prototype.toString=function(){return"("+this.lhs.toString()+" < "+this.rhs.toString()+")"};m.prototype=new A;m.prototype.constructor=m;m.superclass=A.prototype;m.prototype.init=function(b,R){m.superclass.init.call(this,b,R)};m.prototype.evaluate=function(b){return this.lhs.evaluate(b).greaterthan(this.rhs.evaluate(b))}; +m.prototype.toString=function(){return"("+this.lhs.toString()+" > "+this.rhs.toString()+")"};P.prototype=new A;P.prototype.constructor=P;P.superclass=A.prototype;P.prototype.init=function(b,R){P.superclass.init.call(this,b,R)};P.prototype.evaluate=function(b){return this.lhs.evaluate(b).lessthanorequal(this.rhs.evaluate(b))};P.prototype.toString=function(){return"("+this.lhs.toString()+" <= "+this.rhs.toString()+")"};l.prototype=new A;l.prototype.constructor=l;l.superclass=A.prototype;l.prototype.init= +function(b,R){l.superclass.init.call(this,b,R)};l.prototype.evaluate=function(b){return this.lhs.evaluate(b).greaterthanorequal(this.rhs.evaluate(b))};l.prototype.toString=function(){return"("+this.lhs.toString()+" >= "+this.rhs.toString()+")"};e.prototype=new A;e.prototype.constructor=e;e.superclass=A.prototype;e.prototype.init=function(b,R){e.superclass.init.call(this,b,R)};e.prototype.evaluate=function(b){return this.lhs.evaluate(b).number().plus(this.rhs.evaluate(b).number())};e.prototype.toString= +function(){return"("+this.lhs.toString()+" + "+this.rhs.toString()+")"};w.prototype=new A;w.prototype.constructor=w;w.superclass=A.prototype;w.prototype.init=function(b,R){w.superclass.init.call(this,b,R)};w.prototype.evaluate=function(b){return this.lhs.evaluate(b).number().minus(this.rhs.evaluate(b).number())};w.prototype.toString=function(){return"("+this.lhs.toString()+" - "+this.rhs.toString()+")"};J.prototype=new A;J.prototype.constructor=J;J.superclass=A.prototype;J.prototype.init=function(b, +R){J.superclass.init.call(this,b,R)};J.prototype.evaluate=function(b){return this.lhs.evaluate(b).number().multiply(this.rhs.evaluate(b).number())};J.prototype.toString=function(){return"("+this.lhs.toString()+" * "+this.rhs.toString()+")"};h.prototype=new A;h.prototype.constructor=h;h.superclass=A.prototype;h.prototype.init=function(b,R){h.superclass.init.call(this,b,R)};h.prototype.evaluate=function(b){return this.lhs.evaluate(b).number().div(this.rhs.evaluate(b).number())};h.prototype.toString= +function(){return"("+this.lhs.toString()+" div "+this.rhs.toString()+")"};y.prototype=new A;y.prototype.constructor=y;y.superclass=A.prototype;y.prototype.init=function(b,R){y.superclass.init.call(this,b,R)};y.prototype.evaluate=function(b){return this.lhs.evaluate(b).number().mod(this.rhs.evaluate(b).number())};y.prototype.toString=function(){return"("+this.lhs.toString()+" mod "+this.rhs.toString()+")"};G.prototype=new A;G.prototype.constructor=G;G.superclass=A.prototype;G.prototype.init=function(b, +R){G.superclass.init.call(this,b,R)};G.prototype.evaluate=function(b){return this.lhs.evaluate(b).nodeset().union(this.rhs.evaluate(b).nodeset())};G.prototype.toString=function(){return Ha(V,[this.lhs,this.rhs]).join(" | ")};M.prototype=new d;M.prototype.constructor=M;M.superclass=d.prototype;M.prototype.init=function(b,R,ba){M.superclass.init.call(this);this.filter=b;this.filterPredicates=R;this.locationPath=ba};M.applyPredicates=function(b,R,ba){if(0===b.length)return ba;var ra=R.extend({});return Ba(function(oa, +Da){ra.contextSize=oa.length;return Ma(function(Fa,Oa){ra.contextNode=Fa;ra.contextPosition=Oa+1;return M.predicateMatches(Da,ra)},oa)},ba,b)};M.getRoot=function(b,R){R=R[0];if(9===R.nodeType)return R;if(b.virtualRoot)return b.virtualRoot;if(b=R.ownerDocument)return b;for(b=R;null!=b.parentNode;)b=b.parentNode;return b};M.applyStep=function(b,R,ba){var ra=[];R.contextNode=ba;switch(b.axis){case ea.ANCESTOR:if(R.contextNode===R.virtualRoot)break;for(ba=2==R.contextNode.nodeType?M.getOwnerElement(R.contextNode): +R.contextNode.parentNode;null!=ba;){b.nodeTest.matches(ba,R)&&ra.push(ba);if(ba===R.virtualRoot)break;ba=ba.parentNode}break;case ea.ANCESTORORSELF:for(ba=R.contextNode;null!=ba&&(b.nodeTest.matches(ba,R)&&ra.push(ba),ba!==R.virtualRoot);ba=2==ba.nodeType?M.getOwnerElement(ba):ba.parentNode);break;case ea.ATTRIBUTE:var oa=R.contextNode.attributes;if(null!=oa)for(var Da=0;Da"}; +ia.prototype.matches=function(b,R){console.warn("unknown node test type")};ia.NAMETESTANY=0;ia.NAMETESTPREFIXANY=1;ia.NAMETESTQNAME=2;ia.COMMENT=3;ia.TEXT=4;ia.PI=5;ia.NODE=6;ia.isNodeType=function(b){return function(R){a:{for(var ba=0;ba +b.num)};v.prototype.lessthanorequal=function(b){return fa.instance_of(b,O)?b.compareWithNumber(this,nb):fa.instance_of(b,D)||fa.instance_of(b,n)?this.lessthanorequal(b.number()):new D(this.num<=b.num)};v.prototype.greaterthanorequal=function(b){return fa.instance_of(b,O)?b.compareWithNumber(this,gb):fa.instance_of(b,D)||fa.instance_of(b,n)?this.greaterthanorequal(b.number()):new D(this.num>=b.num)};v.prototype.plus=function(b){return new v(this.num+b.num)};v.prototype.minus=function(b){return new v(this.num- +b.num)};v.prototype.multiply=function(b){return new v(this.num*b.num)};v.prototype.div=function(b){return new v(this.num/b.num)};v.prototype.mod=function(b){return new v(this.num%b.num)};D.prototype=new d;D.prototype.constructor=D;D.superclass=d.prototype;D.prototype.init=function(b){this.b=!!b};D.prototype.toString=function(){return this.b.toString()};D.prototype.evaluate=function(b){return this};D.prototype.string=function(){return new n(this.b)};D.prototype.number=function(){return new v(this.b)}; +D.prototype.bool=function(){return this};D.prototype.nodeset=function(){throw Error("Cannot convert boolean to nodeset");};D.prototype.stringValue=function(){return this.string().stringValue()};D.prototype.numberValue=function(){return this.number().numberValue()};D.prototype.booleanValue=function(){return this.b};D.prototype.not=function(){return new D(!this.b)};D.prototype.equals=function(b){return fa.instance_of(b,n)||fa.instance_of(b,v)?this.equals(b.bool()):fa.instance_of(b,O)?b.compareWithBoolean(this, +Ia):new D(this.b==b.b)};D.prototype.notequal=function(b){return fa.instance_of(b,n)||fa.instance_of(b,v)?this.notequal(b.bool()):fa.instance_of(b,O)?b.compareWithBoolean(this,Ra):new D(this.b!=b.b)};D.prototype.lessthan=function(b){return this.number().lessthan(b)};D.prototype.greaterthan=function(b){return this.number().greaterthan(b)};D.prototype.lessthanorequal=function(b){return this.number().lessthanorequal(b)};D.prototype.greaterthanorequal=function(b){return this.number().greaterthanorequal(b)}; +D.true_=new D(!0);D.false_=new D(!1);U.prototype={};U.prototype.constructor=U;U.superclass=Object.prototype;U.prototype.init=function(b){this.right=this.left=null;this.node=b;this.depth=1};U.prototype.balance=function(){var b=null==this.left?0:this.left.depth,R=null==this.right?0:this.right.depth;b>R+1?((null==this.left.left?0:this.left.left.depth)<(null==this.left.right?0:this.left.right.depth)&&this.left.rotateRR(),this.rotateLL()):b+1(null== +this.right.right?0:this.right.right.depth)&&this.right.rotateLL(),this.rotateRR())};U.prototype.rotateLL=function(){var b=this.node,R=this.right;this.node=this.left.node;this.right=this.left;this.left=this.left.left;this.right.left=this.right.right;this.right.right=R;this.right.node=b;this.right.updateInNewLocation();this.updateInNewLocation()};U.prototype.rotateRR=function(){var b=this.node,R=this.left;this.node=this.right.node;this.left=this.right;this.right=this.right.right;this.left.right=this.left.left; +this.left.left=R;this.left.node=b;this.left.updateInNewLocation();this.updateInNewLocation()};U.prototype.updateInNewLocation=function(){this.getDepthFromChildren()};U.prototype.getDepthFromChildren=function(){this.depth=null==this.node?0:1;null!=this.left&&(this.depth=this.left.depth+1);null!=this.right&&this.depth<=this.right.depth&&(this.depth=this.right.depth+1)};U.prototype.add=function(b){if(b===this.node)return!1;var R=N(b,this.node),ba=!1;-1==R?null==this.left?(this.left=new U(b),ba=!0):(ba= +this.left.add(b))&&this.balance():1==R&&(null==this.right?(this.right=new U(b),ba=!0):(ba=this.right.add(b))&&this.balance());ba&&this.getDepthFromChildren();return ba};O.prototype=new d;O.prototype.constructor=O;O.superclass=d.prototype;O.prototype.init=function(){this.tree=null;this.nodes=[];this.size=0};O.prototype.toString=function(){var b=this.first();return null==b?"":this.stringForNode(b)};O.prototype.evaluate=function(b){return this};O.prototype.string=function(){return new n(this.toString())}; +O.prototype.stringValue=function(){return this.toString()};O.prototype.number=function(){return new v(this.string())};O.prototype.numberValue=function(){return Number(this.string())};O.prototype.bool=function(){return new D(this.booleanValue())};O.prototype.booleanValue=function(){return!!this.size};O.prototype.nodeset=function(){return this};O.prototype.stringForNode=function(b){return 9==b.nodeType||1==b.nodeType||11===b.nodeType?this.stringForContainerNode(b):2===b.nodeType?b.value||b.nodeValue: +b.isNamespaceNode?b.namespace:b.nodeValue};O.prototype.stringForContainerNode=function(b){var R="";for(b=b.firstChild;null!=b;b=b.nextSibling){var ba=b.nodeType;if(1===ba||3===ba||4===ba||9===ba||11===ba)R+=this.stringForNode(b)}return R};O.prototype.buildTree=function(){if(!this.tree&&this.nodes.length){this.tree=new U(this.nodes[0]);for(var b=1;barguments.length)throw Error("Function concat expects (string, string[, string]*)"); +for(var R="",ba=1;baFa.length?"":Fa[fb]);return Pa},{},Da);oa=Sa("",Ha(function(Pa){return Pa in Oa?Oa[Pa]:Pa},oa));return new n(oa)},boolean_:function(){var b=arguments[0];if(2!=arguments.length)throw Error("Function boolean expects (object)");return arguments[1].evaluate(b).bool()},not:function(b,R){if(2!=arguments.length)throw Error("Function not expects (object)");return R.evaluate(b).bool().not()},true_:function(){if(1!=arguments.length)throw Error("Function true expects ()");return D.true_},false_:function(){if(1!= +arguments.length)throw Error("Function false expects ()");return D.false_},lang:function(){var b=arguments[0];if(2!=arguments.length)throw Error("Function lang expects (string)");for(var R,ba=b.contextNode;null!=ba&&9!=ba.nodeType;ba=ba.parentNode){var ra=ba.getAttributeNS(k.XML_NAMESPACE_URI,"lang");if(null!=ra){R=String(ra);break}}if(null==R)return D.false_;b=arguments[1].evaluate(b).stringValue();return new D(R.substring(0,b.length)==b&&(R.length==b.length||"-"==R.charAt(b.length)))},number:function(){var b= +arguments[0];if(1!=arguments.length&&2!=arguments.length)throw Error("Function number expects (object?)");return 1==arguments.length?new v(O.prototype.stringForNode(b.contextNode)):arguments[1].evaluate(b).number()},sum:function(){var b=arguments[0],R;if(2!=arguments.length||!fa.instance_of(R=arguments[1].evaluate(b),O))throw Error("Function sum expects (node-set)");R=R.toUnsortedArray();for(var ba=b=0;ba=b||97<=b&&122>=b||192<=b&&214>=b||216<=b&&246>=b||248<=b&&255>=b||256<=b&&305>=b||308<=b&&318>=b||321<=b&&328>= +b||330<=b&&382>=b||384<=b&&451>=b||461<=b&&496>=b||500<=b&&501>=b||506<=b&&535>=b||592<=b&&680>=b||699<=b&&705>=b||902==b||904<=b&&906>=b||908==b||910<=b&&929>=b||931<=b&&974>=b||976<=b&&982>=b||986==b||988==b||990==b||992==b||994<=b&&1011>=b||1025<=b&&1036>=b||1038<=b&&1103>=b||1105<=b&&1116>=b||1118<=b&&1153>=b||1168<=b&&1220>=b||1223<=b&&1224>=b||1227<=b&&1228>=b||1232<=b&&1259>=b||1262<=b&&1269>=b||1272<=b&&1273>=b||1329<=b&&1366>=b||1369==b||1377<=b&&1414>=b||1488<=b&&1514>=b||1520<=b&&1522>= +b||1569<=b&&1594>=b||1601<=b&&1610>=b||1649<=b&&1719>=b||1722<=b&&1726>=b||1728<=b&&1742>=b||1744<=b&&1747>=b||1749==b||1765<=b&&1766>=b||2309<=b&&2361>=b||2365==b||2392<=b&&2401>=b||2437<=b&&2444>=b||2447<=b&&2448>=b||2451<=b&&2472>=b||2474<=b&&2480>=b||2482==b||2486<=b&&2489>=b||2524<=b&&2525>=b||2527<=b&&2529>=b||2544<=b&&2545>=b||2565<=b&&2570>=b||2575<=b&&2576>=b||2579<=b&&2600>=b||2602<=b&&2608>=b||2610<=b&&2611>=b||2613<=b&&2614>=b||2616<=b&&2617>=b||2649<=b&&2652>=b||2654==b||2674<=b&&2676>= +b||2693<=b&&2699>=b||2701==b||2703<=b&&2705>=b||2707<=b&&2728>=b||2730<=b&&2736>=b||2738<=b&&2739>=b||2741<=b&&2745>=b||2749==b||2784==b||2821<=b&&2828>=b||2831<=b&&2832>=b||2835<=b&&2856>=b||2858<=b&&2864>=b||2866<=b&&2867>=b||2870<=b&&2873>=b||2877==b||2908<=b&&2909>=b||2911<=b&&2913>=b||2949<=b&&2954>=b||2958<=b&&2960>=b||2962<=b&&2965>=b||2969<=b&&2970>=b||2972==b||2974<=b&&2975>=b||2979<=b&&2980>=b||2984<=b&&2986>=b||2990<=b&&2997>=b||2999<=b&&3001>=b||3077<=b&&3084>=b||3086<=b&&3088>=b||3090<= +b&&3112>=b||3114<=b&&3123>=b||3125<=b&&3129>=b||3168<=b&&3169>=b||3205<=b&&3212>=b||3214<=b&&3216>=b||3218<=b&&3240>=b||3242<=b&&3251>=b||3253<=b&&3257>=b||3294==b||3296<=b&&3297>=b||3333<=b&&3340>=b||3342<=b&&3344>=b||3346<=b&&3368>=b||3370<=b&&3385>=b||3424<=b&&3425>=b||3585<=b&&3630>=b||3632==b||3634<=b&&3635>=b||3648<=b&&3653>=b||3713<=b&&3714>=b||3716==b||3719<=b&&3720>=b||3722==b||3725==b||3732<=b&&3735>=b||3737<=b&&3743>=b||3745<=b&&3747>=b||3749==b||3751==b||3754<=b&&3755>=b||3757<=b&&3758>= +b||3760==b||3762<=b&&3763>=b||3773==b||3776<=b&&3780>=b||3904<=b&&3911>=b||3913<=b&&3945>=b||4256<=b&&4293>=b||4304<=b&&4342>=b||4352==b||4354<=b&&4355>=b||4357<=b&&4359>=b||4361==b||4363<=b&&4364>=b||4366<=b&&4370>=b||4412==b||4414==b||4416==b||4428==b||4430==b||4432==b||4436<=b&&4437>=b||4441==b||4447<=b&&4449>=b||4451==b||4453==b||4455==b||4457==b||4461<=b&&4462>=b||4466<=b&&4467>=b||4469==b||4510==b||4520==b||4523==b||4526<=b&&4527>=b||4535<=b&&4536>=b||4538==b||4540<=b&&4546>=b||4587==b||4592== +b||4601==b||7680<=b&&7835>=b||7840<=b&&7929>=b||7936<=b&&7957>=b||7960<=b&&7965>=b||7968<=b&&8005>=b||8008<=b&&8013>=b||8016<=b&&8023>=b||8025==b||8027==b||8029==b||8031<=b&&8061>=b||8064<=b&&8116>=b||8118<=b&&8124>=b||8126==b||8130<=b&&8132>=b||8134<=b&&8140>=b||8144<=b&&8147>=b||8150<=b&&8155>=b||8160<=b&&8172>=b||8178<=b&&8180>=b||8182<=b&&8188>=b||8486==b||8490<=b&&8491>=b||8494==b||8576<=b&&8578>=b||12353<=b&&12436>=b||12449<=b&&12538>=b||12549<=b&&12588>=b||44032<=b&&55203>=b||19968<=b&&40869>= +b||12295==b||12321<=b&&12329>=b},isNCNameChar:function(b){return 48<=b&&57>=b||1632<=b&&1641>=b||1776<=b&&1785>=b||2406<=b&&2415>=b||2534<=b&&2543>=b||2662<=b&&2671>=b||2790<=b&&2799>=b||2918<=b&&2927>=b||3047<=b&&3055>=b||3174<=b&&3183>=b||3302<=b&&3311>=b||3430<=b&&3439>=b||3664<=b&&3673>=b||3792<=b&&3801>=b||3872<=b&&3881>=b||46==b||45==b||95==b||fa.isLetter(b)||768<=b&&837>=b||864<=b&&865>=b||1155<=b&&1158>=b||1425<=b&&1441>=b||1443<=b&&1465>=b||1467<=b&&1469>=b||1471==b||1473<=b&&1474>=b||1476== +b||1611<=b&&1618>=b||1648==b||1750<=b&&1756>=b||1757<=b&&1759>=b||1760<=b&&1764>=b||1767<=b&&1768>=b||1770<=b&&1773>=b||2305<=b&&2307>=b||2364==b||2366<=b&&2380>=b||2381==b||2385<=b&&2388>=b||2402<=b&&2403>=b||2433<=b&&2435>=b||2492==b||2494==b||2495==b||2496<=b&&2500>=b||2503<=b&&2504>=b||2507<=b&&2509>=b||2519==b||2530<=b&&2531>=b||2562==b||2620==b||2622==b||2623==b||2624<=b&&2626>=b||2631<=b&&2632>=b||2635<=b&&2637>=b||2672<=b&&2673>=b||2689<=b&&2691>=b||2748==b||2750<=b&&2757>=b||2759<=b&&2761>= +b||2763<=b&&2765>=b||2817<=b&&2819>=b||2876==b||2878<=b&&2883>=b||2887<=b&&2888>=b||2891<=b&&2893>=b||2902<=b&&2903>=b||2946<=b&&2947>=b||3006<=b&&3010>=b||3014<=b&&3016>=b||3018<=b&&3021>=b||3031==b||3073<=b&&3075>=b||3134<=b&&3140>=b||3142<=b&&3144>=b||3146<=b&&3149>=b||3157<=b&&3158>=b||3202<=b&&3203>=b||3262<=b&&3268>=b||3270<=b&&3272>=b||3274<=b&&3277>=b||3285<=b&&3286>=b||3330<=b&&3331>=b||3390<=b&&3395>=b||3398<=b&&3400>=b||3402<=b&&3405>=b||3415==b||3633==b||3636<=b&&3642>=b||3655<=b&&3662>= +b||3761==b||3764<=b&&3769>=b||3771<=b&&3772>=b||3784<=b&&3789>=b||3864<=b&&3865>=b||3893==b||3895==b||3897==b||3902==b||3903==b||3953<=b&&3972>=b||3974<=b&&3979>=b||3984<=b&&3989>=b||3991==b||3993<=b&&4013>=b||4017<=b&&4023>=b||4025==b||8400<=b&&8412>=b||8417==b||12330<=b&&12335>=b||12441==b||12442==b||183==b||720==b||721==b||903==b||1600==b||3654==b||3782==b||12293==b||12337<=b&&12341>=b||12445<=b&&12446>=b||12540<=b&&12542>=b},coalesceText:function(b){for(b=b.firstChild;null!=b;b=b.nextSibling)if(3== +b.nodeType||4==b.nodeType){var R=b.nodeValue,ba=b;for(b=b.nextSibling;null!=b&&(3==b.nodeType||4==b.nodeType);){R+=b.nodeValue;var ra=b;b=b.nextSibling;ra.parentNode.removeChild(ra)}if(4==ba.nodeType)if(ra=ba.parentNode,null==ba.nextSibling)ra.removeChild(ba),ra.appendChild(ra.ownerDocument.createTextNode(R));else{var oa=ba.nextSibling;ra.removeChild(ba);ra.insertBefore(ra.ownerDocument.createTextNode(R),oa)}else ba.nodeValue=R;if(null==b)break}else 1==b.nodeType&&fa.coalesceText(b)},instance_of:function(b, +R){for(;null!=b;){if(b.constructor===R)return!0;if(b===Object)break;b=b.constructor.superclass}return!1},getElementById:function(b,R){if(1==b.nodeType&&(b.getAttribute("id")==R||b.getAttributeNS(null,"id")==R))return b;for(b=b.firstChild;null!=b;b=b.nextSibling){var ba=fa.getElementById(b,R);if(null!=ba)return ba}return null}},wa=function(){function b(R,ba,ra){var oa=Error,Da=oa.call;a:{var Fa=ba?": "+ba.toString():"";switch(R){case b.INVALID_EXPRESSION_ERR:Fa="Invalid expression"+Fa;break a;case b.TYPE_ERR:Fa= +"Type error"+Fa;break a}Fa=null}ra=Da.call(oa,this,Fa||ra);ra.code=R;ra.exception=ba;return ra}b.prototype=Object.create(Error.prototype);b.prototype.constructor=b;b.superclass=Error;b.prototype.toString=function(){return this.message};b.fromMessage=function(R,ba){return new b(null,ba,R)};b.INVALID_EXPRESSION_ERR=51;b.TYPE_ERR=52;return b}();ta.prototype={};ta.prototype.constructor=ta;ta.superclass=Object.prototype;ta.getOwnerDocument=function(b){return 9===b.nodeType?b:b.ownerDocument};ta.detectHtmlDom= +function(b){if(!b)return!1;b=ta.getOwnerDocument(b);try{return b.implementation.hasFeature("HTML","2.0")}catch(R){return!0}};ta.prototype.evaluate=function(b,R,ba){this.context.expressionContextNode=b;this.context.caseInsensitive=ta.detectHtmlDom(b);b=this.xpath.evaluate(this.context);return new ka(b,R)};c.prototype={};c.prototype.constructor=c;c.superclass=Object.prototype;c.prototype.getNamespace=function(b,R){return null==this.xpathNSResolver?null:this.xpathNSResolver.lookupNamespaceURI(b)};X.prototype= +{};X.prototype.constructor=X;X.superclass=Object.prototype;X.prototype.lookupNamespaceURI=function(b){return this.namespaceResolver.getNamespace(b,this.node)};ka.prototype={};ka.prototype.constructor=ka;ka.superclass=Object.prototype;ka.prototype.iterateNext=function(){if(this.resultType!=ka.UNORDERED_NODE_ITERATOR_TYPE&&this.resultType!=ka.ORDERED_NODE_ITERATOR_TYPE)throw new wa(wa.TYPE_ERR);return this.nodes[this.iteratorIndex++]};ka.prototype.snapshotItem=function(b){if(this.resultType!=ka.UNORDERED_NODE_SNAPSHOT_TYPE&& +this.resultType!=ka.ORDERED_NODE_SNAPSHOT_TYPE)throw new wa(wa.TYPE_ERR);return this.nodes[b]};ka.ANY_TYPE=0;ka.NUMBER_TYPE=1;ka.STRING_TYPE=2;ka.BOOLEAN_TYPE=3;ka.UNORDERED_NODE_ITERATOR_TYPE=4;ka.ORDERED_NODE_ITERATOR_TYPE=5;ka.UNORDERED_NODE_SNAPSHOT_TYPE=6;ka.ORDERED_NODE_SNAPSHOT_TYPE=7;ka.ANY_UNORDERED_NODE_TYPE=8;ka.FIRST_ORDERED_NODE_TYPE=9;try{var ya=!0;try{document.implementation&&document.implementation.hasFeature&&document.implementation.hasFeature("XPath",null)&&(ya=!1)}catch(b){}ya&& +ja(document,new f)}catch(b){}ja(u,new f);(function(){function b(Na){return{getNamespace:function(Za,bb){return Na(Za,bb)||ab.getNamespace(Za,bb)}}}function R(Na){return b(function(Za){return Na[Za]})}function ba(Na){if(null===Na||"undefined"===typeof Na||Na instanceof n||Na instanceof D||Na instanceof v||Na instanceof O)return Na;switch(typeof Na){case "string":return new n(Na);case "boolean":return new D(Na);case "number":return new v(Na)}var Za=new O;Za.addArray([].concat(Na));return Za}function ra(Na){return function(Za){var bb= +Array.prototype.slice.call(arguments,1).map(function($a){return $a.evaluate(Za)});bb=Na.apply(this,[].concat(Za,bb));return ba(bb)}}function oa(Na){return{getFunction:function(Za,bb){var $a=Na(Za,bb);return $a?ra($a):fb.getFunction(Za,bb)}}}function Da(Na){return oa(function(Za){return Na[Za]})}function Fa(Na){return{getVariable:function(Za,bb){Za=Na(Za,bb);return ba(Za)}}}function Oa(Na){if(Na){if("function"===typeof Na.getVariable)return Fa(Na.getVariable.bind(Na));if("function"===typeof Na)return Fa(Na); +if("object"===typeof Na)return Fa(function(Za){return Na[Za]})}return mb}var Pa=new f,ab=new za,fb=new ua,mb=new xa,rb={evaluate:function(Na){var Za=this.expression,bb=new pa;if(Na){var $a=($a=Na.namespaces)&&"function"===typeof $a.getNamespace?b($a.getNamespace.bind($a)):"function"===typeof $a?b($a):"object"===typeof $a?R($a):ab;bb.namespaceResolver=$a;$a=($a=Na.functions)&&"function"===typeof $a.getFunction?oa($a.getFunction.bind($a)):"function"===typeof $a?oa($a):"object"===typeof $a?Da($a):fb; +bb.functionResolver=$a;bb.variableResolver=Oa(Na.variables);bb.expressionContextNode=Na.node;"allowAnyNamespaceForNoPrefix"in Na&&(bb.allowAnyNamespaceForNoPrefix=Na.allowAnyNamespaceForNoPrefix);"isHtml"in Na&&(bb.isHtml=Na.isHtml)}else bb.namespaceResolver=ab;return Za.evaluate(bb)},evaluateNumber:function(Na){return this.evaluate(Na).numberValue()},evaluateString:function(Na){return this.evaluate(Na).stringValue()},evaluateBoolean:function(Na){return this.evaluate(Na).booleanValue()},evaluateNodeSet:function(Na){return this.evaluate(Na).nodeset()}, +select:function(Na){return this.evaluateNodeSet(Na).toArray()},select1:function(Na){return this.select(Na)[0]}};u.parse=function(Na){Na=Pa.parse(Na);return Object.create(rb,{expression:{value:Na}})}})();q(u,{XPath:k,XPathParser:f,XPathResult:ka,Step:ea,PathExpr:M,NodeTest:ia,LocationPath:ca,OrOperation:W,AndOperation:F,BarOperation:G,EqualsOperation:H,NotEqualOperation:x,LessThanOperation:z,GreaterThanOperation:m,LessThanOrEqualOperation:P,GreaterThanOrEqualOperation:l,PlusOperation:e,MinusOperation:w, +MultiplyOperation:J,DivOperation:h,ModOperation:y,UnaryMinusOperation:t,FunctionCall:r,VariableReference:na,XPathContext:pa,XNodeSet:O,XBoolean:D,XString:n,XNumber:v,NamespaceResolver:za,FunctionResolver:ua,VariableResolver:xa,Utilities:fa});u.select=function(b,R,ba){return u.selectWithResolver(b,R,null,ba)};u.useNamespaces=function(b){var R={mappings:b||{},lookupNamespaceURI:function(ba){return this.mappings[ba]}};return function(ba,ra,oa){return u.selectWithResolver(ba,ra,R,oa)}};u.selectWithResolver= +function(b,R,ba,ra){b=(new ta(b,ba,new f)).evaluate(R,ka.ANY_TYPE,null);b.resultType==ka.STRING_TYPE?b=b.stringValue:b.resultType==ka.NUMBER_TYPE?b=b.numberValue:b.resultType==ka.BOOLEAN_TYPE?b=b.booleanValue:(b=b.nodes,ra&&(b=b[0]));return b};u.select1=function(b,R){return u.select(b,R,!0)}})(E)},function(Q,E,C){function u(f,k){"string"===typeof f&&(f=q.util.createBuffer(f));if(q.util.isArray(f)&&4this.blockSize<<2)return!1;f.truncate(k);return!0};Q.cbc=function(f){f=f||{};this.name="CBC";this.cipher=f.cipher;this.blockSize=f.blockSize||16;this._ints=this.blockSize/4;this._inBlock=Array(this._ints); +this._outBlock=Array(this._ints)};Q.cbc.prototype.start=function(f){if(null===f.iv){if(!this._prev)throw Error("Invalid IV parameter.");this._iv=this._prev.slice(0)}else if("iv"in f)this._iv=u(f.iv,this.blockSize),this._prev=this._iv.slice(0);else throw Error("Invalid IV parameter.");};Q.cbc.prototype.encrypt=function(f,k,d){if(f.length()this.blockSize<<2)return!1;f.truncate(k);return!0};Q.cfb=function(f){f=f||{};this.name="CFB";this.cipher=f.cipher;this.blockSize=f.blockSize||16;this._ints=this.blockSize/4;this._inBlock=null;this._outBlock=Array(this._ints);this._partialBlock=Array(this._ints);this._partialOutput=q.util.createBuffer();this._partialBytes=0};Q.cfb.prototype.start=function(f){if(!("iv"in f))throw Error("Invalid IV parameter."); +this._iv=u(f.iv,this.blockSize);this._inBlock=this._iv.slice(0);this._partialBytes=0};Q.cfb.prototype.encrypt=function(f,k,d){var g=f.length();if(0===g)return!0;this.cipher.encrypt(this._inBlock,this._outBlock);if(0===this._partialBytes&&g>=this.blockSize)for(var t=0;t=this.blockSize)for(var t=0;t=this.blockSize)for(var t=0;t=this.blockSize)for(var t=0;t=this.blockSize){for(var t=0;t=A||d){d?(t=g%this.blockSize,this._cipherLength+=t,this._partialOutput.truncate(this.blockSize-t)):this._cipherLength+=this.blockSize;for(t=0;tg;++g)f[g/32|0]&1<<31-g%32&&(d[0]^=k[0],d[1]^=k[1],d[2]^=k[2],d[3]^=k[3]),this.pow(k,k);return d};Q.gcm.prototype.pow=function(f,k){for(var d=f[3]&1,g=3;0< +g;--g)k[g]=f[g]>>>1|(f[g-1]&1)<<31;k[0]=f[0]>>>1;d&&(k[0]^=this._R)};Q.gcm.prototype.tableMultiply=function(f){for(var k=[0,0,0,0],d=0;32>d;++d){var g=this._m[d][f[d/8|0]>>>4*(7-d%8)&15];k[0]^=g[0];k[1]^=g[1];k[2]^=g[2];k[3]^=g[3]}return k};Q.gcm.prototype.ghash=function(f,k,d){k[0]^=d[0];k[1]^=d[1];k[2]^=d[2];k[3]^=d[3];return this.tableMultiply(k)};Q.gcm.prototype.generateHashTable=function(f,k){var d=8/k,g=4*d;d*=16;for(var t=Array(d),A=0;A>>1,g=Array(k);g[d]=f.slice(0);for(var t=d>>>1;0>=1;for(t=2;t>1,O=N+(r.length&1),K=r.substr(0,O);O=r.substr(N,O);r=u.util.createBuffer();N=u.hmac.create();v=n+v;var pa=Math.ceil(D/16);n=Math.ceil(D/20);N.start("MD5",K);K=u.util.createBuffer();r.putBytes(v);for(var xa=0;xav)r.error(r,{message:U?"Invalid ServerHello message. Message too short.":"Invalid ClientHello message. Message too short.",send:!0,alert:{level:d.Alert.Level.fatal,description:d.Alert.Description.illegal_parameter}}); +else{n=n.fragment;var N=n.length();D={version:{major:n.getByte(),minor:n.getByte()},random:u.util.createBuffer(n.getBytes(32)),session_id:f(n,1),extensions:[]};U?(D.cipher_suite=n.getBytes(2),D.compression_method=n.getByte()):(D.cipher_suites=f(n,2),D.compression_methods=f(n,1));N=v-(N-n.length());if(0n.version.minor)v=null,D="";0===D.length&&(D=u.random.getBytes(32));r.session.id=D;r.session.clientHelloVersion=n.version;r.session.sp={};if(v)r.version=r.session.version=v.version,r.session.sp=v.sp;else{for(D=1;Dv)return r.error(r,{message:"Invalid Certificate message. Message too short.",send:!0,alert:{level:d.Alert.Level.fatal,description:d.Alert.Description.illegal_parameter}});v=f(n.fragment,3);n=[];try{for(;0v)return r.error(r,{message:"Invalid key parameters. Only RSA is supported.",send:!0,alert:{level:d.Alert.Level.fatal,description:d.Alert.Description.unsupported_certificate}});n=f(n.fragment,2).getBytes();v=null;if(r.getPrivateKey)try{v=r.getPrivateKey(r, +r.session.serverCertificate),v=u.pki.privateKeyFromPem(v)}catch(N){r.error(r,{message:"Could not get private key.",cause:N,send:!0,alert:{level:d.Alert.Level.fatal,description:d.Alert.Description.internal_error}})}if(null===v)return r.error(r,{message:"No private key set.",send:!0,alert:{level:d.Alert.Level.fatal,description:d.Alert.Description.internal_error}});try{var D=r.session.sp;D.pre_master_secret=v.decrypt(n);var U=r.session.clientHelloVersion;if(U.major!==D.pre_master_secret.charCodeAt(0)|| +U.minor!==D.pre_master_secret.charCodeAt(1))throw Error("TLS version rollback attack detected.");}catch(N){D.pre_master_secret=u.random.getBytes(48)}r.expect=e;null!==r.session.clientCertificate&&(r.expect=l);r.process()};d.handleCertificateRequest=function(r,n,v){if(3>v)return r.error(r,{message:"Invalid CertificateRequest. Message too short.",send:!0,alert:{level:d.Alert.Level.fatal,description:d.Alert.Description.illegal_parameter}});n=n.fragment;n={certificate_types:f(n,1),certificate_authorities:f(n, +2)};r.session.certificateRequest=n;r.expect=W;r.process()};d.handleCertificateVerify=function(r,n,v){if(2>v)return r.error(r,{message:"Invalid CertificateVerify. Message too short.",send:!0,alert:{level:d.Alert.Level.fatal,description:d.Alert.Description.illegal_parameter}});v=n.fragment;v.read-=4;n=v.bytes();v.read+=4;v=f(v,2).getBytes();var D=u.util.createBuffer();D.putBuffer(r.session.md5.digest());D.putBuffer(r.session.sha1.digest());D=D.getBytes();try{if(!r.session.clientCertificate.publicKey.verify(D, +v,"NONE"))throw Error("CertificateVerify signature does not match.");r.session.md5.update(n);r.session.sha1.update(n)}catch(U){return r.error(r,{message:"Bad signature in CertificateVerify.",send:!0,alert:{level:d.Alert.Level.fatal,description:d.Alert.Description.handshake_failure}})}r.expect=e;r.process()};d.handleServerHelloDone=function(r,n,v){if(0v.length())return r.fragmented=n,n.fragment=u.util.createBuffer(),v.read-=4,r.process();r.fragmented=null;v.read-=4;var N=v.bytes(U+4);v.read+=4;D in ca[r.entity][r.expect]?(r.entity!==d.ConnectionEnd.server|| +r.open||r.fail||(r.handshaking=!0,r.session={version:null,extensions:{server_name:{serverNameList:[]}},cipherSuite:null,compressionMethod:null,serverCertificate:null,clientCertificate:null,md5:u.md.md5.create(),sha1:u.md.sha1.create()}),D!==d.HandshakeType.hello_request&&D!==d.HandshakeType.certificate_verify&&D!==d.HandshakeType.finished&&(r.session.md5.update(N),r.session.sha1.update(N)),ca[r.entity][r.expect][D](r,n,U)):d.handleUnexpected(r,n)};d.handleApplicationData=function(r,n){r.data.putBuffer(n.fragment); +r.dataReady(r);r.process()};d.handleHeartbeat=function(r,n){var v=n.fragment;n=v.getByte();var D=v.getInt16();v=v.getBytes(D);if(n===d.HeartbeatMessageType.heartbeat_request){if(r.handshaking||D>v.length)return r.process();d.queue(r,d.createRecord(r,{type:d.ContentType.heartbeat,data:d.createHeartbeat(d.HeartbeatMessageType.heartbeat_response,v)}));d.flush(r)}else if(n===d.HeartbeatMessageType.heartbeat_response){if(v!==r.expectedHeartbeatPayload)return r.process();r.heartbeatReceived&&r.heartbeatReceived(r, +u.util.createBuffer(v))}r.process()};var g=1,t=2,A=3,W=4,F=5,H=6,x=7,z=8,m=1,P=2,l=3,e=4,w=5,J=6;E=d.handleUnexpected;C=d.handleChangeCipherSpec;var h=d.handleAlert,y=d.handleHandshake,G=d.handleApplicationData,M=d.handleHeartbeat,S=[];S[d.ConnectionEnd.client]=[[E,h,y,E,M],[E,h,y,E,M],[E,h,y,E,M],[E,h,y,E,M],[E,h,y,E,M],[C,h,E,E,M],[E,h,y,E,M],[E,h,y,G,M],[E,h,y,E,M]];S[d.ConnectionEnd.server]=[[E,h,y,E,M],[E,h,y,E,M],[E,h,y,E,M],[E,h,y,E,M],[C,h,E,E,M],[E,h,y,E,M],[E,h,y,G,M],[E,h,y,E,M]];C=d.handleHelloRequest; +h=d.handleCertificate;y=d.handleServerKeyExchange;G=d.handleCertificateRequest;M=d.handleServerHelloDone;var Z=d.handleFinished,ca=[];ca[d.ConnectionEnd.client]=[[E,E,d.handleServerHello,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E],[C,E,E,E,E,E,E,E,E,E,E,h,y,G,M,E,E,E,E,E,E],[C,E,E,E,E,E,E,E,E,E,E,E,y,G,M,E,E,E,E,E,E],[C,E,E,E,E,E,E,E,E,E,E,E,E,G,M,E,E,E,E,E,E],[C,E,E,E,E,E,E,E,E,E,E,E,E,E,M,E,E,E,E,E,E],[C,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E],[C,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,Z],[C,E,E,E,E,E, +E,E,E,E,E,E,E,E,E,E,E,E,E,E,E],[C,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E]];ca[d.ConnectionEnd.server]=[[E,d.handleClientHello,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E],[E,E,E,E,E,E,E,E,E,E,E,h,E,E,E,E,E,E,E,E,E],[E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,d.handleClientKeyExchange,E,E,E,E],[E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,d.handleCertificateVerify,E,E,E,E,E],[E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E],[E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,Z],[E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E],[E,E,E,E,E,E,E,E,E,E,E, +E,E,E,E,E,E,E,E,E,E]];d.generateKeys=function(r,n){var v=n.client_random+n.server_random;r.session.resuming||(n.master_secret=I(n.pre_master_secret,"master secret",v,48).bytes(),n.pre_master_secret=null);v=n.server_random+n.client_random;var D=2*n.mac_key_length+2*n.enc_key_length;(r=r.version.major===d.Versions.TLS_1_0.major&&r.version.minor===d.Versions.TLS_1_0.minor)&&(D+=2*n.fixed_iv_length);v=I(n.master_secret,"key expansion",v,D);D={client_write_MAC_key:v.getBytes(n.mac_key_length),server_write_MAC_key:v.getBytes(n.mac_key_length), +client_write_key:v.getBytes(n.enc_key_length),server_write_key:v.getBytes(n.enc_key_length)};r&&(D.client_write_IV=v.getBytes(n.fixed_iv_length),D.server_write_IV=v.getBytes(n.fixed_iv_length));return D};d.createConnectionState=function(r){var n=r.entity===d.ConnectionEnd.client,v=function(){var U={sequenceNumber:[0,0],macKey:null,macLength:0,macFunction:null,cipherState:null,cipherFunction:function(N){return!0},compressionState:null,compressFunction:function(N){return!0},updateSequenceNumber:function(){4294967295=== +U.sequenceNumber[1]?(U.sequenceNumber[1]=0,++U.sequenceNumber[0]):++U.sequenceNumber[1]}};return U},D={read:v(),write:v()};D.read.update=function(U,N){D.read.cipherFunction(N,D.read)?D.read.compressFunction(U,N,D.read)||U.error(U,{message:"Could not decompress record.",send:!0,alert:{level:d.Alert.Level.fatal,description:d.Alert.Description.decompression_failure}}):U.error(U,{message:"Could not decrypt record or bad MAC.",send:!0,alert:{level:d.Alert.Level.fatal,description:d.Alert.Description.bad_record_mac}}); +return!U.fail};D.write.update=function(U,N){D.write.compressFunction(U,N,D.write)?D.write.cipherFunction(N,D.write)||U.error(U,{message:"Could not encrypt record.",send:!1,alert:{level:d.Alert.Level.fatal,description:d.Alert.Description.internal_error}}):U.error(U,{message:"Could not compress record.",send:!1,alert:{level:d.Alert.Level.fatal,description:d.Alert.Description.internal_error}});return!U.fail};if(r.session)switch(v=r.session.sp,r.session.cipherSuite.initSecurityParameters(v),v.keys=d.generateKeys(r, +v),D.read.macKey=n?v.keys.server_write_MAC_key:v.keys.client_write_MAC_key,D.write.macKey=n?v.keys.client_write_MAC_key:v.keys.server_write_MAC_key,r.session.cipherSuite.initConnectionState(D,r,v),v.compression_algorithm){case d.CompressionMethod.none:break;case d.CompressionMethod.deflate:D.read.compressFunction=q;D.write.compressFunction=V;break;default:throw Error("Unsupported compression algorithm.");}return D};d.createRandom=function(){var r=new Date;r=+r+6E4*r.getTimezoneOffset();var n=u.util.createBuffer(); +n.putInt32(r);n.putBytes(u.random.getBytes(28));return n};d.createRecord=function(r,n){return n.data?{type:n.type,version:{major:r.version.major,minor:r.version.minor},length:n.data.length(),fragment:n.data}:null};d.createAlert=function(r,n){var v=u.util.createBuffer();v.putByte(n.level);v.putByte(n.description);return d.createRecord(r,{type:d.ContentType.alert,data:v})};d.createClientHello=function(r){r.session.clientHelloVersion={major:r.version.major,minor:r.version.minor};for(var n=u.util.createBuffer(), +v=0;vd.MaxFragment;)v.push(d.createRecord(r,{type:n.type,data:u.util.createBuffer(D.slice(0,d.MaxFragment))})),D=D.slice(d.MaxFragment);0pa?K=5-pa:(N.record={type:O.getByte(),version:{major:O.getByte(),minor:O.getByte()},length:O.getInt16(),fragment:u.util.createBuffer(), +ready:!1},(O=N.record.version.major===N.version.major)&&N.session&&N.session.version&&(O=N.record.version.minor===N.version.minor),O||N.error(N,{message:"Incompatible TLS version.",send:!0,alert:{level:d.Alert.Level.fatal,description:d.Alert.Description.protocol_version}}))}if(!N.fail&&null!==N.record&&!N.record.ready){K=N;O=0;pa=K.input;var xa=pa.length();xa>=8,na+=Z.at(e)+ia.at(e),ia.setAt(e,na&255);ea.putBuffer(ia)}y=ea;h.putBuffer(S)}h.truncate(h.length()-m);return h}; +d.pbe.getCipher=function(F,H,x){switch(F){case d.oids.pkcs5PBES2:return d.pbe.getCipherForPBES2(F,H,x);case d.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:case d.oids["pbewithSHAAnd40BitRC2-CBC"]:return d.pbe.getCipherForPKCS12PBE(F,H,x);default:throw H=Error("Cannot read encrypted PBE data block. Unsupported OID."),H.oid=F,H.supportedOids=["pkcs5PBES2","pbeWithSHAAnd3-KeyTripleDES-CBC","pbewithSHAAnd40BitRC2-CBC"],H;}};d.pbe.getCipherForPBES2=function(F,H,x){var z={};F=[];if(!k.validate(H,A,z,F)){var m= +Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");m.errors=F;throw m;}F=k.derToOid(z.kdfOid);if(F!==d.oids.pkcs5PBKDF2)throw m=Error("Cannot read encrypted private key. Unsupported key derivation function OID."),m.oid=F,m.supportedOids=["pkcs5PBKDF2"],m;F=k.derToOid(z.encOid);if(F!==d.oids["aes128-CBC"]&&F!==d.oids["aes192-CBC"]&&F!==d.oids["aes256-CBC"]&&F!==d.oids["des-EDE3-CBC"]&&F!==d.oids.desCBC)throw m=Error("Cannot read encrypted private key. Unsupported encryption scheme OID."), +m.oid=F,m.supportedOids=["aes128-CBC","aes192-CBC","aes256-CBC","des-EDE3-CBC","desCBC"],m;H=z.kdfSalt;var P=q.util.createBuffer(z.kdfIterationCount);P=P.getInt(P.length()<<3);switch(d.oids[F]){case "aes128-CBC":var l=16;m=q.aes.createDecryptionCipher;break;case "aes192-CBC":l=24;m=q.aes.createDecryptionCipher;break;case "aes256-CBC":l=32;m=q.aes.createDecryptionCipher;break;case "des-EDE3-CBC":l=24;m=q.des.createDecryptionCipher;break;case "desCBC":l=8,m=q.des.createDecryptionCipher}F=I(z.prfOid); +x=q.pkcs5.pbkdf2(x,H,P,l,F);z=z.encIv;m=m(x);m.start(z);return m};d.pbe.getCipherForPKCS12PBE=function(F,H,x){var z={},m=[];if(!k.validate(H,W,z,m))throw x=Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo."),x.errors=m,x;m=q.util.createBuffer(z.salt);H=q.util.createBuffer(z.iterations);H=H.getInt(H.length()<<3);switch(F){case d.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:var P=24;var l=8;F=q.des.startDecrypting;break;case d.oids["pbewithSHAAnd40BitRC2-CBC"]:P= +5;l=8;F=function(e,w){e=q.rc2.createDecryptionCipher(e,40);e.start(w,null);return e};break;default:throw x=Error("Cannot read PKCS #12 PBE data block. Unsupported OID."),x.oid=F,x;}z=I(z.prfOid);P=d.pbe.generatePkcs12Key(x,m,1,H,P,z);z.start();x=d.pbe.generatePkcs12Key(x,m,2,H,l,z);return F(P,x)};d.pbe.opensslDeriveBytes=function(F,H,x,z){if("undefined"===typeof z||null===z){if(!("md5"in q.md))throw Error('"md5" hash algorithm unavailable.');z=q.md.md5.create()}null===H&&(H="");for(var m=[u(z,F+H)], +P=16,l=1;PH;++H)d[H]=g.getInt32();for(;64>H;++H)t=d[H-2],t=(t>>>17|t<<15)^(t>>>19|t<<13)^t>>>10,A=d[H-15],A=(A>>>7|A<<25)^(A>>>18|A<<14)^A>>>3,d[H]=t+d[H-7]+A+d[H-16]|0;x=k.h0;z=k.h1;m=k.h2;P=k.h3;l=k.h4;e=k.h5;w=k.h6;J=k.h7;for(H=0;64>H;++H)t=(l>>>6|l<<26)^(l>>>11|l<<21)^(l>>>25|l<<7),W=w^l&(e^w),A=(x>>>2|x<<30)^(x>>>13|x<<19)^(x>>> +22|x<<10),F=x&z|m&(x^z),t=J+t+W+f[H]+d[H],A+=F,J=w,w=e,e=l,l=P+t>>>0,P=m,m=z,z=x,x=t+A>>>0;k.h0=k.h0+x|0;k.h1=k.h1+z|0;k.h2=k.h2+m|0;k.h3=k.h3+P|0;k.h4=k.h4+l|0;k.h5=k.h5+e|0;k.h6=k.h6+w|0;k.h7=k.h7+J|0;h-=64}}var I=C(5);C(16);C(7);Q=Q.exports=I.sha256=I.sha256||{};I.md.sha256=I.md.algorithms.sha256=Q;Q.create=function(){q||(V=String.fromCharCode(128),V+=I.util.fillString(String.fromCharCode(0),64),f=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080, +310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779, +1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],q=!0);var k=null,d=I.util.createBuffer(),g=Array(64),t={algorithm:"sha256",blockLength:64,digestLength:32,messageLength:0,fullMessageLength:null,messageLengthSize:8,start:function(){t.messageLength=0;t.fullMessageLength=t.messageLength64=[];for(var A=t.messageLengthSize/4,W=0;W>>0,W>>>0];for(var F=t.fullMessageLength.length-1;0<=F;--F)t.fullMessageLength[F]+=W[1],W[1]=W[0]+(t.fullMessageLength[F]/4294967296>>>0),t.fullMessageLength[F]>>>=0,W[0]=W[1]/4294967296>>>0;d.putBytes(A);u(k,g,d);(2048>>0,H+=F,A.putInt32(H>>>0),H=W>>>0;A.putInt32(H);W={h0:k.h0,h1:k.h1,h2:k.h2,h3:k.h3,h4:k.h4,h5:k.h5,h6:k.h6,h7:k.h7};u(W,g,A);A=I.util.createBuffer();A.putInt32(W.h0);A.putInt32(W.h1);A.putInt32(W.h2);A.putInt32(W.h3);A.putInt32(W.h4);A.putInt32(W.h5);A.putInt32(W.h6);A.putInt32(W.h7); +return A};return t};var V=null,q=!1,f=null},function(Q,E,C){(function(u){var I=C(5);C(7);var V=null;!I.util.isNodejs||I.options.usePureJavaScript||u.versions["node-webkit"]||(V=C(40));(Q.exports=I.prng=I.prng||{}).create=function(q){function f(W){if(32<=g.pools[0].messageLength)return k(),W();g.seedFile(32-g.pools[0].messageLength<<5,function(F,H){if(F)return W(F);g.collect(H);k();W()})}function k(){g.reseeds=4294967295===g.reseeds?0:g.reseeds+1;var W=g.plugin.md.create();W.update(g.keyBytes);for(var F= +1,H=0;32>H;++H)0===g.reseeds%F&&(W.update(g.pools[H].digest().getBytes()),g.pools[H].start()),F<<=1;g.keyBytes=W.digest().getBytes();W.start();W.update(g.keyBytes);W=W.digest().getBytes();g.key=g.plugin.formatKey(g.keyBytes);g.seed=g.plugin.formatSeed(W);g.generated=0}function d(W){var F=null,H=I.util.globalScope,x=H.crypto||H.msCrypto;x&&x.getRandomValues&&(F=function(P){return x.getRandomValues(P)});H=I.util.createBuffer();if(F)for(;H.length()>16),z+=(F&32767)<<16,z+=F>>15,z=(z&2147483647)+(z>>31),F=z&4294967295,z=0;3>z;++z)m=F>>>(z<<3),m^=Math.floor(256*Math.random()),H.putByte(String.fromCharCode(m&255));return H.getBytes(W)}var g={plugin:q,key:null,seed:null, +time:null,reseeds:0,generated:0,keyBytes:""};q=q.md;for(var t=Array(32),A=0;32>A;++A)t[A]=q.create();g.pools=t;g.pool=0;g.generate=function(W,F){function H(e){if(e)return F(e);if(l.length()>=W)return F(null,l.getBytes(W));1048575>x&255);g.collect(H)};g.registerWorker=function(W){W===self?g.seedFile= +function(F,H){function x(z){z=z.data;z.forge&&z.forge.prng&&(self.removeEventListener("message",x),H(z.forge.prng.err,z.forge.prng.bytes))}self.addEventListener("message",x);self.postMessage({forge:{prng:{needed:F}}})}:W.addEventListener("message",function(F){F=F.data;F.forge&&F.forge.prng&&g.seedFile(F.forge.prng.needed,function(H,x){W.postMessage({forge:{prng:{err:H,bytes:x}}})})})};return g}}).call(this,C(32))},function(Q,E,C){var u=C(5);C(7);var I=[217,120,249,196,25,221,181,237,40,233,253,121, +74,160,216,157,198,126,55,131,43,118,83,142,98,76,100,136,68,139,251,162,23,154,89,245,135,179,79,19,97,69,109,141,9,129,125,50,189,143,64,235,134,183,123,11,240,149,33,34,92,107,78,130,84,214,101,147,206,96,178,28,115,86,192,20,167,140,241,220,18,117,202,31,59,190,228,209,66,61,212,48,163,60,182,38,111,191,14,218,70,105,7,87,39,242,29,155,188,148,67,3,248,17,199,246,144,239,62,231,6,195,213,47,200,102,30,215,8,232,234,222,128,82,238,247,132,170,114,172,53,77,106,42,150,26,210,113,90,21,73,116,75, +159,208,94,4,24,164,236,194,224,65,110,15,81,203,204,36,145,175,80,161,244,112,57,153,124,58,133,35,184,180,122,252,2,54,91,37,85,151,49,45,93,250,152,227,138,146,174,5,223,41,16,103,108,186,201,211,0,230,207,225,158,168,44,99,22,1,63,88,226,137,169,13,56,52,27,171,51,255,176,187,72,12,95,185,177,205,46,197,243,219,71,229,165,156,119,10,166,32,104,254,127,193,173],V=[1,2,3,5];Q.exports=u.rc2=u.rc2||{};u.rc2.expandKey=function(f,k){"string"===typeof f&&(f=u.util.createBuffer(f));k=k||128;var d=f;f= +f.length();var g=k;k=Math.ceil(g/8);g=255>>(g&7);var t;for(t=f;128>t;t++)d.putByte(I[d.at(t-1)+d.at(t-f)&255]);d.setAt(128-k,I[d.at(128-k)&g]);for(t=127-k;0<=t;t--)d.setAt(t,I[d.at(t+1)^d.at(t+k)]);return d};var q=function(f,k,d){var g=!1,t=null,A=null,W=null,F,H,x=[];f=u.rc2.expandKey(f,k);for(F=0;64>F;F++)x.push(f.getInt16Le());if(d){var z=function(l){for(F=0;4>F;F++){l[F]+=x[H]+(l[(F+3)%4]&l[(F+2)%4])+(~l[(F+3)%4]&l[(F+1)%4]);var e=l[F],w=V[F];l[F]=e<>16-w;H++}};var m=function(l){for(F= +0;4>F;F++)l[F]+=x[l[(F+3)%4]&63]}}else z=function(l){for(F=3;0<=F;F--){var e=l[F],w=V[F];l[F]=(e&65535)>>w|e<<16-w&65535;l[F]-=x[H]+(l[(F+3)%4]&l[(F+2)%4])+(~l[(F+3)%4]&l[(F+1)%4]);H--}},m=function(l){for(F=3;0<=F;F--)l[F]-=x[l[(F+3)%4]&63]};var P=null;return P={start:function(l,e){l&&"string"===typeof l&&(l=u.util.createBuffer(l));g=!1;t=u.util.createBuffer();A=e||new u.util.createBuffer;W=l;P.output=A},update:function(l){for(g||t.putBuffer(l);8<=t.length();){l=[[5,z],[1,m],[6,z],[1,m],[5,z]];var e= +[];for(F=0;4>F;F++){var w=t.getInt16Le();null!==W&&(d?w^=W.getInt16Le():W.putInt16Le(w));e.push(w&65535)}H=d?0:63;for(w=0;wF;F++)null!==W&&(d?W.putInt16Le(e[F]):e[F]^=W.getInt16Le()),A.putInt16Le(e[F])}},finish:function(l){var e=!0;if(d)if(l)e=l(8,t,!d);else{var w=8===t.length()?8:8-t.length();t.fillWithByte(w,w)}e&&(g=!0,P.update());!d&&(e=0===t.length())&&(l?e=l(8,A,!d):(l=A.length(),w=A.at(l-1),w>l?e=!1:A.truncate(w)));return e}}};u.rc2.startEncrypting= +function(f,k,d){f=u.rc2.createEncryptionCipher(f,128);f.start(k,d);return f};u.rc2.createEncryptionCipher=function(f,k){return q(f,k,!0)};u.rc2.startDecrypting=function(f,k,d){f=u.rc2.createDecryptionCipher(f,128);f.start(k,d);return f};u.rc2.createDecryptionCipher=function(f,k){return q(f,k,!1)}},function(Q,E,C){function u(V,q,f){f||(f=I.md.sha1.create());for(var k="",d=Math.ceil(q/f.digestLength),g=0;g>24&255,g>>16&255,g>>8&255,g&255);f.start();f.update(V+t); +k+=f.digest().getBytes()}return k.substring(0,q)}var I=C(5);C(7);C(13);C(26);Q=Q.exports=I.pkcs1=I.pkcs1||{};Q.encode_rsa_oaep=function(V,q,f,k,d){if("string"===typeof f){var g=f;var t=k||void 0;var A=d||void 0}else if(f&&(g=f.label||void 0,t=f.seed||void 0,A=f.md||void 0,f.mgf1&&f.mgf1.md))var W=f.mgf1.md;A?A.start():A=I.md.sha1.create();W||(W=A);V=Math.ceil(V.n.bitLength()/8);f=V-2*A.digestLength-2;if(q.length>f)throw W=Error("RSAES-OAEP input message length is too long."),W.length=q.length,W.maxLength= +f,W;g||(g="");A.update(g,"raw");g=A.digest();k="";f-=q.length;for(d=0;d=P?27:150>=P?18:200>=P?15:250>=P?12:300>=P?9:350>=P?8:400>=P?7:500>=P?6:600>=P?5:800>=P?4:1250>=P?3:2;"millerRabinTests"in x&&(P=x.millerRabinTests);var l=10;"maxBlockTime"in x&&(l=x.maxBlockTime);q(m,F,H,0,P,l,z)}function q(F,H,x,z,m,P,l){var e=+new Date;do{F.bitLength()>H&&(F=k(H,x));if(F.isProbablePrime(m))return l(null,F);F.dAddOffset(t[z++%8],0)}while(0>P||+new Date-eF&&(P=k(F,H));ca=P.toString(16);Z.target.postMessage({hex:ca,workLoad:e});P.dAddOffset(w,0)}}l=Math.max(1,l);for(var y=[],G=0;GD;++D)t[D][0]=A.getInt32()>>>0,t[D][1]=A.getInt32()>>>0;for(;80>D;++D)z=t[D-2],e=z[0],z=z[1],W=((e>>>19|z<<13)^(z>>>29|e<<3)^e>>>6)>>>0,F=((e<<13|z>>>19)^(z<<3|e>>>29)^(e<< +26|z>>>6))>>>0,z=t[D-15],e=z[0],z=z[1],H=((e>>>1|z<<31)^(e>>>8|z<<24)^e>>>7)>>>0,x=((e<<31|z>>>1)^(e<<24|z>>>8)^(e<<25|z>>>7))>>>0,e=t[D-7],w=t[D-16],z=F+e[1]+x+w[1],t[D][0]=W+e[0]+H+w[0]+(z/4294967296>>>0)>>>0,t[D][1]=z>>>0;e=g[0][0];w=g[0][1];J=g[1][0];h=g[1][1];y=g[2][0];G=g[2][1];M=g[3][0];S=g[3][1];Z=g[4][0];ca=g[4][1];ea=g[5][0];ia=g[5][1];na=g[6][0];r=g[6][1];n=g[7][0];v=g[7][1];for(D=0;80>D;++D)W=((Z>>>14|ca<<18)^(Z>>>18|ca<<14)^(ca>>>9|Z<<23))>>>0,z=((Z<<18|ca>>>14)^(Z<<14|ca>>>18)^(ca<< +23|Z>>>9))>>>0,F=(na^Z&(ea^na))>>>0,m=(r^ca&(ia^r))>>>0,H=((e>>>28|w<<4)^(w>>>2|e<<30)^(w>>>7|e<<25))>>>0,x=((e<<4|w>>>28)^(w<<30|e>>>2)^(w<<25|e>>>7))>>>0,P=(e&J|y&(e^J))>>>0,l=(w&h|G&(w^h))>>>0,z=v+z+m+k[D][1]+t[D][1],W=n+W+F+k[D][0]+t[D][0]+(z/4294967296>>>0)>>>0,F=z>>>0,z=x+l,H=H+P+(z/4294967296>>>0)>>>0,x=z>>>0,n=na,v=r,na=ea,r=ia,ea=Z,ia=ca,z=S+F,Z=M+W+(z/4294967296>>>0)>>>0,ca=z>>>0,M=y,S=G,y=J,G=h,J=e,h=w,z=F+x,e=W+H+(z/4294967296>>>0)>>>0,w=z>>>0;z=g[0][1]+w;g[0][0]=g[0][0]+e+(z/4294967296>>> +0)>>>0;g[0][1]=z>>>0;z=g[1][1]+h;g[1][0]=g[1][0]+J+(z/4294967296>>>0)>>>0;g[1][1]=z>>>0;z=g[2][1]+G;g[2][0]=g[2][0]+y+(z/4294967296>>>0)>>>0;g[2][1]=z>>>0;z=g[3][1]+S;g[3][0]=g[3][0]+M+(z/4294967296>>>0)>>>0;g[3][1]=z>>>0;z=g[4][1]+ca;g[4][0]=g[4][0]+Z+(z/4294967296>>>0)>>>0;g[4][1]=z>>>0;z=g[5][1]+ia;g[5][0]=g[5][0]+ea+(z/4294967296>>>0)>>>0;g[5][1]=z>>>0;z=g[6][1]+r;g[6][0]=g[6][0]+na+(z/4294967296>>>0)>>>0;g[6][1]=z>>>0;z=g[7][1]+v;g[7][0]=g[7][0]+n+(z/4294967296>>>0)>>>0;g[7][1]=z>>>0;U-=128}} +var I=C(5);C(16);C(7);var V=Q.exports=I.sha512=I.sha512||{};I.md.sha512=I.md.algorithms.sha512=V;Q=I.sha384=I.sha512.sha384=I.sha512.sha384||{};Q.create=function(){return V.create("SHA-384")};I.md.sha384=I.md.algorithms.sha384=Q;I.sha512.sha256=I.sha512.sha256||{create:function(){return V.create("SHA-512/256")}};I.md["sha512/256"]=I.md.algorithms["sha512/256"]=I.sha512.sha256;I.sha512.sha224=I.sha512.sha224||{create:function(){return V.create("SHA-512/224")}};I.md["sha512/224"]=I.md.algorithms["sha512/224"]= +I.sha512.sha224;V.create=function(g){f||(q=String.fromCharCode(128),q+=I.util.fillString(String.fromCharCode(0),128),k=[[1116352408,3609767458],[1899447441,602891725],[3049323471,3964484399],[3921009573,2173295548],[961987163,4081628472],[1508970993,3053834265],[2453635748,2937671579],[2870763221,3664609560],[3624381080,2734883394],[310598401,1164996542],[607225278,1323610764],[1426881987,3590304994],[1925078388,4068182383],[2162078206,991336113],[2614888103,633803317],[3248222580,3479774868],[3835390401, +2666613458],[4022224774,944711139],[264347078,2341262773],[604807628,2007800933],[770255983,1495990901],[1249150122,1856431235],[1555081692,3175218132],[1996064986,2198950837],[2554220882,3999719339],[2821834349,766784016],[2952996808,2566594879],[3210313671,3203337956],[3336571891,1034457026],[3584528711,2466948901],[113926993,3758326383],[338241895,168717936],[666307205,1188179964],[773529912,1546045734],[1294757372,1522805485],[1396182291,2643833823],[1695183700,2343527390],[1986661051,1014477480], +[2177026350,1206759142],[2456956037,344077627],[2730485921,1290863460],[2820302411,3158454273],[3259730800,3505952657],[3345764771,106217008],[3516065817,3606008344],[3600352804,1432725776],[4094571909,1467031594],[275423344,851169720],[430227734,3100823752],[506948616,1363258195],[659060556,3750685593],[883997877,3785050280],[958139571,3318307427],[1322822218,3812723403],[1537002063,2003034995],[1747873779,3602036899],[1955562222,1575990012],[2024104815,1125592928],[2227730452,2716904306],[2361852424, +442776044],[2428436474,593698344],[2756734187,3733110249],[3204031479,2999351573],[3329325298,3815920427],[3391569614,3928383900],[3515267271,566280711],[3940187606,3454069534],[4118630271,4000239992],[116418474,1914138554],[174292421,2731055270],[289380356,3203993006],[460393269,320620315],[685471733,587496836],[852142971,1086792851],[1017036298,365543100],[1126000580,2618297676],[1288033470,3409855158],[1501505948,4234509866],[1607167915,987167468],[1816402316,1246189591]],d={"SHA-512":[[1779033703, +4089235720],[3144134277,2227873595],[1013904242,4271175723],[2773480762,1595750129],[1359893119,2917565137],[2600822924,725511199],[528734635,4215389547],[1541459225,327033209]],"SHA-384":[[3418070365,3238371032],[1654270250,914150663],[2438529370,812702999],[355462360,4144912697],[1731405415,4290775857],[2394180231,1750603025],[3675008525,1694076839],[1203062813,3204075428]],"SHA-512/256":[[573645204,4230739756],[2673172387,3360449730],[596883563,1867755857],[2520282905,1497426621],[2519219938,2827943907], +[3193839141,1401305490],[721525244,746961066],[246885852,2177182882]],"SHA-512/224":[[2352822216,424955298],[1944164710,2312950998],[502970286,855612546],[1738396948,1479516111],[258812777,2077511080],[2011393907,79989058],[1067287976,1780299464],[286451373,2446758561]]},f=!0);"undefined"===typeof g&&(g="SHA-512");if(!(g in d))throw Error("Invalid SHA-512 algorithm: "+g);for(var t=d[g],A=null,W=I.util.createBuffer(),F=Array(80),H=0;80>H;++H)F[H]=Array(2);H=64;switch(g){case "SHA-384":H=48;break;case "SHA-512/256":H= +32;break;case "SHA-512/224":H=28}var x={algorithm:g.replace("-","").toLowerCase(),blockLength:128,digestLength:H,messageLength:0,fullMessageLength:null,messageLengthSize:16,start:function(){x.messageLength=0;x.fullMessageLength=x.messageLength128=[];for(var z=x.messageLengthSize/4,m=0;m>>0,m>>>0];for(var P=x.fullMessageLength.length-1;0<=P;--P)x.fullMessageLength[P]+=m[1],m[1]=m[0]+(x.fullMessageLength[P]/4294967296>>>0),x.fullMessageLength[P]>>>=0,m[0]=m[1]/4294967296>>>0;W.putBytes(z);u(A,F,W);(2048>>0,l+=P,z.putInt32(l>>>0),l=m>>>0;z.putInt32(l);m=Array(A.length);for(e=0;e>>0};z.signed=x;z.unsigned=z;z.model=H;return z};Q("crc1",function(H,x){u.Buffer.isBuffer(H)||(H=I(H));for(var z=0,m=0;m>8)&65535;return x});var d=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895, +17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244, +48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223, +64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];"undefined"!==typeof Int32Array&&(d=new Int32Array(d));Q("ccitt",function(H,x){u.Buffer.isBuffer(H)||(H=I(H));x="undefined"!==typeof x?~~x:65535;for(var z=0;z>8^H[z])&255]^x<<8)&65535;return x});var g=[0,49345,49537, +320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8E3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16E3,65089,64001,15040,15232,64321,14592, +63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32E3,48577,48257,31808,46081,29888, +30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];"undefined"!==typeof Int32Array&& +(g=new Int32Array(g));Q("crc-16-modbus",function(H,x){u.Buffer.isBuffer(H)||(H=I(H));x="undefined"!==typeof x?~~x:65535;for(var z=0;z>8)&65535;return x});Q("xmodem",function(H,x){u.Buffer.isBuffer(H)||(H=I(H));x="undefined"!==typeof x?~~x:0;for(var z=0;z>>8&255;m^=H[z]&255;m^=m>>>4;x=x<<8&65535;x^=m;m=m<<5&65535;x^=m;m=m<<7&65535;x^=m}return x});var t=[0,4489,8978,12955,17956,22445,25910,29887,35912,40385,44890,48851,51820,56293,59774,63735, +4225,264,13203,8730,22181,18220,30135,25662,40137,36160,49115,44626,56045,52068,63999,59510,8450,12427,528,5017,26406,30383,17460,21949,44362,48323,36440,40913,60270,64231,51324,55797,12675,8202,4753,792,30631,26158,21685,17724,48587,44098,40665,36688,64495,60006,55549,51572,16900,21389,24854,28831,1056,5545,10034,14011,52812,57285,60766,64727,34920,39393,43898,47859,21125,17164,29079,24606,5281,1320,14259,9786,57037,53060,64991,60502,39145,35168,48123,43634,25350,29327,16404,20893,9506,13483,1584, +6073,61262,65223,52316,56789,43370,47331,35448,39921,29575,25102,20629,16668,13731,9258,5809,1848,65487,60998,56541,52564,47595,43106,39673,35696,33800,38273,42778,46739,49708,54181,57662,61623,2112,6601,11090,15067,20068,24557,28022,31999,38025,34048,47003,42514,53933,49956,61887,57398,6337,2376,15315,10842,24293,20332,32247,27774,42250,46211,34328,38801,58158,62119,49212,53685,10562,14539,2640,7129,28518,32495,19572,24061,46475,41986,38553,34576,62383,57894,53437,49460,14787,10314,6865,2904,32743, +28270,23797,19836,50700,55173,58654,62615,32808,37281,41786,45747,19012,23501,26966,30943,3168,7657,12146,16123,54925,50948,62879,58390,37033,33056,46011,41522,23237,19276,31191,26718,7393,3432,16371,11898,59150,63111,50204,54677,41258,45219,33336,37809,27462,31439,18516,23005,11618,15595,3696,8185,63375,58886,54429,50452,45483,40994,37561,33584,31687,27214,22741,18780,15843,11370,7921,3960];"undefined"!==typeof Int32Array&&(t=new Int32Array(t));Q("kermit",function(H,x){u.Buffer.isBuffer(H)||(H=I(H)); +x="undefined"!==typeof x?~~x:0;for(var z=0;z>8)&65535;return x});var A=[0,8801531,9098509,825846,9692897,1419802,1651692,10452759,10584377,2608578,2839604,11344079,3303384,11807523,12104405,4128302,12930697,4391538,5217156,13227903,5679208,13690003,14450021,5910942,6606768,14844747,15604413,6837830,16197969,7431594,8256604,16494759,840169,9084178,8783076,18463,10434312,1670131,1434117,9678590,11358416,2825259,2590173,10602790,4109873,12122826,11821884,3289031,13213536, +5231515,4409965,12912278,5929345,14431610,13675660,5693559,6823513,15618722,14863188,6588335,16513208,8238147,7417269,16212302,1680338,10481449,9664223,1391140,9061683,788936,36926,8838341,12067563,4091408,3340262,11844381,2868234,11372785,10555655,2579964,14478683,5939616,5650518,13661357,5180346,13190977,12967607,4428364,8219746,16457881,16234863,7468436,15633027,6866552,6578062,14816117,1405499,9649856,10463030,1698765,8819930,55329,803287,9047340,11858690,3325945,4072975,12086004,2561507,10574104, +11387118,2853909,13647026,5664841,5958079,14460228,4446803,12949160,13176670,5194661,7454091,16249200,16476294,8201341,14834538,6559633,6852199,15647388,3360676,11864927,12161705,4185682,10527045,2551230,2782280,11286707,9619101,1346150,1577872,10379115,73852,8875143,9172337,899466,16124205,7357910,8182816,16421083,6680524,14918455,15678145,6911546,5736468,13747439,14507289,5968354,12873461,4334094,5159928,13170435,4167245,12180150,11879232,3346363,11301036,2767959,2532769,10545498,10360692,1596303, +1360505,9604738,913813,9157998,8856728,92259,16439492,8164415,7343561,16138546,6897189,15692510,14936872,6662099,5986813,14488838,13733104,5750795,13156124,5174247,4352529,12855018,2810998,11315341,10498427,2522496,12124823,4148844,3397530,11901793,9135439,862644,110658,8912057,1606574,10407765,9590435,1317464,15706879,6940164,6651890,14889737,8145950,16384229,16161043,7394792,5123014,13133629,12910283,4370992,14535975,5997020,5707818,13718737,2504095,10516836,11329682,2796649,11916158,3383173,4130419, +12143240,8893606,129117,876971,9121104,1331783,9576124,10389322,1625009,14908182,6633453,6925851,15721184,7380471,16175372,16402682,8127489,4389423,12891860,13119266,5137369,13704398,5722165,6015427,14517560];"undefined"!==typeof Int32Array&&(A=new Int32Array(A));Q("crc-24",function(H,x){u.Buffer.isBuffer(H)||(H=I(H));x="undefined"!==typeof x?~~x:11994318;for(var z=0;z>16^H[z])&255]^x<<8)&16777215;return x});var W=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685, +2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731, +3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817, +1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814, +4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972, +40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918E3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130, +1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];"undefined"!==typeof Int32Array&&(W=new Int32Array(W));Q("crc-32",function(H,x){u.Buffer.isBuffer(H)||(H=I(H));x=0===x?0:~~x^-1;for(var z=0;z>>8;return x^-1});var F=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047, +2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225, +3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467, +855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852, +4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622, +213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918E3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456, +1567103746,711928724,3020668471,3272380065,1510334235,755167117];"undefined"!==typeof Int32Array&&(F=new Int32Array(F));Q("jam",function(H,x){x=void 0===x?-1:x;u.Buffer.isBuffer(H)||(H=I(H));x=0===x?0:~~x;for(var z=0;z>>8;return x})},function(Q,E,C){function u(f){var k=f.length;if(0>16&255,g[t++]=d>>8&255,g[t++]=d&255;2===k&&(d=V[f.charCodeAt(W)]<<2|V[f.charCodeAt(W+1)]>>4,g[t++]=d&255);1===k&&(d=V[f.charCodeAt(W)]<<10|V[f.charCodeAt(W+1)]<<4|V[f.charCodeAt(W+2)]>>2,g[t++]=d>>8&255,g[t++]=d&255);return g};E.fromByteArray=function(f){for(var k=f.length,d=k% +3,g=[],t=0,A=k-d;tA?A:t+16383,m=[],P=t;P>18&63]+I[H>>12&63]+I[H>>6&63]+I[H&63]);H=m.join("");F.call(W,H)}1===d?(f=f[k-1],g.push(I[f>>2]+I[f<<4&63]+"==")):2===d&&(f=(f[k-2]<<8)+f[k-1],g.push(I[f>>10]+I[f>>4&63]+I[f<<2&63]+"="));return g.join("")};var I=[],V=[],q="undefined"!==typeof Uint8Array?Uint8Array:Array;for(Q=0;64>Q;++Q)I[Q]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[Q], +V["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charCodeAt(Q)]=Q;V[45]=62;V[95]=63},function(Q,E){E.read=function(C,u,I,V,q){var f=8*q-V-1;var k=(1<>1,g=-7;q=I?q-1:0;var t=I?-1:1,A=C[u+q];q+=t;I=A&(1<<-g)-1;A>>=-g;for(g+=f;0>=-g;for(g+=V;0>1,A=23===q?Math.pow(2,-24)-Math.pow(2,-77):0;f=V?0:f-1;var W=V?1:-1,F=0>u||0===u&&0>1/u?1:0;u=Math.abs(u);isNaN(u)||Infinity===u?(u=isNaN(u)?1:0,V=g):(V=Math.floor(Math.log(u)/Math.LN2),1>u*(k=Math.pow(2,-V))&&(V--,k*=2),u=1<=V+t?u+A/k:u+A*Math.pow(2,1-t),2<=u*k&&(V++,k/=2),V+t>=g?(u=0,V=g):1<=V+t?(u=(u*k-1)*Math.pow(2,q),V+=t):(u=u*Math.pow(2,t-1)*Math.pow(2,q),V=0));for(;8<=q;C[I+f]=u&255,f+=W,u/=256,q-=8);V=V<=m+P||m?new java.lang.String(z,m,P)+"":z}function g(z,m){z.currentElement?z.currentElement.appendChild(m): +z.doc.appendChild(m)}Q=C(31);var t=C(46),A=C(69);C=C(70);var W=t.DOMImplementation,F=Q.NAMESPACE,H=C.ParseError,x=C.XMLReader;I.prototype.parseFromString=function(z,m){var P=this.options,l=new x,e=P.domBuilder||new q,w=P.errorHandler,J=P.locator,h=P.xmlns||{},y=/\/x?html?$/.test(m);m=y?A.HTML_ENTITIES:A.XML_ENTITIES;J&&e.setDocumentLocator(J);l.errorHandler=V(w,e,J);l.domBuilder=P.domBuilder||e;y&&(h[""]=F.HTML);h.xml=h.xml||F.XML;P=P.normalizeLineEndings||u;z&&"string"===typeof z?l.parse(P(z),h, +m):l.errorHandler.error("invalid doc source");return e.doc};q.prototype={startDocument:function(){this.doc=(new W).createDocument(null,null,null);this.locator&&(this.doc.documentURI=this.locator.systemId)},startElement:function(z,m,P,l){var e=this.doc;m=e.createElementNS(z,P||m);var w=l.length;g(this,m);this.currentElement=m;this.locator&&f(this.locator,m);for(var J=0;J",lt:"<",quot:'"'});E.HTML_ENTITIES=Q({lt:"<",gt:">",amp:"&",quot:'"',apos:"'",Agrave:"\u00c0",Aacute:"\u00c1",Acirc:"\u00c2",Atilde:"\u00c3",Auml:"\u00c4",Aring:"\u00c5",AElig:"\u00c6",Ccedil:"\u00c7",Egrave:"\u00c8",Eacute:"\u00c9",Ecirc:"\u00ca",Euml:"\u00cb",Igrave:"\u00cc",Iacute:"\u00cd",Icirc:"\u00ce",Iuml:"\u00cf",ETH:"\u00d0",Ntilde:"\u00d1",Ograve:"\u00d2",Oacute:"\u00d3",Ocirc:"\u00d4", +Otilde:"\u00d5",Ouml:"\u00d6",Oslash:"\u00d8",Ugrave:"\u00d9",Uacute:"\u00da",Ucirc:"\u00db",Uuml:"\u00dc",Yacute:"\u00dd",THORN:"\u00de",szlig:"\u00df",agrave:"\u00e0",aacute:"\u00e1",acirc:"\u00e2",atilde:"\u00e3",auml:"\u00e4",aring:"\u00e5",aelig:"\u00e6",ccedil:"\u00e7",egrave:"\u00e8",eacute:"\u00e9",ecirc:"\u00ea",euml:"\u00eb",igrave:"\u00ec",iacute:"\u00ed",icirc:"\u00ee",iuml:"\u00ef",eth:"\u00f0",ntilde:"\u00f1",ograve:"\u00f2",oacute:"\u00f3",ocirc:"\u00f4",otilde:"\u00f5",ouml:"\u00f6", +oslash:"\u00f8",ugrave:"\u00f9",uacute:"\u00fa",ucirc:"\u00fb",uuml:"\u00fc",yacute:"\u00fd",thorn:"\u00fe",yuml:"\u00ff",nbsp:"\u00a0",iexcl:"\u00a1",cent:"\u00a2",pound:"\u00a3",curren:"\u00a4",yen:"\u00a5",brvbar:"\u00a6",sect:"\u00a7",uml:"\u00a8",copy:"\u00a9",ordf:"\u00aa",laquo:"\u00ab",not:"\u00ac",shy:"\u00ad\u00ad",reg:"\u00ae",macr:"\u00af",deg:"\u00b0",plusmn:"\u00b1",sup2:"\u00b2",sup3:"\u00b3",acute:"\u00b4",micro:"\u00b5",para:"\u00b6",middot:"\u00b7",cedil:"\u00b8",sup1:"\u00b9",ordm:"\u00ba", +raquo:"\u00bb",frac14:"\u00bc",frac12:"\u00bd",frac34:"\u00be",iquest:"\u00bf",times:"\u00d7",divide:"\u00f7",forall:"\u2200",part:"\u2202",exist:"\u2203",empty:"\u2205",nabla:"\u2207",isin:"\u2208",notin:"\u2209",ni:"\u220b",prod:"\u220f",sum:"\u2211",minus:"\u2212",lowast:"\u2217",radic:"\u221a",prop:"\u221d",infin:"\u221e",ang:"\u2220",and:"\u2227",or:"\u2228",cap:"\u2229",cup:"\u222a","int":"\u222b",there4:"\u2234",sim:"\u223c",cong:"\u2245",asymp:"\u2248",ne:"\u2260",equiv:"\u2261",le:"\u2264", +ge:"\u2265",sub:"\u2282",sup:"\u2283",nsub:"\u2284",sube:"\u2286",supe:"\u2287",oplus:"\u2295",otimes:"\u2297",perp:"\u22a5",sdot:"\u22c5",Alpha:"\u0391",Beta:"\u0392",Gamma:"\u0393",Delta:"\u0394",Epsilon:"\u0395",Zeta:"\u0396",Eta:"\u0397",Theta:"\u0398",Iota:"\u0399",Kappa:"\u039a",Lambda:"\u039b",Mu:"\u039c",Nu:"\u039d",Xi:"\u039e",Omicron:"\u039f",Pi:"\u03a0",Rho:"\u03a1",Sigma:"\u03a3",Tau:"\u03a4",Upsilon:"\u03a5",Phi:"\u03a6",Chi:"\u03a7",Psi:"\u03a8",Omega:"\u03a9",alpha:"\u03b1",beta:"\u03b2", +gamma:"\u03b3",delta:"\u03b4",epsilon:"\u03b5",zeta:"\u03b6",eta:"\u03b7",theta:"\u03b8",iota:"\u03b9",kappa:"\u03ba",lambda:"\u03bb",mu:"\u03bc",nu:"\u03bd",xi:"\u03be",omicron:"\u03bf",pi:"\u03c0",rho:"\u03c1",sigmaf:"\u03c2",sigma:"\u03c3",tau:"\u03c4",upsilon:"\u03c5",phi:"\u03c6",chi:"\u03c7",psi:"\u03c8",omega:"\u03c9",thetasym:"\u03d1",upsih:"\u03d2",piv:"\u03d6",OElig:"\u0152",oelig:"\u0153",Scaron:"\u0160",scaron:"\u0161",Yuml:"\u0178",fnof:"\u0192",circ:"\u02c6",tilde:"\u02dc",ensp:"\u2002", +emsp:"\u2003",thinsp:"\u2009",zwnj:"\u200c",zwj:"\u200d",lrm:"\u200e",rlm:"\u200f",ndash:"\u2013",mdash:"\u2014",lsquo:"\u2018",rsquo:"\u2019",sbquo:"\u201a",ldquo:"\u201c",rdquo:"\u201d",bdquo:"\u201e",dagger:"\u2020",Dagger:"\u2021",bull:"\u2022",hellip:"\u2026",permil:"\u2030",prime:"\u2032",Prime:"\u2033",lsaquo:"\u2039",rsaquo:"\u203a",oline:"\u203e",euro:"\u20ac",trade:"\u2122",larr:"\u2190",uarr:"\u2191",rarr:"\u2192",darr:"\u2193",harr:"\u2194",crarr:"\u21b5",lceil:"\u2308",rceil:"\u2309", +lfloor:"\u230a",rfloor:"\u230b",loz:"\u25ca",spades:"\u2660",clubs:"\u2663",hearts:"\u2665",diams:"\u2666"});E.entityMap=E.HTML_ENTITIES},function(Q,E,C){function u(x,z){this.message=x;this.locator=z;Error.captureStackTrace&&Error.captureStackTrace(this,u)}function I(){}function V(x,z,m,P,l){function e(za){var ta=za.slice(1,-1);if(ta in m)return m[ta];if("#"===ta.charAt(0))return za=parseInt(ta.substr(1).replace("x","0x")),65535>10),56320+(za&1023))): +za=String.fromCharCode(za),za;l.error("entity not found:"+za);return za}function w(za){if(za>Z){var ta=x.substring(Z,za).replace(/&#?\w+;/g,e);M&&J(Z);P.characters(ta,0,za-Z);Z=za}}function J(za,ta){for(;za>=y&&(ta=G.exec(x));)h=ta.index,y=h+ta[0].length,M.lineNumber++;M.columnNumber=za-h+1}var h=0,y=0,G=/.*(?:\r\n?|\n)|.*$/g,M=P.locator;z=[{currentNSMap:z}];for(var S={},Z=0;;){try{var ca=x.indexOf("<",Z);if(0>ca){if(!x.substr(Z).match(/^\s*$/)){var ea=P.doc,ia=ea.createTextNode(x.substr(Z));ea.appendChild(ia); +P.currentElement=ia}break}ca>Z&&w(ca);switch(x.charAt(ca+1)){case "/":var na=x.indexOf(">",ca+3),r=x.substring(ca+2,na).replace(/[ \t\n\r]+$/g,""),n=z.pop();0>na?(r=x.substring(ca+2).replace(/[\s<].*/,""),l.error("end tag name: "+r+" is not complete:"+n.tagName),na=ca+1+r.length):r.match(/\sZ?Z=na:w(Math.max(ca,Z)+1)}}function q(x,z){z.lineNumber=x.lineNumber;z.columnNumber=x.columnNumber;return z}function f(x,z,m,P,l,e){function w(S,Z,ca){m.attributeNames.hasOwnProperty(S)&&e.fatalError("Attribute "+S+" redefined");m.addValue(S,Z.replace(/[\t\n\r]/g," ").replace(/&#?\w+;/g, +l),ca)}for(var J,h,y=++z,G=0;;){var M=x.charAt(y);switch(M){case "=":if(1===G)J=x.slice(z,y),G=3;else if(2===G)G=3;else throw Error("attribute equal must after attrName");break;case "'":case '"':if(3===G||1===G)if(1===G&&(e.warning('attribute value must after "="'),J=x.slice(z,y)),z=y+1,y=x.indexOf(M,z),0":switch(G){case 0:m.setTagName(x.slice(z,y));case 5:case 6:case 7:break;case 4:case 1:h=x.slice(z,y),"/"===h.slice(-1)&&(m.closed=!0,h=h.slice(0,-1));case 2:2===G&&(h=J); +4==G?(e.warning('attribute "'+h+'" missed quot(")!'),w(J,h,z)):(F.isHTML(P[""])&&h.match(/^(?:disabled|checked|selected)$/i)||e.warning('attribute "'+h+'" missed value!! "'+h+'" instead!!'),w(h,h,z));break;case 3:throw Error("attribute value missed!!");}return y;case "\u0080":M=" ";default:if(" ">=M)switch(G){case 0:m.setTagName(x.slice(z,y));G=6;break;case 1:J=x.slice(z,y);G=2;break;case 4:h=x.slice(z,y),e.warning('attribute "'+h+'" missed quot(")!!'),w(J,h,z);case 5:G=6}else switch(G){case 2:F.isHTML(P[""])&& +J.match(/^(?:disabled|checked|selected)$/i)||e.warning('attribute "'+J+'" missed value!! "'+J+'" instead2!!');w(J,J,z);z=y;G=1;break;case 5:e.warning('attribute space is required"'+J+'"!!');case 6:G=1;z=y;break;case 3:G=4;z=y;break;case 7:throw Error("elements closed character '/' and '>' must be connected to");}}y++}}function k(x,z,m){for(var P=x.tagName,l=null,e=x.length;e--;){var w=x[e],J=w.qName,h=w.value,y=J.indexOf(":");if(0",z);x=x.substring(z+1,e);if(/[&<]/.test(x)){if(/^script$/i.test(m))return l.characters(x,0,x.length),e;x=x.replace(/&#?\w+;/g,P);l.characters(x,0,x.length);return e}}return z+1}function g(x,z,m,P){var l=P[m];null==l&&(l=x.lastIndexOf(""),lz)return m.comment(x, +z+4,l-z-4),l+3;P.error("Unclosed comment")}break;default:if("CDATA["==x.substr(z+3,6))return l=x.indexOf("]]\x3e",z+9),m.startCDATA(),m.characters(x,z+9,l-z-9),m.endCDATA(),l+3;a:{P=[];l=/'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g;l.lastIndex=z;for(l.exec(x);z=l.exec(x);)if(P.push(z),z[1]){l=P;break a}l=void 0}var e=l.length;if(1",z);return P&&(x=x.substring(z,P).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/))?(m.processingInstruction(x[1],x[2]),P+2):-1}function W(){this.attributeNames={}}var F=C(31).NAMESPACE;Q=/[A-Z_a-z\xC0-\xD6\xD8-\xF6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/;C=new RegExp("[\\-\\.0-9"+Q.source.slice(1,-1)+"\\u00B7\\u0300-\\u036F\\u203F-\\u2040]");var H=new RegExp("^"+ +Q.source+C.source+"*(?::"+Q.source+C.source+"*)?$");u.prototype=Error();u.prototype.name=u.name;I.prototype={parse:function(x,z,m){var P=this.domBuilder;P.startDocument();var l=z,e=z={},w;for(w in l)e[w]=l[w];V(x,z,m,P,this.errorHandler);P.endDocument()}};W.prototype={setTagName:function(x){if(!H.test(x))throw Error("invalid tagName:"+x);this.tagName=x},addValue:function(x,z,m){if(!H.test(x))throw Error("invalid attribute:"+x);this.attributeNames[x]=this.length;this[this.length++]={qName:x,value:z, +offset:m}},length:0,getLocalName:function(x){return this[x].localName},getLocator:function(x){return this[x].locator},getQName:function(x){return this[x].qName},getURI:function(x){return this[x].uri},getValue:function(x){return this[x].value}};E.XMLReader=I;E.ParseError=u},function(Q,E){function C(){this.init()}function u(c){this.expression=c}function I(){}function V(c){0 +Ba||9 >>>>>>>>> >>>>>>> >> >> { 1 . +*)(' # \" { 1 . +*)(' # \" {Q QQQQQQQQQ QQQQQQQ QQ aQ {V VVVVVVVVV VVVVVVV VV aV {T TTTTTTTTT TTTTTTT TT T {@ @@@@@@@@@ @@@@@@@ @@ @@ { \u0087 {[ [[[[[[[[[ [[[[[[[ [[ [[ {D DDDDDDDDD DDDDDDD DD DD { HH { \u0088 { F\u0089 {# T# ## # {% V %% U %% % {' 'ZY'' 'XW '' ' {( (ZY(( (XW (( ( {+ +++++ +++\\[ ++ + {* ***** ***\\[ ** * {- ----- ---\\[ -- - {, ,,,,, ,,,\\[ ,, , {0 00000_^] 00000 00 0 {/ /////_^] ///// // / {2 22222222 22222 22 2 {3 33333333 33333 33 3 {4 44444444 44444 44 4 {8 88888888 888888 88 8 { ^ { \u008a {; f;;;;;;;; ;;;;;;e ;; ; {< f<<<<<<<< <<<<<=c.length)break;if("("==la)X.push(C.LEFTPARENTHESIS),ka.push(la),la=c.charAt(ja++);else if(")"==la)X.push(C.RIGHTPARENTHESIS),ka.push(la),la=c.charAt(ja++);else if("["==la)X.push(C.LEFTBRACKET),ka.push(la),la=c.charAt(ja++);else if("]"==la)X.push(C.RIGHTBRACKET),ka.push(la),la=c.charAt(ja++);else if("@"==la)X.push(C.AT),ka.push(la),la=c.charAt(ja++);else if(","==la)X.push(C.COMMA),ka.push(la),la=c.charAt(ja++);else if("|"==la)X.push(C.BAR), +ka.push(la),la=c.charAt(ja++);else if("+"==la)X.push(C.PLUS),ka.push(la),la=c.charAt(ja++);else if("-"==la)X.push(C.MINUS),ka.push(la),la=c.charAt(ja++);else if("="==la)X.push(C.EQUALS),ka.push(la),la=c.charAt(ja++);else if("$"==la)X.push(C.DOLLAR),ka.push(la),la=c.charAt(ja++);else if("."==la)if(la=c.charAt(ja++),"."==la)X.push(C.DOUBLEDOT),ka.push(".."),la=c.charAt(ja++);else if("0"<=la&&"9">=la){var Ba="."+la;for(la=c.charAt(ja++);"0"<=la&&"9">=la;)Ba+=la,la=c.charAt(ja++);X.push(C.NUMBER);ka.push(Ba)}else X.push(C.DOT), +ka.push(".");else if("'"==la||'"'==la){Ba=la;for(var Ha="";(la=c.charAt(ja++))!=Ba;)Ha+=la;X.push(C.LITERAL);ka.push(Ha);la=c.charAt(ja++)}else if("0"<=la&&"9">=la){Ba=la;for(la=c.charAt(ja++);"0"<=la&&"9">=la;)Ba+=la,la=c.charAt(ja++);if("."==la&&"0"<=c.charAt(ja)&&"9">=c.charAt(ja))for(Ba+=la,Ba+=c.charAt(ja++),la=c.charAt(ja++);"0"<=la&&"9">=la;)Ba+=la,la=c.charAt(ja++);X.push(C.NUMBER);ka.push(Ba)}else if("*"==la){if(0"==la)"="==c.charAt(ja)?(X.push(C.GREATERTHANOREQUAL),ka.push(">="),ja++):(X.push(C.GREATERTHAN),ka.push(">")),la=c.charAt(ja++);else if("_"==la||ta.isLetter(la.charCodeAt(0))){Ha= +la;for(la=c.charAt(ja++);ta.isNCNameChar(la.charCodeAt(0));)Ha+=la,la=c.charAt(ja++);if(0"}; +I.prototype.evaluate=function(c){throw Error("Could not evaluate expression.");};V.prototype=new I;V.prototype.constructor=V;V.superclass=I.prototype;V.prototype.init=function(c){this.rhs=c};q.prototype=new V;q.prototype.constructor=q;q.superclass=V.prototype;q.prototype.init=function(c){q.superclass.init.call(this,c)};q.prototype.evaluate=function(c){return this.rhs.evaluate(c).number().negate()};q.prototype.toString=function(){return"-"+this.rhs.toString()};f.prototype=new I;f.prototype.constructor= +f;f.superclass=I.prototype;f.prototype.init=function(c,X){this.lhs=c;this.rhs=X};k.prototype=new f;k.prototype.constructor=k;k.superclass=f.prototype;k.prototype.init=function(c,X){k.superclass.init.call(this,c,X)};k.prototype.toString=function(){return"("+this.lhs.toString()+" or "+this.rhs.toString()+")"};k.prototype.evaluate=function(c){var X=this.lhs.evaluate(c).bool();return X.booleanValue()?X:this.rhs.evaluate(c).bool()};d.prototype=new f;d.prototype.constructor=d;d.superclass=f.prototype;d.prototype.init= +function(c,X){d.superclass.init.call(this,c,X)};d.prototype.toString=function(){return"("+this.lhs.toString()+" and "+this.rhs.toString()+")"};d.prototype.evaluate=function(c){var X=this.lhs.evaluate(c).bool();return X.booleanValue()?this.rhs.evaluate(c).bool():X};g.prototype=new f;g.prototype.constructor=g;g.superclass=f.prototype;g.prototype.init=function(c,X){g.superclass.init.call(this,c,X)};g.prototype.toString=function(){return"("+this.lhs.toString()+" = "+this.rhs.toString()+")"};g.prototype.evaluate= +function(c){return this.lhs.evaluate(c).equals(this.rhs.evaluate(c))};t.prototype=new f;t.prototype.constructor=t;t.superclass=f.prototype;t.prototype.init=function(c,X){t.superclass.init.call(this,c,X)};t.prototype.toString=function(){return"("+this.lhs.toString()+" != "+this.rhs.toString()+")"};t.prototype.evaluate=function(c){return this.lhs.evaluate(c).notequal(this.rhs.evaluate(c))};A.prototype=new f;A.prototype.constructor=A;A.superclass=f.prototype;A.prototype.init=function(c,X){A.superclass.init.call(this, +c,X)};A.prototype.evaluate=function(c){return this.lhs.evaluate(c).lessthan(this.rhs.evaluate(c))};A.prototype.toString=function(){return"("+this.lhs.toString()+" < "+this.rhs.toString()+")"};W.prototype=new f;W.prototype.constructor=W;W.superclass=f.prototype;W.prototype.init=function(c,X){W.superclass.init.call(this,c,X)};W.prototype.evaluate=function(c){return this.lhs.evaluate(c).greaterthan(this.rhs.evaluate(c))};W.prototype.toString=function(){return"("+this.lhs.toString()+" > "+this.rhs.toString()+ +")"};F.prototype=new f;F.prototype.constructor=F;F.superclass=f.prototype;F.prototype.init=function(c,X){F.superclass.init.call(this,c,X)};F.prototype.evaluate=function(c){return this.lhs.evaluate(c).lessthanorequal(this.rhs.evaluate(c))};F.prototype.toString=function(){return"("+this.lhs.toString()+" <= "+this.rhs.toString()+")"};H.prototype=new f;H.prototype.constructor=H;H.superclass=f.prototype;H.prototype.init=function(c,X){H.superclass.init.call(this,c,X)};H.prototype.evaluate=function(c){return this.lhs.evaluate(c).greaterthanorequal(this.rhs.evaluate(c))}; +H.prototype.toString=function(){return"("+this.lhs.toString()+" >= "+this.rhs.toString()+")"};x.prototype=new f;x.prototype.constructor=x;x.superclass=f.prototype;x.prototype.init=function(c,X){x.superclass.init.call(this,c,X)};x.prototype.evaluate=function(c){return this.lhs.evaluate(c).number().plus(this.rhs.evaluate(c).number())};x.prototype.toString=function(){return"("+this.lhs.toString()+" + "+this.rhs.toString()+")"};z.prototype=new f;z.prototype.constructor=z;z.superclass=f.prototype;z.prototype.init= +function(c,X){z.superclass.init.call(this,c,X)};z.prototype.evaluate=function(c){return this.lhs.evaluate(c).number().minus(this.rhs.evaluate(c).number())};z.prototype.toString=function(){return"("+this.lhs.toString()+" - "+this.rhs.toString()+")"};m.prototype=new f;m.prototype.constructor=m;m.superclass=f.prototype;m.prototype.init=function(c,X){m.superclass.init.call(this,c,X)};m.prototype.evaluate=function(c){return this.lhs.evaluate(c).number().multiply(this.rhs.evaluate(c).number())};m.prototype.toString= +function(){return"("+this.lhs.toString()+" * "+this.rhs.toString()+")"};P.prototype=new f;P.prototype.constructor=P;P.superclass=f.prototype;P.prototype.init=function(c,X){P.superclass.init.call(this,c,X)};P.prototype.evaluate=function(c){return this.lhs.evaluate(c).number().div(this.rhs.evaluate(c).number())};P.prototype.toString=function(){return"("+this.lhs.toString()+" div "+this.rhs.toString()+")"};l.prototype=new f;l.prototype.constructor=l;l.superclass=f.prototype;l.prototype.init=function(c, +X){l.superclass.init.call(this,c,X)};l.prototype.evaluate=function(c){return this.lhs.evaluate(c).number().mod(this.rhs.evaluate(c).number())};l.prototype.toString=function(){return"("+this.lhs.toString()+" mod "+this.rhs.toString()+")"};e.prototype=new f;e.prototype.constructor=e;e.superclass=f.prototype;e.prototype.init=function(c,X){e.superclass.init.call(this,c,X)};e.prototype.evaluate=function(c){return this.lhs.evaluate(c).nodeset().union(this.rhs.evaluate(c).nodeset())};e.prototype.toString= +function(){return this.lhs.toString()+" | "+this.rhs.toString()};w.prototype=new I;w.prototype.constructor=w;w.superclass=I.prototype;w.prototype.init=function(c,X,ka){w.superclass.init.call(this);this.filter=c;this.filterPredicates=X;this.locationPath=ka};w.prototype.evaluate=function(c){var X=new r;X.variableResolver=c.variableResolver;X.functionResolver=c.functionResolver;X.namespaceResolver=c.namespaceResolver;X.expressionContextNode=c.expressionContextNode;X.virtualRoot=c.virtualRoot;X.caseInsensitive= +c.caseInsensitive;if(null==this.filter)c=[c.contextNode];else{var ka=this.filter.evaluate(c);if(!ta.instance_of(ka,ia)){if(null!=this.filterPredicates&&0"};y.prototype.matches=function(c,X){switch(this.type){case y.NAMETESTANY:if(2==c.nodeType||1==c.nodeType||c.nodeType==na.XPATH_NAMESPACE_NODE)return!0;break;case y.NAMETESTPREFIXANY:if(2==c.nodeType||1==c.nodeType){if(null==X.namespaceResolver.getNamespace(this.value, +X.expressionContextNode))throw Error("Cannot resolve QName "+this.value);return!0}break;case y.NAMETESTQNAME:if(2==c.nodeType||1==c.nodeType||c.nodeType==na.XPATH_NAMESPACE_NODE){var ka=ta.resolveQName(this.value,X.namespaceResolver,X.expressionContextNode,!1);if(null==ka[0])throw Error("Cannot resolve QName "+this.value);ka[0]=String(ka[0]);ka[1]=String(ka[1]);""==ka[0]&&(ka[0]=null);c=ta.resolveQName(c.nodeName,X.namespaceResolver,c,1==c.nodeType);c[0]=String(c[0]);c[1]=String(c[1]);""==c[0]&&(c[0]= +null);return X.caseInsensitive?ka[0]==c[0]&&String(ka[1]).toLowerCase()==String(c[1]).toLowerCase():ka[0]==c[0]&&ka[1]==c[1]}break;case y.COMMENT:return 8==c.nodeType;case y.TEXT:return 3==c.nodeType||4==c.nodeType;case y.PI:return 7==c.nodeType&&(null==this.value||c.nodeName==this.value);case y.NODE:return 9==c.nodeType||1==c.nodeType||2==c.nodeType||3==c.nodeType||4==c.nodeType||8==c.nodeType||7==c.nodeType}return!1};y.NAMETESTANY=0;y.NAMETESTPREFIXANY=1;y.NAMETESTQNAME=2;y.COMMENT=3;y.TEXT=4;y.PI= +5;y.NODE=6;G.prototype=new I;G.prototype.constructor=G;G.superclass=I.prototype;G.prototype.init=function(c){this.variable=c};G.prototype.toString=function(){return"$"+this.variable};G.prototype.evaluate=function(c){return c.variableResolver.getVariable(this.variable,c)};M.prototype=new I;M.prototype.constructor=M;M.superclass=I.prototype;M.prototype.init=function(c,X){this.functionName=c;this.arguments=X};M.prototype.toString=function(){for(var c=this.functionName+"(",X=0;Xc.num)};Z.prototype.lessthanorequal=function(c){return ta.instance_of(c, +ia)?c.compareWithNumber(this,ua.greaterthan):ta.instance_of(c,ca)||ta.instance_of(c,S)?this.lessthanorequal(c.number()):new ca(this.num<=c.num)};Z.prototype.greaterthanorequal=function(c){return ta.instance_of(c,ia)?c.compareWithNumber(this,ua.lessthan):ta.instance_of(c,ca)||ta.instance_of(c,S)?this.greaterthanorequal(c.number()):new ca(this.num>=c.num)};Z.prototype.plus=function(c){return new Z(this.num+c.num)};Z.prototype.minus=function(c){return new Z(this.num-c.num)};Z.prototype.multiply=function(c){return new Z(this.num* +c.num)};Z.prototype.div=function(c){return new Z(this.num/c.num)};Z.prototype.mod=function(c){return new Z(this.num%c.num)};ca.prototype=new I;ca.prototype.constructor=ca;ca.superclass=I.prototype;ca.prototype.init=function(c){this.b=!!c};ca.prototype.toString=function(){return this.b.toString()};ca.prototype.evaluate=function(c){return this};ca.prototype.string=function(){return new S(this.b)};ca.prototype.number=function(){return new Z(this.b)};ca.prototype.bool=function(){return this};ca.prototype.nodeset= +function(){throw Error("Cannot convert boolean to nodeset");};ca.prototype.stringValue=function(){return this.string().stringValue()};ca.prototype.numberValue=function(){return this.num().numberValue()};ca.prototype.booleanValue=function(){return this.b};ca.prototype.not=function(){return new ca(!this.b)};ca.prototype.equals=function(c){return ta.instance_of(c,S)||ta.instance_of(c,Z)?this.equals(c.bool()):ta.instance_of(c,ia)?c.compareWithBoolean(this,ua.equals):new ca(this.b==c.b)};ca.prototype.notequal= +function(c){return ta.instance_of(c,S)||ta.instance_of(c,Z)?this.notequal(c.bool()):ta.instance_of(c,ia)?c.compareWithBoolean(this,ua.notequal):new ca(this.b!=c.b)};ca.prototype.lessthan=function(c){return ta.instance_of(c,ia)?c.compareWithNumber(this.number(),ua.greaterthanorequal):this.number().lessthan(c.number())};ca.prototype.greaterthan=function(c){return ta.instance_of(c,ia)?c.compareWithNumber(this.number(),ua.lessthanorequal):this.number().greaterthan(c.number())};ca.prototype.lessthanorequal= +function(c){return ta.instance_of(c,ia)?c.compareWithNumber(this.number(),ua.greaterthan):this.number().lessthanorequal(c.number())};ca.prototype.greaterthanorequal=function(c){return ta.instance_of(c,ia)?c.compareWithNumber(this.number(),ua.lessthan):this.number().greaterthanorequal(c.number())};ea.prototype={};ea.prototype.constructor=ea;ea.superclass=Object.prototype;ea.prototype.init=function(c){this.right=this.left=null;this.node=c;this.depth=1};ea.prototype.balance=function(){var c=null==this.left? +0:this.left.depth,X=null==this.right?0:this.right.depth;c>X+1?((null==this.left.left?0:this.left.left.depth)<(null==this.left.right?0:this.left.right.depth)&&this.left.rotateRR(),this.rotateLL()):c+1(null==this.right.right?0:this.right.right.depth)&&this.right.rotateLL(),this.rotateRR())};ea.prototype.rotateLL=function(){var c=this.node,X=this.right;this.node=this.left.node;this.right=this.left;this.left=this.left.left;this.right.left=this.right.right; +this.right.right=X;this.right.node=c;this.right.updateInNewLocation();this.updateInNewLocation()};ea.prototype.rotateRR=function(){var c=this.node,X=this.left;this.node=this.right.node;this.left=this.right;this.right=this.right.right;this.left.right=this.left.left;this.left.left=X;this.left.node=c;this.left.updateInNewLocation();this.updateInNewLocation()};ea.prototype.updateInNewLocation=function(){this.getDepthFromChildren()};ea.prototype.getDepthFromChildren=function(){this.depth=null==this.node? +0:1;null!=this.left&&(this.depth=this.left.depth+1);null!=this.right&&this.depth<=this.right.depth&&(this.depth=this.right.depth+1)};ea.prototype.order=function(c,X){if(c===X)return 0;for(var ka=0,ja=0,la=c;null!=la;la=la.parentNode)ka++;for(la=X;null!=la;la=la.parentNode)ja++;if(ka>ja){for(;ka>ja;)c=c.parentNode,ka--;if(c==X)return 1}else if(ja>ka){for(;ja>ka;)X=X.parentNode,ja--;if(c==X)return-1}for(;c.parentNode!=X.parentNode;)c=c.parentNode,X=X.parentNode;for(;null!=c.previousSibling&&null!=X.previousSibling;)c= +c.previousSibling,X=X.previousSibling;return null==c.previousSibling?-1:1};ea.prototype.add=function(c){if(c===this.node)return!1;var X=this.order(c,this.node),ka=!1;-1==X?null==this.left?(this.left=new ea(c),ka=!0):(ka=this.left.add(c))&&this.balance():1==X&&(null==this.right?(this.right=new ea(c),ka=!0):(ka=this.right.add(c))&&this.balance());ka&&this.getDepthFromChildren();return ka};ia.prototype=new I;ia.prototype.constructor=ia;ia.superclass=I.prototype;ia.prototype.init=function(){this.tree= +null;this.size=0};ia.prototype.toString=function(){var c=this.first();return null==c?"":this.stringForNode(c)};ia.prototype.evaluate=function(c){return this};ia.prototype.string=function(){return new S(this.toString())};ia.prototype.stringValue=function(){return this.toString()};ia.prototype.number=function(){return new Z(this.string())};ia.prototype.numberValue=function(){return Number(this.string())};ia.prototype.bool=function(){return new ca(null!=this.tree)};ia.prototype.booleanValue=function(){return null!= +this.tree};ia.prototype.nodeset=function(){return this};ia.prototype.stringForNode=function(c){9==c.nodeType&&(c=c.documentElement);return 1==c.nodeType?this.stringForNodeRec(c):c.isNamespaceNode?c.namespace:c.nodeValue};ia.prototype.stringForNodeRec=function(c){var X="";for(c=c.firstChild;null!=c;c=c.nextSibling)3==c.nodeType?X+=c.nodeValue:1==c.nodeType&&(X+=this.stringForNodeRec(c));return X};ia.prototype.first=function(){var c=this.tree;if(null==c)return null;for(;null!=c.left;)c=c.left;return c.node}; +ia.prototype.add=function(c){null==this.tree?(this.tree=new ea(c),c=!0):c=this.tree.add(c);c&&this.size++};ia.prototype.addArray=function(c){for(var X=0;Xarguments.length)throw Error("Function concat expects (string, string, string*)");for(var X="",ka=1;kac.length?"":c.charAt(la);ja[Ba]=Ha}}ka="";for(la=0;la=c||97<=c&&122>=c||192<=c&&214>=c||216<=c&&246>=c||248<=c&&255>=c||256<=c&&305>=c||308<=c&&318>=c||321<=c&&328>=c||330<=c&&382>=c||384<=c&&451>=c||461<=c&&496>=c||500<=c&&501>=c||506<=c&&535>=c||592<=c&&680>=c||699<=c&&705>=c||902==c||904<=c&&906>=c||908==c||910<=c&&929>=c||931<=c&&974>=c||976<=c&& +982>=c||986==c||988==c||990==c||992==c||994<=c&&1011>=c||1025<=c&&1036>=c||1038<=c&&1103>=c||1105<=c&&1116>=c||1118<=c&&1153>=c||1168<=c&&1220>=c||1223<=c&&1224>=c||1227<=c&&1228>=c||1232<=c&&1259>=c||1262<=c&&1269>=c||1272<=c&&1273>=c||1329<=c&&1366>=c||1369==c||1377<=c&&1414>=c||1488<=c&&1514>=c||1520<=c&&1522>=c||1569<=c&&1594>=c||1601<=c&&1610>=c||1649<=c&&1719>=c||1722<=c&&1726>=c||1728<=c&&1742>=c||1744<=c&&1747>=c||1749==c||1765<=c&&1766>=c||2309<=c&&2361>=c||2365==c||2392<=c&&2401>=c||2437<= +c&&2444>=c||2447<=c&&2448>=c||2451<=c&&2472>=c||2474<=c&&2480>=c||2482==c||2486<=c&&2489>=c||2524<=c&&2525>=c||2527<=c&&2529>=c||2544<=c&&2545>=c||2565<=c&&2570>=c||2575<=c&&2576>=c||2579<=c&&2600>=c||2602<=c&&2608>=c||2610<=c&&2611>=c||2613<=c&&2614>=c||2616<=c&&2617>=c||2649<=c&&2652>=c||2654==c||2674<=c&&2676>=c||2693<=c&&2699>=c||2701==c||2703<=c&&2705>=c||2707<=c&&2728>=c||2730<=c&&2736>=c||2738<=c&&2739>=c||2741<=c&&2745>=c||2749==c||2784==c||2821<=c&&2828>=c||2831<=c&&2832>=c||2835<=c&&2856>= +c||2858<=c&&2864>=c||2866<=c&&2867>=c||2870<=c&&2873>=c||2877==c||2908<=c&&2909>=c||2911<=c&&2913>=c||2949<=c&&2954>=c||2958<=c&&2960>=c||2962<=c&&2965>=c||2969<=c&&2970>=c||2972==c||2974<=c&&2975>=c||2979<=c&&2980>=c||2984<=c&&2986>=c||2990<=c&&2997>=c||2999<=c&&3001>=c||3077<=c&&3084>=c||3086<=c&&3088>=c||3090<=c&&3112>=c||3114<=c&&3123>=c||3125<=c&&3129>=c||3168<=c&&3169>=c||3205<=c&&3212>=c||3214<=c&&3216>=c||3218<=c&&3240>=c||3242<=c&&3251>=c||3253<=c&&3257>=c||3294==c||3296<=c&&3297>=c||3333<= +c&&3340>=c||3342<=c&&3344>=c||3346<=c&&3368>=c||3370<=c&&3385>=c||3424<=c&&3425>=c||3585<=c&&3630>=c||3632==c||3634<=c&&3635>=c||3648<=c&&3653>=c||3713<=c&&3714>=c||3716==c||3719<=c&&3720>=c||3722==c||3725==c||3732<=c&&3735>=c||3737<=c&&3743>=c||3745<=c&&3747>=c||3749==c||3751==c||3754<=c&&3755>=c||3757<=c&&3758>=c||3760==c||3762<=c&&3763>=c||3773==c||3776<=c&&3780>=c||3904<=c&&3911>=c||3913<=c&&3945>=c||4256<=c&&4293>=c||4304<=c&&4342>=c||4352==c||4354<=c&&4355>=c||4357<=c&&4359>=c||4361==c||4363<= +c&&4364>=c||4366<=c&&4370>=c||4412==c||4414==c||4416==c||4428==c||4430==c||4432==c||4436<=c&&4437>=c||4441==c||4447<=c&&4449>=c||4451==c||4453==c||4455==c||4457==c||4461<=c&&4462>=c||4466<=c&&4467>=c||4469==c||4510==c||4520==c||4523==c||4526<=c&&4527>=c||4535<=c&&4536>=c||4538==c||4540<=c&&4546>=c||4587==c||4592==c||4601==c||7680<=c&&7835>=c||7840<=c&&7929>=c||7936<=c&&7957>=c||7960<=c&&7965>=c||7968<=c&&8005>=c||8008<=c&&8013>=c||8016<=c&&8023>=c||8025==c||8027==c||8029==c||8031<=c&&8061>=c||8064<= +c&&8116>=c||8118<=c&&8124>=c||8126==c||8130<=c&&8132>=c||8134<=c&&8140>=c||8144<=c&&8147>=c||8150<=c&&8155>=c||8160<=c&&8172>=c||8178<=c&&8180>=c||8182<=c&&8188>=c||8486==c||8490<=c&&8491>=c||8494==c||8576<=c&&8578>=c||12353<=c&&12436>=c||12449<=c&&12538>=c||12549<=c&&12588>=c||44032<=c&&55203>=c||19968<=c&&40869>=c||12295==c||12321<=c&&12329>=c},isNCNameChar:function(c){return 48<=c&&57>=c||1632<=c&&1641>=c||1776<=c&&1785>=c||2406<=c&&2415>=c||2534<=c&&2543>=c||2662<=c&&2671>=c||2790<=c&&2799>=c|| +2918<=c&&2927>=c||3047<=c&&3055>=c||3174<=c&&3183>=c||3302<=c&&3311>=c||3430<=c&&3439>=c||3664<=c&&3673>=c||3792<=c&&3801>=c||3872<=c&&3881>=c||46==c||45==c||95==c||ta.isLetter(c)||768<=c&&837>=c||864<=c&&865>=c||1155<=c&&1158>=c||1425<=c&&1441>=c||1443<=c&&1465>=c||1467<=c&&1469>=c||1471==c||1473<=c&&1474>=c||1476==c||1611<=c&&1618>=c||1648==c||1750<=c&&1756>=c||1757<=c&&1759>=c||1760<=c&&1764>=c||1767<=c&&1768>=c||1770<=c&&1773>=c||2305<=c&&2307>=c||2364==c||2366<=c&&2380>=c||2381==c||2385<=c&& +2388>=c||2402<=c&&2403>=c||2433<=c&&2435>=c||2492==c||2494==c||2495==c||2496<=c&&2500>=c||2503<=c&&2504>=c||2507<=c&&2509>=c||2519==c||2530<=c&&2531>=c||2562==c||2620==c||2622==c||2623==c||2624<=c&&2626>=c||2631<=c&&2632>=c||2635<=c&&2637>=c||2672<=c&&2673>=c||2689<=c&&2691>=c||2748==c||2750<=c&&2757>=c||2759<=c&&2761>=c||2763<=c&&2765>=c||2817<=c&&2819>=c||2876==c||2878<=c&&2883>=c||2887<=c&&2888>=c||2891<=c&&2893>=c||2902<=c&&2903>=c||2946<=c&&2947>=c||3006<=c&&3010>=c||3014<=c&&3016>=c||3018<= +c&&3021>=c||3031==c||3073<=c&&3075>=c||3134<=c&&3140>=c||3142<=c&&3144>=c||3146<=c&&3149>=c||3157<=c&&3158>=c||3202<=c&&3203>=c||3262<=c&&3268>=c||3270<=c&&3272>=c||3274<=c&&3277>=c||3285<=c&&3286>=c||3330<=c&&3331>=c||3390<=c&&3395>=c||3398<=c&&3400>=c||3402<=c&&3405>=c||3415==c||3633==c||3636<=c&&3642>=c||3655<=c&&3662>=c||3761==c||3764<=c&&3769>=c||3771<=c&&3772>=c||3784<=c&&3789>=c||3864<=c&&3865>=c||3893==c||3895==c||3897==c||3902==c||3903==c||3953<=c&&3972>=c||3974<=c&&3979>=c||3984<=c&&3989>= +c||3991==c||3993<=c&&4013>=c||4017<=c&&4023>=c||4025==c||8400<=c&&8412>=c||8417==c||12330<=c&&12335>=c||12441==c||12442==c||183==c||720==c||721==c||903==c||1600==c||3654==c||3782==c||12293==c||12337<=c&&12341>=c||12445<=c&&12446>=c||12540<=c&&12542>=c},coalesceText:function(c){for(c=c.firstChild;null!=c;c=c.nextSibling)if(3==c.nodeType||4==c.nodeType){var X=c.nodeValue,ka=c;for(c=c.nextSibling;null!=c&&(3==c.nodeType||4==c.nodeType);){X+=c.nodeValue;var ja=c;c=c.nextSibling;ja.parentNode.removeChild(ja)}if(4== +ka.nodeType)if(ja=ka.parentNode,null==ka.nextSibling)ja.removeChild(ka),ja.appendChild(ja.ownerDocument.createTextNode(X));else{var la=ka.nextSibling;ja.removeChild(ka);ja.insertBefore(ja.ownerDocument.createTextNode(X),la)}else ka.nodeValue=X;if(null==c)break}else 1==c.nodeType&&ta.coalesceText(c)},instance_of:function(c,X){for(;null!=c;){if(c.constructor===X)return!0;if(c===Object)break;c=c.constructor.superclass}return!1},getElementById:function(c,X){if(1==c.nodeType&&(c.getAttribute("id")==X|| +c.getAttributeNS(null,"id")==X))return c;for(c=c.firstChild;null!=c;c=c.nextSibling){var ka=ta.getElementById(c,X);if(null!=ka)return ka}return null}};U.prototype={};U.prototype.constructor=U;U.superclass=Object.prototype;U.prototype.toString=function(){var c=this.exception?": "+this.exception.toString():"";switch(this.code){case U.INVALID_EXPRESSION_ERR:return"Invalid expression"+c;case U.TYPE_ERR:return"Type error"+c}};U.INVALID_EXPRESSION_ERR=51;U.TYPE_ERR=52;N.prototype={};N.prototype.constructor= +N;N.superclass=Object.prototype;N.prototype.evaluate=function(c,X,ka){this.context.expressionContextNode=c;c=this.xpath.evaluate(this.context);return new pa(c,X)};O.prototype={};O.prototype.constructor=O;O.superclass=Object.prototype;O.prototype.getNamespace=function(c,X){return null==this.xpathNSResolver?null:this.xpathNSResolver.lookupNamespaceURI(c)};K.prototype={};K.prototype.constructor=K;K.superclass=Object.prototype;K.prototype.lookupNamespaceURI=function(c){return this.namespaceResolver.getNamespace(c, +this.node)};pa.prototype={};pa.prototype.constructor=pa;pa.superclass=Object.prototype;pa.prototype.iterateNext=function(){if(this.resultType!=pa.UNORDERED_NODE_ITERATOR_TYPE&&this.resultType!=pa.ORDERED_NODE_ITERATOR_TYPE)throw new U(U.TYPE_ERR);return this.nodes[this.iteratorIndex++]};pa.prototype.snapshotItem=function(c){if(this.resultType!=pa.UNORDERED_NODE_SNAPSHOT_TYPE&&this.resultType!=pa.ORDERED_NODE_SNAPSHOT_TYPE)throw new U(U.TYPE_ERR);return this.nodes[c]};pa.ANY_TYPE=0;pa.NUMBER_TYPE= +1;pa.STRING_TYPE=2;pa.BOOLEAN_TYPE=3;pa.UNORDERED_NODE_ITERATOR_TYPE=4;pa.ORDERED_NODE_ITERATOR_TYPE=5;pa.UNORDERED_NODE_SNAPSHOT_TYPE=6;pa.ORDERED_NODE_SNAPSHOT_TYPE=7;pa.ANY_UNORDERED_NODE_TYPE=8;pa.FIRST_ORDERED_NODE_TYPE=9;try{E=!0;try{document.implementation&&document.implementation.hasFeature&&document.implementation.hasFeature("XPath",null)&&(E=!1)}catch(c){}E&&xa(document,new C)}catch(c){}Q.exports=function(c,X){X=(new C).parse(X);var ka=new r;ka.expressionContextNode=c.documentElement?c.documentElement: +c;return X.evaluate(ka).toArray()}},function(Q,E,C){(function(u){function I(f,k){this._id=f;this._clearFn=k}var V="undefined"!==typeof u&&u||"undefined"!==typeof self&&self||window,q=Function.prototype.apply;E.setTimeout=function(){return new I(q.call(setTimeout,V,arguments),clearTimeout)};E.setInterval=function(){return new I(q.call(setInterval,V,arguments),clearInterval)};E.clearTimeout=E.clearInterval=function(f){f&&f.close()};I.prototype.unref=I.prototype.ref=function(){};I.prototype.close=function(){this._clearFn.call(V, +this._id)};E.enroll=function(f,k){clearTimeout(f._idleTimeoutId);f._idleTimeout=k};E.unenroll=function(f){clearTimeout(f._idleTimeoutId);f._idleTimeout=-1};E._unrefActive=E.active=function(f){clearTimeout(f._idleTimeoutId);var k=f._idleTimeout;0<=k&&(f._idleTimeoutId=setTimeout(function(){f._onTimeout&&f._onTimeout()},k))};C(73);E.setImmediate="undefined"!==typeof self&&self.setImmediate||"undefined"!==typeof u&&u.setImmediate||this&&this.setImmediate;E.clearImmediate="undefined"!==typeof self&&self.clearImmediate|| +"undefined"!==typeof u&&u.clearImmediate||this&&this.clearImmediate}).call(this,C(18))},function(Q,E,C){(function(u,I){(function(V,q){function f(e){delete x[e]}function k(e){if(z)setTimeout(k,0,e);else{var w=x[e];if(w){z=!0;try{var J=w.callback,h=w.args;switch(h.length){case 0:J();break;case 1:J(h[0]);break;case 2:J(h[0],h[1]);break;case 3:J(h[0],h[1],h[2]);break;default:J.apply(q,h)}}finally{f(e),z=!1}}}}function d(){P=function(e){I.nextTick(function(){k(e)})}}function g(){if(V.postMessage&&!V.importScripts){var e= +!0,w=V.onmessage;V.onmessage=function(){e=!1};V.postMessage("","*");V.onmessage=w;return e}}function t(){var e="setImmediate$"+Math.random()+"$",w=function(J){J.source===V&&"string"===typeof J.data&&0===J.data.indexOf(e)&&k(+J.data.slice(e.length))};V.addEventListener?V.addEventListener("message",w,!1):V.attachEvent("onmessage",w);P=function(J){V.postMessage(e+J,"*")}}function A(){var e=new MessageChannel;e.port1.onmessage=function(w){k(w.data)};P=function(w){e.port2.postMessage(w)}}function W(){var e= +m.documentElement;P=function(w){var J=m.createElement("script");J.onreadystatechange=function(){k(w);J.onreadystatechange=null;e.removeChild(J);J=null};e.appendChild(J)}}function F(){P=function(e){setTimeout(k,0,e)}}if(!V.setImmediate){var H=1,x={},z=!1,m=V.document,P,l=Object.getPrototypeOf&&Object.getPrototypeOf(V);l=l&&l.setTimeout?l:V;"[object process]"==={}.toString.call(V.process)?d():g()?t():V.MessageChannel?A():m&&"onreadystatechange"in m.createElement("script")?W():F();l.setImmediate=function(e){"function"!== +typeof e&&(e=new Function(""+e));for(var w=Array(arguments.length-1),J=0;J>= +8;for(;0>=8}for(k=0;q[k]===f&&k=d.Versions.TLS_1_1.minor&&t.output.putBytes(W);t.update(g.fragment);t.finish(V)&&(g.fragment=t.output,g.length=g.fragment.length(),A=!0);return A}function V(g,t,A){A||(g-=t.length()%g,t.fillWithByte(g-1,g));return!0}function q(g,t,A){g=!0;if(A){A=t.length();for(var W=t.last(),F=A-1-W;F=F?(g.fragment=W.output.getBytes(x-F),H=W.output.getBytes(F)):g.fragment=W.output.getBytes();g.fragment=k.util.createBuffer(g.fragment);g.length=g.fragment.length();g=t.macFunction(t.macKey,t.sequenceNumber,g);t.updateSequenceNumber();t=t.macKey;W=k.hmac.create();W.start("SHA1",t);W.update(H);H=W.digest().getBytes();W.start(null,null);W.update(g);g=W.digest().getBytes(); +return H===g&&A}var k=C(5);C(19);C(49);var d=Q.exports=k.tls;d.CipherSuites.TLS_RSA_WITH_AES_128_CBC_SHA={id:[0,47],name:"TLS_RSA_WITH_AES_128_CBC_SHA",initSecurityParameters:function(g){g.bulk_cipher_algorithm=d.BulkCipherAlgorithm.aes;g.cipher_type=d.CipherType.block;g.enc_key_length=16;g.block_length=16;g.fixed_iv_length=16;g.record_iv_length=16;g.mac_algorithm=d.MACAlgorithm.hmac_sha1;g.mac_length=20;g.mac_key_length=20},initConnectionState:u};d.CipherSuites.TLS_RSA_WITH_AES_256_CBC_SHA={id:[0, +53],name:"TLS_RSA_WITH_AES_256_CBC_SHA",initSecurityParameters:function(g){g.bulk_cipher_algorithm=d.BulkCipherAlgorithm.aes;g.cipher_type=d.CipherType.block;g.enc_key_length=32;g.block_length=16;g.fixed_iv_length=16;g.record_iv_length=16;g.mac_algorithm=d.MACAlgorithm.hmac_sha1;g.mac_length=20;g.mac_key_length=20},initConnectionState:u}},function(Q,E,C){E=C(5);C(59);Q.exports=E.mgf=E.mgf||{};E.mgf.mgf1=E.mgf1},function(Q,E,C){(function(u){function I(N){var O=N.message;if(O instanceof Uint8Array|| +O instanceof Z)return O;var K=N.encoding;if(void 0===O)if(N.md)O=N.md.digest().getBytes(),K="binary";else throw new TypeError('"options.message" or "options.md" not specified.');if("string"===typeof O&&!K)throw new TypeError('"options.encoding" must be "binary" or "utf8".');if("string"===typeof O){if("undefined"!==typeof u)return u.from(O,K);O=new S(O,K)}else if(!(O instanceof S))throw new TypeError('"options.message" must be a node.js Buffer, a Uint8Array, a forge ByteBuffer, or a string with "options.encoding" specifying its encoding.'); +N=new Z(O.length());for(K=0;KN;++N)K[N]=O.charCodeAt(N);return K}function q(N,O){var K,pa;for(K=63;32<=K;--K){var xa=0;var ua=K-32;for(pa=K-12;ua>8,O[ua]-=256*xa;O[ua]+=xa;O[K]=0}for(ua=xa=0;32>ua;++ua)O[ua]+= +xa-(O[31]>>4)*D[ua],xa=O[ua]>>8,O[ua]&=255;for(ua=0;32>ua;++ua)O[ua]-=xa*D[ua];for(K=0;32>K;++K)O[K+1]+=O[K]>>8,N[K]=O[K]&255}function f(N){for(var O=new Float64Array(64),K=0;64>K;++K)O[K]=N[K],N[K]=0;q(N,O)}function k(N,O){var K=P(),pa=P(),xa=P(),ua=P(),za=P(),ta=P(),c=P(),X=P(),ka=P();e(K,N[1],N[0]);e(ka,O[1],O[0]);w(K,K,ka);l(pa,N[0],N[1]);l(ka,O[0],O[1]);w(pa,pa,ka);w(xa,N[3],O[3]);w(xa,xa,r);w(ua,N[2],O[2]);l(ua,ua,ua);e(za,pa,K);e(ta,ua,xa);l(c,ua,xa);l(X,pa,K);w(N[0],za,ta);w(N[1],X,c);w(N[2], +c,ta);w(N[3],za,X)}function d(N,O){var K=P(),pa=P(),xa=P(),ua=O[2],za=P(),ta;for(ta=0;16>ta;++ta)za[ta]=ua[ta];for(ta=253;0<=ta;--ta)w(za,za,za),2!==ta&&4!==ta&&w(za,za,ua);for(ta=0;16>ta;++ta)xa[ta]=za[ta];w(K,O[0],xa);w(pa,O[1],xa);g(N,pa);N[31]^=W(K)<<7}function g(N,O){var K,pa=P(),xa=P();for(K=0;16>K;++K)xa[K]=O[K];z(xa);z(xa);z(xa);for(O=0;2>O;++O){pa[0]=xa[0]-65517;for(K=1;15>K;++K)pa[K]=xa[K]-65535-(pa[K-1]>>16&1),pa[K-1]&=65535;pa[15]=xa[15]-32767-(pa[14]>>16&1);K=pa[15]>>16&1;pa[14]&=65535; +m(xa,pa,1-K)}for(K=0;16>K;K++)N[2*K]=xa[K]&255,N[2*K+1]=xa[K]>>8}function t(N,O){var K=new Z(32),pa=new Z(32);g(K,N);g(pa,O);return A(K,0,pa,0)}function A(N,O,K,pa){var xa,ua=0;for(xa=0;32>xa;++xa)ua|=N[O+xa]^K[pa+xa];return(1&ua-1>>>8)-1}function W(N){var O=new Z(32);g(O,N);return O[0]&1}function F(N,O,K){var pa;x(N[0],ea);x(N[1],ia);x(N[2],ia);x(N[3],ea);for(pa=255;0<=pa;--pa){var xa=K[pa/8|0]>>(pa&7)&1;for(var ua=N,za=O,ta=xa,c=0;4>c;++c)m(ua[c],za[c],ta);k(O,N);k(N,N);ua=N;za=O;for(ta=0;4>ta;++ta)m(ua[ta], +za[ta],xa)}}function H(N,O){var K=[P(),P(),P(),P()];x(K[0],n);x(K[1],v);x(K[2],ia);w(K[3],n,v);F(N,K,O)}function x(N,O){var K;for(K=0;16>K;K++)N[K]=O[K]|0}function z(N){var O,K=1;for(O=0;16>O;++O){var pa=N[O]+K+65535;K=Math.floor(pa/65536);N[O]=pa-65536*K}N[0]+=K-1+37*(K-1)}function m(N,O,K){for(var pa=~(K-1),xa=0;16>xa;++xa)K=pa&(N[xa]^O[xa]),N[xa]^=K,O[xa]^=K}function P(N){var O,K=new Float64Array(16);if(N)for(O=0;Opa;++pa)N[pa]= +O[pa]+K[pa]}function e(N,O,K){for(var pa=0;16>pa;++pa)N[pa]=O[pa]-K[pa]}function w(N,O,K){var pa=K[0],xa=K[1],ua=K[2],za=K[3],ta=K[4],c=K[5],X=K[6],ka=K[7],ja=K[8],la=K[9],Ba=K[10],Ha=K[11],Ma=K[12],Sa=K[13],Ka=K[14],Ia=K[15];K=O[0];var Ra=K*pa;var db=K*xa;var Va=K*ua;var gb=K*za;var nb=K*ta;var da=K*c;var fa=K*X;var wa=K*ka;var ya=K*ja;var b=K*la;var R=K*Ba;var ba=K*Ha;var ra=K*Ma;var oa=K*Sa;var Da=K*Ka;var Fa=K*Ia;K=O[1];db+=K*pa;Va+=K*xa;gb+=K*ua;nb+=K*za;da+=K*ta;fa+=K*c;wa+=K*X;ya+=K*ka;b+= +K*ja;R+=K*la;ba+=K*Ba;ra+=K*Ha;oa+=K*Ma;Da+=K*Sa;Fa+=K*Ka;var Oa=K*Ia;K=O[2];Va+=K*pa;gb+=K*xa;nb+=K*ua;da+=K*za;fa+=K*ta;wa+=K*c;ya+=K*X;b+=K*ka;R+=K*ja;ba+=K*la;ra+=K*Ba;oa+=K*Ha;Da+=K*Ma;Fa+=K*Sa;Oa+=K*Ka;var Pa=K*Ia;K=O[3];gb+=K*pa;nb+=K*xa;da+=K*ua;fa+=K*za;wa+=K*ta;ya+=K*c;b+=K*X;R+=K*ka;ba+=K*ja;ra+=K*la;oa+=K*Ba;Da+=K*Ha;Fa+=K*Ma;Oa+=K*Sa;Pa+=K*Ka;var ab=K*Ia;K=O[4];nb+=K*pa;da+=K*xa;fa+=K*ua;wa+=K*za;ya+=K*ta;b+=K*c;R+=K*X;ba+=K*ka;ra+=K*ja;oa+=K*la;Da+=K*Ba;Fa+=K*Ha;Oa+=K*Ma;Pa+=K*Sa;ab+= +K*Ka;var fb=K*Ia;K=O[5];da+=K*pa;fa+=K*xa;wa+=K*ua;ya+=K*za;b+=K*ta;R+=K*c;ba+=K*X;ra+=K*ka;oa+=K*ja;Da+=K*la;Fa+=K*Ba;Oa+=K*Ha;Pa+=K*Ma;ab+=K*Sa;fb+=K*Ka;var mb=K*Ia;K=O[6];fa+=K*pa;wa+=K*xa;ya+=K*ua;b+=K*za;R+=K*ta;ba+=K*c;ra+=K*X;oa+=K*ka;Da+=K*ja;Fa+=K*la;Oa+=K*Ba;Pa+=K*Ha;ab+=K*Ma;fb+=K*Sa;mb+=K*Ka;var rb=K*Ia;K=O[7];wa+=K*pa;ya+=K*xa;b+=K*ua;R+=K*za;ba+=K*ta;ra+=K*c;oa+=K*X;Da+=K*ka;Fa+=K*ja;Oa+=K*la;Pa+=K*Ba;ab+=K*Ha;fb+=K*Ma;mb+=K*Sa;rb+=K*Ka;var Na=K*Ia;K=O[8];ya+=K*pa;b+=K*xa;R+=K*ua;ba+= +K*za;ra+=K*ta;oa+=K*c;Da+=K*X;Fa+=K*ka;Oa+=K*ja;Pa+=K*la;ab+=K*Ba;fb+=K*Ha;mb+=K*Ma;rb+=K*Sa;Na+=K*Ka;var Za=K*Ia;K=O[9];b+=K*pa;R+=K*xa;ba+=K*ua;ra+=K*za;oa+=K*ta;Da+=K*c;Fa+=K*X;Oa+=K*ka;Pa+=K*ja;ab+=K*la;fb+=K*Ba;mb+=K*Ha;rb+=K*Ma;Na+=K*Sa;Za+=K*Ka;var bb=K*Ia;K=O[10];R+=K*pa;ba+=K*xa;ra+=K*ua;oa+=K*za;Da+=K*ta;Fa+=K*c;Oa+=K*X;Pa+=K*ka;ab+=K*ja;fb+=K*la;mb+=K*Ba;rb+=K*Ha;Na+=K*Ma;Za+=K*Sa;bb+=K*Ka;var $a=K*Ia;K=O[11];ba+=K*pa;ra+=K*xa;oa+=K*ua;Da+=K*za;Fa+=K*ta;Oa+=K*c;Pa+=K*X;ab+=K*ka;fb+=K*ja; +mb+=K*la;rb+=K*Ba;Na+=K*Ha;Za+=K*Ma;bb+=K*Sa;$a+=K*Ka;var Cb=K*Ia;K=O[12];ra+=K*pa;oa+=K*xa;Da+=K*ua;Fa+=K*za;Oa+=K*ta;Pa+=K*c;ab+=K*X;fb+=K*ka;mb+=K*ja;rb+=K*la;Na+=K*Ba;Za+=K*Ha;bb+=K*Ma;$a+=K*Sa;Cb+=K*Ka;var p=K*Ia;K=O[13];oa+=K*pa;Da+=K*xa;Fa+=K*ua;Oa+=K*za;Pa+=K*ta;ab+=K*c;fb+=K*X;mb+=K*ka;rb+=K*ja;Na+=K*la;Za+=K*Ba;bb+=K*Ha;$a+=K*Ma;Cb+=K*Sa;p+=K*Ka;var T=K*Ia;K=O[14];Da+=K*pa;Fa+=K*xa;Oa+=K*ua;Pa+=K*za;ab+=K*ta;fb+=K*c;mb+=K*X;rb+=K*ka;Na+=K*ja;Za+=K*la;bb+=K*Ba;$a+=K*Ha;Cb+=K*Ma;p+=K*Sa;T+= +K*Ka;var aa=K*Ia;K=O[15];Fa+=K*pa;db+=38*(Pa+K*ua);Va+=38*(ab+K*za);gb+=38*(fb+K*ta);nb+=38*(mb+K*c);da+=38*(rb+K*X);fa+=38*(Na+K*ka);wa+=38*(Za+K*ja);ya+=38*(bb+K*la);b+=38*($a+K*Ba);R+=38*(Cb+K*Ha);ba+=38*(p+K*Ma);ra+=38*(T+K*Sa);oa+=38*(aa+K*Ka);Da+=38*K*Ia;K=Ra+38*(Oa+K*xa)+1+65535;O=Math.floor(K/65536);Ra=K-65536*O;K=db+O+65535;O=Math.floor(K/65536);db=K-65536*O;K=Va+O+65535;O=Math.floor(K/65536);Va=K-65536*O;K=gb+O+65535;O=Math.floor(K/65536);gb=K-65536*O;K=nb+O+65535;O=Math.floor(K/65536); +nb=K-65536*O;K=da+O+65535;O=Math.floor(K/65536);da=K-65536*O;K=fa+O+65535;O=Math.floor(K/65536);fa=K-65536*O;K=wa+O+65535;O=Math.floor(K/65536);wa=K-65536*O;K=ya+O+65535;O=Math.floor(K/65536);ya=K-65536*O;K=b+O+65535;O=Math.floor(K/65536);b=K-65536*O;K=R+O+65535;O=Math.floor(K/65536);R=K-65536*O;K=ba+O+65535;O=Math.floor(K/65536);ba=K-65536*O;K=ra+O+65535;O=Math.floor(K/65536);ra=K-65536*O;K=oa+O+65535;O=Math.floor(K/65536);oa=K-65536*O;K=Da+O+65535;O=Math.floor(K/65536);Da=K-65536*O;K=Fa+O+65535; +O=Math.floor(K/65536);Fa=K-65536*O;Ra+=O-1+37*(O-1);K=Ra+1+65535;O=Math.floor(K/65536);Ra=K-65536*O;K=db+O+65535;O=Math.floor(K/65536);db=K-65536*O;K=Va+O+65535;O=Math.floor(K/65536);Va=K-65536*O;K=gb+O+65535;O=Math.floor(K/65536);gb=K-65536*O;K=nb+O+65535;O=Math.floor(K/65536);nb=K-65536*O;K=da+O+65535;O=Math.floor(K/65536);da=K-65536*O;K=fa+O+65535;O=Math.floor(K/65536);fa=K-65536*O;K=wa+O+65535;O=Math.floor(K/65536);wa=K-65536*O;K=ya+O+65535;O=Math.floor(K/65536);ya=K-65536*O;K=b+O+65535;O=Math.floor(K/ +65536);b=K-65536*O;K=R+O+65535;O=Math.floor(K/65536);R=K-65536*O;K=ba+O+65535;O=Math.floor(K/65536);ba=K-65536*O;K=ra+O+65535;O=Math.floor(K/65536);ra=K-65536*O;K=oa+O+65535;O=Math.floor(K/65536);oa=K-65536*O;K=Da+O+65535;O=Math.floor(K/65536);Da=K-65536*O;K=Fa+O+65535;O=Math.floor(K/65536);N[0]=Ra+(O-1+37*(O-1));N[1]=db;N[2]=Va;N[3]=gb;N[4]=nb;N[5]=da;N[6]=fa;N[7]=wa;N[8]=ya;N[9]=b;N[10]=R;N[11]=ba;N[12]=ra;N[13]=oa;N[14]=Da;N[15]=K-65536*O}var J=C(5);C(35);C(13);C(61);C(7);var h=C(78),y=h.publicKeyValidator, +G=h.privateKeyValidator;if("undefined"===typeof M)var M=J.jsbn.BigInteger;var S=J.util.ByteBuffer,Z="undefined"===typeof u?Uint8Array:u;J.pki=J.pki||{};Q.exports=J.pki.ed25519=J.ed25519=J.ed25519||{};var ca=J.ed25519;ca.constants={};ca.constants.PUBLIC_KEY_BYTE_LENGTH=32;ca.constants.PRIVATE_KEY_BYTE_LENGTH=64;ca.constants.SEED_BYTE_LENGTH=32;ca.constants.SIGN_BYTE_LENGTH=64;ca.constants.HASH_BYTE_LENGTH=64;ca.generateKeyPair=function(N){N=N||{};var O=N.seed;if(void 0===O)O=J.random.getBytesSync(ca.constants.SEED_BYTE_LENGTH); +else if("string"===typeof O){if(O.length!==ca.constants.SEED_BYTE_LENGTH)throw new TypeError('"seed" must be '+ca.constants.SEED_BYTE_LENGTH+" bytes in length.");}else if(!(O instanceof Uint8Array))throw new TypeError('"seed" must be a node.js Buffer, Uint8Array, or a binary string.');O=I({message:O,encoding:"binary"});N=new Z(ca.constants.PUBLIC_KEY_BYTE_LENGTH);for(var K=new Z(ca.constants.PRIVATE_KEY_BYTE_LENGTH),pa=0;32>pa;++pa)K[pa]=O[pa];O=[P(),P(),P(),P()];pa=V(K,32);pa[0]&=248;pa[31]&=127; +pa[31]|=64;H(O,pa);d(N,O);for(O=0;32>O;++O)K[O+32]=N[O];return{publicKey:N,privateKey:K}};ca.privateKeyFromAsn1=function(N){var O={},K=[];if(!J.asn1.validate(N,G,O,K))throw O=Error("Invalid Key."),O.errors=K,O;K=J.asn1.derToOid(O.privateKeyOid);N=J.oids.EdDSA25519;if(K!==N)throw Error('Invalid OID "'+K+'"; OID must be "'+N+'".');return{privateKeyBytes:I({message:J.asn1.fromDer(O.privateKey).value,encoding:"binary"})}};ca.publicKeyFromAsn1=function(N){var O={},K=[];if(!J.asn1.validate(N,y,O,K))throw O= +Error("Invalid Key."),O.errors=K,O;K=J.asn1.derToOid(O.publicKeyOid);N=J.oids.EdDSA25519;if(K!==N)throw Error('Invalid OID "'+K+'"; OID must be "'+N+'".');O=O.ed25519PublicKey;if(O.length!==ca.constants.PUBLIC_KEY_BYTE_LENGTH)throw Error("Key length is invalid.");return I({message:O,encoding:"binary"})};ca.publicKeyFromPrivateKey=function(N){N=N||{};N=I({message:N.privateKey,encoding:"binary"});if(N.length!==ca.constants.PRIVATE_KEY_BYTE_LENGTH)throw new TypeError('"options.privateKey" must have a byte length of '+ +ca.constants.PRIVATE_KEY_BYTE_LENGTH);for(var O=new Z(ca.constants.PUBLIC_KEY_BYTE_LENGTH),K=0;KK;++K)N[32+K]=ta[32+K];O=V(N.subarray(32),pa+32);f(O);H(za,O);d(N,za);for(K=32;64>K;++K)N[K]=xa[K];pa=V(N,pa+64);f(pa);for(K=32;64>K;++K)ua[K]=0;for(K=0;32>K;++K)ua[K]=O[K];for(K=0;32>K;++K)for(O=0;32>O;O++)ua[K+O]+=pa[K]*ta[O];q(N.subarray(32),ua);K=new Z(ca.constants.SIGN_BYTE_LENGTH);for(ua=0;ua< +K.length;++ua)K[ua]=N[ua];return K};ca.verify=function(N){N=N||{};var O=I(N);if(void 0===N.signature)throw new TypeError('"options.signature" must be a node.js Buffer, a Uint8Array, a forge ByteBuffer, or a binary string.');var K=I({message:N.signature,encoding:"binary"});if(K.length!==ca.constants.SIGN_BYTE_LENGTH)throw new TypeError('"options.signature" must have a byte length of '+ca.constants.SIGN_BYTE_LENGTH);var pa=I({message:N.publicKey,encoding:"binary"});if(pa.length!==ca.constants.PUBLIC_KEY_BYTE_LENGTH)throw new TypeError('"options.publicKey" must have a byte length of '+ +ca.constants.PUBLIC_KEY_BYTE_LENGTH);N=new Z(ca.constants.SIGN_BYTE_LENGTH+O.length);var xa=new Z(ca.constants.SIGN_BYTE_LENGTH+O.length),ua;for(ua=0;uaO)N=-1;else{var ta=P();var c=P();var X=P(),ka=P(),ja=P(),la=P(),Ba=P();x(za[2],ia);var Ha=za[1],Ma;for(Ma=0;16>Ma;++Ma)Ha[Ma]=pa[2*Ma]+(pa[2*Ma+1]<<8);Ha[15]&= +32767;Ha=za[1];w(X,Ha,Ha);w(ka,X,na);e(X,X,za[2]);l(ka,za[2],ka);w(ja,ka,ka);w(la,ja,ja);w(Ba,la,ja);w(ta,Ba,X);w(ta,ta,ka);ja=P();for(la=0;16>la;++la)ja[la]=ta[la];for(la=250;0<=la;--la)w(ja,ja,ja),1!==la&&w(ja,ja,ta);for(la=0;16>la;++la)ta[la]=ja[la];w(ta,ta,X);w(ta,ta,ka);w(ta,ta,ka);w(za[0],ta,ka);ta=za[0];w(c,ta,ta);w(c,c,ka);t(c,X)&&w(za[0],za[0],U);ta=za[0];w(c,ta,ta);w(c,c,ka);t(c,X)?c=-1:(W(za[0])===pa[31]>>7&&e(za[0],ea,za[0]),w(za[3],za[0],za[1]),c=0);if(c)N=-1;else{for(c=0;cc;++c)xa[c+32]=pa[c];pa=V(xa,O);f(pa);F(ua,za,pa);H(za,N.subarray(32));k(ua,za);d(K,ua);O-=64;if(A(N,0,K,0)){for(c=0;c=A.compareTo(V.ONE));A=I.util.hexToBytes(A.toString(16));t-=A.length;0=g&&AS)S=1;M/=S;var Z=Math.pow(2,Math.log(Math.abs(M))/Math.log(2)-52);M+=0<=M?Z:-Z;return(0>M?-1:1)*Math.round(Math.abs(M))*S}function I(M){return void 0===M||null===M?"":M.toString()}function V(M){return function(S){var Z=I(S);if(Z.length> +M)throw Error("Value ".concat(S," is longer thant ").concat(M,"."));return Z}}function q(M){return function(S){var Z=I(S);if(!M.test(Z))throw Z=M.toString(),Error("Value ".concat(S," does not match ").concat(Z,"."));return Z}}function f(M){if(M instanceof Date){var S=("00"+M.getDate()).slice(-2),Z=("00"+(M.getMonth()+1)).slice(-2);M=M.getFullYear().toString();return"".concat(S,"-").concat(Z,"-").concat(M)}throw Error("Date expected and ".concat(M," found."));}function k(M){if(M instanceof Date){var S= +("00"+M.getHours()).slice(-2),Z=("00"+M.getMinutes()).slice(-2);M=("00"+M.getSeconds()).slice(-2);return"".concat(S,":").concat(Z,":").concat(M)}throw Error("Date expected and ".concat(M," found."));}function d(M){if("number"===typeof M)return u(M,.01).toFixed(2);throw Error("Number expected and ".concat(M," found."));}function g(M,S){var Z="undefined"!==typeof Symbol&&M[Symbol.iterator]||M["@@iterator"];if(!Z){if(Array.isArray(M)||(Z=t(M))||S&&M&&"number"===typeof M.length){Z&&(M=Z);var ca=0;S=function(){}; +return{s:S,n:function(){return ca>=M.length?{done:!0}:{done:!1,value:M[ca++]}},e:function(r){throw r;},f:S}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}var ea=!0,ia=!1,na;return{s:function(){Z=Z.call(M)},n:function(){var r=Z.next();ea=r.done;return r},e:function(r){ia=!0;na=r},f:function(){try{if(!ea&&null!=Z["return"])Z["return"]()}finally{if(ia)throw na;}}}}function t(M,S){if(M){if("string"=== +typeof M)return A(M,S);var Z=Object.prototype.toString.call(M).slice(8,-1);"Object"===Z&&M.constructor&&(Z=M.constructor.name);if("Map"===Z||"Set"===Z)return Array.from(M);if("Arguments"===Z||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(Z))return A(M,S)}}function A(M,S){if(null==S||S>M.length)S=M.length;for(var Z=0,ca=Array(S);ZNIF",M.issuer.irsId,J],["Emisor>ApellidosNombreRazonSocial",M.issuer.name,e],["CabeceraFactura>SerieFactura",M.id.serie,m],["CabeceraFactura>NumFactura", +M.id.number,m],["CabeceraFactura>FechaExpedicionFactura",M.id.issuedTime,f],["CabeceraFactura>HoraExpedicionFactura",M.id.issuedTime,k],["FechaOperacion",ia.operationDate,f],["DescripcionFactura",ia.text,w],["ImporteTotalFactura",M.total,d],["Software>LicenciaTBAI",Z.license,m],["Software>Nombre",Z.name,e],["Software>Version",Z.version,m],["EntidadDesarrolladora>NIF",Z.developerIrsId,J]];S?Z=Z.concat([["SerieFacturaAnterior",S.serie,m],["NumFacturaAnterior",S.number,m],["FechaExpedicionFacturaAnterior", +S.issuedTime,f],["SignatureValueFirmaFacturaAnterior",S.hash,l]]):ea.querySelectorAll("EncadenamientoFacturaAnterior").forEach(F);if(S=M.recipient){ia="\n \n \n \n \n \n \n ".replace(/>\s+<");ia=(new DOMParser).parseFromString(ia,"application/xml");W(ia,[["NIF",S.irsId,J],["ApellidosNombreRazonSocial",S.name,e],["CodigoPostal",S.postal,h], +["Direccion",S.address,w]]);S.postal||ia.querySelectorAll("CodigoPostal").forEach(F);S.address||ia.querySelectorAll("Direccion").forEach(F);S=ea.querySelector("Destinatarios");if(!S)throw Error("Missing Destinatarios element");S.appendChild(ia.documentElement)}else ea.querySelectorAll("Destinatarios").forEach(F);ca.deviceId?Z=Z.concat([["NumSerieDispositivo",ca.deviceId,P]]):ea.querySelectorAll("NumSerieDispositivo").forEach(F);W(ea,Z);if(ca=ea.querySelector("TipoDesglose")){Z=M.vatLines;S=ea.createElement("DesgloseFactura"); +ca.appendChild(S);ia=ea.createElement("Sujeta");var na=ea.createElement("NoExenta"),r=ea.createElement("DetalleNoExenta"),n=ea.createElement("TipoNoExenta");ca=ea.createElement("DesgloseIVA");if(6y)throw Error("Only up to 1000 invoice lines allowed");if(0\n \n 1.2\n \n \n \n ????\n ????\n \n \n \n \n \n ????\n ????\n ????\n ????\n S\n \n \n ????\n ????\n \n ????\n \n \n \n \n \n \n ????\n ????\n ????\n ????\n \n \n ????\n \n ????\n \n ????\n ????\n \n ????\n \n'.replace(/>\s+<").replace(/\s*xmlns/g," xmlns")}])});}).call(this || window) diff --git a/l10n_es_ticketbai_pos/static/src/img/oca_logo.png b/l10n_es_ticketbai_pos/static/src/img/oca_logo.png new file mode 100644 index 00000000000..ef62eaf9559 Binary files /dev/null and b/l10n_es_ticketbai_pos/static/src/img/oca_logo.png differ diff --git a/l10n_es_ticketbai_pos/static/src/js/Screens/ClientListScreen/ClientListScreen.js b/l10n_es_ticketbai_pos/static/src/js/Screens/ClientListScreen/ClientListScreen.js new file mode 100644 index 00000000000..f75e92946a3 --- /dev/null +++ b/l10n_es_ticketbai_pos/static/src/js/Screens/ClientListScreen/ClientListScreen.js @@ -0,0 +1,62 @@ +/* Copyright 2021 Binovo IT Human Project SL + Copyright 2022 Landoo Sistemas de Informacion SL + Copyright 2022 Advanced Programming Solutions SL (APSL) + License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +*/ + +odoo.define("l10n_es_ticketbai_pos.ClientListScreen", function (require) { + "use strict"; + + const ClientListScreen = require("point_of_sale.ClientListScreen"); + const Registries = require("point_of_sale.Registries"); + + const L10nEsTicketBaiClientListScreen = (ClientListScreen) => + class extends ClientListScreen { + clickClient(event) { + if (this.env.pos.company.tbai_enabled) { + var customer = this.env.pos.db.get_partner_by_id( + event.detail.client.id + ); + var order = this.env.pos.get_order(); + var res = true; + + if (!order.check_customer_country_code(customer)) { + res = false; + this.showPopup("ErrorPopup", { + title: this.env._t("TicketBAI"), + body: _.str.sprintf( + this.env._t("Please set Country for customer %s."), + customer.name + ), + }); + } else if ( + !order.check_simplified_invoice_spanish_customer(customer) + ) { + res = false; + this.showPopup("ErrorPopup", { + title: this.env._t("TicketBAI"), + body: this.env._t( + "Non spanish customers are not supported for Simplified Invoice." + ), + }); + } else if (!order.check_customer_vat(customer)) { + res = false; + this.showPopup("ErrorPopup", { + title: this.env._t("TicketBAI"), + body: _.str.sprintf( + this.env._t( + "Please set VAT or TicketBAI Partner Identification Number for customer %s." + ), + customer.name + ), + }); + } + if (res) { + super.clickClient(event); + } + } + } + }; + Registries.Component.extend(ClientListScreen, L10nEsTicketBaiClientListScreen); + return ClientListScreen; +}); diff --git a/l10n_es_ticketbai_pos/static/src/js/Screens/PaymentScreen/PaymentScreen.js b/l10n_es_ticketbai_pos/static/src/js/Screens/PaymentScreen/PaymentScreen.js new file mode 100644 index 00000000000..501f55dc77d --- /dev/null +++ b/l10n_es_ticketbai_pos/static/src/js/Screens/PaymentScreen/PaymentScreen.js @@ -0,0 +1,98 @@ +/* Copyright 2021 Binovo IT Human Project SL + Copyright 2022 Landoo Sistemas de Informacion SL + Copyright 2022 Advanced Programming Solutions SL (APSL) + License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +*/ + +odoo.define("l10n_esthis.env._ticketbai_pos.PaymentScreen", function (require) { + "use strict"; + + var core = require("web.core"); + var _t = core._t; + const PaymentScreen = require("point_of_sale.PaymentScreen"); + const Registries = require("point_of_sale.Registries"); + + const L10nEsTicketBaiPaymentScreen = (PaymentScreen) => + class extends PaymentScreen { + _isOrderValid(isForceValidate) { + var res = super._isOrderValid(isForceValidate); + if (this.env.pos.company.tbai_enabled && res === true) { + var error_msgs = []; + var order = this.env.pos.get_order(); + if (this.env.pos.tbai_signer === null) { + res = false; + error_msgs.push(_t("TicketBAI certificate not loaded!")); + } + if (!order.check_company_vat()) { + res = false; + error_msgs.push(_t("Please set Company VAT.")); + } + if (!order.check_simplified_invoice_spanish_customer()) { + res = false; + error_msgs.push( + _t( + "Non spanish customers are not supported for Simplified Invoice." + ) + ); + } + if (!order.check_customer_vat()) { + res = false; + error_msgs.push( + _t( + "Please set VAT or TicketBAI Partner Identification Number for customer." + ) + ); + } + if (!order.check_fiscal_position_vat_regime_key()) { + res = false; + error_msgs.push( + _.str.sprintf( + _t("Please set VAT Regime Key for fiscal position %s."), + order.fiscal_position.name + ) + ); + } + if (!order.check_products_have_taxes()) { + res = false; + error_msgs.push( + _t("At least one product does not have a tax.") + ); + } + if (order.tbai_current_invoice.state() !== "resolved") { + res = false; + error_msgs.push( + _t("TicketBAI Invoice not built yet. Please try again.") + ); + } + if (res === false) { + this.showPopup("ErrorPopup", { + title: _t("TicketBAI"), + body: error_msgs.join("\n"), + }); + } + } + return res; + } + + validateOrder(isForceValidate) { + var self = this; + var order = this.env.pos.get_order(); + if (this.env.pos.company.tbai_enabled && !order.is_to_invoice()) { + if (isForceValidate === "tbai_inv_up_to_date") { + super.validateOrder(isForceValidate); + } else { + order = this.env.pos.get_order(); + order.tbai_build_invoice(); + order.tbai_current_invoice.then(function (tbai_inv) { + order.tbai_simplified_invoice = tbai_inv; + self.validateOrder("tbai_inv_up_to_date"); + }); + } + } else { + super.validateOrder(isForceValidate); + } + } + }; + Registries.Component.extend(PaymentScreen, L10nEsTicketBaiPaymentScreen); + return PaymentScreen; +}); diff --git a/l10n_es_ticketbai_pos/static/src/js/Screens/ProductScreen/ProductScreen.js b/l10n_es_ticketbai_pos/static/src/js/Screens/ProductScreen/ProductScreen.js new file mode 100644 index 00000000000..e8104fe6d2f --- /dev/null +++ b/l10n_es_ticketbai_pos/static/src/js/Screens/ProductScreen/ProductScreen.js @@ -0,0 +1,37 @@ +/* Copyright 2021 Binovo IT Human Project SL + Copyright 2022 Landoo Sistemas de Informacion SL + Copyright 2022 Advanced Programming Solutions SL (APSL) + License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +*/ + +odoo.define("l10n_es_ticketbai_pos.ProductScreen", function (require) { + "use strict"; + + const ProductScreen = require("point_of_sale.ProductScreen"); + const Registries = require("point_of_sale.Registries"); + + const L10nEsTicketBaiProductScreen = (ProductScreen) => + class extends ProductScreen { + _clickProduct(event) { + const product = event.detail; + var res = true; + if (this.env.pos.company.tbai_enabled) { + if (product.taxes_id.length !== 1) { + res = false; + this.showPopup("ErrorPopup", { + title: this.env._t("TicketBAI"), + body: _.str.sprintf( + this.env._t("Please set a tax for product %s."), + product.display_name + ), + }); + } + } + if (res) { + super._clickProduct(event); + } + } + }; + Registries.Component.extend(ProductScreen, L10nEsTicketBaiProductScreen); + return ProductScreen; +}); diff --git a/l10n_es_ticketbai_pos/static/src/js/db.js b/l10n_es_ticketbai_pos/static/src/js/db.js new file mode 100644 index 00000000000..04bf56c0ccf --- /dev/null +++ b/l10n_es_ticketbai_pos/static/src/js/db.js @@ -0,0 +1,26 @@ +/* Copyright 2021 Binovo IT Human Project SL + Copyright 2022 Landoo Sistemas de Informacion SL + License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +*/ + +odoo.define("l10n_es_ticketbai_pos.db", function (require) { + "use strict"; + + var PosDB = require("point_of_sale.DB"); + + PosDB.include({ + init: function (options) { + this._super(options); + this.tbai_last_invoice_data = null; + }, + + set_tbai_json_last_invoice_data: function (data) { + this.save("tbai_last_invoice_data", data || {}); + }, + + get_tbai_json_last_invoice_data: function () { + return this.load("tbai_last_invoice_data") || {}; + }, + }); + return PosDB; +}); diff --git a/l10n_es_ticketbai_pos/static/src/js/models.js b/l10n_es_ticketbai_pos/static/src/js/models.js new file mode 100644 index 00000000000..0a616a9f4ba --- /dev/null +++ b/l10n_es_ticketbai_pos/static/src/js/models.js @@ -0,0 +1,451 @@ +/* Copyright 2021 Binovo IT Human Project SL + Copyright 2022 Landoo Sistemas de Informacion SL + License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +*/ + +odoo.define("l10n_es_ticketbai_pos.models", function (require) { + "use strict"; + + var models = require("point_of_sale.models"); + var pos_super = models.PosModel.prototype; + var order_super = models.Order.prototype; + var orderLine_super = models.Orderline.prototype; + var core = require("web.core"); + var _t = core._t; + var tbai_models = require("l10n_es_ticketbai_pos.tbai_models"); + var rpc = require("web.rpc"); + + var tbai = window.tbai; + + models.load_fields("res.company", [ + "tbai_enabled", + "tbai_test_enabled", + "tbai_license_key", + "tbai_developer_id", + "tbai_software_name", + "tbai_software_version", + "tbai_tax_agency_id", + "tbai_protected_data", + "tbai_protected_data_txt", + "tbai_vat_regime_simplified", + ]); + + models.load_fields("res.country", ["code"]); + models.load_fields("res.partner", [ + "tbai_partner_idtype", + "tbai_partner_identification_number", + ]); + + models.load_models([ + { + model: "res.partner", + fields: [ + "vat", + "country_id", + "tbai_partner_idtype", + "tbai_partner_identification_number", + ], + condition: function (self) { + return self.company.tbai_enabled; + }, + domain: function (self) { + return [ + ["customer_rank", "=", 0], + ["id", "=", self.company.tbai_developer_id[0]], + ]; + }, + loaded: function (self, partner) { + if (partner.length === 1 && !self.db.get_partner_by_id(partner[0].id)) { + self.partners.concat(partner); + self.db.add_partners(partner); + } + }, + }, + { + model: "tbai.invoice", + fields: ["signature_value", "number_prefix", "number", "expedition_date"], + condition: function (self) { + return self.company.tbai_enabled; + }, + domain: function (self) { + return [["id", "=", self.config.tbai_last_invoice_id[0]]]; + }, + loaded: function (self, tbai_invoices) { + if (Array.isArray(tbai_invoices) && tbai_invoices.length === 1) { + var tbai_inv = tbai_invoices[0]; + var tbai_last_invoice_data = { + order: { + simplified_invoice: + tbai_inv.number_prefix + tbai_inv.number, + }, + signature_value: tbai_inv.signature_value, + number: tbai_inv.number, + number_prefix: tbai_inv.number_prefix, + expedition_date: moment( + tbai_inv.expedition_date, + "DD-MM-YYYY" + ).toDate(), + }; + self.set("tbai_last_invoice_data", tbai_last_invoice_data); + } + }, + }, + { + model: "pos.config", + fields: ["id"], + condition: function (self) { + return self.company.tbai_enabled; + }, + domain: function (self) { + return [["id", "=", self.pos_session.config_id[0]]]; + }, + loaded: function (self, configs) { + self.set_tbai_last_invoice_data(self.get_tbai_last_invoice_data()); + return rpc + .query({ + model: "pos.config", + method: "get_tbai_p12_and_friendlyname", + args: [configs[0].id], + }) + .then(function (args) { + return tbai.TbaiSigner.fromBuffer( + atob(args[0]), + args[1], + args[2] + ).then( + function (signer) { + self.tbai_signer = signer; + }, + function (err) { + console.error(err); + } + ); + }); + }, + }, + { + model: "tbai.tax.agency", + fields: ["version", "qr_base_url", "test_qr_base_url"], + condition: function (self) { + return self.company.tbai_enabled; + }, + domain: function (self) { + return [["id", "=", self.company.tbai_tax_agency_id[0]]]; + }, + loaded: function (self, tax_agencies) { + self.tbai_version = tax_agencies[0].version; + if (self.company.tbai_test_enabled) { + self.tbai_qr_base_url = tax_agencies[0].test_qr_base_url; + } else { + self.tbai_qr_base_url = tax_agencies[0].qr_base_url; + } + }, + }, + { + model: "tbai.vat.regime.key", + fields: ["code"], + condition: function (self) { + return self.company.tbai_enabled; + }, + domain: [], + loaded: function (self, vat_regime_keys) { + self.tbai_vat_regime_keys = vat_regime_keys; + }, + }, + ]); + + models.PosModel = models.PosModel.extend({ + initialize: function () { + this.tbai_version = null; + this.tbai_signer = null; + this.tbai_qr_base_url = null; + this.tbai_vat_regime_keys = null; + this.set({tbai_last_invoice_data: null}); + pos_super.initialize.apply(this, arguments); + }, + get_country_by_id: function (id) { + var countries = this.countries; + var country = null; + var i = 0; + while (country === null && i < countries.length) { + if (id === countries[i].id) { + country = countries[i]; + } + i++; + } + return country; + }, + get_country_code_by_id: function (id) { + var country = this.get_country_by_id(id); + return (country && country.code.toUpperCase()) || null; + }, + get_tbai_vat_regime_key_by_id: function (id) { + var vat_regime_keys = this.tbai_vat_regime_keys; + var vat_regime_key = null; + var i = 0; + while (vat_regime_key === null && i < vat_regime_keys.length) { + if (id === vat_regime_keys[i].id) { + vat_regime_key = vat_regime_keys[i]; + } + i++; + } + return vat_regime_key; + }, + get_tbai_vat_regime_key_code_by_id: function (id) { + var tbai_vat_regime_key = this.get_tbai_vat_regime_key_by_id(id); + return (tbai_vat_regime_key && tbai_vat_regime_key.code) || null; + }, + push_single_order: function (order, opts) { + var self = this; + if (this.company.tbai_enabled && order) { + return order.tbai_current_invoice.then(function (tbai_inv) { + var tbai_last_invoice_data = { + order: { + simplified_invoice: + tbai_inv.number_prefix + tbai_inv.number, + }, + signature_value: tbai_inv.signature_value, + number: tbai_inv.number, + number_prefix: tbai_inv.number_prefix, + expedition_date: tbai_inv.expedition_date, + }; + self.set_tbai_last_invoice_data(tbai_last_invoice_data); + return pos_super.push_single_order.call(self, order, opts); + }); + } + return pos_super.push_single_order.call(self, order, opts); + }, + get_tbai_last_invoice_data: function () { + var db_json_last_invoice_data = this.db.get_tbai_json_last_invoice_data(); + if (!(Object.keys(db_json_last_invoice_data).length === 0)) { + return db_json_last_invoice_data; + } + return this.get("tbai_last_invoice_data") || null; + }, + set_tbai_last_invoice_data: function (data) { + this.set("tbai_last_invoice_data", data); + this.db.set_tbai_json_last_invoice_data(data); + }, + scan_product: function (parsed_code) { + var res = true; + var ok = true; + if (this.company.tbai_enabled) { + var product = this.db.get_product_by_barcode(parsed_code.base_code); + if (!product) { + res = false; + } else if (product.taxes_id !== 1) { + ok = false; + this.gui.show_popup("error", { + title: _t("TicketBAI"), + body: _.str.sprintf( + _t("Please set a tax for product %s."), + product.display_name + ), + }); + } + } + if (ok) { + res = pos_super.scan_product.call(this, parsed_code); + } else { + res = true; + } + return res; + }, + }); + + models.Orderline = models.Orderline.extend({ + export_as_JSON: function () { + var json = orderLine_super.export_as_JSON.apply(this, arguments); + if (this.pos.company.tbai_enabled) { + var product = this.get_product(); + var price_unit = null; + var tax = this.get_taxes()[0]; + var fp_taxes = this._map_tax_fiscal_position(tax); + json.tbai_description = product.display_name || ""; + if (fp_taxes) { + json.tbai_vat_amount = tax.amount; + json.tbai_price_without_tax = this.get_price_without_tax(); + json.tbai_price_with_tax = this.get_price_with_tax(); + } + if (fp_taxes.length > 0) { + price_unit = this.compute_all( + fp_taxes, + json.price_unit, + 1, + this.pos.currency.rounding, + true + ).total_excluded; + } else { + price_unit = json.price_unit; + } + json.tbai_price_unit = price_unit; + } + return json; + }, + }); + + models.Order = models.Order.extend({ + initialize: function () { + this.tbai_simplified_invoice = null; + this.tbai_current_invoice = $.when(); + order_super.initialize.apply(this, arguments); + if (this.pos.company.tbai_enabled && "json" in arguments[1]) { + this.tbai_simplified_invoice = + new tbai_models.TicketBAISimplifiedInvoice( + {}, + { + pos: this.pos, + tbai_identifier: arguments[1].json.tbai_identifier, + tbai_qr_src: arguments[1].json.tbai_qr_src, + } + ); + } + return this; + }, + check_products_have_taxes: function () { + var orderLines = this.get_orderlines(); + var line = null; + var taxes = null; + var all_products_have_one_tax = true; + var i = 0; + while (all_products_have_one_tax && i < orderLines.length) { + line = orderLines[i]; + taxes = line.get_taxes(); + if (taxes.length !== 1) { + all_products_have_one_tax = false; + } + i++; + } + return all_products_have_one_tax; + }, + check_company_vat: function () { + return Boolean(this.pos.company.vat); + }, + check_customer_country_code: function (client = null) { + var customer = client || this.get_client(); + return !(!customer || (customer && !customer.country_id)); + }, + check_simplified_invoice_spanish_customer: function (client = null) { + var customer = client || this.get_client(); + var ok = true; + if (customer !== null) { + ok = this.check_customer_country_code(customer); + if (ok) { + var country_code = this.pos.get_country_code_by_id( + customer.country_id[0] + ); + if (country_code !== "ES" && !this.to_invoice) { + ok = false; + } + } + } + return ok; + }, + check_customer_vat: function (client = null) { + var customer = client || this.get_client(); + var ok = true; + if (customer !== null) { + ok = this.check_customer_country_code(customer); + if (ok) { + var country_code = this.pos.get_country_code_by_id( + customer.country_id[0] + ); + if (country_code === "ES") { + if (!customer.vat) { + ok = false; + } + } else if (customer.tbai_partner_idtype === "02" && !customer.vat) { + ok = false; + } else if ( + customer.tbai_partner_idtype !== "02" && + !customer.tbai_partner_identification_number + ) { + ok = false; + } + } + } + return ok; + }, + check_fiscal_position_vat_regime_key: function () { + var ok = true; + if (this.fiscal_position && !this.fiscal_position.tbai_vat_regime_key) { + ok = false; + } + return ok; + }, + check_tbai_conf: function () { + return ( + this.check_company_vat() && + this.check_simplified_invoice_spanish_customer() && + this.check_customer_vat() && + this.check_fiscal_position_vat_regime_key() && + this.check_products_have_taxes() + ); + }, + export_as_JSON: function () { + var json = order_super.export_as_JSON.apply(this, arguments); + if (this.pos.company.tbai_enabled) { + var taxLines = []; + var order = this; + this.get_tax_details().forEach(function (taxDetail) { + var taxLineDict = taxDetail; + taxLineDict.baseAmount = order.get_base_by_tax()[taxDetail.tax.id]; + taxLines.push([0, 0, taxLineDict]); + }); + json.taxLines = taxLines; + var tbai_inv = this.tbai_simplified_invoice || null; + if (tbai_inv !== null) { + var datas = tbai_inv.datas; + var signature_value = tbai_inv.signature_value; + if (datas !== null && signature_value !== null) { + json.tbai_signature_value = signature_value; + json.tbai_datas = datas; + json.tbai_vat_regime_key = tbai_inv.vat_regime_key; + json.tbai_identifier = tbai_inv.tbai_identifier; + json.tbai_qr_src = tbai_inv.tbai_qr_src; + if (tbai_inv.previous_tbai_invoice !== null) { + json.tbai_previous_order_pos_reference = + tbai_inv.previous_tbai_invoice.order.simplified_invoice; + } + } + } + } + return json; + }, + export_for_printing: function () { + var receipt = order_super.export_for_printing.apply(this, arguments); + if (this.pos.company.tbai_enabled) { + var tbai_inv = this.tbai_simplified_invoice || null; + if (tbai_inv !== null) { + receipt.tbai_identifier = tbai_inv.tbai_identifier; + receipt.tbai_qr_src = tbai_inv.tbai_qr_src; + } + } + return receipt; + }, + tbai_build_invoice: function () { + var self = this; + if (self.tbai_current_invoice.state() === "rejected") { + self.tbai_current_invoice = new $.when(); + } + self.tbai_current_invoice = self.tbai_current_invoice.then(function () { + var tbai_current_invoice = $.when(); + var tbai_inv = null; + var ok = self.check_tbai_conf(); + if (ok && !self.to_invoice) { + tbai_inv = new tbai_models.TicketBAISimplifiedInvoice( + {}, + { + pos: self.pos, + order: self, + } + ); + tbai_current_invoice = tbai_inv.build_invoice().then(function () { + return tbai_inv; + }); + } + return tbai_current_invoice; + }); + }, + }); +}); diff --git a/l10n_es_ticketbai_pos/static/src/js/tbai_models.js b/l10n_es_ticketbai_pos/static/src/js/tbai_models.js new file mode 100644 index 00000000000..6a632b590c0 --- /dev/null +++ b/l10n_es_ticketbai_pos/static/src/js/tbai_models.js @@ -0,0 +1,355 @@ +/* Copyright 2021 Binovo IT Human Project SL + Copyright 2022 Landoo Sistemas de Informacion SL + Copyright 2022 Advanced Programming Solu SL + License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +*/ + +odoo.define("l10n_es_ticketbai_pos.tbai_models", function (require) { + "use strict"; + + var core = require("web.core"); + var _t = core._t; + var field_utils = require("web.field_utils"); + + var Backbone = window.Backbone; + var tbai = window.tbai; + var QRCode = window.QRCode; + + /* A TicketBAI Simplified Invoice represents a customer's order + to be exported to the Tax Agency. + */ + var TicketBAISimplifiedInvoice = Backbone.Model.extend({ + initialize: function (attributes, options) { + Backbone.Model.prototype.initialize.apply(this, arguments); + var opts = options || {}; + this.pos = opts.pos; + this.previous_tbai_invoice = null; + this.order = opts.order || null; + this.number = opts.number || null; + this.number_prefix = opts.number_prefix || null; + this.expedition_date = opts.expedition_date || null; + this.signature_value = opts.signature_value || null; + this.tbai_identifier = opts.tbai_identifier || null; + this.tbai_qr_src = opts.tbai_qr_src || null; + this.tbai_qr_url = null; + this.vat_regime_key = "01"; + this.vat_regime_key2 = null; + this.vat_regime_key3 = null; + this.unsigned_datas = null; + this.datas = null; + }, + + // Tested on Epson TM-20II + // 164 (default pixels with margin '0') * 35 (required QR image width in mm) / 22 (default width in mm) = 260 + // Pixels. 255 is the maximum. + qr_options: { + margin: 0, + width: 255, + }, + + build_invoice: function () { + var self = this; + var built = new $.Deferred(); + var options = {}; + var deviceId = this.pos.config.tbai_device_serial_number || null; + // Addon l10n_es_pos -> Order.export_as_JSON() + var simplified_invoice = null; + var tbai_json = null; + this.previous_tbai_invoice = this.pos.get_tbai_last_invoice_data(); + this.expedition_date = new Date(); + if (!this.pos.config.pos_sequence_by_device) { + this.number_prefix = this.pos.config.l10n_es_simplified_invoice_prefix; + simplified_invoice = + this.order.simplified_invoice || + this.number_prefix + + this.pos.get_padding_simple_inv( + this.pos.config.l10n_es_simplified_invoice_number, + this.pos.config.l10n_es_simplified_invoice_padding + ); + } else { + this.number_prefix = + this.pos.get_device().device_simplified_invoice_prefix; + simplified_invoice = + this.number_prefix + + this.pos.get_padding_simple_inv( + this.pos.get_device().device_simplified_invoice_number, + this.pos.get_device().device_simplified_invoice_padding + ); + } + this.number = simplified_invoice.slice(this.number_prefix.length); + + if (this.order.fiscal_position) { + var tbai_vat_regime_key = + this.order.fiscal_position.tbai_vat_regime_key; + if (tbai_vat_regime_key) { + var id_vat_regime_key = + this.order.fiscal_position.tbai_vat_regime_key[0]; + var object_vat_regime_key = self.pos.tbai_vat_regime_keys.find( + (x) => x.id === id_vat_regime_key + ); + this.vat_regime_key = object_vat_regime_key.code; + } + var tbai_vat_regime_key2 = + this.order.fiscal_position.tbai_vat_regime_key2; + if (tbai_vat_regime_key2) { + var id_vat_regime_key = + this.order.fiscal_position.tbai_vat_regime_key2[0]; + var object_vat_regime_key = self.pos.tbai_vat_regime_keys.find( + (x) => x.id === id_vat_regime_key + ); + this.vat_regime_key2 = object_vat_regime_key.code; + } + var tbai_vat_regime_key3 = + this.order.fiscal_position.tbai_vat_regime_key3; + if (tbai_vat_regime_key3) { + var id_vat_regime_key = + this.order.fiscal_position.tbai_vat_regime_key3[0]; + var object_vat_regime_key = self.pos.tbai_vat_regime_keys.find( + (x) => x.id === id_vat_regime_key + ); + this.vat_regime_key3 = object_vat_regime_key.code; + } + } + + tbai_json = this.export_as_JSON(); + if (!_.isEmpty(tbai_json) && this.pos.tbai_signer !== null) { + if (typeof deviceId === "string" || deviceId instanceof String) { + options.deviceId = deviceId; + } + try { + this.unsigned_datas = tbai.toXml( + tbai_json.Invoice, + tbai_json.PreviousInvoiceId || null, + tbai_json.Software, + options + ); + this.pos.tbai_signer.sign(this.unsigned_datas).then( + function (datas) { + self.datas = datas; + self.signature_value = tbai.getTbaiChainInfo(datas).hash; + self.tbai_identifier = tbai.getTbaiId(datas); + self.tbai_qr_url = tbai.getTbaiUrlFromBaseURL( + datas, + self.pos.tbai_qr_base_url + ); + QRCode.toDataURL(self.tbai_qr_url, self.qr_options).then( + function (src) { + self.tbai_qr_src = src; + built.resolve(); + }, + function (err) { + throw new Error(err); + } + ); + }, + function (err) { + throw new Error(err); + } + ); + } catch (e) { + console.error(e); + this.showPopup("ErrorPopup", { + title: _t("TicketBAI"), + body: e.message, + }); + built.reject(); + } + } else { + built.reject(); + } + return built; + }, + get_vat_without_country_code: function (vat, country_code) { + var vat_without_country_code = null; + var vat_upper = vat.toUpperCase(); + var country_code_upper = country_code ? country_code.toUpperCase() : null; + if ( + country_code_upper && + vat_upper.slice(0, country_code_upper.length) === country_code_upper + ) { + vat_without_country_code = vat_upper.slice(country_code_upper.length); + } else { + vat_without_country_code = vat_upper; + } + return vat_without_country_code; + }, + get_tbai_company_vat: function () { + var company = this.pos.company; + return this.get_vat_without_country_code(company.vat, company.country.code); + }, + get_tbai_partner_vat: function (partner_id) { + var partner = this.pos.db.get_partner_by_id(partner_id); + var country_code = this.pos.get_country_code_by_id(partner.country_id[0]); + if (country_code === "ES" || partner.tbai_partner_idtype === "02") { + return this.get_vat_without_country_code(partner.vat, country_code); + } + return partner.tbai_partner_identification_number; + }, + export_as_JSON: function () { + var order_json = + (this.order !== null && this.order.export_as_JSON()) || null; + var tbai_json = {}; + var company = this.pos.company; + var vat_keys = [this.vat_regime_key]; + var self = this; + var simplified = "N"; + + if ( + order_json !== null && + this.number !== null && + this.expedition_date !== null + ) { + if (this.vat_regime_key2 !== null) { + vat_keys.push(this.vat_regime_key2); + } + if (this.vat_regime_key3 !== null) { + vat_keys.push(this.vat_regime_key3); + } + if (company.tbai_vat_regime_simplified) { + simplified = "S"; + } + tbai_json.Invoice = { + simple: true, + issuer: { + irsId: this.get_tbai_company_vat(), + name: company.name, + }, + id: { + number: this.number, + serie: this.number_prefix, + issuedTime: this.expedition_date, + }, + description: { + text: order_json.name, + operationDate: this.expedition_date, + }, + lines: this.get_tbai_lines_from_json(order_json.lines), + total: field_utils.parse.float( + self.pos.format_currency_no_symbol(order_json.amount_total) + ), + vatKeys: vat_keys, + simplified: simplified, + }; + tbai_json.Invoice.vatLines = + this.get_tbai_vat_lines_from_json(order_json); + if (order_json.partner_id) { + var partner = this.pos.db.get_partner_by_id(order_json.partner_id); + var zip = partner.zip; + var address = + (partner.street || "") + + ", " + + (partner.zip || "") + + " " + + (partner.city || "") + + ", " + + (partner.country_id[1] || ""); + tbai_json.Invoice.recipient = { + irsId: this.get_tbai_partner_vat(order_json.partner_id), + name: partner.name, + postal: zip, + address: address, + }; + } + if (this.previous_tbai_invoice !== null) { + tbai_json.PreviousInvoiceId = { + number: this.previous_tbai_invoice.number, + serie: this.previous_tbai_invoice.number_prefix, + issuedTime: new Date( + JSON.parse( + JSON.stringify( + this.previous_tbai_invoice.expedition_date + ) + ) + ), + hash: this.previous_tbai_invoice.signature_value.substring( + 0, + 100 + ), + }; + } + tbai_json.Software = { + license: company.tbai_license_key, + developerIrsId: this.get_tbai_partner_vat( + company.tbai_developer_id[0] + ), + name: company.tbai_software_name, + version: company.tbai_software_version, + }; + } + return tbai_json; + }, + get_tbai_lines_from_json: function (lines_json) { + var lines = []; + var line = null; + var company = this.pos.company; + var description_line = null; + var self = this; + lines_json.forEach(function (item) { + line = item[2]; + description_line = line.tbai_description.substring(0, 250); + if (company.tbai_protected_data && company.tbai_protected_data_txt) { + description_line = company.tbai_protected_data_txt.substring( + 0, + 250 + ); + } + lines.push({ + description: description_line, + quantity: line.qty, + price: field_utils.parse.float( + self.pos.format_currency_no_symbol(line.tbai_price_unit) + ), + discount: field_utils.parse.float( + self.pos.format_currency_no_symbol(line.discount) + ), + discountAmount: field_utils.parse.float( + self.pos.format_currency_no_symbol( + (line.qty * line.tbai_price_unit * line.discount) / 100.0 + ) + ), + vat: line.tbai_vat_amount, + amount: field_utils.parse.float( + self.pos.format_currency_no_symbol(line.tbai_price_without_tax) + ), + amountWithVat: field_utils.parse.float( + self.pos.format_currency_no_symbol(line.tbai_price_with_tax) + ), + }); + }); + return lines; + }, + get_tbai_vat_lines_from_json: function (order_json) { + var vatLines = []; + var vatLinesJson = order_json.taxLines; + var self = this; + if (vatLinesJson && vatLinesJson.length > 0) { + vatLinesJson.forEach(function (vatLineJson) { + var vatLine = vatLineJson[2]; + vatLines.push({ + base: field_utils.parse.float( + self.pos.format_currency_no_symbol(vatLine.baseAmount) + ), + rate: vatLine.tax.amount, + amount: field_utils.parse.float( + self.pos.format_currency_no_symbol(vatLine.amount) + ), + }); + }); + } else { + var fline = order_json.lines[0][2]; + vatLines.push({ + base: field_utils.parse.float( + self.pos.format_currency_no_symbol(order_json.amount_total) + ), + rate: fline.tbai_vat_amount, + amount: 0, + }); + } + return vatLines; + }, + }); + + return { + TicketBAISimplifiedInvoice: TicketBAISimplifiedInvoice, + }; +}); diff --git a/l10n_es_ticketbai_pos/static/src/js/widgets.js b/l10n_es_ticketbai_pos/static/src/js/widgets.js new file mode 100644 index 00000000000..49edd4117c7 --- /dev/null +++ b/l10n_es_ticketbai_pos/static/src/js/widgets.js @@ -0,0 +1,30 @@ +/* Copyright 2021 Binovo IT Human Project SL + Copyright 2022 Landoo Sistemas de Informacion SL + License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +*/ + +odoo.define("l10n_es_ticketbai_pos.widgets", function (require) { + "use strict"; + + var screens = require("point_of_sale.OrderManagementScreen"); + var tbai_models = require("l10n_es_ticketbai_pos.tbai_models"); + + screens.OrderList.include({ + _prepare_order_from_order_data: function (order_data, action) { + var order = this._super(order_data, action); + if (this.pos.company.tbai_enabled) { + order.tbai_simplified_invoice = + new tbai_models.TicketBAISimplifiedInvoice( + {}, + { + pos: this.pos, + order: order, + tbai_identifier: order_data.tbai_identifier, + tbai_qr_src: order_data.tbai_qr_src, + } + ); + } + return order; + }, + }); +}); diff --git a/l10n_es_ticketbai_pos/static/src/xml/pos.xml b/l10n_es_ticketbai_pos/static/src/xml/pos.xml new file mode 100644 index 00000000000..93d770b9e24 --- /dev/null +++ b/l10n_es_ticketbai_pos/static/src/xml/pos.xml @@ -0,0 +1,36 @@ + + + + + + + +
PRO FORMA
+
+
+ + +
+
+ + + +
+
+ +
+
+
+
+
diff --git a/l10n_es_ticketbai_pos/tests/__init__.py b/l10n_es_ticketbai_pos/tests/__init__.py new file mode 100644 index 00000000000..c0e629bf4c8 --- /dev/null +++ b/l10n_es_ticketbai_pos/tests/__init__.py @@ -0,0 +1,2 @@ +from . import common +from . import test_l10n_es_ticketbai_pos diff --git a/l10n_es_ticketbai_pos/tests/common.py b/l10n_es_ticketbai_pos/tests/common.py new file mode 100644 index 00000000000..dadcebd7b34 --- /dev/null +++ b/l10n_es_ticketbai_pos/tests/common.py @@ -0,0 +1,211 @@ +# Copyright 2021 Binovo IT Human Project SL +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import fields +from odoo.tests import common + +from odoo.addons.l10n_es_ticketbai.tests.common import TestL10nEsTicketBAI + + +@common.tagged("-at_install", "post_install") +class TestL10nEsTicketBAIPoSCommon(TestL10nEsTicketBAI): + def create_pos_order_from_ui( + self, user, partner_id=False, fp=False, to_invoice=False + ): + untax, atax = 100.0, 21.0 + tax_ids = [self.tax_21b.id] + if fp: + vat_regime_key = fp.tbai_vat_regime_key.id + else: + vat_regime_key = self.env.ref("l10n_es_ticketbai.tbai_vat_regime_01").id + orders = [ + { + "data": { + "tbai_datas": "", + "tbai_signature_value": "", + "amount_return": 0.0, + "amount_paid": untax + atax, + "amount_tax": atax, + "amount_total": untax + atax, + "creation_date": str(fields.Datetime.now()), + "fiscal_position_id": fp and fp.id or False, + "pricelist_id": self.pos_config.available_pricelist_ids[0].id, + "tbai_vat_regime_key": vat_regime_key, + "lines": [ + [ + 0, + 0, + { + "discount": 0.0, + "price_unit": 100.0, + "product_id": self.product_delivery.id, + "qty": 1.0, + "tax_ids": [(6, 0, tax_ids)], + "price_subtotal": 100.0, + "price_subtotal_incl": 100.0, + }, + ] + ], + "name": "TBAI Simplified Invoice Test - 00001-065-0016", + "simplified_invoice": "Shop0001", + "l10n_es_unique_id": "Shop0001", + "partner_id": partner_id, + "pos_session_id": self.pos_config.current_session_id.id, + "sequence_number": 1, + "statement_ids": [ + [ + 0, + 0, + { + "account_id": user.partner_id.property_account_receivable_id.id, + "amount": untax + atax, + "name": fields.Datetime.now(), + "payment_method_id": self.env.ref( + "account.account_payment_method_manual_out" + ).id, + "statement_id": ( + self.pos_config.current_session_id.statement_ids[ + 0 + ].id + ), + }, + ] + ], + "uid": "00001-065-0016", + "user_id": user.id, + "to_invoice": to_invoice, + }, + "to_invoice": to_invoice, + } + ] + order = self.env["pos.order"].with_user(user.id).create_from_ui(orders) + return self.env["pos.order"].browse(order[0]["id"]) + + def create_pos_order_from_ui2( + self, user, partner_id=False, fp=False, to_invoice=False + ): + untax, atax = 100.0, 21.0 + tax_ids = [self.tax_21b.id] + if fp: + vat_regime_key = fp.tbai_vat_regime_key.id + else: + vat_regime_key = self.env.ref("l10n_es_ticketbai.tbai_vat_regime_01").id + orders = [ + { + "data": { + "tbai_datas": "", + "tbai_signature_value": "", + "amount_return": 0.0, + "amount_paid": untax + atax, + "amount_tax": atax, + "amount_total": untax + atax, + "creation_date": str(fields.Datetime.now()), + "fiscal_position_id": fp and fp.id or False, + "pricelist_id": self.pos_config.available_pricelist_ids[0].id, + "tbai_vat_regime_key": vat_regime_key, + "lines": [ + [ + 0, + 0, + { + "discount": 0.0, + "price_unit": 100.0, + "product_id": self.product_delivery.id, + "qty": 1.0, + "tax_ids": [(6, 0, tax_ids)], + "price_subtotal": 100, + "price_subtotal_incl": 100, + }, + ] + ], + "name": "TBAI Simplified Invoice Test - 00001-065-0017", + "tbai_previous_order_pos_reference": "Main0001", + "simplified_invoice": "Shop0002", + "l10n_es_unique_id": "Shop0002", + "partner_id": partner_id, + "pos_session_id": self.pos_config.current_session_id.id, + "sequence_number": 1, + "statement_ids": [ + [ + 0, + 0, + { + "account_id": user.partner_id.property_account_receivable_id.id, + "amount": untax + atax, + "name": fields.Datetime.now(), + "payment_method_id": self.env.ref( + "account.account_payment_method_manual_out" + ).id, + "statement_id": ( + self.pos_config.current_session_id.statement_ids[ + 0 + ].id + ), + }, + ] + ], + "uid": "00001-065-0017", + "user_id": user.id, + "to_invoice": to_invoice, + }, + "to_invoice": to_invoice, + } + ] + order = self.env["pos.order"].with_user(user.id).create_from_ui(orders) + return self.env["pos.order"].browse(order[0]["id"]) + + def create_pos_order(self, uid, fp=False): + tax_ids = [self.tax_21b.id] + if fp: + vat_regime_key = fp.tbai_vat_regime_key.id + else: + vat_regime_key = self.env.ref("l10n_es_ticketbai.tbai_vat_regime_01").id + vals = { + "pos_reference": "Shop0001", + "l10n_es_unique_id": "Shop0001", + "company_id": self.main_company.id, + "session_id": self.pos_config.current_session_id.id, + "partner_id": self.partner.id, + "fiscal_position_id": fp and fp.id or False, + "pricelist_id": self.pos_config.available_pricelist_ids[0].id, + "tbai_vat_regime_key": vat_regime_key, + "lines": [ + ( + 0, + 0, + { + "name": "TBAI Simplified Invoice Line Test - delivery 1", + "product_id": self.product_delivery.id, + "price_unit": 100.0, + "discount": 0.0, + "qty": 1.0, + "tax_ids": [(6, 0, tax_ids)], + "price_subtotal": 100, + "price_subtotal_incl": 100, + }, + ) + ], + "amount_tax": 0, + "amount_total": 100, + "amount_paid": 121, + "amount_return": 0, + } + pos_order = self.env["pos.order"].with_user(uid).create(vals) + payment = ( + self.env["pos.make.payment"] + .with_context(active_ids=[pos_order.id], active_id=pos_order.id) + .create({"amount": pos_order.amount_total}) + ) + payment.with_context(active_id=pos_order.id).check() + return pos_order + + def setUp(self): + super().setUp() + self.product_delivery.available_in_pos = True + self.pos_config = self.env.ref("point_of_sale.pos_config_main") + self.pos_config.available_pricelist_ids.write( + {"currency_id": self.pos_config.currency_id.id} + ) + self.pos_config.iface_l10n_es_simplified_invoice = True + self.account_billing.groups_id = [ + (4, self.env.ref("point_of_sale.group_pos_user").id) + ] diff --git a/l10n_es_ticketbai_pos/tests/test_l10n_es_ticketbai_pos.py b/l10n_es_ticketbai_pos/tests/test_l10n_es_ticketbai_pos.py new file mode 100644 index 00000000000..38c6e0d2328 --- /dev/null +++ b/l10n_es_ticketbai_pos/tests/test_l10n_es_ticketbai_pos.py @@ -0,0 +1,104 @@ +# Copyright 2021 Binovo IT Human Project SL +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import exceptions +from odoo.tests.common import tagged + +from .common import TestL10nEsTicketBAIPoSCommon + + +@tagged("-at_install", "post_install") +class TestL10nEsTicketBAIPoSOrder(TestL10nEsTicketBAIPoSCommon): + def setUp(self): + super().setUp() + + def test_create_pos_order_from_ui(self): + self.pos_config.open_ui() + pos_order = self.create_pos_order_from_ui(self.account_billing) + self.assertEqual("paid", pos_order.state) + self.assertEqual("pending", pos_order.tbai_invoice_id.state) + + def test_create_pos_orders_from_ui(self): + self.pos_config.open_ui() + pos_order = self.create_pos_order_from_ui(self.account_billing) + self.assertEqual("paid", pos_order.state) + self.assertEqual("pending", pos_order.tbai_invoice_id.state) + pos_order2 = self.create_pos_order_from_ui2(self.account_billing) + self.assertEqual("paid", pos_order2.state) + self.assertEqual("pending", pos_order2.tbai_invoice_id.state) + + def test_create_invoice_from_ui(self): + self.pos_config.open_ui() + pos_order = self.create_pos_order_from_ui( + self.account_billing, + partner_id=self.partner.id, + fp=self.fiscal_position_national, + to_invoice=True, + ) + self.assertEqual("invoiced", pos_order.state) + self.assertFalse(pos_order.tbai_invoice_id) + self.assertEqual("posted", pos_order.account_move.state) + self.assertEqual("pending", pos_order.account_move.tbai_invoice_id.state) + + def test_create_invoice_from_ui_partner(self): + self.pos_config.open_ui() + pos_order = self.create_pos_order_from_ui( + self.account_billing, partner_id=self.partner.id, to_invoice=True + ) + self.assertEqual("invoiced", pos_order.state) + self.assertFalse(pos_order.tbai_invoice_id) + self.assertEqual("posted", pos_order.account_move.state) + self.assertEqual("pending", pos_order.account_move.tbai_invoice_id.state) + + def test_create_pos_order(self): + self.pos_config.open_ui() + pos_order = self.create_pos_order(self.account_billing.id) + self.assertFalse(pos_order.tbai_invoice_id) + pos_order.sudo()._tbai_build_invoice() + self.assertEqual("paid", pos_order.state) + self.assertEqual("pending", pos_order.tbai_invoice_id.state) + + def test_create_invoice_from_pos_order(self): + self.pos_config.open_ui() + pos_order = self.create_pos_order(self.account_billing.id) + self.assertFalse(pos_order.tbai_invoice_id) + pos_order.sudo()._tbai_build_invoice() + self.assertEqual("paid", pos_order.state) + self.assertEqual("pending", pos_order.tbai_invoice_id.state) + pos_order.sudo().with_context( + with_company=pos_order.company_id.id + ).action_pos_order_invoice() + self.assertEqual("invoiced", pos_order.state) + self.assertEqual("posted", pos_order.account_move.state) + self.assertTrue(pos_order.account_move.tbai_substitute_simplified_invoice) + self.assertEqual("pending", pos_order.account_move.tbai_invoice_id.state) + + def test_create_refund_invoice_from_pos_order(self): + self.pos_config.open_ui() + pos_order = self.create_pos_order(self.account_billing.id) + self.assertFalse(pos_order.tbai_invoice_id) + pos_order.account_move._post(True) + pos_order.sudo()._tbai_build_invoice() + self.assertEqual("paid", pos_order.state) + self.assertEqual("pending", pos_order.tbai_invoice_id.state) + pos_order.sudo().with_context( + with_company=pos_order.company_id.id + ).action_pos_order_invoice() + self.assertEqual("invoiced", pos_order.state) + self.assertEqual("posted", pos_order.account_move.state) + self.assertTrue(pos_order.account_move.tbai_substitute_simplified_invoice) + self.assertEqual("pending", pos_order.account_move.tbai_invoice_id.state) + + def test_open_session_error_seq(self): + with self.assertRaises(exceptions.ValidationError): + self.pos_config.iface_l10n_es_simplified_invoice = False + self.pos_config.open_ui() + + with self.assertRaises(exceptions.ValidationError): + self.pos_config.iface_l10n_es_simplified_invoice = True + self.pos_config.open_ui() + self.pos_config.iface_l10n_es_simplified_invoice = False + self.pos_config.open_existing_session_cb() + + self.pos_config.iface_l10n_es_simplified_invoice = True + self.pos_config.open_ui() + self.pos_config.open_existing_session_cb() diff --git a/l10n_es_ticketbai_pos/views/pos_order_views.xml b/l10n_es_ticketbai_pos/views/pos_order_views.xml new file mode 100644 index 00000000000..a5ab3830d12 --- /dev/null +++ b/l10n_es_ticketbai_pos/views/pos_order_views.xml @@ -0,0 +1,141 @@ + + + + + pos.order.form.inherit + pos.order + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + +
+
+
+
+
+
+
diff --git a/l10n_es_ticketbai_pos/views/ticketbai_certificate_views.xml b/l10n_es_ticketbai_pos/views/ticketbai_certificate_views.xml new file mode 100644 index 00000000000..88f90ae58d3 --- /dev/null +++ b/l10n_es_ticketbai_pos/views/ticketbai_certificate_views.xml @@ -0,0 +1,12 @@ + + + + + diff --git a/l10n_es_ticketbai_pos/wizard/__init__.py b/l10n_es_ticketbai_pos/wizard/__init__.py new file mode 100644 index 00000000000..0deb68c4680 --- /dev/null +++ b/l10n_es_ticketbai_pos/wizard/__init__.py @@ -0,0 +1 @@ +from . import res_config_settings diff --git a/l10n_es_ticketbai_pos/wizard/res_config_settings.py b/l10n_es_ticketbai_pos/wizard/res_config_settings.py new file mode 100644 index 00000000000..e0cb62227a1 --- /dev/null +++ b/l10n_es_ticketbai_pos/wizard/res_config_settings.py @@ -0,0 +1,15 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import fields, models + + +class ResConfigSettings(models.TransientModel): + _inherit = "res.config.settings" + + pos_tbai_device_serial_number = fields.Char( + string="PoS TicketBAI Device Serial Number", + related="pos_config_id.tbai_device_serial_number", + ) + pos_tbai_certificate_id = fields.Many2one( + related="pos_config_id.tbai_certificate_id", + readonly=False, + ) diff --git a/l10n_es_ticketbai_pos/wizard/res_config_settings_views.xml b/l10n_es_ticketbai_pos/wizard/res_config_settings_views.xml new file mode 100644 index 00000000000..6d1738ce247 --- /dev/null +++ b/l10n_es_ticketbai_pos/wizard/res_config_settings_views.xml @@ -0,0 +1,65 @@ + + + + + res.config.settings.view.form + res.config.settings + + + + +
+
+ TicketBAI +
+ PoS TicketBAI Configuration +
+ +
+
+
+
+
+ +
+
+
+
+
+
+ +
diff --git a/setup/l10n_es_ticketbai_pos/odoo/addons/l10n_es_ticketbai_pos b/setup/l10n_es_ticketbai_pos/odoo/addons/l10n_es_ticketbai_pos new file mode 120000 index 00000000000..c06fdb1a46a --- /dev/null +++ b/setup/l10n_es_ticketbai_pos/odoo/addons/l10n_es_ticketbai_pos @@ -0,0 +1 @@ +../../../../l10n_es_ticketbai_pos \ No newline at end of file diff --git a/setup/l10n_es_ticketbai_pos/setup.py b/setup/l10n_es_ticketbai_pos/setup.py new file mode 100644 index 00000000000..28c57bb6403 --- /dev/null +++ b/setup/l10n_es_ticketbai_pos/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)