{"version":3,"sources":["node_modules/moment/locale/pt-br.js","node_modules/@kurkle/color/dist/color.esm.js","node_modules/chart.js/dist/chunks/helpers.segment.js","node_modules/chart.js/dist/chart.js","node_modules/lodash-es/_freeGlobal.js","node_modules/lodash-es/_root.js","node_modules/lodash-es/_Symbol.js","node_modules/lodash-es/_getRawTag.js","node_modules/lodash-es/_objectToString.js","node_modules/lodash-es/_baseGetTag.js","node_modules/lodash-es/isObjectLike.js","node_modules/lodash-es/isArray.js","node_modules/lodash-es/isObject.js","node_modules/lodash-es/identity.js","node_modules/lodash-es/isFunction.js","node_modules/lodash-es/_coreJsData.js","node_modules/lodash-es/_isMasked.js","node_modules/lodash-es/_toSource.js","node_modules/lodash-es/_baseIsNative.js","node_modules/lodash-es/_getValue.js","node_modules/lodash-es/_getNative.js","node_modules/lodash-es/_baseCreate.js","node_modules/lodash-es/_apply.js","node_modules/lodash-es/_copyArray.js","node_modules/lodash-es/_shortOut.js","node_modules/lodash-es/constant.js","node_modules/lodash-es/_defineProperty.js","node_modules/lodash-es/_baseSetToString.js","node_modules/lodash-es/_setToString.js","node_modules/lodash-es/_isIndex.js","node_modules/lodash-es/_baseAssignValue.js","node_modules/lodash-es/eq.js","node_modules/lodash-es/_assignValue.js","node_modules/lodash-es/_copyObject.js","node_modules/lodash-es/_overRest.js","node_modules/lodash-es/_baseRest.js","node_modules/lodash-es/isLength.js","node_modules/lodash-es/isArrayLike.js","node_modules/lodash-es/_isIterateeCall.js","node_modules/lodash-es/_createAssigner.js","node_modules/lodash-es/_isPrototype.js","node_modules/lodash-es/_baseTimes.js","node_modules/lodash-es/_baseIsArguments.js","node_modules/lodash-es/isArguments.js","node_modules/lodash-es/stubFalse.js","node_modules/lodash-es/isBuffer.js","node_modules/lodash-es/_baseIsTypedArray.js","node_modules/lodash-es/_baseUnary.js","node_modules/lodash-es/_nodeUtil.js","node_modules/lodash-es/isTypedArray.js","node_modules/lodash-es/_arrayLikeKeys.js","node_modules/lodash-es/_overArg.js","node_modules/lodash-es/_nativeKeysIn.js","node_modules/lodash-es/_baseKeysIn.js","node_modules/lodash-es/keysIn.js","node_modules/lodash-es/_nativeCreate.js","node_modules/lodash-es/_hashClear.js","node_modules/lodash-es/_hashDelete.js","node_modules/lodash-es/_hashGet.js","node_modules/lodash-es/_hashHas.js","node_modules/lodash-es/_hashSet.js","node_modules/lodash-es/_Hash.js","node_modules/lodash-es/_listCacheClear.js","node_modules/lodash-es/_assocIndexOf.js","node_modules/lodash-es/_listCacheDelete.js","node_modules/lodash-es/_listCacheGet.js","node_modules/lodash-es/_listCacheHas.js","node_modules/lodash-es/_listCacheSet.js","node_modules/lodash-es/_ListCache.js","node_modules/lodash-es/_Map.js","node_modules/lodash-es/_mapCacheClear.js","node_modules/lodash-es/_isKeyable.js","node_modules/lodash-es/_getMapData.js","node_modules/lodash-es/_mapCacheDelete.js","node_modules/lodash-es/_mapCacheGet.js","node_modules/lodash-es/_mapCacheHas.js","node_modules/lodash-es/_mapCacheSet.js","node_modules/lodash-es/_MapCache.js","node_modules/lodash-es/_getPrototype.js","node_modules/lodash-es/isPlainObject.js","node_modules/lodash-es/_stackClear.js","node_modules/lodash-es/_stackDelete.js","node_modules/lodash-es/_stackGet.js","node_modules/lodash-es/_stackHas.js","node_modules/lodash-es/_stackSet.js","node_modules/lodash-es/_Stack.js","node_modules/lodash-es/_cloneBuffer.js","node_modules/lodash-es/_Uint8Array.js","node_modules/lodash-es/_cloneArrayBuffer.js","node_modules/lodash-es/_cloneTypedArray.js","node_modules/lodash-es/_initCloneObject.js","node_modules/lodash-es/_createBaseFor.js","node_modules/lodash-es/_baseFor.js","node_modules/lodash-es/_assignMergeValue.js","node_modules/lodash-es/isArrayLikeObject.js","node_modules/lodash-es/_safeGet.js","node_modules/lodash-es/toPlainObject.js","node_modules/lodash-es/_baseMergeDeep.js","node_modules/lodash-es/_baseMerge.js","node_modules/lodash-es/merge.js","node_modules/ng2-charts/fesm2022/ng2-charts.mjs","src/app/ui/services/pbm/general-report.service.ts","src/app/ui/components/header/header.component.ts","src/app/ui/components/header/header.component.html","src/app/ui/components/dialog/dialog-close.directive.ts","src/app/ui/components/dialog/full-dialog/full-dialog.module.ts","src/app/ui/components/dialog/dialog.module.ts","src/app/ui/components/toast/toast.module.ts","src/app/ui/components/input-message/input-message.component.ts","src/app/ui/components/input-message/input-message.component.html","src/app/ui/components/header/nav-bar/navbar.module.ts","src/app/ui/components/sidenav/menu-item/menu-item.component.ts","src/app/ui/components/sidenav/menu-item/menu-item.component.html","src/app/ui/components/sidenav/sidenav.component.ts","src/app/ui/components/sidenav/sidenav.component.html","src/app/ui/components/pbm/companies/search-company/search-company.component.ts","src/app/ui/components/pbm/companies/search-company/search-company.component.html","src/app/ui/models/domains/pbm/companies/company-configuration-handler.ts","src/app/ui/components/pbm/companies/delete-contact-dialog/delete-contact-dialog.component.ts","src/app/ui/components/pbm/companies/delete-contact-dialog/delete-contact-dialog.component.html","src/app/ui/models/domains/validator/validation-result.ts","src/app/ui/components/pbm/companies/validators/company-validator.ts","src/app/ui/models/utils/form-dirty.utils.ts","src/app/ui/models/domains/pbm/social-number.model.ts","src/app/ui/components/pbm/companies/validators/contact-validator.ts","src/app/ui/models/domains/pbm/companies/company-contact-handler.ts","src/app/ui/components/pbm/companies/company-contact-dialog/company-contact-dialog.component.ts","src/app/ui/components/pbm/companies/company-contact-dialog/company-contact-dialog.component.html","src/app/ui/models/domains/pbm/companies/company-handler.ts","src/app/ui/components/pbm/companies/edit-company/edit-company.component.ts","src/app/ui/components/pbm/companies/edit-company/edit-company.component.html","src/app/ui/components/pbm/companies/company-master-data-dialog/company-master-data-dialog.component.ts","src/app/ui/components/pbm/companies/company-master-data-dialog/company-master-data-dialog.component.html","src/app/ui/components/pbm/beneficiaries/search-beneficiary/limit-beneficiary-modal/limit-beneficiary-modal.component.ts","src/app/ui/components/pbm/beneficiaries/search-beneficiary/limit-beneficiary-modal/limit-beneficiary-modal.component.html","src/app/ui/components/pbm/beneficiaries/search-beneficiary/search-beneficiary.component.ts","src/app/ui/components/pbm/beneficiaries/search-beneficiary/search-beneficiary.component.html","src/app/ui/components/pbm/beneficiaries/export-beneficiaries/export-beneficiaries.component.ts","src/app/ui/components/pbm/beneficiaries/export-beneficiaries/export-beneficiaries.component.html","src/app/ui/models/domains/pbm/Beneficiary/marital-status-type.ts","src/app/ui/models/domains/pbm/Beneficiary/interfaces/IFilterBeneficiarySearchParameterByExport.ts","src/app/ui/services/pbm/export-beneficiaries.service.ts","node_modules/xlsx/xlsx.mjs","src/app/ui/services/export.service.ts","src/app/ui/components/pbm/beneficiaries/validators/save-beneficiary-validator.ts","src/app/ui/models/domains/pbm/Beneficiary/dto/card-block-dto.ts","src/app/ui/components/pbm/beneficiaries/dialogs/card-block-dialog/card-block-dialog.component.ts","src/app/ui/components/pbm/beneficiaries/dialogs/card-block-dialog/card-block-dialog.component.html","src/app/ui/models/domains/pbm/custom-validators.ts","src/app/ui/components/pbm/beneficiaries/registration-beneficiary/vinculated-socialnumber/vinculated-socialnumber-dialog.component.ts","src/app/ui/components/pbm/beneficiaries/registration-beneficiary/vinculated-socialnumber/vinculated-socialnumber-dialog.component.html","src/app/ui/services/pbm/state.service.ts","src/app/ui/components/pbm/beneficiaries/registration-beneficiary/registration-beneficiary.component.ts","src/app/ui/components/pbm/beneficiaries/registration-beneficiary/registration-beneficiary.component.html","src/app/ui/models/domains/pbm/Beneficiary/file-beneficiary.ts","src/app/ui/components/pbm/beneficiaries/registration-beneficiaries/export-info-dialog/export-info-dialog.component.ts","src/app/ui/components/pbm/beneficiaries/registration-beneficiaries/export-info-dialog/export-info-dialog.component.html","src/app/ui/components/pbm/beneficiaries/registration-beneficiaries/registration-beneficiaries.component.ts","src/app/ui/components/pbm/beneficiaries/registration-beneficiaries/registration-beneficiaries.component.html","src/app/ui/components/pbm/beneficiaries/edit-beneficiary/edit-beneficiary.component.ts","src/app/ui/components/pbm/beneficiaries/edit-beneficiary/edit-beneficiary.component.html","src/app/ui/components/pbm/beneficiaries/dialogs/card-order-dialog/card-order-dialog.component.ts","src/app/ui/components/pbm/beneficiaries/dialogs/card-order-dialog/card-order-dialog.component.html","src/app/ui/models/domains/pbm/Beneficiary/dto/card-unblock-dto.ts","src/app/ui/components/pbm/beneficiaries/dialogs/card-unblock-dialog/card-unblock-dialog.component.ts","src/app/ui/components/pbm/beneficiaries/dialogs/card-unblock-dialog/card-unblock-dialog.component.html","src/app/ui/models/domains/pbm/sales-history/filter-by.ts","src/app/ui/services/pbm/sales-history.service.ts","src/app/ui/components/pbm/sales-histories/sales-history-companies/sales-history-company-card/sales-history-company-card.component.ts","src/app/ui/components/pbm/sales-histories/sales-history-companies/sales-history-company-card/sales-history-company-card.component.html","src/app/ui/components/pbm/sales-histories/sales-history-companies/sales-history-companies.component.ts","src/app/ui/components/pbm/sales-histories/sales-history-companies/sales-history-companies.component.html","src/app/ui/components/pbm/sales-histories/sales-history-company/sales-history-company.component.ts","src/app/ui/components/pbm/sales-histories/sales-history-company/sales-history-company.component.html","src/app/ui/components/pbm/sales-histories/validators/filter-form-validator.ts","src/app/ui/components/pbm/users/search-user/search-user.component.ts","src/app/ui/components/pbm/users/search-user/search-user.component.html","src/app/ui/models/domains/pbm/user/register-user-handler.ts","src/app/ui/components/pbm/users/validators/register-user-form.validator.ts","src/app/ui/components/pbm/users/register-user/register-user.component.ts","src/app/ui/components/pbm/users/register-user/register-user.component.html","src/app/ui/components/auto-complete-search/auto-complete-search.component.ts","src/app/ui/components/auto-complete-search/auto-complete-search.component.html","src/app/ui/components/pbm/financial-statement/financial-statement-company/financial-statement-company.component.ts","src/app/ui/components/pbm/financial-statement/financial-statement-company/financial-statement-company.component.html","src/app/ui/components/pbm/financial-statement/search-financial-statement/search-financial-statement.component.ts","src/app/ui/components/pbm/financial-statement/search-financial-statement/search-financial-statement.component.html","src/app/ui/models/domains/pbm/period.ts","src/app/ui/components/pbm/financial-statement/financial-statement-beneficiary/view-items/beneficiary-view-item.ts","src/app/ui/components/pbm/financial-statement/financial-statement-beneficiary/view-items/holder-view-item.ts","src/app/ui/components/pbm/financial-statement/financial-statement-beneficiary/factory/holder-view-item.factory.ts","src/app/ui/components/pbm/financial-statement/financial-statement-beneficiary/view-items/dependent-view-item.ts","src/app/ui/components/pbm/financial-statement/financial-statement-beneficiary/factory/dependent-view-item.factory.ts","src/app/ui/components/pbm/financial-statement/financial-statement-beneficiary/view-items/financial-statement-header-view-item.ts","src/app/ui/components/pbm/financial-statement/financial-statement-beneficiary/view-items/financial-statement-view-item.ts","src/app/ui/components/pbm/financial-statement/financial-statement-beneficiary/factory/financial-statement-header-view-item.factory.ts","src/app/ui/components/pbm/financial-statement/financial-statement-beneficiary/financial-statement-beneficiary.component.ts","src/app/ui/components/pbm/financial-statement/financial-statement-beneficiary/financial-statement-beneficiary.component.html","src/app/ui/components/pbm/beneficiaries/block-beneficiaries/block-beneficiaries.component.ts","src/app/ui/components/pbm/beneficiaries/block-beneficiaries/block-beneficiaries.component.html","src/app/ui/components/pbm/beneficiaries/validators/dependent-validator.ts","src/app/ui/components/pbm/beneficiaries/edit-dependent/edit-dependent.component.ts","src/app/ui/components/pbm/beneficiaries/edit-dependent/edit-dependent.component.html","src/app/ui/components/pbm/beneficiaries/unblock-beneficiaries/unblock-beneficiaries.component.ts","src/app/ui/components/pbm/beneficiaries/unblock-beneficiaries/unblock-beneficiaries.component.html","src/app/ui/models/domains/pbm/indicators/abstract-indicator-strategy.ts","src/app/ui/pages/home/indicator-data-strategies.ts","src/app/ui/models/domains/pbm/indicators/beneficiary-usage-data.ts","src/app/ui/models/domains/pbm/indicators/company-subsidiary-balance-data.ts","src/app/ui/models/domains/pbm/indicators/monthly-balance-data.ts","src/app/ui/models/domains/pbm/indicators/product-subtype-data.ts","src/app/ui/models/domains/pbm/indicators/top-ten-networks-data.ts","src/app/ui/models/domains/pbm/indicators/top-ten-practitioner-data.ts","src/app/ui/models/domains/pbm/indicators/top-ten-indicator-data.ts","src/app/ui/services/pbm/indicator.service.ts","src/app/ui/services/pbm/indicator-mediator.ts","src/app/ui/components/pbm/home/dialogs/company-filter-dialog/company-filter-dialog.component.ts","src/app/ui/components/pbm/home/dialogs/company-filter-dialog/company-filter-dialog.component.html","src/app/ui/components/pbm/home/indicator-filter-component/indicator-filter.component.ts","src/app/ui/components/pbm/home/indicator-filter-component/indicator-filter.component.html","src/app/ui/components/pbm/home/indicator-loader-component/indicator-loader.component.ts","src/app/ui/components/pbm/home/indicator-loader-component/indicator-loader.component.html","src/app/ui/components/pbm/home/beneficiary-usage-indicator-component/beneficiary-usage-indicator.component.ts","src/app/ui/components/pbm/home/beneficiary-usage-indicator-component/beneficiary-usage-indicator.component.html","src/app/ui/components/pbm/home/company-balance/company-balance.component.ts","src/app/ui/components/pbm/home/company-balance/company-balance.component.html","src/app/ui/components/pbm/home/top-ten-products-indicator-component/top-ten-products-indicator.component.ts","src/app/ui/components/pbm/home/top-ten-products-indicator-component/top-ten-products-indicator.component.html","src/app/ui/components/pbm/home/company-subsidiary-balance/company-subsidiary-balance.component.ts","src/app/ui/components/pbm/home/company-subsidiary-balance/company-subsidiary-balance.component.html","node_modules/chartjs-plugin-annotation/dist/chartjs-plugin-annotation.esm.js","node_modules/chartjs-plugin-datalabels/dist/chartjs-plugin-datalabels.esm.js","src/app/ui/components/pbm/home/product-subtype-indicator-component/product-subtype-indicator.component.ts","src/app/ui/components/pbm/home/product-subtype-indicator-component/product-subtype-indicator.component.html","src/app/ui/components/pbm/home/top-ten-therapeutic-class/top-ten-therapeutic-class.component.ts","src/app/ui/components/pbm/home/top-ten-therapeutic-class/top-ten-therapeutic-class.component.html","src/app/ui/components/pbm/home/top-ten-network-indicator-component/top-ten-networks-indicator.component.ts","src/app/ui/components/pbm/home/top-ten-network-indicator-component/top-ten-networks-indicator.component.html","src/app/ui/components/pbm/home/top-ten-practitioner-indicator-component/top-ten-practitioner-indicator.component.ts","src/app/ui/components/pbm/home/top-ten-practitioner-indicator-component/top-ten-practitioner-indicator.component.html","src/app/ui/components/pbm/financial-report/company-financial-report/company-financial-report.component.ts","src/app/ui/components/pbm/financial-report/company-financial-report/company-financial-report.component.html","src/app/ui/models/domains/pbm/industry/industry-discount-search-parameters.model.ts","src/app/ui/models/domains/pbm/industry/add-industry-product-discount.model.ts","src/app/ui/components/pbm/lpm-management/edit-lpm/add-lpm-product-dialog/add-lpm-product-dialog.component.ts","src/app/ui/components/pbm/lpm-management/edit-lpm/add-lpm-product-dialog/add-lpm-product-dialog.component.html","src/app/ui/components/pbm/lpm-management/edit-lpm/inline-edit/inline-edit.component.ts","src/app/ui/components/pbm/lpm-management/edit-lpm/inline-edit/inline-edit.component.html","src/app/ui/components/pbm/lpm-management/edit-lpm/edit-lpm.component.ts","src/app/ui/components/pbm/lpm-management/edit-lpm/edit-lpm.component.html","src/app/ui/models/domains/pbm/industry/file-industry-products-discounts.model.ts","src/app/ui/components/pbm/lpm-management/add-industry-discounts/add-industry-discounts.component.ts","src/app/ui/components/pbm/lpm-management/add-industry-discounts/add-industry-discounts.component.html","src/app/ui/components/pbm/lpm-management/search-lpm-management/search-lpm-management.component.ts","src/app/ui/components/pbm/lpm-management/search-lpm-management/search-lpm-management.component.html","src/app/ui/components/pbm/product-management/search-product/product-management-search-request.ts","src/app/ui/components/pbm/product-management/search-product/search-product.component.ts","src/app/ui/components/pbm/product-management/search-product/search-product.component.html","src/app/ui/services/pbm/product-management.service.ts","src/app/ui/models/domains/auto-complete/therapeutic-class-product-auto-complete-item.ts","src/app/ui/models/domains/auto-complete/therapeutic-class-product-auto-complete-search-provider.ts","src/app/ui/components/pbm/product-management/edit-product/product-label-info-form.ts","src/app/ui/components/pbm/product-management/edit-product/update-product-validator.ts","src/app/ui/components/pbm/product-management/edit-product/edit-product.component.ts","src/app/ui/components/pbm/product-management/edit-product/edit-product.component.html","src/app/ui/models/domains/pbm/product-management/pricing-info-view-item.model.ts","src/app/ui/models/domains/pbm/product-management/pricing-info-view-item.factory.ts","src/app/ui/models/domains/pbm/product-management/pricing-state-view-item.model.ts","src/app/ui/components/pbm/product-management/edit-product-pricing/edit-product-pricing.component.ts","src/app/ui/components/pbm/product-management/edit-product-pricing/edit-product-pricing.component.html","src/app/ui/components/pbm/product-management/insert-product/create-product-validator.ts","src/app/ui/components/pbm/product-management/insert-product/insert-product.component.ts","src/app/ui/components/pbm/product-management/insert-product/insert-product.component.html","src/app/ui/models/domains/pbm/practitioner-management/search-practitioner.request.ts","src/app/ui/services/pbm/practitioner-management.service.ts","src/app/ui/components/pbm/practitioner-management/search-practitioner/search-practitioner.component.ts","src/app/ui/components/pbm/practitioner-management/search-practitioner/search-practitioner.component.html","src/app/ui/models/domains/auto-complete/practitioner-specialty-auto-complete-item.ts","src/app/ui/models/domains/auto-complete/practitioner-specialty-auto-complete-provider.ts","src/app/ui/components/pbm/practitioner-management/practitioner-form.validator.ts","src/app/ui/components/pbm/practitioner-management/practitioner.form.ts","src/app/ui/components/pbm/practitioner-management/register-practitioner/register-practitioner.component.ts","src/app/ui/components/pbm/practitioner-management/register-practitioner/register-practitioner.component.html","src/app/ui/components/pbm/practitioner-management/edit-practitioner/edit-practitioner.component.ts","src/app/ui/components/pbm/practitioner-management/edit-practitioner/edit-practitioner.component.html","src/app/ui/models/domains/pbm/clusters/cluster-search-parameters.model.ts","src/app/ui/models/domains/pbm/exports/file-export-processor.ts","src/app/ui/components/pbm/cluster-management/search-cluster-management/search-cluster-export-order-request.ts","src/app/ui/components/pbm/cluster-management/search-cluster-management/search-cluster-management.component.ts","src/app/ui/components/pbm/cluster-management/search-cluster-management/search-cluster-management.component.html","src/app/ui/models/domains/pbm/clusters/file-cluster.ts","src/app/ui/components/pbm/cluster-management/edit-cluster/add-batch-product-dialog/add-batch-export-order-request.ts","src/app/ui/components/pbm/cluster-management/edit-cluster/add-batch-product-dialog/add-batch-product-dialog.component.ts","src/app/ui/components/pbm/cluster-management/edit-cluster/add-batch-product-dialog/add-batch-product-dialog.component.html","src/app/ui/models/domains/pbm/clusters/add-cluster-product.model.ts","src/app/ui/components/pbm/cluster-management/edit-cluster/add-product-dialog/add-product-dialog.component.ts","src/app/ui/components/pbm/cluster-management/edit-cluster/add-product-dialog/add-product-dialog.component.html","src/app/ui/components/pbm/cluster-management/edit-cluster/edit-cluster.component.ts","src/app/ui/components/pbm/cluster-management/edit-cluster/edit-cluster.component.html","src/app/ui/components/pbm/companies/create-company/create-company.component.ts","src/app/ui/components/pbm/companies/create-company/create-company.component.html","src/app/ui/models/domains/pbm/companies/company-handler-master-data.ts","src/app/ui/components/pbm/companies/register-company-data-quality/register-company-data-quality.component.ts","src/app/ui/components/pbm/companies/register-company-data-quality/register-company-data-quality.component.html","src/app/ui/components/component.module.ts"],"sourcesContent":["//! moment.js locale configuration\n//! locale : Portuguese (Brazil) [pt-br]\n//! author : Caio Ribeiro Pereira : https://github.com/caio-ribeiro-pereira\n\n;\n(function (global, factory) {\n typeof exports === 'object' && typeof module !== 'undefined' && typeof require === 'function' ? factory(require('../moment')) : typeof define === 'function' && define.amd ? define(['../moment'], factory) : factory(global.moment);\n})(this, function (moment) {\n 'use strict';\n\n //! moment.js locale configuration\n var ptBr = moment.defineLocale('pt-br', {\n months: 'janeiro_fevereiro_março_abril_maio_junho_julho_agosto_setembro_outubro_novembro_dezembro'.split('_'),\n monthsShort: 'jan_fev_mar_abr_mai_jun_jul_ago_set_out_nov_dez'.split('_'),\n weekdays: 'domingo_segunda-feira_terça-feira_quarta-feira_quinta-feira_sexta-feira_sábado'.split('_'),\n weekdaysShort: 'dom_seg_ter_qua_qui_sex_sáb'.split('_'),\n weekdaysMin: 'do_2ª_3ª_4ª_5ª_6ª_sá'.split('_'),\n weekdaysParseExact: true,\n longDateFormat: {\n LT: 'HH:mm',\n LTS: 'HH:mm:ss',\n L: 'DD/MM/YYYY',\n LL: 'D [de] MMMM [de] YYYY',\n LLL: 'D [de] MMMM [de] YYYY [às] HH:mm',\n LLLL: 'dddd, D [de] MMMM [de] YYYY [às] HH:mm'\n },\n calendar: {\n sameDay: '[Hoje às] LT',\n nextDay: '[Amanhã às] LT',\n nextWeek: 'dddd [às] LT',\n lastDay: '[Ontem às] LT',\n lastWeek: function () {\n return this.day() === 0 || this.day() === 6 ? '[Último] dddd [às] LT' // Saturday + Sunday\n : '[Última] dddd [às] LT'; // Monday - Friday\n },\n sameElse: 'L'\n },\n relativeTime: {\n future: 'em %s',\n past: 'há %s',\n s: 'poucos segundos',\n ss: '%d segundos',\n m: 'um minuto',\n mm: '%d minutos',\n h: 'uma hora',\n hh: '%d horas',\n d: 'um dia',\n dd: '%d dias',\n M: 'um mês',\n MM: '%d meses',\n y: 'um ano',\n yy: '%d anos'\n },\n dayOfMonthOrdinalParse: /\\d{1,2}º/,\n ordinal: '%dº',\n invalidDate: 'Data inválida'\n });\n return ptBr;\n});","/*!\n * @kurkle/color v0.3.4\n * https://github.com/kurkle/color#readme\n * (c) 2024 Jukka Kurkela\n * Released under the MIT License\n */\nfunction round(v) {\n return v + 0.5 | 0;\n}\nconst lim = (v, l, h) => Math.max(Math.min(v, h), l);\nfunction p2b(v) {\n return lim(round(v * 2.55), 0, 255);\n}\nfunction b2p(v) {\n return lim(round(v / 2.55), 0, 100);\n}\nfunction n2b(v) {\n return lim(round(v * 255), 0, 255);\n}\nfunction b2n(v) {\n return lim(round(v / 2.55) / 100, 0, 1);\n}\nfunction n2p(v) {\n return lim(round(v * 100), 0, 100);\n}\nconst map$1 = {\n 0: 0,\n 1: 1,\n 2: 2,\n 3: 3,\n 4: 4,\n 5: 5,\n 6: 6,\n 7: 7,\n 8: 8,\n 9: 9,\n A: 10,\n B: 11,\n C: 12,\n D: 13,\n E: 14,\n F: 15,\n a: 10,\n b: 11,\n c: 12,\n d: 13,\n e: 14,\n f: 15\n};\nconst hex = [...'0123456789ABCDEF'];\nconst h1 = b => hex[b & 0xF];\nconst h2 = b => hex[(b & 0xF0) >> 4] + hex[b & 0xF];\nconst eq = b => (b & 0xF0) >> 4 === (b & 0xF);\nconst isShort = v => eq(v.r) && eq(v.g) && eq(v.b) && eq(v.a);\nfunction hexParse(str) {\n var len = str.length;\n var ret;\n if (str[0] === '#') {\n if (len === 4 || len === 5) {\n ret = {\n r: 255 & map$1[str[1]] * 17,\n g: 255 & map$1[str[2]] * 17,\n b: 255 & map$1[str[3]] * 17,\n a: len === 5 ? map$1[str[4]] * 17 : 255\n };\n } else if (len === 7 || len === 9) {\n ret = {\n r: map$1[str[1]] << 4 | map$1[str[2]],\n g: map$1[str[3]] << 4 | map$1[str[4]],\n b: map$1[str[5]] << 4 | map$1[str[6]],\n a: len === 9 ? map$1[str[7]] << 4 | map$1[str[8]] : 255\n };\n }\n }\n return ret;\n}\nconst alpha = (a, f) => a < 255 ? f(a) : '';\nfunction hexString(v) {\n var f = isShort(v) ? h1 : h2;\n return v ? '#' + f(v.r) + f(v.g) + f(v.b) + alpha(v.a, f) : undefined;\n}\nconst HUE_RE = /^(hsla?|hwb|hsv)\\(\\s*([-+.e\\d]+)(?:deg)?[\\s,]+([-+.e\\d]+)%[\\s,]+([-+.e\\d]+)%(?:[\\s,]+([-+.e\\d]+)(%)?)?\\s*\\)$/;\nfunction hsl2rgbn(h, s, l) {\n const a = s * Math.min(l, 1 - l);\n const f = (n, k = (n + h / 30) % 12) => l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);\n return [f(0), f(8), f(4)];\n}\nfunction hsv2rgbn(h, s, v) {\n const f = (n, k = (n + h / 60) % 6) => v - v * s * Math.max(Math.min(k, 4 - k, 1), 0);\n return [f(5), f(3), f(1)];\n}\nfunction hwb2rgbn(h, w, b) {\n const rgb = hsl2rgbn(h, 1, 0.5);\n let i;\n if (w + b > 1) {\n i = 1 / (w + b);\n w *= i;\n b *= i;\n }\n for (i = 0; i < 3; i++) {\n rgb[i] *= 1 - w - b;\n rgb[i] += w;\n }\n return rgb;\n}\nfunction hueValue(r, g, b, d, max) {\n if (r === max) {\n return (g - b) / d + (g < b ? 6 : 0);\n }\n if (g === max) {\n return (b - r) / d + 2;\n }\n return (r - g) / d + 4;\n}\nfunction rgb2hsl(v) {\n const range = 255;\n const r = v.r / range;\n const g = v.g / range;\n const b = v.b / range;\n const max = Math.max(r, g, b);\n const min = Math.min(r, g, b);\n const l = (max + min) / 2;\n let h, s, d;\n if (max !== min) {\n d = max - min;\n s = l > 0.5 ? d / (2 - max - min) : d / (max + min);\n h = hueValue(r, g, b, d, max);\n h = h * 60 + 0.5;\n }\n return [h | 0, s || 0, l];\n}\nfunction calln(f, a, b, c) {\n return (Array.isArray(a) ? f(a[0], a[1], a[2]) : f(a, b, c)).map(n2b);\n}\nfunction hsl2rgb(h, s, l) {\n return calln(hsl2rgbn, h, s, l);\n}\nfunction hwb2rgb(h, w, b) {\n return calln(hwb2rgbn, h, w, b);\n}\nfunction hsv2rgb(h, s, v) {\n return calln(hsv2rgbn, h, s, v);\n}\nfunction hue(h) {\n return (h % 360 + 360) % 360;\n}\nfunction hueParse(str) {\n const m = HUE_RE.exec(str);\n let a = 255;\n let v;\n if (!m) {\n return;\n }\n if (m[5] !== v) {\n a = m[6] ? p2b(+m[5]) : n2b(+m[5]);\n }\n const h = hue(+m[2]);\n const p1 = +m[3] / 100;\n const p2 = +m[4] / 100;\n if (m[1] === 'hwb') {\n v = hwb2rgb(h, p1, p2);\n } else if (m[1] === 'hsv') {\n v = hsv2rgb(h, p1, p2);\n } else {\n v = hsl2rgb(h, p1, p2);\n }\n return {\n r: v[0],\n g: v[1],\n b: v[2],\n a: a\n };\n}\nfunction rotate(v, deg) {\n var h = rgb2hsl(v);\n h[0] = hue(h[0] + deg);\n h = hsl2rgb(h);\n v.r = h[0];\n v.g = h[1];\n v.b = h[2];\n}\nfunction hslString(v) {\n if (!v) {\n return;\n }\n const a = rgb2hsl(v);\n const h = a[0];\n const s = n2p(a[1]);\n const l = n2p(a[2]);\n return v.a < 255 ? `hsla(${h}, ${s}%, ${l}%, ${b2n(v.a)})` : `hsl(${h}, ${s}%, ${l}%)`;\n}\nconst map = {\n x: 'dark',\n Z: 'light',\n Y: 're',\n X: 'blu',\n W: 'gr',\n V: 'medium',\n U: 'slate',\n A: 'ee',\n T: 'ol',\n S: 'or',\n B: 'ra',\n C: 'lateg',\n D: 'ights',\n R: 'in',\n Q: 'turquois',\n E: 'hi',\n P: 'ro',\n O: 'al',\n N: 'le',\n M: 'de',\n L: 'yello',\n F: 'en',\n K: 'ch',\n G: 'arks',\n H: 'ea',\n I: 'ightg',\n J: 'wh'\n};\nconst names$1 = {\n OiceXe: 'f0f8ff',\n antiquewEte: 'faebd7',\n aqua: 'ffff',\n aquamarRe: '7fffd4',\n azuY: 'f0ffff',\n beige: 'f5f5dc',\n bisque: 'ffe4c4',\n black: '0',\n blanKedOmond: 'ffebcd',\n Xe: 'ff',\n XeviTet: '8a2be2',\n bPwn: 'a52a2a',\n burlywood: 'deb887',\n caMtXe: '5f9ea0',\n KartYuse: '7fff00',\n KocTate: 'd2691e',\n cSO: 'ff7f50',\n cSnflowerXe: '6495ed',\n cSnsilk: 'fff8dc',\n crimson: 'dc143c',\n cyan: 'ffff',\n xXe: '8b',\n xcyan: '8b8b',\n xgTMnPd: 'b8860b',\n xWay: 'a9a9a9',\n xgYF: '6400',\n xgYy: 'a9a9a9',\n xkhaki: 'bdb76b',\n xmagFta: '8b008b',\n xTivegYF: '556b2f',\n xSange: 'ff8c00',\n xScEd: '9932cc',\n xYd: '8b0000',\n xsOmon: 'e9967a',\n xsHgYF: '8fbc8f',\n xUXe: '483d8b',\n xUWay: '2f4f4f',\n xUgYy: '2f4f4f',\n xQe: 'ced1',\n xviTet: '9400d3',\n dAppRk: 'ff1493',\n dApskyXe: 'bfff',\n dimWay: '696969',\n dimgYy: '696969',\n dodgerXe: '1e90ff',\n fiYbrick: 'b22222',\n flSOwEte: 'fffaf0',\n foYstWAn: '228b22',\n fuKsia: 'ff00ff',\n gaRsbSo: 'dcdcdc',\n ghostwEte: 'f8f8ff',\n gTd: 'ffd700',\n gTMnPd: 'daa520',\n Way: '808080',\n gYF: '8000',\n gYFLw: 'adff2f',\n gYy: '808080',\n honeyMw: 'f0fff0',\n hotpRk: 'ff69b4',\n RdianYd: 'cd5c5c',\n Rdigo: '4b0082',\n ivSy: 'fffff0',\n khaki: 'f0e68c',\n lavFMr: 'e6e6fa',\n lavFMrXsh: 'fff0f5',\n lawngYF: '7cfc00',\n NmoncEffon: 'fffacd',\n ZXe: 'add8e6',\n ZcSO: 'f08080',\n Zcyan: 'e0ffff',\n ZgTMnPdLw: 'fafad2',\n ZWay: 'd3d3d3',\n ZgYF: '90ee90',\n ZgYy: 'd3d3d3',\n ZpRk: 'ffb6c1',\n ZsOmon: 'ffa07a',\n ZsHgYF: '20b2aa',\n ZskyXe: '87cefa',\n ZUWay: '778899',\n ZUgYy: '778899',\n ZstAlXe: 'b0c4de',\n ZLw: 'ffffe0',\n lime: 'ff00',\n limegYF: '32cd32',\n lRF: 'faf0e6',\n magFta: 'ff00ff',\n maPon: '800000',\n VaquamarRe: '66cdaa',\n VXe: 'cd',\n VScEd: 'ba55d3',\n VpurpN: '9370db',\n VsHgYF: '3cb371',\n VUXe: '7b68ee',\n VsprRggYF: 'fa9a',\n VQe: '48d1cc',\n VviTetYd: 'c71585',\n midnightXe: '191970',\n mRtcYam: 'f5fffa',\n mistyPse: 'ffe4e1',\n moccasR: 'ffe4b5',\n navajowEte: 'ffdead',\n navy: '80',\n Tdlace: 'fdf5e6',\n Tive: '808000',\n TivedBb: '6b8e23',\n Sange: 'ffa500',\n SangeYd: 'ff4500',\n ScEd: 'da70d6',\n pOegTMnPd: 'eee8aa',\n pOegYF: '98fb98',\n pOeQe: 'afeeee',\n pOeviTetYd: 'db7093',\n papayawEp: 'ffefd5',\n pHKpuff: 'ffdab9',\n peru: 'cd853f',\n pRk: 'ffc0cb',\n plum: 'dda0dd',\n powMrXe: 'b0e0e6',\n purpN: '800080',\n YbeccapurpN: '663399',\n Yd: 'ff0000',\n Psybrown: 'bc8f8f',\n PyOXe: '4169e1',\n saddNbPwn: '8b4513',\n sOmon: 'fa8072',\n sandybPwn: 'f4a460',\n sHgYF: '2e8b57',\n sHshell: 'fff5ee',\n siFna: 'a0522d',\n silver: 'c0c0c0',\n skyXe: '87ceeb',\n UXe: '6a5acd',\n UWay: '708090',\n UgYy: '708090',\n snow: 'fffafa',\n sprRggYF: 'ff7f',\n stAlXe: '4682b4',\n tan: 'd2b48c',\n teO: '8080',\n tEstN: 'd8bfd8',\n tomato: 'ff6347',\n Qe: '40e0d0',\n viTet: 'ee82ee',\n JHt: 'f5deb3',\n wEte: 'ffffff',\n wEtesmoke: 'f5f5f5',\n Lw: 'ffff00',\n LwgYF: '9acd32'\n};\nfunction unpack() {\n const unpacked = {};\n const keys = Object.keys(names$1);\n const tkeys = Object.keys(map);\n let i, j, k, ok, nk;\n for (i = 0; i < keys.length; i++) {\n ok = nk = keys[i];\n for (j = 0; j < tkeys.length; j++) {\n k = tkeys[j];\n nk = nk.replace(k, map[k]);\n }\n k = parseInt(names$1[ok], 16);\n unpacked[nk] = [k >> 16 & 0xFF, k >> 8 & 0xFF, k & 0xFF];\n }\n return unpacked;\n}\nlet names;\nfunction nameParse(str) {\n if (!names) {\n names = unpack();\n names.transparent = [0, 0, 0, 0];\n }\n const a = names[str.toLowerCase()];\n return a && {\n r: a[0],\n g: a[1],\n b: a[2],\n a: a.length === 4 ? a[3] : 255\n };\n}\nconst RGB_RE = /^rgba?\\(\\s*([-+.\\d]+)(%)?[\\s,]+([-+.e\\d]+)(%)?[\\s,]+([-+.e\\d]+)(%)?(?:[\\s,/]+([-+.e\\d]+)(%)?)?\\s*\\)$/;\nfunction rgbParse(str) {\n const m = RGB_RE.exec(str);\n let a = 255;\n let r, g, b;\n if (!m) {\n return;\n }\n if (m[7] !== r) {\n const v = +m[7];\n a = m[8] ? p2b(v) : lim(v * 255, 0, 255);\n }\n r = +m[1];\n g = +m[3];\n b = +m[5];\n r = 255 & (m[2] ? p2b(r) : lim(r, 0, 255));\n g = 255 & (m[4] ? p2b(g) : lim(g, 0, 255));\n b = 255 & (m[6] ? p2b(b) : lim(b, 0, 255));\n return {\n r: r,\n g: g,\n b: b,\n a: a\n };\n}\nfunction rgbString(v) {\n return v && (v.a < 255 ? `rgba(${v.r}, ${v.g}, ${v.b}, ${b2n(v.a)})` : `rgb(${v.r}, ${v.g}, ${v.b})`);\n}\nconst to = v => v <= 0.0031308 ? v * 12.92 : Math.pow(v, 1.0 / 2.4) * 1.055 - 0.055;\nconst from = v => v <= 0.04045 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4);\nfunction interpolate(rgb1, rgb2, t) {\n const r = from(b2n(rgb1.r));\n const g = from(b2n(rgb1.g));\n const b = from(b2n(rgb1.b));\n return {\n r: n2b(to(r + t * (from(b2n(rgb2.r)) - r))),\n g: n2b(to(g + t * (from(b2n(rgb2.g)) - g))),\n b: n2b(to(b + t * (from(b2n(rgb2.b)) - b))),\n a: rgb1.a + t * (rgb2.a - rgb1.a)\n };\n}\nfunction modHSL(v, i, ratio) {\n if (v) {\n let tmp = rgb2hsl(v);\n tmp[i] = Math.max(0, Math.min(tmp[i] + tmp[i] * ratio, i === 0 ? 360 : 1));\n tmp = hsl2rgb(tmp);\n v.r = tmp[0];\n v.g = tmp[1];\n v.b = tmp[2];\n }\n}\nfunction clone(v, proto) {\n return v ? Object.assign(proto || {}, v) : v;\n}\nfunction fromObject(input) {\n var v = {\n r: 0,\n g: 0,\n b: 0,\n a: 255\n };\n if (Array.isArray(input)) {\n if (input.length >= 3) {\n v = {\n r: input[0],\n g: input[1],\n b: input[2],\n a: 255\n };\n if (input.length > 3) {\n v.a = n2b(input[3]);\n }\n }\n } else {\n v = clone(input, {\n r: 0,\n g: 0,\n b: 0,\n a: 1\n });\n v.a = n2b(v.a);\n }\n return v;\n}\nfunction functionParse(str) {\n if (str.charAt(0) === 'r') {\n return rgbParse(str);\n }\n return hueParse(str);\n}\nclass Color {\n constructor(input) {\n if (input instanceof Color) {\n return input;\n }\n const type = typeof input;\n let v;\n if (type === 'object') {\n v = fromObject(input);\n } else if (type === 'string') {\n v = hexParse(input) || nameParse(input) || functionParse(input);\n }\n this._rgb = v;\n this._valid = !!v;\n }\n get valid() {\n return this._valid;\n }\n get rgb() {\n var v = clone(this._rgb);\n if (v) {\n v.a = b2n(v.a);\n }\n return v;\n }\n set rgb(obj) {\n this._rgb = fromObject(obj);\n }\n rgbString() {\n return this._valid ? rgbString(this._rgb) : undefined;\n }\n hexString() {\n return this._valid ? hexString(this._rgb) : undefined;\n }\n hslString() {\n return this._valid ? hslString(this._rgb) : undefined;\n }\n mix(color, weight) {\n if (color) {\n const c1 = this.rgb;\n const c2 = color.rgb;\n let w2;\n const p = weight === w2 ? 0.5 : weight;\n const w = 2 * p - 1;\n const a = c1.a - c2.a;\n const w1 = ((w * a === -1 ? w : (w + a) / (1 + w * a)) + 1) / 2.0;\n w2 = 1 - w1;\n c1.r = 0xFF & w1 * c1.r + w2 * c2.r + 0.5;\n c1.g = 0xFF & w1 * c1.g + w2 * c2.g + 0.5;\n c1.b = 0xFF & w1 * c1.b + w2 * c2.b + 0.5;\n c1.a = p * c1.a + (1 - p) * c2.a;\n this.rgb = c1;\n }\n return this;\n }\n interpolate(color, t) {\n if (color) {\n this._rgb = interpolate(this._rgb, color._rgb, t);\n }\n return this;\n }\n clone() {\n return new Color(this.rgb);\n }\n alpha(a) {\n this._rgb.a = n2b(a);\n return this;\n }\n clearer(ratio) {\n const rgb = this._rgb;\n rgb.a *= 1 - ratio;\n return this;\n }\n greyscale() {\n const rgb = this._rgb;\n const val = round(rgb.r * 0.3 + rgb.g * 0.59 + rgb.b * 0.11);\n rgb.r = rgb.g = rgb.b = val;\n return this;\n }\n opaquer(ratio) {\n const rgb = this._rgb;\n rgb.a *= 1 + ratio;\n return this;\n }\n negate() {\n const v = this._rgb;\n v.r = 255 - v.r;\n v.g = 255 - v.g;\n v.b = 255 - v.b;\n return this;\n }\n lighten(ratio) {\n modHSL(this._rgb, 2, ratio);\n return this;\n }\n darken(ratio) {\n modHSL(this._rgb, 2, -ratio);\n return this;\n }\n saturate(ratio) {\n modHSL(this._rgb, 1, ratio);\n return this;\n }\n desaturate(ratio) {\n modHSL(this._rgb, 1, -ratio);\n return this;\n }\n rotate(deg) {\n rotate(this._rgb, deg);\n return this;\n }\n}\nfunction index_esm(input) {\n return new Color(input);\n}\nexport { Color, b2n, b2p, index_esm as default, hexParse, hexString, hsl2rgb, hslString, hsv2rgb, hueParse, hwb2rgb, lim, n2b, n2p, nameParse, p2b, rgb2hsl, rgbParse, rgbString, rotate, round };","/*!\n * Chart.js v4.4.7\n * https://www.chartjs.org\n * (c) 2024 Chart.js Contributors\n * Released under the MIT License\n */\nimport { Color } from '@kurkle/color';\n\n/**\n * @namespace Chart.helpers\n */ /**\n * An empty function that can be used, for example, for optional callback.\n */\nfunction noop() {\n /* noop */}\n/**\n * Returns a unique id, sequentially generated from a global variable.\n */\nconst uid = (() => {\n let id = 0;\n return () => id++;\n})();\n/**\n * Returns true if `value` is neither null nor undefined, else returns false.\n * @param value - The value to test.\n * @since 2.7.0\n */\nfunction isNullOrUndef(value) {\n return value === null || value === undefined;\n}\n/**\n * Returns true if `value` is an array (including typed arrays), else returns false.\n * @param value - The value to test.\n * @function\n */\nfunction isArray(value) {\n if (Array.isArray && Array.isArray(value)) {\n return true;\n }\n const type = Object.prototype.toString.call(value);\n if (type.slice(0, 7) === '[object' && type.slice(-6) === 'Array]') {\n return true;\n }\n return false;\n}\n/**\n * Returns true if `value` is an object (excluding null), else returns false.\n * @param value - The value to test.\n * @since 2.7.0\n */\nfunction isObject(value) {\n return value !== null && Object.prototype.toString.call(value) === '[object Object]';\n}\n/**\n * Returns true if `value` is a finite number, else returns false\n * @param value - The value to test.\n */\nfunction isNumberFinite(value) {\n return (typeof value === 'number' || value instanceof Number) && isFinite(+value);\n}\n/**\n * Returns `value` if finite, else returns `defaultValue`.\n * @param value - The value to return if defined.\n * @param defaultValue - The value to return if `value` is not finite.\n */\nfunction finiteOrDefault(value, defaultValue) {\n return isNumberFinite(value) ? value : defaultValue;\n}\n/**\n * Returns `value` if defined, else returns `defaultValue`.\n * @param value - The value to return if defined.\n * @param defaultValue - The value to return if `value` is undefined.\n */\nfunction valueOrDefault(value, defaultValue) {\n return typeof value === 'undefined' ? defaultValue : value;\n}\nconst toPercentage = (value, dimension) => typeof value === 'string' && value.endsWith('%') ? parseFloat(value) / 100 : +value / dimension;\nconst toDimension = (value, dimension) => typeof value === 'string' && value.endsWith('%') ? parseFloat(value) / 100 * dimension : +value;\n/**\n * Calls `fn` with the given `args` in the scope defined by `thisArg` and returns the\n * value returned by `fn`. If `fn` is not a function, this method returns undefined.\n * @param fn - The function to call.\n * @param args - The arguments with which `fn` should be called.\n * @param [thisArg] - The value of `this` provided for the call to `fn`.\n */\nfunction callback(fn, args, thisArg) {\n if (fn && typeof fn.call === 'function') {\n return fn.apply(thisArg, args);\n }\n}\nfunction each(loopable, fn, thisArg, reverse) {\n let i, len, keys;\n if (isArray(loopable)) {\n len = loopable.length;\n if (reverse) {\n for (i = len - 1; i >= 0; i--) {\n fn.call(thisArg, loopable[i], i);\n }\n } else {\n for (i = 0; i < len; i++) {\n fn.call(thisArg, loopable[i], i);\n }\n }\n } else if (isObject(loopable)) {\n keys = Object.keys(loopable);\n len = keys.length;\n for (i = 0; i < len; i++) {\n fn.call(thisArg, loopable[keys[i]], keys[i]);\n }\n }\n}\n/**\n * Returns true if the `a0` and `a1` arrays have the same content, else returns false.\n * @param a0 - The array to compare\n * @param a1 - The array to compare\n * @private\n */\nfunction _elementsEqual(a0, a1) {\n let i, ilen, v0, v1;\n if (!a0 || !a1 || a0.length !== a1.length) {\n return false;\n }\n for (i = 0, ilen = a0.length; i < ilen; ++i) {\n v0 = a0[i];\n v1 = a1[i];\n if (v0.datasetIndex !== v1.datasetIndex || v0.index !== v1.index) {\n return false;\n }\n }\n return true;\n}\n/**\n * Returns a deep copy of `source` without keeping references on objects and arrays.\n * @param source - The value to clone.\n */\nfunction clone(source) {\n if (isArray(source)) {\n return source.map(clone);\n }\n if (isObject(source)) {\n const target = Object.create(null);\n const keys = Object.keys(source);\n const klen = keys.length;\n let k = 0;\n for (; k < klen; ++k) {\n target[keys[k]] = clone(source[keys[k]]);\n }\n return target;\n }\n return source;\n}\nfunction isValidKey(key) {\n return ['__proto__', 'prototype', 'constructor'].indexOf(key) === -1;\n}\n/**\n * The default merger when Chart.helpers.merge is called without merger option.\n * Note(SB): also used by mergeConfig and mergeScaleConfig as fallback.\n * @private\n */\nfunction _merger(key, target, source, options) {\n if (!isValidKey(key)) {\n return;\n }\n const tval = target[key];\n const sval = source[key];\n if (isObject(tval) && isObject(sval)) {\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n merge(tval, sval, options);\n } else {\n target[key] = clone(sval);\n }\n}\nfunction merge(target, source, options) {\n const sources = isArray(source) ? source : [source];\n const ilen = sources.length;\n if (!isObject(target)) {\n return target;\n }\n options = options || {};\n const merger = options.merger || _merger;\n let current;\n for (let i = 0; i < ilen; ++i) {\n current = sources[i];\n if (!isObject(current)) {\n continue;\n }\n const keys = Object.keys(current);\n for (let k = 0, klen = keys.length; k < klen; ++k) {\n merger(keys[k], target, current, options);\n }\n }\n return target;\n}\nfunction mergeIf(target, source) {\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n return merge(target, source, {\n merger: _mergerIf\n });\n}\n/**\n * Merges source[key] in target[key] only if target[key] is undefined.\n * @private\n */\nfunction _mergerIf(key, target, source) {\n if (!isValidKey(key)) {\n return;\n }\n const tval = target[key];\n const sval = source[key];\n if (isObject(tval) && isObject(sval)) {\n mergeIf(tval, sval);\n } else if (!Object.prototype.hasOwnProperty.call(target, key)) {\n target[key] = clone(sval);\n }\n}\n/**\n * @private\n */\nfunction _deprecated(scope, value, previous, current) {\n if (value !== undefined) {\n console.warn(scope + ': \"' + previous + '\" is deprecated. Please use \"' + current + '\" instead');\n }\n}\n// resolveObjectKey resolver cache\nconst keyResolvers = {\n // Chart.helpers.core resolveObjectKey should resolve empty key to root object\n '': v => v,\n // default resolvers\n x: o => o.x,\n y: o => o.y\n};\n/**\n * @private\n */\nfunction _splitKey(key) {\n const parts = key.split('.');\n const keys = [];\n let tmp = '';\n for (const part of parts) {\n tmp += part;\n if (tmp.endsWith('\\\\')) {\n tmp = tmp.slice(0, -1) + '.';\n } else {\n keys.push(tmp);\n tmp = '';\n }\n }\n return keys;\n}\nfunction _getKeyResolver(key) {\n const keys = _splitKey(key);\n return obj => {\n for (const k of keys) {\n if (k === '') {\n break;\n }\n obj = obj && obj[k];\n }\n return obj;\n };\n}\nfunction resolveObjectKey(obj, key) {\n const resolver = keyResolvers[key] || (keyResolvers[key] = _getKeyResolver(key));\n return resolver(obj);\n}\n/**\n * @private\n */\nfunction _capitalize(str) {\n return str.charAt(0).toUpperCase() + str.slice(1);\n}\nconst defined = value => typeof value !== 'undefined';\nconst isFunction = value => typeof value === 'function';\n// Adapted from https://stackoverflow.com/questions/31128855/comparing-ecma6-sets-for-equality#31129384\nconst setsEqual = (a, b) => {\n if (a.size !== b.size) {\n return false;\n }\n for (const item of a) {\n if (!b.has(item)) {\n return false;\n }\n }\n return true;\n};\n/**\n * @param e - The event\n * @private\n */\nfunction _isClickEvent(e) {\n return e.type === 'mouseup' || e.type === 'click' || e.type === 'contextmenu';\n}\n\n/**\n * @alias Chart.helpers.math\n * @namespace\n */\nconst PI = Math.PI;\nconst TAU = 2 * PI;\nconst PITAU = TAU + PI;\nconst INFINITY = Number.POSITIVE_INFINITY;\nconst RAD_PER_DEG = PI / 180;\nconst HALF_PI = PI / 2;\nconst QUARTER_PI = PI / 4;\nconst TWO_THIRDS_PI = PI * 2 / 3;\nconst log10 = Math.log10;\nconst sign = Math.sign;\nfunction almostEquals(x, y, epsilon) {\n return Math.abs(x - y) < epsilon;\n}\n/**\n * Implementation of the nice number algorithm used in determining where axis labels will go\n */\nfunction niceNum(range) {\n const roundedRange = Math.round(range);\n range = almostEquals(range, roundedRange, range / 1000) ? roundedRange : range;\n const niceRange = Math.pow(10, Math.floor(log10(range)));\n const fraction = range / niceRange;\n const niceFraction = fraction <= 1 ? 1 : fraction <= 2 ? 2 : fraction <= 5 ? 5 : 10;\n return niceFraction * niceRange;\n}\n/**\n * Returns an array of factors sorted from 1 to sqrt(value)\n * @private\n */\nfunction _factorize(value) {\n const result = [];\n const sqrt = Math.sqrt(value);\n let i;\n for (i = 1; i < sqrt; i++) {\n if (value % i === 0) {\n result.push(i);\n result.push(value / i);\n }\n }\n if (sqrt === (sqrt | 0)) {\n result.push(sqrt);\n }\n result.sort((a, b) => a - b).pop();\n return result;\n}\nfunction isNumber(n) {\n return !isNaN(parseFloat(n)) && isFinite(n);\n}\nfunction almostWhole(x, epsilon) {\n const rounded = Math.round(x);\n return rounded - epsilon <= x && rounded + epsilon >= x;\n}\n/**\n * @private\n */\nfunction _setMinAndMaxByKey(array, target, property) {\n let i, ilen, value;\n for (i = 0, ilen = array.length; i < ilen; i++) {\n value = array[i][property];\n if (!isNaN(value)) {\n target.min = Math.min(target.min, value);\n target.max = Math.max(target.max, value);\n }\n }\n}\nfunction toRadians(degrees) {\n return degrees * (PI / 180);\n}\nfunction toDegrees(radians) {\n return radians * (180 / PI);\n}\n/**\n * Returns the number of decimal places\n * i.e. the number of digits after the decimal point, of the value of this Number.\n * @param x - A number.\n * @returns The number of decimal places.\n * @private\n */\nfunction _decimalPlaces(x) {\n if (!isNumberFinite(x)) {\n return;\n }\n let e = 1;\n let p = 0;\n while (Math.round(x * e) / e !== x) {\n e *= 10;\n p++;\n }\n return p;\n}\n// Gets the angle from vertical upright to the point about a centre.\nfunction getAngleFromPoint(centrePoint, anglePoint) {\n const distanceFromXCenter = anglePoint.x - centrePoint.x;\n const distanceFromYCenter = anglePoint.y - centrePoint.y;\n const radialDistanceFromCenter = Math.sqrt(distanceFromXCenter * distanceFromXCenter + distanceFromYCenter * distanceFromYCenter);\n let angle = Math.atan2(distanceFromYCenter, distanceFromXCenter);\n if (angle < -0.5 * PI) {\n angle += TAU; // make sure the returned angle is in the range of (-PI/2, 3PI/2]\n }\n return {\n angle,\n distance: radialDistanceFromCenter\n };\n}\nfunction distanceBetweenPoints(pt1, pt2) {\n return Math.sqrt(Math.pow(pt2.x - pt1.x, 2) + Math.pow(pt2.y - pt1.y, 2));\n}\n/**\n * Shortest distance between angles, in either direction.\n * @private\n */\nfunction _angleDiff(a, b) {\n return (a - b + PITAU) % TAU - PI;\n}\n/**\n * Normalize angle to be between 0 and 2*PI\n * @private\n */\nfunction _normalizeAngle(a) {\n return (a % TAU + TAU) % TAU;\n}\n/**\n * @private\n */\nfunction _angleBetween(angle, start, end, sameAngleIsFullCircle) {\n const a = _normalizeAngle(angle);\n const s = _normalizeAngle(start);\n const e = _normalizeAngle(end);\n const angleToStart = _normalizeAngle(s - a);\n const angleToEnd = _normalizeAngle(e - a);\n const startToAngle = _normalizeAngle(a - s);\n const endToAngle = _normalizeAngle(a - e);\n return a === s || a === e || sameAngleIsFullCircle && s === e || angleToStart > angleToEnd && startToAngle < endToAngle;\n}\n/**\n * Limit `value` between `min` and `max`\n * @param value\n * @param min\n * @param max\n * @private\n */\nfunction _limitValue(value, min, max) {\n return Math.max(min, Math.min(max, value));\n}\n/**\n * @param {number} value\n * @private\n */\nfunction _int16Range(value) {\n return _limitValue(value, -32768, 32767);\n}\n/**\n * @param value\n * @param start\n * @param end\n * @param [epsilon]\n * @private\n */\nfunction _isBetween(value, start, end, epsilon = 1e-6) {\n return value >= Math.min(start, end) - epsilon && value <= Math.max(start, end) + epsilon;\n}\nfunction _lookup(table, value, cmp) {\n cmp = cmp || (index => table[index] < value);\n let hi = table.length - 1;\n let lo = 0;\n let mid;\n while (hi - lo > 1) {\n mid = lo + hi >> 1;\n if (cmp(mid)) {\n lo = mid;\n } else {\n hi = mid;\n }\n }\n return {\n lo,\n hi\n };\n}\n/**\n * Binary search\n * @param table - the table search. must be sorted!\n * @param key - property name for the value in each entry\n * @param value - value to find\n * @param last - lookup last index\n * @private\n */\nconst _lookupByKey = (table, key, value, last) => _lookup(table, value, last ? index => {\n const ti = table[index][key];\n return ti < value || ti === value && table[index + 1][key] === value;\n} : index => table[index][key] < value);\n/**\n * Reverse binary search\n * @param table - the table search. must be sorted!\n * @param key - property name for the value in each entry\n * @param value - value to find\n * @private\n */\nconst _rlookupByKey = (table, key, value) => _lookup(table, value, index => table[index][key] >= value);\n/**\n * Return subset of `values` between `min` and `max` inclusive.\n * Values are assumed to be in sorted order.\n * @param values - sorted array of values\n * @param min - min value\n * @param max - max value\n */\nfunction _filterBetween(values, min, max) {\n let start = 0;\n let end = values.length;\n while (start < end && values[start] < min) {\n start++;\n }\n while (end > start && values[end - 1] > max) {\n end--;\n }\n return start > 0 || end < values.length ? values.slice(start, end) : values;\n}\nconst arrayEvents = ['push', 'pop', 'shift', 'splice', 'unshift'];\nfunction listenArrayEvents(array, listener) {\n if (array._chartjs) {\n array._chartjs.listeners.push(listener);\n return;\n }\n Object.defineProperty(array, '_chartjs', {\n configurable: true,\n enumerable: false,\n value: {\n listeners: [listener]\n }\n });\n arrayEvents.forEach(key => {\n const method = '_onData' + _capitalize(key);\n const base = array[key];\n Object.defineProperty(array, key, {\n configurable: true,\n enumerable: false,\n value(...args) {\n const res = base.apply(this, args);\n array._chartjs.listeners.forEach(object => {\n if (typeof object[method] === 'function') {\n object[method](...args);\n }\n });\n return res;\n }\n });\n });\n}\nfunction unlistenArrayEvents(array, listener) {\n const stub = array._chartjs;\n if (!stub) {\n return;\n }\n const listeners = stub.listeners;\n const index = listeners.indexOf(listener);\n if (index !== -1) {\n listeners.splice(index, 1);\n }\n if (listeners.length > 0) {\n return;\n }\n arrayEvents.forEach(key => {\n delete array[key];\n });\n delete array._chartjs;\n}\n/**\n * @param items\n */\nfunction _arrayUnique(items) {\n const set = new Set(items);\n if (set.size === items.length) {\n return items;\n }\n return Array.from(set);\n}\nfunction fontString(pixelSize, fontStyle, fontFamily) {\n return fontStyle + ' ' + pixelSize + 'px ' + fontFamily;\n}\n/**\n* Request animation polyfill\n*/\nconst requestAnimFrame = function () {\n if (typeof window === 'undefined') {\n return function (callback) {\n return callback();\n };\n }\n return window.requestAnimationFrame;\n}();\n/**\n * Throttles calling `fn` once per animation frame\n * Latest arguments are used on the actual call\n */\nfunction throttled(fn, thisArg) {\n let argsToUse = [];\n let ticking = false;\n return function (...args) {\n // Save the args for use later\n argsToUse = args;\n if (!ticking) {\n ticking = true;\n requestAnimFrame.call(window, () => {\n ticking = false;\n fn.apply(thisArg, argsToUse);\n });\n }\n };\n}\n/**\n * Debounces calling `fn` for `delay` ms\n */\nfunction debounce(fn, delay) {\n let timeout;\n return function (...args) {\n if (delay) {\n clearTimeout(timeout);\n timeout = setTimeout(fn, delay, args);\n } else {\n fn.apply(this, args);\n }\n return delay;\n };\n}\n/**\n * Converts 'start' to 'left', 'end' to 'right' and others to 'center'\n * @private\n */\nconst _toLeftRightCenter = align => align === 'start' ? 'left' : align === 'end' ? 'right' : 'center';\n/**\n * Returns `start`, `end` or `(start + end) / 2` depending on `align`. Defaults to `center`\n * @private\n */\nconst _alignStartEnd = (align, start, end) => align === 'start' ? start : align === 'end' ? end : (start + end) / 2;\n/**\n * Returns `left`, `right` or `(left + right) / 2` depending on `align`. Defaults to `left`\n * @private\n */\nconst _textX = (align, left, right, rtl) => {\n const check = rtl ? 'left' : 'right';\n return align === check ? right : align === 'center' ? (left + right) / 2 : left;\n};\n/**\n * Return start and count of visible points.\n * @private\n */\nfunction _getStartAndCountOfVisiblePoints(meta, points, animationsDisabled) {\n const pointCount = points.length;\n let start = 0;\n let count = pointCount;\n if (meta._sorted) {\n const {\n iScale,\n _parsed\n } = meta;\n const axis = iScale.axis;\n const {\n min,\n max,\n minDefined,\n maxDefined\n } = iScale.getUserBounds();\n if (minDefined) {\n start = _limitValue(Math.min(\n // @ts-expect-error Need to type _parsed\n _lookupByKey(_parsed, axis, min).lo,\n // @ts-expect-error Need to fix types on _lookupByKey\n animationsDisabled ? pointCount : _lookupByKey(points, axis, iScale.getPixelForValue(min)).lo), 0, pointCount - 1);\n }\n if (maxDefined) {\n count = _limitValue(Math.max(\n // @ts-expect-error Need to type _parsed\n _lookupByKey(_parsed, iScale.axis, max, true).hi + 1,\n // @ts-expect-error Need to fix types on _lookupByKey\n animationsDisabled ? 0 : _lookupByKey(points, axis, iScale.getPixelForValue(max), true).hi + 1), start, pointCount) - start;\n } else {\n count = pointCount - start;\n }\n }\n return {\n start,\n count\n };\n}\n/**\n * Checks if the scale ranges have changed.\n * @param {object} meta - dataset meta.\n * @returns {boolean}\n * @private\n */\nfunction _scaleRangesChanged(meta) {\n const {\n xScale,\n yScale,\n _scaleRanges\n } = meta;\n const newRanges = {\n xmin: xScale.min,\n xmax: xScale.max,\n ymin: yScale.min,\n ymax: yScale.max\n };\n if (!_scaleRanges) {\n meta._scaleRanges = newRanges;\n return true;\n }\n const changed = _scaleRanges.xmin !== xScale.min || _scaleRanges.xmax !== xScale.max || _scaleRanges.ymin !== yScale.min || _scaleRanges.ymax !== yScale.max;\n Object.assign(_scaleRanges, newRanges);\n return changed;\n}\nconst atEdge = t => t === 0 || t === 1;\nconst elasticIn = (t, s, p) => -(Math.pow(2, 10 * (t -= 1)) * Math.sin((t - s) * TAU / p));\nconst elasticOut = (t, s, p) => Math.pow(2, -10 * t) * Math.sin((t - s) * TAU / p) + 1;\n/**\n * Easing functions adapted from Robert Penner's easing equations.\n * @namespace Chart.helpers.easing.effects\n * @see http://www.robertpenner.com/easing/\n */\nconst effects = {\n linear: t => t,\n easeInQuad: t => t * t,\n easeOutQuad: t => -t * (t - 2),\n easeInOutQuad: t => (t /= 0.5) < 1 ? 0.5 * t * t : -0.5 * (--t * (t - 2) - 1),\n easeInCubic: t => t * t * t,\n easeOutCubic: t => (t -= 1) * t * t + 1,\n easeInOutCubic: t => (t /= 0.5) < 1 ? 0.5 * t * t * t : 0.5 * ((t -= 2) * t * t + 2),\n easeInQuart: t => t * t * t * t,\n easeOutQuart: t => -((t -= 1) * t * t * t - 1),\n easeInOutQuart: t => (t /= 0.5) < 1 ? 0.5 * t * t * t * t : -0.5 * ((t -= 2) * t * t * t - 2),\n easeInQuint: t => t * t * t * t * t,\n easeOutQuint: t => (t -= 1) * t * t * t * t + 1,\n easeInOutQuint: t => (t /= 0.5) < 1 ? 0.5 * t * t * t * t * t : 0.5 * ((t -= 2) * t * t * t * t + 2),\n easeInSine: t => -Math.cos(t * HALF_PI) + 1,\n easeOutSine: t => Math.sin(t * HALF_PI),\n easeInOutSine: t => -0.5 * (Math.cos(PI * t) - 1),\n easeInExpo: t => t === 0 ? 0 : Math.pow(2, 10 * (t - 1)),\n easeOutExpo: t => t === 1 ? 1 : -Math.pow(2, -10 * t) + 1,\n easeInOutExpo: t => atEdge(t) ? t : t < 0.5 ? 0.5 * Math.pow(2, 10 * (t * 2 - 1)) : 0.5 * (-Math.pow(2, -10 * (t * 2 - 1)) + 2),\n easeInCirc: t => t >= 1 ? t : -(Math.sqrt(1 - t * t) - 1),\n easeOutCirc: t => Math.sqrt(1 - (t -= 1) * t),\n easeInOutCirc: t => (t /= 0.5) < 1 ? -0.5 * (Math.sqrt(1 - t * t) - 1) : 0.5 * (Math.sqrt(1 - (t -= 2) * t) + 1),\n easeInElastic: t => atEdge(t) ? t : elasticIn(t, 0.075, 0.3),\n easeOutElastic: t => atEdge(t) ? t : elasticOut(t, 0.075, 0.3),\n easeInOutElastic(t) {\n const s = 0.1125;\n const p = 0.45;\n return atEdge(t) ? t : t < 0.5 ? 0.5 * elasticIn(t * 2, s, p) : 0.5 + 0.5 * elasticOut(t * 2 - 1, s, p);\n },\n easeInBack(t) {\n const s = 1.70158;\n return t * t * ((s + 1) * t - s);\n },\n easeOutBack(t) {\n const s = 1.70158;\n return (t -= 1) * t * ((s + 1) * t + s) + 1;\n },\n easeInOutBack(t) {\n let s = 1.70158;\n if ((t /= 0.5) < 1) {\n return 0.5 * (t * t * (((s *= 1.525) + 1) * t - s));\n }\n return 0.5 * ((t -= 2) * t * (((s *= 1.525) + 1) * t + s) + 2);\n },\n easeInBounce: t => 1 - effects.easeOutBounce(1 - t),\n easeOutBounce(t) {\n const m = 7.5625;\n const d = 2.75;\n if (t < 1 / d) {\n return m * t * t;\n }\n if (t < 2 / d) {\n return m * (t -= 1.5 / d) * t + 0.75;\n }\n if (t < 2.5 / d) {\n return m * (t -= 2.25 / d) * t + 0.9375;\n }\n return m * (t -= 2.625 / d) * t + 0.984375;\n },\n easeInOutBounce: t => t < 0.5 ? effects.easeInBounce(t * 2) * 0.5 : effects.easeOutBounce(t * 2 - 1) * 0.5 + 0.5\n};\nfunction isPatternOrGradient(value) {\n if (value && typeof value === 'object') {\n const type = value.toString();\n return type === '[object CanvasPattern]' || type === '[object CanvasGradient]';\n }\n return false;\n}\nfunction color(value) {\n return isPatternOrGradient(value) ? value : new Color(value);\n}\nfunction getHoverColor(value) {\n return isPatternOrGradient(value) ? value : new Color(value).saturate(0.5).darken(0.1).hexString();\n}\nconst numbers = ['x', 'y', 'borderWidth', 'radius', 'tension'];\nconst colors = ['color', 'borderColor', 'backgroundColor'];\nfunction applyAnimationsDefaults(defaults) {\n defaults.set('animation', {\n delay: undefined,\n duration: 1000,\n easing: 'easeOutQuart',\n fn: undefined,\n from: undefined,\n loop: undefined,\n to: undefined,\n type: undefined\n });\n defaults.describe('animation', {\n _fallback: false,\n _indexable: false,\n _scriptable: name => name !== 'onProgress' && name !== 'onComplete' && name !== 'fn'\n });\n defaults.set('animations', {\n colors: {\n type: 'color',\n properties: colors\n },\n numbers: {\n type: 'number',\n properties: numbers\n }\n });\n defaults.describe('animations', {\n _fallback: 'animation'\n });\n defaults.set('transitions', {\n active: {\n animation: {\n duration: 400\n }\n },\n resize: {\n animation: {\n duration: 0\n }\n },\n show: {\n animations: {\n colors: {\n from: 'transparent'\n },\n visible: {\n type: 'boolean',\n duration: 0\n }\n }\n },\n hide: {\n animations: {\n colors: {\n to: 'transparent'\n },\n visible: {\n type: 'boolean',\n easing: 'linear',\n fn: v => v | 0\n }\n }\n }\n });\n}\nfunction applyLayoutsDefaults(defaults) {\n defaults.set('layout', {\n autoPadding: true,\n padding: {\n top: 0,\n right: 0,\n bottom: 0,\n left: 0\n }\n });\n}\nconst intlCache = new Map();\nfunction getNumberFormat(locale, options) {\n options = options || {};\n const cacheKey = locale + JSON.stringify(options);\n let formatter = intlCache.get(cacheKey);\n if (!formatter) {\n formatter = new Intl.NumberFormat(locale, options);\n intlCache.set(cacheKey, formatter);\n }\n return formatter;\n}\nfunction formatNumber(num, locale, options) {\n return getNumberFormat(locale, options).format(num);\n}\nconst formatters = {\n values(value) {\n return isArray(value) ? value : '' + value;\n },\n numeric(tickValue, index, ticks) {\n if (tickValue === 0) {\n return '0';\n }\n const locale = this.chart.options.locale;\n let notation;\n let delta = tickValue;\n if (ticks.length > 1) {\n const maxTick = Math.max(Math.abs(ticks[0].value), Math.abs(ticks[ticks.length - 1].value));\n if (maxTick < 1e-4 || maxTick > 1e+15) {\n notation = 'scientific';\n }\n delta = calculateDelta(tickValue, ticks);\n }\n const logDelta = log10(Math.abs(delta));\n const numDecimal = isNaN(logDelta) ? 1 : Math.max(Math.min(-1 * Math.floor(logDelta), 20), 0);\n const options = {\n notation,\n minimumFractionDigits: numDecimal,\n maximumFractionDigits: numDecimal\n };\n Object.assign(options, this.options.ticks.format);\n return formatNumber(tickValue, locale, options);\n },\n logarithmic(tickValue, index, ticks) {\n if (tickValue === 0) {\n return '0';\n }\n const remain = ticks[index].significand || tickValue / Math.pow(10, Math.floor(log10(tickValue)));\n if ([1, 2, 3, 5, 10, 15].includes(remain) || index > 0.8 * ticks.length) {\n return formatters.numeric.call(this, tickValue, index, ticks);\n }\n return '';\n }\n};\nfunction calculateDelta(tickValue, ticks) {\n let delta = ticks.length > 3 ? ticks[2].value - ticks[1].value : ticks[1].value - ticks[0].value;\n if (Math.abs(delta) >= 1 && tickValue !== Math.floor(tickValue)) {\n delta = tickValue - Math.floor(tickValue);\n }\n return delta;\n}\nvar Ticks = {\n formatters\n};\nfunction applyScaleDefaults(defaults) {\n defaults.set('scale', {\n display: true,\n offset: false,\n reverse: false,\n beginAtZero: false,\n bounds: 'ticks',\n clip: true,\n grace: 0,\n grid: {\n display: true,\n lineWidth: 1,\n drawOnChartArea: true,\n drawTicks: true,\n tickLength: 8,\n tickWidth: (_ctx, options) => options.lineWidth,\n tickColor: (_ctx, options) => options.color,\n offset: false\n },\n border: {\n display: true,\n dash: [],\n dashOffset: 0.0,\n width: 1\n },\n title: {\n display: false,\n text: '',\n padding: {\n top: 4,\n bottom: 4\n }\n },\n ticks: {\n minRotation: 0,\n maxRotation: 50,\n mirror: false,\n textStrokeWidth: 0,\n textStrokeColor: '',\n padding: 3,\n display: true,\n autoSkip: true,\n autoSkipPadding: 3,\n labelOffset: 0,\n callback: Ticks.formatters.values,\n minor: {},\n major: {},\n align: 'center',\n crossAlign: 'near',\n showLabelBackdrop: false,\n backdropColor: 'rgba(255, 255, 255, 0.75)',\n backdropPadding: 2\n }\n });\n defaults.route('scale.ticks', 'color', '', 'color');\n defaults.route('scale.grid', 'color', '', 'borderColor');\n defaults.route('scale.border', 'color', '', 'borderColor');\n defaults.route('scale.title', 'color', '', 'color');\n defaults.describe('scale', {\n _fallback: false,\n _scriptable: name => !name.startsWith('before') && !name.startsWith('after') && name !== 'callback' && name !== 'parser',\n _indexable: name => name !== 'borderDash' && name !== 'tickBorderDash' && name !== 'dash'\n });\n defaults.describe('scales', {\n _fallback: 'scale'\n });\n defaults.describe('scale.ticks', {\n _scriptable: name => name !== 'backdropPadding' && name !== 'callback',\n _indexable: name => name !== 'backdropPadding'\n });\n}\nconst overrides = Object.create(null);\nconst descriptors = Object.create(null);\nfunction getScope$1(node, key) {\n if (!key) {\n return node;\n }\n const keys = key.split('.');\n for (let i = 0, n = keys.length; i < n; ++i) {\n const k = keys[i];\n node = node[k] || (node[k] = Object.create(null));\n }\n return node;\n}\nfunction set(root, scope, values) {\n if (typeof scope === 'string') {\n return merge(getScope$1(root, scope), values);\n }\n return merge(getScope$1(root, ''), scope);\n}\nclass Defaults {\n constructor(_descriptors, _appliers) {\n this.animation = undefined;\n this.backgroundColor = 'rgba(0,0,0,0.1)';\n this.borderColor = 'rgba(0,0,0,0.1)';\n this.color = '#666';\n this.datasets = {};\n this.devicePixelRatio = context => context.chart.platform.getDevicePixelRatio();\n this.elements = {};\n this.events = ['mousemove', 'mouseout', 'click', 'touchstart', 'touchmove'];\n this.font = {\n family: \"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif\",\n size: 12,\n style: 'normal',\n lineHeight: 1.2,\n weight: null\n };\n this.hover = {};\n this.hoverBackgroundColor = (ctx, options) => getHoverColor(options.backgroundColor);\n this.hoverBorderColor = (ctx, options) => getHoverColor(options.borderColor);\n this.hoverColor = (ctx, options) => getHoverColor(options.color);\n this.indexAxis = 'x';\n this.interaction = {\n mode: 'nearest',\n intersect: true,\n includeInvisible: false\n };\n this.maintainAspectRatio = true;\n this.onHover = null;\n this.onClick = null;\n this.parsing = true;\n this.plugins = {};\n this.responsive = true;\n this.scale = undefined;\n this.scales = {};\n this.showLine = true;\n this.drawActiveElementsOnTop = true;\n this.describe(_descriptors);\n this.apply(_appliers);\n }\n set(scope, values) {\n return set(this, scope, values);\n }\n get(scope) {\n return getScope$1(this, scope);\n }\n describe(scope, values) {\n return set(descriptors, scope, values);\n }\n override(scope, values) {\n return set(overrides, scope, values);\n }\n route(scope, name, targetScope, targetName) {\n const scopeObject = getScope$1(this, scope);\n const targetScopeObject = getScope$1(this, targetScope);\n const privateName = '_' + name;\n Object.defineProperties(scopeObject, {\n [privateName]: {\n value: scopeObject[name],\n writable: true\n },\n [name]: {\n enumerable: true,\n get() {\n const local = this[privateName];\n const target = targetScopeObject[targetName];\n if (isObject(local)) {\n return Object.assign({}, target, local);\n }\n return valueOrDefault(local, target);\n },\n set(value) {\n this[privateName] = value;\n }\n }\n });\n }\n apply(appliers) {\n appliers.forEach(apply => apply(this));\n }\n}\nvar defaults = /* #__PURE__ */new Defaults({\n _scriptable: name => !name.startsWith('on'),\n _indexable: name => name !== 'events',\n hover: {\n _fallback: 'interaction'\n },\n interaction: {\n _scriptable: false,\n _indexable: false\n }\n}, [applyAnimationsDefaults, applyLayoutsDefaults, applyScaleDefaults]);\n\n/**\n * Converts the given font object into a CSS font string.\n * @param font - A font object.\n * @return The CSS font string. See https://developer.mozilla.org/en-US/docs/Web/CSS/font\n * @private\n */\nfunction toFontString(font) {\n if (!font || isNullOrUndef(font.size) || isNullOrUndef(font.family)) {\n return null;\n }\n return (font.style ? font.style + ' ' : '') + (font.weight ? font.weight + ' ' : '') + font.size + 'px ' + font.family;\n}\n/**\n * @private\n */\nfunction _measureText(ctx, data, gc, longest, string) {\n let textWidth = data[string];\n if (!textWidth) {\n textWidth = data[string] = ctx.measureText(string).width;\n gc.push(string);\n }\n if (textWidth > longest) {\n longest = textWidth;\n }\n return longest;\n}\n/**\n * @private\n */ // eslint-disable-next-line complexity\nfunction _longestText(ctx, font, arrayOfThings, cache) {\n cache = cache || {};\n let data = cache.data = cache.data || {};\n let gc = cache.garbageCollect = cache.garbageCollect || [];\n if (cache.font !== font) {\n data = cache.data = {};\n gc = cache.garbageCollect = [];\n cache.font = font;\n }\n ctx.save();\n ctx.font = font;\n let longest = 0;\n const ilen = arrayOfThings.length;\n let i, j, jlen, thing, nestedThing;\n for (i = 0; i < ilen; i++) {\n thing = arrayOfThings[i];\n // Undefined strings and arrays should not be measured\n if (thing !== undefined && thing !== null && !isArray(thing)) {\n longest = _measureText(ctx, data, gc, longest, thing);\n } else if (isArray(thing)) {\n // if it is an array lets measure each element\n // to do maybe simplify this function a bit so we can do this more recursively?\n for (j = 0, jlen = thing.length; j < jlen; j++) {\n nestedThing = thing[j];\n // Undefined strings and arrays should not be measured\n if (nestedThing !== undefined && nestedThing !== null && !isArray(nestedThing)) {\n longest = _measureText(ctx, data, gc, longest, nestedThing);\n }\n }\n }\n }\n ctx.restore();\n const gcLen = gc.length / 2;\n if (gcLen > arrayOfThings.length) {\n for (i = 0; i < gcLen; i++) {\n delete data[gc[i]];\n }\n gc.splice(0, gcLen);\n }\n return longest;\n}\n/**\n * Returns the aligned pixel value to avoid anti-aliasing blur\n * @param chart - The chart instance.\n * @param pixel - A pixel value.\n * @param width - The width of the element.\n * @returns The aligned pixel value.\n * @private\n */\nfunction _alignPixel(chart, pixel, width) {\n const devicePixelRatio = chart.currentDevicePixelRatio;\n const halfWidth = width !== 0 ? Math.max(width / 2, 0.5) : 0;\n return Math.round((pixel - halfWidth) * devicePixelRatio) / devicePixelRatio + halfWidth;\n}\n/**\n * Clears the entire canvas.\n */\nfunction clearCanvas(canvas, ctx) {\n if (!ctx && !canvas) {\n return;\n }\n ctx = ctx || canvas.getContext('2d');\n ctx.save();\n // canvas.width and canvas.height do not consider the canvas transform,\n // while clearRect does\n ctx.resetTransform();\n ctx.clearRect(0, 0, canvas.width, canvas.height);\n ctx.restore();\n}\nfunction drawPoint(ctx, options, x, y) {\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n drawPointLegend(ctx, options, x, y, null);\n}\n// eslint-disable-next-line complexity\nfunction drawPointLegend(ctx, options, x, y, w) {\n let type, xOffset, yOffset, size, cornerRadius, width, xOffsetW, yOffsetW;\n const style = options.pointStyle;\n const rotation = options.rotation;\n const radius = options.radius;\n let rad = (rotation || 0) * RAD_PER_DEG;\n if (style && typeof style === 'object') {\n type = style.toString();\n if (type === '[object HTMLImageElement]' || type === '[object HTMLCanvasElement]') {\n ctx.save();\n ctx.translate(x, y);\n ctx.rotate(rad);\n ctx.drawImage(style, -style.width / 2, -style.height / 2, style.width, style.height);\n ctx.restore();\n return;\n }\n }\n if (isNaN(radius) || radius <= 0) {\n return;\n }\n ctx.beginPath();\n switch (style) {\n // Default includes circle\n default:\n if (w) {\n ctx.ellipse(x, y, w / 2, radius, 0, 0, TAU);\n } else {\n ctx.arc(x, y, radius, 0, TAU);\n }\n ctx.closePath();\n break;\n case 'triangle':\n width = w ? w / 2 : radius;\n ctx.moveTo(x + Math.sin(rad) * width, y - Math.cos(rad) * radius);\n rad += TWO_THIRDS_PI;\n ctx.lineTo(x + Math.sin(rad) * width, y - Math.cos(rad) * radius);\n rad += TWO_THIRDS_PI;\n ctx.lineTo(x + Math.sin(rad) * width, y - Math.cos(rad) * radius);\n ctx.closePath();\n break;\n case 'rectRounded':\n // NOTE: the rounded rect implementation changed to use `arc` instead of\n // `quadraticCurveTo` since it generates better results when rect is\n // almost a circle. 0.516 (instead of 0.5) produces results with visually\n // closer proportion to the previous impl and it is inscribed in the\n // circle with `radius`. For more details, see the following PRs:\n // https://github.com/chartjs/Chart.js/issues/5597\n // https://github.com/chartjs/Chart.js/issues/5858\n cornerRadius = radius * 0.516;\n size = radius - cornerRadius;\n xOffset = Math.cos(rad + QUARTER_PI) * size;\n xOffsetW = Math.cos(rad + QUARTER_PI) * (w ? w / 2 - cornerRadius : size);\n yOffset = Math.sin(rad + QUARTER_PI) * size;\n yOffsetW = Math.sin(rad + QUARTER_PI) * (w ? w / 2 - cornerRadius : size);\n ctx.arc(x - xOffsetW, y - yOffset, cornerRadius, rad - PI, rad - HALF_PI);\n ctx.arc(x + yOffsetW, y - xOffset, cornerRadius, rad - HALF_PI, rad);\n ctx.arc(x + xOffsetW, y + yOffset, cornerRadius, rad, rad + HALF_PI);\n ctx.arc(x - yOffsetW, y + xOffset, cornerRadius, rad + HALF_PI, rad + PI);\n ctx.closePath();\n break;\n case 'rect':\n if (!rotation) {\n size = Math.SQRT1_2 * radius;\n width = w ? w / 2 : size;\n ctx.rect(x - width, y - size, 2 * width, 2 * size);\n break;\n }\n rad += QUARTER_PI;\n /* falls through */\n case 'rectRot':\n xOffsetW = Math.cos(rad) * (w ? w / 2 : radius);\n xOffset = Math.cos(rad) * radius;\n yOffset = Math.sin(rad) * radius;\n yOffsetW = Math.sin(rad) * (w ? w / 2 : radius);\n ctx.moveTo(x - xOffsetW, y - yOffset);\n ctx.lineTo(x + yOffsetW, y - xOffset);\n ctx.lineTo(x + xOffsetW, y + yOffset);\n ctx.lineTo(x - yOffsetW, y + xOffset);\n ctx.closePath();\n break;\n case 'crossRot':\n rad += QUARTER_PI;\n /* falls through */\n case 'cross':\n xOffsetW = Math.cos(rad) * (w ? w / 2 : radius);\n xOffset = Math.cos(rad) * radius;\n yOffset = Math.sin(rad) * radius;\n yOffsetW = Math.sin(rad) * (w ? w / 2 : radius);\n ctx.moveTo(x - xOffsetW, y - yOffset);\n ctx.lineTo(x + xOffsetW, y + yOffset);\n ctx.moveTo(x + yOffsetW, y - xOffset);\n ctx.lineTo(x - yOffsetW, y + xOffset);\n break;\n case 'star':\n xOffsetW = Math.cos(rad) * (w ? w / 2 : radius);\n xOffset = Math.cos(rad) * radius;\n yOffset = Math.sin(rad) * radius;\n yOffsetW = Math.sin(rad) * (w ? w / 2 : radius);\n ctx.moveTo(x - xOffsetW, y - yOffset);\n ctx.lineTo(x + xOffsetW, y + yOffset);\n ctx.moveTo(x + yOffsetW, y - xOffset);\n ctx.lineTo(x - yOffsetW, y + xOffset);\n rad += QUARTER_PI;\n xOffsetW = Math.cos(rad) * (w ? w / 2 : radius);\n xOffset = Math.cos(rad) * radius;\n yOffset = Math.sin(rad) * radius;\n yOffsetW = Math.sin(rad) * (w ? w / 2 : radius);\n ctx.moveTo(x - xOffsetW, y - yOffset);\n ctx.lineTo(x + xOffsetW, y + yOffset);\n ctx.moveTo(x + yOffsetW, y - xOffset);\n ctx.lineTo(x - yOffsetW, y + xOffset);\n break;\n case 'line':\n xOffset = w ? w / 2 : Math.cos(rad) * radius;\n yOffset = Math.sin(rad) * radius;\n ctx.moveTo(x - xOffset, y - yOffset);\n ctx.lineTo(x + xOffset, y + yOffset);\n break;\n case 'dash':\n ctx.moveTo(x, y);\n ctx.lineTo(x + Math.cos(rad) * (w ? w / 2 : radius), y + Math.sin(rad) * radius);\n break;\n case false:\n ctx.closePath();\n break;\n }\n ctx.fill();\n if (options.borderWidth > 0) {\n ctx.stroke();\n }\n}\n/**\n * Returns true if the point is inside the rectangle\n * @param point - The point to test\n * @param area - The rectangle\n * @param margin - allowed margin\n * @private\n */\nfunction _isPointInArea(point, area, margin) {\n margin = margin || 0.5; // margin - default is to match rounded decimals\n return !area || point && point.x > area.left - margin && point.x < area.right + margin && point.y > area.top - margin && point.y < area.bottom + margin;\n}\nfunction clipArea(ctx, area) {\n ctx.save();\n ctx.beginPath();\n ctx.rect(area.left, area.top, area.right - area.left, area.bottom - area.top);\n ctx.clip();\n}\nfunction unclipArea(ctx) {\n ctx.restore();\n}\n/**\n * @private\n */\nfunction _steppedLineTo(ctx, previous, target, flip, mode) {\n if (!previous) {\n return ctx.lineTo(target.x, target.y);\n }\n if (mode === 'middle') {\n const midpoint = (previous.x + target.x) / 2.0;\n ctx.lineTo(midpoint, previous.y);\n ctx.lineTo(midpoint, target.y);\n } else if (mode === 'after' !== !!flip) {\n ctx.lineTo(previous.x, target.y);\n } else {\n ctx.lineTo(target.x, previous.y);\n }\n ctx.lineTo(target.x, target.y);\n}\n/**\n * @private\n */\nfunction _bezierCurveTo(ctx, previous, target, flip) {\n if (!previous) {\n return ctx.lineTo(target.x, target.y);\n }\n ctx.bezierCurveTo(flip ? previous.cp1x : previous.cp2x, flip ? previous.cp1y : previous.cp2y, flip ? target.cp2x : target.cp1x, flip ? target.cp2y : target.cp1y, target.x, target.y);\n}\nfunction setRenderOpts(ctx, opts) {\n if (opts.translation) {\n ctx.translate(opts.translation[0], opts.translation[1]);\n }\n if (!isNullOrUndef(opts.rotation)) {\n ctx.rotate(opts.rotation);\n }\n if (opts.color) {\n ctx.fillStyle = opts.color;\n }\n if (opts.textAlign) {\n ctx.textAlign = opts.textAlign;\n }\n if (opts.textBaseline) {\n ctx.textBaseline = opts.textBaseline;\n }\n}\nfunction decorateText(ctx, x, y, line, opts) {\n if (opts.strikethrough || opts.underline) {\n /**\n * Now that IE11 support has been dropped, we can use more\n * of the TextMetrics object. The actual bounding boxes\n * are unflagged in Chrome, Firefox, Edge, and Safari so they\n * can be safely used.\n * See https://developer.mozilla.org/en-US/docs/Web/API/TextMetrics#Browser_compatibility\n */\n const metrics = ctx.measureText(line);\n const left = x - metrics.actualBoundingBoxLeft;\n const right = x + metrics.actualBoundingBoxRight;\n const top = y - metrics.actualBoundingBoxAscent;\n const bottom = y + metrics.actualBoundingBoxDescent;\n const yDecoration = opts.strikethrough ? (top + bottom) / 2 : bottom;\n ctx.strokeStyle = ctx.fillStyle;\n ctx.beginPath();\n ctx.lineWidth = opts.decorationWidth || 2;\n ctx.moveTo(left, yDecoration);\n ctx.lineTo(right, yDecoration);\n ctx.stroke();\n }\n}\nfunction drawBackdrop(ctx, opts) {\n const oldColor = ctx.fillStyle;\n ctx.fillStyle = opts.color;\n ctx.fillRect(opts.left, opts.top, opts.width, opts.height);\n ctx.fillStyle = oldColor;\n}\n/**\n * Render text onto the canvas\n */\nfunction renderText(ctx, text, x, y, font, opts = {}) {\n const lines = isArray(text) ? text : [text];\n const stroke = opts.strokeWidth > 0 && opts.strokeColor !== '';\n let i, line;\n ctx.save();\n ctx.font = font.string;\n setRenderOpts(ctx, opts);\n for (i = 0; i < lines.length; ++i) {\n line = lines[i];\n if (opts.backdrop) {\n drawBackdrop(ctx, opts.backdrop);\n }\n if (stroke) {\n if (opts.strokeColor) {\n ctx.strokeStyle = opts.strokeColor;\n }\n if (!isNullOrUndef(opts.strokeWidth)) {\n ctx.lineWidth = opts.strokeWidth;\n }\n ctx.strokeText(line, x, y, opts.maxWidth);\n }\n ctx.fillText(line, x, y, opts.maxWidth);\n decorateText(ctx, x, y, line, opts);\n y += Number(font.lineHeight);\n }\n ctx.restore();\n}\n/**\n * Add a path of a rectangle with rounded corners to the current sub-path\n * @param ctx - Context\n * @param rect - Bounding rect\n */\nfunction addRoundedRectPath(ctx, rect) {\n const {\n x,\n y,\n w,\n h,\n radius\n } = rect;\n // top left arc\n ctx.arc(x + radius.topLeft, y + radius.topLeft, radius.topLeft, 1.5 * PI, PI, true);\n // line from top left to bottom left\n ctx.lineTo(x, y + h - radius.bottomLeft);\n // bottom left arc\n ctx.arc(x + radius.bottomLeft, y + h - radius.bottomLeft, radius.bottomLeft, PI, HALF_PI, true);\n // line from bottom left to bottom right\n ctx.lineTo(x + w - radius.bottomRight, y + h);\n // bottom right arc\n ctx.arc(x + w - radius.bottomRight, y + h - radius.bottomRight, radius.bottomRight, HALF_PI, 0, true);\n // line from bottom right to top right\n ctx.lineTo(x + w, y + radius.topRight);\n // top right arc\n ctx.arc(x + w - radius.topRight, y + radius.topRight, radius.topRight, 0, -HALF_PI, true);\n // line from top right to top left\n ctx.lineTo(x + radius.topLeft, y);\n}\nconst LINE_HEIGHT = /^(normal|(\\d+(?:\\.\\d+)?)(px|em|%)?)$/;\nconst FONT_STYLE = /^(normal|italic|initial|inherit|unset|(oblique( -?[0-9]?[0-9]deg)?))$/;\n/**\n * @alias Chart.helpers.options\n * @namespace\n */ /**\n * Converts the given line height `value` in pixels for a specific font `size`.\n * @param value - The lineHeight to parse (eg. 1.6, '14px', '75%', '1.6em').\n * @param size - The font size (in pixels) used to resolve relative `value`.\n * @returns The effective line height in pixels (size * 1.2 if value is invalid).\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/line-height\n * @since 2.7.0\n */\nfunction toLineHeight(value, size) {\n const matches = ('' + value).match(LINE_HEIGHT);\n if (!matches || matches[1] === 'normal') {\n return size * 1.2;\n }\n value = +matches[2];\n switch (matches[3]) {\n case 'px':\n return value;\n case '%':\n value /= 100;\n break;\n }\n return size * value;\n}\nconst numberOrZero = v => +v || 0;\nfunction _readValueToProps(value, props) {\n const ret = {};\n const objProps = isObject(props);\n const keys = objProps ? Object.keys(props) : props;\n const read = isObject(value) ? objProps ? prop => valueOrDefault(value[prop], value[props[prop]]) : prop => value[prop] : () => value;\n for (const prop of keys) {\n ret[prop] = numberOrZero(read(prop));\n }\n return ret;\n}\n/**\n * Converts the given value into a TRBL object.\n * @param value - If a number, set the value to all TRBL component,\n * else, if an object, use defined properties and sets undefined ones to 0.\n * x / y are shorthands for same value for left/right and top/bottom.\n * @returns The padding values (top, right, bottom, left)\n * @since 3.0.0\n */\nfunction toTRBL(value) {\n return _readValueToProps(value, {\n top: 'y',\n right: 'x',\n bottom: 'y',\n left: 'x'\n });\n}\n/**\n * Converts the given value into a TRBL corners object (similar with css border-radius).\n * @param value - If a number, set the value to all TRBL corner components,\n * else, if an object, use defined properties and sets undefined ones to 0.\n * @returns The TRBL corner values (topLeft, topRight, bottomLeft, bottomRight)\n * @since 3.0.0\n */\nfunction toTRBLCorners(value) {\n return _readValueToProps(value, ['topLeft', 'topRight', 'bottomLeft', 'bottomRight']);\n}\n/**\n * Converts the given value into a padding object with pre-computed width/height.\n * @param value - If a number, set the value to all TRBL component,\n * else, if an object, use defined properties and sets undefined ones to 0.\n * x / y are shorthands for same value for left/right and top/bottom.\n * @returns The padding values (top, right, bottom, left, width, height)\n * @since 2.7.0\n */\nfunction toPadding(value) {\n const obj = toTRBL(value);\n obj.width = obj.left + obj.right;\n obj.height = obj.top + obj.bottom;\n return obj;\n}\n/**\n * Parses font options and returns the font object.\n * @param options - A object that contains font options to be parsed.\n * @param fallback - A object that contains fallback font options.\n * @return The font object.\n * @private\n */\nfunction toFont(options, fallback) {\n options = options || {};\n fallback = fallback || defaults.font;\n let size = valueOrDefault(options.size, fallback.size);\n if (typeof size === 'string') {\n size = parseInt(size, 10);\n }\n let style = valueOrDefault(options.style, fallback.style);\n if (style && !('' + style).match(FONT_STYLE)) {\n console.warn('Invalid font style specified: \"' + style + '\"');\n style = undefined;\n }\n const font = {\n family: valueOrDefault(options.family, fallback.family),\n lineHeight: toLineHeight(valueOrDefault(options.lineHeight, fallback.lineHeight), size),\n size,\n style,\n weight: valueOrDefault(options.weight, fallback.weight),\n string: ''\n };\n font.string = toFontString(font);\n return font;\n}\n/**\n * Evaluates the given `inputs` sequentially and returns the first defined value.\n * @param inputs - An array of values, falling back to the last value.\n * @param context - If defined and the current value is a function, the value\n * is called with `context` as first argument and the result becomes the new input.\n * @param index - If defined and the current value is an array, the value\n * at `index` become the new input.\n * @param info - object to return information about resolution in\n * @param info.cacheable - Will be set to `false` if option is not cacheable.\n * @since 2.7.0\n */\nfunction resolve(inputs, context, index, info) {\n let cacheable = true;\n let i, ilen, value;\n for (i = 0, ilen = inputs.length; i < ilen; ++i) {\n value = inputs[i];\n if (value === undefined) {\n continue;\n }\n if (context !== undefined && typeof value === 'function') {\n value = value(context);\n cacheable = false;\n }\n if (index !== undefined && isArray(value)) {\n value = value[index % value.length];\n cacheable = false;\n }\n if (value !== undefined) {\n if (info && !cacheable) {\n info.cacheable = false;\n }\n return value;\n }\n }\n}\n/**\n * @param minmax\n * @param grace\n * @param beginAtZero\n * @private\n */\nfunction _addGrace(minmax, grace, beginAtZero) {\n const {\n min,\n max\n } = minmax;\n const change = toDimension(grace, (max - min) / 2);\n const keepZero = (value, add) => beginAtZero && value === 0 ? 0 : value + add;\n return {\n min: keepZero(min, -Math.abs(change)),\n max: keepZero(max, change)\n };\n}\nfunction createContext(parentContext, context) {\n return Object.assign(Object.create(parentContext), context);\n}\n\n/**\n * Creates a Proxy for resolving raw values for options.\n * @param scopes - The option scopes to look for values, in resolution order\n * @param prefixes - The prefixes for values, in resolution order.\n * @param rootScopes - The root option scopes\n * @param fallback - Parent scopes fallback\n * @param getTarget - callback for getting the target for changed values\n * @returns Proxy\n * @private\n */\nfunction _createResolver(scopes, prefixes = [''], rootScopes, fallback, getTarget = () => scopes[0]) {\n const finalRootScopes = rootScopes || scopes;\n if (typeof fallback === 'undefined') {\n fallback = _resolve('_fallback', scopes);\n }\n const cache = {\n [Symbol.toStringTag]: 'Object',\n _cacheable: true,\n _scopes: scopes,\n _rootScopes: finalRootScopes,\n _fallback: fallback,\n _getTarget: getTarget,\n override: scope => _createResolver([scope, ...scopes], prefixes, finalRootScopes, fallback)\n };\n return new Proxy(cache, {\n /**\n * A trap for the delete operator.\n */\n deleteProperty(target, prop) {\n delete target[prop]; // remove from cache\n delete target._keys; // remove cached keys\n delete scopes[0][prop]; // remove from top level scope\n return true;\n },\n /**\n * A trap for getting property values.\n */\n get(target, prop) {\n return _cached(target, prop, () => _resolveWithPrefixes(prop, prefixes, scopes, target));\n },\n /**\n * A trap for Object.getOwnPropertyDescriptor.\n * Also used by Object.hasOwnProperty.\n */\n getOwnPropertyDescriptor(target, prop) {\n return Reflect.getOwnPropertyDescriptor(target._scopes[0], prop);\n },\n /**\n * A trap for Object.getPrototypeOf.\n */\n getPrototypeOf() {\n return Reflect.getPrototypeOf(scopes[0]);\n },\n /**\n * A trap for the in operator.\n */\n has(target, prop) {\n return getKeysFromAllScopes(target).includes(prop);\n },\n /**\n * A trap for Object.getOwnPropertyNames and Object.getOwnPropertySymbols.\n */\n ownKeys(target) {\n return getKeysFromAllScopes(target);\n },\n /**\n * A trap for setting property values.\n */\n set(target, prop, value) {\n const storage = target._storage || (target._storage = getTarget());\n target[prop] = storage[prop] = value; // set to top level scope + cache\n delete target._keys; // remove cached keys\n return true;\n }\n });\n}\n/**\n * Returns an Proxy for resolving option values with context.\n * @param proxy - The Proxy returned by `_createResolver`\n * @param context - Context object for scriptable/indexable options\n * @param subProxy - The proxy provided for scriptable options\n * @param descriptorDefaults - Defaults for descriptors\n * @private\n */\nfunction _attachContext(proxy, context, subProxy, descriptorDefaults) {\n const cache = {\n _cacheable: false,\n _proxy: proxy,\n _context: context,\n _subProxy: subProxy,\n _stack: new Set(),\n _descriptors: _descriptors(proxy, descriptorDefaults),\n setContext: ctx => _attachContext(proxy, ctx, subProxy, descriptorDefaults),\n override: scope => _attachContext(proxy.override(scope), context, subProxy, descriptorDefaults)\n };\n return new Proxy(cache, {\n /**\n * A trap for the delete operator.\n */\n deleteProperty(target, prop) {\n delete target[prop]; // remove from cache\n delete proxy[prop]; // remove from proxy\n return true;\n },\n /**\n * A trap for getting property values.\n */\n get(target, prop, receiver) {\n return _cached(target, prop, () => _resolveWithContext(target, prop, receiver));\n },\n /**\n * A trap for Object.getOwnPropertyDescriptor.\n * Also used by Object.hasOwnProperty.\n */\n getOwnPropertyDescriptor(target, prop) {\n return target._descriptors.allKeys ? Reflect.has(proxy, prop) ? {\n enumerable: true,\n configurable: true\n } : undefined : Reflect.getOwnPropertyDescriptor(proxy, prop);\n },\n /**\n * A trap for Object.getPrototypeOf.\n */\n getPrototypeOf() {\n return Reflect.getPrototypeOf(proxy);\n },\n /**\n * A trap for the in operator.\n */\n has(target, prop) {\n return Reflect.has(proxy, prop);\n },\n /**\n * A trap for Object.getOwnPropertyNames and Object.getOwnPropertySymbols.\n */\n ownKeys() {\n return Reflect.ownKeys(proxy);\n },\n /**\n * A trap for setting property values.\n */\n set(target, prop, value) {\n proxy[prop] = value; // set to proxy\n delete target[prop]; // remove from cache\n return true;\n }\n });\n}\n/**\n * @private\n */\nfunction _descriptors(proxy, defaults = {\n scriptable: true,\n indexable: true\n}) {\n const {\n _scriptable = defaults.scriptable,\n _indexable = defaults.indexable,\n _allKeys = defaults.allKeys\n } = proxy;\n return {\n allKeys: _allKeys,\n scriptable: _scriptable,\n indexable: _indexable,\n isScriptable: isFunction(_scriptable) ? _scriptable : () => _scriptable,\n isIndexable: isFunction(_indexable) ? _indexable : () => _indexable\n };\n}\nconst readKey = (prefix, name) => prefix ? prefix + _capitalize(name) : name;\nconst needsSubResolver = (prop, value) => isObject(value) && prop !== 'adapters' && (Object.getPrototypeOf(value) === null || value.constructor === Object);\nfunction _cached(target, prop, resolve) {\n if (Object.prototype.hasOwnProperty.call(target, prop) || prop === 'constructor') {\n return target[prop];\n }\n const value = resolve();\n // cache the resolved value\n target[prop] = value;\n return value;\n}\nfunction _resolveWithContext(target, prop, receiver) {\n const {\n _proxy,\n _context,\n _subProxy,\n _descriptors: descriptors\n } = target;\n let value = _proxy[prop]; // resolve from proxy\n // resolve with context\n if (isFunction(value) && descriptors.isScriptable(prop)) {\n value = _resolveScriptable(prop, value, target, receiver);\n }\n if (isArray(value) && value.length) {\n value = _resolveArray(prop, value, target, descriptors.isIndexable);\n }\n if (needsSubResolver(prop, value)) {\n // if the resolved value is an object, create a sub resolver for it\n value = _attachContext(value, _context, _subProxy && _subProxy[prop], descriptors);\n }\n return value;\n}\nfunction _resolveScriptable(prop, getValue, target, receiver) {\n const {\n _proxy,\n _context,\n _subProxy,\n _stack\n } = target;\n if (_stack.has(prop)) {\n throw new Error('Recursion detected: ' + Array.from(_stack).join('->') + '->' + prop);\n }\n _stack.add(prop);\n let value = getValue(_context, _subProxy || receiver);\n _stack.delete(prop);\n if (needsSubResolver(prop, value)) {\n // When scriptable option returns an object, create a resolver on that.\n value = createSubResolver(_proxy._scopes, _proxy, prop, value);\n }\n return value;\n}\nfunction _resolveArray(prop, value, target, isIndexable) {\n const {\n _proxy,\n _context,\n _subProxy,\n _descriptors: descriptors\n } = target;\n if (typeof _context.index !== 'undefined' && isIndexable(prop)) {\n return value[_context.index % value.length];\n } else if (isObject(value[0])) {\n // Array of objects, return array or resolvers\n const arr = value;\n const scopes = _proxy._scopes.filter(s => s !== arr);\n value = [];\n for (const item of arr) {\n const resolver = createSubResolver(scopes, _proxy, prop, item);\n value.push(_attachContext(resolver, _context, _subProxy && _subProxy[prop], descriptors));\n }\n }\n return value;\n}\nfunction resolveFallback(fallback, prop, value) {\n return isFunction(fallback) ? fallback(prop, value) : fallback;\n}\nconst getScope = (key, parent) => key === true ? parent : typeof key === 'string' ? resolveObjectKey(parent, key) : undefined;\nfunction addScopes(set, parentScopes, key, parentFallback, value) {\n for (const parent of parentScopes) {\n const scope = getScope(key, parent);\n if (scope) {\n set.add(scope);\n const fallback = resolveFallback(scope._fallback, key, value);\n if (typeof fallback !== 'undefined' && fallback !== key && fallback !== parentFallback) {\n // When we reach the descriptor that defines a new _fallback, return that.\n // The fallback will resume to that new scope.\n return fallback;\n }\n } else if (scope === false && typeof parentFallback !== 'undefined' && key !== parentFallback) {\n // Fallback to `false` results to `false`, when falling back to different key.\n // For example `interaction` from `hover` or `plugins.tooltip` and `animation` from `animations`\n return null;\n }\n }\n return false;\n}\nfunction createSubResolver(parentScopes, resolver, prop, value) {\n const rootScopes = resolver._rootScopes;\n const fallback = resolveFallback(resolver._fallback, prop, value);\n const allScopes = [...parentScopes, ...rootScopes];\n const set = new Set();\n set.add(value);\n let key = addScopesFromKey(set, allScopes, prop, fallback || prop, value);\n if (key === null) {\n return false;\n }\n if (typeof fallback !== 'undefined' && fallback !== prop) {\n key = addScopesFromKey(set, allScopes, fallback, key, value);\n if (key === null) {\n return false;\n }\n }\n return _createResolver(Array.from(set), [''], rootScopes, fallback, () => subGetTarget(resolver, prop, value));\n}\nfunction addScopesFromKey(set, allScopes, key, fallback, item) {\n while (key) {\n key = addScopes(set, allScopes, key, fallback, item);\n }\n return key;\n}\nfunction subGetTarget(resolver, prop, value) {\n const parent = resolver._getTarget();\n if (!(prop in parent)) {\n parent[prop] = {};\n }\n const target = parent[prop];\n if (isArray(target) && isObject(value)) {\n // For array of objects, the object is used to store updated values\n return value;\n }\n return target || {};\n}\nfunction _resolveWithPrefixes(prop, prefixes, scopes, proxy) {\n let value;\n for (const prefix of prefixes) {\n value = _resolve(readKey(prefix, prop), scopes);\n if (typeof value !== 'undefined') {\n return needsSubResolver(prop, value) ? createSubResolver(scopes, proxy, prop, value) : value;\n }\n }\n}\nfunction _resolve(key, scopes) {\n for (const scope of scopes) {\n if (!scope) {\n continue;\n }\n const value = scope[key];\n if (typeof value !== 'undefined') {\n return value;\n }\n }\n}\nfunction getKeysFromAllScopes(target) {\n let keys = target._keys;\n if (!keys) {\n keys = target._keys = resolveKeysFromAllScopes(target._scopes);\n }\n return keys;\n}\nfunction resolveKeysFromAllScopes(scopes) {\n const set = new Set();\n for (const scope of scopes) {\n for (const key of Object.keys(scope).filter(k => !k.startsWith('_'))) {\n set.add(key);\n }\n }\n return Array.from(set);\n}\nfunction _parseObjectDataRadialScale(meta, data, start, count) {\n const {\n iScale\n } = meta;\n const {\n key = 'r'\n } = this._parsing;\n const parsed = new Array(count);\n let i, ilen, index, item;\n for (i = 0, ilen = count; i < ilen; ++i) {\n index = i + start;\n item = data[index];\n parsed[i] = {\n r: iScale.parse(resolveObjectKey(item, key), index)\n };\n }\n return parsed;\n}\nconst EPSILON = Number.EPSILON || 1e-14;\nconst getPoint = (points, i) => i < points.length && !points[i].skip && points[i];\nconst getValueAxis = indexAxis => indexAxis === 'x' ? 'y' : 'x';\nfunction splineCurve(firstPoint, middlePoint, afterPoint, t) {\n // Props to Rob Spencer at scaled innovation for his post on splining between points\n // http://scaledinnovation.com/analytics/splines/aboutSplines.html\n // This function must also respect \"skipped\" points\n const previous = firstPoint.skip ? middlePoint : firstPoint;\n const current = middlePoint;\n const next = afterPoint.skip ? middlePoint : afterPoint;\n const d01 = distanceBetweenPoints(current, previous);\n const d12 = distanceBetweenPoints(next, current);\n let s01 = d01 / (d01 + d12);\n let s12 = d12 / (d01 + d12);\n // If all points are the same, s01 & s02 will be inf\n s01 = isNaN(s01) ? 0 : s01;\n s12 = isNaN(s12) ? 0 : s12;\n const fa = t * s01; // scaling factor for triangle Ta\n const fb = t * s12;\n return {\n previous: {\n x: current.x - fa * (next.x - previous.x),\n y: current.y - fa * (next.y - previous.y)\n },\n next: {\n x: current.x + fb * (next.x - previous.x),\n y: current.y + fb * (next.y - previous.y)\n }\n };\n}\n/**\n * Adjust tangents to ensure monotonic properties\n */\nfunction monotoneAdjust(points, deltaK, mK) {\n const pointsLen = points.length;\n let alphaK, betaK, tauK, squaredMagnitude, pointCurrent;\n let pointAfter = getPoint(points, 0);\n for (let i = 0; i < pointsLen - 1; ++i) {\n pointCurrent = pointAfter;\n pointAfter = getPoint(points, i + 1);\n if (!pointCurrent || !pointAfter) {\n continue;\n }\n if (almostEquals(deltaK[i], 0, EPSILON)) {\n mK[i] = mK[i + 1] = 0;\n continue;\n }\n alphaK = mK[i] / deltaK[i];\n betaK = mK[i + 1] / deltaK[i];\n squaredMagnitude = Math.pow(alphaK, 2) + Math.pow(betaK, 2);\n if (squaredMagnitude <= 9) {\n continue;\n }\n tauK = 3 / Math.sqrt(squaredMagnitude);\n mK[i] = alphaK * tauK * deltaK[i];\n mK[i + 1] = betaK * tauK * deltaK[i];\n }\n}\nfunction monotoneCompute(points, mK, indexAxis = 'x') {\n const valueAxis = getValueAxis(indexAxis);\n const pointsLen = points.length;\n let delta, pointBefore, pointCurrent;\n let pointAfter = getPoint(points, 0);\n for (let i = 0; i < pointsLen; ++i) {\n pointBefore = pointCurrent;\n pointCurrent = pointAfter;\n pointAfter = getPoint(points, i + 1);\n if (!pointCurrent) {\n continue;\n }\n const iPixel = pointCurrent[indexAxis];\n const vPixel = pointCurrent[valueAxis];\n if (pointBefore) {\n delta = (iPixel - pointBefore[indexAxis]) / 3;\n pointCurrent[`cp1${indexAxis}`] = iPixel - delta;\n pointCurrent[`cp1${valueAxis}`] = vPixel - delta * mK[i];\n }\n if (pointAfter) {\n delta = (pointAfter[indexAxis] - iPixel) / 3;\n pointCurrent[`cp2${indexAxis}`] = iPixel + delta;\n pointCurrent[`cp2${valueAxis}`] = vPixel + delta * mK[i];\n }\n }\n}\n/**\n * This function calculates Bézier control points in a similar way than |splineCurve|,\n * but preserves monotonicity of the provided data and ensures no local extremums are added\n * between the dataset discrete points due to the interpolation.\n * See : https://en.wikipedia.org/wiki/Monotone_cubic_interpolation\n */\nfunction splineCurveMonotone(points, indexAxis = 'x') {\n const valueAxis = getValueAxis(indexAxis);\n const pointsLen = points.length;\n const deltaK = Array(pointsLen).fill(0);\n const mK = Array(pointsLen);\n // Calculate slopes (deltaK) and initialize tangents (mK)\n let i, pointBefore, pointCurrent;\n let pointAfter = getPoint(points, 0);\n for (i = 0; i < pointsLen; ++i) {\n pointBefore = pointCurrent;\n pointCurrent = pointAfter;\n pointAfter = getPoint(points, i + 1);\n if (!pointCurrent) {\n continue;\n }\n if (pointAfter) {\n const slopeDelta = pointAfter[indexAxis] - pointCurrent[indexAxis];\n // In the case of two points that appear at the same x pixel, slopeDeltaX is 0\n deltaK[i] = slopeDelta !== 0 ? (pointAfter[valueAxis] - pointCurrent[valueAxis]) / slopeDelta : 0;\n }\n mK[i] = !pointBefore ? deltaK[i] : !pointAfter ? deltaK[i - 1] : sign(deltaK[i - 1]) !== sign(deltaK[i]) ? 0 : (deltaK[i - 1] + deltaK[i]) / 2;\n }\n monotoneAdjust(points, deltaK, mK);\n monotoneCompute(points, mK, indexAxis);\n}\nfunction capControlPoint(pt, min, max) {\n return Math.max(Math.min(pt, max), min);\n}\nfunction capBezierPoints(points, area) {\n let i, ilen, point, inArea, inAreaPrev;\n let inAreaNext = _isPointInArea(points[0], area);\n for (i = 0, ilen = points.length; i < ilen; ++i) {\n inAreaPrev = inArea;\n inArea = inAreaNext;\n inAreaNext = i < ilen - 1 && _isPointInArea(points[i + 1], area);\n if (!inArea) {\n continue;\n }\n point = points[i];\n if (inAreaPrev) {\n point.cp1x = capControlPoint(point.cp1x, area.left, area.right);\n point.cp1y = capControlPoint(point.cp1y, area.top, area.bottom);\n }\n if (inAreaNext) {\n point.cp2x = capControlPoint(point.cp2x, area.left, area.right);\n point.cp2y = capControlPoint(point.cp2y, area.top, area.bottom);\n }\n }\n}\n/**\n * @private\n */\nfunction _updateBezierControlPoints(points, options, area, loop, indexAxis) {\n let i, ilen, point, controlPoints;\n // Only consider points that are drawn in case the spanGaps option is used\n if (options.spanGaps) {\n points = points.filter(pt => !pt.skip);\n }\n if (options.cubicInterpolationMode === 'monotone') {\n splineCurveMonotone(points, indexAxis);\n } else {\n let prev = loop ? points[points.length - 1] : points[0];\n for (i = 0, ilen = points.length; i < ilen; ++i) {\n point = points[i];\n controlPoints = splineCurve(prev, point, points[Math.min(i + 1, ilen - (loop ? 0 : 1)) % ilen], options.tension);\n point.cp1x = controlPoints.previous.x;\n point.cp1y = controlPoints.previous.y;\n point.cp2x = controlPoints.next.x;\n point.cp2y = controlPoints.next.y;\n prev = point;\n }\n }\n if (options.capBezierPoints) {\n capBezierPoints(points, area);\n }\n}\n\n/**\n * Note: typedefs are auto-exported, so use a made-up `dom` namespace where\n * necessary to avoid duplicates with `export * from './helpers`; see\n * https://github.com/microsoft/TypeScript/issues/46011\n * @typedef { import('../core/core.controller.js').default } dom.Chart\n * @typedef { import('../../types').ChartEvent } ChartEvent\n */ /**\n * @private\n */\nfunction _isDomSupported() {\n return typeof window !== 'undefined' && typeof document !== 'undefined';\n}\n/**\n * @private\n */\nfunction _getParentNode(domNode) {\n let parent = domNode.parentNode;\n if (parent && parent.toString() === '[object ShadowRoot]') {\n parent = parent.host;\n }\n return parent;\n}\n/**\n * convert max-width/max-height values that may be percentages into a number\n * @private\n */\nfunction parseMaxStyle(styleValue, node, parentProperty) {\n let valueInPixels;\n if (typeof styleValue === 'string') {\n valueInPixels = parseInt(styleValue, 10);\n if (styleValue.indexOf('%') !== -1) {\n // percentage * size in dimension\n valueInPixels = valueInPixels / 100 * node.parentNode[parentProperty];\n }\n } else {\n valueInPixels = styleValue;\n }\n return valueInPixels;\n}\nconst getComputedStyle = element => element.ownerDocument.defaultView.getComputedStyle(element, null);\nfunction getStyle(el, property) {\n return getComputedStyle(el).getPropertyValue(property);\n}\nconst positions = ['top', 'right', 'bottom', 'left'];\nfunction getPositionedStyle(styles, style, suffix) {\n const result = {};\n suffix = suffix ? '-' + suffix : '';\n for (let i = 0; i < 4; i++) {\n const pos = positions[i];\n result[pos] = parseFloat(styles[style + '-' + pos + suffix]) || 0;\n }\n result.width = result.left + result.right;\n result.height = result.top + result.bottom;\n return result;\n}\nconst useOffsetPos = (x, y, target) => (x > 0 || y > 0) && (!target || !target.shadowRoot);\n/**\n * @param e\n * @param canvas\n * @returns Canvas position\n */\nfunction getCanvasPosition(e, canvas) {\n const touches = e.touches;\n const source = touches && touches.length ? touches[0] : e;\n const {\n offsetX,\n offsetY\n } = source;\n let box = false;\n let x, y;\n if (useOffsetPos(offsetX, offsetY, e.target)) {\n x = offsetX;\n y = offsetY;\n } else {\n const rect = canvas.getBoundingClientRect();\n x = source.clientX - rect.left;\n y = source.clientY - rect.top;\n box = true;\n }\n return {\n x,\n y,\n box\n };\n}\n/**\n * Gets an event's x, y coordinates, relative to the chart area\n * @param event\n * @param chart\n * @returns x and y coordinates of the event\n */\nfunction getRelativePosition(event, chart) {\n if ('native' in event) {\n return event;\n }\n const {\n canvas,\n currentDevicePixelRatio\n } = chart;\n const style = getComputedStyle(canvas);\n const borderBox = style.boxSizing === 'border-box';\n const paddings = getPositionedStyle(style, 'padding');\n const borders = getPositionedStyle(style, 'border', 'width');\n const {\n x,\n y,\n box\n } = getCanvasPosition(event, canvas);\n const xOffset = paddings.left + (box && borders.left);\n const yOffset = paddings.top + (box && borders.top);\n let {\n width,\n height\n } = chart;\n if (borderBox) {\n width -= paddings.width + borders.width;\n height -= paddings.height + borders.height;\n }\n return {\n x: Math.round((x - xOffset) / width * canvas.width / currentDevicePixelRatio),\n y: Math.round((y - yOffset) / height * canvas.height / currentDevicePixelRatio)\n };\n}\nfunction getContainerSize(canvas, width, height) {\n let maxWidth, maxHeight;\n if (width === undefined || height === undefined) {\n const container = canvas && _getParentNode(canvas);\n if (!container) {\n width = canvas.clientWidth;\n height = canvas.clientHeight;\n } else {\n const rect = container.getBoundingClientRect(); // this is the border box of the container\n const containerStyle = getComputedStyle(container);\n const containerBorder = getPositionedStyle(containerStyle, 'border', 'width');\n const containerPadding = getPositionedStyle(containerStyle, 'padding');\n width = rect.width - containerPadding.width - containerBorder.width;\n height = rect.height - containerPadding.height - containerBorder.height;\n maxWidth = parseMaxStyle(containerStyle.maxWidth, container, 'clientWidth');\n maxHeight = parseMaxStyle(containerStyle.maxHeight, container, 'clientHeight');\n }\n }\n return {\n width,\n height,\n maxWidth: maxWidth || INFINITY,\n maxHeight: maxHeight || INFINITY\n };\n}\nconst round1 = v => Math.round(v * 10) / 10;\n// eslint-disable-next-line complexity\nfunction getMaximumSize(canvas, bbWidth, bbHeight, aspectRatio) {\n const style = getComputedStyle(canvas);\n const margins = getPositionedStyle(style, 'margin');\n const maxWidth = parseMaxStyle(style.maxWidth, canvas, 'clientWidth') || INFINITY;\n const maxHeight = parseMaxStyle(style.maxHeight, canvas, 'clientHeight') || INFINITY;\n const containerSize = getContainerSize(canvas, bbWidth, bbHeight);\n let {\n width,\n height\n } = containerSize;\n if (style.boxSizing === 'content-box') {\n const borders = getPositionedStyle(style, 'border', 'width');\n const paddings = getPositionedStyle(style, 'padding');\n width -= paddings.width + borders.width;\n height -= paddings.height + borders.height;\n }\n width = Math.max(0, width - margins.width);\n height = Math.max(0, aspectRatio ? width / aspectRatio : height - margins.height);\n width = round1(Math.min(width, maxWidth, containerSize.maxWidth));\n height = round1(Math.min(height, maxHeight, containerSize.maxHeight));\n if (width && !height) {\n // https://github.com/chartjs/Chart.js/issues/4659\n // If the canvas has width, but no height, default to aspectRatio of 2 (canvas default)\n height = round1(width / 2);\n }\n const maintainHeight = bbWidth !== undefined || bbHeight !== undefined;\n if (maintainHeight && aspectRatio && containerSize.height && height > containerSize.height) {\n height = containerSize.height;\n width = round1(Math.floor(height * aspectRatio));\n }\n return {\n width,\n height\n };\n}\n/**\n * @param chart\n * @param forceRatio\n * @param forceStyle\n * @returns True if the canvas context size or transformation has changed.\n */\nfunction retinaScale(chart, forceRatio, forceStyle) {\n const pixelRatio = forceRatio || 1;\n const deviceHeight = Math.floor(chart.height * pixelRatio);\n const deviceWidth = Math.floor(chart.width * pixelRatio);\n chart.height = Math.floor(chart.height);\n chart.width = Math.floor(chart.width);\n const canvas = chart.canvas;\n // If no style has been set on the canvas, the render size is used as display size,\n // making the chart visually bigger, so let's enforce it to the \"correct\" values.\n // See https://github.com/chartjs/Chart.js/issues/3575\n if (canvas.style && (forceStyle || !canvas.style.height && !canvas.style.width)) {\n canvas.style.height = `${chart.height}px`;\n canvas.style.width = `${chart.width}px`;\n }\n if (chart.currentDevicePixelRatio !== pixelRatio || canvas.height !== deviceHeight || canvas.width !== deviceWidth) {\n chart.currentDevicePixelRatio = pixelRatio;\n canvas.height = deviceHeight;\n canvas.width = deviceWidth;\n chart.ctx.setTransform(pixelRatio, 0, 0, pixelRatio, 0, 0);\n return true;\n }\n return false;\n}\n/**\n * Detects support for options object argument in addEventListener.\n * https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#Safely_detecting_option_support\n * @private\n */\nconst supportsEventListenerOptions = function () {\n let passiveSupported = false;\n try {\n const options = {\n get passive() {\n passiveSupported = true;\n return false;\n }\n };\n if (_isDomSupported()) {\n window.addEventListener('test', null, options);\n window.removeEventListener('test', null, options);\n }\n } catch (e) {\n // continue regardless of error\n }\n return passiveSupported;\n}();\n/**\n * The \"used\" size is the final value of a dimension property after all calculations have\n * been performed. This method uses the computed style of `element` but returns undefined\n * if the computed style is not expressed in pixels. That can happen in some cases where\n * `element` has a size relative to its parent and this last one is not yet displayed,\n * for example because of `display: none` on a parent node.\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/used_value\n * @returns Size in pixels or undefined if unknown.\n */\nfunction readUsedSize(element, property) {\n const value = getStyle(element, property);\n const matches = value && value.match(/^(\\d+)(\\.\\d+)?px$/);\n return matches ? +matches[1] : undefined;\n}\n\n/**\n * @private\n */\nfunction _pointInLine(p1, p2, t, mode) {\n return {\n x: p1.x + t * (p2.x - p1.x),\n y: p1.y + t * (p2.y - p1.y)\n };\n}\n/**\n * @private\n */\nfunction _steppedInterpolation(p1, p2, t, mode) {\n return {\n x: p1.x + t * (p2.x - p1.x),\n y: mode === 'middle' ? t < 0.5 ? p1.y : p2.y : mode === 'after' ? t < 1 ? p1.y : p2.y : t > 0 ? p2.y : p1.y\n };\n}\n/**\n * @private\n */\nfunction _bezierInterpolation(p1, p2, t, mode) {\n const cp1 = {\n x: p1.cp2x,\n y: p1.cp2y\n };\n const cp2 = {\n x: p2.cp1x,\n y: p2.cp1y\n };\n const a = _pointInLine(p1, cp1, t);\n const b = _pointInLine(cp1, cp2, t);\n const c = _pointInLine(cp2, p2, t);\n const d = _pointInLine(a, b, t);\n const e = _pointInLine(b, c, t);\n return _pointInLine(d, e, t);\n}\nconst getRightToLeftAdapter = function (rectX, width) {\n return {\n x(x) {\n return rectX + rectX + width - x;\n },\n setWidth(w) {\n width = w;\n },\n textAlign(align) {\n if (align === 'center') {\n return align;\n }\n return align === 'right' ? 'left' : 'right';\n },\n xPlus(x, value) {\n return x - value;\n },\n leftForLtr(x, itemWidth) {\n return x - itemWidth;\n }\n };\n};\nconst getLeftToRightAdapter = function () {\n return {\n x(x) {\n return x;\n },\n setWidth(w) {},\n textAlign(align) {\n return align;\n },\n xPlus(x, value) {\n return x + value;\n },\n leftForLtr(x, _itemWidth) {\n return x;\n }\n };\n};\nfunction getRtlAdapter(rtl, rectX, width) {\n return rtl ? getRightToLeftAdapter(rectX, width) : getLeftToRightAdapter();\n}\nfunction overrideTextDirection(ctx, direction) {\n let style, original;\n if (direction === 'ltr' || direction === 'rtl') {\n style = ctx.canvas.style;\n original = [style.getPropertyValue('direction'), style.getPropertyPriority('direction')];\n style.setProperty('direction', direction, 'important');\n ctx.prevTextDirection = original;\n }\n}\nfunction restoreTextDirection(ctx, original) {\n if (original !== undefined) {\n delete ctx.prevTextDirection;\n ctx.canvas.style.setProperty('direction', original[0], original[1]);\n }\n}\nfunction propertyFn(property) {\n if (property === 'angle') {\n return {\n between: _angleBetween,\n compare: _angleDiff,\n normalize: _normalizeAngle\n };\n }\n return {\n between: _isBetween,\n compare: (a, b) => a - b,\n normalize: x => x\n };\n}\nfunction normalizeSegment({\n start,\n end,\n count,\n loop,\n style\n}) {\n return {\n start: start % count,\n end: end % count,\n loop: loop && (end - start + 1) % count === 0,\n style\n };\n}\nfunction getSegment(segment, points, bounds) {\n const {\n property,\n start: startBound,\n end: endBound\n } = bounds;\n const {\n between,\n normalize\n } = propertyFn(property);\n const count = points.length;\n let {\n start,\n end,\n loop\n } = segment;\n let i, ilen;\n if (loop) {\n start += count;\n end += count;\n for (i = 0, ilen = count; i < ilen; ++i) {\n if (!between(normalize(points[start % count][property]), startBound, endBound)) {\n break;\n }\n start--;\n end--;\n }\n start %= count;\n end %= count;\n }\n if (end < start) {\n end += count;\n }\n return {\n start,\n end,\n loop,\n style: segment.style\n };\n}\nfunction _boundSegment(segment, points, bounds) {\n if (!bounds) {\n return [segment];\n }\n const {\n property,\n start: startBound,\n end: endBound\n } = bounds;\n const count = points.length;\n const {\n compare,\n between,\n normalize\n } = propertyFn(property);\n const {\n start,\n end,\n loop,\n style\n } = getSegment(segment, points, bounds);\n const result = [];\n let inside = false;\n let subStart = null;\n let value, point, prevValue;\n const startIsBefore = () => between(startBound, prevValue, value) && compare(startBound, prevValue) !== 0;\n const endIsBefore = () => compare(endBound, value) === 0 || between(endBound, prevValue, value);\n const shouldStart = () => inside || startIsBefore();\n const shouldStop = () => !inside || endIsBefore();\n for (let i = start, prev = start; i <= end; ++i) {\n point = points[i % count];\n if (point.skip) {\n continue;\n }\n value = normalize(point[property]);\n if (value === prevValue) {\n continue;\n }\n inside = between(value, startBound, endBound);\n if (subStart === null && shouldStart()) {\n subStart = compare(value, startBound) === 0 ? i : prev;\n }\n if (subStart !== null && shouldStop()) {\n result.push(normalizeSegment({\n start: subStart,\n end: i,\n loop,\n count,\n style\n }));\n subStart = null;\n }\n prev = i;\n prevValue = value;\n }\n if (subStart !== null) {\n result.push(normalizeSegment({\n start: subStart,\n end,\n loop,\n count,\n style\n }));\n }\n return result;\n}\nfunction _boundSegments(line, bounds) {\n const result = [];\n const segments = line.segments;\n for (let i = 0; i < segments.length; i++) {\n const sub = _boundSegment(segments[i], line.points, bounds);\n if (sub.length) {\n result.push(...sub);\n }\n }\n return result;\n}\nfunction findStartAndEnd(points, count, loop, spanGaps) {\n let start = 0;\n let end = count - 1;\n if (loop && !spanGaps) {\n while (start < count && !points[start].skip) {\n start++;\n }\n }\n while (start < count && points[start].skip) {\n start++;\n }\n start %= count;\n if (loop) {\n end += start;\n }\n while (end > start && points[end % count].skip) {\n end--;\n }\n end %= count;\n return {\n start,\n end\n };\n}\nfunction solidSegments(points, start, max, loop) {\n const count = points.length;\n const result = [];\n let last = start;\n let prev = points[start];\n let end;\n for (end = start + 1; end <= max; ++end) {\n const cur = points[end % count];\n if (cur.skip || cur.stop) {\n if (!prev.skip) {\n loop = false;\n result.push({\n start: start % count,\n end: (end - 1) % count,\n loop\n });\n start = last = cur.stop ? end : null;\n }\n } else {\n last = end;\n if (prev.skip) {\n start = end;\n }\n }\n prev = cur;\n }\n if (last !== null) {\n result.push({\n start: start % count,\n end: last % count,\n loop\n });\n }\n return result;\n}\nfunction _computeSegments(line, segmentOptions) {\n const points = line.points;\n const spanGaps = line.options.spanGaps;\n const count = points.length;\n if (!count) {\n return [];\n }\n const loop = !!line._loop;\n const {\n start,\n end\n } = findStartAndEnd(points, count, loop, spanGaps);\n if (spanGaps === true) {\n return splitByStyles(line, [{\n start,\n end,\n loop\n }], points, segmentOptions);\n }\n const max = end < start ? end + count : end;\n const completeLoop = !!line._fullLoop && start === 0 && end === count - 1;\n return splitByStyles(line, solidSegments(points, start, max, completeLoop), points, segmentOptions);\n}\nfunction splitByStyles(line, segments, points, segmentOptions) {\n if (!segmentOptions || !segmentOptions.setContext || !points) {\n return segments;\n }\n return doSplitByStyles(line, segments, points, segmentOptions);\n}\nfunction doSplitByStyles(line, segments, points, segmentOptions) {\n const chartContext = line._chart.getContext();\n const baseStyle = readStyle(line.options);\n const {\n _datasetIndex: datasetIndex,\n options: {\n spanGaps\n }\n } = line;\n const count = points.length;\n const result = [];\n let prevStyle = baseStyle;\n let start = segments[0].start;\n let i = start;\n function addStyle(s, e, l, st) {\n const dir = spanGaps ? -1 : 1;\n if (s === e) {\n return;\n }\n s += count;\n while (points[s % count].skip) {\n s -= dir;\n }\n while (points[e % count].skip) {\n e += dir;\n }\n if (s % count !== e % count) {\n result.push({\n start: s % count,\n end: e % count,\n loop: l,\n style: st\n });\n prevStyle = st;\n start = e % count;\n }\n }\n for (const segment of segments) {\n start = spanGaps ? start : segment.start;\n let prev = points[start % count];\n let style;\n for (i = start + 1; i <= segment.end; i++) {\n const pt = points[i % count];\n style = readStyle(segmentOptions.setContext(createContext(chartContext, {\n type: 'segment',\n p0: prev,\n p1: pt,\n p0DataIndex: (i - 1) % count,\n p1DataIndex: i % count,\n datasetIndex\n })));\n if (styleChanged(style, prevStyle)) {\n addStyle(start, i - 1, segment.loop, prevStyle);\n }\n prev = pt;\n prevStyle = style;\n }\n if (start < i - 1) {\n addStyle(start, i - 1, segment.loop, prevStyle);\n }\n }\n return result;\n}\nfunction readStyle(options) {\n return {\n backgroundColor: options.backgroundColor,\n borderCapStyle: options.borderCapStyle,\n borderDash: options.borderDash,\n borderDashOffset: options.borderDashOffset,\n borderJoinStyle: options.borderJoinStyle,\n borderWidth: options.borderWidth,\n borderColor: options.borderColor\n };\n}\nfunction styleChanged(style, prevStyle) {\n if (!prevStyle) {\n return false;\n }\n const cache = [];\n const replacer = function (key, value) {\n if (!isPatternOrGradient(value)) {\n return value;\n }\n if (!cache.includes(value)) {\n cache.push(value);\n }\n return cache.indexOf(value);\n };\n return JSON.stringify(style, replacer) !== JSON.stringify(prevStyle, replacer);\n}\nexport { unclipArea as $, _rlookupByKey as A, _lookupByKey as B, _isPointInArea as C, getAngleFromPoint as D, toPadding as E, each as F, getMaximumSize as G, HALF_PI as H, _getParentNode as I, readUsedSize as J, supportsEventListenerOptions as K, throttled as L, _isDomSupported as M, _factorize as N, finiteOrDefault as O, PI as P, callback as Q, _addGrace as R, _limitValue as S, TAU as T, toDegrees as U, _measureText as V, _int16Range as W, _alignPixel as X, clipArea as Y, renderText as Z, _arrayUnique as _, resolve as a, fontString as a$, toFont as a0, _toLeftRightCenter as a1, _alignStartEnd as a2, overrides as a3, merge as a4, _capitalize as a5, descriptors as a6, isFunction as a7, _attachContext as a8, _createResolver as a9, overrideTextDirection as aA, _textX as aB, restoreTextDirection as aC, drawPointLegend as aD, distanceBetweenPoints as aE, noop as aF, _setMinAndMaxByKey as aG, niceNum as aH, almostWhole as aI, almostEquals as aJ, _decimalPlaces as aK, Ticks as aL, log10 as aM, _longestText as aN, _filterBetween as aO, _lookup as aP, isPatternOrGradient as aQ, getHoverColor as aR, clone as aS, _merger as aT, _mergerIf as aU, _deprecated as aV, _splitKey as aW, toFontString as aX, splineCurve as aY, splineCurveMonotone as aZ, getStyle as a_, _descriptors as aa, mergeIf as ab, uid as ac, debounce as ad, retinaScale as ae, clearCanvas as af, setsEqual as ag, _elementsEqual as ah, _isClickEvent as ai, _isBetween as aj, _readValueToProps as ak, _updateBezierControlPoints as al, _computeSegments as am, _boundSegments as an, _steppedInterpolation as ao, _bezierInterpolation as ap, _pointInLine as aq, _steppedLineTo as ar, _bezierCurveTo as as, drawPoint as at, addRoundedRectPath as au, toTRBL as av, toTRBLCorners as aw, _boundSegment as ax, _normalizeAngle as ay, getRtlAdapter as az, isArray as b, toLineHeight as b0, PITAU as b1, INFINITY as b2, RAD_PER_DEG as b3, QUARTER_PI as b4, TWO_THIRDS_PI as b5, _angleDiff as b6, color as c, defaults as d, effects as e, resolveObjectKey as f, isNumberFinite as g, defined as h, isObject as i, createContext as j, isNullOrUndef as k, listenArrayEvents as l, toPercentage as m, toDimension as n, formatNumber as o, _angleBetween as p, _getStartAndCountOfVisiblePoints as q, requestAnimFrame as r, sign as s, toRadians as t, unlistenArrayEvents as u, valueOrDefault as v, _scaleRangesChanged as w, isNumber as x, _parseObjectDataRadialScale as y, getRelativePosition as z };\n","/*!\n * Chart.js v4.4.7\n * https://www.chartjs.org\n * (c) 2024 Chart.js Contributors\n * Released under the MIT License\n */\nimport { r as requestAnimFrame, a as resolve, e as effects, c as color, i as isObject, d as defaults, b as isArray, v as valueOrDefault, u as unlistenArrayEvents, l as listenArrayEvents, f as resolveObjectKey, g as isNumberFinite, h as defined, s as sign, j as createContext, k as isNullOrUndef, _ as _arrayUnique, t as toRadians, m as toPercentage, n as toDimension, T as TAU, o as formatNumber, p as _angleBetween, H as HALF_PI, P as PI, q as _getStartAndCountOfVisiblePoints, w as _scaleRangesChanged, x as isNumber, y as _parseObjectDataRadialScale, z as getRelativePosition, A as _rlookupByKey, B as _lookupByKey, C as _isPointInArea, D as getAngleFromPoint, E as toPadding, F as each, G as getMaximumSize, I as _getParentNode, J as readUsedSize, K as supportsEventListenerOptions, L as throttled, M as _isDomSupported, N as _factorize, O as finiteOrDefault, Q as callback, R as _addGrace, S as _limitValue, U as toDegrees, V as _measureText, W as _int16Range, X as _alignPixel, Y as clipArea, Z as renderText, $ as unclipArea, a0 as toFont, a1 as _toLeftRightCenter, a2 as _alignStartEnd, a3 as overrides, a4 as merge, a5 as _capitalize, a6 as descriptors, a7 as isFunction, a8 as _attachContext, a9 as _createResolver, aa as _descriptors, ab as mergeIf, ac as uid, ad as debounce, ae as retinaScale, af as clearCanvas, ag as setsEqual, ah as _elementsEqual, ai as _isClickEvent, aj as _isBetween, ak as _readValueToProps, al as _updateBezierControlPoints, am as _computeSegments, an as _boundSegments, ao as _steppedInterpolation, ap as _bezierInterpolation, aq as _pointInLine, ar as _steppedLineTo, as as _bezierCurveTo, at as drawPoint, au as addRoundedRectPath, av as toTRBL, aw as toTRBLCorners, ax as _boundSegment, ay as _normalizeAngle, az as getRtlAdapter, aA as overrideTextDirection, aB as _textX, aC as restoreTextDirection, aD as drawPointLegend, aE as distanceBetweenPoints, aF as noop, aG as _setMinAndMaxByKey, aH as niceNum, aI as almostWhole, aJ as almostEquals, aK as _decimalPlaces, aL as Ticks, aM as log10, aN as _longestText, aO as _filterBetween, aP as _lookup } from './chunks/helpers.segment.js';\nimport '@kurkle/color';\nclass Animator {\n constructor() {\n this._request = null;\n this._charts = new Map();\n this._running = false;\n this._lastDate = undefined;\n }\n _notify(chart, anims, date, type) {\n const callbacks = anims.listeners[type];\n const numSteps = anims.duration;\n callbacks.forEach(fn => fn({\n chart,\n initial: anims.initial,\n numSteps,\n currentStep: Math.min(date - anims.start, numSteps)\n }));\n }\n _refresh() {\n if (this._request) {\n return;\n }\n this._running = true;\n this._request = requestAnimFrame.call(window, () => {\n this._update();\n this._request = null;\n if (this._running) {\n this._refresh();\n }\n });\n }\n _update(date = Date.now()) {\n let remaining = 0;\n this._charts.forEach((anims, chart) => {\n if (!anims.running || !anims.items.length) {\n return;\n }\n const items = anims.items;\n let i = items.length - 1;\n let draw = false;\n let item;\n for (; i >= 0; --i) {\n item = items[i];\n if (item._active) {\n if (item._total > anims.duration) {\n anims.duration = item._total;\n }\n item.tick(date);\n draw = true;\n } else {\n items[i] = items[items.length - 1];\n items.pop();\n }\n }\n if (draw) {\n chart.draw();\n this._notify(chart, anims, date, 'progress');\n }\n if (!items.length) {\n anims.running = false;\n this._notify(chart, anims, date, 'complete');\n anims.initial = false;\n }\n remaining += items.length;\n });\n this._lastDate = date;\n if (remaining === 0) {\n this._running = false;\n }\n }\n _getAnims(chart) {\n const charts = this._charts;\n let anims = charts.get(chart);\n if (!anims) {\n anims = {\n running: false,\n initial: true,\n items: [],\n listeners: {\n complete: [],\n progress: []\n }\n };\n charts.set(chart, anims);\n }\n return anims;\n }\n listen(chart, event, cb) {\n this._getAnims(chart).listeners[event].push(cb);\n }\n add(chart, items) {\n if (!items || !items.length) {\n return;\n }\n this._getAnims(chart).items.push(...items);\n }\n has(chart) {\n return this._getAnims(chart).items.length > 0;\n }\n start(chart) {\n const anims = this._charts.get(chart);\n if (!anims) {\n return;\n }\n anims.running = true;\n anims.start = Date.now();\n anims.duration = anims.items.reduce((acc, cur) => Math.max(acc, cur._duration), 0);\n this._refresh();\n }\n running(chart) {\n if (!this._running) {\n return false;\n }\n const anims = this._charts.get(chart);\n if (!anims || !anims.running || !anims.items.length) {\n return false;\n }\n return true;\n }\n stop(chart) {\n const anims = this._charts.get(chart);\n if (!anims || !anims.items.length) {\n return;\n }\n const items = anims.items;\n let i = items.length - 1;\n for (; i >= 0; --i) {\n items[i].cancel();\n }\n anims.items = [];\n this._notify(chart, anims, Date.now(), 'complete');\n }\n remove(chart) {\n return this._charts.delete(chart);\n }\n}\nvar animator = /* #__PURE__ */new Animator();\nconst transparent = 'transparent';\nconst interpolators = {\n boolean(from, to, factor) {\n return factor > 0.5 ? to : from;\n },\n color(from, to, factor) {\n const c0 = color(from || transparent);\n const c1 = c0.valid && color(to || transparent);\n return c1 && c1.valid ? c1.mix(c0, factor).hexString() : to;\n },\n number(from, to, factor) {\n return from + (to - from) * factor;\n }\n};\nclass Animation {\n constructor(cfg, target, prop, to) {\n const currentValue = target[prop];\n to = resolve([cfg.to, to, currentValue, cfg.from]);\n const from = resolve([cfg.from, currentValue, to]);\n this._active = true;\n this._fn = cfg.fn || interpolators[cfg.type || typeof from];\n this._easing = effects[cfg.easing] || effects.linear;\n this._start = Math.floor(Date.now() + (cfg.delay || 0));\n this._duration = this._total = Math.floor(cfg.duration);\n this._loop = !!cfg.loop;\n this._target = target;\n this._prop = prop;\n this._from = from;\n this._to = to;\n this._promises = undefined;\n }\n active() {\n return this._active;\n }\n update(cfg, to, date) {\n if (this._active) {\n this._notify(false);\n const currentValue = this._target[this._prop];\n const elapsed = date - this._start;\n const remain = this._duration - elapsed;\n this._start = date;\n this._duration = Math.floor(Math.max(remain, cfg.duration));\n this._total += elapsed;\n this._loop = !!cfg.loop;\n this._to = resolve([cfg.to, to, currentValue, cfg.from]);\n this._from = resolve([cfg.from, currentValue, to]);\n }\n }\n cancel() {\n if (this._active) {\n this.tick(Date.now());\n this._active = false;\n this._notify(false);\n }\n }\n tick(date) {\n const elapsed = date - this._start;\n const duration = this._duration;\n const prop = this._prop;\n const from = this._from;\n const loop = this._loop;\n const to = this._to;\n let factor;\n this._active = from !== to && (loop || elapsed < duration);\n if (!this._active) {\n this._target[prop] = to;\n this._notify(true);\n return;\n }\n if (elapsed < 0) {\n this._target[prop] = from;\n return;\n }\n factor = elapsed / duration % 2;\n factor = loop && factor > 1 ? 2 - factor : factor;\n factor = this._easing(Math.min(1, Math.max(0, factor)));\n this._target[prop] = this._fn(from, to, factor);\n }\n wait() {\n const promises = this._promises || (this._promises = []);\n return new Promise((res, rej) => {\n promises.push({\n res,\n rej\n });\n });\n }\n _notify(resolved) {\n const method = resolved ? 'res' : 'rej';\n const promises = this._promises || [];\n for (let i = 0; i < promises.length; i++) {\n promises[i][method]();\n }\n }\n}\nclass Animations {\n constructor(chart, config) {\n this._chart = chart;\n this._properties = new Map();\n this.configure(config);\n }\n configure(config) {\n if (!isObject(config)) {\n return;\n }\n const animationOptions = Object.keys(defaults.animation);\n const animatedProps = this._properties;\n Object.getOwnPropertyNames(config).forEach(key => {\n const cfg = config[key];\n if (!isObject(cfg)) {\n return;\n }\n const resolved = {};\n for (const option of animationOptions) {\n resolved[option] = cfg[option];\n }\n (isArray(cfg.properties) && cfg.properties || [key]).forEach(prop => {\n if (prop === key || !animatedProps.has(prop)) {\n animatedProps.set(prop, resolved);\n }\n });\n });\n }\n _animateOptions(target, values) {\n const newOptions = values.options;\n const options = resolveTargetOptions(target, newOptions);\n if (!options) {\n return [];\n }\n const animations = this._createAnimations(options, newOptions);\n if (newOptions.$shared) {\n awaitAll(target.options.$animations, newOptions).then(() => {\n target.options = newOptions;\n }, () => {});\n }\n return animations;\n }\n _createAnimations(target, values) {\n const animatedProps = this._properties;\n const animations = [];\n const running = target.$animations || (target.$animations = {});\n const props = Object.keys(values);\n const date = Date.now();\n let i;\n for (i = props.length - 1; i >= 0; --i) {\n const prop = props[i];\n if (prop.charAt(0) === '$') {\n continue;\n }\n if (prop === 'options') {\n animations.push(...this._animateOptions(target, values));\n continue;\n }\n const value = values[prop];\n let animation = running[prop];\n const cfg = animatedProps.get(prop);\n if (animation) {\n if (cfg && animation.active()) {\n animation.update(cfg, value, date);\n continue;\n } else {\n animation.cancel();\n }\n }\n if (!cfg || !cfg.duration) {\n target[prop] = value;\n continue;\n }\n running[prop] = animation = new Animation(cfg, target, prop, value);\n animations.push(animation);\n }\n return animations;\n }\n update(target, values) {\n if (this._properties.size === 0) {\n Object.assign(target, values);\n return;\n }\n const animations = this._createAnimations(target, values);\n if (animations.length) {\n animator.add(this._chart, animations);\n return true;\n }\n }\n}\nfunction awaitAll(animations, properties) {\n const running = [];\n const keys = Object.keys(properties);\n for (let i = 0; i < keys.length; i++) {\n const anim = animations[keys[i]];\n if (anim && anim.active()) {\n running.push(anim.wait());\n }\n }\n return Promise.all(running);\n}\nfunction resolveTargetOptions(target, newOptions) {\n if (!newOptions) {\n return;\n }\n let options = target.options;\n if (!options) {\n target.options = newOptions;\n return;\n }\n if (options.$shared) {\n target.options = options = Object.assign({}, options, {\n $shared: false,\n $animations: {}\n });\n }\n return options;\n}\nfunction scaleClip(scale, allowedOverflow) {\n const opts = scale && scale.options || {};\n const reverse = opts.reverse;\n const min = opts.min === undefined ? allowedOverflow : 0;\n const max = opts.max === undefined ? allowedOverflow : 0;\n return {\n start: reverse ? max : min,\n end: reverse ? min : max\n };\n}\nfunction defaultClip(xScale, yScale, allowedOverflow) {\n if (allowedOverflow === false) {\n return false;\n }\n const x = scaleClip(xScale, allowedOverflow);\n const y = scaleClip(yScale, allowedOverflow);\n return {\n top: y.end,\n right: x.end,\n bottom: y.start,\n left: x.start\n };\n}\nfunction toClip(value) {\n let t, r, b, l;\n if (isObject(value)) {\n t = value.top;\n r = value.right;\n b = value.bottom;\n l = value.left;\n } else {\n t = r = b = l = value;\n }\n return {\n top: t,\n right: r,\n bottom: b,\n left: l,\n disabled: value === false\n };\n}\nfunction getSortedDatasetIndices(chart, filterVisible) {\n const keys = [];\n const metasets = chart._getSortedDatasetMetas(filterVisible);\n let i, ilen;\n for (i = 0, ilen = metasets.length; i < ilen; ++i) {\n keys.push(metasets[i].index);\n }\n return keys;\n}\nfunction applyStack(stack, value, dsIndex, options = {}) {\n const keys = stack.keys;\n const singleMode = options.mode === 'single';\n let i, ilen, datasetIndex, otherValue;\n if (value === null) {\n return;\n }\n let found = false;\n for (i = 0, ilen = keys.length; i < ilen; ++i) {\n datasetIndex = +keys[i];\n if (datasetIndex === dsIndex) {\n found = true;\n if (options.all) {\n continue;\n }\n break;\n }\n otherValue = stack.values[datasetIndex];\n if (isNumberFinite(otherValue) && (singleMode || value === 0 || sign(value) === sign(otherValue))) {\n value += otherValue;\n }\n }\n if (!found && !options.all) {\n return 0;\n }\n return value;\n}\nfunction convertObjectDataToArray(data, meta) {\n const {\n iScale,\n vScale\n } = meta;\n const iAxisKey = iScale.axis === 'x' ? 'x' : 'y';\n const vAxisKey = vScale.axis === 'x' ? 'x' : 'y';\n const keys = Object.keys(data);\n const adata = new Array(keys.length);\n let i, ilen, key;\n for (i = 0, ilen = keys.length; i < ilen; ++i) {\n key = keys[i];\n adata[i] = {\n [iAxisKey]: key,\n [vAxisKey]: data[key]\n };\n }\n return adata;\n}\nfunction isStacked(scale, meta) {\n const stacked = scale && scale.options.stacked;\n return stacked || stacked === undefined && meta.stack !== undefined;\n}\nfunction getStackKey(indexScale, valueScale, meta) {\n return `${indexScale.id}.${valueScale.id}.${meta.stack || meta.type}`;\n}\nfunction getUserBounds(scale) {\n const {\n min,\n max,\n minDefined,\n maxDefined\n } = scale.getUserBounds();\n return {\n min: minDefined ? min : Number.NEGATIVE_INFINITY,\n max: maxDefined ? max : Number.POSITIVE_INFINITY\n };\n}\nfunction getOrCreateStack(stacks, stackKey, indexValue) {\n const subStack = stacks[stackKey] || (stacks[stackKey] = {});\n return subStack[indexValue] || (subStack[indexValue] = {});\n}\nfunction getLastIndexInStack(stack, vScale, positive, type) {\n for (const meta of vScale.getMatchingVisibleMetas(type).reverse()) {\n const value = stack[meta.index];\n if (positive && value > 0 || !positive && value < 0) {\n return meta.index;\n }\n }\n return null;\n}\nfunction updateStacks(controller, parsed) {\n const {\n chart,\n _cachedMeta: meta\n } = controller;\n const stacks = chart._stacks || (chart._stacks = {});\n const {\n iScale,\n vScale,\n index: datasetIndex\n } = meta;\n const iAxis = iScale.axis;\n const vAxis = vScale.axis;\n const key = getStackKey(iScale, vScale, meta);\n const ilen = parsed.length;\n let stack;\n for (let i = 0; i < ilen; ++i) {\n const item = parsed[i];\n const {\n [iAxis]: index,\n [vAxis]: value\n } = item;\n const itemStacks = item._stacks || (item._stacks = {});\n stack = itemStacks[vAxis] = getOrCreateStack(stacks, key, index);\n stack[datasetIndex] = value;\n stack._top = getLastIndexInStack(stack, vScale, true, meta.type);\n stack._bottom = getLastIndexInStack(stack, vScale, false, meta.type);\n const visualValues = stack._visualValues || (stack._visualValues = {});\n visualValues[datasetIndex] = value;\n }\n}\nfunction getFirstScaleId(chart, axis) {\n const scales = chart.scales;\n return Object.keys(scales).filter(key => scales[key].axis === axis).shift();\n}\nfunction createDatasetContext(parent, index) {\n return createContext(parent, {\n active: false,\n dataset: undefined,\n datasetIndex: index,\n index,\n mode: 'default',\n type: 'dataset'\n });\n}\nfunction createDataContext(parent, index, element) {\n return createContext(parent, {\n active: false,\n dataIndex: index,\n parsed: undefined,\n raw: undefined,\n element,\n index,\n mode: 'default',\n type: 'data'\n });\n}\nfunction clearStacks(meta, items) {\n const datasetIndex = meta.controller.index;\n const axis = meta.vScale && meta.vScale.axis;\n if (!axis) {\n return;\n }\n items = items || meta._parsed;\n for (const parsed of items) {\n const stacks = parsed._stacks;\n if (!stacks || stacks[axis] === undefined || stacks[axis][datasetIndex] === undefined) {\n return;\n }\n delete stacks[axis][datasetIndex];\n if (stacks[axis]._visualValues !== undefined && stacks[axis]._visualValues[datasetIndex] !== undefined) {\n delete stacks[axis]._visualValues[datasetIndex];\n }\n }\n}\nconst isDirectUpdateMode = mode => mode === 'reset' || mode === 'none';\nconst cloneIfNotShared = (cached, shared) => shared ? cached : Object.assign({}, cached);\nconst createStack = (canStack, meta, chart) => canStack && !meta.hidden && meta._stacked && {\n keys: getSortedDatasetIndices(chart, true),\n values: null\n};\nlet DatasetController = /*#__PURE__*/(() => {\n class DatasetController {\n static defaults = {};\n static datasetElementType = null;\n static dataElementType = null;\n constructor(chart, datasetIndex) {\n this.chart = chart;\n this._ctx = chart.ctx;\n this.index = datasetIndex;\n this._cachedDataOpts = {};\n this._cachedMeta = this.getMeta();\n this._type = this._cachedMeta.type;\n this.options = undefined;\n this._parsing = false;\n this._data = undefined;\n this._objectData = undefined;\n this._sharedOptions = undefined;\n this._drawStart = undefined;\n this._drawCount = undefined;\n this.enableOptionSharing = false;\n this.supportsDecimation = false;\n this.$context = undefined;\n this._syncList = [];\n this.datasetElementType = new.target.datasetElementType;\n this.dataElementType = new.target.dataElementType;\n this.initialize();\n }\n initialize() {\n const meta = this._cachedMeta;\n this.configure();\n this.linkScales();\n meta._stacked = isStacked(meta.vScale, meta);\n this.addElements();\n if (this.options.fill && !this.chart.isPluginEnabled('filler')) {\n console.warn(\"Tried to use the 'fill' option without the 'Filler' plugin enabled. Please import and register the 'Filler' plugin and make sure it is not disabled in the options\");\n }\n }\n updateIndex(datasetIndex) {\n if (this.index !== datasetIndex) {\n clearStacks(this._cachedMeta);\n }\n this.index = datasetIndex;\n }\n linkScales() {\n const chart = this.chart;\n const meta = this._cachedMeta;\n const dataset = this.getDataset();\n const chooseId = (axis, x, y, r) => axis === 'x' ? x : axis === 'r' ? r : y;\n const xid = meta.xAxisID = valueOrDefault(dataset.xAxisID, getFirstScaleId(chart, 'x'));\n const yid = meta.yAxisID = valueOrDefault(dataset.yAxisID, getFirstScaleId(chart, 'y'));\n const rid = meta.rAxisID = valueOrDefault(dataset.rAxisID, getFirstScaleId(chart, 'r'));\n const indexAxis = meta.indexAxis;\n const iid = meta.iAxisID = chooseId(indexAxis, xid, yid, rid);\n const vid = meta.vAxisID = chooseId(indexAxis, yid, xid, rid);\n meta.xScale = this.getScaleForId(xid);\n meta.yScale = this.getScaleForId(yid);\n meta.rScale = this.getScaleForId(rid);\n meta.iScale = this.getScaleForId(iid);\n meta.vScale = this.getScaleForId(vid);\n }\n getDataset() {\n return this.chart.data.datasets[this.index];\n }\n getMeta() {\n return this.chart.getDatasetMeta(this.index);\n }\n getScaleForId(scaleID) {\n return this.chart.scales[scaleID];\n }\n _getOtherScale(scale) {\n const meta = this._cachedMeta;\n return scale === meta.iScale ? meta.vScale : meta.iScale;\n }\n reset() {\n this._update('reset');\n }\n _destroy() {\n const meta = this._cachedMeta;\n if (this._data) {\n unlistenArrayEvents(this._data, this);\n }\n if (meta._stacked) {\n clearStacks(meta);\n }\n }\n _dataCheck() {\n const dataset = this.getDataset();\n const data = dataset.data || (dataset.data = []);\n const _data = this._data;\n if (isObject(data)) {\n const meta = this._cachedMeta;\n this._data = convertObjectDataToArray(data, meta);\n } else if (_data !== data) {\n if (_data) {\n unlistenArrayEvents(_data, this);\n const meta = this._cachedMeta;\n clearStacks(meta);\n meta._parsed = [];\n }\n if (data && Object.isExtensible(data)) {\n listenArrayEvents(data, this);\n }\n this._syncList = [];\n this._data = data;\n }\n }\n addElements() {\n const meta = this._cachedMeta;\n this._dataCheck();\n if (this.datasetElementType) {\n meta.dataset = new this.datasetElementType();\n }\n }\n buildOrUpdateElements(resetNewElements) {\n const meta = this._cachedMeta;\n const dataset = this.getDataset();\n let stackChanged = false;\n this._dataCheck();\n const oldStacked = meta._stacked;\n meta._stacked = isStacked(meta.vScale, meta);\n if (meta.stack !== dataset.stack) {\n stackChanged = true;\n clearStacks(meta);\n meta.stack = dataset.stack;\n }\n this._resyncElements(resetNewElements);\n if (stackChanged || oldStacked !== meta._stacked) {\n updateStacks(this, meta._parsed);\n meta._stacked = isStacked(meta.vScale, meta);\n }\n }\n configure() {\n const config = this.chart.config;\n const scopeKeys = config.datasetScopeKeys(this._type);\n const scopes = config.getOptionScopes(this.getDataset(), scopeKeys, true);\n this.options = config.createResolver(scopes, this.getContext());\n this._parsing = this.options.parsing;\n this._cachedDataOpts = {};\n }\n parse(start, count) {\n const {\n _cachedMeta: meta,\n _data: data\n } = this;\n const {\n iScale,\n _stacked\n } = meta;\n const iAxis = iScale.axis;\n let sorted = start === 0 && count === data.length ? true : meta._sorted;\n let prev = start > 0 && meta._parsed[start - 1];\n let i, cur, parsed;\n if (this._parsing === false) {\n meta._parsed = data;\n meta._sorted = true;\n parsed = data;\n } else {\n if (isArray(data[start])) {\n parsed = this.parseArrayData(meta, data, start, count);\n } else if (isObject(data[start])) {\n parsed = this.parseObjectData(meta, data, start, count);\n } else {\n parsed = this.parsePrimitiveData(meta, data, start, count);\n }\n const isNotInOrderComparedToPrev = () => cur[iAxis] === null || prev && cur[iAxis] < prev[iAxis];\n for (i = 0; i < count; ++i) {\n meta._parsed[i + start] = cur = parsed[i];\n if (sorted) {\n if (isNotInOrderComparedToPrev()) {\n sorted = false;\n }\n prev = cur;\n }\n }\n meta._sorted = sorted;\n }\n if (_stacked) {\n updateStacks(this, parsed);\n }\n }\n parsePrimitiveData(meta, data, start, count) {\n const {\n iScale,\n vScale\n } = meta;\n const iAxis = iScale.axis;\n const vAxis = vScale.axis;\n const labels = iScale.getLabels();\n const singleScale = iScale === vScale;\n const parsed = new Array(count);\n let i, ilen, index;\n for (i = 0, ilen = count; i < ilen; ++i) {\n index = i + start;\n parsed[i] = {\n [iAxis]: singleScale || iScale.parse(labels[index], index),\n [vAxis]: vScale.parse(data[index], index)\n };\n }\n return parsed;\n }\n parseArrayData(meta, data, start, count) {\n const {\n xScale,\n yScale\n } = meta;\n const parsed = new Array(count);\n let i, ilen, index, item;\n for (i = 0, ilen = count; i < ilen; ++i) {\n index = i + start;\n item = data[index];\n parsed[i] = {\n x: xScale.parse(item[0], index),\n y: yScale.parse(item[1], index)\n };\n }\n return parsed;\n }\n parseObjectData(meta, data, start, count) {\n const {\n xScale,\n yScale\n } = meta;\n const {\n xAxisKey = 'x',\n yAxisKey = 'y'\n } = this._parsing;\n const parsed = new Array(count);\n let i, ilen, index, item;\n for (i = 0, ilen = count; i < ilen; ++i) {\n index = i + start;\n item = data[index];\n parsed[i] = {\n x: xScale.parse(resolveObjectKey(item, xAxisKey), index),\n y: yScale.parse(resolveObjectKey(item, yAxisKey), index)\n };\n }\n return parsed;\n }\n getParsed(index) {\n return this._cachedMeta._parsed[index];\n }\n getDataElement(index) {\n return this._cachedMeta.data[index];\n }\n applyStack(scale, parsed, mode) {\n const chart = this.chart;\n const meta = this._cachedMeta;\n const value = parsed[scale.axis];\n const stack = {\n keys: getSortedDatasetIndices(chart, true),\n values: parsed._stacks[scale.axis]._visualValues\n };\n return applyStack(stack, value, meta.index, {\n mode\n });\n }\n updateRangeFromParsed(range, scale, parsed, stack) {\n const parsedValue = parsed[scale.axis];\n let value = parsedValue === null ? NaN : parsedValue;\n const values = stack && parsed._stacks[scale.axis];\n if (stack && values) {\n stack.values = values;\n value = applyStack(stack, parsedValue, this._cachedMeta.index);\n }\n range.min = Math.min(range.min, value);\n range.max = Math.max(range.max, value);\n }\n getMinMax(scale, canStack) {\n const meta = this._cachedMeta;\n const _parsed = meta._parsed;\n const sorted = meta._sorted && scale === meta.iScale;\n const ilen = _parsed.length;\n const otherScale = this._getOtherScale(scale);\n const stack = createStack(canStack, meta, this.chart);\n const range = {\n min: Number.POSITIVE_INFINITY,\n max: Number.NEGATIVE_INFINITY\n };\n const {\n min: otherMin,\n max: otherMax\n } = getUserBounds(otherScale);\n let i, parsed;\n function _skip() {\n parsed = _parsed[i];\n const otherValue = parsed[otherScale.axis];\n return !isNumberFinite(parsed[scale.axis]) || otherMin > otherValue || otherMax < otherValue;\n }\n for (i = 0; i < ilen; ++i) {\n if (_skip()) {\n continue;\n }\n this.updateRangeFromParsed(range, scale, parsed, stack);\n if (sorted) {\n break;\n }\n }\n if (sorted) {\n for (i = ilen - 1; i >= 0; --i) {\n if (_skip()) {\n continue;\n }\n this.updateRangeFromParsed(range, scale, parsed, stack);\n break;\n }\n }\n return range;\n }\n getAllParsedValues(scale) {\n const parsed = this._cachedMeta._parsed;\n const values = [];\n let i, ilen, value;\n for (i = 0, ilen = parsed.length; i < ilen; ++i) {\n value = parsed[i][scale.axis];\n if (isNumberFinite(value)) {\n values.push(value);\n }\n }\n return values;\n }\n getMaxOverflow() {\n return false;\n }\n getLabelAndValue(index) {\n const meta = this._cachedMeta;\n const iScale = meta.iScale;\n const vScale = meta.vScale;\n const parsed = this.getParsed(index);\n return {\n label: iScale ? '' + iScale.getLabelForValue(parsed[iScale.axis]) : '',\n value: vScale ? '' + vScale.getLabelForValue(parsed[vScale.axis]) : ''\n };\n }\n _update(mode) {\n const meta = this._cachedMeta;\n this.update(mode || 'default');\n meta._clip = toClip(valueOrDefault(this.options.clip, defaultClip(meta.xScale, meta.yScale, this.getMaxOverflow())));\n }\n update(mode) {}\n draw() {\n const ctx = this._ctx;\n const chart = this.chart;\n const meta = this._cachedMeta;\n const elements = meta.data || [];\n const area = chart.chartArea;\n const active = [];\n const start = this._drawStart || 0;\n const count = this._drawCount || elements.length - start;\n const drawActiveElementsOnTop = this.options.drawActiveElementsOnTop;\n let i;\n if (meta.dataset) {\n meta.dataset.draw(ctx, area, start, count);\n }\n for (i = start; i < start + count; ++i) {\n const element = elements[i];\n if (element.hidden) {\n continue;\n }\n if (element.active && drawActiveElementsOnTop) {\n active.push(element);\n } else {\n element.draw(ctx, area);\n }\n }\n for (i = 0; i < active.length; ++i) {\n active[i].draw(ctx, area);\n }\n }\n getStyle(index, active) {\n const mode = active ? 'active' : 'default';\n return index === undefined && this._cachedMeta.dataset ? this.resolveDatasetElementOptions(mode) : this.resolveDataElementOptions(index || 0, mode);\n }\n getContext(index, active, mode) {\n const dataset = this.getDataset();\n let context;\n if (index >= 0 && index < this._cachedMeta.data.length) {\n const element = this._cachedMeta.data[index];\n context = element.$context || (element.$context = createDataContext(this.getContext(), index, element));\n context.parsed = this.getParsed(index);\n context.raw = dataset.data[index];\n context.index = context.dataIndex = index;\n } else {\n context = this.$context || (this.$context = createDatasetContext(this.chart.getContext(), this.index));\n context.dataset = dataset;\n context.index = context.datasetIndex = this.index;\n }\n context.active = !!active;\n context.mode = mode;\n return context;\n }\n resolveDatasetElementOptions(mode) {\n return this._resolveElementOptions(this.datasetElementType.id, mode);\n }\n resolveDataElementOptions(index, mode) {\n return this._resolveElementOptions(this.dataElementType.id, mode, index);\n }\n _resolveElementOptions(elementType, mode = 'default', index) {\n const active = mode === 'active';\n const cache = this._cachedDataOpts;\n const cacheKey = elementType + '-' + mode;\n const cached = cache[cacheKey];\n const sharing = this.enableOptionSharing && defined(index);\n if (cached) {\n return cloneIfNotShared(cached, sharing);\n }\n const config = this.chart.config;\n const scopeKeys = config.datasetElementScopeKeys(this._type, elementType);\n const prefixes = active ? [`${elementType}Hover`, 'hover', elementType, ''] : [elementType, ''];\n const scopes = config.getOptionScopes(this.getDataset(), scopeKeys);\n const names = Object.keys(defaults.elements[elementType]);\n const context = () => this.getContext(index, active, mode);\n const values = config.resolveNamedOptions(scopes, names, context, prefixes);\n if (values.$shared) {\n values.$shared = sharing;\n cache[cacheKey] = Object.freeze(cloneIfNotShared(values, sharing));\n }\n return values;\n }\n _resolveAnimations(index, transition, active) {\n const chart = this.chart;\n const cache = this._cachedDataOpts;\n const cacheKey = `animation-${transition}`;\n const cached = cache[cacheKey];\n if (cached) {\n return cached;\n }\n let options;\n if (chart.options.animation !== false) {\n const config = this.chart.config;\n const scopeKeys = config.datasetAnimationScopeKeys(this._type, transition);\n const scopes = config.getOptionScopes(this.getDataset(), scopeKeys);\n options = config.createResolver(scopes, this.getContext(index, active, transition));\n }\n const animations = new Animations(chart, options && options.animations);\n if (options && options._cacheable) {\n cache[cacheKey] = Object.freeze(animations);\n }\n return animations;\n }\n getSharedOptions(options) {\n if (!options.$shared) {\n return;\n }\n return this._sharedOptions || (this._sharedOptions = Object.assign({}, options));\n }\n includeOptions(mode, sharedOptions) {\n return !sharedOptions || isDirectUpdateMode(mode) || this.chart._animationsDisabled;\n }\n _getSharedOptions(start, mode) {\n const firstOpts = this.resolveDataElementOptions(start, mode);\n const previouslySharedOptions = this._sharedOptions;\n const sharedOptions = this.getSharedOptions(firstOpts);\n const includeOptions = this.includeOptions(mode, sharedOptions) || sharedOptions !== previouslySharedOptions;\n this.updateSharedOptions(sharedOptions, mode, firstOpts);\n return {\n sharedOptions,\n includeOptions\n };\n }\n updateElement(element, index, properties, mode) {\n if (isDirectUpdateMode(mode)) {\n Object.assign(element, properties);\n } else {\n this._resolveAnimations(index, mode).update(element, properties);\n }\n }\n updateSharedOptions(sharedOptions, mode, newOptions) {\n if (sharedOptions && !isDirectUpdateMode(mode)) {\n this._resolveAnimations(undefined, mode).update(sharedOptions, newOptions);\n }\n }\n _setStyle(element, index, mode, active) {\n element.active = active;\n const options = this.getStyle(index, active);\n this._resolveAnimations(index, mode, active).update(element, {\n options: !active && this.getSharedOptions(options) || options\n });\n }\n removeHoverStyle(element, datasetIndex, index) {\n this._setStyle(element, index, 'active', false);\n }\n setHoverStyle(element, datasetIndex, index) {\n this._setStyle(element, index, 'active', true);\n }\n _removeDatasetHoverStyle() {\n const element = this._cachedMeta.dataset;\n if (element) {\n this._setStyle(element, undefined, 'active', false);\n }\n }\n _setDatasetHoverStyle() {\n const element = this._cachedMeta.dataset;\n if (element) {\n this._setStyle(element, undefined, 'active', true);\n }\n }\n _resyncElements(resetNewElements) {\n const data = this._data;\n const elements = this._cachedMeta.data;\n for (const [method, arg1, arg2] of this._syncList) {\n this[method](arg1, arg2);\n }\n this._syncList = [];\n const numMeta = elements.length;\n const numData = data.length;\n const count = Math.min(numData, numMeta);\n if (count) {\n this.parse(0, count);\n }\n if (numData > numMeta) {\n this._insertElements(numMeta, numData - numMeta, resetNewElements);\n } else if (numData < numMeta) {\n this._removeElements(numData, numMeta - numData);\n }\n }\n _insertElements(start, count, resetNewElements = true) {\n const meta = this._cachedMeta;\n const data = meta.data;\n const end = start + count;\n let i;\n const move = arr => {\n arr.length += count;\n for (i = arr.length - 1; i >= end; i--) {\n arr[i] = arr[i - count];\n }\n };\n move(data);\n for (i = start; i < end; ++i) {\n data[i] = new this.dataElementType();\n }\n if (this._parsing) {\n move(meta._parsed);\n }\n this.parse(start, count);\n if (resetNewElements) {\n this.updateElements(data, start, count, 'reset');\n }\n }\n updateElements(element, start, count, mode) {}\n _removeElements(start, count) {\n const meta = this._cachedMeta;\n if (this._parsing) {\n const removed = meta._parsed.splice(start, count);\n if (meta._stacked) {\n clearStacks(meta, removed);\n }\n }\n meta.data.splice(start, count);\n }\n _sync(args) {\n if (this._parsing) {\n this._syncList.push(args);\n } else {\n const [method, arg1, arg2] = args;\n this[method](arg1, arg2);\n }\n this.chart._dataChanges.push([this.index, ...args]);\n }\n _onDataPush() {\n const count = arguments.length;\n this._sync(['_insertElements', this.getDataset().data.length - count, count]);\n }\n _onDataPop() {\n this._sync(['_removeElements', this._cachedMeta.data.length - 1, 1]);\n }\n _onDataShift() {\n this._sync(['_removeElements', 0, 1]);\n }\n _onDataSplice(start, count) {\n if (count) {\n this._sync(['_removeElements', start, count]);\n }\n const newCount = arguments.length - 2;\n if (newCount) {\n this._sync(['_insertElements', start, newCount]);\n }\n }\n _onDataUnshift() {\n this._sync(['_insertElements', 0, arguments.length]);\n }\n }\n return DatasetController;\n})();\nfunction getAllScaleValues(scale, type) {\n if (!scale._cache.$bar) {\n const visibleMetas = scale.getMatchingVisibleMetas(type);\n let values = [];\n for (let i = 0, ilen = visibleMetas.length; i < ilen; i++) {\n values = values.concat(visibleMetas[i].controller.getAllParsedValues(scale));\n }\n scale._cache.$bar = _arrayUnique(values.sort((a, b) => a - b));\n }\n return scale._cache.$bar;\n}\nfunction computeMinSampleSize(meta) {\n const scale = meta.iScale;\n const values = getAllScaleValues(scale, meta.type);\n let min = scale._length;\n let i, ilen, curr, prev;\n const updateMinAndPrev = () => {\n if (curr === 32767 || curr === -32768) {\n return;\n }\n if (defined(prev)) {\n min = Math.min(min, Math.abs(curr - prev) || min);\n }\n prev = curr;\n };\n for (i = 0, ilen = values.length; i < ilen; ++i) {\n curr = scale.getPixelForValue(values[i]);\n updateMinAndPrev();\n }\n prev = undefined;\n for (i = 0, ilen = scale.ticks.length; i < ilen; ++i) {\n curr = scale.getPixelForTick(i);\n updateMinAndPrev();\n }\n return min;\n}\nfunction computeFitCategoryTraits(index, ruler, options, stackCount) {\n const thickness = options.barThickness;\n let size, ratio;\n if (isNullOrUndef(thickness)) {\n size = ruler.min * options.categoryPercentage;\n ratio = options.barPercentage;\n } else {\n size = thickness * stackCount;\n ratio = 1;\n }\n return {\n chunk: size / stackCount,\n ratio,\n start: ruler.pixels[index] - size / 2\n };\n}\nfunction computeFlexCategoryTraits(index, ruler, options, stackCount) {\n const pixels = ruler.pixels;\n const curr = pixels[index];\n let prev = index > 0 ? pixels[index - 1] : null;\n let next = index < pixels.length - 1 ? pixels[index + 1] : null;\n const percent = options.categoryPercentage;\n if (prev === null) {\n prev = curr - (next === null ? ruler.end - ruler.start : next - curr);\n }\n if (next === null) {\n next = curr + curr - prev;\n }\n const start = curr - (curr - Math.min(prev, next)) / 2 * percent;\n const size = Math.abs(next - prev) / 2 * percent;\n return {\n chunk: size / stackCount,\n ratio: options.barPercentage,\n start\n };\n}\nfunction parseFloatBar(entry, item, vScale, i) {\n const startValue = vScale.parse(entry[0], i);\n const endValue = vScale.parse(entry[1], i);\n const min = Math.min(startValue, endValue);\n const max = Math.max(startValue, endValue);\n let barStart = min;\n let barEnd = max;\n if (Math.abs(min) > Math.abs(max)) {\n barStart = max;\n barEnd = min;\n }\n item[vScale.axis] = barEnd;\n item._custom = {\n barStart,\n barEnd,\n start: startValue,\n end: endValue,\n min,\n max\n };\n}\nfunction parseValue(entry, item, vScale, i) {\n if (isArray(entry)) {\n parseFloatBar(entry, item, vScale, i);\n } else {\n item[vScale.axis] = vScale.parse(entry, i);\n }\n return item;\n}\nfunction parseArrayOrPrimitive(meta, data, start, count) {\n const iScale = meta.iScale;\n const vScale = meta.vScale;\n const labels = iScale.getLabels();\n const singleScale = iScale === vScale;\n const parsed = [];\n let i, ilen, item, entry;\n for (i = start, ilen = start + count; i < ilen; ++i) {\n entry = data[i];\n item = {};\n item[iScale.axis] = singleScale || iScale.parse(labels[i], i);\n parsed.push(parseValue(entry, item, vScale, i));\n }\n return parsed;\n}\nfunction isFloatBar(custom) {\n return custom && custom.barStart !== undefined && custom.barEnd !== undefined;\n}\nfunction barSign(size, vScale, actualBase) {\n if (size !== 0) {\n return sign(size);\n }\n return (vScale.isHorizontal() ? 1 : -1) * (vScale.min >= actualBase ? 1 : -1);\n}\nfunction borderProps(properties) {\n let reverse, start, end, top, bottom;\n if (properties.horizontal) {\n reverse = properties.base > properties.x;\n start = 'left';\n end = 'right';\n } else {\n reverse = properties.base < properties.y;\n start = 'bottom';\n end = 'top';\n }\n if (reverse) {\n top = 'end';\n bottom = 'start';\n } else {\n top = 'start';\n bottom = 'end';\n }\n return {\n start,\n end,\n reverse,\n top,\n bottom\n };\n}\nfunction setBorderSkipped(properties, options, stack, index) {\n let edge = options.borderSkipped;\n const res = {};\n if (!edge) {\n properties.borderSkipped = res;\n return;\n }\n if (edge === true) {\n properties.borderSkipped = {\n top: true,\n right: true,\n bottom: true,\n left: true\n };\n return;\n }\n const {\n start,\n end,\n reverse,\n top,\n bottom\n } = borderProps(properties);\n if (edge === 'middle' && stack) {\n properties.enableBorderRadius = true;\n if ((stack._top || 0) === index) {\n edge = top;\n } else if ((stack._bottom || 0) === index) {\n edge = bottom;\n } else {\n res[parseEdge(bottom, start, end, reverse)] = true;\n edge = top;\n }\n }\n res[parseEdge(edge, start, end, reverse)] = true;\n properties.borderSkipped = res;\n}\nfunction parseEdge(edge, a, b, reverse) {\n if (reverse) {\n edge = swap(edge, a, b);\n edge = startEnd(edge, b, a);\n } else {\n edge = startEnd(edge, a, b);\n }\n return edge;\n}\nfunction swap(orig, v1, v2) {\n return orig === v1 ? v2 : orig === v2 ? v1 : orig;\n}\nfunction startEnd(v, start, end) {\n return v === 'start' ? start : v === 'end' ? end : v;\n}\nfunction setInflateAmount(properties, {\n inflateAmount\n}, ratio) {\n properties.inflateAmount = inflateAmount === 'auto' ? ratio === 1 ? 0.33 : 0 : inflateAmount;\n}\nlet BarController = /*#__PURE__*/(() => {\n class BarController extends DatasetController {\n static id = 'bar';\n static defaults = {\n datasetElementType: false,\n dataElementType: 'bar',\n categoryPercentage: 0.8,\n barPercentage: 0.9,\n grouped: true,\n animations: {\n numbers: {\n type: 'number',\n properties: ['x', 'y', 'base', 'width', 'height']\n }\n }\n };\n static overrides = {\n scales: {\n _index_: {\n type: 'category',\n offset: true,\n grid: {\n offset: true\n }\n },\n _value_: {\n type: 'linear',\n beginAtZero: true\n }\n }\n };\n parsePrimitiveData(meta, data, start, count) {\n return parseArrayOrPrimitive(meta, data, start, count);\n }\n parseArrayData(meta, data, start, count) {\n return parseArrayOrPrimitive(meta, data, start, count);\n }\n parseObjectData(meta, data, start, count) {\n const {\n iScale,\n vScale\n } = meta;\n const {\n xAxisKey = 'x',\n yAxisKey = 'y'\n } = this._parsing;\n const iAxisKey = iScale.axis === 'x' ? xAxisKey : yAxisKey;\n const vAxisKey = vScale.axis === 'x' ? xAxisKey : yAxisKey;\n const parsed = [];\n let i, ilen, item, obj;\n for (i = start, ilen = start + count; i < ilen; ++i) {\n obj = data[i];\n item = {};\n item[iScale.axis] = iScale.parse(resolveObjectKey(obj, iAxisKey), i);\n parsed.push(parseValue(resolveObjectKey(obj, vAxisKey), item, vScale, i));\n }\n return parsed;\n }\n updateRangeFromParsed(range, scale, parsed, stack) {\n super.updateRangeFromParsed(range, scale, parsed, stack);\n const custom = parsed._custom;\n if (custom && scale === this._cachedMeta.vScale) {\n range.min = Math.min(range.min, custom.min);\n range.max = Math.max(range.max, custom.max);\n }\n }\n getMaxOverflow() {\n return 0;\n }\n getLabelAndValue(index) {\n const meta = this._cachedMeta;\n const {\n iScale,\n vScale\n } = meta;\n const parsed = this.getParsed(index);\n const custom = parsed._custom;\n const value = isFloatBar(custom) ? '[' + custom.start + ', ' + custom.end + ']' : '' + vScale.getLabelForValue(parsed[vScale.axis]);\n return {\n label: '' + iScale.getLabelForValue(parsed[iScale.axis]),\n value\n };\n }\n initialize() {\n this.enableOptionSharing = true;\n super.initialize();\n const meta = this._cachedMeta;\n meta.stack = this.getDataset().stack;\n }\n update(mode) {\n const meta = this._cachedMeta;\n this.updateElements(meta.data, 0, meta.data.length, mode);\n }\n updateElements(bars, start, count, mode) {\n const reset = mode === 'reset';\n const {\n index,\n _cachedMeta: {\n vScale\n }\n } = this;\n const base = vScale.getBasePixel();\n const horizontal = vScale.isHorizontal();\n const ruler = this._getRuler();\n const {\n sharedOptions,\n includeOptions\n } = this._getSharedOptions(start, mode);\n for (let i = start; i < start + count; i++) {\n const parsed = this.getParsed(i);\n const vpixels = reset || isNullOrUndef(parsed[vScale.axis]) ? {\n base,\n head: base\n } : this._calculateBarValuePixels(i);\n const ipixels = this._calculateBarIndexPixels(i, ruler);\n const stack = (parsed._stacks || {})[vScale.axis];\n const properties = {\n horizontal,\n base: vpixels.base,\n enableBorderRadius: !stack || isFloatBar(parsed._custom) || index === stack._top || index === stack._bottom,\n x: horizontal ? vpixels.head : ipixels.center,\n y: horizontal ? ipixels.center : vpixels.head,\n height: horizontal ? ipixels.size : Math.abs(vpixels.size),\n width: horizontal ? Math.abs(vpixels.size) : ipixels.size\n };\n if (includeOptions) {\n properties.options = sharedOptions || this.resolveDataElementOptions(i, bars[i].active ? 'active' : mode);\n }\n const options = properties.options || bars[i].options;\n setBorderSkipped(properties, options, stack, index);\n setInflateAmount(properties, options, ruler.ratio);\n this.updateElement(bars[i], i, properties, mode);\n }\n }\n _getStacks(last, dataIndex) {\n const {\n iScale\n } = this._cachedMeta;\n const metasets = iScale.getMatchingVisibleMetas(this._type).filter(meta => meta.controller.options.grouped);\n const stacked = iScale.options.stacked;\n const stacks = [];\n const currentParsed = this._cachedMeta.controller.getParsed(dataIndex);\n const iScaleValue = currentParsed && currentParsed[iScale.axis];\n const skipNull = meta => {\n const parsed = meta._parsed.find(item => item[iScale.axis] === iScaleValue);\n const val = parsed && parsed[meta.vScale.axis];\n if (isNullOrUndef(val) || isNaN(val)) {\n return true;\n }\n };\n for (const meta of metasets) {\n if (dataIndex !== undefined && skipNull(meta)) {\n continue;\n }\n if (stacked === false || stacks.indexOf(meta.stack) === -1 || stacked === undefined && meta.stack === undefined) {\n stacks.push(meta.stack);\n }\n if (meta.index === last) {\n break;\n }\n }\n if (!stacks.length) {\n stacks.push(undefined);\n }\n return stacks;\n }\n _getStackCount(index) {\n return this._getStacks(undefined, index).length;\n }\n _getStackIndex(datasetIndex, name, dataIndex) {\n const stacks = this._getStacks(datasetIndex, dataIndex);\n const index = name !== undefined ? stacks.indexOf(name) : -1;\n return index === -1 ? stacks.length - 1 : index;\n }\n _getRuler() {\n const opts = this.options;\n const meta = this._cachedMeta;\n const iScale = meta.iScale;\n const pixels = [];\n let i, ilen;\n for (i = 0, ilen = meta.data.length; i < ilen; ++i) {\n pixels.push(iScale.getPixelForValue(this.getParsed(i)[iScale.axis], i));\n }\n const barThickness = opts.barThickness;\n const min = barThickness || computeMinSampleSize(meta);\n return {\n min,\n pixels,\n start: iScale._startPixel,\n end: iScale._endPixel,\n stackCount: this._getStackCount(),\n scale: iScale,\n grouped: opts.grouped,\n ratio: barThickness ? 1 : opts.categoryPercentage * opts.barPercentage\n };\n }\n _calculateBarValuePixels(index) {\n const {\n _cachedMeta: {\n vScale,\n _stacked,\n index: datasetIndex\n },\n options: {\n base: baseValue,\n minBarLength\n }\n } = this;\n const actualBase = baseValue || 0;\n const parsed = this.getParsed(index);\n const custom = parsed._custom;\n const floating = isFloatBar(custom);\n let value = parsed[vScale.axis];\n let start = 0;\n let length = _stacked ? this.applyStack(vScale, parsed, _stacked) : value;\n let head, size;\n if (length !== value) {\n start = length - value;\n length = value;\n }\n if (floating) {\n value = custom.barStart;\n length = custom.barEnd - custom.barStart;\n if (value !== 0 && sign(value) !== sign(custom.barEnd)) {\n start = 0;\n }\n start += value;\n }\n const startValue = !isNullOrUndef(baseValue) && !floating ? baseValue : start;\n let base = vScale.getPixelForValue(startValue);\n if (this.chart.getDataVisibility(index)) {\n head = vScale.getPixelForValue(start + length);\n } else {\n head = base;\n }\n size = head - base;\n if (Math.abs(size) < minBarLength) {\n size = barSign(size, vScale, actualBase) * minBarLength;\n if (value === actualBase) {\n base -= size / 2;\n }\n const startPixel = vScale.getPixelForDecimal(0);\n const endPixel = vScale.getPixelForDecimal(1);\n const min = Math.min(startPixel, endPixel);\n const max = Math.max(startPixel, endPixel);\n base = Math.max(Math.min(base, max), min);\n head = base + size;\n if (_stacked && !floating) {\n parsed._stacks[vScale.axis]._visualValues[datasetIndex] = vScale.getValueForPixel(head) - vScale.getValueForPixel(base);\n }\n }\n if (base === vScale.getPixelForValue(actualBase)) {\n const halfGrid = sign(size) * vScale.getLineWidthForValue(actualBase) / 2;\n base += halfGrid;\n size -= halfGrid;\n }\n return {\n size,\n base,\n head,\n center: head + size / 2\n };\n }\n _calculateBarIndexPixels(index, ruler) {\n const scale = ruler.scale;\n const options = this.options;\n const skipNull = options.skipNull;\n const maxBarThickness = valueOrDefault(options.maxBarThickness, Infinity);\n let center, size;\n if (ruler.grouped) {\n const stackCount = skipNull ? this._getStackCount(index) : ruler.stackCount;\n const range = options.barThickness === 'flex' ? computeFlexCategoryTraits(index, ruler, options, stackCount) : computeFitCategoryTraits(index, ruler, options, stackCount);\n const stackIndex = this._getStackIndex(this.index, this._cachedMeta.stack, skipNull ? index : undefined);\n center = range.start + range.chunk * stackIndex + range.chunk / 2;\n size = Math.min(maxBarThickness, range.chunk * range.ratio);\n } else {\n center = scale.getPixelForValue(this.getParsed(index)[scale.axis], index);\n size = Math.min(maxBarThickness, ruler.min * ruler.ratio);\n }\n return {\n base: center - size / 2,\n head: center + size / 2,\n center,\n size\n };\n }\n draw() {\n const meta = this._cachedMeta;\n const vScale = meta.vScale;\n const rects = meta.data;\n const ilen = rects.length;\n let i = 0;\n for (; i < ilen; ++i) {\n if (this.getParsed(i)[vScale.axis] !== null && !rects[i].hidden) {\n rects[i].draw(this._ctx);\n }\n }\n }\n }\n return BarController;\n})();\nlet BubbleController = /*#__PURE__*/(() => {\n class BubbleController extends DatasetController {\n static id = 'bubble';\n static defaults = {\n datasetElementType: false,\n dataElementType: 'point',\n animations: {\n numbers: {\n type: 'number',\n properties: ['x', 'y', 'borderWidth', 'radius']\n }\n }\n };\n static overrides = {\n scales: {\n x: {\n type: 'linear'\n },\n y: {\n type: 'linear'\n }\n }\n };\n initialize() {\n this.enableOptionSharing = true;\n super.initialize();\n }\n parsePrimitiveData(meta, data, start, count) {\n const parsed = super.parsePrimitiveData(meta, data, start, count);\n for (let i = 0; i < parsed.length; i++) {\n parsed[i]._custom = this.resolveDataElementOptions(i + start).radius;\n }\n return parsed;\n }\n parseArrayData(meta, data, start, count) {\n const parsed = super.parseArrayData(meta, data, start, count);\n for (let i = 0; i < parsed.length; i++) {\n const item = data[start + i];\n parsed[i]._custom = valueOrDefault(item[2], this.resolveDataElementOptions(i + start).radius);\n }\n return parsed;\n }\n parseObjectData(meta, data, start, count) {\n const parsed = super.parseObjectData(meta, data, start, count);\n for (let i = 0; i < parsed.length; i++) {\n const item = data[start + i];\n parsed[i]._custom = valueOrDefault(item && item.r && +item.r, this.resolveDataElementOptions(i + start).radius);\n }\n return parsed;\n }\n getMaxOverflow() {\n const data = this._cachedMeta.data;\n let max = 0;\n for (let i = data.length - 1; i >= 0; --i) {\n max = Math.max(max, data[i].size(this.resolveDataElementOptions(i)) / 2);\n }\n return max > 0 && max;\n }\n getLabelAndValue(index) {\n const meta = this._cachedMeta;\n const labels = this.chart.data.labels || [];\n const {\n xScale,\n yScale\n } = meta;\n const parsed = this.getParsed(index);\n const x = xScale.getLabelForValue(parsed.x);\n const y = yScale.getLabelForValue(parsed.y);\n const r = parsed._custom;\n return {\n label: labels[index] || '',\n value: '(' + x + ', ' + y + (r ? ', ' + r : '') + ')'\n };\n }\n update(mode) {\n const points = this._cachedMeta.data;\n this.updateElements(points, 0, points.length, mode);\n }\n updateElements(points, start, count, mode) {\n const reset = mode === 'reset';\n const {\n iScale,\n vScale\n } = this._cachedMeta;\n const {\n sharedOptions,\n includeOptions\n } = this._getSharedOptions(start, mode);\n const iAxis = iScale.axis;\n const vAxis = vScale.axis;\n for (let i = start; i < start + count; i++) {\n const point = points[i];\n const parsed = !reset && this.getParsed(i);\n const properties = {};\n const iPixel = properties[iAxis] = reset ? iScale.getPixelForDecimal(0.5) : iScale.getPixelForValue(parsed[iAxis]);\n const vPixel = properties[vAxis] = reset ? vScale.getBasePixel() : vScale.getPixelForValue(parsed[vAxis]);\n properties.skip = isNaN(iPixel) || isNaN(vPixel);\n if (includeOptions) {\n properties.options = sharedOptions || this.resolveDataElementOptions(i, point.active ? 'active' : mode);\n if (reset) {\n properties.options.radius = 0;\n }\n }\n this.updateElement(point, i, properties, mode);\n }\n }\n resolveDataElementOptions(index, mode) {\n const parsed = this.getParsed(index);\n let values = super.resolveDataElementOptions(index, mode);\n if (values.$shared) {\n values = Object.assign({}, values, {\n $shared: false\n });\n }\n const radius = values.radius;\n if (mode !== 'active') {\n values.radius = 0;\n }\n values.radius += valueOrDefault(parsed && parsed._custom, radius);\n return values;\n }\n }\n return BubbleController;\n})();\nfunction getRatioAndOffset(rotation, circumference, cutout) {\n let ratioX = 1;\n let ratioY = 1;\n let offsetX = 0;\n let offsetY = 0;\n if (circumference < TAU) {\n const startAngle = rotation;\n const endAngle = startAngle + circumference;\n const startX = Math.cos(startAngle);\n const startY = Math.sin(startAngle);\n const endX = Math.cos(endAngle);\n const endY = Math.sin(endAngle);\n const calcMax = (angle, a, b) => _angleBetween(angle, startAngle, endAngle, true) ? 1 : Math.max(a, a * cutout, b, b * cutout);\n const calcMin = (angle, a, b) => _angleBetween(angle, startAngle, endAngle, true) ? -1 : Math.min(a, a * cutout, b, b * cutout);\n const maxX = calcMax(0, startX, endX);\n const maxY = calcMax(HALF_PI, startY, endY);\n const minX = calcMin(PI, startX, endX);\n const minY = calcMin(PI + HALF_PI, startY, endY);\n ratioX = (maxX - minX) / 2;\n ratioY = (maxY - minY) / 2;\n offsetX = -(maxX + minX) / 2;\n offsetY = -(maxY + minY) / 2;\n }\n return {\n ratioX,\n ratioY,\n offsetX,\n offsetY\n };\n}\nlet DoughnutController = /*#__PURE__*/(() => {\n class DoughnutController extends DatasetController {\n static id = 'doughnut';\n static defaults = {\n datasetElementType: false,\n dataElementType: 'arc',\n animation: {\n animateRotate: true,\n animateScale: false\n },\n animations: {\n numbers: {\n type: 'number',\n properties: ['circumference', 'endAngle', 'innerRadius', 'outerRadius', 'startAngle', 'x', 'y', 'offset', 'borderWidth', 'spacing']\n }\n },\n cutout: '50%',\n rotation: 0,\n circumference: 360,\n radius: '100%',\n spacing: 0,\n indexAxis: 'r'\n };\n static descriptors = {\n _scriptable: name => name !== 'spacing',\n _indexable: name => name !== 'spacing' && !name.startsWith('borderDash') && !name.startsWith('hoverBorderDash')\n };\n static overrides = {\n aspectRatio: 1,\n plugins: {\n legend: {\n labels: {\n generateLabels(chart) {\n const data = chart.data;\n if (data.labels.length && data.datasets.length) {\n const {\n labels: {\n pointStyle,\n color\n }\n } = chart.legend.options;\n return data.labels.map((label, i) => {\n const meta = chart.getDatasetMeta(0);\n const style = meta.controller.getStyle(i);\n return {\n text: label,\n fillStyle: style.backgroundColor,\n strokeStyle: style.borderColor,\n fontColor: color,\n lineWidth: style.borderWidth,\n pointStyle: pointStyle,\n hidden: !chart.getDataVisibility(i),\n index: i\n };\n });\n }\n return [];\n }\n },\n onClick(e, legendItem, legend) {\n legend.chart.toggleDataVisibility(legendItem.index);\n legend.chart.update();\n }\n }\n }\n };\n constructor(chart, datasetIndex) {\n super(chart, datasetIndex);\n this.enableOptionSharing = true;\n this.innerRadius = undefined;\n this.outerRadius = undefined;\n this.offsetX = undefined;\n this.offsetY = undefined;\n }\n linkScales() {}\n parse(start, count) {\n const data = this.getDataset().data;\n const meta = this._cachedMeta;\n if (this._parsing === false) {\n meta._parsed = data;\n } else {\n let getter = i => +data[i];\n if (isObject(data[start])) {\n const {\n key = 'value'\n } = this._parsing;\n getter = i => +resolveObjectKey(data[i], key);\n }\n let i, ilen;\n for (i = start, ilen = start + count; i < ilen; ++i) {\n meta._parsed[i] = getter(i);\n }\n }\n }\n _getRotation() {\n return toRadians(this.options.rotation - 90);\n }\n _getCircumference() {\n return toRadians(this.options.circumference);\n }\n _getRotationExtents() {\n let min = TAU;\n let max = -TAU;\n for (let i = 0; i < this.chart.data.datasets.length; ++i) {\n if (this.chart.isDatasetVisible(i) && this.chart.getDatasetMeta(i).type === this._type) {\n const controller = this.chart.getDatasetMeta(i).controller;\n const rotation = controller._getRotation();\n const circumference = controller._getCircumference();\n min = Math.min(min, rotation);\n max = Math.max(max, rotation + circumference);\n }\n }\n return {\n rotation: min,\n circumference: max - min\n };\n }\n update(mode) {\n const chart = this.chart;\n const {\n chartArea\n } = chart;\n const meta = this._cachedMeta;\n const arcs = meta.data;\n const spacing = this.getMaxBorderWidth() + this.getMaxOffset(arcs) + this.options.spacing;\n const maxSize = Math.max((Math.min(chartArea.width, chartArea.height) - spacing) / 2, 0);\n const cutout = Math.min(toPercentage(this.options.cutout, maxSize), 1);\n const chartWeight = this._getRingWeight(this.index);\n const {\n circumference,\n rotation\n } = this._getRotationExtents();\n const {\n ratioX,\n ratioY,\n offsetX,\n offsetY\n } = getRatioAndOffset(rotation, circumference, cutout);\n const maxWidth = (chartArea.width - spacing) / ratioX;\n const maxHeight = (chartArea.height - spacing) / ratioY;\n const maxRadius = Math.max(Math.min(maxWidth, maxHeight) / 2, 0);\n const outerRadius = toDimension(this.options.radius, maxRadius);\n const innerRadius = Math.max(outerRadius * cutout, 0);\n const radiusLength = (outerRadius - innerRadius) / this._getVisibleDatasetWeightTotal();\n this.offsetX = offsetX * outerRadius;\n this.offsetY = offsetY * outerRadius;\n meta.total = this.calculateTotal();\n this.outerRadius = outerRadius - radiusLength * this._getRingWeightOffset(this.index);\n this.innerRadius = Math.max(this.outerRadius - radiusLength * chartWeight, 0);\n this.updateElements(arcs, 0, arcs.length, mode);\n }\n _circumference(i, reset) {\n const opts = this.options;\n const meta = this._cachedMeta;\n const circumference = this._getCircumference();\n if (reset && opts.animation.animateRotate || !this.chart.getDataVisibility(i) || meta._parsed[i] === null || meta.data[i].hidden) {\n return 0;\n }\n return this.calculateCircumference(meta._parsed[i] * circumference / TAU);\n }\n updateElements(arcs, start, count, mode) {\n const reset = mode === 'reset';\n const chart = this.chart;\n const chartArea = chart.chartArea;\n const opts = chart.options;\n const animationOpts = opts.animation;\n const centerX = (chartArea.left + chartArea.right) / 2;\n const centerY = (chartArea.top + chartArea.bottom) / 2;\n const animateScale = reset && animationOpts.animateScale;\n const innerRadius = animateScale ? 0 : this.innerRadius;\n const outerRadius = animateScale ? 0 : this.outerRadius;\n const {\n sharedOptions,\n includeOptions\n } = this._getSharedOptions(start, mode);\n let startAngle = this._getRotation();\n let i;\n for (i = 0; i < start; ++i) {\n startAngle += this._circumference(i, reset);\n }\n for (i = start; i < start + count; ++i) {\n const circumference = this._circumference(i, reset);\n const arc = arcs[i];\n const properties = {\n x: centerX + this.offsetX,\n y: centerY + this.offsetY,\n startAngle,\n endAngle: startAngle + circumference,\n circumference,\n outerRadius,\n innerRadius\n };\n if (includeOptions) {\n properties.options = sharedOptions || this.resolveDataElementOptions(i, arc.active ? 'active' : mode);\n }\n startAngle += circumference;\n this.updateElement(arc, i, properties, mode);\n }\n }\n calculateTotal() {\n const meta = this._cachedMeta;\n const metaData = meta.data;\n let total = 0;\n let i;\n for (i = 0; i < metaData.length; i++) {\n const value = meta._parsed[i];\n if (value !== null && !isNaN(value) && this.chart.getDataVisibility(i) && !metaData[i].hidden) {\n total += Math.abs(value);\n }\n }\n return total;\n }\n calculateCircumference(value) {\n const total = this._cachedMeta.total;\n if (total > 0 && !isNaN(value)) {\n return TAU * (Math.abs(value) / total);\n }\n return 0;\n }\n getLabelAndValue(index) {\n const meta = this._cachedMeta;\n const chart = this.chart;\n const labels = chart.data.labels || [];\n const value = formatNumber(meta._parsed[index], chart.options.locale);\n return {\n label: labels[index] || '',\n value\n };\n }\n getMaxBorderWidth(arcs) {\n let max = 0;\n const chart = this.chart;\n let i, ilen, meta, controller, options;\n if (!arcs) {\n for (i = 0, ilen = chart.data.datasets.length; i < ilen; ++i) {\n if (chart.isDatasetVisible(i)) {\n meta = chart.getDatasetMeta(i);\n arcs = meta.data;\n controller = meta.controller;\n break;\n }\n }\n }\n if (!arcs) {\n return 0;\n }\n for (i = 0, ilen = arcs.length; i < ilen; ++i) {\n options = controller.resolveDataElementOptions(i);\n if (options.borderAlign !== 'inner') {\n max = Math.max(max, options.borderWidth || 0, options.hoverBorderWidth || 0);\n }\n }\n return max;\n }\n getMaxOffset(arcs) {\n let max = 0;\n for (let i = 0, ilen = arcs.length; i < ilen; ++i) {\n const options = this.resolveDataElementOptions(i);\n max = Math.max(max, options.offset || 0, options.hoverOffset || 0);\n }\n return max;\n }\n _getRingWeightOffset(datasetIndex) {\n let ringWeightOffset = 0;\n for (let i = 0; i < datasetIndex; ++i) {\n if (this.chart.isDatasetVisible(i)) {\n ringWeightOffset += this._getRingWeight(i);\n }\n }\n return ringWeightOffset;\n }\n _getRingWeight(datasetIndex) {\n return Math.max(valueOrDefault(this.chart.data.datasets[datasetIndex].weight, 1), 0);\n }\n _getVisibleDatasetWeightTotal() {\n return this._getRingWeightOffset(this.chart.data.datasets.length) || 1;\n }\n }\n return DoughnutController;\n})();\nlet LineController = /*#__PURE__*/(() => {\n class LineController extends DatasetController {\n static id = 'line';\n static defaults = {\n datasetElementType: 'line',\n dataElementType: 'point',\n showLine: true,\n spanGaps: false\n };\n static overrides = {\n scales: {\n _index_: {\n type: 'category'\n },\n _value_: {\n type: 'linear'\n }\n }\n };\n initialize() {\n this.enableOptionSharing = true;\n this.supportsDecimation = true;\n super.initialize();\n }\n update(mode) {\n const meta = this._cachedMeta;\n const {\n dataset: line,\n data: points = [],\n _dataset\n } = meta;\n const animationsDisabled = this.chart._animationsDisabled;\n let {\n start,\n count\n } = _getStartAndCountOfVisiblePoints(meta, points, animationsDisabled);\n this._drawStart = start;\n this._drawCount = count;\n if (_scaleRangesChanged(meta)) {\n start = 0;\n count = points.length;\n }\n line._chart = this.chart;\n line._datasetIndex = this.index;\n line._decimated = !!_dataset._decimated;\n line.points = points;\n const options = this.resolveDatasetElementOptions(mode);\n if (!this.options.showLine) {\n options.borderWidth = 0;\n }\n options.segment = this.options.segment;\n this.updateElement(line, undefined, {\n animated: !animationsDisabled,\n options\n }, mode);\n this.updateElements(points, start, count, mode);\n }\n updateElements(points, start, count, mode) {\n const reset = mode === 'reset';\n const {\n iScale,\n vScale,\n _stacked,\n _dataset\n } = this._cachedMeta;\n const {\n sharedOptions,\n includeOptions\n } = this._getSharedOptions(start, mode);\n const iAxis = iScale.axis;\n const vAxis = vScale.axis;\n const {\n spanGaps,\n segment\n } = this.options;\n const maxGapLength = isNumber(spanGaps) ? spanGaps : Number.POSITIVE_INFINITY;\n const directUpdate = this.chart._animationsDisabled || reset || mode === 'none';\n const end = start + count;\n const pointsCount = points.length;\n let prevParsed = start > 0 && this.getParsed(start - 1);\n for (let i = 0; i < pointsCount; ++i) {\n const point = points[i];\n const properties = directUpdate ? point : {};\n if (i < start || i >= end) {\n properties.skip = true;\n continue;\n }\n const parsed = this.getParsed(i);\n const nullData = isNullOrUndef(parsed[vAxis]);\n const iPixel = properties[iAxis] = iScale.getPixelForValue(parsed[iAxis], i);\n const vPixel = properties[vAxis] = reset || nullData ? vScale.getBasePixel() : vScale.getPixelForValue(_stacked ? this.applyStack(vScale, parsed, _stacked) : parsed[vAxis], i);\n properties.skip = isNaN(iPixel) || isNaN(vPixel) || nullData;\n properties.stop = i > 0 && Math.abs(parsed[iAxis] - prevParsed[iAxis]) > maxGapLength;\n if (segment) {\n properties.parsed = parsed;\n properties.raw = _dataset.data[i];\n }\n if (includeOptions) {\n properties.options = sharedOptions || this.resolveDataElementOptions(i, point.active ? 'active' : mode);\n }\n if (!directUpdate) {\n this.updateElement(point, i, properties, mode);\n }\n prevParsed = parsed;\n }\n }\n getMaxOverflow() {\n const meta = this._cachedMeta;\n const dataset = meta.dataset;\n const border = dataset.options && dataset.options.borderWidth || 0;\n const data = meta.data || [];\n if (!data.length) {\n return border;\n }\n const firstPoint = data[0].size(this.resolveDataElementOptions(0));\n const lastPoint = data[data.length - 1].size(this.resolveDataElementOptions(data.length - 1));\n return Math.max(border, firstPoint, lastPoint) / 2;\n }\n draw() {\n const meta = this._cachedMeta;\n meta.dataset.updateControlPoints(this.chart.chartArea, meta.iScale.axis);\n super.draw();\n }\n }\n return LineController;\n})();\nlet PolarAreaController = /*#__PURE__*/(() => {\n class PolarAreaController extends DatasetController {\n static id = 'polarArea';\n static defaults = {\n dataElementType: 'arc',\n animation: {\n animateRotate: true,\n animateScale: true\n },\n animations: {\n numbers: {\n type: 'number',\n properties: ['x', 'y', 'startAngle', 'endAngle', 'innerRadius', 'outerRadius']\n }\n },\n indexAxis: 'r',\n startAngle: 0\n };\n static overrides = {\n aspectRatio: 1,\n plugins: {\n legend: {\n labels: {\n generateLabels(chart) {\n const data = chart.data;\n if (data.labels.length && data.datasets.length) {\n const {\n labels: {\n pointStyle,\n color\n }\n } = chart.legend.options;\n return data.labels.map((label, i) => {\n const meta = chart.getDatasetMeta(0);\n const style = meta.controller.getStyle(i);\n return {\n text: label,\n fillStyle: style.backgroundColor,\n strokeStyle: style.borderColor,\n fontColor: color,\n lineWidth: style.borderWidth,\n pointStyle: pointStyle,\n hidden: !chart.getDataVisibility(i),\n index: i\n };\n });\n }\n return [];\n }\n },\n onClick(e, legendItem, legend) {\n legend.chart.toggleDataVisibility(legendItem.index);\n legend.chart.update();\n }\n }\n },\n scales: {\n r: {\n type: 'radialLinear',\n angleLines: {\n display: false\n },\n beginAtZero: true,\n grid: {\n circular: true\n },\n pointLabels: {\n display: false\n },\n startAngle: 0\n }\n }\n };\n constructor(chart, datasetIndex) {\n super(chart, datasetIndex);\n this.innerRadius = undefined;\n this.outerRadius = undefined;\n }\n getLabelAndValue(index) {\n const meta = this._cachedMeta;\n const chart = this.chart;\n const labels = chart.data.labels || [];\n const value = formatNumber(meta._parsed[index].r, chart.options.locale);\n return {\n label: labels[index] || '',\n value\n };\n }\n parseObjectData(meta, data, start, count) {\n return _parseObjectDataRadialScale.bind(this)(meta, data, start, count);\n }\n update(mode) {\n const arcs = this._cachedMeta.data;\n this._updateRadius();\n this.updateElements(arcs, 0, arcs.length, mode);\n }\n getMinMax() {\n const meta = this._cachedMeta;\n const range = {\n min: Number.POSITIVE_INFINITY,\n max: Number.NEGATIVE_INFINITY\n };\n meta.data.forEach((element, index) => {\n const parsed = this.getParsed(index).r;\n if (!isNaN(parsed) && this.chart.getDataVisibility(index)) {\n if (parsed < range.min) {\n range.min = parsed;\n }\n if (parsed > range.max) {\n range.max = parsed;\n }\n }\n });\n return range;\n }\n _updateRadius() {\n const chart = this.chart;\n const chartArea = chart.chartArea;\n const opts = chart.options;\n const minSize = Math.min(chartArea.right - chartArea.left, chartArea.bottom - chartArea.top);\n const outerRadius = Math.max(minSize / 2, 0);\n const innerRadius = Math.max(opts.cutoutPercentage ? outerRadius / 100 * opts.cutoutPercentage : 1, 0);\n const radiusLength = (outerRadius - innerRadius) / chart.getVisibleDatasetCount();\n this.outerRadius = outerRadius - radiusLength * this.index;\n this.innerRadius = this.outerRadius - radiusLength;\n }\n updateElements(arcs, start, count, mode) {\n const reset = mode === 'reset';\n const chart = this.chart;\n const opts = chart.options;\n const animationOpts = opts.animation;\n const scale = this._cachedMeta.rScale;\n const centerX = scale.xCenter;\n const centerY = scale.yCenter;\n const datasetStartAngle = scale.getIndexAngle(0) - 0.5 * PI;\n let angle = datasetStartAngle;\n let i;\n const defaultAngle = 360 / this.countVisibleElements();\n for (i = 0; i < start; ++i) {\n angle += this._computeAngle(i, mode, defaultAngle);\n }\n for (i = start; i < start + count; i++) {\n const arc = arcs[i];\n let startAngle = angle;\n let endAngle = angle + this._computeAngle(i, mode, defaultAngle);\n let outerRadius = chart.getDataVisibility(i) ? scale.getDistanceFromCenterForValue(this.getParsed(i).r) : 0;\n angle = endAngle;\n if (reset) {\n if (animationOpts.animateScale) {\n outerRadius = 0;\n }\n if (animationOpts.animateRotate) {\n startAngle = endAngle = datasetStartAngle;\n }\n }\n const properties = {\n x: centerX,\n y: centerY,\n innerRadius: 0,\n outerRadius,\n startAngle,\n endAngle,\n options: this.resolveDataElementOptions(i, arc.active ? 'active' : mode)\n };\n this.updateElement(arc, i, properties, mode);\n }\n }\n countVisibleElements() {\n const meta = this._cachedMeta;\n let count = 0;\n meta.data.forEach((element, index) => {\n if (!isNaN(this.getParsed(index).r) && this.chart.getDataVisibility(index)) {\n count++;\n }\n });\n return count;\n }\n _computeAngle(index, mode, defaultAngle) {\n return this.chart.getDataVisibility(index) ? toRadians(this.resolveDataElementOptions(index, mode).angle || defaultAngle) : 0;\n }\n }\n return PolarAreaController;\n})();\nlet PieController = /*#__PURE__*/(() => {\n class PieController extends DoughnutController {\n static id = 'pie';\n static defaults = {\n cutout: 0,\n rotation: 0,\n circumference: 360,\n radius: '100%'\n };\n }\n return PieController;\n})();\nlet RadarController = /*#__PURE__*/(() => {\n class RadarController extends DatasetController {\n static id = 'radar';\n static defaults = {\n datasetElementType: 'line',\n dataElementType: 'point',\n indexAxis: 'r',\n showLine: true,\n elements: {\n line: {\n fill: 'start'\n }\n }\n };\n static overrides = {\n aspectRatio: 1,\n scales: {\n r: {\n type: 'radialLinear'\n }\n }\n };\n getLabelAndValue(index) {\n const vScale = this._cachedMeta.vScale;\n const parsed = this.getParsed(index);\n return {\n label: vScale.getLabels()[index],\n value: '' + vScale.getLabelForValue(parsed[vScale.axis])\n };\n }\n parseObjectData(meta, data, start, count) {\n return _parseObjectDataRadialScale.bind(this)(meta, data, start, count);\n }\n update(mode) {\n const meta = this._cachedMeta;\n const line = meta.dataset;\n const points = meta.data || [];\n const labels = meta.iScale.getLabels();\n line.points = points;\n if (mode !== 'resize') {\n const options = this.resolveDatasetElementOptions(mode);\n if (!this.options.showLine) {\n options.borderWidth = 0;\n }\n const properties = {\n _loop: true,\n _fullLoop: labels.length === points.length,\n options\n };\n this.updateElement(line, undefined, properties, mode);\n }\n this.updateElements(points, 0, points.length, mode);\n }\n updateElements(points, start, count, mode) {\n const scale = this._cachedMeta.rScale;\n const reset = mode === 'reset';\n for (let i = start; i < start + count; i++) {\n const point = points[i];\n const options = this.resolveDataElementOptions(i, point.active ? 'active' : mode);\n const pointPosition = scale.getPointPositionForValue(i, this.getParsed(i).r);\n const x = reset ? scale.xCenter : pointPosition.x;\n const y = reset ? scale.yCenter : pointPosition.y;\n const properties = {\n x,\n y,\n angle: pointPosition.angle,\n skip: isNaN(x) || isNaN(y),\n options\n };\n this.updateElement(point, i, properties, mode);\n }\n }\n }\n return RadarController;\n})();\nlet ScatterController = /*#__PURE__*/(() => {\n class ScatterController extends DatasetController {\n static id = 'scatter';\n static defaults = {\n datasetElementType: false,\n dataElementType: 'point',\n showLine: false,\n fill: false\n };\n static overrides = {\n interaction: {\n mode: 'point'\n },\n scales: {\n x: {\n type: 'linear'\n },\n y: {\n type: 'linear'\n }\n }\n };\n getLabelAndValue(index) {\n const meta = this._cachedMeta;\n const labels = this.chart.data.labels || [];\n const {\n xScale,\n yScale\n } = meta;\n const parsed = this.getParsed(index);\n const x = xScale.getLabelForValue(parsed.x);\n const y = yScale.getLabelForValue(parsed.y);\n return {\n label: labels[index] || '',\n value: '(' + x + ', ' + y + ')'\n };\n }\n update(mode) {\n const meta = this._cachedMeta;\n const {\n data: points = []\n } = meta;\n const animationsDisabled = this.chart._animationsDisabled;\n let {\n start,\n count\n } = _getStartAndCountOfVisiblePoints(meta, points, animationsDisabled);\n this._drawStart = start;\n this._drawCount = count;\n if (_scaleRangesChanged(meta)) {\n start = 0;\n count = points.length;\n }\n if (this.options.showLine) {\n if (!this.datasetElementType) {\n this.addElements();\n }\n const {\n dataset: line,\n _dataset\n } = meta;\n line._chart = this.chart;\n line._datasetIndex = this.index;\n line._decimated = !!_dataset._decimated;\n line.points = points;\n const options = this.resolveDatasetElementOptions(mode);\n options.segment = this.options.segment;\n this.updateElement(line, undefined, {\n animated: !animationsDisabled,\n options\n }, mode);\n } else if (this.datasetElementType) {\n delete meta.dataset;\n this.datasetElementType = false;\n }\n this.updateElements(points, start, count, mode);\n }\n addElements() {\n const {\n showLine\n } = this.options;\n if (!this.datasetElementType && showLine) {\n this.datasetElementType = this.chart.registry.getElement('line');\n }\n super.addElements();\n }\n updateElements(points, start, count, mode) {\n const reset = mode === 'reset';\n const {\n iScale,\n vScale,\n _stacked,\n _dataset\n } = this._cachedMeta;\n const firstOpts = this.resolveDataElementOptions(start, mode);\n const sharedOptions = this.getSharedOptions(firstOpts);\n const includeOptions = this.includeOptions(mode, sharedOptions);\n const iAxis = iScale.axis;\n const vAxis = vScale.axis;\n const {\n spanGaps,\n segment\n } = this.options;\n const maxGapLength = isNumber(spanGaps) ? spanGaps : Number.POSITIVE_INFINITY;\n const directUpdate = this.chart._animationsDisabled || reset || mode === 'none';\n let prevParsed = start > 0 && this.getParsed(start - 1);\n for (let i = start; i < start + count; ++i) {\n const point = points[i];\n const parsed = this.getParsed(i);\n const properties = directUpdate ? point : {};\n const nullData = isNullOrUndef(parsed[vAxis]);\n const iPixel = properties[iAxis] = iScale.getPixelForValue(parsed[iAxis], i);\n const vPixel = properties[vAxis] = reset || nullData ? vScale.getBasePixel() : vScale.getPixelForValue(_stacked ? this.applyStack(vScale, parsed, _stacked) : parsed[vAxis], i);\n properties.skip = isNaN(iPixel) || isNaN(vPixel) || nullData;\n properties.stop = i > 0 && Math.abs(parsed[iAxis] - prevParsed[iAxis]) > maxGapLength;\n if (segment) {\n properties.parsed = parsed;\n properties.raw = _dataset.data[i];\n }\n if (includeOptions) {\n properties.options = sharedOptions || this.resolveDataElementOptions(i, point.active ? 'active' : mode);\n }\n if (!directUpdate) {\n this.updateElement(point, i, properties, mode);\n }\n prevParsed = parsed;\n }\n this.updateSharedOptions(sharedOptions, mode, firstOpts);\n }\n getMaxOverflow() {\n const meta = this._cachedMeta;\n const data = meta.data || [];\n if (!this.options.showLine) {\n let max = 0;\n for (let i = data.length - 1; i >= 0; --i) {\n max = Math.max(max, data[i].size(this.resolveDataElementOptions(i)) / 2);\n }\n return max > 0 && max;\n }\n const dataset = meta.dataset;\n const border = dataset.options && dataset.options.borderWidth || 0;\n if (!data.length) {\n return border;\n }\n const firstPoint = data[0].size(this.resolveDataElementOptions(0));\n const lastPoint = data[data.length - 1].size(this.resolveDataElementOptions(data.length - 1));\n return Math.max(border, firstPoint, lastPoint) / 2;\n }\n }\n return ScatterController;\n})();\nvar controllers = /*#__PURE__*/Object.freeze({\n __proto__: null,\n BarController: BarController,\n BubbleController: BubbleController,\n DoughnutController: DoughnutController,\n LineController: LineController,\n PieController: PieController,\n PolarAreaController: PolarAreaController,\n RadarController: RadarController,\n ScatterController: ScatterController\n});\n\n/**\n * @namespace Chart._adapters\n * @since 2.8.0\n * @private\n */\nfunction abstract() {\n throw new Error('This method is not implemented: Check that a complete date adapter is provided.');\n}\n/**\n * Date adapter (current used by the time scale)\n * @namespace Chart._adapters._date\n * @memberof Chart._adapters\n * @private\n */\nclass DateAdapterBase {\n /**\n * Override default date adapter methods.\n * Accepts type parameter to define options type.\n * @example\n * Chart._adapters._date.override<{myAdapterOption: string}>({\n * init() {\n * console.log(this.options.myAdapterOption);\n * }\n * })\n */\n static override(members) {\n Object.assign(DateAdapterBase.prototype, members);\n }\n options;\n constructor(options) {\n this.options = options || {};\n }\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n init() {}\n formats() {\n return abstract();\n }\n parse() {\n return abstract();\n }\n format() {\n return abstract();\n }\n add() {\n return abstract();\n }\n diff() {\n return abstract();\n }\n startOf() {\n return abstract();\n }\n endOf() {\n return abstract();\n }\n}\nvar adapters = {\n _date: DateAdapterBase\n};\nfunction binarySearch(metaset, axis, value, intersect) {\n const {\n controller,\n data,\n _sorted\n } = metaset;\n const iScale = controller._cachedMeta.iScale;\n if (iScale && axis === iScale.axis && axis !== 'r' && _sorted && data.length) {\n const lookupMethod = iScale._reversePixels ? _rlookupByKey : _lookupByKey;\n if (!intersect) {\n return lookupMethod(data, axis, value);\n } else if (controller._sharedOptions) {\n const el = data[0];\n const range = typeof el.getRange === 'function' && el.getRange(axis);\n if (range) {\n const start = lookupMethod(data, axis, value - range);\n const end = lookupMethod(data, axis, value + range);\n return {\n lo: start.lo,\n hi: end.hi\n };\n }\n }\n }\n return {\n lo: 0,\n hi: data.length - 1\n };\n}\nfunction evaluateInteractionItems(chart, axis, position, handler, intersect) {\n const metasets = chart.getSortedVisibleDatasetMetas();\n const value = position[axis];\n for (let i = 0, ilen = metasets.length; i < ilen; ++i) {\n const {\n index,\n data\n } = metasets[i];\n const {\n lo,\n hi\n } = binarySearch(metasets[i], axis, value, intersect);\n for (let j = lo; j <= hi; ++j) {\n const element = data[j];\n if (!element.skip) {\n handler(element, index, j);\n }\n }\n }\n}\nfunction getDistanceMetricForAxis(axis) {\n const useX = axis.indexOf('x') !== -1;\n const useY = axis.indexOf('y') !== -1;\n return function (pt1, pt2) {\n const deltaX = useX ? Math.abs(pt1.x - pt2.x) : 0;\n const deltaY = useY ? Math.abs(pt1.y - pt2.y) : 0;\n return Math.sqrt(Math.pow(deltaX, 2) + Math.pow(deltaY, 2));\n };\n}\nfunction getIntersectItems(chart, position, axis, useFinalPosition, includeInvisible) {\n const items = [];\n if (!includeInvisible && !chart.isPointInArea(position)) {\n return items;\n }\n const evaluationFunc = function (element, datasetIndex, index) {\n if (!includeInvisible && !_isPointInArea(element, chart.chartArea, 0)) {\n return;\n }\n if (element.inRange(position.x, position.y, useFinalPosition)) {\n items.push({\n element,\n datasetIndex,\n index\n });\n }\n };\n evaluateInteractionItems(chart, axis, position, evaluationFunc, true);\n return items;\n}\nfunction getNearestRadialItems(chart, position, axis, useFinalPosition) {\n let items = [];\n function evaluationFunc(element, datasetIndex, index) {\n const {\n startAngle,\n endAngle\n } = element.getProps(['startAngle', 'endAngle'], useFinalPosition);\n const {\n angle\n } = getAngleFromPoint(element, {\n x: position.x,\n y: position.y\n });\n if (_angleBetween(angle, startAngle, endAngle)) {\n items.push({\n element,\n datasetIndex,\n index\n });\n }\n }\n evaluateInteractionItems(chart, axis, position, evaluationFunc);\n return items;\n}\nfunction getNearestCartesianItems(chart, position, axis, intersect, useFinalPosition, includeInvisible) {\n let items = [];\n const distanceMetric = getDistanceMetricForAxis(axis);\n let minDistance = Number.POSITIVE_INFINITY;\n function evaluationFunc(element, datasetIndex, index) {\n const inRange = element.inRange(position.x, position.y, useFinalPosition);\n if (intersect && !inRange) {\n return;\n }\n const center = element.getCenterPoint(useFinalPosition);\n const pointInArea = !!includeInvisible || chart.isPointInArea(center);\n if (!pointInArea && !inRange) {\n return;\n }\n const distance = distanceMetric(position, center);\n if (distance < minDistance) {\n items = [{\n element,\n datasetIndex,\n index\n }];\n minDistance = distance;\n } else if (distance === minDistance) {\n items.push({\n element,\n datasetIndex,\n index\n });\n }\n }\n evaluateInteractionItems(chart, axis, position, evaluationFunc);\n return items;\n}\nfunction getNearestItems(chart, position, axis, intersect, useFinalPosition, includeInvisible) {\n if (!includeInvisible && !chart.isPointInArea(position)) {\n return [];\n }\n return axis === 'r' && !intersect ? getNearestRadialItems(chart, position, axis, useFinalPosition) : getNearestCartesianItems(chart, position, axis, intersect, useFinalPosition, includeInvisible);\n}\nfunction getAxisItems(chart, position, axis, intersect, useFinalPosition) {\n const items = [];\n const rangeMethod = axis === 'x' ? 'inXRange' : 'inYRange';\n let intersectsItem = false;\n evaluateInteractionItems(chart, axis, position, (element, datasetIndex, index) => {\n if (element[rangeMethod] && element[rangeMethod](position[axis], useFinalPosition)) {\n items.push({\n element,\n datasetIndex,\n index\n });\n intersectsItem = intersectsItem || element.inRange(position.x, position.y, useFinalPosition);\n }\n });\n if (intersect && !intersectsItem) {\n return [];\n }\n return items;\n}\nvar Interaction = {\n evaluateInteractionItems,\n modes: {\n index(chart, e, options, useFinalPosition) {\n const position = getRelativePosition(e, chart);\n const axis = options.axis || 'x';\n const includeInvisible = options.includeInvisible || false;\n const items = options.intersect ? getIntersectItems(chart, position, axis, useFinalPosition, includeInvisible) : getNearestItems(chart, position, axis, false, useFinalPosition, includeInvisible);\n const elements = [];\n if (!items.length) {\n return [];\n }\n chart.getSortedVisibleDatasetMetas().forEach(meta => {\n const index = items[0].index;\n const element = meta.data[index];\n if (element && !element.skip) {\n elements.push({\n element,\n datasetIndex: meta.index,\n index\n });\n }\n });\n return elements;\n },\n dataset(chart, e, options, useFinalPosition) {\n const position = getRelativePosition(e, chart);\n const axis = options.axis || 'xy';\n const includeInvisible = options.includeInvisible || false;\n let items = options.intersect ? getIntersectItems(chart, position, axis, useFinalPosition, includeInvisible) : getNearestItems(chart, position, axis, false, useFinalPosition, includeInvisible);\n if (items.length > 0) {\n const datasetIndex = items[0].datasetIndex;\n const data = chart.getDatasetMeta(datasetIndex).data;\n items = [];\n for (let i = 0; i < data.length; ++i) {\n items.push({\n element: data[i],\n datasetIndex,\n index: i\n });\n }\n }\n return items;\n },\n point(chart, e, options, useFinalPosition) {\n const position = getRelativePosition(e, chart);\n const axis = options.axis || 'xy';\n const includeInvisible = options.includeInvisible || false;\n return getIntersectItems(chart, position, axis, useFinalPosition, includeInvisible);\n },\n nearest(chart, e, options, useFinalPosition) {\n const position = getRelativePosition(e, chart);\n const axis = options.axis || 'xy';\n const includeInvisible = options.includeInvisible || false;\n return getNearestItems(chart, position, axis, options.intersect, useFinalPosition, includeInvisible);\n },\n x(chart, e, options, useFinalPosition) {\n const position = getRelativePosition(e, chart);\n return getAxisItems(chart, position, 'x', options.intersect, useFinalPosition);\n },\n y(chart, e, options, useFinalPosition) {\n const position = getRelativePosition(e, chart);\n return getAxisItems(chart, position, 'y', options.intersect, useFinalPosition);\n }\n }\n};\nconst STATIC_POSITIONS = ['left', 'top', 'right', 'bottom'];\nfunction filterByPosition(array, position) {\n return array.filter(v => v.pos === position);\n}\nfunction filterDynamicPositionByAxis(array, axis) {\n return array.filter(v => STATIC_POSITIONS.indexOf(v.pos) === -1 && v.box.axis === axis);\n}\nfunction sortByWeight(array, reverse) {\n return array.sort((a, b) => {\n const v0 = reverse ? b : a;\n const v1 = reverse ? a : b;\n return v0.weight === v1.weight ? v0.index - v1.index : v0.weight - v1.weight;\n });\n}\nfunction wrapBoxes(boxes) {\n const layoutBoxes = [];\n let i, ilen, box, pos, stack, stackWeight;\n for (i = 0, ilen = (boxes || []).length; i < ilen; ++i) {\n box = boxes[i];\n ({\n position: pos,\n options: {\n stack,\n stackWeight = 1\n }\n } = box);\n layoutBoxes.push({\n index: i,\n box,\n pos,\n horizontal: box.isHorizontal(),\n weight: box.weight,\n stack: stack && pos + stack,\n stackWeight\n });\n }\n return layoutBoxes;\n}\nfunction buildStacks(layouts) {\n const stacks = {};\n for (const wrap of layouts) {\n const {\n stack,\n pos,\n stackWeight\n } = wrap;\n if (!stack || !STATIC_POSITIONS.includes(pos)) {\n continue;\n }\n const _stack = stacks[stack] || (stacks[stack] = {\n count: 0,\n placed: 0,\n weight: 0,\n size: 0\n });\n _stack.count++;\n _stack.weight += stackWeight;\n }\n return stacks;\n}\nfunction setLayoutDims(layouts, params) {\n const stacks = buildStacks(layouts);\n const {\n vBoxMaxWidth,\n hBoxMaxHeight\n } = params;\n let i, ilen, layout;\n for (i = 0, ilen = layouts.length; i < ilen; ++i) {\n layout = layouts[i];\n const {\n fullSize\n } = layout.box;\n const stack = stacks[layout.stack];\n const factor = stack && layout.stackWeight / stack.weight;\n if (layout.horizontal) {\n layout.width = factor ? factor * vBoxMaxWidth : fullSize && params.availableWidth;\n layout.height = hBoxMaxHeight;\n } else {\n layout.width = vBoxMaxWidth;\n layout.height = factor ? factor * hBoxMaxHeight : fullSize && params.availableHeight;\n }\n }\n return stacks;\n}\nfunction buildLayoutBoxes(boxes) {\n const layoutBoxes = wrapBoxes(boxes);\n const fullSize = sortByWeight(layoutBoxes.filter(wrap => wrap.box.fullSize), true);\n const left = sortByWeight(filterByPosition(layoutBoxes, 'left'), true);\n const right = sortByWeight(filterByPosition(layoutBoxes, 'right'));\n const top = sortByWeight(filterByPosition(layoutBoxes, 'top'), true);\n const bottom = sortByWeight(filterByPosition(layoutBoxes, 'bottom'));\n const centerHorizontal = filterDynamicPositionByAxis(layoutBoxes, 'x');\n const centerVertical = filterDynamicPositionByAxis(layoutBoxes, 'y');\n return {\n fullSize,\n leftAndTop: left.concat(top),\n rightAndBottom: right.concat(centerVertical).concat(bottom).concat(centerHorizontal),\n chartArea: filterByPosition(layoutBoxes, 'chartArea'),\n vertical: left.concat(right).concat(centerVertical),\n horizontal: top.concat(bottom).concat(centerHorizontal)\n };\n}\nfunction getCombinedMax(maxPadding, chartArea, a, b) {\n return Math.max(maxPadding[a], chartArea[a]) + Math.max(maxPadding[b], chartArea[b]);\n}\nfunction updateMaxPadding(maxPadding, boxPadding) {\n maxPadding.top = Math.max(maxPadding.top, boxPadding.top);\n maxPadding.left = Math.max(maxPadding.left, boxPadding.left);\n maxPadding.bottom = Math.max(maxPadding.bottom, boxPadding.bottom);\n maxPadding.right = Math.max(maxPadding.right, boxPadding.right);\n}\nfunction updateDims(chartArea, params, layout, stacks) {\n const {\n pos,\n box\n } = layout;\n const maxPadding = chartArea.maxPadding;\n if (!isObject(pos)) {\n if (layout.size) {\n chartArea[pos] -= layout.size;\n }\n const stack = stacks[layout.stack] || {\n size: 0,\n count: 1\n };\n stack.size = Math.max(stack.size, layout.horizontal ? box.height : box.width);\n layout.size = stack.size / stack.count;\n chartArea[pos] += layout.size;\n }\n if (box.getPadding) {\n updateMaxPadding(maxPadding, box.getPadding());\n }\n const newWidth = Math.max(0, params.outerWidth - getCombinedMax(maxPadding, chartArea, 'left', 'right'));\n const newHeight = Math.max(0, params.outerHeight - getCombinedMax(maxPadding, chartArea, 'top', 'bottom'));\n const widthChanged = newWidth !== chartArea.w;\n const heightChanged = newHeight !== chartArea.h;\n chartArea.w = newWidth;\n chartArea.h = newHeight;\n return layout.horizontal ? {\n same: widthChanged,\n other: heightChanged\n } : {\n same: heightChanged,\n other: widthChanged\n };\n}\nfunction handleMaxPadding(chartArea) {\n const maxPadding = chartArea.maxPadding;\n function updatePos(pos) {\n const change = Math.max(maxPadding[pos] - chartArea[pos], 0);\n chartArea[pos] += change;\n return change;\n }\n chartArea.y += updatePos('top');\n chartArea.x += updatePos('left');\n updatePos('right');\n updatePos('bottom');\n}\nfunction getMargins(horizontal, chartArea) {\n const maxPadding = chartArea.maxPadding;\n function marginForPositions(positions) {\n const margin = {\n left: 0,\n top: 0,\n right: 0,\n bottom: 0\n };\n positions.forEach(pos => {\n margin[pos] = Math.max(chartArea[pos], maxPadding[pos]);\n });\n return margin;\n }\n return horizontal ? marginForPositions(['left', 'right']) : marginForPositions(['top', 'bottom']);\n}\nfunction fitBoxes(boxes, chartArea, params, stacks) {\n const refitBoxes = [];\n let i, ilen, layout, box, refit, changed;\n for (i = 0, ilen = boxes.length, refit = 0; i < ilen; ++i) {\n layout = boxes[i];\n box = layout.box;\n box.update(layout.width || chartArea.w, layout.height || chartArea.h, getMargins(layout.horizontal, chartArea));\n const {\n same,\n other\n } = updateDims(chartArea, params, layout, stacks);\n refit |= same && refitBoxes.length;\n changed = changed || other;\n if (!box.fullSize) {\n refitBoxes.push(layout);\n }\n }\n return refit && fitBoxes(refitBoxes, chartArea, params, stacks) || changed;\n}\nfunction setBoxDims(box, left, top, width, height) {\n box.top = top;\n box.left = left;\n box.right = left + width;\n box.bottom = top + height;\n box.width = width;\n box.height = height;\n}\nfunction placeBoxes(boxes, chartArea, params, stacks) {\n const userPadding = params.padding;\n let {\n x,\n y\n } = chartArea;\n for (const layout of boxes) {\n const box = layout.box;\n const stack = stacks[layout.stack] || {\n count: 1,\n placed: 0,\n weight: 1\n };\n const weight = layout.stackWeight / stack.weight || 1;\n if (layout.horizontal) {\n const width = chartArea.w * weight;\n const height = stack.size || box.height;\n if (defined(stack.start)) {\n y = stack.start;\n }\n if (box.fullSize) {\n setBoxDims(box, userPadding.left, y, params.outerWidth - userPadding.right - userPadding.left, height);\n } else {\n setBoxDims(box, chartArea.left + stack.placed, y, width, height);\n }\n stack.start = y;\n stack.placed += width;\n y = box.bottom;\n } else {\n const height = chartArea.h * weight;\n const width = stack.size || box.width;\n if (defined(stack.start)) {\n x = stack.start;\n }\n if (box.fullSize) {\n setBoxDims(box, x, userPadding.top, width, params.outerHeight - userPadding.bottom - userPadding.top);\n } else {\n setBoxDims(box, x, chartArea.top + stack.placed, width, height);\n }\n stack.start = x;\n stack.placed += height;\n x = box.right;\n }\n }\n chartArea.x = x;\n chartArea.y = y;\n}\nvar layouts = {\n addBox(chart, item) {\n if (!chart.boxes) {\n chart.boxes = [];\n }\n item.fullSize = item.fullSize || false;\n item.position = item.position || 'top';\n item.weight = item.weight || 0;\n item._layers = item._layers || function () {\n return [{\n z: 0,\n draw(chartArea) {\n item.draw(chartArea);\n }\n }];\n };\n chart.boxes.push(item);\n },\n removeBox(chart, layoutItem) {\n const index = chart.boxes ? chart.boxes.indexOf(layoutItem) : -1;\n if (index !== -1) {\n chart.boxes.splice(index, 1);\n }\n },\n configure(chart, item, options) {\n item.fullSize = options.fullSize;\n item.position = options.position;\n item.weight = options.weight;\n },\n update(chart, width, height, minPadding) {\n if (!chart) {\n return;\n }\n const padding = toPadding(chart.options.layout.padding);\n const availableWidth = Math.max(width - padding.width, 0);\n const availableHeight = Math.max(height - padding.height, 0);\n const boxes = buildLayoutBoxes(chart.boxes);\n const verticalBoxes = boxes.vertical;\n const horizontalBoxes = boxes.horizontal;\n each(chart.boxes, box => {\n if (typeof box.beforeLayout === 'function') {\n box.beforeLayout();\n }\n });\n const visibleVerticalBoxCount = verticalBoxes.reduce((total, wrap) => wrap.box.options && wrap.box.options.display === false ? total : total + 1, 0) || 1;\n const params = Object.freeze({\n outerWidth: width,\n outerHeight: height,\n padding,\n availableWidth,\n availableHeight,\n vBoxMaxWidth: availableWidth / 2 / visibleVerticalBoxCount,\n hBoxMaxHeight: availableHeight / 2\n });\n const maxPadding = Object.assign({}, padding);\n updateMaxPadding(maxPadding, toPadding(minPadding));\n const chartArea = Object.assign({\n maxPadding,\n w: availableWidth,\n h: availableHeight,\n x: padding.left,\n y: padding.top\n }, padding);\n const stacks = setLayoutDims(verticalBoxes.concat(horizontalBoxes), params);\n fitBoxes(boxes.fullSize, chartArea, params, stacks);\n fitBoxes(verticalBoxes, chartArea, params, stacks);\n if (fitBoxes(horizontalBoxes, chartArea, params, stacks)) {\n fitBoxes(verticalBoxes, chartArea, params, stacks);\n }\n handleMaxPadding(chartArea);\n placeBoxes(boxes.leftAndTop, chartArea, params, stacks);\n chartArea.x += chartArea.w;\n chartArea.y += chartArea.h;\n placeBoxes(boxes.rightAndBottom, chartArea, params, stacks);\n chart.chartArea = {\n left: chartArea.left,\n top: chartArea.top,\n right: chartArea.left + chartArea.w,\n bottom: chartArea.top + chartArea.h,\n height: chartArea.h,\n width: chartArea.w\n };\n each(boxes.chartArea, layout => {\n const box = layout.box;\n Object.assign(box, chart.chartArea);\n box.update(chartArea.w, chartArea.h, {\n left: 0,\n top: 0,\n right: 0,\n bottom: 0\n });\n });\n }\n};\nclass BasePlatform {\n acquireContext(canvas, aspectRatio) {}\n releaseContext(context) {\n return false;\n }\n addEventListener(chart, type, listener) {}\n removeEventListener(chart, type, listener) {}\n getDevicePixelRatio() {\n return 1;\n }\n getMaximumSize(element, width, height, aspectRatio) {\n width = Math.max(0, width || element.width);\n height = height || element.height;\n return {\n width,\n height: Math.max(0, aspectRatio ? Math.floor(width / aspectRatio) : height)\n };\n }\n isAttached(canvas) {\n return true;\n }\n updateConfig(config) {}\n}\nclass BasicPlatform extends BasePlatform {\n acquireContext(item) {\n return item && item.getContext && item.getContext('2d') || null;\n }\n updateConfig(config) {\n config.options.animation = false;\n }\n}\nconst EXPANDO_KEY = '$chartjs';\nconst EVENT_TYPES = {\n touchstart: 'mousedown',\n touchmove: 'mousemove',\n touchend: 'mouseup',\n pointerenter: 'mouseenter',\n pointerdown: 'mousedown',\n pointermove: 'mousemove',\n pointerup: 'mouseup',\n pointerleave: 'mouseout',\n pointerout: 'mouseout'\n};\nconst isNullOrEmpty = value => value === null || value === '';\nfunction initCanvas(canvas, aspectRatio) {\n const style = canvas.style;\n const renderHeight = canvas.getAttribute('height');\n const renderWidth = canvas.getAttribute('width');\n canvas[EXPANDO_KEY] = {\n initial: {\n height: renderHeight,\n width: renderWidth,\n style: {\n display: style.display,\n height: style.height,\n width: style.width\n }\n }\n };\n style.display = style.display || 'block';\n style.boxSizing = style.boxSizing || 'border-box';\n if (isNullOrEmpty(renderWidth)) {\n const displayWidth = readUsedSize(canvas, 'width');\n if (displayWidth !== undefined) {\n canvas.width = displayWidth;\n }\n }\n if (isNullOrEmpty(renderHeight)) {\n if (canvas.style.height === '') {\n canvas.height = canvas.width / (aspectRatio || 2);\n } else {\n const displayHeight = readUsedSize(canvas, 'height');\n if (displayHeight !== undefined) {\n canvas.height = displayHeight;\n }\n }\n }\n return canvas;\n}\nconst eventListenerOptions = supportsEventListenerOptions ? {\n passive: true\n} : false;\nfunction addListener(node, type, listener) {\n if (node) {\n node.addEventListener(type, listener, eventListenerOptions);\n }\n}\nfunction removeListener(chart, type, listener) {\n if (chart && chart.canvas) {\n chart.canvas.removeEventListener(type, listener, eventListenerOptions);\n }\n}\nfunction fromNativeEvent(event, chart) {\n const type = EVENT_TYPES[event.type] || event.type;\n const {\n x,\n y\n } = getRelativePosition(event, chart);\n return {\n type,\n chart,\n native: event,\n x: x !== undefined ? x : null,\n y: y !== undefined ? y : null\n };\n}\nfunction nodeListContains(nodeList, canvas) {\n for (const node of nodeList) {\n if (node === canvas || node.contains(canvas)) {\n return true;\n }\n }\n}\nfunction createAttachObserver(chart, type, listener) {\n const canvas = chart.canvas;\n const observer = new MutationObserver(entries => {\n let trigger = false;\n for (const entry of entries) {\n trigger = trigger || nodeListContains(entry.addedNodes, canvas);\n trigger = trigger && !nodeListContains(entry.removedNodes, canvas);\n }\n if (trigger) {\n listener();\n }\n });\n observer.observe(document, {\n childList: true,\n subtree: true\n });\n return observer;\n}\nfunction createDetachObserver(chart, type, listener) {\n const canvas = chart.canvas;\n const observer = new MutationObserver(entries => {\n let trigger = false;\n for (const entry of entries) {\n trigger = trigger || nodeListContains(entry.removedNodes, canvas);\n trigger = trigger && !nodeListContains(entry.addedNodes, canvas);\n }\n if (trigger) {\n listener();\n }\n });\n observer.observe(document, {\n childList: true,\n subtree: true\n });\n return observer;\n}\nconst drpListeningCharts = new Map();\nlet oldDevicePixelRatio = 0;\nfunction onWindowResize() {\n const dpr = window.devicePixelRatio;\n if (dpr === oldDevicePixelRatio) {\n return;\n }\n oldDevicePixelRatio = dpr;\n drpListeningCharts.forEach((resize, chart) => {\n if (chart.currentDevicePixelRatio !== dpr) {\n resize();\n }\n });\n}\nfunction listenDevicePixelRatioChanges(chart, resize) {\n if (!drpListeningCharts.size) {\n window.addEventListener('resize', onWindowResize);\n }\n drpListeningCharts.set(chart, resize);\n}\nfunction unlistenDevicePixelRatioChanges(chart) {\n drpListeningCharts.delete(chart);\n if (!drpListeningCharts.size) {\n window.removeEventListener('resize', onWindowResize);\n }\n}\nfunction createResizeObserver(chart, type, listener) {\n const canvas = chart.canvas;\n const container = canvas && _getParentNode(canvas);\n if (!container) {\n return;\n }\n const resize = throttled((width, height) => {\n const w = container.clientWidth;\n listener(width, height);\n if (w < container.clientWidth) {\n listener();\n }\n }, window);\n const observer = new ResizeObserver(entries => {\n const entry = entries[0];\n const width = entry.contentRect.width;\n const height = entry.contentRect.height;\n if (width === 0 && height === 0) {\n return;\n }\n resize(width, height);\n });\n observer.observe(container);\n listenDevicePixelRatioChanges(chart, resize);\n return observer;\n}\nfunction releaseObserver(chart, type, observer) {\n if (observer) {\n observer.disconnect();\n }\n if (type === 'resize') {\n unlistenDevicePixelRatioChanges(chart);\n }\n}\nfunction createProxyAndListen(chart, type, listener) {\n const canvas = chart.canvas;\n const proxy = throttled(event => {\n if (chart.ctx !== null) {\n listener(fromNativeEvent(event, chart));\n }\n }, chart);\n addListener(canvas, type, proxy);\n return proxy;\n}\nclass DomPlatform extends BasePlatform {\n acquireContext(canvas, aspectRatio) {\n const context = canvas && canvas.getContext && canvas.getContext('2d');\n if (context && context.canvas === canvas) {\n initCanvas(canvas, aspectRatio);\n return context;\n }\n return null;\n }\n releaseContext(context) {\n const canvas = context.canvas;\n if (!canvas[EXPANDO_KEY]) {\n return false;\n }\n const initial = canvas[EXPANDO_KEY].initial;\n ['height', 'width'].forEach(prop => {\n const value = initial[prop];\n if (isNullOrUndef(value)) {\n canvas.removeAttribute(prop);\n } else {\n canvas.setAttribute(prop, value);\n }\n });\n const style = initial.style || {};\n Object.keys(style).forEach(key => {\n canvas.style[key] = style[key];\n });\n canvas.width = canvas.width;\n delete canvas[EXPANDO_KEY];\n return true;\n }\n addEventListener(chart, type, listener) {\n this.removeEventListener(chart, type);\n const proxies = chart.$proxies || (chart.$proxies = {});\n const handlers = {\n attach: createAttachObserver,\n detach: createDetachObserver,\n resize: createResizeObserver\n };\n const handler = handlers[type] || createProxyAndListen;\n proxies[type] = handler(chart, type, listener);\n }\n removeEventListener(chart, type) {\n const proxies = chart.$proxies || (chart.$proxies = {});\n const proxy = proxies[type];\n if (!proxy) {\n return;\n }\n const handlers = {\n attach: releaseObserver,\n detach: releaseObserver,\n resize: releaseObserver\n };\n const handler = handlers[type] || removeListener;\n handler(chart, type, proxy);\n proxies[type] = undefined;\n }\n getDevicePixelRatio() {\n return window.devicePixelRatio;\n }\n getMaximumSize(canvas, width, height, aspectRatio) {\n return getMaximumSize(canvas, width, height, aspectRatio);\n }\n isAttached(canvas) {\n const container = canvas && _getParentNode(canvas);\n return !!(container && container.isConnected);\n }\n}\nfunction _detectPlatform(canvas) {\n if (!_isDomSupported() || typeof OffscreenCanvas !== 'undefined' && canvas instanceof OffscreenCanvas) {\n return BasicPlatform;\n }\n return DomPlatform;\n}\nclass Element {\n static defaults = {};\n static defaultRoutes = undefined;\n x;\n y;\n active = false;\n options;\n $animations;\n tooltipPosition(useFinalPosition) {\n const {\n x,\n y\n } = this.getProps(['x', 'y'], useFinalPosition);\n return {\n x,\n y\n };\n }\n hasValue() {\n return isNumber(this.x) && isNumber(this.y);\n }\n getProps(props, final) {\n const anims = this.$animations;\n if (!final || !anims) {\n // let's not create an object, if not needed\n return this;\n }\n const ret = {};\n props.forEach(prop => {\n ret[prop] = anims[prop] && anims[prop].active() ? anims[prop]._to : this[prop];\n });\n return ret;\n }\n}\nfunction autoSkip(scale, ticks) {\n const tickOpts = scale.options.ticks;\n const determinedMaxTicks = determineMaxTicks(scale);\n const ticksLimit = Math.min(tickOpts.maxTicksLimit || determinedMaxTicks, determinedMaxTicks);\n const majorIndices = tickOpts.major.enabled ? getMajorIndices(ticks) : [];\n const numMajorIndices = majorIndices.length;\n const first = majorIndices[0];\n const last = majorIndices[numMajorIndices - 1];\n const newTicks = [];\n if (numMajorIndices > ticksLimit) {\n skipMajors(ticks, newTicks, majorIndices, numMajorIndices / ticksLimit);\n return newTicks;\n }\n const spacing = calculateSpacing(majorIndices, ticks, ticksLimit);\n if (numMajorIndices > 0) {\n let i, ilen;\n const avgMajorSpacing = numMajorIndices > 1 ? Math.round((last - first) / (numMajorIndices - 1)) : null;\n skip(ticks, newTicks, spacing, isNullOrUndef(avgMajorSpacing) ? 0 : first - avgMajorSpacing, first);\n for (i = 0, ilen = numMajorIndices - 1; i < ilen; i++) {\n skip(ticks, newTicks, spacing, majorIndices[i], majorIndices[i + 1]);\n }\n skip(ticks, newTicks, spacing, last, isNullOrUndef(avgMajorSpacing) ? ticks.length : last + avgMajorSpacing);\n return newTicks;\n }\n skip(ticks, newTicks, spacing);\n return newTicks;\n}\nfunction determineMaxTicks(scale) {\n const offset = scale.options.offset;\n const tickLength = scale._tickSize();\n const maxScale = scale._length / tickLength + (offset ? 0 : 1);\n const maxChart = scale._maxLength / tickLength;\n return Math.floor(Math.min(maxScale, maxChart));\n}\nfunction calculateSpacing(majorIndices, ticks, ticksLimit) {\n const evenMajorSpacing = getEvenSpacing(majorIndices);\n const spacing = ticks.length / ticksLimit;\n if (!evenMajorSpacing) {\n return Math.max(spacing, 1);\n }\n const factors = _factorize(evenMajorSpacing);\n for (let i = 0, ilen = factors.length - 1; i < ilen; i++) {\n const factor = factors[i];\n if (factor > spacing) {\n return factor;\n }\n }\n return Math.max(spacing, 1);\n}\nfunction getMajorIndices(ticks) {\n const result = [];\n let i, ilen;\n for (i = 0, ilen = ticks.length; i < ilen; i++) {\n if (ticks[i].major) {\n result.push(i);\n }\n }\n return result;\n}\nfunction skipMajors(ticks, newTicks, majorIndices, spacing) {\n let count = 0;\n let next = majorIndices[0];\n let i;\n spacing = Math.ceil(spacing);\n for (i = 0; i < ticks.length; i++) {\n if (i === next) {\n newTicks.push(ticks[i]);\n count++;\n next = majorIndices[count * spacing];\n }\n }\n}\nfunction skip(ticks, newTicks, spacing, majorStart, majorEnd) {\n const start = valueOrDefault(majorStart, 0);\n const end = Math.min(valueOrDefault(majorEnd, ticks.length), ticks.length);\n let count = 0;\n let length, i, next;\n spacing = Math.ceil(spacing);\n if (majorEnd) {\n length = majorEnd - majorStart;\n spacing = length / Math.floor(length / spacing);\n }\n next = start;\n while (next < 0) {\n count++;\n next = Math.round(start + count * spacing);\n }\n for (i = Math.max(start, 0); i < end; i++) {\n if (i === next) {\n newTicks.push(ticks[i]);\n count++;\n next = Math.round(start + count * spacing);\n }\n }\n}\nfunction getEvenSpacing(arr) {\n const len = arr.length;\n let i, diff;\n if (len < 2) {\n return false;\n }\n for (diff = arr[0], i = 1; i < len; ++i) {\n if (arr[i] - arr[i - 1] !== diff) {\n return false;\n }\n }\n return diff;\n}\nconst reverseAlign = align => align === 'left' ? 'right' : align === 'right' ? 'left' : align;\nconst offsetFromEdge = (scale, edge, offset) => edge === 'top' || edge === 'left' ? scale[edge] + offset : scale[edge] - offset;\nconst getTicksLimit = (ticksLength, maxTicksLimit) => Math.min(maxTicksLimit || ticksLength, ticksLength);\nfunction sample(arr, numItems) {\n const result = [];\n const increment = arr.length / numItems;\n const len = arr.length;\n let i = 0;\n for (; i < len; i += increment) {\n result.push(arr[Math.floor(i)]);\n }\n return result;\n}\nfunction getPixelForGridLine(scale, index, offsetGridLines) {\n const length = scale.ticks.length;\n const validIndex = Math.min(index, length - 1);\n const start = scale._startPixel;\n const end = scale._endPixel;\n const epsilon = 1e-6;\n let lineValue = scale.getPixelForTick(validIndex);\n let offset;\n if (offsetGridLines) {\n if (length === 1) {\n offset = Math.max(lineValue - start, end - lineValue);\n } else if (index === 0) {\n offset = (scale.getPixelForTick(1) - lineValue) / 2;\n } else {\n offset = (lineValue - scale.getPixelForTick(validIndex - 1)) / 2;\n }\n lineValue += validIndex < index ? offset : -offset;\n if (lineValue < start - epsilon || lineValue > end + epsilon) {\n return;\n }\n }\n return lineValue;\n}\nfunction garbageCollect(caches, length) {\n each(caches, cache => {\n const gc = cache.gc;\n const gcLen = gc.length / 2;\n let i;\n if (gcLen > length) {\n for (i = 0; i < gcLen; ++i) {\n delete cache.data[gc[i]];\n }\n gc.splice(0, gcLen);\n }\n });\n}\nfunction getTickMarkLength(options) {\n return options.drawTicks ? options.tickLength : 0;\n}\nfunction getTitleHeight(options, fallback) {\n if (!options.display) {\n return 0;\n }\n const font = toFont(options.font, fallback);\n const padding = toPadding(options.padding);\n const lines = isArray(options.text) ? options.text.length : 1;\n return lines * font.lineHeight + padding.height;\n}\nfunction createScaleContext(parent, scale) {\n return createContext(parent, {\n scale,\n type: 'scale'\n });\n}\nfunction createTickContext(parent, index, tick) {\n return createContext(parent, {\n tick,\n index,\n type: 'tick'\n });\n}\nfunction titleAlign(align, position, reverse) {\n let ret = _toLeftRightCenter(align);\n if (reverse && position !== 'right' || !reverse && position === 'right') {\n ret = reverseAlign(ret);\n }\n return ret;\n}\nfunction titleArgs(scale, offset, position, align) {\n const {\n top,\n left,\n bottom,\n right,\n chart\n } = scale;\n const {\n chartArea,\n scales\n } = chart;\n let rotation = 0;\n let maxWidth, titleX, titleY;\n const height = bottom - top;\n const width = right - left;\n if (scale.isHorizontal()) {\n titleX = _alignStartEnd(align, left, right);\n if (isObject(position)) {\n const positionAxisID = Object.keys(position)[0];\n const value = position[positionAxisID];\n titleY = scales[positionAxisID].getPixelForValue(value) + height - offset;\n } else if (position === 'center') {\n titleY = (chartArea.bottom + chartArea.top) / 2 + height - offset;\n } else {\n titleY = offsetFromEdge(scale, position, offset);\n }\n maxWidth = right - left;\n } else {\n if (isObject(position)) {\n const positionAxisID = Object.keys(position)[0];\n const value = position[positionAxisID];\n titleX = scales[positionAxisID].getPixelForValue(value) - width + offset;\n } else if (position === 'center') {\n titleX = (chartArea.left + chartArea.right) / 2 - width + offset;\n } else {\n titleX = offsetFromEdge(scale, position, offset);\n }\n titleY = _alignStartEnd(align, bottom, top);\n rotation = position === 'left' ? -HALF_PI : HALF_PI;\n }\n return {\n titleX,\n titleY,\n maxWidth,\n rotation\n };\n}\nclass Scale extends Element {\n constructor(cfg) {\n super();\n this.id = cfg.id;\n this.type = cfg.type;\n this.options = undefined;\n this.ctx = cfg.ctx;\n this.chart = cfg.chart;\n this.top = undefined;\n this.bottom = undefined;\n this.left = undefined;\n this.right = undefined;\n this.width = undefined;\n this.height = undefined;\n this._margins = {\n left: 0,\n right: 0,\n top: 0,\n bottom: 0\n };\n this.maxWidth = undefined;\n this.maxHeight = undefined;\n this.paddingTop = undefined;\n this.paddingBottom = undefined;\n this.paddingLeft = undefined;\n this.paddingRight = undefined;\n this.axis = undefined;\n this.labelRotation = undefined;\n this.min = undefined;\n this.max = undefined;\n this._range = undefined;\n this.ticks = [];\n this._gridLineItems = null;\n this._labelItems = null;\n this._labelSizes = null;\n this._length = 0;\n this._maxLength = 0;\n this._longestTextCache = {};\n this._startPixel = undefined;\n this._endPixel = undefined;\n this._reversePixels = false;\n this._userMax = undefined;\n this._userMin = undefined;\n this._suggestedMax = undefined;\n this._suggestedMin = undefined;\n this._ticksLength = 0;\n this._borderValue = 0;\n this._cache = {};\n this._dataLimitsCached = false;\n this.$context = undefined;\n }\n init(options) {\n this.options = options.setContext(this.getContext());\n this.axis = options.axis;\n this._userMin = this.parse(options.min);\n this._userMax = this.parse(options.max);\n this._suggestedMin = this.parse(options.suggestedMin);\n this._suggestedMax = this.parse(options.suggestedMax);\n }\n parse(raw, index) {\n return raw;\n }\n getUserBounds() {\n let {\n _userMin,\n _userMax,\n _suggestedMin,\n _suggestedMax\n } = this;\n _userMin = finiteOrDefault(_userMin, Number.POSITIVE_INFINITY);\n _userMax = finiteOrDefault(_userMax, Number.NEGATIVE_INFINITY);\n _suggestedMin = finiteOrDefault(_suggestedMin, Number.POSITIVE_INFINITY);\n _suggestedMax = finiteOrDefault(_suggestedMax, Number.NEGATIVE_INFINITY);\n return {\n min: finiteOrDefault(_userMin, _suggestedMin),\n max: finiteOrDefault(_userMax, _suggestedMax),\n minDefined: isNumberFinite(_userMin),\n maxDefined: isNumberFinite(_userMax)\n };\n }\n getMinMax(canStack) {\n let {\n min,\n max,\n minDefined,\n maxDefined\n } = this.getUserBounds();\n let range;\n if (minDefined && maxDefined) {\n return {\n min,\n max\n };\n }\n const metas = this.getMatchingVisibleMetas();\n for (let i = 0, ilen = metas.length; i < ilen; ++i) {\n range = metas[i].controller.getMinMax(this, canStack);\n if (!minDefined) {\n min = Math.min(min, range.min);\n }\n if (!maxDefined) {\n max = Math.max(max, range.max);\n }\n }\n min = maxDefined && min > max ? max : min;\n max = minDefined && min > max ? min : max;\n return {\n min: finiteOrDefault(min, finiteOrDefault(max, min)),\n max: finiteOrDefault(max, finiteOrDefault(min, max))\n };\n }\n getPadding() {\n return {\n left: this.paddingLeft || 0,\n top: this.paddingTop || 0,\n right: this.paddingRight || 0,\n bottom: this.paddingBottom || 0\n };\n }\n getTicks() {\n return this.ticks;\n }\n getLabels() {\n const data = this.chart.data;\n return this.options.labels || (this.isHorizontal() ? data.xLabels : data.yLabels) || data.labels || [];\n }\n getLabelItems(chartArea = this.chart.chartArea) {\n const items = this._labelItems || (this._labelItems = this._computeLabelItems(chartArea));\n return items;\n }\n beforeLayout() {\n this._cache = {};\n this._dataLimitsCached = false;\n }\n beforeUpdate() {\n callback(this.options.beforeUpdate, [this]);\n }\n update(maxWidth, maxHeight, margins) {\n const {\n beginAtZero,\n grace,\n ticks: tickOpts\n } = this.options;\n const sampleSize = tickOpts.sampleSize;\n this.beforeUpdate();\n this.maxWidth = maxWidth;\n this.maxHeight = maxHeight;\n this._margins = margins = Object.assign({\n left: 0,\n right: 0,\n top: 0,\n bottom: 0\n }, margins);\n this.ticks = null;\n this._labelSizes = null;\n this._gridLineItems = null;\n this._labelItems = null;\n this.beforeSetDimensions();\n this.setDimensions();\n this.afterSetDimensions();\n this._maxLength = this.isHorizontal() ? this.width + margins.left + margins.right : this.height + margins.top + margins.bottom;\n if (!this._dataLimitsCached) {\n this.beforeDataLimits();\n this.determineDataLimits();\n this.afterDataLimits();\n this._range = _addGrace(this, grace, beginAtZero);\n this._dataLimitsCached = true;\n }\n this.beforeBuildTicks();\n this.ticks = this.buildTicks() || [];\n this.afterBuildTicks();\n const samplingEnabled = sampleSize < this.ticks.length;\n this._convertTicksToLabels(samplingEnabled ? sample(this.ticks, sampleSize) : this.ticks);\n this.configure();\n this.beforeCalculateLabelRotation();\n this.calculateLabelRotation();\n this.afterCalculateLabelRotation();\n if (tickOpts.display && (tickOpts.autoSkip || tickOpts.source === 'auto')) {\n this.ticks = autoSkip(this, this.ticks);\n this._labelSizes = null;\n this.afterAutoSkip();\n }\n if (samplingEnabled) {\n this._convertTicksToLabels(this.ticks);\n }\n this.beforeFit();\n this.fit();\n this.afterFit();\n this.afterUpdate();\n }\n configure() {\n let reversePixels = this.options.reverse;\n let startPixel, endPixel;\n if (this.isHorizontal()) {\n startPixel = this.left;\n endPixel = this.right;\n } else {\n startPixel = this.top;\n endPixel = this.bottom;\n reversePixels = !reversePixels;\n }\n this._startPixel = startPixel;\n this._endPixel = endPixel;\n this._reversePixels = reversePixels;\n this._length = endPixel - startPixel;\n this._alignToPixels = this.options.alignToPixels;\n }\n afterUpdate() {\n callback(this.options.afterUpdate, [this]);\n }\n beforeSetDimensions() {\n callback(this.options.beforeSetDimensions, [this]);\n }\n setDimensions() {\n if (this.isHorizontal()) {\n this.width = this.maxWidth;\n this.left = 0;\n this.right = this.width;\n } else {\n this.height = this.maxHeight;\n this.top = 0;\n this.bottom = this.height;\n }\n this.paddingLeft = 0;\n this.paddingTop = 0;\n this.paddingRight = 0;\n this.paddingBottom = 0;\n }\n afterSetDimensions() {\n callback(this.options.afterSetDimensions, [this]);\n }\n _callHooks(name) {\n this.chart.notifyPlugins(name, this.getContext());\n callback(this.options[name], [this]);\n }\n beforeDataLimits() {\n this._callHooks('beforeDataLimits');\n }\n determineDataLimits() {}\n afterDataLimits() {\n this._callHooks('afterDataLimits');\n }\n beforeBuildTicks() {\n this._callHooks('beforeBuildTicks');\n }\n buildTicks() {\n return [];\n }\n afterBuildTicks() {\n this._callHooks('afterBuildTicks');\n }\n beforeTickToLabelConversion() {\n callback(this.options.beforeTickToLabelConversion, [this]);\n }\n generateTickLabels(ticks) {\n const tickOpts = this.options.ticks;\n let i, ilen, tick;\n for (i = 0, ilen = ticks.length; i < ilen; i++) {\n tick = ticks[i];\n tick.label = callback(tickOpts.callback, [tick.value, i, ticks], this);\n }\n }\n afterTickToLabelConversion() {\n callback(this.options.afterTickToLabelConversion, [this]);\n }\n beforeCalculateLabelRotation() {\n callback(this.options.beforeCalculateLabelRotation, [this]);\n }\n calculateLabelRotation() {\n const options = this.options;\n const tickOpts = options.ticks;\n const numTicks = getTicksLimit(this.ticks.length, options.ticks.maxTicksLimit);\n const minRotation = tickOpts.minRotation || 0;\n const maxRotation = tickOpts.maxRotation;\n let labelRotation = minRotation;\n let tickWidth, maxHeight, maxLabelDiagonal;\n if (!this._isVisible() || !tickOpts.display || minRotation >= maxRotation || numTicks <= 1 || !this.isHorizontal()) {\n this.labelRotation = minRotation;\n return;\n }\n const labelSizes = this._getLabelSizes();\n const maxLabelWidth = labelSizes.widest.width;\n const maxLabelHeight = labelSizes.highest.height;\n const maxWidth = _limitValue(this.chart.width - maxLabelWidth, 0, this.maxWidth);\n tickWidth = options.offset ? this.maxWidth / numTicks : maxWidth / (numTicks - 1);\n if (maxLabelWidth + 6 > tickWidth) {\n tickWidth = maxWidth / (numTicks - (options.offset ? 0.5 : 1));\n maxHeight = this.maxHeight - getTickMarkLength(options.grid) - tickOpts.padding - getTitleHeight(options.title, this.chart.options.font);\n maxLabelDiagonal = Math.sqrt(maxLabelWidth * maxLabelWidth + maxLabelHeight * maxLabelHeight);\n labelRotation = toDegrees(Math.min(Math.asin(_limitValue((labelSizes.highest.height + 6) / tickWidth, -1, 1)), Math.asin(_limitValue(maxHeight / maxLabelDiagonal, -1, 1)) - Math.asin(_limitValue(maxLabelHeight / maxLabelDiagonal, -1, 1))));\n labelRotation = Math.max(minRotation, Math.min(maxRotation, labelRotation));\n }\n this.labelRotation = labelRotation;\n }\n afterCalculateLabelRotation() {\n callback(this.options.afterCalculateLabelRotation, [this]);\n }\n afterAutoSkip() {}\n beforeFit() {\n callback(this.options.beforeFit, [this]);\n }\n fit() {\n const minSize = {\n width: 0,\n height: 0\n };\n const {\n chart,\n options: {\n ticks: tickOpts,\n title: titleOpts,\n grid: gridOpts\n }\n } = this;\n const display = this._isVisible();\n const isHorizontal = this.isHorizontal();\n if (display) {\n const titleHeight = getTitleHeight(titleOpts, chart.options.font);\n if (isHorizontal) {\n minSize.width = this.maxWidth;\n minSize.height = getTickMarkLength(gridOpts) + titleHeight;\n } else {\n minSize.height = this.maxHeight;\n minSize.width = getTickMarkLength(gridOpts) + titleHeight;\n }\n if (tickOpts.display && this.ticks.length) {\n const {\n first,\n last,\n widest,\n highest\n } = this._getLabelSizes();\n const tickPadding = tickOpts.padding * 2;\n const angleRadians = toRadians(this.labelRotation);\n const cos = Math.cos(angleRadians);\n const sin = Math.sin(angleRadians);\n if (isHorizontal) {\n const labelHeight = tickOpts.mirror ? 0 : sin * widest.width + cos * highest.height;\n minSize.height = Math.min(this.maxHeight, minSize.height + labelHeight + tickPadding);\n } else {\n const labelWidth = tickOpts.mirror ? 0 : cos * widest.width + sin * highest.height;\n minSize.width = Math.min(this.maxWidth, minSize.width + labelWidth + tickPadding);\n }\n this._calculatePadding(first, last, sin, cos);\n }\n }\n this._handleMargins();\n if (isHorizontal) {\n this.width = this._length = chart.width - this._margins.left - this._margins.right;\n this.height = minSize.height;\n } else {\n this.width = minSize.width;\n this.height = this._length = chart.height - this._margins.top - this._margins.bottom;\n }\n }\n _calculatePadding(first, last, sin, cos) {\n const {\n ticks: {\n align,\n padding\n },\n position\n } = this.options;\n const isRotated = this.labelRotation !== 0;\n const labelsBelowTicks = position !== 'top' && this.axis === 'x';\n if (this.isHorizontal()) {\n const offsetLeft = this.getPixelForTick(0) - this.left;\n const offsetRight = this.right - this.getPixelForTick(this.ticks.length - 1);\n let paddingLeft = 0;\n let paddingRight = 0;\n if (isRotated) {\n if (labelsBelowTicks) {\n paddingLeft = cos * first.width;\n paddingRight = sin * last.height;\n } else {\n paddingLeft = sin * first.height;\n paddingRight = cos * last.width;\n }\n } else if (align === 'start') {\n paddingRight = last.width;\n } else if (align === 'end') {\n paddingLeft = first.width;\n } else if (align !== 'inner') {\n paddingLeft = first.width / 2;\n paddingRight = last.width / 2;\n }\n this.paddingLeft = Math.max((paddingLeft - offsetLeft + padding) * this.width / (this.width - offsetLeft), 0);\n this.paddingRight = Math.max((paddingRight - offsetRight + padding) * this.width / (this.width - offsetRight), 0);\n } else {\n let paddingTop = last.height / 2;\n let paddingBottom = first.height / 2;\n if (align === 'start') {\n paddingTop = 0;\n paddingBottom = first.height;\n } else if (align === 'end') {\n paddingTop = last.height;\n paddingBottom = 0;\n }\n this.paddingTop = paddingTop + padding;\n this.paddingBottom = paddingBottom + padding;\n }\n }\n _handleMargins() {\n if (this._margins) {\n this._margins.left = Math.max(this.paddingLeft, this._margins.left);\n this._margins.top = Math.max(this.paddingTop, this._margins.top);\n this._margins.right = Math.max(this.paddingRight, this._margins.right);\n this._margins.bottom = Math.max(this.paddingBottom, this._margins.bottom);\n }\n }\n afterFit() {\n callback(this.options.afterFit, [this]);\n }\n isHorizontal() {\n const {\n axis,\n position\n } = this.options;\n return position === 'top' || position === 'bottom' || axis === 'x';\n }\n isFullSize() {\n return this.options.fullSize;\n }\n _convertTicksToLabels(ticks) {\n this.beforeTickToLabelConversion();\n this.generateTickLabels(ticks);\n let i, ilen;\n for (i = 0, ilen = ticks.length; i < ilen; i++) {\n if (isNullOrUndef(ticks[i].label)) {\n ticks.splice(i, 1);\n ilen--;\n i--;\n }\n }\n this.afterTickToLabelConversion();\n }\n _getLabelSizes() {\n let labelSizes = this._labelSizes;\n if (!labelSizes) {\n const sampleSize = this.options.ticks.sampleSize;\n let ticks = this.ticks;\n if (sampleSize < ticks.length) {\n ticks = sample(ticks, sampleSize);\n }\n this._labelSizes = labelSizes = this._computeLabelSizes(ticks, ticks.length, this.options.ticks.maxTicksLimit);\n }\n return labelSizes;\n }\n _computeLabelSizes(ticks, length, maxTicksLimit) {\n const {\n ctx,\n _longestTextCache: caches\n } = this;\n const widths = [];\n const heights = [];\n const increment = Math.floor(length / getTicksLimit(length, maxTicksLimit));\n let widestLabelSize = 0;\n let highestLabelSize = 0;\n let i, j, jlen, label, tickFont, fontString, cache, lineHeight, width, height, nestedLabel;\n for (i = 0; i < length; i += increment) {\n label = ticks[i].label;\n tickFont = this._resolveTickFontOptions(i);\n ctx.font = fontString = tickFont.string;\n cache = caches[fontString] = caches[fontString] || {\n data: {},\n gc: []\n };\n lineHeight = tickFont.lineHeight;\n width = height = 0;\n if (!isNullOrUndef(label) && !isArray(label)) {\n width = _measureText(ctx, cache.data, cache.gc, width, label);\n height = lineHeight;\n } else if (isArray(label)) {\n for (j = 0, jlen = label.length; j < jlen; ++j) {\n nestedLabel = label[j];\n if (!isNullOrUndef(nestedLabel) && !isArray(nestedLabel)) {\n width = _measureText(ctx, cache.data, cache.gc, width, nestedLabel);\n height += lineHeight;\n }\n }\n }\n widths.push(width);\n heights.push(height);\n widestLabelSize = Math.max(width, widestLabelSize);\n highestLabelSize = Math.max(height, highestLabelSize);\n }\n garbageCollect(caches, length);\n const widest = widths.indexOf(widestLabelSize);\n const highest = heights.indexOf(highestLabelSize);\n const valueAt = idx => ({\n width: widths[idx] || 0,\n height: heights[idx] || 0\n });\n return {\n first: valueAt(0),\n last: valueAt(length - 1),\n widest: valueAt(widest),\n highest: valueAt(highest),\n widths,\n heights\n };\n }\n getLabelForValue(value) {\n return value;\n }\n getPixelForValue(value, index) {\n return NaN;\n }\n getValueForPixel(pixel) {}\n getPixelForTick(index) {\n const ticks = this.ticks;\n if (index < 0 || index > ticks.length - 1) {\n return null;\n }\n return this.getPixelForValue(ticks[index].value);\n }\n getPixelForDecimal(decimal) {\n if (this._reversePixels) {\n decimal = 1 - decimal;\n }\n const pixel = this._startPixel + decimal * this._length;\n return _int16Range(this._alignToPixels ? _alignPixel(this.chart, pixel, 0) : pixel);\n }\n getDecimalForPixel(pixel) {\n const decimal = (pixel - this._startPixel) / this._length;\n return this._reversePixels ? 1 - decimal : decimal;\n }\n getBasePixel() {\n return this.getPixelForValue(this.getBaseValue());\n }\n getBaseValue() {\n const {\n min,\n max\n } = this;\n return min < 0 && max < 0 ? max : min > 0 && max > 0 ? min : 0;\n }\n getContext(index) {\n const ticks = this.ticks || [];\n if (index >= 0 && index < ticks.length) {\n const tick = ticks[index];\n return tick.$context || (tick.$context = createTickContext(this.getContext(), index, tick));\n }\n return this.$context || (this.$context = createScaleContext(this.chart.getContext(), this));\n }\n _tickSize() {\n const optionTicks = this.options.ticks;\n const rot = toRadians(this.labelRotation);\n const cos = Math.abs(Math.cos(rot));\n const sin = Math.abs(Math.sin(rot));\n const labelSizes = this._getLabelSizes();\n const padding = optionTicks.autoSkipPadding || 0;\n const w = labelSizes ? labelSizes.widest.width + padding : 0;\n const h = labelSizes ? labelSizes.highest.height + padding : 0;\n return this.isHorizontal() ? h * cos > w * sin ? w / cos : h / sin : h * sin < w * cos ? h / cos : w / sin;\n }\n _isVisible() {\n const display = this.options.display;\n if (display !== 'auto') {\n return !!display;\n }\n return this.getMatchingVisibleMetas().length > 0;\n }\n _computeGridLineItems(chartArea) {\n const axis = this.axis;\n const chart = this.chart;\n const options = this.options;\n const {\n grid,\n position,\n border\n } = options;\n const offset = grid.offset;\n const isHorizontal = this.isHorizontal();\n const ticks = this.ticks;\n const ticksLength = ticks.length + (offset ? 1 : 0);\n const tl = getTickMarkLength(grid);\n const items = [];\n const borderOpts = border.setContext(this.getContext());\n const axisWidth = borderOpts.display ? borderOpts.width : 0;\n const axisHalfWidth = axisWidth / 2;\n const alignBorderValue = function (pixel) {\n return _alignPixel(chart, pixel, axisWidth);\n };\n let borderValue, i, lineValue, alignedLineValue;\n let tx1, ty1, tx2, ty2, x1, y1, x2, y2;\n if (position === 'top') {\n borderValue = alignBorderValue(this.bottom);\n ty1 = this.bottom - tl;\n ty2 = borderValue - axisHalfWidth;\n y1 = alignBorderValue(chartArea.top) + axisHalfWidth;\n y2 = chartArea.bottom;\n } else if (position === 'bottom') {\n borderValue = alignBorderValue(this.top);\n y1 = chartArea.top;\n y2 = alignBorderValue(chartArea.bottom) - axisHalfWidth;\n ty1 = borderValue + axisHalfWidth;\n ty2 = this.top + tl;\n } else if (position === 'left') {\n borderValue = alignBorderValue(this.right);\n tx1 = this.right - tl;\n tx2 = borderValue - axisHalfWidth;\n x1 = alignBorderValue(chartArea.left) + axisHalfWidth;\n x2 = chartArea.right;\n } else if (position === 'right') {\n borderValue = alignBorderValue(this.left);\n x1 = chartArea.left;\n x2 = alignBorderValue(chartArea.right) - axisHalfWidth;\n tx1 = borderValue + axisHalfWidth;\n tx2 = this.left + tl;\n } else if (axis === 'x') {\n if (position === 'center') {\n borderValue = alignBorderValue((chartArea.top + chartArea.bottom) / 2 + 0.5);\n } else if (isObject(position)) {\n const positionAxisID = Object.keys(position)[0];\n const value = position[positionAxisID];\n borderValue = alignBorderValue(this.chart.scales[positionAxisID].getPixelForValue(value));\n }\n y1 = chartArea.top;\n y2 = chartArea.bottom;\n ty1 = borderValue + axisHalfWidth;\n ty2 = ty1 + tl;\n } else if (axis === 'y') {\n if (position === 'center') {\n borderValue = alignBorderValue((chartArea.left + chartArea.right) / 2);\n } else if (isObject(position)) {\n const positionAxisID = Object.keys(position)[0];\n const value = position[positionAxisID];\n borderValue = alignBorderValue(this.chart.scales[positionAxisID].getPixelForValue(value));\n }\n tx1 = borderValue - axisHalfWidth;\n tx2 = tx1 - tl;\n x1 = chartArea.left;\n x2 = chartArea.right;\n }\n const limit = valueOrDefault(options.ticks.maxTicksLimit, ticksLength);\n const step = Math.max(1, Math.ceil(ticksLength / limit));\n for (i = 0; i < ticksLength; i += step) {\n const context = this.getContext(i);\n const optsAtIndex = grid.setContext(context);\n const optsAtIndexBorder = border.setContext(context);\n const lineWidth = optsAtIndex.lineWidth;\n const lineColor = optsAtIndex.color;\n const borderDash = optsAtIndexBorder.dash || [];\n const borderDashOffset = optsAtIndexBorder.dashOffset;\n const tickWidth = optsAtIndex.tickWidth;\n const tickColor = optsAtIndex.tickColor;\n const tickBorderDash = optsAtIndex.tickBorderDash || [];\n const tickBorderDashOffset = optsAtIndex.tickBorderDashOffset;\n lineValue = getPixelForGridLine(this, i, offset);\n if (lineValue === undefined) {\n continue;\n }\n alignedLineValue = _alignPixel(chart, lineValue, lineWidth);\n if (isHorizontal) {\n tx1 = tx2 = x1 = x2 = alignedLineValue;\n } else {\n ty1 = ty2 = y1 = y2 = alignedLineValue;\n }\n items.push({\n tx1,\n ty1,\n tx2,\n ty2,\n x1,\n y1,\n x2,\n y2,\n width: lineWidth,\n color: lineColor,\n borderDash,\n borderDashOffset,\n tickWidth,\n tickColor,\n tickBorderDash,\n tickBorderDashOffset\n });\n }\n this._ticksLength = ticksLength;\n this._borderValue = borderValue;\n return items;\n }\n _computeLabelItems(chartArea) {\n const axis = this.axis;\n const options = this.options;\n const {\n position,\n ticks: optionTicks\n } = options;\n const isHorizontal = this.isHorizontal();\n const ticks = this.ticks;\n const {\n align,\n crossAlign,\n padding,\n mirror\n } = optionTicks;\n const tl = getTickMarkLength(options.grid);\n const tickAndPadding = tl + padding;\n const hTickAndPadding = mirror ? -padding : tickAndPadding;\n const rotation = -toRadians(this.labelRotation);\n const items = [];\n let i, ilen, tick, label, x, y, textAlign, pixel, font, lineHeight, lineCount, textOffset;\n let textBaseline = 'middle';\n if (position === 'top') {\n y = this.bottom - hTickAndPadding;\n textAlign = this._getXAxisLabelAlignment();\n } else if (position === 'bottom') {\n y = this.top + hTickAndPadding;\n textAlign = this._getXAxisLabelAlignment();\n } else if (position === 'left') {\n const ret = this._getYAxisLabelAlignment(tl);\n textAlign = ret.textAlign;\n x = ret.x;\n } else if (position === 'right') {\n const ret = this._getYAxisLabelAlignment(tl);\n textAlign = ret.textAlign;\n x = ret.x;\n } else if (axis === 'x') {\n if (position === 'center') {\n y = (chartArea.top + chartArea.bottom) / 2 + tickAndPadding;\n } else if (isObject(position)) {\n const positionAxisID = Object.keys(position)[0];\n const value = position[positionAxisID];\n y = this.chart.scales[positionAxisID].getPixelForValue(value) + tickAndPadding;\n }\n textAlign = this._getXAxisLabelAlignment();\n } else if (axis === 'y') {\n if (position === 'center') {\n x = (chartArea.left + chartArea.right) / 2 - tickAndPadding;\n } else if (isObject(position)) {\n const positionAxisID = Object.keys(position)[0];\n const value = position[positionAxisID];\n x = this.chart.scales[positionAxisID].getPixelForValue(value);\n }\n textAlign = this._getYAxisLabelAlignment(tl).textAlign;\n }\n if (axis === 'y') {\n if (align === 'start') {\n textBaseline = 'top';\n } else if (align === 'end') {\n textBaseline = 'bottom';\n }\n }\n const labelSizes = this._getLabelSizes();\n for (i = 0, ilen = ticks.length; i < ilen; ++i) {\n tick = ticks[i];\n label = tick.label;\n const optsAtIndex = optionTicks.setContext(this.getContext(i));\n pixel = this.getPixelForTick(i) + optionTicks.labelOffset;\n font = this._resolveTickFontOptions(i);\n lineHeight = font.lineHeight;\n lineCount = isArray(label) ? label.length : 1;\n const halfCount = lineCount / 2;\n const color = optsAtIndex.color;\n const strokeColor = optsAtIndex.textStrokeColor;\n const strokeWidth = optsAtIndex.textStrokeWidth;\n let tickTextAlign = textAlign;\n if (isHorizontal) {\n x = pixel;\n if (textAlign === 'inner') {\n if (i === ilen - 1) {\n tickTextAlign = !this.options.reverse ? 'right' : 'left';\n } else if (i === 0) {\n tickTextAlign = !this.options.reverse ? 'left' : 'right';\n } else {\n tickTextAlign = 'center';\n }\n }\n if (position === 'top') {\n if (crossAlign === 'near' || rotation !== 0) {\n textOffset = -lineCount * lineHeight + lineHeight / 2;\n } else if (crossAlign === 'center') {\n textOffset = -labelSizes.highest.height / 2 - halfCount * lineHeight + lineHeight;\n } else {\n textOffset = -labelSizes.highest.height + lineHeight / 2;\n }\n } else {\n if (crossAlign === 'near' || rotation !== 0) {\n textOffset = lineHeight / 2;\n } else if (crossAlign === 'center') {\n textOffset = labelSizes.highest.height / 2 - halfCount * lineHeight;\n } else {\n textOffset = labelSizes.highest.height - lineCount * lineHeight;\n }\n }\n if (mirror) {\n textOffset *= -1;\n }\n if (rotation !== 0 && !optsAtIndex.showLabelBackdrop) {\n x += lineHeight / 2 * Math.sin(rotation);\n }\n } else {\n y = pixel;\n textOffset = (1 - lineCount) * lineHeight / 2;\n }\n let backdrop;\n if (optsAtIndex.showLabelBackdrop) {\n const labelPadding = toPadding(optsAtIndex.backdropPadding);\n const height = labelSizes.heights[i];\n const width = labelSizes.widths[i];\n let top = textOffset - labelPadding.top;\n let left = 0 - labelPadding.left;\n switch (textBaseline) {\n case 'middle':\n top -= height / 2;\n break;\n case 'bottom':\n top -= height;\n break;\n }\n switch (textAlign) {\n case 'center':\n left -= width / 2;\n break;\n case 'right':\n left -= width;\n break;\n case 'inner':\n if (i === ilen - 1) {\n left -= width;\n } else if (i > 0) {\n left -= width / 2;\n }\n break;\n }\n backdrop = {\n left,\n top,\n width: width + labelPadding.width,\n height: height + labelPadding.height,\n color: optsAtIndex.backdropColor\n };\n }\n items.push({\n label,\n font,\n textOffset,\n options: {\n rotation,\n color,\n strokeColor,\n strokeWidth,\n textAlign: tickTextAlign,\n textBaseline,\n translation: [x, y],\n backdrop\n }\n });\n }\n return items;\n }\n _getXAxisLabelAlignment() {\n const {\n position,\n ticks\n } = this.options;\n const rotation = -toRadians(this.labelRotation);\n if (rotation) {\n return position === 'top' ? 'left' : 'right';\n }\n let align = 'center';\n if (ticks.align === 'start') {\n align = 'left';\n } else if (ticks.align === 'end') {\n align = 'right';\n } else if (ticks.align === 'inner') {\n align = 'inner';\n }\n return align;\n }\n _getYAxisLabelAlignment(tl) {\n const {\n position,\n ticks: {\n crossAlign,\n mirror,\n padding\n }\n } = this.options;\n const labelSizes = this._getLabelSizes();\n const tickAndPadding = tl + padding;\n const widest = labelSizes.widest.width;\n let textAlign;\n let x;\n if (position === 'left') {\n if (mirror) {\n x = this.right + padding;\n if (crossAlign === 'near') {\n textAlign = 'left';\n } else if (crossAlign === 'center') {\n textAlign = 'center';\n x += widest / 2;\n } else {\n textAlign = 'right';\n x += widest;\n }\n } else {\n x = this.right - tickAndPadding;\n if (crossAlign === 'near') {\n textAlign = 'right';\n } else if (crossAlign === 'center') {\n textAlign = 'center';\n x -= widest / 2;\n } else {\n textAlign = 'left';\n x = this.left;\n }\n }\n } else if (position === 'right') {\n if (mirror) {\n x = this.left + padding;\n if (crossAlign === 'near') {\n textAlign = 'right';\n } else if (crossAlign === 'center') {\n textAlign = 'center';\n x -= widest / 2;\n } else {\n textAlign = 'left';\n x -= widest;\n }\n } else {\n x = this.left + tickAndPadding;\n if (crossAlign === 'near') {\n textAlign = 'left';\n } else if (crossAlign === 'center') {\n textAlign = 'center';\n x += widest / 2;\n } else {\n textAlign = 'right';\n x = this.right;\n }\n }\n } else {\n textAlign = 'right';\n }\n return {\n textAlign,\n x\n };\n }\n _computeLabelArea() {\n if (this.options.ticks.mirror) {\n return;\n }\n const chart = this.chart;\n const position = this.options.position;\n if (position === 'left' || position === 'right') {\n return {\n top: 0,\n left: this.left,\n bottom: chart.height,\n right: this.right\n };\n }\n if (position === 'top' || position === 'bottom') {\n return {\n top: this.top,\n left: 0,\n bottom: this.bottom,\n right: chart.width\n };\n }\n }\n drawBackground() {\n const {\n ctx,\n options: {\n backgroundColor\n },\n left,\n top,\n width,\n height\n } = this;\n if (backgroundColor) {\n ctx.save();\n ctx.fillStyle = backgroundColor;\n ctx.fillRect(left, top, width, height);\n ctx.restore();\n }\n }\n getLineWidthForValue(value) {\n const grid = this.options.grid;\n if (!this._isVisible() || !grid.display) {\n return 0;\n }\n const ticks = this.ticks;\n const index = ticks.findIndex(t => t.value === value);\n if (index >= 0) {\n const opts = grid.setContext(this.getContext(index));\n return opts.lineWidth;\n }\n return 0;\n }\n drawGrid(chartArea) {\n const grid = this.options.grid;\n const ctx = this.ctx;\n const items = this._gridLineItems || (this._gridLineItems = this._computeGridLineItems(chartArea));\n let i, ilen;\n const drawLine = (p1, p2, style) => {\n if (!style.width || !style.color) {\n return;\n }\n ctx.save();\n ctx.lineWidth = style.width;\n ctx.strokeStyle = style.color;\n ctx.setLineDash(style.borderDash || []);\n ctx.lineDashOffset = style.borderDashOffset;\n ctx.beginPath();\n ctx.moveTo(p1.x, p1.y);\n ctx.lineTo(p2.x, p2.y);\n ctx.stroke();\n ctx.restore();\n };\n if (grid.display) {\n for (i = 0, ilen = items.length; i < ilen; ++i) {\n const item = items[i];\n if (grid.drawOnChartArea) {\n drawLine({\n x: item.x1,\n y: item.y1\n }, {\n x: item.x2,\n y: item.y2\n }, item);\n }\n if (grid.drawTicks) {\n drawLine({\n x: item.tx1,\n y: item.ty1\n }, {\n x: item.tx2,\n y: item.ty2\n }, {\n color: item.tickColor,\n width: item.tickWidth,\n borderDash: item.tickBorderDash,\n borderDashOffset: item.tickBorderDashOffset\n });\n }\n }\n }\n }\n drawBorder() {\n const {\n chart,\n ctx,\n options: {\n border,\n grid\n }\n } = this;\n const borderOpts = border.setContext(this.getContext());\n const axisWidth = border.display ? borderOpts.width : 0;\n if (!axisWidth) {\n return;\n }\n const lastLineWidth = grid.setContext(this.getContext(0)).lineWidth;\n const borderValue = this._borderValue;\n let x1, x2, y1, y2;\n if (this.isHorizontal()) {\n x1 = _alignPixel(chart, this.left, axisWidth) - axisWidth / 2;\n x2 = _alignPixel(chart, this.right, lastLineWidth) + lastLineWidth / 2;\n y1 = y2 = borderValue;\n } else {\n y1 = _alignPixel(chart, this.top, axisWidth) - axisWidth / 2;\n y2 = _alignPixel(chart, this.bottom, lastLineWidth) + lastLineWidth / 2;\n x1 = x2 = borderValue;\n }\n ctx.save();\n ctx.lineWidth = borderOpts.width;\n ctx.strokeStyle = borderOpts.color;\n ctx.beginPath();\n ctx.moveTo(x1, y1);\n ctx.lineTo(x2, y2);\n ctx.stroke();\n ctx.restore();\n }\n drawLabels(chartArea) {\n const optionTicks = this.options.ticks;\n if (!optionTicks.display) {\n return;\n }\n const ctx = this.ctx;\n const area = this._computeLabelArea();\n if (area) {\n clipArea(ctx, area);\n }\n const items = this.getLabelItems(chartArea);\n for (const item of items) {\n const renderTextOptions = item.options;\n const tickFont = item.font;\n const label = item.label;\n const y = item.textOffset;\n renderText(ctx, label, 0, y, tickFont, renderTextOptions);\n }\n if (area) {\n unclipArea(ctx);\n }\n }\n drawTitle() {\n const {\n ctx,\n options: {\n position,\n title,\n reverse\n }\n } = this;\n if (!title.display) {\n return;\n }\n const font = toFont(title.font);\n const padding = toPadding(title.padding);\n const align = title.align;\n let offset = font.lineHeight / 2;\n if (position === 'bottom' || position === 'center' || isObject(position)) {\n offset += padding.bottom;\n if (isArray(title.text)) {\n offset += font.lineHeight * (title.text.length - 1);\n }\n } else {\n offset += padding.top;\n }\n const {\n titleX,\n titleY,\n maxWidth,\n rotation\n } = titleArgs(this, offset, position, align);\n renderText(ctx, title.text, 0, 0, font, {\n color: title.color,\n maxWidth,\n rotation,\n textAlign: titleAlign(align, position, reverse),\n textBaseline: 'middle',\n translation: [titleX, titleY]\n });\n }\n draw(chartArea) {\n if (!this._isVisible()) {\n return;\n }\n this.drawBackground();\n this.drawGrid(chartArea);\n this.drawBorder();\n this.drawTitle();\n this.drawLabels(chartArea);\n }\n _layers() {\n const opts = this.options;\n const tz = opts.ticks && opts.ticks.z || 0;\n const gz = valueOrDefault(opts.grid && opts.grid.z, -1);\n const bz = valueOrDefault(opts.border && opts.border.z, 0);\n if (!this._isVisible() || this.draw !== Scale.prototype.draw) {\n return [{\n z: tz,\n draw: chartArea => {\n this.draw(chartArea);\n }\n }];\n }\n return [{\n z: gz,\n draw: chartArea => {\n this.drawBackground();\n this.drawGrid(chartArea);\n this.drawTitle();\n }\n }, {\n z: bz,\n draw: () => {\n this.drawBorder();\n }\n }, {\n z: tz,\n draw: chartArea => {\n this.drawLabels(chartArea);\n }\n }];\n }\n getMatchingVisibleMetas(type) {\n const metas = this.chart.getSortedVisibleDatasetMetas();\n const axisID = this.axis + 'AxisID';\n const result = [];\n let i, ilen;\n for (i = 0, ilen = metas.length; i < ilen; ++i) {\n const meta = metas[i];\n if (meta[axisID] === this.id && (!type || meta.type === type)) {\n result.push(meta);\n }\n }\n return result;\n }\n _resolveTickFontOptions(index) {\n const opts = this.options.ticks.setContext(this.getContext(index));\n return toFont(opts.font);\n }\n _maxDigits() {\n const fontSize = this._resolveTickFontOptions(0).lineHeight;\n return (this.isHorizontal() ? this.width : this.height) / fontSize;\n }\n}\nclass TypedRegistry {\n constructor(type, scope, override) {\n this.type = type;\n this.scope = scope;\n this.override = override;\n this.items = Object.create(null);\n }\n isForType(type) {\n return Object.prototype.isPrototypeOf.call(this.type.prototype, type.prototype);\n }\n register(item) {\n const proto = Object.getPrototypeOf(item);\n let parentScope;\n if (isIChartComponent(proto)) {\n parentScope = this.register(proto);\n }\n const items = this.items;\n const id = item.id;\n const scope = this.scope + '.' + id;\n if (!id) {\n throw new Error('class does not have id: ' + item);\n }\n if (id in items) {\n return scope;\n }\n items[id] = item;\n registerDefaults(item, scope, parentScope);\n if (this.override) {\n defaults.override(item.id, item.overrides);\n }\n return scope;\n }\n get(id) {\n return this.items[id];\n }\n unregister(item) {\n const items = this.items;\n const id = item.id;\n const scope = this.scope;\n if (id in items) {\n delete items[id];\n }\n if (scope && id in defaults[scope]) {\n delete defaults[scope][id];\n if (this.override) {\n delete overrides[id];\n }\n }\n }\n}\nfunction registerDefaults(item, scope, parentScope) {\n const itemDefaults = merge(Object.create(null), [parentScope ? defaults.get(parentScope) : {}, defaults.get(scope), item.defaults]);\n defaults.set(scope, itemDefaults);\n if (item.defaultRoutes) {\n routeDefaults(scope, item.defaultRoutes);\n }\n if (item.descriptors) {\n defaults.describe(scope, item.descriptors);\n }\n}\nfunction routeDefaults(scope, routes) {\n Object.keys(routes).forEach(property => {\n const propertyParts = property.split('.');\n const sourceName = propertyParts.pop();\n const sourceScope = [scope].concat(propertyParts).join('.');\n const parts = routes[property].split('.');\n const targetName = parts.pop();\n const targetScope = parts.join('.');\n defaults.route(sourceScope, sourceName, targetScope, targetName);\n });\n}\nfunction isIChartComponent(proto) {\n return 'id' in proto && 'defaults' in proto;\n}\nclass Registry {\n constructor() {\n this.controllers = new TypedRegistry(DatasetController, 'datasets', true);\n this.elements = new TypedRegistry(Element, 'elements');\n this.plugins = new TypedRegistry(Object, 'plugins');\n this.scales = new TypedRegistry(Scale, 'scales');\n this._typedRegistries = [this.controllers, this.scales, this.elements];\n }\n add(...args) {\n this._each('register', args);\n }\n remove(...args) {\n this._each('unregister', args);\n }\n addControllers(...args) {\n this._each('register', args, this.controllers);\n }\n addElements(...args) {\n this._each('register', args, this.elements);\n }\n addPlugins(...args) {\n this._each('register', args, this.plugins);\n }\n addScales(...args) {\n this._each('register', args, this.scales);\n }\n getController(id) {\n return this._get(id, this.controllers, 'controller');\n }\n getElement(id) {\n return this._get(id, this.elements, 'element');\n }\n getPlugin(id) {\n return this._get(id, this.plugins, 'plugin');\n }\n getScale(id) {\n return this._get(id, this.scales, 'scale');\n }\n removeControllers(...args) {\n this._each('unregister', args, this.controllers);\n }\n removeElements(...args) {\n this._each('unregister', args, this.elements);\n }\n removePlugins(...args) {\n this._each('unregister', args, this.plugins);\n }\n removeScales(...args) {\n this._each('unregister', args, this.scales);\n }\n _each(method, args, typedRegistry) {\n [...args].forEach(arg => {\n const reg = typedRegistry || this._getRegistryForType(arg);\n if (typedRegistry || reg.isForType(arg) || reg === this.plugins && arg.id) {\n this._exec(method, reg, arg);\n } else {\n each(arg, item => {\n const itemReg = typedRegistry || this._getRegistryForType(item);\n this._exec(method, itemReg, item);\n });\n }\n });\n }\n _exec(method, registry, component) {\n const camelMethod = _capitalize(method);\n callback(component['before' + camelMethod], [], component);\n registry[method](component);\n callback(component['after' + camelMethod], [], component);\n }\n _getRegistryForType(type) {\n for (let i = 0; i < this._typedRegistries.length; i++) {\n const reg = this._typedRegistries[i];\n if (reg.isForType(type)) {\n return reg;\n }\n }\n return this.plugins;\n }\n _get(id, typedRegistry, type) {\n const item = typedRegistry.get(id);\n if (item === undefined) {\n throw new Error('\"' + id + '\" is not a registered ' + type + '.');\n }\n return item;\n }\n}\nvar registry = /* #__PURE__ */new Registry();\nclass PluginService {\n constructor() {\n this._init = [];\n }\n notify(chart, hook, args, filter) {\n if (hook === 'beforeInit') {\n this._init = this._createDescriptors(chart, true);\n this._notify(this._init, chart, 'install');\n }\n const descriptors = filter ? this._descriptors(chart).filter(filter) : this._descriptors(chart);\n const result = this._notify(descriptors, chart, hook, args);\n if (hook === 'afterDestroy') {\n this._notify(descriptors, chart, 'stop');\n this._notify(this._init, chart, 'uninstall');\n }\n return result;\n }\n _notify(descriptors, chart, hook, args) {\n args = args || {};\n for (const descriptor of descriptors) {\n const plugin = descriptor.plugin;\n const method = plugin[hook];\n const params = [chart, args, descriptor.options];\n if (callback(method, params, plugin) === false && args.cancelable) {\n return false;\n }\n }\n return true;\n }\n invalidate() {\n if (!isNullOrUndef(this._cache)) {\n this._oldCache = this._cache;\n this._cache = undefined;\n }\n }\n _descriptors(chart) {\n if (this._cache) {\n return this._cache;\n }\n const descriptors = this._cache = this._createDescriptors(chart);\n this._notifyStateChanges(chart);\n return descriptors;\n }\n _createDescriptors(chart, all) {\n const config = chart && chart.config;\n const options = valueOrDefault(config.options && config.options.plugins, {});\n const plugins = allPlugins(config);\n return options === false && !all ? [] : createDescriptors(chart, plugins, options, all);\n }\n _notifyStateChanges(chart) {\n const previousDescriptors = this._oldCache || [];\n const descriptors = this._cache;\n const diff = (a, b) => a.filter(x => !b.some(y => x.plugin.id === y.plugin.id));\n this._notify(diff(previousDescriptors, descriptors), chart, 'stop');\n this._notify(diff(descriptors, previousDescriptors), chart, 'start');\n }\n}\nfunction allPlugins(config) {\n const localIds = {};\n const plugins = [];\n const keys = Object.keys(registry.plugins.items);\n for (let i = 0; i < keys.length; i++) {\n plugins.push(registry.getPlugin(keys[i]));\n }\n const local = config.plugins || [];\n for (let i = 0; i < local.length; i++) {\n const plugin = local[i];\n if (plugins.indexOf(plugin) === -1) {\n plugins.push(plugin);\n localIds[plugin.id] = true;\n }\n }\n return {\n plugins,\n localIds\n };\n}\nfunction getOpts(options, all) {\n if (!all && options === false) {\n return null;\n }\n if (options === true) {\n return {};\n }\n return options;\n}\nfunction createDescriptors(chart, {\n plugins,\n localIds\n}, options, all) {\n const result = [];\n const context = chart.getContext();\n for (const plugin of plugins) {\n const id = plugin.id;\n const opts = getOpts(options[id], all);\n if (opts === null) {\n continue;\n }\n result.push({\n plugin,\n options: pluginOpts(chart.config, {\n plugin,\n local: localIds[id]\n }, opts, context)\n });\n }\n return result;\n}\nfunction pluginOpts(config, {\n plugin,\n local\n}, opts, context) {\n const keys = config.pluginScopeKeys(plugin);\n const scopes = config.getOptionScopes(opts, keys);\n if (local && plugin.defaults) {\n scopes.push(plugin.defaults);\n }\n return config.createResolver(scopes, context, [''], {\n scriptable: false,\n indexable: false,\n allKeys: true\n });\n}\nfunction getIndexAxis(type, options) {\n const datasetDefaults = defaults.datasets[type] || {};\n const datasetOptions = (options.datasets || {})[type] || {};\n return datasetOptions.indexAxis || options.indexAxis || datasetDefaults.indexAxis || 'x';\n}\nfunction getAxisFromDefaultScaleID(id, indexAxis) {\n let axis = id;\n if (id === '_index_') {\n axis = indexAxis;\n } else if (id === '_value_') {\n axis = indexAxis === 'x' ? 'y' : 'x';\n }\n return axis;\n}\nfunction getDefaultScaleIDFromAxis(axis, indexAxis) {\n return axis === indexAxis ? '_index_' : '_value_';\n}\nfunction idMatchesAxis(id) {\n if (id === 'x' || id === 'y' || id === 'r') {\n return id;\n }\n}\nfunction axisFromPosition(position) {\n if (position === 'top' || position === 'bottom') {\n return 'x';\n }\n if (position === 'left' || position === 'right') {\n return 'y';\n }\n}\nfunction determineAxis(id, ...scaleOptions) {\n if (idMatchesAxis(id)) {\n return id;\n }\n for (const opts of scaleOptions) {\n const axis = opts.axis || axisFromPosition(opts.position) || id.length > 1 && idMatchesAxis(id[0].toLowerCase());\n if (axis) {\n return axis;\n }\n }\n throw new Error(`Cannot determine type of '${id}' axis. Please provide 'axis' or 'position' option.`);\n}\nfunction getAxisFromDataset(id, axis, dataset) {\n if (dataset[axis + 'AxisID'] === id) {\n return {\n axis\n };\n }\n}\nfunction retrieveAxisFromDatasets(id, config) {\n if (config.data && config.data.datasets) {\n const boundDs = config.data.datasets.filter(d => d.xAxisID === id || d.yAxisID === id);\n if (boundDs.length) {\n return getAxisFromDataset(id, 'x', boundDs[0]) || getAxisFromDataset(id, 'y', boundDs[0]);\n }\n }\n return {};\n}\nfunction mergeScaleConfig(config, options) {\n const chartDefaults = overrides[config.type] || {\n scales: {}\n };\n const configScales = options.scales || {};\n const chartIndexAxis = getIndexAxis(config.type, options);\n const scales = Object.create(null);\n Object.keys(configScales).forEach(id => {\n const scaleConf = configScales[id];\n if (!isObject(scaleConf)) {\n return console.error(`Invalid scale configuration for scale: ${id}`);\n }\n if (scaleConf._proxy) {\n return console.warn(`Ignoring resolver passed as options for scale: ${id}`);\n }\n const axis = determineAxis(id, scaleConf, retrieveAxisFromDatasets(id, config), defaults.scales[scaleConf.type]);\n const defaultId = getDefaultScaleIDFromAxis(axis, chartIndexAxis);\n const defaultScaleOptions = chartDefaults.scales || {};\n scales[id] = mergeIf(Object.create(null), [{\n axis\n }, scaleConf, defaultScaleOptions[axis], defaultScaleOptions[defaultId]]);\n });\n config.data.datasets.forEach(dataset => {\n const type = dataset.type || config.type;\n const indexAxis = dataset.indexAxis || getIndexAxis(type, options);\n const datasetDefaults = overrides[type] || {};\n const defaultScaleOptions = datasetDefaults.scales || {};\n Object.keys(defaultScaleOptions).forEach(defaultID => {\n const axis = getAxisFromDefaultScaleID(defaultID, indexAxis);\n const id = dataset[axis + 'AxisID'] || axis;\n scales[id] = scales[id] || Object.create(null);\n mergeIf(scales[id], [{\n axis\n }, configScales[id], defaultScaleOptions[defaultID]]);\n });\n });\n Object.keys(scales).forEach(key => {\n const scale = scales[key];\n mergeIf(scale, [defaults.scales[scale.type], defaults.scale]);\n });\n return scales;\n}\nfunction initOptions(config) {\n const options = config.options || (config.options = {});\n options.plugins = valueOrDefault(options.plugins, {});\n options.scales = mergeScaleConfig(config, options);\n}\nfunction initData(data) {\n data = data || {};\n data.datasets = data.datasets || [];\n data.labels = data.labels || [];\n return data;\n}\nfunction initConfig(config) {\n config = config || {};\n config.data = initData(config.data);\n initOptions(config);\n return config;\n}\nconst keyCache = new Map();\nconst keysCached = new Set();\nfunction cachedKeys(cacheKey, generate) {\n let keys = keyCache.get(cacheKey);\n if (!keys) {\n keys = generate();\n keyCache.set(cacheKey, keys);\n keysCached.add(keys);\n }\n return keys;\n}\nconst addIfFound = (set, obj, key) => {\n const opts = resolveObjectKey(obj, key);\n if (opts !== undefined) {\n set.add(opts);\n }\n};\nclass Config {\n constructor(config) {\n this._config = initConfig(config);\n this._scopeCache = new Map();\n this._resolverCache = new Map();\n }\n get platform() {\n return this._config.platform;\n }\n get type() {\n return this._config.type;\n }\n set type(type) {\n this._config.type = type;\n }\n get data() {\n return this._config.data;\n }\n set data(data) {\n this._config.data = initData(data);\n }\n get options() {\n return this._config.options;\n }\n set options(options) {\n this._config.options = options;\n }\n get plugins() {\n return this._config.plugins;\n }\n update() {\n const config = this._config;\n this.clearCache();\n initOptions(config);\n }\n clearCache() {\n this._scopeCache.clear();\n this._resolverCache.clear();\n }\n datasetScopeKeys(datasetType) {\n return cachedKeys(datasetType, () => [[`datasets.${datasetType}`, '']]);\n }\n datasetAnimationScopeKeys(datasetType, transition) {\n return cachedKeys(`${datasetType}.transition.${transition}`, () => [[`datasets.${datasetType}.transitions.${transition}`, `transitions.${transition}`], [`datasets.${datasetType}`, '']]);\n }\n datasetElementScopeKeys(datasetType, elementType) {\n return cachedKeys(`${datasetType}-${elementType}`, () => [[`datasets.${datasetType}.elements.${elementType}`, `datasets.${datasetType}`, `elements.${elementType}`, '']]);\n }\n pluginScopeKeys(plugin) {\n const id = plugin.id;\n const type = this.type;\n return cachedKeys(`${type}-plugin-${id}`, () => [[`plugins.${id}`, ...(plugin.additionalOptionScopes || [])]]);\n }\n _cachedScopes(mainScope, resetCache) {\n const _scopeCache = this._scopeCache;\n let cache = _scopeCache.get(mainScope);\n if (!cache || resetCache) {\n cache = new Map();\n _scopeCache.set(mainScope, cache);\n }\n return cache;\n }\n getOptionScopes(mainScope, keyLists, resetCache) {\n const {\n options,\n type\n } = this;\n const cache = this._cachedScopes(mainScope, resetCache);\n const cached = cache.get(keyLists);\n if (cached) {\n return cached;\n }\n const scopes = new Set();\n keyLists.forEach(keys => {\n if (mainScope) {\n scopes.add(mainScope);\n keys.forEach(key => addIfFound(scopes, mainScope, key));\n }\n keys.forEach(key => addIfFound(scopes, options, key));\n keys.forEach(key => addIfFound(scopes, overrides[type] || {}, key));\n keys.forEach(key => addIfFound(scopes, defaults, key));\n keys.forEach(key => addIfFound(scopes, descriptors, key));\n });\n const array = Array.from(scopes);\n if (array.length === 0) {\n array.push(Object.create(null));\n }\n if (keysCached.has(keyLists)) {\n cache.set(keyLists, array);\n }\n return array;\n }\n chartOptionScopes() {\n const {\n options,\n type\n } = this;\n return [options, overrides[type] || {}, defaults.datasets[type] || {}, {\n type\n }, defaults, descriptors];\n }\n resolveNamedOptions(scopes, names, context, prefixes = ['']) {\n const result = {\n $shared: true\n };\n const {\n resolver,\n subPrefixes\n } = getResolver(this._resolverCache, scopes, prefixes);\n let options = resolver;\n if (needContext(resolver, names)) {\n result.$shared = false;\n context = isFunction(context) ? context() : context;\n const subResolver = this.createResolver(scopes, context, subPrefixes);\n options = _attachContext(resolver, context, subResolver);\n }\n for (const prop of names) {\n result[prop] = options[prop];\n }\n return result;\n }\n createResolver(scopes, context, prefixes = [''], descriptorDefaults) {\n const {\n resolver\n } = getResolver(this._resolverCache, scopes, prefixes);\n return isObject(context) ? _attachContext(resolver, context, undefined, descriptorDefaults) : resolver;\n }\n}\nfunction getResolver(resolverCache, scopes, prefixes) {\n let cache = resolverCache.get(scopes);\n if (!cache) {\n cache = new Map();\n resolverCache.set(scopes, cache);\n }\n const cacheKey = prefixes.join();\n let cached = cache.get(cacheKey);\n if (!cached) {\n const resolver = _createResolver(scopes, prefixes);\n cached = {\n resolver,\n subPrefixes: prefixes.filter(p => !p.toLowerCase().includes('hover'))\n };\n cache.set(cacheKey, cached);\n }\n return cached;\n}\nconst hasFunction = value => isObject(value) && Object.getOwnPropertyNames(value).some(key => isFunction(value[key]));\nfunction needContext(proxy, names) {\n const {\n isScriptable,\n isIndexable\n } = _descriptors(proxy);\n for (const prop of names) {\n const scriptable = isScriptable(prop);\n const indexable = isIndexable(prop);\n const value = (indexable || scriptable) && proxy[prop];\n if (scriptable && (isFunction(value) || hasFunction(value)) || indexable && isArray(value)) {\n return true;\n }\n }\n return false;\n}\nvar version = \"4.4.7\";\nconst KNOWN_POSITIONS = ['top', 'bottom', 'left', 'right', 'chartArea'];\nfunction positionIsHorizontal(position, axis) {\n return position === 'top' || position === 'bottom' || KNOWN_POSITIONS.indexOf(position) === -1 && axis === 'x';\n}\nfunction compare2Level(l1, l2) {\n return function (a, b) {\n return a[l1] === b[l1] ? a[l2] - b[l2] : a[l1] - b[l1];\n };\n}\nfunction onAnimationsComplete(context) {\n const chart = context.chart;\n const animationOptions = chart.options.animation;\n chart.notifyPlugins('afterRender');\n callback(animationOptions && animationOptions.onComplete, [context], chart);\n}\nfunction onAnimationProgress(context) {\n const chart = context.chart;\n const animationOptions = chart.options.animation;\n callback(animationOptions && animationOptions.onProgress, [context], chart);\n}\nfunction getCanvas(item) {\n if (_isDomSupported() && typeof item === 'string') {\n item = document.getElementById(item);\n } else if (item && item.length) {\n item = item[0];\n }\n if (item && item.canvas) {\n item = item.canvas;\n }\n return item;\n}\nconst instances = {};\nconst getChart = key => {\n const canvas = getCanvas(key);\n return Object.values(instances).filter(c => c.canvas === canvas).pop();\n};\nfunction moveNumericKeys(obj, start, move) {\n const keys = Object.keys(obj);\n for (const key of keys) {\n const intKey = +key;\n if (intKey >= start) {\n const value = obj[key];\n delete obj[key];\n if (move > 0 || intKey > start) {\n obj[intKey + move] = value;\n }\n }\n }\n}\nfunction determineLastEvent(e, lastEvent, inChartArea, isClick) {\n if (!inChartArea || e.type === 'mouseout') {\n return null;\n }\n if (isClick) {\n return lastEvent;\n }\n return e;\n}\nfunction getSizeForArea(scale, chartArea, field) {\n return scale.options.clip ? scale[field] : chartArea[field];\n}\nfunction getDatasetArea(meta, chartArea) {\n const {\n xScale,\n yScale\n } = meta;\n if (xScale && yScale) {\n return {\n left: getSizeForArea(xScale, chartArea, 'left'),\n right: getSizeForArea(xScale, chartArea, 'right'),\n top: getSizeForArea(yScale, chartArea, 'top'),\n bottom: getSizeForArea(yScale, chartArea, 'bottom')\n };\n }\n return chartArea;\n}\nlet Chart = /*#__PURE__*/(() => {\n class Chart {\n static defaults = defaults;\n static instances = instances;\n static overrides = overrides;\n static registry = registry;\n static version = version;\n static getChart = getChart;\n static register(...items) {\n registry.add(...items);\n invalidatePlugins();\n }\n static unregister(...items) {\n registry.remove(...items);\n invalidatePlugins();\n }\n constructor(item, userConfig) {\n const config = this.config = new Config(userConfig);\n const initialCanvas = getCanvas(item);\n const existingChart = getChart(initialCanvas);\n if (existingChart) {\n throw new Error('Canvas is already in use. Chart with ID \\'' + existingChart.id + '\\'' + ' must be destroyed before the canvas with ID \\'' + existingChart.canvas.id + '\\' can be reused.');\n }\n const options = config.createResolver(config.chartOptionScopes(), this.getContext());\n this.platform = new (config.platform || _detectPlatform(initialCanvas))();\n this.platform.updateConfig(config);\n const context = this.platform.acquireContext(initialCanvas, options.aspectRatio);\n const canvas = context && context.canvas;\n const height = canvas && canvas.height;\n const width = canvas && canvas.width;\n this.id = uid();\n this.ctx = context;\n this.canvas = canvas;\n this.width = width;\n this.height = height;\n this._options = options;\n this._aspectRatio = this.aspectRatio;\n this._layers = [];\n this._metasets = [];\n this._stacks = undefined;\n this.boxes = [];\n this.currentDevicePixelRatio = undefined;\n this.chartArea = undefined;\n this._active = [];\n this._lastEvent = undefined;\n this._listeners = {};\n this._responsiveListeners = undefined;\n this._sortedMetasets = [];\n this.scales = {};\n this._plugins = new PluginService();\n this.$proxies = {};\n this._hiddenIndices = {};\n this.attached = false;\n this._animationsDisabled = undefined;\n this.$context = undefined;\n this._doResize = debounce(mode => this.update(mode), options.resizeDelay || 0);\n this._dataChanges = [];\n instances[this.id] = this;\n if (!context || !canvas) {\n console.error(\"Failed to create chart: can't acquire context from the given item\");\n return;\n }\n animator.listen(this, 'complete', onAnimationsComplete);\n animator.listen(this, 'progress', onAnimationProgress);\n this._initialize();\n if (this.attached) {\n this.update();\n }\n }\n get aspectRatio() {\n const {\n options: {\n aspectRatio,\n maintainAspectRatio\n },\n width,\n height,\n _aspectRatio\n } = this;\n if (!isNullOrUndef(aspectRatio)) {\n return aspectRatio;\n }\n if (maintainAspectRatio && _aspectRatio) {\n return _aspectRatio;\n }\n return height ? width / height : null;\n }\n get data() {\n return this.config.data;\n }\n set data(data) {\n this.config.data = data;\n }\n get options() {\n return this._options;\n }\n set options(options) {\n this.config.options = options;\n }\n get registry() {\n return registry;\n }\n _initialize() {\n this.notifyPlugins('beforeInit');\n if (this.options.responsive) {\n this.resize();\n } else {\n retinaScale(this, this.options.devicePixelRatio);\n }\n this.bindEvents();\n this.notifyPlugins('afterInit');\n return this;\n }\n clear() {\n clearCanvas(this.canvas, this.ctx);\n return this;\n }\n stop() {\n animator.stop(this);\n return this;\n }\n resize(width, height) {\n if (!animator.running(this)) {\n this._resize(width, height);\n } else {\n this._resizeBeforeDraw = {\n width,\n height\n };\n }\n }\n _resize(width, height) {\n const options = this.options;\n const canvas = this.canvas;\n const aspectRatio = options.maintainAspectRatio && this.aspectRatio;\n const newSize = this.platform.getMaximumSize(canvas, width, height, aspectRatio);\n const newRatio = options.devicePixelRatio || this.platform.getDevicePixelRatio();\n const mode = this.width ? 'resize' : 'attach';\n this.width = newSize.width;\n this.height = newSize.height;\n this._aspectRatio = this.aspectRatio;\n if (!retinaScale(this, newRatio, true)) {\n return;\n }\n this.notifyPlugins('resize', {\n size: newSize\n });\n callback(options.onResize, [this, newSize], this);\n if (this.attached) {\n if (this._doResize(mode)) {\n this.render();\n }\n }\n }\n ensureScalesHaveIDs() {\n const options = this.options;\n const scalesOptions = options.scales || {};\n each(scalesOptions, (axisOptions, axisID) => {\n axisOptions.id = axisID;\n });\n }\n buildOrUpdateScales() {\n const options = this.options;\n const scaleOpts = options.scales;\n const scales = this.scales;\n const updated = Object.keys(scales).reduce((obj, id) => {\n obj[id] = false;\n return obj;\n }, {});\n let items = [];\n if (scaleOpts) {\n items = items.concat(Object.keys(scaleOpts).map(id => {\n const scaleOptions = scaleOpts[id];\n const axis = determineAxis(id, scaleOptions);\n const isRadial = axis === 'r';\n const isHorizontal = axis === 'x';\n return {\n options: scaleOptions,\n dposition: isRadial ? 'chartArea' : isHorizontal ? 'bottom' : 'left',\n dtype: isRadial ? 'radialLinear' : isHorizontal ? 'category' : 'linear'\n };\n }));\n }\n each(items, item => {\n const scaleOptions = item.options;\n const id = scaleOptions.id;\n const axis = determineAxis(id, scaleOptions);\n const scaleType = valueOrDefault(scaleOptions.type, item.dtype);\n if (scaleOptions.position === undefined || positionIsHorizontal(scaleOptions.position, axis) !== positionIsHorizontal(item.dposition)) {\n scaleOptions.position = item.dposition;\n }\n updated[id] = true;\n let scale = null;\n if (id in scales && scales[id].type === scaleType) {\n scale = scales[id];\n } else {\n const scaleClass = registry.getScale(scaleType);\n scale = new scaleClass({\n id,\n type: scaleType,\n ctx: this.ctx,\n chart: this\n });\n scales[scale.id] = scale;\n }\n scale.init(scaleOptions, options);\n });\n each(updated, (hasUpdated, id) => {\n if (!hasUpdated) {\n delete scales[id];\n }\n });\n each(scales, scale => {\n layouts.configure(this, scale, scale.options);\n layouts.addBox(this, scale);\n });\n }\n _updateMetasets() {\n const metasets = this._metasets;\n const numData = this.data.datasets.length;\n const numMeta = metasets.length;\n metasets.sort((a, b) => a.index - b.index);\n if (numMeta > numData) {\n for (let i = numData; i < numMeta; ++i) {\n this._destroyDatasetMeta(i);\n }\n metasets.splice(numData, numMeta - numData);\n }\n this._sortedMetasets = metasets.slice(0).sort(compare2Level('order', 'index'));\n }\n _removeUnreferencedMetasets() {\n const {\n _metasets: metasets,\n data: {\n datasets\n }\n } = this;\n if (metasets.length > datasets.length) {\n delete this._stacks;\n }\n metasets.forEach((meta, index) => {\n if (datasets.filter(x => x === meta._dataset).length === 0) {\n this._destroyDatasetMeta(index);\n }\n });\n }\n buildOrUpdateControllers() {\n const newControllers = [];\n const datasets = this.data.datasets;\n let i, ilen;\n this._removeUnreferencedMetasets();\n for (i = 0, ilen = datasets.length; i < ilen; i++) {\n const dataset = datasets[i];\n let meta = this.getDatasetMeta(i);\n const type = dataset.type || this.config.type;\n if (meta.type && meta.type !== type) {\n this._destroyDatasetMeta(i);\n meta = this.getDatasetMeta(i);\n }\n meta.type = type;\n meta.indexAxis = dataset.indexAxis || getIndexAxis(type, this.options);\n meta.order = dataset.order || 0;\n meta.index = i;\n meta.label = '' + dataset.label;\n meta.visible = this.isDatasetVisible(i);\n if (meta.controller) {\n meta.controller.updateIndex(i);\n meta.controller.linkScales();\n } else {\n const ControllerClass = registry.getController(type);\n const {\n datasetElementType,\n dataElementType\n } = defaults.datasets[type];\n Object.assign(ControllerClass, {\n dataElementType: registry.getElement(dataElementType),\n datasetElementType: datasetElementType && registry.getElement(datasetElementType)\n });\n meta.controller = new ControllerClass(this, i);\n newControllers.push(meta.controller);\n }\n }\n this._updateMetasets();\n return newControllers;\n }\n _resetElements() {\n each(this.data.datasets, (dataset, datasetIndex) => {\n this.getDatasetMeta(datasetIndex).controller.reset();\n }, this);\n }\n reset() {\n this._resetElements();\n this.notifyPlugins('reset');\n }\n update(mode) {\n const config = this.config;\n config.update();\n const options = this._options = config.createResolver(config.chartOptionScopes(), this.getContext());\n const animsDisabled = this._animationsDisabled = !options.animation;\n this._updateScales();\n this._checkEventBindings();\n this._updateHiddenIndices();\n this._plugins.invalidate();\n if (this.notifyPlugins('beforeUpdate', {\n mode,\n cancelable: true\n }) === false) {\n return;\n }\n const newControllers = this.buildOrUpdateControllers();\n this.notifyPlugins('beforeElementsUpdate');\n let minPadding = 0;\n for (let i = 0, ilen = this.data.datasets.length; i < ilen; i++) {\n const {\n controller\n } = this.getDatasetMeta(i);\n const reset = !animsDisabled && newControllers.indexOf(controller) === -1;\n controller.buildOrUpdateElements(reset);\n minPadding = Math.max(+controller.getMaxOverflow(), minPadding);\n }\n minPadding = this._minPadding = options.layout.autoPadding ? minPadding : 0;\n this._updateLayout(minPadding);\n if (!animsDisabled) {\n each(newControllers, controller => {\n controller.reset();\n });\n }\n this._updateDatasets(mode);\n this.notifyPlugins('afterUpdate', {\n mode\n });\n this._layers.sort(compare2Level('z', '_idx'));\n const {\n _active,\n _lastEvent\n } = this;\n if (_lastEvent) {\n this._eventHandler(_lastEvent, true);\n } else if (_active.length) {\n this._updateHoverStyles(_active, _active, true);\n }\n this.render();\n }\n _updateScales() {\n each(this.scales, scale => {\n layouts.removeBox(this, scale);\n });\n this.ensureScalesHaveIDs();\n this.buildOrUpdateScales();\n }\n _checkEventBindings() {\n const options = this.options;\n const existingEvents = new Set(Object.keys(this._listeners));\n const newEvents = new Set(options.events);\n if (!setsEqual(existingEvents, newEvents) || !!this._responsiveListeners !== options.responsive) {\n this.unbindEvents();\n this.bindEvents();\n }\n }\n _updateHiddenIndices() {\n const {\n _hiddenIndices\n } = this;\n const changes = this._getUniformDataChanges() || [];\n for (const {\n method,\n start,\n count\n } of changes) {\n const move = method === '_removeElements' ? -count : count;\n moveNumericKeys(_hiddenIndices, start, move);\n }\n }\n _getUniformDataChanges() {\n const _dataChanges = this._dataChanges;\n if (!_dataChanges || !_dataChanges.length) {\n return;\n }\n this._dataChanges = [];\n const datasetCount = this.data.datasets.length;\n const makeSet = idx => new Set(_dataChanges.filter(c => c[0] === idx).map((c, i) => i + ',' + c.splice(1).join(',')));\n const changeSet = makeSet(0);\n for (let i = 1; i < datasetCount; i++) {\n if (!setsEqual(changeSet, makeSet(i))) {\n return;\n }\n }\n return Array.from(changeSet).map(c => c.split(',')).map(a => ({\n method: a[1],\n start: +a[2],\n count: +a[3]\n }));\n }\n _updateLayout(minPadding) {\n if (this.notifyPlugins('beforeLayout', {\n cancelable: true\n }) === false) {\n return;\n }\n layouts.update(this, this.width, this.height, minPadding);\n const area = this.chartArea;\n const noArea = area.width <= 0 || area.height <= 0;\n this._layers = [];\n each(this.boxes, box => {\n if (noArea && box.position === 'chartArea') {\n return;\n }\n if (box.configure) {\n box.configure();\n }\n this._layers.push(...box._layers());\n }, this);\n this._layers.forEach((item, index) => {\n item._idx = index;\n });\n this.notifyPlugins('afterLayout');\n }\n _updateDatasets(mode) {\n if (this.notifyPlugins('beforeDatasetsUpdate', {\n mode,\n cancelable: true\n }) === false) {\n return;\n }\n for (let i = 0, ilen = this.data.datasets.length; i < ilen; ++i) {\n this.getDatasetMeta(i).controller.configure();\n }\n for (let i = 0, ilen = this.data.datasets.length; i < ilen; ++i) {\n this._updateDataset(i, isFunction(mode) ? mode({\n datasetIndex: i\n }) : mode);\n }\n this.notifyPlugins('afterDatasetsUpdate', {\n mode\n });\n }\n _updateDataset(index, mode) {\n const meta = this.getDatasetMeta(index);\n const args = {\n meta,\n index,\n mode,\n cancelable: true\n };\n if (this.notifyPlugins('beforeDatasetUpdate', args) === false) {\n return;\n }\n meta.controller._update(mode);\n args.cancelable = false;\n this.notifyPlugins('afterDatasetUpdate', args);\n }\n render() {\n if (this.notifyPlugins('beforeRender', {\n cancelable: true\n }) === false) {\n return;\n }\n if (animator.has(this)) {\n if (this.attached && !animator.running(this)) {\n animator.start(this);\n }\n } else {\n this.draw();\n onAnimationsComplete({\n chart: this\n });\n }\n }\n draw() {\n let i;\n if (this._resizeBeforeDraw) {\n const {\n width,\n height\n } = this._resizeBeforeDraw;\n this._resizeBeforeDraw = null;\n this._resize(width, height);\n }\n this.clear();\n if (this.width <= 0 || this.height <= 0) {\n return;\n }\n if (this.notifyPlugins('beforeDraw', {\n cancelable: true\n }) === false) {\n return;\n }\n const layers = this._layers;\n for (i = 0; i < layers.length && layers[i].z <= 0; ++i) {\n layers[i].draw(this.chartArea);\n }\n this._drawDatasets();\n for (; i < layers.length; ++i) {\n layers[i].draw(this.chartArea);\n }\n this.notifyPlugins('afterDraw');\n }\n _getSortedDatasetMetas(filterVisible) {\n const metasets = this._sortedMetasets;\n const result = [];\n let i, ilen;\n for (i = 0, ilen = metasets.length; i < ilen; ++i) {\n const meta = metasets[i];\n if (!filterVisible || meta.visible) {\n result.push(meta);\n }\n }\n return result;\n }\n getSortedVisibleDatasetMetas() {\n return this._getSortedDatasetMetas(true);\n }\n _drawDatasets() {\n if (this.notifyPlugins('beforeDatasetsDraw', {\n cancelable: true\n }) === false) {\n return;\n }\n const metasets = this.getSortedVisibleDatasetMetas();\n for (let i = metasets.length - 1; i >= 0; --i) {\n this._drawDataset(metasets[i]);\n }\n this.notifyPlugins('afterDatasetsDraw');\n }\n _drawDataset(meta) {\n const ctx = this.ctx;\n const clip = meta._clip;\n const useClip = !clip.disabled;\n const area = getDatasetArea(meta, this.chartArea);\n const args = {\n meta,\n index: meta.index,\n cancelable: true\n };\n if (this.notifyPlugins('beforeDatasetDraw', args) === false) {\n return;\n }\n if (useClip) {\n clipArea(ctx, {\n left: clip.left === false ? 0 : area.left - clip.left,\n right: clip.right === false ? this.width : area.right + clip.right,\n top: clip.top === false ? 0 : area.top - clip.top,\n bottom: clip.bottom === false ? this.height : area.bottom + clip.bottom\n });\n }\n meta.controller.draw();\n if (useClip) {\n unclipArea(ctx);\n }\n args.cancelable = false;\n this.notifyPlugins('afterDatasetDraw', args);\n }\n isPointInArea(point) {\n return _isPointInArea(point, this.chartArea, this._minPadding);\n }\n getElementsAtEventForMode(e, mode, options, useFinalPosition) {\n const method = Interaction.modes[mode];\n if (typeof method === 'function') {\n return method(this, e, options, useFinalPosition);\n }\n return [];\n }\n getDatasetMeta(datasetIndex) {\n const dataset = this.data.datasets[datasetIndex];\n const metasets = this._metasets;\n let meta = metasets.filter(x => x && x._dataset === dataset).pop();\n if (!meta) {\n meta = {\n type: null,\n data: [],\n dataset: null,\n controller: null,\n hidden: null,\n xAxisID: null,\n yAxisID: null,\n order: dataset && dataset.order || 0,\n index: datasetIndex,\n _dataset: dataset,\n _parsed: [],\n _sorted: false\n };\n metasets.push(meta);\n }\n return meta;\n }\n getContext() {\n return this.$context || (this.$context = createContext(null, {\n chart: this,\n type: 'chart'\n }));\n }\n getVisibleDatasetCount() {\n return this.getSortedVisibleDatasetMetas().length;\n }\n isDatasetVisible(datasetIndex) {\n const dataset = this.data.datasets[datasetIndex];\n if (!dataset) {\n return false;\n }\n const meta = this.getDatasetMeta(datasetIndex);\n return typeof meta.hidden === 'boolean' ? !meta.hidden : !dataset.hidden;\n }\n setDatasetVisibility(datasetIndex, visible) {\n const meta = this.getDatasetMeta(datasetIndex);\n meta.hidden = !visible;\n }\n toggleDataVisibility(index) {\n this._hiddenIndices[index] = !this._hiddenIndices[index];\n }\n getDataVisibility(index) {\n return !this._hiddenIndices[index];\n }\n _updateVisibility(datasetIndex, dataIndex, visible) {\n const mode = visible ? 'show' : 'hide';\n const meta = this.getDatasetMeta(datasetIndex);\n const anims = meta.controller._resolveAnimations(undefined, mode);\n if (defined(dataIndex)) {\n meta.data[dataIndex].hidden = !visible;\n this.update();\n } else {\n this.setDatasetVisibility(datasetIndex, visible);\n anims.update(meta, {\n visible\n });\n this.update(ctx => ctx.datasetIndex === datasetIndex ? mode : undefined);\n }\n }\n hide(datasetIndex, dataIndex) {\n this._updateVisibility(datasetIndex, dataIndex, false);\n }\n show(datasetIndex, dataIndex) {\n this._updateVisibility(datasetIndex, dataIndex, true);\n }\n _destroyDatasetMeta(datasetIndex) {\n const meta = this._metasets[datasetIndex];\n if (meta && meta.controller) {\n meta.controller._destroy();\n }\n delete this._metasets[datasetIndex];\n }\n _stop() {\n let i, ilen;\n this.stop();\n animator.remove(this);\n for (i = 0, ilen = this.data.datasets.length; i < ilen; ++i) {\n this._destroyDatasetMeta(i);\n }\n }\n destroy() {\n this.notifyPlugins('beforeDestroy');\n const {\n canvas,\n ctx\n } = this;\n this._stop();\n this.config.clearCache();\n if (canvas) {\n this.unbindEvents();\n clearCanvas(canvas, ctx);\n this.platform.releaseContext(ctx);\n this.canvas = null;\n this.ctx = null;\n }\n delete instances[this.id];\n this.notifyPlugins('afterDestroy');\n }\n toBase64Image(...args) {\n return this.canvas.toDataURL(...args);\n }\n bindEvents() {\n this.bindUserEvents();\n if (this.options.responsive) {\n this.bindResponsiveEvents();\n } else {\n this.attached = true;\n }\n }\n bindUserEvents() {\n const listeners = this._listeners;\n const platform = this.platform;\n const _add = (type, listener) => {\n platform.addEventListener(this, type, listener);\n listeners[type] = listener;\n };\n const listener = (e, x, y) => {\n e.offsetX = x;\n e.offsetY = y;\n this._eventHandler(e);\n };\n each(this.options.events, type => _add(type, listener));\n }\n bindResponsiveEvents() {\n if (!this._responsiveListeners) {\n this._responsiveListeners = {};\n }\n const listeners = this._responsiveListeners;\n const platform = this.platform;\n const _add = (type, listener) => {\n platform.addEventListener(this, type, listener);\n listeners[type] = listener;\n };\n const _remove = (type, listener) => {\n if (listeners[type]) {\n platform.removeEventListener(this, type, listener);\n delete listeners[type];\n }\n };\n const listener = (width, height) => {\n if (this.canvas) {\n this.resize(width, height);\n }\n };\n let detached;\n const attached = () => {\n _remove('attach', attached);\n this.attached = true;\n this.resize();\n _add('resize', listener);\n _add('detach', detached);\n };\n detached = () => {\n this.attached = false;\n _remove('resize', listener);\n this._stop();\n this._resize(0, 0);\n _add('attach', attached);\n };\n if (platform.isAttached(this.canvas)) {\n attached();\n } else {\n detached();\n }\n }\n unbindEvents() {\n each(this._listeners, (listener, type) => {\n this.platform.removeEventListener(this, type, listener);\n });\n this._listeners = {};\n each(this._responsiveListeners, (listener, type) => {\n this.platform.removeEventListener(this, type, listener);\n });\n this._responsiveListeners = undefined;\n }\n updateHoverStyle(items, mode, enabled) {\n const prefix = enabled ? 'set' : 'remove';\n let meta, item, i, ilen;\n if (mode === 'dataset') {\n meta = this.getDatasetMeta(items[0].datasetIndex);\n meta.controller['_' + prefix + 'DatasetHoverStyle']();\n }\n for (i = 0, ilen = items.length; i < ilen; ++i) {\n item = items[i];\n const controller = item && this.getDatasetMeta(item.datasetIndex).controller;\n if (controller) {\n controller[prefix + 'HoverStyle'](item.element, item.datasetIndex, item.index);\n }\n }\n }\n getActiveElements() {\n return this._active || [];\n }\n setActiveElements(activeElements) {\n const lastActive = this._active || [];\n const active = activeElements.map(({\n datasetIndex,\n index\n }) => {\n const meta = this.getDatasetMeta(datasetIndex);\n if (!meta) {\n throw new Error('No dataset found at index ' + datasetIndex);\n }\n return {\n datasetIndex,\n element: meta.data[index],\n index\n };\n });\n const changed = !_elementsEqual(active, lastActive);\n if (changed) {\n this._active = active;\n this._lastEvent = null;\n this._updateHoverStyles(active, lastActive);\n }\n }\n notifyPlugins(hook, args, filter) {\n return this._plugins.notify(this, hook, args, filter);\n }\n isPluginEnabled(pluginId) {\n return this._plugins._cache.filter(p => p.plugin.id === pluginId).length === 1;\n }\n _updateHoverStyles(active, lastActive, replay) {\n const hoverOptions = this.options.hover;\n const diff = (a, b) => a.filter(x => !b.some(y => x.datasetIndex === y.datasetIndex && x.index === y.index));\n const deactivated = diff(lastActive, active);\n const activated = replay ? active : diff(active, lastActive);\n if (deactivated.length) {\n this.updateHoverStyle(deactivated, hoverOptions.mode, false);\n }\n if (activated.length && hoverOptions.mode) {\n this.updateHoverStyle(activated, hoverOptions.mode, true);\n }\n }\n _eventHandler(e, replay) {\n const args = {\n event: e,\n replay,\n cancelable: true,\n inChartArea: this.isPointInArea(e)\n };\n const eventFilter = plugin => (plugin.options.events || this.options.events).includes(e.native.type);\n if (this.notifyPlugins('beforeEvent', args, eventFilter) === false) {\n return;\n }\n const changed = this._handleEvent(e, replay, args.inChartArea);\n args.cancelable = false;\n this.notifyPlugins('afterEvent', args, eventFilter);\n if (changed || args.changed) {\n this.render();\n }\n return this;\n }\n _handleEvent(e, replay, inChartArea) {\n const {\n _active: lastActive = [],\n options\n } = this;\n const useFinalPosition = replay;\n const active = this._getActiveElements(e, lastActive, inChartArea, useFinalPosition);\n const isClick = _isClickEvent(e);\n const lastEvent = determineLastEvent(e, this._lastEvent, inChartArea, isClick);\n if (inChartArea) {\n this._lastEvent = null;\n callback(options.onHover, [e, active, this], this);\n if (isClick) {\n callback(options.onClick, [e, active, this], this);\n }\n }\n const changed = !_elementsEqual(active, lastActive);\n if (changed || replay) {\n this._active = active;\n this._updateHoverStyles(active, lastActive, replay);\n }\n this._lastEvent = lastEvent;\n return changed;\n }\n _getActiveElements(e, lastActive, inChartArea, useFinalPosition) {\n if (e.type === 'mouseout') {\n return [];\n }\n if (!inChartArea) {\n return lastActive;\n }\n const hoverOptions = this.options.hover;\n return this.getElementsAtEventForMode(e, hoverOptions.mode, hoverOptions, useFinalPosition);\n }\n }\n return Chart;\n})();\nfunction invalidatePlugins() {\n return each(Chart.instances, chart => chart._plugins.invalidate());\n}\nfunction clipArc(ctx, element, endAngle) {\n const {\n startAngle,\n pixelMargin,\n x,\n y,\n outerRadius,\n innerRadius\n } = element;\n let angleMargin = pixelMargin / outerRadius;\n // Draw an inner border by clipping the arc and drawing a double-width border\n // Enlarge the clipping arc by 0.33 pixels to eliminate glitches between borders\n ctx.beginPath();\n ctx.arc(x, y, outerRadius, startAngle - angleMargin, endAngle + angleMargin);\n if (innerRadius > pixelMargin) {\n angleMargin = pixelMargin / innerRadius;\n ctx.arc(x, y, innerRadius, endAngle + angleMargin, startAngle - angleMargin, true);\n } else {\n ctx.arc(x, y, pixelMargin, endAngle + HALF_PI, startAngle - HALF_PI);\n }\n ctx.closePath();\n ctx.clip();\n}\nfunction toRadiusCorners(value) {\n return _readValueToProps(value, ['outerStart', 'outerEnd', 'innerStart', 'innerEnd']);\n}\n/**\n * Parse border radius from the provided options\n */\nfunction parseBorderRadius$1(arc, innerRadius, outerRadius, angleDelta) {\n const o = toRadiusCorners(arc.options.borderRadius);\n const halfThickness = (outerRadius - innerRadius) / 2;\n const innerLimit = Math.min(halfThickness, angleDelta * innerRadius / 2);\n // Outer limits are complicated. We want to compute the available angular distance at\n // a radius of outerRadius - borderRadius because for small angular distances, this term limits.\n // We compute at r = outerRadius - borderRadius because this circle defines the center of the border corners.\n //\n // If the borderRadius is large, that value can become negative.\n // This causes the outer borders to lose their radius entirely, which is rather unexpected. To solve that, if borderRadius > outerRadius\n // we know that the thickness term will dominate and compute the limits at that point\n const computeOuterLimit = val => {\n const outerArcLimit = (outerRadius - Math.min(halfThickness, val)) * angleDelta / 2;\n return _limitValue(val, 0, Math.min(halfThickness, outerArcLimit));\n };\n return {\n outerStart: computeOuterLimit(o.outerStart),\n outerEnd: computeOuterLimit(o.outerEnd),\n innerStart: _limitValue(o.innerStart, 0, innerLimit),\n innerEnd: _limitValue(o.innerEnd, 0, innerLimit)\n };\n}\n/**\n * Convert (r, 𝜃) to (x, y)\n */\nfunction rThetaToXY(r, theta, x, y) {\n return {\n x: x + r * Math.cos(theta),\n y: y + r * Math.sin(theta)\n };\n}\n/**\n * Path the arc, respecting border radius by separating into left and right halves.\n *\n * Start End\n *\n * 1--->a--->2 Outer\n * / \\\n * 8 3\n * | |\n * | |\n * 7 4\n * \\ /\n * 6<---b<---5 Inner\n */\nfunction pathArc(ctx, element, offset, spacing, end, circular) {\n const {\n x,\n y,\n startAngle: start,\n pixelMargin,\n innerRadius: innerR\n } = element;\n const outerRadius = Math.max(element.outerRadius + spacing + offset - pixelMargin, 0);\n const innerRadius = innerR > 0 ? innerR + spacing + offset + pixelMargin : 0;\n let spacingOffset = 0;\n const alpha = end - start;\n if (spacing) {\n // When spacing is present, it is the same for all items\n // So we adjust the start and end angle of the arc such that\n // the distance is the same as it would be without the spacing\n const noSpacingInnerRadius = innerR > 0 ? innerR - spacing : 0;\n const noSpacingOuterRadius = outerRadius > 0 ? outerRadius - spacing : 0;\n const avNogSpacingRadius = (noSpacingInnerRadius + noSpacingOuterRadius) / 2;\n const adjustedAngle = avNogSpacingRadius !== 0 ? alpha * avNogSpacingRadius / (avNogSpacingRadius + spacing) : alpha;\n spacingOffset = (alpha - adjustedAngle) / 2;\n }\n const beta = Math.max(0.001, alpha * outerRadius - offset / PI) / outerRadius;\n const angleOffset = (alpha - beta) / 2;\n const startAngle = start + angleOffset + spacingOffset;\n const endAngle = end - angleOffset - spacingOffset;\n const {\n outerStart,\n outerEnd,\n innerStart,\n innerEnd\n } = parseBorderRadius$1(element, innerRadius, outerRadius, endAngle - startAngle);\n const outerStartAdjustedRadius = outerRadius - outerStart;\n const outerEndAdjustedRadius = outerRadius - outerEnd;\n const outerStartAdjustedAngle = startAngle + outerStart / outerStartAdjustedRadius;\n const outerEndAdjustedAngle = endAngle - outerEnd / outerEndAdjustedRadius;\n const innerStartAdjustedRadius = innerRadius + innerStart;\n const innerEndAdjustedRadius = innerRadius + innerEnd;\n const innerStartAdjustedAngle = startAngle + innerStart / innerStartAdjustedRadius;\n const innerEndAdjustedAngle = endAngle - innerEnd / innerEndAdjustedRadius;\n ctx.beginPath();\n if (circular) {\n // The first arc segments from point 1 to point a to point 2\n const outerMidAdjustedAngle = (outerStartAdjustedAngle + outerEndAdjustedAngle) / 2;\n ctx.arc(x, y, outerRadius, outerStartAdjustedAngle, outerMidAdjustedAngle);\n ctx.arc(x, y, outerRadius, outerMidAdjustedAngle, outerEndAdjustedAngle);\n // The corner segment from point 2 to point 3\n if (outerEnd > 0) {\n const pCenter = rThetaToXY(outerEndAdjustedRadius, outerEndAdjustedAngle, x, y);\n ctx.arc(pCenter.x, pCenter.y, outerEnd, outerEndAdjustedAngle, endAngle + HALF_PI);\n }\n // The line from point 3 to point 4\n const p4 = rThetaToXY(innerEndAdjustedRadius, endAngle, x, y);\n ctx.lineTo(p4.x, p4.y);\n // The corner segment from point 4 to point 5\n if (innerEnd > 0) {\n const pCenter = rThetaToXY(innerEndAdjustedRadius, innerEndAdjustedAngle, x, y);\n ctx.arc(pCenter.x, pCenter.y, innerEnd, endAngle + HALF_PI, innerEndAdjustedAngle + Math.PI);\n }\n // The inner arc from point 5 to point b to point 6\n const innerMidAdjustedAngle = (endAngle - innerEnd / innerRadius + (startAngle + innerStart / innerRadius)) / 2;\n ctx.arc(x, y, innerRadius, endAngle - innerEnd / innerRadius, innerMidAdjustedAngle, true);\n ctx.arc(x, y, innerRadius, innerMidAdjustedAngle, startAngle + innerStart / innerRadius, true);\n // The corner segment from point 6 to point 7\n if (innerStart > 0) {\n const pCenter = rThetaToXY(innerStartAdjustedRadius, innerStartAdjustedAngle, x, y);\n ctx.arc(pCenter.x, pCenter.y, innerStart, innerStartAdjustedAngle + Math.PI, startAngle - HALF_PI);\n }\n // The line from point 7 to point 8\n const p8 = rThetaToXY(outerStartAdjustedRadius, startAngle, x, y);\n ctx.lineTo(p8.x, p8.y);\n // The corner segment from point 8 to point 1\n if (outerStart > 0) {\n const pCenter = rThetaToXY(outerStartAdjustedRadius, outerStartAdjustedAngle, x, y);\n ctx.arc(pCenter.x, pCenter.y, outerStart, startAngle - HALF_PI, outerStartAdjustedAngle);\n }\n } else {\n ctx.moveTo(x, y);\n const outerStartX = Math.cos(outerStartAdjustedAngle) * outerRadius + x;\n const outerStartY = Math.sin(outerStartAdjustedAngle) * outerRadius + y;\n ctx.lineTo(outerStartX, outerStartY);\n const outerEndX = Math.cos(outerEndAdjustedAngle) * outerRadius + x;\n const outerEndY = Math.sin(outerEndAdjustedAngle) * outerRadius + y;\n ctx.lineTo(outerEndX, outerEndY);\n }\n ctx.closePath();\n}\nfunction drawArc(ctx, element, offset, spacing, circular) {\n const {\n fullCircles,\n startAngle,\n circumference\n } = element;\n let endAngle = element.endAngle;\n if (fullCircles) {\n pathArc(ctx, element, offset, spacing, endAngle, circular);\n for (let i = 0; i < fullCircles; ++i) {\n ctx.fill();\n }\n if (!isNaN(circumference)) {\n endAngle = startAngle + (circumference % TAU || TAU);\n }\n }\n pathArc(ctx, element, offset, spacing, endAngle, circular);\n ctx.fill();\n return endAngle;\n}\nfunction drawBorder(ctx, element, offset, spacing, circular) {\n const {\n fullCircles,\n startAngle,\n circumference,\n options\n } = element;\n const {\n borderWidth,\n borderJoinStyle,\n borderDash,\n borderDashOffset\n } = options;\n const inner = options.borderAlign === 'inner';\n if (!borderWidth) {\n return;\n }\n ctx.setLineDash(borderDash || []);\n ctx.lineDashOffset = borderDashOffset;\n if (inner) {\n ctx.lineWidth = borderWidth * 2;\n ctx.lineJoin = borderJoinStyle || 'round';\n } else {\n ctx.lineWidth = borderWidth;\n ctx.lineJoin = borderJoinStyle || 'bevel';\n }\n let endAngle = element.endAngle;\n if (fullCircles) {\n pathArc(ctx, element, offset, spacing, endAngle, circular);\n for (let i = 0; i < fullCircles; ++i) {\n ctx.stroke();\n }\n if (!isNaN(circumference)) {\n endAngle = startAngle + (circumference % TAU || TAU);\n }\n }\n if (inner) {\n clipArc(ctx, element, endAngle);\n }\n if (!fullCircles) {\n pathArc(ctx, element, offset, spacing, endAngle, circular);\n ctx.stroke();\n }\n}\nclass ArcElement extends Element {\n static id = 'arc';\n static defaults = {\n borderAlign: 'center',\n borderColor: '#fff',\n borderDash: [],\n borderDashOffset: 0,\n borderJoinStyle: undefined,\n borderRadius: 0,\n borderWidth: 2,\n offset: 0,\n spacing: 0,\n angle: undefined,\n circular: true\n };\n static defaultRoutes = {\n backgroundColor: 'backgroundColor'\n };\n static descriptors = {\n _scriptable: true,\n _indexable: name => name !== 'borderDash'\n };\n circumference;\n endAngle;\n fullCircles;\n innerRadius;\n outerRadius;\n pixelMargin;\n startAngle;\n constructor(cfg) {\n super();\n this.options = undefined;\n this.circumference = undefined;\n this.startAngle = undefined;\n this.endAngle = undefined;\n this.innerRadius = undefined;\n this.outerRadius = undefined;\n this.pixelMargin = 0;\n this.fullCircles = 0;\n if (cfg) {\n Object.assign(this, cfg);\n }\n }\n inRange(chartX, chartY, useFinalPosition) {\n const point = this.getProps(['x', 'y'], useFinalPosition);\n const {\n angle,\n distance\n } = getAngleFromPoint(point, {\n x: chartX,\n y: chartY\n });\n const {\n startAngle,\n endAngle,\n innerRadius,\n outerRadius,\n circumference\n } = this.getProps(['startAngle', 'endAngle', 'innerRadius', 'outerRadius', 'circumference'], useFinalPosition);\n const rAdjust = (this.options.spacing + this.options.borderWidth) / 2;\n const _circumference = valueOrDefault(circumference, endAngle - startAngle);\n const nonZeroBetween = _angleBetween(angle, startAngle, endAngle) && startAngle !== endAngle;\n const betweenAngles = _circumference >= TAU || nonZeroBetween;\n const withinRadius = _isBetween(distance, innerRadius + rAdjust, outerRadius + rAdjust);\n return betweenAngles && withinRadius;\n }\n getCenterPoint(useFinalPosition) {\n const {\n x,\n y,\n startAngle,\n endAngle,\n innerRadius,\n outerRadius\n } = this.getProps(['x', 'y', 'startAngle', 'endAngle', 'innerRadius', 'outerRadius'], useFinalPosition);\n const {\n offset,\n spacing\n } = this.options;\n const halfAngle = (startAngle + endAngle) / 2;\n const halfRadius = (innerRadius + outerRadius + spacing + offset) / 2;\n return {\n x: x + Math.cos(halfAngle) * halfRadius,\n y: y + Math.sin(halfAngle) * halfRadius\n };\n }\n tooltipPosition(useFinalPosition) {\n return this.getCenterPoint(useFinalPosition);\n }\n draw(ctx) {\n const {\n options,\n circumference\n } = this;\n const offset = (options.offset || 0) / 4;\n const spacing = (options.spacing || 0) / 2;\n const circular = options.circular;\n this.pixelMargin = options.borderAlign === 'inner' ? 0.33 : 0;\n this.fullCircles = circumference > TAU ? Math.floor(circumference / TAU) : 0;\n if (circumference === 0 || this.innerRadius < 0 || this.outerRadius < 0) {\n return;\n }\n ctx.save();\n const halfAngle = (this.startAngle + this.endAngle) / 2;\n ctx.translate(Math.cos(halfAngle) * offset, Math.sin(halfAngle) * offset);\n const fix = 1 - Math.sin(Math.min(PI, circumference || 0));\n const radiusOffset = offset * fix;\n ctx.fillStyle = options.backgroundColor;\n ctx.strokeStyle = options.borderColor;\n drawArc(ctx, this, radiusOffset, spacing, circular);\n drawBorder(ctx, this, radiusOffset, spacing, circular);\n ctx.restore();\n }\n}\nfunction setStyle(ctx, options, style = options) {\n ctx.lineCap = valueOrDefault(style.borderCapStyle, options.borderCapStyle);\n ctx.setLineDash(valueOrDefault(style.borderDash, options.borderDash));\n ctx.lineDashOffset = valueOrDefault(style.borderDashOffset, options.borderDashOffset);\n ctx.lineJoin = valueOrDefault(style.borderJoinStyle, options.borderJoinStyle);\n ctx.lineWidth = valueOrDefault(style.borderWidth, options.borderWidth);\n ctx.strokeStyle = valueOrDefault(style.borderColor, options.borderColor);\n}\nfunction lineTo(ctx, previous, target) {\n ctx.lineTo(target.x, target.y);\n}\nfunction getLineMethod(options) {\n if (options.stepped) {\n return _steppedLineTo;\n }\n if (options.tension || options.cubicInterpolationMode === 'monotone') {\n return _bezierCurveTo;\n }\n return lineTo;\n}\nfunction pathVars(points, segment, params = {}) {\n const count = points.length;\n const {\n start: paramsStart = 0,\n end: paramsEnd = count - 1\n } = params;\n const {\n start: segmentStart,\n end: segmentEnd\n } = segment;\n const start = Math.max(paramsStart, segmentStart);\n const end = Math.min(paramsEnd, segmentEnd);\n const outside = paramsStart < segmentStart && paramsEnd < segmentStart || paramsStart > segmentEnd && paramsEnd > segmentEnd;\n return {\n count,\n start,\n loop: segment.loop,\n ilen: end < start && !outside ? count + end - start : end - start\n };\n}\nfunction pathSegment(ctx, line, segment, params) {\n const {\n points,\n options\n } = line;\n const {\n count,\n start,\n loop,\n ilen\n } = pathVars(points, segment, params);\n const lineMethod = getLineMethod(options);\n let {\n move = true,\n reverse\n } = params || {};\n let i, point, prev;\n for (i = 0; i <= ilen; ++i) {\n point = points[(start + (reverse ? ilen - i : i)) % count];\n if (point.skip) {\n continue;\n } else if (move) {\n ctx.moveTo(point.x, point.y);\n move = false;\n } else {\n lineMethod(ctx, prev, point, reverse, options.stepped);\n }\n prev = point;\n }\n if (loop) {\n point = points[(start + (reverse ? ilen : 0)) % count];\n lineMethod(ctx, prev, point, reverse, options.stepped);\n }\n return !!loop;\n}\nfunction fastPathSegment(ctx, line, segment, params) {\n const points = line.points;\n const {\n count,\n start,\n ilen\n } = pathVars(points, segment, params);\n const {\n move = true,\n reverse\n } = params || {};\n let avgX = 0;\n let countX = 0;\n let i, point, prevX, minY, maxY, lastY;\n const pointIndex = index => (start + (reverse ? ilen - index : index)) % count;\n const drawX = () => {\n if (minY !== maxY) {\n ctx.lineTo(avgX, maxY);\n ctx.lineTo(avgX, minY);\n ctx.lineTo(avgX, lastY);\n }\n };\n if (move) {\n point = points[pointIndex(0)];\n ctx.moveTo(point.x, point.y);\n }\n for (i = 0; i <= ilen; ++i) {\n point = points[pointIndex(i)];\n if (point.skip) {\n continue;\n }\n const x = point.x;\n const y = point.y;\n const truncX = x | 0;\n if (truncX === prevX) {\n if (y < minY) {\n minY = y;\n } else if (y > maxY) {\n maxY = y;\n }\n avgX = (countX * avgX + x) / ++countX;\n } else {\n drawX();\n ctx.lineTo(x, y);\n prevX = truncX;\n countX = 0;\n minY = maxY = y;\n }\n lastY = y;\n }\n drawX();\n}\nfunction _getSegmentMethod(line) {\n const opts = line.options;\n const borderDash = opts.borderDash && opts.borderDash.length;\n const useFastPath = !line._decimated && !line._loop && !opts.tension && opts.cubicInterpolationMode !== 'monotone' && !opts.stepped && !borderDash;\n return useFastPath ? fastPathSegment : pathSegment;\n}\nfunction _getInterpolationMethod(options) {\n if (options.stepped) {\n return _steppedInterpolation;\n }\n if (options.tension || options.cubicInterpolationMode === 'monotone') {\n return _bezierInterpolation;\n }\n return _pointInLine;\n}\nfunction strokePathWithCache(ctx, line, start, count) {\n let path = line._path;\n if (!path) {\n path = line._path = new Path2D();\n if (line.path(path, start, count)) {\n path.closePath();\n }\n }\n setStyle(ctx, line.options);\n ctx.stroke(path);\n}\nfunction strokePathDirect(ctx, line, start, count) {\n const {\n segments,\n options\n } = line;\n const segmentMethod = _getSegmentMethod(line);\n for (const segment of segments) {\n setStyle(ctx, options, segment.style);\n ctx.beginPath();\n if (segmentMethod(ctx, line, segment, {\n start,\n end: start + count - 1\n })) {\n ctx.closePath();\n }\n ctx.stroke();\n }\n}\nconst usePath2D = typeof Path2D === 'function';\nfunction draw(ctx, line, start, count) {\n if (usePath2D && !line.options.segment) {\n strokePathWithCache(ctx, line, start, count);\n } else {\n strokePathDirect(ctx, line, start, count);\n }\n}\nlet LineElement = /*#__PURE__*/(() => {\n class LineElement extends Element {\n static id = 'line';\n static defaults = {\n borderCapStyle: 'butt',\n borderDash: [],\n borderDashOffset: 0,\n borderJoinStyle: 'miter',\n borderWidth: 3,\n capBezierPoints: true,\n cubicInterpolationMode: 'default',\n fill: false,\n spanGaps: false,\n stepped: false,\n tension: 0\n };\n static defaultRoutes = {\n backgroundColor: 'backgroundColor',\n borderColor: 'borderColor'\n };\n static descriptors = {\n _scriptable: true,\n _indexable: name => name !== 'borderDash' && name !== 'fill'\n };\n constructor(cfg) {\n super();\n this.animated = true;\n this.options = undefined;\n this._chart = undefined;\n this._loop = undefined;\n this._fullLoop = undefined;\n this._path = undefined;\n this._points = undefined;\n this._segments = undefined;\n this._decimated = false;\n this._pointsUpdated = false;\n this._datasetIndex = undefined;\n if (cfg) {\n Object.assign(this, cfg);\n }\n }\n updateControlPoints(chartArea, indexAxis) {\n const options = this.options;\n if ((options.tension || options.cubicInterpolationMode === 'monotone') && !options.stepped && !this._pointsUpdated) {\n const loop = options.spanGaps ? this._loop : this._fullLoop;\n _updateBezierControlPoints(this._points, options, chartArea, loop, indexAxis);\n this._pointsUpdated = true;\n }\n }\n set points(points) {\n this._points = points;\n delete this._segments;\n delete this._path;\n this._pointsUpdated = false;\n }\n get points() {\n return this._points;\n }\n get segments() {\n return this._segments || (this._segments = _computeSegments(this, this.options.segment));\n }\n first() {\n const segments = this.segments;\n const points = this.points;\n return segments.length && points[segments[0].start];\n }\n last() {\n const segments = this.segments;\n const points = this.points;\n const count = segments.length;\n return count && points[segments[count - 1].end];\n }\n interpolate(point, property) {\n const options = this.options;\n const value = point[property];\n const points = this.points;\n const segments = _boundSegments(this, {\n property,\n start: value,\n end: value\n });\n if (!segments.length) {\n return;\n }\n const result = [];\n const _interpolate = _getInterpolationMethod(options);\n let i, ilen;\n for (i = 0, ilen = segments.length; i < ilen; ++i) {\n const {\n start,\n end\n } = segments[i];\n const p1 = points[start];\n const p2 = points[end];\n if (p1 === p2) {\n result.push(p1);\n continue;\n }\n const t = Math.abs((value - p1[property]) / (p2[property] - p1[property]));\n const interpolated = _interpolate(p1, p2, t, options.stepped);\n interpolated[property] = point[property];\n result.push(interpolated);\n }\n return result.length === 1 ? result[0] : result;\n }\n pathSegment(ctx, segment, params) {\n const segmentMethod = _getSegmentMethod(this);\n return segmentMethod(ctx, this, segment, params);\n }\n path(ctx, start, count) {\n const segments = this.segments;\n const segmentMethod = _getSegmentMethod(this);\n let loop = this._loop;\n start = start || 0;\n count = count || this.points.length - start;\n for (const segment of segments) {\n loop &= segmentMethod(ctx, this, segment, {\n start,\n end: start + count - 1\n });\n }\n return !!loop;\n }\n draw(ctx, chartArea, start, count) {\n const options = this.options || {};\n const points = this.points || [];\n if (points.length && options.borderWidth) {\n ctx.save();\n draw(ctx, this, start, count);\n ctx.restore();\n }\n if (this.animated) {\n this._pointsUpdated = false;\n this._path = undefined;\n }\n }\n }\n return LineElement;\n})();\nfunction inRange$1(el, pos, axis, useFinalPosition) {\n const options = el.options;\n const {\n [axis]: value\n } = el.getProps([axis], useFinalPosition);\n return Math.abs(pos - value) < options.radius + options.hitRadius;\n}\nlet PointElement = /*#__PURE__*/(() => {\n class PointElement extends Element {\n static id = 'point';\n parsed;\n skip;\n stop;\n /**\n * @type {any}\n */\n static defaults = {\n borderWidth: 1,\n hitRadius: 1,\n hoverBorderWidth: 1,\n hoverRadius: 4,\n pointStyle: 'circle',\n radius: 3,\n rotation: 0\n };\n /**\n * @type {any}\n */\n static defaultRoutes = {\n backgroundColor: 'backgroundColor',\n borderColor: 'borderColor'\n };\n constructor(cfg) {\n super();\n this.options = undefined;\n this.parsed = undefined;\n this.skip = undefined;\n this.stop = undefined;\n if (cfg) {\n Object.assign(this, cfg);\n }\n }\n inRange(mouseX, mouseY, useFinalPosition) {\n const options = this.options;\n const {\n x,\n y\n } = this.getProps(['x', 'y'], useFinalPosition);\n return Math.pow(mouseX - x, 2) + Math.pow(mouseY - y, 2) < Math.pow(options.hitRadius + options.radius, 2);\n }\n inXRange(mouseX, useFinalPosition) {\n return inRange$1(this, mouseX, 'x', useFinalPosition);\n }\n inYRange(mouseY, useFinalPosition) {\n return inRange$1(this, mouseY, 'y', useFinalPosition);\n }\n getCenterPoint(useFinalPosition) {\n const {\n x,\n y\n } = this.getProps(['x', 'y'], useFinalPosition);\n return {\n x,\n y\n };\n }\n size(options) {\n options = options || this.options || {};\n let radius = options.radius || 0;\n radius = Math.max(radius, radius && options.hoverRadius || 0);\n const borderWidth = radius && options.borderWidth || 0;\n return (radius + borderWidth) * 2;\n }\n draw(ctx, area) {\n const options = this.options;\n if (this.skip || options.radius < 0.1 || !_isPointInArea(this, area, this.size(options) / 2)) {\n return;\n }\n ctx.strokeStyle = options.borderColor;\n ctx.lineWidth = options.borderWidth;\n ctx.fillStyle = options.backgroundColor;\n drawPoint(ctx, options, this.x, this.y);\n }\n getRange() {\n const options = this.options || {};\n // @ts-expect-error Fallbacks should never be hit in practice\n return options.radius + options.hitRadius;\n }\n }\n return PointElement;\n})();\nfunction getBarBounds(bar, useFinalPosition) {\n const {\n x,\n y,\n base,\n width,\n height\n } = bar.getProps(['x', 'y', 'base', 'width', 'height'], useFinalPosition);\n let left, right, top, bottom, half;\n if (bar.horizontal) {\n half = height / 2;\n left = Math.min(x, base);\n right = Math.max(x, base);\n top = y - half;\n bottom = y + half;\n } else {\n half = width / 2;\n left = x - half;\n right = x + half;\n top = Math.min(y, base);\n bottom = Math.max(y, base);\n }\n return {\n left,\n top,\n right,\n bottom\n };\n}\nfunction skipOrLimit(skip, value, min, max) {\n return skip ? 0 : _limitValue(value, min, max);\n}\nfunction parseBorderWidth(bar, maxW, maxH) {\n const value = bar.options.borderWidth;\n const skip = bar.borderSkipped;\n const o = toTRBL(value);\n return {\n t: skipOrLimit(skip.top, o.top, 0, maxH),\n r: skipOrLimit(skip.right, o.right, 0, maxW),\n b: skipOrLimit(skip.bottom, o.bottom, 0, maxH),\n l: skipOrLimit(skip.left, o.left, 0, maxW)\n };\n}\nfunction parseBorderRadius(bar, maxW, maxH) {\n const {\n enableBorderRadius\n } = bar.getProps(['enableBorderRadius']);\n const value = bar.options.borderRadius;\n const o = toTRBLCorners(value);\n const maxR = Math.min(maxW, maxH);\n const skip = bar.borderSkipped;\n const enableBorder = enableBorderRadius || isObject(value);\n return {\n topLeft: skipOrLimit(!enableBorder || skip.top || skip.left, o.topLeft, 0, maxR),\n topRight: skipOrLimit(!enableBorder || skip.top || skip.right, o.topRight, 0, maxR),\n bottomLeft: skipOrLimit(!enableBorder || skip.bottom || skip.left, o.bottomLeft, 0, maxR),\n bottomRight: skipOrLimit(!enableBorder || skip.bottom || skip.right, o.bottomRight, 0, maxR)\n };\n}\nfunction boundingRects(bar) {\n const bounds = getBarBounds(bar);\n const width = bounds.right - bounds.left;\n const height = bounds.bottom - bounds.top;\n const border = parseBorderWidth(bar, width / 2, height / 2);\n const radius = parseBorderRadius(bar, width / 2, height / 2);\n return {\n outer: {\n x: bounds.left,\n y: bounds.top,\n w: width,\n h: height,\n radius\n },\n inner: {\n x: bounds.left + border.l,\n y: bounds.top + border.t,\n w: width - border.l - border.r,\n h: height - border.t - border.b,\n radius: {\n topLeft: Math.max(0, radius.topLeft - Math.max(border.t, border.l)),\n topRight: Math.max(0, radius.topRight - Math.max(border.t, border.r)),\n bottomLeft: Math.max(0, radius.bottomLeft - Math.max(border.b, border.l)),\n bottomRight: Math.max(0, radius.bottomRight - Math.max(border.b, border.r))\n }\n }\n };\n}\nfunction inRange(bar, x, y, useFinalPosition) {\n const skipX = x === null;\n const skipY = y === null;\n const skipBoth = skipX && skipY;\n const bounds = bar && !skipBoth && getBarBounds(bar, useFinalPosition);\n return bounds && (skipX || _isBetween(x, bounds.left, bounds.right)) && (skipY || _isBetween(y, bounds.top, bounds.bottom));\n}\nfunction hasRadius(radius) {\n return radius.topLeft || radius.topRight || radius.bottomLeft || radius.bottomRight;\n}\nfunction addNormalRectPath(ctx, rect) {\n ctx.rect(rect.x, rect.y, rect.w, rect.h);\n}\nfunction inflateRect(rect, amount, refRect = {}) {\n const x = rect.x !== refRect.x ? -amount : 0;\n const y = rect.y !== refRect.y ? -amount : 0;\n const w = (rect.x + rect.w !== refRect.x + refRect.w ? amount : 0) - x;\n const h = (rect.y + rect.h !== refRect.y + refRect.h ? amount : 0) - y;\n return {\n x: rect.x + x,\n y: rect.y + y,\n w: rect.w + w,\n h: rect.h + h,\n radius: rect.radius\n };\n}\nclass BarElement extends Element {\n static id = 'bar';\n static defaults = {\n borderSkipped: 'start',\n borderWidth: 0,\n borderRadius: 0,\n inflateAmount: 'auto',\n pointStyle: undefined\n };\n static defaultRoutes = {\n backgroundColor: 'backgroundColor',\n borderColor: 'borderColor'\n };\n constructor(cfg) {\n super();\n this.options = undefined;\n this.horizontal = undefined;\n this.base = undefined;\n this.width = undefined;\n this.height = undefined;\n this.inflateAmount = undefined;\n if (cfg) {\n Object.assign(this, cfg);\n }\n }\n draw(ctx) {\n const {\n inflateAmount,\n options: {\n borderColor,\n backgroundColor\n }\n } = this;\n const {\n inner,\n outer\n } = boundingRects(this);\n const addRectPath = hasRadius(outer.radius) ? addRoundedRectPath : addNormalRectPath;\n ctx.save();\n if (outer.w !== inner.w || outer.h !== inner.h) {\n ctx.beginPath();\n addRectPath(ctx, inflateRect(outer, inflateAmount, inner));\n ctx.clip();\n addRectPath(ctx, inflateRect(inner, -inflateAmount, outer));\n ctx.fillStyle = borderColor;\n ctx.fill('evenodd');\n }\n ctx.beginPath();\n addRectPath(ctx, inflateRect(inner, inflateAmount));\n ctx.fillStyle = backgroundColor;\n ctx.fill();\n ctx.restore();\n }\n inRange(mouseX, mouseY, useFinalPosition) {\n return inRange(this, mouseX, mouseY, useFinalPosition);\n }\n inXRange(mouseX, useFinalPosition) {\n return inRange(this, mouseX, null, useFinalPosition);\n }\n inYRange(mouseY, useFinalPosition) {\n return inRange(this, null, mouseY, useFinalPosition);\n }\n getCenterPoint(useFinalPosition) {\n const {\n x,\n y,\n base,\n horizontal\n } = this.getProps(['x', 'y', 'base', 'horizontal'], useFinalPosition);\n return {\n x: horizontal ? (x + base) / 2 : x,\n y: horizontal ? y : (y + base) / 2\n };\n }\n getRange(axis) {\n return axis === 'x' ? this.width / 2 : this.height / 2;\n }\n}\nvar elements = /*#__PURE__*/Object.freeze({\n __proto__: null,\n ArcElement: ArcElement,\n BarElement: BarElement,\n LineElement: LineElement,\n PointElement: PointElement\n});\nconst BORDER_COLORS = ['rgb(54, 162, 235)', 'rgb(255, 99, 132)', 'rgb(255, 159, 64)', 'rgb(255, 205, 86)', 'rgb(75, 192, 192)', 'rgb(153, 102, 255)', 'rgb(201, 203, 207)' // grey\n];\n// Border colors with 50% transparency\nconst BACKGROUND_COLORS = /* #__PURE__ */BORDER_COLORS.map(color => color.replace('rgb(', 'rgba(').replace(')', ', 0.5)'));\nfunction getBorderColor(i) {\n return BORDER_COLORS[i % BORDER_COLORS.length];\n}\nfunction getBackgroundColor(i) {\n return BACKGROUND_COLORS[i % BACKGROUND_COLORS.length];\n}\nfunction colorizeDefaultDataset(dataset, i) {\n dataset.borderColor = getBorderColor(i);\n dataset.backgroundColor = getBackgroundColor(i);\n return ++i;\n}\nfunction colorizeDoughnutDataset(dataset, i) {\n dataset.backgroundColor = dataset.data.map(() => getBorderColor(i++));\n return i;\n}\nfunction colorizePolarAreaDataset(dataset, i) {\n dataset.backgroundColor = dataset.data.map(() => getBackgroundColor(i++));\n return i;\n}\nfunction getColorizer(chart) {\n let i = 0;\n return (dataset, datasetIndex) => {\n const controller = chart.getDatasetMeta(datasetIndex).controller;\n if (controller instanceof DoughnutController) {\n i = colorizeDoughnutDataset(dataset, i);\n } else if (controller instanceof PolarAreaController) {\n i = colorizePolarAreaDataset(dataset, i);\n } else if (controller) {\n i = colorizeDefaultDataset(dataset, i);\n }\n };\n}\nfunction containsColorsDefinitions(descriptors) {\n let k;\n for (k in descriptors) {\n if (descriptors[k].borderColor || descriptors[k].backgroundColor) {\n return true;\n }\n }\n return false;\n}\nfunction containsColorsDefinition(descriptor) {\n return descriptor && (descriptor.borderColor || descriptor.backgroundColor);\n}\nfunction containsDefaultColorsDefenitions() {\n return defaults.borderColor !== 'rgba(0,0,0,0.1)' || defaults.backgroundColor !== 'rgba(0,0,0,0.1)';\n}\nvar plugin_colors = {\n id: 'colors',\n defaults: {\n enabled: true,\n forceOverride: false\n },\n beforeLayout(chart, _args, options) {\n if (!options.enabled) {\n return;\n }\n const {\n data: {\n datasets\n },\n options: chartOptions\n } = chart.config;\n const {\n elements\n } = chartOptions;\n const containsColorDefenition = containsColorsDefinitions(datasets) || containsColorsDefinition(chartOptions) || elements && containsColorsDefinitions(elements) || containsDefaultColorsDefenitions();\n if (!options.forceOverride && containsColorDefenition) {\n return;\n }\n const colorizer = getColorizer(chart);\n datasets.forEach(colorizer);\n }\n};\nfunction lttbDecimation(data, start, count, availableWidth, options) {\n const samples = options.samples || availableWidth;\n if (samples >= count) {\n return data.slice(start, start + count);\n }\n const decimated = [];\n const bucketWidth = (count - 2) / (samples - 2);\n let sampledIndex = 0;\n const endIndex = start + count - 1;\n let a = start;\n let i, maxAreaPoint, maxArea, area, nextA;\n decimated[sampledIndex++] = data[a];\n for (i = 0; i < samples - 2; i++) {\n let avgX = 0;\n let avgY = 0;\n let j;\n const avgRangeStart = Math.floor((i + 1) * bucketWidth) + 1 + start;\n const avgRangeEnd = Math.min(Math.floor((i + 2) * bucketWidth) + 1, count) + start;\n const avgRangeLength = avgRangeEnd - avgRangeStart;\n for (j = avgRangeStart; j < avgRangeEnd; j++) {\n avgX += data[j].x;\n avgY += data[j].y;\n }\n avgX /= avgRangeLength;\n avgY /= avgRangeLength;\n const rangeOffs = Math.floor(i * bucketWidth) + 1 + start;\n const rangeTo = Math.min(Math.floor((i + 1) * bucketWidth) + 1, count) + start;\n const {\n x: pointAx,\n y: pointAy\n } = data[a];\n maxArea = area = -1;\n for (j = rangeOffs; j < rangeTo; j++) {\n area = 0.5 * Math.abs((pointAx - avgX) * (data[j].y - pointAy) - (pointAx - data[j].x) * (avgY - pointAy));\n if (area > maxArea) {\n maxArea = area;\n maxAreaPoint = data[j];\n nextA = j;\n }\n }\n decimated[sampledIndex++] = maxAreaPoint;\n a = nextA;\n }\n decimated[sampledIndex++] = data[endIndex];\n return decimated;\n}\nfunction minMaxDecimation(data, start, count, availableWidth) {\n let avgX = 0;\n let countX = 0;\n let i, point, x, y, prevX, minIndex, maxIndex, startIndex, minY, maxY;\n const decimated = [];\n const endIndex = start + count - 1;\n const xMin = data[start].x;\n const xMax = data[endIndex].x;\n const dx = xMax - xMin;\n for (i = start; i < start + count; ++i) {\n point = data[i];\n x = (point.x - xMin) / dx * availableWidth;\n y = point.y;\n const truncX = x | 0;\n if (truncX === prevX) {\n if (y < minY) {\n minY = y;\n minIndex = i;\n } else if (y > maxY) {\n maxY = y;\n maxIndex = i;\n }\n avgX = (countX * avgX + point.x) / ++countX;\n } else {\n const lastIndex = i - 1;\n if (!isNullOrUndef(minIndex) && !isNullOrUndef(maxIndex)) {\n const intermediateIndex1 = Math.min(minIndex, maxIndex);\n const intermediateIndex2 = Math.max(minIndex, maxIndex);\n if (intermediateIndex1 !== startIndex && intermediateIndex1 !== lastIndex) {\n decimated.push({\n ...data[intermediateIndex1],\n x: avgX\n });\n }\n if (intermediateIndex2 !== startIndex && intermediateIndex2 !== lastIndex) {\n decimated.push({\n ...data[intermediateIndex2],\n x: avgX\n });\n }\n }\n if (i > 0 && lastIndex !== startIndex) {\n decimated.push(data[lastIndex]);\n }\n decimated.push(point);\n prevX = truncX;\n countX = 0;\n minY = maxY = y;\n minIndex = maxIndex = startIndex = i;\n }\n }\n return decimated;\n}\nfunction cleanDecimatedDataset(dataset) {\n if (dataset._decimated) {\n const data = dataset._data;\n delete dataset._decimated;\n delete dataset._data;\n Object.defineProperty(dataset, 'data', {\n configurable: true,\n enumerable: true,\n writable: true,\n value: data\n });\n }\n}\nfunction cleanDecimatedData(chart) {\n chart.data.datasets.forEach(dataset => {\n cleanDecimatedDataset(dataset);\n });\n}\nfunction getStartAndCountOfVisiblePointsSimplified(meta, points) {\n const pointCount = points.length;\n let start = 0;\n let count;\n const {\n iScale\n } = meta;\n const {\n min,\n max,\n minDefined,\n maxDefined\n } = iScale.getUserBounds();\n if (minDefined) {\n start = _limitValue(_lookupByKey(points, iScale.axis, min).lo, 0, pointCount - 1);\n }\n if (maxDefined) {\n count = _limitValue(_lookupByKey(points, iScale.axis, max).hi + 1, start, pointCount) - start;\n } else {\n count = pointCount - start;\n }\n return {\n start,\n count\n };\n}\nvar plugin_decimation = {\n id: 'decimation',\n defaults: {\n algorithm: 'min-max',\n enabled: false\n },\n beforeElementsUpdate: (chart, args, options) => {\n if (!options.enabled) {\n cleanDecimatedData(chart);\n return;\n }\n const availableWidth = chart.width;\n chart.data.datasets.forEach((dataset, datasetIndex) => {\n const {\n _data,\n indexAxis\n } = dataset;\n const meta = chart.getDatasetMeta(datasetIndex);\n const data = _data || dataset.data;\n if (resolve([indexAxis, chart.options.indexAxis]) === 'y') {\n return;\n }\n if (!meta.controller.supportsDecimation) {\n return;\n }\n const xAxis = chart.scales[meta.xAxisID];\n if (xAxis.type !== 'linear' && xAxis.type !== 'time') {\n return;\n }\n if (chart.options.parsing) {\n return;\n }\n let {\n start,\n count\n } = getStartAndCountOfVisiblePointsSimplified(meta, data);\n const threshold = options.threshold || 4 * availableWidth;\n if (count <= threshold) {\n cleanDecimatedDataset(dataset);\n return;\n }\n if (isNullOrUndef(_data)) {\n dataset._data = data;\n delete dataset.data;\n Object.defineProperty(dataset, 'data', {\n configurable: true,\n enumerable: true,\n get: function () {\n return this._decimated;\n },\n set: function (d) {\n this._data = d;\n }\n });\n }\n let decimated;\n switch (options.algorithm) {\n case 'lttb':\n decimated = lttbDecimation(data, start, count, availableWidth, options);\n break;\n case 'min-max':\n decimated = minMaxDecimation(data, start, count, availableWidth);\n break;\n default:\n throw new Error(`Unsupported decimation algorithm '${options.algorithm}'`);\n }\n dataset._decimated = decimated;\n });\n },\n destroy(chart) {\n cleanDecimatedData(chart);\n }\n};\nfunction _segments(line, target, property) {\n const segments = line.segments;\n const points = line.points;\n const tpoints = target.points;\n const parts = [];\n for (const segment of segments) {\n let {\n start,\n end\n } = segment;\n end = _findSegmentEnd(start, end, points);\n const bounds = _getBounds(property, points[start], points[end], segment.loop);\n if (!target.segments) {\n parts.push({\n source: segment,\n target: bounds,\n start: points[start],\n end: points[end]\n });\n continue;\n }\n const targetSegments = _boundSegments(target, bounds);\n for (const tgt of targetSegments) {\n const subBounds = _getBounds(property, tpoints[tgt.start], tpoints[tgt.end], tgt.loop);\n const fillSources = _boundSegment(segment, points, subBounds);\n for (const fillSource of fillSources) {\n parts.push({\n source: fillSource,\n target: tgt,\n start: {\n [property]: _getEdge(bounds, subBounds, 'start', Math.max)\n },\n end: {\n [property]: _getEdge(bounds, subBounds, 'end', Math.min)\n }\n });\n }\n }\n }\n return parts;\n}\nfunction _getBounds(property, first, last, loop) {\n if (loop) {\n return;\n }\n let start = first[property];\n let end = last[property];\n if (property === 'angle') {\n start = _normalizeAngle(start);\n end = _normalizeAngle(end);\n }\n return {\n property,\n start,\n end\n };\n}\nfunction _pointsFromSegments(boundary, line) {\n const {\n x = null,\n y = null\n } = boundary || {};\n const linePoints = line.points;\n const points = [];\n line.segments.forEach(({\n start,\n end\n }) => {\n end = _findSegmentEnd(start, end, linePoints);\n const first = linePoints[start];\n const last = linePoints[end];\n if (y !== null) {\n points.push({\n x: first.x,\n y\n });\n points.push({\n x: last.x,\n y\n });\n } else if (x !== null) {\n points.push({\n x,\n y: first.y\n });\n points.push({\n x,\n y: last.y\n });\n }\n });\n return points;\n}\nfunction _findSegmentEnd(start, end, points) {\n for (; end > start; end--) {\n const point = points[end];\n if (!isNaN(point.x) && !isNaN(point.y)) {\n break;\n }\n }\n return end;\n}\nfunction _getEdge(a, b, prop, fn) {\n if (a && b) {\n return fn(a[prop], b[prop]);\n }\n return a ? a[prop] : b ? b[prop] : 0;\n}\nfunction _createBoundaryLine(boundary, line) {\n let points = [];\n let _loop = false;\n if (isArray(boundary)) {\n _loop = true;\n points = boundary;\n } else {\n points = _pointsFromSegments(boundary, line);\n }\n return points.length ? new LineElement({\n points,\n options: {\n tension: 0\n },\n _loop,\n _fullLoop: _loop\n }) : null;\n}\nfunction _shouldApplyFill(source) {\n return source && source.fill !== false;\n}\nfunction _resolveTarget(sources, index, propagate) {\n const source = sources[index];\n let fill = source.fill;\n const visited = [index];\n let target;\n if (!propagate) {\n return fill;\n }\n while (fill !== false && visited.indexOf(fill) === -1) {\n if (!isNumberFinite(fill)) {\n return fill;\n }\n target = sources[fill];\n if (!target) {\n return false;\n }\n if (target.visible) {\n return fill;\n }\n visited.push(fill);\n fill = target.fill;\n }\n return false;\n}\nfunction _decodeFill(line, index, count) {\n const fill = parseFillOption(line);\n if (isObject(fill)) {\n return isNaN(fill.value) ? false : fill;\n }\n let target = parseFloat(fill);\n if (isNumberFinite(target) && Math.floor(target) === target) {\n return decodeTargetIndex(fill[0], index, target, count);\n }\n return ['origin', 'start', 'end', 'stack', 'shape'].indexOf(fill) >= 0 && fill;\n}\nfunction decodeTargetIndex(firstCh, index, target, count) {\n if (firstCh === '-' || firstCh === '+') {\n target = index + target;\n }\n if (target === index || target < 0 || target >= count) {\n return false;\n }\n return target;\n}\nfunction _getTargetPixel(fill, scale) {\n let pixel = null;\n if (fill === 'start') {\n pixel = scale.bottom;\n } else if (fill === 'end') {\n pixel = scale.top;\n } else if (isObject(fill)) {\n pixel = scale.getPixelForValue(fill.value);\n } else if (scale.getBasePixel) {\n pixel = scale.getBasePixel();\n }\n return pixel;\n}\nfunction _getTargetValue(fill, scale, startValue) {\n let value;\n if (fill === 'start') {\n value = startValue;\n } else if (fill === 'end') {\n value = scale.options.reverse ? scale.min : scale.max;\n } else if (isObject(fill)) {\n value = fill.value;\n } else {\n value = scale.getBaseValue();\n }\n return value;\n}\nfunction parseFillOption(line) {\n const options = line.options;\n const fillOption = options.fill;\n let fill = valueOrDefault(fillOption && fillOption.target, fillOption);\n if (fill === undefined) {\n fill = !!options.backgroundColor;\n }\n if (fill === false || fill === null) {\n return false;\n }\n if (fill === true) {\n return 'origin';\n }\n return fill;\n}\nfunction _buildStackLine(source) {\n const {\n scale,\n index,\n line\n } = source;\n const points = [];\n const segments = line.segments;\n const sourcePoints = line.points;\n const linesBelow = getLinesBelow(scale, index);\n linesBelow.push(_createBoundaryLine({\n x: null,\n y: scale.bottom\n }, line));\n for (let i = 0; i < segments.length; i++) {\n const segment = segments[i];\n for (let j = segment.start; j <= segment.end; j++) {\n addPointsBelow(points, sourcePoints[j], linesBelow);\n }\n }\n return new LineElement({\n points,\n options: {}\n });\n}\nfunction getLinesBelow(scale, index) {\n const below = [];\n const metas = scale.getMatchingVisibleMetas('line');\n for (let i = 0; i < metas.length; i++) {\n const meta = metas[i];\n if (meta.index === index) {\n break;\n }\n if (!meta.hidden) {\n below.unshift(meta.dataset);\n }\n }\n return below;\n}\nfunction addPointsBelow(points, sourcePoint, linesBelow) {\n const postponed = [];\n for (let j = 0; j < linesBelow.length; j++) {\n const line = linesBelow[j];\n const {\n first,\n last,\n point\n } = findPoint(line, sourcePoint, 'x');\n if (!point || first && last) {\n continue;\n }\n if (first) {\n postponed.unshift(point);\n } else {\n points.push(point);\n if (!last) {\n break;\n }\n }\n }\n points.push(...postponed);\n}\nfunction findPoint(line, sourcePoint, property) {\n const point = line.interpolate(sourcePoint, property);\n if (!point) {\n return {};\n }\n const pointValue = point[property];\n const segments = line.segments;\n const linePoints = line.points;\n let first = false;\n let last = false;\n for (let i = 0; i < segments.length; i++) {\n const segment = segments[i];\n const firstValue = linePoints[segment.start][property];\n const lastValue = linePoints[segment.end][property];\n if (_isBetween(pointValue, firstValue, lastValue)) {\n first = pointValue === firstValue;\n last = pointValue === lastValue;\n break;\n }\n }\n return {\n first,\n last,\n point\n };\n}\nclass simpleArc {\n constructor(opts) {\n this.x = opts.x;\n this.y = opts.y;\n this.radius = opts.radius;\n }\n pathSegment(ctx, bounds, opts) {\n const {\n x,\n y,\n radius\n } = this;\n bounds = bounds || {\n start: 0,\n end: TAU\n };\n ctx.arc(x, y, radius, bounds.end, bounds.start, true);\n return !opts.bounds;\n }\n interpolate(point) {\n const {\n x,\n y,\n radius\n } = this;\n const angle = point.angle;\n return {\n x: x + Math.cos(angle) * radius,\n y: y + Math.sin(angle) * radius,\n angle\n };\n }\n}\nfunction _getTarget(source) {\n const {\n chart,\n fill,\n line\n } = source;\n if (isNumberFinite(fill)) {\n return getLineByIndex(chart, fill);\n }\n if (fill === 'stack') {\n return _buildStackLine(source);\n }\n if (fill === 'shape') {\n return true;\n }\n const boundary = computeBoundary(source);\n if (boundary instanceof simpleArc) {\n return boundary;\n }\n return _createBoundaryLine(boundary, line);\n}\nfunction getLineByIndex(chart, index) {\n const meta = chart.getDatasetMeta(index);\n const visible = meta && chart.isDatasetVisible(index);\n return visible ? meta.dataset : null;\n}\nfunction computeBoundary(source) {\n const scale = source.scale || {};\n if (scale.getPointPositionForValue) {\n return computeCircularBoundary(source);\n }\n return computeLinearBoundary(source);\n}\nfunction computeLinearBoundary(source) {\n const {\n scale = {},\n fill\n } = source;\n const pixel = _getTargetPixel(fill, scale);\n if (isNumberFinite(pixel)) {\n const horizontal = scale.isHorizontal();\n return {\n x: horizontal ? pixel : null,\n y: horizontal ? null : pixel\n };\n }\n return null;\n}\nfunction computeCircularBoundary(source) {\n const {\n scale,\n fill\n } = source;\n const options = scale.options;\n const length = scale.getLabels().length;\n const start = options.reverse ? scale.max : scale.min;\n const value = _getTargetValue(fill, scale, start);\n const target = [];\n if (options.grid.circular) {\n const center = scale.getPointPositionForValue(0, start);\n return new simpleArc({\n x: center.x,\n y: center.y,\n radius: scale.getDistanceFromCenterForValue(value)\n });\n }\n for (let i = 0; i < length; ++i) {\n target.push(scale.getPointPositionForValue(i, value));\n }\n return target;\n}\nfunction _drawfill(ctx, source, area) {\n const target = _getTarget(source);\n const {\n line,\n scale,\n axis\n } = source;\n const lineOpts = line.options;\n const fillOption = lineOpts.fill;\n const color = lineOpts.backgroundColor;\n const {\n above = color,\n below = color\n } = fillOption || {};\n if (target && line.points.length) {\n clipArea(ctx, area);\n doFill(ctx, {\n line,\n target,\n above,\n below,\n area,\n scale,\n axis\n });\n unclipArea(ctx);\n }\n}\nfunction doFill(ctx, cfg) {\n const {\n line,\n target,\n above,\n below,\n area,\n scale\n } = cfg;\n const property = line._loop ? 'angle' : cfg.axis;\n ctx.save();\n if (property === 'x' && below !== above) {\n clipVertical(ctx, target, area.top);\n fill(ctx, {\n line,\n target,\n color: above,\n scale,\n property\n });\n ctx.restore();\n ctx.save();\n clipVertical(ctx, target, area.bottom);\n }\n fill(ctx, {\n line,\n target,\n color: below,\n scale,\n property\n });\n ctx.restore();\n}\nfunction clipVertical(ctx, target, clipY) {\n const {\n segments,\n points\n } = target;\n let first = true;\n let lineLoop = false;\n ctx.beginPath();\n for (const segment of segments) {\n const {\n start,\n end\n } = segment;\n const firstPoint = points[start];\n const lastPoint = points[_findSegmentEnd(start, end, points)];\n if (first) {\n ctx.moveTo(firstPoint.x, firstPoint.y);\n first = false;\n } else {\n ctx.lineTo(firstPoint.x, clipY);\n ctx.lineTo(firstPoint.x, firstPoint.y);\n }\n lineLoop = !!target.pathSegment(ctx, segment, {\n move: lineLoop\n });\n if (lineLoop) {\n ctx.closePath();\n } else {\n ctx.lineTo(lastPoint.x, clipY);\n }\n }\n ctx.lineTo(target.first().x, clipY);\n ctx.closePath();\n ctx.clip();\n}\nfunction fill(ctx, cfg) {\n const {\n line,\n target,\n property,\n color,\n scale\n } = cfg;\n const segments = _segments(line, target, property);\n for (const {\n source: src,\n target: tgt,\n start,\n end\n } of segments) {\n const {\n style: {\n backgroundColor = color\n } = {}\n } = src;\n const notShape = target !== true;\n ctx.save();\n ctx.fillStyle = backgroundColor;\n clipBounds(ctx, scale, notShape && _getBounds(property, start, end));\n ctx.beginPath();\n const lineLoop = !!line.pathSegment(ctx, src);\n let loop;\n if (notShape) {\n if (lineLoop) {\n ctx.closePath();\n } else {\n interpolatedLineTo(ctx, target, end, property);\n }\n const targetLoop = !!target.pathSegment(ctx, tgt, {\n move: lineLoop,\n reverse: true\n });\n loop = lineLoop && targetLoop;\n if (!loop) {\n interpolatedLineTo(ctx, target, start, property);\n }\n }\n ctx.closePath();\n ctx.fill(loop ? 'evenodd' : 'nonzero');\n ctx.restore();\n }\n}\nfunction clipBounds(ctx, scale, bounds) {\n const {\n top,\n bottom\n } = scale.chart.chartArea;\n const {\n property,\n start,\n end\n } = bounds || {};\n if (property === 'x') {\n ctx.beginPath();\n ctx.rect(start, top, end - start, bottom - top);\n ctx.clip();\n }\n}\nfunction interpolatedLineTo(ctx, target, point, property) {\n const interpolatedPoint = target.interpolate(point, property);\n if (interpolatedPoint) {\n ctx.lineTo(interpolatedPoint.x, interpolatedPoint.y);\n }\n}\nvar index = {\n id: 'filler',\n afterDatasetsUpdate(chart, _args, options) {\n const count = (chart.data.datasets || []).length;\n const sources = [];\n let meta, i, line, source;\n for (i = 0; i < count; ++i) {\n meta = chart.getDatasetMeta(i);\n line = meta.dataset;\n source = null;\n if (line && line.options && line instanceof LineElement) {\n source = {\n visible: chart.isDatasetVisible(i),\n index: i,\n fill: _decodeFill(line, i, count),\n chart,\n axis: meta.controller.options.indexAxis,\n scale: meta.vScale,\n line\n };\n }\n meta.$filler = source;\n sources.push(source);\n }\n for (i = 0; i < count; ++i) {\n source = sources[i];\n if (!source || source.fill === false) {\n continue;\n }\n source.fill = _resolveTarget(sources, i, options.propagate);\n }\n },\n beforeDraw(chart, _args, options) {\n const draw = options.drawTime === 'beforeDraw';\n const metasets = chart.getSortedVisibleDatasetMetas();\n const area = chart.chartArea;\n for (let i = metasets.length - 1; i >= 0; --i) {\n const source = metasets[i].$filler;\n if (!source) {\n continue;\n }\n source.line.updateControlPoints(area, source.axis);\n if (draw && source.fill) {\n _drawfill(chart.ctx, source, area);\n }\n }\n },\n beforeDatasetsDraw(chart, _args, options) {\n if (options.drawTime !== 'beforeDatasetsDraw') {\n return;\n }\n const metasets = chart.getSortedVisibleDatasetMetas();\n for (let i = metasets.length - 1; i >= 0; --i) {\n const source = metasets[i].$filler;\n if (_shouldApplyFill(source)) {\n _drawfill(chart.ctx, source, chart.chartArea);\n }\n }\n },\n beforeDatasetDraw(chart, args, options) {\n const source = args.meta.$filler;\n if (!_shouldApplyFill(source) || options.drawTime !== 'beforeDatasetDraw') {\n return;\n }\n _drawfill(chart.ctx, source, chart.chartArea);\n },\n defaults: {\n propagate: true,\n drawTime: 'beforeDatasetDraw'\n }\n};\nconst getBoxSize = (labelOpts, fontSize) => {\n let {\n boxHeight = fontSize,\n boxWidth = fontSize\n } = labelOpts;\n if (labelOpts.usePointStyle) {\n boxHeight = Math.min(boxHeight, fontSize);\n boxWidth = labelOpts.pointStyleWidth || Math.min(boxWidth, fontSize);\n }\n return {\n boxWidth,\n boxHeight,\n itemHeight: Math.max(fontSize, boxHeight)\n };\n};\nconst itemsEqual = (a, b) => a !== null && b !== null && a.datasetIndex === b.datasetIndex && a.index === b.index;\nclass Legend extends Element {\n constructor(config) {\n super();\n this._added = false;\n this.legendHitBoxes = [];\n this._hoveredItem = null;\n this.doughnutMode = false;\n this.chart = config.chart;\n this.options = config.options;\n this.ctx = config.ctx;\n this.legendItems = undefined;\n this.columnSizes = undefined;\n this.lineWidths = undefined;\n this.maxHeight = undefined;\n this.maxWidth = undefined;\n this.top = undefined;\n this.bottom = undefined;\n this.left = undefined;\n this.right = undefined;\n this.height = undefined;\n this.width = undefined;\n this._margins = undefined;\n this.position = undefined;\n this.weight = undefined;\n this.fullSize = undefined;\n }\n update(maxWidth, maxHeight, margins) {\n this.maxWidth = maxWidth;\n this.maxHeight = maxHeight;\n this._margins = margins;\n this.setDimensions();\n this.buildLabels();\n this.fit();\n }\n setDimensions() {\n if (this.isHorizontal()) {\n this.width = this.maxWidth;\n this.left = this._margins.left;\n this.right = this.width;\n } else {\n this.height = this.maxHeight;\n this.top = this._margins.top;\n this.bottom = this.height;\n }\n }\n buildLabels() {\n const labelOpts = this.options.labels || {};\n let legendItems = callback(labelOpts.generateLabels, [this.chart], this) || [];\n if (labelOpts.filter) {\n legendItems = legendItems.filter(item => labelOpts.filter(item, this.chart.data));\n }\n if (labelOpts.sort) {\n legendItems = legendItems.sort((a, b) => labelOpts.sort(a, b, this.chart.data));\n }\n if (this.options.reverse) {\n legendItems.reverse();\n }\n this.legendItems = legendItems;\n }\n fit() {\n const {\n options,\n ctx\n } = this;\n if (!options.display) {\n this.width = this.height = 0;\n return;\n }\n const labelOpts = options.labels;\n const labelFont = toFont(labelOpts.font);\n const fontSize = labelFont.size;\n const titleHeight = this._computeTitleHeight();\n const {\n boxWidth,\n itemHeight\n } = getBoxSize(labelOpts, fontSize);\n let width, height;\n ctx.font = labelFont.string;\n if (this.isHorizontal()) {\n width = this.maxWidth;\n height = this._fitRows(titleHeight, fontSize, boxWidth, itemHeight) + 10;\n } else {\n height = this.maxHeight;\n width = this._fitCols(titleHeight, labelFont, boxWidth, itemHeight) + 10;\n }\n this.width = Math.min(width, options.maxWidth || this.maxWidth);\n this.height = Math.min(height, options.maxHeight || this.maxHeight);\n }\n _fitRows(titleHeight, fontSize, boxWidth, itemHeight) {\n const {\n ctx,\n maxWidth,\n options: {\n labels: {\n padding\n }\n }\n } = this;\n const hitboxes = this.legendHitBoxes = [];\n const lineWidths = this.lineWidths = [0];\n const lineHeight = itemHeight + padding;\n let totalHeight = titleHeight;\n ctx.textAlign = 'left';\n ctx.textBaseline = 'middle';\n let row = -1;\n let top = -lineHeight;\n this.legendItems.forEach((legendItem, i) => {\n const itemWidth = boxWidth + fontSize / 2 + ctx.measureText(legendItem.text).width;\n if (i === 0 || lineWidths[lineWidths.length - 1] + itemWidth + 2 * padding > maxWidth) {\n totalHeight += lineHeight;\n lineWidths[lineWidths.length - (i > 0 ? 0 : 1)] = 0;\n top += lineHeight;\n row++;\n }\n hitboxes[i] = {\n left: 0,\n top,\n row,\n width: itemWidth,\n height: itemHeight\n };\n lineWidths[lineWidths.length - 1] += itemWidth + padding;\n });\n return totalHeight;\n }\n _fitCols(titleHeight, labelFont, boxWidth, _itemHeight) {\n const {\n ctx,\n maxHeight,\n options: {\n labels: {\n padding\n }\n }\n } = this;\n const hitboxes = this.legendHitBoxes = [];\n const columnSizes = this.columnSizes = [];\n const heightLimit = maxHeight - titleHeight;\n let totalWidth = padding;\n let currentColWidth = 0;\n let currentColHeight = 0;\n let left = 0;\n let col = 0;\n this.legendItems.forEach((legendItem, i) => {\n const {\n itemWidth,\n itemHeight\n } = calculateItemSize(boxWidth, labelFont, ctx, legendItem, _itemHeight);\n if (i > 0 && currentColHeight + itemHeight + 2 * padding > heightLimit) {\n totalWidth += currentColWidth + padding;\n columnSizes.push({\n width: currentColWidth,\n height: currentColHeight\n });\n left += currentColWidth + padding;\n col++;\n currentColWidth = currentColHeight = 0;\n }\n hitboxes[i] = {\n left,\n top: currentColHeight,\n col,\n width: itemWidth,\n height: itemHeight\n };\n currentColWidth = Math.max(currentColWidth, itemWidth);\n currentColHeight += itemHeight + padding;\n });\n totalWidth += currentColWidth;\n columnSizes.push({\n width: currentColWidth,\n height: currentColHeight\n });\n return totalWidth;\n }\n adjustHitBoxes() {\n if (!this.options.display) {\n return;\n }\n const titleHeight = this._computeTitleHeight();\n const {\n legendHitBoxes: hitboxes,\n options: {\n align,\n labels: {\n padding\n },\n rtl\n }\n } = this;\n const rtlHelper = getRtlAdapter(rtl, this.left, this.width);\n if (this.isHorizontal()) {\n let row = 0;\n let left = _alignStartEnd(align, this.left + padding, this.right - this.lineWidths[row]);\n for (const hitbox of hitboxes) {\n if (row !== hitbox.row) {\n row = hitbox.row;\n left = _alignStartEnd(align, this.left + padding, this.right - this.lineWidths[row]);\n }\n hitbox.top += this.top + titleHeight + padding;\n hitbox.left = rtlHelper.leftForLtr(rtlHelper.x(left), hitbox.width);\n left += hitbox.width + padding;\n }\n } else {\n let col = 0;\n let top = _alignStartEnd(align, this.top + titleHeight + padding, this.bottom - this.columnSizes[col].height);\n for (const hitbox of hitboxes) {\n if (hitbox.col !== col) {\n col = hitbox.col;\n top = _alignStartEnd(align, this.top + titleHeight + padding, this.bottom - this.columnSizes[col].height);\n }\n hitbox.top = top;\n hitbox.left += this.left + padding;\n hitbox.left = rtlHelper.leftForLtr(rtlHelper.x(hitbox.left), hitbox.width);\n top += hitbox.height + padding;\n }\n }\n }\n isHorizontal() {\n return this.options.position === 'top' || this.options.position === 'bottom';\n }\n draw() {\n if (this.options.display) {\n const ctx = this.ctx;\n clipArea(ctx, this);\n this._draw();\n unclipArea(ctx);\n }\n }\n _draw() {\n const {\n options: opts,\n columnSizes,\n lineWidths,\n ctx\n } = this;\n const {\n align,\n labels: labelOpts\n } = opts;\n const defaultColor = defaults.color;\n const rtlHelper = getRtlAdapter(opts.rtl, this.left, this.width);\n const labelFont = toFont(labelOpts.font);\n const {\n padding\n } = labelOpts;\n const fontSize = labelFont.size;\n const halfFontSize = fontSize / 2;\n let cursor;\n this.drawTitle();\n ctx.textAlign = rtlHelper.textAlign('left');\n ctx.textBaseline = 'middle';\n ctx.lineWidth = 0.5;\n ctx.font = labelFont.string;\n const {\n boxWidth,\n boxHeight,\n itemHeight\n } = getBoxSize(labelOpts, fontSize);\n const drawLegendBox = function (x, y, legendItem) {\n if (isNaN(boxWidth) || boxWidth <= 0 || isNaN(boxHeight) || boxHeight < 0) {\n return;\n }\n ctx.save();\n const lineWidth = valueOrDefault(legendItem.lineWidth, 1);\n ctx.fillStyle = valueOrDefault(legendItem.fillStyle, defaultColor);\n ctx.lineCap = valueOrDefault(legendItem.lineCap, 'butt');\n ctx.lineDashOffset = valueOrDefault(legendItem.lineDashOffset, 0);\n ctx.lineJoin = valueOrDefault(legendItem.lineJoin, 'miter');\n ctx.lineWidth = lineWidth;\n ctx.strokeStyle = valueOrDefault(legendItem.strokeStyle, defaultColor);\n ctx.setLineDash(valueOrDefault(legendItem.lineDash, []));\n if (labelOpts.usePointStyle) {\n const drawOptions = {\n radius: boxHeight * Math.SQRT2 / 2,\n pointStyle: legendItem.pointStyle,\n rotation: legendItem.rotation,\n borderWidth: lineWidth\n };\n const centerX = rtlHelper.xPlus(x, boxWidth / 2);\n const centerY = y + halfFontSize;\n drawPointLegend(ctx, drawOptions, centerX, centerY, labelOpts.pointStyleWidth && boxWidth);\n } else {\n const yBoxTop = y + Math.max((fontSize - boxHeight) / 2, 0);\n const xBoxLeft = rtlHelper.leftForLtr(x, boxWidth);\n const borderRadius = toTRBLCorners(legendItem.borderRadius);\n ctx.beginPath();\n if (Object.values(borderRadius).some(v => v !== 0)) {\n addRoundedRectPath(ctx, {\n x: xBoxLeft,\n y: yBoxTop,\n w: boxWidth,\n h: boxHeight,\n radius: borderRadius\n });\n } else {\n ctx.rect(xBoxLeft, yBoxTop, boxWidth, boxHeight);\n }\n ctx.fill();\n if (lineWidth !== 0) {\n ctx.stroke();\n }\n }\n ctx.restore();\n };\n const fillText = function (x, y, legendItem) {\n renderText(ctx, legendItem.text, x, y + itemHeight / 2, labelFont, {\n strikethrough: legendItem.hidden,\n textAlign: rtlHelper.textAlign(legendItem.textAlign)\n });\n };\n const isHorizontal = this.isHorizontal();\n const titleHeight = this._computeTitleHeight();\n if (isHorizontal) {\n cursor = {\n x: _alignStartEnd(align, this.left + padding, this.right - lineWidths[0]),\n y: this.top + padding + titleHeight,\n line: 0\n };\n } else {\n cursor = {\n x: this.left + padding,\n y: _alignStartEnd(align, this.top + titleHeight + padding, this.bottom - columnSizes[0].height),\n line: 0\n };\n }\n overrideTextDirection(this.ctx, opts.textDirection);\n const lineHeight = itemHeight + padding;\n this.legendItems.forEach((legendItem, i) => {\n ctx.strokeStyle = legendItem.fontColor;\n ctx.fillStyle = legendItem.fontColor;\n const textWidth = ctx.measureText(legendItem.text).width;\n const textAlign = rtlHelper.textAlign(legendItem.textAlign || (legendItem.textAlign = labelOpts.textAlign));\n const width = boxWidth + halfFontSize + textWidth;\n let x = cursor.x;\n let y = cursor.y;\n rtlHelper.setWidth(this.width);\n if (isHorizontal) {\n if (i > 0 && x + width + padding > this.right) {\n y = cursor.y += lineHeight;\n cursor.line++;\n x = cursor.x = _alignStartEnd(align, this.left + padding, this.right - lineWidths[cursor.line]);\n }\n } else if (i > 0 && y + lineHeight > this.bottom) {\n x = cursor.x = x + columnSizes[cursor.line].width + padding;\n cursor.line++;\n y = cursor.y = _alignStartEnd(align, this.top + titleHeight + padding, this.bottom - columnSizes[cursor.line].height);\n }\n const realX = rtlHelper.x(x);\n drawLegendBox(realX, y, legendItem);\n x = _textX(textAlign, x + boxWidth + halfFontSize, isHorizontal ? x + width : this.right, opts.rtl);\n fillText(rtlHelper.x(x), y, legendItem);\n if (isHorizontal) {\n cursor.x += width + padding;\n } else if (typeof legendItem.text !== 'string') {\n const fontLineHeight = labelFont.lineHeight;\n cursor.y += calculateLegendItemHeight(legendItem, fontLineHeight) + padding;\n } else {\n cursor.y += lineHeight;\n }\n });\n restoreTextDirection(this.ctx, opts.textDirection);\n }\n drawTitle() {\n const opts = this.options;\n const titleOpts = opts.title;\n const titleFont = toFont(titleOpts.font);\n const titlePadding = toPadding(titleOpts.padding);\n if (!titleOpts.display) {\n return;\n }\n const rtlHelper = getRtlAdapter(opts.rtl, this.left, this.width);\n const ctx = this.ctx;\n const position = titleOpts.position;\n const halfFontSize = titleFont.size / 2;\n const topPaddingPlusHalfFontSize = titlePadding.top + halfFontSize;\n let y;\n let left = this.left;\n let maxWidth = this.width;\n if (this.isHorizontal()) {\n maxWidth = Math.max(...this.lineWidths);\n y = this.top + topPaddingPlusHalfFontSize;\n left = _alignStartEnd(opts.align, left, this.right - maxWidth);\n } else {\n const maxHeight = this.columnSizes.reduce((acc, size) => Math.max(acc, size.height), 0);\n y = topPaddingPlusHalfFontSize + _alignStartEnd(opts.align, this.top, this.bottom - maxHeight - opts.labels.padding - this._computeTitleHeight());\n }\n const x = _alignStartEnd(position, left, left + maxWidth);\n ctx.textAlign = rtlHelper.textAlign(_toLeftRightCenter(position));\n ctx.textBaseline = 'middle';\n ctx.strokeStyle = titleOpts.color;\n ctx.fillStyle = titleOpts.color;\n ctx.font = titleFont.string;\n renderText(ctx, titleOpts.text, x, y, titleFont);\n }\n _computeTitleHeight() {\n const titleOpts = this.options.title;\n const titleFont = toFont(titleOpts.font);\n const titlePadding = toPadding(titleOpts.padding);\n return titleOpts.display ? titleFont.lineHeight + titlePadding.height : 0;\n }\n _getLegendItemAt(x, y) {\n let i, hitBox, lh;\n if (_isBetween(x, this.left, this.right) && _isBetween(y, this.top, this.bottom)) {\n lh = this.legendHitBoxes;\n for (i = 0; i < lh.length; ++i) {\n hitBox = lh[i];\n if (_isBetween(x, hitBox.left, hitBox.left + hitBox.width) && _isBetween(y, hitBox.top, hitBox.top + hitBox.height)) {\n return this.legendItems[i];\n }\n }\n }\n return null;\n }\n handleEvent(e) {\n const opts = this.options;\n if (!isListened(e.type, opts)) {\n return;\n }\n const hoveredItem = this._getLegendItemAt(e.x, e.y);\n if (e.type === 'mousemove' || e.type === 'mouseout') {\n const previous = this._hoveredItem;\n const sameItem = itemsEqual(previous, hoveredItem);\n if (previous && !sameItem) {\n callback(opts.onLeave, [e, previous, this], this);\n }\n this._hoveredItem = hoveredItem;\n if (hoveredItem && !sameItem) {\n callback(opts.onHover, [e, hoveredItem, this], this);\n }\n } else if (hoveredItem) {\n callback(opts.onClick, [e, hoveredItem, this], this);\n }\n }\n}\nfunction calculateItemSize(boxWidth, labelFont, ctx, legendItem, _itemHeight) {\n const itemWidth = calculateItemWidth(legendItem, boxWidth, labelFont, ctx);\n const itemHeight = calculateItemHeight(_itemHeight, legendItem, labelFont.lineHeight);\n return {\n itemWidth,\n itemHeight\n };\n}\nfunction calculateItemWidth(legendItem, boxWidth, labelFont, ctx) {\n let legendItemText = legendItem.text;\n if (legendItemText && typeof legendItemText !== 'string') {\n legendItemText = legendItemText.reduce((a, b) => a.length > b.length ? a : b);\n }\n return boxWidth + labelFont.size / 2 + ctx.measureText(legendItemText).width;\n}\nfunction calculateItemHeight(_itemHeight, legendItem, fontLineHeight) {\n let itemHeight = _itemHeight;\n if (typeof legendItem.text !== 'string') {\n itemHeight = calculateLegendItemHeight(legendItem, fontLineHeight);\n }\n return itemHeight;\n}\nfunction calculateLegendItemHeight(legendItem, fontLineHeight) {\n const labelHeight = legendItem.text ? legendItem.text.length : 0;\n return fontLineHeight * labelHeight;\n}\nfunction isListened(type, opts) {\n if ((type === 'mousemove' || type === 'mouseout') && (opts.onHover || opts.onLeave)) {\n return true;\n }\n if (opts.onClick && (type === 'click' || type === 'mouseup')) {\n return true;\n }\n return false;\n}\nvar plugin_legend = {\n id: 'legend',\n _element: Legend,\n start(chart, _args, options) {\n const legend = chart.legend = new Legend({\n ctx: chart.ctx,\n options,\n chart\n });\n layouts.configure(chart, legend, options);\n layouts.addBox(chart, legend);\n },\n stop(chart) {\n layouts.removeBox(chart, chart.legend);\n delete chart.legend;\n },\n beforeUpdate(chart, _args, options) {\n const legend = chart.legend;\n layouts.configure(chart, legend, options);\n legend.options = options;\n },\n afterUpdate(chart) {\n const legend = chart.legend;\n legend.buildLabels();\n legend.adjustHitBoxes();\n },\n afterEvent(chart, args) {\n if (!args.replay) {\n chart.legend.handleEvent(args.event);\n }\n },\n defaults: {\n display: true,\n position: 'top',\n align: 'center',\n fullSize: true,\n reverse: false,\n weight: 1000,\n onClick(e, legendItem, legend) {\n const index = legendItem.datasetIndex;\n const ci = legend.chart;\n if (ci.isDatasetVisible(index)) {\n ci.hide(index);\n legendItem.hidden = true;\n } else {\n ci.show(index);\n legendItem.hidden = false;\n }\n },\n onHover: null,\n onLeave: null,\n labels: {\n color: ctx => ctx.chart.options.color,\n boxWidth: 40,\n padding: 10,\n generateLabels(chart) {\n const datasets = chart.data.datasets;\n const {\n labels: {\n usePointStyle,\n pointStyle,\n textAlign,\n color,\n useBorderRadius,\n borderRadius\n }\n } = chart.legend.options;\n return chart._getSortedDatasetMetas().map(meta => {\n const style = meta.controller.getStyle(usePointStyle ? 0 : undefined);\n const borderWidth = toPadding(style.borderWidth);\n return {\n text: datasets[meta.index].label,\n fillStyle: style.backgroundColor,\n fontColor: color,\n hidden: !meta.visible,\n lineCap: style.borderCapStyle,\n lineDash: style.borderDash,\n lineDashOffset: style.borderDashOffset,\n lineJoin: style.borderJoinStyle,\n lineWidth: (borderWidth.width + borderWidth.height) / 4,\n strokeStyle: style.borderColor,\n pointStyle: pointStyle || style.pointStyle,\n rotation: style.rotation,\n textAlign: textAlign || style.textAlign,\n borderRadius: useBorderRadius && (borderRadius || style.borderRadius),\n datasetIndex: meta.index\n };\n }, this);\n }\n },\n title: {\n color: ctx => ctx.chart.options.color,\n display: false,\n position: 'center',\n text: ''\n }\n },\n descriptors: {\n _scriptable: name => !name.startsWith('on'),\n labels: {\n _scriptable: name => !['generateLabels', 'filter', 'sort'].includes(name)\n }\n }\n};\nclass Title extends Element {\n constructor(config) {\n super();\n this.chart = config.chart;\n this.options = config.options;\n this.ctx = config.ctx;\n this._padding = undefined;\n this.top = undefined;\n this.bottom = undefined;\n this.left = undefined;\n this.right = undefined;\n this.width = undefined;\n this.height = undefined;\n this.position = undefined;\n this.weight = undefined;\n this.fullSize = undefined;\n }\n update(maxWidth, maxHeight) {\n const opts = this.options;\n this.left = 0;\n this.top = 0;\n if (!opts.display) {\n this.width = this.height = this.right = this.bottom = 0;\n return;\n }\n this.width = this.right = maxWidth;\n this.height = this.bottom = maxHeight;\n const lineCount = isArray(opts.text) ? opts.text.length : 1;\n this._padding = toPadding(opts.padding);\n const textSize = lineCount * toFont(opts.font).lineHeight + this._padding.height;\n if (this.isHorizontal()) {\n this.height = textSize;\n } else {\n this.width = textSize;\n }\n }\n isHorizontal() {\n const pos = this.options.position;\n return pos === 'top' || pos === 'bottom';\n }\n _drawArgs(offset) {\n const {\n top,\n left,\n bottom,\n right,\n options\n } = this;\n const align = options.align;\n let rotation = 0;\n let maxWidth, titleX, titleY;\n if (this.isHorizontal()) {\n titleX = _alignStartEnd(align, left, right);\n titleY = top + offset;\n maxWidth = right - left;\n } else {\n if (options.position === 'left') {\n titleX = left + offset;\n titleY = _alignStartEnd(align, bottom, top);\n rotation = PI * -0.5;\n } else {\n titleX = right - offset;\n titleY = _alignStartEnd(align, top, bottom);\n rotation = PI * 0.5;\n }\n maxWidth = bottom - top;\n }\n return {\n titleX,\n titleY,\n maxWidth,\n rotation\n };\n }\n draw() {\n const ctx = this.ctx;\n const opts = this.options;\n if (!opts.display) {\n return;\n }\n const fontOpts = toFont(opts.font);\n const lineHeight = fontOpts.lineHeight;\n const offset = lineHeight / 2 + this._padding.top;\n const {\n titleX,\n titleY,\n maxWidth,\n rotation\n } = this._drawArgs(offset);\n renderText(ctx, opts.text, 0, 0, fontOpts, {\n color: opts.color,\n maxWidth,\n rotation,\n textAlign: _toLeftRightCenter(opts.align),\n textBaseline: 'middle',\n translation: [titleX, titleY]\n });\n }\n}\nfunction createTitle(chart, titleOpts) {\n const title = new Title({\n ctx: chart.ctx,\n options: titleOpts,\n chart\n });\n layouts.configure(chart, title, titleOpts);\n layouts.addBox(chart, title);\n chart.titleBlock = title;\n}\nvar plugin_title = {\n id: 'title',\n _element: Title,\n start(chart, _args, options) {\n createTitle(chart, options);\n },\n stop(chart) {\n const titleBlock = chart.titleBlock;\n layouts.removeBox(chart, titleBlock);\n delete chart.titleBlock;\n },\n beforeUpdate(chart, _args, options) {\n const title = chart.titleBlock;\n layouts.configure(chart, title, options);\n title.options = options;\n },\n defaults: {\n align: 'center',\n display: false,\n font: {\n weight: 'bold'\n },\n fullSize: true,\n padding: 10,\n position: 'top',\n text: '',\n weight: 2000\n },\n defaultRoutes: {\n color: 'color'\n },\n descriptors: {\n _scriptable: true,\n _indexable: false\n }\n};\nconst map = new WeakMap();\nvar plugin_subtitle = {\n id: 'subtitle',\n start(chart, _args, options) {\n const title = new Title({\n ctx: chart.ctx,\n options,\n chart\n });\n layouts.configure(chart, title, options);\n layouts.addBox(chart, title);\n map.set(chart, title);\n },\n stop(chart) {\n layouts.removeBox(chart, map.get(chart));\n map.delete(chart);\n },\n beforeUpdate(chart, _args, options) {\n const title = map.get(chart);\n layouts.configure(chart, title, options);\n title.options = options;\n },\n defaults: {\n align: 'center',\n display: false,\n font: {\n weight: 'normal'\n },\n fullSize: true,\n padding: 0,\n position: 'top',\n text: '',\n weight: 1500\n },\n defaultRoutes: {\n color: 'color'\n },\n descriptors: {\n _scriptable: true,\n _indexable: false\n }\n};\nconst positioners = {\n average(items) {\n if (!items.length) {\n return false;\n }\n let i, len;\n let xSet = new Set();\n let y = 0;\n let count = 0;\n for (i = 0, len = items.length; i < len; ++i) {\n const el = items[i].element;\n if (el && el.hasValue()) {\n const pos = el.tooltipPosition();\n xSet.add(pos.x);\n y += pos.y;\n ++count;\n }\n }\n if (count === 0 || xSet.size === 0) {\n return false;\n }\n const xAverage = [...xSet].reduce((a, b) => a + b) / xSet.size;\n return {\n x: xAverage,\n y: y / count\n };\n },\n nearest(items, eventPosition) {\n if (!items.length) {\n return false;\n }\n let x = eventPosition.x;\n let y = eventPosition.y;\n let minDistance = Number.POSITIVE_INFINITY;\n let i, len, nearestElement;\n for (i = 0, len = items.length; i < len; ++i) {\n const el = items[i].element;\n if (el && el.hasValue()) {\n const center = el.getCenterPoint();\n const d = distanceBetweenPoints(eventPosition, center);\n if (d < minDistance) {\n minDistance = d;\n nearestElement = el;\n }\n }\n }\n if (nearestElement) {\n const tp = nearestElement.tooltipPosition();\n x = tp.x;\n y = tp.y;\n }\n return {\n x,\n y\n };\n }\n};\nfunction pushOrConcat(base, toPush) {\n if (toPush) {\n if (isArray(toPush)) {\n Array.prototype.push.apply(base, toPush);\n } else {\n base.push(toPush);\n }\n }\n return base;\n}\nfunction splitNewlines(str) {\n if ((typeof str === 'string' || str instanceof String) && str.indexOf('\\n') > -1) {\n return str.split('\\n');\n }\n return str;\n}\nfunction createTooltipItem(chart, item) {\n const {\n element,\n datasetIndex,\n index\n } = item;\n const controller = chart.getDatasetMeta(datasetIndex).controller;\n const {\n label,\n value\n } = controller.getLabelAndValue(index);\n return {\n chart,\n label,\n parsed: controller.getParsed(index),\n raw: chart.data.datasets[datasetIndex].data[index],\n formattedValue: value,\n dataset: controller.getDataset(),\n dataIndex: index,\n datasetIndex,\n element\n };\n}\nfunction getTooltipSize(tooltip, options) {\n const ctx = tooltip.chart.ctx;\n const {\n body,\n footer,\n title\n } = tooltip;\n const {\n boxWidth,\n boxHeight\n } = options;\n const bodyFont = toFont(options.bodyFont);\n const titleFont = toFont(options.titleFont);\n const footerFont = toFont(options.footerFont);\n const titleLineCount = title.length;\n const footerLineCount = footer.length;\n const bodyLineItemCount = body.length;\n const padding = toPadding(options.padding);\n let height = padding.height;\n let width = 0;\n let combinedBodyLength = body.reduce((count, bodyItem) => count + bodyItem.before.length + bodyItem.lines.length + bodyItem.after.length, 0);\n combinedBodyLength += tooltip.beforeBody.length + tooltip.afterBody.length;\n if (titleLineCount) {\n height += titleLineCount * titleFont.lineHeight + (titleLineCount - 1) * options.titleSpacing + options.titleMarginBottom;\n }\n if (combinedBodyLength) {\n const bodyLineHeight = options.displayColors ? Math.max(boxHeight, bodyFont.lineHeight) : bodyFont.lineHeight;\n height += bodyLineItemCount * bodyLineHeight + (combinedBodyLength - bodyLineItemCount) * bodyFont.lineHeight + (combinedBodyLength - 1) * options.bodySpacing;\n }\n if (footerLineCount) {\n height += options.footerMarginTop + footerLineCount * footerFont.lineHeight + (footerLineCount - 1) * options.footerSpacing;\n }\n let widthPadding = 0;\n const maxLineWidth = function (line) {\n width = Math.max(width, ctx.measureText(line).width + widthPadding);\n };\n ctx.save();\n ctx.font = titleFont.string;\n each(tooltip.title, maxLineWidth);\n ctx.font = bodyFont.string;\n each(tooltip.beforeBody.concat(tooltip.afterBody), maxLineWidth);\n widthPadding = options.displayColors ? boxWidth + 2 + options.boxPadding : 0;\n each(body, bodyItem => {\n each(bodyItem.before, maxLineWidth);\n each(bodyItem.lines, maxLineWidth);\n each(bodyItem.after, maxLineWidth);\n });\n widthPadding = 0;\n ctx.font = footerFont.string;\n each(tooltip.footer, maxLineWidth);\n ctx.restore();\n width += padding.width;\n return {\n width,\n height\n };\n}\nfunction determineYAlign(chart, size) {\n const {\n y,\n height\n } = size;\n if (y < height / 2) {\n return 'top';\n } else if (y > chart.height - height / 2) {\n return 'bottom';\n }\n return 'center';\n}\nfunction doesNotFitWithAlign(xAlign, chart, options, size) {\n const {\n x,\n width\n } = size;\n const caret = options.caretSize + options.caretPadding;\n if (xAlign === 'left' && x + width + caret > chart.width) {\n return true;\n }\n if (xAlign === 'right' && x - width - caret < 0) {\n return true;\n }\n}\nfunction determineXAlign(chart, options, size, yAlign) {\n const {\n x,\n width\n } = size;\n const {\n width: chartWidth,\n chartArea: {\n left,\n right\n }\n } = chart;\n let xAlign = 'center';\n if (yAlign === 'center') {\n xAlign = x <= (left + right) / 2 ? 'left' : 'right';\n } else if (x <= width / 2) {\n xAlign = 'left';\n } else if (x >= chartWidth - width / 2) {\n xAlign = 'right';\n }\n if (doesNotFitWithAlign(xAlign, chart, options, size)) {\n xAlign = 'center';\n }\n return xAlign;\n}\nfunction determineAlignment(chart, options, size) {\n const yAlign = size.yAlign || options.yAlign || determineYAlign(chart, size);\n return {\n xAlign: size.xAlign || options.xAlign || determineXAlign(chart, options, size, yAlign),\n yAlign\n };\n}\nfunction alignX(size, xAlign) {\n let {\n x,\n width\n } = size;\n if (xAlign === 'right') {\n x -= width;\n } else if (xAlign === 'center') {\n x -= width / 2;\n }\n return x;\n}\nfunction alignY(size, yAlign, paddingAndSize) {\n let {\n y,\n height\n } = size;\n if (yAlign === 'top') {\n y += paddingAndSize;\n } else if (yAlign === 'bottom') {\n y -= height + paddingAndSize;\n } else {\n y -= height / 2;\n }\n return y;\n}\nfunction getBackgroundPoint(options, size, alignment, chart) {\n const {\n caretSize,\n caretPadding,\n cornerRadius\n } = options;\n const {\n xAlign,\n yAlign\n } = alignment;\n const paddingAndSize = caretSize + caretPadding;\n const {\n topLeft,\n topRight,\n bottomLeft,\n bottomRight\n } = toTRBLCorners(cornerRadius);\n let x = alignX(size, xAlign);\n const y = alignY(size, yAlign, paddingAndSize);\n if (yAlign === 'center') {\n if (xAlign === 'left') {\n x += paddingAndSize;\n } else if (xAlign === 'right') {\n x -= paddingAndSize;\n }\n } else if (xAlign === 'left') {\n x -= Math.max(topLeft, bottomLeft) + caretSize;\n } else if (xAlign === 'right') {\n x += Math.max(topRight, bottomRight) + caretSize;\n }\n return {\n x: _limitValue(x, 0, chart.width - size.width),\n y: _limitValue(y, 0, chart.height - size.height)\n };\n}\nfunction getAlignedX(tooltip, align, options) {\n const padding = toPadding(options.padding);\n return align === 'center' ? tooltip.x + tooltip.width / 2 : align === 'right' ? tooltip.x + tooltip.width - padding.right : tooltip.x + padding.left;\n}\nfunction getBeforeAfterBodyLines(callback) {\n return pushOrConcat([], splitNewlines(callback));\n}\nfunction createTooltipContext(parent, tooltip, tooltipItems) {\n return createContext(parent, {\n tooltip,\n tooltipItems,\n type: 'tooltip'\n });\n}\nfunction overrideCallbacks(callbacks, context) {\n const override = context && context.dataset && context.dataset.tooltip && context.dataset.tooltip.callbacks;\n return override ? callbacks.override(override) : callbacks;\n}\nconst defaultCallbacks = {\n beforeTitle: noop,\n title(tooltipItems) {\n if (tooltipItems.length > 0) {\n const item = tooltipItems[0];\n const labels = item.chart.data.labels;\n const labelCount = labels ? labels.length : 0;\n if (this && this.options && this.options.mode === 'dataset') {\n return item.dataset.label || '';\n } else if (item.label) {\n return item.label;\n } else if (labelCount > 0 && item.dataIndex < labelCount) {\n return labels[item.dataIndex];\n }\n }\n return '';\n },\n afterTitle: noop,\n beforeBody: noop,\n beforeLabel: noop,\n label(tooltipItem) {\n if (this && this.options && this.options.mode === 'dataset') {\n return tooltipItem.label + ': ' + tooltipItem.formattedValue || tooltipItem.formattedValue;\n }\n let label = tooltipItem.dataset.label || '';\n if (label) {\n label += ': ';\n }\n const value = tooltipItem.formattedValue;\n if (!isNullOrUndef(value)) {\n label += value;\n }\n return label;\n },\n labelColor(tooltipItem) {\n const meta = tooltipItem.chart.getDatasetMeta(tooltipItem.datasetIndex);\n const options = meta.controller.getStyle(tooltipItem.dataIndex);\n return {\n borderColor: options.borderColor,\n backgroundColor: options.backgroundColor,\n borderWidth: options.borderWidth,\n borderDash: options.borderDash,\n borderDashOffset: options.borderDashOffset,\n borderRadius: 0\n };\n },\n labelTextColor() {\n return this.options.bodyColor;\n },\n labelPointStyle(tooltipItem) {\n const meta = tooltipItem.chart.getDatasetMeta(tooltipItem.datasetIndex);\n const options = meta.controller.getStyle(tooltipItem.dataIndex);\n return {\n pointStyle: options.pointStyle,\n rotation: options.rotation\n };\n },\n afterLabel: noop,\n afterBody: noop,\n beforeFooter: noop,\n footer: noop,\n afterFooter: noop\n};\nfunction invokeCallbackWithFallback(callbacks, name, ctx, arg) {\n const result = callbacks[name].call(ctx, arg);\n if (typeof result === 'undefined') {\n return defaultCallbacks[name].call(ctx, arg);\n }\n return result;\n}\nlet Tooltip = /*#__PURE__*/(() => {\n class Tooltip extends Element {\n static positioners = positioners;\n constructor(config) {\n super();\n this.opacity = 0;\n this._active = [];\n this._eventPosition = undefined;\n this._size = undefined;\n this._cachedAnimations = undefined;\n this._tooltipItems = [];\n this.$animations = undefined;\n this.$context = undefined;\n this.chart = config.chart;\n this.options = config.options;\n this.dataPoints = undefined;\n this.title = undefined;\n this.beforeBody = undefined;\n this.body = undefined;\n this.afterBody = undefined;\n this.footer = undefined;\n this.xAlign = undefined;\n this.yAlign = undefined;\n this.x = undefined;\n this.y = undefined;\n this.height = undefined;\n this.width = undefined;\n this.caretX = undefined;\n this.caretY = undefined;\n this.labelColors = undefined;\n this.labelPointStyles = undefined;\n this.labelTextColors = undefined;\n }\n initialize(options) {\n this.options = options;\n this._cachedAnimations = undefined;\n this.$context = undefined;\n }\n _resolveAnimations() {\n const cached = this._cachedAnimations;\n if (cached) {\n return cached;\n }\n const chart = this.chart;\n const options = this.options.setContext(this.getContext());\n const opts = options.enabled && chart.options.animation && options.animations;\n const animations = new Animations(this.chart, opts);\n if (opts._cacheable) {\n this._cachedAnimations = Object.freeze(animations);\n }\n return animations;\n }\n getContext() {\n return this.$context || (this.$context = createTooltipContext(this.chart.getContext(), this, this._tooltipItems));\n }\n getTitle(context, options) {\n const {\n callbacks\n } = options;\n const beforeTitle = invokeCallbackWithFallback(callbacks, 'beforeTitle', this, context);\n const title = invokeCallbackWithFallback(callbacks, 'title', this, context);\n const afterTitle = invokeCallbackWithFallback(callbacks, 'afterTitle', this, context);\n let lines = [];\n lines = pushOrConcat(lines, splitNewlines(beforeTitle));\n lines = pushOrConcat(lines, splitNewlines(title));\n lines = pushOrConcat(lines, splitNewlines(afterTitle));\n return lines;\n }\n getBeforeBody(tooltipItems, options) {\n return getBeforeAfterBodyLines(invokeCallbackWithFallback(options.callbacks, 'beforeBody', this, tooltipItems));\n }\n getBody(tooltipItems, options) {\n const {\n callbacks\n } = options;\n const bodyItems = [];\n each(tooltipItems, context => {\n const bodyItem = {\n before: [],\n lines: [],\n after: []\n };\n const scoped = overrideCallbacks(callbacks, context);\n pushOrConcat(bodyItem.before, splitNewlines(invokeCallbackWithFallback(scoped, 'beforeLabel', this, context)));\n pushOrConcat(bodyItem.lines, invokeCallbackWithFallback(scoped, 'label', this, context));\n pushOrConcat(bodyItem.after, splitNewlines(invokeCallbackWithFallback(scoped, 'afterLabel', this, context)));\n bodyItems.push(bodyItem);\n });\n return bodyItems;\n }\n getAfterBody(tooltipItems, options) {\n return getBeforeAfterBodyLines(invokeCallbackWithFallback(options.callbacks, 'afterBody', this, tooltipItems));\n }\n getFooter(tooltipItems, options) {\n const {\n callbacks\n } = options;\n const beforeFooter = invokeCallbackWithFallback(callbacks, 'beforeFooter', this, tooltipItems);\n const footer = invokeCallbackWithFallback(callbacks, 'footer', this, tooltipItems);\n const afterFooter = invokeCallbackWithFallback(callbacks, 'afterFooter', this, tooltipItems);\n let lines = [];\n lines = pushOrConcat(lines, splitNewlines(beforeFooter));\n lines = pushOrConcat(lines, splitNewlines(footer));\n lines = pushOrConcat(lines, splitNewlines(afterFooter));\n return lines;\n }\n _createItems(options) {\n const active = this._active;\n const data = this.chart.data;\n const labelColors = [];\n const labelPointStyles = [];\n const labelTextColors = [];\n let tooltipItems = [];\n let i, len;\n for (i = 0, len = active.length; i < len; ++i) {\n tooltipItems.push(createTooltipItem(this.chart, active[i]));\n }\n if (options.filter) {\n tooltipItems = tooltipItems.filter((element, index, array) => options.filter(element, index, array, data));\n }\n if (options.itemSort) {\n tooltipItems = tooltipItems.sort((a, b) => options.itemSort(a, b, data));\n }\n each(tooltipItems, context => {\n const scoped = overrideCallbacks(options.callbacks, context);\n labelColors.push(invokeCallbackWithFallback(scoped, 'labelColor', this, context));\n labelPointStyles.push(invokeCallbackWithFallback(scoped, 'labelPointStyle', this, context));\n labelTextColors.push(invokeCallbackWithFallback(scoped, 'labelTextColor', this, context));\n });\n this.labelColors = labelColors;\n this.labelPointStyles = labelPointStyles;\n this.labelTextColors = labelTextColors;\n this.dataPoints = tooltipItems;\n return tooltipItems;\n }\n update(changed, replay) {\n const options = this.options.setContext(this.getContext());\n const active = this._active;\n let properties;\n let tooltipItems = [];\n if (!active.length) {\n if (this.opacity !== 0) {\n properties = {\n opacity: 0\n };\n }\n } else {\n const position = positioners[options.position].call(this, active, this._eventPosition);\n tooltipItems = this._createItems(options);\n this.title = this.getTitle(tooltipItems, options);\n this.beforeBody = this.getBeforeBody(tooltipItems, options);\n this.body = this.getBody(tooltipItems, options);\n this.afterBody = this.getAfterBody(tooltipItems, options);\n this.footer = this.getFooter(tooltipItems, options);\n const size = this._size = getTooltipSize(this, options);\n const positionAndSize = Object.assign({}, position, size);\n const alignment = determineAlignment(this.chart, options, positionAndSize);\n const backgroundPoint = getBackgroundPoint(options, positionAndSize, alignment, this.chart);\n this.xAlign = alignment.xAlign;\n this.yAlign = alignment.yAlign;\n properties = {\n opacity: 1,\n x: backgroundPoint.x,\n y: backgroundPoint.y,\n width: size.width,\n height: size.height,\n caretX: position.x,\n caretY: position.y\n };\n }\n this._tooltipItems = tooltipItems;\n this.$context = undefined;\n if (properties) {\n this._resolveAnimations().update(this, properties);\n }\n if (changed && options.external) {\n options.external.call(this, {\n chart: this.chart,\n tooltip: this,\n replay\n });\n }\n }\n drawCaret(tooltipPoint, ctx, size, options) {\n const caretPosition = this.getCaretPosition(tooltipPoint, size, options);\n ctx.lineTo(caretPosition.x1, caretPosition.y1);\n ctx.lineTo(caretPosition.x2, caretPosition.y2);\n ctx.lineTo(caretPosition.x3, caretPosition.y3);\n }\n getCaretPosition(tooltipPoint, size, options) {\n const {\n xAlign,\n yAlign\n } = this;\n const {\n caretSize,\n cornerRadius\n } = options;\n const {\n topLeft,\n topRight,\n bottomLeft,\n bottomRight\n } = toTRBLCorners(cornerRadius);\n const {\n x: ptX,\n y: ptY\n } = tooltipPoint;\n const {\n width,\n height\n } = size;\n let x1, x2, x3, y1, y2, y3;\n if (yAlign === 'center') {\n y2 = ptY + height / 2;\n if (xAlign === 'left') {\n x1 = ptX;\n x2 = x1 - caretSize;\n y1 = y2 + caretSize;\n y3 = y2 - caretSize;\n } else {\n x1 = ptX + width;\n x2 = x1 + caretSize;\n y1 = y2 - caretSize;\n y3 = y2 + caretSize;\n }\n x3 = x1;\n } else {\n if (xAlign === 'left') {\n x2 = ptX + Math.max(topLeft, bottomLeft) + caretSize;\n } else if (xAlign === 'right') {\n x2 = ptX + width - Math.max(topRight, bottomRight) - caretSize;\n } else {\n x2 = this.caretX;\n }\n if (yAlign === 'top') {\n y1 = ptY;\n y2 = y1 - caretSize;\n x1 = x2 - caretSize;\n x3 = x2 + caretSize;\n } else {\n y1 = ptY + height;\n y2 = y1 + caretSize;\n x1 = x2 + caretSize;\n x3 = x2 - caretSize;\n }\n y3 = y1;\n }\n return {\n x1,\n x2,\n x3,\n y1,\n y2,\n y3\n };\n }\n drawTitle(pt, ctx, options) {\n const title = this.title;\n const length = title.length;\n let titleFont, titleSpacing, i;\n if (length) {\n const rtlHelper = getRtlAdapter(options.rtl, this.x, this.width);\n pt.x = getAlignedX(this, options.titleAlign, options);\n ctx.textAlign = rtlHelper.textAlign(options.titleAlign);\n ctx.textBaseline = 'middle';\n titleFont = toFont(options.titleFont);\n titleSpacing = options.titleSpacing;\n ctx.fillStyle = options.titleColor;\n ctx.font = titleFont.string;\n for (i = 0; i < length; ++i) {\n ctx.fillText(title[i], rtlHelper.x(pt.x), pt.y + titleFont.lineHeight / 2);\n pt.y += titleFont.lineHeight + titleSpacing;\n if (i + 1 === length) {\n pt.y += options.titleMarginBottom - titleSpacing;\n }\n }\n }\n }\n _drawColorBox(ctx, pt, i, rtlHelper, options) {\n const labelColor = this.labelColors[i];\n const labelPointStyle = this.labelPointStyles[i];\n const {\n boxHeight,\n boxWidth\n } = options;\n const bodyFont = toFont(options.bodyFont);\n const colorX = getAlignedX(this, 'left', options);\n const rtlColorX = rtlHelper.x(colorX);\n const yOffSet = boxHeight < bodyFont.lineHeight ? (bodyFont.lineHeight - boxHeight) / 2 : 0;\n const colorY = pt.y + yOffSet;\n if (options.usePointStyle) {\n const drawOptions = {\n radius: Math.min(boxWidth, boxHeight) / 2,\n pointStyle: labelPointStyle.pointStyle,\n rotation: labelPointStyle.rotation,\n borderWidth: 1\n };\n const centerX = rtlHelper.leftForLtr(rtlColorX, boxWidth) + boxWidth / 2;\n const centerY = colorY + boxHeight / 2;\n ctx.strokeStyle = options.multiKeyBackground;\n ctx.fillStyle = options.multiKeyBackground;\n drawPoint(ctx, drawOptions, centerX, centerY);\n ctx.strokeStyle = labelColor.borderColor;\n ctx.fillStyle = labelColor.backgroundColor;\n drawPoint(ctx, drawOptions, centerX, centerY);\n } else {\n ctx.lineWidth = isObject(labelColor.borderWidth) ? Math.max(...Object.values(labelColor.borderWidth)) : labelColor.borderWidth || 1;\n ctx.strokeStyle = labelColor.borderColor;\n ctx.setLineDash(labelColor.borderDash || []);\n ctx.lineDashOffset = labelColor.borderDashOffset || 0;\n const outerX = rtlHelper.leftForLtr(rtlColorX, boxWidth);\n const innerX = rtlHelper.leftForLtr(rtlHelper.xPlus(rtlColorX, 1), boxWidth - 2);\n const borderRadius = toTRBLCorners(labelColor.borderRadius);\n if (Object.values(borderRadius).some(v => v !== 0)) {\n ctx.beginPath();\n ctx.fillStyle = options.multiKeyBackground;\n addRoundedRectPath(ctx, {\n x: outerX,\n y: colorY,\n w: boxWidth,\n h: boxHeight,\n radius: borderRadius\n });\n ctx.fill();\n ctx.stroke();\n ctx.fillStyle = labelColor.backgroundColor;\n ctx.beginPath();\n addRoundedRectPath(ctx, {\n x: innerX,\n y: colorY + 1,\n w: boxWidth - 2,\n h: boxHeight - 2,\n radius: borderRadius\n });\n ctx.fill();\n } else {\n ctx.fillStyle = options.multiKeyBackground;\n ctx.fillRect(outerX, colorY, boxWidth, boxHeight);\n ctx.strokeRect(outerX, colorY, boxWidth, boxHeight);\n ctx.fillStyle = labelColor.backgroundColor;\n ctx.fillRect(innerX, colorY + 1, boxWidth - 2, boxHeight - 2);\n }\n }\n ctx.fillStyle = this.labelTextColors[i];\n }\n drawBody(pt, ctx, options) {\n const {\n body\n } = this;\n const {\n bodySpacing,\n bodyAlign,\n displayColors,\n boxHeight,\n boxWidth,\n boxPadding\n } = options;\n const bodyFont = toFont(options.bodyFont);\n let bodyLineHeight = bodyFont.lineHeight;\n let xLinePadding = 0;\n const rtlHelper = getRtlAdapter(options.rtl, this.x, this.width);\n const fillLineOfText = function (line) {\n ctx.fillText(line, rtlHelper.x(pt.x + xLinePadding), pt.y + bodyLineHeight / 2);\n pt.y += bodyLineHeight + bodySpacing;\n };\n const bodyAlignForCalculation = rtlHelper.textAlign(bodyAlign);\n let bodyItem, textColor, lines, i, j, ilen, jlen;\n ctx.textAlign = bodyAlign;\n ctx.textBaseline = 'middle';\n ctx.font = bodyFont.string;\n pt.x = getAlignedX(this, bodyAlignForCalculation, options);\n ctx.fillStyle = options.bodyColor;\n each(this.beforeBody, fillLineOfText);\n xLinePadding = displayColors && bodyAlignForCalculation !== 'right' ? bodyAlign === 'center' ? boxWidth / 2 + boxPadding : boxWidth + 2 + boxPadding : 0;\n for (i = 0, ilen = body.length; i < ilen; ++i) {\n bodyItem = body[i];\n textColor = this.labelTextColors[i];\n ctx.fillStyle = textColor;\n each(bodyItem.before, fillLineOfText);\n lines = bodyItem.lines;\n if (displayColors && lines.length) {\n this._drawColorBox(ctx, pt, i, rtlHelper, options);\n bodyLineHeight = Math.max(bodyFont.lineHeight, boxHeight);\n }\n for (j = 0, jlen = lines.length; j < jlen; ++j) {\n fillLineOfText(lines[j]);\n bodyLineHeight = bodyFont.lineHeight;\n }\n each(bodyItem.after, fillLineOfText);\n }\n xLinePadding = 0;\n bodyLineHeight = bodyFont.lineHeight;\n each(this.afterBody, fillLineOfText);\n pt.y -= bodySpacing;\n }\n drawFooter(pt, ctx, options) {\n const footer = this.footer;\n const length = footer.length;\n let footerFont, i;\n if (length) {\n const rtlHelper = getRtlAdapter(options.rtl, this.x, this.width);\n pt.x = getAlignedX(this, options.footerAlign, options);\n pt.y += options.footerMarginTop;\n ctx.textAlign = rtlHelper.textAlign(options.footerAlign);\n ctx.textBaseline = 'middle';\n footerFont = toFont(options.footerFont);\n ctx.fillStyle = options.footerColor;\n ctx.font = footerFont.string;\n for (i = 0; i < length; ++i) {\n ctx.fillText(footer[i], rtlHelper.x(pt.x), pt.y + footerFont.lineHeight / 2);\n pt.y += footerFont.lineHeight + options.footerSpacing;\n }\n }\n }\n drawBackground(pt, ctx, tooltipSize, options) {\n const {\n xAlign,\n yAlign\n } = this;\n const {\n x,\n y\n } = pt;\n const {\n width,\n height\n } = tooltipSize;\n const {\n topLeft,\n topRight,\n bottomLeft,\n bottomRight\n } = toTRBLCorners(options.cornerRadius);\n ctx.fillStyle = options.backgroundColor;\n ctx.strokeStyle = options.borderColor;\n ctx.lineWidth = options.borderWidth;\n ctx.beginPath();\n ctx.moveTo(x + topLeft, y);\n if (yAlign === 'top') {\n this.drawCaret(pt, ctx, tooltipSize, options);\n }\n ctx.lineTo(x + width - topRight, y);\n ctx.quadraticCurveTo(x + width, y, x + width, y + topRight);\n if (yAlign === 'center' && xAlign === 'right') {\n this.drawCaret(pt, ctx, tooltipSize, options);\n }\n ctx.lineTo(x + width, y + height - bottomRight);\n ctx.quadraticCurveTo(x + width, y + height, x + width - bottomRight, y + height);\n if (yAlign === 'bottom') {\n this.drawCaret(pt, ctx, tooltipSize, options);\n }\n ctx.lineTo(x + bottomLeft, y + height);\n ctx.quadraticCurveTo(x, y + height, x, y + height - bottomLeft);\n if (yAlign === 'center' && xAlign === 'left') {\n this.drawCaret(pt, ctx, tooltipSize, options);\n }\n ctx.lineTo(x, y + topLeft);\n ctx.quadraticCurveTo(x, y, x + topLeft, y);\n ctx.closePath();\n ctx.fill();\n if (options.borderWidth > 0) {\n ctx.stroke();\n }\n }\n _updateAnimationTarget(options) {\n const chart = this.chart;\n const anims = this.$animations;\n const animX = anims && anims.x;\n const animY = anims && anims.y;\n if (animX || animY) {\n const position = positioners[options.position].call(this, this._active, this._eventPosition);\n if (!position) {\n return;\n }\n const size = this._size = getTooltipSize(this, options);\n const positionAndSize = Object.assign({}, position, this._size);\n const alignment = determineAlignment(chart, options, positionAndSize);\n const point = getBackgroundPoint(options, positionAndSize, alignment, chart);\n if (animX._to !== point.x || animY._to !== point.y) {\n this.xAlign = alignment.xAlign;\n this.yAlign = alignment.yAlign;\n this.width = size.width;\n this.height = size.height;\n this.caretX = position.x;\n this.caretY = position.y;\n this._resolveAnimations().update(this, point);\n }\n }\n }\n _willRender() {\n return !!this.opacity;\n }\n draw(ctx) {\n const options = this.options.setContext(this.getContext());\n let opacity = this.opacity;\n if (!opacity) {\n return;\n }\n this._updateAnimationTarget(options);\n const tooltipSize = {\n width: this.width,\n height: this.height\n };\n const pt = {\n x: this.x,\n y: this.y\n };\n opacity = Math.abs(opacity) < 1e-3 ? 0 : opacity;\n const padding = toPadding(options.padding);\n const hasTooltipContent = this.title.length || this.beforeBody.length || this.body.length || this.afterBody.length || this.footer.length;\n if (options.enabled && hasTooltipContent) {\n ctx.save();\n ctx.globalAlpha = opacity;\n this.drawBackground(pt, ctx, tooltipSize, options);\n overrideTextDirection(ctx, options.textDirection);\n pt.y += padding.top;\n this.drawTitle(pt, ctx, options);\n this.drawBody(pt, ctx, options);\n this.drawFooter(pt, ctx, options);\n restoreTextDirection(ctx, options.textDirection);\n ctx.restore();\n }\n }\n getActiveElements() {\n return this._active || [];\n }\n setActiveElements(activeElements, eventPosition) {\n const lastActive = this._active;\n const active = activeElements.map(({\n datasetIndex,\n index\n }) => {\n const meta = this.chart.getDatasetMeta(datasetIndex);\n if (!meta) {\n throw new Error('Cannot find a dataset at index ' + datasetIndex);\n }\n return {\n datasetIndex,\n element: meta.data[index],\n index\n };\n });\n const changed = !_elementsEqual(lastActive, active);\n const positionChanged = this._positionChanged(active, eventPosition);\n if (changed || positionChanged) {\n this._active = active;\n this._eventPosition = eventPosition;\n this._ignoreReplayEvents = true;\n this.update(true);\n }\n }\n handleEvent(e, replay, inChartArea = true) {\n if (replay && this._ignoreReplayEvents) {\n return false;\n }\n this._ignoreReplayEvents = false;\n const options = this.options;\n const lastActive = this._active || [];\n const active = this._getActiveElements(e, lastActive, replay, inChartArea);\n const positionChanged = this._positionChanged(active, e);\n const changed = replay || !_elementsEqual(active, lastActive) || positionChanged;\n if (changed) {\n this._active = active;\n if (options.enabled || options.external) {\n this._eventPosition = {\n x: e.x,\n y: e.y\n };\n this.update(true, replay);\n }\n }\n return changed;\n }\n _getActiveElements(e, lastActive, replay, inChartArea) {\n const options = this.options;\n if (e.type === 'mouseout') {\n return [];\n }\n if (!inChartArea) {\n return lastActive.filter(i => this.chart.data.datasets[i.datasetIndex] && this.chart.getDatasetMeta(i.datasetIndex).controller.getParsed(i.index) !== undefined);\n }\n const active = this.chart.getElementsAtEventForMode(e, options.mode, options, replay);\n if (options.reverse) {\n active.reverse();\n }\n return active;\n }\n _positionChanged(active, e) {\n const {\n caretX,\n caretY,\n options\n } = this;\n const position = positioners[options.position].call(this, active, e);\n return position !== false && (caretX !== position.x || caretY !== position.y);\n }\n }\n return Tooltip;\n})();\nvar plugin_tooltip = {\n id: 'tooltip',\n _element: Tooltip,\n positioners,\n afterInit(chart, _args, options) {\n if (options) {\n chart.tooltip = new Tooltip({\n chart,\n options\n });\n }\n },\n beforeUpdate(chart, _args, options) {\n if (chart.tooltip) {\n chart.tooltip.initialize(options);\n }\n },\n reset(chart, _args, options) {\n if (chart.tooltip) {\n chart.tooltip.initialize(options);\n }\n },\n afterDraw(chart) {\n const tooltip = chart.tooltip;\n if (tooltip && tooltip._willRender()) {\n const args = {\n tooltip\n };\n if (chart.notifyPlugins('beforeTooltipDraw', {\n ...args,\n cancelable: true\n }) === false) {\n return;\n }\n tooltip.draw(chart.ctx);\n chart.notifyPlugins('afterTooltipDraw', args);\n }\n },\n afterEvent(chart, args) {\n if (chart.tooltip) {\n const useFinalPosition = args.replay;\n if (chart.tooltip.handleEvent(args.event, useFinalPosition, args.inChartArea)) {\n args.changed = true;\n }\n }\n },\n defaults: {\n enabled: true,\n external: null,\n position: 'average',\n backgroundColor: 'rgba(0,0,0,0.8)',\n titleColor: '#fff',\n titleFont: {\n weight: 'bold'\n },\n titleSpacing: 2,\n titleMarginBottom: 6,\n titleAlign: 'left',\n bodyColor: '#fff',\n bodySpacing: 2,\n bodyFont: {},\n bodyAlign: 'left',\n footerColor: '#fff',\n footerSpacing: 2,\n footerMarginTop: 6,\n footerFont: {\n weight: 'bold'\n },\n footerAlign: 'left',\n padding: 6,\n caretPadding: 2,\n caretSize: 5,\n cornerRadius: 6,\n boxHeight: (ctx, opts) => opts.bodyFont.size,\n boxWidth: (ctx, opts) => opts.bodyFont.size,\n multiKeyBackground: '#fff',\n displayColors: true,\n boxPadding: 0,\n borderColor: 'rgba(0,0,0,0)',\n borderWidth: 0,\n animation: {\n duration: 400,\n easing: 'easeOutQuart'\n },\n animations: {\n numbers: {\n type: 'number',\n properties: ['x', 'y', 'width', 'height', 'caretX', 'caretY']\n },\n opacity: {\n easing: 'linear',\n duration: 200\n }\n },\n callbacks: defaultCallbacks\n },\n defaultRoutes: {\n bodyFont: 'font',\n footerFont: 'font',\n titleFont: 'font'\n },\n descriptors: {\n _scriptable: name => name !== 'filter' && name !== 'itemSort' && name !== 'external',\n _indexable: false,\n callbacks: {\n _scriptable: false,\n _indexable: false\n },\n animation: {\n _fallback: false\n },\n animations: {\n _fallback: 'animation'\n }\n },\n additionalOptionScopes: ['interaction']\n};\nvar plugins = /*#__PURE__*/Object.freeze({\n __proto__: null,\n Colors: plugin_colors,\n Decimation: plugin_decimation,\n Filler: index,\n Legend: plugin_legend,\n SubTitle: plugin_subtitle,\n Title: plugin_title,\n Tooltip: plugin_tooltip\n});\nconst addIfString = (labels, raw, index, addedLabels) => {\n if (typeof raw === 'string') {\n index = labels.push(raw) - 1;\n addedLabels.unshift({\n index,\n label: raw\n });\n } else if (isNaN(raw)) {\n index = null;\n }\n return index;\n};\nfunction findOrAddLabel(labels, raw, index, addedLabels) {\n const first = labels.indexOf(raw);\n if (first === -1) {\n return addIfString(labels, raw, index, addedLabels);\n }\n const last = labels.lastIndexOf(raw);\n return first !== last ? index : first;\n}\nconst validIndex = (index, max) => index === null ? null : _limitValue(Math.round(index), 0, max);\nfunction _getLabelForValue(value) {\n const labels = this.getLabels();\n if (value >= 0 && value < labels.length) {\n return labels[value];\n }\n return value;\n}\nlet CategoryScale = /*#__PURE__*/(() => {\n class CategoryScale extends Scale {\n static id = 'category';\n static defaults = {\n ticks: {\n callback: _getLabelForValue\n }\n };\n constructor(cfg) {\n super(cfg);\n this._startValue = undefined;\n this._valueRange = 0;\n this._addedLabels = [];\n }\n init(scaleOptions) {\n const added = this._addedLabels;\n if (added.length) {\n const labels = this.getLabels();\n for (const {\n index,\n label\n } of added) {\n if (labels[index] === label) {\n labels.splice(index, 1);\n }\n }\n this._addedLabels = [];\n }\n super.init(scaleOptions);\n }\n parse(raw, index) {\n if (isNullOrUndef(raw)) {\n return null;\n }\n const labels = this.getLabels();\n index = isFinite(index) && labels[index] === raw ? index : findOrAddLabel(labels, raw, valueOrDefault(index, raw), this._addedLabels);\n return validIndex(index, labels.length - 1);\n }\n determineDataLimits() {\n const {\n minDefined,\n maxDefined\n } = this.getUserBounds();\n let {\n min,\n max\n } = this.getMinMax(true);\n if (this.options.bounds === 'ticks') {\n if (!minDefined) {\n min = 0;\n }\n if (!maxDefined) {\n max = this.getLabels().length - 1;\n }\n }\n this.min = min;\n this.max = max;\n }\n buildTicks() {\n const min = this.min;\n const max = this.max;\n const offset = this.options.offset;\n const ticks = [];\n let labels = this.getLabels();\n labels = min === 0 && max === labels.length - 1 ? labels : labels.slice(min, max + 1);\n this._valueRange = Math.max(labels.length - (offset ? 0 : 1), 1);\n this._startValue = this.min - (offset ? 0.5 : 0);\n for (let value = min; value <= max; value++) {\n ticks.push({\n value\n });\n }\n return ticks;\n }\n getLabelForValue(value) {\n return _getLabelForValue.call(this, value);\n }\n configure() {\n super.configure();\n if (!this.isHorizontal()) {\n this._reversePixels = !this._reversePixels;\n }\n }\n getPixelForValue(value) {\n if (typeof value !== 'number') {\n value = this.parse(value);\n }\n return value === null ? NaN : this.getPixelForDecimal((value - this._startValue) / this._valueRange);\n }\n getPixelForTick(index) {\n const ticks = this.ticks;\n if (index < 0 || index > ticks.length - 1) {\n return null;\n }\n return this.getPixelForValue(ticks[index].value);\n }\n getValueForPixel(pixel) {\n return Math.round(this._startValue + this.getDecimalForPixel(pixel) * this._valueRange);\n }\n getBasePixel() {\n return this.bottom;\n }\n }\n return CategoryScale;\n})();\nfunction generateTicks$1(generationOptions, dataRange) {\n const ticks = [];\n const MIN_SPACING = 1e-14;\n const {\n bounds,\n step,\n min,\n max,\n precision,\n count,\n maxTicks,\n maxDigits,\n includeBounds\n } = generationOptions;\n const unit = step || 1;\n const maxSpaces = maxTicks - 1;\n const {\n min: rmin,\n max: rmax\n } = dataRange;\n const minDefined = !isNullOrUndef(min);\n const maxDefined = !isNullOrUndef(max);\n const countDefined = !isNullOrUndef(count);\n const minSpacing = (rmax - rmin) / (maxDigits + 1);\n let spacing = niceNum((rmax - rmin) / maxSpaces / unit) * unit;\n let factor, niceMin, niceMax, numSpaces;\n if (spacing < MIN_SPACING && !minDefined && !maxDefined) {\n return [{\n value: rmin\n }, {\n value: rmax\n }];\n }\n numSpaces = Math.ceil(rmax / spacing) - Math.floor(rmin / spacing);\n if (numSpaces > maxSpaces) {\n spacing = niceNum(numSpaces * spacing / maxSpaces / unit) * unit;\n }\n if (!isNullOrUndef(precision)) {\n factor = Math.pow(10, precision);\n spacing = Math.ceil(spacing * factor) / factor;\n }\n if (bounds === 'ticks') {\n niceMin = Math.floor(rmin / spacing) * spacing;\n niceMax = Math.ceil(rmax / spacing) * spacing;\n } else {\n niceMin = rmin;\n niceMax = rmax;\n }\n if (minDefined && maxDefined && step && almostWhole((max - min) / step, spacing / 1000)) {\n numSpaces = Math.round(Math.min((max - min) / spacing, maxTicks));\n spacing = (max - min) / numSpaces;\n niceMin = min;\n niceMax = max;\n } else if (countDefined) {\n niceMin = minDefined ? min : niceMin;\n niceMax = maxDefined ? max : niceMax;\n numSpaces = count - 1;\n spacing = (niceMax - niceMin) / numSpaces;\n } else {\n numSpaces = (niceMax - niceMin) / spacing;\n if (almostEquals(numSpaces, Math.round(numSpaces), spacing / 1000)) {\n numSpaces = Math.round(numSpaces);\n } else {\n numSpaces = Math.ceil(numSpaces);\n }\n }\n const decimalPlaces = Math.max(_decimalPlaces(spacing), _decimalPlaces(niceMin));\n factor = Math.pow(10, isNullOrUndef(precision) ? decimalPlaces : precision);\n niceMin = Math.round(niceMin * factor) / factor;\n niceMax = Math.round(niceMax * factor) / factor;\n let j = 0;\n if (minDefined) {\n if (includeBounds && niceMin !== min) {\n ticks.push({\n value: min\n });\n if (niceMin < min) {\n j++;\n }\n if (almostEquals(Math.round((niceMin + j * spacing) * factor) / factor, min, relativeLabelSize(min, minSpacing, generationOptions))) {\n j++;\n }\n } else if (niceMin < min) {\n j++;\n }\n }\n for (; j < numSpaces; ++j) {\n const tickValue = Math.round((niceMin + j * spacing) * factor) / factor;\n if (maxDefined && tickValue > max) {\n break;\n }\n ticks.push({\n value: tickValue\n });\n }\n if (maxDefined && includeBounds && niceMax !== max) {\n if (ticks.length && almostEquals(ticks[ticks.length - 1].value, max, relativeLabelSize(max, minSpacing, generationOptions))) {\n ticks[ticks.length - 1].value = max;\n } else {\n ticks.push({\n value: max\n });\n }\n } else if (!maxDefined || niceMax === max) {\n ticks.push({\n value: niceMax\n });\n }\n return ticks;\n}\nfunction relativeLabelSize(value, minSpacing, {\n horizontal,\n minRotation\n}) {\n const rad = toRadians(minRotation);\n const ratio = (horizontal ? Math.sin(rad) : Math.cos(rad)) || 0.001;\n const length = 0.75 * minSpacing * ('' + value).length;\n return Math.min(minSpacing / ratio, length);\n}\nclass LinearScaleBase extends Scale {\n constructor(cfg) {\n super(cfg);\n this.start = undefined;\n this.end = undefined;\n this._startValue = undefined;\n this._endValue = undefined;\n this._valueRange = 0;\n }\n parse(raw, index) {\n if (isNullOrUndef(raw)) {\n return null;\n }\n if ((typeof raw === 'number' || raw instanceof Number) && !isFinite(+raw)) {\n return null;\n }\n return +raw;\n }\n handleTickRangeOptions() {\n const {\n beginAtZero\n } = this.options;\n const {\n minDefined,\n maxDefined\n } = this.getUserBounds();\n let {\n min,\n max\n } = this;\n const setMin = v => min = minDefined ? min : v;\n const setMax = v => max = maxDefined ? max : v;\n if (beginAtZero) {\n const minSign = sign(min);\n const maxSign = sign(max);\n if (minSign < 0 && maxSign < 0) {\n setMax(0);\n } else if (minSign > 0 && maxSign > 0) {\n setMin(0);\n }\n }\n if (min === max) {\n let offset = max === 0 ? 1 : Math.abs(max * 0.05);\n setMax(max + offset);\n if (!beginAtZero) {\n setMin(min - offset);\n }\n }\n this.min = min;\n this.max = max;\n }\n getTickLimit() {\n const tickOpts = this.options.ticks;\n let {\n maxTicksLimit,\n stepSize\n } = tickOpts;\n let maxTicks;\n if (stepSize) {\n maxTicks = Math.ceil(this.max / stepSize) - Math.floor(this.min / stepSize) + 1;\n if (maxTicks > 1000) {\n console.warn(`scales.${this.id}.ticks.stepSize: ${stepSize} would result generating up to ${maxTicks} ticks. Limiting to 1000.`);\n maxTicks = 1000;\n }\n } else {\n maxTicks = this.computeTickLimit();\n maxTicksLimit = maxTicksLimit || 11;\n }\n if (maxTicksLimit) {\n maxTicks = Math.min(maxTicksLimit, maxTicks);\n }\n return maxTicks;\n }\n computeTickLimit() {\n return Number.POSITIVE_INFINITY;\n }\n buildTicks() {\n const opts = this.options;\n const tickOpts = opts.ticks;\n let maxTicks = this.getTickLimit();\n maxTicks = Math.max(2, maxTicks);\n const numericGeneratorOptions = {\n maxTicks,\n bounds: opts.bounds,\n min: opts.min,\n max: opts.max,\n precision: tickOpts.precision,\n step: tickOpts.stepSize,\n count: tickOpts.count,\n maxDigits: this._maxDigits(),\n horizontal: this.isHorizontal(),\n minRotation: tickOpts.minRotation || 0,\n includeBounds: tickOpts.includeBounds !== false\n };\n const dataRange = this._range || this;\n const ticks = generateTicks$1(numericGeneratorOptions, dataRange);\n if (opts.bounds === 'ticks') {\n _setMinAndMaxByKey(ticks, this, 'value');\n }\n if (opts.reverse) {\n ticks.reverse();\n this.start = this.max;\n this.end = this.min;\n } else {\n this.start = this.min;\n this.end = this.max;\n }\n return ticks;\n }\n configure() {\n const ticks = this.ticks;\n let start = this.min;\n let end = this.max;\n super.configure();\n if (this.options.offset && ticks.length) {\n const offset = (end - start) / Math.max(ticks.length - 1, 1) / 2;\n start -= offset;\n end += offset;\n }\n this._startValue = start;\n this._endValue = end;\n this._valueRange = end - start;\n }\n getLabelForValue(value) {\n return formatNumber(value, this.chart.options.locale, this.options.ticks.format);\n }\n}\nclass LinearScale extends LinearScaleBase {\n static id = 'linear';\n static defaults = {\n ticks: {\n callback: Ticks.formatters.numeric\n }\n };\n determineDataLimits() {\n const {\n min,\n max\n } = this.getMinMax(true);\n this.min = isNumberFinite(min) ? min : 0;\n this.max = isNumberFinite(max) ? max : 1;\n this.handleTickRangeOptions();\n }\n computeTickLimit() {\n const horizontal = this.isHorizontal();\n const length = horizontal ? this.width : this.height;\n const minRotation = toRadians(this.options.ticks.minRotation);\n const ratio = (horizontal ? Math.sin(minRotation) : Math.cos(minRotation)) || 0.001;\n const tickFont = this._resolveTickFontOptions(0);\n return Math.ceil(length / Math.min(40, tickFont.lineHeight / ratio));\n }\n getPixelForValue(value) {\n return value === null ? NaN : this.getPixelForDecimal((value - this._startValue) / this._valueRange);\n }\n getValueForPixel(pixel) {\n return this._startValue + this.getDecimalForPixel(pixel) * this._valueRange;\n }\n}\nconst log10Floor = v => Math.floor(log10(v));\nconst changeExponent = (v, m) => Math.pow(10, log10Floor(v) + m);\nfunction isMajor(tickVal) {\n const remain = tickVal / Math.pow(10, log10Floor(tickVal));\n return remain === 1;\n}\nfunction steps(min, max, rangeExp) {\n const rangeStep = Math.pow(10, rangeExp);\n const start = Math.floor(min / rangeStep);\n const end = Math.ceil(max / rangeStep);\n return end - start;\n}\nfunction startExp(min, max) {\n const range = max - min;\n let rangeExp = log10Floor(range);\n while (steps(min, max, rangeExp) > 10) {\n rangeExp++;\n }\n while (steps(min, max, rangeExp) < 10) {\n rangeExp--;\n }\n return Math.min(rangeExp, log10Floor(min));\n}\nfunction generateTicks(generationOptions, {\n min,\n max\n}) {\n min = finiteOrDefault(generationOptions.min, min);\n const ticks = [];\n const minExp = log10Floor(min);\n let exp = startExp(min, max);\n let precision = exp < 0 ? Math.pow(10, Math.abs(exp)) : 1;\n const stepSize = Math.pow(10, exp);\n const base = minExp > exp ? Math.pow(10, minExp) : 0;\n const start = Math.round((min - base) * precision) / precision;\n const offset = Math.floor((min - base) / stepSize / 10) * stepSize * 10;\n let significand = Math.floor((start - offset) / Math.pow(10, exp));\n let value = finiteOrDefault(generationOptions.min, Math.round((base + offset + significand * Math.pow(10, exp)) * precision) / precision);\n while (value < max) {\n ticks.push({\n value,\n major: isMajor(value),\n significand\n });\n if (significand >= 10) {\n significand = significand < 15 ? 15 : 20;\n } else {\n significand++;\n }\n if (significand >= 20) {\n exp++;\n significand = 2;\n precision = exp >= 0 ? 1 : precision;\n }\n value = Math.round((base + offset + significand * Math.pow(10, exp)) * precision) / precision;\n }\n const lastTick = finiteOrDefault(generationOptions.max, value);\n ticks.push({\n value: lastTick,\n major: isMajor(lastTick),\n significand\n });\n return ticks;\n}\nclass LogarithmicScale extends Scale {\n static id = 'logarithmic';\n static defaults = {\n ticks: {\n callback: Ticks.formatters.logarithmic,\n major: {\n enabled: true\n }\n }\n };\n constructor(cfg) {\n super(cfg);\n this.start = undefined;\n this.end = undefined;\n this._startValue = undefined;\n this._valueRange = 0;\n }\n parse(raw, index) {\n const value = LinearScaleBase.prototype.parse.apply(this, [raw, index]);\n if (value === 0) {\n this._zero = true;\n return undefined;\n }\n return isNumberFinite(value) && value > 0 ? value : null;\n }\n determineDataLimits() {\n const {\n min,\n max\n } = this.getMinMax(true);\n this.min = isNumberFinite(min) ? Math.max(0, min) : null;\n this.max = isNumberFinite(max) ? Math.max(0, max) : null;\n if (this.options.beginAtZero) {\n this._zero = true;\n }\n if (this._zero && this.min !== this._suggestedMin && !isNumberFinite(this._userMin)) {\n this.min = min === changeExponent(this.min, 0) ? changeExponent(this.min, -1) : changeExponent(this.min, 0);\n }\n this.handleTickRangeOptions();\n }\n handleTickRangeOptions() {\n const {\n minDefined,\n maxDefined\n } = this.getUserBounds();\n let min = this.min;\n let max = this.max;\n const setMin = v => min = minDefined ? min : v;\n const setMax = v => max = maxDefined ? max : v;\n if (min === max) {\n if (min <= 0) {\n setMin(1);\n setMax(10);\n } else {\n setMin(changeExponent(min, -1));\n setMax(changeExponent(max, +1));\n }\n }\n if (min <= 0) {\n setMin(changeExponent(max, -1));\n }\n if (max <= 0) {\n setMax(changeExponent(min, +1));\n }\n this.min = min;\n this.max = max;\n }\n buildTicks() {\n const opts = this.options;\n const generationOptions = {\n min: this._userMin,\n max: this._userMax\n };\n const ticks = generateTicks(generationOptions, this);\n if (opts.bounds === 'ticks') {\n _setMinAndMaxByKey(ticks, this, 'value');\n }\n if (opts.reverse) {\n ticks.reverse();\n this.start = this.max;\n this.end = this.min;\n } else {\n this.start = this.min;\n this.end = this.max;\n }\n return ticks;\n }\n getLabelForValue(value) {\n return value === undefined ? '0' : formatNumber(value, this.chart.options.locale, this.options.ticks.format);\n }\n configure() {\n const start = this.min;\n super.configure();\n this._startValue = log10(start);\n this._valueRange = log10(this.max) - log10(start);\n }\n getPixelForValue(value) {\n if (value === undefined || value === 0) {\n value = this.min;\n }\n if (value === null || isNaN(value)) {\n return NaN;\n }\n return this.getPixelForDecimal(value === this.min ? 0 : (log10(value) - this._startValue) / this._valueRange);\n }\n getValueForPixel(pixel) {\n const decimal = this.getDecimalForPixel(pixel);\n return Math.pow(10, this._startValue + decimal * this._valueRange);\n }\n}\nfunction getTickBackdropHeight(opts) {\n const tickOpts = opts.ticks;\n if (tickOpts.display && opts.display) {\n const padding = toPadding(tickOpts.backdropPadding);\n return valueOrDefault(tickOpts.font && tickOpts.font.size, defaults.font.size) + padding.height;\n }\n return 0;\n}\nfunction measureLabelSize(ctx, font, label) {\n label = isArray(label) ? label : [label];\n return {\n w: _longestText(ctx, font.string, label),\n h: label.length * font.lineHeight\n };\n}\nfunction determineLimits(angle, pos, size, min, max) {\n if (angle === min || angle === max) {\n return {\n start: pos - size / 2,\n end: pos + size / 2\n };\n } else if (angle < min || angle > max) {\n return {\n start: pos - size,\n end: pos\n };\n }\n return {\n start: pos,\n end: pos + size\n };\n}\nfunction fitWithPointLabels(scale) {\n const orig = {\n l: scale.left + scale._padding.left,\n r: scale.right - scale._padding.right,\n t: scale.top + scale._padding.top,\n b: scale.bottom - scale._padding.bottom\n };\n const limits = Object.assign({}, orig);\n const labelSizes = [];\n const padding = [];\n const valueCount = scale._pointLabels.length;\n const pointLabelOpts = scale.options.pointLabels;\n const additionalAngle = pointLabelOpts.centerPointLabels ? PI / valueCount : 0;\n for (let i = 0; i < valueCount; i++) {\n const opts = pointLabelOpts.setContext(scale.getPointLabelContext(i));\n padding[i] = opts.padding;\n const pointPosition = scale.getPointPosition(i, scale.drawingArea + padding[i], additionalAngle);\n const plFont = toFont(opts.font);\n const textSize = measureLabelSize(scale.ctx, plFont, scale._pointLabels[i]);\n labelSizes[i] = textSize;\n const angleRadians = _normalizeAngle(scale.getIndexAngle(i) + additionalAngle);\n const angle = Math.round(toDegrees(angleRadians));\n const hLimits = determineLimits(angle, pointPosition.x, textSize.w, 0, 180);\n const vLimits = determineLimits(angle, pointPosition.y, textSize.h, 90, 270);\n updateLimits(limits, orig, angleRadians, hLimits, vLimits);\n }\n scale.setCenterPoint(orig.l - limits.l, limits.r - orig.r, orig.t - limits.t, limits.b - orig.b);\n scale._pointLabelItems = buildPointLabelItems(scale, labelSizes, padding);\n}\nfunction updateLimits(limits, orig, angle, hLimits, vLimits) {\n const sin = Math.abs(Math.sin(angle));\n const cos = Math.abs(Math.cos(angle));\n let x = 0;\n let y = 0;\n if (hLimits.start < orig.l) {\n x = (orig.l - hLimits.start) / sin;\n limits.l = Math.min(limits.l, orig.l - x);\n } else if (hLimits.end > orig.r) {\n x = (hLimits.end - orig.r) / sin;\n limits.r = Math.max(limits.r, orig.r + x);\n }\n if (vLimits.start < orig.t) {\n y = (orig.t - vLimits.start) / cos;\n limits.t = Math.min(limits.t, orig.t - y);\n } else if (vLimits.end > orig.b) {\n y = (vLimits.end - orig.b) / cos;\n limits.b = Math.max(limits.b, orig.b + y);\n }\n}\nfunction createPointLabelItem(scale, index, itemOpts) {\n const outerDistance = scale.drawingArea;\n const {\n extra,\n additionalAngle,\n padding,\n size\n } = itemOpts;\n const pointLabelPosition = scale.getPointPosition(index, outerDistance + extra + padding, additionalAngle);\n const angle = Math.round(toDegrees(_normalizeAngle(pointLabelPosition.angle + HALF_PI)));\n const y = yForAngle(pointLabelPosition.y, size.h, angle);\n const textAlign = getTextAlignForAngle(angle);\n const left = leftForTextAlign(pointLabelPosition.x, size.w, textAlign);\n return {\n visible: true,\n x: pointLabelPosition.x,\n y,\n textAlign,\n left,\n top: y,\n right: left + size.w,\n bottom: y + size.h\n };\n}\nfunction isNotOverlapped(item, area) {\n if (!area) {\n return true;\n }\n const {\n left,\n top,\n right,\n bottom\n } = item;\n const apexesInArea = _isPointInArea({\n x: left,\n y: top\n }, area) || _isPointInArea({\n x: left,\n y: bottom\n }, area) || _isPointInArea({\n x: right,\n y: top\n }, area) || _isPointInArea({\n x: right,\n y: bottom\n }, area);\n return !apexesInArea;\n}\nfunction buildPointLabelItems(scale, labelSizes, padding) {\n const items = [];\n const valueCount = scale._pointLabels.length;\n const opts = scale.options;\n const {\n centerPointLabels,\n display\n } = opts.pointLabels;\n const itemOpts = {\n extra: getTickBackdropHeight(opts) / 2,\n additionalAngle: centerPointLabels ? PI / valueCount : 0\n };\n let area;\n for (let i = 0; i < valueCount; i++) {\n itemOpts.padding = padding[i];\n itemOpts.size = labelSizes[i];\n const item = createPointLabelItem(scale, i, itemOpts);\n items.push(item);\n if (display === 'auto') {\n item.visible = isNotOverlapped(item, area);\n if (item.visible) {\n area = item;\n }\n }\n }\n return items;\n}\nfunction getTextAlignForAngle(angle) {\n if (angle === 0 || angle === 180) {\n return 'center';\n } else if (angle < 180) {\n return 'left';\n }\n return 'right';\n}\nfunction leftForTextAlign(x, w, align) {\n if (align === 'right') {\n x -= w;\n } else if (align === 'center') {\n x -= w / 2;\n }\n return x;\n}\nfunction yForAngle(y, h, angle) {\n if (angle === 90 || angle === 270) {\n y -= h / 2;\n } else if (angle > 270 || angle < 90) {\n y -= h;\n }\n return y;\n}\nfunction drawPointLabelBox(ctx, opts, item) {\n const {\n left,\n top,\n right,\n bottom\n } = item;\n const {\n backdropColor\n } = opts;\n if (!isNullOrUndef(backdropColor)) {\n const borderRadius = toTRBLCorners(opts.borderRadius);\n const padding = toPadding(opts.backdropPadding);\n ctx.fillStyle = backdropColor;\n const backdropLeft = left - padding.left;\n const backdropTop = top - padding.top;\n const backdropWidth = right - left + padding.width;\n const backdropHeight = bottom - top + padding.height;\n if (Object.values(borderRadius).some(v => v !== 0)) {\n ctx.beginPath();\n addRoundedRectPath(ctx, {\n x: backdropLeft,\n y: backdropTop,\n w: backdropWidth,\n h: backdropHeight,\n radius: borderRadius\n });\n ctx.fill();\n } else {\n ctx.fillRect(backdropLeft, backdropTop, backdropWidth, backdropHeight);\n }\n }\n}\nfunction drawPointLabels(scale, labelCount) {\n const {\n ctx,\n options: {\n pointLabels\n }\n } = scale;\n for (let i = labelCount - 1; i >= 0; i--) {\n const item = scale._pointLabelItems[i];\n if (!item.visible) {\n continue;\n }\n const optsAtIndex = pointLabels.setContext(scale.getPointLabelContext(i));\n drawPointLabelBox(ctx, optsAtIndex, item);\n const plFont = toFont(optsAtIndex.font);\n const {\n x,\n y,\n textAlign\n } = item;\n renderText(ctx, scale._pointLabels[i], x, y + plFont.lineHeight / 2, plFont, {\n color: optsAtIndex.color,\n textAlign: textAlign,\n textBaseline: 'middle'\n });\n }\n}\nfunction pathRadiusLine(scale, radius, circular, labelCount) {\n const {\n ctx\n } = scale;\n if (circular) {\n ctx.arc(scale.xCenter, scale.yCenter, radius, 0, TAU);\n } else {\n let pointPosition = scale.getPointPosition(0, radius);\n ctx.moveTo(pointPosition.x, pointPosition.y);\n for (let i = 1; i < labelCount; i++) {\n pointPosition = scale.getPointPosition(i, radius);\n ctx.lineTo(pointPosition.x, pointPosition.y);\n }\n }\n}\nfunction drawRadiusLine(scale, gridLineOpts, radius, labelCount, borderOpts) {\n const ctx = scale.ctx;\n const circular = gridLineOpts.circular;\n const {\n color,\n lineWidth\n } = gridLineOpts;\n if (!circular && !labelCount || !color || !lineWidth || radius < 0) {\n return;\n }\n ctx.save();\n ctx.strokeStyle = color;\n ctx.lineWidth = lineWidth;\n ctx.setLineDash(borderOpts.dash || []);\n ctx.lineDashOffset = borderOpts.dashOffset;\n ctx.beginPath();\n pathRadiusLine(scale, radius, circular, labelCount);\n ctx.closePath();\n ctx.stroke();\n ctx.restore();\n}\nfunction createPointLabelContext(parent, index, label) {\n return createContext(parent, {\n label,\n index,\n type: 'pointLabel'\n });\n}\nclass RadialLinearScale extends LinearScaleBase {\n static id = 'radialLinear';\n static defaults = {\n display: true,\n animate: true,\n position: 'chartArea',\n angleLines: {\n display: true,\n lineWidth: 1,\n borderDash: [],\n borderDashOffset: 0.0\n },\n grid: {\n circular: false\n },\n startAngle: 0,\n ticks: {\n showLabelBackdrop: true,\n callback: Ticks.formatters.numeric\n },\n pointLabels: {\n backdropColor: undefined,\n backdropPadding: 2,\n display: true,\n font: {\n size: 10\n },\n callback(label) {\n return label;\n },\n padding: 5,\n centerPointLabels: false\n }\n };\n static defaultRoutes = {\n 'angleLines.color': 'borderColor',\n 'pointLabels.color': 'color',\n 'ticks.color': 'color'\n };\n static descriptors = {\n angleLines: {\n _fallback: 'grid'\n }\n };\n constructor(cfg) {\n super(cfg);\n this.xCenter = undefined;\n this.yCenter = undefined;\n this.drawingArea = undefined;\n this._pointLabels = [];\n this._pointLabelItems = [];\n }\n setDimensions() {\n const padding = this._padding = toPadding(getTickBackdropHeight(this.options) / 2);\n const w = this.width = this.maxWidth - padding.width;\n const h = this.height = this.maxHeight - padding.height;\n this.xCenter = Math.floor(this.left + w / 2 + padding.left);\n this.yCenter = Math.floor(this.top + h / 2 + padding.top);\n this.drawingArea = Math.floor(Math.min(w, h) / 2);\n }\n determineDataLimits() {\n const {\n min,\n max\n } = this.getMinMax(false);\n this.min = isNumberFinite(min) && !isNaN(min) ? min : 0;\n this.max = isNumberFinite(max) && !isNaN(max) ? max : 0;\n this.handleTickRangeOptions();\n }\n computeTickLimit() {\n return Math.ceil(this.drawingArea / getTickBackdropHeight(this.options));\n }\n generateTickLabels(ticks) {\n LinearScaleBase.prototype.generateTickLabels.call(this, ticks);\n this._pointLabels = this.getLabels().map((value, index) => {\n const label = callback(this.options.pointLabels.callback, [value, index], this);\n return label || label === 0 ? label : '';\n }).filter((v, i) => this.chart.getDataVisibility(i));\n }\n fit() {\n const opts = this.options;\n if (opts.display && opts.pointLabels.display) {\n fitWithPointLabels(this);\n } else {\n this.setCenterPoint(0, 0, 0, 0);\n }\n }\n setCenterPoint(leftMovement, rightMovement, topMovement, bottomMovement) {\n this.xCenter += Math.floor((leftMovement - rightMovement) / 2);\n this.yCenter += Math.floor((topMovement - bottomMovement) / 2);\n this.drawingArea -= Math.min(this.drawingArea / 2, Math.max(leftMovement, rightMovement, topMovement, bottomMovement));\n }\n getIndexAngle(index) {\n const angleMultiplier = TAU / (this._pointLabels.length || 1);\n const startAngle = this.options.startAngle || 0;\n return _normalizeAngle(index * angleMultiplier + toRadians(startAngle));\n }\n getDistanceFromCenterForValue(value) {\n if (isNullOrUndef(value)) {\n return NaN;\n }\n const scalingFactor = this.drawingArea / (this.max - this.min);\n if (this.options.reverse) {\n return (this.max - value) * scalingFactor;\n }\n return (value - this.min) * scalingFactor;\n }\n getValueForDistanceFromCenter(distance) {\n if (isNullOrUndef(distance)) {\n return NaN;\n }\n const scaledDistance = distance / (this.drawingArea / (this.max - this.min));\n return this.options.reverse ? this.max - scaledDistance : this.min + scaledDistance;\n }\n getPointLabelContext(index) {\n const pointLabels = this._pointLabels || [];\n if (index >= 0 && index < pointLabels.length) {\n const pointLabel = pointLabels[index];\n return createPointLabelContext(this.getContext(), index, pointLabel);\n }\n }\n getPointPosition(index, distanceFromCenter, additionalAngle = 0) {\n const angle = this.getIndexAngle(index) - HALF_PI + additionalAngle;\n return {\n x: Math.cos(angle) * distanceFromCenter + this.xCenter,\n y: Math.sin(angle) * distanceFromCenter + this.yCenter,\n angle\n };\n }\n getPointPositionForValue(index, value) {\n return this.getPointPosition(index, this.getDistanceFromCenterForValue(value));\n }\n getBasePosition(index) {\n return this.getPointPositionForValue(index || 0, this.getBaseValue());\n }\n getPointLabelPosition(index) {\n const {\n left,\n top,\n right,\n bottom\n } = this._pointLabelItems[index];\n return {\n left,\n top,\n right,\n bottom\n };\n }\n drawBackground() {\n const {\n backgroundColor,\n grid: {\n circular\n }\n } = this.options;\n if (backgroundColor) {\n const ctx = this.ctx;\n ctx.save();\n ctx.beginPath();\n pathRadiusLine(this, this.getDistanceFromCenterForValue(this._endValue), circular, this._pointLabels.length);\n ctx.closePath();\n ctx.fillStyle = backgroundColor;\n ctx.fill();\n ctx.restore();\n }\n }\n drawGrid() {\n const ctx = this.ctx;\n const opts = this.options;\n const {\n angleLines,\n grid,\n border\n } = opts;\n const labelCount = this._pointLabels.length;\n let i, offset, position;\n if (opts.pointLabels.display) {\n drawPointLabels(this, labelCount);\n }\n if (grid.display) {\n this.ticks.forEach((tick, index) => {\n if (index !== 0 || index === 0 && this.min < 0) {\n offset = this.getDistanceFromCenterForValue(tick.value);\n const context = this.getContext(index);\n const optsAtIndex = grid.setContext(context);\n const optsAtIndexBorder = border.setContext(context);\n drawRadiusLine(this, optsAtIndex, offset, labelCount, optsAtIndexBorder);\n }\n });\n }\n if (angleLines.display) {\n ctx.save();\n for (i = labelCount - 1; i >= 0; i--) {\n const optsAtIndex = angleLines.setContext(this.getPointLabelContext(i));\n const {\n color,\n lineWidth\n } = optsAtIndex;\n if (!lineWidth || !color) {\n continue;\n }\n ctx.lineWidth = lineWidth;\n ctx.strokeStyle = color;\n ctx.setLineDash(optsAtIndex.borderDash);\n ctx.lineDashOffset = optsAtIndex.borderDashOffset;\n offset = this.getDistanceFromCenterForValue(opts.reverse ? this.min : this.max);\n position = this.getPointPosition(i, offset);\n ctx.beginPath();\n ctx.moveTo(this.xCenter, this.yCenter);\n ctx.lineTo(position.x, position.y);\n ctx.stroke();\n }\n ctx.restore();\n }\n }\n drawBorder() {}\n drawLabels() {\n const ctx = this.ctx;\n const opts = this.options;\n const tickOpts = opts.ticks;\n if (!tickOpts.display) {\n return;\n }\n const startAngle = this.getIndexAngle(0);\n let offset, width;\n ctx.save();\n ctx.translate(this.xCenter, this.yCenter);\n ctx.rotate(startAngle);\n ctx.textAlign = 'center';\n ctx.textBaseline = 'middle';\n this.ticks.forEach((tick, index) => {\n if (index === 0 && this.min >= 0 && !opts.reverse) {\n return;\n }\n const optsAtIndex = tickOpts.setContext(this.getContext(index));\n const tickFont = toFont(optsAtIndex.font);\n offset = this.getDistanceFromCenterForValue(this.ticks[index].value);\n if (optsAtIndex.showLabelBackdrop) {\n ctx.font = tickFont.string;\n width = ctx.measureText(tick.label).width;\n ctx.fillStyle = optsAtIndex.backdropColor;\n const padding = toPadding(optsAtIndex.backdropPadding);\n ctx.fillRect(-width / 2 - padding.left, -offset - tickFont.size / 2 - padding.top, width + padding.width, tickFont.size + padding.height);\n }\n renderText(ctx, tick.label, 0, -offset, tickFont, {\n color: optsAtIndex.color,\n strokeColor: optsAtIndex.textStrokeColor,\n strokeWidth: optsAtIndex.textStrokeWidth\n });\n });\n ctx.restore();\n }\n drawTitle() {}\n}\nconst INTERVALS = {\n millisecond: {\n common: true,\n size: 1,\n steps: 1000\n },\n second: {\n common: true,\n size: 1000,\n steps: 60\n },\n minute: {\n common: true,\n size: 60000,\n steps: 60\n },\n hour: {\n common: true,\n size: 3600000,\n steps: 24\n },\n day: {\n common: true,\n size: 86400000,\n steps: 30\n },\n week: {\n common: false,\n size: 604800000,\n steps: 4\n },\n month: {\n common: true,\n size: 2.628e9,\n steps: 12\n },\n quarter: {\n common: false,\n size: 7.884e9,\n steps: 4\n },\n year: {\n common: true,\n size: 3.154e10\n }\n};\nconst UNITS = /* #__PURE__ */Object.keys(INTERVALS);\nfunction sorter(a, b) {\n return a - b;\n}\nfunction parse(scale, input) {\n if (isNullOrUndef(input)) {\n return null;\n }\n const adapter = scale._adapter;\n const {\n parser,\n round,\n isoWeekday\n } = scale._parseOpts;\n let value = input;\n if (typeof parser === 'function') {\n value = parser(value);\n }\n if (!isNumberFinite(value)) {\n value = typeof parser === 'string' ? adapter.parse(value, parser) : adapter.parse(value);\n }\n if (value === null) {\n return null;\n }\n if (round) {\n value = round === 'week' && (isNumber(isoWeekday) || isoWeekday === true) ? adapter.startOf(value, 'isoWeek', isoWeekday) : adapter.startOf(value, round);\n }\n return +value;\n}\nfunction determineUnitForAutoTicks(minUnit, min, max, capacity) {\n const ilen = UNITS.length;\n for (let i = UNITS.indexOf(minUnit); i < ilen - 1; ++i) {\n const interval = INTERVALS[UNITS[i]];\n const factor = interval.steps ? interval.steps : Number.MAX_SAFE_INTEGER;\n if (interval.common && Math.ceil((max - min) / (factor * interval.size)) <= capacity) {\n return UNITS[i];\n }\n }\n return UNITS[ilen - 1];\n}\nfunction determineUnitForFormatting(scale, numTicks, minUnit, min, max) {\n for (let i = UNITS.length - 1; i >= UNITS.indexOf(minUnit); i--) {\n const unit = UNITS[i];\n if (INTERVALS[unit].common && scale._adapter.diff(max, min, unit) >= numTicks - 1) {\n return unit;\n }\n }\n return UNITS[minUnit ? UNITS.indexOf(minUnit) : 0];\n}\nfunction determineMajorUnit(unit) {\n for (let i = UNITS.indexOf(unit) + 1, ilen = UNITS.length; i < ilen; ++i) {\n if (INTERVALS[UNITS[i]].common) {\n return UNITS[i];\n }\n }\n}\nfunction addTick(ticks, time, timestamps) {\n if (!timestamps) {\n ticks[time] = true;\n } else if (timestamps.length) {\n const {\n lo,\n hi\n } = _lookup(timestamps, time);\n const timestamp = timestamps[lo] >= time ? timestamps[lo] : timestamps[hi];\n ticks[timestamp] = true;\n }\n}\nfunction setMajorTicks(scale, ticks, map, majorUnit) {\n const adapter = scale._adapter;\n const first = +adapter.startOf(ticks[0].value, majorUnit);\n const last = ticks[ticks.length - 1].value;\n let major, index;\n for (major = first; major <= last; major = +adapter.add(major, 1, majorUnit)) {\n index = map[major];\n if (index >= 0) {\n ticks[index].major = true;\n }\n }\n return ticks;\n}\nfunction ticksFromTimestamps(scale, values, majorUnit) {\n const ticks = [];\n const map = {};\n const ilen = values.length;\n let i, value;\n for (i = 0; i < ilen; ++i) {\n value = values[i];\n map[value] = i;\n ticks.push({\n value,\n major: false\n });\n }\n return ilen === 0 || !majorUnit ? ticks : setMajorTicks(scale, ticks, map, majorUnit);\n}\nlet TimeScale = /*#__PURE__*/(() => {\n class TimeScale extends Scale {\n static id = 'time';\n static defaults = {\n bounds: 'data',\n adapters: {},\n time: {\n parser: false,\n unit: false,\n round: false,\n isoWeekday: false,\n minUnit: 'millisecond',\n displayFormats: {}\n },\n ticks: {\n source: 'auto',\n callback: false,\n major: {\n enabled: false\n }\n }\n };\n constructor(props) {\n super(props);\n this._cache = {\n data: [],\n labels: [],\n all: []\n };\n this._unit = 'day';\n this._majorUnit = undefined;\n this._offsets = {};\n this._normalized = false;\n this._parseOpts = undefined;\n }\n init(scaleOpts, opts = {}) {\n const time = scaleOpts.time || (scaleOpts.time = {});\n const adapter = this._adapter = new adapters._date(scaleOpts.adapters.date);\n adapter.init(opts);\n mergeIf(time.displayFormats, adapter.formats());\n this._parseOpts = {\n parser: time.parser,\n round: time.round,\n isoWeekday: time.isoWeekday\n };\n super.init(scaleOpts);\n this._normalized = opts.normalized;\n }\n parse(raw, index) {\n if (raw === undefined) {\n return null;\n }\n return parse(this, raw);\n }\n beforeLayout() {\n super.beforeLayout();\n this._cache = {\n data: [],\n labels: [],\n all: []\n };\n }\n determineDataLimits() {\n const options = this.options;\n const adapter = this._adapter;\n const unit = options.time.unit || 'day';\n let {\n min,\n max,\n minDefined,\n maxDefined\n } = this.getUserBounds();\n function _applyBounds(bounds) {\n if (!minDefined && !isNaN(bounds.min)) {\n min = Math.min(min, bounds.min);\n }\n if (!maxDefined && !isNaN(bounds.max)) {\n max = Math.max(max, bounds.max);\n }\n }\n if (!minDefined || !maxDefined) {\n _applyBounds(this._getLabelBounds());\n if (options.bounds !== 'ticks' || options.ticks.source !== 'labels') {\n _applyBounds(this.getMinMax(false));\n }\n }\n min = isNumberFinite(min) && !isNaN(min) ? min : +adapter.startOf(Date.now(), unit);\n max = isNumberFinite(max) && !isNaN(max) ? max : +adapter.endOf(Date.now(), unit) + 1;\n this.min = Math.min(min, max - 1);\n this.max = Math.max(min + 1, max);\n }\n _getLabelBounds() {\n const arr = this.getLabelTimestamps();\n let min = Number.POSITIVE_INFINITY;\n let max = Number.NEGATIVE_INFINITY;\n if (arr.length) {\n min = arr[0];\n max = arr[arr.length - 1];\n }\n return {\n min,\n max\n };\n }\n buildTicks() {\n const options = this.options;\n const timeOpts = options.time;\n const tickOpts = options.ticks;\n const timestamps = tickOpts.source === 'labels' ? this.getLabelTimestamps() : this._generate();\n if (options.bounds === 'ticks' && timestamps.length) {\n this.min = this._userMin || timestamps[0];\n this.max = this._userMax || timestamps[timestamps.length - 1];\n }\n const min = this.min;\n const max = this.max;\n const ticks = _filterBetween(timestamps, min, max);\n this._unit = timeOpts.unit || (tickOpts.autoSkip ? determineUnitForAutoTicks(timeOpts.minUnit, this.min, this.max, this._getLabelCapacity(min)) : determineUnitForFormatting(this, ticks.length, timeOpts.minUnit, this.min, this.max));\n this._majorUnit = !tickOpts.major.enabled || this._unit === 'year' ? undefined : determineMajorUnit(this._unit);\n this.initOffsets(timestamps);\n if (options.reverse) {\n ticks.reverse();\n }\n return ticksFromTimestamps(this, ticks, this._majorUnit);\n }\n afterAutoSkip() {\n if (this.options.offsetAfterAutoskip) {\n this.initOffsets(this.ticks.map(tick => +tick.value));\n }\n }\n initOffsets(timestamps = []) {\n let start = 0;\n let end = 0;\n let first, last;\n if (this.options.offset && timestamps.length) {\n first = this.getDecimalForValue(timestamps[0]);\n if (timestamps.length === 1) {\n start = 1 - first;\n } else {\n start = (this.getDecimalForValue(timestamps[1]) - first) / 2;\n }\n last = this.getDecimalForValue(timestamps[timestamps.length - 1]);\n if (timestamps.length === 1) {\n end = last;\n } else {\n end = (last - this.getDecimalForValue(timestamps[timestamps.length - 2])) / 2;\n }\n }\n const limit = timestamps.length < 3 ? 0.5 : 0.25;\n start = _limitValue(start, 0, limit);\n end = _limitValue(end, 0, limit);\n this._offsets = {\n start,\n end,\n factor: 1 / (start + 1 + end)\n };\n }\n _generate() {\n const adapter = this._adapter;\n const min = this.min;\n const max = this.max;\n const options = this.options;\n const timeOpts = options.time;\n const minor = timeOpts.unit || determineUnitForAutoTicks(timeOpts.minUnit, min, max, this._getLabelCapacity(min));\n const stepSize = valueOrDefault(options.ticks.stepSize, 1);\n const weekday = minor === 'week' ? timeOpts.isoWeekday : false;\n const hasWeekday = isNumber(weekday) || weekday === true;\n const ticks = {};\n let first = min;\n let time, count;\n if (hasWeekday) {\n first = +adapter.startOf(first, 'isoWeek', weekday);\n }\n first = +adapter.startOf(first, hasWeekday ? 'day' : minor);\n if (adapter.diff(max, min, minor) > 100000 * stepSize) {\n throw new Error(min + ' and ' + max + ' are too far apart with stepSize of ' + stepSize + ' ' + minor);\n }\n const timestamps = options.ticks.source === 'data' && this.getDataTimestamps();\n for (time = first, count = 0; time < max; time = +adapter.add(time, stepSize, minor), count++) {\n addTick(ticks, time, timestamps);\n }\n if (time === max || options.bounds === 'ticks' || count === 1) {\n addTick(ticks, time, timestamps);\n }\n return Object.keys(ticks).sort(sorter).map(x => +x);\n }\n getLabelForValue(value) {\n const adapter = this._adapter;\n const timeOpts = this.options.time;\n if (timeOpts.tooltipFormat) {\n return adapter.format(value, timeOpts.tooltipFormat);\n }\n return adapter.format(value, timeOpts.displayFormats.datetime);\n }\n format(value, format) {\n const options = this.options;\n const formats = options.time.displayFormats;\n const unit = this._unit;\n const fmt = format || formats[unit];\n return this._adapter.format(value, fmt);\n }\n _tickFormatFunction(time, index, ticks, format) {\n const options = this.options;\n const formatter = options.ticks.callback;\n if (formatter) {\n return callback(formatter, [time, index, ticks], this);\n }\n const formats = options.time.displayFormats;\n const unit = this._unit;\n const majorUnit = this._majorUnit;\n const minorFormat = unit && formats[unit];\n const majorFormat = majorUnit && formats[majorUnit];\n const tick = ticks[index];\n const major = majorUnit && majorFormat && tick && tick.major;\n return this._adapter.format(time, format || (major ? majorFormat : minorFormat));\n }\n generateTickLabels(ticks) {\n let i, ilen, tick;\n for (i = 0, ilen = ticks.length; i < ilen; ++i) {\n tick = ticks[i];\n tick.label = this._tickFormatFunction(tick.value, i, ticks);\n }\n }\n getDecimalForValue(value) {\n return value === null ? NaN : (value - this.min) / (this.max - this.min);\n }\n getPixelForValue(value) {\n const offsets = this._offsets;\n const pos = this.getDecimalForValue(value);\n return this.getPixelForDecimal((offsets.start + pos) * offsets.factor);\n }\n getValueForPixel(pixel) {\n const offsets = this._offsets;\n const pos = this.getDecimalForPixel(pixel) / offsets.factor - offsets.end;\n return this.min + pos * (this.max - this.min);\n }\n _getLabelSize(label) {\n const ticksOpts = this.options.ticks;\n const tickLabelWidth = this.ctx.measureText(label).width;\n const angle = toRadians(this.isHorizontal() ? ticksOpts.maxRotation : ticksOpts.minRotation);\n const cosRotation = Math.cos(angle);\n const sinRotation = Math.sin(angle);\n const tickFontSize = this._resolveTickFontOptions(0).size;\n return {\n w: tickLabelWidth * cosRotation + tickFontSize * sinRotation,\n h: tickLabelWidth * sinRotation + tickFontSize * cosRotation\n };\n }\n _getLabelCapacity(exampleTime) {\n const timeOpts = this.options.time;\n const displayFormats = timeOpts.displayFormats;\n const format = displayFormats[timeOpts.unit] || displayFormats.millisecond;\n const exampleLabel = this._tickFormatFunction(exampleTime, 0, ticksFromTimestamps(this, [exampleTime], this._majorUnit), format);\n const size = this._getLabelSize(exampleLabel);\n const capacity = Math.floor(this.isHorizontal() ? this.width / size.w : this.height / size.h) - 1;\n return capacity > 0 ? capacity : 1;\n }\n getDataTimestamps() {\n let timestamps = this._cache.data || [];\n let i, ilen;\n if (timestamps.length) {\n return timestamps;\n }\n const metas = this.getMatchingVisibleMetas();\n if (this._normalized && metas.length) {\n return this._cache.data = metas[0].controller.getAllParsedValues(this);\n }\n for (i = 0, ilen = metas.length; i < ilen; ++i) {\n timestamps = timestamps.concat(metas[i].controller.getAllParsedValues(this));\n }\n return this._cache.data = this.normalize(timestamps);\n }\n getLabelTimestamps() {\n const timestamps = this._cache.labels || [];\n let i, ilen;\n if (timestamps.length) {\n return timestamps;\n }\n const labels = this.getLabels();\n for (i = 0, ilen = labels.length; i < ilen; ++i) {\n timestamps.push(parse(this, labels[i]));\n }\n return this._cache.labels = this._normalized ? timestamps : this.normalize(timestamps);\n }\n normalize(values) {\n return _arrayUnique(values.sort(sorter));\n }\n }\n return TimeScale;\n})();\nfunction interpolate(table, val, reverse) {\n let lo = 0;\n let hi = table.length - 1;\n let prevSource, nextSource, prevTarget, nextTarget;\n if (reverse) {\n if (val >= table[lo].pos && val <= table[hi].pos) {\n ({\n lo,\n hi\n } = _lookupByKey(table, 'pos', val));\n }\n ({\n pos: prevSource,\n time: prevTarget\n } = table[lo]);\n ({\n pos: nextSource,\n time: nextTarget\n } = table[hi]);\n } else {\n if (val >= table[lo].time && val <= table[hi].time) {\n ({\n lo,\n hi\n } = _lookupByKey(table, 'time', val));\n }\n ({\n time: prevSource,\n pos: prevTarget\n } = table[lo]);\n ({\n time: nextSource,\n pos: nextTarget\n } = table[hi]);\n }\n const span = nextSource - prevSource;\n return span ? prevTarget + (nextTarget - prevTarget) * (val - prevSource) / span : prevTarget;\n}\nclass TimeSeriesScale extends TimeScale {\n static id = 'timeseries';\n static defaults = TimeScale.defaults;\n constructor(props) {\n super(props);\n this._table = [];\n this._minPos = undefined;\n this._tableRange = undefined;\n }\n initOffsets() {\n const timestamps = this._getTimestampsForTable();\n const table = this._table = this.buildLookupTable(timestamps);\n this._minPos = interpolate(table, this.min);\n this._tableRange = interpolate(table, this.max) - this._minPos;\n super.initOffsets(timestamps);\n }\n buildLookupTable(timestamps) {\n const {\n min,\n max\n } = this;\n const items = [];\n const table = [];\n let i, ilen, prev, curr, next;\n for (i = 0, ilen = timestamps.length; i < ilen; ++i) {\n curr = timestamps[i];\n if (curr >= min && curr <= max) {\n items.push(curr);\n }\n }\n if (items.length < 2) {\n return [{\n time: min,\n pos: 0\n }, {\n time: max,\n pos: 1\n }];\n }\n for (i = 0, ilen = items.length; i < ilen; ++i) {\n next = items[i + 1];\n prev = items[i - 1];\n curr = items[i];\n if (Math.round((next + prev) / 2) !== curr) {\n table.push({\n time: curr,\n pos: i / (ilen - 1)\n });\n }\n }\n return table;\n }\n _generate() {\n const min = this.min;\n const max = this.max;\n let timestamps = super.getDataTimestamps();\n if (!timestamps.includes(min) || !timestamps.length) {\n timestamps.splice(0, 0, min);\n }\n if (!timestamps.includes(max) || timestamps.length === 1) {\n timestamps.push(max);\n }\n return timestamps.sort((a, b) => a - b);\n }\n _getTimestampsForTable() {\n let timestamps = this._cache.all || [];\n if (timestamps.length) {\n return timestamps;\n }\n const data = this.getDataTimestamps();\n const label = this.getLabelTimestamps();\n if (data.length && label.length) {\n timestamps = this.normalize(data.concat(label));\n } else {\n timestamps = data.length ? data : label;\n }\n timestamps = this._cache.all = timestamps;\n return timestamps;\n }\n getDecimalForValue(value) {\n return (interpolate(this._table, value) - this._minPos) / this._tableRange;\n }\n getValueForPixel(pixel) {\n const offsets = this._offsets;\n const decimal = this.getDecimalForPixel(pixel) / offsets.factor - offsets.end;\n return interpolate(this._table, decimal * this._tableRange + this._minPos, true);\n }\n}\nvar scales = /*#__PURE__*/Object.freeze({\n __proto__: null,\n CategoryScale: CategoryScale,\n LinearScale: LinearScale,\n LogarithmicScale: LogarithmicScale,\n RadialLinearScale: RadialLinearScale,\n TimeScale: TimeScale,\n TimeSeriesScale: TimeSeriesScale\n});\nconst registerables = [controllers, elements, plugins, scales];\nexport { Animation, Animations, ArcElement, BarController, BarElement, BasePlatform, BasicPlatform, BubbleController, CategoryScale, Chart, plugin_colors as Colors, DatasetController, plugin_decimation as Decimation, DomPlatform, DoughnutController, Element, index as Filler, Interaction, plugin_legend as Legend, LineController, LineElement, LinearScale, LogarithmicScale, PieController, PointElement, PolarAreaController, RadarController, RadialLinearScale, Scale, ScatterController, plugin_subtitle as SubTitle, Ticks, TimeScale, TimeSeriesScale, plugin_title as Title, plugin_tooltip as Tooltip, adapters as _adapters, _detectPlatform, animator, controllers, defaults, elements, layouts, plugins, registerables, registry, scales };\n","/** Detect free variable `global` from Node.js. */\nvar freeGlobal = typeof global == 'object' && global && global.Object === Object && global;\nexport default freeGlobal;","import freeGlobal from './_freeGlobal.js';\n\n/** Detect free variable `self`. */\nvar freeSelf = typeof self == 'object' && self && self.Object === Object && self;\n\n/** Used as a reference to the global object. */\nvar root = freeGlobal || freeSelf || Function('return this')();\nexport default root;","import root from './_root.js';\n\n/** Built-in value references. */\nvar Symbol = root.Symbol;\nexport default Symbol;","import Symbol from './_Symbol.js';\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Used to resolve the\n * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)\n * of values.\n */\nvar nativeObjectToString = objectProto.toString;\n\n/** Built-in value references. */\nvar symToStringTag = Symbol ? Symbol.toStringTag : undefined;\n\n/**\n * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.\n *\n * @private\n * @param {*} value The value to query.\n * @returns {string} Returns the raw `toStringTag`.\n */\nfunction getRawTag(value) {\n var isOwn = hasOwnProperty.call(value, symToStringTag),\n tag = value[symToStringTag];\n try {\n value[symToStringTag] = undefined;\n var unmasked = true;\n } catch (e) {}\n var result = nativeObjectToString.call(value);\n if (unmasked) {\n if (isOwn) {\n value[symToStringTag] = tag;\n } else {\n delete value[symToStringTag];\n }\n }\n return result;\n}\nexport default getRawTag;","/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/**\n * Used to resolve the\n * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)\n * of values.\n */\nvar nativeObjectToString = objectProto.toString;\n\n/**\n * Converts `value` to a string using `Object.prototype.toString`.\n *\n * @private\n * @param {*} value The value to convert.\n * @returns {string} Returns the converted string.\n */\nfunction objectToString(value) {\n return nativeObjectToString.call(value);\n}\nexport default objectToString;","import Symbol from './_Symbol.js';\nimport getRawTag from './_getRawTag.js';\nimport objectToString from './_objectToString.js';\n\n/** `Object#toString` result references. */\nvar nullTag = '[object Null]',\n undefinedTag = '[object Undefined]';\n\n/** Built-in value references. */\nvar symToStringTag = Symbol ? Symbol.toStringTag : undefined;\n\n/**\n * The base implementation of `getTag` without fallbacks for buggy environments.\n *\n * @private\n * @param {*} value The value to query.\n * @returns {string} Returns the `toStringTag`.\n */\nfunction baseGetTag(value) {\n if (value == null) {\n return value === undefined ? undefinedTag : nullTag;\n }\n return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);\n}\nexport default baseGetTag;","/**\n * Checks if `value` is object-like. A value is object-like if it's not `null`\n * and has a `typeof` result of \"object\".\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is object-like, else `false`.\n * @example\n *\n * _.isObjectLike({});\n * // => true\n *\n * _.isObjectLike([1, 2, 3]);\n * // => true\n *\n * _.isObjectLike(_.noop);\n * // => false\n *\n * _.isObjectLike(null);\n * // => false\n */\nfunction isObjectLike(value) {\n return value != null && typeof value == 'object';\n}\nexport default isObjectLike;","/**\n * Checks if `value` is classified as an `Array` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an array, else `false`.\n * @example\n *\n * _.isArray([1, 2, 3]);\n * // => true\n *\n * _.isArray(document.body.children);\n * // => false\n *\n * _.isArray('abc');\n * // => false\n *\n * _.isArray(_.noop);\n * // => false\n */\nvar isArray = Array.isArray;\nexport default isArray;","/**\n * Checks if `value` is the\n * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)\n * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an object, else `false`.\n * @example\n *\n * _.isObject({});\n * // => true\n *\n * _.isObject([1, 2, 3]);\n * // => true\n *\n * _.isObject(_.noop);\n * // => true\n *\n * _.isObject(null);\n * // => false\n */\nfunction isObject(value) {\n var type = typeof value;\n return value != null && (type == 'object' || type == 'function');\n}\nexport default isObject;","/**\n * This method returns the first argument it receives.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Util\n * @param {*} value Any value.\n * @returns {*} Returns `value`.\n * @example\n *\n * var object = { 'a': 1 };\n *\n * console.log(_.identity(object) === object);\n * // => true\n */\nfunction identity(value) {\n return value;\n}\nexport default identity;","import baseGetTag from './_baseGetTag.js';\nimport isObject from './isObject.js';\n\n/** `Object#toString` result references. */\nvar asyncTag = '[object AsyncFunction]',\n funcTag = '[object Function]',\n genTag = '[object GeneratorFunction]',\n proxyTag = '[object Proxy]';\n\n/**\n * Checks if `value` is classified as a `Function` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a function, else `false`.\n * @example\n *\n * _.isFunction(_);\n * // => true\n *\n * _.isFunction(/abc/);\n * // => false\n */\nfunction isFunction(value) {\n if (!isObject(value)) {\n return false;\n }\n // The use of `Object#toString` avoids issues with the `typeof` operator\n // in Safari 9 which returns 'object' for typed arrays and other constructors.\n var tag = baseGetTag(value);\n return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;\n}\nexport default isFunction;","import root from './_root.js';\n\n/** Used to detect overreaching core-js shims. */\nvar coreJsData = root['__core-js_shared__'];\nexport default coreJsData;","import coreJsData from './_coreJsData.js';\n\n/** Used to detect methods masquerading as native. */\nvar maskSrcKey = function () {\n var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');\n return uid ? 'Symbol(src)_1.' + uid : '';\n}();\n\n/**\n * Checks if `func` has its source masked.\n *\n * @private\n * @param {Function} func The function to check.\n * @returns {boolean} Returns `true` if `func` is masked, else `false`.\n */\nfunction isMasked(func) {\n return !!maskSrcKey && maskSrcKey in func;\n}\nexport default isMasked;","/** Used for built-in method references. */\nvar funcProto = Function.prototype;\n\n/** Used to resolve the decompiled source of functions. */\nvar funcToString = funcProto.toString;\n\n/**\n * Converts `func` to its source code.\n *\n * @private\n * @param {Function} func The function to convert.\n * @returns {string} Returns the source code.\n */\nfunction toSource(func) {\n if (func != null) {\n try {\n return funcToString.call(func);\n } catch (e) {}\n try {\n return func + '';\n } catch (e) {}\n }\n return '';\n}\nexport default toSource;","import isFunction from './isFunction.js';\nimport isMasked from './_isMasked.js';\nimport isObject from './isObject.js';\nimport toSource from './_toSource.js';\n\n/**\n * Used to match `RegExp`\n * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).\n */\nvar reRegExpChar = /[\\\\^$.*+?()[\\]{}|]/g;\n\n/** Used to detect host constructors (Safari). */\nvar reIsHostCtor = /^\\[object .+?Constructor\\]$/;\n\n/** Used for built-in method references. */\nvar funcProto = Function.prototype,\n objectProto = Object.prototype;\n\n/** Used to resolve the decompiled source of functions. */\nvar funcToString = funcProto.toString;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/** Used to detect if a method is native. */\nvar reIsNative = RegExp('^' + funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\\\$&').replace(/hasOwnProperty|(function).*?(?=\\\\\\()| for .+?(?=\\\\\\])/g, '$1.*?') + '$');\n\n/**\n * The base implementation of `_.isNative` without bad shim checks.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a native function,\n * else `false`.\n */\nfunction baseIsNative(value) {\n if (!isObject(value) || isMasked(value)) {\n return false;\n }\n var pattern = isFunction(value) ? reIsNative : reIsHostCtor;\n return pattern.test(toSource(value));\n}\nexport default baseIsNative;","/**\n * Gets the value at `key` of `object`.\n *\n * @private\n * @param {Object} [object] The object to query.\n * @param {string} key The key of the property to get.\n * @returns {*} Returns the property value.\n */\nfunction getValue(object, key) {\n return object == null ? undefined : object[key];\n}\nexport default getValue;","import baseIsNative from './_baseIsNative.js';\nimport getValue from './_getValue.js';\n\n/**\n * Gets the native function at `key` of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {string} key The key of the method to get.\n * @returns {*} Returns the function if it's native, else `undefined`.\n */\nfunction getNative(object, key) {\n var value = getValue(object, key);\n return baseIsNative(value) ? value : undefined;\n}\nexport default getNative;","import isObject from './isObject.js';\n\n/** Built-in value references. */\nvar objectCreate = Object.create;\n\n/**\n * The base implementation of `_.create` without support for assigning\n * properties to the created object.\n *\n * @private\n * @param {Object} proto The object to inherit from.\n * @returns {Object} Returns the new object.\n */\nvar baseCreate = function () {\n function object() {}\n return function (proto) {\n if (!isObject(proto)) {\n return {};\n }\n if (objectCreate) {\n return objectCreate(proto);\n }\n object.prototype = proto;\n var result = new object();\n object.prototype = undefined;\n return result;\n };\n}();\nexport default baseCreate;","/**\n * A faster alternative to `Function#apply`, this function invokes `func`\n * with the `this` binding of `thisArg` and the arguments of `args`.\n *\n * @private\n * @param {Function} func The function to invoke.\n * @param {*} thisArg The `this` binding of `func`.\n * @param {Array} args The arguments to invoke `func` with.\n * @returns {*} Returns the result of `func`.\n */\nfunction apply(func, thisArg, args) {\n switch (args.length) {\n case 0:\n return func.call(thisArg);\n case 1:\n return func.call(thisArg, args[0]);\n case 2:\n return func.call(thisArg, args[0], args[1]);\n case 3:\n return func.call(thisArg, args[0], args[1], args[2]);\n }\n return func.apply(thisArg, args);\n}\nexport default apply;","/**\n * Copies the values of `source` to `array`.\n *\n * @private\n * @param {Array} source The array to copy values from.\n * @param {Array} [array=[]] The array to copy values to.\n * @returns {Array} Returns `array`.\n */\nfunction copyArray(source, array) {\n var index = -1,\n length = source.length;\n array || (array = Array(length));\n while (++index < length) {\n array[index] = source[index];\n }\n return array;\n}\nexport default copyArray;","/** Used to detect hot functions by number of calls within a span of milliseconds. */\nvar HOT_COUNT = 800,\n HOT_SPAN = 16;\n\n/* Built-in method references for those with the same name as other `lodash` methods. */\nvar nativeNow = Date.now;\n\n/**\n * Creates a function that'll short out and invoke `identity` instead\n * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`\n * milliseconds.\n *\n * @private\n * @param {Function} func The function to restrict.\n * @returns {Function} Returns the new shortable function.\n */\nfunction shortOut(func) {\n var count = 0,\n lastCalled = 0;\n return function () {\n var stamp = nativeNow(),\n remaining = HOT_SPAN - (stamp - lastCalled);\n lastCalled = stamp;\n if (remaining > 0) {\n if (++count >= HOT_COUNT) {\n return arguments[0];\n }\n } else {\n count = 0;\n }\n return func.apply(undefined, arguments);\n };\n}\nexport default shortOut;","/**\n * Creates a function that returns `value`.\n *\n * @static\n * @memberOf _\n * @since 2.4.0\n * @category Util\n * @param {*} value The value to return from the new function.\n * @returns {Function} Returns the new constant function.\n * @example\n *\n * var objects = _.times(2, _.constant({ 'a': 1 }));\n *\n * console.log(objects);\n * // => [{ 'a': 1 }, { 'a': 1 }]\n *\n * console.log(objects[0] === objects[1]);\n * // => true\n */\nfunction constant(value) {\n return function () {\n return value;\n };\n}\nexport default constant;","import getNative from './_getNative.js';\nvar defineProperty = function () {\n try {\n var func = getNative(Object, 'defineProperty');\n func({}, '', {});\n return func;\n } catch (e) {}\n}();\nexport default defineProperty;","import constant from './constant.js';\nimport defineProperty from './_defineProperty.js';\nimport identity from './identity.js';\n\n/**\n * The base implementation of `setToString` without support for hot loop shorting.\n *\n * @private\n * @param {Function} func The function to modify.\n * @param {Function} string The `toString` result.\n * @returns {Function} Returns `func`.\n */\nvar baseSetToString = !defineProperty ? identity : function (func, string) {\n return defineProperty(func, 'toString', {\n 'configurable': true,\n 'enumerable': false,\n 'value': constant(string),\n 'writable': true\n });\n};\nexport default baseSetToString;","import baseSetToString from './_baseSetToString.js';\nimport shortOut from './_shortOut.js';\n\n/**\n * Sets the `toString` method of `func` to return `string`.\n *\n * @private\n * @param {Function} func The function to modify.\n * @param {Function} string The `toString` result.\n * @returns {Function} Returns `func`.\n */\nvar setToString = shortOut(baseSetToString);\nexport default setToString;","/** Used as references for various `Number` constants. */\nvar MAX_SAFE_INTEGER = 9007199254740991;\n\n/** Used to detect unsigned integer values. */\nvar reIsUint = /^(?:0|[1-9]\\d*)$/;\n\n/**\n * Checks if `value` is a valid array-like index.\n *\n * @private\n * @param {*} value The value to check.\n * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.\n * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.\n */\nfunction isIndex(value, length) {\n var type = typeof value;\n length = length == null ? MAX_SAFE_INTEGER : length;\n return !!length && (type == 'number' || type != 'symbol' && reIsUint.test(value)) && value > -1 && value % 1 == 0 && value < length;\n}\nexport default isIndex;","import defineProperty from './_defineProperty.js';\n\n/**\n * The base implementation of `assignValue` and `assignMergeValue` without\n * value checks.\n *\n * @private\n * @param {Object} object The object to modify.\n * @param {string} key The key of the property to assign.\n * @param {*} value The value to assign.\n */\nfunction baseAssignValue(object, key, value) {\n if (key == '__proto__' && defineProperty) {\n defineProperty(object, key, {\n 'configurable': true,\n 'enumerable': true,\n 'value': value,\n 'writable': true\n });\n } else {\n object[key] = value;\n }\n}\nexport default baseAssignValue;","/**\n * Performs a\n * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\n * comparison between two values to determine if they are equivalent.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @returns {boolean} Returns `true` if the values are equivalent, else `false`.\n * @example\n *\n * var object = { 'a': 1 };\n * var other = { 'a': 1 };\n *\n * _.eq(object, object);\n * // => true\n *\n * _.eq(object, other);\n * // => false\n *\n * _.eq('a', 'a');\n * // => true\n *\n * _.eq('a', Object('a'));\n * // => false\n *\n * _.eq(NaN, NaN);\n * // => true\n */\nfunction eq(value, other) {\n return value === other || value !== value && other !== other;\n}\nexport default eq;","import baseAssignValue from './_baseAssignValue.js';\nimport eq from './eq.js';\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Assigns `value` to `key` of `object` if the existing value is not equivalent\n * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\n * for equality comparisons.\n *\n * @private\n * @param {Object} object The object to modify.\n * @param {string} key The key of the property to assign.\n * @param {*} value The value to assign.\n */\nfunction assignValue(object, key, value) {\n var objValue = object[key];\n if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) || value === undefined && !(key in object)) {\n baseAssignValue(object, key, value);\n }\n}\nexport default assignValue;","import assignValue from './_assignValue.js';\nimport baseAssignValue from './_baseAssignValue.js';\n\n/**\n * Copies properties of `source` to `object`.\n *\n * @private\n * @param {Object} source The object to copy properties from.\n * @param {Array} props The property identifiers to copy.\n * @param {Object} [object={}] The object to copy properties to.\n * @param {Function} [customizer] The function to customize copied values.\n * @returns {Object} Returns `object`.\n */\nfunction copyObject(source, props, object, customizer) {\n var isNew = !object;\n object || (object = {});\n var index = -1,\n length = props.length;\n while (++index < length) {\n var key = props[index];\n var newValue = customizer ? customizer(object[key], source[key], key, object, source) : undefined;\n if (newValue === undefined) {\n newValue = source[key];\n }\n if (isNew) {\n baseAssignValue(object, key, newValue);\n } else {\n assignValue(object, key, newValue);\n }\n }\n return object;\n}\nexport default copyObject;","import apply from './_apply.js';\n\n/* Built-in method references for those with the same name as other `lodash` methods. */\nvar nativeMax = Math.max;\n\n/**\n * A specialized version of `baseRest` which transforms the rest array.\n *\n * @private\n * @param {Function} func The function to apply a rest parameter to.\n * @param {number} [start=func.length-1] The start position of the rest parameter.\n * @param {Function} transform The rest array transform.\n * @returns {Function} Returns the new function.\n */\nfunction overRest(func, start, transform) {\n start = nativeMax(start === undefined ? func.length - 1 : start, 0);\n return function () {\n var args = arguments,\n index = -1,\n length = nativeMax(args.length - start, 0),\n array = Array(length);\n while (++index < length) {\n array[index] = args[start + index];\n }\n index = -1;\n var otherArgs = Array(start + 1);\n while (++index < start) {\n otherArgs[index] = args[index];\n }\n otherArgs[start] = transform(array);\n return apply(func, this, otherArgs);\n };\n}\nexport default overRest;","import identity from './identity.js';\nimport overRest from './_overRest.js';\nimport setToString from './_setToString.js';\n\n/**\n * The base implementation of `_.rest` which doesn't validate or coerce arguments.\n *\n * @private\n * @param {Function} func The function to apply a rest parameter to.\n * @param {number} [start=func.length-1] The start position of the rest parameter.\n * @returns {Function} Returns the new function.\n */\nfunction baseRest(func, start) {\n return setToString(overRest(func, start, identity), func + '');\n}\nexport default baseRest;","/** Used as references for various `Number` constants. */\nvar MAX_SAFE_INTEGER = 9007199254740991;\n\n/**\n * Checks if `value` is a valid array-like length.\n *\n * **Note:** This method is loosely based on\n * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.\n * @example\n *\n * _.isLength(3);\n * // => true\n *\n * _.isLength(Number.MIN_VALUE);\n * // => false\n *\n * _.isLength(Infinity);\n * // => false\n *\n * _.isLength('3');\n * // => false\n */\nfunction isLength(value) {\n return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;\n}\nexport default isLength;","import isFunction from './isFunction.js';\nimport isLength from './isLength.js';\n\n/**\n * Checks if `value` is array-like. A value is considered array-like if it's\n * not a function and has a `value.length` that's an integer greater than or\n * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is array-like, else `false`.\n * @example\n *\n * _.isArrayLike([1, 2, 3]);\n * // => true\n *\n * _.isArrayLike(document.body.children);\n * // => true\n *\n * _.isArrayLike('abc');\n * // => true\n *\n * _.isArrayLike(_.noop);\n * // => false\n */\nfunction isArrayLike(value) {\n return value != null && isLength(value.length) && !isFunction(value);\n}\nexport default isArrayLike;","import eq from './eq.js';\nimport isArrayLike from './isArrayLike.js';\nimport isIndex from './_isIndex.js';\nimport isObject from './isObject.js';\n\n/**\n * Checks if the given arguments are from an iteratee call.\n *\n * @private\n * @param {*} value The potential iteratee value argument.\n * @param {*} index The potential iteratee index or key argument.\n * @param {*} object The potential iteratee object argument.\n * @returns {boolean} Returns `true` if the arguments are from an iteratee call,\n * else `false`.\n */\nfunction isIterateeCall(value, index, object) {\n if (!isObject(object)) {\n return false;\n }\n var type = typeof index;\n if (type == 'number' ? isArrayLike(object) && isIndex(index, object.length) : type == 'string' && index in object) {\n return eq(object[index], value);\n }\n return false;\n}\nexport default isIterateeCall;","import baseRest from './_baseRest.js';\nimport isIterateeCall from './_isIterateeCall.js';\n\n/**\n * Creates a function like `_.assign`.\n *\n * @private\n * @param {Function} assigner The function to assign values.\n * @returns {Function} Returns the new assigner function.\n */\nfunction createAssigner(assigner) {\n return baseRest(function (object, sources) {\n var index = -1,\n length = sources.length,\n customizer = length > 1 ? sources[length - 1] : undefined,\n guard = length > 2 ? sources[2] : undefined;\n customizer = assigner.length > 3 && typeof customizer == 'function' ? (length--, customizer) : undefined;\n if (guard && isIterateeCall(sources[0], sources[1], guard)) {\n customizer = length < 3 ? undefined : customizer;\n length = 1;\n }\n object = Object(object);\n while (++index < length) {\n var source = sources[index];\n if (source) {\n assigner(object, source, index, customizer);\n }\n }\n return object;\n });\n}\nexport default createAssigner;","/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/**\n * Checks if `value` is likely a prototype object.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.\n */\nfunction isPrototype(value) {\n var Ctor = value && value.constructor,\n proto = typeof Ctor == 'function' && Ctor.prototype || objectProto;\n return value === proto;\n}\nexport default isPrototype;","/**\n * The base implementation of `_.times` without support for iteratee shorthands\n * or max array length checks.\n *\n * @private\n * @param {number} n The number of times to invoke `iteratee`.\n * @param {Function} iteratee The function invoked per iteration.\n * @returns {Array} Returns the array of results.\n */\nfunction baseTimes(n, iteratee) {\n var index = -1,\n result = Array(n);\n while (++index < n) {\n result[index] = iteratee(index);\n }\n return result;\n}\nexport default baseTimes;","import baseGetTag from './_baseGetTag.js';\nimport isObjectLike from './isObjectLike.js';\n\n/** `Object#toString` result references. */\nvar argsTag = '[object Arguments]';\n\n/**\n * The base implementation of `_.isArguments`.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an `arguments` object,\n */\nfunction baseIsArguments(value) {\n return isObjectLike(value) && baseGetTag(value) == argsTag;\n}\nexport default baseIsArguments;","import baseIsArguments from './_baseIsArguments.js';\nimport isObjectLike from './isObjectLike.js';\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/** Built-in value references. */\nvar propertyIsEnumerable = objectProto.propertyIsEnumerable;\n\n/**\n * Checks if `value` is likely an `arguments` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an `arguments` object,\n * else `false`.\n * @example\n *\n * _.isArguments(function() { return arguments; }());\n * // => true\n *\n * _.isArguments([1, 2, 3]);\n * // => false\n */\nvar isArguments = baseIsArguments(function () {\n return arguments;\n}()) ? baseIsArguments : function (value) {\n return isObjectLike(value) && hasOwnProperty.call(value, 'callee') && !propertyIsEnumerable.call(value, 'callee');\n};\nexport default isArguments;","/**\n * This method returns `false`.\n *\n * @static\n * @memberOf _\n * @since 4.13.0\n * @category Util\n * @returns {boolean} Returns `false`.\n * @example\n *\n * _.times(2, _.stubFalse);\n * // => [false, false]\n */\nfunction stubFalse() {\n return false;\n}\nexport default stubFalse;","import root from './_root.js';\nimport stubFalse from './stubFalse.js';\n\n/** Detect free variable `exports`. */\nvar freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;\n\n/** Detect free variable `module`. */\nvar freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;\n\n/** Detect the popular CommonJS extension `module.exports`. */\nvar moduleExports = freeModule && freeModule.exports === freeExports;\n\n/** Built-in value references. */\nvar Buffer = moduleExports ? root.Buffer : undefined;\n\n/* Built-in method references for those with the same name as other `lodash` methods. */\nvar nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;\n\n/**\n * Checks if `value` is a buffer.\n *\n * @static\n * @memberOf _\n * @since 4.3.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.\n * @example\n *\n * _.isBuffer(new Buffer(2));\n * // => true\n *\n * _.isBuffer(new Uint8Array(2));\n * // => false\n */\nvar isBuffer = nativeIsBuffer || stubFalse;\nexport default isBuffer;","import baseGetTag from './_baseGetTag.js';\nimport isLength from './isLength.js';\nimport isObjectLike from './isObjectLike.js';\n\n/** `Object#toString` result references. */\nvar argsTag = '[object Arguments]',\n arrayTag = '[object Array]',\n boolTag = '[object Boolean]',\n dateTag = '[object Date]',\n errorTag = '[object Error]',\n funcTag = '[object Function]',\n mapTag = '[object Map]',\n numberTag = '[object Number]',\n objectTag = '[object Object]',\n regexpTag = '[object RegExp]',\n setTag = '[object Set]',\n stringTag = '[object String]',\n weakMapTag = '[object WeakMap]';\nvar arrayBufferTag = '[object ArrayBuffer]',\n dataViewTag = '[object DataView]',\n float32Tag = '[object Float32Array]',\n float64Tag = '[object Float64Array]',\n int8Tag = '[object Int8Array]',\n int16Tag = '[object Int16Array]',\n int32Tag = '[object Int32Array]',\n uint8Tag = '[object Uint8Array]',\n uint8ClampedTag = '[object Uint8ClampedArray]',\n uint16Tag = '[object Uint16Array]',\n uint32Tag = '[object Uint32Array]';\n\n/** Used to identify `toStringTag` values of typed arrays. */\nvar typedArrayTags = {};\ntypedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true;\ntypedArrayTags[argsTag] = typedArrayTags[arrayTag] = typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = typedArrayTags[errorTag] = typedArrayTags[funcTag] = typedArrayTags[mapTag] = typedArrayTags[numberTag] = typedArrayTags[objectTag] = typedArrayTags[regexpTag] = typedArrayTags[setTag] = typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false;\n\n/**\n * The base implementation of `_.isTypedArray` without Node.js optimizations.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.\n */\nfunction baseIsTypedArray(value) {\n return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[baseGetTag(value)];\n}\nexport default baseIsTypedArray;","/**\n * The base implementation of `_.unary` without support for storing metadata.\n *\n * @private\n * @param {Function} func The function to cap arguments for.\n * @returns {Function} Returns the new capped function.\n */\nfunction baseUnary(func) {\n return function (value) {\n return func(value);\n };\n}\nexport default baseUnary;","import freeGlobal from './_freeGlobal.js';\n\n/** Detect free variable `exports`. */\nvar freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;\n\n/** Detect free variable `module`. */\nvar freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;\n\n/** Detect the popular CommonJS extension `module.exports`. */\nvar moduleExports = freeModule && freeModule.exports === freeExports;\n\n/** Detect free variable `process` from Node.js. */\nvar freeProcess = moduleExports && freeGlobal.process;\n\n/** Used to access faster Node.js helpers. */\nvar nodeUtil = function () {\n try {\n // Use `util.types` for Node.js 10+.\n var types = freeModule && freeModule.require && freeModule.require('util').types;\n if (types) {\n return types;\n }\n\n // Legacy `process.binding('util')` for Node.js < 10.\n return freeProcess && freeProcess.binding && freeProcess.binding('util');\n } catch (e) {}\n}();\nexport default nodeUtil;","import baseIsTypedArray from './_baseIsTypedArray.js';\nimport baseUnary from './_baseUnary.js';\nimport nodeUtil from './_nodeUtil.js';\n\n/* Node.js helper references. */\nvar nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;\n\n/**\n * Checks if `value` is classified as a typed array.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.\n * @example\n *\n * _.isTypedArray(new Uint8Array);\n * // => true\n *\n * _.isTypedArray([]);\n * // => false\n */\nvar isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;\nexport default isTypedArray;","import baseTimes from './_baseTimes.js';\nimport isArguments from './isArguments.js';\nimport isArray from './isArray.js';\nimport isBuffer from './isBuffer.js';\nimport isIndex from './_isIndex.js';\nimport isTypedArray from './isTypedArray.js';\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Creates an array of the enumerable property names of the array-like `value`.\n *\n * @private\n * @param {*} value The value to query.\n * @param {boolean} inherited Specify returning inherited property names.\n * @returns {Array} Returns the array of property names.\n */\nfunction arrayLikeKeys(value, inherited) {\n var isArr = isArray(value),\n isArg = !isArr && isArguments(value),\n isBuff = !isArr && !isArg && isBuffer(value),\n isType = !isArr && !isArg && !isBuff && isTypedArray(value),\n skipIndexes = isArr || isArg || isBuff || isType,\n result = skipIndexes ? baseTimes(value.length, String) : [],\n length = result.length;\n for (var key in value) {\n if ((inherited || hasOwnProperty.call(value, key)) && !(skipIndexes && (\n // Safari 9 has enumerable `arguments.length` in strict mode.\n key == 'length' ||\n // Node.js 0.10 has enumerable non-index properties on buffers.\n isBuff && (key == 'offset' || key == 'parent') ||\n // PhantomJS 2 has enumerable non-index properties on typed arrays.\n isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset') ||\n // Skip index properties.\n isIndex(key, length)))) {\n result.push(key);\n }\n }\n return result;\n}\nexport default arrayLikeKeys;","/**\n * Creates a unary function that invokes `func` with its argument transformed.\n *\n * @private\n * @param {Function} func The function to wrap.\n * @param {Function} transform The argument transform.\n * @returns {Function} Returns the new function.\n */\nfunction overArg(func, transform) {\n return function (arg) {\n return func(transform(arg));\n };\n}\nexport default overArg;","/**\n * This function is like\n * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)\n * except that it includes inherited enumerable properties.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names.\n */\nfunction nativeKeysIn(object) {\n var result = [];\n if (object != null) {\n for (var key in Object(object)) {\n result.push(key);\n }\n }\n return result;\n}\nexport default nativeKeysIn;","import isObject from './isObject.js';\nimport isPrototype from './_isPrototype.js';\nimport nativeKeysIn from './_nativeKeysIn.js';\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names.\n */\nfunction baseKeysIn(object) {\n if (!isObject(object)) {\n return nativeKeysIn(object);\n }\n var isProto = isPrototype(object),\n result = [];\n for (var key in object) {\n if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {\n result.push(key);\n }\n }\n return result;\n}\nexport default baseKeysIn;","import arrayLikeKeys from './_arrayLikeKeys.js';\nimport baseKeysIn from './_baseKeysIn.js';\nimport isArrayLike from './isArrayLike.js';\n\n/**\n * Creates an array of the own and inherited enumerable property names of `object`.\n *\n * **Note:** Non-object values are coerced to objects.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Object\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names.\n * @example\n *\n * function Foo() {\n * this.a = 1;\n * this.b = 2;\n * }\n *\n * Foo.prototype.c = 3;\n *\n * _.keysIn(new Foo);\n * // => ['a', 'b', 'c'] (iteration order is not guaranteed)\n */\nfunction keysIn(object) {\n return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);\n}\nexport default keysIn;","import getNative from './_getNative.js';\n\n/* Built-in method references that are verified to be native. */\nvar nativeCreate = getNative(Object, 'create');\nexport default nativeCreate;","import nativeCreate from './_nativeCreate.js';\n\n/**\n * Removes all key-value entries from the hash.\n *\n * @private\n * @name clear\n * @memberOf Hash\n */\nfunction hashClear() {\n this.__data__ = nativeCreate ? nativeCreate(null) : {};\n this.size = 0;\n}\nexport default hashClear;","/**\n * Removes `key` and its value from the hash.\n *\n * @private\n * @name delete\n * @memberOf Hash\n * @param {Object} hash The hash to modify.\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\nfunction hashDelete(key) {\n var result = this.has(key) && delete this.__data__[key];\n this.size -= result ? 1 : 0;\n return result;\n}\nexport default hashDelete;","import nativeCreate from './_nativeCreate.js';\n\n/** Used to stand-in for `undefined` hash values. */\nvar HASH_UNDEFINED = '__lodash_hash_undefined__';\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Gets the hash value for `key`.\n *\n * @private\n * @name get\n * @memberOf Hash\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\nfunction hashGet(key) {\n var data = this.__data__;\n if (nativeCreate) {\n var result = data[key];\n return result === HASH_UNDEFINED ? undefined : result;\n }\n return hasOwnProperty.call(data, key) ? data[key] : undefined;\n}\nexport default hashGet;","import nativeCreate from './_nativeCreate.js';\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Checks if a hash value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf Hash\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction hashHas(key) {\n var data = this.__data__;\n return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);\n}\nexport default hashHas;","import nativeCreate from './_nativeCreate.js';\n\n/** Used to stand-in for `undefined` hash values. */\nvar HASH_UNDEFINED = '__lodash_hash_undefined__';\n\n/**\n * Sets the hash `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf Hash\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the hash instance.\n */\nfunction hashSet(key, value) {\n var data = this.__data__;\n this.size += this.has(key) ? 0 : 1;\n data[key] = nativeCreate && value === undefined ? HASH_UNDEFINED : value;\n return this;\n}\nexport default hashSet;","import hashClear from './_hashClear.js';\nimport hashDelete from './_hashDelete.js';\nimport hashGet from './_hashGet.js';\nimport hashHas from './_hashHas.js';\nimport hashSet from './_hashSet.js';\n\n/**\n * Creates a hash object.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\nfunction Hash(entries) {\n var index = -1,\n length = entries == null ? 0 : entries.length;\n this.clear();\n while (++index < length) {\n var entry = entries[index];\n this.set(entry[0], entry[1]);\n }\n}\n\n// Add methods to `Hash`.\nHash.prototype.clear = hashClear;\nHash.prototype['delete'] = hashDelete;\nHash.prototype.get = hashGet;\nHash.prototype.has = hashHas;\nHash.prototype.set = hashSet;\nexport default Hash;","/**\n * Removes all key-value entries from the list cache.\n *\n * @private\n * @name clear\n * @memberOf ListCache\n */\nfunction listCacheClear() {\n this.__data__ = [];\n this.size = 0;\n}\nexport default listCacheClear;","import eq from './eq.js';\n\n/**\n * Gets the index at which the `key` is found in `array` of key-value pairs.\n *\n * @private\n * @param {Array} array The array to inspect.\n * @param {*} key The key to search for.\n * @returns {number} Returns the index of the matched value, else `-1`.\n */\nfunction assocIndexOf(array, key) {\n var length = array.length;\n while (length--) {\n if (eq(array[length][0], key)) {\n return length;\n }\n }\n return -1;\n}\nexport default assocIndexOf;","import assocIndexOf from './_assocIndexOf.js';\n\n/** Used for built-in method references. */\nvar arrayProto = Array.prototype;\n\n/** Built-in value references. */\nvar splice = arrayProto.splice;\n\n/**\n * Removes `key` and its value from the list cache.\n *\n * @private\n * @name delete\n * @memberOf ListCache\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\nfunction listCacheDelete(key) {\n var data = this.__data__,\n index = assocIndexOf(data, key);\n if (index < 0) {\n return false;\n }\n var lastIndex = data.length - 1;\n if (index == lastIndex) {\n data.pop();\n } else {\n splice.call(data, index, 1);\n }\n --this.size;\n return true;\n}\nexport default listCacheDelete;","import assocIndexOf from './_assocIndexOf.js';\n\n/**\n * Gets the list cache value for `key`.\n *\n * @private\n * @name get\n * @memberOf ListCache\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\nfunction listCacheGet(key) {\n var data = this.__data__,\n index = assocIndexOf(data, key);\n return index < 0 ? undefined : data[index][1];\n}\nexport default listCacheGet;","import assocIndexOf from './_assocIndexOf.js';\n\n/**\n * Checks if a list cache value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf ListCache\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction listCacheHas(key) {\n return assocIndexOf(this.__data__, key) > -1;\n}\nexport default listCacheHas;","import assocIndexOf from './_assocIndexOf.js';\n\n/**\n * Sets the list cache `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf ListCache\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the list cache instance.\n */\nfunction listCacheSet(key, value) {\n var data = this.__data__,\n index = assocIndexOf(data, key);\n if (index < 0) {\n ++this.size;\n data.push([key, value]);\n } else {\n data[index][1] = value;\n }\n return this;\n}\nexport default listCacheSet;","import listCacheClear from './_listCacheClear.js';\nimport listCacheDelete from './_listCacheDelete.js';\nimport listCacheGet from './_listCacheGet.js';\nimport listCacheHas from './_listCacheHas.js';\nimport listCacheSet from './_listCacheSet.js';\n\n/**\n * Creates an list cache object.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\nfunction ListCache(entries) {\n var index = -1,\n length = entries == null ? 0 : entries.length;\n this.clear();\n while (++index < length) {\n var entry = entries[index];\n this.set(entry[0], entry[1]);\n }\n}\n\n// Add methods to `ListCache`.\nListCache.prototype.clear = listCacheClear;\nListCache.prototype['delete'] = listCacheDelete;\nListCache.prototype.get = listCacheGet;\nListCache.prototype.has = listCacheHas;\nListCache.prototype.set = listCacheSet;\nexport default ListCache;","import getNative from './_getNative.js';\nimport root from './_root.js';\n\n/* Built-in method references that are verified to be native. */\nvar Map = getNative(root, 'Map');\nexport default Map;","import Hash from './_Hash.js';\nimport ListCache from './_ListCache.js';\nimport Map from './_Map.js';\n\n/**\n * Removes all key-value entries from the map.\n *\n * @private\n * @name clear\n * @memberOf MapCache\n */\nfunction mapCacheClear() {\n this.size = 0;\n this.__data__ = {\n 'hash': new Hash(),\n 'map': new (Map || ListCache)(),\n 'string': new Hash()\n };\n}\nexport default mapCacheClear;","/**\n * Checks if `value` is suitable for use as unique object key.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is suitable, else `false`.\n */\nfunction isKeyable(value) {\n var type = typeof value;\n return type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean' ? value !== '__proto__' : value === null;\n}\nexport default isKeyable;","import isKeyable from './_isKeyable.js';\n\n/**\n * Gets the data for `map`.\n *\n * @private\n * @param {Object} map The map to query.\n * @param {string} key The reference key.\n * @returns {*} Returns the map data.\n */\nfunction getMapData(map, key) {\n var data = map.__data__;\n return isKeyable(key) ? data[typeof key == 'string' ? 'string' : 'hash'] : data.map;\n}\nexport default getMapData;","import getMapData from './_getMapData.js';\n\n/**\n * Removes `key` and its value from the map.\n *\n * @private\n * @name delete\n * @memberOf MapCache\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\nfunction mapCacheDelete(key) {\n var result = getMapData(this, key)['delete'](key);\n this.size -= result ? 1 : 0;\n return result;\n}\nexport default mapCacheDelete;","import getMapData from './_getMapData.js';\n\n/**\n * Gets the map value for `key`.\n *\n * @private\n * @name get\n * @memberOf MapCache\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\nfunction mapCacheGet(key) {\n return getMapData(this, key).get(key);\n}\nexport default mapCacheGet;","import getMapData from './_getMapData.js';\n\n/**\n * Checks if a map value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf MapCache\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction mapCacheHas(key) {\n return getMapData(this, key).has(key);\n}\nexport default mapCacheHas;","import getMapData from './_getMapData.js';\n\n/**\n * Sets the map `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf MapCache\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the map cache instance.\n */\nfunction mapCacheSet(key, value) {\n var data = getMapData(this, key),\n size = data.size;\n data.set(key, value);\n this.size += data.size == size ? 0 : 1;\n return this;\n}\nexport default mapCacheSet;","import mapCacheClear from './_mapCacheClear.js';\nimport mapCacheDelete from './_mapCacheDelete.js';\nimport mapCacheGet from './_mapCacheGet.js';\nimport mapCacheHas from './_mapCacheHas.js';\nimport mapCacheSet from './_mapCacheSet.js';\n\n/**\n * Creates a map cache object to store key-value pairs.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\nfunction MapCache(entries) {\n var index = -1,\n length = entries == null ? 0 : entries.length;\n this.clear();\n while (++index < length) {\n var entry = entries[index];\n this.set(entry[0], entry[1]);\n }\n}\n\n// Add methods to `MapCache`.\nMapCache.prototype.clear = mapCacheClear;\nMapCache.prototype['delete'] = mapCacheDelete;\nMapCache.prototype.get = mapCacheGet;\nMapCache.prototype.has = mapCacheHas;\nMapCache.prototype.set = mapCacheSet;\nexport default MapCache;","import overArg from './_overArg.js';\n\n/** Built-in value references. */\nvar getPrototype = overArg(Object.getPrototypeOf, Object);\nexport default getPrototype;","import baseGetTag from './_baseGetTag.js';\nimport getPrototype from './_getPrototype.js';\nimport isObjectLike from './isObjectLike.js';\n\n/** `Object#toString` result references. */\nvar objectTag = '[object Object]';\n\n/** Used for built-in method references. */\nvar funcProto = Function.prototype,\n objectProto = Object.prototype;\n\n/** Used to resolve the decompiled source of functions. */\nvar funcToString = funcProto.toString;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/** Used to infer the `Object` constructor. */\nvar objectCtorString = funcToString.call(Object);\n\n/**\n * Checks if `value` is a plain object, that is, an object created by the\n * `Object` constructor or one with a `[[Prototype]]` of `null`.\n *\n * @static\n * @memberOf _\n * @since 0.8.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.\n * @example\n *\n * function Foo() {\n * this.a = 1;\n * }\n *\n * _.isPlainObject(new Foo);\n * // => false\n *\n * _.isPlainObject([1, 2, 3]);\n * // => false\n *\n * _.isPlainObject({ 'x': 0, 'y': 0 });\n * // => true\n *\n * _.isPlainObject(Object.create(null));\n * // => true\n */\nfunction isPlainObject(value) {\n if (!isObjectLike(value) || baseGetTag(value) != objectTag) {\n return false;\n }\n var proto = getPrototype(value);\n if (proto === null) {\n return true;\n }\n var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;\n return typeof Ctor == 'function' && Ctor instanceof Ctor && funcToString.call(Ctor) == objectCtorString;\n}\nexport default isPlainObject;","import ListCache from './_ListCache.js';\n\n/**\n * Removes all key-value entries from the stack.\n *\n * @private\n * @name clear\n * @memberOf Stack\n */\nfunction stackClear() {\n this.__data__ = new ListCache();\n this.size = 0;\n}\nexport default stackClear;","/**\n * Removes `key` and its value from the stack.\n *\n * @private\n * @name delete\n * @memberOf Stack\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\nfunction stackDelete(key) {\n var data = this.__data__,\n result = data['delete'](key);\n this.size = data.size;\n return result;\n}\nexport default stackDelete;","/**\n * Gets the stack value for `key`.\n *\n * @private\n * @name get\n * @memberOf Stack\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\nfunction stackGet(key) {\n return this.__data__.get(key);\n}\nexport default stackGet;","/**\n * Checks if a stack value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf Stack\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction stackHas(key) {\n return this.__data__.has(key);\n}\nexport default stackHas;","import ListCache from './_ListCache.js';\nimport Map from './_Map.js';\nimport MapCache from './_MapCache.js';\n\n/** Used as the size to enable large array optimizations. */\nvar LARGE_ARRAY_SIZE = 200;\n\n/**\n * Sets the stack `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf Stack\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the stack cache instance.\n */\nfunction stackSet(key, value) {\n var data = this.__data__;\n if (data instanceof ListCache) {\n var pairs = data.__data__;\n if (!Map || pairs.length < LARGE_ARRAY_SIZE - 1) {\n pairs.push([key, value]);\n this.size = ++data.size;\n return this;\n }\n data = this.__data__ = new MapCache(pairs);\n }\n data.set(key, value);\n this.size = data.size;\n return this;\n}\nexport default stackSet;","import ListCache from './_ListCache.js';\nimport stackClear from './_stackClear.js';\nimport stackDelete from './_stackDelete.js';\nimport stackGet from './_stackGet.js';\nimport stackHas from './_stackHas.js';\nimport stackSet from './_stackSet.js';\n\n/**\n * Creates a stack cache object to store key-value pairs.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\nfunction Stack(entries) {\n var data = this.__data__ = new ListCache(entries);\n this.size = data.size;\n}\n\n// Add methods to `Stack`.\nStack.prototype.clear = stackClear;\nStack.prototype['delete'] = stackDelete;\nStack.prototype.get = stackGet;\nStack.prototype.has = stackHas;\nStack.prototype.set = stackSet;\nexport default Stack;","import root from './_root.js';\n\n/** Detect free variable `exports`. */\nvar freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;\n\n/** Detect free variable `module`. */\nvar freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;\n\n/** Detect the popular CommonJS extension `module.exports`. */\nvar moduleExports = freeModule && freeModule.exports === freeExports;\n\n/** Built-in value references. */\nvar Buffer = moduleExports ? root.Buffer : undefined,\n allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined;\n\n/**\n * Creates a clone of `buffer`.\n *\n * @private\n * @param {Buffer} buffer The buffer to clone.\n * @param {boolean} [isDeep] Specify a deep clone.\n * @returns {Buffer} Returns the cloned buffer.\n */\nfunction cloneBuffer(buffer, isDeep) {\n if (isDeep) {\n return buffer.slice();\n }\n var length = buffer.length,\n result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);\n buffer.copy(result);\n return result;\n}\nexport default cloneBuffer;","import root from './_root.js';\n\n/** Built-in value references. */\nvar Uint8Array = root.Uint8Array;\nexport default Uint8Array;","import Uint8Array from './_Uint8Array.js';\n\n/**\n * Creates a clone of `arrayBuffer`.\n *\n * @private\n * @param {ArrayBuffer} arrayBuffer The array buffer to clone.\n * @returns {ArrayBuffer} Returns the cloned array buffer.\n */\nfunction cloneArrayBuffer(arrayBuffer) {\n var result = new arrayBuffer.constructor(arrayBuffer.byteLength);\n new Uint8Array(result).set(new Uint8Array(arrayBuffer));\n return result;\n}\nexport default cloneArrayBuffer;","import cloneArrayBuffer from './_cloneArrayBuffer.js';\n\n/**\n * Creates a clone of `typedArray`.\n *\n * @private\n * @param {Object} typedArray The typed array to clone.\n * @param {boolean} [isDeep] Specify a deep clone.\n * @returns {Object} Returns the cloned typed array.\n */\nfunction cloneTypedArray(typedArray, isDeep) {\n var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;\n return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);\n}\nexport default cloneTypedArray;","import baseCreate from './_baseCreate.js';\nimport getPrototype from './_getPrototype.js';\nimport isPrototype from './_isPrototype.js';\n\n/**\n * Initializes an object clone.\n *\n * @private\n * @param {Object} object The object to clone.\n * @returns {Object} Returns the initialized clone.\n */\nfunction initCloneObject(object) {\n return typeof object.constructor == 'function' && !isPrototype(object) ? baseCreate(getPrototype(object)) : {};\n}\nexport default initCloneObject;","/**\n * Creates a base function for methods like `_.forIn` and `_.forOwn`.\n *\n * @private\n * @param {boolean} [fromRight] Specify iterating from right to left.\n * @returns {Function} Returns the new base function.\n */\nfunction createBaseFor(fromRight) {\n return function (object, iteratee, keysFunc) {\n var index = -1,\n iterable = Object(object),\n props = keysFunc(object),\n length = props.length;\n while (length--) {\n var key = props[fromRight ? length : ++index];\n if (iteratee(iterable[key], key, iterable) === false) {\n break;\n }\n }\n return object;\n };\n}\nexport default createBaseFor;","import createBaseFor from './_createBaseFor.js';\n\n/**\n * The base implementation of `baseForOwn` which iterates over `object`\n * properties returned by `keysFunc` and invokes `iteratee` for each property.\n * Iteratee functions may exit iteration early by explicitly returning `false`.\n *\n * @private\n * @param {Object} object The object to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @param {Function} keysFunc The function to get the keys of `object`.\n * @returns {Object} Returns `object`.\n */\nvar baseFor = createBaseFor();\nexport default baseFor;","import baseAssignValue from './_baseAssignValue.js';\nimport eq from './eq.js';\n\n/**\n * This function is like `assignValue` except that it doesn't assign\n * `undefined` values.\n *\n * @private\n * @param {Object} object The object to modify.\n * @param {string} key The key of the property to assign.\n * @param {*} value The value to assign.\n */\nfunction assignMergeValue(object, key, value) {\n if (value !== undefined && !eq(object[key], value) || value === undefined && !(key in object)) {\n baseAssignValue(object, key, value);\n }\n}\nexport default assignMergeValue;","import isArrayLike from './isArrayLike.js';\nimport isObjectLike from './isObjectLike.js';\n\n/**\n * This method is like `_.isArrayLike` except that it also checks if `value`\n * is an object.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an array-like object,\n * else `false`.\n * @example\n *\n * _.isArrayLikeObject([1, 2, 3]);\n * // => true\n *\n * _.isArrayLikeObject(document.body.children);\n * // => true\n *\n * _.isArrayLikeObject('abc');\n * // => false\n *\n * _.isArrayLikeObject(_.noop);\n * // => false\n */\nfunction isArrayLikeObject(value) {\n return isObjectLike(value) && isArrayLike(value);\n}\nexport default isArrayLikeObject;","/**\n * Gets the value at `key`, unless `key` is \"__proto__\" or \"constructor\".\n *\n * @private\n * @param {Object} object The object to query.\n * @param {string} key The key of the property to get.\n * @returns {*} Returns the property value.\n */\nfunction safeGet(object, key) {\n if (key === 'constructor' && typeof object[key] === 'function') {\n return;\n }\n if (key == '__proto__') {\n return;\n }\n return object[key];\n}\nexport default safeGet;","import copyObject from './_copyObject.js';\nimport keysIn from './keysIn.js';\n\n/**\n * Converts `value` to a plain object flattening inherited enumerable string\n * keyed properties of `value` to own properties of the plain object.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Lang\n * @param {*} value The value to convert.\n * @returns {Object} Returns the converted plain object.\n * @example\n *\n * function Foo() {\n * this.b = 2;\n * }\n *\n * Foo.prototype.c = 3;\n *\n * _.assign({ 'a': 1 }, new Foo);\n * // => { 'a': 1, 'b': 2 }\n *\n * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));\n * // => { 'a': 1, 'b': 2, 'c': 3 }\n */\nfunction toPlainObject(value) {\n return copyObject(value, keysIn(value));\n}\nexport default toPlainObject;","import assignMergeValue from './_assignMergeValue.js';\nimport cloneBuffer from './_cloneBuffer.js';\nimport cloneTypedArray from './_cloneTypedArray.js';\nimport copyArray from './_copyArray.js';\nimport initCloneObject from './_initCloneObject.js';\nimport isArguments from './isArguments.js';\nimport isArray from './isArray.js';\nimport isArrayLikeObject from './isArrayLikeObject.js';\nimport isBuffer from './isBuffer.js';\nimport isFunction from './isFunction.js';\nimport isObject from './isObject.js';\nimport isPlainObject from './isPlainObject.js';\nimport isTypedArray from './isTypedArray.js';\nimport safeGet from './_safeGet.js';\nimport toPlainObject from './toPlainObject.js';\n\n/**\n * A specialized version of `baseMerge` for arrays and objects which performs\n * deep merges and tracks traversed objects enabling objects with circular\n * references to be merged.\n *\n * @private\n * @param {Object} object The destination object.\n * @param {Object} source The source object.\n * @param {string} key The key of the value to merge.\n * @param {number} srcIndex The index of `source`.\n * @param {Function} mergeFunc The function to merge values.\n * @param {Function} [customizer] The function to customize assigned values.\n * @param {Object} [stack] Tracks traversed source values and their merged\n * counterparts.\n */\nfunction baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {\n var objValue = safeGet(object, key),\n srcValue = safeGet(source, key),\n stacked = stack.get(srcValue);\n if (stacked) {\n assignMergeValue(object, key, stacked);\n return;\n }\n var newValue = customizer ? customizer(objValue, srcValue, key + '', object, source, stack) : undefined;\n var isCommon = newValue === undefined;\n if (isCommon) {\n var isArr = isArray(srcValue),\n isBuff = !isArr && isBuffer(srcValue),\n isTyped = !isArr && !isBuff && isTypedArray(srcValue);\n newValue = srcValue;\n if (isArr || isBuff || isTyped) {\n if (isArray(objValue)) {\n newValue = objValue;\n } else if (isArrayLikeObject(objValue)) {\n newValue = copyArray(objValue);\n } else if (isBuff) {\n isCommon = false;\n newValue = cloneBuffer(srcValue, true);\n } else if (isTyped) {\n isCommon = false;\n newValue = cloneTypedArray(srcValue, true);\n } else {\n newValue = [];\n }\n } else if (isPlainObject(srcValue) || isArguments(srcValue)) {\n newValue = objValue;\n if (isArguments(objValue)) {\n newValue = toPlainObject(objValue);\n } else if (!isObject(objValue) || isFunction(objValue)) {\n newValue = initCloneObject(srcValue);\n }\n } else {\n isCommon = false;\n }\n }\n if (isCommon) {\n // Recursively merge objects and arrays (susceptible to call stack limits).\n stack.set(srcValue, newValue);\n mergeFunc(newValue, srcValue, srcIndex, customizer, stack);\n stack['delete'](srcValue);\n }\n assignMergeValue(object, key, newValue);\n}\nexport default baseMergeDeep;","import Stack from './_Stack.js';\nimport assignMergeValue from './_assignMergeValue.js';\nimport baseFor from './_baseFor.js';\nimport baseMergeDeep from './_baseMergeDeep.js';\nimport isObject from './isObject.js';\nimport keysIn from './keysIn.js';\nimport safeGet from './_safeGet.js';\n\n/**\n * The base implementation of `_.merge` without support for multiple sources.\n *\n * @private\n * @param {Object} object The destination object.\n * @param {Object} source The source object.\n * @param {number} srcIndex The index of `source`.\n * @param {Function} [customizer] The function to customize merged values.\n * @param {Object} [stack] Tracks traversed source values and their merged\n * counterparts.\n */\nfunction baseMerge(object, source, srcIndex, customizer, stack) {\n if (object === source) {\n return;\n }\n baseFor(source, function (srcValue, key) {\n stack || (stack = new Stack());\n if (isObject(srcValue)) {\n baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);\n } else {\n var newValue = customizer ? customizer(safeGet(object, key), srcValue, key + '', object, source, stack) : undefined;\n if (newValue === undefined) {\n newValue = srcValue;\n }\n assignMergeValue(object, key, newValue);\n }\n }, keysIn);\n}\nexport default baseMerge;","import baseMerge from './_baseMerge.js';\nimport createAssigner from './_createAssigner.js';\n\n/**\n * This method is like `_.assign` except that it recursively merges own and\n * inherited enumerable string keyed properties of source objects into the\n * destination object. Source properties that resolve to `undefined` are\n * skipped if a destination value exists. Array and plain object properties\n * are merged recursively. Other objects and value types are overridden by\n * assignment. Source objects are applied from left to right. Subsequent\n * sources overwrite property assignments of previous sources.\n *\n * **Note:** This method mutates `object`.\n *\n * @static\n * @memberOf _\n * @since 0.5.0\n * @category Object\n * @param {Object} object The destination object.\n * @param {...Object} [sources] The source objects.\n * @returns {Object} Returns `object`.\n * @example\n *\n * var object = {\n * 'a': [{ 'b': 2 }, { 'd': 4 }]\n * };\n *\n * var other = {\n * 'a': [{ 'c': 3 }, { 'e': 5 }]\n * };\n *\n * _.merge(object, other);\n * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }\n */\nvar merge = createAssigner(function (object, source, srcIndex) {\n baseMerge(object, source, srcIndex);\n});\nexport default merge;","import * as i0 from '@angular/core';\nimport { InjectionToken, Injectable, EventEmitter, Directive, Optional, Inject, Input, Output } from '@angular/core';\nimport { registerables, Chart, defaults } from 'chart.js';\nimport { merge } from 'lodash-es';\nimport { BehaviorSubject } from 'rxjs';\nimport { distinctUntilChanged } from 'rxjs/operators';\nconst NG_CHARTS_CONFIGURATION = new InjectionToken('Configuration for ngCharts');\n/**\n * Provide all the default registerable as defined by Chart.js\n */\nfunction withDefaultRegisterables(...registerables$1) {\n return {\n registerables: [...registerables, ...registerables$1]\n };\n}\n/**\n * Provide configuration for ngCharts. In most cases, you have to pass it some registerables. So either\n * `withDefaultRegisterables()`, or a custom list of registerables tailored to your needs to reduce bundle size.\n */\nfunction provideCharts(...configurations) {\n const config = merge({}, ...configurations);\n return {\n provide: NG_CHARTS_CONFIGURATION,\n useValue: config\n };\n}\nlet ThemeService = /*#__PURE__*/(() => {\n class ThemeService {\n constructor() {\n this.colorschemesOptions = new BehaviorSubject(undefined);\n }\n setColorschemesOptions(options) {\n this.pColorschemesOptions = options;\n this.colorschemesOptions.next(options);\n }\n getColorschemesOptions() {\n return this.pColorschemesOptions;\n }\n static {\n this.ɵfac = function ThemeService_Factory(__ngFactoryType__) {\n return new (__ngFactoryType__ || ThemeService)();\n };\n }\n static {\n this.ɵprov = /* @__PURE__ */i0.ɵɵdefineInjectable({\n token: ThemeService,\n factory: ThemeService.ɵfac,\n providedIn: 'root'\n });\n }\n }\n return ThemeService;\n})();\n(() => {\n (typeof ngDevMode === \"undefined\" || ngDevMode) && void 0;\n})();\nlet BaseChartDirective = /*#__PURE__*/(() => {\n class BaseChartDirective {\n constructor(element, zone, themeService, config) {\n this.zone = zone;\n this.themeService = themeService;\n this.type = 'bar';\n this.plugins = [];\n this.chartClick = new EventEmitter();\n this.chartHover = new EventEmitter();\n this.subs = [];\n this.themeOverrides = {};\n if (config?.registerables) {\n Chart.register(...config.registerables);\n }\n if (config?.defaults) {\n defaults.set(config.defaults);\n }\n this.ctx = element.nativeElement.getContext('2d');\n this.subs.push(this.themeService.colorschemesOptions.pipe(distinctUntilChanged()).subscribe(r => this.themeChanged(r)));\n }\n ngOnChanges(changes) {\n const requireRender = ['type'];\n const propertyNames = Object.getOwnPropertyNames(changes);\n if (propertyNames.some(key => requireRender.includes(key)) || propertyNames.every(key => changes[key].isFirstChange())) {\n this.render();\n } else {\n const config = this.getChartConfiguration();\n // Using assign to avoid changing the original object reference\n if (this.chart) {\n Object.assign(this.chart.config.data, config.data);\n if (this.chart.config.plugins) {\n Object.assign(this.chart.config.plugins, config.plugins);\n }\n if (this.chart.config.options) {\n Object.assign(this.chart.config.options, config.options);\n }\n }\n this.update();\n }\n }\n ngOnDestroy() {\n if (this.chart) {\n this.chart.destroy();\n this.chart = void 0;\n }\n this.subs.forEach(s => s.unsubscribe());\n }\n render() {\n if (this.chart) {\n this.chart.destroy();\n }\n return this.zone.runOutsideAngular(() => this.chart = new Chart(this.ctx, this.getChartConfiguration()));\n }\n update(mode) {\n if (this.chart) {\n this.zone.runOutsideAngular(() => this.chart?.update(mode));\n }\n }\n hideDataset(index, hidden) {\n if (this.chart) {\n this.chart.getDatasetMeta(index).hidden = hidden;\n this.update();\n }\n }\n isDatasetHidden(index) {\n return this.chart?.getDatasetMeta(index)?.hidden;\n }\n toBase64Image() {\n return this.chart?.toBase64Image();\n }\n themeChanged(options) {\n this.themeOverrides = options;\n if (this.chart) {\n if (this.chart.config.options) {\n Object.assign(this.chart.config.options, this.getChartOptions());\n }\n this.update();\n }\n }\n getChartOptions() {\n return merge({\n onHover: (event, active) => {\n if (!this.chartHover.observed && !this.chartHover.observers?.length) {\n return;\n }\n this.zone.run(() => this.chartHover.emit({\n event,\n active\n }));\n },\n onClick: (event, active) => {\n if (!this.chartClick.observed && !this.chartClick.observers?.length) {\n return;\n }\n this.zone.run(() => this.chartClick.emit({\n event,\n active\n }));\n }\n }, this.themeOverrides, this.options, {\n plugins: {\n legend: {\n display: this.legend\n }\n }\n });\n }\n getChartConfiguration() {\n return {\n type: this.type,\n data: this.getChartData(),\n options: this.getChartOptions(),\n plugins: this.plugins\n };\n }\n getChartData() {\n return this.data ? this.data : {\n labels: this.labels || [],\n datasets: this.datasets || []\n };\n }\n static {\n this.ɵfac = function BaseChartDirective_Factory(__ngFactoryType__) {\n return new (__ngFactoryType__ || BaseChartDirective)(i0.ɵɵdirectiveInject(i0.ElementRef), i0.ɵɵdirectiveInject(i0.NgZone), i0.ɵɵdirectiveInject(ThemeService), i0.ɵɵdirectiveInject(NG_CHARTS_CONFIGURATION, 8));\n };\n }\n static {\n this.ɵdir = /* @__PURE__ */i0.ɵɵdefineDirective({\n type: BaseChartDirective,\n selectors: [[\"canvas\", \"baseChart\", \"\"]],\n inputs: {\n type: \"type\",\n legend: \"legend\",\n data: \"data\",\n options: \"options\",\n plugins: \"plugins\",\n labels: \"labels\",\n datasets: \"datasets\"\n },\n outputs: {\n chartClick: \"chartClick\",\n chartHover: \"chartHover\"\n },\n exportAs: [\"base-chart\"],\n standalone: true,\n features: [i0.ɵɵNgOnChangesFeature]\n });\n }\n }\n return BaseChartDirective;\n})();\n(() => {\n (typeof ngDevMode === \"undefined\" || ngDevMode) && void 0;\n})();\n\n/*\n * Public API Surface of ng2-charts\n */\n\n/**\n * Generated bundle index. Do not edit.\n */\n\nexport { BaseChartDirective, NG_CHARTS_CONFIGURATION, ThemeService, provideCharts, withDefaultRegisterables };\n","import { Injectable } from \"@angular/core\";\r\nimport { Company } from \"../../models/domains/pbm/companies/company\";\r\nimport { ExportOrderKey } from \"../../models/domains/pbm/exports/export-order-key\";\r\nimport { IFileFileExportResult } from \"../../models/domains/pbm/exports/file-export-result\";\r\n\r\nimport { GeneralReportRepository, IParamsGeneralReport } from \"../../repositories/pbm/general-report.repository\";\r\nimport { FileExportService } from \"../file-export.service\";\r\nimport { UserService } from \"../user.service\";\r\nimport { SelectionModel } from \"@angular/cdk/collections\";\r\nimport { MatPaginator } from \"@angular/material/paginator\";\r\nimport { MatSort } from \"@angular/material/sort\";\r\nimport { MatTableDataSource } from \"@angular/material/table\";\r\n\r\n@Injectable({ providedIn: \"root\" })\r\nexport class GeneralReportService {\r\n /**\r\n * 0=status inicial\r\n * 1=processando\r\n * 2=processado e pronto para download\r\n */\r\n private processStatus: number = 0;\r\n private orderKey: ExportOrderKey;\r\n private allowedCompanies = new MatTableDataSource();\r\n private selectedCompanies = new SelectionModel(true, []);\r\n private messageStatus: string;\r\n private filters: {\r\n startAt: string;\r\n endAt: string;\r\n fiscalNumber: string;\r\n } = { startAt: \"\", endAt: \"\", fiscalNumber: \"\" };\r\n private readonly intervalInMillis: number = 5000;\r\n private intervalHandle: any;\r\n\r\n constructor(\r\n private generalReportRepository: GeneralReportRepository,\r\n private userService: UserService,\r\n private fileExportService: FileExportService,\r\n ) {}\r\n\r\n /**\r\n *\r\n * @returns 0=status inicial | 1=processando | 2=processado e pronto para download\r\n */\r\n getProcessStatus(): number {\r\n return this.processStatus;\r\n }\r\n\r\n setProcessStatus(processStatus: 0 | 1 | 2) {\r\n this.processStatus = processStatus;\r\n }\r\n\r\n async generalReportExportOrderKey() {\r\n try {\r\n this.messageStatus = \"\";\r\n let fiscalNumbers: Array<{ value: string }> = [];\r\n this.selectedCompanies.selected.forEach((allowedCompanie) => {\r\n fiscalNumbers.push({ value: allowedCompanie.getFiscalNumber() });\r\n });\r\n\r\n let re = /\\//gi;\r\n const params: IParamsGeneralReport = {\r\n startAt: this.filters.startAt.replace(re, \"\") + \" 00:00\",\r\n endAt: this.filters.endAt.replace(re, \"\") + \" 23:59\",\r\n fiscalNumbers: fiscalNumbers,\r\n };\r\n\r\n this.processStatus = 1;\r\n this.orderKey = await this.generalReportRepository.generalReportExportOrderKey(params);\r\n this.checkFileStatus();\r\n } catch (error) {\r\n clearInterval(this.intervalHandle);\r\n this.processStatus = 0;\r\n this.messageStatus = \"Ocorreu um erro ao processar o relatório. Tente novamente mais tarde.\";\r\n console.error(error);\r\n }\r\n }\r\n\r\n checkFileStatus() {\r\n this.intervalHandle = setInterval(async () => {\r\n try {\r\n const status = await this.fileExportService.getFileExportStatusNumber(this.orderKey);\r\n if (status == 1) {\r\n clearInterval(this.intervalHandle);\r\n this.processStatus = 2;\r\n } else if (status == -1) {\r\n clearInterval(this.intervalHandle);\r\n this.processStatus = 0;\r\n this.messageStatus = \"Ocorreu algum erro ao obter o arquivo. Tente novamente mais tarde.\";\r\n }\r\n } catch (error) {\r\n console.log(error);\r\n }\r\n }, this.intervalInMillis);\r\n }\r\n\r\n getMessageStatus() {\r\n return this.messageStatus;\r\n }\r\n\r\n async download() {\r\n const fileExportResult: IFileFileExportResult = await this.fileExportService.exportFileAsXLSX(this.orderKey);\r\n if (!!fileExportResult) {\r\n fileExportResult.notifyDownload(\"relatorio-geral\");\r\n }\r\n this.processStatus = 0;\r\n }\r\n\r\n getAllowedCompanies() {\r\n return this.allowedCompanies;\r\n }\r\n\r\n getSelectedCompanies() {\r\n return this.selectedCompanies;\r\n }\r\n\r\n getFilters() {\r\n return this.filters;\r\n }\r\n\r\n sortTable(sort: MatSort) {\r\n if (sort.direction === \"asc\") {\r\n this.allowedCompanies.data = this.allowedCompanies.data.sort((a, b) => {\r\n if (this.getIsSelected(a) !== -1 && !(this.getIsSelected(b) !== -1)) {\r\n return -1;\r\n } else if (this.getIsSelected(b) !== -1 && !(this.getIsSelected(a) !== -1)) {\r\n return 1;\r\n }\r\n });\r\n } else if (sort.direction === \"desc\") {\r\n this.allowedCompanies.data = this.allowedCompanies.data.sort((a, b) => {\r\n if (this.getIsSelected(a) !== -1 && !(this.getIsSelected(b) !== -1)) {\r\n return 1;\r\n } else if (this.getIsSelected(b) !== -1 && !(this.getIsSelected(a) !== -1)) {\r\n return -1;\r\n }\r\n });\r\n } else {\r\n this.allowedCompanies.data = this.allowedCompanies.data.sort((a, b) => {\r\n if (a.getCorporateName() === b.getCorporateName()) {\r\n return Number.parseInt(a.getFiscalNumber()) - Number.parseInt(b.getFiscalNumber());\r\n }\r\n return a.getCorporateName() > b.getCorporateName() ? 1 : -1;\r\n });\r\n }\r\n }\r\n\r\n filterAllowedCompanies(paginator: MatPaginator) {\r\n this.allowedCompanies.data = this.userService\r\n .getLoggedUser()\r\n .getAllowedCompanies()\r\n .filter((ac) => {\r\n return ac.getFiscalNumber().substr(0, 8) === this.filters.fiscalNumber.replace(/[^\\d]+/g, \"\").substr(0, 8) || this.filters.fiscalNumber === \"\";\r\n });\r\n\r\n this.allowedCompanies.paginator = paginator;\r\n }\r\n\r\n clearAllowedCompanies() {\r\n clearInterval(this.intervalHandle);\r\n this.allowedCompanies.data = [];\r\n this.selectedCompanies.clear();\r\n this.filters = { startAt: \"\", endAt: \"\", fiscalNumber: \"\" };\r\n this.processStatus = 0;\r\n this.messageStatus = \"\";\r\n }\r\n\r\n isAllSelected() {\r\n const numSelected = this.selectedCompanies.selected.length;\r\n const numRows = this.allowedCompanies.data.length;\r\n return numSelected === numRows;\r\n }\r\n\r\n masterToggle() {\r\n if (this.isAllSelected()) {\r\n this.selectedCompanies.clear();\r\n return;\r\n }\r\n this.selectedCompanies.clear();\r\n this.allowedCompanies.data.forEach((company) => {\r\n this.selectedCompanies.selected.push(company);\r\n });\r\n }\r\n\r\n selectCompany(event: any, element: Company, sort: MatSort) {\r\n const idx = this.getIsSelected(element);\r\n if (idx == -1) {\r\n this.selectedCompanies.selected.push(element);\r\n } else {\r\n this.selectedCompanies.selected.splice(idx, 1);\r\n }\r\n this.allowedCompanies.sort = sort;\r\n }\r\n\r\n /**\r\n * O método nativo this.selectedCompanies.isSelected(element) não funciona neste contexto pois\r\n * ele faz referência a objetos. Quando os dados de \"allCompanies\" eram atualizados, perdiam-se\r\n * as referências dos objetos selecionados mesmo ainda estando na lista \"selectedCompanies\".\r\n * Faz a busca \"manualmente\" verificando pelo identificador fiscalNumber (CNPJ).\r\n * @param element Company this.selectedCompanies.\r\n * @returns índice do elemento. Se não encontrar, retorna -1\r\n */\r\n getIsSelected(element: Company): number {\r\n let ret = -1;\r\n for (let i = 0; i < this.selectedCompanies.selected.length; i++) {\r\n const selected = this.selectedCompanies.selected[i];\r\n if (element.getFiscalNumber() === selected.getFiscalNumber()) {\r\n ret = i;\r\n break;\r\n }\r\n }\r\n return ret;\r\n }\r\n}\r\n","import { Component, OnInit, ElementRef, Input } from \"@angular/core\";\r\nimport { Router } from \"@angular/router\";\r\n\r\nimport { UserService } from \"src/app/ui/services/user.service\";\r\nimport { HeaderService } from \"./../../services/header.service\";\r\nimport { environment } from \"src/environments/environment\";\r\nimport { AuthService } from \"../../services/auth.service\";\r\nimport { RouteStrategyFactory } from \"../../gateways/route-strategy-factory\";\r\nimport { RoutePath } from \"../../models/domains/route-paths.model\";\r\nimport { GeneralReportService } from \"../../services/pbm/general-report.service\";\r\n\r\n@Component({\r\n selector: \"header\",\r\n templateUrl: \"./header.component.html\",\r\n styleUrls: [\"./header.component.scss\"],\r\n})\r\nexport class HeaderComponent implements OnInit {\r\n @Input() headerTitle: string;\r\n\r\n date = new Date();\r\n today = this.date.toLocaleDateString(\"pt-br\", {\r\n year: \"numeric\",\r\n month: \"long\",\r\n day: \"numeric\",\r\n });\r\n\r\n constructor(\r\n private authService: AuthService,\r\n public el: ElementRef,\r\n private routeStrategyFactory: RouteStrategyFactory,\r\n private router: Router,\r\n private headerService: HeaderService,\r\n private userService: UserService,\r\n private generalReportService: GeneralReportService,\r\n ) {}\r\n\r\n ngOnInit(): void {}\r\n\r\n getAppName(): string {\r\n return environment.appName;\r\n }\r\n\r\n getTitle(): string {\r\n return this.headerTitle;\r\n }\r\n\r\n getVersion(): string {\r\n return environment.version;\r\n }\r\n\r\n getDate(): string {\r\n return this.today;\r\n }\r\n\r\n getUserName(): string {\r\n if (this.userService.getLoggedUser()) {\r\n return this.userService.getLoggedUser().getName();\r\n }\r\n return \"\";\r\n }\r\n\r\n getUserRole(): string {\r\n const userRoleList = this.userService.getLoggedUser().getUserRoleList();\r\n if (userRoleList && userRoleList.length > 0) return userRoleList[0].getName();\r\n return \"\";\r\n }\r\n\r\n logOut(): void {\r\n this.authService.logout();\r\n this.generalReportService.clearAllowedCompanies(); //lista do relatório geral\r\n this.routeStrategyFactory.createStrategy().redirect();\r\n }\r\n\r\n healthCheck(): void {\r\n this.router.navigate([RoutePath.HealthCheck]);\r\n }\r\n\r\n getTitleText(): string {\r\n return this.headerService.getTitleText();\r\n }\r\n\r\n getTitleIcon(): string {\r\n return this.headerService.getTitleIcon();\r\n }\r\n}\r\n","
\r\n

\r\n {{ getTitleIcon() }}\r\n {{ getTitleText() }}\r\n

\r\n
\r\n\r\n
\r\n
\r\n today\r\n {{ getDate() }}\r\n {{ getDate() }}\r\n
\r\n
\r\n account_box\r\n {{ getUserName() }}\r\n \r\n {{ getUserName() }}\r\n
{{ getUserRole() }}\r\n
\r\n
\r\n exit_to_app\r\n
\r\n","import { Directive, HostListener, Input, Optional } from \"@angular/core\";\r\n\r\nimport { DialogRef } from \"./dialog-ref\";\r\n\r\n@Directive({\r\n selector: \"[dialogClose]\",\r\n})\r\nexport class DialogCloseDirective {\r\n @Input(\"dialogClose\") dialogResult: T;\r\n\r\n constructor(@Optional() private dialogRef: DialogRef) {}\r\n\r\n @HostListener(\"click\") onClick(): void {\r\n if (!this.dialogRef) {\r\n console.error(\"dialogClose is not supported within a template\");\r\n\r\n return;\r\n }\r\n\r\n this.dialogRef.close(this.dialogResult);\r\n }\r\n}\r\n","import { NgModule } from \"@angular/core\";\r\nimport { MatDividerModule } from \"@angular/material/divider\";\r\nimport { CommonModule } from \"@angular/common\";\r\nimport { FlexLayoutModule } from \"@ngbracket/ngx-layout\";\r\nimport { DialogContent, DialogActions, DialogHeader } from \"./full-dialog.directives\";\r\nimport { FullDialogComponent } from \"./full-dialog.component\";\r\n\r\n@NgModule({\r\n declarations: [\r\n FullDialogComponent,\r\n DialogContent,\r\n DialogActions,\r\n DialogHeader\r\n ],\r\n imports: [\r\n CommonModule,\r\n FlexLayoutModule,\r\n MatDividerModule\r\n ],\r\n exports: [\r\n FullDialogComponent,\r\n DialogContent,\r\n DialogActions,\r\n DialogHeader\r\n ],\r\n})\r\nexport class FullDialogModule {}\r\n","import { OverlayModule } from \"@angular/cdk/overlay\";\r\nimport { PortalModule } from \"@angular/cdk/portal\";\r\nimport { CommonModule } from \"@angular/common\";\r\nimport { NgModule } from \"@angular/core\";\r\n\r\nimport { DialogCloseDirective } from \"./dialog-close.directive\";\r\nimport { DialogComponent } from \"./dialog/dialog.component\";\r\nimport { FullDialogModule } from \"./full-dialog/full-dialog.module\";\r\n\r\n@NgModule({\r\n declarations: [DialogComponent, DialogCloseDirective],\r\n imports: [CommonModule, OverlayModule, PortalModule, FullDialogModule],\r\n exports: [DialogCloseDirective, FullDialogModule]\r\n})\r\nexport class DialogModule {}\r\n","import { NgModule } from \"@angular/core\";\r\nimport { ToastComponent } from \"./toast.component\";\r\nimport { FlexLayoutModule } from \"@ngbracket/ngx-layout\";\r\nimport { CommonModule } from \"@angular/common\";\r\nimport { Toast } from \"./toast\";\r\nimport { OverlayModule } from \"@angular/cdk/overlay\";\r\nimport { MatIconModule } from \"@angular/material/icon\";\r\nimport { MatTooltipModule } from \"@angular/material/tooltip\";\r\n\r\n@NgModule({\r\n imports: [\r\n OverlayModule,\r\n MatIconModule,\r\n MatTooltipModule,\r\n FlexLayoutModule,\r\n CommonModule\r\n ],\r\n declarations: [ToastComponent],\r\n exports: [ToastComponent],\r\n providers: [Toast]\r\n})\r\nexport class ToastModule {}\r\n","import { Component, OnInit, Input } from \"@angular/core\";\r\n\r\n@Component({\r\n selector: \"input-message\",\r\n templateUrl: \"./input-message.component.html\",\r\n styleUrls: [\"./input-message.component.scss\"],\r\n})\r\nexport class InputMessageComponent implements OnInit {\r\n constructor() {}\r\n\r\n @Input() message: string;\r\n @Input() color: string;\r\n ngOnInit() {}\r\n\r\n getStyle(): object {\r\n return { color: this.color, \"padding-left\": \"5px\", \"font-size\": \"1em\" };\r\n }\r\n}\r\n","
\r\n \r\n error\r\n

{{ message }}

\r\n
\r\n
\r\n","import { NgModule } from \"@angular/core\";\r\nimport { NavBarComponent } from \"./nav-bar.component\";\r\nimport { MenuBarComponent } from \"./menu-bar/menu-bar\";\r\nimport { CommonModule } from \"@angular/common\";\r\nimport { FlexLayoutModule } from \"@ngbracket/ngx-layout\";\r\nimport { MenuAccountComponent } from \"./menu-account/menu-account.component\";\r\nimport { PipeModule } from \"src/app/ui/pipes/pipe.module\";\r\nimport { ImgSvgComponent } from \"../../img-svg/img-svg.component\";\r\nimport { NewsPanelComponent } from \"../../news-panel/news-panel.component\";\r\nimport { MatBadgeModule } from \"@angular/material/badge\";\r\nimport { MatButtonModule } from \"@angular/material/button\";\r\nimport { MatDividerModule } from \"@angular/material/divider\";\r\nimport { MatIconModule } from \"@angular/material/icon\";\r\nimport { MatMenuModule } from \"@angular/material/menu\";\r\nimport { MatTooltipModule } from \"@angular/material/tooltip\";\r\n\r\n@NgModule({\r\n declarations: [NavBarComponent, MenuBarComponent, MenuAccountComponent, ImgSvgComponent, NewsPanelComponent],\r\n imports: [\r\n MatIconModule,\r\n MatMenuModule,\r\n MatBadgeModule,\r\n MatButtonModule,\r\n CommonModule,\r\n FlexLayoutModule,\r\n MatDividerModule,\r\n MatTooltipModule,\r\n PipeModule,\r\n ],\r\n exports: [NavBarComponent, MatBadgeModule, MenuBarComponent, ImgSvgComponent, NewsPanelComponent],\r\n})\r\nexport class NavBarModule {}\r\n","import { Component, Input, OnChanges, OnInit, Output, ViewChild } from \"@angular/core\";\r\nimport { Router } from \"@angular/router\";\r\nimport { Menu } from \"./menu-item.model\";\r\nimport { CdkOverlayOrigin, ConnectionPositionPair } from \"@angular/cdk/overlay\";\r\nimport { EventEmitter } from '@angular/core';\r\nimport { AppContext } from \"../../../contexts/app-context\";\r\nimport { RoutePath } from \"../../../models/domains/route-paths.model\";\r\n\r\n@Component({\r\n selector: \"menu-item\",\r\n templateUrl: \"./menu-item.component.html\",\r\n styleUrls: [\"./menu-item.component.scss\"],\r\n})\r\nexport class MenuItemComponent implements OnChanges, OnInit {\r\n @Input() items: Menu[];\r\n @Input() isOpened: boolean;\r\n @Input() openMenu: boolean = false;\r\n @Input() trigger!: CdkOverlayOrigin;\r\n @Output() closeMenu = new EventEmitter();\r\n @ViewChild(\"childMenu\") public childMenu;\r\n isProduto = false;\r\n positionPairs: ConnectionPositionPair[] = [\r\n {\r\n offsetX: 185,\r\n originX: \"end\",\r\n originY: \"center\",\r\n overlayX: \"end\",\r\n overlayY: \"top\"\r\n },\r\n ];\r\n\r\n constructor(private router: Router, private context: AppContext) { }\r\n\r\nngOnInit(){\r\n this.fontColorValidation();\r\n this.btnColorValidation();\r\n}\r\n\r\n ngOnChanges() {\r\n this.positionPairs = [\r\n {\r\n offsetX: this.isOpened ? 185 : 60,\r\n originX: \"end\",\r\n originY: \"center\",\r\n overlayX: \"end\",\r\n overlayY: \"top\"\r\n },\r\n ];\r\n }\r\n\r\n goTo(route: RoutePath): void {\r\n this.closeMenu.emit();\r\n this.router.navigate([route]);\r\n }\r\n\r\n goExternal(route: string): void {\r\n this.closeMenu.emit();\r\n window.open(route);\r\n }\r\n\r\n \r\n btnColorValidation() {\r\n const btnColor = this.context.getCurrentTenant().tenantStyle.buttonBackgroundColor.toString();\r\n if (btnColor == '') {\r\n return \"#9389fb;\";\r\n } else {\r\n return btnColor;\r\n }\r\n }\r\n\r\n fontColorValidation() {\r\n const fontColor = this.context.getCurrentTenant().tenantStyle.fontColor.toString();\r\n if (fontColor == '') {\r\n return \"#fefefe;\";\r\n } else {\r\n return fontColor;\r\n }\r\n }\r\n}\r\n","\r\n
\r\n \r\n \r\n \r\n
\r\n
","import { UserPermissions } from \"./../../models/domains/pbm/user/user-permissions\";\r\nimport { UserService } from \"src/app/ui/services/user.service\";\r\nimport { PageViews } from \"./../../models/domains/features/custom-page-views\";\r\nimport { Component, Input, OnInit, ViewChild, ViewEncapsulation } from \"@angular/core\";\r\nimport { Router } from \"@angular/router\";\r\nimport { RoutePath } from \"../../models/domains/route-paths.model\";\r\nimport { FeatureViewService } from \"./../../services/feature-view.service\";\r\nimport { environment } from \"src/environments/environment\";\r\nimport { AppContext } from \"../../contexts/app-context\";\r\nimport { MatMenuTrigger } from \"@angular/material/menu\";\r\nimport { MatSidenav } from \"@angular/material/sidenav\";\r\n@Component({\r\n selector: \"sidenav\",\r\n templateUrl: \"./sidenav.component.html\",\r\n styleUrls: [\"./sidenav.component.scss\"],\r\n encapsulation: ViewEncapsulation.None,\r\n})\r\nexport class SidenavComponent implements OnInit {\r\n @Input() opened: boolean;\r\n @ViewChild(\"menuTrigger\", { static: true }) menuTrigger: MatMenuTrigger;\r\n @ViewChild(\"sidenav\", { static: true }) sidenav: MatSidenav;\r\n public showManagementGroupMenu = false;\r\n version = environment.version;\r\n\r\n events: string[] = [];\r\n menuSidebar = [\r\n {\r\n link_name: \"HOME\",\r\n link: RoutePath.Home,\r\n icon: \"home\",\r\n sub_menu: null,\r\n hasPermission: true,\r\n isActive: PageViews.HomePageView,\r\n opened: false,\r\n },\r\n {\r\n link_name: \"USUÁRIOS\",\r\n link: RoutePath.SearchUser,\r\n icon: \"account_circle\",\r\n sub_menu: null,\r\n hasPermission: this.hasAccessTo(UserPermissions.SearchUser),\r\n isActive: PageViews.UserPageView,\r\n opened: false,\r\n },\r\n {\r\n link_name: \"EMPRESAS\",\r\n link: RoutePath.SearchCompany,\r\n icon: \"work\",\r\n sub_menu: null,\r\n hasPermission: this.hasAccessTo(UserPermissions.SearchCompany),\r\n isActive: PageViews.CompanyPageView,\r\n opened: false,\r\n },\r\n {\r\n link_name: \"BENEFÍCIOS\",\r\n link: RoutePath.SearchBenefit,\r\n icon: \"local_hospital\",\r\n sub_menu: null,\r\n hasPermission: this.hasAccessTo(UserPermissions.SearchBenefit),\r\n isActive: PageViews.BenefitPageView,\r\n opened: false,\r\n },\r\n {\r\n link_name: \"BENEFICIÁRIOS\",\r\n link: RoutePath.SearchBeneficiary,\r\n icon: \"assignment_ind\",\r\n sub_menu: null,\r\n hasPermission: this.hasAccessTo(UserPermissions.SearchBeneficiary),\r\n isActive: PageViews.BeneficiaryPageView,\r\n opened: false,\r\n },\r\n {\r\n link_name: \"HISTÓRICO DE VENDAS\",\r\n link: RoutePath.SalesHistoryCompanies,\r\n icon: \"shopping_cart\",\r\n sub_menu: null,\r\n hasPermission: this.hasAccessTo(UserPermissions.SearchSalesHistory),\r\n isActive: PageViews.SalesHistoriesPageView,\r\n opened: false,\r\n },\r\n {\r\n link_name: \"FECHAMENTO FINANCEIRO\",\r\n link: RoutePath.CompanyFinancialReport,\r\n icon: \"description\",\r\n sub_menu: null,\r\n hasPermission: this.hasAccessTo(UserPermissions.ViewCompanyFinancialReport),\r\n isActive: PageViews.FinancialReportPageView,\r\n opened: false,\r\n },\r\n {\r\n link_name: \"EXTRATO BENEFICIÁRIOS\",\r\n link: RoutePath.SearchFinancialStatement,\r\n icon: \"account_balance\",\r\n sub_menu: null,\r\n hasPermission: this.hasAccessTo(UserPermissions.SearchFinancialStatement),\r\n isActive: PageViews.FinancialStatementPageView,\r\n opened: false,\r\n },\r\n {\r\n link_name: \"EXTRATO PDV\",\r\n link: null,\r\n icon: \"receipt\",\r\n hasPermission: this.hasAccessTo(UserPermissions.SearchNetworkFinancialStatement),\r\n isActive: PageViews.NetworkFinancialStatementsPageView,\r\n opened: false,\r\n sub_menu: [\r\n {\r\n link_name: \"VISÃO DE REDE\",\r\n link: RoutePath.NetworkFinancialStatements,\r\n isActive: PageViews.NetworkFinancialStatementsPageView,\r\n hasPermission: this.hasAccessTo(UserPermissions.SearchNetworkFinancialStatement),\r\n opened: false,\r\n },\r\n {\r\n link_name: \"VISÃO DE PAGAMENTO \",\r\n link: RoutePath.NetworkFinancialStatmentPayment,\r\n isActive: PageViews.NetworkFinancialStatementsPaymentPageView,\r\n hasPermission: this.hasAccessTo(UserPermissions.SearchNetworkFinancialStatement),\r\n opened: false,\r\n },\r\n ],\r\n },\r\n {\r\n link_name: \"REDE CREDENCIADA\",\r\n link: RoutePath.SearchNetworkTerm,\r\n icon: \"group\",\r\n sub_menu: null,\r\n hasPermission: this.hasAccessTo(UserPermissions.SearchNetworkTerm),\r\n isActive: PageViews.NetworkTermPageView,\r\n opened: false,\r\n },\r\n {\r\n link_name: \"GESTÃO\",\r\n link: null,\r\n icon: \"settings_applications\",\r\n hasPermission: this.hasAccessToManagementButton(),\r\n opened: false,\r\n sub_menu: [\r\n {\r\n link_name: \"GESTÃO LPM\",\r\n link: RoutePath.SearchLpmCompanies,\r\n hasPermission: this.hasAccessTo(UserPermissions.ViewLpmManagement),\r\n opened: false,\r\n },\r\n {\r\n link_name: \"GESTÃO TRANSACIONAL\",\r\n link: RoutePath.TransactionalManagement,\r\n hasPermission: this.hasAccessTo(UserPermissions.TransactionalManagement),\r\n opened: false,\r\n },\r\n {\r\n link_name: \"GESTÃO DE MÉDICOS\",\r\n link: RoutePath.SearchPractitioner,\r\n hasPermission: this.hasAccessTo(UserPermissions.SearchPractitioner),\r\n opened: false,\r\n },\r\n {\r\n link_name: \"GESTÃO DE CLUSTERS \",\r\n link: RoutePath.SearchClusterManagement,\r\n hasPermission: this.hasAccessTo(UserPermissions.ViewCluster),\r\n opened: false,\r\n },\r\n\r\n {\r\n link_name: \"GESTÃO DE CATÁLOGO \",\r\n link: environment.productCatalog,\r\n hasPermission: this.hasAccessTo(UserPermissions.SearchProduct),\r\n externalOpening: true,\r\n opened: false,\r\n },\r\n ],\r\n },\r\n {\r\n link_name: \"PORTAL DROGARIA\",\r\n link: RoutePath.DrugstoreTests,\r\n icon: \"local_pharmacy\",\r\n sub_menu: null,\r\n hasPermission: this.hasAccessTo(UserPermissions.PDVTest),\r\n isActive: PageViews.DrugstoreTests,\r\n opened: false,\r\n },\r\n {\r\n link_name: \"RELATÓRIO GERAL\",\r\n link: RoutePath.GeneralReport,\r\n icon: \"file_download\",\r\n sub_menu: null,\r\n hasPermission: this.hasAccessTo(UserPermissions.ViewGeneralReport),\r\n isActive: PageViews.GeneralReport,\r\n opened: false,\r\n },\r\n {\r\n link_name: \"AUDITORIA\",\r\n link: RoutePath.AuditSale,\r\n icon: \"verified\",\r\n sub_menu: null,\r\n hasPermission: this.hasAccessTo(UserPermissions.ViewAudit),\r\n isActive: PageViews.AuditSale,\r\n opened: false,\r\n },\r\n ];\r\n\r\n constructor(private context: AppContext, private router: Router, private featureViewService: FeatureViewService, private userService: UserService) {}\r\n\r\n ngOnInit() {\r\n this.btnColorValidation();\r\n this.fontColorValidation();\r\n }\r\n\r\n btnColorValidation() {\r\n return this.context.getCurrentTenant().tenantStyle.buttonBackgroundColor;\r\n }\r\n\r\n fontColorValidation() {\r\n return this.context.getCurrentTenant().tenantStyle.fontColor;\r\n }\r\n\r\n goTo(route: RoutePath): void {\r\n this.router.navigate([route]);\r\n }\r\n\r\n openSubMenu() {\r\n this.menuTrigger.openMenu();\r\n }\r\n\r\n isPageView(PermissionToPageView: string): boolean {\r\n return this.featureViewService.getActivePageView() === PermissionToPageView;\r\n }\r\n\r\n hasAccessTo(UserPermission: string): boolean {\r\n return this.userService.getLoggedUser().hasPermission(UserPermission);\r\n }\r\n\r\n hasAccessToManagementButton(): boolean {\r\n return (\r\n this.hasAccessTo(UserPermissions.ViewLpmManagement) ||\r\n this.hasAccessTo(UserPermissions.SearchProduct) ||\r\n this.hasAccessTo(UserPermissions.TransactionalManagement) ||\r\n this.hasAccessTo(UserPermissions.SearchPractitioner) ||\r\n this.hasAccessTo(UserPermissions.ViewCluster)\r\n );\r\n }\r\n\r\n isAuditPageView(): boolean {\r\n return this.featureViewService.getActivePageView() === PageViews.AuditSale || this.featureViewService.getActivePageView() === PageViews.AuditSaleDetails;\r\n }\r\n}\r\n","
\r\n
\r\n
\r\n
\r\n \r\n {{ item.icon }}\r\n \r\n {{ item.link_name }}\r\n \r\n \r\n
\r\n
\r\n \r\n
\r\n {{ item.icon }}\r\n \r\n {{ item.link_name }}\r\n \r\n
\r\n chevron_right\r\n \r\n \r\n
\r\n
\r\n
\r\n\r\n
\r\n \r\n

Versão: {{ version }}

\r\n
\r\n
\r\n","import { Component, OnInit } from \"@angular/core\";\r\nimport { Router } from \"@angular/router\";\r\n\r\nimport { UserPermissions } from \"./../../../../models/domains/pbm/user/user-permissions\";\r\nimport { UserService } from \"src/app/ui/services/user.service\";\r\nimport { CompanyService } from \"src/app/ui/services/pbm/company.service\";\r\nimport { LoadingService } from \"src/app/ui/services/loading.service\";\r\nimport { PageableResult } from \"src/app/ui/models/domains/paginator/pageable-result\";\r\nimport { PagingRequest } from \"src/app/ui/models/domains/paginator/paging-request\";\r\nimport { MaskInput } from \"src/app/ui/models/domains/masks/mask.model\";\r\nimport { AppContext } from \"src/app/ui/contexts/app-context\";\r\nimport { FeatureViewService } from \"src/app/ui/services/feature-view.service\";\r\nimport { FeatureViews } from \"src/app/ui/models/domains/features/custom-feature-views\";\r\nimport { PageViews } from \"src/app/ui/models/domains/features/custom-page-views\";\r\nimport { RoutePath } from \"src/app/ui/models/domains/route-paths.model\";\r\nimport { UserProfile } from \"src/app/ui/models/domains/pbm/user/user-profile\";\r\nimport { UntypedFormControl } from \"@angular/forms\";\r\nimport { ICompanyFilterParams } from \"src/app/ui/models/domains/pbm/companies/company-filter-params\";\r\n\r\n@Component({\r\n selector: \"search-company\",\r\n templateUrl: \"./search-company.component.html\",\r\n styleUrls: [\"./search-company.component.scss\"],\r\n})\r\nexport class SearchCompanyComponent implements OnInit {\r\n private searchCompanyFirst: boolean;\r\n private userProfile: UserProfile;\r\n filterText: string;\r\n pageableResult: PageableResult = new PageableResult();\r\n fiscalNumberMask = MaskInput.getFicalNumberMask();\r\n searchType: UntypedFormControl;\r\n searchStatus: UntypedFormControl;\r\n statusPreference: number = 3;\r\n\r\n constructor(\r\n private router: Router,\r\n private featureViewService: FeatureViewService,\r\n private loadingService: LoadingService,\r\n private companyService: CompanyService,\r\n private appContext: AppContext,\r\n private userService: UserService,\r\n ) {\r\n this.searchType = new UntypedFormControl(1);\r\n this.searchStatus = new UntypedFormControl(3);\r\n }\r\n\r\n ngOnInit() {\r\n this.featureViewService.activeFeatureView(FeatureViews.CompanySearchFeatureView, PageViews.CompanyPageView);\r\n this.userProfile = this.userService.getUserProfile();\r\n this.searchCompanies(this.userProfile.getPreferences().getFilterText());\r\n }\r\n\r\n navigateToEditCompany(fiscalNumber: string) {\r\n this.router.navigate([RoutePath.EditCompany, fiscalNumber.replace(/[./-]/g, \"\")]);\r\n }\r\n\r\n scrollToLastCompany() {\r\n const bottom = document.getElementById(\"bottom\");\r\n bottom.scrollIntoView();\r\n }\r\n\r\n onPressEnterSearchCompanies(event): void {\r\n if (event.key === \"Enter\") { \r\n this.searchCompanies(this.filterText); \r\n this.statusPreference = this.searchStatus.value;\r\n }\r\n }\r\n\r\n searchCompanies(filterText: string) {\r\n const start = 1;\r\n const end = this.appContext.getTotalPerPage();\r\n this.statusPreference = this.searchStatus.value;\r\n this.searchCompanyFirst = true;\r\n this.doSearchCompany(start, end, filterText);\r\n }\r\n\r\n searchMoreCompanies() {\r\n this.searchCompanyFirst = false;\r\n const start = this.pageableResult.getEnd() + 1;\r\n const end = this.appContext.getTotalPerPage();\r\n this.doSearchCompany(start, end, this.userProfile.getPreferences().getFilterText());\r\n }\r\n\r\n private doSearchCompany(start: number, end: number, filterText: string): void {\r\n const ref = this.loadingService.beginLoading();\r\n const pagingRequest = new PagingRequest();\r\n pagingRequest.setStart(start);\r\n pagingRequest.setEnd(end);\r\n\r\n const filterParams: ICompanyFilterParams = {\r\n filterText: filterText ? filterText.replace(/[./-]/g, \"\") : \"\",\r\n status: this.statusPreference,\r\n };\r\n this.companyService\r\n .searchCompany(filterParams, pagingRequest)\r\n .then((pageableResult) => {\r\n this.pageableResult.setStart(start);\r\n this.pageableResult.setEnd(end);\r\n this.pageableResult.setTotalItems(pageableResult.getTotalItems());\r\n if (this.searchCompanyFirst) {\r\n this.pageableResult.setItems(pageableResult.getItems());\r\n } else {\r\n this.pageableResult.addItems(pageableResult.getItems());\r\n }\r\n })\r\n .catch((error) => {\r\n this.pageableResult.setItems(null);\r\n })\r\n .finally(() => {\r\n this.loadingService.finishLoading(ref);\r\n this.storageSearchPreferences(filterText);\r\n this.filterText = \"\";\r\n });\r\n }\r\n\r\n hasCompany(): boolean {\r\n return this.pageableResult.getItems() && this.pageableResult.getItems().length > 0;\r\n }\r\n\r\n showScrollBottomBtn(): boolean {\r\n return this.pageableResult.getItems().length > 1;\r\n }\r\n\r\n showMoreCompaniesBtn(): boolean {\r\n return this.pageableResult.getTotalItems() !== this.pageableResult.getItems().length && this.pageableResult.getItems().length > 1;\r\n }\r\n\r\n hasAccessToEditCompany(): boolean {\r\n return this.userService.getLoggedUser().hasPermission(UserPermissions.EditCompany);\r\n }\r\n\r\n storageSearchPreferences(filterText: string): void {\r\n this.userService.setUserPreferences(filterText ? filterText.replace(/[./-]/g, \"\") : \"\");\r\n this.userProfile = this.userService.getUserProfile();\r\n }\r\n}\r\n","\r\n \r\n
\r\n
\r\n \r\n \r\n
\r\n \r\n
\r\n \r\n \r\n \r\n
\r\n search\r\n
\r\n
\r\n
\r\n

Nenhum registro encontrado.

\r\n
\r\n
\r\n

1\">{{ pageableResult.getTotalItems() }} RESULTADOS ENCONTRADOS

\r\n

1 RESULTADO ENCONTRADO

\r\n\r\n
\r\n arrow_drop_down\r\n ir para o fim da lista\r\n
\r\n
\r\n\r\n
\r\n
\r\n
\r\n \r\n
\r\n
\r\n

{{ company.getCorporateName() }}

\r\n

CNPJ: {{ company.getFiscalNumber() | companyFederalNumber }}

\r\n

{{ company.getTradingName() }}

\r\n
\r\n
\r\n \r\n check_circle_outline\r\n clear\r\n \r\n {{ company.getIsActive() ? \"ATIVO\" : \"INATIVO\" }}\r\n
\r\n
\r\n edit_note\r\n {{ hasAccessToEditCompany() ? \"EDITAR\" : \"VISUALIZAR\" }}\r\n
\r\n
\r\n
\r\n
\r\n\r\n
\r\n carregar mais registros\r\n
\r\n\r\n
\r\n \r\n
\r\n
\r\n","import { CompanyConfiguration } from \"./company-configuration\";\r\nimport { UntypedFormGroup } from \"@angular/forms\";\r\n\r\ninterface ICompanyConfigurationHandler {\r\n handleCompanyConfigurationToForm(CompanyConfiguration: CompanyConfiguration): void;\r\n}\r\n\r\nexport class CompanyConfigurationHandler implements ICompanyConfigurationHandler {\r\n constructor(private formCompanyConfiguration: UntypedFormGroup) {}\r\n\r\n handleCompanyConfigurationToForm(companyConfiguration: CompanyConfiguration): void {\r\n this.formCompanyConfiguration.patchValue({\r\n transactionalLimit: companyConfiguration.getTransactionalLimit(),\r\n hasTransactionalLimit: companyConfiguration.isHasTransactionalLimit(),\r\n });\r\n }\r\n}\r\n","import { Component, OnInit, EventEmitter, Output, Inject } from \"@angular/core\";\r\nimport { MatDialogRef, MAT_DIALOG_DATA } from \"@angular/material/dialog\";\r\n\r\n@Component({\r\n selector: \"app-delete-contact-dialog\",\r\n templateUrl: \"./delete-contact-dialog.component.html\",\r\n styleUrls: [\"./delete-contact-dialog.component.scss\"],\r\n})\r\nexport class DeleteContactDialogComponent implements OnInit {\r\n @Output() delete: EventEmitter = new EventEmitter();\r\n\r\n constructor(private dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public data: any) {}\r\n\r\n ngOnInit() {}\r\n\r\n close() {\r\n this.dialogRef.close(true);\r\n }\r\n\r\n deleteContact() {\r\n this.delete.emit(true);\r\n }\r\n}\r\n","
\r\n
\r\n \r\n

Deletar Conntato

\r\n
\r\n
\r\n\r\n
\r\n

Tem certeza que deseja deletar o contato?

\r\n
\r\n\r\n
\r\n
\r\n Cancelar\r\n
\r\n\r\n
\r\n Deletar\r\n
\r\n
\r\n","export class ValidationResult {\r\n private errorMessages: Array = [];\r\n\r\n public addErrorMessage(errorMessage: string): void {\r\n this.errorMessages.push(errorMessage);\r\n }\r\n\r\n public getErrorMessage(): string {\r\n return this.errorMessages[0];\r\n }\r\n\r\n public hasErrorMessages(): boolean {\r\n return this.errorMessages.length > 0;\r\n }\r\n}\r\n","import { UntypedFormGroup } from \"@angular/forms\";\r\nimport { ValidationResult } from \"src/app/ui/models/domains/validator/validation-result\";\r\n\r\nexport class CompanyValidator {\r\n private validationResult = new ValidationResult();\r\n\r\n public getValidationResult(): ValidationResult {\r\n return this.validationResult;\r\n }\r\n\r\n public validate(formCompanyRegistration: UntypedFormGroup): ValidationResult {\r\n const unit = formCompanyRegistration.get(\"unit\").value;\r\n const headOfficeFiscalNumber = formCompanyRegistration.get(\"headOfficeFiscalNumber\").value;\r\n const fiscalNumber = formCompanyRegistration.get(\"fiscalNumber\").value;\r\n const corporateName = formCompanyRegistration.get(\"corporateName\").value;\r\n const street = formCompanyRegistration.get(\"street\").value;\r\n const num = formCompanyRegistration.get(\"number\").value;\r\n const district = formCompanyRegistration.get(\"district\").value;\r\n const city = formCompanyRegistration.get(\"city\").value;\r\n const region = formCompanyRegistration.get(\"region\").value;\r\n const zipCode = formCompanyRegistration.get(\"zipCode\").value;\r\n\r\n if (!unit) {\r\n this.validationResult.addErrorMessage(\"Unidade é obrigatório\");\r\n } else if (!headOfficeFiscalNumber) {\r\n this.validationResult.addErrorMessage(\"CNPJ da Unidade é obrigatório\");\r\n } else if (!fiscalNumber) {\r\n this.validationResult.addErrorMessage(\"CNPJ da Matriz é obrigatório\");\r\n } else if (!corporateName) {\r\n this.validationResult.addErrorMessage(\"Razão Social é obrigatório\");\r\n } else if (!street) {\r\n this.validationResult.addErrorMessage(\"Endereço é obrigatório\");\r\n } else if (!num) {\r\n this.validationResult.addErrorMessage(\"Número é obrigatório\");\r\n } else if (!district) {\r\n this.validationResult.addErrorMessage(\"Bairro é obrigatório\");\r\n } else if (!city) {\r\n this.validationResult.addErrorMessage(\"Cidade é obrigatório\");\r\n } else if (!region) {\r\n this.validationResult.addErrorMessage(\"UF é obrigatório\");\r\n } else if (!zipCode) {\r\n this.validationResult.addErrorMessage(\"CEP é obrigatório\");\r\n }\r\n\r\n return this.validationResult;\r\n }\r\n}\r\n","export class FormDirty {\r\n private dirty: boolean;\r\n\r\n constructor() {}\r\n\r\n isDirty(): boolean {\r\n return this.dirty;\r\n }\r\n\r\n markAsDirty(): void {\r\n this.dirty = true;\r\n }\r\n\r\n markAsClean(): void {\r\n this.dirty = false;\r\n }\r\n}\r\n","import { Masks } from \"./masks\";\r\n\r\nexport class SocialNumber {\r\n static isValid(value: string): boolean {\r\n value = value.replace(/[^\\d]+/g, \"\");\r\n\r\n if (value === \"\") {\r\n return false;\r\n }\r\n\r\n if (value === null) {\r\n return false;\r\n }\r\n\r\n if (value.length !== 11) {\r\n return false;\r\n }\r\n\r\n if (\r\n value === \"00000000000\" ||\r\n value === \"11111111111\" ||\r\n value === \"22222222222\" ||\r\n value === \"33333333333\" ||\r\n value === \"44444444444\" ||\r\n value === \"55555555555\" ||\r\n value === \"66666666666\" ||\r\n value === \"77777777777\" ||\r\n value === \"88888888888\" ||\r\n value === \"99999999999\"\r\n ) {\r\n return false;\r\n }\r\n\r\n let numero = 0;\r\n\r\n let caracter = \"\";\r\n\r\n const numeros = \"0123456789\";\r\n\r\n let j = 10;\r\n\r\n let somatorio = 0;\r\n\r\n let resto = 0;\r\n\r\n let digito1 = 0;\r\n\r\n let digito2 = 0;\r\n\r\n let valueAux = \"\";\r\n\r\n valueAux = value.substring(0, 9);\r\n\r\n for (let i = 0; i < 9; i++) {\r\n caracter = valueAux.charAt(i);\r\n\r\n if (numeros.search(caracter) === -1) {\r\n return false;\r\n }\r\n\r\n numero = Number(caracter);\r\n\r\n somatorio = somatorio + numero * j;\r\n\r\n j--;\r\n }\r\n\r\n resto = somatorio % 11;\r\n\r\n digito1 = 11 - resto;\r\n\r\n if (digito1 > 9) {\r\n digito1 = 0;\r\n }\r\n\r\n j = 11;\r\n\r\n somatorio = 0;\r\n\r\n valueAux = valueAux + digito1;\r\n\r\n for (let i = 0; i < 10; i++) {\r\n caracter = valueAux.charAt(i);\r\n\r\n numero = Number(caracter);\r\n\r\n somatorio = somatorio + numero * j;\r\n\r\n j--;\r\n }\r\n\r\n resto = somatorio % 11;\r\n\r\n digito2 = 11 - resto;\r\n\r\n if (digito2 > 9) {\r\n digito2 = 0;\r\n }\r\n\r\n valueAux = valueAux + digito2;\r\n\r\n if (value !== valueAux) {\r\n return false;\r\n } else {\r\n return true;\r\n }\r\n }\r\n\r\n private readonly value: string;\r\n\r\n constructor(value: string) {\r\n if (SocialNumber.isValid(value)) {\r\n this.value = value.trim().replace(/[./-]/g, \"\");\r\n } else {\r\n throw Error(\"CPF inválido\");\r\n }\r\n }\r\n\r\n public getValue(): string {\r\n return this.value;\r\n }\r\n\r\n public getMaskedValue(): string {\r\n return Masks.socialNumberMask(this.value);\r\n }\r\n}\r\n","import { SocialNumber } from \"src/app/ui/models/domains/pbm/social-number.model\";\r\nimport { FederalRegistration } from \"src/app/ui/models/domains/pbm/companies/federal-registration\";\r\nimport { ValidationResult } from \"src/app/ui/models/domains/validator/validation-result\";\r\nimport { UntypedFormGroup } from \"@angular/forms\";\r\n\r\nexport class ContactValidator {\r\n private validationResult = new ValidationResult();\r\n\r\n public getValidationResult(): ValidationResult {\r\n return this.validationResult;\r\n }\r\n\r\n public validate(companyContactForm: UntypedFormGroup) {\r\n if (!companyContactForm.get(\"name\").value) {\r\n this.validationResult.addErrorMessage('Campo \"Nome\" é obrigatório');\r\n } else if (!companyContactForm.get(\"jobDescription\").value) {\r\n this.validationResult.addErrorMessage('Campo \"Cargo\" é obrigatório');\r\n } else if (!companyContactForm.get(\"telephone\").value && !companyContactForm.get(\"mobile\").value) {\r\n this.validationResult.addErrorMessage(\"É obrigatório ao menos um número de contato (telefone ou celular)\");\r\n } else if (!companyContactForm.get(\"email\").value) {\r\n this.validationResult.addErrorMessage('Campo \"Email\" é obrigatório');\r\n } else if (companyContactForm.get(\"hasLegalRepresentativeInfo\").value) {\r\n if (!companyContactForm.get(\"federalRegistration\").value && !FederalRegistration.isValid(companyContactForm.get(\"federalRegistration\").value)) {\r\n this.validationResult.addErrorMessage(\"RG inválido\");\r\n } else if (!companyContactForm.get(\"socialNumber\").value && !SocialNumber.isValid(companyContactForm.get(\"socialNumber\").value)) {\r\n this.validationResult.addErrorMessage(\"CPF inválido\");\r\n }\r\n }\r\n\r\n return this.validationResult;\r\n }\r\n}\r\n","import { CompanyContact } from \"./company-contact\";\r\nimport { FederalRegistration } from \"./federal-registration\";\r\nimport { SocialNumber } from \"./social-number\";\r\nimport { UntypedFormGroup } from \"@angular/forms\";\r\nimport { JobDescription } from \"../Beneficiary/job-description\";\r\n\r\ninterface ICompanyContactHandler {\r\n handleFormToCompanyContact(companyContactForm: UntypedFormGroup): CompanyContact;\r\n handleCompanyContactToForm(companyContact: CompanyContact, jobDescriptionList: JobDescription[]): void;\r\n}\r\n\r\nexport class CompanyContactHandler implements ICompanyContactHandler {\r\n constructor(private companyContactForm: UntypedFormGroup) {}\r\n\r\n handleFormToCompanyContact(): CompanyContact {\r\n const companyContact = new CompanyContact();\r\n\r\n companyContact.setCompanyContactKey(this.companyContactForm.get(\"companyContactKey\").value);\r\n companyContact.setCompanyFiscalNumber(this.companyContactForm.get(\"companyFiscalNumber\").value);\r\n companyContact.setUnit(this.companyContactForm.get(\"unit\").value);\r\n companyContact.setName(this.companyContactForm.get(\"name\").value);\r\n companyContact.setJobDescription(this.companyContactForm.get(\"jobDescription\").value);\r\n companyContact.setTelephone(\r\n !!this.companyContactForm.get(\"telephone\").value ? this.companyContactForm.get(\"telephone\").value.replace(/[^\\d]+/g, \"\") : null,\r\n );\r\n companyContact.setMobile(!!this.companyContactForm.get(\"mobile\").value ? this.companyContactForm.get(\"mobile\").value.replace(/[^\\d]+/g, \"\") : null);\r\n companyContact.setEmail(this.companyContactForm.get(\"email\").value);\r\n companyContact.setArea(this.companyContactForm.get(\"area\").value);\r\n companyContact.setAdditionalInformation(this.companyContactForm.get(\"additionalInformation\").value);\r\n companyContact.setHasLegalRepresentativeInfo(this.companyContactForm.get(\"hasLegalRepresentativeInfo\").value);\r\n companyContact.setFederalRegistration(\r\n new FederalRegistration(\r\n !!this.companyContactForm.get(\"federalRegistration\").value ? this.companyContactForm.get(\"federalRegistration\").value.replace(/[^\\d]+/g, \"\") : \"\",\r\n ),\r\n );\r\n companyContact.setSocialNumber(\r\n new SocialNumber(!!this.companyContactForm.get(\"socialNumber\").value ? this.companyContactForm.get(\"socialNumber\").value.replace(/[^\\d]+/g, \"\") : \"\"),\r\n );\r\n\r\n return companyContact;\r\n }\r\n\r\n handleCompanyContactToForm(companyContact: CompanyContact, jobDescriptionList: JobDescription[]): void {\r\n const jobDescription = companyContact.getJobDescription()\r\n ? jobDescriptionList.find((jd) => jd.getKey() === companyContact.getJobDescription().getKey())\r\n : null;\r\n\r\n this.companyContactForm.patchValue({\r\n companyContactKey: companyContact.getCompanyContactKey(),\r\n companyFiscalNumber: companyContact.getCompanyFiscalNumber(),\r\n name: companyContact.getName(),\r\n unit: companyContact.getUnit(),\r\n jobDescription,\r\n telephone: companyContact.getTelephone(),\r\n mobile: companyContact.getMobile(),\r\n email: companyContact.getEmail(),\r\n area: companyContact.getArea(),\r\n additionalInformation: companyContact.getAdditionalInformation(),\r\n hasLegalRepresentativeInfo: companyContact.getHasLegalRepresentativeInfo(),\r\n federalRegistration: companyContact.getFederalRegistration(),\r\n socialNumber: companyContact.getSocialNumber(),\r\n });\r\n }\r\n}\r\n","import { Component, OnInit, Output, EventEmitter, Inject } from \"@angular/core\";\r\nimport { UntypedFormBuilder, UntypedFormGroup } from \"@angular/forms\";\r\nimport { LoadingService } from \"src/app/ui/services/loading.service\";\r\nimport { AlertService } from \"src/app/ui/services/alert.service\";\r\nimport { FormDirty } from \"src/app/ui/models/utils/form-dirty.utils\";\r\nimport { ContactValidator } from \"../validators/contact-validator\";\r\nimport { CompanyContactHandler } from \"src/app/ui/models/domains/pbm/companies/company-contact-handler\";\r\nimport { CompanyService } from \"src/app/ui/services/pbm/company.service\";\r\nimport { CompanyContact } from \"src/app/ui/models/domains/pbm/companies/company-contact\";\r\nimport { MaskInput } from \"src/app/ui/models/domains/masks/mask.model\";\r\nimport { UserPermissions } from \"./../../../../models/domains/pbm/user/user-permissions\";\r\nimport { UserService } from \"src/app/ui/services/user.service\";\r\nimport { JobDescriptionService } from \"src/app/ui/services/pbm/job-description.service\";\r\nimport { JobDescription } from \"src/app/ui/models/domains/pbm/Beneficiary/job-description\";\r\nimport { MAT_DIALOG_DATA, MatDialogRef } from \"@angular/material/dialog\";\r\n\r\n@Component({\r\n selector: \"company-contact-dialog\",\r\n templateUrl: \"./company-contact-dialog.component.html\",\r\n styleUrls: [\"./company-contact-dialog.component.scss\"],\r\n})\r\nexport class CompanyContactDialogComponent implements OnInit {\r\n @Output() saveContact: EventEmitter = new EventEmitter();\r\n @Output() editContact: EventEmitter = new EventEmitter();\r\n\r\n private formDirty: FormDirty;\r\n private jobDescriptionList: JobDescription[];\r\n\r\n telephoneMask = MaskInput.getTelephoneMask();\r\n mobileMask = MaskInput.getMobileMask();\r\n federalRegistrationMask = MaskInput.getFederalRegistrationMask();\r\n socialNumberMask = MaskInput.getSocialNumberMask();\r\n\r\n public companyContactForm: UntypedFormGroup = this.formBuilder.group({\r\n companyContactKey: [\"\"],\r\n companyFiscalNumber: [\"\"],\r\n name: [\"\"],\r\n unit: [\"\"],\r\n jobDescription: [\"\"],\r\n telephone: [\"\"],\r\n mobile: [\"\"],\r\n email: [\"\"],\r\n area: [\"\"],\r\n additionalInformation: [\"\"],\r\n hasLegalRepresentativeInfo: [false],\r\n federalRegistration: [\"\"],\r\n socialNumber: [\"\"],\r\n });\r\n\r\n constructor(\r\n @Inject(MAT_DIALOG_DATA) public data: CompanyContact,\r\n private formBuilder: UntypedFormBuilder,\r\n private dialogRef: MatDialogRef,\r\n private loadingService: LoadingService,\r\n private alertService: AlertService,\r\n private companyService: CompanyService,\r\n private userService: UserService,\r\n private jobDescriptionService: JobDescriptionService,\r\n ) {\r\n this.formDirty = new FormDirty();\r\n }\r\n\r\n async ngOnInit() {\r\n const ref = this.loadingService.beginLoading();\r\n this.companyContactForm.patchValue({ companyFiscalNumber: this.data.getCompanyFiscalNumber() });\r\n this.jobDescriptionList = await this.jobDescriptionService.getJobDescription(this.data.getCompanyFiscalNumber());\r\n if (this.data.getCompanyContactKey() !== \"\") this.patchForm(this.data);\r\n this.formDirty.markAsClean();\r\n this.loadingService.finishLoading(ref);\r\n }\r\n\r\n patchForm(companyContact: CompanyContact): void {\r\n const companyContacHandler = new CompanyContactHandler(this.companyContactForm);\r\n companyContacHandler.handleCompanyContactToForm(companyContact, this.jobDescriptionList);\r\n }\r\n\r\n async onSaveContact() {\r\n const ref = this.loadingService.beginLoading();\r\n const contactValidator = new ContactValidator();\r\n\r\n if (contactValidator.validate(this.companyContactForm).hasErrorMessages()) {\r\n this.showErrorMessage(contactValidator.getValidationResult().getErrorMessage());\r\n this.loadingService.finishLoading(ref);\r\n } else {\r\n const companyContacHandler = new CompanyContactHandler(this.companyContactForm);\r\n const companyContact = companyContacHandler.handleFormToCompanyContact();\r\n try {\r\n await this.companyService.addCompanyContact(companyContact);\r\n this.saveContact.emit();\r\n this.formDirty.markAsClean();\r\n this.close();\r\n } catch (error) {\r\n this.showErrorMessage(error);\r\n } finally {\r\n this.loadingService.finishLoading(ref);\r\n }\r\n }\r\n }\r\n\r\n async onEditContact() {\r\n const ref = this.loadingService.beginLoading();\r\n\r\n const contactValidator = new ContactValidator();\r\n\r\n if (contactValidator.validate(this.companyContactForm).hasErrorMessages()) {\r\n this.showErrorMessage(contactValidator.getValidationResult().getErrorMessage());\r\n\r\n this.loadingService.finishLoading(ref);\r\n } else {\r\n const companyContacHandler = new CompanyContactHandler(this.companyContactForm);\r\n\r\n const companyContact = companyContacHandler.handleFormToCompanyContact();\r\n\r\n try {\r\n await this.companyService.editCompanyContact(companyContact);\r\n\r\n this.editContact.emit();\r\n\r\n this.formDirty.markAsClean();\r\n\r\n this.close();\r\n } catch (error) {\r\n this.showErrorMessage(error);\r\n } finally {\r\n this.loadingService.finishLoading(ref);\r\n }\r\n }\r\n }\r\n\r\n showErrorMessage(errorMessage: string): void {\r\n this.alertService.onlyOneError(errorMessage, true, \"alert-modal\");\r\n }\r\n\r\n onContactInputChange(): void {\r\n this.formDirty.markAsDirty();\r\n }\r\n\r\n isNewContact(): boolean {\r\n return !this.data.getCompanyContactKey();\r\n }\r\n\r\n markAsDirty(): void {\r\n this.formDirty.markAsDirty();\r\n }\r\n\r\n close(): void {\r\n if (this.formDirty.isDirty()) {\r\n const exitWithoutSave = confirm(\"Os dados foram alterados no formulário. Deseja sair sem salvar?\");\r\n\r\n if (exitWithoutSave) this.dialogRef.close();\r\n } else this.dialogRef.close();\r\n }\r\n\r\n hasAccessToEditCompany(): boolean {\r\n return this.userService.getLoggedUser().hasPermission(UserPermissions.EditCompany);\r\n }\r\n\r\n public getJobDescriptionList(): JobDescription[] {\r\n return this.jobDescriptionList;\r\n }\r\n\r\n hasMobile(): boolean {\r\n return !!this.companyContactForm.get(\"mobile\").value;\r\n }\r\n\r\n hasTelephone(): boolean {\r\n return !!this.companyContactForm.get(\"telephone\").value;\r\n }\r\n}\r\n","
\r\n
\r\n edit_note\r\n

{{ isNewContact() ? 'Cadastro de Contato' : hasAccessToEditCompany() ? 'Edição Contato' : 'Contato' }}

\r\n
\r\n
\r\n\r\n
\r\n \r\n\r\n
\r\n
\r\n \r\n Unidade\r\n \r\n \r\n\r\n \r\n Nome *\r\n \r\n \r\n\r\n \r\n Cargo *\r\n \r\n {{ jobDescription.getTitle() }}\r\n \r\n \r\n\r\n \r\n {{ hasMobile() ? 'Telefone' : 'Telefone *' }}\r\n \r\n \r\n\r\n \r\n {{ hasTelephone() ? 'Celular' : 'Celular *' }}\r\n \r\n \r\n\r\n \r\n E-mail *\r\n \r\n \r\n\r\n \r\n Área\r\n \r\n \r\n\r\n \r\n Informações Adicionais\r\n \r\n \r\n\r\n Responsável Legal\r\n
\r\n\r\n
\r\n \r\n RG *\r\n \r\n \r\n\r\n \r\n CPF *\r\n \r\n \r\n
\r\n
\r\n

Campos marcados com * são obrigatórios

\r\n
\r\n\r\n
\r\n
\r\n Fechar\r\n
\r\n\r\n
\r\n
\r\n Salvar\r\n
\r\n\r\n
\r\n Salvar\r\n
\r\n
\r\n
\r\n","import { Company } from \"./company\";\r\nimport { UntypedFormGroup } from \"@angular/forms\";\r\nimport { CompanyInfo } from \"./company-info\";\r\nimport { Address } from \"./address\";\r\nimport { CompanyKey } from \"./company-key\";\r\n\r\ninterface ICompanyHandler {\r\n handleFormToCompany(): Company;\r\n handleCompanyToForm(company: Company): void;\r\n}\r\n\r\nexport class CompanyHandler implements ICompanyHandler {\r\n constructor(private formCompanyRegistration: UntypedFormGroup) {}\r\n\r\n handleFormToCompany(): Company {\r\n const company = new Company();\r\n const companyInfo = new CompanyInfo();\r\n const address = new Address();\r\n const companyKey = new CompanyKey();\r\n\r\n companyKey.setCompanyKey(this.formCompanyRegistration.value.companyKey);\r\n\r\n company.setCompanyKey(companyKey);\r\n company.setUnit(this.formCompanyRegistration.value.unit);\r\n company.setCompanyType(this.formCompanyRegistration.value.companyType);\r\n company.setHeadOfficeFiscalNumber(\r\n !!this.formCompanyRegistration.value.headOfficeFiscalNumber ? this.formCompanyRegistration.value.headOfficeFiscalNumber.replace(/[^\\d]+/g, \"\") : null,\r\n );\r\n company.setFiscalNumber(!!this.formCompanyRegistration.value.fiscalNumber ? this.formCompanyRegistration.value.fiscalNumber.replace(/[^\\d]+/g, \"\") : null);\r\n company.setStateRegistration(this.formCompanyRegistration.value.stateRegistration);\r\n company.setMunicipalRegistration(this.formCompanyRegistration.value.municipalRegistration);\r\n company.setCorporateName(this.formCompanyRegistration.value.corporateName);\r\n company.setTradingName(this.formCompanyRegistration.value.tradingName);\r\n company.setIsActive(this.formCompanyRegistration.value.isActive);\r\n\r\n address.setStreet(this.formCompanyRegistration.value.street);\r\n address.setNumber(this.formCompanyRegistration.value.number);\r\n address.setComplement(this.formCompanyRegistration.value.complement);\r\n address.setDistrict(this.formCompanyRegistration.value.district);\r\n address.setCity(this.formCompanyRegistration.value.city);\r\n address.setRegion(this.formCompanyRegistration.value.region);\r\n address.setZipCode(!!this.formCompanyRegistration.value.zipCode ? this.formCompanyRegistration.value.zipCode.replace(/[^\\d]+/g, \"\") : null);\r\n companyInfo.setAddress(address);\r\n\r\n try{\r\n companyInfo.setEmployeeCount(parseInt(this.formCompanyRegistration.value.employeeCount));\r\n }catch{\r\n companyInfo.setEmployeeCount(0);\r\n }\r\n\r\n company.setCompanyInfo(companyInfo);\r\n\r\n return company;\r\n }\r\n\r\n handleCompanyToForm(company: Company): void {\r\n this.formCompanyRegistration.patchValue({\r\n companyKey: company.getCompanyKey().getCompanyKey(),\r\n unit: company.getUnit(),\r\n companyType: company.getCompanyType(),\r\n headOfficeFiscalNumber: company.getHeadOfficeFiscalNumber(),\r\n fiscalNumber: company.getFiscalNumber(),\r\n stateRegistration: company.getStateRegistration(),\r\n municipalRegistration: company.getMunicipalRegistration(),\r\n corporateName: company.getCorporateName(),\r\n tradingName: company.getTradingName(),\r\n street: company.getCompanyInfo().getAddress().getStreet(),\r\n number: company.getCompanyInfo().getAddress().getNumber(),\r\n complement: company.getCompanyInfo().getAddress().getComplement(),\r\n district: company.getCompanyInfo().getAddress().getDistrict(),\r\n city: company.getCompanyInfo().getAddress().getCity(),\r\n region: company.getCompanyInfo().getAddress().getRegion(),\r\n zipCode: company.getCompanyInfo().getAddress().getZipCode(),\r\n employeeCount: company.getCompanyInfo().getEmployeeCount(),\r\n isActive: company.getIsActive(),\r\n });\r\n }\r\n}\r\n","import { CompanyConfigurationHandler } from \"./../../../../models/domains/pbm/companies/company-configuration-handler\";\r\nimport { Component, OnInit } from \"@angular/core\";\r\nimport { UntypedFormControl, Validators, UntypedFormGroup, UntypedFormBuilder } from \"@angular/forms\";\r\nimport { ActivatedRoute, Router } from \"@angular/router\";\r\n\r\nimport { CompanyService } from \"src/app/ui/services/pbm/company.service\";\r\nimport { Company } from \"src/app/ui/models/domains/pbm/companies/company\";\r\nimport { CompanyContact } from \"src/app/ui/models/domains/pbm/companies/company-contact\";\r\nimport { MaskInput } from \"src/app/ui/models/domains/masks/mask.model\";\r\nimport { ModalService } from \"src/app/ui/services/modal.service\";\r\nimport { DeleteContactDialogComponent } from \"../delete-contact-dialog/delete-contact-dialog.component\";\r\nimport { LoadingService } from \"src/app/ui/services/loading.service\";\r\nimport { FeatureViewService } from \"src/app/ui/services/feature-view.service\";\r\nimport { FeatureViews } from \"src/app/ui/models/domains/features/custom-feature-views\";\r\nimport { PageViews } from \"src/app/ui/models/domains/features/custom-page-views\";\r\nimport { Toast } from \"../../../toast/toast\";\r\nimport { CompanyValidator } from \"../validators/company-validator\";\r\nimport { CompanyContactDialogComponent } from \"../company-contact-dialog/company-contact-dialog.component\";\r\nimport { CompanyHandler } from \"src/app/ui/models/domains/pbm/companies/company-handler\";\r\nimport { UserPermissions } from \"./../../../../models/domains/pbm/user/user-permissions\";\r\nimport { UserService } from \"src/app/ui/services/user.service\";\r\nimport { RoutePath } from \"src/app/ui/models/domains/route-paths.model\";\r\nimport { AppContext } from \"src/app/ui/contexts/app-context\";\r\nimport { CompanyConfiguration } from \"src/app/ui/models/domains/pbm/companies/company-configuration\";\r\nimport { CompanyRemainingLimit } from \"src/app/ui/models/domains/pbm/companies/company-remaining-limit\";\r\nimport { MatDialogRef, MatDialog } from \"@angular/material/dialog\";\r\n\r\n@Component({\r\n selector: \"edit-company\",\r\n templateUrl: \"./edit-company.component.html\",\r\n styleUrls: [\"./edit-company.component.scss\"],\r\n})\r\nexport class EditCompanyComponent implements OnInit {\r\n telephoneMask = MaskInput.getTelephoneMask();\r\n mobileMask = MaskInput.getMobileMask();\r\n fiscalNumberMask = MaskInput.getFicalNumberMask();\r\n zipCodeMask = MaskInput.getZipCodeMask();\r\n federalRegistrationMask = MaskInput.getFederalRegistrationMask();\r\n socialNumberMask = MaskInput.getSocialNumberMask();\r\n companyHasLimit: boolean = false;\r\n transactionalLimit: Number;\r\n\r\n company: Company = new Company();\r\n companyRemainingLimit: CompanyRemainingLimit = new CompanyRemainingLimit();\r\n companyConfigurations: CompanyConfiguration = new CompanyConfiguration();\r\n\r\n companyContactDialogRef: MatDialogRef;\r\n deleteContactDialogRef: MatDialogRef;\r\n\r\n formCompanyRegistration: UntypedFormGroup;\r\n formCompanyConfiguration: UntypedFormGroup;\r\n fiscalNumber = this.activatedRoute.snapshot.params.fiscalNumber;\r\n\r\n constructor(\r\n private formBuilder: UntypedFormBuilder,\r\n private loadingService: LoadingService,\r\n private featureViewService: FeatureViewService,\r\n private companyService: CompanyService,\r\n private activatedRoute: ActivatedRoute,\r\n private dialog: MatDialog,\r\n private modalService: ModalService,\r\n private toast: Toast,\r\n private context: AppContext,\r\n private userService: UserService,\r\n private router: Router,\r\n ) {}\r\n\r\n async ngOnInit() {\r\n this.featureViewService.activeFeatureView(FeatureViews.CompanyEditFeatureView, PageViews.CompanyPageView);\r\n this.formCompanyRegistration = this.formBuilder.group({\r\n companyKey: new UntypedFormControl(\"\"),\r\n unit: new UntypedFormControl(\"\", Validators.required),\r\n companyType: new UntypedFormControl(\"\"),\r\n headOfficeFiscalNumber: new UntypedFormControl(\"\", Validators.required),\r\n fiscalNumber: new UntypedFormControl(\"\", Validators.required),\r\n stateRegistration: new UntypedFormControl(\"\"),\r\n municipalRegistration: new UntypedFormControl(\"\"),\r\n corporateName: new UntypedFormControl(\"\", Validators.required),\r\n tradingName: new UntypedFormControl(\"\"),\r\n street: new UntypedFormControl(\"\", Validators.required),\r\n number: new UntypedFormControl(\"\", Validators.required),\r\n complement: new UntypedFormControl(\"\"),\r\n district: new UntypedFormControl(\"\", Validators.required),\r\n city: new UntypedFormControl(\"\", Validators.required),\r\n region: new UntypedFormControl(\"\", Validators.required),\r\n zipCode: new UntypedFormControl(\"\", Validators.required),\r\n employeeCount: new UntypedFormControl(0, [Validators.required]),\r\n isActive: new UntypedFormControl(false),\r\n });\r\n\r\n this.formCompanyConfiguration = this.formBuilder.group({\r\n transactionalLimit: new UntypedFormControl(\"\"),\r\n currentLimit: new UntypedFormControl(\"\"),\r\n });\r\n\r\n await this.searchCompany(this.fiscalNumber);\r\n }\r\n\r\n async searchCompany(fiscalNumber: string) {\r\n const ref = this.loadingService.beginLoading();\r\n const companyHandler = new CompanyHandler(this.formCompanyRegistration);\r\n const companyConfigurationHandler = new CompanyConfigurationHandler(this.formCompanyConfiguration);\r\n try {\r\n this.company = await this.companyService.findCompanyBy(fiscalNumber);\r\n if (this.company) {\r\n companyHandler.handleCompanyToForm(this.company);\r\n this.companyConfigurations = await this.getCompanyConfigurations();\r\n if (this.companyConfigurations) {\r\n companyConfigurationHandler.handleCompanyConfigurationToForm(this.companyConfigurations);\r\n this.companyHasLimit = this.companyConfigurations.isHasTransactionalLimit();\r\n }\r\n this.companyRemainingLimit = await this.companyService.getCompanyRemainingLimit(fiscalNumber);\r\n } else this.router.navigate([RoutePath.SearchCompany]);\r\n } catch (error) {\r\n this.toast.showWarningToast(error);\r\n this.router.navigate([RoutePath.SearchCompany]);\r\n this.userService.setUserPreferences(\"\");\r\n } finally {\r\n this.loadingService.finishLoading(ref);\r\n }\r\n }\r\n\r\n getCompanyContacts(): CompanyContact[] {\r\n return this.company.getCompanyContacts();\r\n }\r\n\r\n async getCompanyConfigurations(): Promise {\r\n try {\r\n return await this.companyService.companyConfigurations(this.fiscalNumber);\r\n } catch (error) {\r\n this.toast.showWarningToast(error);\r\n }\r\n }\r\n\r\n openContactRegistration() {\r\n const newCompanyContact = new CompanyContact();\r\n newCompanyContact.setCompanyFiscalNumber(this.company.getFiscalNumber());\r\n this.companyContactDialogRef = this.dialog.open(CompanyContactDialogComponent, {\r\n disableClose: true,\r\n hasBackdrop: true,\r\n width: \"700px\",\r\n height: \"auto\",\r\n data: newCompanyContact,\r\n });\r\n this.companyContactDialogRef.componentInstance.saveContact.subscribe(async (data) => {\r\n this.company = await this.companyService.findCompanyBy(this.formCompanyRegistration.value.fiscalNumber.replace(/[./-]/g, \"\"));\r\n this.toast.showSuccessToast(\"Contato salvo com sucesso\");\r\n });\r\n }\r\n\r\n openContactEdit(contact: CompanyContact): void {\r\n contact.setCompanyFiscalNumber(this.company.getFiscalNumber());\r\n this.companyContactDialogRef = this.dialog.open(CompanyContactDialogComponent, {\r\n disableClose: true,\r\n hasBackdrop: true,\r\n width: \"700px\",\r\n height: \"auto\",\r\n data: contact,\r\n });\r\n this.companyContactDialogRef.componentInstance.editContact.subscribe(async (data) => {\r\n this.company = await this.companyService.findCompanyBy(this.formCompanyRegistration.value.fiscalNumber.replace(/[./-]/g, \"\"));\r\n this.toast.showSuccessToast(\"Contato salvo com sucesso\");\r\n });\r\n }\r\n\r\n openDeleteContactModal(contact: CompanyContact): void {\r\n this.deleteContactDialogRef = this.dialog.open(DeleteContactDialogComponent, {\r\n height: \"auto\",\r\n hasBackdrop: true,\r\n disableClose: true,\r\n });\r\n this.deleteContactDialogRef.componentInstance.delete.subscribe((data) => this.deleteContact(contact));\r\n }\r\n\r\n private async deleteContact(contact: CompanyContact) {\r\n const ref = this.loadingService.beginLoading();\r\n const companyContactKey = contact.getCompanyContactKey();\r\n try {\r\n await this.companyService.deleteCompanyContact(companyContactKey);\r\n const companyContactList = await this.companyService.findContactBy(this.formCompanyRegistration.value.fiscalNumber.replace(/[./-]/g, \"\"));\r\n this.company.setCompanyContacts(companyContactList);\r\n this.deleteContactDialogRef.close();\r\n this.toast.showSuccessToast(\"Contato deletado com sucesso\");\r\n } catch (error) {\r\n this.modalService.showErrorMessage(error);\r\n } finally {\r\n this.loadingService.finishLoading(ref);\r\n }\r\n }\r\n\r\n async submitCompanyData() {\r\n const ref = this.loadingService.beginLoading();\r\n const companyValidator = new CompanyValidator();\r\n if (companyValidator.validate(this.formCompanyRegistration).hasErrorMessages()) {\r\n this.toast.showWarningToast(companyValidator.getValidationResult().getErrorMessage());\r\n this.loadingService.finishLoading(ref);\r\n } else {\r\n const companyHandler = new CompanyHandler(this.formCompanyRegistration);\r\n const company = companyHandler.handleFormToCompany();\r\n try {\r\n const companyKey = await this.companyService.addCompany(company);\r\n this.formCompanyRegistration.patchValue({ companyKey });\r\n this.company = await this.companyService.findCompanyBy(company.getFiscalNumber());\r\n this.toast.showSuccessToast(\"Empresa salva com sucesso\");\r\n } catch (error) {\r\n this.toast.showWarningToast(error);\r\n } finally {\r\n this.loadingService.finishLoading(ref);\r\n }\r\n }\r\n }\r\n\r\n async submitCompanyConfigurationData() {\r\n const ref = this.loadingService.beginLoading();\r\n if (this.companyHasLimit == false) {\r\n this.formCompanyConfiguration.value.transactionalLimit = 0;\r\n }\r\n\r\n try {\r\n if (this.formCompanyConfiguration.value.transactionalLimit > 50000.0) {\r\n this.toast.showWarningToast(\"Valor informado maior que R$ 50.000,00\");\r\n } else if (this.companyHasLimit == true && this.formCompanyConfiguration.value.transactionalLimit < 1.0) {\r\n this.toast.showWarningToast(\"Valor do limite inválido\");\r\n } else {\r\n const companyExistance = await this.hasCompanyConfigurations();\r\n if (companyExistance) {\r\n await this.companyService.updateCompanyConfigurations(this.fiscalNumber, this.formCompanyConfiguration.value.transactionalLimit);\r\n } else {\r\n await this.companyService.createCompanyConfigurations(this.fiscalNumber, this.formCompanyConfiguration.value.transactionalLimit);\r\n }\r\n this.formCompanyConfiguration.value.transactionalLimit;\r\n this.toast.showSuccessToast(\"Configuração salva com sucesso\");\r\n }\r\n } catch (error) {\r\n this.toast.showWarningToast(error);\r\n } finally {\r\n this.loadingService.finishLoading(ref);\r\n }\r\n }\r\n\r\n async hasCompanyConfigurations() {\r\n try {\r\n const companyExistance = await this.companyService.companyConfigurations(this.fiscalNumber);\r\n if (companyExistance) {\r\n return true;\r\n }\r\n return false;\r\n } catch {\r\n return false;\r\n }\r\n }\r\n\r\n useDataQuality(): boolean {\r\n return this.context.getCurrentTenant().useDataQuality;\r\n }\r\n\r\n hasAccessToEditCompany(): boolean {\r\n return this.userService.getLoggedUser().hasPermission(UserPermissions.EditCompany);\r\n }\r\n\r\n public backToSearchCompanies(): void {\r\n this.router.navigate([RoutePath.SearchCompany]);\r\n }\r\n}\r\n","\r\n \r\n
\r\n
\r\n

Dados Cadastrais:

\r\n\r\n Inativar empresa\r\n
\r\n
\r\n \r\n Razão Social\r\n \r\n lock\r\n \r\n\r\n \r\n Nome Fantasia\r\n \r\n lock\r\n \r\n
\r\n\r\n
\r\n \r\n Tipo de Empresa\r\n \r\n Matriz\r\n Filial\r\n \r\n \r\n\r\n \r\n Unidade\r\n \r\n \r\n\r\n \r\n CNPJ da Unidade\r\n \r\n lock\r\n \r\n\r\n \r\n N° de Vidas\r\n \r\n \r\n
\r\n\r\n
\r\n \r\n CNPJ da Matriz\r\n \r\n \r\n\r\n \r\n Inscrição Estadual\r\n \r\n \r\n \r\n Inscrição Municipal\r\n \r\n \r\n
\r\n\r\n
\r\n \r\n Endereço\r\n \r\n lock\r\n \r\n\r\n \r\n Número\r\n \r\n lock\r\n \r\n\r\n \r\n Complemento\r\n \r\n lock\r\n \r\n
\r\n\r\n
\r\n \r\n Bairro\r\n \r\n lock\r\n \r\n\r\n \r\n Cidade\r\n \r\n lock\r\n \r\n\r\n \r\n UF\r\n \r\n lock\r\n \r\n\r\n \r\n CEP\r\n \r\n lock\r\n \r\n
\r\n
\r\n
\r\n \r\n \r\n
\r\n
\r\n\r\n \r\n
\r\n

Contatos Cadastrados: {{ getCompanyContacts()?.length }}

\r\n\r\n
\r\n REGISTRAR CONTATO\r\n
\r\n
\r\n
\r\n
\r\n
\r\n {{ contact.getName() }}\r\n
\r\n
\r\n
\r\n Unidade:{{ contact.getUnit() ? contact.getUnit() : \"-\" }}\r\n
\r\n
\r\n Cargo:{{ contact.getJobDescription() ? contact.getJobDescription().getTitle() : \"-\" }}\r\n
\r\n
\r\n Área:{{ contact.getArea() ? contact.getArea() : \"-\" }}\r\n
\r\n
\r\n\r\n
\r\n
\r\n Telefone:{{ contact.getTelephone() ? (contact.getTelephone()| mobileFormatPipe:false) : \"-\" }}\r\n
\r\n
\r\n Celular:{{ contact.getMobile() ? (contact.getMobile()| mobileFormatPipe) : \"-\" }}\r\n
\r\n
\r\n E-mail:{{ contact.getEmail() ? contact.getEmail() : \"-\" }}\r\n
\r\n
\r\n\r\n
\r\n
\r\n Resp. Legal:{{ contact.getHasLegalRepresentativeInfo() === true ? \"Sim\" : \"Não\" }}\r\n
\r\n
\r\n RG:{{ contact.getFederalRegistration() ? (contact.getFederalRegistration() | registroGeralPipe) : \"-\" }}\r\n
\r\n
\r\n CPF:{{ contact.getSocialNumber() ? (contact.getSocialNumber() | socialNumberFormatPipe) : \"-\" }}\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n edit_note\r\n {{ hasAccessToEditCompany() ? \"EDITAR\" : \"VISUALIZAR\" }}\r\n
\r\n\r\n
\r\n delete\r\n DELETAR\r\n
\r\n
\r\n
\r\n
\r\n
\r\n \r\n
\r\n
\r\n \r\n \r\n {{ \"Sem Limite\" | uppercase }}\r\n \r\n\r\n \r\n {{ \"Limite para próximo ciclo:\" | uppercase }}\r\n \r\n Limite\r\n   R$  \r\n \r\n \r\n \r\n \r\n
\r\n\r\n
\r\n SALDO DISPONÍVEL:\r\n
\r\n  \r\n {{ companyRemainingLimit.getRemainingLimitValue() | currencyPbmPipe }} \r\n
\r\n
\r\n \r\n
\r\n \r\n
\r\n
\r\n
\r\n
\r\n","import { Component, OnInit, Output, EventEmitter, Inject } from \"@angular/core\";\r\nimport { UntypedFormBuilder, UntypedFormGroup } from \"@angular/forms\";\r\n\r\nimport { CompanyMasterData } from \"src/app/ui/models/domains/pbm/companies/company-master-data\";\r\nimport { MaskInput } from \"src/app/ui/models/domains/masks/mask.model\";\r\nimport { CompanyService } from \"src/app/ui/services/pbm/company.service\";\r\nimport { LoadingService } from \"src/app/ui/services/loading.service\";\r\nimport { FiscalNumber } from \"src/app/ui/models/domains/pbm/fiscal-number\";\r\nimport { MatDialogRef, MAT_DIALOG_DATA } from \"@angular/material/dialog\";\r\n\r\n@Component({\r\n selector: \"company-master-data-dialog\",\r\n templateUrl: \"./company-master-data-dialog.component.html\",\r\n styleUrls: [\"./company-master-data-dialog.component.scss\"],\r\n})\r\nexport class CompanyMasterDataDialogComponent implements OnInit {\r\n @Output() use: EventEmitter = new EventEmitter();\r\n\r\n fiscalNumberMask = MaskInput.getFicalNumberMask();\r\n zipCodeMask = MaskInput.getZipCodeMask();\r\n\r\n public companyMasterDataForm: UntypedFormGroup = this.formBuilder.group({\r\n fiscalNumber: [this.data.getFiscalNumber()],\r\n corporateName: [this.data.getCorporateName()],\r\n tradingName: [this.data.getTradingName()],\r\n type: [this.data.getType()],\r\n drugFront: [this.data.getDrugFront()],\r\n situation: [this.data.getSituation()],\r\n contract: [this.data.getContract()],\r\n branch: [this.data.getBranch()],\r\n subBranch: [this.data.getSubBranch()],\r\n cluster: [this.data.getCluster()],\r\n street: [this.data.getCompanyInfo().getAddress()[0].getStreet()],\r\n number: [this.data.getCompanyInfo().getAddress()[0].getNumber()],\r\n complement: [this.data.getCompanyInfo().getAddress()[0].getComplement()],\r\n zipCode: [this.data.getCompanyInfo().getAddress()[0].getZipCode()],\r\n district: [this.data.getCompanyInfo().getAddress()[0].getDistrict()],\r\n city: [this.data.getCompanyInfo().getAddress()[0].getCity()],\r\n region: [this.data.getCompanyInfo().getAddress()[0].getState()],\r\n });\r\n\r\n constructor(\r\n private formBuilder: UntypedFormBuilder,\r\n private dialogRef: MatDialogRef,\r\n @Inject(MAT_DIALOG_DATA) public data: CompanyMasterData,\r\n private companyService: CompanyService,\r\n private loadingService: LoadingService,\r\n ) {}\r\n\r\n ngOnInit() {}\r\n\r\n async refreshCompanyMasterData(): Promise {\r\n const ref = this.loadingService.beginLoading();\r\n\r\n try {\r\n const fiscalNumer = new FiscalNumber(this.data.getFiscalNumber());\r\n this.data = await this.companyService.searchCompanyByFicalNumberFromMDM(fiscalNumer);\r\n } catch (error) {\r\n } finally {\r\n this.loadingService.finishLoading(ref);\r\n }\r\n }\r\n\r\n close(): void {\r\n this.dialogRef.close(true);\r\n }\r\n\r\n useCompanyMasterData(): void {\r\n this.use.emit(true);\r\n this.close();\r\n }\r\n}\r\n","
\r\n

Dados da empresa no MDM

\r\n
\r\n\r\n
\r\n
\r\n Atenção! Empresa em processo de aprovação no MDM de empresas.\r\n loop\r\n
\r\n\r\n
\r\n
\r\n \r\n CNPJ\r\n \r\n \r\n\r\n \r\n Razão Social\r\n \r\n \r\n\r\n \r\n Nome Fantasia\r\n \r\n \r\n
\r\n
\r\n \r\n Tipo\r\n \r\n \r\n\r\n \r\n Bandeira\r\n \r\n \r\n\r\n \r\n Situação\r\n \r\n \r\n
\r\n
\r\n \r\n Contrato\r\n \r\n \r\n\r\n \r\n Ramo\r\n \r\n \r\n\r\n \r\n Subramo\r\n \r\n \r\n\r\n \r\n Cluster\r\n \r\n \r\n
\r\n
\r\n\r\n
\r\n
\r\n \r\n Endereço\r\n \r\n \r\n\r\n \r\n Número\r\n \r\n \r\n\r\n \r\n Complemento\r\n \r\n \r\n
\r\n
\r\n \r\n CEP\r\n \r\n \r\n\r\n \r\n Município\r\n \r\n \r\n\r\n \r\n Cidade\r\n \r\n \r\n\r\n \r\n UF\r\n \r\n \r\n
\r\n
\r\n
\r\n\r\n
\r\n
\r\n Fechar\r\n
\r\n\r\n
\r\n Usar dados\r\n
\r\n
\r\n","import { CommonModule } from \"@angular/common\";\r\nimport { Component, Inject, OnInit } from \"@angular/core\";\r\nimport { FormControl, FormControlName, FormGroup, FormsModule, ReactiveFormsModule } from \"@angular/forms\";\r\nimport { MatButtonModule } from \"@angular/material/button\";\r\nimport { MAT_DIALOG_DATA, MatDialogRef } from \"@angular/material/dialog\";\r\nimport { MatFormFieldModule } from \"@angular/material/form-field\";\r\nimport { MatIconModule } from \"@angular/material/icon\";\r\nimport { MatInputModule } from \"@angular/material/input\";\r\nimport { TextMaskModule } from \"src/app/directives/angular2TextMask\";\r\nimport { Toast } from \"src/app/ui/components/toast/toast\";\r\nimport { MaskInput } from \"src/app/ui/models/domains/masks/mask.model\";\r\nimport { BeneficaryTemporaryLimit, Beneficiary } from \"src/app/ui/models/domains/pbm/Beneficiary/beneficiary\";\r\nimport { LoadingService } from \"src/app/ui/services/loading.service\";\r\nimport { BeneficiaryService } from \"src/app/ui/services/pbm/beneficiary.service\";\r\n\r\n@Component({\r\n selector: \"limit-beneficiary-modal\",\r\n templateUrl: \"./limit-beneficiary-modal.component.html\",\r\n styleUrls: [\"./limit-beneficiary-modal.component.scss\"],\r\n standalone: true,\r\n imports: [CommonModule, ReactiveFormsModule, MatFormFieldModule, MatInputModule, MatIconModule, MatButtonModule],\r\n})\r\nexport class LimitBeneficiaryModalComponent implements OnInit {\r\n beneficiary: Beneficiary;\r\n limitConfiguration: BeneficaryTemporaryLimit;\r\n\r\n form = new FormGroup({\r\n newLimitInput: new FormControl(0),\r\n });\r\n\r\n constructor(\r\n private dialogRef: MatDialogRef,\r\n private toast: Toast,\r\n @Inject(MAT_DIALOG_DATA) public data: any,\r\n private beneficiaryService: BeneficiaryService,\r\n private loadingService: LoadingService,\r\n ) {\r\n if (data) {\r\n this.beneficiary = data.beneficiary;\r\n this.form.get(\"newLimitInput\").setValue(this.beneficiary.getLimit());\r\n }\r\n }\r\n\r\n ngOnInit() {}\r\n\r\n close() {\r\n this.toast.showWarningToast(\"As alterações não foram salvas\");\r\n this.dialogRef.close(false);\r\n }\r\n\r\n async saveNewtemporaryLimit() {\r\n const ref = this.loadingService.beginLoading();\r\n try {\r\n this.limitConfiguration = new BeneficaryTemporaryLimit();\r\n this.limitConfiguration.beneficiaryId = this.beneficiary.getBeneficiaryKey().getValue();\r\n this.limitConfiguration.newLimit = this.form.get(\"newLimitInput\").value;\r\n await this.beneficiaryService.beneficiaryTemporaryLimit(this.limitConfiguration);\r\n this.toast.showSuccessToast(\"Limite alterado com sucesso\");\r\n this.dialogRef.close(true);\r\n } catch (error) {\r\n const errorMessage = error.error.Data?.ErrorMessage;\r\n if (!errorMessage) {\r\n this.toast.showWarningToast(\"Erro ao alterar o limite\");\r\n } else {\r\n this.toast.showWarningToast(errorMessage);\r\n }\r\n console.error(error);\r\n } finally {\r\n this.loadingService.finishLoading(ref);\r\n }\r\n }\r\n\r\n inputValidator(event): void {\r\n const input = event.target;\r\n const oldValue = input.value;\r\n const regex = new RegExp(input.pattern, \"g\");\r\n\r\n setTimeout(() => {\r\n const newValue = input.value;\r\n if (!regex.test(newValue)) {\r\n input.value = oldValue;\r\n }\r\n }, 0);\r\n }\r\n\r\n}\r\n","\r\n
\r\n
\r\n

x

\r\n
\r\n
\r\n

\r\n Alterar limite individual do beneficiário\r\n

\r\n
\r\n
\r\n\r\n
\r\n
\r\n

\r\n O beneficiário {{beneficiary.getName()}} está {{beneficiary.isActive() ? \"ATIVO\" : \"INATIVO\"}}. \r\n

\r\n

E possui um limite individual de {{beneficiary.getLimit() | currency:'BRL':'symbol':'1.2-2'}}

\r\n
\r\n
\r\n\r\n\r\n\r\n
\r\n Essa ação promove o ajuste pontual do limite no ciclo atual, para ciclos posteriores a alteração deverá ser no benefício da empresa \r\n \r\n\r\n
\r\n\r\n
\r\n \r\n \r\n Novo limite\r\n R$  \r\n \r\n \r\n
\r\n\r\n\r\n\r\n
\r\n
\r\n \r\n \r\n
\r\n
","import { Component, OnInit } from \"@angular/core\";\r\nimport { Router } from \"@angular/router\";\r\n\r\nimport { FeatureViewService } from \"src/app/ui/services/feature-view.service\";\r\nimport { FeatureViews } from \"src/app/ui/models/domains/features/custom-feature-views\";\r\nimport { PageViews } from \"src/app/ui/models/domains/features/custom-page-views\";\r\nimport { Company } from \"src/app/ui/models/domains/pbm/companies/company\";\r\nimport { LoadingService } from \"src/app/ui/services/loading.service\";\r\nimport { CompanyService } from \"src/app/ui/services/pbm/company.service\";\r\nimport { MaskInput } from \"src/app/ui/models/domains/masks/mask.model\";\r\nimport { BeneficiaryService } from \"src/app/ui/services/pbm/beneficiary.service\";\r\nimport { AppContext } from \"src/app/ui/contexts/app-context\";\r\nimport { PagingRequest } from \"src/app/ui/models/domains/paginator/paging-request\";\r\nimport { RoutePath } from \"src/app/ui/models/domains/route-paths.model\";\r\nimport { Beneficiary } from \"src/app/ui/models/domains/pbm/Beneficiary/beneficiary\";\r\nimport { PageableResult } from \"src/app/ui/models/domains/paginator/pageable-result\";\r\nimport { Toast } from \"../../../toast/toast\";\r\nimport { UserPermissions } from \"./../../../../models/domains/pbm/user/user-permissions\";\r\nimport { UserService } from \"src/app/ui/services/user.service\";\r\nimport { UntypedFormControl } from \"@angular/forms\";\r\nimport { ICompanyFilterParams } from \"src/app/ui/models/domains/pbm/companies/company-filter-params\";\r\nimport { LimitBeneficiaryModalComponent } from \"./limit-beneficiary-modal/limit-beneficiary-modal.component\";\r\nimport { MatDialog } from \"@angular/material/dialog\";\r\n\r\n@Component({\r\n selector: \"search-beneficiary\",\r\n templateUrl: \"./search-beneficiary.component.html\",\r\n styleUrls: [\"./search-beneficiary.component.scss\"],\r\n})\r\nexport class SearchBeneficiaryComponent implements OnInit {\r\n public searchCompanyFirst: boolean;\r\n public pagingRequest = new PagingRequest();\r\n public pageableResult = new PageableResult();\r\n public companyPageableResult = new PageableResult();\r\n public beneficary: Beneficiary;\r\n\r\n private company: Company;\r\n private userProfile = this.userService.getUserProfile();\r\n public filterText: string;\r\n public filter: string;\r\n public fiscalNumberMask = MaskInput.getFicalNumberMask();\r\n public searchType: UntypedFormControl;\r\n public searchStatus: UntypedFormControl;\r\n public statusPreference: number = 3;\r\n\r\n constructor(\r\n private featureViewService: FeatureViewService,\r\n private loadingService: LoadingService,\r\n private companyService: CompanyService,\r\n private beneficiaryService: BeneficiaryService,\r\n private appContext: AppContext,\r\n private toast: Toast,\r\n private router: Router,\r\n private userService: UserService,\r\n private dialog: MatDialog,\r\n ) {\r\n this.searchType = new UntypedFormControl(1);\r\n this.searchStatus = new UntypedFormControl(3);\r\n }\r\n\r\n ngOnInit() {\r\n this.userProfile = this.userService.getUserProfile();\r\n if (this.userProfile.getPreferences().getFilterText()) {\r\n this.searchCompanies(this.userProfile.getPreferences().getFilterText());\r\n } else {\r\n this.searchCompanies(\"\");\r\n }\r\n this.featureViewService.activeFeatureView(FeatureViews.BeneficiarySearchFeatureView, PageViews.BeneficiaryPageView);\r\n }\r\n\r\n hasCompany(): boolean {\r\n return !!this.company;\r\n }\r\n\r\n getCompanies(): Company[] {\r\n return this.companyPageableResult.getItems() as Company[];\r\n }\r\n\r\n onPressEnterSearchCompanies(event): void {\r\n if (event.key === \"Enter\") {\r\n this.statusPreference = this.searchStatus.value;\r\n this.searchCompanies(this.filterText);\r\n }\r\n }\r\n\r\n searchCompanies(filterText: string) {\r\n const start = 1;\r\n const end = this.appContext.getTotalPerPage();\r\n this.statusPreference = this.searchStatus.value;\r\n this.searchCompanyFirst = true;\r\n this.doSearchCompany(start, end, filterText);\r\n }\r\n\r\n searchMoreCompanies() {\r\n this.searchCompanyFirst = false;\r\n const start = this.companyPageableResult.getEnd() + 1;\r\n const end = this.appContext.getTotalPerPage();\r\n this.doSearchCompany(start, end, this.userProfile.getPreferences().getFilterText());\r\n }\r\n\r\n private doSearchCompany(start: number, end: number, filterText: string): void {\r\n const ref = this.loadingService.beginLoading();\r\n const pagingRequest = new PagingRequest();\r\n pagingRequest.setStart(start);\r\n pagingRequest.setEnd(end);\r\n\r\n const filterParams: ICompanyFilterParams = {\r\n filterText: filterText ? filterText.replace(/[./-]/g, \"\") : \"\",\r\n status: this.statusPreference,\r\n };\r\n this.companyService\r\n .searchCompany(filterParams, pagingRequest)\r\n .then((companyPageableResult) => {\r\n this.companyPageableResult.setStart(start);\r\n this.companyPageableResult.setEnd(end);\r\n this.companyPageableResult.setTotalItems(companyPageableResult.getTotalItems());\r\n\r\n if (this.searchCompanyFirst) {\r\n this.companyPageableResult.setItems(companyPageableResult.getItems());\r\n } else {\r\n this.companyPageableResult.addItems(companyPageableResult.getItems());\r\n }\r\n\r\n if (companyPageableResult.getItems().length === 1) {\r\n this.company = companyPageableResult.getItems().find((x) => x !== undefined) as Company;\r\n this.navigateToCompanyBeneficiaries(this.company);\r\n this.storageSearchPreferences(filterText);\r\n } else {\r\n this.company = null;\r\n this.storageSearchPreferences(null);\r\n }\r\n })\r\n .catch((error) => {\r\n this.companyPageableResult.setItems(null);\r\n })\r\n .finally(() => {\r\n this.loadingService.finishLoading(ref);\r\n //this.storageSearchPreferences(filterText);\r\n this.filterText = \"\";\r\n });\r\n }\r\n\r\n showScrollBottomBtn(): boolean {\r\n return this.companyPageableResult.getItems().length > 1;\r\n }\r\n\r\n showMoreCompaniesBtn(): boolean {\r\n return this.companyPageableResult.getTotalItems() !== this.companyPageableResult.getItems().length && this.companyPageableResult.getItems().length > 1;\r\n }\r\n\r\n async navigateToCompanyBeneficiaries(company: Company) {\r\n const ref = this.loadingService.beginLoading();\r\n try {\r\n this.company = await this.companyService.findCompanyBy(company.getFiscalNumber());\r\n this.pagingRequest = new PagingRequest();\r\n this.pagingRequest.setStart(1);\r\n this.pagingRequest.setEnd(this.appContext.getTotalPerPage());\r\n this.pagingRequest.setFilterText(\"\");\r\n this.pageableResult = await this.beneficiaryService.findBeneficiariesByFiscalNumber(company.getFiscalNumber(), this.pagingRequest, false);\r\n this.userService.setUserPreferences(company.getFiscalNumber());\r\n } catch {\r\n this.company = null;\r\n this.toast.showWarningToast(\"Empresa não encontrada\");\r\n } finally {\r\n this.loadingService.finishLoading(ref);\r\n this.storageSearchPreferences(company.getFiscalNumber());\r\n this.filterText = \"\";\r\n }\r\n }\r\n\r\n onPressEnterSearchBeneficiary(event): void {\r\n if (event.key === \"Enter\") {\r\n this.searchBeneficiary();\r\n }\r\n }\r\n\r\n async searchBeneficiary() {\r\n const ref = this.loadingService.beginLoading();\r\n try {\r\n this.pagingRequest = new PagingRequest();\r\n this.pagingRequest.setStart(1);\r\n this.pagingRequest.setEnd(this.appContext.getTotalPerPage());\r\n this.pagingRequest.setFilterText(this.filter.replace(/[.-]/g, \"\"));\r\n this.pageableResult = await this.beneficiaryService.findBeneficiariesByFiscalNumber(\r\n this.userProfile.getPreferences().getFilterText(),\r\n this.pagingRequest,\r\n false,\r\n );\r\n } catch (error) {\r\n this.toast.showWarningToast(\"Beneficiário não encontrado\");\r\n console.log(error);\r\n } finally {\r\n this.loadingService.finishLoading(ref);\r\n }\r\n }\r\n\r\n async searchMoreBeneficiaries() {\r\n const ref = this.loadingService.beginLoading();\r\n try {\r\n const start = this.pagingRequest.getStart() + this.appContext.getTotalPerPage();\r\n const end = this.appContext.getTotalPerPage();\r\n this.pagingRequest = new PagingRequest();\r\n this.pagingRequest.setStart(start);\r\n this.pagingRequest.setEnd(end);\r\n this.pagingRequest.setFilterText(this.filter);\r\n const moreResults = await this.beneficiaryService.findBeneficiariesByFiscalNumber(\r\n this.userProfile.getPreferences().getFilterText(),\r\n this.pagingRequest,\r\n false,\r\n );\r\n this.pageableResult.addItems(moreResults.getItems());\r\n } catch {\r\n this.toast.showWarningToast(\"Beneficiário não encontrado\");\r\n } finally {\r\n this.loadingService.finishLoading(ref);\r\n }\r\n }\r\n\r\n navigateToEditBeneficiary(beneficiary: Beneficiary): void {\r\n const beneficiaryKey = beneficiary.getBeneficiaryKey().getValue();\r\n this.router.navigate([RoutePath.EditBeneficiary, beneficiaryKey]);\r\n }\r\n\r\n hasAccessToEditBeneficiary(): boolean {\r\n return this.userService.getLoggedUser().hasPermission(UserPermissions.EditBeneficiary);\r\n }\r\n\r\n hasAccessToEditCycleLimit(): boolean {\r\n return this.userService.getLoggedUser().hasPermission(UserPermissions.EditCycleLimit);\r\n }\r\n\r\n getCompany(): Company {\r\n return this.company;\r\n }\r\n\r\n getPagebleResultItems(): Beneficiary[] {\r\n if (this.pageableResult && this.pageableResult.getItems().length > 0) {\r\n return this.pageableResult.getItems() as Beneficiary[];\r\n }\r\n return [];\r\n }\r\n\r\n getPeagebleResultItemsLenght(): number {\r\n return this.pageableResult.getItems().length;\r\n }\r\n\r\n storageSearchPreferences(fiscalNumber: string): void {\r\n this.userService.setUserPreferences(fiscalNumber ? fiscalNumber.replace(/[./-]/g, \"\") : \"\");\r\n this.userProfile = this.userService.getUserProfile();\r\n }\r\n\r\n showMoreBeneficiaries(): boolean {\r\n return this.pageableResult && this.pageableResult.getTotalItems() !== this.pageableResult.getItems().length && this.pageableResult.getItems().length > 1;\r\n }\r\n\r\n scrollToLastCompany() {\r\n const bottom = document.getElementById(\"bottom\");\r\n bottom.scrollIntoView();\r\n }\r\n\r\n getResultQuantityPhrase(): string {\r\n if (!this.pageableResult || this.pageableResult.getItems().length === 0) {\r\n return \"Nenhum resultado encontrado.\";\r\n }\r\n return `${this.pageableResult.getItems().length} RESULTADO(S) ENCONTRADO(S)`;\r\n }\r\n\r\n getCompanyResultQuantityPhrase(): string {\r\n if (!this.companyPageableResult || this.companyPageableResult.getItems().length === 0) {\r\n return \"Nenhum resultado encontrado.\";\r\n }\r\n return `${this.companyPageableResult.getItems().length} RESULTADO(S) ENCONTRADO(S)`;\r\n }\r\n\r\n public openModalBeneficiaryLimit(beneficiary: Beneficiary): void {\r\n const dialogRef = this.dialog.open(LimitBeneficiaryModalComponent, {\r\n id: \"status-dialog\",\r\n disableClose: true,\r\n hasBackdrop: true,\r\n width: \"860px\",\r\n height: \"450px\",\r\n data: { beneficiary: beneficiary },\r\n });\r\n dialogRef.afterClosed().subscribe((result) => {\r\n if (result) {\r\n this.navigateToCompanyBeneficiaries(this.company);\r\n }\r\n });\r\n }\r\n}\r\n","
\r\n
\r\n \r\n \r\n
\r\n\r\n
\r\n \r\n \r\n \r\n
\r\n search\r\n
\r\n
\r\n
\r\n\r\n
\r\n
\r\n
\r\n \r\n
\r\n\r\n
\r\n {{ getCompany().getCorporateName() }} \r\n CNPJ: {{ getCompany().getFiscalNumber() | companyFederalNumber }} \r\n Vidas: {{ getCompany().getCompanyInfo().getEmployeeCount() }}\r\n
\r\n
\r\n
\r\n \r\n
\r\n search\r\n
\r\n
\r\n
\r\n\r\n
\r\n
\r\n

{{ getResultQuantityPhrase() }}

\r\n
\r\n
\r\n
\r\n
\r\n
\r\n

{{ beneficiary.getName() }}

\r\n
\r\n
\r\n Número do cartão: {{ beneficiary.getCard().getCardNumber() | cardNumberFormat }}\r\n
\r\n block\r\n BLOQUEADO\r\n
\r\n
\r\n
\r\n
\r\n CPF: {{ beneficiary.getSocialNumber() | socialNumberFormatPipe }}\r\n Dependentes: {{ beneficiary.howManyDependents() }}\r\n
\r\n
\r\n Sexo: {{ beneficiary.getGender().getView() }}\r\n Estado Civil: {{ beneficiary.getMaritalStatus().getView() }}\r\n
\r\n
\r\n Celular: {{ beneficiary.getMobile() }}\r\n E-mail: {{ beneficiary.getEmail() }}\r\n
\r\n
\r\n
\r\n
\r\n Limite: {{ beneficiary.getLimit() | currencyPbmPipe }} \r\n
\r\n
\r\n
\r\n
\r\n
\r\n \r\n check_circle_outline\r\n clear\r\n\r\n {{ beneficiary.isActive() ? \"ATIVO\" : \"INATIVO\" }}\r\n
\r\n\r\n
\r\n edit_note\r\n {{ hasAccessToEditBeneficiary() && beneficiary.isActive() ? \"EDITAR\" : \"VISUALIZAR\" }}\r\n
\r\n\r\n
\r\n attach_money\r\n ALTERAR LIMITE\r\n
\r\n
\r\n
\r\n
\r\n
\r\n carregar mais registros\r\n
\r\n
\r\n\r\n\r\n
\r\n
\r\n

{{ getCompanyResultQuantityPhrase() }}

\r\n
\r\n arrow_drop_down\r\n ir para o fim da lista\r\n
\r\n
\r\n
\r\n
\r\n
\r\n \r\n
\r\n
\r\n
\r\n

{{ company.getCorporateName() }}

\r\n

CNPJ: {{ company.getFiscalNumber() | companyFederalNumber }}

\r\n

{{ company.getTradingName() }}

\r\n
\r\n
\r\n
\r\n \r\n check_circle_outline\r\n clear\r\n\r\n {{ company.getIsActive() ? \"ATIVO\" : \"INATIVO\" }}\r\n
\r\n
\r\n edit_note\r\n {{ hasAccessToEditBeneficiary() ? \"EDITAR\" : \"VISUALIZAR\" }}\r\n
\r\n
\r\n
\r\n
\r\n carregar mais registros\r\n
\r\n\r\n","import { Component, OnInit, TemplateRef, ViewChild } from \"@angular/core\";\r\nimport { BeneficiarySearchParameterDTO } from \"src/app/ui/models/domains/pbm/Beneficiary/dto/beneficiary-search-parameter-dto\";\r\nimport { MaskInput } from \"src/app/ui/models/domains/masks/mask.model\";\r\nimport { UserService } from \"src/app/ui/services/user.service\";\r\nimport { BeneficiaryDTO } from \"src/app/ui/models/domains/pbm/Beneficiary/dto/beneficiary-dto\";\r\nimport { FeatureViewService } from \"src/app/ui/services/feature-view.service\";\r\nimport { FeatureViews } from \"src/app/ui/models/domains/features/custom-feature-views\";\r\nimport { PageViews } from \"src/app/ui/models/domains/features/custom-page-views\";\r\nimport { ExportBeneficiariesService } from \"src/app/ui/services/pbm/export-beneficiaries.service\";\r\nimport { Toast } from \"../../../toast/toast\";\r\nimport { FilterBeneficiarySearchParameterByExportDTO } from \"src/app/ui/models/domains/pbm/Beneficiary/interfaces/IFilterBeneficiarySearchParameterByExport\";\r\nimport { ExportService } from \"src/app/ui/services/export.service\";\r\nimport { DatePipe } from \"@angular/common\";\r\nimport { merge } from \"rxjs\";\r\nimport { startWith, catchError, switchMap } from \"rxjs/operators\";\r\nimport { Company } from \"src/app/ui/models/domains/pbm/companies/company\";\r\nimport { CompanyService } from \"src/app/ui/services/pbm/company.service\";\r\nimport { Gender } from \"src/app/ui/models/domains/pbm/Beneficiary/person\";\r\nimport { RoutePath } from \"src/app/ui/models/domains/route-paths.model\";\r\nimport { Router } from \"@angular/router\";\r\nimport { MaritalLabel } from \"src/app/ui/models/domains/pbm/Beneficiary/marital-status-type\";\r\nimport { MatDialogRef, MatDialog } from \"@angular/material/dialog\";\r\nimport { MatPaginator } from \"@angular/material/paginator\";\r\n\r\n@Component({\r\n selector: \"export-beneficiaries\",\r\n templateUrl: \"./export-beneficiaries.component.html\",\r\n styleUrls: [\"./export-beneficiaries.component.scss\"],\r\n})\r\nexport class ExportBeneficiariesComponent implements OnInit {\r\n @ViewChild(MatPaginator) paginator: MatPaginator;\r\n @ViewChild(\"dialogTemplate\") dialogTemplate: TemplateRef;\r\n public dialogRef: MatDialogRef;\r\n\r\n private userProfile = this.userService.getUserProfile();\r\n\r\n public displayedColumns: Array = [\"check\", \"name\", \"dataCadastro\", \"dependent\", \"active\", \"totalSelected\"];\r\n\r\n public dateMask = MaskInput.getDateMask();\r\n\r\n public totalPerPagesOptions: number[] = [10, 25, 50, 100];\r\n\r\n public count: number = 0;\r\n private company: Company;\r\n hasChanges: boolean = false;\r\n\r\n constructor(\r\n private featureViewService: FeatureViewService,\r\n private exportService: ExportBeneficiariesService,\r\n private companyService: CompanyService,\r\n private userService: UserService,\r\n private dialog: MatDialog,\r\n private toast: Toast,\r\n private exportInternalService: ExportService,\r\n private datePipe: DatePipe,\r\n private router: Router,\r\n ) {}\r\n\r\n async ngAfterViewInit() {\r\n merge(this.paginator.page)\r\n .pipe(\r\n startWith({}),\r\n switchMap(async () => {\r\n if (this.getProcessStatus() === 0) {\r\n if (this.userProfile.getPreferences().getFilterText().length > 0) {\r\n await this.searchBenefiaries();\r\n }\r\n }\r\n }),\r\n catchError(() => {\r\n return [];\r\n }),\r\n )\r\n .subscribe();\r\n }\r\n\r\n ngOnInit() {\r\n if (this.userProfile.getPreferences().getFilterText().length > 0) {\r\n this.featureViewService.activeFeatureView(FeatureViews.BeneficiaryExportFeatureView, PageViews.BeneficiaryPageView);\r\n this.userProfile = this.userService.getUserProfile();\r\n this.findCompany();\r\n this.getFilters().valueChanges.subscribe((x) => {\r\n this.hasChanges = true;\r\n });\r\n } else {\r\n this.router.navigate([RoutePath.SearchBeneficiary]);\r\n this.toast.showWarningToast(\"É necessário selecionar uma empresa para continuar\");\r\n }\r\n }\r\n\r\n hasCompany(): boolean {\r\n return !!this.company;\r\n }\r\n\r\n getCompany(): Company {\r\n return this.company;\r\n }\r\n\r\n async findCompany() {\r\n try {\r\n this.company = await this.companyService.findCompanyBy(this.userProfile.getPreferences().getFilterText());\r\n } catch {\r\n this.company = null;\r\n this.toast.showWarningToast(\"Empresa não encontrada\");\r\n }\r\n }\r\n\r\n private initialValues(): void {\r\n this.getSelectedBeneficiries().clear();\r\n this.exportService.setProcessStatus(0);\r\n }\r\n\r\n getProcessStatus(): number {\r\n return this.exportService.getProcessStatus();\r\n }\r\n\r\n getAllowedBeneficiries() {\r\n return this.exportService.getBeneficiries();\r\n }\r\n\r\n getSelectedBeneficiries() {\r\n return this.exportService.getSelectedBeneficiaries();\r\n }\r\n\r\n hasSelectedBeneficiries() {\r\n return this.getSelectedBeneficiries().selected.length > 0;\r\n }\r\n\r\n getFilters() {\r\n return this.exportService.getFilters();\r\n }\r\n\r\n getResultLenght() {\r\n this.count = this.exportService.getResultLenght();\r\n }\r\n\r\n public openConfiguracoes() {\r\n this.dialogRef = this.dialog.open(this.dialogTemplate, {\r\n width: \"500px\",\r\n });\r\n }\r\n\r\n public onDialogClose() {\r\n this.dialogRef.close();\r\n }\r\n\r\n public async searchBenefiaries() {\r\n this.initialValues();\r\n\r\n if (this.hasChanges) {\r\n this.paginator.pageIndex = 0;\r\n this.hasChanges = false;\r\n }\r\n\r\n let params: BeneficiarySearchParameterDTO = {\r\n StartIndex: this.paginator.pageIndex + 1,\r\n TotalPerPages: this.paginator.pageSize,\r\n FiscalNumber: this.userProfile.getPreferences().getFilterText(),\r\n Filters: this.filtered(),\r\n };\r\n await this.exportService.filterbeneficiries(params).then(() => this.getResultLenght());\r\n }\r\n\r\n public async filterBenefiaries() {\r\n this.initialValues();\r\n this.paginator.pageIndex = 0;\r\n\r\n let params: BeneficiarySearchParameterDTO = {\r\n StartIndex: 1,\r\n TotalPerPages: this.paginator.pageSize,\r\n FiscalNumber: this.userProfile.getPreferences().getFilterText(),\r\n Filters: this.filtered(),\r\n };\r\n await this.exportService.filterbeneficiries(params).then(() => this.getResultLenght());\r\n this.hasChanges = false;\r\n }\r\n\r\n public filtered(): FilterBeneficiarySearchParameterByExportDTO {\r\n let StartDate;\r\n let EndDate;\r\n let ExportType;\r\n let CardState;\r\n\r\n if (this.getFilters().get(\"startDate\").value !== \"\") {\r\n var date = this.getFilters().get(\"startDate\").value.split(\"/\");\r\n StartDate = `${date[2]}-${date[1]}-${date[0]}T` + \"00:00:00\";\r\n EndDate = `${date[2]}-${date[1]}-${date[0]}T` + \"23:59:59\";\r\n }\r\n\r\n if (this.getFilters().get(\"endDate\").value !== \"\") {\r\n var date = this.getFilters().get(\"endDate\").value.split(\"/\");\r\n EndDate = `${date[2]}-${date[1]}-${date[0]}T` + \"23:59:59\";\r\n }\r\n\r\n ExportType = this.getFilters().get(\"typeExport\").value;\r\n CardState = this.getFilters().get(\"cardState\").value;\r\n return {\r\n StartDate: StartDate,\r\n EndDate: EndDate,\r\n ExportType: ExportType,\r\n CardState: CardState,\r\n };\r\n }\r\n\r\n public getShowClearButtom(): boolean {\r\n return this.getFilters().get(\"startDate\").value != \"\" || this.getFilters().get(\"endDate\").value != \"\";\r\n }\r\n\r\n public isAllSelected() {\r\n this.exportService.isAllSelected();\r\n }\r\n\r\n public masterToggle() {\r\n this.exportService.masterToggle();\r\n }\r\n\r\n public selectBeneficiary(event: any, index: BeneficiaryDTO) {\r\n this.exportService.selectBeneficiary(event, index);\r\n }\r\n\r\n public getIsSelected(index: BeneficiaryDTO): number {\r\n return this.exportService.getIsSelected(index);\r\n }\r\n\r\n public getSelectedDescription(): string {\r\n return this.getSelectedBeneficiries().selected.length == 0\r\n ? \"0 selecionada\"\r\n : this.getSelectedBeneficiries().selected.length == 1\r\n ? \"1 selecionada\"\r\n : this.getSelectedBeneficiries().selected.length + \" selecionadas\";\r\n }\r\n\r\n public doActionReport() {\r\n if (this.getProcessStatus() == 2) {\r\n this.exportService.clearFields();\r\n } else {\r\n this.processExport();\r\n }\r\n }\r\n\r\n getProcessStyle(): any {\r\n if (this.getProcessStatus() == 1 || this.getAllowedBeneficiries().data.length == 0) {\r\n return { opacity: \"0.5\" }; //estilo botão desabilitado\r\n }\r\n return {};\r\n }\r\n\r\n clearFields() {\r\n this.exportService.clearFields();\r\n }\r\n\r\n ngOnDestroy() {\r\n this.exportService.clearFields();\r\n }\r\n\r\n async processExport(): Promise {\r\n this.exportService.setProcessStatus(1);\r\n const columns: any[] = [\r\n { value: \"CNPJ_EMPRESA\", key: \"Cnpj\" },\r\n { value: \"TIPO\", key: \"Dependent\" },\r\n { value: \"MATRICULA\", key: \"Registration\" },\r\n { value: \"DATA_ADMISSAO\", key: \"AdmissionDate\" },\r\n { value: \"CARGO\", key: \"JobName\" },\r\n { value: \"CPF_TITULAR\", key: \"SocialNumber\" },\r\n { value: \"CPF_DEPENDENTE\", key: \"SocialNumberDependent\" },\r\n { value: \"NOME_COMPLETO\", key: \"Name\" },\r\n { value: \"SEXO\", key: \"Gender\" },\r\n { value: \"ESTADO_CIVIL\", key: \"MaritalStatus\" },\r\n { value: \"DATA_NASCIMENTO\", key: \"BirthDate\" },\r\n { value: \"ENDERECO\", key: \"Street\" },\r\n { value: \"NUMERO\", key: \"AddressNumber\" },\r\n { value: \"COMPLEMENTO\", key: \"Complement\" },\r\n { value: \"BAIRRO\", key: \"District\" },\r\n { value: \"CEP\", key: \"ZipCode\" },\r\n { value: \"CIDADE\", key: \"City\" },\r\n { value: \"ESTADO\", key: \"Region\" },\r\n { value: \"MESMO_ENDERECO_TITULAR\", key: \"IsNewAddress\" },\r\n { value: \"E_MAIL\", key: \"Email\" },\r\n { value: \"VALIDAR_EMAIL_PROXIMO_ACESSO\", key: \"NeedValidateEmail\" },\r\n { value: \"TELEFONE\", key: \"Telephone\" },\r\n { value: \"CELULAR\", key: \"Mobile\" },\r\n { value: \"SENHA_TRANSACIONAL\", key: \"TransactionalPassword\" },\r\n { value: \"HABILITAR_DELIVERY\", key: \"EnableDelivery\" },\r\n { value: \"DATA_CADASTRO\", key: \"ActivationDate\" },\r\n { value: \"SITUAÇÃO\", key: \"Active\" },\r\n ];\r\n let rows: any[] = [];\r\n\r\n if (this.getSelectedBeneficiries().selected.length > 0) {\r\n this.getSelectedBeneficiries().selected.forEach((p) => {\r\n rows.push({\r\n Cnpj: this.userProfile.getPreferences().getFilterText(),\r\n Dependent: p.Dependent ? \"Dependente\" : \"Titular\",\r\n Registration: p.Registration,\r\n AdmissionDate: this.datePipe.transform(p.AdmissionDate, \"dd/MM/yyyy\"),\r\n JobName: p.JobName,\r\n SocialNumber: p.Dependent ? p.SocialNumberTitular : p.SocialNumber,\r\n SocialNumberDependent: p.Dependent ? p.SocialNumber : \"\",\r\n Name: p.Name,\r\n Gender: new Gender().getOptions()[p.Gender.toString()],\r\n MaritalStatus: MaritalLabel.get(p.MaritalStatus),\r\n BirthDate: this.datePipe.transform(p.BirthDate, \"dd/MM/yyyy\"),\r\n Street: p.Dependent ? (p.IsNewAddress ? p.Street : \"\") : p.Street,\r\n AddressNumber: p.Dependent ? (p.IsNewAddress ? p.AddressNumber : \"\") : p.AddressNumber,\r\n Complement: p.Dependent ? (p.IsNewAddress ? p.Complement : \"\") : p.Complement,\r\n District: p.Dependent ? (p.IsNewAddress ? p.District : \"\") : p.District,\r\n ZipCode: p.Dependent ? (p.IsNewAddress ? p.ZipCode : \"\") : p.ZipCode,\r\n City: p.Dependent ? (p.IsNewAddress ? p.City : \"\") : p.City,\r\n Region: p.Dependent ? (p.IsNewAddress ? p.Region : \"\") : p.Region,\r\n IsNewAddress: p.Dependent ? (p.IsNewAddress ? \"Sim\" : \"Nao\") : \"\",\r\n Email: p.Email,\r\n NeedValidateEmail: p.NeedValidateEmail ? \"Sim\" : \"Nao\",\r\n Telephone: p.Telephone,\r\n Mobile: p.Mobile,\r\n TransactionalPassword: p.TransactionalPassword,\r\n EnableDelivery: p.EnableDelivery ? \"Sim\" : \"Nao\",\r\n ActivationDate: this.datePipe.transform(p.ActivationDate, \"dd/MM/yyyy\"),\r\n Active: p.Active ? \"Ativado\" : \"Desativado\",\r\n });\r\n });\r\n } else {\r\n let params: BeneficiarySearchParameterDTO = {\r\n StartIndex: 1,\r\n TotalPerPages: this.count,\r\n FiscalNumber: this.userProfile.getPreferences().getFilterText(),\r\n Filters: this.filtered(),\r\n };\r\n const response = await this.exportService.searchbeneficiries(params);\r\n\r\n if (response.length > 0) {\r\n response.forEach((p) => {\r\n rows.push({\r\n Cnpj: this.userProfile.getPreferences().getFilterText(),\r\n Dependent: p.Dependent ? \"Dependente\" : \"Titular\",\r\n Registration: p.Registration,\r\n AdmissionDate: this.datePipe.transform(p.AdmissionDate, \"dd/MM/yyyy\"),\r\n JobName: p.JobName,\r\n SocialNumber: p.Dependent ? p.SocialNumberTitular : p.SocialNumber,\r\n SocialNumberDependent: p.Dependent ? p.SocialNumber : \"\",\r\n Name: p.Name,\r\n Gender: new Gender().getOptions()[p.Gender.toString()],\r\n MaritalStatus: MaritalLabel.get(p.MaritalStatus),\r\n BirthDate: this.datePipe.transform(p.BirthDate, \"dd/MM/yyyy\"),\r\n Street: p.Dependent ? (p.IsNewAddress ? p.Street : \"\") : p.Street,\r\n AddressNumber: p.Dependent ? (p.IsNewAddress ? p.AddressNumber : \"\") : p.AddressNumber,\r\n Complement: p.Dependent ? (p.IsNewAddress ? p.Complement : \"\") : p.Complement,\r\n District: p.Dependent ? (p.IsNewAddress ? p.District : \"\") : p.District,\r\n ZipCode: p.Dependent ? (p.IsNewAddress ? p.ZipCode : \"\") : p.ZipCode,\r\n City: p.Dependent ? (p.IsNewAddress ? p.City : \"\") : p.City,\r\n Region: p.Dependent ? (p.IsNewAddress ? p.Region : \"\") : p.Region,\r\n IsNewAddress: p.Dependent ? (p.IsNewAddress ? \"Sim\" : \"Nao\") : \"\",\r\n Email: p.Email,\r\n NeedValidateEmail: p.NeedValidateEmail ? \"Sim\" : \"Nao\",\r\n Telephone: p.Telephone,\r\n Mobile: p.Mobile,\r\n TransactionalPassword: p.TransactionalPassword,\r\n EnableDelivery: p.EnableDelivery ? \"Sim\" : \"Nao\",\r\n ActivationDate: this.datePipe.transform(p.ActivationDate, \"dd/MM/yyyy\"),\r\n Active: p.Active ? \"Ativado\" : \"Desativado\",\r\n });\r\n });\r\n }\r\n }\r\n\r\n if (rows.length > 0) {\r\n this.exportInternalService.exportTo(rows, columns, \"Beneficiarios\", this.getFilters().get(\"format\").value);\r\n this.toast.showSuccessToast(\"Download do relatório de beneficiários realizado com sucesso!\");\r\n this.exportService.setProcessStatus(0);\r\n } else this.toast.showWarningToast(\"Não há itens para download.\");\r\n }\r\n\r\n getDescription(value: any, args: any): any {\r\n const indexOf = Object.keys(args).indexOf(value);\r\n return Object.values(args)[indexOf];\r\n }\r\n}\r\n","
\r\n
\r\n
\r\n
\r\n
\r\n \r\n
\r\n\r\n
\r\n {{ getCompany().getCorporateName() }} \r\n CNPJ: {{ getCompany().getFiscalNumber() | companyFederalNumber }} \r\n
\r\n
\r\n
\r\n \r\n
\r\n
\r\n
\r\n\r\n \r\n Cartão\r\n \r\n Ativo\r\n Bloqueado\r\n Cancelado\r\n \r\n \r\n\r\n \r\n Titular/Dependente\r\n \r\n Todos\r\n Somente Titular\r\n Somente Dependente\r\n \r\n \r\n
\r\n
\r\n \r\n Data Inicial de Cadastro\r\n \r\n \r\n\r\n \r\n Data Final de Cadastro\r\n \r\n \r\n
\r\n
\r\n
\r\n \r\n \r\n
\r\n
\r\n
\r\n 0\">\r\n
\r\n \r\n XLSX\r\n CSV\r\n \r\n \r\n {{ getProcessStatus() == 2 ? \"check\" : \"hourglass_full\" }}\r\n {{ getProcessStatus() == 0 ? \"PROCESSAR RELATÓRIO\" : getProcessStatus() == 1 ? \"RELATÓRIO EM PROCESSAMENTO...\" : \"RELATÓRIO FINALIZADO\" }}\r\n \r\n Download automático \r\n
\r\n
\r\n

\r\n *Somente os itens selecionados aparecem no relatório \r\n

\r\n
\r\n
\r\n
\r\n
\r\n \r\n \r\n \r\n\r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n
\r\n 0 && isAllSelected()\">\r\n \r\n \r\n \r\n \r\n Nome\r\n {{ element.Name }}\r\n Data Cad.\r\n {{ element.ActivationDate | date : \"dd/MM/yyyy - HH:mm\" }}\r\n Tipo\r\n {{ element.Dependent ? \"Dependente\" : \"Titular\" }}\r\n Situação\r\n {{ element.Active ? \"Ativado\" : \"Desativado\" }}\r\n [ {{ getSelectedDescription() }} ]
\r\n\r\n \r\n
\r\n
\r\n
\r\n
\r\n","export enum MaritalStatusType {\r\n Married = 0,\r\n Single = 1,\r\n Divorced = 2,\r\n Widowed = 3,\r\n Other = 10,\r\n}\r\n\r\nexport const MaritalLabel = new Map([\r\n [MaritalStatusType.Married, 'Casado'],\r\n [MaritalStatusType.Single, 'Solteiro'],\r\n [MaritalStatusType.Divorced, 'Divorciado'],\r\n [MaritalStatusType.Widowed, 'Viúvo'],\r\n [MaritalStatusType.Other, 'Outro']\r\n]);","export enum ExportType {\r\n All = 0,\r\n Beneficiries = 1,\r\n Dependents = 2\r\n}\r\nexport enum CardState {\r\n Active = 0,\r\n Blocked = 1,\r\n Canceled = 2\r\n}\r\n\r\nexport type FilterBeneficiarySearchParameterByExportDTO = {\r\n StartDate: string,\r\n EndDate: string,\r\n ExportType: ExportType,\r\n CardState: CardState[]\r\n}","import { Injectable } from \"@angular/core\";\r\n\r\nimport { BeneficiaryRepository } from \"../../repositories/pbm/beneficiary.repository\";\r\nimport { BeneficiaryDTO } from \"../../models/domains/pbm/Beneficiary/dto/beneficiary-dto\";\r\nimport { BeneficiarySearchParameterDTO } from \"../../models/domains/pbm/Beneficiary/dto/beneficiary-search-parameter-dto\";\r\nimport { LoadingService } from \"../loading.service\";\r\nimport { Toast } from \"../../components/toast/toast\";\r\nimport { CardState, ExportType } from \"../../models/domains/pbm/Beneficiary/interfaces/IFilterBeneficiarySearchParameterByExport\";\r\nimport { UntypedFormControl, UntypedFormGroup, Validators } from \"@angular/forms\";\r\nimport { MatTableDataSource } from \"@angular/material/table\";\r\nimport { SelectionModel } from \"@angular/cdk/collections\";\r\n\r\n@Injectable({ providedIn: \"root\" })\r\nexport class ExportBeneficiariesService {\r\n /**\r\n * 0=status inicial\r\n * 1=processando\r\n * 2=processado e pronto para download\r\n */\r\n private processStatus: number = 0;\r\n private beneficiries = new MatTableDataSource();\r\n private selectedBeneficiaries = new SelectionModel(true, []);\r\n filters = new UntypedFormGroup({\r\n cardState: new UntypedFormControl([CardState.Active], [Validators.required]),\r\n typeExport: new UntypedFormControl(ExportType.All, [Validators.required]),\r\n startDate: new UntypedFormControl('', [Validators.required]),\r\n endDate: new UntypedFormControl('', [Validators.required]),\r\n linhas: new UntypedFormControl('1', [Validators.required]),\r\n format: new UntypedFormControl('xlsx', [Validators.required]),\r\n totalPerPage: new UntypedFormControl(100, [Validators.required]),\r\n });\r\n private resultsLength = 0;\r\n\r\n constructor(\r\n private beneficiaryRepository: BeneficiaryRepository,\r\n private loadingService: LoadingService,\r\n private toast: Toast\r\n ) { }\r\n\r\n /**\r\n *\r\n * @returns 0=status inicial | 1=processando | 2=processado e pronto para download\r\n */\r\n getProcessStatus(): number {\r\n return this.processStatus;\r\n }\r\n\r\n setProcessStatus(processStatus: 0 | 1 | 2) {\r\n this.processStatus = processStatus;\r\n }\r\n\r\n getBeneficiries() {\r\n return this.beneficiries;\r\n }\r\n\r\n getSelectedBeneficiaries() {\r\n return this.selectedBeneficiaries;\r\n }\r\n\r\n getFilters() {\r\n return this.filters;\r\n }\r\n\r\n getResultLenght() {\r\n return this.resultsLength;\r\n }\r\n\r\n async searchbeneficiries(params: BeneficiarySearchParameterDTO) {\r\n return await this.beneficiaryRepository.SearchBeneficiaries(params)\r\n .then((beneficiariesByExport) => {\r\n const beneficiaries = beneficiariesByExport\r\n\r\n if (beneficiaries.Data.length === 0)\r\n this.toast.showWarningToast(\"Nenhum beneficiários/dependentes encontrado com os filtros informado(s).\", \"Atenção!\");\r\n\r\n return beneficiaries.Data;\r\n }).catch((error) => {\r\n console.error(error)\r\n this.toast.showWarningToast(error, \"Atenção\");\r\n return [];\r\n })\r\n }\r\n\r\n async filterbeneficiries(params: BeneficiarySearchParameterDTO) {\r\n const ref = this.loadingService.beginLoading();\r\n await this.beneficiaryRepository.SearchBeneficiaries(params)\r\n .then((beneficiariesByExport) => {\r\n const beneficiaries = beneficiariesByExport\r\n\r\n if (beneficiaries.Data.length === 0)\r\n this.toast.showWarningToast(\"Nenhum beneficiários/dependentes encontrado com os filtros informado(s).\", \"Atenção!\");\r\n\r\n this.beneficiries.data = beneficiaries.Data\r\n this.resultsLength = beneficiaries.Count\r\n }).catch((error) => {\r\n console.error(error)\r\n this.toast.showWarningToast(error, \"Atenção\")\r\n }).finally(() => {\r\n this.loadingService.finishLoading(ref);\r\n })\r\n }\r\n\r\n isAllSelected() {\r\n const numSelected = this.selectedBeneficiaries.selected.length;\r\n const numRows = this.beneficiries.data.length;\r\n return numSelected === numRows;\r\n }\r\n\r\n masterToggle() {\r\n if (this.isAllSelected()) {\r\n this.selectedBeneficiaries.clear();\r\n return;\r\n }\r\n this.selectedBeneficiaries.clear();\r\n this.beneficiries.data.forEach((element) => {\r\n this.selectedBeneficiaries.selected.push(element);\r\n });\r\n this.getFilters().get('linhas').setValue(\"0\")\r\n }\r\n\r\n selectBeneficiary(event: any, beneficiary: BeneficiaryDTO) {\r\n const idx = this.getIsSelected(beneficiary);\r\n if (idx == -1) {\r\n this.getFilters().get('linhas').setValue(\"0\")\r\n this.selectedBeneficiaries.selected.push(beneficiary);\r\n } else {\r\n this.selectedBeneficiaries.selected.splice(idx, 1);\r\n }\r\n\r\n if (this.selectedBeneficiaries.selected.length === 0)\r\n this.getFilters().get('linhas').setValue(\"\")\r\n }\r\n\r\n getIsSelected(beneficiary: BeneficiaryDTO): number {\r\n let ret = -1;\r\n for (let i = 0; i < this.selectedBeneficiaries.selected.length; i++) {\r\n const selected = this.selectedBeneficiaries.selected[i];\r\n if (beneficiary.Id === selected.Id) {\r\n ret = i;\r\n break;\r\n }\r\n }\r\n return ret;\r\n }\r\n\r\n clearFields() {\r\n this.filters = new UntypedFormGroup({\r\n cardState: new UntypedFormControl([CardState.Active], [Validators.required]),\r\n typeExport: new UntypedFormControl(ExportType.All, [Validators.required]),\r\n startDate: new UntypedFormControl('', [Validators.required]),\r\n endDate: new UntypedFormControl('', [Validators.required]),\r\n linhas: new UntypedFormControl('1', [Validators.required]),\r\n format: new UntypedFormControl('xlsx', [Validators.required]),\r\n totalPerPage: new UntypedFormControl(100, [Validators.required]),\r\n });\r\n this.beneficiries.data = [];\r\n }\r\n}","/*! xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */\n/* vim: set ts=2: */\n/*exported XLSX */\n/*global process:false, Buffer:false, ArrayBuffer:false, DataView:false, Deno:false */\nvar XLSX = {};\nXLSX.version = '0.18.5';\nvar current_codepage = 1200,\n current_ansi = 1252;\nvar VALID_ANSI = [874, 932, 936, 949, 950, 1250, 1251, 1252, 1253, 1254, 1255, 1256, 1257, 1258, 10000];\n/* ECMA-376 Part I 18.4.1 charset to codepage mapping */\nvar CS2CP = {\n /*::[*/0 /*::]*/: 1252,\n /* ANSI */\n /*::[*/1 /*::]*/: 65001,\n /* DEFAULT */\n /*::[*/2 /*::]*/: 65001,\n /* SYMBOL */\n /*::[*/77 /*::]*/: 10000,\n /* MAC */\n /*::[*/128 /*::]*/: 932,\n /* SHIFTJIS */\n /*::[*/129 /*::]*/: 949,\n /* HANGUL */\n /*::[*/130 /*::]*/: 1361,\n /* JOHAB */\n /*::[*/134 /*::]*/: 936,\n /* GB2312 */\n /*::[*/136 /*::]*/: 950,\n /* CHINESEBIG5 */\n /*::[*/161 /*::]*/: 1253,\n /* GREEK */\n /*::[*/162 /*::]*/: 1254,\n /* TURKISH */\n /*::[*/163 /*::]*/: 1258,\n /* VIETNAMESE */\n /*::[*/177 /*::]*/: 1255,\n /* HEBREW */\n /*::[*/178 /*::]*/: 1256,\n /* ARABIC */\n /*::[*/186 /*::]*/: 1257,\n /* BALTIC */\n /*::[*/204 /*::]*/: 1251,\n /* RUSSIAN */\n /*::[*/222 /*::]*/: 874,\n /* THAI */\n /*::[*/238 /*::]*/: 1250,\n /* EASTEUROPE */\n /*::[*/255 /*::]*/: 1252,\n /* OEM */\n /*::[*/69 /*::]*/: 6969 /* MISC */\n} /*:any*/;\nvar set_ansi = function (cp /*:number*/) {\n if (VALID_ANSI.indexOf(cp) == -1) return;\n current_ansi = CS2CP[0] = cp;\n};\nfunction reset_ansi() {\n set_ansi(1252);\n}\nvar set_cp = function (cp /*:number*/) {\n current_codepage = cp;\n set_ansi(cp);\n};\nfunction reset_cp() {\n set_cp(1200);\n reset_ansi();\n}\nfunction char_codes(data /*:string*/) /*:Array*/{\n var o /*:Array*/ = [];\n for (var i = 0, len = data.length; i < len; ++i) o[i] = data.charCodeAt(i);\n return o;\n}\nfunction utf16leread(data /*:string*/) /*:string*/{\n var o /*:Array*/ = [];\n for (var i = 0; i < data.length >> 1; ++i) o[i] = String.fromCharCode(data.charCodeAt(2 * i) + (data.charCodeAt(2 * i + 1) << 8));\n return o.join(\"\");\n}\nfunction utf16beread(data /*:string*/) /*:string*/{\n var o /*:Array*/ = [];\n for (var i = 0; i < data.length >> 1; ++i) o[i] = String.fromCharCode(data.charCodeAt(2 * i + 1) + (data.charCodeAt(2 * i) << 8));\n return o.join(\"\");\n}\nvar debom = function (data /*:string*/) /*:string*/{\n var c1 = data.charCodeAt(0),\n c2 = data.charCodeAt(1);\n if (c1 == 0xFF && c2 == 0xFE) return utf16leread(data.slice(2));\n if (c1 == 0xFE && c2 == 0xFF) return utf16beread(data.slice(2));\n if (c1 == 0xFEFF) return data.slice(1);\n return data;\n};\nvar _getchar = function _gc1(x /*:number*/) /*:string*/{\n return String.fromCharCode(x);\n};\nvar _getansi = function _ga1(x /*:number*/) /*:string*/{\n return String.fromCharCode(x);\n};\nvar $cptable;\nfunction set_cptable(cptable) {\n $cptable = cptable;\n set_cp = function (cp /*:number*/) {\n current_codepage = cp;\n set_ansi(cp);\n };\n debom = function (data /*:string*/) {\n if (data.charCodeAt(0) === 0xFF && data.charCodeAt(1) === 0xFE) {\n return $cptable.utils.decode(1200, char_codes(data.slice(2)));\n }\n return data;\n };\n _getchar = function _gc2(x /*:number*/) /*:string*/{\n if (current_codepage === 1200) return String.fromCharCode(x);\n return $cptable.utils.decode(current_codepage, [x & 255, x >> 8])[0];\n };\n _getansi = function _ga2(x /*:number*/) /*:string*/{\n return $cptable.utils.decode(current_ansi, [x])[0];\n };\n cpdoit();\n}\nexport { set_cptable };\nvar DENSE = null;\nvar DIF_XL = true;\nvar Base64_map = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\";\nfunction Base64_encode(input) {\n var o = \"\";\n var c1 = 0,\n c2 = 0,\n c3 = 0,\n e1 = 0,\n e2 = 0,\n e3 = 0,\n e4 = 0;\n for (var i = 0; i < input.length;) {\n c1 = input.charCodeAt(i++);\n e1 = c1 >> 2;\n c2 = input.charCodeAt(i++);\n e2 = (c1 & 3) << 4 | c2 >> 4;\n c3 = input.charCodeAt(i++);\n e3 = (c2 & 15) << 2 | c3 >> 6;\n e4 = c3 & 63;\n if (isNaN(c2)) {\n e3 = e4 = 64;\n } else if (isNaN(c3)) {\n e4 = 64;\n }\n o += Base64_map.charAt(e1) + Base64_map.charAt(e2) + Base64_map.charAt(e3) + Base64_map.charAt(e4);\n }\n return o;\n}\nfunction Base64_decode(input) {\n var o = \"\";\n var c1 = 0,\n c2 = 0,\n c3 = 0,\n e1 = 0,\n e2 = 0,\n e3 = 0,\n e4 = 0;\n input = input.replace(/[^\\w\\+\\/\\=]/g, \"\");\n for (var i = 0; i < input.length;) {\n e1 = Base64_map.indexOf(input.charAt(i++));\n e2 = Base64_map.indexOf(input.charAt(i++));\n c1 = e1 << 2 | e2 >> 4;\n o += String.fromCharCode(c1);\n e3 = Base64_map.indexOf(input.charAt(i++));\n c2 = (e2 & 15) << 4 | e3 >> 2;\n if (e3 !== 64) {\n o += String.fromCharCode(c2);\n }\n e4 = Base64_map.indexOf(input.charAt(i++));\n c3 = (e3 & 3) << 6 | e4;\n if (e4 !== 64) {\n o += String.fromCharCode(c3);\n }\n }\n return o;\n}\nvar has_buf = /*#__PURE__*/function () {\n return typeof Buffer !== 'undefined' && typeof process !== 'undefined' && typeof process.versions !== 'undefined' && !!process.versions.node;\n}();\nvar Buffer_from = /*#__PURE__*/function () {\n if (typeof Buffer !== 'undefined') {\n var nbfs = !Buffer.from;\n if (!nbfs) try {\n Buffer.from(\"foo\", \"utf8\");\n } catch (e) {\n nbfs = true;\n }\n return nbfs ? function (buf, enc) {\n return enc ? new Buffer(buf, enc) : new Buffer(buf);\n } : Buffer.from.bind(Buffer);\n }\n return function () {};\n}();\nfunction new_raw_buf(len /*:number*/) {\n /* jshint -W056 */\n if (has_buf) return Buffer.alloc ? Buffer.alloc(len) : new Buffer(len);\n return typeof Uint8Array != \"undefined\" ? new Uint8Array(len) : new Array(len);\n /* jshint +W056 */\n}\nfunction new_unsafe_buf(len /*:number*/) {\n /* jshint -W056 */\n if (has_buf) return Buffer.allocUnsafe ? Buffer.allocUnsafe(len) : new Buffer(len);\n return typeof Uint8Array != \"undefined\" ? new Uint8Array(len) : new Array(len);\n /* jshint +W056 */\n}\nvar s2a = function s2a(s /*:string*/) /*:any*/{\n if (has_buf) return Buffer_from(s, \"binary\");\n return s.split(\"\").map(function (x /*:string*/) /*:number*/{\n return x.charCodeAt(0) & 0xff;\n });\n};\nfunction s2ab(s /*:string*/) /*:any*/{\n if (typeof ArrayBuffer === 'undefined') return s2a(s);\n var buf = new ArrayBuffer(s.length),\n view = new Uint8Array(buf);\n for (var i = 0; i != s.length; ++i) view[i] = s.charCodeAt(i) & 0xFF;\n return buf;\n}\nfunction a2s(data /*:any*/) /*:string*/{\n if (Array.isArray(data)) return data.map(function (c) {\n return String.fromCharCode(c);\n }).join(\"\");\n var o /*:Array*/ = [];\n for (var i = 0; i < data.length; ++i) o[i] = String.fromCharCode(data[i]);\n return o.join(\"\");\n}\nfunction a2u(data /*:Array*/) /*:Uint8Array*/{\n if (typeof Uint8Array === 'undefined') throw new Error(\"Unsupported\");\n return new Uint8Array(data);\n}\nfunction ab2a(data /*:ArrayBuffer|Uint8Array*/) /*:Array*/{\n if (typeof ArrayBuffer == 'undefined') throw new Error(\"Unsupported\");\n if (data instanceof ArrayBuffer) return ab2a(new Uint8Array(data));\n /*:: if(data instanceof ArrayBuffer) throw new Error(\"unreachable\"); */\n var o = new Array(data.length);\n for (var i = 0; i < data.length; ++i) o[i] = data[i];\n return o;\n}\nvar bconcat = has_buf ? function (bufs) {\n return Buffer.concat(bufs.map(function (buf) {\n return Buffer.isBuffer(buf) ? buf : Buffer_from(buf);\n }));\n} : function (bufs) {\n if (typeof Uint8Array !== \"undefined\") {\n var i = 0,\n maxlen = 0;\n for (i = 0; i < bufs.length; ++i) maxlen += bufs[i].length;\n var o = new Uint8Array(maxlen);\n var len = 0;\n for (i = 0, maxlen = 0; i < bufs.length; maxlen += len, ++i) {\n len = bufs[i].length;\n if (bufs[i] instanceof Uint8Array) o.set(bufs[i], maxlen);else if (typeof bufs[i] == \"string\") {\n throw \"wtf\";\n } else o.set(new Uint8Array(bufs[i]), maxlen);\n }\n return o;\n }\n return [].concat.apply([], bufs.map(function (buf) {\n return Array.isArray(buf) ? buf : [].slice.call(buf);\n }));\n};\nfunction utf8decode(content /*:string*/) {\n var out = [],\n widx = 0,\n L = content.length + 250;\n var o = new_raw_buf(content.length + 255);\n for (var ridx = 0; ridx < content.length; ++ridx) {\n var c = content.charCodeAt(ridx);\n if (c < 0x80) o[widx++] = c;else if (c < 0x800) {\n o[widx++] = 192 | c >> 6 & 31;\n o[widx++] = 128 | c & 63;\n } else if (c >= 0xD800 && c < 0xE000) {\n c = (c & 1023) + 64;\n var d = content.charCodeAt(++ridx) & 1023;\n o[widx++] = 240 | c >> 8 & 7;\n o[widx++] = 128 | c >> 2 & 63;\n o[widx++] = 128 | d >> 6 & 15 | (c & 3) << 4;\n o[widx++] = 128 | d & 63;\n } else {\n o[widx++] = 224 | c >> 12 & 15;\n o[widx++] = 128 | c >> 6 & 63;\n o[widx++] = 128 | c & 63;\n }\n if (widx > L) {\n out.push(o.slice(0, widx));\n widx = 0;\n o = new_raw_buf(65535);\n L = 65530;\n }\n }\n out.push(o.slice(0, widx));\n return bconcat(out);\n}\nvar chr0 = /\\u0000/g,\n chr1 = /[\\u0001-\\u0006]/g;\n/*::\ndeclare type Block = any;\ndeclare type BufArray = {\n\tnewblk(sz:number):Block;\n\tnext(sz:number):Block;\n\tend():any;\n\tpush(buf:Block):void;\n};\n\ntype RecordHopperCB = {(d:any, Rn:string, RT:number):?boolean;};\n\ntype EvertType = {[string]:string};\ntype EvertNumType = {[string]:number};\ntype EvertArrType = {[string]:Array};\n\ntype StringConv = {(string):string};\n\n*/\n/* ssf.js (C) 2013-present SheetJS -- http://sheetjs.com */\n/*jshint -W041 */\nfunction _strrev(x /*:string*/) /*:string*/{\n var o = \"\",\n i = x.length - 1;\n while (i >= 0) o += x.charAt(i--);\n return o;\n}\nfunction pad0(v /*:any*/, d /*:number*/) /*:string*/{\n var t = \"\" + v;\n return t.length >= d ? t : fill('0', d - t.length) + t;\n}\nfunction pad_(v /*:any*/, d /*:number*/) /*:string*/{\n var t = \"\" + v;\n return t.length >= d ? t : fill(' ', d - t.length) + t;\n}\nfunction rpad_(v /*:any*/, d /*:number*/) /*:string*/{\n var t = \"\" + v;\n return t.length >= d ? t : t + fill(' ', d - t.length);\n}\nfunction pad0r1(v /*:any*/, d /*:number*/) /*:string*/{\n var t = \"\" + Math.round(v);\n return t.length >= d ? t : fill('0', d - t.length) + t;\n}\nfunction pad0r2(v /*:any*/, d /*:number*/) /*:string*/{\n var t = \"\" + v;\n return t.length >= d ? t : fill('0', d - t.length) + t;\n}\nvar p2_32 = /*#__PURE__*/Math.pow(2, 32);\nfunction pad0r(v /*:any*/, d /*:number*/) /*:string*/{\n if (v > p2_32 || v < -p2_32) return pad0r1(v, d);\n var i = Math.round(v);\n return pad0r2(i, d);\n}\n/* yes, in 2022 this is still faster than string compare */\nfunction SSF_isgeneral(s /*:string*/, i /*:?number*/) /*:boolean*/{\n i = i || 0;\n return s.length >= 7 + i && (s.charCodeAt(i) | 32) === 103 && (s.charCodeAt(i + 1) | 32) === 101 && (s.charCodeAt(i + 2) | 32) === 110 && (s.charCodeAt(i + 3) | 32) === 101 && (s.charCodeAt(i + 4) | 32) === 114 && (s.charCodeAt(i + 5) | 32) === 97 && (s.charCodeAt(i + 6) | 32) === 108;\n}\nvar days /*:Array >*/ = [['Sun', 'Sunday'], ['Mon', 'Monday'], ['Tue', 'Tuesday'], ['Wed', 'Wednesday'], ['Thu', 'Thursday'], ['Fri', 'Friday'], ['Sat', 'Saturday']];\nvar months /*:Array >*/ = [['J', 'Jan', 'January'], ['F', 'Feb', 'February'], ['M', 'Mar', 'March'], ['A', 'Apr', 'April'], ['M', 'May', 'May'], ['J', 'Jun', 'June'], ['J', 'Jul', 'July'], ['A', 'Aug', 'August'], ['S', 'Sep', 'September'], ['O', 'Oct', 'October'], ['N', 'Nov', 'November'], ['D', 'Dec', 'December']];\nfunction SSF_init_table(t /*:any*/) {\n if (!t) t = {};\n t[0] = 'General';\n t[1] = '0';\n t[2] = '0.00';\n t[3] = '#,##0';\n t[4] = '#,##0.00';\n t[9] = '0%';\n t[10] = '0.00%';\n t[11] = '0.00E+00';\n t[12] = '# ?/?';\n t[13] = '# ??/??';\n t[14] = 'm/d/yy';\n t[15] = 'd-mmm-yy';\n t[16] = 'd-mmm';\n t[17] = 'mmm-yy';\n t[18] = 'h:mm AM/PM';\n t[19] = 'h:mm:ss AM/PM';\n t[20] = 'h:mm';\n t[21] = 'h:mm:ss';\n t[22] = 'm/d/yy h:mm';\n t[37] = '#,##0 ;(#,##0)';\n t[38] = '#,##0 ;[Red](#,##0)';\n t[39] = '#,##0.00;(#,##0.00)';\n t[40] = '#,##0.00;[Red](#,##0.00)';\n t[45] = 'mm:ss';\n t[46] = '[h]:mm:ss';\n t[47] = 'mmss.0';\n t[48] = '##0.0E+0';\n t[49] = '@';\n t[56] = '\"上午/下午 \"hh\"時\"mm\"分\"ss\"秒 \"';\n return t;\n}\n/* repeated to satiate webpack */\nvar table_fmt = {\n 0: 'General',\n 1: '0',\n 2: '0.00',\n 3: '#,##0',\n 4: '#,##0.00',\n 9: '0%',\n 10: '0.00%',\n 11: '0.00E+00',\n 12: '# ?/?',\n 13: '# ??/??',\n 14: 'm/d/yy',\n 15: 'd-mmm-yy',\n 16: 'd-mmm',\n 17: 'mmm-yy',\n 18: 'h:mm AM/PM',\n 19: 'h:mm:ss AM/PM',\n 20: 'h:mm',\n 21: 'h:mm:ss',\n 22: 'm/d/yy h:mm',\n 37: '#,##0 ;(#,##0)',\n 38: '#,##0 ;[Red](#,##0)',\n 39: '#,##0.00;(#,##0.00)',\n 40: '#,##0.00;[Red](#,##0.00)',\n 45: 'mm:ss',\n 46: '[h]:mm:ss',\n 47: 'mmss.0',\n 48: '##0.0E+0',\n 49: '@',\n 56: '\"上午/下午 \"hh\"時\"mm\"分\"ss\"秒 \"'\n};\n\n/* Defaults determined by systematically testing in Excel 2019 */\n\n/* These formats appear to default to other formats in the table */\nvar SSF_default_map = {\n 5: 37,\n 6: 38,\n 7: 39,\n 8: 40,\n // 5 -> 37 ... 8 -> 40\n\n 23: 0,\n 24: 0,\n 25: 0,\n 26: 0,\n // 23 -> 0 ... 26 -> 0\n\n 27: 14,\n 28: 14,\n 29: 14,\n 30: 14,\n 31: 14,\n // 27 -> 14 ... 31 -> 14\n\n 50: 14,\n 51: 14,\n 52: 14,\n 53: 14,\n 54: 14,\n // 50 -> 14 ... 58 -> 14\n 55: 14,\n 56: 14,\n 57: 14,\n 58: 14,\n 59: 1,\n 60: 2,\n 61: 3,\n 62: 4,\n // 59 -> 1 ... 62 -> 4\n\n 67: 9,\n 68: 10,\n // 67 -> 9 ... 68 -> 10\n 69: 12,\n 70: 13,\n 71: 14,\n // 69 -> 12 ... 71 -> 14\n 72: 14,\n 73: 15,\n 74: 16,\n 75: 17,\n // 72 -> 14 ... 75 -> 17\n 76: 20,\n 77: 21,\n 78: 22,\n // 76 -> 20 ... 78 -> 22\n 79: 45,\n 80: 46,\n 81: 47,\n // 79 -> 45 ... 81 -> 47\n 82: 0 // 82 -> 0 ... 65536 -> 0 (omitted)\n};\n\n/* These formats technically refer to Accounting formats with no equivalent */\nvar SSF_default_str = {\n // 5 -- Currency, 0 decimal, black negative\n 5: '\"$\"#,##0_);\\\\(\"$\"#,##0\\\\)',\n 63: '\"$\"#,##0_);\\\\(\"$\"#,##0\\\\)',\n // 6 -- Currency, 0 decimal, red negative\n 6: '\"$\"#,##0_);[Red]\\\\(\"$\"#,##0\\\\)',\n 64: '\"$\"#,##0_);[Red]\\\\(\"$\"#,##0\\\\)',\n // 7 -- Currency, 2 decimal, black negative\n 7: '\"$\"#,##0.00_);\\\\(\"$\"#,##0.00\\\\)',\n 65: '\"$\"#,##0.00_);\\\\(\"$\"#,##0.00\\\\)',\n // 8 -- Currency, 2 decimal, red negative\n 8: '\"$\"#,##0.00_);[Red]\\\\(\"$\"#,##0.00\\\\)',\n 66: '\"$\"#,##0.00_);[Red]\\\\(\"$\"#,##0.00\\\\)',\n // 41 -- Accounting, 0 decimal, No Symbol\n 41: '_(* #,##0_);_(* \\\\(#,##0\\\\);_(* \"-\"_);_(@_)',\n // 42 -- Accounting, 0 decimal, $ Symbol\n 42: '_(\"$\"* #,##0_);_(\"$\"* \\\\(#,##0\\\\);_(\"$\"* \"-\"_);_(@_)',\n // 43 -- Accounting, 2 decimal, No Symbol\n 43: '_(* #,##0.00_);_(* \\\\(#,##0.00\\\\);_(* \"-\"??_);_(@_)',\n // 44 -- Accounting, 2 decimal, $ Symbol\n 44: '_(\"$\"* #,##0.00_);_(\"$\"* \\\\(#,##0.00\\\\);_(\"$\"* \"-\"??_);_(@_)'\n};\nfunction SSF_frac(x /*:number*/, D /*:number*/, mixed /*:?boolean*/) /*:Array*/{\n var sgn = x < 0 ? -1 : 1;\n var B = x * sgn;\n var P_2 = 0,\n P_1 = 1,\n P = 0;\n var Q_2 = 1,\n Q_1 = 0,\n Q = 0;\n var A = Math.floor(B);\n while (Q_1 < D) {\n A = Math.floor(B);\n P = A * P_1 + P_2;\n Q = A * Q_1 + Q_2;\n if (B - A < 0.00000005) break;\n B = 1 / (B - A);\n P_2 = P_1;\n P_1 = P;\n Q_2 = Q_1;\n Q_1 = Q;\n }\n if (Q > D) {\n if (Q_1 > D) {\n Q = Q_2;\n P = P_2;\n } else {\n Q = Q_1;\n P = P_1;\n }\n }\n if (!mixed) return [0, sgn * P, Q];\n var q = Math.floor(sgn * P / Q);\n return [q, sgn * P - q * Q, Q];\n}\nfunction SSF_parse_date_code(v /*:number*/, opts /*:?any*/, b2 /*:?boolean*/) {\n if (v > 2958465 || v < 0) return null;\n var date = v | 0,\n time = Math.floor(86400 * (v - date)),\n dow = 0;\n var dout = [];\n var out = {\n D: date,\n T: time,\n u: 86400 * (v - date) - time,\n y: 0,\n m: 0,\n d: 0,\n H: 0,\n M: 0,\n S: 0,\n q: 0\n };\n if (Math.abs(out.u) < 1e-6) out.u = 0;\n if (opts && opts.date1904) date += 1462;\n if (out.u > 0.9999) {\n out.u = 0;\n if (++time == 86400) {\n out.T = time = 0;\n ++date;\n ++out.D;\n }\n }\n if (date === 60) {\n dout = b2 ? [1317, 10, 29] : [1900, 2, 29];\n dow = 3;\n } else if (date === 0) {\n dout = b2 ? [1317, 8, 29] : [1900, 1, 0];\n dow = 6;\n } else {\n if (date > 60) --date;\n /* 1 = Jan 1 1900 in Gregorian */\n var d = new Date(1900, 0, 1);\n d.setDate(d.getDate() + date - 1);\n dout = [d.getFullYear(), d.getMonth() + 1, d.getDate()];\n dow = d.getDay();\n if (date < 60) dow = (dow + 6) % 7;\n if (b2) dow = SSF_fix_hijri(d, dout);\n }\n out.y = dout[0];\n out.m = dout[1];\n out.d = dout[2];\n out.S = time % 60;\n time = Math.floor(time / 60);\n out.M = time % 60;\n time = Math.floor(time / 60);\n out.H = time;\n out.q = dow;\n return out;\n}\nvar SSFbasedate = /*#__PURE__*/new Date(1899, 11, 31, 0, 0, 0);\nvar SSFdnthresh = /*#__PURE__*/SSFbasedate.getTime();\nvar SSFbase1904 = /*#__PURE__*/new Date(1900, 2, 1, 0, 0, 0);\nfunction datenum_local(v /*:Date*/, date1904 /*:?boolean*/) /*:number*/{\n var epoch = /*#__PURE__*/v.getTime();\n if (date1904) epoch -= 1461 * 24 * 60 * 60 * 1000;else if (v >= SSFbase1904) epoch += 24 * 60 * 60 * 1000;\n return (epoch - (SSFdnthresh + (/*#__PURE__*/v.getTimezoneOffset() - /*#__PURE__*/SSFbasedate.getTimezoneOffset()) * 60000)) / (24 * 60 * 60 * 1000);\n}\n/* ECMA-376 18.8.30 numFmt*/\n/* Note: `toPrecision` uses standard form when prec > E and E >= -6 */\n/* exponent >= -9 and <= 9 */\nfunction SSF_strip_decimal(o /*:string*/) /*:string*/{\n return o.indexOf(\".\") == -1 ? o : o.replace(/(?:\\.0*|(\\.\\d*[1-9])0+)$/, \"$1\");\n}\n\n/* General Exponential always shows 2 digits exp and trims the mantissa */\nfunction SSF_normalize_exp(o /*:string*/) /*:string*/{\n if (o.indexOf(\"E\") == -1) return o;\n return o.replace(/(?:\\.0*|(\\.\\d*[1-9])0+)[Ee]/, \"$1E\").replace(/(E[+-])(\\d)$/, \"$10$2\");\n}\n\n/* exponent >= -9 and <= 9 */\nfunction SSF_small_exp(v /*:number*/) /*:string*/{\n var w = v < 0 ? 12 : 11;\n var o = SSF_strip_decimal(v.toFixed(12));\n if (o.length <= w) return o;\n o = v.toPrecision(10);\n if (o.length <= w) return o;\n return v.toExponential(5);\n}\n\n/* exponent >= 11 or <= -10 likely exponential */\nfunction SSF_large_exp(v /*:number*/) /*:string*/{\n var o = SSF_strip_decimal(v.toFixed(11));\n return o.length > (v < 0 ? 12 : 11) || o === \"0\" || o === \"-0\" ? v.toPrecision(6) : o;\n}\nfunction SSF_general_num(v /*:number*/) /*:string*/{\n var V = Math.floor(Math.log(Math.abs(v)) * Math.LOG10E),\n o;\n if (V >= -4 && V <= -1) o = v.toPrecision(10 + V);else if (Math.abs(V) <= 9) o = SSF_small_exp(v);else if (V === 10) o = v.toFixed(10).substr(0, 12);else o = SSF_large_exp(v);\n return SSF_strip_decimal(SSF_normalize_exp(o.toUpperCase()));\n}\n\n/*\n\t\"General\" rules:\n\t- text is passed through (\"@\")\n\t- booleans are rendered as TRUE/FALSE\n\t- \"up to 11 characters\" displayed for numbers\n\t- Default date format (code 14) used for Dates\n\n\tThe longest 32-bit integer text is \"-2147483648\", exactly 11 chars\n\tTODO: technically the display depends on the width of the cell\n*/\nfunction SSF_general(v /*:any*/, opts /*:any*/) {\n switch (typeof v) {\n case 'string':\n return v;\n case 'boolean':\n return v ? \"TRUE\" : \"FALSE\";\n case 'number':\n return (v | 0) === v ? v.toString(10) : SSF_general_num(v);\n case 'undefined':\n return \"\";\n case 'object':\n if (v == null) return \"\";\n if (v instanceof Date) return SSF_format(14, datenum_local(v, opts && opts.date1904), opts);\n }\n throw new Error(\"unsupported value in General format: \" + v);\n}\nfunction SSF_fix_hijri(date /*:Date*/, o /*:[number, number, number]*/) {\n /* TODO: properly adjust y/m/d and */\n o[0] -= 581;\n var dow = date.getDay();\n if (date < 60) dow = (dow + 6) % 7;\n return dow;\n}\n//var THAI_DIGITS = \"\\u0E50\\u0E51\\u0E52\\u0E53\\u0E54\\u0E55\\u0E56\\u0E57\\u0E58\\u0E59\".split(\"\");\nfunction SSF_write_date(type /*:number*/, fmt /*:string*/, val, ss0 /*:?number*/) /*:string*/{\n var o = \"\",\n ss = 0,\n tt = 0,\n y = val.y,\n out,\n outl = 0;\n switch (type) {\n case 98:\n /* 'b' buddhist year */\n y = val.y + 543;\n /* falls through */\n case 121:\n /* 'y' year */\n switch (fmt.length) {\n case 1:\n case 2:\n out = y % 100;\n outl = 2;\n break;\n default:\n out = y % 10000;\n outl = 4;\n break;\n }\n break;\n case 109:\n /* 'm' month */\n switch (fmt.length) {\n case 1:\n case 2:\n out = val.m;\n outl = fmt.length;\n break;\n case 3:\n return months[val.m - 1][1];\n case 5:\n return months[val.m - 1][0];\n default:\n return months[val.m - 1][2];\n }\n break;\n case 100:\n /* 'd' day */\n switch (fmt.length) {\n case 1:\n case 2:\n out = val.d;\n outl = fmt.length;\n break;\n case 3:\n return days[val.q][0];\n default:\n return days[val.q][1];\n }\n break;\n case 104:\n /* 'h' 12-hour */\n switch (fmt.length) {\n case 1:\n case 2:\n out = 1 + (val.H + 11) % 12;\n outl = fmt.length;\n break;\n default:\n throw 'bad hour format: ' + fmt;\n }\n break;\n case 72:\n /* 'H' 24-hour */\n switch (fmt.length) {\n case 1:\n case 2:\n out = val.H;\n outl = fmt.length;\n break;\n default:\n throw 'bad hour format: ' + fmt;\n }\n break;\n case 77:\n /* 'M' minutes */\n switch (fmt.length) {\n case 1:\n case 2:\n out = val.M;\n outl = fmt.length;\n break;\n default:\n throw 'bad minute format: ' + fmt;\n }\n break;\n case 115:\n /* 's' seconds */\n if (fmt != 's' && fmt != 'ss' && fmt != '.0' && fmt != '.00' && fmt != '.000') throw 'bad second format: ' + fmt;\n if (val.u === 0 && (fmt == \"s\" || fmt == \"ss\")) return pad0(val.S, fmt.length);\n /*::if(!ss0) ss0 = 0; */\n if (ss0 >= 2) tt = ss0 === 3 ? 1000 : 100;else tt = ss0 === 1 ? 10 : 1;\n ss = Math.round(tt * (val.S + val.u));\n if (ss >= 60 * tt) ss = 0;\n if (fmt === 's') return ss === 0 ? \"0\" : \"\" + ss / tt;\n o = pad0(ss, 2 + ss0);\n if (fmt === 'ss') return o.substr(0, 2);\n return \".\" + o.substr(2, fmt.length - 1);\n case 90:\n /* 'Z' absolute time */\n switch (fmt) {\n case '[h]':\n case '[hh]':\n out = val.D * 24 + val.H;\n break;\n case '[m]':\n case '[mm]':\n out = (val.D * 24 + val.H) * 60 + val.M;\n break;\n case '[s]':\n case '[ss]':\n out = ((val.D * 24 + val.H) * 60 + val.M) * 60 + Math.round(val.S + val.u);\n break;\n default:\n throw 'bad abstime format: ' + fmt;\n }\n outl = fmt.length === 3 ? 1 : 2;\n break;\n case 101:\n /* 'e' era */\n out = y;\n outl = 1;\n break;\n }\n var outstr = outl > 0 ? pad0(out, outl) : \"\";\n return outstr;\n}\n\n/*jshint -W086 */\n/*jshint +W086 */\nfunction commaify(s /*:string*/) /*:string*/{\n var w = 3;\n if (s.length <= w) return s;\n var j = s.length % w,\n o = s.substr(0, j);\n for (; j != s.length; j += w) o += (o.length > 0 ? \",\" : \"\") + s.substr(j, w);\n return o;\n}\nvar pct1 = /%/g;\nfunction write_num_pct(type /*:string*/, fmt /*:string*/, val /*:number*/) /*:string*/{\n var sfmt = fmt.replace(pct1, \"\"),\n mul = fmt.length - sfmt.length;\n return write_num(type, sfmt, val * Math.pow(10, 2 * mul)) + fill(\"%\", mul);\n}\nfunction write_num_cm(type /*:string*/, fmt /*:string*/, val /*:number*/) /*:string*/{\n var idx = fmt.length - 1;\n while (fmt.charCodeAt(idx - 1) === 44) --idx;\n return write_num(type, fmt.substr(0, idx), val / Math.pow(10, 3 * (fmt.length - idx)));\n}\nfunction write_num_exp(fmt /*:string*/, val /*:number*/) /*:string*/{\n var o /*:string*/;\n var idx = fmt.indexOf(\"E\") - fmt.indexOf(\".\") - 1;\n if (fmt.match(/^#+0.0E\\+0$/)) {\n if (val == 0) return \"0.0E+0\";else if (val < 0) return \"-\" + write_num_exp(fmt, -val);\n var period = fmt.indexOf(\".\");\n if (period === -1) period = fmt.indexOf('E');\n var ee = Math.floor(Math.log(val) * Math.LOG10E) % period;\n if (ee < 0) ee += period;\n o = (val / Math.pow(10, ee)).toPrecision(idx + 1 + (period + ee) % period);\n if (o.indexOf(\"e\") === -1) {\n var fakee = Math.floor(Math.log(val) * Math.LOG10E);\n if (o.indexOf(\".\") === -1) o = o.charAt(0) + \".\" + o.substr(1) + \"E+\" + (fakee - o.length + ee);else o += \"E+\" + (fakee - ee);\n while (o.substr(0, 2) === \"0.\") {\n o = o.charAt(0) + o.substr(2, period) + \".\" + o.substr(2 + period);\n o = o.replace(/^0+([1-9])/, \"$1\").replace(/^0+\\./, \"0.\");\n }\n o = o.replace(/\\+-/, \"-\");\n }\n o = o.replace(/^([+-]?)(\\d*)\\.(\\d*)[Ee]/, function ($$, $1, $2, $3) {\n return $1 + $2 + $3.substr(0, (period + ee) % period) + \".\" + $3.substr(ee) + \"E\";\n });\n } else o = val.toExponential(idx);\n if (fmt.match(/E\\+00$/) && o.match(/e[+-]\\d$/)) o = o.substr(0, o.length - 1) + \"0\" + o.charAt(o.length - 1);\n if (fmt.match(/E\\-/) && o.match(/e\\+/)) o = o.replace(/e\\+/, \"e\");\n return o.replace(\"e\", \"E\");\n}\nvar frac1 = /# (\\?+)( ?)\\/( ?)(\\d+)/;\nfunction write_num_f1(r /*:Array*/, aval /*:number*/, sign /*:string*/) /*:string*/{\n var den = parseInt(r[4], 10),\n rr = Math.round(aval * den),\n base = Math.floor(rr / den);\n var myn = rr - base * den,\n myd = den;\n return sign + (base === 0 ? \"\" : \"\" + base) + \" \" + (myn === 0 ? fill(\" \", r[1].length + 1 + r[4].length) : pad_(myn, r[1].length) + r[2] + \"/\" + r[3] + pad0(myd, r[4].length));\n}\nfunction write_num_f2(r /*:Array*/, aval /*:number*/, sign /*:string*/) /*:string*/{\n return sign + (aval === 0 ? \"\" : \"\" + aval) + fill(\" \", r[1].length + 2 + r[4].length);\n}\nvar dec1 = /^#*0*\\.([0#]+)/;\nvar closeparen = /\\).*[0#]/;\nvar phone = /\\(###\\) ###\\\\?-####/;\nfunction hashq(str /*:string*/) /*:string*/{\n var o = \"\",\n cc;\n for (var i = 0; i != str.length; ++i) switch (cc = str.charCodeAt(i)) {\n case 35:\n break;\n case 63:\n o += \" \";\n break;\n case 48:\n o += \"0\";\n break;\n default:\n o += String.fromCharCode(cc);\n }\n return o;\n}\nfunction rnd(val /*:number*/, d /*:number*/) /*:string*/{\n var dd = Math.pow(10, d);\n return \"\" + Math.round(val * dd) / dd;\n}\nfunction dec(val /*:number*/, d /*:number*/) /*:number*/{\n var _frac = val - Math.floor(val),\n dd = Math.pow(10, d);\n if (d < ('' + Math.round(_frac * dd)).length) return 0;\n return Math.round(_frac * dd);\n}\nfunction carry(val /*:number*/, d /*:number*/) /*:number*/{\n if (d < ('' + Math.round((val - Math.floor(val)) * Math.pow(10, d))).length) {\n return 1;\n }\n return 0;\n}\nfunction flr(val /*:number*/) /*:string*/{\n if (val < 2147483647 && val > -2147483648) return \"\" + (val >= 0 ? val | 0 : val - 1 | 0);\n return \"\" + Math.floor(val);\n}\nfunction write_num_flt(type /*:string*/, fmt /*:string*/, val /*:number*/) /*:string*/{\n if (type.charCodeAt(0) === 40 && !fmt.match(closeparen)) {\n var ffmt = fmt.replace(/\\( */, \"\").replace(/ \\)/, \"\").replace(/\\)/, \"\");\n if (val >= 0) return write_num_flt('n', ffmt, val);\n return '(' + write_num_flt('n', ffmt, -val) + ')';\n }\n if (fmt.charCodeAt(fmt.length - 1) === 44) return write_num_cm(type, fmt, val);\n if (fmt.indexOf('%') !== -1) return write_num_pct(type, fmt, val);\n if (fmt.indexOf('E') !== -1) return write_num_exp(fmt, val);\n if (fmt.charCodeAt(0) === 36) return \"$\" + write_num_flt(type, fmt.substr(fmt.charAt(1) == ' ' ? 2 : 1), val);\n var o;\n var r /*:?Array*/,\n ri,\n ff,\n aval = Math.abs(val),\n sign = val < 0 ? \"-\" : \"\";\n if (fmt.match(/^00+$/)) return sign + pad0r(aval, fmt.length);\n if (fmt.match(/^[#?]+$/)) {\n o = pad0r(val, 0);\n if (o === \"0\") o = \"\";\n return o.length > fmt.length ? o : hashq(fmt.substr(0, fmt.length - o.length)) + o;\n }\n if (r = fmt.match(frac1)) return write_num_f1(r, aval, sign);\n if (fmt.match(/^#+0+$/)) return sign + pad0r(aval, fmt.length - fmt.indexOf(\"0\"));\n if (r = fmt.match(dec1)) {\n o = rnd(val, r[1].length).replace(/^([^\\.]+)$/, \"$1.\" + hashq(r[1])).replace(/\\.$/, \".\" + hashq(r[1])).replace(/\\.(\\d*)$/, function ($$, $1) {\n return \".\" + $1 + fill(\"0\", hashq(/*::(*/r /*::||[\"\"])*/[1]).length - $1.length);\n });\n return fmt.indexOf(\"0.\") !== -1 ? o : o.replace(/^0\\./, \".\");\n }\n fmt = fmt.replace(/^#+([0.])/, \"$1\");\n if (r = fmt.match(/^(0*)\\.(#*)$/)) {\n return sign + rnd(aval, r[2].length).replace(/\\.(\\d*[1-9])0*$/, \".$1\").replace(/^(-?\\d*)$/, \"$1.\").replace(/^0\\./, r[1].length ? \"0.\" : \".\");\n }\n if (r = fmt.match(/^#{1,3},##0(\\.?)$/)) return sign + commaify(pad0r(aval, 0));\n if (r = fmt.match(/^#,##0\\.([#0]*0)$/)) {\n return val < 0 ? \"-\" + write_num_flt(type, fmt, -val) : commaify(\"\" + (Math.floor(val) + carry(val, r[1].length))) + \".\" + pad0(dec(val, r[1].length), r[1].length);\n }\n if (r = fmt.match(/^#,#*,#0/)) return write_num_flt(type, fmt.replace(/^#,#*,/, \"\"), val);\n if (r = fmt.match(/^([0#]+)(\\\\?-([0#]+))+$/)) {\n o = _strrev(write_num_flt(type, fmt.replace(/[\\\\-]/g, \"\"), val));\n ri = 0;\n return _strrev(_strrev(fmt.replace(/\\\\/g, \"\")).replace(/[0#]/g, function (x) {\n return ri < o.length ? o.charAt(ri++) : x === '0' ? '0' : \"\";\n }));\n }\n if (fmt.match(phone)) {\n o = write_num_flt(type, \"##########\", val);\n return \"(\" + o.substr(0, 3) + \") \" + o.substr(3, 3) + \"-\" + o.substr(6);\n }\n var oa = \"\";\n if (r = fmt.match(/^([#0?]+)( ?)\\/( ?)([#0?]+)/)) {\n ri = Math.min(/*::String(*/r[4] /*::)*/.length, 7);\n ff = SSF_frac(aval, Math.pow(10, ri) - 1, false);\n o = \"\" + sign;\n oa = write_num(\"n\", /*::String(*/r[1] /*::)*/, ff[1]);\n if (oa.charAt(oa.length - 1) == \" \") oa = oa.substr(0, oa.length - 1) + \"0\";\n o += oa + /*::String(*/r[2] /*::)*/ + \"/\" + /*::String(*/r[3] /*::)*/;\n oa = rpad_(ff[2], ri);\n if (oa.length < r[4].length) oa = hashq(r[4].substr(r[4].length - oa.length)) + oa;\n o += oa;\n return o;\n }\n if (r = fmt.match(/^# ([#0?]+)( ?)\\/( ?)([#0?]+)/)) {\n ri = Math.min(Math.max(r[1].length, r[4].length), 7);\n ff = SSF_frac(aval, Math.pow(10, ri) - 1, true);\n return sign + (ff[0] || (ff[1] ? \"\" : \"0\")) + \" \" + (ff[1] ? pad_(ff[1], ri) + r[2] + \"/\" + r[3] + rpad_(ff[2], ri) : fill(\" \", 2 * ri + 1 + r[2].length + r[3].length));\n }\n if (r = fmt.match(/^[#0?]+$/)) {\n o = pad0r(val, 0);\n if (fmt.length <= o.length) return o;\n return hashq(fmt.substr(0, fmt.length - o.length)) + o;\n }\n if (r = fmt.match(/^([#0?]+)\\.([#0]+)$/)) {\n o = \"\" + val.toFixed(Math.min(r[2].length, 10)).replace(/([^0])0+$/, \"$1\");\n ri = o.indexOf(\".\");\n var lres = fmt.indexOf(\".\") - ri,\n rres = fmt.length - o.length - lres;\n return hashq(fmt.substr(0, lres) + o + fmt.substr(fmt.length - rres));\n }\n if (r = fmt.match(/^00,000\\.([#0]*0)$/)) {\n ri = dec(val, r[1].length);\n return val < 0 ? \"-\" + write_num_flt(type, fmt, -val) : commaify(flr(val)).replace(/^\\d,\\d{3}$/, \"0$&\").replace(/^\\d*$/, function ($$) {\n return \"00,\" + ($$.length < 3 ? pad0(0, 3 - $$.length) : \"\") + $$;\n }) + \".\" + pad0(ri, r[1].length);\n }\n switch (fmt) {\n case \"###,##0.00\":\n return write_num_flt(type, \"#,##0.00\", val);\n case \"###,###\":\n case \"##,###\":\n case \"#,###\":\n var x = commaify(pad0r(aval, 0));\n return x !== \"0\" ? sign + x : \"\";\n case \"###,###.00\":\n return write_num_flt(type, \"###,##0.00\", val).replace(/^0\\./, \".\");\n case \"#,###.00\":\n return write_num_flt(type, \"#,##0.00\", val).replace(/^0\\./, \".\");\n default:\n }\n throw new Error(\"unsupported format |\" + fmt + \"|\");\n}\nfunction write_num_cm2(type /*:string*/, fmt /*:string*/, val /*:number*/) /*:string*/{\n var idx = fmt.length - 1;\n while (fmt.charCodeAt(idx - 1) === 44) --idx;\n return write_num(type, fmt.substr(0, idx), val / Math.pow(10, 3 * (fmt.length - idx)));\n}\nfunction write_num_pct2(type /*:string*/, fmt /*:string*/, val /*:number*/) /*:string*/{\n var sfmt = fmt.replace(pct1, \"\"),\n mul = fmt.length - sfmt.length;\n return write_num(type, sfmt, val * Math.pow(10, 2 * mul)) + fill(\"%\", mul);\n}\nfunction write_num_exp2(fmt /*:string*/, val /*:number*/) /*:string*/{\n var o /*:string*/;\n var idx = fmt.indexOf(\"E\") - fmt.indexOf(\".\") - 1;\n if (fmt.match(/^#+0.0E\\+0$/)) {\n if (val == 0) return \"0.0E+0\";else if (val < 0) return \"-\" + write_num_exp2(fmt, -val);\n var period = fmt.indexOf(\".\");\n if (period === -1) period = fmt.indexOf('E');\n var ee = Math.floor(Math.log(val) * Math.LOG10E) % period;\n if (ee < 0) ee += period;\n o = (val / Math.pow(10, ee)).toPrecision(idx + 1 + (period + ee) % period);\n if (!o.match(/[Ee]/)) {\n var fakee = Math.floor(Math.log(val) * Math.LOG10E);\n if (o.indexOf(\".\") === -1) o = o.charAt(0) + \".\" + o.substr(1) + \"E+\" + (fakee - o.length + ee);else o += \"E+\" + (fakee - ee);\n o = o.replace(/\\+-/, \"-\");\n }\n o = o.replace(/^([+-]?)(\\d*)\\.(\\d*)[Ee]/, function ($$, $1, $2, $3) {\n return $1 + $2 + $3.substr(0, (period + ee) % period) + \".\" + $3.substr(ee) + \"E\";\n });\n } else o = val.toExponential(idx);\n if (fmt.match(/E\\+00$/) && o.match(/e[+-]\\d$/)) o = o.substr(0, o.length - 1) + \"0\" + o.charAt(o.length - 1);\n if (fmt.match(/E\\-/) && o.match(/e\\+/)) o = o.replace(/e\\+/, \"e\");\n return o.replace(\"e\", \"E\");\n}\nfunction write_num_int(type /*:string*/, fmt /*:string*/, val /*:number*/) /*:string*/{\n if (type.charCodeAt(0) === 40 && !fmt.match(closeparen)) {\n var ffmt = fmt.replace(/\\( */, \"\").replace(/ \\)/, \"\").replace(/\\)/, \"\");\n if (val >= 0) return write_num_int('n', ffmt, val);\n return '(' + write_num_int('n', ffmt, -val) + ')';\n }\n if (fmt.charCodeAt(fmt.length - 1) === 44) return write_num_cm2(type, fmt, val);\n if (fmt.indexOf('%') !== -1) return write_num_pct2(type, fmt, val);\n if (fmt.indexOf('E') !== -1) return write_num_exp2(fmt, val);\n if (fmt.charCodeAt(0) === 36) return \"$\" + write_num_int(type, fmt.substr(fmt.charAt(1) == ' ' ? 2 : 1), val);\n var o;\n var r /*:?Array*/,\n ri,\n ff,\n aval = Math.abs(val),\n sign = val < 0 ? \"-\" : \"\";\n if (fmt.match(/^00+$/)) return sign + pad0(aval, fmt.length);\n if (fmt.match(/^[#?]+$/)) {\n o = \"\" + val;\n if (val === 0) o = \"\";\n return o.length > fmt.length ? o : hashq(fmt.substr(0, fmt.length - o.length)) + o;\n }\n if (r = fmt.match(frac1)) return write_num_f2(r, aval, sign);\n if (fmt.match(/^#+0+$/)) return sign + pad0(aval, fmt.length - fmt.indexOf(\"0\"));\n if (r = fmt.match(dec1)) {\n /*:: if(!Array.isArray(r)) throw new Error(\"unreachable\"); */\n o = (\"\" + val).replace(/^([^\\.]+)$/, \"$1.\" + hashq(r[1])).replace(/\\.$/, \".\" + hashq(r[1]));\n o = o.replace(/\\.(\\d*)$/, function ($$, $1) {\n /*:: if(!Array.isArray(r)) throw new Error(\"unreachable\"); */\n return \".\" + $1 + fill(\"0\", hashq(r[1]).length - $1.length);\n });\n return fmt.indexOf(\"0.\") !== -1 ? o : o.replace(/^0\\./, \".\");\n }\n fmt = fmt.replace(/^#+([0.])/, \"$1\");\n if (r = fmt.match(/^(0*)\\.(#*)$/)) {\n return sign + (\"\" + aval).replace(/\\.(\\d*[1-9])0*$/, \".$1\").replace(/^(-?\\d*)$/, \"$1.\").replace(/^0\\./, r[1].length ? \"0.\" : \".\");\n }\n if (r = fmt.match(/^#{1,3},##0(\\.?)$/)) return sign + commaify(\"\" + aval);\n if (r = fmt.match(/^#,##0\\.([#0]*0)$/)) {\n return val < 0 ? \"-\" + write_num_int(type, fmt, -val) : commaify(\"\" + val) + \".\" + fill('0', r[1].length);\n }\n if (r = fmt.match(/^#,#*,#0/)) return write_num_int(type, fmt.replace(/^#,#*,/, \"\"), val);\n if (r = fmt.match(/^([0#]+)(\\\\?-([0#]+))+$/)) {\n o = _strrev(write_num_int(type, fmt.replace(/[\\\\-]/g, \"\"), val));\n ri = 0;\n return _strrev(_strrev(fmt.replace(/\\\\/g, \"\")).replace(/[0#]/g, function (x) {\n return ri < o.length ? o.charAt(ri++) : x === '0' ? '0' : \"\";\n }));\n }\n if (fmt.match(phone)) {\n o = write_num_int(type, \"##########\", val);\n return \"(\" + o.substr(0, 3) + \") \" + o.substr(3, 3) + \"-\" + o.substr(6);\n }\n var oa = \"\";\n if (r = fmt.match(/^([#0?]+)( ?)\\/( ?)([#0?]+)/)) {\n ri = Math.min(/*::String(*/r[4] /*::)*/.length, 7);\n ff = SSF_frac(aval, Math.pow(10, ri) - 1, false);\n o = \"\" + sign;\n oa = write_num(\"n\", /*::String(*/r[1] /*::)*/, ff[1]);\n if (oa.charAt(oa.length - 1) == \" \") oa = oa.substr(0, oa.length - 1) + \"0\";\n o += oa + /*::String(*/r[2] /*::)*/ + \"/\" + /*::String(*/r[3] /*::)*/;\n oa = rpad_(ff[2], ri);\n if (oa.length < r[4].length) oa = hashq(r[4].substr(r[4].length - oa.length)) + oa;\n o += oa;\n return o;\n }\n if (r = fmt.match(/^# ([#0?]+)( ?)\\/( ?)([#0?]+)/)) {\n ri = Math.min(Math.max(r[1].length, r[4].length), 7);\n ff = SSF_frac(aval, Math.pow(10, ri) - 1, true);\n return sign + (ff[0] || (ff[1] ? \"\" : \"0\")) + \" \" + (ff[1] ? pad_(ff[1], ri) + r[2] + \"/\" + r[3] + rpad_(ff[2], ri) : fill(\" \", 2 * ri + 1 + r[2].length + r[3].length));\n }\n if (r = fmt.match(/^[#0?]+$/)) {\n o = \"\" + val;\n if (fmt.length <= o.length) return o;\n return hashq(fmt.substr(0, fmt.length - o.length)) + o;\n }\n if (r = fmt.match(/^([#0]+)\\.([#0]+)$/)) {\n o = \"\" + val.toFixed(Math.min(r[2].length, 10)).replace(/([^0])0+$/, \"$1\");\n ri = o.indexOf(\".\");\n var lres = fmt.indexOf(\".\") - ri,\n rres = fmt.length - o.length - lres;\n return hashq(fmt.substr(0, lres) + o + fmt.substr(fmt.length - rres));\n }\n if (r = fmt.match(/^00,000\\.([#0]*0)$/)) {\n return val < 0 ? \"-\" + write_num_int(type, fmt, -val) : commaify(\"\" + val).replace(/^\\d,\\d{3}$/, \"0$&\").replace(/^\\d*$/, function ($$) {\n return \"00,\" + ($$.length < 3 ? pad0(0, 3 - $$.length) : \"\") + $$;\n }) + \".\" + pad0(0, r[1].length);\n }\n switch (fmt) {\n case \"###,###\":\n case \"##,###\":\n case \"#,###\":\n var x = commaify(\"\" + aval);\n return x !== \"0\" ? sign + x : \"\";\n default:\n if (fmt.match(/\\.[0#?]*$/)) return write_num_int(type, fmt.slice(0, fmt.lastIndexOf(\".\")), val) + hashq(fmt.slice(fmt.lastIndexOf(\".\")));\n }\n throw new Error(\"unsupported format |\" + fmt + \"|\");\n}\nfunction write_num(type /*:string*/, fmt /*:string*/, val /*:number*/) /*:string*/{\n return (val | 0) === val ? write_num_int(type, fmt, val) : write_num_flt(type, fmt, val);\n}\nfunction SSF_split_fmt(fmt /*:string*/) /*:Array*/{\n var out /*:Array*/ = [];\n var in_str = false /*, cc*/;\n for (var i = 0, j = 0; i < fmt.length; ++i) switch ((/*cc=*/fmt.charCodeAt(i))) {\n case 34:\n /* '\"' */\n in_str = !in_str;\n break;\n case 95:\n case 42:\n case 92:\n /* '_' '*' '\\\\' */\n ++i;\n break;\n case 59:\n /* ';' */\n out[out.length] = fmt.substr(j, i - j);\n j = i + 1;\n }\n out[out.length] = fmt.substr(j);\n if (in_str === true) throw new Error(\"Format |\" + fmt + \"| unterminated string \");\n return out;\n}\nvar SSF_abstime = /\\[[HhMmSs\\u0E0A\\u0E19\\u0E17]*\\]/;\nfunction fmt_is_date(fmt /*:string*/) /*:boolean*/{\n var i = 0,\n /*cc = 0,*/c = \"\",\n o = \"\";\n while (i < fmt.length) {\n switch (c = fmt.charAt(i)) {\n case 'G':\n if (SSF_isgeneral(fmt, i)) i += 6;\n i++;\n break;\n case '\"':\n for (; (/*cc=*/fmt.charCodeAt(++i)) !== 34 && i < fmt.length;) {/*empty*/}\n ++i;\n break;\n case '\\\\':\n i += 2;\n break;\n case '_':\n i += 2;\n break;\n case '@':\n ++i;\n break;\n case 'B':\n case 'b':\n if (fmt.charAt(i + 1) === \"1\" || fmt.charAt(i + 1) === \"2\") return true;\n /* falls through */\n case 'M':\n case 'D':\n case 'Y':\n case 'H':\n case 'S':\n case 'E':\n /* falls through */\n case 'm':\n case 'd':\n case 'y':\n case 'h':\n case 's':\n case 'e':\n case 'g':\n return true;\n case 'A':\n case 'a':\n case '上':\n if (fmt.substr(i, 3).toUpperCase() === \"A/P\") return true;\n if (fmt.substr(i, 5).toUpperCase() === \"AM/PM\") return true;\n if (fmt.substr(i, 5).toUpperCase() === \"上午/下午\") return true;\n ++i;\n break;\n case '[':\n o = c;\n while (fmt.charAt(i++) !== ']' && i < fmt.length) o += fmt.charAt(i);\n if (o.match(SSF_abstime)) return true;\n break;\n case '.':\n /* falls through */\n case '0':\n case '#':\n while (i < fmt.length && (\"0#?.,E+-%\".indexOf(c = fmt.charAt(++i)) > -1 || c == '\\\\' && fmt.charAt(i + 1) == \"-\" && \"0#\".indexOf(fmt.charAt(i + 2)) > -1)) {/* empty */}\n break;\n case '?':\n while (fmt.charAt(++i) === c) {/* empty */}\n break;\n case '*':\n ++i;\n if (fmt.charAt(i) == ' ' || fmt.charAt(i) == '*') ++i;\n break;\n case '(':\n case ')':\n ++i;\n break;\n case '1':\n case '2':\n case '3':\n case '4':\n case '5':\n case '6':\n case '7':\n case '8':\n case '9':\n while (i < fmt.length && \"0123456789\".indexOf(fmt.charAt(++i)) > -1) {/* empty */}\n break;\n case ' ':\n ++i;\n break;\n default:\n ++i;\n break;\n }\n }\n return false;\n}\nfunction eval_fmt(fmt /*:string*/, v /*:any*/, opts /*:any*/, flen /*:number*/) {\n var out = [],\n o = \"\",\n i = 0,\n c = \"\",\n lst = 't',\n dt,\n j,\n cc;\n var hr = 'H';\n /* Tokenize */\n while (i < fmt.length) {\n switch (c = fmt.charAt(i)) {\n case 'G':\n /* General */\n if (!SSF_isgeneral(fmt, i)) throw new Error('unrecognized character ' + c + ' in ' + fmt);\n out[out.length] = {\n t: 'G',\n v: 'General'\n };\n i += 7;\n break;\n case '\"':\n /* Literal text */\n for (o = \"\"; (cc = fmt.charCodeAt(++i)) !== 34 && i < fmt.length;) o += String.fromCharCode(cc);\n out[out.length] = {\n t: 't',\n v: o\n };\n ++i;\n break;\n case '\\\\':\n var w = fmt.charAt(++i),\n t = w === \"(\" || w === \")\" ? w : 't';\n out[out.length] = {\n t: t,\n v: w\n };\n ++i;\n break;\n case '_':\n out[out.length] = {\n t: 't',\n v: \" \"\n };\n i += 2;\n break;\n case '@':\n /* Text Placeholder */\n out[out.length] = {\n t: 'T',\n v: v\n };\n ++i;\n break;\n case 'B':\n case 'b':\n if (fmt.charAt(i + 1) === \"1\" || fmt.charAt(i + 1) === \"2\") {\n if (dt == null) {\n dt = SSF_parse_date_code(v, opts, fmt.charAt(i + 1) === \"2\");\n if (dt == null) return \"\";\n }\n out[out.length] = {\n t: 'X',\n v: fmt.substr(i, 2)\n };\n lst = c;\n i += 2;\n break;\n }\n /* falls through */\n case 'M':\n case 'D':\n case 'Y':\n case 'H':\n case 'S':\n case 'E':\n c = c.toLowerCase();\n /* falls through */\n case 'm':\n case 'd':\n case 'y':\n case 'h':\n case 's':\n case 'e':\n case 'g':\n if (v < 0) return \"\";\n if (dt == null) {\n dt = SSF_parse_date_code(v, opts);\n if (dt == null) return \"\";\n }\n o = c;\n while (++i < fmt.length && fmt.charAt(i).toLowerCase() === c) o += c;\n if (c === 'm' && lst.toLowerCase() === 'h') c = 'M';\n if (c === 'h') c = hr;\n out[out.length] = {\n t: c,\n v: o\n };\n lst = c;\n break;\n case 'A':\n case 'a':\n case '上':\n var q = {\n t: c,\n v: c\n };\n if (dt == null) dt = SSF_parse_date_code(v, opts);\n if (fmt.substr(i, 3).toUpperCase() === \"A/P\") {\n if (dt != null) q.v = dt.H >= 12 ? \"P\" : \"A\";\n q.t = 'T';\n hr = 'h';\n i += 3;\n } else if (fmt.substr(i, 5).toUpperCase() === \"AM/PM\") {\n if (dt != null) q.v = dt.H >= 12 ? \"PM\" : \"AM\";\n q.t = 'T';\n i += 5;\n hr = 'h';\n } else if (fmt.substr(i, 5).toUpperCase() === \"上午/下午\") {\n if (dt != null) q.v = dt.H >= 12 ? \"下午\" : \"上午\";\n q.t = 'T';\n i += 5;\n hr = 'h';\n } else {\n q.t = \"t\";\n ++i;\n }\n if (dt == null && q.t === 'T') return \"\";\n out[out.length] = q;\n lst = c;\n break;\n case '[':\n o = c;\n while (fmt.charAt(i++) !== ']' && i < fmt.length) o += fmt.charAt(i);\n if (o.slice(-1) !== ']') throw 'unterminated \"[\" block: |' + o + '|';\n if (o.match(SSF_abstime)) {\n if (dt == null) {\n dt = SSF_parse_date_code(v, opts);\n if (dt == null) return \"\";\n }\n out[out.length] = {\n t: 'Z',\n v: o.toLowerCase()\n };\n lst = o.charAt(1);\n } else if (o.indexOf(\"$\") > -1) {\n o = (o.match(/\\$([^-\\[\\]]*)/) || [])[1] || \"$\";\n if (!fmt_is_date(fmt)) out[out.length] = {\n t: 't',\n v: o\n };\n }\n break;\n /* Numbers */\n case '.':\n if (dt != null) {\n o = c;\n while (++i < fmt.length && (c = fmt.charAt(i)) === \"0\") o += c;\n out[out.length] = {\n t: 's',\n v: o\n };\n break;\n }\n /* falls through */\n case '0':\n case '#':\n o = c;\n while (++i < fmt.length && \"0#?.,E+-%\".indexOf(c = fmt.charAt(i)) > -1) o += c;\n out[out.length] = {\n t: 'n',\n v: o\n };\n break;\n case '?':\n o = c;\n while (fmt.charAt(++i) === c) o += c;\n out[out.length] = {\n t: c,\n v: o\n };\n lst = c;\n break;\n case '*':\n ++i;\n if (fmt.charAt(i) == ' ' || fmt.charAt(i) == '*') ++i;\n break;\n // **\n case '(':\n case ')':\n out[out.length] = {\n t: flen === 1 ? 't' : c,\n v: c\n };\n ++i;\n break;\n case '1':\n case '2':\n case '3':\n case '4':\n case '5':\n case '6':\n case '7':\n case '8':\n case '9':\n o = c;\n while (i < fmt.length && \"0123456789\".indexOf(fmt.charAt(++i)) > -1) o += fmt.charAt(i);\n out[out.length] = {\n t: 'D',\n v: o\n };\n break;\n case ' ':\n out[out.length] = {\n t: c,\n v: c\n };\n ++i;\n break;\n case '$':\n out[out.length] = {\n t: 't',\n v: '$'\n };\n ++i;\n break;\n default:\n if (\",$-+/():!^&'~{}<>=€acfijklopqrtuvwxzP\".indexOf(c) === -1) throw new Error('unrecognized character ' + c + ' in ' + fmt);\n out[out.length] = {\n t: 't',\n v: c\n };\n ++i;\n break;\n }\n }\n\n /* Scan for date/time parts */\n var bt = 0,\n ss0 = 0,\n ssm;\n for (i = out.length - 1, lst = 't'; i >= 0; --i) {\n switch (out[i].t) {\n case 'h':\n case 'H':\n out[i].t = hr;\n lst = 'h';\n if (bt < 1) bt = 1;\n break;\n case 's':\n if (ssm = out[i].v.match(/\\.0+$/)) ss0 = Math.max(ss0, ssm[0].length - 1);\n if (bt < 3) bt = 3;\n /* falls through */\n case 'd':\n case 'y':\n case 'M':\n case 'e':\n lst = out[i].t;\n break;\n case 'm':\n if (lst === 's') {\n out[i].t = 'M';\n if (bt < 2) bt = 2;\n }\n break;\n case 'X':\n /*if(out[i].v === \"B2\");*/\n break;\n case 'Z':\n if (bt < 1 && out[i].v.match(/[Hh]/)) bt = 1;\n if (bt < 2 && out[i].v.match(/[Mm]/)) bt = 2;\n if (bt < 3 && out[i].v.match(/[Ss]/)) bt = 3;\n }\n }\n /* time rounding depends on presence of minute / second / usec fields */\n switch (bt) {\n case 0:\n break;\n case 1:\n /*::if(!dt) break;*/\n if (dt.u >= 0.5) {\n dt.u = 0;\n ++dt.S;\n }\n if (dt.S >= 60) {\n dt.S = 0;\n ++dt.M;\n }\n if (dt.M >= 60) {\n dt.M = 0;\n ++dt.H;\n }\n break;\n case 2:\n /*::if(!dt) break;*/\n if (dt.u >= 0.5) {\n dt.u = 0;\n ++dt.S;\n }\n if (dt.S >= 60) {\n dt.S = 0;\n ++dt.M;\n }\n break;\n }\n\n /* replace fields */\n var nstr = \"\",\n jj;\n for (i = 0; i < out.length; ++i) {\n switch (out[i].t) {\n case 't':\n case 'T':\n case ' ':\n case 'D':\n break;\n case 'X':\n out[i].v = \"\";\n out[i].t = \";\";\n break;\n case 'd':\n case 'm':\n case 'y':\n case 'h':\n case 'H':\n case 'M':\n case 's':\n case 'e':\n case 'b':\n case 'Z':\n /*::if(!dt) throw \"unreachable\"; */\n out[i].v = SSF_write_date(out[i].t.charCodeAt(0), out[i].v, dt, ss0);\n out[i].t = 't';\n break;\n case 'n':\n case '?':\n jj = i + 1;\n while (out[jj] != null && ((c = out[jj].t) === \"?\" || c === \"D\" || (c === \" \" || c === \"t\") && out[jj + 1] != null && (out[jj + 1].t === '?' || out[jj + 1].t === \"t\" && out[jj + 1].v === '/') || out[i].t === '(' && (c === ' ' || c === 'n' || c === ')') || c === 't' && (out[jj].v === '/' || out[jj].v === ' ' && out[jj + 1] != null && out[jj + 1].t == '?'))) {\n out[i].v += out[jj].v;\n out[jj] = {\n v: \"\",\n t: \";\"\n };\n ++jj;\n }\n nstr += out[i].v;\n i = jj - 1;\n break;\n case 'G':\n out[i].t = 't';\n out[i].v = SSF_general(v, opts);\n break;\n }\n }\n var vv = \"\",\n myv,\n ostr;\n if (nstr.length > 0) {\n if (nstr.charCodeAt(0) == 40) /* '(' */{\n myv = v < 0 && nstr.charCodeAt(0) === 45 ? -v : v;\n ostr = write_num('n', nstr, myv);\n } else {\n myv = v < 0 && flen > 1 ? -v : v;\n ostr = write_num('n', nstr, myv);\n if (myv < 0 && out[0] && out[0].t == 't') {\n ostr = ostr.substr(1);\n out[0].v = \"-\" + out[0].v;\n }\n }\n jj = ostr.length - 1;\n var decpt = out.length;\n for (i = 0; i < out.length; ++i) if (out[i] != null && out[i].t != 't' && out[i].v.indexOf(\".\") > -1) {\n decpt = i;\n break;\n }\n var lasti = out.length;\n if (decpt === out.length && ostr.indexOf(\"E\") === -1) {\n for (i = out.length - 1; i >= 0; --i) {\n if (out[i] == null || 'n?'.indexOf(out[i].t) === -1) continue;\n if (jj >= out[i].v.length - 1) {\n jj -= out[i].v.length;\n out[i].v = ostr.substr(jj + 1, out[i].v.length);\n } else if (jj < 0) out[i].v = \"\";else {\n out[i].v = ostr.substr(0, jj + 1);\n jj = -1;\n }\n out[i].t = 't';\n lasti = i;\n }\n if (jj >= 0 && lasti < out.length) out[lasti].v = ostr.substr(0, jj + 1) + out[lasti].v;\n } else if (decpt !== out.length && ostr.indexOf(\"E\") === -1) {\n jj = ostr.indexOf(\".\") - 1;\n for (i = decpt; i >= 0; --i) {\n if (out[i] == null || 'n?'.indexOf(out[i].t) === -1) continue;\n j = out[i].v.indexOf(\".\") > -1 && i === decpt ? out[i].v.indexOf(\".\") - 1 : out[i].v.length - 1;\n vv = out[i].v.substr(j + 1);\n for (; j >= 0; --j) {\n if (jj >= 0 && (out[i].v.charAt(j) === \"0\" || out[i].v.charAt(j) === \"#\")) vv = ostr.charAt(jj--) + vv;\n }\n out[i].v = vv;\n out[i].t = 't';\n lasti = i;\n }\n if (jj >= 0 && lasti < out.length) out[lasti].v = ostr.substr(0, jj + 1) + out[lasti].v;\n jj = ostr.indexOf(\".\") + 1;\n for (i = decpt; i < out.length; ++i) {\n if (out[i] == null || 'n?('.indexOf(out[i].t) === -1 && i !== decpt) continue;\n j = out[i].v.indexOf(\".\") > -1 && i === decpt ? out[i].v.indexOf(\".\") + 1 : 0;\n vv = out[i].v.substr(0, j);\n for (; j < out[i].v.length; ++j) {\n if (jj < ostr.length) vv += ostr.charAt(jj++);\n }\n out[i].v = vv;\n out[i].t = 't';\n lasti = i;\n }\n }\n }\n for (i = 0; i < out.length; ++i) if (out[i] != null && 'n?'.indexOf(out[i].t) > -1) {\n myv = flen > 1 && v < 0 && i > 0 && out[i - 1].v === \"-\" ? -v : v;\n out[i].v = write_num(out[i].t, out[i].v, myv);\n out[i].t = 't';\n }\n var retval = \"\";\n for (i = 0; i !== out.length; ++i) if (out[i] != null) retval += out[i].v;\n return retval;\n}\nvar cfregex2 = /\\[(=|>[=]?|<[>=]?)(-?\\d+(?:\\.\\d*)?)\\]/;\nfunction chkcond(v, rr) {\n if (rr == null) return false;\n var thresh = parseFloat(rr[2]);\n switch (rr[1]) {\n case \"=\":\n if (v == thresh) return true;\n break;\n case \">\":\n if (v > thresh) return true;\n break;\n case \"<\":\n if (v < thresh) return true;\n break;\n case \"<>\":\n if (v != thresh) return true;\n break;\n case \">=\":\n if (v >= thresh) return true;\n break;\n case \"<=\":\n if (v <= thresh) return true;\n break;\n }\n return false;\n}\nfunction choose_fmt(f /*:string*/, v /*:any*/) {\n var fmt = SSF_split_fmt(f);\n var l = fmt.length,\n lat = fmt[l - 1].indexOf(\"@\");\n if (l < 4 && lat > -1) --l;\n if (fmt.length > 4) throw new Error(\"cannot find right format for |\" + fmt.join(\"|\") + \"|\");\n if (typeof v !== \"number\") return [4, fmt.length === 4 || lat > -1 ? fmt[fmt.length - 1] : \"@\"];\n switch (fmt.length) {\n case 1:\n fmt = lat > -1 ? [\"General\", \"General\", \"General\", fmt[0]] : [fmt[0], fmt[0], fmt[0], \"@\"];\n break;\n case 2:\n fmt = lat > -1 ? [fmt[0], fmt[0], fmt[0], fmt[1]] : [fmt[0], fmt[1], fmt[0], \"@\"];\n break;\n case 3:\n fmt = lat > -1 ? [fmt[0], fmt[1], fmt[0], fmt[2]] : [fmt[0], fmt[1], fmt[2], \"@\"];\n break;\n case 4:\n break;\n }\n var ff = v > 0 ? fmt[0] : v < 0 ? fmt[1] : fmt[2];\n if (fmt[0].indexOf(\"[\") === -1 && fmt[1].indexOf(\"[\") === -1) return [l, ff];\n if (fmt[0].match(/\\[[=<>]/) != null || fmt[1].match(/\\[[=<>]/) != null) {\n var m1 = fmt[0].match(cfregex2);\n var m2 = fmt[1].match(cfregex2);\n return chkcond(v, m1) ? [l, fmt[0]] : chkcond(v, m2) ? [l, fmt[1]] : [l, fmt[m1 != null && m2 != null ? 2 : 1]];\n }\n return [l, ff];\n}\nfunction SSF_format(fmt /*:string|number*/, v /*:any*/, o /*:?any*/) {\n if (o == null) o = {};\n var sfmt = \"\";\n switch (typeof fmt) {\n case \"string\":\n if (fmt == \"m/d/yy\" && o.dateNF) sfmt = o.dateNF;else sfmt = fmt;\n break;\n case \"number\":\n if (fmt == 14 && o.dateNF) sfmt = o.dateNF;else sfmt = (o.table != null ? o.table /*:any*/ : table_fmt)[fmt];\n if (sfmt == null) sfmt = o.table && o.table[SSF_default_map[fmt]] || table_fmt[SSF_default_map[fmt]];\n if (sfmt == null) sfmt = SSF_default_str[fmt] || \"General\";\n break;\n }\n if (SSF_isgeneral(sfmt, 0)) return SSF_general(v, o);\n if (v instanceof Date) v = datenum_local(v, o.date1904);\n var f = choose_fmt(sfmt, v);\n if (SSF_isgeneral(f[1])) return SSF_general(v, o);\n if (v === true) v = \"TRUE\";else if (v === false) v = \"FALSE\";else if (v === \"\" || v == null) return \"\";\n return eval_fmt(f[1], v, o, f[0]);\n}\nfunction SSF_load(fmt /*:string*/, idx /*:?number*/) /*:number*/{\n if (typeof idx != 'number') {\n idx = +idx || -1;\n /*::if(typeof idx != 'number') return 0x188; */\n for (var i = 0; i < 0x0188; ++i) {\n /*::if(typeof idx != 'number') return 0x188; */\n if (table_fmt[i] == undefined) {\n if (idx < 0) idx = i;\n continue;\n }\n if (table_fmt[i] == fmt) {\n idx = i;\n break;\n }\n }\n /*::if(typeof idx != 'number') return 0x188; */\n if (idx < 0) idx = 0x187;\n }\n /*::if(typeof idx != 'number') return 0x188; */\n table_fmt[idx] = fmt;\n return idx;\n}\nfunction SSF_load_table(tbl /*:SSFTable*/) /*:void*/{\n for (var i = 0; i != 0x0188; ++i) if (tbl[i] !== undefined) SSF_load(tbl[i], i);\n}\nfunction make_ssf() {\n table_fmt = SSF_init_table();\n}\nvar SSF = {\n format: SSF_format,\n load: SSF_load,\n _table: table_fmt,\n load_table: SSF_load_table,\n parse_date_code: SSF_parse_date_code,\n is_date: fmt_is_date,\n get_table: function get_table() {\n return SSF._table = table_fmt;\n }\n};\nvar SSFImplicit /*{[number]:string}*/ = {\n \"5\": '\"$\"#,##0_);\\\\(\"$\"#,##0\\\\)',\n \"6\": '\"$\"#,##0_);[Red]\\\\(\"$\"#,##0\\\\)',\n \"7\": '\"$\"#,##0.00_);\\\\(\"$\"#,##0.00\\\\)',\n \"8\": '\"$\"#,##0.00_);[Red]\\\\(\"$\"#,##0.00\\\\)',\n \"23\": 'General',\n \"24\": 'General',\n \"25\": 'General',\n \"26\": 'General',\n \"27\": 'm/d/yy',\n \"28\": 'm/d/yy',\n \"29\": 'm/d/yy',\n \"30\": 'm/d/yy',\n \"31\": 'm/d/yy',\n \"32\": 'h:mm:ss',\n \"33\": 'h:mm:ss',\n \"34\": 'h:mm:ss',\n \"35\": 'h:mm:ss',\n \"36\": 'm/d/yy',\n \"41\": '_(* #,##0_);_(* \\(#,##0\\);_(* \"-\"_);_(@_)',\n \"42\": '_(\"$\"* #,##0_);_(\"$\"* \\(#,##0\\);_(\"$\"* \"-\"_);_(@_)',\n \"43\": '_(* #,##0.00_);_(* \\(#,##0.00\\);_(* \"-\"??_);_(@_)',\n \"44\": '_(\"$\"* #,##0.00_);_(\"$\"* \\(#,##0.00\\);_(\"$\"* \"-\"??_);_(@_)',\n \"50\": 'm/d/yy',\n \"51\": 'm/d/yy',\n \"52\": 'm/d/yy',\n \"53\": 'm/d/yy',\n \"54\": 'm/d/yy',\n \"55\": 'm/d/yy',\n \"56\": 'm/d/yy',\n \"57\": 'm/d/yy',\n \"58\": 'm/d/yy',\n \"59\": '0',\n \"60\": '0.00',\n \"61\": '#,##0',\n \"62\": '#,##0.00',\n \"63\": '\"$\"#,##0_);\\\\(\"$\"#,##0\\\\)',\n \"64\": '\"$\"#,##0_);[Red]\\\\(\"$\"#,##0\\\\)',\n \"65\": '\"$\"#,##0.00_);\\\\(\"$\"#,##0.00\\\\)',\n \"66\": '\"$\"#,##0.00_);[Red]\\\\(\"$\"#,##0.00\\\\)',\n \"67\": '0%',\n \"68\": '0.00%',\n \"69\": '# ?/?',\n \"70\": '# ??/??',\n \"71\": 'm/d/yy',\n \"72\": 'm/d/yy',\n \"73\": 'd-mmm-yy',\n \"74\": 'd-mmm',\n \"75\": 'mmm-yy',\n \"76\": 'h:mm',\n \"77\": 'h:mm:ss',\n \"78\": 'm/d/yy h:mm',\n \"79\": 'mm:ss',\n \"80\": '[h]:mm:ss',\n \"81\": 'mmss.0'\n} /*:any*/;\n\n/* dateNF parse TODO: move to SSF */\nvar dateNFregex = /[dD]+|[mM]+|[yYeE]+|[Hh]+|[Ss]+/g;\nfunction dateNF_regex(dateNF /*:string|number*/) /*:RegExp*/{\n var fmt = typeof dateNF == \"number\" ? table_fmt[dateNF] : dateNF;\n fmt = fmt.replace(dateNFregex, \"(\\\\d+)\");\n return new RegExp(\"^\" + fmt + \"$\");\n}\nfunction dateNF_fix(str /*:string*/, dateNF /*:string*/, match /*:Array*/) /*:string*/{\n var Y = -1,\n m = -1,\n d = -1,\n H = -1,\n M = -1,\n S = -1;\n (dateNF.match(dateNFregex) || []).forEach(function (n, i) {\n var v = parseInt(match[i + 1], 10);\n switch (n.toLowerCase().charAt(0)) {\n case 'y':\n Y = v;\n break;\n case 'd':\n d = v;\n break;\n case 'h':\n H = v;\n break;\n case 's':\n S = v;\n break;\n case 'm':\n if (H >= 0) M = v;else m = v;\n break;\n }\n });\n if (S >= 0 && M == -1 && m >= 0) {\n M = m;\n m = -1;\n }\n var datestr = (\"\" + (Y >= 0 ? Y : new Date().getFullYear())).slice(-4) + \"-\" + (\"00\" + (m >= 1 ? m : 1)).slice(-2) + \"-\" + (\"00\" + (d >= 1 ? d : 1)).slice(-2);\n if (datestr.length == 7) datestr = \"0\" + datestr;\n if (datestr.length == 8) datestr = \"20\" + datestr;\n var timestr = (\"00\" + (H >= 0 ? H : 0)).slice(-2) + \":\" + (\"00\" + (M >= 0 ? M : 0)).slice(-2) + \":\" + (\"00\" + (S >= 0 ? S : 0)).slice(-2);\n if (H == -1 && M == -1 && S == -1) return datestr;\n if (Y == -1 && m == -1 && d == -1) return timestr;\n return datestr + \"T\" + timestr;\n}\n\n/*::\ndeclare var ReadShift:any;\ndeclare var CheckField:any;\ndeclare var prep_blob:any;\ndeclare var __readUInt32LE:any;\ndeclare var __readInt32LE:any;\ndeclare var __toBuffer:any;\ndeclare var __utf16le:any;\ndeclare var bconcat:any;\ndeclare var s2a:any;\ndeclare var chr0:any;\ndeclare var chr1:any;\ndeclare var has_buf:boolean;\ndeclare var new_buf:any;\ndeclare var new_raw_buf:any;\ndeclare var new_unsafe_buf:any;\ndeclare var Buffer_from:any;\n*/\n/* cfb.js (C) 2013-present SheetJS -- http://sheetjs.com */\n/* vim: set ts=2: */\n/*jshint eqnull:true */\n/*exported CFB */\n/*global Uint8Array:false, Uint16Array:false */\n\n/*::\ntype SectorEntry = {\n\tname?:string;\n\tnodes?:Array;\n\tdata:RawBytes;\n};\ntype SectorList = {\n\t[k:string|number]:SectorEntry;\n\tname:?string;\n\tfat_addrs:Array;\n\tssz:number;\n}\ntype CFBFiles = {[n:string]:CFBEntry};\n*/\n/* crc32.js (C) 2014-present SheetJS -- http://sheetjs.com */\n/* vim: set ts=2: */\n/*exported CRC32 */\nvar CRC32 = /*#__PURE__*/function () {\n var CRC32 = {};\n CRC32.version = '1.2.0';\n /* see perf/crc32table.js */\n /*global Int32Array */\n function signed_crc_table() /*:any*/{\n var c = 0,\n table /*:Array*/ = new Array(256);\n for (var n = 0; n != 256; ++n) {\n c = n;\n c = c & 1 ? -306674912 ^ c >>> 1 : c >>> 1;\n c = c & 1 ? -306674912 ^ c >>> 1 : c >>> 1;\n c = c & 1 ? -306674912 ^ c >>> 1 : c >>> 1;\n c = c & 1 ? -306674912 ^ c >>> 1 : c >>> 1;\n c = c & 1 ? -306674912 ^ c >>> 1 : c >>> 1;\n c = c & 1 ? -306674912 ^ c >>> 1 : c >>> 1;\n c = c & 1 ? -306674912 ^ c >>> 1 : c >>> 1;\n c = c & 1 ? -306674912 ^ c >>> 1 : c >>> 1;\n table[n] = c;\n }\n return typeof Int32Array !== 'undefined' ? new Int32Array(table) : table;\n }\n var T0 = signed_crc_table();\n function slice_by_16_tables(T) {\n var c = 0,\n v = 0,\n n = 0,\n table /*:Array*/ = typeof Int32Array !== 'undefined' ? new Int32Array(4096) : new Array(4096);\n for (n = 0; n != 256; ++n) table[n] = T[n];\n for (n = 0; n != 256; ++n) {\n v = T[n];\n for (c = 256 + n; c < 4096; c += 256) v = table[c] = v >>> 8 ^ T[v & 0xFF];\n }\n var out = [];\n for (n = 1; n != 16; ++n) out[n - 1] = typeof Int32Array !== 'undefined' ? table.subarray(n * 256, n * 256 + 256) : table.slice(n * 256, n * 256 + 256);\n return out;\n }\n var TT = slice_by_16_tables(T0);\n var T1 = TT[0],\n T2 = TT[1],\n T3 = TT[2],\n T4 = TT[3],\n T5 = TT[4];\n var T6 = TT[5],\n T7 = TT[6],\n T8 = TT[7],\n T9 = TT[8],\n Ta = TT[9];\n var Tb = TT[10],\n Tc = TT[11],\n Td = TT[12],\n Te = TT[13],\n Tf = TT[14];\n function crc32_bstr(bstr /*:string*/, seed /*:number*/) /*:number*/{\n var C = seed /*:: ? 0 : 0 */ ^ -1;\n for (var i = 0, L = bstr.length; i < L;) C = C >>> 8 ^ T0[(C ^ bstr.charCodeAt(i++)) & 0xFF];\n return ~C;\n }\n function crc32_buf(B /*:Uint8Array|Array*/, seed /*:number*/) /*:number*/{\n var C = seed /*:: ? 0 : 0 */ ^ -1,\n L = B.length - 15,\n i = 0;\n for (; i < L;) C = Tf[B[i++] ^ C & 255] ^ Te[B[i++] ^ C >> 8 & 255] ^ Td[B[i++] ^ C >> 16 & 255] ^ Tc[B[i++] ^ C >>> 24] ^ Tb[B[i++]] ^ Ta[B[i++]] ^ T9[B[i++]] ^ T8[B[i++]] ^ T7[B[i++]] ^ T6[B[i++]] ^ T5[B[i++]] ^ T4[B[i++]] ^ T3[B[i++]] ^ T2[B[i++]] ^ T1[B[i++]] ^ T0[B[i++]];\n L += 15;\n while (i < L) C = C >>> 8 ^ T0[(C ^ B[i++]) & 0xFF];\n return ~C;\n }\n function crc32_str(str /*:string*/, seed /*:number*/) /*:number*/{\n var C = seed ^ -1;\n for (var i = 0, L = str.length, c = 0, d = 0; i < L;) {\n c = str.charCodeAt(i++);\n if (c < 0x80) {\n C = C >>> 8 ^ T0[(C ^ c) & 0xFF];\n } else if (c < 0x800) {\n C = C >>> 8 ^ T0[(C ^ (192 | c >> 6 & 31)) & 0xFF];\n C = C >>> 8 ^ T0[(C ^ (128 | c & 63)) & 0xFF];\n } else if (c >= 0xD800 && c < 0xE000) {\n c = (c & 1023) + 64;\n d = str.charCodeAt(i++) & 1023;\n C = C >>> 8 ^ T0[(C ^ (240 | c >> 8 & 7)) & 0xFF];\n C = C >>> 8 ^ T0[(C ^ (128 | c >> 2 & 63)) & 0xFF];\n C = C >>> 8 ^ T0[(C ^ (128 | d >> 6 & 15 | (c & 3) << 4)) & 0xFF];\n C = C >>> 8 ^ T0[(C ^ (128 | d & 63)) & 0xFF];\n } else {\n C = C >>> 8 ^ T0[(C ^ (224 | c >> 12 & 15)) & 0xFF];\n C = C >>> 8 ^ T0[(C ^ (128 | c >> 6 & 63)) & 0xFF];\n C = C >>> 8 ^ T0[(C ^ (128 | c & 63)) & 0xFF];\n }\n }\n return ~C;\n }\n CRC32.table = T0;\n CRC32.bstr = crc32_bstr;\n CRC32.buf = crc32_buf;\n CRC32.str = crc32_str;\n return CRC32;\n}();\n/* [MS-CFB] v20171201 */\nvar CFB = /*#__PURE__*/function _CFB() {\n var exports = {};\n exports.version = '1.2.1';\n /* [MS-CFB] 2.6.4 */\n function namecmp(l /*:string*/, r /*:string*/) /*:number*/{\n var L = l.split(\"/\"),\n R = r.split(\"/\");\n for (var i = 0, c = 0, Z = Math.min(L.length, R.length); i < Z; ++i) {\n if (c = L[i].length - R[i].length) return c;\n if (L[i] != R[i]) return L[i] < R[i] ? -1 : 1;\n }\n return L.length - R.length;\n }\n function dirname(p /*:string*/) /*:string*/{\n if (p.charAt(p.length - 1) == \"/\") return p.slice(0, -1).indexOf(\"/\") === -1 ? p : dirname(p.slice(0, -1));\n var c = p.lastIndexOf(\"/\");\n return c === -1 ? p : p.slice(0, c + 1);\n }\n function filename(p /*:string*/) /*:string*/{\n if (p.charAt(p.length - 1) == \"/\") return filename(p.slice(0, -1));\n var c = p.lastIndexOf(\"/\");\n return c === -1 ? p : p.slice(c + 1);\n }\n /* -------------------------------------------------------------------------- */\n /* DOS Date format:\n high|YYYYYYYm.mmmddddd.HHHHHMMM.MMMSSSSS|low\n add 1980 to stored year\n stored second should be doubled\n */\n\n /* write JS date to buf as a DOS date */\n function write_dos_date(buf /*:CFBlob*/, date /*:Date|string*/) {\n if (typeof date === \"string\") date = new Date(date);\n var hms /*:number*/ = date.getHours();\n hms = hms << 6 | date.getMinutes();\n hms = hms << 5 | date.getSeconds() >>> 1;\n buf.write_shift(2, hms);\n var ymd /*:number*/ = date.getFullYear() - 1980;\n ymd = ymd << 4 | date.getMonth() + 1;\n ymd = ymd << 5 | date.getDate();\n buf.write_shift(2, ymd);\n }\n\n /* read four bytes from buf and interpret as a DOS date */\n function parse_dos_date(buf /*:CFBlob*/) /*:Date*/{\n var hms = buf.read_shift(2) & 0xFFFF;\n var ymd = buf.read_shift(2) & 0xFFFF;\n var val = new Date();\n var d = ymd & 0x1F;\n ymd >>>= 5;\n var m = ymd & 0x0F;\n ymd >>>= 4;\n val.setMilliseconds(0);\n val.setFullYear(ymd + 1980);\n val.setMonth(m - 1);\n val.setDate(d);\n var S = hms & 0x1F;\n hms >>>= 5;\n var M = hms & 0x3F;\n hms >>>= 6;\n val.setHours(hms);\n val.setMinutes(M);\n val.setSeconds(S << 1);\n return val;\n }\n function parse_extra_field(blob /*:CFBlob*/) /*:any*/{\n prep_blob(blob, 0);\n var o = /*::(*/{} /*:: :any)*/;\n var flags = 0;\n while (blob.l <= blob.length - 4) {\n var type = blob.read_shift(2);\n var sz = blob.read_shift(2),\n tgt = blob.l + sz;\n var p = {};\n switch (type) {\n /* UNIX-style Timestamps */\n case 0x5455:\n {\n flags = blob.read_shift(1);\n if (flags & 1) p.mtime = blob.read_shift(4);\n /* for some reason, CD flag corresponds to LFH */\n if (sz > 5) {\n if (flags & 2) p.atime = blob.read_shift(4);\n if (flags & 4) p.ctime = blob.read_shift(4);\n }\n if (p.mtime) p.mt = new Date(p.mtime * 1000);\n }\n break;\n }\n blob.l = tgt;\n o[type] = p;\n }\n return o;\n }\n var fs /*:: = require('fs'); */;\n function get_fs() {\n return fs || (fs = {});\n }\n function parse(file /*:RawBytes*/, options /*:CFBReadOpts*/) /*:CFBContainer*/{\n if (file[0] == 0x50 && file[1] == 0x4b) return parse_zip(file, options);\n if ((file[0] | 0x20) == 0x6d && (file[1] | 0x20) == 0x69) return parse_mad(file, options);\n if (file.length < 512) throw new Error(\"CFB file size \" + file.length + \" < 512\");\n var mver = 3;\n var ssz = 512;\n var nmfs = 0; // number of mini FAT sectors\n var difat_sec_cnt = 0;\n var dir_start = 0;\n var minifat_start = 0;\n var difat_start = 0;\n var fat_addrs /*:Array*/ = []; // locations of FAT sectors\n\n /* [MS-CFB] 2.2 Compound File Header */\n var blob /*:CFBlob*/ = /*::(*/file.slice(0, 512) /*:: :any)*/;\n prep_blob(blob, 0);\n\n /* major version */\n var mv = check_get_mver(blob);\n mver = mv[0];\n switch (mver) {\n case 3:\n ssz = 512;\n break;\n case 4:\n ssz = 4096;\n break;\n case 0:\n if (mv[1] == 0) return parse_zip(file, options);\n /* falls through */\n default:\n throw new Error(\"Major Version: Expected 3 or 4 saw \" + mver);\n }\n\n /* reprocess header */\n if (ssz !== 512) {\n blob = /*::(*/file.slice(0, ssz) /*:: :any)*/;\n prep_blob(blob, 28 /* blob.l */);\n }\n /* Save header for final object */\n var header /*:RawBytes*/ = file.slice(0, ssz);\n check_shifts(blob, mver);\n\n // Number of Directory Sectors\n var dir_cnt /*:number*/ = blob.read_shift(4, 'i');\n if (mver === 3 && dir_cnt !== 0) throw new Error('# Directory Sectors: Expected 0 saw ' + dir_cnt);\n\n // Number of FAT Sectors\n blob.l += 4;\n\n // First Directory Sector Location\n dir_start = blob.read_shift(4, 'i');\n\n // Transaction Signature\n blob.l += 4;\n\n // Mini Stream Cutoff Size\n blob.chk('00100000', 'Mini Stream Cutoff Size: ');\n\n // First Mini FAT Sector Location\n minifat_start = blob.read_shift(4, 'i');\n\n // Number of Mini FAT Sectors\n nmfs = blob.read_shift(4, 'i');\n\n // First DIFAT sector location\n difat_start = blob.read_shift(4, 'i');\n\n // Number of DIFAT Sectors\n difat_sec_cnt = blob.read_shift(4, 'i');\n\n // Grab FAT Sector Locations\n for (var q = -1, j = 0; j < 109; ++j) {\n /* 109 = (512 - blob.l)>>>2; */\n q = blob.read_shift(4, 'i');\n if (q < 0) break;\n fat_addrs[j] = q;\n }\n\n /** Break the file up into sectors */\n var sectors /*:Array*/ = sectorify(file, ssz);\n sleuth_fat(difat_start, difat_sec_cnt, sectors, ssz, fat_addrs);\n\n /** Chains */\n var sector_list /*:SectorList*/ = make_sector_list(sectors, dir_start, fat_addrs, ssz);\n sector_list[dir_start].name = \"!Directory\";\n if (nmfs > 0 && minifat_start !== ENDOFCHAIN) sector_list[minifat_start].name = \"!MiniFAT\";\n sector_list[fat_addrs[0]].name = \"!FAT\";\n sector_list.fat_addrs = fat_addrs;\n sector_list.ssz = ssz;\n\n /* [MS-CFB] 2.6.1 Compound File Directory Entry */\n var files /*:CFBFiles*/ = {},\n Paths /*:Array*/ = [],\n FileIndex /*:CFBFileIndex*/ = [],\n FullPaths /*:Array*/ = [];\n read_directory(dir_start, sector_list, sectors, Paths, nmfs, files, FileIndex, minifat_start);\n build_full_paths(FileIndex, FullPaths, Paths);\n Paths.shift();\n var o = {\n FileIndex: FileIndex,\n FullPaths: FullPaths\n };\n\n // $FlowIgnore\n if (options && options.raw) o.raw = {\n header: header,\n sectors: sectors\n };\n return o;\n } // parse\n\n /* [MS-CFB] 2.2 Compound File Header -- read up to major version */\n function check_get_mver(blob /*:CFBlob*/) /*:[number, number]*/{\n if (blob[blob.l] == 0x50 && blob[blob.l + 1] == 0x4b) return [0, 0];\n // header signature 8\n blob.chk(HEADER_SIGNATURE, 'Header Signature: ');\n\n // clsid 16\n //blob.chk(HEADER_CLSID, 'CLSID: ');\n blob.l += 16;\n\n // minor version 2\n var mver /*:number*/ = blob.read_shift(2, 'u');\n return [blob.read_shift(2, 'u'), mver];\n }\n function check_shifts(blob /*:CFBlob*/, mver /*:number*/) /*:void*/{\n var shift = 0x09;\n\n // Byte Order\n //blob.chk('feff', 'Byte Order: '); // note: some writers put 0xffff\n blob.l += 2;\n\n // Sector Shift\n switch (shift = blob.read_shift(2)) {\n case 0x09:\n if (mver != 3) throw new Error('Sector Shift: Expected 9 saw ' + shift);\n break;\n case 0x0c:\n if (mver != 4) throw new Error('Sector Shift: Expected 12 saw ' + shift);\n break;\n default:\n throw new Error('Sector Shift: Expected 9 or 12 saw ' + shift);\n }\n\n // Mini Sector Shift\n blob.chk('0600', 'Mini Sector Shift: ');\n\n // Reserved\n blob.chk('000000000000', 'Reserved: ');\n }\n\n /** Break the file up into sectors */\n function sectorify(file /*:RawBytes*/, ssz /*:number*/) /*:Array*/{\n var nsectors = Math.ceil(file.length / ssz) - 1;\n var sectors /*:Array*/ = [];\n for (var i = 1; i < nsectors; ++i) sectors[i - 1] = file.slice(i * ssz, (i + 1) * ssz);\n sectors[nsectors - 1] = file.slice(nsectors * ssz);\n return sectors;\n }\n\n /* [MS-CFB] 2.6.4 Red-Black Tree */\n function build_full_paths(FI /*:CFBFileIndex*/, FP /*:Array*/, Paths /*:Array*/) /*:void*/{\n var i = 0,\n L = 0,\n R = 0,\n C = 0,\n j = 0,\n pl = Paths.length;\n var dad /*:Array*/ = [],\n q /*:Array*/ = [];\n for (; i < pl; ++i) {\n dad[i] = q[i] = i;\n FP[i] = Paths[i];\n }\n for (; j < q.length; ++j) {\n i = q[j];\n L = FI[i].L;\n R = FI[i].R;\n C = FI[i].C;\n if (dad[i] === i) {\n if (L !== -1 /*NOSTREAM*/ && dad[L] !== L) dad[i] = dad[L];\n if (R !== -1 && dad[R] !== R) dad[i] = dad[R];\n }\n if (C !== -1 /*NOSTREAM*/) dad[C] = i;\n if (L !== -1 && i != dad[i]) {\n dad[L] = dad[i];\n if (q.lastIndexOf(L) < j) q.push(L);\n }\n if (R !== -1 && i != dad[i]) {\n dad[R] = dad[i];\n if (q.lastIndexOf(R) < j) q.push(R);\n }\n }\n for (i = 1; i < pl; ++i) if (dad[i] === i) {\n if (R !== -1 /*NOSTREAM*/ && dad[R] !== R) dad[i] = dad[R];else if (L !== -1 && dad[L] !== L) dad[i] = dad[L];\n }\n for (i = 1; i < pl; ++i) {\n if (FI[i].type === 0 /* unknown */) continue;\n j = i;\n if (j != dad[j]) do {\n j = dad[j];\n FP[i] = FP[j] + \"/\" + FP[i];\n } while (j !== 0 && -1 !== dad[j] && j != dad[j]);\n dad[i] = -1;\n }\n FP[0] += \"/\";\n for (i = 1; i < pl; ++i) {\n if (FI[i].type !== 2 /* stream */) FP[i] += \"/\";\n }\n }\n function get_mfat_entry(entry /*:CFBEntry*/, payload /*:RawBytes*/, mini /*:?RawBytes*/) /*:CFBlob*/{\n var start = entry.start,\n size = entry.size;\n //return (payload.slice(start*MSSZ, start*MSSZ + size)/*:any*/);\n var o = [];\n var idx = start;\n while (mini && size > 0 && idx >= 0) {\n o.push(payload.slice(idx * MSSZ, idx * MSSZ + MSSZ));\n size -= MSSZ;\n idx = __readInt32LE(mini, idx * 4);\n }\n if (o.length === 0) return new_buf(0) /*:any*/;\n return bconcat(o).slice(0, entry.size) /*:any*/;\n }\n\n /** Chase down the rest of the DIFAT chain to build a comprehensive list\n DIFAT chains by storing the next sector number as the last 32 bits */\n function sleuth_fat(idx /*:number*/, cnt /*:number*/, sectors /*:Array*/, ssz /*:number*/, fat_addrs) /*:void*/{\n var q /*:number*/ = ENDOFCHAIN;\n if (idx === ENDOFCHAIN) {\n if (cnt !== 0) throw new Error(\"DIFAT chain shorter than expected\");\n } else if (idx !== -1 /*FREESECT*/) {\n var sector = sectors[idx],\n m = (ssz >>> 2) - 1;\n if (!sector) return;\n for (var i = 0; i < m; ++i) {\n if ((q = __readInt32LE(sector, i * 4)) === ENDOFCHAIN) break;\n fat_addrs.push(q);\n }\n sleuth_fat(__readInt32LE(sector, ssz - 4), cnt - 1, sectors, ssz, fat_addrs);\n }\n }\n\n /** Follow the linked list of sectors for a given starting point */\n function get_sector_list(sectors /*:Array*/, start /*:number*/, fat_addrs /*:Array*/, ssz /*:number*/, chkd /*:?Array*/) /*:SectorEntry*/{\n var buf /*:Array*/ = [],\n buf_chain /*:Array*/ = [];\n if (!chkd) chkd = [];\n var modulus = ssz - 1,\n j = 0,\n jj = 0;\n for (j = start; j >= 0;) {\n chkd[j] = true;\n buf[buf.length] = j;\n buf_chain.push(sectors[j]);\n var addr = fat_addrs[Math.floor(j * 4 / ssz)];\n jj = j * 4 & modulus;\n if (ssz < 4 + jj) throw new Error(\"FAT boundary crossed: \" + j + \" 4 \" + ssz);\n if (!sectors[addr]) break;\n j = __readInt32LE(sectors[addr], jj);\n }\n return {\n nodes: buf,\n data: __toBuffer([buf_chain])\n };\n }\n\n /** Chase down the sector linked lists */\n function make_sector_list(sectors /*:Array*/, dir_start /*:number*/, fat_addrs /*:Array*/, ssz /*:number*/) /*:SectorList*/{\n var sl = sectors.length,\n sector_list /*:SectorList*/ = [] /*:any*/;\n var chkd /*:Array*/ = [],\n buf /*:Array*/ = [],\n buf_chain /*:Array*/ = [];\n var modulus = ssz - 1,\n i = 0,\n j = 0,\n k = 0,\n jj = 0;\n for (i = 0; i < sl; ++i) {\n buf = [] /*:Array*/;\n k = i + dir_start;\n if (k >= sl) k -= sl;\n if (chkd[k]) continue;\n buf_chain = [];\n var seen = [];\n for (j = k; j >= 0;) {\n seen[j] = true;\n chkd[j] = true;\n buf[buf.length] = j;\n buf_chain.push(sectors[j]);\n var addr /*:number*/ = fat_addrs[Math.floor(j * 4 / ssz)];\n jj = j * 4 & modulus;\n if (ssz < 4 + jj) throw new Error(\"FAT boundary crossed: \" + j + \" 4 \" + ssz);\n if (!sectors[addr]) break;\n j = __readInt32LE(sectors[addr], jj);\n if (seen[j]) break;\n }\n sector_list[k] = {\n nodes: buf,\n data: __toBuffer([buf_chain])\n } /*:SectorEntry*/;\n }\n return sector_list;\n }\n\n /* [MS-CFB] 2.6.1 Compound File Directory Entry */\n function read_directory(dir_start /*:number*/, sector_list /*:SectorList*/, sectors /*:Array*/, Paths /*:Array*/, nmfs, files, FileIndex, mini) {\n var minifat_store = 0,\n pl = Paths.length ? 2 : 0;\n var sector = sector_list[dir_start].data;\n var i = 0,\n namelen = 0,\n name;\n for (; i < sector.length; i += 128) {\n var blob /*:CFBlob*/ = /*::(*/sector.slice(i, i + 128) /*:: :any)*/;\n prep_blob(blob, 64);\n namelen = blob.read_shift(2);\n name = __utf16le(blob, 0, namelen - pl);\n Paths.push(name);\n var o /*:CFBEntry*/ = {\n name: name,\n type: blob.read_shift(1),\n color: blob.read_shift(1),\n L: blob.read_shift(4, 'i'),\n R: blob.read_shift(4, 'i'),\n C: blob.read_shift(4, 'i'),\n clsid: blob.read_shift(16),\n state: blob.read_shift(4, 'i'),\n start: 0,\n size: 0\n };\n var ctime /*:number*/ = blob.read_shift(2) + blob.read_shift(2) + blob.read_shift(2) + blob.read_shift(2);\n if (ctime !== 0) o.ct = read_date(blob, blob.l - 8);\n var mtime /*:number*/ = blob.read_shift(2) + blob.read_shift(2) + blob.read_shift(2) + blob.read_shift(2);\n if (mtime !== 0) o.mt = read_date(blob, blob.l - 8);\n o.start = blob.read_shift(4, 'i');\n o.size = blob.read_shift(4, 'i');\n if (o.size < 0 && o.start < 0) {\n o.size = o.type = 0;\n o.start = ENDOFCHAIN;\n o.name = \"\";\n }\n if (o.type === 5) {\n /* root */\n minifat_store = o.start;\n if (nmfs > 0 && minifat_store !== ENDOFCHAIN) sector_list[minifat_store].name = \"!StreamData\";\n /*minifat_size = o.size;*/\n } else if (o.size >= 4096 /* MSCSZ */) {\n o.storage = 'fat';\n if (sector_list[o.start] === undefined) sector_list[o.start] = get_sector_list(sectors, o.start, sector_list.fat_addrs, sector_list.ssz);\n sector_list[o.start].name = o.name;\n o.content = sector_list[o.start].data.slice(0, o.size) /*:any*/;\n } else {\n o.storage = 'minifat';\n if (o.size < 0) o.size = 0;else if (minifat_store !== ENDOFCHAIN && o.start !== ENDOFCHAIN && sector_list[minifat_store]) {\n o.content = get_mfat_entry(o, sector_list[minifat_store].data, (sector_list[mini] || {}).data);\n }\n }\n if (o.content) prep_blob(o.content, 0);\n files[name] = o;\n FileIndex.push(o);\n }\n }\n function read_date(blob /*:RawBytes|CFBlob*/, offset /*:number*/) /*:Date*/{\n return new Date((__readUInt32LE(blob, offset + 4) / 1e7 * Math.pow(2, 32) + __readUInt32LE(blob, offset) / 1e7 - 11644473600) * 1000);\n }\n function read_file(filename /*:string*/, options /*:CFBReadOpts*/) {\n get_fs();\n return parse(fs.readFileSync(filename), options);\n }\n function read(blob /*:RawBytes|string*/, options /*:CFBReadOpts*/) {\n var type = options && options.type;\n if (!type) {\n if (has_buf && Buffer.isBuffer(blob)) type = \"buffer\";\n }\n switch (type || \"base64\") {\n case \"file\":\n /*:: if(typeof blob !== 'string') throw \"Must pass a filename when type='file'\"; */return read_file(blob, options);\n case \"base64\":\n /*:: if(typeof blob !== 'string') throw \"Must pass a base64-encoded binary string when type='file'\"; */return parse(s2a(Base64_decode(blob)), options);\n case \"binary\":\n /*:: if(typeof blob !== 'string') throw \"Must pass a binary string when type='file'\"; */return parse(s2a(blob), options);\n }\n return parse(/*::typeof blob == 'string' ? new Buffer(blob, 'utf-8') : */blob, options);\n }\n function init_cfb(cfb /*:CFBContainer*/, opts /*:?any*/) /*:void*/{\n var o = opts || {},\n root = o.root || \"Root Entry\";\n if (!cfb.FullPaths) cfb.FullPaths = [];\n if (!cfb.FileIndex) cfb.FileIndex = [];\n if (cfb.FullPaths.length !== cfb.FileIndex.length) throw new Error(\"inconsistent CFB structure\");\n if (cfb.FullPaths.length === 0) {\n cfb.FullPaths[0] = root + \"/\";\n cfb.FileIndex[0] = {\n name: root,\n type: 5\n } /*:any*/;\n }\n if (o.CLSID) cfb.FileIndex[0].clsid = o.CLSID;\n seed_cfb(cfb);\n }\n function seed_cfb(cfb /*:CFBContainer*/) /*:void*/{\n var nm = \"\\u0001Sh33tJ5\";\n if (CFB.find(cfb, \"/\" + nm)) return;\n var p = new_buf(4);\n p[0] = 55;\n p[1] = p[3] = 50;\n p[2] = 54;\n cfb.FileIndex.push({\n name: nm,\n type: 2,\n content: p,\n size: 4,\n L: 69,\n R: 69,\n C: 69\n } /*:any*/);\n cfb.FullPaths.push(cfb.FullPaths[0] + nm);\n rebuild_cfb(cfb);\n }\n function rebuild_cfb(cfb /*:CFBContainer*/, f /*:?boolean*/) /*:void*/{\n init_cfb(cfb);\n var gc = false,\n s = false;\n for (var i = cfb.FullPaths.length - 1; i >= 0; --i) {\n var _file = cfb.FileIndex[i];\n switch (_file.type) {\n case 0:\n if (s) gc = true;else {\n cfb.FileIndex.pop();\n cfb.FullPaths.pop();\n }\n break;\n case 1:\n case 2:\n case 5:\n s = true;\n if (isNaN(_file.R * _file.L * _file.C)) gc = true;\n if (_file.R > -1 && _file.L > -1 && _file.R == _file.L) gc = true;\n break;\n default:\n gc = true;\n break;\n }\n }\n if (!gc && !f) return;\n var now = new Date(1987, 1, 19),\n j = 0;\n // Track which names exist\n var fullPaths = Object.create ? Object.create(null) : {};\n var data /*:Array<[string, CFBEntry]>*/ = [];\n for (i = 0; i < cfb.FullPaths.length; ++i) {\n fullPaths[cfb.FullPaths[i]] = true;\n if (cfb.FileIndex[i].type === 0) continue;\n data.push([cfb.FullPaths[i], cfb.FileIndex[i]]);\n }\n for (i = 0; i < data.length; ++i) {\n var dad = dirname(data[i][0]);\n s = fullPaths[dad];\n if (!s) {\n data.push([dad, {\n name: filename(dad).replace(\"/\", \"\"),\n type: 1,\n clsid: HEADER_CLSID,\n ct: now,\n mt: now,\n content: null\n } /*:any*/]);\n // Add name to set\n fullPaths[dad] = true;\n }\n }\n data.sort(function (x, y) {\n return namecmp(x[0], y[0]);\n });\n cfb.FullPaths = [];\n cfb.FileIndex = [];\n for (i = 0; i < data.length; ++i) {\n cfb.FullPaths[i] = data[i][0];\n cfb.FileIndex[i] = data[i][1];\n }\n for (i = 0; i < data.length; ++i) {\n var elt = cfb.FileIndex[i];\n var nm = cfb.FullPaths[i];\n elt.name = filename(nm).replace(\"/\", \"\");\n elt.L = elt.R = elt.C = -(elt.color = 1);\n elt.size = elt.content ? elt.content.length : 0;\n elt.start = 0;\n elt.clsid = elt.clsid || HEADER_CLSID;\n if (i === 0) {\n elt.C = data.length > 1 ? 1 : -1;\n elt.size = 0;\n elt.type = 5;\n } else if (nm.slice(-1) == \"/\") {\n for (j = i + 1; j < data.length; ++j) if (dirname(cfb.FullPaths[j]) == nm) break;\n elt.C = j >= data.length ? -1 : j;\n for (j = i + 1; j < data.length; ++j) if (dirname(cfb.FullPaths[j]) == dirname(nm)) break;\n elt.R = j >= data.length ? -1 : j;\n elt.type = 1;\n } else {\n if (dirname(cfb.FullPaths[i + 1] || \"\") == dirname(nm)) elt.R = i + 1;\n elt.type = 2;\n }\n }\n }\n function _write(cfb /*:CFBContainer*/, options /*:CFBWriteOpts*/) /*:RawBytes|string*/{\n var _opts = options || {};\n /* MAD is order-sensitive, skip rebuild and sort */\n if (_opts.fileType == 'mad') return write_mad(cfb, _opts);\n rebuild_cfb(cfb);\n switch (_opts.fileType) {\n case 'zip':\n return write_zip(cfb, _opts);\n //case 'mad': return write_mad(cfb, _opts);\n }\n var L = function (cfb /*:CFBContainer*/) /*:Array*/{\n var mini_size = 0,\n fat_size = 0;\n for (var i = 0; i < cfb.FileIndex.length; ++i) {\n var file = cfb.FileIndex[i];\n if (!file.content) continue;\n /*:: if(file.content == null) throw new Error(\"unreachable\"); */\n var flen = file.content.length;\n if (flen > 0) {\n if (flen < 0x1000) mini_size += flen + 0x3F >> 6;else fat_size += flen + 0x01FF >> 9;\n }\n }\n var dir_cnt = cfb.FullPaths.length + 3 >> 2;\n var mini_cnt = mini_size + 7 >> 3;\n var mfat_cnt = mini_size + 0x7F >> 7;\n var fat_base = mini_cnt + fat_size + dir_cnt + mfat_cnt;\n var fat_cnt = fat_base + 0x7F >> 7;\n var difat_cnt = fat_cnt <= 109 ? 0 : Math.ceil((fat_cnt - 109) / 0x7F);\n while (fat_base + fat_cnt + difat_cnt + 0x7F >> 7 > fat_cnt) difat_cnt = ++fat_cnt <= 109 ? 0 : Math.ceil((fat_cnt - 109) / 0x7F);\n var L = [1, difat_cnt, fat_cnt, mfat_cnt, dir_cnt, fat_size, mini_size, 0];\n cfb.FileIndex[0].size = mini_size << 6;\n L[7] = (cfb.FileIndex[0].start = L[0] + L[1] + L[2] + L[3] + L[4] + L[5]) + (L[6] + 7 >> 3);\n return L;\n }(cfb);\n var o = new_buf(L[7] << 9);\n var i = 0,\n T = 0;\n {\n for (i = 0; i < 8; ++i) o.write_shift(1, HEADER_SIG[i]);\n for (i = 0; i < 8; ++i) o.write_shift(2, 0);\n o.write_shift(2, 0x003E);\n o.write_shift(2, 0x0003);\n o.write_shift(2, 0xFFFE);\n o.write_shift(2, 0x0009);\n o.write_shift(2, 0x0006);\n for (i = 0; i < 3; ++i) o.write_shift(2, 0);\n o.write_shift(4, 0);\n o.write_shift(4, L[2]);\n o.write_shift(4, L[0] + L[1] + L[2] + L[3] - 1);\n o.write_shift(4, 0);\n o.write_shift(4, 1 << 12);\n o.write_shift(4, L[3] ? L[0] + L[1] + L[2] - 1 : ENDOFCHAIN);\n o.write_shift(4, L[3]);\n o.write_shift(-4, L[1] ? L[0] - 1 : ENDOFCHAIN);\n o.write_shift(4, L[1]);\n for (i = 0; i < 109; ++i) o.write_shift(-4, i < L[2] ? L[1] + i : -1);\n }\n if (L[1]) {\n for (T = 0; T < L[1]; ++T) {\n for (; i < 236 + T * 127; ++i) o.write_shift(-4, i < L[2] ? L[1] + i : -1);\n o.write_shift(-4, T === L[1] - 1 ? ENDOFCHAIN : T + 1);\n }\n }\n var chainit = function (w /*:number*/) /*:void*/{\n for (T += w; i < T - 1; ++i) o.write_shift(-4, i + 1);\n if (w) {\n ++i;\n o.write_shift(-4, ENDOFCHAIN);\n }\n };\n T = i = 0;\n for (T += L[1]; i < T; ++i) o.write_shift(-4, consts.DIFSECT);\n for (T += L[2]; i < T; ++i) o.write_shift(-4, consts.FATSECT);\n chainit(L[3]);\n chainit(L[4]);\n var j /*:number*/ = 0,\n flen /*:number*/ = 0;\n var file /*:CFBEntry*/ = cfb.FileIndex[0];\n for (; j < cfb.FileIndex.length; ++j) {\n file = cfb.FileIndex[j];\n if (!file.content) continue;\n /*:: if(file.content == null) throw new Error(\"unreachable\"); */\n flen = file.content.length;\n if (flen < 0x1000) continue;\n file.start = T;\n chainit(flen + 0x01FF >> 9);\n }\n chainit(L[6] + 7 >> 3);\n while (o.l & 0x1FF) o.write_shift(-4, consts.ENDOFCHAIN);\n T = i = 0;\n for (j = 0; j < cfb.FileIndex.length; ++j) {\n file = cfb.FileIndex[j];\n if (!file.content) continue;\n /*:: if(file.content == null) throw new Error(\"unreachable\"); */\n flen = file.content.length;\n if (!flen || flen >= 0x1000) continue;\n file.start = T;\n chainit(flen + 0x3F >> 6);\n }\n while (o.l & 0x1FF) o.write_shift(-4, consts.ENDOFCHAIN);\n for (i = 0; i < L[4] << 2; ++i) {\n var nm = cfb.FullPaths[i];\n if (!nm || nm.length === 0) {\n for (j = 0; j < 17; ++j) o.write_shift(4, 0);\n for (j = 0; j < 3; ++j) o.write_shift(4, -1);\n for (j = 0; j < 12; ++j) o.write_shift(4, 0);\n continue;\n }\n file = cfb.FileIndex[i];\n if (i === 0) file.start = file.size ? file.start - 1 : ENDOFCHAIN;\n var _nm /*:string*/ = i === 0 && _opts.root || file.name;\n flen = 2 * (_nm.length + 1);\n o.write_shift(64, _nm, \"utf16le\");\n o.write_shift(2, flen);\n o.write_shift(1, file.type);\n o.write_shift(1, file.color);\n o.write_shift(-4, file.L);\n o.write_shift(-4, file.R);\n o.write_shift(-4, file.C);\n if (!file.clsid) for (j = 0; j < 4; ++j) o.write_shift(4, 0);else o.write_shift(16, file.clsid, \"hex\");\n o.write_shift(4, file.state || 0);\n o.write_shift(4, 0);\n o.write_shift(4, 0);\n o.write_shift(4, 0);\n o.write_shift(4, 0);\n o.write_shift(4, file.start);\n o.write_shift(4, file.size);\n o.write_shift(4, 0);\n }\n for (i = 1; i < cfb.FileIndex.length; ++i) {\n file = cfb.FileIndex[i];\n /*:: if(!file.content) throw new Error(\"unreachable\"); */\n if (file.size >= 0x1000) {\n o.l = file.start + 1 << 9;\n if (has_buf && Buffer.isBuffer(file.content)) {\n file.content.copy(o, o.l, 0, file.size);\n // o is a 0-filled Buffer so just set next offset\n o.l += file.size + 511 & -512;\n } else {\n for (j = 0; j < file.size; ++j) o.write_shift(1, file.content[j]);\n for (; j & 0x1FF; ++j) o.write_shift(1, 0);\n }\n }\n }\n for (i = 1; i < cfb.FileIndex.length; ++i) {\n file = cfb.FileIndex[i];\n /*:: if(!file.content) throw new Error(\"unreachable\"); */\n if (file.size > 0 && file.size < 0x1000) {\n if (has_buf && Buffer.isBuffer(file.content)) {\n file.content.copy(o, o.l, 0, file.size);\n // o is a 0-filled Buffer so just set next offset\n o.l += file.size + 63 & -64;\n } else {\n for (j = 0; j < file.size; ++j) o.write_shift(1, file.content[j]);\n for (; j & 0x3F; ++j) o.write_shift(1, 0);\n }\n }\n }\n if (has_buf) {\n o.l = o.length;\n } else {\n // When using Buffer, already 0-filled\n while (o.l < o.length) o.write_shift(1, 0);\n }\n return o;\n }\n /* [MS-CFB] 2.6.4 (Unicode 3.0.1 case conversion) */\n function find(cfb /*:CFBContainer*/, path /*:string*/) /*:?CFBEntry*/{\n var UCFullPaths /*:Array*/ = cfb.FullPaths.map(function (x) {\n return x.toUpperCase();\n });\n var UCPaths /*:Array*/ = UCFullPaths.map(function (x) {\n var y = x.split(\"/\");\n return y[y.length - (x.slice(-1) == \"/\" ? 2 : 1)];\n });\n var k /*:boolean*/ = false;\n if (path.charCodeAt(0) === 47 /* \"/\" */) {\n k = true;\n path = UCFullPaths[0].slice(0, -1) + path;\n } else k = path.indexOf(\"/\") !== -1;\n var UCPath /*:string*/ = path.toUpperCase();\n var w /*:number*/ = k === true ? UCFullPaths.indexOf(UCPath) : UCPaths.indexOf(UCPath);\n if (w !== -1) return cfb.FileIndex[w];\n var m = !UCPath.match(chr1);\n UCPath = UCPath.replace(chr0, '');\n if (m) UCPath = UCPath.replace(chr1, '!');\n for (w = 0; w < UCFullPaths.length; ++w) {\n if ((m ? UCFullPaths[w].replace(chr1, '!') : UCFullPaths[w]).replace(chr0, '') == UCPath) return cfb.FileIndex[w];\n if ((m ? UCPaths[w].replace(chr1, '!') : UCPaths[w]).replace(chr0, '') == UCPath) return cfb.FileIndex[w];\n }\n return null;\n }\n /** CFB Constants */\n var MSSZ = 64; /* Mini Sector Size = 1<<6 */\n //var MSCSZ = 4096; /* Mini Stream Cutoff Size */\n /* 2.1 Compound File Sector Numbers and Types */\n var ENDOFCHAIN = -2;\n /* 2.2 Compound File Header */\n var HEADER_SIGNATURE = 'd0cf11e0a1b11ae1';\n var HEADER_SIG = [0xD0, 0xCF, 0x11, 0xE0, 0xA1, 0xB1, 0x1A, 0xE1];\n var HEADER_CLSID = '00000000000000000000000000000000';\n var consts = {\n /* 2.1 Compund File Sector Numbers and Types */\n MAXREGSECT: -6,\n DIFSECT: -4,\n FATSECT: -3,\n ENDOFCHAIN: ENDOFCHAIN,\n FREESECT: -1,\n /* 2.2 Compound File Header */\n HEADER_SIGNATURE: HEADER_SIGNATURE,\n HEADER_MINOR_VERSION: '3e00',\n MAXREGSID: -6,\n NOSTREAM: -1,\n HEADER_CLSID: HEADER_CLSID,\n /* 2.6.1 Compound File Directory Entry */\n EntryTypes: ['unknown', 'storage', 'stream', 'lockbytes', 'property', 'root']\n };\n function write_file(cfb /*:CFBContainer*/, filename /*:string*/, options /*:CFBWriteOpts*/) /*:void*/{\n get_fs();\n var o = _write(cfb, options);\n /*:: if(typeof Buffer == 'undefined' || !Buffer.isBuffer(o) || !(o instanceof Buffer)) throw new Error(\"unreachable\"); */\n fs.writeFileSync(filename, o);\n }\n function a2s(o /*:RawBytes*/) /*:string*/{\n var out = new Array(o.length);\n for (var i = 0; i < o.length; ++i) out[i] = String.fromCharCode(o[i]);\n return out.join(\"\");\n }\n function write(cfb /*:CFBContainer*/, options /*:CFBWriteOpts*/) /*:RawBytes|string*/{\n var o = _write(cfb, options);\n switch (options && options.type || \"buffer\") {\n case \"file\":\n get_fs();\n fs.writeFileSync(options.filename, o /*:any*/);\n return o;\n case \"binary\":\n return typeof o == \"string\" ? o : a2s(o);\n case \"base64\":\n return Base64_encode(typeof o == \"string\" ? o : a2s(o));\n case \"buffer\":\n if (has_buf) return Buffer.isBuffer(o) ? o : Buffer_from(o);\n /* falls through */\n case \"array\":\n return typeof o == \"string\" ? s2a(o) : o;\n }\n return o;\n }\n /* node < 8.1 zlib does not expose bytesRead, so default to pure JS */\n var _zlib;\n function use_zlib(zlib) {\n try {\n var InflateRaw = zlib.InflateRaw;\n var InflRaw = new InflateRaw();\n InflRaw._processChunk(new Uint8Array([3, 0]), InflRaw._finishFlushFlag);\n if (InflRaw.bytesRead) _zlib = zlib;else throw new Error(\"zlib does not expose bytesRead\");\n } catch (e) {\n console.error(\"cannot use native zlib: \" + (e.message || e));\n }\n }\n function _inflateRawSync(payload, usz) {\n if (!_zlib) return _inflate(payload, usz);\n var InflateRaw = _zlib.InflateRaw;\n var InflRaw = new InflateRaw();\n var out = InflRaw._processChunk(payload.slice(payload.l), InflRaw._finishFlushFlag);\n payload.l += InflRaw.bytesRead;\n return out;\n }\n function _deflateRawSync(payload) {\n return _zlib ? _zlib.deflateRawSync(payload) : _deflate(payload);\n }\n var CLEN_ORDER = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15];\n\n /* LEN_ID = [ 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285 ]; */\n var LEN_LN = [3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258];\n\n /* DST_ID = [ 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, 26, 27, 28, 29 ]; */\n var DST_LN = [1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577];\n function bit_swap_8(n) {\n var t = (n << 1 | n << 11) & 0x22110 | (n << 5 | n << 15) & 0x88440;\n return (t >> 16 | t >> 8 | t) & 0xFF;\n }\n var use_typed_arrays = typeof Uint8Array !== 'undefined';\n var bitswap8 = use_typed_arrays ? new Uint8Array(1 << 8) : [];\n for (var q = 0; q < 1 << 8; ++q) bitswap8[q] = bit_swap_8(q);\n function bit_swap_n(n, b) {\n var rev = bitswap8[n & 0xFF];\n if (b <= 8) return rev >>> 8 - b;\n rev = rev << 8 | bitswap8[n >> 8 & 0xFF];\n if (b <= 16) return rev >>> 16 - b;\n rev = rev << 8 | bitswap8[n >> 16 & 0xFF];\n return rev >>> 24 - b;\n }\n\n /* helpers for unaligned bit reads */\n function read_bits_2(buf, bl) {\n var w = bl & 7,\n h = bl >>> 3;\n return (buf[h] | (w <= 6 ? 0 : buf[h + 1] << 8)) >>> w & 0x03;\n }\n function read_bits_3(buf, bl) {\n var w = bl & 7,\n h = bl >>> 3;\n return (buf[h] | (w <= 5 ? 0 : buf[h + 1] << 8)) >>> w & 0x07;\n }\n function read_bits_4(buf, bl) {\n var w = bl & 7,\n h = bl >>> 3;\n return (buf[h] | (w <= 4 ? 0 : buf[h + 1] << 8)) >>> w & 0x0F;\n }\n function read_bits_5(buf, bl) {\n var w = bl & 7,\n h = bl >>> 3;\n return (buf[h] | (w <= 3 ? 0 : buf[h + 1] << 8)) >>> w & 0x1F;\n }\n function read_bits_7(buf, bl) {\n var w = bl & 7,\n h = bl >>> 3;\n return (buf[h] | (w <= 1 ? 0 : buf[h + 1] << 8)) >>> w & 0x7F;\n }\n\n /* works up to n = 3 * 8 + 1 = 25 */\n function read_bits_n(buf, bl, n) {\n var w = bl & 7,\n h = bl >>> 3,\n f = (1 << n) - 1;\n var v = buf[h] >>> w;\n if (n < 8 - w) return v & f;\n v |= buf[h + 1] << 8 - w;\n if (n < 16 - w) return v & f;\n v |= buf[h + 2] << 16 - w;\n if (n < 24 - w) return v & f;\n v |= buf[h + 3] << 24 - w;\n return v & f;\n }\n\n /* helpers for unaligned bit writes */\n function write_bits_3(buf, bl, v) {\n var w = bl & 7,\n h = bl >>> 3;\n if (w <= 5) buf[h] |= (v & 7) << w;else {\n buf[h] |= v << w & 0xFF;\n buf[h + 1] = (v & 7) >> 8 - w;\n }\n return bl + 3;\n }\n function write_bits_1(buf, bl, v) {\n var w = bl & 7,\n h = bl >>> 3;\n v = (v & 1) << w;\n buf[h] |= v;\n return bl + 1;\n }\n function write_bits_8(buf, bl, v) {\n var w = bl & 7,\n h = bl >>> 3;\n v <<= w;\n buf[h] |= v & 0xFF;\n v >>>= 8;\n buf[h + 1] = v;\n return bl + 8;\n }\n function write_bits_16(buf, bl, v) {\n var w = bl & 7,\n h = bl >>> 3;\n v <<= w;\n buf[h] |= v & 0xFF;\n v >>>= 8;\n buf[h + 1] = v & 0xFF;\n buf[h + 2] = v >>> 8;\n return bl + 16;\n }\n\n /* until ArrayBuffer#realloc is a thing, fake a realloc */\n function realloc(b, sz /*:number*/) {\n var L = b.length,\n M = 2 * L > sz ? 2 * L : sz + 5,\n i = 0;\n if (L >= sz) return b;\n if (has_buf) {\n var o = new_unsafe_buf(M);\n // $FlowIgnore\n if (b.copy) b.copy(o);else for (; i < b.length; ++i) o[i] = b[i];\n return o;\n } else if (use_typed_arrays) {\n var a = new Uint8Array(M);\n if (a.set) a.set(b);else for (; i < L; ++i) a[i] = b[i];\n return a;\n }\n b.length = M;\n return b;\n }\n\n /* zero-filled arrays for older browsers */\n function zero_fill_array(n) {\n var o = new Array(n);\n for (var i = 0; i < n; ++i) o[i] = 0;\n return o;\n }\n\n /* build tree (used for literals and lengths) */\n function build_tree(clens, cmap, MAX /*:number*/) /*:number*/{\n var maxlen = 1,\n w = 0,\n i = 0,\n j = 0,\n ccode = 0,\n L = clens.length;\n var bl_count = use_typed_arrays ? new Uint16Array(32) : zero_fill_array(32);\n for (i = 0; i < 32; ++i) bl_count[i] = 0;\n for (i = L; i < MAX; ++i) clens[i] = 0;\n L = clens.length;\n var ctree = use_typed_arrays ? new Uint16Array(L) : zero_fill_array(L); // []\n\n /* build code tree */\n for (i = 0; i < L; ++i) {\n bl_count[w = clens[i]]++;\n if (maxlen < w) maxlen = w;\n ctree[i] = 0;\n }\n bl_count[0] = 0;\n for (i = 1; i <= maxlen; ++i) bl_count[i + 16] = ccode = ccode + bl_count[i - 1] << 1;\n for (i = 0; i < L; ++i) {\n ccode = clens[i];\n if (ccode != 0) ctree[i] = bl_count[ccode + 16]++;\n }\n\n /* cmap[maxlen + 4 bits] = (off&15) + (lit<<4) reverse mapping */\n var cleni = 0;\n for (i = 0; i < L; ++i) {\n cleni = clens[i];\n if (cleni != 0) {\n ccode = bit_swap_n(ctree[i], maxlen) >> maxlen - cleni;\n for (j = (1 << maxlen + 4 - cleni) - 1; j >= 0; --j) cmap[ccode | j << cleni] = cleni & 15 | i << 4;\n }\n }\n return maxlen;\n }\n\n /* Fixed Huffman */\n var fix_lmap = use_typed_arrays ? new Uint16Array(512) : zero_fill_array(512);\n var fix_dmap = use_typed_arrays ? new Uint16Array(32) : zero_fill_array(32);\n if (!use_typed_arrays) {\n for (var i = 0; i < 512; ++i) fix_lmap[i] = 0;\n for (i = 0; i < 32; ++i) fix_dmap[i] = 0;\n }\n (function () {\n var dlens /*:Array*/ = [];\n var i = 0;\n for (; i < 32; i++) dlens.push(5);\n build_tree(dlens, fix_dmap, 32);\n var clens /*:Array*/ = [];\n i = 0;\n for (; i <= 143; i++) clens.push(8);\n for (; i <= 255; i++) clens.push(9);\n for (; i <= 279; i++) clens.push(7);\n for (; i <= 287; i++) clens.push(8);\n build_tree(clens, fix_lmap, 288);\n })();\n var _deflateRaw = /*#__PURE__*/function _deflateRawIIFE() {\n var DST_LN_RE = use_typed_arrays ? new Uint8Array(0x8000) : [];\n var j = 0,\n k = 0;\n for (; j < DST_LN.length - 1; ++j) {\n for (; k < DST_LN[j + 1]; ++k) DST_LN_RE[k] = j;\n }\n for (; k < 32768; ++k) DST_LN_RE[k] = 29;\n var LEN_LN_RE = use_typed_arrays ? new Uint8Array(0x103) : [];\n for (j = 0, k = 0; j < LEN_LN.length - 1; ++j) {\n for (; k < LEN_LN[j + 1]; ++k) LEN_LN_RE[k] = j;\n }\n function write_stored(data, out) {\n var boff = 0;\n while (boff < data.length) {\n var L = Math.min(0xFFFF, data.length - boff);\n var h = boff + L == data.length;\n out.write_shift(1, +h);\n out.write_shift(2, L);\n out.write_shift(2, ~L & 0xFFFF);\n while (L-- > 0) out[out.l++] = data[boff++];\n }\n return out.l;\n }\n\n /* Fixed Huffman */\n function write_huff_fixed(data, out) {\n var bl = 0;\n var boff = 0;\n var addrs = use_typed_arrays ? new Uint16Array(0x8000) : [];\n while (boff < data.length) {\n var L = /* data.length - boff; */Math.min(0xFFFF, data.length - boff);\n\n /* write a stored block for short data */\n if (L < 10) {\n bl = write_bits_3(out, bl, +!!(boff + L == data.length)); // jshint ignore:line\n if (bl & 7) bl += 8 - (bl & 7);\n out.l = bl / 8 | 0;\n out.write_shift(2, L);\n out.write_shift(2, ~L & 0xFFFF);\n while (L-- > 0) out[out.l++] = data[boff++];\n bl = out.l * 8;\n continue;\n }\n bl = write_bits_3(out, bl, +!!(boff + L == data.length) + 2); // jshint ignore:line\n var hash = 0;\n while (L-- > 0) {\n var d = data[boff];\n hash = (hash << 5 ^ d) & 0x7FFF;\n var match = -1,\n mlen = 0;\n if (match = addrs[hash]) {\n match |= boff & ~0x7FFF;\n if (match > boff) match -= 0x8000;\n if (match < boff) while (data[match + mlen] == data[boff + mlen] && mlen < 250) ++mlen;\n }\n if (mlen > 2) {\n /* Copy Token */\n d = LEN_LN_RE[mlen];\n if (d <= 22) bl = write_bits_8(out, bl, bitswap8[d + 1] >> 1) - 1;else {\n write_bits_8(out, bl, 3);\n bl += 5;\n write_bits_8(out, bl, bitswap8[d - 23] >> 5);\n bl += 3;\n }\n var len_eb = d < 8 ? 0 : d - 4 >> 2;\n if (len_eb > 0) {\n write_bits_16(out, bl, mlen - LEN_LN[d]);\n bl += len_eb;\n }\n d = DST_LN_RE[boff - match];\n bl = write_bits_8(out, bl, bitswap8[d] >> 3);\n bl -= 3;\n var dst_eb = d < 4 ? 0 : d - 2 >> 1;\n if (dst_eb > 0) {\n write_bits_16(out, bl, boff - match - DST_LN[d]);\n bl += dst_eb;\n }\n for (var q = 0; q < mlen; ++q) {\n addrs[hash] = boff & 0x7FFF;\n hash = (hash << 5 ^ data[boff]) & 0x7FFF;\n ++boff;\n }\n L -= mlen - 1;\n } else {\n /* Literal Token */\n if (d <= 143) d = d + 48;else bl = write_bits_1(out, bl, 1);\n bl = write_bits_8(out, bl, bitswap8[d]);\n addrs[hash] = boff & 0x7FFF;\n ++boff;\n }\n }\n bl = write_bits_8(out, bl, 0) - 1;\n }\n out.l = (bl + 7) / 8 | 0;\n return out.l;\n }\n return function _deflateRaw(data, out) {\n if (data.length < 8) return write_stored(data, out);\n return write_huff_fixed(data, out);\n };\n }();\n function _deflate(data) {\n var buf = new_buf(50 + Math.floor(data.length * 1.1));\n var off = _deflateRaw(data, buf);\n return buf.slice(0, off);\n }\n /* modified inflate function also moves original read head */\n\n var dyn_lmap = use_typed_arrays ? new Uint16Array(32768) : zero_fill_array(32768);\n var dyn_dmap = use_typed_arrays ? new Uint16Array(32768) : zero_fill_array(32768);\n var dyn_cmap = use_typed_arrays ? new Uint16Array(128) : zero_fill_array(128);\n var dyn_len_1 = 1,\n dyn_len_2 = 1;\n\n /* 5.5.3 Expanding Huffman Codes */\n function dyn(data, boff /*:number*/) {\n /* nomenclature from RFC1951 refers to bit values; these are offset by the implicit constant */\n var _HLIT = read_bits_5(data, boff) + 257;\n boff += 5;\n var _HDIST = read_bits_5(data, boff) + 1;\n boff += 5;\n var _HCLEN = read_bits_4(data, boff) + 4;\n boff += 4;\n var w = 0;\n\n /* grab and store code lengths */\n var clens = use_typed_arrays ? new Uint8Array(19) : zero_fill_array(19);\n var ctree = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];\n var maxlen = 1;\n var bl_count = use_typed_arrays ? new Uint8Array(8) : zero_fill_array(8);\n var next_code = use_typed_arrays ? new Uint8Array(8) : zero_fill_array(8);\n var L = clens.length; /* 19 */\n for (var i = 0; i < _HCLEN; ++i) {\n clens[CLEN_ORDER[i]] = w = read_bits_3(data, boff);\n if (maxlen < w) maxlen = w;\n bl_count[w]++;\n boff += 3;\n }\n\n /* build code tree */\n var ccode = 0;\n bl_count[0] = 0;\n for (i = 1; i <= maxlen; ++i) next_code[i] = ccode = ccode + bl_count[i - 1] << 1;\n for (i = 0; i < L; ++i) if ((ccode = clens[i]) != 0) ctree[i] = next_code[ccode]++;\n /* cmap[7 bits from stream] = (off&7) + (lit<<3) */\n var cleni = 0;\n for (i = 0; i < L; ++i) {\n cleni = clens[i];\n if (cleni != 0) {\n ccode = bitswap8[ctree[i]] >> 8 - cleni;\n for (var j = (1 << 7 - cleni) - 1; j >= 0; --j) dyn_cmap[ccode | j << cleni] = cleni & 7 | i << 3;\n }\n }\n\n /* read literal and dist codes at once */\n var hcodes /*:Array*/ = [];\n maxlen = 1;\n for (; hcodes.length < _HLIT + _HDIST;) {\n ccode = dyn_cmap[read_bits_7(data, boff)];\n boff += ccode & 7;\n switch (ccode >>>= 3) {\n case 16:\n w = 3 + read_bits_2(data, boff);\n boff += 2;\n ccode = hcodes[hcodes.length - 1];\n while (w-- > 0) hcodes.push(ccode);\n break;\n case 17:\n w = 3 + read_bits_3(data, boff);\n boff += 3;\n while (w-- > 0) hcodes.push(0);\n break;\n case 18:\n w = 11 + read_bits_7(data, boff);\n boff += 7;\n while (w-- > 0) hcodes.push(0);\n break;\n default:\n hcodes.push(ccode);\n if (maxlen < ccode) maxlen = ccode;\n break;\n }\n }\n\n /* build literal / length trees */\n var h1 = hcodes.slice(0, _HLIT),\n h2 = hcodes.slice(_HLIT);\n for (i = _HLIT; i < 286; ++i) h1[i] = 0;\n for (i = _HDIST; i < 30; ++i) h2[i] = 0;\n dyn_len_1 = build_tree(h1, dyn_lmap, 286);\n dyn_len_2 = build_tree(h2, dyn_dmap, 30);\n return boff;\n }\n\n /* return [ data, bytesRead ] */\n function inflate(data, usz /*:number*/) {\n /* shortcircuit for empty buffer [0x03, 0x00] */\n if (data[0] == 3 && !(data[1] & 0x3)) {\n return [new_raw_buf(usz), 2];\n }\n\n /* bit offset */\n var boff = 0;\n\n /* header includes final bit and type bits */\n var header = 0;\n var outbuf = new_unsafe_buf(usz ? usz : 1 << 18);\n var woff = 0;\n var OL = outbuf.length >>> 0;\n var max_len_1 = 0,\n max_len_2 = 0;\n while ((header & 1) == 0) {\n header = read_bits_3(data, boff);\n boff += 3;\n if (header >>> 1 == 0) {\n /* Stored block */\n if (boff & 7) boff += 8 - (boff & 7);\n /* 2 bytes sz, 2 bytes bit inverse */\n var sz = data[boff >>> 3] | data[(boff >>> 3) + 1] << 8;\n boff += 32;\n /* push sz bytes */\n if (sz > 0) {\n if (!usz && OL < woff + sz) {\n outbuf = realloc(outbuf, woff + sz);\n OL = outbuf.length;\n }\n while (sz-- > 0) {\n outbuf[woff++] = data[boff >>> 3];\n boff += 8;\n }\n }\n continue;\n } else if (header >> 1 == 1) {\n /* Fixed Huffman */\n max_len_1 = 9;\n max_len_2 = 5;\n } else {\n /* Dynamic Huffman */\n boff = dyn(data, boff);\n max_len_1 = dyn_len_1;\n max_len_2 = dyn_len_2;\n }\n for (;;) {\n // while(true) is apparently out of vogue in modern JS circles\n if (!usz && OL < woff + 32767) {\n outbuf = realloc(outbuf, woff + 32767);\n OL = outbuf.length;\n }\n /* ingest code and move read head */\n var bits = read_bits_n(data, boff, max_len_1);\n var code = header >>> 1 == 1 ? fix_lmap[bits] : dyn_lmap[bits];\n boff += code & 15;\n code >>>= 4;\n /* 0-255 are literals, 256 is end of block token, 257+ are copy tokens */\n if ((code >>> 8 & 0xFF) === 0) outbuf[woff++] = code;else if (code == 256) break;else {\n code -= 257;\n var len_eb = code < 8 ? 0 : code - 4 >> 2;\n if (len_eb > 5) len_eb = 0;\n var tgt = woff + LEN_LN[code];\n /* length extra bits */\n if (len_eb > 0) {\n tgt += read_bits_n(data, boff, len_eb);\n boff += len_eb;\n }\n\n /* dist code */\n bits = read_bits_n(data, boff, max_len_2);\n code = header >>> 1 == 1 ? fix_dmap[bits] : dyn_dmap[bits];\n boff += code & 15;\n code >>>= 4;\n var dst_eb = code < 4 ? 0 : code - 2 >> 1;\n var dst = DST_LN[code];\n /* dist extra bits */\n if (dst_eb > 0) {\n dst += read_bits_n(data, boff, dst_eb);\n boff += dst_eb;\n }\n\n /* in the common case, manual byte copy is faster than TA set / Buffer copy */\n if (!usz && OL < tgt) {\n outbuf = realloc(outbuf, tgt + 100);\n OL = outbuf.length;\n }\n while (woff < tgt) {\n outbuf[woff] = outbuf[woff - dst];\n ++woff;\n }\n }\n }\n }\n if (usz) return [outbuf, boff + 7 >>> 3];\n return [outbuf.slice(0, woff), boff + 7 >>> 3];\n }\n function _inflate(payload, usz) {\n var data = payload.slice(payload.l || 0);\n var out = inflate(data, usz);\n payload.l += out[1];\n return out[0];\n }\n function warn_or_throw(wrn, msg) {\n if (wrn) {\n if (typeof console !== 'undefined') console.error(msg);\n } else throw new Error(msg);\n }\n function parse_zip(file /*:RawBytes*/, options /*:CFBReadOpts*/) /*:CFBContainer*/{\n var blob /*:CFBlob*/ = /*::(*/file /*:: :any)*/;\n prep_blob(blob, 0);\n var FileIndex /*:CFBFileIndex*/ = [],\n FullPaths /*:Array*/ = [];\n var o = {\n FileIndex: FileIndex,\n FullPaths: FullPaths\n };\n init_cfb(o, {\n root: options.root\n });\n\n /* find end of central directory, start just after signature */\n var i = blob.length - 4;\n while ((blob[i] != 0x50 || blob[i + 1] != 0x4b || blob[i + 2] != 0x05 || blob[i + 3] != 0x06) && i >= 0) --i;\n blob.l = i + 4;\n\n /* parse end of central directory */\n blob.l += 4;\n var fcnt = blob.read_shift(2);\n blob.l += 6;\n var start_cd = blob.read_shift(4);\n\n /* parse central directory */\n blob.l = start_cd;\n for (i = 0; i < fcnt; ++i) {\n /* trust local file header instead of CD entry */\n blob.l += 20;\n var csz = blob.read_shift(4);\n var usz = blob.read_shift(4);\n var namelen = blob.read_shift(2);\n var efsz = blob.read_shift(2);\n var fcsz = blob.read_shift(2);\n blob.l += 8;\n var offset = blob.read_shift(4);\n var EF = parse_extra_field(/*::(*/blob.slice(blob.l + namelen, blob.l + namelen + efsz) /*:: :any)*/);\n blob.l += namelen + efsz + fcsz;\n var L = blob.l;\n blob.l = offset + 4;\n parse_local_file(blob, csz, usz, o, EF);\n blob.l = L;\n }\n return o;\n }\n\n /* head starts just after local file header signature */\n function parse_local_file(blob /*:CFBlob*/, csz /*:number*/, usz /*:number*/, o /*:CFBContainer*/, EF) {\n /* [local file header] */\n blob.l += 2;\n var flags = blob.read_shift(2);\n var meth = blob.read_shift(2);\n var date = parse_dos_date(blob);\n if (flags & 0x2041) throw new Error(\"Unsupported ZIP encryption\");\n var crc32 = blob.read_shift(4);\n var _csz = blob.read_shift(4);\n var _usz = blob.read_shift(4);\n var namelen = blob.read_shift(2);\n var efsz = blob.read_shift(2);\n\n // TODO: flags & (1<<11) // UTF8\n var name = \"\";\n for (var i = 0; i < namelen; ++i) name += String.fromCharCode(blob[blob.l++]);\n if (efsz) {\n var ef = parse_extra_field(/*::(*/blob.slice(blob.l, blob.l + efsz) /*:: :any)*/);\n if ((ef[0x5455] || {}).mt) date = ef[0x5455].mt;\n if (((EF || {})[0x5455] || {}).mt) date = EF[0x5455].mt;\n }\n blob.l += efsz;\n\n /* [encryption header] */\n\n /* [file data] */\n var data = blob.slice(blob.l, blob.l + _csz);\n switch (meth) {\n case 8:\n data = _inflateRawSync(blob, _usz);\n break;\n case 0:\n break;\n // TODO: scan for magic number\n default:\n throw new Error(\"Unsupported ZIP Compression method \" + meth);\n }\n\n /* [data descriptor] */\n var wrn = false;\n if (flags & 8) {\n crc32 = blob.read_shift(4);\n if (crc32 == 0x08074b50) {\n crc32 = blob.read_shift(4);\n wrn = true;\n }\n _csz = blob.read_shift(4);\n _usz = blob.read_shift(4);\n }\n if (_csz != csz) warn_or_throw(wrn, \"Bad compressed size: \" + csz + \" != \" + _csz);\n if (_usz != usz) warn_or_throw(wrn, \"Bad uncompressed size: \" + usz + \" != \" + _usz);\n //var _crc32 = CRC32.buf(data, 0);\n //if((crc32>>0) != (_crc32>>0)) warn_or_throw(wrn, \"Bad CRC32 checksum: \" + crc32 + \" != \" + _crc32);\n cfb_add(o, name, data, {\n unsafe: true,\n mt: date\n });\n }\n function write_zip(cfb /*:CFBContainer*/, options /*:CFBWriteOpts*/) /*:RawBytes*/{\n var _opts = options || {};\n var out = [],\n cdirs = [];\n var o /*:CFBlob*/ = new_buf(1);\n var method = _opts.compression ? 8 : 0,\n flags = 0;\n var desc = false;\n if (desc) flags |= 8;\n var i = 0,\n j = 0;\n var start_cd = 0,\n fcnt = 0;\n var root = cfb.FullPaths[0],\n fp = root,\n fi = cfb.FileIndex[0];\n var crcs = [];\n var sz_cd = 0;\n for (i = 1; i < cfb.FullPaths.length; ++i) {\n fp = cfb.FullPaths[i].slice(root.length);\n fi = cfb.FileIndex[i];\n if (!fi.size || !fi.content || fp == \"\\u0001Sh33tJ5\") continue;\n var start = start_cd;\n\n /* TODO: CP437 filename */\n var namebuf = new_buf(fp.length);\n for (j = 0; j < fp.length; ++j) namebuf.write_shift(1, fp.charCodeAt(j) & 0x7F);\n namebuf = namebuf.slice(0, namebuf.l);\n crcs[fcnt] = CRC32.buf(/*::((*/fi.content /*::||[]):any)*/, 0);\n var outbuf = fi.content /*::||[]*/;\n if (method == 8) outbuf = _deflateRawSync(outbuf);\n\n /* local file header */\n o = new_buf(30);\n o.write_shift(4, 0x04034b50);\n o.write_shift(2, 20);\n o.write_shift(2, flags);\n o.write_shift(2, method);\n /* TODO: last mod file time/date */\n if (fi.mt) write_dos_date(o, fi.mt);else o.write_shift(4, 0);\n o.write_shift(-4, flags & 8 ? 0 : crcs[fcnt]);\n o.write_shift(4, flags & 8 ? 0 : outbuf.length);\n o.write_shift(4, flags & 8 ? 0 : /*::(*/fi.content /*::||[])*/.length);\n o.write_shift(2, namebuf.length);\n o.write_shift(2, 0);\n start_cd += o.length;\n out.push(o);\n start_cd += namebuf.length;\n out.push(namebuf);\n\n /* TODO: extra fields? */\n\n /* TODO: encryption header ? */\n\n start_cd += outbuf.length;\n out.push(outbuf);\n\n /* data descriptor */\n if (flags & 8) {\n o = new_buf(12);\n o.write_shift(-4, crcs[fcnt]);\n o.write_shift(4, outbuf.length);\n o.write_shift(4, /*::(*/fi.content /*::||[])*/.length);\n start_cd += o.l;\n out.push(o);\n }\n\n /* central directory */\n o = new_buf(46);\n o.write_shift(4, 0x02014b50);\n o.write_shift(2, 0);\n o.write_shift(2, 20);\n o.write_shift(2, flags);\n o.write_shift(2, method);\n o.write_shift(4, 0); /* TODO: last mod file time/date */\n o.write_shift(-4, crcs[fcnt]);\n o.write_shift(4, outbuf.length);\n o.write_shift(4, /*::(*/fi.content /*::||[])*/.length);\n o.write_shift(2, namebuf.length);\n o.write_shift(2, 0);\n o.write_shift(2, 0);\n o.write_shift(2, 0);\n o.write_shift(2, 0);\n o.write_shift(4, 0);\n o.write_shift(4, start);\n sz_cd += o.l;\n cdirs.push(o);\n sz_cd += namebuf.length;\n cdirs.push(namebuf);\n ++fcnt;\n }\n\n /* end of central directory */\n o = new_buf(22);\n o.write_shift(4, 0x06054b50);\n o.write_shift(2, 0);\n o.write_shift(2, 0);\n o.write_shift(2, fcnt);\n o.write_shift(2, fcnt);\n o.write_shift(4, sz_cd);\n o.write_shift(4, start_cd);\n o.write_shift(2, 0);\n return bconcat([bconcat(out /*:any*/), bconcat(cdirs), o] /*:any*/);\n }\n var ContentTypeMap = {\n \"htm\": \"text/html\",\n \"xml\": \"text/xml\",\n \"gif\": \"image/gif\",\n \"jpg\": \"image/jpeg\",\n \"png\": \"image/png\",\n \"mso\": \"application/x-mso\",\n \"thmx\": \"application/vnd.ms-officetheme\",\n \"sh33tj5\": \"application/octet-stream\"\n } /*:any*/;\n function get_content_type(fi /*:CFBEntry*/, fp /*:string*/) /*:string*/{\n if (fi.ctype) return fi.ctype;\n var ext = fi.name || \"\",\n m = ext.match(/\\.([^\\.]+)$/);\n if (m && ContentTypeMap[m[1]]) return ContentTypeMap[m[1]];\n if (fp) {\n m = (ext = fp).match(/[\\.\\\\]([^\\.\\\\])+$/);\n if (m && ContentTypeMap[m[1]]) return ContentTypeMap[m[1]];\n }\n return \"application/octet-stream\";\n }\n\n /* 76 character chunks TODO: intertwine encoding */\n function write_base64_76(bstr /*:string*/) /*:string*/{\n var data = Base64_encode(bstr);\n var o = [];\n for (var i = 0; i < data.length; i += 76) o.push(data.slice(i, i + 76));\n return o.join(\"\\r\\n\") + \"\\r\\n\";\n }\n\n /*\n Rules for QP:\n \t- escape =## applies for all non-display characters and literal \"=\"\n \t- space or tab at end of line must be encoded\n \t- \\r\\n newlines can be preserved, but bare \\r and \\n must be escaped\n \t- lines must not exceed 76 characters, use soft breaks =\\r\\n\n \n TODO: Some files from word appear to write line extensions with bare equals:\n \n ```\n */ = [],\n split = encoded.split(\"\\r\\n\");\n for (var si = 0; si < split.length; ++si) {\n var str = split[si];\n if (str.length == 0) {\n o.push(\"\");\n continue;\n }\n for (var i = 0; i < str.length;) {\n var end = 76;\n var tmp = str.slice(i, i + end);\n if (tmp.charAt(end - 1) == \"=\") end--;else if (tmp.charAt(end - 2) == \"=\") end -= 2;else if (tmp.charAt(end - 3) == \"=\") end -= 3;\n tmp = str.slice(i, i + end);\n i += end;\n if (i < str.length) tmp += \"=\";\n o.push(tmp);\n }\n }\n return o.join(\"\\r\\n\");\n }\n function parse_quoted_printable(data /*:Array*/) /*:RawBytes*/{\n var o = [];\n\n /* unify long lines */\n for (var di = 0; di < data.length; ++di) {\n var line = data[di];\n while (di <= data.length && line.charAt(line.length - 1) == \"=\") line = line.slice(0, line.length - 1) + data[++di];\n o.push(line);\n }\n\n /* decode */\n for (var oi = 0; oi < o.length; ++oi) o[oi] = o[oi].replace(/[=][0-9A-Fa-f]{2}/g, function ($$) {\n return String.fromCharCode(parseInt($$.slice(1), 16));\n });\n return s2a(o.join(\"\\r\\n\"));\n }\n function parse_mime(cfb /*:CFBContainer*/, data /*:Array*/, root /*:string*/) /*:void*/{\n var fname = \"\",\n cte = \"\",\n ctype = \"\",\n fdata;\n var di = 0;\n for (; di < 10; ++di) {\n var line = data[di];\n if (!line || line.match(/^\\s*$/)) break;\n var m = line.match(/^(.*?):\\s*([^\\s].*)$/);\n if (m) switch (m[1].toLowerCase()) {\n case \"content-location\":\n fname = m[2].trim();\n break;\n case \"content-type\":\n ctype = m[2].trim();\n break;\n case \"content-transfer-encoding\":\n cte = m[2].trim();\n break;\n }\n }\n ++di;\n switch (cte.toLowerCase()) {\n case 'base64':\n fdata = s2a(Base64_decode(data.slice(di).join(\"\")));\n break;\n case 'quoted-printable':\n fdata = parse_quoted_printable(data.slice(di));\n break;\n default:\n throw new Error(\"Unsupported Content-Transfer-Encoding \" + cte);\n }\n var file = cfb_add(cfb, fname.slice(root.length), fdata, {\n unsafe: true\n });\n if (ctype) file.ctype = ctype;\n }\n function parse_mad(file /*:RawBytes*/, options /*:CFBReadOpts*/) /*:CFBContainer*/{\n if (a2s(file.slice(0, 13)).toLowerCase() != \"mime-version:\") throw new Error(\"Unsupported MAD header\");\n var root = options && options.root || \"\";\n // $FlowIgnore\n var data = (has_buf && Buffer.isBuffer(file) ? file.toString(\"binary\") : a2s(file)).split(\"\\r\\n\");\n var di = 0,\n row = \"\";\n\n /* if root is not specified, scan for the common prefix */\n for (di = 0; di < data.length; ++di) {\n row = data[di];\n if (!/^Content-Location:/i.test(row)) continue;\n row = row.slice(row.indexOf(\"file\"));\n if (!root) root = row.slice(0, row.lastIndexOf(\"/\") + 1);\n if (row.slice(0, root.length) == root) continue;\n while (root.length > 0) {\n root = root.slice(0, root.length - 1);\n root = root.slice(0, root.lastIndexOf(\"/\") + 1);\n if (row.slice(0, root.length) == root) break;\n }\n }\n var mboundary = (data[1] || \"\").match(/boundary=\"(.*?)\"/);\n if (!mboundary) throw new Error(\"MAD cannot find boundary\");\n var boundary = \"--\" + (mboundary[1] || \"\");\n var FileIndex /*:CFBFileIndex*/ = [],\n FullPaths /*:Array*/ = [];\n var o = {\n FileIndex: FileIndex,\n FullPaths: FullPaths\n };\n init_cfb(o);\n var start_di,\n fcnt = 0;\n for (di = 0; di < data.length; ++di) {\n var line = data[di];\n if (line !== boundary && line !== boundary + \"--\") continue;\n if (fcnt++) parse_mime(o, data.slice(start_di, di), root);\n start_di = di;\n }\n return o;\n }\n function write_mad(cfb /*:CFBContainer*/, options /*:CFBWriteOpts*/) /*:string*/{\n var opts = options || {};\n var boundary = opts.boundary || \"SheetJS\";\n boundary = '------=' + boundary;\n var out = ['MIME-Version: 1.0', 'Content-Type: multipart/related; boundary=\"' + boundary.slice(2) + '\"', '', '', ''];\n var root = cfb.FullPaths[0],\n fp = root,\n fi = cfb.FileIndex[0];\n for (var i = 1; i < cfb.FullPaths.length; ++i) {\n fp = cfb.FullPaths[i].slice(root.length);\n fi = cfb.FileIndex[i];\n if (!fi.size || !fi.content || fp == \"\\u0001Sh33tJ5\") continue;\n\n /* Normalize filename */\n fp = fp.replace(/[\\x00-\\x08\\x0B\\x0C\\x0E-\\x1F\\x7E-\\xFF]/g, function (c) {\n return \"_x\" + c.charCodeAt(0).toString(16) + \"_\";\n }).replace(/[\\u0080-\\uFFFF]/g, function (u) {\n return \"_u\" + u.charCodeAt(0).toString(16) + \"_\";\n });\n\n /* Extract content as binary string */\n var ca = fi.content;\n // $FlowIgnore\n var cstr = has_buf && Buffer.isBuffer(ca) ? ca.toString(\"binary\") : a2s(ca);\n\n /* 4/5 of first 1024 chars ascii -> quoted printable, else base64 */\n var dispcnt = 0,\n L = Math.min(1024, cstr.length),\n cc = 0;\n for (var csl = 0; csl <= L; ++csl) if ((cc = cstr.charCodeAt(csl)) >= 0x20 && cc < 0x80) ++dispcnt;\n var qp = dispcnt >= L * 4 / 5;\n out.push(boundary);\n out.push('Content-Location: ' + (opts.root || 'file:///C:/SheetJS/') + fp);\n out.push('Content-Transfer-Encoding: ' + (qp ? 'quoted-printable' : 'base64'));\n out.push('Content-Type: ' + get_content_type(fi, fp));\n out.push('');\n out.push(qp ? write_quoted_printable(cstr) : write_base64_76(cstr));\n }\n out.push(boundary + '--\\r\\n');\n return out.join(\"\\r\\n\");\n }\n function cfb_new(opts /*:?any*/) /*:CFBContainer*/{\n var o /*:CFBContainer*/ = {} /*:any*/;\n init_cfb(o, opts);\n return o;\n }\n function cfb_add(cfb /*:CFBContainer*/, name /*:string*/, content /*:?RawBytes*/, opts /*:?any*/) /*:CFBEntry*/{\n var unsafe = opts && opts.unsafe;\n if (!unsafe) init_cfb(cfb);\n var file = !unsafe && CFB.find(cfb, name);\n if (!file) {\n var fpath /*:string*/ = cfb.FullPaths[0];\n if (name.slice(0, fpath.length) == fpath) fpath = name;else {\n if (fpath.slice(-1) != \"/\") fpath += \"/\";\n fpath = (fpath + name).replace(\"//\", \"/\");\n }\n file = {\n name: filename(name),\n type: 2\n } /*:any*/;\n cfb.FileIndex.push(file);\n cfb.FullPaths.push(fpath);\n if (!unsafe) CFB.utils.cfb_gc(cfb);\n }\n /*:: if(!file) throw new Error(\"unreachable\"); */\n file.content = content /*:any*/;\n file.size = content ? content.length : 0;\n if (opts) {\n if (opts.CLSID) file.clsid = opts.CLSID;\n if (opts.mt) file.mt = opts.mt;\n if (opts.ct) file.ct = opts.ct;\n }\n return file;\n }\n function cfb_del(cfb /*:CFBContainer*/, name /*:string*/) /*:boolean*/{\n init_cfb(cfb);\n var file = CFB.find(cfb, name);\n if (file) for (var j = 0; j < cfb.FileIndex.length; ++j) if (cfb.FileIndex[j] == file) {\n cfb.FileIndex.splice(j, 1);\n cfb.FullPaths.splice(j, 1);\n return true;\n }\n return false;\n }\n function cfb_mov(cfb /*:CFBContainer*/, old_name /*:string*/, new_name /*:string*/) /*:boolean*/{\n init_cfb(cfb);\n var file = CFB.find(cfb, old_name);\n if (file) for (var j = 0; j < cfb.FileIndex.length; ++j) if (cfb.FileIndex[j] == file) {\n cfb.FileIndex[j].name = filename(new_name);\n cfb.FullPaths[j] = new_name;\n return true;\n }\n return false;\n }\n function cfb_gc(cfb /*:CFBContainer*/) /*:void*/{\n rebuild_cfb(cfb, true);\n }\n exports.find = find;\n exports.read = read;\n exports.parse = parse;\n exports.write = write;\n exports.writeFile = write_file;\n exports.utils = {\n cfb_new: cfb_new,\n cfb_add: cfb_add,\n cfb_del: cfb_del,\n cfb_mov: cfb_mov,\n cfb_gc: cfb_gc,\n ReadShift: ReadShift,\n CheckField: CheckField,\n prep_blob: prep_blob,\n bconcat: bconcat,\n use_zlib: use_zlib,\n _deflateRaw: _deflate,\n _inflateRaw: _inflate,\n consts: consts\n };\n return exports;\n}();\nlet _fs = void 0;\nfunction set_fs(fs) {\n _fs = fs;\n}\nexport { set_fs };\n\n/* normalize data for blob ctor */\nfunction blobify(data) {\n if (typeof data === \"string\") return s2ab(data);\n if (Array.isArray(data)) return a2u(data);\n return data;\n}\n/* write or download file */\nfunction write_dl(fname /*:string*/, payload /*:any*/, enc /*:?string*/) {\n /*global IE_SaveFile, Blob, navigator, saveAs, document, File, chrome */\n if (typeof _fs !== 'undefined' && _fs.writeFileSync) return enc ? _fs.writeFileSync(fname, payload, enc) : _fs.writeFileSync(fname, payload);\n if (typeof Deno !== 'undefined') {\n /* in this spot, it's safe to assume typed arrays and TextEncoder/TextDecoder exist */\n if (enc && typeof payload == \"string\") switch (enc) {\n case \"utf8\":\n payload = new TextEncoder(enc).encode(payload);\n break;\n case \"binary\":\n payload = s2ab(payload);\n break;\n /* TODO: binary equivalent */\n default:\n throw new Error(\"Unsupported encoding \" + enc);\n }\n return Deno.writeFileSync(fname, payload);\n }\n var data = enc == \"utf8\" ? utf8write(payload) : payload;\n /*:: declare var IE_SaveFile: any; */\n if (typeof IE_SaveFile !== 'undefined') return IE_SaveFile(data, fname);\n if (typeof Blob !== 'undefined') {\n var blob = new Blob([blobify(data)], {\n type: \"application/octet-stream\"\n });\n /*:: declare var navigator: any; */\n if (typeof navigator !== 'undefined' && navigator.msSaveBlob) return navigator.msSaveBlob(blob, fname);\n /*:: declare var saveAs: any; */\n if (typeof saveAs !== 'undefined') return saveAs(blob, fname);\n if (typeof URL !== 'undefined' && typeof document !== 'undefined' && document.createElement && URL.createObjectURL) {\n var url = URL.createObjectURL(blob);\n /*:: declare var chrome: any; */\n if (typeof chrome === 'object' && typeof (chrome.downloads || {}).download == \"function\") {\n if (URL.revokeObjectURL && typeof setTimeout !== 'undefined') setTimeout(function () {\n URL.revokeObjectURL(url);\n }, 60000);\n return chrome.downloads.download({\n url: url,\n filename: fname,\n saveAs: true\n });\n }\n var a = document.createElement(\"a\");\n if (a.download != null) {\n /*:: if(document.body == null) throw new Error(\"unreachable\"); */\n a.download = fname;\n a.href = url;\n document.body.appendChild(a);\n a.click();\n /*:: if(document.body == null) throw new Error(\"unreachable\"); */\n document.body.removeChild(a);\n if (URL.revokeObjectURL && typeof setTimeout !== 'undefined') setTimeout(function () {\n URL.revokeObjectURL(url);\n }, 60000);\n return url;\n }\n }\n }\n // $FlowIgnore\n if (typeof $ !== 'undefined' && typeof File !== 'undefined' && typeof Folder !== 'undefined') try {\n // extendscript\n // $FlowIgnore\n var out = File(fname);\n out.open(\"w\");\n out.encoding = \"binary\";\n if (Array.isArray(payload)) payload = a2s(payload);\n out.write(payload);\n out.close();\n return payload;\n } catch (e) {\n if (!e.message || !e.message.match(/onstruct/)) throw e;\n }\n throw new Error(\"cannot save file \" + fname);\n}\n\n/* read binary data from file */\nfunction read_binary(path /*:string*/) {\n if (typeof _fs !== 'undefined') return _fs.readFileSync(path);\n if (typeof Deno !== 'undefined') return Deno.readFileSync(path);\n // $FlowIgnore\n if (typeof $ !== 'undefined' && typeof File !== 'undefined' && typeof Folder !== 'undefined') try {\n // extendscript\n // $FlowIgnore\n var infile = File(path);\n infile.open(\"r\");\n infile.encoding = \"binary\";\n var data = infile.read();\n infile.close();\n return data;\n } catch (e) {\n if (!e.message || !e.message.match(/onstruct/)) throw e;\n }\n throw new Error(\"Cannot access file \" + path);\n}\nfunction keys(o /*:any*/) /*:Array*/{\n var ks = Object.keys(o),\n o2 = [];\n for (var i = 0; i < ks.length; ++i) if (Object.prototype.hasOwnProperty.call(o, ks[i])) o2.push(ks[i]);\n return o2;\n}\nfunction evert_key(obj /*:any*/, key /*:string*/) /*:EvertType*/{\n var o = [] /*:any*/,\n K = keys(obj);\n for (var i = 0; i !== K.length; ++i) if (o[obj[K[i]][key]] == null) o[obj[K[i]][key]] = K[i];\n return o;\n}\nfunction evert(obj /*:any*/) /*:EvertType*/{\n var o = [] /*:any*/,\n K = keys(obj);\n for (var i = 0; i !== K.length; ++i) o[obj[K[i]]] = K[i];\n return o;\n}\nfunction evert_num(obj /*:any*/) /*:EvertNumType*/{\n var o = [] /*:any*/,\n K = keys(obj);\n for (var i = 0; i !== K.length; ++i) o[obj[K[i]]] = parseInt(K[i], 10);\n return o;\n}\nfunction evert_arr(obj /*:any*/) /*:EvertArrType*/{\n var o /*:EvertArrType*/ = [] /*:any*/,\n K = keys(obj);\n for (var i = 0; i !== K.length; ++i) {\n if (o[obj[K[i]]] == null) o[obj[K[i]]] = [];\n o[obj[K[i]]].push(K[i]);\n }\n return o;\n}\nvar basedate = /*#__PURE__*/new Date(1899, 11, 30, 0, 0, 0); // 2209161600000\nfunction datenum(v /*:Date*/, date1904 /*:?boolean*/) /*:number*/{\n var epoch = /*#__PURE__*/v.getTime();\n if (date1904) epoch -= 1462 * 24 * 60 * 60 * 1000;\n var dnthresh = /*#__PURE__*/basedate.getTime() + (/*#__PURE__*/v.getTimezoneOffset() - /*#__PURE__*/basedate.getTimezoneOffset()) * 60000;\n return (epoch - dnthresh) / (24 * 60 * 60 * 1000);\n}\nvar refdate = /*#__PURE__*/new Date();\nvar dnthresh = /*#__PURE__*/basedate.getTime() + (/*#__PURE__*/refdate.getTimezoneOffset() - /*#__PURE__*/basedate.getTimezoneOffset()) * 60000;\nvar refoffset = /*#__PURE__*/refdate.getTimezoneOffset();\nfunction numdate(v /*:number*/) /*:Date*/{\n var out = new Date();\n out.setTime(v * 24 * 60 * 60 * 1000 + dnthresh);\n if (out.getTimezoneOffset() !== refoffset) {\n out.setTime(out.getTime() + (out.getTimezoneOffset() - refoffset) * 60000);\n }\n return out;\n}\n\n/* ISO 8601 Duration */\nfunction parse_isodur(s) {\n var sec = 0,\n mt = 0,\n time = false;\n var m = s.match(/P([0-9\\.]+Y)?([0-9\\.]+M)?([0-9\\.]+D)?T([0-9\\.]+H)?([0-9\\.]+M)?([0-9\\.]+S)?/);\n if (!m) throw new Error(\"|\" + s + \"| is not an ISO8601 Duration\");\n for (var i = 1; i != m.length; ++i) {\n if (!m[i]) continue;\n mt = 1;\n if (i > 3) time = true;\n switch (m[i].slice(m[i].length - 1)) {\n case 'Y':\n throw new Error(\"Unsupported ISO Duration Field: \" + m[i].slice(m[i].length - 1));\n case 'D':\n mt *= 24;\n /* falls through */\n case 'H':\n mt *= 60;\n /* falls through */\n case 'M':\n if (!time) throw new Error(\"Unsupported ISO Duration Field: M\");else mt *= 60;\n /* falls through */\n case 'S':\n break;\n }\n sec += mt * parseInt(m[i], 10);\n }\n return sec;\n}\nvar good_pd_date_1 = /*#__PURE__*/new Date('2017-02-19T19:06:09.000Z');\nvar good_pd_date = /*#__PURE__*/isNaN(/*#__PURE__*/good_pd_date_1.getFullYear()) ? /*#__PURE__*/new Date('2/19/17') : good_pd_date_1;\nvar good_pd = /*#__PURE__*/good_pd_date.getFullYear() == 2017;\n/* parses a date as a local date */\nfunction parseDate(str /*:string|Date*/, fixdate /*:?number*/) /*:Date*/{\n var d = new Date(str);\n if (good_pd) {\n /*:: if(fixdate == null) fixdate = 0; */\n if (fixdate > 0) d.setTime(d.getTime() + d.getTimezoneOffset() * 60 * 1000);else if (fixdate < 0) d.setTime(d.getTime() - d.getTimezoneOffset() * 60 * 1000);\n return d;\n }\n if (str instanceof Date) return str;\n if (good_pd_date.getFullYear() == 1917 && !isNaN(d.getFullYear())) {\n var s = d.getFullYear();\n if (str.indexOf(\"\" + s) > -1) return d;\n d.setFullYear(d.getFullYear() + 100);\n return d;\n }\n var n = str.match(/\\d+/g) || [\"2017\", \"2\", \"19\", \"0\", \"0\", \"0\"];\n var out = new Date(+n[0], +n[1] - 1, +n[2], +n[3] || 0, +n[4] || 0, +n[5] || 0);\n if (str.indexOf(\"Z\") > -1) out = new Date(out.getTime() - out.getTimezoneOffset() * 60 * 1000);\n return out;\n}\nfunction cc2str(arr /*:Array*/, debomit) /*:string*/{\n if (has_buf && Buffer.isBuffer(arr)) {\n if (debomit) {\n if (arr[0] == 0xFF && arr[1] == 0xFE) return utf8write(arr.slice(2).toString(\"utf16le\"));\n if (arr[1] == 0xFE && arr[2] == 0xFF) return utf8write(utf16beread(arr.slice(2).toString(\"binary\")));\n }\n return arr.toString(\"binary\");\n }\n if (typeof TextDecoder !== \"undefined\") try {\n if (debomit) {\n if (arr[0] == 0xFF && arr[1] == 0xFE) return utf8write(new TextDecoder(\"utf-16le\").decode(arr.slice(2)));\n if (arr[0] == 0xFE && arr[1] == 0xFF) return utf8write(new TextDecoder(\"utf-16be\").decode(arr.slice(2)));\n }\n var rev = {\n \"\\u20ac\": \"\\x80\",\n \"\\u201a\": \"\\x82\",\n \"\\u0192\": \"\\x83\",\n \"\\u201e\": \"\\x84\",\n \"\\u2026\": \"\\x85\",\n \"\\u2020\": \"\\x86\",\n \"\\u2021\": \"\\x87\",\n \"\\u02c6\": \"\\x88\",\n \"\\u2030\": \"\\x89\",\n \"\\u0160\": \"\\x8a\",\n \"\\u2039\": \"\\x8b\",\n \"\\u0152\": \"\\x8c\",\n \"\\u017d\": \"\\x8e\",\n \"\\u2018\": \"\\x91\",\n \"\\u2019\": \"\\x92\",\n \"\\u201c\": \"\\x93\",\n \"\\u201d\": \"\\x94\",\n \"\\u2022\": \"\\x95\",\n \"\\u2013\": \"\\x96\",\n \"\\u2014\": \"\\x97\",\n \"\\u02dc\": \"\\x98\",\n \"\\u2122\": \"\\x99\",\n \"\\u0161\": \"\\x9a\",\n \"\\u203a\": \"\\x9b\",\n \"\\u0153\": \"\\x9c\",\n \"\\u017e\": \"\\x9e\",\n \"\\u0178\": \"\\x9f\"\n };\n if (Array.isArray(arr)) arr = new Uint8Array(arr);\n return new TextDecoder(\"latin1\").decode(arr).replace(/[€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ]/g, function (c) {\n return rev[c] || c;\n });\n } catch (e) {}\n var o = [];\n for (var i = 0; i != arr.length; ++i) o.push(String.fromCharCode(arr[i]));\n return o.join(\"\");\n}\nfunction dup(o /*:any*/) /*:any*/{\n if (typeof JSON != 'undefined' && !Array.isArray(o)) return JSON.parse(JSON.stringify(o));\n if (typeof o != 'object' || o == null) return o;\n if (o instanceof Date) return new Date(o.getTime());\n var out = {};\n for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) out[k] = dup(o[k]);\n return out;\n}\nfunction fill(c /*:string*/, l /*:number*/) /*:string*/{\n var o = \"\";\n while (o.length < l) o += c;\n return o;\n}\n\n/* TODO: stress test */\nfunction fuzzynum(s /*:string*/) /*:number*/{\n var v /*:number*/ = Number(s);\n if (!isNaN(v)) return isFinite(v) ? v : NaN;\n if (!/\\d/.test(s)) return v;\n var wt = 1;\n var ss = s.replace(/([\\d]),([\\d])/g, \"$1$2\").replace(/[$]/g, \"\").replace(/[%]/g, function () {\n wt *= 100;\n return \"\";\n });\n if (!isNaN(v = Number(ss))) return v / wt;\n ss = ss.replace(/[(](.*)[)]/, function ($$, $1) {\n wt = -wt;\n return $1;\n });\n if (!isNaN(v = Number(ss))) return v / wt;\n return v;\n}\nvar lower_months = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'];\nfunction fuzzydate(s /*:string*/) /*:Date*/{\n var o = new Date(s),\n n = new Date(NaN);\n var y = o.getYear(),\n m = o.getMonth(),\n d = o.getDate();\n if (isNaN(d)) return n;\n var lower = s.toLowerCase();\n if (lower.match(/jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec/)) {\n lower = lower.replace(/[^a-z]/g, \"\").replace(/([^a-z]|^)[ap]m?([^a-z]|$)/, \"\");\n if (lower.length > 3 && lower_months.indexOf(lower) == -1) return n;\n } else if (lower.match(/[a-z]/)) return n;\n if (y < 0 || y > 8099) return n;\n if ((m > 0 || d > 1) && y != 101) return o;\n if (s.match(/[^-0-9:,\\/\\\\]/)) return n;\n return o;\n}\nvar split_regex = /*#__PURE__*/function () {\n var safe_split_regex = \"abacaba\".split(/(:?b)/i).length == 5;\n return function split_regex(str /*:string*/, re, def /*:string*/) /*:Array*/{\n if (safe_split_regex || typeof re == \"string\") return str.split(re);\n var p = str.split(re),\n o = [p[0]];\n for (var i = 1; i < p.length; ++i) {\n o.push(def);\n o.push(p[i]);\n }\n return o;\n };\n}();\nfunction getdatastr(data) /*:?string*/{\n if (!data) return null;\n if (data.content && data.type) return cc2str(data.content, true);\n if (data.data) return debom(data.data);\n if (data.asNodeBuffer && has_buf) return debom(data.asNodeBuffer().toString('binary'));\n if (data.asBinary) return debom(data.asBinary());\n if (data._data && data._data.getContent) return debom(cc2str(Array.prototype.slice.call(data._data.getContent(), 0)));\n return null;\n}\nfunction getdatabin(data) {\n if (!data) return null;\n if (data.data) return char_codes(data.data);\n if (data.asNodeBuffer && has_buf) return data.asNodeBuffer();\n if (data._data && data._data.getContent) {\n var o = data._data.getContent();\n if (typeof o == \"string\") return char_codes(o);\n return Array.prototype.slice.call(o);\n }\n if (data.content && data.type) return data.content;\n return null;\n}\nfunction getdata(data) {\n return data && data.name.slice(-4) === \".bin\" ? getdatabin(data) : getdatastr(data);\n}\n\n/* Part 2 Section 10.1.2 \"Mapping Content Types\" Names are case-insensitive */\n/* OASIS does not comment on filename case sensitivity */\nfunction safegetzipfile(zip, file /*:string*/) {\n var k = zip.FullPaths || keys(zip.files);\n var f = file.toLowerCase().replace(/[\\/]/g, '\\\\'),\n g = f.replace(/\\\\/g, '\\/');\n for (var i = 0; i < k.length; ++i) {\n var n = k[i].replace(/^Root Entry[\\/]/, \"\").toLowerCase();\n if (f == n || g == n) return zip.files ? zip.files[k[i]] : zip.FileIndex[i];\n }\n return null;\n}\nfunction getzipfile(zip, file /*:string*/) {\n var o = safegetzipfile(zip, file);\n if (o == null) throw new Error(\"Cannot find file \" + file + \" in zip\");\n return o;\n}\nfunction getzipdata(zip, file /*:string*/, safe /*:?boolean*/) /*:any*/{\n if (!safe) return getdata(getzipfile(zip, file));\n if (!file) return null;\n try {\n return getzipdata(zip, file);\n } catch (e) {\n return null;\n }\n}\nfunction getzipstr(zip, file /*:string*/, safe /*:?boolean*/) /*:?string*/{\n if (!safe) return getdatastr(getzipfile(zip, file));\n if (!file) return null;\n try {\n return getzipstr(zip, file);\n } catch (e) {\n return null;\n }\n}\nfunction getzipbin(zip, file /*:string*/, safe /*:?boolean*/) /*:any*/{\n if (!safe) return getdatabin(getzipfile(zip, file));\n if (!file) return null;\n try {\n return getzipbin(zip, file);\n } catch (e) {\n return null;\n }\n}\nfunction zipentries(zip) {\n var k = zip.FullPaths || keys(zip.files),\n o = [];\n for (var i = 0; i < k.length; ++i) if (k[i].slice(-1) != '/') o.push(k[i].replace(/^Root Entry[\\/]/, \"\"));\n return o.sort();\n}\nfunction zip_add_file(zip, path, content) {\n if (zip.FullPaths) {\n if (typeof content == \"string\") {\n var res;\n if (has_buf) res = Buffer_from(content);\n /* TODO: investigate performance in Edge 13 */\n //else if(typeof TextEncoder !== \"undefined\") res = new TextEncoder().encode(content);\n else res = utf8decode(content);\n return CFB.utils.cfb_add(zip, path, res);\n }\n CFB.utils.cfb_add(zip, path, content);\n } else zip.file(path, content);\n}\nfunction zip_new() {\n return CFB.utils.cfb_new();\n}\nfunction zip_read(d, o) {\n switch (o.type) {\n case \"base64\":\n return CFB.read(d, {\n type: \"base64\"\n });\n case \"binary\":\n return CFB.read(d, {\n type: \"binary\"\n });\n case \"buffer\":\n case \"array\":\n return CFB.read(d, {\n type: \"buffer\"\n });\n }\n throw new Error(\"Unrecognized type \" + o.type);\n}\nfunction resolve_path(path /*:string*/, base /*:string*/) /*:string*/{\n if (path.charAt(0) == \"/\") return path.slice(1);\n var result = base.split('/');\n if (base.slice(-1) != \"/\") result.pop(); // folder path\n var target = path.split('/');\n while (target.length !== 0) {\n var step = target.shift();\n if (step === '..') result.pop();else if (step !== '.') result.push(step);\n }\n return result.join('/');\n}\nvar XML_HEADER = '\\r\\n';\nvar attregexg = /([^\"\\s?>\\/]+)\\s*=\\s*((?:\")([^\"]*)(?:\")|(?:')([^']*)(?:')|([^'\">\\s]+))/g;\nvar tagregex1 = /<[\\/\\?]?[a-zA-Z0-9:_-]+(?:\\s+[^\"\\s?>\\/]+\\s*=\\s*(?:\"[^\"]*\"|'[^']*'|[^'\">\\s=]+))*\\s*[\\/\\?]?>/mg,\n tagregex2 = /<[^>]*>/g;\nvar tagregex = /*#__PURE__*/XML_HEADER.match(tagregex1) ? tagregex1 : tagregex2;\nvar nsregex = /<\\w*:/,\n nsregex2 = /<(\\/?)\\w+:/;\nfunction parsexmltag(tag /*:string*/, skip_root /*:?boolean*/, skip_LC /*:?boolean*/) /*:any*/{\n var z = {} /*:any*/;\n var eq = 0,\n c = 0;\n for (; eq !== tag.length; ++eq) if ((c = tag.charCodeAt(eq)) === 32 || c === 10 || c === 13) break;\n if (!skip_root) z[0] = tag.slice(0, eq);\n if (eq === tag.length) return z;\n var m = tag.match(attregexg),\n j = 0,\n v = \"\",\n i = 0,\n q = \"\",\n cc = \"\",\n quot = 1;\n if (m) for (i = 0; i != m.length; ++i) {\n cc = m[i];\n for (c = 0; c != cc.length; ++c) if (cc.charCodeAt(c) === 61) break;\n q = cc.slice(0, c).trim();\n while (cc.charCodeAt(c + 1) == 32) ++c;\n quot = (eq = cc.charCodeAt(c + 1)) == 34 || eq == 39 ? 1 : 0;\n v = cc.slice(c + 1 + quot, cc.length - quot);\n for (j = 0; j != q.length; ++j) if (q.charCodeAt(j) === 58) break;\n if (j === q.length) {\n if (q.indexOf(\"_\") > 0) q = q.slice(0, q.indexOf(\"_\")); // from ods\n z[q] = v;\n if (!skip_LC) z[q.toLowerCase()] = v;\n } else {\n var k = (j === 5 && q.slice(0, 5) === \"xmlns\" ? \"xmlns\" : \"\") + q.slice(j + 1);\n if (z[k] && q.slice(j - 3, j) == \"ext\") continue; // from ods\n z[k] = v;\n if (!skip_LC) z[k.toLowerCase()] = v;\n }\n }\n return z;\n}\nfunction strip_ns(x /*:string*/) /*:string*/{\n return x.replace(nsregex2, \"<$1\");\n}\nvar encodings = {\n '"': '\"',\n ''': \"'\",\n '>': '>',\n '<': '<',\n '&': '&'\n};\nvar rencoding = /*#__PURE__*/evert(encodings);\n//var rencstr = \"&<>'\\\"\".split(\"\");\n\n// TODO: CP remap (need to read file version to determine OS)\nvar unescapexml /*:StringConv*/ = /*#__PURE__*/function () {\n /* 22.4.2.4 bstr (Basic String) */\n var encregex = /&(?:quot|apos|gt|lt|amp|#x?([\\da-fA-F]+));/ig,\n coderegex = /_x([\\da-fA-F]{4})_/ig;\n return function unescapexml(text /*:string*/) /*:string*/{\n var s = text + '',\n i = s.indexOf(\" -1 ? 16 : 10)) || $$;\n }).replace(coderegex, function (m, c) {\n return String.fromCharCode(parseInt(c, 16));\n });\n var j = s.indexOf(\"]]>\");\n return unescapexml(s.slice(0, i)) + s.slice(i + 9, j) + unescapexml(s.slice(j + 3));\n };\n}();\nvar decregex = /[&<>'\"]/g,\n charegex = /[\\u0000-\\u0008\\u000b-\\u001f]/g;\nfunction escapexml(text /*:string*/) /*:string*/{\n var s = text + '';\n return s.replace(decregex, function (y) {\n return rencoding[y];\n }).replace(charegex, function (s) {\n return \"_x\" + (\"000\" + s.charCodeAt(0).toString(16)).slice(-4) + \"_\";\n });\n}\nfunction escapexmltag(text /*:string*/) /*:string*/{\n return escapexml(text).replace(/ /g, \"_x0020_\");\n}\nvar htmlcharegex = /[\\u0000-\\u001f]/g;\nfunction escapehtml(text /*:string*/) /*:string*/{\n var s = text + '';\n return s.replace(decregex, function (y) {\n return rencoding[y];\n }).replace(/\\n/g, \"
\").replace(htmlcharegex, function (s) {\n return \"&#x\" + (\"000\" + s.charCodeAt(0).toString(16)).slice(-4) + \";\";\n });\n}\nfunction escapexlml(text /*:string*/) /*:string*/{\n var s = text + '';\n return s.replace(decregex, function (y) {\n return rencoding[y];\n }).replace(htmlcharegex, function (s) {\n return \"&#x\" + s.charCodeAt(0).toString(16).toUpperCase() + \";\";\n });\n}\n\n/* TODO: handle codepages */\nvar xlml_fixstr /*:StringConv*/ = /*#__PURE__*/function () {\n var entregex = /&#(\\d+);/g;\n function entrepl($$ /*:string*/, $1 /*:string*/) /*:string*/{\n return String.fromCharCode(parseInt($1, 10));\n }\n return function xlml_fixstr(str /*:string*/) /*:string*/{\n return str.replace(entregex, entrepl);\n };\n}();\nfunction xlml_unfixstr(str /*:string*/) /*:string*/{\n return str.replace(/(\\r\\n|[\\r\\n])/g, \"\\ \");\n}\nfunction parsexmlbool(value /*:any*/) /*:boolean*/{\n switch (value) {\n case 1:\n case true:\n case '1':\n case 'true':\n case 'TRUE':\n return true;\n /* case '0': case 'false': case 'FALSE':*/\n default:\n return false;\n }\n}\nfunction utf8reada(orig /*:string*/) /*:string*/{\n var out = \"\",\n i = 0,\n c = 0,\n d = 0,\n e = 0,\n f = 0,\n w = 0;\n while (i < orig.length) {\n c = orig.charCodeAt(i++);\n if (c < 128) {\n out += String.fromCharCode(c);\n continue;\n }\n d = orig.charCodeAt(i++);\n if (c > 191 && c < 224) {\n f = (c & 31) << 6;\n f |= d & 63;\n out += String.fromCharCode(f);\n continue;\n }\n e = orig.charCodeAt(i++);\n if (c < 240) {\n out += String.fromCharCode((c & 15) << 12 | (d & 63) << 6 | e & 63);\n continue;\n }\n f = orig.charCodeAt(i++);\n w = ((c & 7) << 18 | (d & 63) << 12 | (e & 63) << 6 | f & 63) - 65536;\n out += String.fromCharCode(0xD800 + (w >>> 10 & 1023));\n out += String.fromCharCode(0xDC00 + (w & 1023));\n }\n return out;\n}\nfunction utf8readb(data) {\n var out = new_raw_buf(2 * data.length),\n w,\n i,\n j = 1,\n k = 0,\n ww = 0,\n c;\n for (i = 0; i < data.length; i += j) {\n j = 1;\n if ((c = data.charCodeAt(i)) < 128) w = c;else if (c < 224) {\n w = (c & 31) * 64 + (data.charCodeAt(i + 1) & 63);\n j = 2;\n } else if (c < 240) {\n w = (c & 15) * 4096 + (data.charCodeAt(i + 1) & 63) * 64 + (data.charCodeAt(i + 2) & 63);\n j = 3;\n } else {\n j = 4;\n w = (c & 7) * 262144 + (data.charCodeAt(i + 1) & 63) * 4096 + (data.charCodeAt(i + 2) & 63) * 64 + (data.charCodeAt(i + 3) & 63);\n w -= 65536;\n ww = 0xD800 + (w >>> 10 & 1023);\n w = 0xDC00 + (w & 1023);\n }\n if (ww !== 0) {\n out[k++] = ww & 255;\n out[k++] = ww >>> 8;\n ww = 0;\n }\n out[k++] = w % 256;\n out[k++] = w >>> 8;\n }\n return out.slice(0, k).toString('ucs2');\n}\nfunction utf8readc(data) {\n return Buffer_from(data, 'binary').toString('utf8');\n}\nvar utf8corpus = \"foo bar baz\\u00e2\\u0098\\u0083\\u00f0\\u009f\\u008d\\u00a3\";\nvar utf8read = has_buf && (/*#__PURE__*/utf8readc(utf8corpus) == /*#__PURE__*/utf8reada(utf8corpus) && utf8readc || /*#__PURE__*/utf8readb(utf8corpus) == /*#__PURE__*/utf8reada(utf8corpus) && utf8readb) || utf8reada;\nvar utf8write /*:StringConv*/ = has_buf ? function (data) {\n return Buffer_from(data, 'utf8').toString(\"binary\");\n} : function (orig /*:string*/) /*:string*/{\n var out /*:Array*/ = [],\n i = 0,\n c = 0,\n d = 0;\n while (i < orig.length) {\n c = orig.charCodeAt(i++);\n switch (true) {\n case c < 128:\n out.push(String.fromCharCode(c));\n break;\n case c < 2048:\n out.push(String.fromCharCode(192 + (c >> 6)));\n out.push(String.fromCharCode(128 + (c & 63)));\n break;\n case c >= 55296 && c < 57344:\n c -= 55296;\n d = orig.charCodeAt(i++) - 56320 + (c << 10);\n out.push(String.fromCharCode(240 + (d >> 18 & 7)));\n out.push(String.fromCharCode(144 + (d >> 12 & 63)));\n out.push(String.fromCharCode(128 + (d >> 6 & 63)));\n out.push(String.fromCharCode(128 + (d & 63)));\n break;\n default:\n out.push(String.fromCharCode(224 + (c >> 12)));\n out.push(String.fromCharCode(128 + (c >> 6 & 63)));\n out.push(String.fromCharCode(128 + (c & 63)));\n }\n }\n return out.join(\"\");\n};\n\n// matches ... extracts content\nvar matchtag = /*#__PURE__*/function () {\n var mtcache /*:{[k:string]:RegExp}*/ = {} /*:any*/;\n return function matchtag(f /*:string*/, g /*:?string*/) /*:RegExp*/{\n var t = f + \"|\" + (g || \"\");\n if (mtcache[t]) return mtcache[t];\n return mtcache[t] = new RegExp('<(?:\\\\w+:)?' + f + '(?: xml:space=\"preserve\")?(?:[^>]*)>([\\\\s\\\\S]*?)', g || \"\" /*:any*/);\n };\n}();\nvar htmldecode /*:{(s:string):string}*/ = /*#__PURE__*/function () {\n var entities /*:Array<[RegExp, string]>*/ = [['nbsp', ' '], ['middot', '·'], ['quot', '\"'], ['apos', \"'\"], ['gt', '>'], ['lt', '<'], ['amp', '&']].map(function (x /*:[string, string]*/) {\n return [new RegExp('&' + x[0] + ';', \"ig\"), x[1]];\n });\n return function htmldecode(str /*:string*/) /*:string*/{\n var o = str\n // Remove new lines and spaces from start of content\n .replace(/^[\\t\\n\\r ]+/, \"\")\n // Remove new lines and spaces from end of content\n .replace(/[\\t\\n\\r ]+$/, \"\")\n // Added line which removes any white space characters after and before html tags\n .replace(/>\\s+/g, \">\").replace(/\\s+ tags with new lines\n .replace(/<\\s*[bB][rR]\\s*\\/?>/g, \"\\n\")\n // Strip HTML elements\n .replace(/<[^>]*>/g, \"\");\n for (var i = 0; i < entities.length; ++i) o = o.replace(entities[i][0], entities[i][1]);\n return o;\n };\n}();\nvar vtregex = /*#__PURE__*/function () {\n var vt_cache = {};\n return function vt_regex(bt) {\n if (vt_cache[bt] !== undefined) return vt_cache[bt];\n return vt_cache[bt] = new RegExp(\"<(?:vt:)?\" + bt + \">([\\\\s\\\\S]*?)\", 'g');\n };\n}();\nvar vtvregex = /<\\/?(?:vt:)?variant>/g,\n vtmregex = /<(?:vt:)([^>]*)>([\\s\\S]*)*/{\n var h = parsexmltag(data);\n var matches /*:Array*/ = data.match(vtregex(h.baseType)) || [];\n var res /*:Array*/ = [];\n if (matches.length != h.size) {\n if (opts.WTF) throw new Error(\"unexpected vector length \" + matches.length + \" != \" + h.size);\n return res;\n }\n matches.forEach(function (x /*:string*/) {\n var v = x.replace(vtvregex, \"\").match(vtmregex);\n if (v) res.push({\n v: utf8read(v[2]),\n t: v[1]\n });\n });\n return res;\n}\nvar wtregex = /(^\\s|\\s$|\\n)/;\nfunction writetag(f /*:string*/, g /*:string*/) /*:string*/{\n return '<' + f + (g.match(wtregex) ? ' xml:space=\"preserve\"' : \"\") + '>' + g + '';\n}\nfunction wxt_helper(h) /*:string*/{\n return keys(h).map(function (k) {\n return \" \" + k + '=\"' + h[k] + '\"';\n }).join(\"\");\n}\nfunction writextag(f /*:string*/, g /*:?string*/, h) {\n return '<' + f + (h != null ? wxt_helper(h) : \"\") + (g != null ? (g.match(wtregex) ? ' xml:space=\"preserve\"' : \"\") + '>' + g + '';\n}\nfunction write_w3cdtf(d /*:Date*/, t /*:?boolean*/) /*:string*/{\n try {\n return d.toISOString().replace(/\\.\\d*/, \"\");\n } catch (e) {\n if (t) throw e;\n }\n return \"\";\n}\nfunction write_vt(s, xlsx /*:?boolean*/) /*:string*/{\n switch (typeof s) {\n case 'string':\n var o = writextag('vt:lpwstr', escapexml(s));\n if (xlsx) o = o.replace(/"/g, \"_x0022_\");\n return o;\n case 'number':\n return writextag((s | 0) == s ? 'vt:i4' : 'vt:r8', escapexml(String(s)));\n case 'boolean':\n return writextag('vt:bool', s ? 'true' : 'false');\n }\n if (s instanceof Date) return writextag('vt:filetime', write_w3cdtf(s));\n throw new Error(\"Unable to serialize \" + s);\n}\nfunction xlml_normalize(d) /*:string*/{\n if (has_buf && /*::typeof Buffer !== \"undefined\" && d != null && d instanceof Buffer &&*/Buffer.isBuffer(d)) return d.toString('utf8');\n if (typeof d === 'string') return d;\n /* duktape */\n if (typeof Uint8Array !== 'undefined' && d instanceof Uint8Array) return utf8read(a2s(ab2a(d)));\n throw new Error(\"Bad input format: expected Buffer or string\");\n}\n/* UOS uses CJK in tags */\nvar xlmlregex = /<(\\/?)([^\\s?>:\\/]+)(?:[\\s?:\\/][^>]*)?>/mg;\n//var xlmlregex = /<(\\/?)([a-z0-9]*:|)(\\w+)[^>]*>/mg;\n\nvar XMLNS = {\n CORE_PROPS: 'http://schemas.openxmlformats.org/package/2006/metadata/core-properties',\n CUST_PROPS: \"http://schemas.openxmlformats.org/officeDocument/2006/custom-properties\",\n EXT_PROPS: \"http://schemas.openxmlformats.org/officeDocument/2006/extended-properties\",\n CT: 'http://schemas.openxmlformats.org/package/2006/content-types',\n RELS: 'http://schemas.openxmlformats.org/package/2006/relationships',\n TCMNT: 'http://schemas.microsoft.com/office/spreadsheetml/2018/threadedcomments',\n 'dc': 'http://purl.org/dc/elements/1.1/',\n 'dcterms': 'http://purl.org/dc/terms/',\n 'dcmitype': 'http://purl.org/dc/dcmitype/',\n 'mx': 'http://schemas.microsoft.com/office/mac/excel/2008/main',\n 'r': 'http://schemas.openxmlformats.org/officeDocument/2006/relationships',\n 'sjs': 'http://schemas.openxmlformats.org/package/2006/sheetjs/core-properties',\n 'vt': 'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes',\n 'xsi': 'http://www.w3.org/2001/XMLSchema-instance',\n 'xsd': 'http://www.w3.org/2001/XMLSchema'\n} /*:any*/;\nvar XMLNS_main = ['http://schemas.openxmlformats.org/spreadsheetml/2006/main', 'http://purl.oclc.org/ooxml/spreadsheetml/main', 'http://schemas.microsoft.com/office/excel/2006/main', 'http://schemas.microsoft.com/office/excel/2006/2'];\nvar XLMLNS = {\n 'o': 'urn:schemas-microsoft-com:office:office',\n 'x': 'urn:schemas-microsoft-com:office:excel',\n 'ss': 'urn:schemas-microsoft-com:office:spreadsheet',\n 'dt': 'uuid:C2F41010-65B3-11d1-A29F-00AA00C14882',\n 'mv': 'http://macVmlSchemaUri',\n 'v': 'urn:schemas-microsoft-com:vml',\n 'html': 'http://www.w3.org/TR/REC-html40'\n} /*:any*/;\nfunction read_double_le(b /*:RawBytes|CFBlob*/, idx /*:number*/) /*:number*/{\n var s = 1 - 2 * (b[idx + 7] >>> 7);\n var e = ((b[idx + 7] & 0x7f) << 4) + (b[idx + 6] >>> 4 & 0x0f);\n var m = b[idx + 6] & 0x0f;\n for (var i = 5; i >= 0; --i) m = m * 256 + b[idx + i];\n if (e == 0x7ff) return m == 0 ? s * Infinity : NaN;\n if (e == 0) e = -1022;else {\n e -= 1023;\n m += Math.pow(2, 52);\n }\n return s * Math.pow(2, e - 52) * m;\n}\nfunction write_double_le(b /*:RawBytes|CFBlob*/, v /*:number*/, idx /*:number*/) {\n var bs = (v < 0 || 1 / v == -Infinity ? 1 : 0) << 7,\n e = 0,\n m = 0;\n var av = bs ? -v : v;\n if (!isFinite(av)) {\n e = 0x7ff;\n m = isNaN(v) ? 0x6969 : 0;\n } else if (av == 0) e = m = 0;else {\n e = Math.floor(Math.log(av) / Math.LN2);\n m = av * Math.pow(2, 52 - e);\n if (e <= -1023 && (!isFinite(m) || m < Math.pow(2, 52))) {\n e = -1022;\n } else {\n m -= Math.pow(2, 52);\n e += 1023;\n }\n }\n for (var i = 0; i <= 5; ++i, m /= 256) b[idx + i] = m & 0xff;\n b[idx + 6] = (e & 0x0f) << 4 | m & 0xf;\n b[idx + 7] = e >> 4 | bs;\n}\nvar ___toBuffer = function (bufs /*:Array >*/) /*:RawBytes*/{\n var x = [],\n w = 10240;\n for (var i = 0; i < bufs[0].length; ++i) if (bufs[0][i]) for (var j = 0, L = bufs[0][i].length; j < L; j += w) x.push.apply(x, bufs[0][i].slice(j, j + w));\n return x;\n};\nvar __toBuffer = has_buf ? function (bufs) {\n return bufs[0].length > 0 && Buffer.isBuffer(bufs[0][0]) ? Buffer.concat(bufs[0].map(function (x) {\n return Buffer.isBuffer(x) ? x : Buffer_from(x);\n })) : ___toBuffer(bufs);\n} : ___toBuffer;\nvar ___utf16le = function (b /*:RawBytes|CFBlob*/, s /*:number*/, e /*:number*/) /*:string*/{\n var ss /*:Array*/ = [];\n for (var i = s; i < e; i += 2) ss.push(String.fromCharCode(__readUInt16LE(b, i)));\n return ss.join(\"\").replace(chr0, '');\n};\nvar __utf16le = has_buf ? function (b /*:RawBytes|CFBlob*/, s /*:number*/, e /*:number*/) /*:string*/{\n if (!Buffer.isBuffer(b) /*:: || !(b instanceof Buffer)*/) return ___utf16le(b, s, e);\n return b.toString('utf16le', s, e).replace(chr0, '') /*.replace(chr1,'!')*/;\n} : ___utf16le;\nvar ___hexlify = function (b /*:RawBytes|CFBlob*/, s /*:number*/, l /*:number*/) /*:string*/{\n var ss /*:Array*/ = [];\n for (var i = s; i < s + l; ++i) ss.push((\"0\" + b[i].toString(16)).slice(-2));\n return ss.join(\"\");\n};\nvar __hexlify = has_buf ? function (b /*:RawBytes|CFBlob*/, s /*:number*/, l /*:number*/) /*:string*/{\n return Buffer.isBuffer(b) /*:: && b instanceof Buffer*/ ? b.toString('hex', s, s + l) : ___hexlify(b, s, l);\n} : ___hexlify;\nvar ___utf8 = function (b /*:RawBytes|CFBlob*/, s /*:number*/, e /*:number*/) {\n var ss = [];\n for (var i = s; i < e; i++) ss.push(String.fromCharCode(__readUInt8(b, i)));\n return ss.join(\"\");\n};\nvar __utf8 = has_buf ? function utf8_b(b /*:RawBytes|CFBlob*/, s /*:number*/, e /*:number*/) {\n return Buffer.isBuffer(b) /*:: && (b instanceof Buffer)*/ ? b.toString('utf8', s, e) : ___utf8(b, s, e);\n} : ___utf8;\nvar ___lpstr = function (b /*:RawBytes|CFBlob*/, i /*:number*/) {\n var len = __readUInt32LE(b, i);\n return len > 0 ? __utf8(b, i + 4, i + 4 + len - 1) : \"\";\n};\nvar __lpstr = ___lpstr;\nvar ___cpstr = function (b /*:RawBytes|CFBlob*/, i /*:number*/) {\n var len = __readUInt32LE(b, i);\n return len > 0 ? __utf8(b, i + 4, i + 4 + len - 1) : \"\";\n};\nvar __cpstr = ___cpstr;\nvar ___lpwstr = function (b /*:RawBytes|CFBlob*/, i /*:number*/) {\n var len = 2 * __readUInt32LE(b, i);\n return len > 0 ? __utf8(b, i + 4, i + 4 + len - 1) : \"\";\n};\nvar __lpwstr = ___lpwstr;\nvar ___lpp4 = function lpp4_(b /*:RawBytes|CFBlob*/, i /*:number*/) {\n var len = __readUInt32LE(b, i);\n return len > 0 ? __utf16le(b, i + 4, i + 4 + len) : \"\";\n};\nvar __lpp4 = ___lpp4;\nvar ___8lpp4 = function (b /*:RawBytes|CFBlob*/, i /*:number*/) {\n var len = __readUInt32LE(b, i);\n return len > 0 ? __utf8(b, i + 4, i + 4 + len) : \"\";\n};\nvar __8lpp4 = ___8lpp4;\nvar ___double = function (b /*:RawBytes|CFBlob*/, idx /*:number*/) {\n return read_double_le(b, idx);\n};\nvar __double = ___double;\nvar is_buf = function is_buf_a(a) {\n return Array.isArray(a) || typeof Uint8Array !== \"undefined\" && a instanceof Uint8Array;\n};\nif (has_buf /*:: && typeof Buffer !== 'undefined'*/) {\n __lpstr = function lpstr_b(b /*:RawBytes|CFBlob*/, i /*:number*/) {\n if (!Buffer.isBuffer(b) /*:: || !(b instanceof Buffer)*/) return ___lpstr(b, i);\n var len = b.readUInt32LE(i);\n return len > 0 ? b.toString('utf8', i + 4, i + 4 + len - 1) : \"\";\n };\n __cpstr = function cpstr_b(b /*:RawBytes|CFBlob*/, i /*:number*/) {\n if (!Buffer.isBuffer(b) /*:: || !(b instanceof Buffer)*/) return ___cpstr(b, i);\n var len = b.readUInt32LE(i);\n return len > 0 ? b.toString('utf8', i + 4, i + 4 + len - 1) : \"\";\n };\n __lpwstr = function lpwstr_b(b /*:RawBytes|CFBlob*/, i /*:number*/) {\n if (!Buffer.isBuffer(b) /*:: || !(b instanceof Buffer)*/) return ___lpwstr(b, i);\n var len = 2 * b.readUInt32LE(i);\n return b.toString('utf16le', i + 4, i + 4 + len - 1);\n };\n __lpp4 = function lpp4_b(b /*:RawBytes|CFBlob*/, i /*:number*/) {\n if (!Buffer.isBuffer(b) /*:: || !(b instanceof Buffer)*/) return ___lpp4(b, i);\n var len = b.readUInt32LE(i);\n return b.toString('utf16le', i + 4, i + 4 + len);\n };\n __8lpp4 = function lpp4_8b(b /*:RawBytes|CFBlob*/, i /*:number*/) {\n if (!Buffer.isBuffer(b) /*:: || !(b instanceof Buffer)*/) return ___8lpp4(b, i);\n var len = b.readUInt32LE(i);\n return b.toString('utf8', i + 4, i + 4 + len);\n };\n __double = function double_(b /*:RawBytes|CFBlob*/, i /*:number*/) {\n if (Buffer.isBuffer(b) /*::&& b instanceof Buffer*/) return b.readDoubleLE(i);\n return ___double(b, i);\n };\n is_buf = function is_buf_b(a) {\n return Buffer.isBuffer(a) || Array.isArray(a) || typeof Uint8Array !== \"undefined\" && a instanceof Uint8Array;\n };\n}\n\n/* from js-xls */\nfunction cpdoit() {\n __utf16le = function (b /*:RawBytes|CFBlob*/, s /*:number*/, e /*:number*/) {\n return $cptable.utils.decode(1200, b.slice(s, e)).replace(chr0, '');\n };\n __utf8 = function (b /*:RawBytes|CFBlob*/, s /*:number*/, e /*:number*/) {\n return $cptable.utils.decode(65001, b.slice(s, e));\n };\n __lpstr = function (b /*:RawBytes|CFBlob*/, i /*:number*/) {\n var len = __readUInt32LE(b, i);\n return len > 0 ? $cptable.utils.decode(current_ansi, b.slice(i + 4, i + 4 + len - 1)) : \"\";\n };\n __cpstr = function (b /*:RawBytes|CFBlob*/, i /*:number*/) {\n var len = __readUInt32LE(b, i);\n return len > 0 ? $cptable.utils.decode(current_codepage, b.slice(i + 4, i + 4 + len - 1)) : \"\";\n };\n __lpwstr = function (b /*:RawBytes|CFBlob*/, i /*:number*/) {\n var len = 2 * __readUInt32LE(b, i);\n return len > 0 ? $cptable.utils.decode(1200, b.slice(i + 4, i + 4 + len - 1)) : \"\";\n };\n __lpp4 = function (b /*:RawBytes|CFBlob*/, i /*:number*/) {\n var len = __readUInt32LE(b, i);\n return len > 0 ? $cptable.utils.decode(1200, b.slice(i + 4, i + 4 + len)) : \"\";\n };\n __8lpp4 = function (b /*:RawBytes|CFBlob*/, i /*:number*/) {\n var len = __readUInt32LE(b, i);\n return len > 0 ? $cptable.utils.decode(65001, b.slice(i + 4, i + 4 + len)) : \"\";\n };\n}\nif (typeof $cptable !== 'undefined') cpdoit();\nvar __readUInt8 = function (b /*:RawBytes|CFBlob*/, idx /*:number*/) /*:number*/{\n return b[idx];\n};\nvar __readUInt16LE = function (b /*:RawBytes|CFBlob*/, idx /*:number*/) /*:number*/{\n return b[idx + 1] * (1 << 8) + b[idx];\n};\nvar __readInt16LE = function (b /*:RawBytes|CFBlob*/, idx /*:number*/) /*:number*/{\n var u = b[idx + 1] * (1 << 8) + b[idx];\n return u < 0x8000 ? u : (0xffff - u + 1) * -1;\n};\nvar __readUInt32LE = function (b /*:RawBytes|CFBlob*/, idx /*:number*/) /*:number*/{\n return b[idx + 3] * (1 << 24) + (b[idx + 2] << 16) + (b[idx + 1] << 8) + b[idx];\n};\nvar __readInt32LE = function (b /*:RawBytes|CFBlob*/, idx /*:number*/) /*:number*/{\n return b[idx + 3] << 24 | b[idx + 2] << 16 | b[idx + 1] << 8 | b[idx];\n};\nvar __readInt32BE = function (b /*:RawBytes|CFBlob*/, idx /*:number*/) /*:number*/{\n return b[idx] << 24 | b[idx + 1] << 16 | b[idx + 2] << 8 | b[idx + 3];\n};\nfunction ReadShift(size /*:number*/, t /*:?string*/) /*:number|string*/{\n var o = \"\",\n oI /*:: :number = 0*/,\n oR,\n oo = [],\n w,\n vv,\n i,\n loc;\n switch (t) {\n case 'dbcs':\n loc = this.l;\n if (has_buf && Buffer.isBuffer(this)) o = this.slice(this.l, this.l + 2 * size).toString(\"utf16le\");else for (i = 0; i < size; ++i) {\n o += String.fromCharCode(__readUInt16LE(this, loc));\n loc += 2;\n }\n size *= 2;\n break;\n case 'utf8':\n o = __utf8(this, this.l, this.l + size);\n break;\n case 'utf16le':\n size *= 2;\n o = __utf16le(this, this.l, this.l + size);\n break;\n case 'wstr':\n if (typeof $cptable !== 'undefined') o = $cptable.utils.decode(current_codepage, this.slice(this.l, this.l + 2 * size));else return ReadShift.call(this, size, 'dbcs');\n size = 2 * size;\n break;\n\n /* [MS-OLEDS] 2.1.4 LengthPrefixedAnsiString */\n case 'lpstr-ansi':\n o = __lpstr(this, this.l);\n size = 4 + __readUInt32LE(this, this.l);\n break;\n case 'lpstr-cp':\n o = __cpstr(this, this.l);\n size = 4 + __readUInt32LE(this, this.l);\n break;\n /* [MS-OLEDS] 2.1.5 LengthPrefixedUnicodeString */\n case 'lpwstr':\n o = __lpwstr(this, this.l);\n size = 4 + 2 * __readUInt32LE(this, this.l);\n break;\n /* [MS-OFFCRYPTO] 2.1.2 Length-Prefixed Padded Unicode String (UNICODE-LP-P4) */\n case 'lpp4':\n size = 4 + __readUInt32LE(this, this.l);\n o = __lpp4(this, this.l);\n if (size & 0x02) size += 2;\n break;\n /* [MS-OFFCRYPTO] 2.1.3 Length-Prefixed UTF-8 String (UTF-8-LP-P4) */\n case '8lpp4':\n size = 4 + __readUInt32LE(this, this.l);\n o = __8lpp4(this, this.l);\n if (size & 0x03) size += 4 - (size & 0x03);\n break;\n case 'cstr':\n size = 0;\n o = \"\";\n while ((w = __readUInt8(this, this.l + size++)) !== 0) oo.push(_getchar(w));\n o = oo.join(\"\");\n break;\n case '_wstr':\n size = 0;\n o = \"\";\n while ((w = __readUInt16LE(this, this.l + size)) !== 0) {\n oo.push(_getchar(w));\n size += 2;\n }\n size += 2;\n o = oo.join(\"\");\n break;\n\n /* sbcs and dbcs support continue records in the SST way TODO codepages */\n case 'dbcs-cont':\n o = \"\";\n loc = this.l;\n for (i = 0; i < size; ++i) {\n if (this.lens && this.lens.indexOf(loc) !== -1) {\n w = __readUInt8(this, loc);\n this.l = loc + 1;\n vv = ReadShift.call(this, size - i, w ? 'dbcs-cont' : 'sbcs-cont');\n return oo.join(\"\") + vv;\n }\n oo.push(_getchar(__readUInt16LE(this, loc)));\n loc += 2;\n }\n o = oo.join(\"\");\n size *= 2;\n break;\n case 'cpstr':\n if (typeof $cptable !== 'undefined') {\n o = $cptable.utils.decode(current_codepage, this.slice(this.l, this.l + size));\n break;\n }\n /* falls through */\n case 'sbcs-cont':\n o = \"\";\n loc = this.l;\n for (i = 0; i != size; ++i) {\n if (this.lens && this.lens.indexOf(loc) !== -1) {\n w = __readUInt8(this, loc);\n this.l = loc + 1;\n vv = ReadShift.call(this, size - i, w ? 'dbcs-cont' : 'sbcs-cont');\n return oo.join(\"\") + vv;\n }\n oo.push(_getchar(__readUInt8(this, loc)));\n loc += 1;\n }\n o = oo.join(\"\");\n break;\n default:\n switch (size) {\n case 1:\n oI = __readUInt8(this, this.l);\n this.l++;\n return oI;\n case 2:\n oI = (t === 'i' ? __readInt16LE : __readUInt16LE)(this, this.l);\n this.l += 2;\n return oI;\n case 4:\n case -4:\n if (t === 'i' || (this[this.l + 3] & 0x80) === 0) {\n oI = (size > 0 ? __readInt32LE : __readInt32BE)(this, this.l);\n this.l += 4;\n return oI;\n } else {\n oR = __readUInt32LE(this, this.l);\n this.l += 4;\n }\n return oR;\n case 8:\n case -8:\n if (t === 'f') {\n if (size == 8) oR = __double(this, this.l);else oR = __double([this[this.l + 7], this[this.l + 6], this[this.l + 5], this[this.l + 4], this[this.l + 3], this[this.l + 2], this[this.l + 1], this[this.l + 0]], 0);\n this.l += 8;\n return oR;\n } else size = 8;\n /* falls through */\n case 16:\n o = __hexlify(this, this.l, size);\n break;\n }\n }\n this.l += size;\n return o;\n}\nvar __writeUInt32LE = function (b /*:RawBytes|CFBlob*/, val /*:number*/, idx /*:number*/) /*:void*/{\n b[idx] = val & 0xFF;\n b[idx + 1] = val >>> 8 & 0xFF;\n b[idx + 2] = val >>> 16 & 0xFF;\n b[idx + 3] = val >>> 24 & 0xFF;\n};\nvar __writeInt32LE = function (b /*:RawBytes|CFBlob*/, val /*:number*/, idx /*:number*/) /*:void*/{\n b[idx] = val & 0xFF;\n b[idx + 1] = val >> 8 & 0xFF;\n b[idx + 2] = val >> 16 & 0xFF;\n b[idx + 3] = val >> 24 & 0xFF;\n};\nvar __writeUInt16LE = function (b /*:RawBytes|CFBlob*/, val /*:number*/, idx /*:number*/) /*:void*/{\n b[idx] = val & 0xFF;\n b[idx + 1] = val >>> 8 & 0xFF;\n};\nfunction WriteShift(t /*:number*/, val /*:string|number*/, f /*:?string*/) /*:any*/{\n var size = 0,\n i = 0;\n if (f === 'dbcs') {\n /*:: if(typeof val !== 'string') throw new Error(\"unreachable\"); */\n for (i = 0; i != val.length; ++i) __writeUInt16LE(this, val.charCodeAt(i), this.l + 2 * i);\n size = 2 * val.length;\n } else if (f === 'sbcs') {\n if (typeof $cptable !== 'undefined' && current_ansi == 874) {\n /* TODO: use tables directly, don't encode */\n /*:: if(typeof val !== \"string\") throw new Error(\"unreachable\"); */\n for (i = 0; i != val.length; ++i) {\n var cppayload = $cptable.utils.encode(current_ansi, val.charAt(i));\n this[this.l + i] = cppayload[0];\n }\n } else {\n /*:: if(typeof val !== 'string') throw new Error(\"unreachable\"); */\n val = val.replace(/[^\\x00-\\x7F]/g, \"_\");\n /*:: if(typeof val !== 'string') throw new Error(\"unreachable\"); */\n for (i = 0; i != val.length; ++i) this[this.l + i] = val.charCodeAt(i) & 0xFF;\n }\n size = val.length;\n } else if (f === 'hex') {\n for (; i < t; ++i) {\n /*:: if(typeof val !== \"string\") throw new Error(\"unreachable\"); */\n this[this.l++] = parseInt(val.slice(2 * i, 2 * i + 2), 16) || 0;\n }\n return this;\n } else if (f === 'utf16le') {\n /*:: if(typeof val !== \"string\") throw new Error(\"unreachable\"); */\n var end /*:number*/ = Math.min(this.l + t, this.length);\n for (i = 0; i < Math.min(val.length, t); ++i) {\n var cc = val.charCodeAt(i);\n this[this.l++] = cc & 0xff;\n this[this.l++] = cc >> 8;\n }\n while (this.l < end) this[this.l++] = 0;\n return this;\n } else /*:: if(typeof val === 'number') */switch (t) {\n case 1:\n size = 1;\n this[this.l] = val & 0xFF;\n break;\n case 2:\n size = 2;\n this[this.l] = val & 0xFF;\n val >>>= 8;\n this[this.l + 1] = val & 0xFF;\n break;\n case 3:\n size = 3;\n this[this.l] = val & 0xFF;\n val >>>= 8;\n this[this.l + 1] = val & 0xFF;\n val >>>= 8;\n this[this.l + 2] = val & 0xFF;\n break;\n case 4:\n size = 4;\n __writeUInt32LE(this, val, this.l);\n break;\n case 8:\n size = 8;\n if (f === 'f') {\n write_double_le(this, val, this.l);\n break;\n }\n /* falls through */\n case 16:\n break;\n case -4:\n size = 4;\n __writeInt32LE(this, val, this.l);\n break;\n }\n this.l += size;\n return this;\n}\nfunction CheckField(hexstr /*:string*/, fld /*:string*/) /*:void*/{\n var m = __hexlify(this, this.l, hexstr.length >> 1);\n if (m !== hexstr) throw new Error(fld + 'Expected ' + hexstr + ' saw ' + m);\n this.l += hexstr.length >> 1;\n}\nfunction prep_blob(blob, pos /*:number*/) /*:void*/{\n blob.l = pos;\n blob.read_shift = /*::(*/ReadShift /*:: :any)*/;\n blob.chk = CheckField;\n blob.write_shift = WriteShift;\n}\nfunction parsenoop(blob, length /*:: :number, opts?:any */) {\n blob.l += length;\n}\nfunction new_buf(sz /*:number*/) /*:Block*/{\n var o = new_raw_buf(sz);\n prep_blob(o, 0);\n return o;\n}\n\n/* [MS-XLSB] 2.1.4 Record */\nfunction recordhopper(data, cb /*:RecordHopperCB*/, opts /*:?any*/) {\n if (!data) return;\n var tmpbyte, cntbyte, length;\n prep_blob(data, data.l || 0);\n var L = data.length,\n RT = 0,\n tgt = 0;\n while (data.l < L) {\n RT = data.read_shift(1);\n if (RT & 0x80) RT = (RT & 0x7F) + ((data.read_shift(1) & 0x7F) << 7);\n var R = XLSBRecordEnum[RT] || XLSBRecordEnum[0xFFFF];\n tmpbyte = data.read_shift(1);\n length = tmpbyte & 0x7F;\n for (cntbyte = 1; cntbyte < 4 && tmpbyte & 0x80; ++cntbyte) length += ((tmpbyte = data.read_shift(1)) & 0x7F) << 7 * cntbyte;\n tgt = data.l + length;\n var d = R.f && R.f(data, length, opts);\n data.l = tgt;\n if (cb(d, R, RT)) return;\n }\n}\n\n/* control buffer usage for fixed-length buffers */\nfunction buf_array() /*:BufArray*/{\n var bufs /*:Array*/ = [],\n blksz = has_buf ? 256 : 2048;\n var newblk = function ba_newblk(sz /*:number*/) /*:Block*/{\n var o /*:Block*/ = new_buf(sz) /*:any*/;\n prep_blob(o, 0);\n return o;\n };\n var curbuf /*:Block*/ = newblk(blksz);\n var endbuf = function ba_endbuf() {\n if (!curbuf) return;\n if (curbuf.length > curbuf.l) {\n curbuf = curbuf.slice(0, curbuf.l);\n curbuf.l = curbuf.length;\n }\n if (curbuf.length > 0) bufs.push(curbuf);\n curbuf = null;\n };\n var next = function ba_next(sz /*:number*/) /*:Block*/{\n if (curbuf && sz < curbuf.length - curbuf.l) return curbuf;\n endbuf();\n return curbuf = newblk(Math.max(sz + 1, blksz));\n };\n var end = function ba_end() {\n endbuf();\n return bconcat(bufs);\n };\n var push = function ba_push(buf) {\n endbuf();\n curbuf = buf;\n if (curbuf.l == null) curbuf.l = curbuf.length;\n next(blksz);\n };\n return {\n next: next,\n push: push,\n end: end,\n _bufs: bufs\n } /*:any*/;\n}\nfunction write_record(ba /*:BufArray*/, type /*:number*/, payload, length /*:?number*/) {\n var t /*:number*/ = +type,\n l;\n if (isNaN(t)) return; // TODO: throw something here?\n if (!length) length = XLSBRecordEnum[t].p || (payload || []).length || 0;\n l = 1 + (t >= 0x80 ? 1 : 0) + 1 /* + length*/;\n if (length >= 0x80) ++l;\n if (length >= 0x4000) ++l;\n if (length >= 0x200000) ++l;\n var o = ba.next(l);\n if (t <= 0x7F) o.write_shift(1, t);else {\n o.write_shift(1, (t & 0x7F) + 0x80);\n o.write_shift(1, t >> 7);\n }\n for (var i = 0; i != 4; ++i) {\n if (length >= 0x80) {\n o.write_shift(1, (length & 0x7F) + 0x80);\n length >>= 7;\n } else {\n o.write_shift(1, length);\n break;\n }\n }\n if (/*:: length != null &&*/length > 0 && is_buf(payload)) ba.push(payload);\n}\n/* XLS ranges enforced */\nfunction shift_cell_xls(cell /*:CellAddress*/, tgt /*:any*/, opts /*:?any*/) /*:CellAddress*/{\n var out = dup(cell);\n if (tgt.s) {\n if (out.cRel) out.c += tgt.s.c;\n if (out.rRel) out.r += tgt.s.r;\n } else {\n if (out.cRel) out.c += tgt.c;\n if (out.rRel) out.r += tgt.r;\n }\n if (!opts || opts.biff < 12) {\n while (out.c >= 0x100) out.c -= 0x100;\n while (out.r >= 0x10000) out.r -= 0x10000;\n }\n return out;\n}\nfunction shift_range_xls(cell, range, opts) {\n var out = dup(cell);\n out.s = shift_cell_xls(out.s, range.s, opts);\n out.e = shift_cell_xls(out.e, range.s, opts);\n return out;\n}\nfunction encode_cell_xls(c /*:CellAddress*/, biff /*:number*/) /*:string*/{\n if (c.cRel && c.c < 0) {\n c = dup(c);\n while (c.c < 0) c.c += biff > 8 ? 0x4000 : 0x100;\n }\n if (c.rRel && c.r < 0) {\n c = dup(c);\n while (c.r < 0) c.r += biff > 8 ? 0x100000 : biff > 5 ? 0x10000 : 0x4000;\n }\n var s = encode_cell(c);\n if (!c.cRel && c.cRel != null) s = fix_col(s);\n if (!c.rRel && c.rRel != null) s = fix_row(s);\n return s;\n}\nfunction encode_range_xls(r, opts) /*:string*/{\n if (r.s.r == 0 && !r.s.rRel) {\n if (r.e.r == (opts.biff >= 12 ? 0xFFFFF : opts.biff >= 8 ? 0x10000 : 0x4000) && !r.e.rRel) {\n return (r.s.cRel ? \"\" : \"$\") + encode_col(r.s.c) + \":\" + (r.e.cRel ? \"\" : \"$\") + encode_col(r.e.c);\n }\n }\n if (r.s.c == 0 && !r.s.cRel) {\n if (r.e.c == (opts.biff >= 12 ? 0x3FFF : 0xFF) && !r.e.cRel) {\n return (r.s.rRel ? \"\" : \"$\") + encode_row(r.s.r) + \":\" + (r.e.rRel ? \"\" : \"$\") + encode_row(r.e.r);\n }\n }\n return encode_cell_xls(r.s, opts.biff) + \":\" + encode_cell_xls(r.e, opts.biff);\n}\nfunction decode_row(rowstr /*:string*/) /*:number*/{\n return parseInt(unfix_row(rowstr), 10) - 1;\n}\nfunction encode_row(row /*:number*/) /*:string*/{\n return \"\" + (row + 1);\n}\nfunction fix_row(cstr /*:string*/) /*:string*/{\n return cstr.replace(/([A-Z]|^)(\\d+)$/, \"$1$$$2\");\n}\nfunction unfix_row(cstr /*:string*/) /*:string*/{\n return cstr.replace(/\\$(\\d+)$/, \"$1\");\n}\nfunction decode_col(colstr /*:string*/) /*:number*/{\n var c = unfix_col(colstr),\n d = 0,\n i = 0;\n for (; i !== c.length; ++i) d = 26 * d + c.charCodeAt(i) - 64;\n return d - 1;\n}\nfunction encode_col(col /*:number*/) /*:string*/{\n if (col < 0) throw new Error(\"invalid column \" + col);\n var s = \"\";\n for (++col; col; col = Math.floor((col - 1) / 26)) s = String.fromCharCode((col - 1) % 26 + 65) + s;\n return s;\n}\nfunction fix_col(cstr /*:string*/) /*:string*/{\n return cstr.replace(/^([A-Z])/, \"$$$1\");\n}\nfunction unfix_col(cstr /*:string*/) /*:string*/{\n return cstr.replace(/^\\$([A-Z])/, \"$1\");\n}\nfunction split_cell(cstr /*:string*/) /*:Array*/{\n return cstr.replace(/(\\$?[A-Z]*)(\\$?\\d*)/, \"$1,$2\").split(\",\");\n}\n//function decode_cell(cstr/*:string*/)/*:CellAddress*/ { var splt = split_cell(cstr); return { c:decode_col(splt[0]), r:decode_row(splt[1]) }; }\nfunction decode_cell(cstr /*:string*/) /*:CellAddress*/{\n var R = 0,\n C = 0;\n for (var i = 0; i < cstr.length; ++i) {\n var cc = cstr.charCodeAt(i);\n if (cc >= 48 && cc <= 57) R = 10 * R + (cc - 48);else if (cc >= 65 && cc <= 90) C = 26 * C + (cc - 64);\n }\n return {\n c: C - 1,\n r: R - 1\n };\n}\n//function encode_cell(cell/*:CellAddress*/)/*:string*/ { return encode_col(cell.c) + encode_row(cell.r); }\nfunction encode_cell(cell /*:CellAddress*/) /*:string*/{\n var col = cell.c + 1;\n var s = \"\";\n for (; col; col = (col - 1) / 26 | 0) s = String.fromCharCode((col - 1) % 26 + 65) + s;\n return s + (cell.r + 1);\n}\nfunction decode_range(range /*:string*/) /*:Range*/{\n var idx = range.indexOf(\":\");\n if (idx == -1) return {\n s: decode_cell(range),\n e: decode_cell(range)\n };\n return {\n s: decode_cell(range.slice(0, idx)),\n e: decode_cell(range.slice(idx + 1))\n };\n}\n/*# if only one arg, it is assumed to be a Range. If 2 args, both are cell addresses */\nfunction encode_range(cs /*:CellAddrSpec|Range*/, ce /*:?CellAddrSpec*/) /*:string*/{\n if (typeof ce === 'undefined' || typeof ce === 'number') {\n /*:: if(!(cs instanceof Range)) throw \"unreachable\"; */\n return encode_range(cs.s, cs.e);\n }\n /*:: if((cs instanceof Range)) throw \"unreachable\"; */\n if (typeof cs !== 'string') cs = encode_cell(cs /*:any*/);\n if (typeof ce !== 'string') ce = encode_cell(ce /*:any*/);\n /*:: if(typeof cs !== 'string') throw \"unreachable\"; */\n /*:: if(typeof ce !== 'string') throw \"unreachable\"; */\n return cs == ce ? cs : cs + \":\" + ce;\n}\nfunction safe_decode_range(range /*:string*/) /*:Range*/{\n var o = {\n s: {\n c: 0,\n r: 0\n },\n e: {\n c: 0,\n r: 0\n }\n };\n var idx = 0,\n i = 0,\n cc = 0;\n var len = range.length;\n for (idx = 0; i < len; ++i) {\n if ((cc = range.charCodeAt(i) - 64) < 1 || cc > 26) break;\n idx = 26 * idx + cc;\n }\n o.s.c = --idx;\n for (idx = 0; i < len; ++i) {\n if ((cc = range.charCodeAt(i) - 48) < 0 || cc > 9) break;\n idx = 10 * idx + cc;\n }\n o.s.r = --idx;\n if (i === len || cc != 10) {\n o.e.c = o.s.c;\n o.e.r = o.s.r;\n return o;\n }\n ++i;\n for (idx = 0; i != len; ++i) {\n if ((cc = range.charCodeAt(i) - 64) < 1 || cc > 26) break;\n idx = 26 * idx + cc;\n }\n o.e.c = --idx;\n for (idx = 0; i != len; ++i) {\n if ((cc = range.charCodeAt(i) - 48) < 0 || cc > 9) break;\n idx = 10 * idx + cc;\n }\n o.e.r = --idx;\n return o;\n}\nfunction safe_format_cell(cell /*:Cell*/, v /*:any*/) {\n var q = cell.t == 'd' && v instanceof Date;\n if (cell.z != null) try {\n return cell.w = SSF_format(cell.z, q ? datenum(v) : v);\n } catch (e) {}\n try {\n return cell.w = SSF_format((cell.XF || {}).numFmtId || (q ? 14 : 0), q ? datenum(v) : v);\n } catch (e) {\n return '' + v;\n }\n}\nfunction format_cell(cell /*:Cell*/, v /*:any*/, o /*:any*/) {\n if (cell == null || cell.t == null || cell.t == 'z') return \"\";\n if (cell.w !== undefined) return cell.w;\n if (cell.t == 'd' && !cell.z && o && o.dateNF) cell.z = o.dateNF;\n if (cell.t == \"e\") return BErr[cell.v] || cell.v;\n if (v == undefined) return safe_format_cell(cell, cell.v);\n return safe_format_cell(cell, v);\n}\nfunction sheet_to_workbook(sheet /*:Worksheet*/, opts) /*:Workbook*/{\n var n = opts && opts.sheet ? opts.sheet : \"Sheet1\";\n var sheets = {};\n sheets[n] = sheet;\n return {\n SheetNames: [n],\n Sheets: sheets\n };\n}\nfunction sheet_add_aoa(_ws /*:?Worksheet*/, data /*:AOA*/, opts /*:?any*/) /*:Worksheet*/{\n var o = opts || {};\n var dense = _ws ? Array.isArray(_ws) : o.dense;\n if (DENSE != null && dense == null) dense = DENSE;\n var ws /*:Worksheet*/ = _ws || (dense ? [] /*:any*/ : {} /*:any*/);\n var _R = 0,\n _C = 0;\n if (ws && o.origin != null) {\n if (typeof o.origin == 'number') _R = o.origin;else {\n var _origin /*:CellAddress*/ = typeof o.origin == \"string\" ? decode_cell(o.origin) : o.origin;\n _R = _origin.r;\n _C = _origin.c;\n }\n if (!ws[\"!ref\"]) ws[\"!ref\"] = \"A1:A1\";\n }\n var range /*:Range*/ = {\n s: {\n c: 10000000,\n r: 10000000\n },\n e: {\n c: 0,\n r: 0\n }\n } /*:any*/;\n if (ws['!ref']) {\n var _range = safe_decode_range(ws['!ref']);\n range.s.c = _range.s.c;\n range.s.r = _range.s.r;\n range.e.c = Math.max(range.e.c, _range.e.c);\n range.e.r = Math.max(range.e.r, _range.e.r);\n if (_R == -1) range.e.r = _R = _range.e.r + 1;\n }\n for (var R = 0; R != data.length; ++R) {\n if (!data[R]) continue;\n if (!Array.isArray(data[R])) throw new Error(\"aoa_to_sheet expects an array of arrays\");\n for (var C = 0; C != data[R].length; ++C) {\n if (typeof data[R][C] === 'undefined') continue;\n var cell /*:Cell*/ = {\n v: data[R][C]\n } /*:any*/;\n var __R = _R + R,\n __C = _C + C;\n if (range.s.r > __R) range.s.r = __R;\n if (range.s.c > __C) range.s.c = __C;\n if (range.e.r < __R) range.e.r = __R;\n if (range.e.c < __C) range.e.c = __C;\n if (data[R][C] && typeof data[R][C] === 'object' && !Array.isArray(data[R][C]) && !(data[R][C] instanceof Date)) cell = data[R][C];else {\n if (Array.isArray(cell.v)) {\n cell.f = data[R][C][1];\n cell.v = cell.v[0];\n }\n if (cell.v === null) {\n if (cell.f) cell.t = 'n';else if (o.nullError) {\n cell.t = 'e';\n cell.v = 0;\n } else if (!o.sheetStubs) continue;else cell.t = 'z';\n } else if (typeof cell.v === 'number') cell.t = 'n';else if (typeof cell.v === 'boolean') cell.t = 'b';else if (cell.v instanceof Date) {\n cell.z = o.dateNF || table_fmt[14];\n if (o.cellDates) {\n cell.t = 'd';\n cell.w = SSF_format(cell.z, datenum(cell.v));\n } else {\n cell.t = 'n';\n cell.v = datenum(cell.v);\n cell.w = SSF_format(cell.z, cell.v);\n }\n } else cell.t = 's';\n }\n if (dense) {\n if (!ws[__R]) ws[__R] = [];\n if (ws[__R][__C] && ws[__R][__C].z) cell.z = ws[__R][__C].z;\n ws[__R][__C] = cell;\n } else {\n var cell_ref = encode_cell({\n c: __C,\n r: __R\n } /*:any*/);\n if (ws[cell_ref] && ws[cell_ref].z) cell.z = ws[cell_ref].z;\n ws[cell_ref] = cell;\n }\n }\n }\n if (range.s.c < 10000000) ws['!ref'] = encode_range(range);\n return ws;\n}\nfunction aoa_to_sheet(data /*:AOA*/, opts /*:?any*/) /*:Worksheet*/{\n return sheet_add_aoa(null, data, opts);\n}\nfunction parse_Int32LE(data) {\n return data.read_shift(4, 'i');\n}\nfunction write_UInt32LE(x /*:number*/, o) {\n if (!o) o = new_buf(4);\n o.write_shift(4, x);\n return o;\n}\n\n/* [MS-XLSB] 2.5.168 */\nfunction parse_XLWideString(data /*::, length*/) /*:string*/{\n var cchCharacters = data.read_shift(4);\n return cchCharacters === 0 ? \"\" : data.read_shift(cchCharacters, 'dbcs');\n}\nfunction write_XLWideString(data /*:string*/, o) {\n var _null = false;\n if (o == null) {\n _null = true;\n o = new_buf(4 + 2 * data.length);\n }\n o.write_shift(4, data.length);\n if (data.length > 0) o.write_shift(0, data, 'dbcs');\n return _null ? o.slice(0, o.l) : o;\n}\n\n/* [MS-XLSB] 2.5.91 */\n//function parse_LPWideString(data/*::, length*/)/*:string*/ {\n//\tvar cchCharacters = data.read_shift(2);\n//\treturn cchCharacters === 0 ? \"\" : data.read_shift(cchCharacters, \"utf16le\");\n//}\n\n/* [MS-XLSB] 2.5.143 */\nfunction parse_StrRun(data) {\n return {\n ich: data.read_shift(2),\n ifnt: data.read_shift(2)\n };\n}\nfunction write_StrRun(run, o) {\n if (!o) o = new_buf(4);\n o.write_shift(2, run.ich || 0);\n o.write_shift(2, run.ifnt || 0);\n return o;\n}\n\n/* [MS-XLSB] 2.5.121 */\nfunction parse_RichStr(data, length /*:number*/) /*:XLString*/{\n var start = data.l;\n var flags = data.read_shift(1);\n var str = parse_XLWideString(data);\n var rgsStrRun = [];\n var z = {\n t: str,\n h: str\n } /*:any*/;\n if ((flags & 1) !== 0) {\n /* fRichStr */\n /* TODO: formatted string */\n var dwSizeStrRun = data.read_shift(4);\n for (var i = 0; i != dwSizeStrRun; ++i) rgsStrRun.push(parse_StrRun(data));\n z.r = rgsStrRun;\n } else z.r = [{\n ich: 0,\n ifnt: 0\n }];\n //if((flags & 2) !== 0) { /* fExtStr */\n //\t/* TODO: phonetic string */\n //}\n data.l = start + length;\n return z;\n}\nfunction write_RichStr(str /*:XLString*/, o /*:?Block*/) /*:Block*/{\n /* TODO: formatted string */\n var _null = false;\n if (o == null) {\n _null = true;\n o = new_buf(15 + 4 * str.t.length);\n }\n o.write_shift(1, 0);\n write_XLWideString(str.t, o);\n return _null ? o.slice(0, o.l) : o;\n}\n/* [MS-XLSB] 2.4.328 BrtCommentText (RichStr w/1 run) */\nvar parse_BrtCommentText = parse_RichStr;\nfunction write_BrtCommentText(str /*:XLString*/, o /*:?Block*/) /*:Block*/{\n /* TODO: formatted string */\n var _null = false;\n if (o == null) {\n _null = true;\n o = new_buf(23 + 4 * str.t.length);\n }\n o.write_shift(1, 1);\n write_XLWideString(str.t, o);\n o.write_shift(4, 1);\n write_StrRun({\n ich: 0,\n ifnt: 0\n }, o);\n return _null ? o.slice(0, o.l) : o;\n}\n\n/* [MS-XLSB] 2.5.9 */\nfunction parse_XLSBCell(data) /*:any*/{\n var col = data.read_shift(4);\n var iStyleRef = data.read_shift(2);\n iStyleRef += data.read_shift(1) << 16;\n data.l++; //var fPhShow = data.read_shift(1);\n return {\n c: col,\n iStyleRef: iStyleRef\n };\n}\nfunction write_XLSBCell(cell /*:any*/, o /*:?Block*/) {\n if (o == null) o = new_buf(8);\n o.write_shift(-4, cell.c);\n o.write_shift(3, cell.iStyleRef || cell.s);\n o.write_shift(1, 0); /* fPhShow */\n return o;\n}\n\n/* Short XLSB Cell does not include column */\nfunction parse_XLSBShortCell(data) /*:any*/{\n var iStyleRef = data.read_shift(2);\n iStyleRef += data.read_shift(1) << 16;\n data.l++; //var fPhShow = data.read_shift(1);\n return {\n c: -1,\n iStyleRef: iStyleRef\n };\n}\nfunction write_XLSBShortCell(cell /*:any*/, o /*:?Block*/) {\n if (o == null) o = new_buf(4);\n o.write_shift(3, cell.iStyleRef || cell.s);\n o.write_shift(1, 0); /* fPhShow */\n return o;\n}\n\n/* [MS-XLSB] 2.5.21 */\nvar parse_XLSBCodeName = parse_XLWideString;\nvar write_XLSBCodeName = write_XLWideString;\n\n/* [MS-XLSB] 2.5.166 */\nfunction parse_XLNullableWideString(data /*::, length*/) /*:string*/{\n var cchCharacters = data.read_shift(4);\n return cchCharacters === 0 || cchCharacters === 0xFFFFFFFF ? \"\" : data.read_shift(cchCharacters, 'dbcs');\n}\nfunction write_XLNullableWideString(data /*:string*/, o) {\n var _null = false;\n if (o == null) {\n _null = true;\n o = new_buf(127);\n }\n o.write_shift(4, data.length > 0 ? data.length : 0xFFFFFFFF);\n if (data.length > 0) o.write_shift(0, data, 'dbcs');\n return _null ? o.slice(0, o.l) : o;\n}\n\n/* [MS-XLSB] 2.5.165 */\nvar parse_XLNameWideString = parse_XLWideString;\n//var write_XLNameWideString = write_XLWideString;\n\n/* [MS-XLSB] 2.5.114 */\nvar parse_RelID = parse_XLNullableWideString;\nvar write_RelID = write_XLNullableWideString;\n\n/* [MS-XLS] 2.5.217 ; [MS-XLSB] 2.5.122 */\nfunction parse_RkNumber(data) /*:number*/{\n var b = data.slice(data.l, data.l + 4);\n var fX100 = b[0] & 1,\n fInt = b[0] & 2;\n data.l += 4;\n var RK = fInt === 0 ? __double([0, 0, 0, 0, b[0] & 0xFC, b[1], b[2], b[3]], 0) : __readInt32LE(b, 0) >> 2;\n return fX100 ? RK / 100 : RK;\n}\nfunction write_RkNumber(data /*:number*/, o) {\n if (o == null) o = new_buf(4);\n var fX100 = 0,\n fInt = 0,\n d100 = data * 100;\n if (data == (data | 0) && data >= -(1 << 29) && data < 1 << 29) {\n fInt = 1;\n } else if (d100 == (d100 | 0) && d100 >= -(1 << 29) && d100 < 1 << 29) {\n fInt = 1;\n fX100 = 1;\n }\n if (fInt) o.write_shift(-4, ((fX100 ? d100 : data) << 2) + (fX100 + 2));else throw new Error(\"unsupported RkNumber \" + data); // TODO\n}\n\n/* [MS-XLSB] 2.5.117 RfX */\nfunction parse_RfX(data /*::, length*/) /*:Range*/{\n var cell /*:Range*/ = {\n s: {},\n e: {}\n } /*:any*/;\n cell.s.r = data.read_shift(4);\n cell.e.r = data.read_shift(4);\n cell.s.c = data.read_shift(4);\n cell.e.c = data.read_shift(4);\n return cell;\n}\nfunction write_RfX(r /*:Range*/, o) {\n if (!o) o = new_buf(16);\n o.write_shift(4, r.s.r);\n o.write_shift(4, r.e.r);\n o.write_shift(4, r.s.c);\n o.write_shift(4, r.e.c);\n return o;\n}\n\n/* [MS-XLSB] 2.5.153 UncheckedRfX */\nvar parse_UncheckedRfX = parse_RfX;\nvar write_UncheckedRfX = write_RfX;\n\n/* [MS-XLSB] 2.5.155 UncheckedSqRfX */\n//function parse_UncheckedSqRfX(data) {\n//\tvar cnt = data.read_shift(4);\n//\tvar out = [];\n//\tfor(var i = 0; i < cnt; ++i) {\n//\t\tvar rng = parse_UncheckedRfX(data);\n//\t\tout.push(encode_range(rng));\n//\t}\n//\treturn out.join(\",\");\n//}\n//function write_UncheckedSqRfX(sqrfx/*:string*/) {\n//\tvar parts = sqrfx.split(/\\s*,\\s*/);\n//\tvar o = new_buf(4); o.write_shift(4, parts.length);\n//\tvar out = [o];\n//\tparts.forEach(function(rng) {\n//\t\tout.push(write_UncheckedRfX(safe_decode_range(rng)));\n//\t});\n//\treturn bconcat(out);\n//}\n\n/* [MS-XLS] 2.5.342 ; [MS-XLSB] 2.5.171 */\n/* TODO: error checking, NaN and Infinity values are not valid Xnum */\nfunction parse_Xnum(data /*::, length*/) {\n if (data.length - data.l < 8) throw \"XLS Xnum Buffer underflow\";\n return data.read_shift(8, 'f');\n}\nfunction write_Xnum(data, o) {\n return (o || new_buf(8)).write_shift(8, data, 'f');\n}\n\n/* [MS-XLSB] 2.4.324 BrtColor */\nfunction parse_BrtColor(data /*::, length*/) {\n var out = {};\n var d = data.read_shift(1);\n\n //var fValidRGB = d & 1;\n var xColorType = d >>> 1;\n var index = data.read_shift(1);\n var nTS = data.read_shift(2, 'i');\n var bR = data.read_shift(1);\n var bG = data.read_shift(1);\n var bB = data.read_shift(1);\n data.l++; //var bAlpha = data.read_shift(1);\n\n switch (xColorType) {\n case 0:\n out.auto = 1;\n break;\n case 1:\n out.index = index;\n var icv = XLSIcv[index];\n /* automatic pseudo index 81 */\n if (icv) out.rgb = rgb2Hex(icv);\n break;\n case 2:\n /* if(!fValidRGB) throw new Error(\"invalid\"); */\n out.rgb = rgb2Hex([bR, bG, bB]);\n break;\n case 3:\n out.theme = index;\n break;\n }\n if (nTS != 0) out.tint = nTS > 0 ? nTS / 32767 : nTS / 32768;\n return out;\n}\nfunction write_BrtColor(color, o) {\n if (!o) o = new_buf(8);\n if (!color || color.auto) {\n o.write_shift(4, 0);\n o.write_shift(4, 0);\n return o;\n }\n if (color.index != null) {\n o.write_shift(1, 0x02);\n o.write_shift(1, color.index);\n } else if (color.theme != null) {\n o.write_shift(1, 0x06);\n o.write_shift(1, color.theme);\n } else {\n o.write_shift(1, 0x05);\n o.write_shift(1, 0);\n }\n var nTS = color.tint || 0;\n if (nTS > 0) nTS *= 32767;else if (nTS < 0) nTS *= 32768;\n o.write_shift(2, nTS);\n if (!color.rgb || color.theme != null) {\n o.write_shift(2, 0);\n o.write_shift(1, 0);\n o.write_shift(1, 0);\n } else {\n var rgb = color.rgb || 'FFFFFF';\n if (typeof rgb == 'number') rgb = (\"000000\" + rgb.toString(16)).slice(-6);\n o.write_shift(1, parseInt(rgb.slice(0, 2), 16));\n o.write_shift(1, parseInt(rgb.slice(2, 4), 16));\n o.write_shift(1, parseInt(rgb.slice(4, 6), 16));\n o.write_shift(1, 0xFF);\n }\n return o;\n}\n\n/* [MS-XLSB] 2.5.52 */\nfunction parse_FontFlags(data /*::, length, opts*/) {\n var d = data.read_shift(1);\n data.l++;\n var out = {\n fBold: d & 0x01,\n fItalic: d & 0x02,\n fUnderline: d & 0x04,\n fStrikeout: d & 0x08,\n fOutline: d & 0x10,\n fShadow: d & 0x20,\n fCondense: d & 0x40,\n fExtend: d & 0x80\n };\n return out;\n}\nfunction write_FontFlags(font, o) {\n if (!o) o = new_buf(2);\n var grbit = (font.italic ? 0x02 : 0) | (font.strike ? 0x08 : 0) | (font.outline ? 0x10 : 0) | (font.shadow ? 0x20 : 0) | (font.condense ? 0x40 : 0) | (font.extend ? 0x80 : 0);\n o.write_shift(1, grbit);\n o.write_shift(1, 0);\n return o;\n}\n\n/* [MS-OLEDS] 2.3.1 and 2.3.2 */\nfunction parse_ClipboardFormatOrString(o, w /*:number*/) /*:string*/{\n // $FlowIgnore\n var ClipFmt = {\n 2: \"BITMAP\",\n 3: \"METAFILEPICT\",\n 8: \"DIB\",\n 14: \"ENHMETAFILE\"\n };\n var m /*:number*/ = o.read_shift(4);\n switch (m) {\n case 0x00000000:\n return \"\";\n case 0xffffffff:\n case 0xfffffffe:\n return ClipFmt[o.read_shift(4)] || \"\";\n }\n if (m > 0x190) throw new Error(\"Unsupported Clipboard: \" + m.toString(16));\n o.l -= 4;\n return o.read_shift(0, w == 1 ? \"lpstr\" : \"lpwstr\");\n}\nfunction parse_ClipboardFormatOrAnsiString(o) {\n return parse_ClipboardFormatOrString(o, 1);\n}\nfunction parse_ClipboardFormatOrUnicodeString(o) {\n return parse_ClipboardFormatOrString(o, 2);\n}\n\n/* [MS-OLEPS] 2.2 PropertyType */\n// Note: some tree shakers cannot handle VT_VECTOR | $CONST, hence extra vars\n//var VT_EMPTY = 0x0000;\n//var VT_NULL = 0x0001;\nvar VT_I2 = 0x0002;\nvar VT_I4 = 0x0003;\n//var VT_R4 = 0x0004;\n//var VT_R8 = 0x0005;\n//var VT_CY = 0x0006;\n//var VT_DATE = 0x0007;\n//var VT_BSTR = 0x0008;\n//var VT_ERROR = 0x000A;\nvar VT_BOOL = 0x000B;\nvar VT_VARIANT = 0x000C;\n//var VT_DECIMAL = 0x000E;\n//var VT_I1 = 0x0010;\n//var VT_UI1 = 0x0011;\n//var VT_UI2 = 0x0012;\nvar VT_UI4 = 0x0013;\n//var VT_I8 = 0x0014;\n//var VT_UI8 = 0x0015;\n//var VT_INT = 0x0016;\n//var VT_UINT = 0x0017;\nvar VT_LPSTR = 0x001E;\n//var VT_LPWSTR = 0x001F;\nvar VT_FILETIME = 0x0040;\nvar VT_BLOB = 0x0041;\n//var VT_STREAM = 0x0042;\n//var VT_STORAGE = 0x0043;\n//var VT_STREAMED_Object = 0x0044;\n//var VT_STORED_Object = 0x0045;\n//var VT_BLOB_Object = 0x0046;\nvar VT_CF = 0x0047;\n//var VT_CLSID = 0x0048;\n//var VT_VERSIONED_STREAM = 0x0049;\nvar VT_VECTOR = 0x1000;\nvar VT_VECTOR_VARIANT = 0x100C;\nvar VT_VECTOR_LPSTR = 0x101E;\n//var VT_ARRAY = 0x2000;\n\nvar VT_STRING = 0x0050; // 2.3.3.1.11 VtString\nvar VT_USTR = 0x0051; // 2.3.3.1.12 VtUnalignedString\nvar VT_CUSTOM = [VT_STRING, VT_USTR];\n\n/* [MS-OSHARED] 2.3.3.2.2.1 Document Summary Information PIDDSI */\nvar DocSummaryPIDDSI = {\n /*::[*/0x01 /*::]*/: {\n n: 'CodePage',\n t: VT_I2\n },\n /*::[*/0x02 /*::]*/: {\n n: 'Category',\n t: VT_STRING\n },\n /*::[*/0x03 /*::]*/: {\n n: 'PresentationFormat',\n t: VT_STRING\n },\n /*::[*/0x04 /*::]*/: {\n n: 'ByteCount',\n t: VT_I4\n },\n /*::[*/0x05 /*::]*/: {\n n: 'LineCount',\n t: VT_I4\n },\n /*::[*/0x06 /*::]*/: {\n n: 'ParagraphCount',\n t: VT_I4\n },\n /*::[*/0x07 /*::]*/: {\n n: 'SlideCount',\n t: VT_I4\n },\n /*::[*/0x08 /*::]*/: {\n n: 'NoteCount',\n t: VT_I4\n },\n /*::[*/0x09 /*::]*/: {\n n: 'HiddenCount',\n t: VT_I4\n },\n /*::[*/0x0a /*::]*/: {\n n: 'MultimediaClipCount',\n t: VT_I4\n },\n /*::[*/0x0b /*::]*/: {\n n: 'ScaleCrop',\n t: VT_BOOL\n },\n /*::[*/0x0c /*::]*/: {\n n: 'HeadingPairs',\n t: VT_VECTOR_VARIANT /* VT_VECTOR | VT_VARIANT */\n },\n /*::[*/0x0d /*::]*/: {\n n: 'TitlesOfParts',\n t: VT_VECTOR_LPSTR /* VT_VECTOR | VT_LPSTR */\n },\n /*::[*/0x0e /*::]*/: {\n n: 'Manager',\n t: VT_STRING\n },\n /*::[*/0x0f /*::]*/: {\n n: 'Company',\n t: VT_STRING\n },\n /*::[*/0x10 /*::]*/: {\n n: 'LinksUpToDate',\n t: VT_BOOL\n },\n /*::[*/0x11 /*::]*/: {\n n: 'CharacterCount',\n t: VT_I4\n },\n /*::[*/0x13 /*::]*/: {\n n: 'SharedDoc',\n t: VT_BOOL\n },\n /*::[*/0x16 /*::]*/: {\n n: 'HyperlinksChanged',\n t: VT_BOOL\n },\n /*::[*/0x17 /*::]*/: {\n n: 'AppVersion',\n t: VT_I4,\n p: 'version'\n },\n /*::[*/0x18 /*::]*/: {\n n: 'DigSig',\n t: VT_BLOB\n },\n /*::[*/0x1A /*::]*/: {\n n: 'ContentType',\n t: VT_STRING\n },\n /*::[*/0x1B /*::]*/: {\n n: 'ContentStatus',\n t: VT_STRING\n },\n /*::[*/0x1C /*::]*/: {\n n: 'Language',\n t: VT_STRING\n },\n /*::[*/0x1D /*::]*/: {\n n: 'Version',\n t: VT_STRING\n },\n /*::[*/0xFF /*::]*/: {},\n /* [MS-OLEPS] 2.18 */\n /*::[*/0x80000000 /*::]*/: {\n n: 'Locale',\n t: VT_UI4\n },\n /*::[*/0x80000003 /*::]*/: {\n n: 'Behavior',\n t: VT_UI4\n },\n /*::[*/0x72627262 /*::]*/: {}\n};\n\n/* [MS-OSHARED] 2.3.3.2.1.1 Summary Information Property Set PIDSI */\nvar SummaryPIDSI = {\n /*::[*/0x01 /*::]*/: {\n n: 'CodePage',\n t: VT_I2\n },\n /*::[*/0x02 /*::]*/: {\n n: 'Title',\n t: VT_STRING\n },\n /*::[*/0x03 /*::]*/: {\n n: 'Subject',\n t: VT_STRING\n },\n /*::[*/0x04 /*::]*/: {\n n: 'Author',\n t: VT_STRING\n },\n /*::[*/0x05 /*::]*/: {\n n: 'Keywords',\n t: VT_STRING\n },\n /*::[*/0x06 /*::]*/: {\n n: 'Comments',\n t: VT_STRING\n },\n /*::[*/0x07 /*::]*/: {\n n: 'Template',\n t: VT_STRING\n },\n /*::[*/0x08 /*::]*/: {\n n: 'LastAuthor',\n t: VT_STRING\n },\n /*::[*/0x09 /*::]*/: {\n n: 'RevNumber',\n t: VT_STRING\n },\n /*::[*/0x0A /*::]*/: {\n n: 'EditTime',\n t: VT_FILETIME\n },\n /*::[*/0x0B /*::]*/: {\n n: 'LastPrinted',\n t: VT_FILETIME\n },\n /*::[*/0x0C /*::]*/: {\n n: 'CreatedDate',\n t: VT_FILETIME\n },\n /*::[*/0x0D /*::]*/: {\n n: 'ModifiedDate',\n t: VT_FILETIME\n },\n /*::[*/0x0E /*::]*/: {\n n: 'PageCount',\n t: VT_I4\n },\n /*::[*/0x0F /*::]*/: {\n n: 'WordCount',\n t: VT_I4\n },\n /*::[*/0x10 /*::]*/: {\n n: 'CharCount',\n t: VT_I4\n },\n /*::[*/0x11 /*::]*/: {\n n: 'Thumbnail',\n t: VT_CF\n },\n /*::[*/0x12 /*::]*/: {\n n: 'Application',\n t: VT_STRING\n },\n /*::[*/0x13 /*::]*/: {\n n: 'DocSecurity',\n t: VT_I4\n },\n /*::[*/0xFF /*::]*/: {},\n /* [MS-OLEPS] 2.18 */\n /*::[*/0x80000000 /*::]*/: {\n n: 'Locale',\n t: VT_UI4\n },\n /*::[*/0x80000003 /*::]*/: {\n n: 'Behavior',\n t: VT_UI4\n },\n /*::[*/0x72627262 /*::]*/: {}\n};\n\n/* [MS-XLS] 2.4.63 Country/Region codes */\nvar CountryEnum = {\n /*::[*/0x0001 /*::]*/: \"US\",\n // United States\n /*::[*/\n 0x0002 /*::]*/: \"CA\",\n // Canada\n /*::[*/\n 0x0003 /*::]*/: \"\",\n // Latin America (except Brazil)\n /*::[*/\n 0x0007 /*::]*/: \"RU\",\n // Russia\n /*::[*/\n 0x0014 /*::]*/: \"EG\",\n // Egypt\n /*::[*/\n 0x001E /*::]*/: \"GR\",\n // Greece\n /*::[*/\n 0x001F /*::]*/: \"NL\",\n // Netherlands\n /*::[*/\n 0x0020 /*::]*/: \"BE\",\n // Belgium\n /*::[*/\n 0x0021 /*::]*/: \"FR\",\n // France\n /*::[*/\n 0x0022 /*::]*/: \"ES\",\n // Spain\n /*::[*/\n 0x0024 /*::]*/: \"HU\",\n // Hungary\n /*::[*/\n 0x0027 /*::]*/: \"IT\",\n // Italy\n /*::[*/\n 0x0029 /*::]*/: \"CH\",\n // Switzerland\n /*::[*/\n 0x002B /*::]*/: \"AT\",\n // Austria\n /*::[*/\n 0x002C /*::]*/: \"GB\",\n // United Kingdom\n /*::[*/\n 0x002D /*::]*/: \"DK\",\n // Denmark\n /*::[*/\n 0x002E /*::]*/: \"SE\",\n // Sweden\n /*::[*/\n 0x002F /*::]*/: \"NO\",\n // Norway\n /*::[*/\n 0x0030 /*::]*/: \"PL\",\n // Poland\n /*::[*/\n 0x0031 /*::]*/: \"DE\",\n // Germany\n /*::[*/\n 0x0034 /*::]*/: \"MX\",\n // Mexico\n /*::[*/\n 0x0037 /*::]*/: \"BR\",\n // Brazil\n /*::[*/\n 0x003d /*::]*/: \"AU\",\n // Australia\n /*::[*/\n 0x0040 /*::]*/: \"NZ\",\n // New Zealand\n /*::[*/\n 0x0042 /*::]*/: \"TH\",\n // Thailand\n /*::[*/\n 0x0051 /*::]*/: \"JP\",\n // Japan\n /*::[*/\n 0x0052 /*::]*/: \"KR\",\n // Korea\n /*::[*/\n 0x0054 /*::]*/: \"VN\",\n // Viet Nam\n /*::[*/\n 0x0056 /*::]*/: \"CN\",\n // China\n /*::[*/\n 0x005A /*::]*/: \"TR\",\n // Turkey\n /*::[*/\n 0x0069 /*::]*/: \"JS\",\n // Ramastan\n /*::[*/\n 0x00D5 /*::]*/: \"DZ\",\n // Algeria\n /*::[*/\n 0x00D8 /*::]*/: \"MA\",\n // Morocco\n /*::[*/\n 0x00DA /*::]*/: \"LY\",\n // Libya\n /*::[*/\n 0x015F /*::]*/: \"PT\",\n // Portugal\n /*::[*/\n 0x0162 /*::]*/: \"IS\",\n // Iceland\n /*::[*/\n 0x0166 /*::]*/: \"FI\",\n // Finland\n /*::[*/\n 0x01A4 /*::]*/: \"CZ\",\n // Czech Republic\n /*::[*/\n 0x0376 /*::]*/: \"TW\",\n // Taiwan\n /*::[*/\n 0x03C1 /*::]*/: \"LB\",\n // Lebanon\n /*::[*/\n 0x03C2 /*::]*/: \"JO\",\n // Jordan\n /*::[*/\n 0x03C3 /*::]*/: \"SY\",\n // Syria\n /*::[*/\n 0x03C4 /*::]*/: \"IQ\",\n // Iraq\n /*::[*/\n 0x03C5 /*::]*/: \"KW\",\n // Kuwait\n /*::[*/\n 0x03C6 /*::]*/: \"SA\",\n // Saudi Arabia\n /*::[*/\n 0x03CB /*::]*/: \"AE\",\n // United Arab Emirates\n /*::[*/\n 0x03CC /*::]*/: \"IL\",\n // Israel\n /*::[*/\n 0x03CE /*::]*/: \"QA\",\n // Qatar\n /*::[*/\n 0x03D5 /*::]*/: \"IR\",\n // Iran\n /*::[*/\n 0xFFFF /*::]*/: \"US\" // United States\n};\n\n/* [MS-XLS] 2.5.127 */\nvar XLSFillPattern = [null, 'solid', 'mediumGray', 'darkGray', 'lightGray', 'darkHorizontal', 'darkVertical', 'darkDown', 'darkUp', 'darkGrid', 'darkTrellis', 'lightHorizontal', 'lightVertical', 'lightDown', 'lightUp', 'lightGrid', 'lightTrellis', 'gray125', 'gray0625'];\nfunction rgbify(arr /*:Array*/) /*:Array<[number, number, number]>*/{\n return arr.map(function (x) {\n return [x >> 16 & 255, x >> 8 & 255, x & 255];\n });\n}\n\n/* [MS-XLS] 2.5.161 */\n/* [MS-XLSB] 2.5.75 Icv */\nvar _XLSIcv = /*#__PURE__*/rgbify([/* Color Constants */\n0x000000, 0xFFFFFF, 0xFF0000, 0x00FF00, 0x0000FF, 0xFFFF00, 0xFF00FF, 0x00FFFF, /* Overridable Defaults */\n0x000000, 0xFFFFFF, 0xFF0000, 0x00FF00, 0x0000FF, 0xFFFF00, 0xFF00FF, 0x00FFFF, 0x800000, 0x008000, 0x000080, 0x808000, 0x800080, 0x008080, 0xC0C0C0, 0x808080, 0x9999FF, 0x993366, 0xFFFFCC, 0xCCFFFF, 0x660066, 0xFF8080, 0x0066CC, 0xCCCCFF, 0x000080, 0xFF00FF, 0xFFFF00, 0x00FFFF, 0x800080, 0x800000, 0x008080, 0x0000FF, 0x00CCFF, 0xCCFFFF, 0xCCFFCC, 0xFFFF99, 0x99CCFF, 0xFF99CC, 0xCC99FF, 0xFFCC99, 0x3366FF, 0x33CCCC, 0x99CC00, 0xFFCC00, 0xFF9900, 0xFF6600, 0x666699, 0x969696, 0x003366, 0x339966, 0x003300, 0x333300, 0x993300, 0x993366, 0x333399, 0x333333, /* Other entries to appease BIFF8/12 */\n0xFFFFFF, /* 0x40 icvForeground ?? */\n0x000000, /* 0x41 icvBackground ?? */\n0x000000, /* 0x42 icvFrame ?? */\n0x000000, /* 0x43 icv3D ?? */\n0x000000, /* 0x44 icv3DText ?? */\n0x000000, /* 0x45 icv3DHilite ?? */\n0x000000, /* 0x46 icv3DShadow ?? */\n0x000000, /* 0x47 icvHilite ?? */\n0x000000, /* 0x48 icvCtlText ?? */\n0x000000, /* 0x49 icvCtlScrl ?? */\n0x000000, /* 0x4A icvCtlInv ?? */\n0x000000, /* 0x4B icvCtlBody ?? */\n0x000000, /* 0x4C icvCtlFrame ?? */\n0x000000, /* 0x4D icvCtlFore ?? */\n0x000000, /* 0x4E icvCtlBack ?? */\n0x000000, /* 0x4F icvCtlNeutral */\n0x000000, /* 0x50 icvInfoBk ?? */\n0x000000 /* 0x51 icvInfoText ?? */]);\nvar XLSIcv = /*#__PURE__*/dup(_XLSIcv);\n\n/* [MS-XLSB] 2.5.97.2 */\nvar BErr = {\n /*::[*/0x00 /*::]*/: \"#NULL!\",\n /*::[*/0x07 /*::]*/: \"#DIV/0!\",\n /*::[*/0x0F /*::]*/: \"#VALUE!\",\n /*::[*/0x17 /*::]*/: \"#REF!\",\n /*::[*/0x1D /*::]*/: \"#NAME?\",\n /*::[*/0x24 /*::]*/: \"#NUM!\",\n /*::[*/0x2A /*::]*/: \"#N/A\",\n /*::[*/0x2B /*::]*/: \"#GETTING_DATA\",\n /*::[*/0xFF /*::]*/: \"#WTF?\"\n};\n//var RBErr = evert_num(BErr);\nvar RBErr = {\n \"#NULL!\": 0x00,\n \"#DIV/0!\": 0x07,\n \"#VALUE!\": 0x0F,\n \"#REF!\": 0x17,\n \"#NAME?\": 0x1D,\n \"#NUM!\": 0x24,\n \"#N/A\": 0x2A,\n \"#GETTING_DATA\": 0x2B,\n \"#WTF?\": 0xFF\n};\n\n/* Parts enumerated in OPC spec, MS-XLSB and MS-XLSX */\n/* 12.3 Part Summary */\n/* 14.2 Part Summary */\n/* [MS-XLSX] 2.1 Part Enumerations ; [MS-XLSB] 2.1.7 Part Enumeration */\nvar ct2type /*{[string]:string}*/ = {\n /* Workbook */\n \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml\": \"workbooks\",\n \"application/vnd.ms-excel.sheet.macroEnabled.main+xml\": \"workbooks\",\n \"application/vnd.ms-excel.sheet.binary.macroEnabled.main\": \"workbooks\",\n \"application/vnd.ms-excel.addin.macroEnabled.main+xml\": \"workbooks\",\n \"application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml\": \"workbooks\",\n /* Worksheet */\n \"application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml\": \"sheets\",\n \"application/vnd.ms-excel.worksheet\": \"sheets\",\n \"application/vnd.ms-excel.binIndexWs\": \"TODO\",\n /* Binary Index */\n\n /* Chartsheet */\n \"application/vnd.openxmlformats-officedocument.spreadsheetml.chartsheet+xml\": \"charts\",\n \"application/vnd.ms-excel.chartsheet\": \"charts\",\n /* Macrosheet */\n \"application/vnd.ms-excel.macrosheet+xml\": \"macros\",\n \"application/vnd.ms-excel.macrosheet\": \"macros\",\n \"application/vnd.ms-excel.intlmacrosheet\": \"TODO\",\n \"application/vnd.ms-excel.binIndexMs\": \"TODO\",\n /* Binary Index */\n\n /* Dialogsheet */\n \"application/vnd.openxmlformats-officedocument.spreadsheetml.dialogsheet+xml\": \"dialogs\",\n \"application/vnd.ms-excel.dialogsheet\": \"dialogs\",\n /* Shared Strings */\n \"application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml\": \"strs\",\n \"application/vnd.ms-excel.sharedStrings\": \"strs\",\n /* Styles */\n \"application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml\": \"styles\",\n \"application/vnd.ms-excel.styles\": \"styles\",\n /* File Properties */\n \"application/vnd.openxmlformats-package.core-properties+xml\": \"coreprops\",\n \"application/vnd.openxmlformats-officedocument.custom-properties+xml\": \"custprops\",\n \"application/vnd.openxmlformats-officedocument.extended-properties+xml\": \"extprops\",\n /* Custom Data Properties */\n \"application/vnd.openxmlformats-officedocument.customXmlProperties+xml\": \"TODO\",\n \"application/vnd.openxmlformats-officedocument.spreadsheetml.customProperty\": \"TODO\",\n /* Comments */\n \"application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml\": \"comments\",\n \"application/vnd.ms-excel.comments\": \"comments\",\n \"application/vnd.ms-excel.threadedcomments+xml\": \"threadedcomments\",\n \"application/vnd.ms-excel.person+xml\": \"people\",\n /* Metadata (Stock/Geography and Dynamic Array) */\n \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheetMetadata+xml\": \"metadata\",\n \"application/vnd.ms-excel.sheetMetadata\": \"metadata\",\n /* PivotTable */\n \"application/vnd.ms-excel.pivotTable\": \"TODO\",\n \"application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml\": \"TODO\",\n /* Chart Objects */\n \"application/vnd.openxmlformats-officedocument.drawingml.chart+xml\": \"TODO\",\n /* Chart Colors */\n \"application/vnd.ms-office.chartcolorstyle+xml\": \"TODO\",\n /* Chart Style */\n \"application/vnd.ms-office.chartstyle+xml\": \"TODO\",\n /* Chart Advanced */\n \"application/vnd.ms-office.chartex+xml\": \"TODO\",\n /* Calculation Chain */\n \"application/vnd.ms-excel.calcChain\": \"calcchains\",\n \"application/vnd.openxmlformats-officedocument.spreadsheetml.calcChain+xml\": \"calcchains\",\n /* Printer Settings */\n \"application/vnd.openxmlformats-officedocument.spreadsheetml.printerSettings\": \"TODO\",\n /* ActiveX */\n \"application/vnd.ms-office.activeX\": \"TODO\",\n \"application/vnd.ms-office.activeX+xml\": \"TODO\",\n /* Custom Toolbars */\n \"application/vnd.ms-excel.attachedToolbars\": \"TODO\",\n /* External Data Connections */\n \"application/vnd.ms-excel.connections\": \"TODO\",\n \"application/vnd.openxmlformats-officedocument.spreadsheetml.connections+xml\": \"TODO\",\n /* External Links */\n \"application/vnd.ms-excel.externalLink\": \"links\",\n \"application/vnd.openxmlformats-officedocument.spreadsheetml.externalLink+xml\": \"links\",\n /* PivotCache */\n \"application/vnd.ms-excel.pivotCacheDefinition\": \"TODO\",\n \"application/vnd.ms-excel.pivotCacheRecords\": \"TODO\",\n \"application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheDefinition+xml\": \"TODO\",\n \"application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheRecords+xml\": \"TODO\",\n /* Query Table */\n \"application/vnd.ms-excel.queryTable\": \"TODO\",\n \"application/vnd.openxmlformats-officedocument.spreadsheetml.queryTable+xml\": \"TODO\",\n /* Shared Workbook */\n \"application/vnd.ms-excel.userNames\": \"TODO\",\n \"application/vnd.ms-excel.revisionHeaders\": \"TODO\",\n \"application/vnd.ms-excel.revisionLog\": \"TODO\",\n \"application/vnd.openxmlformats-officedocument.spreadsheetml.revisionHeaders+xml\": \"TODO\",\n \"application/vnd.openxmlformats-officedocument.spreadsheetml.revisionLog+xml\": \"TODO\",\n \"application/vnd.openxmlformats-officedocument.spreadsheetml.userNames+xml\": \"TODO\",\n /* Single Cell Table */\n \"application/vnd.ms-excel.tableSingleCells\": \"TODO\",\n \"application/vnd.openxmlformats-officedocument.spreadsheetml.tableSingleCells+xml\": \"TODO\",\n /* Slicer */\n \"application/vnd.ms-excel.slicer\": \"TODO\",\n \"application/vnd.ms-excel.slicerCache\": \"TODO\",\n \"application/vnd.ms-excel.slicer+xml\": \"TODO\",\n \"application/vnd.ms-excel.slicerCache+xml\": \"TODO\",\n /* Sort Map */\n \"application/vnd.ms-excel.wsSortMap\": \"TODO\",\n /* Table */\n \"application/vnd.ms-excel.table\": \"TODO\",\n \"application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml\": \"TODO\",\n /* Themes */\n \"application/vnd.openxmlformats-officedocument.theme+xml\": \"themes\",\n /* Theme Override */\n \"application/vnd.openxmlformats-officedocument.themeOverride+xml\": \"TODO\",\n /* Timeline */\n \"application/vnd.ms-excel.Timeline+xml\": \"TODO\",\n /* verify */\n \"application/vnd.ms-excel.TimelineCache+xml\": \"TODO\",\n /* verify */\n\n /* VBA */\n \"application/vnd.ms-office.vbaProject\": \"vba\",\n \"application/vnd.ms-office.vbaProjectSignature\": \"TODO\",\n /* Volatile Dependencies */\n \"application/vnd.ms-office.volatileDependencies\": \"TODO\",\n \"application/vnd.openxmlformats-officedocument.spreadsheetml.volatileDependencies+xml\": \"TODO\",\n /* Control Properties */\n \"application/vnd.ms-excel.controlproperties+xml\": \"TODO\",\n /* Data Model */\n \"application/vnd.openxmlformats-officedocument.model+data\": \"TODO\",\n /* Survey */\n \"application/vnd.ms-excel.Survey+xml\": \"TODO\",\n /* Drawing */\n \"application/vnd.openxmlformats-officedocument.drawing+xml\": \"drawings\",\n \"application/vnd.openxmlformats-officedocument.drawingml.chartshapes+xml\": \"TODO\",\n \"application/vnd.openxmlformats-officedocument.drawingml.diagramColors+xml\": \"TODO\",\n \"application/vnd.openxmlformats-officedocument.drawingml.diagramData+xml\": \"TODO\",\n \"application/vnd.openxmlformats-officedocument.drawingml.diagramLayout+xml\": \"TODO\",\n \"application/vnd.openxmlformats-officedocument.drawingml.diagramStyle+xml\": \"TODO\",\n /* VML */\n \"application/vnd.openxmlformats-officedocument.vmlDrawing\": \"TODO\",\n \"application/vnd.openxmlformats-package.relationships+xml\": \"rels\",\n \"application/vnd.openxmlformats-officedocument.oleObject\": \"TODO\",\n /* Image */\n \"image/png\": \"TODO\",\n \"sheet\": \"js\"\n} /*:any*/;\nvar CT_LIST = {\n workbooks: {\n xlsx: \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml\",\n xlsm: \"application/vnd.ms-excel.sheet.macroEnabled.main+xml\",\n xlsb: \"application/vnd.ms-excel.sheet.binary.macroEnabled.main\",\n xlam: \"application/vnd.ms-excel.addin.macroEnabled.main+xml\",\n xltx: \"application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml\"\n },\n strs: {\n /* Shared Strings */\n xlsx: \"application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml\",\n xlsb: \"application/vnd.ms-excel.sharedStrings\"\n },\n comments: {\n /* Comments */\n xlsx: \"application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml\",\n xlsb: \"application/vnd.ms-excel.comments\"\n },\n sheets: {\n /* Worksheet */\n xlsx: \"application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml\",\n xlsb: \"application/vnd.ms-excel.worksheet\"\n },\n charts: {\n /* Chartsheet */\n xlsx: \"application/vnd.openxmlformats-officedocument.spreadsheetml.chartsheet+xml\",\n xlsb: \"application/vnd.ms-excel.chartsheet\"\n },\n dialogs: {\n /* Dialogsheet */\n xlsx: \"application/vnd.openxmlformats-officedocument.spreadsheetml.dialogsheet+xml\",\n xlsb: \"application/vnd.ms-excel.dialogsheet\"\n },\n macros: {\n /* Macrosheet (Excel 4.0 Macros) */\n xlsx: \"application/vnd.ms-excel.macrosheet+xml\",\n xlsb: \"application/vnd.ms-excel.macrosheet\"\n },\n metadata: {\n /* Metadata (Stock/Geography and Dynamic Array) */\n xlsx: \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheetMetadata+xml\",\n xlsb: \"application/vnd.ms-excel.sheetMetadata\"\n },\n styles: {\n /* Styles */\n xlsx: \"application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml\",\n xlsb: \"application/vnd.ms-excel.styles\"\n }\n};\nfunction new_ct() /*:any*/{\n return {\n workbooks: [],\n sheets: [],\n charts: [],\n dialogs: [],\n macros: [],\n rels: [],\n strs: [],\n comments: [],\n threadedcomments: [],\n links: [],\n coreprops: [],\n extprops: [],\n custprops: [],\n themes: [],\n styles: [],\n calcchains: [],\n vba: [],\n drawings: [],\n metadata: [],\n people: [],\n TODO: [],\n xmlns: \"\"\n } /*:any*/;\n}\nfunction parse_ct(data /*:?string*/) {\n var ct = new_ct();\n if (!data || !data.match) return ct;\n var ctext = {};\n (data.match(tagregex) || []).forEach(function (x) {\n var y = parsexmltag(x);\n switch (y[0].replace(nsregex, \"<\")) {\n case ' 0 ? ct.calcchains[0] : \"\";\n ct.sst = ct.strs.length > 0 ? ct.strs[0] : \"\";\n ct.style = ct.styles.length > 0 ? ct.styles[0] : \"\";\n ct.defaults = ctext;\n delete ct.calcchains;\n return ct;\n}\nfunction write_ct(ct, opts) /*:string*/{\n var type2ct /*{[string]:Array}*/ = evert_arr(ct2type);\n var o /*:Array*/ = [],\n v;\n o[o.length] = XML_HEADER;\n o[o.length] = writextag('Types', null, {\n 'xmlns': XMLNS.CT,\n 'xmlns:xsd': XMLNS.xsd,\n 'xmlns:xsi': XMLNS.xsi\n });\n o = o.concat([['xml', 'application/xml'], ['bin', 'application/vnd.ms-excel.sheet.binary.macroEnabled.main'], ['vml', 'application/vnd.openxmlformats-officedocument.vmlDrawing'], ['data', 'application/vnd.openxmlformats-officedocument.model+data'], /* from test files */\n ['bmp', 'image/bmp'], ['png', 'image/png'], ['gif', 'image/gif'], ['emf', 'image/x-emf'], ['wmf', 'image/x-wmf'], ['jpg', 'image/jpeg'], ['jpeg', 'image/jpeg'], ['tif', 'image/tiff'], ['tiff', 'image/tiff'], ['pdf', 'application/pdf'], ['rels', 'application/vnd.openxmlformats-package.relationships+xml']].map(function (x) {\n return writextag('Default', null, {\n 'Extension': x[0],\n 'ContentType': x[1]\n });\n }));\n\n /* only write first instance */\n var f1 = function (w) {\n if (ct[w] && ct[w].length > 0) {\n v = ct[w][0];\n o[o.length] = writextag('Override', null, {\n 'PartName': (v[0] == '/' ? \"\" : \"/\") + v,\n 'ContentType': CT_LIST[w][opts.bookType] || CT_LIST[w]['xlsx']\n });\n }\n };\n\n /* book type-specific */\n var f2 = function (w) {\n (ct[w] || []).forEach(function (v) {\n o[o.length] = writextag('Override', null, {\n 'PartName': (v[0] == '/' ? \"\" : \"/\") + v,\n 'ContentType': CT_LIST[w][opts.bookType] || CT_LIST[w]['xlsx']\n });\n });\n };\n\n /* standard type */\n var f3 = function (t) {\n (ct[t] || []).forEach(function (v) {\n o[o.length] = writextag('Override', null, {\n 'PartName': (v[0] == '/' ? \"\" : \"/\") + v,\n 'ContentType': type2ct[t][0]\n });\n });\n };\n f1('workbooks');\n f2('sheets');\n f2('charts');\n f3('themes');\n ['strs', 'styles'].forEach(f1);\n ['coreprops', 'extprops', 'custprops'].forEach(f3);\n f3('vba');\n f3('comments');\n f3('threadedcomments');\n f3('drawings');\n f2('metadata');\n f3('people');\n if (o.length > 2) {\n o[o.length] = '';\n o[1] = o[1].replace(\"/>\", \">\");\n }\n return o.join(\"\");\n}\n/* 9.3 Relationships */\nvar RELS = {\n WB: \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument\",\n SHEET: \"http://sheetjs.openxmlformats.org/officeDocument/2006/relationships/officeDocument\",\n HLINK: \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink\",\n VML: \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing\",\n XPATH: \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/externalLinkPath\",\n XMISS: \"http://schemas.microsoft.com/office/2006/relationships/xlExternalLinkPath/xlPathMissing\",\n XLINK: \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/externalLink\",\n CXML: \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml\",\n CXMLP: \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXmlProps\",\n CMNT: \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments\",\n CORE_PROPS: \"http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties\",\n EXT_PROPS: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties',\n CUST_PROPS: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties',\n SST: \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings\",\n STY: \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles\",\n THEME: \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme\",\n CHART: \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart\",\n CHARTEX: \"http://schemas.microsoft.com/office/2014/relationships/chartEx\",\n CS: \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/chartsheet\",\n WS: [\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet\", \"http://purl.oclc.org/ooxml/officeDocument/relationships/worksheet\"],\n DS: \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/dialogsheet\",\n MS: \"http://schemas.microsoft.com/office/2006/relationships/xlMacrosheet\",\n IMG: \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image\",\n DRAW: \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing\",\n XLMETA: \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/sheetMetadata\",\n TCMNT: \"http://schemas.microsoft.com/office/2017/10/relationships/threadedComment\",\n PEOPLE: \"http://schemas.microsoft.com/office/2017/10/relationships/person\",\n VBA: \"http://schemas.microsoft.com/office/2006/relationships/vbaProject\"\n} /*:any*/;\n\n/* 9.3.3 Representing Relationships */\nfunction get_rels_path(file /*:string*/) /*:string*/{\n var n = file.lastIndexOf(\"/\");\n return file.slice(0, n + 1) + '_rels/' + file.slice(n + 1) + \".rels\";\n}\nfunction parse_rels(data /*:?string*/, currentFilePath /*:string*/) {\n var rels = {\n \"!id\": {}\n };\n if (!data) return rels;\n if (currentFilePath.charAt(0) !== '/') {\n currentFilePath = '/' + currentFilePath;\n }\n var hash = {};\n (data.match(tagregex) || []).forEach(function (x) {\n var y = parsexmltag(x);\n /* 9.3.2.2 OPC_Relationships */\n if (y[0] === ' 2) {\n o[o.length] = '';\n o[1] = o[1].replace(\"/>\", \">\");\n }\n return o.join(\"\");\n}\nfunction add_rels(rels, rId /*:number*/, f, type, relobj, targetmode /*:?string*/) /*:number*/{\n if (!relobj) relobj = {};\n if (!rels['!id']) rels['!id'] = {};\n if (!rels['!idx']) rels['!idx'] = 1;\n if (rId < 0) for (rId = rels['!idx']; rels['!id']['rId' + rId]; ++rId) {/* empty */}\n rels['!idx'] = rId + 1;\n relobj.Id = 'rId' + rId;\n relobj.Type = type;\n relobj.Target = f;\n if (targetmode) relobj.TargetMode = targetmode;else if ([RELS.HLINK, RELS.XPATH, RELS.XMISS].indexOf(relobj.Type) > -1) relobj.TargetMode = \"External\";\n if (rels['!id'][relobj.Id]) throw new Error(\"Cannot rewrite rId \" + rId);\n rels['!id'][relobj.Id] = relobj;\n rels[('/' + relobj.Target).replace(\"//\", \"/\")] = relobj;\n return rId;\n}\n/* Open Document Format for Office Applications (OpenDocument) Version 1.2 */\n/* Part 3 Section 4 Manifest File */\nvar CT_ODS = \"application/vnd.oasis.opendocument.spreadsheet\";\nfunction parse_manifest(d, opts) {\n var str = xlml_normalize(d);\n var Rn;\n var FEtag;\n while (Rn = xlmlregex.exec(str)) switch (Rn[3]) {\n case 'manifest':\n break;\n // 4.2 \n case 'file-entry':\n // 4.3 \n FEtag = parsexmltag(Rn[0], false);\n if (FEtag.path == '/' && FEtag.type !== CT_ODS) throw new Error(\"This OpenDocument is not a spreadsheet\");\n break;\n case 'encryption-data': // 4.4 \n case 'algorithm': // 4.5 \n case 'start-key-generation': // 4.6 \n case 'key-derivation':\n // 4.7 \n throw new Error(\"Unsupported ODS Encryption\");\n default:\n if (opts && opts.WTF) throw Rn;\n }\n}\nfunction write_manifest(manifest /*:Array >*/) /*:string*/{\n var o = [XML_HEADER];\n o.push('\\n');\n o.push(' \\n');\n for (var i = 0; i < manifest.length; ++i) o.push(' \\n');\n o.push('');\n return o.join(\"\");\n}\n\n/* Part 3 Section 6 Metadata Manifest File */\nfunction write_rdf_type(file /*:string*/, res /*:string*/, tag /*:?string*/) {\n return [' \\n', ' \\n', ' \\n'].join(\"\");\n}\nfunction write_rdf_has(base /*:string*/, file /*:string*/) {\n return [' \\n', ' \\n', ' \\n'].join(\"\");\n}\nfunction write_rdf(rdf) {\n var o = [XML_HEADER];\n o.push('\\n');\n for (var i = 0; i != rdf.length; ++i) {\n o.push(write_rdf_type(rdf[i][0], rdf[i][1]));\n o.push(write_rdf_has(\"\", rdf[i][0]));\n }\n o.push(write_rdf_type(\"\", \"Document\", \"pkg\"));\n o.push('');\n return o.join(\"\");\n}\n/* TODO: pull properties */\nfunction write_meta_ods(/*:: wb: Workbook, opts: any*/\n) /*:string*/{\n return 'Sheet' + 'JS ' + XLSX.version + '';\n}\n\n/* ECMA-376 Part II 11.1 Core Properties Part */\n/* [MS-OSHARED] 2.3.3.2.[1-2].1 (PIDSI/PIDDSI) */\nvar CORE_PROPS /*:Array >*/ = [[\"cp:category\", \"Category\"], [\"cp:contentStatus\", \"ContentStatus\"], [\"cp:keywords\", \"Keywords\"], [\"cp:lastModifiedBy\", \"LastAuthor\"], [\"cp:lastPrinted\", \"LastPrinted\"], [\"cp:revision\", \"RevNumber\"], [\"cp:version\", \"Version\"], [\"dc:creator\", \"Author\"], [\"dc:description\", \"Comments\"], [\"dc:identifier\", \"Identifier\"], [\"dc:language\", \"Language\"], [\"dc:subject\", \"Subject\"], [\"dc:title\", \"Title\"], [\"dcterms:created\", \"CreatedDate\", 'date'], [\"dcterms:modified\", \"ModifiedDate\", 'date']];\nvar CORE_PROPS_REGEX /*:Array*/ = /*#__PURE__*/function () {\n var r = new Array(CORE_PROPS.length);\n for (var i = 0; i < CORE_PROPS.length; ++i) {\n var f = CORE_PROPS[i];\n var g = \"(?:\" + f[0].slice(0, f[0].indexOf(\":\")) + \":)\" + f[0].slice(f[0].indexOf(\":\") + 1);\n r[i] = new RegExp(\"<\" + g + \"[^>]*>([\\\\s\\\\S]*?)<\\/\" + g + \">\");\n }\n return r;\n}();\nfunction parse_core_props(data) {\n var p = {};\n data = utf8read(data);\n for (var i = 0; i < CORE_PROPS.length; ++i) {\n var f = CORE_PROPS[i],\n cur = data.match(CORE_PROPS_REGEX[i]);\n if (cur != null && cur.length > 0) p[f[1]] = unescapexml(cur[1]);\n if (f[2] === 'date' && p[f[1]]) p[f[1]] = parseDate(p[f[1]]);\n }\n return p;\n}\nfunction cp_doit(f, g, h, o, p) {\n if (p[f] != null || g == null || g === \"\") return;\n p[f] = g;\n g = escapexml(g);\n o[o.length] = h ? writextag(f, g, h) : writetag(f, g);\n}\nfunction write_core_props(cp, _opts) {\n var opts = _opts || {};\n var o = [XML_HEADER, writextag('cp:coreProperties', null, {\n //'xmlns': XMLNS.CORE_PROPS,\n 'xmlns:cp': XMLNS.CORE_PROPS,\n 'xmlns:dc': XMLNS.dc,\n 'xmlns:dcterms': XMLNS.dcterms,\n 'xmlns:dcmitype': XMLNS.dcmitype,\n 'xmlns:xsi': XMLNS.xsi\n })],\n p = {};\n if (!cp && !opts.Props) return o.join(\"\");\n if (cp) {\n if (cp.CreatedDate != null) cp_doit(\"dcterms:created\", typeof cp.CreatedDate === \"string\" ? cp.CreatedDate : write_w3cdtf(cp.CreatedDate, opts.WTF), {\n \"xsi:type\": \"dcterms:W3CDTF\"\n }, o, p);\n if (cp.ModifiedDate != null) cp_doit(\"dcterms:modified\", typeof cp.ModifiedDate === \"string\" ? cp.ModifiedDate : write_w3cdtf(cp.ModifiedDate, opts.WTF), {\n \"xsi:type\": \"dcterms:W3CDTF\"\n }, o, p);\n }\n for (var i = 0; i != CORE_PROPS.length; ++i) {\n var f = CORE_PROPS[i];\n var v = opts.Props && opts.Props[f[1]] != null ? opts.Props[f[1]] : cp ? cp[f[1]] : null;\n if (v === true) v = \"1\";else if (v === false) v = \"0\";else if (typeof v == \"number\") v = String(v);\n if (v != null) cp_doit(f[0], v, null, o, p);\n }\n if (o.length > 2) {\n o[o.length] = '';\n o[1] = o[1].replace(\"/>\", \">\");\n }\n return o.join(\"\");\n}\n/* 15.2.12.3 Extended File Properties Part */\n/* [MS-OSHARED] 2.3.3.2.[1-2].1 (PIDSI/PIDDSI) */\nvar EXT_PROPS /*:Array >*/ = [[\"Application\", \"Application\", \"string\"], [\"AppVersion\", \"AppVersion\", \"string\"], [\"Company\", \"Company\", \"string\"], [\"DocSecurity\", \"DocSecurity\", \"string\"], [\"Manager\", \"Manager\", \"string\"], [\"HyperlinksChanged\", \"HyperlinksChanged\", \"bool\"], [\"SharedDoc\", \"SharedDoc\", \"bool\"], [\"LinksUpToDate\", \"LinksUpToDate\", \"bool\"], [\"ScaleCrop\", \"ScaleCrop\", \"bool\"], [\"HeadingPairs\", \"HeadingPairs\", \"raw\"], [\"TitlesOfParts\", \"TitlesOfParts\", \"raw\"]];\nvar PseudoPropsPairs = [\"Worksheets\", \"SheetNames\", \"NamedRanges\", \"DefinedNames\", \"Chartsheets\", \"ChartNames\"];\nfunction load_props_pairs(HP /*:string|Array>*/, TOP, props, opts) {\n var v = [];\n if (typeof HP == \"string\") v = parseVector(HP, opts);else for (var j = 0; j < HP.length; ++j) v = v.concat(HP[j].map(function (hp) {\n return {\n v: hp\n };\n }));\n var parts = typeof TOP == \"string\" ? parseVector(TOP, opts).map(function (x) {\n return x.v;\n }) : TOP;\n var idx = 0,\n len = 0;\n if (parts.length > 0) for (var i = 0; i !== v.length; i += 2) {\n len = +v[i + 1].v;\n switch (v[i].v) {\n case \"Worksheets\":\n case \"工作表\":\n case \"Листы\":\n case \"أوراق العمل\":\n case \"ワークシート\":\n case \"גליונות עבודה\":\n case \"Arbeitsblätter\":\n case \"Çalışma Sayfaları\":\n case \"Feuilles de calcul\":\n case \"Fogli di lavoro\":\n case \"Folhas de cálculo\":\n case \"Planilhas\":\n case \"Regneark\":\n case \"Hojas de cálculo\":\n case \"Werkbladen\":\n props.Worksheets = len;\n props.SheetNames = parts.slice(idx, idx + len);\n break;\n case \"Named Ranges\":\n case \"Rangos con nombre\":\n case \"名前付き一覧\":\n case \"Benannte Bereiche\":\n case \"Navngivne områder\":\n props.NamedRanges = len;\n props.DefinedNames = parts.slice(idx, idx + len);\n break;\n case \"Charts\":\n case \"Diagramme\":\n props.Chartsheets = len;\n props.ChartNames = parts.slice(idx, idx + len);\n break;\n }\n idx += len;\n }\n}\nfunction parse_ext_props(data, p, opts) {\n var q = {};\n if (!p) p = {};\n data = utf8read(data);\n EXT_PROPS.forEach(function (f) {\n var xml = (data.match(matchtag(f[0])) || [])[1];\n switch (f[2]) {\n case \"string\":\n if (xml) p[f[1]] = unescapexml(xml);\n break;\n case \"bool\":\n p[f[1]] = xml === \"true\";\n break;\n case \"raw\":\n var cur = data.match(new RegExp(\"<\" + f[0] + \"[^>]*>([\\\\s\\\\S]*?)<\\/\" + f[0] + \">\"));\n if (cur && cur.length > 0) q[f[1]] = cur[1];\n break;\n }\n });\n if (q.HeadingPairs && q.TitlesOfParts) load_props_pairs(q.HeadingPairs, q.TitlesOfParts, p, opts);\n return p;\n}\nfunction write_ext_props(cp /*::, opts*/) /*:string*/{\n var o /*:Array*/ = [],\n W = writextag;\n if (!cp) cp = {};\n cp.Application = \"SheetJS\";\n o[o.length] = XML_HEADER;\n o[o.length] = writextag('Properties', null, {\n 'xmlns': XMLNS.EXT_PROPS,\n 'xmlns:vt': XMLNS.vt\n });\n EXT_PROPS.forEach(function (f) {\n if (cp[f[1]] === undefined) return;\n var v;\n switch (f[2]) {\n case 'string':\n v = escapexml(String(cp[f[1]]));\n break;\n case 'bool':\n v = cp[f[1]] ? 'true' : 'false';\n break;\n }\n if (v !== undefined) o[o.length] = W(f[0], v);\n });\n\n /* TODO: HeadingPairs, TitlesOfParts */\n o[o.length] = W('HeadingPairs', W('vt:vector', W('vt:variant', 'Worksheets') + W('vt:variant', W('vt:i4', String(cp.Worksheets))), {\n size: 2,\n baseType: \"variant\"\n }));\n o[o.length] = W('TitlesOfParts', W('vt:vector', cp.SheetNames.map(function (s) {\n return \"\" + escapexml(s) + \"\";\n }).join(\"\"), {\n size: cp.Worksheets,\n baseType: \"lpstr\"\n }));\n if (o.length > 2) {\n o[o.length] = '';\n o[1] = o[1].replace(\"/>\", \">\");\n }\n return o.join(\"\");\n}\n/* 15.2.12.2 Custom File Properties Part */\nvar custregex = /<[^>]+>[^<]*/g;\nfunction parse_cust_props(data /*:string*/, opts) {\n var p = {},\n name = \"\";\n var m = data.match(custregex);\n if (m) for (var i = 0; i != m.length; ++i) {\n var x = m[i],\n y = parsexmltag(x);\n switch (y[0]) {\n case '':\n name = null;\n break;\n default:\n if (x.indexOf('');\n var type = toks[0].slice(4),\n text = toks[1];\n /* 22.4.2.32 (CT_Variant). Omit the binary types from 22.4 (Variant Types) */\n switch (type) {\n case 'lpstr':\n case 'bstr':\n case 'lpwstr':\n p[name] = unescapexml(text);\n break;\n case 'bool':\n p[name] = parsexmlbool(text);\n break;\n case 'i1':\n case 'i2':\n case 'i4':\n case 'i8':\n case 'int':\n case 'uint':\n p[name] = parseInt(text, 10);\n break;\n case 'r4':\n case 'r8':\n case 'decimal':\n p[name] = parseFloat(text);\n break;\n case 'filetime':\n case 'date':\n p[name] = parseDate(text);\n break;\n case 'cy':\n case 'error':\n p[name] = unescapexml(text);\n break;\n default:\n if (type.slice(-1) == '/') break;\n if (opts.WTF && typeof console !== 'undefined') console.warn('Unexpected', x, type, toks);\n }\n } else if (x.slice(0, 2) === \" 2) {\n o[o.length] = '';\n o[1] = o[1].replace(\"/>\", \">\");\n }\n return o.join(\"\");\n}\n/* Common Name -> XLML Name */\nvar XLMLDocPropsMap = {\n Title: 'Title',\n Subject: 'Subject',\n Author: 'Author',\n Keywords: 'Keywords',\n Comments: 'Description',\n LastAuthor: 'LastAuthor',\n RevNumber: 'Revision',\n Application: 'AppName',\n /* TotalTime: 'TotalTime', */\n LastPrinted: 'LastPrinted',\n CreatedDate: 'Created',\n ModifiedDate: 'LastSaved',\n /* Pages */\n /* Words */\n /* Characters */\n Category: 'Category',\n /* PresentationFormat */\n Manager: 'Manager',\n Company: 'Company',\n /* Guid */\n /* HyperlinkBase */\n /* Bytes */\n /* Lines */\n /* Paragraphs */\n /* CharactersWithSpaces */\n AppVersion: 'Version',\n ContentStatus: 'ContentStatus',\n /* NOTE: missing from schema */\n Identifier: 'Identifier',\n /* NOTE: missing from schema */\n Language: 'Language' /* NOTE: missing from schema */\n};\nvar evert_XLMLDPM;\nfunction xlml_set_prop(Props, tag /*:string*/, val) {\n if (!evert_XLMLDPM) evert_XLMLDPM = evert(XLMLDocPropsMap);\n tag = evert_XLMLDPM[tag] || tag;\n Props[tag] = val;\n}\nfunction xlml_write_docprops(Props, opts) {\n var o /*:Array*/ = [];\n keys(XLMLDocPropsMap).map(function (m) {\n for (var i = 0; i < CORE_PROPS.length; ++i) if (CORE_PROPS[i][1] == m) return CORE_PROPS[i];\n for (i = 0; i < EXT_PROPS.length; ++i) if (EXT_PROPS[i][1] == m) return EXT_PROPS[i];\n throw m;\n }).forEach(function (p) {\n if (Props[p[1]] == null) return;\n var m = opts && opts.Props && opts.Props[p[1]] != null ? opts.Props[p[1]] : Props[p[1]];\n switch (p[2]) {\n case 'date':\n m = new Date(m).toISOString().replace(/\\.\\d*Z/, \"Z\");\n break;\n }\n if (typeof m == 'number') m = String(m);else if (m === true || m === false) {\n m = m ? \"1\" : \"0\";\n } else if (m instanceof Date) m = new Date(m).toISOString().replace(/\\.\\d*Z/, \"\");\n o.push(writetag(XLMLDocPropsMap[p[1]] || p[1], m));\n });\n return writextag('DocumentProperties', o.join(\"\"), {\n xmlns: XLMLNS.o\n });\n}\nfunction xlml_write_custprops(Props, Custprops /*::, opts*/) {\n var BLACKLIST = [\"Worksheets\", \"SheetNames\"];\n var T = 'CustomDocumentProperties';\n var o /*:Array*/ = [];\n if (Props) keys(Props).forEach(function (k) {\n /*:: if(!Props) return; */\n if (!Object.prototype.hasOwnProperty.call(Props, k)) return;\n for (var i = 0; i < CORE_PROPS.length; ++i) if (k == CORE_PROPS[i][1]) return;\n for (i = 0; i < EXT_PROPS.length; ++i) if (k == EXT_PROPS[i][1]) return;\n for (i = 0; i < BLACKLIST.length; ++i) if (k == BLACKLIST[i]) return;\n var m = Props[k];\n var t = \"string\";\n if (typeof m == 'number') {\n t = \"float\";\n m = String(m);\n } else if (m === true || m === false) {\n t = \"boolean\";\n m = m ? \"1\" : \"0\";\n } else m = String(m);\n o.push(writextag(escapexmltag(k), m, {\n \"dt:dt\": t\n }));\n });\n if (Custprops) keys(Custprops).forEach(function (k) {\n /*:: if(!Custprops) return; */\n if (!Object.prototype.hasOwnProperty.call(Custprops, k)) return;\n if (Props && Object.prototype.hasOwnProperty.call(Props, k)) return;\n var m = Custprops[k];\n var t = \"string\";\n if (typeof m == 'number') {\n t = \"float\";\n m = String(m);\n } else if (m === true || m === false) {\n t = \"boolean\";\n m = m ? \"1\" : \"0\";\n } else if (m instanceof Date) {\n t = \"dateTime.tz\";\n m = m.toISOString();\n } else m = String(m);\n o.push(writextag(escapexmltag(k), m, {\n \"dt:dt\": t\n }));\n });\n return '<' + T + ' xmlns=\"' + XLMLNS.o + '\">' + o.join(\"\") + '';\n}\n/* [MS-DTYP] 2.3.3 FILETIME */\n/* [MS-OLEDS] 2.1.3 FILETIME (Packet Version) */\n/* [MS-OLEPS] 2.8 FILETIME (Packet Version) */\nfunction parse_FILETIME(blob) {\n var dwLowDateTime = blob.read_shift(4),\n dwHighDateTime = blob.read_shift(4);\n return new Date((dwHighDateTime / 1e7 * Math.pow(2, 32) + dwLowDateTime / 1e7 - 11644473600) * 1000).toISOString().replace(/\\.000/, \"\");\n}\nfunction write_FILETIME(time /*:string|Date*/) {\n var date = typeof time == \"string\" ? new Date(Date.parse(time)) : time;\n var t = date.getTime() / 1000 + 11644473600;\n var l = t % Math.pow(2, 32),\n h = (t - l) / Math.pow(2, 32);\n l *= 1e7;\n h *= 1e7;\n var w = l / Math.pow(2, 32) | 0;\n if (w > 0) {\n l = l % Math.pow(2, 32);\n h += w;\n }\n var o = new_buf(8);\n o.write_shift(4, l);\n o.write_shift(4, h);\n return o;\n}\n\n/* [MS-OSHARED] 2.3.3.1.4 Lpstr */\nfunction parse_lpstr(blob, type, pad /*:?number*/) {\n var start = blob.l;\n var str = blob.read_shift(0, 'lpstr-cp');\n if (pad) while (blob.l - start & 3) ++blob.l;\n return str;\n}\n\n/* [MS-OSHARED] 2.3.3.1.6 Lpwstr */\nfunction parse_lpwstr(blob, type, pad) {\n var str = blob.read_shift(0, 'lpwstr');\n if (pad) blob.l += 4 - (str.length + 1 & 3) & 3;\n return str;\n}\n\n/* [MS-OSHARED] 2.3.3.1.11 VtString */\n/* [MS-OSHARED] 2.3.3.1.12 VtUnalignedString */\nfunction parse_VtStringBase(blob, stringType, pad) {\n if (stringType === 0x1F /*VT_LPWSTR*/) return parse_lpwstr(blob);\n return parse_lpstr(blob, stringType, pad);\n}\nfunction parse_VtString(blob, t /*:number*/, pad /*:?boolean*/) {\n return parse_VtStringBase(blob, t, pad === false ? 0 : 4);\n}\nfunction parse_VtUnalignedString(blob, t /*:number*/) {\n if (!t) throw new Error(\"VtUnalignedString must have positive length\");\n return parse_VtStringBase(blob, t, 0);\n}\n\n/* [MS-OSHARED] 2.3.3.1.7 VtVecLpwstrValue */\nfunction parse_VtVecLpwstrValue(blob) /*:Array*/{\n var length = blob.read_shift(4);\n var ret /*:Array*/ = [];\n for (var i = 0; i != length; ++i) {\n var start = blob.l;\n ret[i] = blob.read_shift(0, 'lpwstr').replace(chr0, '');\n if (blob.l - start & 0x02) blob.l += 2;\n }\n return ret;\n}\n\n/* [MS-OSHARED] 2.3.3.1.9 VtVecUnalignedLpstrValue */\nfunction parse_VtVecUnalignedLpstrValue(blob) /*:Array*/{\n var length = blob.read_shift(4);\n var ret /*:Array*/ = [];\n for (var i = 0; i != length; ++i) ret[i] = blob.read_shift(0, 'lpstr-cp').replace(chr0, '');\n return ret;\n}\n\n/* [MS-OSHARED] 2.3.3.1.13 VtHeadingPair */\nfunction parse_VtHeadingPair(blob) {\n var start = blob.l;\n var headingString = parse_TypedPropertyValue(blob, VT_USTR);\n if (blob[blob.l] == 0x00 && blob[blob.l + 1] == 0x00 && blob.l - start & 0x02) blob.l += 2;\n var headerParts = parse_TypedPropertyValue(blob, VT_I4);\n return [headingString, headerParts];\n}\n\n/* [MS-OSHARED] 2.3.3.1.14 VtVecHeadingPairValue */\nfunction parse_VtVecHeadingPairValue(blob) {\n var cElements = blob.read_shift(4);\n var out = [];\n for (var i = 0; i < cElements / 2; ++i) out.push(parse_VtHeadingPair(blob));\n return out;\n}\n\n/* [MS-OLEPS] 2.18.1 Dictionary (uses 2.17, 2.16) */\nfunction parse_dictionary(blob, CodePage) {\n var cnt = blob.read_shift(4);\n var dict /*:{[number]:string}*/ = {} /*:any*/;\n for (var j = 0; j != cnt; ++j) {\n var pid = blob.read_shift(4);\n var len = blob.read_shift(4);\n dict[pid] = blob.read_shift(len, CodePage === 0x4B0 ? 'utf16le' : 'utf8').replace(chr0, '').replace(chr1, '!');\n if (CodePage === 0x4B0 && len % 2) blob.l += 2;\n }\n if (blob.l & 3) blob.l = blob.l >> 2 + 1 << 2;\n return dict;\n}\n\n/* [MS-OLEPS] 2.9 BLOB */\nfunction parse_BLOB(blob) {\n var size = blob.read_shift(4);\n var bytes = blob.slice(blob.l, blob.l + size);\n blob.l += size;\n if ((size & 3) > 0) blob.l += 4 - (size & 3) & 3;\n return bytes;\n}\n\n/* [MS-OLEPS] 2.11 ClipboardData */\nfunction parse_ClipboardData(blob) {\n // TODO\n var o = {};\n o.Size = blob.read_shift(4);\n //o.Format = blob.read_shift(4);\n blob.l += o.Size + 3 - (o.Size - 1) % 4;\n return o;\n}\n\n/* [MS-OLEPS] 2.15 TypedPropertyValue */\nfunction parse_TypedPropertyValue(blob, type /*:number*/, _opts) /*:any*/{\n var t = blob.read_shift(2),\n ret,\n opts = _opts || {};\n blob.l += 2;\n if (type !== VT_VARIANT) if (t !== type && VT_CUSTOM.indexOf(type) === -1 && !((type & 0xFFFE) == 0x101E && (t & 0xFFFE) == 0x101E)) throw new Error('Expected type ' + type + ' saw ' + t);\n switch (type === VT_VARIANT ? t : type) {\n case 0x02 /*VT_I2*/:\n ret = blob.read_shift(2, 'i');\n if (!opts.raw) blob.l += 2;\n return ret;\n case 0x03 /*VT_I4*/:\n ret = blob.read_shift(4, 'i');\n return ret;\n case 0x0B /*VT_BOOL*/:\n return blob.read_shift(4) !== 0x0;\n case 0x13 /*VT_UI4*/:\n ret = blob.read_shift(4);\n return ret;\n case 0x1E /*VT_LPSTR*/:\n return parse_lpstr(blob, t, 4).replace(chr0, '');\n case 0x1F /*VT_LPWSTR*/:\n return parse_lpwstr(blob);\n case 0x40 /*VT_FILETIME*/:\n return parse_FILETIME(blob);\n case 0x41 /*VT_BLOB*/:\n return parse_BLOB(blob);\n case 0x47 /*VT_CF*/:\n return parse_ClipboardData(blob);\n case 0x50 /*VT_STRING*/:\n return parse_VtString(blob, t, !opts.raw).replace(chr0, '');\n case 0x51 /*VT_USTR*/:\n return parse_VtUnalignedString(blob, t /*, 4*/).replace(chr0, '');\n case 0x100C /*VT_VECTOR|VT_VARIANT*/:\n return parse_VtVecHeadingPairValue(blob);\n case 0x101E /*VT_VECTOR|VT_LPSTR*/:\n case 0x101F /*VT_VECTOR|VT_LPWSTR*/:\n return t == 0x101F ? parse_VtVecLpwstrValue(blob) : parse_VtVecUnalignedLpstrValue(blob);\n default:\n throw new Error(\"TypedPropertyValue unrecognized type \" + type + \" \" + t);\n }\n}\nfunction write_TypedPropertyValue(type /*:number*/, value) {\n var o = new_buf(4),\n p = new_buf(4);\n o.write_shift(4, type == 0x50 ? 0x1F : type);\n switch (type) {\n case 0x03 /*VT_I4*/:\n p.write_shift(-4, value);\n break;\n case 0x05 /*VT_I4*/:\n p = new_buf(8);\n p.write_shift(8, value, 'f');\n break;\n case 0x0B /*VT_BOOL*/:\n p.write_shift(4, value ? 0x01 : 0x00);\n break;\n case 0x40 /*VT_FILETIME*/:\n /*:: if(typeof value !== \"string\" && !(value instanceof Date)) throw \"unreachable\"; */p = write_FILETIME(value);\n break;\n case 0x1F /*VT_LPWSTR*/:\n case 0x50 /*VT_STRING*/:\n /*:: if(typeof value !== \"string\") throw \"unreachable\"; */\n p = new_buf(4 + 2 * (value.length + 1) + (value.length % 2 ? 0 : 2));\n p.write_shift(4, value.length + 1);\n p.write_shift(0, value, \"dbcs\");\n while (p.l != p.length) p.write_shift(1, 0);\n break;\n default:\n throw new Error(\"TypedPropertyValue unrecognized type \" + type + \" \" + value);\n }\n return bconcat([o, p]);\n}\n\n/* [MS-OLEPS] 2.20 PropertySet */\nfunction parse_PropertySet(blob, PIDSI) {\n var start_addr = blob.l;\n var size = blob.read_shift(4);\n var NumProps = blob.read_shift(4);\n var Props = [],\n i = 0;\n var CodePage = 0;\n var Dictionary = -1,\n DictObj /*:{[number]:string}*/ = {} /*:any*/;\n for (i = 0; i != NumProps; ++i) {\n var PropID = blob.read_shift(4);\n var Offset = blob.read_shift(4);\n Props[i] = [PropID, Offset + start_addr];\n }\n Props.sort(function (x, y) {\n return x[1] - y[1];\n });\n var PropH = {};\n for (i = 0; i != NumProps; ++i) {\n if (blob.l !== Props[i][1]) {\n var fail = true;\n if (i > 0 && PIDSI) switch (PIDSI[Props[i - 1][0]].t) {\n case 0x02 /*VT_I2*/:\n if (blob.l + 2 === Props[i][1]) {\n blob.l += 2;\n fail = false;\n }\n break;\n case 0x50 /*VT_STRING*/:\n if (blob.l <= Props[i][1]) {\n blob.l = Props[i][1];\n fail = false;\n }\n break;\n case 0x100C /*VT_VECTOR|VT_VARIANT*/:\n if (blob.l <= Props[i][1]) {\n blob.l = Props[i][1];\n fail = false;\n }\n break;\n }\n if ((!PIDSI || i == 0) && blob.l <= Props[i][1]) {\n fail = false;\n blob.l = Props[i][1];\n }\n if (fail) throw new Error(\"Read Error: Expected address \" + Props[i][1] + ' at ' + blob.l + ' :' + i);\n }\n if (PIDSI) {\n var piddsi = PIDSI[Props[i][0]];\n PropH[piddsi.n] = parse_TypedPropertyValue(blob, piddsi.t, {\n raw: true\n });\n if (piddsi.p === 'version') PropH[piddsi.n] = String(PropH[piddsi.n] >> 16) + \".\" + (\"0000\" + String(PropH[piddsi.n] & 0xFFFF)).slice(-4);\n if (piddsi.n == \"CodePage\") switch (PropH[piddsi.n]) {\n case 0:\n PropH[piddsi.n] = 1252;\n /* falls through */\n case 874:\n case 932:\n case 936:\n case 949:\n case 950:\n case 1250:\n case 1251:\n case 1253:\n case 1254:\n case 1255:\n case 1256:\n case 1257:\n case 1258:\n case 10000:\n case 1200:\n case 1201:\n case 1252:\n case 65000:\n case -536:\n case 65001:\n case -535:\n set_cp(CodePage = PropH[piddsi.n] >>> 0 & 0xFFFF);\n break;\n default:\n throw new Error(\"Unsupported CodePage: \" + PropH[piddsi.n]);\n }\n } else {\n if (Props[i][0] === 0x1) {\n CodePage = PropH.CodePage = parse_TypedPropertyValue(blob, VT_I2) /*:number*/;\n set_cp(CodePage);\n if (Dictionary !== -1) {\n var oldpos = blob.l;\n blob.l = Props[Dictionary][1];\n DictObj = parse_dictionary(blob, CodePage);\n blob.l = oldpos;\n }\n } else if (Props[i][0] === 0) {\n if (CodePage === 0) {\n Dictionary = i;\n blob.l = Props[i + 1][1];\n continue;\n }\n DictObj = parse_dictionary(blob, CodePage);\n } else {\n var name = DictObj[Props[i][0]];\n var val;\n /* [MS-OSHARED] 2.3.3.2.3.1.2 + PROPVARIANT */\n switch (blob[blob.l]) {\n case 0x41 /*VT_BLOB*/:\n blob.l += 4;\n val = parse_BLOB(blob);\n break;\n case 0x1E /*VT_LPSTR*/:\n blob.l += 4;\n val = parse_VtString(blob, blob[blob.l - 4]).replace(/\\u0000+$/, \"\");\n break;\n case 0x1F /*VT_LPWSTR*/:\n blob.l += 4;\n val = parse_VtString(blob, blob[blob.l - 4]).replace(/\\u0000+$/, \"\");\n break;\n case 0x03 /*VT_I4*/:\n blob.l += 4;\n val = blob.read_shift(4, 'i');\n break;\n case 0x13 /*VT_UI4*/:\n blob.l += 4;\n val = blob.read_shift(4);\n break;\n case 0x05 /*VT_R8*/:\n blob.l += 4;\n val = blob.read_shift(8, 'f');\n break;\n case 0x0B /*VT_BOOL*/:\n blob.l += 4;\n val = parsebool(blob, 4);\n break;\n case 0x40 /*VT_FILETIME*/:\n blob.l += 4;\n val = parseDate(parse_FILETIME(blob));\n break;\n default:\n throw new Error(\"unparsed value: \" + blob[blob.l]);\n }\n PropH[name] = val;\n }\n }\n }\n blob.l = start_addr + size; /* step ahead to skip padding */\n return PropH;\n}\nvar XLSPSSkip = [\"CodePage\", \"Thumbnail\", \"_PID_LINKBASE\", \"_PID_HLINKS\", \"SystemIdentifier\", \"FMTID\"]; //.concat(PseudoPropsPairs);\nfunction guess_property_type(val /*:any*/) /*:number*/{\n switch (typeof val) {\n case \"boolean\":\n return 0x0B;\n case \"number\":\n return (val | 0) == val ? 0x03 : 0x05;\n case \"string\":\n return 0x1F;\n case \"object\":\n if (val instanceof Date) return 0x40;\n break;\n }\n return -1;\n}\nfunction write_PropertySet(entries, RE, PIDSI) {\n var hdr = new_buf(8),\n piao = [],\n prop = [];\n var sz = 8,\n i = 0;\n var pr = new_buf(8),\n pio = new_buf(8);\n pr.write_shift(4, 0x0002);\n pr.write_shift(4, 0x04B0);\n pio.write_shift(4, 0x0001);\n prop.push(pr);\n piao.push(pio);\n sz += 8 + pr.length;\n if (!RE) {\n pio = new_buf(8);\n pio.write_shift(4, 0);\n piao.unshift(pio);\n var bufs = [new_buf(4)];\n bufs[0].write_shift(4, entries.length);\n for (i = 0; i < entries.length; ++i) {\n var value = entries[i][0];\n pr = new_buf(4 + 4 + 2 * (value.length + 1) + (value.length % 2 ? 0 : 2));\n pr.write_shift(4, i + 2);\n pr.write_shift(4, value.length + 1);\n pr.write_shift(0, value, \"dbcs\");\n while (pr.l != pr.length) pr.write_shift(1, 0);\n bufs.push(pr);\n }\n pr = bconcat(bufs);\n prop.unshift(pr);\n sz += 8 + pr.length;\n }\n for (i = 0; i < entries.length; ++i) {\n if (RE && !RE[entries[i][0]]) continue;\n if (XLSPSSkip.indexOf(entries[i][0]) > -1 || PseudoPropsPairs.indexOf(entries[i][0]) > -1) continue;\n if (entries[i][1] == null) continue;\n var val = entries[i][1],\n idx = 0;\n if (RE) {\n idx = +RE[entries[i][0]];\n var pinfo = PIDSI /*:: || {}*/[idx] /*:: || {} */;\n if (pinfo.p == \"version\" && typeof val == \"string\") {\n /*:: if(typeof val !== \"string\") throw \"unreachable\"; */\n var arr = val.split(\".\");\n val = (+arr[0] << 16) + (+arr[1] || 0);\n }\n pr = write_TypedPropertyValue(pinfo.t, val);\n } else {\n var T = guess_property_type(val);\n if (T == -1) {\n T = 0x1F;\n val = String(val);\n }\n pr = write_TypedPropertyValue(T, val);\n }\n prop.push(pr);\n pio = new_buf(8);\n pio.write_shift(4, !RE ? 2 + i : idx);\n piao.push(pio);\n sz += 8 + pr.length;\n }\n var w = 8 * (prop.length + 1);\n for (i = 0; i < prop.length; ++i) {\n piao[i].write_shift(4, w);\n w += prop[i].length;\n }\n hdr.write_shift(4, sz);\n hdr.write_shift(4, prop.length);\n return bconcat([hdr].concat(piao).concat(prop));\n}\n\n/* [MS-OLEPS] 2.21 PropertySetStream */\nfunction parse_PropertySetStream(file, PIDSI, clsid) {\n var blob = file.content;\n if (!blob) return {} /*:any*/;\n prep_blob(blob, 0);\n var NumSets,\n FMTID0,\n FMTID1,\n Offset0,\n Offset1 = 0;\n blob.chk('feff', 'Byte Order: ');\n\n /*var vers = */\n blob.read_shift(2); // TODO: check version\n var SystemIdentifier = blob.read_shift(4);\n var CLSID = blob.read_shift(16);\n if (CLSID !== CFB.utils.consts.HEADER_CLSID && CLSID !== clsid) throw new Error(\"Bad PropertySet CLSID \" + CLSID);\n NumSets = blob.read_shift(4);\n if (NumSets !== 1 && NumSets !== 2) throw new Error(\"Unrecognized #Sets: \" + NumSets);\n FMTID0 = blob.read_shift(16);\n Offset0 = blob.read_shift(4);\n if (NumSets === 1 && Offset0 !== blob.l) throw new Error(\"Length mismatch: \" + Offset0 + \" !== \" + blob.l);else if (NumSets === 2) {\n FMTID1 = blob.read_shift(16);\n Offset1 = blob.read_shift(4);\n }\n var PSet0 = parse_PropertySet(blob, PIDSI);\n var rval = {\n SystemIdentifier: SystemIdentifier\n } /*:any*/;\n for (var y in PSet0) rval[y] = PSet0[y];\n //rval.blob = blob;\n rval.FMTID = FMTID0;\n //rval.PSet0 = PSet0;\n if (NumSets === 1) return rval;\n if (Offset1 - blob.l == 2) blob.l += 2;\n if (blob.l !== Offset1) throw new Error(\"Length mismatch 2: \" + blob.l + \" !== \" + Offset1);\n var PSet1;\n try {\n PSet1 = parse_PropertySet(blob, null);\n } catch (e) {/* empty */}\n for (y in PSet1) rval[y] = PSet1[y];\n rval.FMTID = [FMTID0, FMTID1]; // TODO: verify FMTID0/1\n return rval;\n}\nfunction write_PropertySetStream(entries, clsid, RE, PIDSI /*:{[key:string|number]:any}*/, entries2 /*:?any*/, clsid2 /*:?any*/) {\n var hdr = new_buf(entries2 ? 68 : 48);\n var bufs = [hdr];\n hdr.write_shift(2, 0xFFFE);\n hdr.write_shift(2, 0x0000); /* TODO: type 1 props */\n hdr.write_shift(4, 0x32363237);\n hdr.write_shift(16, CFB.utils.consts.HEADER_CLSID, \"hex\");\n hdr.write_shift(4, entries2 ? 2 : 1);\n hdr.write_shift(16, clsid, \"hex\");\n hdr.write_shift(4, entries2 ? 68 : 48);\n var ps0 = write_PropertySet(entries, RE, PIDSI);\n bufs.push(ps0);\n if (entries2) {\n var ps1 = write_PropertySet(entries2, null, null);\n hdr.write_shift(16, clsid2, \"hex\");\n hdr.write_shift(4, 68 + ps0.length);\n bufs.push(ps1);\n }\n return bconcat(bufs);\n}\nfunction parsenoop2(blob, length) {\n blob.read_shift(length);\n return null;\n}\nfunction writezeroes(n, o) {\n if (!o) o = new_buf(n);\n for (var j = 0; j < n; ++j) o.write_shift(1, 0);\n return o;\n}\nfunction parslurp(blob, length, cb) {\n var arr = [],\n target = blob.l + length;\n while (blob.l < target) arr.push(cb(blob, target - blob.l));\n if (target !== blob.l) throw new Error(\"Slurp error\");\n return arr;\n}\nfunction parsebool(blob, length /*:number*/) {\n return blob.read_shift(length) === 0x1;\n}\nfunction writebool(v /*:any*/, o) {\n if (!o) o = new_buf(2);\n o.write_shift(2, +!!v);\n return o;\n}\nfunction parseuint16(blob /*::, length:?number, opts:?any*/) {\n return blob.read_shift(2, 'u');\n}\nfunction writeuint16(v /*:number*/, o) {\n if (!o) o = new_buf(2);\n o.write_shift(2, v);\n return o;\n}\nfunction parseuint16a(blob, length /*:: :?number, opts:?any*/) {\n return parslurp(blob, length, parseuint16);\n}\n\n/* --- 2.5 Structures --- */\n\n/* [MS-XLS] 2.5.10 Bes (boolean or error) */\nfunction parse_Bes(blob /*::, length*/) {\n var v = blob.read_shift(1),\n t = blob.read_shift(1);\n return t === 0x01 ? v : v === 0x01;\n}\nfunction write_Bes(v, t /*:string*/, o) {\n if (!o) o = new_buf(2);\n o.write_shift(1, t == 'e' ? +v : +!!v);\n o.write_shift(1, t == 'e' ? 1 : 0);\n return o;\n}\n\n/* [MS-XLS] 2.5.240 ShortXLUnicodeString */\nfunction parse_ShortXLUnicodeString(blob, length, opts) {\n var cch = blob.read_shift(opts && opts.biff >= 12 ? 2 : 1);\n var encoding = 'sbcs-cont';\n var cp = current_codepage;\n if (opts && opts.biff >= 8) current_codepage = 1200;\n if (!opts || opts.biff == 8) {\n var fHighByte = blob.read_shift(1);\n if (fHighByte) {\n encoding = 'dbcs-cont';\n }\n } else if (opts.biff == 12) {\n encoding = 'wstr';\n }\n if (opts.biff >= 2 && opts.biff <= 5) encoding = 'cpstr';\n var o = cch ? blob.read_shift(cch, encoding) : \"\";\n current_codepage = cp;\n return o;\n}\n\n/* 2.5.293 XLUnicodeRichExtendedString */\nfunction parse_XLUnicodeRichExtendedString(blob) {\n var cp = current_codepage;\n current_codepage = 1200;\n var cch = blob.read_shift(2),\n flags = blob.read_shift(1);\n var /*fHighByte = flags & 0x1,*/fExtSt = flags & 0x4,\n fRichSt = flags & 0x8;\n var width = 1 + (flags & 0x1); // 0x0 -> utf8, 0x1 -> dbcs\n var cRun = 0,\n cbExtRst;\n var z = {};\n if (fRichSt) cRun = blob.read_shift(2);\n if (fExtSt) cbExtRst = blob.read_shift(4);\n var encoding = width == 2 ? 'dbcs-cont' : 'sbcs-cont';\n var msg = cch === 0 ? \"\" : blob.read_shift(cch, encoding);\n if (fRichSt) blob.l += 4 * cRun; //TODO: parse this\n if (fExtSt) blob.l += cbExtRst; //TODO: parse this\n z.t = msg;\n if (!fRichSt) {\n z.raw = \"\" + z.t + \"\";\n z.r = z.t;\n }\n current_codepage = cp;\n return z;\n}\nfunction write_XLUnicodeRichExtendedString(xlstr /*:: :XLString, opts*/) {\n var str = xlstr.t || \"\",\n nfmts = 1;\n var hdr = new_buf(3 + (nfmts > 1 ? 2 : 0));\n hdr.write_shift(2, str.length);\n hdr.write_shift(1, (nfmts > 1 ? 0x08 : 0x00) | 0x01);\n if (nfmts > 1) hdr.write_shift(2, nfmts);\n var otext = new_buf(2 * str.length);\n otext.write_shift(2 * str.length, str, 'utf16le');\n var out = [hdr, otext];\n return bconcat(out);\n}\n\n/* 2.5.296 XLUnicodeStringNoCch */\nfunction parse_XLUnicodeStringNoCch(blob, cch, opts) {\n var retval;\n if (opts) {\n if (opts.biff >= 2 && opts.biff <= 5) return blob.read_shift(cch, 'cpstr');\n if (opts.biff >= 12) return blob.read_shift(cch, 'dbcs-cont');\n }\n var fHighByte = blob.read_shift(1);\n if (fHighByte === 0) {\n retval = blob.read_shift(cch, 'sbcs-cont');\n } else {\n retval = blob.read_shift(cch, 'dbcs-cont');\n }\n return retval;\n}\n\n/* 2.5.294 XLUnicodeString */\nfunction parse_XLUnicodeString(blob, length, opts) {\n var cch = blob.read_shift(opts && opts.biff == 2 ? 1 : 2);\n if (cch === 0) {\n blob.l++;\n return \"\";\n }\n return parse_XLUnicodeStringNoCch(blob, cch, opts);\n}\n/* BIFF5 override */\nfunction parse_XLUnicodeString2(blob, length, opts) {\n if (opts.biff > 5) return parse_XLUnicodeString(blob, length, opts);\n var cch = blob.read_shift(1);\n if (cch === 0) {\n blob.l++;\n return \"\";\n }\n return blob.read_shift(cch, opts.biff <= 4 || !blob.lens ? 'cpstr' : 'sbcs-cont');\n}\n/* TODO: BIFF5 and lower, codepage awareness */\nfunction write_XLUnicodeString(str, opts, o) {\n if (!o) o = new_buf(3 + 2 * str.length);\n o.write_shift(2, str.length);\n o.write_shift(1, 1);\n o.write_shift(31, str, 'utf16le');\n return o;\n}\n\n/* [MS-XLS] 2.5.61 ControlInfo */\nfunction parse_ControlInfo(blob /*::, length, opts*/) {\n var flags = blob.read_shift(1);\n blob.l++;\n var accel = blob.read_shift(2);\n blob.l += 2;\n return [flags, accel];\n}\n\n/* [MS-OSHARED] 2.3.7.6 URLMoniker TODO: flags */\nfunction parse_URLMoniker(blob /*::, length, opts*/) {\n var len = blob.read_shift(4),\n start = blob.l;\n var extra = false;\n if (len > 24) {\n /* look ahead */\n blob.l += len - 24;\n if (blob.read_shift(16) === \"795881f43b1d7f48af2c825dc4852763\") extra = true;\n blob.l = start;\n }\n var url = blob.read_shift((extra ? len - 24 : len) >> 1, 'utf16le').replace(chr0, \"\");\n if (extra) blob.l += 24;\n return url;\n}\n\n/* [MS-OSHARED] 2.3.7.8 FileMoniker TODO: all fields */\nfunction parse_FileMoniker(blob /*::, length*/) {\n var cAnti = blob.read_shift(2);\n var preamble = \"\";\n while (cAnti-- > 0) preamble += \"../\";\n var ansiPath = blob.read_shift(0, 'lpstr-ansi');\n blob.l += 2; //var endServer = blob.read_shift(2);\n if (blob.read_shift(2) != 0xDEAD) throw new Error(\"Bad FileMoniker\");\n var sz = blob.read_shift(4);\n if (sz === 0) return preamble + ansiPath.replace(/\\\\/g, \"/\");\n var bytes = blob.read_shift(4);\n if (blob.read_shift(2) != 3) throw new Error(\"Bad FileMoniker\");\n var unicodePath = blob.read_shift(bytes >> 1, 'utf16le').replace(chr0, \"\");\n return preamble + unicodePath;\n}\n\n/* [MS-OSHARED] 2.3.7.2 HyperlinkMoniker TODO: all the monikers */\nfunction parse_HyperlinkMoniker(blob, length) {\n var clsid = blob.read_shift(16);\n length -= 16;\n switch (clsid) {\n case \"e0c9ea79f9bace118c8200aa004ba90b\":\n return parse_URLMoniker(blob, length);\n case \"0303000000000000c000000000000046\":\n return parse_FileMoniker(blob, length);\n default:\n throw new Error(\"Unsupported Moniker \" + clsid);\n }\n}\n\n/* [MS-OSHARED] 2.3.7.9 HyperlinkString */\nfunction parse_HyperlinkString(blob /*::, length*/) {\n var len = blob.read_shift(4);\n var o = len > 0 ? blob.read_shift(len, 'utf16le').replace(chr0, \"\") : \"\";\n return o;\n}\nfunction write_HyperlinkString(str /*:string*/, o) {\n if (!o) o = new_buf(6 + str.length * 2);\n o.write_shift(4, 1 + str.length);\n for (var i = 0; i < str.length; ++i) o.write_shift(2, str.charCodeAt(i));\n o.write_shift(2, 0);\n return o;\n}\n\n/* [MS-OSHARED] 2.3.7.1 Hyperlink Object */\nfunction parse_Hyperlink(blob, length) /*:Hyperlink*/{\n var end = blob.l + length;\n var sVer = blob.read_shift(4);\n if (sVer !== 2) throw new Error(\"Unrecognized streamVersion: \" + sVer);\n var flags = blob.read_shift(2);\n blob.l += 2;\n var displayName,\n targetFrameName,\n moniker,\n oleMoniker,\n Loc = \"\",\n guid,\n fileTime;\n if (flags & 0x0010) displayName = parse_HyperlinkString(blob, end - blob.l);\n if (flags & 0x0080) targetFrameName = parse_HyperlinkString(blob, end - blob.l);\n if ((flags & 0x0101) === 0x0101) moniker = parse_HyperlinkString(blob, end - blob.l);\n if ((flags & 0x0101) === 0x0001) oleMoniker = parse_HyperlinkMoniker(blob, end - blob.l);\n if (flags & 0x0008) Loc = parse_HyperlinkString(blob, end - blob.l);\n if (flags & 0x0020) guid = blob.read_shift(16);\n if (flags & 0x0040) fileTime = parse_FILETIME(blob /*, 8*/);\n blob.l = end;\n var target = targetFrameName || moniker || oleMoniker || \"\";\n if (target && Loc) target += \"#\" + Loc;\n if (!target) target = \"#\" + Loc;\n if (flags & 0x0002 && target.charAt(0) == \"/\" && target.charAt(1) != \"/\") target = \"file://\" + target;\n var out = {\n Target: target\n } /*:any*/;\n if (guid) out.guid = guid;\n if (fileTime) out.time = fileTime;\n if (displayName) out.Tooltip = displayName;\n return out;\n}\nfunction write_Hyperlink(hl) {\n var out = new_buf(512),\n i = 0;\n var Target = hl.Target;\n if (Target.slice(0, 7) == \"file://\") Target = Target.slice(7);\n var hashidx = Target.indexOf(\"#\");\n var F = hashidx > -1 ? 0x1f : 0x17;\n switch (Target.charAt(0)) {\n case \"#\":\n F = 0x1c;\n break;\n case \".\":\n F &= ~2;\n break;\n }\n out.write_shift(4, 2);\n out.write_shift(4, F);\n var data = [8, 6815827, 6619237, 4849780, 83];\n for (i = 0; i < data.length; ++i) out.write_shift(4, data[i]);\n if (F == 0x1C) {\n Target = Target.slice(1);\n write_HyperlinkString(Target, out);\n } else if (F & 0x02) {\n data = \"e0 c9 ea 79 f9 ba ce 11 8c 82 00 aa 00 4b a9 0b\".split(\" \");\n for (i = 0; i < data.length; ++i) out.write_shift(1, parseInt(data[i], 16));\n var Pretarget = hashidx > -1 ? Target.slice(0, hashidx) : Target;\n out.write_shift(4, 2 * (Pretarget.length + 1));\n for (i = 0; i < Pretarget.length; ++i) out.write_shift(2, Pretarget.charCodeAt(i));\n out.write_shift(2, 0);\n if (F & 0x08) write_HyperlinkString(hashidx > -1 ? Target.slice(hashidx + 1) : \"\", out);\n } else {\n data = \"03 03 00 00 00 00 00 00 c0 00 00 00 00 00 00 46\".split(\" \");\n for (i = 0; i < data.length; ++i) out.write_shift(1, parseInt(data[i], 16));\n var P = 0;\n while (Target.slice(P * 3, P * 3 + 3) == \"../\" || Target.slice(P * 3, P * 3 + 3) == \"..\\\\\") ++P;\n out.write_shift(2, P);\n out.write_shift(4, Target.length - 3 * P + 1);\n for (i = 0; i < Target.length - 3 * P; ++i) out.write_shift(1, Target.charCodeAt(i + 3 * P) & 0xFF);\n out.write_shift(1, 0);\n out.write_shift(2, 0xFFFF);\n out.write_shift(2, 0xDEAD);\n for (i = 0; i < 6; ++i) out.write_shift(4, 0);\n }\n return out.slice(0, out.l);\n}\n\n/* 2.5.178 LongRGBA */\nfunction parse_LongRGBA(blob /*::, length*/) {\n var r = blob.read_shift(1),\n g = blob.read_shift(1),\n b = blob.read_shift(1),\n a = blob.read_shift(1);\n return [r, g, b, a];\n}\n\n/* 2.5.177 LongRGB */\nfunction parse_LongRGB(blob, length) {\n var x = parse_LongRGBA(blob, length);\n x[3] = 0;\n return x;\n}\n\n/* [MS-XLS] 2.5.19 */\nfunction parse_XLSCell(blob /*::, length*/) /*:Cell*/{\n var rw = blob.read_shift(2); // 0-indexed\n var col = blob.read_shift(2);\n var ixfe = blob.read_shift(2);\n return {\n r: rw,\n c: col,\n ixfe: ixfe\n } /*:any*/;\n}\nfunction write_XLSCell(R /*:number*/, C /*:number*/, ixfe /*:?number*/, o) {\n if (!o) o = new_buf(6);\n o.write_shift(2, R);\n o.write_shift(2, C);\n o.write_shift(2, ixfe || 0);\n return o;\n}\n\n/* [MS-XLS] 2.5.134 */\nfunction parse_frtHeader(blob) {\n var rt = blob.read_shift(2);\n var flags = blob.read_shift(2); // TODO: parse these flags\n blob.l += 8;\n return {\n type: rt,\n flags: flags\n };\n}\nfunction parse_OptXLUnicodeString(blob, length, opts) {\n return length === 0 ? \"\" : parse_XLUnicodeString2(blob, length, opts);\n}\n\n/* [MS-XLS] 2.5.344 */\nfunction parse_XTI(blob, length, opts) {\n var w = opts.biff > 8 ? 4 : 2;\n var iSupBook = blob.read_shift(w),\n itabFirst = blob.read_shift(w, 'i'),\n itabLast = blob.read_shift(w, 'i');\n return [iSupBook, itabFirst, itabLast];\n}\n\n/* [MS-XLS] 2.5.218 */\nfunction parse_RkRec(blob) {\n var ixfe = blob.read_shift(2);\n var RK = parse_RkNumber(blob);\n return [ixfe, RK];\n}\n\n/* [MS-XLS] 2.5.1 */\nfunction parse_AddinUdf(blob, length, opts) {\n blob.l += 4;\n length -= 4;\n var l = blob.l + length;\n var udfName = parse_ShortXLUnicodeString(blob, length, opts);\n var cb = blob.read_shift(2);\n l -= blob.l;\n if (cb !== l) throw new Error(\"Malformed AddinUdf: padding = \" + l + \" != \" + cb);\n blob.l += cb;\n return udfName;\n}\n\n/* [MS-XLS] 2.5.209 TODO: Check sizes */\nfunction parse_Ref8U(blob /*::, length*/) {\n var rwFirst = blob.read_shift(2);\n var rwLast = blob.read_shift(2);\n var colFirst = blob.read_shift(2);\n var colLast = blob.read_shift(2);\n return {\n s: {\n c: colFirst,\n r: rwFirst\n },\n e: {\n c: colLast,\n r: rwLast\n }\n };\n}\nfunction write_Ref8U(r /*:Range*/, o) {\n if (!o) o = new_buf(8);\n o.write_shift(2, r.s.r);\n o.write_shift(2, r.e.r);\n o.write_shift(2, r.s.c);\n o.write_shift(2, r.e.c);\n return o;\n}\n\n/* [MS-XLS] 2.5.211 */\nfunction parse_RefU(blob /*::, length*/) {\n var rwFirst = blob.read_shift(2);\n var rwLast = blob.read_shift(2);\n var colFirst = blob.read_shift(1);\n var colLast = blob.read_shift(1);\n return {\n s: {\n c: colFirst,\n r: rwFirst\n },\n e: {\n c: colLast,\n r: rwLast\n }\n };\n}\n\n/* [MS-XLS] 2.5.207 */\nvar parse_Ref = parse_RefU;\n\n/* [MS-XLS] 2.5.143 */\nfunction parse_FtCmo(blob /*::, length*/) {\n blob.l += 4;\n var ot = blob.read_shift(2);\n var id = blob.read_shift(2);\n var flags = blob.read_shift(2);\n blob.l += 12;\n return [id, ot, flags];\n}\n\n/* [MS-XLS] 2.5.149 */\nfunction parse_FtNts(blob) {\n var out = {};\n blob.l += 4;\n blob.l += 16; // GUID TODO\n out.fSharedNote = blob.read_shift(2);\n blob.l += 4;\n return out;\n}\n\n/* [MS-XLS] 2.5.142 */\nfunction parse_FtCf(blob) {\n var out = {};\n blob.l += 4;\n blob.cf = blob.read_shift(2);\n return out;\n}\n\n/* [MS-XLS] 2.5.140 - 2.5.154 and friends */\nfunction parse_FtSkip(blob) {\n blob.l += 2;\n blob.l += blob.read_shift(2);\n}\nvar FtTab = {\n /*::[*/0x00 /*::]*/: parse_FtSkip,\n /* FtEnd */\n /*::[*/0x04 /*::]*/: parse_FtSkip,\n /* FtMacro */\n /*::[*/0x05 /*::]*/: parse_FtSkip,\n /* FtButton */\n /*::[*/0x06 /*::]*/: parse_FtSkip,\n /* FtGmo */\n /*::[*/0x07 /*::]*/: parse_FtCf,\n /* FtCf */\n /*::[*/0x08 /*::]*/: parse_FtSkip,\n /* FtPioGrbit */\n /*::[*/0x09 /*::]*/: parse_FtSkip,\n /* FtPictFmla */\n /*::[*/0x0A /*::]*/: parse_FtSkip,\n /* FtCbls */\n /*::[*/0x0B /*::]*/: parse_FtSkip,\n /* FtRbo */\n /*::[*/0x0C /*::]*/: parse_FtSkip,\n /* FtSbs */\n /*::[*/0x0D /*::]*/: parse_FtNts,\n /* FtNts */\n /*::[*/0x0E /*::]*/: parse_FtSkip,\n /* FtSbsFmla */\n /*::[*/0x0F /*::]*/: parse_FtSkip,\n /* FtGboData */\n /*::[*/0x10 /*::]*/: parse_FtSkip,\n /* FtEdoData */\n /*::[*/0x11 /*::]*/: parse_FtSkip,\n /* FtRboData */\n /*::[*/0x12 /*::]*/: parse_FtSkip,\n /* FtCblsData */\n /*::[*/0x13 /*::]*/: parse_FtSkip,\n /* FtLbsData */\n /*::[*/0x14 /*::]*/: parse_FtSkip,\n /* FtCblsFmla */\n /*::[*/0x15 /*::]*/: parse_FtCmo\n};\nfunction parse_FtArray(blob, length /*::, ot*/) {\n var tgt = blob.l + length;\n var fts = [];\n while (blob.l < tgt) {\n var ft = blob.read_shift(2);\n blob.l -= 2;\n try {\n fts.push(FtTab[ft](blob, tgt - blob.l));\n } catch (e) {\n blob.l = tgt;\n return fts;\n }\n }\n if (blob.l != tgt) blob.l = tgt; //throw new Error(\"bad Object Ft-sequence\");\n return fts;\n}\n\n/* --- 2.4 Records --- */\n\n/* [MS-XLS] 2.4.21 */\nfunction parse_BOF(blob, length) {\n var o = {\n BIFFVer: 0,\n dt: 0\n };\n o.BIFFVer = blob.read_shift(2);\n length -= 2;\n if (length >= 2) {\n o.dt = blob.read_shift(2);\n blob.l -= 2;\n }\n switch (o.BIFFVer) {\n case 0x0600: /* BIFF8 */\n case 0x0500: /* BIFF5 */\n case 0x0400: /* BIFF4 */\n case 0x0300: /* BIFF3 */\n case 0x0200: /* BIFF2 */\n case 0x0002:\n case 0x0007:\n /* BIFF2 */\n break;\n default:\n if (length > 6) throw new Error(\"Unexpected BIFF Ver \" + o.BIFFVer);\n }\n blob.read_shift(length);\n return o;\n}\nfunction write_BOF(wb /*:Workbook*/, t /*:number*/, o) {\n var h = 0x0600,\n w = 16;\n switch (o.bookType) {\n case 'biff8':\n break;\n case 'biff5':\n h = 0x0500;\n w = 8;\n break;\n case 'biff4':\n h = 0x0004;\n w = 6;\n break;\n case 'biff3':\n h = 0x0003;\n w = 6;\n break;\n case 'biff2':\n h = 0x0002;\n w = 4;\n break;\n case 'xla':\n break;\n default:\n throw new Error(\"unsupported BIFF version\");\n }\n var out = new_buf(w);\n out.write_shift(2, h);\n out.write_shift(2, t);\n if (w > 4) out.write_shift(2, 0x7262);\n if (w > 6) out.write_shift(2, 0x07CD);\n if (w > 8) {\n out.write_shift(2, 0xC009);\n out.write_shift(2, 0x0001);\n out.write_shift(2, 0x0706);\n out.write_shift(2, 0x0000);\n }\n return out;\n}\n\n/* [MS-XLS] 2.4.146 */\nfunction parse_InterfaceHdr(blob, length) {\n if (length === 0) return 0x04b0;\n if (blob.read_shift(2) !== 0x04b0) {/* empty */}\n return 0x04b0;\n}\n\n/* [MS-XLS] 2.4.349 */\nfunction parse_WriteAccess(blob, length, opts) {\n if (opts.enc) {\n blob.l += length;\n return \"\";\n }\n var l = blob.l;\n // TODO: make sure XLUnicodeString doesnt overrun\n var UserName = parse_XLUnicodeString2(blob, 0, opts);\n blob.read_shift(length + l - blob.l);\n return UserName;\n}\nfunction write_WriteAccess(s /*:string*/, opts) {\n var b8 = !opts || opts.biff == 8;\n var o = new_buf(b8 ? 112 : 54);\n o.write_shift(opts.biff == 8 ? 2 : 1, 7);\n if (b8) o.write_shift(1, 0);\n o.write_shift(4, 0x33336853);\n o.write_shift(4, 0x00534A74 | (b8 ? 0 : 0x20000000));\n while (o.l < o.length) o.write_shift(1, b8 ? 0 : 32);\n return o;\n}\n\n/* [MS-XLS] 2.4.351 */\nfunction parse_WsBool(blob, length, opts) {\n var flags = opts && opts.biff == 8 || length == 2 ? blob.read_shift(2) : (blob.l += length, 0);\n return {\n fDialog: flags & 0x10,\n fBelow: flags & 0x40,\n fRight: flags & 0x80\n };\n}\n\n/* [MS-XLS] 2.4.28 */\nfunction parse_BoundSheet8(blob, length, opts) {\n var pos = blob.read_shift(4);\n var hidden = blob.read_shift(1) & 0x03;\n var dt = blob.read_shift(1);\n switch (dt) {\n case 0:\n dt = 'Worksheet';\n break;\n case 1:\n dt = 'Macrosheet';\n break;\n case 2:\n dt = 'Chartsheet';\n break;\n case 6:\n dt = 'VBAModule';\n break;\n }\n var name = parse_ShortXLUnicodeString(blob, 0, opts);\n if (name.length === 0) name = \"Sheet1\";\n return {\n pos: pos,\n hs: hidden,\n dt: dt,\n name: name\n };\n}\nfunction write_BoundSheet8(data, opts) {\n var w = !opts || opts.biff >= 8 ? 2 : 1;\n var o = new_buf(8 + w * data.name.length);\n o.write_shift(4, data.pos);\n o.write_shift(1, data.hs || 0);\n o.write_shift(1, data.dt);\n o.write_shift(1, data.name.length);\n if (opts.biff >= 8) o.write_shift(1, 1);\n o.write_shift(w * data.name.length, data.name, opts.biff < 8 ? 'sbcs' : 'utf16le');\n var out = o.slice(0, o.l);\n out.l = o.l;\n return out;\n}\n\n/* [MS-XLS] 2.4.265 TODO */\nfunction parse_SST(blob, length) /*:SST*/{\n var end = blob.l + length;\n var cnt = blob.read_shift(4);\n var ucnt = blob.read_shift(4);\n var strs /*:SST*/ = [] /*:any*/;\n for (var i = 0; i != ucnt && blob.l < end; ++i) {\n strs.push(parse_XLUnicodeRichExtendedString(blob));\n }\n strs.Count = cnt;\n strs.Unique = ucnt;\n return strs;\n}\nfunction write_SST(sst, opts) {\n var header = new_buf(8);\n header.write_shift(4, sst.Count);\n header.write_shift(4, sst.Unique);\n var strs = [];\n for (var j = 0; j < sst.length; ++j) strs[j] = write_XLUnicodeRichExtendedString(sst[j], opts);\n var o = bconcat([header].concat(strs));\n /*::(*/\n o /*:: :any)*/.parts = [header.length].concat(strs.map(function (str) {\n return str.length;\n }));\n return o;\n}\n\n/* [MS-XLS] 2.4.107 */\nfunction parse_ExtSST(blob, length) {\n var extsst = {};\n extsst.dsst = blob.read_shift(2);\n blob.l += length - 2;\n return extsst;\n}\n\n/* [MS-XLS] 2.4.221 TODO: check BIFF2-4 */\nfunction parse_Row(blob) {\n var z = {} /*:any*/;\n z.r = blob.read_shift(2);\n z.c = blob.read_shift(2);\n z.cnt = blob.read_shift(2) - z.c;\n var miyRw = blob.read_shift(2);\n blob.l += 4; // reserved(2), unused(2)\n var flags = blob.read_shift(1); // various flags\n blob.l += 3; // reserved(8), ixfe(12), flags(4)\n if (flags & 0x07) z.level = flags & 0x07;\n // collapsed: flags & 0x10\n if (flags & 0x20) z.hidden = true;\n if (flags & 0x40) z.hpt = miyRw / 20;\n return z;\n}\n\n/* [MS-XLS] 2.4.125 */\nfunction parse_ForceFullCalculation(blob) {\n var header = parse_frtHeader(blob);\n if (header.type != 0x08A3) throw new Error(\"Invalid Future Record \" + header.type);\n var fullcalc = blob.read_shift(4);\n return fullcalc !== 0x0;\n}\n\n/* [MS-XLS] 2.4.215 rt */\nfunction parse_RecalcId(blob) {\n blob.read_shift(2);\n return blob.read_shift(4);\n}\n\n/* [MS-XLS] 2.4.87 */\nfunction parse_DefaultRowHeight(blob, length, opts) {\n var f = 0;\n if (!(opts && opts.biff == 2)) {\n f = blob.read_shift(2);\n }\n var miyRw = blob.read_shift(2);\n if (opts && opts.biff == 2) {\n f = 1 - (miyRw >> 15);\n miyRw &= 0x7fff;\n }\n var fl = {\n Unsynced: f & 1,\n DyZero: (f & 2) >> 1,\n ExAsc: (f & 4) >> 2,\n ExDsc: (f & 8) >> 3\n };\n return [fl, miyRw];\n}\n\n/* [MS-XLS] 2.4.345 TODO */\nfunction parse_Window1(blob) {\n var xWn = blob.read_shift(2),\n yWn = blob.read_shift(2),\n dxWn = blob.read_shift(2),\n dyWn = blob.read_shift(2);\n var flags = blob.read_shift(2),\n iTabCur = blob.read_shift(2),\n iTabFirst = blob.read_shift(2);\n var ctabSel = blob.read_shift(2),\n wTabRatio = blob.read_shift(2);\n return {\n Pos: [xWn, yWn],\n Dim: [dxWn, dyWn],\n Flags: flags,\n CurTab: iTabCur,\n FirstTab: iTabFirst,\n Selected: ctabSel,\n TabRatio: wTabRatio\n };\n}\nfunction write_Window1(/*::opts*/\n) {\n var o = new_buf(18);\n o.write_shift(2, 0);\n o.write_shift(2, 0);\n o.write_shift(2, 0x7260);\n o.write_shift(2, 0x44c0);\n o.write_shift(2, 0x38);\n o.write_shift(2, 0);\n o.write_shift(2, 0);\n o.write_shift(2, 1);\n o.write_shift(2, 0x01f4);\n return o;\n}\n/* [MS-XLS] 2.4.346 TODO */\nfunction parse_Window2(blob, length, opts) {\n if (opts && opts.biff >= 2 && opts.biff < 5) return {};\n var f = blob.read_shift(2);\n return {\n RTL: f & 0x40\n };\n}\nfunction write_Window2(view) {\n var o = new_buf(18),\n f = 0x6b6;\n if (view && view.RTL) f |= 0x40;\n o.write_shift(2, f);\n o.write_shift(4, 0);\n o.write_shift(4, 64);\n o.write_shift(4, 0);\n o.write_shift(4, 0);\n return o;\n}\n\n/* [MS-XLS] 2.4.189 TODO */\nfunction parse_Pane(/*blob, length, opts*/\n) {}\n\n/* [MS-XLS] 2.4.122 TODO */\nfunction parse_Font(blob, length, opts) {\n var o /*:any*/ = {\n dyHeight: blob.read_shift(2),\n fl: blob.read_shift(2)\n };\n switch (opts && opts.biff || 8) {\n case 2:\n break;\n case 3:\n case 4:\n blob.l += 2;\n break;\n default:\n blob.l += 10;\n break;\n }\n o.name = parse_ShortXLUnicodeString(blob, 0, opts);\n return o;\n}\nfunction write_Font(data, opts) {\n var name = data.name || \"Arial\";\n var b5 = opts && opts.biff == 5,\n w = b5 ? 15 + name.length : 16 + 2 * name.length;\n var o = new_buf(w);\n o.write_shift(2, (data.sz || 12) * 20);\n o.write_shift(4, 0);\n o.write_shift(2, 400);\n o.write_shift(4, 0);\n o.write_shift(2, 0);\n o.write_shift(1, name.length);\n if (!b5) o.write_shift(1, 1);\n o.write_shift((b5 ? 1 : 2) * name.length, name, b5 ? \"sbcs\" : \"utf16le\");\n return o;\n}\n\n/* [MS-XLS] 2.4.149 */\nfunction parse_LabelSst(blob) {\n var cell = parse_XLSCell(blob);\n cell.isst = blob.read_shift(4);\n return cell;\n}\nfunction write_LabelSst(R /*:number*/, C /*:number*/, v /*:number*/, os /*:number*/ /*::, opts*/) {\n var o = new_buf(10);\n write_XLSCell(R, C, os, o);\n o.write_shift(4, v);\n return o;\n}\n\n/* [MS-XLS] 2.4.148 */\nfunction parse_Label(blob, length, opts) {\n if (opts.biffguess && opts.biff == 2) opts.biff = 5;\n var target = blob.l + length;\n var cell = parse_XLSCell(blob, 6);\n if (opts.biff == 2) blob.l++;\n var str = parse_XLUnicodeString(blob, target - blob.l, opts);\n cell.val = str;\n return cell;\n}\nfunction write_Label(R /*:number*/, C /*:number*/, v /*:string*/, os /*:number*/, opts) {\n var b8 = !opts || opts.biff == 8;\n var o = new_buf(6 + 2 + +b8 + (1 + b8) * v.length);\n write_XLSCell(R, C, os, o);\n o.write_shift(2, v.length);\n if (b8) o.write_shift(1, 1);\n o.write_shift((1 + b8) * v.length, v, b8 ? 'utf16le' : 'sbcs');\n return o;\n}\n\n/* [MS-XLS] 2.4.126 Number Formats */\nfunction parse_Format(blob, length, opts) {\n var numFmtId = blob.read_shift(2);\n var fmtstr = parse_XLUnicodeString2(blob, 0, opts);\n return [numFmtId, fmtstr];\n}\nfunction write_Format(i /*:number*/, f /*:string*/, opts, o) {\n var b5 = opts && opts.biff == 5;\n if (!o) o = new_buf(b5 ? 3 + f.length : 5 + 2 * f.length);\n o.write_shift(2, i);\n o.write_shift(b5 ? 1 : 2, f.length);\n if (!b5) o.write_shift(1, 1);\n o.write_shift((b5 ? 1 : 2) * f.length, f, b5 ? 'sbcs' : 'utf16le');\n var out = o.length > o.l ? o.slice(0, o.l) : o;\n if (out.l == null) out.l = out.length;\n return out;\n}\nvar parse_BIFF2Format = parse_XLUnicodeString2;\n\n/* [MS-XLS] 2.4.90 */\nfunction parse_Dimensions(blob, length, opts) {\n var end = blob.l + length;\n var w = opts.biff == 8 || !opts.biff ? 4 : 2;\n var r = blob.read_shift(w),\n R = blob.read_shift(w);\n var c = blob.read_shift(2),\n C = blob.read_shift(2);\n blob.l = end;\n return {\n s: {\n r: r,\n c: c\n },\n e: {\n r: R,\n c: C\n }\n };\n}\nfunction write_Dimensions(range, opts) {\n var w = opts.biff == 8 || !opts.biff ? 4 : 2;\n var o = new_buf(2 * w + 6);\n o.write_shift(w, range.s.r);\n o.write_shift(w, range.e.r + 1);\n o.write_shift(2, range.s.c);\n o.write_shift(2, range.e.c + 1);\n o.write_shift(2, 0);\n return o;\n}\n\n/* [MS-XLS] 2.4.220 */\nfunction parse_RK(blob) {\n var rw = blob.read_shift(2),\n col = blob.read_shift(2);\n var rkrec = parse_RkRec(blob);\n return {\n r: rw,\n c: col,\n ixfe: rkrec[0],\n rknum: rkrec[1]\n };\n}\n\n/* [MS-XLS] 2.4.175 */\nfunction parse_MulRk(blob, length) {\n var target = blob.l + length - 2;\n var rw = blob.read_shift(2),\n col = blob.read_shift(2);\n var rkrecs = [];\n while (blob.l < target) rkrecs.push(parse_RkRec(blob));\n if (blob.l !== target) throw new Error(\"MulRK read error\");\n var lastcol = blob.read_shift(2);\n if (rkrecs.length != lastcol - col + 1) throw new Error(\"MulRK length mismatch\");\n return {\n r: rw,\n c: col,\n C: lastcol,\n rkrec: rkrecs\n };\n}\n/* [MS-XLS] 2.4.174 */\nfunction parse_MulBlank(blob, length) {\n var target = blob.l + length - 2;\n var rw = blob.read_shift(2),\n col = blob.read_shift(2);\n var ixfes = [];\n while (blob.l < target) ixfes.push(blob.read_shift(2));\n if (blob.l !== target) throw new Error(\"MulBlank read error\");\n var lastcol = blob.read_shift(2);\n if (ixfes.length != lastcol - col + 1) throw new Error(\"MulBlank length mismatch\");\n return {\n r: rw,\n c: col,\n C: lastcol,\n ixfe: ixfes\n };\n}\n\n/* [MS-XLS] 2.5.20 2.5.249 TODO: interpret values here */\nfunction parse_CellStyleXF(blob, length, style, opts) {\n var o = {};\n var a = blob.read_shift(4),\n b = blob.read_shift(4);\n var c = blob.read_shift(4),\n d = blob.read_shift(2);\n o.patternType = XLSFillPattern[c >> 26];\n if (!opts.cellStyles) return o;\n o.alc = a & 0x07;\n o.fWrap = a >> 3 & 0x01;\n o.alcV = a >> 4 & 0x07;\n o.fJustLast = a >> 7 & 0x01;\n o.trot = a >> 8 & 0xFF;\n o.cIndent = a >> 16 & 0x0F;\n o.fShrinkToFit = a >> 20 & 0x01;\n o.iReadOrder = a >> 22 & 0x02;\n o.fAtrNum = a >> 26 & 0x01;\n o.fAtrFnt = a >> 27 & 0x01;\n o.fAtrAlc = a >> 28 & 0x01;\n o.fAtrBdr = a >> 29 & 0x01;\n o.fAtrPat = a >> 30 & 0x01;\n o.fAtrProt = a >> 31 & 0x01;\n o.dgLeft = b & 0x0F;\n o.dgRight = b >> 4 & 0x0F;\n o.dgTop = b >> 8 & 0x0F;\n o.dgBottom = b >> 12 & 0x0F;\n o.icvLeft = b >> 16 & 0x7F;\n o.icvRight = b >> 23 & 0x7F;\n o.grbitDiag = b >> 30 & 0x03;\n o.icvTop = c & 0x7F;\n o.icvBottom = c >> 7 & 0x7F;\n o.icvDiag = c >> 14 & 0x7F;\n o.dgDiag = c >> 21 & 0x0F;\n o.icvFore = d & 0x7F;\n o.icvBack = d >> 7 & 0x7F;\n o.fsxButton = d >> 14 & 0x01;\n return o;\n}\n//function parse_CellXF(blob, length, opts) {return parse_CellStyleXF(blob,length,0, opts);}\n//function parse_StyleXF(blob, length, opts) {return parse_CellStyleXF(blob,length,1, opts);}\n\n/* [MS-XLS] 2.4.353 TODO: actually do this right */\nfunction parse_XF(blob, length, opts) {\n var o = {};\n o.ifnt = blob.read_shift(2);\n o.numFmtId = blob.read_shift(2);\n o.flags = blob.read_shift(2);\n o.fStyle = o.flags >> 2 & 0x01;\n length -= 6;\n o.data = parse_CellStyleXF(blob, length, o.fStyle, opts);\n return o;\n}\nfunction write_XF(data, ixfeP, opts, o) {\n var b5 = opts && opts.biff == 5;\n if (!o) o = new_buf(b5 ? 16 : 20);\n o.write_shift(2, 0);\n if (data.style) {\n o.write_shift(2, data.numFmtId || 0);\n o.write_shift(2, 0xFFF4);\n } else {\n o.write_shift(2, data.numFmtId || 0);\n o.write_shift(2, ixfeP << 4);\n }\n var f = 0;\n if (data.numFmtId > 0 && b5) f |= 0x0400;\n o.write_shift(4, f);\n o.write_shift(4, 0);\n if (!b5) o.write_shift(4, 0);\n o.write_shift(2, 0);\n return o;\n}\n\n/* [MS-XLS] 2.4.134 */\nfunction parse_Guts(blob) {\n blob.l += 4;\n var out = [blob.read_shift(2), blob.read_shift(2)];\n if (out[0] !== 0) out[0]--;\n if (out[1] !== 0) out[1]--;\n if (out[0] > 7 || out[1] > 7) throw new Error(\"Bad Gutters: \" + out.join(\"|\"));\n return out;\n}\nfunction write_Guts(guts /*:Array*/) {\n var o = new_buf(8);\n o.write_shift(4, 0);\n o.write_shift(2, guts[0] ? guts[0] + 1 : 0);\n o.write_shift(2, guts[1] ? guts[1] + 1 : 0);\n return o;\n}\n\n/* [MS-XLS] 2.4.24 */\nfunction parse_BoolErr(blob, length, opts) {\n var cell = parse_XLSCell(blob, 6);\n if (opts.biff == 2 || length == 9) ++blob.l;\n var val = parse_Bes(blob, 2);\n cell.val = val;\n cell.t = val === true || val === false ? 'b' : 'e';\n return cell;\n}\nfunction write_BoolErr(R /*:number*/, C /*:number*/, v, os /*:number*/, opts, t /*:string*/) {\n var o = new_buf(8);\n write_XLSCell(R, C, os, o);\n write_Bes(v, t, o);\n return o;\n}\n\n/* [MS-XLS] 2.4.180 Number */\nfunction parse_Number(blob, length, opts) {\n if (opts.biffguess && opts.biff == 2) opts.biff = 5;\n var cell = parse_XLSCell(blob, 6);\n var xnum = parse_Xnum(blob, 8);\n cell.val = xnum;\n return cell;\n}\nfunction write_Number(R /*:number*/, C /*:number*/, v, os /*:: :number, opts*/) {\n var o = new_buf(14);\n write_XLSCell(R, C, os, o);\n write_Xnum(v, o);\n return o;\n}\nvar parse_XLHeaderFooter = parse_OptXLUnicodeString; // TODO: parse 2.4.136\n\n/* [MS-XLS] 2.4.271 */\nfunction parse_SupBook(blob, length, opts) {\n var end = blob.l + length;\n var ctab = blob.read_shift(2);\n var cch = blob.read_shift(2);\n opts.sbcch = cch;\n if (cch == 0x0401 || cch == 0x3A01) return [cch, ctab];\n if (cch < 0x01 || cch > 0xff) throw new Error(\"Unexpected SupBook type: \" + cch);\n var virtPath = parse_XLUnicodeStringNoCch(blob, cch);\n /* TODO: 2.5.277 Virtual Path */\n var rgst = [];\n while (end > blob.l) rgst.push(parse_XLUnicodeString(blob));\n return [cch, ctab, virtPath, rgst];\n}\n\n/* [MS-XLS] 2.4.105 TODO */\nfunction parse_ExternName(blob, length, opts) {\n var flags = blob.read_shift(2);\n var body;\n var o = {\n fBuiltIn: flags & 0x01,\n fWantAdvise: flags >>> 1 & 0x01,\n fWantPict: flags >>> 2 & 0x01,\n fOle: flags >>> 3 & 0x01,\n fOleLink: flags >>> 4 & 0x01,\n cf: flags >>> 5 & 0x3FF,\n fIcon: flags >>> 15 & 0x01\n } /*:any*/;\n if (opts.sbcch === 0x3A01) body = parse_AddinUdf(blob, length - 2, opts);\n //else throw new Error(\"unsupported SupBook cch: \" + opts.sbcch);\n o.body = body || blob.read_shift(length - 2);\n if (typeof body === \"string\") o.Name = body;\n return o;\n}\n\n/* [MS-XLS] 2.4.150 TODO */\nvar XLSLblBuiltIn = [\"_xlnm.Consolidate_Area\", \"_xlnm.Auto_Open\", \"_xlnm.Auto_Close\", \"_xlnm.Extract\", \"_xlnm.Database\", \"_xlnm.Criteria\", \"_xlnm.Print_Area\", \"_xlnm.Print_Titles\", \"_xlnm.Recorder\", \"_xlnm.Data_Form\", \"_xlnm.Auto_Activate\", \"_xlnm.Auto_Deactivate\", \"_xlnm.Sheet_Title\", \"_xlnm._FilterDatabase\"];\nfunction parse_Lbl(blob, length, opts) {\n var target = blob.l + length;\n var flags = blob.read_shift(2);\n var chKey = blob.read_shift(1);\n var cch = blob.read_shift(1);\n var cce = blob.read_shift(opts && opts.biff == 2 ? 1 : 2);\n var itab = 0;\n if (!opts || opts.biff >= 5) {\n if (opts.biff != 5) blob.l += 2;\n itab = blob.read_shift(2);\n if (opts.biff == 5) blob.l += 2;\n blob.l += 4;\n }\n var name = parse_XLUnicodeStringNoCch(blob, cch, opts);\n if (flags & 0x20) name = XLSLblBuiltIn[name.charCodeAt(0)];\n var npflen = target - blob.l;\n if (opts && opts.biff == 2) --npflen;\n /*jshint -W018 */\n var rgce = target == blob.l || cce === 0 || !(npflen > 0) ? [] : parse_NameParsedFormula(blob, npflen, opts, cce);\n /*jshint +W018 */\n return {\n chKey: chKey,\n Name: name,\n itab: itab,\n rgce: rgce\n };\n}\n\n/* [MS-XLS] 2.4.106 TODO: verify filename encoding */\nfunction parse_ExternSheet(blob, length, opts) {\n if (opts.biff < 8) return parse_BIFF5ExternSheet(blob, length, opts);\n var o = [],\n target = blob.l + length,\n len = blob.read_shift(opts.biff > 8 ? 4 : 2);\n while (len-- !== 0) o.push(parse_XTI(blob, opts.biff > 8 ? 12 : 6, opts));\n // [iSupBook, itabFirst, itabLast];\n if (blob.l != target) throw new Error(\"Bad ExternSheet: \" + blob.l + \" != \" + target);\n return o;\n}\nfunction parse_BIFF5ExternSheet(blob, length, opts) {\n if (blob[blob.l + 1] == 0x03) blob[blob.l]++;\n var o = parse_ShortXLUnicodeString(blob, length, opts);\n return o.charCodeAt(0) == 0x03 ? o.slice(1) : o;\n}\n\n/* [MS-XLS] 2.4.176 TODO: check older biff */\nfunction parse_NameCmt(blob, length, opts) {\n if (opts.biff < 8) {\n blob.l += length;\n return;\n }\n var cchName = blob.read_shift(2);\n var cchComment = blob.read_shift(2);\n var name = parse_XLUnicodeStringNoCch(blob, cchName, opts);\n var comment = parse_XLUnicodeStringNoCch(blob, cchComment, opts);\n return [name, comment];\n}\n\n/* [MS-XLS] 2.4.260 */\nfunction parse_ShrFmla(blob, length, opts) {\n var ref = parse_RefU(blob, 6);\n blob.l++;\n var cUse = blob.read_shift(1);\n length -= 8;\n return [parse_SharedParsedFormula(blob, length, opts), cUse, ref];\n}\n\n/* [MS-XLS] 2.4.4 TODO */\nfunction parse_Array(blob, length, opts) {\n var ref = parse_Ref(blob, 6);\n /* TODO: fAlwaysCalc */\n switch (opts.biff) {\n case 2:\n blob.l++;\n length -= 7;\n break;\n case 3:\n case 4:\n blob.l += 2;\n length -= 8;\n break;\n default:\n blob.l += 6;\n length -= 12;\n }\n return [ref, parse_ArrayParsedFormula(blob, length, opts, ref)];\n}\n\n/* [MS-XLS] 2.4.173 */\nfunction parse_MTRSettings(blob) {\n var fMTREnabled = blob.read_shift(4) !== 0x00;\n var fUserSetThreadCount = blob.read_shift(4) !== 0x00;\n var cUserThreadCount = blob.read_shift(4);\n return [fMTREnabled, fUserSetThreadCount, cUserThreadCount];\n}\n\n/* [MS-XLS] 2.5.186 TODO: BIFF5 */\nfunction parse_NoteSh(blob, length, opts) {\n if (opts.biff < 8) return;\n var row = blob.read_shift(2),\n col = blob.read_shift(2);\n var flags = blob.read_shift(2),\n idObj = blob.read_shift(2);\n var stAuthor = parse_XLUnicodeString2(blob, 0, opts);\n if (opts.biff < 8) blob.read_shift(1);\n return [{\n r: row,\n c: col\n }, stAuthor, idObj, flags];\n}\n\n/* [MS-XLS] 2.4.179 */\nfunction parse_Note(blob, length, opts) {\n /* TODO: Support revisions */\n return parse_NoteSh(blob, length, opts);\n}\n\n/* [MS-XLS] 2.4.168 */\nfunction parse_MergeCells(blob, length) /*:Array*/{\n var merges /*:Array*/ = [];\n var cmcs = blob.read_shift(2);\n while (cmcs--) merges.push(parse_Ref8U(blob, length));\n return merges;\n}\nfunction write_MergeCells(merges /*:Array*/) {\n var o = new_buf(2 + merges.length * 8);\n o.write_shift(2, merges.length);\n for (var i = 0; i < merges.length; ++i) write_Ref8U(merges[i], o);\n return o;\n}\n\n/* [MS-XLS] 2.4.181 TODO: parse all the things! */\nfunction parse_Obj(blob, length, opts) {\n if (opts && opts.biff < 8) return parse_BIFF5Obj(blob, length, opts);\n var cmo = parse_FtCmo(blob, 22); // id, ot, flags\n var fts = parse_FtArray(blob, length - 22, cmo[1]);\n return {\n cmo: cmo,\n ft: fts\n };\n}\n/* from older spec */\nvar parse_BIFF5OT = {\n 0x08: function (blob, length) {\n var tgt = blob.l + length;\n blob.l += 10; // todo\n var cf = blob.read_shift(2);\n blob.l += 4;\n blob.l += 2; //var cbPictFmla = blob.read_shift(2);\n blob.l += 2;\n blob.l += 2; //var grbit = blob.read_shift(2);\n blob.l += 4;\n var cchName = blob.read_shift(1);\n blob.l += cchName; // TODO: stName\n blob.l = tgt; // TODO: fmla\n return {\n fmt: cf\n };\n }\n};\nfunction parse_BIFF5Obj(blob, length, opts) {\n blob.l += 4; //var cnt = blob.read_shift(4);\n var ot = blob.read_shift(2);\n var id = blob.read_shift(2);\n var grbit = blob.read_shift(2);\n blob.l += 2; //var colL = blob.read_shift(2);\n blob.l += 2; //var dxL = blob.read_shift(2);\n blob.l += 2; //var rwT = blob.read_shift(2);\n blob.l += 2; //var dyT = blob.read_shift(2);\n blob.l += 2; //var colR = blob.read_shift(2);\n blob.l += 2; //var dxR = blob.read_shift(2);\n blob.l += 2; //var rwB = blob.read_shift(2);\n blob.l += 2; //var dyB = blob.read_shift(2);\n blob.l += 2; //var cbMacro = blob.read_shift(2);\n blob.l += 6;\n length -= 36;\n var fts = [];\n fts.push((parse_BIFF5OT[ot] || parsenoop)(blob, length, opts));\n return {\n cmo: [id, ot, grbit],\n ft: fts\n };\n}\n\n/* [MS-XLS] 2.4.329 TODO: parse properly */\nfunction parse_TxO(blob, length, opts) {\n var s = blob.l;\n var texts = \"\";\n try {\n blob.l += 4;\n var ot = (opts.lastobj || {\n cmo: [0, 0]\n }).cmo[1];\n var controlInfo; // eslint-disable-line no-unused-vars\n if ([0, 5, 7, 11, 12, 14].indexOf(ot) == -1) blob.l += 6;else controlInfo = parse_ControlInfo(blob, 6, opts); // eslint-disable-line no-unused-vars\n var cchText = blob.read_shift(2);\n /*var cbRuns = */\n blob.read_shift(2);\n /*var ifntEmpty = */\n parseuint16(blob, 2);\n var len = blob.read_shift(2);\n blob.l += len;\n //var fmla = parse_ObjFmla(blob, s + length - blob.l);\n\n for (var i = 1; i < blob.lens.length - 1; ++i) {\n if (blob.l - s != blob.lens[i]) throw new Error(\"TxO: bad continue record\");\n var hdr = blob[blob.l];\n var t = parse_XLUnicodeStringNoCch(blob, blob.lens[i + 1] - blob.lens[i] - 1);\n texts += t;\n if (texts.length >= (hdr ? cchText : 2 * cchText)) break;\n }\n if (texts.length !== cchText && texts.length !== cchText * 2) {\n throw new Error(\"cchText: \" + cchText + \" != \" + texts.length);\n }\n blob.l = s + length;\n /* [MS-XLS] 2.5.272 TxORuns */\n //\tvar rgTxoRuns = [];\n //\tfor(var j = 0; j != cbRuns/8-1; ++j) blob.l += 8;\n //\tvar cchText2 = blob.read_shift(2);\n //\tif(cchText2 !== cchText) throw new Error(\"TxOLastRun mismatch: \" + cchText2 + \" \" + cchText);\n //\tblob.l += 6;\n //\tif(s + length != blob.l) throw new Error(\"TxO \" + (s + length) + \", at \" + blob.l);\n return {\n t: texts\n };\n } catch (e) {\n blob.l = s + length;\n return {\n t: texts\n };\n }\n}\n\n/* [MS-XLS] 2.4.140 */\nfunction parse_HLink(blob, length) {\n var ref = parse_Ref8U(blob, 8);\n blob.l += 16; /* CLSID */\n var hlink = parse_Hyperlink(blob, length - 24);\n return [ref, hlink];\n}\nfunction write_HLink(hl) {\n var O = new_buf(24);\n var ref = decode_cell(hl[0]);\n O.write_shift(2, ref.r);\n O.write_shift(2, ref.r);\n O.write_shift(2, ref.c);\n O.write_shift(2, ref.c);\n var clsid = \"d0 c9 ea 79 f9 ba ce 11 8c 82 00 aa 00 4b a9 0b\".split(\" \");\n for (var i = 0; i < 16; ++i) O.write_shift(1, parseInt(clsid[i], 16));\n return bconcat([O, write_Hyperlink(hl[1])]);\n}\n\n/* [MS-XLS] 2.4.141 */\nfunction parse_HLinkTooltip(blob, length) {\n blob.read_shift(2);\n var ref = parse_Ref8U(blob, 8);\n var wzTooltip = blob.read_shift((length - 10) / 2, 'dbcs-cont');\n wzTooltip = wzTooltip.replace(chr0, \"\");\n return [ref, wzTooltip];\n}\nfunction write_HLinkTooltip(hl) {\n var TT = hl[1].Tooltip;\n var O = new_buf(10 + 2 * (TT.length + 1));\n O.write_shift(2, 0x0800);\n var ref = decode_cell(hl[0]);\n O.write_shift(2, ref.r);\n O.write_shift(2, ref.r);\n O.write_shift(2, ref.c);\n O.write_shift(2, ref.c);\n for (var i = 0; i < TT.length; ++i) O.write_shift(2, TT.charCodeAt(i));\n O.write_shift(2, 0);\n return O;\n}\n\n/* [MS-XLS] 2.4.63 */\nfunction parse_Country(blob) /*:[string|number, string|number]*/{\n var o = [0, 0],\n d;\n d = blob.read_shift(2);\n o[0] = CountryEnum[d] || d;\n d = blob.read_shift(2);\n o[1] = CountryEnum[d] || d;\n return o;\n}\nfunction write_Country(o) {\n if (!o) o = new_buf(4);\n o.write_shift(2, 0x01);\n o.write_shift(2, 0x01);\n return o;\n}\n\n/* [MS-XLS] 2.4.50 ClrtClient */\nfunction parse_ClrtClient(blob) {\n var ccv = blob.read_shift(2);\n var o = [];\n while (ccv-- > 0) o.push(parse_LongRGB(blob, 8));\n return o;\n}\n\n/* [MS-XLS] 2.4.188 */\nfunction parse_Palette(blob) {\n var ccv = blob.read_shift(2);\n var o = [];\n while (ccv-- > 0) o.push(parse_LongRGB(blob, 8));\n return o;\n}\n\n/* [MS-XLS] 2.4.354 */\nfunction parse_XFCRC(blob) {\n blob.l += 2;\n var o = {\n cxfs: 0,\n crc: 0\n };\n o.cxfs = blob.read_shift(2);\n o.crc = blob.read_shift(4);\n return o;\n}\n\n/* [MS-XLS] 2.4.53 TODO: parse flags */\n/* [MS-XLSB] 2.4.323 TODO: parse flags */\nfunction parse_ColInfo(blob, length, opts) {\n if (!opts.cellStyles) return parsenoop(blob, length);\n var w = opts && opts.biff >= 12 ? 4 : 2;\n var colFirst = blob.read_shift(w);\n var colLast = blob.read_shift(w);\n var coldx = blob.read_shift(w);\n var ixfe = blob.read_shift(w);\n var flags = blob.read_shift(2);\n if (w == 2) blob.l += 2;\n var o = {\n s: colFirst,\n e: colLast,\n w: coldx,\n ixfe: ixfe,\n flags: flags\n } /*:any*/;\n if (opts.biff >= 5 || !opts.biff) o.level = flags >> 8 & 0x7;\n return o;\n}\nfunction write_ColInfo(col, idx) {\n var o = new_buf(12);\n o.write_shift(2, idx);\n o.write_shift(2, idx);\n o.write_shift(2, col.width * 256);\n o.write_shift(2, 0);\n var f = 0;\n if (col.hidden) f |= 1;\n o.write_shift(1, f);\n f = col.level || 0;\n o.write_shift(1, f);\n o.write_shift(2, 0);\n return o;\n}\n\n/* [MS-XLS] 2.4.257 */\nfunction parse_Setup(blob, length) {\n var o = {};\n if (length < 32) return o;\n blob.l += 16;\n o.header = parse_Xnum(blob, 8);\n o.footer = parse_Xnum(blob, 8);\n blob.l += 2;\n return o;\n}\n\n/* [MS-XLS] 2.4.261 */\nfunction parse_ShtProps(blob, length, opts) {\n var def = {\n area: false\n };\n if (opts.biff != 5) {\n blob.l += length;\n return def;\n }\n var d = blob.read_shift(1);\n blob.l += 3;\n if (d & 0x10) def.area = true;\n return def;\n}\n\n/* [MS-XLS] 2.4.241 */\nfunction write_RRTabId(n /*:number*/) {\n var out = new_buf(2 * n);\n for (var i = 0; i < n; ++i) out.write_shift(2, i + 1);\n return out;\n}\nvar parse_Blank = parse_XLSCell; /* [MS-XLS] 2.4.20 Just the cell */\nvar parse_Scl = parseuint16a; /* [MS-XLS] 2.4.247 num, den */\nvar parse_String = parse_XLUnicodeString; /* [MS-XLS] 2.4.268 */\n\n/* --- Specific to versions before BIFF8 --- */\nfunction parse_ImData(blob) {\n var cf = blob.read_shift(2);\n var env = blob.read_shift(2);\n var lcb = blob.read_shift(4);\n var o = {\n fmt: cf,\n env: env,\n len: lcb,\n data: blob.slice(blob.l, blob.l + lcb)\n };\n blob.l += lcb;\n return o;\n}\n\n/* BIFF2_??? where ??? is the name from [XLS] */\nfunction parse_BIFF2STR(blob, length, opts) {\n if (opts.biffguess && opts.biff == 5) opts.biff = 2;\n var cell = parse_XLSCell(blob, 6);\n ++blob.l;\n var str = parse_XLUnicodeString2(blob, length - 7, opts);\n cell.t = 'str';\n cell.val = str;\n return cell;\n}\nfunction parse_BIFF2NUM(blob /*::, length*/) {\n var cell = parse_XLSCell(blob, 6);\n ++blob.l;\n var num = parse_Xnum(blob, 8);\n cell.t = 'n';\n cell.val = num;\n return cell;\n}\nfunction write_BIFF2NUM(r /*:number*/, c /*:number*/, val /*:number*/) {\n var out = new_buf(15);\n write_BIFF2Cell(out, r, c);\n out.write_shift(8, val, 'f');\n return out;\n}\nfunction parse_BIFF2INT(blob) {\n var cell = parse_XLSCell(blob, 6);\n ++blob.l;\n var num = blob.read_shift(2);\n cell.t = 'n';\n cell.val = num;\n return cell;\n}\nfunction write_BIFF2INT(r /*:number*/, c /*:number*/, val /*:number*/) {\n var out = new_buf(9);\n write_BIFF2Cell(out, r, c);\n out.write_shift(2, val);\n return out;\n}\nfunction parse_BIFF2STRING(blob) {\n var cch = blob.read_shift(1);\n if (cch === 0) {\n blob.l++;\n return \"\";\n }\n return blob.read_shift(cch, 'sbcs-cont');\n}\n\n/* TODO: convert to BIFF8 font struct */\nfunction parse_BIFF2FONTXTRA(blob, length) {\n blob.l += 6; // unknown\n blob.l += 2; // font weight \"bls\"\n blob.l += 1; // charset\n blob.l += 3; // unknown\n blob.l += 1; // font family\n blob.l += length - 13;\n}\n\n/* TODO: parse rich text runs */\nfunction parse_RString(blob, length, opts) {\n var end = blob.l + length;\n var cell = parse_XLSCell(blob, 6);\n var cch = blob.read_shift(2);\n var str = parse_XLUnicodeStringNoCch(blob, cch, opts);\n blob.l = end;\n cell.t = 'str';\n cell.val = str;\n return cell;\n}\n/* from js-harb (C) 2014-present SheetJS */\nvar DBF_SUPPORTED_VERSIONS = [0x02, 0x03, 0x30, 0x31, 0x83, 0x8B, 0x8C, 0xF5];\nvar DBF = /*#__PURE__*/function () {\n var dbf_codepage_map = {\n /* Code Pages Supported by Visual FoxPro */\n /*::[*/0x01 /*::]*/: 437,\n /*::[*/0x02 /*::]*/: 850,\n /*::[*/0x03 /*::]*/: 1252,\n /*::[*/0x04 /*::]*/: 10000,\n /*::[*/0x64 /*::]*/: 852,\n /*::[*/0x65 /*::]*/: 866,\n /*::[*/0x66 /*::]*/: 865,\n /*::[*/0x67 /*::]*/: 861,\n /*::[*/0x68 /*::]*/: 895,\n /*::[*/0x69 /*::]*/: 620,\n /*::[*/0x6A /*::]*/: 737,\n /*::[*/0x6B /*::]*/: 857,\n /*::[*/0x78 /*::]*/: 950,\n /*::[*/0x79 /*::]*/: 949,\n /*::[*/0x7A /*::]*/: 936,\n /*::[*/0x7B /*::]*/: 932,\n /*::[*/0x7C /*::]*/: 874,\n /*::[*/0x7D /*::]*/: 1255,\n /*::[*/0x7E /*::]*/: 1256,\n /*::[*/0x96 /*::]*/: 10007,\n /*::[*/0x97 /*::]*/: 10029,\n /*::[*/0x98 /*::]*/: 10006,\n /*::[*/0xC8 /*::]*/: 1250,\n /*::[*/0xC9 /*::]*/: 1251,\n /*::[*/0xCA /*::]*/: 1254,\n /*::[*/0xCB /*::]*/: 1253,\n /* shapefile DBF extension */\n /*::[*/0x00 /*::]*/: 20127,\n /*::[*/0x08 /*::]*/: 865,\n /*::[*/0x09 /*::]*/: 437,\n /*::[*/0x0A /*::]*/: 850,\n /*::[*/0x0B /*::]*/: 437,\n /*::[*/0x0D /*::]*/: 437,\n /*::[*/0x0E /*::]*/: 850,\n /*::[*/0x0F /*::]*/: 437,\n /*::[*/0x10 /*::]*/: 850,\n /*::[*/0x11 /*::]*/: 437,\n /*::[*/0x12 /*::]*/: 850,\n /*::[*/0x13 /*::]*/: 932,\n /*::[*/0x14 /*::]*/: 850,\n /*::[*/0x15 /*::]*/: 437,\n /*::[*/0x16 /*::]*/: 850,\n /*::[*/0x17 /*::]*/: 865,\n /*::[*/0x18 /*::]*/: 437,\n /*::[*/0x19 /*::]*/: 437,\n /*::[*/0x1A /*::]*/: 850,\n /*::[*/0x1B /*::]*/: 437,\n /*::[*/0x1C /*::]*/: 863,\n /*::[*/0x1D /*::]*/: 850,\n /*::[*/0x1F /*::]*/: 852,\n /*::[*/0x22 /*::]*/: 852,\n /*::[*/0x23 /*::]*/: 852,\n /*::[*/0x24 /*::]*/: 860,\n /*::[*/0x25 /*::]*/: 850,\n /*::[*/0x26 /*::]*/: 866,\n /*::[*/0x37 /*::]*/: 850,\n /*::[*/0x40 /*::]*/: 852,\n /*::[*/0x4D /*::]*/: 936,\n /*::[*/0x4E /*::]*/: 949,\n /*::[*/0x4F /*::]*/: 950,\n /*::[*/0x50 /*::]*/: 874,\n /*::[*/0x57 /*::]*/: 1252,\n /*::[*/0x58 /*::]*/: 1252,\n /*::[*/0x59 /*::]*/: 1252,\n /*::[*/0x6C /*::]*/: 863,\n /*::[*/0x86 /*::]*/: 737,\n /*::[*/0x87 /*::]*/: 852,\n /*::[*/0x88 /*::]*/: 857,\n /*::[*/0xCC /*::]*/: 1257,\n /*::[*/0xFF /*::]*/: 16969\n };\n var dbf_reverse_map = evert({\n /*::[*/0x01 /*::]*/: 437,\n /*::[*/0x02 /*::]*/: 850,\n /*::[*/0x03 /*::]*/: 1252,\n /*::[*/0x04 /*::]*/: 10000,\n /*::[*/0x64 /*::]*/: 852,\n /*::[*/0x65 /*::]*/: 866,\n /*::[*/0x66 /*::]*/: 865,\n /*::[*/0x67 /*::]*/: 861,\n /*::[*/0x68 /*::]*/: 895,\n /*::[*/0x69 /*::]*/: 620,\n /*::[*/0x6A /*::]*/: 737,\n /*::[*/0x6B /*::]*/: 857,\n /*::[*/0x78 /*::]*/: 950,\n /*::[*/0x79 /*::]*/: 949,\n /*::[*/0x7A /*::]*/: 936,\n /*::[*/0x7B /*::]*/: 932,\n /*::[*/0x7C /*::]*/: 874,\n /*::[*/0x7D /*::]*/: 1255,\n /*::[*/0x7E /*::]*/: 1256,\n /*::[*/0x96 /*::]*/: 10007,\n /*::[*/0x97 /*::]*/: 10029,\n /*::[*/0x98 /*::]*/: 10006,\n /*::[*/0xC8 /*::]*/: 1250,\n /*::[*/0xC9 /*::]*/: 1251,\n /*::[*/0xCA /*::]*/: 1254,\n /*::[*/0xCB /*::]*/: 1253,\n /*::[*/0x00 /*::]*/: 20127\n });\n /* TODO: find an actual specification */\n function dbf_to_aoa(buf, opts) /*:AOA*/{\n var out /*:AOA*/ = [];\n var d /*:Block*/ = new_raw_buf(1) /*:any*/;\n switch (opts.type) {\n case 'base64':\n d = s2a(Base64_decode(buf));\n break;\n case 'binary':\n d = s2a(buf);\n break;\n case 'buffer':\n case 'array':\n d = buf;\n break;\n }\n prep_blob(d, 0);\n\n /* header */\n var ft = d.read_shift(1);\n var memo = !!(ft & 0x88);\n var vfp = false,\n l7 = false;\n switch (ft) {\n case 0x02:\n break;\n // dBASE II\n case 0x03:\n break;\n // dBASE III\n case 0x30:\n vfp = true;\n memo = true;\n break;\n // VFP\n case 0x31:\n vfp = true;\n memo = true;\n break;\n // VFP with autoincrement\n // 0x43 dBASE IV SQL table files\n // 0x63 dBASE IV SQL system files\n case 0x83:\n break;\n // dBASE III with memo\n case 0x8B:\n break;\n // dBASE IV with memo\n case 0x8C:\n l7 = true;\n break;\n // dBASE Level 7 with memo\n // case 0xCB dBASE IV SQL table files with memo\n case 0xF5:\n break;\n // FoxPro 2.x with memo\n // case 0xFB FoxBASE\n default:\n throw new Error(\"DBF Unsupported Version: \" + ft.toString(16));\n }\n var nrow = 0,\n fpos = 0x0209;\n if (ft == 0x02) nrow = d.read_shift(2);\n d.l += 3; // dBASE II stores DDMMYY date, others use YYMMDD\n if (ft != 0x02) nrow = d.read_shift(4);\n if (nrow > 1048576) nrow = 1e6;\n if (ft != 0x02) fpos = d.read_shift(2); // header length\n var rlen = d.read_shift(2); // record length\n\n var /*flags = 0,*/current_cp = opts.codepage || 1252;\n if (ft != 0x02) {\n // 20 reserved bytes\n d.l += 16;\n /*flags = */\n d.read_shift(1);\n //if(memo && ((flags & 0x02) === 0)) throw new Error(\"DBF Flags \" + flags.toString(16) + \" ft \" + ft.toString(16));\n\n /* codepage present in FoxPro and dBASE Level 7 */\n if (d[d.l] !== 0) current_cp = dbf_codepage_map[d[d.l]];\n d.l += 1;\n d.l += 2;\n }\n if (l7) d.l += 36; // Level 7: 32 byte \"Language driver name\", 4 byte reserved\n\n /*:: type DBFField = { name:string; len:number; type:string; } */\n var fields /*:Array*/ = [],\n field /*:DBFField*/ = {} /*:any*/;\n var hend = Math.min(d.length, ft == 0x02 ? 0x209 : fpos - 10 - (vfp ? 264 : 0));\n var ww = l7 ? 32 : 11;\n while (d.l < hend && d[d.l] != 0x0d) {\n field = {} /*:any*/;\n field.name = $cptable.utils.decode(current_cp, d.slice(d.l, d.l + ww)).replace(/[\\u0000\\r\\n].*$/g, \"\");\n d.l += ww;\n field.type = String.fromCharCode(d.read_shift(1));\n if (ft != 0x02 && !l7) field.offset = d.read_shift(4);\n field.len = d.read_shift(1);\n if (ft == 0x02) field.offset = d.read_shift(2);\n field.dec = d.read_shift(1);\n if (field.name.length) fields.push(field);\n if (ft != 0x02) d.l += l7 ? 13 : 14;\n switch (field.type) {\n case 'B':\n // Double (VFP) / Binary (dBASE L7)\n if ((!vfp || field.len != 8) && opts.WTF) console.log('Skipping ' + field.name + ':' + field.type);\n break;\n case 'G': // General (FoxPro and dBASE L7)\n case 'P':\n // Picture (FoxPro and dBASE L7)\n if (opts.WTF) console.log('Skipping ' + field.name + ':' + field.type);\n break;\n case '+': // Autoincrement (dBASE L7 only)\n case '0': // _NullFlags (VFP only)\n case '@': // Timestamp (dBASE L7 only)\n case 'C': // Character (dBASE II)\n case 'D': // Date (dBASE III)\n case 'F': // Float (dBASE IV)\n case 'I': // Long (VFP and dBASE L7)\n case 'L': // Logical (dBASE II)\n case 'M': // Memo (dBASE III)\n case 'N': // Number (dBASE II)\n case 'O': // Double (dBASE L7 only)\n case 'T': // Datetime (VFP only)\n case 'Y':\n // Currency (VFP only)\n break;\n default:\n throw new Error('Unknown Field Type: ' + field.type);\n }\n }\n if (d[d.l] !== 0x0D) d.l = fpos - 1;\n if (d.read_shift(1) !== 0x0D) throw new Error(\"DBF Terminator not found \" + d.l + \" \" + d[d.l]);\n d.l = fpos;\n\n /* data */\n var R = 0,\n C = 0;\n out[0] = [];\n for (C = 0; C != fields.length; ++C) out[0][C] = fields[C].name;\n while (nrow-- > 0) {\n if (d[d.l] === 0x2A) {\n // TODO: record marked as deleted -- create a hidden row?\n d.l += rlen;\n continue;\n }\n ++d.l;\n out[++R] = [];\n C = 0;\n for (C = 0; C != fields.length; ++C) {\n var dd = d.slice(d.l, d.l + fields[C].len);\n d.l += fields[C].len;\n prep_blob(dd, 0);\n var s = $cptable.utils.decode(current_cp, dd);\n switch (fields[C].type) {\n case 'C':\n // NOTE: it is conventional to write ' / / ' for empty dates\n if (s.trim().length) out[R][C] = s.replace(/\\s+$/, \"\");\n break;\n case 'D':\n if (s.length === 8) out[R][C] = new Date(+s.slice(0, 4), +s.slice(4, 6) - 1, +s.slice(6, 8));else out[R][C] = s;\n break;\n case 'F':\n out[R][C] = parseFloat(s.trim());\n break;\n case '+':\n case 'I':\n out[R][C] = l7 ? dd.read_shift(-4, 'i') ^ 0x80000000 : dd.read_shift(4, 'i');\n break;\n case 'L':\n switch (s.trim().toUpperCase()) {\n case 'Y':\n case 'T':\n out[R][C] = true;\n break;\n case 'N':\n case 'F':\n out[R][C] = false;\n break;\n case '':\n case '?':\n break;\n default:\n throw new Error(\"DBF Unrecognized L:|\" + s + \"|\");\n }\n break;\n case 'M':\n /* TODO: handle memo files */\n if (!memo) throw new Error(\"DBF Unexpected MEMO for type \" + ft.toString(16));\n out[R][C] = \"##MEMO##\" + (l7 ? parseInt(s.trim(), 10) : dd.read_shift(4));\n break;\n case 'N':\n s = s.replace(/\\u0000/g, \"\").trim();\n // NOTE: dBASE II interprets \" . \" as 0\n if (s && s != \".\") out[R][C] = +s || 0;\n break;\n case '@':\n // NOTE: dBASE specs appear to be incorrect\n out[R][C] = new Date(dd.read_shift(-8, 'f') - 0x388317533400);\n break;\n case 'T':\n out[R][C] = new Date((dd.read_shift(4) - 0x253D8C) * 0x5265C00 + dd.read_shift(4));\n break;\n case 'Y':\n out[R][C] = dd.read_shift(4, 'i') / 1e4 + dd.read_shift(4, 'i') / 1e4 * Math.pow(2, 32);\n break;\n case 'O':\n out[R][C] = -dd.read_shift(-8, 'f');\n break;\n case 'B':\n if (vfp && fields[C].len == 8) {\n out[R][C] = dd.read_shift(8, 'f');\n break;\n }\n /* falls through */\n case 'G':\n case 'P':\n dd.l += fields[C].len;\n break;\n case '0':\n if (fields[C].name === '_NullFlags') break;\n /* falls through */\n default:\n throw new Error(\"DBF Unsupported data type \" + fields[C].type);\n }\n }\n }\n if (ft != 0x02) if (d.l < d.length && d[d.l++] != 0x1A) throw new Error(\"DBF EOF Marker missing \" + (d.l - 1) + \" of \" + d.length + \" \" + d[d.l - 1].toString(16));\n if (opts && opts.sheetRows) out = out.slice(0, opts.sheetRows);\n opts.DBF = fields;\n return out;\n }\n function dbf_to_sheet(buf, opts) /*:Worksheet*/{\n var o = opts || {};\n if (!o.dateNF) o.dateNF = \"yyyymmdd\";\n var ws = aoa_to_sheet(dbf_to_aoa(buf, o), o);\n ws[\"!cols\"] = o.DBF.map(function (field) {\n return {\n wch: field.len,\n DBF: field\n };\n });\n delete o.DBF;\n return ws;\n }\n function dbf_to_workbook(buf, opts) /*:Workbook*/{\n try {\n return sheet_to_workbook(dbf_to_sheet(buf, opts), opts);\n } catch (e) {\n if (opts && opts.WTF) throw e;\n }\n return {\n SheetNames: [],\n Sheets: {}\n };\n }\n var _RLEN = {\n 'B': 8,\n 'C': 250,\n 'L': 1,\n 'D': 8,\n '?': 0,\n '': 0\n };\n function sheet_to_dbf(ws /*:Worksheet*/, opts /*:WriteOpts*/) {\n var o = opts || {};\n if (+o.codepage >= 0) set_cp(+o.codepage);\n if (o.type == \"string\") throw new Error(\"Cannot write DBF to JS string\");\n var ba = buf_array();\n var aoa /*:AOA*/ = sheet_to_json(ws, {\n header: 1,\n raw: true,\n cellDates: true\n });\n var headers = aoa[0],\n data = aoa.slice(1),\n cols = ws[\"!cols\"] || [];\n var i = 0,\n j = 0,\n hcnt = 0,\n rlen = 1;\n for (i = 0; i < headers.length; ++i) {\n if (((cols[i] || {}).DBF || {}).name) {\n headers[i] = cols[i].DBF.name;\n ++hcnt;\n continue;\n }\n if (headers[i] == null) continue;\n ++hcnt;\n if (typeof headers[i] === 'number') headers[i] = headers[i].toString(10);\n if (typeof headers[i] !== 'string') throw new Error(\"DBF Invalid column name \" + headers[i] + \" |\" + typeof headers[i] + \"|\");\n if (headers.indexOf(headers[i]) !== i) for (j = 0; j < 1024; ++j) if (headers.indexOf(headers[i] + \"_\" + j) == -1) {\n headers[i] += \"_\" + j;\n break;\n }\n }\n var range = safe_decode_range(ws['!ref']);\n var coltypes /*:Array*/ = [];\n var colwidths /*:Array*/ = [];\n var coldecimals /*:Array*/ = [];\n for (i = 0; i <= range.e.c - range.s.c; ++i) {\n var guess = '',\n _guess = '',\n maxlen = 0;\n var col /*:Array*/ = [];\n for (j = 0; j < data.length; ++j) {\n if (data[j][i] != null) col.push(data[j][i]);\n }\n if (col.length == 0 || headers[i] == null) {\n coltypes[i] = '?';\n continue;\n }\n for (j = 0; j < col.length; ++j) {\n switch (typeof col[j]) {\n /* TODO: check if L2 compat is desired */\n case 'number':\n _guess = 'B';\n break;\n case 'string':\n _guess = 'C';\n break;\n case 'boolean':\n _guess = 'L';\n break;\n case 'object':\n _guess = col[j] instanceof Date ? 'D' : 'C';\n break;\n default:\n _guess = 'C';\n }\n maxlen = Math.max(maxlen, String(col[j]).length);\n guess = guess && guess != _guess ? 'C' : _guess;\n //if(guess == 'C') break;\n }\n if (maxlen > 250) maxlen = 250;\n _guess = ((cols[i] || {}).DBF || {}).type;\n /* TODO: more fine grained control over DBF type resolution */\n if (_guess == 'C') {\n if (cols[i].DBF.len > maxlen) maxlen = cols[i].DBF.len;\n }\n if (guess == 'B' && _guess == 'N') {\n guess = 'N';\n coldecimals[i] = cols[i].DBF.dec;\n maxlen = cols[i].DBF.len;\n }\n colwidths[i] = guess == 'C' || _guess == 'N' ? maxlen : _RLEN[guess] || 0;\n rlen += colwidths[i];\n coltypes[i] = guess;\n }\n var h = ba.next(32);\n h.write_shift(4, 0x13021130);\n h.write_shift(4, data.length);\n h.write_shift(2, 296 + 32 * hcnt);\n h.write_shift(2, rlen);\n for (i = 0; i < 4; ++i) h.write_shift(4, 0);\n h.write_shift(4, 0x00000000 | (+dbf_reverse_map[/*::String(*/current_ansi /*::)*/] || 0x03) << 8);\n for (i = 0, j = 0; i < headers.length; ++i) {\n if (headers[i] == null) continue;\n var hf = ba.next(32);\n var _f = (headers[i].slice(-10) + \"\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\").slice(0, 11);\n hf.write_shift(1, _f, \"sbcs\");\n hf.write_shift(1, coltypes[i] == '?' ? 'C' : coltypes[i], \"sbcs\");\n hf.write_shift(4, j);\n hf.write_shift(1, colwidths[i] || _RLEN[coltypes[i]] || 0);\n hf.write_shift(1, coldecimals[i] || 0);\n hf.write_shift(1, 0x02);\n hf.write_shift(4, 0);\n hf.write_shift(1, 0);\n hf.write_shift(4, 0);\n hf.write_shift(4, 0);\n j += colwidths[i] || _RLEN[coltypes[i]] || 0;\n }\n var hb = ba.next(264);\n hb.write_shift(4, 0x0000000D);\n for (i = 0; i < 65; ++i) hb.write_shift(4, 0x00000000);\n for (i = 0; i < data.length; ++i) {\n var rout = ba.next(rlen);\n rout.write_shift(1, 0);\n for (j = 0; j < headers.length; ++j) {\n if (headers[j] == null) continue;\n switch (coltypes[j]) {\n case 'L':\n rout.write_shift(1, data[i][j] == null ? 0x3F : data[i][j] ? 0x54 : 0x46);\n break;\n case 'B':\n rout.write_shift(8, data[i][j] || 0, 'f');\n break;\n case 'N':\n var _n = \"0\";\n if (typeof data[i][j] == \"number\") _n = data[i][j].toFixed(coldecimals[j] || 0);\n for (hcnt = 0; hcnt < colwidths[j] - _n.length; ++hcnt) rout.write_shift(1, 0x20);\n rout.write_shift(1, _n, \"sbcs\");\n break;\n case 'D':\n if (!data[i][j]) rout.write_shift(8, \"00000000\", \"sbcs\");else {\n rout.write_shift(4, (\"0000\" + data[i][j].getFullYear()).slice(-4), \"sbcs\");\n rout.write_shift(2, (\"00\" + (data[i][j].getMonth() + 1)).slice(-2), \"sbcs\");\n rout.write_shift(2, (\"00\" + data[i][j].getDate()).slice(-2), \"sbcs\");\n }\n break;\n case 'C':\n var _s = String(data[i][j] != null ? data[i][j] : \"\").slice(0, colwidths[j]);\n rout.write_shift(1, _s, \"sbcs\");\n for (hcnt = 0; hcnt < colwidths[j] - _s.length; ++hcnt) rout.write_shift(1, 0x20);\n break;\n }\n }\n // data\n }\n ba.next(1).write_shift(1, 0x1A);\n return ba.end();\n }\n return {\n to_workbook: dbf_to_workbook,\n to_sheet: dbf_to_sheet,\n from_sheet: sheet_to_dbf\n };\n}();\nvar SYLK = /*#__PURE__*/function () {\n /* TODO: stress test sequences */\n var sylk_escapes = {\n AA: 'À',\n BA: 'Á',\n CA: 'Â',\n DA: 195,\n HA: 'Ä',\n JA: 197,\n AE: 'È',\n BE: 'É',\n CE: 'Ê',\n HE: 'Ë',\n AI: 'Ì',\n BI: 'Í',\n CI: 'Î',\n HI: 'Ï',\n AO: 'Ò',\n BO: 'Ó',\n CO: 'Ô',\n DO: 213,\n HO: 'Ö',\n AU: 'Ù',\n BU: 'Ú',\n CU: 'Û',\n HU: 'Ü',\n Aa: 'à',\n Ba: 'á',\n Ca: 'â',\n Da: 227,\n Ha: 'ä',\n Ja: 229,\n Ae: 'è',\n Be: 'é',\n Ce: 'ê',\n He: 'ë',\n Ai: 'ì',\n Bi: 'í',\n Ci: 'î',\n Hi: 'ï',\n Ao: 'ò',\n Bo: 'ó',\n Co: 'ô',\n Do: 245,\n Ho: 'ö',\n Au: 'ù',\n Bu: 'ú',\n Cu: 'û',\n Hu: 'ü',\n KC: 'Ç',\n Kc: 'ç',\n q: 'æ',\n z: 'œ',\n a: 'Æ',\n j: 'Œ',\n DN: 209,\n Dn: 241,\n Hy: 255,\n S: 169,\n c: 170,\n R: 174,\n \"B \": 180,\n /*::[*/0 /*::]*/: 176,\n /*::[*/1 /*::]*/: 177,\n /*::[*/2 /*::]*/: 178,\n /*::[*/3 /*::]*/: 179,\n /*::[*/5 /*::]*/: 181,\n /*::[*/6 /*::]*/: 182,\n /*::[*/7 /*::]*/: 183,\n Q: 185,\n k: 186,\n b: 208,\n i: 216,\n l: 222,\n s: 240,\n y: 248,\n \"!\": 161,\n '\"': 162,\n \"#\": 163,\n \"(\": 164,\n \"%\": 165,\n \"'\": 167,\n \"H \": 168,\n \"+\": 171,\n \";\": 187,\n \"<\": 188,\n \"=\": 189,\n \">\": 190,\n \"?\": 191,\n \"{\": 223\n } /*:any*/;\n var sylk_char_regex = new RegExp(\"\\u001BN(\" + keys(sylk_escapes).join(\"|\").replace(/\\|\\|\\|/, \"|\\\\||\").replace(/([?()+])/g, \"\\\\$1\") + \"|\\\\|)\", \"gm\");\n var sylk_char_fn = function (_, $1) {\n var o = sylk_escapes[$1];\n return typeof o == \"number\" ? _getansi(o) : o;\n };\n var decode_sylk_char = function ($$, $1, $2) {\n var newcc = $1.charCodeAt(0) - 0x20 << 4 | $2.charCodeAt(0) - 0x30;\n return newcc == 59 ? $$ : _getansi(newcc);\n };\n sylk_escapes[\"|\"] = 254;\n /* TODO: find an actual specification */\n function sylk_to_aoa(d /*:RawData*/, opts) /*:[AOA, Worksheet]*/{\n switch (opts.type) {\n case 'base64':\n return sylk_to_aoa_str(Base64_decode(d), opts);\n case 'binary':\n return sylk_to_aoa_str(d, opts);\n case 'buffer':\n return sylk_to_aoa_str(has_buf && Buffer.isBuffer(d) ? d.toString('binary') : a2s(d), opts);\n case 'array':\n return sylk_to_aoa_str(cc2str(d), opts);\n }\n throw new Error(\"Unrecognized type \" + opts.type);\n }\n function sylk_to_aoa_str(str /*:string*/, opts) /*:[AOA, Worksheet]*/{\n var records = str.split(/[\\n\\r]+/),\n R = -1,\n C = -1,\n ri = 0,\n rj = 0,\n arr /*:AOA*/ = [];\n var formats /*:Array*/ = [];\n var next_cell_format /*:string|null*/ = null;\n var sht = {},\n rowinfo /*:Array*/ = [],\n colinfo /*:Array*/ = [],\n cw /*:Array*/ = [];\n var Mval = 0,\n j;\n if (+opts.codepage >= 0) set_cp(+opts.codepage);\n for (; ri !== records.length; ++ri) {\n Mval = 0;\n var rstr = records[ri].trim().replace(/\\x1B([\\x20-\\x2F])([\\x30-\\x3F])/g, decode_sylk_char).replace(sylk_char_regex, sylk_char_fn);\n var record = rstr.replace(/;;/g, \"\\u0000\").split(\";\").map(function (x) {\n return x.replace(/\\u0000/g, \";\");\n });\n var RT = record[0],\n val;\n if (rstr.length > 0) switch (RT) {\n case 'ID':\n break;\n /* header */\n case 'E':\n break;\n /* EOF */\n case 'B':\n break;\n /* dimensions */\n case 'O':\n break;\n /* options? */\n case 'W':\n break;\n /* window? */\n case 'P':\n if (record[1].charAt(0) == 'P') formats.push(rstr.slice(3).replace(/;;/g, \";\"));\n break;\n case 'C':\n var C_seen_K = false,\n C_seen_X = false,\n C_seen_S = false,\n C_seen_E = false,\n _R = -1,\n _C = -1;\n for (rj = 1; rj < record.length; ++rj) switch (record[rj].charAt(0)) {\n case 'A':\n break;\n // TODO: comment\n case 'X':\n C = parseInt(record[rj].slice(1)) - 1;\n C_seen_X = true;\n break;\n case 'Y':\n R = parseInt(record[rj].slice(1)) - 1;\n if (!C_seen_X) C = 0;\n for (j = arr.length; j <= R; ++j) arr[j] = [];\n break;\n case 'K':\n val = record[rj].slice(1);\n if (val.charAt(0) === '\"') val = val.slice(1, val.length - 1);else if (val === 'TRUE') val = true;else if (val === 'FALSE') val = false;else if (!isNaN(fuzzynum(val))) {\n val = fuzzynum(val);\n if (next_cell_format !== null && fmt_is_date(next_cell_format)) val = numdate(val);\n } else if (!isNaN(fuzzydate(val).getDate())) {\n val = parseDate(val);\n }\n if (typeof $cptable !== 'undefined' && typeof val == \"string\" && (opts || {}).type != \"string\" && (opts || {}).codepage) val = $cptable.utils.decode(opts.codepage, val);\n C_seen_K = true;\n break;\n case 'E':\n C_seen_E = true;\n var formula = rc_to_a1(record[rj].slice(1), {\n r: R,\n c: C\n });\n arr[R][C] = [arr[R][C], formula];\n break;\n case 'S':\n C_seen_S = true;\n arr[R][C] = [arr[R][C], \"S5S\"];\n break;\n case 'G':\n break;\n // unknown\n case 'R':\n _R = parseInt(record[rj].slice(1)) - 1;\n break;\n case 'C':\n _C = parseInt(record[rj].slice(1)) - 1;\n break;\n default:\n if (opts && opts.WTF) throw new Error(\"SYLK bad record \" + rstr);\n }\n if (C_seen_K) {\n if (arr[R][C] && arr[R][C].length == 2) arr[R][C][0] = val;else arr[R][C] = val;\n next_cell_format = null;\n }\n if (C_seen_S) {\n if (C_seen_E) throw new Error(\"SYLK shared formula cannot have own formula\");\n var shrbase = _R > -1 && arr[_R][_C];\n if (!shrbase || !shrbase[1]) throw new Error(\"SYLK shared formula cannot find base\");\n arr[R][C][1] = shift_formula_str(shrbase[1], {\n r: R - _R,\n c: C - _C\n });\n }\n break;\n case 'F':\n var F_seen = 0;\n for (rj = 1; rj < record.length; ++rj) switch (record[rj].charAt(0)) {\n case 'X':\n C = parseInt(record[rj].slice(1)) - 1;\n ++F_seen;\n break;\n case 'Y':\n R = parseInt(record[rj].slice(1)) - 1; /*C = 0;*/\n for (j = arr.length; j <= R; ++j) arr[j] = [];\n break;\n case 'M':\n Mval = parseInt(record[rj].slice(1)) / 20;\n break;\n case 'F':\n break;\n /* ??? */\n case 'G':\n break;\n /* hide grid */\n case 'P':\n next_cell_format = formats[parseInt(record[rj].slice(1))];\n break;\n case 'S':\n break;\n /* cell style */\n case 'D':\n break;\n /* column */\n case 'N':\n break;\n /* font */\n case 'W':\n cw = record[rj].slice(1).split(\" \");\n for (j = parseInt(cw[0], 10); j <= parseInt(cw[1], 10); ++j) {\n Mval = parseInt(cw[2], 10);\n colinfo[j - 1] = Mval === 0 ? {\n hidden: true\n } : {\n wch: Mval\n };\n process_col(colinfo[j - 1]);\n }\n break;\n case 'C':\n /* default column format */\n C = parseInt(record[rj].slice(1)) - 1;\n if (!colinfo[C]) colinfo[C] = {};\n break;\n case 'R':\n /* row properties */\n R = parseInt(record[rj].slice(1)) - 1;\n if (!rowinfo[R]) rowinfo[R] = {};\n if (Mval > 0) {\n rowinfo[R].hpt = Mval;\n rowinfo[R].hpx = pt2px(Mval);\n } else if (Mval === 0) rowinfo[R].hidden = true;\n break;\n default:\n if (opts && opts.WTF) throw new Error(\"SYLK bad record \" + rstr);\n }\n if (F_seen < 1) next_cell_format = null;\n break;\n default:\n if (opts && opts.WTF) throw new Error(\"SYLK bad record \" + rstr);\n }\n }\n if (rowinfo.length > 0) sht['!rows'] = rowinfo;\n if (colinfo.length > 0) sht['!cols'] = colinfo;\n if (opts && opts.sheetRows) arr = arr.slice(0, opts.sheetRows);\n return [arr, sht];\n }\n function sylk_to_sheet(d /*:RawData*/, opts) /*:Worksheet*/{\n var aoasht = sylk_to_aoa(d, opts);\n var aoa = aoasht[0],\n ws = aoasht[1];\n var o = aoa_to_sheet(aoa, opts);\n keys(ws).forEach(function (k) {\n o[k] = ws[k];\n });\n return o;\n }\n function sylk_to_workbook(d /*:RawData*/, opts) /*:Workbook*/{\n return sheet_to_workbook(sylk_to_sheet(d, opts), opts);\n }\n function write_ws_cell_sylk(cell /*:Cell*/, ws /*:Worksheet*/, R /*:number*/, C /*:number*/ /*::, opts*/) /*:string*/{\n var o = \"C;Y\" + (R + 1) + \";X\" + (C + 1) + \";K\";\n switch (cell.t) {\n case 'n':\n o += cell.v || 0;\n if (cell.f && !cell.F) o += \";E\" + a1_to_rc(cell.f, {\n r: R,\n c: C\n });\n break;\n case 'b':\n o += cell.v ? \"TRUE\" : \"FALSE\";\n break;\n case 'e':\n o += cell.w || cell.v;\n break;\n case 'd':\n o += '\"' + (cell.w || cell.v) + '\"';\n break;\n case 's':\n o += '\"' + cell.v.replace(/\"/g, \"\").replace(/;/g, \";;\") + '\"';\n break;\n }\n return o;\n }\n function write_ws_cols_sylk(out, cols) {\n cols.forEach(function (col, i) {\n var rec = \"F;W\" + (i + 1) + \" \" + (i + 1) + \" \";\n if (col.hidden) rec += \"0\";else {\n if (typeof col.width == 'number' && !col.wpx) col.wpx = width2px(col.width);\n if (typeof col.wpx == 'number' && !col.wch) col.wch = px2char(col.wpx);\n if (typeof col.wch == 'number') rec += Math.round(col.wch);\n }\n if (rec.charAt(rec.length - 1) != \" \") out.push(rec);\n });\n }\n function write_ws_rows_sylk(out /*:Array*/, rows /*:Array*/) {\n rows.forEach(function (row, i) {\n var rec = \"F;\";\n if (row.hidden) rec += \"M0;\";else if (row.hpt) rec += \"M\" + 20 * row.hpt + \";\";else if (row.hpx) rec += \"M\" + 20 * px2pt(row.hpx) + \";\";\n if (rec.length > 2) out.push(rec + \"R\" + (i + 1));\n });\n }\n function sheet_to_sylk(ws /*:Worksheet*/, opts /*:?any*/) /*:string*/{\n var preamble /*:Array*/ = [\"ID;PWXL;N;E\"],\n o /*:Array*/ = [];\n var r = safe_decode_range(ws['!ref']),\n cell /*:Cell*/;\n var dense = Array.isArray(ws);\n var RS = \"\\r\\n\";\n preamble.push(\"P;PGeneral\");\n preamble.push(\"F;P0;DG0G8;M255\");\n if (ws['!cols']) write_ws_cols_sylk(preamble, ws['!cols']);\n if (ws['!rows']) write_ws_rows_sylk(preamble, ws['!rows']);\n preamble.push(\"B;Y\" + (r.e.r - r.s.r + 1) + \";X\" + (r.e.c - r.s.c + 1) + \";D\" + [r.s.c, r.s.r, r.e.c, r.e.r].join(\" \"));\n for (var R = r.s.r; R <= r.e.r; ++R) {\n for (var C = r.s.c; C <= r.e.c; ++C) {\n var coord = encode_cell({\n r: R,\n c: C\n });\n cell = dense ? (ws[R] || [])[C] : ws[coord];\n if (!cell || cell.v == null && (!cell.f || cell.F)) continue;\n o.push(write_ws_cell_sylk(cell, ws, R, C, opts));\n }\n }\n return preamble.join(RS) + RS + o.join(RS) + RS + \"E\" + RS;\n }\n return {\n to_workbook: sylk_to_workbook,\n to_sheet: sylk_to_sheet,\n from_sheet: sheet_to_sylk\n };\n}();\nvar DIF = /*#__PURE__*/function () {\n function dif_to_aoa(d /*:RawData*/, opts) /*:AOA*/{\n switch (opts.type) {\n case 'base64':\n return dif_to_aoa_str(Base64_decode(d), opts);\n case 'binary':\n return dif_to_aoa_str(d, opts);\n case 'buffer':\n return dif_to_aoa_str(has_buf && Buffer.isBuffer(d) ? d.toString('binary') : a2s(d), opts);\n case 'array':\n return dif_to_aoa_str(cc2str(d), opts);\n }\n throw new Error(\"Unrecognized type \" + opts.type);\n }\n function dif_to_aoa_str(str /*:string*/, opts) /*:AOA*/{\n var records = str.split('\\n'),\n R = -1,\n C = -1,\n ri = 0,\n arr /*:AOA*/ = [];\n for (; ri !== records.length; ++ri) {\n if (records[ri].trim() === 'BOT') {\n arr[++R] = [];\n C = 0;\n continue;\n }\n if (R < 0) continue;\n var metadata = records[ri].trim().split(\",\");\n var type = metadata[0],\n value = metadata[1];\n ++ri;\n var data = records[ri] || \"\";\n while ((data.match(/[\"]/g) || []).length & 1 && ri < records.length - 1) data += \"\\n\" + records[++ri];\n data = data.trim();\n switch (+type) {\n case -1:\n if (data === 'BOT') {\n arr[++R] = [];\n C = 0;\n continue;\n } else if (data !== 'EOD') throw new Error(\"Unrecognized DIF special command \" + data);\n break;\n case 0:\n if (data === 'TRUE') arr[R][C] = true;else if (data === 'FALSE') arr[R][C] = false;else if (!isNaN(fuzzynum(value))) arr[R][C] = fuzzynum(value);else if (!isNaN(fuzzydate(value).getDate())) arr[R][C] = parseDate(value);else arr[R][C] = value;\n ++C;\n break;\n case 1:\n data = data.slice(1, data.length - 1);\n data = data.replace(/\"\"/g, '\"');\n if (DIF_XL && data && data.match(/^=\".*\"$/)) data = data.slice(2, -1);\n arr[R][C++] = data !== '' ? data : null;\n break;\n }\n if (data === 'EOD') break;\n }\n if (opts && opts.sheetRows) arr = arr.slice(0, opts.sheetRows);\n return arr;\n }\n function dif_to_sheet(str /*:string*/, opts) /*:Worksheet*/{\n return aoa_to_sheet(dif_to_aoa(str, opts), opts);\n }\n function dif_to_workbook(str /*:string*/, opts) /*:Workbook*/{\n return sheet_to_workbook(dif_to_sheet(str, opts), opts);\n }\n var sheet_to_dif = /*#__PURE__*/function () {\n var push_field = function pf(o /*:Array*/, topic /*:string*/, v /*:number*/, n /*:number*/, s /*:string*/) {\n o.push(topic);\n o.push(v + \",\" + n);\n o.push('\"' + s.replace(/\"/g, '\"\"') + '\"');\n };\n var push_value = function po(o /*:Array*/, type /*:number*/, v /*:any*/, s /*:string*/) {\n o.push(type + \",\" + v);\n o.push(type == 1 ? '\"' + s.replace(/\"/g, '\"\"') + '\"' : s);\n };\n return function sheet_to_dif(ws /*:Worksheet*/ /*::, opts:?any*/) /*:string*/{\n var o /*:Array*/ = [];\n var r = safe_decode_range(ws['!ref']),\n cell /*:Cell*/;\n var dense = Array.isArray(ws);\n push_field(o, \"TABLE\", 0, 1, \"sheetjs\");\n push_field(o, \"VECTORS\", 0, r.e.r - r.s.r + 1, \"\");\n push_field(o, \"TUPLES\", 0, r.e.c - r.s.c + 1, \"\");\n push_field(o, \"DATA\", 0, 0, \"\");\n for (var R = r.s.r; R <= r.e.r; ++R) {\n push_value(o, -1, 0, \"BOT\");\n for (var C = r.s.c; C <= r.e.c; ++C) {\n var coord = encode_cell({\n r: R,\n c: C\n });\n cell = dense ? (ws[R] || [])[C] : ws[coord];\n if (!cell) {\n push_value(o, 1, 0, \"\");\n continue;\n }\n switch (cell.t) {\n case 'n':\n var val = DIF_XL ? cell.w : cell.v;\n if (!val && cell.v != null) val = cell.v;\n if (val == null) {\n if (DIF_XL && cell.f && !cell.F) push_value(o, 1, 0, \"=\" + cell.f);else push_value(o, 1, 0, \"\");\n } else push_value(o, 0, val, \"V\");\n break;\n case 'b':\n push_value(o, 0, cell.v ? 1 : 0, cell.v ? \"TRUE\" : \"FALSE\");\n break;\n case 's':\n push_value(o, 1, 0, !DIF_XL || isNaN(cell.v) ? cell.v : '=\"' + cell.v + '\"');\n break;\n case 'd':\n if (!cell.w) cell.w = SSF_format(cell.z || table_fmt[14], datenum(parseDate(cell.v)));\n if (DIF_XL) push_value(o, 0, cell.w, \"V\");else push_value(o, 1, 0, cell.w);\n break;\n default:\n push_value(o, 1, 0, \"\");\n }\n }\n }\n push_value(o, -1, 0, \"EOD\");\n var RS = \"\\r\\n\";\n var oo = o.join(RS);\n //while((oo.length & 0x7F) != 0) oo += \"\\0\";\n return oo;\n };\n }();\n return {\n to_workbook: dif_to_workbook,\n to_sheet: dif_to_sheet,\n from_sheet: sheet_to_dif\n };\n}();\nvar ETH = /*#__PURE__*/function () {\n function decode(s /*:string*/) /*:string*/{\n return s.replace(/\\\\b/g, \"\\\\\").replace(/\\\\c/g, \":\").replace(/\\\\n/g, \"\\n\");\n }\n function encode(s /*:string*/) /*:string*/{\n return s.replace(/\\\\/g, \"\\\\b\").replace(/:/g, \"\\\\c\").replace(/\\n/g, \"\\\\n\");\n }\n function eth_to_aoa(str /*:string*/, opts) /*:AOA*/{\n var records = str.split('\\n'),\n R = -1,\n C = -1,\n ri = 0,\n arr /*:AOA*/ = [];\n for (; ri !== records.length; ++ri) {\n var record = records[ri].trim().split(\":\");\n if (record[0] !== 'cell') continue;\n var addr = decode_cell(record[1]);\n if (arr.length <= addr.r) for (R = arr.length; R <= addr.r; ++R) if (!arr[R]) arr[R] = [];\n R = addr.r;\n C = addr.c;\n switch (record[2]) {\n case 't':\n arr[R][C] = decode(record[3]);\n break;\n case 'v':\n arr[R][C] = +record[3];\n break;\n case 'vtf':\n var _f = record[record.length - 1];\n /* falls through */\n case 'vtc':\n switch (record[3]) {\n case 'nl':\n arr[R][C] = +record[4] ? true : false;\n break;\n default:\n arr[R][C] = +record[4];\n break;\n }\n if (record[2] == 'vtf') arr[R][C] = [arr[R][C], _f];\n }\n }\n if (opts && opts.sheetRows) arr = arr.slice(0, opts.sheetRows);\n return arr;\n }\n function eth_to_sheet(d /*:string*/, opts) /*:Worksheet*/{\n return aoa_to_sheet(eth_to_aoa(d, opts), opts);\n }\n function eth_to_workbook(d /*:string*/, opts) /*:Workbook*/{\n return sheet_to_workbook(eth_to_sheet(d, opts), opts);\n }\n var header = [\"socialcalc:version:1.5\", \"MIME-Version: 1.0\", \"Content-Type: multipart/mixed; boundary=SocialCalcSpreadsheetControlSave\"].join(\"\\n\");\n var sep = [\"--SocialCalcSpreadsheetControlSave\", \"Content-type: text/plain; charset=UTF-8\"].join(\"\\n\") + \"\\n\";\n\n /* TODO: the other parts */\n var meta = [\"# SocialCalc Spreadsheet Control Save\", \"part:sheet\"].join(\"\\n\");\n var end = \"--SocialCalcSpreadsheetControlSave--\";\n function sheet_to_eth_data(ws /*:Worksheet*/) /*:string*/{\n if (!ws || !ws['!ref']) return \"\";\n var o /*:Array*/ = [],\n oo /*:Array*/ = [],\n cell,\n coord = \"\";\n var r = decode_range(ws['!ref']);\n var dense = Array.isArray(ws);\n for (var R = r.s.r; R <= r.e.r; ++R) {\n for (var C = r.s.c; C <= r.e.c; ++C) {\n coord = encode_cell({\n r: R,\n c: C\n });\n cell = dense ? (ws[R] || [])[C] : ws[coord];\n if (!cell || cell.v == null || cell.t === 'z') continue;\n oo = [\"cell\", coord, 't'];\n switch (cell.t) {\n case 's':\n case 'str':\n oo.push(encode(cell.v));\n break;\n case 'n':\n if (!cell.f) {\n oo[2] = 'v';\n oo[3] = cell.v;\n } else {\n oo[2] = 'vtf';\n oo[3] = 'n';\n oo[4] = cell.v;\n oo[5] = encode(cell.f);\n }\n break;\n case 'b':\n oo[2] = 'vt' + (cell.f ? 'f' : 'c');\n oo[3] = 'nl';\n oo[4] = cell.v ? \"1\" : \"0\";\n oo[5] = encode(cell.f || (cell.v ? 'TRUE' : 'FALSE'));\n break;\n case 'd':\n var t = datenum(parseDate(cell.v));\n oo[2] = 'vtc';\n oo[3] = 'nd';\n oo[4] = \"\" + t;\n oo[5] = cell.w || SSF_format(cell.z || table_fmt[14], t);\n break;\n case 'e':\n continue;\n }\n o.push(oo.join(\":\"));\n }\n }\n o.push(\"sheet:c:\" + (r.e.c - r.s.c + 1) + \":r:\" + (r.e.r - r.s.r + 1) + \":tvf:1\");\n o.push(\"valueformat:1:text-wiki\");\n //o.push(\"copiedfrom:\" + ws['!ref']); // clipboard only\n return o.join(\"\\n\");\n }\n function sheet_to_eth(ws /*:Worksheet*/ /*::, opts:?any*/) /*:string*/{\n return [header, sep, meta, sep, sheet_to_eth_data(ws), end].join(\"\\n\");\n // return [\"version:1.5\", sheet_to_eth_data(ws)].join(\"\\n\"); // clipboard form\n }\n return {\n to_workbook: eth_to_workbook,\n to_sheet: eth_to_sheet,\n from_sheet: sheet_to_eth\n };\n}();\nvar PRN = /*#__PURE__*/function () {\n function set_text_arr(data /*:string*/, arr /*:AOA*/, R /*:number*/, C /*:number*/, o /*:any*/) {\n if (o.raw) arr[R][C] = data;else if (data === \"\") {/* empty */} else if (data === 'TRUE') arr[R][C] = true;else if (data === 'FALSE') arr[R][C] = false;else if (!isNaN(fuzzynum(data))) arr[R][C] = fuzzynum(data);else if (!isNaN(fuzzydate(data).getDate())) arr[R][C] = parseDate(data);else arr[R][C] = data;\n }\n function prn_to_aoa_str(f /*:string*/, opts) /*:AOA*/{\n var o = opts || {};\n var arr /*:AOA*/ = [] /*:any*/;\n if (!f || f.length === 0) return arr;\n var lines = f.split(/[\\r\\n]/);\n var L = lines.length - 1;\n while (L >= 0 && lines[L].length === 0) --L;\n var start = 10,\n idx = 0;\n var R = 0;\n for (; R <= L; ++R) {\n idx = lines[R].indexOf(\" \");\n if (idx == -1) idx = lines[R].length;else idx++;\n start = Math.max(start, idx);\n }\n for (R = 0; R <= L; ++R) {\n arr[R] = [];\n /* TODO: confirm that widths are always 10 */\n var C = 0;\n set_text_arr(lines[R].slice(0, start).trim(), arr, R, C, o);\n for (C = 1; C <= (lines[R].length - start) / 10 + 1; ++C) set_text_arr(lines[R].slice(start + (C - 1) * 10, start + C * 10).trim(), arr, R, C, o);\n }\n if (o.sheetRows) arr = arr.slice(0, o.sheetRows);\n return arr;\n }\n\n // List of accepted CSV separators\n var guess_seps = {\n /*::[*/0x2C /*::]*/: ',',\n /*::[*/0x09 /*::]*/: \"\\t\",\n /*::[*/0x3B /*::]*/: ';',\n /*::[*/0x7C /*::]*/: '|'\n };\n\n // CSV separator weights to be used in case of equal numbers\n var guess_sep_weights = {\n /*::[*/0x2C /*::]*/: 3,\n /*::[*/0x09 /*::]*/: 2,\n /*::[*/0x3B /*::]*/: 1,\n /*::[*/0x7C /*::]*/: 0\n };\n function guess_sep(str) {\n var cnt = {},\n instr = false,\n end = 0,\n cc = 0;\n for (; end < str.length; ++end) {\n if ((cc = str.charCodeAt(end)) == 0x22) instr = !instr;else if (!instr && cc in guess_seps) cnt[cc] = (cnt[cc] || 0) + 1;\n }\n cc = [];\n for (end in cnt) if (Object.prototype.hasOwnProperty.call(cnt, end)) {\n cc.push([cnt[end], end]);\n }\n if (!cc.length) {\n cnt = guess_sep_weights;\n for (end in cnt) if (Object.prototype.hasOwnProperty.call(cnt, end)) {\n cc.push([cnt[end], end]);\n }\n }\n cc.sort(function (a, b) {\n return a[0] - b[0] || guess_sep_weights[a[1]] - guess_sep_weights[b[1]];\n });\n return guess_seps[cc.pop()[1]] || 0x2C;\n }\n function dsv_to_sheet_str(str /*:string*/, opts) /*:Worksheet*/{\n var o = opts || {};\n var sep = \"\";\n if (DENSE != null && o.dense == null) o.dense = DENSE;\n var ws /*:Worksheet*/ = o.dense ? [] /*:any*/ : {} /*:any*/;\n var range /*:Range*/ = {\n s: {\n c: 0,\n r: 0\n },\n e: {\n c: 0,\n r: 0\n }\n } /*:any*/;\n if (str.slice(0, 4) == \"sep=\") {\n // If the line ends in \\r\\n\n if (str.charCodeAt(5) == 13 && str.charCodeAt(6) == 10) {\n sep = str.charAt(4);\n str = str.slice(7);\n }\n // If line ends in \\r OR \\n\n else if (str.charCodeAt(5) == 13 || str.charCodeAt(5) == 10) {\n sep = str.charAt(4);\n str = str.slice(6);\n } else sep = guess_sep(str.slice(0, 1024));\n } else if (o && o.FS) sep = o.FS;else sep = guess_sep(str.slice(0, 1024));\n var R = 0,\n C = 0,\n v = 0;\n var start = 0,\n end = 0,\n sepcc = sep.charCodeAt(0),\n instr = false,\n cc = 0,\n startcc = str.charCodeAt(0);\n str = str.replace(/\\r\\n/mg, \"\\n\");\n var _re /*:?RegExp*/ = o.dateNF != null ? dateNF_regex(o.dateNF) : null;\n function finish_cell() {\n var s = str.slice(start, end);\n var cell = {} /*:any*/;\n if (s.charAt(0) == '\"' && s.charAt(s.length - 1) == '\"') s = s.slice(1, -1).replace(/\"\"/g, '\"');\n if (s.length === 0) cell.t = 'z';else if (o.raw) {\n cell.t = 's';\n cell.v = s;\n } else if (s.trim().length === 0) {\n cell.t = 's';\n cell.v = s;\n } else if (s.charCodeAt(0) == 0x3D) {\n if (s.charCodeAt(1) == 0x22 && s.charCodeAt(s.length - 1) == 0x22) {\n cell.t = 's';\n cell.v = s.slice(2, -1).replace(/\"\"/g, '\"');\n } else if (fuzzyfmla(s)) {\n cell.t = 'n';\n cell.f = s.slice(1);\n } else {\n cell.t = 's';\n cell.v = s;\n }\n } else if (s == \"TRUE\") {\n cell.t = 'b';\n cell.v = true;\n } else if (s == \"FALSE\") {\n cell.t = 'b';\n cell.v = false;\n } else if (!isNaN(v = fuzzynum(s))) {\n cell.t = 'n';\n if (o.cellText !== false) cell.w = s;\n cell.v = v;\n } else if (!isNaN(fuzzydate(s).getDate()) || _re && s.match(_re)) {\n cell.z = o.dateNF || table_fmt[14];\n var k = 0;\n if (_re && s.match(_re)) {\n s = dateNF_fix(s, o.dateNF, s.match(_re) || []);\n k = 1;\n }\n if (o.cellDates) {\n cell.t = 'd';\n cell.v = parseDate(s, k);\n } else {\n cell.t = 'n';\n cell.v = datenum(parseDate(s, k));\n }\n if (o.cellText !== false) cell.w = SSF_format(cell.z, cell.v instanceof Date ? datenum(cell.v) : cell.v);\n if (!o.cellNF) delete cell.z;\n } else {\n cell.t = 's';\n cell.v = s;\n }\n if (cell.t == 'z') {} else if (o.dense) {\n if (!ws[R]) ws[R] = [];\n ws[R][C] = cell;\n } else ws[encode_cell({\n c: C,\n r: R\n })] = cell;\n start = end + 1;\n startcc = str.charCodeAt(start);\n if (range.e.c < C) range.e.c = C;\n if (range.e.r < R) range.e.r = R;\n if (cc == sepcc) ++C;else {\n C = 0;\n ++R;\n if (o.sheetRows && o.sheetRows <= R) return true;\n }\n }\n outer: for (; end < str.length; ++end) switch (cc = str.charCodeAt(end)) {\n case 0x22:\n if (startcc === 0x22) instr = !instr;\n break;\n case sepcc:\n case 0x0a:\n case 0x0d:\n if (!instr && finish_cell()) break outer;\n break;\n default:\n break;\n }\n if (end - start > 0) finish_cell();\n ws['!ref'] = encode_range(range);\n return ws;\n }\n function prn_to_sheet_str(str /*:string*/, opts) /*:Worksheet*/{\n if (!(opts && opts.PRN)) return dsv_to_sheet_str(str, opts);\n if (opts.FS) return dsv_to_sheet_str(str, opts);\n if (str.slice(0, 4) == \"sep=\") return dsv_to_sheet_str(str, opts);\n if (str.indexOf(\"\\t\") >= 0 || str.indexOf(\",\") >= 0 || str.indexOf(\";\") >= 0) return dsv_to_sheet_str(str, opts);\n return aoa_to_sheet(prn_to_aoa_str(str, opts), opts);\n }\n function prn_to_sheet(d /*:RawData*/, opts) /*:Worksheet*/{\n var str = \"\",\n bytes = opts.type == 'string' ? [0, 0, 0, 0] : firstbyte(d, opts);\n switch (opts.type) {\n case 'base64':\n str = Base64_decode(d);\n break;\n case 'binary':\n str = d;\n break;\n case 'buffer':\n if (opts.codepage == 65001) str = d.toString('utf8'); // TODO: test if buf\n else if (opts.codepage && typeof $cptable !== 'undefined') str = $cptable.utils.decode(opts.codepage, d);else str = has_buf && Buffer.isBuffer(d) ? d.toString('binary') : a2s(d);\n break;\n case 'array':\n str = cc2str(d);\n break;\n case 'string':\n str = d;\n break;\n default:\n throw new Error(\"Unrecognized type \" + opts.type);\n }\n if (bytes[0] == 0xEF && bytes[1] == 0xBB && bytes[2] == 0xBF) str = utf8read(str.slice(3));else if (opts.type != 'string' && opts.type != 'buffer' && opts.codepage == 65001) str = utf8read(str);else if (opts.type == 'binary' && typeof $cptable !== 'undefined' && opts.codepage) str = $cptable.utils.decode(opts.codepage, $cptable.utils.encode(28591, str));\n if (str.slice(0, 19) == \"socialcalc:version:\") return ETH.to_sheet(opts.type == 'string' ? str : utf8read(str), opts);\n return prn_to_sheet_str(str, opts);\n }\n function prn_to_workbook(d /*:RawData*/, opts) /*:Workbook*/{\n return sheet_to_workbook(prn_to_sheet(d, opts), opts);\n }\n function sheet_to_prn(ws /*:Worksheet*/ /*::, opts:?any*/) /*:string*/{\n var o /*:Array*/ = [];\n var r = safe_decode_range(ws['!ref']),\n cell /*:Cell*/;\n var dense = Array.isArray(ws);\n for (var R = r.s.r; R <= r.e.r; ++R) {\n var oo /*:Array*/ = [];\n for (var C = r.s.c; C <= r.e.c; ++C) {\n var coord = encode_cell({\n r: R,\n c: C\n });\n cell = dense ? (ws[R] || [])[C] : ws[coord];\n if (!cell || cell.v == null) {\n oo.push(\" \");\n continue;\n }\n var w = (cell.w || (format_cell(cell), cell.w) || \"\").slice(0, 10);\n while (w.length < 10) w += \" \";\n oo.push(w + (C === 0 ? \" \" : \"\"));\n }\n o.push(oo.join(\"\"));\n }\n return o.join(\"\\n\");\n }\n return {\n to_workbook: prn_to_workbook,\n to_sheet: prn_to_sheet,\n from_sheet: sheet_to_prn\n };\n}();\n\n/* Excel defaults to SYLK but warns if data is not valid */\nfunction read_wb_ID(d, opts) {\n var o = opts || {},\n OLD_WTF = !!o.WTF;\n o.WTF = true;\n try {\n var out = SYLK.to_workbook(d, o);\n o.WTF = OLD_WTF;\n return out;\n } catch (e) {\n o.WTF = OLD_WTF;\n if (!e.message.match(/SYLK bad record ID/) && OLD_WTF) throw e;\n return PRN.to_workbook(d, opts);\n }\n}\nvar WK_ = /*#__PURE__*/function () {\n function lotushopper(data, cb /*:RecordHopperCB*/, opts /*:any*/) {\n if (!data) return;\n prep_blob(data, data.l || 0);\n var Enum = opts.Enum || WK1Enum;\n while (data.l < data.length) {\n var RT = data.read_shift(2);\n var R = Enum[RT] || Enum[0xFFFF];\n var length = data.read_shift(2);\n var tgt = data.l + length;\n var d = R.f && R.f(data, length, opts);\n data.l = tgt;\n if (cb(d, R, RT)) return;\n }\n }\n function lotus_to_workbook(d /*:RawData*/, opts) {\n switch (opts.type) {\n case 'base64':\n return lotus_to_workbook_buf(s2a(Base64_decode(d)), opts);\n case 'binary':\n return lotus_to_workbook_buf(s2a(d), opts);\n case 'buffer':\n case 'array':\n return lotus_to_workbook_buf(d, opts);\n }\n throw \"Unsupported type \" + opts.type;\n }\n function lotus_to_workbook_buf(d, opts) /*:Workbook*/{\n if (!d) return d;\n var o = opts || {};\n if (DENSE != null && o.dense == null) o.dense = DENSE;\n var s /*:Worksheet*/ = o.dense ? [] : {} /*:any*/,\n n = \"Sheet1\",\n next_n = \"\",\n sidx = 0;\n var sheets = {},\n snames = [],\n realnames = [];\n var refguess = {\n s: {\n r: 0,\n c: 0\n },\n e: {\n r: 0,\n c: 0\n }\n };\n var sheetRows = o.sheetRows || 0;\n if (d[2] == 0x00) {\n if (d[3] == 0x08 || d[3] == 0x09) {\n if (d.length >= 16 && d[14] == 0x05 && d[15] === 0x6c) throw new Error(\"Unsupported Works 3 for Mac file\");\n }\n }\n if (d[2] == 0x02) {\n o.Enum = WK1Enum;\n lotushopper(d, function (val, R, RT) {\n switch (RT) {\n case 0x00:\n /* BOF */\n o.vers = val;\n if (val >= 0x1000) o.qpro = true;\n break;\n case 0x06:\n refguess = val;\n break;\n /* RANGE */\n case 0xCC:\n if (val) next_n = val;\n break;\n /* SHEETNAMECS */\n case 0xDE:\n next_n = val;\n break;\n /* SHEETNAMELP */\n case 0x0F: /* LABEL */\n case 0x33:\n /* STRING */\n if (!o.qpro) val[1].v = val[1].v.slice(1);\n /* falls through */\n case 0x0D: /* INTEGER */\n case 0x0E: /* NUMBER */\n case 0x10:\n /* FORMULA */\n /* TODO: actual translation of the format code */\n if (RT == 0x0E && (val[2] & 0x70) == 0x70 && (val[2] & 0x0F) > 1 && (val[2] & 0x0F) < 15) {\n val[1].z = o.dateNF || table_fmt[14];\n if (o.cellDates) {\n val[1].t = 'd';\n val[1].v = numdate(val[1].v);\n }\n }\n if (o.qpro) {\n if (val[3] > sidx) {\n s[\"!ref\"] = encode_range(refguess);\n sheets[n] = s;\n snames.push(n);\n s = o.dense ? [] : {};\n refguess = {\n s: {\n r: 0,\n c: 0\n },\n e: {\n r: 0,\n c: 0\n }\n };\n sidx = val[3];\n n = next_n || \"Sheet\" + (sidx + 1);\n next_n = \"\";\n }\n }\n var tmpcell = o.dense ? (s[val[0].r] || [])[val[0].c] : s[encode_cell(val[0])];\n if (tmpcell) {\n tmpcell.t = val[1].t;\n tmpcell.v = val[1].v;\n if (val[1].z != null) tmpcell.z = val[1].z;\n if (val[1].f != null) tmpcell.f = val[1].f;\n break;\n }\n if (o.dense) {\n if (!s[val[0].r]) s[val[0].r] = [];\n s[val[0].r][val[0].c] = val[1];\n } else s[encode_cell(val[0])] = val[1];\n break;\n default:\n }\n }, o);\n } else if (d[2] == 0x1A || d[2] == 0x0E) {\n o.Enum = WK3Enum;\n if (d[2] == 0x0E) {\n o.qpro = true;\n d.l = 0;\n }\n lotushopper(d, function (val, R, RT) {\n switch (RT) {\n case 0xCC:\n n = val;\n break;\n /* SHEETNAMECS */\n case 0x16:\n /* LABEL16 */\n val[1].v = val[1].v.slice(1);\n /* falls through */\n case 0x17: /* NUMBER17 */\n case 0x18: /* NUMBER18 */\n case 0x19: /* FORMULA19 */\n case 0x25: /* NUMBER25 */\n case 0x27: /* NUMBER27 */\n case 0x28:\n /* FORMULA28 */\n if (val[3] > sidx) {\n s[\"!ref\"] = encode_range(refguess);\n sheets[n] = s;\n snames.push(n);\n s = o.dense ? [] : {};\n refguess = {\n s: {\n r: 0,\n c: 0\n },\n e: {\n r: 0,\n c: 0\n }\n };\n sidx = val[3];\n n = \"Sheet\" + (sidx + 1);\n }\n if (sheetRows > 0 && val[0].r >= sheetRows) break;\n if (o.dense) {\n if (!s[val[0].r]) s[val[0].r] = [];\n s[val[0].r][val[0].c] = val[1];\n } else s[encode_cell(val[0])] = val[1];\n if (refguess.e.c < val[0].c) refguess.e.c = val[0].c;\n if (refguess.e.r < val[0].r) refguess.e.r = val[0].r;\n break;\n case 0x1B:\n /* XFORMAT */\n if (val[0x36b0]) realnames[val[0x36b0][0]] = val[0x36b0][1];\n break;\n case 0x0601:\n /* SHEETINFOQP */\n realnames[val[0]] = val[1];\n if (val[0] == sidx) n = val[1];\n break;\n default:\n break;\n }\n }, o);\n } else throw new Error(\"Unrecognized LOTUS BOF \" + d[2]);\n s[\"!ref\"] = encode_range(refguess);\n sheets[next_n || n] = s;\n snames.push(next_n || n);\n if (!realnames.length) return {\n SheetNames: snames,\n Sheets: sheets\n };\n var osheets = {},\n rnames = [];\n /* TODO: verify no collisions */\n for (var i = 0; i < realnames.length; ++i) if (sheets[snames[i]]) {\n rnames.push(realnames[i] || snames[i]);\n osheets[realnames[i]] = sheets[realnames[i]] || sheets[snames[i]];\n } else {\n rnames.push(realnames[i]);\n osheets[realnames[i]] = {\n \"!ref\": \"A1\"\n };\n }\n return {\n SheetNames: rnames,\n Sheets: osheets\n };\n }\n function sheet_to_wk1(ws /*:Worksheet*/, opts /*:WriteOpts*/) {\n var o = opts || {};\n if (+o.codepage >= 0) set_cp(+o.codepage);\n if (o.type == \"string\") throw new Error(\"Cannot write WK1 to JS string\");\n var ba = buf_array();\n var range = safe_decode_range(ws[\"!ref\"]);\n var dense = Array.isArray(ws);\n var cols = [];\n write_biff_rec(ba, 0x00, write_BOF_WK1(0x0406));\n write_biff_rec(ba, 0x06, write_RANGE(range));\n var max_R = Math.min(range.e.r, 8191);\n for (var R = range.s.r; R <= max_R; ++R) {\n var rr = encode_row(R);\n for (var C = range.s.c; C <= range.e.c; ++C) {\n if (R === range.s.r) cols[C] = encode_col(C);\n var ref = cols[C] + rr;\n var cell = dense ? (ws[R] || [])[C] : ws[ref];\n if (!cell || cell.t == \"z\") continue;\n /* TODO: formula records */\n if (cell.t == \"n\") {\n if ((cell.v | 0) == cell.v && cell.v >= -32768 && cell.v <= 32767) write_biff_rec(ba, 0x0d, write_INTEGER(R, C, cell.v));else write_biff_rec(ba, 0x0e, write_NUMBER(R, C, cell.v));\n } else {\n var str = format_cell(cell);\n write_biff_rec(ba, 0x0F, write_LABEL(R, C, str.slice(0, 239)));\n }\n }\n }\n write_biff_rec(ba, 0x01);\n return ba.end();\n }\n function book_to_wk3(wb /*:Workbook*/, opts /*:WriteOpts*/) {\n var o = opts || {};\n if (+o.codepage >= 0) set_cp(+o.codepage);\n if (o.type == \"string\") throw new Error(\"Cannot write WK3 to JS string\");\n var ba = buf_array();\n write_biff_rec(ba, 0x00, write_BOF_WK3(wb));\n for (var i = 0, cnt = 0; i < wb.SheetNames.length; ++i) if ((wb.Sheets[wb.SheetNames[i]] || {})[\"!ref\"]) write_biff_rec(ba, 0x1b, write_XFORMAT_SHEETNAME(wb.SheetNames[i], cnt++));\n var wsidx = 0;\n for (i = 0; i < wb.SheetNames.length; ++i) {\n var ws = wb.Sheets[wb.SheetNames[i]];\n if (!ws || !ws[\"!ref\"]) continue;\n var range = safe_decode_range(ws[\"!ref\"]);\n var dense = Array.isArray(ws);\n var cols = [];\n var max_R = Math.min(range.e.r, 8191);\n for (var R = range.s.r; R <= max_R; ++R) {\n var rr = encode_row(R);\n for (var C = range.s.c; C <= range.e.c; ++C) {\n if (R === range.s.r) cols[C] = encode_col(C);\n var ref = cols[C] + rr;\n var cell = dense ? (ws[R] || [])[C] : ws[ref];\n if (!cell || cell.t == \"z\") continue;\n /* TODO: FORMULA19 NUMBER18 records */\n if (cell.t == \"n\") {\n write_biff_rec(ba, 0x17, write_NUMBER_17(R, C, wsidx, cell.v));\n } else {\n var str = format_cell(cell);\n /* TODO: max len? */\n write_biff_rec(ba, 0x16, write_LABEL_16(R, C, wsidx, str.slice(0, 239)));\n }\n }\n }\n ++wsidx;\n }\n write_biff_rec(ba, 0x01);\n return ba.end();\n }\n function write_BOF_WK1(v /*:number*/) {\n var out = new_buf(2);\n out.write_shift(2, v);\n return out;\n }\n function write_BOF_WK3(wb /*:Workbook*/) {\n var out = new_buf(26);\n out.write_shift(2, 0x1000);\n out.write_shift(2, 0x0004);\n out.write_shift(4, 0x0000);\n var rows = 0,\n cols = 0,\n wscnt = 0;\n for (var i = 0; i < wb.SheetNames.length; ++i) {\n var name = wb.SheetNames[i];\n var ws = wb.Sheets[name];\n if (!ws || !ws[\"!ref\"]) continue;\n ++wscnt;\n var range = decode_range(ws[\"!ref\"]);\n if (rows < range.e.r) rows = range.e.r;\n if (cols < range.e.c) cols = range.e.c;\n }\n if (rows > 8191) rows = 8191;\n out.write_shift(2, rows);\n out.write_shift(1, wscnt);\n out.write_shift(1, cols);\n out.write_shift(2, 0x00);\n out.write_shift(2, 0x00);\n out.write_shift(1, 0x01);\n out.write_shift(1, 0x02);\n out.write_shift(4, 0);\n out.write_shift(4, 0);\n return out;\n }\n function parse_RANGE(blob, length, opts) {\n var o = {\n s: {\n c: 0,\n r: 0\n },\n e: {\n c: 0,\n r: 0\n }\n };\n if (length == 8 && opts.qpro) {\n o.s.c = blob.read_shift(1);\n blob.l++;\n o.s.r = blob.read_shift(2);\n o.e.c = blob.read_shift(1);\n blob.l++;\n o.e.r = blob.read_shift(2);\n return o;\n }\n o.s.c = blob.read_shift(2);\n o.s.r = blob.read_shift(2);\n if (length == 12 && opts.qpro) blob.l += 2;\n o.e.c = blob.read_shift(2);\n o.e.r = blob.read_shift(2);\n if (length == 12 && opts.qpro) blob.l += 2;\n if (o.s.c == 0xFFFF) o.s.c = o.e.c = o.s.r = o.e.r = 0;\n return o;\n }\n function write_RANGE(range) {\n var out = new_buf(8);\n out.write_shift(2, range.s.c);\n out.write_shift(2, range.s.r);\n out.write_shift(2, range.e.c);\n out.write_shift(2, range.e.r);\n return out;\n }\n function parse_cell(blob, length, opts) {\n var o = [{\n c: 0,\n r: 0\n }, {\n t: 'n',\n v: 0\n }, 0, 0];\n if (opts.qpro && opts.vers != 0x5120) {\n o[0].c = blob.read_shift(1);\n o[3] = blob.read_shift(1);\n o[0].r = blob.read_shift(2);\n blob.l += 2;\n } else {\n o[2] = blob.read_shift(1);\n o[0].c = blob.read_shift(2);\n o[0].r = blob.read_shift(2);\n }\n return o;\n }\n function parse_LABEL(blob, length, opts) {\n var tgt = blob.l + length;\n var o = parse_cell(blob, length, opts);\n o[1].t = 's';\n if (opts.vers == 0x5120) {\n blob.l++;\n var len = blob.read_shift(1);\n o[1].v = blob.read_shift(len, 'utf8');\n return o;\n }\n if (opts.qpro) blob.l++;\n o[1].v = blob.read_shift(tgt - blob.l, 'cstr');\n return o;\n }\n function write_LABEL(R, C, s) {\n /* TODO: encoding */\n var o = new_buf(7 + s.length);\n o.write_shift(1, 0xFF);\n o.write_shift(2, C);\n o.write_shift(2, R);\n o.write_shift(1, 0x27); // ??\n for (var i = 0; i < o.length; ++i) {\n var cc = s.charCodeAt(i);\n o.write_shift(1, cc >= 0x80 ? 0x5F : cc);\n }\n o.write_shift(1, 0);\n return o;\n }\n function parse_INTEGER(blob, length, opts) {\n var o = parse_cell(blob, length, opts);\n o[1].v = blob.read_shift(2, 'i');\n return o;\n }\n function write_INTEGER(R, C, v) {\n var o = new_buf(7);\n o.write_shift(1, 0xFF);\n o.write_shift(2, C);\n o.write_shift(2, R);\n o.write_shift(2, v, 'i');\n return o;\n }\n function parse_NUMBER(blob, length, opts) {\n var o = parse_cell(blob, length, opts);\n o[1].v = blob.read_shift(8, 'f');\n return o;\n }\n function write_NUMBER(R, C, v) {\n var o = new_buf(13);\n o.write_shift(1, 0xFF);\n o.write_shift(2, C);\n o.write_shift(2, R);\n o.write_shift(8, v, 'f');\n return o;\n }\n function parse_FORMULA(blob, length, opts) {\n var tgt = blob.l + length;\n var o = parse_cell(blob, length, opts);\n /* TODO: formula */\n o[1].v = blob.read_shift(8, 'f');\n if (opts.qpro) blob.l = tgt;else {\n var flen = blob.read_shift(2);\n wk1_fmla_to_csf(blob.slice(blob.l, blob.l + flen), o);\n blob.l += flen;\n }\n return o;\n }\n function wk1_parse_rc(B, V, col) {\n var rel = V & 0x8000;\n V &= ~0x8000;\n V = (rel ? B : 0) + (V >= 0x2000 ? V - 0x4000 : V);\n return (rel ? \"\" : \"$\") + (col ? encode_col(V) : encode_row(V));\n }\n /* var oprec = [\n \t8, 8, 8, 8, 8, 8, 8, 8, 6, 4, 4, 5, 5, 7, 3, 3,\n \t3, 3, 3, 3, 1, 1, 2, 6, 8, 8, 8, 8, 8, 8, 8, 8\n ]; */\n /* TODO: flesh out */\n var FuncTab = {\n 0x33: [\"FALSE\", 0],\n 0x34: [\"TRUE\", 0],\n 0x46: [\"LEN\", 1],\n 0x50: [\"SUM\", 69],\n 0x51: [\"AVERAGEA\", 69],\n 0x52: [\"COUNTA\", 69],\n 0x53: [\"MINA\", 69],\n 0x54: [\"MAXA\", 69],\n 0x6F: [\"T\", 1]\n };\n var BinOpTab = [\"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\",\n // eslint-disable-line no-mixed-spaces-and-tabs\n \"\", \"+\", \"-\", \"*\", \"/\", \"^\", \"=\", \"<>\",\n // eslint-disable-line no-mixed-spaces-and-tabs\n \"<=\", \">=\", \"<\", \">\", \"\", \"\", \"\", \"\",\n // eslint-disable-line no-mixed-spaces-and-tabs\n \"&\", \"\", \"\", \"\", \"\", \"\", \"\", \"\" // eslint-disable-line no-mixed-spaces-and-tabs\n ];\n function wk1_fmla_to_csf(blob, o) {\n prep_blob(blob, 0);\n var out = [],\n argc = 0,\n R = \"\",\n C = \"\",\n argL = \"\",\n argR = \"\";\n while (blob.l < blob.length) {\n var cc = blob[blob.l++];\n switch (cc) {\n case 0x00:\n out.push(blob.read_shift(8, 'f'));\n break;\n case 0x01:\n {\n C = wk1_parse_rc(o[0].c, blob.read_shift(2), true);\n R = wk1_parse_rc(o[0].r, blob.read_shift(2), false);\n out.push(C + R);\n }\n break;\n case 0x02:\n {\n var c = wk1_parse_rc(o[0].c, blob.read_shift(2), true);\n var r = wk1_parse_rc(o[0].r, blob.read_shift(2), false);\n C = wk1_parse_rc(o[0].c, blob.read_shift(2), true);\n R = wk1_parse_rc(o[0].r, blob.read_shift(2), false);\n out.push(c + r + \":\" + C + R);\n }\n break;\n case 0x03:\n if (blob.l < blob.length) {\n console.error(\"WK1 premature formula end\");\n return;\n }\n break;\n case 0x04:\n out.push(\"(\" + out.pop() + \")\");\n break;\n case 0x05:\n out.push(blob.read_shift(2));\n break;\n case 0x06:\n {\n /* TODO: text encoding */\n var Z = \"\";\n while (cc = blob[blob.l++]) Z += String.fromCharCode(cc);\n out.push('\"' + Z.replace(/\"/g, '\"\"') + '\"');\n }\n break;\n case 0x08:\n out.push(\"-\" + out.pop());\n break;\n case 0x17:\n out.push(\"+\" + out.pop());\n break;\n case 0x16:\n out.push(\"NOT(\" + out.pop() + \")\");\n break;\n case 0x14:\n case 0x15:\n {\n argR = out.pop();\n argL = out.pop();\n out.push([\"AND\", \"OR\"][cc - 0x14] + \"(\" + argL + \",\" + argR + \")\");\n }\n break;\n default:\n if (cc < 0x20 && BinOpTab[cc]) {\n argR = out.pop();\n argL = out.pop();\n out.push(argL + BinOpTab[cc] + argR);\n } else if (FuncTab[cc]) {\n argc = FuncTab[cc][1];\n if (argc == 69) argc = blob[blob.l++];\n if (argc > out.length) {\n console.error(\"WK1 bad formula parse 0x\" + cc.toString(16) + \":|\" + out.join(\"|\") + \"|\");\n return;\n }\n var args = out.slice(-argc);\n out.length -= argc;\n out.push(FuncTab[cc][0] + \"(\" + args.join(\",\") + \")\");\n } else if (cc <= 0x07) return console.error(\"WK1 invalid opcode \" + cc.toString(16));else if (cc <= 0x18) return console.error(\"WK1 unsupported op \" + cc.toString(16));else if (cc <= 0x1E) return console.error(\"WK1 invalid opcode \" + cc.toString(16));else if (cc <= 0x73) return console.error(\"WK1 unsupported function opcode \" + cc.toString(16));\n // possible future functions ??\n else return console.error(\"WK1 unrecognized opcode \" + cc.toString(16));\n }\n }\n if (out.length == 1) o[1].f = \"\" + out[0];else console.error(\"WK1 bad formula parse |\" + out.join(\"|\") + \"|\");\n }\n function parse_cell_3(blob /*::, length*/) {\n var o = [{\n c: 0,\n r: 0\n }, {\n t: 'n',\n v: 0\n }, 0];\n o[0].r = blob.read_shift(2);\n o[3] = blob[blob.l++];\n o[0].c = blob[blob.l++];\n return o;\n }\n function parse_LABEL_16(blob, length) {\n var o = parse_cell_3(blob, length);\n o[1].t = 's';\n o[1].v = blob.read_shift(length - 4, 'cstr');\n return o;\n }\n function write_LABEL_16(R, C, wsidx, s) {\n /* TODO: encoding */\n var o = new_buf(6 + s.length);\n o.write_shift(2, R);\n o.write_shift(1, wsidx);\n o.write_shift(1, C);\n o.write_shift(1, 0x27);\n for (var i = 0; i < s.length; ++i) {\n var cc = s.charCodeAt(i);\n o.write_shift(1, cc >= 0x80 ? 0x5F : cc);\n }\n o.write_shift(1, 0);\n return o;\n }\n function parse_NUMBER_18(blob, length) {\n var o = parse_cell_3(blob, length);\n o[1].v = blob.read_shift(2);\n var v = o[1].v >> 1;\n if (o[1].v & 0x1) {\n switch (v & 0x07) {\n case 0:\n v = (v >> 3) * 5000;\n break;\n case 1:\n v = (v >> 3) * 500;\n break;\n case 2:\n v = (v >> 3) / 20;\n break;\n case 3:\n v = (v >> 3) / 200;\n break;\n case 4:\n v = (v >> 3) / 2000;\n break;\n case 5:\n v = (v >> 3) / 20000;\n break;\n case 6:\n v = (v >> 3) / 16;\n break;\n case 7:\n v = (v >> 3) / 64;\n break;\n }\n }\n o[1].v = v;\n return o;\n }\n function parse_NUMBER_17(blob, length) {\n var o = parse_cell_3(blob, length);\n var v1 = blob.read_shift(4);\n var v2 = blob.read_shift(4);\n var e = blob.read_shift(2);\n if (e == 0xFFFF) {\n if (v1 === 0 && v2 === 0xC0000000) {\n o[1].t = \"e\";\n o[1].v = 0x0F;\n } // ERR -> #VALUE!\n else if (v1 === 0 && v2 === 0xD0000000) {\n o[1].t = \"e\";\n o[1].v = 0x2A;\n } // NA -> #N/A\n else o[1].v = 0;\n return o;\n }\n var s = e & 0x8000;\n e = (e & 0x7FFF) - 16446;\n o[1].v = (1 - s * 2) * (v2 * Math.pow(2, e + 32) + v1 * Math.pow(2, e));\n return o;\n }\n function write_NUMBER_17(R, C, wsidx, v) {\n var o = new_buf(14);\n o.write_shift(2, R);\n o.write_shift(1, wsidx);\n o.write_shift(1, C);\n if (v == 0) {\n o.write_shift(4, 0);\n o.write_shift(4, 0);\n o.write_shift(2, 0xFFFF);\n return o;\n }\n var s = 0,\n e = 0,\n v1 = 0,\n v2 = 0;\n if (v < 0) {\n s = 1;\n v = -v;\n }\n e = Math.log2(v) | 0;\n v /= Math.pow(2, e - 31);\n v2 = v >>> 0;\n if ((v2 & 0x80000000) == 0) {\n v /= 2;\n ++e;\n v2 = v >>> 0;\n }\n v -= v2;\n v2 |= 0x80000000;\n v2 >>>= 0;\n v *= Math.pow(2, 32);\n v1 = v >>> 0;\n o.write_shift(4, v1);\n o.write_shift(4, v2);\n e += 0x3FFF + (s ? 0x8000 : 0);\n o.write_shift(2, e);\n return o;\n }\n function parse_FORMULA_19(blob, length) {\n var o = parse_NUMBER_17(blob, 14);\n blob.l += length - 14; /* TODO: WK3 formula */\n return o;\n }\n function parse_NUMBER_25(blob, length) {\n var o = parse_cell_3(blob, length);\n var v1 = blob.read_shift(4);\n o[1].v = v1 >> 6;\n return o;\n }\n function parse_NUMBER_27(blob, length) {\n var o = parse_cell_3(blob, length);\n var v1 = blob.read_shift(8, 'f');\n o[1].v = v1;\n return o;\n }\n function parse_FORMULA_28(blob, length) {\n var o = parse_NUMBER_27(blob, 14);\n blob.l += length - 10; /* TODO: formula */\n return o;\n }\n function parse_SHEETNAMECS(blob, length) {\n return blob[blob.l + length - 1] == 0 ? blob.read_shift(length, 'cstr') : \"\";\n }\n function parse_SHEETNAMELP(blob, length) {\n var len = blob[blob.l++];\n if (len > length - 1) len = length - 1;\n var o = \"\";\n while (o.length < len) o += String.fromCharCode(blob[blob.l++]);\n return o;\n }\n function parse_SHEETINFOQP(blob, length, opts) {\n if (!opts.qpro || length < 21) return;\n var id = blob.read_shift(1);\n blob.l += 17;\n blob.l += 1; //var len = blob.read_shift(1);\n blob.l += 2;\n var nm = blob.read_shift(length - 21, 'cstr');\n return [id, nm];\n }\n function parse_XFORMAT(blob, length) {\n var o = {},\n tgt = blob.l + length;\n while (blob.l < tgt) {\n var dt = blob.read_shift(2);\n if (dt == 0x36b0) {\n o[dt] = [0, \"\"];\n o[dt][0] = blob.read_shift(2);\n while (blob[blob.l]) {\n o[dt][1] += String.fromCharCode(blob[blob.l]);\n blob.l++;\n }\n blob.l++;\n }\n // TODO: 0x3a99 ??\n }\n return o;\n }\n function write_XFORMAT_SHEETNAME(name, wsidx) {\n var out = new_buf(5 + name.length);\n out.write_shift(2, 0x36b0);\n out.write_shift(2, wsidx);\n for (var i = 0; i < name.length; ++i) {\n var cc = name.charCodeAt(i);\n out[out.l++] = cc > 0x7F ? 0x5F : cc;\n }\n out[out.l++] = 0;\n return out;\n }\n var WK1Enum = {\n /*::[*/0x0000 /*::]*/: {\n n: \"BOF\",\n f: parseuint16\n },\n /*::[*/0x0001 /*::]*/: {\n n: \"EOF\"\n },\n /*::[*/0x0002 /*::]*/: {\n n: \"CALCMODE\"\n },\n /*::[*/0x0003 /*::]*/: {\n n: \"CALCORDER\"\n },\n /*::[*/0x0004 /*::]*/: {\n n: \"SPLIT\"\n },\n /*::[*/0x0005 /*::]*/: {\n n: \"SYNC\"\n },\n /*::[*/0x0006 /*::]*/: {\n n: \"RANGE\",\n f: parse_RANGE\n },\n /*::[*/0x0007 /*::]*/: {\n n: \"WINDOW1\"\n },\n /*::[*/0x0008 /*::]*/: {\n n: \"COLW1\"\n },\n /*::[*/0x0009 /*::]*/: {\n n: \"WINTWO\"\n },\n /*::[*/0x000A /*::]*/: {\n n: \"COLW2\"\n },\n /*::[*/0x000B /*::]*/: {\n n: \"NAME\"\n },\n /*::[*/0x000C /*::]*/: {\n n: \"BLANK\"\n },\n /*::[*/0x000D /*::]*/: {\n n: \"INTEGER\",\n f: parse_INTEGER\n },\n /*::[*/0x000E /*::]*/: {\n n: \"NUMBER\",\n f: parse_NUMBER\n },\n /*::[*/0x000F /*::]*/: {\n n: \"LABEL\",\n f: parse_LABEL\n },\n /*::[*/0x0010 /*::]*/: {\n n: \"FORMULA\",\n f: parse_FORMULA\n },\n /*::[*/0x0018 /*::]*/: {\n n: \"TABLE\"\n },\n /*::[*/0x0019 /*::]*/: {\n n: \"ORANGE\"\n },\n /*::[*/0x001A /*::]*/: {\n n: \"PRANGE\"\n },\n /*::[*/0x001B /*::]*/: {\n n: \"SRANGE\"\n },\n /*::[*/0x001C /*::]*/: {\n n: \"FRANGE\"\n },\n /*::[*/0x001D /*::]*/: {\n n: \"KRANGE1\"\n },\n /*::[*/0x0020 /*::]*/: {\n n: \"HRANGE\"\n },\n /*::[*/0x0023 /*::]*/: {\n n: \"KRANGE2\"\n },\n /*::[*/0x0024 /*::]*/: {\n n: \"PROTEC\"\n },\n /*::[*/0x0025 /*::]*/: {\n n: \"FOOTER\"\n },\n /*::[*/0x0026 /*::]*/: {\n n: \"HEADER\"\n },\n /*::[*/0x0027 /*::]*/: {\n n: \"SETUP\"\n },\n /*::[*/0x0028 /*::]*/: {\n n: \"MARGINS\"\n },\n /*::[*/0x0029 /*::]*/: {\n n: \"LABELFMT\"\n },\n /*::[*/0x002A /*::]*/: {\n n: \"TITLES\"\n },\n /*::[*/0x002B /*::]*/: {\n n: \"SHEETJS\"\n },\n /*::[*/0x002D /*::]*/: {\n n: \"GRAPH\"\n },\n /*::[*/0x002E /*::]*/: {\n n: \"NGRAPH\"\n },\n /*::[*/0x002F /*::]*/: {\n n: \"CALCCOUNT\"\n },\n /*::[*/0x0030 /*::]*/: {\n n: \"UNFORMATTED\"\n },\n /*::[*/0x0031 /*::]*/: {\n n: \"CURSORW12\"\n },\n /*::[*/0x0032 /*::]*/: {\n n: \"WINDOW\"\n },\n /*::[*/0x0033 /*::]*/: {\n n: \"STRING\",\n f: parse_LABEL\n },\n /*::[*/0x0037 /*::]*/: {\n n: \"PASSWORD\"\n },\n /*::[*/0x0038 /*::]*/: {\n n: \"LOCKED\"\n },\n /*::[*/0x003C /*::]*/: {\n n: \"QUERY\"\n },\n /*::[*/0x003D /*::]*/: {\n n: \"QUERYNAME\"\n },\n /*::[*/0x003E /*::]*/: {\n n: \"PRINT\"\n },\n /*::[*/0x003F /*::]*/: {\n n: \"PRINTNAME\"\n },\n /*::[*/0x0040 /*::]*/: {\n n: \"GRAPH2\"\n },\n /*::[*/0x0041 /*::]*/: {\n n: \"GRAPHNAME\"\n },\n /*::[*/0x0042 /*::]*/: {\n n: \"ZOOM\"\n },\n /*::[*/0x0043 /*::]*/: {\n n: \"SYMSPLIT\"\n },\n /*::[*/0x0044 /*::]*/: {\n n: \"NSROWS\"\n },\n /*::[*/0x0045 /*::]*/: {\n n: \"NSCOLS\"\n },\n /*::[*/0x0046 /*::]*/: {\n n: \"RULER\"\n },\n /*::[*/0x0047 /*::]*/: {\n n: \"NNAME\"\n },\n /*::[*/0x0048 /*::]*/: {\n n: \"ACOMM\"\n },\n /*::[*/0x0049 /*::]*/: {\n n: \"AMACRO\"\n },\n /*::[*/0x004A /*::]*/: {\n n: \"PARSE\"\n },\n /*::[*/0x0066 /*::]*/: {\n n: \"PRANGES??\"\n },\n /*::[*/0x0067 /*::]*/: {\n n: \"RRANGES??\"\n },\n /*::[*/0x0068 /*::]*/: {\n n: \"FNAME??\"\n },\n /*::[*/0x0069 /*::]*/: {\n n: \"MRANGES??\"\n },\n /*::[*/0x00CC /*::]*/: {\n n: \"SHEETNAMECS\",\n f: parse_SHEETNAMECS\n },\n /*::[*/0x00DE /*::]*/: {\n n: \"SHEETNAMELP\",\n f: parse_SHEETNAMELP\n },\n /*::[*/0xFFFF /*::]*/: {\n n: \"\"\n }\n };\n var WK3Enum = {\n /*::[*/0x0000 /*::]*/: {\n n: \"BOF\"\n },\n /*::[*/0x0001 /*::]*/: {\n n: \"EOF\"\n },\n /*::[*/0x0002 /*::]*/: {\n n: \"PASSWORD\"\n },\n /*::[*/0x0003 /*::]*/: {\n n: \"CALCSET\"\n },\n /*::[*/0x0004 /*::]*/: {\n n: \"WINDOWSET\"\n },\n /*::[*/0x0005 /*::]*/: {\n n: \"SHEETCELLPTR\"\n },\n /*::[*/0x0006 /*::]*/: {\n n: \"SHEETLAYOUT\"\n },\n /*::[*/0x0007 /*::]*/: {\n n: \"COLUMNWIDTH\"\n },\n /*::[*/0x0008 /*::]*/: {\n n: \"HIDDENCOLUMN\"\n },\n /*::[*/0x0009 /*::]*/: {\n n: \"USERRANGE\"\n },\n /*::[*/0x000A /*::]*/: {\n n: \"SYSTEMRANGE\"\n },\n /*::[*/0x000B /*::]*/: {\n n: \"ZEROFORCE\"\n },\n /*::[*/0x000C /*::]*/: {\n n: \"SORTKEYDIR\"\n },\n /*::[*/0x000D /*::]*/: {\n n: \"FILESEAL\"\n },\n /*::[*/0x000E /*::]*/: {\n n: \"DATAFILLNUMS\"\n },\n /*::[*/0x000F /*::]*/: {\n n: \"PRINTMAIN\"\n },\n /*::[*/0x0010 /*::]*/: {\n n: \"PRINTSTRING\"\n },\n /*::[*/0x0011 /*::]*/: {\n n: \"GRAPHMAIN\"\n },\n /*::[*/0x0012 /*::]*/: {\n n: \"GRAPHSTRING\"\n },\n /*::[*/0x0013 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x0014 /*::]*/: {\n n: \"ERRCELL\"\n },\n /*::[*/0x0015 /*::]*/: {\n n: \"NACELL\"\n },\n /*::[*/0x0016 /*::]*/: {\n n: \"LABEL16\",\n f: parse_LABEL_16\n },\n /*::[*/0x0017 /*::]*/: {\n n: \"NUMBER17\",\n f: parse_NUMBER_17\n },\n /*::[*/0x0018 /*::]*/: {\n n: \"NUMBER18\",\n f: parse_NUMBER_18\n },\n /*::[*/0x0019 /*::]*/: {\n n: \"FORMULA19\",\n f: parse_FORMULA_19\n },\n /*::[*/0x001A /*::]*/: {\n n: \"FORMULA1A\"\n },\n /*::[*/0x001B /*::]*/: {\n n: \"XFORMAT\",\n f: parse_XFORMAT\n },\n /*::[*/0x001C /*::]*/: {\n n: \"DTLABELMISC\"\n },\n /*::[*/0x001D /*::]*/: {\n n: \"DTLABELCELL\"\n },\n /*::[*/0x001E /*::]*/: {\n n: \"GRAPHWINDOW\"\n },\n /*::[*/0x001F /*::]*/: {\n n: \"CPA\"\n },\n /*::[*/0x0020 /*::]*/: {\n n: \"LPLAUTO\"\n },\n /*::[*/0x0021 /*::]*/: {\n n: \"QUERY\"\n },\n /*::[*/0x0022 /*::]*/: {\n n: \"HIDDENSHEET\"\n },\n /*::[*/0x0023 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x0025 /*::]*/: {\n n: \"NUMBER25\",\n f: parse_NUMBER_25\n },\n /*::[*/0x0026 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x0027 /*::]*/: {\n n: \"NUMBER27\",\n f: parse_NUMBER_27\n },\n /*::[*/0x0028 /*::]*/: {\n n: \"FORMULA28\",\n f: parse_FORMULA_28\n },\n /*::[*/0x008E /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x0093 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x0096 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x0097 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x0098 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x0099 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x009A /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x009B /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x009C /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x00A3 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x00AE /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x00AF /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x00B0 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x00B1 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x00B8 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x00B9 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x00BA /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x00BB /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x00BC /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x00C3 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x00C9 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x00CC /*::]*/: {\n n: \"SHEETNAMECS\",\n f: parse_SHEETNAMECS\n },\n /*::[*/0x00CD /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x00CE /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x00CF /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x00D0 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x0100 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x0103 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x0104 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x0105 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x0106 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x0107 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x0109 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x010A /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x010B /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x010C /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x010E /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x010F /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x0180 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x0185 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x0186 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x0189 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x018C /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x0200 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x0202 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x0201 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x0204 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x0205 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x0280 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x0281 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x0282 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x0283 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x0284 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x0285 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x0286 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x0287 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x0288 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x0292 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x0293 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x0294 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x0295 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x0296 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x0299 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x029A /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x0300 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x0304 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x0601 /*::]*/: {\n n: \"SHEETINFOQP\",\n f: parse_SHEETINFOQP\n },\n /*::[*/0x0640 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x0642 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x0701 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x0702 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x0703 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x0704 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x0780 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x0800 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x0801 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x0804 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x0A80 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x2AF6 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x3231 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x6E49 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0x6F44 /*::]*/: {\n n: \"??\"\n },\n /*::[*/0xFFFF /*::]*/: {\n n: \"\"\n }\n };\n return {\n sheet_to_wk1: sheet_to_wk1,\n book_to_wk3: book_to_wk3,\n to_workbook: lotus_to_workbook\n };\n}();\n/* 18.4.7 rPr CT_RPrElt */\nfunction parse_rpr(rpr) {\n var font = {},\n m = rpr.match(tagregex),\n i = 0;\n var pass = false;\n if (m) for (; i != m.length; ++i) {\n var y = parsexmltag(m[i]);\n switch (y[0].replace(/\\w*:/g, \"\")) {\n /* 18.8.12 condense CT_BooleanProperty */\n /* ** not required . */\n case '':\n case '':\n font.shadow = 1;\n break;\n case '':\n break;\n\n /* 18.4.1 charset CT_IntProperty TODO */\n case '':\n case '':\n font.outline = 1;\n break;\n case '':\n break;\n\n /* 18.4.5 rFont CT_FontName */\n case '':\n case '':\n font.strike = 1;\n break;\n case '':\n break;\n\n /* 18.4.13 u CT_UnderlineProperty */\n case '':\n case '':\n font.u = 1;\n break;\n case '':\n break;\n\n /* 18.8.2 b */\n case '':\n case '':\n font.b = 1;\n break;\n case '':\n break;\n\n /* 18.8.26 i */\n case '':\n case '':\n font.i = 1;\n break;\n case '':\n break;\n\n /* 18.3.1.15 color CT_Color TODO: tint, theme, auto, indexed */\n case '':\n case '':\n case '':\n break;\n\n /* 18.8.18 family ST_FontFamily */\n case '':\n case '':\n case '':\n break;\n\n /* 18.4.14 vertAlign CT_VerticalAlignFontProperty TODO */\n case '':\n case '':\n case '':\n break;\n\n /* 18.8.35 scheme CT_FontScheme TODO */\n case '':\n case '':\n case '':\n break;\n\n /* 18.2.10 extLst CT_ExtensionList ? */\n case '':\n case '':\n break;\n case '':\n pass = false;\n break;\n default:\n if (y[0].charCodeAt(1) !== 47 && !pass) throw new Error('Unrecognized rich format ' + y[0]);\n }\n }\n return font;\n}\nvar parse_rs = /*#__PURE__*/function () {\n var tregex = matchtag(\"t\"),\n rpregex = matchtag(\"rPr\");\n /* 18.4.4 r CT_RElt */\n function parse_r(r) {\n /* 18.4.12 t ST_Xstring */\n var t = r.match(tregex) /*, cp = 65001*/;\n if (!t) return {\n t: \"s\",\n v: \"\"\n };\n var o /*:Cell*/ = {\n t: 's',\n v: unescapexml(t[1])\n } /*:any*/;\n var rpr = r.match(rpregex);\n if (rpr) o.s = parse_rpr(rpr[1]);\n return o;\n }\n var rregex = /<(?:\\w+:)?r>/g,\n rend = /<\\/(?:\\w+:)?r>/;\n return function parse_rs(rs) {\n return rs.replace(rregex, \"\").split(rend).map(parse_r).filter(function (r) {\n return r.v;\n });\n };\n}();\n\n/* Parse a list of tags */\nvar rs_to_html = /*#__PURE__*/function parse_rs_factory() {\n var nlregex = /(\\r\\n|\\n)/g;\n function parse_rpr2(font, intro, outro) {\n var style /*:Array*/ = [];\n if (font.u) style.push(\"text-decoration: underline;\");\n if (font.uval) style.push(\"text-underline-style:\" + font.uval + \";\");\n if (font.sz) style.push(\"font-size:\" + font.sz + \"pt;\");\n if (font.outline) style.push(\"text-effect: outline;\");\n if (font.shadow) style.push(\"text-shadow: auto;\");\n intro.push('');\n if (font.b) {\n intro.push(\"\");\n outro.push(\"\");\n }\n if (font.i) {\n intro.push(\"\");\n outro.push(\"\");\n }\n if (font.strike) {\n intro.push(\"\");\n outro.push(\"\");\n }\n var align = font.valign || \"\";\n if (align == \"superscript\" || align == \"super\") align = \"sup\";else if (align == \"subscript\") align = \"sub\";\n if (align != \"\") {\n intro.push(\"<\" + align + \">\");\n outro.push(\"\");\n }\n outro.push(\"\");\n return font;\n }\n\n /* 18.4.4 r CT_RElt */\n function r_to_html(r) {\n var terms /*:[Array, string, Array]*/ = [[], r.v, []];\n if (!r.v) return \"\";\n if (r.s) parse_rpr2(r.s, terms[0], terms[2]);\n return terms[0].join(\"\") + terms[1].replace(nlregex, '
') + terms[2].join(\"\");\n }\n return function parse_rs(rs) {\n return rs.map(r_to_html).join(\"\");\n };\n}();\n\n/* 18.4.8 si CT_Rst */\nvar sitregex = /<(?:\\w+:)?t[^>]*>([^<]*)<\\/(?:\\w+:)?t>/g,\n sirregex = /<(?:\\w+:)?r>/;\nvar sirphregex = /<(?:\\w+:)?rPh.*?>([\\s\\S]*?)<\\/(?:\\w+:)?rPh>/g;\nfunction parse_si(x, opts) {\n var html = opts ? opts.cellHTML : true;\n var z = {};\n if (!x) return {\n t: \"\"\n };\n //var y;\n /* 18.4.12 t ST_Xstring (Plaintext String) */\n // TODO: is whitespace actually valid here?\n if (x.match(/^\\s*<(?:\\w+:)?t[^>]*>/)) {\n z.t = unescapexml(utf8read(x.slice(x.indexOf(\">\") + 1).split(/<\\/(?:\\w+:)?t>/)[0] || \"\"));\n z.r = utf8read(x);\n if (html) z.h = escapehtml(z.t);\n }\n /* 18.4.4 r CT_RElt (Rich Text Run) */else if ((/*y = */x.match(sirregex))) {\n z.r = utf8read(x);\n z.t = unescapexml(utf8read((x.replace(sirphregex, '').match(sitregex) || []).join(\"\").replace(tagregex, \"\")));\n if (html) z.h = rs_to_html(parse_rs(z.r));\n }\n /* 18.4.3 phoneticPr CT_PhoneticPr (TODO: needed for Asian support) */\n /* 18.4.6 rPh CT_PhoneticRun (TODO: needed for Asian support) */\n return z;\n}\n\n/* 18.4 Shared String Table */\nvar sstr0 = /<(?:\\w+:)?sst([^>]*)>([\\s\\S]*)<\\/(?:\\w+:)?sst>/;\nvar sstr1 = /<(?:\\w+:)?(?:si|sstItem)>/g;\nvar sstr2 = /<\\/(?:\\w+:)?(?:si|sstItem)>/;\nfunction parse_sst_xml(data /*:string*/, opts) /*:SST*/{\n var s /*:SST*/ = [] /*:any*/,\n ss = \"\";\n if (!data) return s;\n /* 18.4.9 sst CT_Sst */\n var sst = data.match(sstr0);\n if (sst) {\n ss = sst[2].replace(sstr1, \"\").split(sstr2);\n for (var i = 0; i != ss.length; ++i) {\n var o = parse_si(ss[i].trim(), opts);\n if (o != null) s[s.length] = o;\n }\n sst = parsexmltag(sst[1]);\n s.Count = sst.count;\n s.Unique = sst.uniqueCount;\n }\n return s;\n}\nvar straywsregex = /^\\s|\\s$|[\\t\\n\\r]/;\nfunction write_sst_xml(sst /*:SST*/, opts) /*:string*/{\n if (!opts.bookSST) return \"\";\n var o = [XML_HEADER];\n o[o.length] = writextag('sst', null, {\n xmlns: XMLNS_main[0],\n count: sst.Count,\n uniqueCount: sst.Unique\n });\n for (var i = 0; i != sst.length; ++i) {\n if (sst[i] == null) continue;\n var s /*:XLString*/ = sst[i];\n var sitag = \"\";\n if (s.r) sitag += s.r;else {\n sitag += \"\" + escapexml(s.t) + \"\";\n }\n sitag += \"\";\n o[o.length] = sitag;\n }\n if (o.length > 2) {\n o[o.length] = '';\n o[1] = o[1].replace(\"/>\", \">\");\n }\n return o.join(\"\");\n}\n/* [MS-XLSB] 2.4.221 BrtBeginSst */\nfunction parse_BrtBeginSst(data) {\n return [data.read_shift(4), data.read_shift(4)];\n}\n\n/* [MS-XLSB] 2.1.7.45 Shared Strings */\nfunction parse_sst_bin(data, opts) /*:SST*/{\n var s /*:SST*/ = [] /*:any*/;\n var pass = false;\n recordhopper(data, function hopper_sst(val, R, RT) {\n switch (RT) {\n case 0x009F:\n /* BrtBeginSst */\n s.Count = val[0];\n s.Unique = val[1];\n break;\n case 0x0013:\n /* BrtSSTItem */\n s.push(val);\n break;\n case 0x00A0:\n /* BrtEndSst */\n return true;\n case 0x0023:\n /* BrtFRTBegin */\n pass = true;\n break;\n case 0x0024:\n /* BrtFRTEnd */\n pass = false;\n break;\n default:\n if (R.T) {}\n if (!pass || opts.WTF) throw new Error(\"Unexpected record 0x\" + RT.toString(16));\n }\n });\n return s;\n}\nfunction write_BrtBeginSst(sst, o) {\n if (!o) o = new_buf(8);\n o.write_shift(4, sst.Count);\n o.write_shift(4, sst.Unique);\n return o;\n}\nvar write_BrtSSTItem = write_RichStr;\nfunction write_sst_bin(sst /*::, opts*/) {\n var ba = buf_array();\n write_record(ba, 0x009F /* BrtBeginSst */, write_BrtBeginSst(sst));\n for (var i = 0; i < sst.length; ++i) write_record(ba, 0x0013 /* BrtSSTItem */, write_BrtSSTItem(sst[i]));\n /* FRTSST */\n write_record(ba, 0x00A0 /* BrtEndSst */);\n return ba.end();\n}\nfunction _JS2ANSI(str /*:string*/) /*:Array*/{\n if (typeof $cptable !== 'undefined') return $cptable.utils.encode(current_ansi, str);\n var o /*:Array*/ = [],\n oo = str.split(\"\");\n for (var i = 0; i < oo.length; ++i) o[i] = oo[i].charCodeAt(0);\n return o;\n}\n\n/* [MS-OFFCRYPTO] 2.1.4 Version */\nfunction parse_CRYPTOVersion(blob, length /*:?number*/) {\n var o /*:any*/ = {};\n o.Major = blob.read_shift(2);\n o.Minor = blob.read_shift(2);\n /*:: if(length == null) return o; */\n if (length >= 4) blob.l += length - 4;\n return o;\n}\n\n/* [MS-OFFCRYPTO] 2.1.5 DataSpaceVersionInfo */\nfunction parse_DataSpaceVersionInfo(blob) {\n var o = {};\n o.id = blob.read_shift(0, 'lpp4');\n o.R = parse_CRYPTOVersion(blob, 4);\n o.U = parse_CRYPTOVersion(blob, 4);\n o.W = parse_CRYPTOVersion(blob, 4);\n return o;\n}\n\n/* [MS-OFFCRYPTO] 2.1.6.1 DataSpaceMapEntry Structure */\nfunction parse_DataSpaceMapEntry(blob) {\n var len = blob.read_shift(4);\n var end = blob.l + len - 4;\n var o = {};\n var cnt = blob.read_shift(4);\n var comps /*:Array<{t:number, v:string}>*/ = [];\n /* [MS-OFFCRYPTO] 2.1.6.2 DataSpaceReferenceComponent Structure */\n while (cnt-- > 0) comps.push({\n t: blob.read_shift(4),\n v: blob.read_shift(0, 'lpp4')\n });\n o.name = blob.read_shift(0, 'lpp4');\n o.comps = comps;\n if (blob.l != end) throw new Error(\"Bad DataSpaceMapEntry: \" + blob.l + \" != \" + end);\n return o;\n}\n\n/* [MS-OFFCRYPTO] 2.1.6 DataSpaceMap */\nfunction parse_DataSpaceMap(blob) {\n var o = [];\n blob.l += 4; // must be 0x8\n var cnt = blob.read_shift(4);\n while (cnt-- > 0) o.push(parse_DataSpaceMapEntry(blob));\n return o;\n}\n\n/* [MS-OFFCRYPTO] 2.1.7 DataSpaceDefinition */\nfunction parse_DataSpaceDefinition(blob) /*:Array*/{\n var o /*:Array*/ = [];\n blob.l += 4; // must be 0x8\n var cnt = blob.read_shift(4);\n while (cnt-- > 0) o.push(blob.read_shift(0, 'lpp4'));\n return o;\n}\n\n/* [MS-OFFCRYPTO] 2.1.8 DataSpaceDefinition */\nfunction parse_TransformInfoHeader(blob) {\n var o = {};\n /*var len = */\n blob.read_shift(4);\n blob.l += 4; // must be 0x1\n o.id = blob.read_shift(0, 'lpp4');\n o.name = blob.read_shift(0, 'lpp4');\n o.R = parse_CRYPTOVersion(blob, 4);\n o.U = parse_CRYPTOVersion(blob, 4);\n o.W = parse_CRYPTOVersion(blob, 4);\n return o;\n}\nfunction parse_Primary(blob) {\n /* [MS-OFFCRYPTO] 2.2.6 IRMDSTransformInfo */\n var hdr = parse_TransformInfoHeader(blob);\n /* [MS-OFFCRYPTO] 2.1.9 EncryptionTransformInfo */\n hdr.ename = blob.read_shift(0, '8lpp4');\n hdr.blksz = blob.read_shift(4);\n hdr.cmode = blob.read_shift(4);\n if (blob.read_shift(4) != 0x04) throw new Error(\"Bad !Primary record\");\n return hdr;\n}\n\n/* [MS-OFFCRYPTO] 2.3.2 Encryption Header */\nfunction parse_EncryptionHeader(blob, length /*:number*/) {\n var tgt = blob.l + length;\n var o = {};\n o.Flags = blob.read_shift(4) & 0x3F;\n blob.l += 4;\n o.AlgID = blob.read_shift(4);\n var valid = false;\n switch (o.AlgID) {\n case 0x660E:\n case 0x660F:\n case 0x6610:\n valid = o.Flags == 0x24;\n break;\n case 0x6801:\n valid = o.Flags == 0x04;\n break;\n case 0:\n valid = o.Flags == 0x10 || o.Flags == 0x04 || o.Flags == 0x24;\n break;\n default:\n throw 'Unrecognized encryption algorithm: ' + o.AlgID;\n }\n if (!valid) throw new Error(\"Encryption Flags/AlgID mismatch\");\n o.AlgIDHash = blob.read_shift(4);\n o.KeySize = blob.read_shift(4);\n o.ProviderType = blob.read_shift(4);\n blob.l += 8;\n o.CSPName = blob.read_shift(tgt - blob.l >> 1, 'utf16le');\n blob.l = tgt;\n return o;\n}\n\n/* [MS-OFFCRYPTO] 2.3.3 Encryption Verifier */\nfunction parse_EncryptionVerifier(blob, length /*:number*/) {\n var o = {},\n tgt = blob.l + length;\n blob.l += 4; // SaltSize must be 0x10\n o.Salt = blob.slice(blob.l, blob.l + 16);\n blob.l += 16;\n o.Verifier = blob.slice(blob.l, blob.l + 16);\n blob.l += 16;\n /*var sz = */\n blob.read_shift(4);\n o.VerifierHash = blob.slice(blob.l, tgt);\n blob.l = tgt;\n return o;\n}\n\n/* [MS-OFFCRYPTO] 2.3.4.* EncryptionInfo Stream */\nfunction parse_EncryptionInfo(blob) {\n var vers = parse_CRYPTOVersion(blob);\n switch (vers.Minor) {\n case 0x02:\n return [vers.Minor, parse_EncInfoStd(blob, vers)];\n case 0x03:\n return [vers.Minor, parse_EncInfoExt(blob, vers)];\n case 0x04:\n return [vers.Minor, parse_EncInfoAgl(blob, vers)];\n }\n throw new Error(\"ECMA-376 Encrypted file unrecognized Version: \" + vers.Minor);\n}\n\n/* [MS-OFFCRYPTO] 2.3.4.5 EncryptionInfo Stream (Standard Encryption) */\nfunction parse_EncInfoStd(blob /*::, vers*/) {\n var flags = blob.read_shift(4);\n if ((flags & 0x3F) != 0x24) throw new Error(\"EncryptionInfo mismatch\");\n var sz = blob.read_shift(4);\n //var tgt = blob.l + sz;\n var hdr = parse_EncryptionHeader(blob, sz);\n var verifier = parse_EncryptionVerifier(blob, blob.length - blob.l);\n return {\n t: \"Std\",\n h: hdr,\n v: verifier\n };\n}\n/* [MS-OFFCRYPTO] 2.3.4.6 EncryptionInfo Stream (Extensible Encryption) */\nfunction parse_EncInfoExt(/*::blob, vers*/) {\n throw new Error(\"File is password-protected: ECMA-376 Extensible\");\n}\n/* [MS-OFFCRYPTO] 2.3.4.10 EncryptionInfo Stream (Agile Encryption) */\nfunction parse_EncInfoAgl(blob /*::, vers*/) {\n var KeyData = [\"saltSize\", \"blockSize\", \"keyBits\", \"hashSize\", \"cipherAlgorithm\", \"cipherChaining\", \"hashAlgorithm\", \"saltValue\"];\n blob.l += 4;\n var xml = blob.read_shift(blob.length - blob.l, 'utf8');\n var o = {};\n xml.replace(tagregex, function xml_agile(x) {\n var y /*:any*/ = parsexmltag(x);\n switch (strip_ns(y[0])) {\n case '':\n break;\n case '':\n case '':\n break;\n case '':\n break;\n case ' 4 || vers.Major < 2) throw new Error('unrecognized major version code: ' + vers.Major);\n o.Flags = blob.read_shift(4);\n length -= 4;\n var sz = blob.read_shift(4);\n length -= 4;\n o.EncryptionHeader = parse_EncryptionHeader(blob, sz);\n length -= sz;\n o.EncryptionVerifier = parse_EncryptionVerifier(blob, length);\n return o;\n}\n/* [MS-OFFCRYPTO] 2.3.6.1 RC4 Encryption Header */\nfunction parse_RC4Header(blob /*::, length*/) {\n var o = {};\n var vers = o.EncryptionVersionInfo = parse_CRYPTOVersion(blob, 4);\n if (vers.Major != 1 || vers.Minor != 1) throw 'unrecognized version code ' + vers.Major + ' : ' + vers.Minor;\n o.Salt = blob.read_shift(16);\n o.EncryptedVerifier = blob.read_shift(16);\n o.EncryptedVerifierHash = blob.read_shift(16);\n return o;\n}\n\n/* [MS-OFFCRYPTO] 2.3.7.1 Binary Document Password Verifier Derivation */\nfunction crypto_CreatePasswordVerifier_Method1(Password /*:string*/) {\n var Verifier = 0x0000,\n PasswordArray;\n var PasswordDecoded = _JS2ANSI(Password);\n var len = PasswordDecoded.length + 1,\n i,\n PasswordByte;\n var Intermediate1, Intermediate2, Intermediate3;\n PasswordArray = new_raw_buf(len);\n PasswordArray[0] = PasswordDecoded.length;\n for (i = 1; i != len; ++i) PasswordArray[i] = PasswordDecoded[i - 1];\n for (i = len - 1; i >= 0; --i) {\n PasswordByte = PasswordArray[i];\n Intermediate1 = (Verifier & 0x4000) === 0x0000 ? 0 : 1;\n Intermediate2 = Verifier << 1 & 0x7FFF;\n Intermediate3 = Intermediate1 | Intermediate2;\n Verifier = Intermediate3 ^ PasswordByte;\n }\n return Verifier ^ 0xCE4B;\n}\n\n/* [MS-OFFCRYPTO] 2.3.7.2 Binary Document XOR Array Initialization */\nvar crypto_CreateXorArray_Method1 = /*#__PURE__*/function () {\n var PadArray = [0xBB, 0xFF, 0xFF, 0xBA, 0xFF, 0xFF, 0xB9, 0x80, 0x00, 0xBE, 0x0F, 0x00, 0xBF, 0x0F, 0x00];\n var InitialCode = [0xE1F0, 0x1D0F, 0xCC9C, 0x84C0, 0x110C, 0x0E10, 0xF1CE, 0x313E, 0x1872, 0xE139, 0xD40F, 0x84F9, 0x280C, 0xA96A, 0x4EC3];\n var XorMatrix = [0xAEFC, 0x4DD9, 0x9BB2, 0x2745, 0x4E8A, 0x9D14, 0x2A09, 0x7B61, 0xF6C2, 0xFDA5, 0xEB6B, 0xC6F7, 0x9DCF, 0x2BBF, 0x4563, 0x8AC6, 0x05AD, 0x0B5A, 0x16B4, 0x2D68, 0x5AD0, 0x0375, 0x06EA, 0x0DD4, 0x1BA8, 0x3750, 0x6EA0, 0xDD40, 0xD849, 0xA0B3, 0x5147, 0xA28E, 0x553D, 0xAA7A, 0x44D5, 0x6F45, 0xDE8A, 0xAD35, 0x4A4B, 0x9496, 0x390D, 0x721A, 0xEB23, 0xC667, 0x9CEF, 0x29FF, 0x53FE, 0xA7FC, 0x5FD9, 0x47D3, 0x8FA6, 0x0F6D, 0x1EDA, 0x3DB4, 0x7B68, 0xF6D0, 0xB861, 0x60E3, 0xC1C6, 0x93AD, 0x377B, 0x6EF6, 0xDDEC, 0x45A0, 0x8B40, 0x06A1, 0x0D42, 0x1A84, 0x3508, 0x6A10, 0xAA51, 0x4483, 0x8906, 0x022D, 0x045A, 0x08B4, 0x1168, 0x76B4, 0xED68, 0xCAF1, 0x85C3, 0x1BA7, 0x374E, 0x6E9C, 0x3730, 0x6E60, 0xDCC0, 0xA9A1, 0x4363, 0x86C6, 0x1DAD, 0x3331, 0x6662, 0xCCC4, 0x89A9, 0x0373, 0x06E6, 0x0DCC, 0x1021, 0x2042, 0x4084, 0x8108, 0x1231, 0x2462, 0x48C4];\n var Ror = function (Byte) {\n return (Byte / 2 | Byte * 128) & 0xFF;\n };\n var XorRor = function (byte1, byte2) {\n return Ror(byte1 ^ byte2);\n };\n var CreateXorKey_Method1 = function (Password) {\n var XorKey = InitialCode[Password.length - 1];\n var CurrentElement = 0x68;\n for (var i = Password.length - 1; i >= 0; --i) {\n var Char = Password[i];\n for (var j = 0; j != 7; ++j) {\n if (Char & 0x40) XorKey ^= XorMatrix[CurrentElement];\n Char *= 2;\n --CurrentElement;\n }\n }\n return XorKey;\n };\n return function (password /*:string*/) {\n var Password = _JS2ANSI(password);\n var XorKey = CreateXorKey_Method1(Password);\n var Index = Password.length;\n var ObfuscationArray = new_raw_buf(16);\n for (var i = 0; i != 16; ++i) ObfuscationArray[i] = 0x00;\n var Temp, PasswordLastChar, PadIndex;\n if ((Index & 1) === 1) {\n Temp = XorKey >> 8;\n ObfuscationArray[Index] = XorRor(PadArray[0], Temp);\n --Index;\n Temp = XorKey & 0xFF;\n PasswordLastChar = Password[Password.length - 1];\n ObfuscationArray[Index] = XorRor(PasswordLastChar, Temp);\n }\n while (Index > 0) {\n --Index;\n Temp = XorKey >> 8;\n ObfuscationArray[Index] = XorRor(Password[Index], Temp);\n --Index;\n Temp = XorKey & 0xFF;\n ObfuscationArray[Index] = XorRor(Password[Index], Temp);\n }\n Index = 15;\n PadIndex = 15 - Password.length;\n while (PadIndex > 0) {\n Temp = XorKey >> 8;\n ObfuscationArray[Index] = XorRor(PadArray[PadIndex], Temp);\n --Index;\n --PadIndex;\n Temp = XorKey & 0xFF;\n ObfuscationArray[Index] = XorRor(Password[Index], Temp);\n --Index;\n --PadIndex;\n }\n return ObfuscationArray;\n };\n}();\n\n/* [MS-OFFCRYPTO] 2.3.7.3 Binary Document XOR Data Transformation Method 1 */\nvar crypto_DecryptData_Method1 = function (password /*:string*/, Data, XorArrayIndex, XorArray, O) {\n /* If XorArray is set, use it; if O is not set, make changes in-place */\n if (!O) O = Data;\n if (!XorArray) XorArray = crypto_CreateXorArray_Method1(password);\n var Index, Value;\n for (Index = 0; Index != Data.length; ++Index) {\n Value = Data[Index];\n Value ^= XorArray[XorArrayIndex];\n Value = (Value >> 5 | Value << 3) & 0xFF;\n O[Index] = Value;\n ++XorArrayIndex;\n }\n return [O, XorArrayIndex, XorArray];\n};\nvar crypto_MakeXorDecryptor = function (password /*:string*/) {\n var XorArrayIndex = 0,\n XorArray = crypto_CreateXorArray_Method1(password);\n return function (Data) {\n var O = crypto_DecryptData_Method1(\"\", Data, XorArrayIndex, XorArray);\n XorArrayIndex = O[1];\n return O[0];\n };\n};\n\n/* 2.5.343 */\nfunction parse_XORObfuscation(blob, length, opts, out) {\n var o = {\n key: parseuint16(blob),\n verificationBytes: parseuint16(blob)\n } /*:any*/;\n if (opts.password) o.verifier = crypto_CreatePasswordVerifier_Method1(opts.password);\n out.valid = o.verificationBytes === o.verifier;\n if (out.valid) out.insitu = crypto_MakeXorDecryptor(opts.password);\n return o;\n}\n\n/* 2.4.117 */\nfunction parse_FilePassHeader(blob, length /*:number*/, oo) {\n var o = oo || {};\n o.Info = blob.read_shift(2);\n blob.l -= 2;\n if (o.Info === 1) o.Data = parse_RC4Header(blob, length);else o.Data = parse_RC4CryptoHeader(blob, length);\n return o;\n}\nfunction parse_FilePass(blob, length /*:number*/, opts) {\n var o = {\n Type: opts.biff >= 8 ? blob.read_shift(2) : 0\n } /*:any*/; /* wEncryptionType */\n if (o.Type) parse_FilePassHeader(blob, length - 2, o);else parse_XORObfuscation(blob, opts.biff >= 8 ? length : length - 2, opts, o);\n return o;\n}\nvar RTF = /*#__PURE__*/function () {\n function rtf_to_sheet(d /*:RawData*/, opts) /*:Worksheet*/{\n switch (opts.type) {\n case 'base64':\n return rtf_to_sheet_str(Base64_decode(d), opts);\n case 'binary':\n return rtf_to_sheet_str(d, opts);\n case 'buffer':\n return rtf_to_sheet_str(has_buf && Buffer.isBuffer(d) ? d.toString('binary') : a2s(d), opts);\n case 'array':\n return rtf_to_sheet_str(cc2str(d), opts);\n }\n throw new Error(\"Unrecognized type \" + opts.type);\n }\n\n /* TODO: this is a stub */\n function rtf_to_sheet_str(str /*:string*/, opts) /*:Worksheet*/{\n var o = opts || {};\n var ws /*:Worksheet*/ = o.dense ? [] /*:any*/ : {} /*:any*/;\n var rows = str.match(/\\\\trowd.*?\\\\row\\b/g);\n if (!rows.length) throw new Error(\"RTF missing table\");\n var range /*:Range*/ = {\n s: {\n c: 0,\n r: 0\n },\n e: {\n c: 0,\n r: rows.length - 1\n }\n } /*:any*/;\n rows.forEach(function (rowtf, R) {\n if (Array.isArray(ws)) ws[R] = [];\n var rtfre = /\\\\\\w+\\b/g;\n var last_index = 0;\n var res;\n var C = -1;\n while (res = rtfre.exec(rowtf)) {\n switch (res[0]) {\n case \"\\\\cell\":\n var data = rowtf.slice(last_index, rtfre.lastIndex - res[0].length);\n if (data[0] == \" \") data = data.slice(1);\n ++C;\n if (data.length) {\n // TODO: value parsing, including codepage adjustments\n var cell = {\n v: data,\n t: \"s\"\n };\n if (Array.isArray(ws)) ws[R][C] = cell;else ws[encode_cell({\n r: R,\n c: C\n })] = cell;\n }\n break;\n }\n last_index = rtfre.lastIndex;\n }\n if (C > range.e.c) range.e.c = C;\n });\n ws['!ref'] = encode_range(range);\n return ws;\n }\n function rtf_to_workbook(d /*:RawData*/, opts) /*:Workbook*/{\n return sheet_to_workbook(rtf_to_sheet(d, opts), opts);\n }\n\n /* TODO: this is a stub */\n function sheet_to_rtf(ws /*:Worksheet*/ /*::, opts*/) /*:string*/{\n var o = [\"{\\\\rtf1\\\\ansi\"];\n var r = safe_decode_range(ws['!ref']),\n cell /*:Cell*/;\n var dense = Array.isArray(ws);\n for (var R = r.s.r; R <= r.e.r; ++R) {\n o.push(\"\\\\trowd\\\\trautofit1\");\n for (var C = r.s.c; C <= r.e.c; ++C) o.push(\"\\\\cellx\" + (C + 1));\n o.push(\"\\\\pard\\\\intbl\");\n for (C = r.s.c; C <= r.e.c; ++C) {\n var coord = encode_cell({\n r: R,\n c: C\n });\n cell = dense ? (ws[R] || [])[C] : ws[coord];\n if (!cell || cell.v == null && (!cell.f || cell.F)) continue;\n o.push(\" \" + (cell.w || (format_cell(cell), cell.w)));\n o.push(\"\\\\cell\");\n }\n o.push(\"\\\\pard\\\\intbl\\\\row\");\n }\n return o.join(\"\") + \"}\";\n }\n return {\n to_workbook: rtf_to_workbook,\n to_sheet: rtf_to_sheet,\n from_sheet: sheet_to_rtf\n };\n}();\nfunction hex2RGB(h) {\n var o = h.slice(h[0] === \"#\" ? 1 : 0).slice(0, 6);\n return [parseInt(o.slice(0, 2), 16), parseInt(o.slice(2, 4), 16), parseInt(o.slice(4, 6), 16)];\n}\nfunction rgb2Hex(rgb) {\n for (var i = 0, o = 1; i != 3; ++i) o = o * 256 + (rgb[i] > 255 ? 255 : rgb[i] < 0 ? 0 : rgb[i]);\n return o.toString(16).toUpperCase().slice(1);\n}\nfunction rgb2HSL(rgb) {\n var R = rgb[0] / 255,\n G = rgb[1] / 255,\n B = rgb[2] / 255;\n var M = Math.max(R, G, B),\n m = Math.min(R, G, B),\n C = M - m;\n if (C === 0) return [0, 0, R];\n var H6 = 0,\n S = 0,\n L2 = M + m;\n S = C / (L2 > 1 ? 2 - L2 : L2);\n switch (M) {\n case R:\n H6 = ((G - B) / C + 6) % 6;\n break;\n case G:\n H6 = (B - R) / C + 2;\n break;\n case B:\n H6 = (R - G) / C + 4;\n break;\n }\n return [H6 / 6, S, L2 / 2];\n}\nfunction hsl2RGB(hsl) {\n var H = hsl[0],\n S = hsl[1],\n L = hsl[2];\n var C = S * 2 * (L < 0.5 ? L : 1 - L),\n m = L - C / 2;\n var rgb = [m, m, m],\n h6 = 6 * H;\n var X;\n if (S !== 0) switch (h6 | 0) {\n case 0:\n case 6:\n X = C * h6;\n rgb[0] += C;\n rgb[1] += X;\n break;\n case 1:\n X = C * (2 - h6);\n rgb[0] += X;\n rgb[1] += C;\n break;\n case 2:\n X = C * (h6 - 2);\n rgb[1] += C;\n rgb[2] += X;\n break;\n case 3:\n X = C * (4 - h6);\n rgb[1] += X;\n rgb[2] += C;\n break;\n case 4:\n X = C * (h6 - 4);\n rgb[2] += C;\n rgb[0] += X;\n break;\n case 5:\n X = C * (6 - h6);\n rgb[2] += X;\n rgb[0] += C;\n break;\n }\n for (var i = 0; i != 3; ++i) rgb[i] = Math.round(rgb[i] * 255);\n return rgb;\n}\n\n/* 18.8.3 bgColor tint algorithm */\nfunction rgb_tint(hex, tint) {\n if (tint === 0) return hex;\n var hsl = rgb2HSL(hex2RGB(hex));\n if (tint < 0) hsl[2] = hsl[2] * (1 + tint);else hsl[2] = 1 - (1 - hsl[2]) * (1 - tint);\n return rgb2Hex(hsl2RGB(hsl));\n}\n\n/* 18.3.1.13 width calculations */\n/* [MS-OI29500] 2.1.595 Column Width & Formatting */\nvar DEF_MDW = 6,\n MAX_MDW = 15,\n MIN_MDW = 1,\n MDW = DEF_MDW;\nfunction width2px(width) {\n return Math.floor((width + Math.round(128 / MDW) / 256) * MDW);\n}\nfunction px2char(px) {\n return Math.floor((px - 5) / MDW * 100 + 0.5) / 100;\n}\nfunction char2width(chr) {\n return Math.round((chr * MDW + 5) / MDW * 256) / 256;\n}\n//function px2char_(px) { return (((px - 5)/MDW * 100 + 0.5))/100; }\n//function char2width_(chr) { return (((chr * MDW + 5)/MDW*256))/256; }\nfunction cycle_width(collw) {\n return char2width(px2char(width2px(collw)));\n}\n/* XLSX/XLSB/XLS specify width in units of MDW */\nfunction find_mdw_colw(collw) {\n var delta = Math.abs(collw - cycle_width(collw)),\n _MDW = MDW;\n if (delta > 0.005) for (MDW = MIN_MDW; MDW < MAX_MDW; ++MDW) if (Math.abs(collw - cycle_width(collw)) <= delta) {\n delta = Math.abs(collw - cycle_width(collw));\n _MDW = MDW;\n }\n MDW = _MDW;\n}\n/* XLML specifies width in terms of pixels */\n/*function find_mdw_wpx(wpx) {\n\tvar delta = Infinity, guess = 0, _MDW = MIN_MDW;\n\tfor(MDW=MIN_MDW; MDW 0.5) guess--;\n\t\tif(Math.abs(guess) < delta) { delta = Math.abs(guess); _MDW = MDW; }\n\t}\n\tMDW = _MDW;\n}*/\n\nfunction process_col(coll /*:ColInfo*/) {\n if (coll.width) {\n coll.wpx = width2px(coll.width);\n coll.wch = px2char(coll.wpx);\n coll.MDW = MDW;\n } else if (coll.wpx) {\n coll.wch = px2char(coll.wpx);\n coll.width = char2width(coll.wch);\n coll.MDW = MDW;\n } else if (typeof coll.wch == 'number') {\n coll.width = char2width(coll.wch);\n coll.wpx = width2px(coll.width);\n coll.MDW = MDW;\n }\n if (coll.customWidth) delete coll.customWidth;\n}\nvar DEF_PPI = 96,\n PPI = DEF_PPI;\nfunction px2pt(px) {\n return px * 96 / PPI;\n}\nfunction pt2px(pt) {\n return pt * PPI / 96;\n}\n\n/* [MS-EXSPXML3] 2.4.54 ST_enmPattern */\nvar XLMLPatternTypeMap = {\n \"None\": \"none\",\n \"Solid\": \"solid\",\n \"Gray50\": \"mediumGray\",\n \"Gray75\": \"darkGray\",\n \"Gray25\": \"lightGray\",\n \"HorzStripe\": \"darkHorizontal\",\n \"VertStripe\": \"darkVertical\",\n \"ReverseDiagStripe\": \"darkDown\",\n \"DiagStripe\": \"darkUp\",\n \"DiagCross\": \"darkGrid\",\n \"ThickDiagCross\": \"darkTrellis\",\n \"ThinHorzStripe\": \"lightHorizontal\",\n \"ThinVertStripe\": \"lightVertical\",\n \"ThinReverseDiagStripe\": \"lightDown\",\n \"ThinHorzCross\": \"lightGrid\"\n};\n\n/* 18.8.5 borders CT_Borders */\nfunction parse_borders(t, styles, themes, opts) {\n styles.Borders = [];\n var border = {};\n var pass = false;\n (t[0].match(tagregex) || []).forEach(function (x) {\n var y = parsexmltag(x);\n switch (strip_ns(y[0])) {\n case '':\n case '':\n break;\n\n /* 18.8.4 border CT_Border */\n case '':\n case '':\n border = /*::(*/{} /*:: :any)*/;\n if (y.diagonalUp) border.diagonalUp = parsexmlbool(y.diagonalUp);\n if (y.diagonalDown) border.diagonalDown = parsexmlbool(y.diagonalDown);\n styles.Borders.push(border);\n break;\n case '':\n break;\n\n /* note: not in spec, appears to be CT_BorderPr */\n case '':\n break;\n case '':\n break;\n case '':\n break;\n\n /* note: not in spec, appears to be CT_BorderPr */\n case '':\n break;\n case '':\n break;\n case '':\n break;\n\n /* 18.8.43 top CT_BorderPr */\n case '':\n break;\n case '':\n break;\n case '':\n break;\n\n /* 18.8.6 bottom CT_BorderPr */\n case '':\n break;\n case '':\n break;\n case '':\n break;\n\n /* 18.8.13 diagonal CT_BorderPr */\n case '':\n case '':\n break;\n case '':\n break;\n\n /* 18.8.25 horizontal CT_BorderPr */\n case '':\n case '':\n break;\n case '':\n break;\n\n /* 18.8.44 vertical CT_BorderPr */\n case '':\n case '':\n break;\n case '':\n break;\n\n /* 18.8.37 start CT_BorderPr */\n case '':\n case '':\n break;\n case '':\n break;\n\n /* 18.8.16 end CT_BorderPr */\n case '':\n case '':\n break;\n case '':\n break;\n\n /* 18.8.? color CT_Color */\n case '':\n break;\n case '':\n case '':\n break;\n\n /* 18.2.10 extLst CT_ExtensionList ? */\n case '':\n case '':\n break;\n case '':\n pass = false;\n break;\n default:\n if (opts && opts.WTF) {\n if (!pass) throw new Error('unrecognized ' + y[0] + ' in borders');\n }\n }\n });\n}\n\n/* 18.8.21 fills CT_Fills */\nfunction parse_fills(t, styles, themes, opts) {\n styles.Fills = [];\n var fill = {};\n var pass = false;\n (t[0].match(tagregex) || []).forEach(function (x) {\n var y = parsexmltag(x);\n switch (strip_ns(y[0])) {\n case '':\n case '':\n break;\n\n /* 18.8.20 fill CT_Fill */\n case '':\n case '':\n fill = {};\n styles.Fills.push(fill);\n break;\n case '':\n break;\n\n /* 18.8.24 gradientFill CT_GradientFill */\n case '':\n break;\n case '':\n styles.Fills.push(fill);\n fill = {};\n break;\n\n /* 18.8.32 patternFill CT_PatternFill */\n case '':\n if (y.patternType) fill.patternType = y.patternType;\n break;\n case '':\n case '':\n break;\n\n /* 18.8.3 bgColor CT_Color */\n case '':\n case '':\n break;\n\n /* 18.8.19 fgColor CT_Color */\n case '':\n case '':\n break;\n\n /* 18.8.38 stop CT_GradientStop */\n case '':\n break;\n case '':\n break;\n\n /* 18.8.? color CT_Color */\n case '':\n break;\n case '':\n break;\n\n /* 18.2.10 extLst CT_ExtensionList ? */\n case '':\n case '':\n break;\n case '':\n pass = false;\n break;\n default:\n if (opts && opts.WTF) {\n if (!pass) throw new Error('unrecognized ' + y[0] + ' in fills');\n }\n }\n });\n}\n\n/* 18.8.23 fonts CT_Fonts */\nfunction parse_fonts(t, styles, themes, opts) {\n styles.Fonts = [];\n var font = {};\n var pass = false;\n (t[0].match(tagregex) || []).forEach(function (x) {\n var y = parsexmltag(x);\n switch (strip_ns(y[0])) {\n case '':\n case '':\n break;\n\n /* 18.8.22 font CT_Font */\n case '':\n break;\n case '':\n case '':\n styles.Fonts.push(font);\n font = {};\n break;\n\n /* 18.8.29 name CT_FontName */\n case '':\n case '':\n break;\n\n /* 18.8.2 b CT_BooleanProperty */\n case '':\n font.bold = 1;\n break;\n\n /* 18.8.26 i CT_BooleanProperty */\n case '':\n font.italic = 1;\n break;\n\n /* 18.4.13 u CT_UnderlineProperty */\n case '':\n font.underline = 1;\n break;\n\n /* 18.4.10 strike CT_BooleanProperty */\n case '':\n font.strike = 1;\n break;\n\n /* 18.4.2 outline CT_BooleanProperty */\n case '':\n font.outline = 1;\n break;\n\n /* 18.8.36 shadow CT_BooleanProperty */\n case '':\n font.shadow = 1;\n break;\n\n /* 18.8.12 condense CT_BooleanProperty */\n case '':\n font.condense = 1;\n break;\n\n /* 18.8.17 extend CT_BooleanProperty */\n case '':\n font.extend = 1;\n break;\n\n /* 18.4.11 sz CT_FontSize */\n case '':\n case '':\n break;\n\n /* 18.4.14 vertAlign CT_VerticalAlignFontProperty */\n case '':\n case '':\n break;\n\n /* 18.8.18 family CT_FontFamily */\n case '':\n case '':\n break;\n\n /* 18.8.35 scheme CT_FontScheme */\n case '':\n case '':\n break;\n\n /* 18.4.1 charset CT_IntProperty */\n case '':\n case '':\n break;\n\n /* note: sometimes mc:AlternateContent appears bare */\n case '':\n pass = false;\n break;\n\n /* 18.2.10 extLst CT_ExtensionList ? */\n case '':\n case '':\n break;\n case '':\n pass = false;\n break;\n default:\n if (opts && opts.WTF) {\n if (!pass) throw new Error('unrecognized ' + y[0] + ' in fonts');\n }\n }\n });\n}\n\n/* 18.8.31 numFmts CT_NumFmts */\nfunction parse_numFmts(t, styles, opts) {\n styles.NumberFmt = [];\n var k /*Array*/ = keys(table_fmt) /*:any*/;\n for (var i = 0; i < k.length; ++i) styles.NumberFmt[k[i]] = table_fmt[k[i]];\n var m = t[0].match(tagregex);\n if (!m) return;\n for (i = 0; i < m.length; ++i) {\n var y = parsexmltag(m[i]);\n switch (strip_ns(y[0])) {\n case '':\n case '':\n case '':\n break;\n case ' 0) {\n if (j > 0x188) {\n for (j = 0x188; j > 0x3c; --j) if (styles.NumberFmt[j] == null) break;\n styles.NumberFmt[j] = f;\n }\n SSF_load(f, j);\n }\n }\n break;\n case '':\n break;\n default:\n if (opts.WTF) throw new Error('unrecognized ' + y[0] + ' in numFmts');\n }\n }\n}\nfunction write_numFmts(NF /*:{[n:number|string]:string}*/ /*::, opts*/) {\n var o = [\"\"];\n [[5, 8], [23, 26], [41, 44], [/*63*/50, /*66],[164,*/392]].forEach(function (r) {\n for (var i = r[0]; i <= r[1]; ++i) if (NF[i] != null) o[o.length] = writextag('numFmt', null, {\n numFmtId: i,\n formatCode: escapexml(NF[i])\n });\n });\n if (o.length === 1) return \"\";\n o[o.length] = \"\";\n o[0] = writextag('numFmts', null, {\n count: o.length - 2\n }).replace(\"/>\", \">\");\n return o.join(\"\");\n}\n\n/* 18.8.10 cellXfs CT_CellXfs */\nvar cellXF_uint = [\"numFmtId\", \"fillId\", \"fontId\", \"borderId\", \"xfId\"];\nvar cellXF_bool = [\"applyAlignment\", \"applyBorder\", \"applyFill\", \"applyFont\", \"applyNumberFormat\", \"applyProtection\", \"pivotButton\", \"quotePrefix\"];\nfunction parse_cellXfs(t, styles, opts) {\n styles.CellXf = [];\n var xf;\n var pass = false;\n (t[0].match(tagregex) || []).forEach(function (x) {\n var y = parsexmltag(x),\n i = 0;\n switch (strip_ns(y[0])) {\n case '':\n case '':\n case '':\n break;\n\n /* 18.8.45 xf CT_Xf */\n case '':\n xf = y;\n delete xf[0];\n for (i = 0; i < cellXF_uint.length; ++i) if (xf[cellXF_uint[i]]) xf[cellXF_uint[i]] = parseInt(xf[cellXF_uint[i]], 10);\n for (i = 0; i < cellXF_bool.length; ++i) if (xf[cellXF_bool[i]]) xf[cellXF_bool[i]] = parsexmlbool(xf[cellXF_bool[i]]);\n if (styles.NumberFmt && xf.numFmtId > 0x188) {\n for (i = 0x188; i > 0x3c; --i) if (styles.NumberFmt[xf.numFmtId] == styles.NumberFmt[i]) {\n xf.numFmtId = i;\n break;\n }\n }\n styles.CellXf.push(xf);\n break;\n case '':\n break;\n\n /* 18.8.1 alignment CT_CellAlignment */\n case '':\n var alignment = {};\n if (y.vertical) alignment.vertical = y.vertical;\n if (y.horizontal) alignment.horizontal = y.horizontal;\n if (y.textRotation != null) alignment.textRotation = y.textRotation;\n if (y.indent) alignment.indent = y.indent;\n if (y.wrapText) alignment.wrapText = parsexmlbool(y.wrapText);\n xf.alignment = alignment;\n break;\n case '':\n break;\n\n /* 18.8.33 protection CT_CellProtection */\n case '':\n case '':\n break;\n\n /* note: sometimes mc:AlternateContent appears bare */\n case '':\n pass = false;\n break;\n\n /* 18.2.10 extLst CT_ExtensionList ? */\n case '':\n case '':\n break;\n case '':\n pass = false;\n break;\n default:\n if (opts && opts.WTF) {\n if (!pass) throw new Error('unrecognized ' + y[0] + ' in cellXfs');\n }\n }\n });\n}\nfunction write_cellXfs(cellXfs) /*:string*/{\n var o /*:Array*/ = [];\n o[o.length] = writextag('cellXfs', null);\n cellXfs.forEach(function (c) {\n o[o.length] = writextag('xf', null, c);\n });\n o[o.length] = \"\";\n if (o.length === 2) return \"\";\n o[0] = writextag('cellXfs', null, {\n count: o.length - 2\n }).replace(\"/>\", \">\");\n return o.join(\"\");\n}\n\n/* 18.8 Styles CT_Stylesheet*/\nvar parse_sty_xml = /*#__PURE__*/function make_pstyx() {\n var numFmtRegex = /<(?:\\w+:)?numFmts([^>]*)>[\\S\\s]*?<\\/(?:\\w+:)?numFmts>/;\n var cellXfRegex = /<(?:\\w+:)?cellXfs([^>]*)>[\\S\\s]*?<\\/(?:\\w+:)?cellXfs>/;\n var fillsRegex = /<(?:\\w+:)?fills([^>]*)>[\\S\\s]*?<\\/(?:\\w+:)?fills>/;\n var fontsRegex = /<(?:\\w+:)?fonts([^>]*)>[\\S\\s]*?<\\/(?:\\w+:)?fonts>/;\n var bordersRegex = /<(?:\\w+:)?borders([^>]*)>[\\S\\s]*?<\\/(?:\\w+:)?borders>/;\n return function parse_sty_xml(data, themes, opts) {\n var styles = {};\n if (!data) return styles;\n data = data.replace(//mg, \"\").replace(//gm, \"\");\n /* 18.8.39 styleSheet CT_Stylesheet */\n var t;\n\n /* 18.8.31 numFmts CT_NumFmts ? */\n if (t = data.match(numFmtRegex)) parse_numFmts(t, styles, opts);\n\n /* 18.8.23 fonts CT_Fonts ? */\n if (t = data.match(fontsRegex)) parse_fonts(t, styles, themes, opts);\n\n /* 18.8.21 fills CT_Fills ? */\n if (t = data.match(fillsRegex)) parse_fills(t, styles, themes, opts);\n\n /* 18.8.5 borders CT_Borders ? */\n if (t = data.match(bordersRegex)) parse_borders(t, styles, themes, opts);\n\n /* 18.8.9 cellStyleXfs CT_CellStyleXfs ? */\n /* 18.8.8 cellStyles CT_CellStyles ? */\n\n /* 18.8.10 cellXfs CT_CellXfs ? */\n if (t = data.match(cellXfRegex)) parse_cellXfs(t, styles, opts);\n\n /* 18.8.15 dxfs CT_Dxfs ? */\n /* 18.8.42 tableStyles CT_TableStyles ? */\n /* 18.8.11 colors CT_Colors ? */\n /* 18.2.10 extLst CT_ExtensionList ? */\n\n return styles;\n };\n}();\nfunction write_sty_xml(wb /*:Workbook*/, opts) /*:string*/{\n var o = [XML_HEADER, writextag('styleSheet', null, {\n 'xmlns': XMLNS_main[0],\n 'xmlns:vt': XMLNS.vt\n })],\n w;\n if (wb.SSF && (w = write_numFmts(wb.SSF)) != null) o[o.length] = w;\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n if (w = write_cellXfs(opts.cellXfs)) o[o.length] = w;\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n if (o.length > 2) {\n o[o.length] = '';\n o[1] = o[1].replace(\"/>\", \">\");\n }\n return o.join(\"\");\n}\n/* [MS-XLSB] 2.4.657 BrtFmt */\nfunction parse_BrtFmt(data, length /*:number*/) {\n var numFmtId = data.read_shift(2);\n var stFmtCode = parse_XLWideString(data, length - 2);\n return [numFmtId, stFmtCode];\n}\nfunction write_BrtFmt(i /*:number*/, f /*:string*/, o) {\n if (!o) o = new_buf(6 + 4 * f.length);\n o.write_shift(2, i);\n write_XLWideString(f, o);\n var out = o.length > o.l ? o.slice(0, o.l) : o;\n if (o.l == null) o.l = o.length;\n return out;\n}\n\n/* [MS-XLSB] 2.4.659 BrtFont TODO */\nfunction parse_BrtFont(data, length /*:number*/, opts) {\n var out = {} /*:any*/;\n out.sz = data.read_shift(2) / 20;\n var grbit = parse_FontFlags(data, 2, opts);\n if (grbit.fItalic) out.italic = 1;\n if (grbit.fCondense) out.condense = 1;\n if (grbit.fExtend) out.extend = 1;\n if (grbit.fShadow) out.shadow = 1;\n if (grbit.fOutline) out.outline = 1;\n if (grbit.fStrikeout) out.strike = 1;\n var bls = data.read_shift(2);\n if (bls === 0x02BC) out.bold = 1;\n switch (data.read_shift(2)) {\n /* case 0: out.vertAlign = \"baseline\"; break; */\n case 1:\n out.vertAlign = \"superscript\";\n break;\n case 2:\n out.vertAlign = \"subscript\";\n break;\n }\n var underline = data.read_shift(1);\n if (underline != 0) out.underline = underline;\n var family = data.read_shift(1);\n if (family > 0) out.family = family;\n var bCharSet = data.read_shift(1);\n if (bCharSet > 0) out.charset = bCharSet;\n data.l++;\n out.color = parse_BrtColor(data, 8);\n switch (data.read_shift(1)) {\n /* case 0: out.scheme = \"none\": break; */\n case 1:\n out.scheme = \"major\";\n break;\n case 2:\n out.scheme = \"minor\";\n break;\n }\n out.name = parse_XLWideString(data, length - 21);\n return out;\n}\nfunction write_BrtFont(font /*:any*/, o) {\n if (!o) o = new_buf(25 + 4 * 32);\n o.write_shift(2, font.sz * 20);\n write_FontFlags(font, o);\n o.write_shift(2, font.bold ? 0x02BC : 0x0190);\n var sss = 0;\n if (font.vertAlign == \"superscript\") sss = 1;else if (font.vertAlign == \"subscript\") sss = 2;\n o.write_shift(2, sss);\n o.write_shift(1, font.underline || 0);\n o.write_shift(1, font.family || 0);\n o.write_shift(1, font.charset || 0);\n o.write_shift(1, 0);\n write_BrtColor(font.color, o);\n var scheme = 0;\n if (font.scheme == \"major\") scheme = 1;\n if (font.scheme == \"minor\") scheme = 2;\n o.write_shift(1, scheme);\n write_XLWideString(font.name, o);\n return o.length > o.l ? o.slice(0, o.l) : o;\n}\n\n/* [MS-XLSB] 2.4.650 BrtFill */\nvar XLSBFillPTNames = [\"none\", \"solid\", \"mediumGray\", \"darkGray\", \"lightGray\", \"darkHorizontal\", \"darkVertical\", \"darkDown\", \"darkUp\", \"darkGrid\", \"darkTrellis\", \"lightHorizontal\", \"lightVertical\", \"lightDown\", \"lightUp\", \"lightGrid\", \"lightTrellis\", \"gray125\", \"gray0625\"];\nvar rev_XLSBFillPTNames /*:EvertNumType*/;\n/* TODO: gradient fill representation */\nvar parse_BrtFill = parsenoop;\nfunction write_BrtFill(fill, o) {\n if (!o) o = new_buf(4 * 3 + 8 * 7 + 16 * 1);\n if (!rev_XLSBFillPTNames) rev_XLSBFillPTNames = evert(XLSBFillPTNames) /*:any*/;\n var fls /*:number*/ = rev_XLSBFillPTNames[fill.patternType];\n if (fls == null) fls = 0x28;\n o.write_shift(4, fls);\n var j = 0;\n if (fls != 0x28) {\n /* TODO: custom FG Color */\n write_BrtColor({\n auto: 1\n }, o);\n /* TODO: custom BG Color */\n write_BrtColor({\n auto: 1\n }, o);\n for (; j < 12; ++j) o.write_shift(4, 0);\n } else {\n for (; j < 4; ++j) o.write_shift(4, 0);\n for (; j < 12; ++j) o.write_shift(4, 0); /* TODO */\n /* iGradientType */\n /* xnumDegree */\n /* xnumFillToLeft */\n /* xnumFillToRight */\n /* xnumFillToTop */\n /* xnumFillToBottom */\n /* cNumStop */\n /* xfillGradientStop */\n }\n return o.length > o.l ? o.slice(0, o.l) : o;\n}\n\n/* [MS-XLSB] 2.4.824 BrtXF */\nfunction parse_BrtXF(data, length /*:number*/) {\n var tgt = data.l + length;\n var ixfeParent = data.read_shift(2);\n var ifmt = data.read_shift(2);\n data.l = tgt;\n return {\n ixfe: ixfeParent,\n numFmtId: ifmt\n };\n}\nfunction write_BrtXF(data, ixfeP, o) {\n if (!o) o = new_buf(16);\n o.write_shift(2, ixfeP || 0);\n o.write_shift(2, data.numFmtId || 0);\n o.write_shift(2, 0); /* iFont */\n o.write_shift(2, 0); /* iFill */\n o.write_shift(2, 0); /* ixBorder */\n o.write_shift(1, 0); /* trot */\n o.write_shift(1, 0); /* indent */\n var flow = 0;\n o.write_shift(1, flow); /* flags */\n o.write_shift(1, 0); /* flags */\n o.write_shift(1, 0); /* xfGrbitAtr */\n o.write_shift(1, 0);\n return o;\n}\n\n/* [MS-XLSB] 2.5.4 Blxf TODO */\nfunction write_Blxf(data, o) {\n if (!o) o = new_buf(10);\n o.write_shift(1, 0); /* dg */\n o.write_shift(1, 0);\n o.write_shift(4, 0); /* color */\n o.write_shift(4, 0); /* color */\n return o;\n}\n/* [MS-XLSB] 2.4.302 BrtBorder TODO */\nvar parse_BrtBorder = parsenoop;\nfunction write_BrtBorder(border, o) {\n if (!o) o = new_buf(51);\n o.write_shift(1, 0); /* diagonal */\n write_Blxf(null, o); /* top */\n write_Blxf(null, o); /* bottom */\n write_Blxf(null, o); /* left */\n write_Blxf(null, o); /* right */\n write_Blxf(null, o); /* diag */\n return o.length > o.l ? o.slice(0, o.l) : o;\n}\n\n/* [MS-XLSB] 2.4.763 BrtStyle TODO */\nfunction write_BrtStyle(style, o) {\n if (!o) o = new_buf(12 + 4 * 10);\n o.write_shift(4, style.xfId);\n o.write_shift(2, 1);\n o.write_shift(1, +style.builtinId);\n o.write_shift(1, 0); /* iLevel */\n write_XLNullableWideString(style.name || \"\", o);\n return o.length > o.l ? o.slice(0, o.l) : o;\n}\n\n/* [MS-XLSB] 2.4.272 BrtBeginTableStyles */\nfunction write_BrtBeginTableStyles(cnt, defTableStyle, defPivotStyle) {\n var o = new_buf(4 + 256 * 2 * 4);\n o.write_shift(4, cnt);\n write_XLNullableWideString(defTableStyle, o);\n write_XLNullableWideString(defPivotStyle, o);\n return o.length > o.l ? o.slice(0, o.l) : o;\n}\n\n/* [MS-XLSB] 2.1.7.50 Styles */\nfunction parse_sty_bin(data, themes, opts) {\n var styles = {};\n styles.NumberFmt = [] /*:any*/;\n for (var y in table_fmt) styles.NumberFmt[y] = table_fmt[y];\n styles.CellXf = [];\n styles.Fonts = [];\n var state /*:Array*/ = [];\n var pass = false;\n recordhopper(data, function hopper_sty(val, R, RT) {\n switch (RT) {\n case 0x002C:\n /* BrtFmt */\n styles.NumberFmt[val[0]] = val[1];\n SSF_load(val[1], val[0]);\n break;\n case 0x002B:\n /* BrtFont */\n styles.Fonts.push(val);\n if (val.color.theme != null && themes && themes.themeElements && themes.themeElements.clrScheme) {\n val.color.rgb = rgb_tint(themes.themeElements.clrScheme[val.color.theme].rgb, val.color.tint || 0);\n }\n break;\n case 0x0401:\n /* BrtKnownFonts */break;\n case 0x002D:\n /* BrtFill */\n break;\n case 0x002E:\n /* BrtBorder */\n break;\n case 0x002F:\n /* BrtXF */\n if (state[state.length - 1] == 0x0269 /* BrtBeginCellXFs */) {\n styles.CellXf.push(val);\n }\n break;\n case 0x0030: /* BrtStyle */\n case 0x01FB: /* BrtDXF */\n case 0x023C: /* BrtMRUColor */\n case 0x01DB:\n /* BrtIndexedColor */\n break;\n case 0x0493: /* BrtDXF14 */\n case 0x0836: /* BrtDXF15 */\n case 0x046A: /* BrtSlicerStyleElement */\n case 0x0200: /* BrtTableStyleElement */\n case 0x082F: /* BrtTimelineStyleElement */\n case 0x0C00:\n /* BrtUid */\n break;\n case 0x0023:\n /* BrtFRTBegin */\n pass = true;\n break;\n case 0x0024:\n /* BrtFRTEnd */\n pass = false;\n break;\n case 0x0025:\n /* BrtACBegin */\n state.push(RT);\n pass = true;\n break;\n case 0x0026:\n /* BrtACEnd */\n state.pop();\n pass = false;\n break;\n default:\n if (R.T > 0) state.push(RT);else if (R.T < 0) state.pop();else if (!pass || opts.WTF && state[state.length - 1] != 0x0025 /* BrtACBegin */) throw new Error(\"Unexpected record 0x\" + RT.toString(16));\n }\n });\n return styles;\n}\nfunction write_FMTS_bin(ba, NF /*:?SSFTable*/) {\n if (!NF) return;\n var cnt = 0;\n [[5, 8], [23, 26], [41, 44], [/*63*/50, /*66],[164,*/392]].forEach(function (r) {\n /*:: if(!NF) return; */\n for (var i = r[0]; i <= r[1]; ++i) if (NF[i] != null) ++cnt;\n });\n if (cnt == 0) return;\n write_record(ba, 0x0267 /* BrtBeginFmts */, write_UInt32LE(cnt));\n [[5, 8], [23, 26], [41, 44], [/*63*/50, /*66],[164,*/392]].forEach(function (r) {\n /*:: if(!NF) return; */\n for (var i = r[0]; i <= r[1]; ++i) if (NF[i] != null) write_record(ba, 0x002C /* BrtFmt */, write_BrtFmt(i, NF[i]));\n });\n write_record(ba, 0x0268 /* BrtEndFmts */);\n}\nfunction write_FONTS_bin(ba /*::, data*/) {\n var cnt = 1;\n if (cnt == 0) return;\n write_record(ba, 0x0263 /* BrtBeginFonts */, write_UInt32LE(cnt));\n write_record(ba, 0x002B /* BrtFont */, write_BrtFont({\n sz: 12,\n color: {\n theme: 1\n },\n name: \"Calibri\",\n family: 2,\n scheme: \"minor\"\n }));\n /* 1*65491BrtFont [ACFONTS] */\n write_record(ba, 0x0264 /* BrtEndFonts */);\n}\nfunction write_FILLS_bin(ba /*::, data*/) {\n var cnt = 2;\n if (cnt == 0) return;\n write_record(ba, 0x025B /* BrtBeginFills */, write_UInt32LE(cnt));\n write_record(ba, 0x002D /* BrtFill */, write_BrtFill({\n patternType: \"none\"\n }));\n write_record(ba, 0x002D /* BrtFill */, write_BrtFill({\n patternType: \"gray125\"\n }));\n /* 1*65431BrtFill */\n write_record(ba, 0x025C /* BrtEndFills */);\n}\nfunction write_BORDERS_bin(ba /*::, data*/) {\n var cnt = 1;\n if (cnt == 0) return;\n write_record(ba, 0x0265 /* BrtBeginBorders */, write_UInt32LE(cnt));\n write_record(ba, 0x002E /* BrtBorder */, write_BrtBorder({}));\n /* 1*65430BrtBorder */\n write_record(ba, 0x0266 /* BrtEndBorders */);\n}\nfunction write_CELLSTYLEXFS_bin(ba /*::, data*/) {\n var cnt = 1;\n write_record(ba, 0x0272 /* BrtBeginCellStyleXFs */, write_UInt32LE(cnt));\n write_record(ba, 0x002F /* BrtXF */, write_BrtXF({\n numFmtId: 0,\n fontId: 0,\n fillId: 0,\n borderId: 0\n }, 0xFFFF));\n /* 1*65430(BrtXF *FRT) */\n write_record(ba, 0x0273 /* BrtEndCellStyleXFs */);\n}\nfunction write_CELLXFS_bin(ba, data) {\n write_record(ba, 0x0269 /* BrtBeginCellXFs */, write_UInt32LE(data.length));\n data.forEach(function (c) {\n write_record(ba, 0x002F /* BrtXF */, write_BrtXF(c, 0));\n });\n /* 1*65430(BrtXF *FRT) */\n write_record(ba, 0x026A /* BrtEndCellXFs */);\n}\nfunction write_STYLES_bin(ba /*::, data*/) {\n var cnt = 1;\n write_record(ba, 0x026B /* BrtBeginStyles */, write_UInt32LE(cnt));\n write_record(ba, 0x0030 /* BrtStyle */, write_BrtStyle({\n xfId: 0,\n builtinId: 0,\n name: \"Normal\"\n }));\n /* 1*65430(BrtStyle *FRT) */\n write_record(ba, 0x026C /* BrtEndStyles */);\n}\nfunction write_DXFS_bin(ba /*::, data*/) {\n var cnt = 0;\n write_record(ba, 0x01F9 /* BrtBeginDXFs */, write_UInt32LE(cnt));\n /* *2147483647(BrtDXF *FRT) */\n write_record(ba, 0x01FA /* BrtEndDXFs */);\n}\nfunction write_TABLESTYLES_bin(ba /*::, data*/) {\n var cnt = 0;\n write_record(ba, 0x01FC /* BrtBeginTableStyles */, write_BrtBeginTableStyles(cnt, \"TableStyleMedium9\", \"PivotStyleMedium4\"));\n /* *TABLESTYLE */\n write_record(ba, 0x01FD /* BrtEndTableStyles */);\n}\nfunction write_COLORPALETTE_bin(/*::ba, data*/\n) {\n return;\n /* BrtBeginColorPalette [INDEXEDCOLORS] [MRUCOLORS] BrtEndColorPalette */\n}\n\n/* [MS-XLSB] 2.1.7.50 Styles */\nfunction write_sty_bin(wb, opts) {\n var ba = buf_array();\n write_record(ba, 0x0116 /* BrtBeginStyleSheet */);\n write_FMTS_bin(ba, wb.SSF);\n write_FONTS_bin(ba, wb);\n write_FILLS_bin(ba, wb);\n write_BORDERS_bin(ba, wb);\n write_CELLSTYLEXFS_bin(ba, wb);\n write_CELLXFS_bin(ba, opts.cellXfs);\n write_STYLES_bin(ba, wb);\n write_DXFS_bin(ba, wb);\n write_TABLESTYLES_bin(ba, wb);\n write_COLORPALETTE_bin(ba, wb);\n /* FRTSTYLESHEET*/\n write_record(ba, 0x0117 /* BrtEndStyleSheet */);\n return ba.end();\n}\n/* Even though theme layout is dk1 lt1 dk2 lt2, true order is lt1 dk1 lt2 dk2 */\nvar XLSXThemeClrScheme = ['', '', '', '', '', '', '', '', '', '', '', ''];\n/* 20.1.6.2 clrScheme CT_ColorScheme */\nfunction parse_clrScheme(t, themes, opts) {\n themes.themeElements.clrScheme = [];\n var color = {};\n (t[0].match(tagregex) || []).forEach(function (x) {\n var y = parsexmltag(x);\n switch (y[0]) {\n /* 20.1.6.2 clrScheme (Color Scheme) CT_ColorScheme */\n case '':\n break;\n\n /* 20.1.2.3.32 srgbClr CT_SRgbColor */\n case '':\n case '':\n case '':\n case '':\n case '':\n case '':\n case '':\n case '':\n case '':\n case '':\n case '':\n case '':\n case '':\n case '':\n case '':\n case '':\n case '':\n case '':\n case '':\n case '':\n case '':\n case '':\n case '':\n case '':\n if (y[0].charAt(1) === '/') {\n themes.themeElements.clrScheme[XLSXThemeClrScheme.indexOf(y[0])] = color;\n color = {};\n } else {\n color.name = y[0].slice(3, y[0].length - 1);\n }\n break;\n default:\n if (opts && opts.WTF) throw new Error('Unrecognized ' + y[0] + ' in clrScheme');\n }\n });\n}\n\n/* 20.1.4.1.18 fontScheme CT_FontScheme */\nfunction parse_fontScheme(/*::t, themes, opts*/) {}\n\n/* 20.1.4.1.15 fmtScheme CT_StyleMatrix */\nfunction parse_fmtScheme(/*::t, themes, opts*/) {}\nvar clrsregex = /]*)>[\\s\\S]*<\\/a:clrScheme>/;\nvar fntsregex = /]*)>[\\s\\S]*<\\/a:fontScheme>/;\nvar fmtsregex = /]*)>[\\s\\S]*<\\/a:fmtScheme>/;\n\n/* 20.1.6.10 themeElements CT_BaseStyles */\nfunction parse_themeElements(data, themes, opts) {\n themes.themeElements = {};\n var t;\n [/* clrScheme CT_ColorScheme */\n ['clrScheme', clrsregex, parse_clrScheme], /* fontScheme CT_FontScheme */\n ['fontScheme', fntsregex, parse_fontScheme], /* fmtScheme CT_StyleMatrix */\n ['fmtScheme', fmtsregex, parse_fmtScheme]].forEach(function (m) {\n if (!(t = data.match(m[1]))) throw new Error(m[0] + ' not found in themeElements');\n m[2](t, themes, opts);\n });\n}\nvar themeltregex = /]*)>[\\s\\S]*<\\/a:themeElements>/;\n\n/* 14.2.7 Theme Part */\nfunction parse_theme_xml(data /*:string*/, opts) {\n /* 20.1.6.9 theme CT_OfficeStyleSheet */\n if (!data || data.length === 0) data = write_theme();\n var t;\n var themes = {};\n\n /* themeElements CT_BaseStyles */\n if (!(t = data.match(themeltregex))) throw new Error('themeElements not found in theme');\n parse_themeElements(t[0], themes, opts);\n themes.raw = data;\n return themes;\n}\nfunction write_theme(Themes, opts) /*:string*/{\n if (opts && opts.themeXLSX) return opts.themeXLSX;\n if (Themes && typeof Themes.raw == \"string\") return Themes.raw;\n var o = [XML_HEADER];\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n o[o.length] = '';\n return o.join(\"\");\n}\n/* [MS-XLS] 2.4.326 TODO: payload is a zip file */\nfunction parse_Theme(blob, length, opts) {\n var end = blob.l + length;\n var dwThemeVersion = blob.read_shift(4);\n if (dwThemeVersion === 124226) return;\n if (!opts.cellStyles) {\n blob.l = end;\n return;\n }\n var data = blob.slice(blob.l);\n blob.l = end;\n var zip;\n try {\n zip = zip_read(data, {\n type: \"array\"\n });\n } catch (e) {\n return;\n }\n var themeXML = getzipstr(zip, \"theme/theme/theme1.xml\", true);\n if (!themeXML) return;\n return parse_theme_xml(themeXML, opts);\n}\n\n/* 2.5.49 */\nfunction parse_ColorTheme(blob /*::, length*/) {\n return blob.read_shift(4);\n}\n\n/* 2.5.155 */\nfunction parse_FullColorExt(blob /*::, length*/) {\n var o = {};\n o.xclrType = blob.read_shift(2);\n o.nTintShade = blob.read_shift(2);\n switch (o.xclrType) {\n case 0:\n blob.l += 4;\n break;\n case 1:\n o.xclrValue = parse_IcvXF(blob, 4);\n break;\n case 2:\n o.xclrValue = parse_LongRGBA(blob, 4);\n break;\n case 3:\n o.xclrValue = parse_ColorTheme(blob, 4);\n break;\n case 4:\n blob.l += 4;\n break;\n }\n blob.l += 8;\n return o;\n}\n\n/* 2.5.164 TODO: read 7 bits*/\nfunction parse_IcvXF(blob, length) {\n return parsenoop(blob, length);\n}\n\n/* 2.5.280 */\nfunction parse_XFExtGradient(blob, length) {\n return parsenoop(blob, length);\n}\n\n/* [MS-XLS] 2.5.108 */\nfunction parse_ExtProp(blob /*::, length*/) /*:Array*/{\n var extType = blob.read_shift(2);\n var cb = blob.read_shift(2) - 4;\n var o = [extType];\n switch (extType) {\n case 0x04:\n case 0x05:\n case 0x07:\n case 0x08:\n case 0x09:\n case 0x0A:\n case 0x0B:\n case 0x0D:\n o[1] = parse_FullColorExt(blob, cb);\n break;\n case 0x06:\n o[1] = parse_XFExtGradient(blob, cb);\n break;\n case 0x0E:\n case 0x0F:\n o[1] = blob.read_shift(cb === 1 ? 1 : 2);\n break;\n default:\n throw new Error(\"Unrecognized ExtProp type: \" + extType + \" \" + cb);\n }\n return o;\n}\n\n/* 2.4.355 */\nfunction parse_XFExt(blob, length) {\n var end = blob.l + length;\n blob.l += 2;\n var ixfe = blob.read_shift(2);\n blob.l += 2;\n var cexts = blob.read_shift(2);\n var ext /*:AOA*/ = [];\n while (cexts-- > 0) ext.push(parse_ExtProp(blob, end - blob.l));\n return {\n ixfe: ixfe,\n ext: ext\n };\n}\n\n/* xf is an XF, see parse_XFExt for xfext */\nfunction update_xfext(xf, xfext) {\n xfext.forEach(function (xfe) {\n switch (xfe[0]) {\n /* 2.5.108 extPropData */\n case 0x04:\n break;\n /* foreground color */\n case 0x05:\n break;\n /* background color */\n case 0x06:\n break;\n /* gradient fill */\n case 0x07:\n break;\n /* top cell border color */\n case 0x08:\n break;\n /* bottom cell border color */\n case 0x09:\n break;\n /* left cell border color */\n case 0x0a:\n break;\n /* right cell border color */\n case 0x0b:\n break;\n /* diagonal cell border color */\n case 0x0d:\n /* text color */\n break;\n case 0x0e:\n break;\n /* font scheme */\n case 0x0f:\n break;\n /* indentation level */\n }\n });\n}\nfunction parse_BrtMdtinfo(data, length) {\n return {\n flags: data.read_shift(4),\n version: data.read_shift(4),\n name: parse_XLWideString(data, length - 8)\n };\n}\nfunction write_BrtMdtinfo(data) {\n var o = new_buf(12 + 2 * data.name.length);\n o.write_shift(4, data.flags);\n o.write_shift(4, data.version);\n write_XLWideString(data.name, o);\n return o.slice(0, o.l);\n}\nfunction parse_BrtMdb(data) {\n var out = [];\n var cnt = data.read_shift(4);\n while (cnt-- > 0) out.push([data.read_shift(4), data.read_shift(4)]);\n return out;\n}\nfunction write_BrtMdb(mdb) {\n var o = new_buf(4 + 8 * mdb.length);\n o.write_shift(4, mdb.length);\n for (var i = 0; i < mdb.length; ++i) {\n o.write_shift(4, mdb[i][0]);\n o.write_shift(4, mdb[i][1]);\n }\n return o;\n}\nfunction write_BrtBeginEsfmd(cnt, name) {\n var o = new_buf(8 + 2 * name.length);\n o.write_shift(4, cnt);\n write_XLWideString(name, o);\n return o.slice(0, o.l);\n}\nfunction parse_BrtBeginEsmdb(data) {\n data.l += 4;\n return data.read_shift(4) != 0;\n}\nfunction write_BrtBeginEsmdb(cnt, cm) {\n var o = new_buf(8);\n o.write_shift(4, cnt);\n o.write_shift(4, cm ? 1 : 0);\n return o;\n}\nfunction parse_xlmeta_bin(data, name, _opts) {\n var out = {\n Types: [],\n Cell: [],\n Value: []\n };\n var opts = _opts || {};\n var state = [];\n var pass = false;\n var metatype = 2;\n recordhopper(data, function (val, R, RT) {\n switch (RT) {\n case 335:\n out.Types.push({\n name: val.name\n });\n break;\n case 51:\n val.forEach(function (r) {\n if (metatype == 1) out.Cell.push({\n type: out.Types[r[0] - 1].name,\n index: r[1]\n });else if (metatype == 0) out.Value.push({\n type: out.Types[r[0] - 1].name,\n index: r[1]\n });\n });\n break;\n case 337:\n metatype = val ? 1 : 0;\n break;\n case 338:\n metatype = 2;\n break;\n case 35:\n state.push(RT);\n pass = true;\n break;\n case 36:\n state.pop();\n pass = false;\n break;\n default:\n if (R.T) {} else if (!pass || opts.WTF && state[state.length - 1] != 35) throw new Error(\"Unexpected record 0x\" + RT.toString(16));\n }\n });\n return out;\n}\nfunction write_xlmeta_bin() {\n var ba = buf_array();\n write_record(ba, 332);\n write_record(ba, 334, write_UInt32LE(1));\n write_record(ba, 335, write_BrtMdtinfo({\n name: \"XLDAPR\",\n version: 12e4,\n flags: 3496657072\n }));\n write_record(ba, 336);\n write_record(ba, 339, write_BrtBeginEsfmd(1, \"XLDAPR\"));\n write_record(ba, 52);\n write_record(ba, 35, write_UInt32LE(514));\n write_record(ba, 4096, write_UInt32LE(0));\n write_record(ba, 4097, writeuint16(1));\n write_record(ba, 36);\n write_record(ba, 53);\n write_record(ba, 340);\n write_record(ba, 337, write_BrtBeginEsmdb(1, true));\n write_record(ba, 51, write_BrtMdb([[1, 0]]));\n write_record(ba, 338);\n write_record(ba, 333);\n return ba.end();\n}\nfunction parse_xlmeta_xml(data, name, opts) {\n var out = {\n Types: [],\n Cell: [],\n Value: []\n };\n if (!data) return out;\n var pass = false;\n var metatype = 2;\n var lastmeta;\n data.replace(tagregex, function (x) {\n var y = parsexmltag(x);\n switch (strip_ns(y[0])) {\n case \"\":\n break;\n case \"\":\n break;\n case \"\":\n break;\n case \"\":\n break;\n case \"\":\n break;\n case \"\":\n break;\n case \"\":\n break;\n case \"\":\n metatype = 2;\n break;\n case \"\":\n metatype = 2;\n break;\n case \"\":\n case \"\":\n case \"\":\n break;\n case \"\":\n pass = false;\n break;\n case \"\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n');\n return o.join(\"\");\n}\n/* 18.6 Calculation Chain */\nfunction parse_cc_xml(data /*::, name, opts*/) /*:Array*/{\n var d = [];\n if (!data) return d;\n var i = 1;\n (data.match(tagregex) || []).forEach(function (x) {\n var y = parsexmltag(x);\n switch (y[0]) {\n case '':\n case '':\n break;\n /* 18.6.1 c CT_CalcCell 1 */\n case ']*r:id=\"([^\"]*)\"/) || [\"\", \"\"])[1];\n return rels['!id'][id].Target;\n}\n\n/* L.5.5.2 SpreadsheetML Comments + VML Schema */\nvar _shapeid = 1024;\nfunction write_comments_vml(rId /*:number*/, comments) {\n var csize = [21600, 21600];\n /* L.5.2.1.2 Path Attribute */\n var bbox = [\"m0,0l0\", csize[1], csize[0], csize[1], csize[0], \"0xe\"].join(\",\");\n var o = [writextag(\"xml\", null, {\n 'xmlns:v': XLMLNS.v,\n 'xmlns:o': XLMLNS.o,\n 'xmlns:x': XLMLNS.x,\n 'xmlns:mv': XLMLNS.mv\n }).replace(/\\/>/, \">\"), writextag(\"o:shapelayout\", writextag(\"o:idmap\", null, {\n 'v:ext': \"edit\",\n 'data': rId\n }), {\n 'v:ext': \"edit\"\n }), writextag(\"v:shapetype\", [writextag(\"v:stroke\", null, {\n joinstyle: \"miter\"\n }), writextag(\"v:path\", null, {\n gradientshapeok: \"t\",\n 'o:connecttype': \"rect\"\n })].join(\"\"), {\n id: \"_x0000_t202\",\n 'o:spt': 202,\n coordsize: csize.join(\",\"),\n path: bbox\n })];\n while (_shapeid < rId * 1000) _shapeid += 1000;\n comments.forEach(function (x) {\n var c = decode_cell(x[0]);\n var fillopts = /*::(*/{\n 'color2': \"#BEFF82\",\n 'type': \"gradient\"\n } /*:: :any)*/;\n if (fillopts.type == \"gradient\") fillopts.angle = \"-180\";\n var fillparm = fillopts.type == \"gradient\" ? writextag(\"o:fill\", null, {\n type: \"gradientUnscaled\",\n 'v:ext': \"view\"\n }) : null;\n var fillxml = writextag('v:fill', fillparm, fillopts);\n var shadata = {\n on: \"t\",\n 'obscured': \"t\"\n } /*:any*/;\n ++_shapeid;\n o = o.concat(['', fillxml, writextag(\"v:shadow\", null, shadata), writextag(\"v:path\", null, {\n 'o:connecttype': \"none\"\n }), '
', '', '', '', /* Part 4 19.4.2.3 Anchor (Anchor) */\n writetag('x:Anchor', [c.c + 1, 0, c.r + 1, 0, c.c + 3, 20, c.r + 5, 20].join(\",\")), writetag('x:AutoFill', \"False\"), writetag('x:Row', String(c.r)), writetag('x:Column', String(c.c)), x[1].hidden ? '' : '', '', '']);\n });\n o.push('');\n return o.join(\"\");\n}\nfunction sheet_insert_comments(sheet, comments /*:Array*/, threaded /*:boolean*/, people /*:?Array*/) {\n var dense = Array.isArray(sheet);\n var cell /*:Cell*/;\n comments.forEach(function (comment) {\n var r = decode_cell(comment.ref);\n if (dense) {\n if (!sheet[r.r]) sheet[r.r] = [];\n cell = sheet[r.r][r.c];\n } else cell = sheet[comment.ref];\n if (!cell) {\n cell = {\n t: \"z\"\n } /*:any*/;\n if (dense) sheet[r.r][r.c] = cell;else sheet[comment.ref] = cell;\n var range = safe_decode_range(sheet[\"!ref\"] || \"BDWGO1000001:A1\");\n if (range.s.r > r.r) range.s.r = r.r;\n if (range.e.r < r.r) range.e.r = r.r;\n if (range.s.c > r.c) range.s.c = r.c;\n if (range.e.c < r.c) range.e.c = r.c;\n var encoded = encode_range(range);\n if (encoded !== sheet[\"!ref\"]) sheet[\"!ref\"] = encoded;\n }\n if (!cell.c) cell.c = [];\n var o /*:Comment*/ = {\n a: comment.author,\n t: comment.t,\n r: comment.r,\n T: threaded\n };\n if (comment.h) o.h = comment.h;\n\n /* threaded comments always override */\n for (var i = cell.c.length - 1; i >= 0; --i) {\n if (!threaded && cell.c[i].T) return;\n if (threaded && !cell.c[i].T) cell.c.splice(i, 1);\n }\n if (threaded && people) for (i = 0; i < people.length; ++i) {\n if (o.a == people[i].id) {\n o.a = people[i].name || o.a;\n break;\n }\n }\n cell.c.push(o);\n });\n}\n\n/* 18.7 Comments */\nfunction parse_comments_xml(data /*:string*/, opts) /*:Array*/{\n /* 18.7.6 CT_Comments */\n if (data.match(/<(?:\\w+:)?comments *\\/>/)) return [];\n var authors /*:Array*/ = [];\n var commentList /*:Array*/ = [];\n var authtag = data.match(/<(?:\\w+:)?authors>([\\s\\S]*)<\\/(?:\\w+:)?authors>/);\n if (authtag && authtag[1]) authtag[1].split(/<\\/\\w*:?author>/).forEach(function (x) {\n if (x === \"\" || x.trim() === \"\") return;\n var a = x.match(/<(?:\\w+:)?author[^>]*>(.*)/);\n if (a) authors.push(a[1]);\n });\n var cmnttag = data.match(/<(?:\\w+:)?commentList>([\\s\\S]*)<\\/(?:\\w+:)?commentList>/);\n if (cmnttag && cmnttag[1]) cmnttag[1].split(/<\\/\\w*:?comment>/).forEach(function (x) {\n if (x === \"\" || x.trim() === \"\") return;\n var cm = x.match(/<(?:\\w+:)?comment[^>]*>/);\n if (!cm) return;\n var y = parsexmltag(cm[0]);\n var comment /*:RawComment*/ = {\n author: y.authorId && authors[y.authorId] || \"sheetjsghost\",\n ref: y.ref,\n guid: y.guid\n } /*:any*/;\n var cell = decode_cell(y.ref);\n if (opts.sheetRows && opts.sheetRows <= cell.r) return;\n var textMatch = x.match(/<(?:\\w+:)?text>([\\s\\S]*)<\\/(?:\\w+:)?text>/);\n var rt = !!textMatch && !!textMatch[1] && parse_si(textMatch[1]) || {\n r: \"\",\n t: \"\",\n h: \"\"\n };\n comment.r = rt.r;\n if (rt.r == \"\") rt.t = rt.h = \"\";\n comment.t = (rt.t || \"\").replace(/\\r\\n/g, \"\\n\").replace(/\\r/g, \"\\n\");\n if (opts.cellHTML) comment.h = rt.h;\n commentList.push(comment);\n });\n return commentList;\n}\nfunction write_comments_xml(data /*::, opts*/) {\n var o = [XML_HEADER, writextag('comments', null, {\n 'xmlns': XMLNS_main[0]\n })];\n var iauthor /*:Array*/ = [];\n o.push(\"\");\n data.forEach(function (x) {\n x[1].forEach(function (w) {\n var a = escapexml(w.a);\n if (iauthor.indexOf(a) == -1) {\n iauthor.push(a);\n o.push(\"\" + a + \"\");\n }\n if (w.T && w.ID && iauthor.indexOf(\"tc=\" + w.ID) == -1) {\n iauthor.push(\"tc=\" + w.ID);\n o.push(\"\" + \"tc=\" + w.ID + \"\");\n }\n });\n });\n if (iauthor.length == 0) {\n iauthor.push(\"SheetJ5\");\n o.push(\"SheetJ5\");\n }\n o.push(\"\");\n o.push(\"\");\n data.forEach(function (d) {\n /* 18.7.3 CT_Comment */\n var lastauthor = 0,\n ts = [];\n if (d[1][0] && d[1][0].T && d[1][0].ID) lastauthor = iauthor.indexOf(\"tc=\" + d[1][0].ID);else d[1].forEach(function (c) {\n if (c.a) lastauthor = iauthor.indexOf(escapexml(c.a));\n ts.push(c.t || \"\");\n });\n o.push('');\n if (ts.length <= 1) o.push(writetag(\"t\", escapexml(ts[0] || \"\")));else {\n /* based on Threaded Comments -> Comments projection */\n var t = \"Comment:\\n \" + ts[0] + \"\\n\";\n for (var i = 1; i < ts.length; ++i) t += \"Reply:\\n \" + ts[i] + \"\\n\";\n o.push(writetag(\"t\", escapexml(t)));\n }\n o.push('');\n });\n o.push(\"\");\n if (o.length > 2) {\n o[o.length] = '';\n o[1] = o[1].replace(\"/>\", \">\");\n }\n return o.join(\"\");\n}\n\n/* [MS-XLSX] 2.1.17 */\nfunction parse_tcmnt_xml(data /*:string*/, opts) /*:Array*/{\n var out = [];\n var pass = false,\n comment = {},\n tidx = 0;\n data.replace(tagregex, function xml_tcmnt(x, idx) {\n var y /*:any*/ = parsexmltag(x);\n switch (strip_ns(y[0])) {\n case '':\n break;\n\n /* 2.6.205 threadedComment CT_ThreadedComment */\n case '':\n if (comment.t != null) out.push(comment);\n break;\n case '':\n case '':\n comment.t = data.slice(tidx, idx).replace(/\\r\\n/g, \"\\n\").replace(/\\r/g, \"\\n\");\n break;\n\n /* 2.6.206 mentions CT_ThreadedCommentMentions TODO */\n case '':\n pass = true;\n break;\n case '':\n pass = false;\n break;\n\n /* 2.6.202 mention CT_Mention TODO */\n\n /* 18.2.10 extLst CT_ExtensionList ? */\n case '':\n case '
':\n case '':\n break;\n /* 18.2.7 ext CT_Extension + */\n case '':\n pass = false;\n break;\n default:\n if (!pass && opts.WTF) throw new Error('unrecognized ' + y[0] + ' in threaded comments');\n }\n return x;\n });\n return out;\n}\nfunction write_tcmnt_xml(comments, people, opts) {\n var o = [XML_HEADER, writextag('ThreadedComments', null, {\n 'xmlns': XMLNS.TCMNT\n }).replace(/[\\/]>/, \">\")];\n comments.forEach(function (carr) {\n var rootid = \"\";\n (carr[1] || []).forEach(function (c, idx) {\n if (!c.T) {\n delete c.ID;\n return;\n }\n if (c.a && people.indexOf(c.a) == -1) people.push(c.a);\n var tcopts = {\n ref: carr[0],\n id: \"{54EE7951-7262-4200-6969-\" + (\"000000000000\" + opts.tcid++).slice(-12) + \"}\"\n };\n if (idx == 0) rootid = tcopts.id;else tcopts.parentId = rootid;\n c.ID = tcopts.id;\n if (c.a) tcopts.personId = \"{54EE7950-7262-4200-6969-\" + (\"000000000000\" + people.indexOf(c.a)).slice(-12) + \"}\";\n o.push(writextag('threadedComment', writetag('text', c.t || \"\"), tcopts));\n });\n });\n o.push('');\n return o.join(\"\");\n}\n\n/* [MS-XLSX] 2.1.18 */\nfunction parse_people_xml(data /*:string*/, opts) {\n var out = [];\n var pass = false;\n data.replace(tagregex, function xml_tcmnt(x) {\n var y /*:any*/ = parsexmltag(x);\n switch (strip_ns(y[0])) {\n case '':\n break;\n\n /* 2.6.203 person CT_Person TODO: providers */\n case '':\n break;\n\n /* 18.2.10 extLst CT_ExtensionList ? */\n case '':\n case '':\n case '':\n break;\n /* 18.2.7 ext CT_Extension + */\n case '':\n pass = false;\n break;\n default:\n if (!pass && opts.WTF) throw new Error('unrecognized ' + y[0] + ' in threaded comments');\n }\n return x;\n });\n return out;\n}\nfunction write_people_xml(people /*, opts*/) {\n var o = [XML_HEADER, writextag('personList', null, {\n 'xmlns': XMLNS.TCMNT,\n 'xmlns:x': XMLNS_main[0]\n }).replace(/[\\/]>/, \">\")];\n people.forEach(function (person, idx) {\n o.push(writextag('person', null, {\n displayName: person,\n id: \"{54EE7950-7262-4200-6969-\" + (\"000000000000\" + idx).slice(-12) + \"}\",\n userId: person,\n providerId: \"None\"\n }));\n });\n o.push(\"\");\n return o.join(\"\");\n}\n/* [MS-XLSB] 2.4.28 BrtBeginComment */\nfunction parse_BrtBeginComment(data) {\n var out = {};\n out.iauthor = data.read_shift(4);\n var rfx = parse_UncheckedRfX(data, 16);\n out.rfx = rfx.s;\n out.ref = encode_cell(rfx.s);\n data.l += 16; /*var guid = parse_GUID(data); */\n return out;\n}\nfunction write_BrtBeginComment(data, o) {\n if (o == null) o = new_buf(36);\n o.write_shift(4, data[1].iauthor);\n write_UncheckedRfX(data[0] /*:any*/, o);\n o.write_shift(4, 0);\n o.write_shift(4, 0);\n o.write_shift(4, 0);\n o.write_shift(4, 0);\n return o;\n}\n\n/* [MS-XLSB] 2.4.327 BrtCommentAuthor */\nvar parse_BrtCommentAuthor = parse_XLWideString;\nfunction write_BrtCommentAuthor(data) {\n return write_XLWideString(data.slice(0, 54));\n}\n\n/* [MS-XLSB] 2.1.7.8 Comments */\nfunction parse_comments_bin(data, opts) /*:Array*/{\n var out /*:Array*/ = [];\n var authors /*:Array*/ = [];\n var c = {};\n var pass = false;\n recordhopper(data, function hopper_cmnt(val, R, RT) {\n switch (RT) {\n case 0x0278:\n /* 'BrtCommentAuthor' */\n authors.push(val);\n break;\n case 0x027B:\n /* 'BrtBeginComment' */\n c = val;\n break;\n case 0x027D:\n /* 'BrtCommentText' */\n c.t = val.t;\n c.h = val.h;\n c.r = val.r;\n break;\n case 0x027C:\n /* 'BrtEndComment' */\n c.author = authors[c.iauthor];\n delete c /*:any*/.iauthor;\n if (opts.sheetRows && c.rfx && opts.sheetRows <= c.rfx.r) break;\n if (!c.t) c.t = \"\";\n delete c.rfx;\n out.push(c);\n break;\n case 0x0C00:\n /* 'BrtUid' */\n break;\n case 0x0023:\n /* 'BrtFRTBegin' */\n pass = true;\n break;\n case 0x0024:\n /* 'BrtFRTEnd' */\n pass = false;\n break;\n case 0x0025:\n /* 'BrtACBegin' */break;\n case 0x0026:\n /* 'BrtACEnd' */break;\n default:\n if (R.T) {/* empty */} else if (!pass || opts.WTF) throw new Error(\"Unexpected record 0x\" + RT.toString(16));\n }\n });\n return out;\n}\nfunction write_comments_bin(data /*::, opts*/) {\n var ba = buf_array();\n var iauthor /*:Array*/ = [];\n write_record(ba, 0x0274 /* BrtBeginComments */);\n write_record(ba, 0x0276 /* BrtBeginCommentAuthors */);\n data.forEach(function (comment) {\n comment[1].forEach(function (c) {\n if (iauthor.indexOf(c.a) > -1) return;\n iauthor.push(c.a.slice(0, 54));\n write_record(ba, 0x0278 /* BrtCommentAuthor */, write_BrtCommentAuthor(c.a));\n });\n });\n write_record(ba, 0x0277 /* BrtEndCommentAuthors */);\n write_record(ba, 0x0279 /* BrtBeginCommentList */);\n data.forEach(function (comment) {\n comment[1].forEach(function (c) {\n c.iauthor = iauthor.indexOf(c.a);\n var range = {\n s: decode_cell(comment[0]),\n e: decode_cell(comment[0])\n };\n write_record(ba, 0x027B /* BrtBeginComment */, write_BrtBeginComment([range, c]));\n if (c.t && c.t.length > 0) write_record(ba, 0x027D /* BrtCommentText */, write_BrtCommentText(c));\n write_record(ba, 0x027C /* BrtEndComment */);\n delete c.iauthor;\n });\n });\n write_record(ba, 0x027A /* BrtEndCommentList */);\n write_record(ba, 0x0275 /* BrtEndComments */);\n return ba.end();\n}\nvar CT_VBA = \"application/vnd.ms-office.vbaProject\";\nfunction make_vba_xls(cfb) {\n var newcfb = CFB.utils.cfb_new({\n root: \"R\"\n });\n cfb.FullPaths.forEach(function (p, i) {\n if (p.slice(-1) === \"/\" || !p.match(/_VBA_PROJECT_CUR/)) return;\n var newpath = p.replace(/^[^\\/]*/, \"R\").replace(/\\/_VBA_PROJECT_CUR\\u0000*/, \"\");\n CFB.utils.cfb_add(newcfb, newpath, cfb.FileIndex[i].content);\n });\n return CFB.write(newcfb);\n}\nfunction fill_vba_xls(cfb, vba) {\n vba.FullPaths.forEach(function (p, i) {\n if (i == 0) return;\n var newpath = p.replace(/[^\\/]*[\\/]/, \"/_VBA_PROJECT_CUR/\");\n if (newpath.slice(-1) !== \"/\") CFB.utils.cfb_add(cfb, newpath, vba.FileIndex[i].content);\n });\n}\nvar VBAFMTS = [\"xlsb\", \"xlsm\", \"xlam\", \"biff8\", \"xla\"];\n/* macro and dialog sheet stubs */\nfunction parse_ds_bin(/*::data:any, opts, idx:number, rels, wb, themes, styles*/) /*:Worksheet*/{\n return {\n '!type': 'dialog'\n };\n}\nfunction parse_ds_xml(/*::data:any, opts, idx:number, rels, wb, themes, styles*/) /*:Worksheet*/{\n return {\n '!type': 'dialog'\n };\n}\nfunction parse_ms_bin(/*::data:any, opts, idx:number, rels, wb, themes, styles*/) /*:Worksheet*/{\n return {\n '!type': 'macro'\n };\n}\nfunction parse_ms_xml(/*::data:any, opts, idx:number, rels, wb, themes, styles*/) /*:Worksheet*/{\n return {\n '!type': 'macro'\n };\n}\n/* TODO: it will be useful to parse the function str */\nvar rc_to_a1 = /*#__PURE__*/function () {\n var rcregex = /(^|[^A-Za-z_])R(\\[?-?\\d+\\]|[1-9]\\d*|)C(\\[?-?\\d+\\]|[1-9]\\d*|)(?![A-Za-z0-9_])/g;\n var rcbase /*:Cell*/ = {\n r: 0,\n c: 0\n } /*:any*/;\n function rcfunc($$, $1, $2, $3) {\n var cRel = false,\n rRel = false;\n if ($2.length == 0) rRel = true;else if ($2.charAt(0) == \"[\") {\n rRel = true;\n $2 = $2.slice(1, -1);\n }\n if ($3.length == 0) cRel = true;else if ($3.charAt(0) == \"[\") {\n cRel = true;\n $3 = $3.slice(1, -1);\n }\n var R = $2.length > 0 ? parseInt($2, 10) | 0 : 0,\n C = $3.length > 0 ? parseInt($3, 10) | 0 : 0;\n if (cRel) C += rcbase.c;else --C;\n if (rRel) R += rcbase.r;else --R;\n return $1 + (cRel ? \"\" : \"$\") + encode_col(C) + (rRel ? \"\" : \"$\") + encode_row(R);\n }\n return function rc_to_a1(fstr /*:string*/, base /*:Cell*/) /*:string*/{\n rcbase = base;\n return fstr.replace(rcregex, rcfunc);\n };\n}();\nvar crefregex = /(^|[^._A-Z0-9])([$]?)([A-Z]{1,2}|[A-W][A-Z]{2}|X[A-E][A-Z]|XF[A-D])([$]?)(10[0-3]\\d{4}|104[0-7]\\d{3}|1048[0-4]\\d{2}|10485[0-6]\\d|104857[0-6]|[1-9]\\d{0,5})(?![_.\\(A-Za-z0-9])/g;\nvar a1_to_rc = /*#__PURE__*/function () {\n return function a1_to_rc(fstr /*:string*/, base /*:CellAddress*/) {\n return fstr.replace(crefregex, function ($0, $1, $2, $3, $4, $5) {\n var c = decode_col($3) - ($2 ? 0 : base.c);\n var r = decode_row($5) - ($4 ? 0 : base.r);\n var R = r == 0 ? \"\" : !$4 ? \"[\" + r + \"]\" : r + 1;\n var C = c == 0 ? \"\" : !$2 ? \"[\" + c + \"]\" : c + 1;\n return $1 + \"R\" + R + \"C\" + C;\n });\n };\n}();\n\n/* no defined name can collide with a valid cell address A1:XFD1048576 ... except LOG10! */\nfunction shift_formula_str(f /*:string*/, delta /*:Cell*/) /*:string*/{\n return f.replace(crefregex, function ($0, $1, $2, $3, $4, $5) {\n return $1 + ($2 == \"$\" ? $2 + $3 : encode_col(decode_col($3) + delta.c)) + ($4 == \"$\" ? $4 + $5 : encode_row(decode_row($5) + delta.r));\n });\n}\nfunction shift_formula_xlsx(f /*:string*/, range /*:string*/, cell /*:string*/) /*:string*/{\n var r = decode_range(range),\n s = r.s,\n c = decode_cell(cell);\n var delta = {\n r: c.r - s.r,\n c: c.c - s.c\n };\n return shift_formula_str(f, delta);\n}\n\n/* TODO: parse formula */\nfunction fuzzyfmla(f /*:string*/) /*:boolean*/{\n if (f.length == 1) return false;\n return true;\n}\nfunction _xlfn(f /*:string*/) /*:string*/{\n return f.replace(/_xlfn\\./g, \"\");\n}\nfunction parseread1(blob) {\n blob.l += 1;\n return;\n}\n\n/* [MS-XLS] 2.5.51 */\nfunction parse_ColRelU(blob, length) {\n var c = blob.read_shift(length == 1 ? 1 : 2);\n return [c & 0x3FFF, c >> 14 & 1, c >> 15 & 1];\n}\n\n/* [MS-XLS] 2.5.198.105 ; [MS-XLSB] 2.5.97.89 */\nfunction parse_RgceArea(blob, length, opts) {\n var w = 2;\n if (opts) {\n if (opts.biff >= 2 && opts.biff <= 5) return parse_RgceArea_BIFF2(blob, length, opts);else if (opts.biff == 12) w = 4;\n }\n var r = blob.read_shift(w),\n R = blob.read_shift(w);\n var c = parse_ColRelU(blob, 2);\n var C = parse_ColRelU(blob, 2);\n return {\n s: {\n r: r,\n c: c[0],\n cRel: c[1],\n rRel: c[2]\n },\n e: {\n r: R,\n c: C[0],\n cRel: C[1],\n rRel: C[2]\n }\n };\n}\n/* BIFF 2-5 encodes flags in the row field */\nfunction parse_RgceArea_BIFF2(blob /*::, length, opts*/) {\n var r = parse_ColRelU(blob, 2),\n R = parse_ColRelU(blob, 2);\n var c = blob.read_shift(1);\n var C = blob.read_shift(1);\n return {\n s: {\n r: r[0],\n c: c,\n cRel: r[1],\n rRel: r[2]\n },\n e: {\n r: R[0],\n c: C,\n cRel: R[1],\n rRel: R[2]\n }\n };\n}\n\n/* [MS-XLS] 2.5.198.105 ; [MS-XLSB] 2.5.97.90 */\nfunction parse_RgceAreaRel(blob, length, opts) {\n if (opts.biff < 8) return parse_RgceArea_BIFF2(blob, length, opts);\n var r = blob.read_shift(opts.biff == 12 ? 4 : 2),\n R = blob.read_shift(opts.biff == 12 ? 4 : 2);\n var c = parse_ColRelU(blob, 2);\n var C = parse_ColRelU(blob, 2);\n return {\n s: {\n r: r,\n c: c[0],\n cRel: c[1],\n rRel: c[2]\n },\n e: {\n r: R,\n c: C[0],\n cRel: C[1],\n rRel: C[2]\n }\n };\n}\n\n/* [MS-XLS] 2.5.198.109 ; [MS-XLSB] 2.5.97.91 */\nfunction parse_RgceLoc(blob, length, opts) {\n if (opts && opts.biff >= 2 && opts.biff <= 5) return parse_RgceLoc_BIFF2(blob, length, opts);\n var r = blob.read_shift(opts && opts.biff == 12 ? 4 : 2);\n var c = parse_ColRelU(blob, 2);\n return {\n r: r,\n c: c[0],\n cRel: c[1],\n rRel: c[2]\n };\n}\nfunction parse_RgceLoc_BIFF2(blob /*::, length, opts*/) {\n var r = parse_ColRelU(blob, 2);\n var c = blob.read_shift(1);\n return {\n r: r[0],\n c: c,\n cRel: r[1],\n rRel: r[2]\n };\n}\n\n/* [MS-XLS] 2.5.198.107, 2.5.47 */\nfunction parse_RgceElfLoc(blob /*::, length, opts*/) {\n var r = blob.read_shift(2);\n var c = blob.read_shift(2);\n return {\n r: r,\n c: c & 0xFF,\n fQuoted: !!(c & 0x4000),\n cRel: c >> 15,\n rRel: c >> 15\n };\n}\n\n/* [MS-XLS] 2.5.198.111 ; [MS-XLSB] 2.5.97.92 TODO */\nfunction parse_RgceLocRel(blob, length, opts) {\n var biff = opts && opts.biff ? opts.biff : 8;\n if (biff >= 2 && biff <= 5) return parse_RgceLocRel_BIFF2(blob, length, opts);\n var r = blob.read_shift(biff >= 12 ? 4 : 2);\n var cl = blob.read_shift(2);\n var cRel = (cl & 0x4000) >> 14,\n rRel = (cl & 0x8000) >> 15;\n cl &= 0x3FFF;\n if (rRel == 1) while (r > 0x7FFFF) r -= 0x100000;\n if (cRel == 1) while (cl > 0x1FFF) cl = cl - 0x4000;\n return {\n r: r,\n c: cl,\n cRel: cRel,\n rRel: rRel\n };\n}\nfunction parse_RgceLocRel_BIFF2(blob /*::, length:number, opts*/) {\n var rl = blob.read_shift(2);\n var c = blob.read_shift(1);\n var rRel = (rl & 0x8000) >> 15,\n cRel = (rl & 0x4000) >> 14;\n rl &= 0x3FFF;\n if (rRel == 1 && rl >= 0x2000) rl = rl - 0x4000;\n if (cRel == 1 && c >= 0x80) c = c - 0x100;\n return {\n r: rl,\n c: c,\n cRel: cRel,\n rRel: rRel\n };\n}\n\n/* [MS-XLS] 2.5.198.27 ; [MS-XLSB] 2.5.97.18 */\nfunction parse_PtgArea(blob, length, opts) {\n var type = (blob[blob.l++] & 0x60) >> 5;\n var area = parse_RgceArea(blob, opts.biff >= 2 && opts.biff <= 5 ? 6 : 8, opts);\n return [type, area];\n}\n\n/* [MS-XLS] 2.5.198.28 ; [MS-XLSB] 2.5.97.19 */\nfunction parse_PtgArea3d(blob, length, opts) {\n var type = (blob[blob.l++] & 0x60) >> 5;\n var ixti = blob.read_shift(2, 'i');\n var w = 8;\n if (opts) switch (opts.biff) {\n case 5:\n blob.l += 12;\n w = 6;\n break;\n case 12:\n w = 12;\n break;\n }\n var area = parse_RgceArea(blob, w, opts);\n return [type, ixti, area];\n}\n\n/* [MS-XLS] 2.5.198.29 ; [MS-XLSB] 2.5.97.20 */\nfunction parse_PtgAreaErr(blob, length, opts) {\n var type = (blob[blob.l++] & 0x60) >> 5;\n blob.l += opts && opts.biff > 8 ? 12 : opts.biff < 8 ? 6 : 8;\n return [type];\n}\n/* [MS-XLS] 2.5.198.30 ; [MS-XLSB] 2.5.97.21 */\nfunction parse_PtgAreaErr3d(blob, length, opts) {\n var type = (blob[blob.l++] & 0x60) >> 5;\n var ixti = blob.read_shift(2);\n var w = 8;\n if (opts) switch (opts.biff) {\n case 5:\n blob.l += 12;\n w = 6;\n break;\n case 12:\n w = 12;\n break;\n }\n blob.l += w;\n return [type, ixti];\n}\n\n/* [MS-XLS] 2.5.198.31 ; [MS-XLSB] 2.5.97.22 */\nfunction parse_PtgAreaN(blob, length, opts) {\n var type = (blob[blob.l++] & 0x60) >> 5;\n var area = parse_RgceAreaRel(blob, length - 1, opts);\n return [type, area];\n}\n\n/* [MS-XLS] 2.5.198.32 ; [MS-XLSB] 2.5.97.23 */\nfunction parse_PtgArray(blob, length, opts) {\n var type = (blob[blob.l++] & 0x60) >> 5;\n blob.l += opts.biff == 2 ? 6 : opts.biff == 12 ? 14 : 7;\n return [type];\n}\n\n/* [MS-XLS] 2.5.198.33 ; [MS-XLSB] 2.5.97.24 */\nfunction parse_PtgAttrBaxcel(blob) {\n var bitSemi = blob[blob.l + 1] & 0x01; /* 1 = volatile */\n var bitBaxcel = 1;\n blob.l += 4;\n return [bitSemi, bitBaxcel];\n}\n\n/* [MS-XLS] 2.5.198.34 ; [MS-XLSB] 2.5.97.25 */\nfunction parse_PtgAttrChoose(blob, length, opts) /*:Array*/{\n blob.l += 2;\n var offset = blob.read_shift(opts && opts.biff == 2 ? 1 : 2);\n var o /*:Array*/ = [];\n /* offset is 1 less than the number of elements */\n for (var i = 0; i <= offset; ++i) o.push(blob.read_shift(opts && opts.biff == 2 ? 1 : 2));\n return o;\n}\n\n/* [MS-XLS] 2.5.198.35 ; [MS-XLSB] 2.5.97.26 */\nfunction parse_PtgAttrGoto(blob, length, opts) {\n var bitGoto = blob[blob.l + 1] & 0xFF ? 1 : 0;\n blob.l += 2;\n return [bitGoto, blob.read_shift(opts && opts.biff == 2 ? 1 : 2)];\n}\n\n/* [MS-XLS] 2.5.198.36 ; [MS-XLSB] 2.5.97.27 */\nfunction parse_PtgAttrIf(blob, length, opts) {\n var bitIf = blob[blob.l + 1] & 0xFF ? 1 : 0;\n blob.l += 2;\n return [bitIf, blob.read_shift(opts && opts.biff == 2 ? 1 : 2)];\n}\n\n/* [MS-XLSB] 2.5.97.28 */\nfunction parse_PtgAttrIfError(blob) {\n var bitIf = blob[blob.l + 1] & 0xFF ? 1 : 0;\n blob.l += 2;\n return [bitIf, blob.read_shift(2)];\n}\n\n/* [MS-XLS] 2.5.198.37 ; [MS-XLSB] 2.5.97.29 */\nfunction parse_PtgAttrSemi(blob, length, opts) {\n var bitSemi = blob[blob.l + 1] & 0xFF ? 1 : 0;\n blob.l += opts && opts.biff == 2 ? 3 : 4;\n return [bitSemi];\n}\n\n/* [MS-XLS] 2.5.198.40 ; [MS-XLSB] 2.5.97.32 */\nfunction parse_PtgAttrSpaceType(blob /*::, length*/) {\n var type = blob.read_shift(1),\n cch = blob.read_shift(1);\n return [type, cch];\n}\n\n/* [MS-XLS] 2.5.198.38 ; [MS-XLSB] 2.5.97.30 */\nfunction parse_PtgAttrSpace(blob) {\n blob.read_shift(2);\n return parse_PtgAttrSpaceType(blob, 2);\n}\n\n/* [MS-XLS] 2.5.198.39 ; [MS-XLSB] 2.5.97.31 */\nfunction parse_PtgAttrSpaceSemi(blob) {\n blob.read_shift(2);\n return parse_PtgAttrSpaceType(blob, 2);\n}\n\n/* [MS-XLS] 2.5.198.84 ; [MS-XLSB] 2.5.97.68 TODO */\nfunction parse_PtgRef(blob, length, opts) {\n //var ptg = blob[blob.l] & 0x1F;\n var type = (blob[blob.l] & 0x60) >> 5;\n blob.l += 1;\n var loc = parse_RgceLoc(blob, 0, opts);\n return [type, loc];\n}\n\n/* [MS-XLS] 2.5.198.88 ; [MS-XLSB] 2.5.97.72 TODO */\nfunction parse_PtgRefN(blob, length, opts) {\n var type = (blob[blob.l] & 0x60) >> 5;\n blob.l += 1;\n var loc = parse_RgceLocRel(blob, 0, opts);\n return [type, loc];\n}\n\n/* [MS-XLS] 2.5.198.85 ; [MS-XLSB] 2.5.97.69 TODO */\nfunction parse_PtgRef3d(blob, length, opts) {\n var type = (blob[blob.l] & 0x60) >> 5;\n blob.l += 1;\n var ixti = blob.read_shift(2); // XtiIndex\n if (opts && opts.biff == 5) blob.l += 12;\n var loc = parse_RgceLoc(blob, 0, opts); // TODO: or RgceLocRel\n return [type, ixti, loc];\n}\n\n/* [MS-XLS] 2.5.198.62 ; [MS-XLSB] 2.5.97.45 TODO */\nfunction parse_PtgFunc(blob, length, opts) {\n //var ptg = blob[blob.l] & 0x1F;\n var type = (blob[blob.l] & 0x60) >> 5;\n blob.l += 1;\n var iftab = blob.read_shift(opts && opts.biff <= 3 ? 1 : 2);\n return [FtabArgc[iftab], Ftab[iftab], type];\n}\n/* [MS-XLS] 2.5.198.63 ; [MS-XLSB] 2.5.97.46 TODO */\nfunction parse_PtgFuncVar(blob, length, opts) {\n var type = blob[blob.l++];\n var cparams = blob.read_shift(1),\n tab = opts && opts.biff <= 3 ? [type == 0x58 ? -1 : 0, blob.read_shift(1)] : parsetab(blob);\n return [cparams, (tab[0] === 0 ? Ftab : Cetab)[tab[1]]];\n}\nfunction parsetab(blob) {\n return [blob[blob.l + 1] >> 7, blob.read_shift(2) & 0x7FFF];\n}\n\n/* [MS-XLS] 2.5.198.41 ; [MS-XLSB] 2.5.97.33 */\nfunction parse_PtgAttrSum(blob, length, opts) {\n blob.l += opts && opts.biff == 2 ? 3 : 4;\n return;\n}\n\n/* [MS-XLS] 2.5.198.58 ; [MS-XLSB] 2.5.97.40 */\nfunction parse_PtgExp(blob, length, opts) {\n blob.l++;\n if (opts && opts.biff == 12) return [blob.read_shift(4, 'i'), 0];\n var row = blob.read_shift(2);\n var col = blob.read_shift(opts && opts.biff == 2 ? 1 : 2);\n return [row, col];\n}\n\n/* [MS-XLS] 2.5.198.57 ; [MS-XLSB] 2.5.97.39 */\nfunction parse_PtgErr(blob) {\n blob.l++;\n return BErr[blob.read_shift(1)];\n}\n\n/* [MS-XLS] 2.5.198.66 ; [MS-XLSB] 2.5.97.49 */\nfunction parse_PtgInt(blob) {\n blob.l++;\n return blob.read_shift(2);\n}\n\n/* [MS-XLS] 2.5.198.42 ; [MS-XLSB] 2.5.97.34 */\nfunction parse_PtgBool(blob) {\n blob.l++;\n return blob.read_shift(1) !== 0;\n}\n\n/* [MS-XLS] 2.5.198.79 ; [MS-XLSB] 2.5.97.63 */\nfunction parse_PtgNum(blob) {\n blob.l++;\n return parse_Xnum(blob, 8);\n}\n\n/* [MS-XLS] 2.5.198.89 ; [MS-XLSB] 2.5.97.74 */\nfunction parse_PtgStr(blob, length, opts) {\n blob.l++;\n return parse_ShortXLUnicodeString(blob, length - 1, opts);\n}\n\n/* [MS-XLS] 2.5.192.112 + 2.5.192.11{3,4,5,6,7} */\n/* [MS-XLSB] 2.5.97.93 + 2.5.97.9{4,5,6,7} */\nfunction parse_SerAr(blob, biff /*:number*/) {\n var val = [blob.read_shift(1)];\n if (biff == 12) switch (val[0]) {\n case 0x02:\n val[0] = 0x04;\n break;\n /* SerBool */\n case 0x04:\n val[0] = 0x10;\n break;\n /* SerErr */\n case 0x00:\n val[0] = 0x01;\n break;\n /* SerNum */\n case 0x01:\n val[0] = 0x02;\n break;\n /* SerStr */\n }\n switch (val[0]) {\n case 0x04:\n /* SerBool -- boolean */\n val[1] = parsebool(blob, 1) ? 'TRUE' : 'FALSE';\n if (biff != 12) blob.l += 7;\n break;\n case 0x25: /* appears to be an alias */\n case 0x10:\n /* SerErr -- error */\n val[1] = BErr[blob[blob.l]];\n blob.l += biff == 12 ? 4 : 8;\n break;\n case 0x00:\n /* SerNil -- honestly, I'm not sure how to reproduce this */\n blob.l += 8;\n break;\n case 0x01:\n /* SerNum -- Xnum */\n val[1] = parse_Xnum(blob, 8);\n break;\n case 0x02:\n /* SerStr -- XLUnicodeString (<256 chars) */\n val[1] = parse_XLUnicodeString2(blob, 0, {\n biff: biff > 0 && biff < 8 ? 2 : biff\n });\n break;\n default:\n throw new Error(\"Bad SerAr: \" + val[0]);\n /* Unreachable */\n }\n return val;\n}\n\n/* [MS-XLS] 2.5.198.61 ; [MS-XLSB] 2.5.97.44 */\nfunction parse_PtgExtraMem(blob, cce, opts) {\n var count = blob.read_shift(opts.biff == 12 ? 4 : 2);\n var out /*:Array*/ = [];\n for (var i = 0; i != count; ++i) out.push((opts.biff == 12 ? parse_UncheckedRfX : parse_Ref8U)(blob, 8));\n return out;\n}\n\n/* [MS-XLS] 2.5.198.59 ; [MS-XLSB] 2.5.97.41 */\nfunction parse_PtgExtraArray(blob, length, opts) {\n var rows = 0,\n cols = 0;\n if (opts.biff == 12) {\n rows = blob.read_shift(4); // DRw\n cols = blob.read_shift(4); // DCol\n } else {\n cols = 1 + blob.read_shift(1); //DColByteU\n rows = 1 + blob.read_shift(2); //DRw\n }\n if (opts.biff >= 2 && opts.biff < 8) {\n --rows;\n if (--cols == 0) cols = 0x100;\n }\n // $FlowIgnore\n for (var i = 0, o /*:Array>*/ = []; i != rows && (o[i] = []); ++i) for (var j = 0; j != cols; ++j) o[i][j] = parse_SerAr(blob, opts.biff);\n return o;\n}\n\n/* [MS-XLS] 2.5.198.76 ; [MS-XLSB] 2.5.97.60 */\nfunction parse_PtgName(blob, length, opts) {\n var type = blob.read_shift(1) >>> 5 & 0x03;\n var w = !opts || opts.biff >= 8 ? 4 : 2;\n var nameindex = blob.read_shift(w);\n switch (opts.biff) {\n case 2:\n blob.l += 5;\n break;\n case 3:\n case 4:\n blob.l += 8;\n break;\n case 5:\n blob.l += 12;\n break;\n }\n return [type, 0, nameindex];\n}\n\n/* [MS-XLS] 2.5.198.77 ; [MS-XLSB] 2.5.97.61 */\nfunction parse_PtgNameX(blob, length, opts) {\n if (opts.biff == 5) return parse_PtgNameX_BIFF5(blob, length, opts);\n var type = blob.read_shift(1) >>> 5 & 0x03;\n var ixti = blob.read_shift(2); // XtiIndex\n var nameindex = blob.read_shift(4);\n return [type, ixti, nameindex];\n}\nfunction parse_PtgNameX_BIFF5(blob /*::, length, opts*/) {\n var type = blob.read_shift(1) >>> 5 & 0x03;\n var ixti = blob.read_shift(2, 'i'); // XtiIndex\n blob.l += 8;\n var nameindex = blob.read_shift(2);\n blob.l += 12;\n return [type, ixti, nameindex];\n}\n\n/* [MS-XLS] 2.5.198.70 ; [MS-XLSB] 2.5.97.54 */\nfunction parse_PtgMemArea(blob, length, opts) {\n var type = blob.read_shift(1) >>> 5 & 0x03;\n blob.l += opts && opts.biff == 2 ? 3 : 4;\n var cce = blob.read_shift(opts && opts.biff == 2 ? 1 : 2);\n return [type, cce];\n}\n\n/* [MS-XLS] 2.5.198.72 ; [MS-XLSB] 2.5.97.56 */\nfunction parse_PtgMemFunc(blob, length, opts) {\n var type = blob.read_shift(1) >>> 5 & 0x03;\n var cce = blob.read_shift(opts && opts.biff == 2 ? 1 : 2);\n return [type, cce];\n}\n\n/* [MS-XLS] 2.5.198.86 ; [MS-XLSB] 2.5.97.69 */\nfunction parse_PtgRefErr(blob, length, opts) {\n var type = blob.read_shift(1) >>> 5 & 0x03;\n blob.l += 4;\n if (opts.biff < 8) blob.l--;\n if (opts.biff == 12) blob.l += 2;\n return [type];\n}\n\n/* [MS-XLS] 2.5.198.87 ; [MS-XLSB] 2.5.97.71 */\nfunction parse_PtgRefErr3d(blob, length, opts) {\n var type = (blob[blob.l++] & 0x60) >> 5;\n var ixti = blob.read_shift(2);\n var w = 4;\n if (opts) switch (opts.biff) {\n case 5:\n w = 15;\n break;\n case 12:\n w = 6;\n break;\n }\n blob.l += w;\n return [type, ixti];\n}\n\n/* [MS-XLS] 2.5.198.71 ; [MS-XLSB] 2.5.97.55 */\nvar parse_PtgMemErr = parsenoop;\n/* [MS-XLS] 2.5.198.73 ; [MS-XLSB] 2.5.97.57 */\nvar parse_PtgMemNoMem = parsenoop;\n/* [MS-XLS] 2.5.198.92 */\nvar parse_PtgTbl = parsenoop;\nfunction parse_PtgElfLoc(blob, length, opts) {\n blob.l += 2;\n return [parse_RgceElfLoc(blob, 4, opts)];\n}\nfunction parse_PtgElfNoop(blob /*::, length, opts*/) {\n blob.l += 6;\n return [];\n}\n/* [MS-XLS] 2.5.198.46 */\nvar parse_PtgElfCol = parse_PtgElfLoc;\n/* [MS-XLS] 2.5.198.47 */\nvar parse_PtgElfColS = parse_PtgElfNoop;\n/* [MS-XLS] 2.5.198.48 */\nvar parse_PtgElfColSV = parse_PtgElfNoop;\n/* [MS-XLS] 2.5.198.49 */\nvar parse_PtgElfColV = parse_PtgElfLoc;\n/* [MS-XLS] 2.5.198.50 */\nfunction parse_PtgElfLel(blob /*::, length, opts*/) {\n blob.l += 2;\n return [parseuint16(blob), blob.read_shift(2) & 0x01];\n}\n/* [MS-XLS] 2.5.198.51 */\nvar parse_PtgElfRadical = parse_PtgElfLoc;\n/* [MS-XLS] 2.5.198.52 */\nvar parse_PtgElfRadicalLel = parse_PtgElfLel;\n/* [MS-XLS] 2.5.198.53 */\nvar parse_PtgElfRadicalS = parse_PtgElfNoop;\n/* [MS-XLS] 2.5.198.54 */\nvar parse_PtgElfRw = parse_PtgElfLoc;\n/* [MS-XLS] 2.5.198.55 */\nvar parse_PtgElfRwV = parse_PtgElfLoc;\n\n/* [MS-XLSB] 2.5.97.52 TODO */\nvar PtgListRT = [\"Data\", \"All\", \"Headers\", \"??\", \"?Data2\", \"??\", \"?DataHeaders\", \"??\", \"Totals\", \"??\", \"??\", \"??\", \"?DataTotals\", \"??\", \"??\", \"??\", \"?Current\"];\nfunction parse_PtgList(blob /*::, length, opts*/) {\n blob.l += 2;\n var ixti = blob.read_shift(2);\n var flags = blob.read_shift(2);\n var idx = blob.read_shift(4);\n var c = blob.read_shift(2);\n var C = blob.read_shift(2);\n var rt = PtgListRT[flags >> 2 & 0x1F];\n return {\n ixti: ixti,\n coltype: flags & 0x3,\n rt: rt,\n idx: idx,\n c: c,\n C: C\n };\n}\n/* [MS-XLS] 2.5.198.91 ; [MS-XLSB] 2.5.97.76 */\nfunction parse_PtgSxName(blob /*::, length, opts*/) {\n blob.l += 2;\n return [blob.read_shift(4)];\n}\n\n/* [XLS] old spec */\nfunction parse_PtgSheet(blob, length, opts) {\n blob.l += 5;\n blob.l += 2;\n blob.l += opts.biff == 2 ? 1 : 4;\n return [\"PTGSHEET\"];\n}\nfunction parse_PtgEndSheet(blob, length, opts) {\n blob.l += opts.biff == 2 ? 4 : 5;\n return [\"PTGENDSHEET\"];\n}\nfunction parse_PtgMemAreaN(blob /*::, length, opts*/) {\n var type = blob.read_shift(1) >>> 5 & 0x03;\n var cce = blob.read_shift(2);\n return [type, cce];\n}\nfunction parse_PtgMemNoMemN(blob /*::, length, opts*/) {\n var type = blob.read_shift(1) >>> 5 & 0x03;\n var cce = blob.read_shift(2);\n return [type, cce];\n}\nfunction parse_PtgAttrNoop(blob /*::, length, opts*/) {\n blob.l += 4;\n return [0, 0];\n}\n\n/* [MS-XLS] 2.5.198.25 ; [MS-XLSB] 2.5.97.16 */\nvar PtgTypes = {\n /*::[*/0x01 /*::]*/: {\n n: 'PtgExp',\n f: parse_PtgExp\n },\n /*::[*/0x02 /*::]*/: {\n n: 'PtgTbl',\n f: parse_PtgTbl\n },\n /*::[*/0x03 /*::]*/: {\n n: 'PtgAdd',\n f: parseread1\n },\n /*::[*/0x04 /*::]*/: {\n n: 'PtgSub',\n f: parseread1\n },\n /*::[*/0x05 /*::]*/: {\n n: 'PtgMul',\n f: parseread1\n },\n /*::[*/0x06 /*::]*/: {\n n: 'PtgDiv',\n f: parseread1\n },\n /*::[*/0x07 /*::]*/: {\n n: 'PtgPower',\n f: parseread1\n },\n /*::[*/0x08 /*::]*/: {\n n: 'PtgConcat',\n f: parseread1\n },\n /*::[*/0x09 /*::]*/: {\n n: 'PtgLt',\n f: parseread1\n },\n /*::[*/0x0A /*::]*/: {\n n: 'PtgLe',\n f: parseread1\n },\n /*::[*/0x0B /*::]*/: {\n n: 'PtgEq',\n f: parseread1\n },\n /*::[*/0x0C /*::]*/: {\n n: 'PtgGe',\n f: parseread1\n },\n /*::[*/0x0D /*::]*/: {\n n: 'PtgGt',\n f: parseread1\n },\n /*::[*/0x0E /*::]*/: {\n n: 'PtgNe',\n f: parseread1\n },\n /*::[*/0x0F /*::]*/: {\n n: 'PtgIsect',\n f: parseread1\n },\n /*::[*/0x10 /*::]*/: {\n n: 'PtgUnion',\n f: parseread1\n },\n /*::[*/0x11 /*::]*/: {\n n: 'PtgRange',\n f: parseread1\n },\n /*::[*/0x12 /*::]*/: {\n n: 'PtgUplus',\n f: parseread1\n },\n /*::[*/0x13 /*::]*/: {\n n: 'PtgUminus',\n f: parseread1\n },\n /*::[*/0x14 /*::]*/: {\n n: 'PtgPercent',\n f: parseread1\n },\n /*::[*/0x15 /*::]*/: {\n n: 'PtgParen',\n f: parseread1\n },\n /*::[*/0x16 /*::]*/: {\n n: 'PtgMissArg',\n f: parseread1\n },\n /*::[*/0x17 /*::]*/: {\n n: 'PtgStr',\n f: parse_PtgStr\n },\n /*::[*/0x1A /*::]*/: {\n n: 'PtgSheet',\n f: parse_PtgSheet\n },\n /*::[*/0x1B /*::]*/: {\n n: 'PtgEndSheet',\n f: parse_PtgEndSheet\n },\n /*::[*/0x1C /*::]*/: {\n n: 'PtgErr',\n f: parse_PtgErr\n },\n /*::[*/0x1D /*::]*/: {\n n: 'PtgBool',\n f: parse_PtgBool\n },\n /*::[*/0x1E /*::]*/: {\n n: 'PtgInt',\n f: parse_PtgInt\n },\n /*::[*/0x1F /*::]*/: {\n n: 'PtgNum',\n f: parse_PtgNum\n },\n /*::[*/0x20 /*::]*/: {\n n: 'PtgArray',\n f: parse_PtgArray\n },\n /*::[*/0x21 /*::]*/: {\n n: 'PtgFunc',\n f: parse_PtgFunc\n },\n /*::[*/0x22 /*::]*/: {\n n: 'PtgFuncVar',\n f: parse_PtgFuncVar\n },\n /*::[*/0x23 /*::]*/: {\n n: 'PtgName',\n f: parse_PtgName\n },\n /*::[*/0x24 /*::]*/: {\n n: 'PtgRef',\n f: parse_PtgRef\n },\n /*::[*/0x25 /*::]*/: {\n n: 'PtgArea',\n f: parse_PtgArea\n },\n /*::[*/0x26 /*::]*/: {\n n: 'PtgMemArea',\n f: parse_PtgMemArea\n },\n /*::[*/0x27 /*::]*/: {\n n: 'PtgMemErr',\n f: parse_PtgMemErr\n },\n /*::[*/0x28 /*::]*/: {\n n: 'PtgMemNoMem',\n f: parse_PtgMemNoMem\n },\n /*::[*/0x29 /*::]*/: {\n n: 'PtgMemFunc',\n f: parse_PtgMemFunc\n },\n /*::[*/0x2A /*::]*/: {\n n: 'PtgRefErr',\n f: parse_PtgRefErr\n },\n /*::[*/0x2B /*::]*/: {\n n: 'PtgAreaErr',\n f: parse_PtgAreaErr\n },\n /*::[*/0x2C /*::]*/: {\n n: 'PtgRefN',\n f: parse_PtgRefN\n },\n /*::[*/0x2D /*::]*/: {\n n: 'PtgAreaN',\n f: parse_PtgAreaN\n },\n /*::[*/0x2E /*::]*/: {\n n: 'PtgMemAreaN',\n f: parse_PtgMemAreaN\n },\n /*::[*/0x2F /*::]*/: {\n n: 'PtgMemNoMemN',\n f: parse_PtgMemNoMemN\n },\n /*::[*/0x39 /*::]*/: {\n n: 'PtgNameX',\n f: parse_PtgNameX\n },\n /*::[*/0x3A /*::]*/: {\n n: 'PtgRef3d',\n f: parse_PtgRef3d\n },\n /*::[*/0x3B /*::]*/: {\n n: 'PtgArea3d',\n f: parse_PtgArea3d\n },\n /*::[*/0x3C /*::]*/: {\n n: 'PtgRefErr3d',\n f: parse_PtgRefErr3d\n },\n /*::[*/0x3D /*::]*/: {\n n: 'PtgAreaErr3d',\n f: parse_PtgAreaErr3d\n },\n /*::[*/0xFF /*::]*/: {}\n};\n/* These are duplicated in the PtgTypes table */\nvar PtgDupes = {\n /*::[*/0x40 /*::]*/: 0x20,\n /*::[*/0x60 /*::]*/: 0x20,\n /*::[*/0x41 /*::]*/: 0x21,\n /*::[*/0x61 /*::]*/: 0x21,\n /*::[*/0x42 /*::]*/: 0x22,\n /*::[*/0x62 /*::]*/: 0x22,\n /*::[*/0x43 /*::]*/: 0x23,\n /*::[*/0x63 /*::]*/: 0x23,\n /*::[*/0x44 /*::]*/: 0x24,\n /*::[*/0x64 /*::]*/: 0x24,\n /*::[*/0x45 /*::]*/: 0x25,\n /*::[*/0x65 /*::]*/: 0x25,\n /*::[*/0x46 /*::]*/: 0x26,\n /*::[*/0x66 /*::]*/: 0x26,\n /*::[*/0x47 /*::]*/: 0x27,\n /*::[*/0x67 /*::]*/: 0x27,\n /*::[*/0x48 /*::]*/: 0x28,\n /*::[*/0x68 /*::]*/: 0x28,\n /*::[*/0x49 /*::]*/: 0x29,\n /*::[*/0x69 /*::]*/: 0x29,\n /*::[*/0x4A /*::]*/: 0x2A,\n /*::[*/0x6A /*::]*/: 0x2A,\n /*::[*/0x4B /*::]*/: 0x2B,\n /*::[*/0x6B /*::]*/: 0x2B,\n /*::[*/0x4C /*::]*/: 0x2C,\n /*::[*/0x6C /*::]*/: 0x2C,\n /*::[*/0x4D /*::]*/: 0x2D,\n /*::[*/0x6D /*::]*/: 0x2D,\n /*::[*/0x4E /*::]*/: 0x2E,\n /*::[*/0x6E /*::]*/: 0x2E,\n /*::[*/0x4F /*::]*/: 0x2F,\n /*::[*/0x6F /*::]*/: 0x2F,\n /*::[*/0x58 /*::]*/: 0x22,\n /*::[*/0x78 /*::]*/: 0x22,\n /*::[*/0x59 /*::]*/: 0x39,\n /*::[*/0x79 /*::]*/: 0x39,\n /*::[*/0x5A /*::]*/: 0x3A,\n /*::[*/0x7A /*::]*/: 0x3A,\n /*::[*/0x5B /*::]*/: 0x3B,\n /*::[*/0x7B /*::]*/: 0x3B,\n /*::[*/0x5C /*::]*/: 0x3C,\n /*::[*/0x7C /*::]*/: 0x3C,\n /*::[*/0x5D /*::]*/: 0x3D,\n /*::[*/0x7D /*::]*/: 0x3D\n};\nvar Ptg18 = {\n /*::[*/0x01 /*::]*/: {\n n: 'PtgElfLel',\n f: parse_PtgElfLel\n },\n /*::[*/0x02 /*::]*/: {\n n: 'PtgElfRw',\n f: parse_PtgElfRw\n },\n /*::[*/0x03 /*::]*/: {\n n: 'PtgElfCol',\n f: parse_PtgElfCol\n },\n /*::[*/0x06 /*::]*/: {\n n: 'PtgElfRwV',\n f: parse_PtgElfRwV\n },\n /*::[*/0x07 /*::]*/: {\n n: 'PtgElfColV',\n f: parse_PtgElfColV\n },\n /*::[*/0x0A /*::]*/: {\n n: 'PtgElfRadical',\n f: parse_PtgElfRadical\n },\n /*::[*/0x0B /*::]*/: {\n n: 'PtgElfRadicalS',\n f: parse_PtgElfRadicalS\n },\n /*::[*/0x0D /*::]*/: {\n n: 'PtgElfColS',\n f: parse_PtgElfColS\n },\n /*::[*/0x0F /*::]*/: {\n n: 'PtgElfColSV',\n f: parse_PtgElfColSV\n },\n /*::[*/0x10 /*::]*/: {\n n: 'PtgElfRadicalLel',\n f: parse_PtgElfRadicalLel\n },\n /*::[*/0x19 /*::]*/: {\n n: 'PtgList',\n f: parse_PtgList\n },\n /*::[*/0x1D /*::]*/: {\n n: 'PtgSxName',\n f: parse_PtgSxName\n },\n /*::[*/0xFF /*::]*/: {}\n};\nvar Ptg19 = {\n /*::[*/0x00 /*::]*/: {\n n: 'PtgAttrNoop',\n f: parse_PtgAttrNoop\n },\n /*::[*/0x01 /*::]*/: {\n n: 'PtgAttrSemi',\n f: parse_PtgAttrSemi\n },\n /*::[*/0x02 /*::]*/: {\n n: 'PtgAttrIf',\n f: parse_PtgAttrIf\n },\n /*::[*/0x04 /*::]*/: {\n n: 'PtgAttrChoose',\n f: parse_PtgAttrChoose\n },\n /*::[*/0x08 /*::]*/: {\n n: 'PtgAttrGoto',\n f: parse_PtgAttrGoto\n },\n /*::[*/0x10 /*::]*/: {\n n: 'PtgAttrSum',\n f: parse_PtgAttrSum\n },\n /*::[*/0x20 /*::]*/: {\n n: 'PtgAttrBaxcel',\n f: parse_PtgAttrBaxcel\n },\n /*::[*/0x21 /*::]*/: {\n n: 'PtgAttrBaxcel',\n f: parse_PtgAttrBaxcel\n },\n /*::[*/0x40 /*::]*/: {\n n: 'PtgAttrSpace',\n f: parse_PtgAttrSpace\n },\n /*::[*/0x41 /*::]*/: {\n n: 'PtgAttrSpaceSemi',\n f: parse_PtgAttrSpaceSemi\n },\n /*::[*/0x80 /*::]*/: {\n n: 'PtgAttrIfError',\n f: parse_PtgAttrIfError\n },\n /*::[*/0xFF /*::]*/: {}\n};\n\n/* [MS-XLS] 2.5.198.103 ; [MS-XLSB] 2.5.97.87 */\nfunction parse_RgbExtra(blob, length, rgce, opts) {\n if (opts.biff < 8) return parsenoop(blob, length);\n var target = blob.l + length;\n var o = [];\n for (var i = 0; i !== rgce.length; ++i) {\n switch (rgce[i][0]) {\n case 'PtgArray':\n /* PtgArray -> PtgExtraArray */\n rgce[i][1] = parse_PtgExtraArray(blob, 0, opts);\n o.push(rgce[i][1]);\n break;\n case 'PtgMemArea':\n /* PtgMemArea -> PtgExtraMem */\n rgce[i][2] = parse_PtgExtraMem(blob, rgce[i][1], opts);\n o.push(rgce[i][2]);\n break;\n case 'PtgExp':\n /* PtgExp -> PtgExtraCol */\n if (opts && opts.biff == 12) {\n rgce[i][1][1] = blob.read_shift(4);\n o.push(rgce[i][1]);\n }\n break;\n case 'PtgList': /* TODO: PtgList -> PtgExtraList */\n case 'PtgElfRadicalS': /* TODO: PtgElfRadicalS -> PtgExtraElf */\n case 'PtgElfColS': /* TODO: PtgElfColS -> PtgExtraElf */\n case 'PtgElfColSV':\n /* TODO: PtgElfColSV -> PtgExtraElf */\n throw \"Unsupported \" + rgce[i][0];\n default:\n break;\n }\n }\n length = target - blob.l;\n /* note: this is technically an error but Excel disregards */\n //if(target !== blob.l && blob.l !== target - length) throw new Error(target + \" != \" + blob.l);\n if (length !== 0) o.push(parsenoop(blob, length));\n return o;\n}\n\n/* [MS-XLS] 2.5.198.104 ; [MS-XLSB] 2.5.97.88 */\nfunction parse_Rgce(blob, length, opts) {\n var target = blob.l + length;\n var R,\n id,\n ptgs = [];\n while (target != blob.l) {\n length = target - blob.l;\n id = blob[blob.l];\n R = PtgTypes[id] || PtgTypes[PtgDupes[id]];\n if (id === 0x18 || id === 0x19) R = (id === 0x18 ? Ptg18 : Ptg19)[blob[blob.l + 1]];\n if (!R || !R.f) {\n /*ptgs.push*/parsenoop(blob, length);\n } else {\n ptgs.push([R.n, R.f(blob, length, opts)]);\n }\n }\n return ptgs;\n}\nfunction stringify_array(f /*:Array>*/) /*:string*/{\n var o /*:Array*/ = [];\n for (var i = 0; i < f.length; ++i) {\n var x = f[i],\n r /*:Array*/ = [];\n for (var j = 0; j < x.length; ++j) {\n var y = x[j];\n if (y) switch (y[0]) {\n // TODO: handle embedded quotes\n case 0x02:\n /*:: if(typeof y[1] != 'string') throw \"unreachable\"; */\n r.push('\"' + y[1].replace(/\"/g, '\"\"') + '\"');\n break;\n default:\n r.push(y[1]);\n } else r.push(\"\");\n }\n o.push(r.join(\",\"));\n }\n return o.join(\";\");\n}\n\n/* [MS-XLS] 2.2.2 ; [MS-XLSB] 2.2.2 TODO */\nvar PtgBinOp = {\n PtgAdd: \"+\",\n PtgConcat: \"&\",\n PtgDiv: \"/\",\n PtgEq: \"=\",\n PtgGe: \">=\",\n PtgGt: \">\",\n PtgLe: \"<=\",\n PtgLt: \"<\",\n PtgMul: \"*\",\n PtgNe: \"<>\",\n PtgPower: \"^\",\n PtgSub: \"-\"\n};\n\n// List of invalid characters needs to be tested further\nfunction formula_quote_sheet_name(sname /*:string*/, opts) /*:string*/{\n if (!sname && !(opts && opts.biff <= 5 && opts.biff >= 2)) throw new Error(\"empty sheet name\");\n if (/[^\\w\\u4E00-\\u9FFF\\u3040-\\u30FF]/.test(sname)) return \"'\" + sname + \"'\";\n return sname;\n}\nfunction get_ixti_raw(supbooks, ixti /*:number*/, opts) /*:string*/{\n if (!supbooks) return \"SH33TJSERR0\";\n if (opts.biff > 8 && (!supbooks.XTI || !supbooks.XTI[ixti])) return supbooks.SheetNames[ixti];\n if (!supbooks.XTI) return \"SH33TJSERR6\";\n var XTI = supbooks.XTI[ixti];\n if (opts.biff < 8) {\n if (ixti > 10000) ixti -= 65536;\n if (ixti < 0) ixti = -ixti;\n return ixti == 0 ? \"\" : supbooks.XTI[ixti - 1];\n }\n if (!XTI) return \"SH33TJSERR1\";\n var o = \"\";\n if (opts.biff > 8) switch (supbooks[XTI[0]][0]) {\n case 0x0165:\n /* 'BrtSupSelf' */\n o = XTI[1] == -1 ? \"#REF\" : supbooks.SheetNames[XTI[1]];\n return XTI[1] == XTI[2] ? o : o + \":\" + supbooks.SheetNames[XTI[2]];\n case 0x0166:\n /* 'BrtSupSame' */\n if (opts.SID != null) return supbooks.SheetNames[opts.SID];\n return \"SH33TJSSAME\" + supbooks[XTI[0]][0];\n case 0x0163: /* 'BrtSupBookSrc' */\n /* falls through */\n default:\n return \"SH33TJSSRC\" + supbooks[XTI[0]][0];\n }\n switch (supbooks[XTI[0]][0][0]) {\n case 0x0401:\n o = XTI[1] == -1 ? \"#REF\" : supbooks.SheetNames[XTI[1]] || \"SH33TJSERR3\";\n return XTI[1] == XTI[2] ? o : o + \":\" + supbooks.SheetNames[XTI[2]];\n case 0x3A01:\n return supbooks[XTI[0]].slice(1).map(function (name) {\n return name.Name;\n }).join(\";;\");\n //return \"SH33TJSERR8\";\n default:\n if (!supbooks[XTI[0]][0][3]) return \"SH33TJSERR2\";\n o = XTI[1] == -1 ? \"#REF\" : supbooks[XTI[0]][0][3][XTI[1]] || \"SH33TJSERR4\";\n return XTI[1] == XTI[2] ? o : o + \":\" + supbooks[XTI[0]][0][3][XTI[2]];\n }\n}\nfunction get_ixti(supbooks, ixti /*:number*/, opts) /*:string*/{\n var ixtiraw = get_ixti_raw(supbooks, ixti, opts);\n return ixtiraw == \"#REF\" ? ixtiraw : formula_quote_sheet_name(ixtiraw, opts);\n}\nfunction stringify_formula(formula /*Array*/, range, cell /*:any*/, supbooks, opts) /*:string*/{\n var biff = opts && opts.biff || 8;\n var _range = /*range != null ? range :*/{\n s: {\n c: 0,\n r: 0\n },\n e: {\n c: 0,\n r: 0\n }\n };\n var stack /*:Array*/ = [],\n e1,\n e2,\n /*::type,*/c /*:CellAddress*/,\n ixti = 0,\n nameidx = 0,\n r,\n sname = \"\";\n if (!formula[0] || !formula[0][0]) return \"\";\n var last_sp = -1,\n sp = \"\";\n for (var ff = 0, fflen = formula[0].length; ff < fflen; ++ff) {\n var f = formula[0][ff];\n switch (f[0]) {\n case 'PtgUminus':\n /* [MS-XLS] 2.5.198.93 */\n stack.push(\"-\" + stack.pop());\n break;\n case 'PtgUplus':\n /* [MS-XLS] 2.5.198.95 */\n stack.push(\"+\" + stack.pop());\n break;\n case 'PtgPercent':\n /* [MS-XLS] 2.5.198.81 */\n stack.push(stack.pop() + \"%\");\n break;\n case 'PtgAdd': /* [MS-XLS] 2.5.198.26 */\n case 'PtgConcat': /* [MS-XLS] 2.5.198.43 */\n case 'PtgDiv': /* [MS-XLS] 2.5.198.45 */\n case 'PtgEq': /* [MS-XLS] 2.5.198.56 */\n case 'PtgGe': /* [MS-XLS] 2.5.198.64 */\n case 'PtgGt': /* [MS-XLS] 2.5.198.65 */\n case 'PtgLe': /* [MS-XLS] 2.5.198.68 */\n case 'PtgLt': /* [MS-XLS] 2.5.198.69 */\n case 'PtgMul': /* [MS-XLS] 2.5.198.75 */\n case 'PtgNe': /* [MS-XLS] 2.5.198.78 */\n case 'PtgPower': /* [MS-XLS] 2.5.198.82 */\n case 'PtgSub':\n /* [MS-XLS] 2.5.198.90 */\n e1 = stack.pop();\n e2 = stack.pop();\n if (last_sp >= 0) {\n switch (formula[0][last_sp][1][0]) {\n case 0:\n // $FlowIgnore\n sp = fill(\" \", formula[0][last_sp][1][1]);\n break;\n case 1:\n // $FlowIgnore\n sp = fill(\"\\r\", formula[0][last_sp][1][1]);\n break;\n default:\n sp = \"\";\n // $FlowIgnore\n if (opts.WTF) throw new Error(\"Unexpected PtgAttrSpaceType \" + formula[0][last_sp][1][0]);\n }\n e2 = e2 + sp;\n last_sp = -1;\n }\n stack.push(e2 + PtgBinOp[f[0]] + e1);\n break;\n case 'PtgIsect':\n /* [MS-XLS] 2.5.198.67 */\n e1 = stack.pop();\n e2 = stack.pop();\n stack.push(e2 + \" \" + e1);\n break;\n case 'PtgUnion':\n /* [MS-XLS] 2.5.198.94 */\n e1 = stack.pop();\n e2 = stack.pop();\n stack.push(e2 + \",\" + e1);\n break;\n case 'PtgRange':\n /* [MS-XLS] 2.5.198.83 */\n e1 = stack.pop();\n e2 = stack.pop();\n stack.push(e2 + \":\" + e1);\n break;\n case 'PtgAttrChoose':\n /* [MS-XLS] 2.5.198.34 */\n break;\n case 'PtgAttrGoto':\n /* [MS-XLS] 2.5.198.35 */\n break;\n case 'PtgAttrIf':\n /* [MS-XLS] 2.5.198.36 */\n break;\n case 'PtgAttrIfError':\n /* [MS-XLSB] 2.5.97.28 */\n break;\n case 'PtgRef':\n /* [MS-XLS] 2.5.198.84 */\n /*::type = f[1][0]; */c = shift_cell_xls(f[1][1] /*:any*/, _range, opts);\n stack.push(encode_cell_xls(c, biff));\n break;\n case 'PtgRefN':\n /* [MS-XLS] 2.5.198.88 */\n /*::type = f[1][0]; */c = cell ? shift_cell_xls(f[1][1] /*:any*/, cell, opts) : f[1][1] /*:any*/;\n stack.push(encode_cell_xls(c, biff));\n break;\n case 'PtgRef3d':\n /* [MS-XLS] 2.5.198.85 */\n /*::type = f[1][0]; */ixti = /*::Number(*/f[1][1] /*::)*/;\n c = shift_cell_xls(f[1][2] /*:any*/, _range, opts);\n sname = get_ixti(supbooks, ixti, opts);\n var w = sname; /* IE9 fails on defined names */ // eslint-disable-line no-unused-vars\n stack.push(sname + \"!\" + encode_cell_xls(c, biff));\n break;\n case 'PtgFunc': /* [MS-XLS] 2.5.198.62 */\n case 'PtgFuncVar':\n /* [MS-XLS] 2.5.198.63 */\n /* f[1] = [argc, func, type] */\n var argc /*:number*/ = f[1][0] /*:any*/,\n func /*:string*/ = f[1][1] /*:any*/;\n if (!argc) argc = 0;\n argc &= 0x7F;\n var args = argc == 0 ? [] : stack.slice(-argc);\n stack.length -= argc;\n if (func === 'User') func = args.shift();\n stack.push(func + \"(\" + args.join(\",\") + \")\");\n break;\n case 'PtgBool':\n /* [MS-XLS] 2.5.198.42 */\n stack.push(f[1] ? \"TRUE\" : \"FALSE\");\n break;\n case 'PtgInt':\n /* [MS-XLS] 2.5.198.66 */\n stack.push(/*::String(*/f[1] /*::)*/);\n break;\n case 'PtgNum':\n /* [MS-XLS] 2.5.198.79 TODO: precision? */\n stack.push(String(f[1]));\n break;\n case 'PtgStr':\n /* [MS-XLS] 2.5.198.89 */\n // $FlowIgnore\n stack.push('\"' + f[1].replace(/\"/g, '\"\"') + '\"');\n break;\n case 'PtgErr':\n /* [MS-XLS] 2.5.198.57 */\n stack.push(/*::String(*/f[1] /*::)*/);\n break;\n case 'PtgAreaN':\n /* [MS-XLS] 2.5.198.31 TODO */\n /*::type = f[1][0]; */r = shift_range_xls(f[1][1], cell ? {\n s: cell\n } : _range, opts);\n stack.push(encode_range_xls(r /*:any*/, opts));\n break;\n case 'PtgArea':\n /* [MS-XLS] 2.5.198.27 TODO: fixed points */\n /*::type = f[1][0]; */r = shift_range_xls(f[1][1], _range, opts);\n stack.push(encode_range_xls(r /*:any*/, opts));\n break;\n case 'PtgArea3d':\n /* [MS-XLS] 2.5.198.28 TODO */\n /*::type = f[1][0]; */ixti = /*::Number(*/f[1][1] /*::)*/;\n r = f[1][2];\n sname = get_ixti(supbooks, ixti, opts);\n stack.push(sname + \"!\" + encode_range_xls(r /*:any*/, opts));\n break;\n case 'PtgAttrSum':\n /* [MS-XLS] 2.5.198.41 */\n stack.push(\"SUM(\" + stack.pop() + \")\");\n break;\n case 'PtgAttrBaxcel': /* [MS-XLS] 2.5.198.33 */\n case 'PtgAttrSemi':\n /* [MS-XLS] 2.5.198.37 */\n break;\n case 'PtgName':\n /* [MS-XLS] 2.5.198.76 ; [MS-XLSB] 2.5.97.60 TODO: revisions */\n /* f[1] = type, 0, nameindex */\n nameidx = f[1][2] /*:any*/;\n var lbl = (supbooks.names || [])[nameidx - 1] || (supbooks[0] || [])[nameidx];\n var name = lbl ? lbl.Name : \"SH33TJSNAME\" + String(nameidx);\n /* [MS-XLSB] 2.5.97.10 Ftab -- last verified 20220204 */\n if (name && name.slice(0, 6) == \"_xlfn.\" && !opts.xlfn) name = name.slice(6);\n stack.push(name);\n break;\n case 'PtgNameX':\n /* [MS-XLS] 2.5.198.77 ; [MS-XLSB] 2.5.97.61 TODO: revisions */\n /* f[1] = type, ixti, nameindex */\n var bookidx /*:number*/ = f[1][1] /*:any*/;\n nameidx = f[1][2] /*:any*/;\n var externbook;\n /* TODO: Properly handle missing values -- this should be using get_ixti_raw primarily */\n if (opts.biff <= 5) {\n if (bookidx < 0) bookidx = -bookidx;\n if (supbooks[bookidx]) externbook = supbooks[bookidx][nameidx];\n } else {\n var o = \"\";\n if (((supbooks[bookidx] || [])[0] || [])[0] == 0x3A01) {/* empty */} else if (((supbooks[bookidx] || [])[0] || [])[0] == 0x0401) {\n if (supbooks[bookidx][nameidx] && supbooks[bookidx][nameidx].itab > 0) {\n o = supbooks.SheetNames[supbooks[bookidx][nameidx].itab - 1] + \"!\";\n }\n } else o = supbooks.SheetNames[nameidx - 1] + \"!\";\n if (supbooks[bookidx] && supbooks[bookidx][nameidx]) o += supbooks[bookidx][nameidx].Name;else if (supbooks[0] && supbooks[0][nameidx]) o += supbooks[0][nameidx].Name;else {\n var ixtidata = (get_ixti_raw(supbooks, bookidx, opts) || \"\").split(\";;\");\n if (ixtidata[nameidx - 1]) o = ixtidata[nameidx - 1]; // TODO: confirm this is correct\n else o += \"SH33TJSERRX\";\n }\n stack.push(o);\n break;\n }\n if (!externbook) externbook = {\n Name: \"SH33TJSERRY\"\n };\n stack.push(externbook.Name);\n break;\n case 'PtgParen':\n /* [MS-XLS] 2.5.198.80 */\n var lp = '(',\n rp = ')';\n if (last_sp >= 0) {\n sp = \"\";\n switch (formula[0][last_sp][1][0]) {\n // $FlowIgnore\n case 2:\n lp = fill(\" \", formula[0][last_sp][1][1]) + lp;\n break;\n // $FlowIgnore\n case 3:\n lp = fill(\"\\r\", formula[0][last_sp][1][1]) + lp;\n break;\n // $FlowIgnore\n case 4:\n rp = fill(\" \", formula[0][last_sp][1][1]) + rp;\n break;\n // $FlowIgnore\n case 5:\n rp = fill(\"\\r\", formula[0][last_sp][1][1]) + rp;\n break;\n default:\n // $FlowIgnore\n if (opts.WTF) throw new Error(\"Unexpected PtgAttrSpaceType \" + formula[0][last_sp][1][0]);\n }\n last_sp = -1;\n }\n stack.push(lp + stack.pop() + rp);\n break;\n case 'PtgRefErr':\n /* [MS-XLS] 2.5.198.86 */\n stack.push('#REF!');\n break;\n case 'PtgRefErr3d':\n /* [MS-XLS] 2.5.198.87 */\n stack.push('#REF!');\n break;\n case 'PtgExp':\n /* [MS-XLS] 2.5.198.58 TODO */\n c = {\n c: f[1][1] /*:any*/,\n r: f[1][0] /*:any*/\n };\n var q = {\n c: cell.c,\n r: cell.r\n } /*:any*/;\n if (supbooks.sharedf[encode_cell(c)]) {\n var parsedf = supbooks.sharedf[encode_cell(c)];\n stack.push(stringify_formula(parsedf, _range, q, supbooks, opts));\n } else {\n var fnd = false;\n for (e1 = 0; e1 != supbooks.arrayf.length; ++e1) {\n /* TODO: should be something like range_has */\n e2 = supbooks.arrayf[e1];\n if (c.c < e2[0].s.c || c.c > e2[0].e.c) continue;\n if (c.r < e2[0].s.r || c.r > e2[0].e.r) continue;\n stack.push(stringify_formula(e2[1], _range, q, supbooks, opts));\n fnd = true;\n break;\n }\n if (!fnd) stack.push(/*::String(*/f[1] /*::)*/);\n }\n break;\n case 'PtgArray':\n /* [MS-XLS] 2.5.198.32 TODO */\n stack.push(\"{\" + stringify_array(/*::(*/f[1] /*:: :any)*/) + \"}\");\n break;\n case 'PtgMemArea':\n /* [MS-XLS] 2.5.198.70 TODO: confirm this is a non-display */\n //stack.push(\"(\" + f[2].map(encode_range).join(\",\") + \")\");\n break;\n case 'PtgAttrSpace': /* [MS-XLS] 2.5.198.38 */\n case 'PtgAttrSpaceSemi':\n /* [MS-XLS] 2.5.198.39 */\n last_sp = ff;\n break;\n case 'PtgTbl':\n /* [MS-XLS] 2.5.198.92 TODO */\n break;\n case 'PtgMemErr':\n /* [MS-XLS] 2.5.198.71 */\n break;\n case 'PtgMissArg':\n /* [MS-XLS] 2.5.198.74 */\n stack.push(\"\");\n break;\n case 'PtgAreaErr':\n /* [MS-XLS] 2.5.198.29 */\n stack.push(\"#REF!\");\n break;\n case 'PtgAreaErr3d':\n /* [MS-XLS] 2.5.198.30 */\n stack.push(\"#REF!\");\n break;\n case 'PtgList':\n /* [MS-XLSB] 2.5.97.52 */\n // $FlowIgnore\n stack.push(\"Table\" + f[1].idx + \"[#\" + f[1].rt + \"]\");\n break;\n case 'PtgMemAreaN':\n case 'PtgMemNoMemN':\n case 'PtgAttrNoop':\n case 'PtgSheet':\n case 'PtgEndSheet':\n break;\n case 'PtgMemFunc':\n /* [MS-XLS] 2.5.198.72 TODO */\n break;\n case 'PtgMemNoMem':\n /* [MS-XLS] 2.5.198.73 TODO */\n break;\n case 'PtgElfCol': /* [MS-XLS] 2.5.198.46 */\n case 'PtgElfColS': /* [MS-XLS] 2.5.198.47 */\n case 'PtgElfColSV': /* [MS-XLS] 2.5.198.48 */\n case 'PtgElfColV': /* [MS-XLS] 2.5.198.49 */\n case 'PtgElfLel': /* [MS-XLS] 2.5.198.50 */\n case 'PtgElfRadical': /* [MS-XLS] 2.5.198.51 */\n case 'PtgElfRadicalLel': /* [MS-XLS] 2.5.198.52 */\n case 'PtgElfRadicalS': /* [MS-XLS] 2.5.198.53 */\n case 'PtgElfRw': /* [MS-XLS] 2.5.198.54 */\n case 'PtgElfRwV':\n /* [MS-XLS] 2.5.198.55 */\n throw new Error(\"Unsupported ELFs\");\n case 'PtgSxName':\n /* [MS-XLS] 2.5.198.91 TODO -- find a test case */\n throw new Error('Unrecognized Formula Token: ' + String(f));\n default:\n throw new Error('Unrecognized Formula Token: ' + String(f));\n }\n var PtgNonDisp = ['PtgAttrSpace', 'PtgAttrSpaceSemi', 'PtgAttrGoto'];\n if (opts.biff != 3) if (last_sp >= 0 && PtgNonDisp.indexOf(formula[0][ff][0]) == -1) {\n f = formula[0][last_sp];\n var _left = true;\n switch (f[1][0]) {\n /* note: some bad XLSB files omit the PtgParen */\n case 4:\n _left = false;\n /* falls through */\n case 0:\n // $FlowIgnore\n sp = fill(\" \", f[1][1]);\n break;\n case 5:\n _left = false;\n /* falls through */\n case 1:\n // $FlowIgnore\n sp = fill(\"\\r\", f[1][1]);\n break;\n default:\n sp = \"\";\n // $FlowIgnore\n if (opts.WTF) throw new Error(\"Unexpected PtgAttrSpaceType \" + f[1][0]);\n }\n stack.push((_left ? sp : \"\") + stack.pop() + (_left ? \"\" : sp));\n last_sp = -1;\n }\n }\n if (stack.length > 1 && opts.WTF) throw new Error(\"bad formula stack\");\n return stack[0];\n}\n\n/* [MS-XLS] 2.5.198.1 TODO */\nfunction parse_ArrayParsedFormula(blob, length, opts /*::, ref*/) {\n var target = blob.l + length,\n len = opts.biff == 2 ? 1 : 2;\n var rgcb,\n cce = blob.read_shift(len); // length of rgce\n if (cce == 0xFFFF) return [[], parsenoop(blob, length - 2)];\n var rgce = parse_Rgce(blob, cce, opts);\n if (length !== cce + len) rgcb = parse_RgbExtra(blob, length - cce - len, rgce, opts);\n blob.l = target;\n return [rgce, rgcb];\n}\n\n/* [MS-XLS] 2.5.198.3 TODO */\nfunction parse_XLSCellParsedFormula(blob, length, opts) {\n var target = blob.l + length,\n len = opts.biff == 2 ? 1 : 2;\n var rgcb,\n cce = blob.read_shift(len); // length of rgce\n if (cce == 0xFFFF) return [[], parsenoop(blob, length - 2)];\n var rgce = parse_Rgce(blob, cce, opts);\n if (length !== cce + len) rgcb = parse_RgbExtra(blob, length - cce - len, rgce, opts);\n blob.l = target;\n return [rgce, rgcb];\n}\n\n/* [MS-XLS] 2.5.198.21 */\nfunction parse_NameParsedFormula(blob, length, opts, cce) {\n var target = blob.l + length;\n var rgce = parse_Rgce(blob, cce, opts);\n var rgcb;\n if (target !== blob.l) rgcb = parse_RgbExtra(blob, target - blob.l, rgce, opts);\n return [rgce, rgcb];\n}\n\n/* [MS-XLS] 2.5.198.118 TODO */\nfunction parse_SharedParsedFormula(blob, length, opts) {\n var target = blob.l + length;\n var rgcb,\n cce = blob.read_shift(2); // length of rgce\n var rgce = parse_Rgce(blob, cce, opts);\n if (cce == 0xFFFF) return [[], parsenoop(blob, length - 2)];\n if (length !== cce + 2) rgcb = parse_RgbExtra(blob, target - cce - 2, rgce, opts);\n return [rgce, rgcb];\n}\n\n/* [MS-XLS] 2.5.133 TODO: how to emit empty strings? */\nfunction parse_FormulaValue(blob /*::, length*/) {\n var b;\n if (__readUInt16LE(blob, blob.l + 6) !== 0xFFFF) return [parse_Xnum(blob), 'n'];\n switch (blob[blob.l]) {\n case 0x00:\n blob.l += 8;\n return [\"String\", 's'];\n case 0x01:\n b = blob[blob.l + 2] === 0x1;\n blob.l += 8;\n return [b, 'b'];\n case 0x02:\n b = blob[blob.l + 2];\n blob.l += 8;\n return [b, 'e'];\n case 0x03:\n blob.l += 8;\n return [\"\", 's'];\n }\n return [];\n}\nfunction write_FormulaValue(value) {\n if (value == null) {\n // Blank String Value\n var o = new_buf(8);\n o.write_shift(1, 0x03);\n o.write_shift(1, 0);\n o.write_shift(2, 0);\n o.write_shift(2, 0);\n o.write_shift(2, 0xFFFF);\n return o;\n } else if (typeof value == \"number\") return write_Xnum(value);\n return write_Xnum(0);\n}\n\n/* [MS-XLS] 2.4.127 TODO */\nfunction parse_Formula(blob, length, opts) {\n var end = blob.l + length;\n var cell = parse_XLSCell(blob, 6);\n if (opts.biff == 2) ++blob.l;\n var val = parse_FormulaValue(blob, 8);\n var flags = blob.read_shift(1);\n if (opts.biff != 2) {\n blob.read_shift(1);\n if (opts.biff >= 5) {\n /*var chn = */blob.read_shift(4);\n }\n }\n var cbf = parse_XLSCellParsedFormula(blob, end - blob.l, opts);\n return {\n cell: cell,\n val: val[0],\n formula: cbf,\n shared: flags >> 3 & 1,\n tt: val[1]\n };\n}\nfunction write_Formula(cell /*:Cell*/, R /*:number*/, C /*:number*/, opts, os /*:number*/) {\n // Cell\n var o1 = write_XLSCell(R, C, os);\n\n // FormulaValue\n var o2 = write_FormulaValue(cell.v);\n\n // flags + cache\n var o3 = new_buf(6);\n var flags = 0x01 | 0x20;\n o3.write_shift(2, flags);\n o3.write_shift(4, 0);\n\n // CellParsedFormula\n var bf = new_buf(cell.bf.length);\n for (var i = 0; i < cell.bf.length; ++i) bf[i] = cell.bf[i];\n var out = bconcat([o1, o2, o3, bf]);\n return out;\n}\n\n/* XLSB Parsed Formula records have the same shape */\nfunction parse_XLSBParsedFormula(data, length, opts) {\n var cce = data.read_shift(4);\n var rgce = parse_Rgce(data, cce, opts);\n var cb = data.read_shift(4);\n var rgcb = cb > 0 ? parse_RgbExtra(data, cb, rgce, opts) : null;\n return [rgce, rgcb];\n}\n\n/* [MS-XLSB] 2.5.97.1 ArrayParsedFormula */\nvar parse_XLSBArrayParsedFormula = parse_XLSBParsedFormula;\n/* [MS-XLSB] 2.5.97.4 CellParsedFormula */\nvar parse_XLSBCellParsedFormula = parse_XLSBParsedFormula;\n/* [MS-XLSB] 2.5.97.8 DVParsedFormula */\n//var parse_XLSBDVParsedFormula = parse_XLSBParsedFormula;\n/* [MS-XLSB] 2.5.97.9 FRTParsedFormula */\n//var parse_XLSBFRTParsedFormula = parse_XLSBParsedFormula2;\n/* [MS-XLSB] 2.5.97.12 NameParsedFormula */\nvar parse_XLSBNameParsedFormula = parse_XLSBParsedFormula;\n/* [MS-XLSB] 2.5.97.98 SharedParsedFormula */\nvar parse_XLSBSharedParsedFormula = parse_XLSBParsedFormula;\nvar Cetab = {\n 0: \"BEEP\",\n 1: \"OPEN\",\n 2: \"OPEN.LINKS\",\n 3: \"CLOSE.ALL\",\n 4: \"SAVE\",\n 5: \"SAVE.AS\",\n 6: \"FILE.DELETE\",\n 7: \"PAGE.SETUP\",\n 8: \"PRINT\",\n 9: \"PRINTER.SETUP\",\n 10: \"QUIT\",\n 11: \"NEW.WINDOW\",\n 12: \"ARRANGE.ALL\",\n 13: \"WINDOW.SIZE\",\n 14: \"WINDOW.MOVE\",\n 15: \"FULL\",\n 16: \"CLOSE\",\n 17: \"RUN\",\n 22: \"SET.PRINT.AREA\",\n 23: \"SET.PRINT.TITLES\",\n 24: \"SET.PAGE.BREAK\",\n 25: \"REMOVE.PAGE.BREAK\",\n 26: \"FONT\",\n 27: \"DISPLAY\",\n 28: \"PROTECT.DOCUMENT\",\n 29: \"PRECISION\",\n 30: \"A1.R1C1\",\n 31: \"CALCULATE.NOW\",\n 32: \"CALCULATION\",\n 34: \"DATA.FIND\",\n 35: \"EXTRACT\",\n 36: \"DATA.DELETE\",\n 37: \"SET.DATABASE\",\n 38: \"SET.CRITERIA\",\n 39: \"SORT\",\n 40: \"DATA.SERIES\",\n 41: \"TABLE\",\n 42: \"FORMAT.NUMBER\",\n 43: \"ALIGNMENT\",\n 44: \"STYLE\",\n 45: \"BORDER\",\n 46: \"CELL.PROTECTION\",\n 47: \"COLUMN.WIDTH\",\n 48: \"UNDO\",\n 49: \"CUT\",\n 50: \"COPY\",\n 51: \"PASTE\",\n 52: \"CLEAR\",\n 53: \"PASTE.SPECIAL\",\n 54: \"EDIT.DELETE\",\n 55: \"INSERT\",\n 56: \"FILL.RIGHT\",\n 57: \"FILL.DOWN\",\n 61: \"DEFINE.NAME\",\n 62: \"CREATE.NAMES\",\n 63: \"FORMULA.GOTO\",\n 64: \"FORMULA.FIND\",\n 65: \"SELECT.LAST.CELL\",\n 66: \"SHOW.ACTIVE.CELL\",\n 67: \"GALLERY.AREA\",\n 68: \"GALLERY.BAR\",\n 69: \"GALLERY.COLUMN\",\n 70: \"GALLERY.LINE\",\n 71: \"GALLERY.PIE\",\n 72: \"GALLERY.SCATTER\",\n 73: \"COMBINATION\",\n 74: \"PREFERRED\",\n 75: \"ADD.OVERLAY\",\n 76: \"GRIDLINES\",\n 77: \"SET.PREFERRED\",\n 78: \"AXES\",\n 79: \"LEGEND\",\n 80: \"ATTACH.TEXT\",\n 81: \"ADD.ARROW\",\n 82: \"SELECT.CHART\",\n 83: \"SELECT.PLOT.AREA\",\n 84: \"PATTERNS\",\n 85: \"MAIN.CHART\",\n 86: \"OVERLAY\",\n 87: \"SCALE\",\n 88: \"FORMAT.LEGEND\",\n 89: \"FORMAT.TEXT\",\n 90: \"EDIT.REPEAT\",\n 91: \"PARSE\",\n 92: \"JUSTIFY\",\n 93: \"HIDE\",\n 94: \"UNHIDE\",\n 95: \"WORKSPACE\",\n 96: \"FORMULA\",\n 97: \"FORMULA.FILL\",\n 98: \"FORMULA.ARRAY\",\n 99: \"DATA.FIND.NEXT\",\n 100: \"DATA.FIND.PREV\",\n 101: \"FORMULA.FIND.NEXT\",\n 102: \"FORMULA.FIND.PREV\",\n 103: \"ACTIVATE\",\n 104: \"ACTIVATE.NEXT\",\n 105: \"ACTIVATE.PREV\",\n 106: \"UNLOCKED.NEXT\",\n 107: \"UNLOCKED.PREV\",\n 108: \"COPY.PICTURE\",\n 109: \"SELECT\",\n 110: \"DELETE.NAME\",\n 111: \"DELETE.FORMAT\",\n 112: \"VLINE\",\n 113: \"HLINE\",\n 114: \"VPAGE\",\n 115: \"HPAGE\",\n 116: \"VSCROLL\",\n 117: \"HSCROLL\",\n 118: \"ALERT\",\n 119: \"NEW\",\n 120: \"CANCEL.COPY\",\n 121: \"SHOW.CLIPBOARD\",\n 122: \"MESSAGE\",\n 124: \"PASTE.LINK\",\n 125: \"APP.ACTIVATE\",\n 126: \"DELETE.ARROW\",\n 127: \"ROW.HEIGHT\",\n 128: \"FORMAT.MOVE\",\n 129: \"FORMAT.SIZE\",\n 130: \"FORMULA.REPLACE\",\n 131: \"SEND.KEYS\",\n 132: \"SELECT.SPECIAL\",\n 133: \"APPLY.NAMES\",\n 134: \"REPLACE.FONT\",\n 135: \"FREEZE.PANES\",\n 136: \"SHOW.INFO\",\n 137: \"SPLIT\",\n 138: \"ON.WINDOW\",\n 139: \"ON.DATA\",\n 140: \"DISABLE.INPUT\",\n 142: \"OUTLINE\",\n 143: \"LIST.NAMES\",\n 144: \"FILE.CLOSE\",\n 145: \"SAVE.WORKBOOK\",\n 146: \"DATA.FORM\",\n 147: \"COPY.CHART\",\n 148: \"ON.TIME\",\n 149: \"WAIT\",\n 150: \"FORMAT.FONT\",\n 151: \"FILL.UP\",\n 152: \"FILL.LEFT\",\n 153: \"DELETE.OVERLAY\",\n 155: \"SHORT.MENUS\",\n 159: \"SET.UPDATE.STATUS\",\n 161: \"COLOR.PALETTE\",\n 162: \"DELETE.STYLE\",\n 163: \"WINDOW.RESTORE\",\n 164: \"WINDOW.MAXIMIZE\",\n 166: \"CHANGE.LINK\",\n 167: \"CALCULATE.DOCUMENT\",\n 168: \"ON.KEY\",\n 169: \"APP.RESTORE\",\n 170: \"APP.MOVE\",\n 171: \"APP.SIZE\",\n 172: \"APP.MINIMIZE\",\n 173: \"APP.MAXIMIZE\",\n 174: \"BRING.TO.FRONT\",\n 175: \"SEND.TO.BACK\",\n 185: \"MAIN.CHART.TYPE\",\n 186: \"OVERLAY.CHART.TYPE\",\n 187: \"SELECT.END\",\n 188: \"OPEN.MAIL\",\n 189: \"SEND.MAIL\",\n 190: \"STANDARD.FONT\",\n 191: \"CONSOLIDATE\",\n 192: \"SORT.SPECIAL\",\n 193: \"GALLERY.3D.AREA\",\n 194: \"GALLERY.3D.COLUMN\",\n 195: \"GALLERY.3D.LINE\",\n 196: \"GALLERY.3D.PIE\",\n 197: \"VIEW.3D\",\n 198: \"GOAL.SEEK\",\n 199: \"WORKGROUP\",\n 200: \"FILL.GROUP\",\n 201: \"UPDATE.LINK\",\n 202: \"PROMOTE\",\n 203: \"DEMOTE\",\n 204: \"SHOW.DETAIL\",\n 206: \"UNGROUP\",\n 207: \"OBJECT.PROPERTIES\",\n 208: \"SAVE.NEW.OBJECT\",\n 209: \"SHARE\",\n 210: \"SHARE.NAME\",\n 211: \"DUPLICATE\",\n 212: \"APPLY.STYLE\",\n 213: \"ASSIGN.TO.OBJECT\",\n 214: \"OBJECT.PROTECTION\",\n 215: \"HIDE.OBJECT\",\n 216: \"SET.EXTRACT\",\n 217: \"CREATE.PUBLISHER\",\n 218: \"SUBSCRIBE.TO\",\n 219: \"ATTRIBUTES\",\n 220: \"SHOW.TOOLBAR\",\n 222: \"PRINT.PREVIEW\",\n 223: \"EDIT.COLOR\",\n 224: \"SHOW.LEVELS\",\n 225: \"FORMAT.MAIN\",\n 226: \"FORMAT.OVERLAY\",\n 227: \"ON.RECALC\",\n 228: \"EDIT.SERIES\",\n 229: \"DEFINE.STYLE\",\n 240: \"LINE.PRINT\",\n 243: \"ENTER.DATA\",\n 249: \"GALLERY.RADAR\",\n 250: \"MERGE.STYLES\",\n 251: \"EDITION.OPTIONS\",\n 252: \"PASTE.PICTURE\",\n 253: \"PASTE.PICTURE.LINK\",\n 254: \"SPELLING\",\n 256: \"ZOOM\",\n 259: \"INSERT.OBJECT\",\n 260: \"WINDOW.MINIMIZE\",\n 265: \"SOUND.NOTE\",\n 266: \"SOUND.PLAY\",\n 267: \"FORMAT.SHAPE\",\n 268: \"EXTEND.POLYGON\",\n 269: \"FORMAT.AUTO\",\n 272: \"GALLERY.3D.BAR\",\n 273: \"GALLERY.3D.SURFACE\",\n 274: \"FILL.AUTO\",\n 276: \"CUSTOMIZE.TOOLBAR\",\n 277: \"ADD.TOOL\",\n 278: \"EDIT.OBJECT\",\n 279: \"ON.DOUBLECLICK\",\n 280: \"ON.ENTRY\",\n 281: \"WORKBOOK.ADD\",\n 282: \"WORKBOOK.MOVE\",\n 283: \"WORKBOOK.COPY\",\n 284: \"WORKBOOK.OPTIONS\",\n 285: \"SAVE.WORKSPACE\",\n 288: \"CHART.WIZARD\",\n 289: \"DELETE.TOOL\",\n 290: \"MOVE.TOOL\",\n 291: \"WORKBOOK.SELECT\",\n 292: \"WORKBOOK.ACTIVATE\",\n 293: \"ASSIGN.TO.TOOL\",\n 295: \"COPY.TOOL\",\n 296: \"RESET.TOOL\",\n 297: \"CONSTRAIN.NUMERIC\",\n 298: \"PASTE.TOOL\",\n 302: \"WORKBOOK.NEW\",\n 305: \"SCENARIO.CELLS\",\n 306: \"SCENARIO.DELETE\",\n 307: \"SCENARIO.ADD\",\n 308: \"SCENARIO.EDIT\",\n 309: \"SCENARIO.SHOW\",\n 310: \"SCENARIO.SHOW.NEXT\",\n 311: \"SCENARIO.SUMMARY\",\n 312: \"PIVOT.TABLE.WIZARD\",\n 313: \"PIVOT.FIELD.PROPERTIES\",\n 314: \"PIVOT.FIELD\",\n 315: \"PIVOT.ITEM\",\n 316: \"PIVOT.ADD.FIELDS\",\n 318: \"OPTIONS.CALCULATION\",\n 319: \"OPTIONS.EDIT\",\n 320: \"OPTIONS.VIEW\",\n 321: \"ADDIN.MANAGER\",\n 322: \"MENU.EDITOR\",\n 323: \"ATTACH.TOOLBARS\",\n 324: \"VBAActivate\",\n 325: \"OPTIONS.CHART\",\n 328: \"VBA.INSERT.FILE\",\n 330: \"VBA.PROCEDURE.DEFINITION\",\n 336: \"ROUTING.SLIP\",\n 338: \"ROUTE.DOCUMENT\",\n 339: \"MAIL.LOGON\",\n 342: \"INSERT.PICTURE\",\n 343: \"EDIT.TOOL\",\n 344: \"GALLERY.DOUGHNUT\",\n 350: \"CHART.TREND\",\n 352: \"PIVOT.ITEM.PROPERTIES\",\n 354: \"WORKBOOK.INSERT\",\n 355: \"OPTIONS.TRANSITION\",\n 356: \"OPTIONS.GENERAL\",\n 370: \"FILTER.ADVANCED\",\n 373: \"MAIL.ADD.MAILER\",\n 374: \"MAIL.DELETE.MAILER\",\n 375: \"MAIL.REPLY\",\n 376: \"MAIL.REPLY.ALL\",\n 377: \"MAIL.FORWARD\",\n 378: \"MAIL.NEXT.LETTER\",\n 379: \"DATA.LABEL\",\n 380: \"INSERT.TITLE\",\n 381: \"FONT.PROPERTIES\",\n 382: \"MACRO.OPTIONS\",\n 383: \"WORKBOOK.HIDE\",\n 384: \"WORKBOOK.UNHIDE\",\n 385: \"WORKBOOK.DELETE\",\n 386: \"WORKBOOK.NAME\",\n 388: \"GALLERY.CUSTOM\",\n 390: \"ADD.CHART.AUTOFORMAT\",\n 391: \"DELETE.CHART.AUTOFORMAT\",\n 392: \"CHART.ADD.DATA\",\n 393: \"AUTO.OUTLINE\",\n 394: \"TAB.ORDER\",\n 395: \"SHOW.DIALOG\",\n 396: \"SELECT.ALL\",\n 397: \"UNGROUP.SHEETS\",\n 398: \"SUBTOTAL.CREATE\",\n 399: \"SUBTOTAL.REMOVE\",\n 400: \"RENAME.OBJECT\",\n 412: \"WORKBOOK.SCROLL\",\n 413: \"WORKBOOK.NEXT\",\n 414: \"WORKBOOK.PREV\",\n 415: \"WORKBOOK.TAB.SPLIT\",\n 416: \"FULL.SCREEN\",\n 417: \"WORKBOOK.PROTECT\",\n 420: \"SCROLLBAR.PROPERTIES\",\n 421: \"PIVOT.SHOW.PAGES\",\n 422: \"TEXT.TO.COLUMNS\",\n 423: \"FORMAT.CHARTTYPE\",\n 424: \"LINK.FORMAT\",\n 425: \"TRACER.DISPLAY\",\n 430: \"TRACER.NAVIGATE\",\n 431: \"TRACER.CLEAR\",\n 432: \"TRACER.ERROR\",\n 433: \"PIVOT.FIELD.GROUP\",\n 434: \"PIVOT.FIELD.UNGROUP\",\n 435: \"CHECKBOX.PROPERTIES\",\n 436: \"LABEL.PROPERTIES\",\n 437: \"LISTBOX.PROPERTIES\",\n 438: \"EDITBOX.PROPERTIES\",\n 439: \"PIVOT.REFRESH\",\n 440: \"LINK.COMBO\",\n 441: \"OPEN.TEXT\",\n 442: \"HIDE.DIALOG\",\n 443: \"SET.DIALOG.FOCUS\",\n 444: \"ENABLE.OBJECT\",\n 445: \"PUSHBUTTON.PROPERTIES\",\n 446: \"SET.DIALOG.DEFAULT\",\n 447: \"FILTER\",\n 448: \"FILTER.SHOW.ALL\",\n 449: \"CLEAR.OUTLINE\",\n 450: \"FUNCTION.WIZARD\",\n 451: \"ADD.LIST.ITEM\",\n 452: \"SET.LIST.ITEM\",\n 453: \"REMOVE.LIST.ITEM\",\n 454: \"SELECT.LIST.ITEM\",\n 455: \"SET.CONTROL.VALUE\",\n 456: \"SAVE.COPY.AS\",\n 458: \"OPTIONS.LISTS.ADD\",\n 459: \"OPTIONS.LISTS.DELETE\",\n 460: \"SERIES.AXES\",\n 461: \"SERIES.X\",\n 462: \"SERIES.Y\",\n 463: \"ERRORBAR.X\",\n 464: \"ERRORBAR.Y\",\n 465: \"FORMAT.CHART\",\n 466: \"SERIES.ORDER\",\n 467: \"MAIL.LOGOFF\",\n 468: \"CLEAR.ROUTING.SLIP\",\n 469: \"APP.ACTIVATE.MICROSOFT\",\n 470: \"MAIL.EDIT.MAILER\",\n 471: \"ON.SHEET\",\n 472: \"STANDARD.WIDTH\",\n 473: \"SCENARIO.MERGE\",\n 474: \"SUMMARY.INFO\",\n 475: \"FIND.FILE\",\n 476: \"ACTIVE.CELL.FONT\",\n 477: \"ENABLE.TIPWIZARD\",\n 478: \"VBA.MAKE.ADDIN\",\n 480: \"INSERTDATATABLE\",\n 481: \"WORKGROUP.OPTIONS\",\n 482: \"MAIL.SEND.MAILER\",\n 485: \"AUTOCORRECT\",\n 489: \"POST.DOCUMENT\",\n 491: \"PICKLIST\",\n 493: \"VIEW.SHOW\",\n 494: \"VIEW.DEFINE\",\n 495: \"VIEW.DELETE\",\n 509: \"SHEET.BACKGROUND\",\n 510: \"INSERT.MAP.OBJECT\",\n 511: \"OPTIONS.MENONO\",\n 517: \"MSOCHECKS\",\n 518: \"NORMAL\",\n 519: \"LAYOUT\",\n 520: \"RM.PRINT.AREA\",\n 521: \"CLEAR.PRINT.AREA\",\n 522: \"ADD.PRINT.AREA\",\n 523: \"MOVE.BRK\",\n 545: \"HIDECURR.NOTE\",\n 546: \"HIDEALL.NOTES\",\n 547: \"DELETE.NOTE\",\n 548: \"TRAVERSE.NOTES\",\n 549: \"ACTIVATE.NOTES\",\n 620: \"PROTECT.REVISIONS\",\n 621: \"UNPROTECT.REVISIONS\",\n 647: \"OPTIONS.ME\",\n 653: \"WEB.PUBLISH\",\n 667: \"NEWWEBQUERY\",\n 673: \"PIVOT.TABLE.CHART\",\n 753: \"OPTIONS.SAVE\",\n 755: \"OPTIONS.SPELL\",\n 808: \"HIDEALL.INKANNOTS\"\n};\nvar Ftab = {\n 0: \"COUNT\",\n 1: \"IF\",\n 2: \"ISNA\",\n 3: \"ISERROR\",\n 4: \"SUM\",\n 5: \"AVERAGE\",\n 6: \"MIN\",\n 7: \"MAX\",\n 8: \"ROW\",\n 9: \"COLUMN\",\n 10: \"NA\",\n 11: \"NPV\",\n 12: \"STDEV\",\n 13: \"DOLLAR\",\n 14: \"FIXED\",\n 15: \"SIN\",\n 16: \"COS\",\n 17: \"TAN\",\n 18: \"ATAN\",\n 19: \"PI\",\n 20: \"SQRT\",\n 21: \"EXP\",\n 22: \"LN\",\n 23: \"LOG10\",\n 24: \"ABS\",\n 25: \"INT\",\n 26: \"SIGN\",\n 27: \"ROUND\",\n 28: \"LOOKUP\",\n 29: \"INDEX\",\n 30: \"REPT\",\n 31: \"MID\",\n 32: \"LEN\",\n 33: \"VALUE\",\n 34: \"TRUE\",\n 35: \"FALSE\",\n 36: \"AND\",\n 37: \"OR\",\n 38: \"NOT\",\n 39: \"MOD\",\n 40: \"DCOUNT\",\n 41: \"DSUM\",\n 42: \"DAVERAGE\",\n 43: \"DMIN\",\n 44: \"DMAX\",\n 45: \"DSTDEV\",\n 46: \"VAR\",\n 47: \"DVAR\",\n 48: \"TEXT\",\n 49: \"LINEST\",\n 50: \"TREND\",\n 51: \"LOGEST\",\n 52: \"GROWTH\",\n 53: \"GOTO\",\n 54: \"HALT\",\n 55: \"RETURN\",\n 56: \"PV\",\n 57: \"FV\",\n 58: \"NPER\",\n 59: \"PMT\",\n 60: \"RATE\",\n 61: \"MIRR\",\n 62: \"IRR\",\n 63: \"RAND\",\n 64: \"MATCH\",\n 65: \"DATE\",\n 66: \"TIME\",\n 67: \"DAY\",\n 68: \"MONTH\",\n 69: \"YEAR\",\n 70: \"WEEKDAY\",\n 71: \"HOUR\",\n 72: \"MINUTE\",\n 73: \"SECOND\",\n 74: \"NOW\",\n 75: \"AREAS\",\n 76: \"ROWS\",\n 77: \"COLUMNS\",\n 78: \"OFFSET\",\n 79: \"ABSREF\",\n 80: \"RELREF\",\n 81: \"ARGUMENT\",\n 82: \"SEARCH\",\n 83: \"TRANSPOSE\",\n 84: \"ERROR\",\n 85: \"STEP\",\n 86: \"TYPE\",\n 87: \"ECHO\",\n 88: \"SET.NAME\",\n 89: \"CALLER\",\n 90: \"DEREF\",\n 91: \"WINDOWS\",\n 92: \"SERIES\",\n 93: \"DOCUMENTS\",\n 94: \"ACTIVE.CELL\",\n 95: \"SELECTION\",\n 96: \"RESULT\",\n 97: \"ATAN2\",\n 98: \"ASIN\",\n 99: \"ACOS\",\n 100: \"CHOOSE\",\n 101: \"HLOOKUP\",\n 102: \"VLOOKUP\",\n 103: \"LINKS\",\n 104: \"INPUT\",\n 105: \"ISREF\",\n 106: \"GET.FORMULA\",\n 107: \"GET.NAME\",\n 108: \"SET.VALUE\",\n 109: \"LOG\",\n 110: \"EXEC\",\n 111: \"CHAR\",\n 112: \"LOWER\",\n 113: \"UPPER\",\n 114: \"PROPER\",\n 115: \"LEFT\",\n 116: \"RIGHT\",\n 117: \"EXACT\",\n 118: \"TRIM\",\n 119: \"REPLACE\",\n 120: \"SUBSTITUTE\",\n 121: \"CODE\",\n 122: \"NAMES\",\n 123: \"DIRECTORY\",\n 124: \"FIND\",\n 125: \"CELL\",\n 126: \"ISERR\",\n 127: \"ISTEXT\",\n 128: \"ISNUMBER\",\n 129: \"ISBLANK\",\n 130: \"T\",\n 131: \"N\",\n 132: \"FOPEN\",\n 133: \"FCLOSE\",\n 134: \"FSIZE\",\n 135: \"FREADLN\",\n 136: \"FREAD\",\n 137: \"FWRITELN\",\n 138: \"FWRITE\",\n 139: \"FPOS\",\n 140: \"DATEVALUE\",\n 141: \"TIMEVALUE\",\n 142: \"SLN\",\n 143: \"SYD\",\n 144: \"DDB\",\n 145: \"GET.DEF\",\n 146: \"REFTEXT\",\n 147: \"TEXTREF\",\n 148: \"INDIRECT\",\n 149: \"REGISTER\",\n 150: \"CALL\",\n 151: \"ADD.BAR\",\n 152: \"ADD.MENU\",\n 153: \"ADD.COMMAND\",\n 154: \"ENABLE.COMMAND\",\n 155: \"CHECK.COMMAND\",\n 156: \"RENAME.COMMAND\",\n 157: \"SHOW.BAR\",\n 158: \"DELETE.MENU\",\n 159: \"DELETE.COMMAND\",\n 160: \"GET.CHART.ITEM\",\n 161: \"DIALOG.BOX\",\n 162: \"CLEAN\",\n 163: \"MDETERM\",\n 164: \"MINVERSE\",\n 165: \"MMULT\",\n 166: \"FILES\",\n 167: \"IPMT\",\n 168: \"PPMT\",\n 169: \"COUNTA\",\n 170: \"CANCEL.KEY\",\n 171: \"FOR\",\n 172: \"WHILE\",\n 173: \"BREAK\",\n 174: \"NEXT\",\n 175: \"INITIATE\",\n 176: \"REQUEST\",\n 177: \"POKE\",\n 178: \"EXECUTE\",\n 179: \"TERMINATE\",\n 180: \"RESTART\",\n 181: \"HELP\",\n 182: \"GET.BAR\",\n 183: \"PRODUCT\",\n 184: \"FACT\",\n 185: \"GET.CELL\",\n 186: \"GET.WORKSPACE\",\n 187: \"GET.WINDOW\",\n 188: \"GET.DOCUMENT\",\n 189: \"DPRODUCT\",\n 190: \"ISNONTEXT\",\n 191: \"GET.NOTE\",\n 192: \"NOTE\",\n 193: \"STDEVP\",\n 194: \"VARP\",\n 195: \"DSTDEVP\",\n 196: \"DVARP\",\n 197: \"TRUNC\",\n 198: \"ISLOGICAL\",\n 199: \"DCOUNTA\",\n 200: \"DELETE.BAR\",\n 201: \"UNREGISTER\",\n 204: \"USDOLLAR\",\n 205: \"FINDB\",\n 206: \"SEARCHB\",\n 207: \"REPLACEB\",\n 208: \"LEFTB\",\n 209: \"RIGHTB\",\n 210: \"MIDB\",\n 211: \"LENB\",\n 212: \"ROUNDUP\",\n 213: \"ROUNDDOWN\",\n 214: \"ASC\",\n 215: \"DBCS\",\n 216: \"RANK\",\n 219: \"ADDRESS\",\n 220: \"DAYS360\",\n 221: \"TODAY\",\n 222: \"VDB\",\n 223: \"ELSE\",\n 224: \"ELSE.IF\",\n 225: \"END.IF\",\n 226: \"FOR.CELL\",\n 227: \"MEDIAN\",\n 228: \"SUMPRODUCT\",\n 229: \"SINH\",\n 230: \"COSH\",\n 231: \"TANH\",\n 232: \"ASINH\",\n 233: \"ACOSH\",\n 234: \"ATANH\",\n 235: \"DGET\",\n 236: \"CREATE.OBJECT\",\n 237: \"VOLATILE\",\n 238: \"LAST.ERROR\",\n 239: \"CUSTOM.UNDO\",\n 240: \"CUSTOM.REPEAT\",\n 241: \"FORMULA.CONVERT\",\n 242: \"GET.LINK.INFO\",\n 243: \"TEXT.BOX\",\n 244: \"INFO\",\n 245: \"GROUP\",\n 246: \"GET.OBJECT\",\n 247: \"DB\",\n 248: \"PAUSE\",\n 251: \"RESUME\",\n 252: \"FREQUENCY\",\n 253: \"ADD.TOOLBAR\",\n 254: \"DELETE.TOOLBAR\",\n 255: \"User\",\n 256: \"RESET.TOOLBAR\",\n 257: \"EVALUATE\",\n 258: \"GET.TOOLBAR\",\n 259: \"GET.TOOL\",\n 260: \"SPELLING.CHECK\",\n 261: \"ERROR.TYPE\",\n 262: \"APP.TITLE\",\n 263: \"WINDOW.TITLE\",\n 264: \"SAVE.TOOLBAR\",\n 265: \"ENABLE.TOOL\",\n 266: \"PRESS.TOOL\",\n 267: \"REGISTER.ID\",\n 268: \"GET.WORKBOOK\",\n 269: \"AVEDEV\",\n 270: \"BETADIST\",\n 271: \"GAMMALN\",\n 272: \"BETAINV\",\n 273: \"BINOMDIST\",\n 274: \"CHIDIST\",\n 275: \"CHIINV\",\n 276: \"COMBIN\",\n 277: \"CONFIDENCE\",\n 278: \"CRITBINOM\",\n 279: \"EVEN\",\n 280: \"EXPONDIST\",\n 281: \"FDIST\",\n 282: \"FINV\",\n 283: \"FISHER\",\n 284: \"FISHERINV\",\n 285: \"FLOOR\",\n 286: \"GAMMADIST\",\n 287: \"GAMMAINV\",\n 288: \"CEILING\",\n 289: \"HYPGEOMDIST\",\n 290: \"LOGNORMDIST\",\n 291: \"LOGINV\",\n 292: \"NEGBINOMDIST\",\n 293: \"NORMDIST\",\n 294: \"NORMSDIST\",\n 295: \"NORMINV\",\n 296: \"NORMSINV\",\n 297: \"STANDARDIZE\",\n 298: \"ODD\",\n 299: \"PERMUT\",\n 300: \"POISSON\",\n 301: \"TDIST\",\n 302: \"WEIBULL\",\n 303: \"SUMXMY2\",\n 304: \"SUMX2MY2\",\n 305: \"SUMX2PY2\",\n 306: \"CHITEST\",\n 307: \"CORREL\",\n 308: \"COVAR\",\n 309: \"FORECAST\",\n 310: \"FTEST\",\n 311: \"INTERCEPT\",\n 312: \"PEARSON\",\n 313: \"RSQ\",\n 314: \"STEYX\",\n 315: \"SLOPE\",\n 316: \"TTEST\",\n 317: \"PROB\",\n 318: \"DEVSQ\",\n 319: \"GEOMEAN\",\n 320: \"HARMEAN\",\n 321: \"SUMSQ\",\n 322: \"KURT\",\n 323: \"SKEW\",\n 324: \"ZTEST\",\n 325: \"LARGE\",\n 326: \"SMALL\",\n 327: \"QUARTILE\",\n 328: \"PERCENTILE\",\n 329: \"PERCENTRANK\",\n 330: \"MODE\",\n 331: \"TRIMMEAN\",\n 332: \"TINV\",\n 334: \"MOVIE.COMMAND\",\n 335: \"GET.MOVIE\",\n 336: \"CONCATENATE\",\n 337: \"POWER\",\n 338: \"PIVOT.ADD.DATA\",\n 339: \"GET.PIVOT.TABLE\",\n 340: \"GET.PIVOT.FIELD\",\n 341: \"GET.PIVOT.ITEM\",\n 342: \"RADIANS\",\n 343: \"DEGREES\",\n 344: \"SUBTOTAL\",\n 345: \"SUMIF\",\n 346: \"COUNTIF\",\n 347: \"COUNTBLANK\",\n 348: \"SCENARIO.GET\",\n 349: \"OPTIONS.LISTS.GET\",\n 350: \"ISPMT\",\n 351: \"DATEDIF\",\n 352: \"DATESTRING\",\n 353: \"NUMBERSTRING\",\n 354: \"ROMAN\",\n 355: \"OPEN.DIALOG\",\n 356: \"SAVE.DIALOG\",\n 357: \"VIEW.GET\",\n 358: \"GETPIVOTDATA\",\n 359: \"HYPERLINK\",\n 360: \"PHONETIC\",\n 361: \"AVERAGEA\",\n 362: \"MAXA\",\n 363: \"MINA\",\n 364: \"STDEVPA\",\n 365: \"VARPA\",\n 366: \"STDEVA\",\n 367: \"VARA\",\n 368: \"BAHTTEXT\",\n 369: \"THAIDAYOFWEEK\",\n 370: \"THAIDIGIT\",\n 371: \"THAIMONTHOFYEAR\",\n 372: \"THAINUMSOUND\",\n 373: \"THAINUMSTRING\",\n 374: \"THAISTRINGLENGTH\",\n 375: \"ISTHAIDIGIT\",\n 376: \"ROUNDBAHTDOWN\",\n 377: \"ROUNDBAHTUP\",\n 378: \"THAIYEAR\",\n 379: \"RTD\",\n 380: \"CUBEVALUE\",\n 381: \"CUBEMEMBER\",\n 382: \"CUBEMEMBERPROPERTY\",\n 383: \"CUBERANKEDMEMBER\",\n 384: \"HEX2BIN\",\n 385: \"HEX2DEC\",\n 386: \"HEX2OCT\",\n 387: \"DEC2BIN\",\n 388: \"DEC2HEX\",\n 389: \"DEC2OCT\",\n 390: \"OCT2BIN\",\n 391: \"OCT2HEX\",\n 392: \"OCT2DEC\",\n 393: \"BIN2DEC\",\n 394: \"BIN2OCT\",\n 395: \"BIN2HEX\",\n 396: \"IMSUB\",\n 397: \"IMDIV\",\n 398: \"IMPOWER\",\n 399: \"IMABS\",\n 400: \"IMSQRT\",\n 401: \"IMLN\",\n 402: \"IMLOG2\",\n 403: \"IMLOG10\",\n 404: \"IMSIN\",\n 405: \"IMCOS\",\n 406: \"IMEXP\",\n 407: \"IMARGUMENT\",\n 408: \"IMCONJUGATE\",\n 409: \"IMAGINARY\",\n 410: \"IMREAL\",\n 411: \"COMPLEX\",\n 412: \"IMSUM\",\n 413: \"IMPRODUCT\",\n 414: \"SERIESSUM\",\n 415: \"FACTDOUBLE\",\n 416: \"SQRTPI\",\n 417: \"QUOTIENT\",\n 418: \"DELTA\",\n 419: \"GESTEP\",\n 420: \"ISEVEN\",\n 421: \"ISODD\",\n 422: \"MROUND\",\n 423: \"ERF\",\n 424: \"ERFC\",\n 425: \"BESSELJ\",\n 426: \"BESSELK\",\n 427: \"BESSELY\",\n 428: \"BESSELI\",\n 429: \"XIRR\",\n 430: \"XNPV\",\n 431: \"PRICEMAT\",\n 432: \"YIELDMAT\",\n 433: \"INTRATE\",\n 434: \"RECEIVED\",\n 435: \"DISC\",\n 436: \"PRICEDISC\",\n 437: \"YIELDDISC\",\n 438: \"TBILLEQ\",\n 439: \"TBILLPRICE\",\n 440: \"TBILLYIELD\",\n 441: \"PRICE\",\n 442: \"YIELD\",\n 443: \"DOLLARDE\",\n 444: \"DOLLARFR\",\n 445: \"NOMINAL\",\n 446: \"EFFECT\",\n 447: \"CUMPRINC\",\n 448: \"CUMIPMT\",\n 449: \"EDATE\",\n 450: \"EOMONTH\",\n 451: \"YEARFRAC\",\n 452: \"COUPDAYBS\",\n 453: \"COUPDAYS\",\n 454: \"COUPDAYSNC\",\n 455: \"COUPNCD\",\n 456: \"COUPNUM\",\n 457: \"COUPPCD\",\n 458: \"DURATION\",\n 459: \"MDURATION\",\n 460: \"ODDLPRICE\",\n 461: \"ODDLYIELD\",\n 462: \"ODDFPRICE\",\n 463: \"ODDFYIELD\",\n 464: \"RANDBETWEEN\",\n 465: \"WEEKNUM\",\n 466: \"AMORDEGRC\",\n 467: \"AMORLINC\",\n 468: \"CONVERT\",\n 724: \"SHEETJS\",\n 469: \"ACCRINT\",\n 470: \"ACCRINTM\",\n 471: \"WORKDAY\",\n 472: \"NETWORKDAYS\",\n 473: \"GCD\",\n 474: \"MULTINOMIAL\",\n 475: \"LCM\",\n 476: \"FVSCHEDULE\",\n 477: \"CUBEKPIMEMBER\",\n 478: \"CUBESET\",\n 479: \"CUBESETCOUNT\",\n 480: \"IFERROR\",\n 481: \"COUNTIFS\",\n 482: \"SUMIFS\",\n 483: \"AVERAGEIF\",\n 484: \"AVERAGEIFS\"\n};\nvar FtabArgc = {\n 2: 1,\n 3: 1,\n 10: 0,\n 15: 1,\n 16: 1,\n 17: 1,\n 18: 1,\n 19: 0,\n 20: 1,\n 21: 1,\n 22: 1,\n 23: 1,\n 24: 1,\n 25: 1,\n 26: 1,\n 27: 2,\n 30: 2,\n 31: 3,\n 32: 1,\n 33: 1,\n 34: 0,\n 35: 0,\n 38: 1,\n 39: 2,\n 40: 3,\n 41: 3,\n 42: 3,\n 43: 3,\n 44: 3,\n 45: 3,\n 47: 3,\n 48: 2,\n 53: 1,\n 61: 3,\n 63: 0,\n 65: 3,\n 66: 3,\n 67: 1,\n 68: 1,\n 69: 1,\n 70: 1,\n 71: 1,\n 72: 1,\n 73: 1,\n 74: 0,\n 75: 1,\n 76: 1,\n 77: 1,\n 79: 2,\n 80: 2,\n 83: 1,\n 85: 0,\n 86: 1,\n 89: 0,\n 90: 1,\n 94: 0,\n 95: 0,\n 97: 2,\n 98: 1,\n 99: 1,\n 101: 3,\n 102: 3,\n 105: 1,\n 106: 1,\n 108: 2,\n 111: 1,\n 112: 1,\n 113: 1,\n 114: 1,\n 117: 2,\n 118: 1,\n 119: 4,\n 121: 1,\n 126: 1,\n 127: 1,\n 128: 1,\n 129: 1,\n 130: 1,\n 131: 1,\n 133: 1,\n 134: 1,\n 135: 1,\n 136: 2,\n 137: 2,\n 138: 2,\n 140: 1,\n 141: 1,\n 142: 3,\n 143: 4,\n 144: 4,\n 161: 1,\n 162: 1,\n 163: 1,\n 164: 1,\n 165: 2,\n 172: 1,\n 175: 2,\n 176: 2,\n 177: 3,\n 178: 2,\n 179: 1,\n 184: 1,\n 186: 1,\n 189: 3,\n 190: 1,\n 195: 3,\n 196: 3,\n 197: 1,\n 198: 1,\n 199: 3,\n 201: 1,\n 207: 4,\n 210: 3,\n 211: 1,\n 212: 2,\n 213: 2,\n 214: 1,\n 215: 1,\n 225: 0,\n 229: 1,\n 230: 1,\n 231: 1,\n 232: 1,\n 233: 1,\n 234: 1,\n 235: 3,\n 244: 1,\n 247: 4,\n 252: 2,\n 257: 1,\n 261: 1,\n 271: 1,\n 273: 4,\n 274: 2,\n 275: 2,\n 276: 2,\n 277: 3,\n 278: 3,\n 279: 1,\n 280: 3,\n 281: 3,\n 282: 3,\n 283: 1,\n 284: 1,\n 285: 2,\n 286: 4,\n 287: 3,\n 288: 2,\n 289: 4,\n 290: 3,\n 291: 3,\n 292: 3,\n 293: 4,\n 294: 1,\n 295: 3,\n 296: 1,\n 297: 3,\n 298: 1,\n 299: 2,\n 300: 3,\n 301: 3,\n 302: 4,\n 303: 2,\n 304: 2,\n 305: 2,\n 306: 2,\n 307: 2,\n 308: 2,\n 309: 3,\n 310: 2,\n 311: 2,\n 312: 2,\n 313: 2,\n 314: 2,\n 315: 2,\n 316: 4,\n 325: 2,\n 326: 2,\n 327: 2,\n 328: 2,\n 331: 2,\n 332: 2,\n 337: 2,\n 342: 1,\n 343: 1,\n 346: 2,\n 347: 1,\n 350: 4,\n 351: 3,\n 352: 1,\n 353: 2,\n 360: 1,\n 368: 1,\n 369: 1,\n 370: 1,\n 371: 1,\n 372: 1,\n 373: 1,\n 374: 1,\n 375: 1,\n 376: 1,\n 377: 1,\n 378: 1,\n 382: 3,\n 385: 1,\n 392: 1,\n 393: 1,\n 396: 2,\n 397: 2,\n 398: 2,\n 399: 1,\n 400: 1,\n 401: 1,\n 402: 1,\n 403: 1,\n 404: 1,\n 405: 1,\n 406: 1,\n 407: 1,\n 408: 1,\n 409: 1,\n 410: 1,\n 414: 4,\n 415: 1,\n 416: 1,\n 417: 2,\n 420: 1,\n 421: 1,\n 422: 2,\n 424: 1,\n 425: 2,\n 426: 2,\n 427: 2,\n 428: 2,\n 430: 3,\n 438: 3,\n 439: 3,\n 440: 3,\n 443: 2,\n 444: 2,\n 445: 2,\n 446: 2,\n 447: 6,\n 448: 6,\n 449: 2,\n 450: 2,\n 464: 2,\n 468: 3,\n 476: 2,\n 479: 1,\n 480: 2,\n 65535: 0\n};\n/* Part 3 TODO: actually parse formulae */\nfunction ods_to_csf_formula(f /*:string*/) /*:string*/{\n if (f.slice(0, 3) == \"of:\") f = f.slice(3);\n /* 5.2 Basic Expressions */\n if (f.charCodeAt(0) == 61) {\n f = f.slice(1);\n if (f.charCodeAt(0) == 61) f = f.slice(1);\n }\n f = f.replace(/COM\\.MICROSOFT\\./g, \"\");\n /* Part 3 Section 5.8 References */\n f = f.replace(/\\[((?:\\.[A-Z]+[0-9]+)(?::\\.[A-Z]+[0-9]+)?)\\]/g, function ($$, $1) {\n return $1.replace(/\\./g, \"\");\n });\n /* TODO: something other than this */\n f = f.replace(/\\[.(#[A-Z]*[?!])\\]/g, \"$1\");\n return f.replace(/[;~]/g, \",\").replace(/\\|/g, \";\");\n}\nfunction csf_to_ods_formula(f /*:string*/) /*:string*/{\n var o = \"of:=\" + f.replace(crefregex, \"$1[.$2$3$4$5]\").replace(/\\]:\\[/g, \":\");\n /* TODO: something other than this */\n return o.replace(/;/g, \"|\").replace(/,/g, \";\");\n}\nfunction ods_to_csf_3D(r /*:string*/) /*:[string, string]*/{\n var a = r.split(\":\");\n var s = a[0].split(\".\")[0];\n return [s, a[0].split(\".\")[1] + (a.length > 1 ? \":\" + (a[1].split(\".\")[1] || a[1].split(\".\")[0]) : \"\")];\n}\nfunction csf_to_ods_3D(r /*:string*/) /*:string*/{\n return r.replace(/\\./, \"!\");\n}\nvar strs = {}; // shared strings\nvar _ssfopts = {}; // spreadsheet formatting options\n\n/*global Map */\nvar browser_has_Map = typeof Map !== 'undefined';\nfunction get_sst_id(sst /*:SST*/, str /*:string*/, rev) /*:number*/{\n var i = 0,\n len = sst.length;\n if (rev) {\n if (browser_has_Map ? rev.has(str) : Object.prototype.hasOwnProperty.call(rev, str)) {\n var revarr = browser_has_Map ? rev.get(str) : rev[str];\n for (; i < revarr.length; ++i) {\n if (sst[revarr[i]].t === str) {\n sst.Count++;\n return revarr[i];\n }\n }\n }\n } else for (; i < len; ++i) {\n if (sst[i].t === str) {\n sst.Count++;\n return i;\n }\n }\n sst[len] = {\n t: str\n } /*:any*/;\n sst.Count++;\n sst.Unique++;\n if (rev) {\n if (browser_has_Map) {\n if (!rev.has(str)) rev.set(str, []);\n rev.get(str).push(len);\n } else {\n if (!Object.prototype.hasOwnProperty.call(rev, str)) rev[str] = [];\n rev[str].push(len);\n }\n }\n return len;\n}\nfunction col_obj_w(C /*:number*/, col) {\n var p = {\n min: C + 1,\n max: C + 1\n } /*:any*/;\n /* wch (chars), wpx (pixels) */\n var wch = -1;\n if (col.MDW) MDW = col.MDW;\n if (col.width != null) p.customWidth = 1;else if (col.wpx != null) wch = px2char(col.wpx);else if (col.wch != null) wch = col.wch;\n if (wch > -1) {\n p.width = char2width(wch);\n p.customWidth = 1;\n } else if (col.width != null) p.width = col.width;\n if (col.hidden) p.hidden = true;\n if (col.level != null) {\n p.outlineLevel = p.level = col.level;\n }\n return p;\n}\nfunction default_margins(margins /*:Margins*/, mode /*:?string*/) {\n if (!margins) return;\n var defs = [0.7, 0.7, 0.75, 0.75, 0.3, 0.3];\n if (mode == 'xlml') defs = [1, 1, 1, 1, 0.5, 0.5];\n if (margins.left == null) margins.left = defs[0];\n if (margins.right == null) margins.right = defs[1];\n if (margins.top == null) margins.top = defs[2];\n if (margins.bottom == null) margins.bottom = defs[3];\n if (margins.header == null) margins.header = defs[4];\n if (margins.footer == null) margins.footer = defs[5];\n}\nfunction get_cell_style(styles /*:Array*/, cell /*:Cell*/, opts) {\n var z = opts.revssf[cell.z != null ? cell.z : \"General\"];\n var i = 0x3c,\n len = styles.length;\n if (z == null && opts.ssf) {\n for (; i < 0x188; ++i) if (opts.ssf[i] == null) {\n SSF_load(cell.z, i);\n // $FlowIgnore\n opts.ssf[i] = cell.z;\n opts.revssf[cell.z] = z = i;\n break;\n }\n }\n for (i = 0; i != len; ++i) if (styles[i].numFmtId === z) return i;\n styles[len] = {\n numFmtId: z,\n fontId: 0,\n fillId: 0,\n borderId: 0,\n xfId: 0,\n applyNumberFormat: 1\n };\n return len;\n}\nfunction safe_format(p /*:Cell*/, fmtid /*:number*/, fillid /*:?number*/, opts, themes, styles) {\n try {\n if (opts.cellNF) p.z = table_fmt[fmtid];\n } catch (e) {\n if (opts.WTF) throw e;\n }\n if (p.t === 'z' && !opts.cellStyles) return;\n if (p.t === 'd' && typeof p.v === 'string') p.v = parseDate(p.v);\n if ((!opts || opts.cellText !== false) && p.t !== 'z') try {\n if (table_fmt[fmtid] == null) SSF_load(SSFImplicit[fmtid] || \"General\", fmtid);\n if (p.t === 'e') p.w = p.w || BErr[p.v];else if (fmtid === 0) {\n if (p.t === 'n') {\n if ((p.v | 0) === p.v) p.w = p.v.toString(10);else p.w = SSF_general_num(p.v);\n } else if (p.t === 'd') {\n var dd = datenum(p.v);\n if ((dd | 0) === dd) p.w = dd.toString(10);else p.w = SSF_general_num(dd);\n } else if (p.v === undefined) return \"\";else p.w = SSF_general(p.v, _ssfopts);\n } else if (p.t === 'd') p.w = SSF_format(fmtid, datenum(p.v), _ssfopts);else p.w = SSF_format(fmtid, p.v, _ssfopts);\n } catch (e) {\n if (opts.WTF) throw e;\n }\n if (!opts.cellStyles) return;\n if (fillid != null) try {\n p.s = styles.Fills[fillid];\n if (p.s.fgColor && p.s.fgColor.theme && !p.s.fgColor.rgb) {\n p.s.fgColor.rgb = rgb_tint(themes.themeElements.clrScheme[p.s.fgColor.theme].rgb, p.s.fgColor.tint || 0);\n if (opts.WTF) p.s.fgColor.raw_rgb = themes.themeElements.clrScheme[p.s.fgColor.theme].rgb;\n }\n if (p.s.bgColor && p.s.bgColor.theme) {\n p.s.bgColor.rgb = rgb_tint(themes.themeElements.clrScheme[p.s.bgColor.theme].rgb, p.s.bgColor.tint || 0);\n if (opts.WTF) p.s.bgColor.raw_rgb = themes.themeElements.clrScheme[p.s.bgColor.theme].rgb;\n }\n } catch (e) {\n if (opts.WTF && styles.Fills) throw e;\n }\n}\nfunction check_ws(ws /*:Worksheet*/, sname /*:string*/, i /*:number*/) {\n if (ws && ws['!ref']) {\n var range = safe_decode_range(ws['!ref']);\n if (range.e.c < range.s.c || range.e.r < range.s.r) throw new Error(\"Bad range (\" + i + \"): \" + ws['!ref']);\n }\n}\nfunction parse_ws_xml_dim(ws /*:Worksheet*/, s /*:string*/) {\n var d = safe_decode_range(s);\n if (d.s.r <= d.e.r && d.s.c <= d.e.c && d.s.r >= 0 && d.s.c >= 0) ws[\"!ref\"] = encode_range(d);\n}\nvar mergecregex = /<(?:\\w:)?mergeCell ref=\"[A-Z0-9:]+\"\\s*[\\/]?>/g;\nvar sheetdataregex = /<(?:\\w+:)?sheetData[^>]*>([\\s\\S]*)<\\/(?:\\w+:)?sheetData>/;\nvar hlinkregex = /<(?:\\w:)?hyperlink [^>]*>/mg;\nvar dimregex = /\"(\\w*:\\w*)\"/;\nvar colregex = /<(?:\\w:)?col\\b[^>]*[\\/]?>/g;\nvar afregex = /<(?:\\w:)?autoFilter[^>]*([\\/]|>([\\s\\S]*)<\\/(?:\\w:)?autoFilter)>/g;\nvar marginregex = /<(?:\\w:)?pageMargins[^>]*\\/>/g;\nvar sheetprregex = /<(?:\\w:)?sheetPr\\b(?:[^>a-z][^>]*)?\\/>/;\nvar sheetprregex2 = /<(?:\\w:)?sheetPr[^>]*(?:[\\/]|>([\\s\\S]*)<\\/(?:\\w:)?sheetPr)>/;\nvar svsregex = /<(?:\\w:)?sheetViews[^>]*(?:[\\/]|>([\\s\\S]*)<\\/(?:\\w:)?sheetViews)>/;\n\n/* 18.3 Worksheets */\nfunction parse_ws_xml(data /*:?string*/, opts, idx /*:number*/, rels, wb /*:WBWBProps*/, themes, styles) /*:Worksheet*/{\n if (!data) return data;\n if (!rels) rels = {\n '!id': {}\n };\n if (DENSE != null && opts.dense == null) opts.dense = DENSE;\n\n /* 18.3.1.99 worksheet CT_Worksheet */\n var s = opts.dense ? [] /*:any*/ : {} /*:any*/;\n var refguess /*:Range*/ = {\n s: {\n r: 2000000,\n c: 2000000\n },\n e: {\n r: 0,\n c: 0\n }\n } /*:any*/;\n var data1 = \"\",\n data2 = \"\";\n var mtch /*:?any*/ = data.match(sheetdataregex);\n if (mtch) {\n data1 = data.slice(0, mtch.index);\n data2 = data.slice(mtch.index + mtch[0].length);\n } else data1 = data2 = data;\n\n /* 18.3.1.82 sheetPr CT_SheetPr */\n var sheetPr = data1.match(sheetprregex);\n if (sheetPr) parse_ws_xml_sheetpr(sheetPr[0], s, wb, idx);else if (sheetPr = data1.match(sheetprregex2)) parse_ws_xml_sheetpr2(sheetPr[0], sheetPr[1] || \"\", s, wb, idx, styles, themes);\n\n /* 18.3.1.35 dimension CT_SheetDimension */\n var ridx = (data1.match(/<(?:\\w*:)?dimension/) || {\n index: -1\n }).index;\n if (ridx > 0) {\n var ref = data1.slice(ridx, ridx + 50).match(dimregex);\n if (ref) parse_ws_xml_dim(s, ref[1]);\n }\n\n /* 18.3.1.88 sheetViews CT_SheetViews */\n var svs = data1.match(svsregex);\n if (svs && svs[1]) parse_ws_xml_sheetviews(svs[1], wb);\n\n /* 18.3.1.17 cols CT_Cols */\n var columns /*:Array*/ = [];\n if (opts.cellStyles) {\n /* 18.3.1.13 col CT_Col */\n var cols = data1.match(colregex);\n if (cols) parse_ws_xml_cols(columns, cols);\n }\n\n /* 18.3.1.80 sheetData CT_SheetData ? */\n if (mtch) parse_ws_xml_data(mtch[1], s, opts, refguess, themes, styles);\n\n /* 18.3.1.2 autoFilter CT_AutoFilter */\n var afilter = data2.match(afregex);\n if (afilter) s['!autofilter'] = parse_ws_xml_autofilter(afilter[0]);\n\n /* 18.3.1.55 mergeCells CT_MergeCells */\n var merges /*:Array*/ = [];\n var _merge = data2.match(mergecregex);\n if (_merge) for (ridx = 0; ridx != _merge.length; ++ridx) merges[ridx] = safe_decode_range(_merge[ridx].slice(_merge[ridx].indexOf(\"\\\"\") + 1));\n\n /* 18.3.1.48 hyperlinks CT_Hyperlinks */\n var hlink = data2.match(hlinkregex);\n if (hlink) parse_ws_xml_hlinks(s, hlink, rels);\n\n /* 18.3.1.62 pageMargins CT_PageMargins */\n var margins = data2.match(marginregex);\n if (margins) s['!margins'] = parse_ws_xml_margins(parsexmltag(margins[0]));\n if (!s[\"!ref\"] && refguess.e.c >= refguess.s.c && refguess.e.r >= refguess.s.r) s[\"!ref\"] = encode_range(refguess);\n if (opts.sheetRows > 0 && s[\"!ref\"]) {\n var tmpref = safe_decode_range(s[\"!ref\"]);\n if (opts.sheetRows <= +tmpref.e.r) {\n tmpref.e.r = opts.sheetRows - 1;\n if (tmpref.e.r > refguess.e.r) tmpref.e.r = refguess.e.r;\n if (tmpref.e.r < tmpref.s.r) tmpref.s.r = tmpref.e.r;\n if (tmpref.e.c > refguess.e.c) tmpref.e.c = refguess.e.c;\n if (tmpref.e.c < tmpref.s.c) tmpref.s.c = tmpref.e.c;\n s[\"!fullref\"] = s[\"!ref\"];\n s[\"!ref\"] = encode_range(tmpref);\n }\n }\n if (columns.length > 0) s[\"!cols\"] = columns;\n if (merges.length > 0) s[\"!merges\"] = merges;\n return s;\n}\nfunction write_ws_xml_merges(merges /*:Array*/) /*:string*/{\n if (merges.length === 0) return \"\";\n var o = '';\n for (var i = 0; i != merges.length; ++i) o += '';\n return o + '';\n}\n\n/* 18.3.1.82-3 sheetPr CT_ChartsheetPr / CT_SheetPr */\nfunction parse_ws_xml_sheetpr(sheetPr /*:string*/, s, wb /*:WBWBProps*/, idx /*:number*/) {\n var data = parsexmltag(sheetPr);\n if (!wb.Sheets[idx]) wb.Sheets[idx] = {};\n if (data.codeName) wb.Sheets[idx].CodeName = unescapexml(utf8read(data.codeName));\n}\nfunction parse_ws_xml_sheetpr2(sheetPr /*:string*/, body /*:string*/, s, wb /*:WBWBProps*/, idx /*:number*/) {\n parse_ws_xml_sheetpr(sheetPr.slice(0, sheetPr.indexOf(\">\")), s, wb, idx);\n}\nfunction write_ws_xml_sheetpr(ws, wb, idx, opts, o) {\n var needed = false;\n var props = {},\n payload = null;\n if (opts.bookType !== 'xlsx' && wb.vbaraw) {\n var cname = wb.SheetNames[idx];\n try {\n if (wb.Workbook) cname = wb.Workbook.Sheets[idx].CodeName || cname;\n } catch (e) {}\n needed = true;\n props.codeName = utf8write(escapexml(cname));\n }\n if (ws && ws[\"!outline\"]) {\n var outlineprops = {\n summaryBelow: 1,\n summaryRight: 1\n };\n if (ws[\"!outline\"].above) outlineprops.summaryBelow = 0;\n if (ws[\"!outline\"].left) outlineprops.summaryRight = 0;\n payload = (payload || \"\") + writextag('outlinePr', null, outlineprops);\n }\n if (!needed && !payload) return;\n o[o.length] = writextag('sheetPr', payload, props);\n}\n\n/* 18.3.1.85 sheetProtection CT_SheetProtection */\nvar sheetprot_deffalse = [\"objects\", \"scenarios\", \"selectLockedCells\", \"selectUnlockedCells\"];\nvar sheetprot_deftrue = [\"formatColumns\", \"formatRows\", \"formatCells\", \"insertColumns\", \"insertRows\", \"insertHyperlinks\", \"deleteColumns\", \"deleteRows\", \"sort\", \"autoFilter\", \"pivotTables\"];\nfunction write_ws_xml_protection(sp) /*:string*/{\n // algorithmName, hashValue, saltValue, spinCount\n var o = {\n sheet: 1\n } /*:any*/;\n sheetprot_deffalse.forEach(function (n) {\n if (sp[n] != null && sp[n]) o[n] = \"1\";\n });\n sheetprot_deftrue.forEach(function (n) {\n if (sp[n] != null && !sp[n]) o[n] = \"0\";\n });\n /* TODO: algorithm */\n if (sp.password) o.password = crypto_CreatePasswordVerifier_Method1(sp.password).toString(16).toUpperCase();\n return writextag('sheetProtection', null, o);\n}\nfunction parse_ws_xml_hlinks(s, data /*:Array*/, rels) {\n var dense = Array.isArray(s);\n for (var i = 0; i != data.length; ++i) {\n var val = parsexmltag(utf8read(data[i]), true);\n if (!val.ref) return;\n var rel = ((rels || {})['!id'] || [])[val.id];\n if (rel) {\n val.Target = rel.Target;\n if (val.location) val.Target += \"#\" + unescapexml(val.location);\n } else {\n val.Target = \"#\" + unescapexml(val.location);\n rel = {\n Target: val.Target,\n TargetMode: 'Internal'\n };\n }\n val.Rel = rel;\n if (val.tooltip) {\n val.Tooltip = val.tooltip;\n delete val.tooltip;\n }\n var rng = safe_decode_range(val.ref);\n for (var R = rng.s.r; R <= rng.e.r; ++R) for (var C = rng.s.c; C <= rng.e.c; ++C) {\n var addr = encode_cell({\n c: C,\n r: R\n });\n if (dense) {\n if (!s[R]) s[R] = [];\n if (!s[R][C]) s[R][C] = {\n t: \"z\",\n v: undefined\n };\n s[R][C].l = val;\n } else {\n if (!s[addr]) s[addr] = {\n t: \"z\",\n v: undefined\n };\n s[addr].l = val;\n }\n }\n }\n}\nfunction parse_ws_xml_margins(margin) {\n var o = {};\n [\"left\", \"right\", \"top\", \"bottom\", \"header\", \"footer\"].forEach(function (k) {\n if (margin[k]) o[k] = parseFloat(margin[k]);\n });\n return o;\n}\nfunction write_ws_xml_margins(margin) /*:string*/{\n default_margins(margin);\n return writextag('pageMargins', null, margin);\n}\nfunction parse_ws_xml_cols(columns, cols) {\n var seencol = false;\n for (var coli = 0; coli != cols.length; ++coli) {\n var coll = parsexmltag(cols[coli], true);\n if (coll.hidden) coll.hidden = parsexmlbool(coll.hidden);\n var colm = parseInt(coll.min, 10) - 1,\n colM = parseInt(coll.max, 10) - 1;\n if (coll.outlineLevel) coll.level = +coll.outlineLevel || 0;\n delete coll.min;\n delete coll.max;\n coll.width = +coll.width;\n if (!seencol && coll.width) {\n seencol = true;\n find_mdw_colw(coll.width);\n }\n process_col(coll);\n while (colm <= colM) columns[colm++] = dup(coll);\n }\n}\nfunction write_ws_xml_cols(ws, cols) /*:string*/{\n var o = [\"\"],\n col;\n for (var i = 0; i != cols.length; ++i) {\n if (!(col = cols[i])) continue;\n o[o.length] = writextag('col', null, col_obj_w(i, col));\n }\n o[o.length] = \"\";\n return o.join(\"\");\n}\nfunction parse_ws_xml_autofilter(data /*:string*/) {\n var o = {\n ref: (data.match(/ref=\"([^\"]*)\"/) || [])[1]\n };\n return o;\n}\nfunction write_ws_xml_autofilter(data, ws, wb, idx) /*:string*/{\n var ref = typeof data.ref == \"string\" ? data.ref : encode_range(data.ref);\n if (!wb.Workbook) wb.Workbook = {\n Sheets: []\n } /*:any*/;\n if (!wb.Workbook.Names) wb.Workbook.Names = [];\n var names /*: Array */ = wb.Workbook.Names;\n var range = decode_range(ref);\n if (range.s.r == range.e.r) {\n range.e.r = decode_range(ws[\"!ref\"]).e.r;\n ref = encode_range(range);\n }\n for (var i = 0; i < names.length; ++i) {\n var name = names[i];\n if (name.Name != '_xlnm._FilterDatabase') continue;\n if (name.Sheet != idx) continue;\n name.Ref = \"'\" + wb.SheetNames[idx] + \"'!\" + ref;\n break;\n }\n if (i == names.length) names.push({\n Name: '_xlnm._FilterDatabase',\n Sheet: idx,\n Ref: \"'\" + wb.SheetNames[idx] + \"'!\" + ref\n });\n return writextag(\"autoFilter\", null, {\n ref: ref\n });\n}\n\n/* 18.3.1.88 sheetViews CT_SheetViews */\n/* 18.3.1.87 sheetView CT_SheetView */\nvar sviewregex = /<(?:\\w:)?sheetView(?:[^>a-z][^>]*)?\\/?>/;\nfunction parse_ws_xml_sheetviews(data, wb /*:WBWBProps*/) {\n if (!wb.Views) wb.Views = [{}];\n (data.match(sviewregex) || []).forEach(function (r /*:string*/, i /*:number*/) {\n var tag = parsexmltag(r);\n // $FlowIgnore\n if (!wb.Views[i]) wb.Views[i] = {};\n // $FlowIgnore\n if (+tag.zoomScale) wb.Views[i].zoom = +tag.zoomScale;\n // $FlowIgnore\n if (parsexmlbool(tag.rightToLeft)) wb.Views[i].RTL = true;\n });\n}\nfunction write_ws_xml_sheetviews(ws, opts, idx, wb) /*:string*/{\n var sview = {\n workbookViewId: \"0\"\n } /*:any*/;\n // $FlowIgnore\n if ((((wb || {}).Workbook || {}).Views || [])[0]) sview.rightToLeft = wb.Workbook.Views[0].RTL ? \"1\" : \"0\";\n return writextag(\"sheetViews\", writextag(\"sheetView\", null, sview), {});\n}\nfunction write_ws_xml_cell(cell /*:Cell*/, ref, ws, opts /*::, idx, wb*/) /*:string*/{\n if (cell.c) ws['!comments'].push([ref, cell.c]);\n if (cell.v === undefined && typeof cell.f !== \"string\" || cell.t === 'z' && !cell.f) return \"\";\n var vv = \"\";\n var oldt = cell.t,\n oldv = cell.v;\n if (cell.t !== \"z\") switch (cell.t) {\n case 'b':\n vv = cell.v ? \"1\" : \"0\";\n break;\n case 'n':\n vv = '' + cell.v;\n break;\n case 'e':\n vv = BErr[cell.v];\n break;\n case 'd':\n if (opts && opts.cellDates) vv = parseDate(cell.v, -1).toISOString();else {\n cell = dup(cell);\n cell.t = 'n';\n vv = '' + (cell.v = datenum(parseDate(cell.v)));\n }\n if (typeof cell.z === 'undefined') cell.z = table_fmt[14];\n break;\n default:\n vv = cell.v;\n break;\n }\n var v = writetag('v', escapexml(vv)),\n o = {\n r: ref\n } /*:any*/;\n /* TODO: cell style */\n var os = get_cell_style(opts.cellXfs, cell, opts);\n if (os !== 0) o.s = os;\n switch (cell.t) {\n case 'n':\n break;\n case 'd':\n o.t = \"d\";\n break;\n case 'b':\n o.t = \"b\";\n break;\n case 'e':\n o.t = \"e\";\n break;\n case 'z':\n break;\n default:\n if (cell.v == null) {\n delete cell.t;\n break;\n }\n if (cell.v.length > 32767) throw new Error(\"Text length must not exceed 32767 characters\");\n if (opts && opts.bookSST) {\n v = writetag('v', '' + get_sst_id(opts.Strings, cell.v, opts.revStrings));\n o.t = \"s\";\n break;\n }\n o.t = \"str\";\n break;\n }\n if (cell.t != oldt) {\n cell.t = oldt;\n cell.v = oldv;\n }\n if (typeof cell.f == \"string\" && cell.f) {\n var ff = cell.F && cell.F.slice(0, ref.length) == ref ? {\n t: \"array\",\n ref: cell.F\n } : null;\n v = writextag('f', escapexml(cell.f), ff) + (cell.v != null ? v : \"\");\n }\n if (cell.l) ws['!links'].push([ref, cell.l]);\n if (cell.D) o.cm = 1;\n return writextag('c', v, o);\n}\nvar parse_ws_xml_data = /*#__PURE__*/function () {\n var cellregex = /<(?:\\w+:)?c[ \\/>]/,\n rowregex = /<\\/(?:\\w+:)?row>/;\n var rregex = /r=[\"']([^\"']*)[\"']/,\n isregex = /<(?:\\w+:)?is>([\\S\\s]*?)<\\/(?:\\w+:)?is>/;\n var refregex = /ref=[\"']([^\"']*)[\"']/;\n var match_v = matchtag(\"v\"),\n match_f = matchtag(\"f\");\n return function parse_ws_xml_data(sdata /*:string*/, s, opts, guess /*:Range*/, themes, styles) {\n var ri = 0,\n x = \"\",\n cells /*:Array*/ = [],\n cref /*:?Array*/ = [],\n idx = 0,\n i = 0,\n cc = 0,\n d = \"\",\n p /*:any*/;\n var tag,\n tagr = 0,\n tagc = 0;\n var sstr, ftag;\n var fmtid = 0,\n fillid = 0;\n var do_format = Array.isArray(styles.CellXf),\n cf;\n var arrayf /*:Array<[Range, string]>*/ = [];\n var sharedf = [];\n var dense = Array.isArray(s);\n var rows /*:Array*/ = [],\n rowobj = {},\n rowrite = false;\n var sheetStubs = !!opts.sheetStubs;\n for (var marr = sdata.split(rowregex), mt = 0, marrlen = marr.length; mt != marrlen; ++mt) {\n x = marr[mt].trim();\n var xlen = x.length;\n if (xlen === 0) continue;\n\n /* 18.3.1.73 row CT_Row */\n var rstarti = 0;\n outa: for (ri = 0; ri < xlen; ++ri) switch (/*x.charCodeAt(ri)*/x[ri]) {\n case \">\" /*62*/:\n if (/*x.charCodeAt(ri-1) != 47*/x[ri - 1] != \"/\") {\n ++ri;\n break outa;\n }\n if (opts && opts.cellStyles) {\n // TODO: avoid duplication\n tag = parsexmltag(x.slice(rstarti, ri), true);\n tagr = tag.r != null ? parseInt(tag.r, 10) : tagr + 1;\n tagc = -1;\n if (opts.sheetRows && opts.sheetRows < tagr) continue;\n rowobj = {};\n rowrite = false;\n if (tag.ht) {\n rowrite = true;\n rowobj.hpt = parseFloat(tag.ht);\n rowobj.hpx = pt2px(rowobj.hpt);\n }\n if (tag.hidden == \"1\") {\n rowrite = true;\n rowobj.hidden = true;\n }\n if (tag.outlineLevel != null) {\n rowrite = true;\n rowobj.level = +tag.outlineLevel;\n }\n if (rowrite) rows[tagr - 1] = rowobj;\n }\n break;\n case \"<\" /*60*/:\n rstarti = ri;\n break;\n }\n if (rstarti >= ri) break;\n tag = parsexmltag(x.slice(rstarti, ri), true);\n tagr = tag.r != null ? parseInt(tag.r, 10) : tagr + 1;\n tagc = -1;\n if (opts.sheetRows && opts.sheetRows < tagr) continue;\n if (guess.s.r > tagr - 1) guess.s.r = tagr - 1;\n if (guess.e.r < tagr - 1) guess.e.r = tagr - 1;\n if (opts && opts.cellStyles) {\n rowobj = {};\n rowrite = false;\n if (tag.ht) {\n rowrite = true;\n rowobj.hpt = parseFloat(tag.ht);\n rowobj.hpx = pt2px(rowobj.hpt);\n }\n if (tag.hidden == \"1\") {\n rowrite = true;\n rowobj.hidden = true;\n }\n if (tag.outlineLevel != null) {\n rowrite = true;\n rowobj.level = +tag.outlineLevel;\n }\n if (rowrite) rows[tagr - 1] = rowobj;\n }\n\n /* 18.3.1.4 c CT_Cell */\n cells = x.slice(ri).split(cellregex);\n for (var rslice = 0; rslice != cells.length; ++rslice) if (cells[rslice].trim().charAt(0) != \"<\") break;\n cells = cells.slice(rslice);\n for (ri = 0; ri != cells.length; ++ri) {\n x = cells[ri].trim();\n if (x.length === 0) continue;\n cref = x.match(rregex);\n idx = ri;\n i = 0;\n cc = 0;\n x = \"\" : \"\") + x;\n if (cref != null && cref.length === 2) {\n idx = 0;\n d = cref[1];\n for (i = 0; i != d.length; ++i) {\n if ((cc = d.charCodeAt(i) - 64) < 1 || cc > 26) break;\n idx = 26 * idx + cc;\n }\n --idx;\n tagc = idx;\n } else ++tagc;\n for (i = 0; i != x.length; ++i) if (x.charCodeAt(i) === 62) break;\n ++i;\n tag = parsexmltag(x.slice(0, i), true);\n if (!tag.r) tag.r = encode_cell({\n r: tagr - 1,\n c: tagc\n });\n d = x.slice(i);\n p = {\n t: \"\"\n } /*:any*/;\n if ((cref = d.match(match_v)) != null && /*::cref != null && */cref[1] !== '') p.v = unescapexml(cref[1]);\n if (opts.cellFormula) {\n if ((cref = d.match(match_f)) != null && /*::cref != null && */cref[1] !== '') {\n /* TODO: match against XLSXFutureFunctions */\n p.f = unescapexml(utf8read(cref[1])).replace(/\\r\\n/g, \"\\n\");\n if (!opts.xlfn) p.f = _xlfn(p.f);\n if (/*::cref != null && cref[0] != null && */cref[0].indexOf('t=\"array\"') > -1) {\n p.F = (d.match(refregex) || [])[1];\n if (p.F.indexOf(\":\") > -1) arrayf.push([safe_decode_range(p.F), p.F]);\n } else if (/*::cref != null && cref[0] != null && */cref[0].indexOf('t=\"shared\"') > -1) {\n // TODO: parse formula\n ftag = parsexmltag(cref[0]);\n var ___f = unescapexml(utf8read(cref[1]));\n if (!opts.xlfn) ___f = _xlfn(___f);\n sharedf[parseInt(ftag.si, 10)] = [ftag, ___f, tag.r];\n }\n } else if (cref = d.match(/]*\\/>/)) {\n ftag = parsexmltag(cref[0]);\n if (sharedf[ftag.si]) p.f = shift_formula_xlsx(sharedf[ftag.si][1], sharedf[ftag.si][2] /*[0].ref*/, tag.r);\n }\n /* TODO: factor out contains logic */\n var _tag = decode_cell(tag.r);\n for (i = 0; i < arrayf.length; ++i) if (_tag.r >= arrayf[i][0].s.r && _tag.r <= arrayf[i][0].e.r) if (_tag.c >= arrayf[i][0].s.c && _tag.c <= arrayf[i][0].e.c) p.F = arrayf[i][1];\n }\n if (tag.t == null && p.v === undefined) {\n if (p.f || p.F) {\n p.v = 0;\n p.t = \"n\";\n } else if (!sheetStubs) continue;else p.t = \"z\";\n } else p.t = tag.t || \"n\";\n if (guess.s.c > tagc) guess.s.c = tagc;\n if (guess.e.c < tagc) guess.e.c = tagc;\n /* 18.18.11 t ST_CellType */\n switch (p.t) {\n case 'n':\n if (p.v == \"\" || p.v == null) {\n if (!sheetStubs) continue;\n p.t = 'z';\n } else p.v = parseFloat(p.v);\n break;\n case 's':\n if (typeof p.v == 'undefined') {\n if (!sheetStubs) continue;\n p.t = 'z';\n } else {\n sstr = strs[parseInt(p.v, 10)];\n p.v = sstr.t;\n p.r = sstr.r;\n if (opts.cellHTML) p.h = sstr.h;\n }\n break;\n case 'str':\n p.t = \"s\";\n p.v = p.v != null ? utf8read(p.v) : '';\n if (opts.cellHTML) p.h = escapehtml(p.v);\n break;\n case 'inlineStr':\n cref = d.match(isregex);\n p.t = 's';\n if (cref != null && (sstr = parse_si(cref[1]))) {\n p.v = sstr.t;\n if (opts.cellHTML) p.h = sstr.h;\n } else p.v = \"\";\n break;\n case 'b':\n p.v = parsexmlbool(p.v);\n break;\n case 'd':\n if (opts.cellDates) p.v = parseDate(p.v, 1);else {\n p.v = datenum(parseDate(p.v, 1));\n p.t = 'n';\n }\n break;\n /* error string in .w, number in .v */\n case 'e':\n if (!opts || opts.cellText !== false) p.w = p.v;\n p.v = RBErr[p.v];\n break;\n }\n /* formatting */\n fmtid = fillid = 0;\n cf = null;\n if (do_format && tag.s !== undefined) {\n cf = styles.CellXf[tag.s];\n if (cf != null) {\n if (cf.numFmtId != null) fmtid = cf.numFmtId;\n if (opts.cellStyles) {\n if (cf.fillId != null) fillid = cf.fillId;\n }\n }\n }\n safe_format(p, fmtid, fillid, opts, themes, styles);\n if (opts.cellDates && do_format && p.t == 'n' && fmt_is_date(table_fmt[fmtid])) {\n p.t = 'd';\n p.v = numdate(p.v);\n }\n if (tag.cm && opts.xlmeta) {\n var cm = (opts.xlmeta.Cell || [])[+tag.cm - 1];\n if (cm && cm.type == 'XLDAPR') p.D = true;\n }\n if (dense) {\n var _r = decode_cell(tag.r);\n if (!s[_r.r]) s[_r.r] = [];\n s[_r.r][_r.c] = p;\n } else s[tag.r] = p;\n }\n }\n if (rows.length > 0) s['!rows'] = rows;\n };\n}();\nfunction write_ws_xml_data(ws /*:Worksheet*/, opts, idx /*:number*/, wb /*:Workbook*/ /*::, rels*/) /*:string*/{\n var o /*:Array*/ = [],\n r /*:Array*/ = [],\n range = safe_decode_range(ws['!ref']),\n cell = \"\",\n ref,\n rr = \"\",\n cols /*:Array*/ = [],\n R = 0,\n C = 0,\n rows = ws['!rows'];\n var dense = Array.isArray(ws);\n var params = {\n r: rr\n } /*:any*/,\n row /*:RowInfo*/,\n height = -1;\n for (C = range.s.c; C <= range.e.c; ++C) cols[C] = encode_col(C);\n for (R = range.s.r; R <= range.e.r; ++R) {\n r = [];\n rr = encode_row(R);\n for (C = range.s.c; C <= range.e.c; ++C) {\n ref = cols[C] + rr;\n var _cell = dense ? (ws[R] || [])[C] : ws[ref];\n if (_cell === undefined) continue;\n if ((cell = write_ws_xml_cell(_cell, ref, ws, opts, idx, wb)) != null) r.push(cell);\n }\n if (r.length > 0 || rows && rows[R]) {\n params = {\n r: rr\n } /*:any*/;\n if (rows && rows[R]) {\n row = rows[R];\n if (row.hidden) params.hidden = 1;\n height = -1;\n if (row.hpx) height = px2pt(row.hpx);else if (row.hpt) height = row.hpt;\n if (height > -1) {\n params.ht = height;\n params.customHeight = 1;\n }\n if (row.level) {\n params.outlineLevel = row.level;\n }\n }\n o[o.length] = writextag('row', r.join(\"\"), params);\n }\n }\n if (rows) for (; R < rows.length; ++R) {\n if (rows && rows[R]) {\n params = {\n r: R + 1\n } /*:any*/;\n row = rows[R];\n if (row.hidden) params.hidden = 1;\n height = -1;\n if (row.hpx) height = px2pt(row.hpx);else if (row.hpt) height = row.hpt;\n if (height > -1) {\n params.ht = height;\n params.customHeight = 1;\n }\n if (row.level) {\n params.outlineLevel = row.level;\n }\n o[o.length] = writextag('row', \"\", params);\n }\n }\n return o.join(\"\");\n}\nfunction write_ws_xml(idx /*:number*/, opts, wb /*:Workbook*/, rels) /*:string*/{\n var o = [XML_HEADER, writextag('worksheet', null, {\n 'xmlns': XMLNS_main[0],\n 'xmlns:r': XMLNS.r\n })];\n var s = wb.SheetNames[idx],\n sidx = 0,\n rdata = \"\";\n var ws = wb.Sheets[s];\n if (ws == null) ws = {};\n var ref = ws['!ref'] || 'A1';\n var range = safe_decode_range(ref);\n if (range.e.c > 0x3FFF || range.e.r > 0xFFFFF) {\n if (opts.WTF) throw new Error(\"Range \" + ref + \" exceeds format limit A1:XFD1048576\");\n range.e.c = Math.min(range.e.c, 0x3FFF);\n range.e.r = Math.min(range.e.c, 0xFFFFF);\n ref = encode_range(range);\n }\n if (!rels) rels = {};\n ws['!comments'] = [];\n var _drawing = [];\n write_ws_xml_sheetpr(ws, wb, idx, opts, o);\n o[o.length] = writextag('dimension', null, {\n 'ref': ref\n });\n o[o.length] = write_ws_xml_sheetviews(ws, opts, idx, wb);\n\n /* TODO: store in WB, process styles */\n if (opts.sheetFormat) o[o.length] = writextag('sheetFormatPr', null, {\n defaultRowHeight: opts.sheetFormat.defaultRowHeight || '16',\n baseColWidth: opts.sheetFormat.baseColWidth || '10',\n outlineLevelRow: opts.sheetFormat.outlineLevelRow || '7'\n });\n if (ws['!cols'] != null && ws['!cols'].length > 0) o[o.length] = write_ws_xml_cols(ws, ws['!cols']);\n o[sidx = o.length] = '';\n ws['!links'] = [];\n if (ws['!ref'] != null) {\n rdata = write_ws_xml_data(ws, opts, idx, wb, rels);\n if (rdata.length > 0) o[o.length] = rdata;\n }\n if (o.length > sidx + 1) {\n o[o.length] = '';\n o[sidx] = o[sidx].replace(\"/>\", \">\");\n }\n\n /* sheetCalcPr */\n\n if (ws['!protect']) o[o.length] = write_ws_xml_protection(ws['!protect']);\n\n /* protectedRanges */\n /* scenarios */\n\n if (ws['!autofilter'] != null) o[o.length] = write_ws_xml_autofilter(ws['!autofilter'], ws, wb, idx);\n\n /* sortState */\n /* dataConsolidate */\n /* customSheetViews */\n\n if (ws['!merges'] != null && ws['!merges'].length > 0) o[o.length] = write_ws_xml_merges(ws['!merges']);\n\n /* phoneticPr */\n /* conditionalFormatting */\n /* dataValidations */\n\n var relc = -1,\n rel,\n rId = -1;\n if (/*::(*/ws['!links'] /*::||[])*/.length > 0) {\n o[o.length] = \"\";\n /*::(*/\n ws['!links'] /*::||[])*/.forEach(function (l) {\n if (!l[1].Target) return;\n rel = {\n \"ref\": l[0]\n } /*:any*/;\n if (l[1].Target.charAt(0) != \"#\") {\n rId = add_rels(rels, -1, escapexml(l[1].Target).replace(/#.*$/, \"\"), RELS.HLINK);\n rel[\"r:id\"] = \"rId\" + rId;\n }\n if ((relc = l[1].Target.indexOf(\"#\")) > -1) rel.location = escapexml(l[1].Target.slice(relc + 1));\n if (l[1].Tooltip) rel.tooltip = escapexml(l[1].Tooltip);\n o[o.length] = writextag(\"hyperlink\", null, rel);\n });\n o[o.length] = \"\";\n }\n delete ws['!links'];\n\n /* printOptions */\n\n if (ws['!margins'] != null) o[o.length] = write_ws_xml_margins(ws['!margins']);\n\n /* pageSetup */\n /* headerFooter */\n /* rowBreaks */\n /* colBreaks */\n /* customProperties */\n /* cellWatches */\n\n if (!opts || opts.ignoreEC || opts.ignoreEC == void 0) o[o.length] = writetag(\"ignoredErrors\", writextag(\"ignoredError\", null, {\n numberStoredAsText: 1,\n sqref: ref\n }));\n\n /* smartTags */\n\n if (_drawing.length > 0) {\n rId = add_rels(rels, -1, \"../drawings/drawing\" + (idx + 1) + \".xml\", RELS.DRAW);\n o[o.length] = writextag(\"drawing\", null, {\n \"r:id\": \"rId\" + rId\n });\n ws['!drawing'] = _drawing;\n }\n if (ws['!comments'].length > 0) {\n rId = add_rels(rels, -1, \"../drawings/vmlDrawing\" + (idx + 1) + \".vml\", RELS.VML);\n o[o.length] = writextag(\"legacyDrawing\", null, {\n \"r:id\": \"rId\" + rId\n });\n ws['!legacy'] = rId;\n }\n\n /* legacyDrawingHF */\n /* picture */\n /* oleObjects */\n /* controls */\n /* webPublishItems */\n /* tableParts */\n /* extLst */\n\n if (o.length > 1) {\n o[o.length] = '';\n o[1] = o[1].replace(\"/>\", \">\");\n }\n return o.join(\"\");\n}\n\n/* [MS-XLSB] 2.4.726 BrtRowHdr */\nfunction parse_BrtRowHdr(data, length) {\n var z = {} /*:any*/;\n var tgt = data.l + length;\n z.r = data.read_shift(4);\n data.l += 4; // TODO: ixfe\n var miyRw = data.read_shift(2);\n data.l += 1; // TODO: top/bot padding\n var flags = data.read_shift(1);\n data.l = tgt;\n if (flags & 0x07) z.level = flags & 0x07;\n if (flags & 0x10) z.hidden = true;\n if (flags & 0x20) z.hpt = miyRw / 20;\n return z;\n}\nfunction write_BrtRowHdr(R /*:number*/, range, ws) {\n var o = new_buf(17 + 8 * 16);\n var row = (ws['!rows'] || [])[R] || {};\n o.write_shift(4, R);\n o.write_shift(4, 0); /* TODO: ixfe */\n\n var miyRw = 0x0140;\n if (row.hpx) miyRw = px2pt(row.hpx) * 20;else if (row.hpt) miyRw = row.hpt * 20;\n o.write_shift(2, miyRw);\n o.write_shift(1, 0); /* top/bot padding */\n\n var flags = 0x0;\n if (row.level) flags |= row.level;\n if (row.hidden) flags |= 0x10;\n if (row.hpx || row.hpt) flags |= 0x20;\n o.write_shift(1, flags);\n o.write_shift(1, 0); /* phonetic guide */\n\n /* [MS-XLSB] 2.5.8 BrtColSpan explains the mechanism */\n var ncolspan = 0,\n lcs = o.l;\n o.l += 4;\n var caddr = {\n r: R,\n c: 0\n };\n for (var i = 0; i < 16; ++i) {\n if (range.s.c > i + 1 << 10 || range.e.c < i << 10) continue;\n var first = -1,\n last = -1;\n for (var j = i << 10; j < i + 1 << 10; ++j) {\n caddr.c = j;\n var cell = Array.isArray(ws) ? (ws[caddr.r] || [])[caddr.c] : ws[encode_cell(caddr)];\n if (cell) {\n if (first < 0) first = j;\n last = j;\n }\n }\n if (first < 0) continue;\n ++ncolspan;\n o.write_shift(4, first);\n o.write_shift(4, last);\n }\n var l = o.l;\n o.l = lcs;\n o.write_shift(4, ncolspan);\n o.l = l;\n return o.length > o.l ? o.slice(0, o.l) : o;\n}\nfunction write_row_header(ba, ws, range, R) {\n var o = write_BrtRowHdr(R, range, ws);\n if (o.length > 17 || (ws['!rows'] || [])[R]) write_record(ba, 0x0000 /* BrtRowHdr */, o);\n}\n\n/* [MS-XLSB] 2.4.820 BrtWsDim */\nvar parse_BrtWsDim = parse_UncheckedRfX;\nvar write_BrtWsDim = write_UncheckedRfX;\n\n/* [MS-XLSB] 2.4.821 BrtWsFmtInfo */\nfunction parse_BrtWsFmtInfo(/*::data, length*/\n) {}\n//function write_BrtWsFmtInfo(ws, o) { }\n\n/* [MS-XLSB] 2.4.823 BrtWsProp */\nfunction parse_BrtWsProp(data, length) {\n var z = {};\n var f = data[data.l];\n ++data.l;\n z.above = !(f & 0x40);\n z.left = !(f & 0x80);\n /* TODO: pull flags */\n data.l += 18;\n z.name = parse_XLSBCodeName(data, length - 19);\n return z;\n}\nfunction write_BrtWsProp(str, outl, o) {\n if (o == null) o = new_buf(84 + 4 * str.length);\n var f = 0xC0;\n if (outl) {\n if (outl.above) f &= ~0x40;\n if (outl.left) f &= ~0x80;\n }\n o.write_shift(1, f);\n for (var i = 1; i < 3; ++i) o.write_shift(1, 0);\n write_BrtColor({\n auto: 1\n }, o);\n o.write_shift(-4, -1);\n o.write_shift(-4, -1);\n write_XLSBCodeName(str, o);\n return o.slice(0, o.l);\n}\n\n/* [MS-XLSB] 2.4.306 BrtCellBlank */\nfunction parse_BrtCellBlank(data) {\n var cell = parse_XLSBCell(data);\n return [cell];\n}\nfunction write_BrtCellBlank(cell, ncell, o) {\n if (o == null) o = new_buf(8);\n return write_XLSBCell(ncell, o);\n}\nfunction parse_BrtShortBlank(data) {\n var cell = parse_XLSBShortCell(data);\n return [cell];\n}\nfunction write_BrtShortBlank(cell, ncell, o) {\n if (o == null) o = new_buf(4);\n return write_XLSBShortCell(ncell, o);\n}\n\n/* [MS-XLSB] 2.4.307 BrtCellBool */\nfunction parse_BrtCellBool(data) {\n var cell = parse_XLSBCell(data);\n var fBool = data.read_shift(1);\n return [cell, fBool, 'b'];\n}\nfunction write_BrtCellBool(cell, ncell, o) {\n if (o == null) o = new_buf(9);\n write_XLSBCell(ncell, o);\n o.write_shift(1, cell.v ? 1 : 0);\n return o;\n}\nfunction parse_BrtShortBool(data) {\n var cell = parse_XLSBShortCell(data);\n var fBool = data.read_shift(1);\n return [cell, fBool, 'b'];\n}\nfunction write_BrtShortBool(cell, ncell, o) {\n if (o == null) o = new_buf(5);\n write_XLSBShortCell(ncell, o);\n o.write_shift(1, cell.v ? 1 : 0);\n return o;\n}\n\n/* [MS-XLSB] 2.4.308 BrtCellError */\nfunction parse_BrtCellError(data) {\n var cell = parse_XLSBCell(data);\n var bError = data.read_shift(1);\n return [cell, bError, 'e'];\n}\nfunction write_BrtCellError(cell, ncell, o) {\n if (o == null) o = new_buf(9);\n write_XLSBCell(ncell, o);\n o.write_shift(1, cell.v);\n return o;\n}\nfunction parse_BrtShortError(data) {\n var cell = parse_XLSBShortCell(data);\n var bError = data.read_shift(1);\n return [cell, bError, 'e'];\n}\nfunction write_BrtShortError(cell, ncell, o) {\n if (o == null) o = new_buf(8);\n write_XLSBShortCell(ncell, o);\n o.write_shift(1, cell.v);\n o.write_shift(2, 0);\n o.write_shift(1, 0);\n return o;\n}\n\n/* [MS-XLSB] 2.4.311 BrtCellIsst */\nfunction parse_BrtCellIsst(data) {\n var cell = parse_XLSBCell(data);\n var isst = data.read_shift(4);\n return [cell, isst, 's'];\n}\nfunction write_BrtCellIsst(cell, ncell, o) {\n if (o == null) o = new_buf(12);\n write_XLSBCell(ncell, o);\n o.write_shift(4, ncell.v);\n return o;\n}\nfunction parse_BrtShortIsst(data) {\n var cell = parse_XLSBShortCell(data);\n var isst = data.read_shift(4);\n return [cell, isst, 's'];\n}\nfunction write_BrtShortIsst(cell, ncell, o) {\n if (o == null) o = new_buf(8);\n write_XLSBShortCell(ncell, o);\n o.write_shift(4, ncell.v);\n return o;\n}\n\n/* [MS-XLSB] 2.4.313 BrtCellReal */\nfunction parse_BrtCellReal(data) {\n var cell = parse_XLSBCell(data);\n var value = parse_Xnum(data);\n return [cell, value, 'n'];\n}\nfunction write_BrtCellReal(cell, ncell, o) {\n if (o == null) o = new_buf(16);\n write_XLSBCell(ncell, o);\n write_Xnum(cell.v, o);\n return o;\n}\nfunction parse_BrtShortReal(data) {\n var cell = parse_XLSBShortCell(data);\n var value = parse_Xnum(data);\n return [cell, value, 'n'];\n}\nfunction write_BrtShortReal(cell, ncell, o) {\n if (o == null) o = new_buf(12);\n write_XLSBShortCell(ncell, o);\n write_Xnum(cell.v, o);\n return o;\n}\n\n/* [MS-XLSB] 2.4.314 BrtCellRk */\nfunction parse_BrtCellRk(data) {\n var cell = parse_XLSBCell(data);\n var value = parse_RkNumber(data);\n return [cell, value, 'n'];\n}\nfunction write_BrtCellRk(cell, ncell, o) {\n if (o == null) o = new_buf(12);\n write_XLSBCell(ncell, o);\n write_RkNumber(cell.v, o);\n return o;\n}\nfunction parse_BrtShortRk(data) {\n var cell = parse_XLSBShortCell(data);\n var value = parse_RkNumber(data);\n return [cell, value, 'n'];\n}\nfunction write_BrtShortRk(cell, ncell, o) {\n if (o == null) o = new_buf(8);\n write_XLSBShortCell(ncell, o);\n write_RkNumber(cell.v, o);\n return o;\n}\n\n/* [MS-XLSB] 2.4.323 BrtCellRString */\nfunction parse_BrtCellRString(data) {\n var cell = parse_XLSBCell(data);\n var value = parse_RichStr(data);\n return [cell, value, 'is'];\n}\n\n/* [MS-XLSB] 2.4.317 BrtCellSt */\nfunction parse_BrtCellSt(data) {\n var cell = parse_XLSBCell(data);\n var value = parse_XLWideString(data);\n return [cell, value, 'str'];\n}\nfunction write_BrtCellSt(cell, ncell, o) {\n if (o == null) o = new_buf(12 + 4 * cell.v.length);\n write_XLSBCell(ncell, o);\n write_XLWideString(cell.v, o);\n return o.length > o.l ? o.slice(0, o.l) : o;\n}\nfunction parse_BrtShortSt(data) {\n var cell = parse_XLSBShortCell(data);\n var value = parse_XLWideString(data);\n return [cell, value, 'str'];\n}\nfunction write_BrtShortSt(cell, ncell, o) {\n if (o == null) o = new_buf(8 + 4 * cell.v.length);\n write_XLSBShortCell(ncell, o);\n write_XLWideString(cell.v, o);\n return o.length > o.l ? o.slice(0, o.l) : o;\n}\n\n/* [MS-XLSB] 2.4.653 BrtFmlaBool */\nfunction parse_BrtFmlaBool(data, length, opts) {\n var end = data.l + length;\n var cell = parse_XLSBCell(data);\n cell.r = opts['!row'];\n var value = data.read_shift(1);\n var o = [cell, value, 'b'];\n if (opts.cellFormula) {\n data.l += 2;\n var formula = parse_XLSBCellParsedFormula(data, end - data.l, opts);\n o[3] = stringify_formula(formula, null /*range*/, cell, opts.supbooks, opts); /* TODO */\n } else data.l = end;\n return o;\n}\n\n/* [MS-XLSB] 2.4.654 BrtFmlaError */\nfunction parse_BrtFmlaError(data, length, opts) {\n var end = data.l + length;\n var cell = parse_XLSBCell(data);\n cell.r = opts['!row'];\n var value = data.read_shift(1);\n var o = [cell, value, 'e'];\n if (opts.cellFormula) {\n data.l += 2;\n var formula = parse_XLSBCellParsedFormula(data, end - data.l, opts);\n o[3] = stringify_formula(formula, null /*range*/, cell, opts.supbooks, opts); /* TODO */\n } else data.l = end;\n return o;\n}\n\n/* [MS-XLSB] 2.4.655 BrtFmlaNum */\nfunction parse_BrtFmlaNum(data, length, opts) {\n var end = data.l + length;\n var cell = parse_XLSBCell(data);\n cell.r = opts['!row'];\n var value = parse_Xnum(data);\n var o = [cell, value, 'n'];\n if (opts.cellFormula) {\n data.l += 2;\n var formula = parse_XLSBCellParsedFormula(data, end - data.l, opts);\n o[3] = stringify_formula(formula, null /*range*/, cell, opts.supbooks, opts); /* TODO */\n } else data.l = end;\n return o;\n}\n\n/* [MS-XLSB] 2.4.656 BrtFmlaString */\nfunction parse_BrtFmlaString(data, length, opts) {\n var end = data.l + length;\n var cell = parse_XLSBCell(data);\n cell.r = opts['!row'];\n var value = parse_XLWideString(data);\n var o = [cell, value, 'str'];\n if (opts.cellFormula) {\n data.l += 2;\n var formula = parse_XLSBCellParsedFormula(data, end - data.l, opts);\n o[3] = stringify_formula(formula, null /*range*/, cell, opts.supbooks, opts); /* TODO */\n } else data.l = end;\n return o;\n}\n\n/* [MS-XLSB] 2.4.682 BrtMergeCell */\nvar parse_BrtMergeCell = parse_UncheckedRfX;\nvar write_BrtMergeCell = write_UncheckedRfX;\n/* [MS-XLSB] 2.4.107 BrtBeginMergeCells */\nfunction write_BrtBeginMergeCells(cnt, o) {\n if (o == null) o = new_buf(4);\n o.write_shift(4, cnt);\n return o;\n}\n\n/* [MS-XLSB] 2.4.662 BrtHLink */\nfunction parse_BrtHLink(data, length /*::, opts*/) {\n var end = data.l + length;\n var rfx = parse_UncheckedRfX(data, 16);\n var relId = parse_XLNullableWideString(data);\n var loc = parse_XLWideString(data);\n var tooltip = parse_XLWideString(data);\n var display = parse_XLWideString(data);\n data.l = end;\n var o = {\n rfx: rfx,\n relId: relId,\n loc: loc,\n display: display\n } /*:any*/;\n if (tooltip) o.Tooltip = tooltip;\n return o;\n}\nfunction write_BrtHLink(l, rId) {\n var o = new_buf(50 + 4 * (l[1].Target.length + (l[1].Tooltip || \"\").length));\n write_UncheckedRfX({\n s: decode_cell(l[0]),\n e: decode_cell(l[0])\n }, o);\n write_RelID(\"rId\" + rId, o);\n var locidx = l[1].Target.indexOf(\"#\");\n var loc = locidx == -1 ? \"\" : l[1].Target.slice(locidx + 1);\n write_XLWideString(loc || \"\", o);\n write_XLWideString(l[1].Tooltip || \"\", o);\n write_XLWideString(\"\", o);\n return o.slice(0, o.l);\n}\n\n/* [MS-XLSB] 2.4.692 BrtPane */\nfunction parse_BrtPane(/*data, length, opts*/\n) {}\n\n/* [MS-XLSB] 2.4.6 BrtArrFmla */\nfunction parse_BrtArrFmla(data, length, opts) {\n var end = data.l + length;\n var rfx = parse_RfX(data, 16);\n var fAlwaysCalc = data.read_shift(1);\n var o = [rfx];\n o[2] = fAlwaysCalc;\n if (opts.cellFormula) {\n var formula = parse_XLSBArrayParsedFormula(data, end - data.l, opts);\n o[1] = formula;\n } else data.l = end;\n return o;\n}\n\n/* [MS-XLSB] 2.4.750 BrtShrFmla */\nfunction parse_BrtShrFmla(data, length, opts) {\n var end = data.l + length;\n var rfx = parse_UncheckedRfX(data, 16);\n var o = [rfx];\n if (opts.cellFormula) {\n var formula = parse_XLSBSharedParsedFormula(data, end - data.l, opts);\n o[1] = formula;\n data.l = end;\n } else data.l = end;\n return o;\n}\n\n/* [MS-XLSB] 2.4.323 BrtColInfo */\n/* TODO: once XLS ColInfo is set, combine the functions */\nfunction write_BrtColInfo(C /*:number*/, col, o) {\n if (o == null) o = new_buf(18);\n var p = col_obj_w(C, col);\n o.write_shift(-4, C);\n o.write_shift(-4, C);\n o.write_shift(4, (p.width || 10) * 256);\n o.write_shift(4, 0 /*ixfe*/); // style\n var flags = 0;\n if (col.hidden) flags |= 0x01;\n if (typeof p.width == 'number') flags |= 0x02;\n if (col.level) flags |= col.level << 8;\n o.write_shift(2, flags); // bit flag\n return o;\n}\n\n/* [MS-XLSB] 2.4.678 BrtMargins */\nvar BrtMarginKeys = [\"left\", \"right\", \"top\", \"bottom\", \"header\", \"footer\"];\nfunction parse_BrtMargins(data /*::, length, opts*/) /*:Margins*/{\n var margins = {} /*:any*/;\n BrtMarginKeys.forEach(function (k) {\n margins[k] = parse_Xnum(data, 8);\n });\n return margins;\n}\nfunction write_BrtMargins(margins /*:Margins*/, o) {\n if (o == null) o = new_buf(6 * 8);\n default_margins(margins);\n BrtMarginKeys.forEach(function (k) {\n write_Xnum(margins /*:any*/[k], o);\n });\n return o;\n}\n\n/* [MS-XLSB] 2.4.299 BrtBeginWsView */\nfunction parse_BrtBeginWsView(data /*::, length, opts*/) {\n var f = data.read_shift(2);\n data.l += 28;\n return {\n RTL: f & 0x20\n };\n}\nfunction write_BrtBeginWsView(ws, Workbook, o) {\n if (o == null) o = new_buf(30);\n var f = 0x39c;\n if ((((Workbook || {}).Views || [])[0] || {}).RTL) f |= 0x20;\n o.write_shift(2, f); // bit flag\n o.write_shift(4, 0);\n o.write_shift(4, 0); // view first row\n o.write_shift(4, 0); // view first col\n o.write_shift(1, 0); // gridline color ICV\n o.write_shift(1, 0);\n o.write_shift(2, 0);\n o.write_shift(2, 100); // zoom scale\n o.write_shift(2, 0);\n o.write_shift(2, 0);\n o.write_shift(2, 0);\n o.write_shift(4, 0); // workbook view id\n return o;\n}\n\n/* [MS-XLSB] 2.4.309 BrtCellIgnoreEC */\nfunction write_BrtCellIgnoreEC(ref) {\n var o = new_buf(24);\n o.write_shift(4, 4);\n o.write_shift(4, 1);\n write_UncheckedRfX(ref, o);\n return o;\n}\n\n/* [MS-XLSB] 2.4.748 BrtSheetProtection */\nfunction write_BrtSheetProtection(sp, o) {\n if (o == null) o = new_buf(16 * 4 + 2);\n o.write_shift(2, sp.password ? crypto_CreatePasswordVerifier_Method1(sp.password) : 0);\n o.write_shift(4, 1); // this record should not be written if no protection\n [[\"objects\", false],\n // fObjects\n [\"scenarios\", false],\n // fScenarios\n [\"formatCells\", true],\n // fFormatCells\n [\"formatColumns\", true],\n // fFormatColumns\n [\"formatRows\", true],\n // fFormatRows\n [\"insertColumns\", true],\n // fInsertColumns\n [\"insertRows\", true],\n // fInsertRows\n [\"insertHyperlinks\", true],\n // fInsertHyperlinks\n [\"deleteColumns\", true],\n // fDeleteColumns\n [\"deleteRows\", true],\n // fDeleteRows\n [\"selectLockedCells\", false],\n // fSelLockedCells\n [\"sort\", true],\n // fSort\n [\"autoFilter\", true],\n // fAutoFilter\n [\"pivotTables\", true],\n // fPivotTables\n [\"selectUnlockedCells\", false] // fSelUnlockedCells\n ].forEach(function (n) {\n /*:: if(o == null) throw \"unreachable\"; */\n if (n[1]) o.write_shift(4, sp[n[0]] != null && !sp[n[0]] ? 1 : 0);else o.write_shift(4, sp[n[0]] != null && sp[n[0]] ? 0 : 1);\n });\n return o;\n}\nfunction parse_BrtDVal(/*data, length, opts*/\n) {}\nfunction parse_BrtDVal14(/*data, length, opts*/\n) {}\n/* [MS-XLSB] 2.1.7.61 Worksheet */\nfunction parse_ws_bin(data, _opts, idx, rels, wb /*:WBWBProps*/, themes, styles) /*:Worksheet*/{\n if (!data) return data;\n var opts = _opts || {};\n if (!rels) rels = {\n '!id': {}\n };\n if (DENSE != null && opts.dense == null) opts.dense = DENSE;\n var s /*:Worksheet*/ = opts.dense ? [] : {};\n var ref;\n var refguess = {\n s: {\n r: 2000000,\n c: 2000000\n },\n e: {\n r: 0,\n c: 0\n }\n };\n var state /*:Array*/ = [];\n var pass = false,\n end = false;\n var row, p, cf, R, C, addr, sstr, rr, cell /*:Cell*/;\n var merges /*:Array*/ = [];\n opts.biff = 12;\n opts['!row'] = 0;\n var ai = 0,\n af = false;\n var arrayf /*:Array<[Range, string]>*/ = [];\n var sharedf = {};\n var supbooks = opts.supbooks || /*::(*/wb /*:: :any)*/.supbooks || [[]] /*:any*/;\n supbooks.sharedf = sharedf;\n supbooks.arrayf = arrayf;\n supbooks.SheetNames = wb.SheetNames || wb.Sheets.map(function (x) {\n return x.name;\n });\n if (!opts.supbooks) {\n opts.supbooks = supbooks;\n if (wb.Names) for (var i = 0; i < wb.Names.length; ++i) supbooks[0][i + 1] = wb.Names[i];\n }\n var colinfo /*:Array*/ = [],\n rowinfo /*:Array*/ = [];\n var seencol = false;\n XLSBRecordEnum[0x0010] = {\n n: \"BrtShortReal\",\n f: parse_BrtShortReal\n };\n var cm, vm;\n recordhopper(data, function ws_parse(val, RR, RT) {\n if (end) return;\n switch (RT) {\n case 0x0094:\n /* 'BrtWsDim' */\n ref = val;\n break;\n case 0x0000:\n /* 'BrtRowHdr' */\n row = val;\n if (opts.sheetRows && opts.sheetRows <= row.r) end = true;\n rr = encode_row(R = row.r);\n opts['!row'] = row.r;\n if (val.hidden || val.hpt || val.level != null) {\n if (val.hpt) val.hpx = pt2px(val.hpt);\n rowinfo[val.r] = val;\n }\n break;\n case 0x0002: /* 'BrtCellRk' */\n case 0x0003: /* 'BrtCellError' */\n case 0x0004: /* 'BrtCellBool' */\n case 0x0005: /* 'BrtCellReal' */\n case 0x0006: /* 'BrtCellSt' */\n case 0x0007: /* 'BrtCellIsst' */\n case 0x0008: /* 'BrtFmlaString' */\n case 0x0009: /* 'BrtFmlaNum' */\n case 0x000A: /* 'BrtFmlaBool' */\n case 0x000B: /* 'BrtFmlaError' */\n case 0x000D: /* 'BrtShortRk' */\n case 0x000E: /* 'BrtShortError' */\n case 0x000F: /* 'BrtShortBool' */\n case 0x0010: /* 'BrtShortReal' */\n case 0x0011: /* 'BrtShortSt' */\n case 0x0012: /* 'BrtShortIsst' */\n case 0x003E:\n /* 'BrtCellRString' */\n p = {\n t: val[2]\n } /*:any*/;\n switch (val[2]) {\n case 'n':\n p.v = val[1];\n break;\n case 's':\n sstr = strs[val[1]];\n p.v = sstr.t;\n p.r = sstr.r;\n break;\n case 'b':\n p.v = val[1] ? true : false;\n break;\n case 'e':\n p.v = val[1];\n if (opts.cellText !== false) p.w = BErr[p.v];\n break;\n case 'str':\n p.t = 's';\n p.v = val[1];\n break;\n case 'is':\n p.t = 's';\n p.v = val[1].t;\n break;\n }\n if (cf = styles.CellXf[val[0].iStyleRef]) safe_format(p, cf.numFmtId, null, opts, themes, styles);\n C = val[0].c == -1 ? C + 1 : val[0].c;\n if (opts.dense) {\n if (!s[R]) s[R] = [];\n s[R][C] = p;\n } else s[encode_col(C) + rr] = p;\n if (opts.cellFormula) {\n af = false;\n for (ai = 0; ai < arrayf.length; ++ai) {\n var aii = arrayf[ai];\n if (row.r >= aii[0].s.r && row.r <= aii[0].e.r) if (C >= aii[0].s.c && C <= aii[0].e.c) {\n p.F = encode_range(aii[0]);\n af = true;\n }\n }\n if (!af && val.length > 3) p.f = val[3];\n }\n if (refguess.s.r > row.r) refguess.s.r = row.r;\n if (refguess.s.c > C) refguess.s.c = C;\n if (refguess.e.r < row.r) refguess.e.r = row.r;\n if (refguess.e.c < C) refguess.e.c = C;\n if (opts.cellDates && cf && p.t == 'n' && fmt_is_date(table_fmt[cf.numFmtId])) {\n var _d = SSF_parse_date_code(p.v);\n if (_d) {\n p.t = 'd';\n p.v = new Date(_d.y, _d.m - 1, _d.d, _d.H, _d.M, _d.S, _d.u);\n }\n }\n if (cm) {\n if (cm.type == 'XLDAPR') p.D = true;\n cm = void 0;\n }\n if (vm) vm = void 0;\n break;\n case 0x0001: /* 'BrtCellBlank' */\n case 0x000C:\n /* 'BrtShortBlank' */\n if (!opts.sheetStubs || pass) break;\n p = {\n t: 'z',\n v: void 0\n } /*:any*/;\n C = val[0].c == -1 ? C + 1 : val[0].c;\n if (opts.dense) {\n if (!s[R]) s[R] = [];\n s[R][C] = p;\n } else s[encode_col(C) + rr] = p;\n if (refguess.s.r > row.r) refguess.s.r = row.r;\n if (refguess.s.c > C) refguess.s.c = C;\n if (refguess.e.r < row.r) refguess.e.r = row.r;\n if (refguess.e.c < C) refguess.e.c = C;\n if (cm) {\n if (cm.type == 'XLDAPR') p.D = true;\n cm = void 0;\n }\n if (vm) vm = void 0;\n break;\n case 0x00B0:\n /* 'BrtMergeCell' */\n merges.push(val);\n break;\n case 0x0031:\n {\n /* 'BrtCellMeta' */\n cm = ((opts.xlmeta || {}).Cell || [])[val - 1];\n }\n break;\n case 0x01EE:\n /* 'BrtHLink' */\n var rel = rels['!id'][val.relId];\n if (rel) {\n val.Target = rel.Target;\n if (val.loc) val.Target += \"#\" + val.loc;\n val.Rel = rel;\n } else if (val.relId == '') {\n val.Target = \"#\" + val.loc;\n }\n for (R = val.rfx.s.r; R <= val.rfx.e.r; ++R) for (C = val.rfx.s.c; C <= val.rfx.e.c; ++C) {\n if (opts.dense) {\n if (!s[R]) s[R] = [];\n if (!s[R][C]) s[R][C] = {\n t: 'z',\n v: undefined\n };\n s[R][C].l = val;\n } else {\n addr = encode_cell({\n c: C,\n r: R\n });\n if (!s[addr]) s[addr] = {\n t: 'z',\n v: undefined\n };\n s[addr].l = val;\n }\n }\n break;\n case 0x01AA:\n /* 'BrtArrFmla' */\n if (!opts.cellFormula) break;\n arrayf.push(val);\n cell = opts.dense ? s[R][C] : s[encode_col(C) + rr] /*:any*/;\n cell.f = stringify_formula(val[1], refguess, {\n r: row.r,\n c: C\n }, supbooks, opts);\n cell.F = encode_range(val[0]);\n break;\n case 0x01AB:\n /* 'BrtShrFmla' */\n if (!opts.cellFormula) break;\n sharedf[encode_cell(val[0].s)] = val[1];\n cell = opts.dense ? s[R][C] : s[encode_col(C) + rr];\n cell.f = stringify_formula(val[1], refguess, {\n r: row.r,\n c: C\n }, supbooks, opts);\n break;\n\n /* identical to 'ColInfo' in XLS */\n case 0x003C:\n /* 'BrtColInfo' */\n if (!opts.cellStyles) break;\n while (val.e >= val.s) {\n colinfo[val.e--] = {\n width: val.w / 256,\n hidden: !!(val.flags & 0x01),\n level: val.level\n };\n if (!seencol) {\n seencol = true;\n find_mdw_colw(val.w / 256);\n }\n process_col(colinfo[val.e + 1]);\n }\n break;\n case 0x00A1:\n /* 'BrtBeginAFilter' */\n s['!autofilter'] = {\n ref: encode_range(val)\n };\n break;\n case 0x01DC:\n /* 'BrtMargins' */\n s['!margins'] = val;\n break;\n case 0x0093:\n /* 'BrtWsProp' */\n if (!wb.Sheets[idx]) wb.Sheets[idx] = {};\n if (val.name) wb.Sheets[idx].CodeName = val.name;\n if (val.above || val.left) s['!outline'] = {\n above: val.above,\n left: val.left\n };\n break;\n case 0x0089:\n /* 'BrtBeginWsView' */\n if (!wb.Views) wb.Views = [{}];\n if (!wb.Views[0]) wb.Views[0] = {};\n if (val.RTL) wb.Views[0].RTL = true;\n break;\n case 0x01E5:\n /* 'BrtWsFmtInfo' */\n break;\n case 0x0040: /* 'BrtDVal' */\n case 0x041D:\n /* 'BrtDVal14' */\n break;\n case 0x0097:\n /* 'BrtPane' */\n break;\n case 0x0098: /* 'BrtSel' */\n case 0x00AF: /* 'BrtAFilterDateGroupItem' */\n case 0x0284: /* 'BrtActiveX' */\n case 0x0271: /* 'BrtBigName' */\n case 0x0232: /* 'BrtBkHim' */\n case 0x018C: /* 'BrtBrk' */\n case 0x0458: /* 'BrtCFIcon' */\n case 0x047A: /* 'BrtCFRuleExt' */\n case 0x01D7: /* 'BrtCFVO' */\n case 0x041A: /* 'BrtCFVO14' */\n case 0x0289: /* 'BrtCellIgnoreEC' */\n case 0x0451: /* 'BrtCellIgnoreEC14' */\n case 0x024D: /* 'BrtCellSmartTagProperty' */\n case 0x025F: /* 'BrtCellWatch' */\n case 0x0234: /* 'BrtColor' */\n case 0x041F: /* 'BrtColor14' */\n case 0x00A8: /* 'BrtColorFilter' */\n case 0x00AE: /* 'BrtCustomFilter' */\n case 0x049C: /* 'BrtCustomFilter14' */\n case 0x01F3: /* 'BrtDRef' */\n case 0x01FB: /* 'BrtDXF' */\n case 0x0226: /* 'BrtDrawing' */\n case 0x00AB: /* 'BrtDynamicFilter' */\n case 0x00A7: /* 'BrtFilter' */\n case 0x0499: /* 'BrtFilter14' */\n case 0x00A9: /* 'BrtIconFilter' */\n case 0x049D: /* 'BrtIconFilter14' */\n case 0x0227: /* 'BrtLegacyDrawing' */\n case 0x0228: /* 'BrtLegacyDrawingHF' */\n case 0x0295: /* 'BrtListPart' */\n case 0x027F: /* 'BrtOleObject' */\n case 0x01DE: /* 'BrtPageSetup' */\n case 0x0219: /* 'BrtPhoneticInfo' */\n case 0x01DD: /* 'BrtPrintOptions' */\n case 0x0218: /* 'BrtRangeProtection' */\n case 0x044F: /* 'BrtRangeProtection14' */\n case 0x02A8: /* 'BrtRangeProtectionIso' */\n case 0x0450: /* 'BrtRangeProtectionIso14' */\n case 0x0400: /* 'BrtRwDescent' */\n case 0x0297: /* 'BrtSheetCalcProp' */\n case 0x0217: /* 'BrtSheetProtection' */\n case 0x02A6: /* 'BrtSheetProtectionIso' */\n case 0x01F8: /* 'BrtSlc' */\n case 0x0413: /* 'BrtSparkline' */\n case 0x01AC: /* 'BrtTable' */\n case 0x00AA: /* 'BrtTop10Filter' */\n case 0x0C00: /* 'BrtUid' */\n case 0x0032: /* 'BrtValueMeta' */\n case 0x0816: /* 'BrtWebExtension' */\n case 0x0415:\n /* 'BrtWsFmtInfoEx14' */\n break;\n case 0x0023:\n /* 'BrtFRTBegin' */\n pass = true;\n break;\n case 0x0024:\n /* 'BrtFRTEnd' */\n pass = false;\n break;\n case 0x0025:\n /* 'BrtACBegin' */\n state.push(RT);\n pass = true;\n break;\n case 0x0026:\n /* 'BrtACEnd' */\n state.pop();\n pass = false;\n break;\n default:\n if (RR.T) {/* empty */} else if (!pass || opts.WTF) throw new Error(\"Unexpected record 0x\" + RT.toString(16));\n }\n }, opts);\n delete opts.supbooks;\n delete opts['!row'];\n if (!s[\"!ref\"] && (refguess.s.r < 2000000 || ref && (ref.e.r > 0 || ref.e.c > 0 || ref.s.r > 0 || ref.s.c > 0))) s[\"!ref\"] = encode_range(ref || refguess);\n if (opts.sheetRows && s[\"!ref\"]) {\n var tmpref = safe_decode_range(s[\"!ref\"]);\n if (opts.sheetRows <= +tmpref.e.r) {\n tmpref.e.r = opts.sheetRows - 1;\n if (tmpref.e.r > refguess.e.r) tmpref.e.r = refguess.e.r;\n if (tmpref.e.r < tmpref.s.r) tmpref.s.r = tmpref.e.r;\n if (tmpref.e.c > refguess.e.c) tmpref.e.c = refguess.e.c;\n if (tmpref.e.c < tmpref.s.c) tmpref.s.c = tmpref.e.c;\n s[\"!fullref\"] = s[\"!ref\"];\n s[\"!ref\"] = encode_range(tmpref);\n }\n }\n if (merges.length > 0) s[\"!merges\"] = merges;\n if (colinfo.length > 0) s[\"!cols\"] = colinfo;\n if (rowinfo.length > 0) s[\"!rows\"] = rowinfo;\n return s;\n}\n\n/* TODO: something useful -- this is a stub */\nfunction write_ws_bin_cell(ba /*:BufArray*/, cell /*:Cell*/, R /*:number*/, C /*:number*/, opts, ws /*:Worksheet*/, last_seen /*:boolean*/) /*:boolean*/{\n if (cell.v === undefined) return false;\n var vv = \"\";\n switch (cell.t) {\n case 'b':\n vv = cell.v ? \"1\" : \"0\";\n break;\n case 'd':\n // no BrtCellDate :(\n cell = dup(cell);\n cell.z = cell.z || table_fmt[14];\n cell.v = datenum(parseDate(cell.v));\n cell.t = 'n';\n break;\n /* falls through */\n case 'n':\n case 'e':\n vv = '' + cell.v;\n break;\n default:\n vv = cell.v;\n break;\n }\n var o /*:any*/ = {\n r: R,\n c: C\n } /*:any*/;\n /* TODO: cell style */\n o.s = get_cell_style(opts.cellXfs, cell, opts);\n if (cell.l) ws['!links'].push([encode_cell(o), cell.l]);\n if (cell.c) ws['!comments'].push([encode_cell(o), cell.c]);\n switch (cell.t) {\n case 's':\n case 'str':\n if (opts.bookSST) {\n vv = get_sst_id(opts.Strings, cell.v /*:any*/, opts.revStrings);\n o.t = \"s\";\n o.v = vv;\n if (last_seen) write_record(ba, 0x0012 /* BrtShortIsst */, write_BrtShortIsst(cell, o));else write_record(ba, 0x0007 /* BrtCellIsst */, write_BrtCellIsst(cell, o));\n } else {\n o.t = \"str\";\n if (last_seen) write_record(ba, 0x0011 /* BrtShortSt */, write_BrtShortSt(cell, o));else write_record(ba, 0x0006 /* BrtCellSt */, write_BrtCellSt(cell, o));\n }\n return true;\n case 'n':\n /* TODO: determine threshold for Real vs RK */\n if (cell.v == (cell.v | 0) && cell.v > -1000 && cell.v < 1000) {\n if (last_seen) write_record(ba, 0x000D /* BrtShortRk */, write_BrtShortRk(cell, o));else write_record(ba, 0x0002 /* BrtCellRk */, write_BrtCellRk(cell, o));\n } else {\n if (last_seen) write_record(ba, 0x0010 /* BrtShortReal */, write_BrtShortReal(cell, o));else write_record(ba, 0x0005 /* BrtCellReal */, write_BrtCellReal(cell, o));\n }\n return true;\n case 'b':\n o.t = \"b\";\n if (last_seen) write_record(ba, 0x000F /* BrtShortBool */, write_BrtShortBool(cell, o));else write_record(ba, 0x0004 /* BrtCellBool */, write_BrtCellBool(cell, o));\n return true;\n case 'e':\n o.t = \"e\";\n if (last_seen) write_record(ba, 0x000E /* BrtShortError */, write_BrtShortError(cell, o));else write_record(ba, 0x0003 /* BrtCellError */, write_BrtCellError(cell, o));\n return true;\n }\n if (last_seen) write_record(ba, 0x000C /* BrtShortBlank */, write_BrtShortBlank(cell, o));else write_record(ba, 0x0001 /* BrtCellBlank */, write_BrtCellBlank(cell, o));\n return true;\n}\nfunction write_CELLTABLE(ba, ws /*:Worksheet*/, idx /*:number*/, opts /*::, wb:Workbook*/) {\n var range = safe_decode_range(ws['!ref'] || \"A1\"),\n ref,\n rr = \"\",\n cols /*:Array*/ = [];\n write_record(ba, 0x0091 /* BrtBeginSheetData */);\n var dense = Array.isArray(ws);\n var cap = range.e.r;\n if (ws['!rows']) cap = Math.max(range.e.r, ws['!rows'].length - 1);\n for (var R = range.s.r; R <= cap; ++R) {\n rr = encode_row(R);\n /* [ACCELLTABLE] */\n /* BrtRowHdr */\n write_row_header(ba, ws, range, R);\n var last_seen = false;\n if (R <= range.e.r) for (var C = range.s.c; C <= range.e.c; ++C) {\n /* *16384CELL */\n if (R === range.s.r) cols[C] = encode_col(C);\n ref = cols[C] + rr;\n var cell = dense ? (ws[R] || [])[C] : ws[ref];\n if (!cell) {\n last_seen = false;\n continue;\n }\n /* write cell */\n last_seen = write_ws_bin_cell(ba, cell, R, C, opts, ws, last_seen);\n }\n }\n write_record(ba, 0x0092 /* BrtEndSheetData */);\n}\nfunction write_MERGECELLS(ba, ws /*:Worksheet*/) {\n if (!ws || !ws['!merges']) return;\n write_record(ba, 0x00B1 /* BrtBeginMergeCells */, write_BrtBeginMergeCells(ws['!merges'].length));\n ws['!merges'].forEach(function (m) {\n write_record(ba, 0x00B0 /* BrtMergeCell */, write_BrtMergeCell(m));\n });\n write_record(ba, 0x00B2 /* BrtEndMergeCells */);\n}\nfunction write_COLINFOS(ba, ws /*:Worksheet*/ /*::, idx:number, opts, wb:Workbook*/) {\n if (!ws || !ws['!cols']) return;\n write_record(ba, 0x0186 /* BrtBeginColInfos */);\n ws['!cols'].forEach(function (m, i) {\n if (m) write_record(ba, 0x003C /* 'BrtColInfo' */, write_BrtColInfo(i, m));\n });\n write_record(ba, 0x0187 /* BrtEndColInfos */);\n}\nfunction write_IGNOREECS(ba, ws /*:Worksheet*/) {\n if (!ws || !ws['!ref']) return;\n write_record(ba, 0x0288 /* BrtBeginCellIgnoreECs */);\n write_record(ba, 0x0289 /* BrtCellIgnoreEC */, write_BrtCellIgnoreEC(safe_decode_range(ws['!ref'])));\n write_record(ba, 0x028A /* BrtEndCellIgnoreECs */);\n}\nfunction write_HLINKS(ba, ws /*:Worksheet*/, rels) {\n /* *BrtHLink */\n ws['!links'].forEach(function (l) {\n if (!l[1].Target) return;\n var rId = add_rels(rels, -1, l[1].Target.replace(/#.*$/, \"\"), RELS.HLINK);\n write_record(ba, 0x01EE /* BrtHLink */, write_BrtHLink(l, rId));\n });\n delete ws['!links'];\n}\nfunction write_LEGACYDRAWING(ba, ws /*:Worksheet*/, idx /*:number*/, rels) {\n /* [BrtLegacyDrawing] */\n if (ws['!comments'].length > 0) {\n var rId = add_rels(rels, -1, \"../drawings/vmlDrawing\" + (idx + 1) + \".vml\", RELS.VML);\n write_record(ba, 0x0227 /* BrtLegacyDrawing */, write_RelID(\"rId\" + rId));\n ws['!legacy'] = rId;\n }\n}\nfunction write_AUTOFILTER(ba, ws, wb, idx) {\n if (!ws['!autofilter']) return;\n var data = ws['!autofilter'];\n var ref = typeof data.ref === \"string\" ? data.ref : encode_range(data.ref);\n\n /* Update FilterDatabase defined name for the worksheet */\n if (!wb.Workbook) wb.Workbook = {\n Sheets: []\n } /*:any*/;\n if (!wb.Workbook.Names) wb.Workbook.Names = [];\n var names /*: Array */ = wb.Workbook.Names;\n var range = decode_range(ref);\n if (range.s.r == range.e.r) {\n range.e.r = decode_range(ws[\"!ref\"]).e.r;\n ref = encode_range(range);\n }\n for (var i = 0; i < names.length; ++i) {\n var name = names[i];\n if (name.Name != '_xlnm._FilterDatabase') continue;\n if (name.Sheet != idx) continue;\n name.Ref = \"'\" + wb.SheetNames[idx] + \"'!\" + ref;\n break;\n }\n if (i == names.length) names.push({\n Name: '_xlnm._FilterDatabase',\n Sheet: idx,\n Ref: \"'\" + wb.SheetNames[idx] + \"'!\" + ref\n });\n write_record(ba, 0x00A1 /* BrtBeginAFilter */, write_UncheckedRfX(safe_decode_range(ref)));\n /* *FILTERCOLUMN */\n /* [SORTSTATE] */\n /* BrtEndAFilter */\n write_record(ba, 0x00A2 /* BrtEndAFilter */);\n}\nfunction write_WSVIEWS2(ba, ws, Workbook) {\n write_record(ba, 0x0085 /* BrtBeginWsViews */);\n {\n /* 1*WSVIEW2 */\n /* [ACUID] */\n write_record(ba, 0x0089 /* BrtBeginWsView */, write_BrtBeginWsView(ws, Workbook));\n /* [BrtPane] */\n /* *4BrtSel */\n /* *4SXSELECT */\n /* *FRT */\n write_record(ba, 0x008A /* BrtEndWsView */);\n }\n /* *FRT */\n write_record(ba, 0x0086 /* BrtEndWsViews */);\n}\nfunction write_WSFMTINFO(/*::ba, ws*/\n) {\n /* [ACWSFMTINFO] */\n // write_record(ba, 0x01E5 /* BrtWsFmtInfo */, write_BrtWsFmtInfo(ws));\n}\nfunction write_SHEETPROTECT(ba, ws) {\n if (!ws['!protect']) return;\n /* [BrtSheetProtectionIso] */\n write_record(ba, 0x0217 /* BrtSheetProtection */, write_BrtSheetProtection(ws['!protect']));\n}\nfunction write_ws_bin(idx /*:number*/, opts, wb /*:Workbook*/, rels) {\n var ba = buf_array();\n var s = wb.SheetNames[idx],\n ws = wb.Sheets[s] || {};\n var c /*:string*/ = s;\n try {\n if (wb && wb.Workbook) c = wb.Workbook.Sheets[idx].CodeName || c;\n } catch (e) {}\n var r = safe_decode_range(ws['!ref'] || \"A1\");\n if (r.e.c > 0x3FFF || r.e.r > 0xFFFFF) {\n if (opts.WTF) throw new Error(\"Range \" + (ws['!ref'] || \"A1\") + \" exceeds format limit A1:XFD1048576\");\n r.e.c = Math.min(r.e.c, 0x3FFF);\n r.e.r = Math.min(r.e.c, 0xFFFFF);\n }\n ws['!links'] = [];\n /* passed back to write_zip and removed there */\n ws['!comments'] = [];\n write_record(ba, 0x0081 /* BrtBeginSheet */);\n if (wb.vbaraw || ws['!outline']) write_record(ba, 0x0093 /* BrtWsProp */, write_BrtWsProp(c, ws['!outline']));\n write_record(ba, 0x0094 /* BrtWsDim */, write_BrtWsDim(r));\n write_WSVIEWS2(ba, ws, wb.Workbook);\n write_WSFMTINFO(ba, ws);\n write_COLINFOS(ba, ws, idx, opts, wb);\n write_CELLTABLE(ba, ws, idx, opts, wb);\n /* [BrtSheetCalcProp] */\n write_SHEETPROTECT(ba, ws);\n /* *([BrtRangeProtectionIso] BrtRangeProtection) */\n /* [SCENMAN] */\n write_AUTOFILTER(ba, ws, wb, idx);\n /* [SORTSTATE] */\n /* [DCON] */\n /* [USERSHVIEWS] */\n write_MERGECELLS(ba, ws);\n /* [BrtPhoneticInfo] */\n /* *CONDITIONALFORMATTING */\n /* [DVALS] */\n write_HLINKS(ba, ws, rels);\n /* [BrtPrintOptions] */\n if (ws['!margins']) write_record(ba, 0x01DC /* BrtMargins */, write_BrtMargins(ws['!margins']));\n /* [BrtPageSetup] */\n /* [HEADERFOOTER] */\n /* [RWBRK] */\n /* [COLBRK] */\n /* *BrtBigName */\n /* [CELLWATCHES] */\n if (!opts || opts.ignoreEC || opts.ignoreEC == void 0) write_IGNOREECS(ba, ws);\n /* [SMARTTAGS] */\n /* [BrtDrawing] */\n write_LEGACYDRAWING(ba, ws, idx, rels);\n /* [BrtLegacyDrawingHF] */\n /* [BrtBkHim] */\n /* [OLEOBJECTS] */\n /* [ACTIVEXCONTROLS] */\n /* [WEBPUBITEMS] */\n /* [LISTPARTS] */\n /* FRTWORKSHEET */\n write_record(ba, 0x0082 /* BrtEndSheet */);\n return ba.end();\n}\nfunction parse_Cache(data /*:string*/) /*:[Array, string, ?string]*/{\n var col /*:Array*/ = [];\n var num = data.match(/^/);\n var f;\n\n /* 21.2.2.150 pt CT_NumVal */\n (data.match(/(.*?)<\\/c:pt>/mg) || []).forEach(function (pt) {\n var q = pt.match(/(.*)<\\/c:v><\\/c:pt>/);\n if (!q) return;\n col[+q[1]] = num ? +q[2] : q[2];\n });\n\n /* 21.2.2.71 formatCode CT_Xstring */\n var nf = unescapexml((data.match(/([\\s\\S]*?)<\\/c:formatCode>/) || [\"\", \"General\"])[1]);\n (data.match(/(.*?)<\\/c:f>/mg) || []).forEach(function (F) {\n f = F.replace(/<.*?>/g, \"\");\n });\n return [col, nf, f];\n}\n\n/* 21.2 DrawingML - Charts */\nfunction parse_chart(data /*:?string*/, name /*:string*/, opts, rels, wb, csheet) {\n var cs /*:Worksheet*/ = csheet || {\n \"!type\": \"chart\"\n } /*:any*/;\n if (!data) return csheet;\n /* 21.2.2.27 chart CT_Chart */\n\n var C = 0,\n R = 0,\n col = \"A\";\n var refguess = {\n s: {\n r: 2000000,\n c: 2000000\n },\n e: {\n r: 0,\n c: 0\n }\n };\n\n /* 21.2.2.120 numCache CT_NumData */\n (data.match(/[\\s\\S]*?<\\/c:numCache>/gm) || []).forEach(function (nc) {\n var cache = parse_Cache(nc);\n refguess.s.r = refguess.s.c = 0;\n refguess.e.c = C;\n col = encode_col(C);\n cache[0].forEach(function (n, i) {\n cs[col + encode_row(i)] = {\n t: 'n',\n v: n,\n z: cache[1]\n };\n R = i;\n });\n if (refguess.e.r < R) refguess.e.r = R;\n ++C;\n });\n if (C > 0) cs[\"!ref\"] = encode_range(refguess);\n return cs;\n}\n/* 18.3 Worksheets also covers Chartsheets */\nfunction parse_cs_xml(data /*:?string*/, opts, idx /*:number*/, rels, wb /*::, themes, styles*/) /*:Worksheet*/{\n if (!data) return data;\n /* 18.3.1.12 chartsheet CT_ChartSheet */\n if (!rels) rels = {\n '!id': {}\n };\n var s = {\n '!type': \"chart\",\n '!drawel': null,\n '!rel': \"\"\n } /*:any*/;\n var m;\n\n /* 18.3.1.83 sheetPr CT_ChartsheetPr */\n var sheetPr = data.match(sheetprregex);\n if (sheetPr) parse_ws_xml_sheetpr(sheetPr[0], s, wb, idx);\n\n /* 18.3.1.36 drawing CT_Drawing */\n if (m = data.match(/drawing r:id=\"(.*?)\"/)) s['!rel'] = m[1];\n if (rels['!id'][s['!rel']]) s['!drawel'] = rels['!id'][s['!rel']];\n return s;\n}\nfunction write_cs_xml(idx /*:number*/, opts, wb /*:Workbook*/, rels) /*:string*/{\n var o = [XML_HEADER, writextag('chartsheet', null, {\n 'xmlns': XMLNS_main[0],\n 'xmlns:r': XMLNS.r\n })];\n o[o.length] = writextag(\"drawing\", null, {\n \"r:id\": \"rId1\"\n });\n add_rels(rels, -1, \"../drawings/drawing\" + (idx + 1) + \".xml\", RELS.DRAW);\n if (o.length > 2) {\n o[o.length] = '';\n o[1] = o[1].replace(\"/>\", \">\");\n }\n return o.join(\"\");\n}\n\n/* [MS-XLSB] 2.4.331 BrtCsProp */\nfunction parse_BrtCsProp(data, length /*:number*/) {\n data.l += 10;\n var name = parse_XLWideString(data, length - 10);\n return {\n name: name\n };\n}\n\n/* [MS-XLSB] 2.1.7.7 Chart Sheet */\nfunction parse_cs_bin(data, opts, idx /*:number*/, rels, wb /*::, themes, styles*/) /*:Worksheet*/{\n if (!data) return data;\n if (!rels) rels = {\n '!id': {}\n };\n var s = {\n '!type': \"chart\",\n '!drawel': null,\n '!rel': \"\"\n };\n var state /*:Array*/ = [];\n var pass = false;\n recordhopper(data, function cs_parse(val, R, RT) {\n switch (RT) {\n case 0x0226:\n /* 'BrtDrawing' */\n s['!rel'] = val;\n break;\n case 0x028B:\n /* 'BrtCsProp' */\n if (!wb.Sheets[idx]) wb.Sheets[idx] = {};\n if (val.name) wb.Sheets[idx].CodeName = val.name;\n break;\n case 0x0232: /* 'BrtBkHim' */\n case 0x028C: /* 'BrtCsPageSetup' */\n case 0x029D: /* 'BrtCsProtection' */\n case 0x02A7: /* 'BrtCsProtectionIso' */\n case 0x0227: /* 'BrtLegacyDrawing' */\n case 0x0228: /* 'BrtLegacyDrawingHF' */\n case 0x01DC: /* 'BrtMargins' */\n case 0x0C00:\n /* 'BrtUid' */\n break;\n case 0x0023:\n /* 'BrtFRTBegin' */\n pass = true;\n break;\n case 0x0024:\n /* 'BrtFRTEnd' */\n pass = false;\n break;\n case 0x0025:\n /* 'BrtACBegin' */\n state.push(RT);\n break;\n case 0x0026:\n /* 'BrtACEnd' */\n state.pop();\n break;\n default:\n if (R.T > 0) state.push(RT);else if (R.T < 0) state.pop();else if (!pass || opts.WTF) throw new Error(\"Unexpected record 0x\" + RT.toString(16));\n }\n }, opts);\n if (rels['!id'][s['!rel']]) s['!drawel'] = rels['!id'][s['!rel']];\n return s;\n}\nfunction write_cs_bin(/*::idx:number, opts, wb:Workbook, rels*/\n) {\n var ba = buf_array();\n write_record(ba, 0x0081 /* BrtBeginSheet */);\n /* [BrtCsProp] */\n /* CSVIEWS */\n /* [[BrtCsProtectionIso] BrtCsProtection] */\n /* [USERCSVIEWS] */\n /* [BrtMargins] */\n /* [BrtCsPageSetup] */\n /* [HEADERFOOTER] */\n /* BrtDrawing */\n /* [BrtLegacyDrawing] */\n /* [BrtLegacyDrawingHF] */\n /* [BrtBkHim] */\n /* [WEBPUBITEMS] */\n /* FRTCHARTSHEET */\n write_record(ba, 0x0082 /* BrtEndSheet */);\n return ba.end();\n}\n/* 18.2.28 (CT_WorkbookProtection) Defaults */\nvar WBPropsDef = [['allowRefreshQuery', false, \"bool\"], ['autoCompressPictures', true, \"bool\"], ['backupFile', false, \"bool\"], ['checkCompatibility', false, \"bool\"], ['CodeName', ''], ['date1904', false, \"bool\"], ['defaultThemeVersion', 0, \"int\"], ['filterPrivacy', false, \"bool\"], ['hidePivotFieldList', false, \"bool\"], ['promptedSolutions', false, \"bool\"], ['publishItems', false, \"bool\"], ['refreshAllConnections', false, \"bool\"], ['saveExternalLinkValues', true, \"bool\"], ['showBorderUnselectedTables', true, \"bool\"], ['showInkAnnotation', true, \"bool\"], ['showObjects', 'all'], ['showPivotChartFilter', false, \"bool\"], ['updateLinks', 'userSet']];\n\n/* 18.2.30 (CT_BookView) Defaults */\nvar WBViewDef = [['activeTab', 0, \"int\"], ['autoFilterDateGrouping', true, \"bool\"], ['firstSheet', 0, \"int\"], ['minimized', false, \"bool\"], ['showHorizontalScroll', true, \"bool\"], ['showSheetTabs', true, \"bool\"], ['showVerticalScroll', true, \"bool\"], ['tabRatio', 600, \"int\"], ['visibility', 'visible']\n//window{Height,Width}, {x,y}Window\n];\n\n/* 18.2.19 (CT_Sheet) Defaults */\nvar SheetDef = [\n //['state', 'visible']\n];\n\n/* 18.2.2 (CT_CalcPr) Defaults */\nvar CalcPrDef = [['calcCompleted', 'true'], ['calcMode', 'auto'], ['calcOnSave', 'true'], ['concurrentCalc', 'true'], ['fullCalcOnLoad', 'false'], ['fullPrecision', 'true'], ['iterate', 'false'], ['iterateCount', '100'], ['iterateDelta', '0.001'], ['refMode', 'A1']];\n\n/* 18.2.3 (CT_CustomWorkbookView) Defaults */\n/*var CustomWBViewDef = [\n\t['autoUpdate', 'false'],\n\t['changesSavedWin', 'false'],\n\t['includeHiddenRowCol', 'true'],\n\t['includePrintSettings', 'true'],\n\t['maximized', 'false'],\n\t['minimized', 'false'],\n\t['onlySync', 'false'],\n\t['personalView', 'false'],\n\t['showComments', 'commIndicator'],\n\t['showFormulaBar', 'true'],\n\t['showHorizontalScroll', 'true'],\n\t['showObjects', 'all'],\n\t['showSheetTabs', 'true'],\n\t['showStatusbar', 'true'],\n\t['showVerticalScroll', 'true'],\n\t['tabRatio', '600'],\n\t['xWindow', '0'],\n\t['yWindow', '0']\n];*/\n\nfunction push_defaults_array(target, defaults) {\n for (var j = 0; j != target.length; ++j) {\n var w = target[j];\n for (var i = 0; i != defaults.length; ++i) {\n var z = defaults[i];\n if (w[z[0]] == null) w[z[0]] = z[1];else switch (z[2]) {\n case \"bool\":\n if (typeof w[z[0]] == \"string\") w[z[0]] = parsexmlbool(w[z[0]]);\n break;\n case \"int\":\n if (typeof w[z[0]] == \"string\") w[z[0]] = parseInt(w[z[0]], 10);\n break;\n }\n }\n }\n}\nfunction push_defaults(target, defaults) {\n for (var i = 0; i != defaults.length; ++i) {\n var z = defaults[i];\n if (target[z[0]] == null) target[z[0]] = z[1];else switch (z[2]) {\n case \"bool\":\n if (typeof target[z[0]] == \"string\") target[z[0]] = parsexmlbool(target[z[0]]);\n break;\n case \"int\":\n if (typeof target[z[0]] == \"string\") target[z[0]] = parseInt(target[z[0]], 10);\n break;\n }\n }\n}\nfunction parse_wb_defaults(wb) {\n push_defaults(wb.WBProps, WBPropsDef);\n push_defaults(wb.CalcPr, CalcPrDef);\n push_defaults_array(wb.WBView, WBViewDef);\n push_defaults_array(wb.Sheets, SheetDef);\n _ssfopts.date1904 = parsexmlbool(wb.WBProps.date1904);\n}\nfunction safe1904(wb /*:Workbook*/) /*:string*/{\n /* TODO: store date1904 somewhere else */\n if (!wb.Workbook) return \"false\";\n if (!wb.Workbook.WBProps) return \"false\";\n return parsexmlbool(wb.Workbook.WBProps.date1904) ? \"true\" : \"false\";\n}\nvar badchars = /*#__PURE__*/\"][*?\\/\\\\\".split(\"\");\nfunction check_ws_name(n /*:string*/, safe /*:?boolean*/) /*:boolean*/{\n if (n.length > 31) {\n if (safe) return false;\n throw new Error(\"Sheet names cannot exceed 31 chars\");\n }\n var _good = true;\n badchars.forEach(function (c) {\n if (n.indexOf(c) == -1) return;\n if (!safe) throw new Error(\"Sheet name cannot contain : \\\\ / ? * [ ]\");\n _good = false;\n });\n return _good;\n}\nfunction check_wb_names(N, S, codes) {\n N.forEach(function (n, i) {\n check_ws_name(n);\n for (var j = 0; j < i; ++j) if (n == N[j]) throw new Error(\"Duplicate Sheet Name: \" + n);\n if (codes) {\n var cn = S && S[i] && S[i].CodeName || n;\n if (cn.charCodeAt(0) == 95 && cn.length > 22) throw new Error(\"Bad Code Name: Worksheet\" + cn);\n }\n });\n}\nfunction check_wb(wb) {\n if (!wb || !wb.SheetNames || !wb.Sheets) throw new Error(\"Invalid Workbook\");\n if (!wb.SheetNames.length) throw new Error(\"Workbook is empty\");\n var Sheets = wb.Workbook && wb.Workbook.Sheets || [];\n check_wb_names(wb.SheetNames, Sheets, !!wb.vbaraw);\n for (var i = 0; i < wb.SheetNames.length; ++i) check_ws(wb.Sheets[wb.SheetNames[i]], wb.SheetNames[i], i);\n /* TODO: validate workbook */\n}\n/* 18.2 Workbook */\nvar wbnsregex = /<\\w+:workbook/;\nfunction parse_wb_xml(data, opts) /*:WorkbookFile*/{\n if (!data) throw new Error(\"Could not find file\");\n var wb = /*::(*/{\n AppVersion: {},\n WBProps: {},\n WBView: [],\n Sheets: [],\n CalcPr: {},\n Names: [],\n xmlns: \"\"\n } /*::)*/;\n var pass = false,\n xmlns = \"xmlns\";\n var dname = {},\n dnstart = 0;\n data.replace(tagregex, function xml_wb(x, idx) {\n var y /*:any*/ = parsexmltag(x);\n switch (strip_ns(y[0])) {\n case '':\n break;\n\n /* 18.2.13 fileVersion CT_FileVersion ? */\n case '':\n case '':\n break;\n\n /* 18.2.12 fileSharing CT_FileSharing ? */\n case '':\n break;\n\n /* 18.2.28 workbookPr CT_WorkbookPr ? */\n case '':\n WBPropsDef.forEach(function (w) {\n if (y[w[0]] == null) return;\n switch (w[2]) {\n case \"bool\":\n wb.WBProps[w[0]] = parsexmlbool(y[w[0]]);\n break;\n case \"int\":\n wb.WBProps[w[0]] = parseInt(y[w[0]], 10);\n break;\n default:\n wb.WBProps[w[0]] = y[w[0]];\n }\n });\n if (y.codeName) wb.WBProps.CodeName = utf8read(y.codeName);\n break;\n case '':\n break;\n\n /* 18.2.29 workbookProtection CT_WorkbookProtection ? */\n case '':\n break;\n\n /* 18.2.1 bookViews CT_BookViews ? */\n case '':\n case '':\n break;\n /* 18.2.30 workbookView CT_BookView + */\n case '':\n delete y[0];\n wb.WBView.push(y);\n break;\n case '':\n break;\n\n /* 18.2.20 sheets CT_Sheets 1 */\n case '':\n case '':\n break;\n // aggregate sheet\n /* 18.2.19 sheet CT_Sheet + */\n case '':\n break;\n\n /* 18.2.15 functionGroups CT_FunctionGroups ? */\n case '':\n break;\n /* 18.2.14 functionGroup CT_FunctionGroup + */\n case '':\n case '':\n break;\n /* 18.2.8 externalReference CT_ExternalReference + */\n case '':\n break;\n case '':\n case '':\n pass = false;\n break;\n /* 18.2.5 definedName CT_DefinedName + */\n case '':\n {\n dname.Ref = unescapexml(utf8read(data.slice(dnstart, idx)));\n wb.Names.push(dname);\n }\n break;\n case '':\n break;\n\n /* 18.2.2 calcPr CT_CalcPr ? */\n case '':\n delete y[0];\n wb.CalcPr = y;\n break;\n case '':\n break;\n\n /* 18.2.16 oleSize CT_OleSize ? (ref required) */\n case '':\n case '':\n case '':\n break;\n\n /* 18.2.18 pivotCaches CT_PivotCaches ? */\n case '':\n case '':\n case '':\n break;\n\n /* 18.2.23 smartTagTypes CT_SmartTagTypes ? */\n case '':\n case '':\n break;\n /* 18.2.22 smartTagType CT_SmartTagType ? */\n case '':\n break;\n\n /* 18.2.11 fileRecoveryPr CT_FileRecoveryPr ? */\n case '':\n break;\n\n /* 18.2.26 webPublishObjects CT_WebPublishObjects ? */\n case '':\n case '':\n break;\n /* 18.2.25 webPublishObject CT_WebPublishObject ? */\n case '':\n case '':\n case '':\n break;\n /* 18.2.7 ext CT_Extension + */\n case '':\n pass = false;\n break;\n\n /* Others */\n case '':\n pass = true;\n break;\n case '':\n pass = false;\n break;\n\n /* TODO */\n case ' 0;\n\n /* fileVersion */\n /* fileSharing */\n\n var workbookPr /*:any*/ = {\n codeName: \"ThisWorkbook\"\n } /*:any*/;\n if (wb.Workbook && wb.Workbook.WBProps) {\n WBPropsDef.forEach(function (x) {\n /*:: if(!wb.Workbook || !wb.Workbook.WBProps) throw \"unreachable\"; */\n if (wb.Workbook.WBProps[x[0]] /*:any*/ == null) return;\n if (wb.Workbook.WBProps[x[0]] /*:any*/ == x[1]) return;\n workbookPr[x[0]] = wb.Workbook.WBProps[x[0]] /*:any*/;\n });\n /*:: if(!wb.Workbook || !wb.Workbook.WBProps) throw \"unreachable\"; */\n if (wb.Workbook.WBProps.CodeName) {\n workbookPr.codeName = wb.Workbook.WBProps.CodeName;\n delete workbookPr.CodeName;\n }\n }\n o[o.length] = writextag('workbookPr', null, workbookPr);\n\n /* workbookProtection */\n\n var sheets = wb.Workbook && wb.Workbook.Sheets || [];\n var i = 0;\n\n /* bookViews only written if first worksheet is hidden */\n if (sheets && sheets[0] && !!sheets[0].Hidden) {\n o[o.length] = \"\";\n for (i = 0; i != wb.SheetNames.length; ++i) {\n if (!sheets[i]) break;\n if (!sheets[i].Hidden) break;\n }\n if (i == wb.SheetNames.length) i = 0;\n o[o.length] = '';\n o[o.length] = \"\";\n }\n o[o.length] = \"\";\n for (i = 0; i != wb.SheetNames.length; ++i) {\n var sht = {\n name: escapexml(wb.SheetNames[i].slice(0, 31))\n } /*:any*/;\n sht.sheetId = \"\" + (i + 1);\n sht[\"r:id\"] = \"rId\" + (i + 1);\n if (sheets[i]) switch (sheets[i].Hidden) {\n case 1:\n sht.state = \"hidden\";\n break;\n case 2:\n sht.state = \"veryHidden\";\n break;\n }\n o[o.length] = writextag('sheet', null, sht);\n }\n o[o.length] = \"\";\n\n /* functionGroups */\n /* externalReferences */\n\n if (write_names) {\n o[o.length] = \"\";\n if (wb.Workbook && wb.Workbook.Names) wb.Workbook.Names.forEach(function (n) {\n var d /*:any*/ = {\n name: n.Name\n };\n if (n.Comment) d.comment = n.Comment;\n if (n.Sheet != null) d.localSheetId = \"\" + n.Sheet;\n if (n.Hidden) d.hidden = \"1\";\n if (!n.Ref) return;\n o[o.length] = writextag('definedName', escapexml(n.Ref), d);\n });\n o[o.length] = \"\";\n }\n\n /* calcPr */\n /* oleSize */\n /* customWorkbookViews */\n /* pivotCaches */\n /* smartTagPr */\n /* smartTagTypes */\n /* webPublishing */\n /* fileRecoveryPr */\n /* webPublishObjects */\n /* extLst */\n\n if (o.length > 2) {\n o[o.length] = '';\n o[1] = o[1].replace(\"/>\", \">\");\n }\n return o.join(\"\");\n}\n/* [MS-XLSB] 2.4.304 BrtBundleSh */\nfunction parse_BrtBundleSh(data, length /*:number*/) {\n var z = {};\n z.Hidden = data.read_shift(4); //hsState ST_SheetState\n z.iTabID = data.read_shift(4);\n z.strRelID = parse_RelID(data, length - 8);\n z.name = parse_XLWideString(data);\n return z;\n}\nfunction write_BrtBundleSh(data, o) {\n if (!o) o = new_buf(127);\n o.write_shift(4, data.Hidden);\n o.write_shift(4, data.iTabID);\n write_RelID(data.strRelID, o);\n write_XLWideString(data.name.slice(0, 31), o);\n return o.length > o.l ? o.slice(0, o.l) : o;\n}\n\n/* [MS-XLSB] 2.4.815 BrtWbProp */\nfunction parse_BrtWbProp(data, length) /*:WBProps*/{\n var o /*:WBProps*/ = {} /*:any*/;\n var flags = data.read_shift(4);\n o.defaultThemeVersion = data.read_shift(4);\n var strName = length > 8 ? parse_XLWideString(data) : \"\";\n if (strName.length > 0) o.CodeName = strName;\n o.autoCompressPictures = !!(flags & 0x10000);\n o.backupFile = !!(flags & 0x40);\n o.checkCompatibility = !!(flags & 0x1000);\n o.date1904 = !!(flags & 0x01);\n o.filterPrivacy = !!(flags & 0x08);\n o.hidePivotFieldList = !!(flags & 0x400);\n o.promptedSolutions = !!(flags & 0x10);\n o.publishItems = !!(flags & 0x800);\n o.refreshAllConnections = !!(flags & 0x40000);\n o.saveExternalLinkValues = !!(flags & 0x80);\n o.showBorderUnselectedTables = !!(flags & 0x04);\n o.showInkAnnotation = !!(flags & 0x20);\n o.showObjects = [\"all\", \"placeholders\", \"none\"][flags >> 13 & 0x03];\n o.showPivotChartFilter = !!(flags & 0x8000);\n o.updateLinks = [\"userSet\", \"never\", \"always\"][flags >> 8 & 0x03];\n return o;\n}\nfunction write_BrtWbProp(data /*:?WBProps*/, o) {\n if (!o) o = new_buf(72);\n var flags = 0;\n if (data) {\n /* TODO: mirror parse_BrtWbProp fields */\n if (data.filterPrivacy) flags |= 0x08;\n }\n o.write_shift(4, flags);\n o.write_shift(4, 0);\n write_XLSBCodeName(data && data.CodeName || \"ThisWorkbook\", o);\n return o.slice(0, o.l);\n}\nfunction parse_BrtFRTArchID$(data, length) {\n var o = {};\n data.read_shift(4);\n o.ArchID = data.read_shift(4);\n data.l += length - 8;\n return o;\n}\n\n/* [MS-XLSB] 2.4.687 BrtName */\nfunction parse_BrtName(data, length, opts) {\n var end = data.l + length;\n data.l += 4; //var flags = data.read_shift(4);\n data.l += 1; //var chKey = data.read_shift(1);\n var itab = data.read_shift(4);\n var name = parse_XLNameWideString(data);\n var formula = parse_XLSBNameParsedFormula(data, 0, opts);\n var comment = parse_XLNullableWideString(data);\n //if(0 /* fProc */) {\n // unusedstring1: XLNullableWideString\n // description: XLNullableWideString\n // helpTopic: XLNullableWideString\n // unusedstring2: XLNullableWideString\n //}\n data.l = end;\n var out = {\n Name: name,\n Ptg: formula\n } /*:any*/;\n if (itab < 0xFFFFFFF) out.Sheet = itab;\n if (comment) out.Comment = comment;\n return out;\n}\n\n/* [MS-XLSB] 2.1.7.61 Workbook */\nfunction parse_wb_bin(data, opts) /*:WorkbookFile*/{\n var wb = {\n AppVersion: {},\n WBProps: {},\n WBView: [],\n Sheets: [],\n CalcPr: {},\n xmlns: \"\"\n };\n var state /*:Array*/ = [];\n var pass = false;\n if (!opts) opts = {};\n opts.biff = 12;\n var Names = [];\n var supbooks = [[]] /*:any*/;\n supbooks.SheetNames = [];\n supbooks.XTI = [];\n XLSBRecordEnum[0x0010] = {\n n: \"BrtFRTArchID$\",\n f: parse_BrtFRTArchID$\n };\n recordhopper(data, function hopper_wb(val, R, RT) {\n switch (RT) {\n case 0x009C:\n /* 'BrtBundleSh' */\n supbooks.SheetNames.push(val.name);\n wb.Sheets.push(val);\n break;\n case 0x0099:\n /* 'BrtWbProp' */\n wb.WBProps = val;\n break;\n case 0x0027:\n /* 'BrtName' */\n if (val.Sheet != null) opts.SID = val.Sheet;\n val.Ref = stringify_formula(val.Ptg, null, null, supbooks, opts);\n delete opts.SID;\n delete val.Ptg;\n Names.push(val);\n break;\n case 0x040C:\n /* 'BrtNameExt' */break;\n case 0x0165: /* 'BrtSupSelf' */\n case 0x0166: /* 'BrtSupSame' */\n case 0x0163: /* 'BrtSupBookSrc' */\n case 0x029B:\n /* 'BrtSupAddin' */\n if (!supbooks[0].length) supbooks[0] = [RT, val];else supbooks.push([RT, val]);\n supbooks[supbooks.length - 1].XTI = [];\n break;\n case 0x016A:\n /* 'BrtExternSheet' */\n if (supbooks.length === 0) {\n supbooks[0] = [];\n supbooks[0].XTI = [];\n }\n supbooks[supbooks.length - 1].XTI = supbooks[supbooks.length - 1].XTI.concat(val);\n supbooks.XTI = supbooks.XTI.concat(val);\n break;\n case 0x0169:\n /* 'BrtPlaceholderName' */\n break;\n case 0x0817: /* 'BrtAbsPath15' */\n case 0x009E: /* 'BrtBookView' */\n case 0x008F: /* 'BrtBeginBundleShs' */\n case 0x0298: /* 'BrtBeginFnGroup' */\n case 0x0161:\n /* 'BrtBeginExternals' */\n break;\n\n /* case 'BrtModelTimeGroupingCalcCol' */\n case 0x0C00: /* 'BrtUid' */\n case 0x0C01: /* 'BrtRevisionPtr' */\n case 0x0216: /* 'BrtBookProtection' */\n case 0x02A5: /* 'BrtBookProtectionIso' */\n case 0x009D: /* 'BrtCalcProp' */\n case 0x0262: /* 'BrtCrashRecErr' */\n case 0x0802: /* 'BrtDecoupledPivotCacheID' */\n case 0x009B: /* 'BrtFileRecover' */\n case 0x0224: /* 'BrtFileSharing' */\n case 0x02A4: /* 'BrtFileSharingIso' */\n case 0x0080: /* 'BrtFileVersion' */\n case 0x0299: /* 'BrtFnGroup' */\n case 0x0850: /* 'BrtModelRelationship' */\n case 0x084D: /* 'BrtModelTable' */\n case 0x0225: /* 'BrtOleSize' */\n case 0x0805: /* 'BrtPivotTableRef' */\n case 0x0254: /* 'BrtSmartTagType' */\n case 0x081C: /* 'BrtTableSlicerCacheID' */\n case 0x081B: /* 'BrtTableSlicerCacheIDs' */\n case 0x0822: /* 'BrtTimelineCachePivotCacheID' */\n case 0x018D: /* 'BrtUserBookView' */\n case 0x009A: /* 'BrtWbFactoid' */\n case 0x045D: /* 'BrtWbProp14' */\n case 0x0229: /* 'BrtWebOpt' */\n case 0x082B:\n /* 'BrtWorkBookPr15' */\n break;\n case 0x0023:\n /* 'BrtFRTBegin' */\n state.push(RT);\n pass = true;\n break;\n case 0x0024:\n /* 'BrtFRTEnd' */\n state.pop();\n pass = false;\n break;\n case 0x0025:\n /* 'BrtACBegin' */\n state.push(RT);\n pass = true;\n break;\n case 0x0026:\n /* 'BrtACEnd' */\n state.pop();\n pass = false;\n break;\n case 0x0010:\n /* 'BrtFRTArchID$' */break;\n default:\n if (R.T) {/* empty */} else if (!pass || opts.WTF && state[state.length - 1] != 0x0025 /* BrtACBegin */ && state[state.length - 1] != 0x0023 /* BrtFRTBegin */) throw new Error(\"Unexpected record 0x\" + RT.toString(16));\n }\n }, opts);\n parse_wb_defaults(wb);\n\n // $FlowIgnore\n wb.Names = Names;\n wb /*:any*/.supbooks = supbooks;\n return wb;\n}\nfunction write_BUNDLESHS(ba, wb /*::, opts*/) {\n write_record(ba, 0x008F /* BrtBeginBundleShs */);\n for (var idx = 0; idx != wb.SheetNames.length; ++idx) {\n var viz = wb.Workbook && wb.Workbook.Sheets && wb.Workbook.Sheets[idx] && wb.Workbook.Sheets[idx].Hidden || 0;\n var d = {\n Hidden: viz,\n iTabID: idx + 1,\n strRelID: 'rId' + (idx + 1),\n name: wb.SheetNames[idx]\n };\n write_record(ba, 0x009C /* BrtBundleSh */, write_BrtBundleSh(d));\n }\n write_record(ba, 0x0090 /* BrtEndBundleShs */);\n}\n\n/* [MS-XLSB] 2.4.649 BrtFileVersion */\nfunction write_BrtFileVersion(data, o) {\n if (!o) o = new_buf(127);\n for (var i = 0; i != 4; ++i) o.write_shift(4, 0);\n write_XLWideString(\"SheetJS\", o);\n write_XLWideString(XLSX.version, o);\n write_XLWideString(XLSX.version, o);\n write_XLWideString(\"7262\", o);\n return o.length > o.l ? o.slice(0, o.l) : o;\n}\n\n/* [MS-XLSB] 2.4.301 BrtBookView */\nfunction write_BrtBookView(idx, o) {\n if (!o) o = new_buf(29);\n o.write_shift(-4, 0);\n o.write_shift(-4, 460);\n o.write_shift(4, 28800);\n o.write_shift(4, 17600);\n o.write_shift(4, 500);\n o.write_shift(4, idx);\n o.write_shift(4, idx);\n var flags = 0x78;\n o.write_shift(1, flags);\n return o.length > o.l ? o.slice(0, o.l) : o;\n}\nfunction write_BOOKVIEWS(ba, wb /*::, opts*/) {\n /* required if hidden tab appears before visible tab */\n if (!wb.Workbook || !wb.Workbook.Sheets) return;\n var sheets = wb.Workbook.Sheets;\n var i = 0,\n vistab = -1,\n hidden = -1;\n for (; i < sheets.length; ++i) {\n if (!sheets[i] || !sheets[i].Hidden && vistab == -1) vistab = i;else if (sheets[i].Hidden == 1 && hidden == -1) hidden = i;\n }\n if (hidden > vistab) return;\n write_record(ba, 0x0087 /* BrtBeginBookViews */);\n write_record(ba, 0x009E /* BrtBookView */, write_BrtBookView(vistab));\n /* 1*(BrtBookView *FRT) */\n write_record(ba, 0x0088 /* BrtEndBookViews */);\n}\n\n/* [MS-XLSB] 2.4.305 BrtCalcProp */\n/*function write_BrtCalcProp(data, o) {\n\tif(!o) o = new_buf(26);\n\to.write_shift(4,0); // force recalc\n\to.write_shift(4,1);\n\to.write_shift(4,0);\n\twrite_Xnum(0, o);\n\to.write_shift(-4, 1023);\n\to.write_shift(1, 0x33);\n\to.write_shift(1, 0x00);\n\treturn o;\n}*/\n\n/* [MS-XLSB] 2.4.646 BrtFileRecover */\n/*function write_BrtFileRecover(data, o) {\n\tif(!o) o = new_buf(1);\n\to.write_shift(1,0);\n\treturn o;\n}*/\n\n/* [MS-XLSB] 2.1.7.61 Workbook */\nfunction write_wb_bin(wb, opts) {\n var ba = buf_array();\n write_record(ba, 0x0083 /* BrtBeginBook */);\n write_record(ba, 0x0080 /* BrtFileVersion */, write_BrtFileVersion());\n /* [[BrtFileSharingIso] BrtFileSharing] */\n write_record(ba, 0x0099 /* BrtWbProp */, write_BrtWbProp(wb.Workbook && wb.Workbook.WBProps || null));\n /* [ACABSPATH] */\n /* [[BrtBookProtectionIso] BrtBookProtection] */\n write_BOOKVIEWS(ba, wb, opts);\n write_BUNDLESHS(ba, wb, opts);\n /* [FNGROUP] */\n /* [EXTERNALS] */\n /* *BrtName */\n /* write_record(ba, 0x009D BrtCalcProp, write_BrtCalcProp()); */\n /* [BrtOleSize] */\n /* *(BrtUserBookView *FRT) */\n /* [PIVOTCACHEIDS] */\n /* [BrtWbFactoid] */\n /* [SMARTTAGTYPES] */\n /* [BrtWebOpt] */\n /* write_record(ba, 0x009B BrtFileRecover, write_BrtFileRecover()); */\n /* [WEBPUBITEMS] */\n /* [CRERRS] */\n /* FRTWORKBOOK */\n write_record(ba, 0x0084 /* BrtEndBook */);\n return ba.end();\n}\nfunction parse_wb(data, name /*:string*/, opts) /*:WorkbookFile*/{\n if (name.slice(-4) === \".bin\") return parse_wb_bin(data /*:any*/, opts);\n return parse_wb_xml(data /*:any*/, opts);\n}\nfunction parse_ws(data, name /*:string*/, idx /*:number*/, opts, rels, wb, themes, styles) /*:Worksheet*/{\n if (name.slice(-4) === \".bin\") return parse_ws_bin(data /*:any*/, opts, idx, rels, wb, themes, styles);\n return parse_ws_xml(data /*:any*/, opts, idx, rels, wb, themes, styles);\n}\nfunction parse_cs(data, name /*:string*/, idx /*:number*/, opts, rels, wb, themes, styles) /*:Worksheet*/{\n if (name.slice(-4) === \".bin\") return parse_cs_bin(data /*:any*/, opts, idx, rels, wb, themes, styles);\n return parse_cs_xml(data /*:any*/, opts, idx, rels, wb, themes, styles);\n}\nfunction parse_ms(data, name /*:string*/, idx /*:number*/, opts, rels, wb, themes, styles) /*:Worksheet*/{\n if (name.slice(-4) === \".bin\") return parse_ms_bin(data /*:any*/, opts, idx, rels, wb, themes, styles);\n return parse_ms_xml(data /*:any*/, opts, idx, rels, wb, themes, styles);\n}\nfunction parse_ds(data, name /*:string*/, idx /*:number*/, opts, rels, wb, themes, styles) /*:Worksheet*/{\n if (name.slice(-4) === \".bin\") return parse_ds_bin(data /*:any*/, opts, idx, rels, wb, themes, styles);\n return parse_ds_xml(data /*:any*/, opts, idx, rels, wb, themes, styles);\n}\nfunction parse_sty(data, name /*:string*/, themes, opts) {\n if (name.slice(-4) === \".bin\") return parse_sty_bin(data /*:any*/, themes, opts);\n return parse_sty_xml(data /*:any*/, themes, opts);\n}\nfunction parse_theme(data /*:string*/, name /*:string*/, opts) {\n return parse_theme_xml(data, opts);\n}\nfunction parse_sst(data, name /*:string*/, opts) /*:SST*/{\n if (name.slice(-4) === \".bin\") return parse_sst_bin(data /*:any*/, opts);\n return parse_sst_xml(data /*:any*/, opts);\n}\nfunction parse_cmnt(data, name /*:string*/, opts) /*:Array*/{\n if (name.slice(-4) === \".bin\") return parse_comments_bin(data /*:any*/, opts);\n return parse_comments_xml(data /*:any*/, opts);\n}\nfunction parse_cc(data, name /*:string*/, opts) {\n if (name.slice(-4) === \".bin\") return parse_cc_bin(data /*:any*/, name, opts);\n return parse_cc_xml(data /*:any*/, name, opts);\n}\nfunction parse_xlink(data, rel, name /*:string*/, opts) {\n if (name.slice(-4) === \".bin\") return parse_xlink_bin(data /*:any*/, rel, name, opts);\n return parse_xlink_xml(data /*:any*/, rel, name, opts);\n}\nfunction parse_xlmeta(data, name /*:string*/, opts) {\n if (name.slice(-4) === \".bin\") return parse_xlmeta_bin(data /*:any*/, name, opts);\n return parse_xlmeta_xml(data /*:any*/, name, opts);\n}\nfunction write_wb(wb, name /*:string*/, opts) {\n return (name.slice(-4) === \".bin\" ? write_wb_bin : write_wb_xml)(wb, opts);\n}\nfunction write_ws(data /*:number*/, name /*:string*/, opts, wb /*:Workbook*/, rels) {\n return (name.slice(-4) === \".bin\" ? write_ws_bin : write_ws_xml)(data, opts, wb, rels);\n}\n\n// eslint-disable-next-line no-unused-vars\nfunction write_cs(data /*:number*/, name /*:string*/, opts, wb /*:Workbook*/, rels) {\n return (name.slice(-4) === \".bin\" ? write_cs_bin : write_cs_xml)(data, opts, wb, rels);\n}\nfunction write_sty(data, name /*:string*/, opts) {\n return (name.slice(-4) === \".bin\" ? write_sty_bin : write_sty_xml)(data, opts);\n}\nfunction write_sst(data /*:SST*/, name /*:string*/, opts) {\n return (name.slice(-4) === \".bin\" ? write_sst_bin : write_sst_xml)(data, opts);\n}\nfunction write_cmnt(data /*:Array*/, name /*:string*/, opts) {\n return (name.slice(-4) === \".bin\" ? write_comments_bin : write_comments_xml)(data, opts);\n}\n/*\nfunction write_cc(data, name:string, opts) {\n\treturn (name.slice(-4)===\".bin\" ? write_cc_bin : write_cc_xml)(data, opts);\n}\n*/\n\nfunction write_xlmeta(name /*:string*/) {\n return (name.slice(-4) === \".bin\" ? write_xlmeta_bin : write_xlmeta_xml)();\n}\nvar attregexg2 = /([\\w:]+)=((?:\")([^\"]*)(?:\")|(?:')([^']*)(?:'))/g;\nvar attregex2 = /([\\w:]+)=((?:\")(?:[^\"]*)(?:\")|(?:')(?:[^']*)(?:'))/;\nfunction xlml_parsexmltag(tag /*:string*/, skip_root /*:?boolean*/) {\n var words = tag.split(/\\s+/);\n var z /*:any*/ = [] /*:any*/;\n if (!skip_root) z[0] = words[0];\n if (words.length === 1) return z;\n var m = tag.match(attregexg2),\n y,\n j,\n w,\n i;\n if (m) for (i = 0; i != m.length; ++i) {\n y = m[i].match(attregex2);\n /*:: if(!y || !y[2]) continue; */\n if ((j = y[1].indexOf(\":\")) === -1) z[y[1]] = y[2].slice(1, y[2].length - 1);else {\n if (y[1].slice(0, 6) === \"xmlns:\") w = \"xmlns\" + y[1].slice(6);else w = y[1].slice(j + 1);\n z[w] = y[2].slice(1, y[2].length - 1);\n }\n }\n return z;\n}\nfunction xlml_parsexmltagobj(tag /*:string*/) {\n var words = tag.split(/\\s+/);\n var z = {};\n if (words.length === 1) return z;\n var m = tag.match(attregexg2),\n y,\n j,\n w,\n i;\n if (m) for (i = 0; i != m.length; ++i) {\n y = m[i].match(attregex2);\n /*:: if(!y || !y[2]) continue; */\n if ((j = y[1].indexOf(\":\")) === -1) z[y[1]] = y[2].slice(1, y[2].length - 1);else {\n if (y[1].slice(0, 6) === \"xmlns:\") w = \"xmlns\" + y[1].slice(6);else w = y[1].slice(j + 1);\n z[w] = y[2].slice(1, y[2].length - 1);\n }\n }\n return z;\n}\n\n// ----\n\n/* map from xlml named formats to SSF TODO: localize */\nvar XLMLFormatMap /*: {[string]:string}*/;\nfunction xlml_format(format, value) /*:string*/{\n var fmt = XLMLFormatMap[format] || unescapexml(format);\n if (fmt === \"General\") return SSF_general(value);\n return SSF_format(fmt, value);\n}\nfunction xlml_set_custprop(Custprops, key, cp, val /*:string*/) {\n var oval /*:any*/ = val;\n switch ((cp[0].match(/dt:dt=\"([\\w.]+)\"/) || [\"\", \"\"])[1]) {\n case \"boolean\":\n oval = parsexmlbool(val);\n break;\n case \"i2\":\n case \"int\":\n oval = parseInt(val, 10);\n break;\n case \"r4\":\n case \"float\":\n oval = parseFloat(val);\n break;\n case \"date\":\n case \"dateTime.tz\":\n oval = parseDate(val);\n break;\n case \"i8\":\n case \"string\":\n case \"fixed\":\n case \"uuid\":\n case \"bin.base64\":\n break;\n default:\n throw new Error(\"bad custprop:\" + cp[0]);\n }\n Custprops[unescapexml(key)] = oval;\n}\nfunction safe_format_xlml(cell /*:Cell*/, nf, o) {\n if (cell.t === 'z') return;\n if (!o || o.cellText !== false) try {\n if (cell.t === 'e') {\n cell.w = cell.w || BErr[cell.v];\n } else if (nf === \"General\") {\n if (cell.t === 'n') {\n if ((cell.v | 0) === cell.v) cell.w = cell.v.toString(10);else cell.w = SSF_general_num(cell.v);\n } else cell.w = SSF_general(cell.v);\n } else cell.w = xlml_format(nf || \"General\", cell.v);\n } catch (e) {\n if (o.WTF) throw e;\n }\n try {\n var z = XLMLFormatMap[nf] || nf || \"General\";\n if (o.cellNF) cell.z = z;\n if (o.cellDates && cell.t == 'n' && fmt_is_date(z)) {\n var _d = SSF_parse_date_code(cell.v);\n if (_d) {\n cell.t = 'd';\n cell.v = new Date(_d.y, _d.m - 1, _d.d, _d.H, _d.M, _d.S, _d.u);\n }\n }\n } catch (e) {\n if (o.WTF) throw e;\n }\n}\nfunction process_style_xlml(styles, stag, opts) {\n if (opts.cellStyles) {\n if (stag.Interior) {\n var I = stag.Interior;\n if (I.Pattern) I.patternType = XLMLPatternTypeMap[I.Pattern] || I.Pattern;\n }\n }\n styles[stag.ID] = stag;\n}\n\n/* TODO: there must exist some form of OSP-blessed spec */\nfunction parse_xlml_data(xml, ss, data, cell /*:any*/, base, styles, csty, row, arrayf, o) {\n var nf = \"General\",\n sid = cell.StyleID,\n S = {};\n o = o || {};\n var interiors = [];\n var i = 0;\n if (sid === undefined && row) sid = row.StyleID;\n if (sid === undefined && csty) sid = csty.StyleID;\n while (styles[sid] !== undefined) {\n if (styles[sid].nf) nf = styles[sid].nf;\n if (styles[sid].Interior) interiors.push(styles[sid].Interior);\n if (!styles[sid].Parent) break;\n sid = styles[sid].Parent;\n }\n switch (data.Type) {\n case 'Boolean':\n cell.t = 'b';\n cell.v = parsexmlbool(xml);\n break;\n case 'String':\n cell.t = 's';\n cell.r = xlml_fixstr(unescapexml(xml));\n cell.v = xml.indexOf(\"<\") > -1 ? unescapexml(ss || xml).replace(/<.*?>/g, \"\") : cell.r; // todo: BR etc\n break;\n case 'DateTime':\n if (xml.slice(-1) != \"Z\") xml += \"Z\";\n cell.v = (parseDate(xml) - new Date(Date.UTC(1899, 11, 30))) / (24 * 60 * 60 * 1000);\n if (cell.v !== cell.v) cell.v = unescapexml(xml);else if (cell.v < 60) cell.v = cell.v - 1;\n if (!nf || nf == \"General\") nf = \"yyyy-mm-dd\";\n /* falls through */\n case 'Number':\n if (cell.v === undefined) cell.v = +xml;\n if (!cell.t) cell.t = 'n';\n break;\n case 'Error':\n cell.t = 'e';\n cell.v = RBErr[xml];\n if (o.cellText !== false) cell.w = xml;\n break;\n default:\n if (xml == \"\" && ss == \"\") {\n cell.t = 'z';\n } else {\n cell.t = 's';\n cell.v = xlml_fixstr(ss || xml);\n }\n break;\n }\n safe_format_xlml(cell, nf, o);\n if (o.cellFormula !== false) {\n if (cell.Formula) {\n var fstr = unescapexml(cell.Formula);\n /* strictly speaking, the leading = is required but some writers omit */\n if (fstr.charCodeAt(0) == 61 /* = */) fstr = fstr.slice(1);\n cell.f = rc_to_a1(fstr, base);\n delete cell.Formula;\n if (cell.ArrayRange == \"RC\") cell.F = rc_to_a1(\"RC:RC\", base);else if (cell.ArrayRange) {\n cell.F = rc_to_a1(cell.ArrayRange, base);\n arrayf.push([safe_decode_range(cell.F), cell.F]);\n }\n } else {\n for (i = 0; i < arrayf.length; ++i) if (base.r >= arrayf[i][0].s.r && base.r <= arrayf[i][0].e.r) if (base.c >= arrayf[i][0].s.c && base.c <= arrayf[i][0].e.c) cell.F = arrayf[i][1];\n }\n }\n if (o.cellStyles) {\n interiors.forEach(function (x) {\n if (!S.patternType && x.patternType) S.patternType = x.patternType;\n });\n cell.s = S;\n }\n if (cell.StyleID !== undefined) cell.ixfe = cell.StyleID;\n}\nfunction xlml_clean_comment(comment /*:any*/) {\n comment.t = comment.v || \"\";\n comment.t = comment.t.replace(/\\r\\n/g, \"\\n\").replace(/\\r/g, \"\\n\");\n comment.v = comment.w = comment.ixfe = undefined;\n}\n\n/* TODO: Everything */\nfunction parse_xlml_xml(d, _opts) /*:Workbook*/{\n var opts = _opts || {};\n make_ssf();\n var str = debom(xlml_normalize(d));\n if (opts.type == 'binary' || opts.type == 'array' || opts.type == 'base64') {\n if (typeof $cptable !== 'undefined') str = $cptable.utils.decode(65001, char_codes(str));else str = utf8read(str);\n }\n var opening = str.slice(0, 1024).toLowerCase(),\n ishtml = false;\n opening = opening.replace(/\".*?\"/g, \"\");\n if ((opening.indexOf(\">\") & 1023) > Math.min(opening.indexOf(\",\") & 1023, opening.indexOf(\";\") & 1023)) {\n var _o = dup(opts);\n _o.type = \"string\";\n return PRN.to_workbook(str, _o);\n }\n if (opening.indexOf(\"= 0) ishtml = true;\n });\n if (ishtml) return html_to_workbook(str, opts);\n XLMLFormatMap = {\n \"General Number\": \"General\",\n \"General Date\": table_fmt[22],\n \"Long Date\": \"dddd, mmmm dd, yyyy\",\n \"Medium Date\": table_fmt[15],\n \"Short Date\": table_fmt[14],\n \"Long Time\": table_fmt[19],\n \"Medium Time\": table_fmt[18],\n \"Short Time\": table_fmt[20],\n \"Currency\": '\"$\"#,##0.00_);[Red]\\\\(\"$\"#,##0.00\\\\)',\n \"Fixed\": table_fmt[2],\n \"Standard\": table_fmt[4],\n \"Percent\": table_fmt[10],\n \"Scientific\": table_fmt[11],\n \"Yes/No\": '\"Yes\";\"Yes\";\"No\";@',\n \"True/False\": '\"True\";\"True\";\"False\";@',\n \"On/Off\": '\"Yes\";\"Yes\";\"No\";@'\n } /*:any*/;\n var Rn;\n var state = [],\n tmp;\n if (DENSE != null && opts.dense == null) opts.dense = DENSE;\n var sheets = {},\n sheetnames /*:Array*/ = [],\n cursheet /*:Worksheet*/ = opts.dense ? [] : {},\n sheetname = \"\";\n var cell = {} /*:any*/,\n row = {}; // eslint-disable-line no-unused-vars\n var dtag = xlml_parsexmltag(''),\n didx = 0;\n var c = 0,\n r = 0;\n var refguess /*:Range*/ = {\n s: {\n r: 2000000,\n c: 2000000\n },\n e: {\n r: 0,\n c: 0\n }\n };\n var styles = {},\n stag = {};\n var ss = \"\",\n fidx = 0;\n var merges /*:Array*/ = [];\n var Props = {},\n Custprops = {},\n pidx = 0,\n cp = [];\n var comments /*:Array*/ = [],\n comment /*:Comment*/ = {} /*:any*/;\n var cstys = [],\n csty,\n seencol = false;\n var arrayf /*:Array<[Range, string]>*/ = [];\n var rowinfo /*:Array*/ = [],\n rowobj = {},\n cc = 0,\n rr = 0;\n var Workbook /*:WBWBProps*/ = {\n Sheets: [],\n WBProps: {\n date1904: false\n }\n } /*:any*/,\n wsprops = {};\n xlmlregex.lastIndex = 0;\n str = str.replace(//mg, \"\");\n var raw_Rn3 = \"\";\n while (Rn = xlmlregex.exec(str)) switch (Rn[3] = (raw_Rn3 = Rn[3]).toLowerCase()) {\n case 'data' /*case 'Data'*/:\n if (raw_Rn3 == \"data\") {\n if (Rn[1] === '/') {\n if ((tmp = state.pop())[0] !== Rn[3]) throw new Error(\"Bad state: \" + tmp.join(\"|\"));\n } else if (Rn[0].charAt(Rn[0].length - 2) !== '/') state.push([Rn[3], true]);\n break;\n }\n if (state[state.length - 1][1]) break;\n if (Rn[1] === '/') parse_xlml_data(str.slice(didx, Rn.index), ss, dtag, state[state.length - 1][0] == /*\"Comment\"*/\"comment\" ? comment : cell, {\n c: c,\n r: r\n }, styles, cstys[c], row, arrayf, opts);else {\n ss = \"\";\n dtag = xlml_parsexmltag(Rn[0]);\n didx = Rn.index + Rn[0].length;\n }\n break;\n case 'cell' /*case 'Cell'*/:\n if (Rn[1] === '/') {\n if (comments.length > 0) cell.c = comments;\n if ((!opts.sheetRows || opts.sheetRows > r) && cell.v !== undefined) {\n if (opts.dense) {\n if (!cursheet[r]) cursheet[r] = [];\n cursheet[r][c] = cell;\n } else cursheet[encode_col(c) + encode_row(r)] = cell;\n }\n if (cell.HRef) {\n cell.l = {\n Target: unescapexml(cell.HRef)\n } /*:any*/;\n if (cell.HRefScreenTip) cell.l.Tooltip = cell.HRefScreenTip;\n delete cell.HRef;\n delete cell.HRefScreenTip;\n }\n if (cell.MergeAcross || cell.MergeDown) {\n cc = c + (parseInt(cell.MergeAcross, 10) | 0);\n rr = r + (parseInt(cell.MergeDown, 10) | 0);\n merges.push({\n s: {\n c: c,\n r: r\n },\n e: {\n c: cc,\n r: rr\n }\n });\n }\n if (!opts.sheetStubs) {\n if (cell.MergeAcross) c = cc + 1;else ++c;\n } else if (cell.MergeAcross || cell.MergeDown) {\n /*:: if(!cc) cc = 0; if(!rr) rr = 0; */\n for (var cma = c; cma <= cc; ++cma) {\n for (var cmd = r; cmd <= rr; ++cmd) {\n if (cma > c || cmd > r) {\n if (opts.dense) {\n if (!cursheet[cmd]) cursheet[cmd] = [];\n cursheet[cmd][cma] = {\n t: 'z'\n };\n } else cursheet[encode_col(cma) + encode_row(cmd)] = {\n t: 'z'\n };\n }\n }\n }\n c = cc + 1;\n } else ++c;\n } else {\n cell = xlml_parsexmltagobj(Rn[0]);\n if (cell.Index) c = +cell.Index - 1;\n if (c < refguess.s.c) refguess.s.c = c;\n if (c > refguess.e.c) refguess.e.c = c;\n if (Rn[0].slice(-2) === \"/>\") ++c;\n comments = [];\n }\n break;\n case 'row' /*case 'Row'*/:\n if (Rn[1] === '/' || Rn[0].slice(-2) === \"/>\") {\n if (r < refguess.s.r) refguess.s.r = r;\n if (r > refguess.e.r) refguess.e.r = r;\n if (Rn[0].slice(-2) === \"/>\") {\n row = xlml_parsexmltag(Rn[0]);\n if (row.Index) r = +row.Index - 1;\n }\n c = 0;\n ++r;\n } else {\n row = xlml_parsexmltag(Rn[0]);\n if (row.Index) r = +row.Index - 1;\n rowobj = {};\n if (row.AutoFitHeight == \"0\" || row.Height) {\n rowobj.hpx = parseInt(row.Height, 10);\n rowobj.hpt = px2pt(rowobj.hpx);\n rowinfo[r] = rowobj;\n }\n if (row.Hidden == \"1\") {\n rowobj.hidden = true;\n rowinfo[r] = rowobj;\n }\n }\n break;\n case 'worksheet' /*case 'Worksheet'*/:\n /* TODO: read range from FullRows/FullColumns */\n if (Rn[1] === '/') {\n if ((tmp = state.pop())[0] !== Rn[3]) throw new Error(\"Bad state: \" + tmp.join(\"|\"));\n sheetnames.push(sheetname);\n if (refguess.s.r <= refguess.e.r && refguess.s.c <= refguess.e.c) {\n cursheet[\"!ref\"] = encode_range(refguess);\n if (opts.sheetRows && opts.sheetRows <= refguess.e.r) {\n cursheet[\"!fullref\"] = cursheet[\"!ref\"];\n refguess.e.r = opts.sheetRows - 1;\n cursheet[\"!ref\"] = encode_range(refguess);\n }\n }\n if (merges.length) cursheet[\"!merges\"] = merges;\n if (cstys.length > 0) cursheet[\"!cols\"] = cstys;\n if (rowinfo.length > 0) cursheet[\"!rows\"] = rowinfo;\n sheets[sheetname] = cursheet;\n } else {\n refguess = {\n s: {\n r: 2000000,\n c: 2000000\n },\n e: {\n r: 0,\n c: 0\n }\n };\n r = c = 0;\n state.push([Rn[3], false]);\n tmp = xlml_parsexmltag(Rn[0]);\n sheetname = unescapexml(tmp.Name);\n cursheet = opts.dense ? [] : {};\n merges = [];\n arrayf = [];\n rowinfo = [];\n wsprops = {\n name: sheetname,\n Hidden: 0\n };\n Workbook.Sheets.push(wsprops);\n }\n break;\n case 'table' /*case 'Table'*/:\n if (Rn[1] === '/') {\n if ((tmp = state.pop())[0] !== Rn[3]) throw new Error(\"Bad state: \" + tmp.join(\"|\"));\n } else if (Rn[0].slice(-2) == \"/>\") break;else {\n state.push([Rn[3], false]);\n cstys = [];\n seencol = false;\n }\n break;\n case 'style' /*case 'Style'*/:\n if (Rn[1] === '/') process_style_xlml(styles, stag, opts);else stag = xlml_parsexmltag(Rn[0]);\n break;\n case 'numberformat' /*case 'NumberFormat'*/:\n stag.nf = unescapexml(xlml_parsexmltag(Rn[0]).Format || \"General\");\n if (XLMLFormatMap[stag.nf]) stag.nf = XLMLFormatMap[stag.nf];\n for (var ssfidx = 0; ssfidx != 0x188; ++ssfidx) if (table_fmt[ssfidx] == stag.nf) break;\n if (ssfidx == 0x188) for (ssfidx = 0x39; ssfidx != 0x188; ++ssfidx) if (table_fmt[ssfidx] == null) {\n SSF_load(stag.nf, ssfidx);\n break;\n }\n break;\n case 'column' /*case 'Column'*/:\n if (state[state.length - 1][0] !== /*'Table'*/'table') break;\n csty = xlml_parsexmltag(Rn[0]);\n if (csty.Hidden) {\n csty.hidden = true;\n delete csty.Hidden;\n }\n if (csty.Width) csty.wpx = parseInt(csty.Width, 10);\n if (!seencol && csty.wpx > 10) {\n seencol = true;\n MDW = DEF_MDW; //find_mdw_wpx(csty.wpx);\n for (var _col = 0; _col < cstys.length; ++_col) if (cstys[_col]) process_col(cstys[_col]);\n }\n if (seencol) process_col(csty);\n cstys[csty.Index - 1 || cstys.length] = csty;\n for (var i = 0; i < +csty.Span; ++i) cstys[cstys.length] = dup(csty);\n break;\n case 'namedrange' /*case 'NamedRange'*/:\n if (Rn[1] === '/') break;\n if (!Workbook.Names) Workbook.Names = [];\n var _NamedRange = parsexmltag(Rn[0]);\n var _DefinedName /*:DefinedName*/ = {\n Name: _NamedRange.Name,\n Ref: rc_to_a1(_NamedRange.RefersTo.slice(1), {\n r: 0,\n c: 0\n })\n } /*:any*/;\n if (Workbook.Sheets.length > 0) _DefinedName.Sheet = Workbook.Sheets.length - 1;\n /*:: if(Workbook.Names) */\n Workbook.Names.push(_DefinedName);\n break;\n case 'namedcell' /*case 'NamedCell'*/:\n break;\n case 'b' /*case 'B'*/:\n break;\n case 'i' /*case 'I'*/:\n break;\n case 'u' /*case 'U'*/:\n break;\n case 's' /*case 'S'*/:\n break;\n case 'em' /*case 'EM'*/:\n break;\n case 'h2' /*case 'H2'*/:\n break;\n case 'h3' /*case 'H3'*/:\n break;\n case 'sub' /*case 'Sub'*/:\n break;\n case 'sup' /*case 'Sup'*/:\n break;\n case 'span' /*case 'Span'*/:\n break;\n case 'alignment' /*case 'Alignment'*/:\n break;\n case 'borders' /*case 'Borders'*/:\n break;\n case 'border' /*case 'Border'*/:\n break;\n case 'font' /*case 'Font'*/:\n if (Rn[0].slice(-2) === \"/>\") break;else if (Rn[1] === \"/\") ss += str.slice(fidx, Rn.index);else fidx = Rn.index + Rn[0].length;\n break;\n case 'interior' /*case 'Interior'*/:\n if (!opts.cellStyles) break;\n stag.Interior = xlml_parsexmltag(Rn[0]);\n break;\n case 'protection' /*case 'Protection'*/:\n break;\n case 'author' /*case 'Author'*/:\n case 'title' /*case 'Title'*/:\n case 'description' /*case 'Description'*/:\n case 'created' /*case 'Created'*/:\n case 'keywords' /*case 'Keywords'*/:\n case 'subject' /*case 'Subject'*/:\n case 'category' /*case 'Category'*/:\n case 'company' /*case 'Company'*/:\n case 'lastauthor' /*case 'LastAuthor'*/:\n case 'lastsaved' /*case 'LastSaved'*/:\n case 'lastprinted' /*case 'LastPrinted'*/:\n case 'version' /*case 'Version'*/:\n case 'revision' /*case 'Revision'*/:\n case 'totaltime' /*case 'TotalTime'*/:\n case 'hyperlinkbase' /*case 'HyperlinkBase'*/:\n case 'manager' /*case 'Manager'*/:\n case 'contentstatus' /*case 'ContentStatus'*/:\n case 'identifier' /*case 'Identifier'*/:\n case 'language' /*case 'Language'*/:\n case 'appname' /*case 'AppName'*/:\n if (Rn[0].slice(-2) === \"/>\") break;else if (Rn[1] === \"/\") xlml_set_prop(Props, raw_Rn3, str.slice(pidx, Rn.index));else pidx = Rn.index + Rn[0].length;\n break;\n case 'paragraphs' /*case 'Paragraphs'*/:\n break;\n case 'styles' /*case 'Styles'*/:\n case 'workbook' /*case 'Workbook'*/:\n if (Rn[1] === '/') {\n if ((tmp = state.pop())[0] !== Rn[3]) throw new Error(\"Bad state: \" + tmp.join(\"|\"));\n } else state.push([Rn[3], false]);\n break;\n case 'comment' /*case 'Comment'*/:\n if (Rn[1] === '/') {\n if ((tmp = state.pop())[0] !== Rn[3]) throw new Error(\"Bad state: \" + tmp.join(\"|\"));\n xlml_clean_comment(comment);\n comments.push(comment);\n } else {\n state.push([Rn[3], false]);\n tmp = xlml_parsexmltag(Rn[0]);\n comment = {\n a: tmp.Author\n } /*:any*/;\n }\n break;\n case 'autofilter' /*case 'AutoFilter'*/:\n if (Rn[1] === '/') {\n if ((tmp = state.pop())[0] !== Rn[3]) throw new Error(\"Bad state: \" + tmp.join(\"|\"));\n } else if (Rn[0].charAt(Rn[0].length - 2) !== '/') {\n var AutoFilter = xlml_parsexmltag(Rn[0]);\n cursheet['!autofilter'] = {\n ref: rc_to_a1(AutoFilter.Range).replace(/\\$/g, \"\")\n };\n state.push([Rn[3], true]);\n }\n break;\n case 'name' /*case 'Name'*/:\n break;\n case 'datavalidation' /*case 'DataValidation'*/:\n if (Rn[1] === '/') {\n if ((tmp = state.pop())[0] !== Rn[3]) throw new Error(\"Bad state: \" + tmp.join(\"|\"));\n } else {\n if (Rn[0].charAt(Rn[0].length - 2) !== '/') state.push([Rn[3], true]);\n }\n break;\n case 'pixelsperinch' /*case 'PixelsPerInch'*/:\n break;\n case 'componentoptions' /*case 'ComponentOptions'*/:\n case 'documentproperties' /*case 'DocumentProperties'*/:\n case 'customdocumentproperties' /*case 'CustomDocumentProperties'*/:\n case 'officedocumentsettings' /*case 'OfficeDocumentSettings'*/:\n case 'pivottable' /*case 'PivotTable'*/:\n case 'pivotcache' /*case 'PivotCache'*/:\n case 'names' /*case 'Names'*/:\n case 'mapinfo' /*case 'MapInfo'*/:\n case 'pagebreaks' /*case 'PageBreaks'*/:\n case 'querytable' /*case 'QueryTable'*/:\n case 'sorting' /*case 'Sorting'*/:\n case 'schema' /*case 'Schema'*/: //case 'data' /*case 'data'*/:\n case 'conditionalformatting' /*case 'ConditionalFormatting'*/:\n case 'smarttagtype' /*case 'SmartTagType'*/:\n case 'smarttags' /*case 'SmartTags'*/:\n case 'excelworkbook' /*case 'ExcelWorkbook'*/:\n case 'workbookoptions' /*case 'WorkbookOptions'*/:\n case 'worksheetoptions' /*case 'WorksheetOptions'*/:\n if (Rn[1] === '/') {\n if ((tmp = state.pop())[0] !== Rn[3]) throw new Error(\"Bad state: \" + tmp.join(\"|\"));\n } else if (Rn[0].charAt(Rn[0].length - 2) !== '/') state.push([Rn[3], true]);\n break;\n case 'null' /*case 'Null'*/:\n break;\n default:\n /* FODS file root is */\n if (state.length == 0 && Rn[3] == \"document\") return parse_fods(str, opts);\n /* UOS file root is */\n if (state.length == 0 && Rn[3] == \"uof\" /*\"UOF\"*/) return parse_fods(str, opts);\n var seen = true;\n switch (state[state.length - 1][0]) {\n /* OfficeDocumentSettings */\n case 'officedocumentsettings' /*case 'OfficeDocumentSettings'*/:\n switch (Rn[3]) {\n case 'allowpng' /*case 'AllowPNG'*/:\n break;\n case 'removepersonalinformation' /*case 'RemovePersonalInformation'*/:\n break;\n case 'downloadcomponents' /*case 'DownloadComponents'*/:\n break;\n case 'locationofcomponents' /*case 'LocationOfComponents'*/:\n break;\n case 'colors' /*case 'Colors'*/:\n break;\n case 'color' /*case 'Color'*/:\n break;\n case 'index' /*case 'Index'*/:\n break;\n case 'rgb' /*case 'RGB'*/:\n break;\n case 'targetscreensize' /*case 'TargetScreenSize'*/:\n break;\n case 'readonlyrecommended' /*case 'ReadOnlyRecommended'*/:\n break;\n default:\n seen = false;\n }\n break;\n\n /* ComponentOptions */\n case 'componentoptions' /*case 'ComponentOptions'*/:\n switch (Rn[3]) {\n case 'toolbar' /*case 'Toolbar'*/:\n break;\n case 'hideofficelogo' /*case 'HideOfficeLogo'*/:\n break;\n case 'spreadsheetautofit' /*case 'SpreadsheetAutoFit'*/:\n break;\n case 'label' /*case 'Label'*/:\n break;\n case 'caption' /*case 'Caption'*/:\n break;\n case 'maxheight' /*case 'MaxHeight'*/:\n break;\n case 'maxwidth' /*case 'MaxWidth'*/:\n break;\n case 'nextsheetnumber' /*case 'NextSheetNumber'*/:\n break;\n default:\n seen = false;\n }\n break;\n\n /* ExcelWorkbook */\n case 'excelworkbook' /*case 'ExcelWorkbook'*/:\n switch (Rn[3]) {\n case 'date1904' /*case 'Date1904'*/:\n /*:: if(!Workbook.WBProps) Workbook.WBProps = {}; */\n Workbook.WBProps.date1904 = true;\n break;\n case 'windowheight' /*case 'WindowHeight'*/:\n break;\n case 'windowwidth' /*case 'WindowWidth'*/:\n break;\n case 'windowtopx' /*case 'WindowTopX'*/:\n break;\n case 'windowtopy' /*case 'WindowTopY'*/:\n break;\n case 'tabratio' /*case 'TabRatio'*/:\n break;\n case 'protectstructure' /*case 'ProtectStructure'*/:\n break;\n case 'protectwindow' /*case 'ProtectWindow'*/:\n break;\n case 'protectwindows' /*case 'ProtectWindows'*/:\n break;\n case 'activesheet' /*case 'ActiveSheet'*/:\n break;\n case 'displayinknotes' /*case 'DisplayInkNotes'*/:\n break;\n case 'firstvisiblesheet' /*case 'FirstVisibleSheet'*/:\n break;\n case 'supbook' /*case 'SupBook'*/:\n break;\n case 'sheetname' /*case 'SheetName'*/:\n break;\n case 'sheetindex' /*case 'SheetIndex'*/:\n break;\n case 'sheetindexfirst' /*case 'SheetIndexFirst'*/:\n break;\n case 'sheetindexlast' /*case 'SheetIndexLast'*/:\n break;\n case 'dll' /*case 'Dll'*/:\n break;\n case 'acceptlabelsinformulas' /*case 'AcceptLabelsInFormulas'*/:\n break;\n case 'donotsavelinkvalues' /*case 'DoNotSaveLinkValues'*/:\n break;\n case 'iteration' /*case 'Iteration'*/:\n break;\n case 'maxiterations' /*case 'MaxIterations'*/:\n break;\n case 'maxchange' /*case 'MaxChange'*/:\n break;\n case 'path' /*case 'Path'*/:\n break;\n case 'xct' /*case 'Xct'*/:\n break;\n case 'count' /*case 'Count'*/:\n break;\n case 'selectedsheets' /*case 'SelectedSheets'*/:\n break;\n case 'calculation' /*case 'Calculation'*/:\n break;\n case 'uncalced' /*case 'Uncalced'*/:\n break;\n case 'startupprompt' /*case 'StartupPrompt'*/:\n break;\n case 'crn' /*case 'Crn'*/:\n break;\n case 'externname' /*case 'ExternName'*/:\n break;\n case 'formula' /*case 'Formula'*/:\n break;\n case 'colfirst' /*case 'ColFirst'*/:\n break;\n case 'collast' /*case 'ColLast'*/:\n break;\n case 'wantadvise' /*case 'WantAdvise'*/:\n break;\n case 'boolean' /*case 'Boolean'*/:\n break;\n case 'error' /*case 'Error'*/:\n break;\n case 'text' /*case 'Text'*/:\n break;\n case 'ole' /*case 'OLE'*/:\n break;\n case 'noautorecover' /*case 'NoAutoRecover'*/:\n break;\n case 'publishobjects' /*case 'PublishObjects'*/:\n break;\n case 'donotcalculatebeforesave' /*case 'DoNotCalculateBeforeSave'*/:\n break;\n case 'number' /*case 'Number'*/:\n break;\n case 'refmoder1c1' /*case 'RefModeR1C1'*/:\n break;\n case 'embedsavesmarttags' /*case 'EmbedSaveSmartTags'*/:\n break;\n default:\n seen = false;\n }\n break;\n\n /* WorkbookOptions */\n case 'workbookoptions' /*case 'WorkbookOptions'*/:\n switch (Rn[3]) {\n case 'owcversion' /*case 'OWCVersion'*/:\n break;\n case 'height' /*case 'Height'*/:\n break;\n case 'width' /*case 'Width'*/:\n break;\n default:\n seen = false;\n }\n break;\n\n /* WorksheetOptions */\n case 'worksheetoptions' /*case 'WorksheetOptions'*/:\n switch (Rn[3]) {\n case 'visible' /*case 'Visible'*/:\n if (Rn[0].slice(-2) === \"/>\") {/* empty */} else if (Rn[1] === \"/\") switch (str.slice(pidx, Rn.index)) {\n case \"SheetHidden\":\n wsprops.Hidden = 1;\n break;\n case \"SheetVeryHidden\":\n wsprops.Hidden = 2;\n break;\n } else pidx = Rn.index + Rn[0].length;\n break;\n case 'header' /*case 'Header'*/:\n if (!cursheet['!margins']) default_margins(cursheet['!margins'] = {}, 'xlml');\n if (!isNaN(+parsexmltag(Rn[0]).Margin)) cursheet['!margins'].header = +parsexmltag(Rn[0]).Margin;\n break;\n case 'footer' /*case 'Footer'*/:\n if (!cursheet['!margins']) default_margins(cursheet['!margins'] = {}, 'xlml');\n if (!isNaN(+parsexmltag(Rn[0]).Margin)) cursheet['!margins'].footer = +parsexmltag(Rn[0]).Margin;\n break;\n case 'pagemargins' /*case 'PageMargins'*/:\n var pagemargins = parsexmltag(Rn[0]);\n if (!cursheet['!margins']) default_margins(cursheet['!margins'] = {}, 'xlml');\n if (!isNaN(+pagemargins.Top)) cursheet['!margins'].top = +pagemargins.Top;\n if (!isNaN(+pagemargins.Left)) cursheet['!margins'].left = +pagemargins.Left;\n if (!isNaN(+pagemargins.Right)) cursheet['!margins'].right = +pagemargins.Right;\n if (!isNaN(+pagemargins.Bottom)) cursheet['!margins'].bottom = +pagemargins.Bottom;\n break;\n case 'displayrighttoleft' /*case 'DisplayRightToLeft'*/:\n if (!Workbook.Views) Workbook.Views = [];\n if (!Workbook.Views[0]) Workbook.Views[0] = {};\n Workbook.Views[0].RTL = true;\n break;\n case 'freezepanes' /*case 'FreezePanes'*/:\n break;\n case 'frozennosplit' /*case 'FrozenNoSplit'*/:\n break;\n case 'splithorizontal' /*case 'SplitHorizontal'*/:\n case 'splitvertical' /*case 'SplitVertical'*/:\n break;\n case 'donotdisplaygridlines' /*case 'DoNotDisplayGridlines'*/:\n break;\n case 'activerow' /*case 'ActiveRow'*/:\n break;\n case 'activecol' /*case 'ActiveCol'*/:\n break;\n case 'toprowbottompane' /*case 'TopRowBottomPane'*/:\n break;\n case 'leftcolumnrightpane' /*case 'LeftColumnRightPane'*/:\n break;\n case 'unsynced' /*case 'Unsynced'*/:\n break;\n case 'print' /*case 'Print'*/:\n break;\n case 'printerrors' /*case 'PrintErrors'*/:\n break;\n case 'panes' /*case 'Panes'*/:\n break;\n case 'scale' /*case 'Scale'*/:\n break;\n case 'pane' /*case 'Pane'*/:\n break;\n case 'number' /*case 'Number'*/:\n break;\n case 'layout' /*case 'Layout'*/:\n break;\n case 'pagesetup' /*case 'PageSetup'*/:\n break;\n case 'selected' /*case 'Selected'*/:\n break;\n case 'protectobjects' /*case 'ProtectObjects'*/:\n break;\n case 'enableselection' /*case 'EnableSelection'*/:\n break;\n case 'protectscenarios' /*case 'ProtectScenarios'*/:\n break;\n case 'validprinterinfo' /*case 'ValidPrinterInfo'*/:\n break;\n case 'horizontalresolution' /*case 'HorizontalResolution'*/:\n break;\n case 'verticalresolution' /*case 'VerticalResolution'*/:\n break;\n case 'numberofcopies' /*case 'NumberofCopies'*/:\n break;\n case 'activepane' /*case 'ActivePane'*/:\n break;\n case 'toprowvisible' /*case 'TopRowVisible'*/:\n break;\n case 'leftcolumnvisible' /*case 'LeftColumnVisible'*/:\n break;\n case 'fittopage' /*case 'FitToPage'*/:\n break;\n case 'rangeselection' /*case 'RangeSelection'*/:\n break;\n case 'papersizeindex' /*case 'PaperSizeIndex'*/:\n break;\n case 'pagelayoutzoom' /*case 'PageLayoutZoom'*/:\n break;\n case 'pagebreakzoom' /*case 'PageBreakZoom'*/:\n break;\n case 'filteron' /*case 'FilterOn'*/:\n break;\n case 'fitwidth' /*case 'FitWidth'*/:\n break;\n case 'fitheight' /*case 'FitHeight'*/:\n break;\n case 'commentslayout' /*case 'CommentsLayout'*/:\n break;\n case 'zoom' /*case 'Zoom'*/:\n break;\n case 'lefttoright' /*case 'LeftToRight'*/:\n break;\n case 'gridlines' /*case 'Gridlines'*/:\n break;\n case 'allowsort' /*case 'AllowSort'*/:\n break;\n case 'allowfilter' /*case 'AllowFilter'*/:\n break;\n case 'allowinsertrows' /*case 'AllowInsertRows'*/:\n break;\n case 'allowdeleterows' /*case 'AllowDeleteRows'*/:\n break;\n case 'allowinsertcols' /*case 'AllowInsertCols'*/:\n break;\n case 'allowdeletecols' /*case 'AllowDeleteCols'*/:\n break;\n case 'allowinserthyperlinks' /*case 'AllowInsertHyperlinks'*/:\n break;\n case 'allowformatcells' /*case 'AllowFormatCells'*/:\n break;\n case 'allowsizecols' /*case 'AllowSizeCols'*/:\n break;\n case 'allowsizerows' /*case 'AllowSizeRows'*/:\n break;\n case 'nosummaryrowsbelowdetail' /*case 'NoSummaryRowsBelowDetail'*/:\n if (!cursheet[\"!outline\"]) cursheet[\"!outline\"] = {};\n cursheet[\"!outline\"].above = true;\n break;\n case 'tabcolorindex' /*case 'TabColorIndex'*/:\n break;\n case 'donotdisplayheadings' /*case 'DoNotDisplayHeadings'*/:\n break;\n case 'showpagelayoutzoom' /*case 'ShowPageLayoutZoom'*/:\n break;\n case 'nosummarycolumnsrightdetail' /*case 'NoSummaryColumnsRightDetail'*/:\n if (!cursheet[\"!outline\"]) cursheet[\"!outline\"] = {};\n cursheet[\"!outline\"].left = true;\n break;\n case 'blackandwhite' /*case 'BlackAndWhite'*/:\n break;\n case 'donotdisplayzeros' /*case 'DoNotDisplayZeros'*/:\n break;\n case 'displaypagebreak' /*case 'DisplayPageBreak'*/:\n break;\n case 'rowcolheadings' /*case 'RowColHeadings'*/:\n break;\n case 'donotdisplayoutline' /*case 'DoNotDisplayOutline'*/:\n break;\n case 'noorientation' /*case 'NoOrientation'*/:\n break;\n case 'allowusepivottables' /*case 'AllowUsePivotTables'*/:\n break;\n case 'zeroheight' /*case 'ZeroHeight'*/:\n break;\n case 'viewablerange' /*case 'ViewableRange'*/:\n break;\n case 'selection' /*case 'Selection'*/:\n break;\n case 'protectcontents' /*case 'ProtectContents'*/:\n break;\n default:\n seen = false;\n }\n break;\n\n /* PivotTable */\n case 'pivottable' /*case 'PivotTable'*/:\n case 'pivotcache' /*case 'PivotCache'*/:\n switch (Rn[3]) {\n case 'immediateitemsondrop' /*case 'ImmediateItemsOnDrop'*/:\n break;\n case 'showpagemultipleitemlabel' /*case 'ShowPageMultipleItemLabel'*/:\n break;\n case 'compactrowindent' /*case 'CompactRowIndent'*/:\n break;\n case 'location' /*case 'Location'*/:\n break;\n case 'pivotfield' /*case 'PivotField'*/:\n break;\n case 'orientation' /*case 'Orientation'*/:\n break;\n case 'layoutform' /*case 'LayoutForm'*/:\n break;\n case 'layoutsubtotallocation' /*case 'LayoutSubtotalLocation'*/:\n break;\n case 'layoutcompactrow' /*case 'LayoutCompactRow'*/:\n break;\n case 'position' /*case 'Position'*/:\n break;\n case 'pivotitem' /*case 'PivotItem'*/:\n break;\n case 'datatype' /*case 'DataType'*/:\n break;\n case 'datafield' /*case 'DataField'*/:\n break;\n case 'sourcename' /*case 'SourceName'*/:\n break;\n case 'parentfield' /*case 'ParentField'*/:\n break;\n case 'ptlineitems' /*case 'PTLineItems'*/:\n break;\n case 'ptlineitem' /*case 'PTLineItem'*/:\n break;\n case 'countofsameitems' /*case 'CountOfSameItems'*/:\n break;\n case 'item' /*case 'Item'*/:\n break;\n case 'itemtype' /*case 'ItemType'*/:\n break;\n case 'ptsource' /*case 'PTSource'*/:\n break;\n case 'cacheindex' /*case 'CacheIndex'*/:\n break;\n case 'consolidationreference' /*case 'ConsolidationReference'*/:\n break;\n case 'filename' /*case 'FileName'*/:\n break;\n case 'reference' /*case 'Reference'*/:\n break;\n case 'nocolumngrand' /*case 'NoColumnGrand'*/:\n break;\n case 'norowgrand' /*case 'NoRowGrand'*/:\n break;\n case 'blanklineafteritems' /*case 'BlankLineAfterItems'*/:\n break;\n case 'hidden' /*case 'Hidden'*/:\n break;\n case 'subtotal' /*case 'Subtotal'*/:\n break;\n case 'basefield' /*case 'BaseField'*/:\n break;\n case 'mapchilditems' /*case 'MapChildItems'*/:\n break;\n case 'function' /*case 'Function'*/:\n break;\n case 'refreshonfileopen' /*case 'RefreshOnFileOpen'*/:\n break;\n case 'printsettitles' /*case 'PrintSetTitles'*/:\n break;\n case 'mergelabels' /*case 'MergeLabels'*/:\n break;\n case 'defaultversion' /*case 'DefaultVersion'*/:\n break;\n case 'refreshname' /*case 'RefreshName'*/:\n break;\n case 'refreshdate' /*case 'RefreshDate'*/:\n break;\n case 'refreshdatecopy' /*case 'RefreshDateCopy'*/:\n break;\n case 'versionlastrefresh' /*case 'VersionLastRefresh'*/:\n break;\n case 'versionlastupdate' /*case 'VersionLastUpdate'*/:\n break;\n case 'versionupdateablemin' /*case 'VersionUpdateableMin'*/:\n break;\n case 'versionrefreshablemin' /*case 'VersionRefreshableMin'*/:\n break;\n case 'calculation' /*case 'Calculation'*/:\n break;\n default:\n seen = false;\n }\n break;\n\n /* PageBreaks */\n case 'pagebreaks' /*case 'PageBreaks'*/:\n switch (Rn[3]) {\n case 'colbreaks' /*case 'ColBreaks'*/:\n break;\n case 'colbreak' /*case 'ColBreak'*/:\n break;\n case 'rowbreaks' /*case 'RowBreaks'*/:\n break;\n case 'rowbreak' /*case 'RowBreak'*/:\n break;\n case 'colstart' /*case 'ColStart'*/:\n break;\n case 'colend' /*case 'ColEnd'*/:\n break;\n case 'rowend' /*case 'RowEnd'*/:\n break;\n default:\n seen = false;\n }\n break;\n\n /* AutoFilter */\n case 'autofilter' /*case 'AutoFilter'*/:\n switch (Rn[3]) {\n case 'autofiltercolumn' /*case 'AutoFilterColumn'*/:\n break;\n case 'autofiltercondition' /*case 'AutoFilterCondition'*/:\n break;\n case 'autofilterand' /*case 'AutoFilterAnd'*/:\n break;\n case 'autofilteror' /*case 'AutoFilterOr'*/:\n break;\n default:\n seen = false;\n }\n break;\n\n /* QueryTable */\n case 'querytable' /*case 'QueryTable'*/:\n switch (Rn[3]) {\n case 'id' /*case 'Id'*/:\n break;\n case 'autoformatfont' /*case 'AutoFormatFont'*/:\n break;\n case 'autoformatpattern' /*case 'AutoFormatPattern'*/:\n break;\n case 'querysource' /*case 'QuerySource'*/:\n break;\n case 'querytype' /*case 'QueryType'*/:\n break;\n case 'enableredirections' /*case 'EnableRedirections'*/:\n break;\n case 'refreshedinxl9' /*case 'RefreshedInXl9'*/:\n break;\n case 'urlstring' /*case 'URLString'*/:\n break;\n case 'htmltables' /*case 'HTMLTables'*/:\n break;\n case 'connection' /*case 'Connection'*/:\n break;\n case 'commandtext' /*case 'CommandText'*/:\n break;\n case 'refreshinfo' /*case 'RefreshInfo'*/:\n break;\n case 'notitles' /*case 'NoTitles'*/:\n break;\n case 'nextid' /*case 'NextId'*/:\n break;\n case 'columninfo' /*case 'ColumnInfo'*/:\n break;\n case 'overwritecells' /*case 'OverwriteCells'*/:\n break;\n case 'donotpromptforfile' /*case 'DoNotPromptForFile'*/:\n break;\n case 'textwizardsettings' /*case 'TextWizardSettings'*/:\n break;\n case 'source' /*case 'Source'*/:\n break;\n case 'number' /*case 'Number'*/:\n break;\n case 'decimal' /*case 'Decimal'*/:\n break;\n case 'thousandseparator' /*case 'ThousandSeparator'*/:\n break;\n case 'trailingminusnumbers' /*case 'TrailingMinusNumbers'*/:\n break;\n case 'formatsettings' /*case 'FormatSettings'*/:\n break;\n case 'fieldtype' /*case 'FieldType'*/:\n break;\n case 'delimiters' /*case 'Delimiters'*/:\n break;\n case 'tab' /*case 'Tab'*/:\n break;\n case 'comma' /*case 'Comma'*/:\n break;\n case 'autoformatname' /*case 'AutoFormatName'*/:\n break;\n case 'versionlastedit' /*case 'VersionLastEdit'*/:\n break;\n case 'versionlastrefresh' /*case 'VersionLastRefresh'*/:\n break;\n default:\n seen = false;\n }\n break;\n case 'datavalidation' /*case 'DataValidation'*/:\n switch (Rn[3]) {\n case 'range' /*case 'Range'*/:\n break;\n case 'type' /*case 'Type'*/:\n break;\n case 'min' /*case 'Min'*/:\n break;\n case 'max' /*case 'Max'*/:\n break;\n case 'sort' /*case 'Sort'*/:\n break;\n case 'descending' /*case 'Descending'*/:\n break;\n case 'order' /*case 'Order'*/:\n break;\n case 'casesensitive' /*case 'CaseSensitive'*/:\n break;\n case 'value' /*case 'Value'*/:\n break;\n case 'errorstyle' /*case 'ErrorStyle'*/:\n break;\n case 'errormessage' /*case 'ErrorMessage'*/:\n break;\n case 'errortitle' /*case 'ErrorTitle'*/:\n break;\n case 'inputmessage' /*case 'InputMessage'*/:\n break;\n case 'inputtitle' /*case 'InputTitle'*/:\n break;\n case 'combohide' /*case 'ComboHide'*/:\n break;\n case 'inputhide' /*case 'InputHide'*/:\n break;\n case 'condition' /*case 'Condition'*/:\n break;\n case 'qualifier' /*case 'Qualifier'*/:\n break;\n case 'useblank' /*case 'UseBlank'*/:\n break;\n case 'value1' /*case 'Value1'*/:\n break;\n case 'value2' /*case 'Value2'*/:\n break;\n case 'format' /*case 'Format'*/:\n break;\n case 'cellrangelist' /*case 'CellRangeList'*/:\n break;\n default:\n seen = false;\n }\n break;\n case 'sorting' /*case 'Sorting'*/:\n case 'conditionalformatting' /*case 'ConditionalFormatting'*/:\n switch (Rn[3]) {\n case 'range' /*case 'Range'*/:\n break;\n case 'type' /*case 'Type'*/:\n break;\n case 'min' /*case 'Min'*/:\n break;\n case 'max' /*case 'Max'*/:\n break;\n case 'sort' /*case 'Sort'*/:\n break;\n case 'descending' /*case 'Descending'*/:\n break;\n case 'order' /*case 'Order'*/:\n break;\n case 'casesensitive' /*case 'CaseSensitive'*/:\n break;\n case 'value' /*case 'Value'*/:\n break;\n case 'errorstyle' /*case 'ErrorStyle'*/:\n break;\n case 'errormessage' /*case 'ErrorMessage'*/:\n break;\n case 'errortitle' /*case 'ErrorTitle'*/:\n break;\n case 'cellrangelist' /*case 'CellRangeList'*/:\n break;\n case 'inputmessage' /*case 'InputMessage'*/:\n break;\n case 'inputtitle' /*case 'InputTitle'*/:\n break;\n case 'combohide' /*case 'ComboHide'*/:\n break;\n case 'inputhide' /*case 'InputHide'*/:\n break;\n case 'condition' /*case 'Condition'*/:\n break;\n case 'qualifier' /*case 'Qualifier'*/:\n break;\n case 'useblank' /*case 'UseBlank'*/:\n break;\n case 'value1' /*case 'Value1'*/:\n break;\n case 'value2' /*case 'Value2'*/:\n break;\n case 'format' /*case 'Format'*/:\n break;\n default:\n seen = false;\n }\n break;\n\n /* MapInfo (schema) */\n case 'mapinfo' /*case 'MapInfo'*/:\n case 'schema' /*case 'Schema'*/:\n case 'data' /*case 'data'*/:\n switch (Rn[3]) {\n case 'map' /*case 'Map'*/:\n break;\n case 'entry' /*case 'Entry'*/:\n break;\n case 'range' /*case 'Range'*/:\n break;\n case 'xpath' /*case 'XPath'*/:\n break;\n case 'field' /*case 'Field'*/:\n break;\n case 'xsdtype' /*case 'XSDType'*/:\n break;\n case 'filteron' /*case 'FilterOn'*/:\n break;\n case 'aggregate' /*case 'Aggregate'*/:\n break;\n case 'elementtype' /*case 'ElementType'*/:\n break;\n case 'attributetype' /*case 'AttributeType'*/:\n break;\n /* These are from xsd (XML Schema Definition) */\n case 'schema' /*case 'schema'*/:\n case 'element' /*case 'element'*/:\n case 'complextype' /*case 'complexType'*/:\n case 'datatype' /*case 'datatype'*/:\n case 'all' /*case 'all'*/:\n case 'attribute' /*case 'attribute'*/:\n case 'extends' /*case 'extends'*/:\n break;\n case 'row' /*case 'row'*/:\n break;\n default:\n seen = false;\n }\n break;\n\n /* SmartTags (can be anything) */\n case 'smarttags' /*case 'SmartTags'*/:\n break;\n default:\n seen = false;\n break;\n }\n if (seen) break;\n /* CustomDocumentProperties */\n if (Rn[3].match(/!\\[CDATA/)) break;\n if (!state[state.length - 1][1]) throw 'Unrecognized tag: ' + Rn[3] + \"|\" + state.join(\"|\");\n if (state[state.length - 1][0] === /*'CustomDocumentProperties'*/'customdocumentproperties') {\n if (Rn[0].slice(-2) === \"/>\") break;else if (Rn[1] === \"/\") xlml_set_custprop(Custprops, raw_Rn3, cp, str.slice(pidx, Rn.index));else {\n cp = Rn;\n pidx = Rn.index + Rn[0].length;\n }\n break;\n }\n if (opts.WTF) throw 'Unrecognized tag: ' + Rn[3] + \"|\" + state.join(\"|\");\n }\n var out = {} /*:any*/;\n if (!opts.bookSheets && !opts.bookProps) out.Sheets = sheets;\n out.SheetNames = sheetnames;\n out.Workbook = Workbook;\n out.SSF = dup(table_fmt);\n out.Props = Props;\n out.Custprops = Custprops;\n return out;\n}\nfunction parse_xlml(data /*:RawBytes|string*/, opts) /*:Workbook*/{\n fix_read_opts(opts = opts || {});\n switch (opts.type || \"base64\") {\n case \"base64\":\n return parse_xlml_xml(Base64_decode(data), opts);\n case \"binary\":\n case \"buffer\":\n case \"file\":\n return parse_xlml_xml(data, opts);\n case \"array\":\n return parse_xlml_xml(a2s(data), opts);\n }\n /*:: throw new Error(\"unsupported type \" + opts.type); */\n}\n\n/* TODO */\nfunction write_props_xlml(wb /*:Workbook*/, opts) /*:string*/{\n var o /*:Array*/ = [];\n /* DocumentProperties */\n if (wb.Props) o.push(xlml_write_docprops(wb.Props, opts));\n /* CustomDocumentProperties */\n if (wb.Custprops) o.push(xlml_write_custprops(wb.Props, wb.Custprops, opts));\n return o.join(\"\");\n}\n/* TODO */\nfunction write_wb_xlml(/*::wb, opts*/\n) /*:string*/{\n /* OfficeDocumentSettings */\n /* ExcelWorkbook */\n return \"\";\n}\n/* TODO */\nfunction write_sty_xlml(wb, opts) /*:string*/{\n /* Styles */\n var styles /*:Array*/ = [''];\n opts.cellXfs.forEach(function (xf, id) {\n var payload /*:Array*/ = [];\n payload.push(writextag('NumberFormat', null, {\n \"ss:Format\": escapexml(table_fmt[xf.numFmtId])\n }));\n var o = /*::(*/{\n \"ss:ID\": \"s\" + (21 + id)\n } /*:: :any)*/;\n styles.push(writextag('Style', payload.join(\"\"), o));\n });\n return writextag(\"Styles\", styles.join(\"\"));\n}\nfunction write_name_xlml(n) {\n return writextag(\"NamedRange\", null, {\n \"ss:Name\": n.Name,\n \"ss:RefersTo\": \"=\" + a1_to_rc(n.Ref, {\n r: 0,\n c: 0\n })\n });\n}\nfunction write_names_xlml(wb /*::, opts*/) /*:string*/{\n if (!((wb || {}).Workbook || {}).Names) return \"\";\n /*:: if(!wb || !wb.Workbook || !wb.Workbook.Names) throw new Error(\"unreachable\"); */\n var names /*:Array*/ = wb.Workbook.Names;\n var out /*:Array*/ = [];\n for (var i = 0; i < names.length; ++i) {\n var n = names[i];\n if (n.Sheet != null) continue;\n if (n.Name.match(/^_xlfn\\./)) continue;\n out.push(write_name_xlml(n));\n }\n return writextag(\"Names\", out.join(\"\"));\n}\nfunction write_ws_xlml_names(ws /*:Worksheet*/, opts, idx /*:number*/, wb /*:Workbook*/) /*:string*/{\n if (!ws) return \"\";\n if (!((wb || {}).Workbook || {}).Names) return \"\";\n /*:: if(!wb || !wb.Workbook || !wb.Workbook.Names) throw new Error(\"unreachable\"); */\n var names /*:Array*/ = wb.Workbook.Names;\n var out /*:Array*/ = [];\n for (var i = 0; i < names.length; ++i) {\n var n = names[i];\n if (n.Sheet != idx) continue;\n /*switch(n.Name) {\n \tcase \"_\": continue;\n }*/\n if (n.Name.match(/^_xlfn\\./)) continue;\n out.push(write_name_xlml(n));\n }\n return out.join(\"\");\n}\n/* WorksheetOptions */\nfunction write_ws_xlml_wsopts(ws /*:Worksheet*/, opts, idx /*:number*/, wb /*:Workbook*/) /*:string*/{\n if (!ws) return \"\";\n var o /*:Array*/ = [];\n /* NOTE: spec technically allows any order, but stick with implied order */\n\n /* FitToPage */\n /* DoNotDisplayColHeaders */\n /* DoNotDisplayRowHeaders */\n /* ViewableRange */\n /* Selection */\n /* GridlineColor */\n /* Name */\n /* ExcelWorksheetType */\n /* IntlMacro */\n /* Unsynced */\n /* Selected */\n /* CodeName */\n\n if (ws['!margins']) {\n o.push(\"\");\n if (ws['!margins'].header) o.push(writextag(\"Header\", null, {\n 'x:Margin': ws['!margins'].header\n }));\n if (ws['!margins'].footer) o.push(writextag(\"Footer\", null, {\n 'x:Margin': ws['!margins'].footer\n }));\n o.push(writextag(\"PageMargins\", null, {\n 'x:Bottom': ws['!margins'].bottom || \"0.75\",\n 'x:Left': ws['!margins'].left || \"0.7\",\n 'x:Right': ws['!margins'].right || \"0.7\",\n 'x:Top': ws['!margins'].top || \"0.75\"\n }));\n o.push(\"\");\n }\n\n /* PageSetup */\n /* DisplayPageBreak */\n /* TransitionExpressionEvaluation */\n /* TransitionFormulaEntry */\n /* Print */\n /* Zoom */\n /* PageLayoutZoom */\n /* PageBreakZoom */\n /* ShowPageBreakZoom */\n /* DefaultRowHeight */\n /* DefaultColumnWidth */\n /* StandardWidth */\n\n if (wb && wb.Workbook && wb.Workbook.Sheets && wb.Workbook.Sheets[idx]) {\n /* Visible */\n if (wb.Workbook.Sheets[idx].Hidden) o.push(writextag(\"Visible\", wb.Workbook.Sheets[idx].Hidden == 1 ? \"SheetHidden\" : \"SheetVeryHidden\", {}));else {\n /* Selected */\n for (var i = 0; i < idx; ++i) if (wb.Workbook.Sheets[i] && !wb.Workbook.Sheets[i].Hidden) break;\n if (i == idx) o.push(\"\");\n }\n }\n\n /* LeftColumnVisible */\n\n if (((((wb || {}).Workbook || {}).Views || [])[0] || {}).RTL) o.push(\"\");\n\n /* GridlineColorIndex */\n /* DisplayFormulas */\n /* DoNotDisplayGridlines */\n /* DoNotDisplayHeadings */\n /* DoNotDisplayOutline */\n /* ApplyAutomaticOutlineStyles */\n /* NoSummaryRowsBelowDetail */\n /* NoSummaryColumnsRightDetail */\n /* DoNotDisplayZeros */\n /* ActiveRow */\n /* ActiveColumn */\n /* FilterOn */\n /* RangeSelection */\n /* TopRowVisible */\n /* TopRowBottomPane */\n /* LeftColumnRightPane */\n /* ActivePane */\n /* SplitHorizontal */\n /* SplitVertical */\n /* FreezePanes */\n /* FrozenNoSplit */\n /* TabColorIndex */\n /* Panes */\n\n /* NOTE: Password not supported in XLML Format */\n if (ws['!protect']) {\n o.push(writetag(\"ProtectContents\", \"True\"));\n if (ws['!protect'].objects) o.push(writetag(\"ProtectObjects\", \"True\"));\n if (ws['!protect'].scenarios) o.push(writetag(\"ProtectScenarios\", \"True\"));\n if (ws['!protect'].selectLockedCells != null && !ws['!protect'].selectLockedCells) o.push(writetag(\"EnableSelection\", \"NoSelection\"));else if (ws['!protect'].selectUnlockedCells != null && !ws['!protect'].selectUnlockedCells) o.push(writetag(\"EnableSelection\", \"UnlockedCells\"));\n [[\"formatCells\", \"AllowFormatCells\"], [\"formatColumns\", \"AllowSizeCols\"], [\"formatRows\", \"AllowSizeRows\"], [\"insertColumns\", \"AllowInsertCols\"], [\"insertRows\", \"AllowInsertRows\"], [\"insertHyperlinks\", \"AllowInsertHyperlinks\"], [\"deleteColumns\", \"AllowDeleteCols\"], [\"deleteRows\", \"AllowDeleteRows\"], [\"sort\", \"AllowSort\"], [\"autoFilter\", \"AllowFilter\"], [\"pivotTables\", \"AllowUsePivotTables\"]].forEach(function (x) {\n if (ws['!protect'][x[0]]) o.push(\"<\" + x[1] + \"/>\");\n });\n }\n if (o.length == 0) return \"\";\n return writextag(\"WorksheetOptions\", o.join(\"\"), {\n xmlns: XLMLNS.x\n });\n}\nfunction write_ws_xlml_comment(comments /*:Array*/) /*:string*/{\n return comments.map(function (c) {\n // TODO: formatted text\n var t = xlml_unfixstr(c.t || \"\");\n var d = writextag(\"ss:Data\", t, {\n \"xmlns\": \"http://www.w3.org/TR/REC-html40\"\n });\n return writextag(\"Comment\", d, {\n \"ss:Author\": c.a\n });\n }).join(\"\");\n}\nfunction write_ws_xlml_cell(cell, ref /*:string*/, ws, opts, idx /*:number*/, wb, addr) /*:string*/{\n if (!cell || cell.v == undefined && cell.f == undefined) return \"\";\n var attr = {};\n if (cell.f) attr[\"ss:Formula\"] = \"=\" + escapexml(a1_to_rc(cell.f, addr));\n if (cell.F && cell.F.slice(0, ref.length) == ref) {\n var end = decode_cell(cell.F.slice(ref.length + 1));\n attr[\"ss:ArrayRange\"] = \"RC:R\" + (end.r == addr.r ? \"\" : \"[\" + (end.r - addr.r) + \"]\") + \"C\" + (end.c == addr.c ? \"\" : \"[\" + (end.c - addr.c) + \"]\");\n }\n if (cell.l && cell.l.Target) {\n attr[\"ss:HRef\"] = escapexml(cell.l.Target);\n if (cell.l.Tooltip) attr[\"x:HRefScreenTip\"] = escapexml(cell.l.Tooltip);\n }\n if (ws['!merges']) {\n var marr = ws['!merges'];\n for (var mi = 0; mi != marr.length; ++mi) {\n if (marr[mi].s.c != addr.c || marr[mi].s.r != addr.r) continue;\n if (marr[mi].e.c > marr[mi].s.c) attr['ss:MergeAcross'] = marr[mi].e.c - marr[mi].s.c;\n if (marr[mi].e.r > marr[mi].s.r) attr['ss:MergeDown'] = marr[mi].e.r - marr[mi].s.r;\n }\n }\n var t = \"\",\n p = \"\";\n switch (cell.t) {\n case 'z':\n if (!opts.sheetStubs) return \"\";\n break;\n case 'n':\n t = 'Number';\n p = String(cell.v);\n break;\n case 'b':\n t = 'Boolean';\n p = cell.v ? \"1\" : \"0\";\n break;\n case 'e':\n t = 'Error';\n p = BErr[cell.v];\n break;\n case 'd':\n t = 'DateTime';\n p = new Date(cell.v).toISOString();\n if (cell.z == null) cell.z = cell.z || table_fmt[14];\n break;\n case 's':\n t = 'String';\n p = escapexlml(cell.v || \"\");\n break;\n }\n /* TODO: cell style */\n var os = get_cell_style(opts.cellXfs, cell, opts);\n attr[\"ss:StyleID\"] = \"s\" + (21 + os);\n attr[\"ss:Index\"] = addr.c + 1;\n var _v = cell.v != null ? p : \"\";\n var m = cell.t == 'z' ? \"\" : '' + _v + '';\n if ((cell.c || []).length > 0) m += write_ws_xlml_comment(cell.c);\n return writextag(\"Cell\", m, attr);\n}\nfunction write_ws_xlml_row(R /*:number*/, row) /*:string*/{\n var o = '';\n}\n/* TODO */\nfunction write_ws_xlml_table(ws /*:Worksheet*/, opts, idx /*:number*/, wb /*:Workbook*/) /*:string*/{\n if (!ws['!ref']) return \"\";\n var range /*:Range*/ = safe_decode_range(ws['!ref']);\n var marr /*:Array*/ = ws['!merges'] || [],\n mi = 0;\n var o /*:Array*/ = [];\n if (ws['!cols']) ws['!cols'].forEach(function (n, i) {\n process_col(n);\n var w = !!n.width;\n var p = col_obj_w(i, n);\n var k /*:any*/ = {\n \"ss:Index\": i + 1\n };\n if (w) k['ss:Width'] = width2px(p.width);\n if (n.hidden) k['ss:Hidden'] = \"1\";\n o.push(writextag(\"Column\", null, k));\n });\n var dense = Array.isArray(ws);\n for (var R = range.s.r; R <= range.e.r; ++R) {\n var row = [write_ws_xlml_row(R, (ws['!rows'] || [])[R])];\n for (var C = range.s.c; C <= range.e.c; ++C) {\n var skip = false;\n for (mi = 0; mi != marr.length; ++mi) {\n if (marr[mi].s.c > C) continue;\n if (marr[mi].s.r > R) continue;\n if (marr[mi].e.c < C) continue;\n if (marr[mi].e.r < R) continue;\n if (marr[mi].s.c != C || marr[mi].s.r != R) skip = true;\n break;\n }\n if (skip) continue;\n var addr = {\n r: R,\n c: C\n };\n var ref = encode_cell(addr),\n cell = dense ? (ws[R] || [])[C] : ws[ref];\n row.push(write_ws_xlml_cell(cell, ref, ws, opts, idx, wb, addr));\n }\n row.push(\"\");\n if (row.length > 2) o.push(row.join(\"\"));\n }\n return o.join(\"\");\n}\nfunction write_ws_xlml(idx /*:number*/, opts, wb /*:Workbook*/) /*:string*/{\n var o /*:Array*/ = [];\n var s = wb.SheetNames[idx];\n var ws = wb.Sheets[s];\n var t /*:string*/ = ws ? write_ws_xlml_names(ws, opts, idx, wb) : \"\";\n if (t.length > 0) o.push(\"\" + t + \"\");\n\n /* Table */\n t = ws ? write_ws_xlml_table(ws, opts, idx, wb) : \"\";\n if (t.length > 0) o.push(\"
\" + t + \"
\");\n\n /* WorksheetOptions */\n o.push(write_ws_xlml_wsopts(ws, opts, idx, wb));\n return o.join(\"\");\n}\nfunction write_xlml(wb, opts) /*:string*/{\n if (!opts) opts = {};\n if (!wb.SSF) wb.SSF = dup(table_fmt);\n if (wb.SSF) {\n make_ssf();\n SSF_load_table(wb.SSF);\n // $FlowIgnore\n opts.revssf = evert_num(wb.SSF);\n opts.revssf[wb.SSF[65535]] = 0;\n opts.ssf = wb.SSF;\n opts.cellXfs = [];\n get_cell_style(opts.cellXfs, {}, {\n revssf: {\n \"General\": 0\n }\n });\n }\n var d /*:Array*/ = [];\n d.push(write_props_xlml(wb, opts));\n d.push(write_wb_xlml(wb, opts));\n d.push(\"\");\n d.push(\"\");\n for (var i = 0; i < wb.SheetNames.length; ++i) d.push(writextag(\"Worksheet\", write_ws_xlml(i, opts, wb), {\n \"ss:Name\": escapexml(wb.SheetNames[i])\n }));\n d[2] = write_sty_xlml(wb, opts);\n d[3] = write_names_xlml(wb, opts);\n return XML_HEADER + writextag(\"Workbook\", d.join(\"\"), {\n 'xmlns': XLMLNS.ss,\n 'xmlns:o': XLMLNS.o,\n 'xmlns:x': XLMLNS.x,\n 'xmlns:ss': XLMLNS.ss,\n 'xmlns:dt': XLMLNS.dt,\n 'xmlns:html': XLMLNS.html\n });\n}\n/* [MS-OLEDS] 2.3.8 CompObjStream */\nfunction parse_compobj(obj /*:CFBEntry*/) {\n var v = {};\n var o = obj.content;\n /*:: if(o == null) return; */\n\n /* [MS-OLEDS] 2.3.7 CompObjHeader -- All fields MUST be ignored */\n o.l = 28;\n v.AnsiUserType = o.read_shift(0, \"lpstr-ansi\");\n v.AnsiClipboardFormat = parse_ClipboardFormatOrAnsiString(o);\n if (o.length - o.l <= 4) return v;\n var m /*:number*/ = o.read_shift(4);\n if (m == 0 || m > 40) return v;\n o.l -= 4;\n v.Reserved1 = o.read_shift(0, \"lpstr-ansi\");\n if (o.length - o.l <= 4) return v;\n m = o.read_shift(4);\n if (m !== 0x71b239f4) return v;\n v.UnicodeClipboardFormat = parse_ClipboardFormatOrUnicodeString(o);\n m = o.read_shift(4);\n if (m == 0 || m > 40) return v;\n o.l -= 4;\n v.Reserved2 = o.read_shift(0, \"lpwstr\");\n}\n\n/*\n\tContinue logic for:\n\t- 2.4.58 Continue 0x003c\n\t- 2.4.59 ContinueBigName 0x043c\n\t- 2.4.60 ContinueFrt 0x0812\n\t- 2.4.61 ContinueFrt11 0x0875\n\t- 2.4.62 ContinueFrt12 0x087f\n*/\nvar CONTINUE_RT = [0x003c, 0x043c, 0x0812, 0x0875, 0x087f];\nfunction slurp(RecordType, R, blob, length /*:number*/, opts) /*:any*/{\n var l = length;\n var bufs = [];\n var d = blob.slice(blob.l, blob.l + l);\n if (opts && opts.enc && opts.enc.insitu && d.length > 0) switch (RecordType) {\n case 0x0009:\n case 0x0209:\n case 0x0409:\n case 0x0809 /* BOF */:\n case 0x002f /* FilePass */:\n case 0x0195 /* FileLock */:\n case 0x00e1 /* InterfaceHdr */:\n case 0x0196 /* RRDInfo */:\n case 0x0138 /* RRDHead */:\n case 0x0194 /* UsrExcl */:\n case 0x000a /* EOF */:\n break;\n case 0x0085 /* BoundSheet8 */:\n break;\n default:\n opts.enc.insitu(d);\n }\n bufs.push(d);\n blob.l += l;\n var nextrt = __readUInt16LE(blob, blob.l),\n next = XLSRecordEnum[nextrt];\n var start = 0;\n while (next != null && CONTINUE_RT.indexOf(nextrt) > -1) {\n l = __readUInt16LE(blob, blob.l + 2);\n start = blob.l + 4;\n if (nextrt == 0x0812 /* ContinueFrt */) start += 4;else if (nextrt == 0x0875 || nextrt == 0x087f) {\n start += 12;\n }\n d = blob.slice(start, blob.l + 4 + l);\n bufs.push(d);\n blob.l += 4 + l;\n next = XLSRecordEnum[nextrt = __readUInt16LE(blob, blob.l)];\n }\n var b = bconcat(bufs) /*:any*/;\n prep_blob(b, 0);\n var ll = 0;\n b.lens = [];\n for (var j = 0; j < bufs.length; ++j) {\n b.lens.push(ll);\n ll += bufs[j].length;\n }\n if (b.length < length) throw \"XLS Record 0x\" + RecordType.toString(16) + \" Truncated: \" + b.length + \" < \" + length;\n return R.f(b, b.length, opts);\n}\nfunction safe_format_xf(p /*:any*/, opts /*:ParseOpts*/, date1904 /*:?boolean*/) {\n if (p.t === 'z') return;\n if (!p.XF) return;\n var fmtid = 0;\n try {\n fmtid = p.z || p.XF.numFmtId || 0;\n if (opts.cellNF) p.z = table_fmt[fmtid];\n } catch (e) {\n if (opts.WTF) throw e;\n }\n if (!opts || opts.cellText !== false) try {\n if (p.t === 'e') {\n p.w = p.w || BErr[p.v];\n } else if (fmtid === 0 || fmtid == \"General\") {\n if (p.t === 'n') {\n if ((p.v | 0) === p.v) p.w = p.v.toString(10);else p.w = SSF_general_num(p.v);\n } else p.w = SSF_general(p.v);\n } else p.w = SSF_format(fmtid, p.v, {\n date1904: !!date1904,\n dateNF: opts && opts.dateNF\n });\n } catch (e) {\n if (opts.WTF) throw e;\n }\n if (opts.cellDates && fmtid && p.t == 'n' && fmt_is_date(table_fmt[fmtid] || String(fmtid))) {\n var _d = SSF_parse_date_code(p.v);\n if (_d) {\n p.t = 'd';\n p.v = new Date(_d.y, _d.m - 1, _d.d, _d.H, _d.M, _d.S, _d.u);\n }\n }\n}\nfunction make_cell(val, ixfe, t) /*:Cell*/{\n return {\n v: val,\n ixfe: ixfe,\n t: t\n } /*:any*/;\n}\n\n// 2.3.2\nfunction parse_workbook(blob, options /*:ParseOpts*/) /*:Workbook*/{\n var wb = {\n opts: {}\n } /*:any*/;\n var Sheets = {};\n if (DENSE != null && options.dense == null) options.dense = DENSE;\n var out /*:Worksheet*/ = options.dense ? [] : {} /*:any*/;\n var Directory = {};\n var range /*:Range*/ = {} /*:any*/;\n var last_formula = null;\n var sst /*:SST*/ = [] /*:any*/;\n var cur_sheet = \"\";\n var Preamble = {};\n var lastcell,\n last_cell = \"\",\n cc /*:Cell*/,\n cmnt,\n rngC,\n rngR;\n var sharedf = {};\n var arrayf /*:Array<[Range, string]>*/ = [];\n var temp_val /*:Cell*/;\n var country;\n var XFs = []; /* XF records */\n var palette /*:Array<[number, number, number]>*/ = [];\n var Workbook /*:WBWBProps*/ = {\n Sheets: [],\n WBProps: {\n date1904: false\n },\n Views: [{}]\n } /*:any*/,\n wsprops = {};\n var get_rgb = function getrgb(icv /*:number*/) /*:[number, number, number]*/{\n if (icv < 8) return XLSIcv[icv];\n if (icv < 64) return palette[icv - 8] || XLSIcv[icv];\n return XLSIcv[icv];\n };\n var process_cell_style = function pcs(cell, line /*:any*/, options) {\n var xfd = line.XF.data;\n if (!xfd || !xfd.patternType || !options || !options.cellStyles) return;\n line.s = {} /*:any*/;\n line.s.patternType = xfd.patternType;\n var t;\n if (t = rgb2Hex(get_rgb(xfd.icvFore))) {\n line.s.fgColor = {\n rgb: t\n };\n }\n if (t = rgb2Hex(get_rgb(xfd.icvBack))) {\n line.s.bgColor = {\n rgb: t\n };\n }\n };\n var addcell = function addcell(cell /*:any*/, line /*:any*/, options /*:any*/) {\n if (file_depth > 1) return;\n if (options.sheetRows && cell.r >= options.sheetRows) return;\n if (options.cellStyles && line.XF && line.XF.data) process_cell_style(cell, line, options);\n delete line.ixfe;\n delete line.XF;\n lastcell = cell;\n last_cell = encode_cell(cell);\n if (!range || !range.s || !range.e) range = {\n s: {\n r: 0,\n c: 0\n },\n e: {\n r: 0,\n c: 0\n }\n };\n if (cell.r < range.s.r) range.s.r = cell.r;\n if (cell.c < range.s.c) range.s.c = cell.c;\n if (cell.r + 1 > range.e.r) range.e.r = cell.r + 1;\n if (cell.c + 1 > range.e.c) range.e.c = cell.c + 1;\n if (options.cellFormula && line.f) {\n for (var afi = 0; afi < arrayf.length; ++afi) {\n if (arrayf[afi][0].s.c > cell.c || arrayf[afi][0].s.r > cell.r) continue;\n if (arrayf[afi][0].e.c < cell.c || arrayf[afi][0].e.r < cell.r) continue;\n line.F = encode_range(arrayf[afi][0]);\n if (arrayf[afi][0].s.c != cell.c || arrayf[afi][0].s.r != cell.r) delete line.f;\n if (line.f) line.f = \"\" + stringify_formula(arrayf[afi][1], range, cell, supbooks, opts);\n break;\n }\n }\n {\n if (options.dense) {\n if (!out[cell.r]) out[cell.r] = [];\n out[cell.r][cell.c] = line;\n } else out[last_cell] = line;\n }\n };\n var opts = {\n enc: false,\n // encrypted\n sbcch: 0,\n // cch in the preceding SupBook\n snames: [],\n // sheetnames\n sharedf: sharedf,\n // shared formulae by address\n arrayf: arrayf,\n // array formulae array\n rrtabid: [],\n // RRTabId\n lastuser: \"\",\n // Last User from WriteAccess\n biff: 8,\n // BIFF version\n codepage: 0,\n // CP from CodePage record\n winlocked: 0,\n // fLockWn from WinProtect\n cellStyles: !!options && !!options.cellStyles,\n WTF: !!options && !!options.wtf\n } /*:any*/;\n if (options.password) opts.password = options.password;\n var themes;\n var merges /*:Array*/ = [];\n var objects = [];\n var colinfo /*:Array*/ = [],\n rowinfo /*:Array*/ = [];\n var seencol = false;\n var supbooks = [] /*:any*/; // 1-indexed, will hold extern names\n supbooks.SheetNames = opts.snames;\n supbooks.sharedf = opts.sharedf;\n supbooks.arrayf = opts.arrayf;\n supbooks.names = [];\n supbooks.XTI = [];\n var last_RT = 0;\n var file_depth = 0; /* TODO: make a real stack */\n var BIFF2Fmt = 0,\n BIFF2FmtTable /*:Array*/ = [];\n var FilterDatabases = []; /* TODO: sort out supbooks and process elsewhere */\n var last_lbl /*:?DefinedName*/;\n\n /* explicit override for some broken writers */\n opts.codepage = 1200;\n set_cp(1200);\n var seen_codepage = false;\n while (blob.l < blob.length - 1) {\n var s = blob.l;\n var RecordType = blob.read_shift(2);\n if (RecordType === 0 && last_RT === 0x000a /* EOF */) break;\n var length = blob.l === blob.length ? 0 : blob.read_shift(2);\n var R = XLSRecordEnum[RecordType];\n //console.log(RecordType.toString(16), RecordType, R, blob.l, length, blob.length);\n //if(!R) console.log(blob.slice(blob.l, blob.l + length));\n if (R && R.f) {\n if (options.bookSheets) {\n if (last_RT === 0x0085 /* BoundSheet8 */ && RecordType !== 0x0085 /* R.n !== 'BoundSheet8' */) break;\n }\n last_RT = RecordType;\n if (R.r === 2 || R.r == 12) {\n var rt = blob.read_shift(2);\n length -= 2;\n if (!opts.enc && rt !== RecordType && ((rt & 0xFF) << 8 | rt >> 8) !== RecordType) throw new Error(\"rt mismatch: \" + rt + \"!=\" + RecordType);\n if (R.r == 12) {\n blob.l += 10;\n length -= 10;\n } // skip FRT\n }\n //console.error(R,blob.l,length,blob.length);\n var val /*:any*/ = {} /*:any*/;\n if (RecordType === 0x000a /* EOF */) val = /*::(*/R.f(blob, length, opts) /*:: :any)*/;else val = /*::(*/slurp(RecordType, R, blob, length, opts) /*:: :any)*/;\n /*:: val = (val:any); */\n if (file_depth == 0 && [0x0009, 0x0209, 0x0409, 0x0809].indexOf(last_RT) === -1 /* 'BOF' */) continue;\n switch (RecordType) {\n case 0x0022 /* Date1904 */:\n /*:: if(!Workbook.WBProps) Workbook.WBProps = {}; */\n wb.opts.Date1904 = Workbook.WBProps.date1904 = val;\n break;\n case 0x0086 /* WriteProtect */:\n wb.opts.WriteProtect = true;\n break;\n case 0x002f /* FilePass */:\n if (!opts.enc) blob.l = 0;\n opts.enc = val;\n if (!options.password) throw new Error(\"File is password-protected\");\n if (val.valid == null) throw new Error(\"Encryption scheme unsupported\");\n if (!val.valid) throw new Error(\"Password is incorrect\");\n break;\n case 0x005c /* WriteAccess */:\n opts.lastuser = val;\n break;\n case 0x0042 /* CodePage */:\n var cpval = Number(val);\n /* overrides based on test cases */\n switch (cpval) {\n case 0x5212:\n cpval = 1200;\n break;\n case 0x8000:\n cpval = 10000;\n break;\n case 0x8001:\n cpval = 1252;\n break;\n }\n set_cp(opts.codepage = cpval);\n seen_codepage = true;\n break;\n case 0x013d /* RRTabId */:\n opts.rrtabid = val;\n break;\n case 0x0019 /* WinProtect */:\n opts.winlocked = val;\n break;\n case 0x01b7 /* RefreshAll */:\n wb.opts[\"RefreshAll\"] = val;\n break;\n case 0x000c /* CalcCount */:\n wb.opts[\"CalcCount\"] = val;\n break;\n case 0x0010 /* CalcDelta */:\n wb.opts[\"CalcDelta\"] = val;\n break;\n case 0x0011 /* CalcIter */:\n wb.opts[\"CalcIter\"] = val;\n break;\n case 0x000d /* CalcMode */:\n wb.opts[\"CalcMode\"] = val;\n break;\n case 0x000e /* CalcPrecision */:\n wb.opts[\"CalcPrecision\"] = val;\n break;\n case 0x005f /* CalcSaveRecalc */:\n wb.opts[\"CalcSaveRecalc\"] = val;\n break;\n case 0x000f /* CalcRefMode */:\n opts.CalcRefMode = val;\n break;\n // TODO: implement R1C1\n case 0x08a3 /* ForceFullCalculation */:\n wb.opts.FullCalc = val;\n break;\n case 0x0081 /* WsBool */:\n if (val.fDialog) out[\"!type\"] = \"dialog\";\n if (!val.fBelow) (out[\"!outline\"] || (out[\"!outline\"] = {})).above = true;\n if (!val.fRight) (out[\"!outline\"] || (out[\"!outline\"] = {})).left = true;\n break;\n // TODO\n case 0x00e0 /* XF */:\n XFs.push(val);\n break;\n case 0x01ae /* SupBook */:\n supbooks.push([val]);\n supbooks[supbooks.length - 1].XTI = [];\n break;\n case 0x0023:\n case 0x0223 /* ExternName */:\n supbooks[supbooks.length - 1].push(val);\n break;\n case 0x0018:\n case 0x0218 /* Lbl */:\n last_lbl = {\n Name: val.Name,\n Ref: stringify_formula(val.rgce, range, null, supbooks, opts)\n } /*:DefinedName*/;\n if (val.itab > 0) last_lbl.Sheet = val.itab - 1;\n supbooks.names.push(last_lbl);\n if (!supbooks[0]) {\n supbooks[0] = [];\n supbooks[0].XTI = [];\n }\n supbooks[supbooks.length - 1].push(val);\n if (val.Name == \"_xlnm._FilterDatabase\" && val.itab > 0) if (val.rgce && val.rgce[0] && val.rgce[0][0] && val.rgce[0][0][0] == 'PtgArea3d') FilterDatabases[val.itab - 1] = {\n ref: encode_range(val.rgce[0][0][1][2])\n };\n break;\n case 0x0016 /* ExternCount */:\n opts.ExternCount = val;\n break;\n case 0x0017 /* ExternSheet */:\n if (supbooks.length == 0) {\n supbooks[0] = [];\n supbooks[0].XTI = [];\n }\n supbooks[supbooks.length - 1].XTI = supbooks[supbooks.length - 1].XTI.concat(val);\n supbooks.XTI = supbooks.XTI.concat(val);\n break;\n case 0x0894 /* NameCmt */:\n /* TODO: search for correct name */\n if (opts.biff < 8) break;\n if (last_lbl != null) last_lbl.Comment = val[1];\n break;\n case 0x0012 /* Protect */:\n out[\"!protect\"] = val;\n break;\n /* for sheet or book */\n case 0x0013 /* Password */:\n if (val !== 0 && opts.WTF) console.error(\"Password verifier: \" + val);\n break;\n case 0x0085 /* BoundSheet8 */:\n {\n Directory[val.pos] = val;\n opts.snames.push(val.name);\n }\n break;\n case 0x000a /* EOF */:\n {\n if (--file_depth) break;\n if (range.e) {\n if (range.e.r > 0 && range.e.c > 0) {\n range.e.r--;\n range.e.c--;\n out[\"!ref\"] = encode_range(range);\n if (options.sheetRows && options.sheetRows <= range.e.r) {\n var tmpri = range.e.r;\n range.e.r = options.sheetRows - 1;\n out[\"!fullref\"] = out[\"!ref\"];\n out[\"!ref\"] = encode_range(range);\n range.e.r = tmpri;\n }\n range.e.r++;\n range.e.c++;\n }\n if (merges.length > 0) out[\"!merges\"] = merges;\n if (objects.length > 0) out[\"!objects\"] = objects;\n if (colinfo.length > 0) out[\"!cols\"] = colinfo;\n if (rowinfo.length > 0) out[\"!rows\"] = rowinfo;\n Workbook.Sheets.push(wsprops);\n }\n if (cur_sheet === \"\") Preamble = out;else Sheets[cur_sheet] = out;\n out = options.dense ? [] : {} /*:any*/;\n }\n break;\n case 0x0009:\n case 0x0209:\n case 0x0409:\n case 0x0809 /* BOF */:\n {\n if (opts.biff === 8) opts.biff = {\n /*::[*/0x0009 /*::]*/: 2,\n /*::[*/0x0209 /*::]*/: 3,\n /*::[*/0x0409 /*::]*/: 4\n }[RecordType] || {\n /*::[*/0x0200 /*::]*/: 2,\n /*::[*/0x0300 /*::]*/: 3,\n /*::[*/0x0400 /*::]*/: 4,\n /*::[*/0x0500 /*::]*/: 5,\n /*::[*/0x0600 /*::]*/: 8,\n /*::[*/0x0002 /*::]*/: 2,\n /*::[*/0x0007 /*::]*/: 2\n }[val.BIFFVer] || 8;\n opts.biffguess = val.BIFFVer == 0;\n if (val.BIFFVer == 0 && val.dt == 0x1000) {\n opts.biff = 5;\n seen_codepage = true;\n set_cp(opts.codepage = 28591);\n }\n if (opts.biff == 8 && val.BIFFVer == 0 && val.dt == 16) opts.biff = 2;\n if (file_depth++) break;\n out = options.dense ? [] : {} /*:any*/;\n if (opts.biff < 8 && !seen_codepage) {\n seen_codepage = true;\n set_cp(opts.codepage = options.codepage || 1252);\n }\n if (opts.biff < 5 || val.BIFFVer == 0 && val.dt == 0x1000) {\n if (cur_sheet === \"\") cur_sheet = \"Sheet1\";\n range = {\n s: {\n r: 0,\n c: 0\n },\n e: {\n r: 0,\n c: 0\n }\n };\n /* fake BoundSheet8 */\n var fakebs8 = {\n pos: blob.l - length,\n name: cur_sheet\n };\n Directory[fakebs8.pos] = fakebs8;\n opts.snames.push(cur_sheet);\n } else cur_sheet = (Directory[s] || {\n name: \"\"\n }).name;\n if (val.dt == 0x20) out[\"!type\"] = \"chart\";\n if (val.dt == 0x40) out[\"!type\"] = \"macro\";\n merges = [];\n objects = [];\n opts.arrayf = arrayf = [];\n colinfo = [];\n rowinfo = [];\n seencol = false;\n wsprops = {\n Hidden: (Directory[s] || {\n hs: 0\n }).hs,\n name: cur_sheet\n };\n }\n break;\n case 0x0203 /* Number */:\n case 0x0003 /* BIFF2NUM */:\n case 0x0002 /* BIFF2INT */:\n {\n if (out[\"!type\"] == \"chart\") if (options.dense ? (out[val.r] || [])[val.c] : out[encode_cell({\n c: val.c,\n r: val.r\n })]) ++val.c;\n temp_val = {\n ixfe: val.ixfe,\n XF: XFs[val.ixfe] || {},\n v: val.val,\n t: 'n'\n } /*:any*/;\n if (BIFF2Fmt > 0) temp_val.z = BIFF2FmtTable[temp_val.ixfe >> 8 & 0x3F];\n safe_format_xf(temp_val, options, wb.opts.Date1904);\n addcell({\n c: val.c,\n r: val.r\n }, temp_val, options);\n }\n break;\n case 0x0005:\n case 0x0205 /* BoolErr */:\n {\n temp_val = {\n ixfe: val.ixfe,\n XF: XFs[val.ixfe],\n v: val.val,\n t: val.t\n } /*:any*/;\n if (BIFF2Fmt > 0) temp_val.z = BIFF2FmtTable[temp_val.ixfe >> 8 & 0x3F];\n safe_format_xf(temp_val, options, wb.opts.Date1904);\n addcell({\n c: val.c,\n r: val.r\n }, temp_val, options);\n }\n break;\n case 0x027e /* RK */:\n {\n temp_val = {\n ixfe: val.ixfe,\n XF: XFs[val.ixfe],\n v: val.rknum,\n t: 'n'\n } /*:any*/;\n if (BIFF2Fmt > 0) temp_val.z = BIFF2FmtTable[temp_val.ixfe >> 8 & 0x3F];\n safe_format_xf(temp_val, options, wb.opts.Date1904);\n addcell({\n c: val.c,\n r: val.r\n }, temp_val, options);\n }\n break;\n case 0x00bd /* MulRk */:\n {\n for (var j = val.c; j <= val.C; ++j) {\n var ixfe = val.rkrec[j - val.c][0];\n temp_val = {\n ixfe: ixfe,\n XF: XFs[ixfe],\n v: val.rkrec[j - val.c][1],\n t: 'n'\n } /*:any*/;\n if (BIFF2Fmt > 0) temp_val.z = BIFF2FmtTable[temp_val.ixfe >> 8 & 0x3F];\n safe_format_xf(temp_val, options, wb.opts.Date1904);\n addcell({\n c: j,\n r: val.r\n }, temp_val, options);\n }\n }\n break;\n case 0x0006:\n case 0x0206:\n case 0x0406 /* Formula */:\n {\n if (val.val == 'String') {\n last_formula = val;\n break;\n }\n temp_val = make_cell(val.val, val.cell.ixfe, val.tt);\n temp_val.XF = XFs[temp_val.ixfe];\n if (options.cellFormula) {\n var _f = val.formula;\n if (_f && _f[0] && _f[0][0] && _f[0][0][0] == 'PtgExp') {\n var _fr = _f[0][0][1][0],\n _fc = _f[0][0][1][1];\n var _fe = encode_cell({\n r: _fr,\n c: _fc\n });\n if (sharedf[_fe]) temp_val.f = \"\" + stringify_formula(val.formula, range, val.cell, supbooks, opts);else temp_val.F = ((options.dense ? (out[_fr] || [])[_fc] : out[_fe]) || {}).F;\n } else temp_val.f = \"\" + stringify_formula(val.formula, range, val.cell, supbooks, opts);\n }\n if (BIFF2Fmt > 0) temp_val.z = BIFF2FmtTable[temp_val.ixfe >> 8 & 0x3F];\n safe_format_xf(temp_val, options, wb.opts.Date1904);\n addcell(val.cell, temp_val, options);\n last_formula = val;\n }\n break;\n case 0x0007:\n case 0x0207 /* String */:\n {\n if (last_formula) {\n /* technically always true */\n last_formula.val = val;\n temp_val = make_cell(val, last_formula.cell.ixfe, 's');\n temp_val.XF = XFs[temp_val.ixfe];\n if (options.cellFormula) {\n temp_val.f = \"\" + stringify_formula(last_formula.formula, range, last_formula.cell, supbooks, opts);\n }\n if (BIFF2Fmt > 0) temp_val.z = BIFF2FmtTable[temp_val.ixfe >> 8 & 0x3F];\n safe_format_xf(temp_val, options, wb.opts.Date1904);\n addcell(last_formula.cell, temp_val, options);\n last_formula = null;\n } else throw new Error(\"String record expects Formula\");\n }\n break;\n case 0x0021:\n case 0x0221 /* Array */:\n {\n arrayf.push(val);\n var _arraystart = encode_cell(val[0].s);\n cc = options.dense ? (out[val[0].s.r] || [])[val[0].s.c] : out[_arraystart];\n if (options.cellFormula && cc) {\n if (!last_formula) break; /* technically unreachable */\n if (!_arraystart || !cc) break;\n cc.f = \"\" + stringify_formula(val[1], range, val[0], supbooks, opts);\n cc.F = encode_range(val[0]);\n }\n }\n break;\n case 0x04bc /* ShrFmla */:\n {\n if (!options.cellFormula) break;\n if (last_cell) {\n /* TODO: capture range */\n if (!last_formula) break; /* technically unreachable */\n sharedf[encode_cell(last_formula.cell)] = val[0];\n cc = options.dense ? (out[last_formula.cell.r] || [])[last_formula.cell.c] : out[encode_cell(last_formula.cell)];\n (cc || {}).f = \"\" + stringify_formula(val[0], range, lastcell, supbooks, opts);\n }\n }\n break;\n case 0x00fd /* LabelSst */:\n temp_val = make_cell(sst[val.isst].t, val.ixfe, 's');\n if (sst[val.isst].h) temp_val.h = sst[val.isst].h;\n temp_val.XF = XFs[temp_val.ixfe];\n if (BIFF2Fmt > 0) temp_val.z = BIFF2FmtTable[temp_val.ixfe >> 8 & 0x3F];\n safe_format_xf(temp_val, options, wb.opts.Date1904);\n addcell({\n c: val.c,\n r: val.r\n }, temp_val, options);\n break;\n case 0x0201 /* Blank */:\n if (options.sheetStubs) {\n temp_val = {\n ixfe: val.ixfe,\n XF: XFs[val.ixfe],\n t: 'z'\n } /*:any*/;\n if (BIFF2Fmt > 0) temp_val.z = BIFF2FmtTable[temp_val.ixfe >> 8 & 0x3F];\n safe_format_xf(temp_val, options, wb.opts.Date1904);\n addcell({\n c: val.c,\n r: val.r\n }, temp_val, options);\n }\n break;\n case 0x00be /* MulBlank */:\n if (options.sheetStubs) {\n for (var _j = val.c; _j <= val.C; ++_j) {\n var _ixfe = val.ixfe[_j - val.c];\n temp_val = {\n ixfe: _ixfe,\n XF: XFs[_ixfe],\n t: 'z'\n } /*:any*/;\n if (BIFF2Fmt > 0) temp_val.z = BIFF2FmtTable[temp_val.ixfe >> 8 & 0x3F];\n safe_format_xf(temp_val, options, wb.opts.Date1904);\n addcell({\n c: _j,\n r: val.r\n }, temp_val, options);\n }\n }\n break;\n case 0x00d6 /* RString */:\n case 0x0204 /* Label */:\n case 0x0004 /* BIFF2STR */:\n temp_val = make_cell(val.val, val.ixfe, 's');\n temp_val.XF = XFs[temp_val.ixfe];\n if (BIFF2Fmt > 0) temp_val.z = BIFF2FmtTable[temp_val.ixfe >> 8 & 0x3F];\n safe_format_xf(temp_val, options, wb.opts.Date1904);\n addcell({\n c: val.c,\n r: val.r\n }, temp_val, options);\n break;\n case 0x0000:\n case 0x0200 /* Dimensions */:\n {\n if (file_depth === 1) range = val; /* TODO: stack */\n }\n break;\n case 0x00fc /* SST */:\n {\n sst = val;\n }\n break;\n case 0x041e /* Format */:\n {\n /* val = [id, fmt] */\n if (opts.biff == 4) {\n BIFF2FmtTable[BIFF2Fmt++] = val[1];\n for (var b4idx = 0; b4idx < BIFF2Fmt + 163; ++b4idx) if (table_fmt[b4idx] == val[1]) break;\n if (b4idx >= 163) SSF_load(val[1], BIFF2Fmt + 163);\n } else SSF_load(val[1], val[0]);\n }\n break;\n case 0x001e /* BIFF2FORMAT */:\n {\n BIFF2FmtTable[BIFF2Fmt++] = val;\n for (var b2idx = 0; b2idx < BIFF2Fmt + 163; ++b2idx) if (table_fmt[b2idx] == val) break;\n if (b2idx >= 163) SSF_load(val, BIFF2Fmt + 163);\n }\n break;\n case 0x00e5 /* MergeCells */:\n merges = merges.concat(val);\n break;\n case 0x005d /* Obj */:\n objects[val.cmo[0]] = opts.lastobj = val;\n break;\n case 0x01b6 /* TxO */:\n opts.lastobj.TxO = val;\n break;\n case 0x007f /* ImData */:\n opts.lastobj.ImData = val;\n break;\n case 0x01b8 /* HLink */:\n {\n for (rngR = val[0].s.r; rngR <= val[0].e.r; ++rngR) for (rngC = val[0].s.c; rngC <= val[0].e.c; ++rngC) {\n cc = options.dense ? (out[rngR] || [])[rngC] : out[encode_cell({\n c: rngC,\n r: rngR\n })];\n if (cc) cc.l = val[1];\n }\n }\n break;\n case 0x0800 /* HLinkTooltip */:\n {\n for (rngR = val[0].s.r; rngR <= val[0].e.r; ++rngR) for (rngC = val[0].s.c; rngC <= val[0].e.c; ++rngC) {\n cc = options.dense ? (out[rngR] || [])[rngC] : out[encode_cell({\n c: rngC,\n r: rngR\n })];\n if (cc && cc.l) cc.l.Tooltip = val[1];\n }\n }\n break;\n case 0x001c /* Note */:\n {\n if (opts.biff <= 5 && opts.biff >= 2) break; /* TODO: BIFF5 */\n cc = options.dense ? (out[val[0].r] || [])[val[0].c] : out[encode_cell(val[0])];\n var noteobj = objects[val[2]];\n if (!cc) {\n if (options.dense) {\n if (!out[val[0].r]) out[val[0].r] = [];\n cc = out[val[0].r][val[0].c] = {\n t: \"z\"\n } /*:any*/;\n } else {\n cc = out[encode_cell(val[0])] = {\n t: \"z\"\n } /*:any*/;\n }\n range.e.r = Math.max(range.e.r, val[0].r);\n range.s.r = Math.min(range.s.r, val[0].r);\n range.e.c = Math.max(range.e.c, val[0].c);\n range.s.c = Math.min(range.s.c, val[0].c);\n }\n if (!cc.c) cc.c = [];\n cmnt = {\n a: val[1],\n t: noteobj.TxO.t\n };\n cc.c.push(cmnt);\n }\n break;\n case 0x087d /* XFExt */:\n update_xfext(XFs[val.ixfe], val.ext);\n break;\n case 0x007d /* ColInfo */:\n {\n if (!opts.cellStyles) break;\n while (val.e >= val.s) {\n colinfo[val.e--] = {\n width: val.w / 256,\n level: val.level || 0,\n hidden: !!(val.flags & 1)\n };\n if (!seencol) {\n seencol = true;\n find_mdw_colw(val.w / 256);\n }\n process_col(colinfo[val.e + 1]);\n }\n }\n break;\n case 0x0208 /* Row */:\n {\n var rowobj = {};\n if (val.level != null) {\n rowinfo[val.r] = rowobj;\n rowobj.level = val.level;\n }\n if (val.hidden) {\n rowinfo[val.r] = rowobj;\n rowobj.hidden = true;\n }\n if (val.hpt) {\n rowinfo[val.r] = rowobj;\n rowobj.hpt = val.hpt;\n rowobj.hpx = pt2px(val.hpt);\n }\n }\n break;\n case 0x0026 /* LeftMargin */:\n case 0x0027 /* RightMargin */:\n case 0x0028 /* TopMargin */:\n case 0x0029 /* BottomMargin */:\n if (!out['!margins']) default_margins(out['!margins'] = {});\n out['!margins'][{\n 0x26: \"left\",\n 0x27: \"right\",\n 0x28: \"top\",\n 0x29: \"bottom\"\n }[RecordType]] = val;\n break;\n case 0x00a1 /* Setup */:\n // TODO\n if (!out['!margins']) default_margins(out['!margins'] = {});\n out['!margins'].header = val.header;\n out['!margins'].footer = val.footer;\n break;\n case 0x023e /* Window2 */:\n // TODO\n // $FlowIgnore\n if (val.RTL) Workbook.Views[0].RTL = true;\n break;\n case 0x0092 /* Palette */:\n palette = val;\n break;\n case 0x0896 /* Theme */:\n themes = val;\n break;\n case 0x008c /* Country */:\n country = val;\n break;\n case 0x01ba /* CodeName */:\n {\n /*:: if(!Workbook.WBProps) Workbook.WBProps = {}; */\n if (!cur_sheet) Workbook.WBProps.CodeName = val || \"ThisWorkbook\";else wsprops.CodeName = val || wsprops.name;\n }\n break;\n }\n } else {\n if (!R) console.error(\"Missing Info for XLS Record 0x\" + RecordType.toString(16));\n blob.l += length;\n }\n }\n wb.SheetNames = keys(Directory).sort(function (a, b) {\n return Number(a) - Number(b);\n }).map(function (x) {\n return Directory[x].name;\n });\n if (!options.bookSheets) wb.Sheets = Sheets;\n if (!wb.SheetNames.length && Preamble[\"!ref\"]) {\n wb.SheetNames.push(\"Sheet1\");\n /*jshint -W069 */\n if (wb.Sheets) wb.Sheets[\"Sheet1\"] = Preamble;\n /*jshint +W069 */\n } else wb.Preamble = Preamble;\n if (wb.Sheets) FilterDatabases.forEach(function (r, i) {\n wb.Sheets[wb.SheetNames[i]]['!autofilter'] = r;\n });\n wb.Strings = sst;\n wb.SSF = dup(table_fmt);\n if (opts.enc) wb.Encryption = opts.enc;\n if (themes) wb.Themes = themes;\n wb.Metadata = {};\n if (country !== undefined) wb.Metadata.Country = country;\n if (supbooks.names.length > 0) Workbook.Names = supbooks.names;\n wb.Workbook = Workbook;\n return wb;\n}\n\n/* TODO: split props*/\nvar PSCLSID = {\n SI: \"e0859ff2f94f6810ab9108002b27b3d9\",\n DSI: \"02d5cdd59c2e1b10939708002b2cf9ae\",\n UDI: \"05d5cdd59c2e1b10939708002b2cf9ae\"\n};\nfunction parse_xls_props(cfb /*:CFBContainer*/, props, o) {\n /* [MS-OSHARED] 2.3.3.2.2 Document Summary Information Property Set */\n var DSI = CFB.find(cfb, '/!DocumentSummaryInformation');\n if (DSI && DSI.size > 0) try {\n var DocSummary = parse_PropertySetStream(DSI, DocSummaryPIDDSI, PSCLSID.DSI);\n for (var d in DocSummary) props[d] = DocSummary[d];\n } catch (e) {\n if (o.WTF) throw e; /* empty */\n }\n\n /* [MS-OSHARED] 2.3.3.2.1 Summary Information Property Set*/\n var SI = CFB.find(cfb, '/!SummaryInformation');\n if (SI && SI.size > 0) try {\n var Summary = parse_PropertySetStream(SI, SummaryPIDSI, PSCLSID.SI);\n for (var s in Summary) if (props[s] == null) props[s] = Summary[s];\n } catch (e) {\n if (o.WTF) throw e; /* empty */\n }\n if (props.HeadingPairs && props.TitlesOfParts) {\n load_props_pairs(props.HeadingPairs, props.TitlesOfParts, props, o);\n delete props.HeadingPairs;\n delete props.TitlesOfParts;\n }\n}\nfunction write_xls_props(wb /*:Workbook*/, cfb /*:CFBContainer*/) {\n var DSEntries = [],\n SEntries = [],\n CEntries = [];\n var i = 0,\n Keys;\n var DocSummaryRE /*:{[key:string]:string}*/ = evert_key(DocSummaryPIDDSI, \"n\");\n var SummaryRE /*:{[key:string]:string}*/ = evert_key(SummaryPIDSI, \"n\");\n if (wb.Props) {\n Keys = keys(wb.Props);\n // $FlowIgnore\n for (i = 0; i < Keys.length; ++i) (Object.prototype.hasOwnProperty.call(DocSummaryRE, Keys[i]) ? DSEntries : Object.prototype.hasOwnProperty.call(SummaryRE, Keys[i]) ? SEntries : CEntries).push([Keys[i], wb.Props[Keys[i]]]);\n }\n if (wb.Custprops) {\n Keys = keys(wb.Custprops);\n // $FlowIgnore\n for (i = 0; i < Keys.length; ++i) if (!Object.prototype.hasOwnProperty.call(wb.Props || {}, Keys[i])) (Object.prototype.hasOwnProperty.call(DocSummaryRE, Keys[i]) ? DSEntries : Object.prototype.hasOwnProperty.call(SummaryRE, Keys[i]) ? SEntries : CEntries).push([Keys[i], wb.Custprops[Keys[i]]]);\n }\n var CEntries2 = [];\n for (i = 0; i < CEntries.length; ++i) {\n if (XLSPSSkip.indexOf(CEntries[i][0]) > -1 || PseudoPropsPairs.indexOf(CEntries[i][0]) > -1) continue;\n if (CEntries[i][1] == null) continue;\n CEntries2.push(CEntries[i]);\n }\n if (SEntries.length) CFB.utils.cfb_add(cfb, \"/\\u0005SummaryInformation\", write_PropertySetStream(SEntries, PSCLSID.SI, SummaryRE, SummaryPIDSI));\n if (DSEntries.length || CEntries2.length) CFB.utils.cfb_add(cfb, \"/\\u0005DocumentSummaryInformation\", write_PropertySetStream(DSEntries, PSCLSID.DSI, DocSummaryRE, DocSummaryPIDDSI, CEntries2.length ? CEntries2 : null, PSCLSID.UDI));\n}\nfunction parse_xlscfb(cfb /*:any*/, options /*:?ParseOpts*/) /*:Workbook*/{\n if (!options) options = {};\n fix_read_opts(options);\n reset_cp();\n if (options.codepage) set_ansi(options.codepage);\n var CompObj /*:?CFBEntry*/, WB /*:?any*/;\n if (cfb.FullPaths) {\n if (CFB.find(cfb, '/encryption')) throw new Error(\"File is password-protected\");\n CompObj = CFB.find(cfb, '!CompObj');\n WB = CFB.find(cfb, '/Workbook') || CFB.find(cfb, '/Book');\n } else {\n switch (options.type) {\n case 'base64':\n cfb = s2a(Base64_decode(cfb));\n break;\n case 'binary':\n cfb = s2a(cfb);\n break;\n case 'buffer':\n break;\n case 'array':\n if (!Array.isArray(cfb)) cfb = Array.prototype.slice.call(cfb);\n break;\n }\n prep_blob(cfb, 0);\n WB = {\n content: cfb\n } /*:any*/;\n }\n var /*::CompObjP, */WorkbookP /*:: :Workbook = XLSX.utils.book_new(); */;\n var _data /*:?any*/;\n if (CompObj) /*::CompObjP = */parse_compobj(CompObj);\n if (options.bookProps && !options.bookSheets) WorkbookP = {} /*:any*/;else /*:: if(cfb instanceof CFBContainer) */{\n var T = has_buf ? 'buffer' : 'array';\n if (WB && WB.content) WorkbookP = parse_workbook(WB.content, options);\n /* Quattro Pro 7-8 */else if ((_data = CFB.find(cfb, 'PerfectOffice_MAIN')) && _data.content) WorkbookP = WK_.to_workbook(_data.content, (options.type = T, options));\n /* Quattro Pro 9 */else if ((_data = CFB.find(cfb, 'NativeContent_MAIN')) && _data.content) WorkbookP = WK_.to_workbook(_data.content, (options.type = T, options));\n /* Works 4 for Mac */else if ((_data = CFB.find(cfb, 'MN0')) && _data.content) throw new Error(\"Unsupported Works 4 for Mac file\");else throw new Error(\"Cannot find Workbook stream\");\n if (options.bookVBA && cfb.FullPaths && CFB.find(cfb, '/_VBA_PROJECT_CUR/VBA/dir')) WorkbookP.vbaraw = make_vba_xls(cfb);\n }\n var props = {};\n if (cfb.FullPaths) parse_xls_props(/*::((*/cfb /*:: :any):CFBContainer)*/, props, options);\n WorkbookP.Props = WorkbookP.Custprops = props; /* TODO: split up properties */\n if (options.bookFiles) WorkbookP.cfb = cfb;\n /*WorkbookP.CompObjP = CompObjP; // TODO: storage? */\n return WorkbookP;\n}\nfunction write_xlscfb(wb /*:Workbook*/, opts /*:WriteOpts*/) /*:CFBContainer*/{\n var o = opts || {};\n var cfb = CFB.utils.cfb_new({\n root: \"R\"\n });\n var wbpath = \"/Workbook\";\n switch (o.bookType || \"xls\") {\n case \"xls\":\n o.bookType = \"biff8\";\n /* falls through */\n case \"xla\":\n if (!o.bookType) o.bookType = \"xla\";\n /* falls through */\n case \"biff8\":\n wbpath = \"/Workbook\";\n o.biff = 8;\n break;\n case \"biff5\":\n wbpath = \"/Book\";\n o.biff = 5;\n break;\n default:\n throw new Error(\"invalid type \" + o.bookType + \" for XLS CFB\");\n }\n CFB.utils.cfb_add(cfb, wbpath, write_biff_buf(wb, o));\n if (o.biff == 8 && (wb.Props || wb.Custprops)) write_xls_props(wb, cfb);\n // TODO: SI, DSI, CO\n if (o.biff == 8 && wb.vbaraw) fill_vba_xls(cfb, CFB.read(wb.vbaraw, {\n type: typeof wb.vbaraw == \"string\" ? \"binary\" : \"buffer\"\n }));\n return cfb;\n}\n/* [MS-XLSB] 2.3 Record Enumeration */\nvar XLSBRecordEnum = {\n /*::[*/0x0000 /*::]*/: {\n /* n:\"BrtRowHdr\", */f: parse_BrtRowHdr\n },\n /*::[*/0x0001 /*::]*/: {\n /* n:\"BrtCellBlank\", */f: parse_BrtCellBlank\n },\n /*::[*/0x0002 /*::]*/: {\n /* n:\"BrtCellRk\", */f: parse_BrtCellRk\n },\n /*::[*/0x0003 /*::]*/: {\n /* n:\"BrtCellError\", */f: parse_BrtCellError\n },\n /*::[*/0x0004 /*::]*/: {\n /* n:\"BrtCellBool\", */f: parse_BrtCellBool\n },\n /*::[*/0x0005 /*::]*/: {\n /* n:\"BrtCellReal\", */f: parse_BrtCellReal\n },\n /*::[*/0x0006 /*::]*/: {\n /* n:\"BrtCellSt\", */f: parse_BrtCellSt\n },\n /*::[*/0x0007 /*::]*/: {\n /* n:\"BrtCellIsst\", */f: parse_BrtCellIsst\n },\n /*::[*/0x0008 /*::]*/: {\n /* n:\"BrtFmlaString\", */f: parse_BrtFmlaString\n },\n /*::[*/0x0009 /*::]*/: {\n /* n:\"BrtFmlaNum\", */f: parse_BrtFmlaNum\n },\n /*::[*/0x000A /*::]*/: {\n /* n:\"BrtFmlaBool\", */f: parse_BrtFmlaBool\n },\n /*::[*/0x000B /*::]*/: {\n /* n:\"BrtFmlaError\", */f: parse_BrtFmlaError\n },\n /*::[*/0x000C /*::]*/: {\n /* n:\"BrtShortBlank\", */f: parse_BrtShortBlank\n },\n /*::[*/0x000D /*::]*/: {\n /* n:\"BrtShortRk\", */f: parse_BrtShortRk\n },\n /*::[*/0x000E /*::]*/: {\n /* n:\"BrtShortError\", */f: parse_BrtShortError\n },\n /*::[*/0x000F /*::]*/: {\n /* n:\"BrtShortBool\", */f: parse_BrtShortBool\n },\n /*::[*/0x0010 /*::]*/: {\n /* n:\"BrtShortReal\", */f: parse_BrtShortReal\n },\n /*::[*/0x0011 /*::]*/: {\n /* n:\"BrtShortSt\", */f: parse_BrtShortSt\n },\n /*::[*/0x0012 /*::]*/: {\n /* n:\"BrtShortIsst\", */f: parse_BrtShortIsst\n },\n /*::[*/0x0013 /*::]*/: {\n /* n:\"BrtSSTItem\", */f: parse_RichStr\n },\n /*::[*/0x0014 /*::]*/: {/* n:\"BrtPCDIMissing\" */},\n /*::[*/0x0015 /*::]*/: {/* n:\"BrtPCDINumber\" */},\n /*::[*/0x0016 /*::]*/: {/* n:\"BrtPCDIBoolean\" */},\n /*::[*/0x0017 /*::]*/: {/* n:\"BrtPCDIError\" */},\n /*::[*/0x0018 /*::]*/: {/* n:\"BrtPCDIString\" */},\n /*::[*/0x0019 /*::]*/: {/* n:\"BrtPCDIDatetime\" */},\n /*::[*/0x001A /*::]*/: {/* n:\"BrtPCDIIndex\" */},\n /*::[*/0x001B /*::]*/: {/* n:\"BrtPCDIAMissing\" */},\n /*::[*/0x001C /*::]*/: {/* n:\"BrtPCDIANumber\" */},\n /*::[*/0x001D /*::]*/: {/* n:\"BrtPCDIABoolean\" */},\n /*::[*/0x001E /*::]*/: {/* n:\"BrtPCDIAError\" */},\n /*::[*/0x001F /*::]*/: {/* n:\"BrtPCDIAString\" */},\n /*::[*/0x0020 /*::]*/: {/* n:\"BrtPCDIADatetime\" */},\n /*::[*/0x0021 /*::]*/: {/* n:\"BrtPCRRecord\" */},\n /*::[*/0x0022 /*::]*/: {/* n:\"BrtPCRRecordDt\" */},\n /*::[*/0x0023 /*::]*/: {\n /* n:\"BrtFRTBegin\", */T: 1\n },\n /*::[*/0x0024 /*::]*/: {\n /* n:\"BrtFRTEnd\", */T: -1\n },\n /*::[*/0x0025 /*::]*/: {\n /* n:\"BrtACBegin\", */T: 1\n },\n /*::[*/0x0026 /*::]*/: {\n /* n:\"BrtACEnd\", */T: -1\n },\n /*::[*/0x0027 /*::]*/: {\n /* n:\"BrtName\", */f: parse_BrtName\n },\n /*::[*/0x0028 /*::]*/: {/* n:\"BrtIndexRowBlock\" */},\n /*::[*/0x002A /*::]*/: {/* n:\"BrtIndexBlock\" */},\n /*::[*/0x002B /*::]*/: {\n /* n:\"BrtFont\", */f: parse_BrtFont\n },\n /*::[*/0x002C /*::]*/: {\n /* n:\"BrtFmt\", */f: parse_BrtFmt\n },\n /*::[*/0x002D /*::]*/: {\n /* n:\"BrtFill\", */f: parse_BrtFill\n },\n /*::[*/0x002E /*::]*/: {\n /* n:\"BrtBorder\", */f: parse_BrtBorder\n },\n /*::[*/0x002F /*::]*/: {\n /* n:\"BrtXF\", */f: parse_BrtXF\n },\n /*::[*/0x0030 /*::]*/: {/* n:\"BrtStyle\" */},\n /*::[*/0x0031 /*::]*/: {\n /* n:\"BrtCellMeta\", */f: parse_Int32LE\n },\n /*::[*/0x0032 /*::]*/: {/* n:\"BrtValueMeta\" */},\n /*::[*/0x0033 /*::]*/: {\n /* n:\"BrtMdb\" */f: parse_BrtMdb\n },\n /*::[*/0x0034 /*::]*/: {\n /* n:\"BrtBeginFmd\", */T: 1\n },\n /*::[*/0x0035 /*::]*/: {\n /* n:\"BrtEndFmd\", */T: -1\n },\n /*::[*/0x0036 /*::]*/: {\n /* n:\"BrtBeginMdx\", */T: 1\n },\n /*::[*/0x0037 /*::]*/: {\n /* n:\"BrtEndMdx\", */T: -1\n },\n /*::[*/0x0038 /*::]*/: {\n /* n:\"BrtBeginMdxTuple\", */T: 1\n },\n /*::[*/0x0039 /*::]*/: {\n /* n:\"BrtEndMdxTuple\", */T: -1\n },\n /*::[*/0x003A /*::]*/: {/* n:\"BrtMdxMbrIstr\" */},\n /*::[*/0x003B /*::]*/: {/* n:\"BrtStr\" */},\n /*::[*/0x003C /*::]*/: {\n /* n:\"BrtColInfo\", */f: parse_ColInfo\n },\n /*::[*/0x003E /*::]*/: {\n /* n:\"BrtCellRString\", */f: parse_BrtCellRString\n },\n /*::[*/0x003F /*::]*/: {\n /* n:\"BrtCalcChainItem$\", */f: parse_BrtCalcChainItem$\n },\n /*::[*/0x0040 /*::]*/: {\n /* n:\"BrtDVal\", */f: parse_BrtDVal\n },\n /*::[*/0x0041 /*::]*/: {/* n:\"BrtSxvcellNum\" */},\n /*::[*/0x0042 /*::]*/: {/* n:\"BrtSxvcellStr\" */},\n /*::[*/0x0043 /*::]*/: {/* n:\"BrtSxvcellBool\" */},\n /*::[*/0x0044 /*::]*/: {/* n:\"BrtSxvcellErr\" */},\n /*::[*/0x0045 /*::]*/: {/* n:\"BrtSxvcellDate\" */},\n /*::[*/0x0046 /*::]*/: {/* n:\"BrtSxvcellNil\" */},\n /*::[*/0x0080 /*::]*/: {/* n:\"BrtFileVersion\" */},\n /*::[*/0x0081 /*::]*/: {\n /* n:\"BrtBeginSheet\", */T: 1\n },\n /*::[*/0x0082 /*::]*/: {\n /* n:\"BrtEndSheet\", */T: -1\n },\n /*::[*/0x0083 /*::]*/: {\n /* n:\"BrtBeginBook\", */T: 1,\n f: parsenoop,\n p: 0\n },\n /*::[*/0x0084 /*::]*/: {\n /* n:\"BrtEndBook\", */T: -1\n },\n /*::[*/0x0085 /*::]*/: {\n /* n:\"BrtBeginWsViews\", */T: 1\n },\n /*::[*/0x0086 /*::]*/: {\n /* n:\"BrtEndWsViews\", */T: -1\n },\n /*::[*/0x0087 /*::]*/: {\n /* n:\"BrtBeginBookViews\", */T: 1\n },\n /*::[*/0x0088 /*::]*/: {\n /* n:\"BrtEndBookViews\", */T: -1\n },\n /*::[*/0x0089 /*::]*/: {\n /* n:\"BrtBeginWsView\", */T: 1,\n f: parse_BrtBeginWsView\n },\n /*::[*/0x008A /*::]*/: {\n /* n:\"BrtEndWsView\", */T: -1\n },\n /*::[*/0x008B /*::]*/: {\n /* n:\"BrtBeginCsViews\", */T: 1\n },\n /*::[*/0x008C /*::]*/: {\n /* n:\"BrtEndCsViews\", */T: -1\n },\n /*::[*/0x008D /*::]*/: {\n /* n:\"BrtBeginCsView\", */T: 1\n },\n /*::[*/0x008E /*::]*/: {\n /* n:\"BrtEndCsView\", */T: -1\n },\n /*::[*/0x008F /*::]*/: {\n /* n:\"BrtBeginBundleShs\", */T: 1\n },\n /*::[*/0x0090 /*::]*/: {\n /* n:\"BrtEndBundleShs\", */T: -1\n },\n /*::[*/0x0091 /*::]*/: {\n /* n:\"BrtBeginSheetData\", */T: 1\n },\n /*::[*/0x0092 /*::]*/: {\n /* n:\"BrtEndSheetData\", */T: -1\n },\n /*::[*/0x0093 /*::]*/: {\n /* n:\"BrtWsProp\", */f: parse_BrtWsProp\n },\n /*::[*/0x0094 /*::]*/: {\n /* n:\"BrtWsDim\", */f: parse_BrtWsDim,\n p: 16\n },\n /*::[*/0x0097 /*::]*/: {\n /* n:\"BrtPane\", */f: parse_BrtPane\n },\n /*::[*/0x0098 /*::]*/: {/* n:\"BrtSel\" */},\n /*::[*/0x0099 /*::]*/: {\n /* n:\"BrtWbProp\", */f: parse_BrtWbProp\n },\n /*::[*/0x009A /*::]*/: {/* n:\"BrtWbFactoid\" */},\n /*::[*/0x009B /*::]*/: {/* n:\"BrtFileRecover\" */},\n /*::[*/0x009C /*::]*/: {\n /* n:\"BrtBundleSh\", */f: parse_BrtBundleSh\n },\n /*::[*/0x009D /*::]*/: {/* n:\"BrtCalcProp\" */},\n /*::[*/0x009E /*::]*/: {/* n:\"BrtBookView\" */},\n /*::[*/0x009F /*::]*/: {\n /* n:\"BrtBeginSst\", */T: 1,\n f: parse_BrtBeginSst\n },\n /*::[*/0x00A0 /*::]*/: {\n /* n:\"BrtEndSst\", */T: -1\n },\n /*::[*/0x00A1 /*::]*/: {\n /* n:\"BrtBeginAFilter\", */T: 1,\n f: parse_UncheckedRfX\n },\n /*::[*/0x00A2 /*::]*/: {\n /* n:\"BrtEndAFilter\", */T: -1\n },\n /*::[*/0x00A3 /*::]*/: {\n /* n:\"BrtBeginFilterColumn\", */T: 1\n },\n /*::[*/0x00A4 /*::]*/: {\n /* n:\"BrtEndFilterColumn\", */T: -1\n },\n /*::[*/0x00A5 /*::]*/: {\n /* n:\"BrtBeginFilters\", */T: 1\n },\n /*::[*/0x00A6 /*::]*/: {\n /* n:\"BrtEndFilters\", */T: -1\n },\n /*::[*/0x00A7 /*::]*/: {/* n:\"BrtFilter\" */},\n /*::[*/0x00A8 /*::]*/: {/* n:\"BrtColorFilter\" */},\n /*::[*/0x00A9 /*::]*/: {/* n:\"BrtIconFilter\" */},\n /*::[*/0x00AA /*::]*/: {/* n:\"BrtTop10Filter\" */},\n /*::[*/0x00AB /*::]*/: {/* n:\"BrtDynamicFilter\" */},\n /*::[*/0x00AC /*::]*/: {\n /* n:\"BrtBeginCustomFilters\", */T: 1\n },\n /*::[*/0x00AD /*::]*/: {\n /* n:\"BrtEndCustomFilters\", */T: -1\n },\n /*::[*/0x00AE /*::]*/: {/* n:\"BrtCustomFilter\" */},\n /*::[*/0x00AF /*::]*/: {/* n:\"BrtAFilterDateGroupItem\" */},\n /*::[*/0x00B0 /*::]*/: {\n /* n:\"BrtMergeCell\", */f: parse_BrtMergeCell\n },\n /*::[*/0x00B1 /*::]*/: {\n /* n:\"BrtBeginMergeCells\", */T: 1\n },\n /*::[*/0x00B2 /*::]*/: {\n /* n:\"BrtEndMergeCells\", */T: -1\n },\n /*::[*/0x00B3 /*::]*/: {\n /* n:\"BrtBeginPivotCacheDef\", */T: 1\n },\n /*::[*/0x00B4 /*::]*/: {\n /* n:\"BrtEndPivotCacheDef\", */T: -1\n },\n /*::[*/0x00B5 /*::]*/: {\n /* n:\"BrtBeginPCDFields\", */T: 1\n },\n /*::[*/0x00B6 /*::]*/: {\n /* n:\"BrtEndPCDFields\", */T: -1\n },\n /*::[*/0x00B7 /*::]*/: {\n /* n:\"BrtBeginPCDField\", */T: 1\n },\n /*::[*/0x00B8 /*::]*/: {\n /* n:\"BrtEndPCDField\", */T: -1\n },\n /*::[*/0x00B9 /*::]*/: {\n /* n:\"BrtBeginPCDSource\", */T: 1\n },\n /*::[*/0x00BA /*::]*/: {\n /* n:\"BrtEndPCDSource\", */T: -1\n },\n /*::[*/0x00BB /*::]*/: {\n /* n:\"BrtBeginPCDSRange\", */T: 1\n },\n /*::[*/0x00BC /*::]*/: {\n /* n:\"BrtEndPCDSRange\", */T: -1\n },\n /*::[*/0x00BD /*::]*/: {\n /* n:\"BrtBeginPCDFAtbl\", */T: 1\n },\n /*::[*/0x00BE /*::]*/: {\n /* n:\"BrtEndPCDFAtbl\", */T: -1\n },\n /*::[*/0x00BF /*::]*/: {\n /* n:\"BrtBeginPCDIRun\", */T: 1\n },\n /*::[*/0x00C0 /*::]*/: {\n /* n:\"BrtEndPCDIRun\", */T: -1\n },\n /*::[*/0x00C1 /*::]*/: {\n /* n:\"BrtBeginPivotCacheRecords\", */T: 1\n },\n /*::[*/0x00C2 /*::]*/: {\n /* n:\"BrtEndPivotCacheRecords\", */T: -1\n },\n /*::[*/0x00C3 /*::]*/: {\n /* n:\"BrtBeginPCDHierarchies\", */T: 1\n },\n /*::[*/0x00C4 /*::]*/: {\n /* n:\"BrtEndPCDHierarchies\", */T: -1\n },\n /*::[*/0x00C5 /*::]*/: {\n /* n:\"BrtBeginPCDHierarchy\", */T: 1\n },\n /*::[*/0x00C6 /*::]*/: {\n /* n:\"BrtEndPCDHierarchy\", */T: -1\n },\n /*::[*/0x00C7 /*::]*/: {\n /* n:\"BrtBeginPCDHFieldsUsage\", */T: 1\n },\n /*::[*/0x00C8 /*::]*/: {\n /* n:\"BrtEndPCDHFieldsUsage\", */T: -1\n },\n /*::[*/0x00C9 /*::]*/: {\n /* n:\"BrtBeginExtConnection\", */T: 1\n },\n /*::[*/0x00CA /*::]*/: {\n /* n:\"BrtEndExtConnection\", */T: -1\n },\n /*::[*/0x00CB /*::]*/: {\n /* n:\"BrtBeginECDbProps\", */T: 1\n },\n /*::[*/0x00CC /*::]*/: {\n /* n:\"BrtEndECDbProps\", */T: -1\n },\n /*::[*/0x00CD /*::]*/: {\n /* n:\"BrtBeginECOlapProps\", */T: 1\n },\n /*::[*/0x00CE /*::]*/: {\n /* n:\"BrtEndECOlapProps\", */T: -1\n },\n /*::[*/0x00CF /*::]*/: {\n /* n:\"BrtBeginPCDSConsol\", */T: 1\n },\n /*::[*/0x00D0 /*::]*/: {\n /* n:\"BrtEndPCDSConsol\", */T: -1\n },\n /*::[*/0x00D1 /*::]*/: {\n /* n:\"BrtBeginPCDSCPages\", */T: 1\n },\n /*::[*/0x00D2 /*::]*/: {\n /* n:\"BrtEndPCDSCPages\", */T: -1\n },\n /*::[*/0x00D3 /*::]*/: {\n /* n:\"BrtBeginPCDSCPage\", */T: 1\n },\n /*::[*/0x00D4 /*::]*/: {\n /* n:\"BrtEndPCDSCPage\", */T: -1\n },\n /*::[*/0x00D5 /*::]*/: {\n /* n:\"BrtBeginPCDSCPItem\", */T: 1\n },\n /*::[*/0x00D6 /*::]*/: {\n /* n:\"BrtEndPCDSCPItem\", */T: -1\n },\n /*::[*/0x00D7 /*::]*/: {\n /* n:\"BrtBeginPCDSCSets\", */T: 1\n },\n /*::[*/0x00D8 /*::]*/: {\n /* n:\"BrtEndPCDSCSets\", */T: -1\n },\n /*::[*/0x00D9 /*::]*/: {\n /* n:\"BrtBeginPCDSCSet\", */T: 1\n },\n /*::[*/0x00DA /*::]*/: {\n /* n:\"BrtEndPCDSCSet\", */T: -1\n },\n /*::[*/0x00DB /*::]*/: {\n /* n:\"BrtBeginPCDFGroup\", */T: 1\n },\n /*::[*/0x00DC /*::]*/: {\n /* n:\"BrtEndPCDFGroup\", */T: -1\n },\n /*::[*/0x00DD /*::]*/: {\n /* n:\"BrtBeginPCDFGItems\", */T: 1\n },\n /*::[*/0x00DE /*::]*/: {\n /* n:\"BrtEndPCDFGItems\", */T: -1\n },\n /*::[*/0x00DF /*::]*/: {\n /* n:\"BrtBeginPCDFGRange\", */T: 1\n },\n /*::[*/0x00E0 /*::]*/: {\n /* n:\"BrtEndPCDFGRange\", */T: -1\n },\n /*::[*/0x00E1 /*::]*/: {\n /* n:\"BrtBeginPCDFGDiscrete\", */T: 1\n },\n /*::[*/0x00E2 /*::]*/: {\n /* n:\"BrtEndPCDFGDiscrete\", */T: -1\n },\n /*::[*/0x00E3 /*::]*/: {\n /* n:\"BrtBeginPCDSDTupleCache\", */T: 1\n },\n /*::[*/0x00E4 /*::]*/: {\n /* n:\"BrtEndPCDSDTupleCache\", */T: -1\n },\n /*::[*/0x00E5 /*::]*/: {\n /* n:\"BrtBeginPCDSDTCEntries\", */T: 1\n },\n /*::[*/0x00E6 /*::]*/: {\n /* n:\"BrtEndPCDSDTCEntries\", */T: -1\n },\n /*::[*/0x00E7 /*::]*/: {\n /* n:\"BrtBeginPCDSDTCEMembers\", */T: 1\n },\n /*::[*/0x00E8 /*::]*/: {\n /* n:\"BrtEndPCDSDTCEMembers\", */T: -1\n },\n /*::[*/0x00E9 /*::]*/: {\n /* n:\"BrtBeginPCDSDTCEMember\", */T: 1\n },\n /*::[*/0x00EA /*::]*/: {\n /* n:\"BrtEndPCDSDTCEMember\", */T: -1\n },\n /*::[*/0x00EB /*::]*/: {\n /* n:\"BrtBeginPCDSDTCQueries\", */T: 1\n },\n /*::[*/0x00EC /*::]*/: {\n /* n:\"BrtEndPCDSDTCQueries\", */T: -1\n },\n /*::[*/0x00ED /*::]*/: {\n /* n:\"BrtBeginPCDSDTCQuery\", */T: 1\n },\n /*::[*/0x00EE /*::]*/: {\n /* n:\"BrtEndPCDSDTCQuery\", */T: -1\n },\n /*::[*/0x00EF /*::]*/: {\n /* n:\"BrtBeginPCDSDTCSets\", */T: 1\n },\n /*::[*/0x00F0 /*::]*/: {\n /* n:\"BrtEndPCDSDTCSets\", */T: -1\n },\n /*::[*/0x00F1 /*::]*/: {\n /* n:\"BrtBeginPCDSDTCSet\", */T: 1\n },\n /*::[*/0x00F2 /*::]*/: {\n /* n:\"BrtEndPCDSDTCSet\", */T: -1\n },\n /*::[*/0x00F3 /*::]*/: {\n /* n:\"BrtBeginPCDCalcItems\", */T: 1\n },\n /*::[*/0x00F4 /*::]*/: {\n /* n:\"BrtEndPCDCalcItems\", */T: -1\n },\n /*::[*/0x00F5 /*::]*/: {\n /* n:\"BrtBeginPCDCalcItem\", */T: 1\n },\n /*::[*/0x00F6 /*::]*/: {\n /* n:\"BrtEndPCDCalcItem\", */T: -1\n },\n /*::[*/0x00F7 /*::]*/: {\n /* n:\"BrtBeginPRule\", */T: 1\n },\n /*::[*/0x00F8 /*::]*/: {\n /* n:\"BrtEndPRule\", */T: -1\n },\n /*::[*/0x00F9 /*::]*/: {\n /* n:\"BrtBeginPRFilters\", */T: 1\n },\n /*::[*/0x00FA /*::]*/: {\n /* n:\"BrtEndPRFilters\", */T: -1\n },\n /*::[*/0x00FB /*::]*/: {\n /* n:\"BrtBeginPRFilter\", */T: 1\n },\n /*::[*/0x00FC /*::]*/: {\n /* n:\"BrtEndPRFilter\", */T: -1\n },\n /*::[*/0x00FD /*::]*/: {\n /* n:\"BrtBeginPNames\", */T: 1\n },\n /*::[*/0x00FE /*::]*/: {\n /* n:\"BrtEndPNames\", */T: -1\n },\n /*::[*/0x00FF /*::]*/: {\n /* n:\"BrtBeginPName\", */T: 1\n },\n /*::[*/0x0100 /*::]*/: {\n /* n:\"BrtEndPName\", */T: -1\n },\n /*::[*/0x0101 /*::]*/: {\n /* n:\"BrtBeginPNPairs\", */T: 1\n },\n /*::[*/0x0102 /*::]*/: {\n /* n:\"BrtEndPNPairs\", */T: -1\n },\n /*::[*/0x0103 /*::]*/: {\n /* n:\"BrtBeginPNPair\", */T: 1\n },\n /*::[*/0x0104 /*::]*/: {\n /* n:\"BrtEndPNPair\", */T: -1\n },\n /*::[*/0x0105 /*::]*/: {\n /* n:\"BrtBeginECWebProps\", */T: 1\n },\n /*::[*/0x0106 /*::]*/: {\n /* n:\"BrtEndECWebProps\", */T: -1\n },\n /*::[*/0x0107 /*::]*/: {\n /* n:\"BrtBeginEcWpTables\", */T: 1\n },\n /*::[*/0x0108 /*::]*/: {\n /* n:\"BrtEndECWPTables\", */T: -1\n },\n /*::[*/0x0109 /*::]*/: {\n /* n:\"BrtBeginECParams\", */T: 1\n },\n /*::[*/0x010A /*::]*/: {\n /* n:\"BrtEndECParams\", */T: -1\n },\n /*::[*/0x010B /*::]*/: {\n /* n:\"BrtBeginECParam\", */T: 1\n },\n /*::[*/0x010C /*::]*/: {\n /* n:\"BrtEndECParam\", */T: -1\n },\n /*::[*/0x010D /*::]*/: {\n /* n:\"BrtBeginPCDKPIs\", */T: 1\n },\n /*::[*/0x010E /*::]*/: {\n /* n:\"BrtEndPCDKPIs\", */T: -1\n },\n /*::[*/0x010F /*::]*/: {\n /* n:\"BrtBeginPCDKPI\", */T: 1\n },\n /*::[*/0x0110 /*::]*/: {\n /* n:\"BrtEndPCDKPI\", */T: -1\n },\n /*::[*/0x0111 /*::]*/: {\n /* n:\"BrtBeginDims\", */T: 1\n },\n /*::[*/0x0112 /*::]*/: {\n /* n:\"BrtEndDims\", */T: -1\n },\n /*::[*/0x0113 /*::]*/: {\n /* n:\"BrtBeginDim\", */T: 1\n },\n /*::[*/0x0114 /*::]*/: {\n /* n:\"BrtEndDim\", */T: -1\n },\n /*::[*/0x0115 /*::]*/: {/* n:\"BrtIndexPartEnd\" */},\n /*::[*/0x0116 /*::]*/: {\n /* n:\"BrtBeginStyleSheet\", */T: 1\n },\n /*::[*/0x0117 /*::]*/: {\n /* n:\"BrtEndStyleSheet\", */T: -1\n },\n /*::[*/0x0118 /*::]*/: {\n /* n:\"BrtBeginSXView\", */T: 1\n },\n /*::[*/0x0119 /*::]*/: {\n /* n:\"BrtEndSXVI\", */T: -1\n },\n /*::[*/0x011A /*::]*/: {\n /* n:\"BrtBeginSXVI\", */T: 1\n },\n /*::[*/0x011B /*::]*/: {\n /* n:\"BrtBeginSXVIs\", */T: 1\n },\n /*::[*/0x011C /*::]*/: {\n /* n:\"BrtEndSXVIs\", */T: -1\n },\n /*::[*/0x011D /*::]*/: {\n /* n:\"BrtBeginSXVD\", */T: 1\n },\n /*::[*/0x011E /*::]*/: {\n /* n:\"BrtEndSXVD\", */T: -1\n },\n /*::[*/0x011F /*::]*/: {\n /* n:\"BrtBeginSXVDs\", */T: 1\n },\n /*::[*/0x0120 /*::]*/: {\n /* n:\"BrtEndSXVDs\", */T: -1\n },\n /*::[*/0x0121 /*::]*/: {\n /* n:\"BrtBeginSXPI\", */T: 1\n },\n /*::[*/0x0122 /*::]*/: {\n /* n:\"BrtEndSXPI\", */T: -1\n },\n /*::[*/0x0123 /*::]*/: {\n /* n:\"BrtBeginSXPIs\", */T: 1\n },\n /*::[*/0x0124 /*::]*/: {\n /* n:\"BrtEndSXPIs\", */T: -1\n },\n /*::[*/0x0125 /*::]*/: {\n /* n:\"BrtBeginSXDI\", */T: 1\n },\n /*::[*/0x0126 /*::]*/: {\n /* n:\"BrtEndSXDI\", */T: -1\n },\n /*::[*/0x0127 /*::]*/: {\n /* n:\"BrtBeginSXDIs\", */T: 1\n },\n /*::[*/0x0128 /*::]*/: {\n /* n:\"BrtEndSXDIs\", */T: -1\n },\n /*::[*/0x0129 /*::]*/: {\n /* n:\"BrtBeginSXLI\", */T: 1\n },\n /*::[*/0x012A /*::]*/: {\n /* n:\"BrtEndSXLI\", */T: -1\n },\n /*::[*/0x012B /*::]*/: {\n /* n:\"BrtBeginSXLIRws\", */T: 1\n },\n /*::[*/0x012C /*::]*/: {\n /* n:\"BrtEndSXLIRws\", */T: -1\n },\n /*::[*/0x012D /*::]*/: {\n /* n:\"BrtBeginSXLICols\", */T: 1\n },\n /*::[*/0x012E /*::]*/: {\n /* n:\"BrtEndSXLICols\", */T: -1\n },\n /*::[*/0x012F /*::]*/: {\n /* n:\"BrtBeginSXFormat\", */T: 1\n },\n /*::[*/0x0130 /*::]*/: {\n /* n:\"BrtEndSXFormat\", */T: -1\n },\n /*::[*/0x0131 /*::]*/: {\n /* n:\"BrtBeginSXFormats\", */T: 1\n },\n /*::[*/0x0132 /*::]*/: {\n /* n:\"BrtEndSxFormats\", */T: -1\n },\n /*::[*/0x0133 /*::]*/: {\n /* n:\"BrtBeginSxSelect\", */T: 1\n },\n /*::[*/0x0134 /*::]*/: {\n /* n:\"BrtEndSxSelect\", */T: -1\n },\n /*::[*/0x0135 /*::]*/: {\n /* n:\"BrtBeginISXVDRws\", */T: 1\n },\n /*::[*/0x0136 /*::]*/: {\n /* n:\"BrtEndISXVDRws\", */T: -1\n },\n /*::[*/0x0137 /*::]*/: {\n /* n:\"BrtBeginISXVDCols\", */T: 1\n },\n /*::[*/0x0138 /*::]*/: {\n /* n:\"BrtEndISXVDCols\", */T: -1\n },\n /*::[*/0x0139 /*::]*/: {\n /* n:\"BrtEndSXLocation\", */T: -1\n },\n /*::[*/0x013A /*::]*/: {\n /* n:\"BrtBeginSXLocation\", */T: 1\n },\n /*::[*/0x013B /*::]*/: {\n /* n:\"BrtEndSXView\", */T: -1\n },\n /*::[*/0x013C /*::]*/: {\n /* n:\"BrtBeginSXTHs\", */T: 1\n },\n /*::[*/0x013D /*::]*/: {\n /* n:\"BrtEndSXTHs\", */T: -1\n },\n /*::[*/0x013E /*::]*/: {\n /* n:\"BrtBeginSXTH\", */T: 1\n },\n /*::[*/0x013F /*::]*/: {\n /* n:\"BrtEndSXTH\", */T: -1\n },\n /*::[*/0x0140 /*::]*/: {\n /* n:\"BrtBeginISXTHRws\", */T: 1\n },\n /*::[*/0x0141 /*::]*/: {\n /* n:\"BrtEndISXTHRws\", */T: -1\n },\n /*::[*/0x0142 /*::]*/: {\n /* n:\"BrtBeginISXTHCols\", */T: 1\n },\n /*::[*/0x0143 /*::]*/: {\n /* n:\"BrtEndISXTHCols\", */T: -1\n },\n /*::[*/0x0144 /*::]*/: {\n /* n:\"BrtBeginSXTDMPS\", */T: 1\n },\n /*::[*/0x0145 /*::]*/: {\n /* n:\"BrtEndSXTDMPs\", */T: -1\n },\n /*::[*/0x0146 /*::]*/: {\n /* n:\"BrtBeginSXTDMP\", */T: 1\n },\n /*::[*/0x0147 /*::]*/: {\n /* n:\"BrtEndSXTDMP\", */T: -1\n },\n /*::[*/0x0148 /*::]*/: {\n /* n:\"BrtBeginSXTHItems\", */T: 1\n },\n /*::[*/0x0149 /*::]*/: {\n /* n:\"BrtEndSXTHItems\", */T: -1\n },\n /*::[*/0x014A /*::]*/: {\n /* n:\"BrtBeginSXTHItem\", */T: 1\n },\n /*::[*/0x014B /*::]*/: {\n /* n:\"BrtEndSXTHItem\", */T: -1\n },\n /*::[*/0x014C /*::]*/: {\n /* n:\"BrtBeginMetadata\", */T: 1\n },\n /*::[*/0x014D /*::]*/: {\n /* n:\"BrtEndMetadata\", */T: -1\n },\n /*::[*/0x014E /*::]*/: {\n /* n:\"BrtBeginEsmdtinfo\", */T: 1\n },\n /*::[*/0x014F /*::]*/: {\n /* n:\"BrtMdtinfo\", */f: parse_BrtMdtinfo\n },\n /*::[*/0x0150 /*::]*/: {\n /* n:\"BrtEndEsmdtinfo\", */T: -1\n },\n /*::[*/0x0151 /*::]*/: {\n /* n:\"BrtBeginEsmdb\", */f: parse_BrtBeginEsmdb,\n T: 1\n },\n /*::[*/0x0152 /*::]*/: {\n /* n:\"BrtEndEsmdb\", */T: -1\n },\n /*::[*/0x0153 /*::]*/: {\n /* n:\"BrtBeginEsfmd\", */T: 1\n },\n /*::[*/0x0154 /*::]*/: {\n /* n:\"BrtEndEsfmd\", */T: -1\n },\n /*::[*/0x0155 /*::]*/: {\n /* n:\"BrtBeginSingleCells\", */T: 1\n },\n /*::[*/0x0156 /*::]*/: {\n /* n:\"BrtEndSingleCells\", */T: -1\n },\n /*::[*/0x0157 /*::]*/: {\n /* n:\"BrtBeginList\", */T: 1\n },\n /*::[*/0x0158 /*::]*/: {\n /* n:\"BrtEndList\", */T: -1\n },\n /*::[*/0x0159 /*::]*/: {\n /* n:\"BrtBeginListCols\", */T: 1\n },\n /*::[*/0x015A /*::]*/: {\n /* n:\"BrtEndListCols\", */T: -1\n },\n /*::[*/0x015B /*::]*/: {\n /* n:\"BrtBeginListCol\", */T: 1\n },\n /*::[*/0x015C /*::]*/: {\n /* n:\"BrtEndListCol\", */T: -1\n },\n /*::[*/0x015D /*::]*/: {\n /* n:\"BrtBeginListXmlCPr\", */T: 1\n },\n /*::[*/0x015E /*::]*/: {\n /* n:\"BrtEndListXmlCPr\", */T: -1\n },\n /*::[*/0x015F /*::]*/: {/* n:\"BrtListCCFmla\" */},\n /*::[*/0x0160 /*::]*/: {/* n:\"BrtListTrFmla\" */},\n /*::[*/0x0161 /*::]*/: {\n /* n:\"BrtBeginExternals\", */T: 1\n },\n /*::[*/0x0162 /*::]*/: {\n /* n:\"BrtEndExternals\", */T: -1\n },\n /*::[*/0x0163 /*::]*/: {\n /* n:\"BrtSupBookSrc\", */f: parse_RelID\n },\n /*::[*/0x0165 /*::]*/: {/* n:\"BrtSupSelf\" */},\n /*::[*/0x0166 /*::]*/: {/* n:\"BrtSupSame\" */},\n /*::[*/0x0167 /*::]*/: {/* n:\"BrtSupTabs\" */},\n /*::[*/0x0168 /*::]*/: {\n /* n:\"BrtBeginSupBook\", */T: 1\n },\n /*::[*/0x0169 /*::]*/: {/* n:\"BrtPlaceholderName\" */},\n /*::[*/0x016A /*::]*/: {\n /* n:\"BrtExternSheet\", */f: parse_ExternSheet\n },\n /*::[*/0x016B /*::]*/: {/* n:\"BrtExternTableStart\" */},\n /*::[*/0x016C /*::]*/: {/* n:\"BrtExternTableEnd\" */},\n /*::[*/0x016E /*::]*/: {/* n:\"BrtExternRowHdr\" */},\n /*::[*/0x016F /*::]*/: {/* n:\"BrtExternCellBlank\" */},\n /*::[*/0x0170 /*::]*/: {/* n:\"BrtExternCellReal\" */},\n /*::[*/0x0171 /*::]*/: {/* n:\"BrtExternCellBool\" */},\n /*::[*/0x0172 /*::]*/: {/* n:\"BrtExternCellError\" */},\n /*::[*/0x0173 /*::]*/: {/* n:\"BrtExternCellString\" */},\n /*::[*/0x0174 /*::]*/: {\n /* n:\"BrtBeginEsmdx\", */T: 1\n },\n /*::[*/0x0175 /*::]*/: {\n /* n:\"BrtEndEsmdx\", */T: -1\n },\n /*::[*/0x0176 /*::]*/: {\n /* n:\"BrtBeginMdxSet\", */T: 1\n },\n /*::[*/0x0177 /*::]*/: {\n /* n:\"BrtEndMdxSet\", */T: -1\n },\n /*::[*/0x0178 /*::]*/: {\n /* n:\"BrtBeginMdxMbrProp\", */T: 1\n },\n /*::[*/0x0179 /*::]*/: {\n /* n:\"BrtEndMdxMbrProp\", */T: -1\n },\n /*::[*/0x017A /*::]*/: {\n /* n:\"BrtBeginMdxKPI\", */T: 1\n },\n /*::[*/0x017B /*::]*/: {\n /* n:\"BrtEndMdxKPI\", */T: -1\n },\n /*::[*/0x017C /*::]*/: {\n /* n:\"BrtBeginEsstr\", */T: 1\n },\n /*::[*/0x017D /*::]*/: {\n /* n:\"BrtEndEsstr\", */T: -1\n },\n /*::[*/0x017E /*::]*/: {\n /* n:\"BrtBeginPRFItem\", */T: 1\n },\n /*::[*/0x017F /*::]*/: {\n /* n:\"BrtEndPRFItem\", */T: -1\n },\n /*::[*/0x0180 /*::]*/: {\n /* n:\"BrtBeginPivotCacheIDs\", */T: 1\n },\n /*::[*/0x0181 /*::]*/: {\n /* n:\"BrtEndPivotCacheIDs\", */T: -1\n },\n /*::[*/0x0182 /*::]*/: {\n /* n:\"BrtBeginPivotCacheID\", */T: 1\n },\n /*::[*/0x0183 /*::]*/: {\n /* n:\"BrtEndPivotCacheID\", */T: -1\n },\n /*::[*/0x0184 /*::]*/: {\n /* n:\"BrtBeginISXVIs\", */T: 1\n },\n /*::[*/0x0185 /*::]*/: {\n /* n:\"BrtEndISXVIs\", */T: -1\n },\n /*::[*/0x0186 /*::]*/: {\n /* n:\"BrtBeginColInfos\", */T: 1\n },\n /*::[*/0x0187 /*::]*/: {\n /* n:\"BrtEndColInfos\", */T: -1\n },\n /*::[*/0x0188 /*::]*/: {\n /* n:\"BrtBeginRwBrk\", */T: 1\n },\n /*::[*/0x0189 /*::]*/: {\n /* n:\"BrtEndRwBrk\", */T: -1\n },\n /*::[*/0x018A /*::]*/: {\n /* n:\"BrtBeginColBrk\", */T: 1\n },\n /*::[*/0x018B /*::]*/: {\n /* n:\"BrtEndColBrk\", */T: -1\n },\n /*::[*/0x018C /*::]*/: {/* n:\"BrtBrk\" */},\n /*::[*/0x018D /*::]*/: {/* n:\"BrtUserBookView\" */},\n /*::[*/0x018E /*::]*/: {/* n:\"BrtInfo\" */},\n /*::[*/0x018F /*::]*/: {/* n:\"BrtCUsr\" */},\n /*::[*/0x0190 /*::]*/: {/* n:\"BrtUsr\" */},\n /*::[*/0x0191 /*::]*/: {\n /* n:\"BrtBeginUsers\", */T: 1\n },\n /*::[*/0x0193 /*::]*/: {/* n:\"BrtEOF\" */},\n /*::[*/0x0194 /*::]*/: {/* n:\"BrtUCR\" */},\n /*::[*/0x0195 /*::]*/: {/* n:\"BrtRRInsDel\" */},\n /*::[*/0x0196 /*::]*/: {/* n:\"BrtRREndInsDel\" */},\n /*::[*/0x0197 /*::]*/: {/* n:\"BrtRRMove\" */},\n /*::[*/0x0198 /*::]*/: {/* n:\"BrtRREndMove\" */},\n /*::[*/0x0199 /*::]*/: {/* n:\"BrtRRChgCell\" */},\n /*::[*/0x019A /*::]*/: {/* n:\"BrtRREndChgCell\" */},\n /*::[*/0x019B /*::]*/: {/* n:\"BrtRRHeader\" */},\n /*::[*/0x019C /*::]*/: {/* n:\"BrtRRUserView\" */},\n /*::[*/0x019D /*::]*/: {/* n:\"BrtRRRenSheet\" */},\n /*::[*/0x019E /*::]*/: {/* n:\"BrtRRInsertSh\" */},\n /*::[*/0x019F /*::]*/: {/* n:\"BrtRRDefName\" */},\n /*::[*/0x01A0 /*::]*/: {/* n:\"BrtRRNote\" */},\n /*::[*/0x01A1 /*::]*/: {/* n:\"BrtRRConflict\" */},\n /*::[*/0x01A2 /*::]*/: {/* n:\"BrtRRTQSIF\" */},\n /*::[*/0x01A3 /*::]*/: {/* n:\"BrtRRFormat\" */},\n /*::[*/0x01A4 /*::]*/: {/* n:\"BrtRREndFormat\" */},\n /*::[*/0x01A5 /*::]*/: {/* n:\"BrtRRAutoFmt\" */},\n /*::[*/0x01A6 /*::]*/: {\n /* n:\"BrtBeginUserShViews\", */T: 1\n },\n /*::[*/0x01A7 /*::]*/: {\n /* n:\"BrtBeginUserShView\", */T: 1\n },\n /*::[*/0x01A8 /*::]*/: {\n /* n:\"BrtEndUserShView\", */T: -1\n },\n /*::[*/0x01A9 /*::]*/: {\n /* n:\"BrtEndUserShViews\", */T: -1\n },\n /*::[*/0x01AA /*::]*/: {\n /* n:\"BrtArrFmla\", */f: parse_BrtArrFmla\n },\n /*::[*/0x01AB /*::]*/: {\n /* n:\"BrtShrFmla\", */f: parse_BrtShrFmla\n },\n /*::[*/0x01AC /*::]*/: {/* n:\"BrtTable\" */},\n /*::[*/0x01AD /*::]*/: {\n /* n:\"BrtBeginExtConnections\", */T: 1\n },\n /*::[*/0x01AE /*::]*/: {\n /* n:\"BrtEndExtConnections\", */T: -1\n },\n /*::[*/0x01AF /*::]*/: {\n /* n:\"BrtBeginPCDCalcMems\", */T: 1\n },\n /*::[*/0x01B0 /*::]*/: {\n /* n:\"BrtEndPCDCalcMems\", */T: -1\n },\n /*::[*/0x01B1 /*::]*/: {\n /* n:\"BrtBeginPCDCalcMem\", */T: 1\n },\n /*::[*/0x01B2 /*::]*/: {\n /* n:\"BrtEndPCDCalcMem\", */T: -1\n },\n /*::[*/0x01B3 /*::]*/: {\n /* n:\"BrtBeginPCDHGLevels\", */T: 1\n },\n /*::[*/0x01B4 /*::]*/: {\n /* n:\"BrtEndPCDHGLevels\", */T: -1\n },\n /*::[*/0x01B5 /*::]*/: {\n /* n:\"BrtBeginPCDHGLevel\", */T: 1\n },\n /*::[*/0x01B6 /*::]*/: {\n /* n:\"BrtEndPCDHGLevel\", */T: -1\n },\n /*::[*/0x01B7 /*::]*/: {\n /* n:\"BrtBeginPCDHGLGroups\", */T: 1\n },\n /*::[*/0x01B8 /*::]*/: {\n /* n:\"BrtEndPCDHGLGroups\", */T: -1\n },\n /*::[*/0x01B9 /*::]*/: {\n /* n:\"BrtBeginPCDHGLGroup\", */T: 1\n },\n /*::[*/0x01BA /*::]*/: {\n /* n:\"BrtEndPCDHGLGroup\", */T: -1\n },\n /*::[*/0x01BB /*::]*/: {\n /* n:\"BrtBeginPCDHGLGMembers\", */T: 1\n },\n /*::[*/0x01BC /*::]*/: {\n /* n:\"BrtEndPCDHGLGMembers\", */T: -1\n },\n /*::[*/0x01BD /*::]*/: {\n /* n:\"BrtBeginPCDHGLGMember\", */T: 1\n },\n /*::[*/0x01BE /*::]*/: {\n /* n:\"BrtEndPCDHGLGMember\", */T: -1\n },\n /*::[*/0x01BF /*::]*/: {\n /* n:\"BrtBeginQSI\", */T: 1\n },\n /*::[*/0x01C0 /*::]*/: {\n /* n:\"BrtEndQSI\", */T: -1\n },\n /*::[*/0x01C1 /*::]*/: {\n /* n:\"BrtBeginQSIR\", */T: 1\n },\n /*::[*/0x01C2 /*::]*/: {\n /* n:\"BrtEndQSIR\", */T: -1\n },\n /*::[*/0x01C3 /*::]*/: {\n /* n:\"BrtBeginDeletedNames\", */T: 1\n },\n /*::[*/0x01C4 /*::]*/: {\n /* n:\"BrtEndDeletedNames\", */T: -1\n },\n /*::[*/0x01C5 /*::]*/: {\n /* n:\"BrtBeginDeletedName\", */T: 1\n },\n /*::[*/0x01C6 /*::]*/: {\n /* n:\"BrtEndDeletedName\", */T: -1\n },\n /*::[*/0x01C7 /*::]*/: {\n /* n:\"BrtBeginQSIFs\", */T: 1\n },\n /*::[*/0x01C8 /*::]*/: {\n /* n:\"BrtEndQSIFs\", */T: -1\n },\n /*::[*/0x01C9 /*::]*/: {\n /* n:\"BrtBeginQSIF\", */T: 1\n },\n /*::[*/0x01CA /*::]*/: {\n /* n:\"BrtEndQSIF\", */T: -1\n },\n /*::[*/0x01CB /*::]*/: {\n /* n:\"BrtBeginAutoSortScope\", */T: 1\n },\n /*::[*/0x01CC /*::]*/: {\n /* n:\"BrtEndAutoSortScope\", */T: -1\n },\n /*::[*/0x01CD /*::]*/: {\n /* n:\"BrtBeginConditionalFormatting\", */T: 1\n },\n /*::[*/0x01CE /*::]*/: {\n /* n:\"BrtEndConditionalFormatting\", */T: -1\n },\n /*::[*/0x01CF /*::]*/: {\n /* n:\"BrtBeginCFRule\", */T: 1\n },\n /*::[*/0x01D0 /*::]*/: {\n /* n:\"BrtEndCFRule\", */T: -1\n },\n /*::[*/0x01D1 /*::]*/: {\n /* n:\"BrtBeginIconSet\", */T: 1\n },\n /*::[*/0x01D2 /*::]*/: {\n /* n:\"BrtEndIconSet\", */T: -1\n },\n /*::[*/0x01D3 /*::]*/: {\n /* n:\"BrtBeginDatabar\", */T: 1\n },\n /*::[*/0x01D4 /*::]*/: {\n /* n:\"BrtEndDatabar\", */T: -1\n },\n /*::[*/0x01D5 /*::]*/: {\n /* n:\"BrtBeginColorScale\", */T: 1\n },\n /*::[*/0x01D6 /*::]*/: {\n /* n:\"BrtEndColorScale\", */T: -1\n },\n /*::[*/0x01D7 /*::]*/: {/* n:\"BrtCFVO\" */},\n /*::[*/0x01D8 /*::]*/: {/* n:\"BrtExternValueMeta\" */},\n /*::[*/0x01D9 /*::]*/: {\n /* n:\"BrtBeginColorPalette\", */T: 1\n },\n /*::[*/0x01DA /*::]*/: {\n /* n:\"BrtEndColorPalette\", */T: -1\n },\n /*::[*/0x01DB /*::]*/: {/* n:\"BrtIndexedColor\" */},\n /*::[*/0x01DC /*::]*/: {\n /* n:\"BrtMargins\", */f: parse_BrtMargins\n },\n /*::[*/0x01DD /*::]*/: {/* n:\"BrtPrintOptions\" */},\n /*::[*/0x01DE /*::]*/: {/* n:\"BrtPageSetup\" */},\n /*::[*/0x01DF /*::]*/: {\n /* n:\"BrtBeginHeaderFooter\", */T: 1\n },\n /*::[*/0x01E0 /*::]*/: {\n /* n:\"BrtEndHeaderFooter\", */T: -1\n },\n /*::[*/0x01E1 /*::]*/: {\n /* n:\"BrtBeginSXCrtFormat\", */T: 1\n },\n /*::[*/0x01E2 /*::]*/: {\n /* n:\"BrtEndSXCrtFormat\", */T: -1\n },\n /*::[*/0x01E3 /*::]*/: {\n /* n:\"BrtBeginSXCrtFormats\", */T: 1\n },\n /*::[*/0x01E4 /*::]*/: {\n /* n:\"BrtEndSXCrtFormats\", */T: -1\n },\n /*::[*/0x01E5 /*::]*/: {\n /* n:\"BrtWsFmtInfo\", */f: parse_BrtWsFmtInfo\n },\n /*::[*/0x01E6 /*::]*/: {\n /* n:\"BrtBeginMgs\", */T: 1\n },\n /*::[*/0x01E7 /*::]*/: {\n /* n:\"BrtEndMGs\", */T: -1\n },\n /*::[*/0x01E8 /*::]*/: {\n /* n:\"BrtBeginMGMaps\", */T: 1\n },\n /*::[*/0x01E9 /*::]*/: {\n /* n:\"BrtEndMGMaps\", */T: -1\n },\n /*::[*/0x01EA /*::]*/: {\n /* n:\"BrtBeginMG\", */T: 1\n },\n /*::[*/0x01EB /*::]*/: {\n /* n:\"BrtEndMG\", */T: -1\n },\n /*::[*/0x01EC /*::]*/: {\n /* n:\"BrtBeginMap\", */T: 1\n },\n /*::[*/0x01ED /*::]*/: {\n /* n:\"BrtEndMap\", */T: -1\n },\n /*::[*/0x01EE /*::]*/: {\n /* n:\"BrtHLink\", */f: parse_BrtHLink\n },\n /*::[*/0x01EF /*::]*/: {\n /* n:\"BrtBeginDCon\", */T: 1\n },\n /*::[*/0x01F0 /*::]*/: {\n /* n:\"BrtEndDCon\", */T: -1\n },\n /*::[*/0x01F1 /*::]*/: {\n /* n:\"BrtBeginDRefs\", */T: 1\n },\n /*::[*/0x01F2 /*::]*/: {\n /* n:\"BrtEndDRefs\", */T: -1\n },\n /*::[*/0x01F3 /*::]*/: {/* n:\"BrtDRef\" */},\n /*::[*/0x01F4 /*::]*/: {\n /* n:\"BrtBeginScenMan\", */T: 1\n },\n /*::[*/0x01F5 /*::]*/: {\n /* n:\"BrtEndScenMan\", */T: -1\n },\n /*::[*/0x01F6 /*::]*/: {\n /* n:\"BrtBeginSct\", */T: 1\n },\n /*::[*/0x01F7 /*::]*/: {\n /* n:\"BrtEndSct\", */T: -1\n },\n /*::[*/0x01F8 /*::]*/: {/* n:\"BrtSlc\" */},\n /*::[*/0x01F9 /*::]*/: {\n /* n:\"BrtBeginDXFs\", */T: 1\n },\n /*::[*/0x01FA /*::]*/: {\n /* n:\"BrtEndDXFs\", */T: -1\n },\n /*::[*/0x01FB /*::]*/: {/* n:\"BrtDXF\" */},\n /*::[*/0x01FC /*::]*/: {\n /* n:\"BrtBeginTableStyles\", */T: 1\n },\n /*::[*/0x01FD /*::]*/: {\n /* n:\"BrtEndTableStyles\", */T: -1\n },\n /*::[*/0x01FE /*::]*/: {\n /* n:\"BrtBeginTableStyle\", */T: 1\n },\n /*::[*/0x01FF /*::]*/: {\n /* n:\"BrtEndTableStyle\", */T: -1\n },\n /*::[*/0x0200 /*::]*/: {/* n:\"BrtTableStyleElement\" */},\n /*::[*/0x0201 /*::]*/: {/* n:\"BrtTableStyleClient\" */},\n /*::[*/0x0202 /*::]*/: {\n /* n:\"BrtBeginVolDeps\", */T: 1\n },\n /*::[*/0x0203 /*::]*/: {\n /* n:\"BrtEndVolDeps\", */T: -1\n },\n /*::[*/0x0204 /*::]*/: {\n /* n:\"BrtBeginVolType\", */T: 1\n },\n /*::[*/0x0205 /*::]*/: {\n /* n:\"BrtEndVolType\", */T: -1\n },\n /*::[*/0x0206 /*::]*/: {\n /* n:\"BrtBeginVolMain\", */T: 1\n },\n /*::[*/0x0207 /*::]*/: {\n /* n:\"BrtEndVolMain\", */T: -1\n },\n /*::[*/0x0208 /*::]*/: {\n /* n:\"BrtBeginVolTopic\", */T: 1\n },\n /*::[*/0x0209 /*::]*/: {\n /* n:\"BrtEndVolTopic\", */T: -1\n },\n /*::[*/0x020A /*::]*/: {/* n:\"BrtVolSubtopic\" */},\n /*::[*/0x020B /*::]*/: {/* n:\"BrtVolRef\" */},\n /*::[*/0x020C /*::]*/: {/* n:\"BrtVolNum\" */},\n /*::[*/0x020D /*::]*/: {/* n:\"BrtVolErr\" */},\n /*::[*/0x020E /*::]*/: {/* n:\"BrtVolStr\" */},\n /*::[*/0x020F /*::]*/: {/* n:\"BrtVolBool\" */},\n /*::[*/0x0210 /*::]*/: {\n /* n:\"BrtBeginCalcChain$\", */T: 1\n },\n /*::[*/0x0211 /*::]*/: {\n /* n:\"BrtEndCalcChain$\", */T: -1\n },\n /*::[*/0x0212 /*::]*/: {\n /* n:\"BrtBeginSortState\", */T: 1\n },\n /*::[*/0x0213 /*::]*/: {\n /* n:\"BrtEndSortState\", */T: -1\n },\n /*::[*/0x0214 /*::]*/: {\n /* n:\"BrtBeginSortCond\", */T: 1\n },\n /*::[*/0x0215 /*::]*/: {\n /* n:\"BrtEndSortCond\", */T: -1\n },\n /*::[*/0x0216 /*::]*/: {/* n:\"BrtBookProtection\" */},\n /*::[*/0x0217 /*::]*/: {/* n:\"BrtSheetProtection\" */},\n /*::[*/0x0218 /*::]*/: {/* n:\"BrtRangeProtection\" */},\n /*::[*/0x0219 /*::]*/: {/* n:\"BrtPhoneticInfo\" */},\n /*::[*/0x021A /*::]*/: {\n /* n:\"BrtBeginECTxtWiz\", */T: 1\n },\n /*::[*/0x021B /*::]*/: {\n /* n:\"BrtEndECTxtWiz\", */T: -1\n },\n /*::[*/0x021C /*::]*/: {\n /* n:\"BrtBeginECTWFldInfoLst\", */T: 1\n },\n /*::[*/0x021D /*::]*/: {\n /* n:\"BrtEndECTWFldInfoLst\", */T: -1\n },\n /*::[*/0x021E /*::]*/: {\n /* n:\"BrtBeginECTwFldInfo\", */T: 1\n },\n /*::[*/0x0224 /*::]*/: {/* n:\"BrtFileSharing\" */},\n /*::[*/0x0225 /*::]*/: {/* n:\"BrtOleSize\" */},\n /*::[*/0x0226 /*::]*/: {\n /* n:\"BrtDrawing\", */f: parse_RelID\n },\n /*::[*/0x0227 /*::]*/: {/* n:\"BrtLegacyDrawing\" */},\n /*::[*/0x0228 /*::]*/: {/* n:\"BrtLegacyDrawingHF\" */},\n /*::[*/0x0229 /*::]*/: {/* n:\"BrtWebOpt\" */},\n /*::[*/0x022A /*::]*/: {\n /* n:\"BrtBeginWebPubItems\", */T: 1\n },\n /*::[*/0x022B /*::]*/: {\n /* n:\"BrtEndWebPubItems\", */T: -1\n },\n /*::[*/0x022C /*::]*/: {\n /* n:\"BrtBeginWebPubItem\", */T: 1\n },\n /*::[*/0x022D /*::]*/: {\n /* n:\"BrtEndWebPubItem\", */T: -1\n },\n /*::[*/0x022E /*::]*/: {\n /* n:\"BrtBeginSXCondFmt\", */T: 1\n },\n /*::[*/0x022F /*::]*/: {\n /* n:\"BrtEndSXCondFmt\", */T: -1\n },\n /*::[*/0x0230 /*::]*/: {\n /* n:\"BrtBeginSXCondFmts\", */T: 1\n },\n /*::[*/0x0231 /*::]*/: {\n /* n:\"BrtEndSXCondFmts\", */T: -1\n },\n /*::[*/0x0232 /*::]*/: {/* n:\"BrtBkHim\" */},\n /*::[*/0x0234 /*::]*/: {/* n:\"BrtColor\" */},\n /*::[*/0x0235 /*::]*/: {\n /* n:\"BrtBeginIndexedColors\", */T: 1\n },\n /*::[*/0x0236 /*::]*/: {\n /* n:\"BrtEndIndexedColors\", */T: -1\n },\n /*::[*/0x0239 /*::]*/: {\n /* n:\"BrtBeginMRUColors\", */T: 1\n },\n /*::[*/0x023A /*::]*/: {\n /* n:\"BrtEndMRUColors\", */T: -1\n },\n /*::[*/0x023C /*::]*/: {/* n:\"BrtMRUColor\" */},\n /*::[*/0x023D /*::]*/: {\n /* n:\"BrtBeginDVals\", */T: 1\n },\n /*::[*/0x023E /*::]*/: {\n /* n:\"BrtEndDVals\", */T: -1\n },\n /*::[*/0x0241 /*::]*/: {/* n:\"BrtSupNameStart\" */},\n /*::[*/0x0242 /*::]*/: {/* n:\"BrtSupNameValueStart\" */},\n /*::[*/0x0243 /*::]*/: {/* n:\"BrtSupNameValueEnd\" */},\n /*::[*/0x0244 /*::]*/: {/* n:\"BrtSupNameNum\" */},\n /*::[*/0x0245 /*::]*/: {/* n:\"BrtSupNameErr\" */},\n /*::[*/0x0246 /*::]*/: {/* n:\"BrtSupNameSt\" */},\n /*::[*/0x0247 /*::]*/: {/* n:\"BrtSupNameNil\" */},\n /*::[*/0x0248 /*::]*/: {/* n:\"BrtSupNameBool\" */},\n /*::[*/0x0249 /*::]*/: {/* n:\"BrtSupNameFmla\" */},\n /*::[*/0x024A /*::]*/: {/* n:\"BrtSupNameBits\" */},\n /*::[*/0x024B /*::]*/: {/* n:\"BrtSupNameEnd\" */},\n /*::[*/0x024C /*::]*/: {\n /* n:\"BrtEndSupBook\", */T: -1\n },\n /*::[*/0x024D /*::]*/: {/* n:\"BrtCellSmartTagProperty\" */},\n /*::[*/0x024E /*::]*/: {\n /* n:\"BrtBeginCellSmartTag\", */T: 1\n },\n /*::[*/0x024F /*::]*/: {\n /* n:\"BrtEndCellSmartTag\", */T: -1\n },\n /*::[*/0x0250 /*::]*/: {\n /* n:\"BrtBeginCellSmartTags\", */T: 1\n },\n /*::[*/0x0251 /*::]*/: {\n /* n:\"BrtEndCellSmartTags\", */T: -1\n },\n /*::[*/0x0252 /*::]*/: {\n /* n:\"BrtBeginSmartTags\", */T: 1\n },\n /*::[*/0x0253 /*::]*/: {\n /* n:\"BrtEndSmartTags\", */T: -1\n },\n /*::[*/0x0254 /*::]*/: {/* n:\"BrtSmartTagType\" */},\n /*::[*/0x0255 /*::]*/: {\n /* n:\"BrtBeginSmartTagTypes\", */T: 1\n },\n /*::[*/0x0256 /*::]*/: {\n /* n:\"BrtEndSmartTagTypes\", */T: -1\n },\n /*::[*/0x0257 /*::]*/: {\n /* n:\"BrtBeginSXFilters\", */T: 1\n },\n /*::[*/0x0258 /*::]*/: {\n /* n:\"BrtEndSXFilters\", */T: -1\n },\n /*::[*/0x0259 /*::]*/: {\n /* n:\"BrtBeginSXFILTER\", */T: 1\n },\n /*::[*/0x025A /*::]*/: {\n /* n:\"BrtEndSXFilter\", */T: -1\n },\n /*::[*/0x025B /*::]*/: {\n /* n:\"BrtBeginFills\", */T: 1\n },\n /*::[*/0x025C /*::]*/: {\n /* n:\"BrtEndFills\", */T: -1\n },\n /*::[*/0x025D /*::]*/: {\n /* n:\"BrtBeginCellWatches\", */T: 1\n },\n /*::[*/0x025E /*::]*/: {\n /* n:\"BrtEndCellWatches\", */T: -1\n },\n /*::[*/0x025F /*::]*/: {/* n:\"BrtCellWatch\" */},\n /*::[*/0x0260 /*::]*/: {\n /* n:\"BrtBeginCRErrs\", */T: 1\n },\n /*::[*/0x0261 /*::]*/: {\n /* n:\"BrtEndCRErrs\", */T: -1\n },\n /*::[*/0x0262 /*::]*/: {/* n:\"BrtCrashRecErr\" */},\n /*::[*/0x0263 /*::]*/: {\n /* n:\"BrtBeginFonts\", */T: 1\n },\n /*::[*/0x0264 /*::]*/: {\n /* n:\"BrtEndFonts\", */T: -1\n },\n /*::[*/0x0265 /*::]*/: {\n /* n:\"BrtBeginBorders\", */T: 1\n },\n /*::[*/0x0266 /*::]*/: {\n /* n:\"BrtEndBorders\", */T: -1\n },\n /*::[*/0x0267 /*::]*/: {\n /* n:\"BrtBeginFmts\", */T: 1\n },\n /*::[*/0x0268 /*::]*/: {\n /* n:\"BrtEndFmts\", */T: -1\n },\n /*::[*/0x0269 /*::]*/: {\n /* n:\"BrtBeginCellXFs\", */T: 1\n },\n /*::[*/0x026A /*::]*/: {\n /* n:\"BrtEndCellXFs\", */T: -1\n },\n /*::[*/0x026B /*::]*/: {\n /* n:\"BrtBeginStyles\", */T: 1\n },\n /*::[*/0x026C /*::]*/: {\n /* n:\"BrtEndStyles\", */T: -1\n },\n /*::[*/0x0271 /*::]*/: {/* n:\"BrtBigName\" */},\n /*::[*/0x0272 /*::]*/: {\n /* n:\"BrtBeginCellStyleXFs\", */T: 1\n },\n /*::[*/0x0273 /*::]*/: {\n /* n:\"BrtEndCellStyleXFs\", */T: -1\n },\n /*::[*/0x0274 /*::]*/: {\n /* n:\"BrtBeginComments\", */T: 1\n },\n /*::[*/0x0275 /*::]*/: {\n /* n:\"BrtEndComments\", */T: -1\n },\n /*::[*/0x0276 /*::]*/: {\n /* n:\"BrtBeginCommentAuthors\", */T: 1\n },\n /*::[*/0x0277 /*::]*/: {\n /* n:\"BrtEndCommentAuthors\", */T: -1\n },\n /*::[*/0x0278 /*::]*/: {\n /* n:\"BrtCommentAuthor\", */f: parse_BrtCommentAuthor\n },\n /*::[*/0x0279 /*::]*/: {\n /* n:\"BrtBeginCommentList\", */T: 1\n },\n /*::[*/0x027A /*::]*/: {\n /* n:\"BrtEndCommentList\", */T: -1\n },\n /*::[*/0x027B /*::]*/: {\n /* n:\"BrtBeginComment\", */T: 1,\n f: parse_BrtBeginComment\n },\n /*::[*/0x027C /*::]*/: {\n /* n:\"BrtEndComment\", */T: -1\n },\n /*::[*/0x027D /*::]*/: {\n /* n:\"BrtCommentText\", */f: parse_BrtCommentText\n },\n /*::[*/0x027E /*::]*/: {\n /* n:\"BrtBeginOleObjects\", */T: 1\n },\n /*::[*/0x027F /*::]*/: {/* n:\"BrtOleObject\" */},\n /*::[*/0x0280 /*::]*/: {\n /* n:\"BrtEndOleObjects\", */T: -1\n },\n /*::[*/0x0281 /*::]*/: {\n /* n:\"BrtBeginSxrules\", */T: 1\n },\n /*::[*/0x0282 /*::]*/: {\n /* n:\"BrtEndSxRules\", */T: -1\n },\n /*::[*/0x0283 /*::]*/: {\n /* n:\"BrtBeginActiveXControls\", */T: 1\n },\n /*::[*/0x0284 /*::]*/: {/* n:\"BrtActiveX\" */},\n /*::[*/0x0285 /*::]*/: {\n /* n:\"BrtEndActiveXControls\", */T: -1\n },\n /*::[*/0x0286 /*::]*/: {\n /* n:\"BrtBeginPCDSDTCEMembersSortBy\", */T: 1\n },\n /*::[*/0x0288 /*::]*/: {\n /* n:\"BrtBeginCellIgnoreECs\", */T: 1\n },\n /*::[*/0x0289 /*::]*/: {/* n:\"BrtCellIgnoreEC\" */},\n /*::[*/0x028A /*::]*/: {\n /* n:\"BrtEndCellIgnoreECs\", */T: -1\n },\n /*::[*/0x028B /*::]*/: {\n /* n:\"BrtCsProp\", */f: parse_BrtCsProp\n },\n /*::[*/0x028C /*::]*/: {/* n:\"BrtCsPageSetup\" */},\n /*::[*/0x028D /*::]*/: {\n /* n:\"BrtBeginUserCsViews\", */T: 1\n },\n /*::[*/0x028E /*::]*/: {\n /* n:\"BrtEndUserCsViews\", */T: -1\n },\n /*::[*/0x028F /*::]*/: {\n /* n:\"BrtBeginUserCsView\", */T: 1\n },\n /*::[*/0x0290 /*::]*/: {\n /* n:\"BrtEndUserCsView\", */T: -1\n },\n /*::[*/0x0291 /*::]*/: {\n /* n:\"BrtBeginPcdSFCIEntries\", */T: 1\n },\n /*::[*/0x0292 /*::]*/: {\n /* n:\"BrtEndPCDSFCIEntries\", */T: -1\n },\n /*::[*/0x0293 /*::]*/: {/* n:\"BrtPCDSFCIEntry\" */},\n /*::[*/0x0294 /*::]*/: {\n /* n:\"BrtBeginListParts\", */T: 1\n },\n /*::[*/0x0295 /*::]*/: {/* n:\"BrtListPart\" */},\n /*::[*/0x0296 /*::]*/: {\n /* n:\"BrtEndListParts\", */T: -1\n },\n /*::[*/0x0297 /*::]*/: {/* n:\"BrtSheetCalcProp\" */},\n /*::[*/0x0298 /*::]*/: {\n /* n:\"BrtBeginFnGroup\", */T: 1\n },\n /*::[*/0x0299 /*::]*/: {/* n:\"BrtFnGroup\" */},\n /*::[*/0x029A /*::]*/: {\n /* n:\"BrtEndFnGroup\", */T: -1\n },\n /*::[*/0x029B /*::]*/: {/* n:\"BrtSupAddin\" */},\n /*::[*/0x029C /*::]*/: {/* n:\"BrtSXTDMPOrder\" */},\n /*::[*/0x029D /*::]*/: {/* n:\"BrtCsProtection\" */},\n /*::[*/0x029F /*::]*/: {\n /* n:\"BrtBeginWsSortMap\", */T: 1\n },\n /*::[*/0x02A0 /*::]*/: {\n /* n:\"BrtEndWsSortMap\", */T: -1\n },\n /*::[*/0x02A1 /*::]*/: {\n /* n:\"BrtBeginRRSort\", */T: 1\n },\n /*::[*/0x02A2 /*::]*/: {\n /* n:\"BrtEndRRSort\", */T: -1\n },\n /*::[*/0x02A3 /*::]*/: {/* n:\"BrtRRSortItem\" */},\n /*::[*/0x02A4 /*::]*/: {/* n:\"BrtFileSharingIso\" */},\n /*::[*/0x02A5 /*::]*/: {/* n:\"BrtBookProtectionIso\" */},\n /*::[*/0x02A6 /*::]*/: {/* n:\"BrtSheetProtectionIso\" */},\n /*::[*/0x02A7 /*::]*/: {/* n:\"BrtCsProtectionIso\" */},\n /*::[*/0x02A8 /*::]*/: {/* n:\"BrtRangeProtectionIso\" */},\n /*::[*/0x02A9 /*::]*/: {/* n:\"BrtDValList\" */},\n /*::[*/0x0400 /*::]*/: {/* n:\"BrtRwDescent\" */},\n /*::[*/0x0401 /*::]*/: {/* n:\"BrtKnownFonts\" */},\n /*::[*/0x0402 /*::]*/: {\n /* n:\"BrtBeginSXTupleSet\", */T: 1\n },\n /*::[*/0x0403 /*::]*/: {\n /* n:\"BrtEndSXTupleSet\", */T: -1\n },\n /*::[*/0x0404 /*::]*/: {\n /* n:\"BrtBeginSXTupleSetHeader\", */T: 1\n },\n /*::[*/0x0405 /*::]*/: {\n /* n:\"BrtEndSXTupleSetHeader\", */T: -1\n },\n /*::[*/0x0406 /*::]*/: {/* n:\"BrtSXTupleSetHeaderItem\" */},\n /*::[*/0x0407 /*::]*/: {\n /* n:\"BrtBeginSXTupleSetData\", */T: 1\n },\n /*::[*/0x0408 /*::]*/: {\n /* n:\"BrtEndSXTupleSetData\", */T: -1\n },\n /*::[*/0x0409 /*::]*/: {\n /* n:\"BrtBeginSXTupleSetRow\", */T: 1\n },\n /*::[*/0x040A /*::]*/: {\n /* n:\"BrtEndSXTupleSetRow\", */T: -1\n },\n /*::[*/0x040B /*::]*/: {/* n:\"BrtSXTupleSetRowItem\" */},\n /*::[*/0x040C /*::]*/: {/* n:\"BrtNameExt\" */},\n /*::[*/0x040D /*::]*/: {/* n:\"BrtPCDH14\" */},\n /*::[*/0x040E /*::]*/: {\n /* n:\"BrtBeginPCDCalcMem14\", */T: 1\n },\n /*::[*/0x040F /*::]*/: {\n /* n:\"BrtEndPCDCalcMem14\", */T: -1\n },\n /*::[*/0x0410 /*::]*/: {/* n:\"BrtSXTH14\" */},\n /*::[*/0x0411 /*::]*/: {\n /* n:\"BrtBeginSparklineGroup\", */T: 1\n },\n /*::[*/0x0412 /*::]*/: {\n /* n:\"BrtEndSparklineGroup\", */T: -1\n },\n /*::[*/0x0413 /*::]*/: {/* n:\"BrtSparkline\" */},\n /*::[*/0x0414 /*::]*/: {/* n:\"BrtSXDI14\" */},\n /*::[*/0x0415 /*::]*/: {/* n:\"BrtWsFmtInfoEx14\" */},\n /*::[*/0x0416 /*::]*/: {\n /* n:\"BrtBeginConditionalFormatting14\", */T: 1\n },\n /*::[*/0x0417 /*::]*/: {\n /* n:\"BrtEndConditionalFormatting14\", */T: -1\n },\n /*::[*/0x0418 /*::]*/: {\n /* n:\"BrtBeginCFRule14\", */T: 1\n },\n /*::[*/0x0419 /*::]*/: {\n /* n:\"BrtEndCFRule14\", */T: -1\n },\n /*::[*/0x041A /*::]*/: {/* n:\"BrtCFVO14\" */},\n /*::[*/0x041B /*::]*/: {\n /* n:\"BrtBeginDatabar14\", */T: 1\n },\n /*::[*/0x041C /*::]*/: {\n /* n:\"BrtBeginIconSet14\", */T: 1\n },\n /*::[*/0x041D /*::]*/: {\n /* n:\"BrtDVal14\", */f: parse_BrtDVal14\n },\n /*::[*/0x041E /*::]*/: {\n /* n:\"BrtBeginDVals14\", */T: 1\n },\n /*::[*/0x041F /*::]*/: {/* n:\"BrtColor14\" */},\n /*::[*/0x0420 /*::]*/: {\n /* n:\"BrtBeginSparklines\", */T: 1\n },\n /*::[*/0x0421 /*::]*/: {\n /* n:\"BrtEndSparklines\", */T: -1\n },\n /*::[*/0x0422 /*::]*/: {\n /* n:\"BrtBeginSparklineGroups\", */T: 1\n },\n /*::[*/0x0423 /*::]*/: {\n /* n:\"BrtEndSparklineGroups\", */T: -1\n },\n /*::[*/0x0425 /*::]*/: {/* n:\"BrtSXVD14\" */},\n /*::[*/0x0426 /*::]*/: {\n /* n:\"BrtBeginSXView14\", */T: 1\n },\n /*::[*/0x0427 /*::]*/: {\n /* n:\"BrtEndSXView14\", */T: -1\n },\n /*::[*/0x0428 /*::]*/: {\n /* n:\"BrtBeginSXView16\", */T: 1\n },\n /*::[*/0x0429 /*::]*/: {\n /* n:\"BrtEndSXView16\", */T: -1\n },\n /*::[*/0x042A /*::]*/: {\n /* n:\"BrtBeginPCD14\", */T: 1\n },\n /*::[*/0x042B /*::]*/: {\n /* n:\"BrtEndPCD14\", */T: -1\n },\n /*::[*/0x042C /*::]*/: {\n /* n:\"BrtBeginExtConn14\", */T: 1\n },\n /*::[*/0x042D /*::]*/: {\n /* n:\"BrtEndExtConn14\", */T: -1\n },\n /*::[*/0x042E /*::]*/: {\n /* n:\"BrtBeginSlicerCacheIDs\", */T: 1\n },\n /*::[*/0x042F /*::]*/: {\n /* n:\"BrtEndSlicerCacheIDs\", */T: -1\n },\n /*::[*/0x0430 /*::]*/: {\n /* n:\"BrtBeginSlicerCacheID\", */T: 1\n },\n /*::[*/0x0431 /*::]*/: {\n /* n:\"BrtEndSlicerCacheID\", */T: -1\n },\n /*::[*/0x0433 /*::]*/: {\n /* n:\"BrtBeginSlicerCache\", */T: 1\n },\n /*::[*/0x0434 /*::]*/: {\n /* n:\"BrtEndSlicerCache\", */T: -1\n },\n /*::[*/0x0435 /*::]*/: {\n /* n:\"BrtBeginSlicerCacheDef\", */T: 1\n },\n /*::[*/0x0436 /*::]*/: {\n /* n:\"BrtEndSlicerCacheDef\", */T: -1\n },\n /*::[*/0x0437 /*::]*/: {\n /* n:\"BrtBeginSlicersEx\", */T: 1\n },\n /*::[*/0x0438 /*::]*/: {\n /* n:\"BrtEndSlicersEx\", */T: -1\n },\n /*::[*/0x0439 /*::]*/: {\n /* n:\"BrtBeginSlicerEx\", */T: 1\n },\n /*::[*/0x043A /*::]*/: {\n /* n:\"BrtEndSlicerEx\", */T: -1\n },\n /*::[*/0x043B /*::]*/: {\n /* n:\"BrtBeginSlicer\", */T: 1\n },\n /*::[*/0x043C /*::]*/: {\n /* n:\"BrtEndSlicer\", */T: -1\n },\n /*::[*/0x043D /*::]*/: {/* n:\"BrtSlicerCachePivotTables\" */},\n /*::[*/0x043E /*::]*/: {\n /* n:\"BrtBeginSlicerCacheOlapImpl\", */T: 1\n },\n /*::[*/0x043F /*::]*/: {\n /* n:\"BrtEndSlicerCacheOlapImpl\", */T: -1\n },\n /*::[*/0x0440 /*::]*/: {\n /* n:\"BrtBeginSlicerCacheLevelsData\", */T: 1\n },\n /*::[*/0x0441 /*::]*/: {\n /* n:\"BrtEndSlicerCacheLevelsData\", */T: -1\n },\n /*::[*/0x0442 /*::]*/: {\n /* n:\"BrtBeginSlicerCacheLevelData\", */T: 1\n },\n /*::[*/0x0443 /*::]*/: {\n /* n:\"BrtEndSlicerCacheLevelData\", */T: -1\n },\n /*::[*/0x0444 /*::]*/: {\n /* n:\"BrtBeginSlicerCacheSiRanges\", */T: 1\n },\n /*::[*/0x0445 /*::]*/: {\n /* n:\"BrtEndSlicerCacheSiRanges\", */T: -1\n },\n /*::[*/0x0446 /*::]*/: {\n /* n:\"BrtBeginSlicerCacheSiRange\", */T: 1\n },\n /*::[*/0x0447 /*::]*/: {\n /* n:\"BrtEndSlicerCacheSiRange\", */T: -1\n },\n /*::[*/0x0448 /*::]*/: {/* n:\"BrtSlicerCacheOlapItem\" */},\n /*::[*/0x0449 /*::]*/: {\n /* n:\"BrtBeginSlicerCacheSelections\", */T: 1\n },\n /*::[*/0x044A /*::]*/: {/* n:\"BrtSlicerCacheSelection\" */},\n /*::[*/0x044B /*::]*/: {\n /* n:\"BrtEndSlicerCacheSelections\", */T: -1\n },\n /*::[*/0x044C /*::]*/: {\n /* n:\"BrtBeginSlicerCacheNative\", */T: 1\n },\n /*::[*/0x044D /*::]*/: {\n /* n:\"BrtEndSlicerCacheNative\", */T: -1\n },\n /*::[*/0x044E /*::]*/: {/* n:\"BrtSlicerCacheNativeItem\" */},\n /*::[*/0x044F /*::]*/: {/* n:\"BrtRangeProtection14\" */},\n /*::[*/0x0450 /*::]*/: {/* n:\"BrtRangeProtectionIso14\" */},\n /*::[*/0x0451 /*::]*/: {/* n:\"BrtCellIgnoreEC14\" */},\n /*::[*/0x0457 /*::]*/: {/* n:\"BrtList14\" */},\n /*::[*/0x0458 /*::]*/: {/* n:\"BrtCFIcon\" */},\n /*::[*/0x0459 /*::]*/: {\n /* n:\"BrtBeginSlicerCachesPivotCacheIDs\", */T: 1\n },\n /*::[*/0x045A /*::]*/: {\n /* n:\"BrtEndSlicerCachesPivotCacheIDs\", */T: -1\n },\n /*::[*/0x045B /*::]*/: {\n /* n:\"BrtBeginSlicers\", */T: 1\n },\n /*::[*/0x045C /*::]*/: {\n /* n:\"BrtEndSlicers\", */T: -1\n },\n /*::[*/0x045D /*::]*/: {/* n:\"BrtWbProp14\" */},\n /*::[*/0x045E /*::]*/: {\n /* n:\"BrtBeginSXEdit\", */T: 1\n },\n /*::[*/0x045F /*::]*/: {\n /* n:\"BrtEndSXEdit\", */T: -1\n },\n /*::[*/0x0460 /*::]*/: {\n /* n:\"BrtBeginSXEdits\", */T: 1\n },\n /*::[*/0x0461 /*::]*/: {\n /* n:\"BrtEndSXEdits\", */T: -1\n },\n /*::[*/0x0462 /*::]*/: {\n /* n:\"BrtBeginSXChange\", */T: 1\n },\n /*::[*/0x0463 /*::]*/: {\n /* n:\"BrtEndSXChange\", */T: -1\n },\n /*::[*/0x0464 /*::]*/: {\n /* n:\"BrtBeginSXChanges\", */T: 1\n },\n /*::[*/0x0465 /*::]*/: {\n /* n:\"BrtEndSXChanges\", */T: -1\n },\n /*::[*/0x0466 /*::]*/: {/* n:\"BrtSXTupleItems\" */},\n /*::[*/0x0468 /*::]*/: {\n /* n:\"BrtBeginSlicerStyle\", */T: 1\n },\n /*::[*/0x0469 /*::]*/: {\n /* n:\"BrtEndSlicerStyle\", */T: -1\n },\n /*::[*/0x046A /*::]*/: {/* n:\"BrtSlicerStyleElement\" */},\n /*::[*/0x046B /*::]*/: {\n /* n:\"BrtBeginStyleSheetExt14\", */T: 1\n },\n /*::[*/0x046C /*::]*/: {\n /* n:\"BrtEndStyleSheetExt14\", */T: -1\n },\n /*::[*/0x046D /*::]*/: {\n /* n:\"BrtBeginSlicerCachesPivotCacheID\", */T: 1\n },\n /*::[*/0x046E /*::]*/: {\n /* n:\"BrtEndSlicerCachesPivotCacheID\", */T: -1\n },\n /*::[*/0x046F /*::]*/: {\n /* n:\"BrtBeginConditionalFormattings\", */T: 1\n },\n /*::[*/0x0470 /*::]*/: {\n /* n:\"BrtEndConditionalFormattings\", */T: -1\n },\n /*::[*/0x0471 /*::]*/: {\n /* n:\"BrtBeginPCDCalcMemExt\", */T: 1\n },\n /*::[*/0x0472 /*::]*/: {\n /* n:\"BrtEndPCDCalcMemExt\", */T: -1\n },\n /*::[*/0x0473 /*::]*/: {\n /* n:\"BrtBeginPCDCalcMemsExt\", */T: 1\n },\n /*::[*/0x0474 /*::]*/: {\n /* n:\"BrtEndPCDCalcMemsExt\", */T: -1\n },\n /*::[*/0x0475 /*::]*/: {/* n:\"BrtPCDField14\" */},\n /*::[*/0x0476 /*::]*/: {\n /* n:\"BrtBeginSlicerStyles\", */T: 1\n },\n /*::[*/0x0477 /*::]*/: {\n /* n:\"BrtEndSlicerStyles\", */T: -1\n },\n /*::[*/0x0478 /*::]*/: {\n /* n:\"BrtBeginSlicerStyleElements\", */T: 1\n },\n /*::[*/0x0479 /*::]*/: {\n /* n:\"BrtEndSlicerStyleElements\", */T: -1\n },\n /*::[*/0x047A /*::]*/: {/* n:\"BrtCFRuleExt\" */},\n /*::[*/0x047B /*::]*/: {\n /* n:\"BrtBeginSXCondFmt14\", */T: 1\n },\n /*::[*/0x047C /*::]*/: {\n /* n:\"BrtEndSXCondFmt14\", */T: -1\n },\n /*::[*/0x047D /*::]*/: {\n /* n:\"BrtBeginSXCondFmts14\", */T: 1\n },\n /*::[*/0x047E /*::]*/: {\n /* n:\"BrtEndSXCondFmts14\", */T: -1\n },\n /*::[*/0x0480 /*::]*/: {\n /* n:\"BrtBeginSortCond14\", */T: 1\n },\n /*::[*/0x0481 /*::]*/: {\n /* n:\"BrtEndSortCond14\", */T: -1\n },\n /*::[*/0x0482 /*::]*/: {\n /* n:\"BrtEndDVals14\", */T: -1\n },\n /*::[*/0x0483 /*::]*/: {\n /* n:\"BrtEndIconSet14\", */T: -1\n },\n /*::[*/0x0484 /*::]*/: {\n /* n:\"BrtEndDatabar14\", */T: -1\n },\n /*::[*/0x0485 /*::]*/: {\n /* n:\"BrtBeginColorScale14\", */T: 1\n },\n /*::[*/0x0486 /*::]*/: {\n /* n:\"BrtEndColorScale14\", */T: -1\n },\n /*::[*/0x0487 /*::]*/: {\n /* n:\"BrtBeginSxrules14\", */T: 1\n },\n /*::[*/0x0488 /*::]*/: {\n /* n:\"BrtEndSxrules14\", */T: -1\n },\n /*::[*/0x0489 /*::]*/: {\n /* n:\"BrtBeginPRule14\", */T: 1\n },\n /*::[*/0x048A /*::]*/: {\n /* n:\"BrtEndPRule14\", */T: -1\n },\n /*::[*/0x048B /*::]*/: {\n /* n:\"BrtBeginPRFilters14\", */T: 1\n },\n /*::[*/0x048C /*::]*/: {\n /* n:\"BrtEndPRFilters14\", */T: -1\n },\n /*::[*/0x048D /*::]*/: {\n /* n:\"BrtBeginPRFilter14\", */T: 1\n },\n /*::[*/0x048E /*::]*/: {\n /* n:\"BrtEndPRFilter14\", */T: -1\n },\n /*::[*/0x048F /*::]*/: {\n /* n:\"BrtBeginPRFItem14\", */T: 1\n },\n /*::[*/0x0490 /*::]*/: {\n /* n:\"BrtEndPRFItem14\", */T: -1\n },\n /*::[*/0x0491 /*::]*/: {\n /* n:\"BrtBeginCellIgnoreECs14\", */T: 1\n },\n /*::[*/0x0492 /*::]*/: {\n /* n:\"BrtEndCellIgnoreECs14\", */T: -1\n },\n /*::[*/0x0493 /*::]*/: {/* n:\"BrtDxf14\" */},\n /*::[*/0x0494 /*::]*/: {\n /* n:\"BrtBeginDxF14s\", */T: 1\n },\n /*::[*/0x0495 /*::]*/: {\n /* n:\"BrtEndDxf14s\", */T: -1\n },\n /*::[*/0x0499 /*::]*/: {/* n:\"BrtFilter14\" */},\n /*::[*/0x049A /*::]*/: {\n /* n:\"BrtBeginCustomFilters14\", */T: 1\n },\n /*::[*/0x049C /*::]*/: {/* n:\"BrtCustomFilter14\" */},\n /*::[*/0x049D /*::]*/: {/* n:\"BrtIconFilter14\" */},\n /*::[*/0x049E /*::]*/: {/* n:\"BrtPivotCacheConnectionName\" */},\n /*::[*/0x0800 /*::]*/: {\n /* n:\"BrtBeginDecoupledPivotCacheIDs\", */T: 1\n },\n /*::[*/0x0801 /*::]*/: {\n /* n:\"BrtEndDecoupledPivotCacheIDs\", */T: -1\n },\n /*::[*/0x0802 /*::]*/: {/* n:\"BrtDecoupledPivotCacheID\" */},\n /*::[*/0x0803 /*::]*/: {\n /* n:\"BrtBeginPivotTableRefs\", */T: 1\n },\n /*::[*/0x0804 /*::]*/: {\n /* n:\"BrtEndPivotTableRefs\", */T: -1\n },\n /*::[*/0x0805 /*::]*/: {/* n:\"BrtPivotTableRef\" */},\n /*::[*/0x0806 /*::]*/: {/* n:\"BrtSlicerCacheBookPivotTables\" */},\n /*::[*/0x0807 /*::]*/: {\n /* n:\"BrtBeginSxvcells\", */T: 1\n },\n /*::[*/0x0808 /*::]*/: {\n /* n:\"BrtEndSxvcells\", */T: -1\n },\n /*::[*/0x0809 /*::]*/: {\n /* n:\"BrtBeginSxRow\", */T: 1\n },\n /*::[*/0x080A /*::]*/: {\n /* n:\"BrtEndSxRow\", */T: -1\n },\n /*::[*/0x080C /*::]*/: {/* n:\"BrtPcdCalcMem15\" */},\n /*::[*/0x0813 /*::]*/: {/* n:\"BrtQsi15\" */},\n /*::[*/0x0814 /*::]*/: {\n /* n:\"BrtBeginWebExtensions\", */T: 1\n },\n /*::[*/0x0815 /*::]*/: {\n /* n:\"BrtEndWebExtensions\", */T: -1\n },\n /*::[*/0x0816 /*::]*/: {/* n:\"BrtWebExtension\" */},\n /*::[*/0x0817 /*::]*/: {/* n:\"BrtAbsPath15\" */},\n /*::[*/0x0818 /*::]*/: {\n /* n:\"BrtBeginPivotTableUISettings\", */T: 1\n },\n /*::[*/0x0819 /*::]*/: {\n /* n:\"BrtEndPivotTableUISettings\", */T: -1\n },\n /*::[*/0x081B /*::]*/: {/* n:\"BrtTableSlicerCacheIDs\" */},\n /*::[*/0x081C /*::]*/: {/* n:\"BrtTableSlicerCacheID\" */},\n /*::[*/0x081D /*::]*/: {\n /* n:\"BrtBeginTableSlicerCache\", */T: 1\n },\n /*::[*/0x081E /*::]*/: {\n /* n:\"BrtEndTableSlicerCache\", */T: -1\n },\n /*::[*/0x081F /*::]*/: {/* n:\"BrtSxFilter15\" */},\n /*::[*/0x0820 /*::]*/: {\n /* n:\"BrtBeginTimelineCachePivotCacheIDs\", */T: 1\n },\n /*::[*/0x0821 /*::]*/: {\n /* n:\"BrtEndTimelineCachePivotCacheIDs\", */T: -1\n },\n /*::[*/0x0822 /*::]*/: {/* n:\"BrtTimelineCachePivotCacheID\" */},\n /*::[*/0x0823 /*::]*/: {\n /* n:\"BrtBeginTimelineCacheIDs\", */T: 1\n },\n /*::[*/0x0824 /*::]*/: {\n /* n:\"BrtEndTimelineCacheIDs\", */T: -1\n },\n /*::[*/0x0825 /*::]*/: {\n /* n:\"BrtBeginTimelineCacheID\", */T: 1\n },\n /*::[*/0x0826 /*::]*/: {\n /* n:\"BrtEndTimelineCacheID\", */T: -1\n },\n /*::[*/0x0827 /*::]*/: {\n /* n:\"BrtBeginTimelinesEx\", */T: 1\n },\n /*::[*/0x0828 /*::]*/: {\n /* n:\"BrtEndTimelinesEx\", */T: -1\n },\n /*::[*/0x0829 /*::]*/: {\n /* n:\"BrtBeginTimelineEx\", */T: 1\n },\n /*::[*/0x082A /*::]*/: {\n /* n:\"BrtEndTimelineEx\", */T: -1\n },\n /*::[*/0x082B /*::]*/: {/* n:\"BrtWorkBookPr15\" */},\n /*::[*/0x082C /*::]*/: {/* n:\"BrtPCDH15\" */},\n /*::[*/0x082D /*::]*/: {\n /* n:\"BrtBeginTimelineStyle\", */T: 1\n },\n /*::[*/0x082E /*::]*/: {\n /* n:\"BrtEndTimelineStyle\", */T: -1\n },\n /*::[*/0x082F /*::]*/: {/* n:\"BrtTimelineStyleElement\" */},\n /*::[*/0x0830 /*::]*/: {\n /* n:\"BrtBeginTimelineStylesheetExt15\", */T: 1\n },\n /*::[*/0x0831 /*::]*/: {\n /* n:\"BrtEndTimelineStylesheetExt15\", */T: -1\n },\n /*::[*/0x0832 /*::]*/: {\n /* n:\"BrtBeginTimelineStyles\", */T: 1\n },\n /*::[*/0x0833 /*::]*/: {\n /* n:\"BrtEndTimelineStyles\", */T: -1\n },\n /*::[*/0x0834 /*::]*/: {\n /* n:\"BrtBeginTimelineStyleElements\", */T: 1\n },\n /*::[*/0x0835 /*::]*/: {\n /* n:\"BrtEndTimelineStyleElements\", */T: -1\n },\n /*::[*/0x0836 /*::]*/: {/* n:\"BrtDxf15\" */},\n /*::[*/0x0837 /*::]*/: {\n /* n:\"BrtBeginDxfs15\", */T: 1\n },\n /*::[*/0x0838 /*::]*/: {\n /* n:\"BrtEndDxfs15\", */T: -1\n },\n /*::[*/0x0839 /*::]*/: {/* n:\"BrtSlicerCacheHideItemsWithNoData\" */},\n /*::[*/0x083A /*::]*/: {\n /* n:\"BrtBeginItemUniqueNames\", */T: 1\n },\n /*::[*/0x083B /*::]*/: {\n /* n:\"BrtEndItemUniqueNames\", */T: -1\n },\n /*::[*/0x083C /*::]*/: {/* n:\"BrtItemUniqueName\" */},\n /*::[*/0x083D /*::]*/: {\n /* n:\"BrtBeginExtConn15\", */T: 1\n },\n /*::[*/0x083E /*::]*/: {\n /* n:\"BrtEndExtConn15\", */T: -1\n },\n /*::[*/0x083F /*::]*/: {\n /* n:\"BrtBeginOledbPr15\", */T: 1\n },\n /*::[*/0x0840 /*::]*/: {\n /* n:\"BrtEndOledbPr15\", */T: -1\n },\n /*::[*/0x0841 /*::]*/: {\n /* n:\"BrtBeginDataFeedPr15\", */T: 1\n },\n /*::[*/0x0842 /*::]*/: {\n /* n:\"BrtEndDataFeedPr15\", */T: -1\n },\n /*::[*/0x0843 /*::]*/: {/* n:\"BrtTextPr15\" */},\n /*::[*/0x0844 /*::]*/: {/* n:\"BrtRangePr15\" */},\n /*::[*/0x0845 /*::]*/: {/* n:\"BrtDbCommand15\" */},\n /*::[*/0x0846 /*::]*/: {\n /* n:\"BrtBeginDbTables15\", */T: 1\n },\n /*::[*/0x0847 /*::]*/: {\n /* n:\"BrtEndDbTables15\", */T: -1\n },\n /*::[*/0x0848 /*::]*/: {/* n:\"BrtDbTable15\" */},\n /*::[*/0x0849 /*::]*/: {\n /* n:\"BrtBeginDataModel\", */T: 1\n },\n /*::[*/0x084A /*::]*/: {\n /* n:\"BrtEndDataModel\", */T: -1\n },\n /*::[*/0x084B /*::]*/: {\n /* n:\"BrtBeginModelTables\", */T: 1\n },\n /*::[*/0x084C /*::]*/: {\n /* n:\"BrtEndModelTables\", */T: -1\n },\n /*::[*/0x084D /*::]*/: {/* n:\"BrtModelTable\" */},\n /*::[*/0x084E /*::]*/: {\n /* n:\"BrtBeginModelRelationships\", */T: 1\n },\n /*::[*/0x084F /*::]*/: {\n /* n:\"BrtEndModelRelationships\", */T: -1\n },\n /*::[*/0x0850 /*::]*/: {/* n:\"BrtModelRelationship\" */},\n /*::[*/0x0851 /*::]*/: {\n /* n:\"BrtBeginECTxtWiz15\", */T: 1\n },\n /*::[*/0x0852 /*::]*/: {\n /* n:\"BrtEndECTxtWiz15\", */T: -1\n },\n /*::[*/0x0853 /*::]*/: {\n /* n:\"BrtBeginECTWFldInfoLst15\", */T: 1\n },\n /*::[*/0x0854 /*::]*/: {\n /* n:\"BrtEndECTWFldInfoLst15\", */T: -1\n },\n /*::[*/0x0855 /*::]*/: {\n /* n:\"BrtBeginECTWFldInfo15\", */T: 1\n },\n /*::[*/0x0856 /*::]*/: {/* n:\"BrtFieldListActiveItem\" */},\n /*::[*/0x0857 /*::]*/: {/* n:\"BrtPivotCacheIdVersion\" */},\n /*::[*/0x0858 /*::]*/: {/* n:\"BrtSXDI15\" */},\n /*::[*/0x0859 /*::]*/: {\n /* n:\"BrtBeginModelTimeGroupings\", */T: 1\n },\n /*::[*/0x085A /*::]*/: {\n /* n:\"BrtEndModelTimeGroupings\", */T: -1\n },\n /*::[*/0x085B /*::]*/: {\n /* n:\"BrtBeginModelTimeGrouping\", */T: 1\n },\n /*::[*/0x085C /*::]*/: {\n /* n:\"BrtEndModelTimeGrouping\", */T: -1\n },\n /*::[*/0x085D /*::]*/: {/* n:\"BrtModelTimeGroupingCalcCol\" */},\n /*::[*/0x0C00 /*::]*/: {/* n:\"BrtUid\" */},\n /*::[*/0x0C01 /*::]*/: {/* n:\"BrtRevisionPtr\" */},\n /*::[*/0x1000 /*::]*/: {\n /* n:\"BrtBeginDynamicArrayPr\", */T: 1\n },\n /*::[*/0x1001 /*::]*/: {\n /* n:\"BrtEndDynamicArrayPr\", */T: -1\n },\n /*::[*/0x138A /*::]*/: {\n /* n:\"BrtBeginRichValueBlock\", */T: 1\n },\n /*::[*/0x138B /*::]*/: {\n /* n:\"BrtEndRichValueBlock\", */T: -1\n },\n /*::[*/0x13D9 /*::]*/: {\n /* n:\"BrtBeginRichFilters\", */T: 1\n },\n /*::[*/0x13DA /*::]*/: {\n /* n:\"BrtEndRichFilters\", */T: -1\n },\n /*::[*/0x13DB /*::]*/: {/* n:\"BrtRichFilter\" */},\n /*::[*/0x13DC /*::]*/: {\n /* n:\"BrtBeginRichFilterColumn\", */T: 1\n },\n /*::[*/0x13DD /*::]*/: {\n /* n:\"BrtEndRichFilterColumn\", */T: -1\n },\n /*::[*/0x13DE /*::]*/: {\n /* n:\"BrtBeginCustomRichFilters\", */T: 1\n },\n /*::[*/0x13DF /*::]*/: {\n /* n:\"BrtEndCustomRichFilters\", */T: -1\n },\n /*::[*/0x13E0 /*::]*/: {/* n:\"BrtCustomRichFilter\" */},\n /*::[*/0x13E1 /*::]*/: {/* n:\"BrtTop10RichFilter\" */},\n /*::[*/0x13E2 /*::]*/: {/* n:\"BrtDynamicRichFilter\" */},\n /*::[*/0x13E4 /*::]*/: {\n /* n:\"BrtBeginRichSortCondition\", */T: 1\n },\n /*::[*/0x13E5 /*::]*/: {\n /* n:\"BrtEndRichSortCondition\", */T: -1\n },\n /*::[*/0x13E6 /*::]*/: {/* n:\"BrtRichFilterDateGroupItem\" */},\n /*::[*/0x13E7 /*::]*/: {\n /* n:\"BrtBeginCalcFeatures\", */T: 1\n },\n /*::[*/0x13E8 /*::]*/: {\n /* n:\"BrtEndCalcFeatures\", */T: -1\n },\n /*::[*/0x13E9 /*::]*/: {/* n:\"BrtCalcFeature\" */},\n /*::[*/0x13EB /*::]*/: {/* n:\"BrtExternalLinksPr\" */},\n /*::[*/0xFFFF /*::]*/: {\n n: \"\"\n }\n};\n\n/* [MS-XLS] 2.3 Record Enumeration (and other sources) */\nvar XLSRecordEnum = {\n /* [MS-XLS] 2.3 Record Enumeration 2021-08-17 */\n /*::[*/0x0006 /*::]*/: {\n /* n:\"Formula\", */f: parse_Formula\n },\n /*::[*/0x000a /*::]*/: {\n /* n:\"EOF\", */f: parsenoop2\n },\n /*::[*/0x000c /*::]*/: {\n /* n:\"CalcCount\", */f: parseuint16\n },\n //\n /*::[*/\n 0x000d /*::]*/: {\n /* n:\"CalcMode\", */f: parseuint16\n },\n //\n /*::[*/\n 0x000e /*::]*/: {\n /* n:\"CalcPrecision\", */f: parsebool\n },\n //\n /*::[*/\n 0x000f /*::]*/: {\n /* n:\"CalcRefMode\", */f: parsebool\n },\n //\n /*::[*/\n 0x0010 /*::]*/: {\n /* n:\"CalcDelta\", */f: parse_Xnum\n },\n //\n /*::[*/\n 0x0011 /*::]*/: {\n /* n:\"CalcIter\", */f: parsebool\n },\n //\n /*::[*/\n 0x0012 /*::]*/: {\n /* n:\"Protect\", */f: parsebool\n },\n /*::[*/0x0013 /*::]*/: {\n /* n:\"Password\", */f: parseuint16\n },\n /*::[*/0x0014 /*::]*/: {\n /* n:\"Header\", */f: parse_XLHeaderFooter\n },\n /*::[*/0x0015 /*::]*/: {\n /* n:\"Footer\", */f: parse_XLHeaderFooter\n },\n /*::[*/0x0017 /*::]*/: {\n /* n:\"ExternSheet\", */f: parse_ExternSheet\n },\n /*::[*/0x0018 /*::]*/: {\n /* n:\"Lbl\", */f: parse_Lbl\n },\n /*::[*/0x0019 /*::]*/: {\n /* n:\"WinProtect\", */f: parsebool\n },\n /*::[*/0x001a /*::]*/: {/* n:\"VerticalPageBreaks\", */},\n /*::[*/0x001b /*::]*/: {/* n:\"HorizontalPageBreaks\", */},\n /*::[*/0x001c /*::]*/: {\n /* n:\"Note\", */f: parse_Note\n },\n /*::[*/0x001d /*::]*/: {/* n:\"Selection\", */},\n /*::[*/0x0022 /*::]*/: {\n /* n:\"Date1904\", */f: parsebool\n },\n /*::[*/0x0023 /*::]*/: {\n /* n:\"ExternName\", */f: parse_ExternName\n },\n /*::[*/0x0026 /*::]*/: {\n /* n:\"LeftMargin\", */f: parse_Xnum\n },\n // *\n /*::[*/\n 0x0027 /*::]*/: {\n /* n:\"RightMargin\", */f: parse_Xnum\n },\n // *\n /*::[*/\n 0x0028 /*::]*/: {\n /* n:\"TopMargin\", */f: parse_Xnum\n },\n // *\n /*::[*/\n 0x0029 /*::]*/: {\n /* n:\"BottomMargin\", */f: parse_Xnum\n },\n // *\n /*::[*/\n 0x002a /*::]*/: {\n /* n:\"PrintRowCol\", */f: parsebool\n },\n /*::[*/0x002b /*::]*/: {\n /* n:\"PrintGrid\", */f: parsebool\n },\n /*::[*/0x002f /*::]*/: {\n /* n:\"FilePass\", */f: parse_FilePass\n },\n /*::[*/0x0031 /*::]*/: {\n /* n:\"Font\", */f: parse_Font\n },\n /*::[*/0x0033 /*::]*/: {\n /* n:\"PrintSize\", */f: parseuint16\n },\n /*::[*/0x003c /*::]*/: {/* n:\"Continue\", */},\n /*::[*/0x003d /*::]*/: {\n /* n:\"Window1\", */f: parse_Window1\n },\n /*::[*/0x0040 /*::]*/: {\n /* n:\"Backup\", */f: parsebool\n },\n /*::[*/0x0041 /*::]*/: {\n /* n:\"Pane\", */f: parse_Pane\n },\n /*::[*/0x0042 /*::]*/: {\n /* n:\"CodePage\", */f: parseuint16\n },\n /*::[*/0x004d /*::]*/: {/* n:\"Pls\", */},\n /*::[*/0x0050 /*::]*/: {/* n:\"DCon\", */},\n /*::[*/0x0051 /*::]*/: {/* n:\"DConRef\", */},\n /*::[*/0x0052 /*::]*/: {/* n:\"DConName\", */},\n /*::[*/0x0055 /*::]*/: {\n /* n:\"DefColWidth\", */f: parseuint16\n },\n /*::[*/0x0059 /*::]*/: {/* n:\"XCT\", */},\n /*::[*/0x005a /*::]*/: {/* n:\"CRN\", */},\n /*::[*/0x005b /*::]*/: {/* n:\"FileSharing\", */},\n /*::[*/0x005c /*::]*/: {\n /* n:\"WriteAccess\", */f: parse_WriteAccess\n },\n /*::[*/0x005d /*::]*/: {\n /* n:\"Obj\", */f: parse_Obj\n },\n /*::[*/0x005e /*::]*/: {/* n:\"Uncalced\", */},\n /*::[*/0x005f /*::]*/: {\n /* n:\"CalcSaveRecalc\", */f: parsebool\n },\n //\n /*::[*/\n 0x0060 /*::]*/: {/* n:\"Template\", */},\n /*::[*/0x0061 /*::]*/: {/* n:\"Intl\", */},\n /*::[*/0x0063 /*::]*/: {\n /* n:\"ObjProtect\", */f: parsebool\n },\n /*::[*/0x007d /*::]*/: {\n /* n:\"ColInfo\", */f: parse_ColInfo\n },\n /*::[*/0x0080 /*::]*/: {\n /* n:\"Guts\", */f: parse_Guts\n },\n /*::[*/0x0081 /*::]*/: {\n /* n:\"WsBool\", */f: parse_WsBool\n },\n /*::[*/0x0082 /*::]*/: {\n /* n:\"GridSet\", */f: parseuint16\n },\n /*::[*/0x0083 /*::]*/: {\n /* n:\"HCenter\", */f: parsebool\n },\n /*::[*/0x0084 /*::]*/: {\n /* n:\"VCenter\", */f: parsebool\n },\n /*::[*/0x0085 /*::]*/: {\n /* n:\"BoundSheet8\", */f: parse_BoundSheet8\n },\n /*::[*/0x0086 /*::]*/: {/* n:\"WriteProtect\", */},\n /*::[*/0x008c /*::]*/: {\n /* n:\"Country\", */f: parse_Country\n },\n /*::[*/0x008d /*::]*/: {\n /* n:\"HideObj\", */f: parseuint16\n },\n /*::[*/0x0090 /*::]*/: {/* n:\"Sort\", */},\n /*::[*/0x0092 /*::]*/: {\n /* n:\"Palette\", */f: parse_Palette\n },\n /*::[*/0x0097 /*::]*/: {/* n:\"Sync\", */},\n /*::[*/0x0098 /*::]*/: {/* n:\"LPr\", */},\n /*::[*/0x0099 /*::]*/: {/* n:\"DxGCol\", */},\n /*::[*/0x009a /*::]*/: {/* n:\"FnGroupName\", */},\n /*::[*/0x009b /*::]*/: {/* n:\"FilterMode\", */},\n /*::[*/0x009c /*::]*/: {\n /* n:\"BuiltInFnGroupCount\", */f: parseuint16\n },\n /*::[*/0x009d /*::]*/: {/* n:\"AutoFilterInfo\", */},\n /*::[*/0x009e /*::]*/: {/* n:\"AutoFilter\", */},\n /*::[*/0x00a0 /*::]*/: {\n /* n:\"Scl\", */f: parse_Scl\n },\n /*::[*/0x00a1 /*::]*/: {\n /* n:\"Setup\", */f: parse_Setup\n },\n /*::[*/0x00ae /*::]*/: {/* n:\"ScenMan\", */},\n /*::[*/0x00af /*::]*/: {/* n:\"SCENARIO\", */},\n /*::[*/0x00b0 /*::]*/: {/* n:\"SxView\", */},\n /*::[*/0x00b1 /*::]*/: {/* n:\"Sxvd\", */},\n /*::[*/0x00b2 /*::]*/: {/* n:\"SXVI\", */},\n /*::[*/0x00b4 /*::]*/: {/* n:\"SxIvd\", */},\n /*::[*/0x00b5 /*::]*/: {/* n:\"SXLI\", */},\n /*::[*/0x00b6 /*::]*/: {/* n:\"SXPI\", */},\n /*::[*/0x00b8 /*::]*/: {/* n:\"DocRoute\", */},\n /*::[*/0x00b9 /*::]*/: {/* n:\"RecipName\", */},\n /*::[*/0x00bd /*::]*/: {\n /* n:\"MulRk\", */f: parse_MulRk\n },\n /*::[*/0x00be /*::]*/: {\n /* n:\"MulBlank\", */f: parse_MulBlank\n },\n /*::[*/0x00c1 /*::]*/: {\n /* n:\"Mms\", */f: parsenoop2\n },\n /*::[*/0x00c5 /*::]*/: {/* n:\"SXDI\", */},\n /*::[*/0x00c6 /*::]*/: {/* n:\"SXDB\", */},\n /*::[*/0x00c7 /*::]*/: {/* n:\"SXFDB\", */},\n /*::[*/0x00c8 /*::]*/: {/* n:\"SXDBB\", */},\n /*::[*/0x00c9 /*::]*/: {/* n:\"SXNum\", */},\n /*::[*/0x00ca /*::]*/: {\n /* n:\"SxBool\", */f: parsebool\n },\n /*::[*/0x00cb /*::]*/: {/* n:\"SxErr\", */},\n /*::[*/0x00cc /*::]*/: {/* n:\"SXInt\", */},\n /*::[*/0x00cd /*::]*/: {/* n:\"SXString\", */},\n /*::[*/0x00ce /*::]*/: {/* n:\"SXDtr\", */},\n /*::[*/0x00cf /*::]*/: {/* n:\"SxNil\", */},\n /*::[*/0x00d0 /*::]*/: {/* n:\"SXTbl\", */},\n /*::[*/0x00d1 /*::]*/: {/* n:\"SXTBRGIITM\", */},\n /*::[*/0x00d2 /*::]*/: {/* n:\"SxTbpg\", */},\n /*::[*/0x00d3 /*::]*/: {/* n:\"ObProj\", */},\n /*::[*/0x00d5 /*::]*/: {/* n:\"SXStreamID\", */},\n /*::[*/0x00d7 /*::]*/: {/* n:\"DBCell\", */},\n /*::[*/0x00d8 /*::]*/: {/* n:\"SXRng\", */},\n /*::[*/0x00d9 /*::]*/: {/* n:\"SxIsxoper\", */},\n /*::[*/0x00da /*::]*/: {\n /* n:\"BookBool\", */f: parseuint16\n },\n /*::[*/0x00dc /*::]*/: {/* n:\"DbOrParamQry\", */},\n /*::[*/0x00dd /*::]*/: {\n /* n:\"ScenarioProtect\", */f: parsebool\n },\n /*::[*/0x00de /*::]*/: {/* n:\"OleObjectSize\", */},\n /*::[*/0x00e0 /*::]*/: {\n /* n:\"XF\", */f: parse_XF\n },\n /*::[*/0x00e1 /*::]*/: {\n /* n:\"InterfaceHdr\", */f: parse_InterfaceHdr\n },\n /*::[*/0x00e2 /*::]*/: {\n /* n:\"InterfaceEnd\", */f: parsenoop2\n },\n /*::[*/0x00e3 /*::]*/: {/* n:\"SXVS\", */},\n /*::[*/0x00e5 /*::]*/: {\n /* n:\"MergeCells\", */f: parse_MergeCells\n },\n /*::[*/0x00e9 /*::]*/: {/* n:\"BkHim\", */},\n /*::[*/0x00eb /*::]*/: {/* n:\"MsoDrawingGroup\", */},\n /*::[*/0x00ec /*::]*/: {/* n:\"MsoDrawing\", */},\n /*::[*/0x00ed /*::]*/: {/* n:\"MsoDrawingSelection\", */},\n /*::[*/0x00ef /*::]*/: {/* n:\"PhoneticInfo\", */},\n /*::[*/0x00f0 /*::]*/: {/* n:\"SxRule\", */},\n /*::[*/0x00f1 /*::]*/: {/* n:\"SXEx\", */},\n /*::[*/0x00f2 /*::]*/: {/* n:\"SxFilt\", */},\n /*::[*/0x00f4 /*::]*/: {/* n:\"SxDXF\", */},\n /*::[*/0x00f5 /*::]*/: {/* n:\"SxItm\", */},\n /*::[*/0x00f6 /*::]*/: {/* n:\"SxName\", */},\n /*::[*/0x00f7 /*::]*/: {/* n:\"SxSelect\", */},\n /*::[*/0x00f8 /*::]*/: {/* n:\"SXPair\", */},\n /*::[*/0x00f9 /*::]*/: {/* n:\"SxFmla\", */},\n /*::[*/0x00fb /*::]*/: {/* n:\"SxFormat\", */},\n /*::[*/0x00fc /*::]*/: {\n /* n:\"SST\", */f: parse_SST\n },\n /*::[*/0x00fd /*::]*/: {\n /* n:\"LabelSst\", */f: parse_LabelSst\n },\n /*::[*/0x00ff /*::]*/: {\n /* n:\"ExtSST\", */f: parse_ExtSST\n },\n /*::[*/0x0100 /*::]*/: {/* n:\"SXVDEx\", */},\n /*::[*/0x0103 /*::]*/: {/* n:\"SXFormula\", */},\n /*::[*/0x0122 /*::]*/: {/* n:\"SXDBEx\", */},\n /*::[*/0x0137 /*::]*/: {/* n:\"RRDInsDel\", */},\n /*::[*/0x0138 /*::]*/: {/* n:\"RRDHead\", */},\n /*::[*/0x013b /*::]*/: {/* n:\"RRDChgCell\", */},\n /*::[*/0x013d /*::]*/: {\n /* n:\"RRTabId\", */f: parseuint16a\n },\n /*::[*/0x013e /*::]*/: {/* n:\"RRDRenSheet\", */},\n /*::[*/0x013f /*::]*/: {/* n:\"RRSort\", */},\n /*::[*/0x0140 /*::]*/: {/* n:\"RRDMove\", */},\n /*::[*/0x014a /*::]*/: {/* n:\"RRFormat\", */},\n /*::[*/0x014b /*::]*/: {/* n:\"RRAutoFmt\", */},\n /*::[*/0x014d /*::]*/: {/* n:\"RRInsertSh\", */},\n /*::[*/0x014e /*::]*/: {/* n:\"RRDMoveBegin\", */},\n /*::[*/0x014f /*::]*/: {/* n:\"RRDMoveEnd\", */},\n /*::[*/0x0150 /*::]*/: {/* n:\"RRDInsDelBegin\", */},\n /*::[*/0x0151 /*::]*/: {/* n:\"RRDInsDelEnd\", */},\n /*::[*/0x0152 /*::]*/: {/* n:\"RRDConflict\", */},\n /*::[*/0x0153 /*::]*/: {/* n:\"RRDDefName\", */},\n /*::[*/0x0154 /*::]*/: {/* n:\"RRDRstEtxp\", */},\n /*::[*/0x015f /*::]*/: {/* n:\"LRng\", */},\n /*::[*/0x0160 /*::]*/: {\n /* n:\"UsesELFs\", */f: parsebool\n },\n /*::[*/0x0161 /*::]*/: {\n /* n:\"DSF\", */f: parsenoop2\n },\n /*::[*/0x0191 /*::]*/: {/* n:\"CUsr\", */},\n /*::[*/0x0192 /*::]*/: {/* n:\"CbUsr\", */},\n /*::[*/0x0193 /*::]*/: {/* n:\"UsrInfo\", */},\n /*::[*/0x0194 /*::]*/: {/* n:\"UsrExcl\", */},\n /*::[*/0x0195 /*::]*/: {/* n:\"FileLock\", */},\n /*::[*/0x0196 /*::]*/: {/* n:\"RRDInfo\", */},\n /*::[*/0x0197 /*::]*/: {/* n:\"BCUsrs\", */},\n /*::[*/0x0198 /*::]*/: {/* n:\"UsrChk\", */},\n /*::[*/0x01a9 /*::]*/: {/* n:\"UserBView\", */},\n /*::[*/0x01aa /*::]*/: {/* n:\"UserSViewBegin\", */},\n /*::[*/0x01ab /*::]*/: {/* n:\"UserSViewEnd\", */},\n /*::[*/0x01ac /*::]*/: {/* n:\"RRDUserView\", */},\n /*::[*/0x01ad /*::]*/: {/* n:\"Qsi\", */},\n /*::[*/0x01ae /*::]*/: {\n /* n:\"SupBook\", */f: parse_SupBook\n },\n /*::[*/0x01af /*::]*/: {\n /* n:\"Prot4Rev\", */f: parsebool\n },\n /*::[*/0x01b0 /*::]*/: {/* n:\"CondFmt\", */},\n /*::[*/0x01b1 /*::]*/: {/* n:\"CF\", */},\n /*::[*/0x01b2 /*::]*/: {/* n:\"DVal\", */},\n /*::[*/0x01b5 /*::]*/: {/* n:\"DConBin\", */},\n /*::[*/0x01b6 /*::]*/: {\n /* n:\"TxO\", */f: parse_TxO\n },\n /*::[*/0x01b7 /*::]*/: {\n /* n:\"RefreshAll\", */f: parsebool\n },\n //\n /*::[*/\n 0x01b8 /*::]*/: {\n /* n:\"HLink\", */f: parse_HLink\n },\n /*::[*/0x01b9 /*::]*/: {/* n:\"Lel\", */},\n /*::[*/0x01ba /*::]*/: {\n /* n:\"CodeName\", */f: parse_XLUnicodeString\n },\n /*::[*/0x01bb /*::]*/: {/* n:\"SXFDBType\", */},\n /*::[*/0x01bc /*::]*/: {\n /* n:\"Prot4RevPass\", */f: parseuint16\n },\n /*::[*/0x01bd /*::]*/: {/* n:\"ObNoMacros\", */},\n /*::[*/0x01be /*::]*/: {/* n:\"Dv\", */},\n /*::[*/0x01c0 /*::]*/: {\n /* n:\"Excel9File\", */f: parsenoop2\n },\n /*::[*/0x01c1 /*::]*/: {\n /* n:\"RecalcId\", */f: parse_RecalcId,\n r: 2\n },\n /*::[*/0x01c2 /*::]*/: {\n /* n:\"EntExU2\", */f: parsenoop2\n },\n /*::[*/0x0200 /*::]*/: {\n /* n:\"Dimensions\", */f: parse_Dimensions\n },\n /*::[*/0x0201 /*::]*/: {\n /* n:\"Blank\", */f: parse_Blank\n },\n /*::[*/0x0203 /*::]*/: {\n /* n:\"Number\", */f: parse_Number\n },\n /*::[*/0x0204 /*::]*/: {\n /* n:\"Label\", */f: parse_Label\n },\n /*::[*/0x0205 /*::]*/: {\n /* n:\"BoolErr\", */f: parse_BoolErr\n },\n /*::[*/0x0207 /*::]*/: {\n /* n:\"String\", */f: parse_String\n },\n /*::[*/0x0208 /*::]*/: {\n /* n:\"Row\", */f: parse_Row\n },\n /*::[*/0x020b /*::]*/: {/* n:\"Index\", */},\n /*::[*/0x0221 /*::]*/: {\n /* n:\"Array\", */f: parse_Array\n },\n /*::[*/0x0225 /*::]*/: {\n /* n:\"DefaultRowHeight\", */f: parse_DefaultRowHeight\n },\n /*::[*/0x0236 /*::]*/: {/* n:\"Table\", */},\n /*::[*/0x023e /*::]*/: {\n /* n:\"Window2\", */f: parse_Window2\n },\n /*::[*/0x027e /*::]*/: {\n /* n:\"RK\", */f: parse_RK\n },\n /*::[*/0x0293 /*::]*/: {/* n:\"Style\", */},\n /*::[*/0x0418 /*::]*/: {/* n:\"BigName\", */},\n /*::[*/0x041e /*::]*/: {\n /* n:\"Format\", */f: parse_Format\n },\n /*::[*/0x043c /*::]*/: {/* n:\"ContinueBigName\", */},\n /*::[*/0x04bc /*::]*/: {\n /* n:\"ShrFmla\", */f: parse_ShrFmla\n },\n /*::[*/0x0800 /*::]*/: {\n /* n:\"HLinkTooltip\", */f: parse_HLinkTooltip\n },\n /*::[*/0x0801 /*::]*/: {/* n:\"WebPub\", */},\n /*::[*/0x0802 /*::]*/: {/* n:\"QsiSXTag\", */},\n /*::[*/0x0803 /*::]*/: {/* n:\"DBQueryExt\", */},\n /*::[*/0x0804 /*::]*/: {/* n:\"ExtString\", */},\n /*::[*/0x0805 /*::]*/: {/* n:\"TxtQry\", */},\n /*::[*/0x0806 /*::]*/: {/* n:\"Qsir\", */},\n /*::[*/0x0807 /*::]*/: {/* n:\"Qsif\", */},\n /*::[*/0x0808 /*::]*/: {/* n:\"RRDTQSIF\", */},\n /*::[*/0x0809 /*::]*/: {\n /* n:\"BOF\", */f: parse_BOF\n },\n /*::[*/0x080a /*::]*/: {/* n:\"OleDbConn\", */},\n /*::[*/0x080b /*::]*/: {/* n:\"WOpt\", */},\n /*::[*/0x080c /*::]*/: {/* n:\"SXViewEx\", */},\n /*::[*/0x080d /*::]*/: {/* n:\"SXTH\", */},\n /*::[*/0x080e /*::]*/: {/* n:\"SXPIEx\", */},\n /*::[*/0x080f /*::]*/: {/* n:\"SXVDTEx\", */},\n /*::[*/0x0810 /*::]*/: {/* n:\"SXViewEx9\", */},\n /*::[*/0x0812 /*::]*/: {/* n:\"ContinueFrt\", */},\n /*::[*/0x0813 /*::]*/: {/* n:\"RealTimeData\", */},\n /*::[*/0x0850 /*::]*/: {/* n:\"ChartFrtInfo\", */},\n /*::[*/0x0851 /*::]*/: {/* n:\"FrtWrapper\", */},\n /*::[*/0x0852 /*::]*/: {/* n:\"StartBlock\", */},\n /*::[*/0x0853 /*::]*/: {/* n:\"EndBlock\", */},\n /*::[*/0x0854 /*::]*/: {/* n:\"StartObject\", */},\n /*::[*/0x0855 /*::]*/: {/* n:\"EndObject\", */},\n /*::[*/0x0856 /*::]*/: {/* n:\"CatLab\", */},\n /*::[*/0x0857 /*::]*/: {/* n:\"YMult\", */},\n /*::[*/0x0858 /*::]*/: {/* n:\"SXViewLink\", */},\n /*::[*/0x0859 /*::]*/: {/* n:\"PivotChartBits\", */},\n /*::[*/0x085a /*::]*/: {/* n:\"FrtFontList\", */},\n /*::[*/0x0862 /*::]*/: {/* n:\"SheetExt\", */},\n /*::[*/0x0863 /*::]*/: {\n /* n:\"BookExt\", */r: 12\n },\n /*::[*/0x0864 /*::]*/: {/* n:\"SXAddl\", */},\n /*::[*/0x0865 /*::]*/: {/* n:\"CrErr\", */},\n /*::[*/0x0866 /*::]*/: {/* n:\"HFPicture\", */},\n /*::[*/0x0867 /*::]*/: {\n /* n:\"FeatHdr\", */f: parsenoop2\n },\n /*::[*/0x0868 /*::]*/: {/* n:\"Feat\", */},\n /*::[*/0x086a /*::]*/: {/* n:\"DataLabExt\", */},\n /*::[*/0x086b /*::]*/: {/* n:\"DataLabExtContents\", */},\n /*::[*/0x086c /*::]*/: {/* n:\"CellWatch\", */},\n /*::[*/0x0871 /*::]*/: {/* n:\"FeatHdr11\", */},\n /*::[*/0x0872 /*::]*/: {/* n:\"Feature11\", */},\n /*::[*/0x0874 /*::]*/: {/* n:\"DropDownObjIds\", */},\n /*::[*/0x0875 /*::]*/: {/* n:\"ContinueFrt11\", */},\n /*::[*/0x0876 /*::]*/: {/* n:\"DConn\", */},\n /*::[*/0x0877 /*::]*/: {/* n:\"List12\", */},\n /*::[*/0x0878 /*::]*/: {/* n:\"Feature12\", */},\n /*::[*/0x0879 /*::]*/: {/* n:\"CondFmt12\", */},\n /*::[*/0x087a /*::]*/: {/* n:\"CF12\", */},\n /*::[*/0x087b /*::]*/: {/* n:\"CFEx\", */},\n /*::[*/0x087c /*::]*/: {\n /* n:\"XFCRC\", */f: parse_XFCRC,\n r: 12\n },\n /*::[*/0x087d /*::]*/: {\n /* n:\"XFExt\", */f: parse_XFExt,\n r: 12\n },\n /*::[*/0x087e /*::]*/: {/* n:\"AutoFilter12\", */},\n /*::[*/0x087f /*::]*/: {/* n:\"ContinueFrt12\", */},\n /*::[*/0x0884 /*::]*/: {/* n:\"MDTInfo\", */},\n /*::[*/0x0885 /*::]*/: {/* n:\"MDXStr\", */},\n /*::[*/0x0886 /*::]*/: {/* n:\"MDXTuple\", */},\n /*::[*/0x0887 /*::]*/: {/* n:\"MDXSet\", */},\n /*::[*/0x0888 /*::]*/: {/* n:\"MDXProp\", */},\n /*::[*/0x0889 /*::]*/: {/* n:\"MDXKPI\", */},\n /*::[*/0x088a /*::]*/: {/* n:\"MDB\", */},\n /*::[*/0x088b /*::]*/: {/* n:\"PLV\", */},\n /*::[*/0x088c /*::]*/: {\n /* n:\"Compat12\", */f: parsebool,\n r: 12\n },\n /*::[*/0x088d /*::]*/: {/* n:\"DXF\", */},\n /*::[*/0x088e /*::]*/: {\n /* n:\"TableStyles\", */r: 12\n },\n /*::[*/0x088f /*::]*/: {/* n:\"TableStyle\", */},\n /*::[*/0x0890 /*::]*/: {/* n:\"TableStyleElement\", */},\n /*::[*/0x0892 /*::]*/: {/* n:\"StyleExt\", */},\n /*::[*/0x0893 /*::]*/: {/* n:\"NamePublish\", */},\n /*::[*/0x0894 /*::]*/: {\n /* n:\"NameCmt\", */f: parse_NameCmt,\n r: 12\n },\n /*::[*/0x0895 /*::]*/: {/* n:\"SortData\", */},\n /*::[*/0x0896 /*::]*/: {\n /* n:\"Theme\", */f: parse_Theme,\n r: 12\n },\n /*::[*/0x0897 /*::]*/: {/* n:\"GUIDTypeLib\", */},\n /*::[*/0x0898 /*::]*/: {/* n:\"FnGrp12\", */},\n /*::[*/0x0899 /*::]*/: {/* n:\"NameFnGrp12\", */},\n /*::[*/0x089a /*::]*/: {\n /* n:\"MTRSettings\", */f: parse_MTRSettings,\n r: 12\n },\n /*::[*/0x089b /*::]*/: {\n /* n:\"CompressPictures\", */f: parsenoop2\n },\n /*::[*/0x089c /*::]*/: {/* n:\"HeaderFooter\", */},\n /*::[*/0x089d /*::]*/: {/* n:\"CrtLayout12\", */},\n /*::[*/0x089e /*::]*/: {/* n:\"CrtMlFrt\", */},\n /*::[*/0x089f /*::]*/: {/* n:\"CrtMlFrtContinue\", */},\n /*::[*/0x08a3 /*::]*/: {\n /* n:\"ForceFullCalculation\", */f: parse_ForceFullCalculation\n },\n /*::[*/0x08a4 /*::]*/: {/* n:\"ShapePropsStream\", */},\n /*::[*/0x08a5 /*::]*/: {/* n:\"TextPropsStream\", */},\n /*::[*/0x08a6 /*::]*/: {/* n:\"RichTextStream\", */},\n /*::[*/0x08a7 /*::]*/: {/* n:\"CrtLayout12A\", */},\n /*::[*/0x1001 /*::]*/: {/* n:\"Units\", */},\n /*::[*/0x1002 /*::]*/: {/* n:\"Chart\", */},\n /*::[*/0x1003 /*::]*/: {/* n:\"Series\", */},\n /*::[*/0x1006 /*::]*/: {/* n:\"DataFormat\", */},\n /*::[*/0x1007 /*::]*/: {/* n:\"LineFormat\", */},\n /*::[*/0x1009 /*::]*/: {/* n:\"MarkerFormat\", */},\n /*::[*/0x100a /*::]*/: {/* n:\"AreaFormat\", */},\n /*::[*/0x100b /*::]*/: {/* n:\"PieFormat\", */},\n /*::[*/0x100c /*::]*/: {/* n:\"AttachedLabel\", */},\n /*::[*/0x100d /*::]*/: {/* n:\"SeriesText\", */},\n /*::[*/0x1014 /*::]*/: {/* n:\"ChartFormat\", */},\n /*::[*/0x1015 /*::]*/: {/* n:\"Legend\", */},\n /*::[*/0x1016 /*::]*/: {/* n:\"SeriesList\", */},\n /*::[*/0x1017 /*::]*/: {/* n:\"Bar\", */},\n /*::[*/0x1018 /*::]*/: {/* n:\"Line\", */},\n /*::[*/0x1019 /*::]*/: {/* n:\"Pie\", */},\n /*::[*/0x101a /*::]*/: {/* n:\"Area\", */},\n /*::[*/0x101b /*::]*/: {/* n:\"Scatter\", */},\n /*::[*/0x101c /*::]*/: {/* n:\"CrtLine\", */},\n /*::[*/0x101d /*::]*/: {/* n:\"Axis\", */},\n /*::[*/0x101e /*::]*/: {/* n:\"Tick\", */},\n /*::[*/0x101f /*::]*/: {/* n:\"ValueRange\", */},\n /*::[*/0x1020 /*::]*/: {/* n:\"CatSerRange\", */},\n /*::[*/0x1021 /*::]*/: {/* n:\"AxisLine\", */},\n /*::[*/0x1022 /*::]*/: {/* n:\"CrtLink\", */},\n /*::[*/0x1024 /*::]*/: {/* n:\"DefaultText\", */},\n /*::[*/0x1025 /*::]*/: {/* n:\"Text\", */},\n /*::[*/0x1026 /*::]*/: {\n /* n:\"FontX\", */f: parseuint16\n },\n /*::[*/0x1027 /*::]*/: {/* n:\"ObjectLink\", */},\n /*::[*/0x1032 /*::]*/: {/* n:\"Frame\", */},\n /*::[*/0x1033 /*::]*/: {/* n:\"Begin\", */},\n /*::[*/0x1034 /*::]*/: {/* n:\"End\", */},\n /*::[*/0x1035 /*::]*/: {/* n:\"PlotArea\", */},\n /*::[*/0x103a /*::]*/: {/* n:\"Chart3d\", */},\n /*::[*/0x103c /*::]*/: {/* n:\"PicF\", */},\n /*::[*/0x103d /*::]*/: {/* n:\"DropBar\", */},\n /*::[*/0x103e /*::]*/: {/* n:\"Radar\", */},\n /*::[*/0x103f /*::]*/: {/* n:\"Surf\", */},\n /*::[*/0x1040 /*::]*/: {/* n:\"RadarArea\", */},\n /*::[*/0x1041 /*::]*/: {/* n:\"AxisParent\", */},\n /*::[*/0x1043 /*::]*/: {/* n:\"LegendException\", */},\n /*::[*/0x1044 /*::]*/: {\n /* n:\"ShtProps\", */f: parse_ShtProps\n },\n /*::[*/0x1045 /*::]*/: {/* n:\"SerToCrt\", */},\n /*::[*/0x1046 /*::]*/: {/* n:\"AxesUsed\", */},\n /*::[*/0x1048 /*::]*/: {/* n:\"SBaseRef\", */},\n /*::[*/0x104a /*::]*/: {/* n:\"SerParent\", */},\n /*::[*/0x104b /*::]*/: {/* n:\"SerAuxTrend\", */},\n /*::[*/0x104e /*::]*/: {/* n:\"IFmtRecord\", */},\n /*::[*/0x104f /*::]*/: {/* n:\"Pos\", */},\n /*::[*/0x1050 /*::]*/: {/* n:\"AlRuns\", */},\n /*::[*/0x1051 /*::]*/: {/* n:\"BRAI\", */},\n /*::[*/0x105b /*::]*/: {/* n:\"SerAuxErrBar\", */},\n /*::[*/0x105c /*::]*/: {\n /* n:\"ClrtClient\", */f: parse_ClrtClient\n },\n /*::[*/0x105d /*::]*/: {/* n:\"SerFmt\", */},\n /*::[*/0x105f /*::]*/: {/* n:\"Chart3DBarShape\", */},\n /*::[*/0x1060 /*::]*/: {/* n:\"Fbi\", */},\n /*::[*/0x1061 /*::]*/: {/* n:\"BopPop\", */},\n /*::[*/0x1062 /*::]*/: {/* n:\"AxcExt\", */},\n /*::[*/0x1063 /*::]*/: {/* n:\"Dat\", */},\n /*::[*/0x1064 /*::]*/: {/* n:\"PlotGrowth\", */},\n /*::[*/0x1065 /*::]*/: {/* n:\"SIIndex\", */},\n /*::[*/0x1066 /*::]*/: {/* n:\"GelFrame\", */},\n /*::[*/0x1067 /*::]*/: {/* n:\"BopPopCustom\", */},\n /*::[*/0x1068 /*::]*/: {/* n:\"Fbi2\", */},\n /*::[*/0x0000 /*::]*/: {\n /* n:\"Dimensions\", */f: parse_Dimensions\n },\n /*::[*/0x0001 /*::]*/: {/* n:\"BIFF2BLANK\", */},\n /*::[*/0x0002 /*::]*/: {\n /* n:\"BIFF2INT\", */f: parse_BIFF2INT\n },\n /*::[*/0x0003 /*::]*/: {\n /* n:\"BIFF2NUM\", */f: parse_BIFF2NUM\n },\n /*::[*/0x0004 /*::]*/: {\n /* n:\"BIFF2STR\", */f: parse_BIFF2STR\n },\n /*::[*/0x0005 /*::]*/: {\n /* n:\"BoolErr\", */f: parse_BoolErr\n },\n /*::[*/0x0007 /*::]*/: {\n /* n:\"String\", */f: parse_BIFF2STRING\n },\n /*::[*/0x0008 /*::]*/: {/* n:\"BIFF2ROW\", */},\n /*::[*/0x0009 /*::]*/: {\n /* n:\"BOF\", */f: parse_BOF\n },\n /*::[*/0x000b /*::]*/: {/* n:\"Index\", */},\n /*::[*/0x0016 /*::]*/: {\n /* n:\"ExternCount\", */f: parseuint16\n },\n /*::[*/0x001e /*::]*/: {\n /* n:\"BIFF2FORMAT\", */f: parse_BIFF2Format\n },\n /*::[*/0x001f /*::]*/: {/* n:\"BIFF2FMTCNT\", */},\n /* 16-bit cnt of BIFF2FORMAT records */\n /*::[*/0x0020 /*::]*/: {/* n:\"BIFF2COLINFO\", */},\n /*::[*/0x0021 /*::]*/: {\n /* n:\"Array\", */f: parse_Array\n },\n /*::[*/0x0024 /*::]*/: {/* n:\"COLWIDTH\", */},\n /*::[*/0x0025 /*::]*/: {\n /* n:\"DefaultRowHeight\", */f: parse_DefaultRowHeight\n },\n // 0x2c ??\n // 0x2d ??\n // 0x2e ??\n // 0x30 FONTCOUNT: number of fonts\n /*::[*/\n 0x0032 /*::]*/: {\n /* n:\"BIFF2FONTXTRA\", */f: parse_BIFF2FONTXTRA\n },\n // 0x35: INFOOPTS\n // 0x36: TABLE (BIFF2 only)\n // 0x37: TABLE2 (BIFF2 only)\n // 0x38: WNDESK\n // 0x39 ??\n // 0x3a: BEGINPREF\n // 0x3b: ENDPREF\n /*::[*/\n 0x003e /*::]*/: {/* n:\"BIFF2WINDOW2\", */},\n // 0x3f ??\n // 0x46: SHOWSCROLL\n // 0x47: SHOWFORMULA\n // 0x48: STATUSBAR\n // 0x49: SHORTMENUS\n // 0x4A:\n // 0x4B:\n // 0x4C:\n // 0x4E:\n // 0x4F:\n // 0x58: TOOLBAR (BIFF3)\n\n /* - - - */\n /*::[*/\n 0x0034 /*::]*/: {/* n:\"DDEObjName\", */},\n /*::[*/0x0043 /*::]*/: {/* n:\"BIFF2XF\", */},\n /*::[*/0x0044 /*::]*/: {\n /* n:\"BIFF2XFINDEX\", */f: parseuint16\n },\n /*::[*/0x0045 /*::]*/: {/* n:\"BIFF2FONTCLR\", */},\n /*::[*/0x0056 /*::]*/: {/* n:\"BIFF4FMTCNT\", */},\n /* 16-bit cnt, similar to BIFF2 */\n /*::[*/0x007e /*::]*/: {/* n:\"RK\", */},\n /* Not necessarily same as 0x027e */\n /*::[*/0x007f /*::]*/: {\n /* n:\"ImData\", */f: parse_ImData\n },\n /*::[*/0x0087 /*::]*/: {/* n:\"Addin\", */},\n /*::[*/0x0088 /*::]*/: {/* n:\"Edg\", */},\n /*::[*/0x0089 /*::]*/: {/* n:\"Pub\", */},\n // 0x8A\n // 0x8B LH: alternate menu key flag (BIFF3/4)\n // 0x8E\n // 0x8F\n /*::[*/\n 0x0091 /*::]*/: {/* n:\"Sub\", */},\n // 0x93 STYLE\n /*::[*/\n 0x0094 /*::]*/: {/* n:\"LHRecord\", */},\n /*::[*/0x0095 /*::]*/: {/* n:\"LHNGraph\", */},\n /*::[*/0x0096 /*::]*/: {/* n:\"Sound\", */},\n // 0xA2 FNPROTO: function prototypes (BIFF4)\n // 0xA3\n // 0xA8\n /*::[*/\n 0x00a9 /*::]*/: {/* n:\"CoordList\", */},\n /*::[*/0x00ab /*::]*/: {/* n:\"GCW\", */},\n /*::[*/0x00bc /*::]*/: {/* n:\"ShrFmla\", */},\n /* Not necessarily same as 0x04bc */\n /*::[*/0x00bf /*::]*/: {/* n:\"ToolbarHdr\", */},\n /*::[*/0x00c0 /*::]*/: {/* n:\"ToolbarEnd\", */},\n /*::[*/0x00c2 /*::]*/: {/* n:\"AddMenu\", */},\n /*::[*/0x00c3 /*::]*/: {/* n:\"DelMenu\", */},\n /*::[*/0x00d6 /*::]*/: {\n /* n:\"RString\", */f: parse_RString\n },\n /*::[*/0x00df /*::]*/: {/* n:\"UDDesc\", */},\n /*::[*/0x00ea /*::]*/: {/* n:\"TabIdConf\", */},\n /*::[*/0x0162 /*::]*/: {/* n:\"XL5Modify\", */},\n /*::[*/0x01a5 /*::]*/: {/* n:\"FileSharing2\", */},\n /*::[*/0x0206 /*::]*/: {\n /* n:\"Formula\", */f: parse_Formula\n },\n /*::[*/0x0209 /*::]*/: {\n /* n:\"BOF\", */f: parse_BOF\n },\n /*::[*/0x0218 /*::]*/: {\n /* n:\"Lbl\", */f: parse_Lbl\n },\n /*::[*/0x0223 /*::]*/: {\n /* n:\"ExternName\", */f: parse_ExternName\n },\n /*::[*/0x0231 /*::]*/: {/* n:\"Font\", */},\n /*::[*/0x0243 /*::]*/: {/* n:\"BIFF3XF\", */},\n /*::[*/0x0406 /*::]*/: {\n /* n:\"Formula\", */f: parse_Formula\n },\n /*::[*/0x0409 /*::]*/: {\n /* n:\"BOF\", */f: parse_BOF\n },\n /*::[*/0x0443 /*::]*/: {/* n:\"BIFF4XF\", */},\n /*::[*/0x086d /*::]*/: {/* n:\"FeatInfo\", */},\n /*::[*/0x0873 /*::]*/: {/* n:\"FeatInfo11\", */},\n /*::[*/0x0881 /*::]*/: {/* n:\"SXAddl12\", */},\n /*::[*/0x08c0 /*::]*/: {/* n:\"AutoWebPub\", */},\n /*::[*/0x08c1 /*::]*/: {/* n:\"ListObj\", */},\n /*::[*/0x08c2 /*::]*/: {/* n:\"ListField\", */},\n /*::[*/0x08c3 /*::]*/: {/* n:\"ListDV\", */},\n /*::[*/0x08c4 /*::]*/: {/* n:\"ListCondFmt\", */},\n /*::[*/0x08c5 /*::]*/: {/* n:\"ListCF\", */},\n /*::[*/0x08c6 /*::]*/: {/* n:\"FMQry\", */},\n /*::[*/0x08c7 /*::]*/: {/* n:\"FMSQry\", */},\n /*::[*/0x08c8 /*::]*/: {/* n:\"PLV\", */},\n /*::[*/0x08c9 /*::]*/: {/* n:\"LnExt\", */},\n /*::[*/0x08ca /*::]*/: {/* n:\"MkrExt\", */},\n /*::[*/0x08cb /*::]*/: {/* n:\"CrtCoopt\", */},\n /*::[*/0x08d6 /*::]*/: {\n /* n:\"FRTArchId$\", */r: 12\n },\n /*::[*/0x7262 /*::]*/: {}\n};\nfunction write_biff_rec(ba /*:BufArray*/, type /*:number*/, payload, length /*:?number*/) /*:void*/{\n var t /*:number*/ = type;\n if (isNaN(t)) return;\n var len = length || (payload || []).length || 0;\n var o = ba.next(4);\n o.write_shift(2, t);\n o.write_shift(2, len);\n if (/*:: len != null &&*/len > 0 && is_buf(payload)) ba.push(payload);\n}\nfunction write_biff_continue(ba /*:BufArray*/, type /*:number*/, payload, length /*:?number*/) /*:void*/{\n var len = length || (payload || []).length || 0;\n if (len <= 8224) return write_biff_rec(ba, type, payload, len);\n var t = type;\n if (isNaN(t)) return;\n var parts = payload.parts || [],\n sidx = 0;\n var i = 0,\n w = 0;\n while (w + (parts[sidx] || 8224) <= 8224) {\n w += parts[sidx] || 8224;\n sidx++;\n }\n var o = ba.next(4);\n o.write_shift(2, t);\n o.write_shift(2, w);\n ba.push(payload.slice(i, i + w));\n i += w;\n while (i < len) {\n o = ba.next(4);\n o.write_shift(2, 0x3c); // TODO: figure out correct continue type\n w = 0;\n while (w + (parts[sidx] || 8224) <= 8224) {\n w += parts[sidx] || 8224;\n sidx++;\n }\n o.write_shift(2, w);\n ba.push(payload.slice(i, i + w));\n i += w;\n }\n}\nfunction write_BIFF2Cell(out, r /*:number*/, c /*:number*/) {\n if (!out) out = new_buf(7);\n out.write_shift(2, r);\n out.write_shift(2, c);\n out.write_shift(2, 0);\n out.write_shift(1, 0);\n return out;\n}\nfunction write_BIFF2BERR(r /*:number*/, c /*:number*/, val, t /*:?string*/) {\n var out = new_buf(9);\n write_BIFF2Cell(out, r, c);\n write_Bes(val, t || 'b', out);\n return out;\n}\n\n/* TODO: codepage, large strings */\nfunction write_BIFF2LABEL(r /*:number*/, c /*:number*/, val) {\n var out = new_buf(8 + 2 * val.length);\n write_BIFF2Cell(out, r, c);\n out.write_shift(1, val.length);\n out.write_shift(val.length, val, 'sbcs');\n return out.l < out.length ? out.slice(0, out.l) : out;\n}\nfunction write_ws_biff2_cell(ba /*:BufArray*/, cell /*:Cell*/, R /*:number*/, C /*:number*/ /*::, opts*/) {\n if (cell.v != null) switch (cell.t) {\n case 'd':\n case 'n':\n var v = cell.t == 'd' ? datenum(parseDate(cell.v)) : cell.v;\n if (v == (v | 0) && v >= 0 && v < 65536) write_biff_rec(ba, 0x0002, write_BIFF2INT(R, C, v));else write_biff_rec(ba, 0x0003, write_BIFF2NUM(R, C, v));\n return;\n case 'b':\n case 'e':\n write_biff_rec(ba, 0x0005, write_BIFF2BERR(R, C, cell.v, cell.t));\n return;\n /* TODO: codepage, sst */\n case 's':\n case 'str':\n write_biff_rec(ba, 0x0004, write_BIFF2LABEL(R, C, (cell.v || \"\").slice(0, 255)));\n return;\n }\n write_biff_rec(ba, 0x0001, write_BIFF2Cell(null, R, C));\n}\nfunction write_ws_biff2(ba /*:BufArray*/, ws /*:Worksheet*/, idx /*:number*/, opts /*::, wb:Workbook*/) {\n var dense = Array.isArray(ws);\n var range = safe_decode_range(ws['!ref'] || \"A1\"),\n ref /*:string*/,\n rr = \"\",\n cols /*:Array*/ = [];\n if (range.e.c > 0xFF || range.e.r > 0x3FFF) {\n if (opts.WTF) throw new Error(\"Range \" + (ws['!ref'] || \"A1\") + \" exceeds format limit A1:IV16384\");\n range.e.c = Math.min(range.e.c, 0xFF);\n range.e.r = Math.min(range.e.c, 0x3FFF);\n ref = encode_range(range);\n }\n for (var R = range.s.r; R <= range.e.r; ++R) {\n rr = encode_row(R);\n for (var C = range.s.c; C <= range.e.c; ++C) {\n if (R === range.s.r) cols[C] = encode_col(C);\n ref = cols[C] + rr;\n var cell = dense ? (ws[R] || [])[C] : ws[ref];\n if (!cell) continue;\n /* write cell */\n write_ws_biff2_cell(ba, cell, R, C, opts);\n }\n }\n}\n\n/* Based on test files */\nfunction write_biff2_buf(wb /*:Workbook*/, opts /*:WriteOpts*/) {\n var o = opts || {};\n if (DENSE != null && o.dense == null) o.dense = DENSE;\n var ba = buf_array();\n var idx = 0;\n for (var i = 0; i < wb.SheetNames.length; ++i) if (wb.SheetNames[i] == o.sheet) idx = i;\n if (idx == 0 && !!o.sheet && wb.SheetNames[0] != o.sheet) throw new Error(\"Sheet not found: \" + o.sheet);\n write_biff_rec(ba, o.biff == 4 ? 0x0409 : o.biff == 3 ? 0x0209 : 0x0009, write_BOF(wb, 0x10, o));\n /* ... */\n write_ws_biff2(ba, wb.Sheets[wb.SheetNames[idx]], idx, o, wb);\n /* ... */\n write_biff_rec(ba, 0x000A);\n return ba.end();\n}\nfunction write_FONTS_biff8(ba, data, opts) {\n write_biff_rec(ba, 0x0031 /* Font */, write_Font({\n sz: 12,\n color: {\n theme: 1\n },\n name: \"Arial\",\n family: 2,\n scheme: \"minor\"\n }, opts));\n}\nfunction write_FMTS_biff8(ba, NF /*:?SSFTable*/, opts) {\n if (!NF) return;\n [[5, 8], [23, 26], [41, 44], [/*63*/50, /*66],[164,*/392]].forEach(function (r) {\n /*:: if(!NF) return; */\n for (var i = r[0]; i <= r[1]; ++i) if (NF[i] != null) write_biff_rec(ba, 0x041E /* Format */, write_Format(i, NF[i], opts));\n });\n}\nfunction write_FEAT(ba, ws) {\n /* [MS-XLS] 2.4.112 */\n var o = new_buf(19);\n o.write_shift(4, 0x867);\n o.write_shift(4, 0);\n o.write_shift(4, 0);\n o.write_shift(2, 3);\n o.write_shift(1, 1);\n o.write_shift(4, 0);\n write_biff_rec(ba, 0x0867 /* FeatHdr */, o);\n /* [MS-XLS] 2.4.111 */\n o = new_buf(39);\n o.write_shift(4, 0x868);\n o.write_shift(4, 0);\n o.write_shift(4, 0);\n o.write_shift(2, 3);\n o.write_shift(1, 0);\n o.write_shift(4, 0);\n o.write_shift(2, 1);\n o.write_shift(4, 4);\n o.write_shift(2, 0);\n write_Ref8U(safe_decode_range(ws['!ref'] || \"A1\"), o);\n o.write_shift(4, 4);\n write_biff_rec(ba, 0x0868 /* Feat */, o);\n}\nfunction write_CELLXFS_biff8(ba, opts) {\n for (var i = 0; i < 16; ++i) write_biff_rec(ba, 0x00e0 /* XF */, write_XF({\n numFmtId: 0,\n style: true\n }, 0, opts));\n opts.cellXfs.forEach(function (c) {\n write_biff_rec(ba, 0x00e0 /* XF */, write_XF(c, 0, opts));\n });\n}\nfunction write_ws_biff8_hlinks(ba /*:BufArray*/, ws) {\n for (var R = 0; R < ws['!links'].length; ++R) {\n var HL = ws['!links'][R];\n write_biff_rec(ba, 0x01b8 /* HLink */, write_HLink(HL));\n if (HL[1].Tooltip) write_biff_rec(ba, 0x0800 /* HLinkTooltip */, write_HLinkTooltip(HL));\n }\n delete ws['!links'];\n}\nfunction write_ws_cols_biff8(ba, cols) {\n if (!cols) return;\n var cnt = 0;\n cols.forEach(function (col, idx) {\n if (++cnt <= 256 && col) {\n write_biff_rec(ba, 0x007d /* ColInfo */, write_ColInfo(col_obj_w(idx, col), idx));\n }\n });\n}\nfunction write_ws_biff8_cell(ba /*:BufArray*/, cell /*:Cell*/, R /*:number*/, C /*:number*/, opts) {\n var os = 16 + get_cell_style(opts.cellXfs, cell, opts);\n if (cell.v == null && !cell.bf) {\n write_biff_rec(ba, 0x0201 /* Blank */, write_XLSCell(R, C, os));\n return;\n }\n if (cell.bf) write_biff_rec(ba, 0x0006 /* Formula */, write_Formula(cell, R, C, opts, os));else switch (cell.t) {\n case 'd':\n case 'n':\n var v = cell.t == 'd' ? datenum(parseDate(cell.v)) : cell.v;\n /* TODO: emit RK as appropriate */\n write_biff_rec(ba, 0x0203 /* Number */, write_Number(R, C, v, os, opts));\n break;\n case 'b':\n case 'e':\n write_biff_rec(ba, 0x0205 /* BoolErr */, write_BoolErr(R, C, cell.v, os, opts, cell.t));\n break;\n /* TODO: codepage, sst */\n case 's':\n case 'str':\n if (opts.bookSST) {\n var isst = get_sst_id(opts.Strings, cell.v, opts.revStrings);\n write_biff_rec(ba, 0x00fd /* LabelSst */, write_LabelSst(R, C, isst, os, opts));\n } else write_biff_rec(ba, 0x0204 /* Label */, write_Label(R, C, (cell.v || \"\").slice(0, 255), os, opts));\n break;\n default:\n write_biff_rec(ba, 0x0201 /* Blank */, write_XLSCell(R, C, os));\n }\n}\n\n/* [MS-XLS] 2.1.7.20.5 */\nfunction write_ws_biff8(idx /*:number*/, opts, wb /*:Workbook*/) {\n var ba = buf_array();\n var s = wb.SheetNames[idx],\n ws = wb.Sheets[s] || {};\n var _WB /*:WBWBProps*/ = (wb || {}).Workbook || {} /*:any*/;\n var _sheet /*:WBWSProp*/ = (_WB.Sheets || [])[idx] || {} /*:any*/;\n var dense = Array.isArray(ws);\n var b8 = opts.biff == 8;\n var ref /*:string*/,\n rr = \"\",\n cols /*:Array*/ = [];\n var range = safe_decode_range(ws['!ref'] || \"A1\");\n var MAX_ROWS = b8 ? 65536 : 16384;\n if (range.e.c > 0xFF || range.e.r >= MAX_ROWS) {\n if (opts.WTF) throw new Error(\"Range \" + (ws['!ref'] || \"A1\") + \" exceeds format limit A1:IV16384\");\n range.e.c = Math.min(range.e.c, 0xFF);\n range.e.r = Math.min(range.e.c, MAX_ROWS - 1);\n }\n write_biff_rec(ba, 0x0809, write_BOF(wb, 0x10, opts));\n /* [Uncalced] Index */\n write_biff_rec(ba, 0x000d /* CalcMode */, writeuint16(1));\n write_biff_rec(ba, 0x000c /* CalcCount */, writeuint16(100));\n write_biff_rec(ba, 0x000f /* CalcRefMode */, writebool(true));\n write_biff_rec(ba, 0x0011 /* CalcIter */, writebool(false));\n write_biff_rec(ba, 0x0010 /* CalcDelta */, write_Xnum(0.001));\n write_biff_rec(ba, 0x005f /* CalcSaveRecalc */, writebool(true));\n write_biff_rec(ba, 0x002a /* PrintRowCol */, writebool(false));\n write_biff_rec(ba, 0x002b /* PrintGrid */, writebool(false));\n write_biff_rec(ba, 0x0082 /* GridSet */, writeuint16(1));\n write_biff_rec(ba, 0x0080 /* Guts */, write_Guts([0, 0]));\n /* DefaultRowHeight WsBool [Sync] [LPr] [HorizontalPageBreaks] [VerticalPageBreaks] */\n /* Header (string) */\n /* Footer (string) */\n write_biff_rec(ba, 0x0083 /* HCenter */, writebool(false));\n write_biff_rec(ba, 0x0084 /* VCenter */, writebool(false));\n /* ... */\n if (b8) write_ws_cols_biff8(ba, ws[\"!cols\"]);\n /* ... */\n write_biff_rec(ba, 0x200, write_Dimensions(range, opts));\n /* ... */\n\n if (b8) ws['!links'] = [];\n for (var R = range.s.r; R <= range.e.r; ++R) {\n rr = encode_row(R);\n for (var C = range.s.c; C <= range.e.c; ++C) {\n if (R === range.s.r) cols[C] = encode_col(C);\n ref = cols[C] + rr;\n var cell = dense ? (ws[R] || [])[C] : ws[ref];\n if (!cell) continue;\n /* write cell */\n write_ws_biff8_cell(ba, cell, R, C, opts);\n if (b8 && cell.l) ws['!links'].push([ref, cell.l]);\n }\n }\n var cname /*:string*/ = _sheet.CodeName || _sheet.name || s;\n /* ... */\n if (b8) write_biff_rec(ba, 0x023e /* Window2 */, write_Window2((_WB.Views || [])[0]));\n /* ... */\n if (b8 && (ws['!merges'] || []).length) write_biff_rec(ba, 0x00e5 /* MergeCells */, write_MergeCells(ws['!merges']));\n /* [LRng] *QUERYTABLE [PHONETICINFO] CONDFMTS */\n if (b8) write_ws_biff8_hlinks(ba, ws);\n /* [DVAL] */\n write_biff_rec(ba, 0x01ba /* CodeName */, write_XLUnicodeString(cname, opts));\n /* *WebPub *CellWatch [SheetExt] */\n if (b8) write_FEAT(ba, ws);\n /* *FEAT11 *RECORD12 */\n write_biff_rec(ba, 0x000a /* EOF */);\n return ba.end();\n}\n\n/* [MS-XLS] 2.1.7.20.3 */\nfunction write_biff8_global(wb /*:Workbook*/, bufs, opts /*:WriteOpts*/) {\n var A = buf_array();\n var _WB /*:WBWBProps*/ = (wb || {}).Workbook || {} /*:any*/;\n var _sheets /*:Array*/ = _WB.Sheets || [];\n var _wb /*:WBProps*/ = /*::((*/_WB.WBProps || {/*::CodeName:\"ThisWorkbook\"*/} /*:: ):any)*/;\n var b8 = opts.biff == 8,\n b5 = opts.biff == 5;\n write_biff_rec(A, 0x0809, write_BOF(wb, 0x05, opts));\n if (opts.bookType == \"xla\") write_biff_rec(A, 0x0087 /* Addin */);\n write_biff_rec(A, 0x00e1 /* InterfaceHdr */, b8 ? writeuint16(0x04b0) : null);\n write_biff_rec(A, 0x00c1 /* Mms */, writezeroes(2));\n if (b5) write_biff_rec(A, 0x00bf /* ToolbarHdr */);\n if (b5) write_biff_rec(A, 0x00c0 /* ToolbarEnd */);\n write_biff_rec(A, 0x00e2 /* InterfaceEnd */);\n write_biff_rec(A, 0x005c /* WriteAccess */, write_WriteAccess(\"SheetJS\", opts));\n /* [FileSharing] */\n write_biff_rec(A, 0x0042 /* CodePage */, writeuint16(b8 ? 0x04b0 : 0x04E4));\n /* *2047 Lel */\n if (b8) write_biff_rec(A, 0x0161 /* DSF */, writeuint16(0));\n if (b8) write_biff_rec(A, 0x01c0 /* Excel9File */);\n write_biff_rec(A, 0x013d /* RRTabId */, write_RRTabId(wb.SheetNames.length));\n if (b8 && wb.vbaraw) write_biff_rec(A, 0x00d3 /* ObProj */);\n /* [ObNoMacros] */\n if (b8 && wb.vbaraw) {\n var cname /*:string*/ = _wb.CodeName || \"ThisWorkbook\";\n write_biff_rec(A, 0x01ba /* CodeName */, write_XLUnicodeString(cname, opts));\n }\n write_biff_rec(A, 0x009c /* BuiltInFnGroupCount */, writeuint16(0x11));\n /* *FnGroupName *FnGrp12 */\n /* *Lbl */\n /* [OleObjectSize] */\n write_biff_rec(A, 0x0019 /* WinProtect */, writebool(false));\n write_biff_rec(A, 0x0012 /* Protect */, writebool(false));\n write_biff_rec(A, 0x0013 /* Password */, writeuint16(0));\n if (b8) write_biff_rec(A, 0x01af /* Prot4Rev */, writebool(false));\n if (b8) write_biff_rec(A, 0x01bc /* Prot4RevPass */, writeuint16(0));\n write_biff_rec(A, 0x003d /* Window1 */, write_Window1(opts));\n write_biff_rec(A, 0x0040 /* Backup */, writebool(false));\n write_biff_rec(A, 0x008d /* HideObj */, writeuint16(0));\n write_biff_rec(A, 0x0022 /* Date1904 */, writebool(safe1904(wb) == \"true\"));\n write_biff_rec(A, 0x000e /* CalcPrecision */, writebool(true));\n if (b8) write_biff_rec(A, 0x01b7 /* RefreshAll */, writebool(false));\n write_biff_rec(A, 0x00DA /* BookBool */, writeuint16(0));\n /* ... */\n write_FONTS_biff8(A, wb, opts);\n write_FMTS_biff8(A, wb.SSF, opts);\n write_CELLXFS_biff8(A, opts);\n /* ... */\n if (b8) write_biff_rec(A, 0x0160 /* UsesELFs */, writebool(false));\n var a = A.end();\n var C = buf_array();\n /* METADATA [MTRSettings] [ForceFullCalculation] */\n if (b8) write_biff_rec(C, 0x008C, write_Country());\n /* *SUPBOOK *LBL *RTD [RecalcId] *HFPicture *MSODRAWINGGROUP */\n\n /* BIFF8: [SST *Continue] ExtSST */\n if (b8 && opts.Strings) write_biff_continue(C, 0x00FC, write_SST(opts.Strings, opts));\n\n /* *WebPub [WOpt] [CrErr] [BookExt] *FeatHdr *DConn [THEME] [CompressPictures] [Compat12] [GUIDTypeLib] */\n write_biff_rec(C, 0x000A /* EOF */);\n var c = C.end();\n var B = buf_array();\n var blen = 0,\n j = 0;\n for (j = 0; j < wb.SheetNames.length; ++j) blen += (b8 ? 12 : 11) + (b8 ? 2 : 1) * wb.SheetNames[j].length;\n var start = a.length + blen + c.length;\n for (j = 0; j < wb.SheetNames.length; ++j) {\n var _sheet /*:WBWSProp*/ = _sheets[j] || {} /*:any*/;\n write_biff_rec(B, 0x0085 /* BoundSheet8 */, write_BoundSheet8({\n pos: start,\n hs: _sheet.Hidden || 0,\n dt: 0,\n name: wb.SheetNames[j]\n }, opts));\n start += bufs[j].length;\n }\n /* 1*BoundSheet8 */\n var b = B.end();\n if (blen != b.length) throw new Error(\"BS8 \" + blen + \" != \" + b.length);\n var out = [];\n if (a.length) out.push(a);\n if (b.length) out.push(b);\n if (c.length) out.push(c);\n return bconcat(out);\n}\n\n/* [MS-XLS] 2.1.7.20 Workbook Stream */\nfunction write_biff8_buf(wb /*:Workbook*/, opts /*:WriteOpts*/) {\n var o = opts || {};\n var bufs = [];\n if (wb && !wb.SSF) {\n wb.SSF = dup(table_fmt);\n }\n if (wb && wb.SSF) {\n make_ssf();\n SSF_load_table(wb.SSF);\n // $FlowIgnore\n o.revssf = evert_num(wb.SSF);\n o.revssf[wb.SSF[65535]] = 0;\n o.ssf = wb.SSF;\n }\n o.Strings = /*::((*/[] /*:: :any):SST)*/;\n o.Strings.Count = 0;\n o.Strings.Unique = 0;\n fix_write_opts(o);\n o.cellXfs = [];\n get_cell_style(o.cellXfs, {}, {\n revssf: {\n \"General\": 0\n }\n });\n if (!wb.Props) wb.Props = {};\n for (var i = 0; i < wb.SheetNames.length; ++i) bufs[bufs.length] = write_ws_biff8(i, o, wb);\n bufs.unshift(write_biff8_global(wb, bufs, o));\n return bconcat(bufs);\n}\nfunction write_biff_buf(wb /*:Workbook*/, opts /*:WriteOpts*/) {\n for (var i = 0; i <= wb.SheetNames.length; ++i) {\n var ws = wb.Sheets[wb.SheetNames[i]];\n if (!ws || !ws[\"!ref\"]) continue;\n var range = decode_range(ws[\"!ref\"]);\n if (range.e.c > 255) {\n // note: 255 is IV\n if (typeof console != \"undefined\" && console.error) console.error(\"Worksheet '\" + wb.SheetNames[i] + \"' extends beyond column IV (255). Data may be lost.\");\n }\n }\n var o = opts || {};\n switch (o.biff || 2) {\n case 8:\n case 5:\n return write_biff8_buf(wb, opts);\n case 4:\n case 3:\n case 2:\n return write_biff2_buf(wb, opts);\n }\n throw new Error(\"invalid type \" + o.bookType + \" for BIFF\");\n}\n/* note: browser DOM element cannot see mso- style attrs, must parse */\nfunction html_to_sheet(str /*:string*/, _opts) /*:Workbook*/{\n var opts = _opts || {};\n if (DENSE != null && opts.dense == null) opts.dense = DENSE;\n var ws /*:Worksheet*/ = opts.dense ? [] /*:any*/ : {} /*:any*/;\n str = str.replace(//g, \"\");\n var mtch /*:any*/ = str.match(/\");\n var mtch2 /*:any*/ = str.match(/<\\/table/i);\n var i /*:number*/ = mtch.index,\n j /*:number*/ = mtch2 && mtch2.index || str.length;\n var rows = split_regex(str.slice(i, j), /(:?]*>)/i, \"\");\n var R = -1,\n C = 0,\n RS = 0,\n CS = 0;\n var range /*:Range*/ = {\n s: {\n r: 10000000,\n c: 10000000\n },\n e: {\n r: 0,\n c: 0\n }\n };\n var merges /*:Array*/ = [];\n for (i = 0; i < rows.length; ++i) {\n var row = rows[i].trim();\n var hd = row.slice(0, 3).toLowerCase();\n if (hd == \"/i);\n for (j = 0; j < cells.length; ++j) {\n var cell = cells[j].trim();\n if (!cell.match(/\")) > -1) m = m.slice(cc + 1);\n for (var midx = 0; midx < merges.length; ++midx) {\n var _merge /*:Range*/ = merges[midx];\n if (_merge.s.c == C && _merge.s.r < R && R <= _merge.e.r) {\n C = _merge.e.c + 1;\n midx = -1;\n }\n }\n var tag = parsexmltag(cell.slice(0, cell.indexOf(\">\")));\n CS = tag.colspan ? +tag.colspan : 1;\n if ((RS = +tag.rowspan) > 1 || CS > 1) merges.push({\n s: {\n r: R,\n c: C\n },\n e: {\n r: R + (RS || 1) - 1,\n c: C + CS - 1\n }\n });\n var _t /*:string*/ = tag.t || tag[\"data-t\"] || \"\";\n /* TODO: generate stub cells */\n if (!m.length) {\n C += CS;\n continue;\n }\n m = htmldecode(m);\n if (range.s.r > R) range.s.r = R;\n if (range.e.r < R) range.e.r = R;\n if (range.s.c > C) range.s.c = C;\n if (range.e.c < C) range.e.c = C;\n if (!m.length) {\n C += CS;\n continue;\n }\n var o /*:Cell*/ = {\n t: 's',\n v: m\n };\n if (opts.raw || !m.trim().length || _t == 's') {} else if (m === 'TRUE') o = {\n t: 'b',\n v: true\n };else if (m === 'FALSE') o = {\n t: 'b',\n v: false\n };else if (!isNaN(fuzzynum(m))) o = {\n t: 'n',\n v: fuzzynum(m)\n };else if (!isNaN(fuzzydate(m).getDate())) {\n o = {\n t: 'd',\n v: parseDate(m)\n } /*:any*/;\n if (!opts.cellDates) o = {\n t: 'n',\n v: datenum(o.v)\n } /*:any*/;\n o.z = opts.dateNF || table_fmt[14];\n }\n if (opts.dense) {\n if (!ws[R]) ws[R] = [];\n ws[R][C] = o;\n } else ws[encode_cell({\n r: R,\n c: C\n })] = o;\n C += CS;\n }\n }\n ws['!ref'] = encode_range(range);\n if (merges.length) ws[\"!merges\"] = merges;\n return ws;\n}\nfunction make_html_row(ws /*:Worksheet*/, r /*:Range*/, R /*:number*/, o /*:Sheet2HTMLOpts*/) /*:string*/{\n var M /*:Array*/ = ws['!merges'] || [];\n var oo /*:Array*/ = [];\n for (var C = r.s.c; C <= r.e.c; ++C) {\n var RS = 0,\n CS = 0;\n for (var j = 0; j < M.length; ++j) {\n if (M[j].s.r > R || M[j].s.c > C) continue;\n if (M[j].e.r < R || M[j].e.c < C) continue;\n if (M[j].s.r < R || M[j].s.c < C) {\n RS = -1;\n break;\n }\n RS = M[j].e.r - M[j].s.r + 1;\n CS = M[j].e.c - M[j].s.c + 1;\n break;\n }\n if (RS < 0) continue;\n var coord = encode_cell({\n r: R,\n c: C\n });\n var cell = o.dense ? (ws[R] || [])[C] : ws[coord];\n /* TODO: html entities */\n var w = cell && cell.v != null && (cell.h || escapehtml(cell.w || (format_cell(cell), cell.w) || \"\")) || \"\";\n var sp = {} /*:any*/;\n if (RS > 1) sp.rowspan = RS;\n if (CS > 1) sp.colspan = CS;\n if (o.editable) w = '' + w + '';else if (cell) {\n sp[\"data-t\"] = cell && cell.t || 'z';\n if (cell.v != null) sp[\"data-v\"] = cell.v;\n if (cell.z != null) sp[\"data-z\"] = cell.z;\n if (cell.l && (cell.l.Target || \"#\").charAt(0) != \"#\") w = '' + w + '';\n }\n sp.id = (o.id || \"sjs\") + \"-\" + coord;\n oo.push(writextag('td', w, sp));\n }\n var preamble = \"\";\n return preamble + oo.join(\"\") + \"\";\n}\nvar HTML_BEGIN = 'SheetJS Table Export';\nvar HTML_END = '';\nfunction html_to_workbook(str /*:string*/, opts) /*:Workbook*/{\n var mtch = str.match(/[\\s\\S]*?<\\/table>/gi);\n if (!mtch || mtch.length == 0) throw new Error(\"Invalid HTML: could not find
\");\n if (mtch.length == 1) return sheet_to_workbook(html_to_sheet(mtch[0], opts), opts);\n var wb = book_new();\n mtch.forEach(function (s, idx) {\n book_append_sheet(wb, html_to_sheet(s, opts), \"Sheet\" + (idx + 1));\n });\n return wb;\n}\nfunction make_html_preamble(ws /*:Worksheet*/, R /*:Range*/, o /*:Sheet2HTMLOpts*/) /*:string*/{\n var out /*:Array*/ = [];\n return out.join(\"\") + '';\n}\nfunction sheet_to_html(ws /*:Worksheet*/, opts /*:?Sheet2HTMLOpts*/ /*, wb:?Workbook*/) /*:string*/{\n var o = opts || {};\n var header = o.header != null ? o.header : HTML_BEGIN;\n var footer = o.footer != null ? o.footer : HTML_END;\n var out /*:Array*/ = [header];\n var r = decode_range(ws['!ref']);\n o.dense = Array.isArray(ws);\n out.push(make_html_preamble(ws, r, o));\n for (var R = r.s.r; R <= r.e.r; ++R) out.push(make_html_row(ws, r, R, o));\n out.push(\"
\" + footer);\n return out.join(\"\");\n}\nfunction sheet_add_dom(ws /*:Worksheet*/, table /*:HTMLElement*/, _opts /*:?any*/) /*:Worksheet*/{\n var opts = _opts || {};\n if (DENSE != null) opts.dense = DENSE;\n var or_R = 0,\n or_C = 0;\n if (opts.origin != null) {\n if (typeof opts.origin == 'number') or_R = opts.origin;else {\n var _origin /*:CellAddress*/ = typeof opts.origin == \"string\" ? decode_cell(opts.origin) : opts.origin;\n or_R = _origin.r;\n or_C = _origin.c;\n }\n }\n var rows /*:HTMLCollection*/ = table.getElementsByTagName('tr');\n var sheetRows = Math.min(opts.sheetRows || 10000000, rows.length);\n var range /*:Range*/ = {\n s: {\n r: 0,\n c: 0\n },\n e: {\n r: or_R,\n c: or_C\n }\n };\n if (ws[\"!ref\"]) {\n var _range /*:Range*/ = decode_range(ws[\"!ref\"]);\n range.s.r = Math.min(range.s.r, _range.s.r);\n range.s.c = Math.min(range.s.c, _range.s.c);\n range.e.r = Math.max(range.e.r, _range.e.r);\n range.e.c = Math.max(range.e.c, _range.e.c);\n if (or_R == -1) range.e.r = or_R = _range.e.r + 1;\n }\n var merges /*:Array*/ = [],\n midx = 0;\n var rowinfo /*:Array*/ = ws[\"!rows\"] || (ws[\"!rows\"] = []);\n var _R = 0,\n R = 0,\n _C = 0,\n C = 0,\n RS = 0,\n CS = 0;\n if (!ws[\"!cols\"]) ws['!cols'] = [];\n for (; _R < rows.length && R < sheetRows; ++_R) {\n var row /*:HTMLTableRowElement*/ = rows[_R];\n if (is_dom_element_hidden(row)) {\n if (opts.display) continue;\n rowinfo[R] = {\n hidden: true\n };\n }\n var elts /*:HTMLCollection*/ = row.children /*:any*/;\n for (_C = C = 0; _C < elts.length; ++_C) {\n var elt /*:HTMLTableCellElement*/ = elts[_C];\n if (opts.display && is_dom_element_hidden(elt)) continue;\n var v /*:?string*/ = elt.hasAttribute('data-v') ? elt.getAttribute('data-v') : elt.hasAttribute('v') ? elt.getAttribute('v') : htmldecode(elt.innerHTML);\n var z /*:?string*/ = elt.getAttribute('data-z') || elt.getAttribute('z');\n for (midx = 0; midx < merges.length; ++midx) {\n var m /*:Range*/ = merges[midx];\n if (m.s.c == C + or_C && m.s.r < R + or_R && R + or_R <= m.e.r) {\n C = m.e.c + 1 - or_C;\n midx = -1;\n }\n }\n /* TODO: figure out how to extract nonstandard mso- style */\n CS = +elt.getAttribute(\"colspan\") || 1;\n if ((RS = +elt.getAttribute(\"rowspan\") || 1) > 1 || CS > 1) merges.push({\n s: {\n r: R + or_R,\n c: C + or_C\n },\n e: {\n r: R + or_R + (RS || 1) - 1,\n c: C + or_C + (CS || 1) - 1\n }\n });\n var o /*:Cell*/ = {\n t: 's',\n v: v\n };\n var _t /*:string*/ = elt.getAttribute(\"data-t\") || elt.getAttribute(\"t\") || \"\";\n if (v != null) {\n if (v.length == 0) o.t = _t || 'z';else if (opts.raw || v.trim().length == 0 || _t == \"s\") {} else if (v === 'TRUE') o = {\n t: 'b',\n v: true\n };else if (v === 'FALSE') o = {\n t: 'b',\n v: false\n };else if (!isNaN(fuzzynum(v))) o = {\n t: 'n',\n v: fuzzynum(v)\n };else if (!isNaN(fuzzydate(v).getDate())) {\n o = {\n t: 'd',\n v: parseDate(v)\n } /*:any*/;\n if (!opts.cellDates) o = {\n t: 'n',\n v: datenum(o.v)\n } /*:any*/;\n o.z = opts.dateNF || table_fmt[14];\n }\n }\n if (o.z === undefined && z != null) o.z = z;\n /* The first link is used. Links are assumed to be fully specified.\n * TODO: The right way to process relative links is to make a new */\n var l = \"\",\n Aelts = elt.getElementsByTagName(\"A\");\n if (Aelts && Aelts.length) for (var Aelti = 0; Aelti < Aelts.length; ++Aelti) if (Aelts[Aelti].hasAttribute(\"href\")) {\n l = Aelts[Aelti].getAttribute(\"href\");\n if (l.charAt(0) != \"#\") break;\n }\n if (l && l.charAt(0) != \"#\") o.l = {\n Target: l\n };\n if (opts.dense) {\n if (!ws[R + or_R]) ws[R + or_R] = [];\n ws[R + or_R][C + or_C] = o;\n } else ws[encode_cell({\n c: C + or_C,\n r: R + or_R\n })] = o;\n if (range.e.c < C + or_C) range.e.c = C + or_C;\n C += CS;\n }\n ++R;\n }\n if (merges.length) ws['!merges'] = (ws[\"!merges\"] || []).concat(merges);\n range.e.r = Math.max(range.e.r, R - 1 + or_R);\n ws['!ref'] = encode_range(range);\n if (R >= sheetRows) ws['!fullref'] = encode_range((range.e.r = rows.length - _R + R - 1 + or_R, range)); // We can count the real number of rows to parse but we don't to improve the performance\n return ws;\n}\nfunction parse_dom_table(table /*:HTMLElement*/, _opts /*:?any*/) /*:Worksheet*/{\n var opts = _opts || {};\n var ws /*:Worksheet*/ = opts.dense ? [] /*:any*/ : {} /*:any*/;\n return sheet_add_dom(ws, table, _opts);\n}\nfunction table_to_book(table /*:HTMLElement*/, opts /*:?any*/) /*:Workbook*/{\n return sheet_to_workbook(parse_dom_table(table, opts), opts);\n}\nfunction is_dom_element_hidden(element /*:HTMLElement*/) /*:boolean*/{\n var display /*:string*/ = '';\n var get_computed_style /*:?function*/ = get_get_computed_style_function(element);\n if (get_computed_style) display = get_computed_style(element).getPropertyValue('display');\n if (!display) display = element.style && element.style.display;\n return display === 'none';\n}\n\n/* global getComputedStyle */\nfunction get_get_computed_style_function(element /*:HTMLElement*/) /*:?function*/{\n // The proper getComputedStyle implementation is the one defined in the element window\n if (element.ownerDocument.defaultView && typeof element.ownerDocument.defaultView.getComputedStyle === 'function') return element.ownerDocument.defaultView.getComputedStyle;\n // If it is not available, try to get one from the global namespace\n if (typeof getComputedStyle === 'function') return getComputedStyle;\n return null;\n}\n/* OpenDocument */\nfunction parse_text_p(text /*:string*/ /*::, tag*/) /*:Array*/{\n /* 6.1.2 White Space Characters */\n var fixed = text.replace(/[\\t\\r\\n]/g, \" \").trim().replace(/ +/g, \" \").replace(//g, \" \").replace(//g, function ($$, $1) {\n return Array(parseInt($1, 10) + 1).join(\" \");\n }).replace(/]*\\/>/g, \"\\t\").replace(//g, \"\\n\");\n var v = unescapexml(fixed.replace(/<[^>]*>/g, \"\"));\n return [v];\n}\nvar number_formats_ods = {\n /* ods name: [short ssf fmt, long ssf fmt] */\n day: [\"d\", \"dd\"],\n month: [\"m\", \"mm\"],\n year: [\"y\", \"yy\"],\n hours: [\"h\", \"hh\"],\n minutes: [\"m\", \"mm\"],\n seconds: [\"s\", \"ss\"],\n \"am-pm\": [\"A/P\", \"AM/PM\"],\n \"day-of-week\": [\"ddd\", \"dddd\"],\n era: [\"e\", \"ee\"],\n /* there is no native representation of LO \"Q\" format */\n quarter: [\"\\\\Qm\", \"m\\\\\\\"th quarter\\\"\"]\n};\nfunction parse_content_xml(d /*:string*/, _opts) /*:Workbook*/{\n var opts = _opts || {};\n if (DENSE != null && opts.dense == null) opts.dense = DENSE;\n var str = xlml_normalize(d);\n var state /*:Array*/ = [],\n tmp;\n var tag /*:: = {}*/;\n var NFtag = {\n name: \"\"\n },\n NF = \"\",\n pidx = 0;\n var sheetag /*:: = {name:\"\", '名称':\"\"}*/;\n var rowtag /*:: = {'行号':\"\"}*/;\n var Sheets = {},\n SheetNames /*:Array*/ = [];\n var ws = opts.dense ? [] /*:any*/ : {} /*:any*/;\n var Rn, q /*:: :any = ({t:\"\", v:null, z:null, w:\"\",c:[],}:any)*/;\n var ctag = {\n value: \"\"\n } /*:any*/;\n var textp = \"\",\n textpidx = 0,\n textptag /*:: = {}*/;\n var textR = [];\n var R = -1,\n C = -1,\n range = {\n s: {\n r: 1000000,\n c: 10000000\n },\n e: {\n r: 0,\n c: 0\n }\n };\n var row_ol = 0;\n var number_format_map = {};\n var merges /*:Array*/ = [],\n mrange = {},\n mR = 0,\n mC = 0;\n var rowinfo /*:Array*/ = [],\n rowpeat = 1,\n colpeat = 1;\n var arrayf /*:Array<[Range, string]>*/ = [];\n var WB = {\n Names: []\n };\n var atag = {} /*:any*/;\n var _Ref /*:[string, string]*/ = [\"\", \"\"];\n var comments /*:Array*/ = [],\n comment /*:Comment*/ = {} /*:any*/;\n var creator = \"\",\n creatoridx = 0;\n var isstub = false,\n intable = false;\n var i = 0;\n xlmlregex.lastIndex = 0;\n str = str.replace(//mg, \"\").replace(//gm, \"\");\n while (Rn = xlmlregex.exec(str)) switch (Rn[3] = Rn[3].replace(/_.*$/, \"\")) {\n case 'table':\n case '工作表':\n // 9.1.2 \n if (Rn[1] === '/') {\n if (range.e.c >= range.s.c && range.e.r >= range.s.r) ws['!ref'] = encode_range(range);else ws['!ref'] = \"A1:A1\";\n if (opts.sheetRows > 0 && opts.sheetRows <= range.e.r) {\n ws['!fullref'] = ws['!ref'];\n range.e.r = opts.sheetRows - 1;\n ws['!ref'] = encode_range(range);\n }\n if (merges.length) ws['!merges'] = merges;\n if (rowinfo.length) ws[\"!rows\"] = rowinfo;\n sheetag.name = sheetag['名称'] || sheetag.name;\n if (typeof JSON !== 'undefined') JSON.stringify(sheetag);\n SheetNames.push(sheetag.name);\n Sheets[sheetag.name] = ws;\n intable = false;\n } else if (Rn[0].charAt(Rn[0].length - 2) !== '/') {\n sheetag = parsexmltag(Rn[0], false);\n R = C = -1;\n range.s.r = range.s.c = 10000000;\n range.e.r = range.e.c = 0;\n ws = opts.dense ? [] /*:any*/ : {} /*:any*/;\n merges = [];\n rowinfo = [];\n intable = true;\n }\n break;\n case 'table-row-group':\n // 9.1.9 \n if (Rn[1] === \"/\") --row_ol;else ++row_ol;\n break;\n case 'table-row':\n case '行':\n // 9.1.3 \n if (Rn[1] === '/') {\n R += rowpeat;\n rowpeat = 1;\n break;\n }\n rowtag = parsexmltag(Rn[0], false);\n if (rowtag['行号']) R = rowtag['行号'] - 1;else if (R == -1) R = 0;\n rowpeat = +rowtag['number-rows-repeated'] || 1;\n /* TODO: remove magic */\n if (rowpeat < 10) for (i = 0; i < rowpeat; ++i) if (row_ol > 0) rowinfo[R + i] = {\n level: row_ol\n };\n C = -1;\n break;\n case 'covered-table-cell':\n // 9.1.5 \n if (Rn[1] !== '/') ++C;\n if (opts.sheetStubs) {\n if (opts.dense) {\n if (!ws[R]) ws[R] = [];\n ws[R][C] = {\n t: 'z'\n };\n } else ws[encode_cell({\n r: R,\n c: C\n })] = {\n t: 'z'\n };\n }\n textp = \"\";\n textR = [];\n break;\n /* stub */\n case 'table-cell':\n case '数据':\n if (Rn[0].charAt(Rn[0].length - 2) === '/') {\n ++C;\n ctag = parsexmltag(Rn[0], false);\n colpeat = parseInt(ctag['number-columns-repeated'] || \"1\", 10);\n q = {\n t: 'z',\n v: null /*:: , z:null, w:\"\",c:[]*/\n } /*:any*/;\n if (ctag.formula && opts.cellFormula != false) q.f = ods_to_csf_formula(unescapexml(ctag.formula));\n if ((ctag['数据类型'] || ctag['value-type']) == \"string\") {\n q.t = \"s\";\n q.v = unescapexml(ctag['string-value'] || \"\");\n if (opts.dense) {\n if (!ws[R]) ws[R] = [];\n ws[R][C] = q;\n } else {\n ws[encode_cell({\n r: R,\n c: C\n })] = q;\n }\n }\n C += colpeat - 1;\n } else if (Rn[1] !== '/') {\n ++C;\n textp = \"\";\n textpidx = 0;\n textR = [];\n colpeat = 1;\n var rptR = rowpeat ? R + rowpeat - 1 : R;\n if (C > range.e.c) range.e.c = C;\n if (C < range.s.c) range.s.c = C;\n if (R < range.s.r) range.s.r = R;\n if (rptR > range.e.r) range.e.r = rptR;\n ctag = parsexmltag(Rn[0], false);\n comments = [];\n comment = {} /*:any*/;\n q = {\n t: ctag['数据类型'] || ctag['value-type'],\n v: null /*:: , z:null, w:\"\",c:[]*/\n } /*:any*/;\n if (opts.cellFormula) {\n if (ctag.formula) ctag.formula = unescapexml(ctag.formula);\n if (ctag['number-matrix-columns-spanned'] && ctag['number-matrix-rows-spanned']) {\n mR = parseInt(ctag['number-matrix-rows-spanned'], 10) || 0;\n mC = parseInt(ctag['number-matrix-columns-spanned'], 10) || 0;\n mrange = {\n s: {\n r: R,\n c: C\n },\n e: {\n r: R + mR - 1,\n c: C + mC - 1\n }\n };\n q.F = encode_range(mrange);\n arrayf.push([mrange, q.F]);\n }\n if (ctag.formula) q.f = ods_to_csf_formula(ctag.formula);else for (i = 0; i < arrayf.length; ++i) if (R >= arrayf[i][0].s.r && R <= arrayf[i][0].e.r) if (C >= arrayf[i][0].s.c && C <= arrayf[i][0].e.c) q.F = arrayf[i][1];\n }\n if (ctag['number-columns-spanned'] || ctag['number-rows-spanned']) {\n mR = parseInt(ctag['number-rows-spanned'], 10) || 0;\n mC = parseInt(ctag['number-columns-spanned'], 10) || 0;\n mrange = {\n s: {\n r: R,\n c: C\n },\n e: {\n r: R + mR - 1,\n c: C + mC - 1\n }\n };\n merges.push(mrange);\n }\n\n /* 19.675.2 table:number-columns-repeated */\n if (ctag['number-columns-repeated']) colpeat = parseInt(ctag['number-columns-repeated'], 10);\n\n /* 19.385 office:value-type */\n switch (q.t) {\n case 'boolean':\n q.t = 'b';\n q.v = parsexmlbool(ctag['boolean-value']);\n break;\n case 'float':\n q.t = 'n';\n q.v = parseFloat(ctag.value);\n break;\n case 'percentage':\n q.t = 'n';\n q.v = parseFloat(ctag.value);\n break;\n case 'currency':\n q.t = 'n';\n q.v = parseFloat(ctag.value);\n break;\n case 'date':\n q.t = 'd';\n q.v = parseDate(ctag['date-value']);\n if (!opts.cellDates) {\n q.t = 'n';\n q.v = datenum(q.v);\n }\n q.z = 'm/d/yy';\n break;\n case 'time':\n q.t = 'n';\n q.v = parse_isodur(ctag['time-value']) / 86400;\n if (opts.cellDates) {\n q.t = 'd';\n q.v = numdate(q.v);\n }\n q.z = 'HH:MM:SS';\n break;\n case 'number':\n q.t = 'n';\n q.v = parseFloat(ctag['数据数值']);\n break;\n default:\n if (q.t === 'string' || q.t === 'text' || !q.t) {\n q.t = 's';\n if (ctag['string-value'] != null) {\n textp = unescapexml(ctag['string-value']);\n textR = [];\n }\n } else throw new Error('Unsupported value type ' + q.t);\n }\n } else {\n isstub = false;\n if (q.t === 's') {\n q.v = textp || '';\n if (textR.length) q.R = textR;\n isstub = textpidx == 0;\n }\n if (atag.Target) q.l = atag;\n if (comments.length > 0) {\n q.c = comments;\n comments = [];\n }\n if (textp && opts.cellText !== false) q.w = textp;\n if (isstub) {\n q.t = \"z\";\n delete q.v;\n }\n if (!isstub || opts.sheetStubs) {\n if (!(opts.sheetRows && opts.sheetRows <= R)) {\n for (var rpt = 0; rpt < rowpeat; ++rpt) {\n colpeat = parseInt(ctag['number-columns-repeated'] || \"1\", 10);\n if (opts.dense) {\n if (!ws[R + rpt]) ws[R + rpt] = [];\n ws[R + rpt][C] = rpt == 0 ? q : dup(q);\n while (--colpeat > 0) ws[R + rpt][C + colpeat] = dup(q);\n } else {\n ws[encode_cell({\n r: R + rpt,\n c: C\n })] = q;\n while (--colpeat > 0) ws[encode_cell({\n r: R + rpt,\n c: C + colpeat\n })] = dup(q);\n }\n if (range.e.c <= C) range.e.c = C;\n }\n }\n }\n colpeat = parseInt(ctag['number-columns-repeated'] || \"1\", 10);\n C += colpeat - 1;\n colpeat = 0;\n q = {/*:: t:\"\", v:null, z:null, w:\"\",c:[]*/};\n textp = \"\";\n textR = [];\n }\n atag = {} /*:any*/;\n break;\n // 9.1.4 \n\n /* pure state */\n case 'document': // TODO: is the root for FODS\n case 'document-content':\n case '电子表格文档': // 3.1.3.2 \n case 'spreadsheet':\n case '主体': // 3.7 \n case 'scripts': // 3.12 \n case 'styles': // TODO \n case 'font-face-decls': // 3.14 \n case 'master-styles':\n // 3.15.4 -- relevant for FODS\n if (Rn[1] === '/') {\n if ((tmp = state.pop())[0] !== Rn[3]) throw \"Bad state: \" + tmp;\n } else if (Rn[0].charAt(Rn[0].length - 2) !== '/') state.push([Rn[3], true]);\n break;\n case 'annotation':\n // 14.1 \n if (Rn[1] === '/') {\n if ((tmp = state.pop())[0] !== Rn[3]) throw \"Bad state: \" + tmp;\n comment.t = textp;\n if (textR.length) /*::(*/comment /*:: :any)*/.R = textR;\n comment.a = creator;\n comments.push(comment);\n } else if (Rn[0].charAt(Rn[0].length - 2) !== '/') {\n state.push([Rn[3], false]);\n }\n creator = \"\";\n creatoridx = 0;\n textp = \"\";\n textpidx = 0;\n textR = [];\n break;\n case 'creator':\n // 4.3.2.7 \n if (Rn[1] === '/') {\n creator = str.slice(creatoridx, Rn.index);\n } else creatoridx = Rn.index + Rn[0].length;\n break;\n\n /* ignore state */\n case 'meta':\n case '元数据': // TODO: FODS/UOF\n case 'settings': // TODO: \n case 'config-item-set': // TODO: \n case 'config-item-map-indexed': // TODO: \n case 'config-item-map-entry': // TODO: \n case 'config-item-map-named': // TODO: \n case 'shapes': // 9.2.8 \n case 'frame': // 10.4.2 \n case 'text-box': // 10.4.3 \n case 'image': // 10.4.4 \n case 'data-pilot-tables': // 9.6.2 \n case 'list-style': // 16.30 \n case 'form': // 13.13 \n case 'dde-links': // 9.8 \n case 'event-listeners': // TODO\n case 'chart':\n // TODO\n if (Rn[1] === '/') {\n if ((tmp = state.pop())[0] !== Rn[3]) throw \"Bad state: \" + tmp;\n } else if (Rn[0].charAt(Rn[0].length - 2) !== '/') state.push([Rn[3], false]);\n textp = \"\";\n textpidx = 0;\n textR = [];\n break;\n case 'scientific-number':\n // TODO: \n break;\n case 'currency-symbol':\n // TODO: \n break;\n case 'currency-style':\n // TODO: \n break;\n case 'number-style': // 16.27.2 \n case 'percentage-style': // 16.27.9 \n case 'date-style': // 16.27.10 \n case 'time-style':\n // 16.27.18 \n if (Rn[1] === '/') {\n number_format_map[NFtag.name] = NF;\n if ((tmp = state.pop())[0] !== Rn[3]) throw \"Bad state: \" + tmp;\n } else if (Rn[0].charAt(Rn[0].length - 2) !== '/') {\n NF = \"\";\n NFtag = parsexmltag(Rn[0], false);\n state.push([Rn[3], true]);\n }\n break;\n case 'script':\n break;\n // 3.13 \n case 'libraries':\n break;\n // TODO: \n case 'automatic-styles':\n break;\n // 3.15.3 \n\n case 'default-style': // TODO: \n case 'page-layout':\n break;\n // TODO: \n case 'style':\n // 16.2 \n break;\n case 'map':\n break;\n // 16.3 \n case 'font-face':\n break;\n // 16.21 \n\n case 'paragraph-properties':\n break;\n // 17.6 \n case 'table-properties':\n break;\n // 17.15 \n case 'table-column-properties':\n break;\n // 17.16 \n case 'table-row-properties':\n break;\n // 17.17 \n case 'table-cell-properties':\n break;\n // 17.18 \n\n case 'number':\n // 16.27.3 \n switch (state[state.length - 1][0]) {\n case 'time-style':\n case 'date-style':\n tag = parsexmltag(Rn[0], false);\n NF += number_formats_ods[Rn[3]][tag.style === 'long' ? 1 : 0];\n break;\n }\n break;\n case 'fraction':\n break;\n // TODO 16.27.6 \n\n case 'day': // 16.27.11 \n case 'month': // 16.27.12 \n case 'year': // 16.27.13 \n case 'era': // 16.27.14 \n case 'day-of-week': // 16.27.15 \n case 'week-of-year': // 16.27.16 \n case 'quarter': // 16.27.17 \n case 'hours': // 16.27.19 \n case 'minutes': // 16.27.20 \n case 'seconds': // 16.27.21 \n case 'am-pm':\n // 16.27.22 \n switch (state[state.length - 1][0]) {\n case 'time-style':\n case 'date-style':\n tag = parsexmltag(Rn[0], false);\n NF += number_formats_ods[Rn[3]][tag.style === 'long' ? 1 : 0];\n break;\n }\n break;\n case 'boolean-style':\n break;\n // 16.27.23 \n case 'boolean':\n break;\n // 16.27.24 \n case 'text-style':\n break;\n // 16.27.25 \n case 'text':\n // 16.27.26 \n if (Rn[0].slice(-2) === \"/>\") break;else if (Rn[1] === \"/\") switch (state[state.length - 1][0]) {\n case 'number-style':\n case 'date-style':\n case 'time-style':\n NF += str.slice(pidx, Rn.index);\n break;\n } else pidx = Rn.index + Rn[0].length;\n break;\n case 'named-range':\n // 9.4.12 \n tag = parsexmltag(Rn[0], false);\n _Ref = ods_to_csf_3D(tag['cell-range-address']);\n var nrange = {\n Name: tag.name,\n Ref: _Ref[0] + '!' + _Ref[1]\n } /*:any*/;\n if (intable) nrange.Sheet = SheetNames.length;\n WB.Names.push(nrange);\n break;\n case 'text-content':\n break;\n // 16.27.27 \n case 'text-properties':\n break;\n // 16.27.27 \n case 'embedded-text':\n break;\n // 16.27.4 \n\n case 'body':\n case '电子表格':\n break;\n // 3.3 16.9.6 19.726.3\n\n case 'forms':\n break;\n // 12.25.2 13.2\n case 'table-column':\n break;\n // 9.1.6 \n case 'table-header-rows':\n break;\n // 9.1.7 \n case 'table-rows':\n break;\n // 9.1.12 \n /* TODO: outline levels */\n case 'table-column-group':\n break;\n // 9.1.10 \n case 'table-header-columns':\n break;\n // 9.1.11 \n case 'table-columns':\n break;\n // 9.1.12 \n\n case 'null-date':\n break;\n // 9.4.2 TODO: date1904\n\n case 'graphic-properties':\n break;\n // 17.21 \n case 'calculation-settings':\n break;\n // 9.4.1 \n case 'named-expressions':\n break;\n // 9.4.11 \n case 'label-range':\n break;\n // 9.4.9 \n case 'label-ranges':\n break;\n // 9.4.10 \n case 'named-expression':\n break;\n // 9.4.13 \n case 'sort':\n break;\n // 9.4.19 \n case 'sort-by':\n break;\n // 9.4.20 \n case 'sort-groups':\n break;\n // 9.4.22 \n\n case 'tab':\n break;\n // 6.1.4 \n case 'line-break':\n break;\n // 6.1.5 \n case 'span':\n break;\n // 6.1.7 \n case 'p':\n case '文本串':\n // 5.1.3 \n if (['master-styles'].indexOf(state[state.length - 1][0]) > -1) break;\n if (Rn[1] === '/' && (!ctag || !ctag['string-value'])) {\n var ptp = parse_text_p(str.slice(textpidx, Rn.index), textptag);\n textp = (textp.length > 0 ? textp + \"\\n\" : \"\") + ptp[0];\n } else {\n textptag = parsexmltag(Rn[0], false);\n textpidx = Rn.index + Rn[0].length;\n }\n break;\n // \n case 's':\n break;\n // \n\n case 'database-range':\n // 9.4.15 \n if (Rn[1] === '/') break;\n try {\n _Ref = ods_to_csf_3D(parsexmltag(Rn[0])['target-range-address']);\n Sheets[_Ref[0]]['!autofilter'] = {\n ref: _Ref[1]\n };\n } catch (e) {/* empty */}\n break;\n case 'date':\n break;\n // <*:date>\n\n case 'object':\n break;\n // 10.4.6.2 \n case 'title':\n case '标题':\n break;\n // <*:title> OR \n case 'desc':\n break;\n // <*:desc>\n case 'binary-data':\n break;\n // 10.4.5 TODO: b64 blob\n\n /* 9.2 Advanced Tables */\n case 'table-source':\n break;\n // 9.2.6\n case 'scenario':\n break;\n // 9.2.6\n\n case 'iteration':\n break;\n // 9.4.3 \n case 'content-validations':\n break;\n // 9.4.4 \n case 'filter':\n break;\n // 9.5.2 \n case 'filter-and':\n break;\n // 9.5.3 \n case 'filter-or':\n break;\n // 9.5.4 \n case 'filter-condition':\n break;\n // 9.5.5 \n\n case 'list-level-style-bullet':\n break;\n // 16.31 \n case 'page-count':\n break;\n // TODO \n case 'time':\n break;\n // TODO \n\n /* 9.3 Advanced Table Cells */\n case 'cell-range-source':\n break;\n // 9.3.1 \n case 'property':\n break;\n // 13.8 \n\n case 'a':\n // 6.1.8 hyperlink\n if (Rn[1] !== '/') {\n atag = parsexmltag(Rn[0], false);\n if (!atag.href) break;\n atag.Target = unescapexml(atag.href);\n delete atag.href;\n if (atag.Target.charAt(0) == \"#\" && atag.Target.indexOf(\".\") > -1) {\n _Ref = ods_to_csf_3D(atag.Target.slice(1));\n atag.Target = \"#\" + _Ref[0] + \"!\" + _Ref[1];\n } else if (atag.Target.match(/^\\.\\.[\\\\\\/]/)) atag.Target = atag.Target.slice(3);\n }\n break;\n\n /* non-standard */\n case 'table-protection':\n break;\n case 'data-pilot-grand-total':\n break;\n // ', '', '', '', '', '', '', ''].join(\"\");\n var payload = '' + master_styles + '';\n return function wso(/*::wb, opts*/\n ) {\n return XML_HEADER + payload;\n };\n}();\nvar write_content_ods /*:{(wb:any, opts:any):string}*/ = /* @__PURE__ */function () {\n /* 6.1.2 White Space Characters */\n var write_text_p = function (text /*:string*/) /*:string*/{\n return escapexml(text).replace(/ +/g, function ($$) {\n return '';\n }).replace(/\\t/g, \"\").replace(/\\n/g, \"\").replace(/^ /, \"\").replace(/ $/, \"\");\n };\n var null_cell_xml = ' \\n';\n var covered_cell_xml = ' \\n';\n var write_ws = function (ws, wb /*:Workbook*/, i /*:number*/ /*::, opts*/) /*:string*/{\n /* Section 9 Tables */\n var o /*:Array*/ = [];\n o.push(' \\n');\n var R = 0,\n C = 0,\n range = decode_range(ws['!ref'] || \"A1\");\n var marr /*:Array*/ = ws['!merges'] || [],\n mi = 0;\n var dense = Array.isArray(ws);\n if (ws[\"!cols\"]) {\n for (C = 0; C <= range.e.c; ++C) o.push(' \\n');\n }\n var H = \"\",\n ROWS = ws[\"!rows\"] || [];\n for (R = 0; R < range.s.r; ++R) {\n H = ROWS[R] ? ' table:style-name=\"ro' + ROWS[R].ods + '\"' : \"\";\n o.push(' \\n');\n }\n for (; R <= range.e.r; ++R) {\n H = ROWS[R] ? ' table:style-name=\"ro' + ROWS[R].ods + '\"' : \"\";\n o.push(' \\n');\n for (C = 0; C < range.s.c; ++C) o.push(null_cell_xml);\n for (; C <= range.e.c; ++C) {\n var skip = false,\n ct = {},\n textp = \"\";\n for (mi = 0; mi != marr.length; ++mi) {\n if (marr[mi].s.c > C) continue;\n if (marr[mi].s.r > R) continue;\n if (marr[mi].e.c < C) continue;\n if (marr[mi].e.r < R) continue;\n if (marr[mi].s.c != C || marr[mi].s.r != R) skip = true;\n ct['table:number-columns-spanned'] = marr[mi].e.c - marr[mi].s.c + 1;\n ct['table:number-rows-spanned'] = marr[mi].e.r - marr[mi].s.r + 1;\n break;\n }\n if (skip) {\n o.push(covered_cell_xml);\n continue;\n }\n var ref = encode_cell({\n r: R,\n c: C\n }),\n cell = dense ? (ws[R] || [])[C] : ws[ref];\n if (cell && cell.f) {\n ct['table:formula'] = escapexml(csf_to_ods_formula(cell.f));\n if (cell.F) {\n if (cell.F.slice(0, ref.length) == ref) {\n var _Fref = decode_range(cell.F);\n ct['table:number-matrix-columns-spanned'] = _Fref.e.c - _Fref.s.c + 1;\n ct['table:number-matrix-rows-spanned'] = _Fref.e.r - _Fref.s.r + 1;\n }\n }\n }\n if (!cell) {\n o.push(null_cell_xml);\n continue;\n }\n switch (cell.t) {\n case 'b':\n textp = cell.v ? 'TRUE' : 'FALSE';\n ct['office:value-type'] = \"boolean\";\n ct['office:boolean-value'] = cell.v ? 'true' : 'false';\n break;\n case 'n':\n textp = cell.w || String(cell.v || 0);\n ct['office:value-type'] = \"float\";\n ct['office:value'] = cell.v || 0;\n break;\n case 's':\n case 'str':\n textp = cell.v == null ? \"\" : cell.v;\n ct['office:value-type'] = \"string\";\n break;\n case 'd':\n textp = cell.w || parseDate(cell.v).toISOString();\n ct['office:value-type'] = \"date\";\n ct['office:date-value'] = parseDate(cell.v).toISOString();\n ct['table:style-name'] = \"ce1\";\n break;\n //case 'e':\n default:\n o.push(null_cell_xml);\n continue;\n }\n var text_p = write_text_p(textp);\n if (cell.l && cell.l.Target) {\n var _tgt = cell.l.Target;\n _tgt = _tgt.charAt(0) == \"#\" ? \"#\" + csf_to_ods_3D(_tgt.slice(1)) : _tgt;\n // TODO: choose correct parent path format based on link delimiters\n if (_tgt.charAt(0) != \"#\" && !_tgt.match(/^\\w+:/)) _tgt = '../' + _tgt;\n text_p = writextag('text:a', text_p, {\n 'xlink:href': _tgt.replace(/&/g, \"&\")\n });\n }\n o.push(' ' + writextag('table:table-cell', writextag('text:p', text_p, {}), ct) + '\\n');\n }\n o.push(' \\n');\n }\n o.push(' \\n');\n return o.join(\"\");\n };\n var write_automatic_styles_ods = function (o /*:Array*/, wb) {\n o.push(' \\n');\n o.push(' \\n');\n o.push(' \\n');\n o.push(' /\\n');\n o.push(' \\n');\n o.push(' /\\n');\n o.push(' \\n');\n o.push(' \\n');\n\n /* column styles */\n var cidx = 0;\n wb.SheetNames.map(function (n) {\n return wb.Sheets[n];\n }).forEach(function (ws) {\n if (!ws) return;\n if (ws[\"!cols\"]) {\n for (var C = 0; C < ws[\"!cols\"].length; ++C) if (ws[\"!cols\"][C]) {\n var colobj = ws[\"!cols\"][C];\n if (colobj.width == null && colobj.wpx == null && colobj.wch == null) continue;\n process_col(colobj);\n colobj.ods = cidx;\n var w = ws[\"!cols\"][C].wpx + \"px\";\n o.push(' \\n');\n o.push(' \\n');\n o.push(' \\n');\n ++cidx;\n }\n }\n });\n\n /* row styles */\n var ridx = 0;\n wb.SheetNames.map(function (n) {\n return wb.Sheets[n];\n }).forEach(function (ws) {\n if (!ws) return;\n if (ws[\"!rows\"]) {\n for (var R = 0; R < ws[\"!rows\"].length; ++R) if (ws[\"!rows\"][R]) {\n ws[\"!rows\"][R].ods = ridx;\n var h = ws[\"!rows\"][R].hpx + \"px\";\n o.push(' \\n');\n o.push(' \\n');\n o.push(' \\n');\n ++ridx;\n }\n }\n });\n\n /* table */\n o.push(' \\n');\n o.push(' \\n');\n o.push(' \\n');\n\n /* table cells, text */\n o.push(' \\n');\n\n /* page-layout */\n\n o.push(' \\n');\n };\n return function wcx(wb, opts) {\n var o = [XML_HEADER];\n /* 3.1.3.2 */\n var attr = wxt_helper({\n 'xmlns:office': \"urn:oasis:names:tc:opendocument:xmlns:office:1.0\",\n 'xmlns:table': \"urn:oasis:names:tc:opendocument:xmlns:table:1.0\",\n 'xmlns:style': \"urn:oasis:names:tc:opendocument:xmlns:style:1.0\",\n 'xmlns:text': \"urn:oasis:names:tc:opendocument:xmlns:text:1.0\",\n 'xmlns:draw': \"urn:oasis:names:tc:opendocument:xmlns:drawing:1.0\",\n 'xmlns:fo': \"urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0\",\n 'xmlns:xlink': \"http://www.w3.org/1999/xlink\",\n 'xmlns:dc': \"http://purl.org/dc/elements/1.1/\",\n 'xmlns:meta': \"urn:oasis:names:tc:opendocument:xmlns:meta:1.0\",\n 'xmlns:number': \"urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0\",\n 'xmlns:presentation': \"urn:oasis:names:tc:opendocument:xmlns:presentation:1.0\",\n 'xmlns:svg': \"urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0\",\n 'xmlns:chart': \"urn:oasis:names:tc:opendocument:xmlns:chart:1.0\",\n 'xmlns:dr3d': \"urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0\",\n 'xmlns:math': \"http://www.w3.org/1998/Math/MathML\",\n 'xmlns:form': \"urn:oasis:names:tc:opendocument:xmlns:form:1.0\",\n 'xmlns:script': \"urn:oasis:names:tc:opendocument:xmlns:script:1.0\",\n 'xmlns:ooo': \"http://openoffice.org/2004/office\",\n 'xmlns:ooow': \"http://openoffice.org/2004/writer\",\n 'xmlns:oooc': \"http://openoffice.org/2004/calc\",\n 'xmlns:dom': \"http://www.w3.org/2001/xml-events\",\n 'xmlns:xforms': \"http://www.w3.org/2002/xforms\",\n 'xmlns:xsd': \"http://www.w3.org/2001/XMLSchema\",\n 'xmlns:xsi': \"http://www.w3.org/2001/XMLSchema-instance\",\n 'xmlns:sheet': \"urn:oasis:names:tc:opendocument:sh33tjs:1.0\",\n 'xmlns:rpt': \"http://openoffice.org/2005/report\",\n 'xmlns:of': \"urn:oasis:names:tc:opendocument:xmlns:of:1.2\",\n 'xmlns:xhtml': \"http://www.w3.org/1999/xhtml\",\n 'xmlns:grddl': \"http://www.w3.org/2003/g/data-view#\",\n 'xmlns:tableooo': \"http://openoffice.org/2009/table\",\n 'xmlns:drawooo': \"http://openoffice.org/2010/draw\",\n 'xmlns:calcext': \"urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0\",\n 'xmlns:loext': \"urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0\",\n 'xmlns:field': \"urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0\",\n 'xmlns:formx': \"urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0\",\n 'xmlns:css3t': \"http://www.w3.org/TR/css3-text/\",\n 'office:version': \"1.2\"\n });\n var fods = wxt_helper({\n 'xmlns:config': \"urn:oasis:names:tc:opendocument:xmlns:config:1.0\",\n 'office:mimetype': \"application/vnd.oasis.opendocument.spreadsheet\"\n });\n if (opts.bookType == \"fods\") {\n o.push('\\n');\n o.push(write_meta_ods().replace(/office:document-meta/g, \"office:meta\"));\n // TODO: settings (equiv of settings.xml for ODS)\n } else o.push('\\n');\n // o.push(' \\n');\n write_automatic_styles_ods(o, wb);\n o.push(' \\n');\n o.push(' \\n');\n for (var i = 0; i != wb.SheetNames.length; ++i) o.push(write_ws(wb.Sheets[wb.SheetNames[i]], wb, i, opts));\n o.push(' \\n');\n o.push(' \\n');\n if (opts.bookType == \"fods\") o.push('');else o.push('');\n return o.join(\"\");\n };\n}();\nfunction write_ods(wb /*:any*/, opts /*:any*/) {\n if (opts.bookType == \"fods\") return write_content_ods(wb, opts);\n var zip = zip_new();\n var f = \"\";\n var manifest /*:Array >*/ = [];\n var rdf /*:Array<[string, string]>*/ = [];\n\n /* Part 3 Section 3.3 MIME Media Type */\n f = \"mimetype\";\n zip_add_file(zip, f, \"application/vnd.oasis.opendocument.spreadsheet\");\n\n /* Part 1 Section 2.2 Documents */\n f = \"content.xml\";\n zip_add_file(zip, f, write_content_ods(wb, opts));\n manifest.push([f, \"text/xml\"]);\n rdf.push([f, \"ContentFile\"]);\n\n /* TODO: these are hard-coded styles to satiate excel */\n f = \"styles.xml\";\n zip_add_file(zip, f, write_styles_ods(wb, opts));\n manifest.push([f, \"text/xml\"]);\n rdf.push([f, \"StylesFile\"]);\n\n /* TODO: this is hard-coded to satiate excel */\n f = \"meta.xml\";\n zip_add_file(zip, f, XML_HEADER + write_meta_ods(/*::wb, opts*/));\n manifest.push([f, \"text/xml\"]);\n rdf.push([f, \"MetadataFile\"]);\n\n /* Part 3 Section 6 Metadata Manifest File */\n f = \"manifest.rdf\";\n zip_add_file(zip, f, write_rdf(rdf /*, opts*/));\n manifest.push([f, \"application/rdf+xml\"]);\n\n /* Part 3 Section 4 Manifest File */\n f = \"META-INF/manifest.xml\";\n zip_add_file(zip, f, write_manifest(manifest /*, opts*/));\n return zip;\n}\n\n/*! sheetjs (C) 2013-present SheetJS -- http://sheetjs.com */\nfunction u8_to_dataview(array) {\n return new DataView(array.buffer, array.byteOffset, array.byteLength);\n}\nfunction u8str(u8) {\n return typeof TextDecoder != \"undefined\" ? new TextDecoder().decode(u8) : utf8read(a2s(u8));\n}\nfunction stru8(str) {\n return typeof TextEncoder != \"undefined\" ? new TextEncoder().encode(str) : s2a(utf8write(str));\n}\nfunction u8contains(body, search) {\n outer: for (var L = 0; L <= body.length - search.length; ++L) {\n for (var j = 0; j < search.length; ++j) if (body[L + j] != search[j]) continue outer;\n return true;\n }\n return false;\n}\nfunction u8concat(u8a) {\n var len = u8a.reduce(function (acc, x) {\n return acc + x.length;\n }, 0);\n var out = new Uint8Array(len);\n var off = 0;\n u8a.forEach(function (u8) {\n out.set(u8, off);\n off += u8.length;\n });\n return out;\n}\nfunction popcnt(x) {\n x -= x >> 1 & 1431655765;\n x = (x & 858993459) + (x >> 2 & 858993459);\n return (x + (x >> 4) & 252645135) * 16843009 >>> 24;\n}\nfunction readDecimal128LE(buf, offset) {\n var exp = (buf[offset + 15] & 127) << 7 | buf[offset + 14] >> 1;\n var mantissa = buf[offset + 14] & 1;\n for (var j = offset + 13; j >= offset; --j) mantissa = mantissa * 256 + buf[j];\n return (buf[offset + 15] & 128 ? -mantissa : mantissa) * Math.pow(10, exp - 6176);\n}\nfunction writeDecimal128LE(buf, offset, value) {\n var exp = Math.floor(value == 0 ? 0 : Math.LOG10E * Math.log(Math.abs(value))) + 6176 - 20;\n var mantissa = value / Math.pow(10, exp - 6176);\n buf[offset + 15] |= exp >> 7;\n buf[offset + 14] |= (exp & 127) << 1;\n for (var i = 0; mantissa >= 1; ++i, mantissa /= 256) buf[offset + i] = mantissa & 255;\n buf[offset + 15] |= value >= 0 ? 0 : 128;\n}\nfunction parse_varint49(buf, ptr) {\n var l = ptr ? ptr[0] : 0;\n var usz = buf[l] & 127;\n varint: if (buf[l++] >= 128) {\n usz |= (buf[l] & 127) << 7;\n if (buf[l++] < 128) break varint;\n usz |= (buf[l] & 127) << 14;\n if (buf[l++] < 128) break varint;\n usz |= (buf[l] & 127) << 21;\n if (buf[l++] < 128) break varint;\n usz += (buf[l] & 127) * Math.pow(2, 28);\n ++l;\n if (buf[l++] < 128) break varint;\n usz += (buf[l] & 127) * Math.pow(2, 35);\n ++l;\n if (buf[l++] < 128) break varint;\n usz += (buf[l] & 127) * Math.pow(2, 42);\n ++l;\n if (buf[l++] < 128) break varint;\n }\n if (ptr) ptr[0] = l;\n return usz;\n}\nfunction write_varint49(v) {\n var usz = new Uint8Array(7);\n usz[0] = v & 127;\n var L = 1;\n sz: if (v > 127) {\n usz[L - 1] |= 128;\n usz[L] = v >> 7 & 127;\n ++L;\n if (v <= 16383) break sz;\n usz[L - 1] |= 128;\n usz[L] = v >> 14 & 127;\n ++L;\n if (v <= 2097151) break sz;\n usz[L - 1] |= 128;\n usz[L] = v >> 21 & 127;\n ++L;\n if (v <= 268435455) break sz;\n usz[L - 1] |= 128;\n usz[L] = v / 256 >>> 21 & 127;\n ++L;\n if (v <= 34359738367) break sz;\n usz[L - 1] |= 128;\n usz[L] = v / 65536 >>> 21 & 127;\n ++L;\n if (v <= 4398046511103) break sz;\n usz[L - 1] |= 128;\n usz[L] = v / 16777216 >>> 21 & 127;\n ++L;\n }\n return usz.slice(0, L);\n}\nfunction varint_to_i32(buf) {\n var l = 0,\n i32 = buf[l] & 127;\n varint: if (buf[l++] >= 128) {\n i32 |= (buf[l] & 127) << 7;\n if (buf[l++] < 128) break varint;\n i32 |= (buf[l] & 127) << 14;\n if (buf[l++] < 128) break varint;\n i32 |= (buf[l] & 127) << 21;\n if (buf[l++] < 128) break varint;\n i32 |= (buf[l] & 127) << 28;\n }\n return i32;\n}\nfunction parse_shallow(buf) {\n var out = [],\n ptr = [0];\n while (ptr[0] < buf.length) {\n var off = ptr[0];\n var num = parse_varint49(buf, ptr);\n var type = num & 7;\n num = Math.floor(num / 8);\n var len = 0;\n var res;\n if (num == 0) break;\n switch (type) {\n case 0:\n {\n var l = ptr[0];\n while (buf[ptr[0]++] >= 128);\n res = buf.slice(l, ptr[0]);\n }\n break;\n case 5:\n len = 4;\n res = buf.slice(ptr[0], ptr[0] + len);\n ptr[0] += len;\n break;\n case 1:\n len = 8;\n res = buf.slice(ptr[0], ptr[0] + len);\n ptr[0] += len;\n break;\n case 2:\n len = parse_varint49(buf, ptr);\n res = buf.slice(ptr[0], ptr[0] + len);\n ptr[0] += len;\n break;\n case 3:\n case 4:\n default:\n throw new Error(\"PB Type \".concat(type, \" for Field \").concat(num, \" at offset \").concat(off));\n }\n var v = {\n data: res,\n type: type\n };\n if (out[num] == null) out[num] = [v];else out[num].push(v);\n }\n return out;\n}\nfunction write_shallow(proto) {\n var out = [];\n proto.forEach(function (field, idx) {\n field.forEach(function (item) {\n if (!item.data) return;\n out.push(write_varint49(idx * 8 + item.type));\n if (item.type == 2) out.push(write_varint49(item.data.length));\n out.push(item.data);\n });\n });\n return u8concat(out);\n}\nfunction mappa(data, cb) {\n return (data == null ? void 0 : data.map(function (d) {\n return cb(d.data);\n })) || [];\n}\nfunction parse_iwa_file(buf) {\n var _a;\n var out = [],\n ptr = [0];\n while (ptr[0] < buf.length) {\n var len = parse_varint49(buf, ptr);\n var ai = parse_shallow(buf.slice(ptr[0], ptr[0] + len));\n ptr[0] += len;\n var res = {\n id: varint_to_i32(ai[1][0].data),\n messages: []\n };\n ai[2].forEach(function (b) {\n var mi = parse_shallow(b.data);\n var fl = varint_to_i32(mi[3][0].data);\n res.messages.push({\n meta: mi,\n data: buf.slice(ptr[0], ptr[0] + fl)\n });\n ptr[0] += fl;\n });\n if ((_a = ai[3]) == null ? void 0 : _a[0]) res.merge = varint_to_i32(ai[3][0].data) >>> 0 > 0;\n out.push(res);\n }\n return out;\n}\nfunction write_iwa_file(ias) {\n var bufs = [];\n ias.forEach(function (ia) {\n var ai = [];\n ai[1] = [{\n data: write_varint49(ia.id),\n type: 0\n }];\n ai[2] = [];\n if (ia.merge != null) ai[3] = [{\n data: write_varint49(+!!ia.merge),\n type: 0\n }];\n var midata = [];\n ia.messages.forEach(function (mi) {\n midata.push(mi.data);\n mi.meta[3] = [{\n type: 0,\n data: write_varint49(mi.data.length)\n }];\n ai[2].push({\n data: write_shallow(mi.meta),\n type: 2\n });\n });\n var aipayload = write_shallow(ai);\n bufs.push(write_varint49(aipayload.length));\n bufs.push(aipayload);\n midata.forEach(function (mid) {\n return bufs.push(mid);\n });\n });\n return u8concat(bufs);\n}\nfunction parse_snappy_chunk(type, buf) {\n if (type != 0) throw new Error(\"Unexpected Snappy chunk type \".concat(type));\n var ptr = [0];\n var usz = parse_varint49(buf, ptr);\n var chunks = [];\n while (ptr[0] < buf.length) {\n var tag = buf[ptr[0]] & 3;\n if (tag == 0) {\n var len = buf[ptr[0]++] >> 2;\n if (len < 60) ++len;else {\n var c = len - 59;\n len = buf[ptr[0]];\n if (c > 1) len |= buf[ptr[0] + 1] << 8;\n if (c > 2) len |= buf[ptr[0] + 2] << 16;\n if (c > 3) len |= buf[ptr[0] + 3] << 24;\n len >>>= 0;\n len++;\n ptr[0] += c;\n }\n chunks.push(buf.slice(ptr[0], ptr[0] + len));\n ptr[0] += len;\n continue;\n } else {\n var offset = 0,\n length = 0;\n if (tag == 1) {\n length = (buf[ptr[0]] >> 2 & 7) + 4;\n offset = (buf[ptr[0]++] & 224) << 3;\n offset |= buf[ptr[0]++];\n } else {\n length = (buf[ptr[0]++] >> 2) + 1;\n if (tag == 2) {\n offset = buf[ptr[0]] | buf[ptr[0] + 1] << 8;\n ptr[0] += 2;\n } else {\n offset = (buf[ptr[0]] | buf[ptr[0] + 1] << 8 | buf[ptr[0] + 2] << 16 | buf[ptr[0] + 3] << 24) >>> 0;\n ptr[0] += 4;\n }\n }\n chunks = [u8concat(chunks)];\n if (offset == 0) throw new Error(\"Invalid offset 0\");\n if (offset > chunks[0].length) throw new Error(\"Invalid offset beyond length\");\n if (length >= offset) {\n chunks.push(chunks[0].slice(-offset));\n length -= offset;\n while (length >= chunks[chunks.length - 1].length) {\n chunks.push(chunks[chunks.length - 1]);\n length -= chunks[chunks.length - 1].length;\n }\n }\n chunks.push(chunks[0].slice(-offset, -offset + length));\n }\n }\n var o = u8concat(chunks);\n if (o.length != usz) throw new Error(\"Unexpected length: \".concat(o.length, \" != \").concat(usz));\n return o;\n}\nfunction decompress_iwa_file(buf) {\n var out = [];\n var l = 0;\n while (l < buf.length) {\n var t = buf[l++];\n var len = buf[l] | buf[l + 1] << 8 | buf[l + 2] << 16;\n l += 3;\n out.push(parse_snappy_chunk(t, buf.slice(l, l + len)));\n l += len;\n }\n if (l !== buf.length) throw new Error(\"data is not a valid framed stream!\");\n return u8concat(out);\n}\nfunction compress_iwa_file(buf) {\n var out = [];\n var l = 0;\n while (l < buf.length) {\n var c = Math.min(buf.length - l, 268435455);\n var frame = new Uint8Array(4);\n out.push(frame);\n var usz = write_varint49(c);\n var L = usz.length;\n out.push(usz);\n if (c <= 60) {\n L++;\n out.push(new Uint8Array([c - 1 << 2]));\n } else if (c <= 256) {\n L += 2;\n out.push(new Uint8Array([240, c - 1 & 255]));\n } else if (c <= 65536) {\n L += 3;\n out.push(new Uint8Array([244, c - 1 & 255, c - 1 >> 8 & 255]));\n } else if (c <= 16777216) {\n L += 4;\n out.push(new Uint8Array([248, c - 1 & 255, c - 1 >> 8 & 255, c - 1 >> 16 & 255]));\n } else if (c <= 4294967296) {\n L += 5;\n out.push(new Uint8Array([252, c - 1 & 255, c - 1 >> 8 & 255, c - 1 >> 16 & 255, c - 1 >>> 24 & 255]));\n }\n out.push(buf.slice(l, l + c));\n L += c;\n frame[0] = 0;\n frame[1] = L & 255;\n frame[2] = L >> 8 & 255;\n frame[3] = L >> 16 & 255;\n l += c;\n }\n return u8concat(out);\n}\nfunction parse_old_storage(buf, sst, rsst, v) {\n var dv = u8_to_dataview(buf);\n var flags = dv.getUint32(4, true);\n var data_offset = (v > 1 ? 12 : 8) + popcnt(flags & (v > 1 ? 3470 : 398)) * 4;\n var ridx = -1,\n sidx = -1,\n ieee = NaN,\n dt = new Date(2001, 0, 1);\n if (flags & 512) {\n ridx = dv.getUint32(data_offset, true);\n data_offset += 4;\n }\n data_offset += popcnt(flags & (v > 1 ? 12288 : 4096)) * 4;\n if (flags & 16) {\n sidx = dv.getUint32(data_offset, true);\n data_offset += 4;\n }\n if (flags & 32) {\n ieee = dv.getFloat64(data_offset, true);\n data_offset += 8;\n }\n if (flags & 64) {\n dt.setTime(dt.getTime() + dv.getFloat64(data_offset, true) * 1e3);\n data_offset += 8;\n }\n var ret;\n switch (buf[2]) {\n case 0:\n break;\n case 2:\n ret = {\n t: \"n\",\n v: ieee\n };\n break;\n case 3:\n ret = {\n t: \"s\",\n v: sst[sidx]\n };\n break;\n case 5:\n ret = {\n t: \"d\",\n v: dt\n };\n break;\n case 6:\n ret = {\n t: \"b\",\n v: ieee > 0\n };\n break;\n case 7:\n ret = {\n t: \"n\",\n v: ieee / 86400\n };\n break;\n case 8:\n ret = {\n t: \"e\",\n v: 0\n };\n break;\n case 9:\n {\n if (ridx > -1) ret = {\n t: \"s\",\n v: rsst[ridx]\n };else if (sidx > -1) ret = {\n t: \"s\",\n v: sst[sidx]\n };else if (!isNaN(ieee)) ret = {\n t: \"n\",\n v: ieee\n };else throw new Error(\"Unsupported cell type \".concat(buf.slice(0, 4)));\n }\n break;\n default:\n throw new Error(\"Unsupported cell type \".concat(buf.slice(0, 4)));\n }\n return ret;\n}\nfunction parse_new_storage(buf, sst, rsst) {\n var dv = u8_to_dataview(buf);\n var flags = dv.getUint32(8, true);\n var data_offset = 12;\n var ridx = -1,\n sidx = -1,\n d128 = NaN,\n ieee = NaN,\n dt = new Date(2001, 0, 1);\n if (flags & 1) {\n d128 = readDecimal128LE(buf, data_offset);\n data_offset += 16;\n }\n if (flags & 2) {\n ieee = dv.getFloat64(data_offset, true);\n data_offset += 8;\n }\n if (flags & 4) {\n dt.setTime(dt.getTime() + dv.getFloat64(data_offset, true) * 1e3);\n data_offset += 8;\n }\n if (flags & 8) {\n sidx = dv.getUint32(data_offset, true);\n data_offset += 4;\n }\n if (flags & 16) {\n ridx = dv.getUint32(data_offset, true);\n data_offset += 4;\n }\n var ret;\n switch (buf[1]) {\n case 0:\n break;\n case 2:\n ret = {\n t: \"n\",\n v: d128\n };\n break;\n case 3:\n ret = {\n t: \"s\",\n v: sst[sidx]\n };\n break;\n case 5:\n ret = {\n t: \"d\",\n v: dt\n };\n break;\n case 6:\n ret = {\n t: \"b\",\n v: ieee > 0\n };\n break;\n case 7:\n ret = {\n t: \"n\",\n v: ieee / 86400\n };\n break;\n case 8:\n ret = {\n t: \"e\",\n v: 0\n };\n break;\n case 9:\n {\n if (ridx > -1) ret = {\n t: \"s\",\n v: rsst[ridx]\n };else throw new Error(\"Unsupported cell type \".concat(buf[1], \" : \").concat(flags & 31, \" : \").concat(buf.slice(0, 4)));\n }\n break;\n case 10:\n ret = {\n t: \"n\",\n v: d128\n };\n break;\n default:\n throw new Error(\"Unsupported cell type \".concat(buf[1], \" : \").concat(flags & 31, \" : \").concat(buf.slice(0, 4)));\n }\n return ret;\n}\nfunction write_new_storage(cell, sst) {\n var out = new Uint8Array(32),\n dv = u8_to_dataview(out),\n l = 12,\n flags = 0;\n out[0] = 5;\n switch (cell.t) {\n case \"n\":\n out[1] = 2;\n writeDecimal128LE(out, l, cell.v);\n flags |= 1;\n l += 16;\n break;\n case \"b\":\n out[1] = 6;\n dv.setFloat64(l, cell.v ? 1 : 0, true);\n flags |= 2;\n l += 8;\n break;\n case \"s\":\n if (sst.indexOf(cell.v) == -1) throw new Error(\"Value \".concat(cell.v, \" missing from SST!\"));\n out[1] = 3;\n dv.setUint32(l, sst.indexOf(cell.v), true);\n flags |= 8;\n l += 4;\n break;\n default:\n throw \"unsupported cell type \" + cell.t;\n }\n dv.setUint32(8, flags, true);\n return out.slice(0, l);\n}\nfunction write_old_storage(cell, sst) {\n var out = new Uint8Array(32),\n dv = u8_to_dataview(out),\n l = 12,\n flags = 0;\n out[0] = 3;\n switch (cell.t) {\n case \"n\":\n out[2] = 2;\n dv.setFloat64(l, cell.v, true);\n flags |= 32;\n l += 8;\n break;\n case \"b\":\n out[2] = 6;\n dv.setFloat64(l, cell.v ? 1 : 0, true);\n flags |= 32;\n l += 8;\n break;\n case \"s\":\n if (sst.indexOf(cell.v) == -1) throw new Error(\"Value \".concat(cell.v, \" missing from SST!\"));\n out[2] = 3;\n dv.setUint32(l, sst.indexOf(cell.v), true);\n flags |= 16;\n l += 4;\n break;\n default:\n throw \"unsupported cell type \" + cell.t;\n }\n dv.setUint32(4, flags, true);\n return out.slice(0, l);\n}\nfunction parse_cell_storage(buf, sst, rsst) {\n switch (buf[0]) {\n case 0:\n case 1:\n case 2:\n case 3:\n return parse_old_storage(buf, sst, rsst, buf[0]);\n case 5:\n return parse_new_storage(buf, sst, rsst);\n default:\n throw new Error(\"Unsupported payload version \".concat(buf[0]));\n }\n}\nfunction parse_TSP_Reference(buf) {\n var pb = parse_shallow(buf);\n return parse_varint49(pb[1][0].data);\n}\nfunction write_TSP_Reference(idx) {\n var out = [];\n out[1] = [{\n type: 0,\n data: write_varint49(idx)\n }];\n return write_shallow(out);\n}\nfunction parse_TST_TableDataList(M, root) {\n var pb = parse_shallow(root.data);\n var type = varint_to_i32(pb[1][0].data);\n var entries = pb[3];\n var data = [];\n (entries || []).forEach(function (entry) {\n var le = parse_shallow(entry.data);\n var key = varint_to_i32(le[1][0].data) >>> 0;\n switch (type) {\n case 1:\n data[key] = u8str(le[3][0].data);\n break;\n case 8:\n {\n var rt = M[parse_TSP_Reference(le[9][0].data)][0];\n var rtp = parse_shallow(rt.data);\n var rtpref = M[parse_TSP_Reference(rtp[1][0].data)][0];\n var mtype = varint_to_i32(rtpref.meta[1][0].data);\n if (mtype != 2001) throw new Error(\"2000 unexpected reference to \".concat(mtype));\n var tswpsa = parse_shallow(rtpref.data);\n data[key] = tswpsa[3].map(function (x) {\n return u8str(x.data);\n }).join(\"\");\n }\n break;\n }\n });\n return data;\n}\nfunction parse_TST_TileRowInfo(u8, type) {\n var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;\n var pb = parse_shallow(u8);\n var R = varint_to_i32(pb[1][0].data) >>> 0;\n var cnt = varint_to_i32(pb[2][0].data) >>> 0;\n var wide_offsets = ((_b = (_a = pb[8]) == null ? void 0 : _a[0]) == null ? void 0 : _b.data) && varint_to_i32(pb[8][0].data) > 0 || false;\n var used_storage_u8, used_storage;\n if (((_d = (_c = pb[7]) == null ? void 0 : _c[0]) == null ? void 0 : _d.data) && type != 0) {\n used_storage_u8 = (_f = (_e = pb[7]) == null ? void 0 : _e[0]) == null ? void 0 : _f.data;\n used_storage = (_h = (_g = pb[6]) == null ? void 0 : _g[0]) == null ? void 0 : _h.data;\n } else if (((_j = (_i = pb[4]) == null ? void 0 : _i[0]) == null ? void 0 : _j.data) && type != 1) {\n used_storage_u8 = (_l = (_k = pb[4]) == null ? void 0 : _k[0]) == null ? void 0 : _l.data;\n used_storage = (_n = (_m = pb[3]) == null ? void 0 : _m[0]) == null ? void 0 : _n.data;\n } else throw \"NUMBERS Tile missing \".concat(type, \" cell storage\");\n var width = wide_offsets ? 4 : 1;\n var used_storage_offsets = u8_to_dataview(used_storage_u8);\n var offsets = [];\n for (var C = 0; C < used_storage_u8.length / 2; ++C) {\n var off = used_storage_offsets.getUint16(C * 2, true);\n if (off < 65535) offsets.push([C, off]);\n }\n if (offsets.length != cnt) throw \"Expected \".concat(cnt, \" cells, found \").concat(offsets.length);\n var cells = [];\n for (C = 0; C < offsets.length - 1; ++C) cells[offsets[C][0]] = used_storage.subarray(offsets[C][1] * width, offsets[C + 1][1] * width);\n if (offsets.length >= 1) cells[offsets[offsets.length - 1][0]] = used_storage.subarray(offsets[offsets.length - 1][1] * width);\n return {\n R: R,\n cells: cells\n };\n}\nfunction parse_TST_Tile(M, root) {\n var _a;\n var pb = parse_shallow(root.data);\n var storage = ((_a = pb == null ? void 0 : pb[7]) == null ? void 0 : _a[0]) ? varint_to_i32(pb[7][0].data) >>> 0 > 0 ? 1 : 0 : -1;\n var ri = mappa(pb[5], function (u8) {\n return parse_TST_TileRowInfo(u8, storage);\n });\n return {\n nrows: varint_to_i32(pb[4][0].data) >>> 0,\n data: ri.reduce(function (acc, x) {\n if (!acc[x.R]) acc[x.R] = [];\n x.cells.forEach(function (cell, C) {\n if (acc[x.R][C]) throw new Error(\"Duplicate cell r=\".concat(x.R, \" c=\").concat(C));\n acc[x.R][C] = cell;\n });\n return acc;\n }, [])\n };\n}\nfunction parse_TST_TableModelArchive(M, root, ws) {\n var _a;\n var pb = parse_shallow(root.data);\n var range = {\n s: {\n r: 0,\n c: 0\n },\n e: {\n r: 0,\n c: 0\n }\n };\n range.e.r = (varint_to_i32(pb[6][0].data) >>> 0) - 1;\n if (range.e.r < 0) throw new Error(\"Invalid row varint \".concat(pb[6][0].data));\n range.e.c = (varint_to_i32(pb[7][0].data) >>> 0) - 1;\n if (range.e.c < 0) throw new Error(\"Invalid col varint \".concat(pb[7][0].data));\n ws[\"!ref\"] = encode_range(range);\n var store = parse_shallow(pb[4][0].data);\n var sst = parse_TST_TableDataList(M, M[parse_TSP_Reference(store[4][0].data)][0]);\n var rsst = ((_a = store[17]) == null ? void 0 : _a[0]) ? parse_TST_TableDataList(M, M[parse_TSP_Reference(store[17][0].data)][0]) : [];\n var tile = parse_shallow(store[3][0].data);\n var _R = 0;\n tile[1].forEach(function (t) {\n var tl = parse_shallow(t.data);\n var ref = M[parse_TSP_Reference(tl[2][0].data)][0];\n var mtype = varint_to_i32(ref.meta[1][0].data);\n if (mtype != 6002) throw new Error(\"6001 unexpected reference to \".concat(mtype));\n var _tile = parse_TST_Tile(M, ref);\n _tile.data.forEach(function (row, R) {\n row.forEach(function (buf, C) {\n var addr = encode_cell({\n r: _R + R,\n c: C\n });\n var res = parse_cell_storage(buf, sst, rsst);\n if (res) ws[addr] = res;\n });\n });\n _R += _tile.nrows;\n });\n}\nfunction parse_TST_TableInfoArchive(M, root) {\n var pb = parse_shallow(root.data);\n var out = {\n \"!ref\": \"A1\"\n };\n var tableref = M[parse_TSP_Reference(pb[2][0].data)];\n var mtype = varint_to_i32(tableref[0].meta[1][0].data);\n if (mtype != 6001) throw new Error(\"6000 unexpected reference to \".concat(mtype));\n parse_TST_TableModelArchive(M, tableref[0], out);\n return out;\n}\nfunction parse_TN_SheetArchive(M, root) {\n var _a;\n var pb = parse_shallow(root.data);\n var out = {\n name: ((_a = pb[1]) == null ? void 0 : _a[0]) ? u8str(pb[1][0].data) : \"\",\n sheets: []\n };\n var shapeoffs = mappa(pb[2], parse_TSP_Reference);\n shapeoffs.forEach(function (off) {\n M[off].forEach(function (m) {\n var mtype = varint_to_i32(m.meta[1][0].data);\n if (mtype == 6e3) out.sheets.push(parse_TST_TableInfoArchive(M, m));\n });\n });\n return out;\n}\nfunction parse_TN_DocumentArchive(M, root) {\n var out = book_new();\n var pb = parse_shallow(root.data);\n var sheetoffs = mappa(pb[1], parse_TSP_Reference);\n sheetoffs.forEach(function (off) {\n M[off].forEach(function (m) {\n var mtype = varint_to_i32(m.meta[1][0].data);\n if (mtype == 2) {\n var root2 = parse_TN_SheetArchive(M, m);\n root2.sheets.forEach(function (sheet, idx) {\n book_append_sheet(out, sheet, idx == 0 ? root2.name : root2.name + \"_\" + idx, true);\n });\n }\n });\n });\n if (out.SheetNames.length == 0) throw new Error(\"Empty NUMBERS file\");\n return out;\n}\nfunction parse_numbers_iwa(cfb) {\n var _a, _b, _c, _d;\n var M = {},\n indices = [];\n cfb.FullPaths.forEach(function (p) {\n if (p.match(/\\.iwpv2/)) throw new Error(\"Unsupported password protection\");\n });\n cfb.FileIndex.forEach(function (s) {\n if (!s.name.match(/\\.iwa$/)) return;\n var o;\n try {\n o = decompress_iwa_file(s.content);\n } catch (e) {\n return console.log(\"?? \" + s.content.length + \" \" + (e.message || e));\n }\n var packets;\n try {\n packets = parse_iwa_file(o);\n } catch (e) {\n return console.log(\"## \" + (e.message || e));\n }\n packets.forEach(function (packet) {\n M[packet.id] = packet.messages;\n indices.push(packet.id);\n });\n });\n if (!indices.length) throw new Error(\"File has no messages\");\n var docroot = ((_d = (_c = (_b = (_a = M == null ? void 0 : M[1]) == null ? void 0 : _a[0]) == null ? void 0 : _b.meta) == null ? void 0 : _c[1]) == null ? void 0 : _d[0].data) && varint_to_i32(M[1][0].meta[1][0].data) == 1 && M[1][0];\n if (!docroot) indices.forEach(function (idx) {\n M[idx].forEach(function (iwam) {\n var mtype = varint_to_i32(iwam.meta[1][0].data) >>> 0;\n if (mtype == 1) {\n if (!docroot) docroot = iwam;else throw new Error(\"Document has multiple roots\");\n }\n });\n });\n if (!docroot) throw new Error(\"Cannot find Document root\");\n return parse_TN_DocumentArchive(M, docroot);\n}\nfunction write_tile_row(tri, data, SST) {\n var _a, _b, _c, _d;\n if (!((_a = tri[6]) == null ? void 0 : _a[0]) || !((_b = tri[7]) == null ? void 0 : _b[0])) throw \"Mutation only works on post-BNC storages!\";\n var wide_offsets = ((_d = (_c = tri[8]) == null ? void 0 : _c[0]) == null ? void 0 : _d.data) && varint_to_i32(tri[8][0].data) > 0 || false;\n if (wide_offsets) throw \"Math only works with normal offsets\";\n var cnt = 0;\n var dv = u8_to_dataview(tri[7][0].data),\n last_offset = 0,\n cell_storage = [];\n var _dv = u8_to_dataview(tri[4][0].data),\n _last_offset = 0,\n _cell_storage = [];\n for (var C = 0; C < data.length; ++C) {\n if (data[C] == null) {\n dv.setUint16(C * 2, 65535, true);\n _dv.setUint16(C * 2, 65535);\n continue;\n }\n dv.setUint16(C * 2, last_offset, true);\n _dv.setUint16(C * 2, _last_offset, true);\n var celload, _celload;\n switch (typeof data[C]) {\n case \"string\":\n celload = write_new_storage({\n t: \"s\",\n v: data[C]\n }, SST);\n _celload = write_old_storage({\n t: \"s\",\n v: data[C]\n }, SST);\n break;\n case \"number\":\n celload = write_new_storage({\n t: \"n\",\n v: data[C]\n }, SST);\n _celload = write_old_storage({\n t: \"n\",\n v: data[C]\n }, SST);\n break;\n case \"boolean\":\n celload = write_new_storage({\n t: \"b\",\n v: data[C]\n }, SST);\n _celload = write_old_storage({\n t: \"b\",\n v: data[C]\n }, SST);\n break;\n default:\n throw new Error(\"Unsupported value \" + data[C]);\n }\n cell_storage.push(celload);\n last_offset += celload.length;\n _cell_storage.push(_celload);\n _last_offset += _celload.length;\n ++cnt;\n }\n tri[2][0].data = write_varint49(cnt);\n for (; C < tri[7][0].data.length / 2; ++C) {\n dv.setUint16(C * 2, 65535, true);\n _dv.setUint16(C * 2, 65535, true);\n }\n tri[6][0].data = u8concat(cell_storage);\n tri[3][0].data = u8concat(_cell_storage);\n return cnt;\n}\nfunction write_numbers_iwa(wb, opts) {\n if (!opts || !opts.numbers) throw new Error(\"Must pass a `numbers` option -- check the README\");\n var ws = wb.Sheets[wb.SheetNames[0]];\n if (wb.SheetNames.length > 1) console.error(\"The Numbers writer currently writes only the first table\");\n var range = decode_range(ws[\"!ref\"]);\n range.s.r = range.s.c = 0;\n var trunc = false;\n if (range.e.c > 9) {\n trunc = true;\n range.e.c = 9;\n }\n if (range.e.r > 49) {\n trunc = true;\n range.e.r = 49;\n }\n if (trunc) console.error(\"The Numbers writer is currently limited to \".concat(encode_range(range)));\n var data = sheet_to_json(ws, {\n range: range,\n header: 1\n });\n var SST = [\"~Sh33tJ5~\"];\n data.forEach(function (row) {\n return row.forEach(function (cell) {\n if (typeof cell == \"string\") SST.push(cell);\n });\n });\n var dependents = {};\n var indices = [];\n var cfb = CFB.read(opts.numbers, {\n type: \"base64\"\n });\n cfb.FileIndex.map(function (fi, idx) {\n return [fi, cfb.FullPaths[idx]];\n }).forEach(function (row) {\n var fi = row[0],\n fp = row[1];\n if (fi.type != 2) return;\n if (!fi.name.match(/\\.iwa/)) return;\n var old_content = fi.content;\n var raw1 = decompress_iwa_file(old_content);\n var x2 = parse_iwa_file(raw1);\n x2.forEach(function (packet2) {\n indices.push(packet2.id);\n dependents[packet2.id] = {\n deps: [],\n location: fp,\n type: varint_to_i32(packet2.messages[0].meta[1][0].data)\n };\n });\n });\n indices.sort(function (x2, y2) {\n return x2 - y2;\n });\n var indices_varint = indices.filter(function (x2) {\n return x2 > 1;\n }).map(function (x2) {\n return [x2, write_varint49(x2)];\n });\n cfb.FileIndex.map(function (fi, idx) {\n return [fi, cfb.FullPaths[idx]];\n }).forEach(function (row) {\n var fi = row[0],\n fp = row[1];\n if (!fi.name.match(/\\.iwa/)) return;\n var x2 = parse_iwa_file(decompress_iwa_file(fi.content));\n x2.forEach(function (ia) {\n ia.messages.forEach(function (m) {\n indices_varint.forEach(function (ivi) {\n if (ia.messages.some(function (mess) {\n return varint_to_i32(mess.meta[1][0].data) != 11006 && u8contains(mess.data, ivi[1]);\n })) {\n dependents[ivi[0]].deps.push(ia.id);\n }\n });\n });\n });\n });\n function get_unique_msgid() {\n for (var i = 927262; i < 2e6; ++i) if (!dependents[i]) return i;\n throw new Error(\"Too many messages\");\n }\n var entry = CFB.find(cfb, dependents[1].location);\n var x = parse_iwa_file(decompress_iwa_file(entry.content));\n var docroot;\n for (var xi = 0; xi < x.length; ++xi) {\n var packet = x[xi];\n if (packet.id == 1) docroot = packet;\n }\n var sheetrootref = parse_TSP_Reference(parse_shallow(docroot.messages[0].data)[1][0].data);\n entry = CFB.find(cfb, dependents[sheetrootref].location);\n x = parse_iwa_file(decompress_iwa_file(entry.content));\n for (xi = 0; xi < x.length; ++xi) {\n packet = x[xi];\n if (packet.id == sheetrootref) docroot = packet;\n }\n sheetrootref = parse_TSP_Reference(parse_shallow(docroot.messages[0].data)[2][0].data);\n entry = CFB.find(cfb, dependents[sheetrootref].location);\n x = parse_iwa_file(decompress_iwa_file(entry.content));\n for (xi = 0; xi < x.length; ++xi) {\n packet = x[xi];\n if (packet.id == sheetrootref) docroot = packet;\n }\n sheetrootref = parse_TSP_Reference(parse_shallow(docroot.messages[0].data)[2][0].data);\n entry = CFB.find(cfb, dependents[sheetrootref].location);\n x = parse_iwa_file(decompress_iwa_file(entry.content));\n for (xi = 0; xi < x.length; ++xi) {\n packet = x[xi];\n if (packet.id == sheetrootref) docroot = packet;\n }\n var pb = parse_shallow(docroot.messages[0].data);\n {\n pb[6][0].data = write_varint49(range.e.r + 1);\n pb[7][0].data = write_varint49(range.e.c + 1);\n var cruidsref = parse_TSP_Reference(pb[46][0].data);\n var oldbucket = CFB.find(cfb, dependents[cruidsref].location);\n var _x = parse_iwa_file(decompress_iwa_file(oldbucket.content));\n {\n for (var j = 0; j < _x.length; ++j) {\n if (_x[j].id == cruidsref) break;\n }\n if (_x[j].id != cruidsref) throw \"Bad ColumnRowUIDMapArchive\";\n var cruids = parse_shallow(_x[j].messages[0].data);\n cruids[1] = [];\n cruids[2] = [], cruids[3] = [];\n for (var C = 0; C <= range.e.c; ++C) {\n var uuid = [];\n uuid[1] = uuid[2] = [{\n type: 0,\n data: write_varint49(C + 420690)\n }];\n cruids[1].push({\n type: 2,\n data: write_shallow(uuid)\n });\n cruids[2].push({\n type: 0,\n data: write_varint49(C)\n });\n cruids[3].push({\n type: 0,\n data: write_varint49(C)\n });\n }\n cruids[4] = [];\n cruids[5] = [], cruids[6] = [];\n for (var R = 0; R <= range.e.r; ++R) {\n uuid = [];\n uuid[1] = uuid[2] = [{\n type: 0,\n data: write_varint49(R + 726270)\n }];\n cruids[4].push({\n type: 2,\n data: write_shallow(uuid)\n });\n cruids[5].push({\n type: 0,\n data: write_varint49(R)\n });\n cruids[6].push({\n type: 0,\n data: write_varint49(R)\n });\n }\n _x[j].messages[0].data = write_shallow(cruids);\n }\n oldbucket.content = compress_iwa_file(write_iwa_file(_x));\n oldbucket.size = oldbucket.content.length;\n delete pb[46];\n var store = parse_shallow(pb[4][0].data);\n {\n store[7][0].data = write_varint49(range.e.r + 1);\n var row_headers = parse_shallow(store[1][0].data);\n var row_header_ref = parse_TSP_Reference(row_headers[2][0].data);\n oldbucket = CFB.find(cfb, dependents[row_header_ref].location);\n _x = parse_iwa_file(decompress_iwa_file(oldbucket.content));\n {\n if (_x[0].id != row_header_ref) throw \"Bad HeaderStorageBucket\";\n var base_bucket = parse_shallow(_x[0].messages[0].data);\n for (R = 0; R < data.length; ++R) {\n var _bucket = parse_shallow(base_bucket[2][0].data);\n _bucket[1][0].data = write_varint49(R);\n _bucket[4][0].data = write_varint49(data[R].length);\n base_bucket[2][R] = {\n type: base_bucket[2][0].type,\n data: write_shallow(_bucket)\n };\n }\n _x[0].messages[0].data = write_shallow(base_bucket);\n }\n oldbucket.content = compress_iwa_file(write_iwa_file(_x));\n oldbucket.size = oldbucket.content.length;\n var col_header_ref = parse_TSP_Reference(store[2][0].data);\n oldbucket = CFB.find(cfb, dependents[col_header_ref].location);\n _x = parse_iwa_file(decompress_iwa_file(oldbucket.content));\n {\n if (_x[0].id != col_header_ref) throw \"Bad HeaderStorageBucket\";\n base_bucket = parse_shallow(_x[0].messages[0].data);\n for (C = 0; C <= range.e.c; ++C) {\n _bucket = parse_shallow(base_bucket[2][0].data);\n _bucket[1][0].data = write_varint49(C);\n _bucket[4][0].data = write_varint49(range.e.r + 1);\n base_bucket[2][C] = {\n type: base_bucket[2][0].type,\n data: write_shallow(_bucket)\n };\n }\n _x[0].messages[0].data = write_shallow(base_bucket);\n }\n oldbucket.content = compress_iwa_file(write_iwa_file(_x));\n oldbucket.size = oldbucket.content.length;\n var sstref = parse_TSP_Reference(store[4][0].data);\n (function () {\n var sentry = CFB.find(cfb, dependents[sstref].location);\n var sx = parse_iwa_file(decompress_iwa_file(sentry.content));\n var sstroot;\n for (var sxi = 0; sxi < sx.length; ++sxi) {\n var packet2 = sx[sxi];\n if (packet2.id == sstref) sstroot = packet2;\n }\n var sstdata = parse_shallow(sstroot.messages[0].data);\n {\n sstdata[3] = [];\n var newsst = [];\n SST.forEach(function (str, i) {\n newsst[1] = [{\n type: 0,\n data: write_varint49(i)\n }];\n newsst[2] = [{\n type: 0,\n data: write_varint49(1)\n }];\n newsst[3] = [{\n type: 2,\n data: stru8(str)\n }];\n sstdata[3].push({\n type: 2,\n data: write_shallow(newsst)\n });\n });\n }\n sstroot.messages[0].data = write_shallow(sstdata);\n var sy = write_iwa_file(sx);\n var raw32 = compress_iwa_file(sy);\n sentry.content = raw32;\n sentry.size = sentry.content.length;\n })();\n var tile = parse_shallow(store[3][0].data);\n {\n var t = tile[1][0];\n delete tile[2];\n var tl = parse_shallow(t.data);\n {\n var tileref = parse_TSP_Reference(tl[2][0].data);\n (function () {\n var tentry = CFB.find(cfb, dependents[tileref].location);\n var tx = parse_iwa_file(decompress_iwa_file(tentry.content));\n var tileroot;\n for (var sxi = 0; sxi < tx.length; ++sxi) {\n var packet2 = tx[sxi];\n if (packet2.id == tileref) tileroot = packet2;\n }\n var tiledata = parse_shallow(tileroot.messages[0].data);\n {\n delete tiledata[6];\n delete tile[7];\n var rowload = new Uint8Array(tiledata[5][0].data);\n tiledata[5] = [];\n var cnt = 0;\n for (var R2 = 0; R2 <= range.e.r; ++R2) {\n var tilerow = parse_shallow(rowload);\n cnt += write_tile_row(tilerow, data[R2], SST);\n tilerow[1][0].data = write_varint49(R2);\n tiledata[5].push({\n data: write_shallow(tilerow),\n type: 2\n });\n }\n tiledata[1] = [{\n type: 0,\n data: write_varint49(range.e.c + 1)\n }];\n tiledata[2] = [{\n type: 0,\n data: write_varint49(range.e.r + 1)\n }];\n tiledata[3] = [{\n type: 0,\n data: write_varint49(cnt)\n }];\n tiledata[4] = [{\n type: 0,\n data: write_varint49(range.e.r + 1)\n }];\n }\n tileroot.messages[0].data = write_shallow(tiledata);\n var ty = write_iwa_file(tx);\n var raw32 = compress_iwa_file(ty);\n tentry.content = raw32;\n tentry.size = tentry.content.length;\n })();\n }\n t.data = write_shallow(tl);\n }\n store[3][0].data = write_shallow(tile);\n }\n pb[4][0].data = write_shallow(store);\n }\n docroot.messages[0].data = write_shallow(pb);\n var y = write_iwa_file(x);\n var raw3 = compress_iwa_file(y);\n entry.content = raw3;\n entry.size = entry.content.length;\n return cfb;\n}\nfunction fix_opts_func(defaults /*:Array >*/) /*:{(o:any):void}*/{\n return function fix_opts(opts) {\n for (var i = 0; i != defaults.length; ++i) {\n var d = defaults[i];\n if (opts[d[0]] === undefined) opts[d[0]] = d[1];\n if (d[2] === 'n') opts[d[0]] = Number(opts[d[0]]);\n }\n };\n}\nfunction fix_read_opts(opts) {\n fix_opts_func([['cellNF', false], /* emit cell number format string as .z */\n ['cellHTML', true], /* emit html string as .h */\n ['cellFormula', true], /* emit formulae as .f */\n ['cellStyles', false], /* emits style/theme as .s */\n ['cellText', true], /* emit formatted text as .w */\n ['cellDates', false], /* emit date cells with type `d` */\n\n ['sheetStubs', false], /* emit empty cells */\n ['sheetRows', 0, 'n'], /* read n rows (0 = read all rows) */\n\n ['bookDeps', false], /* parse calculation chains */\n ['bookSheets', false], /* only try to get sheet names (no Sheets) */\n ['bookProps', false], /* only try to get properties (no Sheets) */\n ['bookFiles', false], /* include raw file structure (keys, files, cfb) */\n ['bookVBA', false], /* include vba raw data (vbaraw) */\n\n ['password', ''], /* password */\n ['WTF', false] /* WTF mode (throws errors) */])(opts);\n}\nfunction fix_write_opts(opts) {\n fix_opts_func([['cellDates', false], /* write date cells with type `d` */\n\n ['bookSST', false], /* Generate Shared String Table */\n\n ['bookType', 'xlsx'], /* Type of workbook (xlsx/m/b) */\n\n ['compression', false], /* Use file compression */\n\n ['WTF', false] /* WTF mode (throws errors) */])(opts);\n}\nfunction get_sheet_type(n /*:string*/) /*:string*/{\n if (RELS.WS.indexOf(n) > -1) return \"sheet\";\n if (RELS.CS && n == RELS.CS) return \"chart\";\n if (RELS.DS && n == RELS.DS) return \"dialog\";\n if (RELS.MS && n == RELS.MS) return \"macro\";\n return n && n.length ? n : \"sheet\";\n}\nfunction safe_parse_wbrels(wbrels, sheets) {\n if (!wbrels) return 0;\n try {\n wbrels = sheets.map(function pwbr(w) {\n if (!w.id) w.id = w.strRelID;\n return [w.name, wbrels['!id'][w.id].Target, get_sheet_type(wbrels['!id'][w.id].Type)];\n });\n } catch (e) {\n return null;\n }\n return !wbrels || wbrels.length === 0 ? null : wbrels;\n}\nfunction safe_parse_sheet(zip, path /*:string*/, relsPath /*:string*/, sheet, idx /*:number*/, sheetRels, sheets, stype /*:string*/, opts, wb, themes, styles) {\n try {\n sheetRels[sheet] = parse_rels(getzipstr(zip, relsPath, true), path);\n var data = getzipdata(zip, path);\n var _ws;\n switch (stype) {\n case 'sheet':\n _ws = parse_ws(data, path, idx, opts, sheetRels[sheet], wb, themes, styles);\n break;\n case 'chart':\n _ws = parse_cs(data, path, idx, opts, sheetRels[sheet], wb, themes, styles);\n if (!_ws || !_ws['!drawel']) break;\n var dfile = resolve_path(_ws['!drawel'].Target, path);\n var drelsp = get_rels_path(dfile);\n var draw = parse_drawing(getzipstr(zip, dfile, true), parse_rels(getzipstr(zip, drelsp, true), dfile));\n var chartp = resolve_path(draw, dfile);\n var crelsp = get_rels_path(chartp);\n _ws = parse_chart(getzipstr(zip, chartp, true), chartp, opts, parse_rels(getzipstr(zip, crelsp, true), chartp), wb, _ws);\n break;\n case 'macro':\n _ws = parse_ms(data, path, idx, opts, sheetRels[sheet], wb, themes, styles);\n break;\n case 'dialog':\n _ws = parse_ds(data, path, idx, opts, sheetRels[sheet], wb, themes, styles);\n break;\n default:\n throw new Error(\"Unrecognized sheet type \" + stype);\n }\n sheets[sheet] = _ws;\n\n /* scan rels for comments and threaded comments */\n var tcomments = [];\n if (sheetRels && sheetRels[sheet]) keys(sheetRels[sheet]).forEach(function (n) {\n var dfile = \"\";\n if (sheetRels[sheet][n].Type == RELS.CMNT) {\n dfile = resolve_path(sheetRels[sheet][n].Target, path);\n var comments = parse_cmnt(getzipdata(zip, dfile, true), dfile, opts);\n if (!comments || !comments.length) return;\n sheet_insert_comments(_ws, comments, false);\n }\n if (sheetRels[sheet][n].Type == RELS.TCMNT) {\n dfile = resolve_path(sheetRels[sheet][n].Target, path);\n tcomments = tcomments.concat(parse_tcmnt_xml(getzipdata(zip, dfile, true), opts));\n }\n });\n if (tcomments && tcomments.length) sheet_insert_comments(_ws, tcomments, true, opts.people || []);\n } catch (e) {\n if (opts.WTF) throw e;\n }\n}\nfunction strip_front_slash(x /*:string*/) /*:string*/{\n return x.charAt(0) == '/' ? x.slice(1) : x;\n}\nfunction parse_zip(zip /*:ZIP*/, opts /*:?ParseOpts*/) /*:Workbook*/{\n make_ssf();\n opts = opts || {};\n fix_read_opts(opts);\n\n /* OpenDocument Part 3 Section 2.2.1 OpenDocument Package */\n if (safegetzipfile(zip, 'META-INF/manifest.xml')) return parse_ods(zip, opts);\n /* UOC */\n if (safegetzipfile(zip, 'objectdata.xml')) return parse_ods(zip, opts);\n /* Numbers */\n if (safegetzipfile(zip, 'Index/Document.iwa')) {\n if (typeof Uint8Array == \"undefined\") throw new Error('NUMBERS file parsing requires Uint8Array support');\n if (typeof parse_numbers_iwa != \"undefined\") {\n if (zip.FileIndex) return parse_numbers_iwa(zip);\n var _zip = CFB.utils.cfb_new();\n zipentries(zip).forEach(function (e) {\n zip_add_file(_zip, e, getzipbin(zip, e));\n });\n return parse_numbers_iwa(_zip);\n }\n throw new Error('Unsupported NUMBERS file');\n }\n if (!safegetzipfile(zip, '[Content_Types].xml')) {\n if (safegetzipfile(zip, 'index.xml.gz')) throw new Error('Unsupported NUMBERS 08 file');\n if (safegetzipfile(zip, 'index.xml')) throw new Error('Unsupported NUMBERS 09 file');\n throw new Error('Unsupported ZIP file');\n }\n var entries = zipentries(zip);\n var dir = parse_ct(getzipstr(zip, '[Content_Types].xml') /*:?any*/);\n var xlsb = false;\n var sheets, binname;\n if (dir.workbooks.length === 0) {\n binname = \"xl/workbook.xml\";\n if (getzipdata(zip, binname, true)) dir.workbooks.push(binname);\n }\n if (dir.workbooks.length === 0) {\n binname = \"xl/workbook.bin\";\n if (!getzipdata(zip, binname, true)) throw new Error(\"Could not find workbook\");\n dir.workbooks.push(binname);\n xlsb = true;\n }\n if (dir.workbooks[0].slice(-3) == \"bin\") xlsb = true;\n var themes = {} /*:any*/;\n var styles = {} /*:any*/;\n if (!opts.bookSheets && !opts.bookProps) {\n strs = [];\n if (dir.sst) try {\n strs = parse_sst(getzipdata(zip, strip_front_slash(dir.sst)), dir.sst, opts);\n } catch (e) {\n if (opts.WTF) throw e;\n }\n if (opts.cellStyles && dir.themes.length) themes = parse_theme(getzipstr(zip, dir.themes[0].replace(/^\\//, ''), true) || \"\", dir.themes[0], opts);\n if (dir.style) styles = parse_sty(getzipdata(zip, strip_front_slash(dir.style)), dir.style, themes, opts);\n }\n\n /*var externbooks = */\n dir.links.map(function (link) {\n try {\n var rels = parse_rels(getzipstr(zip, get_rels_path(strip_front_slash(link))), link);\n return parse_xlink(getzipdata(zip, strip_front_slash(link)), rels, link, opts);\n } catch (e) {}\n });\n var wb = parse_wb(getzipdata(zip, strip_front_slash(dir.workbooks[0])), dir.workbooks[0], opts);\n var props = {},\n propdata = \"\";\n if (dir.coreprops.length) {\n propdata = getzipdata(zip, strip_front_slash(dir.coreprops[0]), true);\n if (propdata) props = parse_core_props(propdata);\n if (dir.extprops.length !== 0) {\n propdata = getzipdata(zip, strip_front_slash(dir.extprops[0]), true);\n if (propdata) parse_ext_props(propdata, props, opts);\n }\n }\n var custprops = {};\n if (!opts.bookSheets || opts.bookProps) {\n if (dir.custprops.length !== 0) {\n propdata = getzipstr(zip, strip_front_slash(dir.custprops[0]), true);\n if (propdata) custprops = parse_cust_props(propdata, opts);\n }\n }\n var out = {} /*:any*/;\n if (opts.bookSheets || opts.bookProps) {\n if (wb.Sheets) sheets = wb.Sheets.map(function pluck(x) {\n return x.name;\n });else if (props.Worksheets && props.SheetNames.length > 0) sheets = props.SheetNames;\n if (opts.bookProps) {\n out.Props = props;\n out.Custprops = custprops;\n }\n if (opts.bookSheets && typeof sheets !== 'undefined') out.SheetNames = sheets;\n if (opts.bookSheets ? out.SheetNames : opts.bookProps) return out;\n }\n sheets = {};\n var deps = {};\n if (opts.bookDeps && dir.calcchain) deps = parse_cc(getzipdata(zip, strip_front_slash(dir.calcchain)), dir.calcchain, opts);\n var i = 0;\n var sheetRels = {} /*:any*/;\n var path, relsPath;\n {\n var wbsheets = wb.Sheets;\n props.Worksheets = wbsheets.length;\n props.SheetNames = [];\n for (var j = 0; j != wbsheets.length; ++j) {\n props.SheetNames[j] = wbsheets[j].name;\n }\n }\n var wbext = xlsb ? \"bin\" : \"xml\";\n var wbrelsi = dir.workbooks[0].lastIndexOf(\"/\");\n var wbrelsfile = (dir.workbooks[0].slice(0, wbrelsi + 1) + \"_rels/\" + dir.workbooks[0].slice(wbrelsi + 1) + \".rels\").replace(/^\\//, \"\");\n if (!safegetzipfile(zip, wbrelsfile)) wbrelsfile = 'xl/_rels/workbook.' + wbext + '.rels';\n var wbrels = parse_rels(getzipstr(zip, wbrelsfile, true), wbrelsfile.replace(/_rels.*/, \"s5s\"));\n if ((dir.metadata || []).length >= 1) {\n /* TODO: MDX and other types of metadata */\n opts.xlmeta = parse_xlmeta(getzipdata(zip, strip_front_slash(dir.metadata[0])), dir.metadata[0], opts);\n }\n if ((dir.people || []).length >= 1) {\n opts.people = parse_people_xml(getzipdata(zip, strip_front_slash(dir.people[0])), opts);\n }\n if (wbrels) wbrels = safe_parse_wbrels(wbrels, wb.Sheets);\n\n /* Numbers iOS hack */\n var nmode = getzipdata(zip, \"xl/worksheets/sheet.xml\", true) ? 1 : 0;\n wsloop: for (i = 0; i != props.Worksheets; ++i) {\n var stype = \"sheet\";\n if (wbrels && wbrels[i]) {\n path = 'xl/' + wbrels[i][1].replace(/[\\/]?xl\\//, \"\");\n if (!safegetzipfile(zip, path)) path = wbrels[i][1];\n if (!safegetzipfile(zip, path)) path = wbrelsfile.replace(/_rels\\/.*$/, \"\") + wbrels[i][1];\n stype = wbrels[i][2];\n } else {\n path = 'xl/worksheets/sheet' + (i + 1 - nmode) + \".\" + wbext;\n path = path.replace(/sheet0\\./, \"sheet.\");\n }\n relsPath = path.replace(/^(.*)(\\/)([^\\/]*)$/, \"$1/_rels/$3.rels\");\n if (opts && opts.sheets != null) switch (typeof opts.sheets) {\n case \"number\":\n if (i != opts.sheets) continue wsloop;\n break;\n case \"string\":\n if (props.SheetNames[i].toLowerCase() != opts.sheets.toLowerCase()) continue wsloop;\n break;\n default:\n if (Array.isArray && Array.isArray(opts.sheets)) {\n var snjseen = false;\n for (var snj = 0; snj != opts.sheets.length; ++snj) {\n if (typeof opts.sheets[snj] == \"number\" && opts.sheets[snj] == i) snjseen = 1;\n if (typeof opts.sheets[snj] == \"string\" && opts.sheets[snj].toLowerCase() == props.SheetNames[i].toLowerCase()) snjseen = 1;\n }\n if (!snjseen) continue wsloop;\n }\n }\n safe_parse_sheet(zip, path, relsPath, props.SheetNames[i], i, sheetRels, sheets, stype, opts, wb, themes, styles);\n }\n out = {\n Directory: dir,\n Workbook: wb,\n Props: props,\n Custprops: custprops,\n Deps: deps,\n Sheets: sheets,\n SheetNames: props.SheetNames,\n Strings: strs,\n Styles: styles,\n Themes: themes,\n SSF: dup(table_fmt)\n } /*:any*/;\n if (opts && opts.bookFiles) {\n if (zip.files) {\n out.keys = entries;\n out.files = zip.files;\n } else {\n out.keys = [];\n out.files = {};\n zip.FullPaths.forEach(function (p, idx) {\n p = p.replace(/^Root Entry[\\/]/, \"\");\n out.keys.push(p);\n out.files[p] = zip.FileIndex[idx];\n });\n }\n }\n if (opts && opts.bookVBA) {\n if (dir.vba.length > 0) out.vbaraw = getzipdata(zip, strip_front_slash(dir.vba[0]), true);else if (dir.defaults && dir.defaults.bin === CT_VBA) out.vbaraw = getzipdata(zip, 'xl/vbaProject.bin', true);\n }\n return out;\n}\n\n/* [MS-OFFCRYPTO] 2.1.1 */\nfunction parse_xlsxcfb(cfb, _opts /*:?ParseOpts*/) /*:Workbook*/{\n var opts = _opts || {};\n var f = 'Workbook',\n data = CFB.find(cfb, f);\n try {\n f = '/!DataSpaces/Version';\n data = CFB.find(cfb, f);\n if (!data || !data.content) throw new Error(\"ECMA-376 Encrypted file missing \" + f);\n /*var version = */\n parse_DataSpaceVersionInfo(data.content);\n\n /* 2.3.4.1 */\n f = '/!DataSpaces/DataSpaceMap';\n data = CFB.find(cfb, f);\n if (!data || !data.content) throw new Error(\"ECMA-376 Encrypted file missing \" + f);\n var dsm = parse_DataSpaceMap(data.content);\n if (dsm.length !== 1 || dsm[0].comps.length !== 1 || dsm[0].comps[0].t !== 0 || dsm[0].name !== \"StrongEncryptionDataSpace\" || dsm[0].comps[0].v !== \"EncryptedPackage\") throw new Error(\"ECMA-376 Encrypted file bad \" + f);\n\n /* 2.3.4.2 */\n f = '/!DataSpaces/DataSpaceInfo/StrongEncryptionDataSpace';\n data = CFB.find(cfb, f);\n if (!data || !data.content) throw new Error(\"ECMA-376 Encrypted file missing \" + f);\n var seds = parse_DataSpaceDefinition(data.content);\n if (seds.length != 1 || seds[0] != \"StrongEncryptionTransform\") throw new Error(\"ECMA-376 Encrypted file bad \" + f);\n\n /* 2.3.4.3 */\n f = '/!DataSpaces/TransformInfo/StrongEncryptionTransform/!Primary';\n data = CFB.find(cfb, f);\n if (!data || !data.content) throw new Error(\"ECMA-376 Encrypted file missing \" + f);\n /*var hdr = */\n parse_Primary(data.content);\n } catch (e) {}\n f = '/EncryptionInfo';\n data = CFB.find(cfb, f);\n if (!data || !data.content) throw new Error(\"ECMA-376 Encrypted file missing \" + f);\n var einfo = parse_EncryptionInfo(data.content);\n\n /* 2.3.4.4 */\n f = '/EncryptedPackage';\n data = CFB.find(cfb, f);\n if (!data || !data.content) throw new Error(\"ECMA-376 Encrypted file missing \" + f);\n\n /*global decrypt_agile */\n /*:: declare var decrypt_agile:any; */\n if (einfo[0] == 0x04 && typeof decrypt_agile !== 'undefined') return decrypt_agile(einfo[1], data.content, opts.password || \"\", opts);\n /*global decrypt_std76 */\n /*:: declare var decrypt_std76:any; */\n if (einfo[0] == 0x02 && typeof decrypt_std76 !== 'undefined') return decrypt_std76(einfo[1], data.content, opts.password || \"\", opts);\n throw new Error(\"File is password-protected\");\n}\nfunction write_zip(wb /*:Workbook*/, opts /*:WriteOpts*/) /*:ZIP*/{\n if (opts.bookType == \"ods\") return write_ods(wb, opts);\n if (opts.bookType == \"numbers\") return write_numbers_iwa(wb, opts);\n if (opts.bookType == \"xlsb\") return write_zip_xlsxb(wb, opts);\n return write_zip_xlsx(wb, opts);\n}\n\n/* XLSX and XLSB writing are very similar. Originally they were unified in one\n export function. This is horrible for tree shaking in the common case (most\n applications need to export files in one format) so this function supports\n both formats while write_zip_xlsx only handles XLSX */\nfunction write_zip_xlsxb(wb /*:Workbook*/, opts /*:WriteOpts*/) /*:ZIP*/{\n _shapeid = 1024;\n if (wb && !wb.SSF) {\n wb.SSF = dup(table_fmt);\n }\n if (wb && wb.SSF) {\n make_ssf();\n SSF_load_table(wb.SSF);\n // $FlowIgnore\n opts.revssf = evert_num(wb.SSF);\n opts.revssf[wb.SSF[65535]] = 0;\n opts.ssf = wb.SSF;\n }\n opts.rels = {};\n opts.wbrels = {};\n opts.Strings = /*::((*/[] /*:: :any):SST)*/;\n opts.Strings.Count = 0;\n opts.Strings.Unique = 0;\n if (browser_has_Map) opts.revStrings = new Map();else {\n opts.revStrings = {};\n opts.revStrings.foo = [];\n delete opts.revStrings.foo;\n }\n var wbext = opts.bookType == \"xlsb\" ? \"bin\" : \"xml\";\n var vbafmt = VBAFMTS.indexOf(opts.bookType) > -1;\n var ct = new_ct();\n fix_write_opts(opts = opts || {});\n var zip = zip_new();\n var f = \"\",\n rId = 0;\n opts.cellXfs = [];\n get_cell_style(opts.cellXfs, {}, {\n revssf: {\n \"General\": 0\n }\n });\n if (!wb.Props) wb.Props = {};\n f = \"docProps/core.xml\";\n zip_add_file(zip, f, write_core_props(wb.Props, opts));\n ct.coreprops.push(f);\n add_rels(opts.rels, 2, f, RELS.CORE_PROPS);\n\n /*::if(!wb.Props) throw \"unreachable\"; */\n f = \"docProps/app.xml\";\n if (wb.Props && wb.Props.SheetNames) {/* empty */} else if (!wb.Workbook || !wb.Workbook.Sheets) wb.Props.SheetNames = wb.SheetNames;else {\n var _sn = [];\n for (var _i = 0; _i < wb.SheetNames.length; ++_i) if ((wb.Workbook.Sheets[_i] || {}).Hidden != 2) _sn.push(wb.SheetNames[_i]);\n wb.Props.SheetNames = _sn;\n }\n wb.Props.Worksheets = wb.Props.SheetNames.length;\n zip_add_file(zip, f, write_ext_props(wb.Props, opts));\n ct.extprops.push(f);\n add_rels(opts.rels, 3, f, RELS.EXT_PROPS);\n if (wb.Custprops !== wb.Props && keys(wb.Custprops || {}).length > 0) {\n f = \"docProps/custom.xml\";\n zip_add_file(zip, f, write_cust_props(wb.Custprops, opts));\n ct.custprops.push(f);\n add_rels(opts.rels, 4, f, RELS.CUST_PROPS);\n }\n for (rId = 1; rId <= wb.SheetNames.length; ++rId) {\n var wsrels = {\n '!id': {}\n };\n var ws = wb.Sheets[wb.SheetNames[rId - 1]];\n var _type = (ws || {})[\"!type\"] || \"sheet\";\n switch (_type) {\n case \"chart\":\n /* falls through */\n default:\n f = \"xl/worksheets/sheet\" + rId + \".\" + wbext;\n zip_add_file(zip, f, write_ws(rId - 1, f, opts, wb, wsrels));\n ct.sheets.push(f);\n add_rels(opts.wbrels, -1, \"worksheets/sheet\" + rId + \".\" + wbext, RELS.WS[0]);\n }\n if (ws) {\n var comments = ws['!comments'];\n var need_vml = false;\n var cf = \"\";\n if (comments && comments.length > 0) {\n cf = \"xl/comments\" + rId + \".\" + wbext;\n zip_add_file(zip, cf, write_cmnt(comments, cf, opts));\n ct.comments.push(cf);\n add_rels(wsrels, -1, \"../comments\" + rId + \".\" + wbext, RELS.CMNT);\n need_vml = true;\n }\n if (ws['!legacy']) {\n if (need_vml) zip_add_file(zip, \"xl/drawings/vmlDrawing\" + rId + \".vml\", write_comments_vml(rId, ws['!comments']));\n }\n delete ws['!comments'];\n delete ws['!legacy'];\n }\n if (wsrels['!id'].rId1) zip_add_file(zip, get_rels_path(f), write_rels(wsrels));\n }\n if (opts.Strings != null && opts.Strings.length > 0) {\n f = \"xl/sharedStrings.\" + wbext;\n zip_add_file(zip, f, write_sst(opts.Strings, f, opts));\n ct.strs.push(f);\n add_rels(opts.wbrels, -1, \"sharedStrings.\" + wbext, RELS.SST);\n }\n f = \"xl/workbook.\" + wbext;\n zip_add_file(zip, f, write_wb(wb, f, opts));\n ct.workbooks.push(f);\n add_rels(opts.rels, 1, f, RELS.WB);\n\n /* TODO: something more intelligent with themes */\n\n f = \"xl/theme/theme1.xml\";\n zip_add_file(zip, f, write_theme(wb.Themes, opts));\n ct.themes.push(f);\n add_rels(opts.wbrels, -1, \"theme/theme1.xml\", RELS.THEME);\n\n /* TODO: something more intelligent with styles */\n\n f = \"xl/styles.\" + wbext;\n zip_add_file(zip, f, write_sty(wb, f, opts));\n ct.styles.push(f);\n add_rels(opts.wbrels, -1, \"styles.\" + wbext, RELS.STY);\n if (wb.vbaraw && vbafmt) {\n f = \"xl/vbaProject.bin\";\n zip_add_file(zip, f, wb.vbaraw);\n ct.vba.push(f);\n add_rels(opts.wbrels, -1, \"vbaProject.bin\", RELS.VBA);\n }\n f = \"xl/metadata.\" + wbext;\n zip_add_file(zip, f, write_xlmeta(f));\n ct.metadata.push(f);\n add_rels(opts.wbrels, -1, \"metadata.\" + wbext, RELS.XLMETA);\n zip_add_file(zip, \"[Content_Types].xml\", write_ct(ct, opts));\n zip_add_file(zip, '_rels/.rels', write_rels(opts.rels));\n zip_add_file(zip, 'xl/_rels/workbook.' + wbext + '.rels', write_rels(opts.wbrels));\n delete opts.revssf;\n delete opts.ssf;\n return zip;\n}\nfunction write_zip_xlsx(wb /*:Workbook*/, opts /*:WriteOpts*/) /*:ZIP*/{\n _shapeid = 1024;\n if (wb && !wb.SSF) {\n wb.SSF = dup(table_fmt);\n }\n if (wb && wb.SSF) {\n make_ssf();\n SSF_load_table(wb.SSF);\n // $FlowIgnore\n opts.revssf = evert_num(wb.SSF);\n opts.revssf[wb.SSF[65535]] = 0;\n opts.ssf = wb.SSF;\n }\n opts.rels = {};\n opts.wbrels = {};\n opts.Strings = /*::((*/[] /*:: :any):SST)*/;\n opts.Strings.Count = 0;\n opts.Strings.Unique = 0;\n if (browser_has_Map) opts.revStrings = new Map();else {\n opts.revStrings = {};\n opts.revStrings.foo = [];\n delete opts.revStrings.foo;\n }\n var wbext = \"xml\";\n var vbafmt = VBAFMTS.indexOf(opts.bookType) > -1;\n var ct = new_ct();\n fix_write_opts(opts = opts || {});\n var zip = zip_new();\n var f = \"\",\n rId = 0;\n opts.cellXfs = [];\n get_cell_style(opts.cellXfs, {}, {\n revssf: {\n \"General\": 0\n }\n });\n if (!wb.Props) wb.Props = {};\n f = \"docProps/core.xml\";\n zip_add_file(zip, f, write_core_props(wb.Props, opts));\n ct.coreprops.push(f);\n add_rels(opts.rels, 2, f, RELS.CORE_PROPS);\n\n /*::if(!wb.Props) throw \"unreachable\"; */\n f = \"docProps/app.xml\";\n if (wb.Props && wb.Props.SheetNames) {/* empty */} else if (!wb.Workbook || !wb.Workbook.Sheets) wb.Props.SheetNames = wb.SheetNames;else {\n var _sn = [];\n for (var _i = 0; _i < wb.SheetNames.length; ++_i) if ((wb.Workbook.Sheets[_i] || {}).Hidden != 2) _sn.push(wb.SheetNames[_i]);\n wb.Props.SheetNames = _sn;\n }\n wb.Props.Worksheets = wb.Props.SheetNames.length;\n zip_add_file(zip, f, write_ext_props(wb.Props, opts));\n ct.extprops.push(f);\n add_rels(opts.rels, 3, f, RELS.EXT_PROPS);\n if (wb.Custprops !== wb.Props && keys(wb.Custprops || {}).length > 0) {\n f = \"docProps/custom.xml\";\n zip_add_file(zip, f, write_cust_props(wb.Custprops, opts));\n ct.custprops.push(f);\n add_rels(opts.rels, 4, f, RELS.CUST_PROPS);\n }\n var people = [\"SheetJ5\"];\n opts.tcid = 0;\n for (rId = 1; rId <= wb.SheetNames.length; ++rId) {\n var wsrels = {\n '!id': {}\n };\n var ws = wb.Sheets[wb.SheetNames[rId - 1]];\n var _type = (ws || {})[\"!type\"] || \"sheet\";\n switch (_type) {\n case \"chart\":\n /* falls through */\n default:\n f = \"xl/worksheets/sheet\" + rId + \".\" + wbext;\n zip_add_file(zip, f, write_ws_xml(rId - 1, opts, wb, wsrels));\n ct.sheets.push(f);\n add_rels(opts.wbrels, -1, \"worksheets/sheet\" + rId + \".\" + wbext, RELS.WS[0]);\n }\n if (ws) {\n var comments = ws['!comments'];\n var need_vml = false;\n var cf = \"\";\n if (comments && comments.length > 0) {\n var needtc = false;\n comments.forEach(function (carr) {\n carr[1].forEach(function (c) {\n if (c.T == true) needtc = true;\n });\n });\n if (needtc) {\n cf = \"xl/threadedComments/threadedComment\" + rId + \".\" + wbext;\n zip_add_file(zip, cf, write_tcmnt_xml(comments, people, opts));\n ct.threadedcomments.push(cf);\n add_rels(wsrels, -1, \"../threadedComments/threadedComment\" + rId + \".\" + wbext, RELS.TCMNT);\n }\n cf = \"xl/comments\" + rId + \".\" + wbext;\n zip_add_file(zip, cf, write_comments_xml(comments, opts));\n ct.comments.push(cf);\n add_rels(wsrels, -1, \"../comments\" + rId + \".\" + wbext, RELS.CMNT);\n need_vml = true;\n }\n if (ws['!legacy']) {\n if (need_vml) zip_add_file(zip, \"xl/drawings/vmlDrawing\" + rId + \".vml\", write_comments_vml(rId, ws['!comments']));\n }\n delete ws['!comments'];\n delete ws['!legacy'];\n }\n if (wsrels['!id'].rId1) zip_add_file(zip, get_rels_path(f), write_rels(wsrels));\n }\n if (opts.Strings != null && opts.Strings.length > 0) {\n f = \"xl/sharedStrings.\" + wbext;\n zip_add_file(zip, f, write_sst_xml(opts.Strings, opts));\n ct.strs.push(f);\n add_rels(opts.wbrels, -1, \"sharedStrings.\" + wbext, RELS.SST);\n }\n f = \"xl/workbook.\" + wbext;\n zip_add_file(zip, f, write_wb_xml(wb, opts));\n ct.workbooks.push(f);\n add_rels(opts.rels, 1, f, RELS.WB);\n\n /* TODO: something more intelligent with themes */\n\n f = \"xl/theme/theme1.xml\";\n zip_add_file(zip, f, write_theme(wb.Themes, opts));\n ct.themes.push(f);\n add_rels(opts.wbrels, -1, \"theme/theme1.xml\", RELS.THEME);\n\n /* TODO: something more intelligent with styles */\n\n f = \"xl/styles.\" + wbext;\n zip_add_file(zip, f, write_sty_xml(wb, opts));\n ct.styles.push(f);\n add_rels(opts.wbrels, -1, \"styles.\" + wbext, RELS.STY);\n if (wb.vbaraw && vbafmt) {\n f = \"xl/vbaProject.bin\";\n zip_add_file(zip, f, wb.vbaraw);\n ct.vba.push(f);\n add_rels(opts.wbrels, -1, \"vbaProject.bin\", RELS.VBA);\n }\n f = \"xl/metadata.\" + wbext;\n zip_add_file(zip, f, write_xlmeta_xml());\n ct.metadata.push(f);\n add_rels(opts.wbrels, -1, \"metadata.\" + wbext, RELS.XLMETA);\n if (people.length > 1) {\n f = \"xl/persons/person.xml\";\n zip_add_file(zip, f, write_people_xml(people, opts));\n ct.people.push(f);\n add_rels(opts.wbrels, -1, \"persons/person.xml\", RELS.PEOPLE);\n }\n zip_add_file(zip, \"[Content_Types].xml\", write_ct(ct, opts));\n zip_add_file(zip, '_rels/.rels', write_rels(opts.rels));\n zip_add_file(zip, 'xl/_rels/workbook.' + wbext + '.rels', write_rels(opts.wbrels));\n delete opts.revssf;\n delete opts.ssf;\n return zip;\n}\nfunction firstbyte(f /*:RawData*/, o /*:?TypeOpts*/) /*:Array*/{\n var x = \"\";\n switch ((o || {}).type || \"base64\") {\n case 'buffer':\n return [f[0], f[1], f[2], f[3], f[4], f[5], f[6], f[7]];\n case 'base64':\n x = Base64_decode(f.slice(0, 12));\n break;\n case 'binary':\n x = f;\n break;\n case 'array':\n return [f[0], f[1], f[2], f[3], f[4], f[5], f[6], f[7]];\n default:\n throw new Error(\"Unrecognized type \" + (o && o.type || \"undefined\"));\n }\n return [x.charCodeAt(0), x.charCodeAt(1), x.charCodeAt(2), x.charCodeAt(3), x.charCodeAt(4), x.charCodeAt(5), x.charCodeAt(6), x.charCodeAt(7)];\n}\nfunction read_cfb(cfb /*:CFBContainer*/, opts /*:?ParseOpts*/) /*:Workbook*/{\n if (CFB.find(cfb, \"EncryptedPackage\")) return parse_xlsxcfb(cfb, opts);\n return parse_xlscfb(cfb, opts);\n}\nfunction read_zip(data /*:RawData*/, opts /*:?ParseOpts*/) /*:Workbook*/{\n var zip,\n d = data;\n var o = opts || {};\n if (!o.type) o.type = has_buf && Buffer.isBuffer(data) ? \"buffer\" : \"base64\";\n zip = zip_read(d, o);\n return parse_zip(zip, o);\n}\nfunction read_plaintext(data /*:string*/, o /*:ParseOpts*/) /*:Workbook*/{\n var i = 0;\n main: while (i < data.length) switch (data.charCodeAt(i)) {\n case 0x0A:\n case 0x0D:\n case 0x20:\n ++i;\n break;\n case 0x3C:\n return parse_xlml(data.slice(i), o);\n default:\n break main;\n }\n return PRN.to_workbook(data, o);\n}\nfunction read_plaintext_raw(data /*:RawData*/, o /*:ParseOpts*/) /*:Workbook*/{\n var str = \"\",\n bytes = firstbyte(data, o);\n switch (o.type) {\n case 'base64':\n str = Base64_decode(data);\n break;\n case 'binary':\n str = data;\n break;\n case 'buffer':\n str = data.toString('binary');\n break;\n case 'array':\n str = cc2str(data);\n break;\n default:\n throw new Error(\"Unrecognized type \" + o.type);\n }\n if (bytes[0] == 0xEF && bytes[1] == 0xBB && bytes[2] == 0xBF) str = utf8read(str);\n o.type = \"binary\";\n return read_plaintext(str, o);\n}\nfunction read_utf16(data /*:RawData*/, o /*:ParseOpts*/) /*:Workbook*/{\n var d = data;\n if (o.type == 'base64') d = Base64_decode(d);\n d = $cptable.utils.decode(1200, d.slice(2), 'str');\n o.type = \"binary\";\n return read_plaintext(d, o);\n}\nfunction bstrify(data /*:string*/) /*:string*/{\n return !data.match(/[^\\x00-\\x7F]/) ? data : utf8write(data);\n}\nfunction read_prn(data, d, o, str) {\n if (str) {\n o.type = \"string\";\n return PRN.to_workbook(data, o);\n }\n return PRN.to_workbook(d, o);\n}\nfunction readSync(data /*:RawData*/, opts /*:?ParseOpts*/) /*:Workbook*/{\n reset_cp();\n var o = opts || {};\n if (typeof ArrayBuffer !== 'undefined' && data instanceof ArrayBuffer) return readSync(new Uint8Array(data), (o = dup(o), o.type = \"array\", o));\n if (typeof Uint8Array !== 'undefined' && data instanceof Uint8Array && !o.type) o.type = typeof Deno !== \"undefined\" ? \"buffer\" : \"array\";\n var d = data,\n n = [0, 0, 0, 0],\n str = false;\n if (o.cellStyles) {\n o.cellNF = true;\n o.sheetStubs = true;\n }\n _ssfopts = {};\n if (o.dateNF) _ssfopts.dateNF = o.dateNF;\n if (!o.type) o.type = has_buf && Buffer.isBuffer(data) ? \"buffer\" : \"base64\";\n if (o.type == \"file\") {\n o.type = has_buf ? \"buffer\" : \"binary\";\n d = read_binary(data);\n if (typeof Uint8Array !== 'undefined' && !has_buf) o.type = \"array\";\n }\n if (o.type == \"string\") {\n str = true;\n o.type = \"binary\";\n o.codepage = 65001;\n d = bstrify(data);\n }\n if (o.type == 'array' && typeof Uint8Array !== 'undefined' && data instanceof Uint8Array && typeof ArrayBuffer !== 'undefined') {\n // $FlowIgnore\n var ab = new ArrayBuffer(3),\n vu = new Uint8Array(ab);\n vu.foo = \"bar\";\n // $FlowIgnore\n if (!vu.foo) {\n o = dup(o);\n o.type = 'array';\n return readSync(ab2a(d), o);\n }\n }\n switch ((n = firstbyte(d, o))[0]) {\n case 0xD0:\n if (n[1] === 0xCF && n[2] === 0x11 && n[3] === 0xE0 && n[4] === 0xA1 && n[5] === 0xB1 && n[6] === 0x1A && n[7] === 0xE1) return read_cfb(CFB.read(d, o), o);\n break;\n case 0x09:\n if (n[1] <= 0x08) return parse_xlscfb(d, o);\n break;\n case 0x3C:\n return parse_xlml(d, o);\n case 0x49:\n if (n[1] === 0x49 && n[2] === 0x2a && n[3] === 0x00) throw new Error(\"TIFF Image File is not a spreadsheet\");\n if (n[1] === 0x44) return read_wb_ID(d, o);\n break;\n case 0x54:\n if (n[1] === 0x41 && n[2] === 0x42 && n[3] === 0x4C) return DIF.to_workbook(d, o);\n break;\n case 0x50:\n return n[1] === 0x4B && n[2] < 0x09 && n[3] < 0x09 ? read_zip(d, o) : read_prn(data, d, o, str);\n case 0xEF:\n return n[3] === 0x3C ? parse_xlml(d, o) : read_prn(data, d, o, str);\n case 0xFF:\n if (n[1] === 0xFE) {\n return read_utf16(d, o);\n } else if (n[1] === 0x00 && n[2] === 0x02 && n[3] === 0x00) return WK_.to_workbook(d, o);\n break;\n case 0x00:\n if (n[1] === 0x00) {\n if (n[2] >= 0x02 && n[3] === 0x00) return WK_.to_workbook(d, o);\n if (n[2] === 0x00 && (n[3] === 0x08 || n[3] === 0x09)) return WK_.to_workbook(d, o);\n }\n break;\n case 0x03:\n case 0x83:\n case 0x8B:\n case 0x8C:\n return DBF.to_workbook(d, o);\n case 0x7B:\n if (n[1] === 0x5C && n[2] === 0x72 && n[3] === 0x74) return RTF.to_workbook(d, o);\n break;\n case 0x0A:\n case 0x0D:\n case 0x20:\n return read_plaintext_raw(d, o);\n case 0x89:\n if (n[1] === 0x50 && n[2] === 0x4E && n[3] === 0x47) throw new Error(\"PNG Image File is not a spreadsheet\");\n break;\n }\n if (DBF_SUPPORTED_VERSIONS.indexOf(n[0]) > -1 && n[2] <= 12 && n[3] <= 31) return DBF.to_workbook(d, o);\n return read_prn(data, d, o, str);\n}\nfunction readFileSync(filename /*:string*/, opts /*:?ParseOpts*/) /*:Workbook*/{\n var o = opts || {};\n o.type = 'file';\n return readSync(filename, o);\n}\nfunction write_cfb_ctr(cfb /*:CFBContainer*/, o /*:WriteOpts*/) /*:any*/{\n switch (o.type) {\n case \"base64\":\n case \"binary\":\n break;\n case \"buffer\":\n case \"array\":\n o.type = \"\";\n break;\n case \"file\":\n return write_dl(o.file, CFB.write(cfb, {\n type: has_buf ? 'buffer' : \"\"\n }));\n case \"string\":\n throw new Error(\"'string' output type invalid for '\" + o.bookType + \"' files\");\n default:\n throw new Error(\"Unrecognized type \" + o.type);\n }\n return CFB.write(cfb, o);\n}\n\n/*:: declare var encrypt_agile:any; */\nfunction write_zip_type(wb /*:Workbook*/, opts /*:?WriteOpts*/) /*:any*/{\n var o = dup(opts || {});\n var z = write_zip(wb, o);\n return write_zip_denouement(z, o);\n}\nfunction write_zip_typeXLSX(wb /*:Workbook*/, opts /*:?WriteOpts*/) /*:any*/{\n var o = dup(opts || {});\n var z = write_zip_xlsx(wb, o);\n return write_zip_denouement(z, o);\n}\nfunction write_zip_denouement(z /*:any*/, o /*:?WriteOpts*/) /*:any*/{\n var oopts = {};\n var ftype = has_buf ? \"nodebuffer\" : typeof Uint8Array !== \"undefined\" ? \"array\" : \"string\";\n if (o.compression) oopts.compression = 'DEFLATE';\n if (o.password) oopts.type = ftype;else switch (o.type) {\n case \"base64\":\n oopts.type = \"base64\";\n break;\n case \"binary\":\n oopts.type = \"string\";\n break;\n case \"string\":\n throw new Error(\"'string' output type invalid for '\" + o.bookType + \"' files\");\n case \"buffer\":\n case \"file\":\n oopts.type = ftype;\n break;\n default:\n throw new Error(\"Unrecognized type \" + o.type);\n }\n var out = z.FullPaths ? CFB.write(z, {\n fileType: \"zip\",\n type: /*::(*/{\n \"nodebuffer\": \"buffer\",\n \"string\": \"binary\"\n } /*:: :any)*/[oopts.type] || oopts.type,\n compression: !!o.compression\n }) : z.generate(oopts);\n if (typeof Deno !== \"undefined\") {\n if (typeof out == \"string\") {\n if (o.type == \"binary\" || o.type == \"base64\") return out;\n out = new Uint8Array(s2ab(out));\n }\n }\n /*jshint -W083 */\n if (o.password && typeof encrypt_agile !== 'undefined') return write_cfb_ctr(encrypt_agile(out, o.password), o); // eslint-disable-line no-undef\n /*jshint +W083 */\n if (o.type === \"file\") return write_dl(o.file, out);\n return o.type == \"string\" ? utf8read(/*::(*/out /*:: :any)*/) : out;\n}\nfunction write_cfb_type(wb /*:Workbook*/, opts /*:?WriteOpts*/) /*:any*/{\n var o = opts || {};\n var cfb /*:CFBContainer*/ = write_xlscfb(wb, o);\n return write_cfb_ctr(cfb, o);\n}\nfunction write_string_type(out /*:string*/, opts /*:WriteOpts*/, bom /*:?string*/) /*:any*/{\n if (!bom) bom = \"\";\n var o = bom + out;\n switch (opts.type) {\n case \"base64\":\n return Base64_encode(utf8write(o));\n case \"binary\":\n return utf8write(o);\n case \"string\":\n return out;\n case \"file\":\n return write_dl(opts.file, o, 'utf8');\n case \"buffer\":\n {\n if (has_buf) return Buffer_from(o, 'utf8');else if (typeof TextEncoder !== \"undefined\") return new TextEncoder().encode(o);else return write_string_type(o, {\n type: 'binary'\n }).split(\"\").map(function (c) {\n return c.charCodeAt(0);\n });\n }\n }\n throw new Error(\"Unrecognized type \" + opts.type);\n}\nfunction write_stxt_type(out /*:string*/, opts /*:WriteOpts*/) /*:any*/{\n switch (opts.type) {\n case \"base64\":\n return Base64_encode(out);\n case \"binary\":\n return out;\n case \"string\":\n return out;\n /* override in sheet_to_txt */\n case \"file\":\n return write_dl(opts.file, out, 'binary');\n case \"buffer\":\n {\n if (has_buf) return Buffer_from(out, 'binary');else return out.split(\"\").map(function (c) {\n return c.charCodeAt(0);\n });\n }\n }\n throw new Error(\"Unrecognized type \" + opts.type);\n}\n\n/* TODO: test consistency */\nfunction write_binary_type(out, opts /*:WriteOpts*/) /*:any*/{\n switch (opts.type) {\n case \"string\":\n case \"base64\":\n case \"binary\":\n var bstr = \"\";\n // $FlowIgnore\n for (var i = 0; i < out.length; ++i) bstr += String.fromCharCode(out[i]);\n return opts.type == 'base64' ? Base64_encode(bstr) : opts.type == 'string' ? utf8read(bstr) : bstr;\n case \"file\":\n return write_dl(opts.file, out);\n case \"buffer\":\n return out;\n default:\n throw new Error(\"Unrecognized type \" + opts.type);\n }\n}\nfunction writeSyncXLSX(wb /*:Workbook*/, opts /*:?WriteOpts*/) {\n reset_cp();\n check_wb(wb);\n var o = dup(opts || {});\n if (o.cellStyles) {\n o.cellNF = true;\n o.sheetStubs = true;\n }\n if (o.type == \"array\") {\n o.type = \"binary\";\n var out /*:string*/ = writeSyncXLSX(wb, o) /*:any*/;\n o.type = \"array\";\n return s2ab(out);\n }\n return write_zip_typeXLSX(wb, o);\n}\nfunction writeSync(wb /*:Workbook*/, opts /*:?WriteOpts*/) {\n reset_cp();\n check_wb(wb);\n var o = dup(opts || {});\n if (o.cellStyles) {\n o.cellNF = true;\n o.sheetStubs = true;\n }\n if (o.type == \"array\") {\n o.type = \"binary\";\n var out /*:string*/ = writeSync(wb, o) /*:any*/;\n o.type = \"array\";\n return s2ab(out);\n }\n var idx = 0;\n if (o.sheet) {\n if (typeof o.sheet == \"number\") idx = o.sheet;else idx = wb.SheetNames.indexOf(o.sheet);\n if (!wb.SheetNames[idx]) throw new Error(\"Sheet not found: \" + o.sheet + \" : \" + typeof o.sheet);\n }\n switch (o.bookType || 'xlsb') {\n case 'xml':\n case 'xlml':\n return write_string_type(write_xlml(wb, o), o);\n case 'slk':\n case 'sylk':\n return write_string_type(SYLK.from_sheet(wb.Sheets[wb.SheetNames[idx]], o), o);\n case 'htm':\n case 'html':\n return write_string_type(sheet_to_html(wb.Sheets[wb.SheetNames[idx]], o), o);\n case 'txt':\n return write_stxt_type(sheet_to_txt(wb.Sheets[wb.SheetNames[idx]], o), o);\n case 'csv':\n return write_string_type(sheet_to_csv(wb.Sheets[wb.SheetNames[idx]], o), o, \"\\ufeff\");\n case 'dif':\n return write_string_type(DIF.from_sheet(wb.Sheets[wb.SheetNames[idx]], o), o);\n case 'dbf':\n return write_binary_type(DBF.from_sheet(wb.Sheets[wb.SheetNames[idx]], o), o);\n case 'prn':\n return write_string_type(PRN.from_sheet(wb.Sheets[wb.SheetNames[idx]], o), o);\n case 'rtf':\n return write_string_type(RTF.from_sheet(wb.Sheets[wb.SheetNames[idx]], o), o);\n case 'eth':\n return write_string_type(ETH.from_sheet(wb.Sheets[wb.SheetNames[idx]], o), o);\n case 'fods':\n return write_string_type(write_ods(wb, o), o);\n case 'wk1':\n return write_binary_type(WK_.sheet_to_wk1(wb.Sheets[wb.SheetNames[idx]], o), o);\n case 'wk3':\n return write_binary_type(WK_.book_to_wk3(wb, o), o);\n case 'biff2':\n if (!o.biff) o.biff = 2;\n /* falls through */\n case 'biff3':\n if (!o.biff) o.biff = 3;\n /* falls through */\n case 'biff4':\n if (!o.biff) o.biff = 4;\n return write_binary_type(write_biff_buf(wb, o), o);\n case 'biff5':\n if (!o.biff) o.biff = 5;\n /* falls through */\n case 'biff8':\n case 'xla':\n case 'xls':\n if (!o.biff) o.biff = 8;\n return write_cfb_type(wb, o);\n case 'xlsx':\n case 'xlsm':\n case 'xlam':\n case 'xlsb':\n case 'numbers':\n case 'ods':\n return write_zip_type(wb, o);\n default:\n throw new Error(\"Unrecognized bookType |\" + o.bookType + \"|\");\n }\n}\nfunction resolve_book_type(o /*:WriteFileOpts*/) {\n if (o.bookType) return;\n var _BT = {\n \"xls\": \"biff8\",\n \"htm\": \"html\",\n \"slk\": \"sylk\",\n \"socialcalc\": \"eth\",\n \"Sh33tJS\": \"WTF\"\n };\n var ext = o.file.slice(o.file.lastIndexOf(\".\")).toLowerCase();\n if (ext.match(/^\\.[a-z]+$/)) o.bookType = ext.slice(1);\n o.bookType = _BT[o.bookType] || o.bookType;\n}\nfunction writeFileSync(wb /*:Workbook*/, filename /*:string*/, opts /*:?WriteFileOpts*/) {\n var o = opts || {};\n o.type = 'file';\n o.file = filename;\n resolve_book_type(o);\n return writeSync(wb, o);\n}\nfunction writeFileSyncXLSX(wb /*:Workbook*/, filename /*:string*/, opts /*:?WriteFileOpts*/) {\n var o = opts || {};\n o.type = 'file';\n o.file = filename;\n resolve_book_type(o);\n return writeSyncXLSX(wb, o);\n}\nfunction writeFileAsync(filename /*:string*/, wb /*:Workbook*/, opts /*:?WriteFileOpts*/, cb /*:?(e?:ErrnoError)=>void*/) {\n var o = opts || {};\n o.type = 'file';\n o.file = filename;\n resolve_book_type(o);\n o.type = 'buffer';\n var _cb = cb;\n if (!(_cb instanceof Function)) _cb = opts /*:any*/;\n return _fs.writeFile(filename, writeSync(wb, o), _cb);\n}\n/*::\ntype MJRObject = {\n\trow: any;\n\tisempty: boolean;\n};\n*/\nfunction make_json_row(sheet /*:Worksheet*/, r /*:Range*/, R /*:number*/, cols /*:Array*/, header /*:number*/, hdr /*:Array*/, dense /*:boolean*/, o /*:Sheet2JSONOpts*/) /*:MJRObject*/{\n var rr = encode_row(R);\n var defval = o.defval,\n raw = o.raw || !Object.prototype.hasOwnProperty.call(o, \"raw\");\n var isempty = true;\n var row /*:any*/ = header === 1 ? [] : {};\n if (header !== 1) {\n if (Object.defineProperty) try {\n Object.defineProperty(row, '__rowNum__', {\n value: R,\n enumerable: false\n });\n } catch (e) {\n row.__rowNum__ = R;\n } else row.__rowNum__ = R;\n }\n if (!dense || sheet[R]) for (var C = r.s.c; C <= r.e.c; ++C) {\n var val = dense ? sheet[R][C] : sheet[cols[C] + rr];\n if (val === undefined || val.t === undefined) {\n if (defval === undefined) continue;\n if (hdr[C] != null) {\n row[hdr[C]] = defval;\n }\n continue;\n }\n var v = val.v;\n switch (val.t) {\n case 'z':\n if (v == null) break;\n continue;\n case 'e':\n v = v == 0 ? null : void 0;\n break;\n case 's':\n case 'd':\n case 'b':\n case 'n':\n break;\n default:\n throw new Error('unrecognized type ' + val.t);\n }\n if (hdr[C] != null) {\n if (v == null) {\n if (val.t == \"e\" && v === null) row[hdr[C]] = null;else if (defval !== undefined) row[hdr[C]] = defval;else if (raw && v === null) row[hdr[C]] = null;else continue;\n } else {\n row[hdr[C]] = raw && (val.t !== \"n\" || val.t === \"n\" && o.rawNumbers !== false) ? v : format_cell(val, v, o);\n }\n if (v != null) isempty = false;\n }\n }\n return {\n row: row,\n isempty: isempty\n };\n}\nfunction sheet_to_json(sheet /*:Worksheet*/, opts /*:?Sheet2JSONOpts*/) {\n if (sheet == null || sheet[\"!ref\"] == null) return [];\n var val = {\n t: 'n',\n v: 0\n },\n header = 0,\n offset = 1,\n hdr /*:Array*/ = [],\n v = 0,\n vv = \"\";\n var r = {\n s: {\n r: 0,\n c: 0\n },\n e: {\n r: 0,\n c: 0\n }\n };\n var o = opts || {};\n var range = o.range != null ? o.range : sheet[\"!ref\"];\n if (o.header === 1) header = 1;else if (o.header === \"A\") header = 2;else if (Array.isArray(o.header)) header = 3;else if (o.header == null) header = 0;\n switch (typeof range) {\n case 'string':\n r = safe_decode_range(range);\n break;\n case 'number':\n r = safe_decode_range(sheet[\"!ref\"]);\n r.s.r = range;\n break;\n default:\n r = range;\n }\n if (header > 0) offset = 0;\n var rr = encode_row(r.s.r);\n var cols /*:Array*/ = [];\n var out /*:Array*/ = [];\n var outi = 0,\n counter = 0;\n var dense = Array.isArray(sheet);\n var R = r.s.r,\n C = 0;\n var header_cnt = {};\n if (dense && !sheet[R]) sheet[R] = [];\n var colinfo /*:Array*/ = o.skipHidden && sheet[\"!cols\"] || [];\n var rowinfo /*:Array*/ = o.skipHidden && sheet[\"!rows\"] || [];\n for (C = r.s.c; C <= r.e.c; ++C) {\n if ((colinfo[C] || {}).hidden) continue;\n cols[C] = encode_col(C);\n val = dense ? sheet[R][C] : sheet[cols[C] + rr];\n switch (header) {\n case 1:\n hdr[C] = C - r.s.c;\n break;\n case 2:\n hdr[C] = cols[C];\n break;\n case 3:\n hdr[C] = o.header[C - r.s.c];\n break;\n default:\n if (val == null) val = {\n w: \"__EMPTY\",\n t: \"s\"\n };\n vv = v = format_cell(val, null, o);\n counter = header_cnt[v] || 0;\n if (!counter) header_cnt[v] = 1;else {\n do {\n vv = v + \"_\" + counter++;\n } while (header_cnt[vv]);\n header_cnt[v] = counter;\n header_cnt[vv] = 1;\n }\n hdr[C] = vv;\n }\n }\n for (R = r.s.r + offset; R <= r.e.r; ++R) {\n if ((rowinfo[R] || {}).hidden) continue;\n var row = make_json_row(sheet, r, R, cols, header, hdr, dense, o);\n if (row.isempty === false || (header === 1 ? o.blankrows !== false : !!o.blankrows)) out[outi++] = row.row;\n }\n out.length = outi;\n return out;\n}\nvar qreg = /\"/g;\nfunction make_csv_row(sheet /*:Worksheet*/, r /*:Range*/, R /*:number*/, cols /*:Array*/, fs /*:number*/, rs /*:number*/, FS /*:string*/, o /*:Sheet2CSVOpts*/) /*:?string*/{\n var isempty = true;\n var row /*:Array*/ = [],\n txt = \"\",\n rr = encode_row(R);\n for (var C = r.s.c; C <= r.e.c; ++C) {\n if (!cols[C]) continue;\n var val = o.dense ? (sheet[R] || [])[C] : sheet[cols[C] + rr];\n if (val == null) txt = \"\";else if (val.v != null) {\n isempty = false;\n txt = '' + (o.rawNumbers && val.t == \"n\" ? val.v : format_cell(val, null, o));\n for (var i = 0, cc = 0; i !== txt.length; ++i) if ((cc = txt.charCodeAt(i)) === fs || cc === rs || cc === 34 || o.forceQuotes) {\n txt = \"\\\"\" + txt.replace(qreg, '\"\"') + \"\\\"\";\n break;\n }\n if (txt == \"ID\") txt = '\"ID\"';\n } else if (val.f != null && !val.F) {\n isempty = false;\n txt = '=' + val.f;\n if (txt.indexOf(\",\") >= 0) txt = '\"' + txt.replace(qreg, '\"\"') + '\"';\n } else txt = \"\";\n /* NOTE: Excel CSV does not support array formulae */\n row.push(txt);\n }\n if (o.blankrows === false && isempty) return null;\n return row.join(FS);\n}\nfunction sheet_to_csv(sheet /*:Worksheet*/, opts /*:?Sheet2CSVOpts*/) /*:string*/{\n var out /*:Array*/ = [];\n var o = opts == null ? {} : opts;\n if (sheet == null || sheet[\"!ref\"] == null) return \"\";\n var r = safe_decode_range(sheet[\"!ref\"]);\n var FS = o.FS !== undefined ? o.FS : \",\",\n fs = FS.charCodeAt(0);\n var RS = o.RS !== undefined ? o.RS : \"\\n\",\n rs = RS.charCodeAt(0);\n var endregex = new RegExp((FS == \"|\" ? \"\\\\|\" : FS) + \"+$\");\n var row = \"\",\n cols /*:Array*/ = [];\n o.dense = Array.isArray(sheet);\n var colinfo /*:Array*/ = o.skipHidden && sheet[\"!cols\"] || [];\n var rowinfo /*:Array*/ = o.skipHidden && sheet[\"!rows\"] || [];\n for (var C = r.s.c; C <= r.e.c; ++C) if (!(colinfo[C] || {}).hidden) cols[C] = encode_col(C);\n var w = 0;\n for (var R = r.s.r; R <= r.e.r; ++R) {\n if ((rowinfo[R] || {}).hidden) continue;\n row = make_csv_row(sheet, r, R, cols, fs, rs, FS, o);\n if (row == null) {\n continue;\n }\n if (o.strip) row = row.replace(endregex, \"\");\n if (row || o.blankrows !== false) out.push((w++ ? RS : \"\") + row);\n }\n delete o.dense;\n return out.join(\"\");\n}\nfunction sheet_to_txt(sheet /*:Worksheet*/, opts /*:?Sheet2CSVOpts*/) {\n if (!opts) opts = {};\n opts.FS = \"\\t\";\n opts.RS = \"\\n\";\n var s = sheet_to_csv(sheet, opts);\n if (typeof $cptable == 'undefined' || opts.type == 'string') return s;\n var o = $cptable.utils.encode(1200, s, 'str');\n return String.fromCharCode(255) + String.fromCharCode(254) + o;\n}\nfunction sheet_to_formulae(sheet /*:Worksheet*/) /*:Array*/{\n var y = \"\",\n x,\n val = \"\";\n if (sheet == null || sheet[\"!ref\"] == null) return [];\n var r = safe_decode_range(sheet['!ref']),\n rr = \"\",\n cols /*:Array*/ = [],\n C;\n var cmds /*:Array*/ = [];\n var dense = Array.isArray(sheet);\n for (C = r.s.c; C <= r.e.c; ++C) cols[C] = encode_col(C);\n for (var R = r.s.r; R <= r.e.r; ++R) {\n rr = encode_row(R);\n for (C = r.s.c; C <= r.e.c; ++C) {\n y = cols[C] + rr;\n x = dense ? (sheet[R] || [])[C] : sheet[y];\n val = \"\";\n if (x === undefined) continue;else if (x.F != null) {\n y = x.F;\n if (!x.f) continue;\n val = x.f;\n if (y.indexOf(\":\") == -1) y = y + \":\" + y;\n }\n if (x.f != null) val = x.f;else if (x.t == 'z') continue;else if (x.t == 'n' && x.v != null) val = \"\" + x.v;else if (x.t == 'b') val = x.v ? \"TRUE\" : \"FALSE\";else if (x.w !== undefined) val = \"'\" + x.w;else if (x.v === undefined) continue;else if (x.t == 's') val = \"'\" + x.v;else val = \"\" + x.v;\n cmds[cmds.length] = y + \"=\" + val;\n }\n }\n return cmds;\n}\nfunction sheet_add_json(_ws /*:?Worksheet*/, js /*:Array*/, opts) /*:Worksheet*/{\n var o = opts || {};\n var offset = +!o.skipHeader;\n var ws /*:Worksheet*/ = _ws || {} /*:any*/;\n var _R = 0,\n _C = 0;\n if (ws && o.origin != null) {\n if (typeof o.origin == 'number') _R = o.origin;else {\n var _origin /*:CellAddress*/ = typeof o.origin == \"string\" ? decode_cell(o.origin) : o.origin;\n _R = _origin.r;\n _C = _origin.c;\n }\n }\n var cell /*:Cell*/;\n var range /*:Range*/ = {\n s: {\n c: 0,\n r: 0\n },\n e: {\n c: _C,\n r: _R + js.length - 1 + offset\n }\n } /*:any*/;\n if (ws['!ref']) {\n var _range = safe_decode_range(ws['!ref']);\n range.e.c = Math.max(range.e.c, _range.e.c);\n range.e.r = Math.max(range.e.r, _range.e.r);\n if (_R == -1) {\n _R = _range.e.r + 1;\n range.e.r = _R + js.length - 1 + offset;\n }\n } else {\n if (_R == -1) {\n _R = 0;\n range.e.r = js.length - 1 + offset;\n }\n }\n var hdr /*:Array*/ = o.header || [],\n C = 0;\n js.forEach(function (JS, R /*:number*/) {\n keys(JS).forEach(function (k) {\n if ((C = hdr.indexOf(k)) == -1) hdr[C = hdr.length] = k;\n var v = JS[k];\n var t = 'z';\n var z = \"\";\n var ref = encode_cell({\n c: _C + C,\n r: _R + R + offset\n });\n cell = ws_get_cell_stub(ws, ref);\n if (v && typeof v === 'object' && !(v instanceof Date)) {\n ws[ref] = v;\n } else {\n if (typeof v == 'number') t = 'n';else if (typeof v == 'boolean') t = 'b';else if (typeof v == 'string') t = 's';else if (v instanceof Date) {\n t = 'd';\n if (!o.cellDates) {\n t = 'n';\n v = datenum(v);\n }\n z = o.dateNF || table_fmt[14];\n } else if (v === null && o.nullError) {\n t = 'e';\n v = 0;\n }\n if (!cell) ws[ref] = cell = {\n t: t,\n v: v\n } /*:any*/;else {\n cell.t = t;\n cell.v = v;\n delete cell.w;\n delete cell.R;\n if (z) cell.z = z;\n }\n if (z) cell.z = z;\n }\n });\n });\n range.e.c = Math.max(range.e.c, _C + hdr.length - 1);\n var __R = encode_row(_R);\n if (offset) for (C = 0; C < hdr.length; ++C) ws[encode_col(C + _C) + __R] = {\n t: 's',\n v: hdr[C]\n };\n ws['!ref'] = encode_range(range);\n return ws;\n}\nfunction json_to_sheet(js /*:Array*/, opts) /*:Worksheet*/{\n return sheet_add_json(null, js, opts);\n}\n\n/* get cell, creating a stub if necessary */\nfunction ws_get_cell_stub(ws /*:Worksheet*/, R, C /*:?number*/) /*:Cell*/{\n /* A1 cell address */\n if (typeof R == \"string\") {\n /* dense */\n if (Array.isArray(ws)) {\n var RC = decode_cell(R);\n if (!ws[RC.r]) ws[RC.r] = [];\n return ws[RC.r][RC.c] || (ws[RC.r][RC.c] = {\n t: 'z'\n });\n }\n return ws[R] || (ws[R] = {\n t: 'z'\n });\n }\n /* cell address object */\n if (typeof R != \"number\") return ws_get_cell_stub(ws, encode_cell(R));\n /* R and C are 0-based indices */\n return ws_get_cell_stub(ws, encode_cell({\n r: R,\n c: C || 0\n }));\n}\n\n/* find sheet index for given name / validate index */\nfunction wb_sheet_idx(wb /*:Workbook*/, sh /*:number|string*/) {\n if (typeof sh == \"number\") {\n if (sh >= 0 && wb.SheetNames.length > sh) return sh;\n throw new Error(\"Cannot find sheet # \" + sh);\n } else if (typeof sh == \"string\") {\n var idx = wb.SheetNames.indexOf(sh);\n if (idx > -1) return idx;\n throw new Error(\"Cannot find sheet name |\" + sh + \"|\");\n } else throw new Error(\"Cannot find sheet |\" + sh + \"|\");\n}\n\n/* simple blank workbook object */\nfunction book_new() /*:Workbook*/{\n return {\n SheetNames: [],\n Sheets: {}\n };\n}\n\n/* add a worksheet to the end of a given workbook */\nfunction book_append_sheet(wb /*:Workbook*/, ws /*:Worksheet*/, name /*:?string*/, roll /*:?boolean*/) /*:string*/{\n var i = 1;\n if (!name) for (; i <= 0xFFFF; ++i, name = undefined) if (wb.SheetNames.indexOf(name = \"Sheet\" + i) == -1) break;\n if (!name || wb.SheetNames.length >= 0xFFFF) throw new Error(\"Too many worksheets\");\n if (roll && wb.SheetNames.indexOf(name) >= 0) {\n var m = name.match(/(^.*?)(\\d+)$/);\n i = m && +m[2] || 0;\n var root = m && m[1] || name;\n for (++i; i <= 0xFFFF; ++i) if (wb.SheetNames.indexOf(name = root + i) == -1) break;\n }\n check_ws_name(name);\n if (wb.SheetNames.indexOf(name) >= 0) throw new Error(\"Worksheet with name |\" + name + \"| already exists!\");\n wb.SheetNames.push(name);\n wb.Sheets[name] = ws;\n return name;\n}\n\n/* set sheet visibility (visible/hidden/very hidden) */\nfunction book_set_sheet_visibility(wb /*:Workbook*/, sh /*:number|string*/, vis /*:number*/) {\n if (!wb.Workbook) wb.Workbook = {};\n if (!wb.Workbook.Sheets) wb.Workbook.Sheets = [];\n var idx = wb_sheet_idx(wb, sh);\n // $FlowIgnore\n if (!wb.Workbook.Sheets[idx]) wb.Workbook.Sheets[idx] = {};\n switch (vis) {\n case 0:\n case 1:\n case 2:\n break;\n default:\n throw new Error(\"Bad sheet visibility setting \" + vis);\n }\n // $FlowIgnore\n wb.Workbook.Sheets[idx].Hidden = vis;\n}\n\n/* set number format */\nfunction cell_set_number_format(cell /*:Cell*/, fmt /*:string|number*/) {\n cell.z = fmt;\n return cell;\n}\n\n/* set cell hyperlink */\nfunction cell_set_hyperlink(cell /*:Cell*/, target /*:string*/, tooltip /*:?string*/) {\n if (!target) {\n delete cell.l;\n } else {\n cell.l = {\n Target: target\n } /*:Hyperlink*/;\n if (tooltip) cell.l.Tooltip = tooltip;\n }\n return cell;\n}\nfunction cell_set_internal_link(cell /*:Cell*/, range /*:string*/, tooltip /*:?string*/) {\n return cell_set_hyperlink(cell, \"#\" + range, tooltip);\n}\n\n/* add to cell comments */\nfunction cell_add_comment(cell /*:Cell*/, text /*:string*/, author /*:?string*/) {\n if (!cell.c) cell.c = [];\n cell.c.push({\n t: text,\n a: author || \"SheetJS\"\n });\n}\n\n/* set array formula and flush related cells */\nfunction sheet_set_array_formula(ws /*:Worksheet*/, range, formula /*:string*/, dynamic /*:boolean*/) {\n var rng = typeof range != \"string\" ? range : safe_decode_range(range);\n var rngstr = typeof range == \"string\" ? range : encode_range(range);\n for (var R = rng.s.r; R <= rng.e.r; ++R) for (var C = rng.s.c; C <= rng.e.c; ++C) {\n var cell = ws_get_cell_stub(ws, R, C);\n cell.t = 'n';\n cell.F = rngstr;\n delete cell.v;\n if (R == rng.s.r && C == rng.s.c) {\n cell.f = formula;\n if (dynamic) cell.D = true;\n }\n }\n return ws;\n}\nvar utils /*:any*/ = {\n encode_col: encode_col,\n encode_row: encode_row,\n encode_cell: encode_cell,\n encode_range: encode_range,\n decode_col: decode_col,\n decode_row: decode_row,\n split_cell: split_cell,\n decode_cell: decode_cell,\n decode_range: decode_range,\n format_cell: format_cell,\n sheet_add_aoa: sheet_add_aoa,\n sheet_add_json: sheet_add_json,\n sheet_add_dom: sheet_add_dom,\n aoa_to_sheet: aoa_to_sheet,\n json_to_sheet: json_to_sheet,\n table_to_sheet: parse_dom_table,\n table_to_book: table_to_book,\n sheet_to_csv: sheet_to_csv,\n sheet_to_txt: sheet_to_txt,\n sheet_to_json: sheet_to_json,\n sheet_to_html: sheet_to_html,\n sheet_to_formulae: sheet_to_formulae,\n sheet_to_row_object_array: sheet_to_json,\n sheet_get_cell: ws_get_cell_stub,\n book_new: book_new,\n book_append_sheet: book_append_sheet,\n book_set_sheet_visibility: book_set_sheet_visibility,\n cell_set_number_format: cell_set_number_format,\n cell_set_hyperlink: cell_set_hyperlink,\n cell_set_internal_link: cell_set_internal_link,\n cell_add_comment: cell_add_comment,\n sheet_set_array_formula: sheet_set_array_formula,\n consts: {\n SHEET_VISIBLE: 0,\n SHEET_HIDDEN: 1,\n SHEET_VERY_HIDDEN: 2\n }\n};\nvar _Readable;\nfunction set_readable(R) {\n _Readable = R;\n}\nfunction write_csv_stream(sheet /*:Worksheet*/, opts /*:?Sheet2CSVOpts*/) {\n var stream = _Readable();\n var o = opts == null ? {} : opts;\n if (sheet == null || sheet[\"!ref\"] == null) {\n stream.push(null);\n return stream;\n }\n var r = safe_decode_range(sheet[\"!ref\"]);\n var FS = o.FS !== undefined ? o.FS : \",\",\n fs = FS.charCodeAt(0);\n var RS = o.RS !== undefined ? o.RS : \"\\n\",\n rs = RS.charCodeAt(0);\n var endregex = new RegExp((FS == \"|\" ? \"\\\\|\" : FS) + \"+$\");\n var row /*:?string*/ = \"\",\n cols /*:Array*/ = [];\n o.dense = Array.isArray(sheet);\n var colinfo /*:Array*/ = o.skipHidden && sheet[\"!cols\"] || [];\n var rowinfo /*:Array*/ = o.skipHidden && sheet[\"!rows\"] || [];\n for (var C = r.s.c; C <= r.e.c; ++C) if (!(colinfo[C] || {}).hidden) cols[C] = encode_col(C);\n var R = r.s.r;\n var BOM = false,\n w = 0;\n stream._read = function () {\n if (!BOM) {\n BOM = true;\n return stream.push(\"\\uFEFF\");\n }\n while (R <= r.e.r) {\n ++R;\n if ((rowinfo[R - 1] || {}).hidden) continue;\n row = make_csv_row(sheet, r, R - 1, cols, fs, rs, FS, o);\n if (row != null) {\n if (o.strip) row = row.replace(endregex, \"\");\n if (row || o.blankrows !== false) return stream.push((w++ ? RS : \"\") + row);\n }\n }\n return stream.push(null);\n };\n return stream;\n}\nfunction write_html_stream(ws /*:Worksheet*/, opts /*:?Sheet2HTMLOpts*/) {\n var stream = _Readable();\n var o = opts || {};\n var header = o.header != null ? o.header : HTML_BEGIN;\n var footer = o.footer != null ? o.footer : HTML_END;\n stream.push(header);\n var r = decode_range(ws['!ref']);\n o.dense = Array.isArray(ws);\n stream.push(make_html_preamble(ws, r, o));\n var R = r.s.r;\n var end = false;\n stream._read = function () {\n if (R > r.e.r) {\n if (!end) {\n end = true;\n stream.push(\"\" + footer);\n }\n return stream.push(null);\n }\n while (R <= r.e.r) {\n stream.push(make_html_row(ws, r, R, o));\n ++R;\n break;\n }\n };\n return stream;\n}\nfunction write_json_stream(sheet /*:Worksheet*/, opts /*:?Sheet2CSVOpts*/) {\n var stream = _Readable({\n objectMode: true\n });\n if (sheet == null || sheet[\"!ref\"] == null) {\n stream.push(null);\n return stream;\n }\n var val = {\n t: 'n',\n v: 0\n },\n header = 0,\n offset = 1,\n hdr /*:Array*/ = [],\n v = 0,\n vv = \"\";\n var r = {\n s: {\n r: 0,\n c: 0\n },\n e: {\n r: 0,\n c: 0\n }\n };\n var o = opts || {};\n var range = o.range != null ? o.range : sheet[\"!ref\"];\n if (o.header === 1) header = 1;else if (o.header === \"A\") header = 2;else if (Array.isArray(o.header)) header = 3;\n switch (typeof range) {\n case 'string':\n r = safe_decode_range(range);\n break;\n case 'number':\n r = safe_decode_range(sheet[\"!ref\"]);\n r.s.r = range;\n break;\n default:\n r = range;\n }\n if (header > 0) offset = 0;\n var rr = encode_row(r.s.r);\n var cols /*:Array*/ = [];\n var counter = 0;\n var dense = Array.isArray(sheet);\n var R = r.s.r,\n C = 0;\n var header_cnt = {};\n if (dense && !sheet[R]) sheet[R] = [];\n var colinfo /*:Array*/ = o.skipHidden && sheet[\"!cols\"] || [];\n var rowinfo /*:Array*/ = o.skipHidden && sheet[\"!rows\"] || [];\n for (C = r.s.c; C <= r.e.c; ++C) {\n if ((colinfo[C] || {}).hidden) continue;\n cols[C] = encode_col(C);\n val = dense ? sheet[R][C] : sheet[cols[C] + rr];\n switch (header) {\n case 1:\n hdr[C] = C - r.s.c;\n break;\n case 2:\n hdr[C] = cols[C];\n break;\n case 3:\n hdr[C] = o.header[C - r.s.c];\n break;\n default:\n if (val == null) val = {\n w: \"__EMPTY\",\n t: \"s\"\n };\n vv = v = format_cell(val, null, o);\n counter = header_cnt[v] || 0;\n if (!counter) header_cnt[v] = 1;else {\n do {\n vv = v + \"_\" + counter++;\n } while (header_cnt[vv]);\n header_cnt[v] = counter;\n header_cnt[vv] = 1;\n }\n hdr[C] = vv;\n }\n }\n R = r.s.r + offset;\n stream._read = function () {\n while (R <= r.e.r) {\n if ((rowinfo[R - 1] || {}).hidden) continue;\n var row = make_json_row(sheet, r, R, cols, header, hdr, dense, o);\n ++R;\n if (row.isempty === false || (header === 1 ? o.blankrows !== false : !!o.blankrows)) {\n stream.push(row.row);\n return;\n }\n }\n return stream.push(null);\n };\n return stream;\n}\nvar __stream = {\n to_json: write_json_stream,\n to_html: write_html_stream,\n to_csv: write_csv_stream,\n set_readable: set_readable\n};\nexport const version = XLSX.version;\nexport { parse_xlscfb, parse_zip, readSync as read, readFileSync as readFile, readFileSync, writeSync as write, writeFileSync as writeFile, writeFileSync, writeFileAsync, writeSyncXLSX as writeXLSX, writeFileSyncXLSX as writeFileXLSX, utils, __stream as stream, SSF, CFB };","import { Injectable } from '@angular/core';\r\nimport * as XLSX from 'xlsx';\r\nimport { Observable, Observer } from 'rxjs';\r\nimport { Cells } from '../models/utils/cells.model';\r\nimport moment from 'moment';\r\n\r\n@Injectable({\r\n providedIn: 'root',\r\n})\r\nexport class ExportService {\r\n constructor() {}\r\n\r\n importTo(file: any, column: any[]): Observable {\r\n var reader = new FileReader();\r\n return new Observable((obs: Observer) => {\r\n reader.readAsArrayBuffer(file);\r\n reader.onload = (event) => {\r\n let fileBuffer = reader.result;\r\n const workbook = XLSX.read(fileBuffer, {});\r\n const worksheet = workbook.Sheets[workbook.SheetNames[0]];\r\n var worksheetNameList = workbook.SheetNames;\r\n let columnHeaders = [];\r\n for (\r\n var sheetIndex = 0;\r\n sheetIndex < worksheetNameList.length;\r\n sheetIndex++\r\n ) {\r\n var workSheet = workbook.Sheets[worksheetNameList[sheetIndex]];\r\n for (let key in workSheet) {\r\n let regEx = new RegExp('^(\\\\w)(1){1}$');\r\n if (regEx.test(key) == true) {\r\n columnHeaders.push(workSheet[key].v);\r\n }\r\n }\r\n }\r\n const columns = this.getKeyColumns(column, columnHeaders);\r\n const jsonArray = XLSX.utils.sheet_to_json(worksheet, {\r\n range: 1,\r\n raw: true,\r\n header: columns,\r\n defval: '',\r\n });\r\n obs.next(jsonArray);\r\n obs.complete();\r\n };\r\n reader.onerror = () => {\r\n const { name } = file;\r\n obs.error({\r\n error: { name, errorMessage: 'Ocorreu um erro na importação!' },\r\n });\r\n };\r\n });\r\n }\r\n\r\n exportTo(\r\n value: any,\r\n column: any[],\r\n sheetName: string,\r\n fmt: string,\r\n comments: Cells[] | null = null\r\n ) {\r\n const stringify = JSON.stringify(value);\r\n const data = JSON.parse(stringify);\r\n const columns = this.getColumns(column);\r\n\r\n const worksheet = XLSX.utils.json_to_sheet(data);\r\n\r\n /* fix headers */\r\n XLSX.utils.sheet_add_aoa(worksheet, [columns], { origin: 'A1' });\r\n\r\n /* calculate column width */\r\n worksheet['!cols'] = this.fitToColumn(data, columns);\r\n\r\n if (comments) {\r\n comments.forEach((c: Cells) => {\r\n /* get cell A1, creating an empty cell if necessary */\r\n var cell = worksheet[c.cell];\r\n if (!worksheet[c.cell]) worksheet[c.cell] = { t: c.t };\r\n\r\n /* create comment array if it does not exist */\r\n if (!cell.c) cell.c = [];\r\n\r\n /* create a comment part */\r\n var comment_part = {\r\n a: c.a,\r\n t: c.t,\r\n };\r\n\r\n /* Add comment part to the comment array */\r\n cell.c.push(comment_part);\r\n });\r\n }\r\n\r\n const workbook = XLSX.utils.book_new();\r\n XLSX.utils.book_append_sheet(workbook, worksheet, sheetName);\r\n XLSX.writeFile(\r\n workbook,\r\n `export-beneficiarios-${moment().format('YYYYMMDDhhmmss')}.${fmt}`\r\n );\r\n }\r\n\r\n private fitToColumn(data: any, columns:any) {\r\n let objectMaxLength: any[] = [];\r\n for (let i = 0; i < data.length; i++) {\r\n let value = Object.values(data[i]);\r\n for (let j = 0; j < value.length; j++) {\r\n if (value[j]) {\r\n objectMaxLength[j] =\r\n objectMaxLength[j] >= value[j].length\r\n ? Math.max(objectMaxLength[j])\r\n : columns[j].length >= value[j].length\r\n ? Math.max(columns[j].length + 1) : Math.max(value[j].length + 1);\r\n }\r\n }\r\n }\r\n return objectMaxLength.map((m) => ({ wch: m }));\r\n }\r\n\r\n private getColumns(data: any[]): string[] {\r\n const columns: any[] = [];\r\n data.forEach((col) => {\r\n if (!columns.includes(col.value)) {\r\n columns.push(col.value);\r\n }\r\n });\r\n return columns;\r\n }\r\n\r\n private getKeyColumns(data: any[], ref: any[]): string[] {\r\n const columns: any[] = [];\r\n ref.forEach((col) => {\r\n const index = data.findIndex((f) => f.value === col);\r\n if (index >= 0 && !columns.includes(data[index].key)) {\r\n columns.push(data[index].key);\r\n }\r\n });\r\n return columns;\r\n }\r\n}\r\n","import { UntypedFormGroup } from \"@angular/forms\";\r\nimport { ValidationResult } from \"src/app/ui/models/domains/validator/validation-result\";\r\nimport \"moment/locale/pt-br\";\r\nimport moment from 'moment';\r\nimport { SocialNumber } from \"src/app/ui/models/domains/pbm/social-number.model\";\r\n\r\nexport class SaveBeneficiaryValidator {\r\n public validationResult = new ValidationResult();\r\n\r\n constructor(private registrationBeneficiaryForm: UntypedFormGroup) {}\r\n\r\n getValidationResult(): ValidationResult {\r\n return this.validationResult;\r\n }\r\n\r\n validate(): ValidationResult {\r\n const name = this.registrationBeneficiaryForm.get(\"name\").value;\r\n const socialNumber = this.registrationBeneficiaryForm.get(\"socialNumber\").value;\r\n const admissionDate = this.registrationBeneficiaryForm.get(\"admissionDate\").value;\r\n const birthDate = this.registrationBeneficiaryForm.get(\"birthDate\").value;\r\n const gender = this.registrationBeneficiaryForm.get(\"gender\").value;\r\n const maritalStatus = this.registrationBeneficiaryForm.get(\"maritalStatus\").value;\r\n const email = this.registrationBeneficiaryForm.get(\"email\").value;\r\n const region = this.registrationBeneficiaryForm.get(\"region\").value;\r\n const city = this.registrationBeneficiaryForm.get(\"city\").value;\r\n const district = this.registrationBeneficiaryForm.get(\"district\").value;\r\n const needValidateEmail = this.registrationBeneficiaryForm.get(\"needValidateEmail\").value;\r\n const enableDelivery = this.registrationBeneficiaryForm.get(\"enableDelivery\").value;\r\n const transactionalPassword = this.registrationBeneficiaryForm.get(\"transactionalPassword\").value;\r\n const confirmTransactionalPassword = this.registrationBeneficiaryForm.get(\"confirmTransactionalPassword\").value;\r\n const changePassword = this.registrationBeneficiaryForm.get(\"changePassword\").value;\r\n const passwordPattern = /^([0-9]){6}$/;\r\n const emailRegex =\r\n /^(([^<>()\\[\\]\\\\.,;:\\s@\"]+(\\.[^<>()\\[\\]\\\\.,;:\\s@\"]+)*)|(\".+\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/;\r\n\r\n if (!name) {\r\n this.validationResult.addErrorMessage(\"É necessário inserir um nome\");\r\n } else if (!socialNumber) {\r\n this.validationResult.addErrorMessage(\"É necessário inserir um CPF\");\r\n } else if (!SocialNumber.isValid(socialNumber)) {\r\n this.validationResult.addErrorMessage(\"CPF inválido\");\r\n } else if (gender === null) {\r\n this.validationResult.addErrorMessage(\"É necessário selecionar um Sexo\");\r\n } else if (maritalStatus === null) {\r\n this.validationResult.addErrorMessage(\"É necessário selecionar um Estado Civil\");\r\n } else if (!region) {\r\n this.validationResult.addErrorMessage(\"É necessário inserir um Estado\");\r\n } else if (!city) {\r\n this.validationResult.addErrorMessage(\"É necessário inserir uma Cidade\");\r\n } else if (!district) {\r\n this.validationResult.addErrorMessage(\"É necessário inserir um Bairro\");\r\n } else if (!!admissionDate && !moment(admissionDate, \"DDMMYYYY\").isValid()) {\r\n this.validationResult.addErrorMessage(\"Data de admissão inválida\");\r\n } else if (!!birthDate && !moment(birthDate, \"DDMMYYYY\").isValid()) {\r\n this.validationResult.addErrorMessage(\"Data de nascimento inválida\");\r\n } else if (needValidateEmail && !email) {\r\n this.validationResult.addErrorMessage(\"É necessário inserir um E-mail\");\r\n } else if (email && !emailRegex.test(email.toLowerCase())) {\r\n this.validationResult.addErrorMessage(\"E-mail inválido\");\r\n } else if (changePassword === true) {\r\n if (!passwordPattern.test(transactionalPassword)) {\r\n if (transactionalPassword == null || !transactionalPassword) {\r\n this.validationResult.addErrorMessage(\"Preencha os campos senha e confirma senha\");\r\n } else {\r\n if (transactionalPassword.length !== 6) {\r\n this.validationResult.addErrorMessage(\"A senha deve conter seis digitos\");\r\n }\r\n if (confirmTransactionalPassword.length !== 6 || confirmTransactionalPassword == null) {\r\n this.validationResult.addErrorMessage(\"A senha deve conter seis digitos\");\r\n }\r\n }\r\n }\r\n\r\n if (!passwordPattern.test(confirmTransactionalPassword)) {\r\n if (confirmTransactionalPassword == null || !confirmTransactionalPassword) {\r\n this.validationResult.addErrorMessage(\"Preencha os campos senha e confirma senha\");\r\n } else {\r\n if (transactionalPassword.length !== 6) {\r\n this.validationResult.addErrorMessage(\"A senha deve conter seis digitos\");\r\n }\r\n if (confirmTransactionalPassword.length !== 6 || confirmTransactionalPassword == null) {\r\n this.validationResult.addErrorMessage(\"A senha deve conter seis digitos\");\r\n }\r\n }\r\n }\r\n\r\n if (transactionalPassword !== confirmTransactionalPassword) {\r\n this.validationResult.addErrorMessage(\"A senha e a confirmação de senha precisam ser idênticas\");\r\n }\r\n }\r\n return this.validationResult;\r\n }\r\n\r\n public validateAdmissionDate(): string {\r\n if (!this.registrationBeneficiaryForm.get(\"admissionDate\").value) {\r\n return \"\";\r\n } else {\r\n return this.registrationBeneficiaryForm.get(\"admissionDate\").value;\r\n }\r\n }\r\n\r\n public validateBirthDate(): string {\r\n if (!this.registrationBeneficiaryForm.get(\"birthDate\").value) {\r\n return \"\";\r\n } else {\r\n return this.registrationBeneficiaryForm.get(\"birthDate\").value;\r\n }\r\n }\r\n\r\n public validateTelephone(): string {\r\n if (!this.registrationBeneficiaryForm.get(\"telephone\").value) {\r\n return \"\";\r\n } else {\r\n return this.registrationBeneficiaryForm.get(\"telephone\").value;\r\n }\r\n }\r\n\r\n public validateMobile(): string {\r\n if (!this.registrationBeneficiaryForm.get(\"mobile\").value) {\r\n return \"\";\r\n } else {\r\n return this.registrationBeneficiaryForm.get(\"mobile\").value;\r\n }\r\n }\r\n\r\n public validateZipCode(): string {\r\n if (!this.registrationBeneficiaryForm.get(\"zipCode\").value) {\r\n return \"\";\r\n } else {\r\n return this.registrationBeneficiaryForm.get(\"zipCode\").value;\r\n }\r\n }\r\n}\r\n","import { BeneficiaryKey } from \"../../Benefit/beneficiary-key\";\r\n\r\nexport class CardBlockDTO {\r\n constructor(private readonly beneficiaryKey: BeneficiaryKey, private readonly blockReason: string, private readonly includeDependents: boolean) {}\r\n\r\n getBeneficiaryKey(): BeneficiaryKey {\r\n return this.beneficiaryKey;\r\n }\r\n\r\n getBlockReason(): string {\r\n return this.blockReason;\r\n }\r\n\r\n getIncludeDependents(): boolean {\r\n return this.includeDependents;\r\n }\r\n}\r\n","import { Component, EventEmitter, Inject, OnInit } from \"@angular/core\";\r\nimport { UntypedFormBuilder, UntypedFormGroup, Validators } from \"@angular/forms\";\r\n\r\nimport { Beneficiary } from \"src/app/ui/models/domains/pbm/Beneficiary/beneficiary\";\r\nimport { BlockCardReason } from \"src/app/ui/models/domains/pbm/Beneficiary/block-card-reason\";\r\nimport { CardBlockDTO } from \"src/app/ui/models/domains/pbm/Beneficiary/dto/card-block-dto\";\r\nimport { Dependent } from \"src/app/ui/models/domains/pbm/Beneficiary/dependent\";\r\nimport { LoadingService } from \"src/app/ui/services/loading.service\";\r\nimport { BeneficiaryService } from \"src/app/ui/services/pbm/beneficiary.service\";\r\nimport { Toast } from \"../../../../toast/toast\";\r\nimport { MatDialogRef, MAT_DIALOG_DATA } from \"@angular/material/dialog\";\r\n\r\n@Component({\r\n templateUrl: \"./card-block-dialog.component.html\",\r\n styleUrls: [\"./card-block-dialog.component.scss\"],\r\n})\r\nexport class CardBlockDialogComponent implements OnInit {\r\n blockCardNumberEvent: EventEmitter = new EventEmitter();\r\n\r\n formGroup: UntypedFormGroup = this.formBuilder.group({\r\n blockReason: [\"\", Validators.required],\r\n includeDependents: [false],\r\n });\r\n\r\n blockReasonList: BlockCardReason[] = [];\r\n\r\n constructor(\r\n public dialogRef: MatDialogRef,\r\n @Inject(MAT_DIALOG_DATA) public data: Beneficiary | Dependent,\r\n public beneficiaryService: BeneficiaryService,\r\n public formBuilder: UntypedFormBuilder,\r\n private loadingService: LoadingService,\r\n private toast: Toast,\r\n ) {}\r\n\r\n async ngOnInit() {\r\n this.blockReasonList = await this.beneficiaryService.getBlockReasonList();\r\n }\r\n\r\n closeDialog(): void {\r\n this.dialogRef.close();\r\n }\r\n\r\n async blockBeneficiaryCard(): Promise {\r\n const loadingRef = this.loadingService.beginLoading();\r\n\r\n try {\r\n const cardBlockDTO = this.buildCardBlockDTO();\r\n await this.beneficiaryService.blockBeneficiaryCard(cardBlockDTO);\r\n this.toast.showSuccessToast(\"Cartão bloqueado com sucesso.\");\r\n this.blockCardNumberEvent.emit(this.data);\r\n this.closeDialog();\r\n } catch (err) {\r\n this.toast.showWarningToast(\"Erro ao bloquear cartão.\");\r\n } finally {\r\n loadingRef.closeLoading();\r\n }\r\n }\r\n\r\n private buildCardBlockDTO(): CardBlockDTO {\r\n const beneficiaryKey = this.data.getBeneficiaryKey();\r\n const blockReason = this.formGroup.get(\"blockReason\").value;\r\n const includeDependents = this.formGroup.get(\"includeDependents\").value;\r\n\r\n return new CardBlockDTO(beneficiaryKey, blockReason, includeDependents);\r\n }\r\n\r\n public isBeneficiary(): boolean {\r\n return this.data instanceof Beneficiary;\r\n }\r\n\r\n public getName(): string {\r\n return this.data.getName();\r\n }\r\n\r\n public getCardNumber(): string {\r\n return this.data.getCard().getCardNumber();\r\n }\r\n}\r\n","
\r\n

BLOQUEIO DE CARTÃO

\r\n
\r\n\r\n
\r\n
\r\n
\r\n

{{ isBeneficiary() ? \"Beneficiário\" : \"Dependente\" }}

\r\n

{{ getName() }}

\r\n
\r\n\r\n
\r\n

Número do cartão

\r\n

{{ getCardNumber() | cardNumberFormat }}

\r\n
\r\n
\r\n\r\n
\r\n \r\n Motivo do bloqueio\r\n \r\n {{ reason.getLocalizedName() }}\r\n \r\n \r\n\r\n Incluir dependentes no bloqueio?\r\n
\r\n
\r\n\r\n
\r\n \r\n\r\n \r\n
\r\n","import { AbstractControl, ValidationErrors, ValidatorFn } from \"@angular/forms\";\r\nimport moment from 'moment';\r\n\r\nexport class CustomValidators {\r\n static passwordValidator(): ValidatorFn {\r\n return (control: AbstractControl): ValidationErrors | null => {\r\n const text = control.value;\r\n\r\n if (!text) {\r\n return null;\r\n }\r\n\r\n const hasUpperCase = (value: string) => /[A-Z]+/.test(value);\r\n const hasNumber = (value: string) => /[0-9]+/.test(value);\r\n const hasSpecialCharacters = (value: string) => /[#?!@$%^&*-]/g.test(value);\r\n\r\n if (hasUpperCase(text) && hasSpecialCharacters(text) && hasNumber(text)) {\r\n return null;\r\n } else {\r\n return { passwordValid: true };\r\n }\r\n };\r\n }\r\n\r\n static emailValidator(): ValidatorFn {\r\n return (control: AbstractControl): ValidationErrors | null => {\r\n if (!/^[\\w-\\.]+@([\\w-]+\\.)+[\\w-]{2,4}$/.test(control.value)) {\r\n return { \"invalid e-mail\": true };\r\n }\r\n return null;\r\n };\r\n }\r\n\r\n static mustMatch(index: string): ValidatorFn {\r\n return (control: AbstractControl): ValidationErrors | null => {\r\n const text = control.value;\r\n\r\n if (!text) {\r\n return null;\r\n } else if (control.parent && control.parent.value[index] === text) {\r\n return null;\r\n } else {\r\n return { confirmPasswordValid: true };\r\n }\r\n };\r\n }\r\n\r\n static phoneValidator(): ValidatorFn {\r\n return (control: AbstractControl): ValidationErrors | null => {\r\n if (!/(\\((?!00)[1-9]{2}\\)[\\s\\d](\\d{5}-\\d{4}))/i.test(control.value)) {\r\n return { \"invalid phone\": true };\r\n }\r\n };\r\n }\r\n\r\n static nameValidator(): ValidatorFn {\r\n return (control: AbstractControl): ValidationErrors | null => {\r\n if (!/^[a-z\\u00C0-\\u02AB'´`]+( [a-z\\u00C0-\\u02AB'´`]+)*$/i.test(control.value)) {\r\n return { \"invalid name\": true };\r\n }\r\n\r\n return null;\r\n };\r\n }\r\n\r\n static percentValidator(): ValidatorFn {\r\n return (control: AbstractControl): ValidationErrors | null => {\r\n let number = control.value.toString();\r\n\r\n if (number === \"\" || number === null || number === undefined) {\r\n return { \"invalid percent\": true };\r\n }\r\n\r\n number = number.replace(/,/g, \".\");\r\n\r\n if (number.split(\".\").length > 2) {\r\n return { \"invalid percent\": true };\r\n }\r\n\r\n if (isNaN(number) || number > 100 || number < 0) {\r\n return { \"invalid percent\": true };\r\n }\r\n };\r\n }\r\n\r\n static codeValidator(): ValidatorFn {\r\n return (control: AbstractControl): ValidationErrors | null => {\r\n if (!/(\\d{6})/i.test(control.value)) {\r\n return { \"invalid code\": true };\r\n }\r\n };\r\n }\r\n\r\n static dateValidator(): ValidatorFn {\r\n return (control: AbstractControl): ValidationErrors | null => {\r\n moment.locale(\"pt-br\");\r\n const userDateInput = moment(control.value, \"DD/MM/YYYY\", true);\r\n\r\n if (!userDateInput.isValid()) {\r\n return { \"invalid date\": true };\r\n }\r\n };\r\n }\r\n\r\n static hoursAndMinutesValidator(): ValidatorFn {\r\n return (control: AbstractControl): ValidationErrors | null => {\r\n const value = control.value;\r\n if (!value) return { invalid: true };\r\n\r\n const hour = parseInt(value.substring(0, 2));\r\n const minute = parseInt(value.substring(3, 5));\r\n if (hour > 23 || minute > 59) {\r\n return { invalid: true };\r\n }\r\n };\r\n }\r\n}\r\n","import { Component, Inject } from \"@angular/core\";\r\nimport { MatDialogRef, MAT_DIALOG_DATA } from \"@angular/material/dialog\";\r\nimport { Beneficiary } from \"src/app/ui/models/domains/pbm/Beneficiary/beneficiary\";\r\nimport { Company } from \"src/app/ui/models/domains/pbm/companies/company\";\r\n\r\n@Component({\r\n templateUrl: \"./vinculated-socialnumber-dialog.component.html\",\r\n styleUrls: [\"./vinculated-socialnumber-dialog.component.scss\"],\r\n})\r\nexport class VinculatedSocialnumberDialogComponent {\r\n beneficiary: Beneficiary;\r\n companies: Company[] = [];\r\n\r\n constructor(\r\n private dialogRef: MatDialogRef,\r\n @Inject(MAT_DIALOG_DATA) public data: any\r\n ) {\r\n if (data && data.beneficiary) {\r\n this.beneficiary = data.beneficiary;\r\n this.companies = data.beneficiary.getCompany();\r\n }\r\n }\r\n\r\n hasCompany(): boolean {\r\n return this.companies.length > 0;\r\n }\r\n\r\n close() {\r\n this.dialogRef.close(true);\r\n }\r\n}\r\n","
\r\n
\r\n

\r\n {{ beneficiary ? \"CPF já vinculado\" : \"CPF não vinculado\" }}\r\n \r\n

\r\n
\r\n
\r\n

{{ beneficiary ? \"O CPF já está cadastrado no portal.\" : \"O CPF ainda não foi cadastrado no portal.\" }}

\r\n

Vinculado na(s) empresa(s):

\r\n
    \r\n
  • \r\n
    \r\n {{ company.getCorporateName() }}\r\n CNPJ: {{ company.getFiscalNumber() | companyFederalNumber }} \r\n
    \r\n
  • \r\n
\r\n
\r\n
\r\n","import { Injectable } from \"@angular/core\";\r\nimport { City } from \"../../models/domains/pbm/state/city\";\r\nimport { StateAcronym } from \"../../models/domains/pbm/state/state-acronym\";\r\nimport { StateRepository } from \"../../repositories/pbm/state.repository\";\r\nimport { ZipCodeIntegration } from \"../../models/domains/pbm/state/zip-code-integration.model.ts\";\r\n\r\n@Injectable({ providedIn: \"root\" })\r\nexport class StateService {\r\n constructor(private stateRepository: StateRepository) {}\r\n\r\n public async getStates(): Promise {\r\n return await this.stateRepository.getStates();\r\n }\r\n\r\n public async getCityByStateAcronym(stateAcronym: StateAcronym): Promise {\r\n return await this.stateRepository.getCityByStateAcronym(stateAcronym);\r\n }\r\n\r\n public async getZipCodeIntegration(zipCode: string): Promise {\r\n return await Promise.resolve(this.stateRepository.getZipCode(zipCode));\r\n }\r\n}\r\n","import { UntypedFormGroup, UntypedFormBuilder, Validators } from \"@angular/forms\";\r\nimport { Component, OnInit } from \"@angular/core\";\r\nimport { FeatureViews } from \"src/app/ui/models/domains/features/custom-feature-views\";\r\nimport { PageViews } from \"src/app/ui/models/domains/features/custom-page-views\";\r\nimport { FeatureViewService } from \"src/app/ui/services/feature-view.service\";\r\nimport { MaskInput } from \"src/app/ui/models/domains/masks/mask.model\";\r\nimport { LoadingService } from \"src/app/ui/services/loading.service\";\r\nimport { CompanyService } from \"src/app/ui/services/pbm/company.service\";\r\nimport { BeneficiaryService } from \"src/app/ui/services/pbm/beneficiary.service\";\r\nimport { Company } from \"src/app/ui/models/domains/pbm/companies/company\";\r\nimport { Dependent } from \"src/app/ui/models/domains/pbm/Beneficiary/dependent\";\r\nimport { FormDirty } from \"src/app/ui/models/utils/form-dirty.utils\";\r\nimport { Gender, MaritalStatus } from \"src/app/ui/models/domains/pbm/Beneficiary/person\";\r\nimport { SaveBeneficiaryValidator } from \"../validators/save-beneficiary-validator\";\r\nimport { Beneficiary } from \"src/app/ui/models/domains/pbm/Beneficiary/beneficiary\";\r\nimport { Address } from \"src/app/ui/models/domains/pbm/companies/address\";\r\nimport { BeneficiaryKey } from \"src/app/ui/models/domains/pbm/Benefit/beneficiary-key\";\r\nimport { GenderType } from \"src/app/ui/models/domains/pbm/Beneficiary/gender-type\";\r\nimport { Toast } from \"../../../toast/toast\";\r\nimport { Employee } from \"src/app/ui/models/domains/pbm/Beneficiary/employee\";\r\nimport { Card } from \"src/app/ui/models/domains/pbm/Beneficiary/card\";\r\nimport { StateAcronym } from \"src/app/ui/models/domains/pbm/state/state-acronym\";\r\nimport { StateService } from \"src/app/ui/services/pbm/state.service\";\r\nimport { City } from \"src/app/ui/models/domains/pbm/state/city\";\r\nimport { UserService } from \"src/app/ui/services/user.service\";\r\nimport { RoutePath } from \"src/app/ui/models/domains/route-paths.model\";\r\nimport { Router } from \"@angular/router\";\r\nimport { CardBlockDialogComponent } from \"../dialogs/card-block-dialog/card-block-dialog.component\";\r\nimport { JobDescription } from \"src/app/ui/models/domains/pbm/Beneficiary/job-description\";\r\nimport { AddJobDescriptionDialog } from \"../../shared/dialogs/add-job-description-dialog/add-job-description-dialog.component\";\r\nimport { JobDescriptionService } from \"src/app/ui/services/pbm/job-description.service\";\r\nimport { JobDescriptionDialogType } from \"../../shared/dialogs/add-job-description-dialog/add-job-description-dialog.enum\";\r\nimport { PageableResult } from \"src/app/ui/models/domains/paginator/pageable-result\";\r\nimport { AppContext } from \"src/app/ui/contexts/app-context\";\r\nimport { PagingRequest } from \"src/app/ui/models/domains/paginator/paging-request\";\r\nimport { UntypedFormControl } from \"@angular/forms\";\r\nimport { ICompanyFilterParams } from \"src/app/ui/models/domains/pbm/companies/company-filter-params\";\r\nimport { CustomValidators } from \"src/app/ui/models/domains/pbm/custom-validators\";\r\nimport { VinculatedSocialnumberDialogComponent } from \"./vinculated-socialnumber/vinculated-socialnumber-dialog.component\";\r\nimport { MatDialogRef, MatDialog } from \"@angular/material/dialog\";\r\nimport { MatSlideToggle } from \"@angular/material/slide-toggle\";\r\n\r\n@Component({\r\n selector: \"app-registration-beneficiary\",\r\n templateUrl: \"./registration-beneficiary.component.html\",\r\n styleUrls: [\"./registration-beneficiary.component.scss\"],\r\n})\r\nexport class RegistrationBeneficiaryComponent implements OnInit {\r\n public region: string = \"\";\r\n public city: string = \"\";\r\n public filterText: string;\r\n private company: Company;\r\n private beneficiary: Beneficiary;\r\n private selectedTabIndex = 0;\r\n private formDirty = new FormDirty();\r\n private jobDescriptionList: JobDescription[] = [];\r\n private stateList: StateAcronym[] = [];\r\n private cityList: City[] = [];\r\n private cardBlockDialogRef: MatDialogRef;\r\n private addJobDescriptionRef: MatDialogRef;\r\n public companyPageableResult = new PageableResult();\r\n private searchCompanyFirst: boolean;\r\n private userProfile = this.userService.getUserProfile();\r\n\r\n public fiscalNumberMask = MaskInput.getFicalNumberMask();\r\n public socialNumberMask = MaskInput.getSocialNumberMask();\r\n public dateMask = MaskInput.getDateMask();\r\n public zipCodeMask = MaskInput.getZipCodeMask();\r\n public telephoneMask = MaskInput.getTelephoneMask();\r\n public mobileMask = MaskInput.getMobileMask();\r\n\r\n public numericalPasswordMask = MaskInput.getNumericalPassword();\r\n public genderType = GenderType;\r\n public searchType: UntypedFormControl;\r\n\r\n public userNameInputBorder = \"1px white solid\";\r\n public passwordInputBorder = \"1px white solid\";\r\n public passwordInputPlaceholder = \"SENHA:\";\r\n public passwordInputType = \"password\";\r\n public passwordPattern = /^([0-9]){6}$/;\r\n public confirmPasswordInputType = \"password\";\r\n public beneficiaryInfo = null;\r\n public socialNumberFind = '';\r\n\r\n public hidePassword = true;\r\n public alertLogin = false;\r\n public userErrorVisible = false;\r\n public passwordErrorVisible = false;\r\n public showPassword = false;\r\n public showConfirmPassword = false;\r\n\r\n public registrationBeneficiaryForm: UntypedFormGroup = this.formBuilder.group({\r\n beneficiaryKey: [\"\"],\r\n active: [true],\r\n cardNumber: [\"\"],\r\n name: [\"\", Validators.required],\r\n registration: [\"\"],\r\n jobDescription: [\"\"],\r\n admissionDate: [\"\"],\r\n socialNumber: [\"\", Validators.required],\r\n birthDate: [\"\"],\r\n gender: [0, Validators.required],\r\n maritalStatus: [0, Validators.required],\r\n isNewAddress: [false],\r\n street: [\"\"],\r\n number: [\"\"],\r\n complement: [\"\"],\r\n district: [\"\", Validators.required],\r\n city: new UntypedFormControl({ value: this.city }, Validators.required),\r\n region: new UntypedFormControl({ value: this.region }, Validators.required),\r\n zipCode: [\"\"],\r\n email: [\"\", Validators.required],\r\n telephone: [\"\"],\r\n mobile: [\"\"],\r\n needValidateEmail: [false],\r\n changePassword: [false],\r\n transactionalPassword: new UntypedFormControl(\"\", [Validators.pattern(this.passwordPattern), Validators.maxLength(6)]),\r\n confirmTransactionalPassword: new UntypedFormControl(\"\", [\r\n Validators.pattern(this.passwordPattern),\r\n Validators.maxLength(6),\r\n CustomValidators.mustMatch(\"transactionalPassword\"),\r\n ]),\r\n enableDelivery: [false],\r\n });\r\n\r\n constructor(\r\n private featureViewService: FeatureViewService,\r\n private formBuilder: UntypedFormBuilder,\r\n private dialog: MatDialog,\r\n private loadingService: LoadingService,\r\n private companyService: CompanyService,\r\n private beneficiaryService: BeneficiaryService,\r\n private jobDescriptionService: JobDescriptionService,\r\n private toast: Toast,\r\n private stateService: StateService,\r\n private userService: UserService,\r\n private router: Router,\r\n private appContext: AppContext,\r\n ) {\r\n this.searchType = new UntypedFormControl(1);\r\n }\r\n\r\n async ngOnInit() {\r\n this.userProfile = this.userService.getUserProfile();\r\n this.featureViewService.activeFeatureView(FeatureViews.BeneficiaryRegistrationBeneficiaryFeatureView, PageViews.BeneficiaryPageView);\r\n\r\n if (this.userProfile.getPreferences().getFilterText()) {\r\n this.searchCompanies(this.userProfile.getPreferences().getFilterText());\r\n } else {\r\n this.searchCompanies(\"\");\r\n }\r\n this.stateList = await this.stateService.getStates();\r\n\r\n this.disableTransactionalPasswordFields();\r\n }\r\n\r\n private getTabIndex(tabName: string): number {\r\n switch (tabName) {\r\n case \"Cadastrar Beneficiário\":\r\n return 0;\r\n case \"Lista de Dependentes\":\r\n return 1;\r\n default:\r\n return -1;\r\n }\r\n }\r\n\r\n onTabClick(clickEvent: any) {\r\n const clickedTab = clickEvent.target as HTMLDivElement;\r\n const clickedTabIndex = this.getTabIndex(clickedTab.innerText);\r\n if (clickedTabIndex === -1) {\r\n return;\r\n }\r\n if (this.selectedTabIndex !== clickedTabIndex) {\r\n if (this.formDirty.isDirty()) {\r\n alert(\"Os dados foram alterados no formulário. Por favor, salve antes de prosseguir.\");\r\n } else {\r\n this.selectedTabIndex = clickedTabIndex;\r\n }\r\n }\r\n }\r\n public async getZipCode() {\r\n const formValue = this.registrationBeneficiaryForm.get(\"zipCode\").value;\r\n var boolean = /^\\d{5}[-]\\d{3}$/.test(formValue);\r\n\r\n if (boolean) {\r\n const ref = this.loadingService.beginLoading();\r\n this.registrationBeneficiaryForm.get(\"zipCode\").disable();\r\n try {\r\n const zip = await this.stateService.getZipCodeIntegration(formValue);\r\n const state = this.stateList.find((state) => state.getValue() === zip.getStateCode());\r\n this.registrationBeneficiaryForm.get(\"region\").setValue(state);\r\n await this.onStateInputChange();\r\n\r\n const city = this.cityList.find((city) => city.getName() === zip.getLocality());\r\n this.registrationBeneficiaryForm.get(\"city\").setValue(city);\r\n\r\n this.registrationBeneficiaryForm.get(\"street\").setValue(zip.getAddress());\r\n this.registrationBeneficiaryForm.get(\"district\").setValue(zip.getNeighborhood());\r\n } catch (error) {\r\n this.toast.showWarningToast(\"CEP não encontrado.\");\r\n } finally {\r\n this.loadingService.finishLoading(ref);\r\n this.registrationBeneficiaryForm.get(\"zipCode\").enable();\r\n }\r\n }\r\n }\r\n\r\n async searchCompany(company: Company) {\r\n const ref = this.loadingService.beginLoading();\r\n try {\r\n if (!!company.getFiscalNumber()) {\r\n this.company = await this.companyService.findCompanyBy(company.getFiscalNumber());\r\n this.jobDescriptionList = await this.jobDescriptionService.getJobDescription(this.company.getFiscalNumber());\r\n if (!!this.company) {\r\n this.storageSearchPreferences(company.getFiscalNumber());\r\n } else {\r\n this.storageSearchPreferences(null);\r\n }\r\n } else {\r\n this.toast.showWarningToast(\"Insira um CNPJ.\");\r\n }\r\n } catch (erro) {\r\n this.toast.showWarningToast(erro);\r\n this.storageSearchPreferences(null);\r\n } finally {\r\n this.loadingService.finishLoading(ref);\r\n //this.storageSearchPreferences(company.getFiscalNumber());\r\n this.filterText = \"\";\r\n }\r\n }\r\n\r\n async searchBeneficiary() {\r\n const socialNumber = this.registrationBeneficiaryForm.get(\"socialNumber\").value.replace(/[^\\d]+/g, \"\");\r\n if (socialNumber.length === 11 && this.socialNumberFind !== socialNumber && !this.beneficiaryInfo) {\r\n this.socialNumberFind = socialNumber;\r\n this.beneficiaryInfo = await this.searchBeneficiaryBySocialNumber(socialNumber, this.company.getFiscalNumber());\r\n if (this.beneficiaryInfo) {\r\n let message = this.beneficiaryInfo.getCompany().length === 1 ? `Beneficiário já está cadastrado no portal junto à empresa ${this.beneficiaryInfo.getCompany()[0].getCorporateName()}.` : `Beneficiário já está cadastrado no portal em ${this.beneficiaryInfo.getCompany().length} empresas.`;\r\n message += \"\\r\\n Para ver mais detalhes clique no ícone de informação (¡) ao lado do campo CPF.\";\r\n this.toast.showWarningToast(message, \"CPF já vinculado\");\r\n }\r\n } else {\r\n this.beneficiaryInfo = null;\r\n }\r\n }\r\n\r\n private async searchBeneficiaryBySocialNumber(socialNumber: string, fiscalNumber:string) {\r\n const ref = this.loadingService.beginLoading();\r\n try {\r\n return await this.beneficiaryService.findBeneficiaryHolderBySocialNumber(socialNumber, fiscalNumber);\r\n } catch (erro) {\r\n console.error(erro);\r\n this.toast.showWarningToast(`Beneficiário ainda não está cadastrado no portal.`, \"CPF não vinculado\");\r\n } finally {\r\n this.loadingService.finishLoading(ref);\r\n }\r\n }\r\n\r\n openVinculatedDialog() {\r\n const socialNumber = this.registrationBeneficiaryForm.get(\"socialNumber\").value.replace(/[^\\d]+/g, \"\");\r\n if (socialNumber.length === 11 && this.socialNumberFind === socialNumber) {\r\n this.dialog.open(VinculatedSocialnumberDialogComponent, {\r\n id: \"status-dialog\",\r\n disableClose: true,\r\n hasBackdrop: true,\r\n width: \"400px\",\r\n data: { beneficiary: this.beneficiaryInfo },\r\n });\r\n }\r\n }\r\n\r\n hasCompany(): boolean {\r\n return !!this.company;\r\n }\r\n\r\n hasBenficiary(): boolean {\r\n return !!this.beneficiary;\r\n }\r\n\r\n onBeneficiaryInputChange(): void {\r\n this.formDirty.markAsDirty();\r\n }\r\n\r\n getPlaceHolderColor(): string {\r\n return this.passwordErrorVisible ? \"error-placeholder\" : \"default-placeholder\";\r\n }\r\n\r\n setPasswordVisible(): void {\r\n this.showPassword = !this.showPassword;\r\n if (this.showPassword) this.passwordInputType = \"text\";\r\n else this.passwordInputType = \"password\";\r\n }\r\n\r\n setConfirmPasswordVisible(): void {\r\n this.showConfirmPassword = !this.showConfirmPassword;\r\n if (this.showConfirmPassword) this.confirmPasswordInputType = \"text\";\r\n else this.confirmPasswordInputType = \"password\";\r\n }\r\n\r\n enableTransactionalPasswordFields() {\r\n this.registrationBeneficiaryForm.get(\"transactionalPassword\").enable();\r\n this.registrationBeneficiaryForm.get(\"confirmTransactionalPassword\").enable();\r\n }\r\n\r\n disableTransactionalPasswordFields() {\r\n this.registrationBeneficiaryForm.get(\"transactionalPassword\").setValue(null);\r\n this.registrationBeneficiaryForm.get(\"transactionalPassword\").disable();\r\n\r\n this.registrationBeneficiaryForm.get(\"confirmTransactionalPassword\").setValue(null);\r\n this.registrationBeneficiaryForm.get(\"confirmTransactionalPassword\").disable();\r\n }\r\n\r\n async changeDisable(event: MatSlideToggle) {\r\n if (!!event) {\r\n this.registrationBeneficiaryForm.get(\"changePassword\").patchValue(true);\r\n this.enableTransactionalPasswordFields();\r\n } else {\r\n this.registrationBeneficiaryForm.get(\"changePassword\").patchValue(false);\r\n this.disableTransactionalPasswordFields();\r\n }\r\n }\r\n\r\n async onStateInputChange() {\r\n const state = this.registrationBeneficiaryForm.get(\"region\").value;\r\n if (state) {\r\n const ref = this.loadingService.beginLoading();\r\n try {\r\n this.cityList = await this.stateService.getCityByStateAcronym(state);\r\n this.registrationBeneficiaryForm.get(\"city\").enable();\r\n this.registrationBeneficiaryForm.get(\"city\").setValue(0);\r\n } catch (error) {\r\n this.cityList = [];\r\n this.registrationBeneficiaryForm.get(\"city\").disable();\r\n this.toast.showWarningToast(error);\r\n } finally {\r\n this.loadingService.finishLoading(ref);\r\n }\r\n } else {\r\n this.cityList = [];\r\n this.registrationBeneficiaryForm.get(\"city\").setValue(0);\r\n this.registrationBeneficiaryForm.get(\"city\").disable();\r\n }\r\n }\r\n\r\n gotToCreateDependent(): void {\r\n const newDependent = new Dependent();\r\n newDependent.setBeneficiarySocialNumber(this.beneficiary.getSocialNumber());\r\n this.beneficiaryService.setDependent(newDependent);\r\n this.router.navigate([RoutePath.RegistrationDependent]);\r\n }\r\n\r\n goToEditDependent(dependent: Dependent): void {\r\n this.beneficiaryService.setDependent(dependent);\r\n this.router.navigate([RoutePath.EditDependent]);\r\n }\r\n\r\n async saveBenficiary(): Promise {\r\n const ref = this.loadingService.beginLoading();\r\n const saveBeneficiaryValidator = new SaveBeneficiaryValidator(this.registrationBeneficiaryForm);\r\n if (saveBeneficiaryValidator.validate().hasErrorMessages()) {\r\n this.toast.showWarningToast(saveBeneficiaryValidator.getValidationResult().getErrorMessage());\r\n this.loadingService.finishLoading(ref);\r\n } else {\r\n const newBeneficiaryConfiguration = new Beneficiary();\r\n if (this.hasBeneficiaryKey()) {\r\n newBeneficiaryConfiguration.setBeneficiaryKey(this.beneficiary.getBeneficiaryKey());\r\n newBeneficiaryConfiguration.setCard(this.beneficiary.getCard());\r\n } else {\r\n const newBeneficiaryKey = new BeneficiaryKey();\r\n newBeneficiaryKey.setValue(\"\");\r\n newBeneficiaryConfiguration.setBeneficiaryKey(newBeneficiaryKey);\r\n const card = new Card();\r\n card.setCardNumber(\"\");\r\n newBeneficiaryConfiguration.setCard(card);\r\n }\r\n\r\n const employee = new Employee();\r\n employee.setRegistration(this.registrationBeneficiaryForm.get(\"registration\").value);\r\n employee.setAdmissionDate(this.registrationBeneficiaryForm.get(\"admissionDate\").value.replace(/[^\\d]+/g, \"\"));\r\n employee.setJobDescription(this.registrationBeneficiaryForm.get(\"jobDescription\").value);\r\n newBeneficiaryConfiguration.setEmployee(employee);\r\n\r\n newBeneficiaryConfiguration.setName(this.registrationBeneficiaryForm.get(\"name\").value);\r\n newBeneficiaryConfiguration.setSocialNumber(this.registrationBeneficiaryForm.get(\"socialNumber\").value.replace(/[^\\d]+/g, \"\"));\r\n newBeneficiaryConfiguration.setBirthDate(this.registrationBeneficiaryForm.get(\"birthDate\").value.replace(/[^\\d]+/g, \"\"));\r\n newBeneficiaryConfiguration.setEmail(this.registrationBeneficiaryForm.get(\"email\").value);\r\n newBeneficiaryConfiguration.setTelephone(this.registrationBeneficiaryForm.get(\"telephone\").value.replace(/[^\\d]+/g, \"\"));\r\n newBeneficiaryConfiguration.setMobile(this.registrationBeneficiaryForm.get(\"mobile\").value.replace(/[^\\d]+/g, \"\"));\r\n newBeneficiaryConfiguration.setNeedValidateEmail(this.registrationBeneficiaryForm.get(\"needValidateEmail\").value);\r\n newBeneficiaryConfiguration.setEnableDelivery(this.registrationBeneficiaryForm.get(\"enableDelivery\").value);\r\n newBeneficiaryConfiguration.setTransactionalPassword(this.registrationBeneficiaryForm.get(\"transactionalPassword\").value);\r\n newBeneficiaryConfiguration.setChangePassword(this.registrationBeneficiaryForm.get(\"changePassword\").value);\r\n const personGender = new Gender();\r\n personGender.setGender(this.registrationBeneficiaryForm.get(\"gender\").value);\r\n newBeneficiaryConfiguration.setGender(personGender);\r\n\r\n const personMaritalStatus = new MaritalStatus();\r\n personMaritalStatus.setMaritalStatus(this.registrationBeneficiaryForm.get(\"maritalStatus\").value);\r\n newBeneficiaryConfiguration.setMaritalStatus(personMaritalStatus);\r\n\r\n const address = new Address();\r\n address.setStreet(this.registrationBeneficiaryForm.get(\"street\").value);\r\n address.setNumber(this.registrationBeneficiaryForm.get(\"number\").value);\r\n address.setComplement(this.registrationBeneficiaryForm.get(\"complement\").value);\r\n address.setZipCode(this.registrationBeneficiaryForm.get(\"zipCode\").value.replace(/[^\\d]+/g, \"\"));\r\n address.setDistrict(this.registrationBeneficiaryForm.get(\"district\").value);\r\n address.setCity(this.registrationBeneficiaryForm.get(\"city\").value.getName());\r\n address.setRegion(this.registrationBeneficiaryForm.get(\"region\").value.getValue());\r\n newBeneficiaryConfiguration.setAddress(address);\r\n\r\n try {\r\n if (newBeneficiaryConfiguration.getBeneficiaryKey().getValue() !== \"\") {\r\n const beneficiaryKey = await this.beneficiaryService.saveBeneficiary(this.company.getFiscalNumber(), newBeneficiaryConfiguration);\r\n this.beneficiary = await this.beneficiaryService.findBeneficiaryByKey(beneficiaryKey);\r\n this.beneficiaryService.setBeneficiary(this.beneficiary);\r\n } else {\r\n const beneficiaryKey = await this.beneficiaryService.saveBeneficiary(this.company.getFiscalNumber(), newBeneficiaryConfiguration);\r\n this.beneficiary = await this.beneficiaryService.findBeneficiaryByKey(beneficiaryKey);\r\n this.beneficiaryService.setBeneficiary(this.beneficiary);\r\n setTimeout(() => (this.selectedTabIndex = 1), 1500);\r\n }\r\n this.toast.showSuccessToast(\"Registro de beneficiário realizado com sucesso!\");\r\n this.router.navigate([RoutePath.EditBeneficiary, this.beneficiary.getBeneficiaryKey().getValue()]);\r\n } catch (erro) {\r\n this.toast.showWarningToast(erro);\r\n } finally {\r\n this.formDirty.markAsClean();\r\n this.loadingService.finishLoading(ref);\r\n }\r\n }\r\n }\r\n\r\n onPressEnterSearchCompanies(event): void {\r\n if (event.key === \"Enter\") this.searchCompanies(this.filterText);\r\n }\r\n\r\n searchCompanies(filterText: string) {\r\n const start = 1;\r\n const end = this.appContext.getTotalPerPage();\r\n this.searchCompanyFirst = true;\r\n this.doSearchCompany(start, end, filterText);\r\n }\r\n\r\n searchMoreCompanies() {\r\n this.searchCompanyFirst = false;\r\n const start = this.companyPageableResult.getEnd() + 1;\r\n const end = this.appContext.getTotalPerPage();\r\n this.doSearchCompany(start, end, this.userProfile.getPreferences().getFilterText());\r\n }\r\n\r\n private doSearchCompany(start: number, end: number, filterText: string): void {\r\n const ref = this.loadingService.beginLoading();\r\n const pagingRequest = new PagingRequest();\r\n pagingRequest.setStart(start);\r\n pagingRequest.setEnd(end);\r\n\r\n const filterParams: ICompanyFilterParams = {\r\n filterText: filterText ? filterText.replace(/[./-]/g, \"\") : \"\",\r\n };\r\n this.companyService\r\n .searchCompany(filterParams, pagingRequest)\r\n .then((companyPageableResult) => {\r\n this.companyPageableResult.setStart(start);\r\n this.companyPageableResult.setEnd(end);\r\n this.companyPageableResult.setTotalItems(companyPageableResult.getTotalItems());\r\n\r\n if (this.searchCompanyFirst) {\r\n this.companyPageableResult.setItems(companyPageableResult.getItems());\r\n } else {\r\n this.companyPageableResult.addItems(companyPageableResult.getItems());\r\n }\r\n\r\n if (companyPageableResult.getItems().length === 1) {\r\n this.company = companyPageableResult.getItems().find((x) => x !== undefined) as Company;\r\n this.searchCompany(this.company);\r\n this.storageSearchPreferences(filterText);\r\n } else {\r\n this.company = null;\r\n this.storageSearchPreferences(null);\r\n }\r\n })\r\n .catch((error) => {\r\n this.companyPageableResult.setItems(null);\r\n this.storageSearchPreferences(null);\r\n })\r\n .finally(() => {\r\n this.loadingService.finishLoading(ref);\r\n this.filterText = \"\";\r\n });\r\n }\r\n\r\n showScrollBottomBtn(): boolean {\r\n return this.companyPageableResult.getItems().length > 1;\r\n }\r\n\r\n showMoreCompaniesBtn(): boolean {\r\n return this.companyPageableResult.getTotalItems() !== this.companyPageableResult.getItems().length && this.companyPageableResult.getItems().length > 1;\r\n }\r\n\r\n hasBeneficiaryKey(): boolean {\r\n return !!this.beneficiary && !!this.beneficiary.getBeneficiaryKey();\r\n }\r\n\r\n getDependents(): Dependent[] {\r\n return this.beneficiary.getDependets();\r\n }\r\n\r\n cardNumber(): string {\r\n return this.beneficiary.getCard().getCardNumber();\r\n }\r\n\r\n getCompany(): Company {\r\n return this.company;\r\n }\r\n\r\n getJobList(): JobDescription[] {\r\n return this.jobDescriptionList.filter((job) => job.getEnabled());\r\n }\r\n\r\n getStateList(): StateAcronym[] {\r\n return this.stateList;\r\n }\r\n\r\n getCityList(): City[] {\r\n return this.cityList;\r\n }\r\n\r\n getSelectedTabIndex(): number {\r\n return this.selectedTabIndex;\r\n }\r\n\r\n storageSearchPreferences(fiscalNumber: string): void {\r\n this.userService.setUserPreferences(fiscalNumber ? fiscalNumber.replace(/[^\\d]+/g, \"\") : fiscalNumber);\r\n }\r\n\r\n openCardBlockDialog(): void {\r\n this.cardBlockDialogRef = this.dialog.open(CardBlockDialogComponent, {\r\n disableClose: true,\r\n hasBackdrop: true,\r\n height: \"345px\",\r\n width: \"600px\",\r\n data: this.beneficiary,\r\n });\r\n\r\n this.cardBlockDialogRef.componentInstance.blockCardNumberEvent.subscribe(async (data) => {\r\n this.router.navigate([RoutePath.EditBeneficiary, this.beneficiary.getBeneficiaryKey().getValue()]);\r\n });\r\n }\r\n\r\n isBeneficiaryCardBlocked(): boolean {\r\n return this.beneficiary.getCard() && this.beneficiary.getCard().getIsBlocked();\r\n }\r\n\r\n openAddJobDescriptionDialog() {\r\n this.addJobDescriptionRef = this.dialog.open(AddJobDescriptionDialog, {\r\n disableClose: true,\r\n hasBackdrop: true,\r\n height: \"600px\",\r\n width: \"900px\",\r\n data: {\r\n strategy: JobDescriptionDialogType.Beneficiary,\r\n company: this.company,\r\n jobDescriptionList: this.jobDescriptionList,\r\n },\r\n });\r\n\r\n this.addJobDescriptionRef.componentInstance.closeDialogEvent.subscribe(async (beneficiaryJobDescription: JobDescription) => {\r\n const loadingRef = this.loadingService.beginLoading();\r\n try {\r\n this.jobDescriptionList = await this.jobDescriptionService.getJobDescription(this.company.getFiscalNumber());\r\n if (beneficiaryJobDescription) {\r\n const peteca = this.jobDescriptionList.find((job) => job.getKey() === beneficiaryJobDescription.getKey());\r\n this.registrationBeneficiaryForm.get(\"jobDescription\").setValue(peteca);\r\n }\r\n } finally {\r\n loadingRef.closeLoading();\r\n }\r\n });\r\n }\r\n\r\n scrollToLastCompany() {\r\n const bottom = document.getElementById(\"bottom\");\r\n bottom.scrollIntoView();\r\n }\r\n}\r\n","\r\n \r\n
\r\n \r\n \r\n \r\n
\r\n search\r\n
\r\n
\r\n\r\n
\r\n
\r\n \r\n
\r\n\r\n
\r\n {{ getCompany().getCorporateName() }} \r\n \r\n CNPJ:\r\n {{ getCompany().getFiscalNumber() | companyFederalNumber }} Vidas: {{ getCompany().getCompanyInfo().getEmployeeCount() }} \r\n
\r\n\r\n
\r\n Número do Cartão: {{ cardNumber() | cardNumberFormat }}\r\n
\r\n
\r\n\r\n
\r\n\r\n
\r\n
\r\n
\r\n \r\n Habilitar delivery\r\n \r\n
\r\n
\r\n \r\n CPF\r\n \r\n info\r\n \r\n \r\n Nome\r\n \r\n \r\n
\r\n
\r\n \r\n Data de Admissão\r\n \r\n \r\n\r\n \r\n Matrícula\r\n \r\n \r\n\r\n \r\n Cargo\r\n \r\n {{ job.getTitle() }}\r\n - Adicionar novo cargo -\r\n \r\n \r\n
\r\n
\r\n \r\n Data de Nascimento\r\n \r\n \r\n\r\n \r\n Sexo\r\n \r\n {{ genderType.Male }}\r\n {{ genderType.Female }}\r\n {{ genderType.Unknow }}\r\n \r\n \r\n\r\n \r\n Estado Civil\r\n \r\n Casado\r\n Solteiro\r\n Divorciado\r\n Viúvo\r\n \r\n \r\n
\r\n
\r\n \r\n Telefone\r\n \r\n \r\n\r\n \r\n Celular\r\n \r\n \r\n
\r\n
\r\n \r\n CEP\r\n \r\n \r\n\r\n \r\n Endereço\r\n \r\n \r\n\r\n \r\n Número\r\n \r\n \r\n
\r\n
\r\n \r\n Complemento\r\n \r\n \r\n\r\n \r\n Estado\r\n \r\n Selecione\r\n {{ state.getValue() }}\r\n \r\n \r\n\r\n \r\n Cidade\r\n \r\n Selecione\r\n {{ city.getName() }}\r\n \r\n \r\n\r\n \r\n Bairro\r\n \r\n \r\n
\r\n
\r\n \r\n E-mail\r\n \r\n \r\n\r\n \r\n Validar email no primeiro acesso\r\n \r\n
\r\n
\r\n Inserir senha?\r\n \r\n Senha Transacional\r\n \r\n {{ showPassword ? \"visibility_off\" : \"visibility\" }}\r\n \r\n\r\n \r\n Repetir senha transacional\r\n \r\n {{\r\n showConfirmPassword ? \"visibility_off\" : \"visibility\"\r\n }}\r\n \r\n
\r\n
\r\n
\r\n
\r\n \r\n\r\n \r\n
\r\n \r\n\r\n \r\n
\r\n Dependentes Cadastrados: {{ getDependents().length }}\r\n\r\n
\r\n REGISTRAR DEPENDENTE\r\n
\r\n
\r\n\r\n
\r\n
\r\n
\r\n
\r\n
\r\n

{{ dependent?.getName() }}

\r\n
\r\n\r\n
\r\n Número do cartão: {{ dependent?.getCard()?.getCardNumber() | cardNumberFormat }}\r\n
\r\n\r\n
\r\n
\r\n CPF: {{ dependent?.getSocialNumber() | socialNumberFormatPipe }}\r\n Nascimento: {{ dependent?.getBirthDate() | dateFormat }}\r\n
\r\n\r\n
\r\n Sexo: {{ dependent?.getGender()?.getView() }}\r\n Estado Civil: {{ dependent?.getMaritalStatus()?.getView() }}\r\n
\r\n\r\n
\r\n Celular: {{ dependent?.getMobile() | mobileFormatPipe }}\r\n E-mail: {{ dependent?.getEmail() }}\r\n
\r\n
\r\n
\r\n
\r\n\r\n
\r\n
\r\n \r\n EDITAR\r\n
\r\n\r\n \r\n \r\n \r\n {{ dependent.isActive() ? \"ATIVO\" : \"INATIVO\" }}\r\n
\r\n
\r\n
\r\n \r\n
\r\n\r\n","export class FileBeneficiary {\r\n private file: File;\r\n private fiscalNumber: string;\r\n\r\n static isCsvExtension(file: File): boolean {\r\n return file.name.includes(\".csv\");\r\n }\r\n\r\n getFile(): File {\r\n return this.file;\r\n }\r\n\r\n setFile(file: File): void {\r\n this.file = file;\r\n }\r\n\r\n getFiscalNumber(): string {\r\n return this.fiscalNumber;\r\n }\r\n\r\n setFiscalNumber(value: string): void {\r\n this.fiscalNumber = value;\r\n }\r\n\r\n hasFile(): boolean {\r\n return !!(this.file && this.fiscalNumber);\r\n }\r\n}\r\n","import { Component } from \"@angular/core\";\r\nimport { MatDialogRef } from \"@angular/material/dialog\";\r\n\r\n@Component({\r\n templateUrl: \"./export-info-dialog.component.html\",\r\n styleUrls: [\"./export-info-dialog.component.scss\"],\r\n})\r\nexport class ExportInfoDialogComponent {\r\n constructor(private dialogRef: MatDialogRef) {}\r\n\r\n ngOnInit() {}\r\n\r\n close() {\r\n this.dialogRef.close(true);\r\n }\r\n}\r\n","
\r\n
\r\n

Instruções para realizar uma Importação em lote

\r\n\r\n
\r\n
\r\n ATENÇÃO
\r\n O arquivo utilizado para realizar a manuntenção, deverá conter no máximo 50 mil beneficiários \r\n
\r\n\r\n
\r\n Manutenção em Lote\r\n Cada linha do arquivo, refere-se à um beneficiário (seja ele titular ou dependente)\r\n
\r\n\r\n
\r\n Tipos de Usuários \r\n Em \"Tipo\" será informado se é Titular (T) ou Dependente (D)\r\n
\r\n
\r\n \r\n
\r\n
\r\n","import { Component, OnInit } from \"@angular/core\";\r\nimport { FeatureViews } from \"src/app/ui/models/domains/features/custom-feature-views\";\r\nimport { PageViews } from \"src/app/ui/models/domains/features/custom-page-views\";\r\nimport { FeatureViewService } from \"src/app/ui/services/feature-view.service\";\r\nimport { BeneficiaryService } from \"src/app/ui/services/pbm/beneficiary.service\";\r\nimport { FileBeneficiary } from \"src/app/ui/models/domains/pbm/Beneficiary/file-beneficiary\";\r\nimport { LoadingService } from \"src/app/ui/services/loading.service\";\r\nimport { CompanyService } from \"src/app/ui/services/pbm/company.service\";\r\nimport { Company } from \"src/app/ui/models/domains/pbm/companies/company\";\r\nimport { MaskInput } from \"src/app/ui/models/domains/masks/mask.model\";\r\nimport { Toast } from \"../../../toast/toast\";\r\nimport { UserService } from \"src/app/ui/services/user.service\";\r\nimport { environment } from \"src/environments/environment\";\r\nimport { AppContext } from \"src/app/ui/contexts/app-context\";\r\nimport { PageableResult } from \"src/app/ui/models/domains/paginator/pageable-result\";\r\nimport { PagingRequest } from \"src/app/ui/models/domains/paginator/paging-request\";\r\nimport { UntypedFormControl } from \"@angular/forms\";\r\nimport { ICompanyFilterParams } from \"src/app/ui/models/domains/pbm/companies/company-filter-params\";\r\nimport { ExportInfoDialogComponent } from \"./export-info-dialog/export-info-dialog.component\";\r\nimport { AsyncImportStatus } from \"src/app/ui/models/domains/pbm/async-import/async-import-status\";\r\nimport { AsyncImportService } from \"src/app/ui/services/pbm/async-import-service\";\r\nimport { FiscalNumber } from \"src/app/ui/models/domains/pbm/fiscal-number\";\r\nimport { MatDialog } from \"@angular/material/dialog\";\r\n\r\n@Component({\r\n selector: \"app-registration-beneficiaries\",\r\n templateUrl: \"./registration-beneficiaries.component.html\",\r\n styleUrls: [\"./registration-beneficiaries.component.scss\"],\r\n})\r\nexport class RegistrationBeneficiariesComponent implements OnInit {\r\n fileName: string;\r\n company: Company;\r\n filterText: string;\r\n fileBeneficiary = new FileBeneficiary();\r\n searchNotFound = false;\r\n searchActionFired = false;\r\n fiscalNumberMask = MaskInput.getFicalNumberMask();\r\n fileLink = environment.beneficiaryTemplateRegisterFileUploadLink;\r\n searchType: UntypedFormControl;\r\n private searchCompanyFirst: boolean;\r\n public companyPageableResult = new PageableResult();\r\n private userProfile = this.userService.getUserProfile();\r\n public tabIndex = 0;\r\n\r\n constructor(\r\n private asyncImportService: AsyncImportService,\r\n private featureViewService: FeatureViewService,\r\n private beneficiaryService: BeneficiaryService,\r\n private loadingService: LoadingService,\r\n private companyService: CompanyService,\r\n private toast: Toast,\r\n private userService: UserService,\r\n private appContext: AppContext,\r\n private dialog: MatDialog,\r\n ) {\r\n this.searchType = new UntypedFormControl(1);\r\n }\r\n lastImportStatus: AsyncImportStatus;\r\n lastImportedKey: string;\r\n\r\n ngOnInit() {\r\n this.userProfile = this.userService.getUserProfile();\r\n if (this.userProfile.getPreferences().getFilterText()) {\r\n this.searchCompanies(this.userProfile.getPreferences().getFilterText());\r\n } else {\r\n this.searchCompanies(\"\");\r\n }\r\n this.featureViewService.activeFeatureView(FeatureViews.BeneficiaryRegistrationBeneficiariesFeatureView, PageViews.BeneficiaryPageView);\r\n this.loadLastUploaded();\r\n }\r\n\r\n private loadLastUploaded(): void {\r\n if (!this.company) return;\r\n this.lastImportStatus = null;\r\n this.lastImportedKey = null;\r\n\r\n const loadingRef = this.loadingService.beginLoading();\r\n try {\r\n this.lastImportedKey = this.asyncImportService.getKey(this.company.getFiscalNumber());\r\n if (this.lastImportedKey) {\r\n this.asyncImportService.registerConsult(this.lastImportedKey).subscribe((x) => {\r\n this.lastImportStatus = x;\r\n if (x.isFinished()) {\r\n loadingRef.closeLoading()\r\n }\r\n });\r\n }\r\n } catch (e) {\r\n console.log(e);\r\n } finally {\r\n loadingRef.closeLoading();\r\n }\r\n }\r\n\r\n hasLastImportStatus(): boolean {\r\n return this.lastImportStatus != null;\r\n }\r\n\r\n async searchCompany(company: Company) {\r\n this.lastImportStatus = null;\r\n this.lastImportedKey = null;\r\n if (company.getFiscalNumber()) {\r\n const ref = this.loadingService.beginLoading();\r\n await this.companyService\r\n .findCompanyBy(company.getFiscalNumber())\r\n .then((x) => {\r\n this.company = x;\r\n this.fileBeneficiary.setFiscalNumber(company.getFiscalNumber());\r\n this.searchNotFound = false;\r\n this.storageSearchPreferences(company.getFiscalNumber());\r\n })\r\n .catch((e) => {\r\n this.company = null;\r\n this.searchNotFound = true;\r\n this.toast.showWarningToast(e);\r\n this.storageSearchPreferences(null);\r\n })\r\n .finally(() => {\r\n this.filterText = \"\";\r\n this.loadingService.finishLoading(ref);\r\n this.loadLastUploaded();\r\n });\r\n } else {\r\n this.company = null;\r\n this.searchNotFound = true;\r\n this.filterText = \"\";\r\n }\r\n }\r\n\r\n getFile(event) {\r\n const files = event.target.files;\r\n if (!FileBeneficiary.isCsvExtension(files.item(0))) {\r\n this.toast.showWarningToast(\"Insira um arquivo .csv\");\r\n } else {\r\n const file = files.item(0);\r\n this.fileName = file.name;\r\n this.fileBeneficiary.setFile(file);\r\n }\r\n event.target.value = null;\r\n }\r\n\r\n getCompanies(): Array {\r\n return this.companyPageableResult.getItems() as Array;\r\n }\r\n\r\n async uploadImportBeneficiaiesFile() {\r\n if (!this.fileBeneficiary || !this.fileBeneficiary.hasFile() || !this.company) return;\r\n const loadingRef = this.loadingService.beginLoading();\r\n\r\n await this.beneficiaryService\r\n .importBeneficiary(this.fileBeneficiary, new FiscalNumber(this.company.getFiscalNumber()))\r\n .then((key) => {\r\n if (this.lastImportedKey) {\r\n this.asyncImportService.removeKey(this.asyncImportService.createKey(this.lastImportedKey, this.company.getFiscalNumber()));\r\n }\r\n this.asyncImportService.addKey(this.asyncImportService.createKey(key, this.company.getFiscalNumber()));\r\n this.loadLastUploaded();\r\n })\r\n .catch((e) => {\r\n this.toast.showWarningToast(e.error.Data.ErrorMessage);\r\n })\r\n .finally(() => {\r\n loadingRef.closeLoading();\r\n });\r\n this.fileName = null;\r\n this.fileBeneficiary.setFile(null);\r\n }\r\n\r\n async downloadFile() {\r\n const loadingRef = this.loadingService.beginLoading();\r\n await this.asyncImportService.downloadFileSummary(this.lastImportedKey).then((fileData) => {\r\n try {\r\n const fileLink = document.createElement(\"a\");\r\n document.body.appendChild(fileLink);\r\n const url = window.URL.createObjectURL(fileData);\r\n fileLink.href = url;\r\n fileLink.download = \"Resumo_Importacao_Beneficiarios.csv\";\r\n fileLink.click();\r\n this.toast.showSuccessToast(\"Arquivo .csv exportado com sucesso.\");\r\n this.tabIndex = 1;\r\n } catch (error) {\r\n console.log(error);\r\n } finally {\r\n loadingRef.closeLoading();\r\n }\r\n }).finally(() => {\r\n loadingRef.closeLoading();\r\n });\r\n }\r\n\r\n hasCompany(): boolean {\r\n return !!this.company;\r\n }\r\n\r\n onPressEnterSearchCompanies(event): void {\r\n if (event.key === \"Enter\") this.searchCompanies(this.filterText);\r\n }\r\n\r\n searchCompanies(filterText: string) {\r\n const start = 1;\r\n const end = this.appContext.getTotalPerPage();\r\n this.searchCompanyFirst = true;\r\n this.doSearchCompany(start, end, filterText);\r\n }\r\n\r\n searchMoreCompanies() {\r\n this.searchCompanyFirst = false;\r\n const start = this.companyPageableResult.getEnd() + 1;\r\n const end = this.appContext.getTotalPerPage();\r\n this.doSearchCompany(start, end, this.userProfile.getPreferences().getFilterText());\r\n }\r\n\r\n private doSearchCompany(start: number, end: number, filterText: string): void {\r\n const ref = this.loadingService.beginLoading();\r\n const pagingRequest = new PagingRequest();\r\n pagingRequest.setStart(start);\r\n pagingRequest.setEnd(end);\r\n\r\n const filterParams: ICompanyFilterParams = {\r\n filterText: filterText ? filterText.replace(/[./-]/g, \"\") : \"\",\r\n };\r\n this.companyService\r\n .searchCompany(filterParams, pagingRequest)\r\n .then((companyPageableResult) => {\r\n this.companyPageableResult.setStart(start);\r\n this.companyPageableResult.setEnd(end);\r\n this.companyPageableResult.setTotalItems(companyPageableResult.getTotalItems());\r\n\r\n if (this.searchCompanyFirst) {\r\n this.companyPageableResult.setItems(companyPageableResult.getItems());\r\n } else {\r\n this.companyPageableResult.addItems(companyPageableResult.getItems());\r\n }\r\n\r\n if (companyPageableResult.getItems().length === 1) {\r\n this.company = companyPageableResult.getItems()[0] as Company;\r\n this.searchCompany(this.company);\r\n this.storageSearchPreferences(filterText);\r\n } else {\r\n this.company = null;\r\n this.storageSearchPreferences(null);\r\n }\r\n })\r\n .catch((error) => {\r\n this.companyPageableResult.setItems(null);\r\n this.storageSearchPreferences(null);\r\n })\r\n .finally(() => {\r\n this.loadingService.finishLoading(ref);\r\n this.filterText = \"\";\r\n });\r\n }\r\n\r\n showScrollBottomBtn(): boolean {\r\n return this.companyPageableResult.getItems().length > 1;\r\n }\r\n\r\n showMoreCompaniesBtn(): boolean {\r\n return this.companyPageableResult.getTotalItems() !== this.companyPageableResult.getItems().length && this.companyPageableResult.getItems().length > 1;\r\n }\r\n\r\n storageSearchPreferences(fiscalNumber): void {\r\n this.userService.setUserPreferences(fiscalNumber ? fiscalNumber.replace(/[^\\d]+/g, \"\") : fiscalNumber);\r\n }\r\n\r\n scrollToLastCompany() {\r\n const bottom = document.getElementById(\"bottom\");\r\n bottom.scrollIntoView();\r\n }\r\n\r\n public openExportInfoModal(): void {\r\n this.dialog.open(ExportInfoDialogComponent, {\r\n id: \"status-dialog\",\r\n disableClose: true,\r\n hasBackdrop: true,\r\n width: \"860px\",\r\n height: \"300px\",\r\n });\r\n }\r\n}\r\n","\r\n \r\n

Selecione a empresa para importação em lote:

\r\n
\r\n \r\n \r\n \r\n
\r\n search\r\n
\r\n
\r\n\r\n
\r\n
\r\n \r\n
\r\n
\r\n
{{ company.getCorporateName() }}
\r\n CNPJ: {{ company.getFiscalNumber() | companyFederalNumber }} \r\n {{ company.getCompanyInfo().getEmployeeCount() }} vidas\r\n
\r\n
\r\n

Nenhum resultado encontrado.

\r\n
\r\n\r\n
\r\n \r\n \r\n
\r\n
\r\n

Adicionar vários beneficiários de uma vez.

\r\n
\r\n \r\n file_download\r\n

Faça download do arquivo modelo .csv

\r\n
\r\n
\r\n\r\n
\r\n
\r\n \r\n \r\n \r\n \r\n
\r\n
\r\n
\r\n \r\n
\r\n

{{ lastImportStatus.statusLabel() }}

\r\n \r\n download\r\n BAIXAR RESULTADO\r\n \r\n

\r\n {{ lastImportStatus.isFinished() ? \"check\" : \"hourglass_full\" }}\r\n \r\n {{ lastImportStatus.getStatusDescription() }}\r\n \r\n

\r\n
\r\n Atualizados: {{ lastImportStatus.info.totalUpdated }}\r\n Inseridos: {{ lastImportStatus.info.totalCreated }}\r\n Itens com Erros: {{ lastImportStatus.info.totalFailed }}\r\n
\r\n Mensagem:\r\n
{{ lastImportStatus.info.exceptionLog }}
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n\r\n
\r\n
\r\n

1\">{{ companyPageableResult.getItems().length }} RESULTADOS ENCONTRADOS

\r\n

1 RESULTADO ENCONTRADO

\r\n
\r\n arrow_drop_down\r\n ir para o fim da lista\r\n
\r\n
\r\n\r\n
\r\n
\r\n
\r\n \r\n
\r\n
\r\n

{{ company.getCorporateName() }}

\r\n

CNPJ: {{ company.getFiscalNumber() | companyFederalNumber }}

\r\n

{{ company.getTradingName() }}

\r\n
\r\n
\r\n
\r\n check_circle_outline\r\n ATIVA\r\n
\r\n
\r\n add_box\r\n ADICIONAR\r\n
\r\n
\r\n
\r\n
\r\n\r\n Carregar mais registros\r\n
\r\n
\r\n
\r\n
\r\n","import { Component, OnInit } from \"@angular/core\";\r\nimport { UntypedFormBuilder, UntypedFormGroup, Validators } from \"@angular/forms\";\r\nimport { ActivatedRoute, Router } from \"@angular/router\";\r\nimport { UserPermissions } from \"./../../../../models/domains/pbm/user/user-permissions\";\r\n\r\nimport \"moment/locale/pt-br\";\r\nimport { FeatureViews } from \"src/app/ui/models/domains/features/custom-feature-views\";\r\nimport { PageViews } from \"src/app/ui/models/domains/features/custom-page-views\";\r\nimport { MaskInput } from \"src/app/ui/models/domains/masks/mask.model\";\r\nimport { Beneficiary } from \"src/app/ui/models/domains/pbm/Beneficiary/beneficiary\";\r\nimport { Card } from \"src/app/ui/models/domains/pbm/Beneficiary/card\";\r\nimport { Dependent } from \"src/app/ui/models/domains/pbm/Beneficiary/dependent\";\r\nimport { OrderCardDTO } from \"src/app/ui/models/domains/pbm/Beneficiary/dto/order-card-dto\";\r\nimport { Employee } from \"src/app/ui/models/domains/pbm/Beneficiary/employee\";\r\nimport { GenderType } from \"src/app/ui/models/domains/pbm/Beneficiary/gender-type\";\r\nimport { JobDescription } from \"src/app/ui/models/domains/pbm/Beneficiary/job-description\";\r\nimport { Gender, MaritalStatus } from \"src/app/ui/models/domains/pbm/Beneficiary/person\";\r\nimport { BeneficiaryKey } from \"src/app/ui/models/domains/pbm/Benefit/beneficiary-key\";\r\nimport { Address } from \"src/app/ui/models/domains/pbm/companies/address\";\r\nimport { Company } from \"src/app/ui/models/domains/pbm/companies/company\";\r\nimport { City } from \"src/app/ui/models/domains/pbm/state/city\";\r\nimport { StateAcronym } from \"src/app/ui/models/domains/pbm/state/state-acronym\";\r\nimport { RoutePath } from \"src/app/ui/models/domains/route-paths.model\";\r\nimport { FormDirty } from \"src/app/ui/models/utils/form-dirty.utils\";\r\nimport { FeatureViewService } from \"src/app/ui/services/feature-view.service\";\r\nimport { LoadingService } from \"src/app/ui/services/loading.service\";\r\nimport { BeneficiaryService } from \"src/app/ui/services/pbm/beneficiary.service\";\r\nimport { CompanyService } from \"src/app/ui/services/pbm/company.service\";\r\nimport { JobDescriptionService } from \"src/app/ui/services/pbm/job-description.service\";\r\nimport { StateService } from \"src/app/ui/services/pbm/state.service\";\r\nimport { UserService } from \"src/app/ui/services/user.service\";\r\nimport { Toast } from \"../../../toast/toast\";\r\nimport { AddJobDescriptionDialog } from \"../../shared/dialogs/add-job-description-dialog/add-job-description-dialog.component\";\r\nimport { JobDescriptionDialogType } from \"../../shared/dialogs/add-job-description-dialog/add-job-description-dialog.enum\";\r\nimport { ConfirmDialog } from \"../../shared/dialogs/confirm-dialog/confirm-dialog.component\";\r\nimport { CardBlockDialogComponent } from \"../dialogs/card-block-dialog/card-block-dialog.component\";\r\nimport { CardOrderDialogComponent } from \"../dialogs/card-order-dialog/card-order-dialog.component\";\r\nimport { CardUnblockDialogComponent } from \"../dialogs/card-unblock-dialog/card-unblock-dialog.component\";\r\nimport { SaveBeneficiaryValidator } from \"../validators/save-beneficiary-validator\";\r\nimport { MatDialogRef, MatDialog } from \"@angular/material/dialog\";\r\nimport { MatSlideToggle } from \"@angular/material/slide-toggle\";\r\n\r\n@Component({\r\n selector: \"app-edit-beneficiary\",\r\n templateUrl: \"./edit-beneficiary.component.html\",\r\n styleUrls: [\"./edit-beneficiary.component.scss\"],\r\n})\r\nexport class EditBeneficiaryComponent implements OnInit {\r\n O;\r\n private fiscalNumber: string;\r\n private company: Company;\r\n private beneficiary: Beneficiary;\r\n private formDirty: FormDirty;\r\n private selectedTabIndex = 0;\r\n private confirmDialogRef: MatDialogRef;\r\n private cardOrderDialogRef: MatDialogRef;\r\n private cardBlockDialogRef: MatDialogRef;\r\n private cardUnblockDialogRef: MatDialogRef;\r\n private addJobDescriptionRef: MatDialogRef;\r\n private jobDescriptionList: JobDescription[] = [];\r\n private stateList: StateAcronym[] = [];\r\n private cityList: City[] = [];\r\n\r\n public fiscalNumberMask = MaskInput.getFicalNumberMask();\r\n public socialNumberMask = MaskInput.getSocialNumberMask();\r\n public dateMask = MaskInput.getDateMask();\r\n public zipCodeMask = MaskInput.getZipCodeMask();\r\n public telephoneMask = MaskInput.getTelephoneMask();\r\n public mobileMask = MaskInput.getMobileMask();\r\n public numericalPasswordMask = MaskInput.getNumericalPassword();\r\n public genderType = GenderType;\r\n\r\n public userNameInputBorder = \"1px white solid\";\r\n public passwordInputBorder = \"1px white solid\";\r\n public passwordInputPlaceholder = \"SENHA:\";\r\n public passwordInputType = \"password\";\r\n public confirmPasswordInputType = \"password\";\r\n passwordPattern = /^([0-9]){6}$/;\r\n\r\n public hidePassword = true;\r\n public alertLogin = false;\r\n public userErrorVisible = false;\r\n public passwordErrorVisible = false;\r\n public showPassword = false;\r\n public showConfirmPassword = false;\r\n\r\n public registrationBeneficiaryForm: UntypedFormGroup = this.formBuilder.group(\r\n {\r\n beneficiaryKey: [\"\"],\r\n active: [\"\"],\r\n cardNumber: [\"\"],\r\n name: [\"\", Validators.required],\r\n registration: [\"\"],\r\n jobDescription: [\"\"],\r\n admissionDate: [\"\"],\r\n socialNumber: [\"\", Validators.required],\r\n birthDate: [\"\"],\r\n gender: [\"\"],\r\n maritalStatus: [\"\"],\r\n street: [\"\"],\r\n number: [\"\"],\r\n complement: [\"\"],\r\n district: [\"\", Validators.required],\r\n city: [{ value: 0, disabled: true }, Validators.required],\r\n region: [0, Validators.required],\r\n zipCode: [\"\"],\r\n email: [\"\", Validators.required],\r\n telephone: [\"\"],\r\n mobile: [\"\"],\r\n changePassword: [false],\r\n transactionalPassword: [\"\", Validators.pattern(this.passwordPattern)],\r\n confirmTransactionalPassword: [\"\", Validators.pattern(this.passwordPattern)],\r\n needValidateEmail: [false],\r\n enableDelivery: [false],\r\n },\r\n { validator: this.checkPasswords },\r\n );\r\n\r\n constructor(\r\n private featureViewService: FeatureViewService,\r\n private activatedRoute: ActivatedRoute,\r\n private companyService: CompanyService,\r\n private beneficiaryService: BeneficiaryService,\r\n private loadingService: LoadingService,\r\n private formBuilder: UntypedFormBuilder,\r\n private dialog: MatDialog,\r\n private toast: Toast,\r\n private userService: UserService,\r\n private stateService: StateService,\r\n private jobDescriptionService: JobDescriptionService,\r\n private router: Router,\r\n ) {\r\n this.beneficiary = new Beneficiary();\r\n this.formDirty = new FormDirty();\r\n }\r\n\r\n async ngOnInit() {\r\n this.loadBeneficiaryScreen();\r\n }\r\n\r\n async loadBeneficiaryScreen() {\r\n this.featureViewService.activeFeatureView(FeatureViews.BeneficiaryEditBeneficiaryFeatureView, PageViews.BeneficiaryPageView);\r\n const ref = this.loadingService.beginLoading();\r\n const beneficiaryKey = new BeneficiaryKey();\r\n beneficiaryKey.setValue(this.activatedRoute.snapshot.params.beneficiaryKey);\r\n this.beneficiary.setBeneficiaryKey(beneficiaryKey);\r\n const userProfile = this.userService.getUserProfile();\r\n this.fiscalNumber = userProfile.getPreferences().getFilterText();\r\n try {\r\n this.beneficiary = await this.beneficiaryService.findBeneficiaryByKey(this.beneficiary.getBeneficiaryKey());\r\n this.beneficiaryService.setBeneficiary(this.beneficiary);\r\n this.stateList = await this.stateService.getStates();\r\n this.company = await this.companyService.findCompanyBy(this.fiscalNumber);\r\n this.jobDescriptionList = await this.jobDescriptionService.getJobDescription(this.company.getFiscalNumber());\r\n await this.patchRegistrationBeneficiaryForm();\r\n this.formDirty.markAsClean();\r\n } catch (error) {\r\n this.toast.showWarningToast(error);\r\n this.router.navigate([RoutePath.SearchBeneficiary]);\r\n } finally {\r\n this.loadingService.finishLoading(ref);\r\n }\r\n this.disableTransactionalPasswordFields();\r\n }\r\n\r\n private async patchRegistrationBeneficiaryForm(): Promise {\r\n const state = this.stateList.find((state) => state.getValue() === this.beneficiary.getAddress().getRegion());\r\n\r\n if (state) {\r\n this.cityList = await this.stateService.getCityByStateAcronym(state);\r\n }\r\n\r\n const city = this.cityList.find((city) => city.getName() === this.beneficiary.getAddress().getCity());\r\n\r\n let beneficiaryJobDescription = null;\r\n\r\n if (this.beneficiary.getEmployee().getJobDescription()) {\r\n beneficiaryJobDescription = this.jobDescriptionList.find((job) => job.getKey() === this.beneficiary.getEmployee().getJobDescription().getKey());\r\n }\r\n this.registrationBeneficiaryForm.patchValue({\r\n beneficiaryKey: this.beneficiary.getBeneficiaryKey(),\r\n active: this.beneficiary.isActive(),\r\n cardNumber: this.beneficiary.getCard().getCardNumber(),\r\n name: this.beneficiary.getName(),\r\n registration: this.beneficiary.getEmployee().getRegistration(),\r\n admissionDate: this.beneficiary.getEmployee().getAdmissionDate(),\r\n jobDescription: beneficiaryJobDescription,\r\n socialNumber: this.beneficiary.getSocialNumber(),\r\n birthDate: this.beneficiary.getBirthDate(),\r\n gender: this.beneficiary.getGender().getValue(),\r\n maritalStatus: this.beneficiary.getMaritalStatus().getValue(),\r\n street: this.beneficiary.getAddress().getStreet(),\r\n number: this.beneficiary.getAddress().getNumber(),\r\n complement: this.beneficiary.getAddress().getComplement(),\r\n district: this.beneficiary.getAddress().getDistrict(),\r\n city: city ? city : 0,\r\n region: state ? state : 0,\r\n zipCode: this.beneficiary.getAddress().getZipCode(),\r\n email: this.beneficiary.getEmail(),\r\n telephone: this.beneficiary.getTelephone(),\r\n mobile: this.beneficiary.getMobile(),\r\n changePassword: this.beneficiary.getChangePassword(),\r\n haveTransactionalPassword: this.beneficiary.getHaveTransactionalPassword(),\r\n transactionalPassword: this.beneficiary.getTransactionalPassword(),\r\n needValidateEmail: this.beneficiary.getNeedValidateEmail(),\r\n enableDelivery: this.beneficiary.getEnableDelivery(),\r\n });\r\n\r\n this.registrationBeneficiaryForm.enable();\r\n }\r\n\r\n private getTabIndex(tabName: string): number {\r\n switch (tabName) {\r\n case \"EDITAR BENEFICIÁRIO\":\r\n return 0;\r\n case \"Beneficiário\":\r\n return 0;\r\n case \"LISTA DE DEPENDENTES\":\r\n return 1;\r\n default:\r\n return -1;\r\n }\r\n }\r\n\r\n onTabClick(clickEvent: PointerEvent) {\r\n const clickedTab = clickEvent.target as HTMLDivElement;\r\n const clickedTabIndex = this.getTabIndex(clickedTab.innerText);\r\n if (clickedTabIndex === -1) {\r\n return;\r\n }\r\n if (this.selectedTabIndex !== clickedTabIndex) {\r\n if (this.formDirty.isDirty()) {\r\n alert(\"Os dados foram alterados no formulário. Por favor, salve antes de prosseguir.\");\r\n } else {\r\n this.selectedTabIndex = clickedTabIndex;\r\n }\r\n }\r\n }\r\n\r\n enableTransactionalPasswordFields() {\r\n this.registrationBeneficiaryForm.get(\"transactionalPassword\").enable();\r\n this.registrationBeneficiaryForm.get(\"confirmTransactionalPassword\").enable();\r\n }\r\n\r\n disableTransactionalPasswordFields() {\r\n this.registrationBeneficiaryForm.get(\"transactionalPassword\").setValue(null);\r\n this.registrationBeneficiaryForm.get(\"transactionalPassword\").disable();\r\n this.registrationBeneficiaryForm.get(\"confirmTransactionalPassword\").setValue(null);\r\n this.registrationBeneficiaryForm.get(\"confirmTransactionalPassword\").disable();\r\n }\r\n\r\n async changeDisable(event: MatSlideToggle) {\r\n if (!!event) {\r\n this.registrationBeneficiaryForm.get(\"changePassword\").patchValue(true);\r\n this.enableTransactionalPasswordFields();\r\n } else {\r\n this.registrationBeneficiaryForm.get(\"changePassword\").patchValue(false);\r\n this.disableTransactionalPasswordFields();\r\n }\r\n }\r\n\r\n getPlaceHolderColor(): string {\r\n return this.passwordErrorVisible ? \"error-placeholder\" : \"default-placeholder\";\r\n }\r\n\r\n setPasswordVisible(): void {\r\n this.showPassword = !this.showPassword;\r\n if (this.showPassword) this.passwordInputType = \"text\";\r\n else this.passwordInputType = \"password\";\r\n }\r\n\r\n setConfirmPasswordVisible(): void {\r\n this.showConfirmPassword = !this.showConfirmPassword;\r\n if (this.showConfirmPassword) this.confirmPasswordInputType = \"text\";\r\n else this.confirmPasswordInputType = \"password\";\r\n }\r\n\r\n checkPasswords(group: UntypedFormGroup) {\r\n let password = group.controls.transactionalPassword;\r\n let confirmPassword = group.controls.confirmTransactionalPassword;\r\n return password.value != confirmPassword.value ? { matchPassword: true } : null;\r\n }\r\n\r\n hasCompany(): boolean {\r\n return !!this.company;\r\n }\r\n public async getZipCode() {\r\n const formValue = this.registrationBeneficiaryForm.get(\"zipCode\").value;\r\n var boolean = /^\\d{5}[-]\\d{3}$/.test(formValue);\r\n\r\n if (boolean) {\r\n const ref = this.loadingService.beginLoading();\r\n this.registrationBeneficiaryForm.get(\"zipCode\").disable();\r\n try {\r\n const zip = await this.stateService.getZipCodeIntegration(formValue);\r\n const state = this.stateList.find((state) => state.getValue() === zip.getStateCode());\r\n this.registrationBeneficiaryForm.get(\"region\").setValue(state);\r\n await this.onStateInputChange();\r\n\r\n const city = this.cityList.find((city) => city.getName() === zip.getLocality());\r\n this.registrationBeneficiaryForm.get(\"city\").setValue(city);\r\n\r\n this.registrationBeneficiaryForm.get(\"street\").setValue(zip.getAddress());\r\n this.registrationBeneficiaryForm.get(\"district\").setValue(zip.getNeighborhood());\r\n } catch (error) {\r\n this.toast.showWarningToast(\"CEP não encontrado.\");\r\n } finally {\r\n this.loadingService.finishLoading(ref);\r\n this.registrationBeneficiaryForm.get(\"zipCode\").enable();\r\n }\r\n }\r\n }\r\n\r\n onBeneficiaryInputChange(): void {\r\n this.formDirty.markAsDirty();\r\n }\r\n\r\n async onStateInputChange() {\r\n const state = this.registrationBeneficiaryForm.get(\"region\").value;\r\n if (state) {\r\n const ref = this.loadingService.beginLoading();\r\n try {\r\n this.cityList = await this.stateService.getCityByStateAcronym(state);\r\n this.registrationBeneficiaryForm.get(\"city\").enable();\r\n this.registrationBeneficiaryForm.get(\"city\").setValue(0);\r\n } catch (error) {\r\n this.cityList = [];\r\n this.registrationBeneficiaryForm.get(\"city\").disable();\r\n this.toast.showWarningToast(error);\r\n } finally {\r\n this.loadingService.finishLoading(ref);\r\n }\r\n } else {\r\n this.cityList = [];\r\n this.registrationBeneficiaryForm.get(\"city\").setValue(0);\r\n this.registrationBeneficiaryForm.get(\"city\").disable();\r\n }\r\n }\r\n\r\n goToCreateDependent(): void {\r\n const newDependent = new Dependent();\r\n newDependent.setBeneficiarySocialNumber(this.beneficiary.getSocialNumber());\r\n this.beneficiaryService.setDependent(newDependent);\r\n this.router.navigate([RoutePath.RegistrationDependent]);\r\n }\r\n\r\n goToEditDependent(dependent: Dependent): void {\r\n this.beneficiaryService.setDependent(dependent);\r\n this.router.navigate([RoutePath.EditDependent]);\r\n }\r\n\r\n async saveBenficiary(): Promise {\r\n const ref = this.loadingService.beginLoading();\r\n const saveBeneficiaryValidator = new SaveBeneficiaryValidator(this.registrationBeneficiaryForm);\r\n\r\n if (saveBeneficiaryValidator.validate().hasErrorMessages()) {\r\n this.toast.showWarningToast(saveBeneficiaryValidator.getValidationResult().getErrorMessage());\r\n this.loadingService.finishLoading(ref);\r\n } else {\r\n const newBeneficiaryConfiguration = new Beneficiary();\r\n newBeneficiaryConfiguration.setBeneficiaryKey(this.beneficiary.getBeneficiaryKey());\r\n\r\n newBeneficiaryConfiguration.setName(this.registrationBeneficiaryForm.get(\"name\").value);\r\n newBeneficiaryConfiguration.setSocialNumber(this.registrationBeneficiaryForm.get(\"socialNumber\").value.replace(/[^\\d]+/g, \"\"));\r\n newBeneficiaryConfiguration.setBirthDate(this.registrationBeneficiaryForm.get(\"birthDate\").value.replace(/[^\\d]+/g, \"\"));\r\n newBeneficiaryConfiguration.setEmail(this.registrationBeneficiaryForm.get(\"email\").value);\r\n newBeneficiaryConfiguration.setTelephone(this.registrationBeneficiaryForm.get(\"telephone\").value.replace(/[^\\d]+/g, \"\"));\r\n newBeneficiaryConfiguration.setMobile(this.registrationBeneficiaryForm.get(\"mobile\").value.replace(/[^\\d]+/g, \"\"));\r\n newBeneficiaryConfiguration.setChangePassword(this.registrationBeneficiaryForm.get(\"changePassword\").value);\r\n newBeneficiaryConfiguration.setTransactionalPassword(this.registrationBeneficiaryForm.get(\"transactionalPassword\").value);\r\n newBeneficiaryConfiguration.setNeedValidateEmail(this.registrationBeneficiaryForm.get(\"needValidateEmail\").value);\r\n newBeneficiaryConfiguration.setEnableDelivery(this.registrationBeneficiaryForm.get(\"enableDelivery\").value);\r\n\r\n newBeneficiaryConfiguration.setDependents(this.beneficiary.getDependets());\r\n\r\n const employee = new Employee();\r\n employee.setRegistration(this.registrationBeneficiaryForm.get(\"registration\").value);\r\n employee.setAdmissionDate(this.registrationBeneficiaryForm.get(\"admissionDate\").value.replace(/[^\\d]+/g, \"\"));\r\n employee.setJobDescription(this.registrationBeneficiaryForm.get(\"jobDescription\").value);\r\n newBeneficiaryConfiguration.setEmployee(employee);\r\n\r\n const card = new Card();\r\n card.setCardNumber(this.registrationBeneficiaryForm.get(\"cardNumber\").value);\r\n newBeneficiaryConfiguration.setCard(card);\r\n\r\n const personGender = new Gender();\r\n personGender.setGender(this.registrationBeneficiaryForm.get(\"gender\").value);\r\n newBeneficiaryConfiguration.setGender(personGender);\r\n\r\n const personMaritalStatus = new MaritalStatus();\r\n personMaritalStatus.setMaritalStatus(this.registrationBeneficiaryForm.get(\"maritalStatus\").value);\r\n newBeneficiaryConfiguration.setMaritalStatus(personMaritalStatus);\r\n\r\n const address = new Address();\r\n address.setStreet(this.registrationBeneficiaryForm.get(\"street\").value);\r\n address.setNumber(this.registrationBeneficiaryForm.get(\"number\").value);\r\n address.setComplement(this.registrationBeneficiaryForm.get(\"complement\").value);\r\n address.setZipCode(this.registrationBeneficiaryForm.get(\"zipCode\").value.replace(/[^\\d]+/g, \"\"));\r\n address.setDistrict(this.registrationBeneficiaryForm.get(\"district\").value);\r\n address.setCity(this.registrationBeneficiaryForm.get(\"city\").value.getName());\r\n address.setRegion(this.registrationBeneficiaryForm.get(\"region\").value.getValue());\r\n newBeneficiaryConfiguration.setAddress(address);\r\n\r\n this.beneficiary = newBeneficiaryConfiguration;\r\n try {\r\n await this.beneficiaryService.saveBeneficiary(this.fiscalNumber.replace(/[^\\d]+/g, \"\"), this.beneficiary);\r\n this.beneficiary = await this.beneficiaryService.findBeneficiaryByKey(this.beneficiary.getBeneficiaryKey());\r\n this.toast.showSuccessToast(\"Edição de beneficiário salva com sucesso!\");\r\n } catch (erro) {\r\n this.toast.showWarningToast(erro);\r\n } finally {\r\n this.formDirty.markAsClean();\r\n this.loadingService.finishLoading(ref);\r\n this.loadBeneficiaryScreen();\r\n }\r\n }\r\n }\r\n\r\n getDependents(): Dependent[] {\r\n return this.beneficiary.getDependets();\r\n }\r\n\r\n hasAccessToEditBeneficiary(): boolean {\r\n return this.userService.getLoggedUser().hasPermission(UserPermissions.EditBeneficiary);\r\n }\r\n\r\n hasAccessToBeneficiaryBlockCard(): boolean {\r\n return this.userService.getLoggedUser().hasPermission(UserPermissions.BeneficiaryBlockCard);\r\n }\r\n\r\n hasAccessToBeneficiaryReactivateCard(): boolean {\r\n return this.userService.getLoggedUser().hasPermission(UserPermissions.BeneficiaryReactivateCard);\r\n }\r\n\r\n getCompany(): Company {\r\n return this.company;\r\n }\r\n\r\n getJobList(): JobDescription[] {\r\n return this.jobDescriptionList.filter((job) => job.getEnabled());\r\n }\r\n\r\n getStateList(): StateAcronym[] {\r\n return this.stateList;\r\n }\r\n\r\n getCityList(): City[] {\r\n return this.cityList;\r\n }\r\n\r\n getSelectedTabIndex(): number {\r\n return this.selectedTabIndex;\r\n }\r\n\r\n isBeneficiaryActive(): boolean {\r\n return this.beneficiary.isActive();\r\n }\r\n\r\n isBeneficiaryCardBlocked(): boolean {\r\n return this.beneficiary.getCard() && this.beneficiary.getCard().getIsBlocked();\r\n }\r\n\r\n isBeneficiaryCardCancelled(): boolean {\r\n return this.beneficiary.getCard() && this.beneficiary.getCard().getIsCancelled();\r\n }\r\n\r\n hasCard(): boolean {\r\n return !!this.beneficiary.getCard();\r\n }\r\n\r\n isEditableBeneficiary(): boolean {\r\n return this.hasAccessToEditBeneficiary() && !this.isBeneficiaryCardCancelled();\r\n }\r\n\r\n haveTransactionalPassword(): boolean {\r\n return this.beneficiary.getHaveTransactionalPassword();\r\n }\r\n\r\n onCancelBeneficiaryCard(): void {\r\n this.confirmDialogRef = this.dialog.open(ConfirmDialog, {\r\n disableClose: true,\r\n hasBackdrop: true,\r\n height: \"200px\",\r\n width: \"600px\",\r\n data: {\r\n title: \"Cancelamento de Cartão\",\r\n text: \"Deseja cancelar o cartão do beneficiário?\",\r\n },\r\n });\r\n\r\n this.confirmDialogRef.componentInstance.confirmDialogEvent.subscribe(async () => {\r\n const loadingRef = this.loadingService.beginLoading();\r\n\r\n try {\r\n await this.beneficiaryService.cancelBeneficiaryCard(this.beneficiary.getBeneficiaryKey());\r\n this.beneficiary = await this.beneficiaryService.findBeneficiaryByKey(this.beneficiary.getBeneficiaryKey());\r\n this.toast.showSuccessToast(\"Cartão cancelado com sucesso\");\r\n } catch (error) {\r\n this.toast.showWarningToast(\"Erro ao cancelar o cartão\");\r\n } finally {\r\n loadingRef.closeLoading();\r\n }\r\n });\r\n }\r\n\r\n async onOrderBeneficiaryCard() {\r\n const loadingRef = this.loadingService.beginLoading();\r\n\r\n try {\r\n const orderCardDTO = await this.beneficiaryService.orderBeneficiaryCard(this.beneficiary.getBeneficiaryKey());\r\n this.beneficiary = await this.beneficiaryService.findBeneficiaryByKey(this.beneficiary.getBeneficiaryKey());\r\n this.patchRegistrationBeneficiaryForm();\r\n this.openOrderBeneficiaryCardDialog(orderCardDTO);\r\n } catch (error) {\r\n this.toast.showWarningToast(error.error.Data.ErrorMessage);\r\n } finally {\r\n loadingRef.closeLoading();\r\n }\r\n }\r\n\r\n private openOrderBeneficiaryCardDialog(orderCardDTO: OrderCardDTO) {\r\n this.cardOrderDialogRef = this.dialog.open(CardOrderDialogComponent, {\r\n disableClose: true,\r\n hasBackdrop: true,\r\n height: \"320px\",\r\n width: \"600px\",\r\n data: orderCardDTO,\r\n });\r\n }\r\n\r\n openCardBlockDialog(): void {\r\n this.cardBlockDialogRef = this.dialog.open(CardBlockDialogComponent, {\r\n disableClose: true,\r\n hasBackdrop: true,\r\n height: \"345px\",\r\n width: \"600px\",\r\n data: this.beneficiary,\r\n });\r\n\r\n this.cardBlockDialogRef.componentInstance.blockCardNumberEvent.subscribe(async (data) => {\r\n this.beneficiary = await this.beneficiaryService.findBeneficiaryByKey(this.beneficiary.getBeneficiaryKey());\r\n this.beneficiaryService.setBeneficiary(this.beneficiary);\r\n });\r\n }\r\n\r\n openCardUnblockDialog(): void {\r\n this.cardUnblockDialogRef = this.dialog.open(CardUnblockDialogComponent, {\r\n disableClose: true,\r\n hasBackdrop: true,\r\n height: \"300px\",\r\n width: \"600px\",\r\n data: this.beneficiary,\r\n });\r\n\r\n this.cardUnblockDialogRef.componentInstance.unblockCardNumberEvent.subscribe(async (data) => {\r\n this.beneficiary = await this.beneficiaryService.findBeneficiaryByKey(this.beneficiary.getBeneficiaryKey());\r\n this.beneficiaryService.setBeneficiary(this.beneficiary);\r\n });\r\n }\r\n\r\n async exportBeneficiaryUsageFile(): Promise {\r\n const loadingRef = this.loadingService.beginLoading();\r\n try {\r\n const data = await this.beneficiaryService.exportBeneficiaryUsageFileByCardNumber(this.beneficiary.getCard().getCardNumber());\r\n const a = document.createElement(\"a\");\r\n document.body.appendChild(a);\r\n const url = window.URL.createObjectURL(data);\r\n a.href = url;\r\n a.download = `Relatório_Consumo_${this.beneficiary.getSocialNumber()}.csv`;\r\n a.click();\r\n this.toast.showSuccessToast(\"Arquivo .csv exportado com sucesso.\");\r\n } catch (error) {\r\n console.log(error);\r\n } finally {\r\n loadingRef.closeLoading();\r\n }\r\n }\r\n\r\n openAddJobDescriptionDialog() {\r\n this.addJobDescriptionRef = this.dialog.open(AddJobDescriptionDialog, {\r\n disableClose: true,\r\n hasBackdrop: true,\r\n height: \"600px\",\r\n width: \"900px\",\r\n data: {\r\n strategy: JobDescriptionDialogType.Beneficiary,\r\n company: this.company,\r\n jobDescriptionList: this.jobDescriptionList,\r\n },\r\n });\r\n\r\n this.addJobDescriptionRef.componentInstance.closeDialogEvent.subscribe(async (beneficiaryJobDescription: JobDescription) => {\r\n const loadingRef = this.loadingService.beginLoading();\r\n try {\r\n this.jobDescriptionList = await this.jobDescriptionService.getJobDescription(this.company.getFiscalNumber());\r\n if (beneficiaryJobDescription) {\r\n const peteca = this.jobDescriptionList.find((job) => job.getKey() === beneficiaryJobDescription.getKey());\r\n this.registrationBeneficiaryForm.get(\"jobDescription\").setValue(peteca);\r\n }\r\n } finally {\r\n loadingRef.closeLoading();\r\n }\r\n });\r\n }\r\n}\r\n","\r\n \r\n
\r\n
\r\n
\r\n \r\n
\r\n
{{ getCompany().getCorporateName() }}
\r\n CNPJ: {{ getCompany().getFiscalNumber() | companyFederalNumber }} \r\n
\r\n
\r\n Vidas: {{ getCompany().getCompanyInfo().getEmployeeCount() }}\r\n
\r\n
\r\n
\r\n
\r\n
\r\n Número do Cartão: {{ registrationBeneficiaryForm.get(\"cardNumber\").value | cardNumberFormat }}\r\n \r\n Habilitar delivery\r\n \r\n
\r\n
\r\n \r\n BLOQUEADO\r\n
\r\n
\r\n
\r\n
\r\n \r\n CPF\r\n \r\n \r\n \r\n Nome\r\n \r\n \r\n
\r\n
\r\n
\r\n \r\n Data de Admissão\r\n \r\n \r\n\r\n \r\n Matrícula\r\n \r\n \r\n\r\n \r\n Cargo\r\n \r\n {{ job.getTitle() }}\r\n - Adicionar novo cargo -\r\n \r\n \r\n
\r\n
\r\n \r\n Data de Nascimento\r\n \r\n \r\n\r\n \r\n Sexo\r\n \r\n {{ genderType.Male }}\r\n {{ genderType.Female }}\r\n {{ genderType.Unknow }}\r\n \r\n \r\n\r\n \r\n Estado Civil\r\n \r\n Casado\r\n Solteiro\r\n Divorciado\r\n Viúvo\r\n \r\n \r\n
\r\n
\r\n \r\n Telefone\r\n \r\n \r\n\r\n \r\n Celular\r\n \r\n \r\n
\r\n
\r\n \r\n CEP\r\n \r\n \r\n\r\n \r\n Endereço\r\n \r\n \r\n\r\n \r\n Número\r\n \r\n \r\n
\r\n
\r\n \r\n Complemento\r\n \r\n \r\n \r\n Estado\r\n \r\n Selecione\r\n {{ state.getValue() }}\r\n \r\n \r\n\r\n \r\n Cidade\r\n \r\n Selecione\r\n {{ city.getName() }}\r\n \r\n \r\n\r\n \r\n Bairro\r\n \r\n \r\n
\r\n
\r\n \r\n E-mail\r\n \r\n \r\n\r\n \r\n Validar email no próximo acesso\r\n \r\n
\r\n
\r\n {{ haveTransactionalPassword() ? \"Alterar\" : \"Inserir\" }} senha?\r\n \r\n Senha Transacional\r\n \r\n {{ showPassword ? \"visibility_off\" : \"visibility\" }}\r\n \r\n \r\n Repetir senha transacional\r\n \r\n {{ showConfirmPassword ? \"visibility_off\" : \"visibility\" }}\r\n \r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n \r\n CANCELAR CARTÃO\r\n \r\n
\r\n\r\n
\r\n \r\n 2° VIA DE CARTÃO\r\n \r\n \r\n BLOQUEAR CARTÃO\r\n \r\n \r\n \r\n DESBLOQUEAR CARTÃO\r\n \r\n \r\n GERAR CONSUMO\r\n \r\n
\r\n
\r\n
\r\n\r\n \r\n
\r\n Dependentes Cadastrados: {{ getDependents().length }}\r\n\r\n
\r\n REGISTRAR DEPENDENTE\r\n
\r\n
\r\n\r\n
\r\n
\r\n
\r\n
\r\n
\r\n

{{ dependent?.getName() }}

\r\n
\r\n\r\n
\r\n Número do cartão: {{ dependent?.getCard()?.getCardNumber() | cardNumberFormat }}\r\n
\r\n \r\n BLOQUEADO\r\n
\r\n
\r\n\r\n
\r\n
\r\n CPF: {{ dependent?.getSocialNumber() | socialNumberFormatPipe }}\r\n Nascimento: {{ dependent?.getBirthDate() | dateFormat }}\r\n
\r\n\r\n
\r\n Sexo: {{ dependent?.getGender()?.getView() }}\r\n Estado Civil: {{ dependent?.getMaritalStatus()?.getView() }}\r\n
\r\n\r\n
\r\n Celular: {{ dependent?.getMobile() | mobileFormatPipe }}\r\n E-mail: {{ dependent?.getEmail() }}\r\n
\r\n
\r\n
\r\n
\r\n\r\n
\r\n \r\n check_circle_outline\r\n clear\r\n\r\n {{ dependent.isActive() ? \"ATIVO\" : \"INATIVO\" }}\r\n
\r\n
\r\n edit_note\r\n {{ isEditableBeneficiary() ? \"EDITAR\" : \"VISUALIZAR\" }}\r\n
\r\n
\r\n
\r\n \r\n
\r\n
\r\n","import { Component, Inject } from \"@angular/core\";\r\nimport { MatDialogRef, MAT_DIALOG_DATA } from \"@angular/material/dialog\";\r\nimport { OrderCardDTO } from \"src/app/ui/models/domains/pbm/Beneficiary/dto/order-card-dto\";\r\n\r\n@Component({\r\n templateUrl: \"./card-order-dialog.component.html\",\r\n styleUrls: [\"./card-order-dialog.component.scss\"],\r\n})\r\nexport class CardOrderDialogComponent {\r\n constructor(public dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public data: OrderCardDTO) {}\r\n\r\n getProtocolNumber(): string {\r\n return this.data.getProtocol().getNumber();\r\n }\r\n\r\n getCardNumber(): string {\r\n return this.data.getCard().getCardNumber();\r\n }\r\n\r\n closeDialog(): void {\r\n this.dialogRef.close();\r\n }\r\n}\r\n","
\r\n

SOLICITAÇÃO DE 2° VIA DE CARTÃO

\r\n
\r\n\r\n
\r\n
\r\n Protocolo da operação:\r\n {{ getProtocolNumber() }}\r\n
\r\n\r\n
\r\n Novo número de cartão:\r\n {{ getCardNumber() | cardNumberFormat }}\r\n
\r\n
\r\n\r\n
\r\n \r\n
\r\n","import { BeneficiaryKey } from \"../../Benefit/beneficiary-key\";\r\n\r\nexport class CardUnblockDTO {\r\n constructor(private readonly beneficiaryKey: BeneficiaryKey, private readonly includeDependents: boolean) {}\r\n\r\n getBeneficiaryKey(): BeneficiaryKey {\r\n return this.beneficiaryKey;\r\n }\r\n\r\n getIncludeDependents(): boolean {\r\n return this.includeDependents;\r\n }\r\n}\r\n","import { Component, EventEmitter, Inject } from \"@angular/core\";\r\nimport { UntypedFormBuilder, UntypedFormControl } from \"@angular/forms\";\r\nimport { Beneficiary } from \"src/app/ui/models/domains/pbm/Beneficiary/beneficiary\";\r\nimport { CardUnblockDTO } from \"src/app/ui/models/domains/pbm/Beneficiary/dto/card-unblock-dto\";\r\nimport { Dependent } from \"src/app/ui/models/domains/pbm/Beneficiary/dependent\";\r\nimport { LoadingService } from \"src/app/ui/services/loading.service\";\r\nimport { BeneficiaryService } from \"src/app/ui/services/pbm/beneficiary.service\";\r\nimport { Toast } from \"../../../../toast/toast\";\r\nimport { MatDialogRef, MAT_DIALOG_DATA } from \"@angular/material/dialog\";\r\n\r\n@Component({\r\n templateUrl: \"./card-unblock-dialog.component.html\",\r\n styleUrls: [\"./card-unblock-dialog.component.scss\"],\r\n})\r\nexport class CardUnblockDialogComponent {\r\n unblockCardNumberEvent: EventEmitter = new EventEmitter();\r\n includeDependetsFormControl = new UntypedFormControl(false);\r\n\r\n constructor(\r\n public dialogRef: MatDialogRef,\r\n @Inject(MAT_DIALOG_DATA) public data: Beneficiary | Dependent,\r\n public beneficiaryService: BeneficiaryService,\r\n public formBuilder: UntypedFormBuilder,\r\n private loadingService: LoadingService,\r\n private toast: Toast,\r\n ) {}\r\n\r\n closeDialog(): void {\r\n this.dialogRef.close();\r\n }\r\n\r\n async unblockBeneficiaryCard(): Promise {\r\n const loadingRef = this.loadingService.beginLoading();\r\n\r\n try {\r\n const cardUnblockDTO = this.buildCardUnblockDTO();\r\n await this.beneficiaryService.unblockBeneficiaryCard(cardUnblockDTO);\r\n this.toast.showSuccessToast(\"Cartão desbloqueado com sucesso.\");\r\n this.unblockCardNumberEvent.emit(this.data);\r\n this.closeDialog();\r\n } catch (err) {\r\n this.toast.showWarningToast(\"Erro ao desbloquear cartão.\");\r\n } finally {\r\n loadingRef.closeLoading();\r\n }\r\n }\r\n\r\n private buildCardUnblockDTO(): CardUnblockDTO {\r\n const beneficiaryKey = this.data.getBeneficiaryKey();\r\n const includeDependents = this.includeDependetsFormControl.value;\r\n\r\n return new CardUnblockDTO(beneficiaryKey, includeDependents);\r\n }\r\n\r\n public isBeneficiary(): boolean {\r\n return this.data instanceof Beneficiary;\r\n }\r\n\r\n public getName(): string {\r\n return this.data.getName();\r\n }\r\n\r\n public getCardNumber(): string {\r\n return this.data.getCard().getCardNumber();\r\n }\r\n}\r\n","
\r\n

DESBLOQUEIO DE CARTÃO

\r\n
\r\n\r\n
\r\n
\r\n
\r\n

{{ isBeneficiary() ? \"Beneficiário\" : \"Dependente\" }}

\r\n

{{ getName() }}

\r\n
\r\n\r\n
\r\n

Número do cartão

\r\n

{{ getCardNumber() | cardNumberFormat }}

\r\n
\r\n
\r\n\r\n
\r\n Incluir dependentes no desbloqueio?\r\n
\r\n
\r\n\r\n
\r\n \r\n\r\n \r\n
\r\n","export enum FilterBy {\r\n LastDay = \"Ontem\",\r\n Last7Days = \"Últimos 7 dias\",\r\n Last15Days = \"Últimos 15 dias\",\r\n LastMonth = \"Último mês\",\r\n}\r\n","import { Injectable } from \"@angular/core\";\r\n\r\nimport { PagingRequest } from \"../../models/domains/paginator/paging-request\";\r\nimport { PageableResult } from \"../../models/domains/paginator/pageable-result\";\r\nimport { SalesHistoryRepository } from \"../../repositories/pbm/sales-history.repository\";\r\nimport { SalesHistoryCompany } from \"../../models/domains/pbm/sales-history/sales-history-company\";\r\n\r\n@Injectable({ providedIn: \"root\" })\r\nexport class SalesHistoryService {\r\n constructor(private salesHistoryRepository: SalesHistoryRepository) {}\r\n\r\n public async findSalesHistory(filterText: string, pagingRequest: PagingRequest): Promise {\r\n return await this.salesHistoryRepository.findSalesHistory(filterText, pagingRequest);\r\n }\r\n\r\n public async findSalesHistoryByFiscalNumber(pagingRequest: PagingRequest): Promise {\r\n return await this.salesHistoryRepository.findSalesHistoryByFiscalNumber(pagingRequest);\r\n }\r\n}\r\n","import { Component, OnInit, Output, Input, EventEmitter } from \"@angular/core\";\r\n\r\nimport { SalesHistoryCompanySummary } from \"src/app/ui/models/domains/pbm/sales-history/sales-history-company-summary\";\r\n\r\n@Component({\r\n selector: \"sales-history-company-card\",\r\n templateUrl: \"./sales-history-company-card.component.html\",\r\n styleUrls: [\"./sales-history-company-card.component.scss\"],\r\n})\r\nexport class SalesHistoryCompanyCardComponent implements OnInit {\r\n @Input() salesHistoryCompanySummary: SalesHistoryCompanySummary;\r\n\r\n @Output() detailSalesHistory: EventEmitter = new EventEmitter();\r\n\r\n constructor() {}\r\n\r\n ngOnInit() {}\r\n\r\n detail(): void {\r\n this.detailSalesHistory.emit(this.salesHistoryCompanySummary.getFiscalNumber());\r\n }\r\n}\r\n","
\r\n \r\n
\r\n {{ salesHistoryCompanySummary.getCorporateName() }}\r\n CNPJ: {{ salesHistoryCompanySummary.getFiscalNumber() | companyFederalNumber }}\r\n
\r\n
\r\n\r\n
\r\n {{ salesHistoryCompanySummary.getProductSoldCount() }} Produtos vendidos\r\n
\r\n\r\n
\r\n Top {{ salesHistoryCompanySummary.getSalesHistoryProductList().length }} mais vendidos\r\n\r\n
\r\n VER TODOS\r\n
\r\n
\r\n\r\n
\r\n
\r\n {{ salesHistoryCompanySummary.getSalesHistoryProductList()[0].getProductName() }}\r\n
\r\n {{ salesHistoryCompanySummary.getSalesHistoryProductList()[0].getSoldItemQuantity() }}\r\n
\r\n
\r\n\r\n
\r\n -\r\n
\r\n 0\r\n
\r\n
\r\n\r\n
\r\n {{ salesHistoryCompanySummary.getSalesHistoryProductList()[1].getProductName() }}\r\n
\r\n {{ salesHistoryCompanySummary.getSalesHistoryProductList()[1].getSoldItemQuantity() }}\r\n
\r\n
\r\n\r\n
\r\n -\r\n
\r\n 0\r\n
\r\n
\r\n\r\n
\r\n {{ salesHistoryCompanySummary.getSalesHistoryProductList()[2].getProductName() }}\r\n
\r\n {{ salesHistoryCompanySummary.getSalesHistoryProductList()[2].getSoldItemQuantity() }}\r\n
\r\n
\r\n\r\n
\r\n -\r\n
\r\n 0\r\n
\r\n
\r\n\r\n
\r\n {{ salesHistoryCompanySummary.getSalesHistoryProductList()[3].getProductName() }}\r\n
\r\n {{ salesHistoryCompanySummary.getSalesHistoryProductList()[3].getSoldItemQuantity() }}\r\n
\r\n
\r\n\r\n
\r\n -\r\n
\r\n 0\r\n
\r\n
\r\n\r\n
\r\n {{ salesHistoryCompanySummary.getSalesHistoryProductList()[4].getProductName() }}\r\n
\r\n {{ salesHistoryCompanySummary.getSalesHistoryProductList()[4].getSoldItemQuantity() }}\r\n
\r\n
\r\n\r\n
\r\n -\r\n
\r\n 0\r\n
\r\n
\r\n\r\n
\r\n {{ salesHistoryCompanySummary.getSalesHistoryProductList()[5].getProductName() }}\r\n
\r\n {{ salesHistoryCompanySummary.getSalesHistoryProductList()[5].getSoldItemQuantity() }}\r\n
\r\n
\r\n\r\n
\r\n -\r\n
\r\n 0\r\n
\r\n
\r\n
\r\n","import { Component, OnInit } from \"@angular/core\";\r\nimport { Router } from \"@angular/router\";\r\n\r\nimport { PagingRequest } from \"./../../../../models/domains/paginator/paging-request\";\r\nimport { RoutePath } from \"./../../../../models/domains/route-paths.model\";\r\nimport { FeatureViewService } from \"src/app/ui/services/feature-view.service\";\r\nimport { FeatureViews } from \"src/app/ui/models/domains/features/custom-feature-views\";\r\nimport { PageViews } from \"src/app/ui/models/domains/features/custom-page-views\";\r\nimport { PageableResult } from \"src/app/ui/models/domains/paginator/pageable-result\";\r\nimport { SalesHistoryService } from \"src/app/ui/services/pbm/sales-history.service\";\r\nimport { LoadingService } from \"src/app/ui/services/loading.service\";\r\nimport { FilterBy } from \"src/app/ui/models/domains/pbm/sales-history/filter-by\";\r\nimport { MaskInput } from \"src/app/ui/models/domains/masks/mask.model\";\r\nimport { Toast } from \"../../../toast/toast\";\r\nimport { UserService } from \"src/app/ui/services/user.service\";\r\nimport { UntypedFormControl } from \"@angular/forms\";\r\nimport { FiscalNumber } from \"src/app/ui/models/domains/pbm/fiscal-number\";\r\n\r\n@Component({\r\n selector: \"sales-history-companies\",\r\n templateUrl: \"./sales-history-companies.component.html\",\r\n styleUrls: [\"./sales-history-companies.component.scss\"],\r\n})\r\nexport class SalesHistoryCompaniesComponent implements OnInit {\r\n pageableResult: PageableResult = new PageableResult();\r\n filterBy = FilterBy;\r\n fiscalNumberMask = MaskInput.getFicalNumberMask();\r\n filterText: string = \"\";\r\n messageResult = new MessageResult();\r\n searchType: UntypedFormControl;\r\n totalPerPage = 10;\r\n showLoadMore = true;\r\n\r\n constructor(\r\n private featureViewService: FeatureViewService,\r\n private router: Router,\r\n private salesHistoryService: SalesHistoryService,\r\n private loadingService: LoadingService,\r\n private toast: Toast,\r\n private userService: UserService,\r\n ) {\r\n this.searchType = new UntypedFormControl(1);\r\n }\r\n\r\n async ngOnInit() {\r\n this.featureViewService.activeFeatureView(FeatureViews.SalesHistoryCompanies, PageViews.SalesHistoriesPageView);\r\n const userProfile = this.userService.getUserProfile();\r\n if (userProfile.getPreferences().getFilterText()) {\r\n this.detailSalesHistory(userProfile.getPreferences().getFilterText());\r\n }\r\n const ref = this.loadingService.beginLoading();\r\n const pagingRequest = new PagingRequest();\r\n pagingRequest.setStart(1);\r\n pagingRequest.setEnd(this.totalPerPage);\r\n pagingRequest.setFilterText(\"Last7Days\");\r\n try {\r\n this.pageableResult = await this.salesHistoryService.findSalesHistory(\"\", pagingRequest);\r\n if (this.salesHistoryList().length === 0) {\r\n this.messageResult.setMessage(\"Nenhum resultado encontrado.\");\r\n this.showLoadMore = false;\r\n } else {\r\n this.messageResult.setMessage(\"\");\r\n }\r\n } catch (error) {\r\n this.toast.showWarningToast(error);\r\n } finally {\r\n this.loadingService.finishLoading(ref);\r\n }\r\n }\r\n\r\n onPressEnterSearchCompanies(event): void {\r\n if (event.key === \"Enter\") {\r\n this.onSearchCompany(this.filterText);\r\n }\r\n }\r\n\r\n async searchMoreSalesHistories() {\r\n const ref = this.loadingService.beginLoading();\r\n\r\n const filter = document.getElementById(\"filter\") as HTMLSelectElement;\r\n\r\n const pagingRequest = new PagingRequest();\r\n pagingRequest.setStart(this.pageableResult.getEnd());\r\n pagingRequest.setEnd(this.totalPerPage);\r\n pagingRequest.setFilterText(filter.value);\r\n\r\n try {\r\n const result = await this.salesHistoryService.findSalesHistory(\"\", pagingRequest);\r\n this.pageableResult.setStart(result.getStart());\r\n this.pageableResult.setEnd(this.totalPerPage + 1);\r\n this.pageableResult.addItems(result.getItems());\r\n if (result.getItems().length < this.totalPerPage) {\r\n this.showLoadMore = false;\r\n }\r\n } catch (error) {\r\n this.toast.showWarningToast(error);\r\n } finally {\r\n this.loadingService.finishLoading(ref);\r\n }\r\n }\r\n\r\n async onSearchCompany(filterText: string) {\r\n const ref = this.loadingService.beginLoading();\r\n const filter = document.getElementById(\"filter\") as HTMLSelectElement;\r\n const pagingRequest = new PagingRequest();\r\n pagingRequest.setStart(1);\r\n pagingRequest.setEnd(this.totalPerPage);\r\n pagingRequest.setFilterText(filter.value);\r\n try {\r\n this.pageableResult = await this.salesHistoryService.findSalesHistory(filterText.replace(/[./-]/g, \"\"), pagingRequest);\r\n if (this.salesHistoryList().length === 0) {\r\n this.messageResult.setMessage(\"Nenhum resultado encontrado.\");\r\n this.showLoadMore = false;\r\n } else {\r\n this.messageResult.setMessage(\"\");\r\n }\r\n this.storageSearchPreferences(filterText);\r\n } catch (error) {\r\n this.toast.showWarningToast(error);\r\n } finally {\r\n this.loadingService.finishLoading(ref);\r\n }\r\n }\r\n\r\n salesHistoryList() {\r\n return this.pageableResult.getItems();\r\n }\r\n\r\n detailSalesHistory(filterText: string): void {\r\n if (FiscalNumber.isValid(filterText)) {\r\n this.router.navigate([RoutePath.SalesHistoryCompany], {\r\n queryParams: { b: filterText },\r\n });\r\n }\r\n }\r\n\r\n storageSearchPreferences(filterText: string): void {\r\n this.userService.setUserPreferences(filterText.replace(/[./-]/g, \"\"));\r\n }\r\n}\r\n\r\nclass MessageResult {\r\n private message: string;\r\n\r\n constructor() {\r\n this.message = \"\";\r\n }\r\n\r\n setMessage(value: string): void {\r\n this.message = value;\r\n }\r\n\r\n getMessage(): string {\r\n return this.message;\r\n }\r\n}\r\n","
\r\n
\r\n \r\n \r\n \r\n
\r\n search\r\n
\r\n
\r\n\r\n \r\n
\r\n
\r\n

\r\n {{ messageResult.getMessage() }}\r\n

\r\n
\r\n \r\n
\r\n \r\n
\r\n","import { UntypedFormBuilder, UntypedFormGroup } from \"@angular/forms\";\r\nimport { Component, OnInit } from \"@angular/core\";\r\nimport { ActivatedRoute, Router } from \"@angular/router\";\r\n\r\nimport { SalesHistoryService } from \"./../../../../services/pbm/sales-history.service\";\r\nimport { FeatureViewService } from \"src/app/ui/services/feature-view.service\";\r\nimport { FeatureViews } from \"src/app/ui/models/domains/features/custom-feature-views\";\r\nimport { PageViews } from \"src/app/ui/models/domains/features/custom-page-views\";\r\nimport { RoutePath } from \"src/app/ui/models/domains/route-paths.model\";\r\nimport { SalesHistoryCompany } from \"src/app/ui/models/domains/pbm/sales-history/sales-history-company\";\r\nimport { PagingRequest } from \"src/app/ui/models/domains/paginator/paging-request\";\r\nimport { ProductType } from \"src/app/ui/models/domains/pbm/Benefit/product-type\";\r\nimport { LoadingService } from \"src/app/ui/services/loading.service\";\r\nimport { MaskInput } from \"src/app/ui/models/domains/masks/mask.model\";\r\nimport { FilterOption } from \"src/app/ui/models/domains/filters/filter-option\";\r\nimport { FilterOptionType } from \"src/app/ui/models/domains/filters/filter-option-type.enum\";\r\nimport { Toast } from \"../../../toast/toast\";\r\nimport moment from \"moment\";\r\nimport { FilterFormValidator } from \"../validators/filter-form-validator\";\r\nimport { ProductService } from \"src/app/ui/services/pbm/product.service\";\r\nimport { UserService } from \"src/app/ui/services/user.service\";\r\n\r\n@Component({\r\n selector: \"sales-history-company\",\r\n templateUrl: \"./sales-history-company.component.html\",\r\n styleUrls: [\"./sales-history-company.component.scss\"],\r\n})\r\nexport class SalesHistoryCompanyComponent implements OnInit {\r\n private salesHistoryCompany: SalesHistoryCompany;\r\n private productTypes: ProductType[];\r\n public dataMask = MaskInput.getDateMask();\r\n private fiscalNumber: string;\r\n\r\n public filterForm: UntypedFormGroup = this.formBuilder.group({\r\n startDate: [moment().subtract(1, \"M\").format(\"DDMMYYYY\")],\r\n endDate: [moment().format(\"DDMMYYYY\")],\r\n productManufacturer: [],\r\n productType: [],\r\n });\r\n\r\n constructor(\r\n private featureViewService: FeatureViewService,\r\n private activatedRoute: ActivatedRoute,\r\n private router: Router,\r\n private salesHistoryService: SalesHistoryService,\r\n private productService: ProductService,\r\n private loadingService: LoadingService,\r\n private toast: Toast,\r\n private formBuilder: UntypedFormBuilder,\r\n private userService: UserService,\r\n ) {}\r\n\r\n async ngOnInit() {\r\n this.featureViewService.activeFeatureView(FeatureViews.SalesHistoryCompany, PageViews.SalesHistoriesPageView);\r\n\r\n const paramns = this.activatedRoute.snapshot.queryParams;\r\n\r\n if (!!paramns.b) {\r\n const ref = this.loadingService.beginLoading();\r\n\r\n this.fiscalNumber = paramns.b;\r\n\r\n const startDateFilter = new FilterOption(FilterOptionType.Text, \"startDateFilter\", \"startDateFilter\");\r\n startDateFilter.setValue(moment().subtract(1, \"M\").format(\"DDMMYYYY\"));\r\n\r\n const endDateFilter = new FilterOption(FilterOptionType.Text, \"endDateFilter\", \"endDateFilter\");\r\n endDateFilter.setValue(moment().format(\"DDMMYYYY\"));\r\n\r\n const productManufacturerFilter = new FilterOption(FilterOptionType.Text, \"productManufacturerFilter\", \"productManufacturerFilter\");\r\n productManufacturerFilter.setValue(\"\");\r\n\r\n const prouctTypeFilter = new FilterOption(FilterOptionType.Text, \"prouctTypeFilter\", \"prouctTypeFilter\");\r\n prouctTypeFilter.setValue(\"\");\r\n\r\n const fiscalNumberFilter = new FilterOption(FilterOptionType.Text, \"fiscalNumberFilter\", \"fiscalNumberFilter\");\r\n fiscalNumberFilter.setValue(this.fiscalNumber);\r\n\r\n const filters: FilterOption[] = [];\r\n filters.push(startDateFilter);\r\n filters.push(endDateFilter);\r\n filters.push(productManufacturerFilter);\r\n filters.push(prouctTypeFilter);\r\n filters.push(fiscalNumberFilter);\r\n\r\n const pagingRequest = new PagingRequest();\r\n pagingRequest.setStart(1);\r\n pagingRequest.setEnd(10);\r\n pagingRequest.setFilters(filters);\r\n\r\n try {\r\n this.productTypes = await this.productService.getProductTypes();\r\n this.salesHistoryCompany = await this.salesHistoryService.findSalesHistoryByFiscalNumber(pagingRequest);\r\n } catch (error) {\r\n this.toast.showWarningToast(error);\r\n this.storageSearchPreferences(\"\");\r\n this.router.navigate([RoutePath.SalesHistoryCompanies]);\r\n } finally {\r\n this.loadingService.finishLoading(ref);\r\n }\r\n } else {\r\n this.router.navigate([RoutePath.SalesHistoryCompanies]);\r\n }\r\n }\r\n\r\n async onFilterChange(): Promise {\r\n const ref = this.loadingService.beginLoading();\r\n\r\n const filterFormValidator = new FilterFormValidator();\r\n\r\n if (filterFormValidator.validate(this.filterForm).hasErrorMessages()) {\r\n this.toast.showWarningToast(filterFormValidator.getValidationResult().getErrorMessage());\r\n this.loadingService.finishLoading(ref);\r\n } else {\r\n const startDate = this.filterForm.get(\"startDate\").value;\r\n const endDate = this.filterForm.get(\"endDate\").value;\r\n const productManufacturer = this.filterForm.get(\"productManufacturer\").value;\r\n const productType = this.filterForm.get(\"productType\") ? this.filterForm.get(\"productType\").value : \"\";\r\n\r\n const startDateFilter = new FilterOption(FilterOptionType.Text, \"startDateFilter\", \"startDateFilter\");\r\n startDateFilter.setValue(moment(startDate, \"DD/MM/YYYY\").format(\"DDMMYYYY\"));\r\n\r\n const endDateFilter = new FilterOption(FilterOptionType.Text, \"endDateFilter\", \"endDateFilter\");\r\n endDateFilter.setValue(moment(endDate, \"DD/MM/YYYY\").format(\"DDMMYYYY\"));\r\n\r\n const productManufacturerFilter = new FilterOption(FilterOptionType.Text, \"productManufacturerFilter\", \"productManufacturerFilter\");\r\n productManufacturerFilter.setValue(productManufacturer);\r\n\r\n const prouctTypeFilter = new FilterOption(FilterOptionType.Text, \"prouctTypeFilter\", \"prouctTypeFilter\");\r\n prouctTypeFilter.setValue(productType);\r\n\r\n const fiscalNumberFilter = new FilterOption(FilterOptionType.Text, \"fiscalNumberFilter\", \"fiscalNumberFilter\");\r\n fiscalNumberFilter.setValue(this.fiscalNumber);\r\n\r\n const filters: FilterOption[] = [];\r\n filters.push(startDateFilter);\r\n filters.push(endDateFilter);\r\n filters.push(productManufacturerFilter);\r\n filters.push(prouctTypeFilter);\r\n filters.push(fiscalNumberFilter);\r\n\r\n const pagingRequest = new PagingRequest();\r\n pagingRequest.setStart(1);\r\n pagingRequest.setEnd(10);\r\n pagingRequest.setFilters(filters);\r\n\r\n try {\r\n this.salesHistoryCompany = await this.salesHistoryService.findSalesHistoryByFiscalNumber(pagingRequest);\r\n } catch (error) {\r\n this.toast.showWarningToast(error);\r\n } finally {\r\n this.loadingService.finishLoading(ref);\r\n }\r\n }\r\n }\r\n\r\n async searchMore(): Promise {\r\n const ref = this.loadingService.beginLoading();\r\n\r\n const startDate = this.filterForm.get(\"startDate\").value;\r\n const endDate = this.filterForm.get(\"endDate\").value;\r\n const productManufacturer = this.filterForm.get(\"productManufacturer\").value;\r\n const productType = this.filterForm.get(\"productType\") ? this.filterForm.get(\"productType\").value : \"\";\r\n\r\n const startDateFilter = new FilterOption(FilterOptionType.Text, \"startDateFilter\", \"startDateFilter\");\r\n startDateFilter.setValue(moment(startDate, \"DD/MM/YYYY\").format(\"DDMMYYYY\"));\r\n\r\n const endDateFilter = new FilterOption(FilterOptionType.Text, \"endDateFilter\", \"endDateFilter\");\r\n endDateFilter.setValue(moment(endDate, \"DD/MM/YYYY\").format(\"DDMMYYYY\"));\r\n\r\n const productManufacturerFilter = new FilterOption(FilterOptionType.Text, \"productManufacturerFilter\", \"productManufacturerFilter\");\r\n productManufacturerFilter.setValue(productManufacturer);\r\n\r\n const prouctTypeFilter = new FilterOption(FilterOptionType.Text, \"prouctTypeFilter\", \"prouctTypeFilter\");\r\n prouctTypeFilter.setValue(productType);\r\n\r\n const fiscalNumberFilter = new FilterOption(FilterOptionType.Text, \"fiscalNumberFilter\", \"fiscalNumberFilter\");\r\n fiscalNumberFilter.setValue(this.fiscalNumber);\r\n\r\n const filters: FilterOption[] = [];\r\n filters.push(startDateFilter);\r\n filters.push(endDateFilter);\r\n filters.push(productManufacturerFilter);\r\n filters.push(prouctTypeFilter);\r\n filters.push(fiscalNumberFilter);\r\n\r\n const pagingRequest = new PagingRequest();\r\n pagingRequest.setStart(this.salesHistoryCompany.getPagingInfo().getEnd());\r\n pagingRequest.setEnd(10);\r\n pagingRequest.setFilters(filters);\r\n\r\n try {\r\n const result = await this.salesHistoryService.findSalesHistoryByFiscalNumber(pagingRequest);\r\n this.salesHistoryCompany.setPagingInfo(result.getPagingInfo());\r\n this.salesHistoryCompany.addItems(result.getcompanySalesHistoryItemList());\r\n } catch (error) {\r\n this.toast.showWarningToast(error);\r\n } finally {\r\n this.loadingService.finishLoading(ref);\r\n }\r\n }\r\n\r\n backToSalesHistorySummary(): void {\r\n this.userService.setUserPreferences(\"\");\r\n this.router.navigate([RoutePath.SalesHistoryCompanies]);\r\n }\r\n\r\n hasSalesHistoryCompany(): boolean {\r\n return !!this.salesHistoryCompany;\r\n }\r\n\r\n hasSalesHistoryCompanyItem(): boolean {\r\n return !!this.salesHistoryCompany && this.salesHistoryCompany.getcompanySalesHistoryItemList().length > 0;\r\n }\r\n\r\n getSalesHistoryCompany(): SalesHistoryCompany {\r\n return this.salesHistoryCompany;\r\n }\r\n\r\n getProductTypes(): ProductType[] {\r\n return this.productTypes;\r\n }\r\n\r\n storageSearchPreferences(fiscalNumber: string = \"\"): void {\r\n this.userService.setUserPreferences(fiscalNumber.replace(/[^\\d]+/g, \"\"));\r\n }\r\n}\r\n","
\r\n \r\n west\r\n VOLTAR\r\n \r\n
\r\n
\r\n \r\n
\r\n
\r\n
\r\n {{ getSalesHistoryCompany().getCorporateName() }}\r\n
\r\n \r\n CNPJ:\r\n {{ getSalesHistoryCompany().getFiscalNumber() | companyFederalNumber }}\r\n \r\n {{ getSalesHistoryCompany().getEmployeeCount() }} Vidas\r\n
\r\n
\r\n
\r\n
\r\n
\r\n Produtos
Vendidos
\r\n {{ getSalesHistoryCompany().getSalesHistorySummary().getProductSoldCount() }}\r\n
\r\n
\r\n Valores
Gerados
\r\n {{ getSalesHistoryCompany().getSalesHistorySummary().getSalesValueableCount() | currencyPbmPipe }}\r\n
\r\n
\r\n Subsídio
Praticado
\r\n {{ getSalesHistoryCompany().getSalesHistorySummary().getSalesSubsidyValueCount() | currencyPbmPipe }}\r\n
\r\n
\r\n Desconto
em folha
\r\n {{ getSalesHistoryCompany().getSalesHistorySummary().getPaymentrollValueCount() | currencyPbmPipe }}\r\n
\r\n
\r\n
\r\n
\r\n \r\n Data inicial\r\n \r\n \r\n \r\n Data final\r\n \r\n \r\n \r\n Por Fabricante\r\n \r\n \r\n \r\n Por Tipo de Produto\r\n \r\n Todos\r\n {{ type.getValue() }}\r\n \r\n \r\n
\r\n
\r\n
\r\n
\r\n
\r\n Medicamento/Produto\r\n {{ item.getProductName() }}\r\n
\r\n
\r\n Quantidade\r\n {{ item.getSoldItemCount() }}\r\n
\r\n
\r\n Região\r\n {{ item.getStateName() }}\r\n
\r\n
\r\n Rede\r\n {{ item.getNetworkName() }}\r\n
\r\n
\r\n Valor Gerado\r\n {{ item.getSoldValueCount().toFixed(2) | currencyPbmPipe }}\r\n
\r\n
\r\n \r\n
\r\n","import { ValidationResult } from \"src/app/ui/models/domains/validator/validation-result\";\r\nimport { UntypedFormGroup } from \"@angular/forms\";\r\nimport moment from \"moment\";\r\n\r\nexport class FilterFormValidator {\r\n private validationResult = new ValidationResult();\r\n\r\n getValidationResult(): ValidationResult {\r\n return this.validationResult;\r\n }\r\n\r\n validate(filterForm: UntypedFormGroup): ValidationResult {\r\n const startDate = moment(filterForm.get(\"startDate\").value, \"DD/MM/YYYY\");\r\n const endDate = moment(filterForm.get(\"endDate\").value, \"DD/MM/YYYY\");\r\n\r\n if (!startDate.isValid()) {\r\n this.validationResult.addErrorMessage(\"Data de início inválida.\");\r\n } else if (!endDate.isValid()) {\r\n this.validationResult.addErrorMessage(\"Data final inválida.\");\r\n } else if (startDate > endDate) {\r\n this.validationResult.addErrorMessage(\"Data inicial maior que data final.\");\r\n }\r\n\r\n return this.validationResult;\r\n }\r\n}\r\n","import { Component, OnInit } from \"@angular/core\";\r\nimport { Router } from \"@angular/router\";\r\n\r\nimport { UserPermissions } from \"./../../../../models/domains/pbm/user/user-permissions\";\r\nimport { RoutePath } from \"src/app/ui/models/domains/route-paths.model\";\r\nimport { Toast } from \"./../../../toast/toast\";\r\nimport { LoadingService } from \"./../../../../services/loading.service\";\r\nimport { PageableResult } from \"src/app/ui/models/domains/paginator/pageable-result\";\r\nimport { UserService } from \"./../../../../services/user.service\";\r\nimport { FeatureViewService } from \"src/app/ui/services/feature-view.service\";\r\nimport { FeatureViews } from \"src/app/ui/models/domains/features/custom-feature-views\";\r\nimport { PageViews } from \"src/app/ui/models/domains/features/custom-page-views\";\r\nimport { PagingRequest } from \"src/app/ui/models/domains/paginator/paging-request\";\r\nimport { User } from \"src/app/ui/models/domains/pbm/user/user\";\r\nimport { AppContext } from \"src/app/ui/contexts/app-context\";\r\nimport { UntypedFormControl } from \"@angular/forms\";\r\n\r\n@Component({\r\n selector: \"search-user\",\r\n templateUrl: \"./search-user.component.html\",\r\n styleUrls: [\"./search-user.component.scss\"],\r\n})\r\nexport class SearchUserComponent implements OnInit {\r\n pageableResult = new PageableResult();\r\n nameControl = new UntypedFormControl();\r\n\r\n constructor(\r\n private featureViewService: FeatureViewService,\r\n private userService: UserService,\r\n private loadingService: LoadingService,\r\n private toast: Toast,\r\n private router: Router,\r\n private appContext: AppContext,\r\n ) {}\r\n\r\n async ngOnInit() {\r\n this.featureViewService.activeFeatureView(FeatureViews.UserSearchFeatureView, PageViews.UserPageView);\r\n this.searchUserByName();\r\n }\r\n\r\n async searchUserByName() {\r\n const ref = this.loadingService.beginLoading();\r\n const pagingRequest = new PagingRequest();\r\n pagingRequest.setStart(1);\r\n pagingRequest.setEnd(this.appContext.getTotalPerPage());\r\n pagingRequest.setFilterText(this.nameControl.value);\r\n try {\r\n const result = await this.userService.searchUser(pagingRequest);\r\n this.pageableResult.setStart(pagingRequest.getStart());\r\n this.pageableResult.setEnd(pagingRequest.getEnd());\r\n this.pageableResult.setTotalItems(result.getTotalItems());\r\n this.pageableResult.setItems(result.getItems());\r\n } catch (error) {\r\n this.toast.showWarningToast(error);\r\n } finally {\r\n this.loadingService.finishLoading(ref);\r\n }\r\n }\r\n\r\n async searchMoreUsers() {\r\n const ref = this.loadingService.beginLoading();\r\n const pagingRequest = new PagingRequest();\r\n pagingRequest.setStart(this.pageableResult.getEnd() + 1);\r\n pagingRequest.setEnd(this.appContext.getTotalPerPage());\r\n pagingRequest.setFilterText(this.nameControl.value);\r\n try {\r\n const result = await this.userService.searchUser(pagingRequest);\r\n this.pageableResult.setStart(pagingRequest.getStart());\r\n this.pageableResult.setEnd(pagingRequest.getEnd());\r\n this.pageableResult.setTotalItems(result.getTotalItems());\r\n this.pageableResult.addItems(result.getItems());\r\n } catch (error) {\r\n this.toast.showWarningToast(error);\r\n } finally {\r\n this.loadingService.finishLoading(ref);\r\n }\r\n }\r\n\r\n showMoreUsersBtn(): boolean {\r\n return this.pageableResult && this.pageableResult.getTotalItems() !== this.pageableResult.getItems().length && this.pageableResult.getItems().length > 1;\r\n }\r\n\r\n goToEditUser(user: User): void {\r\n this.router.navigate([RoutePath.RegisterUser, user.getUserKey()]);\r\n }\r\n\r\n hasAccessToEditUser(): boolean {\r\n return this.userService.getLoggedUser().hasPermission(UserPermissions.EditUser);\r\n }\r\n\r\n isResultEmpty(): boolean {\r\n return this.pageableResult && this.pageableResult.getItems().length === 0;\r\n }\r\n}\r\n","
\r\n
\r\n Pesquisar por nome\r\n \r\n
\r\n\r\n
\r\n search\r\n
\r\n
\r\n\r\n
\r\n
\r\n

Nenhum resultado encontrado.

\r\n
\r\n\r\n
\r\n
\r\n

{{ userItem.getName() }}

\r\n\r\n
\r\n \r\n E-mail: \r\n {{ userItem.getEmail() }}\r\n \r\n Perfis: \r\n {{ userRole.getName() }}\r\n
\r\n
\r\n\r\n
\r\n
\r\n check_circle_outline\r\n ATIVO\r\n
\r\n\r\n
\r\n delete\r\n INATIVO\r\n
\r\n\r\n
\r\n edit_note\r\n {{ hasAccessToEditUser() ? \"EDITAR\" : \"VISUALIZAR\" }}\r\n
\r\n
\r\n
\r\n\r\n \r\n
\r\n","import { UserRoleTypes } from \"./user-role-types\";\r\nimport { UntypedFormGroup } from \"@angular/forms\";\r\n\r\nimport { User } from \"./user\";\r\nimport { UserCompanyInfo } from \"./user-company-info\";\r\nimport { UserRole } from \"./user-role\";\r\nimport { UserPermission } from \"./user-permission\";\r\nimport { CompanyInfo } from \"../companies/company-info\";\r\n\r\ninterface IRegisterUserHandler {\r\n handlerFormToUser(formGroup: UntypedFormGroup): User;\r\n}\r\n\r\nexport class RegisterUserHandler implements IRegisterUserHandler {\r\n public handlerFormToUser(userForm: UntypedFormGroup): User {\r\n const userCompanyInfo = new UserCompanyInfo();\r\n userCompanyInfo.setTelephone(userForm.get(\"telephone\").value);\r\n userCompanyInfo.setFiscalNumber(userForm.get(\"fiscalNumber\").value);\r\n userCompanyInfo.setHealthProfessional(userForm.get(\"isHealthProfessional\").value);\r\n\r\n if (userCompanyInfo.isHealthProfessional()) {\r\n userCompanyInfo.setClassCouncil(userForm.get(\"classCouncil\").value);\r\n userCompanyInfo.setRegistrationNumber(userForm.get(\"registrationNumber\").value);\r\n } else {\r\n userCompanyInfo.setClassCouncil(null);\r\n userCompanyInfo.setRegistrationNumber(null);\r\n }\r\n\r\n const userRole: UserRole = userForm.get(\"userRole\").value;\r\n\r\n if (userRole.isAdministratorRole()) {\r\n userRole.setUserPermissionList([]);\r\n } else {\r\n userRole.setUserPermissionList(userForm.get(\"userPermissionList\").value);\r\n }\r\n\r\n const user = new User();\r\n user.setUserKey(userForm.get(\"userKey\").value);\r\n user.setActivate(userForm.get(\"active\").value);\r\n user.setName(userForm.get(\"name\").value);\r\n user.setEmail(userForm.get(\"email\").value);\r\n user.setAllowedCompanies(userForm.get(\"allowedCompanies\").value);\r\n user.setUserCompanyInfo(userCompanyInfo);\r\n user.setUserRoleList([userRole]);\r\n user.correlatedId = userForm.get(\"externalClientId\").value;\r\n\r\n return user;\r\n }\r\n\r\n public handlerUserToForm(userKey: string, user: User, userRoleList: UserRole[], userForm: UntypedFormGroup): void {\r\n let userRole: UserRole;\r\n let userPermissionList: UserPermission[] = [];\r\n let telephoneType: number = null;\r\n let password: string = null;\r\n\r\n if (user.getUserCompanyInfo() && user.getUserCompanyInfo().isMobile()) {\r\n telephoneType = 1;\r\n } else {\r\n telephoneType = 0;\r\n }\r\n\r\n if (user.getUserRoleList().length > 0) {\r\n userRole = userRoleList.find((userRole) => userRole.getUserRoleKey() === user.getUserRoleList()[0].getUserRoleKey());\r\n\r\n userPermissionList = userRole.getUserPermissionList().filter((i) => {\r\n let exist = false;\r\n\r\n for (const e of user.getUserRoleList()[0].getUserPermissionList()) {\r\n if (exist) break;\r\n else exist = e.getCode() === i.getCode();\r\n }\r\n\r\n return exist;\r\n });\r\n }\r\n\r\n userForm.setValue({\r\n userKey: userKey,\r\n name: user.getName(),\r\n email: user.getEmail(),\r\n password: password,\r\n telephoneType: telephoneType,\r\n telephone: user.getUserCompanyInfo().getTelephone()\r\n ? user\r\n .getUserCompanyInfo()\r\n .getTelephone()\r\n .replace(/[^\\d]+/g, \"\")\r\n : \"\",\r\n externalClientId: user.correlatedId || \"\",\r\n fiscalNumber: user.getUserCompanyInfo().getFiscalNumber() ? user.getUserCompanyInfo().getFiscalNumber() : \"\",\r\n isHealthProfessional: user.getUserCompanyInfo().isHealthProfessional() ? user.getUserCompanyInfo().isHealthProfessional() : false,\r\n classCouncil: user.getUserCompanyInfo().getClassCouncil() ? user.getUserCompanyInfo().getClassCouncil() : \"\",\r\n registrationNumber: user.getUserCompanyInfo().getRegistrationNumber() ? user.getUserCompanyInfo().getRegistrationNumber() : \"\",\r\n userRole: userRole,\r\n userPermissionList: userPermissionList,\r\n allowedCompanies: user.getUserCompanyInfo() ? user.getUserCompanyInfo() : [],\r\n active: user.isActivate(),\r\n changePassword: false,\r\n newPassword: \"\",\r\n confirmNewPassword: \"\",\r\n filterText: \"\",\r\n companyType: 2,\r\n city: \"\",\r\n region: \"\",\r\n });\r\n }\r\n}\r\n","import { ValidationResult } from \"src/app/ui/models/domains/validator/validation-result\";\r\nimport { UntypedFormGroup } from \"@angular/forms\";\r\nimport { UserRole } from \"src/app/ui/models/domains/pbm/user/user-role\";\r\nimport { UserRoleTypes } from \"src/app/ui/models/domains/pbm/user/user-role-types\";\r\n\r\nexport class RegisterUserFormValidator {\r\n private validationResult = new ValidationResult();\r\n\r\n getValidationResult(): ValidationResult {\r\n return this.validationResult;\r\n }\r\n\r\n validate(userForm: UntypedFormGroup, isEditing: boolean): ValidationResult {\r\n const emailRegex =\r\n /^(([^<>()\\[\\]\\\\.,;:\\s@\"]+(\\.[^<>()\\[\\]\\\\.,;:\\s@\"]+)*)|(\".+\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/;\r\n const passwordRegex = /^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$%^&*(){}\\-_])[A-Za-z0-9#?!@$%^&*(){}\\-_]{8,}$/;\r\n const userRole = userForm.get(\"userRole\").value as UserRole;\r\n\r\n if (!userRole) {\r\n this.validationResult.addErrorMessage(\"É necessário selecionar ao menos um perfil.\");\r\n }\r\n if (!userForm.get(\"name\").value) {\r\n this.validationResult.addErrorMessage(\"É necessário inserir um nome.\");\r\n }\r\n\r\n const isExternalManager = userRole.getUserRoleType() === UserRoleTypes.ExternalManager;\r\n const isCompanyManager = userRole.getUserRoleType() === UserRoleTypes.CompanyManager;\r\n\r\n if (isExternalManager && !userForm.get('externalClientId').value) {\r\n this.validationResult.addErrorMessage(\"Infromar o Client Id para usuário externo.\");\r\n }\r\n \r\n if (!userForm.get(\"email\").value) {\r\n this.validationResult.addErrorMessage(\"É necessário inserir um e-mail.\");\r\n }\r\n\r\n if (!isExternalManager) {\r\n \r\n if (!emailRegex.test(userForm.get(\"email\").value)) {\r\n this.validationResult.addErrorMessage(\"E-mail inválido.\");\r\n }\r\n if (!emailRegex.test(userForm.get(\"email\").value)) {\r\n this.validationResult.addErrorMessage(\"E-mail inválido.\");\r\n }\r\n if (!userForm.get(\"telephone\").value) {\r\n this.validationResult.addErrorMessage(\"É necessário inserir um telefone.\");\r\n }\r\n if (userForm.get(\"telephone\").value.replace(/[^\\d]+/g, \"\").length < 10) {\r\n this.validationResult.addErrorMessage(\"Telefone inválido.\");\r\n }\r\n }\r\n\r\n if (isCompanyManager || isExternalManager) {\r\n if (userForm.get(\"allowedCompanies\").value.length == 0) {\r\n this.validationResult.addErrorMessage(\"É necessário selecionar ao menos um CNPJ.\");\r\n }\r\n if (!userForm.get(\"fiscalNumber\").value) {\r\n this.validationResult.addErrorMessage(\"É necessário inserir o CNPJ da empresa que o usuário é registrado.\");\r\n } else if (userForm.get(\"fiscalNumber\").value.replace(/[^\\d]+/g, \"\").length < 14) {\r\n this.validationResult.addErrorMessage(\"CNPJ inválido.\");\r\n }\r\n }\r\n\r\n if (!isExternalManager) {\r\n if (!isEditing && !passwordRegex.test(userForm.get(\"password\").value)) {\r\n this.validationResult.addErrorMessage(\"Senha inválida\");\r\n }\r\n if (isEditing && userForm.get(\"changePassword\").value == true) {\r\n if (!passwordRegex.test(userForm.get(\"newPassword\").value)) {\r\n this.validationResult.addErrorMessage(\"Senha inválida\");\r\n } else if (passwordRegex.test(userForm.get(\"newPassword\").value) && userForm.get(\"newPassword\").value !== userForm.get(\"confirmNewPassword\").value) {\r\n this.validationResult.addErrorMessage(\"A senha e a confirmação de senha precisam ser idênticas\");\r\n }\r\n }\r\n }\r\n\r\n\r\n if (!this.validationResult.hasErrorMessages()) {\r\n if (userForm.get(\"isHealthProfessional\").value) {\r\n if (!userForm.get(\"classCouncil\").value) {\r\n this.validationResult.addErrorMessage(\"É necessário inserir um conselho de classe.\");\r\n } else if (!userForm.get(\"registrationNumber\").value) {\r\n this.validationResult.addErrorMessage(\"É necessário inserir um número de registro.\");\r\n }\r\n }\r\n }\r\n return this.validationResult;\r\n }\r\n}\r\n","import { ChangeDetectorRef, Component, OnInit, ViewChild } from \"@angular/core\";\r\nimport { UntypedFormGroup, UntypedFormBuilder, Validators } from \"@angular/forms\";\r\nimport { ActivatedRoute, Router } from \"@angular/router\";\r\n\r\nimport { RegisterUserHandler } from \"../../../../models/domains/pbm/user/register-user-handler\";\r\nimport { RoutePath } from \"src/app/ui/models/domains/route-paths.model\";\r\nimport { UserService } from \"src/app/ui/services/user.service\";\r\nimport { Toast } from \"./../../../toast/toast\";\r\nimport { LoadingService } from \"src/app/ui/services/loading.service\";\r\nimport { FeatureViewService } from \"src/app/ui/services/feature-view.service\";\r\nimport { FeatureViews } from \"src/app/ui/models/domains/features/custom-feature-views\";\r\nimport { PageViews } from \"src/app/ui/models/domains/features/custom-page-views\";\r\nimport { UserRole } from \"src/app/ui/models/domains/pbm/user/user-role\";\r\nimport { RegisterUserFormValidator } from \"../validators/register-user-form.validator\";\r\nimport { MaskInput } from \"./../../../../models/domains/masks/mask.model\";\r\nimport { CompanyService } from \"src/app/ui/services/pbm/company.service\";\r\nimport { PageableResult } from \"src/app/ui/models/domains/paginator/pageable-result\";\r\nimport { PagingRequest } from \"src/app/ui/models/domains/paginator/paging-request\";\r\nimport { Company } from \"src/app/ui/models/domains/pbm/companies/company\";\r\nimport { ConfirmDialog } from \"../../shared/dialogs/confirm-dialog/confirm-dialog.component\";\r\nimport { UserCompanyInfo } from \"src/app/ui/models/domains/pbm/user/user-company-info\";\r\nimport { User } from \"src/app/ui/models/domains/pbm/user/user\";\r\nimport { ICompanyFilterParams } from \"src/app/ui/models/domains/pbm/companies/company-filter-params\";\r\nimport { City } from \"src/app/ui/models/domains/pbm/state/city\";\r\nimport { StateService } from \"src/app/ui/services/pbm/state.service\";\r\nimport { StateAcronym } from \"src/app/ui/models/domains/pbm/state/state-acronym\";\r\nimport { UserPermissions } from \"src/app/ui/models/domains/pbm/user/user-permissions\";\r\nimport { UserPermission } from \"src/app/ui/models/domains/pbm/user/user-permission\";\r\nimport { UserRoleTypes } from \"src/app/ui/models/domains/pbm/user/user-role-types\";\r\nimport { SelectionModel } from \"@angular/cdk/collections\";\r\nimport { MatDialogRef, MatDialog } from \"@angular/material/dialog\";\r\nimport { MatPaginator } from \"@angular/material/paginator\";\r\nimport { MatSort } from \"@angular/material/sort\";\r\nimport { MatTableDataSource } from \"@angular/material/table\";\r\n@Component({\r\n selector: \"register-user\",\r\n templateUrl: \"./register-user.component.html\",\r\n styleUrls: [\"./register-user.component.scss\"],\r\n})\r\nexport class RegisterUserComponent implements OnInit {\r\n @ViewChild(MatPaginator) paginator: MatPaginator;\r\n @ViewChild(MatSort) sort: MatSort;\r\n\r\n fieldDirective = {\r\n email: {\r\n visible: () => !this.isExternalManager(),\r\n },\r\n externalClientId: {\r\n visible: () => this.isExternalManager(),\r\n },\r\n password: {\r\n visible: () => !this.isExternalManager(),\r\n },\r\n isHealthProfessional: {\r\n visible: () => !this.isExternalManager(),\r\n },\r\n telephone: {\r\n visible: () => !this.isExternalManager(),\r\n },\r\n };\r\n\r\n private user: User = new User();\r\n userForm: UntypedFormGroup;\r\n userRoleList: UserRole[];\r\n telephoneMaskInput = MaskInput.getTelephoneMask();\r\n mobileMaskInput = MaskInput.getMobileMask();\r\n fiscalNumberMaskInput = MaskInput.getFicalNumberMask();\r\n public displayedColumns: Array;\r\n private pageableResult: PageableResult = new PageableResult();\r\n public selectedCompanies = new SelectionModel(true, []);\r\n public allCompanies = [];\r\n public dataSource = new MatTableDataSource();\r\n private confirmDialogRef: MatDialogRef;\r\n public passwordFocused: boolean = false;\r\n public initialTableState: Array<{\r\n fiscalNumber: string;\r\n initialState: boolean;\r\n }> = []; //Apenas para visualização em tela\r\n public filterParams: ICompanyFilterParams;\r\n private stateList: Array = [];\r\n private cityList: Array = [];\r\n private userPermissionList: Array;\r\n private userKey: string;\r\n public isEditing: boolean;\r\n private registerUserHandler: RegisterUserHandler;\r\n\r\n constructor(\r\n private featureViewService: FeatureViewService,\r\n private formBuilder: UntypedFormBuilder,\r\n private loadingService: LoadingService,\r\n private userService: UserService,\r\n private toast: Toast,\r\n private router: Router,\r\n private companyService: CompanyService,\r\n private dialog: MatDialog,\r\n private stateService: StateService,\r\n private activatedRoute: ActivatedRoute,\r\n private cdref: ChangeDetectorRef\r\n ) {\r\n this.userKey = this.activatedRoute.snapshot.params.userKey;\r\n\r\n /**\r\n * Parâmetros iniciais para a busca de Companies\r\n */\r\n this.filterParams = {\r\n filterText: \"\",\r\n companyType: 2, // 0 = Apenas Matriz; 1 = Apenas Filiais; 2 = Todas\r\n address: {\r\n city: \"\",\r\n region: \"\",\r\n },\r\n };\r\n }\r\n\r\n async ngOnInit() {\r\n this.featureViewService.activeFeatureView(FeatureViews.UserRegisterFeatureView, PageViews.UserPageView);\r\n this.userForm = this.formBuilder.group({\r\n userKey: [\"\"],\r\n name: [\"\", Validators.required],\r\n email: [\"\", Validators.required],\r\n password: [\"\", Validators.required],\r\n telephoneType: [null],\r\n telephone: [\"\", Validators.required],\r\n fiscalNumber: [{ value: \"\", disabled: false }],\r\n isHealthProfessional: [false],\r\n classCouncil: [\"\"],\r\n registrationNumber: [\"\"],\r\n userRole: [\"\", Validators.required],\r\n externalClientId: [\"\", Validators.required],\r\n userPermissionList: [[]],\r\n allowedCompanies: [[]],\r\n active: [false],\r\n changePassword: [false],\r\n newPassword: [\"\"],\r\n confirmNewPassword: [\"\"],\r\n filterText: [this.filterParams.filterText],\r\n companyType: [this.filterParams.companyType],\r\n city: [this.filterParams.address.city],\r\n region: [this.filterParams.address.region],\r\n });\r\n\r\n this.displayedColumns = [\"check\", \"status\", \"fiscalNumber\", \"companyType\", \"corporateName\", \"region\", \"city\"];\r\n this.dataSource.paginator = this.paginator;\r\n await this.checkUserParam();\r\n }\r\n\r\n ngAfterContentChecked() {\r\n this.cdref.detectChanges();\r\n }\r\n\r\n private async checkUserParam() {\r\n const ref = this.loadingService.beginLoading();\r\n try {\r\n this.userRoleList = await this.userService.requestUserRoles();\r\n this.stateList = await this.stateService.getStates();\r\n if (this.userKey) {\r\n this.isEditing = true;\r\n this.user = await this.userService.searchUserByUserKey(this.userKey);\r\n this.userForm.get(\"userRole\").valueChanges.subscribe((value: UserRole) => (this.userPermissionList = value.getUserPermissionList()));\r\n this.registerUserHandler = new RegisterUserHandler();\r\n this.registerUserHandler.handlerUserToForm(this.userKey, this.user, this.userRoleList, this.userForm);\r\n await this.doSearchAllCompanies();\r\n this.setPreviouslySelectedCompanies();\r\n }\r\n } catch (e) {\r\n console.error(e);\r\n } finally {\r\n this.loadingService.finishLoading(ref);\r\n }\r\n }\r\n\r\n async doSaveUser() {\r\n const ref = this.loadingService.beginLoading();\r\n const userFormValidator = new RegisterUserFormValidator();\r\n if (!this.canAllowPermissionPerCompany()) {\r\n this.selectedCompanies.select(...this.dataSource.data);\r\n }\r\n this.userForm.patchValue({\r\n allowedCompanies: this.selectedCompanies.selected,\r\n });\r\n\r\n if (userFormValidator.validate(this.userForm, this.isEditing).hasErrorMessages()) {\r\n this.loadingService.finishLoading(ref);\r\n this.toast.showWarningToast(userFormValidator.getValidationResult().getErrorMessage());\r\n } else {\r\n try {\r\n const registerUserHandler = new RegisterUserHandler();\r\n this.user = registerUserHandler.handlerFormToUser(this.userForm);\r\n\r\n if (this.isEditing) {\r\n const newPassword = this.userForm.get(\"newPassword\").value;\r\n const confirmNewPassword = this.userForm.get(\"confirmNewPassword\").value;\r\n await this.userService.updateUser(this.user, newPassword, confirmNewPassword);\r\n this.toast.showSuccessToast(\"Usuário regravado com sucesso!\");\r\n } else {\r\n const password = this.userForm.get(\"password\").value;\r\n await this.userService.addUser(this.user, password);\r\n this.toast.showSuccessToast(\"Usuário salvo com sucesso!\");\r\n }\r\n this.router.navigate([RoutePath.SearchUser]);\r\n } catch (error) {\r\n this.toast.showWarningToast(error.errorMessage);\r\n } finally {\r\n this.loadingService.finishLoading(ref);\r\n }\r\n }\r\n }\r\n\r\n canShowUserPermissions(): boolean {\r\n const selectedRole = this.userForm.get(\"userRole\").value;\r\n\r\n return (\r\n selectedRole &&\r\n (selectedRole.userRoleType === UserRoleTypes.Manager ||\r\n selectedRole.userRoleType === UserRoleTypes.CompanyManager ||\r\n selectedRole.userRoleType === UserRoleTypes.Audit ||\r\n selectedRole.userRoleType === UserRoleTypes.Tester)\r\n );\r\n }\r\n getTelephoneMask(typeSelectedByUser) {\r\n let retMask: any = [/[0-9]/, /[0-9]/, /[0-9]/, /[0-9]/, /[0-9]/, /[0-9]/, /[0-9]/, /[0-9]/, /[0-9]/, /[0-9]/, /[0-9]/, /[0-9]/]; // valor default que aceita todos os números e em qualquer posição.\r\n if (this.user.getUserKey()) {\r\n const phoneType = this.userForm.get(\"telephoneType\").value;\r\n retMask = phoneType == 0 || phoneType == 1 ? (phoneType == 0 ? this.telephoneMaskInput : this.mobileMaskInput) : retMask;\r\n } else if (typeSelectedByUser) {\r\n const type = typeSelectedByUser.value;\r\n retMask = type == 0 || type == 1 ? (type == 0 ? this.telephoneMaskInput : this.mobileMaskInput) : retMask;\r\n }\r\n return retMask;\r\n }\r\n\r\n canAllowPermissionPerCompany(): boolean {\r\n return this.userForm.get(\"userRole\").value && this.userForm.get(\"userRole\").value.isCompanyManagerRole();\r\n }\r\n\r\n permissionList(): Array {\r\n if (this.userForm.get(\"userRole\").value) {\r\n let list = this.userForm.get(\"userRole\").value.getUserPermissionList() as Array;\r\n if (this.canAllowPermissionPerCompany()) {\r\n // gestor RH não pode cadastrar empresas. Ele só tem acesso as que foram associadas a ele por um ADM Interplayers\r\n return list.filter((perm) => {\r\n return perm.getCode() !== \"ADD_COMPANY\";\r\n });\r\n } else {\r\n return list;\r\n }\r\n }\r\n return [];\r\n }\r\n\r\n public onUserRoleChange(): void {\r\n this.selectedCompanies.clear();\r\n this.userForm.get(\"userPermissionList\").value;\r\n this.userForm.patchValue({ [\"userPermissionList\"]: [] });\r\n this.userForm.patchValue({ [\"externalClientId\"]: \"\" });\r\n }\r\n isExternalManager(): boolean {\r\n const role = this.userForm.get(\"userRole\").value;\r\n if (role) return role.userRoleType == UserRoleTypes.ExternalManager;\r\n return false;\r\n }\r\n isAllSelected() {\r\n const numSelected = this.selectedCompanies.selected.length;\r\n const numRows = this.dataSource.data.length;\r\n return numSelected === numRows;\r\n }\r\n\r\n masterToggle() {\r\n if (this.isAllSelected()) {\r\n this.selectedCompanies.clear();\r\n return;\r\n }\r\n this.selectedCompanies.clear();\r\n this.allCompanies.forEach((company) => {\r\n this.selectedCompanies.selected.push(company);\r\n });\r\n }\r\n\r\n selectCompany(element: Company) {\r\n const idx = this.getIsSelected(element);\r\n if (idx == -1) {\r\n this.selectedCompanies.selected.push(element);\r\n } else {\r\n this.selectedCompanies.selected.splice(idx, 1);\r\n }\r\n this.checkCompanyType(element);\r\n this.dataSource.sort = this.sort;\r\n }\r\n\r\n /**\r\n * O método nativo this.selectedCompanies.isSelected(element) não funciona neste contexto pois\r\n * ele faz referência a objetos. Quando os dados de \"allCompanies\" eram atualizados, perdiam-se\r\n * as referências dos objetos selecionados mesmo ainda estando na lista \"selectedCompanies\".\r\n * Faz a busca \"manualmente\" verificando pelo identificador fiscalNumber (CNPJ).\r\n * @param element Company this.selectedCompanies.\r\n * @returns índice do elemento. Se não encontrar, retorna -1\r\n */\r\n getIsSelected(element: Company): number {\r\n let ret = -1;\r\n for (let i = 0; i < this.selectedCompanies.selected.length; i++) {\r\n const selected = this.selectedCompanies.selected[i];\r\n if (element?.getFiscalNumber() === selected.getFiscalNumber()) {\r\n ret = i;\r\n break;\r\n }\r\n }\r\n return ret;\r\n }\r\n\r\n checkCompanyType(company: Company) {\r\n if (company.getCompanyType() == 0) {\r\n const rootFiscalNumber = company.getFiscalNumber().slice(0, 8);\r\n const branches = this.dataSource.data.filter((c) => {\r\n return c.getCompanyType() !== 0 && c.getFiscalNumber().slice(0, 8) == rootFiscalNumber;\r\n });\r\n\r\n if (branches.length > 0) {\r\n this.confirmDialogRef = this.dialog.open(ConfirmDialog, {\r\n disableClose: true,\r\n hasBackdrop: true,\r\n height: \"200px\",\r\n width: \"600px\",\r\n data: {\r\n title: \"Esta empresa é uma Matriz.\",\r\n text: \"Deseja replicar esta ação para todas as filiais?\",\r\n },\r\n });\r\n\r\n this.confirmDialogRef.componentInstance.confirmDialogEvent.subscribe(async () => {\r\n branches.forEach((branch) => {\r\n if (this.getIsSelected(company) !== -1) {\r\n const idx = this.getIsSelected(branch);\r\n if (idx == -1) {\r\n this.selectedCompanies.selected.push(branch);\r\n }\r\n } else {\r\n const idx = this.getIsSelected(branch);\r\n if (idx != -1) {\r\n this.selectedCompanies.selected.splice(idx, 1);\r\n }\r\n }\r\n });\r\n });\r\n }\r\n }\r\n }\r\n\r\n public pageChange() {\r\n const data = this.allCompanies;\r\n const startIndex = this.paginator.pageIndex * this.paginator.pageSize;\r\n const endIndex = startIndex + this.paginator.pageSize;\r\n const paginatedData = data.slice(startIndex, endIndex);\r\n this.dataSource.data = paginatedData;\r\n this.paginator.length = this.pageableResult.getTotalItems();\r\n }\r\n\r\n /**\r\n * Busca todas as empresas cadastradas para exibir na tela e comparar com a lista de empresas\r\n * permitidas para o usuário\r\n */\r\n public async doSearchAllCompanies() {\r\n const ref = this.loadingService.beginLoading();\r\n const pagingRequest = new PagingRequest();\r\n pagingRequest.setStart(1);\r\n pagingRequest.setEnd(9999);\r\n this.filterParams = {\r\n filterText: this.userForm.get(\"filterText\").value.replace(/[./-]/g, \"\").slice(0, 8),\r\n companyType: this.userForm.get(\"companyType\").value,\r\n address: {\r\n city: this.userForm.get(\"city\").value,\r\n region: this.userForm.get(\"region\").value,\r\n },\r\n };\r\n\r\n await this.companyService\r\n .searchCompany(this.filterParams, pagingRequest)\r\n .then((pageableResult) => {\r\n this.pageableResult.setStart(1);\r\n this.pageableResult.setEnd(9999);\r\n this.pageableResult.setTotalItems(pageableResult.getTotalItems());\r\n this.pageableResult.setItems(pageableResult.getItems());\r\n this.allCompanies = >this.pageableResult.getItems();\r\n\r\n if (this.allCompanies.length == 0) {\r\n this.toast.showWarningToast(\"Nenhum resultado encontrado para os filtros selecionados\", \"Atenção!\");\r\n return;\r\n }\r\n\r\n if (!this.isEditing) {\r\n // quando está editando, faz só 1 vez na inicialização da tela\r\n this.setPreviouslySelectedCompanies();\r\n }\r\n this.pageChange();\r\n this.dataSource._updatePaginator(this.pageableResult.getTotalItems());\r\n this.dataSource._updateChangeSubscription();\r\n })\r\n .catch(() => {\r\n this.pageableResult.setItems(null);\r\n })\r\n .finally(() => {\r\n this.loadingService.finishLoading(ref);\r\n });\r\n }\r\n\r\n getSelectedDescription(): string {\r\n return this.selectedCompanies.selected.length == 0\r\n ? \"Nenhum selecionado\"\r\n : this.selectedCompanies.selected.length == 1\r\n ? \"1 selecionado\"\r\n : this.selectedCompanies.selected.length + \" selecionados\";\r\n }\r\n\r\n /**\r\n * Insere na lista de selecionadas (selectedCompanies) as empresas vinculadas anteriormente para o\r\n * usuário em questão, caso tenha.\r\n */\r\n setPreviouslySelectedCompanies(): void {\r\n this.allCompanies.forEach((comp) => {\r\n if (this.userKey) {\r\n const allowedCompanies = this.user.getAllowedCompanies().map(compUser => compUser.getFiscalNumber());\r\n const isAllowed = allowedCompanies.includes(comp.getFiscalNumber());\r\n\r\n if (isAllowed && this.getIsSelected(comp) === -1) {\r\n this.selectedCompanies.selected.push(comp);\r\n }\r\n\r\n this.setInitialTableState({\r\n fiscalNumber: comp.getFiscalNumber(),\r\n initialState: isAllowed,\r\n });\r\n } else {\r\n this.setInitialTableState({\r\n fiscalNumber: comp.getFiscalNumber(),\r\n initialState: false,\r\n });\r\n }\r\n });\r\n }\r\n\r\n getTableState(company: Company): string {\r\n if (!this.initialTableState.length) {\r\n return \"\";\r\n }\r\n const initialState = this.initialTableState.find(ts => ts.fiscalNumber === company.getFiscalNumber())?.initialState;\r\n const currentState = this.getIsSelected(company) !== -1;\r\n\r\n if (initialState !== undefined) {\r\n if (initialState !== currentState) {\r\n return \"Alterado\";\r\n } else if (initialState) {\r\n return \"Salvo\";\r\n }\r\n }\r\n return \"\";\r\n }\r\n\r\n setInitialTableState(state: { fiscalNumber: string; initialState: boolean }) {\r\n this.initialTableState.push(state);\r\n }\r\n\r\n setPasswordFocused(isFocused: boolean) {\r\n this.passwordFocused = isFocused;\r\n }\r\n\r\n /**\r\n * Faz o parse dos itens da tabela de CNPJs (Company)\r\n * para itens do tipo (UserCompanyInfo) que serão armazenados no usuário\r\n * @returns Array\r\n */\r\n getSelectedCompaniesInfo(): Array {\r\n let data: Array = new Array();\r\n this.selectedCompanies.selected.forEach((selectedCompany) => {\r\n const userCompanyInfo: UserCompanyInfo = new UserCompanyInfo();\r\n userCompanyInfo.setTelephone(this.userForm.get(\"telephone\").value);\r\n userCompanyInfo.setFiscalNumber(selectedCompany.getFiscalNumber());\r\n userCompanyInfo.setCorporateName(selectedCompany.getCorporateName());\r\n userCompanyInfo.setHealthProfessional(this.userForm.get(\"isHealthProfessional\").value);\r\n userCompanyInfo.setClassCouncil(this.userForm.get(\"classCouncil\").value);\r\n userCompanyInfo.setRegistrationNumber(this.userForm.get(\"registrationNumber\").value);\r\n data.push(userCompanyInfo);\r\n });\r\n return data;\r\n }\r\n\r\n isPasswordValid(password: string): boolean {\r\n const passwordRegex = /^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$%^&*(){}\\-_])[A-Za-z0-9#?!@$%^&*(){}\\-_]{8,}$/;\r\n return passwordRegex.test(password);\r\n }\r\n\r\n comparePasswords(newPassword, confirmNewPassword): boolean {\r\n return newPassword && confirmNewPassword ? newPassword.value == confirmNewPassword.value : false;\r\n }\r\n\r\n async onStateInputChange() {\r\n const value = this.userForm.get(\"region\").value;\r\n let state: StateAcronym = new StateAcronym(value);\r\n if (state.getValue() !== \"\") {\r\n const ref = this.loadingService.beginLoading();\r\n try {\r\n this.cityList = await this.stateService.getCityByStateAcronym(state);\r\n this.userForm.get(\"city\").enable();\r\n this.userForm.get(\"city\").setValue(\"\");\r\n } catch (error) {\r\n this.cityList = [];\r\n this.userForm.get(\"city\").disable();\r\n this.toast.showWarningToast(error);\r\n } finally {\r\n this.loadingService.finishLoading(ref);\r\n }\r\n } else {\r\n this.cityList = [];\r\n this.userForm.get(\"city\").setValue(\"\");\r\n this.userForm.get(\"city\").disable();\r\n }\r\n }\r\n\r\n getStateList(): Array {\r\n return this.stateList;\r\n }\r\n\r\n getCityList(): Array {\r\n return this.cityList;\r\n }\r\n\r\n sortTable() {\r\n if (this.sort.direction === \"asc\") {\r\n this.dataSource.data = this.dataSource.data.sort((a, b) => {\r\n if (this.getIsSelected(a) !== -1 && !(this.getIsSelected(b) !== -1)) {\r\n return -1;\r\n } else if (this.getIsSelected(b) !== -1 && !(this.getIsSelected(a) !== -1)) {\r\n return 1;\r\n }\r\n });\r\n } else if (this.sort.direction === \"desc\") {\r\n this.dataSource.data = this.dataSource.data.sort((a, b) => {\r\n if (this.getIsSelected(a) !== -1 && !(this.getIsSelected(b) !== -1)) {\r\n return 1;\r\n } else if (this.getIsSelected(b) !== -1 && !(this.getIsSelected(a) !== -1)) {\r\n return -1;\r\n }\r\n });\r\n } else {\r\n this.dataSource.data = this.dataSource.data.sort((a, b) => {\r\n if (a.getCorporateName() === b.getCorporateName()) {\r\n return Number.parseInt(a.getFiscalNumber()) - Number.parseInt(b.getFiscalNumber());\r\n }\r\n return a.getCorporateName() > b.getCorporateName() ? 1 : -1;\r\n });\r\n }\r\n }\r\n\r\n hasAccessToEditUser(): boolean {\r\n return this.userService.getLoggedUser().hasPermission(UserPermissions.EditUser);\r\n }\r\n}\r\n","\r\n \r\n
\r\n
\r\n
\r\n \r\n Perfis\r\n \r\n {{ userRole.getName() }}\r\n \r\n \r\n \r\n Permissões\r\n \r\n {{ userPermission.getName() }}\r\n \r\n \r\n \r\n Client Id\r\n \r\n \r\n
\r\n
\r\n \r\n Nome\r\n \r\n \r\n \r\n E-mail\r\n \r\n \r\n
\r\n
\r\n \r\n CNPJ\r\n \r\n \r\n \r\n Senha\r\n \r\n \r\n info\r\n \r\n \r\n Tipo do telefone\r\n \r\n Trabalho\r\n Celular\r\n \r\n \r\n \r\n Telefone\r\n \r\n \r\n
\r\n
\r\n Profissional da saúde?\r\n
\r\n \r\n Conselho de Classe\r\n \r\n \r\n \r\n Número do Registro\r\n \r\n \r\n
\r\n
\r\n
\r\n Ativo\r\n
\r\n \r\n Nova senha\r\n \r\n \r\n info\r\n \r\n \r\n Confirmação da nova senha\r\n \r\n \r\n \r\n
\r\n
\r\n\r\n
\r\n
CNPJs Vinculados * [ {{ getSelectedDescription() }} ]
\r\n\r\n
\r\n
\r\n \r\n CNPJ Matriz\r\n \r\n \r\n\r\n \r\n Unidade\r\n \r\n Todas\r\n Matriz\r\n Filial\r\n \r\n \r\n\r\n \r\n Estado\r\n \r\n Todos\r\n {{ state.getValue() }}\r\n \r\n \r\n\r\n \r\n Cidade\r\n \r\n Todas\r\n {{ city.getName() }}\r\n \r\n \r\n
\r\n\r\n \r\n
\r\n\r\n
\r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n\r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n {{ getTableState(element) }} \r\n \r\n \r\n\r\n \r\n \r\n
CNPJ\r\n {{ element.getFiscalNumber() | companyFederalNumber }}\r\n Unidade\r\n {{ element.getCompanyType() == 0 ? \"Matriz\" : \"Filial\" }}\r\n Razão Social\r\n {{ element.getCorporateName() }}\r\n UF\r\n {{ element.getCompanyInfo().getAddress().getRegion() }}\r\n Cidade\r\n {{ element.getCompanyInfo().getAddress().getCity() }}\r\n \r\n 0 && isAllSelected()\"\r\n [indeterminate]=\"selectedCompanies.selected.length > 0 && !isAllSelected()\">\r\n \r\n \r\n \r\n Status
\r\n\r\n \r\n
\r\n
\r\n\r\n
\r\n
\r\n \r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n","import { UntypedFormControl } from \"@angular/forms\";\r\nimport { Component, EventEmitter, Input, Output, OnInit, ViewChild } from \"@angular/core\";\r\nimport { BehaviorSubject } from \"rxjs\";\r\nimport { debounceTime } from \"rxjs/operators\";\r\n\r\nimport { IAutoCompleteSearchProvider } from \"../../models/domains/auto-complete/iauto-complete-search-provider\";\r\nimport { IAutoCompleteItem } from \"../../models/domains/auto-complete/iauto-complete-item\";\r\n\r\n@Component({\r\n selector: \"auto-complete-search\",\r\n templateUrl: \"./auto-complete-search.component.html\",\r\n styleUrls: [\"./auto-complete-search.component.scss\"],\r\n})\r\nexport class AutoCompleteSearchComponent implements OnInit {\r\n @Output() valueChange = new EventEmitter();\r\n @Input() width: number;\r\n @Input() value: any;\r\n @Input() searchProvider: IAutoCompleteSearchProvider;\r\n @Input() placeholder = \"\";\r\n @Input() appearance = \"\";\r\n @Input() initFocused = false;\r\n\r\n @ViewChild(\"input\") input: HTMLInputElement;\r\n\r\n searchControl: UntypedFormControl = new UntypedFormControl();\r\n filteredOptions: BehaviorSubject = new BehaviorSubject(undefined);\r\n\r\n constructor() {\r\n this.searchControl.valueChanges.pipe(debounceTime(400)).subscribe((data) => {\r\n if (typeof data === \"string\") {\r\n this.filter(data);\r\n }\r\n });\r\n }\r\n\r\n ngOnInit() {\r\n this.searchControl.setValue(this.value ? this.value : \"\");\r\n document.addEventListener(\"resetSearchControl\", () => {\r\n this.searchControl.reset();\r\n });\r\n }\r\n\r\n private async filter(filterByText: string) {\r\n const items = await this.searchProvider.search(filterByText);\r\n this.filteredOptions.next(items);\r\n }\r\n\r\n public getDisplayFn() {\r\n return (val: any) => this.display(val);\r\n }\r\n\r\n private display(item: IAutoCompleteItem): string {\r\n if (typeof item === \"string\") {\r\n return item;\r\n }\r\n return item ? item.getDisplayValue() : \"\";\r\n }\r\n\r\n public selected(item: IAutoCompleteItem) {\r\n this.value = item.getDisplayValue();\r\n this.valueChange.emit(item);\r\n }\r\n\r\n public onFocusInput(): void {\r\n if (document.getElementById(\"inputFilterText\")) {\r\n document.getElementById(\"inputFilterText\").click();\r\n }\r\n }\r\n}\r\n","\r\n {{ placeholder }}\r\n \r\n \r\n {{ option.getDisplayValue() }} \r\n \r\n\r\n","import { UntypedFormBuilder, UntypedFormControl, UntypedFormGroup } from \"@angular/forms\";\r\nimport { Component, OnInit } from \"@angular/core\";\r\nimport { ActivatedRoute, Router } from \"@angular/router\";\r\n\r\nimport { SalesHistoryService } from \"./../../../../services/pbm/sales-history.service\";\r\nimport { FeatureViewService } from \"src/app/ui/services/feature-view.service\";\r\nimport { FeatureViews } from \"src/app/ui/models/domains/features/custom-feature-views\";\r\nimport { PageViews } from \"src/app/ui/models/domains/features/custom-page-views\";\r\nimport { RoutePath } from \"src/app/ui/models/domains/route-paths.model\";\r\nimport { SalesHistoryCompany } from \"src/app/ui/models/domains/pbm/sales-history/sales-history-company\";\r\nimport { PagingRequest } from \"src/app/ui/models/domains/paginator/paging-request\";\r\nimport { ProductType } from \"src/app/ui/models/domains/pbm/Benefit/product-type\";\r\nimport { LoadingService } from \"src/app/ui/services/loading.service\";\r\nimport { MaskInput } from \"src/app/ui/models/domains/masks/mask.model\";\r\nimport { FilterOption } from \"src/app/ui/models/domains/filters/filter-option\";\r\nimport { FilterOptionType } from \"src/app/ui/models/domains/filters/filter-option-type.enum\";\r\nimport { Toast } from \"../../../toast/toast\";\r\nimport moment from \"moment\";\r\nimport { ProductService } from \"src/app/ui/services/pbm/product.service\";\r\nimport { FilterFormValidator } from \"../../sales-histories/validators/filter-form-validator\";\r\n\r\n@Component({\r\n selector: \"financial-statement-company.component\",\r\n templateUrl: \"./financial-statement-company.component.html\",\r\n styleUrls: [\"./financial-statement-company.component.scss\"],\r\n})\r\nexport class FinancialStatementCompanyComponent implements OnInit {\r\n salesHistoryCompany: SalesHistoryCompany;\r\n productTypes: ProductType[];\r\n fiscalNumber: string;\r\n socialNumber: string;\r\n searchType: UntypedFormControl;\r\n filterText= new UntypedFormControl();\r\n isDependent = new UntypedFormControl(0); \r\n dataMask = MaskInput.getDateMask();\r\n socialNumberMask = MaskInput.getSocialNumberMask();\r\n cardNumberMask = MaskInput.getCardNumberMask();\r\n\r\n filterForm: UntypedFormGroup = this.formBuilder.group({\r\n startDate: [moment().subtract(1, \"M\").format(\"DDMMYYYY\")],\r\n endDate: [moment().format(\"DDMMYYYY\")],\r\n productManufacturer: [],\r\n productType: [],\r\n });\r\n\r\n constructor(\r\n private featureViewService: FeatureViewService,\r\n private activatedRoute: ActivatedRoute,\r\n private router: Router,\r\n private salesHistoryService: SalesHistoryService,\r\n private productService: ProductService,\r\n private loadingService: LoadingService,\r\n private toast: Toast,\r\n private formBuilder: UntypedFormBuilder,\r\n ) {\r\n this.searchType = new UntypedFormControl(1);\r\n }\r\n\r\n async ngOnInit() {\r\n this.featureViewService.activeFeatureView(FeatureViews.SalesHistoryCompany, PageViews.SalesHistoriesPageView);\r\n\r\n const paramns = this.activatedRoute.snapshot.queryParams;\r\n\r\n if (!!paramns.b) {\r\n const ref = this.loadingService.beginLoading();\r\n\r\n this.fiscalNumber = paramns.b;\r\n\r\n const startDateFilter = new FilterOption(FilterOptionType.Text, \"startDateFilter\", \"startDateFilter\");\r\n startDateFilter.setValue(moment().subtract(1, \"M\").format(\"DDMMYYYY\"));\r\n\r\n const endDateFilter = new FilterOption(FilterOptionType.Text, \"endDateFilter\", \"endDateFilter\");\r\n endDateFilter.setValue(moment().format(\"DDMMYYYY\"));\r\n\r\n const productManufacturerFilter = new FilterOption(FilterOptionType.Text, \"productManufacturerFilter\", \"productManufacturerFilter\");\r\n productManufacturerFilter.setValue(\"\");\r\n\r\n const prouctTypeFilter = new FilterOption(FilterOptionType.Text, \"prouctTypeFilter\", \"prouctTypeFilter\");\r\n prouctTypeFilter.setValue(\"\");\r\n\r\n const fiscalNumberFilter = new FilterOption(FilterOptionType.Text, \"fiscalNumberFilter\", \"fiscalNumberFilter\");\r\n fiscalNumberFilter.setValue(this.fiscalNumber);\r\n\r\n const filters: FilterOption[] = [];\r\n filters.push(startDateFilter);\r\n filters.push(endDateFilter);\r\n filters.push(productManufacturerFilter);\r\n filters.push(prouctTypeFilter);\r\n filters.push(fiscalNumberFilter);\r\n\r\n const pagingRequest = new PagingRequest();\r\n pagingRequest.setStart(1);\r\n pagingRequest.setEnd(10);\r\n pagingRequest.setFilters(filters);\r\n\r\n try {\r\n this.productTypes = await this.productService.getProductTypes();\r\n this.salesHistoryCompany = await this.salesHistoryService.findSalesHistoryByFiscalNumber(pagingRequest);\r\n } catch (error) {\r\n this.toast.showWarningToast(error);\r\n this.router.navigate([RoutePath.SearchFinancialStatement]);\r\n } finally {\r\n this.loadingService.finishLoading(ref);\r\n }\r\n } else {\r\n this.router.navigate([RoutePath.SearchFinancialStatement]);\r\n }\r\n }\r\n\r\n onPressNavigateToFinancialStatementBeneficiary(event, filterText: string): void {\r\n if (event.key === \"Enter\") {\r\n this.navigateToFinancialStatementBeneficiary(filterText);\r\n }\r\n }\r\n\r\n navigateToFinancialStatementBeneficiary(filterText: string) {\r\n if (this.hasSearchParam(filterText)) {\r\n this.router.navigate([RoutePath.FinancialStatementBeneficiary], {\r\n queryParams: { f: this.fiscalNumber, s: null, ft: filterText, dep: this.isDependent.value, searchType: this.searchType.value},\r\n });\r\n } else {\r\n let doc: string = \"\";\r\n switch (Number.parseInt(this.searchType.value)) {\r\n case 1:\r\n doc = \"CPF\";\r\n break;\r\n case 2:\r\n doc = \"NOME\";\r\n break;\r\n case 3:\r\n doc = \"Nº DO CARTÃO\";\r\n break;\r\n default:\r\n break;\r\n }\r\n this.toast.showWarningToast(\"Por favor, informe o \" + doc + \" do beneficiário para consulta do extrato.\");\r\n }\r\n }\r\n\r\n async onFilterChange(): Promise {\r\n const ref = this.loadingService.beginLoading();\r\n\r\n const filterFormValidator = new FilterFormValidator();\r\n\r\n if (filterFormValidator.validate(this.filterForm).hasErrorMessages()) {\r\n this.toast.showWarningToast(filterFormValidator.getValidationResult().getErrorMessage());\r\n this.loadingService.finishLoading(ref);\r\n } else {\r\n const startDate = this.filterForm.get(\"startDate\").value;\r\n const endDate = this.filterForm.get(\"endDate\").value;\r\n const productManufacturer = this.filterForm.get(\"productManufacturer\").value;\r\n const productType = this.filterForm.get(\"productType\") ? this.filterForm.get(\"productType\").value : \"\";\r\n\r\n const startDateFilter = new FilterOption(FilterOptionType.Text, \"startDateFilter\", \"startDateFilter\");\r\n startDateFilter.setValue(moment(startDate, \"DD/MM/YYYY\").format(\"DDMMYYYY\"));\r\n\r\n const endDateFilter = new FilterOption(FilterOptionType.Text, \"endDateFilter\", \"endDateFilter\");\r\n endDateFilter.setValue(moment(endDate, \"DD/MM/YYYY\").format(\"DDMMYYYY\"));\r\n\r\n const productManufacturerFilter = new FilterOption(FilterOptionType.Text, \"productManufacturerFilter\", \"productManufacturerFilter\");\r\n productManufacturerFilter.setValue(productManufacturer);\r\n\r\n const prouctTypeFilter = new FilterOption(FilterOptionType.Text, \"prouctTypeFilter\", \"prouctTypeFilter\");\r\n prouctTypeFilter.setValue(productType);\r\n\r\n const fiscalNumberFilter = new FilterOption(FilterOptionType.Text, \"fiscalNumberFilter\", \"fiscalNumberFilter\");\r\n fiscalNumberFilter.setValue(this.fiscalNumber);\r\n\r\n const filters: FilterOption[] = [];\r\n filters.push(startDateFilter);\r\n filters.push(endDateFilter);\r\n filters.push(productManufacturerFilter);\r\n filters.push(prouctTypeFilter);\r\n filters.push(fiscalNumberFilter);\r\n\r\n const pagingRequest = new PagingRequest();\r\n pagingRequest.setStart(1);\r\n pagingRequest.setEnd(10);\r\n pagingRequest.setFilters(filters);\r\n\r\n try {\r\n this.salesHistoryCompany = await this.salesHistoryService.findSalesHistoryByFiscalNumber(pagingRequest);\r\n } catch (error) {\r\n this.toast.showWarningToast(error);\r\n } finally {\r\n this.loadingService.finishLoading(ref);\r\n }\r\n }\r\n }\r\n\r\n async searchMore(): Promise {\r\n const ref = this.loadingService.beginLoading();\r\n const startDate = this.filterForm.get(\"startDate\").value;\r\n const endDate = this.filterForm.get(\"endDate\").value;\r\n const productManufacturer = this.filterForm.get(\"productManufacturer\").value;\r\n const productType = this.filterForm.get(\"productType\") ? this.filterForm.get(\"productType\").value : \"\";\r\n\r\n const startDateFilter = new FilterOption(FilterOptionType.Text, \"startDateFilter\", \"startDateFilter\");\r\n startDateFilter.setValue(moment(startDate, \"DD/MM/YYYY\").format(\"DDMMYYYY\"));\r\n\r\n const endDateFilter = new FilterOption(FilterOptionType.Text, \"endDateFilter\", \"endDateFilter\");\r\n endDateFilter.setValue(moment(endDate, \"DD/MM/YYYY\").format(\"DDMMYYYY\"));\r\n\r\n const productManufacturerFilter = new FilterOption(FilterOptionType.Text, \"productManufacturerFilter\", \"productManufacturerFilter\");\r\n productManufacturerFilter.setValue(productManufacturer);\r\n\r\n const prouctTypeFilter = new FilterOption(FilterOptionType.Text, \"prouctTypeFilter\", \"prouctTypeFilter\");\r\n prouctTypeFilter.setValue(productType);\r\n\r\n const fiscalNumberFilter = new FilterOption(FilterOptionType.Text, \"fiscalNumberFilter\", \"fiscalNumberFilter\");\r\n fiscalNumberFilter.setValue(this.fiscalNumber);\r\n\r\n const filters: FilterOption[] = [];\r\n filters.push(startDateFilter);\r\n filters.push(endDateFilter);\r\n filters.push(productManufacturerFilter);\r\n filters.push(prouctTypeFilter);\r\n filters.push(fiscalNumberFilter);\r\n\r\n const pagingRequest = new PagingRequest();\r\n pagingRequest.setStart(this.salesHistoryCompany.getPagingInfo().getEnd());\r\n pagingRequest.setEnd(10);\r\n pagingRequest.setFilters(filters);\r\n\r\n try {\r\n const result = await this.salesHistoryService.findSalesHistoryByFiscalNumber(pagingRequest);\r\n this.salesHistoryCompany.setPagingInfo(result.getPagingInfo());\r\n this.salesHistoryCompany.addItems(result.getcompanySalesHistoryItemList());\r\n } catch (error) {\r\n this.toast.showWarningToast(error);\r\n } finally {\r\n this.loadingService.finishLoading(ref);\r\n }\r\n }\r\n\r\n backToSearchFinancialStatement(): void {\r\n this.router.navigate([RoutePath.SearchFinancialStatement]);\r\n }\r\n\r\n hasSalesHistoryCompany(): boolean {\r\n return !!this.salesHistoryCompany;\r\n }\r\n\r\n hasSalesHistoryCompanyItem(): boolean {\r\n return !!this.salesHistoryCompany && this.salesHistoryCompany.getcompanySalesHistoryItemList().length > 0;\r\n }\r\n\r\n hasSearchParam(filterText: string): boolean {\r\n return filterText !== \"\";\r\n }\r\n}\r\n","
\r\n \r\n west\r\n VOLTAR\r\n \r\n
\r\n
\r\n \r\n
\r\n
\r\n
\r\n {{ salesHistoryCompany.getCorporateName() }}\r\n
\r\n CNPJ: {{ salesHistoryCompany.getFiscalNumber() | companyFederalNumber }} \r\n {{ salesHistoryCompany.getEmployeeCount() }} vidas \r\n
\r\n
\r\n
\r\n\r\n
\r\n
\r\n
\r\n \r\n Titular/Dependente\r\n \r\n Todos\r\n Somente Titular\r\n Somente Dependente\r\n \r\n \r\n\r\n \r\n Tipo\r\n \r\n CPF\r\n NOME\r\n Nº DO CARTÃO\r\n \r\n \r\n
\r\n \r\n Pesquisar CPF\r\n \r\n \r\n \r\n Pesquisar Nome\r\n \r\n \r\n \r\n Pesquisar Número do Cartão\r\n \r\n \r\n
\r\n \r\n
\r\n
\r\n
\r\n
\r\n Produtos
Vendidos
\r\n {{ salesHistoryCompany.getSalesHistorySummary().getProductSoldCount() }}\r\n
\r\n
\r\n Valores
Gerados
\r\n {{ salesHistoryCompany.getSalesHistorySummary().getSalesValueableCount() | currencyPbmPipe }}\r\n
\r\n
\r\n Subsídio
Praticado
\r\n {{ salesHistoryCompany.getSalesHistorySummary().getSalesSubsidyValueCount() | currencyPbmPipe }}\r\n
\r\n
\r\n Desconto
em folha
\r\n {{ salesHistoryCompany.getSalesHistorySummary().getPaymentrollValueCount() | currencyPbmPipe }}\r\n
\r\n
\r\n
\r\n
\r\n \r\n Data inicial\r\n \r\n \r\n \r\n Data final\r\n \r\n \r\n \r\n Por Fabricante\r\n \r\n \r\n \r\n Por Tipo de Produto\r\n \r\n Todos\r\n {{ type.getValue() }}\r\n \r\n \r\n
\r\n
\r\n
\r\n
\r\n
\r\n Medicamento/Produto\r\n {{ item.getProductName() }}\r\n
\r\n
\r\n Quantidade\r\n {{ item.getSoldItemCount() }}\r\n
\r\n
\r\n Região\r\n {{ item.getStateName() }}\r\n
\r\n
\r\n Rede\r\n {{ item.getNetworkName() }}\r\n
\r\n
\r\n Valor Gerado\r\n {{ item.getSoldValueCount().toFixed(2) | currencyPbmPipe }}\r\n
\r\n
\r\n \r\n
\r\n\r\n
\r\n","import { Component, OnInit } from \"@angular/core\";\r\nimport { Router } from \"@angular/router\";\r\nimport { PageableResult } from \"src/app/ui/models/domains/paginator/pageable-result\";\r\nimport { UserPermissions } from \"./../../../../models/domains/pbm/user/user-permissions\";\r\nimport { UserService } from \"src/app/ui/services/user.service\";\r\nimport { MaskInput } from \"src/app/ui/models/domains/masks/mask.model\";\r\nimport { AppContext } from \"src/app/ui/contexts/app-context\";\r\nimport { FeatureViewService } from \"src/app/ui/services/feature-view.service\";\r\nimport { FeatureViews } from \"src/app/ui/models/domains/features/custom-feature-views\";\r\nimport { PagingRequest } from \"src/app/ui/models/domains/paginator/paging-request\";\r\nimport { PageViews } from \"src/app/ui/models/domains/features/custom-page-views\";\r\nimport { RoutePath } from \"src/app/ui/models/domains/route-paths.model\";\r\nimport { LoadingService } from \"src/app/ui/services/loading.service\";\r\nimport { CompanyService } from \"src/app/ui/services/pbm/company.service\";\r\nimport { UserProfile } from \"src/app/ui/models/domains/pbm/user/user-profile\";\r\nimport { Company } from \"src/app/ui/models/domains/pbm/companies/company\";\r\nimport { UntypedFormControl } from \"@angular/forms\";\r\nimport { ICompanyFilterParams } from \"src/app/ui/models/domains/pbm/companies/company-filter-params\";\r\n\r\n@Component({\r\n selector: \"search-financial-statement\",\r\n templateUrl: \"./search-financial-statement.component.html\",\r\n styleUrls: [\"./search-financial-statement.component.scss\"],\r\n})\r\nexport class SearchFinancialStatementComponent implements OnInit {\r\n filterText: string;\r\n pageableResult: PageableResult = new PageableResult();\r\n fiscalNumberMask = MaskInput.getFicalNumberMask();\r\n userProfile: UserProfile;\r\n searchType: UntypedFormControl;\r\n private searchCompanyFirst: boolean;\r\n\r\n constructor(\r\n private router: Router,\r\n private featureViewService: FeatureViewService,\r\n private loadingService: LoadingService,\r\n private companyService: CompanyService,\r\n private appContext: AppContext,\r\n private userService: UserService,\r\n ) {\r\n this.searchType = new UntypedFormControl(1);\r\n }\r\n\r\n ngOnInit() {\r\n this.featureViewService.activeFeatureView(FeatureViews.FinancialStatementSearchFeatureView, PageViews.FinancialStatementPageView);\r\n this.userProfile = this.userService.getUserProfile();\r\n this.searchCompanies(this.userProfile.getPreferences().getFilterText());\r\n }\r\n\r\n navigateToFinancialStatementCompany(fiscalNumber: string) {\r\n this.router.navigate([RoutePath.FinancialStatementCompany], { queryParams: { b: fiscalNumber } });\r\n }\r\n\r\n scrollToLastCompany() {\r\n const bottom = document.getElementById(\"bottom\");\r\n bottom.scrollIntoView();\r\n }\r\n\r\n onPressEnterSearchCompanies(event): void {\r\n if (event.key === \"Enter\") {\r\n this.searchCompanies(this.filterText);\r\n }\r\n }\r\n\r\n searchCompanies(fiscalNumber: string) {\r\n const start = 1;\r\n const end = this.appContext.getTotalPerPage();\r\n this.searchCompanyFirst = true;\r\n this.doSearchCompany(start, end, fiscalNumber);\r\n }\r\n\r\n searchMoreCompanies() {\r\n this.searchCompanyFirst = false;\r\n const start = this.pageableResult.getEnd() + 1;\r\n const end = this.appContext.getTotalPerPage();\r\n this.doSearchCompany(start, end, this.userProfile.getPreferences().getFilterText());\r\n }\r\n\r\n private doSearchCompany(start: number, end: number, fiscalNumber: string): void {\r\n const pagingRequest = new PagingRequest();\r\n pagingRequest.setStart(start);\r\n pagingRequest.setEnd(end);\r\n const ref = this.loadingService.beginLoading();\r\n const filterParams: ICompanyFilterParams = {\r\n filterText: fiscalNumber ? fiscalNumber.replace(/[./-]/g, \"\") : \"\",\r\n };\r\n this.companyService\r\n .searchCompany(filterParams, pagingRequest)\r\n .then((pageableResult) => {\r\n this.pageableResult.setStart(start);\r\n this.pageableResult.setEnd(end);\r\n this.pageableResult.setTotalItems(pageableResult.getTotalItems());\r\n if (this.searchCompanyFirst) {\r\n this.pageableResult.setItems(pageableResult.getItems());\r\n } else {\r\n this.pageableResult.addItems(pageableResult.getItems());\r\n }\r\n this.storageSearchPreferences(fiscalNumber);\r\n this.filterText = \"\";\r\n })\r\n .catch((error) => {\r\n this.pageableResult.setItems(null);\r\n })\r\n .finally(() => {\r\n this.loadingService.finishLoading(ref);\r\n });\r\n }\r\n\r\n hasCompany(): boolean {\r\n return this.pageableResult.getItems().length > 0;\r\n }\r\n\r\n showScrollBottomBtn(): boolean {\r\n return this.pageableResult.getItems().length > 1;\r\n }\r\n\r\n showMoreCompaniesBtn(): boolean {\r\n return this.pageableResult.getTotalItems() !== this.pageableResult.getItems().length && this.pageableResult.getItems().length > 1;\r\n }\r\n\r\n hasAccessToViewFinancialStatement(): boolean {\r\n return this.userService.getLoggedUser().hasPermission(UserPermissions.SearchFinancialStatement);\r\n }\r\n\r\n storageSearchPreferences(fiscalNumber: string): void {\r\n this.userService.setUserPreferences(fiscalNumber ? fiscalNumber.replace(/[./-]/g, \"\") : \"\");\r\n this.userProfile = this.userService.getUserProfile();\r\n }\r\n\r\n getCompanyList(): Company[] {\r\n return this.pageableResult.getItems() as Company[];\r\n }\r\n}\r\n","
\r\n \r\n \r\n \r\n
\r\n search\r\n
\r\n
\r\n
\r\n
\r\n

1\">{{ pageableResult.getItems().length }} RESULTADOS ENCONTRADOS

\r\n

1 RESULTADO ENCONTRADO

\r\n

Nenhum resultado encontrado.

\r\n
\r\n arrow_drop_down\r\n ir para o fim da lista\r\n
\r\n
\r\n\r\n
\r\n
\r\n
\r\n \r\n
\r\n
\r\n

{{ company.getCorporateName() }}

\r\n CNPJ: {{ company.getFiscalNumber() | companyFederalNumber }} \r\n {{ company.getTradingName() }}\r\n
\r\n
\r\n
\r\n visibility\r\n {{ \"VISUALIZAR\" }}\r\n
\r\n
\r\n
\r\n
\r\n\r\n carregar mais registros\r\n
\r\n
\r\n","import moment from \"moment\";\r\n\r\nexport class Period {\r\n value: string;\r\n label: string;\r\n\r\n constructor(private dateValue: string, private labelValue: string) {\r\n this.setValue(dateValue);\r\n this.setLabel(labelValue);\r\n }\r\n\r\n setValue(value: string): void {\r\n this.value = value;\r\n }\r\n\r\n setLabel(value: string): void {\r\n this.label = value;\r\n }\r\n\r\n getValue(): string {\r\n return this.value;\r\n }\r\n\r\n getLabel(): string {\r\n return this.label;\r\n }\r\n\r\n static getLastMonths(totalMonths: number): Array {\r\n const dates = new Array();\r\n for (let i = 0; i < totalMonths; i++) {\r\n var dateValue = moment(new Date()).endOf(\"month\").subtract(i, \"month\");\r\n var labelValue = dateValue.format(\"MMMM\") + \" de \" + dateValue.year();\r\n const date = new Period(dateValue.format(\"DDMMYYYY\"), labelValue);\r\n dates.push(date);\r\n }\r\n return dates;\r\n }\r\n\r\n static getLastMonthsWithFixedDay(totalMonths: number, day: number): Array {\r\n const dates = new Array();\r\n for (let i = 0; i < totalMonths; i++) {\r\n var dateValue = moment(new Date()).endOf(\"month\").subtract(i, \"month\");\r\n if(dateValue.date() > day){\r\n dateValue = dateValue.date(day);\r\n }\r\n var labelValue = dateValue.format(\"MMMM\") + \" de \" + dateValue.year();\r\n const date = new Period(dateValue.format(\"DDMMYYYY\"), labelValue);\r\n dates.push(date);\r\n }\r\n return dates;\r\n }\r\n}\r\n","export class Option {\r\n value: number;\r\n viewValue: string;\r\n}\r\n\r\nexport abstract class BeneficiaryViewItem {\r\n private name: string;\r\n private socialNumber: string;\r\n private cardNumber: string;\r\n private limitType: Option;\r\n private limit: number;\r\n private active: boolean;\r\n\r\n private limitTypes: Array