allyhub 0.20.0 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/cloud-tools.js +5 -5
- package/dist/commands/export.js +1 -1
- package/dist/commands/frames.js +8 -8
- package/dist/commands/index.js +1 -1
- package/dist/commands/run.js +2 -0
- package/dist/commands.json +1 -1
- package/dist/help.js +3 -3
- package/dist/main.js +4 -4
- package/dist/node_modules/@allyhub/3d-extension/package.json +1 -1
- package/dist/node_modules/@allyhub/audio/package.json +1 -1
- package/dist/node_modules/@allyhub/blocks/dist/elements.js +1 -1
- package/dist/node_modules/@allyhub/blocks/dist/layout.js +1 -1
- package/dist/node_modules/@allyhub/blocks/dist/palette.js +1 -1
- package/dist/node_modules/@allyhub/blocks/dist/resolve.js +1 -1
- package/dist/node_modules/@allyhub/blocks/package.json +1 -1
- package/dist/node_modules/@allyhub/browser/package.json +1 -1
- package/dist/node_modules/@allyhub/build/dist/migrate.js +1 -1
- package/dist/node_modules/@allyhub/build/dist/prepare.js +3 -3
- package/dist/node_modules/@allyhub/build/dist/project-root.js +1 -1
- package/dist/node_modules/@allyhub/build/dist/work.js +3 -3
- package/dist/node_modules/@allyhub/build/package.json +1 -1
- package/dist/node_modules/@allyhub/canvas-extension/package.json +1 -1
- package/dist/node_modules/@allyhub/canvas-model/package.json +1 -1
- package/dist/node_modules/@allyhub/chart/package.json +1 -1
- package/dist/node_modules/@allyhub/check/package.json +1 -1
- package/dist/node_modules/@allyhub/cloud/dist/call.js +2 -2
- package/dist/node_modules/@allyhub/cloud/dist/client.js +1 -1
- package/dist/node_modules/@allyhub/cloud/package.json +1 -1
- package/dist/node_modules/@allyhub/components/package.json +1 -1
- package/dist/node_modules/@allyhub/dev-server/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/dev-server/dist/record.js +2 -1
- package/dist/node_modules/@allyhub/dev-server/dist/validate.js +2 -2
- package/dist/node_modules/@allyhub/dev-server/package.json +1 -1
- package/dist/node_modules/@allyhub/diagnostics/package.json +1 -1
- package/dist/node_modules/@allyhub/doc/dist/block-shapes.js +2 -0
- package/dist/node_modules/@allyhub/doc/dist/blocks.js +1 -1
- package/dist/node_modules/@allyhub/doc/dist/docx.js +5 -5
- package/dist/node_modules/@allyhub/doc/dist/shapes.js +2 -2
- package/dist/node_modules/@allyhub/doc/package.json +1 -1
- package/dist/node_modules/@allyhub/doc-extension/dist/cli/import.js +1 -1
- package/dist/node_modules/@allyhub/doc-extension/dist/export.js +1 -1
- package/dist/node_modules/@allyhub/doc-extension/package.json +1 -1
- package/dist/node_modules/@allyhub/doc-print/package.json +1 -1
- package/dist/node_modules/@allyhub/export/package.json +1 -1
- package/dist/node_modules/@allyhub/extension-api/package.json +1 -1
- package/dist/node_modules/@allyhub/extension-host/package.json +1 -1
- package/dist/node_modules/@allyhub/formats/dist/data/deck-code.d.ts +3 -3
- package/dist/node_modules/@allyhub/formats/dist/data/page-data.d.ts +9 -1
- package/dist/node_modules/@allyhub/formats/dist/data/page-data.js +1 -1
- package/dist/node_modules/@allyhub/formats/dist/data/sheet.d.ts +151 -151
- package/dist/node_modules/@allyhub/formats/dist/data/slides.d.ts +173 -173
- package/dist/node_modules/@allyhub/formats/dist/data/work.d.ts +1 -2
- package/dist/node_modules/@allyhub/formats/dist/data/work.js +1 -1
- package/dist/node_modules/@allyhub/formats/dist/index.d.ts +1 -1
- package/dist/node_modules/@allyhub/formats/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/formats/dist/layout.d.ts +2 -0
- package/dist/node_modules/@allyhub/formats/dist/layout.js +1 -1
- package/dist/node_modules/@allyhub/formats/dist/schemas.d.ts +106 -101
- package/dist/node_modules/@allyhub/formats/dist/schemas.js +1 -1
- package/dist/node_modules/@allyhub/formats/dist/tolerant.d.ts +26 -1
- package/dist/node_modules/@allyhub/formats/dist/tolerant.js +1 -1
- package/dist/node_modules/@allyhub/formats/package.json +1 -1
- package/dist/node_modules/@allyhub/html-extension/package.json +1 -1
- package/dist/node_modules/@allyhub/i18n/package.json +1 -1
- package/dist/node_modules/@allyhub/image-draw/package.json +1 -1
- package/dist/node_modules/@allyhub/image-extension/package.json +1 -1
- package/dist/node_modules/@allyhub/image-extension/skills/allyhub/references/images.md +1 -1
- package/dist/node_modules/@allyhub/image-measure/package.json +1 -1
- package/dist/node_modules/@allyhub/image-psd/package.json +1 -1
- package/dist/node_modules/@allyhub/image-render/package.json +1 -1
- package/dist/node_modules/@allyhub/image-runtime/package.json +1 -1
- package/dist/node_modules/@allyhub/image-sdk/package.json +1 -1
- package/dist/node_modules/@allyhub/jobs/package.json +1 -1
- package/dist/node_modules/@allyhub/linkedin-extension/package.json +1 -1
- package/dist/node_modules/@allyhub/linkedin-model/package.json +1 -1
- package/dist/node_modules/@allyhub/linkedin-view/package.json +1 -1
- package/dist/node_modules/@allyhub/linkedin-view/src/style.css +1 -1
- package/dist/node_modules/@allyhub/measure/package.json +1 -1
- package/dist/node_modules/@allyhub/media/package.json +1 -1
- package/dist/node_modules/@allyhub/media-extension/package.json +1 -1
- package/dist/node_modules/@allyhub/model/package.json +1 -1
- package/dist/node_modules/@allyhub/office-extension/package.json +1 -1
- package/dist/node_modules/@allyhub/ooxml/package.json +1 -1
- package/dist/node_modules/@allyhub/piece/package.json +1 -1
- package/dist/node_modules/@allyhub/project/package.json +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/cloud.js +1 -1
- package/dist/node_modules/@allyhub/protocol/package.json +1 -1
- package/dist/node_modules/@allyhub/registry/package.json +1 -1
- package/dist/node_modules/@allyhub/render/package.json +1 -1
- package/dist/node_modules/@allyhub/report-extension/LICENSE +241 -0
- package/dist/node_modules/@allyhub/report-extension/dist/build.js +3 -0
- package/dist/node_modules/@allyhub/report-extension/dist/check.js +37 -0
- package/dist/node_modules/@allyhub/report-extension/dist/cli/index.js +4 -0
- package/dist/node_modules/@allyhub/report-extension/dist/export.js +2 -0
- package/dist/node_modules/@allyhub/report-extension/dist/inline.js +58 -0
- package/dist/node_modules/@allyhub/report-extension/dist/page.js +23 -0
- package/dist/node_modules/@allyhub/report-extension/dist/project-tools.js +33 -0
- package/dist/node_modules/@allyhub/report-extension/dist/styles.js +2 -0
- package/dist/node_modules/@allyhub/report-extension/dist/theme.js +2 -0
- package/dist/node_modules/@allyhub/report-extension/dist/tools.js +2 -0
- package/dist/node_modules/@allyhub/report-extension/dist/workspace.js +2 -0
- package/dist/node_modules/@allyhub/report-extension/package.json +185 -0
- package/dist/node_modules/@allyhub/report-extension/styles/allyhub/STYLE.md +180 -0
- package/dist/node_modules/@allyhub/report-extension/styles/allyhub/style.json +15 -0
- package/dist/node_modules/@allyhub/runtime/package.json +1 -1
- package/dist/node_modules/@allyhub/runtimes/package.json +1 -1
- package/dist/node_modules/@allyhub/scaffold/dist/index.js +8 -8
- package/dist/node_modules/@allyhub/scaffold/package.json +1 -1
- package/dist/node_modules/@allyhub/scenery/package.json +1 -1
- package/dist/node_modules/@allyhub/scenery-host/package.json +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/file.js +2 -2
- package/dist/node_modules/@allyhub/sheet/dist/html.js +10 -10
- package/dist/node_modules/@allyhub/sheet/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/table-style.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/theme.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/tiles.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/charts.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/tile-shapes.js +2 -0
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/write.js +1 -1
- package/dist/node_modules/@allyhub/sheet/package.json +1 -1
- package/dist/node_modules/@allyhub/sheet-extension/dist/build.js +1 -1
- package/dist/node_modules/@allyhub/sheet-extension/dist/cli/sheet.js +1 -1
- package/dist/node_modules/@allyhub/sheet-extension/package.json +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/capabilities.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/file.js +3 -3
- package/dist/node_modules/@allyhub/slides-core/package.json +1 -1
- package/dist/node_modules/@allyhub/slides-extension/dist/build.js +2 -2
- package/dist/node_modules/@allyhub/slides-extension/dist/cli/slides.js +1 -1
- package/dist/node_modules/@allyhub/slides-extension/package.json +1 -1
- package/dist/node_modules/@allyhub/slides-pptx/package.json +1 -1
- package/dist/node_modules/@allyhub/slides-runtime/package.json +1 -1
- package/dist/node_modules/@allyhub/stage/package.json +1 -1
- package/dist/node_modules/@allyhub/stage-page/package.json +1 -1
- package/dist/node_modules/@allyhub/stage-runtime/dist/runtime.js +2 -2
- package/dist/node_modules/@allyhub/stage-runtime/package.json +1 -1
- package/dist/node_modules/@allyhub/telemetry/package.json +1 -1
- package/dist/node_modules/@allyhub/text-extension/package.json +1 -1
- package/dist/node_modules/@allyhub/video-core/package.json +1 -1
- package/dist/node_modules/@allyhub/video-extension/package.json +1 -1
- package/dist/node_modules/@allyhub/video-measure/package.json +1 -1
- package/dist/node_modules/@allyhub/video-sdk/package.json +1 -1
- package/dist/node_modules/@allyhub/website/package.json +1 -1
- package/dist/node_modules/@allyhub/website-extension/package.json +1 -1
- package/dist/node_modules/@allyhub/x-extension/package.json +1 -1
- package/dist/node_modules/@allyhub/x-model/package.json +1 -1
- package/dist/node_modules/@allyhub/x-view/package.json +1 -1
- package/dist/package.json +15 -14
- package/dist/run-register.js +2 -0
- package/dist/works.js +1 -1
- package/editor-web/assets/{abnfDiagram-WEYOIA3C-BkVJMd53.js → abnfDiagram-WEYOIA3C-D6qI3rai.js} +1 -1
- package/editor-web/assets/{architecture-WOLXFQ4H-C6rnaynZ.js → architecture-WOLXFQ4H-B3V6ggq8.js} +1 -1
- package/editor-web/assets/{architectureDiagram-ZHVYKT53-D3vrh8LK.js → architectureDiagram-ZHVYKT53-IauNyxXn.js} +1 -1
- package/editor-web/assets/article-BHjKp5We.js +3 -0
- package/editor-web/assets/article-BlNKv1Cn.js +7 -0
- package/editor-web/assets/bar-button-CJmpgNg4.js +1 -0
- package/editor-web/assets/{blockDiagram-RJAE7QA3-BKngt8H7.js → blockDiagram-RJAE7QA3-yXhlfxbH.js} +1 -1
- package/editor-web/assets/{c4Diagram-XDPPPE54-j7sUELqF.js → c4Diagram-XDPPPE54-B-anrhvt.js} +1 -1
- package/editor-web/assets/{calc-worker-Cr4a0xmt.js → calc-worker-BpAgQE9E.js} +3 -3
- package/editor-web/assets/channel-Bhb-_8v6.js +1 -0
- package/editor-web/assets/chip-pNQlYa2W.js +1 -0
- package/editor-web/assets/{chunk-2E7WHVMD-BXa-uRSi.js → chunk-2E7WHVMD-QPOni4XB.js} +1 -1
- package/editor-web/assets/{chunk-4EMNKR2T-B3ntcsZN.js → chunk-4EMNKR2T-DG1FCRRI.js} +1 -1
- package/editor-web/assets/{chunk-55XCU76K-AMvnFwUg.js → chunk-55XCU76K-mKuMXpnC.js} +1 -1
- package/editor-web/assets/{chunk-7S6XSTFO-BA6esfFu.js → chunk-7S6XSTFO-CgZAazgt.js} +1 -1
- package/editor-web/assets/{chunk-AQDTSKZB-BT_vANXs.js → chunk-AQDTSKZB-BRU84phF.js} +1 -1
- package/editor-web/assets/{chunk-DSNLSHJZ-DoUgmzGB.js → chunk-DSNLSHJZ-zku9oeG3.js} +1 -1
- package/editor-web/assets/{chunk-HAGFOTED-DtnIrCZb.js → chunk-HAGFOTED-CaUkBv_0.js} +1 -1
- package/editor-web/assets/{chunk-HNE4Q36P-BlPwQx3_.js → chunk-HNE4Q36P-BQz4ZCJf.js} +1 -1
- package/editor-web/assets/{chunk-NQOKRVIF-D2r7jp2r.js → chunk-NQOKRVIF-CHVBEDkg.js} +1 -1
- package/editor-web/assets/{chunk-UHW7PFBP-Cmc0_F5o.js → chunk-UHW7PFBP-DrYeJo1e.js} +1 -1
- package/editor-web/assets/{chunk-VQ5W62QI-nJSMqAr0.js → chunk-VQ5W62QI-D8ToVCUe.js} +1 -1
- package/editor-web/assets/{chunk-WQQL4CDK-Btq2nbF6.js → chunk-WQQL4CDK-DZ0tyi9F.js} +1 -1
- package/editor-web/assets/{chunk-YZO67HFG-DTbcCoGt.js → chunk-YZO67HFG-BLe7PXER.js} +1 -1
- package/editor-web/assets/{chunk-ZAUX2LTX-DVwkg-2N.js → chunk-ZAUX2LTX-ByaeSIre.js} +1 -1
- package/editor-web/assets/{chunk-ZCHMQSOR-BV39jOOE.js → chunk-ZCHMQSOR-DdMJr_t5.js} +1 -1
- package/editor-web/assets/{classDiagram-v2-4MYWR3UA-Cj74-fhM.js → classDiagram-v2-4MYWR3UA-DDpq7fFC.js} +1 -1
- package/editor-web/assets/collaborator-CbTacvkB.js +1 -0
- package/editor-web/assets/color-picker-CDeICDN5.js +1 -0
- package/editor-web/assets/{cynefin-EF2NZ3EQ-C0CkiipV.js → cynefin-EF2NZ3EQ-CMivy2fr.js} +1 -1
- package/editor-web/assets/{cynefinDiagram-WF24UDRP-hdsnJ4cI.js → cynefinDiagram-WF24UDRP-GtxT_9wW.js} +1 -1
- package/editor-web/assets/{dagre-NK4GIZVX-CC7WSgaK.js → dagre-NK4GIZVX-Bn1O2Hjl.js} +1 -1
- package/editor-web/assets/deck-Cohd-G5m.js +1 -0
- package/editor-web/assets/{diagram-CBK3MWTC-DmaVm13J.js → diagram-CBK3MWTC-W715PWZw.js} +1 -1
- package/editor-web/assets/{diagram-I5XIIV2D-De8jqp7b.js → diagram-I5XIIV2D-BKObZPn2.js} +1 -1
- package/editor-web/assets/{diagram-ODIL2UCW-B5pBTulX.js → diagram-ODIL2UCW-UtQxEPoW.js} +1 -1
- package/editor-web/assets/{diagram-PFBEJUXE-BYsXg5_w.js → diagram-PFBEJUXE-CpLGEK-k.js} +1 -1
- package/editor-web/assets/{diagram-RJA3I4VV-DZ8f6bYe.js → diagram-RJA3I4VV-DGyMXoHb.js} +1 -1
- package/editor-web/assets/{diagram-TYUNFSNR-qXHUsauD.js → diagram-TYUNFSNR-Dy_Ewr8V.js} +1 -1
- package/editor-web/assets/dist-0I0Obj60.js +19 -0
- package/editor-web/assets/dist-6ugUm4dS.js +6 -0
- package/editor-web/assets/dist-B0rUvCi2.js +1 -0
- package/editor-web/assets/{dist-DAhe-kFC.js → dist-B8_6sJ_V.js} +1 -1
- package/editor-web/assets/dist-CKD_paj_.js +1 -0
- package/editor-web/assets/dist-CKUW5NzS.js +3 -0
- package/editor-web/assets/dist-Ca9Gsuu0.js +24 -0
- package/editor-web/assets/dist-Cc8v9lfc.js +1 -0
- package/editor-web/assets/dist-CynBNzYv.js +1 -0
- package/editor-web/assets/{dist-9kuRjUTN.js → dist-D7M5YTq2.js} +6 -6
- package/editor-web/assets/dist-D9tsFc2N.js +16 -0
- package/editor-web/assets/dist-DNMKDcLg.js +35 -0
- package/editor-web/assets/dist-Doj7_HUI.js +547 -0
- package/editor-web/assets/dist-DptBQzJR.js +1 -0
- package/editor-web/assets/dist-DzKB210A.js +5 -0
- package/editor-web/assets/{dist-B3rd02Cg.js → dist-H9rTuNhb.js} +6 -6
- package/editor-web/assets/{dist-DA72-4WB.js → dist-QLXI7XGS.js} +1 -1
- package/editor-web/assets/dist-RyGsFHE0.js +4 -0
- package/editor-web/assets/dist-oeSWr2LE.js +19 -0
- package/editor-web/assets/dist-wD_hHJ8_.js +19 -0
- package/editor-web/assets/{docx-draw-L54blreB.js → docx-draw-B5cM77hc.js} +1 -1
- package/editor-web/assets/{ebnfDiagram-V4P3TTPT-B7-IfVI-.js → ebnfDiagram-V4P3TTPT-GPYcx6dU.js} +1 -1
- package/editor-web/assets/{elk-QONTBCTQ-Gj_WaeBn.js → elk-QONTBCTQ-Bi0r4UFM.js} +1 -1
- package/editor-web/assets/{erDiagram-KYQIGQAA-BDF6Qoqx.js → erDiagram-KYQIGQAA-DrOSrnci.js} +1 -1
- package/editor-web/assets/esm-jIPnpbBD.js +21 -0
- package/editor-web/assets/{eventmodeling-K75KTNOO-elxVXXEe.js → eventmodeling-K75KTNOO-Dw-MjgUb.js} +1 -1
- package/editor-web/assets/eye-DwfE1USj.js +1 -0
- package/editor-web/assets/flowDiagram-IUGLLWBU-DbZTfPEP.js +1 -0
- package/editor-web/assets/{ganttDiagram-R7GPNTJY-CEogW3jW.js → ganttDiagram-R7GPNTJY-Bwe8cQqi.js} +1 -1
- package/editor-web/assets/{gitGraph-VSP46ZUC-Bh9cRWFa.js → gitGraph-VSP46ZUC-DsAcAKP0.js} +1 -1
- package/editor-web/assets/{gitGraphDiagram-PDYL7XHY-BQAvdM_V.js → gitGraphDiagram-PDYL7XHY-aObRwdru.js} +1 -1
- package/editor-web/assets/hint-F4fIBnVU.js +1 -0
- package/editor-web/assets/index-Cah2zchD.css +2 -0
- package/editor-web/assets/index-D-MNVykg.js +28 -0
- package/editor-web/assets/{info-OHQRW6UA-CdPrqere.js → info-OHQRW6UA-DBPN8JFr.js} +1 -1
- package/editor-web/assets/{infoDiagram-MVDRKAX5-uwIMeP44.js → infoDiagram-MVDRKAX5-Bx26Hq7M.js} +1 -1
- package/editor-web/assets/{ishikawaDiagram-HPEHV2GE-rtfvqK7E.js → ishikawaDiagram-HPEHV2GE-BJ_MCDwA.js} +1 -1
- package/editor-web/assets/{journeyDiagram-BOSHW7O7-mmhfIyVG.js → journeyDiagram-BOSHW7O7-B5g4W2Dx.js} +1 -1
- package/editor-web/assets/{kanban-definition-FNSA4HC5-Fe7jBsi-.js → kanban-definition-FNSA4HC5-U8YNlxN7.js} +1 -1
- package/editor-web/assets/layout-CuWN7_3k.js +1 -0
- package/editor-web/assets/{mermaid-parser.core-BxOSjBH9.js → mermaid-parser.core-DYLQlYDo.js} +3 -3
- package/editor-web/assets/{mermaid.core-BOln9YdH.js → mermaid.core-qNJmZ0b4.js} +4 -4
- package/editor-web/assets/{mindmap-definition-6OY57UG3-M3Q1LOtO.js → mindmap-definition-6OY57UG3-CI5aBWbK.js} +1 -1
- package/editor-web/assets/{packet-JDAUHWVQ-Dbb0TUG6.js → packet-JDAUHWVQ-BBclMGlJ.js} +1 -1
- package/editor-web/assets/palette-DchDLJj6.js +1 -0
- package/editor-web/assets/panes-BShVq38A.js +3 -0
- package/editor-web/assets/{pegDiagram-ECIUJNBX-BZMRpSFC.js → pegDiagram-ECIUJNBX-B3pljPTu.js} +1 -1
- package/editor-web/assets/{pie-XZMESJXO-Ctm9XdKp.js → pie-XZMESJXO-B7WzimHm.js} +1 -1
- package/editor-web/assets/{pieDiagram-GNMPY74T-cGbs5ZTl.js → pieDiagram-GNMPY74T-tM1Da50-.js} +1 -1
- package/editor-web/assets/progress-D1Uv3d1b.js +6 -0
- package/editor-web/assets/{quadrantDiagram-D57K4MC3-BUe_zsxT.js → quadrantDiagram-D57K4MC3-BEq_Shj9.js} +1 -1
- package/editor-web/assets/{radar-ABXABTNO-CCmKtqLs.js → radar-ABXABTNO-v2jJSW5T.js} +1 -1
- package/editor-web/assets/{railroad-I3PHUGI6-k-yhjhjA.js → railroad-I3PHUGI6-6W3Z4F8Y.js} +1 -1
- package/editor-web/assets/{railroad-abnf-LNEFI6M7-B-PvntB3.js → railroad-abnf-LNEFI6M7-DxIN7Zrt.js} +1 -1
- package/editor-web/assets/{railroad-ebnf-DWYD2UWJ-Ds2rua1h.js → railroad-ebnf-DWYD2UWJ-Bb5O7tAx.js} +1 -1
- package/editor-web/assets/{railroad-peg-JR7BVNR7-jNZ2wEp2.js → railroad-peg-JR7BVNR7-i2LjEP5t.js} +1 -1
- package/editor-web/assets/{railroadDiagram-Y72NRBL7-CTqSQ15w.js → railroadDiagram-Y72NRBL7-DhsyVKbG.js} +1 -1
- package/editor-web/assets/{requirementDiagram-EQYSW5RA-CUblhR5M.js → requirementDiagram-EQYSW5RA-Du2k7i1E.js} +1 -1
- package/editor-web/assets/ribbon-tabs-Bxuj_hct.js +1 -0
- package/editor-web/assets/row-DqS4-5b1.js +1 -0
- package/editor-web/assets/{sankeyDiagram-SY24JHO5-nSz6zDX3.js → sankeyDiagram-SY24JHO5-CDnRMu7J.js} +1 -1
- package/editor-web/assets/schemas-CnlOL0u4.js +1 -0
- package/editor-web/assets/{sequenceDiagram-BLEHNHQU-DxTpOYuo.js → sequenceDiagram-BLEHNHQU-BUXBhWYW.js} +1 -1
- package/editor-web/assets/{session-BhClkDyr.js → session--OJYv_B7.js} +1 -1
- package/editor-web/assets/{snapshots-DwGHDN3t.js → snapshots-DYooVfOx.js} +1 -1
- package/editor-web/assets/{stateDiagram-v2-A6IESKWZ-C3e14iHY.js → stateDiagram-v2-A6IESKWZ-Enb8LZUA.js} +1 -1
- package/editor-web/assets/surface-BUoi7cmR.js +1 -0
- package/editor-web/assets/swatch-DCmD1gZl.js +1 -0
- package/editor-web/assets/{swimlanes-B3ENRKFQ-DPPdzNzu.js → swimlanes-B3ENRKFQ-pnpjgTrl.js} +1 -1
- package/editor-web/assets/swimlanesDiagram-AYQRV4AK-B-B2Eoc8.js +8 -0
- package/editor-web/assets/switch-b6GCy_ix.js +1 -0
- package/editor-web/assets/syntax-Bqyhj0dw.js +1 -0
- package/editor-web/assets/tablet-C6oePHEW.js +1 -0
- package/editor-web/assets/textarea-Bu6uPEqT.js +1 -0
- package/editor-web/assets/themes-D_ISkWVz.js +1 -0
- package/editor-web/assets/{timeline-definition-JXYKGLGB-DRTJ1_Er.js → timeline-definition-JXYKGLGB-C4pR18kd.js} +1 -1
- package/editor-web/assets/trash-2-SFReAxVM.js +1 -0
- package/editor-web/assets/{treeView-D4JQ5SDB-BYJ_m-i5.js → treeView-D4JQ5SDB-kzNGeAv6.js} +1 -1
- package/editor-web/assets/{treemap-SAJKECNS-BcU6I6Rg.js → treemap-SAJKECNS-Buhb5wzt.js} +1 -1
- package/editor-web/assets/updating-Cbxw83_O.js +1 -0
- package/editor-web/assets/{usecaseDiagram-WPOLBNNX-YV92pS4o.js → usecaseDiagram-WPOLBNNX-CL-xLQWl.js} +1 -1
- package/editor-web/assets/{vennDiagram-Q3Y3IDCW-oAvfHZtf.js → vennDiagram-Q3Y3IDCW-bwsyCcdK.js} +1 -1
- package/editor-web/assets/{video-SJvDRCJK.js → video-8MxWX9f5.js} +1 -1
- package/editor-web/assets/{wardley-7MLQ67FV-BLNiqxtt.js → wardley-7MLQ67FV-DXsLgedI.js} +1 -1
- package/editor-web/assets/{wardleyDiagram-IVAIDKWA-SppgC6xW.js → wardleyDiagram-IVAIDKWA-Cn0ph953.js} +1 -1
- package/editor-web/assets/{words-BUlNNuH2.js → words-B2jQwWpp.js} +1 -1
- package/editor-web/assets/{words-zMedmPWc.js → words-DgMuEmDO.js} +1 -1
- package/editor-web/assets/workbook-BDWkQ149.js +41 -0
- package/editor-web/assets/x-BAJilkKD.js +41 -0
- package/editor-web/assets/{xychartDiagram-4URNHDU4-BHMn_jwJ.js → xychartDiagram-4URNHDU4-CfXnqGWZ.js} +1 -1
- package/editor-web/index.html +6 -6
- package/package.json +5 -2
- package/editor-web/assets/article-DHf6mOY_.js +0 -7
- package/editor-web/assets/article-Dns1-Xh-.js +0 -3
- package/editor-web/assets/bar-button-CKPfx2AB.js +0 -1
- package/editor-web/assets/channel-CVWSV3su.js +0 -1
- package/editor-web/assets/chip-Bn_9JRRG.js +0 -1
- package/editor-web/assets/collaborator-XiHOxwGM.js +0 -1
- package/editor-web/assets/deck-DQpNIS2p.js +0 -1
- package/editor-web/assets/dist--z0ZHp4T.js +0 -16
- package/editor-web/assets/dist-B5GOGGEe.js +0 -1
- package/editor-web/assets/dist-Bx6q9kCu.js +0 -1
- package/editor-web/assets/dist-C4hHtrJr.js +0 -1
- package/editor-web/assets/dist-CCXJewsi.js +0 -19
- package/editor-web/assets/dist-CfK2BLl8.js +0 -4
- package/editor-web/assets/dist-Cmux3oJ_.js +0 -1
- package/editor-web/assets/dist-Cspf85KV.js +0 -6
- package/editor-web/assets/dist-DOrGo1GD.js +0 -19
- package/editor-web/assets/dist-DjiCHlSu.js +0 -35
- package/editor-web/assets/dist-Do4a40Wn.js +0 -19
- package/editor-web/assets/dist-FKEWS3Co.js +0 -547
- package/editor-web/assets/dist-QKd2i6kG.js +0 -5
- package/editor-web/assets/dist-SGnOfLhx.js +0 -24
- package/editor-web/assets/dist-VmVB7tl4.js +0 -3
- package/editor-web/assets/esm-PQD5Pn8a.js +0 -21
- package/editor-web/assets/flowDiagram-IUGLLWBU-B-25n8zE.js +0 -1
- package/editor-web/assets/hint-CbwoSBMw.js +0 -1
- package/editor-web/assets/index-CXisi0Cj.css +0 -2
- package/editor-web/assets/index-wMlfx8aT.js +0 -28
- package/editor-web/assets/layout-SWqqA0yV.js +0 -1
- package/editor-web/assets/progress-DZQTiRLv.js +0 -6
- package/editor-web/assets/ribbon-DajdQ_Ya.js +0 -1
- package/editor-web/assets/row-Bei9HNEe.js +0 -1
- package/editor-web/assets/schemas-C21MyseF.js +0 -1
- package/editor-web/assets/split-DBAbwPZ5.js +0 -3
- package/editor-web/assets/surface-CIF0Ae0z.js +0 -1
- package/editor-web/assets/swatch-BUzr_XmH.js +0 -1
- package/editor-web/assets/swimlanesDiagram-AYQRV4AK-B8n3zOw_.js +0 -8
- package/editor-web/assets/switch-DrZxoPQS.js +0 -1
- package/editor-web/assets/syntax-emXV4DnN.js +0 -1
- package/editor-web/assets/tabs-BwU2E7bU.js +0 -1
- package/editor-web/assets/textarea-BX_ax3X8.js +0 -1
- package/editor-web/assets/tolerant-DM9s0Mt1.js +0 -1
- package/editor-web/assets/type-CvZ0HZsV.js +0 -41
- package/editor-web/assets/workbook-BZKYx4WB.js +0 -41
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import{i as e,n as t,t as n}from"./rolldown-runtime-COiEfhsA.js";import{n as r}from"./schemas-C21MyseF.js";import{a as i,lt as a,m as o,ot as s,p as c,r as l,s as u,ut as d}from"./tolerant-DM9s0Mt1.js";import{r as f}from"./csv-Bwre9FdI.js";import{B as p,H as m,I as h,L as g,M as _,N as v,O as ee,R as te,V as y,d as b,i as ne,j as re,k as ie,l as ae,m as oe,n as se,t as ce,v as le,z as ue}from"./dist-B3rd02Cg.js";import{d as de,f as fe,i as pe,l as me,n as he,o as ge,p as _e}from"./browser-DEGNhKTV.js";var ve=[`Normal`,`Title`,`Heading 1`,`Heading 2`,`Heading 3`,`Heading 4`,`Good`,`Bad`,`Neutral`,`Input`,`Output`,`Calculation`,`Check Cell`,`Linked Cell`,`Note`,`Warning Text`,`Explanatory Text`,`Total`,`Hyperlink`,`Followed Hyperlink`,...[1,2,3,4,5,6].flatMap(e=>[`Accent${String(e)}`,`20% - Accent${String(e)}`,`40% - Accent${String(e)}`,`60% - Accent${String(e)}`]),`Comma`,`Comma [0]`,`Currency`,`Currency [0]`,`Percent`],ye={"Headline 1":`Heading 1`,"Headline 2":`Heading 2`,"Headline 3":`Heading 3`,"Headline 4":`Heading 4`},be=[...ve,...Object.keys(ye)];({...Object.fromEntries([1,2,3,4,5,6].flatMap(e=>{let t=29+(e-1)*4;return[[`Accent${String(e)}`,t],[`20% - Accent${String(e)}`,t+1],[`40% - Accent${String(e)}`,t+2],[`60% - Accent${String(e)}`,t+3]]}))});var xe=1048576,Se=16384;function Ce(e){let t=``;for(let n=e+1;n>0;n=Math.floor((n-1)/26))t=String.fromCharCode(65+(n-1)%26)+t;return t}function we(e){if(!/^[A-Za-z]{1,3}$/u.test(e))return;let t=0;for(let n of e.toUpperCase())t=t*26+n.charCodeAt(0)-64;return t<=16384?t-1:void 0}var Te=e=>`${Ce(e.col)}${String(e.row+1)}`;function Ee(e){let t=Te({row:e.top,col:e.left});return e.top===e.bottom&&e.left===e.right?t:`${t}:${Te({row:e.bottom,col:e.right})}`}function De(e){let t=/^\$?([A-Za-z]{1,3})\$?([1-9]\d*)$/u.exec(e.trim());if(!t)return;let n=we(t[1]??``),r=Number(t[2])-1;return n===void 0||r>=1048576?void 0:{row:r,col:n}}function x(e){let[t=``,n,r]=e.split(`:`);if(r!==void 0)return;let i=De(t),a=n===void 0?i:De(n);if(i&&a)return{top:Math.min(i.row,a.row),left:Math.min(i.col,a.col),bottom:Math.max(i.row,a.row),right:Math.max(i.col,a.col)}}function Oe(e){let t=[];for(let n of e.trim().split(/\s+/u)){let e=x(n);if(!e)return;t.push(e)}return t}var ke=(e,t,n)=>t>=e.top&&t<=e.bottom&&n>=e.left&&n<=e.right,S=(e,t)=>e.top<=t.bottom&&t.top<=e.bottom&&e.left<=t.right&&t.left<=e.right,C=class e{static all=new Map;code;constructor(e){this.code=e}static of(t){let n=e.all.get(t);return n||(n=new e(t),e.all.set(t,n)),n}toString(){return this.code}toJSON(){return this.code}},w={NULL:C.of(`#NULL!`),DIV0:C.of(`#DIV/0!`),VALUE:C.of(`#VALUE!`),REF:C.of(`#REF!`),NAME:C.of(`#NAME?`),NUM:C.of(`#NUM!`),NA:C.of(`#N/A`),SPILL:C.of(`#SPILL!`),CALC:C.of(`#CALC!`),CYCLE:C.of(`#CYCLE!`)},Ae=[`#NULL!`,`#DIV/0!`,`#VALUE!`,`#REF!`,`#NAME?`,`#NUM!`,`#N/A`,`#GETTING_DATA`,`#SPILL!`,`#CALC!`,`#CYCLE!`];function je(e){let t=e.toUpperCase(),n=Ae.find(e=>e===t);return n===void 0?void 0:C.of(n)}var T=class{rows;cols;data;constructor(e,t,n){this.rows=e,this.cols=t,this.data=n}at(e,t){return this.data[e*this.cols+t]??null}},Me=864e5,Ne=25569;function Pe(e){let t=e+Ne;return t<61?t-1:t}function Fe(e){let t=Math.floor(e);if(t!==60)return(t<60?t+1:t)-Ne}function Ie(e,t,n){let r=new Date(Date.UTC(2e3,t-1,1));return r.setUTCFullYear(r.getUTCFullYear()-2e3+e),Pe(Math.floor(r.getTime()/Me))+n-1}function Le(e){let t=Fe(e);return t===void 0?{year:1900,month:2,day:29}:Math.floor(e)===0?{year:1900,month:1,day:0}:Re(t)}function Re(e){let t=e+719468,n=Math.floor(t/146097),r=t-n*146097,i=Math.floor((r-Math.floor(r/1460)+Math.floor(r/36524)-Math.floor(r/146096))/365),a=r-(365*i+Math.floor(i/4)-Math.floor(i/100)),o=Math.floor((5*a+2)/153),s=a-Math.floor((153*o+2)/5)+1,c=o<10?o+3:o-9;return{year:i+n*400+ +(c<=2),month:c,day:s}}function ze(e){let t=e.getTime(),n=Math.floor(t/Me);return Pe(n)+(t-n*Me)/Me}function Be(e){let t=Fe(e);if(t===void 0)return;let n=e-Math.floor(e);return new Date(t*Me+Math.round(n*Me))}var Ve=(e,t=2)=>String(e).padStart(t,`0`);function He(e){let{year:t,month:n,day:r}=Le(e),i=`${Ve(t,4)}-${Ve(n)}-${Ve(r)}`,a=Math.round((e-Math.floor(e))*86400);if(a===0)return i;let o=a%60;return`${i}T${Ve(Math.floor(a/3600))}:${Ve(Math.floor(a/60)%60)}${o===0?``:`:${Ve(o)}`}`}function Ue(e){if(e===0)return`0`;let t=Number(e.toPrecision(15)),n=Math.floor(Math.log10(Math.abs(t)));if(n>=15||n<-10){let[e=``,n=`0`]=t.toExponential().split(`e`),r=Number(n);return`${e}E${r<0?`-`:`+`}${Ve(Math.abs(r))}`}let r=String(t);return r.includes(`e`)?t.toFixed(Math.min(20,Math.abs(n)+15)).replace(/0+$/u,``):r}var We=/^[+-]?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?$/u,Ge=/^[+-]?\d{1,3}(?:,\d{3})+(?:\.\d+)?$/u,Ke=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?)?$/u,qe=e=>/^[+-]?\d+$/u.test(e)&&e.replace(/^[+-]?0*/u,``).length>15;function Je(e){let t=Ke.exec(e);if(!t)return;let[n,r,i]=[Number(t[1]),Number(t[2]),Number(t[3])],a=Ie(n,r,i),o=Le(a);if(o.month!==r||o.day!==i)return;if(t[4]===void 0)return{value:a,format:`yyyy-mm-dd`};let[s,c,l]=[Number(t[4]),Number(t[5]),Number(t[6]??0)];if(s>23||c>59||l>59)return;let u=t[7],d=0;if(u!==void 0&&u!==`Z`){let e=u.replace(`:`,``);d=(e.startsWith(`-`)?1:-1)*(Number(e.slice(1,3))*60+Number(e.slice(3,5)))/1440}return{value:a+(s*3600+c*60+l)/86400+d,format:t[6]===void 0?`yyyy-mm-dd hh:mm`:`yyyy-mm-dd hh:mm:ss`}}function Ye(e){let t=/^(\d{1,4}):([0-5]?\d)(?::([0-5]?\d))?(?:\s*([AaPp])[Mm]?)?$/u.exec(e)??/^(\d{1,2})()()\s*([AaPp])[Mm]?$/u.exec(e);if(!t)return;let n=Number(t[1]),r=t[2]===void 0||t[2]===``?0:Number(t[2]),i=t[3]===void 0||t[3]===``?0:Number(t[3]),a=t[4]?.toUpperCase();if(a!==void 0)return n<1||n>12?void 0:{value:((n%12+(a===`P`?12:0))*3600+r*60+i)/86400,format:t[3]?`h:mm:ss AM/PM`:`h:mm AM/PM`};let o=(n*3600+r*60+i)/86400;return n>=24?{value:o,format:`[h]:mm:ss`}:{value:o,format:t[3]?`h:mm:ss`:`h:mm`}}function Xe(e){if(e===``)return{value:null};if(e.startsWith(`'`))return{value:e.slice(1)};if(e.length>1&&e.startsWith(`=`))return{value:null,formula:e};let t=e.trim();if(t===``)return{value:e};let n=t.toUpperCase();if(n===`TRUE`)return{value:!0};if(n===`FALSE`)return{value:!1};if(We.test(t))return qe(t)?{value:e}:{value:Number(t)};if(t.endsWith(`%`)){let e=t.slice(0,-1).trim();if(We.test(e))return{value:Number(e)/100,format:e.includes(`.`)?`0.00%`:`0%`}}if(Ge.test(t))return{value:Number(t.replaceAll(`,`,``)),format:t.includes(`.`)?`#,##0.00`:`#,##0`};let r=/^([+-]?)\$(\d[\d,]*(?:\.\d+)?)$/u.exec(t),i=r?.[2]?.replaceAll(`,`,``);if(r&&i!==void 0)return{value:Number(`${r[1]??``}${i}`),format:t.includes(`.`)?`$#,##0.00`:`$#,##0`};let a=Je(t);if(a)return a;let o=Ye(t);if(o)return o;let s=je(t);return s?{value:s}:{value:e}}function Ze(e){if(e===null)return``;if(typeof e==`number`){let t=String(e);return qe(t)?e.toExponential():t}if(typeof e==`boolean`)return e?`TRUE`:`FALSE`;if(e instanceof C)return e.code;let t=Xe(e);return t.value===e&&t.formula===void 0?e:`'${e}`}function Qe(e){let t=h(`General`,e),n=[t];for(let r=10;r>=1;r--){let i=h(`General`,Number(e.toPrecision(r)));i.length<(n[n.length-1]??t).length&&n.push(i)}for(let r=5;r>=0;r--){let i=e.toExponential(r).replace(/e([+-])(\d)$/u,`E$10$2`).replace(/e/u,`E`);i.length<(n[n.length-1]??t).length&&n.push(i)}return n}function $e(e,t){let n=Qe(e);return t?n.find(t):n[0]}function et(e,t){if(e===null)return``;if(e instanceof C)return e.code;if(typeof e==`boolean`)return e?`TRUE`:`FALSE`;let n=t??`General`;if(typeof e==`string`)return t!==void 0&&ue(t)?h(t,e):e;if(n===`General`||!ue(n))return $e(e)??Ue(e);try{return h(n,e)}catch{return $e(e)??Ue(e)}}function tt(e,t){if(typeof e!=`number`||t===void 0||!ue(t))return;let n=g(t,e);return typeof n==`string`?n:void 0}var nt=e=>e!==void 0&&ue(e)&&te(e);function rt(e,t,n){let r=a(`heatmap`,t??{}),i=r.problems.filter(e=>!e.message.includes(`has values, or data`)).map(e=>`${e.path.length>0?`${e.path.join(`.`)}: `:``}${e.message}`),o=r.block?.fields??{},s=typeof o.data==`string`?o.data.trim():void 0,c=s===void 0?e:s.replace(/^=/u,``),l=oe(n??u),d=typeof o.color==`string`?o.color:`accent1`,f=e=>{let t=b(e,l);return/^#[0-9A-Fa-f]{6}$/u.test(t)?t.toUpperCase():`#4472C4`},p=typeof o.mid==`number`?o.mid:void 0,m=typeof o.low_color==`string`?o.low_color:p===void 0?void 0:`accent2`,h=e=>typeof o[e]==`number`?{at:`num`,value:o[e]}:{at:e};return{rule:{range:c,type:`colorScale`,stops:m===void 0?[{...h(`min`),color:f(`${d}~6`)},{...h(`max`),color:f(d)}]:[{...h(`min`),color:f(m)},{at:`num`,value:p??0,color:f(`ground`)},{...h(`max`),color:f(d)}]},problems:i}}var E=class{sheet;top;left;bottom;right;constructor(e,t,n,r,i){this.sheet=e,this.top=t,this.left=n,this.bottom=r,this.right=i}get rows(){return this.bottom-this.top+1}get cols(){return this.right-this.left+1}get single(){return this.top===this.bottom&&this.left===this.right}get key(){return`${String(this.sheet.index)}!${String(this.top)},${String(this.left)}:${String(this.bottom)},${String(this.right)}`}},it=class{parts;constructor(e){this.parts=e}},at=class{params;body;frame;named;constructor(e,t,n,r){this.params=e,this.body=t,this.frame=n,this.named=r}},D=class{missing=!0},ot=new D;function st(e,t){for(let n of t)e.push(n)}var ct=e=>`${e.abs?`$`:``}${Ce(e.index)}`,lt=e=>`${e.abs?`$`:``}${String(e.index+1)}`;function ut(e,t){let n=t===void 0?e:`${e}:${t}`;return/^[\p{L}_][\p{L}\p{N}_.]*$/u.test(e)&&!/^[A-Za-z]{1,3}\d+$/u.test(e)&&!/^(?:TRUE|FALSE)$/iu.test(e)&&(t===void 0||/^[\p{L}_][\p{L}\p{N}_.]*$/u.test(t))?`${n}!`:`'${n.replaceAll(`'`,`''`)}'!`}function dt(e){let t=e.sheet===void 0?``:ut(e.sheet,e.lastSheet);if(e.row===void 0&&e.col&&e.col2)return`${t}${ct(e.col)}:${ct(e.col2)}`;if(e.col===void 0&&e.row&&e.row2)return`${t}${lt(e.row)}:${lt(e.row2)}`;if(!e.col||!e.row)return`${t}#REF!`;let n=`${ct(e.col)}${lt(e.row)}`;return e.col2&&e.row2?`${t}${n}:${ct(e.col2)}${lt(e.row2)}`:`${t}${n}`}var ft=e=>e.replace(/([[\]#'@])/gu,`'$1`),pt=e=>/^[\p{L}\p{N}_]+$/u.test(e);function mt(e){let t=e.table??``,[n,r]=e.columns,i=e.columns.map(e=>`[${ft(e)}]`).join(`:`);if(e.sections.length===0)return e.thisRow?n===void 0?`${t}[@]`:r===void 0?`${t}[@${pt(n)?ft(n):i}]`:`${t}[@${i}]`:n===void 0?t===``?`[]`:t:r===void 0?`${t}[${ft(n)}]`:`${t}[${i}]`;if(n===void 0&&e.sections.length===1)return`${t}[${e.sections[0]??``}]`;let a=e.sections.map(e=>`[${e}]`);return i!==``&&a.push(i),`${t}[${a.join(`,`)}]`}function ht(e){let{before:t=``,after:n=``}=e.space??{};return`${t}${gt(e)}${n}`}function gt(e){let t=e.space?.inner??``;switch(e.kind){case`number`:return e.raw;case`string`:return`"${e.value.replaceAll(`"`,`""`)}"`;case`boolean`:return e.value?`TRUE`:`FALSE`;case`error`:return`${e.sheet===void 0?``:ut(e.sheet)}${e.code}`;case`missing`:return``;case`ref`:return dt(e);case`structured`:return mt(e);case`name`:return`${e.sheet===void 0?``:ut(e.sheet)}${e.name}`;case`unary`:return`${e.op}${ht(e.arg)}`;case`postfix`:return`${ht(e.arg)}${e.op}`;case`binary`:return`${ht(e.left)}${t}${e.op}${ht(e.right)}`;case`call`:return`${e.written}(${e.args.map(ht).join(`,`)}${t})`;case`invoke`:return`${ht(e.callee)}(${e.args.map(ht).join(`,`)}${t})`;case`array`:return`{${e.rows.map(e=>e.map(ht).join(`,`)).join(`;`)}}`;case`paren`:return`(${ht(e.arg)}${t})`}}var _t=e=>`=${ht(e)}`,vt={width:480,height:288,size:9,titleSize:14,ink:`#595959`,pixelsToPoints:.75};function yt(e,t,n){let{node:r}=n;if(!r)return[];let i=e.eval(r,{sheet:t,row:0,col:0,dr:0,dc:0}),a=t=>{let n=t.sheet,r=e.filtered(n),i=[],a=Math.min(t.bottom,n.lastRow),o=Math.min(t.right,n.columnsUsed-1);for(let s=t.top;s<=a;s++)if(!(r.has(s)||n.spec.rows?.[String(s+1)]?.hidden===!0))for(let r=t.left;r<=o;r++)n.spec.columns?.[Ce(r)]?.hidden!==!0&&i.push({value:e.value(n,s,r),sheet:n,row:s,col:r});return i};if(i instanceof E)return a(i);if(i instanceof it)return i.parts.flatMap(a);if(i instanceof T)return i.data.map(e=>({value:e}));let o=e.flat(i);return o instanceof T?o.data.map(e=>({value:e})):[{value:o}]}var bt=e=>{if(e.value===null)return``;let t=e.sheet&&e.row!==void 0&&e.col!==void 0?e.sheet.lookAt(e.row,e.col).format:void 0;return et(e.value,t)};function xt(e){return typeof e==`number`?Number.isFinite(e)?e:null:e===null||e instanceof C?null:typeof e==`boolean`?+!!e:0}var St=e=>e&&{...e.min===void 0?{}:{minimum_scale:e.min},...e.max===void 0?{}:{maximum_scale:e.max},...e.major===void 0?{}:{major_unit:e.major},...e.gridlines===void 0?{}:{has_major_gridlines:e.gridlines},...e.visible===void 0?{}:{visible:e.visible},...e.format===void 0?{}:{number_format:e.format},...e.reverse===void 0?{}:{reverse_order:e.reverse},...e.title===void 0||e.title===``?{}:{title:e.title}},Ct=e=>e===void 0?void 0:{rgb:e};function wt(e){if(e===void 0||e===!1)return;if(e===!0)return{show_value:!0};let t=typeof e.color==`string`?Ct(e.color):void 0;return{...e.value===void 0?{}:{show_value:e.value},...e.percentage===void 0?{}:{show_percentage:e.percentage},...e.category===void 0?{}:{show_category_name:e.category},...e.series===void 0?{}:{show_series_name:e.series},...e.format===void 0?{}:{number_format:e.format},...e.position===void 0?{}:{position:e.position},...e.size===void 0?{}:{size:e.size},...t?{color:t}:{}}}var Tt=e=>{let t=e.find(e=>e.sheet);return t?.sheet&&t.row!==void 0&&t.col!==void 0?t.sheet.lookAt(t.row,t.col).format:void 0};function Et(e,t,n){let r=kt(e,t,n);return n.gantt?Ot(e,t,n,r):r}var Dt=25569;function Ot(e,t,n,r){let[i,a,...o]=r.series;if(!i||!a)return r;let s=i.values.flatMap((e,t)=>{let n=a.values[t];return e===null?[]:[{start:e-Dt,end:e-Dt+(n??0)}]}),c=s.length===0?void 0:ae({kind:`gantt`,groups:[],tasks:s.map(e=>({...e,name:``,milestone:!1,depends:[]}))}),l=n.gantt?.group?yt(e,t,n.gantt.group).map(bt):[],u=[...new Set(l.filter(e=>e!==``))],d=[`accent1`,`accent2`,`accent3`,`accent4`,`accent5`,`accent6`],f=c===void 0||c.scale===`day`||c.scale===`week`;return{...r,series:[{...i,transparency:1,labels:null},{...a,...u.length>1?{point_colors:l.map(e=>e===``?null:d[u.indexOf(e)%d.length])}:{}},...o],value_axis:{...r.value_axis,...c===void 0?{}:{minimum_scale:c.lo+Dt,maximum_scale:c.hi+Dt},...c?.scale===`week`?{major_unit:7}:{},...c?.scale===`day`?{major_unit:1}:{},number_format:f?`d mmm`:`mmm yyyy`}}}function kt(e,t,n){let{spec:r}=n,i=ie(r.type),a=n.categories?yt(e,t,n.categories):void 0,o=n.series.map((n,o)=>{let s=r.series[o],c=yt(e,t,n.values),l=n.name?yt(e,t,n.name)[0]:void 0,u=n.x?yt(e,t,n.x):i?a:void 0,d=s.format??Tt(c),f=Ct(s.color);return{name:(l?bt(l):s.name)??`Series${String(o+1)}`,values:c.map(e=>xt(e.value)),...u?{x:u.map(e=>xt(e.value))}:{},...n.sizes?{sizes:yt(e,t,n.sizes).map(e=>xt(e.value))}:{},...d===void 0?{}:{number_format:d},...f?{color:f}:{},...s.smooth===void 0?{}:{smooth:s.smooth},...s.line_width===void 0?{}:{line_width:s.line_width},...s.marker_size===void 0?{}:{marker_size:s.marker_size},...s.type===void 0?{}:{type:s.type},...s.secondary===!0?{secondary:!0}:{}}}),s=Math.max(0,...o.map(e=>e.values.length)),c=new Set(a?.map(e=>e.col)),l=a&&_(r.type)&&c.size>1?[...new Set(a.map(e=>e.row))].map(e=>a.filter(t=>t.row===e).map(bt)):void 0,u=l?l.map(e=>[...e].reverse().find(e=>e!==``)??``):a?a.map(bt):v(r.type)?Array.from({length:s},(e,t)=>String(t+1)):[],d=(r.totals??[]).flatMap(e=>{let t=u.indexOf(e);return t<0?[]:[t]}),f=re(r.type),p=n.title?yt(e,t,n.title)[0]:void 0,m=p?bt(p):r.title,h=wt(r.labels),g=St(r.value_axis),ee=St(r.category_axis),te=St(r.secondary_axis);return{type:r.type,categories:u,series:o,...m===void 0||m===``?{}:{title:m},...r.legend===void 0||r.legend===`none`?{}:{legend:r.legend},...h?{labels:h}:{},...r.gap_width===void 0?{}:{gap_width:r.gap_width},...r.overlap===void 0?{}:{overlap:r.overlap},...r.vary_by_categories===void 0?{}:{vary_by_categories:r.vary_by_categories},...r.hole_size===void 0?{}:{hole_size:r.hole_size},...g?{value_axis:g}:{},...ee?{category_axis:ee}:{},...te?{secondary_axis:te}:{},...d.length===0?{}:{totals:d},...r.connector_lines===void 0?{}:{connector_lines:r.connector_lines},...r.quartiles===void 0?{}:{quartile_method:r.quartiles},...r.mean_markers===void 0?{}:{show_mean_markers:r.mean_markers},...r.mean_line===void 0?{}:{show_mean_line:r.mean_line},...r.outliers===void 0?{}:{show_outliers:r.outliers},...r.inner_points===void 0?{}:{show_inner_points:r.inner_points},...r.bin_count===void 0?{}:{bin_count:r.bin_count},...r.bin_width===void 0?{}:{bin_width:r.bin_width},...r.overflow===void 0?{}:{overflow:r.overflow},...r.underflow===void 0?{}:{underflow:r.underflow},...r.interval_closed===void 0?{}:{interval_closed:r.interval_closed},...l?{category_levels:l}:{},...r.high_low_lines===void 0?{}:{high_low_lines:r.high_low_lines},...r.secondary_gap_width===void 0?{}:{secondary_gap_width:r.secondary_gap_width},...r.orientation===void 0?{}:{orientation:r.orientation},...r.parent_labels===void 0?{}:{parent_labels:r.parent_labels},...r.labels===void 0&&f?{labels:f}:{},font_size:r.size??vt.size,title_size:r.title_size??vt.titleSize,font_color:Ct(r.color)??{rgb:vt.ink}}}var At=e=>({width:e.width??vt.width,height:e.height??vt.height}),jt=(e,t,n,r={})=>le(e,t,n,{pointsPerPixel:vt.pixelsToPoints,...r});function Mt(e,t){let n=e=>e?.startsWith(`=`)===!0?t(e):e,r=n(e.title);return{...e,...r===void 0?{}:{title:r},...e.categories===void 0?{}:{categories:t(e.categories)},series:e.series.map(e=>{let r=n(e.name);return{...e,values:t(e.values),...e.x===void 0?{}:{x:t(e.x)},...e.sizes===void 0?{}:{sizes:t(e.sizes)},...r===void 0?{}:{name:r}}})}}function Nt(e,t,n,r){if(r){let e=r.data;if(n.top===e.top&&n.bottom===e.bottom&&n.left===n.right){let e=r.columns[n.left-r.at.col];if(e)return`${r.name}[${e.name}]`}}return`${t===e?``:ut(t.name)}${Ee(n)}`}var Pt=(e,t,n,r)=>typeof e.value(t,n,r)==`number`,Ft=(e,t,n,r)=>{let i=e.value(t,n,r);if(typeof i==`string`)return!0;let a=t.lookAt(n,r).format;return typeof i==`number`&&a!==void 0&&/[ymd]/iu.test(a)};function It(e,t,n,r,i){let a=r.bottom-r.top+1,o=r.right-r.left+1,s=t.tables.find(e=>ke(e.area,r.top,r.left)),c=e=>Nt(n,t,e,s),l=ie(i),u=a>1&&Array.from({length:o},(e,t)=>r.left+t).some(n=>!Pt(e,t,r.top,n)),d=o>1&&(l||Array.from({length:a-+!!u},(e,t)=>t).every(n=>Ft(e,t,r.top+ +!!u+n,r.left)||e.value(t,r.top+ +!!u+n,r.left)===null)),f=r.top+ +!!u,p=r.left+ +!!d;if(f>r.bottom||p>r.right)return;let m=!l&&!ee(i)&&r.right-p>r.bottom-f,h=[],g=(r,i)=>e.value(t,r,i)===null?void 0:`=${t===n?``:ut(t.name)}${Te({row:r,col:i})}`,_=m?{first:f,last:r.bottom}:{first:p,last:r.right};for(let e=_.first;e<=_.last;e++){let t=m?{top:e,left:p,bottom:e,right:r.right}:{top:f,left:e,bottom:r.bottom,right:e},n=m?d?g(e,r.left):void 0:u?g(r.top,e):void 0;h.push({values:c(t),...n===void 0?{}:{name:n}})}let v=m?u?{top:r.top,left:p,bottom:r.top,right:r.right}:void 0:d?{top:f,left:r.left,bottom:r.bottom,right:r.left}:void 0,te=h.length>1&&!ee(i),y=ee(i)?h.slice(0,1):h,b=y.length===1?y[0]?.name:void 0;return{type:i,...v?{categories:c(v)}:{},series:y,...te||ee(i)?{legend:`bottom`}:{},...b===void 0?{}:{title:b}}}function Lt(e,t,n){if(!n?.node)return;let r=e.eval(n.node,{sheet:t,row:0,col:0,dr:0,dc:0});return r instanceof E?{sheet:r.sheet,area:{top:r.top,left:r.left,bottom:Math.min(r.bottom,Math.max(r.top,r.sheet.lastRow)),right:r.right}}:void 0}function Rt(e,t,n){let r=[Lt(e,t,n.categories),...n.series.flatMap(n=>[Lt(e,t,n.values),Lt(e,t,n.name),Lt(e,t,n.x)])].filter(e=>e!==void 0),i=r[0];if(!i||r.some(e=>e.sheet!==i.sheet))return;let a={top:Math.min(...r.map(e=>e.area.top)),left:Math.min(...r.map(e=>e.area.left)),bottom:Math.max(...r.map(e=>e.area.bottom)),right:Math.max(...r.map(e=>e.area.right))};return`${i.sheet===t?``:ut(i.sheet.name)}${Ee(a)}`}function zt(e,t,n){let r=n.lastIndexOf(`!`),i=r<0?void 0:n.slice(0,r).replace(/^'|'$/gu,``),a=i===void 0?t:e.wb.sheet(i.replaceAll(`''`,`'`)),o=x(n.slice(r+1).replaceAll(`$`,``));return a&&o?{sheet:a,area:o}:void 0}function Bt(e){let t=e.lastIndexOf(`!`),n=t<0?void 0:e.slice(0,t),r=n===void 0?void 0:/^'.*'$/u.test(n)?n.slice(1,-1).replaceAll(`''`,`'`):n,i=x((t<0?e:e.slice(t+1)).replace(/\$/gu,``));return i===void 0?void 0:{...r===void 0?{}:{sheet:r},area:i}}function Vt(e,t){let n=x(t.at.replace(/\$/gu,``)),r=Bt(t.data.replace(/^=/u,``));if(n===void 0)return{problem:`${t.at} is not a cell or a range of cells`};if(r===void 0)return{problem:`${t.data} is not a range`};let i=ut(r.sheet??e),a=r.area,o=a.bottom-a.top+1,s=a.right-a.left+1,c=[],l=[];for(let e=n.top;e<=n.bottom;e++)for(let t=n.left;t<=n.right;t++)l.push({row:e,col:t});if(l.length===1){let e=l[0];return e===void 0?{problem:`${t.at} is no cell`}:o>1&&s>1?{problem:`one cell draws a row or a column of values, not ${t.data}; for a block of rows, at is a column of cells, one a row`}:{cells:[{...e,data:i+Ee(a)}]}}let u=n.left===n.right,d=n.top===n.bottom;if(u&&l.length===o)l.forEach((e,t)=>{c.push({...e,data:i+Ee({...a,top:a.top+t,bottom:a.top+t})})});else if(d&&l.length===s)l.forEach((e,t)=>{c.push({...e,data:i+Ee({...a,left:a.left+t,right:a.left+t})})});else return{problem:`${t.at} has ${String(l.length)} cells, and ${t.data} ${String(o)} rows and ${String(s)} columns: a column of cells draws a row of the data each, a row of cells a column each`};return{cells:c}}var Ht=e=>String(Math.round(e*100)/100);function Ut(e,t,n,r,i){let a=e.map(e=>e??NaN),o=a.filter(e=>Number.isFinite(e));if(o.length===0)return``;let s=t.type??`line`,c=Math.min(...o)<0&&Math.max(...o)>0,l=c?Math.min(...o,0):Math.min(...o),u=(c?Math.max(...o,0):Math.max(...o))-l||1,d=e=>2+(r-4)*(1-(e-l)/u),f=a.length,p=a.indexOf(Math.max(...o)),m=a.indexOf(Math.min(...o)),h=a.findIndex(e=>Number.isFinite(e)),g=a.length-1-[...a].reverse().findIndex(e=>Number.isFinite(e)),_=e=>t.high===!0&&e===p||t.low===!0&&e===m||t.first===!0&&e===h||t.last===!0&&e===g||t.negative===!0&&(a[e]??0)<0,v=[];if(s===`line`){let e=e=>2+(n-4)*e/Math.max(1,f-1),r=``,o=!1;a.forEach((t,n)=>{Number.isFinite(t)?(r+=`${o?`L`:`M`}${Ht(e(n))} ${Ht(d(t))}`,o=!0):o=!1}),v.push(`<path d="${r}" fill="none" stroke="${i.series}" stroke-width="1.5" stroke-linejoin="round" stroke-linecap="round" vector-effect="non-scaling-stroke"/>`),a.forEach((n,r)=>{Number.isFinite(n)&&(t.markers===!0||_(r))&&v.push(`<circle cx="${Ht(e(r))}" cy="${Ht(d(n))}" r="2" fill="${_(r)?i.marks:i.series}"/>`)})}else{let e=(n-4)/Math.max(1,f),o=e*.7,l=s===`win_loss`?r/2:c?d(0):r-2;a.forEach((n,a)=>{if(!Number.isFinite(n)||s===`win_loss`&&n===0)return;let c=2+e*a+(e-o)/2,u=s===`win_loss`?n>0?2:r/2:Math.min(d(n),l),f=s===`win_loss`?r/2-2:Math.max(1,Math.abs(d(n)-l)),p=_(a)||t.negative===!0&&n<0?i.marks:i.series;v.push(`<rect x="${Ht(c)}" y="${Ht(u)}" width="${Ht(o)}" height="${Ht(f)}" fill="${p}"/>`)})}return`<svg xmlns="http://www.w3.org/2000/svg" width="${Ht(n)}" height="${Ht(r)}" viewBox="0 0 ${Ht(n)} ${Ht(r)}" preserveAspectRatio="none">${v.join(``)}</svg>`}function Wt(e){let t=new Map;for(let n of e.sparklines)for(let e of n.cells)t.set(`${String(e.row)},${String(e.col)}`,{group:n,data:e.data});return t}function Gt(e,t,n,r,i,a){let o=Ut(e,t,i,a,{series:`S`,marks:`M`}),s=[],c=[],l=[];for(let e of o.matchAll(/<path d="([^"]*)"/gu))for(let t of(e[1]??``).split(`M`).filter(Boolean))l.push(t.split(`L`).map(e=>{let[t=`0`,i=`0`]=e.trim().split(` `);return{x:n+Number(t),y:r+Number(i)}}));for(let e of o.matchAll(/<circle cx="([^"]*)" cy="([^"]*)" r="[^"]*" fill="(S|M)"/gu))s.push({x:n+Number(e[1]),y:r+Number(e[2]),marked:e[3]===`M`});for(let e of o.matchAll(/<rect x="([^"]*)" y="([^"]*)" width="([^"]*)" height="([^"]*)" fill="(S|M)"/gu))c.push({x:n+Number(e[1]),y:r+Number(e[2]),w:Number(e[3]),h:Number(e[4]),marked:e[5]===`M`});return{...l.length>0?{line:l}:{},dots:s,bars:c}}var O=Symbol(`NOT_RESOLVED`);function Kt(e,t){return{tagName:e,nodeKind:`scalar`,implicit:t.implicit??!1,matchByTagPrefix:t.matchByTagPrefix??!1,implicitFirstChars:t.implicitFirstChars??null,resolve:t.resolve,identify:t.identify,represent:t.represent??(e=>String(e)),representTagName:t.representTagName??(()=>e)}}function qt(e,t){let n=t.finalize===void 0;return{tagName:e,nodeKind:`sequence`,implicit:!1,matchByTagPrefix:t.matchByTagPrefix??!1,create:t.create,addItem:t.addItem,finalize:t.finalize??(e=>e),carrierIsResult:n,identify:t.identify,represent:t.represent??(e=>e),representTagName:t.representTagName??(()=>e)}}function Jt(e,t){let n=t.finalize===void 0;return{tagName:e,nodeKind:`mapping`,implicit:!1,matchByTagPrefix:t.matchByTagPrefix??!1,create:t.create,addPair:t.addPair,has:t.has,keys:t.keys,get:t.get,finalize:t.finalize??(e=>e),carrierIsResult:n,identify:t.identify,represent:t.represent??(e=>e),representTagName:t.representTagName??(()=>e)}}var Yt=Kt(`tag:yaml.org,2002:str`,{resolve:e=>e,identify:e=>typeof e==`string`}),Xt=[``,`~`,`null`,`Null`,`NULL`],Zt=Kt(`tag:yaml.org,2002:null`,{implicit:!0,implicitFirstChars:[``,`~`,`n`,`N`],resolve:e=>Xt.indexOf(e)===-1?O:null,identify:e=>e===null,represent:()=>`null`}),Qt=Kt(`tag:yaml.org,2002:null`,{implicit:!0,implicitFirstChars:[`n`],resolve:(e,t)=>e===`null`||t&&e===``?null:O,identify:e=>e===null,represent:()=>`null`}),$t=[``,`~`,`null`,`Null`,`NULL`],en=Kt(`tag:yaml.org,2002:null`,{implicit:!0,implicitFirstChars:[``,`~`,`n`,`N`],resolve:e=>$t.indexOf(e)===-1?O:null,identify:e=>e===null,represent:()=>`null`}),tn=[`true`,`True`,`TRUE`],nn=[`false`,`False`,`FALSE`],rn=Kt(`tag:yaml.org,2002:bool`,{implicit:!0,implicitFirstChars:[`t`,`T`,`f`,`F`],resolve:e=>tn.indexOf(e)!==-1||nn.indexOf(e)===-1&&O,identify:e=>Object.prototype.toString.call(e)===`[object Boolean]`,represent:e=>e?`true`:`false`}),an=[`true`],on=[`false`],sn=Kt(`tag:yaml.org,2002:bool`,{implicit:!0,implicitFirstChars:[`t`,`f`],resolve:e=>an.indexOf(e)!==-1||on.indexOf(e)===-1&&O,identify:e=>Object.prototype.toString.call(e)===`[object Boolean]`,represent:e=>e?`true`:`false`}),cn=[`true`,`True`,`TRUE`,`y`,`Y`,`yes`,`Yes`,`YES`,`on`,`On`,`ON`],ln=[`false`,`False`,`FALSE`,`n`,`N`,`no`,`No`,`NO`,`off`,`Off`,`OFF`],un=Kt(`tag:yaml.org,2002:bool`,{implicit:!0,implicitFirstChars:[`y`,`Y`,`n`,`N`,`t`,`T`,`f`,`F`,`o`,`O`],resolve:e=>cn.indexOf(e)!==-1||ln.indexOf(e)===-1&&O,identify:e=>Object.prototype.toString.call(e)===`[object Boolean]`,represent:e=>e?`true`:`false`}),dn=RegExp(`^(?:0o[0-7]+|0x[0-9a-fA-F]+|[-+]?[0-9]+)$`),fn=RegExp(`^(?:[-+]?0b[0-1]+|[-+]?0o[0-7]+|[-+]?0x[0-9a-fA-F]+|[-+]?[0-9]+)$`);function pn(e){let t=e,n=1;return(t[0]===`-`||t[0]===`+`)&&(t[0]===`-`&&(n=-1),t=t.slice(1)),t.startsWith(`0b`)?n*parseInt(t.slice(2),2):t.startsWith(`0o`)?n*parseInt(t.slice(2),8):t.startsWith(`0x`)?n*parseInt(t.slice(2),16):n*parseInt(t,10)}function mn(e,t){if(t){if(!fn.test(e))return O}else if(!dn.test(e))return O;let n=pn(e);return Number.isFinite(n)?n:O}var hn=Kt(`tag:yaml.org,2002:int`,{implicit:!0,implicitFirstChars:[`-`,`+`,...`0123456789`],resolve:mn,identify:e=>Number.isInteger(e)&&!Object.is(e,-0)&&e.toString(10).indexOf(`e`)<0,represent:e=>e.toString(10)}),gn=RegExp(`^-?(?:0|[1-9][0-9]*)$`),_n=RegExp(`^(?:[-+]?0b[0-1]+|[-+]?0o[0-7]+|[-+]?0x[0-9a-fA-F]+|[-+]?[0-9]+)$`);function vn(e){let t=e,n=1;return(t[0]===`-`||t[0]===`+`)&&(t[0]===`-`&&(n=-1),t=t.slice(1)),t.startsWith(`0b`)?n*parseInt(t.slice(2),2):t.startsWith(`0o`)?n*parseInt(t.slice(2),8):t.startsWith(`0x`)?n*parseInt(t.slice(2),16):n*parseInt(t,10)}function yn(e,t){if(t){if(!_n.test(e))return O}else if(!gn.test(e))return O;let n=vn(e);return Number.isFinite(n)?n:O}var bn=Kt(`tag:yaml.org,2002:int`,{implicit:!0,implicitFirstChars:[`-`,...`0123456789`],resolve:yn,identify:e=>Number.isInteger(e)&&!Object.is(e,-0)&&e.toString(10).indexOf(`e`)<0,represent:e=>e.toString(10)}),xn=RegExp(`^(?:[-+]?0b[0-1_]+|[-+]?0[0-7_]+|[-+]?0x[0-9a-fA-F_]+|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+|[-+]?(?:0|[1-9][0-9_]*))$`);function Sn(e){let t=e.replace(/_/g,``),n=1;if((t[0]===`-`||t[0]===`+`)&&(t[0]===`-`&&(n=-1),t=t.slice(1)),t.startsWith(`0b`))return n*parseInt(t.slice(2),2);if(t.startsWith(`0x`))return n*parseInt(t.slice(2),16);if(t.includes(`:`)){let e=0;for(let n of t.split(`:`))e=e*60+Number(n);return n*e}return t!==`0`&&t[0]===`0`?n*parseInt(t,8):n*parseInt(t,10)}function Cn(e){if(!xn.test(e))return O;let t=Sn(e);return Number.isFinite(t)?t:O}var wn=Kt(`tag:yaml.org,2002:int`,{implicit:!0,implicitFirstChars:[`-`,`+`,...`0123456789`],resolve:Cn,identify:e=>Number.isInteger(e)&&!Object.is(e,-0)&&e.toString(10).indexOf(`e`)<0,represent:e=>e.toString(10)}),Tn=RegExp(`^(?:[-+]?[0-9]+(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|[-+]?\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$`),En=RegExp(`^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$`);function Dn(e){if(!Tn.test(e))return O;let t=e.toLowerCase(),n=t[0]===`-`?-1:1;if(`+-`.includes(t[0])&&(t=t.slice(1)),t===`.inf`)return n===1?1/0:-1/0;if(t===`.nan`)return NaN;let r=n*parseFloat(t);return Number.isFinite(r)||En.test(e)?r:O}function On(e){if(isNaN(e))return`.nan`;if(e===1/0)return`.inf`;if(e===-1/0)return`-.inf`;if(Object.is(e,-0))return`-0.0`;let t=e.toString(10);return/^[-+]?[0-9]+e/.test(t)?t.replace(`e`,`.e`):t}var kn=Kt(`tag:yaml.org,2002:float`,{implicit:!0,implicitFirstChars:[`-`,`+`,`.`,...`0123456789`],resolve:Dn,identify:e=>typeof e==`number`&&(!Number.isInteger(e)||Object.is(e,-0)||e.toString(10).indexOf(`e`)>=0),represent:On}),An=RegExp(`^-?(?:0|[1-9][0-9]*)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$`),jn=RegExp(`^(?:[-+]?[0-9]+(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|[-+]?\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$`);function Mn(e,t){if(t){if(!jn.test(e))return O;let t=e.toLowerCase(),n=t[0]===`-`?-1:1;if(`+-`.includes(t[0])&&(t=t.slice(1)),t===`.inf`)return n===1?1/0:-1/0;if(t===`.nan`)return NaN;let r=n*parseFloat(t);return Number.isFinite(r)?r:O}if(!An.test(e))return O;let n=Number(e);return Number.isFinite(n)?n:O}function Nn(e){if(isNaN(e))return`.nan`;if(e===1/0)return`.inf`;if(e===-1/0)return`-.inf`;if(Object.is(e,-0))return`-0.0`;let t=e.toString(10);return/^[-+]?[0-9]+e/.test(t)?t.replace(`e`,`.e`):t}var Pn=Kt(`tag:yaml.org,2002:float`,{implicit:!0,implicitFirstChars:[`-`,...`0123456789`],resolve:Mn,identify:e=>typeof e==`number`&&(!Number.isInteger(e)||Object.is(e,-0)||e.toString(10).indexOf(`e`)>=0),represent:Nn}),Fn=RegExp(`^(?:[-+]?(?:(?:[0-9][0-9_]*)?\\.[0-9_]*)(?:[eE][-+][0-9]+)?|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$`),In=RegExp(`^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$`);function Ln(e){if(!Fn.test(e))return O;let t=e.toLowerCase().replace(/_/g,``),n=t[0]===`-`?-1:1;if(`+-`.includes(t[0])&&(t=t.slice(1)),t===`.inf`)return n===1?1/0:-1/0;if(t===`.nan`)return NaN;let r=0;if(t.includes(`:`)){for(let e of t.split(`:`))r=r*60+Number(e);r*=n}else r=n*parseFloat(t);return Number.isFinite(r)||In.test(e)?r:O}function Rn(e){if(isNaN(e))return`.nan`;if(e===1/0)return`.inf`;if(e===-1/0)return`-.inf`;if(Object.is(e,-0))return`-0.0`;let t=e.toString(10);return/^[-+]?[0-9]+e/.test(t)?t.replace(`e`,`.e`):t}var zn=Kt(`tag:yaml.org,2002:float`,{implicit:!0,implicitFirstChars:[`-`,`+`,`.`,...`0123456789`],resolve:Ln,identify:e=>typeof e==`number`&&(!Number.isInteger(e)||Object.is(e,-0)||e.toString(10).indexOf(`e`)>=0),represent:Rn}),Bn=Kt(`tag:yaml.org,2002:merge`,{implicit:!0,implicitFirstChars:[`<`],resolve:(e,t)=>e===`<<`||t&&e===``?`<<`:O,identify:()=>!1}),Vn=/^[A-Za-z0-9+/]*={0,2}$/;function Hn(e){let t=e.replace(/\s/g,``);if(t.length%4!=0||!Vn.test(t))return O;let n=atob(t),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return r}function Un(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}var Wn=Kt(`tag:yaml.org,2002:binary`,{resolve:Hn,identify:e=>Object.prototype.toString.call(e)===`[object Uint8Array]`,represent:Un}),Gn=RegExp(`^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$`),Kn=RegExp(`^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$`);function qn(e,t,n,r=0,i=0,a=0,o=0){let s=new Date(Date.UTC(e,t,n,r,i,a,o));return s.setUTCFullYear(e,t,n),s}function Jn(e){let t=Gn.exec(e);if(t===null&&(t=Kn.exec(e)),t===null)return O;let n=+t[1],r=t[2]-1,i=+t[3];if(!t[4]){let e=qn(n,r,i);return e.getUTCFullYear()!==n||e.getUTCMonth()!==r||e.getUTCDate()!==i?O:e}let a=+t[4],o=+t[5],s=+t[6],c=0;if(a>23||o>59||s>59)return O;if(t[7]){let e=t[7].slice(0,3);for(;e.length<3;)e+=`0`;c=+e}let l=qn(n,r,i,a,o,s,c);if(l.getUTCFullYear()!==n||l.getUTCMonth()!==r||l.getUTCDate()!==i)return O;if(t[9]){let e=+t[10],n=+(t[11]||0);if(e>23||n>59)return O;let r=(e*60+n)*6e4;l.setTime(l.getTime()-(t[9]===`-`?-r:r))}return l}var Yn=Kt(`tag:yaml.org,2002:timestamp`,{implicit:!0,implicitFirstChars:[...`0123456789`],resolve:Jn,identify:e=>e instanceof Date,represent:e=>e.toISOString()}),Xn=qt(`tag:yaml.org,2002:seq`,{create:()=>[],addItem:(e,t)=>{e.push(t)},identify:Array.isArray});function Zn(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===null||t===Object.prototype}function Qn(e,t){let n={};for(let r of t)e[r]!==void 0&&(n[r]=e[r]);return n}var $n=qt(`tag:yaml.org,2002:omap`,{create:()=>({list:[],seen:new Set}),addItem:(e,t)=>{let n;if(t instanceof Map){if(t.size!==1)return`cannot resolve an ordered map item`;n=t.keys().next().value}else if(Zn(t)){let e=Object.keys(t);if(e.length!==1)return`cannot resolve an ordered map item`;n=e[0]}else return`cannot resolve an ordered map item`;return e.seen.has(n)?`duplicate key in ordered map`:(e.seen.add(n),e.list.push(t),``)},finalize:e=>e.list,identify:()=>!1}),er=qt(`tag:yaml.org,2002:pairs`,{create:()=>[],addItem:(e,t)=>{if(t instanceof Map)return t.size===1?(e.push(t.entries().next().value),``):`cannot resolve a pairs item`;if(Object.prototype.toString.call(t)!==`[object Object]`)return`cannot resolve a pairs item`;let n=t,r=Object.keys(n);return r.length===1?(e.push([r[0],n[r[0]]]),``):`cannot resolve a pairs item`},identify:()=>!1}),tr=Jt(`tag:yaml.org,2002:map`,{create:()=>({}),identify:Zn,represent:e=>{let t=new Map;for(let n of Object.keys(e))t.set(n,e[n]);return t},addPair:(e,t,n)=>{if(typeof t==`object`&&t)return`object-based map does not support complex keys`;let r=String(t);return r===`__proto__`?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,``},has:(e,t)=>typeof t==`object`&&t?!1:Object.prototype.hasOwnProperty.call(e,String(t)),keys:e=>Object.keys(e),get:(e,t)=>{let n=String(t);return Object.prototype.hasOwnProperty.call(e,n)?e[n]:null}}),nr=Jt(`tag:yaml.org,2002:set`,{create:()=>new Set,identify:e=>e instanceof Set,represent:e=>{let t=new Map;for(let n of e)t.set(n,null);return t},addPair:(e,t,n)=>n===null?(e.add(t),``):`cannot resolve a set item`,has:(e,t)=>e.has(t),keys:e=>e.keys(),get:()=>null});function rr(){return{scalar:Object.create(null),sequence:Object.create(null),mapping:Object.create(null)}}function ir(){return{scalar:[],sequence:[],mapping:[]}}function ar(e){let t=[];for(let n of e){let e=t.length;for(let r=0;r<t.length;r++){let i=t[r];if(i.nodeKind===n.nodeKind&&i.tagName===n.tagName&&i.matchByTagPrefix===n.matchByTagPrefix){e=r;break}}t[e]=n}return t}var or=class e{tags;implicitScalarTags;implicitScalarByFirstChar;implicitScalarAnyFirstChar;defaultScalarTag;defaultSequenceTag;defaultMappingTag;exact;prefix;constructor(e){let t=ar(e),n=[],r=rr(),i=ir();for(let e of t){if(e.nodeKind===`scalar`&&e.implicit){if(e.matchByTagPrefix)throw Error(`Implicit scalar tags cannot match by tag prefix`);n.push(e)}switch(e.nodeKind){case`scalar`:e.matchByTagPrefix?i.scalar.push(e):r.scalar[e.tagName]=e;break;case`sequence`:e.matchByTagPrefix?i.sequence.push(e):r.sequence[e.tagName]=e;break;case`mapping`:e.matchByTagPrefix?i.mapping.push(e):r.mapping[e.tagName]=e}}let a=n.filter(e=>e.implicitFirstChars===null),o=new Set;for(let e of n)if(e.implicitFirstChars!==null)for(let t of e.implicitFirstChars)o.add(t);let s=new Map;for(let e of o)s.set(e,n.filter(t=>t.implicitFirstChars===null||t.implicitFirstChars.indexOf(e)!==-1));let c=r.scalar[`tag:yaml.org,2002:str`];if(!c)throw Error(`schema does not define the default scalar tag (tag:yaml.org,2002:str)`);this.tags=t,this.implicitScalarTags=n,this.implicitScalarByFirstChar=s,this.implicitScalarAnyFirstChar=a,this.defaultScalarTag=c,this.defaultSequenceTag=r.sequence[`tag:yaml.org,2002:seq`],this.defaultMappingTag=r.mapping[`tag:yaml.org,2002:map`],this.exact=r,this.prefix=i}lookupScalarTag(e){let t=this.exact.scalar[e];if(t)return t;for(let t of this.prefix.scalar)if(e.startsWith(t.tagName))return t}lookupSequenceTag(e){let t=this.exact.sequence[e];if(t)return t;for(let t of this.prefix.sequence)if(e.startsWith(t.tagName))return t}lookupMappingTag(e){let t=this.exact.mapping[e];if(t)return t;for(let t of this.prefix.mapping)if(e.startsWith(t.tagName))return t}resolveImplicitScalarTag(e){let t=this.implicitScalarByFirstChar.get(e.charAt(0))??this.implicitScalarAnyFirstChar;for(let n of t){let t=n.resolve(e,!1,n.tagName);if(t!==O)return{value:t,tag:n}}let n=this.defaultScalarTag;return{value:n.resolve(e,!1,n.tagName),tag:n}}withTags(...t){let n=[];for(let e of t)n=n.concat(e);return new e([...this.tags,...n])}},sr=new or([Yt,Xn,tr]);new or([...sr.tags,Qt,sn,bn,Pn]);var cr=new or([...sr.tags,Zt,rn,hn,kn]);new or([...sr.tags,en,un,wn,zn,Yn,Bn,Wn,$n,er,nr]).withTags({...wn,resolve:(e,t,n)=>{let r=wn.resolve(e,t,n);return r===O?hn.resolve(e,t,n):r}},{...zn,resolve:(e,t,n)=>{let r=zn.resolve(e,t,n);return r===O?kn.resolve(e,t,n):r}}),Jt(`tag:yaml.org,2002:map`,{create:()=>new Map,addPair:(e,t,n)=>(e.set(t,n),``),has:(e,t)=>e.has(t),keys:e=>e.keys(),get:(e,t)=>e.get(t),identify:e=>e instanceof Map||Zn(e),represent:e=>{if(e instanceof Map)return e;let t=new Map,n=e;for(let e of Object.keys(n))t.set(e,n[e]);return t}});function lr(e){if(Array.isArray(e)){let t=Array.prototype.slice.call(e);for(let e=0;e<t.length;e++){if(Array.isArray(t[e]))return null;typeof t[e]==`object`&&Object.prototype.toString.call(t[e])===`[object Object]`&&(t[e]=`[object Object]`)}return String(t)}return typeof e==`object`&&Object.prototype.toString.call(e)===`[object Object]`?`[object Object]`:String(e)}Jt(`tag:yaml.org,2002:map`,{create:()=>({}),identify:Zn,represent:e=>{let t=new Map;for(let n of Object.keys(e))t.set(n,e[n]);return t},addPair:(e,t,n)=>{let r=lr(t);return r===null?`nested arrays are not supported inside keys`:(r===`__proto__`?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,``)},has:(e,t)=>{let n=lr(t);return n!==null&&Object.prototype.hasOwnProperty.call(e,n)},keys:e=>Object.keys(e),get:(e,t)=>{let n=String(t);return Object.prototype.hasOwnProperty.call(e,n)?e[n]:null}});var ur={maxLength:79,indent:1,linesBefore:3,linesAfter:2};function dr(e,t,n,r,i){let a=``,o=``,s=Math.floor(i/2)-1;return r-t>s&&(a=` ... `,t=r-s+a.length),n-r>s&&(o=` ...`,n=r+s-o.length),{str:a+e.slice(t,n).replace(/\t/g,`→`)+o,pos:r-t+a.length}}function fr(e,t){return` `.repeat(Math.max(t-e.length,0))+e}function pr(e,t){if(!e.buffer)return null;let n={...ur,...t},r=/\r?\n|\r|\0/g,i=[0],a=[],o,s=-1;for(;o=r.exec(e.buffer);)a.push(o.index),i.push(o.index+o[0].length),e.position<=o.index&&s<0&&(s=i.length-2);s<0&&(s=i.length-1);let c=``,l=Math.min(e.line+n.linesAfter,a.length).toString().length,u=n.maxLength-(n.indent+l+3);for(let t=1;t<=n.linesBefore&&!(s-t<0);t++){let r=dr(e.buffer,i[s-t],a[s-t],e.position-(i[s]-i[s-t]),u);c=`${` `.repeat(n.indent)}${fr((e.line-t+1).toString(),l)} | ${r.str}\n${c}`}let d=dr(e.buffer,i[s],a[s],e.position,u);c+=`${` `.repeat(n.indent)}${fr((e.line+1).toString(),l)} | ${d.str}\n`,c+=`${`-`.repeat(n.indent+l+3+d.pos)}^\n`;for(let t=1;t<=n.linesAfter&&!(s+t>=a.length);t++){let r=dr(e.buffer,i[s+t],a[s+t],e.position-(i[s]-i[s+t]),u);c+=`${` `.repeat(n.indent)}${fr((e.line+t+1).toString(),l)} | ${r.str}\n`}return c.replace(/\n$/,``)}function mr(e,t){let n=``;return e.mark?(e.mark.name&&(n+=`in "${e.mark.name}" `),n+=`(${e.mark.line+1}:${e.mark.column+1})`,!t&&e.mark.snippet&&(n+=`\n\n${e.mark.snippet}`),`${e.reason} ${n}`):e.reason}var hr=class e extends Error{reason;mark;constructor(e,t){super(),this.name=`YAMLException`,this.reason=e,this.mark=t,this.message=mr(this,!1),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}toString(e){return`${this.name}: ${mr(this,e)}`}static throwAt(t,n,r,i=``){let a=0,o=0;for(let e=0;e<n;e++){let n=t.charCodeAt(e);n===10?(a++,o=e+1):n===13&&(a++,t.charCodeAt(e+1)===10&&e++,o=e+1)}let s={name:i,buffer:t,position:n,line:a,column:n-o};throw s.snippet=pr(s),new e(r,s)}},gr={DOCUMENT:1,SEQUENCE:2,MAPPING:3,SCALAR:4,ALIAS:5,POP:6},k={PLAIN:1,SINGLE_QUOTED:2,DOUBLE_QUOTED:3,LITERAL_BLOCK:4,FOLDED_BLOCK:5},_r={BLOCK:1,FLOW:2},vr={CLIP:1,STRIP:2,KEEP:3},yr=-1;function br(e){switch(e){case 48:return`\0`;case 97:return`\x07`;case 98:return`\b`;case 116:return` `;case 9:return` `;case 110:return`
|
|
2
|
-
`;case 118:return`\v`;case 102:return`\f`;case 114:return`\r`;case 101:return`\x1B`;case 32:return` `;case 34:return`"`;case 47:return`/`;case 92:return`\\`;case 78:return`
`;case 95:return`\xA0`;case 76:return`\u2028`;case 80:return`\u2029`;default:return``}}var xr=Array(256),Sr=Array(256);for(let e=0;e<256;e++)xr[e]=+!!br(e),Sr[e]=br(e);function Cr(e){return e<=65535?String.fromCharCode(e):String.fromCharCode((e-65536>>10)+55296,(e-65536&1023)+56320)}function wr(e){return e>=48&&e<=57?e-48:(e|32)-97+10}function Tr(e){return e===120?2:e===117?4:8}function Er(e,t,n){let r=0;for(;t<n;){let n=e.charCodeAt(t);if(n===10)r++,t++;else if(n===13)r++,t++,e.charCodeAt(t)===10&&t++;else if(n===32||n===9)t++;else break}return{position:t,breaks:r}}function Dr(e){return e===1?` `:`
|
|
3
|
-
`.repeat(e-1)}function Or(e,t,n){let r=``,i=t,a=t,o=t;for(;i<n;){let t=e.charCodeAt(i);if(t===10||t===13){r+=e.slice(a,o);let t=Er(e,i,n);r+=Dr(t.breaks),i=a=o=t.position}else i++,t!==32&&t!==9&&(o=i)}return r+e.slice(a,o)}function kr(e,t,n){let r=``,i=t,a=t,o=t;for(;i<n;){let t=e.charCodeAt(i);if(t===39)r+=e.slice(a,i)+`'`,i+=2,a=o=i;else if(t===10||t===13){r+=e.slice(a,o);let t=Er(e,i,n);r+=Dr(t.breaks),i=a=o=t.position}else i++,t!==32&&t!==9&&(o=i)}return r+e.slice(a,n)}function Ar(e,t,n){let r=``,i=t,a=t,o=t;for(;i<n;){let t=e.charCodeAt(i);if(t===92){r+=e.slice(a,i),i++;let t=e.charCodeAt(i);if(t===10||t===13)i=Er(e,i,n).position;else if(t<256&&xr[t])r+=Sr[t],i++;else{let n=Tr(t),a=0;for(;n>0;n--){i++;let t=wr(e.charCodeAt(i));a=(a<<4)+t}r+=Cr(a),i++}a=o=i}else if(t===10||t===13){r+=e.slice(a,o);let t=Er(e,i,n);r+=Dr(t.breaks),i=a=o=t.position}else i++,t!==32&&t!==9&&(o=i)}return r+e.slice(a,n)}function jr(e,t,n,r,i,a){let o=r<0?0:r,s=e.slice(t,n).replace(/\r\n?/g,`
|
|
4
|
-
`),c=s===``?[]:(s.endsWith(`
|
|
5
|
-
`)?s.slice(0,-1):s).split(`
|
|
6
|
-
`),l=``,u=!1,d=0,f=!1;for(let e of c){let t=0;for(;t<o&&e.charCodeAt(t)===32;)t++;if(r<0||t>=e.length){d++;continue}let n=e.slice(o),i=n.charCodeAt(0);a?i===32||i===9?(f=!0,l+=`
|
|
7
|
-
`.repeat(u?1+d:d)):f?(f=!1,l+=`
|
|
8
|
-
`.repeat(d+1)):d===0?u&&(l+=` `):l+=`
|
|
9
|
-
`.repeat(d):l+=`
|
|
10
|
-
`.repeat(u?1+d:d),l+=n,u=!0,d=0}return i===vr.KEEP?l+=`
|
|
11
|
-
`.repeat(u?1+d:d):i!==vr.STRIP&&u&&(l+=`
|
|
12
|
-
`),l}function Mr(e,t){if(t.valueStart===yr)return``;let{valueStart:n,valueEnd:r}=t;if(t.fast)return e.slice(n,r);switch(t.style){case k.SINGLE_QUOTED:return kr(e,n,r);case k.DOUBLE_QUOTED:return Ar(e,n,r);case k.LITERAL_BLOCK:return jr(e,n,r,t.indent,t.chomping,!1);case k.FOLDED_BLOCK:return jr(e,n,r,t.indent,t.chomping,!0);default:return Or(e,n,r)}}var Nr=Object.assign(Object.create(null),{"!":`!`,"!!":`tag:yaml.org,2002:`});function Pr(e,t){if(e.startsWith(`!<`)&&e.endsWith(`>`))return decodeURIComponent(e.slice(2,-1));let n=e.indexOf(`!`,1),r=n===-1?`!`:e.slice(0,n+1),i=t?.[r]??Nr[r]??r;return decodeURIComponent(i)+decodeURIComponent(e.slice(r.length))}var Fr=-1,Ir=`tag:yaml.org,2002:merge`,Lr={filename:``,schema:cr,json:!1,maxTotalMergeKeys:1e4,maxAliases:-1};function Rr(e){return`tagStart`in e&&e.tagStart!==Fr?e.tagStart:`anchorStart`in e&&e.anchorStart!==Fr?e.anchorStart:`valueStart`in e&&e.valueStart!==Fr?e.valueStart:`start`in e?e.start:0}function zr(e,t){hr.throwAt(e.source,e.position,t,e.filename)}function Br(e,t,n,r){try{return n.finalize(r)}catch(n){if(n instanceof hr)throw n;hr.throwAt(e.source,t,n instanceof Error?n.message:String(n),e.filename)}}function Vr(e,t){let n=Mr(e.source,t),r=t.tagStart===Fr?``:e.source.slice(t.tagStart,t.tagEnd),i=e.schema.defaultScalarTag;if(r!==``){if(r===`!`)return{value:n,tag:i};let t=Pr(r,e.tagHandlers),a=e.schema.lookupScalarTag(t);if(a){let r=a.resolve(n,!0,t);return r===O&&zr(e,`cannot resolve a node with !<${t}> explicit tag`),{value:r,tag:a}}let o=e.schema.lookupMappingTag(t)??e.schema.lookupSequenceTag(t);if(o){n!==``&&zr(e,`cannot resolve a node with !<${t}> explicit tag`);let r=o.create(t);return{value:o.carrierIsResult?r:Br(e,e.position,o,r),tag:o}}zr(e,`unknown scalar tag !<${t}>`)}return t.style===k.PLAIN?e.schema.resolveImplicitScalarTag(n):{value:i.resolve(n,!1,i.tagName),tag:i}}function Hr(e,t,n){let r=t.tagStart===Fr?``:e.source.slice(t.tagStart,t.tagEnd);return r===``||r===`!`?n:Pr(r,e.tagHandlers)}function Ur(e){return e.nodeKind===`mapping`}function Wr(e){e.totalMergeKeys++,e.maxTotalMergeKeys!==-1&&e.totalMergeKeys>e.maxTotalMergeKeys&&zr(e,`merge keys exceeded maxTotalMergeKeys (${e.maxTotalMergeKeys})`)}function Gr(e,t,n,r){Wr(e);for(let i of r.keys(n)){if(Wr(e),t.tag.has(t.value,i))continue;let a=t.tag.addPair(t.value,i,r.get(n,i));a&&zr(e,a),t.overridable??=new Set,t.overridable.add(i)}}function Kr(e,t,n,r){if(e.position=t.keyPosition,Ur(r))Gr(e,t,n,r);else if(r.nodeKind===`sequence`&&Array.isArray(n)){n.length>100&&zr(e,`abnormal merge sequence size`);for(let r of n){let n=e.nodeTags.get(r);n||zr(e,`cannot merge mappings; the provided source object is unacceptable`),Gr(e,t,r,n)}}else zr(e,`cannot merge mappings; the provided source object is unacceptable`)}function qr(e,t,n,r,i){if(e.position=t.keyPosition,t.keyIsMerge){Kr(e,t,r,i);return}!e.json&&t.tag.has(t.value,n)&&!t.overridable?.has(n)&&zr(e,`duplicated mapping key`);let a=t.tag.addPair(t.value,n,r);a&&zr(e,a),t.overridable?.delete(n)}function Jr(e,t,n){let r=e.frames[e.frames.length-1];if(r.kind===`document`)r.value=t,r.hasValue=!0;else if(r.kind===`sequence`){Ur(n)&&e.nodeTags.set(t,n);let i=r.tag.addItem(r.value,t,r.index++);i&&zr(e,i)}else if(r.hasKey){let i=r.key;r.key=void 0,r.hasKey=!1,qr(e,r,i,t,n)}else r.key=t,r.keyPosition=e.position,r.hasKey=!0,r.keyIsMerge=n.tagName===Ir}function Yr(e,t,n,r,i){if(t.anchorStart!==Fr){let a={value:n,tag:r,isValueFinal:i};return e.anchors.set(e.source.slice(t.anchorStart,t.anchorEnd),a),a}return null}function Xr(e,t){let n={...Lr,...t,events:e,documents:[],eventIndex:0,position:0,frames:[],anchors:new Map,nodeTags:new Map,tagHandlers:Object.create(null),totalMergeKeys:0,aliasCount:0};for(;n.eventIndex<n.events.length;){let e=n.events[n.eventIndex++];switch(n.position=Rr(e),e.type){case gr.DOCUMENT:n.anchors=new Map,n.nodeTags=new Map,n.aliasCount=0,n.tagHandlers=Object.create(null);for(let t of e.directives)t.kind===`tag`&&(n.tagHandlers[t.handle]=t.prefix);n.frames.push({kind:`document`,position:n.position,value:void 0,hasValue:!1});break;case gr.SCALAR:{let{value:t,tag:r}=Vr(n,e);Yr(n,e,t,r,!0),Jr(n,t,r);break}case gr.SEQUENCE:{let t=Hr(n,e,`tag:yaml.org,2002:seq`),r=n.schema.lookupSequenceTag(t);r||zr(n,`unknown sequence tag !<${t}>`);let i=r.create(t),a=Yr(n,e,i,r,r.carrierIsResult);n.frames.push({kind:`sequence`,position:n.position,value:i,tag:r,anchor:a,index:0});break}case gr.MAPPING:{let t=Hr(n,e,`tag:yaml.org,2002:map`),r=n.schema.lookupMappingTag(t);r||zr(n,`unknown mapping tag !<${t}>`);let i=r.create(t),a=Yr(n,e,i,r,r.carrierIsResult);n.frames.push({kind:`mapping`,position:n.position,value:i,tag:r,anchor:a,key:void 0,keyPosition:n.position,hasKey:!1,keyIsMerge:!1,overridable:null});break}case gr.ALIAS:{n.maxAliases!==-1&&++n.aliasCount>n.maxAliases&&zr(n,`aliases exceeded maxAliases (${n.maxAliases})`);let t=n.source.slice(e.anchorStart,e.anchorEnd),r=n.anchors.get(t);r||zr(n,`unidentified alias "${t}"`),r.isValueFinal||zr(n,`recursive alias "${t}" is not supported for tag ${r.tag.tagName} because it uses finalize()`),Jr(n,r.value,r.tag);break}case gr.POP:{let e=n.frames.pop();if(e.kind===`mapping`&&e.hasKey&&(n.position=e.keyPosition,zr(n,`incomplete mapping pair in event stream`)),e.kind===`document`)n.documents.push(e.value);else{let t=e.tag.carrierIsResult?e.value:Br(n,e.position,e.tag,e.value);e.anchor&&(e.anchor.value=t,e.anchor.isValueFinal=!0),Jr(n,t,e.tag)}break}}}return n.documents}var A=-1,Zr=Object.prototype.hasOwnProperty,Qr=1,$r=2,ei=3,ti=4,ni=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,ri=/[,\[\]{}]/,ii=/^(?:!|!!|![0-9A-Za-z-]+!)$/,ai=String.raw`(?:%[0-9A-Fa-f]{2}|[0-9A-Za-z\-#;/?:@&=+$,_.!~*'()\[\]])`,oi=String.raw`(?:%[0-9A-Fa-f]{2}|[0-9A-Za-z\-#;/?:@&=+$.~*'()_])`,si=RegExp(`^(?:${ai})*$`),ci=RegExp(`^(?:${oi})+$`),li=RegExp(`^(?:!(?:${ai})*|${oi}(?:${ai})*)$`),ui={filename:``,maxDepth:100};function di(e,t,n){e.events.push({type:gr.DOCUMENT,explicitStart:t,explicitEnd:n,directives:e.directives})}function fi(e,t,n,r,i,a,o){e.events.push({type:gr.SEQUENCE,start:t,anchorStart:n,anchorEnd:r,tagStart:i,tagEnd:a,style:o})}function pi(e,t,n,r,i,a,o){e.events.push({type:gr.MAPPING,start:t,anchorStart:n,anchorEnd:r,tagStart:i,tagEnd:a,style:o})}function mi(e,t){e.events.splice(t.eventsLength,0,{type:gr.MAPPING,start:t.position,anchorStart:A,anchorEnd:A,tagStart:A,tagEnd:A,style:_r.FLOW})}function hi(e,t,n,r,i,a,o,s,c=vr.CLIP,l=-1,u=!1){e.events.push({type:gr.SCALAR,valueStart:t,valueEnd:n,anchorStart:r,anchorEnd:i,tagStart:a,tagEnd:o,style:s,chomping:c,indent:l,fast:u})}function gi(e,t,n){e.events.push({type:gr.ALIAS,anchorStart:t,anchorEnd:n})}function _i(e){e.events.push({type:gr.POP})}function vi(e){hi(e,A,A,A,A,A,A,k.PLAIN)}function yi(){return{anchorStart:A,anchorEnd:A,tagStart:A,tagEnd:A}}function bi(e){return{position:e.position,line:e.line,lineStart:e.lineStart,lineIndent:e.lineIndent,firstTabInLine:e.firstTabInLine,eventsLength:e.events.length}}function xi(e,t){e.position=t.position,e.line=t.line,e.lineStart=t.lineStart,e.lineIndent=t.lineIndent,e.firstTabInLine=t.firstTabInLine,e.events.length=t.eventsLength}function j(e,t){hr.throwAt(e.input.slice(0,e.length),e.position,t,e.filename)}function Si(e){return e===10||e===13}function Ci(e){return e===9||e===32}function wi(e){return Ci(e)||Si(e)}function Ti(e){return e===0||wi(e)}function Ei(e){return e===44||e===91||e===93||e===123||e===125}function Di(e){return e>=48&&e<=57?e-48:-1}function Oi(e){if(e>=48&&e<=57)return e-48;let t=e|32;return t>=97&&t<=102?t-97+10:-1}function ki(e){return e===120?2:e===117?4:e===85?8:0}function Ai(e){return e===48||e===97||e===98||e===116||e===9||e===110||e===118||e===102||e===114||e===101||e===32||e===34||e===47||e===92||e===78||e===95||e===76||e===80}function ji(e){e.input.charCodeAt(e.position)===10?e.position++:(e.position++,e.input.charCodeAt(e.position)===10&&e.position++),e.line++,e.lineStart=e.position,e.lineIndent=0,e.firstTabInLine=-1}function Mi(e,t){let n=0,r=e.input.charCodeAt(e.position),i=e.position===e.lineStart||wi(e.input.charCodeAt(e.position-1));for(;r!==0;){for(;Ci(r);)i=!0,r===9&&e.firstTabInLine===-1&&(e.firstTabInLine=e.position),r=e.input.charCodeAt(++e.position);if(t&&i&&r===35)do r=e.input.charCodeAt(++e.position);while(!Si(r)&&r!==0);if(!Si(r))break;for(ji(e),n++,i=!0,r=e.input.charCodeAt(e.position);r===32;)e.lineIndent++,r=e.input.charCodeAt(++e.position)}return n}function Ni(e,t=e.position){let n=e.input.charCodeAt(t);if((n===45||n===46)&&n===e.input.charCodeAt(t+1)&&n===e.input.charCodeAt(t+2)){let n=e.input.charCodeAt(t+3);return n===0||wi(n)}return!1}function Pi(e){e.position===e.lineStart&&e.input.charCodeAt(e.position)===65279&&(e.position++,e.lineStart=e.position)}function Fi(e){if(e.position!==e.lineStart)return!1;if(Ni(e))return!0;if(e.input.charCodeAt(e.position)!==65279)return!1;let t=bi(e);Pi(e),Mi(e,!0);let n=e.input.charCodeAt(e.position),r=e.position===e.lineStart&&(n===37||n===45&&Ni(e));return xi(e,t),r}function Ii(e){let t=e.input.charCodeAt(e.position);for(;t!==0&&!Si(t);)t=e.input.charCodeAt(++e.position)}function Li(e,t,n){ni.test(e.input.slice(t,n))&&j(e,`the stream contains non-printable characters`)}function Ri(e,t,n){if(e.input.charCodeAt(e.position)!==33)return!1;t.tagStart!==A&&j(e,`duplication of a tag property`);let r=e.position,i=!1,a=!1,o=`!`,s=e.input.charCodeAt(++e.position);s===60?(i=!0,s=e.input.charCodeAt(++e.position)):s===33&&(a=!0,o=`!!`,s=e.input.charCodeAt(++e.position));let c=e.position,l;if(i){for(;s!==0&&s!==62;)s=e.input.charCodeAt(++e.position);s!==62&&j(e,`unexpected end of the stream within a verbatim tag`),l=e.input.slice(c,e.position),e.position++}else{for(;s!==0&&!wi(s)&&!(n&&Ei(s));)s===33&&(a?j(e,`tag suffix cannot contain exclamation marks`):(o=e.input.slice(c-1,e.position+1),ii.test(o)||j(e,`named tag handle cannot contain such characters`),a=!0,c=e.position+1)),s=e.input.charCodeAt(++e.position);l=e.input.slice(c,e.position),ri.test(l)&&j(e,`tag suffix cannot contain flow indicator characters`)}return l&&!(i?si.test(l):ci.test(l))&&j(e,`tag name cannot contain such characters: ${l}`),!i&&o!==`!`&&o!==`!!`&&!Zr.call(e.tagHandlers,o)&&j(e,`undeclared tag handle "${o}"`),t.tagStart=r,t.tagEnd=e.position,!0}function zi(e,t){if(e.input.charCodeAt(e.position)!==38)return!1;t.anchorStart!==A&&j(e,`duplication of an anchor property`),e.position++;let n=e.position;for(;e.input.charCodeAt(e.position)!==0&&!wi(e.input.charCodeAt(e.position))&&!Ei(e.input.charCodeAt(e.position));)e.position++;return e.position===n&&j(e,`name of an anchor node must contain at least one character`),t.anchorStart=n,t.anchorEnd=e.position,!0}function Bi(e,t){if(e.input.charCodeAt(e.position)!==42)return!1;(t.anchorStart!==A||t.tagStart!==A)&&j(e,`alias node should not have any properties`),e.position++;let n=e.position;for(;e.input.charCodeAt(e.position)!==0&&!wi(e.input.charCodeAt(e.position))&&!Ei(e.input.charCodeAt(e.position));)e.position++;return e.position===n&&j(e,`name of an alias node must contain at least one character`),gi(e,n,e.position),!0}function Vi(e,t){Mi(e,!1),e.lineIndent<t&&j(e,`deficient indentation`)}function Hi(e,t,n){if(e.input.charCodeAt(e.position)!==39)return!1;e.position++;let r=e.position,i=!0;for(;e.input.charCodeAt(e.position)!==0;){let a=e.input.charCodeAt(e.position);if(a===39){if(e.input.charCodeAt(e.position+1)===39){i=!1,e.position+=2;continue}let t=e.position;return e.position++,hi(e,r,t,n.anchorStart,n.anchorEnd,n.tagStart,n.tagEnd,k.SINGLE_QUOTED,vr.CLIP,-1,i),!0}Si(a)?(i=!1,Vi(e,t)):e.position===e.lineStart&&Ni(e)?j(e,`unexpected end of the document within a single quoted scalar`):a!==9&&a<32?j(e,`expected valid JSON character`):e.position++}j(e,`unexpected end of the stream within a single quoted scalar`)}function Ui(e,t,n){if(e.input.charCodeAt(e.position)!==34)return!1;e.position++;let r=e.position,i=!0;for(;e.input.charCodeAt(e.position)!==0;){let a=e.input.charCodeAt(e.position);if(a===34){let t=e.position;return e.position++,hi(e,r,t,n.anchorStart,n.anchorEnd,n.tagStart,n.tagEnd,k.DOUBLE_QUOTED,vr.CLIP,-1,i),!0}if(a===92){i=!1;let n=e.input.charCodeAt(++e.position);if(Si(n))Vi(e,t);else if(Ai(n))e.position++;else{let t=ki(n);for(t===0&&j(e,`unknown escape sequence`);t-->0;)e.position++,Oi(e.input.charCodeAt(e.position))<0&&j(e,`expected hexadecimal character`);e.position++}}else Si(a)?(i=!1,Vi(e,t)):e.position===e.lineStart&&Ni(e)?j(e,`unexpected end of the document within a double quoted scalar`):a!==9&&a<32?j(e,`expected valid JSON character`):e.position++}j(e,`unexpected end of the stream within a double quoted scalar`)}function Wi(e,t,n){let r=e.input.charCodeAt(e.position),i=vr.CLIP,a=-1,o=!1;if(r!==124&&r!==62)return!1;let s=r===124?k.LITERAL_BLOCK:k.FOLDED_BLOCK;for(e.position++;e.input.charCodeAt(e.position)!==0;){let n=e.input.charCodeAt(e.position),r=Di(n);if(n===43||n===45)i!==vr.CLIP&&j(e,`repeat of a chomping mode identifier`),i=n===43?vr.KEEP:vr.STRIP,e.position++;else if(r>=0)r===0&&j(e,`bad explicit indentation width of a block scalar; it cannot be less than one`),o&&j(e,`repeat of an indentation width identifier`),a=t+r-1,o=!0,e.position++;else break}let c=!1;for(;Ci(e.input.charCodeAt(e.position));)c=!0,e.position++;c&&e.input.charCodeAt(e.position)===35&&Ii(e),Si(e.input.charCodeAt(e.position))?ji(e):e.input.charCodeAt(e.position)!==0&&j(e,`a line break is expected`);let l=o?a:-1,u=0,d=e.position,f=e.position;for(;e.input.charCodeAt(e.position)!==0;){let n=e.position,r=0;for(;e.input.charCodeAt(n+r)===32;)r++;let i=e.input.charCodeAt(n+r);if(i===0){l>=0?r>l&&(f=n+r):r>0&&(f=n+r);break}if(Fi(e))break;if(!o&&l===-1&&Si(i)&&(u=Math.max(u,r)),!o&&l===-1&&!Si(i)&&(i===9&&r<t&&(e.position=n+r,j(e,`tab characters must not be used in indentation`)),r<u&&(e.position=n+r,j(e,`bad indentation of a mapping entry`))),l===-1&&i!==0&&!Si(i)&&r<t){e.lineIndent=r,e.position=n+r;break}!o&&i!==0&&!Si(i)&&l===-1&&(l=r);let a=l===-1?t+1:l;if(i!==0&&!Si(i)&&r<a){e.lineIndent=r,e.position=n+r;break}Ii(e),f=e.position,Si(e.input.charCodeAt(e.position))&&(ji(e),f=e.position)}return Li(e,d,f),hi(e,d,f,n.anchorStart,n.anchorEnd,n.tagStart,n.tagEnd,s,i,l),!0}function Gi(e,t){let n=e.input.charCodeAt(e.position),r=t===Qr;if(n===0||wi(n)||n===35||n===38||n===42||n===33||n===124||n===62||n===39||n===34||n===37||n===64||n===96||r&&Ei(n))return!1;if(n===63||n===45){let t=e.input.charCodeAt(e.position+1);if(Ti(t)||r&&Ei(t))return!1}return!0}function Ki(e,t,n,r){if(!Gi(e,n))return!1;let i=e.position,a=e.position,o=e.input.charCodeAt(e.position),s=n===Qr,c=!1;for(;o!==0&&!Fi(e);){if(o===58){let t=e.input.charCodeAt(e.position+1);if(Ti(t)||s&&Ei(t))break}else if(o===35){if(wi(e.input.charCodeAt(e.position-1)))break}else if(s&&Ei(o))break;else if(Si(o)){let n=e.position,r=e.line,i=e.lineStart,a=e.lineIndent;if(Mi(e,!1),e.lineIndent>=t){c=!0,o=e.input.charCodeAt(e.position);continue}e.position=n,e.line=r,e.lineStart=i,e.lineIndent=a;break}Ci(o)||(a=e.position+1),o=e.input.charCodeAt(++e.position)}return a!==i&&(Li(e,i,a),hi(e,i,a,r.anchorStart,r.anchorEnd,r.tagStart,r.tagEnd,k.PLAIN,vr.CLIP,-1,!c),!0)}function qi(e,t){let n=e.line;Mi(e,!0),(e.line>n&&e.lineIndent<t||e.firstTabInLine!==-1&&e.lineIndent<t)&&j(e,`deficient indentation`)}function Ji(e,t,n){let r=e.input.charCodeAt(e.position),i=r===123,a=e.position,o=!0;if(r!==91&&r!==123)return!1;let s=i?125:93;for(i?pi(e,a,n.anchorStart,n.anchorEnd,n.tagStart,n.tagEnd,_r.FLOW):fi(e,a,n.anchorStart,n.anchorEnd,n.tagStart,n.tagEnd,_r.FLOW),e.position++;e.input.charCodeAt(e.position)!==0;){qi(e,t);let n=e.input.charCodeAt(e.position);if(n===s)return e.position++,_i(e),!0;o?n===44&&j(e,`expected the node content, but found ','`):j(e,`missed comma between flow collection entries`);let r=!1,a=!1;n===63&&wi(e.input.charCodeAt(e.position+1))&&(r=a=!0,e.position+=1,qi(e,t));let c=e.line,l=bi(e),u=Zi(e,t,Qr,!1,!0);qi(e,t),n=e.input.charCodeAt(e.position),(i||a||e.line===c)&&n===58?(r=!0,e.position++,qi(e,t),i||mi(e,l),u||vi(e),Zi(e,t,Qr,!1,!0)||vi(e),qi(e,t),i||_i(e)):i&&r?(u||vi(e),vi(e)):i?vi(e):r&&(mi(e,l),u||vi(e),vi(e),_i(e)),n=e.input.charCodeAt(e.position),n===44?(o=!0,e.position++):o=!1}j(e,`unexpected end of the stream within a flow collection`)}function Yi(e,t,n){if(e.firstTabInLine!==-1||e.input.charCodeAt(e.position)!==45||!Ti(e.input.charCodeAt(e.position+1)))return!1;for(fi(e,e.position,n.anchorStart,n.anchorEnd,n.tagStart,n.tagEnd,_r.BLOCK);e.input.charCodeAt(e.position)===45&&Ti(e.input.charCodeAt(e.position+1));){e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,j(e,`tab characters must not be used in indentation`));let n=e.line;e.position++;let r=Mi(e,!0)>0;if(e.firstTabInLine!==-1&&e.input.charCodeAt(e.position)===45&&Ti(e.input.charCodeAt(e.position+1))&&j(e,`bad indentation of a sequence entry`),r&&e.lineIndent<=t?vi(e):Zi(e,t,ei,!1,!0),Mi(e,!0),e.lineIndent<t||e.position>=e.length)break;e.lineIndent>t&&j(e,`bad indentation of a sequence entry`),e.line===n&&e.input.charCodeAt(e.position)===45&&Ti(e.input.charCodeAt(e.position+1))&&j(e,`bad indentation of a sequence entry`)}return _i(e),!0}function Xi(e,t,n,r){let i=!1,a=!1,o=!1,s=!1;if(e.firstTabInLine!==-1)return!1;let c=e.input.charCodeAt(e.position);for(;c!==0;){!i&&e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,j(e,`tab characters must not be used in indentation`));let l=e.input.charCodeAt(e.position+1),u=e.line;if((c===63||c===58)&&Ti(l))o||=(pi(e,e.position,r.anchorStart,r.anchorEnd,r.tagStart,r.tagEnd,_r.BLOCK),!0),c===63?(i&&vi(e),a=!0,i=!0):(i||(vi(e),a=!0),i=!1),e.position+=1,s=!0;else{i&&=(vi(e),!1);let t=bi(e);if(!Zi(e,n,$r,!1,!0))break;if(e.line===u){for(c=e.input.charCodeAt(e.position);Ci(c);)c=e.input.charCodeAt(++e.position);if(c===58){if(c=e.input.charCodeAt(++e.position),Ti(c)||j(e,`a whitespace character is expected after the key-value separator within a block mapping`),!o){for(xi(e,t),pi(e,t.position,r.anchorStart,r.anchorEnd,r.tagStart,r.tagEnd,_r.BLOCK),o=!0,Zi(e,n,$r,!1,!0),c=e.input.charCodeAt(e.position);Ci(c);)c=e.input.charCodeAt(++e.position);e.position++}a=!0,i=!1,s=!1}else if(a)j(e,`expected ':' after a mapping key`);else return r.anchorStart!==A||r.tagStart!==A?(xi(e,t),!1):!0}else if(a)j(e,`can not read a block mapping entry; a multiline key may not be an implicit key`);else return r.anchorStart!==A||r.tagStart!==A?(xi(e,t),!1):!0}if(Zi(e,t,ti,!0,s)&&(s=!1),i||(s&&=(vi(e),!1)),Mi(e,!0),c=e.input.charCodeAt(e.position),(e.line===u||e.lineIndent>t)&&c!==0)j(e,`bad indentation of a mapping entry`);else if(e.lineIndent<t)break}return a?(i&&vi(e),o&&_i(e),!0):!1}function Zi(e,t,n,r,i,a=!0){e.depth>=e.maxDepth&&j(e,`nesting exceeded maxDepth (${e.maxDepth})`),e.depth++;let o=1,s=!1,c=!1,l=null,u=yi(),d=n===ti||n===ei,f=d,p=d;if(r&&Mi(e,!0)&&(s=!0,o=e.lineIndent>t?1:e.lineIndent===t?0:-1),o===1)for(;;){let r=e.input.charCodeAt(e.position),i=bi(e);if(s&&o!==1&&(r===33||r===38))break;if(s&&p&&(u.tagStart!==A||u.anchorStart!==A)&&(r===33||r===38)){let n=bi(e),r=t+1;if(Xi(e,e.position-e.lineStart,r,u)&&e.events[n.eventsLength]?.type===gr.MAPPING)return e.depth--,!0;xi(e,n)}if(s&&(r===33&&u.tagStart!==A||r===38&&u.anchorStart!==A)||!Ri(e,u,n===Qr)&&!zi(e,u))break;l===null&&(l=i),Mi(e,!0)?(s=!0,f=p,o=e.lineIndent>t?1:e.lineIndent===t?0:-1):f=!1}if(f&&=s||i,o===1||n===ti){let r=n===Qr||n===$r?t:t+1,i=e.position-e.lineStart;if(o===1){if(f&&(Yi(e,i,u)||Xi(e,i,r,u))||Ji(e,r,u))c=!0;else{let t=e.input.charCodeAt(e.position);if(l!==null&&a&&p&&!f&&t!==124&&t!==62){let t=bi(e),n=l.position-l.lineStart;xi(e,l),Xi(e,n,r,yi())&&e.events[t.eventsLength]?.type===gr.MAPPING?c=!0:xi(e,t)}!c&&(d&&Wi(e,r,u)||Hi(e,r,u)||Ui(e,r,u)||Bi(e,u)||Ki(e,r,n,u))&&(c=!0)}}else o===0&&(c=f&&Yi(e,i,u))}return d&&=!c,!c&&(u.anchorStart!==A||u.tagStart!==A||d)&&(hi(e,A,A,u.anchorStart,u.anchorEnd,u.tagStart,u.tagEnd,k.PLAIN),c=!0),e.depth--,c||u.anchorStart!==A||u.tagStart!==A}function Qi(e){if(e.lineIndent>0||e.input.charCodeAt(e.position)!==37)return!1;e.position++;let t=e.position;for(;e.input.charCodeAt(e.position)!==0&&!wi(e.input.charCodeAt(e.position));)e.position++;let n=e.input.slice(t,e.position),r=[];for(n.length===0&&j(e,`directive name must not be less than one character in length`);e.input.charCodeAt(e.position)!==0&&!Si(e.input.charCodeAt(e.position));){for(;Ci(e.input.charCodeAt(e.position));)e.position++;if(e.input.charCodeAt(e.position)===35||Si(e.input.charCodeAt(e.position))||e.input.charCodeAt(e.position)===0)break;let t=e.position;for(;e.input.charCodeAt(e.position)!==0&&!wi(e.input.charCodeAt(e.position));)e.position++;r.push(e.input.slice(t,e.position))}if(Si(e.input.charCodeAt(e.position))&&ji(e),n===`YAML`){e.directives.some(e=>e.kind===`yaml`)&&j(e,`duplication of %YAML directive`),r.length!==1&&j(e,`YAML directive accepts exactly one argument`);let t=/^([0-9]+)\.([0-9]+)$/.exec(r[0]);t===null&&j(e,`ill-formed argument of the YAML directive`),parseInt(t[1],10)!==1&&j(e,`unacceptable YAML version of the document`),e.directives.push({kind:`yaml`,version:r[0]})}else if(n===`TAG`){r.length!==2&&j(e,`TAG directive accepts exactly two arguments`);let[t,n]=r;ii.test(t)||j(e,`ill-formed tag handle (first argument) of the TAG directive`),Zr.call(e.tagHandlers,t)&&j(e,`there is a previously declared suffix for "${t}" tag handle`),li.test(n)||j(e,`ill-formed tag prefix (second argument) of the TAG directive`),e.tagHandlers[t]=n,e.directives.push({kind:`tag`,handle:t,prefix:n})}return!0}function $i(e){e.directives=[],e.tagHandlers=Object.create(null);let t=!1;for(Mi(e,!0);Qi(e);)t=!0,Mi(e,!0);let n=!1,r=!1,i=!0;if(e.lineIndent===0&&e.input.charCodeAt(e.position)===45&&e.input.charCodeAt(e.position+1)===45&&e.input.charCodeAt(e.position+2)===45&&Ti(e.input.charCodeAt(e.position+3))){n=!0;let t=e.line;e.position+=3,Mi(e,!0),i=e.line>t}else t&&j(e,`directives end mark is expected`);let a=e.events.length;if(!n&&e.position===e.lineStart&&e.input.charCodeAt(e.position)===46&&Ni(e)){e.position+=3,Mi(e,!0);return}if(di(e,n,!1),Zi(e,e.lineIndent-1,ti,!1,i,i)||vi(e),Mi(e,!0),e.position===e.lineStart&&Ni(e)&&(r=e.input.charCodeAt(e.position)===46,r)){let t=e.line;e.position+=3,Mi(e,!0),e.line===t&&e.position<e.length&&j(e,`end of the stream or a document separator is expected`)}let o=e.events[a];o?.type===gr.DOCUMENT&&(o.explicitEnd=r),_i(e),!r&&e.position<e.length&&!Fi(e)&&j(e,`end of the stream or a document separator is expected`)}function ea(e,t){let n=e.length,r={...ui,...t,input:`${e}\0`,length:n,position:0,line:0,lineStart:0,lineIndent:0,firstTabInLine:-1,depth:0,directives:[],tagHandlers:Object.create(null),events:[]},i=e.indexOf(`\0`);for(i!==-1&&hr.throwAt(e,i,`null byte is not allowed in input`,r.filename);r.position<r.length&&(Pi(r),Mi(r,!0),!(r.position>=r.length));){let e=r.position;$i(r),r.position===e&&j(r,`can not read a document`)}return r.events}var ta={...ui,...Lr};function na(e,t={}){let n={...ta,...t},r=String(e),i=Object.keys(ui),a=Object.keys(Lr);return Xr(ea(r,Qn(n,i)),{...Qn(n,a),source:r})}function ra(e,t){let n=na(e,t);if(n.length===0)throw new hr(`expected a document, but the input is empty`);if(n.length===1)return n[0];throw new hr(`expected a single document in the stream, but found more`)}function ia(e,t){return!!(e&1<<t)}var aa={applyQuoteFlowKeysOption:sa,doubleQuoteForInvisibles:ca,doubleQuoteWhitespaceOnly:la,applyForceQuotesOption:ua,tryLongOrMultilineAsBlock:da,quoteInvalidPlain:fa,fallbackToDoubleQuoted:pa};function oa(e){return e.presenterOptions.quoteStyle===`single`&&ia(e.allowedStylesMask,k.SINGLE_QUOTED)?k.SINGLE_QUOTED:k.DOUBLE_QUOTED}function sa(e){e.presenterOptions.quoteFlowKeys&&e.isKey&&e.flowOnly&&e.style===k.PLAIN&&(e.style=k.DOUBLE_QUOTED)}function ca(e){e.style===k.PLAIN&&/[\t\x7F-\xA0\u2028\u2029\uFEFF\uFFFE\uFFFF]/.test(e.node.value)&&(e.style=k.DOUBLE_QUOTED)}function la(e){e.style===k.PLAIN&&/^\s+$/.test(e.node.value)&&(e.style=k.DOUBLE_QUOTED)}function ua(e){e.presenterOptions.forceQuotes&&(e.isKey||e.style!==k.PLAIN||(e.style=e.node.value.includes(`
|
|
13
|
-
`)?k.DOUBLE_QUOTED:oa(e)))}function da(e){if(e.style!==k.PLAIN||e.isKey)return;let t=e.node.value,n=t.indexOf(`
|
|
14
|
-
`)!==-1;if(!ia(e.allowedStylesMask,k.LITERAL_BLOCK)){n&&(e.style=k.DOUBLE_QUOTED);return}let r=e.presenterOptions.lineWidth;if(r===-1){n&&(e.style=k.LITERAL_BLOCK);return}let i=Math.max(Math.min(r,40),r-e.shiftOfContent),a=0,o=!1;for(;a<=t.length;){let e=t.length,n=t.indexOf(`
|
|
15
|
-
`,a);n!==-1&&(e=n);let r=t.slice(a,e);if(r.length>i&&r[0]!==` `&&/ [^ \t]/.test(r)&&(o=!0),n===-1)break;a=n+1}o?e.style=k.FOLDED_BLOCK:n&&(e.style=k.LITERAL_BLOCK)}function fa(e){e.style===k.PLAIN&&!ia(e.allowedStylesMask,k.PLAIN)&&(e.style=oa(e))}function pa(e){ia(e.allowedStylesMask,e.style)||(e.style=k.DOUBLE_QUOTED)}var ma=`[\\x09\\x0A\\x0D\\x20-\\x7E\\x85\\xA0-\\uD7FF\\uE000-\\uFFFD\\u{10000}-\\u{10FFFF}]`,ha=`[\\n\\r]`,ga=`\\uFEFF`,_a=`[ \\t]`,va=`(?:(?!(?:${ha}|${ga}))${ma})`,ya=`(?:(?!${_a})${va})`,ba=`[\\x09\\x20-\\uD7FF\\uE000-\\uFFFF\\u{10000}-\\u{10FFFF}]`,xa=`[-?:,\\[\\]{}#&*!|>'"%@\`]`,Sa=`[,\\[\\]{}]`,Ca=ya,wa=`(?:(?!${Sa})${ya})`,Ta=`(?:(?:(?!${xa})${ya})|[?:-](?=${Ca}))`,Ea=`(?:(?:(?!${xa})${ya})|[?:-](?=${wa}))`,Da=`(?:(?:(?![:#])${Ca})|:(?=${Ca}))#*`,Oa=`(?:(?:(?![:#])${wa})|:(?=${wa}))#*`,ka=`(?:${_a}*${Da})*`,Aa=`(?:${_a}*${Oa})*`,ja=`${Ta}#*${ka}`,Ma=`${Ea}#*${Aa}`,Na=ja,Pa=Ma,Fa=`\\n+${Da}${ka}`,Ia=`\\n+${Oa}${Aa}`,La=`${ja}(?:${Fa})*`,Ra=`${Ma}(?:${Ia})*`;RegExp(`^(?:${La})$`,`u`),RegExp(`^(?:${Ra})$`,`u`),RegExp(`^(?:${Na})$`,`u`),RegExp(`^(?:${Pa})$`,`u`),RegExp(`^(?:${ba})*$`,`u`),RegExp(`^(?:${ba}|\\n)*$`,`u`),RegExp(`^(?:${va}|\\n)*$`,`u`),Object.keys(aa).map(e=>Reflect.get(aa,e)),gr.DOCUMENT,gr.SEQUENCE,gr.MAPPING,gr.SCALAR,gr.ALIAS,gr.POP,k.PLAIN,k.SINGLE_QUOTED,k.DOUBLE_QUOTED,k.LITERAL_BLOCK,k.FOLDED_BLOCK,_r.BLOCK,_r.FLOW,vr.CLIP,vr.STRIP,vr.KEEP;var za=e=>e*7,Ba=e=>Math.round(e/7*100)/100,Va=e=>e*4/3,Ha=e=>Math.round(e*3/4*100)/100;function Ua(e,t,n){let r=JSON.parse(JSON.stringify(e)),i=(e,t,n)=>{for(let r of Object.values(e??{}))r&&typeof r[t]==`number`&&(r[t]=n(r[t]))};for(let e of r.sheets){i(e.columns,`width`,t),i(e.rows,`height`,n);for(let n of e.tables??[])i(n.columns,`width`,t)}return r}function Wa(e){return e.units===`px`?e:Ua(e,za,Va)}function Ga(e){return e.units===`px`?e:Ua(e,Ba,Ha)}var Ka=`sheet.yaml`,qa=`sheet.ts`,Ja={clustered:`clustered`,standard:`clustered`,stacked:`stacked`,percentStacked:`stacked-100`},Ya={col:`column`,column:`column`,bar:`bar`,area:`area`,line:`line`};function Xa(e){let t=e.sheets;if(!Array.isArray(t))return e;for(let e of t)if(Array.isArray(e.charts))for(let t of e.charts){let e=typeof t.type==`string`?Ya[t.type]:void 0,n=t.grouping;if(e===void 0||typeof n!=`string`)continue;let r=Ja[n];r!==void 0&&(t.type=(e===`line`||e===`area`)&&r===`clustered`?e:`${e}-${r}`,Reflect.deleteProperty(t,`grouping`))}return e}function Za(e,t){let n=e=>{let n=e===``?[]:e.split(`/`);for(let e of t.split(`/`))if(e!==``&&e!==`.`){if(e===`..`){if(n.length===0)return;n.pop()}else n.push(e)}return n.join(`/`)};return[...new Set([n(e),n(``)])].filter(e=>e!==void 0&&e!==``)}function Qa(e){let t=io(e),n=t.file??t.partial;return[...new Set(n?.sheets.flatMap(e=>[...(e.tables??[]).map(e=>e.rows),...(e.blocks??[]).map(e=>e.rows)])??[])]}function $a(e){let t=[];return me(e,{Map(e,n){if(!de(n))return;let r=new Set;for(let e of n.items){let n=fe(e.key)?String(e.key.value):void 0;if(n!==void 0){if(r.has(n)){let r=fe(e.key)?e.key.range?.[0]??0:0;t.push({at:r,key:n})}else r.add(n)}}}}),t}var eo=2e7,to=e=>`${String(Math.round(e/1e5)/10)} MB`;function no(e,t){let n=t;return t=>{if(n===void 0){let t=new pe;n={doc:he(e,{lineCounter:t,uniqueKeys:!1}),counter:t}}let{doc:r,counter:i}=n;for(let e=t.length;e>=0;e--){let n=r.getIn(t.slice(0,e),!0)?.range?.[0];if(n!==void 0)return i.linePos(n).line}}}function ro(e){try{return{value:ra(e,{schema:cr})}}catch{return}}function io(e){if(e.length>2e7)return{problems:[{file:Ka,line:1,message:`this file is ${to(e.length)}; a sheet's file over ${to(eo)} is not read`}],lineOf:()=>void 0};let t=ro(e);if(t)return ao(Xa(t.value??{}),no(e));let n=new pe,r=he(e,{lineCounter:n,uniqueKeys:!1}),i=$a(r);return r.errors.length>0||i.length>0?{problems:[...r.errors.map(e=>({file:Ka,line:n.linePos(e.pos[0]).line,message:`not YAML: ${e.message.split(`
|
|
16
|
-
`)[0]??``}`})),...i.map(e=>({file:Ka,line:n.linePos(e.at).line,message:`not YAML: Map keys must be unique (${e.key})`}))],lineOf:no(e,{doc:r,counter:n})}:ao(Xa(r.toJS()??{}),no(e,{doc:r,counter:n}))}function ao(e,t){let n=r(`sheet`,e);return n.ok?{file:Wa(n.value),problems:[],lineOf:t}:{...n.partial?{partial:Wa(n.partial)}:{},problems:n.problems.map(e=>{let n=t(e.path===``?[]:e.path.split(`.`).map(e=>/^\d+$/u.test(e)?Number(e):e));return{file:Ka,...n===void 0?{}:{line:n},message:`${e.path===``?``:`${e.path}: `}${e.message}`}}),lineOf:t}}var oo=RegExp(`^[:A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$`);function so(e,t){let n=[],r=t.exec(e);for(;r;){let i=[];i.startIndex=t.lastIndex-r[0].length;let a=r.length;for(let e=0;e<a;e++)i.push(r[e]);n.push(i),r=t.exec(e)}return n}var co=function(e){return oo.exec(e)!=null};function lo(e){return e!==void 0}var uo=[`hasOwnProperty`,`toString`,`valueOf`,`__defineGetter__`,`__defineSetter__`,`__lookupGetter__`,`__lookupSetter__`],fo=[`__proto__`,`constructor`,`prototype`],po={allowBooleanAttributes:!1,unpairedTags:[]};function mo(e,t){t=Object.assign({},po,t);let n=[],r=!1,i=!1;e[0]===``&&(e=e.substr(1));for(let a=0;a<e.length;a++)if(e[a]===`<`&&e[a+1]===`?`){if(a+=2,a=go(e,a),a.err)return a}else if(e[a]===`<`){let o=a;if(a++,e[a]===`!`){a=_o(e,a);continue}{let s=!1;e[a]===`/`&&(s=!0,a++);let c=``;for(;a<e.length&&e[a]!==`>`&&e[a]!==` `&&e[a]!==` `&&e[a]!==`
|
|
17
|
-
`&&e[a]!==`\r`;a++)c+=e[a];if(c=c.trim(),c[c.length-1]===`/`&&(c=c.substring(0,c.length-1),a--),!Do(c)){let t;return t=c.trim().length===0?`Invalid space after '<'.`:`Tag '`+c+`' is an invalid name.`,To(`InvalidTag`,t,Oo(e,a))}let l=bo(e,a);if(l===!1)return To(`InvalidAttr`,`Attributes for '`+c+`' have open quote.`,Oo(e,a));let u=l.value;if(a=l.index,u[u.length-1]===`/`){let n=a-u.length;u=u.substring(0,u.length-1);let i=So(u,t);if(i===!0)r=!0;else return To(i.err.code,i.err.msg,Oo(e,n+i.err.line))}else if(s){if(!l.tagClosed)return To(`InvalidTag`,`Closing tag '`+c+`' doesn't have proper closing.`,Oo(e,a));if(u.trim().length>0)return To(`InvalidTag`,`Closing tag '`+c+`' can't have attributes or invalid starting.`,Oo(e,o));if(n.length===0)return To(`InvalidTag`,`Closing tag '`+c+`' has not been opened.`,Oo(e,o));{let t=n.pop();if(c!==t.tagName){let n=Oo(e,t.tagStartPos);return To(`InvalidTag`,`Expected closing tag '`+t.tagName+`' (opened in line `+n.line+`, col `+n.col+`) instead of closing tag '`+c+`'.`,Oo(e,o))}n.length==0&&(i=!0)}}else{let s=So(u,t);if(s!==!0)return To(s.err.code,s.err.msg,Oo(e,a-u.length+s.err.line));if(i===!0)return To(`InvalidXml`,`Multiple possible root nodes found.`,Oo(e,a));t.unpairedTags.indexOf(c)!==-1||n.push({tagName:c,tagStartPos:o}),r=!0}for(a++;a<e.length;a++)if(e[a]===`<`){if(e[a+1]===`!`){a++,a=_o(e,a);continue}if(e[a+1]===`?`){if(a=go(e,++a),a.err)return a}else break}else if(e[a]===`&`){let t=wo(e,a);if(t==-1)return To(`InvalidChar`,`char '&' is not expected.`,Oo(e,a));a=t}else if(i===!0&&!ho(e[a]))return To(`InvalidXml`,`Extra text at the end`,Oo(e,a));e[a]===`<`&&a--}}else{if(ho(e[a]))continue;return To(`InvalidChar`,`char '`+e[a]+`' is not expected.`,Oo(e,a))}return r?n.length==1?To(`InvalidTag`,`Unclosed tag '`+n[0].tagName+`'.`,Oo(e,n[0].tagStartPos)):n.length>0?To(`InvalidXml`,`Invalid '`+JSON.stringify(n.map(e=>e.tagName),null,4).replace(/\r?\n/g,``)+`' found.`,{line:1,col:1}):!0:To(`InvalidXml`,`Start tag expected.`,1)}function ho(e){return e===` `||e===` `||e===`
|
|
18
|
-
`||e===`\r`}function go(e,t){let n=t;for(;t<e.length;t++)if(e[t]==`?`||e[t]==` `){let r=e.substr(n,t-n);if(t>5&&r===`xml`)return To(`InvalidXml`,`XML declaration allowed only at the start of the document.`,Oo(e,t));if(e[t]==`?`&&e[t+1]==`>`){t++;break}continue}return t}function _o(e,t){if(e.length>t+5&&e[t+1]===`-`&&e[t+2]===`-`){for(t+=3;t<e.length;t++)if(e[t]===`-`&&e[t+1]===`-`&&e[t+2]===`>`){t+=2;break}}else if(e.length>t+8&&e[t+1]===`D`&&e[t+2]===`O`&&e[t+3]===`C`&&e[t+4]===`T`&&e[t+5]===`Y`&&e[t+6]===`P`&&e[t+7]===`E`){let n=1;for(t+=8;t<e.length;t++)if(e[t]===`<`)n++;else if(e[t]===`>`&&(n--,n===0))break}else if(e.length>t+9&&e[t+1]===`[`&&e[t+2]===`C`&&e[t+3]===`D`&&e[t+4]===`A`&&e[t+5]===`T`&&e[t+6]===`A`&&e[t+7]===`[`){for(t+=8;t<e.length;t++)if(e[t]===`]`&&e[t+1]===`]`&&e[t+2]===`>`){t+=2;break}}return t}var vo=`"`,yo=`'`;function bo(e,t){let n=``,r=``,i=!1;for(;t<e.length;t++){if(e[t]===vo||e[t]===yo)r===``?r=e[t]:r!==e[t]||(r=``);else if(e[t]===`>`&&r===``){i=!0;break}n+=e[t]}return r===``&&{value:n,index:t,tagClosed:i}}function xo(e){let t=[],n=e.length,r=0;for(;r<n;){let i=r;for(;r<n&&ho(e[r]);)r++;if(r>=n)break;if(e[r]===`=`){r=i+1;continue}let a=e.slice(i,r),o=r;for(;r<n&&!ho(e[r])&&e[r]!==`=`;)r++;let s=e.slice(o,r),c,l=r;for(;l<n&&ho(e[l]);)l++;l<n&&e[l]===`=`&&(c=e.slice(r,l+1),r=l+1);let u,d,f=r;for(;f<n&&ho(e[f]);)f++;if(f<n&&(e[f]===`"`||e[f]===`'`)){let t=f+1,n=e.indexOf(e[f],t);n!==-1&&(u=e[f],d=e.slice(t,n),r=n+1)}let p={startIndex:i};p[1]=a,p[2]=s,p[3]=c,p[4]=u!==void 0||void 0,p[5]=u,p[6]=d,t.push(p)}return t}function So(e,t){let n=xo(e),r={};for(let e=0;e<n.length;e++){if(n[e][1].length===0)return To(`InvalidAttr`,`Attribute '`+n[e][2]+`' has no space in starting.`,ko(n[e]));if(n[e][3]!==void 0&&n[e][4]===void 0)return To(`InvalidAttr`,`Attribute '`+n[e][2]+`' is without value.`,ko(n[e]));if(n[e][3]===void 0&&!t.allowBooleanAttributes)return To(`InvalidAttr`,`boolean attribute '`+n[e][2]+`' is not allowed.`,ko(n[e]));let i=n[e][2];if(!Eo(i))return To(`InvalidAttr`,`Attribute '`+i+`' is an invalid name.`,ko(n[e]));if(!Object.prototype.hasOwnProperty.call(r,i))r[i]=1;else return To(`InvalidAttr`,`Attribute '`+i+`' is repeated.`,ko(n[e]))}return!0}function Co(e,t){let n=/\d/;for(e[t]===`x`&&(t++,n=/[\da-fA-F]/);t<e.length;t++){if(e[t]===`;`)return t;if(!e[t].match(n))break}return-1}function wo(e,t){if(t++,e[t]===`;`)return-1;if(e[t]===`#`)return t++,Co(e,t);let n=0;for(;t<e.length;t++,n++)if(!(e[t].match(/\w/)&&n<20)){if(e[t]===`;`)break;return-1}return t}function To(e,t,n){return{err:{code:e,msg:t,line:n.line||n,col:n.col}}}function Eo(e){return co(e)}function Do(e){return co(e)}function Oo(e,t){let n=e.substring(0,t).split(/\r?\n/);return{line:n.length,col:n[n.length-1].length+1}}function ko(e){return e.startIndex+e[1].length}var Ao={cent:`¢`,pound:`£`,curren:`¤`,yen:`¥`,euro:`€`,dollar:`$`,fnof:`ƒ`,inr:`₹`,af:`؋`,birr:`ብር`,peso:`₱`,rub:`₽`,won:`₩`,yuan:`¥`,cedil:`¸`},jo={amp:`&`,apos:`'`,gt:`>`,lt:`<`,quot:`"`},Mo={nbsp:`\xA0`,copy:`©`,reg:`®`,trade:`™`,mdash:`—`,ndash:`–`,hellip:`…`,laquo:`«`,raquo:`»`,lsquo:`‘`,rsquo:`’`,ldquo:`“`,rdquo:`”`,bull:`•`,para:`¶`,sect:`§`,deg:`°`,frac12:`½`,frac14:`¼`,frac34:`¾`},No=Object.freeze({ALLOW:`allow`,BLOCK:`block`,THROW:`throw`}),Po=new Set(`!?\\\\/[]$%{}^&*()<>|+`);function Fo(e){if(e[0]===`#`)throw Error(`[EntityReplacer] Invalid character '#' in entity name: "${e}"`);for(let t of e)if(Po.has(t))throw Error(`[EntityReplacer] Invalid character '${t}' in entity name: "${e}"`);return e}function Io(...e){let t=Object.create(null);for(let n of e)if(n)for(let e of Object.keys(n)){let r=n[e];if(typeof r==`string`)t[e]=r;else if(r&&typeof r==`object`&&r.val!==void 0){let n=r.val;typeof n==`string`&&(t[e]=n)}}return t}var Lo=`external`,Ro=`base`,zo=`all`;function Bo(e){return!e||e===Lo?new Set([Lo]):e===zo?new Set([zo]):e===Ro?new Set([Ro]):Array.isArray(e)?new Set(e):new Set([Lo])}var Vo=Object.freeze({allow:0,leave:1,remove:2,throw:3}),Ho=new Set([9,10,13]);function Uo(e){if(!e)return{xmlVersion:1,onLevel:Vo.allow,nullLevel:Vo.remove};let t=e.xmlVersion===1.1?1.1:1,n=Vo[e.onNCR]??Vo.allow,r=Vo[e.nullNCR]??Vo.remove;return{xmlVersion:t,onLevel:n,nullLevel:Math.max(r,Vo.remove)}}var Wo=class{constructor(e={}){this._limit=e.limit||{},this._maxTotalExpansions=this._limit.maxTotalExpansions||0,this._maxExpandedLength=this._limit.maxExpandedLength||0,this._postCheck=typeof e.postCheck==`function`?e.postCheck:e=>e,this._limitTiers=Bo(this._limit.applyLimitsTo??Lo),this._numericAllowed=e.numericAllowed??!0,this._baseMap=Io(jo,e.namedEntities||null),this._externalMap=Object.create(null),this._inputMap=Object.create(null),this._totalExpansions=0,this._expandedLength=0,this._removeSet=new Set(e.remove&&Array.isArray(e.remove)?e.remove:[]),this._leaveSet=new Set(e.leave&&Array.isArray(e.leave)?e.leave:[]);let t=Uo(e.ncr);this._ncrXmlVersion=t.xmlVersion,this._ncrOnLevel=t.onLevel,this._ncrNullLevel=t.nullLevel,this._onExternalEntity=typeof e.onExternalEntity==`function`?e.onExternalEntity:null,this._onInputEntity=typeof e.onInputEntity==`function`?e.onInputEntity:null}_applyRegistrationHook(e,t,n,r){if(!e)return!0;let i=e(t,n);if(i===No.BLOCK)return!1;if(i===No.THROW)throw Error(`[EntityDecoder] Registration of ${r} entity "&${t};" was rejected by hook`);return!0}setExternalEntities(e){if(e)for(let t of Object.keys(e))Fo(t);if(!this._onExternalEntity){this._externalMap=Io(e);return}let t=Io(e),n=Object.create(null);for(let[e,r]of Object.entries(t))this._applyRegistrationHook(this._onExternalEntity,e,r,`external`)&&(n[e]=r);this._externalMap=n}addExternalEntity(e,t){Fo(e),typeof t==`string`&&t.indexOf(`&`)===-1&&this._applyRegistrationHook(this._onExternalEntity,e,t,`external`)&&(this._externalMap[e]=t)}addInputEntities(e){if(this._totalExpansions=0,this._expandedLength=0,!this._onInputEntity){this._inputMap=Io(e);return}let t=Io(e),n=Object.create(null);for(let[e,r]of Object.entries(t))this._applyRegistrationHook(this._onInputEntity,e,r,`input`)&&(n[e]=r);this._inputMap=n}reset(){return this._inputMap=Object.create(null),this._totalExpansions=0,this._expandedLength=0,this}setXmlVersion(e){this._ncrXmlVersion=e===1.1?1.1:1}decode(e){if(typeof e!=`string`||e.length===0||e.indexOf(`&`)===-1)return e;let t=e,n=[],r=e.length,i=0,a=0,o=this._maxTotalExpansions>0,s=this._maxExpandedLength>0,c=o||s;for(;a<r;){if(e.charCodeAt(a)!==38){a++;continue}let t=a+1;for(;t<r&&e.charCodeAt(t)!==59&&t-a<=32;)t++;if(t>=r||e.charCodeAt(t)!==59){a++;continue}let l=e.slice(a+1,t);if(l.length===0){a++;continue}let u,d;if(this._removeSet.has(l))u=``,d===void 0&&(d=Lo);else if(this._leaveSet.has(l)){a++;continue}else if(l.charCodeAt(0)===35){let e=this._resolveNCR(l);if(e===void 0){a++;continue}u=e,d=Ro}else{let e=this._resolveName(l);u=e?.value,d=e?.tier}if(u===void 0)a++;else if(a>i&&n.push(e.slice(i,a)),n.push(u),i=t+1,a=i,c&&this._tierCounts(d)){if(o&&(this._totalExpansions++,this._totalExpansions>this._maxTotalExpansions))throw Error(`[EntityReplacer] Entity expansion count limit exceeded: ${this._totalExpansions} > ${this._maxTotalExpansions}`);if(s){let e=u.length-(l.length+2);if(e>0&&(this._expandedLength+=e,this._expandedLength>this._maxExpandedLength))throw Error(`[EntityReplacer] Expanded content length limit exceeded: ${this._expandedLength} > ${this._maxExpandedLength}`)}}}i<r&&n.push(e.slice(i));let l=n.length===0?e:n.join(``);return this._postCheck(l,t)}_tierCounts(e){return this._limitTiers.has(zo)?!0:this._limitTiers.has(e)}_resolveName(e){if(e in this._inputMap)return{value:this._inputMap[e],tier:Lo};if(e in this._externalMap)return{value:this._externalMap[e],tier:Lo};if(e in this._baseMap)return{value:this._baseMap[e],tier:Ro}}_classifyNCR(e){return e===0?this._ncrNullLevel:e>=55296&&e<=57343||this._ncrXmlVersion===1&&e>=1&&e<=31&&!Ho.has(e)?Vo.remove:-1}_applyNCRAction(e,t,n){switch(e){case Vo.allow:return String.fromCodePoint(n);case Vo.remove:return``;case Vo.leave:return;case Vo.throw:throw Error(`[EntityDecoder] Prohibited numeric character reference &${t}; (U+${n.toString(16).toUpperCase().padStart(4,`0`)})`);default:return String.fromCodePoint(n)}}_resolveNCR(e){let t=e.charCodeAt(1),n;if(n=t===120||t===88?parseInt(e.slice(2),16):parseInt(e.slice(1),10),Number.isNaN(n)||n<0||n>1114111)return;let r=this._classifyNCR(n);if(!this._numericAllowed&&r<Vo.remove)return;let i=r===-1?this._ncrOnLevel:Math.max(this._ncrOnLevel,r);return this._applyNCRAction(i,e,n)}},Go=e=>uo.includes(e)?`__`+e:e,Ko={preserveOrder:!1,attributeNamePrefix:`@_`,attributesGroupName:!1,textNodeName:`#text`,ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0,unicode:!1},tagValueProcessor:function(e,t){return t},attributeValueProcessor:function(e,t){return t},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,entityDecoder:null,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(e,t,n){return e},captureMetaData:!1,maxNestedTags:100,strictReservedNames:!0,jPath:!0,onDangerousProperty:Go};function qo(e,t){if(typeof e!=`string`)return;let n=e.toLowerCase();if(uo.some(e=>n===e.toLowerCase())||fo.some(e=>n===e.toLowerCase()))throw Error(`[SECURITY] Invalid ${t}: "${e}" is a reserved JavaScript keyword that could cause prototype pollution`)}function Jo(e,t){return typeof e==`boolean`?{enabled:e,maxEntitySize:1e4,maxExpansionDepth:1e4,maxTotalExpansions:1/0,maxExpandedLength:1e5,maxEntityCount:1e3,allowedTags:null,tagFilter:null,appliesTo:`all`}:typeof e==`object`&&e?{enabled:e.enabled!==!1,maxEntitySize:Math.max(1,e.maxEntitySize??1e4),maxExpansionDepth:Math.max(1,e.maxExpansionDepth??1e4),maxTotalExpansions:Math.max(1,e.maxTotalExpansions??1/0),maxExpandedLength:Math.max(1,e.maxExpandedLength??1e5),maxEntityCount:Math.max(1,e.maxEntityCount??1e3),allowedTags:e.allowedTags??null,tagFilter:e.tagFilter??null,appliesTo:e.appliesTo??`all`}:Jo(!0)}var Yo=function(e){let t=Object.assign({},Ko,e),n=[{value:t.attributeNamePrefix,name:`attributeNamePrefix`},{value:t.attributesGroupName,name:`attributesGroupName`},{value:t.textNodeName,name:`textNodeName`},{value:t.cdataPropName,name:`cdataPropName`},{value:t.commentPropName,name:`commentPropName`}];for(let{value:e,name:t}of n)e&&qo(e,t);return t.onDangerousProperty===null&&(t.onDangerousProperty=Go),t.processEntities=Jo(t.processEntities,t.htmlEntities),t.unpairedTagsSet=new Set(t.unpairedTags),t.stopNodes&&Array.isArray(t.stopNodes)&&(t.stopNodes=t.stopNodes.map(e=>typeof e==`string`&&e.startsWith(`*.`)?`..`+e.substring(2):e)),t},Xo=typeof Symbol==`function`?Symbol(`XML Node Metadata`):`@@xmlMetadata`,Zo=class{constructor(e){this.tagname=e,this.child=[],this[`:@`]=Object.create(null)}add(e,t){e===`__proto__`&&(e=`#__proto__`),this.child.push({[e]:t})}addChild(e,t){e.tagname===`__proto__`&&(e.tagname=`#__proto__`),e[`:@`]&&Object.keys(e[`:@`]).length>0?this.child.push({[e.tagname]:e.child,":@":e[`:@`]}):this.child.push({[e.tagname]:e.child}),this.addStartIndex(t)}addStartIndex(e){e!==void 0&&(this.child[this.child.length-1][Xo]={startIndex:e})}addEndIndex(e){let t=this.child[this.child.length-1];t!==void 0&&t[Xo]!==void 0&&t[Xo].endIndex===void 0&&(t[Xo].endIndex=e)}static getMetaDataSymbol(){return Xo}},Qo=`:A-Za-z_À-ÖØ-öø-˿Ͱ-ͽͿ-҆҈--⁰-Ⰰ-、-豈-﷏ﷰ-�`,$o=Qo+`\\-\\.\\d·̀-ͯ‿-⁀`,es=`:A-Za-z_À-˿Ͱ-ͽͿ-҆҈--⁰-Ⰰ-、-豈-﷏ﷰ-�𐀀-`,ts=es+`\\-\\.\\d·̀-ͯ҇‿-⁀`,ns=(e,t,n=``)=>{let r=`[${e.replace(`:`,``)}][${t.replace(`:`,``)}]*`;return{name:RegExp(`^[${e}][${t}]*$`,n),ncName:RegExp(`^${r}$`,n),qName:RegExp(`^${r}(?::${r})?$`,n),nmToken:RegExp(`^[${t}]+$`,n),nmTokens:RegExp(`^[${t}]+(?:\\s+[${t}]+)*$`,n)}},rs=ns(Qo,$o),is=ns(es,ts,`u`),as=ns(`:A-Za-z_`,`:A-Za-z_\\-\\.\\d`),os=(e=`1.0`,t=!1)=>t?as:e===`1.1`?is:rs,ss=(e,{xmlVersion:t=`1.0`,asciiOnly:n=!1}={})=>os(t,n).qName.test(e),cs=class{constructor(e,t){this.suppressValidationErr=!e,this.options=e,this.xmlVersion=t||1}setXmlVersion(e=1){this.xmlVersion=e}readDocType(e,t){let n=Object.create(null),r=0;if(e[t+3]===`O`&&e[t+4]===`C`&&e[t+5]===`T`&&e[t+6]===`Y`&&e[t+7]===`P`&&e[t+8]===`E`){t+=9;let i=1,a=!1,o=!1,s=null,c=``;for(;t<e.length;t++)if(s!==null)e[t]===s&&(s=null),c+=e[t];else if(!a&&!o&&(e[t]===`"`||e[t]===`'`))s=e[t],c+=e[t];else if(e[t]===`<`&&!o){if(a&&us(e,`!ENTITY`,t)){t+=7;let i,a;if([i,a,t]=this.readEntityExp(e,t+1,this.suppressValidationErr),a.indexOf(`&`)===-1){if(this.options.enabled!==!1&&this.options.maxEntityCount!=null&&r>=this.options.maxEntityCount)throw Error(`Entity count (${r+1}) exceeds maximum allowed (${this.options.maxEntityCount})`);n[i]=a,r++}}else if(a&&us(e,`!ELEMENT`,t)){t+=8;let{index:n}=this.readElementExp(e,t+1);t=n}else if(a&&us(e,`!ATTLIST`,t))t+=8;else if(a&&us(e,`!NOTATION`,t)){t+=9;let{index:n}=this.readNotationExp(e,t+1,this.suppressValidationErr);t=n}else if(us(e,`!--`,t))o=!0;else throw Error(`Invalid DOCTYPE`);i++,c=``}else if(e[t]===`>`){if(o?e[t-1]===`-`&&e[t-2]===`-`&&(o=!1,i--):i--,i===0)break}else e[t]===`[`?a=!0:c+=e[t];if(s!==null||i!==0)throw Error(`Unclosed DOCTYPE`)}else throw Error(`Invalid Tag instead of DOCTYPE`);return{entities:n,i:t}}readEntityExp(e,t){t=ls(e,t);let n=t;for(;t<e.length&&!/\s/.test(e[t])&&e[t]!==`"`&&e[t]!==`'`;)t++;let r=e.substring(n,t);if(ds(r,{xmlVersion:this.xmlVersion}),t=ls(e,t),!this.suppressValidationErr){if(e.substring(t,t+6).toUpperCase()===`SYSTEM`)throw Error(`External entities are not supported`);if(e[t]===`%`)throw Error(`Parameter entities are not supported`)}let i=``;if([t,i]=this.readIdentifierVal(e,t,`entity`),this.options.enabled!==!1&&this.options.maxEntitySize!=null&&i.length>this.options.maxEntitySize)throw Error(`Entity "${r}" size (${i.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`);return t--,[r,i,t]}readNotationExp(e,t){t=ls(e,t);let n=t;for(;t<e.length&&!/\s/.test(e[t]);)t++;let r=e.substring(n,t);!this.suppressValidationErr&&ds(r,{xmlVersion:this.xmlVersion}),t=ls(e,t);let i=e.substring(t,t+6).toUpperCase();if(!this.suppressValidationErr&&i!==`SYSTEM`&&i!==`PUBLIC`)throw Error(`Expected SYSTEM or PUBLIC, found "${i}"`);t+=i.length,t=ls(e,t);let a=null,o=null;if(i===`PUBLIC`)[t,a]=this.readIdentifierVal(e,t,`publicIdentifier`),t=ls(e,t),(e[t]===`"`||e[t]===`'`)&&([t,o]=this.readIdentifierVal(e,t,`systemIdentifier`));else if(i===`SYSTEM`&&([t,o]=this.readIdentifierVal(e,t,`systemIdentifier`),!this.suppressValidationErr&&!o))throw Error(`Missing mandatory system identifier for SYSTEM notation`);return{notationName:r,publicIdentifier:a,systemIdentifier:o,index:--t}}readIdentifierVal(e,t,n){let r=``,i=e[t];if(i!==`"`&&i!==`'`)throw Error(`Expected quoted string, found "${i}"`);t++;let a=t;for(;t<e.length&&e[t]!==i;)t++;if(r=e.substring(a,t),e[t]!==i)throw Error(`Unterminated ${n} value`);return t++,[t,r]}readElementExp(e,t){t=ls(e,t);let n=t;for(;t<e.length&&!/\s/.test(e[t]);)t++;let r=e.substring(n,t);if(!this.suppressValidationErr&&!ss(r,{xmlVersion:this.xmlVersion}))throw Error(`Invalid element name: "${r}"`);t=ls(e,t);let i=``;if(e[t]===`E`&&us(e,`MPTY`,t))t+=4;else if(e[t]===`A`&&us(e,`NY`,t))t+=2;else if(e[t]===`(`){t++;let n=t;for(;t<e.length&&e[t]!==`)`;)t++;if(i=e.substring(n,t),e[t]!==`)`)throw Error(`Unterminated content model`)}else if(!this.suppressValidationErr)throw Error(`Invalid Element Expression, found "${e[t]}"`);return{elementName:r,contentModel:i.trim(),index:t}}readAttlistExp(e,t){t=ls(e,t);let n=t;for(;t<e.length&&!/\s/.test(e[t]);)t++;let r=e.substring(n,t);for(ds(r,{xmlVersion:this.xmlVersion}),t=ls(e,t),n=t;t<e.length&&!/\s/.test(e[t]);)t++;let i=e.substring(n,t);if(!ds(i,{xmlVersion:this.xmlVersion}))throw Error(`Invalid attribute name: "${i}"`);t=ls(e,t);let a=``;if(e.substring(t,t+8).toUpperCase()===`NOTATION`){if(a=`NOTATION`,t+=8,t=ls(e,t),e[t]!==`(`)throw Error(`Expected '(', found "${e[t]}"`);t++;let n=[];for(;t<e.length&&e[t]!==`)`;){let r=t;for(;t<e.length&&e[t]!==`|`&&e[t]!==`)`;)t++;let i=e.substring(r,t);if(i=i.trim(),!ds(i,{xmlVersion:this.xmlVersion}))throw Error(`Invalid notation name: "${i}"`);n.push(i),e[t]===`|`&&(t++,t=ls(e,t))}if(e[t]!==`)`)throw Error(`Unterminated list of notations`);t++,a+=` (`+n.join(`|`)+`)`}else{let n=t;for(;t<e.length&&!/\s/.test(e[t]);)t++;if(a+=e.substring(n,t),!this.suppressValidationErr&&![`CDATA`,`ID`,`IDREF`,`IDREFS`,`ENTITY`,`ENTITIES`,`NMTOKEN`,`NMTOKENS`].includes(a.toUpperCase()))throw Error(`Invalid attribute type: "${a}"`)}t=ls(e,t);let o=``;return e.substring(t,t+8).toUpperCase()===`#REQUIRED`?(o=`#REQUIRED`,t+=8):e.substring(t,t+7).toUpperCase()===`#IMPLIED`?(o=`#IMPLIED`,t+=7):[t,o]=this.readIdentifierVal(e,t,`ATTLIST`),{elementName:r,attributeName:i,attributeType:a,defaultValue:o,index:t}}},ls=(e,t)=>{for(;t<e.length&&/\s/.test(e[t]);)t++;return t};function us(e,t,n){for(let r=0;r<t.length;r++)if(t[r]!==e[n+r+1])return!1;return!0}function ds(e,t){if(ss(e,{xmlVersion:t}))return e;throw Error(`Invalid entity name ${e}`)}var fs=[48,1632,1776,2406,2534,2662,2790,2918,3046,3174,3302,3430,3558,3664,3792,3872,4160,4240,6112,6160,6470,6608,6784,6800,6992,7088,7232,7248,65296,120782,120792,120802,120812,120822,66720,68912,69734,69872,69942,70096,70384,70736,70864,71248,71360,71472,71904,72016,72688,72784,73040,73120,73552,92768,92864,93008,123200,123632,124144,125264,130032],ps=new Map,ms=65535,hs=1632,gs=new Uint8Array(63904).fill(255);for(let e of fs)for(let t=0;t<10;t++){let n=e+t;n<=ms?gs[n-hs]=t:ps.set(n,t)}var _s=48,vs=57,ys=45,bs=new Set([8722,65293,65123]);function xs(e){if(typeof e!=`string`)return e;let t=e.length;if(t===0)return e;let n=-1;for(let r=0;r<t;r++){let i=e.charCodeAt(r);if(!(i>=_s&&i<=vs||i===ys)){if(i<1632){if(bs.has(i)){n=r;break}}else if(i>=55296&&i<=56319){if(r+1<t){let t=e.charCodeAt(r+1);if(t>=56320&&t<=57343){let e=65536+(i-55296<<10)+(t-56320);if(ps.has(e)){n=r;break}}}}else if(gs[i-1632]!==255||bs.has(i)){n=r;break}}}if(n===-1)return e;let r=[];n>0&&r.push(e.slice(0,n));for(let i=n;i<t;i++){let n=e.charCodeAt(i);if(n>=_s&&n<=vs||n===ys){r.push(e[i]);continue}if(n<1632){r.push(bs.has(n)?`-`:e[i]);continue}if(n>=55296&&n<=56319){if(i+1<t){let t=e.charCodeAt(i+1);if(t>=56320&&t<=57343){let e=65536+(n-55296<<10)+(t-56320),a=ps.get(e);if(a!==void 0){r.push(String.fromCharCode(a+48)),i++;continue}}}r.push(e[i]);continue}if(bs.has(n)){r.push(`-`);continue}let a=gs[n-hs];r.push(a===255?e[i]:String.fromCharCode(a+48))}return r.join(``)}var Ss=/^[-+]?0x[a-fA-F0-9]+$/,Cs=/^0b[01]+$/,ws=/^0o[0-7]+$/,Ts=/^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/,Es={hex:!0,binary:!1,octal:!1,leadingZeros:!0,decimalPoint:`.`,eNotation:!0,infinity:`original`,unicode:!1};function Ds(e,t={}){if(t=Object.assign({},Es,t),!e||typeof e!=`string`)return e;let n=e.trim();if(n.length===0||t.skipLike!==void 0&&t.skipLike.test(n))return e;if(n===`0`||t.unicode&&(n=xs(n),n===`0`))return 0;if(t.hex&&Ss.test(n))return js(n,16);if(t.binary&&Cs.test(n))return js(n,2);if(t.octal&&ws.test(n))return js(n,8);if(!isFinite(n)){let r=Number(n);return Number.isNaN(r)?e:Ms(e,r,t)}if(n.includes(`e`)||n.includes(`E`))return ks(e,n,t);{let r=Ts.exec(n);if(r){let i=r[1]||``,a=r[2],o=As(r[3]),s=i?n[a.length+1]===`.`:n[a.length]===`.`;if(!t.leadingZeros&&(a.length>1||a.length===1&&!s))return e;{let r=Number(n),s=String(r);if(r===0)return r;if(s.search(/[eE]/)!==-1)return t.eNotation?r:e;if(n.indexOf(`.`)!==-1)return s===`0`||s===o||s===`${i}${o}`?r:e;let c=a?o:n;return a?c===s||i+c===s?r:e:c===s||c===i+s?r:e}}return e}}var Os=/^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;function ks(e,t,n){if(!n.eNotation)return e;let r=t.match(Os);if(r){let i=r[1]||``,a=r[3].indexOf(`e`)===-1?`E`:`e`,o=r[2],s=i?t[o.length+1]===a:t[o.length]===a;return o.length>1&&s?e:o.length===1&&(r[3].startsWith(`.${a}`)||r[3][0]===a)?Number(t):o.length>0?n.leadingZeros&&!s?Number(t):e:Number(t)}return e}function As(e){if(e&&e.indexOf(`.`)!==-1){let t=e.length;for(;t>0&&e.charCodeAt(t-1)===48;)t--;return e=e.slice(0,t),e===`.`?e=`0`:e[0]===`.`?e=`0`+e:e[e.length-1]===`.`&&(e=e.substring(0,e.length-1)),e}return e}function js(e,t){let n=e.trim();if((t===2||t===8)&&(e=n.substring(2)),parseInt)return parseInt(e,t);if(Number.parseInt)return Number.parseInt(e,t);if(window&&window.parseInt)return window.parseInt(e,t);throw Error(`parseInt, Number.parseInt, window.parseInt are not supported`)}function Ms(e,t,n){let r=t===1/0;switch(n.infinity.toLowerCase()){case`null`:return null;case`infinity`:return t;case`string`:return r?`Infinity`:`-Infinity`;default:return e}}function Ns(e){return typeof e==`function`?e:Array.isArray(e)?t=>{for(let n of e)if(typeof n==`string`&&t===n||n instanceof RegExp&&n.test(t))return!0}:()=>!1}var Ps=class{constructor(e,t={},n){this.pattern=e,this.separator=t.separator||`.`,this.segments=this._parse(e),this.data=n,this._hasDeepWildcard=this.segments.some(e=>e.type===`deep-wildcard`),this._hasAttributeCondition=this.segments.some(e=>e.attrName!==void 0),this._hasPositionSelector=this.segments.some(e=>e.position!==void 0)}_parse(e){let t=[],n=0,r=``;for(;n<e.length;)e[n]===this.separator?n+1<e.length&&e[n+1]===this.separator?(r.trim()&&(t.push(this._parseSegment(r.trim())),r=``),t.push({type:`deep-wildcard`}),n+=2):(r.trim()&&t.push(this._parseSegment(r.trim())),r=``,n++):(r+=e[n],n++);return r.trim()&&t.push(this._parseSegment(r.trim())),t}_parseSegment(e){let t={type:`tag`},n=null,r=e,i=e.match(/^([^\[]+)(\[[^\]]*\])(.*)$/);if(i&&(r=i[1]+i[3],i[2])){let e=i[2].slice(1,-1);e&&(n=e)}let a,o=r;if(r.includes(`::`)){let t=r.indexOf(`::`);if(a=r.substring(0,t).trim(),o=r.substring(t+2).trim(),!a)throw Error(`Invalid namespace in pattern: ${e}`)}let s,c=null;if(o.includes(`:`)){let e=o.lastIndexOf(`:`),t=o.substring(0,e).trim(),n=o.substring(e+1).trim();[`first`,`last`,`odd`,`even`].includes(n)||/^nth\(\d+\)$/.test(n)?(s=t,c=n):s=o}else s=o;if(!s)throw Error(`Invalid segment pattern: ${e}`);if(t.tag=s,a&&(t.namespace=a),n){if(n.includes(`=`)){let e=n.indexOf(`=`);t.attrName=n.substring(0,e).trim(),t.attrValue=n.substring(e+1).trim()}else t.attrName=n.trim()}if(c){let e=c.match(/^nth\((\d+)\)$/);e?(t.position=`nth`,t.positionValue=parseInt(e[1],10)):t.position=c}return t}get length(){return this.segments.length}hasDeepWildcard(){return this._hasDeepWildcard}hasAttributeCondition(){return this._hasAttributeCondition}hasPositionSelector(){return this._hasPositionSelector}toString(){return this.pattern}},Fs=class{constructor(){this._byDepthAndTag=new Map,this._wildcardByDepth=new Map,this._deepWildcards=[],this._deepByTerminalTag=new Map,this._patterns=new Set,this._sealed=!1}add(e){if(this._sealed)throw TypeError(`ExpressionSet is sealed. Create a new ExpressionSet to add more expressions.`);if(this._patterns.has(e.pattern))return this;if(this._patterns.add(e.pattern),e.hasDeepWildcard()){let t=e.segments[e.segments.length-1];if(t&&t.type!==`deep-wildcard`&&t.tag!==`*`){let n=t.tag;this._deepByTerminalTag.has(n)||this._deepByTerminalTag.set(n,[]),this._deepByTerminalTag.get(n).push(e)}else this._deepWildcards.push(e);return this}let t=e.length,n=e.segments[e.segments.length-1]?.tag;if(!n||n===`*`)this._wildcardByDepth.has(t)||this._wildcardByDepth.set(t,[]),this._wildcardByDepth.get(t).push(e);else{let r=`${t}:${n}`;this._byDepthAndTag.has(r)||this._byDepthAndTag.set(r,[]),this._byDepthAndTag.get(r).push(e)}return this}addAll(e){for(let t of e)this.add(t);return this}has(e){return this._patterns.has(e.pattern)}get size(){return this._patterns.size}seal(){return this._sealed=!0,this}get isSealed(){return this._sealed}matchesAny(e){return this.findMatch(e)!==null}findMatch(e){let t=e.getDepth(),n=e.getCurrentTag(),r=`${t}:${n}`,i=this._byDepthAndTag.get(r);if(i){for(let t=0;t<i.length;t++)if(e.matches(i[t]))return i[t]}let a=this._wildcardByDepth.get(t);if(a){for(let t=0;t<a.length;t++)if(e.matches(a[t]))return a[t]}let o=this._deepByTerminalTag.get(n);if(o){for(let t=0;t<o.length;t++)if(e.matches(o[t]))return o[t]}for(let t=0;t<this._deepWildcards.length;t++)if(e.matches(this._deepWildcards[t]))return this._deepWildcards[t];return null}},Is=class{constructor(e){this._matcher=e}get separator(){return this._matcher.separator}getCurrentTag(){let e=this._matcher.path;return e.length>0?e[e.length-1].tag:void 0}getCurrentNamespace(){let e=this._matcher.path;return e.length>0?e[e.length-1].namespace:void 0}getAttrValue(e){let t=this._matcher.path;if(t.length!==0)return t[t.length-1].values?.[e]}hasAttr(e){let t=this._matcher.path;if(t.length===0)return!1;let n=t[t.length-1];return n.values!==void 0&&e in n.values}getAnyParentAttr(e){return this._matcher.getAnyParentAttr(e)}hasAnyParentAttr(e){return this._matcher.hasAnyParentAttr(e)}getPosition(){let e=this._matcher.path;return e.length===0?-1:e[e.length-1].position??0}getCounter(){let e=this._matcher.path;return e.length===0?-1:e[e.length-1].counter??0}getIndex(){return this.getPosition()}getDepth(){return this._matcher.path.length}toString(e,t=!0){return this._matcher.toString(e,t)}toArray(){return this._matcher.path.map(e=>e.tag)}matches(e){return this._matcher.matches(e)}matchesAny(e){return e.matchesAny(this._matcher)}},Ls=class{constructor(e={}){this.separator=e.separator||`.`,this.path=[],this.siblingStacks=[],this._pathStringCache=null,this._view=new Is(this),this._keptAttrs=[]}push(e,t=null,n=null,r=null){this._pathStringCache=null,this.path.length>0&&(this.path[this.path.length-1].values=void 0);let i=this.path.length,a=this.siblingStacks[i];a||(a={counts:new Map,total:0},this.siblingStacks[i]=a);let o=n?`${n}:${e}`:e,s=a.counts.get(o)||0,c=a.total;a.counts.set(o,s+1),a.total++;let l={tag:e,position:c,counter:s};n!=null&&(l.namespace=n),t!=null&&(l.values=t),this.path.push(l);let u=this.path.length,d=r===null?null:r.keep;if(d!=null&&d.length>0&&t)for(let e=0;e<d.length;e++){let n=d[e];t[n]!==void 0&&this._keptAttrs.push({depth:u,name:n,value:t[n]})}}pop(){if(this.path.length===0)return;this._pathStringCache=null;let e=this.path.pop();this.siblingStacks.length>this.path.length+1&&(this.siblingStacks.length=this.path.length+1);let t=this.path.length+1;for(;this._keptAttrs.length>0&&this._keptAttrs[this._keptAttrs.length-1].depth>=t;)this._keptAttrs.pop();return e}updateCurrent(e){if(this.path.length>0){let t=this.path[this.path.length-1];e!=null&&(t.values=e)}}getCurrentTag(){return this.path.length>0?this.path[this.path.length-1].tag:void 0}getCurrentNamespace(){return this.path.length>0?this.path[this.path.length-1].namespace:void 0}getAttrValue(e){if(this.path.length!==0)return this.path[this.path.length-1].values?.[e]}hasAttr(e){if(this.path.length===0)return!1;let t=this.path[this.path.length-1];return t.values!==void 0&&e in t.values}getAnyParentAttr(e){let t=this._keptAttrs;for(let n=t.length-1;n>=0;n--)if(t[n].name===e)return t[n].value}hasAnyParentAttr(e){let t=this._keptAttrs;for(let n=t.length-1;n>=0;n--)if(t[n].name===e)return!0;return!1}getPosition(){return this.path.length===0?-1:this.path[this.path.length-1].position??0}getCounter(){return this.path.length===0?-1:this.path[this.path.length-1].counter??0}getIndex(){return this.getPosition()}getDepth(){return this.path.length}toString(e,t=!0){let n=e||this.separator;if(n===this.separator&&t===!0){if(this._pathStringCache!==null)return this._pathStringCache;let e=this.path.map(e=>e.namespace?`${e.namespace}:${e.tag}`:e.tag).join(n);return this._pathStringCache=e,e}return this.path.map(e=>t&&e.namespace?`${e.namespace}:${e.tag}`:e.tag).join(n)}toArray(){return this.path.map(e=>e.tag)}reset(){this._pathStringCache=null,this.path=[],this.siblingStacks=[],this._keptAttrs=[]}matches(e){let t=e.segments;return t.length===0?!1:e.hasDeepWildcard()?this._matchWithDeepWildcard(t):this._matchSimple(t)}_matchSimple(e){if(this.path.length!==e.length)return!1;for(let t=0;t<e.length;t++)if(!this._matchSegment(e[t],this.path[t],t===this.path.length-1))return!1;return!0}_matchWithDeepWildcard(e){let t=this.path.length-1,n=e.length-1;for(;n>=0&&t>=0;){let r=e[n];if(r.type===`deep-wildcard`){if(n--,n<0)return!0;let r=e[n],i=!1;for(let e=t;e>=0;e--)if(this._matchSegment(r,this.path[e],e===this.path.length-1)){t=e-1,n--,i=!0;break}if(!i)return!1}else{if(!this._matchSegment(r,this.path[t],t===this.path.length-1))return!1;t--,n--}}return n<0}_matchSegment(e,t,n){if(e.tag!==`*`&&e.tag!==t.tag||e.namespace!==void 0&&e.namespace!==`*`&&e.namespace!==t.namespace||e.attrName!==void 0&&(!n||!t.values||!(e.attrName in t.values)||e.attrValue!==void 0&&String(t.values[e.attrName])!==String(e.attrValue)))return!1;if(e.position!==void 0){if(!n)return!1;let r=t.counter??0;if(e.position===`first`&&r!==0||e.position===`odd`&&r%2!=1||e.position===`even`&&r%2!=0||e.position===`nth`&&r!==e.positionValue)return!1}return!0}matchesAny(e){return e.matchesAny(this)}snapshot(){return{path:this.path.map(e=>({...e})),siblingStacks:this.siblingStacks.map(e=>e&&{counts:new Map(e.counts),total:e.total}),keptAttrs:this._keptAttrs.map(e=>({...e}))}}restore(e){this._pathStringCache=null,this.path=e.path.map(e=>({...e})),this.siblingStacks=e.siblingStacks.map(e=>e&&{counts:new Map(e.counts),total:e.total}),this._keptAttrs=(e.keptAttrs||[]).map(e=>({...e}))}readOnly(){return this._view}},Rs=[{id:`html-script-open`,description:`<script opening tag`,pattern:/<script[\s>/]/i},{id:`html-script-close`,description:`<\/script closing tag`,pattern:/<\/script[\s>]/i},{id:`html-javascript-protocol`,description:`javascript: URI scheme (with optional whitespace/encoding)`,pattern:/j[\t\n\r ]*a[\t\n\r ]*v[\t\n\r ]*a[\t\n\r ]*s[\t\n\r ]*c[\t\n\r ]*r[\t\n\r ]*i[\t\n\r ]*p[\t\n\r ]*t[\t\n\r ]*:/i},{id:`html-vbscript-protocol`,description:`vbscript: URI scheme`,pattern:/vbscript[\t\n\r ]*:/i},{id:`html-data-html`,description:`data:text/html URI — can execute scripts in browsers`,pattern:/data[\t\n\r ]*:[\t\n\r ]*text\/html/i},{id:`html-data-xhtml`,description:`data:application/xhtml+xml URI`,pattern:/data[\t\n\r ]*:[\t\n\r ]*application\/xhtml/i},{id:`html-data-svg`,description:`data:image/svg+xml URI — can execute scripts`,pattern:/data[\t\n\r ]*:[\t\n\r ]*image\/svg\+xml/i},{id:`html-inline-event-handler`,description:`Inline event handler attributes: onclick=, onerror=, onload=, etc.`,pattern:/\bon\w{1,30}\s*=/i},{id:`html-entity-obfuscated-script`,description:`HTML-entity-encoded <script (e.g. <script or <script)`,pattern:/(?:�*3[Cc];?|�*60;?|<)\s*script/i},{id:`html-entity-obfuscated-javascript`,description:`HTML-entity-encoded javascript: (partial — catches common j or j for "j")`,pattern:/(?:�*6[Aa];?|�*106;?)\s*(?:�*61;?|a)[\s\S]{0,80}script\s*:/i},{id:`html-style-expression`,description:`CSS expression() — IE-era code execution in style attributes`,pattern:/style[\s\S]{0,20}expression\s*\(/i},{id:`html-object-embed`,description:`<object or <embed tags that can load active content`,pattern:/<(?:object|embed)[\s>/]/i},{id:`html-base-tag`,description:`<base href= — can hijack all relative URLs on a page`,pattern:/<base[\s>]/i},{id:`html-meta-refresh`,description:`<meta http-equiv="refresh" — can redirect users`,pattern:/<meta[\s\S]{0,40}http-equiv[\s\S]{0,20}refresh/i},{id:`html-srcdoc`,description:`srcdoc= attribute on iframes — embeds HTML that can run scripts`,pattern:/srcdoc\s*=/i},{id:`html-iframe`,description:`<iframe tag`,pattern:/<iframe[\s>/]/i},{id:`html-form`,description:`<form tag — can be used for phishing / credential harvesting injection`,pattern:/<form[\s>/]/i}],zs=[{id:`xml-cdata-injection`,description:`CDATA section injection: <![CDATA[ breaks out of text node context`,pattern:/<!\[CDATA\[/i},{id:`xml-cdata-close`,description:`CDATA close sequence: ]]> can terminate an enclosing CDATA section`,pattern:/\]\]>/},{id:`xml-processing-instruction`,description:`XML processing instruction: <?xml-stylesheet or <?php etc.`,pattern:/<\?(?:xml[\- ]|php|asp)/i},{id:`xml-doctype-injection`,description:`DOCTYPE declaration embedded in content — can define entities`,pattern:/<!DOCTYPE(?:[\s[]|$)/i},{id:`xml-entity-system`,description:`SYSTEM keyword — used in external entity declarations (XXE)`,pattern:/\bSYSTEM\s+["']/i},{id:`xml-entity-public`,description:`PUBLIC keyword — used in external entity declarations (XXE)`,pattern:/\bPUBLIC\s+["']/i},{id:`xml-entity-declaration`,description:`<!ENTITY declaration — defines entities, potential XXE or entity expansion`,pattern:/<!ENTITY[\s%]/i},{id:`xml-billion-laughs`,description:`Entity reference chaining / billion laughs: repeated &eX; style references`,pattern:/(?:&\w{1,20};){3,}/},{id:`xml-namespace-confusion`,description:`xmlns: attribute injection — can redefine namespaces to confuse parsers`,pattern:/\bxmlns(?::\w{1,40})?\s*=/i},{id:`xml-comment-injection`,description:`<!-- comment injection — can hide content from some parsers`,pattern:/<!--/},{id:`xml-comment-close`,description:`--> closes an enclosing XML comment`,pattern:/-->/},{id:`xml-pi-close`,description:`?> closes an enclosing processing instruction`,pattern:/\?>/}],Bs=[{id:`svg-script-element`,description:`<script element inside SVG executes JavaScript`,pattern:/<script[\s>/]/i},{id:`svg-xlink-href-javascript`,description:`xlink:href with javascript: — classic SVG XSS via <a> or <use>`,pattern:/xlink\s*:\s*href\s*=\s*["']?\s*javascript\s*:/i},{id:`svg-href-javascript`,description:`href= with javascript: in SVG context (<a>, <animate>, etc.)`,pattern:/href\s*=\s*["']?\s*javascript\s*:/i},{id:`svg-foreignobject`,description:`<foreignObject embeds HTML inside SVG — can execute scripts`,pattern:/<foreignObject[\s>/]/i},{id:`svg-use-external`,description:`<use xlink:href or href pointing to external resource (non-fragment URL)`,pattern:/<use[\s\S]{0,60}(?:xlink\s*:\s*)?href\s*=\s*(?:["'][^#]|[^"'#\s>])/i},{id:`svg-animate-href`,description:`<animate attributeName="href" — can dynamically change href to javascript:`,pattern:/<animate[\s\S]{0,80}attributeName\s*=\s*["'][\s]*href["']/i},{id:`svg-animate-xlinkhref`,description:`<animate attributeName="xlink:href"`,pattern:/<animate[\s\S]{0,80}attributeName\s*=\s*["'][\s]*xlink\s*:\s*href["']/i},{id:`svg-set-javascript`,description:`<set to="javascript:..." — sets an attribute to a javascript: URI`,pattern:/<set[\s\S]{0,80}to\s*=\s*["']?\s*javascript\s*:/i},{id:`svg-event-handler`,description:`SVG-specific event handler attributes: onload=, onerror=, onactivate=, etc.`,pattern:/\bon(?:load|error|activate|begin|end|repeat|focus|blur|click|mouse\w{1,20}|key\w{1,20})\s*=/i},{id:`svg-handler-generic`,description:`Generic on* handler catch-all for SVG attributes`,pattern:/\bon\w{1,30}\s*=/i},{id:`svg-filter-feimage`,description:`<feImage href= — filter primitive that can load external resources`,pattern:/<feImage[\s\S]{0,80}(?:xlink\s*:\s*)?href\s*=/i},{id:`svg-image-external`,description:`<image xlink:href with http/https or javascript protocol`,pattern:/<image[\s\S]{0,80}(?:xlink\s*:\s*)?href\s*=\s*["']?\s*(?:https?|javascript)\s*:/i},{id:`svg-style-javascript`,description:`style= attribute containing javascript: (e.g. background:url(javascript:...))`,pattern:/style\s*=[\s\S]{0,60}javascript\s*:/i}],Vs=[{id:`sql-block-comment-open`,description:`SQL block comment open: /* ... */ — unusual in legitimate user text`,pattern:/\/\*/},{id:`sql-union-select`,description:`UNION SELECT — most common SQL injection aggregation attack`,pattern:/\bUNION\s{1,20}(?:ALL\s{1,20})?SELECT\b/i},{id:`sql-drop-table`,description:`DROP TABLE — destructive DDL injection`,pattern:/\bDROP\s{1,20}TABLE\b/i},{id:`sql-drop-database`,description:`DROP DATABASE — destructive DDL injection`,pattern:/\bDROP\s{1,20}DATABASE\b/i},{id:`sql-insert-into`,description:`INSERT INTO — data injection`,pattern:/\bINSERT\s{1,20}INTO\b/i},{id:`sql-delete-from`,description:`DELETE FROM — data deletion injection`,pattern:/\bDELETE\s{1,20}FROM\b/i},{id:`sql-update-set`,description:`UPDATE ... SET — data modification injection`,pattern:/\bUPDATE\b[\s\S]{1,60}\bSET\b/i},{id:`sql-exec-xp`,description:`EXEC xp_ — MSSQL extended stored procedure execution`,pattern:/\bEXEC(?:UTE)?\s{1,20}xp_/i},{id:`sql-tautology-string`,description:`Classic string tautology: ' OR '1'='1 or " OR "1"="1"`,pattern:/'\s{0,10}OR\s{0,10}'[^']{0,20}'\s*=\s*'[^']{0,20}/i},{id:`sql-tautology-numeric`,description:`Numeric tautology: OR 1=1`,pattern:/\bOR\s{1,10}1\s*=\s*1\b/i},{id:`sql-always-true-zero`,description:`Numeric tautology: OR 0=0`,pattern:/\bOR\s{1,10}0\s*=\s*0\b/i},{id:`sql-sleep-benchmark`,description:`Time-based blind injection: SLEEP() or BENCHMARK()`,pattern:/\b(?:SLEEP|BENCHMARK)\s*\(/i},{id:`sql-waitfor-delay`,description:`MSSQL time-based blind injection: WAITFOR DELAY`,pattern:/\bWAITFOR\s{1,20}DELAY\b/i},{id:`sql-char-function`,description:`CHAR() function — used to obfuscate injected strings`,pattern:/\bCHAR\s*\(\s*\d{1,3}/i},{id:`sql-information-schema`,description:`INFORMATION_SCHEMA — reconnaissance query for table/column enumeration`,pattern:/\bINFORMATION_SCHEMA\b/i}],Hs=[{id:`shell-path-traversal-unix`,description:`Unix path traversal: ../ — climbing the directory tree`,pattern:/\.\.\//},{id:`shell-path-traversal-windows`,description:`Windows path traversal: ..\\ — climbing the directory tree`,pattern:/\.\.\\/},{id:`shell-path-traversal-encoded`,description:`URL-encoded path traversal: %2e%2e or %2f variants`,pattern:/%2e%2e|%2f\.\.|\.\.%2f/i},{id:`shell-null-byte`,description:`Null byte injection: \\x00 or %00 — truncates strings in C-backed functions`,pattern:/\x00|%00/},{id:`shell-semicolon`,description:`Semicolon command separator: cmd1; cmd2`,pattern:/;/},{id:`shell-pipe`,description:`Pipe operator: cmd1 | cmd2`,pattern:/\|/},{id:`shell-and-operator`,description:`AND operator: cmd1 && cmd2`,pattern:/&&/},{id:`shell-or-operator`,description:`OR operator: cmd1 || cmd2`,pattern:/\|\|/},{id:`shell-backtick`,description:"Backtick command substitution: `cmd`",pattern:/`/},{id:`shell-dollar-paren`,description:`Dollar-paren command substitution: $(cmd)`,pattern:/\$\(/},{id:`shell-dollar-brace`,description:"Dollar-brace variable expansion: ${var} — can be abused for injection",pattern:/\$\{/},{id:`shell-redirect-out`,description:`Output redirection: cmd > file or cmd >> file`,pattern:/>{1,2}/},{id:`shell-redirect-in`,description:`Input redirection: cmd < file`,pattern:/</},{id:`shell-newline-injection`,description:`Newline injection: \\n or \\r — can inject new shell commands`,pattern:/[\n\r]/},{id:`shell-glob-star`,description:`Glob expansion: * or ? — can expand to unintended files`,pattern:/[/\\][*?]/},{id:`shell-absolute-root`,description:`Absolute root path injection: string starting with / or \\ (Windows UNC)`,pattern:/^(?:\/|\\\\)/},{id:`shell-windows-drive`,description:`Windows drive letter path injection: C:\\ or D:/`,pattern:/^[a-zA-Z]:[/\\]/},{id:`shell-curl-wget`,description:`curl/wget with URL or flags — can exfiltrate data or download payloads`,pattern:/\b(?:curl|wget)\s+(?:https?:\/\/|ftp:\/\/|-)/i}],Us=[{id:`redos-nested-quantifier-plus`,description:`Nested + quantifier inside a group with outer quantifier: (a+)+, (.+b)*, etc.`,pattern:/\([^)]*\+[^)]*\)[+*]/},{id:`redos-nested-quantifier-star`,description:`Nested * quantifier: (a*)* or (a*)+ — catastrophic backtracking`,pattern:/\([^)]*\*[^)]*\)[*+]/},{id:`redos-nested-groups`,description:`Doubly nested quantified groups: ((a+)+) — guaranteed catastrophic`,pattern:/\(\([^)]{0,40}\)[+*]\)[+*]/},{id:`redos-alternation-overlap`,description:`Overlapping alternation under quantifier: (a|a)+ — ambiguous NFA paths`,pattern:/\(([^|()]{1,20})\|(?:\1)(?:\|[^|()]{1,20}){0,5}\)[+*?]{1,2}/},{id:`redos-star-plus-concat`,description:`(x*x)+ pattern — triggers super-linear backtracking`,pattern:/\([^)]{0,10}\*[^)]{0,10}\)[+*]/},{id:`redos-dot-star-greedy`,description:`(.*){n,} or (.+){n,} — repeated greedy dot quantifiers`,pattern:/\(\.[*+]\)\{?\d/},{id:`redos-large-repetition`,description:`Very large fixed or range repetition count {1000,} or {1000,n} — denial of service via backtracking`,pattern:/\{\d{4,}(?:,\d*)?\}/},{id:`redos-catastrophic-alternation`,description:`Long alternation with many similar branches — polynomial backtracking risk`,pattern:/\([^)]{0,200}(?:\|[^|)]{0,50}){9,}\)/}],Ws=`["'\\s]*:`,Gs=[{id:`nosql-where-operator`,description:`$where — executes arbitrary JavaScript server-side in MongoDB`,pattern:RegExp(`\\$where${Ws}`,`i`)},{id:`nosql-ne-operator`,description:`$ne — "not equal" operator used to bypass equality checks`,pattern:RegExp(`\\$ne${Ws}`,`i`)},{id:`nosql-gt-operator`,description:`$gt — "greater than" used to bypass password/value checks`,pattern:RegExp(`\\$gte?${Ws}`,`i`)},{id:`nosql-lt-operator`,description:`$lt / $lte — "less than" bypass variants`,pattern:RegExp(`\\$lte?${Ws}`,`i`)},{id:`nosql-regex-operator`,description:`$regex — can be used to extract data character by character (blind injection)`,pattern:RegExp(`\\$regex${Ws}`,`i`)},{id:`nosql-or-operator`,description:`$or — logical OR; used to create always-true conditions`,pattern:RegExp(`\\$or${Ws}\\s*\\[`,`i`)},{id:`nosql-and-operator`,description:`$and — logical AND operator injection`,pattern:RegExp(`\\$and${Ws}\\s*\\[`,`i`)},{id:`nosql-nor-operator`,description:`$nor — logical NOR operator injection`,pattern:RegExp(`\\$nor${Ws}\\s*\\[`,`i`)},{id:`nosql-exists-operator`,description:`$exists — can enumerate fields to determine schema`,pattern:RegExp(`\\$exists${Ws}`,`i`)},{id:`nosql-in-operator`,description:`$in — matches any value in a list; can enumerate values`,pattern:RegExp(`\\$in${Ws}\\s*\\[`,`i`)},{id:`nosql-expr-operator`,description:`$expr — allows aggregation expressions in queries (MongoDB 3.6+)`,pattern:RegExp(`\\$expr${Ws}`,`i`)},{id:`nosql-function-operator`,description:`$function — executes arbitrary JavaScript in MongoDB 4.4+`,pattern:RegExp(`\\$function${Ws}`,`i`)},{id:`nosql-accumulator-operator`,description:`$accumulator — custom aggregation with arbitrary JS execution`,pattern:RegExp(`\\$accumulator${Ws}`,`i`)},{id:`nosql-proto-pollution`,description:`__proto__ — prototype pollution via object key injection`,pattern:/__proto__/},{id:`nosql-constructor-prototype`,description:`constructor.prototype — alternative prototype pollution vector (dot notation or JSON key)`,pattern:/constructor[\s"':.,{\[]*prototype/i},{id:`nosql-proto-bracket`,description:`["__proto__"] — bracket-notation prototype pollution`,pattern:/\[["']__proto__["']\]/}],Ks=[{id:`log-crlf-injection`,description:`CRLF injection: literal \\r or \\n embeds fake log lines`,pattern:/[\r\n]/},{id:`log-url-encoded-crlf`,description:`URL-encoded CRLF: %0d, %0a, %0D, %0A — decoded by some log parsers`,pattern:/%0[dDaA]/},{id:`log-unicode-newline`,description:`Unicode newline variants: U+2028 (line separator), U+2029 (paragraph separator)`,pattern:/[\u2028\u2029]/},{id:`log-log4shell-jndi`,description:"Log4Shell: ${jndi:...} triggers remote code execution in Apache Log4j",pattern:/\$\{jndi\s*:/i},{id:`log-log4shell-obfuscated`,description:"Obfuscated Log4Shell: ${::-j}... lookup-bypass prefix used to evade WAF detection",pattern:/\$\{::-/},{id:`log-log4j-lookup`,description:"Log4j lookup syntax: ${env:...}, ${sys:...}, ${ctx:...} — data exfiltration",pattern:/\$\{(?:env|sys|ctx|main|map|sd|web|docker|k8s|spring)\s*:/i},{id:`log-ssti-double-brace`,description:`SSTI double-brace: {{expression}} — Jinja2, Twig, Handlebars, etc.`,pattern:/\{\{[\s\S]{0,80}\}\}/},{id:`log-ssti-hash-brace`,description:`SSTI hash-brace: #{expression} — Thymeleaf, Velocity, Ruby ERB`,pattern:/#\{[\s\S]{0,80}\}/},{id:`log-ssti-dollar-brace`,description:"SSTI/EL injection: ${expression with operators or method calls} — JSP EL, Freemarker, SpEL",pattern:/\$\{[^}]*(?:\.|\(|\*|\+|\bclass\b|\bruntime\b|\bprocess\b|\bexec\b)[^}]{0,80}\}/i},{id:`log-ssti-percent-tag`,description:`SSTI ERB/ASP tag: <%= expression %> — Ruby ERB, ASP`,pattern:/<%=[\s\S]{0,80}%>/},{id:`log-null-byte`,description:`Null byte: \\x00 or %00 — can truncate log entries in C-backed loggers`,pattern:/\x00|%00/},{id:`log-ansi-escape`,description:`ANSI escape sequence: ESC[ — can manipulate terminal output when logs are tailed`,pattern:/\x1b\[/}],qs=[{id:`sql-line-comment`,description:`SQL line comment: -- followed by whitespace or end of string`,pattern:/--(?:\s|$)/},{id:`sql-stacked-query`,description:`Stacked queries: semicolon immediately followed by a SQL keyword`,pattern:/;\s{0,10}(?:SELECT|INSERT|UPDATE|DELETE|DROP|CREATE|ALTER|EXEC)\b/i},{id:`sql-hex-encoding`,description:`Hex-encoded string injection: 0x41414141 style (MySQL)`,pattern:/\b0x[0-9a-f]{4,}/i}],Js=[...Vs,...qs];Rs.label=`HTML`,zs.label=`XML`,Bs.label=`SVG`,Vs.label=`SQL`,Js.label=`SQL-STRICT`,Hs.label=`SHELL`,Us.label=`REDOS`,Gs.label=`NOSQL`,Ks.label=`LOG`,Object.freeze({HTML:Rs,XML:zs,SVG:Bs,SQL:Vs,"SQL-STRICT":Js,SHELL:Hs,REDOS:Us,NOSQL:Gs,LOG:Ks});function Ys(e){if(typeof e!=`string`)throw TypeError(`is-unsafe: first argument must be a string, got ${typeof e}`)}function Xs(e){if(!(e instanceof RegExp)){if(Array.isArray(e)){if(e.length===0)throw TypeError(`is-unsafe: context must not be an empty array`);if(Array.isArray(e[0])){for(let t of e)if(!Array.isArray(t)||t.length===0)throw TypeError(`is-unsafe: each context in the array must be a non-empty pattern array (PatternList)`)}}else throw TypeError(`is-unsafe: second argument must be a PatternList (e.g. HTML), an array of PatternLists (e.g. [HTML, XML]), or a RegExp. Got: ${typeof e}`)}}function Zs(e){return e instanceof RegExp?{lists:null,regex:e}:Array.isArray(e[0])?{lists:e,regex:null}:{lists:[e],regex:null}}function Qs(e,t){let n=t.label??`CUSTOM`;for(let r of t)if(r.pattern.test(e))return{context:n,id:r.id,description:r.description,pattern:r.pattern};return null}function $s(e,t){Ys(e),Xs(t);let{lists:n,regex:r}=Zs(t);if(r)return r.test(e);for(let t of n)if(Qs(e,t)!==null)return!0;return!1}function ec(e,t){if(!e)return{};let n=t.attributesGroupName?e[t.attributesGroupName]:e;if(!n)return{};let r={};for(let e in n)if(e.startsWith(t.attributeNamePrefix)){let i=e.substring(t.attributeNamePrefix.length);r[i]=n[e]}else r[e]=n[e];return r}function tc(e){if(!e||typeof e!=`string`)return;let t=e.indexOf(`:`);if(t!==-1&&t>0){let n=e.substring(0,t);if(n!==`xmlns`)return n}}var nc=class{constructor(e,t){this.options=e,this.currentNode=null,this.tagsNodeStack=[],this.parseXml=sc,this.parseTextData=rc,this.resolveNameSpace=ic,this.buildAttributesMap=oc,this.isItStopNode=dc,this.replaceEntitiesValue=lc,this.readStopNodeData=gc,this.saveTextToParentTag=uc,this.addChild=cc,this.ignoreAttributesFn=Ns(this.options.ignoreAttributes),this.entityExpansionCount=0,this.currentExpandedLength=0,this.doctypefound=!1;let n={...jo};this.options.entityDecoder?this.entityDecoder=this.options.entityDecoder:(typeof this.options.htmlEntities==`object`?n=this.options.htmlEntities:this.options.htmlEntities===!0&&(n={...Mo,...Ao}),this.entityDecoder=new Wo({namedEntities:{...n,...t},numericAllowed:this.options.htmlEntities,limit:{maxTotalExpansions:this.options.processEntities.maxTotalExpansions,maxExpandedLength:this.options.processEntities.maxExpandedLength,applyLimitsTo:this.options.processEntities.appliesTo},onInputEntity:(e,t)=>$s(t,[Rs,zs])?No.BLOCK:No.ALLOW})),this.matcher=new Ls,this.readonlyMatcher=this.matcher.readOnly(),this.isCurrentNodeStopNode=!1,this.stopNodeExpressionsSet=new Fs;let r=this.options.stopNodes;if(r&&r.length>0){for(let e=0;e<r.length;e++){let t=r[e];typeof t==`string`?this.stopNodeExpressionsSet.add(new Ps(t)):t instanceof Ps&&this.stopNodeExpressionsSet.add(t)}this.stopNodeExpressionsSet.seal()}}};function rc(e,t,n,r,i,a,o){let s=this.options;if(e!==void 0&&(s.trimValues&&!r&&(e=e.trim()),e.length>0)){o||(e=this.replaceEntitiesValue(e,t,n));let r=s.jPath?n.toString():n,c=s.tagValueProcessor(t,e,r,i,a);return c==null?e:typeof c!=typeof e||c!==e?c:s.trimValues||e.trim()===e?_c(e,s.parseTagValue,s.numberParseOptions):e}}function ic(e){if(this.options.removeNSPrefix){let t=e.split(`:`),n=e.charAt(0)===`/`?`/`:``;if(t[0]===`xmlns`)return``;t.length===2&&(e=n+t[1])}return e}var ac=RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`,`gm`);function oc(e,t,n,r=!1){let i=this.options;if(r===!0||i.ignoreAttributes!==!0&&typeof e==`string`){let r=so(e,ac),a=r.length,o={},s=Array(a),c=!1,l={};for(let e=0;e<a;e++){let t=this.resolveNameSpace(r[e][1]),a=r[e][4];if(t.length&&a!==void 0){let r=a;i.trimValues&&(r=r.trim()),r=this.replaceEntitiesValue(r,n,this.readonlyMatcher),s[e]=r,l[t]=r,c=!0}}c&&typeof t==`object`&&t.updateCurrent&&t.updateCurrent(l);let u=i.jPath?t.toString():this.readonlyMatcher,d=!1;for(let e=0;e<a;e++){let t=this.resolveNameSpace(r[e][1]);if(this.ignoreAttributesFn(t,u))continue;let n=i.attributeNamePrefix+t;if(t.length){if(i.transformAttributeName&&(n=i.transformAttributeName(n)),n=yc(n,i),r[e][4]!==void 0){let r=s[e],a=i.attributeValueProcessor(t,r,u);a==null?o[n]=r:typeof a!=typeof r||a!==r?o[n]=a:o[n]=_c(r,i.parseAttributeValue,i.numberParseOptions),d=!0}else i.allowBooleanAttributes&&(o[n]=!0,d=!0)}}if(!d)return;if(i.attributesGroupName&&!i.preserveOrder){let e={};return e[i.attributesGroupName]=o,e}return o}}var sc=function(e){e=e.replace(/\r\n?/g,`
|
|
19
|
-
`);let t=new Zo(`!xml`),n=t,r=``;this.matcher.reset(),this.entityDecoder.reset(),this.entityExpansionCount=0,this.currentExpandedLength=0,this.doctypefound=!1;let i=this.options,a=new cs(i.processEntities),o=e.length;for(let s=0;s<o;s++)if(e[s]===`<`){let c=e.charCodeAt(s+1);if(c===47){let a=pc(e,`>`,s,`Closing Tag is not closed.`),o=e.substring(s+2,a).trim();if(i.removeNSPrefix){let e=o.indexOf(`:`);e!==-1&&(o=o.substr(e+1))}o=vc(i.transformTagName,o,``,i).tagName,n&&(r=this.saveTextToParentTag(r,n,this.readonlyMatcher));let c=this.matcher.getCurrentTag();if(o&&i.unpairedTagsSet.has(o))throw Error(`Unpaired tag can not be used as closing tag: </${o}>`);c&&i.unpairedTagsSet.has(c)&&(this.matcher.pop(),this.tagsNodeStack.pop()),this.matcher.pop(),this.isCurrentNodeStopNode=!1,n=this.tagsNodeStack.pop()||t,i.captureMetaData&&n&&n.addEndIndex(a+1),r=``,s=a}else if(c===63){let t=hc(e,s,!1,`?>`);if(!t)throw Error(`Pi Tag is not closed.`);r=this.saveTextToParentTag(r,n,this.readonlyMatcher);let o=this.buildAttributesMap(t.tagExp,this.matcher,t.tagName,!0);if(o){let e=o[this.options.attributeNamePrefix+`version`];this.entityDecoder.setXmlVersion(Number(e)||1),a.setXmlVersion(Number(e)||1)}if(!(i.ignoreDeclaration&&t.tagName===`?xml`||i.ignorePiTags)){let e=new Zo(t.tagName);e.add(i.textNodeName,``),t.tagName!==t.tagExp&&t.attrExpPresent&&i.ignoreAttributes!==!0&&(e[`:@`]=o),this.addChild(n,e,this.readonlyMatcher,s),i.captureMetaData&&n.addEndIndex(t.closeIndex+2)}s=t.closeIndex+1}else if(c===33&&e.charCodeAt(s+2)===45&&e.charCodeAt(s+3)===45){let t=pc(e,`-->`,s+4,`Comment is not closed.`);if(i.commentPropName){let a=e.substring(s+4,t-2);r=this.saveTextToParentTag(r,n,this.readonlyMatcher),n.add(i.commentPropName,[{[i.textNodeName]:a}])}s=t}else if(c===33&&e.charCodeAt(s+2)===68){if(this.doctypefound)throw Error(`Multiple DOCTYPE declarations found.`);this.doctypefound=!0;let t=a.readDocType(e,s);this.entityDecoder.addInputEntities(t.entities),s=t.i}else if(c===33&&e.charCodeAt(s+2)===91){let t=pc(e,`]]>`,s,`CDATA is not closed.`)-2,a=e.substring(s+9,t);r=this.saveTextToParentTag(r,n,this.readonlyMatcher);let o=this.parseTextData(a,n.tagname,this.readonlyMatcher,!0,!1,!0,!0);o??=``,i.cdataPropName?n.add(i.cdataPropName,[{[i.textNodeName]:a}]):n.add(i.textNodeName,o),s=t+2}else{let a=hc(e,s,i.removeNSPrefix);if(!a){let t=e.substring(Math.max(0,s-50),Math.min(o,s+50));throw Error(`readTagExp returned undefined at position ${s}. Context: "${t}"`)}let c=a.tagName,l=a.rawTagName,u=a.tagExp,d=a.attrExpPresent,f=a.closeIndex;if({tagName:c,tagExp:u}=vc(i.transformTagName,c,u,i),i.strictReservedNames&&(c===i.commentPropName||c===i.cdataPropName||c===i.textNodeName||c===i.attributesGroupName))throw Error(`Invalid tag name: ${c}`);n&&r&&n.tagname!==`!xml`&&(r=this.saveTextToParentTag(r,n,this.readonlyMatcher,!1));let p=n;p&&i.unpairedTagsSet.has(p.tagname)&&(n=this.tagsNodeStack.pop(),this.matcher.pop());let m=!1;u.length>0&&u.lastIndexOf(`/`)===u.length-1&&(m=!0,c[c.length-1]===`/`?(c=c.substr(0,c.length-1),u=c):u=u.substr(0,u.length-1),d=c!==u);let h=null,g;g=tc(l),c!==t.tagname&&this.matcher.push(c,{},g),c!==u&&d&&(h=this.buildAttributesMap(u,this.matcher,c),h&&ec(h,i)),c!==t.tagname&&(this.isCurrentNodeStopNode=this.isItStopNode());let _=s;if(this.isCurrentNodeStopNode){let t=``;if(m)s=a.closeIndex;else if(i.unpairedTagsSet.has(c))s=a.closeIndex;else{let n=this.readStopNodeData(e,l,f+1);if(!n)throw Error(`Unexpected end of ${l}`);s=n.i,t=n.tagContent}let r=new Zo(c);h&&(r[`:@`]=h),r.add(i.textNodeName,t),this.matcher.pop(),this.isCurrentNodeStopNode=!1,this.addChild(n,r,this.readonlyMatcher,_),i.captureMetaData&&n.addEndIndex(s+1)}else{if(m){({tagName:c,tagExp:u}=vc(i.transformTagName,c,u,i));let e=new Zo(c);h&&(e[`:@`]=h),this.addChild(n,e,this.readonlyMatcher,_),i.captureMetaData&&n.addEndIndex(f+1),this.matcher.pop(),this.isCurrentNodeStopNode=!1}else if(i.unpairedTagsSet.has(c)){let e=new Zo(c);h&&(e[`:@`]=h),this.addChild(n,e,this.readonlyMatcher,_),i.captureMetaData&&n.addEndIndex(a.closeIndex+1),this.matcher.pop(),this.isCurrentNodeStopNode=!1,s=a.closeIndex;continue}else{let e=new Zo(c);if(this.tagsNodeStack.length>i.maxNestedTags)throw Error(`Maximum nested tags exceeded`);this.tagsNodeStack.push(n),h&&(e[`:@`]=h),this.addChild(n,e,this.readonlyMatcher,_),n=e}r=``,s=f}}}else r+=e[s];return t.child};function cc(e,t,n,r){this.options.captureMetaData||(r=void 0);let i=this.options.jPath?n.toString():n,a=this.options.updateTag(t.tagname,i,t[`:@`]);a===!1||(typeof a==`string`&&(t.tagname=a),e.addChild(t,r))}function lc(e,t,n){let r=this.options.processEntities;if(!r||!r.enabled)return e;if(r.allowedTags){let i=this.options.jPath?n.toString():n;if(!(Array.isArray(r.allowedTags)?r.allowedTags.includes(t):r.allowedTags(t,i)))return e}if(r.tagFilter){let i=this.options.jPath?n.toString():n;if(!r.tagFilter(t,i))return e}return this.entityDecoder.decode(e)}function uc(e,t,n,r){return e&&=(r===void 0&&(r=t.child.length===0),e=this.parseTextData(e,t.tagname,n,!1,t[`:@`]?Object.keys(t[`:@`]).length!==0:!1,r),e!==void 0&&e!==``&&t.add(this.options.textNodeName,e),``),e}function dc(){return this.stopNodeExpressionsSet.size!==0&&this.matcher.matchesAny(this.stopNodeExpressionsSet)}function fc(e,t,n=`>`){let r=0,i=e.length,a=n.charCodeAt(0),o=n.length>1?n.charCodeAt(1):-1,s=``,c=t;for(let n=t;n<i;n++){let t=e.charCodeAt(n);if(r)t===r&&(r=0);else if(t===34||t===39)r=t;else if(t===a){if(o!==-1){if(e.charCodeAt(n+1)===o)return s+=e.substring(c,n),{data:s,index:n}}else return s+=e.substring(c,n),{data:s,index:n}}else t===9&&!r&&(s+=e.substring(c,n)+` `,c=n+1)}}function pc(e,t,n,r){let i=e.indexOf(t,n);if(i===-1)throw Error(r);return i+t.length-1}function mc(e,t,n,r){let i=e.indexOf(t,n);if(i===-1)throw Error(r);return i}function hc(e,t,n,r=`>`){let i=fc(e,t+1,r);if(!i)return;let a=i.data,o=i.index,s=a.search(/\s/),c=a,l=!0;s!==-1&&(c=a.substring(0,s),a=a.substring(s+1).trimStart());let u=c;if(n){let e=c.indexOf(`:`);e!==-1&&(c=c.substr(e+1),l=c!==i.data.substr(e+1))}return{tagName:c,tagExp:a,closeIndex:o,attrExpPresent:l,rawTagName:u}}function gc(e,t,n){let r=n,i=1,a=e.length;for(;n<a;n++)if(e[n]===`<`){let a=e.charCodeAt(n+1);if(a===47){let a=mc(e,`>`,n,`${t} is not closed`);if(e.substring(n+2,a).trim()===t&&(i--,i===0))return{tagContent:e.substring(r,n),i:a};n=a}else if(a===63)n=pc(e,`?>`,n+1,`StopNode is not closed.`);else if(a===33&&e.charCodeAt(n+2)===45&&e.charCodeAt(n+3)===45)n=pc(e,`-->`,n+3,`StopNode is not closed.`);else if(a===33&&e.charCodeAt(n+2)===91)n=pc(e,`]]>`,n,`StopNode is not closed.`)-2;else{let r=hc(e,n,!1);r&&((r&&r.tagName)===t&&r.tagExp[r.tagExp.length-1]!==`/`&&i++,n=r.closeIndex)}}}function _c(e,t,n){if(t&&typeof e==`string`){let t=e.trim();return t===`true`||t!==`false`&&Ds(e,n)}return lo(e)?e:``}function vc(e,t,n,r){if(e){let r=e(t);n===t&&(n=r),t=r}return t=yc(t,r),{tagName:t,tagExp:n}}function yc(e,t){if(fo.includes(e))throw Error(`[SECURITY] Invalid name: "${e}" is a reserved JavaScript keyword that could cause prototype pollution`);return uo.includes(e)?t.onDangerousProperty(e):e}var bc=Zo.getMetaDataSymbol();function xc(e,t){if(!e||typeof e!=`object`)return{};if(!t)return e;let n={};for(let r in e)if(r.startsWith(t)){let i=r.substring(t.length);n[i]=e[r]}else n[r]=e[r];return n}function Sc(e,t,n,r){return Cc(e,t,n,r)}function Cc(e,t,n,r){let i,a={};for(let o=0;o<e.length;o++){let s=e[o],c=wc(s);if(c!==void 0&&c!==t.textNodeName){let e=xc(s[`:@`]||{},t.attributeNamePrefix);n.push(c,e)}if(c===t.textNodeName)i===void 0?i=s[c]:i+=``+s[c];else if(c===void 0)continue;else if(s[c]){let e=Cc(s[c],t,n,r),i=Ec(e,t);if(Object.keys(e).length===0&&t.alwaysCreateTextNode&&(e[t.textNodeName]=``),s[`:@`]?Tc(e,s[`:@`],r,t):Object.keys(e).length===1&&e[t.textNodeName]!==void 0&&!t.alwaysCreateTextNode?e=e[t.textNodeName]:Object.keys(e).length===0&&(t.alwaysCreateTextNode?e[t.textNodeName]=``:e=``),s[bc]!==void 0&&typeof e==`object`&&e&&(e[bc]=s[bc]),a[c]!==void 0&&Object.prototype.hasOwnProperty.call(a,c))Array.isArray(a[c])||(a[c]=[a[c]]),a[c].push(e);else{let n=t.jPath?r.toString():r;a[c]=t.isArray(c,n,i)?[e]:e}c!==void 0&&c!==t.textNodeName&&n.pop()}}return typeof i==`string`?i.length>0&&(a[t.textNodeName]=i):i!==void 0&&(a[t.textNodeName]=i),a}function wc(e){let t=Object.keys(e);for(let e=0;e<t.length;e++){let n=t[e];if(n!==`:@`)return n}}function Tc(e,t,n,r){if(t){let i=Object.keys(t),a=i.length;for(let o=0;o<a;o++){let a=i[o],s=a.startsWith(r.attributeNamePrefix)?a.substring(r.attributeNamePrefix.length):a,c=r.jPath?n.toString()+`.`+s:n;e[a]=r.isArray(a,c,!0,!0)?[t[a]]:t[a]}}}function Ec(e,t){let{textNodeName:n}=t,r=Object.keys(e).length;return!!(r===0||r===1&&(e[n]||typeof e[n]==`boolean`||e[n]===0))}var Dc=class{constructor(e){this.externalEntities={},this.options=Yo(e)}parse(e,t){if(typeof e!=`string`&&e.toString)e=e instanceof Uint8Array&&!(typeof Buffer<`u`&&Buffer.isBuffer(e))?new TextDecoder(`utf-8`,{ignoreBOM:!0}).decode(e):e.toString();else if(typeof e!=`string`)throw Error(`XML data is accepted in String or Bytes[] form.`);if(t){t===!0&&(t={});let n=mo(e,t);if(n!==!0)throw Error(`${n.err.msg}:${n.err.line}:${n.err.col}`)}let n=new nc(this.options,this.externalEntities),r=n.parseXml(e);return this.options.preserveOrder||r===void 0?r:Sc(r,this.options,n.matcher,n.readonlyMatcher)}addEntity(e,t){if(t.indexOf(`&`)!==-1)throw Error(`Entity value can't have '&'`);if(e.indexOf(`&`)!==-1||e.indexOf(`;`)!==-1)throw Error(`An entity must be set without '&' and ';'. Eg. use '#xD' for '
'`);if(t===`&`)throw Error(`An entity with value '&' is not permitted`);this.externalEntities[e]=t}static getMetaDataSymbol(){return Zo.getMetaDataSymbol()}},Oc={"&":`&`,"<":`<`,">":`>`,'"':`"`},kc=e=>e<32&&e!==9&&e!==10||e===65534||e===65535||e>=55296&&e<=57343,Ac=e=>e.toString(16).toUpperCase().padStart(4,`0`);function jc(e){let t=e.replace(/_(?=x[0-9A-Fa-f]{4}_)/gu,`_x005F_`),n=``;for(let e of t){let t=e.codePointAt(0)??0;n+=e.length===1&&kc(t)?`_x${Ac(t)}_`:e}return n.replace(/[&<>"]/gu,e=>Oc[e]??e)}var Mc=e=>jc(e).replace(/[\t\n\r]/gu,e=>`_x${Ac(e.charCodeAt(0))}_`),Nc=e=>e.includes(`_x`)?e.replace(/_x([0-9A-Fa-f]{4})_/gu,(e,t)=>String.fromCharCode(Number.parseInt(t,16))):e;function Pc(e,t={},...n){let r=``;for(let[e,n]of Object.entries(t))n!==void 0&&(r+=` ${e}="${Mc(typeof n==`boolean`?n?`1`:`0`:String(n))}"`);let i=n.join(``);return i===``?`<${e}${r}/>`:`<${e}${r}>${i}</${e}>`}var Fc={main:`http://schemas.openxmlformats.org/spreadsheetml/2006/main`,rel:`http://schemas.openxmlformats.org/officeDocument/2006/relationships`,pkg:`http://schemas.openxmlformats.org/package/2006/relationships`,types:`http://schemas.openxmlformats.org/package/2006/content-types`,drawing:`http://schemas.openxmlformats.org/drawingml/2006/main`},Ic=new Set(`c.row.col.cols.si.r.rPh.sheet.definedName.font.fill.border.numFmt.xf.Relationship.Override.Default.mergeCell.tablePart.tableColumn.sheetView.pane.selection.conditionalFormatting.dataValidation.hyperlink.rgbColor.brk.filterColumn.externalReference.gsd`.split(`.`)),Lc=new Dc({ignoreAttributes:!1,attributeNamePrefix:``,removeNSPrefix:!0,trimValues:!1,parseTagValue:!1,parseAttributeValue:!1,processEntities:!0,htmlEntities:!0,textNodeName:`#text`,isArray:(e,t,n,r)=>!r&&Ic.has(e)});function Rc(e){return Lc.parse(e.replace(/\r\n?/gu,`
|
|
20
|
-
`))}var zc=e=>typeof e==`object`?e:{},Bc=e=>Array.isArray(e)?e.map(zc):e===void 0?[]:[zc(e)],Vc=e=>{let t=Array.isArray(e)?e[0]:e;return t===void 0?void 0:zc(t)};function Hc(e){if(typeof e==`string`)return e;if(e==null)return``;if(Array.isArray(e))return e.map(Hc).join(``);let t=e[`#text`];return typeof t==`string`?t:``}var Uc=(e,t)=>{let n=e?.[t];return typeof n==`string`?n:void 0},Wc=(e,t)=>{let n=Uc(e,t);if(n===void 0||n===``)return;let r=Number(n);return Number.isFinite(r)?r:void 0},Gc=(e,t)=>{let n=Uc(e,t);return n===void 0?void 0:n===`1`||n===`true`},Kc=`000000 FFFFFF FF0000 00FF00 0000FF FFFF00 FF00FF 00FFFF 000000 FFFFFF FF0000 00FF00 0000FF FFFF00 FF00FF 00FFFF 800000 008000 000080 808000 800080 008080 C0C0C0 808080 9999FF 993366 FFFFCC CCFFFF 660066 FF8080 0066CC CCCCFF 000080 FF00FF FFFF00 00FFFF 800080 800000 008080 0000FF 00CCFF CCFFFF CCFFCC FFFF99 99CCFF FF99CC CC99FF FFCC99 3366FF 33CCCC 99CC00 FFCC00 FF9900 FF6600 666699 969696 003366 339966 003300 333300 993300 993366 333399 333333`.split(` `),qc=[`FFFFFF`,`000000`,`E7E6E6`,`44546A`,`4472C4`,`ED7D31`,`A5A5A5`,`FFC000`,`5B9BD5`,`70AD47`,`0563C1`,`954F72`];function Jc(e){let t=Vc(Vc(Vc(Rc(e).theme)?.themeElements)?.clrScheme);if(!t)return[...qc];let n=(e,n)=>{let r=Vc(t[e]),i=Vc(r?.srgbClr),a=Vc(r?.sysClr);return(Uc(i,`val`)??Uc(a,`lastClr`)??qc[n]??`000000`).toUpperCase()};return[n(`lt1`,0),n(`dk1`,1),n(`lt2`,2),n(`dk2`,3),...[1,2,3,4,5,6].map(e=>n(`accent${String(e)}`,e+3)),n(`hlink`,10),n(`folHlink`,11)]}function Yc(e){let t=Number.parseInt(e.slice(0,2),16)/255,n=Number.parseInt(e.slice(2,4),16)/255,r=Number.parseInt(e.slice(4,6),16)/255,i=Math.max(t,n,r),a=Math.min(t,n,r),o=(i+a)/2;if(i===a)return[0,0,o];let s=i-a,c=o>.5?s/(2-i-a):s/(i+a);return[(i===t?(n-r)/s+(n<r?6:0):i===n?(r-t)/s+2:(t-n)/s+4)/6,c,o]}function Xc(e,t,n){let r=n<.5?n*(1+t):n+t-n*t,i=2*n-r,a=e=>{let a=e<0?e+1:e>1?e-1:e,o=t===0?n:a<1/6?i+(r-i)*6*a:a<1/2?r:a<2/3?i+(r-i)*(2/3-a)*6:i;return Math.round(o*255).toString(16).toUpperCase().padStart(2,`0`)};return`${a(e+1/3)}${a(e)}${a(e-1/3)}`}function Zc(e,t){if(t===0)return e;let[n,r,i]=Yc(e),a=t<0?i*(1+t):i*(1-t)+t;return Xc(n,r,Math.min(1,Math.max(0,a)))}var Qc=(e,t)=>{let n=Bc(Vc(Vc(t?.colors)?.indexedColors)?.rgbColor);return{theme:e,indexed:n.length>0?n.map(e=>(Uc(e,`rgb`)??`00000000`).slice(-6).toUpperCase()):Kc}};function $c(e,t){if(!e||Uc(e,`auto`)===`1`)return;let n=Uc(e,`rgb`),r=Number(Uc(e,`tint`)??0),i;n!==void 0&&(i=n.slice(-6).toUpperCase());let a=Uc(e,`theme`);i===void 0&&a!==void 0&&(i=t.theme[Number(a)]);let o=Uc(e,`indexed`);if(i===void 0&&o!==void 0){let e=Number(o);i=e===64?`000000`:e===65?`FFFFFF`:t.indexed[e]}return i===void 0?void 0:`#${Zc(i,r)}`}function el(e){return[e.lt1,e.dk1,e.lt2,e.dk2,e.accent1,e.accent2,e.accent3,e.accent4,e.accent5,e.accent6,e.hlink,e.folHlink].map(e=>e.slice(1).toUpperCase())}var tl=(e,t,n=0)=>`#${Zc(e[t].slice(1).toUpperCase(),n)}`;function nl(e,t){if(!e.startsWith(`t`))return e;let[n,r]=e.slice(1).split(`:`);return`#${Zc(t[Number(n)]??`000000`,Number(r??0))}`}var rl=(e,t)=>o(e,t,(e,t)=>`#${Zc(e.slice(1).toUpperCase(),t)}`);function il(e,t){let n=e=>e===void 0||e.startsWith(`#`)?e:rl(e,t),r={...e};if(e.color!==void 0&&(r.color=n(e.color)),typeof e.fill==`string`?r.fill=n(e.fill):e.fill&&(r.fill={...e.fill,...e.fill.color===void 0?{}:{color:n(e.fill.color)},...e.fill.background===void 0?{}:{background:n(e.fill.background)}}),e.border){let t={};for(let[r,i]of Object.entries(e.border)){if(!i)continue;let e=n(i.color);t[r]=e===void 0?i:{...i,color:e}}r.border=t}return r}var al=.7999816888943144,ol=.5999938962981048,sl=.499984740745262,cl=.3999755851924192,ll=(e,t)=>({left:{style:e,color:t},right:{style:e,color:t},top:{style:e,color:t},bottom:{style:e,color:t}});function ul(e){let t=(t,n=0)=>tl(e,t,n),n={Normal:{},Title:{size:18,color:t(`dk2`)},"Heading 1":{size:15,bold:!0,color:t(`dk2`),border:{bottom:{style:`thick`,color:t(`accent1`)}}},"Heading 2":{size:13,bold:!0,color:t(`dk2`),border:{bottom:{style:`thick`,color:t(`accent1`,sl)}}},"Heading 3":{bold:!0,color:t(`dk2`),border:{bottom:{style:`medium`,color:t(`accent1`,cl)}}},"Heading 4":{bold:!0,color:t(`dk2`)},Good:{fill:`#C6EFCE`,color:`#006100`},Bad:{fill:`#FFC7CE`,color:`#9C0006`},Neutral:{fill:`#FFEB9C`,color:`#9C5700`},Input:{fill:`#FFCC99`,color:`#3F3F76`,border:ll(`thin`,`#7F7F7F`)},Output:{fill:`#F2F2F2`,bold:!0,color:`#3F3F3F`,border:ll(`thin`,`#3F3F3F`)},Calculation:{fill:`#F2F2F2`,bold:!0,color:`#FA7D00`,border:ll(`thin`,`#7F7F7F`)},"Check Cell":{fill:`#A5A5A5`,bold:!0,color:`#FFFFFF`,border:ll(`double`,`#3F3F3F`)},"Linked Cell":{color:`#FA7D00`,border:{bottom:{style:`double`,color:`#FF8001`}}},Note:{fill:`#FFFFCC`,border:ll(`thin`,`#B2B2B2`)},"Warning Text":{color:`#FF0000`},"Explanatory Text":{italic:!0,color:`#7F7F7F`},Total:{bold:!0,border:{top:{style:`thin`,color:t(`accent1`)},bottom:{style:`double`,color:t(`accent1`)}}},Hyperlink:{color:t(`hlink`),underline:!0},"Followed Hyperlink":{color:t(`folHlink`),underline:!0},Comma:{format:`_(* #,##0.00_);_(* \\(#,##0.00\\);_(* "-"??_);_(@_)`},"Comma [0]":{format:`_(* #,##0_);_(* \\(#,##0\\);_(* "-"_);_(@_)`},Currency:{format:`_("$"* #,##0.00_);_("$"* \\(#,##0.00\\);_("$"* "-"??_);_(@_)`},"Currency [0]":{format:`_("$"* #,##0_);_("$"* \\(#,##0\\);_("$"* "-"_);_(@_)`},Percent:{format:`0%`}};for(let e of[1,2,3,4,5,6]){let r=`accent${String(e)}`;n[`Accent${String(e)}`]={fill:t(r),color:t(`lt1`)},n[`20% - Accent${String(e)}`]={fill:t(r,al)},n[`40% - Accent${String(e)}`]={fill:t(r,ol)},n[`60% - Accent${String(e)}`]={fill:t(r,cl),color:t(`lt1`)}}return n}var dl=new WeakMap;function fl(e,t=u){let n=dl.get(t);return n||(n=ul(t),dl.set(t,n)),n[ye[e]??e]}var pl=e=>e.toLowerCase();function ml(e,t){let n=e.sheets.length;if(!t)return{file:e,own:n,names:new Set,ordinary:[]};let r=new Set(e.sheets.map(e=>pl(e.name))),i=t.sheets.filter(e=>!r.has(pl(e.name))),a=t.sheets.filter(e=>r.has(pl(e.name))).map(e=>e.name),o=new Set(Object.keys(e.names??{}).map(pl)),s=Object.entries(t.names??{}).filter(([e])=>!o.has(pl(e)));return{file:{...e,sheets:[...e.sheets,...i],...s.length===0?{}:{names:{...e.names,...Object.fromEntries(s)}}},own:n,names:new Set(s.map(([e])=>e)),ordinary:a}}var hl=e=>[...(e.tables??[]).map(e=>e.rows),...(e.blocks??[]).map(e=>e.rows)],gl=e=>e.toLowerCase().replace(/[^\p{L}\p{N}]+/gu,`-`).replace(/^-|-$/gu,``);function _l(e,t,n,r=()=>!1){let i=t.sheets.find(e=>pl(e.name)===pl(n));if(!i)return{rows:new Map,cells:[],whole:!1,refused:`no-sheet`};let a=new Map,o=new Map;for(let e of hl(i)){let n=t.csv[e];if(n===void 0)continue;let s=gl(`${i.name} ${e.split(`/`).pop()??``}`).replace(/-csv$/u,``),c=`${s}.csv`;for(let e=2;r(c)||a.has(c);e++)c=`${s}-${String(e)}.csv`;o.set(e,c),a.set(c,f(n).records.map(e=>e.end===e.start?[]:e.fields))}let s=e=>o.get(e)??e,c=structuredClone(i);for(let e of c.tables??[])e.rows=s(e.rows);for(let e of c.blocks??[])e.rows=s(e.rows);return{file:{...e.file,sheets:[...e.file.sheets,c]},rows:a,cells:[],whole:!0}}function vl(e,t){return t(yl(e,t))}function yl(e,t){switch(e.kind){case`unary`:case`postfix`:case`paren`:{let n=vl(e.arg,t);return n===e.arg?e:{...e,arg:n}}case`binary`:{let n=vl(e.left,t),r=vl(e.right,t);return n===e.left&&r===e.right?e:{...e,left:n,right:r}}case`call`:{let n=e.args.map(e=>vl(e,t));return n.every((t,n)=>t===e.args[n])?e:{...e,args:n}}case`invoke`:{let n=vl(e.callee,t),r=e.args.map(e=>vl(e,t));return n===e.callee&&r.every((t,n)=>t===e.args[n])?e:{...e,callee:n,args:r}}case`array`:{let n=e.rows.map(e=>e.map(e=>vl(e,t)));return n.every((t,n)=>t.every((t,r)=>t===e.rows[n]?.[r]))?e:{...e,rows:n}}default:return e}}function bl(e,t){switch(t(e),e.kind){case`unary`:case`postfix`:case`paren`:bl(e.arg,t);break;case`binary`:bl(e.left,t),bl(e.right,t);break;case`call`:for(let n of e.args)bl(n,t);break;case`invoke`:bl(e.callee,t);for(let n of e.args)bl(n,t);break;case`array`:for(let n of e.rows)for(let e of n)bl(e,t)}}function xl(e,t,n){if(e.abs||t===0)return e;let r=e.index+t;return r<0||r>=n?void 0:{...e,index:r}}function Sl(e,t,n){let r=e.col&&xl(e.col,n,16384),i=e.col2&&xl(e.col2,n,16384),a=e.row&&xl(e.row,t,1048576),o=e.row2&&xl(e.row2,t,1048576),s=(e,t)=>e!==void 0&&t===void 0;return s(e.col,r)||s(e.col2,i)||s(e.row,a)||s(e.row2,o)?{kind:`error`,code:`#REF!`,...e.sheet===void 0?{}:{sheet:e.sheet}}:r===e.col&&i===e.col2&&a===e.row&&o===e.row2?e:{...e,...r?{col:r}:{},...i?{col2:i}:{},...a?{row:a}:{},...o?{row2:o}:{}}}function Cl(e,t,n){return t===0&&n===0?e:vl(e,e=>e.kind===`ref`?Sl(e,t,n):e)}function wl(e,t,n){let r=[],i=e=>e===void 0?`~`:JSON.stringify(e),a=(e,t)=>e===void 0?`~`:e.abs?`$${String(e.index)}`:`^${String(e.index-t)}`,o=e=>{r.push(`(`);for(let t of e)s(t);r.push(`)`)},s=e=>{switch(e.kind){case`number`:r.push(`n`,String(e.value),i(e.raw));return;case`string`:r.push(`s`,i(e.value));return;case`boolean`:r.push(e.value?`T`:`F`);return;case`error`:r.push(`e`,e.code,i(e.sheet));return;case`missing`:r.push(`m`);return;case`ref`:r.push(e.range?`R`:`r`,i(e.sheet),i(e.lastSheet),a(e.col,n),a(e.row,t),a(e.col2,n),a(e.row2,t));return;case`structured`:r.push(`t`,i(e.table),JSON.stringify(e.sections),JSON.stringify(e.columns),e.thisRow?`@`:`-`);return;case`name`:r.push(`a`,i(e.name),i(e.sheet));return;case`unary`:case`postfix`:r.push(e.kind===`unary`?`u`:`p`,e.op),s(e.arg);return;case`paren`:r.push(`{`),s(e.arg),r.push(`}`);return;case`binary`:r.push(`b`,JSON.stringify(e.op)),s(e.left),s(e.right);return;case`call`:r.push(`c`,i(e.name),i(e.written)),o(e.args);return;case`invoke`:r.push(`i`),s(e.callee),o(e.args);return;case`array`:r.push(`[`);for(let t of e.rows)o(t);r.push(`]`);return}};return s(e),r.join(` `)}var Tl=[`#All`,`#Data`,`#Headers`,`#Totals`,`#This Row`],El=class extends Error{at;constructor(e,t){super(e),this.at=t}},Dl=new Set([`=`,`<>`,`<`,`<=`,`>`,`>=`]),Ol={"=":1,"<>":1,"<":1,"<=":1,">":1,">=":1,"&":2,"+":3,"-":3,"*":4,"/":4,"^":5},kl=e=>e>=`0`&&e<=`9`,Al=e=>/[\p{L}_\\]/u.test(e)||e>=`\ud800`&&e<=`\udfff`,jl=e=>/[\p{L}\p{N}\p{M}_.?\\]/u.test(e)||e>=`\ud800`&&e<=`\udfff`,Ml=(e,t)=>({index:e,abs:t});function Nl(e,t){let n={};return t.before&&(n.before=t.before),t.inner&&(n.inner=t.inner),t.after&&(n.after=t.after),Object.keys(n).length===0?e:{...e,space:{...e.space,...n}}}var Pl=class{at=0;s;locals=[];constructor(e){this.s=e}blanks(){return this.space()!==``}space(){let e=this.at;for(;/\s/u.test(this.s.charAt(this.at));)this.at+=1;return this.s.slice(e,this.at)}peek(e){return this.s.startsWith(e,this.at)}eat(e){return this.peek(e)?(this.at+=e.length,!0):!1}stop(e,t=this.at){throw new El(e,t)}parse(){this.eat(`=`),this.s.slice(this.at).trim()===``&&this.stop(`a formula with nothing in it`,this.s.length);let e=this.expression(0);return this.blanks(),this.at<this.s.length&&this.stop(`"${this.s.charAt(this.at)}" where an operator should be`),e}operator(){let e=this.at,t=this.space(),n=this.s.slice(this.at,this.at+2),r=this.s.charAt(this.at);return this.at=e,Dl.has(n)?{op:n,inner:t}:Ol[r]===void 0?void 0:{op:r,inner:t}}expression(e){let t=this.prefix();for(;;){let n=this.operator();if(n===void 0)return t;let{op:r,inner:i}=n,a=Ol[r]??0;if(a<=e)return t;this.at+=i.length+r.length;let o=this.expression(a);t=Nl({kind:`binary`,op:r,left:t,right:o},{inner:i})}}prefix(){let e=this.at,t=this.space();for(let e of[`-`,`+`,`@`])if(this.eat(e))return Nl({kind:`unary`,op:e,arg:this.prefix()},{before:t});return this.at=e,this.postfix()}postfix(){let e=this.references();for(;;){let t=this.at;if(this.blanks(),this.eat(`%`))e={kind:`postfix`,op:`%`,arg:e};else if(this.at=t,this.peek(`#`)&&!Ll(this.s,this.at))this.at+=1,e={kind:`postfix`,op:`#`,arg:e};else if(this.peek(`(`)&&(e.kind===`call`||e.kind===`paren`)){let{args:t}=this.call(``);e={kind:`invoke`,callee:e,args:t}}else return e}}spilled(){let e=this.primary();return!this.peek(`#`)||Ll(this.s,this.at)?e:(this.at+=1,{kind:`postfix`,op:`#`,arg:e})}references(){let e=this.spilled();for(;;){if(this.peek(`:`)){this.at+=1,this.blanks();let t=this.spilled();e={kind:`binary`,op:`:`,left:e,right:t};continue}let t=this.at;if(Il(e)&&this.blanks()&&this.startsReference()){let t=this.primary();e={kind:`binary`,op:` `,left:e,right:t}}else return this.at=t,e}}startsReference(){let e=this.s.charAt(this.at);return e===`$`||e===`'`||e===`(`||e===`[`||Al(e)}primary(){let e=this.space();return Nl(this.bare(),{before:e})}bare(){let e=this.s.charAt(this.at);if(e===``&&this.stop(`the formula ends where a value should be`),e===`(`)return this.parenthesis();if(e===`{`)return this.arrayConstant();if(e===`"`)return{kind:`string`,value:this.text()};if(kl(e)||e===`.`){let e=Vl(this.s,this.at);return e?(this.at=e.end,{kind:`ref`,...e.ref}):this.number()}return e===`#`?this.errorLiteral(void 0):e===`[`?this.bracket(void 0):e===`$`||e===`'`||Al(e)?this.word():this.stop(`"${e}" where a value should be`)}parenthesis(){let e=this.at;this.at+=1;let t=this.expression(0),n=this.space();for(;this.eat(`,`);){let e=this.expression(0);t=Nl({kind:`binary`,op:`,`,left:t,right:e},{inner:n}),n=this.space()}return this.eat(`)`)||this.stop(`a ( that is never closed`,e),Nl({kind:`paren`,arg:t},{inner:n})}number(){let e=/^(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/u.exec(this.s.slice(this.at));return e?(this.at+=e[0].length,{kind:`number`,value:Number(e[0]),raw:e[0]}):this.stop(`a number that is not one`)}text(){let e=this.at;this.at+=1;let t=``;for(;;){this.at>=this.s.length&&this.stop(`a " that is never closed`,e);let n=this.s.charAt(this.at);if(n===`"`){if(this.s.charAt(this.at+1)!==`"`)return this.at+=1,t;this.at+=1}t+=n,this.at+=1}}errorLiteral(e){let t=Ll(this.s,this.at);return t===void 0?this.stop(`a # that names no error`):(this.at+=t.length,{kind:`error`,code:t,...e===void 0?{}:{sheet:e}})}arrayConstant(){let e=this.at;this.at+=1;let t=[[]];for(;;)if(this.blanks(),t[t.length-1]?.push(this.arrayItem()),this.blanks(),!this.eat(`,`)){if(this.eat(`;`))t.push([]);else{if(this.eat(`}`))break;this.stop(`a { that is never closed`,e)}}let n=t[0]?.length;return t.some(e=>e.length!==n)&&this.stop(`an array whose rows are not all as long`,e),{kind:`array`,rows:t}}arrayItem(){let e=this.s.charAt(this.at);if(e===`"`)return{kind:`string`,value:this.text()};if(e===`#`)return this.errorLiteral(void 0);if(e===`-`||e===`+`)return this.at+=1,{kind:`unary`,op:e,arg:this.number()};if(kl(e)||e===`.`)return this.number();let t=this.name(),n=t.toUpperCase();return n===`TRUE`||n===`FALSE`?{kind:`boolean`,value:n===`TRUE`}:this.stop(`${t} in an array: an array holds only constants`)}name(){let e=this.at;for(;this.at<this.s.length&&jl(this.s.charAt(this.at));)this.at+=1;return this.s.slice(e,this.at)}quoted(){let e=this.at;this.at+=1;let t=``;for(;;){this.at>=this.s.length&&this.stop(`a ' that is never closed`,e);let n=this.s.charAt(this.at);if(n===`'`){if(this.s.charAt(this.at+1)!==`'`)return this.at+=1,t;this.at+=1}t+=n,this.at+=1}}bound(e){let t=e.toLowerCase();return this.locals.some(e=>e.has(t))}word(){let e=this.sheetPrefix();if(e)return this.afterSheet(e.first,e.last);let t=Vl(this.s,this.at);if(t)return this.at=t.end,{kind:`ref`,...t.ref};let n=/^([A-Za-z]{1,3}):([A-Za-z]{1,3})/u.exec(this.s.slice(this.at)),r=n!==null&&(this.bound(n[1]??``)||this.bound(n[2]??``))?void 0:zl(this.s,this.at);if(r)return this.at=r.end,{kind:`ref`,...r.ref};if(this.peek(`$`))return this.stop(`a "$" that is not part of a reference`);let i=this.at,a=this.name();if(a===``)return this.stop(`"${this.s.charAt(i)}" in a name`);if(this.peek(`(`))return this.call(a);if(this.peek(`[`))return this.bracket(a);let o=a.toUpperCase();return o===`TRUE`||o===`FALSE`?{kind:`boolean`,value:o===`TRUE`}:{kind:`name`,name:a}}sheetPrefix(){let e=this.at;if(this.peek(`'`)){let t=this.quoted();if(!this.eat(`!`)){this.at=e;return}let n=t.indexOf(`:`);return n>0?{first:t.slice(0,n),last:t.slice(n+1)}:{first:t}}let t=this.name();if(t!==``&&this.eat(`!`))return{first:t};if(t!==``&&this.eat(`:`)){let e=this.name();if(e!==``&&this.eat(`!`))return{first:t,last:e}}this.at=e}afterSheet(e,t){let n={sheet:e,...t===void 0?{}:{lastSheet:t}};if(this.peek(`#`))return this.errorLiteral(e);let r=Vl(this.s,this.at);if(r)return this.at=r.end,{kind:`ref`,...n,...r.ref};let i=zl(this.s,this.at);if(i)return this.at=i.end,{kind:`ref`,...n,...i.ref};let a=this.name();return a===``?this.stop(`nothing after ${e}!`):{kind:`name`,name:a,sheet:e}}call(e){let t=this.at;this.at+=1;let n=[],r=t=>Nl({kind:`call`,name:e.toUpperCase(),written:e,args:n},{inner:t}),i=this.at,a=this.space();if(this.eat(`)`))return r(a);this.at=i;let o=Fl.test(e)?new Set:void 0;o&&this.locals.push(o);let s=e=>(o&&this.locals.pop(),r(e));for(;;){let r=this.at,i=this.space(),a;this.peek(`,`)||this.peek(`)`)?a=Nl({kind:`missing`},{before:i}):(this.at=r,a=this.expression(0));let c=this.space();if(o&&a.kind===`name`&&a.sheet===void 0&&o.add(a.name.replace(/^_xlpm\./iu,``).toLowerCase()),this.eat(`,`))n.push(Nl(a,{after:c}));else{if(n.push(a),this.eat(`)`))return s(c);this.stop(`a ( of ${e.toUpperCase()} that is never closed`,t)}}}columnName(){let e=``;for(;;){this.at>=this.s.length&&this.stop(`a [ that is never closed`);let t=this.s.charAt(this.at);if(t===`]`)return e;t===`[`&&this.stop(`a [ inside a column's name`),t===`'`?(this.at+=1,e+=this.s.charAt(this.at),this.at+=1):(e+=t,this.at+=1)}}bracket(e){let t=this.at;this.at+=1;let n={kind:`structured`,...e===void 0?{}:{table:e},sections:[],columns:[],thisRow:!1};if(this.eat(`]`))return n;if(!(this.peek(`[`)||this.peek(`#`)||this.peek(`@`))){let r=this.columnName();return this.at+=1,e===void 0&&/[!']/u.test(this.s.charAt(this.at))&&this.stop(`a formula that reaches into another workbook`,t),e===void 0&&Al(this.s.charAt(this.at))&&this.stop(`a formula that reaches into another workbook`,t),n.columns=[r.trim()],n}return this.eat(`@`)?(n.thisRow=!0,this.eat(`]`)||(this.peek(`[`)?this.items(n):n.columns=[this.columnName().trim()],this.eat(`]`)||this.stop(`a [ that is never closed`,t)),n):(this.items(n),this.eat(`]`)||this.stop(`a [ that is never closed`,t),n)}items(e){for(;;){if(this.blanks(),this.peek(`#`))this.section(e);else if(this.eat(`[`)){if(this.peek(`#`))this.section(e),this.eat(`]`)||this.stop(`a [ that is never closed`);else{let t=this.columnName().trim();this.at+=1,e.columns.push(t),this.eat(`:`)&&(this.eat(`[`)||this.stop(`a column's name after :`),e.columns.push(this.columnName().trim()),this.at+=1)}}else this.stop(`a column or a section of a table`);if(this.blanks(),!this.eat(`,`))return}}section(e){let t=this.s.slice(this.at).toLowerCase(),n=Tl.find(e=>t.startsWith(e.toLowerCase()));n===void 0&&this.stop(`a section of a table that is not one`),this.at+=n.length,n===`#This Row`?e.thisRow=!0:e.sections.push(n)}},Fl=/^(?:_xlfn\.)?(?:LET|LAMBDA)$/iu,Il=e=>e.kind===`ref`||e.kind===`name`||e.kind===`structured`||e.kind===`call`||e.kind===`paren`||e.kind===`binary`&&(e.op===`:`||e.op===` `);function Ll(e,t){let n=/^#[A-Za-z0-9_/]+[!?]?/u.exec(e.slice(t));return n?je(n[0])?.code:void 0}var Rl=(e,t)=>{let n=e.charAt(t);return n!==``&&(jl(n)||n===`(`||n===`!`||n===`[`)};function zl(e,t){let n=e.slice(t),r=/^(\$?)([A-Za-z]{1,3}):(\$?)([A-Za-z]{1,3})/u.exec(n);if(r){let n=t+r[0].length,i=we(r[2]??``),a=we(r[4]??``);if(i!==void 0&&a!==void 0&&!Rl(e,n))return{ref:{col:Ml(i,r[1]===`$`),col2:Ml(a,r[3]===`$`),range:!0},end:n}}let i=/^(\$?)([A-Za-z]{1,3})(\$?)([1-9]\d*)/u.exec(n);if(!i)return;let a=Bl(i),o=t+i[0].length;if(a&&!Rl(e,o)){if(e.charAt(o)===`:`){let t=/^(\$?)([A-Za-z]{1,3})(\$?)([1-9]\d*)/u.exec(e.slice(o+1));if(t){let n=Bl(t),r=o+1+t[0].length;if(n&&!Rl(e,r))return{ref:{...a,col2:n.col,row2:n.row,range:!0},end:r}}}return{ref:{...a,range:!1},end:o}}}function Bl(e){let t=we(e[2]??``),n=Number(e[4])-1;if(!(t===void 0||t>=16384||n>=1048576))return{col:Ml(t,e[1]===`$`),row:Ml(n,e[3]===`$`)}}function Vl(e,t){let n=/^(\$?)([1-9]\d*):(\$?)([1-9]\d*)/u.exec(e.slice(t));if(!n)return;let r=t+n[0].length,i=Number(n[2])-1,a=Number(n[4])-1;if(!(i>=1048576||a>=1048576||Rl(e,r)))return{ref:{row:Ml(i,n[1]===`$`),row2:Ml(a,n[3]===`$`),range:!0},end:r}}function Hl(e){try{return{ok:!0,node:new Pl(e).parse()}}catch(e){if(e instanceof El)return{ok:!1,error:{message:e.message,at:e.at}};throw e}}var Ul=class{node;error;analysis;text;row;col;atRow;atCol;source;constructor(e,t,n,r,i){this.text=e,this.atRow=t,this.atCol=n,this.source=r;let a=Hl(e);if(!a.ok){this.error=a.error,this.row=t,this.col=n;return}let o=i===void 0||!Wl(a.node)?void 0:wl(a.node,t,n),s=o===void 0?void 0:i?.get(o);s?(this.node=s.node,this.row=s.row,this.col=s.col):(this.node=a.node,this.row=t,this.col=n,o!==void 0&&i?.set(o,{node:a.node,row:t,col:n}))}};function Wl(e){let t=!0,n=e=>{if(!t||typeof e!=`object`||!e)return;let r=e;if(r.kind===`call`&&typeof r.name==`string`&&r.name.toUpperCase()===`TABLE`)t=!1;else for(let t of Object.values(e))if(Array.isArray(t))for(let e of t)n(e);else typeof t==`object`&&t&&n(t)};return n(e),t}var M=class{value=null;array;spill;blocked;state=1;mark=0;shared;sheet;row;col;constructor(e,t,n,r){this.shared=e,this.sheet=t,this.row=n,this.col=r}get moved(){let{node:e,row:t,col:n}=this.shared;if(!e)throw Error(`${this.shared.text} does not parse.`);return Cl(e,this.row-t,this.col-n)}get text(){let{node:e,text:t,atRow:n,atCol:r}=this.shared;return!e||n===this.row&&r===this.col?t:_t(this.moved)}},Gl=class{columns=[];firsts=[];lasts=[];formulas=[];get(e,t){return this.columns[t]?.[e]}set(e,t,n){let r=this.columns[t];r||(r=[],this.columns[t]=r,this.firsts[t]=e,this.lasts[t]=e),r[e]instanceof M&&(this.formulas[t]=(this.formulas[t]??1)-1),n instanceof M&&(this.formulas[t]=(this.formulas[t]??0)+1),r[e]=n,e<(this.firsts[t]??e)&&(this.firsts[t]=e),e>(this.lasts[t]??e)&&(this.lasts[t]=e)}get width(){return this.columns.length}holds(e,t,n){let r=Math.min(e.right,this.columns.length-1);for(let i=e.left;i<=r;i++){let r=this.columns[i];if(!r)continue;let a=Math.min(e.bottom,this.last(i));for(let o=Math.max(e.top,this.first(i));o<=a;o++)if(r[o]!==void 0&&(o!==t||i!==n))return!0}return!1}first(e){return this.firsts[e]??1/0}last(e){return this.lasts[e]??-1}hasFormulas(e){return(this.formulas[e]??0)>0}},Kl=class{columns=[];rows=0;lines=[];places=[];records=[];name;sheet;at;file;spec;constructor(e,t,n,r,i){this.name=e,this.sheet=t,this.at=n,this.file=r,this.spec=i}get area(){return{top:this.at.row,left:this.at.col,bottom:this.at.row+this.rows,right:this.at.col+Math.max(this.columns.length,1)-1}}get data(){let e=this.area;return{...e,top:e.top+1}}column(e){let t=e.toLowerCase();return this.columns.find(e=>e.name.toLowerCase()===t)}},ql=(e,t)=>e*16384+t;function Jl(e,t){e.bottom=Math.max(e.bottom,t.bottom),e.right=Math.max(e.right,t.right);for(let n=t.left;n<=t.right;n++){let r=e.columns.get(n);e.columns.set(n,[Math.min(r?.[0]??t.top,t.top),Math.max(r?.[1]??t.bottom,t.bottom)])}}var Yl=class{tables=[];blocks=[];merges=[];formulas=new Set;implied=new Map;keys=new Map;fills=[];blanks=new Set;conditions=[];validations=[];filters=[];charts=[];tiles=[];sparklines=[];names=new Map;freeze;generated=!1;grid=new Gl;expanded=!1;lowest=-1;ghosts=new Map;spills=new Set;stopped=new Set;reach;lookAreas;name;index;spec;book;constructor(e,t,n){this.name=e,this.index=t,this.spec=n}respec(e){let t=e.charts!==this.spec.charts;this.spec=e,this.lookAreas=void 0,t&&(this.charts.length=0,e.charts?.forEach((e,t)=>{let n=lu(cu(this,e),t,[],()=>void 0);n&&this.charts.push(n)}))}put(e,t,n){n instanceof M&&this.formulas.add(n),this.grid.set(e,t,n),e>this.lowest&&(this.lowest=e)}replace(e,t,n){this.expand();let r=this.grid.get(e,t);r instanceof M&&this.formulas.delete(r),n instanceof M&&this.formulas.add(n),this.grid.set(e,t,n),e>this.lowest&&(this.lowest=e)}expand(){if(!this.expanded){this.expanded=!0;for(let e=this.fills.length-1;e>=0;e--){let t=this.fills[e];if(!t)continue;let{area:n,shared:r,value:i,format:a,start:o}=t;for(let e=n.top;e<=n.bottom;e++)for(let t=n.left;t<=n.right;t++)if(this.grid.get(e,t)===void 0&&!this.blanks.has(ql(e,t))){if(r){let n=new M(r,this,e,t);o!==void 0&&(n.value=o),this.put(e,t,n)}else i!=null&&(this.put(e,t,i),a!==void 0&&this.implied.set(ql(e,t),a))}}}}at(e,t){return this.expand(),this.grid.get(e,t)}spillAt(e,t){return this.ghosts.size===0?void 0:this.ghosts.get(ql(e,t))}holds(e,t){return this.expand(),this.grid.holds(e,t.row,t.col)}spillsIn(e){if(this.spills.size===0)return[];if((e.bottom-e.top+1)*(e.right-e.left+1)>=this.spills.size)return[...this.spills].filter(t=>t.spill!==void 0&&S(t.spill,e));let t=new Set;for(let n=e.top;n<=e.bottom;n++)for(let r=e.left;r<=e.right;r++){let e=this.ghosts.get(ql(n,r));e&&t.add(e)}return[...t]}blockedBy(e){if(this.stopped.size===0)return[];let t=[];for(let n of this.stopped)n.blocked&&S(n.blocked,e)&&t.push(n);return t}placeSpill(e,t){e.spill=t,this.spills.add(e);for(let n=t.top;n<=t.bottom;n++)for(let r=t.left;r<=t.right;r++)(n!==e.row||r!==e.col)&&this.ghosts.set(ql(n,r),e);this.reach&&Jl(this.reach,t)}blockSpill(e,t){e.blocked=t,this.stopped.add(e)}clearSpill(e){let t=e.spill;if(t)for(let n=t.top;n<=t.bottom;n++)for(let r=t.left;r<=t.right;r++)this.ghosts.get(ql(n,r))===e&&this.ghosts.delete(ql(n,r));e.spill=void 0,e.blocked=void 0,this.spills.delete(e),this.stopped.delete(e)}clearSpills(){for(let e of[...this.spills,...this.stopped])e.spill=void 0,e.blocked=void 0;this.spills.clear(),this.stopped.clear(),this.ghosts.clear(),this.reach=void 0}tighten(){this.reach=void 0}spillReach(){if(this.reach)return this.reach;let e={columns:new Map,bottom:-1,right:-1};for(let{spill:t}of this.spills)t&&Jl(e,t);return this.reach=e,e}hasFormulas(e){return this.expand(),this.grid.hasFormulas(e)}span(e,t,n){this.expand();let r=this.grid.first(e),i=this.grid.last(e);if(this.spills.size===0)return[Math.max(t,r),Math.min(n,i)];let[a,o]=this.spillReach().columns.get(e)??[1/0,-1];return[Math.max(t,Math.min(r,a)),Math.min(n,Math.max(i,o))]}get columnsUsed(){return this.expand(),this.spills.size===0?this.grid.width:Math.max(this.grid.width,this.spillReach().right+1)}get lastRow(){return this.expand(),this.spills.size===0?this.lowest:Math.max(this.lowest,this.spillReach().bottom)}get used(){let e=this.lastRow,t=this.columnsUsed-1;return e<0||t<0?void 0:{top:0,left:0,bottom:e,right:t}}tableAt(e,t){return this.tables.find(n=>ke(n.area,e,t))}blockAt(e,t){return this.blocks.find(n=>ke(n.area,e,t))}looks(){if(this.lookAreas)return this.lookAreas;let e=[];for(let t of this.spec.format??[]){let n=x(t.range);n&&e.push({area:n,entry:t})}let t=[];for(let[e,n]of Object.entries(this.spec.cells??{})){if(!e.includes(`:`)||typeof n!=`object`||!n)continue;let r=x(e);r&&t.push({area:r,entry:n})}return this.lookAreas={formats:e,ranges:t},this.lookAreas}styledAreas(){let{formats:e,ranges:t}=this.looks();return[...e,...t.filter(e=>Object.keys(e.entry).some(e=>eu.has(e)))]}lookAt(e,t){let n={},r=e=>{if(!e)return;let t=e.style;typeof t==`string`&&r(this.styleLook(t));for(let[t,r]of Object.entries(e))eu.has(t)&&r!==void 0&&(n[t]=t===`border`?{...n.border,...r}:r)},i=this.implied.get(ql(e,t));i!==void 0&&(n.format=i);let a=this.ghosts.size===0?void 0:this.spillAt(e,t),o=a&&this.lookAt(a.row,a.col).format;o!==void 0&&(n.format=o),this.spec.columns&&r(this.spec.columns[Ce(t)]),this.spec.rows&&r(this.spec.rows[String(e+1)]);let s=this.tableAt(e,t);s&&e>s.at.row&&r(s.columns[t-s.at.col]?.spec);let{formats:c,ranges:l}=this.looks();for(let n of c)ke(n.area,e,t)&&r(n.entry);for(let n of l)ke(n.area,e,t)&&r(n.entry);let u=this.keys.get(ql(e,t)),d=u===void 0?void 0:this.spec.cells?.[u];if(typeof d==`object`&&d&&r(d),n.border){let e=Object.entries(n.border).filter(([,e])=>e?.style!==`none`);e.length===0?delete n.border:n.border=Object.fromEntries(e)}return Ql(n,this.book?.colors)}styleLook(e){if(this.book)return this.book.styleLook(e);let t=$l(e,void 0);return t&&`builtin`in t?fl(t.builtin):void 0}runsAt(e,t){let n=this.keys.get(ql(e,t)),r=n===void 0?void 0:this.spec.cells?.[n];return typeof r==`object`&&r?r.runs:void 0}mergeAt(e,t){return this.merges.find(n=>ke(n,e,t))}validationAt(e,t){return this.validations.find(n=>n.areas.some(n=>ke(n,e,t)))}filterHeadAt(e,t){return this.filters.find(n=>e===n.area.top&&t>=n.area.left&&t<=n.area.right)}filterAt(e,t){return this.filters.find(n=>ke(n.area,e,t))}filesAt(e,t){let n=this.tableAt(e,t);if(n&&e>n.at.row){let e=n.columns[t-n.at.col]?.spec?.files;if(e!==void 0)return e}return n?.at.row===e?void 0:this.spec.columns?.[Ce(t)]?.files}},Xl=e=>(typeof e==`object`?e.separator:void 0)??`, `;function Zl(e,t){let n=Xl(t);return e.split(n.trim()===``?n:n.trim()).map(e=>e.trim()).filter(e=>e!==``)}function Ql(e,t){let n=e=>typeof e==`string`&&!e.startsWith(`#`),r=e.fill;return n(e.color)||n(r)||typeof r==`object`&&(n(r.color)||n(r.background))||Object.values(e.border??{}).some(e=>n(e?.color))?il(e,t??u):e}function $l(e,t){if(t&&e in t)return{own:e};let n=t?i(e,Object.keys(t)):void 0;if(n!==void 0)return{own:n};let r=i(e,be);return r===void 0?void 0:{builtin:ye[r]??r}}var eu=new Set([`style`,`bold`,`italic`,`underline`,`strike`,`font`,`size`,`color`,`fill`,`align`,`valign`,`wrap`,`shrink`,`indent`,`rotation`,`border`,`locked`,`hide_formula`,`format`]),tu=class{title;sheets=[];names=new Map;checks=[];bySheet=new Map;byTable=new Map;file;generated;ordinary=[];colors;themeOrder;projectTheme;constructor(e,t,n){this.file=e,this.title=e.title,this.generated=t,this.projectTheme=n,this.colors=c(this.theme),this.themeOrder=el(this.colors)}get theme(){return this.file.theme??this.projectTheme}respec(e){this.file=ml(e,this.generated).file,this.title=e.title,this.colors=c(this.theme),this.themeOrder=el(this.colors),this.sheets.forEach(t=>{let n=e.sheets.find(e=>e.name===t.name);n&&t.respec(n)})}sheet(e){return this.bySheet.get(e.toLowerCase())}styleLook(e,t=0){let n=this.file.styles,r=$l(e,n);if(!r)return;if(`builtin`in r)return fl(r.builtin,this.colors);let i=n?.[r.own];if(i){let n={...i.style!==void 0&&i.style!==e&&t<8?this.styleLook(i.style,t+1):void 0};for(let[e,t]of Object.entries(i))e!==`style`&&t!==void 0&&(n[e]=e===`border`?{...n.border,...t}:t);return Ql(n,this.colors)}}styleNamed(e){return $l(e,this.file.styles)}table(e){return this.byTable.get(e.toLowerCase())}name(e,t){let n=e.toLowerCase();return(t?.names.size?t.names.get(n):void 0)??this.names.get(n)}definitions(e){let t=e.toLowerCase(),n=[],r=this.names.get(t);r&&n.push(r);for(let e of this.sheets){let r=e.names.get(t);r&&n.push(r)}return n}get tables(){return[...this.byTable.values()]}addSheet(e){e.book=this,this.sheets.push(e),this.bySheet.set(e.name.toLowerCase(),e)}addTable(e){e.sheet.tables.push(e),this.byTable.set(e.name.toLowerCase(),e)}sourceOf(e,t,n){if(e.generated)return{file:qa};let r=this.sheets.indexOf(e),i=e.tableAt(t,n);if(i){let e=i.columns[n-i.at.col],r=t-i.at.row-1,a=e?.csv!==void 0&&(i.records[r]?.[e.csv]??``)!==``;return r>=0&&e?.formula&&!a?e.formula.source:{file:i.file,line:r<0?1:i.lines[r]??1}}let a=e.blockAt(t,n);if(a)return{file:a.file,line:a.lines[t-a.area.top]??1};let o=e.keys.get(ql(t,n));if(o!==void 0)return{file:Ka,path:[`sheets`,r,`cells`,o]};for(let i of Object.keys(e.spec.cells??{})){if(!i.includes(`:`))continue;let e=x(i);if(e&&ke(e,t,n))return{file:Ka,path:[`sheets`,r,`cells`,i]}}}},nu=/^[\p{L}_\\][\p{L}\p{N}_.\\?]*$/u;function ru(e){return nu.test(e)&&De(e)===void 0&&!/^(?:TRUE|FALSE)$/iu.test(e)&&!/^[Rr](?:\d+)?(?:[Cc]\d*)?$/u.test(e)&&!/^[Cc]\d*$/u.test(e)}var iu=`made`,au=e=>e[0]===iu?qa:Ka;function ou(e){let t=e.length;for(;t>1&&(e[t-1]??``).trim()===``;)t--;return e.slice(0,t)}var su=class{problems=[];wb;read_;lineOf;own;madeNames;trees=new Map;unread=new Set;constructor(e,t,n,r,i){this.wb=e,this.read_=t,this.lineOf=n,this.own=r,this.madeNames=i}yaml(e,t){let n=this.lineOf(e);this.problems.push({file:au(e),...n===void 0?{}:{line:n},message:t})}sheetPath(e){return e<this.own?[`sheets`,e]:[iu,`sheets`,e-this.own]}read(){let{file:e}=this.wb;e.sheets.forEach((e,t)=>{let n=this.sheetPath(t);if(this.wb.sheet(e.name)){this.yaml([...n,`name`],`two sheets are named ${e.name}`);return}(/[\\/?*[\]:]/u.test(e.name)||e.name.length>31)&&this.yaml([...n,`name`],`${e.name} cannot be a sheet's name: at most 31 characters, none of \\ / ? * [ ] :`);let r=new Yl(e.name,this.wb.sheets.length,e);r.generated=t>=this.own,this.wb.addSheet(r)}),this.names();for(let[t,n]of e.sheets.entries()){let e=this.wb.sheets[t];e?.spec===n&&this.sheet(e,this.sheetPath(t))}this.styles(),e.checks?.forEach((e,t)=>{let n={file:Ka,path:[`checks`,t,`formula`]};this.wb.checks.push({name:e.name,formula:new Ul(e.formula,0,0,n),source:n})})}styles(){let{file:e}=this.wb,t=Object.keys(e.styles??{}),n=(e,n)=>{if(typeof n!=`object`||!n)return;let r=n.style;if(typeof r!=`string`||this.wb.styleNamed(r))return;let i=l(r,[...t,...be]);this.yaml([...e,`style`],`${r} is no cell style${i===void 0?``:`: did you mean "${i}"?`} A style is one of Excel's (Heading 1, Input, Total, 20% - Accent1…) or one \`styles\` defines`)};for(let[t,r]of Object.entries(e.styles??{}))n([`styles`,t],r);e.sheets.forEach((e,t)=>{if(t>=this.own)return;let r=[`sheets`,t];for(let[t,i]of Object.entries(e.cells??{}))n([...r,`cells`,t],i);e.format?.forEach((e,t)=>{n([...r,`format`,t],e)});for(let[t,i]of Object.entries(e.columns??{}))n([...r,`columns`,t],i);for(let[t,i]of Object.entries(e.rows??{}))n([...r,`rows`,t],i);e.tables?.forEach((e,t)=>{for(let[i,a]of Object.entries(e.columns??{}))n([...r,`tables`,t,`columns`,i],a)})})}names(){let{file:e}=this.wb;this.namesOf(e.names,e.hidden_names,e=>this.madeNames.has(e)?[iu,`names`,e]:[`names`,e],this.wb.names,void 0),e.sheets.forEach((e,t)=>{let n=this.wb.sheets[t];n?.spec===e&&this.namesOf(e.names,e.hidden_names,e=>[...this.sheetPath(t),`names`,e],n.names,n)})}namesOf(e,t,n,r,i){let a=new Set(t?.map(e=>e.toLowerCase()));for(let[t,o]of Object.entries(e??{})){let e=n(t);if(!ru(t)){this.yaml(e,`${t} cannot be a name`);continue}let s={file:au(e),path:e},c=typeof o==`string`&&o.startsWith(`=`)?{name:t,formula:new Ul(o,0,0,s),source:s}:{name:t,value:typeof o==`string`?Xe(o).value:o,source:s};i&&(c.sheet=i),a.has(t.toLowerCase())&&(c.hidden=!0),r.set(t.toLowerCase(),c)}}sheet(e,t){let{spec:n}=e;if(n.freeze!==void 0){let r=De(n.freeze);r?e.freeze=r:this.yaml([...t,`freeze`],`${n.freeze} is not a cell`)}n.tables?.forEach((n,r)=>{this.table(e,n,[...t,`tables`,r])});for(let[t,n]of e.tables.entries())for(let r of e.tables.slice(t+1))S(n.area,r.area)&&this.problems.push({file:Ka,message:`tables ${n.name} and ${r.name} overlap on ${e.name}`});n.blocks?.forEach((n,r)=>{this.block(e,n.at,n.rows,[...t,`blocks`,r])}),this.cells(e,n.cells??{},[...t,`cells`]),n.merges?.forEach((n,r)=>{let i=x(n);i?e.merges.push(i):this.yaml([...t,`merges`,r],`${n} is not a range`)}),n.format?.forEach((e,n)=>{x(e.range)||this.yaml([...t,`format`,n,`range`],`${e.range} is not a range`)}),n.conditional?.forEach((n,r)=>{this.condition(e,n,[...t,`conditional`,r])}),n.validations?.forEach((n,r)=>{this.validation(e,n,[...t,`validations`,r])}),this.filters(e,t),n.charts?.forEach((n,r)=>{this.chart(e,n,r,[...t,`charts`,r])}),n.tiles?.forEach((n,r)=>{let i=cu(e,n),a=Object.keys(n).find(e=>s(e)!==void 0);if(a!==void 0&&s(a)===`heatmap`){let i=rt(n.at,n[a],this.wb.colors);for(let e of i.problems)this.yaml([...t,`tiles`,r,a],e);i.rule&&this.condition(e,i.rule,[...t,`tiles`,r,`at`]);return}let o=De(i.at);o?a!==void 0&&e.tiles.push({spec:i,at:o,index:r,kind:a}):this.yaml([...t,`tiles`,r,`at`],`${n.at} is not a cell`)}),n.sparklines?.forEach((n,r)=>{let i=Vt(e.name,n);i.cells?e.sparklines.push({spec:n,index:r,cells:i.cells}):this.yaml([...t,`sparklines`,r],i.problem??`not a sparkline`)});for(let e of Object.keys(n.columns??{}))we(e)===void 0&&this.yaml([...t,`columns`,e],`${e} is not a column`);for(let e of Object.keys(n.rows??{}))(!/^[1-9]\d*$/u.test(e)||Number(e)>1048576)&&this.yaml([...t,`rows`,e],`${e} is not a row`)}chart(e,t,n,r){let i=lu(cu(e,t),n,r,(e,t)=>{this.yaml(e,t)});i&&e.charts.push(i)}bound(e,t,n){if(!(typeof e!=`string`||!e.startsWith(`=`)||e.length<2))return new Ul(e,t?.top??0,t?.left??0,{file:au(n),path:n})}condition(e,t,n){let r=Oe(t.range);if(!r){this.yaml([...n,`range`],`${t.range} is not a range`);return}let[i]=r,a=[],o=(e,t)=>{let n=this.bound(e,i,t);n&&a.push(n)};if(t.type===`expression`&&o(t.formula.startsWith(`=`)?t.formula:`=${t.formula}`,[...n,`formula`]),t.type===`cellIs`&&t.formula.forEach((e,t)=>{o(e,[...n,`formula`,t])}),t.type===`dataBar`)for(let e of[`min`,`max`])o(t[e]?.value,[...n,e,`value`]);(t.type===`colorScale`||t.type===`iconSet`)&&t.stops?.forEach((e,t)=>{o(e.value,[...n,`stops`,t,`value`])}),e.conditions.push({spec:t,areas:r,formulas:a})}validation(e,t,n){let r=Oe(t.range);if(!r){this.yaml([...n,`range`],`${t.range} is not a range`);return}let i=(t.formula??[]).map((e,t)=>this.bound(e,r[0],[...n,`formula`,t])),a=t.formula?.length??0,o=t.type!==`list`&&t.type!==`custom`&&(t.operator===void 0||t.operator===`between`||t.operator===`notBetween`);(t.type!==`list`||t.values===void 0)&&a<(o?2:1)&&this.yaml(n,`a ${t.type} validation needs its bounds`),e.validations.push({spec:t,areas:r,formulas:i})}filters(e,t){let{spec:n}=e;if(n.filter){let r=[...t,`filter`],i=x(n.filter.range);if(!i)this.yaml([...r,`range`],`${n.filter.range} is not a range`);else{let t=new Map;for(let[e,a]of Object.entries(n.filter.columns??{})){let o=we(e);o===void 0||o<i.left||o>i.right?this.yaml([...r,`columns`,e],`${e} is not a column of ${n.filter.range}`):t.set(o,a)}let a=e.tables.find(e=>S(e.area,i));a&&this.yaml(r,`a filter over table ${a.name}: a table has its own`),e.filters.push({area:i,columns:t})}}e.tables.forEach((n,r)=>{let{filter:i}=n.spec;if(i===!1)return;let a=new Map;for(let[e,o]of Object.entries(i?.columns??{})){let i=n.column(e);i?a.set(n.at.col+i.index,o):this.unread.has(n)||this.yaml([...t,`tables`,r,`filter`,`columns`,e],`table ${n.name} has no column ${e}`)}e.filters.push({area:n.area,table:n,columns:a})})}csv(e,t,n){let r=this.read_(e);return r||this.yaml(t,`${n}: ${e} is not there, from this file's folder or from the project's root`),r}overlapping(e,t){let n=e.tables.find(e=>S(e.area,t));if(n)return`table ${n.name}`;let r=e.blocks.find(e=>S(e.area,t));return r?`the block of ${r.file}`:void 0}typed(e,t,n,r,i){if(r.formula!==void 0){let a=new M(new Ul(r.formula,t,n,i,this.trees),e,t,n);r.start!==void 0&&(a.value=r.start),e.put(t,n,a)}else r.value!==null&&(e.put(t,n,r.value),r.format!==void 0&&e.implied.set(ql(t,n),r.format))}table(e,t,n){let r=De(t.at);if(!r){this.yaml([...n,`at`],`${t.at} is not a cell`);return}if(!ru(t.name)){this.yaml([...n,`name`],`${t.name} cannot be a table's name`);return}if(this.wb.table(t.name)){this.yaml([...n,`name`],`two tables are named ${t.name}`);return}this.wb.name(t.name)&&this.yaml([...n,`name`],`${t.name} is a defined name and a table's`);let i=new Kl(t.name,e,r,t.rows,t),a=this.csv(t.rows,[...n,`rows`],`table ${t.name}`),o=a?.rows??[],s=a?.lines??[],c=o[0],l=s[0]??1,u=new Set,d=ou(c??[]),f=c?.length===0?[``]:o.slice(1).every(e=>e.slice(d.length).every(e=>e.trim()===``))?d:c??[];f.forEach((e,n)=>{let r=e.trim();r===``&&this.problems.push({file:t.rows,line:l,message:`column ${String(n+1)} has no name`}),u.has(r.toLowerCase())&&this.problems.push({file:t.rows,line:l,message:`two columns are named ${r}`}),u.add(r.toLowerCase()),i.columns.push({name:r,index:i.columns.length,csv:n})});for(let[e,r]of Object.entries(t.columns??{})){let o=i.column(e),s=o??{name:e,index:i.columns.length};o||(r.formula===void 0&&a&&this.yaml([...n,`columns`,e],`table ${t.name} has no column ${e}`),i.columns.push(s)),s.spec=r}let p=f.length;for(let e=1;e<o.length;e++){let n=o[e];if(!n||n.length===0)continue;let r=s[e]??e+1;i.places.push(e),i.records.push(n),i.lines.push(r),n.slice(p).some(e=>e.trim()!==``)&&this.problems.push({file:t.rows,line:r,message:`this row has ${String(n.length)} fields and the header ${String(p)}`})}i.rows=i.records.length;let m=this.overlapping(e,i.area);m&&this.yaml(n,`table ${t.name} overlaps ${m} on ${e.name}`),this.wb.addTable(i),a?this.tableKey(i,n):this.unread.add(i);let h=r.row+1;i.columns.forEach(a=>{let o=r.col+a.index;e.put(r.row,o,a.name);let s=a.spec?.formula;s!==void 0&&(a.formula=new Ul(s,h,o,{file:au(n),path:[...n,`columns`,a.name,`formula`]}),i.rows>0&&e.fills.push({area:{top:h,left:o,bottom:h+i.rows-1,right:o},shared:a.formula})),a.csv!==void 0&&i.records.forEach((n,r)=>{this.typed(e,h+r,o,Xe(n[a.csv??0]??``),{file:t.rows,line:i.lines[r]??1})})})}tableKey(e,t){let{key:n}=e.spec;if(n===void 0)return;let r=e.column(n);if(r?.csv===void 0){this.yaml([...t,`key`],`table ${e.name} has no column ${n} in ${e.file}`);return}let i=new Set;e.records.forEach((t,a)=>{let o=t[r.csv??0]??``,s=e.lines[a]??1;o===``?this.problems.push({file:e.file,line:s,message:`this row has no ${n}, table ${e.name}'s key`}):i.has(o)&&this.problems.push({file:e.file,line:s,message:`two rows have the key ${o}`}),i.add(o)})}block(e,t,n,r){let i=De(t);if(!i){this.yaml([...r,`at`],`${t} is not a cell`);return}let a=this.csv(n,[...r,`rows`],`a block`);if(!a)return;let o=a.rows,s=o.map((e,t)=>a.lines[t]??t+1),c=o.reduce((e,t)=>Math.max(e,t.length),1),l={top:i.row,left:i.col,bottom:i.row+Math.max(o.length,1)-1,right:i.col+c-1},u=this.overlapping(e,l);u&&this.yaml(r,`the block of ${n} overlaps ${u} on ${e.name}`),e.blocks.push({area:l,file:n,lines:s}),o.forEach((t,r)=>{t.forEach((t,a)=>{this.typed(e,i.row+r,i.col+a,Xe(t),{file:n,line:s[r]??r+1})})})}cells(e,t,n){let r=[];for(let[i,a]of Object.entries(t)){let t=[...n,i],o=x(i);if(!o){this.yaml(t,`${i} is not a cell or a range`);continue}let s=this.overlapping(e,o);if(s&&this.yaml(t,`${i} overlaps ${s}`),i.includes(`:`)){let n=(o.bottom-o.top+1)*(o.right-o.left+1);n>5e6?this.yaml(t,`${i} is ${String(n)} cells`):(typeof a==`object`&&a&&a.runs&&this.yaml([...t,`runs`],`${i} is a range: runs are one cell's`),this.fill(e,o,a,t))}else r.push([i,a,{row:o.top,col:o.left}])}for(let[t,i,a]of r){let r=[...n,t],o=pu(i),s=ql(a.row,a.col);e.keys.set(s,t),o.value===null&&o.formula===void 0&&e.blanks.add(s),this.typed(e,a.row,a.col,o,{file:au(r),path:r});let c=typeof i==`object`&&i?i.name:void 0;c!==void 0&&this.cellName(e,a,c,r)}}cellName(e,t,n,r){if(!ru(n)){this.yaml(r,`${n} cannot be a name`);return}if(this.wb.name(n)){this.yaml(r,`two places are named ${n}`);return}let i={file:au(r),path:r},a=Te(t).replace(/^([A-Z]+)(\d+)$/u,`$$$1$$$2`),o=`='${e.name.replaceAll(`'`,`''`)}'!${a}`;this.wb.names.set(n.toLowerCase(),{name:n,formula:new Ul(o,0,0,i),source:i})}fill(e,t,n,r){let i=pu(n),a={file:au(r),path:r};e.fills.push(i.formula===void 0?{area:t,value:i.value,...i.format===void 0?{}:{format:i.format}}:{area:t,shared:new Ul(i.formula,t.top,t.left,a),...i.start===void 0?{}:{start:i.start}})}};function cu(e,t){let n=t.at.includes(`:`)?x(t.at):void 0;if(!n)return t;let r=0;for(let t=n.left;t<=n.right;t++)r+=Tu(e,t);let i=0;for(let t=n.top;t<=n.bottom;t++)i+=Eu(e,t);return{...t,at:Te({row:n.top,col:n.left}),width:t.width??r,height:t.height??i}}function lu(e,t,n,r){let i=De(e.at);if(!i){r([...n,`at`],`${e.at} is not a cell`);return}let a=(e,t)=>{let n=new Ul(uu(e),0,0,{file:au(t),path:t});return n.node&&!du(n.node)&&r(t,`${e} is not a range or a table's column`),n},o=(e,t)=>e?.startsWith(`=`)===!0?a(e,t):void 0,s=o(e.title,[...n,`title`]);return{spec:e,at:i,index:t,...e.categories===void 0?{}:{categories:a(e.categories,[...n,`categories`])},...s?{title:s}:{},series:e.series.map((e,t)=>{let r=[...n,`series`,t],i=o(e.name,[...r,`name`]);return{values:a(e.values,[...r,`values`]),...e.x===void 0?{}:{x:a(e.x,[...r,`x`])},...e.sizes===void 0?{}:{sizes:a(e.sizes,[...r,`sizes`])},...i?{name:i}:{}}})}}var uu=e=>e.startsWith(`=`)?e:`=${e}`;function du(e){switch(e.kind){case`error`:case`ref`:case`structured`:case`name`:return!0;case`paren`:case`postfix`:return du(e.arg);case`binary`:return e.op===`:`||e.op===`,`;default:return!1}}var fu=e=>e.map(e=>e.text).join(``);function pu(e){if(e===null)return{value:null};if(typeof e==`string`)return Xe(e);if(typeof e!=`object`)return{value:e};if(e.formula!==void 0)return{value:null,formula:e.formula.startsWith(`=`)?e.formula:`=${e.formula}`,...e.start===void 0?{}:{start:typeof e.start==`string`?Xe(e.start).value:e.start}};if(e.runs!==void 0)return{value:fu(e.runs)};let{value:t}=e;return typeof t==`string`?Xe(t):{value:t??null}}function mu(e){let t=ml(e.file,e.generated),n=new tu(t.file,e.generated,e.theme);return n.ordinary=t.ordinary,new su(n,t=>{let n=e.generated?.csv[t];if(n!==void 0)return{rows:f(n).records.map(e=>e.end===e.start?[]:e.fields),lines:[]};let r=e.rows(t);return r&&{rows:r,lines:[]}},()=>void 0,t.own,t.names).read(),n}var hu={width:320,height:160},gu=e=>({width:e.spec.width??hu.width,height:e.spec.height??hu.height});function _u(e,t,n){let r=n.replace(/^=/u,``).trim(),i=t.book?.tables.find(e=>e.name.toLowerCase()===r.toLowerCase());if(!i)return;let{top:a,bottom:o,left:s}=i.data,c=[],l=[];for(let t=a;t<=o;t++){let n={},r={};for(let a of i.columns){let o={value:e.value(i.sheet,t,s+a.index),sheet:i.sheet,row:t,col:s+a.index};n[a.name]=o.value instanceof Object?String(o.value):o.value,r[a.name]=bt(o)}c.push(n),l.push(r)}return{value:c,shown:l}}function vu(e,t,n){let r=_u(e,t,n);if(r)return r;let i=new Ul(uu(n),0,0,{file:``,path:[]});if(!i.node)return;let a=yt(e,t,i);if(a.length===0)return;let o=a.map(e=>e.value instanceof Object?String(e.value):e.value),s=a.map(bt);return a.length===1?{value:o[0],shown:s[0]}:{value:o,shown:s}}function yu(e,t,n){let r=ce(n.kind,n.spec[n.kind],{data:n=>vu(e,t,n)?.value??void 0,shown:n=>vu(e,t,n)?.shown}),i=r.problems.map(e=>`${e.path.length>0?`${e.path.join(`.`)}: `:``}${e.message}`);return r.block===void 0?{problems:i}:{def:r.block,problems:i}}var bu=new WeakMap;function xu(e){let t=d(`task`,{[e]:`1`});return Object.keys(t.fields??{})[0]}function Su(e,t){let n=bu.get(t);if(n)return n;let r=Cu(e,t);return bu.set(t,r),r}function Cu(e,t){if(s(t.kind)!==`gantt`)return{};let n=a(t.kind,t.spec[t.kind]).block?.fields,r=(typeof n?.data==`string`?n.data:``).replace(/^=/u,``).trim(),i=e.book?.tables.find(e=>e.name.toLowerCase()===r.toLowerCase());if(!i)return{};let o=n?.columns??{},c=e=>{let t=o[e];return t===void 0?i.columns.find(t=>xu(t.name)===e):i.columns.find(e=>e.name.toLowerCase()===t.toLowerCase())},l=c(`name`),u=c(`start`),d=c(`duration`),f=c(`group`);if(!l||!u||!d)return{problem:`a Gantt over the cells draws Excel's own Gantt from ${i.name}'s task, start and duration columns${!d&&c(`end`)?`: add a duration column, =[@End]-[@Start]`:``}; it has ${i.columns.map(e=>e.name).join(`, `)}.`};let p=e=>`${i.name}[${e.name.replace(/([[\]#'])/gu,`'$1`)}]`,m=lu({type:`bar-stacked`,at:Te(t.at),...t.spec.x===void 0?{}:{x:t.spec.x},...t.spec.y===void 0?{}:{y:t.spec.y},...gu(t),categories:p(l),series:[{name:u.name,values:p(u)},{name:d.name,values:p(d)}],gap_width:40,category_axis:{reverse:!0},value_axis:{gridlines:!0}},t.index,[],()=>void 0);return m?(m.gantt={...f?{group:new Ul(uu(p(f)),0,0,{file:``,path:[]})}:{}},{chart:m}):{}}function wu(e,t,n,r={}){let{def:i,problems:a}=yu(e,t,n);if(i===void 0)return{problems:a};let{width:o,height:s}=gu(n),c=Su(t,n);if(c.chart)return{svg:jt(Et(e,t,c.chart),o,s,{...t.book?{colors:t.book.colors}:{}}),alt:ne(i),problems:a};c.problem!==void 0&&a.push(c.problem);let l=oe(t.book?.colors??u,{...r.ground===void 0?{}:{ground:r.ground}});return{svg:se(i,{width:o*.75,height:s*.75},l,{id:r.id??`t${String(n.index)}`}),alt:ne(i),problems:a}}function Tu(e,t){let n=e.spec.columns?.[Ce(t)]?.width;if(n!==void 0)return n;for(let n of e.tables){let e=n.columns[t-n.at.col]?.spec?.width;if(e!==void 0)return e}return 64}var Eu=(e,t)=>e.spec.rows?.[String(t+1)]?.height??20,Du=e=>e instanceof C?{error:e.code}:e;function Ou(e){return typeof e!=`object`||!e?e:je(e.error)??w.VALUE}var ku=e=>({rows:e.rows,cols:e.cols,data:e.data.map(Du)}),Au=e=>new T(e.rows,e.cols,e.data.map(Ou));function ju(e,t){let n=t.formula?.text;if(n===void 0)return;let r=Hl(n);if(!r.ok||r.node.kind!==`ref`)return;let i=r.node;if(i.range||!i.col||!i.row||i.lastSheet!==void 0)return;let a=i.sheet===void 0?e.sheets[0]:e.sheet(i.sheet);return a&&{sheet:a,row:i.row.index,col:i.col.index}}var Mu=e=>typeof e==`string`?Xe(e):{value:e??null};function Nu(e,t){let n=e.file.scenarios?.[t];if(!n)return!1;for(let[t,r]of Object.entries(n)){let n=e.name(t);if(!n)continue;let i=Mu(r),a=ju(e,n);i.formula===void 0?a?a.sheet.replace(a.row,a.col,i.value??void 0):(n.value=i.value,delete n.formula):(n.formula=new Ul(i.formula,0,0,n.source),delete n.value)}return!0}var Pu=new Map,Fu=5e4;function Iu(e){if(!/\d/u.test(e))return;if(Pu.has(e))return Pu.get(e);Pu.size>=Fu&&Pu.clear();let t=Lu(e);return Pu.set(e,t),t}function Lu(e){let t=Xe(e.trim());if(typeof t.value==`number`)return t.value;if(e.trim()===``)return;let n=m(e);if(typeof n?.value==`number`)return n.value;let r=/^(\s*\d{1,2})([A-Za-z]{3,}\s+\d{2,4}\s*)$/u.exec(e);if(!r)return;let i=m(`${r[1]??``} ${r[2]??``}`);return typeof i?.value==`number`?i.value:void 0}function N(e){return typeof e==`number`?e:e==null?0:typeof e==`boolean`?+!!e:e instanceof C?e:Iu(e)??w.VALUE}function P(e){return typeof e==`string`?e:e==null?``:typeof e==`number`?Ue(e):typeof e==`boolean`?e?`TRUE`:`FALSE`:e}function Ru(e){if(typeof e==`boolean`)return e;if(e==null)return!1;if(typeof e==`number`)return e!==0;if(e instanceof C)return e;let t=e.trim().toUpperCase();return t===`TRUE`||t!==`FALSE`&&w.VALUE}var zu=e=>typeof e==`number`?0:typeof e==`string`?1:2,Bu=(e,t)=>e===t?!0:Math.abs(e-t)>1e-13*Math.max(Math.abs(e),Math.abs(t))?!1:Number(e.toPrecision(15))===Number(t.toPrecision(15));function Vu(e,t){let n=e??(typeof t==`string`?``:typeof t!=`boolean`&&0),r=t??(typeof e==`string`?``:typeof e!=`boolean`&&0),i=zu(n),a=zu(r);if(i!==a)return i<a?-1:1;if(typeof n==`number`&&typeof r==`number`)return Bu(n,r)?0:n<r?-1:1;if(typeof n==`string`&&typeof r==`string`){let e=n.toUpperCase(),t=r.toUpperCase();return e===t?0:e<t?-1:1}return n===r?0:n===!1?-1:1}var Hu=e=>Number.isFinite(e)?e:w.NUM;function Uu(e,t,n){return Math.abs(e)<=Math.max(Math.abs(t),Math.abs(n))*89e-17?0:e}function Wu(e,t,n){let r=N(t);if(r instanceof C)return r;let i=N(n);if(i instanceof C)return i;switch(e){case`+`:return Hu(Uu(r+i,r,i));case`-`:return Hu(Uu(r-i,r,i));case`*`:return Hu(r*i);case`/`:return i===0?w.DIV0:Hu(r/i);default:return r===0&&i===0?w.NUM:r===0&&i<0?w.DIV0:Hu(r**i)}}function Gu(e,t,n){if(t instanceof C)return t;if(n instanceof C)return n;switch(e){case`&`:{let e=P(t);if(e instanceof C)return e;let r=P(n);return r instanceof C?r:`${e}${r}`}case`=`:return Vu(t,n)===0;case`<>`:return Vu(t,n)!==0;case`<`:return Vu(t,n)<0;case`<=`:return Vu(t,n)<=0;case`>`:return Vu(t,n)>0;case`>=`:return Vu(t,n)>=0;default:return Wu(e,t,n)}}function Ku(e,t,n){let r=Math.max(e.rows,t.rows),i=Math.max(e.cols,t.cols),a=Array(r*i),o=(e,t,n)=>{let r=e.rows===1?0:t,i=e.cols===1?0:n;return r<e.rows&&i<e.cols?e.at(r,i):void 0};for(let s=0;s<r;s++)for(let r=0;r<i;r++){let c=o(e,s,r),l=o(t,s,r);a[s*i+r]=c===void 0||l===void 0?w.NA:n(c,l)}return new T(r,i,a)}var qu=e=>({top:e.top,left:e.left,bottom:e.bottom,right:e.right}),Ju=class{kept=new Map;of(e,t,n){let r=this.kept.get(e);if(r)return r.value;let i=n();return this.kept.set(e,{over:t.map(e=>({sheet:e.sheet,area:qu(e)})),value:i}),i}asked=new Set;ofRepeated(e,t,n){let r=this.kept.get(e);if(r)return r.value;if(!this.asked.has(e))this.asked.add(e);else return this.asked.delete(e),this.of(e,t,n)}get(e){return this.kept.get(e)?.value}set(e,t,n){this.kept.set(e,{over:t.map(e=>({sheet:e.sheet,area:qu(e)})),value:n})}changed(e,t){if(this.kept.size!==0)for(let[n,r]of this.kept)r.over.some(n=>n.sheet===e&&S(n.area,t))&&this.kept.delete(n)}clear(){this.kept.clear(),this.asked.clear()}},Yu=(e,t)=>`${e}:${t.key}`,Xu=new Map,Zu=255;function Qu(e){let t=/^([vr?]*)(?:\(([vr]+)\))?$/u.exec(e),n=t?.[1];if(n===void 0||(n.match(/\?/gu)??[]).length>1)throw Error(`"${e}" is not a signature.`);let r=e=>Array.from({length:e.length},(t,n)=>e.charAt(n)===`v`?`value`:`whole`),i=r(n.replace(`?`,``)),a=r(t?.[2]??``),o=n.indexOf(`?`);return{fixed:i,group:a,min:o>=0?o:i.length+a.length,max:a.length>0?Zu:i.length}}function $u(e,t){return t<e.fixed.length?e.fixed[t]??`whole`:e.group.length===0?`whole`:e.group[(t-e.fixed.length)%e.group.length]??`whole`}function ed(e,t){return e.group.length===0||t<=e.fixed.length||(t-e.fixed.length)%e.group.length===0}function F(e,t,n,r,i={}){Xu.set(e,{name:e,min:t,max:n,kind:`scalar`,call:r,from:i.from??`allyhub`,...i.errors===!0?{errors:!0}:{},...i.volatile===!0?{volatile:!0}:{}})}function I(e,t,n,r={}){let{min:i,max:a,fixed:o,group:s}=Qu(t);Xu.set(e,{name:e,min:i,max:a,kind:`raw`,params:{fixed:o,group:s},call:n,from:r.from??`allyhub`,...r.volatile===!0?{volatile:!0}:{}})}function td(e,t,n,r){Xu.set(e,{name:e,min:t,max:n,kind:`lazy`,call:r,from:`allyhub`})}function nd(e,t){let n=Xu.get(t);n&&Xu.set(e,{...n,name:e})}function L(e,t){if(e instanceof C)return e;if(e instanceof it)return w.VALUE;if(e instanceof E){let n=Math.min(e.bottom,e.sheet.lastRow);return{rows:Math.max(0,n-e.top+1),cols:e.cols,at:(n,r)=>t.calc.read(e.sheet,e.top+n,e.left+r),reference:e}}if(e instanceof T)return{rows:e.rows,cols:e.cols,at:(t,n)=>e.at(t,n),array:e};if(e instanceof at)return w.VALUE;let n=e instanceof D?null:e;return{rows:1,cols:1,at:()=>n}}function rd(e,t,n){for(let r of e)if(r instanceof E)t.calc.each(r,e=>{n(e,!1)});else if(r instanceof it)for(let e of r.parts)t.calc.each(e,e=>{n(e,!1)});else if(r instanceof T)for(let e of r.data)e!==null&&n(e,!1);else r instanceof D?n(null,!0):r instanceof at?n(w.VALUE,!0):n(r,!0)}function id(e,t,n){let r=e=>{for(let r of t.calc.matrix(e).data)n(r,!1)};for(let t of e)if(t instanceof E)r(t);else if(t instanceof it)t.parts.forEach(r);else if(t instanceof T)for(let e of t.data)n(e,!1);else t instanceof D?n(null,!0):t instanceof at?n(w.VALUE,!0):n(t,!0)}function ad(e,t){let n=[],r;return rd(e,t,(e,t)=>{if(!r){if(e instanceof C)r=e;else if(typeof e==`number`)n.push(e);else if(t){let t=N(e);t instanceof C?r=t:n.push(t)}}}),r??n}function od(e,t){let n=[],r;return rd(e,t,(e,t)=>{if(!r){if(e instanceof C)r=e;else if(typeof e==`number`)n.push(e);else if(typeof e==`boolean`)n.push(+!!e);else if(t){let t=N(e);t instanceof C?r=t:n.push(t)}else typeof e==`string`&&n.push(0)}}),r??n}var sd=e=>(...t)=>{let n=[];for(let e of t){let t=N(e);if(t instanceof C)return t;n.push(t)}return e(...n)};function cd(e,t){return e===void 0?t:N(e)}function ld(e){if(typeof e==`number`)return`n${String(Number(e.toPrecision(15)))}`;if(typeof e==`string`)return`t${e.toUpperCase()}`;if(typeof e==`boolean`)return e?`bT`:`bF`}var ud=new Map,dd=1e4;function fd(e){let t=ud.get(e);if(t)return t;ud.size>=dd&&ud.clear();let n=pd(e);return ud.set(e,n),n}function pd(e){let t=``;for(let n=0;n<e.length;n++){let r=e.charAt(n);r===`~`&&/[*?~]/u.test(e.charAt(n+1))?(n+=1,t+=e.charAt(n).replace(/[*?]/u,`\\$&`)):t+=r===`*`?`[\\s\\S]*`:r===`?`?`[\\s\\S]`:r.replace(/[.*+?^${}()|[\]\\]/gu,`\\$&`)}let n=RegExp(`^${t}$`,`iu`);return e=>n.test(e)}var md=e=>/[*?~]/u.test(e);function hd(e){let t=``;for(let n=0;n<e.length;n++){let r=e.charAt(n);if(r===`~`&&/[*?~]/u.test(e.charAt(n+1)))n+=1,t+=e.charAt(n);else if(r===`*`||r===`?`)return;else t+=r}return t}function gd(e){return t=>{if(typeof t==`number`)return Bu(t,e);if(typeof t!=`string`)return!1;let n=Iu(t);return n!==void 0&&Bu(n,e)}}function _d(e,t){let n=t=>e===`>`?t>0:e===`>=`?t>=0:e===`<`?t<0:t<=0;return e=>typeof e==typeof t&&n(Vu(e,t))}function vd(e){if(e===null)return{test:gd(0),key:`n0`};if(typeof e==`number`)return{test:gd(e),key:`n${String(Number(e.toPrecision(15)))}`};if(typeof e==`boolean`)return{test:t=>t===e,key:e?`bT`:`bF`};if(e instanceof C)return{test:t=>t===e};let t=/^(<>|>=|<=|=|>|<)/u.exec(e),n=t?.[1]??`=`,r=t?e.slice(n.length):e,i=e=>e===null;if(r===``)return n===`=`?{test:t?i:e=>e===null||e===``}:n===`<>`?{test:e=>e!==null}:{test:()=>!1};let a=Iu(r),o=/^(?:TRUE|FALSE)$/iu.test(r)?r.toUpperCase()===`TRUE`:void 0,s=a??o;if(n===`=`||n===`<>`){let e,t;if(a!==void 0)e=gd(a),t=ld(a);else if(o!==void 0)e=e=>e===o,t=ld(o);else if(je(r)!==void 0)e=e=>e instanceof C&&e.code===r.toUpperCase();else if(md(r)){let t=fd(r);e=e=>typeof e==`string`&&t(e)}else{let n=r.toUpperCase();e=e=>typeof e==`string`&&e.toUpperCase()===n,t=ld(r)}return n===`=`?t===void 0?{test:e}:{test:e,key:t}:{test:t=>!e(t)}}return{test:_d(n,s??r)}}function yd(e,t){let n=e.reference;if(!(n?.cols!==1||e.rows<64))return t.calc.indexes.ofRepeated(Yu(`crit`,n),[n],()=>{let t=new Map,n=(e,n)=>{if(e===void 0)return;let r=t.get(e);r?r.push(n):t.set(e,[n])};for(let t=0;t<e.rows;t++){let r=e.at(t,0);if(n(ld(r),t),typeof r==`string`){let e=Iu(r);e!==void 0&&n(ld(e),t)}}return t})}function bd(e,t){return vd(t.calc.scalar(e,t.frame))}function xd(e,t){let n=[];for(let r=0;r+1<e.length;r+=2){let i=L(e[r],t);if(i instanceof C)return i;let a=bd(e[r+1],t);if(a instanceof C)return a;n.push({cells:i,crit:a})}let r=n[0]?.cells;return r&&n.some(e=>!Sd(e.cells,r))?w.VALUE:n}var Sd=(e,t)=>e.cols===t.cols&&(e.reference?.rows??e.rows)===(t.reference?.rows??t.rows);function Cd(e,t,n){let r=e[0];if(!r)return;let i,a;for(let n of e){if(n.crit.key===void 0)continue;let e=yd(n.cells,t);if(!e)continue;let r=e.get(n.crit.key)??[];(i===void 0||r.length<i.length)&&(i=r,a=n)}if(i!==void 0){let t=e.filter(e=>e!==a);for(let e of i)t.every(t=>t.crit.test(t.cells.at(e,0)))&&n(e,0);return}let o=Math.max(...e.map(e=>e.cells.rows));for(let t=0;t<o;t++)for(let i=0;i<r.cells.cols;i++)e.every(e=>e.crit.test(e.cells.at(t,i)))&&n(t,i)}function wd(e,t){return e instanceof E?(e.rows-t.rows)*e.cols:0}function Td(e,t,n,r){let i;return Cd(t,n,(t,n)=>{if(i)return;let a=e.at(t,n);a instanceof C?i=a:typeof a==`number`&&r(a)}),i}function Ed(e,t){let n=L(e[0],t);if(n instanceof C)return n;let r=e[2];return r===void 0?n:L(r,t)}var Dd=e=>(t,n)=>{let r=L(t[0],n);if(r instanceof C)return r;let i=bd(t[1],n);if(i instanceof C)return i;let a=Ed(t,n);if(a instanceof C)return a;let o=[];return Td(a,[{cells:r,crit:i}],n,e=>{o.push(e)})??e(o)},Od=e=>(t,n)=>{let r=L(t[0],n);if(r instanceof C)return r;let i=xd(t.slice(1),n);if(i instanceof C)return i;let a=i[0]?.cells;if(a&&!Sd(r,a))return w.VALUE;let o=[];return Td(r,i,n,e=>{o.push(e)})??e(o)},kd=(e,t)=>(n,r)=>{let i=[],a=[e];for(let e of n)if(e instanceof E)i.push(e),a.push(`r${e.key}`);else if(e instanceof D)a.push(`-`);else if(e instanceof C)a.push(`e${e.code}`);else if(typeof e!=`object`||!e)a.push(`${typeof e}:${String(e)}`);else return t(n,r);if(i.length===0)return t(n,r);let o=a.join(`\0`),s=r.calc.results.get(o);if(s!==void 0)return s;let c=t(n,r);return(typeof c!=`object`||!c||c instanceof C)&&r.calc.results.set(o,i,c),c},Ad=e=>e.reduce((e,t)=>e+t,0),jd=e=>e.length===0?w.DIV0:Ad(e)/e.length;I(`SUMIF`,`rv?r`,kd(`SUMIF`,Dd(Ad))),I(`AVERAGEIF`,`rv?r`,kd(`AVERAGEIF`,Dd(jd))),I(`SUMIFS`,`r(rv)`,kd(`SUMIFS`,Od(Ad))),I(`AVERAGEIFS`,`r(rv)`,kd(`AVERAGEIFS`,Od(jd))),I(`MINIFS`,`r(rv)`,kd(`MINIFS`,Od(e=>e.length===0?0:e.reduce((e,t)=>t<e?t:e)))),I(`MAXIFS`,`r(rv)`,kd(`MAXIFS`,Od(e=>e.length===0?0:e.reduce((e,t)=>t>e?t:e)))),I(`COUNTIF`,`rv`,kd(`COUNTIF`,(e,t)=>{let n=L(e[0],t);if(n instanceof C)return n;let r=bd(e[1],t);if(r instanceof C)return r;let i=0;return Cd([{cells:n,crit:r}],t,()=>{i+=1}),i+(r.test(null)?wd(e[0],n):0)})),I(`COUNTIFS`,`(rv)`,kd(`COUNTIFS`,(e,t)=>{let n=xd(e,t);if(n instanceof C)return n;let r=0;return Cd(n,t,()=>{r+=1}),r}));var Md=(e,t)=>e?.toLowerCase()===t?.toLowerCase(),Nd=(e,t,n)=>e.index>=t?{...e,index:e.index+n}:e;function Pd(e,t,n){if(e.index<t)return e;if(e.index>=t+n)return{...e,index:e.index-n}}function Fd(e,t,n,r){let i=e.index<=t.index?e:t,a=i===e?t:e,o=Nd(i,n,r),s=a.index>=n?{...a,index:a.index+r}:a;return i===e?[o,s]:[s,o]}function Id(e,t,n,r){let i=e.index<=t.index?e:t,a=i===e?t:e,o=n+r-1;if(i.index>=n&&a.index<=o)return;let s=i.index<n?i:i.index>o?{...i,index:i.index-r}:{...i,index:n},c=a.index<n?a:a.index>o?{...a,index:a.index-r}:{...a,index:n-1};return i===e?[s,c]:[c,s]}function Ld(e){return{kind:`error`,code:`#REF!`,...e.sheet===void 0?{}:{sheet:e.sheet}}}var Rd={kind:`error`,code:`#REF!`};function zd(e,t,n){if(!Md(e.sheet??n,t.sheet)||e.lastSheet!==void 0)return e;let{col:r,row:i}=e;if(r===void 0||i===void 0)return e;let a=e.col2??r,o=e.row2??i,{area:s,rows:c,columns:l,to:u}=t;if(!(Math.min(r.index,a.index)>=s.left&&Math.max(r.index,a.index)<=s.right&&Math.min(i.index,o.index)>=s.top&&Math.max(i.index,o.index)<=s.bottom))return e;let d=(e,t)=>({...e,index:e.index+t}),f={...e,col:d(r,l),row:d(i,c),...e.col2?{col2:d(e.col2,l)}:{},...e.row2?{row2:d(e.row2,c)}:{}};return u===void 0?f:Md(u,n)?Object.fromEntries(Object.entries(f).filter(([e])=>e!==`sheet`)):{...f,sheet:u}}function Bd(e,t,n){if(!Md(e.sheet??n,t.sheet)||e.lastSheet!==void 0)return e;let r=t.op===`insert-rows`||t.op===`delete-rows`,i=r?e.row:e.col,a=r?e.row2:e.col2;if(i===void 0)return e;let o=r?[`row`,`row2`]:[`col`,`col2`],s=t.op===`insert-rows`||t.op===`insert-columns`,c=r?xe:Se;if(a===void 0){let n=s?Nd(i,t.at,t.count):Pd(i,t.at,t.count);return!n||n.index>=c?Ld(e):n===i?e:{...e,[o[0]]:n}}let l=s?Fd(i,a,t.at,t.count):Id(i,a,t.at,t.count);return!l||l[0].index>=c||l[1].index>=c?Ld(e):l[0]===i&&l[1]===a?e:{...e,[o[0]]:l[0],[o[1]]:l[1]}}function Vd(e,t,n){let r=t.rows?e.col:e.row,i=(t.rows?e.col2:e.row2)??r;return r===void 0||i===void 0||Math.min(r.index,i.index)<t.first||Math.max(r.index,i.index)>t.last?e:Bd(e,{op:t.rows?t.insert?`insert-rows`:`delete-rows`:t.insert?`insert-columns`:`delete-columns`,sheet:t.sheet,at:t.at,count:t.count},n)}function Hd(e,t,n,r){let i=(e,t)=>e===void 0?r===void 0||Md(r,t):Md(e,t);return vl(e,e=>{switch(t.op){case`rename-sheet`:return(e.kind===`ref`||e.kind===`name`||e.kind===`error`)&&Md(e.sheet,t.from)?{...e,sheet:t.to}:e.kind===`ref`&&Md(e.lastSheet,t.from)?{...e,lastSheet:t.to}:e;case`rename-table`:return e.kind===`structured`&&Md(e.table,t.from)?{...e,table:t.to}:e;case`delete-sheet`:return e.kind===`ref`&&Md(e.sheet,t.name)||e.kind===`ref`&&Md(e.lastSheet,t.name)?Ld(e):e.kind===`name`&&Md(e.sheet,t.name)?Rd:e;case`delete-table`:return e.kind===`structured`&&Md(e.table,t.name)||e.kind===`name`&&Md(e.name,t.name)?Rd:e;case`delete-column`:return e.kind===`structured`&&i(e.table,t.table)&&e.columns.some(e=>Md(e,t.name))?Rd:e;case`rename-column`:return e.kind===`structured`&&i(e.table,t.table)&&e.columns.some(e=>Md(e,t.from))?{...e,columns:e.columns.map(e=>Md(e,t.from)?t.to:e)}:e;case`rename-name`:return e.kind===`name`&&Md(e.name,t.from)?{...e,name:t.to}:e.kind===`call`&&Md(e.name,t.from)?{...e,name:t.to.toUpperCase(),written:t.to}:e;case`move-cells`:return e.kind===`ref`?zd(e,t,n):e;case`shift-cells`:return e.kind===`ref`?Vd(e,t,n):e;default:return e.kind===`ref`?Bd(e,t,n):e}})}var Ud=e=>e.op===`insert-rows`||e.op===`delete-rows`||e.op===`insert-columns`||e.op===`delete-columns`,Wd=e=>e.op===`insert-rows`||e.op===`insert-columns`,Gd=e=>e.op===`insert-rows`||e.op===`delete-rows`;function Kd(e,t){return Wd(t)?e>=t.at?e+t.count:e:e<t.at?e:e>=t.at+t.count?e-t.count:void 0}function qd(e,t){let n=De(e);if(!n)return e;let r=Kd(Gd(t)?n.row:n.col,t);if(r!==void 0)return Te(Gd(t)?{...n,row:r}:{...n,col:r})}function Jd(e,t){return Object.fromEntries(Object.entries(e).flatMap(([e,n])=>{let r=qd(e,t);return r===void 0?[]:[[r,n]]}))}var Yd=e=>Gd(e)?xe:Se;function Xd(e,t,n){let r=Yd(n);if(Wd(n)){let i=e>=n.at?e+n.count:e,a=t>=n.at?t+n.count:t;return i>=r?void 0:[i,Math.min(a,r-1)]}let i=n.at+n.count-1;if(!(e>=n.at&&t<=i))return[e<n.at?e:e>i?e-n.count:n.at,t<n.at?t:t>i?t-n.count:n.at-1]}function Zd(e,t){let n=Gd(t)?Xd(e.top,e.bottom,t):Xd(e.left,e.right,t);if(n)return Gd(t)?{...e,top:n[0],bottom:n[1]}:{...e,left:n[0],right:n[1]}}function Qd(e,t,n,r){let i=0,a=(e,t)=>{e&&!e.abs&&(i=Math.max(i,Math.abs(e.index-t)))};return bl(e,e=>{e.kind===`ref`&&(t?(a(e.row,n),a(e.row2,n)):(a(e.col,r),a(e.col2,r)))}),i}function $d(e,t,n,r){let i=new Set,a=n=>{for(let a=n-r-1;a<=n+r+1;a++)a>=e&&a<=t&&i.add(a)};a(n.at),a(n.at+n.count);let o=[...i].sort((e,t)=>e-t),s=[],c=e;for(let e of o)e>c&&s.push([c,e-1]),s.push([e,e]),c=e+1;return c<=t&&s.push([c,t]),s}function ef(e,t,n,r,i){let a=Hl(t);if(!a.ok){let n=i?Zd(e,r):e;return n?[{area:n,text:t}]:[]}let o=Gd(r),[s,c]=o?[e.top,e.bottom]:[e.left,e.right],l=Qd(a.node,o,e.top,e.left),u=[],d=!0;for(let[t,f]of $d(s,c,r,l)){let s=o?t:e.top,c=o?e.left:t,l=i?Kd(t,r):t;if(l===void 0)continue;let p=i?Kd(f,r):f;if(p===void 0)continue;let m=Cl(a.node,s-e.top,c-e.left),h=Hd(m,r,n);h!==m&&(d=!1);let g=wl(h,o?l:e.top,o?e.left:l),_=u[u.length-1];_?.key===g&&_.to+1===l?_.to=p:u.push({from:l,to:p,key:g,text:_t(h)})}return u.map(n=>({area:o?{...e,top:n.from,bottom:n.to}:{...e,left:n.from,right:n.to},text:d&&u.length===1?t:n.text}))}function tf(e,t){return typeof e==`object`&&e?{...e,formula:t}:t}var nf=e=>{if(typeof e==`string`)return e.startsWith(`=`)?e:void 0;if(typeof e==`object`&&e)return e.formula===void 0?typeof e.value==`string`&&e.value.startsWith(`=`)?e.value:void 0:e.formula.startsWith(`=`)?e.formula:`=${e.formula}`};function rf(e,t,n,r){let i=Hl(e);if(!i.ok)return e;let a=Hd(i.node,t,n,r);return a===i.node?e:_t(a)}function af(e,t,n,r){let i={},a=Ud(n)?n:void 0;for(let[o,s]of Object.entries(e)){let e=nf(s),c=x(o);if(!c){i[o]=s;continue}let l=r&&a!==void 0;if(o.includes(`:`)){if(!a){i[o]=e===void 0?s:tf(s,rf(e,n,t));continue}if(e!==void 0){for(let n of ef(c,e,t,a,l))i[Ee(n.area)]=tf(s,n.text);continue}if(!l){i[o]=s;continue}if(!Wd(a)){let e=Zd(c,a);e&&(i[Ee(e)]=s);continue}let r=Gd(a),[u,d]=r?[c.top,c.bottom]:[c.left,c.right];for(let[e,t]of[[u,Math.min(d,a.at-1)],[Math.max(u,a.at),d]]){if(e>t)continue;let n=e>=a.at?a.count:0,o=r?{...c,top:e+n,bottom:t+n}:{...c,left:e+n,right:t+n};i[Ee(o)]=s}continue}let u={row:c.top,col:c.left},d=u;if(l){let e=Kd(Gd(a)?u.row:u.col,a);d=e===void 0?void 0:Gd(a)?{...u,row:e}:{...u,col:e}}d&&(i[Te(d)]=e===void 0?s:tf(s,rf(e,n,t)))}return i}function of(e,t){let n=De(e.at);if(!n)return;let r=t[0]??[],i=r.map(e=>e.trim()),a=new Set(i.map(e=>e.toLowerCase()));for(let t of Object.keys(e.columns??{}))a.has(t.toLowerCase())||i.push(t);let o=[];return t.forEach((e,t)=>{t>0&&e.length>0&&o.push(t)}),{at:n,header:r,names:i,places:o}}var sf=e=>e.reduce((e,t)=>Math.max(e,t.length),0);function cf(e,t,n){let r=Math.max(sf(e),1),i=Array.from({length:n},()=>Array(r).fill(``));return[...e.slice(0,t),...i,...e.slice(t)]}function lf(e,t=`Column`){let n=new Set(e.map(e=>e.toLowerCase()));for(let e=1;;e++){let r=`${t}${String(e)}`;if(!n.has(r.toLowerCase()))return r}}function uf(e,t){let n=new Set(e.map(e=>e.toLowerCase()));if(!n.has(t.toLowerCase()))return t;for(let e=2;;e++){let r=`${t}${String(e)}`;if(!n.has(r.toLowerCase()))return r}}function df(e,t,n){let r=e.map(e=>[...e]),i=r[0]??[];for(r.length===0&&r.push(i);i.length<=n;)i.push(t[i.length]??``);let a=i.length;for(let e=1;e<r.length;e++){let t=r[e];if(t&&t.length>0)for(;t.length<a;)t.push(``)}return r}var ff=class{file;rows;edit;after=[];refused;constructor(e,t){this.file=structuredClone(e.file),this.rows=new Map(e.rows),this.edit=t}sheets(){return this.file.sheets}rewrite(e){let t=this.file.sheets[0]?.name??``;if(this.file.names)for(let[n,r]of Object.entries(this.file.names))typeof r==`string`&&r.startsWith(`=`)&&(this.file.names[n]=rf(r,e,t));for(let n of this.file.checks??[])n.formula=rf(n.formula,e,t);for(let t of this.sheets())this.rewriteSheet(t,e)}rewriteSheet(e,t){let n=Ud(t)&&pf(e.name,t.sheet);if(e.names)for(let[n,r]of Object.entries(e.names))typeof r==`string`&&r.startsWith(`=`)&&(e.names[n]=rf(r,t,e.name));e.cells&&=af(e.cells,e.name,t,n);for(let n of e.tables??[]){for(let r of Object.values(n.columns??{}))r.formula!==void 0&&(r.formula=rf(r.formula,t,e.name,n.name));this.rewriteCsv(n.rows,t,e.name,n.name)}for(let n of e.blocks??[])this.rewriteCsv(n.rows,t,e.name);this.rewriteRules(e,t)}freePath(e,t){let n=e.slice(0,e.lastIndexOf(`/`)+1),r=e=>[...this.rows.keys()].some(t=>pf(t,e)),i=`${n}${t}.csv`;for(let e=2;r(i);e++)i=`${n}${t}-${String(e)}.csv`;return i}duplicate(e,t){let n=this.sheets(),r=n.findIndex(t=>pf(t.name,e)),i=n[r];if(!i){this.refused=`no-sheet`;return}let a=structuredClone(i);a.name=t,delete a.hidden;for(let e of Object.values(a.cells??{}))typeof e==`object`&&e&&delete e.name;let o=new Set(n.flatMap(e=>e.tables??[]).map(e=>e.name.toLowerCase())),s=new Set(Object.keys(this.file.names??{}).map(e=>e.toLowerCase())),c=[];for(let e of a.tables??[]){let t=e.name;for(let n=2;;n++){t=`${e.name}${String(n)}`;let r=t.toLowerCase();if(!o.has(r)&&!s.has(r))break}o.add(t.toLowerCase());let n=this.freePath(e.rows,t);this.rows.set(n,this.rows.get(e.rows)??[]),c.push({op:`rename-table`,from:e.name,to:t}),e.rows=n,e.name=t}for(let e of a.blocks??[]){let t=e.rows.slice(e.rows.lastIndexOf(`/`)+1,-4),n=this.freePath(e.rows,t);this.rows.set(n,this.rows.get(e.rows)??[]),e.rows=n}this.file.sheets=[...n.slice(0,r+1),a,...n.slice(r+1)],this.rewriteSheet(a,{op:`rename-sheet`,from:e,to:t});for(let e of c)this.rewriteSheet(a,e)}rewriteRules(e,t){let n=n=>typeof n==`string`&&n.startsWith(`=`)?rf(n,t,e.name):n,r=e=>e.value===void 0?e:{...e,value:n(e.value)},i=e.conditional?.map(i=>{switch(i.type){case`cellIs`:return{...i,formula:i.formula.map(n)};case`expression`:return{...i,formula:rf(i.formula.startsWith(`=`)?i.formula:`=${i.formula}`,t,e.name)};case`dataBar`:return{...i,...i.min?{min:r(i.min)}:{},...i.max?{max:r(i.max)}:{}};case`colorScale`:return{...i,stops:i.stops.map(r)};case`iconSet`:return i.stops?{...i,stops:i.stops.map(r)}:i;default:return i}});i&&(e.conditional=i);let a=e.validations?.map(e=>e.formula?{...e,formula:e.formula.map(n)}:e);a&&(e.validations=a),Ud(t)&&t.sheet===e.name&&(e.links&&=Jd(e.links,t),e.notes&&=Jd(e.notes,t),e.pictures&&=e.pictures.flatMap(e=>{let n=qd(e.at,t);return n===void 0?[]:[{...e,at:n}]})),e.charts&&=e.charts.map(n=>Mt(n,n=>{let r=n.startsWith(`=`),i=rf(uu(n),t,e.name);return r?i:i.slice(1)}))}rewriteCsv(e,t,n,r){let i=this.rows.get(e);if(!i)return;let a;i.forEach((e,o)=>{if(!e.some(e=>e.charCodeAt(0)===61))return;let s=e.map(e=>Xe(e).formula===void 0?e:rf(e,t,n,r));s.every((t,n)=>t===e[n])||(a??=[...i],a[o]=s)}),a&&this.rows.set(e,a)}tableOn(e,t){let n=Gd(t),r=[];for(let i of e.tables??[]){let e=this.rows.get(i.rows),a=e&&of(i,e);if(!e||!a){r.push(i);continue}let o=a.at.row,s=a.at.col,c=o+a.places.length,l=s+Math.max(a.names.length,1)-1,[u,d]=n?[o,c]:[s,l];if(!Wd(t)&&t.at<=u&&t.at+t.count-1>=d){this.after.push({op:`delete-table`,name:i.name});continue}let f={...a.at};if(n){if(Wd(t)){if(t.at<=o)f.row+=t.count;else if(t.at<=c){let n=a.places[t.at-o-1]??e.length;this.rows.set(i.rows,cf(e,n,t.count))}}else{let n=t.at+t.count-1;if(n<o)f.row-=t.count;else if(t.at<=o){this.refused=`table-header`;return}else if(t.at<=c){let r=new Set(a.places.slice(t.at-o-1,n-o));this.rows.set(i.rows,e.filter((e,t)=>!r.has(t)))}}}else if(Wd(t))t.at<=s?f.col+=t.count:t.at<=l&&this.columnsIn(i,a,t.at-s,t.count);else{let e=t.at+t.count-1;if(e<s)f.col-=t.count;else if(t.at<=l){f.col=Math.min(s,t.at);let n=Math.max(0,t.at-s),r=Math.min(a.names.length-1,e-s);this.columnsOut(i,a,n,r)}}i.at=Te(f),r.push(i)}e.tables=r,r.length===0&&delete e.tables}columnsIn(e,t,n,r){let i=this.rows.get(e.rows)??[],a=n>0?df(i,t.names,n-1):i.map(e=>[...e]),o=[...t.names];a.forEach((e,t)=>{if(t>0&&e.length===0)return;let i=[];for(let e=0;e<r;e++)if(t===0){let e=lf(o);o.push(e),i.push(e)}else i.push(``);for(;e.length<n;)e.push(``);e.splice(n,0,...i)}),this.rows.set(e.rows,a)}columnsOut(e,t,n,r){let i=t.names.slice(n,r+1),a=this.rows.get(e.rows)??[],o=t.header.length,s=new Set;for(let e=n;e<=r&&e<o;e++)s.add(e);if(s.size>0&&this.rows.set(e.rows,a.map(e=>e.length===0?e:e.filter((e,t)=>!s.has(t)))),e.columns){let t=new Set(i.map(e=>e.toLowerCase()));e.columns=Object.fromEntries(Object.entries(e.columns).filter(([e])=>!t.has(e.toLowerCase()))),Object.keys(e.columns).length===0&&delete e.columns}if(e.key!==void 0&&i.some(t=>t.toLowerCase()===e.key?.toLowerCase())&&delete e.key,e.filter){let t=new Set(i.map(e=>e.toLowerCase())),n=Object.fromEntries(Object.entries(e.filter.columns).filter(([e])=>!t.has(e.toLowerCase())));Object.keys(n).length>0?e.filter={columns:n}:delete e.filter}for(let t of i)this.after.push({op:`delete-column`,table:e.name,name:t})}blocksOn(e,t){let n=Gd(t),r=(e.blocks??[]).flatMap(e=>{let r=De(e.at),i=this.rows.get(e.rows);if(!r||!i)return[e];let a=n?r.row:r.col,o=a+(n?i.length:Math.max(sf(i),1))-1,s=Xd(a,o,t);if(!s)return[];let c=n?{...r,row:s[0]}:{...r,col:s[0]};if(Wd(t)&&t.at>a&&t.at<=o){let r=t.at-a;this.rows.set(e.rows,n?cf(i,r,t.count):i.map(e=>{if(e.length===0)return e;let n=[...e];for(;n.length<r;)n.push(``);return n.splice(r,0,...Array(t.count).fill(``)),n}))}else if(!Wd(t)&&t.at<=o){let r=Math.max(t.at,a)-a,s=Math.min(t.at+t.count-1,o)-a;this.rows.set(e.rows,n?i.filter((e,t)=>t<r||t>s):i.map(e=>e.filter((e,t)=>t<r||t>s)))}return[{...e,at:Te(c)}]});e.blocks=r,r.length===0&&delete e.blocks}looksOn(e,t){let n=Gd(t);e.format&&=e.format.flatMap(e=>{let n=x(e.range);if(!n)return[e];let r=Zd(n,t);return r?[{...e,range:Ee(r)}]:[]}),e.format?.length===0&&delete e.format,e.merges&&=e.merges.flatMap(e=>{let n=x(e);if(!n)return[e];let r=Zd(n,t);return r?[Ee(r)]:[]}),e.merges?.length===0&&delete e.merges;let r=e=>{let n=Oe(e);if(!n)return e;let r=n.flatMap(e=>{let n=Zd(e,t);return n?[Ee(n)]:[]});return r.length===0?void 0:r.join(` `)};if(e.conditional&&=e.conditional.flatMap(e=>{let t=r(e.range);return t===void 0?[]:[{...e,range:t}]}),e.conditional?.length===0&&delete e.conditional,e.validations&&=e.validations.flatMap(e=>{let t=r(e.range);return t===void 0?[]:[{...e,range:t}]}),e.validations?.length===0&&delete e.validations,e.charts&&=e.charts.map(e=>{let r=De(e.at);if(!r)return e;let i=Kd(n?r.row:r.col,t)??t.at;return{...e,at:Te(n?{...r,row:i}:{...r,col:i})}}),e.filter){let r=x(e.filter.range),i=r&&Zd(r,t);if(r&&!i)delete e.filter;else if(i){let r=n?e.filter.columns:Object.fromEntries(Object.entries(e.filter.columns??{}).flatMap(([e,n])=>{let r=we(e),i=r===void 0?void 0:Kd(r,t);return i===void 0?[]:[[Ce(i),n]]}));e.filter={range:Ee(i),...r&&Object.keys(r).length>0?{columns:r}:{}}}}if(e.freeze!==void 0){let r=De(e.freeze);if(r){let i=n?r.row:r.col,a=Xd(0,i-1,t),o=i===0?0:a?a[1]+1:0;e.freeze=Te(n?{...r,row:o}:{...r,col:o})}}let i=(e,n,r)=>{if(!e)return;let i={};for(let[a,o]of Object.entries(e)){let e=n(a),s=e===void 0?void 0:Kd(e,t);e===void 0?i[a]=o:s!==void 0&&(i[r(s)]=o)}return i};if(n){let t=i(e.rows,e=>/^[1-9]\d*$/u.test(e)?Number(e)-1:void 0,e=>String(e+1));t&&(e.rows=t)}else{let t=i(e.columns,we,Ce);t&&(e.columns=t)}}run(){let e=this.edit;if(Ud(e)){let t=this.sheets().find(t=>pf(t.name,e.sheet));if(!t){this.refused=`no-sheet`;return}if(this.rewrite(e),this.tableOn(t,e),this.refused)return;this.blocksOn(t,e),this.looksOn(t,e);for(let e of this.after)this.rewrite(e)}else switch(e.op){case`rename-sheet`:{this.rewrite(e);let t=this.sheets().find(t=>pf(t.name,e.from));t&&(t.name=e.to);return}case`rename-column`:this.renameColumn(e.table,e.from,e.to),this.rewrite(e);return;case`delete-sheet`:{let t=this.sheets(),n=t.find(t=>pf(t.name,e.name));if(!n){this.refused=`no-sheet`;return}if(t.filter(e=>e.hidden!==!0).length<=1){this.refused=`last-sheet`;return}this.rewrite(e);for(let e of n.tables??[])this.rewrite({op:`delete-table`,name:e.name});this.file.sheets=t.filter(e=>e!==n);return}default:this.rewrite(e)}}renameColumn(e,t,n){let r=this.sheets().flatMap(e=>e.tables??[]).find(t=>pf(t.name,e));if(!r)return;let i=t.toLowerCase(),a=this.rows.get(r.rows),o=a?.[0]?.findIndex(e=>e.trim().toLowerCase()===i)??-1;if(a&&o>=0){let e=[...a[0]??[]];e[o]=n,this.rows.set(r.rows,[e,...a.slice(1)])}if(r.columns){let e=Object.keys(r.columns).find(e=>e.toLowerCase()===i);e!==void 0&&(r.columns=Object.fromEntries(Object.entries(r.columns).map(([t,r])=>[t===e?n:t,r])))}r.key?.toLowerCase()===i&&(r.key=n),r.filter&&={columns:Object.fromEntries(Object.entries(r.filter.columns).map(([e,t])=>[e.toLowerCase()===i?n:e,t]))}}},pf=(e,t)=>e.toLowerCase()===t.toLowerCase();function mf(e,t){let n=new ff(e,t);return n.run(),n.refused?{file:e.file,rows:new Map(e.rows),refused:n.refused}:{file:n.file,rows:n.rows}}function hf(e,t,n){let r=new ff(e,{op:`rename-sheet`,from:t,to:n});return r.duplicate(t,n),r.refused?{file:e.file,rows:new Map(e.rows),refused:r.refused}:{file:r.file,rows:r.rows}}var gf=[`bold`,`italic`,`underline`,`strike`,`font`,`size`,`color`,`script`];function _f(e){return Object.fromEntries(Object.entries(e).filter(([e])=>e!==`text`))}var vf=(e,t)=>gf.every(n=>e[n]===t[n]);function yf(e){let t={text:e.text};for(let n of gf)e[n]!==void 0&&(t[n]=e[n]);return t}function bf(e){let t=[];for(let n of e){if(n.text===``)continue;let e=t[t.length-1];e&&vf(_f(e),_f(n))?t[t.length-1]={...e,text:e.text+n.text}:t.push(yf(n))}return t}var xf=e=>e.every(e=>gf.every(t=>e[t]===void 0));function Sf(e,t){let n=[],r=0;for(let i of e){let e=r+i.text.length;t>r&&t<e?(n.push({...i,text:i.text.slice(0,t-r)}),n.push({...i,text:i.text.slice(t-r)})):n.push(i),r=e}return n}function Cf(e,t,n,r){let i=Sf(Sf(e,t),n),a=0;return bf(i.map(e=>{let i=a+e.text.length,o=a>=t&&i<=n;if(a=i,!o)return e;let s=Object.entries(r).filter(([,e])=>e!==void 0);return Object.fromEntries([...Object.entries(e).filter(([e])=>!(e in r)),...s])}))}function wf(e,t){let n=new Set(t);return bf(e.map(e=>Object.fromEntries(Object.entries(e).filter(([e])=>!n.has(e)))))}function Tf(e,t){let n=0;for(let r of e){let e=n+r.text.length;if(t>n&&t<=e||t===0&&n===0&&r.text!==``)return r;n=e}return e[e.length-1]}function Ef(e,t,n){let r=[],i=0;for(let a of e){let e=i+a.text.length,o=Math.max(t,i),s=Math.min(n,e);o<s&&r.push({...a,text:a.text.slice(o-i,s-i)}),i=e}return r}function Df(e,t){let n=e.map(e=>e.text).join(``);if(n===t)return[...e];let r=Math.min(n.length,t.length),i=0;for(;i<r&&n[i]===t[i];)i+=1;let a=0;for(;a<r-i&&n[n.length-1-a]===t[t.length-1-a];)a+=1;let o=Tf(e,n.length-a>i?i+1:i);return bf([...Ef(e,0,i),{...o?_f(o):{},text:t.slice(i,t.length-a)},...Ef(e,n.length-a,n.length)])}var Of=(e,t)=>e.top<=t.top&&e.left<=t.left&&e.bottom>=t.bottom&&e.right>=t.right,kf=(e,t)=>Object.fromEntries(Object.entries(e).filter(([e])=>e!==t)),Af=e=>kf(e,`formula`),jf=(e,t)=>Object.fromEntries(Object.entries(e).filter(([e])=>e!==t)),Mf=()=>({rows:new Map,cells:[],whole:!1}),R=e=>({...Mf(),refused:e}),Nf=e=>Xe(e).formula!==void 0;function Pf(e){let t=Xe(e);return t.formula===void 0?t.value===null?null:t.format===void 0&&(typeof t.value==`number`||typeof t.value==`boolean`)?t.value:e:e}var Ff=e=>typeof e==`object`&&e?Object.fromEntries(Object.entries(e).filter(([e])=>e!==`value`&&e!==`formula`&&e!==`runs`)):{},z=class{book;specs=new Map;file;fileChanged=!1;grown=new Map;added=new Map;edit=Mf();constructor(e){this.book=e,this.file=e.file}spec(e){let t=this.specs.get(e.index);if(!t){let n=this.file.sheets.findIndex(t=>t.name===e.name);t={...this.file.sheets[n]??{name:e.name}},this.specs.set(e.index,t),this.fileChanged||=(this.file={...this.file,sheets:[...this.file.sheets]},!0),this.file.sheets[n]=t}return t}table(e,t){let n=this.spec(e),r=[...n.tables??[]],i=r.findIndex(e=>e.name===t.name),a={...r[i]??t.spec};return r[i]=a,n.tables=r,a}rows(e){let t=this.edit.rows.get(e);if(t)return t;let n=[...this.book.rows.get(e)??[]];return this.edit.rows.set(e,n),n}setField(e,t,n,r){let i=this.rows(e),a=[...i[t]??[]];for(;a.length<=n;)a.push(``);return a[n]=r,i[t]=a,a}rowsOf(e){return this.grown.get(e)??e.rows}grow(e,t,n){this.grown.set(e,this.rowsOf(e)+1);let r=this.added.get(e)??new Map;r.set(t,n),this.added.set(e,r)}addedAt(e,t,n){for(let[r,i]of this.added){let a=i.get(t);if(a!==void 0&&r.sheet===e&&n>=r.at.col&&n<r.at.col+r.columns.length)return{table:r,record:a}}}finish(){return this.fileChanged&&(this.edit.file=this.file),this.edit}};function If(e,t,n,r){return t.tables.find(i=>{if(n!==i.at.row+e.rowsOf(i)+1)return!1;let a=i.at.col+i.columns.length-1;if(r<i.at.col||r>a)return!1;for(let e=i.at.col;e<=a;e++)if(t.at(n,e)!==void 0)return!1;return!0})}function Lf(e,t,n){return e.tables.find(r=>{let{top:i,bottom:a,right:o}=r.area;if(n!==o+1||t<i||t>a)return!1;for(let t=i;t<=a;t++)if(e.at(t,n)!==void 0)return!1;return!0})}var Rf=(e,t,n)=>{let r=Hl(e);return r.ok?_t(Cl(r.node,t,n)):e};function zf(e,t,n,r,i,a){let o=n.at.row+1,s=e.table(t,n),c=Rf(a,o-i,0);if(s.columns={...s.columns,[r.name]:{...s.columns?.[r.name],formula:c}},r.csv!==void 0){let t=n.places[i-o];t!==void 0&&e.setField(n.file,t,r.csv,``)}e.edit.whole=!0}function Bf(e,t,n,r){let{csv:i}=n;if(i===void 0)return!1;let a=e.rows(t.file);return t.places.some((e,t)=>t!==r&&(a[e]?.[i]??``)!==``)}function Vf(e,t,n,r,i){let a=i.trim();if(a===``)return R(`column-name`);if(a===r.name)return e.finish();let o=uf(n.columns.filter(e=>e!==r).map(e=>e.name),a),s=mf(t,{op:`rename-column`,table:n.name,from:r.name,to:o});return{...Mf(),file:s.file,rows:new Map(s.rows),whole:!0}}function Hf(e,t,n,r,i,a){let o=n.columns[i-n.at.col];if(!o)return;let s=r-n.at.row-1;if(Nf(a)){if(o.formula||!Bf(e,n,o,s)){zf(e,t,n,o,r,a);return}e.edit.offer={sheet:t.name,row:r,col:i,text:a}}let c=n.places[s];if(c===void 0)return;let l=o.csv;if(l===void 0){if(a===``)return;let t=n.columns.map(e=>e.name);e.edit.rows.set(n.file,df(e.rows(n.file),t,o.index)),e.edit.whole=!0,l=o.index}let u=e.setField(n.file,c,l,a);e.edit.cells.push({sheet:t,row:r,col:i,...a===``&&o.formula?{column:o.formula}:{input:a},record:{table:n,index:s,fields:u}})}function Uf(e,t,n,r,i){let a=e.rows(t.file),o=Math.max(a[0]?.length??1,1),s=Array(o).fill(``),c=t.columns[r-t.at.col];c?.csv!==void 0&&(s[c.csv]=i),a.push(s),e.grow(t,n,a.length-1),e.edit.whole=!0}function Wf(e,t,n,r,i){let a=e.table(t,n),o=n.columns.map(e=>e.name),s=r===n.at.row,c=s?uf(o,i.trim()===``?lf(o):i.trim()):lf(o);if(e.edit.whole=!0,!s&&Nf(i)){a.columns={...a.columns,[c]:{formula:Rf(i,n.at.row+1-r,0)}};return}let l=o.length,u=df(e.rows(n.file),o,l-1),d=u[0];if(d&&d.push(c),u.forEach((e,t)=>{t>0&&e.length>0&&e.push(``)}),!s){let e=n.places[r-n.at.row-1],t=e===void 0?void 0:u[e];t&&(t[l]=i)}e.edit.rows.set(n.file,u)}function Gf(e,t,n,r,i,a,o){e.setField(n,i-r.top,a-r.left,o),e.edit.cells.push({sheet:t,row:i,col:a,input:o})}function Kf(e,t,n){return Object.keys(e.spec.cells??{}).some(e=>{if(!e.includes(`:`))return!1;let r=x(e);return r!==void 0&&ke(r,t,n)})}function qf(e,t,n,r,i){let a=e.spec(t),o=Te({row:n,col:r}),s={...a.cells},c=s[o];if(typeof c==`object`&&c&&c.runs!==void 0&&fu(c.runs)===i){e.edit.cells.push({sheet:t,row:n,col:r,input:i,key:o});return}let l=c===void 0?{}:Ff(c),u=Pf(i),d=Object.keys(l).length===0,f;if(u===null){let e=Kf(t,n,r);f=!d||e,d&&!e?s=jf(s,o):s[o]=d?null:l}else f=!0,s[o]=d?u:{...l,...Nf(i)?{formula:i}:{value:u}};a.cells=s,Object.keys(s).length===0&&delete a.cells,e.edit.cells.push({sheet:t,row:n,col:r,input:i,key:f?o:null})}function Jf(e,t,n,r,i,a){let o=e.addedAt(n,r,i);if(o){let{csv:t}=o.table.columns[i-o.table.at.col]??{};t!==void 0&&e.setField(o.table.file,o.record,t,a);return}let s=n.tableAt(r,i);if(s){let o=s.columns[i-s.at.col];if(r===s.at.row)return o?Vf(e,t,s,o,a):void 0;Hf(e,n,s,r,i,a);return}if(a!==``){let t=If(e,n,r,i);if(t){Uf(e,t,r,i,a);return}let o=Lf(n,r,i);if(o){Wf(e,n,o,r,a);return}}let c=n.blockAt(r,i);c?Gf(e,n,c.file,c.area,r,i,a):qf(e,n,r,i,a)}function Yf(e,t,n,r,i){let a=e.workbook.sheet(t);if(!a)return R(`no-sheet`);let o=bf(i),s=fu(o);if(o.length===0||xf(o))return Zf(e,t,[{row:n,col:r,text:s}]);if(a.tableAt(n,r)||a.blockAt(n,r))return R(`rich-loose`);let c=new z(e),l=c.spec(a),u=Te({row:n,col:r}),d=l.cells?.[u],f=d===void 0?{}:Ff(d);return l.cells={...l.cells,[u]:{...f,runs:o}},c.edit.cells.push({sheet:a,row:n,col:r,input:s,key:u}),c.finish()}function Xf(e,t){if(typeof e!=`object`||!e||!e.runs)return e;let n=wf(e.runs,t);if(!xf(n))return{...e,runs:n};let r=fu(n),i=Ff(e);return Xe(r).value===r&&Xe(r).format===void 0?Object.keys(i).length===0?r:{...i,value:r}:{...i,runs:[{text:r}]}}function Zf(e,t,n){let r=e.workbook.sheet(t);if(!r)return R(`no-sheet`);let i=new z(e);for(let{row:t,col:a,text:o}of[...n].sort((e,t)=>e.row-t.row||e.col-t.col)){let n=Jf(i,e,r,t,a,o);if(n)return n}return i.finish()}function Qf(e,t,n,r,i){let a=e.workbook.sheet(t),o=a?.tableAt(n,r);if(!a||!o)return R(`no-sheet`);let s=o.columns[r-o.at.col];if(!s)return R(`no-sheet`);let c=new z(e);zf(c,a,o,s,n,i);let{csv:l}=s;if(l!==void 0)for(let e of o.places)c.setField(o.file,e,l,``);return c.finish()}function*$f(e,t){let n=Math.min(t.right,e.columnsUsed-1);for(let r=t.left;r<=n;r++){let[n,i]=e.span(r,t.top,t.bottom);for(let t=n;t<=i;t++)e.at(t,r)!==void 0&&(yield[t,r])}}function ep(e,t,n){let r=e.workbook.sheet(t);if(!r)return R(`no-sheet`);let i=new z(e);for(let e of r.tables){let{top:t,bottom:a}=e.data;if(!(a<t||n.top>t||n.bottom<a))for(let t of e.columns){let a=e.at.col+t.index;if(a<n.left||a>n.right||!t.formula)continue;let o=i.table(r,e),s=e.columns.map(e=>e.name);t.csv===void 0&&i.edit.rows.set(e.file,df(i.rows(e.file),s,t.index));let c=Af(o.columns?.[t.name]??{}),l=jf(o.columns??{},t.name);o.columns=Object.keys(c).length>0?{...l,[t.name]:c}:l,Object.keys(o.columns).length===0&&delete o.columns,i.edit.whole=!0}}for(let[t,a]of $f(r,n)){if(r.tableAt(t,a)?.at.row===t)continue;let n=Jf(i,e,r,t,a,``);if(n)return n}return i.finish()}function tp(e,t){e.cells&&=Object.fromEntries(Object.entries(e.cells).filter(([e])=>{let n=x(e);return!n||!Of(t,n)}))}function np(e,t,n,r,i){let a=e.workbook.sheet(t);if(!a)return R(`no-sheet`);if(!a.tables.some(e=>S(e.area,r))&&!a.blocks.some(e=>S(e.area,r))&&Nf(i)){let t=new z(e),o=t.spec(a);tp(o,r);let s=Rf(i,r.top-n.row,r.left-n.col),c=Ee(r);return o.cells={...o.cells,[c]:s},t.edit.whole=!0,t.finish()}let o=[];for(let e=r.top;e<=r.bottom;e++)for(let t=r.left;t<=r.right;t++)(e!==n.row||t!==n.col)&&o.push({row:e,col:t,text:Nf(i)?Rf(i,e-n.row,t-n.col):i});return Zf(e,t,o)}function rp(e,t,n,r,i){let a=e.workbook.sheet(t);if(!a)return R(`no-sheet`);let o=new z(e),s=o.spec(a);return s.blocks=[...s.blocks??[],{at:Te(n),rows:i}],o.edit.rows.set(i,r),o.edit.whole=!0,o.finish()}var ip=(e,t)=>Object.keys(t).some(t=>t in e),ap=(e,t)=>Object.fromEntries(Object.entries(e).filter(([e])=>!(e in t)));function op(e){if(typeof e!=`object`||!e)return e;let t=Object.keys(e);return t.length===1&&t[0]===`value`?e.value??null:t.length===1&&t[0]===`formula`?e.formula??null:e}var sp={bold:!1,italic:!1,underline:!1,strike:!1,wrap:!1,locked:!0,hide_formula:!1,align:`general`,format:`General`,color:`#000000`,fill:`#FFFFFF`,font:`Calibri`,size:11,border:{left:{style:`none`},right:{style:`none`},top:{style:`none`},bottom:{style:`none`}}};function cp(e,t,n,r){for(let[t,i]of Object.entries(e.columns??{})){let e=De(`${t}1`)?.col;if(e!==void 0&&e>=n.left&&e<=n.right&&r in i)return!0}for(let[t,i]of Object.entries(e.rows??{})){let e=Number(t)-1;if(e>=n.top&&e<=n.bottom&&r in i)return!0}return t.tables.some(e=>S(e.area,n)&&e.columns.some(t=>t.spec!==void 0&&r in t.spec&&e.at.col+t.index>=n.left&&e.at.col+t.index<=n.right))}function lp(e,t,n,r){let i=e.workbook.sheet(t);if(!i)return R(`no-sheet`);let a=new z(e);return up(a,i,n,r),a.finish()}function up(e,t,n,r){let i=e.spec(t);dp(e,t,i,n,r),fp(i)}function dp(e,t,n,r,i){let a=gf.filter(e=>e in i);if(n.cells&&a.length>0)for(let[e,t]of Object.entries(n.cells)){if(typeof t!=`object`||!t||!t.runs)continue;let i=x(e);i&&S(i,r)&&(n.cells={...n.cells,[e]:Xf(t,a)})}if(n.cells){let e={...n.cells},t=[];for(let[n,a]of Object.entries(e)){if(typeof a!=`object`||!a||!ip(a,i))continue;let o=x(n);o&&S(o,r)&&(n.includes(`:`)&&!Of(r,o)&&t.push({range:n,...Object.fromEntries(Object.entries(a).filter(([e])=>e in i))}),e[n]=op(ap(a,i)))}n.cells=e,t.length>0&&(n.format=[...n.format??[],...t])}let o=n.format??[],s=e=>{let t=x(e.range);return t!==void 0&&S(t,r)},c=o.some(e=>s(e)&&ip(e,i)),l=Object.fromEntries(Object.entries(i).filter(([,e])=>e!==void 0)),u=r.top===0&&r.bottom===1048575,d=r.left===0&&r.right===16383;if(u&&!d&&!c){let e={...n.columns};for(let t=r.left;t<=r.right;t++){let n=Ce(t),r={...ap(e[n]??{},i),...l};e=Object.keys(r).length===0?jf(e,n):{...e,[n]:r}}n.columns=e;return}if(d&&!u&&!c){let e={...n.rows};for(let t=r.top;t<=r.bottom;t++){let n=String(t+1),r={...ap(e[n]??{},i),...l};e=Object.keys(r).length===0?jf(e,n):{...e,[n]:r}}n.rows=e;return}let f=t.tables.find(e=>e.rows>0&&r.top===e.data.top&&r.bottom===e.data.bottom&&r.left>=e.area.left&&r.right<=e.area.right);if(f&&!c){let n=e.table(t,f),a={...n.columns};for(let e=r.left;e<=r.right;e++){let t=f.columns[e-f.at.col]?.name;if(t===void 0)continue;let n={...ap(a[t]??{},i),...l};a=Object.keys(n).length===0?jf(a,t):{...a,[t]:n}}n.columns=a,Object.keys(a).length===0&&delete n.columns,e.edit.whole=!0;return}let p=Ee(r),m=o.find(e=>{let t=x(e.range);return t!==void 0&&Ee(t)===p}),h=(m?o.slice(o.indexOf(m)+1):[]).some(e=>s(e)&&ip(e,i)),g={};for(let[e,a]of Object.entries(i)){let i=o.some(t=>t!==m&&s(t)&&e in t)||cp(n,t,r,e);a===void 0?i&&(g[e]=sp[e]):g[e]=a}if(m&&!h){let e={...ap(m,i),...g};n.format=o.flatMap(t=>t===m?Object.keys(e).length>1?[e]:[]:[t])}else Object.keys(g).length>0&&(n.format=[...o,{range:p,...g}])}function fp(e){e.format?.length===0&&delete e.format,e.columns&&Object.keys(e.columns).length===0&&delete e.columns,e.rows&&Object.keys(e.rows).length===0&&delete e.rows,e.cells&&Object.keys(e.cells).length===0&&delete e.cells}function pp(e,t,n,r){let i=e.workbook.sheet(t);if(!i)return R(`no-sheet`);let a=new z(e),o=a.spec(i),s=Ce(n),c=kf(o.columns?.[s]??{},`width`),l=r===void 0?c:{...c,width:r},u=jf(o.columns??{},s);return o.columns=Object.keys(l).length===0?u:{...u,[s]:l},fp(o),a.finish()}function mp(e,t,n,r){let i=e.workbook.sheet(t);if(!i)return R(`no-sheet`);let a=new z(e),o=a.spec(i),s=String(n+1),c=kf(o.rows?.[s]??{},`height`),l=r===void 0?c:{...c,height:r},u=jf(o.rows??{},s);return o.rows=Object.keys(l).length===0?u:{...u,[s]:l},fp(o),a.finish()}function hp(e,t,n){if(t.trim()===``||t.length>31||/[\\/?*[\]:]/u.test(t)||t.startsWith(`'`)||t.endsWith(`'`))return`sheet-name`;let r=e.workbook.sheet(t);if(r&&r.name!==n)return`sheet-taken`}function gp(e,t,n){let r=hp(e,n,t);if(r)return R(r);let i=mf(e,{op:`rename-sheet`,from:t,to:n});return{...Mf(),file:i.file,rows:new Map(i.rows),whole:!0}}function _p(e,t,n){let r=hp(e,t);if(r)return R(r);let i=[...e.file.sheets],a=i.findIndex(e=>e.name===n);return i.splice(a<0?i.length:a+1,0,{name:t}),{...Mf(),file:{...e.file,sheets:i},whole:!0}}function vp(e,t){for(let n=2;;n++){let r=` (${String(n)})`,i=t.slice(0,31-r.length).trimEnd()+r;if(!e.workbook.sheet(i))return i}}function yp(e,t){let n=hf(e,t,vp(e,t));return n.refused?R(n.refused):{...Mf(),file:n.file,rows:new Map(n.rows),whole:!0}}function bp(e,t){let n=mf(e,{op:`delete-sheet`,name:t});if(n.refused)return R(n.refused);let r=xp(e.file,n.file);for(let e of r)n.rows.delete(e);return{...Mf(),file:n.file,rows:new Map(n.rows),whole:!0,...r.length===0?{}:{removed:r}}}function xp(e,t){let n=e=>e.sheets.flatMap(e=>[...(e.tables??[]).map(e=>e.rows),...(e.blocks??[]).map(e=>e.rows)]),r=new Set(n(t));return[...new Set(n(e))].filter(e=>!r.has(e))}function Sp(e,t,n){let r=[...e.file.sheets],i=r.findIndex(e=>e.name===t),[a]=r.splice(i,1);return a?(r.splice(n,0,a),{...Mf(),file:{...e.file,sheets:r},whole:!0}):R(`no-sheet`)}function Cp(e,t){let n=mf(e,t);return n.refused?R(n.refused):{...Mf(),file:n.file,rows:new Map(n.rows),whole:!0}}function wp(e,t,n,r){if(!ru(t)||e.workbook.name(t)||e.workbook.table(t))return R(`name-invalid`);let i=(e,t)=>`$${Ce(t)}$${String(e+1)}`,a=r.top===r.bottom&&r.left===r.right?i(r.top,r.left):`${i(r.top,r.left)}:${i(r.bottom,r.right)}`,o=/^[\p{L}_][\p{L}\p{N}_.]*$/u.test(n)?n:`'${n.replaceAll(`'`,`''`)}'`;return{...Mf(),file:{...e.file,names:{...e.file.names,[t]:`=${o}!${a}`}},whole:!0}}function Tp(e,t,n,r){let i=t.at(n,r);if(i===void 0)return``;if(i instanceof M)return i.text;let a=t.tableAt(n,r);if(a){let e=a.columns[r-a.at.col];if(n===a.at.row)return e?.name??``;let t=e?.csv===void 0?void 0:a.records[n-a.at.row-1]?.[e.csv];if(t!==void 0)return t}let o=t.blockAt(n,r);if(o){let t=e.rows.get(o.file)?.[n-o.area.top]?.[r-o.area.left];if(t!==void 0)return t}let s=t.keys.get(ql(n,r)),c=s===void 0?void 0:t.spec.cells?.[s],l=typeof c==`object`&&c?c.value:c;return l==null?typeof i==`object`?i.code:String(i):String(l)}function Ep(e){let t=new Set([...e.file.sheets.flatMap(e=>(e.tables??[]).map(e=>e.name)),...Object.keys(e.file.names??{})].map(e=>e.toLowerCase()));for(let e=1;;e++){let n=`Table${String(e)}`;if(!t.has(n.toLowerCase()))return n}}function Dp(e,t,n,r){let i=e.workbook.sheet(t);if(!i)return R(`no-sheet`);if(i.tables.some(e=>S(e.area,n)))return R(`table-overlap`);let a=n.right-n.left+1,o=(t,n)=>Tp(e,i,t,n);if(!r.header){if(n.top===0)return R(`table-room`);for(let e=0;e<a;e++)if(o(n.top-1,n.left+e)!==``)return R(`table-room`)}let s=new z(e),c=new Set,l=Array.from({length:a},(e,t)=>{let i=r.header?o(n.top,n.left+t).trim():``,a=i===``?`Column${String(t+1)}`:i;for(let e=2;c.has(a.toLowerCase());e++)a=`${i===``?`Column${String(t+1)}`:i}${String(e)}`;return c.add(a.toLowerCase()),a}),u=r.header?n.top+1:n.top,d=[];for(let e=u;e<=n.bottom;e++)d.push(Array.from({length:a},(t,r)=>o(e,n.left+r)));for(let[t,r]of $f(i,n)){let n=Jf(s,e,i,t,r,``);if(n)return n}let f=Ep(e),p=new Set([...e.rows.keys(),...s.edit.rows.keys()].map(e=>e.toLowerCase())),m=`data/${f.toLowerCase()}.csv`;for(let e=2;p.has(m);e++)m=`data/${f.toLowerCase()}-${String(e)}.csv`;s.edit.rows.set(m,[l,...d]);let h=s.spec(i),g=r.header?n.top:n.top-1;return h.tables=[...h.tables??[],{name:f,at:Te({row:g,col:n.left}),rows:m,...r.style!==void 0&&r.style!==`TableStyleMedium2`?{style:r.style}:{}}],s.edit.whole=!0,s.finish()}function Op(e,t,n,r){let i=e.workbook.sheet(t),a=i?.tables.find(e=>e.name===n);if(!i||!a)return R(`no-sheet`);let o=new z(e),s=o.table(i,a);return r===`TableStyleMedium2`?delete s.style:s.style=r,o.edit.whole=!0,o.finish()}function kp(e,t,n,r){let i=e.workbook.sheet(t),a=i?.tables.find(e=>e.name===n);if(!i||!a)return R(`no-sheet`);let o=new z(e),s=o.table(i,a);return r.banded_rows!==void 0&&(r.banded_rows?delete s.banded_rows:s.banded_rows=!1),r.banded_columns!==void 0&&(r.banded_columns?s.banded_columns=!0:delete s.banded_columns),r.first_column!==void 0&&(r.first_column?s.first_column=!0:delete s.first_column),r.last_column!==void 0&&(r.last_column?s.last_column=!0:delete s.last_column),o.edit.whole=!0,o.finish()}function Ap(e,t){return t===void 0?e.names:e.sheets.find(e=>e.name===t)?.names}function jp(e,t,n){let r=Object.keys(n).length===0?void 0:n;if(t===void 0){let t={...e};return r?t.names=r:delete t.names,t}return{...e,sheets:e.sheets.map(e=>{if(e.name!==t)return e;let n={...e};return r?n.names=r:delete n.names,n})}}function Mp(e,t){let n=t.name.trim(),r=t.was!==void 0&&t.was.name.toLowerCase()!==n.toLowerCase(),i=Object.keys(Ap(e.file,t.scope)??{}).some(e=>e.toLowerCase()===n.toLowerCase()&&(e.toLowerCase()!==t.was?.name.toLowerCase()||t.was.scope!==t.scope));if(!ru(n)||i||e.workbook.table(n))return R(`name-invalid`);let a=t.value.trim(),o=Xe(a).value,s=a.startsWith(`=`)||o instanceof C?a:o,c=r&&t.was?Cp(e,{op:`rename-name`,from:t.was.name,to:n}):void 0;if(c?.refused)return c;let l=c?.file??e.file;if(t.was){let e={...Ap(l,t.was.scope)};for(let n of Object.keys(e))n.toLowerCase()===t.was.name.toLowerCase()&&(e[n]=null);l=jp(l,t.was.scope,Object.fromEntries(Object.entries(e).filter(([,e])=>e!==null)))}return l=jp(l,t.scope,{...Ap(l,t.scope),[n]:s}),{...Mf(),file:l,rows:c?.rows??new Map,whole:!0}}function Np(e,t,n){let r=Ap(e.file,n)??{},i=Object.fromEntries(Object.entries(r).filter(([e])=>e.toLowerCase()!==t.toLowerCase()));return{...Mf(),file:jp(e.file,n,i),whole:!0}}var Pp=e=>typeof e==`number`?0:typeof e==`string`?1:typeof e==`boolean`?2:3;function Fp(e,t){let n=Pp(e),r=Pp(t);if(n!==r)return n-r;if(typeof e==`number`&&typeof t==`number`)return e-t;if(typeof e==`string`&&typeof t==`string`){let n=e.toLowerCase(),r=t.toLowerCase();return n<r?-1:+(n>r)}return typeof e==`boolean`&&typeof t==`boolean`?e===t?0:e?1:-1:e instanceof C&&t instanceof C?e.code<t.code?-1:+(e.code>t.code):0}var Ip=e=>e===null||e===``;function Lp(e,t,n){return e.map((e,t)=>({row:e,index:t})).sort((e,r)=>{for(let{col:i,descending:a}of t){let t=n(e.row,i),o=n(r.row,i);if(Ip(t)||Ip(o)){if(Ip(t)&&Ip(o))continue;return Ip(t)?1:-1}let s=Fp(t,o);if(s!==0)return a===!0?-s:s}return e.index-r.index}).map(e=>e.row)}function Rp(e,t,n,r,i){let a=e.rows(t.file),o=[...a];r.forEach((e,r)=>{let s=n[r];if(s===void 0)return;let c=t.places[e-i],l=t.places[s-i];if(c===void 0||l===void 0)return;let u=s-e,d=o[c]??[];a[l]=u===0?d:d.map(e=>Xe(e).formula===void 0?e:Rf(e,u,0))}),e.edit.whole=!0}var zp=(e,t,n)=>{let r=[];for(let i=e;i<=t;i++)n?.has(i)||r.push(i);return r};function Bp(e,t,n,r,i,a){let o=e.workbook.sheet(n);if(!o)return R(`no-sheet`);if(i.length===0)return Mf();let s=(e,n)=>t.value(o,e,n),c=o.tables.find(e=>e.rows>0&&ke(e.area,r.top,r.left)),l=new z(e);if(c){let{top:e,bottom:t}=c.data,n=zp(e,t,a),r=Lp(n,i,s);return r.every((e,t)=>e===n[t])?Mf():(Rp(l,c,n,r,e),l.finish())}let u=zp(r.top,Math.min(r.bottom,o.lastRow),a);return Vp(l,e,o,r,u,Lp(u,i,s)),l.finish()}function Vp(e,t,n,r,i,a){let o=Math.min(r.right,n.columnsUsed-1);a.forEach((a,s)=>{let c=i[s];if(c!==void 0&&a!==c)for(let i=r.left;i<=o;i++){let r=Tp(t,n,a,i),o=Xe(r).formula===void 0?r:Rf(r,c-a,0);o!==Tp(t,n,c,i)&&Jf(e,t,n,c,i,o)}})}function Hp(e,t,n){if(n.bottom<=n.top)return!1;let r=(n,r)=>t.value(e,n,r);for(let t=n.left;t<=n.right;t++){let i=r(n.top,t),a=r(n.top+1,t);if(typeof i==`string`&&a!==null&&typeof a!=`string`||e.lookAt(n.top,t).bold===!0&&e.lookAt(n.top+1,t).bold!==!0)return!0}return!1}var Up=.1,Wp={3:[0,33,67],4:[0,25,50,75],5:[0,20,40,60,80]},Gp=e=>{if(e!==null&&e!==``&&!(e instanceof C))return typeof e==`string`?`s${e.toLowerCase()}`:`${typeof e}${String(e)}`},Kp=e=>Math.round(e).toString(16).padStart(2,`0`);function qp(e,t,n){let r=(e,t)=>Number.parseInt(e.slice(t,t+2),16),i=i=>Kp(r(e,i)+(r(t,i)-r(e,i))*n);return`#${i(1)}${i(3)}${i(5)}`.toUpperCase()}function Jp(e,t){let n=e=>typeof e==`number`||e===null?0:typeof e==`string`?1:typeof e==`boolean`?2:3,r=n(e),i=n(t);if(r!==i)return r-i;if(r===0)return(e??0)-(t??0);if(r===1){let n=e.toLowerCase(),r=t.toLowerCase();return n<r?-1:+(n>r)}return e===t?0:e===!0?1:-1}function Yp(e,t,n,r){if(t instanceof C)return!1;let i=()=>Jp(t,n);switch(e){case`equal`:return i()===0;case`notEqual`:return i()!==0;case`greaterThan`:return i()>0;case`lessThan`:return i()<0;case`greaterThanOrEqual`:return i()>=0;case`lessThanOrEqual`:return i()<=0;default:{let n=i()>=0&&Jp(t,r)<=0;return e===`notBetween`?!n:n}}}var Xp=e=>e===null||e instanceof C?``:typeof e==`boolean`?e?`TRUE`:`FALSE`:String(e);function Zp(e,t,n){if(t instanceof C)return!1;let r=Xp(t).toLowerCase(),i=n.toLowerCase();switch(e){case`notContains`:return!r.includes(i);case`beginsWith`:return r.startsWith(i);case`endsWith`:return r.endsWith(i);default:return r.includes(i)}}function Qp(e){if(e.type===`dataBar`||e.type===`colorScale`||e.type===`iconSet`)return;let t={};return e.bold!==void 0&&(t.bold=e.bold),e.italic!==void 0&&(t.italic=e.italic),e.underline!==void 0&&(t.underline=e.underline),e.strike!==void 0&&(t.strike=e.strike),e.color!==void 0&&(t.color=e.color),e.fill!==void 0&&(t.fill=e.fill),e.border!==void 0&&(t.border=e.border),e.format!==void 0&&(t.format=e.format),t}function $p(e,t){let n=(e.length-1)*t,r=Math.floor(n),i=Math.ceil(n),a=e[r]??0;return a+((e[i]??a)-a)*(n-r)}var em=class{sheet;calc;measured=new Map;constructor(e,t){this.sheet=e,this.calc=t}measure(e){let t=this.measured.get(e);if(t)return t;let n=[],r=new Map;for(let t of e.areas)this.eachIn(t,e=>{typeof e==`number`&&n.push(e);let t=Gp(e);t!==void 0&&r.set(t,(r.get(t)??0)+1)});let i={numbers:n,sorted:[...n].sort((e,t)=>e-t),counts:r};return this.measured.set(e,i),i}eachIn(e,t){let{sheet:n,calc:r}=this,i=Math.min(e.right,n.columnsUsed-1);for(let a=e.left;a<=i;a++){let[i,o]=n.span(a,e.top,e.bottom);for(let e=i;e<=o;e++){let i=r.value(n,e,a);i!==null&&t(i)}}}boundAt(e,t,n,r){if(t===void 0)return null;if(typeof t==`number`)return t;if(!t.startsWith(`=`)){let e=Xe(t);return e.formula===void 0?e.value:t}let i=e.formulas.find(e=>e.text===t);if(!i)return null;let a=this.calc.evaluateAt(i,this.sheet,n,r);return a instanceof T?a.at(0,0):a}stopAt(e,t,n,r,i){let{sorted:a}=this.measure(e),o=a[0]??0,s=a[a.length-1]??0,c=this.boundAt(e,t.value,n,r),l=typeof c==`number`?c:void 0;switch(t.at){case`min`:return o;case`max`:return s;case`percent`:return o+(s-o)*(l??i)/100;case`percentile`:return $p(a,(l??i)/100);default:return l??i}}whether(e,t,n,r){let{spec:i}=e;switch(i.type){case`cellIs`:return Yp(i.operator,t,this.boundAt(e,i.formula[0],n,r),this.boundAt(e,i.formula[1],n,r));case`containsText`:return Zp(i.operator,t,i.text);case`duplicateValues`:case`uniqueValues`:{let n=Gp(t);if(n===void 0)return!1;let r=this.measure(e).counts.get(n)??0;return i.type===`duplicateValues`?r>1:r===1}case`top10`:{if(typeof t!=`number`)return!1;let{sorted:n}=this.measure(e),r=i.percent===!0?Math.max(1,Math.floor(n.length*i.rank/100)):i.rank,a=i.bottom===!0?n[Math.min(r,n.length)-1]:n[Math.max(n.length-r,0)];return a===void 0?!1:i.bottom===!0?t<=a:t>=a}case`aboveAverage`:{if(typeof t!=`number`)return!1;let{numbers:n}=this.measure(e);if(n.length===0)return!1;let r=n.reduce((e,t)=>e+t,0)/n.length;return i.equal===!0&&t===r?!0:i.below===!0?t<r:t>r}case`expression`:{let[t]=e.formulas;if(!t)return!1;let i=this.calc.evaluateAt(t,this.sheet,n,r);return Ru(i instanceof T?i.at(0,0):i)===!0}default:return!1}}scale(e,t,n,r,i){let a=t.stops.map((n,a)=>({at:this.stopAt(e,n,r,i,a*100/(t.stops.length-1)),color:n.color})),[o]=a,s=a[a.length-1];if(o&&s){if(n<=o.at)return o.color;if(n>=s.at)return s.color;for(let e=1;e<a.length;e++){let t=a[e-1],r=a[e];if(t&&r&&n<=r.at)return qp(t.color,r.color,r.at===t.at?1:(n-t.at)/(r.at-t.at))}return s.color}}bar(e,t,n,r,i){let a=this.stopAt(e,t.min??{at:`min`},r,i,0),o=this.stopAt(e,t.max??{at:`max`},r,i,100);return o<=a?Up:Up+.8*Math.min(1,Math.max(0,(n-a)/(o-a)))}icon(e,t,n,r,i){let a=Number.parseInt(t.icons,10),o=t.stops??(Wp[a]??[]).map(e=>({at:`percent`,value:e})),s=0;return o.forEach((t,a)=>{n>=this.stopAt(e,t,r,i,0)&&(s=a)}),t.reverse===!0?a-1-s:s}at(e,t){let{sheet:n,calc:r}=this;if(n.conditions.length===0)return;let i=r.value(n,e,t),a;for(let r of n.conditions){if(!r.areas.some(n=>ke(n,e,t)))continue;let{spec:n}=r;if(n.type===`dataBar`||n.type===`colorScale`||n.type===`iconSet`){if(typeof i!=`number`)continue;if(a??={},n.type===`dataBar`)a.bar??={share:this.bar(r,n,i,e,t),color:n.color},n.show===!1&&(a.bare=!0);else if(n.type===`colorScale`){let o=this.scale(r,n,i,e,t);o!==void 0&&(a.scale??=o)}else a.icon??={set:n.icons,index:this.icon(r,n,i,e,t)},n.show===!1&&(a.bare=!0);if(n.stop===!0)break}else if(this.whether(r,i,e,t)&&(a??={},a.look={...Qp(n),...a.look},n.stop===!0))break}return a}},tm=`#00A651`,nm=`#FFC000`,rm=`#E03C32`,im=`#7F7F7F`,am=`#000000`,om=`#2F75B5`,sm=e=>e===3?[rm,nm,tm]:e===4?[am,rm,nm,tm]:[rm,`#ED7D31`,nm,`#92D050`,tm];function cm(e,t){let n=Number.parseInt(e,10),r=sm(n)[t]??im,i=e.slice(1);return i.startsWith(`Arrows`)?{shape:(n===3?[`down`,`right`,`up`]:n===4?[`down`,`down-right`,`up-right`,`up`]:[`down`,`down-right`,`right`,`up-right`,`up`])[t]??`right`,color:i===`ArrowsGray`?im:r}:i===`Flags`?{shape:`flag`,color:r}:i===`Signs`?{shape:t===0?`diamond`:t===1?`triangle`:`circle`,color:r}:i.startsWith(`Symbols`)?{shape:t===0?`cross`:t===1?`bang`:`check`,color:r}:i===`Rating`?{shape:`bars`,color:om,level:t+1}:i===`Quarters`?{shape:`quarter`,color:im,level:t}:i===`RedToBlack`?{shape:`circle`,color:[`#000000`,`#7F7F7F`,`#F4B6B6`,`#E03C32`][t]??im}:{shape:`circle`,color:r}}var lm=e=>e.separator??`, `;function um(e,t){let n=lm(t);return e.split(n.trim()===``?n:n.trim()).map(e=>e.trim()).filter(e=>e!==``)}var dm=(e,t)=>e.join(lm(t));function fm(e,t,n,r,i){let{spec:a}=n;if(a.values)return a.values;let[o]=a.formula??[],[s]=n.formulas;if(!s)return typeof o==`string`?o.split(`,`):[];let c=e.evaluateAt(s,t,r,i),l=e=>et(e,void 0);return c instanceof T?c.data.map(l).filter(e=>e!==``):c===null?[]:[l(c)]}function pm(e,t,n,r,i,a){let o=n.spec.formula?.[r];if(o===void 0)return null;let s=n.formulas[r];if(s){let n=e.evaluateAt(s,t,i,a);return n instanceof T?n.at(0,0):n}if(typeof o==`number`)return o;let c=Xe(o);return c.formula===void 0?c.value:null}function mm(e,t,n,r,i,a){let[o]=n.formulas;if(!o)return!0;let s=t.at(r,i),c=e.value(t,r,i)!==a&&!(s instanceof M);c&&e.change([{sheet:t,row:r,col:i,slot:a??void 0}]);let l=e.evaluateAt(o,t,r,i);return c&&e.change([{sheet:t,row:r,col:i,slot:s}]),Ru(l instanceof T?l.at(0,0):l)===!0}function hm(e,t,n,r,i,a){let{spec:o}=n;if(a===null||a===``)return o.blank!==!1;if(a instanceof C)return!1;let s=o.operator??`between`,c=a=>pm(e,t,n,a,r,i);switch(o.type){case`list`:{let s=et(a,void 0),c=fm(e,t,n,r,i).map(e=>e.trim()),l=e=>o.values?c.includes(e.trim()):c.some(t=>t.toLowerCase()===e.trim().toLowerCase());return o.multiple===!0?um(s,o).every(l):l(s)}case`custom`:return mm(e,t,n,r,i,a);case`textLength`:return Yp(s,(typeof a==`string`?a:et(a)).length,c(0),c(1));case`whole`:return typeof a==`number`&&Number.isInteger(a)&&Yp(s,a,c(0),c(1));case`time`:return typeof a==`number`&&a>=0&&a<1&&Yp(s,a,c(0),c(1));default:return typeof a==`number`&&Yp(s,a,c(0),c(1))}}function gm(e,t,n){let r=Math.min(t.right,e.columnsUsed-1);for(let i=t.left;i<=r;i++){let[r,a]=e.span(i,t.top,t.bottom);for(let t=r;t<=a;t++)e.at(t,i)!==void 0&&n(t,i)}}function _m(e,t){let n=[];for(let r of e.sheets)for(let e of r.validations)for(let i of e.areas)gm(r,i,(i,a)=>{let o=t.value(r,i,a);hm(t,r,e,i,a,o)||n.push({sheet:r.name,row:i,col:a,value:o,range:e.spec.range,type:e.spec.type})});return n}var vm=(e,t,n,r)=>et(t.value(e,n,r),e.lookAt(n,r).format),ym=(e,t)=>{if(t===``)return e.blanks===!0;let n=t.toLowerCase();return e.values?.some(e=>e.toLowerCase()===n)===!0},bm=e=>e.values!==void 0||e.blanks!==void 0,xm=(e,t)=>!bm(e)||ym(e,t);function Sm(e,t,n,r){let i=e.validations.length===0?void 0:e.validationAt(t,n);return i?.spec.multiple===!0?um(r,i.spec):[r]}function Cm(e,t,n){let{operator:r}=e,i=e.value;if(typeof i==`number`&&typeof t==`number`)switch(r){case`equal`:return t===i;case`notEqual`:return t!==i;case`greaterThan`:return t>i;case`greaterThanOrEqual`:return t>=i;case`lessThan`:return t<i;case`lessThanOrEqual`:return t<=i}let a=String(i);if(r===`equal`||r===`notEqual`){let e=md(a)?fd(a)(n):n.toLowerCase()===a.toLowerCase();return r===`equal`?e:!e}if(n===``)return!1;let o=n.toLowerCase().localeCompare(a.toLowerCase());switch(r){case`greaterThan`:return o>0;case`greaterThanOrEqual`:return o>=0;case`lessThan`:return o<0;case`lessThanOrEqual`:return o<=0}}function wm(e,t,n,r,i){let{top:a}=n.area,o=Math.min(n.area.bottom,e.lastRow),s=()=>{let n=[];for(let i=a+1;i<=o;i++){let a=t.value(e,i,r);typeof a==`number`&&n.push(a)}return n};if(i.values!==void 0||i.blanks!==void 0)return n=>{let a=vm(e,t,n,r);return a===``?i.blanks===!0:Sm(e,n,r,a).some(e=>ym(i,e))};let c=i.conditions;if(c)return n=>{let a=t.value(e,n,r),o=vm(e,t,n,r),s=c.map(e=>Cm(e,a,o));return i.or===!0?s.some(Boolean):s.every(Boolean)};let l=i.top;if(l){let n=s().sort((e,t)=>l.bottom===!0?e-t:t-e),i=l.percent===!0?Math.max(1,Math.floor(n.length*l.count/100)):Math.round(l.count),a=n[Math.min(i,n.length)-1];return n=>{let i=t.value(e,n,r);return typeof i!=`number`||a===void 0?!1:l.bottom===!0?i<=a:i>=a}}if(i.average){let n=s(),a=n.reduce((e,t)=>e+t,0)/Math.max(1,n.length),o=i.average===`above`;return n=>{let i=t.value(e,n,r);return typeof i==`number`&&(o?i>a:i<a)}}let u=i.color;return u?t=>{let n=e.lookAt(t,r);return u.fill===void 0?u.font===void 0||(n.color??`#000000`).toUpperCase()===u.font.toUpperCase():typeof n.fill==`string`&&n.fill.toUpperCase()===u.fill.toUpperCase()}:()=>!0}function Tm(e,t,n,r){return[...n.columns].filter(([e])=>e!==r).map(([r,i])=>wm(e,t,n,r,i))}var Em=(e,t)=>e.every(e=>e(t));function Dm(e,t){let n=new Set;for(let r of e.filters){if(r.columns.size===0)continue;let{top:i,bottom:a}=r.area,o=Math.min(a,e.lastRow),s=Tm(e,t,r);for(let e=i+1;e<=o;e++)Em(s,e)||n.add(e)}return n}function Om(e,t,n,r){let i=n.columns.get(r),a=new Map,o=0,{top:s,bottom:c}=n.area,l=Math.min(c,e.lastRow),u=Tm(e,t,n,r);for(let n=s+1;n<=l;n++){if(!Em(u,n))continue;let s=vm(e,t,n,r);if(s===``){o+=1;continue}let c=Sm(e,n,r,s);for(let o of c){let s=o.toLowerCase(),l=a.get(s);l?l.count+=1:a.set(s,{text:o,count:1,on:i===void 0||xm(i,o),value:c.length>1?o:t.value(e,n,r)})}}return{values:[...a.values()].sort((e,t)=>Fp(e.value,t.value)),blanks:o===0?void 0:{count:o,on:i===void 0||i.blanks===!0||!bm(i)}}}function km(e,t){let n=(t,n)=>t>=0&&n>=0&&(e.at(t,n)!==void 0||e.spillAt(t,n)!==void 0),r={top:t.row,left:t.col,bottom:t.row,right:t.col};for(let e=!0;e;){e=!1;let t=e=>{for(let t=r.left-1;t<=r.right+1;t++)if(n(e,t))return!0;return!1},i=e=>{for(let t=r.top-1;t<=r.bottom+1;t++)if(n(t,e))return!0;return!1};t(r.top-1)&&(--r.top,e=!0),t(r.bottom+1)&&(r.bottom+=1,e=!0),i(r.left-1)&&(--r.left,e=!0),i(r.right+1)&&(r.right+=1,e=!0)}return r.top===r.bottom&&r.left===r.right&&!n(r.top,r.left)?void 0:r}var Am=(e,t)=>e?t.calc.eval(e,t.frame):!1;function jm(e,t,n){if(!(e instanceof T))return e;let r=e.rows===1?0:t,i=e.cols===1?0:n;return r<e.rows&&i<e.cols?e.at(r,i):w.NA}function Mm(e,t,n){let r=[e,...t].filter(e=>e instanceof T),i=Math.max(...r.map(e=>e.rows)),a=Math.max(...r.map(e=>e.cols)),o=Array(i*a);for(let r=0;r<i;r++)for(let i=0;i<a;i++){let s=n(jm(e,r,i));o[r*a+i]=s instanceof C?s:jm(t[s]??w.VALUE,r,i)}return new T(i,a,o)}td(`IF`,1,3,(e,t)=>{let n=t.calc.flat(Am(e[0],t)),r=n=>{let r=e[n];if(r===void 0)return n===1;let i=t.calc.eval(r,t.frame);return i instanceof D?null:i};if(n instanceof T){let i=n=>n<e.length?t.calc.flat(r(n))??0:!1;return Mm(n,[i(1),i(2)],e=>{let t=Ru(e);return t instanceof C?t:+!t})}let i=Ru(n);return i instanceof C?i:r(i?1:2)}),td(`IFS`,2,255,(e,t)=>{for(let n=0;n+1<e.length;n+=2){let r=Ru(t.calc.scalar(Am(e[n],t),t.frame));if(r instanceof C)return r;if(r)return Am(e[n+1],t)}return w.NA});var Nm=e=>(t,n)=>{let r=n.calc.flat(Am(t[0],n)),i=t=>t instanceof C&&(e===void 0||t===e),a=()=>t[1]?n.calc.flat(n.calc.eval(t[1],n.frame)):``;return r instanceof T?Mm(r,[r,a()],e=>+!!i(e)):i(r)?a():r};td(`IFERROR`,2,2,Nm()),td(`IFNA`,2,2,Nm(w.NA)),td(`CHOOSE`,2,255,(e,t)=>{let n=t.calc.flat(Am(e[0],t));if(n instanceof T){let r=e.slice(1).map(e=>t.calc.flat(t.calc.eval(e,t.frame)));return Mm(n,r,e=>{let t=N(e);if(t instanceof C)return t;let n=Math.trunc(t)-1;return n<0||n>=r.length?w.VALUE:n})}let r=N(n);if(r instanceof C)return r;let i=Math.trunc(r),a=e[i];return i<1||a===void 0?w.VALUE:t.calc.eval(a,t.frame)}),td(`SWITCH`,3,255,(e,t)=>{let n=t.calc.scalar(Am(e[0],t),t.frame);if(n instanceof C)return n;let r=1;for(;r+1<e.length;r+=2){let i=t.calc.scalar(Am(e[r],t),t.frame);if(i instanceof C)return i;if(Vu(n,i)===0)return Am(e[r+1],t)}return r<e.length?Am(e[r],t):w.NA});function Pm(e,t){let n=[],r;return rd(e,t,(e,t)=>{if(r)return;if(e instanceof C){r=e;return}if(typeof e==`string`&&!t||e===null)return;let i=Ru(e);i instanceof C?r=i:n.push(i)}),r||(n.length===0?w.VALUE:n)}I(`AND`,`(r)`,(e,t)=>{let n=Pm(e,t);return n instanceof C?n:n.every(Boolean)}),I(`OR`,`(r)`,(e,t)=>{let n=Pm(e,t);return n instanceof C?n:n.some(Boolean)}),I(`XOR`,`(r)`,(e,t)=>{let n=Pm(e,t);return n instanceof C?n:n.filter(Boolean).length%2==1}),F(`NOT`,1,1,e=>{let t=Ru(e);return t instanceof C?t:!t}),I(`TRUE`,``,()=>!0),I(`FALSE`,``,()=>!1);var Fm=(e,t)=>t?{names:e,parent:t}:{names:e};td(`LET`,3,255,(e,t)=>{if(e.length%2==0)return w.VALUE;let n=new Map,r={...t.frame,scope:Fm(n,t.frame.scope)};for(let i=0;i+1<e.length;i+=2){let a=e[i];if(a?.kind!==`name`)return w.VALUE;n.set(a.name.toLowerCase(),Am(e[i+1],{...t,frame:r}))}return Am(e[e.length-1],{...t,frame:r})}),td(`LAMBDA`,1,254,(e,t)=>{let n=[];for(let t of e.slice(0,-1)){if(t.kind!==`name`)return w.VALUE;n.push(t.name.toLowerCase())}let r=e[e.length-1];return r?new at(n,r,t.frame):w.VALUE});function Im(e){let t=0;for(let n of e)t=Uu(t+n,t,n);return t}I(`SUM`,`(r)`,(e,t)=>{let n=0,r;return rd(e,t,(e,i)=>{if(!r){if(typeof e==`number`)n=Uu(n+e,n,e);else if(e instanceof C)r=e;else if(i){let i=ad([e],t);i instanceof C?r=i:n+=i[0]??0}}}),r??Hu(n)}),I(`AVERAGE`,`(r)`,(e,t)=>{let n=ad(e,t);return n instanceof C?n:n.length===0?w.DIV0:Im(n)/n.length}),I(`AVERAGEA`,`(r)`,(e,t)=>{let n=od(e,t);return n instanceof C?n:n.length===0?w.DIV0:Im(n)/n.length}),I(`COUNT`,`(r)`,(e,t)=>{let n=0;return rd(e,t,(e,r)=>{typeof e==`number`?n+=1:r&&!(e instanceof C)&&e!==null&&(ad([e],t)instanceof C||(n+=1))}),n}),I(`COUNTA`,`(r)`,(e,t)=>{let n=0;return rd(e,t,()=>{n+=1}),n}),I(`COUNTBLANK`,`r`,(e,t)=>{let n=e[0];if(n instanceof C)return n;if(n instanceof E){let e=0;return t.calc.each(n,t=>{t!==``&&(e+=1)}),n.rows*n.cols-e}let r=t.calc.flat(n);return r instanceof T?r.data.filter(e=>e===null||e===``).length:+(r===null||r===``)});var Lm=e=>t=>{if(t instanceof C)return t;if(t.length===0)return 0;let n=t[0]??0;for(let r of t)n=e(n,r);return n},Rm=Lm((e,t)=>t<e?t:e),zm=Lm((e,t)=>t>e?t:e);I(`MIN`,`(r)`,(e,t)=>Rm(ad(e,t))),I(`MAX`,`(r)`,(e,t)=>zm(ad(e,t))),I(`MINA`,`(r)`,(e,t)=>Rm(od(e,t))),I(`MAXA`,`(r)`,(e,t)=>zm(od(e,t))),I(`PRODUCT`,`(r)`,(e,t)=>{let n=ad(e,t);return n instanceof C?n:n.length===0?0:Hu(n.reduce((e,t)=>e*t,1))}),I(`SUMSQ`,`(r)`,(e,t)=>{let n=ad(e,t);return n instanceof C?n:Hu(Im(n.map(e=>e*e)))}),I(`SUMPRODUCT`,`(r)`,(e,t)=>{let n=e.map(e=>L(e,t)),r=n[0];if(r===void 0||r instanceof C)return r??w.VALUE;let{rows:i}=r,{cols:a}=r,o=e=>e.reference&&e.reference.bottom<1048575?e.reference.rows:e.rows;for(let e of n){if(e instanceof C)return e;if(e.cols!==a||o(e)!==o(r))return w.VALUE;i=Math.min(i,e.rows)}let s=0;for(let e=0;e<i;e++)for(let t=0;t<a;t++){let r=1;for(let i of n){let n=i.at(e,t);if(n instanceof C)return n;r*=typeof n==`number`?n:0}s+=r}return Hu(s)});var Bm={1:`AVERAGE`,2:`COUNT`,3:`COUNTA`,4:`MAX`,5:`MIN`,6:`PRODUCT`,7:`STDEV.S`,8:`STDEV.P`,9:`SUM`,10:`VAR.S`,11:`VAR.P`};function Vm(e){if(!(e instanceof M))return!1;let{node:t}=e.shared;return t?.kind===`call`&&t.name===`SUBTOTAL`}I(`SUBTOTAL`,`v(r)`,(e,t)=>{let n=t.calc.scalar(e[0],t.frame);if(n instanceof C)return n;if(typeof n!=`number`)return w.VALUE;let r=n<100,i=Bm[r?n:n-100],a=i===void 0?void 0:Xu.get(i);if(a?.kind!==`raw`)return w.VALUE;let o=[],s=e=>{let n=t=>e.sheet.spec.rows?.[String(t+1)]?.hidden===!0,i=Math.min(e.bottom,e.sheet.lastRow),a=[],s=t.calc.filtered(e.sheet);for(let o=e.top;o<=i;o++)if(!s.has(o)&&(r||!n(o)))for(let n=e.left;n<=e.right;n++)a.push(Vm(e.sheet.at(o,n))?null:t.calc.read(e.sheet,o,n));o.push(new T(a.length,1,a))};for(let t of e.slice(1)){if(t instanceof C)return t;if(t instanceof E)s(t);else if(t instanceof it)t.parts.forEach(s);else return w.VALUE}return a.call(o,t)});var Hm=(e,t)=>typeof e==typeof t&&!(e instanceof C)&&e!==null;function Um(e){if(e.rows===1)return{length:e.cols,at:t=>e.at(0,t)};if(e.cols===1)return{length:e.rows,at:t=>e.at(t,0)}}var Wm=new WeakMap;function Gm(e,t){let n=Wm.get(e);if(n)return n;if(n===void 0){Wm.set(e,null);return}let r=t();return Wm.set(e,r),r}function Km(e,t,n,r,i,a=0,o=1){let s=typeof e==`string`?e:void 0,c=i&&s!==void 0&&md(s)?hd(s):s;if(s!==void 0&&c===void 0){let e=fd(s);for(let n=a;n>=0&&n<t.length;n+=o){let r=t.at(n);if(typeof r==`string`&&e(r))return n}return-1}let l=ld(c??e);if(l===void 0)return-1;if(t.length>=64&&a===0&&o===1){let e=()=>{let e=new Map;for(let n=t.length-1;n>=0;n--){let r=ld(t.at(n));r!==void 0&&e.set(r,[n])}return e},i=n.reference,a=i?r.calc.indexes.ofRepeated(Yu(`find`,i),[i],e):n.array&&Gm(n.array,e);if(a)return a.get(l)?.[0]??-1}for(let e=a;e>=0&&e<t.length;e+=o)if(ld(t.at(e))===l)return e;return-1}function qm(e,t,n=!1){let r=0,i=t.length-1,a=-1;for(;r<=i;){let o=r+i>>1,s=o;for(;s>=r&&!Hm(t.at(s),e);)--s;if(s<r){r=o+1;continue}let c=Vu(t.at(s),e);(n?c>=0:c<=0)?(a=s,r=o+1):i=s-1}return a}var Jm=(e,t)=>t.calc.scalar(e??null,t.frame),Ym=(e,t,n)=>e===void 0?n:e instanceof D?!1:Ru(t.calc.scalar(e,t.frame));function Xm(e){return(t,n)=>{let r=Jm(t[0],n);if(r instanceof C)return r;let i=L(t[1],n);if(i instanceof C)return i;let a=N(n.calc.scalar(t[2],n.frame));if(a instanceof C)return a;let o=Math.trunc(a);if(o<1)return w.VALUE;let s=i.reference,c=s?s.bottom-s.top+1:i.rows;if(o>(e?i.cols:c))return w.REF;let l=Ym(t[3],n,!0);if(l instanceof C)return l;let u={length:e?i.rows:i.cols,at:t=>e?i.at(t,0):i.at(0,t)},d={rows:e?i.rows:1,cols:e?1:i.cols,at:(e,t)=>i.at(e,t),...i.reference?{reference:new E(i.reference.sheet,i.reference.top,i.reference.left,e?i.reference.bottom:i.reference.top,e?i.reference.left:i.reference.right)}:{}},f=l?qm(r,u):Km(r,u,d,n,!0);return f<0?w.NA:e?i.at(f,o-1):i.at(o-1,f)}}I(`VLOOKUP`,`vrv?v`,Xm(!0)),I(`HLOOKUP`,`vrv?v`,Xm(!1)),I(`MATCH`,`vr?v`,(e,t)=>{let n=Jm(e[0],t);if(n instanceof C)return n;let r=L(e[1],t);if(r instanceof C)return r;let i=Um(r);if(!i)return w.NA;let a=e[2]===void 0?1:e[2]instanceof D?0:N(t.calc.scalar(e[2],t.frame));if(a instanceof C)return a;let o=a===0?Km(n,i,r,t,!0):qm(n,i,a<0);return o<0?w.NA:o+1}),I(`LOOKUP`,`vr?r`,(e,t)=>{let n=Jm(e[0],t);if(n instanceof C)return n;let r=L(e[1],t);if(r instanceof C)return r;let i=r.rows>=r.cols,a=qm(n,{length:i?r.rows:r.cols,at:e=>i?r.at(e,0):r.at(0,e)});if(a<0)return w.NA;if(e[2]===void 0)return i?r.at(a,r.cols-1):r.at(r.rows-1,a);let o=L(e[2],t);if(o instanceof C)return o;let s=Um(o);return s?s.at(a):w.NA});function Zm(e,t,n,r,i){let a=Um(t);if(!a)return-1;let o=i===-1;if(Math.abs(i)===2){let t=qm(e,a,i<0);if(t>=0&&Vu(a.at(t),e)===0)return t;if(r===0)return-1}let s=Km(e,a,t,n,r===2,o?a.length-1:0,o?-1:1);if(s>=0||r===0||r===2)return s;let c=-1;for(let t=0;t<a.length;t++){let n=a.at(t);if(!Hm(n,e))continue;let i=Vu(n,e),o=c<0||(r<0?Vu(n,a.at(c))>0:Vu(n,a.at(c))<0);(r<0?i<0:i>0)&&o&&(c=t)}return c}var Qm=(e,t,n)=>{let r=(e,t)=>e===void 0||e instanceof D?t:N(n.calc.scalar(e,n.frame)),i=r(e,0);if(i instanceof C)return i;let a=r(t,1);return a instanceof C?a:[i,a]};I(`XLOOKUP`,`vrr?rvv`,(e,t)=>{let n=Jm(e[0],t);if(n instanceof C)return n;let r=L(e[1],t);if(r instanceof C)return r;let i=L(e[2],t);if(i instanceof C)return i;let a=Qm(e[4],e[5],t);if(a instanceof C)return a;let o=Zm(n,r,t,a[0],a[1]);if(o<0){let n=e[3];return n===void 0||n instanceof D?w.NA:t.calc.flat(n)}if(r.cols===1){if(i.cols===1)return i.at(o,0);let e=[];for(let t=0;t<i.cols;t++)e.push(i.at(o,t));return new T(1,i.cols,e)}if(i.rows===1)return i.at(0,o);let s=[];for(let e=0;e<i.rows;e++)s.push(i.at(e,o));return new T(i.rows,1,s)}),I(`XMATCH`,`vr?vv`,(e,t)=>{let n=Jm(e[0],t);if(n instanceof C)return n;let r=L(e[1],t);if(r instanceof C)return r;let i=Qm(e[2],e[3],t);if(i instanceof C)return i;let a=Zm(n,r,t,i[0],i[1]);return a<0?w.NA:a+1}),I(`INDEX`,`rv?vv`,(e,t)=>{let n=e[0],r=e=>{if(e===void 0||e instanceof D)return 0;let n=N(t.calc.scalar(e,t.frame));return n instanceof C?n:Math.trunc(n)};if(n instanceof it){let t=r(e[3]??1);if(t instanceof C)return t;let i=n.parts[t-1];if(!i)return w.REF;n=i}if(n instanceof C)return n;let i=r(e[1]);if(i instanceof C)return i;let a=r(e[2]);if(a instanceof C)return a;if(i<0||a<0)return w.VALUE;if(n instanceof E){let t=e[2]===void 0&&n.rows===1,r=t?1:i,o=t?i:a;return r>n.rows||o>n.cols?w.REF:new E(n.sheet,r===0?n.top:n.top+r-1,o===0?n.left:n.left+o-1,r===0?n.bottom:n.top+r-1,o===0?n.right:n.left+o-1)}let o=L(n,t);if(o instanceof C)return o;let s=e[2]===void 0&&o.rows===1,c=s?1:i,l=s?i:a===0&&o.cols===1?1:a;if(c>o.rows||l>o.cols)return w.REF;if(c>0&&l>0)return o.at(c-1,l-1);let u=c===0?o.rows:1,d=l===0?o.cols:1,f=[];for(let e=0;e<u;e++)for(let t=0;t<d;t++)f.push(o.at(c===0?e:c-1,l===0?t:l-1));return new T(u,d,f)}),I(`OFFSET`,`rvv?vv`,(e,t)=>{let n=e[0];if(n instanceof C)return n;if(!(n instanceof E))return w.VALUE;let r=(e,n)=>{if(e===void 0||e instanceof D)return n;let r=N(t.calc.scalar(e,t.frame));return r instanceof C?r:Math.trunc(r)},i=r(e[1],0),a=r(e[2],0),o=r(e[3],n.rows),s=r(e[4],n.cols);for(let e of[i,a,o,s])if(e instanceof C)return e;let[c,l,u,d]=[i,a,o,s];if(u===0||d===0)return w.REF;let f=n.top+(c??0),p=n.left+(l??0),m=f+(u??1)-1,h=p+(d??1)-1;return Math.min(f,m)<0||Math.min(p,h)<0||Math.max(f,m)>=1048576||Math.max(p,h)>=16384?w.REF:new E(n.sheet,Math.min(f,m),Math.min(p,h),Math.max(f,m),Math.max(p,h))},{volatile:!0});var $m=/^(?:(.*)!)?R(\[-?\d+\]|\d+)?C(\[-?\d+\]|\d+)?(?::R(\[-?\d+\]|\d+)?C(\[-?\d+\]|\d+)?)?$/iu,eh=(e,t)=>e===void 0?t:e.startsWith(`[`)?t+Number(e.slice(1,-1)):Number(e)-1;function th(e,t,n){let r=$m.exec(e.trim());if(!r)return;let[,i,a,o,s,c]=r,l={row:eh(a,t),col:eh(o,n)};if(l.row<0||l.col<0)return;let u=Te(l),d=i===void 0?``:`${i}!`;if(s===void 0&&c===void 0)return`${d}${u}`;let f={row:eh(s,t),col:eh(c,n)};return f.row<0||f.col<0?void 0:`${d}${u}:${Te(f)}`}I(`INDIRECT`,`v?v`,(e,t)=>{let n=P(t.calc.scalar(e[0],t.frame));if(n instanceof C)return n;let r=e[1]===void 0||Ru(t.calc.scalar(e[1],t.frame));if(r instanceof C)return r;let i=r?n:th(n,t.frame.row,t.frame.col);if(i===void 0)return w.REF;let a=Hl(i);if(!a.ok)return w.REF;let{node:o}=a;if(o.kind!==`ref`&&o.kind!==`structured`&&o.kind!==`name`&&(o.kind!==`binary`||o.op!==`:`))return w.REF;let s=t.calc.eval(o,{...t.frame,dr:0,dc:0});return s instanceof E||s instanceof it?s:w.REF},{volatile:!0});var nh=(e,t,n)=>{if(e===void 0||e instanceof D)return t+1;if(e instanceof C)return e;if(e instanceof T)return new T(e.rows,e.cols,e.data.map(e=>e instanceof C?e:w.VALUE));if(!(e instanceof E))return w.VALUE;let[r,i]=n(e);if(i<=1)return r+1;let a=Array.from({length:i},(e,t)=>r+t+1);return n===rh?new T(i,1,a):new T(1,i,a)},rh=e=>[e.top,e.bottom===1048575?Math.min(e.rows,e.sheet.lastRow-e.top+1):e.rows],ih=e=>[e.left,e.cols];I(`ROW`,`?r`,(e,t)=>nh(e[0],t.frame.row,rh)),I(`COLUMN`,`?r`,(e,t)=>nh(e[0],t.frame.col,ih)),I(`ROWS`,`r`,(e,t)=>{let n=e[0];if(n instanceof E)return n.rows;let r=L(n,t);return r instanceof C?r:r.rows}),I(`COLUMNS`,`r`,(e,t)=>{let n=e[0];if(n instanceof E)return n.cols;let r=L(n,t);return r instanceof C?r:r.cols}),I(`AREAS`,`r`,e=>{let t=e[0];return t instanceof E?1:t instanceof it?t.parts.length:w.VALUE}),F(`ADDRESS`,2,5,(e,t,n,r,i)=>{let a=N(e),o=N(t),s=n==null?1:N(n);for(let e of[a,o,s])if(e instanceof C)return e;let[c,l,u]=[a,o,s];if((c??0)<1||(l??0)<1||(c??0)>1048576||(l??0)>16384)return w.VALUE;let d=r==null||Ru(r);if(d instanceof C)return d;let f=u===1||u===2,p=u===1||u===3,m=d?`${p?`$`:``}${Ce((l??1)-1)}${f?`$`:``}${String(c)}`:`R${f?String(c):`[${String(c)}]`}C${p?String(l):`[${String(l)}]`}`;if(i==null)return m;let h=P(i);return h instanceof C?h:`${ut(h)}${m}`}),I(`TRANSPOSE`,`r`,(e,t)=>{let n=L(e[0],t);if(n instanceof C)return n;let r=[];for(let e=0;e<n.cols;e++)for(let t=0;t<n.rows;t++)r.push(n.at(t,e));return new T(n.cols,n.rows,r)}),td(`SHEET`,0,1,(e,t)=>{let n=e[0];if(n===void 0)return t.frame.sheet.index+1;let r=t.calc.eval(n,t.frame);if(r instanceof E)return r.sheet.index+1;let i=t.calc.scalar(r,t.frame);if(typeof i!=`string`)return w.NA;let a=t.calc.wb.sheet(i);return a?a.index+1:w.NA}),I(`SHEETS`,`?r`,(e,t)=>t.calc.wb.sheets.length);var ah=(e,t)=>Array.from(e,e=>{let n=t(e);return n.length===e.length?n:e}).join(``),oh=e=>ah(e,e=>e.toLowerCase());function sh(e,t){if(e===void 0||e instanceof D)return[];let n=L(e,t);if(n instanceof C)return n;let r=[];for(let e=0;e<n.rows;e++)for(let t=0;t<n.cols;t++){let i=n.at(e,t);if(i===null)continue;let a=P(i);if(a instanceof C)return a;r.push(a)}return r}function ch(e,t,n){let r=n?oh(e):e,i=(n?t.map(oh):[...t]).filter(e=>e!==``).sort((e,t)=>t.length-e.length),a=[];if(i.length===0)return a;let o=0;for(;o<e.length;){let e=i.find(e=>r.startsWith(e,o));e===void 0?o+=1:(a.push({at:o,length:e.length}),o+=e.length)}return a}function lh(e,t,n){let r=[],i=0;for(let a of ch(e,t,n))r.push(e.slice(i,a.at)),i=a.at+a.length;return r.push(e.slice(i)),r}var uh=e=>t=>{let n=P(t);return n instanceof C?n:e(n)},dh=(e,t)=>{if(e===void 0)return t;let n=N(e);return n instanceof C?n:n<0?w.VALUE:Math.trunc(n)},fh=e=>ah(e,e=>e.toUpperCase()),ph=oh;F(`LEFT`,1,2,(e,t)=>{let n=P(e),r=dh(t,1);return n instanceof C?n:r instanceof C?r:n.slice(0,r)}),F(`RIGHT`,1,2,(e,t)=>{let n=P(e),r=dh(t,1);return n instanceof C?n:r instanceof C?r:r===0?``:n.slice(-r)}),F(`MID`,3,3,(e,t,n)=>{let r=P(e),i=N(t),a=dh(n,0);if(r instanceof C)return r;if(i instanceof C)return i;if(a instanceof C)return a;if(i<1)return w.VALUE;let o=Math.trunc(i)-1;return r.slice(o,o+a)}),F(`LEN`,1,1,uh(e=>e.length)),F(`LOWER`,1,1,uh(ph)),F(`UPPER`,1,1,uh(fh)),F(`PROPER`,1,1,uh(e=>ph(e).replace(/(^|[^\p{L}])(\p{L})/gu,(e,t,n)=>`${t}${fh(n)}`))),F(`TRIM`,1,1,uh(e=>e.replace(/ +/gu,` `).replace(/^ | $/gu,``))),F(`CLEAN`,1,1,uh(e=>e.replace(/[\u0000-\u001f]/gu,``))),F(`T`,1,1,e=>typeof e==`string`?e:``),F(`EXACT`,2,2,(e,t)=>{let n=P(e),r=P(t);return n instanceof C?n:r instanceof C?r:n===r}),F(`REPT`,2,2,(e,t)=>{let n=P(e),r=dh(t,0);return n instanceof C?n:r instanceof C?r:n.length*r>32767?w.VALUE:n.repeat(r)}),F(`CHAR`,1,1,sd(e=>{let t=Math.trunc(e);return t<1||t>255?w.VALUE:hh(t)})),F(`UNICHAR`,1,1,sd(e=>{let t=Math.trunc(e);return t<1||t>1114111?w.VALUE:String.fromCodePoint(t)})),F(`CODE`,1,1,uh(e=>e===``?w.VALUE:e.charCodeAt(0))),F(`UNICODE`,1,1,uh(e=>e.codePointAt(0)??w.VALUE));var mh=`€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ`;function hh(e){return e>=128&&e<160?mh.charAt(e-128):String.fromCharCode(e)}I(`CONCAT`,`(r)`,(e,t)=>{let n=``,r;return id(e,t,e=>{if(r)return;let t=P(e);t instanceof C?r=t:n+=t}),r??n}),F(`CONCATENATE`,1,255,(...e)=>{let t=``;for(let n of e){let e=P(n);if(e instanceof C)return e;t+=e}return t}),I(`TEXTJOIN`,`rv(r)`,(e,t)=>{let[n,r,...i]=e,a=L(n??``,t);if(a instanceof C)return a;let o=[];for(let e=0;e<a.rows;e++)for(let t=0;t<a.cols;t++){let n=P(a.at(e,t));if(n instanceof C)return n;o.push(n)}let s=Ru(t.calc.scalar(r===void 0||r instanceof D||r,t.frame));if(s instanceof C)return s;let c=[],l;if(id(i,t,e=>{if(l)return;let t=P(e);t instanceof C?l=t:s&&t===``||c.push(t)}),l)return l;let u=c[0]??``;for(let e=1;e<c.length;e++)u+=`${o.length>0?o[(e-1)%o.length]??``:``}${c[e]??``}`;return u}),F(`SUBSTITUTE`,3,4,(e,t,n,r)=>{let i=P(e),a=P(t),o=P(n);if(i instanceof C)return i;if(a instanceof C)return a;if(o instanceof C)return o;if(a===``)return i;if(r===void 0)return i.split(a).join(o);let s=N(r);if(s instanceof C)return s;if(s<1)return w.VALUE;let c=-1;for(let e=0;e<Math.trunc(s);e++)if(c=i.indexOf(a,c+1),c<0)return i;return`${i.slice(0,c)}${o}${i.slice(c+a.length)}`}),F(`REPLACE`,4,4,(e,t,n,r)=>{let i=P(e),a=N(t),o=dh(n,0),s=P(r);if(i instanceof C)return i;if(a instanceof C)return a;if(o instanceof C)return o;if(s instanceof C)return s;if(a<1)return w.VALUE;let c=Math.trunc(a)-1;return`${i.slice(0,c)}${s}${i.slice(c+o)}`}),F(`FIND`,2,3,(e,t,n)=>{let r=P(e),i=P(t),a=n===void 0?1:N(n);if(r instanceof C)return r;if(i instanceof C)return i;if(a instanceof C)return a;if(a<1||a>i.length+1)return w.VALUE;let o=i.indexOf(r,Math.trunc(a)-1);return o<0?w.VALUE:o+1}),F(`SEARCH`,2,3,(e,t,n)=>{let r=P(e),i=P(t),a=n===void 0?1:N(n);if(r instanceof C)return r;if(i instanceof C)return i;if(a instanceof C)return a;if(a<1||a>i.length+1)return w.VALUE;let o=Math.trunc(a)-1,s=hd(r);if(s!==void 0){let e=i.toLowerCase(),t=s.toLowerCase();if(e.length===i.length&&t.length===s.length){let n=e.indexOf(t,o);return n<0?w.VALUE:n+1}}let c=fd(`${r}*`);for(let e=o;e<=i.length;e++)if(c(i.slice(e)))return e+1;return w.VALUE}),F(`VALUE`,1,1,e=>typeof e==`number`?e:e==null?0:typeof e==`string`?Iu(e)??w.VALUE:w.VALUE),F(`NUMBERVALUE`,1,3,(e,t,n)=>{let r=P(e),i=P(t??`.`),a=P(n??`,`);if(r instanceof C)return r;if(i instanceof C)return i;if(a instanceof C)return a;let o=r.replace(/\s/gu,``).split(a).join(``).replace(i,`.`);if(o===``)return 0;let s=/%*$/u.exec(o)?.[0].length??0,c=Number(o.slice(0,o.length-s));return Number.isNaN(c)?w.VALUE:c/100**s}),F(`TEXT`,2,2,(e,t)=>{let n=P(t);if(n instanceof C)return n;if(!ue(n))return w.VALUE;if(typeof e==`boolean`)return e?`TRUE`:`FALSE`;let r=typeof e==`string`?Iu(e)??e:e??0;if(r instanceof C)return r;try{return h(n,r)}catch{return w.VALUE}});function gh(e,t,n){let r=n?`#,##0`:`0`,i=t>0?`.${`0`.repeat(t)}`:``;return h(`${r}${i}`,e)}var _h=(e,t)=>{let n=10**t;return Math.sign(e)*Math.round(Math.abs(e)*n+1e-9)/n};F(`FIXED`,1,3,(e,t,n)=>{let r=N(e),i=t==null?2:N(t),a=n!==void 0&&Ru(n);if(r instanceof C)return r;if(i instanceof C)return i;if(a instanceof C)return a;let o=Math.trunc(i);return gh(_h(r,o),Math.max(0,o),!a)}),F(`DOLLAR`,1,2,(e,t)=>{let n=N(e),r=t==null?2:N(t);if(n instanceof C)return n;if(r instanceof C)return r;let i=Math.trunc(r),a=gh(Math.abs(_h(n,i)),Math.max(0,i),!0);return n<0?`($${a})`:`$${a}`});function vh(e,t,n,r,i){let a=ch(e,t,r);return n>0?(i&&a.push({at:e.length,length:0}),a[n-1]):(i&&a.unshift({at:0,length:0}),a[a.length+n])}function yh(e){return(t,n)=>{let[r,i,a,o,s,c]=t.map(e=>e instanceof D?void 0:e),l=P(r??null),u=sh(i,n),d=cd(a,1),f=cd(o,0),p=cd(s,0);if(l instanceof C)return l;if(u instanceof C)return u;if(d instanceof C)return d;if(f instanceof C)return f;if(p instanceof C)return p;let m=Math.trunc(d);if(m===0||Math.abs(m)>Math.max(l.length,1))return w.VALUE;if(u.length>0&&u.every(e=>e===``))return m>0==(e===`before`)?``:l;let h=vh(l,u,m,f===1,p===1);return h?e===`before`?l.slice(0,h.at):l.slice(h.at+h.length):c===void 0?w.NA:c}}I(`TEXTBEFORE`,`vr?vvvv`,yh(`before`)),I(`TEXTAFTER`,`vr?vvvv`,yh(`after`)),F(`HYPERLINK`,1,2,(e,t)=>t===void 0?e??``:t),F(`ENCODEURL`,1,1,uh(e=>encodeURIComponent(e)));for(let e of[`LEN`,`LEFT`,`RIGHT`,`MID`,`FIND`,`SEARCH`,`REPLACE`])nd(`${e}B`,e);var bh=2958465,xh=e=>{let t=N(e);return t instanceof C?t:t<0||t>=2958466?w.NUM:Math.floor(t)},Sh=e=>e%4==0&&e%100!=0||e%400==0,Ch=(e,t)=>t===2?Sh(e)?29:28:[4,6,9,11].includes(t)?30:31,wh=e=>e.month===2&&e.day===Ch(e.year,2);F(`DATE`,3,3,sd((e=0,t=1,n=1)=>{let r=Math.trunc(e);if(r<0||r>9999)return w.NUM;let i=Ie(r<1900?r+1900:r,Math.trunc(t),Math.trunc(n));return Number.isFinite(i)&&i>=0&&i<=bh?i:w.NUM})),F(`TIME`,3,3,sd((e=0,t=0,n=0)=>{let r=Math.trunc(e)*3600+Math.trunc(t)*60+Math.trunc(n);return r<0?w.NUM:r%86400/86400})),F(`YEAR`,1,1,e=>{let t=xh(e);return t instanceof C?t:Le(t).year}),F(`MONTH`,1,1,e=>{let t=xh(e);return t instanceof C?t:Le(t).month}),F(`DAY`,1,1,e=>{let t=xh(e);return t instanceof C?t:Le(t).day});var Th=e=>{let t=N(e);return t instanceof C?t:t<0?w.NUM:Math.round((t-Math.floor(t))*86400)%86400};F(`HOUR`,1,1,e=>{let t=Th(e);return t instanceof C?t:Math.floor(t/3600)}),F(`MINUTE`,1,1,e=>{let t=Th(e);return t instanceof C?t:Math.floor(t/60)%60}),F(`SECOND`,1,1,e=>{let t=Th(e);return t instanceof C?t:t%60}),F(`DATEVALUE`,1,1,e=>{let t=P(e);if(t instanceof C)return t;let n=p(t)??m(t);return typeof n?.value==`number`?Math.floor(n.value):w.VALUE}),F(`TIMEVALUE`,1,1,e=>{let t=P(e);if(t instanceof C)return t;let n=y(t)??m(t);return typeof n?.value==`number`?n.value-Math.floor(n.value):w.VALUE});var Eh=e=>(e%7+6)%7;F(`WEEKDAY`,1,2,(e,t)=>{let n=xh(e);if(n instanceof C)return n;let r=t==null?1:N(t);if(r instanceof C)return r;let i=Eh(n);return r===1?i+1:r===2?(i+6)%7+1:r===3?(i+6)%7:r>=11&&r<=17?(i+7-(r-10)%7)%7+1:w.NUM});var Dh=e=>{let t=e-(Eh(e)+6)%7+3,{year:n}=Le(t);return Math.floor((t-Ie(n,1,1))/7)+1};F(`ISOWEEKNUM`,1,1,e=>{let t=xh(e);return t instanceof C?t:Dh(t)}),F(`WEEKNUM`,1,2,(e,t)=>{let n=xh(e);if(n instanceof C)return n;let r=t==null?1:N(t);if(r instanceof C)return r;if(r===21)return Dh(n);let i=r===1?0:r===2?1:r>=11&&r<=17?(r-10)%7:-1;if(i<0)return w.NUM;let a=Ie(Le(n).year,1,1),o=(Eh(a)+7-i)%7;return Math.floor((n-a+o)/7)+1});var Oh=(e,t)=>{let{year:n,month:r,day:i}=Le(e),a=n*12+r-1+t,o=Math.floor(a/12),s=a-o*12+1;return Ie(o,s,Math.min(i,Ch(o,s)))};F(`EDATE`,2,2,(e,t)=>{let n=xh(e),r=N(t);if(n instanceof C)return n;if(r instanceof C)return r;let i=Oh(n,Math.trunc(r));return i<0?w.NUM:i}),F(`EOMONTH`,2,2,(e,t)=>{let n=xh(e),r=N(t);if(n instanceof C)return n;if(r instanceof C)return r;let i=Le(Oh(n,Math.trunc(r))),a=Ie(i.year,i.month,Ch(i.year,i.month));return a<0?w.NUM:a}),F(`DAYS`,2,2,(e,t)=>{let n=xh(e),r=xh(t);return n instanceof C?n:r instanceof C?r:n-r}),F(`DATEDIF`,3,3,(e,t,n)=>{let r=xh(e),i=xh(t),a=P(n);if(r instanceof C)return r;if(i instanceof C)return i;if(a instanceof C)return a;if(r>i)return w.NUM;let o=Le(r),s=Le(i),c=(s.year-o.year)*12+s.month-o.month-+(s.day<o.day);switch(a.toUpperCase()){case`D`:return i-r;case`M`:return c;case`Y`:return Math.floor(c/12);case`YM`:return c%12;case`MD`:{if(s.day>=o.day)return s.day-o.day;let e=s.month===1?12:s.month-1;return Ch(s.month===1?s.year-1:s.year,e)-o.day+s.day}case`YD`:{let e=s.year-o.year-+(c%12<0),t=Oh(r,Math.floor(c/12)*12);return e>=0?i-t:w.NUM}default:return w.NUM}});function kh(e,t,n){let r=Le(e),i=Le(t),a=r.day,o=i.day,s=i.month,c=i.year;return n?(a=Math.min(a,30),o=Math.min(o,30)):(a===Ch(r.year,r.month)&&(a=30),o===31&&(a<30?(o=1,s+=1,s>12&&(s=1,c+=1)):o=30)),(c-r.year)*360+(s-r.month)*30+o-a}F(`DAYS360`,2,3,(e,t,n)=>{let r=xh(e),i=xh(t),a=n!==void 0&&Ru(n);return r instanceof C?r:i instanceof C?i:a instanceof C?a:kh(r,i,a)});function Ah(e,t,n){let[r,i]=e<=t?[e,t]:[t,e],a=Le(r),o=Le(i),s=i-r;switch(n){case 0:{let e=a.day,t=o.day;return wh(a)&&(wh(o)&&(t=30),e=30),t===31&&e>=30&&(t=30),e===31&&(e=30),((o.year-a.year)*360+(o.month-a.month)*30+t-e)/360}case 2:return s/360;case 3:return s/365;case 4:return kh(r,i,!0)/360;default:{if(a.year===o.year||o.year===a.year+1&&(a.month>o.month||a.month===o.month&&a.day>=o.day)){let e;if(a.year===o.year)e=Sh(a.year);else{let t=e=>Sh(e)?Ie(e,2,29):1/0;e=t(a.year)>=r&&t(a.year)<=i||t(o.year)>=r&&t(o.year)<=i}return s/(e?366:365)}let e=o.year-a.year+1;return s/((Ie(o.year+1,1,1)-Ie(a.year,1,1))/e)}}}F(`YEARFRAC`,2,3,(e,t,n)=>{let r=xh(e),i=xh(t),a=n==null?0:N(n);if(r instanceof C)return r;if(i instanceof C)return i;if(a instanceof C)return a;let o=Math.trunc(a);return o<0||o>4?w.NUM:Ah(r,i,o)});function jh(e){let t=(...e)=>[0,1,2,3,4,5,6].map(t=>e.includes(t));if(e==null)return t(0,6);if(typeof e==`string`){if(!/^[01]{7}$/u.test(e)||e===`1111111`)return w.VALUE;let t=e.split(``).map(e=>e===`1`);return[t[6]??!1,...t.slice(0,6)]}let n=N(e);return n instanceof C?n:n>=1&&n<=7?t((n+5)%7,(n+6)%7):n>=11&&n<=17?t(n-11):w.NUM}function Mh(e,t){if(e===void 0||e instanceof D)return new Set;let n=ad([e],t);return n instanceof C?n:new Set(n.map(e=>Math.floor(e)))}function Nh(e,t,n,r){let i=e<=t?1:-1,a=0;for(let o=e;i>0?o<=t:o>=t;o+=i)n[Eh(o)]!==!0&&!r.has(o)&&(a+=i);return a}function Ph(e,t,n,r){if(n.every(Boolean))return w.VALUE;let i=t<0?-1:1,a=e;for(let e=Math.abs(t);e>0;)a+=i,n[Eh(a)]!==!0&&!r.has(a)&&--e;return a<0?w.NUM:a}var Fh=e=>(t,n)=>{let r=xh(n.calc.scalar(t[0],n.frame)),i=xh(n.calc.scalar(t[1],n.frame));if(r instanceof C)return r;if(i instanceof C)return i;let a=e?t[2]:void 0,o=jh(a===void 0||a instanceof D?void 0:n.calc.scalar(a,n.frame));if(o instanceof C)return o;let s=Mh(t[e?3:2],n);return s instanceof C?s:Nh(r,i,o,s)},Ih=e=>(t,n)=>{let r=xh(n.calc.scalar(t[0],n.frame)),i=N(n.calc.scalar(t[1],n.frame));if(r instanceof C)return r;if(i instanceof C)return i;let a=e?t[2]:void 0,o=jh(a===void 0||a instanceof D?void 0:n.calc.scalar(a,n.frame));if(o instanceof C)return o;let s=Mh(t[e?3:2],n);return s instanceof C?s:Ph(r,Math.trunc(i),o,s)};I(`NETWORKDAYS`,`vv?r`,Fh(!1)),I(`NETWORKDAYS.INTL`,`vv?vr`,Fh(!0)),I(`WORKDAY`,`vv?r`,Ih(!1)),I(`WORKDAY.INTL`,`vv?vr`,Ih(!0)),I(`NOW`,``,(e,t)=>t.calc.nowSerial(),{volatile:!0}),I(`TODAY`,``,(e,t)=>Math.floor(t.calc.nowSerial()),{volatile:!0});function Lh(e,t,n){let r=n[0]??0,i=0;return t.forEach((t,a)=>{i+=t/(1+e)**(((n[a]??r)-r)/365)}),i}var Rh=(e,t)=>{let n=[];return id([e],t,e=>n.push(e)),n},zh=(e,t)=>{let n=Rh(e[0],t),r=Rh(e[1],t);if(n.length!==r.length)return w.NUM;let i=[],a=[];for(let[e,t]of n.entries()){let n=r[e]??null;if(t instanceof C)return t;if(n instanceof C)return n;if(typeof t==`number`){if(typeof n!=`number`)return w.VALUE;i.push(t),a.push(Math.floor(n))}}return i.length===0?w.NUM:{values:i,dates:a}};I(`XNPV`,`vrr`,(e,t)=>{let n=N(t.calc.scalar(e[0],t.frame));if(n instanceof C)return n;let r=zh(e.slice(1),t);return r instanceof C?r:n<=0?w.NUM:Lh(n,r.values,r.dates)}),I(`XIRR`,`rr?v`,(e,t)=>{let n=zh(e,t);if(n instanceof C)return n;let{values:r,dates:i}=n;if(!r.some(e=>e>0)||!r.some(e=>e<0))return w.NUM;let a=e[2]===void 0||e[2]instanceof D?.1:N(t.calc.scalar(e[2],t.frame));if(a instanceof C)return a;let o=i[0]??0,s=a;for(let e=0;e<100;e++){let e=0,t=0;r.forEach((n,r)=>{let a=((i[r]??o)-o)/365;e+=n/(1+s)**a,t-=a*n/(1+s)**(a+1)});let n=s-e/t;if(!Number.isFinite(n))return w.NUM;if(Math.abs(n-s)<1e-10)return n;s=n<=-1?(s-1)/2:n}return w.NUM});var Bh=(e,t)=>{F(e,1,1,e=>t(e),{errors:!0})};Bh(`ISBLANK`,e=>e==null),Bh(`ISNUMBER`,e=>typeof e==`number`),Bh(`ISTEXT`,e=>typeof e==`string`),Bh(`ISNONTEXT`,e=>typeof e!=`string`),Bh(`ISLOGICAL`,e=>typeof e==`boolean`),Bh(`ISERROR`,e=>e instanceof C),Bh(`ISERR`,e=>e instanceof C&&e!==w.NA),Bh(`ISNA`,e=>e===w.NA);var Vh=(e,t)=>{let n=N(e);return n instanceof C?n:Math.abs(Math.trunc(n))%2===t};F(`ISEVEN`,1,1,e=>Vh(e,0)),F(`ISODD`,1,1,e=>Vh(e,1)),F(`N`,1,1,e=>typeof e==`number`?e:typeof e==`boolean`?+!!e:e instanceof C?e:0,{errors:!0}),I(`NA`,``,()=>w.NA),I(`TYPE`,`r`,(e,t)=>{let n=t.calc.flat(e[0]);return n instanceof T?64:typeof n==`number`||n===null?1:typeof n==`string`?2:typeof n==`boolean`?4:16});var Hh=[w.NULL,w.DIV0,w.VALUE,w.REF,w.NAME,w.NUM,w.NA];F(`ERROR.TYPE`,1,1,e=>{let t=e instanceof C?Hh.indexOf(e):-1;return t<0?w.NA:t+1},{errors:!0}),td(`ISREF`,1,1,(e,t)=>{let n=e[0];if(!n)return!1;let r=t.calc.eval(n,t.frame);return r instanceof E||r instanceof it});var Uh=e=>e instanceof E?e.sheet.at(e.top,e.left):void 0;td(`ISFORMULA`,1,1,(e,t)=>{let n=e[0];if(!n)return w.VALUE;let r=t.calc.eval(n,t.frame);return r instanceof at?w.VALUE:Uh(r)instanceof M}),td(`FORMULATEXT`,1,1,(e,t)=>{let n=e[0];if(!n)return w.VALUE;let r=Uh(t.calc.eval(n,t.frame));return r instanceof M?r.text:w.NA}),I(`CELL`,`v?r`,(e,t)=>{let n=P(t.calc.scalar(e[0],t.frame));if(n instanceof C)return n;let r=e[1],i=r instanceof E?r:new E(t.frame.sheet,t.frame.row,t.frame.col,t.frame.row,t.frame.col),a=()=>t.calc.read(i.sheet,i.top,i.left);switch(n.toLowerCase()){case`filename`:return`[${t.calc.wb.title??`sheet`}.xlsx]${i.sheet.name}`;case`row`:return i.top+1;case`col`:return i.left+1;case`address`:return Te({row:i.top,col:i.left}).replace(/^([A-Z]+)(\d+)$/u,`$$$1$$$2`);case`contents`:return a();case`type`:{let e=a();return e===null?`b`:typeof e==`string`?`l`:`v`}default:return w.VALUE}}),I(`TABLE`,`?rrrrr`,()=>w.NA);var Wh=n(((e,t,n)=>{(function(n,r){typeof e==`object`?t.exports=r():typeof define==`function`&&define.amd?define(r):n.jStat=r()})(n,function(){var e=function(e,t){var n=Array.prototype.concat,r=Array.prototype.slice,i=Object.prototype.toString;function a(t,n){var r=t>n?t:n;return e.pow(10,17-~~(e.log(r>0?r:-r)*e.LOG10E))}var o=Array.isArray||function(e){return i.call(e)===`[object Array]`};function s(e){return i.call(e)===`[object Function]`}function c(e){return typeof e==`number`&&e-e===0}function l(e){return n.apply([],e)}function u(){return new u._init(arguments)}u.fn=u.prototype,u._init=function(e){if(o(e[0])){if(o(e[0][0])){s(e[1])&&(e[0]=u.map(e[0],e[1]));for(var t=0;t<e[0].length;t++)this[t]=e[0][t];this.length=e[0].length}else this[0]=s(e[1])?u.map(e[0],e[1]):e[0],this.length=1}else if(c(e[0]))this[0]=u.seq.apply(null,e),this.length=1;else if(e[0]instanceof u)return u(e[0].toArray());else this[0]=[],this.length=1;return this},u._init.prototype=u.prototype,u._init.constructor=u,u.utils={calcRdx:a,isArray:o,isFunction:s,isNumber:c,toVector:l},u._random_fn=e.random,u.setRandom=function(e){if(typeof e!=`function`)throw TypeError(`fn is not a function`);u._random_fn=e},u.extend=function(e){var t,n;if(arguments.length===1){for(n in e)u[n]=e[n];return this}for(t=1;t<arguments.length;t++)for(n in arguments[t])e[n]=arguments[t][n];return e},u.rows=function(e){return e.length||1},u.cols=function(e){return e[0].length||1},u.dimensions=function(e){return{rows:u.rows(e),cols:u.cols(e)}},u.row=function(e,t){return o(t)?t.map(function(t){return u.row(e,t)}):e[t]},u.rowa=function(e,t){return u.row(e,t)},u.col=function(e,t){if(o(t)){var n=u.arange(e.length).map(function(){return Array(t.length)});return t.forEach(function(t,r){u.arange(e.length).forEach(function(i){n[i][r]=e[i][t]})}),n}for(var r=Array(e.length),i=0;i<e.length;i++)r[i]=[e[i][t]];return r},u.cola=function(e,t){return u.col(e,t).map(function(e){return e[0]})},u.diag=function(e){for(var t=u.rows(e),n=Array(t),r=0;r<t;r++)n[r]=[e[r][r]];return n},u.antidiag=function(e){for(var t=u.rows(e)-1,n=Array(t),r=0;t>=0;t--,r++)n[r]=[e[r][t]];return n},u.transpose=function(e){var t=[],n,r,i,a,s;for(o(e[0])||(e=[e]),r=e.length,i=e[0].length,s=0;s<i;s++){for(n=Array(r),a=0;a<r;a++)n[a]=e[a][s];t.push(n)}return t.length===1?t[0]:t},u.map=function(e,t,n){var r,i,a,s,c;for(o(e[0])||(e=[e]),i=e.length,a=e[0].length,s=n?e:Array(i),r=0;r<i;r++)for(s[r]||(s[r]=Array(a)),c=0;c<a;c++)s[r][c]=t(e[r][c],r,c);return s.length===1?s[0]:s},u.cumreduce=function(e,t,n){var r,i,a,s,c;for(o(e[0])||(e=[e]),i=e.length,a=e[0].length,s=n?e:Array(i),r=0;r<i;r++)for(s[r]||(s[r]=Array(a)),a>0&&(s[r][0]=e[r][0]),c=1;c<a;c++)s[r][c]=t(s[r][c-1],e[r][c]);return s.length===1?s[0]:s},u.alter=function(e,t){return u.map(e,t,!0)},u.create=function(e,t,n){var r=Array(e),i,a;for(s(t)&&(n=t,t=e),i=0;i<e;i++)for(r[i]=Array(t),a=0;a<t;a++)r[i][a]=n(i,a);return r};function d(){return 0}u.zeros=function(e,t){return c(t)||(t=e),u.create(e,t,d)};function f(){return 1}u.ones=function(e,t){return c(t)||(t=e),u.create(e,t,f)},u.rand=function(e,t){return c(t)||(t=e),u.create(e,t,u._random_fn)};function p(e,t){return+(e===t)}u.identity=function(e,t){return c(t)||(t=e),u.create(e,t,p)},u.symmetric=function(e){var t=e.length,n,r;if(e.length!==e[0].length)return!1;for(n=0;n<t;n++)for(r=0;r<t;r++)if(e[r][n]!==e[n][r])return!1;return!0},u.clear=function(e){return u.alter(e,d)},u.seq=function(e,t,n,r){s(r)||(r=!1);for(var i=[],o=a(e,t),c=(t*o-e*o)/((n-1)*o),l=e,u=0;l<=t&&u<n;u++,l=(e*o+c*o*u)/o)i.push(r?r(l,u):l);return i},u.arange=function(e,n,r){var i=[],a;if(r||=1,n===t&&(n=e,e=0),e===n||r===0||e<n&&r<0||e>n&&r>0)return[];if(r>0)for(a=e;a<n;a+=r)i.push(a);else for(a=e;a>n;a+=r)i.push(a);return i},u.slice=function(){function e(e,n,r,i){var a,o=[],s=e.length;if(n===t&&r===t&&i===t)return u.copy(e);if(n||=0,r||=e.length,n=n>=0?n:s+n,r=r>=0?r:s+r,i||=1,n===r||i===0||n<r&&i<0||n>r&&i>0)return[];if(i>0)for(a=n;a<r;a+=i)o.push(e[a]);else for(a=n;a>r;a+=i)o.push(e[a]);return o}function n(t,n){var r,i;if(n||={},c(n.row)){if(c(n.col))return t[n.row][n.col];var a=u.rowa(t,n.row);return r=n.col||{},e(a,r.start,r.end,r.step)}if(c(n.col)){var o=u.cola(t,n.col);return i=n.row||{},e(o,i.start,i.end,i.step)}return i=n.row||{},r=n.col||{},e(t,i.start,i.end,i.step).map(function(t){return e(t,r.start,r.end,r.step)})}return n}(),u.sliceAssign=function(n,r,i){var a,o;if(c(r.row)){if(c(r.col))return n[r.row][r.col]=i;r.col=r.col||{},r.col.start=r.col.start||0,r.col.end=r.col.end||n[0].length,r.col.step=r.col.step||1,a=u.arange(r.col.start,e.min(n.length,r.col.end),r.col.step);var s=r.row;return a.forEach(function(e,t){n[s][e]=i[t]}),n}if(c(r.col)){r.row=r.row||{},r.row.start=r.row.start||0,r.row.end=r.row.end||n.length,r.row.step=r.row.step||1,o=u.arange(r.row.start,e.min(n[0].length,r.row.end),r.row.step);var l=r.col;return o.forEach(function(e,t){n[e][l]=i[t]}),n}return i[0].length===t&&(i=[i]),r.row.start=r.row.start||0,r.row.end=r.row.end||n.length,r.row.step=r.row.step||1,r.col.start=r.col.start||0,r.col.end=r.col.end||n[0].length,r.col.step=r.col.step||1,o=u.arange(r.row.start,e.min(n.length,r.row.end),r.row.step),a=u.arange(r.col.start,e.min(n[0].length,r.col.end),r.col.step),o.forEach(function(e,t){a.forEach(function(r,a){n[e][r]=i[t][a]})}),n},u.diagonal=function(e){var t=u.zeros(e.length,e.length);return e.forEach(function(e,n){t[n][n]=e}),t},u.copy=function(e){return e.map(function(e){return c(e)?e:e.map(function(e){return e})})};var m=u.prototype;return m.length=0,m.push=Array.prototype.push,m.sort=Array.prototype.sort,m.splice=Array.prototype.splice,m.slice=Array.prototype.slice,m.toArray=function(){return this.length>1?r.call(this):r.call(this)[0]},m.map=function(e,t){return u(u.map(this,e,t))},m.cumreduce=function(e,t){return u(u.cumreduce(this,e,t))},m.alter=function(e){return u.alter(this,e),this},(function(e){for(var t=0;t<e.length;t++)(function(e){m[e]=function(t){var n=this,r;return t?(setTimeout(function(){t.call(n,m[e].call(n))}),this):(r=u[e](this),o(r)?u(r):r)}})(e[t])})(`transpose clear symmetric rows cols dimensions diag antidiag`.split(` `)),(function(e){for(var t=0;t<e.length;t++)(function(e){m[e]=function(t,n){var r=this;return n?(setTimeout(function(){n.call(r,m[e].call(r,t))}),this):u(u[e](this,t))}})(e[t])})(`row col`.split(` `)),(function(e){for(var t=0;t<e.length;t++)(function(e){m[e]=function(){return u(u[e].apply(null,arguments))}})(e[t])})(`create zeros ones rand identity`.split(` `)),u}(Math);return(function(e,t){var n=e.utils.isFunction;function r(e,t){return e-t}function i(e,n,r){return t.max(n,t.min(e,r))}e.sum=function(e){for(var t=0,n=e.length;--n>=0;)t+=e[n];return t},e.sumsqrd=function(e){for(var t=0,n=e.length;--n>=0;)t+=e[n]*e[n];return t},e.sumsqerr=function(t){for(var n=e.mean(t),r=0,i=t.length,a;--i>=0;)a=t[i]-n,r+=a*a;return r},e.sumrow=function(e){for(var t=0,n=e.length;--n>=0;)t+=e[n];return t},e.product=function(e){for(var t=1,n=e.length;--n>=0;)t*=e[n];return t},e.min=function(e){for(var t=e[0],n=0;++n<e.length;)e[n]<t&&(t=e[n]);return t},e.max=function(e){for(var t=e[0],n=0;++n<e.length;)e[n]>t&&(t=e[n]);return t},e.unique=function(e){for(var t={},n=[],r=0;r<e.length;r++)t[e[r]]||(t[e[r]]=!0,n.push(e[r]));return n},e.mean=function(t){return e.sum(t)/t.length},e.meansqerr=function(t){return e.sumsqerr(t)/t.length},e.geomean=function(n){var r=n.map(t.log),i=e.mean(r);return t.exp(i)},e.median=function(e){var t=e.length,n=e.slice().sort(r);return t&1?n[t/2|0]:(n[t/2-1]+n[t/2])/2},e.cumsum=function(t){return e.cumreduce(t,function(e,t){return e+t})},e.cumprod=function(t){return e.cumreduce(t,function(e,t){return e*t})},e.diff=function(e){for(var t=[],n=e.length,r=1;r<n;r++)t.push(e[r]-e[r-1]);return t},e.rank=function(e){var t,n=[],i={};for(t=0;t<e.length;t++){var a=e[t];i[a]?i[a]++:(i[a]=1,n.push(a))}var o=n.sort(r),s={},c=1;for(t=0;t<o.length;t++){var a=o[t],l=i[a];s[a]=(c+(c+l-1))/2,c+=l}return e.map(function(e){return s[e]})},e.mode=function(e){for(var t=e.length,n=e.slice().sort(r),i=1,a=0,o=0,s=[],c=0;c<t;c++)n[c]===n[c+1]?i++:(i>a?(s=[n[c]],a=i,o=0):i===a&&(s.push(n[c]),o++),i=1);return o===0?s[0]:s},e.range=function(t){return e.max(t)-e.min(t)},e.variance=function(t,n){return e.sumsqerr(t)/(t.length-+!!n)},e.pooledvariance=function(t){return t.reduce(function(t,n){return t+e.sumsqerr(n)},0)/(t.reduce(function(e,t){return e+t.length},0)-t.length)},e.deviation=function(t){for(var n=e.mean(t),r=t.length,i=Array(r),a=0;a<r;a++)i[a]=t[a]-n;return i},e.stdev=function(n,r){return t.sqrt(e.variance(n,r))},e.pooledstdev=function(n){return t.sqrt(e.pooledvariance(n))},e.meandev=function(n){for(var r=e.mean(n),i=[],a=n.length-1;a>=0;a--)i.push(t.abs(n[a]-r));return e.mean(i)},e.meddev=function(n){for(var r=e.median(n),i=[],a=n.length-1;a>=0;a--)i.push(t.abs(n[a]-r));return e.median(i)},e.coeffvar=function(t){return e.stdev(t)/e.mean(t)},e.quartiles=function(e){var n=e.length,i=e.slice().sort(r);return[i[t.round(n/4)-1],i[t.round(n/2)-1],i[t.round(n*3/4)-1]]},e.quantiles=function(e,n,a,o){var s=e.slice().sort(r),c=[n.length],l=e.length,u,d,f,p,m,h;for(a===void 0&&(a=3/8),o===void 0&&(o=3/8),u=0;u<n.length;u++)d=n[u],f=a+d*(1-a-o),p=l*d+f,m=t.floor(i(p,1,l-1)),h=i(p-m,0,1),c[u]=(1-h)*s[m-1]+h*s[m];return c},e.percentile=function(e,t,n){var i=e.slice().sort(r),a=t*(i.length+(n?1:-1))+ +!n,o=parseInt(a),s=a-o;return o+1<i.length?i[o-1]+s*(i[o]-i[o-1]):i[o-1]},e.percentileOfScore=function(e,t,n){var r=0,i=e.length,a=!1,o,s;for(n===`strict`&&(a=!0),s=0;s<i;s++)o=e[s],(a&&o<t||!a&&o<=t)&&r++;return r/i},e.histogram=function(n,r){r||=4;for(var i=e.min(n),a=(e.max(n)-i)/r,o=n.length,s=[],c=0;c<r;c++)s[c]=0;for(c=0;c<o;c++)s[t.min(t.floor((n[c]-i)/a),r-1)]+=1;return s},e.covariance=function(t,n){for(var r=e.mean(t),i=e.mean(n),a=t.length,o=Array(a),s=0;s<a;s++)o[s]=(t[s]-r)*(n[s]-i);return e.sum(o)/(a-1)},e.corrcoeff=function(t,n){return e.covariance(t,n)/e.stdev(t,1)/e.stdev(n,1)},e.spearmancoeff=function(t,n){return t=e.rank(t),n=e.rank(n),e.corrcoeff(t,n)},e.stanMoment=function(n,r){for(var i=e.mean(n),a=e.stdev(n),o=n.length,s=0,c=0;c<o;c++)s+=t.pow((n[c]-i)/a,r);return s/n.length},e.skewness=function(t){return e.stanMoment(t,3)},e.kurtosis=function(t){return e.stanMoment(t,4)-3};var a=e.prototype;(function(t){for(var r=0;r<t.length;r++)(function(t){a[t]=function(r,i){var o=[],s=0,c=this;if(n(r)&&(i=r,r=!1),i)return setTimeout(function(){i.call(c,a[t].call(c,r))}),this;if(this.length>1){for(c=r===!0?this:this.transpose();s<c.length;s++)o[s]=e[t](c[s]);return o}return e[t](this[0],r)}})(t[r])})(`cumsum cumprod`.split(` `)),(function(t){for(var r=0;r<t.length;r++)(function(t){a[t]=function(r,i){var o=[],s=0,c=this;if(n(r)&&(i=r,r=!1),i)return setTimeout(function(){i.call(c,a[t].call(c,r))}),this;if(this.length>1){for(t!==`sumrow`&&(c=r===!0?this:this.transpose());s<c.length;s++)o[s]=e[t](c[s]);return r===!0?e[t](e.utils.toVector(o)):o}return e[t](this[0],r)}})(t[r])})(`sum sumsqrd sumsqerr sumrow product min max unique mean meansqerr geomean median diff rank mode range variance deviation stdev meandev meddev coeffvar quartiles histogram skewness kurtosis`.split(` `)),(function(t){for(var r=0;r<t.length;r++)(function(t){a[t]=function(){var r=[],i=0,o=this,s=Array.prototype.slice.call(arguments),c;if(n(s[s.length-1])){c=s[s.length-1];var l=s.slice(0,s.length-1);return setTimeout(function(){c.call(o,a[t].apply(o,l))}),this}c=void 0;var u=function(n){return e[t].apply(o,[n].concat(s))};if(this.length>1){for(o=o.transpose();i<o.length;i++)r[i]=u(o[i]);return r}return u(this[0])}})(t[r])})(`quantiles percentileOfScore`.split(` `))})(e,Math),(function(e,t){e.gammaln=function(e){var n=0,r=[76.18009172947146,-86.50532032941678,24.01409824083091,-1.231739572450155,.001208650973866179,-5395239384953e-18],i=1.000000000190015,a,o,s=(o=a=e)+5.5;for(s-=(a+.5)*t.log(s);n<6;n++)i+=r[n]/++o;return t.log(2.5066282746310007*i/a)-s},e.loggam=function(e){var n,r,i,a,o,s,c,l=[.08333333333333333,-.002777777777777778,.0007936507936507937,-.0005952380952380952,.0008417508417508418,-.001917526917526918,.00641025641025641,-.02955065359477124,.1796443723688307,-1.3924322169059];if(n=e,c=0,e==1||e==2)return 0;for(e<=7&&(c=t.floor(7-e),n=e+c),r=1/(n*n),i=2*t.PI,o=l[9],s=8;s>=0;s--)o*=r,o+=l[s];if(a=o/n+.5*t.log(i)+(n-.5)*t.log(n)-n,e<=7)for(s=1;s<=c;s++)a-=t.log(n-1),--n;return a},e.gammafn=function(e){var n=[-1.716185138865495,24.76565080557592,-379.80425647094563,629.3311553128184,866.9662027904133,-31451.272968848367,-36144.413418691176,66456.14382024054],r=[-30.8402300119739,315.35062697960416,-1015.1563674902192,-3107.771671572311,22538.11842098015,4755.846277527881,-134659.9598649693,-115132.2596755535],i=!1,a=0,o=0,s=0,c=e,l,u,d,f;if(e>171.6243769536076)return 1/0;if(c<=0){if(f=c%1+36e-17,f)i=(c&1?-1:1)*t.PI/t.sin(t.PI*f),c=1-c;else return 1/0}for(d=c,u=c<1?c++:(c-=a=(c|0)-1)-1,l=0;l<8;++l)s=(s+n[l])*u,o=o*u+r[l];if(f=s/o+1,d<c)f/=d;else if(d>c)for(l=0;l<a;++l)f*=c,c++;return i&&(f=i/f),f},e.gammap=function(t,n){return e.lowRegGamma(t,n)*e.gammafn(t)},e.lowRegGamma=function(n,r){var i=e.gammaln(n),a=n,o=1/n,s=o,c=r+1-n,l=1/1e-30,u=1/c,d=u,f=1,p=-~(t.log(n>=1?n:1/n)*8.5+n*.4+17),m;if(r<0||n<=0)return NaN;if(r<n+1){for(;f<=p;f++)o+=s*=r/++a;return o*t.exp(-r+n*t.log(r)-i)}for(;f<=p;f++)m=-f*(f-n),c+=2,u=m*u+c,l=c+m/l,u=1/u,d*=u*l;return 1-d*t.exp(-r+n*t.log(r)-i)},e.factorialln=function(t){return t<0?NaN:e.gammaln(t+1)},e.factorial=function(t){return t<0?NaN:e.gammafn(t+1)},e.combination=function(n,r){return n>170||r>170?t.exp(e.combinationln(n,r)):e.factorial(n)/e.factorial(r)/e.factorial(n-r)},e.combinationln=function(t,n){return e.factorialln(t)-e.factorialln(n)-e.factorialln(t-n)},e.permutation=function(t,n){return e.factorial(t)/e.factorial(t-n)},e.betafn=function(n,r){if(!(n<=0||r<=0))return n+r>170?t.exp(e.betaln(n,r)):e.gammafn(n)*e.gammafn(r)/e.gammafn(n+r)},e.betaln=function(t,n){return e.gammaln(t)+e.gammaln(n)-e.gammaln(t+n)},e.betacf=function(e,n,r){var i=1e-30,a=1,o=n+r,s=n+1,c=n-1,l=1,u=1-o*e/s,d,f,p,m;for(t.abs(u)<i&&(u=i),u=1/u,m=u;a<=100&&(d=2*a,f=a*(r-a)*e/((c+d)*(n+d)),u=1+f*u,t.abs(u)<i&&(u=i),l=1+f/l,t.abs(l)<i&&(l=i),u=1/u,m*=u*l,f=-(n+a)*(o+a)*e/((n+d)*(s+d)),u=1+f*u,t.abs(u)<i&&(u=i),l=1+f/l,t.abs(l)<i&&(l=i),u=1/u,p=u*l,m*=p,!(t.abs(p-1)<3e-7));a++);return m},e.gammapinv=function(n,r){var i=0,a=r-1,o=1e-8,s=e.gammaln(r),c,l,u,d,f,p,m;if(n>=1)return t.max(100,r+100*t.sqrt(r));if(n<=0)return 0;for(r>1?(p=t.log(a),m=t.exp(a*(p-1)-s),f=n<.5?n:1-n,u=t.sqrt(-2*t.log(f)),c=(2.30753+u*.27061)/(1+u*(.99229+u*.04481))-u,n<.5&&(c=-c),c=t.max(.001,r*t.pow(1-1/(9*r)-c/(3*t.sqrt(r)),3))):(u=1-r*(.253+r*.12),c=n<u?t.pow(n/u,1/r):1-t.log(1-(n-u)/(1-u)));i<12;i++){if(c<=0)return 0;if(l=e.lowRegGamma(r,c)-n,u=r>1?m*t.exp(-(c-a)+a*(t.log(c)-p)):t.exp(-c+a*t.log(c)-s),d=l/u,c-=u=d/(1-.5*t.min(1,d*((r-1)/c-1))),c<=0&&(c=.5*(c+u)),t.abs(u)<o*c)break}return c},e.erf=function(e){var n=[-1.3026537197817094,.6419697923564902,.019476473204185836,-.00956151478680863,-.000946595344482036,.000366839497852761,42523324806907e-18,-20278578112534e-18,-1624290004647e-18,130365583558e-17,1.5626441722e-8,-8.5238095915e-8,6.529054439e-9,5.059343495e-9,-991364156e-18,-227365122e-18,96467911e-18,2394038e-18,-6886027e-18,894487e-18,313092e-18,-112708e-18,381e-18,7106e-18,-1523e-18,-94e-18,121e-18,-28e-18],r=n.length-1,i=!1,a=0,o=0,s,c,l,u;for(e<0&&(e=-e,i=!0),s=2/(2+e),c=4*s-2;r>0;r--)l=a,a=c*a-o+n[r],o=l;return u=s*t.exp(-e*e+.5*(n[0]+c*a)-o),i?u-1:1-u},e.erfc=function(t){return 1-e.erf(t)},e.erfcinv=function(n){var r=0,i,a,o,s;if(n>=2)return-100;if(n<=0)return 100;for(s=n<1?n:2-n,o=t.sqrt(-2*t.log(s/2)),i=-.70711*((2.30753+o*.27061)/(1+o*(.99229+o*.04481))-o);r<2;r++)a=e.erfc(i)-s,i+=a/(1.1283791670955126*t.exp(-i*i)-i*a);return n<1?i:-i},e.ibetainv=function(n,r,i){var a=1e-8,o=r-1,s=i-1,c=0,l,u,d,f,p,m,h,g,_,v,ee;if(n<=0)return 0;if(n>=1)return 1;for(r>=1&&i>=1?(d=n<.5?n:1-n,f=t.sqrt(-2*t.log(d)),h=(2.30753+f*.27061)/(1+f*(.99229+f*.04481))-f,n<.5&&(h=-h),g=(h*h-3)/6,_=2/(1/(2*r-1)+1/(2*i-1)),v=h*t.sqrt(g+_)/_-(1/(2*i-1)-1/(2*r-1))*(g+5/6-2/(3*_)),h=r/(r+i*t.exp(2*v))):(l=t.log(r/(r+i)),u=t.log(i/(r+i)),f=t.exp(r*l)/r,p=t.exp(i*u)/i,v=f+p,h=n<f/v?t.pow(r*v*n,1/r):1-t.pow(i*v*(1-n),1/i)),ee=-e.gammaln(r)-e.gammaln(i)+e.gammaln(r+i);c<10;c++){if(h===0||h===1)return h;if(m=e.ibeta(h,r,i)-n,f=t.exp(o*t.log(h)+s*t.log(1-h)+ee),p=m/f,h-=f=p/(1-.5*t.min(1,p*(o/h-s/(1-h)))),h<=0&&(h=.5*(h+f)),h>=1&&(h=.5*(h+f+1)),t.abs(f)<a*h&&c>0)break}return h},e.ibeta=function(n,r,i){var a=n===0||n===1?0:t.exp(e.gammaln(r+i)-e.gammaln(r)-e.gammaln(i)+r*t.log(n)+i*t.log(1-n));return n<0||n>1?!1:n<(r+1)/(r+i+2)?a*e.betacf(n,r,i)/r:1-a*e.betacf(1-n,i,r)/i},e.randn=function(n,r){var i,a,o,s,c;if(r||=n,n)return e.create(n,r,function(){return e.randn()});do i=e._random_fn(),a=1.7156*(e._random_fn()-.5),o=i-.449871,s=t.abs(a)+.386595,c=o*o+s*(.196*s-.25472*o);while(c>.27597&&(c>.27846||a*a>-4*t.log(i)*i*i));return a/i},e.randg=function(n,r,i){var a=n,o,s,c,l,u,d;if(i||=r,n||=1,r)return d=e.zeros(r,i),d.alter(function(){return e.randg(n)}),d;n<1&&(n+=1),o=n-1/3,s=1/t.sqrt(9*o);do{do u=e.randn(),l=1+s*u;while(l<=0);l=l*l*l,c=e._random_fn()}while(c>1-.331*t.pow(u,4)&&t.log(c)>.5*u*u+o*(1-l+t.log(l)));if(n==a)return o*l;do c=e._random_fn();while(c===0);return t.pow(c,1/a)*o*l},(function(t){for(var n=0;n<t.length;n++)(function(t){e.fn[t]=function(){return e(e.map(this,function(n){return e[t](n)}))}})(t[n])})(`gammaln gammafn factorial factorialln`.split(` `)),(function(t){for(var n=0;n<t.length;n++)(function(t){e.fn[t]=function(){return e(e[t].apply(null,arguments))}})(t[n])})(`randn`.split(` `))})(e,Math),(function(e,t){(function(t){for(var n=0;n<t.length;n++)(function(t){e[t]=function e(t,n,r){return this instanceof e?(this._a=t,this._b=n,this._c=r,this):new e(t,n,r)},e.fn[t]=function(n,r,i){var a=e[t](n,r,i);return a.data=this,a},e[t].prototype.sample=function(n){var r=this._a,i=this._b,a=this._c;return n?e.alter(n,function(){return e[t].sample(r,i,a)}):e[t].sample(r,i,a)},(function(n){for(var r=0;r<n.length;r++)(function(n){e[t].prototype[n]=function(r){var i=this._a,a=this._b,o=this._c;return!r&&r!==0&&(r=this.data),typeof r==`number`?e[t][n](r,i,a,o):e.fn.map.call(r,function(r){return e[t][n](r,i,a,o)})}})(n[r])})(`pdf cdf inv`.split(` `)),(function(n){for(var r=0;r<n.length;r++)(function(n){e[t].prototype[n]=function(){return e[t][n](this._a,this._b,this._c)}})(n[r])})(`mean median mode variance`.split(` `))})(t[n])})(`beta centralF cauchy chisquare exponential gamma invgamma kumaraswamy laplace lognormal noncentralt normal pareto studentt weibull uniform binomial negbin hypgeom poisson triangular tukey arcsine`.split(` `)),e.extend(e.beta,{pdf:function(n,r,i){return n>1||n<0?0:r==1&&i==1?1:r<512&&i<512?t.pow(n,r-1)*t.pow(1-n,i-1)/e.betafn(r,i):t.exp((r-1)*t.log(n)+(i-1)*t.log(1-n)-e.betaln(r,i))},cdf:function(t,n,r){return t>1||t<0?(t>1)*1:e.ibeta(t,n,r)},inv:function(t,n,r){return e.ibetainv(t,n,r)},mean:function(e,t){return e/(e+t)},median:function(t,n){return e.ibetainv(.5,t,n)},mode:function(e,t){return(e-1)/(e+t-2)},sample:function(t,n){var r=e.randg(t);return r/(r+e.randg(n))},variance:function(e,n){return e*n/(t.pow(e+n,2)*(e+n+1))}}),e.extend(e.centralF,{pdf:function(n,r,i){var a,o,s;return n<0?0:r<=2?n===0&&r<2?1/0:n===0&&r===2?1:1/e.betafn(r/2,i/2)*t.pow(r/i,r/2)*t.pow(n,r/2-1)*t.pow(1+r/i*n,-(r+i)/2):(a=r*n/(i+n*r),o=i/(i+n*r),s=r*o/2,s*e.binomial.pdf((r-2)/2,(r+i-2)/2,a))},cdf:function(t,n,r){return t<0?0:e.ibeta(n*t/(n*t+r),n/2,r/2)},inv:function(t,n,r){return r/(n*(1/e.ibetainv(t,n/2,r/2)-1))},mean:function(e,t){return t>2?t/(t-2):void 0},mode:function(e,t){return e>2?t*(e-2)/(e*(t+2)):void 0},sample:function(t,n){var r=e.randg(t/2)*2,i=e.randg(n/2)*2;return r/t/(i/n)},variance:function(e,t){if(!(t<=4))return 2*t*t*(e+t-2)/(e*(t-2)*(t-2)*(t-4))}}),e.extend(e.cauchy,{pdf:function(e,n,r){return r<0?0:r/(t.pow(e-n,2)+t.pow(r,2))/t.PI},cdf:function(e,n,r){return t.atan((e-n)/r)/t.PI+.5},inv:function(e,n,r){return n+r*t.tan(t.PI*(e-.5))},median:function(e){return e},mode:function(e){return e},sample:function(n,r){return e.randn()*t.sqrt(1/(2*e.randg(.5)))*r+n}}),e.extend(e.chisquare,{pdf:function(n,r){return n<0?0:n===0&&r===2?.5:t.exp((r/2-1)*t.log(n)-n/2-r/2*t.log(2)-e.gammaln(r/2))},cdf:function(t,n){return t<0?0:e.lowRegGamma(n/2,t/2)},inv:function(t,n){return 2*e.gammapinv(t,.5*n)},mean:function(e){return e},median:function(e){return e*t.pow(1-2/(9*e),3)},mode:function(e){return e-2>0?e-2:0},sample:function(t){return e.randg(t/2)*2},variance:function(e){return 2*e}}),e.extend(e.exponential,{pdf:function(e,n){return e<0?0:n*t.exp(-n*e)},cdf:function(e,n){return e<0?0:1-t.exp(-n*e)},inv:function(e,n){return-t.log(1-e)/n},mean:function(e){return 1/e},median:function(e){return 1/e*t.log(2)},mode:function(){return 0},sample:function(n){return-1/n*t.log(e._random_fn())},variance:function(e){return t.pow(e,-2)}}),e.extend(e.gamma,{pdf:function(n,r,i){return n<0?0:n===0&&r===1?1/i:t.exp((r-1)*t.log(n)-n/i-e.gammaln(r)-r*t.log(i))},cdf:function(t,n,r){return t<0?0:e.lowRegGamma(n,t/r)},inv:function(t,n,r){return e.gammapinv(t,n)*r},mean:function(e,t){return e*t},mode:function(e,t){if(e>1)return(e-1)*t},sample:function(t,n){return e.randg(t)*n},variance:function(e,t){return e*t*t}}),e.extend(e.invgamma,{pdf:function(n,r,i){return n<=0?0:t.exp(-(r+1)*t.log(n)-i/n-e.gammaln(r)+r*t.log(i))},cdf:function(t,n,r){return t<=0?0:1-e.lowRegGamma(n,r/t)},inv:function(t,n,r){return r/e.gammapinv(1-t,n)},mean:function(e,t){return e>1?t/(e-1):void 0},mode:function(e,t){return t/(e+1)},sample:function(t,n){return n/e.randg(t)},variance:function(e,t){if(!(e<=2))return t*t/((e-1)*(e-1)*(e-2))}}),e.extend(e.kumaraswamy,{pdf:function(e,n,r){return e===0&&n===1?r:e===1&&r===1?n:t.exp(t.log(n)+t.log(r)+(n-1)*t.log(e)+(r-1)*t.log(1-t.pow(e,n)))},cdf:function(e,n,r){return e<0?0:e>1?1:1-t.pow(1-t.pow(e,n),r)},inv:function(e,n,r){return t.pow(1-t.pow(1-e,1/r),1/n)},mean:function(t,n){return n*e.gammafn(1+1/t)*e.gammafn(n)/e.gammafn(1+1/t+n)},median:function(e,n){return t.pow(1-t.pow(2,-1/n),1/e)},mode:function(e,n){if(e>=1&&n>=1&&e!==1&&n!==1)return t.pow((e-1)/(e*n-1),1/e)},variance:function(){throw Error(`variance not yet implemented`)}}),e.extend(e.lognormal,{pdf:function(e,n,r){return e<=0?0:t.exp(-t.log(e)-.5*t.log(2*t.PI)-t.log(r)-t.pow(t.log(e)-n,2)/(2*r*r))},cdf:function(n,r,i){return n<0?0:.5+.5*e.erf((t.log(n)-r)/t.sqrt(2*i*i))},inv:function(n,r,i){return t.exp(-1.4142135623730951*i*e.erfcinv(2*n)+r)},mean:function(e,n){return t.exp(e+n*n/2)},median:function(e){return t.exp(e)},mode:function(e,n){return t.exp(e-n*n)},sample:function(n,r){return t.exp(e.randn()*r+n)},variance:function(e,n){return(t.exp(n*n)-1)*t.exp(2*e+n*n)}}),e.extend(e.noncentralt,{pdf:function(n,r,i){var a=1e-14;return t.abs(i)<a?e.studentt.pdf(n,r):t.abs(n)<a?t.exp(e.gammaln((r+1)/2)-i*i/2-.5*t.log(t.PI*r)-e.gammaln(r/2)):r/n*(e.noncentralt.cdf(n*t.sqrt(1+2/r),r+2,i)-e.noncentralt.cdf(n,r,i))},cdf:function(n,r,i){var a=1e-14,o=200;if(t.abs(i)<a)return e.studentt.cdf(n,r);var s=!1;n<0&&(s=!0,i=-i);for(var c=e.normal.cdf(-i,0,1),l=a+1,u=l,d=n*n/(n*n+r),f=0,p=t.exp(-i*i/2),m=t.exp(-i*i/2-.5*t.log(2)-e.gammaln(3/2))*i;f<o||u>a||l>a;)u=l,f>0&&(p*=i*i/(2*f),m*=i*i/(2*(f+1/2))),l=p*e.beta.cdf(d,f+.5,r/2)+m*e.beta.cdf(d,f+1,r/2),c+=.5*l,f++;return s?1-c:c}}),e.extend(e.normal,{pdf:function(e,n,r){return t.exp(-.5*t.log(2*t.PI)-t.log(r)-t.pow(e-n,2)/(2*r*r))},cdf:function(n,r,i){return .5*(1+e.erf((n-r)/t.sqrt(2*i*i)))},inv:function(t,n,r){return-1.4142135623730951*r*e.erfcinv(2*t)+n},mean:function(e){return e},median:function(e){return e},mode:function(e){return e},sample:function(t,n){return e.randn()*n+t},variance:function(e,t){return t*t}}),e.extend(e.pareto,{pdf:function(e,n,r){return e<n?0:r*t.pow(n,r)/t.pow(e,r+1)},cdf:function(e,n,r){return e<n?0:1-t.pow(n/e,r)},inv:function(e,n,r){return n/t.pow(1-e,1/r)},mean:function(e,n){if(!(n<=1))return n*t.pow(e,n)/(n-1)},median:function(e,n){return e*(n*t.SQRT2)},mode:function(e){return e},variance:function(e,n){if(!(n<=2))return e*e*n/(t.pow(n-1,2)*(n-2))}}),e.extend(e.studentt,{pdf:function(n,r){return r=r>1e100?1e100:r,1/(t.sqrt(r)*e.betafn(.5,r/2))*t.pow(1+n*n/r,-((r+1)/2))},cdf:function(n,r){var i=r/2;return e.ibeta((n+t.sqrt(n*n+r))/(2*t.sqrt(n*n+r)),i,i)},inv:function(n,r){var i=e.ibetainv(2*t.min(n,1-n),.5*r,.5);return i=t.sqrt(r*(1-i)/i),n>.5?i:-i},mean:function(e){return e>1?0:void 0},median:function(){return 0},mode:function(){return 0},sample:function(n){return e.randn()*t.sqrt(n/(2*e.randg(n/2)))},variance:function(e){return e>2?e/(e-2):e>1?1/0:void 0}}),e.extend(e.weibull,{pdf:function(e,n,r){return e<0||n<0||r<0?0:r/n*t.pow(e/n,r-1)*t.exp(-t.pow(e/n,r))},cdf:function(e,n,r){return e<0?0:1-t.exp(-t.pow(e/n,r))},inv:function(e,n,r){return n*t.pow(-t.log(1-e),1/r)},mean:function(t,n){return t*e.gammafn(1+1/n)},median:function(e,n){return e*t.pow(t.log(2),1/n)},mode:function(e,n){return n<=1?0:e*t.pow((n-1)/n,1/n)},sample:function(n,r){return n*t.pow(-t.log(e._random_fn()),1/r)},variance:function(n,r){return n*n*e.gammafn(1+2/r)-t.pow(e.weibull.mean(n,r),2)}}),e.extend(e.uniform,{pdf:function(e,t,n){return e<t||e>n?0:1/(n-t)},cdf:function(e,t,n){return e<t?0:e<n?(e-t)/(n-t):1},inv:function(e,t,n){return t+e*(n-t)},mean:function(e,t){return .5*(e+t)},median:function(t,n){return e.mean(t,n)},mode:function(){throw Error(`mode is not yet implemented`)},sample:function(t,n){return t/2+n/2+(n/2-t/2)*(2*e._random_fn()-1)},variance:function(e,n){return t.pow(n-e,2)/12}});function n(e,n,r,i){for(var a=0,o=1,s=1,c=1,l=0,u=0,d;t.abs((s-u)/s)>i;)u=s,d=-(n+l)*(n+r+l)*e/(n+2*l)/(n+2*l+1),a=s+d*a,o=c+d*o,l+=1,d=l*(r-l)*e/(n+2*l-1)/(n+2*l),s=a+d*s,c=o+d*c,a/=c,o/=c,s/=c,c=1;return s/n}e.extend(e.binomial,{pdf:function(n,r,i){return i===0||i===1?+(r*i===n):e.combination(r,n)*t.pow(i,n)*t.pow(1-i,r-n)},cdf:function(r,i,a){var o,s=1e-10;if(r<0)return 0;if(r>=i)return 1;if(a<0||a>1||i<=0)return NaN;r=t.floor(r);var c=a,l=r+1,u=i-r,d=l+u,f=t.exp(e.gammaln(d)-e.gammaln(u)-e.gammaln(l)+l*t.log(c)+u*t.log(1-c));return o=c<(l+1)/(d+2)?f*n(c,l,u,s):1-f*n(1-c,u,l,s),t.round((1-o)*(1/s))/(1/s)}}),e.extend(e.negbin,{pdf:function(n,r,i){return n===n>>>0?n<0?0:e.combination(n+r-1,r-1)*t.pow(1-i,n)*t.pow(i,r):!1},cdf:function(t,n,r){var i=0,a=0;if(t<0)return 0;for(;a<=t;a++)i+=e.negbin.pdf(a,n,r);return i}}),e.extend(e.hypgeom,{pdf:function(n,r,i,a){if(n!==n|0)return!1;if(n<0||n<i-(r-a)||n>a||n>i)return 0;if(i*2>r)return a*2>r?e.hypgeom.pdf(r-i-a+n,r,r-i,r-a):e.hypgeom.pdf(a-n,r,r-i,a);if(a*2>r)return e.hypgeom.pdf(i-n,r,i,r-a);if(i<a)return e.hypgeom.pdf(n,r,a,i);for(var o=1,s=0,c=0;c<n;c++){for(;o>1&&s<a;)o*=1-i/(r-s),s++;o*=(a-c)*(i-c)/((c+1)*(r-i-a+c+1))}for(;s<a;s++)o*=1-i/(r-s);return t.min(1,t.max(0,o))},cdf:function(n,r,i,a){if(n<0||n<i-(r-a))return 0;if(n>=a||n>=i)return 1;if(i*2>r)return a*2>r?e.hypgeom.cdf(r-i-a+n,r,r-i,r-a):1-e.hypgeom.cdf(a-n-1,r,r-i,a);if(a*2>r)return 1-e.hypgeom.cdf(i-n-1,r,i,r-a);if(i<a)return e.hypgeom.cdf(n,r,a,i);for(var o=1,s=1,c=0,l=0;l<n;l++){for(;o>1&&c<a;){var u=1-i/(r-c);s*=u,o*=u,c++}s*=(a-l)*(i-l)/((l+1)*(r-i-a+l+1)),o+=s}for(;c<a;c++)o*=1-i/(r-c);return t.min(1,t.max(0,o))}}),e.extend(e.poisson,{pdf:function(n,r){return r<0||n%1!=0||n<0?0:t.pow(r,n)*t.exp(-r)/e.factorial(n)},cdf:function(t,n){var r=[],i=0;if(t<0)return 0;for(;i<=t;i++)r.push(e.poisson.pdf(i,n));return e.sum(r)},mean:function(e){return e},variance:function(e){return e},sampleSmall:function(n){var r=1,i=0,a=t.exp(-n);do i++,r*=e._random_fn();while(r>a);return i-1},sampleLarge:function(n){var r=n,i,a,o,s=t.sqrt(r),c=t.log(r),l,u=.931+2.53*s,d,f,p;for(l=-.059+.02483*u,d=1.1239+1.1328/(u-3.4),f=.9277-3.6224/(u-2);;)if(a=t.random()-.5,o=t.random(),p=.5-t.abs(a),i=t.floor((2*l/p+u)*a+r+.43),p>=.07&&o<=f||!(i<0||p<.013&&o>p)&&t.log(o)+t.log(d)-t.log(l/(p*p)+u)<=-r+i*c-e.loggam(i+1))return i},sample:function(e){return e<10?this.sampleSmall(e):this.sampleLarge(e)}}),e.extend(e.triangular,{pdf:function(e,t,n,r){return n<=t||r<t||r>n?NaN:e<t||e>n?0:e<r?2*(e-t)/((n-t)*(r-t)):e===r?2/(n-t):2*(n-e)/((n-t)*(n-r))},cdf:function(e,n,r,i){return r<=n||i<n||i>r?NaN:e<=n?0:e>=r?1:e<=i?t.pow(e-n,2)/((r-n)*(i-n)):1-t.pow(r-e,2)/((r-n)*(r-i))},inv:function(e,n,r,i){return r<=n||i<n||i>r?NaN:e<=(i-n)/(r-n)?n+(r-n)*t.sqrt(e*((i-n)/(r-n))):n+(r-n)*(1-t.sqrt((1-e)*(1-(i-n)/(r-n))))},mean:function(e,t,n){return(e+t+n)/3},median:function(e,n,r){if(r<=(e+n)/2)return n-t.sqrt((n-e)*(n-r))/t.sqrt(2);if(r>(e+n)/2)return e+t.sqrt((n-e)*(r-e))/t.sqrt(2)},mode:function(e,t,n){return n},sample:function(n,r,i){var a=e._random_fn();return a<(i-n)/(r-n)?n+t.sqrt(a*(r-n)*(i-n)):r-t.sqrt((1-a)*(r-n)*(r-i))},variance:function(e,t,n){return(e*e+t*t+n*n-e*t-e*n-t*n)/18}}),e.extend(e.arcsine,{pdf:function(e,n,r){return r<=n?NaN:e<=n||e>=r?0:2/t.PI*t.pow(t.pow(r-n,2)-t.pow(2*e-n-r,2),-.5)},cdf:function(e,n,r){return e<n?0:e<r?2/t.PI*t.asin(t.sqrt((e-n)/(r-n))):1},inv:function(e,n,r){return n+(.5-.5*t.cos(t.PI*e))*(r-n)},mean:function(e,t){return t<=e?NaN:(e+t)/2},median:function(e,t){return t<=e?NaN:(e+t)/2},mode:function(){throw Error(`mode is not yet implemented`)},sample:function(n,r){return(n+r)/2+(r-n)/2*t.sin(2*t.PI*e.uniform.sample(0,1))},variance:function(e,n){return n<=e?NaN:t.pow(n-e,2)/8}});function r(e){return e/t.abs(e)}e.extend(e.laplace,{pdf:function(e,n,r){return r<=0?0:t.exp(-t.abs(e-n)/r)/(2*r)},cdf:function(e,n,r){return r<=0?0:e<n?.5*t.exp((e-n)/r):1-.5*t.exp(-(e-n)/r)},mean:function(e){return e},median:function(e){return e},mode:function(e){return e},variance:function(e,t){return 2*t*t},sample:function(n,i){var a=e._random_fn()-.5;return n-i*r(a)*t.log(1-2*t.abs(a))}});function i(n,r,i){var a=12,o=6,s=-30,c=-50,l=60,u=8,d=3,f=2,p=3,m=[.9815606342467192,.9041172563704749,.7699026741943047,.5873179542866175,.3678314989981802,.1252334085114689],h=[.04717533638651183,.10693932599531843,.16007832854334622,.20316742672306592,.2334925365383548,.24914704581340277],g=n*.5;if(g>=u)return 1;var _=2*e.normal.cdf(g,0,1,1,0)-1;_=_>=t.exp(c/i)?t.pow(_,i):0;for(var v=n>d?f:p,ee=g,te=(u-g)/v,y=ee+te,b=0,ne=i-1,re=1;re<=v;re++){for(var ie=0,ae=.5*(y+ee),oe=.5*(y-ee),se=1;se<=a;se++){var ce,le;o<se?(ce=a-se+1,le=m[ce-1]):(ce=se,le=-m[ce-1]);var ue=ae+oe*le,de=ue*ue;if(de>l)break;var fe=2*e.normal.cdf(ue,0,1,1,0),pe=2*e.normal.cdf(ue,n,1,1,0),me=fe*.5-pe*.5;me>=t.exp(s/ne)&&(me=h[ce-1]*t.exp(-(.5*de))*t.pow(me,ne),ie+=me)}ie*=2*oe*i/t.sqrt(2*t.PI),b+=ie,ee=y,y+=te}return _+=b,_<=t.exp(s/r)?0:(_=t.pow(_,r),_>=1?1:_)}function a(e,n,r){var i=.322232421088,a=.099348462606,o=-1,s=.588581570495,c=-.342242088547,l=.531103462366,u=-.204231210125,d=.10353775285,f=-453642210148e-16,p=.0038560700634,m=.8832,h=.2368,g=1.214,_=1.208,v=1.4142,ee=120,te=.5-.5*e,y=t.sqrt(t.log(1/(te*te))),b=y+((((y*f+u)*y+c)*y+o)*y+i)/((((y*p+d)*y+l)*y+s)*y+a);r<ee&&(b+=(b*b*b+b)/r/4);var ne=m-h*b;return r<ee&&(ne+=-g/r+_*b/r),b*(ne*t.log(n-1)+v)}e.extend(e.tukey,{cdf:function(n,r,a){var o=1,s=r,c=16,l=8,u=-30,d=1e-14,f=100,p=800,m=5e3,h=25e3,g=1,_=.5,v=.25,ee=.125,te=[.9894009349916499,.9445750230732326,.8656312023878318,.755404408355003,.6178762444026438,.45801677765722737,.2816035507792589,.09501250983763744],y=[.027152459411754096,.062253523938647894,.09515851168249279,.12462897125553388,.14959598881657674,.16915651939500254,.18260341504492358,.1894506104550685];if(n<=0)return 0;if(a<2||o<1||s<2)return NaN;if(!Number.isFinite(n))return 1;if(a>h)return i(n,o,s);var b=a*.5,ne=b*t.log(a)-a*t.log(2)-e.gammaln(b),re=b-1,ie=a*.25,ae=a<=f?g:a<=p?_:a<=m?v:ee;ne+=t.log(ae);for(var oe=0,se=1;se<=50;se++){for(var ce=0,le=(2*se-1)*ae,ue=1;ue<=c;ue++){var de,fe;l<ue?(de=ue-l-1,fe=ne+re*t.log(le+te[de]*ae)-(te[de]*ae+le)*ie):(de=ue-1,fe=ne+re*t.log(le-te[de]*ae)+(te[de]*ae-le)*ie);var pe;if(fe>=u){pe=l<ue?n*t.sqrt((te[de]*ae+le)*.5):n*t.sqrt((-(te[de]*ae)+le)*.5);var me=i(pe,o,s)*y[de]*t.exp(fe);ce+=me}}if(se*ae>=1&&ce<=d)break;oe+=ce}if(ce>d)throw Error(`tukey.cdf failed to converge`);return oe>1&&(oe=1),oe},inv:function(n,r,i){var o=1,s=r,c=1e-4,l=50;if(i<2||o<1||s<2||n<0||n>1)return NaN;if(n===0)return 0;if(n===1)return 1/0;for(var u=a(n,s,i),d=e.tukey.cdf(u,r,i)-n,f=d>0?t.max(0,u-1):u+1,p=e.tukey.cdf(f,r,i)-n,m,h=1;h<l;h++)if(m=f-p*(f-u)/(p-d),d=p,u=f,m<0&&(m=0,p=-n),p=e.tukey.cdf(m,r,i)-n,f=m,t.abs(f-u)<c)return m;throw Error(`tukey.inv failed to converge`)}})})(e,Math),(function(e,t){var n=Array.prototype.push,r=e.utils.isArray;function i(t){return r(t)||t instanceof e}e.extend({add:function(t,n){return i(n)?(i(n[0])||(n=[n]),e.map(t,function(e,t,r){return e+n[t][r]})):e.map(t,function(e){return e+n})},subtract:function(t,n){return i(n)?(i(n[0])||(n=[n]),e.map(t,function(e,t,r){return e-n[t][r]||0})):e.map(t,function(e){return e-n})},divide:function(t,n){return i(n)?(i(n[0])||(n=[n]),e.multiply(t,e.inv(n))):e.map(t,function(e){return e/n})},multiply:function(t,n){var r,a,o,s,c,l,u,d;if(t.length===void 0&&n.length===void 0)return t*n;if(c=t.length,l=t[0].length,u=e.zeros(c,o=i(n)?n[0].length:l),d=0,i(n)){for(;d<o;d++)for(r=0;r<c;r++){for(s=0,a=0;a<l;a++)s+=t[r][a]*n[a][d];u[r][d]=s}return c===1&&d===1?u[0][0]:u}return e.map(t,function(e){return e*n})},outer:function(t,n){return e.multiply(t.map(function(e){return[e]}),[n])},dot:function(t,n){i(t[0])||(t=[t]),i(n[0])||(n=[n]);for(var r=t[0].length===1&&t.length!==1?e.transpose(t):t,a=n[0].length===1&&n.length!==1?e.transpose(n):n,o=[],s=0,c=r.length,l=r[0].length,u,d;s<c;s++){for(o[s]=[],u=0,d=0;d<l;d++)u+=r[s][d]*a[s][d];o[s]=u}return o.length===1?o[0]:o},pow:function(n,r){return e.map(n,function(e){return t.pow(e,r)})},exp:function(n){return e.map(n,function(e){return t.exp(e)})},log:function(n){return e.map(n,function(e){return t.log(e)})},abs:function(n){return e.map(n,function(e){return t.abs(e)})},norm:function(e,n){var r=0,a=0;for(isNaN(n)&&(n=2),i(e[0])&&(e=e[0]);a<e.length;a++)r+=t.pow(t.abs(e[a]),n);return t.pow(r,1/n)},angle:function(n,r){return t.acos(e.dot(n,r)/(e.norm(n)*e.norm(r)))},aug:function(e,t){for(var r=[],i=0;i<e.length;i++)r.push(e[i].slice());for(i=0;i<r.length;i++)n.apply(r[i],t[i]);return r},inv:function(t){for(var n=t.length,r=t[0].length,i=e.identity(n,r),a=e.gauss_jordan(t,i),o=[],s=0,c;s<n;s++)for(o[s]=[],c=r;c<a[0].length;c++)o[s][c-r]=a[s][c];return o},det:function e(t){if(t.length===2)return t[0][0]*t[1][1]-t[0][1]*t[1][0];for(var n=0,r=0;r<t.length;r++){for(var i=[],a=1;a<t.length;a++){i[a-1]=[];for(var o=0;o<t.length;o++)o<r?i[a-1][o]=t[a][o]:o>r&&(i[a-1][o-1]=t[a][o])}var s=r%2?-1:1;n+=e(i)*t[0][r]*s}return n},gauss_elimination:function(n,r){var i=0,a=0,o=n.length,s=n[0].length,c=1,l=0,u=[],d,f,p,m;for(n=e.aug(n,r),d=n[0].length,i=0;i<o;i++){for(f=n[i][i],a=i,m=i+1;m<s;m++)f<t.abs(n[m][i])&&(f=n[m][i],a=m);if(a!=i)for(m=0;m<d;m++)p=n[i][m],n[i][m]=n[a][m],n[a][m]=p;for(a=i+1;a<o;a++)for(c=n[a][i]/n[i][i],m=i;m<d;m++)n[a][m]=n[a][m]-c*n[i][m]}for(i=o-1;i>=0;i--){for(l=0,a=i+1;a<=o-1;a++)l+=u[a]*n[i][a];u[i]=(n[i][d-1]-l)/n[i][i]}return u},gauss_jordan:function(n,r){for(var i=e.aug(n,r),a=i.length,o=i[0].length,s=0,c,l=0,u;l<a;l++){var d=l;for(u=l+1;u<a;u++)t.abs(i[u][l])>t.abs(i[d][l])&&(d=u);var f=i[l];for(i[l]=i[d],i[d]=f,u=l+1;u<a;u++)for(s=i[u][l]/i[l][l],c=l;c<o;c++)i[u][c]-=i[l][c]*s}for(l=a-1;l>=0;l--){for(s=i[l][l],u=0;u<l;u++)for(c=o-1;c>l-1;c--)i[u][c]-=i[l][c]*i[u][l]/s;for(i[l][l]/=s,c=a;c<o;c++)i[l][c]/=s}return i},triaUpSolve:function(t,n){var r=t[0].length,i=e.zeros(1,r)[0],a,o=!1;return n[0].length!=null&&(n=n.map(function(e){return e[0]}),o=!0),e.arange(r-1,-1,-1).forEach(function(o){a=e.arange(o+1,r).map(function(e){return i[e]*t[o][e]}),i[o]=(n[o]-e.sum(a))/t[o][o]}),o?i.map(function(e){return[e]}):i},triaLowSolve:function(t,n){var r=t[0].length,i=e.zeros(1,r)[0],a,o=!1;return n[0].length!=null&&(n=n.map(function(e){return e[0]}),o=!0),e.arange(r).forEach(function(r){a=e.arange(r).map(function(e){return t[r][e]*i[e]}),i[r]=(n[r]-e.sum(a))/t[r][r]}),o?i.map(function(e){return[e]}):i},lu:function(t){var n=t.length,r=e.identity(n),i=e.zeros(t.length,t[0].length),a;return e.arange(n).forEach(function(e){i[0][e]=t[0][e]}),e.arange(1,n).forEach(function(o){e.arange(o).forEach(function(n){a=e.arange(n).map(function(e){return r[o][e]*i[e][n]}),r[o][n]=(t[o][n]-e.sum(a))/i[n][n]}),e.arange(o,n).forEach(function(n){a=e.arange(o).map(function(e){return r[o][e]*i[e][n]}),i[o][n]=t[a.length][n]-e.sum(a)})}),[r,i]},cholesky:function(n){var r=n.length,i=e.zeros(n.length,n[0].length),a;return e.arange(r).forEach(function(o){a=e.arange(o).map(function(e){return t.pow(i[o][e],2)}),i[o][o]=t.sqrt(n[o][o]-e.sum(a)),e.arange(o+1,r).forEach(function(t){a=e.arange(o).map(function(e){return i[o][e]*i[t][e]}),i[t][o]=(n[o][t]-e.sum(a))/i[o][o]})}),i},gauss_jacobi:function(n,r,i,a){for(var o=0,s=0,c=n.length,l=[],u=[],d=[],f,p,m,h;o<c;o++)for(l[o]=[],u[o]=[],d[o]=[],s=0;s<c;s++)o>s?(l[o][s]=n[o][s],u[o][s]=d[o][s]=0):o<s?(u[o][s]=n[o][s],l[o][s]=d[o][s]=0):(d[o][s]=n[o][s],l[o][s]=u[o][s]=0);for(m=e.multiply(e.multiply(e.inv(d),e.add(l,u)),-1),p=e.multiply(e.inv(d),r),f=i,h=e.add(e.multiply(m,i),p),o=2;t.abs(e.norm(e.subtract(h,f)))>a;)f=h,h=e.add(e.multiply(m,f),p),o++;return h},gauss_seidel:function(n,r,i,a){for(var o=0,s=n.length,c=[],l=[],u=[],d,f,p,m,h;o<s;o++)for(c[o]=[],l[o]=[],u[o]=[],d=0;d<s;d++)o>d?(c[o][d]=n[o][d],l[o][d]=u[o][d]=0):o<d?(l[o][d]=n[o][d],c[o][d]=u[o][d]=0):(u[o][d]=n[o][d],c[o][d]=l[o][d]=0);for(m=e.multiply(e.multiply(e.inv(e.add(u,c)),l),-1),p=e.multiply(e.inv(e.add(u,c)),r),f=i,h=e.add(e.multiply(m,i),p),o=2;t.abs(e.norm(e.subtract(h,f)))>a;)f=h,h=e.add(e.multiply(m,f),p),o+=1;return h},SOR:function(n,r,i,a,o){for(var s=0,c=n.length,l=[],u=[],d=[],f,p,m,h,g;s<c;s++)for(l[s]=[],u[s]=[],d[s]=[],f=0;f<c;f++)s>f?(l[s][f]=n[s][f],u[s][f]=d[s][f]=0):s<f?(u[s][f]=n[s][f],l[s][f]=d[s][f]=0):(d[s][f]=n[s][f],l[s][f]=u[s][f]=0);for(h=e.multiply(e.inv(e.add(d,e.multiply(l,o))),e.subtract(e.multiply(d,1-o),e.multiply(u,o))),m=e.multiply(e.multiply(e.inv(e.add(d,e.multiply(l,o))),r),o),p=i,g=e.add(e.multiply(h,i),m),s=2;t.abs(e.norm(e.subtract(g,p)))>a;)p=g,g=e.add(e.multiply(h,p),m),s++;return g},householder:function(n){for(var r=n.length,i=n[0].length,a=0,o=[],s=[],c,l,u,d,f;a<r-1;a++){for(c=0,d=a+1;d<i;d++)c+=n[d][a]*n[d][a];for(f=n[a+1][a]>0?-1:1,c=f*t.sqrt(c),l=t.sqrt((c*c-n[a+1][a]*c)/2),o=e.zeros(r,1),o[a+1][0]=(n[a+1][a]-c)/(2*l),u=a+2;u<r;u++)o[u][0]=n[u][a]/(2*l);s=e.subtract(e.identity(r,i),e.multiply(e.multiply(o,e.transpose(o)),2)),n=e.multiply(s,e.multiply(n,s))}return n},QR:function(){var n=e.sum,r=e.arange;function i(i){var a=i.length,o=i[0].length,s=e.zeros(o,o);i=e.copy(i);for(var c,l=0,u;l<o;l++){for(s[l][l]=t.sqrt(n(r(a).map(function(e){return i[e][l]*i[e][l]}))),c=0;c<a;c++)i[c][l]=i[c][l]/s[l][l];for(u=l+1;u<o;u++)for(s[l][u]=n(r(a).map(function(e){return i[e][l]*i[e][u]})),c=0;c<a;c++)i[c][u]=i[c][u]-i[c][l]*s[l][u]}return[i,s]}return i}(),lstsq:function(){function t(t){t=e.copy(t);var n=t.length,r=e.identity(n);return e.arange(n-1,-1,-1).forEach(function(n){e.sliceAssign(r,{row:n},e.divide(e.slice(r,{row:n}),t[n][n])),e.sliceAssign(t,{row:n},e.divide(e.slice(t,{row:n}),t[n][n])),e.arange(n).forEach(function(i){var a=e.multiply(t[i][n],-1),o=e.slice(t,{row:i}),s=e.multiply(e.slice(t,{row:n}),a);e.sliceAssign(t,{row:i},e.add(o,s));var c=e.slice(r,{row:i}),l=e.multiply(e.slice(r,{row:n}),a);e.sliceAssign(r,{row:i},e.add(c,l))})}),r}function n(n,r){var i=!1;r[0].length===void 0&&(r=r.map(function(e){return[e]}),i=!0);var a=e.QR(n),o=a[0],s=a[1],c=n[0].length,l=e.slice(o,{col:{end:c}}),u=t(e.slice(s,{row:{end:c}})),d=e.transpose(l);d[0].length===void 0&&(d=[d]);var f=e.multiply(e.multiply(u,d),r);return f.length===void 0&&(f=[[f]]),i?f.map(function(e){return e[0]}):f}return n}(),jacobi:function(n){for(var r=1,i=n.length,a=e.identity(i,i),o=[],s,c,l,u,d,f,p,m;r===1;){for(f=n[0][1],u=0,d=1,c=0;c<i;c++)for(l=0;l<i;l++)c!=l&&f<t.abs(n[c][l])&&(f=t.abs(n[c][l]),u=c,d=l);for(p=n[u][u]===n[d][d]?n[u][d]>0?t.PI/4:-t.PI/4:t.atan(2*n[u][d]/(n[u][u]-n[d][d]))/2,m=e.identity(i,i),m[u][u]=t.cos(p),m[u][d]=-t.sin(p),m[d][u]=t.sin(p),m[d][d]=t.cos(p),a=e.multiply(a,m),s=e.multiply(e.multiply(e.inv(m),n),m),n=s,r=0,c=1;c<i;c++)for(l=1;l<i;l++)c!=l&&t.abs(n[c][l])>.001&&(r=1)}for(c=0;c<i;c++)o.push(n[c][c]);return[a,o]},rungekutta:function(e,t,n,r,i,a){var o,s,c,l,u;if(a===2)for(;r<=n;)o=t*e(r,i),s=t*e(r+t,i+o),c=i+(o+s)/2,i=c,r+=t;if(a===4)for(;r<=n;)o=t*e(r,i),s=t*e(r+t/2,i+o/2),l=t*e(r+t/2,i+s/2),u=t*e(r+t,i+l),c=i+(o+2*s+2*l+u)/6,i=c,r+=t;return i},romberg:function(e,n,r,i){for(var a=0,o=(r-n)/2,s=[],c=[],l=[],u,d,f,p,m;a<i/2;){for(m=e(n),f=n,p=0;f<=r;f+=o,p++)s[p]=f;for(u=s.length,f=1;f<u-1;f++)m+=(f%2==0?2:4)*e(s[f]);m=o/3*(m+e(r)),l[a]=m,o/=2,a++}for(d=l.length,u=1;d!==1;){for(f=0;f<d-1;f++)c[f]=(t.pow(4,u)*l[f+1]-l[f])/(t.pow(4,u)-1);d=c.length,l=c,c=[],u++}return l},richardson:function(e,n,r,i){function a(e,t){for(var n=0,r=e.length,i;n<r;n++)e[n]===t&&(i=n);return i}for(var o=t.abs(r-e[a(e,r)+1]),s=0,c=[],l=[],u,d,f,p,m;i>=o;)u=a(e,r+i),d=a(e,r),c[s]=(n[u]-2*n[d]+n[2*d-u])/(i*i),i/=2,s++;for(p=c.length,f=1;p!=1;){for(m=0;m<p-1;m++)l[m]=(t.pow(4,f)*c[m+1]-c[m])/(t.pow(4,f)-1);p=l.length,c=l,l=[],f++}return c},simpson:function(e,t,n,r){for(var i=(n-t)/r,a=e(t),o=[],s=t,c=0,l=1,u;s<=n;s+=i,c++)o[c]=s;for(u=o.length;l<u-1;l++)a+=(l%2==0?2:4)*e(o[l]);return i/3*(a+e(n))},hermite:function(e,t,n,r){for(var i=e.length,a=0,o=0,s=[],c=[],l=[],u=[],d;o<i;o++){for(s[o]=1,d=0;d<i;d++)o!=d&&(s[o]*=(r-e[d])/(e[o]-e[d]));for(c[o]=0,d=0;d<i;d++)o!=d&&(c[o]+=1/(e[o]-e[d]));l[o]=(1-2*(r-e[o])*c[o])*(s[o]*s[o]),u[o]=(r-e[o])*(s[o]*s[o]),a+=l[o]*t[o]+u[o]*n[o]}return a},lagrange:function(e,t,n){for(var r=0,i=0,a,o,s=e.length;i<s;i++){for(o=t[i],a=0;a<s;a++)i!=a&&(o*=(n-e[a])/(e[i]-e[a]));r+=o}return r},cubic_spline:function(t,n,r){for(var i=t.length,a=0,o,s=[],c=[],l=[],u=[],d=[],f=[],p=[];a<i-1;a++)d[a]=t[a+1]-t[a];for(l[0]=0,a=1;a<i-1;a++)l[a]=3/d[a]*(n[a+1]-n[a])-3/d[a-1]*(n[a]-n[a-1]);for(a=1;a<i-1;a++)s[a]=[],c[a]=[],s[a][a-1]=d[a-1],s[a][a]=2*(d[a-1]+d[a]),s[a][a+1]=d[a],c[a][0]=l[a];for(u=e.multiply(e.inv(s),c),o=0;o<i-1;o++)f[o]=(n[o+1]-n[o])/d[o]-d[o]*(u[o+1][0]+2*u[o][0])/3,p[o]=(u[o+1][0]-u[o][0])/(3*d[o]);for(o=0;o<i&&!(t[o]>r);o++);return--o,n[o]+(r-t[o])*f[o]+e.sq(r-t[o])*u[o]+(r-t[o])*e.sq(r-t[o])*p[o]},gauss_quadrature:function(){throw Error(`gauss_quadrature not yet implemented`)},PCA:function(t){var n=t.length,r=t[0].length,i=0,a,o,s=[],c=[],l=[],u=[],d=[],f=[],p=[],m=[],h=[],g=[];for(i=0;i<n;i++)s[i]=e.sum(t[i])/r;for(i=0;i<r;i++)for(p[i]=[],a=0;a<n;a++)p[i][a]=t[a][i]-s[a];for(p=e.transpose(p),i=0;i<n;i++)for(m[i]=[],a=0;a<n;a++)m[i][a]=e.dot([p[i]],[p[a]])/(r-1);for(l=e.jacobi(m),h=l[0],c=l[1],g=e.transpose(h),i=0;i<c.length;i++)for(a=i;a<c.length;a++)c[i]<c[a]&&(o=c[i],c[i]=c[a],c[a]=o,u=g[i],g[i]=g[a],g[a]=u);for(f=e.transpose(p),i=0;i<n;i++)for(d[i]=[],a=0;a<f.length;a++)d[i][a]=e.dot([g[i]],[f[a]]);return[t,c,g,d]}}),(function(t){for(var n=0;n<t.length;n++)(function(t){e.fn[t]=function(n,r){var i=this;return r?(setTimeout(function(){r.call(i,e.fn[t].call(i,n))},15),this):typeof e[t](this,n)==`number`?e[t](this,n):e(e[t](this,n))}})(t[n])})(`add divide multiply subtract dot pow exp log abs norm angle`.split(` `))})(e,Math),(function(e,t){var n=[].slice,r=e.utils.isNumber,i=e.utils.isArray;e.extend({zscore:function(){var t=n.call(arguments);return r(t[1])?(t[0]-t[1])/t[2]:(t[0]-e.mean(t[1]))/e.stdev(t[1],t[2])},ztest:function(){var r=n.call(arguments),a;return i(r[1])?(a=e.zscore(r[0],r[1],r[3]),r[2]===1?e.normal.cdf(-t.abs(a),0,1):e.normal.cdf(-t.abs(a),0,1)*2):r.length>2?(a=e.zscore(r[0],r[1],r[2]),r[3]===1?e.normal.cdf(-t.abs(a),0,1):e.normal.cdf(-t.abs(a),0,1)*2):(a=r[0],r[1]===1?e.normal.cdf(-t.abs(a),0,1):e.normal.cdf(-t.abs(a),0,1)*2)}}),e.extend(e.fn,{zscore:function(e,t){return(e-this.mean())/this.stdev(t)},ztest:function(n,r,i){var a=t.abs(this.zscore(n,i));return r===1?e.normal.cdf(-a,0,1):e.normal.cdf(-a,0,1)*2}}),e.extend({tscore:function(){var r=n.call(arguments);return r.length===4?(r[0]-r[1])/(r[2]/t.sqrt(r[3])):(r[0]-e.mean(r[1]))/(e.stdev(r[1],!0)/t.sqrt(r[1].length))},ttest:function(){var i=n.call(arguments),a;return i.length===5?(a=t.abs(e.tscore(i[0],i[1],i[2],i[3])),i[4]===1?e.studentt.cdf(-a,i[3]-1):e.studentt.cdf(-a,i[3]-1)*2):r(i[1])?(a=t.abs(i[0]),i[2]==1?e.studentt.cdf(-a,i[1]-1):e.studentt.cdf(-a,i[1]-1)*2):(a=t.abs(e.tscore(i[0],i[1])),i[2]==1?e.studentt.cdf(-a,i[1].length-1):e.studentt.cdf(-a,i[1].length-1)*2)}}),e.extend(e.fn,{tscore:function(e){return(e-this.mean())/(this.stdev(!0)/t.sqrt(this.cols()))},ttest:function(n,r){return r===1?1-e.studentt.cdf(t.abs(this.tscore(n)),this.cols()-1):e.studentt.cdf(-t.abs(this.tscore(n)),this.cols()-1)*2}}),e.extend({anovafscore:function(){var r=n.call(arguments),i,a,o,s,c,l,u,d;if(r.length===1){for(c=Array(r[0].length),u=0;u<r[0].length;u++)c[u]=r[0][u];r=c}for(a=[],u=0;u<r.length;u++)a=a.concat(r[u]);for(o=e.mean(a),i=0,u=0;u<r.length;u++)i+=r[u].length*t.pow(e.mean(r[u])-o,2);for(i/=r.length-1,l=0,u=0;u<r.length;u++)for(s=e.mean(r[u]),d=0;d<r[u].length;d++)l+=t.pow(r[u][d]-s,2);return l/=a.length-r.length,i/l},anovaftest:function(){var t=n.call(arguments),i,a,o,s;if(r(t[0]))return 1-e.centralF.cdf(t[0],t[1],t[2]);var c=e.anovafscore(t);for(i=t.length-1,o=0,s=0;s<t.length;s++)o+=t[s].length;return a=o-i-1,1-e.centralF.cdf(c,i,a)},ftest:function(t,n,r){return 1-e.centralF.cdf(t,n,r)}}),e.extend(e.fn,{anovafscore:function(){return e.anovafscore(this.toArray())},anovaftes:function(){for(var t=0,n=0;n<this.length;n++)t+=this[n].length;return e.ftest(this.anovafscore(),this.length-1,t-this.length)}}),e.extend({qscore:function(){var i=n.call(arguments),a,o,s,c,l;return r(i[0])?(a=i[0],o=i[1],s=i[2],c=i[3],l=i[4]):(a=e.mean(i[0]),o=e.mean(i[1]),s=i[0].length,c=i[1].length,l=i[2]),t.abs(a-o)/(l*t.sqrt((1/s+1/c)/2))},qtest:function(){var t=n.call(arguments),r;t.length===3?(r=t[0],t=t.slice(1)):t.length===7?(r=e.qscore(t[0],t[1],t[2],t[3],t[4]),t=t.slice(5)):(r=e.qscore(t[0],t[1],t[2]),t=t.slice(3));var i=t[0],a=t[1];return 1-e.tukey.cdf(r,a,i-a)},tukeyhsd:function(t){for(var n=e.pooledstdev(t),r=t.map(function(t){return e.mean(t)}),i=t.reduce(function(e,t){return e+t.length},0),a=[],o=0;o<t.length;++o)for(var s=o+1;s<t.length;++s){var c=e.qtest(r[o],r[s],t[o].length,t[s].length,n,i,t.length);a.push([[o,s],c])}return a}}),e.extend({normalci:function(){var r=n.call(arguments),i=[,,],a=r.length===4?t.abs(e.normal.inv(r[1]/2,0,1)*r[2]/t.sqrt(r[3])):t.abs(e.normal.inv(r[1]/2,0,1)*e.stdev(r[2])/t.sqrt(r[2].length));return i[0]=r[0]-a,i[1]=r[0]+a,i},tci:function(){var r=n.call(arguments),i=[,,],a=r.length===4?t.abs(e.studentt.inv(r[1]/2,r[3]-1)*r[2]/t.sqrt(r[3])):t.abs(e.studentt.inv(r[1]/2,r[2].length-1)*e.stdev(r[2],!0)/t.sqrt(r[2].length));return i[0]=r[0]-a,i[1]=r[0]+a,i},significant:function(e,t){return e<t}}),e.extend(e.fn,{normalci:function(t,n){return e.normalci(t,n,this.toArray())},tci:function(t,n){return e.tci(t,n,this.toArray())}});function a(e,n,r,i){if(e>1||r>1||e<=0||r<=0)throw Error(`Proportions should be greater than 0 and less than 1`);var a=(e*n+r*i)/(n+i),o=t.sqrt(a*(1-a)*(1/n+1/i));return(e-r)/o}e.extend(e.fn,{oneSidedDifferenceOfProportions:function(t,n,r,i){var o=a(t,n,r,i);return e.ztest(o,1)},twoSidedDifferenceOfProportions:function(t,n,r,i){var o=a(t,n,r,i);return e.ztest(o,2)}})})(e,Math),e.models=(function(){function t(t){var r=t[0].length;return e.arange(r).map(function(i){var a=e.arange(r).filter(function(e){return e!==i});return n(e.col(t,i).map(function(e){return e[0]}),e.col(t,a))})}function n(t,n){var r=t.length,i=n[0].length-1,a=r-i-1,o=e.lstsq(n,t),s=e.multiply(n,o.map(function(e){return[e]})).map(function(e){return e[0]}),c=e.subtract(t,s),l=e.mean(t),u=e.sum(s.map(function(e){return(e-l)**2})),d=e.sum(t.map(function(e,t){return(e-s[t])**2})),f=u+d;return{exog:n,endog:t,nobs:r,df_model:i,df_resid:a,coef:o,predict:s,resid:c,ybar:l,SST:f,SSE:u,SSR:d,R2:u/f}}function r(n){var r=t(n.exog),i=Math.sqrt(n.SSR/n.df_resid),a=r.map(function(e){var t=e.SST,n=e.R2;return i/Math.sqrt(t*(1-n))}),o=n.coef.map(function(e,t){return(e-0)/a[t]}),s=o.map(function(t){var r=e.studentt.cdf(t,n.df_resid);return(r>.5?1-r:r)*2}),c=e.studentt.inv(.975,n.df_resid);return{se:a,t:o,p:s,sigmaHat:i,interval95:n.coef.map(function(e,t){var n=c*a[t];return[e-n,e+n]})}}function i(t){var n=t.R2/t.df_model/((1-t.R2)/t.df_resid);return{F_statistic:n,pvalue:1-function(t,n,r){return e.beta.cdf(t/(r/n+t),n/2,r/2)}(n,t.df_model,t.df_resid)}}function a(e,t){var a=n(e,t),o=r(a),s=i(a),c=1-(1-a.R2)*((a.nobs-1)/a.df_resid);return a.t=o,a.f=s,a.adjust_R2=c,a}return{ols:a}})(),e.extend({buildxmatrix:function(){for(var t=Array(arguments.length),n=0;n<arguments.length;n++)t[n]=[1].concat(arguments[n]);return e(t)},builddxmatrix:function(){for(var t=Array(arguments[0].length),n=0;n<arguments[0].length;n++)t[n]=[1].concat(arguments[0][n]);return e(t)},buildjxmatrix:function(t){for(var n=Array(t.length),r=0;r<t.length;r++)n[r]=t[r];return e.builddxmatrix(n)},buildymatrix:function(t){return e(t).transpose()},buildjymatrix:function(e){return e.transpose()},matrixmult:function(t,n){var r,i,a,o,s;if(t.cols()==n.rows()){if(n.rows()>1){for(o=[],r=0;r<t.rows();r++)for(o[r]=[],i=0;i<n.cols();i++){for(s=0,a=0;a<t.cols();a++)s+=t.toArray()[r][a]*n.toArray()[a][i];o[r][i]=s}return e(o)}for(o=[],r=0;r<t.rows();r++)for(o[r]=[],i=0;i<n.cols();i++){for(s=0,a=0;a<t.cols();a++)s+=t.toArray()[r][a]*n.toArray()[i];o[r][i]=s}return e(o)}},regress:function(t,n){var r=e.xtranspxinv(t),i=t.transpose(),a=e.matrixmult(e(r),i);return e.matrixmult(a,n)},regresst:function(t,n,r){var i=e.regress(t,n),a={};a.anova={};var o=e.jMatYBar(t,i);a.yBar=o;var s=n.mean();a.anova.residuals=e.residuals(n,o),a.anova.ssr=e.ssr(o,s),a.anova.msr=a.anova.ssr/(t[0].length-1),a.anova.sse=e.sse(n,o),a.anova.mse=a.anova.sse/(n.length-(t[0].length-1)-1),a.anova.sst=e.sst(n,s),a.anova.mst=a.anova.sst/(n.length-1),a.anova.r2=1-a.anova.sse/a.anova.sst,a.anova.r2<0&&(a.anova.r2=0),a.anova.fratio=a.anova.msr/a.anova.mse,a.anova.pvalue=e.anovaftest(a.anova.fratio,t[0].length-1,n.length-(t[0].length-1)-1),a.anova.rmse=Math.sqrt(a.anova.mse),a.anova.r2adj=1-a.anova.mse/a.anova.mst,a.anova.r2adj<0&&(a.anova.r2adj=0),a.stats=Array(t[0].length);for(var c=e.xtranspxinv(t),l,u,d,f=0;f<i.length;f++)l=Math.sqrt(a.anova.mse*Math.abs(c[f][f])),u=Math.abs(i[f]/l),d=e.ttest(u,n.length-t[0].length-1,r),a.stats[f]=[i[f],l,u,d];return a.regress=i,a},xtranspx:function(t){return e.matrixmult(t.transpose(),t)},xtranspxinv:function(t){var n=e.matrixmult(t.transpose(),t);return e.inv(n)},jMatYBar:function(t,n){return new e(e.matrixmult(t,n))},residuals:function(t,n){return e.matrixsubtract(t,n)},ssr:function(e,t){for(var n=0,r=0;r<e.length;r++)n+=(e[r]-t)**2;return n},sse:function(e,t){for(var n=0,r=0;r<e.length;r++)n+=(e[r]-t[r])**2;return n},sst:function(e,t){for(var n=0,r=0;r<e.length;r++)n+=(e[r]-t)**2;return n},matrixsubtract:function(t,n){for(var r=Array(t.length),i=0;i<t.length;i++){r[i]=Array(t[i].length);for(var a=0;a<t[i].length;a++)r[i][a]=t[i][a]-n[i][a]}return e(r)}}),e.jStat=e,e})})),Gh=n((e=>{(function(t){typeof DO_NOT_EXPORT_BESSEL>`u`?typeof e==`object`?t(e):typeof define==`function`&&define.amd?define(function(){var e={};return t(e),e}):t({}):t({})})(function(e){e.version=`1.0.2`;var t=Math;function n(e,t){for(var n=0,r=0;n<e.length;++n)r=t*r+e[n];return r}function r(e,t,n,r,i){if(t===0)return n;if(t===1)return r;for(var a=2/e,o=r,s=1;s<t;++s)o=r*s*a+i*n,n=r,r=o;return o}function i(e,t,n,i,a){return function(n,o){if(i){if(n===0)return i==1?-1/0:1/0;if(n<0)return NaN}if(o===0)return e(n);if(o===1)return t(n);if(o<0)return NaN;o|=0;var s=e(n),c=t(n);return r(n,o,s,c,a)}}var a=(function(){var e=.636619772,i=[57568490574,-13362590354,651619640.7,-11214424.18,77392.33017,-184.9052456].reverse(),a=[57568490411,1029532985,9494680.718,59272.64853,267.8532712,1].reverse(),o=[1,-.001098628627,2734510407e-14,-2073370639e-15,2.093887211e-7].reverse(),s=[-.01562499995,.0001430488765,-6911147651e-15,7.621095161e-7,-9.34935152e-8].reverse();function c(r){var c=0,l=0,u=0,d=r*r;if(r<8)l=n(i,d),u=n(a,d),c=l/u;else{var f=r-.785398164;d=64/d,l=n(o,d),u=n(s,d),c=t.sqrt(e/r)*(t.cos(f)*l-t.sin(f)*u*8/r)}return c}var l=[72362614232,-7895059235,242396853.1,-2972611.439,15704.4826,-30.16036606].reverse(),u=[144725228442,2300535178,18583304.74,99447.43394,376.9991397,1].reverse(),d=[1,.00183105,-3516396496e-14,2457520174e-15,-2.40337019e-7].reverse(),f=[.04687499995,-.0002002690873,8449199096e-15,-8.8228987e-7,1.05787412e-7].reverse();function p(r){var i=0,a=0,o=0,s=r*r,c=t.abs(r)-2.356194491;return Math.abs(r)<8?(a=r*n(l,s),o=n(u,s),i=a/o):(s=64/s,a=n(d,s),o=n(f,s),i=t.sqrt(e/t.abs(r))*(t.cos(c)*a-t.sin(c)*o*8/t.abs(r)),r<0&&(i=-i)),i}return function e(n,i){if(i=Math.round(i),!isFinite(n))return isNaN(n)?n:0;if(i<0)return(i%2?-1:1)*e(n,-i);if(n<0)return(i%2?-1:1)*e(-n,i);if(i===0)return c(n);if(i===1)return p(n);if(n===0)return 0;var a=0;if(n>i)a=r(n,i,c(n),p(n),-1);else{for(var o=2*t.floor((i+t.floor(t.sqrt(40*i)))/2),s=!1,l=0,u=0,d=1,f=0,m=2/n,h=o;h>0;h--)f=h*m*d-l,l=d,d=f,t.abs(d)>1e10&&(d*=1e-10,l*=1e-10,a*=1e-10,u*=1e-10),s&&(u+=d),s=!s,h==i&&(a=l);u=2*u-d,a/=u}return a}})(),o=(function(){var e=.636619772,r=[-2957821389,7062834065,-512359803.6,10879881.29,-86327.92757,228.4622733].reverse(),o=[40076544269,745249964.8,7189466.438,47447.2647,226.1030244,1].reverse(),s=[1,-.001098628627,2734510407e-14,-2073370639e-15,2.093887211e-7].reverse(),c=[-.01562499995,.0001430488765,-6911147651e-15,7.621095161e-7,-9.34945152e-8].reverse();function l(i){var l=0,u=0,d=0,f=i*i,p=i-.785398164;return i<8?(u=n(r,f),d=n(o,f),l=u/d+e*a(i,0)*t.log(i)):(f=64/f,u=n(s,f),d=n(c,f),l=t.sqrt(e/i)*(t.sin(p)*u+t.cos(p)*d*8/i)),l}var u=[-4900604943e3,127527439e4,-51534381390,734926455.1,-4237922.726,8511.937935].reverse(),d=[249958057e5,424441966400,3733650367,22459040.02,102042.605,354.9632885,1].reverse(),f=[1,.00183105,-3516396496e-14,2457520174e-15,-2.40337019e-7].reverse(),p=[.04687499995,-.0002002690873,8449199096e-15,-8.8228987e-7,1.05787412e-7].reverse();function m(r){var i=0,o=0,s=0,c=r*r,l=r-2.356194491;return r<8?(o=r*n(u,c),s=n(d,c),i=o/s+e*(a(r,1)*t.log(r)-1/r)):(c=64/c,o=n(f,c),s=n(p,c),i=t.sqrt(e/r)*(t.sin(l)*o+t.cos(l)*s*8/r)),i}return i(l,m,`BESSELY`,1,-1)})(),s=(function(){var e=[1,3.5156229,3.0899424,1.2067492,.2659732,.0360768,.0045813].reverse(),r=[.39894228,.01328592,.00225319,-.00157565,.00916281,-.02057706,.02635537,-.01647633,.00392377].reverse();function i(i){return i<=3.75?n(e,i*i/14.0625):t.exp(t.abs(i))/t.sqrt(t.abs(i))*n(r,3.75/t.abs(i))}var a=[.5,.87890594,.51498869,.15084934,.02658733,.00301532,32411e-8].reverse(),o=[.39894228,-.03988024,-.00362018,.00163801,-.01031555,.02282967,-.02895312,.01787654,-.00420059].reverse();function s(e){return e<3.75?e*n(a,e*e/14.0625):(e<0?-1:1)*t.exp(t.abs(e))/t.sqrt(t.abs(e))*n(o,3.75/t.abs(e))}return function e(n,r){if(r=Math.round(r),r===0)return i(n);if(r===1)return s(n);if(r<0)return NaN;if(t.abs(n)===0)return 0;if(n==1/0)return 1/0;var a=0,o,c=2/t.abs(n),l=0,u=1,d=0;for(o=2*t.round((r+t.round(t.sqrt(40*r)))/2);o>0;o--)d=o*c*u+l,l=u,u=d,t.abs(u)>1e10&&(u*=1e-10,l*=1e-10,a*=1e-10),o==r&&(a=l);return a*=e(n,0)/u,n<0&&r%2?-a:a}})(),c=(function(){var e=[-.57721566,.4227842,.23069756,.0348859,.00262698,1075e-7,74e-7].reverse(),r=[1.25331414,-.07832358,.02189568,-.01062446,.00587872,-.0025154,53208e-8].reverse();function a(i){return i<=2?-t.log(i/2)*s(i,0)+n(e,i*i/4):t.exp(-i)/t.sqrt(i)*n(r,2/i)}var o=[1,.15443144,-.67278579,-.18156897,-.01919402,-.00110404,-4686e-8].reverse(),c=[1.25331414,.23498619,-.0365562,.01504268,-.00780353,.00325614,-68245e-8].reverse();function l(e){return e<=2?t.log(e/2)*s(e,1)+1/e*n(o,e*e/4):t.exp(-e)/t.sqrt(e)*n(c,2/e)}return i(a,l,`BESSELK`,2,1)})();e.besselj=a,e.bessely=o,e.besseli=s,e.besselk=c})})),Kh=t({ABS:()=>_y,ACCRINT:()=>YC,ACOS:()=>vy,ACOSH:()=>yy,ACOT:()=>by,ACOTH:()=>xy,AGGREGATE:()=>Sy,AND:()=>Ow,ARABIC:()=>Cy,ASIN:()=>wy,ASINH:()=>Ty,ATAN:()=>Ey,ATAN2:()=>Dy,ATANH:()=>Oy,AVEDEV:()=>Q_,AVERAGE:()=>$_,AVERAGEA:()=>ev,AVERAGEIF:()=>tv,AVERAGEIFS:()=>nv,BASE:()=>ky,BESSELI:()=>Ex,BESSELJ:()=>Dx,BESSELK:()=>Ox,BESSELY:()=>kx,BETA:()=>rv,BETADIST:()=>wS,BETAINV:()=>TS,BIN2DEC:()=>Ax,BIN2HEX:()=>jx,BIN2OCT:()=>Mx,BINOM:()=>iv,BINOMDIST:()=>ES,BITAND:()=>Nx,BITLSHIFT:()=>Px,BITOR:()=>Fx,BITRSHIFT:()=>Ix,BITXOR:()=>Lx,CEILING:()=>Ay,CEILINGMATH:()=>DS,CEILINGPRECISE:()=>OS,CHAR:()=>C_,CHIDIST:()=>kS,CHIDISTRT:()=>AS,CHIINV:()=>jS,CHIINVRT:()=>MS,CHISQ:()=>av,CHITEST:()=>NS,CHOOSE:()=>i_,CHOOSECOLS:()=>a_,CHOOSEROWS:()=>o_,CLEAN:()=>w_,CODE:()=>T_,COLUMN:()=>s_,COLUMNS:()=>c_,COMBIN:()=>jy,COMBINA:()=>My,COMPLEX:()=>Rx,CONCAT:()=>D_,CONCATENATE:()=>E_,CONFIDENCE:()=>ov,CONVERT:()=>zx,CORREL:()=>sv,COS:()=>Ny,COSH:()=>Py,COT:()=>Fy,COTH:()=>Iy,COUNT:()=>cv,COUNTA:()=>lv,COUNTBLANK:()=>uv,COUNTIF:()=>dv,COUNTIFS:()=>fv,COUPDAYS:()=>XC,COVAR:()=>PS,COVARIANCE:()=>pv,COVARIANCEP:()=>FS,COVARIANCES:()=>IS,CRITBINOM:()=>LS,CSC:()=>Ly,CSCH:()=>Ry,CUMIPMT:()=>ZC,CUMPRINC:()=>QC,DATE:()=>$b,DATEDIF:()=>ex,DATEVALUE:()=>tx,DAVERAGE:()=>MC,DAY:()=>nx,DAYS:()=>ix,DAYS360:()=>ax,DB:()=>$C,DCOUNT:()=>NC,DCOUNTA:()=>PC,DDB:()=>ew,DEC2BIN:()=>Bx,DEC2HEX:()=>Vx,DEC2OCT:()=>Hx,DECIMAL:()=>zy,DEGREES:()=>By,DELTA:()=>Ux,DEVSQ:()=>mv,DGET:()=>FC,DISC:()=>tw,DMAX:()=>IC,DMIN:()=>LC,DOLLAR:()=>O_,DOLLARDE:()=>nw,DOLLARFR:()=>rw,DPRODUCT:()=>RC,DROP:()=>l_,DSTDEV:()=>zC,DSTDEVP:()=>BC,DSUM:()=>VC,DVAR:()=>HC,DVARP:()=>UC,EDATE:()=>ox,EFFECT:()=>iw,EOMONTH:()=>sx,ERF:()=>Wx,ERFC:()=>Gx,ERFCPRECISE:()=>RS,ERFPRECISE:()=>zS,ERROR:()=>Wg,EVEN:()=>Vy,EXACT:()=>k_,EXP:()=>Hy,EXPAND:()=>u_,EXPON:()=>hv,EXPONDIST:()=>BS,F:()=>gv,FACT:()=>Wy,FACTDOUBLE:()=>Gy,FALSE:()=>kw,FDIST:()=>VS,FDISTRT:()=>HS,FIND:()=>A_,FINV:()=>US,FINVRT:()=>WS,FISHER:()=>_v,FISHERINV:()=>vv,FIXED:()=>j_,FLOOR:()=>Ky,FLOORMATH:()=>GS,FLOORPRECISE:()=>KS,FORECAST:()=>yv,FREQUENCY:()=>bv,FTEST:()=>qS,FV:()=>aw,FVSCHEDULE:()=>ow,GAMMA:()=>xv,GAMMADIST:()=>JS,GAMMAINV:()=>YS,GAMMALN:()=>Sv,GAMMALNPRECISE:()=>XS,GAUSS:()=>Cv,GCD:()=>qy,GEOMEAN:()=>wv,GESTEP:()=>Kx,GROWTH:()=>Tv,HARMEAN:()=>Ev,HEX2BIN:()=>qx,HEX2DEC:()=>Jx,HEX2OCT:()=>Yx,HLOOKUP:()=>d_,HOUR:()=>cx,HSTACK:()=>x_,HYPGEOM:()=>Dv,HYPGEOMDIST:()=>ZS,IF:()=>Aw,IFERROR:()=>Mw,IFNA:()=>Nw,IFS:()=>jw,IMABS:()=>Xx,IMAGINARY:()=>Zx,IMARGUMENT:()=>Qx,IMCONJUGATE:()=>$x,IMCOS:()=>eS,IMCOSH:()=>tS,IMCOT:()=>nS,IMCSC:()=>gS,IMCSCH:()=>_S,IMDIV:()=>rS,IMEXP:()=>iS,IMLN:()=>aS,IMLOG10:()=>oS,IMLOG2:()=>sS,IMPOWER:()=>cS,IMPRODUCT:()=>lS,IMREAL:()=>uS,IMSEC:()=>dS,IMSECH:()=>fS,IMSIN:()=>pS,IMSINH:()=>mS,IMSQRT:()=>hS,IMSUB:()=>vS,IMSUM:()=>yS,IMTAN:()=>bS,INDEX:()=>f_,INT:()=>Jy,INTERCEPT:()=>Ov,IPMT:()=>sw,IRR:()=>cw,ISBLANK:()=>Gg,ISERR:()=>Kg,ISERROR:()=>qg,ISEVEN:()=>Jg,ISLOGICAL:()=>Yg,ISNA:()=>Xg,ISNONTEXT:()=>Zg,ISNUMBER:()=>Qg,ISO:()=>Yy,ISODD:()=>$g,ISOWEEKNUM:()=>lx,ISPMT:()=>lw,ISTEXT:()=>e_,KURT:()=>kv,LARGE:()=>Av,LCM:()=>Xy,LEFT:()=>M_,LEN:()=>N_,LINEST:()=>jv,LN:()=>Zy,LOG:()=>Qy,LOG10:()=>$y,LOGEST:()=>Mv,LOGINV:()=>QS,LOGNORM:()=>Nv,LOGNORMDIST:()=>$S,LOGNORMINV:()=>eC,LOOKUP:()=>p_,LOWER:()=>P_,MATCH:()=>m_,MAX:()=>Pv,MAXA:()=>Fv,MAXIFS:()=>Iv,MEDIAN:()=>Lv,MID:()=>F_,MIN:()=>Rv,MINA:()=>zv,MINIFS:()=>Bv,MINUTE:()=>ux,MIRR:()=>uw,MMULT:()=>eb,MOD:()=>tb,MODE:()=>Vv,MODEMULT:()=>tC,MODESNGL:()=>nC,MONTH:()=>dx,MROUND:()=>nb,MULTINOMIAL:()=>rb,MUNIT:()=>ib,N:()=>t_,NA:()=>n_,NEGBINOM:()=>Hv,NEGBINOMDIST:()=>rC,NETWORKDAYS:()=>fx,NETWORKDAYSINTL:()=>iC,NOMINAL:()=>dw,NORM:()=>Uv,NORMDIST:()=>aC,NORMINV:()=>oC,NORMSDIST:()=>sC,NORMSINV:()=>cC,NOT:()=>Pw,NOW:()=>px,NPER:()=>fw,NPV:()=>pw,NUMBERVALUE:()=>I_,OCT2BIN:()=>xS,OCT2DEC:()=>SS,OCT2HEX:()=>CS,ODD:()=>ab,OR:()=>Fw,PDURATION:()=>mw,PEARSON:()=>Wv,PERCENTILE:()=>Gv,PERCENTILEEXC:()=>lC,PERCENTILEINC:()=>uC,PERCENTRANK:()=>Kv,PERCENTRANKEXC:()=>dC,PERCENTRANKINC:()=>fC,PERMUT:()=>qv,PERMUTATIONA:()=>Jv,PHI:()=>Yv,PI:()=>ob,PMT:()=>hw,POISSON:()=>Xv,POISSONDIST:()=>pC,POWER:()=>sb,PPMT:()=>gw,PRICEDISC:()=>_w,PROB:()=>Zv,PRODUCT:()=>cb,PROPER:()=>L_,PV:()=>vw,QUARTILE:()=>Qv,QUARTILEEXC:()=>mC,QUARTILEINC:()=>hC,QUOTIENT:()=>lb,RADIANS:()=>ub,RAND:()=>db,RANDBETWEEN:()=>fb,RANK:()=>$v,RANKAVG:()=>gC,RANKEQ:()=>_C,RATE:()=>yw,REPLACE:()=>R_,REPT:()=>z_,RIGHT:()=>B_,ROMAN:()=>pb,ROUND:()=>hb,ROUNDDOWN:()=>gb,ROUNDUP:()=>_b,ROW:()=>ey,ROWS:()=>h_,RRI:()=>bw,RSQ:()=>ty,SEARCH:()=>V_,SEC:()=>vb,SECH:()=>yb,SECOND:()=>mx,SERIESSUM:()=>bb,SIGN:()=>xb,SIN:()=>Sb,SINH:()=>Cb,SKEW:()=>ny,SKEWP:()=>vC,SLN:()=>xw,SLOPE:()=>ry,SMALL:()=>iy,SORT:()=>g_,SQRT:()=>wb,SQRTPI:()=>Tb,STANDARDIZE:()=>ay,STDEV:()=>oy,STDEVA:()=>sy,STDEVP:()=>yC,STDEVPA:()=>cy,STDEVS:()=>bC,STEYX:()=>ly,SUBSTITUTE:()=>H_,SUBTOTAL:()=>Eb,SUM:()=>Db,SUMIF:()=>Ob,SUMIFS:()=>kb,SUMPRODUCT:()=>Ab,SUMSQ:()=>jb,SUMX2MY2:()=>Mb,SUMX2PY2:()=>Nb,SUMXMY2:()=>Pb,SWITCH:()=>Rw,SYD:()=>Sw,T:()=>U_,TAKE:()=>__,TAN:()=>Fb,TANH:()=>Ib,TBILLEQ:()=>Cw,TBILLPRICE:()=>ww,TBILLYIELD:()=>Tw,TDIST:()=>xC,TDISTRT:()=>SC,TEXT:()=>W_,TEXTJOIN:()=>G_,TIME:()=>hx,TIMEVALUE:()=>gx,TINV:()=>CC,TODAY:()=>_x,TRANSPOSE:()=>v_,TREND:()=>uy,TRIM:()=>K_,TRIMMEAN:()=>dy,TRUE:()=>Iw,TRUNC:()=>Lb,TTEST:()=>wC,TYPE:()=>r_,UNICHAR:()=>q_,UNICODE:()=>J_,UNIQUE:()=>y_,UPPER:()=>Y_,VALUE:()=>X_,VAR:()=>fy,VARA:()=>py,VARP:()=>TC,VARPA:()=>my,VARS:()=>EC,VLOOKUP:()=>b_,VSTACK:()=>S_,WEEKDAY:()=>vx,WEEKNUM:()=>yx,WEIBULL:()=>hy,WEIBULLDIST:()=>DC,WORKDAY:()=>bx,WORKDAYINTL:()=>OC,XIRR:()=>Ew,XNPV:()=>Dw,XOR:()=>Lw,YEAR:()=>xx,YEARFRAC:()=>wx,Z:()=>gy,ZTEST:()=>kC,utils:()=>zw}),B=e(Wh(),1),qh=e(Gh(),1),Jh=Error(`#NULL!`),Yh=Error(`#DIV/0!`),V=Error(`#VALUE!`),Xh=Error(`#REF!`),Zh=Error(`#NAME?`),H=Error(`#NUM!`),U=Error(`#N/A`),Qh=Error(`#ERROR!`),$h=Error(`#GETTING_DATA`),eg=Error(`#CALC!`),tg=Object.freeze({__proto__:null,calc:eg,data:$h,div0:Yh,error:Qh,na:U,name:Zh,nil:Jh,num:H,ref:Xh,value:V}),ng=!1;function rg(){ng=!0}function ig(){ng=!1}function ag(e){e<60&&(e+=1);let t=Math.floor(e-25569)*86400,n=new Date(t*1e3),r=e-Math.floor(e)+1e-7,i=Math.floor(86400*r),a=i%60;i-=a;let o=Math.floor(i/3600),s=Math.floor(i/60)%60,c=n.getUTCDate(),l=n.getUTCMonth();return e>=60&&e<61&&(c=29,l=1),new Date(n.getUTCFullYear(),l,c,o,s,a)}function og(e){let t=new Date(1900,0,1),n=e>-22038912e5?2:1;return Math.ceil((e-t)/864e5)+n}var sg=Object.freeze({__proto__:null,dateToSerial:og,get returnSerial(){return ng},serialToDate:ag,useDate:ig,useSerial:rg}),cg=`=`,lg=[`>`,`>=`,`<`,`<=`,`=`,`<>`],ug=`operator`,dg=`literal`,fg=[ug,dg],pg=ug,mg=dg;function hg(e,t){if(fg.indexOf(t)===-1)throw Error(`Unsupported token type: `+t);return{value:e,type:t}}function gg(e){return typeof e==`string`&&/^\d+(\.\d+)?$/.test(e)&&(e=e.indexOf(`.`)===-1?parseInt(e,10):parseFloat(e)),e}function _g(e){let t=e.length,n=[],r=0,i=``,a=``;for(;r<t;){let t=e.charAt(r);switch(t){case`>`:case`<`:case`=`:a+=t,i.length>0&&(n.push(i),i=``);break;default:a.length>0&&(n.push(a),a=``),i+=t}r++}return i.length>0&&n.push(i),a.length>0&&n.push(a),n}function vg(e){let t=``,n=[];for(let r=0;r<e.length;r++){let i=e[r];r===0&&lg.indexOf(i)>=0?n.push(hg(i,pg)):t+=i}return t.length>0&&n.push(hg(gg(t),mg)),n.length>0&&n[0].type!==pg&&n.unshift(hg(cg,pg)),n}function yg(e){let t=[],n;for(let r=0;r<e.length;r++){let i=e[r];switch(i.type){case pg:n=i.value;break;case mg:t.push(i.value)}}return bg(t,n)}function bg(e,t){let n=!1;switch(t){case`>`:n=e[0]>e[1];break;case`>=`:n=e[0]>=e[1];break;case`<`:n=e[0]<e[1];break;case`<=`:n=e[0]<=e[1];break;case`=`:n=e[0]==e[1];break;case`<>`:n=e[0]!=e[1]}return n}function xg(e){return vg(_g(e))}var Sg=yg;function Cg(e){let t=[];return wg(e,e=>{t.push(e)}),t}function wg(e,t){let n=-1,r=e.length;for(;++n<r&&t(e[n],n,e)!==!1;);return e}function Tg(e){let t=e.length,n;for(;t--;)if(n=e[t],typeof n!=`number`){if(n===!0)e[t]=1;else if(n===!1)e[t]=0;else if(typeof n==`string`){let r=J(n);e[t]=r instanceof Error?0:r}}return e}function Eg(e){return[e.length,e.reduce((e,t)=>Math.max(e,t.length),0)]}function Dg(e,t){let n=[e,t];return n.some(e=>!Ug(e))?U:n.some(e=>e<=0)?V:Array.from({length:e},()=>Array.from({length:t},()=>void 0))}function Og(e,t){if(!e)return V;e.every(e=>Array.isArray(e))&&e.length!==0||(e=[[...e]]),e.map((t,n)=>{t.map((t,r)=>{t||(e[n][r]=0)})});let n=e.reduce((t,n,r)=>n.length>e[t].length?r:t,0),r=e[n].length;return e.map(e=>[...e,...Array(r-e.length).fill(0)])}function W(){let e;if(arguments.length===1){let t=arguments[0];e=jg(t)?Cg.apply(null,arguments):[t]}else e=Array.from(arguments);for(;!Mg(e);)e=kg(e);return e}function kg(e){return!e||!e.reduce?[e]:e.reduce((e,t)=>{let n=Array.isArray(e),r=Array.isArray(t);return n&&r?e.concat(t):n?(e.push(t),e):r?[e].concat(t):[e,t]})}function Ag(e,t){return t||=1,!e||typeof e.slice!=`function`?e:e.slice(0,e.length-t)}function jg(e){return e!=null&&typeof e.length==`number`&&typeof e!=`string`}function Mg(e){if(!e)return!1;for(let t=0;t<e.length;++t)if(Array.isArray(e[t]))return!1;return!0}function Ng(e,t){return t||=1,!e||typeof e.slice!=`function`?e:e.slice(t)}function Pg(e){return e?e[0].map((t,n)=>e.map(e=>e[n])):V}function Fg(e,t){let n=null;return wg(e,(e,r)=>{if(e[0]===t)return n=r,!1}),n??V}function G(){for(let e=0;e<arguments.length;e++)if(arguments[e]instanceof Error)return arguments[e]}function K(){let e=arguments.length;for(;e--;)if(arguments[e]instanceof Error)return!0;return!1}function Ig(e){let t=0x5af3107a4000;return Math.round(e*t)/t}function Lg(){return W.apply(null,arguments).filter(e=>typeof e==`number`)}function Rg(e){if(typeof e==`boolean`||e instanceof Error)return e;if(typeof e==`number`)return e!==0;if(typeof e==`string`){let t=e.toUpperCase();if(t===`TRUE`)return!0;if(t===`FALSE`)return!1}return e instanceof Date&&!isNaN(e)||V}function q(e){if(!isNaN(e)){if(e instanceof Date)return new Date(e);let t=parseFloat(e);return t<0||t>=2958466?H:ag(t)}return typeof e==`string`&&(e=/(\d{4})-(\d\d?)-(\d\d?)$/.test(e)?new Date(e+`T00:00:00.000`):new Date(e),!isNaN(e))?e:V}function zg(e){let t=e.length,n;for(;t--;){if(n=q(e[t]),n===V)return n;e[t]=n}return e}function J(e){return e instanceof Error?e:e==null?0:(typeof e==`boolean`&&(e=+e),!isNaN(e)&&e!==``?parseFloat(e):V)}function Y(e){let t;if(!e||(t=e.length)===0)return V;let n;for(;t--;){if(e[t]instanceof Error)return e[t];if(n=J(e[t]),n instanceof Error)return n;e[t]=n}return e}function Bg(e){return e instanceof Error?e:e==null?``:e.toString()}function Vg(){let e=arguments.length;for(;e--;)if(typeof arguments[e]==`string`)return!0;return!1}function Hg(){let e=Cg(arguments),t=Y(W(e.shift()));if(t instanceof Error)return t;let n=e,r=n.length/2;for(let e=0;e<r;e++)n[e*2]=W(n[e*2]);let i=[];for(let e=0;e<t.length;e++){let a=!1;for(let t=0;t<r;t++){let r=n[t*2][e],i=n[t*2+1],o=i===void 0||i===`*`,s=!1;if(o)s=!0;else{let e=xg(i+``);s=Sg([hg(r,mg)].concat(e))}if(!s){a=!1;break}a=!0}a&&i.push(t[e])}return i}function Ug(e){return e!=null}var Wg={};Wg.TYPE=e=>{switch(e){case Jh:return 1;case Yh:return 2;case V:return 3;case Xh:return 4;case Zh:return 5;case H:return 6;case U:return 7;case $h:return 8}return U};function Gg(e){return e===null}function Kg(e){return[V,Xh,Yh,H,Zh,Jh].indexOf(e)>=0||typeof e==`number`&&(isNaN(e)||!isFinite(e))}function qg(e){return Kg(e)||e===U}function Jg(e){return!(Math.floor(Math.abs(e))&1)}function Yg(e){return e===!0||e===!1}function Xg(e){return e===U}function Zg(e){return typeof e!=`string`}function Qg(e){return typeof e==`number`&&!isNaN(e)&&isFinite(e)}function $g(e){return!!(Math.floor(Math.abs(e))&1)}function e_(e){return typeof e==`string`}function t_(e){return Qg(e)?e:e instanceof Date?e.getTime():e===!0?1:e===!1?0:qg(e)?e:0}function n_(){return U}function r_(e){if(Qg(e))return 1;if(e_(e))return 2;if(Yg(e))return 4;if(qg(e))return 16;if(Array.isArray(e))return 64}function i_(){if(arguments.length<2)return U;let e=arguments[0];return e<1||e>254||arguments.length<e+1?V:arguments[e]}function a_(e,t,...n){if(!Array.isArray(e))return V;let r=W([t,...n]),[i,a]=Eg(e);if(r.some(e=>{if(!Ug(e))return!0;let t=Math.abs(e);return!(0<t&&t<=a)}))return V;let o=r.map(e=>e<0?e+a+1:e),s=Array(i);for(let t=0;t<i;t++){s[t]=Array(o.length);for(let n=0;n<o.length;n++)s[t][n]=e[t][o[n]-1]??0}return s}function o_(e,t,...n){if(!Array.isArray(e))return V;let r=W([t,...n]);return r.some(t=>{if(!Ug(t))return!0;let n=Math.abs(t);return!(0<n&&n<=e.length)})?V:r.map(t=>t<0?t+e.length+1:t).reduce((t,n)=>{let r=[...e[--n]].map(e=>Ug(e)?e:0);return t.push(r),t},[])}function s_(e,t){if(arguments.length!==2)return U;if(t<0)return H;if(!(e instanceof Array)||typeof t!=`number`)return V;if(e.length!==0)return B.default.col(e,t)}function c_(e){return arguments.length===1?e instanceof Array?e.length===0?0:B.default.cols(e):V:U}function l_(e,t,n){if(K(e,t,n))return G(e,t,n);if(!(e instanceof Array))return V;let r=[],[i,a]=Eg(e),o=0,s=i;if(typeof t==`number`){if(Math.abs(t)>i)return eg;t>0?o=t:t<0&&(s+=t)}let c=0,l=a;if(typeof n==`number`){if(Math.abs(n)>a)return eg;n>0?c=n:n<0&&(l+=n)}for(let t=o;t<s;t++){let n=[...e[t].slice(c,l).map(e=>e??0)];r.push(n)}return r}function u_(e,t,n,r){let[i,a]=Eg(e);if(Ug(t)||(t=i),Ug(n)||(n=a),t<i||n<a)return V;let o=Dg(t,n);for(let s=0;s<t;s++)for(let t=0;t<n;t++){let n=e[s]?.[t];Ug(n)||(n=s<i&&t<a?0:r??U),o[s][t]=n}return o}function d_(e,t,n,r){return b_(e,Pg(t),n,r)}function f_(e,t,n){let r=G(e,t,n);if(r)return r;if(!Array.isArray(e))return V;let i=e.length>0&&!Array.isArray(e[0]);return i&&!n?(n=t,t=1):(n||=1,t||=1),n<0||t<0?V:i&&t===1&&n<=e.length?e[n-1]:t<=e.length&&n<=e[t-1].length?e[t-1][n-1]:Xh}function p_(e,t,n){t=W(t),n=n?W(n):t;let r=typeof e==`number`,i=U;for(let a=0;a<t.length;a++)if(t[a]===e)return n[a];else if(r&&t[a]<=e||typeof t[a]==`string`&&t[a].localeCompare(e)<0)i=n[a];else if(r&&t[a]>e)return i;return i}function m_(e,t,n){if(!e&&e!==0||!t||(arguments.length===2&&(n=1),t=W(t),!(t instanceof Array))||n!==-1&&n!==0&&n!==1)return U;let r,i;for(let a=0;a<t.length;a++)if(n===1){if(t[a]===e)return a+1;t[a]<e&&(i?t[a]>i&&(r=a+1,i=t[a]):(r=a+1,i=t[a]))}else if(n===0){if(typeof e==`string`&&typeof t[a]==`string`){let n=e.toLowerCase().replace(/\?/g,`.`).replace(/\*/g,`.*`).replace(/~/g,`\\`).replace(/\+/g,`\\+`).replace(/\(/g,`\\(`).replace(/\)/g,`\\)`).replace(/\[/g,`\\[`).replace(/\]/g,`\\]`);if(RegExp(`^`+n+`$`).test(t[a].toLowerCase()))return a+1}else if(t[a]===e)return a+1}else if(n===-1){if(t[a]===e)return a+1;t[a]>e&&(i?t[a]<i&&(r=a+1,i=t[a]):(r=a+1,i=t[a]))}return r||U}function h_(e){return arguments.length===1?e instanceof Array?e.length===0?0:B.default.rows(e):V:U}function g_(e,t=1,n=1,r=!1){if(!e||!Array.isArray(e))return U;if(e.length===0)return 0;if(t=J(t),!t||t<1||(n=J(n),n!==1&&n!==-1))return V;if(r=Rg(r),typeof r!=`boolean`)return Zh;let i=e=>e.sort((e,r)=>(e=Bg(e[t-1]),r=Bg(r[t-1]),n===1?e<r?n*-1:n:e>r?n:n*-1)),a=Og(e),o=r?Pg(a):a;return t>=1&&t<=o[0].length?r?Pg(i(o)):i(o):V}function __(e,t,n){if(K(e,t,n))return G(e,t,n);if(!(e instanceof Array))return V;let[r,i]=Eg(e),a=0,o=r-1;if(typeof t==`number`){if(t===0)return eg;Math.abs(t)<=r&&(t<0?a=r+t:o=t-1)}let s=0,c=i-1;if(typeof n==`number`){if(n===0)return eg;Math.abs(n)<=i&&(n<0?s=i+n:c=n-1)}let l=Dg(o-a+1,c-s+1),u=-1,d;for(let t=a;t<=o;t++){u++,d=-1;for(let n=s;n<=c;n++)l[u][++d]=e[t]?.[n]??0}return l}function v_(e){return e?Pg(Og(e)):U}function y_(){let e=[];for(let t=0;t<arguments.length;++t){let n=!1,r=arguments[t];for(let t=0;t<e.length&&(n=e[t]===r,!n);++t);n||e.push(r)}return e}function b_(e,t,n,r){if(!t||!n)return U;r=r!==0&&r!==!1;let i=U,a=!1,o=typeof e==`number`,s=typeof e==`string`?e.toLowerCase():e;for(let c=0;c<t.length;c++){let l=t[c],u=typeof l[0]==`string`?l[0].toLowerCase():l[0];if(u===s){i=n<l.length+1?l[n-1]:Xh;break}!a&&(o&&r&&u<=e||r&&typeof u==`string`&&u.localeCompare(e)<0)&&(i=n<l.length+1?l[n-1]:Xh),o&&u>e&&(a=!0)}return i}function x_(e,...t){let n=[e,...t],r=0,i=0,a=[];for(let e of n){let[t,n]=Eg(e);r=Math.max(r,t),i+=n,a.push(n)}let o=Array.from({length:r},()=>Array(i)),s=0;for(let e=0;e<n.length;e++){let t=n[e],i=a[e];for(let e=0;e<i;e++){for(let n=0;n<r;n++)o[n][s]=t[n]?.[e]??(n<t.length?0:U);s++}}return o}function S_(e,...t){let n=[e,...t],r=0,i=0;for(let e of n){let[t,n]=Eg(e);r=Math.max(r,n),i+=t}let a=Array(i),o,s=-1;for(;(o=n.shift())!==void 0;)for(let e=0;e<o.length;e++){a[++s]=Array(r);for(let t=0;t<r;t++)a[s][t]=o[e][t]??(t<o[e].length?0:U)}return a}function C_(e){return e=J(e),e===0?V:e instanceof Error?e:String.fromCharCode(e)}function w_(e){return K(e)?e:(e||=``,e.replace(/[\0-\x1F]/g,``))}function T_(e){if(K(e))return e;e||=``;let t=e.charCodeAt(0);return isNaN(t)&&(t=V),t}function E_(){let e=W(arguments),t=G.apply(void 0,e);if(t)return t;let n=0;for(;(n=e.indexOf(!0))>-1;)e[n]=`TRUE`;let r=0;for(;(r=e.indexOf(!1))>-1;)e[r]=`FALSE`;return e.join(``)}var D_=E_;function O_(e,t=2){if(e=J(e),isNaN(e))return V;e=hb(e,t);let n={style:`currency`,currency:`USD`,minimumFractionDigits:t>=0?t:0,maximumFractionDigits:t>=0?t:0},r=e.toLocaleString(`en-US`,n);return e<0?`$(`+r.slice(2)+`)`:r}function k_(e,t){return arguments.length===2?G(e,t)||(e=Bg(e),t=Bg(t),e===t):U}function A_(e,t,n){if(arguments.length<2)return U;e=Bg(e),t=Bg(t),n=n===void 0?0:n;let r=t.indexOf(e,n-1);return r===-1?V:r+1}function j_(e,t=2,n=!1){if(e=J(e),isNaN(e)||(t=J(t),isNaN(t)))return V;if(t<0){let n=10**-t;e=Math.round(e/n)*n}else e=e.toFixed(t);if(n)e=e.toString().replace(/,/g,``);else{let t=e.toString().split(`.`);t[0]=t[0].replace(/\B(?=(\d{3})+$)/g,`,`),e=t.join(`.`)}return e}function M_(e,t){return G(e,t)||(e=Bg(e),t=t===void 0?1:t,t=J(t),t instanceof Error||typeof e!=`string`?V:e.substring(0,t))}function N_(e){return arguments.length===0?Qh:e instanceof Error?e:Array.isArray(e)?V:Bg(e).length}function P_(e){return arguments.length===1?(e=Bg(e),K(e)?e:e.toLowerCase()):V}function F_(e,t,n){if(K(e,t,n))return G(e,t,n);let r=[t,n].map(e=>J(e));if(!r.every(e=>!(e instanceof Error)&&e>0))return V;Ug(e)?typeof e!=`string`&&(e=String(e)):e=``,[t,n]=r;let i=t-1,a=i+n;return e.substring(i,a)}function I_(e,t,n){return e=Ug(e)?e:``,typeof e==`number`?e:typeof e==`string`?(t=t===void 0?`.`:t,n=n===void 0?`,`:n,Number(e.replace(t,`.`).replace(n,``))):U}function L_(e){return K(e)?e:isNaN(e)&&typeof e==`number`?V:(e=Bg(e),e.replace(/\w\S*/g,e=>e.charAt(0).toUpperCase()+e.substr(1).toLowerCase()))}function R_(e,t,n,r){return t=J(t),n=J(n),K(t,n)||typeof e!=`string`||typeof r!=`string`?V:e.substr(0,t-1)+r+e.substr(t-1+n)}function z_(e,t){return G(e,t)||(e=Bg(e),t=J(t),t instanceof Error?t:Array(t+1).join(e))}function B_(e,t){return G(e,t)||(e=Bg(e),t=t===void 0?1:t,t=J(t),t instanceof Error?t:e.substring(e.length-t))}function V_(e,t,n){let r;return typeof e!=`string`||typeof t!=`string`?V:(n=n===void 0?0:n,r=t.toLowerCase().indexOf(e.toLowerCase(),n-1)+1,r===0?V:r)}function H_(e,t,n,r){if(arguments.length<3)return U;if(!e||!t)return e;if(r===void 0)return e.split(t).join(n);{if(r=Math.floor(Number(r)),Number.isNaN(r)||r<=0)return V;let i=0,a=0;for(;i>-1&&e.indexOf(t,i)>-1;)if(i=e.indexOf(t,i+1),a++,i>-1&&a===r)return e.substring(0,i)+n+e.substring(i+t.length);return e}}function U_(e){return e instanceof Error||typeof e==`string`?e:``}function W_(e,t){if(e===void 0||e instanceof Error||t instanceof Error)return U;if(e instanceof Date)return e.toISOString().slice(0,10);if(t==null)return``;if(typeof t==`number`)return String(t);if(typeof t!=`string`)return V;let n=t.startsWith(`$`)?`$`:``,r=t.endsWith(`%`);t=t.replace(/%/g,``).replace(/\$/g,``);let i=t.includes(`.`)?t.split(`.`)[1].match(/0/g).length:0,a=!t.includes(`,`);return r&&(e*=100),e=j_(e,i,a),e.startsWith(`-`)?(e=e.replace(`-`,``),e=`-`+n+e):e=n+e,r&&(e+=`%`),e}function G_(e,t,...n){if(typeof t!=`boolean`&&(t=Rg(t)),arguments.length<3)return U;e??=``;let r=W(n),i=t?r.filter(e=>e):r;if(Array.isArray(e)){e=W(e);let t=i.map(e=>[e]),n=0;for(let r=0;r<t.length-1;r++)t[r].push(e[n]),n++,n===e.length&&(n=0);return i=W(t),i.join(``)}return i.join(e)}function K_(e){return e=Bg(e),e instanceof Error?e:e.replace(/\s+/g,` `).trim()}var q_=C_,J_=T_;function Y_(e){return e=Bg(e),e instanceof Error?e:e.toUpperCase()}function X_(e){let t=G(e);if(t)return t;if(typeof e==`number`)return e;if(Ug(e)||(e=``),typeof e!=`string`)return V;let n=/(%)$/.test(e)||/^(%)/.test(e);if(e=e.replace(/^[^0-9-]{0,3}/,``),e=e.replace(/[^0-9]{0,3}$/,``),e=e.replace(/[ ,]/g,``),e===``)return 0;let r=Number(e);return isNaN(r)?V:(r||=0,n&&(r*=.01),r)}var Z_=2.5066282746310002;function Q_(){let e=W(arguments).filter(Ug);if(e.length===0)return H;let t=Y(e);return t instanceof Error?t:B.default.sum((0,B.default)(t).subtract(B.default.mean(t)).abs()[0])/t.length}function $_(){let e=W(arguments).filter(Ug);if(e.length===0)return Yh;let t=G.apply(void 0,e);if(t)return t;let n=Lg(e),r=n.length,i=0,a=0,o;for(let e=0;e<r;e++)i+=n[e],a+=1;return o=i/a,isNaN(o)&&(o=H),o}function ev(){let e=W(arguments).filter(Ug);if(e.length===0)return Yh;let t=G.apply(void 0,e);if(t)return t;let n=e,r=n.length,i=0,a=0,o;for(let e=0;e<r;e++){let t=n[e];typeof t==`number`&&(i+=t),t===!0&&i++,t!==null&&a++}return o=i/a,isNaN(o)&&(o=H),o}function tv(e,t,n){if(arguments.length<=1)return U;if(n||=e,n=Y(W(n).filter(Ug)),e=W(e),n instanceof Error)return n;let r=0,i=0,a=t===void 0||t===`*`,o=a?null:xg(t+``);for(let t=0;t<e.length;t++){let s=e[t];(a||Sg([hg(s,mg)].concat(o)))&&(i+=n[t],r++)}return i/r}function nv(){let e=Hg(...arguments),t=e.reduce((e,t)=>e+t,0)/e.length;return isNaN(t)?0:t}var rv={};rv.DIST=function(e,t,n,r,i,a){return arguments.length<4||(i=i===void 0?0:i,a=a===void 0?1:a,e=J(e),t=J(t),n=J(n),i=J(i),a=J(a),K(e,t,n,i,a))?V:(e=(e-i)/(a-i),r?B.default.beta.cdf(e,t,n):B.default.beta.pdf(e,t,n))},rv.INV=(e,t,n,r,i)=>(r=r===void 0?0:r,i=i===void 0?1:i,e=J(e),t=J(t),n=J(n),r=J(r),i=J(i),K(e,t,n,r,i)?V:B.default.beta.inv(e,t,n)*(i-r)+r);var iv={};iv.DIST=(e,t,n,r)=>(e=J(e),t=J(t),n=J(n),r=J(r),K(e,t,n,r)?V:r?B.default.binomial.cdf(e,t,n):B.default.binomial.pdf(e,t,n)),iv.DIST.RANGE=(e,t,n,r)=>{if(r=r===void 0?n:r,e=J(e),t=J(t),n=J(n),r=J(r),K(e,t,n,r))return V;let i=0;for(let a=n;a<=r;a++)i+=jy(e,a)*t**+a*(1-t)**(e-a);return i},iv.INV=(e,t,n)=>{if(e=J(e),t=J(t),n=J(n),K(e,t,n))return V;let r=0;for(;r<=e;){if(B.default.binomial.cdf(r,e,t)>=n)return r;r++}};var av={};av.DIST=(e,t,n)=>(e=J(e),t=J(t),K(e,t)?V:n?B.default.chisquare.cdf(e,t):B.default.chisquare.pdf(e,t)),av.DIST.RT=(e,t)=>!e|!t?U:e<1||t>10**10?H:typeof e!=`number`||typeof t!=`number`?V:1-B.default.chisquare.cdf(e,t),av.INV=(e,t)=>(e=J(e),t=J(t),K(e,t)?V:B.default.chisquare.inv(e,t)),av.INV.RT=(e,t)=>!e|!t?U:e<0||e>1||t<1||t>10**10?H:typeof e!=`number`||typeof t!=`number`?V:B.default.chisquare.inv(1-e,t),av.TEST=function(e,t){if(arguments.length!==2)return U;if(!(e instanceof Array)||!(t instanceof Array)||e.length!==t.length||e[0]&&t[0]&&e[0].length!==t[0].length)return V;let n=e.length,r,i,a;for(i=0;i<n;i++)e[i]instanceof Array||(r=e[i],e[i]=[],e[i].push(r)),t[i]instanceof Array||(r=t[i],t[i]=[],t[i].push(r));let o=e[0].length,s=o===1?n-1:(n-1)*(o-1),c=0,l=Math.PI;for(i=0;i<n;i++)for(a=0;a<o;a++)c+=(e[i][a]-t[i][a])**2/t[i][a];function u(e,t){let n=Math.exp(-.5*e);t%2==1&&(n*=Math.sqrt(2*e/l));let r=t;for(;r>=2;)n=n*e/r,r-=2;let i=n,a=t;for(;i>1e-10*n;)a+=2,i=i*e/a,n+=i;return 1-n}return Math.round(u(c,s)*1e6)/1e6};var ov={};ov.NORM=(e,t,n)=>(e=J(e),t=J(t),n=J(n),K(e,t,n)?V:B.default.normalci(1,e,t,n)[1]-1),ov.T=(e,t,n)=>(e=J(e),t=J(t),n=J(n),K(e,t,n)?V:B.default.tci(1,e,t,n)[1]-1);function sv(e,t){return e=Y(W(e)),t=Y(W(t)),K(e,t)?V:B.default.corrcoeff(e,t)}function cv(){return Lg(W(arguments)).length}function lv(){let e=W(arguments);return e.length-uv(e)}function uv(){let e=W(arguments),t=0,n;for(let r=0;r<e.length;r++)n=e[r],(n==null||n===``)&&t++;return t}function dv(e,t){if(e=W(e),t===void 0||t===`*`)return e.length;let n=0,r=xg(t+``);for(let t=0;t<e.length;t++){let i=e[t];Sg([hg(i,mg)].concat(r))&&n++}return n}function fv(){let e=Cg(arguments),t=Array(W(e[0]).length);for(let e=0;e<t.length;e++)t[e]=!0;for(let n=0;n<e.length;n+=2){let r=W(e[n]),i=e[n+1];if(i!==void 0&&i!==`*`){let e=xg(i+``);for(let n=0;n<r.length;n++){let i=r[n],a=[hg(i,mg)].concat(e);t[n]=t[n]&&Sg(a)}}}let n=0;for(let e=0;e<t.length;e++)t[e]&&n++;return n}var pv={};pv.P=(e,t)=>{if(e=Y(W(e)),t=Y(W(t)),K(e,t))return V;let n=B.default.mean(e),r=B.default.mean(t),i=0,a=e.length;for(let o=0;o<a;o++)i+=(e[o]-n)*(t[o]-r);return i/a},pv.S=(e,t)=>(e=Y(W(e)),t=Y(W(t)),K(e,t)?V:B.default.covariance(e,t));function mv(){let e=Y(W(arguments));if(e instanceof Error)return e;let t=B.default.mean(e),n=0;for(let r=0;r<e.length;r++)n+=(e[r]-t)**2;return n}var hv={};hv.DIST=(e,t,n)=>(e=J(e),t=J(t),K(e,t)?V:n?B.default.exponential.cdf(e,t):B.default.exponential.pdf(e,t));var gv={};gv.DIST=(e,t,n,r)=>(e=J(e),t=J(t),n=J(n),K(e,t,n)?V:r?B.default.centralF.cdf(e,t,n):B.default.centralF.pdf(e,t,n)),gv.DIST.RT=function(e,t,n){return arguments.length===3?e<0||t<1||n<1?H:typeof e!=`number`||typeof t!=`number`||typeof n!=`number`?V:1-B.default.centralF.cdf(e,t,n):U},gv.INV=(e,t,n)=>(e=J(e),t=J(t),n=J(n),K(e,t,n)?V:e<=0||e>1?H:B.default.centralF.inv(e,t,n)),gv.INV.RT=function(e,t,n){return arguments.length===3?e<0||e>1||t<1||t>10**10||n<1||n>10**10?H:typeof e!=`number`||typeof t!=`number`||typeof n!=`number`?V:B.default.centralF.inv(1-e,t,n):U},gv.TEST=(e,t)=>{if(!e||!t||!(e instanceof Array)||!(t instanceof Array))return U;if(e.length<2||t.length<2)return Yh;let n=(e,t)=>{let n=0;for(let r=0;r<e.length;r++)n+=(e[r]-t)**2;return n},r=Db(e)/e.length,i=Db(t)/t.length;return n(e,r)/(e.length-1)/(n(t,i)/(t.length-1))};function _v(e){return e=J(e),e instanceof Error?e:Math.log((1+e)/(1-e))/2}function vv(e){if(e=J(e),e instanceof Error)return e;let t=Math.exp(2*e);return(t-1)/(t+1)}function yv(e,t,n){if(e=J(e),t=Y(W(t)),n=Y(W(n)),K(e,t,n))return V;let r=B.default.mean(n),i=B.default.mean(t),a=n.length,o=0,s=0;for(let e=0;e<a;e++)o+=(n[e]-r)*(t[e]-i),s+=(n[e]-r)**2;let c=o/s;return i-c*r+c*e}function bv(e,t){if(e=Y(W(e)),t=Y(W(t)),K(e,t))return V;let n=e.length,r=t.length,i=[];for(let a=0;a<=r;a++){i[a]=0;for(let o=0;o<n;o++)a===0?e[o]<=t[0]&&(i[0]+=1):a<r?e[o]>t[a-1]&&e[o]<=t[a]&&(i[a]+=1):a===r&&e[o]>t[r-1]&&(i[r]+=1)}return i}function xv(e){return e=J(e),e instanceof Error?e:e===0||parseInt(e,10)===e&&e<0?H:B.default.gammafn(e)}xv.DIST=function(e,t,n,r){return arguments.length===4?e<0||t<=0||n<=0||typeof e!=`number`||typeof t!=`number`||typeof n!=`number`?V:r?B.default.gamma.cdf(e,t,n,!0):B.default.gamma.pdf(e,t,n,!1):U},xv.INV=function(e,t,n){return arguments.length===3?e<0||e>1||t<=0||n<=0?H:typeof e!=`number`||typeof t!=`number`||typeof n!=`number`?V:B.default.gamma.inv(e,t,n):U};function Sv(e){return e=J(e),e instanceof Error?e:B.default.gammaln(e)}Sv.PRECISE=function(e){return arguments.length===1?e<=0?H:typeof e==`number`?B.default.gammaln(e):V:U};function Cv(e){return e=J(e),e instanceof Error?e:B.default.normal.cdf(e,0,1)-.5}function wv(){let e=Y(W(arguments));return e instanceof Error?e:B.default.geomean(e)}function Tv(e,t,n,r){if(e=Y(W(e)),e instanceof Error)return e;let i;if(t===void 0)for(t=[],i=1;i<=e.length;i++)t.push(i);if(n===void 0&&(n=t),t=Y(W(t)),n=Y(W(n)),K(t,n))return V;r===void 0&&(r=!0);let a=e.length,o=0,s=0,c=0,l=0;for(i=0;i<a;i++){let n=t[i],r=Math.log(e[i]);o+=n,s+=r,c+=n*r,l+=n*n}o/=a,s/=a,c/=a,l/=a;let u,d;r?(u=(c-o*s)/(l-o*o),d=s-u*o):(u=c/l,d=0);let f=[];for(i=0;i<n.length;i++)f.push(Math.exp(d+u*n[i]));return f}function Ev(){let e=Y(W(arguments));if(e instanceof Error)return e;let t=e.length,n=0;for(let r=0;r<t;r++)n+=1/e[r];return t/n}var Dv={};Dv.DIST=(e,t,n,r,i)=>{if(e=J(e),t=J(t),n=J(n),r=J(r),K(e,t,n,r))return V;function a(e,t,n,r){return jy(n,e)*jy(r-n,t-e)/jy(r,t)}function o(e,t,n,r){let i=0;for(let o=0;o<=e;o++)i+=a(o,t,n,r);return i}return i?o(e,t,n,r):a(e,t,n,r)};function Ov(e,t){return e=Y(e),t=Y(t),K(e,t)?V:e.length===t.length?yv(0,e,t):U}function kv(){let e=Y(W(arguments));if(e instanceof Error)return e;let t=B.default.mean(e),n=e.length,r=0;for(let i=0;i<n;i++)r+=(e[i]-t)**4;return r/=B.default.stdev(e,!0)**4,n*(n+1)/((n-1)*(n-2)*(n-3))*r-3*(n-1)*(n-1)/((n-2)*(n-3))}function Av(e,t){return G.apply(void 0,e)||(K(t)?t:(e=Lg(W(e)),t=J(t),t<0||e.length<t?V:e.sort((e,t)=>t-e)[t-1]))}function jv(e,t){if(e=Y(W(e)),t=Y(W(t)),K(e,t))return V;let n=B.default.mean(e),r=B.default.mean(t),i=t.length,a=0,o=0;for(let s=0;s<i;s++)a+=(t[s]-r)*(e[s]-n),o+=(t[s]-r)**2;let s=a/o;return[s,n-s*r]}function Mv(e,t){if(e=Y(W(e)),t=Y(W(t)),K(e,t)||e.length!==t.length)return V;for(let t=0;t<e.length;t++)e[t]=Math.log(e[t]);let n=jv(e,t);return n[0]=Math.round(Math.exp(n[0])*1e6)/1e6,n[1]=Math.round(Math.exp(n[1])*1e6)/1e6,n}var Nv={};Nv.DIST=(e,t,n,r)=>(e=J(e),t=J(t),n=J(n),K(e,t,n)?V:r?B.default.lognormal.cdf(e,t,n):B.default.lognormal.pdf(e,t,n)),Nv.INV=(e,t,n)=>(e=J(e),t=J(t),n=J(n),K(e,t,n)?V:B.default.lognormal.inv(e,t,n));function Pv(){let e=W(arguments),t=G.apply(void 0,e);if(t)return t;let n=Lg(e);return n.length===0?0:Math.max.apply(Math,n)}function Fv(){let e=W(arguments),t=G.apply(void 0,e);if(t)return t;let n=Tg(e);return n=n.map(e=>e??0),n.length===0?0:Math.max.apply(Math,n)}function Iv(){let e=Hg(...arguments);return e.length===0?0:Math.max.apply(Math,e)}function Lv(){let e=W(arguments),t=G.apply(void 0,e);if(t)return t;let n=Tg(e),r=B.default.median(n);return isNaN(r)&&(r=H),r}function Rv(){let e=W(arguments),t=G.apply(void 0,e);if(t)return t;let n=Lg(e);return n.length===0?0:Math.min.apply(Math,n)}function zv(){let e=W(arguments),t=G.apply(void 0,e);if(t)return t;let n=Tg(e);return n=n.map(e=>e??0),n.length===0?0:Math.min.apply(Math,n)}function Bv(){let e=Hg(...arguments);return e.length===0?0:Math.min.apply(Math,e)}var Vv={};Vv.MULT=function(){let e=Y(W(arguments));if(e instanceof Error)return e;let t=e.length,n={},r=[],i=0,a;for(let o=0;o<t;o++)a=e[o],n[a]=n[a]?n[a]+1:1,n[a]>i&&(i=n[a],r=[]),n[a]===i&&(r[r.length]=a);return r},Vv.SNGL=function(){let e=Y(W(arguments));return e instanceof Error?e:Vv.MULT(e).sort((e,t)=>e-t)[0]};var Hv={};Hv.DIST=(e,t,n,r)=>(e=J(e),t=J(t),n=J(n),K(e,t,n)?V:r?B.default.negbin.cdf(e,t,n):B.default.negbin.pdf(e,t,n));var Uv={};Uv.DIST=(e,t,n,r)=>(e=J(e),t=J(t),n=J(n),K(e,t,n)?V:n<=0?H:r?B.default.normal.cdf(e,t,n):B.default.normal.pdf(e,t,n)),Uv.INV=(e,t,n)=>(e=J(e),t=J(t),n=J(n),K(e,t,n)?V:B.default.normal.inv(e,t,n)),Uv.S={},Uv.S.DIST=(e,t)=>(e=J(e),e instanceof Error?V:t?B.default.normal.cdf(e,0,1):B.default.normal.pdf(e,0,1)),Uv.S.INV=e=>(e=J(e),e instanceof Error?V:B.default.normal.inv(e,0,1));function Wv(e,t){if(t=Y(W(t)),e=Y(W(e)),K(t,e))return V;let n=B.default.mean(e),r=B.default.mean(t),i=e.length,a=0,o=0,s=0;for(let c=0;c<i;c++)a+=(e[c]-n)*(t[c]-r),o+=(e[c]-n)**2,s+=(t[c]-r)**2;return a/Math.sqrt(o*s)}var Gv={};Gv.EXC=(e,t)=>{if(e=Y(W(e)),t=J(t),K(e,t))return V;e=e.sort((e,t)=>e-t);let n=e.length;if(t<1/(n+1)||t>1-1/(n+1))return H;let r=t*(n+1)-1,i=Math.floor(r);return Ig(r===i?e[r]:e[i]+(r-i)*(e[i+1]-e[i]))},Gv.INC=(e,t)=>{if(e=Y(W(e)),t=J(t),K(e,t))return V;e=e.sort((e,t)=>e-t);let n=e.length,r=t*(n-1),i=Math.floor(r);return Ig(r===i?e[r]:e[i]+(r-i)*(e[i+1]-e[i]))};var Kv={};Kv.EXC=(e,t,n)=>{if(n=n===void 0?3:n,e=Y(W(e)),t=J(t),n=J(n),K(e,t,n))return V;e=e.sort((e,t)=>e-t);let r=y_.apply(null,e),i=e.length,a=r.length,o=10**n,s=0,c=!1,l=0;for(;!c&&l<a;)t===r[l]?(s=(e.indexOf(r[l])+1)/(i+1),c=!0):t>=r[l]&&(t<r[l+1]||l===a-1)&&(s=(e.indexOf(r[l])+1+(t-r[l])/(r[l+1]-r[l]))/(i+1),c=!0),l++;return Math.floor(s*o)/o},Kv.INC=(e,t,n)=>{if(n=n===void 0?3:n,e=Y(W(e)),t=J(t),n=J(n),K(e,t,n))return V;e=e.sort((e,t)=>e-t);let r=y_.apply(null,e),i=e.length,a=r.length,o=10**n,s=0,c=!1,l=0;for(;!c&&l<a;)t===r[l]?(s=e.indexOf(r[l])/(i-1),c=!0):t>=r[l]&&(t<r[l+1]||l===a-1)&&(s=(e.indexOf(r[l])+(t-r[l])/(r[l+1]-r[l]))/(i-1),c=!0),l++;return Math.floor(s*o)/o};function qv(e,t){return e=J(e),t=J(t),K(e,t)?V:Wy(e)/Wy(e-t)}function Jv(e,t){return e=J(e),t=J(t),K(e,t)?V:e**+t}function Yv(e){return e=J(e),e instanceof Error?V:Math.exp(-.5*e*e)/Z_}var Xv={};Xv.DIST=(e,t,n)=>(e=J(e),t=J(t),K(e,t)?V:n?B.default.poisson.cdf(e,t):B.default.poisson.pdf(e,t));function Zv(e,t,n,r){if(n===void 0)return 0;if(r=r===void 0?n:r,e=Y(W(e)),t=Y(W(t)),n=J(n),r=J(r),K(e,t,n,r))return V;if(n===r)return e.indexOf(n)>=0?t[e.indexOf(n)]:0;let i=e.sort((e,t)=>e-t),a=i.length,o=0;for(let s=0;s<a;s++)i[s]>=n&&i[s]<=r&&(o+=t[e.indexOf(i[s])]);return o}var Qv={};Qv.EXC=(e,t)=>{if(e=Y(Lg(W(e))),t=J(t),K(e,t))return V;switch(t){case 1:return Gv.EXC(e,.25);case 2:return Gv.EXC(e,.5);case 3:return Gv.EXC(e,.75);default:return H}},Qv.INC=(e,t)=>{if(e=Y(Lg(W(e))),t=J(t),K(e,t))return V;switch(t){case 1:return Gv.INC(e,.25);case 2:return Gv.INC(e,.5);case 3:return Gv.INC(e,.75);default:return H}};var $v={};$v.AVG=(e,t,n)=>{if(e=J(e),t=Y(W(t)),K(e,t))return V;t=W(t),n||=!1;let r=n?(e,t)=>e-t:(e,t)=>t-e;t=t.sort(r);let i=t.length,a=0;for(let n=0;n<i;n++)t[n]===e&&a++;return a>1?(2*t.indexOf(e)+a+1)/2:t.indexOf(e)+1},$v.EQ=(e,t,n)=>{if(e=J(e),t=Y(W(t)),K(e,t))return V;n||=!1;let r=n?(e,t)=>e-t:(e,t)=>t-e;return t=t.sort(r),t.indexOf(e)+1};function ey(e,t){if(arguments.length!==2)return U;if(t<0)return H;if(!(e instanceof Array)||typeof t!=`number`)return V;if(e.length!==0)return B.default.row(e,t)}function ty(e,t){return e=Y(W(e)),t=Y(W(t)),K(e,t)?V:Wv(e,t)**2}function ny(){let e=Y(W(arguments));if(e instanceof Error)return e;let t=B.default.mean(e),n=e.length,r=0;for(let i=0;i<n;i++)r+=(e[i]-t)**3;return n*r/((n-1)*(n-2)*B.default.stdev(e,!0)**3)}ny.P=function(){let e=Y(W(arguments));if(e instanceof Error)return e;let t=B.default.mean(e),n=e.length,r=0,i=0;for(let a=0;a<n;a++)i+=(e[a]-t)**3,r+=(e[a]-t)**2;return i/=n,r/=n,i/r**(3/2)};function ry(e,t){if(e=Y(W(e)),t=Y(W(t)),K(e,t))return V;let n=B.default.mean(t),r=B.default.mean(e),i=t.length,a=0,o=0;for(let s=0;s<i;s++)a+=(t[s]-n)*(e[s]-r),o+=(t[s]-n)**2;return a/o}function iy(e,t){return e=Y(W(e)),t=J(t),K(e,t)?e:e.sort((e,t)=>e-t)[t-1]}function ay(e,t,n){return e=J(e),t=J(t),n=J(n),K(e,t,n)?V:(e-t)/n}var oy={};oy.P=function(){let e=fy.P.apply(this,arguments),t=Math.sqrt(e);return isNaN(t)&&(t=H),t},oy.S=function(){let e=fy.S.apply(this,arguments);return Math.sqrt(e)};function sy(){let e=py.apply(this,arguments);return Math.sqrt(e)}function cy(){let e=my.apply(this,arguments),t=Math.sqrt(e);return isNaN(t)&&(t=H),t}function ly(e,t){if(e=Y(W(e)),t=Y(W(t)),K(e,t))return V;let n=B.default.mean(t),r=B.default.mean(e),i=t.length,a=0,o=0,s=0;for(let c=0;c<i;c++)a+=(e[c]-r)**2,o+=(t[c]-n)*(e[c]-r),s+=(t[c]-n)**2;return Math.sqrt((a-o*o/s)/(i-2))}U_.DIST=(e,t,n)=>n!==1&&n!==2?H:n===1?U_.DIST.RT(e,t):U_.DIST[`2T`](e,t),U_.DIST[`2T`]=function(e,t){return arguments.length===2?e<0||t<1?H:typeof e!=`number`||typeof t!=`number`?V:(1-B.default.studentt.cdf(e,t))*2:U},U_.DIST.RT=function(e,t){return arguments.length===2?e<0||t<1?H:typeof e!=`number`||typeof t!=`number`?V:1-B.default.studentt.cdf(e,t):U},U_.INV=(e,t)=>(e=J(e),t=J(t),K(e,t)?V:B.default.studentt.inv(e,t)),U_.INV[`2T`]=(e,t)=>(e=J(e),t=J(t),e<=0||e>1||t<1?H:K(e,t)?V:Math.abs(B.default.studentt.inv(e/2,t))),U_.TEST=(e,t)=>{if(e=Y(W(e)),t=Y(W(t)),K(e,t))return V;let n=B.default.mean(e),r=B.default.mean(t),i=0,a=0,o=0;for(;o<e.length;o++)i+=(e[o]-n)**2;for(o=0;o<t.length;o++)a+=(t[o]-r)**2;i/=e.length-1,a/=t.length-1;let s=Math.abs(n-r)/Math.sqrt(i/e.length+a/t.length);return U_.DIST[`2T`](s,e.length+t.length-2)};function uy(e,t,n){if(e=Y(W(e)),t=Y(W(t)),n=Y(W(n)),K(e,t,n))return V;let r=jv(e,t),i=r[0],a=r[1],o=[];return n.forEach(e=>{o.push(i*e+a)}),o}function dy(e,t){if(e=Y(W(e)),t=J(t),K(e,t))return V;let n=Ky(e.length*t,2)/2;return B.default.mean(Ag(Ng(e.sort((e,t)=>e-t),n),n))}var fy={};fy.P=function(){let e=Lg(W(arguments)),t=e.length,n=0,r=$_(e),i;for(let i=0;i<t;i++)n+=(e[i]-r)**2;return i=n/t,isNaN(i)&&(i=H),i},fy.S=function(){let e=Lg(W(arguments)),t=e.length,n=0,r=$_(e);for(let i=0;i<t;i++)n+=(e[i]-r)**2;return n/(t-1)};function py(){let e=W(arguments),t=e.length,n=0,r=0,i=ev(e);for(let a=0;a<t;a++){let t=e[a];n+=typeof t==`number`?(t-i)**2:t===!0?(1-i)**2:(0-i)**2,t!==null&&r++}return n/(r-1)}function my(){let e=W(arguments),t=e.length,n=0,r=0,i=ev(e),a;for(let a=0;a<t;a++){let t=e[a];n+=typeof t==`number`?(t-i)**2:t===!0?(1-i)**2:(0-i)**2,t!==null&&r++}return a=n/r,isNaN(a)&&(a=H),a}var hy={};hy.DIST=(e,t,n,r)=>(e=J(e),t=J(t),n=J(n),K(e,t,n)?V:r?1-Math.exp(-((e/n)**+t)):e**(t-1)*Math.exp(-((e/n)**+t))*t/n**+t);var gy={};gy.TEST=(e,t,n)=>{if(e=Y(W(e)),t=J(t),K(e,t))return V;n||=oy.S(e);let r=e.length;return 1-Uv.S.DIST(($_(e)-t)/(n/Math.sqrt(r)),!0)};function _y(e){return e=J(e),e instanceof Error?e:Math.abs(e)}function vy(e){if(e=J(e),e instanceof Error)return e;let t=Math.acos(e);return isNaN(t)&&(t=H),t}function yy(e){if(e=J(e),e instanceof Error)return e;let t=Math.log(e+Math.sqrt(e*e-1));return isNaN(t)&&(t=H),t}function by(e){return e=J(e),e instanceof Error?e:Math.atan(1/e)}function xy(e){if(e=J(e),e instanceof Error)return e;let t=.5*Math.log((e+1)/(e-1));return isNaN(t)&&(t=H),t}function Sy(e,t,n,r){if(e=J(e),t=J(e),K(e,t))return V;switch(e){case 1:return $_(n);case 2:return cv(n);case 3:return lv(n);case 4:return Pv(n);case 5:return Rv(n);case 6:return cb(n);case 7:return oy.S(n);case 8:return oy.P(n);case 9:return Db(n);case 10:return fy.S(n);case 11:return fy.P(n);case 12:return Lv(n);case 13:return Vv.SNGL(n);case 14:return Av(n,r);case 15:return iy(n,r);case 16:return Gv.INC(n,r);case 17:return Qv.INC(n,r);case 18:return Gv.EXC(n,r);case 19:return Qv.EXC(n,r)}}function Cy(e){if(e==null)return 0;if(e instanceof Error)return e;if(!/^M*(?:D?C{0,3}|C[MD])(?:L?X{0,3}|X[CL])(?:V?I{0,3}|I[XV])$/.test(e))return V;let t=0;return e.replace(/[MDLV]|C[MD]?|X[CL]?|I[XV]?/g,e=>{t+={M:1e3,CM:900,D:500,CD:400,C:100,XC:90,L:50,XL:40,X:10,IX:9,V:5,IV:4,I:1}[e]}),t}function wy(e){if(e=J(e),e instanceof Error)return e;let t=Math.asin(e);return isNaN(t)&&(t=H),t}function Ty(e){return e=J(e),e instanceof Error?e:Math.log(e+Math.sqrt(e*e+1))}function Ey(e){return e=J(e),e instanceof Error?e:Math.atan(e)}function Dy(e,t){return e=J(e),t=J(t),G(e,t)||Math.atan2(e,t)}function Oy(e){if(e=J(e),e instanceof Error)return e;let t=Math.log((1+e)/(1-e))/2;return isNaN(t)&&(t=H),t}function ky(e,t,n){e=J(e),t=J(t),n=J(n);let r=G(e,t,n);if(r)return r;if(t===0)return H;let i=e.toString(t);return Array(Math.max(n+1-i.length,0)).join(`0`)+i}function Ay(e,t){return e=J(e),t=J(t),G(e,t)||(t===0?0:e>0&&t<0?H:Math.ceil(e/t)*t)}Ay.MATH=(e,t,n=0)=>(t===void 0&&(t=e>0?1:-1),e=J(e),t=J(t),n=J(n),G(e,t,n)||(t===0?0:(t=Math.abs(t),n===0||e>0?Math.ceil(e/t)*t:Math.floor(e/t)*t))),Ay.PRECISE=(e,t)=>Ay.MATH(e,t);function jy(e,t){return e=J(e),t=J(t),G(e,t)||(e<t?H:Wy(e)/(Wy(t)*Wy(e-t)))}function My(e,t){return e=J(e),t=J(t),G(e,t)||(e<t?H:e===0&&t===0?1:jy(e+t-1,e-1))}function Ny(e){return e=J(e),e instanceof Error?e:Math.cos(e)}function Py(e){return e=J(e),e instanceof Error?e:(Math.exp(e)+Math.exp(-e))/2}function Fy(e){return e=J(e),e instanceof Error?e:e===0?Yh:1/Math.tan(e)}function Iy(e){if(e=J(e),e instanceof Error)return e;if(e===0)return Yh;let t=Math.exp(2*e);return(t+1)/(t-1)}function Ly(e){return e=J(e),e instanceof Error?e:e===0?Yh:1/Math.sin(e)}function Ry(e){return e=J(e),e instanceof Error?e:e===0?Yh:2/(Math.exp(e)-Math.exp(-e))}function zy(e,t){if(arguments.length<2)return U;e||=`0`,t=J(t);let n=G(e,t);if(n)return n;if(t===0)return H;let r=parseInt(e,t);return isNaN(r)?H:r}function By(e){return e=J(e),e instanceof Error?e:e*180/Math.PI}function Vy(e){return e=J(e),e instanceof Error?e:Ay.MATH(e,-2,-1)}function Hy(e){return arguments.length<1?U:arguments.length>1?Qh:(e=J(e),e instanceof Error||(e=Math.exp(e)),e)}var Uy=[];function Wy(e){if(e=J(e),e instanceof Error)return e;let t=Math.floor(e);return t===0||t===1?1:(Uy[t]>0||(Uy[t]=Wy(t-1)*t),Uy[t])}function Gy(e){if(e=J(e),e instanceof Error)return e;let t=Math.floor(e);return t<=0?1:t*Gy(t-2)}function Ky(e,t){return e=J(e),t=J(t),G(e,t)||(t?e>0&&t<0?H:Math.floor(e/t)*t:Yh)}Ky.MATH=(e,t=1,n=0)=>(e=J(e),t=J(t),n=J(n),G(e,t,n)||(t===0?0:(t=Math.abs(t),n===0||e>0?Math.floor(e/t)*t:Math.ceil(e/t)*t))),Ky.PRECISE=(e,t)=>Ky.MATH(e,t);function qy(){let e=Y(W(arguments));if(e instanceof Error)return e;let t=e.length,n=e[0],r=n<0?-n:n;for(let n=1;n<t;n++){let t=e[n],i=t<0?-t:t;for(;r&&i;)r>i?r%=i:i%=r;r+=i}return r}function Jy(e){return e=J(e),e instanceof Error?e:Math.floor(e)}var Yy={CEILING:Ay};function Xy(){let e=Y(W(arguments));if(e instanceof Error)return e;for(var t,n,r,i,a=1;(r=e.pop())!==void 0;){if(r===0)return 0;for(;r>1;){if(r%2){for(t=3,n=Math.floor(Math.sqrt(r));t<=n&&r%t;t+=2);i=t<=n?t:r}else i=2;for(r/=i,a*=i,t=e.length;t;e[--t]%i===0&&(e[t]/=i)===1&&e.splice(t,1));}}return a}function Zy(e){return e=J(e),e instanceof Error?e:e===0?H:Math.log(e)}function Qy(e,t){return e=J(e),t=t?J(t):10,G(e,t)||(e===0||t===0?H:Math.log(e)/Math.log(t))}function $y(e){return e=J(e),e instanceof Error?e:e===0?H:Math.log(e)/Math.log(10)}function eb(e,t){return!Array.isArray(e)||!Array.isArray(t)||e.some(e=>!e.length)||t.some(e=>!e.length)||kg(e).some(e=>typeof e!=`number`)||kg(t).some(e=>typeof e!=`number`)||e[0].length!==t.length?V:Array(e.length).fill(0).map(()=>Array(t[0].length).fill(0)).map((n,r)=>n.map((n,i)=>e[r].reduce((e,n,r)=>e+n*t[r][i],0)))}function tb(e,t){e=J(e),t=J(t);let n=G(e,t);if(n)return n;if(t===0)return Yh;let r=Math.abs(e%t);return r=e<0?t-r:r,t>0?r:-r}function nb(e,t){return e=J(e),t=J(t),G(e,t)||(e*t===0?0:e*t<0?H:Math.round(e/t)*t)}function rb(){let e=Y(W(arguments));if(e instanceof Error)return e;let t=0,n=1;for(let r=0;r<e.length;r++)t+=e[r],n*=Wy(e[r]);return Wy(t)/n}function ib(e){return arguments.length>1?U:(e=parseInt(e),!e||e<=0?V:Array(e).fill(0).map(()=>Array(e).fill(0)).map((e,t)=>(e[t]=1,e)))}function ab(e){if(e=J(e),e instanceof Error)return e;let t=Math.ceil(Math.abs(e));return t=t&1?t:t+1,e>=0?t:-t}function ob(){return Math.PI}function sb(e,t){e=J(e),t=J(t);let n=G(e,t);if(n)return n;if(e===0&&t===0)return H;let r=e**+t;return isNaN(r)?H:r}function cb(){let e=W(arguments).filter(e=>e!=null);if(e.length===0)return 0;let t=Y(e);if(t instanceof Error)return t;let n=1;for(let e=0;e<t.length;e++)n*=t[e];return n}function lb(e,t){return e=J(e),t=J(t),G(e,t)||parseInt(e/t,10)}function ub(e){return e=J(e),e instanceof Error?e:e*Math.PI/180}function db(){return Math.random()}function fb(e,t){return e=J(e),t=J(t),G(e,t)||e+Math.ceil((t-e+1)*Math.random())-1}function pb(e){if(e=J(e),e instanceof Error)return e;let t=String(e).split(``),n=`.C.CC.CCC.CD.D.DC.DCC.DCCC.CM..X.XX.XXX.XL.L.LX.LXX.LXXX.XC..I.II.III.IV.V.VI.VII.VIII.IX`.split(`.`),r=``,i=3;for(;i--;)r=(n[+t.pop()+i*10]||``)+r;return Array(+t.join(``)+1).join(`M`)+r}function mb(e,t,n){e=J(e),t=J(t);let r=G(e,t);if(r)return r;let i=e>=0?1:-1,a=(Math.abs(e)+`e`+t).split(`e`);return a=(n(a[0]+`e`+a[1])+`e`+-t).split(`e`),Number(a[0]+`e`+a[1])*i}function hb(e,t){return mb(e,t,Math.round)}function gb(e,t){return mb(e,t,Math.floor)}function _b(e,t){return mb(e,t,Math.ceil)}function vb(e){return e=J(e),e instanceof Error?e:1/Math.cos(e)}function yb(e){return e=J(e),e instanceof Error?e:2/(Math.exp(e)+Math.exp(-e))}function bb(e,t,n,r){if(e=J(e),t=J(t),n=J(n),r=Y(r),K(e,t,n,r))return V;let i=r[0]*e**+t;for(let a=1;a<r.length;a++)i+=r[a]*e**+(t+a*n);return i}function xb(e){return e=J(e),e instanceof Error?e:e<0?-1:e===0?0:1}function Sb(e){return e=J(e),e instanceof Error?e:Math.sin(e)}function Cb(e){return e=J(e),e instanceof Error?e:(Math.exp(e)-Math.exp(-e))/2}function wb(e){return e=J(e),e instanceof Error?e:e<0?H:Math.sqrt(e)}function Tb(e){return e=J(e),e instanceof Error?e:Math.sqrt(e*Math.PI)}function Eb(e,t){if(e=J(e),e instanceof Error)return e;switch(e){case 1:return $_(t);case 2:return cv(t);case 3:return lv(t);case 4:return Pv(t);case 5:return Rv(t);case 6:return cb(t);case 7:return oy.S(t);case 8:return oy.P(t);case 9:return Db(t);case 10:return fy.S(t);case 11:return fy.P(t);case 101:return $_(t);case 102:return cv(t);case 103:return lv(t);case 104:return Pv(t);case 105:return Rv(t);case 106:return cb(t);case 107:return oy.S(t);case 108:return oy.P(t);case 109:return Db(t);case 110:return fy.S(t);case 111:return fy.P(t)}}function Db(){let e=0;return wg(Cg(arguments),t=>{if(e instanceof Error)return!1;if(t instanceof Error)e=t;else if(typeof t==`number`)e+=t;else if(typeof t==`string`){let n=parseFloat(t);!isNaN(n)&&(e+=n)}else if(Array.isArray(t)){let n=Db.apply(null,t);n instanceof Error?e=n:e+=n}}),e}function Ob(e,t,n){if(e=W(e),n=n?W(n):e,e instanceof Error)return e;if(t==null||t instanceof Error)return 0;let r=0,i=t===`*`,a=i?null:xg(t+``);for(let t=0;t<e.length;t++){let o=e[t],s=n[t];if(i)r+=o;else{let e=[hg(o,mg)].concat(a);r+=Sg(e)?s:0}}return r}function kb(){let e=Cg(arguments);return e[0]=Tg(W(e[0])),Db(Hg(...e))}function Ab(){if(!arguments||arguments.length===0)return V;let e=arguments.length+1,t=0,n,r,i,a;for(let o=0;o<arguments[0].length;o++)if(arguments[0][o]instanceof Array)for(let i=0;i<arguments[0][o].length;i++){for(n=1,r=1;r<e;r++){let e=arguments[r-1][o][i];if(e instanceof Error)return e;if(a=J(e),a instanceof Error)return a;n*=a}t+=n}else{for(n=1,r=1;r<e;r++){let e=arguments[r-1][o];if(e instanceof Error)return e;if(i=J(e),i instanceof Error)return i;n*=i}t+=n}return t}function jb(){let e=Y(W(arguments));if(e instanceof Error)return e;let t=0,n=e.length;for(let r=0;r<n;r++)t+=Qg(e[r])?e[r]*e[r]:0;return t}function Mb(e,t){if(e=Y(W(e)),t=Y(W(t)),K(e,t))return V;let n=0;for(let r=0;r<e.length;r++)n+=e[r]*e[r]-t[r]*t[r];return n}function Nb(e,t){if(e=Y(W(e)),t=Y(W(t)),K(e,t))return V;let n=0;e=Y(W(e)),t=Y(W(t));for(let r=0;r<e.length;r++)n+=e[r]*e[r]+t[r]*t[r];return n}function Pb(e,t){if(e=Y(W(e)),t=Y(W(t)),K(e,t))return V;let n=0;e=W(e),t=W(t);for(let r=0;r<e.length;r++)n+=(e[r]-t[r])**2;return n}function Fb(e){return e=J(e),e instanceof Error?e:Math.tan(e)}function Ib(e){if(e=J(e),e instanceof Error)return e;let t=Math.exp(2*e);return(t-1)/(t+1)}function Lb(e,t){return e=J(e),t=J(t),G(e,t)||(e>0?1:-1)*Math.floor(Math.abs(e)*10**t)/10**t}function Rb(e,t){return arguments.length===2?(e=J(e),t=J(t),G(e,t)||e+t):U}function zb(e,t){return arguments.length===2?(e=J(e),t=J(t),G(e,t)||(t===0?Yh:e/t)):U}function Bb(e,t){return arguments.length===2?e instanceof Error?e:t instanceof Error?t:(e===null&&(e=void 0),t===null&&(t=void 0),e===t):U}function Vb(e,t){return arguments.length===2?e instanceof Error?e:t instanceof Error?t:(Vg(e,t)?(e=Bg(e),t=Bg(t)):(e=J(e),t=J(t)),G(e,t)||e>t):U}function Hb(e,t){return arguments.length===2?(Vg(e,t)?(e=Bg(e),t=Bg(t)):(e=J(e),t=J(t)),G(e,t)||e>=t):U}function Ub(e,t){return arguments.length===2?(Vg(e,t)?(e=Bg(e),t=Bg(t)):(e=J(e),t=J(t)),G(e,t)||e<t):U}function Wb(e,t){return arguments.length===2?(Vg(e,t)?(e=Bg(e),t=Bg(t)):(e=J(e),t=J(t)),G(e,t)||e<=t):U}function Gb(e,t){return arguments.length===2?(e=J(e),t=J(t),G(e,t)||e-t):U}function Kb(e,t){return arguments.length===2?(e=J(e),t=J(t),G(e,t)||e*t):U}function qb(e,t){return arguments.length===2?e instanceof Error?e:t instanceof Error?t:(e===null&&(e=void 0),t===null&&(t=void 0),e!==t):U}function Jb(e,t){return arguments.length===2?sb(e,t):U}var Yb=Object.freeze({__proto__:null,ADD:Rb,DIVIDE:zb,EQ:Bb,GT:Vb,GTE:Hb,LT:Ub,LTE:Wb,MINUS:Gb,MULTIPLY:Kb,NE:qb,POW:Jb}),Xb=[void 0,0,1,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,1,2,3,4,5,6,0],Zb=[[],[1,2,3,4,5,6,7],[7,1,2,3,4,5,6],[6,0,1,2,3,4,5],[],[],[],[],[],[],[],[7,1,2,3,4,5,6],[6,7,1,2,3,4,5],[5,6,7,1,2,3,4],[4,5,6,7,1,2,3],[3,4,5,6,7,1,2],[2,3,4,5,6,7,1],[1,2,3,4,5,6,7]],Qb=[[],[6,0],[0,1],[1,2],[2,3],[3,4],[4,5],[5,6],void 0,void 0,void 0,[0,0],[1,1],[2,2],[3,3],[4,4],[5,5],[6,6]];function $b(e,t,n){let r;return e=J(e),t=J(t),n=J(n),K(e,t,n)?r=V:(r=new Date(e,t-1,n),r.getFullYear()<0&&(r=H)),ng?og(r):r}function ex(e,t,n){n=n.toUpperCase(),e=q(e),t=q(t);let r=e.getFullYear(),i=e.getMonth(),a=e.getDate(),o=t.getFullYear(),s=t.getMonth(),c=t.getDate(),l;switch(n){case`Y`:l=Math.floor(wx(e,t));break;case`D`:l=ix(t,e);break;case`M`:l=s-i+12*(o-r),c<a&&l--;break;case`MD`:a<=c?l=c-a:(s===0?(e.setFullYear(o-1),e.setMonth(12)):(e.setFullYear(o),e.setMonth(s-1)),l=ix(t,e));break;case`YM`:l=s-i+12*(o-r),c<a&&l--,l%=12;break;case`YD`:s>i||s===i&&c<a?e.setFullYear(o):e.setFullYear(o-1),l=ix(t,e)}return l}function tx(e){if(typeof e!=`string`||isNaN(Date.parse(e)))return V;let t=new Date(e);return ng?og(t):t}function nx(e){let t=q(e);return t instanceof Error?t:t.getDate()}function rx(e){let t=new Date(e);return t.setHours(0,0,0,0),t}function ix(e,t){return e=q(e),t=q(t),e instanceof Error?e:t instanceof Error?t:og(rx(e))-og(rx(t))}function ax(e,t,n){if(n=Rg(n||`false`),e=q(e),t=q(t),e instanceof Error)return e;if(t instanceof Error)return t;if(n instanceof Error)return n;let r=e.getMonth(),i=t.getMonth(),a,o;if(n)a=e.getDate()===31?30:e.getDate(),o=t.getDate()===31?30:t.getDate();else{let n=new Date(e.getFullYear(),r+1,0).getDate(),s=new Date(t.getFullYear(),i+1,0).getDate();a=e.getDate()===n?30:e.getDate(),t.getDate()===s?a<30?(i++,o=1):o=30:o=t.getDate()}return 360*(t.getFullYear()-e.getFullYear())+30*(i-r)+(o-a)}function ox(e,t){if(e=q(e),e instanceof Error)return e;if(isNaN(t))return V;let n=e.getDate();e.setDate(1),t=parseInt(t,10),e.setMonth(e.getMonth()+t);let r=e.getMonth();if(n>28){let t=[31,28,31,30,31,30,31,31,30,31,30,31][r],i=e.getFullYear();r===1&&(i%4==0&&i%100!=0||i%400==0)&&(t=29),n=Math.min(n,t)}return e.setDate(n),ng?og(e):e}function sx(e,t){if(e=q(e),e instanceof Error)return e;if(isNaN(t))return V;t=parseInt(t,10);let n=new Date(e.getFullYear(),e.getMonth()+t+1,0);return ng?og(n):n}function cx(e){return e=q(e),e instanceof Error?e:e.getHours()}function lx(e){if(e=q(e),e instanceof Error)return e;e=rx(e),e.setDate(e.getDate()+4-(e.getDay()||7));let t=new Date(e.getFullYear(),0,1);return Math.ceil(((e-t)/864e5+1)/7)}function ux(e){return e=q(e),e instanceof Error?e:e.getMinutes()}function dx(e){return e=q(e),e instanceof Error?e:e.getMonth()+1}function fx(e,t,n){return fx.INTL(e,t,1,n)}fx.INTL=(e,t,n,r)=>{if(e=q(e),e instanceof Error)return e;if(t=q(t),t instanceof Error)return t;let i=!1,a=[],o=[1,2,3,4,5,6,0],s=RegExp(`^[0|1]{7}$`);if(n===void 0)n=Qb[1];else if(typeof n==`string`&&s.test(n)){i=!0,n=n.split(``);for(let e=0;e<n.length;e++)n[e]===`1`&&a.push(o[e])}else n=Qb[n];if(!(n instanceof Array))return V;r===void 0?r=[]:r instanceof Array||(r=[r]);for(let e=0;e<r.length;e++){let t=q(r[e]);if(t instanceof Error)return t;r[e]=t}let c=Math.round((t-e)/864e5)+1,l=c,u=e;for(let e=0;e<c;e++){let e=new Date().getTimezoneOffset()>0?u.getUTCDay():u.getDay(),t=i?a.includes(e):e===n[0]||e===n[1];for(let e=0;e<r.length;e++){let n=r[e];if(n.getDate()===u.getDate()&&n.getMonth()===u.getMonth()&&n.getFullYear()===u.getFullYear()){t=!0;break}}t&&l--,u.setDate(u.getDate()+1)}return l};function px(){return ng?og(new Date):new Date}function mx(e){return e=q(e),e instanceof Error?e:e.getSeconds()}function hx(e,t,n){return e=J(e),t=J(t),n=J(n),K(e,t,n)?V:e<0||t<0||n<0?H:(3600*e+60*t+n)/86400}function gx(e){return e=q(e),e instanceof Error?e:(3600*e.getHours()+60*e.getMinutes()+e.getSeconds())/86400}function _x(){let e=rx(new Date);return ng?og(e):e}function vx(e,t){if(e=q(e),e instanceof Error)return e;t===void 0&&(t=1);let n=e.getDay();return Zb[t][n]}function yx(e,t){if(e=q(e),e instanceof Error)return e;if(t===void 0&&(t=1),t===21)return lx(e);let n=Xb[t],r=new Date(e.getFullYear(),0,1),i=+(r.getDay()<n);return r-=Math.abs(r.getDay()-n)*24*60*60*1e3,Math.floor((e-r)/864e5/7+1)+i}function bx(e,t,n){return bx.INTL(e,t,1,n)}bx.INTL=(e,t,n,r)=>{if(e=q(e),e instanceof Error)return e;if(t=J(t),t instanceof Error)return t;if(n=n===void 0?Qb[1]:Qb[n],!(n instanceof Array))return V;r===void 0?r=[]:r instanceof Array||(r=[r]);for(let e=0;e<r.length;e++){let t=q(r[e]);if(t instanceof Error)return t;r[e]=t}let i=0,a=Math.sign(t);for(;i<t*a;){e.setDate(e.getDate()+a);let t=e.getDay();if(t!==n[0]&&t!==n[1]){for(let t=0;t<r.length;t++){let n=r[t];if(n.getDate()===e.getDate()&&n.getMonth()===e.getMonth()&&n.getFullYear()===e.getFullYear()){i--;break}}i++}}return e.getFullYear()<1900?V:e};function xx(e){return e=q(e),e instanceof Error?e:e.getFullYear()}function Sx(e){return new Date(e,1,29).getMonth()===1}function Cx(e,t){return Math.ceil((t-e)/1e3/60/60/24)}function wx(e,t,n){if(e=q(e),e instanceof Error)return e;if(t=q(t),t instanceof Error)return t;n||=0;let r=e.getDate(),i=e.getMonth()+1,a=e.getFullYear(),o=t.getDate(),s=t.getMonth()+1,c=t.getFullYear();switch(n){case 0:return r===31&&o===31?(r=30,o=30):r===31?r=30:r===30&&o===31&&(o=30),(o+s*30+c*360-(r+i*30+a*360))/360;case 1:{let n=(e,t)=>{let n=e.getFullYear(),r=new Date(n,2,1);if(Sx(n)&&e<r&&t>=r)return!0;let i=t.getFullYear(),a=new Date(i,2,1);return Sx(i)&&t>=a&&e<a},l=365;if(a===c||a+1===c&&(i>s||i===s&&r>=o))return(a===c&&Sx(a)||n(e,t)||s===1&&o===29)&&(l=366),Cx(e,t)/l;let u=c-a+1,d=(new Date(c+1,0,1)-new Date(a,0,1))/1e3/60/60/24/u;return Cx(e,t)/d}case 2:return Cx(e,t)/360;case 3:return Cx(e,t)/365;case 4:return(o+s*30+c*360-(r+i*30+a*360))/360}}function Tx(e){return/^[01]{1,10}$/.test(e)}function Ex(e,t){return e=J(e),t=J(t),K(e,t)?V:qh.default.besseli(e,t)}function Dx(e,t){return e=J(e),t=J(t),K(e,t)?V:qh.default.besselj(e,t)}function Ox(e,t){return e=J(e),t=J(t),K(e,t)?V:qh.default.besselk(e,t)}function kx(e,t){return e=J(e),t=J(t),K(e,t)?V:qh.default.bessely(e,t)}function Ax(e){if(!Tx(e))return H;let t=parseInt(e,2),n=e.toString();return n.length===10&&n.substring(0,1)===`1`?parseInt(n.substring(1),2)-512:t}function jx(e,t){if(!Tx(e))return H;let n=e.toString();if(n.length===10&&n.substring(0,1)===`1`)return(0xfffffffe00+parseInt(n.substring(1),2)).toString(16);let r=parseInt(e,2).toString(16);return t===void 0?r:isNaN(t)?V:t<0?H:(t=Math.floor(t),t>=r.length?z_(`0`,t-r.length)+r:H)}function Mx(e,t){if(!Tx(e))return H;let n=e.toString();if(n.length===10&&n.substring(0,1)===`1`)return(1073741312+parseInt(n.substring(1),2)).toString(8);let r=parseInt(e,2).toString(8);return t===void 0?r:isNaN(t)?V:t<0?H:(t=Math.floor(t),t>=r.length?z_(`0`,t-r.length)+r:H)}function Nx(e,t){return e=J(e),t=J(t),K(e,t)?V:e<0||t<0||Math.floor(e)!==e||Math.floor(t)!==t||e>0xffffffffffff||t>0xffffffffffff?H:e&t}function Px(e,t){return e=J(e),t=J(t),K(e,t)?V:e<0||Math.floor(e)!==e||e>0xffffffffffff||Math.abs(t)>53?H:t>=0?e<<t:e>>-t}function Fx(e,t){return e=J(e),t=J(t),K(e,t)?V:e<0||t<0||Math.floor(e)!==e||Math.floor(t)!==t||e>0xffffffffffff||t>0xffffffffffff?H:e|t}function Ix(e,t){return e=J(e),t=J(t),K(e,t)?V:e<0||Math.floor(e)!==e||e>0xffffffffffff||Math.abs(t)>53?H:t>=0?e>>t:e<<-t}function Lx(e,t){return e=J(e),t=J(t),K(e,t)?V:e<0||t<0||Math.floor(e)!==e||Math.floor(t)!==t||e>0xffffffffffff||t>0xffffffffffff?H:e^t}function Rx(e,t,n){if(e=J(e),t=J(t),K(e,t))return e;if(n=n===void 0?`i`:n,n!==`i`&&n!==`j`)return V;if(e===0&&t===0)return 0;if(e===0)return t===1?n:t.toString()+n;if(t===0)return e.toString();{let r=t>0?`+`:``;return e.toString()+r+(t===1?n:t.toString()+n)}}function zx(e,t,n){if(e=J(e),e instanceof Error)return e;let r=[[`a.u. of action`,`?`,null,`action`,!1,!1,105457168181818e-48],[`a.u. of charge`,`e`,null,`electric_charge`,!1,!1,160217653141414e-33],[`a.u. of energy`,`Eh`,null,`energy`,!1,!1,435974417757576e-32],[`a.u. of length`,`a?`,null,`length`,!1,!1,529177210818182e-25],[`a.u. of mass`,`m?`,null,`mass`,!1,!1,910938261616162e-45],[`a.u. of time`,`?/Eh`,null,`time`,!1,!1,241888432650516e-31],[`admiralty knot`,`admkn`,null,`speed`,!1,!0,.514773333],[`ampere`,`A`,null,`electric_current`,!0,!1,1],[`ampere per meter`,`A/m`,null,`magnetic_field_intensity`,!0,!1,1],[`ångström`,`Å`,[`ang`],`length`,!1,!0,1e-10],[`are`,`ar`,null,`area`,!1,!0,100],[`astronomical unit`,`ua`,null,`length`,!1,!1,149597870691667e-25],[`bar`,`bar`,null,`pressure`,!1,!1,1e5],[`barn`,`b`,null,`area`,!1,!1,1e-28],[`becquerel`,`Bq`,null,`radioactivity`,!0,!1,1],[`bit`,`bit`,[`b`],`information`,!1,!0,1],[`btu`,`BTU`,[`btu`],`energy`,!1,!0,1055.05585262],[`byte`,`byte`,null,`information`,!1,!0,8],[`candela`,`cd`,null,`luminous_intensity`,!0,!1,1],[`candela per square metre`,`cd/m?`,null,`luminance`,!0,!1,1],[`coulomb`,`C`,null,`electric_charge`,!0,!1,1],[`cubic ångström`,`ang3`,[`ang^3`],`volume`,!1,!0,1e-30],[`cubic foot`,`ft3`,[`ft^3`],`volume`,!1,!0,.028316846592],[`cubic inch`,`in3`,[`in^3`],`volume`,!1,!0,16387064e-12],[`cubic light-year`,`ly3`,[`ly^3`],`volume`,!1,!0,846786664623715e-61],[`cubic metre`,`m3`,[`m^3`],`volume`,!0,!0,1],[`cubic mile`,`mi3`,[`mi^3`],`volume`,!1,!0,4168181825.44058],[`cubic nautical mile`,`Nmi3`,[`Nmi^3`],`volume`,!1,!0,6352182208],[`cubic Pica`,`Pica3`,[`Picapt3`,`Pica^3`,`Picapt^3`],`volume`,!1,!0,7.58660370370369e-8],[`cubic yard`,`yd3`,[`yd^3`],`volume`,!1,!0,.764554857984],[`cup`,`cup`,null,`volume`,!1,!0,.0002365882365],[`dalton`,`Da`,[`u`],`mass`,!1,!1,166053886282828e-41],[`day`,`d`,[`day`],`time`,!1,!0,86400],[`degree`,`°`,null,`angle`,!1,!1,.0174532925199433],[`degrees Rankine`,`Rank`,null,`temperature`,!1,!0,.555555555555556],[`dyne`,`dyn`,[`dy`],`force`,!1,!0,1e-5],[`electronvolt`,`eV`,[`ev`],`energy`,!1,!0,1.60217656514141],[`ell`,`ell`,null,`length`,!1,!0,1.143],[`erg`,`erg`,[`e`],`energy`,!1,!0,1e-7],[`farad`,`F`,null,`electric_capacitance`,!0,!1,1],[`fluid ounce`,`oz`,null,`volume`,!1,!0,295735295625e-16],[`foot`,`ft`,null,`length`,!1,!0,.3048],[`foot-pound`,`flb`,null,`energy`,!1,!0,1.3558179483314],[`gal`,`Gal`,null,`acceleration`,!1,!1,.01],[`gallon`,`gal`,null,`volume`,!1,!0,.003785411784],[`gauss`,`G`,[`ga`],`magnetic_flux_density`,!1,!0,1],[`grain`,`grain`,null,`mass`,!1,!0,647989e-10],[`gram`,`g`,null,`mass`,!1,!0,.001],[`gray`,`Gy`,null,`absorbed_dose`,!0,!1,1],[`gross registered ton`,`GRT`,[`regton`],`volume`,!1,!0,2.8316846592],[`hectare`,`ha`,null,`area`,!1,!0,1e4],[`henry`,`H`,null,`inductance`,!0,!1,1],[`hertz`,`Hz`,null,`frequency`,!0,!1,1],[`horsepower`,`HP`,[`h`],`power`,!1,!0,745.69987158227],[`horsepower-hour`,`HPh`,[`hh`,`hph`],`energy`,!1,!0,2684519.538],[`hour`,`h`,[`hr`],`time`,!1,!0,3600],[`imperial gallon (U.K.)`,`uk_gal`,null,`volume`,!1,!0,.00454609],[`imperial hundredweight`,`lcwt`,[`uk_cwt`,`hweight`],`mass`,!1,!0,50.802345],[`imperial quart (U.K)`,`uk_qt`,null,`volume`,!1,!0,.0011365225],[`imperial ton`,`brton`,[`uk_ton`,`LTON`],`mass`,!1,!0,1016.046909],[`inch`,`in`,null,`length`,!1,!0,.0254],[`international acre`,`uk_acre`,null,`area`,!1,!0,4046.8564224],[`IT calorie`,`cal`,null,`energy`,!1,!0,4.1868],[`joule`,`J`,null,`energy`,!0,!0,1],[`katal`,`kat`,null,`catalytic_activity`,!0,!1,1],[`kelvin`,`K`,[`kel`],`temperature`,!0,!0,1],[`kilogram`,`kg`,null,`mass`,!0,!0,1],[`knot`,`kn`,null,`speed`,!1,!0,.514444444444444],[`light-year`,`ly`,null,`length`,!1,!0,9460730472580800],[`litre`,`L`,[`l`,`lt`],`volume`,!1,!0,.001],[`lumen`,`lm`,null,`luminous_flux`,!0,!1,1],[`lux`,`lx`,null,`illuminance`,!0,!1,1],[`maxwell`,`Mx`,null,`magnetic_flux`,!1,!1,1e-18],[`measurement ton`,`MTON`,null,`volume`,!1,!0,1.13267386368],[`meter per hour`,`m/h`,[`m/hr`],`speed`,!1,!0,.00027777777777778],[`meter per second`,`m/s`,[`m/sec`],`speed`,!0,!0,1],[`meter per second squared`,`m?s??`,null,`acceleration`,!0,!1,1],[`parsec`,`pc`,[`parsec`],`length`,!1,!0,0x6da012f958ee1c],[`meter squared per second`,`m?/s`,null,`kinematic_viscosity`,!0,!1,1],[`metre`,`m`,null,`length`,!0,!0,1],[`miles per hour`,`mph`,null,`speed`,!1,!0,.44704],[`millimetre of mercury`,`mmHg`,null,`pressure`,!1,!1,133.322],[`minute`,`?`,null,`angle`,!1,!1,.000290888208665722],[`minute`,`min`,[`mn`],`time`,!1,!0,60],[`modern teaspoon`,`tspm`,null,`volume`,!1,!0,5e-6],[`mole`,`mol`,null,`amount_of_substance`,!0,!1,1],[`morgen`,`Morgen`,null,`area`,!1,!0,2500],[`n.u. of action`,`?`,null,`action`,!1,!1,105457168181818e-48],[`n.u. of mass`,`m?`,null,`mass`,!1,!1,910938261616162e-45],[`n.u. of speed`,`c?`,null,`speed`,!1,!1,299792458],[`n.u. of time`,`?/(me?c??)`,null,`time`,!1,!1,128808866778687e-35],[`nautical mile`,`M`,[`Nmi`],`length`,!1,!0,1852],[`newton`,`N`,null,`force`,!0,!0,1],[`œrsted`,`Oe `,null,`magnetic_field_intensity`,!1,!1,79.5774715459477],[`ohm`,`Ω`,null,`electric_resistance`,!0,!1,1],[`ounce mass`,`ozm`,null,`mass`,!1,!0,.028349523125],[`pascal`,`Pa`,null,`pressure`,!0,!1,1],[`pascal second`,`Pa?s`,null,`dynamic_viscosity`,!0,!1,1],[`pferdestärke`,`PS`,null,`power`,!1,!0,735.49875],[`phot`,`ph`,null,`illuminance`,!1,!1,1e-4],[`pica (1/6 inch)`,`pica`,null,`length`,!1,!0,.00035277777777778],[`pica (1/72 inch)`,`Pica`,[`Picapt`],`length`,!1,!0,.00423333333333333],[`poise`,`P`,null,`dynamic_viscosity`,!1,!1,.1],[`pond`,`pond`,null,`force`,!1,!0,.00980665],[`pound force`,`lbf`,null,`force`,!1,!0,4.4482216152605],[`pound mass`,`lbm`,null,`mass`,!1,!0,.45359237],[`quart`,`qt`,null,`volume`,!1,!0,.000946352946],[`radian`,`rad`,null,`angle`,!0,!1,1],[`second`,`?`,null,`angle`,!1,!1,484813681109536e-20],[`second`,`s`,[`sec`],`time`,!0,!0,1],[`short hundredweight`,`cwt`,[`shweight`],`mass`,!1,!0,45.359237],[`siemens`,`S`,null,`electrical_conductance`,!0,!1,1],[`sievert`,`Sv`,null,`equivalent_dose`,!0,!1,1],[`slug`,`sg`,null,`mass`,!1,!0,14.59390294],[`square ångström`,`ang2`,[`ang^2`],`area`,!1,!0,1e-20],[`square foot`,`ft2`,[`ft^2`],`area`,!1,!0,.09290304],[`square inch`,`in2`,[`in^2`],`area`,!1,!0,64516e-8],[`square light-year`,`ly2`,[`ly^2`],`area`,!1,!0,895054210748189e17],[`square meter`,`m?`,null,`area`,!0,!0,1],[`square mile`,`mi2`,[`mi^2`],`area`,!1,!0,2589988.110336],[`square nautical mile`,`Nmi2`,[`Nmi^2`],`area`,!1,!0,3429904],[`square Pica`,`Pica2`,[`Picapt2`,`Pica^2`,`Picapt^2`],`area`,!1,!0,1792111111111e-17],[`square yard`,`yd2`,[`yd^2`],`area`,!1,!0,.83612736],[`statute mile`,`mi`,null,`length`,!1,!0,1609.344],[`steradian`,`sr`,null,`solid_angle`,!0,!1,1],[`stilb`,`sb`,null,`luminance`,!1,!1,1e-4],[`stokes`,`St`,null,`kinematic_viscosity`,!1,!1,1e-4],[`stone`,`stone`,null,`mass`,!1,!0,6.35029318],[`tablespoon`,`tbs`,null,`volume`,!1,!0,147868e-10],[`teaspoon`,`tsp`,null,`volume`,!1,!0,492892e-11],[`tesla`,`T`,null,`magnetic_flux_density`,!0,!0,1],[`thermodynamic calorie`,`c`,null,`energy`,!1,!0,4.184],[`ton`,`ton`,null,`mass`,!1,!0,907.18474],[`tonne`,`t`,null,`mass`,!1,!1,1e3],[`U.K. pint`,`uk_pt`,null,`volume`,!1,!0,.00056826125],[`U.S. bushel`,`bushel`,null,`volume`,!1,!0,.03523907],[`U.S. oil barrel`,`barrel`,null,`volume`,!1,!0,.158987295],[`U.S. pint`,`pt`,[`us_pt`],`volume`,!1,!0,.000473176473],[`U.S. survey mile`,`survey_mi`,null,`length`,!1,!0,1609.347219],[`U.S. survey/statute acre`,`us_acre`,null,`area`,!1,!0,4046.87261],[`volt`,`V`,null,`voltage`,!0,!1,1],[`watt`,`W`,null,`power`,!0,!0,1],[`watt-hour`,`Wh`,[`wh`],`energy`,!1,!0,3600],[`weber`,`Wb`,null,`magnetic_flux`,!0,!1,1],[`yard`,`yd`,null,`length`,!1,!0,.9144],[`year`,`yr`,null,`time`,!1,!0,31557600]],i={Yi:[`yobi`,80,12089258196146292e8,`Yi`,`yotta`],Zi:[`zebi`,70,0x400000000000000000,`Zi`,`zetta`],Ei:[`exbi`,60,0x1000000000000000,`Ei`,`exa`],Pi:[`pebi`,50,0x4000000000000,`Pi`,`peta`],Ti:[`tebi`,40,1099511627776,`Ti`,`tera`],Gi:[`gibi`,30,1073741824,`Gi`,`giga`],Mi:[`mebi`,20,1048576,`Mi`,`mega`],ki:[`kibi`,10,1024,`ki`,`kilo`]},a={Y:[`yotta`,1e24,`Y`],Z:[`zetta`,1e21,`Z`],E:[`exa`,0xde0b6b3a7640000,`E`],P:[`peta`,0x38d7ea4c68000,`P`],T:[`tera`,0xe8d4a51000,`T`],G:[`giga`,1e9,`G`],M:[`mega`,1e6,`M`],k:[`kilo`,1e3,`k`],h:[`hecto`,100,`h`],e:[`dekao`,10,`e`],d:[`deci`,.1,`d`],c:[`centi`,.01,`c`],m:[`milli`,.001,`m`],u:[`micro`,1e-6,`u`],n:[`nano`,1e-9,`n`],p:[`pico`,1e-12,`p`],f:[`femto`,1e-15,`f`],a:[`atto`,1e-18,`a`],z:[`zepto`,1e-21,`z`],y:[`yocto`,1e-24,`y`]},o=null,s=null,c=t,l=n,u=1,d=1,f;for(let e=0;e<r.length;e++)f=r[e][2]===null?[]:r[e][2],(r[e][1]===c||f.indexOf(c)>=0)&&(o=r[e]),(r[e][1]===l||f.indexOf(l)>=0)&&(s=r[e]);if(o===null){let e=i[t.substring(0,2)],n=a[t.substring(0,1)];t.substring(0,2)===`da`&&(n=[`dekao`,10,`da`]),e?(u=e[2],c=t.substring(2)):n&&(u=n[1],c=t.substring(n[2].length));for(let e=0;e<r.length;e++)f=r[e][2]===null?[]:r[e][2],(r[e][1]===c||f.indexOf(c)>=0)&&(o=r[e])}if(s===null){let e=i[n.substring(0,2)],t=a[n.substring(0,1)];n.substring(0,2)===`da`&&(t=[`dekao`,10,`da`]),e?(d=e[2],l=n.substring(2)):t&&(d=t[1],l=n.substring(t[2].length));for(let e=0;e<r.length;e++)f=r[e][2]===null?[]:r[e][2],(r[e][1]===l||f.indexOf(l)>=0)&&(s=r[e])}return o===null||s===null||o[3]!==s[3]?U:e*o[6]*u/(s[6]*d)}function Bx(e,t){if(e=J(e),e instanceof Error)return e;if(!/^-?[0-9]{1,3}$/.test(e)||e<-512||e>511)return H;if(e<0)return`1`+z_(`0`,9-(512+e).toString(2).length)+(512+e).toString(2);let n=parseInt(e,10).toString(2);return t===void 0?n:isNaN(t)?V:t<0?H:(t=Math.floor(t),t>=n.length?z_(`0`,t-n.length)+n:H)}function Vx(e,t){if(e=J(e),e instanceof Error)return e;if(!/^-?[0-9]{1,12}$/.test(e)||e<-549755813888||e>549755813887)return H;if(e<0)return(1099511627776+e).toString(16);let n=parseInt(e,10).toString(16);return t===void 0?n:isNaN(t)?V:t<0?H:(t=Math.floor(t),t>=n.length?z_(`0`,t-n.length)+n:H)}function Hx(e,t){if(e=J(e),e instanceof Error)return e;if(!/^-?[0-9]{1,9}$/.test(e)||e<-536870912||e>536870911)return H;if(e<0)return(1073741824+e).toString(8);let n=parseInt(e,10).toString(8);return t===void 0?n:isNaN(t)?V:t<0?H:(t=Math.floor(t),t>=n.length?z_(`0`,t-n.length)+n:H)}function Ux(e,t){return t=t===void 0?0:t,e=J(e),t=J(t),K(e,t)?V:+(e===t)}function Wx(e,t){return t=t===void 0?0:t,e=J(e),t=J(t),K(e,t)?V:B.default.erf(e)}function Gx(e){return isNaN(e)?V:B.default.erfc(e)}function Kx(e,t){return t||=0,e=J(e),K(t,e)?e:+(e>=t)}function qx(e,t){if(!/^[0-9A-Fa-f]{1,10}$/.test(e))return H;let n=e.length===10&&e.substring(0,1).toLowerCase()===`f`,r=n?parseInt(e,16)-1099511627776:parseInt(e,16);if(r<-512||r>511)return H;if(n)return`1`+z_(`0`,9-(512+r).toString(2).length)+(512+r).toString(2);let i=r.toString(2);return t===void 0?i:isNaN(t)?V:t<0?H:(t=Math.floor(t),t>=i.length?z_(`0`,t-i.length)+i:H)}function Jx(e){if(!/^[0-9A-Fa-f]{1,10}$/.test(e))return H;let t=parseInt(e,16);return t>=549755813888?t-1099511627776:t}function Yx(e,t){if(!/^[0-9A-Fa-f]{1,10}$/.test(e))return H;let n=parseInt(e,16);if(n>536870911&&n<0xffe0000000)return H;if(n>=0xffe0000000)return(n-0xffc0000000).toString(8);let r=n.toString(8);return t===void 0?r:isNaN(t)?V:t<0?H:(t=Math.floor(t),t>=r.length?z_(`0`,t-r.length)+r:H)}function Xx(e){let t=uS(e),n=Zx(e);return K(t,n)?V:Math.sqrt(t**2+n**2)}function Zx(e){if(e===void 0||e===!0||e===!1)return V;if(e===0||e===`0`)return 0;if([`i`,`j`].indexOf(e)>=0)return 1;e+=``,e=e.replace(`+i`,`+1i`).replace(`-i`,`-1i`).replace(`+j`,`+1j`).replace(`-j`,`-1j`);let t=e.indexOf(`+`),n=e.indexOf(`-`);t===0&&(t=e.indexOf(`+`,1)),n===0&&(n=e.indexOf(`-`,1));let r=e.substring(e.length-1,e.length),i=r===`i`||r===`j`;return t>=0||n>=0?i?t>=0?isNaN(e.substring(0,t))||isNaN(e.substring(t+1,e.length-1))?H:Number(e.substring(t+1,e.length-1)):isNaN(e.substring(0,n))||isNaN(e.substring(n+1,e.length-1))?H:-Number(e.substring(n+1,e.length-1)):H:i?isNaN(e.substring(0,e.length-1))?H:e.substring(0,e.length-1):isNaN(e)?H:0}function Qx(e){let t=uS(e),n=Zx(e);return K(t,n)?V:t===0&&n===0?Yh:t===0&&n>0?Math.PI/2:t===0&&n<0?-Math.PI/2:n===0&&t>0?0:n===0&&t<0?-Math.PI:t>0?Math.atan(n/t):t<0&&n>=0?Math.atan(n/t)+Math.PI:Math.atan(n/t)-Math.PI}function $x(e){let t=uS(e),n=Zx(e);if(K(t,n))return V;let r=e.substring(e.length-1);return r=r===`i`||r===`j`?r:`i`,n===0?e:Rx(t,-n,r)}function eS(e){let t=uS(e),n=Zx(e);if(K(t,n))return V;let r=e.substring(e.length-1);return r=r===`i`||r===`j`?r:`i`,Rx(Math.cos(t)*(Math.exp(n)+Math.exp(-n))/2,-Math.sin(t)*(Math.exp(n)-Math.exp(-n))/2,r)}function tS(e){let t=uS(e),n=Zx(e);if(K(t,n))return V;let r=e.substring(e.length-1);return r=r===`i`||r===`j`?r:`i`,Rx(Math.cos(n)*(Math.exp(t)+Math.exp(-t))/2,Math.sin(n)*(Math.exp(t)-Math.exp(-t))/2,r)}function nS(e){return K(uS(e),Zx(e))?V:rS(eS(e),pS(e))}function rS(e,t){let n=uS(e),r=Zx(e),i=uS(t),a=Zx(t);if(K(n,r,i,a))return V;let o=e.substring(e.length-1),s=t.substring(t.length-1),c=`i`;if((o===`j`||s===`j`)&&(c=`j`),i===0&&a===0)return H;let l=i*i+a*a;return Rx((n*i+r*a)/l,(r*i-n*a)/l,c)}function iS(e){let t=uS(e),n=Zx(e);if(K(t,n))return V;let r=e.substring(e.length-1);r=r===`i`||r===`j`?r:`i`;let i=Math.exp(t);return Rx(i*Math.cos(n),i*Math.sin(n),r)}function aS(e){let t=uS(e),n=Zx(e);if(K(t,n))return V;let r=e.substring(e.length-1);return r=r===`i`||r===`j`?r:`i`,Rx(Math.log(Math.sqrt(t*t+n*n)),Math.atan(n/t),r)}function oS(e){let t=uS(e),n=Zx(e);if(K(t,n))return V;let r=e.substring(e.length-1);return r=r===`i`||r===`j`?r:`i`,Rx(Math.log(Math.sqrt(t*t+n*n))/Math.log(10),Math.atan(n/t)/Math.log(10),r)}function sS(e){let t=uS(e),n=Zx(e);if(K(t,n))return V;let r=e.substring(e.length-1);return r=r===`i`||r===`j`?r:`i`,Rx(Math.log(Math.sqrt(t*t+n*n))/Math.log(2),Math.atan(n/t)/Math.log(2),r)}function cS(e,t){t=J(t);let n=uS(e),r=Zx(e);if(K(t,n,r))return V;let i=e.substring(e.length-1);i=i===`i`||i===`j`?i:`i`;let a=Xx(e)**+t,o=Qx(e);return Rx(a*Math.cos(t*o),a*Math.sin(t*o),i)}function lS(){let e=arguments[0];if(!arguments.length)return V;for(let t=1;t<arguments.length;t++){let n=uS(e),r=Zx(e),i=uS(arguments[t]),a=Zx(arguments[t]);if(K(n,r,i,a))return V;e=Rx(n*i-r*a,n*a+r*i)}return e}function uS(e){if(e===void 0||e===!0||e===!1)return V;if(e===0||e===`0`||[`i`,`+i`,`1i`,`+1i`,`-i`,`-1i`,`j`,`+j`,`1j`,`+1j`,`-j`,`-1j`].indexOf(e)>=0)return 0;e+=``;let t=e.indexOf(`+`),n=e.indexOf(`-`);t===0&&(t=e.indexOf(`+`,1)),n===0&&(n=e.indexOf(`-`,1));let r=e.substring(e.length-1,e.length),i=r===`i`||r===`j`;return t>=0||n>=0?i?t>=0?isNaN(e.substring(0,t))||isNaN(e.substring(t+1,e.length-1))?H:Number(e.substring(0,t)):isNaN(e.substring(0,n))||isNaN(e.substring(n+1,e.length-1))?H:Number(e.substring(0,n)):H:i?isNaN(e.substring(0,e.length-1))?H:0:isNaN(e)?H:e}function dS(e){return e===!0||e===!1||K(uS(e),Zx(e))?V:rS(`1`,eS(e))}function fS(e){return K(uS(e),Zx(e))?V:rS(`1`,tS(e))}function pS(e){let t=uS(e),n=Zx(e);if(K(t,n))return V;let r=e.substring(e.length-1);return r=r===`i`||r===`j`?r:`i`,Rx(Math.sin(t)*(Math.exp(n)+Math.exp(-n))/2,Math.cos(t)*(Math.exp(n)-Math.exp(-n))/2,r)}function mS(e){let t=uS(e),n=Zx(e);if(K(t,n))return V;let r=e.substring(e.length-1);return r=r===`i`||r===`j`?r:`i`,Rx(Math.cos(n)*(Math.exp(t)-Math.exp(-t))/2,Math.sin(n)*(Math.exp(t)+Math.exp(-t))/2,r)}function hS(e){if(K(uS(e),Zx(e)))return V;let t=e.substring(e.length-1);t=t===`i`||t===`j`?t:`i`;let n=Math.sqrt(Xx(e)),r=Qx(e);return Rx(n*Math.cos(r/2),n*Math.sin(r/2),t)}function gS(e){return e===!0||e===!1?V:K(uS(e),Zx(e))?H:rS(`1`,pS(e))}function _S(e){return e===!0||e===!1?V:K(uS(e),Zx(e))?H:rS(`1`,mS(e))}function vS(e,t){let n=uS(e),r=Zx(e),i=uS(t),a=Zx(t);if(K(n,r,i,a))return V;let o=e.substring(e.length-1),s=t.substring(t.length-1),c=`i`;return(o===`j`||s===`j`)&&(c=`j`),Rx(n-i,r-a,c)}function yS(){if(!arguments.length)return V;let e=W(arguments),t=0,n=0;for(let r of e){let e=+uS(r),i=+Zx(r);if(K(e,i))return V;t+=e,n+=i}return Rx(t,n,`i`)}function bS(e){return e===!0||e===!1||K(uS(e),Zx(e))?V:rS(pS(e),eS(e))}function xS(e,t){if(!/^[0-7]{1,10}$/.test(e))return H;let n=e.length===10&&e.substring(0,1)===`7`,r=n?parseInt(e,8)-1073741824:parseInt(e,8);if(r<-512||r>511)return H;if(n)return`1`+z_(`0`,9-(512+r).toString(2).length)+(512+r).toString(2);let i=r.toString(2);return t===void 0?i:isNaN(t)?V:t<0?H:(t=Math.floor(t),t>=i.length?z_(`0`,t-i.length)+i:H)}function SS(e){if(!/^[0-7]{1,10}$/.test(e))return H;let t=parseInt(e,8);return t>=536870912?t-1073741824:t}function CS(e,t){if(!/^[0-7]{1,10}$/.test(e))return H;let n=parseInt(e,8);if(n>=536870912)return`ff`+(n+3221225472).toString(16);let r=n.toString(16);return t===void 0?r:isNaN(t)?V:t<0?H:(t=Math.floor(t),t>=r.length?z_(`0`,t-r.length)+r:H)}var wS=rv.DIST,TS=rv.INV,ES=iv.DIST,DS=Ay.MATH,OS=Ay.PRECISE,kS=av.DIST,AS=av.DIST.RT,jS=av.INV,MS=av.INV.RT,NS=av.TEST,PS=pv.P,FS=pv.P,IS=pv.S,LS=iv.INV,RS=Gx.PRECISE,zS=Wx.PRECISE,BS=hv.DIST,VS=gv.DIST,HS=gv.DIST.RT,US=gv.INV,WS=gv.INV.RT,GS=Ky.MATH,KS=Ky.PRECISE,qS=gv.TEST,JS=xv.DIST,YS=xv.INV,XS=Sv.PRECISE,ZS=Dv.DIST,QS=Nv.INV,$S=Nv.DIST,eC=Nv.INV,tC=Vv.MULT,nC=Vv.SNGL,rC=Hv.DIST,iC=fx.INTL,aC=Uv.DIST,oC=Uv.INV,sC=Uv.S.DIST,cC=Uv.S.INV,lC=Gv.EXC,uC=Gv.INC,dC=Kv.EXC,fC=Kv.INC,pC=Xv.DIST,mC=Qv.EXC,hC=Qv.INC,gC=$v.AVG,_C=$v.EQ,vC=ny.P,yC=oy.P,bC=oy.S,xC=U_.DIST,SC=U_.DIST.RT,CC=U_.INV,wC=U_.TEST,TC=fy.P,EC=fy.S,DC=hy.DIST,OC=bx.INTL,kC=gy.TEST;function AC(e){let t=[];return wg(e,e=>{e&&t.push(e)}),t}function jC(e,t){let n={};for(let t=1;t<e[0].length;++t)n[t]=!0;let r=t[0].length;for(let e=1;e<t.length;++e)t[e].length>r&&(r=t[e].length);for(let i=1;i<e.length;++i)for(let a=1;a<e[i].length;++a){let o=!1,s=!1;for(let n=0;n<t.length;++n){let c=t[n];if(c.length<r)continue;let l=c[0];if(e[i][0]===l){s=!0;for(let t=1;t<c.length;++t)if(!o){if(c[t]===void 0||c[t]===`*`)o=!0;else{let n=xg(c[t]+``);o=Sg([hg(e[i][a],mg)].concat(n))}}}}s&&(n[a]=n[a]&&o)}let i=[];for(let t=0;t<e[0].length;++t)n[t]&&i.push(t-1);return i}function MC(e,t,n){if(isNaN(t)&&typeof t!=`string`)return V;let r=jC(e,n),i=[];i=Ng(typeof t==`string`?e[Fg(e,t)]:e[t]);let a=0;return wg(r,e=>{a+=i[e]}),r.length===0?Yh:a/r.length}function NC(e,t,n){if(isNaN(t)&&typeof t!=`string`)return V;let r=jC(e,n),i=[];i=Ng(typeof t==`string`?e[Fg(e,t)]:e[t]);let a=[];return wg(r,e=>{a.push(i[e])}),cv(a)}function PC(e,t,n){if(isNaN(t)&&typeof t!=`string`)return V;let r=jC(e,n),i=[];i=Ng(typeof t==`string`?e[Fg(e,t)]:e[t]);let a=[];return wg(r,e=>{a.push(i[e])}),lv(a)}function FC(e,t,n){if(isNaN(t)&&typeof t!=`string`)return V;let r=jC(e,n),i=[];return i=Ng(typeof t==`string`?e[Fg(e,t)]:e[t]),r.length===0?V:r.length>1?H:i[r[0]]}function IC(e,t,n){if(isNaN(t)&&typeof t!=`string`)return V;let r=jC(e,n),i=[];i=Ng(typeof t==`string`?e[Fg(e,t)]:e[t]);let a=i[r[0]];return wg(r,e=>{a<i[e]&&(a=i[e])}),a}function LC(e,t,n){if(isNaN(t)&&typeof t!=`string`)return V;let r=jC(e,n),i=[];i=Ng(typeof t==`string`?e[Fg(e,t)]:e[t]);let a=i[r[0]];return wg(r,e=>{a>i[e]&&(a=i[e])}),a}function RC(e,t,n){if(isNaN(t)&&typeof t!=`string`)return V;let r=jC(e,n),i=[];i=Ng(typeof t==`string`?e[Fg(e,t)]:e[t]);let a=[];wg(r,e=>{a.push(i[e])}),a=AC(a);let o=1;return wg(a,e=>{o*=e}),o}function zC(e,t,n){if(isNaN(t)&&typeof t!=`string`)return V;let r=jC(e,n),i=[];i=Ng(typeof t==`string`?e[Fg(e,t)]:e[t]);let a=[];return wg(r,e=>{a.push(i[e])}),a=AC(a),oy.S(a)}function BC(e,t,n){if(isNaN(t)&&typeof t!=`string`)return V;let r=jC(e,n),i=[];i=Ng(typeof t==`string`?e[Fg(e,t)]:e[t]);let a=[];return wg(r,e=>{a.push(i[e])}),a=AC(a),oy.P(a)}function VC(e,t,n){if(isNaN(t)&&typeof t!=`string`)return V;let r=jC(e,n),i=[];i=Ng(typeof t==`string`?e[Fg(e,t)]:e[t]);let a=[];return wg(r,e=>{a.push(i[e])}),Db(a)}function HC(e,t,n){if(isNaN(t)&&typeof t!=`string`)return V;let r=jC(e,n),i=[];i=Ng(typeof t==`string`?e[Fg(e,t)]:e[t]);let a=[];return wg(r,e=>{a.push(i[e])}),fy.S(a)}function UC(e,t,n){if(isNaN(t)&&typeof t!=`string`)return V;let r=jC(e,n),i=[];i=Ng(typeof t==`string`?e[Fg(e,t)]:e[t]);let a=[];return wg(r,e=>{a.push(i[e])}),fy.P(a)}function WC(e){return e&&e.getTime&&!isNaN(e.getTime())}function GC(e){return e instanceof Date?e:new Date(e)}function KC(e,t,n){let r=q(t);for(r.setFullYear(e.getFullYear()),r<e&&r.setFullYear(r.getFullYear()+1);r>e;)r.setMonth(r.getMonth()+-12/n);return r}function qC(e){return e=J(e),[1,2,4].indexOf(e)===-1?H:e}function JC(e){return e=J(e),[0,1,2,3,4].indexOf(e)===-1?H:e}function YC(e,t,n,r,i,a,o){return e=GC(e),t=GC(t),n=GC(n),a=qC(a),o=JC(o),G(a,o)?H:!WC(e)||!WC(t)||!WC(n)?V:r<=0||i<=0||n<=e?H:(i||=0,o||=0,i*r*wx(e,n,o))}function XC(e,t,n,r){if(r=JC(r),n=qC(n),e=q(e),t=q(t),G(e,t))return V;if(G(n,r)||e>=t)return H;if(r===1){let r=KC(e,t,n),i=q(r);return i.setMonth(i.getMonth()+12/n),ex(r,i,`D`)}let i;switch(r){case 0:case 2:case 4:i=360;break;case 3:i=365;break;default:return H}return i/n}function ZC(e,t,n,r,i,a){if(e=J(e),t=J(t),n=J(n),K(e,t,n))return V;if(e<=0||t<=0||n<=0||r<1||i<1||r>i||a!==0&&a!==1)return H;let o=hw(e,t,n,0,a),s=0;r===1&&(a===0&&(s=-n),r++);for(let t=r;t<=i;t++)s+=a===1?aw(e,t-2,o,n,1)-o:aw(e,t-1,o,n,0);return s*=e,s}function QC(e,t,n,r,i,a){if(e=J(e),t=J(t),n=J(n),K(e,t,n))return V;if(e<=0||t<=0||n<=0||r<1||i<1||r>i||a!==0&&a!==1)return H;let o=hw(e,t,n,0,a),s=0;r===1&&(s=a===0?o+n*e:o,r++);for(let t=r;t<=i;t++)s+=a>0?o-(aw(e,t-2,o,n,1)-o)*e:o-aw(e,t-1,o,n,0)*e;return s}function $C(e,t,n,r,i){if(i=i===void 0?12:i,e=J(e),t=J(t),n=J(n),r=J(r),i=J(i),K(e,t,n,r,i))return V;if(e<0||t<0||n<0||r<0||[1,2,3,4,5,6,7,8,9,10,11,12].indexOf(i)===-1||r>n)return H;if(t>=e)return 0;let a=(1-(t/e)**(1/n)).toFixed(3),o=e*a*i/12,s=o,c=0,l=r===n?n-1:r;for(let t=2;t<=l;t++)c=(e-s)*a,s+=c;return r===1?o:r===n?(e-s)*a:c}function ew(e,t,n,r,i){if(i=i===void 0?2:i,e=J(e),t=J(t),n=J(n),r=J(r),i=J(i),K(e,t,n,r,i))return V;if(e<0||t<0||n<0||r<0||i<=0||r>n)return H;if(t>=e)return 0;let a=0,o=0;for(let s=1;s<=r;s++)o=Math.min((e-a)*(i/n),e-t-a),a+=o;return o}function tw(e,t,n,r,i){if(e=q(e),t=q(t),n=J(n),r=J(r),i=J(i),i||=0,K(e,t,n,r,i))return V;if(n<=0||r<=0)return H;if(e>=t)return V;let a,o;switch(i){case 0:a=360,o=ax(e,t,!1);break;case 1:a=365,o=ex(e,t,`D`);break;case 2:a=360,o=ex(e,t,`D`);break;case 3:a=365,o=ex(e,t,`D`);break;case 4:a=360,o=ax(e,t,!0);break;default:return H}return(r-n)/r*a/o}function nw(e,t){if(e=J(e),t=J(t),K(e,t))return V;if(t<0)return H;if(t>=0&&t<1)return Yh;t=parseInt(t,10);let n=parseInt(e,10);n+=e%1*10**Math.ceil(Math.log(t)/Math.LN10)/t;let r=10**(Math.ceil(Math.log(t)/Math.LN2)+1);return n=Math.round(n*r)/r,n}function rw(e,t){if(e=J(e),t=J(t),K(e,t))return V;if(t<0)return H;if(t>=0&&t<1)return Yh;t=parseInt(t,10);let n=parseInt(e,10);return n+=e%1*10**-Math.ceil(Math.log(t)/Math.LN10)*t,n}function iw(e,t){return e=J(e),t=J(t),K(e,t)?V:e<=0||t<1?H:(t=parseInt(t,10),(1+e/t)**+t-1)}function aw(e,t,n,r,i){if(r||=0,i||=0,e=J(e),t=J(t),n=J(n),r=J(r),i=J(i),K(e,t,n,r,i))return V;let a;if(e===0)a=r+n*t;else{let o=(1+e)**+t;a=i===1?r*o+n*(1+e)*(o-1)/e:r*o+n*(o-1)/e}return-a}function ow(e,t){if(e=J(e),t=Y(W(t)),K(e,t))return V;let n=t.length,r=e;for(let e=0;e<n;e++)r*=1+t[e];return r}function sw(e,t,n,r,i,a){if(i||=0,a||=0,e=J(e),t=J(t),n=J(n),r=J(r),i=J(i),a=J(a),K(e,t,n,r,i,a))return V;let o=hw(e,n,r,i,a);return(t===1?a===1?0:-r:a===1?aw(e,t-2,o,r,1)-o:aw(e,t-1,o,r,0))*e}function cw(e,t){if(t=typeof t==`number`?t:t===void 0?.1:J(t),e=W(e).filter(Ug),e=Y(e),K(e,t))return V;let n=new Float64Array(e.length),r=!1,i=!1;for(let t=0;t<e.length;t++)n[t]=e[t],n[t]>0&&(r=!0),n[t]<0&&(i=!0);if(!r||!i)return H;let a=e=>{e<=-1&&(e=-.999999999);let t=n[0],r=1+e,i=1;for(let e=1;e<n.length;e++)i*=r,t+=n[e]/i;return t},o=new Map,s=function(e){let t=Math.round(e*1e10)/1e10;if(o.has(t))return o.get(t);let n=a(t);return o.set(t,n),n};return function(){let e=1e-10,n=1e3,r=t,i=r,a=0;for(;a<n;){let t=s(r);if(Math.abs(t)<e)return r;if(a>0&&Math.abs(r-i)<e*10)break;let n=Math.max(1e-4,Math.abs(r*1e-4)),o=(s(r+n)-t)/n;if(Math.abs(o)<e)break;i=r;let c=t/o,l=Math.max(.1,Math.abs(r)*.5);r-=Math.abs(c)>l?Math.sign(c)*l:c,r<=-1&&(r=-.99999999),r>1e3&&(r=1e3),a++}let o=s(r);if(Math.abs(o)<e)return r;let c,l;if(o>0){for(c=r,l=r+.1;s(l)>0&&l<1e3;)l=l*2+.1;if(l>=1e3)return r}else{for(l=r,c=Math.max(-.99999999,r-.1);s(c)<0&&c>-.99999999;)c=Math.max(-.99999999,c-.1);if(c<=-.99999999)return r}let u;for(let t=0;t<n;t++){u=(c+l)/2;let t=s(u);if(Math.abs(t)<e||Math.abs(l-c)<e)return u;t*s(c)<0?l=u:c=u}return u}()}function lw(e,t,n,r){return e=J(e),t=J(t),n=J(n),r=J(r),K(e,t,n,r)?V:r*e*(t/n-1)}function uw(e,t,n){if(e=Y(W(e)),t=J(t),n=J(n),K(e,t,n))return V;let r=e.length,i=[],a=[];for(let t=0;t<r;t++)e[t]<0?i.push(e[t]):a.push(e[t]);return(-pw(n,a)*(1+n)**(r-1)/(pw(t,i)*(1+t)))**(1/(r-1))-1}function dw(e,t){return e=J(e),t=J(t),K(e,t)?V:e<=0||t<1?H:(t=parseInt(t,10),((e+1)**(1/t)-1)*t)}function fw(e,t,n,r,i){if(i=i===void 0?0:i,r=r===void 0?0:r,e=J(e),t=J(t),n=J(n),r=J(r),i=J(i),K(e,t,n,r,i))return V;if(e===0)return-(n+r)/t;{let a=t*(1+e*i)-r*e,o=n*e+t*(1+e*i);return Math.log(a/o)/Math.log(1+e)}}function pw(){let e=Y(W(arguments));if(e instanceof Error)return e;let t=e[0],n=0;for(let r=1;r<e.length;r++)n+=e[r]/(1+t)**+r;return n}function mw(e,t,n){return e=J(e),t=J(t),n=J(n),K(e,t,n)?V:e<=0?H:(Math.log(n)-Math.log(t))/Math.log(1+e)}function hw(e,t,n,r,i){if(r||=0,i||=0,e=J(e),t=J(t),n=J(n),r=J(r),i=J(i),K(e,t,n,r,i))return V;let a;if(e===0)a=(n+r)/t;else{let o=(1+e)**+t;a=i===1?(r*e/(o-1)+n*e/(1-1/o))/(1+e):r*e/(o-1)+n*e/(1-1/o)}return-a}function gw(e,t,n,r,i,a){return i||=0,a||=0,e=J(e),n=J(n),r=J(r),i=J(i),a=J(a),K(e,n,r,i,a)?V:hw(e,n,r,i,a)-sw(e,t,n,r,i,a)}function _w(e,t,n,r,i){if(e=q(e),t=q(t),n=J(n),r=J(r),i=J(i),i||=0,K(e,t,n,r,i))return V;if(n<=0||r<=0)return H;if(e>=t)return V;let a,o;switch(i){case 0:a=360,o=ax(e,t,!1);break;case 1:a=365,o=ex(e,t,`D`);break;case 2:a=360,o=ex(e,t,`D`);break;case 3:a=365,o=ex(e,t,`D`);break;case 4:a=360,o=ax(e,t,!0);break;default:return H}return r-n*r*o/a}function vw(e,t,n,r,i){return r||=0,i||=0,e=J(e),t=J(t),n=J(n),r=J(r),i=J(i),K(e,t,n,r,i)?V:e===0?-n*t-r:((1-(1+e)**+t)/e*n*(1+e*i)-r)/(1+e)**+t}function yw(e,t,n,r,i,a){if(a=a===void 0?.1:a,r=r===void 0?0:r,i=i===void 0?0:i,e=J(e),t=J(t),n=J(n),r=J(r),i=J(i),a=J(a),K(e,t,n,r,i,a))return V;let o=1e-10,s=a;i=+!!i;for(let a=0;a<100;a++){if(s<=-1)return H;let a,c;if(Math.abs(s)<o?a=n*(1+e*s)+t*(1+s*i)*e+r:(c=(1+s)**+e,a=n*c+t*(1/s+i)*(c-1)+r),Math.abs(a)<o)return s;let l;if(Math.abs(s)<o)l=n*e+t*i*e;else{c=(1+s)**+e;let r=e*(1+s)**(e-1);l=n*r+t*(1/s+i)*r+t*(-1/(s*s))*(c-1)}s-=a/l}return s}function bw(e,t,n){return e=J(e),t=J(t),n=J(n),K(e,t,n)?V:e===0||t===0?H:(n/t)**(1/e)-1}function xw(e,t,n){return e=J(e),t=J(t),n=J(n),K(e,t,n)?V:n===0?H:(e-t)/n}function Sw(e,t,n,r){return e=J(e),t=J(t),n=J(n),r=J(r),K(e,t,n,r)?V:n===0||r<1||r>n?H:(r=parseInt(r,10),(e-t)*(n-r+1)*2/(n*(n+1)))}function Cw(e,t,n){return e=q(e),t=q(t),n=J(n),K(e,t,n)?V:n<=0||e>t||t-e>31536e6?H:365*n/(360-n*ax(e,t,!1))}function ww(e,t,n){return e=q(e),t=q(t),n=J(n),K(e,t,n)?V:n<=0||e>t||t-e>31536e6?H:100*(1-n*ax(e,t,!1)/360)}function Tw(e,t,n){return e=q(e),t=q(t),n=J(n),K(e,t,n)?V:n<=0||e>t||t-e>31536e6?H:(100-n)*360/(n*ax(e,t,!1))}function Ew(e,t,n){if(e=Y(W(e)),t=zg(W(t)),n=J(n),K(e,t,n))return V;let r=(e,t,n)=>{let r=n+1,i=e[0];for(let n=1;n<e.length;n++)i+=e[n]/r**(ix(t[n],t[0])/365);return i},i=(e,t,n)=>{let r=n+1,i=0;for(let n=1;n<e.length;n++){let a=ix(t[n],t[0])/365;i-=a*e[n]/r**+(a+1)}return i},a=!1,o=!1;for(let t=0;t<e.length;t++)e[t]>0&&(a=!0),e[t]<0&&(o=!0);if(!a||!o)return H;n||=.1;let s=n,c=1e-10,l,u,d,f=!0;do d=r(e,t,s),l=s-d/i(e,t,s),u=Math.abs(l-s),s=l,f=u>c&&Math.abs(d)>c;while(f);return s}function Dw(e,t,n){if(e=J(e),t=Y(W(t)),n=zg(W(n)),K(e,t,n))return V;let r=0;for(let i=0;i<t.length;i++)r+=t[i]/(1+e)**(ix(n[i],n[0])/365);return r}function Ow(){let e=W(arguments),t=V;for(let n=0;n<e.length;n++){if(e[n]instanceof Error)return e[n];e[n]!==void 0&&e[n]!==null&&typeof e[n]!=`string`&&(t===V&&(t=!0),e[n]||(t=!1))}return t}function kw(){return!1}function Aw(e,t,n){return e instanceof Error?e:(t=arguments.length>=2?t:!0,t??=0,n=arguments.length===3&&n,n??=0,e?t:n)}function jw(){for(let e=0;e<arguments.length/2;e++)if(arguments[e*2])return arguments[e*2+1];return U}function Mw(e,t){return qg(e)?t:e}function Nw(e,t){return e===U?t:e}function Pw(e){return typeof e==`string`?V:e instanceof Error?e:!e}function Fw(){let e=W(arguments),t=V;for(let n=0;n<e.length;n++){if(e[n]instanceof Error)return e[n];e[n]!==void 0&&e[n]!==null&&typeof e[n]!=`string`&&(t===V&&(t=!1),e[n]&&(t=!0))}return t}function Iw(){return!0}function Lw(){let e=W(arguments),t=V;for(let n=0;n<e.length;n++){if(e[n]instanceof Error)return e[n];e[n]!==void 0&&e[n]!==null&&typeof e[n]!=`string`&&(t===V&&(t=0),e[n]&&t++)}return t===V?t:!!(Math.floor(Math.abs(t))&1)}function Rw(){let e;if(arguments.length>0){let t=arguments[0],n=arguments.length-1,r=Math.floor(n/2),i=!1,a=n%2!=0,o=n%2==0?null:arguments[arguments.length-1];if(r){for(let n=0;n<r;n++)if(t===arguments[n*2+1]){e=arguments[n*2+2],i=!0;break}}i||(e=a?o:U)}else e=V;return e}var zw={errors:tg,symbols:Yb,date:sg},Bw=Kh;function Vw(e){let t=e.split(`.`).reduce((e,t)=>e?.[t],Bw);if(typeof t!=`function`)throw Error(`@formulajs/formulajs has no ${e}.`);return t}function Hw(e){return typeof e==`number`?Number.isFinite(e)?e:w.NUM:e instanceof Error?je(e.message)??w.VALUE:typeof e==`boolean`||typeof e==`string`?e:w.VALUE}var Uw=(e,t)=>{try{return Hw(e(...t))}catch{return w.VALUE}};function Ww(e,t){return ad([e],t)}function Gw(e,t){let n=L(e,t);if(n instanceof C)return n;let r=[];for(let e=0;e<n.rows;e++){let t=[];for(let r=0;r<n.cols;r++){let i=n.at(e,r);if(i instanceof C)return i;t.push(typeof i==`number`?i:0)}r.push(t)}return r}function X(e,t,n){let r=t.split(`?`)[0]?.length??0,i=t.replace(`?`,``),a=Vw(n);F(e,r,i.length,(...e)=>{let t=[];for(let[n,r]of e.entries()){if(r===void 0){t.push(void 0);continue}let e=i.charAt(n),a=e===`n`?N(r):e===`b`?Ru(r):P(r);if(a instanceof C)return a;t.push(a)}return Uw(a,t)},{from:`formulajs`})}function Kw(e,t,n){let r=t.replace(`?`,``),i=r.endsWith(`r`),a=Vw(n);I(e,Array.from({length:t.length},(e,n)=>{let r=t.charAt(n);return r===`?`?`?`:i&&n===t.length-1?`(r)`:`lm`.includes(r)?`r`:`v`}).join(``),(e,t)=>{let n=[];for(let[a,o]of e.entries()){let s=i&&a>=r.length-1?`r`:r.charAt(a);if(s===`r`){let r=ad(e.slice(a),t);if(r instanceof C)return r;n.push(r);break}if(o instanceof D){n.push(void 0);continue}let c;if(s===`l`)c=Ww(o,t);else if(s===`m`)c=Gw(o,t);else{let e=t.calc.scalar(o,t.frame);c=s===`n`?N(e):s===`b`?Ru(e):P(e)}if(c instanceof C)return c;n.push(c)}return Uw(a,n)},{from:`formulajs`})}function qw(e,t,n=``,r=1){let i=Vw(t),a=n.length;I(e,`${`v`.repeat(a)}rr`,(e,t)=>{let n=[];for(let r of e.slice(0,a)){let e=N(t.calc.scalar(r,t.frame));if(e instanceof C)return e;n.push(e)}let o=L(e[a],t),s=L(e[a+1],t);if(o instanceof C)return o;if(s instanceof C)return s;if(o.rows*o.cols!==s.rows*s.cols)return w.NA;let c=[],l=[];for(let e=0;e<o.rows;e++)for(let t=0;t<o.cols;t++){let n=o.at(e,t),r=s.rows===o.rows?s.at(e,t):s.at(t,e);if(n instanceof C)return n;if(r instanceof C)return r;typeof n==`number`&&typeof r==`number`&&(c.push(n),l.push(r))}if(c.length<r)return w.DIV0;let u=Uw(i,[...n,c,l]);return u===w.NUM?w.DIV0:u},{from:`formulajs`})}function Jw(e,t,n=!1,r=1,i=w.DIV0){let a=Vw(t);I(e,`(r)`,(e,t)=>{let o=n?od(e,t):ad(e,t);if(o instanceof C)return o;if(o.length<r)return i;let s=Uw(a,[o]);return s===w.NUM&&i===w.DIV0?w.DIV0:s},{from:`formulajs`})}function Yw(e){let t=/^([+-]?[\d.]+(?:e[+-]?\d+)?)?(?:([+-]?)([\d.]+(?:e[+-]?\d+)?)?([ij]))?$/iu.exec(e);if(!t)return e;let[,n,r,i,a]=t,o=n===void 0?``:Ue(Number(n));if(a===void 0)return o;let s=i===void 0?``:Ue(Number(i));return`${o}${r??``}${s===`1`?``:s}${a}`}function Xw(e,t){let n=Vw(e);F(e,t.length,t.length,(...e)=>{let r=[];for(let[n,i]of e.entries()){let e=t.charAt(n)===`n`?N(i):P(i);if(e instanceof C)return e;r.push(e)}let i=Uw(n,r);return typeof i==`string`?Yw(i):i},{from:`formulajs`})}for(let e of`ABS.ACOS.ACOSH.ACOT.ACOTH.ASIN.ASINH.ATAN.ATANH.COS.COSH.COT.COTH.CSC.CSCH.DEGREES.EVEN.EXP.INT.LN.LOG10.ODD.RADIANS.SEC.SECH.SIGN.SIN.SINH.SQRT.SQRTPI.TAN.TANH`.split(`.`))X(e,`n`,e);for(let e of[`COMBIN`,`COMBINA`,`MROUND`,`PERMUT`,`PERMUTATIONA`,`POWER`])X(e,`nn`,e);X(`TRUNC`,`n?n`,`TRUNC`),X(`CEILING`,`nn`,`CEILING`),F(`FLOOR`,2,2,(e,t)=>{let n=N(e??0);if(n instanceof C)return n;let r=N(t??0);return r instanceof C?r:n===0&&r===0?0:Uw(Vw(`FLOOR`),[n,r])}),X(`CEILING.MATH`,`n?nn`,`CEILINGMATH`),X(`FLOOR.MATH`,`n?nn`,`FLOORMATH`),X(`CEILING.PRECISE`,`n?n`,`CEILINGPRECISE`),X(`FLOOR.PRECISE`,`n?n`,`FLOORPRECISE`),nd(`ISO.CEILING`,`CEILING.PRECISE`),F(`PI`,0,0,()=>Math.PI),I(`RAND`,``,(e,t)=>t.calc.random(),{volatile:!0}),I(`RANDBETWEEN`,`vv`,(e,t)=>{let n=N(t.calc.scalar(e[0],t.frame)),r=N(t.calc.scalar(e[1],t.frame));if(n instanceof C)return n;if(r instanceof C)return r;let i=Math.ceil(n),a=Math.floor(r);return i>a?w.NUM:i+Math.floor(t.calc.random()*(a-i+1))},{volatile:!0}),Jw(`MULTINOMIAL`,`MULTINOMIAL`),Jw(`AVEDEV`,`AVEDEV`,!1,1,w.NUM),Jw(`DEVSQ`,`DEVSQ`,!1,1,w.NUM),Jw(`MEDIAN`,`MEDIAN`,!1,1,w.NUM),Jw(`SKEW`,`SKEW`,!1,3),Jw(`SKEW.P`,`SKEW.P`,!1,3),Jw(`STDEV.S`,`STDEV.S`,!1,2),Jw(`STDEV.P`,`STDEV.P`,!1,1),Jw(`VAR.S`,`VAR.S`,!1,2),Jw(`VAR.P`,`VAR.P`,!1,1),Jw(`STDEVA`,`STDEVA`,!0,2),Jw(`STDEVPA`,`STDEVPA`,!0,1),Jw(`VARA`,`VARA`,!0,2),Jw(`VARPA`,`VARPA`,!0,1);for(let[e,t]of[[`STDEV`,`STDEV.S`],[`STDEVP`,`STDEV.P`],[`VAR`,`VAR.S`],[`VARP`,`VAR.P`]])nd(e,t);Kw(`PERCENTILE.INC`,`ln`,`PERCENTILE.INC`),Kw(`PERCENTILE.EXC`,`ln`,`PERCENTILE.EXC`),Kw(`PERCENTRANK.INC`,`ln?n`,`PERCENTRANK.INC`),Kw(`PERCENTRANK.EXC`,`ln?n`,`PERCENTRANK.EXC`),Kw(`QUARTILE.EXC`,`ln`,`QUARTILE.EXC`),I(`TRIMMEAN`,`rv`,(e,t)=>{let n=ad([e[0]],t);if(n instanceof C)return n;let r=N(t.calc.scalar(e[1],t.frame));if(r instanceof C)return r;if(r<0||r>=1||n.length===0)return w.NUM;let i=Math.floor(n.length*r/2),a=[...n].sort((e,t)=>e-t).slice(i,n.length-i);return a.reduce((e,t)=>e+t,0)/a.length}),nd(`PERCENTILE`,`PERCENTILE.INC`),nd(`PERCENTRANK`,`PERCENTRANK.INC`),qw(`CORREL`,`CORREL`),qw(`PEARSON`,`PEARSON`),qw(`RSQ`,`RSQ`),qw(`SLOPE`,`SLOPE`),qw(`INTERCEPT`,`INTERCEPT`),qw(`STEYX`,`STEYX`,``,3),qw(`COVARIANCE.P`,`COVARIANCE.P`),qw(`COVARIANCE.S`,`COVARIANCE.S`,``,2),qw(`FORECAST`,`FORECAST`,`n`),nd(`FORECAST.LINEAR`,`FORECAST`),nd(`COVAR`,`COVARIANCE.P`),X(`PV`,`nnn?nn`,`PV`),X(`NPER`,`nnn?nn`,`NPER`),X(`RATE`,`nnn?nnn`,`RATE`),X(`SYD`,`nnnn`,`SYD`),X(`DDB`,`nnnn?n`,`DDB`),X(`ISPMT`,`nnnn`,`ISPMT`),X(`EFFECT`,`nn`,`EFFECT`),X(`NOMINAL`,`nn`,`NOMINAL`),X(`CUMIPMT`,`nnnnnn`,`CUMIPMT`),X(`CUMPRINC`,`nnnnnn`,`CUMPRINC`),X(`DOLLARDE`,`nn`,`DOLLARDE`),X(`DOLLARFR`,`nn`,`DOLLARFR`),X(`PDURATION`,`nnn`,`PDURATION`),X(`RRI`,`nnn`,`RRI`),Kw(`IRR`,`l?n`,`IRR`),Kw(`MIRR`,`lnn`,`MIRR`),Kw(`NPV`,`nr`,`NPV`),Kw(`FVSCHEDULE`,`nl`,`FVSCHEDULE`);for(let e of[`BIN2DEC`,`HEX2DEC`,`OCT2DEC`,`IMABS`,`IMAGINARY`,`IMARGUMENT`,`IMREAL`])X(e,`t`,e);for(let e of[`IMCONJUGATE`,`IMCOS`,`IMCOSH`,`IMCOT`,`IMCSC`,`IMCSCH`,`IMEXP`,`IMLN`,`IMLOG10`,`IMLOG2`,`IMSEC`,`IMSECH`,`IMSIN`,`IMSINH`,`IMSQRT`,`IMTAN`])Xw(e,`t`);for(let e of[`BIN2OCT`,`HEX2BIN`,`HEX2OCT`,`OCT2BIN`])X(e,`t?n`,e);for(let e of[`DEC2BIN`,`DEC2OCT`])X(e,`n?n`,e);for(let[e,t]of[[`BIN2HEX`,`t`],[`OCT2HEX`,`t`],[`DEC2HEX`,`n`]]){let n=Vw(e);F(e,1,2,(e,r)=>{let i=t===`n`?N(e):P(e);if(i instanceof C)return i;let a=r===void 0?void 0:N(r);if(a instanceof C)return a;let o=Uw(n,[i,a]);return typeof o==`string`?o.toUpperCase():o},{from:`formulajs`})}Xw(`IMDIV`,`tt`),Xw(`IMSUB`,`tt`),Xw(`IMPOWER`,`tn`),X(`COMPLEX`,`nn?t`,`COMPLEX`),X(`DECIMAL`,`tn`,`DECIMAL`),X(`ARABIC`,`t`,`ARABIC`);for(let e of[`IMSUM`,`IMPRODUCT`]){let t=Vw(e);I(e,`(r)`,(e,n)=>{let r=[],i;if(rd(e,n,e=>{if(i||e===null)return;let t=P(e);t instanceof C?i=t:r.push(t)}),i)return i;let a=Uw(t,r);return typeof a==`string`?Yw(a):a},{from:`formulajs`})}X(`DELTA`,`n?n`,`DELTA`),X(`GESTEP`,`n?n`,`GESTEP`);var Zw=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.00016431823292116355,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22],Qw=607/128,$w=.5*Math.log(2*Math.PI);function eT(e){if(Number.isInteger(e)&&e<=171)return Math.log(tT(e));let t=Zw[0]??0;for(let n=1;n<Zw.length;n++)t+=(Zw[n]??0)/(e+n);let n=e+Qw+.5;return $w+Math.log(t/e)+(e+.5)*Math.log(n)-n}function tT(e){if(e<=0&&Number.isInteger(e))return NaN;if(Number.isInteger(e)&&e<=171){let t=1;for(let n=2;n<e;n++)t*=n;return t}return e<.5?Math.PI/(Math.sin(Math.PI*e)*tT(1-e)):Math.exp(eT(e))}var nT=1e-16,rT=1e-300,iT=1e5;function aT(e,t){if(t<=0)return 0;if(t<e+1){let n=1/e,r=n,i=e;for(let e=0;e<iT&&(i+=1,n*=t/i,r+=n,!(Math.abs(n)<Math.abs(r)*nT));e++);return r*Math.exp(-t+e*Math.log(t)-eT(e))}return 1-oT(e,t)}function oT(e,t){if(t<=0)return 1;if(t<e+1)return 1-aT(e,t);let n=t+1-e,r=1/rT,i=1/n,a=i;for(let t=1;t<iT;t++){let o=-t*(t-e);n+=2,i=o*i+n,Math.abs(i)<rT&&(i=rT),r=n+o/r,Math.abs(r)<rT&&(r=rT),i=1/i;let s=i*r;if(a*=s,Math.abs(s-1)<nT)break}return Math.exp(-t+e*Math.log(t)-eT(e))*a}function sT(e,t,n){let r=e+t,i=e+1,a=e-1,o=1,s=1-r*n/i;Math.abs(s)<rT&&(s=rT),s=1/s;let c=s;for(let l=1;l<iT;l++){let u=2*l,d=l*(t-l)*n/((a+u)*(e+u));s=1+d*s,Math.abs(s)<rT&&(s=rT),o=1+d/o,Math.abs(o)<rT&&(o=rT),s=1/s,c*=s*o,d=-(e+l)*(r+l)*n/((e+u)*(i+u)),s=1+d*s,Math.abs(s)<rT&&(s=rT),o=1+d/o,Math.abs(o)<rT&&(o=rT),s=1/s;let f=s*o;if(c*=f,Math.abs(f-1)<nT)break}return c}function cT(e,t,n){if(n<=0)return 0;if(n>=1)return 1;let r=Math.exp(eT(e+t)-eT(e)-eT(t)+e*Math.log(n)+t*Math.log1p(-n));return n<(e+1)/(e+t+2)?r*sT(e,t,n)/e:1-r*sT(t,e,1-n)/t}var lT=e=>e===0?0:(e<0?-1:1)*aT(.5,e*e),uT=e=>e<0?2-uT(-e):oT(.5,e*e),dT=e=>Math.exp(-e*e/2)/Math.sqrt(2*Math.PI),fT=e=>uT(-e/Math.SQRT2)/2,pT=(e,t)=>e.reduce((e,n)=>e*t+n,0),mT={a:[2509.0859296330846,33430.57558358813,67265.7709270087,45921.95393154987,13731.69376550946,1971.5909503065513,133.14166789178438,3.3871328727963665],b:[5226.495278852854,28729.085735721943,39307.89580009271,21213.794301586597,5394.196021424751,687.1870074920579,42.31333070160091,1],c:[.0007745450142783414,.022723844989269184,.2417807251774506,1.2704582524523684,3.6478483247632045,5.769497221460691,4.630337846156546,1.4234371107496837],d:[1.0507500716444169e-9,.0005475938084995344,.015198666563616457,.14810397642748008,.6897673349851,1.6763848301838038,2.053191626637759,1],e:[2.0103343992922881e-7,27115555687434876e-21,.0012426609473880784,.026532189526576124,.29656057182850487,1.7848265399172913,5.463784911164114,6.657904643501104],f:[20442631033899397e-31,1.421511758316446e-7,18463183175100548e-21,.0007868691311456133,.014875361290850615,.1369298809227358,.599832206555888,1]};function hT(e){let t=e-.5;if(t===0)return 0;if(Math.abs(t)<=.425){let e=.180625-t*t;return t*pT(mT.a,e)/pT(mT.b,e)}let n=t<0?e:1-e,r=Math.sqrt(-Math.log(n)),i=r<=5?pT(mT.c,r-1.6)/pT(mT.d,r-1.6):pT(mT.e,r-5)/pT(mT.f,r-5);return t<0?-i:i}function gT(e,t,n,r,i=1/0){let a=n,o=Math.min(r,i);for(;e(o)<t&&o<i;)a=o,o=Math.min(o*2+1,i);for(let n=0;n<400;n++){let n=(a+o)/2;if(n===a||n===o)return n;e(n)<t?a=n:o=n}return(a+o)/2}function _T(e,t,n,r){let i=(n-t)/r,a=e(t)+e(n);for(let n=1;n<r;n++)a+=e(t+n*i)*(n%2==1?4:2);return a*i/3}var vT=4e4;function yT(e,t){let n=Math.max(256,4*Math.ceil(Math.abs(t)+e)+256),r=Math.PI/n,i=.5*(Math.cos(0)+Math.cos(e*Math.PI));for(let a=1;a<n;a++){let n=a*r;i+=Math.cos(e*n-t*Math.sin(n))}return i*r/Math.PI}function bT(e,t){let n=_T(n=>Math.sin(t*Math.sin(n)-e*n),0,Math.PI,vT),r=Math.asinh((760+2*e*e)/t)+2,i=e%2==0?1:-1;return(n-_T(n=>(Math.exp(e*n)+i*Math.exp(-e*n))*Math.exp(-t*Math.sinh(n)),0,r,vT))/Math.PI}function xT(e,t){let n=Math.max(256,4*Math.ceil(Math.abs(t)+e)+256),r=Math.PI/n,i=.5*(Math.exp(t)+Math.exp(-t)*Math.cos(e*Math.PI));for(let a=1;a<n;a++){let n=a*r;i+=Math.exp(t*Math.cos(n))*Math.cos(e*n)}return i*r/Math.PI}function ST(e,t){let n=Math.acosh(760/t+1)+2+e,r=4096,i=n/r,a=.5*Math.exp(-t);for(let n=1;n<=r;n++){let r=n*i;a+=Math.exp(-t*Math.cosh(r))*Math.cosh(e*r)}return a*i}function Z(e,t,n,r){F(e,t,n,(...e)=>{let t=[];for(let n of e){let e=n===void 0?NaN:N(n);if(e instanceof C)return e;t.push(e)}return r(...t)})}function CT(e,t,n,r=0){F(e,t+1,t+1+r,(...e)=>{let r=Ru(e[t]);if(r instanceof C)return r;let i=[];for(let[n,r]of e.entries()){if(n===t)continue;let e=r===void 0?NaN:N(r);if(e instanceof C)return e;i.push(e)}return n(r,...i)})}var wT=e=>Number.isFinite(e)?e:w.NUM;CT(`NORM.DIST`,3,(e,t=0,n=0,r=0)=>{if(r<=0)return w.NUM;let i=(t-n)/r;return e?fT(i):dT(i)/r}),Z(`NORM.INV`,3,3,(e=0,t=0,n=0)=>e<=0||e>=1||n<=0?w.NUM:t+n*hT(e)),F(`NORM.S.DIST`,1,2,(e,t)=>{let n=N(e);if(n instanceof C)return n;let r=t===void 0||Ru(t);return r instanceof C?r:r?fT(n):dT(n)}),Z(`NORMSDIST`,1,1,(e=0)=>fT(e)),Z(`NORM.S.INV`,1,1,(e=0)=>e<=0||e>=1?w.NUM:hT(e)),CT(`LOGNORM.DIST`,3,(e,t=0,n=0,r=0)=>{if(t<=0||r<=0)return w.NUM;let i=(Math.log(t)-n)/r;return e?fT(i):dT(i)/(t*r)}),Z(`LOGNORMDIST`,3,3,(e=0,t=0,n=0)=>e<=0||n<=0?w.NUM:fT((Math.log(e)-t)/n)),Z(`LOGNORM.INV`,3,3,(e=0,t=0,n=0)=>e<=0||e>=1||n<=0?w.NUM:Math.exp(t+n*hT(e))),Z(`STANDARDIZE`,3,3,(e=0,t=0,n=0)=>n<=0?w.NUM:(e-t)/n),Z(`GAUSS`,1,1,(e=0)=>fT(e)-.5),Z(`PHI`,1,1,(e=0)=>dT(e)),Z(`FISHER`,1,1,(e=0)=>e<=-1||e>=1?w.NUM:.5*Math.log((1+e)/(1-e))),Z(`FISHERINV`,1,1,(e=0)=>{let t=Math.exp(2*e);return(t-1)/(t+1)}),Z(`CONFIDENCE.NORM`,3,3,(e=0,t=0,n=0)=>{let r=Math.trunc(n);return e<=0||e>=1||t<=0||r<1?w.NUM:hT(1-e/2)*t/Math.sqrt(r)});var TT=(e,t)=>cT(t/2,.5,t/(t+e*e)),ET=(e,t)=>e<0?TT(e,t)/2:1-TT(e,t)/2;CT(`T.DIST`,2,(e,t=0,n=0)=>{let r=Math.trunc(n);return r<1?w.NUM:e?ET(t,r):Math.exp(eT((r+1)/2)-eT(r/2))/Math.sqrt(r*Math.PI)*(1+t*t/r)**(-(r+1)/2)}),Z(`T.DIST.2T`,2,2,(e=0,t=0)=>{let n=Math.trunc(t);return e<0||n<1?w.NUM:TT(e,n)}),Z(`T.DIST.RT`,2,2,(e=0,t=0)=>{let n=Math.trunc(t);return n<1?w.NUM:e<0?1-TT(e,n)/2:TT(e,n)/2}),Z(`TDIST`,3,3,(e=0,t=0,n=0)=>{let r=Math.trunc(t),i=Math.trunc(n);return e<0||r<1||i!==1&&i!==2?w.NUM:TT(e,r)*i/2}),Z(`T.INV`,2,2,(e=0,t=0)=>{let n=Math.trunc(t);return e<=0||e>=1||n<1?w.NUM:e===.5?0:e<.5?-DT(2*e,n):DT(2*(1-e),n)});var DT=(e,t)=>gT(e=>-TT(e,t),-e,0,1);Z(`T.INV.2T`,2,2,(e=0,t=0)=>{let n=Math.trunc(t);return e<=0||e>1||n<1?w.NUM:DT(e,n)}),Z(`CONFIDENCE.T`,3,3,(e=0,t=0,n=0)=>{let r=Math.trunc(n);return e<=0||e>=1||t<=0||r<1?w.NUM:r===1?w.DIV0:DT(e,r-1)*t/Math.sqrt(r)}),CT(`CHISQ.DIST`,2,(e,t=0,n=0)=>{let r=Math.trunc(n);return t<0||r<1?w.NUM:e?aT(r/2,t/2):t===0?r===2?.5:r<2?w.NUM:0:Math.exp((r/2-1)*Math.log(t)-t/2-r/2*Math.LN2-eT(r/2))}),Z(`CHISQ.DIST.RT`,2,2,(e=0,t=0)=>{let n=Math.trunc(t);return e<0||n<1?w.NUM:oT(n/2,e/2)}),Z(`CHISQ.INV`,2,2,(e=0,t=0)=>{let n=Math.trunc(t);return e<0||e>=1||n<1?w.NUM:e===0?0:gT(e=>aT(n/2,e/2),e,0,n)}),Z(`CHISQ.INV.RT`,2,2,(e=0,t=0)=>{let n=Math.trunc(t);return e<=0||e>1||n<1?w.NUM:e===1?0:gT(e=>-oT(n/2,e/2),-e,0,n)});var OT=(e,t,n)=>cT(t/2,n/2,t*e/(t*e+n)),kT=(e,t,n)=>cT(n/2,t/2,n/(t*e+n));CT(`F.DIST`,3,(e,t=0,n=0,r=0)=>{let i=Math.trunc(n),a=Math.trunc(r);if(t<0||i<1||a<1)return w.NUM;if(e)return OT(t,i,a);if(t===0)return i===2?1:i<2?w.NUM:0;let o=eT((i+a)/2)-eT(i/2)-eT(a/2)+i/2*Math.log(i/a)+(i/2-1)*Math.log(t)-(i+a)/2*Math.log(1+i*t/a);return Math.exp(o)}),Z(`F.DIST.RT`,3,3,(e=0,t=0,n=0)=>{let r=Math.trunc(t),i=Math.trunc(n);return e<0||r<1||i<1?w.NUM:kT(e,r,i)}),Z(`F.INV`,3,3,(e=0,t=0,n=0)=>{let r=Math.trunc(t),i=Math.trunc(n);return e<0||e>1||r<1||i<1?w.NUM:e===0?0:e===1?w.NUM:gT(e=>OT(e,r,i),e,0,1)}),Z(`F.INV.RT`,3,3,(e=0,t=0,n=0)=>{let r=Math.trunc(t),i=Math.trunc(n);return e<=0||e>1||r<1||i<1?w.NUM:e===1?0:gT(e=>-kT(e,r,i),-e,0,1)}),CT(`GAMMA.DIST`,3,(e,t=0,n=0,r=0)=>t<0||n<=0||r<=0?w.NUM:e?aT(n,t/r):t===0?n===1?1/r:n<1?w.NUM:0:Math.exp((n-1)*Math.log(t)-t/r-n*Math.log(r)-eT(n))),Z(`GAMMA.INV`,3,3,(e=0,t=0,n=0)=>e<0||e>=1||t<=0||n<=0?w.NUM:e===0?0:n*gT(e=>aT(t,e),e,0,t));var AT=(e,t,n)=>Math.exp(eT(t+n)-eT(t)-eT(n)+(t-1)*Math.log(e)+(n-1)*Math.log1p(-e));CT(`BETA.DIST`,3,(e,t=0,n=0,r=0,i=0,a=1)=>{let o=Number.isNaN(i)?0:i,s=Number.isNaN(a)?1:a;if(n<=0||r<=0||t<o||t>s||o===s)return w.NUM;let c=(t-o)/(s-o);return e?cT(n,r,c):AT(c,n,r)/(s-o)},2),Z(`BETADIST`,3,5,(e=0,t=0,n=0,r=0,i=1)=>{let a=Number.isNaN(r)?0:r,o=Number.isNaN(i)?1:i;return t<=0||n<=0||e<a||e>o||a===o?w.NUM:cT(t,n,(e-a)/(o-a))}),Z(`BETA.INV`,3,5,(e=0,t=0,n=0,r=0,i=1)=>{let a=Number.isNaN(r)?0:r,o=Number.isNaN(i)?1:i;return e<=0||e>1||t<=0||n<=0||a>=o?w.NUM:a+(o-a)*gT(e=>cT(t,n,e),e,0,.5,1)}),nd(`BETAINV`,`BETA.INV`);var jT=(e,t)=>eT(e+1)-eT(t+1)-eT(e-t+1),MT=(e,t,n)=>n===0?+(e===0):n===1?+(e===t):Math.exp(jT(t,e)+e*Math.log(n)+(t-e)*Math.log1p(-n)),NT=(e,t,n)=>e>=t||n===0?1:n===1?0:1-cT(e+1,t-e,n);CT(`BINOM.DIST`,3,(e,t=0,n=0,r=0)=>{let i=Math.trunc(t),a=Math.trunc(n);return i<0||i>a||r<0||r>1?w.NUM:e?NT(i,a,r):MT(i,a,r)}),Z(`BINOM.INV`,3,3,(e=0,t=0,n=0)=>{let r=Math.trunc(e);if(r<0||t<=0||t>=1||n<=0||n>=1)return w.NUM;for(let e=0;e<r;e++)if(NT(e,r,t)>=n)return e;return r}),Z(`BINOM.DIST.RANGE`,3,4,(e=0,t=0,n=0,r=NaN)=>{let i=Math.trunc(e),a=Math.trunc(n),o=Number.isNaN(r)?a:Math.trunc(r);if(i<0||t<0||t>1||a<0||a>i||o<a||o>i)return w.NUM;let s=0;for(let e=a;e<=o;e++)s+=MT(e,i,t);return s}),CT(`NEGBINOM.DIST`,3,(e,t=0,n=0,r=0)=>{let i=Math.trunc(t),a=Math.trunc(n);return i<0||a<1||r<0||r>1?w.NUM:e?cT(a,i+1,r):r===0||r===1?+(r===1&&i===0):Math.exp(jT(i+a-1,a-1)+a*Math.log(r)+i*Math.log1p(-r))}),Z(`NEGBINOMDIST`,3,3,(e=0,t=0,n=0)=>{let r=Math.trunc(e),i=Math.trunc(t);return r<0||i<1||n<0||n>1?w.NUM:n===0||n===1?+(n===1&&r===0):Math.exp(jT(r+i-1,i-1)+i*Math.log(n)+r*Math.log1p(-n))}),CT(`POISSON.DIST`,2,(e,t=0,n=0)=>{let r=Math.trunc(t);return r<0||n<0?w.NUM:n===0?e||r===0?1:0:e?oT(r+1,n):Math.exp(r*Math.log(n)-n-eT(r+1))}),CT(`EXPON.DIST`,2,(e,t=0,n=0)=>t<0||n<=0?w.NUM:e?-Math.expm1(-n*t):n*Math.exp(-n*t)),CT(`WEIBULL.DIST`,3,(e,t=0,n=0,r=0)=>{if(t<0||n<=0||r<=0)return w.NUM;let i=(t/r)**n;return e?-Math.expm1(-i):n/r**n*t**(n-1)*Math.exp(-i)});var PT=(e,t,n,r)=>Math.exp(jT(n,e)+jT(r-n,t-e)-jT(r,t));CT(`HYPGEOM.DIST`,4,(e,t=0,n=0,r=0,i=0)=>{let a=Math.trunc(t),o=Math.trunc(n),s=Math.trunc(r),c=Math.trunc(i);if(a<0||a>o||a>s||o>c||s>c||o<=0||s<=0||c<=0||a<o-c+s)return w.NUM;if(!e)return PT(a,o,s,c);let l=0;for(let e=Math.max(0,o-c+s);e<=a;e++)l+=PT(e,o,s,c);return Math.min(1,l)}),Z(`HYPGEOMDIST`,4,4,(e=0,t=0,n=0,r=0)=>{let i=Math.trunc(e),a=Math.trunc(t),o=Math.trunc(n),s=Math.trunc(r);return i<0||i>a||i>o||a>s||o>s||i<a-s+o?w.NUM:PT(i,a,o,s)}),Z(`GAMMA`,1,1,(e=0)=>wT(tT(e))),Z(`GAMMALN`,1,1,(e=0)=>e<=0?w.NUM:eT(e)),nd(`GAMMALN.PRECISE`,`GAMMALN`),Z(`ERF`,1,2,(e=0,t=NaN)=>Number.isNaN(t)?lT(e):lT(t)-lT(e)),Z(`ERFC`,1,1,(e=0)=>uT(e)),nd(`ERF.PRECISE`,`ERF`),nd(`ERFC.PRECISE`,`ERFC`);for(let[e,t]of[[`NORMDIST`,`NORM.DIST`],[`NORMINV`,`NORM.INV`],[`NORMSINV`,`NORM.S.INV`],[`LOGINV`,`LOGNORM.INV`],[`CHIINV`,`CHISQ.INV.RT`],[`CHIDIST`,`CHISQ.DIST.RT`],[`FDIST`,`F.DIST.RT`],[`FINV`,`F.INV.RT`],[`BINOMDIST`,`BINOM.DIST`],[`CRITBINOM`,`BINOM.INV`],[`POISSON`,`POISSON.DIST`],[`EXPONDIST`,`EXPON.DIST`],[`GAMMADIST`,`GAMMA.DIST`],[`GAMMAINV`,`GAMMA.INV`],[`TINV`,`T.INV.2T`],[`WEIBULL`,`WEIBULL.DIST`],[`CONFIDENCE`,`CONFIDENCE.NORM`]])nd(e,t);var FT=2**48;function IT(e,t){let[n=`0`,r=`0`]=e.toExponential().split(`e`);return Number(`${n}e${String(Number(r)+t)}`)}var LT=e=>Number(e.toPrecision(15));function RT(e,t,n){let r=Math.trunc(t),i=IT(Math.abs(LT(e)),r);if(i>=2**53)return e;let a=IT(n(i),-r);return e<0?-a:a}F(`ROUND`,2,2,sd((e=0,t=0)=>RT(e,t,e=>Math.floor(e+.5)))),F(`ROUNDUP`,2,2,sd((e=0,t=0)=>RT(e,t,Math.ceil))),F(`ROUNDDOWN`,2,2,sd((e=0,t=0)=>RT(e,t,Math.floor))),F(`MOD`,2,2,sd((e=0,t=0)=>{if(t===0)return w.DIV0;let n=e%t;return n!==0&&n<0!=t<0?n+t:n})),F(`QUOTIENT`,2,2,sd((e=0,t=0)=>t===0?w.DIV0:Math.trunc(e/t))),F(`POWER`,2,2,sd((e=0,t=0)=>{if(e===0&&t===0)return w.NUM;if(e===0&&t<0)return w.DIV0;let n=e**t;return Number.isFinite(n)?n:w.NUM})),F(`LOG`,1,2,(e,t)=>{let n=N(e),r=t==null?10:N(t);return n instanceof C?n:r instanceof C?r:n<=0||r<=0?w.NUM:r===1?w.DIV0:r===10?Math.log10(n):r===2?Math.log2(n):Math.log(n)/Math.log(r)});function zT(e,t){let[n,r]=[e,t];for(;r!==0;)[n,r]=[r,n%r];return n}function BT(e,t){let n=ad(e,t);if(n instanceof C)return n;let r=n.map(Math.trunc);return r.some(e=>e<0||e>=2**53)?w.NUM:r}I(`GCD`,`(r)`,(e,t)=>{let n=BT(e,t);return n instanceof C?n:n.reduce(zT,0)}),I(`LCM`,`(r)`,(e,t)=>{let n=BT(e,t);if(n instanceof C)return n;if(n.includes(0))return 0;let r=n.reduce((e,t)=>e*t/zT(e,t),1);return Number.isFinite(r)?r:w.NUM}),F(`BASE`,2,3,sd((e=0,t=0,n=NaN)=>{let r=Math.trunc(e),i=Math.trunc(t),a=Number.isNaN(n)?0:Math.trunc(n);return r<0||r>=2**53||i<2||i>36||a<0||a>255?w.NUM:r.toString(i).toUpperCase().padStart(a,`0`)}));var VT=`MDCLXVI`,HT=[1e3,500,100,50,10,5,1];function UT(e,t){let n=e=>HT[e]??1,r=e=>VT.charAt(e),i=HT.length-1,a=e,o=``;for(let e=0;e<=i/2;e++){let s=2*e,c=Math.floor(a/n(s));if(c%5==4){let e=c===4?s-1:s-2,l=s,u=0;for(;u<t&&l<i;)u+=1,n(e)-n(l+1)<=a?l+=1:u=t;o+=r(l)+r(e),a+=n(l)-n(e)}else c>4&&(o+=r(s-1)),o+=r(s).repeat(c%5),a%=n(s)}return o}F(`ROMAN`,1,2,(e,t)=>{let n=N(e);if(n instanceof C)return n;let r=0;if(typeof t==`boolean`)r=t?0:4;else if(t!=null){let e=N(t);if(e instanceof C)return e;r=Math.trunc(e)}let i=Math.trunc(n);return i<0||i>3999||r<0||r>4?w.VALUE:UT(i,r)});function WT(e){return!Number.isInteger(e)||e<0||e>=FT?w.NUM:BigInt(e)}for(let[e,t]of[[`BITAND`,(e,t)=>e&t],[`BITOR`,(e,t)=>e|t],[`BITXOR`,(e,t)=>e^t]])F(e,2,2,sd((e=0,n=0)=>{let r=WT(e),i=WT(n);return r instanceof C?r:i instanceof C?i:Number(t(r,i))}));for(let[e,t]of[[`BITLSHIFT`,1],[`BITRSHIFT`,-1]])F(e,2,2,sd((e=0,n=0)=>{let r=WT(e);if(r instanceof C)return r;let i=Math.trunc(n)*t;if(Math.abs(i)>53)return w.NUM;let a=i>=0?r<<BigInt(i):r>>BigInt(-i);return a>=BigInt(FT)?w.NUM:Number(a)}));for(let[e,t,n]of[[`BESSELJ`,yT,!1],[`BESSELI`,xT,!1],[`BESSELY`,bT,!0],[`BESSELK`,ST,!0]])F(e,2,2,sd((e=0,r=0)=>{let i=Math.trunc(r);if(i<0||n&&e<=0)return w.NUM;let a=t(i,e);return Number.isFinite(a)?a:w.NUM}));F(`SLN`,3,3,sd((e=0,t=0,n=0)=>n===0?w.DIV0:(e-t)/n)),I(`GEOMEAN`,`(r)`,(e,t)=>{let n=ad(e,t);return n instanceof C?n:n.length===0||n.some(e=>e<=0)?w.NUM:Math.exp(n.reduce((e,t)=>e+Math.log(t),0)/n.length)}),I(`HARMEAN`,`(r)`,(e,t)=>{let n=ad(e,t);return n instanceof C?n:n.length===0||n.some(e=>e<=0)?w.NUM:n.length/n.reduce((e,t)=>e+1/t,0)}),I(`KURT`,`(r)`,(e,t)=>{let n=ad(e,t);if(n instanceof C)return n;let r=n.length;if(r<4)return w.DIV0;let i=n.reduce((e,t)=>e+t,0)/r,a=n.reduce((e,t)=>e+(t-i)**2,0)/(r-1);if(a===0)return w.DIV0;let o=n.reduce((e,t)=>e+(t-i)**4,0)/a**2;return r*(r+1)/((r-1)*(r-2)*(r-3))*o-3*(r-1)**2/((r-2)*(r-3))});function GT(e,t){let n=[],r;return id(e,t,(e,t)=>{if(!r){if(e instanceof C)r=e;else if(typeof e==`number`)n.push(e);else if(t&&e!==null){let t=N(e);t instanceof C?r=t:n.push(t)}}}),r??n}I(`MODE.SNGL`,`(r)`,(e,t)=>{let n=GT(e,t);if(n instanceof C)return n;let r=new Map;for(let e of n)r.set(e,(r.get(e)??0)+1);let i,a=1;for(let[e,t]of r)t>a&&(i=e,a=t);return i??w.NA}),nd(`MODE`,`MODE.SNGL`),I(`MODE.MULT`,`(r)`,(e,t)=>{let n=GT(e,t);if(n instanceof C)return n;let r=new Map;for(let e of n)r.set(e,(r.get(e)??0)+1);let i=0;for(let e of r.values())i=Math.max(i,e);if(i<2)return w.NA;let a=[...r].filter(([,e])=>e===i).map(([e])=>e);return new T(a.length,1,a)});function KT(e,t){let n=t*(e.length-1),r=Math.floor(n),i=e[r]??0,a=e[r+1]??i;return i+(n-r)*(a-i)}I(`QUARTILE.INC`,`rv`,(e,t)=>{let n=ad([e[0]],t);if(n instanceof C)return n;let r=N(t.calc.scalar(e[1],t.frame));if(r instanceof C)return r;let i=Math.trunc(r);return n.length===0||i<0||i>4?w.NUM:KT([...n].sort((e,t)=>e-t),i/4)}),nd(`QUARTILE`,`QUARTILE.INC`);function qT(e,t){let n=N(t.calc.scalar(e[0],t.frame));if(n instanceof C)return n;let r=ad([e[1]],t);if(r instanceof C)return r;let i=e[2]===void 0?0:N(t.calc.scalar(e[2],t.frame));if(i instanceof C)return i;let a=r.filter(e=>e===n).length;return a===0?w.NA:{before:r.filter(e=>i===0?e>n:e<n).length,ties:a}}I(`RANK.EQ`,`vr?v`,(e,t)=>{let n=qT(e,t);return n instanceof C?n:n.before+1}),I(`RANK.AVG`,`vr?v`,(e,t)=>{let n=qT(e,t);return n instanceof C?n:n.before+(n.ties+1)/2}),nd(`RANK`,`RANK.EQ`);function JT(e,t){let n=L(e,t);if(n instanceof C)return n;let r=[];for(let e=0;e<n.rows;e++){let t=[];for(let r=0;r<n.cols;r++){let i=n.at(e,r);if(i instanceof C)return i;if(typeof i!=`number`)return w.VALUE;t.push(i)}r.push(t)}return r}var YT=e=>new T(e.length,e[0]?.length??0,e.flat());function XT(e,t){let n=t[0]?.length??0;return e.map(e=>Array.from({length:n},(n,r)=>e.reduce((e,n,i)=>e+n*(t[i]?.[r]??0),0)))}I(`MMULT`,`rr`,(e,t)=>{let n=JT(e[0],t),r=JT(e[1],t);return n instanceof C?n:r instanceof C?r:(n[0]?.length??0)===r.length?YT(XT(n,r)):w.VALUE});function ZT(e){let t=e.length,n=e.map((e,n)=>[...e,...Array.from({length:t},(e,t)=>+(n===t))]),r=(e,t)=>n[e]?.[t]??0,i=1;for(let e=0;e<t;e++){let a=e;for(let n=e+1;n<t;n++)Math.abs(r(n,e))>Math.abs(r(a,e))&&(a=n);if(r(a,e)===0)return{determinant:0};if(a!==e){let[t=[],r=[]]=[n[e],n[a]];n[e]=r,n[a]=t,i=-i}let o=r(e,e);i*=o,n[e]=(n[e]??[]).map(e=>e/o);for(let i=0;i<t;i++){if(i===e)continue;let t=r(i,e),a=n[e]??[];n[i]=(n[i]??[]).map((e,n)=>e-t*(a[n]??0))}}return{determinant:i,inverse:n.map(e=>e.slice(t))}}var QT=e=>e.length>0&&e.every(t=>t.length===e.length);I(`MDETERM`,`r`,(e,t)=>{let n=JT(e[0],t);return n instanceof C?n:QT(n)?ZT(n).determinant:w.VALUE}),I(`MINVERSE`,`r`,(e,t)=>{let n=JT(e[0],t);if(n instanceof C)return n;if(!QT(n))return w.VALUE;let{inverse:r}=ZT(n);return r?YT(r):w.NUM}),F(`MUNIT`,1,1,sd((e=0)=>{let t=Math.trunc(e);return t<1||t>73?w.VALUE:YT(Array.from({length:t},(e,n)=>Array.from({length:t},(e,t)=>+(n===t))))}));function $T(e,t,n){let r=L(e,n),i=L(t,n);if(r instanceof C)return r;if(i instanceof C)return i;if(r.rows*r.cols!==i.rows*i.cols)return w.NA;let a=[],o=[];for(let e=0;e<r.rows;e++)for(let t=0;t<r.cols;t++){let n=r.at(e,t),s=i.rows===r.rows?i.at(e,t):i.at(t,e);if(n instanceof C)return n;if(s instanceof C)return s;typeof n==`number`&&typeof s==`number`&&(a.push(n),o.push(s))}return{xs:a,ys:o}}for(let[e,t]of[[`SUMX2MY2`,(e,t)=>e*e-t*t],[`SUMX2PY2`,(e,t)=>e*e+t*t],[`SUMXMY2`,(e,t)=>(e-t)**2]])I(e,`rr`,(e,n)=>{let r=$T(e[0],e[1],n);return r instanceof C?r:r.xs.length===0?w.DIV0:r.xs.reduce((e,n,i)=>e+t(n,r.ys[i]??0),0)});I(`SERIESSUM`,`vvvr`,(e,t)=>{let[n,r,i]=e.slice(0,3).map(e=>N(t.calc.scalar(e,t.frame)));if(n instanceof C)return n;if(r instanceof C)return r;if(i instanceof C)return i;let a=ad([e[3]],t);return a instanceof C?a:a.reduce((e,t,a)=>e+t*(n??0)**((r??0)+a*(i??0)),0)}),I(`FREQUENCY`,`rr`,(e,t)=>{let n=ad([e[0]],t);if(n instanceof C)return n;let r=[];rd([e[1]],t,e=>{typeof e==`number`&&r.push(e)});let i=r.map((e,t)=>({b:e,i:t})).sort((e,t)=>e.b-t.b),a=Array(r.length+1).fill(0);for(let e of n){let t=0,n=i.length;for(;t<n;){let r=t+n>>1;e<=(i[r]?.b??1/0)?n=r:t=r+1}let o=i[t]?.i??r.length;a[o]=(a[o]??0)+1}return new T(a.length,1,a)}),I(`PROB`,`rrv?v`,(e,t)=>{let n=$T(e[0],e[1],t);if(n instanceof C)return n;let r=N(t.calc.scalar(e[2],t.frame));if(r instanceof C)return r;let i=e[3]===void 0?r:N(t.calc.scalar(e[3],t.frame));if(i instanceof C)return i;let a=n.ys.reduce((e,t)=>e+t,0);return n.ys.some(e=>e<=0||e>1)||Math.abs(a-1)>1e-12?w.NUM:n.xs.reduce((e,t,a)=>t>=r&&t<=i?e+(n.ys[a]??0):e,0)});var eE=e=>e.reduce((e,t)=>e+t,0);function tE(e,t,n){let r=t.map(e=>n?[...e,1]:[...e]),i=r[0]?.length??0,{inverse:a}=ZT(Array.from({length:i},(e,t)=>Array.from({length:i},(e,n)=>r.reduce((e,r)=>e+(r[t]??0)*(r[n]??0),0))));if(!a)return;let o=Array.from({length:i},(t,n)=>r.reduce((t,r,i)=>t+(r[n]??0)*(e[i]??0),0)),s=a.map(e=>e.reduce((e,t,n)=>e+t*(o[n]??0),0));return n?s:[...s,0]}function nE(e,t,n){let r=JT(e[0],t);if(r instanceof C)return r;let i=r.length===1,a=r.flat();if(n&&a.some(e=>e<=0))return w.NUM;let o=n?a.map(Math.log):a,s=e[1];if(s===void 0||!rE(s))return{ys:o,xs:a.map((e,t)=>[t+1]),byRow:i};let c=JT(s,t);if(c instanceof C)return c;let l=c[0]?.length??0;return i?l===o.length?{ys:o,xs:Array.from({length:l},(e,t)=>c.map(e=>e[t]??0)),byRow:i}:w.REF:c.length===o.length?{ys:o,xs:c,byRow:i}:w.REF}var rE=e=>e instanceof E||e instanceof T||typeof e==`number`,iE=(e,t)=>e===void 0||!rE(e)&&typeof e!=`boolean`||Ru(t.calc.scalar(e,t.frame));function aE(e){return(t,n)=>{let r=nE(t,n,e);if(r instanceof C)return r;let i=iE(t[3],n);if(i instanceof C)return i;let a=tE(r.ys,r.xs,i);if(!a)return w.NUM;let o=t[2],s=r.xs;if(o!==void 0&&rE(o)){let e=JT(o,n);if(e instanceof C)return e;let t=r.xs[0]?.length??1,i=e[0]?.length??0;s=r.byRow||t===1&&e.length===1?Array.from({length:i},(t,n)=>e.map(e=>e[n]??0)):e}let c=s.map(t=>{let n=t.reduce((e,t,n)=>e+t*(a[n]??0),0)+(a[t.length]??0);return e?Math.exp(n):n});return r.byRow?new T(1,c.length,c):new T(c.length,1,c)}}I(`TREND`,`r?rrv`,aE(!1)),I(`GROWTH`,`r?rrv`,aE(!0));function oE(e,t,n,r){let i=t.map(e=>r?[...e,1]:[...e]),a=i[0]?.length??0,{inverse:o}=ZT(Array.from({length:a},(e,t)=>Array.from({length:a},(e,n)=>i.reduce((e,r)=>e+(r[t]??0)*(r[n]??0),0))));if(!o)return;let s=t.map(e=>e.reduce((e,t,r)=>e+t*(n[r]??0),0)+(n[e.length]??0)),c=e.reduce((e,t,n)=>e+(t-(s[n]??0))**2,0),l=r?eE(e)/e.length:0,u=e.reduce((e,t)=>e+(t-l)**2,0),d=u-c,f=e.length-a,p=f>0?c/f:0,m=o.map((e,t)=>Math.sqrt(Math.max(0,(e[t]??0)*p))),h=t[0]?.length??0;return{errors:m,r2:u===0?1:d/u,sey:Math.sqrt(p),f:f>0&&c>0?d/h/(c/f):0,df:f,ssreg:d,ssresid:c}}function sE(e){return(t,n)=>{let r=nE(t,n,e);if(r instanceof C)return r;let i=iE(t[2],n);if(i instanceof C)return i;let a=tE(r.ys,r.xs,i);if(!a)return w.NUM;let o=[...a.slice(0,-1).reverse(),a[a.length-1]??0],s=e?o.map(Math.exp):o,c=t[3],l=c===void 0||!cE(c)?!1:Ru(n.calc.scalar(c,n.frame));if(l instanceof C)return l;if(!l)return new T(1,s.length,s);let u=oE(r.ys,r.xs,a,i);if(!u)return w.NUM;let d=s.length,f=e=>[...e,...Array(d-e.length).fill(w.NA)],p=i?[...u.errors.slice(0,-1).reverse(),u.errors[u.errors.length-1]??0]:[...[...u.errors].reverse(),w.NA];return new T(5,d,[...s,...p,...f([u.r2,u.sey]),...f([u.f,u.df]),...f([u.ssreg,u.ssresid])])}}var cE=e=>rE(e)||typeof e==`boolean`;I(`LINEST`,`r?rvv`,sE(!1)),I(`LOGEST`,`r?rvv`,sE(!0));var lE=e=>eE(e)/e.length,uE=e=>{let t=lE(e);return e.reduce((e,n)=>e+(n-t)**2,0)/(e.length-1)};I(`CHISQ.TEST`,`rr`,(e,t)=>{let n=JT(e[0],t),r=JT(e[1],t);if(n instanceof C)return n;if(r instanceof C)return r;let i=n.length,a=n[0]?.length??0;if(r.length!==i||(r[0]?.length??0)!==a||i*a<2)return w.NA;let o=0;for(let e=0;e<i;e++)for(let t=0;t<a;t++){let i=r[e]?.[t]??0;if(i<0)return w.NUM;if(i===0)return w.DIV0;o+=((n[e]?.[t]??0)-i)**2/i}return oT((i>1&&a>1?(i-1)*(a-1):i>1?i-1:a-1)/2,o/2)}),nd(`CHITEST`,`CHISQ.TEST`),I(`T.TEST`,`rrvv`,(e,t)=>{let n=N(t.calc.scalar(e[2],t.frame)),r=N(t.calc.scalar(e[3],t.frame));if(n instanceof C)return n;if(r instanceof C)return r;let i=Math.trunc(n),a=Math.trunc(r);if(i!==1&&i!==2||a<1||a>3)return w.NUM;let o,s;if(a===1){let n=$T(e[0],e[1],t);if(n instanceof C)return n;let r=n.xs.map((e,t)=>e-(n.ys[t]??0));if(r.length<2)return w.DIV0;o=lE(r)/Math.sqrt(uE(r)/r.length),s=r.length-1}else{let n=ad([e[0]],t),r=ad([e[1]],t);if(n instanceof C)return n;if(r instanceof C)return r;if(n.length<2||r.length<2)return w.DIV0;let[i,c,l,u]=[uE(n),uE(r),n.length,r.length],d=Math.abs(lE(n)-lE(r));if(a===2){s=l+u-2;let e=((l-1)*i+(u-1)*c)/s;o=d/Math.sqrt(e*(1/l+1/u))}else{let e=i/l,t=c/u;o=d/Math.sqrt(e+t),s=(e+t)**2/(e**2/(l-1)+t**2/(u-1))}}return Number.isFinite(o)?cT(s/2,.5,s/(s+o*o))*i/2:w.DIV0}),nd(`TTEST`,`T.TEST`),I(`F.TEST`,`rr`,(e,t)=>{let n=ad([e[0]],t),r=ad([e[1]],t);if(n instanceof C)return n;if(r instanceof C)return r;if(n.length<2||r.length<2)return w.DIV0;let[i,a]=[uE(n),uE(r)];if(i===0||a===0)return w.DIV0;let o=i/a,[s,c]=[n.length-1,r.length-1],l=cT(c/2,s/2,c/(s*o+c));return 2*Math.min(l,1-l)}),nd(`FTEST`,`F.TEST`),I(`Z.TEST`,`rv?v`,(e,t)=>{let n=ad([e[0]],t);if(n instanceof C)return n;let r=N(t.calc.scalar(e[1],t.frame));if(r instanceof C)return r;if(n.length===0)return w.NA;let i=e[2]===void 0?n.length<2?w.DIV0:Math.sqrt(uE(n)):N(t.calc.scalar(e[2],t.frame));return i instanceof C?i:i===0?w.DIV0:1-fT((lE(n)-r)/(i/Math.sqrt(n.length)))}),nd(`ZTEST`,`Z.TEST`);var dE={1:`AVERAGE`,2:`COUNT`,3:`COUNTA`,4:`MAX`,5:`MIN`,6:`PRODUCT`,7:`STDEV.S`,8:`STDEV.P`,9:`SUM`,10:`VAR.S`,11:`VAR.P`,12:`MEDIAN`,13:`MODE.SNGL`,14:`LARGE`,15:`SMALL`,16:`PERCENTILE.INC`,17:`QUARTILE.INC`,18:`PERCENTILE.EXC`,19:`QUARTILE.EXC`};I(`AGGREGATE`,`vv(r)`,(e,t)=>{let n=N(t.calc.scalar(e[0],t.frame)),r=N(t.calc.scalar(e[1],t.frame));if(n instanceof C)return n;if(r instanceof C)return r;let i=dE[Math.trunc(n)],a=i===void 0?void 0:Xu.get(i);if(a===void 0)return w.VALUE;let o=![2,3,6,7].includes(Math.trunc(r)),s=[1,3,5,7].includes(Math.trunc(r)),c=e=>{let n=e instanceof it?e.parts:[e],r=[];for(let e of n)if(e instanceof E){let n=e;for(let e=n.top;e<=Math.min(n.bottom,n.sheet.lastRow);e++)if(!s||n.sheet.spec.rows?.[String(e+1)]?.hidden!==!0&&!t.calc.filtered(n.sheet).has(e))for(let i=n.left;i<=n.right;i++)r.push(t.calc.read(n.sheet,e,i))}else{let n=t.calc.flat(e);n instanceof T?st(r,n.data):r.push(n)}let i=o?r:r.filter(e=>!(e instanceof C));return new T(i.length,1,i)},l=Math.trunc(n)>=14,u=e.slice(2),d=l?[c(u[0]),...u.slice(1)]:u.map(c);return t.calc.applyFunction(a,d,t.frame)}),F(`FACT`,1,1,sd(e=>{if(e<0)return w.NUM;let t=1;for(let n=2;n<=Math.trunc(e);n++)t*=n;return Number.isFinite(t)?t:w.NUM})),F(`FACTDOUBLE`,1,1,sd(e=>{if(e<0)return w.NUM;let t=1;for(let n=Math.trunc(e);n>1;n-=2)t*=n;return Number.isFinite(t)?t:w.NUM})),F(`ATAN2`,2,2,sd((e,t)=>e===0&&t===0?w.DIV0:Math.atan2(t,e)));var fE={largest:new WeakMap,smallest:new WeakMap};function pE(e,t,n){let r=()=>{let r=ad([e],n);return r instanceof C?r:r.sort((e,n)=>t?n-e:e-n)};if(e instanceof E)return n.calc.indexes.ofRepeated(Yu(t?`large`:`small`,e),[e],()=>{let e=r();return new Map(e instanceof C?[]:[[``,e]])})?.get(``)??r();if(!(e instanceof T))return r();let i=t?fE.largest:fE.smallest,a=i.get(e);if(a)return a;let o=r();return o instanceof C||i.set(e,a===null?o:null),o}for(let[e,t]of[[`LARGE`,!0],[`SMALL`,!1]])I(e,`rv`,(e,n)=>{let r=pE(e[0],t,n);if(r instanceof C)return r;let i=N(e[1]);if(i instanceof C)return i;let a=Math.ceil(i);return a<1||a>r.length?w.NUM:r[a-1]??w.NUM});var mE=.0254,hE=12*mE,gE=3*hE,_E=5280*hE,vE=1852,yE=9460730472580800,bE=mE/72,xE=453.59237,SE=9.80665,CE=xE/1e3*SE,wE=hE*CE,TE=231*mE**3/128,EE=.00454609,DE=101325,OE=550*wE,kE=new Map;function Q(e,t){for(let n of e)kE.set(n,t)}var AE=(e,t)=>({quantity:e,factor:t,prefix:1});Q([`g`],AE(`mass`,1)),Q([`sg`],{quantity:`mass`,factor:CE*1e3/hE}),Q([`lbm`],{quantity:`mass`,factor:xE}),Q([`u`],AE(`mass`,1660538782e-33)),Q([`ozm`],{quantity:`mass`,factor:xE/16}),Q([`grain`],{quantity:`mass`,factor:xE/7e3}),Q([`cwt`,`shweight`],{quantity:`mass`,factor:100*xE}),Q([`uk_cwt`,`lcwt`,`hweight`],{quantity:`mass`,factor:112*xE}),Q([`stone`],{quantity:`mass`,factor:14*xE}),Q([`ton`],{quantity:`mass`,factor:2e3*xE}),Q([`uk_ton`,`LTON`,`brton`],{quantity:`mass`,factor:2240*xE}),Q([`m`],AE(`distance`,1)),Q([`mi`],{quantity:`distance`,factor:_E}),Q([`Nmi`],{quantity:`distance`,factor:vE}),Q([`in`],{quantity:`distance`,factor:mE}),Q([`ft`],{quantity:`distance`,factor:hE}),Q([`yd`],{quantity:`distance`,factor:gE}),Q([`ang`],AE(`distance`,1e-10)),Q([`ell`],{quantity:`distance`,factor:45*mE}),Q([`ly`],AE(`distance`,yE)),Q([`parsec`,`pc`],AE(`distance`,648e3/Math.PI*149597870700)),Q([`Picapt`,`Pica`],{quantity:`distance`,factor:bE}),Q([`pica`],{quantity:`distance`,factor:mE/6}),Q([`survey_mi`],{quantity:`distance`,factor:6336e3/3937}),Q([`yr`],{quantity:`time`,factor:31557600}),Q([`day`,`d`],{quantity:`time`,factor:86400}),Q([`hr`],{quantity:`time`,factor:3600}),Q([`mn`,`min`],{quantity:`time`,factor:60}),Q([`sec`,`s`],AE(`time`,1)),Q([`Pa`,`p`],AE(`pressure`,1)),Q([`atm`,`at`],AE(`pressure`,DE)),Q([`mmHg`],AE(`pressure`,DE/760)),Q([`psi`],{quantity:`pressure`,factor:CE/mE**2}),Q([`Torr`],{quantity:`pressure`,factor:DE/760}),Q([`N`],AE(`force`,1)),Q([`dyn`,`dy`],AE(`force`,1e-5)),Q([`lbf`],{quantity:`force`,factor:CE}),Q([`pond`],AE(`force`,SE/1e3)),Q([`J`],AE(`energy`,1)),Q([`e`],AE(`energy`,1e-7)),Q([`c`],AE(`energy`,4.184)),Q([`cal`],AE(`energy`,4.1868)),Q([`eV`,`ev`],AE(`energy`,1602176487e-28)),Q([`HPh`,`hh`],{quantity:`energy`,factor:OE*3600}),Q([`Wh`,`wh`],AE(`energy`,3600)),Q([`flb`],{quantity:`energy`,factor:wE}),Q([`BTU`,`btu`],{quantity:`energy`,factor:1055.05585262}),Q([`HP`,`h`],{quantity:`power`,factor:OE}),Q([`PS`],{quantity:`power`,factor:75*SE}),Q([`W`,`w`],AE(`power`,1)),Q([`T`],AE(`magnetism`,1)),Q([`ga`],AE(`magnetism`,1e-4));var jE=(e,t,n=!1)=>{Q(e,{quantity:`volume`,factor:t**3,...n?{prefix:3}:{}})};Q([`tsp`],{quantity:`volume`,factor:TE/6}),Q([`tspm`],{quantity:`volume`,factor:5e-6}),Q([`tbs`],{quantity:`volume`,factor:TE/2}),Q([`oz`],{quantity:`volume`,factor:TE}),Q([`cup`],{quantity:`volume`,factor:8*TE}),Q([`pt`,`us_pt`],{quantity:`volume`,factor:16*TE}),Q([`uk_pt`],{quantity:`volume`,factor:EE/8}),Q([`qt`],{quantity:`volume`,factor:32*TE}),Q([`uk_qt`],{quantity:`volume`,factor:EE/4}),Q([`gal`],{quantity:`volume`,factor:128*TE}),Q([`uk_gal`],{quantity:`volume`,factor:EE}),Q([`l`,`L`,`lt`],AE(`volume`,.001)),Q([`barrel`],{quantity:`volume`,factor:5376*TE}),Q([`bushel`],{quantity:`volume`,factor:2150.42*mE**3}),Q([`GRT`,`regton`],{quantity:`volume`,factor:100*hE**3}),Q([`MTON`],{quantity:`volume`,factor:40*hE**3}),jE([`m3`,`m^3`],1,!0),jE([`ang3`,`ang^3`],1e-10,!0),jE([`ft3`,`ft^3`],hE),jE([`in3`,`in^3`],mE),jE([`ly3`,`ly^3`],yE),jE([`mi3`,`mi^3`],_E),jE([`yd3`,`yd^3`],gE),jE([`Nmi3`,`Nmi^3`],vE),jE([`Pica3`,`Picapt3`,`Pica^3`,`Picapt^3`],bE);var ME=(e,t,n=!1)=>{Q(e,{quantity:`area`,factor:t**2,...n?{prefix:2}:{}})};Q([`uk_acre`],{quantity:`area`,factor:4840*gE**2}),Q([`us_acre`],{quantity:`area`,factor:43560*(1200/3937)**2}),Q([`ar`],AE(`area`,100)),Q([`ha`],{quantity:`area`,factor:1e4}),Q([`Morgen`],{quantity:`area`,factor:2500}),ME([`m2`,`m^2`],1,!0),ME([`ang2`,`ang^2`],1e-10,!0),ME([`ft2`,`ft^2`],hE),ME([`in2`,`in^2`],mE),ME([`ly2`,`ly^2`],yE),ME([`mi2`,`mi^2`],_E),ME([`yd2`,`yd^2`],gE),ME([`Nmi2`,`Nmi^2`],vE),ME([`Pica2`,`Picapt2`,`Pica^2`,`Picapt^2`],bE),Q([`bit`],{quantity:`information`,factor:1,prefix:1,binary:!0}),Q([`byte`],{quantity:`information`,factor:8,prefix:1,binary:!0}),Q([`admkn`],{quantity:`speed`,factor:6080*hE/3600}),Q([`kn`],{quantity:`speed`,factor:vE/3600}),Q([`m/h`,`m/hr`],AE(`speed`,1/3600)),Q([`m/s`,`m/sec`],AE(`speed`,1)),Q([`mph`],{quantity:`speed`,factor:_E/3600});var NE={Y:1e24,Z:1e21,E:0xde0b6b3a7640000,P:0x38d7ea4c68000,T:0xe8d4a51000,G:1e9,M:1e6,k:1e3,h:100,da:10,e:10,d:.1,c:.01,m:.001,u:1e-6,n:1e-9,p:1e-12,f:1e-15,a:1e-18,z:1e-21,y:1e-24},PE={Yi:2**80,Zi:2**70,Ei:2**60,Pi:2**50,Ti:2**40,Gi:2**30,Mi:2**20,ki:1024},FE={C:{toK:e=>e+273.15,fromK:e=>e-273.15},F:{toK:e=>(e-32)*5/9+273.15,fromK:e=>(e-273.15)*9/5+32},K:{toK:e=>e,fromK:e=>e},Rank:{toK:e=>e*5/9,fromK:e=>e*9/5},Reau:{toK:e=>e*5/4+273.15,fromK:e=>(e-273.15)*4/5}},IE={C:`C`,cel:`C`,F:`F`,fah:`F`,K:`K`,kel:`K`,Rank:`Rank`,Reau:`Reau`};function LE(e){let t=IE[e];if(t!==void 0)return{kind:`temperature`,scale:t,times:1};let n=kE.get(e);if(n)return{kind:`unit`,quantity:n.quantity,factor:n.factor};for(let[t,n]of Object.entries(NE)){if(!e.startsWith(t))continue;let r=e.slice(t.length);if(IE[r]===`K`)return{kind:`temperature`,scale:`K`,times:n};let i=kE.get(r);if(i?.prefix!==void 0)return{kind:`unit`,quantity:i.quantity,factor:i.factor*n**i.prefix}}for(let[t,n]of Object.entries(PE)){if(!e.startsWith(t))continue;let r=kE.get(e.slice(t.length));if(r?.binary===!0)return{kind:`unit`,quantity:r.quantity,factor:r.factor*n}}}function RE(e,t,n){let r=LE(t),i=LE(n);if(!r||!i)return w.NA;if(r.kind===`temperature`||i.kind===`temperature`){if(r.kind!==`temperature`||i.kind!==`temperature`)return w.NA;let t=FE[r.scale],n=FE[i.scale];return!t||!n?w.NA:n.fromK(t.toK(e*r.times))/i.times}return r.quantity===i.quantity?e*r.factor/i.factor:w.NA}F(`CONVERT`,3,3,(e,t,n)=>{let r=N(e),i=P(t),a=P(n);return r instanceof C?r:i instanceof C?i:a instanceof C?a:RE(r,i,a)});var zE=5e6,BE=e=>Array.from({length:e.rows},(t,n)=>Array.from({length:e.cols},(t,r)=>e.at(n,r))),VE=e=>{let t=e[0]?.length??0;return new T(e.length,t,e.flat())},HE=e=>{let t=e[0]?.length??0;return Array.from({length:t},(t,n)=>e.map(e=>e[n]??null))};function UE(e,t){if(!(e===void 0||e instanceof D))return t.calc.scalar(e,t.frame)}function WE(e,t,n){let r=UE(e,t);return r==null?n:N(r)}function GE(e,t,n){let r=UE(e,t);return r==null?n:Ru(r)}function KE(e,t,n){if(e===void 0||e instanceof D)return[n];let r=L(e,t);if(r instanceof C)return r;let i=[];for(let e=0;e<r.rows;e++)for(let t=0;t<r.cols;t++){let n=N(r.at(e,t));if(n instanceof C)return n;i.push(Math.trunc(n))}return i}var qE=e=>e===null||e===``;function JE(e,t,n){if(qE(e)||qE(t))return qE(e)&&qE(t)?0:qE(e)?1:-1;let r=Fp(e,t);return n?-r:r}function YE(e){return e instanceof C?e:e===null?!1:typeof e==`boolean`?e:typeof e==`number`?e!==0:w.VALUE}I(`FILTER`,`rr?r`,(e,t)=>{let n=L(e[0],t),r=L(e[1],t);if(n instanceof C)return n;if(r instanceof C)return r;if(r.rows>1&&r.cols>1)return w.VALUE;let i=r.cols===1&&r.rows===n.rows?!0:r.rows===1&&r.cols===n.cols?!1:void 0;if(i===void 0)return w.VALUE;let a=BE(n),o=i?a:HE(a),s=[];for(let e=0;e<o.length;e++){let t=YE(i?r.at(e,0):r.at(0,e));if(t instanceof C)return t;t&&s.push(o[e]??[])}return s.length===0?e[2]===void 0||e[2]instanceof D?w.CALC:e[2]:VE(i?s:HE(s))}),I(`SORT`,`r?rrr`,(e,t)=>{let n=L(e[0],t);if(n instanceof C)return n;let r=KE(e[1],t,1);if(r instanceof C)return r;let i=KE(e[2],t,1);if(i instanceof C)return i;let a=GE(e[3],t,!1);if(a instanceof C)return a;let o=BE(n),s=a?HE(o):o,c=s[0]?.length??0;if(i.length!==1&&i.length!==r.length||r.some(e=>e<1||e>c)||i.some(e=>e!==1&&e!==-1))return w.VALUE;let l=s.map((e,t)=>({line:e,index:t})).sort((e,t)=>{for(let[n,a]of r.entries()){let r=i[i.length===1?0:n]??1,o=JE(e.line[a-1]??null,t.line[a-1]??null,r<0);if(o!==0)return o}return e.index-t.index}).map(e=>e.line);return VE(a?HE(l):l)}),I(`SORTBY`,`r(r)`,(e,t)=>{let n=L(e[0],t);if(n instanceof C)return n;let r=[],i;for(let a=1;a<e.length;a+=2){let o=L(e[a],t);if(o instanceof C)return o;if(o.rows>1&&o.cols>1)return w.VALUE;let s=o.cols===1&&o.rows===n.rows,c=o.rows===1&&o.cols===n.cols;if(!s&&!c)return w.VALUE;let l=i??s;if(l?!s:!c)return w.VALUE;i=l;let u=WE(e[a+1],t,1);if(u instanceof C)return u;if(u!==1&&u!==-1)return w.VALUE;r.push({values:BE(o).flat(),descending:u<0})}let a=BE(n),o=(i===!1?HE(a):a).map((e,t)=>({line:e,index:t})).sort((e,t)=>{for(let{values:n,descending:i}of r){let r=JE(n[e.index]??null,n[t.index]??null,i);if(r!==0)return r}return e.index-t.index}).map(e=>e.line);return VE(i===!1?HE(o):o)});var XE=e=>e instanceof C?`e${e.code}`:typeof e==`string`?`s${e.toLowerCase()}`:`${typeof e}${String(e)}`;I(`UNIQUE`,`r?rr`,(e,t)=>{let n=L(e[0],t);if(n instanceof C)return n;let r=GE(e[1],t,!1);if(r instanceof C)return r;let i=GE(e[2],t,!1);if(i instanceof C)return i;let a=BE(n),o=(n.reference?.rows??n.rows)-n.rows,s=e=>Array(e).fill(null);if(o>0&&r&&(a.length+o)*n.cols<=zE)for(let e=0;e<o;e++)a.push(s(n.cols));let c=r?HE(a):a,l=new Map,u=(e,t)=>{let n=e.map(XE).join(`\0`),r=l.get(n);r?r.count+=t:l.set(n,{line:e,count:t})};for(let e of c)u(e,1);o>0&&!r&&u(s(n.cols),o);let d=[...l.values()].filter(e=>!i||e.count===1).map(e=>e.line);return d.length===0?w.CALC:VE(r?HE(d):d)});function ZE(e,t){if(e instanceof C)return e;if(t instanceof C)return t;let n=Math.trunc(e),r=Math.trunc(t);return n<0||r<0?w.VALUE:n===0||r===0?w.CALC:n>1048576||r>16384||n*r>zE?w.VALUE:{rows:n,cols:r}}I(`SEQUENCE`,`r?rrr`,(e,t)=>{let n=ZE(WE(e[0],t,1),WE(e[1],t,1));if(n instanceof C)return n;let r=WE(e[2],t,1);if(r instanceof C)return r;let i=WE(e[3],t,1);if(i instanceof C)return i;let a=Array(n.rows*n.cols);for(let e=0;e<a.length;e++)a[e]=r+e*i;return new T(n.rows,n.cols,a)}),I(`RANDARRAY`,`?rrrrr`,(e,t)=>{let n=ZE(WE(e[0],t,1),WE(e[1],t,1));if(n instanceof C)return n;let r=WE(e[2],t,0);if(r instanceof C)return r;let i=WE(e[3],t,1);if(i instanceof C)return i;let a=GE(e[4],t,!1);if(a instanceof C)return a;if(r>i||a&&(!Number.isInteger(r)||!Number.isInteger(i)))return w.VALUE;let o=Array(n.rows*n.cols);for(let e=0;e<o.length;e++){let n=t.calc.random();o[e]=a?r+Math.floor(n*(i-r+1)):r+n*(i-r)}return new T(n.rows,n.cols,o)},{volatile:!0}),I(`TEXTSPLIT`,`vr?rvvv`,(e,t)=>{let n=UE(e[0],t);if(n instanceof C)return n;let r=P(n??``);if(r instanceof C)return r;let i=sh(e[1],t);if(i instanceof C)return i;let a=sh(e[2],t);if(a instanceof C)return a;if(i.length===0&&a.length===0||i.includes(``)||a.includes(``))return w.VALUE;let o=GE(e[3],t,!1);if(o instanceof C)return o;let s=WE(e[4],t,0);if(s instanceof C)return s;let c=UE(e[5],t)??w.NA,l=s===1,u=(a.length===0?[r]:lh(r,a,l)).filter(e=>!(o&&e===``)).map(e=>{let t=i.length===0?[e]:lh(e,i,l);return o?t.filter(e=>e!==``):t}),d=Math.max(0,...u.map(e=>e.length));return u.length===0||d===0?w.CALC:VE(u.map(e=>Array.from({length:d},(t,n)=>e[n]??c)))});var QE=(e,t)=>{let n=t.calc.flat(e);return n instanceof T?n.at(0,0):n};I(`MAP`,`r(r)`,(e,t)=>{let n=e[e.length-1];if(!(n instanceof at))return w.VALUE;let r=[];for(let n of e.slice(0,-1)){let e=L(n,t);if(e instanceof C)return e;r.push(e)}let i=r[0];if(!i)return w.VALUE;let{rows:a,cols:o}=i;if(r.some(e=>e.rows!==a||e.cols!==o))return w.VALUE;let s=Array(a*o);for(let e=0;e<a;e++)for(let i=0;i<o;i++)s[e*o+i]=QE(t.calc.apply(n,r.map(t=>t.at(e,i))),t);return new T(a,o,s)});function $E(e,t){let n=e.length===3,r=e[e.length-1];if(!(r instanceof at))return w.VALUE;let i=L(e[+!!n],t);return i instanceof C?i:{start:n?UE(e[0],t)??null:i.at(0,0),cells:i,fn:r}}I(`REDUCE`,`rr?r`,(e,t)=>{let n=$E(e,t);if(n instanceof C)return n;let{cells:r,fn:i}=n,a=e.length===3?0:1,o=n.start;for(let e=a;e<r.rows*r.cols;e++)o=QE(t.calc.apply(i,[o,r.at(Math.floor(e/r.cols),e%r.cols)]),t);return o}),I(`SCAN`,`rr?r`,(e,t)=>{let n=$E(e,t);if(n instanceof C)return n;let{cells:r,fn:i}=n,a=r.rows*r.cols,o=e.length===3?0:1,s=Array(a),c=n.start;o===1&&(s[0]=c);for(let e=o;e<a;e++)c=QE(t.calc.apply(i,[c,r.at(Math.floor(e/r.cols),e%r.cols)]),t),s[e]=c;return new T(r.rows,r.cols,s)});var eD=e=>(t,n)=>{let r=L(t[0],n);if(r instanceof C)return r;let i=t[1];if(!(i instanceof at))return w.VALUE;let a=BE(r),o=(e?a:HE(a)).map(t=>QE(n.calc.apply(i,[e?new T(1,t.length,t):new T(t.length,1,t)]),n));return e?new T(o.length,1,o):new T(1,o.length,o)};I(`BYROW`,`rr`,eD(!0)),I(`BYCOL`,`rr`,eD(!1)),I(`MAKEARRAY`,`rrr`,(e,t)=>{let n=ZE(WE(e[0],t,1),WE(e[1],t,1));if(n instanceof C)return n;let r=e[2];if(!(r instanceof at))return w.VALUE;let i=Array(n.rows*n.cols);for(let e=0;e<n.rows;e++)for(let a=0;a<n.cols;a++)i[e*n.cols+a]=QE(t.calc.apply(r,[e+1,a+1]),t);return new T(n.rows,n.cols,i)});function tD(e){return(t,n)=>{let r=[];for(let i of t){let t=L(i,n);if(t instanceof C)return t;let a=BE(t);r.push(e?a:HE(a))}let i=Math.max(0,...r.map(e=>e[0]?.length??0)),a=r.flatMap(e=>e.map(e=>Array.from({length:i},(t,n)=>n<e.length?e[n]??null:w.NA)));return a.length===0?w.CALC:VE(e?a:HE(a))}}I(`VSTACK`,`(r)`,tD(!0)),I(`HSTACK`,`(r)`,tD(!1));function nD(e,t,n){let r=Math.min(e,Math.abs(t));return n?t>=0?[0,r]:[e-r,e]:t>=0?[r,e]:[0,e-r]}function rD(e){return(t,n)=>{let r=L(t[0],n);if(r instanceof C)return r;let i=e=>e===void 0||e instanceof D,a=WE(t[1],n,e?r.rows:0);if(a instanceof C)return a;let o=WE(t[2],n,e?r.cols:0);if(o instanceof C)return o;if(e&&!i(t[1])&&Math.trunc(a)===0||e&&!i(t[2])&&Math.trunc(o)===0)return w.CALC;let[s,c]=nD(r.rows,Math.trunc(a),e),[l,u]=nD(r.cols,Math.trunc(o),e);return c<=s||u<=l?w.CALC:VE(BE(r).slice(s,c).map(e=>e.slice(l,u)))}}I(`TAKE`,`rr?r`,rD(!0)),I(`DROP`,`rr?r`,rD(!1));function iD(e){return(t,n)=>{let r=L(t[0],n);if(r instanceof C)return r;let i=WE(t[1],n,0);if(i instanceof C)return i;let a=GE(t[2],n,!1);if(a instanceof C)return a;if(![0,1,2,3].includes(i))return w.VALUE;let o=BE(r),s=(a?HE(o):o).flat().filter(e=>!((i===1||i===3)&&e===null||(i===2||i===3)&&e instanceof C));return s.length===0?w.CALC:e?new T(s.length,1,s):new T(1,s.length,s)}}I(`TOCOL`,`r?rr`,iD(!0)),I(`TOROW`,`r?rr`,iD(!1));function aD(e){return(t,n)=>{let r=L(t[0],n);if(r instanceof C)return r;let i=BE(r),a=e?i:HE(i),o=[];for(let e of t.slice(1)){let t=KE(e,n,1);if(t instanceof C)return t;for(let e of t){let t=a[e>0?e-1:a.length+e];if(e===0||!t)return w.VALUE;o.push(t)}}return VE(e?o:HE(o))}}I(`CHOOSEROWS`,`r(r)`,aD(!0)),I(`CHOOSECOLS`,`r(r)`,aD(!1)),I(`EXPAND`,`rr?rr`,(e,t)=>{let n=L(e[0],t);if(n instanceof C)return n;let r=ZE(WE(e[1],t,n.rows),WE(e[2],t,n.cols));if(r instanceof C)return r;if(r.rows<n.rows||r.cols<n.cols)return w.VALUE;let i=UE(e[3],t)??w.NA,a=Array(r.rows*r.cols);for(let e=0;e<r.rows;e++)for(let t=0;t<r.cols;t++)a[e*r.cols+t]=e<n.rows&&t<n.cols?n.at(e,t):i;return new T(r.rows,r.cols,a)});function oD(e){return(t,n)=>{let r=L(t[0],n);if(r instanceof C)return r;if(r.rows>1&&r.cols>1)return w.VALUE;let i=WE(t[1],n,1);if(i instanceof C)return i;let a=Math.trunc(i);if(a<1)return w.NUM;let o=UE(t[2],n)??w.NA,s=BE(r).flat(),c=[];for(let e=0;e<s.length;e+=a)c.push(Array.from({length:a},(t,n)=>e+n<s.length?s[e+n]??null:o));return VE(e?c:HE(c))}}I(`WRAPROWS`,`rr?r`,oD(!0)),I(`WRAPCOLS`,`rr?r`,oD(!1));function sD(e,t,n){let r=P(e);if(r instanceof C)return r;let i=t==null?0:N(t);if(i instanceof C)return i;if(i!==0&&i!==1)return w.VALUE;try{return new RegExp(r,`${i===1?`i`:``}${n?`g`:``}`)}catch{return w.VALUE}}F(`REGEXTEST`,2,3,(e,t,n)=>{let r=P(e);if(r instanceof C)return r;let i=sD(t,n,!1);return i instanceof C?i:i.test(r)}),I(`REGEXEXTRACT`,`vv?vv`,(e,t)=>{let n=P(e[0]instanceof D?null:e[0]);if(n instanceof C)return n;let r=WE(e[2],t,0);if(r instanceof C)return r;let i=e[3]instanceof D?void 0:e[3],a=sD(e[1],i,r===1);if(a instanceof C)return a;if(r===0)return a.exec(n)?.[0]??w.NA;if(r===1){let e=[...n.matchAll(a)].map(e=>e[0]);return e.length===0?w.NA:new T(e.length,1,e)}if(r===2){let e=a.exec(n);if(!e)return w.NA;let t=e.slice(1).map(e=>e??``);return t.length===0?w.NA:new T(1,t.length,t)}return w.VALUE}),F(`REGEXREPLACE`,3,5,(e,t,n,r,i)=>{let a=P(e),o=P(n);if(a instanceof C)return a;if(o instanceof C)return o;let s=r==null?0:N(r);if(s instanceof C)return s;let c=sD(t,i,!0);if(c instanceof C)return c;let l=Math.trunc(s);if(l===0)return a.replace(c,o);let u=[...a.matchAll(c)],d=l>0?u[l-1]:u[u.length+l];if(!d)return a;let f=new RegExp(c.source,c.flags.replace(`g`,``)),p=d.index;return a.slice(0,p)+d[0].replace(f,o)+a.slice(p+d[0].length)}),I(`PERCENTOF`,`rr`,(e,t)=>{let n=Xu.get(`SUM`);if(!n)return w.NAME;let r=N(QE(t.calc.applyFunction(n,[e[0]],t.frame),t)),i=N(QE(t.calc.applyFunction(n,[e[1]],t.frame),t));return r instanceof C?r:i instanceof C?i:i===0?w.DIV0:r/i}),I(`TRIMRANGE`,`r?vv`,(e,t)=>{let n=e[0];if(!(n instanceof E))return n instanceof C?n:w.VALUE;let r=WE(e[1],t,3),i=WE(e[2],t,3);if(r instanceof C)return r;if(i instanceof C)return i;let a=t.calc.matrix(n),o=e=>Array.from({length:a.cols},(t,n)=>a.at(e,n)).every(e=>e===null),s=e=>Array.from({length:a.rows},(t,n)=>a.at(n,e)).every(e=>e===null),c=0,l=a.rows-1,u=0,d=a.cols-1;if(r===1||r===3)for(;c<=l&&o(c);)c++;if(r===2||r===3)for(;l>=c&&o(l);)l--;if(i===1||i===3)for(;u<=d&&s(u);)u++;if(i===2||i===3)for(;d>=u&&s(d);)d--;return c>l||u>d?w.REF:new E(n.sheet,n.top+c,n.left+u,n.top+l,n.left+d)});function cD(e,t,n){let r=new Map;for(let i of n){let n=e[i]?.[t]??null,a=XE(n),o=r.get(a);o?o.records.push(i):r.set(a,{key:n,records:[i],children:[]})}return[...r.values()]}function lD(e,t,n,r,i,a){let o=(e,t)=>e.sort((e,n)=>{for(let r of i){let i=`field`in r?r.field===t?JE(e.key,n.key,r.down):0:JE(r.value(e.records),r.value(n.records),r.down);if(i!==0)return i}return 0}),s=[],c=r<0,l=Math.abs(r);if(a){let r=new Map;for(let i of n){let n=(e[i]??[]).slice(0,t).map(XE).join(`\0`),a=r.get(n);a?a.records.push(i):r.set(n,{key:null,records:[i],children:[]})}let a=[...r.values()].sort((t,n)=>{for(let r of i){let i=`field`in r?JE(e[t.records[0]??0]?.[r.field]??null,e[n.records[0]??0]?.[r.field]??null,r.down):JE(r.value(t.records),r.value(n.records),r.down);if(i!==0)return i}return 0});for(let n of a)s.push({kind:`leaf`,keys:(e[n.records[0]??0]??[]).slice(0,t),records:n.records})}else{let r=(n,i,a)=>{for(let u of o(n,i)){let n=[...a,u.key];if(i===t-1){s.push({kind:`leaf`,keys:n,records:u.records});continue}let o={kind:`subtotal`,keys:[...n,...Array(t-n.length).fill(null)],records:u.records},d=i<l-1;d&&c&&s.push(o),r(cD(e,i+1,u.records),i+1,n),d&&!c&&s.push(o)}};r(cD(e,0,n),0,[])}if(l>=1){let e={kind:`total`,keys:[`Total`,...Array(t-1).fill(null)],records:[...n]};c?s.unshift(e):s.push(e)}return s}function uD(e,t,n,r){let i=e=>new T(e.length,1,[...e]),a=e.named===void 0?void 0:Xu.get(e.named),o=(a?a.min>=2:e.params.length>=2)?[i(t),i(n)]:[i(t)];return QE(r.calc.apply(e,o),r)}function dD(e,t,n){if(e===void 0||e instanceof D){let e=t[0]??[],n=t[1]??[];return{has:e.length>0&&e.every(e=>typeof e==`string`)&&n.some(e=>typeof e==`number`),show:!1,named:!1}}let r=WE(e,n,0);return r instanceof C?r:[0,1,2,3].includes(r)?{has:r===1||r===3,show:r===2||r===3,named:r===2}:w.VALUE}function fD(e,t,n,r){let i=Array.from({length:t},(e,t)=>t);if(e===void 0||e instanceof D)return i;let a=L(e,r);if(a instanceof C)return a;if(a.rows*a.cols!==t+n)return w.VALUE;let o=[];for(let e of i){let t=e+n,r=YE(a.cols===1?a.at(t,0):a.at(0,t));if(r instanceof C)return r;r&&o.push(e)}return o}function pD(e,t,n,r){let i=e===void 0||e instanceof D?[]:KE(e,r,1);if(i instanceof C)return i;let a=[];for(let e of i){let r=Math.abs(e)-1,i=e<0;if(r<0)return w.VALUE;if(r<t)a.push({field:r,down:i});else{let e=n(r-t);if(!e)return w.VALUE;a.push({value:e,down:i})}}for(let e=0;e<t;e++)a.some(t=>`field`in t&&t.field===e)||a.push({field:e,down:!1});return a}var mD=(e,t,n)=>WE(e,t,n);I(`GROUPBY`,`rrr?vvrrv`,(e,t)=>{let n=L(e[0],t),r=L(e[1],t),i=e[2];if(n instanceof C)return n;if(r instanceof C)return r;if(!(i instanceof at)||n.rows!==r.rows)return w.VALUE;let a=n.cols===0?[]:BE(n),o=BE(r),s=dD(e[3],o,t);if(s instanceof C)return s;let c=+!!s.has,l=a.slice(c),u=o.slice(c),d=mD(e[4],t,1);if(d instanceof C)return d;let f=WE(e[7],t,0);if(f instanceof C)return f;let p=fD(e[6],l.length,c,t);if(p instanceof C)return p;if(p.length===0)return w.CALC;let m=n.cols,h=r.cols,g=e=>u.map(t=>t[e]??null),_=Array.from({length:h},(e,t)=>g(t)),v=e=>p.map(t=>_[e]?.[t]??null),ee=(e,n)=>uD(i,n.map(t=>_[e]?.[t]??null),v(e),t),te=pD(e[5],m,e=>e<h?t=>ee(e,t):void 0,t);if(te instanceof C)return te;let y=lD(l,m,p,d,te,f===1),b=[];s.show&&b.push([...Array.from({length:m},(e,t)=>s.named?`Row Field ${String(t+1)}`:a[0]?.[t]??null),...Array.from({length:h},(e,t)=>s.named?`Value ${String(t+1)}`:o[0]?.[t]??null)]);for(let e of y)b.push([...e.keys,...Array.from({length:h},(t,n)=>ee(n,e.records))]);return VE(b)}),I(`PIVOTBY`,`rrrr?vvrvrrv`,(e,t)=>{let n=L(e[0],t),r=L(e[1],t),i=L(e[2],t),a=e[3];if(n instanceof C)return n;if(r instanceof C)return r;if(i instanceof C)return i;if(!(a instanceof at)||n.rows!==i.rows||r.rows!==i.rows)return w.VALUE;let o=BE(n),s=BE(r),c=BE(i),l=dD(e[4],c,t);if(l instanceof C)return l;let u=+!!l.has,d=o.slice(u),f=s.slice(u),p=c.slice(u),m=mD(e[5],t,1),h=mD(e[7],t,1),g=WE(e[10],t,0);if(m instanceof C)return m;if(h instanceof C)return h;if(g instanceof C)return g;let _=fD(e[9],p.length,u,t);if(_ instanceof C)return _;if(_.length===0)return w.CALC;let v=i.cols,ee=pD(e[6],n.cols,()=>void 0,t),te=pD(e[8],r.cols,()=>void 0,t);if(ee instanceof C)return ee;if(te instanceof C)return te;let y=lD(d,n.cols,_,m,ee,!1),b=lD(f,r.cols,_,h,te,!1),ne=(e,t)=>{let n=new Set(t);return e.filter(e=>n.has(e))},re=(e,t)=>p[t]?.[e]??null,ie=(e,n,r)=>{let i=ne(n.records,r.records);if(i.length===0)return null;let o=g===1?n.records:g===2?_:r.records;return uD(a,i.map(t=>re(e,t)),o.map(t=>re(e,t)),t)},ae=n.cols,oe=[];for(let e=0;e<r.cols;e++)oe.push([...Array(ae).fill(null),...b.flatMap(t=>Array.from({length:v},(n,r)=>r===0?t.keys[e]??null:null))]);(v>1||l.show)&&oe.push([...Array.from({length:ae},(e,t)=>l.show?o[0]?.[t]??null:null),...b.flatMap(()=>Array.from({length:v},(e,t)=>l.has?c[0]?.[t]??null:`Value ${String(t+1)}`))]);for(let e of y)oe.push([...e.keys,...b.flatMap(t=>Array.from({length:v},(n,r)=>ie(r,e,t)))]);return VE(oe)});var hD=(e,t)=>Le(Ie(e,t+1,0)).day,gD=(e,t,n)=>n===0||n===4?Math.round(Ah(e,t,n)*360):t-e;function _D(e,t,n){let r=Le(e),i=r.year*12+r.month-1+t,a=Math.floor(i/12),o=i-a*12+1,s=hD(a,o);return Ie(a,o,n?s:Math.min(r.day,s))}var vD=e=>{let t=Le(e);return t.day===hD(t.year,t.month)};function yD(e,t,n,r){let i=12/n,a=vD(t),o=0,s=t;for(;s>e;)o+=1,s=_D(t,-i*o,a);let c=_D(t,-i*(o-1),a),l=r===1?c-s:r===3?365/n:360/n,u=gD(s,e,r);return{previous:s,next:c,count:o,period:l,since:u,until:r===0||r===4?l-u:c-e}}function bD(e,t){let n=[];for(let[r,i]of t.entries()){let t=e[r],a=t==null?i??0:N(t);if(a instanceof C)return a;n.push(a)}return n}var xD=e=>Number.isInteger(e)&&e>=0&&e<=4,SD=e=>e===1||e===2||e===4;function CD(e,t,n,r){F(e,t,n.length,(...e)=>{let t=bD(e,n);if(t instanceof C)return t;let[i=0,a=0,...o]=t,s=Math.trunc(i),c=Math.trunc(a),l=Math.trunc(o[o.length-1]??0);return s>=c||!xD(l)?w.NUM:r(s,c,...o.slice(0,-1),l)})}var $=void 0;for(let[e,t]of[[`COUPDAYBS`,e=>e.since],[`COUPDAYS`,e=>e.period],[`COUPDAYSNC`,e=>e.until],[`COUPNCD`,e=>e.next],[`COUPNUM`,e=>e.count],[`COUPPCD`,e=>e.previous]])CD(e,3,[$,$,$,0],(e,n,r=0,i=0)=>SD(r)?t(yD(e,n,r,i)):w.NUM);function wD(e,t,n,r,i,a,o){let s=yD(e,t,a,o),c=100*n/a,l=s.until/s.period;if(s.count===1)return(i+c)/(1+l*r/a)-c*s.since/s.period;let u=i/(1+r/a)**(s.count-1+l);for(let e=1;e<=s.count;e++)u+=c/(1+r/a)**(e-1+l);return u-c*s.since/s.period}CD(`PRICE`,6,[$,$,$,$,$,$,0],(e,t,n=0,r=0,i=0,a=0,o=0)=>n<0||r<0||i<=0||!SD(a)?w.NUM:wD(e,t,n,r,i,a,o)),CD(`YIELD`,6,[$,$,$,$,$,$,0],(e,t,n=0,r=0,i=0,a=0,o=0)=>{if(n<0||r<=0||i<=0||!SD(a))return w.NUM;let s=-.99,c=1;for(;wD(e,t,n,c,i,a,o)>r&&c<1e6;)c*=2;for(let l=0;l<200;l++){let l=(s+c)/2;wD(e,t,n,l,i,a,o)>r?s=l:c=l}return(s+c)/2});function TD(e,t,n,r,i,a){let o=yD(e,t,i,a),s=o.until/o.period,c=0,l=0;for(let e=1;e<=o.count;e++){let t=e-1+s,a=(100*n/i+(e===o.count?100:0))/(1+r/i)**t;c+=t*a,l+=a}return c/l/i}CD(`DURATION`,5,[$,$,$,$,$,0],(e,t,n=0,r=0,i=0,a=0)=>n<0||r<0||!SD(i)?w.NUM:TD(e,t,n,r,i,a)),CD(`MDURATION`,5,[$,$,$,$,$,0],(e,t,n=0,r=0,i=0,a=0)=>n<0||r<0||!SD(i)?w.NUM:TD(e,t,n,r,i,a)/(1+r/i)),CD(`DISC`,4,[$,$,$,$,0],(e,t,n=0,r=0,i=0)=>n<=0||r<=0?w.NUM:(r-n)/r/Ah(e,t,i)),CD(`INTRATE`,4,[$,$,$,$,0],(e,t,n=0,r=0,i=0)=>n<=0||r<=0?w.NUM:(r-n)/n/Ah(e,t,i)),CD(`RECEIVED`,4,[$,$,$,$,0],(e,t,n=0,r=0,i=0)=>{let a=1-r*Ah(e,t,i);return n<=0||r<=0||a<=0?w.NUM:n/a}),CD(`PRICEDISC`,4,[$,$,$,$,0],(e,t,n=0,r=0,i=0)=>n<=0||r<=0?w.NUM:r*(1-n*Ah(e,t,i))),CD(`YIELDDISC`,4,[$,$,$,$,0],(e,t,n=0,r=0,i=0)=>n<=0||r<=0?w.NUM:(r-n)/n/Ah(e,t,i));function ED(e,t){F(e,3,3,sd((e=0,n=0,r=0)=>{let i=Math.trunc(e),a=Math.trunc(n);return i>=a||r<=0||a>_D(i,12,!1)?w.NUM:t(a-i,r)}))}ED(`TBILLPRICE`,(e,t)=>{let n=100*(1-t*e/360);return n<=0?w.NUM:n}),ED(`TBILLYIELD`,(e,t)=>(100-t)/t*360/e),ED(`TBILLEQ`,(e,t)=>{if(e<=182)return 365*t/(360-t*e);let n=100*(1-t*e/360),r=e/365,i=r*r-(2*r-1)*(1-100/n);return(-r+Math.sqrt(i))/(r-.5)}),F(`ACCRINTM`,3,5,(...e)=>{let t=bD(e,[$,$,$,1e3,0]);if(t instanceof C)return t;let[n=0,r=0,i=0,a=0,o=0]=t,s=Math.trunc(n),c=Math.trunc(r);return s>=c||i<=0||a<=0||!xD(o)?w.NUM:a*i*Ah(s,c,o)}),F(`ACCRINT`,6,8,(...e)=>{let t=bD(e.slice(0,7),[$,$,$,$,1e3,$,0]);if(t instanceof C)return t;let[n=0,r=0,i=0,a=0,o=0,s=0,c=0]=t,l=e[7]===void 0||Ru(e[7]);if(l instanceof C)return l;let u=Math.trunc(n),d=Math.trunc(i),f=Math.trunc(r);if(u>=d||a<=0||o<=0||!SD(s)||!xD(c))return w.NUM;let p=12/s,m=f,h=f;for(let e=1;m>u;e++)m=_D(f,-p*e,!1);let g=0;for(;m<d;){h=_D(m,p,!1);let e=l?Math.max(u,m):Math.max(m,f<=d?f:u),t=Math.min(d,h),n=c===1?h-m:c===3?365/s:360/s;t>e&&(g+=gD(e,t,c)/n),m=h}return o*a*g/s});var DD=(e,t)=>(1+e)**t,OD=e=>e===0?0:1,kD=e=>Number.isFinite(e)?e:w.NUM;function AD(e,t,n,r,i){if(e===0)return-(n+r)/t;let a=DD(e,t);return-(n*a+r)*e/((1+e*i)*(a-1))}function jD(e,t,n,r,i){if(e===0)return-(r+n*t);let a=DD(e,t);return-(r*a+n*(1+e*i)*(a-1)/e)}function MD(e,t,n,r,i,a){if(t<1||t>n)return w.NUM;if(a===1&&t===1)return 0;let o=AD(e,n,r,i,a);return kD((a===1?jD(e,t-2,o,r,1)-o:jD(e,t-1,o,r,0))*e)}F(`PMT`,3,5,sd((e,t,n,r=0,i=0)=>t===0?w.NUM:kD(AD(e,t,n,r,OD(i))))),F(`FV`,3,5,sd((e,t,n,r=0,i=0)=>kD(jD(e,t,n,r,OD(i))))),F(`IPMT`,4,6,sd((e,t,n,r,i=0,a=0)=>MD(e,t,n,r,i,OD(a)))),F(`PPMT`,4,6,sd((e,t,n,r,i=0,a=0)=>{let o=OD(a),s=MD(e,t,n,r,i,o);return s instanceof C?s:kD(AD(e,n,r,i,o)-s)})),F(`DB`,4,5,sd((e,t,n,r,i=12)=>{let a=Math.trunc(r);if(e<0||t<0||n<=0||a<=0||i<=0||i>12||a>n+1)return w.NUM;let o=e===0?0:Math.round((1-(t/e)**(1/n))*1e3)/1e3,s=0,c=0;for(let t=1;t<=a;t++)c=t===1?e*o*i/12:t===n+1?(e-s)*o*(12-i)/12:(e-s)*o,s+=c;return kD(c)})),F(`VDB`,5,7,(...e)=>{let t=bD(e.slice(0,6),[$,$,$,$,$,2]);if(t instanceof C)return t;let[n=0,r=0,i=0,a=0,o=0,s=0]=t,c=e[6]!==void 0&&Ru(e[6]);if(c instanceof C)return c;if(n<0||r<0||i<=0||a<0||o>i||a>o||s<=0)return w.NUM;let l=n,u=0,d=Math.ceil(o);for(let e=1;e<=d;e++){let t=Math.min(l*s/i,Math.max(0,l-r)),n=i-e+1,d=(l-r)/n,f=c?t:Math.max(t,d),p=Math.min(o,e)-Math.max(a,e-1);p>0&&(u+=f*p),l-=f}return u});var ND=(e,t,n,r,i)=>({whole:Ah(n,t,i),accrued:Ah(n,e,i),left:Ah(e,t,i),rate:r});CD(`PRICEMAT`,5,[$,$,$,$,$,0],(e,t,n=0,r=0,i=0,a=0)=>{let o=Math.trunc(n);if(o>=e||r<0||i<0)return w.NUM;let{whole:s,accrued:c,left:l}=ND(e,t,o,r,a);return(100+s*r*100)/(1+l*i)-c*r*100}),CD(`YIELDMAT`,5,[$,$,$,$,$,0],(e,t,n=0,r=0,i=0,a=0)=>{let o=Math.trunc(n);if(o>=e||r<0||i<=0)return w.NUM;let{whole:s,accrued:c,left:l}=ND(e,t,o,r,a);return((1+s*r)/(i/100+c*r)-1)/l});function PD(e,t,n,r,i){let a=12/r,o=vD(t),s={held:0,accrued:0,left:0,count:0},c=0,l=t;for(;l>e;){c+=1;let u=_D(t,-a*c,o),d=i===1?l-u:i===3?365/r:360/r,f=Math.max(u,e),p=l,m=(e,t)=>t>e?gD(e,t,i)/d:0;s.held+=m(f,p),s.accrued+=m(f,Math.min(n,p)),s.left+=m(Math.max(n,f),p),s.count+=1,l=u}return s}function FD(e,t,n,r,i,a,o,s,c){let l=100*i/s,u=yD(r,t,s,c).count+1,d=PD(n,r,e,s,c),f=1+a/s,p=d.left,m=o/f**(u-1+p);m+=l*d.held/f**p;for(let e=2;e<=u;e++)m+=l/f**(e-1+p);return m-l*d.accrued}function ID(e,t,n){let r=n;for(let n=0;n<100;n++){let n=e(r),i=n-t;if(Math.abs(i)<1e-10)return r;let a=(e(r+1e-6)-n)/1e-6;if(a===0||!Number.isFinite(a))return;r-=i/a,r<=-1&&(r=-.99)}}function LD(e,t){F(e,8,9,(...e)=>{let n=bD(e,[$,$,$,$,$,$,$,$,0]);if(n instanceof C)return n;let[r=0,i=0,a=0,o=0,s=0,c=0,l=0,u=0]=n,d=Math.trunc(n[8]??0),f=Math.trunc(r),p=Math.trunc(i),m=Math.trunc(a),h=Math.trunc(o);return!xD(d)||!SD(u)||!(p>h&&h>f&&f>m)||s<0||c<0||l<=0?w.NUM:t(e=>FD(f,p,m,h,s,e,l,u,d),c)})}LD(`ODDFPRICE`,(e,t)=>e(t)),LD(`ODDFYIELD`,(e,t)=>ID(e,t,.1)??w.NUM);function RD(e,t){F(e,7,8,(...e)=>{let n=bD(e,[$,$,$,$,$,$,$,0]);if(n instanceof C)return n;let[r=0,i=0,a=0,o=0,s=0,c=0,l=0]=n,u=Math.trunc(n[7]??0),d=Math.trunc(r),f=Math.trunc(i),p=Math.trunc(a);return!xD(u)||!SD(l)||!(f>d&&d>p)||o<0||s<0||c<=0?w.NUM:t({odd:PD(p,f,d,l,u),coupon:100*o/l,last:s,red:c,f:l})})}RD(`ODDLPRICE`,({odd:e,coupon:t,last:n,red:r,f:i})=>(r+e.held*t)/(1+e.left*n/i)-e.accrued*t),RD(`ODDLYIELD`,({odd:e,coupon:t,last:n,red:r,f:i})=>{let a=n+e.accrued*t;return(r+e.held*t-a)/a*i/e.left}),F(`AMORLINC`,6,7,(...e)=>{let t=bD(e,[$,$,$,$,$,$,0]);if(t instanceof C)return t;let[n=0,r=0,i=0,a=0,o=0,s=0]=t,c=Math.trunc(t[6]??0),l=Math.trunc(o);if(!xD(c)||c===2||n<0||a<0||a>n||l<0||s<=0||r>i)return w.NUM;let u=n*s,d=Ah(Math.trunc(r),Math.trunc(i),c)*u,f=Math.trunc((n-a-d)/u);return l===0?d:l<=f?u:l===f+1?n-a-u*f-d:0}),F(`AMORDEGRC`,6,7,(...e)=>{let t=bD(e,[$,$,$,$,$,$,0]);if(t instanceof C)return t;let[n=0,r=0,i=0,a=0,o=0,s=0]=t,c=Math.trunc(t[6]??0),l=Math.trunc(o);if(!xD(c)||c===2||n<0||a<0||a>n||l<0||s<=0||r>i)return w.NUM;let u=1/s,d=s*(u<3?1:u<5?1.5:u<=6?2:2.5),f=Math.round(Ah(Math.trunc(r),Math.trunc(i),c)*d*n);if(l===0)return f;let p=n-f,m=p-a;for(let e=0;e<l;e++){if(f=Math.round(d*p),m-=f,m<0)return l-e<=1?Math.round(p*.5):0;p-=f}return f});function zD(e,t){let n=[];for(let t=0;t<e.cols;t++){let r=P(e.at(0,t));if(r instanceof C)return r;n.push(r.toLowerCase())}let r=[];for(let i=1;i<e.rows;i++){let a=t.rows<2;for(let r=1;r<t.rows&&!a;r++){let o=!0;for(let a=0;a<t.cols&&o;a++){let s=t.at(r,a);if(s===null||s===``)continue;let c=P(t.at(0,a));if(c instanceof C)return c;let l=n.indexOf(c.toLowerCase());if(l<0){o=!1;continue}let u=vd(s);if(u instanceof C)return u;u.test(e.at(i,l))||(o=!1)}o&&(a=!0)}a&&r.push(i)}return r}function BD(e,t){if(typeof t==`number`){let n=Math.trunc(t)-1;return n<0||n>=e.cols?w.VALUE:n}let n=P(t);if(n instanceof C)return n;for(let t=0;t<e.cols;t++){let r=e.at(0,t);if(typeof r==`string`&&Vu(r,n)===0)return t}return w.VALUE}function VD(e,t){let n=L(e[0],t);if(n instanceof C)return n;let r=L(e[2],t);if(r instanceof C)return r;let i=zD(n,r);if(i instanceof C)return i;let a=e[1];if(a===void 0)return{list:i.map(()=>null),db:n};let o=BD(n,t.calc.scalar(a,t.frame));return o instanceof C?o:{list:i.map(e=>n.at(e,o)),db:n}}function HD(e,t){I(e,`rvr`,(e,n)=>{let r=VD(e,n);if(r instanceof C)return r;let i=Xu.get(t);if(i?.kind!==`raw`)return w.VALUE;let a=r.list.filter(e=>typeof e==`number`);return i.call([...a.length>0?a:[0]],n)})}for(let[e,t]of[[`DSUM`,`SUM`],[`DMAX`,`MAX`],[`DMIN`,`MIN`],[`DPRODUCT`,`PRODUCT`]])HD(e,t);for(let[e,t]of[[`DAVERAGE`,`AVERAGE`],[`DSTDEV`,`STDEV.S`],[`DSTDEVP`,`STDEV.P`],[`DVAR`,`VAR.S`],[`DVARP`,`VAR.P`]])I(e,`rvr`,(e,n)=>{let r=VD(e,n);if(r instanceof C)return r;let i=Xu.get(t);if(i?.kind!==`raw`)return w.VALUE;let a=r.list.filter(e=>typeof e==`number`);return a.length===0?w.DIV0:i.call(a,n)});I(`DCOUNT`,`rv?r`,(e,t)=>{let n=VD(e.length===2?[e[0],void 0,e[1]]:e,t);return n instanceof C?n:n.list.filter(e=>typeof e==`number`).length}),I(`DCOUNTA`,`rv?r`,(e,t)=>{let n=VD(e.length===2?[e[0],void 0,e[1]]:e,t);return n instanceof C?n:n.list.filter(e=>e!==null).length}),I(`DGET`,`rvr`,(e,t)=>{let n=VD(e,t);return n instanceof C?n:n.list.length===0?w.VALUE:n.list.length>1?w.NUM:n.list[0]??null});function UD(e,t,n){let r={reads:[],names:new Set,volatile:!1,unknownNames:[],unknownFunctions:[],arguments:[]},i=new Set,a=(t,a,s)=>{let c=t.toLowerCase();if(s===void 0&&a.has(c))return!0;let l=s===void 0?n:e.sheet(s),u=l?[e.name(c,l)]:e.definitions(c);if(u.some(e=>e!==void 0)){r.names.add(c);let e=`${s??``}!${c}`;if(!i.has(e)){i.add(e);for(let e of u)e?.formula?.node&&o(e.formula.node,new Set)}return!0}if(Xu.has(t.toUpperCase()))return!0;let d=e.table(c);return d?(r.reads.push({kind:`structured`,table:d.name,sections:[],columns:[],thisRow:!1}),!0):!1},o=(e,t)=>{switch(e.kind){case`ref`:case`structured`:r.reads.push(e);return;case`name`:a(e.name,t,e.sheet)||r.unknownNames.push(e.name);return;case`unary`:case`postfix`:case`paren`:o(e.arg,t);return;case`binary`:o(e.left,t),o(e.right,t);return;case`array`:return;case`invoke`:o(e.callee,t);for(let n of e.args)o(n,t);return;case`call`:{let n=Xu.get(e.name);if(e.name===`LET`||e.name===`LAMBDA`){let n=new Set(t),r=e.args[e.args.length-1];e.args.forEach((t,i)=>{t!==r&&(e.name===`LET`&&i%2==1?o(t,n):t.kind===`name`&&n.add(t.name.toLowerCase()))}),r&&o(r,n);return}if(!n)a(e.written,t)||r.unknownFunctions.push(e.name);else{n.volatile===!0&&(r.volatile=!0);let t=n.kind===`raw`&&!ed(n.params,e.args.length);(e.args.length<n.min||e.args.length>n.max||t)&&r.arguments.push({name:e.name,given:e.args.length,min:n.min,max:n.max,...t?{group:n.params.group.length}:{}})}for(let n of e.args)o(n,t);return}default:return}};return t.node&&o(t.node,new Set),r}var WD=32,GD=class{cells=new Set;reference;constructor(e){this.reference=e}footprint(){return{sheet:this.reference.sheet,area:this.reference}}visit(e,t,n){if(this.reference.sheet===e&&S(this.reference,t))for(let e of this.cells)n(e)}},KD=class{s;constructor(e){this.s=e}footprint(){let{s:e}=this;return{sheet:e.reads,area:{top:e.t+e.kt*e.group.top,bottom:e.b+e.kb*e.group.bottom,left:e.l+e.kl*e.group.left,right:e.r+e.kr*e.group.right}}}visit(e,t,n){let{s:r}=this;if(e!==r.reads)return;let i=qD(r.group.top,r.group.bottom,r.t,r.kt,r.b,r.kb,t.top,t.bottom);if(!i)return;let a=qD(r.group.left,r.group.right,r.l,r.kl,r.r,r.kr,t.left,t.right);if(a)for(let e=i[0];e<=i[1];e++)for(let t=a[0];t<=a[1];t++){let i=r.on.at(e,t);i instanceof M&&i.shared===r.shared&&n(i)}}};function qD(e,t,n,r,i,a,o,s){let c=e,l=t;if(r===1)l=Math.min(l,s-n);else if(n>s)return;if(a===1)c=Math.max(c,o-i);else if(i<o)return;return c<=l?[c,l]:void 0}var JD=class{single=new Map;ranges=new Map;byColumn=new Map;wide=[];source;constructor(e){this.source=e}build(e){let t=new Map;for(let n of e){let e=t.get(n.shared);e?e.push(n):t.set(n.shared,[n])}for(let[e,n]of t)if(n.length<2||!this.addGroup(e,n))for(let e of n)this.add(e)}add(e){for(let t of this.source.readsOf(e))if(t.single){let n=this.single.get(t.sheet);n||(n=new Map,this.single.set(t.sheet,n));let r=ql(t.top,t.left),i=n.get(r);i||(i=new Set,n.set(r,i)),i.add(e)}else{let n=this.ranges.get(t.key);n||(n=new GD(t),this.ranges.set(t.key,n),this.list(n)),n.cells.add(e)}}remove(e){for(let t of this.source.readsOf(e))t.single?this.single.get(t.sheet)?.get(ql(t.top,t.left))?.delete(e):this.ranges.get(t.key)?.cells.delete(e)}readersIn(e,t){let n=new Set,r=e=>{n.add(e)},i=this.single.get(e);if(i)for(let e=t.top;e<=t.bottom;e++)for(let r=t.left;r<=t.right;r++)for(let t of i.get(ql(e,r))??[])n.add(t);let a=new Set,o=n=>{a.has(n)||(a.add(n),n.visit(e,t,r))};for(let e of this.wide)o(e);let s=this.byColumn.get(e);if(s)for(let e=t.left;e<=t.right;e++)s.get(e)?.forEach(o);return[...n]}readers(e,t,n){return this.readersIn(e,{top:t,left:n,bottom:t,right:n})}list(e){let{sheet:t,area:n}=e.footprint();if(n.right-n.left+1>WD){this.wide.push(e);return}let r=this.byColumn.get(t);r||(r=new Map,this.byColumn.set(t,r));for(let t=n.left;t<=n.right;t++){let n=r.get(t);n?n.push(e):r.set(t,[e])}}addGroup(e,t){let n=t[0]?.sheet;if(!n||t.some(e=>e.sheet!==n))return!1;let r={top:1/0,bottom:-1/0,left:1/0,right:-1/0};for(let e of t)r.top=Math.min(r.top,e.row),r.bottom=Math.max(r.bottom,e.row),r.left=Math.min(r.left,e.col),r.right=Math.max(r.right,e.col);let i=(t,r)=>this.source.readsAt(e,n,t,r),a=i(r.top,r.left),o=r.bottom>r.top?i(r.top+1,r.left):a,s=r.right>r.left?i(r.top,r.left+1):a,c=i(r.bottom,r.right);if(o.length!==a.length||s.length!==a.length||c.length!==a.length)return!1;let l=[];for(let t=0;t<a.length;t++){let i=a[t],u=o[t],d=s[t],f=c[t];if(!i||!u||!d||!f||u.sheet!==i.sheet||d.sheet!==i.sheet||f.sheet!==i.sheet)return!1;let p=(e,t)=>{let n=e-t;return n===0||n===1?n:void 0},m=r.bottom>r.top,h=r.right>r.left,g=m?p(u.top,i.top):0,_=m?p(u.bottom,i.bottom):0,v=h?p(d.left,i.left):0,ee=h?p(d.right,i.right):0;if(g===void 0||_===void 0||v===void 0||ee===void 0)return!1;let te=i.top-g*r.top,y=i.bottom-_*r.top,b=i.left-v*r.left,ne=i.right-ee*r.left;if(f.top!==te+g*r.bottom||f.bottom!==y+_*r.bottom||f.left!==b+v*r.right||f.right!==ne+ee*r.right)return!1;l.push(new KD({shared:e,on:n,group:r,reads:i.sheet,t:te,kt:g,b:y,kb:_,l:b,kl:v,r:ne,kr:ee}))}for(let e of l)this.list(e);return!0}};function YD(e){let t=2166136261;for(let n=0;n<e.length;n++)t=Math.imul(t^e.charCodeAt(n),16777619);return()=>{t=t+1831565813|0;let e=Math.imul(t^t>>>15,1|t);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}var XD=new Set,ZD=/\b(?:SUBTOTAL|AGGREGATE)\(/iu,QD=2e3,$D=50,eO=1024,tO=class extends Error{cell;constructor(e){super(`computed first`),this.cell=e}},nO=12,rO={max_iterations:100,max_change:.001};function iO(e,t){return typeof e==`number`&&typeof t==`number`?Math.abs(t-e):e===t||e instanceof C&&t instanceof C&&e.code===t.code?0:1/0}var aO=(e,t)=>!e||!t?e===t:e.rows!==t.rows||e.cols!==t.cols?!1:e.data.every((e,n)=>e===t.data[n]),oO=(e,t)=>e.row<t.row||e.row===t.row&&e.col<t.col,sO=class{cycles=[];computed=0;iterated;nowSerial;random;pass=0;lambdaSlots=0;stack=[];inCycle=new Set;waiting=new Set;work=[];unwound=new Map;counted=new Set;looping=new Set;tablesOf;inTables=!1;loop=new Set;around=new Set;namesAt=new Set;graph=new JD({readsOf:e=>this.readsOf(e),readsAt:(e,t,n,r)=>this.readsAt(e,t,n,r)});graphMade=!1;reports;replica;settled=new Set;moved=[];unsettled=new Set;hiddenBy=new Map;volatiles=new Set;indexes=new Ju;results=new Ju;wb;constructor(e,t={}){this.wb=e;let{now:n,random:r}=t;this.reports=t.report===!0,this.replica=t.replica===!0,this.nowSerial=()=>ze(n??new Date),this.random=r??Math.random;for(let t of e.sheets)t.expand()}allCells(){return this.wb.sheets.flatMap(e=>[...e.formulas])}filtered(e){return this.hiddenBy.get(e)??XD}calculate(){if(this.replica){for(let e of this.wb.sheets)e.clearSpills();for(let e of this.allCells())e.state=0;return this}this.hiddenBy.clear(),this.indexes.clear(),this.results.clear();for(let e of this.wb.sheets)e.clearSpills();this.moved=[],this.unsettled.clear();let e=this.allCells();for(let t of e)t.state=1;return this.cycles=[],this.inCycle.clear(),this.looping.clear(),this.loop=new Set,this.around.clear(),this.tablesOf=void 0,this.iterated=void 0,this.run(e),this.applyFilters(e),this}iteration(){let e=this.wb.file.iteration;if(e!==void 0)return{max_iterations:(e===!0?void 0:e.max_iterations)??rO.max_iterations,max_change:(e===!0?void 0:e.max_change)??rO.max_change}}applyFilters(e){for(let e of this.wb.sheets){if(e.filters.every(e=>e.columns.size===0))continue;let t=Dm(e,this);t.size>0&&this.hiddenBy.set(e,t)}if(this.hiddenBy.size!==0&&e.some(e=>ZD.test(e.shared.text))){for(let t of e)t.state=1;this.cycles=[],this.inCycle.clear(),this.run([...e])}}value(e,t,n){return this.read(e,t,n)}read(e,t,n){let r=e.at(t,n);return r===void 0?this.ghost(e,t,n):typeof r!=`object`||r instanceof C?r:(r.state===1&&!this.waiting.has(r)?this.computeNow(r):r.state!==0&&this.circular(r),r.value)}ghost(e,t,n){let r=e.spillAt(t,n);if(!r)return null;if(r.state===1&&!this.waiting.has(r))this.computeNow(r);else if(r.state!==0)return this.circular(r),null;let{array:i}=r;return i&&e.spillAt(t,n)===r?i.at(t-r.row,n-r.col):null}circular(e){let t=this.stack.indexOf(e),n=t>=0?this.stack.slice(t):[e],r=!1;if(t<0&&this.waiting.has(e)){n=[];for(let t=this.work.lastIndexOf(e);t<this.work.length-1;t++){let e=this.work[t];e!==void 0&&(this.counted.has(e)?r=!0:(this.counted.add(e),n.push(...this.unwound.get(e)??[e])))}n.push(...this.stack)}if(this.iteration())for(let e of n)this.looping.add(e);else{!r&&!n.some(e=>this.inCycle.has(e))&&this.cycles.push(n);for(let e of n)this.inCycle.add(e)}}forget(e,t){this.indexes.changed(e,t),this.results.changed(e,t)}run(e){for(let t of e){let{sheet:e,row:n,col:r}=t;this.forget(e,{top:n,left:r,bottom:n,right:r}),t.spill&&this.forget(e,t.spill)}e.some(e=>this.loop.has(e))&&(this.iterated=void 0),this.computed=0;for(let t of this.order(e))t.state===1&&this.computeNow(t);this.spread(),this.iterate(),this.tables()}tableCells(){if(this.tablesOf)return this.tablesOf;let e=new Map;for(let t of this.allCells())if(uO(t.shared.node)){let n=e.get(t.shared);n?n.push(t):e.set(t.shared,[t])}return this.tablesOf=e,e}tables(){if(this.replica||this.inTables)return;let e=this.tableCells();if(e.size!==0){this.inTables=!0;try{let t=[];for(let[n,r]of e)this.table(n,r),t.push(...r);let n=new Set(t),r=new Set;for(let e of t)for(let t of this.readers(e.sheet,e.row,e.col))n.has(t)||r.add(t);r.size>0&&this.mark([...r])}finally{this.inTables=!1}}}operations(e){let t=new Map,n=(e,t)=>{let n=e===void 0?void 0:this.eval(e,t);return n instanceof E&&n.single?n:void 0},r=e.map(e=>{let r=e.shared.node;if(r?.kind!==`call`)return w.REF;let i=dO(e),a=n(r.args[0],i);if(!a)return w.REF;let o=[];for(let e=1;e+1<r.args.length;e+=2){let a=n(r.args[e],i),s=n(r.args[e+1],i);if(!a||!s)return w.REF;let c=`${String(a.sheet.index)}:${String(a.top)}:${String(a.left)}`;t.has(c)||t.set(c,{sheet:a.sheet,row:a.top,col:a.left,slot:a.sheet.at(a.top,a.left)});let l=this.read(s.sheet,s.top,s.left);o.push({sheet:a.sheet,row:a.top,col:a.left,slot:l??void 0})}return this.change(o),this.read(a.sheet,a.top,a.left)});t.size>0&&this.change([...t.values()]),e.forEach((e,t)=>{e.value=r[t]??null,this.reports&&this.settled.add(e)})}table(e,t){let[n]=t,r=e.node;if(!n||r?.kind!==`call`)return;if(r.args.length>2){this.operations(t);return}let{sheet:i}=n,a=e.row,o=e.col,s={sheet:i,row:a,col:o,dr:0,dc:0},c=e=>{if(e===void 0||e.kind===`missing`)return null;let t=this.eval(e,s);return t instanceof E&&t.single?t:void 0},l=c(r.args[0]),u=c(r.args[1]),d=e=>{for(let n of t)n.value=e,this.reports&&this.settled.add(n)};if(l===void 0||u===void 0||l===null&&u===null||a===0||o===0){d(w.REF);return}let f=[l,u].filter(e=>e!==null).map(e=>({sheet:e.sheet,row:e.top,col:e.left,slot:e.sheet.at(e.top,e.left)})),p=e=>{let t=[];l&&t.push({sheet:l.sheet,row:l.top,col:l.left,slot:this.read(i,a-1,e.col)??void 0}),u&&t.push({sheet:u.sheet,row:u.top,col:u.left,slot:this.read(i,e.row,o-1)??void 0}),this.change(t)},m=e=>{let[t,n]=l&&u?[a-1,o-1]:u?[a-1,e.col]:[e.row,o-1];return this.read(i,t,n)},h=e=>l&&u?void 0:u?e.row:e.col,g=t.map((e,t)=>({cell:e,i:t})).sort((e,t)=>u&&!l?e.cell.row-t.cell.row||e.cell.col-t.cell.col:e.cell.col-t.cell.col||e.cell.row-t.cell.row),_=[],v;for(let{cell:e,i:t}of g){let n=h(e);(n===void 0||n!==v)&&(p(e),v=n),_[t]=m(e)}this.change(f),t.forEach((e,t)=>{e.value=_[t]??null,this.reports&&this.settled.add(e)})}iterate(){let e=this.iteration();if(!e||this.looping.size===0){this.looping.clear();return}for(let e of this.looping)this.around.add(e);let t=this.downstream([...this.looping]),n=[...t],r=1,i=1/0;for(;r<e.max_iterations;){let t=n.map(e=>e.value);this.looping.clear(),this.indexes.clear(),this.results.clear();for(let e of n)e.state=1;for(let e of this.order(n))e.state===1&&this.computeNow(e);if(r+=1,i=0,n.forEach((e,n)=>{i=Math.max(i,iO(t[n]??null,e.value))}),i<e.max_change)break}this.looping.clear(),this.spread(),this.looping.clear(),this.loop=t,this.iterated={cells:n.length,iterations:r,change:i}}iterates(e){return this.loop.has(e)}circularCells(){return[...this.around]}downstream(e){let t=new Set(e),n=[...e];for(;;){let e=n.pop();if(!e)break;for(let r of this.readers(e.sheet,e.row,e.col))t.has(r)||(t.add(r),n.push(r))}return t}spread(){for(let e=0;this.moved.length>0;e++){let t=this.moved;if(this.moved=[],e>=24)break;if(e>=nO)for(let{sheet:e,area:n}of t)for(let t of e.spillsIn(n))this.unsettled.add(t);this.build();let n=new Set,r=[...this.unsettled];for(let{sheet:e,area:n}of t)st(r,this.readersIn(e,n)),st(r,e.blockedBy(n));for(;;){let e=r.pop();if(!e)break;n.has(e)||(n.add(e),st(r,this.readers(e.sheet,e.row,e.col)))}if(n.size!==0){for(let e of n)e.state=1,this.inCycle.delete(e);this.cycles=this.cycles.filter(e=>!e.some(e=>n.has(e))),this.indexes.clear(),this.results.clear();for(let e of this.order([...n]))e.state===1&&this.computeNow(e)}}for(let e of this.wb.sheets)e.tighten()}spillOut(e,t){let{sheet:n,row:r,col:i}=e,a={top:r,left:i,bottom:r+t.rows-1,right:i+t.cols-1},o=n.spillsIn(a).filter(t=>t!==e);if(a.bottom>=1048576||a.right>=16384||n.holds(a,e)||n.tables.some(e=>S(e.area,a))||n.merges.some(e=>S(e,a))||o.some(t=>oO(t,e)))return n.blockSpill(e,a),!1;for(let e of o)this.evict(e,a);return n.placeSpill(e,a),!0}evict(e,t){let{sheet:n,spill:r}=e;r&&(n.clearSpill(e),n.blockSpill(e,t),e.array=void 0,e.value=w.SPILL,this.moved.push({sheet:n,area:r}),this.reports&&this.settled.add(e))}analysisOf(e){if(e.analysis!==void 0)return e.analysis;let t=e.node,n=t===void 0?void 0:this.analyses.get(t),r=n??UD(this.wb,e);return t!==void 0&&n===void 0&&this.analyses.set(t,r),e.analysis=r,r}analyses=new WeakMap;readsOf(e){let t=[],n=dO(e);for(let r of this.analysisOf(e.shared).reads){let e=r.kind===`ref`?this.resolveRef(r,n):this.structured(r,n);e instanceof E?t.push(e):e instanceof it&&t.push(...e.parts)}return t}readsAt(e,t,n,r){let i={sheet:t,row:n,col:r,dr:n-e.row,dc:r-e.col},a=[];for(let t of this.analysisOf(e).reads){let e=t.kind===`ref`?this.resolveRef(t,i):this.structured(t,i);e instanceof E?a.push(e):e instanceof it?a.push(...e.parts):a.push(void 0)}return a}readsOfFormula(e,t){let n=[],r={sheet:t,row:e.row,col:e.col,dr:0,dc:0};for(let t of this.analysisOf(e).reads){let e=t.kind===`ref`?this.resolveRef(t,r):this.structured(t,r);e instanceof E?n.push(e):e instanceof it&&n.push(...e.parts)}return n}order(e){this.pass+=1;let{pass:t}=this,n=[],r=new Set,i=[],a=e=>{e.mark=t,i.push({cell:e,reads:this.pending(e,r),next:0})};for(let r of e)if(r.mark!==t)for(a(r);;){let e=i[i.length-1];if(!e)break;let r=e.reads[e.next];e.next+=1,r===void 0?(n.push(e.cell),i.pop()):r.mark!==t&&r.state===1&&a(r)}return n}pending(e,t){let n=[];for(let r of this.readsOf(e)){let{sheet:e}=r;if(r.single){let t=e.at(r.top,r.left);t instanceof M&&n.push(t);continue}if(t.has(r.key))continue;t.add(r.key);let i=Math.min(r.right,e.columnsUsed-1);for(let t=r.left;t<=i;t++){if(!e.hasFormulas(t))continue;let[i,a]=e.span(t,r.top,r.bottom);for(let r=i;r<=a;r++){let i=e.at(r,t);i instanceof M&&n.push(i)}}}return n}computeNow(e){if(this.stack.length>0){if(this.stack.length>=$D&&this.stack.length<QD)throw new tO(e);this.compute(e);return}let t=[e],n=new Set([e]);this.work=t;try{for(;t.length>0;){let e=t[t.length-1];if(e===void 0)break;if(this.waiting.delete(e),e.state!==1)t.pop();else try{this.compute(e),t.pop()}catch(r){if(!(r instanceof tO))throw r;this.unwound.set(e,[...this.stack]),this.counted.delete(e);for(let e of this.stack)e.state=1;if(this.stack.length=0,this.waiting.add(e),n.has(r.cell)){r.cell.value=w.CALC,r.cell.state=0;continue}n.add(r.cell),t.push(r.cell)}}}finally{this.waiting.clear(),this.unwound.clear(),this.counted.clear(),this.work=[]}}compute(e){if(this.stack.length>=QD){e.value=w.CALC,e.state=0;return}e.state=2,this.stack.push(e),this.computed+=1;let{node:t}=e.shared,n=uO(t)?e.value:t?this.top(this.eval(t,dO(e))):w.NAME;this.stack.pop(),this.unsettled.has(e)&&!this.inCycle.has(e)&&(this.inCycle.add(e),this.cycles.push([e])),this.settleResult(e,n),e.state=0,this.reports&&this.settled.add(e)}settleResult(e,t){let{sheet:n}=e,r=e.spill,i=e.array;if(n.clearSpill(e),e.array=void 0,t instanceof T){let n=lO(t);n.rows*n.cols<=1||this.spillOut(e,n)?(e.array=n,e.value=n.at(0,0)??0):e.value=w.SPILL}else e.value=t;this.inCycle.has(e)&&(n.clearSpill(e),e.value=w.CYCLE,e.array=void 0);let a=e.spill;aO(i,e.array)&&cO(r,a)||(r&&this.moved.push({sheet:n,area:r}),a&&this.moved.push({sheet:n,area:a}))}top(e){let t=this.flat(e);return t===null?0:t}flat(e){return e instanceof E?e.single?this.read(e.sheet,e.top,e.left):this.matrix(e):e instanceof it?w.VALUE:e instanceof at?w.CALC:e instanceof D?null:e}matrix(e){let t=e.bottom===1048575?Math.min(e.bottom,e.sheet.lastRow):e.bottom,n=e.right===16383?Math.min(e.right,e.sheet.columnsUsed-1):e.right,r=Math.max(0,t-e.top+1),i=Math.max(0,n-e.left+1),a=Array(r*i);for(let t=0;t<r;t++)for(let n=0;n<i;n++)a[t*i+n]=this.read(e.sheet,e.top+t,e.left+n);return new T(r,i,a)}each(e,t){let{sheet:n}=e,r=Math.min(e.right,n.columnsUsed-1);for(let i=e.left;i<=r;i++){let[r,a]=n.span(i,e.top,e.bottom);for(let e=r;e<=a;e++){let r=n.at(e,i);r===void 0?n.spillAt(e,i)&&t(this.read(n,e,i),e,i):t(typeof r==`object`&&!(r instanceof C)?this.read(n,e,i):r,e,i)}}}evaluate(e,t){let{node:n}=e;return n?this.top(this.eval(n,{sheet:t,row:e.row,col:e.col,dr:0,dc:0})):w.NAME}evaluateAt(e,t,n,r){let{node:i}=e;return i?this.top(this.eval(i,{sheet:t,row:n,col:r,dr:n-e.row,dc:r-e.col})):w.NAME}hyperlinkTarget(e){let t=e.shared.node;for(;t?.kind===`paren`;)t=t.arg;if(t?.kind!==`call`||t.name!==`HYPERLINK`)return;let[n]=t.args;if(n===void 0)return;let r=dO(e);return this.scalar(this.eval(n,r),r)}bound(e,t,n){let r=e.abs?e.index:e.index+t;return r<0||r>=n?void 0:r}resolveRef(e,t){let n=e.sheet===void 0?t.sheet:this.wb.sheet(e.sheet);if(!n)return w.REF;let r=0,i=Se-1,a=0,o=xe-1;if(e.col){let n=this.bound(e.col,t.dc,Se),a=this.bound(e.col2??e.col,t.dc,Se);if(n===void 0||a===void 0)return w.REF;r=Math.min(n,a),i=Math.max(n,a)}if(e.row){let n=this.bound(e.row,t.dr,xe),r=this.bound(e.row2??e.row,t.dr,xe);if(n===void 0||r===void 0)return w.REF;a=Math.min(n,r),o=Math.max(n,r)}if(e.lastSheet!==void 0){let t=this.wb.sheet(e.lastSheet);if(!t)return w.REF;let[s,c]=[Math.min(n.index,t.index),Math.max(n.index,t.index)];return new it(this.wb.sheets.slice(s,c+1).map(e=>new E(e,a,r,o,i)))}return new E(n,a,r,o,i)}structured(e,t){let n=e.table===void 0?t.sheet.tableAt(t.row,t.col):this.wb.table(e.table);return n?fO(n,e,t):e.table===void 0?w.REF:w.NAME}nameValue(e,t,n){let r=e.toLowerCase();if(n===void 0)for(let e=t.scope;e;e=e.parent){let t=e.names.get(r);if(t!==void 0)return t}let i=n===void 0?t.sheet:this.wb.sheet(n);if(!i)return w.REF;let a=this.wb.name(e,i);if(a){if(!a.formula)return a.value??null;let{node:e}=a.formula;if(!e)return w.NAME;if(this.namesAt.has(r))return w.CYCLE;this.namesAt.add(r);try{return this.eval(e,{sheet:t.sheet,row:0,col:0,dr:0,dc:0})}finally{this.namesAt.delete(r)}}let o=this.wb.table(e);if(o){let{top:e,left:t,bottom:n,right:r}=o.data;return new E(o.sheet,e,t,n,r)}let s=Xu.get(e.toUpperCase());return s&&s.kind!==`lazy`?pO(s,e,t):w.NAME}intersect(e,t){return!(e instanceof E)||e.single?e:e.cols===1&&t.row>=e.top&&t.row<=e.bottom?new E(e.sheet,t.row,e.left,t.row,e.left):e.rows===1&&t.col>=e.left&&t.col<=e.right?new E(e.sheet,e.top,t.col,e.top,t.col):w.VALUE}unary(e,t){let n=this.flat(e);return n instanceof T?new T(n.rows,n.cols,n.data.map(t)):t(n)}operate(e,t,n){let r=this.flat(t),i=this.flat(n);return r instanceof T||i instanceof T?Ku(r instanceof T?r:new T(1,1,[r]),i instanceof T?i:new T(1,1,[i]),(t,n)=>Gu(e,t,n)):Gu(e,r,i)}rangeOf(e,t){return e instanceof C?e:t instanceof C?t:!(e instanceof E)||!(t instanceof E)||e.sheet!==t.sheet?w.REF:new E(e.sheet,Math.min(e.top,t.top),Math.min(e.left,t.left),Math.max(e.bottom,t.bottom),Math.max(e.right,t.right))}intersection(e,t){if(e instanceof C)return e;if(t instanceof C)return t;if(!(e instanceof E)||!(t instanceof E))return w.REF;let n=Math.max(e.top,t.top),r=Math.max(e.left,t.left),i=Math.min(e.bottom,t.bottom),a=Math.min(e.right,t.right);return e.sheet!==t.sheet||n>i||r>a?w.NULL:new E(e.sheet,n,r,i,a)}union(e,t){if(e instanceof C)return e;if(t instanceof C)return t;let n=e=>e instanceof E?[e]:e instanceof it?e.parts:[],r=[...n(e),...n(t)];return r.length===0?w.VALUE:new it(r)}eval(e,t){switch(e.kind){case`number`:case`string`:case`boolean`:return e.value;case`error`:return C.of(e.code);case`missing`:return ot;case`ref`:return this.resolveRef(e,t);case`structured`:return this.structured(e,t);case`name`:return this.nameValue(e.name,t,e.sheet);case`paren`:return this.eval(e.arg,t);case`unary`:{let n=this.eval(e.arg,t);return e.op===`@`?this.intersect(n,t):e.op===`+`?n:this.unary(n,e=>Gu(`*`,e,-1))}case`postfix`:{let n=this.eval(e.arg,t);if(e.op===`%`)return this.unary(n,e=>Gu(`/`,e,100));if(n instanceof E&&n.single){let e=n.sheet.at(n.top,n.left);if(e instanceof M){this.read(n.sheet,n.top,n.left);let{spill:t}=e;if(t)return new E(n.sheet,t.top,t.left,t.bottom,t.right);if(e.array)return n}}return w.REF}case`binary`:{let n=this.eval(e.left,t),r=this.eval(e.right,t);return e.op===`:`?this.rangeOf(n,r):e.op===` `?this.intersection(n,r):e.op===`,`?this.union(n,r):this.operate(e.op,n,r)}case`array`:return new T(e.rows.length,e.rows[0]?.length??0,e.rows.flatMap(e=>e.map(e=>{let n=this.eval(e,t);return n instanceof T||n instanceof E||n instanceof it||n instanceof at||n instanceof D?w.VALUE:n})));case`invoke`:{let n=this.eval(e.callee,t);return n instanceof at?this.invoke(n,e.args,t):n instanceof C?n:w.VALUE}case`call`:return this.call(e.name,e.args,t)}}invoke(e,t,n){return this.apply(e,t.map(e=>this.eval(e,n)))}apply(e,t){if(e.named!==void 0){let n=Xu.get(e.named);return!n||n.kind===`lazy`?w.NAME:t.length<n.min||t.length>n.max?w.VALUE:this.applyFunction(n,t,e.frame)}if(t.length>e.params.length)return w.VALUE;let n=e.params.length+1;if(this.lambdaSlots+n>eO)return w.NUM;let r=new Map;e.params.forEach((e,n)=>{r.set(e,t[n]??ot)}),this.lambdaSlots+=n;let i=this.stack.length;try{return this.eval(e.body,{...e.frame,scope:{names:r,...e.frame.scope?{parent:e.frame.scope}:{}}})}catch(e){if(!(e instanceof RangeError)||!e.message.includes(`call stack`))throw e;for(let e of this.stack.splice(i))e.state=1;return w.NUM}finally{this.lambdaSlots-=n}}call(e,t,n){let r=Xu.get(e);if(!r){let r=this.nameValue(e,n);return r instanceof at?this.invoke(r,t,n):w.NAME}return t.length<r.min||t.length>r.max?w.VALUE:r.kind===`lazy`?r.call(t,{calc:this,frame:n}):this.applyFunction(r,t.map(e=>this.eval(e,n)),n)}applyFunction(e,t,n){let r={calc:this,frame:n};if(e.kind===`lazy`)return w.VALUE;if(e.kind===`raw`)return ed(e.params,t.length)?this.over(t,t=>$u(e.params,t)===`value`,t=>e.call(t,r)):w.VALUE;let i=e.errors===!0;return this.over(t,()=>!0,t=>{let n=t.map(e=>e instanceof D?void 0:e);if(!i){for(let e of n)if(e instanceof C)return e}return e.call(...n)})}over(e,t,n){let r=[],i=new Map;for(let[n,a]of e.entries()){if(!t(n)||a instanceof D){r.push(a);continue}let e=this.flat(a);e instanceof T&&i.set(n,e),r.push(e)}if(i.size===0)return n(r);let a=[...i.values()],o=Math.max(...a.map(e=>e.rows)),s=Math.max(...a.map(e=>e.cols));if(o===0||s===0)return w.CALC;let c=Array(o*s);for(let e=0;e<o;e++)for(let t=0;t<s;t++){let a=r.map((n,r)=>{let a=i.get(r);if(!a)return n;let o=a.rows===1?0:e,s=a.cols===1?0:t;return o<a.rows&&s<a.cols?a.at(o,s):w.NA});c[e*s+t]=this.element(n(a))}return new T(o,s,c)}element(e){let t=this.flat(e);return t instanceof T?t.rows>0&&t.cols>0?t.at(0,0):w.CALC:t}scalar(e,t){if(e instanceof D)return null;if(e instanceof E){let n=this.intersect(e,t);return n instanceof E?this.read(n.sheet,n.top,n.left):w.VALUE}return e instanceof T?e.at(0,0):e instanceof it||e instanceof at?w.VALUE:e}recalculate(){if(this.replica)return this;let e=this.allCells().filter(e=>this.analysisOf(e.shared).volatile);return this.mark(e),this}build(){if(this.graphMade)return;this.graphMade=!0;let e=this.allCells();for(let t of e)this.analysisOf(t.shared).volatile&&this.volatiles.add(t);this.graph.build(e)}addEdges(e){this.analysisOf(e.shared).volatile&&this.volatiles.add(e),this.graph.add(e)}removeEdges(e){this.volatiles.delete(e),this.graph.remove(e)}readersIn(e,t){return this.graph.readersIn(e,t)}readers(e,t,n){return this.build(),this.graph.readers(e,t,n)}precedents(e){return this.readsOf(e)}mark(e){this.build();let t=new Set(e),n=[...e];for(;;){let e=n.pop();if(!e)break;for(let r of this.readers(e.sheet,e.row,e.col))t.has(r)||(t.add(r),n.push(r))}this.settle(t)}settle(e){for(let t of e)t.state=1,this.inCycle.delete(t);this.cycles=this.cycles.filter(t=>!t.some(t=>e.has(t))),this.run([...e])}set(e,t,n,r){let i=typeof r==`string`&&r.length>1&&r.startsWith(`=`)?new M(new Ul(r,t,n,{file:``}),e,t,n):void 0;this.change([{sheet:e,row:t,col:n,slot:i??r??void 0}])}prepare(){this.build()}change(e){if(this.replica){for(let{sheet:t,row:n,col:r,slot:i}of e){let e=t.at(n,r);e instanceof M&&t.clearSpill(e),t.replace(n,r,i),i instanceof M&&(i.state=0)}return}this.build();let t=new Set,n=[...this.unsettled];this.unsettled.clear();let r=new Set;for(let{sheet:i,row:a,col:o,slot:s}of e){let e=i.at(a,o);(e instanceof M&&uO(e.shared.node)||s instanceof M&&uO(s.shared.node))&&(this.tablesOf=void 0),e instanceof M&&(r.add(e),this.inCycle.delete(e),this.removeEdges(e),t.delete(e),e.spill&&this.moved.push({sheet:i,area:e.spill}),i.clearSpill(e));let c=i.spillAt(a,o);c&&n.push(c),n.push(...i.blockedBy({top:a,left:o,bottom:a,right:o})),i.replace(a,o,s),this.forget(i,{top:a,left:o,bottom:a,right:o}),s instanceof M&&(this.addEdges(s),t.add(s))}r.size>0&&(this.cycles=this.cycles.filter(e=>!e.some(e=>r.has(e))));for(let{sheet:t,row:r,col:i}of e)st(n,this.readers(t,r,i));for(st(n,this.volatiles);;){let e=n.pop();if(!e)break;t.has(e)||this.inTables&&uO(e.shared.node)||(t.add(e),st(n,this.readers(e.sheet,e.row,e.col)))}this.settle(t)}setName(e,t){let n=this.wb.name(e);if(!n)throw Error(`There is no name ${e}.`);n.value=t,delete n.formula;let r=e.toLowerCase();this.mark(this.allCells().filter(e=>this.analysisOf(e.shared).names.has(r)))}takeComputed(){let e=[];for(let t of this.settled)e.push({sheet:t.sheet.index,row:t.row,col:t.col,value:Du(t.value),...t.array?{array:ku(t.array)}:{},...t.spill?{spill:t.spill}:{},...t.blocked?{blocked:t.blocked}:{}});return this.settled.clear(),{cells:e,cycles:this.cycles.map(e=>e.map(e=>({sheet:e.sheet.index,row:e.row,col:e.col}))),hidden:[...this.hiddenBy].map(([e,t])=>({sheet:e.index,rows:[...t]}))}}receive(e){for(let t of e.cells){let e=this.wb.sheets[t.sheet],n=e?.at(t.row,t.col);e&&n instanceof M&&(e.clearSpill(n),n.value=Ou(t.value),n.array=t.array?Au(t.array):void 0,t.spill&&e.placeSpill(n,t.spill),t.blocked&&e.blockSpill(n,t.blocked),n.state=0)}this.cycles=e.cycles.flatMap(e=>{let t=e.flatMap(e=>{let t=this.wb.sheets[e.sheet]?.at(e.row,e.col);return t instanceof M?[t]:[]});return t.length>0?[t]:[]});let t=new Map(this.hiddenBy);this.hiddenBy.clear();for(let{sheet:n,rows:r}of e.hidden){let e=this.wb.sheets[n];if(!e)continue;let i=t.get(e),a=i?.size===r.length&&r.every(e=>i.has(e));this.hiddenBy.set(e,a?i:new Set(r))}for(let e of this.wb.sheets)e.tighten()}numberOf(e){return N(e)}},cO=(e,t)=>e?.top===t?.top&&e?.left===t?.left&&e?.bottom===t?.bottom&&e?.right===t?.right;function lO(e){return e.data.some(e=>e===null)?new T(e.rows,e.cols,e.data.map(e=>e??0)):e}function uO(e){return e?.kind===`call`&&e.name===`TABLE`}function dO(e){return{sheet:e.sheet,row:e.row,col:e.col,dr:e.row-e.shared.row,dc:e.col-e.shared.col}}function fO(e,t,n){let{sheet:r}=e,i=e.area,a=i.left,o=i.right,[s,c]=t.columns;if(s!==void 0){let t=e.column(s),n=c===void 0?t:e.column(c);if(!t||!n)return w.REF;a=i.left+Math.min(t.index,n.index),o=i.left+Math.max(t.index,n.index)}if(t.thisRow)return n.sheet!==r||n.row<=i.top||n.row>i.bottom?w.VALUE:new E(r,n.row,a,n.row,o);let l=t.sections;if(l.includes(`#Totals`))return w.REF;let u=l.includes(`#All`)||l.includes(`#Headers`),d=l.length===0||l.includes(`#All`)||l.includes(`#Data`),f=u?i.top:i.top+1,p=d?i.bottom:i.top;return new E(r,f,a,p,o)}function pO(e,t,n){return new at([],{kind:`call`,name:e.name,written:t,args:[]},n,e.name)}function mO(e){return e.cells.map(e=>{let t=e.column?e.sheet.tables.flatMap(e=>e.columns.map(t=>({table:e.name,col:t}))).find(t=>t.col.formula===e.column):void 0;return{sheet:e.sheet.index,row:e.row,col:e.col,...e.input===void 0?{}:{input:e.input},...t?{column:{table:t.table,name:t.col.name}}:{},...e.key===void 0?{}:{key:e.key},...e.record?{record:{table:e.record.table.name,index:e.record.index,fields:e.record.fields}}:{}}})}function hO(e,t,n,r){r&&e.respec(r);let i=[];for(let t of n){let n=e.sheets[t.sheet];if(!n)continue;let{row:r,col:a}=t,o=ql(r,a);if(t.key===null?n.keys.delete(o):t.key!==void 0&&n.keys.set(o,t.key),t.record){let n=e.table(t.record.table);n&&(n.records[t.record.index]=t.record.fields)}n.implied.delete(o);let s=t.column?e.table(t.column.table)?.columns.find(e=>e.name===t.column?.name)?.formula:void 0;if(s){i.push({sheet:n,row:r,col:a,slot:new M(s,n,r,a)});continue}let c=Xe(t.input??``);c.format!==void 0&&n.implied.set(o,c.format),i.push({sheet:n,row:r,col:a,slot:c.formula===void 0?c.value??void 0:new M(new Ul(c.formula,r,a,{file:``}),n,r,a)})}t.change(i)}function gO(e,t={}){let n=new Map(e.rows),r=mu({file:e.file,rows:e=>n.get(e),generated:e.generated,theme:e.theme});return e.scenario!==void 0&&Nu(r,e.scenario),{workbook:r,calc:new sO(r,{random:YD(e.seed),...t}).calculate()}}var _O=class{model;generation=-1;handle(e){if(e.kind===`open`)this.model=gO(e,{report:!0}),this.generation=e.generation;else{if(e.generation!==this.generation||!this.model)return;e.kind===`cells`?hO(this.model.workbook,this.model.calc,e.cells,e.file):this.model.calc.recalculate()}return{generation:this.generation,computed:this.model.calc.takeComputed()}}},vO=/\.(?:png|jpe?g|gif|webp|bmp|svg)$/iu,yO=e=>vO.test(e),bO=e=>(typeof e==`object`?e.height:void 0)??60;function xO(e){return Object.values(e.spec.columns??{}).some(e=>e.files!==void 0)||e.tables.some(e=>e.columns.some(e=>e.spec?.files))}function SO(e,t){if(!xO(e))return[];let n=[],r=(r,i,a)=>{let o=t.value(e,r,i);if(typeof o!=`string`)return;let s=Zl(o,a);s.length>0&&n.push({row:r,col:i,paths:s,column:a})},i=(t,n)=>e.tableAt(t,n)!==void 0;for(let[t,n]of Object.entries(e.spec.columns??{})){let a=we(t);if(a===void 0||n.files===void 0)continue;let[o,s]=e.span(a,0,e.lastRow);for(let e=o;e<=s;e++)i(e,a)||r(e,a,n.files)}for(let t of e.tables)for(let n of t.columns){let i=t.at.col+n.index,a=n.spec?.files??e.spec.columns?.[Ce(i)]?.files;if(a!==void 0)for(let e=t.data.top;e<=t.data.bottom;e++)r(e,i,a)}return n}function CO(e,t,n){let r=e.notes?.[Te({row:t,col:n})];if(r!==void 0)return typeof r==`string`?{text:r}:{text:r.text,...r.author?{author:r.author}:{}}}var wO=new WeakMap;function TO(e){let t=wO.get(e);return t||(t=Object.entries(e).flatMap(([e,t])=>{let n=x(e);return n?[{range:e,to:t,at:n}]:[]}),wO.set(e,t)),t}function EO(e,t,n){if(e.links){for(let{range:r,to:i,at:a}of TO(e.links))if(t>=a.top&&t<=a.bottom&&n>=a.left&&n<=a.right)return{range:r,to:i}}}var DO={color:`#0563C1`,underline:!0};function OO(e){return/^(?:https?:|mailto:|#)/iu.test(e)}function kO(e,t,n,r){let i=t.mergeAt(n,r),a=i?.top??n,o=i?.left??r,s=EO(t.spec,a,o);if(s)return OO(s.to)?s:void 0;let c=t.at(a,o);if(!(c instanceof M))return;let l=e.hyperlinkTarget(c);if(typeof l!=`string`)return;let u=l.trim();return OO(u)?{to:u}:void 0}function AO(e){return{color:e.color??DO.color,underline:e.underline??DO.underline}}var jO={TableStyleDark1:{whole:{color:`t0`,fill:`t1:0.4499954222235786`},header:{bold:!0,color:`t0`,fill:`t1`,border:{bottom:{style:`medium`,color:`t0`}}},first:{bold:!0,color:`t0`,fill:`t1:0.249977111117893`,border:{right:{style:`medium`,color:`t0`}}},last:{bold:!0,color:`t0`,fill:`t1:0.249977111117893`,border:{left:{style:`medium`,color:`t0`}}},stripe:{fill:`t1:0.249977111117893`},column:{fill:`t1:0.249977111117893`}},TableStyleDark2:{whole:{color:`t0`,fill:`t4`},header:{bold:!0,color:`t0`,fill:`t1`,border:{bottom:{style:`medium`,color:`t0`}}},first:{bold:!0,color:`t0`,fill:`t4:-0.249977111117893`,border:{right:{style:`medium`,color:`t0`}}},last:{bold:!0,color:`t0`,fill:`t4:-0.249977111117893`,border:{left:{style:`medium`,color:`t0`}}},stripe:{fill:`t4:-0.249977111117893`},column:{fill:`t4:-0.249977111117893`}},TableStyleDark3:{whole:{color:`t0`,fill:`t5`},header:{bold:!0,color:`t0`,fill:`t1`,border:{bottom:{style:`medium`,color:`t0`}}},first:{bold:!0,color:`t0`,fill:`t5:-0.249977111117893`,border:{right:{style:`medium`,color:`t0`}}},last:{bold:!0,color:`t0`,fill:`t5:-0.249977111117893`,border:{left:{style:`medium`,color:`t0`}}},stripe:{fill:`t5:-0.249977111117893`},column:{fill:`t5:-0.249977111117893`}},TableStyleDark4:{whole:{color:`t0`,fill:`t6`},header:{bold:!0,color:`t0`,fill:`t1`,border:{bottom:{style:`medium`,color:`t0`}}},first:{bold:!0,color:`t0`,fill:`t6:-0.249977111117893`,border:{right:{style:`medium`,color:`t0`}}},last:{bold:!0,color:`t0`,fill:`t6:-0.249977111117893`,border:{left:{style:`medium`,color:`t0`}}},stripe:{fill:`t6:-0.249977111117893`},column:{fill:`t6:-0.249977111117893`}},TableStyleDark5:{whole:{color:`t0`,fill:`t7`},header:{bold:!0,color:`t0`,fill:`t1`,border:{bottom:{style:`medium`,color:`t0`}}},first:{bold:!0,color:`t0`,fill:`t7:-0.249977111117893`,border:{right:{style:`medium`,color:`t0`}}},last:{bold:!0,color:`t0`,fill:`t7:-0.249977111117893`,border:{left:{style:`medium`,color:`t0`}}},stripe:{fill:`t7:-0.249977111117893`},column:{fill:`t7:-0.249977111117893`}},TableStyleDark6:{whole:{color:`t0`,fill:`t8`},header:{bold:!0,color:`t0`,fill:`t1`,border:{bottom:{style:`medium`,color:`t0`}}},first:{bold:!0,color:`t0`,fill:`t8:-0.249977111117893`,border:{right:{style:`medium`,color:`t0`}}},last:{bold:!0,color:`t0`,fill:`t8:-0.249977111117893`,border:{left:{style:`medium`,color:`t0`}}},stripe:{fill:`t8:-0.249977111117893`},column:{fill:`t8:-0.249977111117893`}},TableStyleDark7:{whole:{color:`t0`,fill:`t9`},header:{bold:!0,color:`t0`,fill:`t1`,border:{bottom:{style:`medium`,color:`t0`}}},first:{bold:!0,color:`t0`,fill:`t9:-0.249977111117893`,border:{right:{style:`medium`,color:`t0`}}},last:{bold:!0,color:`t0`,fill:`t9:-0.249977111117893`,border:{left:{style:`medium`,color:`t0`}}},stripe:{fill:`t9:-0.249977111117893`},column:{fill:`t9:-0.249977111117893`}},TableStyleDark8:{whole:{fill:`t0:-0.1499984740745262`},header:{color:`t0`,fill:`t1`},first:{bold:!0,color:`t1`},last:{bold:!0,color:`t1`},stripe:{fill:`t0:-0.3499862666707358`},column:{fill:`t0:-0.3499862666707358`}},TableStyleDark9:{whole:{fill:`t4:0.7999816888943144`},header:{color:`t0`,fill:`t5`},first:{bold:!0,color:`t1`},last:{bold:!0,color:`t1`},stripe:{fill:`t4:0.5999938962981048`},column:{fill:`t4:0.5999938962981048`}},TableStyleDark10:{whole:{fill:`t6:0.7999816888943144`},header:{color:`t0`,fill:`t7`},first:{bold:!0,color:`t1`},last:{bold:!0,color:`t1`},stripe:{fill:`t6:0.5999938962981048`},column:{fill:`t6:0.5999938962981048`}},TableStyleDark11:{whole:{fill:`t8:0.7999816888943144`},header:{color:`t0`,fill:`t9`},first:{bold:!0,color:`t1`},last:{bold:!0,color:`t1`},stripe:{fill:`t8:0.5999938962981048`},column:{fill:`t8:0.5999938962981048`}},TableStyleLight1:{whole:{color:`t1`,border:{top:{style:`thin`,color:`t1`},bottom:{style:`thin`,color:`t1`}}},header:{bold:!0,color:`t1`,border:{bottom:{style:`thin`,color:`t1`}}},first:{bold:!0,color:`t1`},last:{bold:!0,color:`t1`},stripe:{fill:`t0:-0.1499984740745262`},column:{fill:`t0:-0.1499984740745262`}},TableStyleLight2:{whole:{color:`t4:-0.249977111117893`,border:{top:{style:`thin`,color:`t4`},bottom:{style:`thin`,color:`t4`}}},header:{bold:!0,color:`t4:-0.249977111117893`,border:{bottom:{style:`thin`,color:`t4`}}},first:{bold:!0,color:`t4:-0.249977111117893`},last:{bold:!0,color:`t4:-0.249977111117893`},stripe:{fill:`t4:0.7999816888943144`},column:{fill:`t4:0.7999816888943144`}},TableStyleLight3:{whole:{color:`t5:-0.249977111117893`,border:{top:{style:`thin`,color:`t5`},bottom:{style:`thin`,color:`t5`}}},header:{bold:!0,color:`t5:-0.249977111117893`,border:{bottom:{style:`thin`,color:`t5`}}},first:{bold:!0,color:`t5:-0.249977111117893`},last:{bold:!0,color:`t5:-0.249977111117893`},stripe:{fill:`t5:0.7999816888943144`},column:{fill:`t5:0.7999816888943144`}},TableStyleLight4:{whole:{color:`t6:-0.249977111117893`,border:{top:{style:`thin`,color:`t6`},bottom:{style:`thin`,color:`t6`}}},header:{bold:!0,color:`t6:-0.249977111117893`,border:{bottom:{style:`thin`,color:`t6`}}},first:{bold:!0,color:`t6:-0.249977111117893`},last:{bold:!0,color:`t6:-0.249977111117893`},stripe:{fill:`t6:0.7999816888943144`},column:{fill:`t6:0.7999816888943144`}},TableStyleLight5:{whole:{color:`t7:-0.249977111117893`,border:{top:{style:`thin`,color:`t7`},bottom:{style:`thin`,color:`t7`}}},header:{bold:!0,color:`t7:-0.249977111117893`,border:{bottom:{style:`thin`,color:`t7`}}},first:{bold:!0,color:`t7:-0.249977111117893`},last:{bold:!0,color:`t7:-0.249977111117893`},stripe:{fill:`t7:0.7999816888943144`},column:{fill:`t7:0.7999816888943144`}},TableStyleLight6:{whole:{color:`t8:-0.249977111117893`,border:{top:{style:`thin`,color:`t8`},bottom:{style:`thin`,color:`t8`}}},header:{bold:!0,color:`t8:-0.249977111117893`,border:{bottom:{style:`thin`,color:`t8`}}},first:{bold:!0,color:`t8:-0.249977111117893`},last:{bold:!0,color:`t8:-0.249977111117893`},stripe:{fill:`t8:0.7999816888943144`},column:{fill:`t8:0.7999816888943144`}},TableStyleLight7:{whole:{color:`t9:-0.249977111117893`,border:{top:{style:`thin`,color:`t9`},bottom:{style:`thin`,color:`t9`}}},header:{bold:!0,color:`t9:-0.249977111117893`,border:{bottom:{style:`thin`,color:`t9`}}},first:{bold:!0,color:`t9:-0.249977111117893`},last:{bold:!0,color:`t9:-0.249977111117893`},stripe:{fill:`t9:0.7999816888943144`},column:{fill:`t9:0.7999816888943144`}},TableStyleLight8:{whole:{color:`t1`,border:{left:{style:`thin`,color:`t1`},right:{style:`thin`,color:`t1`},top:{style:`thin`,color:`t1`},bottom:{style:`thin`,color:`t1`}}},header:{bold:!0,color:`t0`,fill:`t1`},first:{bold:!0,color:`t1`},last:{bold:!0,color:`t1`},stripe:{border:{top:{style:`thin`,color:`t1`}}},stripe2:{border:{top:{style:`thin`,color:`t1`}}},column:{border:{left:{style:`thin`,color:`t1`}}},column2:{border:{left:{style:`thin`,color:`t1`}}}},TableStyleLight9:{whole:{color:`t1`,border:{left:{style:`thin`,color:`t4`},right:{style:`thin`,color:`t4`},top:{style:`thin`,color:`t4`},bottom:{style:`thin`,color:`t4`}}},header:{bold:!0,color:`t0`,fill:`t4`},first:{bold:!0,color:`t1`},last:{bold:!0,color:`t1`},stripe:{border:{top:{style:`thin`,color:`t4`}}},stripe2:{border:{top:{style:`thin`,color:`t4`}}},column:{border:{left:{style:`thin`,color:`t4`}}},column2:{border:{left:{style:`thin`,color:`t4`}}}},TableStyleLight10:{whole:{color:`t1`,border:{left:{style:`thin`,color:`t5`},right:{style:`thin`,color:`t5`},top:{style:`thin`,color:`t5`},bottom:{style:`thin`,color:`t5`}}},header:{bold:!0,color:`t0`,fill:`t5`},first:{bold:!0,color:`t1`},last:{bold:!0,color:`t1`},stripe:{border:{top:{style:`thin`,color:`t5`}}},stripe2:{border:{top:{style:`thin`,color:`t5`}}},column:{border:{left:{style:`thin`,color:`t5`}}},column2:{border:{left:{style:`thin`,color:`t5`}}}},TableStyleLight11:{whole:{color:`t1`,border:{left:{style:`thin`,color:`t6`},right:{style:`thin`,color:`t6`},top:{style:`thin`,color:`t6`},bottom:{style:`thin`,color:`t6`}}},header:{bold:!0,color:`t0`,fill:`t6`},first:{bold:!0,color:`t1`},last:{bold:!0,color:`t1`},stripe:{border:{top:{style:`thin`,color:`t6`}}},stripe2:{border:{top:{style:`thin`,color:`t6`}}},column:{border:{left:{style:`thin`,color:`t6`}}},column2:{border:{left:{style:`thin`,color:`t6`}}}},TableStyleLight12:{whole:{color:`t1`,border:{left:{style:`thin`,color:`t7`},right:{style:`thin`,color:`t7`},top:{style:`thin`,color:`t7`},bottom:{style:`thin`,color:`t7`}}},header:{bold:!0,color:`t0`,fill:`t7`},first:{bold:!0,color:`t1`},last:{bold:!0,color:`t1`},stripe:{border:{top:{style:`thin`,color:`t7`}}},stripe2:{border:{top:{style:`thin`,color:`t7`}}},column:{border:{left:{style:`thin`,color:`t7`}}},column2:{border:{left:{style:`thin`,color:`t7`}}}},TableStyleLight13:{whole:{color:`t1`,border:{left:{style:`thin`,color:`t8`},right:{style:`thin`,color:`t8`},top:{style:`thin`,color:`t8`},bottom:{style:`thin`,color:`t8`}}},header:{bold:!0,color:`t0`,fill:`t8`},first:{bold:!0,color:`t1`},last:{bold:!0,color:`t1`},stripe:{border:{top:{style:`thin`,color:`t8`}}},stripe2:{border:{top:{style:`thin`,color:`t8`}}},column:{border:{left:{style:`thin`,color:`t8`}}},column2:{border:{left:{style:`thin`,color:`t8`}}}},TableStyleLight14:{whole:{color:`t1`,border:{left:{style:`thin`,color:`t9`},right:{style:`thin`,color:`t9`},top:{style:`thin`,color:`t9`},bottom:{style:`thin`,color:`t9`}}},header:{bold:!0,color:`t0`,fill:`t9`},first:{bold:!0,color:`t1`},last:{bold:!0,color:`t1`},stripe:{border:{top:{style:`thin`,color:`t9`}}},stripe2:{border:{top:{style:`thin`,color:`t9`}}},column:{border:{left:{style:`thin`,color:`t9`}}},column2:{border:{left:{style:`thin`,color:`t9`}}}},TableStyleLight15:{whole:{color:`t1`,border:{left:{style:`thin`,color:`t1`},right:{style:`thin`,color:`t1`},top:{style:`thin`,color:`t1`},bottom:{style:`thin`,color:`t1`},horizontal:{style:`thin`,color:`t1`},vertical:{style:`thin`,color:`t1`}}},header:{bold:!0,color:`t1`,border:{bottom:{style:`medium`,color:`t1`}}},first:{bold:!0,color:`t1`},last:{bold:!0,color:`t1`},stripe:{fill:`t0:-0.1499984740745262`},column:{fill:`t0:-0.1499984740745262`}},TableStyleLight16:{whole:{color:`t1`,border:{left:{style:`thin`,color:`t4`},right:{style:`thin`,color:`t4`},top:{style:`thin`,color:`t4`},bottom:{style:`thin`,color:`t4`},horizontal:{style:`thin`,color:`t4`},vertical:{style:`thin`,color:`t4`}}},header:{bold:!0,color:`t1`,border:{bottom:{style:`medium`,color:`t4`}}},first:{bold:!0,color:`t1`},last:{bold:!0,color:`t1`},stripe:{fill:`t4:0.7999816888943144`},column:{fill:`t4:0.7999816888943144`}},TableStyleLight17:{whole:{color:`t1`,border:{left:{style:`thin`,color:`t5`},right:{style:`thin`,color:`t5`},top:{style:`thin`,color:`t5`},bottom:{style:`thin`,color:`t5`},horizontal:{style:`thin`,color:`t5`},vertical:{style:`thin`,color:`t5`}}},header:{bold:!0,color:`t1`,border:{bottom:{style:`medium`,color:`t5`}}},first:{bold:!0,color:`t1`},last:{bold:!0,color:`t1`},stripe:{fill:`t5:0.7999816888943144`},column:{fill:`t5:0.7999816888943144`}},TableStyleLight18:{whole:{color:`t1`,border:{left:{style:`thin`,color:`t6`},right:{style:`thin`,color:`t6`},top:{style:`thin`,color:`t6`},bottom:{style:`thin`,color:`t6`},horizontal:{style:`thin`,color:`t6`},vertical:{style:`thin`,color:`t6`}}},header:{bold:!0,color:`t1`,border:{bottom:{style:`medium`,color:`t6`}}},first:{bold:!0,color:`t1`},last:{bold:!0,color:`t1`},stripe:{fill:`t6:0.7999816888943144`},column:{fill:`t6:0.7999816888943144`}},TableStyleLight19:{whole:{color:`t1`,border:{left:{style:`thin`,color:`t7`},right:{style:`thin`,color:`t7`},top:{style:`thin`,color:`t7`},bottom:{style:`thin`,color:`t7`},horizontal:{style:`thin`,color:`t7`},vertical:{style:`thin`,color:`t7`}}},header:{bold:!0,color:`t1`,border:{bottom:{style:`medium`,color:`t7`}}},first:{bold:!0,color:`t1`},last:{bold:!0,color:`t1`},stripe:{fill:`t7:0.7999816888943144`},column:{fill:`t7:0.7999816888943144`}},TableStyleLight20:{whole:{color:`t1`,border:{left:{style:`thin`,color:`t8`},right:{style:`thin`,color:`t8`},top:{style:`thin`,color:`t8`},bottom:{style:`thin`,color:`t8`},horizontal:{style:`thin`,color:`t8`},vertical:{style:`thin`,color:`t8`}}},header:{bold:!0,color:`t1`,border:{bottom:{style:`medium`,color:`t8`}}},first:{bold:!0,color:`t1`},last:{bold:!0,color:`t1`},stripe:{fill:`t8:0.7999816888943144`},column:{fill:`t8:0.7999816888943144`}},TableStyleLight21:{whole:{color:`t1`,border:{left:{style:`thin`,color:`t9`},right:{style:`thin`,color:`t9`},top:{style:`thin`,color:`t9`},bottom:{style:`thin`,color:`t9`},horizontal:{style:`thin`,color:`t9`},vertical:{style:`thin`,color:`t9`}}},header:{bold:!0,color:`t1`,border:{bottom:{style:`medium`,color:`t9`}}},first:{bold:!0,color:`t1`},last:{bold:!0,color:`t1`},stripe:{fill:`t9:0.7999816888943144`},column:{fill:`t9:0.7999816888943144`}},TableStyleMedium1:{whole:{color:`t1`,border:{left:{style:`thin`,color:`t1`},right:{style:`thin`,color:`t1`},top:{style:`thin`,color:`t1`},bottom:{style:`thin`,color:`t1`},horizontal:{style:`thin`,color:`t1`}}},header:{bold:!0,color:`t0`,fill:`t1`},first:{bold:!0,color:`t1`},last:{bold:!0,color:`t1`},stripe:{fill:`t0:-0.1499984740745262`},column:{fill:`t0:-0.1499984740745262`}},TableStyleMedium2:{whole:{color:`t1`,border:{left:{style:`thin`,color:`t4:0.3999755851924192`},right:{style:`thin`,color:`t4:0.3999755851924192`},top:{style:`thin`,color:`t4:0.3999755851924192`},bottom:{style:`thin`,color:`t4:0.3999755851924192`},horizontal:{style:`thin`,color:`t4:0.3999755851924192`}}},header:{bold:!0,color:`t0`,fill:`t4`},first:{bold:!0,color:`t1`},last:{bold:!0,color:`t1`},stripe:{fill:`t4:0.7999816888943144`},column:{fill:`t4:0.7999816888943144`}},TableStyleMedium3:{whole:{color:`t1`,border:{left:{style:`thin`,color:`t5:0.3999755851924192`},right:{style:`thin`,color:`t5:0.3999755851924192`},top:{style:`thin`,color:`t5:0.3999755851924192`},bottom:{style:`thin`,color:`t5:0.3999755851924192`},horizontal:{style:`thin`,color:`t5:0.3999755851924192`}}},header:{bold:!0,color:`t0`,fill:`t5`},first:{bold:!0,color:`t1`},last:{bold:!0,color:`t1`},stripe:{fill:`t5:0.7999816888943144`},column:{fill:`t5:0.7999816888943144`}},TableStyleMedium4:{whole:{color:`t1`,border:{left:{style:`thin`,color:`t6:0.3999755851924192`},right:{style:`thin`,color:`t6:0.3999755851924192`},top:{style:`thin`,color:`t6:0.3999755851924192`},bottom:{style:`thin`,color:`t6:0.3999755851924192`},horizontal:{style:`thin`,color:`t6:0.3999755851924192`}}},header:{bold:!0,color:`t0`,fill:`t6`},first:{bold:!0,color:`t1`},last:{bold:!0,color:`t1`},stripe:{fill:`t6:0.7999816888943144`},column:{fill:`t6:0.7999816888943144`}},TableStyleMedium5:{whole:{color:`t1`,border:{left:{style:`thin`,color:`t7:0.3999755851924192`},right:{style:`thin`,color:`t7:0.3999755851924192`},top:{style:`thin`,color:`t7:0.3999755851924192`},bottom:{style:`thin`,color:`t7:0.3999755851924192`},horizontal:{style:`thin`,color:`t7:0.3999755851924192`}}},header:{bold:!0,color:`t0`,fill:`t7`},first:{bold:!0,color:`t1`},last:{bold:!0,color:`t1`},stripe:{fill:`t7:0.7999816888943144`},column:{fill:`t7:0.7999816888943144`}},TableStyleMedium6:{whole:{color:`t1`,border:{left:{style:`thin`,color:`t8:0.3999755851924192`},right:{style:`thin`,color:`t8:0.3999755851924192`},top:{style:`thin`,color:`t8:0.3999755851924192`},bottom:{style:`thin`,color:`t8:0.3999755851924192`},horizontal:{style:`thin`,color:`t8:0.3999755851924192`}}},header:{bold:!0,color:`t0`,fill:`t8`},first:{bold:!0,color:`t1`},last:{bold:!0,color:`t1`},stripe:{fill:`t8:0.7999816888943144`},column:{fill:`t8:0.7999816888943144`}},TableStyleMedium7:{whole:{color:`t1`,border:{left:{style:`thin`,color:`t9:0.3999755851924192`},right:{style:`thin`,color:`t9:0.3999755851924192`},top:{style:`thin`,color:`t9:0.3999755851924192`},bottom:{style:`thin`,color:`t9:0.3999755851924192`},horizontal:{style:`thin`,color:`t9:0.3999755851924192`}}},header:{bold:!0,color:`t0`,fill:`t9`},first:{bold:!0,color:`t1`},last:{bold:!0,color:`t1`},stripe:{fill:`t9:0.7999816888943144`},column:{fill:`t9:0.7999816888943144`}},TableStyleMedium8:{whole:{color:`t1`,fill:`t0:-0.1499984740745262`,border:{horizontal:{style:`thin`,color:`t0`},vertical:{style:`thin`,color:`t0`}}},header:{bold:!0,color:`t0`,fill:`t1`,border:{bottom:{style:`thick`,color:`t0`}}},first:{bold:!0,color:`t0`,fill:`t1`},last:{bold:!0,color:`t0`,fill:`t1`},stripe:{fill:`t0:-0.3499862666707358`},column:{fill:`t0:-0.3499862666707358`}},TableStyleMedium9:{whole:{color:`t1`,fill:`t4:0.7999816888943144`,border:{horizontal:{style:`thin`,color:`t0`},vertical:{style:`thin`,color:`t0`}}},header:{bold:!0,color:`t0`,fill:`t4`,border:{bottom:{style:`thick`,color:`t0`}}},first:{bold:!0,color:`t0`,fill:`t4`},last:{bold:!0,color:`t0`,fill:`t4`},stripe:{fill:`t4:0.5999938962981048`},column:{fill:`t4:0.5999938962981048`}},TableStyleMedium10:{whole:{color:`t1`,fill:`t5:0.7999816888943144`,border:{horizontal:{style:`thin`,color:`t0`},vertical:{style:`thin`,color:`t0`}}},header:{bold:!0,color:`t0`,fill:`t5`,border:{bottom:{style:`thick`,color:`t0`}}},first:{bold:!0,color:`t0`,fill:`t5`},last:{bold:!0,color:`t0`,fill:`t5`},stripe:{fill:`t5:0.5999938962981048`},column:{fill:`t5:0.5999938962981048`}},TableStyleMedium11:{whole:{color:`t1`,fill:`t6:0.7999816888943144`,border:{horizontal:{style:`thin`,color:`t0`},vertical:{style:`thin`,color:`t0`}}},header:{bold:!0,color:`t0`,fill:`t6`,border:{bottom:{style:`thick`,color:`t0`}}},first:{bold:!0,color:`t0`,fill:`t6`},last:{bold:!0,color:`t0`,fill:`t6`},stripe:{fill:`t6:0.5999938962981048`},column:{fill:`t6:0.5999938962981048`}},TableStyleMedium12:{whole:{color:`t1`,fill:`t7:0.7999816888943144`,border:{horizontal:{style:`thin`,color:`t0`},vertical:{style:`thin`,color:`t0`}}},header:{bold:!0,color:`t0`,fill:`t7`,border:{bottom:{style:`thick`,color:`t0`}}},first:{bold:!0,color:`t0`,fill:`t7`},last:{bold:!0,color:`t0`,fill:`t7`},stripe:{fill:`t7:0.5999938962981048`},column:{fill:`t7:0.5999938962981048`}},TableStyleMedium13:{whole:{color:`t1`,fill:`t8:0.7999816888943144`,border:{horizontal:{style:`thin`,color:`t0`},vertical:{style:`thin`,color:`t0`}}},header:{bold:!0,color:`t0`,fill:`t8`,border:{bottom:{style:`thick`,color:`t0`}}},first:{bold:!0,color:`t0`,fill:`t8`},last:{bold:!0,color:`t0`,fill:`t8`},stripe:{fill:`t8:0.5999938962981048`},column:{fill:`t8:0.5999938962981048`}},TableStyleMedium14:{whole:{color:`t1`,fill:`t9:0.7999816888943144`,border:{horizontal:{style:`thin`,color:`t0`},vertical:{style:`thin`,color:`t0`}}},header:{bold:!0,color:`t0`,fill:`t9`,border:{bottom:{style:`thick`,color:`t0`}}},first:{bold:!0,color:`t0`,fill:`t9`},last:{bold:!0,color:`t0`,fill:`t9`},stripe:{fill:`t9:0.5999938962981048`},column:{fill:`t9:0.5999938962981048`}},TableStyleMedium15:{whole:{color:`t1`,border:{left:{style:`thin`,color:`t1`},right:{style:`thin`,color:`t1`},top:{style:`medium`,color:`t1`},bottom:{style:`medium`,color:`t1`},horizontal:{style:`thin`,color:`t1`},vertical:{style:`thin`,color:`t1`}}},header:{bold:!0,color:`t0`,fill:`t1`,border:{bottom:{style:`medium`,color:`t1`}}},first:{bold:!0,color:`t0`,fill:`t1`},last:{bold:!0,color:`t0`,fill:`t1`},stripe:{fill:`t0:-0.1499984740745262`},column:{fill:`t0:-0.1499984740745262`}},TableStyleMedium16:{whole:{color:`t1`,border:{top:{style:`medium`,color:`t1`},bottom:{style:`medium`,color:`t1`}}},header:{bold:!0,color:`t0`,fill:`t4`,border:{bottom:{style:`medium`,color:`t1`}}},first:{bold:!0,color:`t0`,fill:`t4`},last:{bold:!0,color:`t0`,fill:`t4`},stripe:{fill:`t0:-0.1499984740745262`},column:{fill:`t0:-0.1499984740745262`}},TableStyleMedium17:{whole:{color:`t1`,border:{top:{style:`medium`,color:`t1`},bottom:{style:`medium`,color:`t1`}}},header:{bold:!0,color:`t0`,fill:`t5`,border:{bottom:{style:`medium`,color:`t1`}}},first:{bold:!0,color:`t0`,fill:`t5`},last:{bold:!0,color:`t0`,fill:`t5`},stripe:{fill:`t0:-0.1499984740745262`},column:{fill:`t0:-0.1499984740745262`}},TableStyleMedium18:{whole:{color:`t1`,border:{top:{style:`medium`,color:`t1`},bottom:{style:`medium`,color:`t1`}}},header:{bold:!0,color:`t0`,fill:`t6`,border:{bottom:{style:`medium`,color:`t1`}}},first:{bold:!0,color:`t0`,fill:`t6`},last:{bold:!0,color:`t0`,fill:`t6`},stripe:{fill:`t0:-0.1499984740745262`},column:{fill:`t0:-0.1499984740745262`}},TableStyleMedium19:{whole:{color:`t1`,border:{top:{style:`medium`,color:`t1`},bottom:{style:`medium`,color:`t1`}}},header:{bold:!0,color:`t0`,fill:`t7`,border:{bottom:{style:`medium`,color:`t1`}}},first:{bold:!0,color:`t0`,fill:`t7`},last:{bold:!0,color:`t0`,fill:`t7`},stripe:{fill:`t0:-0.1499984740745262`},column:{fill:`t0:-0.1499984740745262`}},TableStyleMedium20:{whole:{color:`t1`,border:{top:{style:`medium`,color:`t1`},bottom:{style:`medium`,color:`t1`}}},header:{bold:!0,color:`t0`,fill:`t8`,border:{bottom:{style:`medium`,color:`t1`}}},first:{bold:!0,color:`t0`,fill:`t8`},last:{bold:!0,color:`t0`,fill:`t8`},stripe:{fill:`t0:-0.1499984740745262`},column:{fill:`t0:-0.1499984740745262`}},TableStyleMedium21:{whole:{color:`t1`,border:{top:{style:`medium`,color:`t1`},bottom:{style:`medium`,color:`t1`}}},header:{bold:!0,color:`t0`,fill:`t9`,border:{bottom:{style:`medium`,color:`t1`}}},first:{bold:!0,color:`t0`,fill:`t9`},last:{bold:!0,color:`t0`,fill:`t9`},stripe:{fill:`t0:-0.1499984740745262`},column:{fill:`t0:-0.1499984740745262`}},TableStyleMedium22:{whole:{color:`t1`,fill:`t0:-0.1499984740745262`,border:{left:{style:`thin`,color:`t1`},right:{style:`thin`,color:`t1`},top:{style:`thin`,color:`t1`},bottom:{style:`thin`,color:`t1`},horizontal:{style:`thin`,color:`t1`},vertical:{style:`thin`,color:`t1`}}},header:{bold:!0,color:`t1`},first:{bold:!0,color:`t1`},last:{bold:!0,color:`t1`},stripe:{fill:`t0:-0.3499862666707358`},column:{fill:`t0:-0.3499862666707358`}},TableStyleMedium23:{whole:{color:`t1`,fill:`t4:0.7999816888943144`,border:{left:{style:`thin`,color:`t4:0.3999755851924192`},right:{style:`thin`,color:`t4:0.3999755851924192`},top:{style:`thin`,color:`t4:0.3999755851924192`},bottom:{style:`thin`,color:`t4:0.3999755851924192`},horizontal:{style:`thin`,color:`t4:0.3999755851924192`},vertical:{style:`thin`,color:`t4:0.3999755851924192`}}},header:{bold:!0,color:`t1`},first:{bold:!0,color:`t1`},last:{bold:!0,color:`t1`},stripe:{fill:`t4:0.5999938962981048`},column:{fill:`t4:0.5999938962981048`}},TableStyleMedium24:{whole:{color:`t1`,fill:`t5:0.7999816888943144`,border:{left:{style:`thin`,color:`t5:0.3999755851924192`},right:{style:`thin`,color:`t5:0.3999755851924192`},top:{style:`thin`,color:`t5:0.3999755851924192`},bottom:{style:`thin`,color:`t5:0.3999755851924192`},horizontal:{style:`thin`,color:`t5:0.3999755851924192`},vertical:{style:`thin`,color:`t5:0.3999755851924192`}}},header:{bold:!0,color:`t1`},first:{bold:!0,color:`t1`},last:{bold:!0,color:`t1`},stripe:{fill:`t5:0.5999938962981048`},column:{fill:`t5:0.5999938962981048`}},TableStyleMedium25:{whole:{color:`t1`,fill:`t6:0.7999816888943144`,border:{left:{style:`thin`,color:`t6:0.3999755851924192`},right:{style:`thin`,color:`t6:0.3999755851924192`},top:{style:`thin`,color:`t6:0.3999755851924192`},bottom:{style:`thin`,color:`t6:0.3999755851924192`},horizontal:{style:`thin`,color:`t6:0.3999755851924192`},vertical:{style:`thin`,color:`t6:0.3999755851924192`}}},header:{bold:!0,color:`t1`},first:{bold:!0,color:`t1`},last:{bold:!0,color:`t1`},stripe:{fill:`t6:0.5999938962981048`},column:{fill:`t6:0.5999938962981048`}},TableStyleMedium26:{whole:{color:`t1`,fill:`t7:0.7999816888943144`,border:{left:{style:`thin`,color:`t7:0.3999755851924192`},right:{style:`thin`,color:`t7:0.3999755851924192`},top:{style:`thin`,color:`t7:0.3999755851924192`},bottom:{style:`thin`,color:`t7:0.3999755851924192`},horizontal:{style:`thin`,color:`t7:0.3999755851924192`},vertical:{style:`thin`,color:`t7:0.3999755851924192`}}},header:{bold:!0,color:`t1`},first:{bold:!0,color:`t1`},last:{bold:!0,color:`t1`},stripe:{fill:`t7:0.5999938962981048`},column:{fill:`t7:0.5999938962981048`}},TableStyleMedium27:{whole:{color:`t1`,fill:`t8:0.7999816888943144`,border:{left:{style:`thin`,color:`t8:0.3999755851924192`},right:{style:`thin`,color:`t8:0.3999755851924192`},top:{style:`thin`,color:`t8:0.3999755851924192`},bottom:{style:`thin`,color:`t8:0.3999755851924192`},horizontal:{style:`thin`,color:`t8:0.3999755851924192`},vertical:{style:`thin`,color:`t8:0.3999755851924192`}}},header:{bold:!0,color:`t1`},first:{bold:!0,color:`t1`},last:{bold:!0,color:`t1`},stripe:{fill:`t8:0.5999938962981048`},column:{fill:`t8:0.5999938962981048`}},TableStyleMedium28:{whole:{color:`t1`,fill:`t9:0.7999816888943144`,border:{left:{style:`thin`,color:`t9:0.3999755851924192`},right:{style:`thin`,color:`t9:0.3999755851924192`},top:{style:`thin`,color:`t9:0.3999755851924192`},bottom:{style:`thin`,color:`t9:0.3999755851924192`},horizontal:{style:`thin`,color:`t9:0.3999755851924192`},vertical:{style:`thin`,color:`t9:0.3999755851924192`}}},header:{bold:!0,color:`t1`},first:{bold:!0,color:`t1`},last:{bold:!0,color:`t1`},stripe:{fill:`t9:0.5999938962981048`},column:{fill:`t9:0.5999938962981048`}}},MO=new Map;function NO(e,t){let n=e=>{if(!e)return;let n={...e};if(e.color!==void 0&&(n.color=nl(e.color,t)),e.fill!==void 0&&(n.fill=nl(e.fill,t)),e.border){let r={};for(let[n,i]of Object.entries(e.border))r[n]={style:i.style,color:nl(i.color,t)};n.border=r}return n},r={};for(let[t,i]of Object.entries(e)){let e=n(i);e&&(r[t]=e)}return r}function PO(e){if(e.spec.style===`none`)return;let t=e.spec.style??`TableStyleMedium2`,n=jO[t];if(!n)return;let r=e.sheet.book?.themeOrder??FO,i=r.join(),a=MO.get(i);a||(a=new Map,MO.set(i,a));let o=a.get(t);return o||(o=NO(n,r),a.set(t,o)),o}var FO=el(u);function IO(e,t,n,r,i){let{area:a}=t,o={},s={},c=(e,t)=>{if(!e)return;e.bold!==void 0&&(o.bold=e.bold),e.color!==void 0&&(o.color=e.color),e.fill!==void 0&&(o.fill=e.fill);let n=e.border;if(!n)return;let r=(e,r)=>{let i=t[e]?n[e]:n[r];i&&(s[e]=i)};r(`left`,`vertical`),r(`right`,`vertical`),r(`top`,`horizontal`),r(`bottom`,`horizontal`)},l={left:r===a.left,right:r===a.right},u={top:n===a.top,bottom:n===a.bottom},d={left:!0,right:!0,...u},f=t.spec;return c(e.whole,{...l,...u}),f.banded_columns===!0&&c((r-a.left)%2==0?e.column:e.column2,d),i!==void 0&&f.banded_rows!==!1&&c(i%2==0?e.stripe:e.stripe2,{...l,top:!0,bottom:!0}),f.last_column===!0&&r===a.right&&c(e.last,d),f.first_column===!0&&r===a.left&&c(e.first,d),i===void 0&&c(e.header,{...l,top:!0,bottom:!0}),Object.keys(s).length>0&&(o.border=s),o}var LO=e=>fe(e.key)?String(e.key.value):void 0,RO=96,zO=e=>fe(e)&&!(typeof e.value==`string`&&/[\n\r]/u.test(e.value)),BO=e=>zO(e)||_e(e)&&e.items.every(zO),VO=new Set([``,`sheets[]`,`tables[]`,`cells`,`columns`,`rows`,`names`,`scenarios`]);function HO(e,t){if(_e(e)){for(let n of e.items)HO(n,`${t}[]`);e.flow=e.items.every(zO)}else if(de(e)){for(let t of e.items)HO(t.value,LO(t)??``);e.flow=!VO.has(t)&&e.items.length>0&&e.items.every(e=>BO(e.value)||de(e.value)&&e.value.flow===!0),e.flow&&new ge(e).toString({lineWidth:0,flowCollectionPadding:!0}).length>RO&&(e.flow=!1)}}var UO={lineWidth:0,flowCollectionPadding:!0};function WO(e){let t=new ge(e,{aliasDuplicateObjects:!1});HO(t.contents,``);let n=t.toString(UO);return n===`{}
|
|
21
|
-
`?``:GO(n)}function GO(e){let t=he(e,{uniqueKeys:!1});if(t.errors.length>0)return e;let n=[];KO(t.contents,t=>{if(!_e(t)||!t.flow||!t.range)return;let[r,i]=t.range;if(e[r]!==`[`||e[i-1]!==`]`)return;let a=e.slice(r+1,i-1),o=/^ [^[\]{}"'\n]* $/u.test(a);(o||a.startsWith(` {`))&&e[r+1]===` `&&n.push(r+1),(o||a.endsWith(`} `))&&e[i-2]===` `&&n.push(i-2)});let r=e;for(let e of[...new Set(n)].sort((e,t)=>t-e))r=r.slice(0,e)+r.slice(e+1);return r}function KO(e,t){if(t(e),de(e))for(let n of e.items)KO(n.key,t),KO(n.value,t);else if(_e(e))for(let n of e.items)KO(n,t)}var qO=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function JO(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((e,n)=>JO(e,t[n]));if(!qO(e)||!qO(t))return!1;let n=e=>Object.keys(e).filter(t=>e[t]!==void 0),r=n(e);return r.length===n(t).length&&r.every(n=>n in t&&JO(e[n],t[n]))}function YO(e,t,n,r,i){if(!JO(t,n)){if(de(e)&&!e.flow&&qO(t)&&qO(n))for(let a of new Set([...Object.keys(t),...Object.keys(n)])){let o=e.items.find(e=>LO(e)===a)?.value;JO(t[a],n[a])||YO(o,t[a],n[a],[...r,a],i)}else if(_e(e)&&!e.flow&&Array.isArray(t)&&Array.isArray(n)&&n.length>0){let a=Math.min(t.length,n.length),o=0;for(;o<a&&JO(t[o],n[o]);)o++;let s=0;for(;s<a-o&&JO(t[t.length-1-s],n[n.length-1-s]);)s++;let c=t.length-o-s,l=n.length-o-s,u=Math.min(c,l);for(let a=o;a<o+u;a++)YO(e.items[a],t[a],n[a],[...r,a],i);for(let e=o+c-1;e>=o+u;e--)i.push({path:[...r,e],value:void 0});for(let e=o+u;e<o+l;e++)i.push({path:[...r,e],value:n[e],...s>0?{insert:!0}:{}})}else i.push({path:r,value:n})}}var XO=(e,t)=>e.lastIndexOf(`
|
|
22
|
-
`,t-1)+1,ZO=(e,t)=>{let n=e.indexOf(`
|
|
23
|
-
`,t);return n<0?e.length:n+1},QO=(e,t)=>e.split(`
|
|
24
|
-
`).map((e,n)=>n===0||e===``?e:` `.repeat(t)+e).join(`
|
|
25
|
-
`);function $O(e,t,n,r){let i=new ge({[e]:t},{aliasDuplicateObjects:!1}),a=i.contents;HO(a,``);let o=a.items[0];return(de(r)||_e(r))&&(de(o?.value)||_e(o?.value))&&(o.value.flow=r.flow??!1),QO(GO(i.toString(UO).replace(/\n$/,``)),n)}function ek(e,t,n){let r=new ge([e],{aliasDuplicateObjects:!1}),i=r.contents;return HO(i,n),i.flow=!1,QO(GO(r.toString(UO).replace(/\n$/,``)),t)}function tk(e,t){let n=e.contents;for(let e of t.slice(0,-1))if(de(n)){if(n.flow)return;n=n.items.find(t=>LO(t)===String(e))?.value}else if(_e(n)){if(n.flow)return;n=n.items[Number(e)]}else return;return de(n)||_e(n)?n:void 0}function nk(e,t){let n=t.items[0]?.range?.[0];if(n===void 0)return;let r=XO(e,n),i=e.indexOf(`-`,r);return i>=0&&i<n?i-r:void 0}function rk(e,t){let n=he(e);if(n.errors.length>0)return;let{path:r,value:i}=t,a=r[r.length-1],o=tk(n,r);if(a===void 0||!o||o.flow)return;if(_e(o)){let n=Number(a),s=nk(e,o);if(s===void 0)return;let c=o.items[n];if(i===void 0){let t=c?.range?.[0],n=c?.range?.[1];return t===void 0||n===void 0?void 0:e.slice(0,XO(e,t))+e.slice(ZO(e,n-1))}if(t.insert===!0){let t=c?.range?.[0];if(t===void 0)return;let n=XO(e,t);return`${e.slice(0,n)}${` `.repeat(s)}${ek(i,s,String(r[r.length-2]))}\n${e.slice(n)}`}if(c)return;let l=o.items[o.items.length-1]?.range?.[1];if(l===void 0)return;let u=e.charAt(l-1)===`
|
|
26
|
-
`?l:ZO(e,l),d=u>0&&e.charAt(u-1)!==`
|
|
27
|
-
`?`
|
|
28
|
-
`:``;return`${e.slice(0,u)}${d}${` `.repeat(s)}${ek(i,s,String(r[r.length-2]??``))}\n${e.slice(u)}`}let s=String(a),c=o.items.find(e=>LO(e)===s),l=c?.key,u=c?.value??void 0,d=(o.items[0]?.key)?.range?.[0],f=d===void 0?2*(r.length-1):d-XO(e,d);if(c&&l?.range){let t=l.range[0],n=u?.range?u.range[1]:l.range[1];if(i===void 0)return e.slice(0,XO(e,t))+e.slice(ZO(e,n-1));let r=e.charAt(n-1)===`
|
|
29
|
-
`?`
|
|
30
|
-
`:``;return e.slice(0,t)+$O(s,i,f,u)+r+e.slice(n)}if(i===void 0)return e;let p=$O(s,i,f,void 0),m=o.items[o.items.length-1],h=(m?.value??m?.key)?.range?.[1];if(h===void 0)return`${e}${e===``||e.endsWith(`
|
|
31
|
-
`)?``:`
|
|
32
|
-
`}${` `.repeat(f)}${p}\n`;let g=e.charAt(h-1)===`
|
|
33
|
-
`?h:ZO(e,h),_=g>0&&e.charAt(g-1)!==`
|
|
34
|
-
`?`
|
|
35
|
-
`:``;return`${e.slice(0,g)}${_}${` `.repeat(f)}${p}\n${e.slice(g)}`}var ik=400;function ak(e,t){let n=he(e);if(n.errors.length>0||e.trim()!==``&&!de(n.contents)||e.trim()===``)return WO(t);let r=[];if(YO(n.contents,n.toJS(),t,[],r),r.length===0)return e;if(r.length>ik)return WO(t);let i=e;for(let e of r){let n=rk(i,e);if(n===void 0)return WO(t);i=n}let a=he(i);return a.errors.length===0&&JO(a.toJS(),ok(t))?i:WO(t)}var ok=e=>JSON.parse(JSON.stringify(e));function sk(e,t){return ak(e,Ga(t))}var ck=[`bottom`,`top`,`left`,`right`,`none`,`all`,`outside`,`thickOutside`,`bottomDouble`,`thickBottom`,`topBottom`,`topThickBottom`,`topDoubleBottom`],lk=(e,t)=>Object.fromEntries(Object.entries(e).filter(([e])=>e!==t)),uk={top:e=>({...e,bottom:e.top}),bottom:e=>({...e,top:e.bottom}),left:e=>({...e,right:e.left}),right:e=>({...e,left:e.right})};function dk(e,t,n){let r=e=>({...n,style:e});switch(e){case`bottom`:return[{area:uk.bottom(t),sides:{bottom:n}}];case`top`:return[{area:uk.top(t),sides:{top:n}}];case`left`:return[{area:uk.left(t),sides:{left:n}}];case`right`:return[{area:uk.right(t),sides:{right:n}}];case`all`:return[{area:t,sides:{left:n,right:n,top:n,bottom:n}}];case`outside`:case`thickOutside`:{let i=e===`outside`?n:r(`thick`);return[{area:uk.top(t),sides:{top:i}},{area:uk.bottom(t),sides:{bottom:i}},{area:uk.left(t),sides:{left:i}},{area:uk.right(t),sides:{right:i}}]}case`bottomDouble`:return[{area:uk.bottom(t),sides:{bottom:r(`double`)}}];case`thickBottom`:return[{area:uk.bottom(t),sides:{bottom:r(`thick`)}}];case`topBottom`:return[{area:uk.top(t),sides:{top:n}},{area:uk.bottom(t),sides:{bottom:n}}];case`topThickBottom`:return[{area:uk.top(t),sides:{top:n}},{area:uk.bottom(t),sides:{bottom:r(`thick`)}}];case`topDoubleBottom`:return[{area:uk.top(t),sides:{top:n}},{area:uk.bottom(t),sides:{bottom:r(`double`)}}];case`none`:return[]}}function fk(e,t,n,r){let i=e.spec(t),a=Ee(n),o=i.format?.find(e=>e.range===a)?.border;up(e,t,n,{border:{...o,...r}})}function pk(e,t,n,r,i={}){let a=e.workbook.sheet(t);if(!a)return R(`no-sheet`);let o=new z(e);if(r===`none`)return up(o,a,n,{border:void 0}),o.finish();let s={style:i.style??`thin`,...i.color===void 0?{}:{color:i.color}};for(let e of dk(r,n,s))fk(o,a,e.area,e.sides);return o.finish()}function mk(e,t,n,r){let i=e.workbook.sheet(t);if(!i)return R(`no-sheet`);let a=new z(e),o=e=>e??{style:`none`},{top:s,bottom:c,left:l,right:u,horizontal:d,vertical:f}=r;return s!==void 0&&fk(a,i,uk.top(n),{top:o(s)}),c!==void 0&&fk(a,i,uk.bottom(n),{bottom:o(c)}),l!==void 0&&fk(a,i,uk.left(n),{left:o(l)}),u!==void 0&&fk(a,i,uk.right(n),{right:o(u)}),d!==void 0&&n.bottom>n.top&&fk(a,i,{...n,bottom:n.bottom-1},{bottom:o(d)}),f!==void 0&&n.right>n.left&&fk(a,i,{...n,right:n.right-1},{right:o(f)}),a.finish()}function hk(e,t,n){let r=Math.min(t.right,e.columnsUsed-1),i=Math.min(t.bottom,e.lastRow);for(let a=t.top;a<=i;a++){let o=!0;for(let i=t.left;i<=r;i++)if(e.at(a,i)!==void 0){if(o&&(n===`across`||a===t.top))o=!1;else return!0}if(n!==`across`&&!o&&a>=t.top){for(let n=a+1;n<=i;n++)for(let i=t.left;i<=r;i++)if(e.at(n,i)!==void 0)return!0;return!1}}return!1}function gk(e,t,n,r){let i=e.workbook.sheet(t);if(!i)return R(`no-sheet`);if(i.tables.some(e=>S(e.area,n)))return R(`merge-table`);let a=new z(e),o=a.spec(i),s=(o.merges??[]).filter(e=>{let t=x(e);return!t||!S(t,n)}),c=r===`across`?Array.from({length:n.bottom-n.top+1},(e,t)=>({...n,top:n.top+t,bottom:n.top+t})):[n],l=[];for(let t of c)(t.top!==t.bottom||t.left!==t.right)&&(l.push(Ee(t)),_k(a,e,i,t));return l.length===0?Mf():(o.merges=[...s,...l],r===`center`&&up(a,i,n,{align:`center`}),a.edit.whole=!0,a.finish())}function _k(e,t,n,r){let i=``,a=Math.min(r.right,n.columnsUsed-1),o=Math.min(r.bottom,n.lastRow);for(let s=r.top;s<=o;s++)for(let o=r.left;o<=a;o++)n.at(s,o)!==void 0&&(i===``&&(i=Tp(t,n,s,o)),(s!==r.top||o!==r.left)&&Jf(e,t,n,s,o,``));i!==Tp(t,n,r.top,r.left)&&Jf(e,t,n,r.top,r.left,i)}function vk(e,t,n){let r=e.workbook.sheet(t);if(!r)return R(`no-sheet`);let i=new z(e),a=i.spec(r),o=(a.merges??[]).filter(e=>{let t=x(e);return!t||!S(t,n)});return o.length===0?delete a.merges:a.merges=o,i.edit.whole=!0,i.finish()}function yk(e,t,n){let r=e.workbook.sheet(t);if(!r)return R(`no-sheet`);let i=new z(e),a=i.spec(r);return n&&(n.row>0||n.col>0)?a.freeze=Te(n):delete a.freeze,i.edit.whole=!0,i.finish()}function bk(e,t,n,r,i,a){let o=e.workbook.sheet(t);if(!o)return R(`no-sheet`);let s=new z(e),c=s.spec(o),l=(e,t)=>{let n=lk(e[t]??{},`hidden`);return a?{...e,[t]:{...n,hidden:!0}}:Object.keys(n).length===0?lk(e,t):{...e,[t]:n}};if(n===`columns`){let e={...c.columns},t=a?Array.from({length:i-r+1},(e,t)=>Ce(r+t)):Object.keys(e).filter(e=>{let t=we(e);return t!==void 0&&t>=r&&t<=i});for(let n of t)e=l(e,n);c.columns=e}else{let e={...c.rows},t=a?Array.from({length:i-r+1},(e,t)=>String(r+t+1)):Object.keys(e).filter(e=>{let t=Number(e)-1;return t>=r&&t<=i});for(let n of t)e=l(e,n);c.rows=e}return fp(c),s.edit.whole=!0,s.finish()}function xk(e,t,n){let r=e.file.sheets,i=r.filter(e=>e.hidden!==!0),a=r.findIndex(e=>e.name===t),o=r[a];if(!o)return R(`no-sheet`);if(n&&i.length<=1)return R(`last-sheet`);let s=lk(o,`hidden`),c=n?{...s,hidden:!0}:s;return{...Mf(),file:{...e.file,sheets:r.map((e,t)=>t===a?c:e)},whole:!0}}function Sk(e,t,n){let r=e.workbook.sheet(t);if(!r)return R(`no-sheet`);let i=new z(e),a=i.spec(r);return n===void 0?delete a.tab:a.tab=n,i.finish()}function Ck(e,t,n){let r=e.workbook.sheet(t);if(!r)return R(`no-sheet`);let i=new z(e),a=i.spec(r);return n?delete a.gridlines:a.gridlines=!1,i.finish()}function wk(e,t,n){let r=e.workbook.sheet(t);if(!r)return R(`no-sheet`);let i=new z(e),a={row:n.top,col:n.left},o=r.tableAt(a.row,a.col);if(o){let e=i.table(r,o);return e.filter===!1?delete e.filter:e.filter=!1,i.edit.whole=!0,i.finish()}let s=i.spec(r);if(s.filter)return delete s.filter,i.edit.whole=!0,i.finish();let c=n.top===n.bottom&&n.left===n.right?km(r,a):n;if(!c)return R(`no-data`);let l=r.used;return s.filter={range:Ee({...c,bottom:Math.min(c.bottom,l?.bottom??c.bottom),right:Math.min(c.right,l?.right??c.right)})},i.edit.whole=!0,i.finish()}function Tk(e,t,n,r,i){let a=e.workbook.sheet(t);if(!a)return R(`no-sheet`);let o=new z(e),{table:s}=n;if(s){let e=o.table(a,s),t=s.columns[r-s.at.col]?.name??``,n=lk(e.filter===!1||!e.filter?{}:e.filter.columns,t),c=i?{...n,[t]:i}:n;Object.keys(c).length===0?delete e.filter:e.filter={columns:c}}else{let e=o.spec(a);if(!e.filter)return R(`no-sheet`);let t=Ce(r),n=lk(e.filter.columns??{},t),s=i?{...n,[t]:i}:n;e.filter={range:e.filter.range,...Object.keys(s).length===0?{}:{columns:s}}}return o.edit.whole=!0,o.finish()}function Ek(e,t){let n=e.workbook.sheet(t);if(!n)return R(`no-sheet`);let r=new z(e),i=r.spec(n);i.filter&&={range:i.filter.range};for(let e of n.tables)e.spec.filter&&delete r.table(n,e).filter;return r.edit.whole=!0,r.finish()}function Dk(e,t,n){let r=e.workbook.sheet(t);if(!r)return R(`no-sheet`);let i=new z(e),a=i.spec(r);return a.conditional=[n,...a.conditional??[]],i.edit.whole=!0,i.finish()}function Ok(e,t){if(!S(e,t))return[e];let n=[];t.top>e.top&&n.push({...e,bottom:t.top-1}),t.bottom<e.bottom&&n.push({...e,top:t.bottom+1});let r=Math.max(e.top,t.top),i=Math.min(e.bottom,t.bottom);return t.left>e.left&&n.push({...e,top:r,bottom:i,right:t.left-1}),t.right<e.right&&n.push({...e,top:r,bottom:i,left:t.right+1}),n}function kk(e,t){let n=Oe(e);if(!n)return e;let r=n.flatMap(e=>Ok(e,t));return r.length===0?void 0:r.map(Ee).join(` `)}function Ak(e,t,n){let r=e.workbook.sheet(t);if(!r)return R(`no-sheet`);let i=new z(e),a=i.spec(r),o=n?(a.conditional??[]).flatMap(e=>{let t=kk(e.range,n);return t===void 0?[]:[{...e,range:t}]}):[];return o.length===0?delete a.conditional:a.conditional=o,i.edit.whole=!0,i.finish()}function jk(e,t,n,r){let i=e.workbook.sheet(t);if(!i)return R(`no-sheet`);let a=new z(e),o=a.spec(i),s=(o.validations??[]).flatMap(e=>{let t=kk(e.range,n);return t===void 0?[]:[{...e,range:t}]}),c=r?[...s,{...r,range:Ee(n)}]:s;return c.length===0?delete o.validations:o.validations=c,a.edit.whole=!0,a.finish()}function Mk(e,t,n){let r=e.workbook.sheet(t);if(!r)return R(`no-sheet`);let i=new z(e),a=i.spec(r);return a.charts=[...a.charts??[],n],i.finish()}function Nk(e,t,n,r){let i=e.workbook.sheet(t),a=i?.spec.charts?.[n];if(!i||!a)return R(`no-sheet`);let o=new z(e),s=o.spec(i),c=Object.fromEntries(Object.entries({...a,...r}).filter(([,e])=>e!==void 0));return s.charts=(s.charts??[]).map((e,t)=>t===n?c:e),o.finish()}function Pk(e,t,n){let r=e.workbook.sheet(t);if(!r)return R(`no-sheet`);let i=new z(e),a=i.spec(r),o=(a.charts??[]).filter((e,t)=>t!==n);return o.length>0?a.charts=o:delete a.charts,i.finish()}function Fk(e,t,n,r){let i=e.workbook.sheet(t);if(!i)return R(`no-sheet`);let a=new z(e),o=a.spec(i),s=Te(n),c=Object.fromEntries(Object.entries(o.notes??{}).filter(([e])=>e!==s));return r!==void 0&&r.text.trim()!==``&&(c[s]=r.author===void 0||r.author===``?r.text:{text:r.text,author:r.author}),Object.keys(c).length===0?delete o.notes:o.notes=c,a.finish()}function Ik(e,t,n,r){let i=e.workbook.sheet(t);if(!i)return R(`no-sheet`);let a=new z(e),o=a.spec(i),s=Object.fromEntries(Object.entries(o.links??{}).filter(([e])=>{let t=x(e);return t===void 0||!S(t,n)}));if(r!==void 0&&r.trim()!==``){s[Ee(n)]=r.trim();let e=i.lookAt(n.top,n.left);e.color===void 0&&e.underline===void 0&&up(a,i,n,DO)}return Object.keys(s).length===0?delete o.links:o.links=s,fp(o),a.finish()}function Lk(e,t,n){let r=e.workbook.sheet(t);if(!r)return R(`no-sheet`);let i=new z(e),a=i.spec(r);return n?a.protect=!0:delete a.protect,i.finish()}function Rk(e,t){if(e.spec.protect!==!0)return!1;let n=Math.min(t.bottom,Math.max(t.top,e.lastRow+1)),r=Math.min(t.right,Math.max(t.left,e.columnsUsed+1));for(let i=t.top;i<=n;i++)for(let n=t.left;n<=r;n++)if(e.lookAt(i,n).locked!==!1)return!0;return!1}function zk(e,t,n){let r=e.workbook.sheet(t);if(!r)return R(`no-sheet`);let i=new z(e),a=i.spec(r);return n.length===0?delete a.conditional:a.conditional=[...n],i.edit.whole=!0,i.finish()}function Bk(e,t,n){let r=e.workbook.sheet(t);if(!r)return R(`no-sheet`);let i=new z(e),a=i.spec(r),o=Object.fromEntries(Object.entries({...a.print,...n}).filter(([,e])=>e!==void 0));return Object.keys(o).length===0?delete a.print:a.print=o,i.finish()}var Vk=(e,t)=>e===`rows`?Number(t)-1:we(t),Hk=(e,t)=>e===`rows`?String(t+1):Ce(t);function Uk(e,t){let n=new Map,r=(t===`rows`?e.rows:e.columns)??{};for(let[e,i]of Object.entries(r)){let r=Vk(t,e);r!==void 0&&Number.isInteger(r)&&r>=0&&n.set(r,i)}return n}function Wk(e,t){let n=0;for(let r of Uk(e,t).values())n=Math.max(n,r.level??0);return n}function Gk(e,t){let n=Uk(e,t),r=[...n].filter(([,e])=>(e.level??0)>0).map(([e])=>e).sort((e,t)=>e-t),i=[],a=Wk(e,t);for(let e=1;e<=a;e++){let t,a=-2,o=()=>{if(t===void 0)return;let r=!0;for(let e=t;e<=a;e++)n.get(e)?.hidden!==!0&&(r=!1);i.push({level:e,from:t,to:a,collapsed:r}),t=void 0};for(let i of r)(n.get(i)?.level??0)<e||(i!==a+1&&o(),t??=i,a=i);o()}return i}function Kk(e,t,n){return(t===`rows`?e.outline?.summary_below!==!1:e.outline?.summary_right!==!1)?n.to+1:Math.max(0,n.from-1)}function qk(e,t,n,r,i){let a=e.workbook.sheet(t);if(!a)return R(`no-sheet`);let o=new z(e),s=o.spec(a),c=(n===`rows`?s.rows:s.columns)??{},l=new Map(Object.entries(c));for(let e of i){let t=Hk(n,e),i=r(e,l.get(t)??{}),a=Object.fromEntries(Object.entries(i).filter(([,e])=>e!==void 0));Object.keys(a).length===0?l.delete(t):l.set(t,a)}let u=l.size===0?void 0:Object.fromEntries(l);return n===`rows`?u?s.rows=u:delete s.rows:u?s.columns=u:delete s.columns,o.finish()}var Jk=(e,t)=>Array.from({length:t-e+1},(t,n)=>e+n);function Yk(e,t,n,r,i,a){return qk(e,t,n,(e,t)=>{let n=Math.max(0,Math.min(7,(t.level??0)+a));return{...t,level:n===0?void 0:n,hidden:n===0&&(t.level??0)>0?void 0:t.hidden}},Jk(r,i))}function Xk(e,t,n,r,i){return qk(e,t,n,(e,t)=>({...t,hidden:!i||void 0}),Jk(r.from,r.to))}function Zk(e,t,n,r){let i=e.workbook.sheet(t);return i?qk(e,t,n,(e,t)=>({...t,hidden:(t.level??0)>=r||void 0}),[...Uk(i.spec,n)].filter(([,e])=>(e.level??0)>0).map(([e])=>e)):R(`no-sheet`)}var Qk=e=>e===null?``:typeof e==`string`?`s${e.toLowerCase()}`:e instanceof C?`e${e.code}`:`${typeof e}${String(e)}`;function $k(e,t){let n=new Set;return e.map(e=>{let r=(t.length===0?e.map((e,t)=>t):t).map(t=>Qk(e[t]??null)).join(`\0`);return!n.has(r)&&(n.add(r),!0)})}function eA(e,t){if(t===0||!e.startsWith(`=`))return e;let n=Hl(e);return n.ok?_t(Cl(n.node,t,0)):e}function tA(e,t,n,r,i){let a=e.workbook.sheet(n);if(!a)return{...R(`no-sheet`),duplicates:0,unique:0};let o=i.header?r.top+1:r.top,s=r.right-r.left+1,c=[],l=[];for(let n=o;n<=r.bottom;n++)c.push(Array.from({length:s},(e,i)=>t.value(a,n,r.left+i))),l.push(Array.from({length:s},(t,i)=>Tp(e,a,n,r.left+i)));let u=$k(c,i.columns.map(e=>e-r.left)),d=[],f=o;u.forEach((e,t)=>{let n=o+t;e&&(n!==f&&l[t]?.forEach((e,t)=>{d.push({row:f,col:r.left+t,text:eA(e,f-n)})}),f+=1)});for(let e=f;e<=r.bottom;e++)for(let t=0;t<s;t++)d.push({row:e,col:r.left+t,text:``});let p=f-o;return{...Zf(e,n,d),duplicates:u.length-p,unique:p}}function nA(e,t){if(t.widths&&t.widths.length>0){let n=[...new Set(t.widths)].filter(e=>e>0).sort((e,t)=>e-t),r=[],i=0;for(let t of n)r.push(e.slice(i,t).trim()),i=t;return r.push(e.slice(i).trim()),r}let n=t.delimiters??[];if(n.length===0)return[e];let r=[],i=``,a=!1,o=!1;for(let s=0;s<e.length;s++){let c=e.charAt(s);t.qualifier&&c===t.qualifier?(a&&e.charAt(s+1)===t.qualifier?(i+=c,s+=1):a=!a,o=!1):!a&&n.includes(c)?(t.consecutive===!0&&o||r.push(i),i=``,o=!0):(i+=c,o=!1)}return r.push(i),r}function rA(e,t,n,r,i){let a=e.workbook.sheet(n);if(!a)return R(`no-sheet`);let o=i.destination??{row:r.top,col:r.left},s=[];for(let n=r.top;n<=r.bottom;n++){let c=t.value(a,n,r.left);c!==null&&nA(typeof c==`string`?c:Tp(e,a,n,r.left),i).forEach((e,t)=>{s.push({row:o.row+n-r.top,col:o.col+t,text:e})})}return s.length===0?R(`no-data`):Zf(e,n,s)}function iA(e){let t=[...e].sort((e,t)=>e.row-t.row||e.col-t.col),n=[];for(let e of t){let t=n[n.length-1];t?.top===e.row&&t.right===e.col-1?t.right=e.col:n.push({top:e.row,bottom:e.row,left:e.col,right:e.col})}let r=[],i=[];for(let e of n){let t=r.find(t=>t.bottom===e.top-1&&t.left===e.left&&t.right===e.right);t?t.bottom=e.bottom:r.push({...e});for(let t=r.length-1;t>=0;t--){let n=r[t];n&&n.bottom<e.top-1&&(i.push(n),r.splice(t,1))}}return[...i,...r].sort((e,t)=>e.top-t.top||e.left-t.left)}var aA=[[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`],[`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`,`Sunday`],[`周一`,`周二`,`周三`,`周四`,`周五`,`周六`,`周日`],[`星期一`,`星期二`,`星期三`,`星期四`,`星期五`,`星期六`,`星期日`]],oA=[[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],[`一月`,`二月`,`三月`,`四月`,`五月`,`六月`,`七月`,`八月`,`九月`,`十月`,`十一月`,`十二月`]],sA=[...aA,...oA];function cA(e){let t=e.trim().toLowerCase();for(let e of sA){let n=e.findIndex(e=>e.toLowerCase()===t);if(n>=0)return{list:e,at:n}}}function lA(e,t){return t===t.toUpperCase()&&t!==t.toLowerCase()?e.toUpperCase():t===t.toLowerCase()&&t!==t.toUpperCase()?e.toLowerCase():e}var uA=/^\d{4}-\d{2}-\d{2}/u;function dA(e,t,n){let r=e.length,i=(r-1)/2,a=e.reduce((e,t)=>e+t,0)/r,o=0,s=0;e.forEach((e,t)=>{o+=(t-i)*(e-a),s+=(t-i)**2});let c=s===0?1:o/s,l=[];for(let e=0;e<t;e++){let t=a+c*((n?-1-e:r+e)-i);l.push(Number(t.toPrecision(15)))}return l}function fA(e,t,n){let r=e.map(e=>Be(e)),i=r.flatMap(e=>e?[e]:[]),[a,o]=i;if(a&&o&&i.length===r.length){let e=e=>e.getUTCFullYear()*12+e.getUTCMonth(),r=e(o)-e(a);if(r!==0&&i.every((t,n)=>t.getUTCDate()===a.getUTCDate()&&e(t)===e(a)+r*n)){let e=[];for(let o=0;o<t;o++){let t=n?-1-o:i.length+o;e.push(ze(new Date(Date.UTC(a.getUTCFullYear(),a.getUTCMonth()+r*t,a.getUTCDate()))))}return e}}if(e.length===1){let[r=0]=e;return Array.from({length:t},(e,t)=>n?r-t-1:r+t+1)}return dA(e,t,n)}var pA=(e,t)=>t.length>10?He(e):He(Math.round(e)),mA=(e,t,n)=>`${e}${String(Math.max(n,0)).padStart(t.length,`0`)}`,hA=/^(.*?)(\d+)$/su;function gA(e,t,n){let r=e.map(e=>hA.exec(e)),[i]=r;if(!i||r.some(e=>!e||e[1]!==i[1]))return;let a=i[1]??``,o=i[2]??``,s=dA(r.map(e=>Number(e?.[2])),t,n),c=/^q$/iu.test(a);return s.map(e=>mA(a,o,c?(Math.round(e)+399)%4+1:Math.round(e)))}function _A(e,t,n){let r=e.map(cA),[i]=r;if(!i||r.some(e=>e?.list!==i.list))return;let a=i.list.length,o=r[r.length-1],s=r.length>1&&o&&(o.at-i.at)/(r.length-1)||1,c=e[0]??``,l=[],u=n?i.at:o?.at??i.at;for(let e=0;e<t;e++){let t=u+(n?-s:s)*(e+1),r=i.list[(Math.round(t)%a+a)%a]??``;l.push(lA(r,c))}return l}var vA=(e,t,n)=>{let r=e.length;return Array.from({length:t},(t,i)=>n?e[((r-1-i)%r+r)%r]??``:e[i%r]??``)};function yA(e,t,n={}){let r=n.mode??`auto`,i=n.back===!0;if(r===`copy`||e.length===0)return vA(e,t,i);let a=e.map(e=>Xe(e).value),o=e.length===1,s=a.flatMap(e=>typeof e==`number`?[e]:[]);if(s.length===a.length){if(e.every(e=>uA.test(e)))return fA(s,t,i).map(t=>pA(t,e[0]??``));if(o&&r===`auto`)return vA(e,t,i);let n=s;return(o&&n[0]!==void 0?Array.from({length:t},(e,t)=>i?(n[0]??0)-t-1:(n[0]??0)+t+1):dA(n,t,i)).map(String)}return a.every(e=>typeof e==`string`)?_A(e,t,i)??gA(e,t,i)??vA(e,t,i):vA(e,t,i)}var bA=e=>Xe(e).formula!==void 0;function xA(e,t,n){let r=Hl(e);return r.ok?wl(r.node,t,n):void 0}var SA=(e,t)=>!e.tables.some(e=>S(e.area,t))&&!e.blocks.some(e=>S(e.area,t));function CA(e,t,n,r){if(e.some(e=>bA(e.text))){let r=e.length;return t.map((t,i)=>{let a=n?e[((r-1-i)%r+r)%r]:e[i%r],o=a?.text??``;return{...t,text:a?Rf(o,t.row-a.row,t.col-a.col):o}})}let i=yA(e.map(e=>e.text),t.length,{mode:r,back:n});return t.map((e,t)=>({...e,text:i[t]??``}))}var wA=[`bold`,`italic`,`underline`,`strike`,`font`,`size`,`color`,`fill`,`align`,`valign`,`wrap`,`shrink`,`indent`,`rotation`,`border`,`locked`,`hide_formula`,`format`],TA=Object.fromEntries(wA.map(e=>[e,void 0]));function EA(e,t,n,r){let i=new Map;for(let e of r){let r=t.lookAt(e.from.row,e.from.col),a=n.lookAt(e.to.row,e.to.col);if(JSON.stringify(r)===JSON.stringify(a))continue;let o=JSON.stringify(r),s=i.get(o);s?s.places.push(e.to):i.set(o,{look:r,places:[e.to]})}for(let{look:t,places:r}of i.values()){let i={};for(let e of wA)i[e]=t[e];for(let t of iA(r))up(e,n,t,i)}}function DA(e,t,n,r,i=`auto`){let a=e.workbook.sheet(t);if(!a)return R(`no-sheet`);let o=r.bottom>n.bottom||r.top<n.top,s=r.top<n.top||r.left<n.left,c=new z(e),l=o?{first:n.left,last:n.right}:{first:n.top,last:n.bottom},u=new Map,d=(t,n)=>{let r=`${String(t)}:${String(n)}`,i=u.get(r);return i===void 0&&(i=Tp(e,a,t,n),u.set(r,i)),i},f=(n.bottom-n.top+1)*(n.right-n.left+1),p=new Set;for(let e=n.top;e<=n.bottom;e++)for(let t=n.left;t<=n.right;t++){let n=d(e,t);bA(n)&&p.add(xA(n,e,t)??``)}if(p.size===1&&f>0&&SA(a,r)&&OA(d,n)){let e=c.spec(a);return tp(e,r),e.cells={...e.cells,[Ee(r)]:Rf(d(n.top,n.left),r.top-n.top,r.left-n.left)},c.edit.whole=!0,kA(c,a,n,r,o),c.finish()}for(let t=l.first;t<=l.last;t++){let l=[];if(o)for(let e=n.top;e<=n.bottom;e++)l.push({row:e,col:t,text:d(e,t)});else for(let e=n.left;e<=n.right;e++)l.push({row:t,col:e,text:d(t,e)});let u=[],f=s?o?n.top-1:n.left-1:o?n.bottom+1:n.right+1,p=o?s?r.top:r.bottom:s?r.left:r.right,m=s?-1:1;for(let e=f;s?e>=p:e<=p;e+=m)u.push(o?{row:e,col:t}:{row:t,col:e});for(let t of CA(l,u,s,i))Jf(c,e,a,t.row,t.col,t.text)}return kA(c,a,n,r,o),c.finish()}function OA(e,t){for(let n=t.top;n<=t.bottom;n++)for(let r=t.left;r<=t.right;r++)if(!bA(e(n,r)))return!1;return!0}function kA(e,t,n,r,i){let a=[],o=n.bottom-n.top+1,s=n.right-n.left+1;for(let e=r.top;e<=r.bottom;e++)for(let t=r.left;t<=r.right;t++){if(ke(n,e,t))continue;let r=i?n.top+((e-n.top)%o+o)%o:e,c=i?t:n.left+((t-n.left)%s+s)%s;a.push({from:{row:r,col:c},to:{row:e,col:t}})}EA(e,t,t,a)}function AA(e,t,n,r){let i=e.workbook.sheet(t),a=e.workbook.sheet(n);if(!i||!a)return R(`no-sheet`);let o=new z(e);return EA(o,i,a,r),o.finish()}function jA(e,t){let n=(t,n)=>n>=0&&e.at(t,n)!==void 0;for(let e of[t.left-1,t.right+1]){if(!n(t.bottom,e)&&!n(t.bottom+1,e))continue;let r=t.bottom;for(;n(r+1,e);)r+=1;if(r>t.bottom)return r}}function MA(e,t,n){if(!bA(e))return e;let r=Hl(e);return r.ok?_t(vl(r.node,e=>e.kind===`ref`?e.sheet===void 0?{...e,sheet:t}:e.sheet.toLowerCase()!==n.toLowerCase()||e.lastSheet!==void 0?e:Object.fromEntries(Object.entries(e).filter(([e])=>e!==`sheet`)):e)):e}function NA(e){let t=Mf();t.whole=!0;for(let n of e){n.file&&(t.file=n.file);for(let[e,r]of n.rows)t.rows.set(e,r)}return t}function PA(e,t){let n=t.file??e.file,r=new Map(e.rows);for(let[e,n]of t.rows)r.set(e,n);return{file:n,rows:r,workbook:mu({file:n,rows:e=>r.get(e)})}}function FA(e,t,n,r,i){let a=e.workbook.sheet(t),o=e.workbook.sheet(r);if(!a||!o)return R(`no-sheet`);let s=i.row-n.top,c=i.col-n.left;if(s===0&&c===0&&a===o)return Mf();let l={top:i.row,left:i.col,bottom:n.bottom+s,right:n.right+c},u=a.tables.filter(e=>ke(n,e.area.top,e.area.left)&&ke(n,e.area.bottom,e.area.right));for(let e of a.tables)if(!u.includes(e)&&S(e.area,n)&&n.top<=e.at.row)return R(`table-move`);if(u.length>0&&a!==o)return R(`table-move`);for(let e of o.tables)if(!u.includes(e)&&S(e.area,l)&&l.top<=e.at.row)return R(`table-move`);let d=mf(e,{op:`move-cells`,sheet:t,area:n,rows:s,columns:c,...a===o?{}:{to:r}}),f={...Mf(),file:d.file,rows:new Map(d.rows)},p=PA(e,f),m=p.workbook.sheet(t),h=p.workbook.sheet(r);if(!m||!h)return R(`no-sheet`);let g=[],_=[],v=Math.min(n.right,m.columnsUsed-1),ee=Math.min(n.bottom,m.lastRow),te=(e,t)=>u.some(n=>ke(n.area,e,t));for(let e=n.top;e<=ee;e++)for(let i=n.left;i<=v;i++)if(!te(e,i)){if(m.at(e,i)!==void 0){let n=Tp(p,m,e,i);g.push({row:e+s,col:i+c,text:a===o?n:MA(n,t,r)})}_.push({from:{row:e,col:i},to:{row:e+s,col:i+c}})}let y=ep(p,t,n);if(y.refused!==void 0)return y;let b=PA(p,y),ne=[f,y],re=b;if(u.length>0){let e=new z(b),n=b.workbook.sheet(t);if(!n)return R(`no-sheet`);for(let t of u){let r=n.tables.find(e=>e.name===t.name);if(!r)continue;let i=e.table(n,r);i.at=Te({row:t.at.row+s,col:t.at.col+c})}let r=e.finish();ne.push(r),re=PA(b,r)}let ie=Zf(re,r,g);if(ie.refused!==void 0)return ie;ne.push(ie);let ae=PA(re,ie),oe=ae.workbook.sheet(t),se=ae.workbook.sheet(r);if(oe&&se){let e=new z(ae);EA(e,m,se,_);let t=_.map(e=>e.from).filter(e=>!(a===o&&ke(l,e.row,e.col))&&Object.keys(m.lookAt(e.row,e.col)).length>0);for(let n of iA(t))up(e,oe,n,TA);ne.push(e.finish())}return NA(ne)}function IA(e,t,n,r){let i=e.workbook.sheet(t);if(!i)return R(`no-sheet`);let a=r===`down`||r===`up`,o=r===`down`||r===`right`,s=a?n.bottom-n.top+1:n.right-n.left+1,c=a?{...n,bottom:Math.max(n.bottom,i.lastRow)}:{...n,right:Math.max(n.right,i.columnsUsed-1)},l=a?{...n,bottom:xe-1}:{...n,right:Se-1};if(i.tables.some(e=>S(e.area,l)))return R(`table-shift`);if(i.merges.some(e=>S(e,l)))return R(`merge-shift`);let u=mf(e,{op:`shift-cells`,sheet:t,rows:a,insert:o,at:a?n.top:n.left,count:s,first:a?n.left:n.top,last:a?n.right:n.bottom});if(u.refused!==void 0)return R(u.refused);let d={...Mf(),file:u.file,rows:new Map(u.rows)},f=PA(e,d),p=f.workbook.sheet(t);if(!p)return R(`no-sheet`);let m=o?s:-s,h=o?c:a?{...c,top:n.bottom+1}:{...c,left:n.right+1},g=Math.min(c.bottom,p.lastRow),_=Math.min(c.right,p.columnsUsed-1),v=[],ee=[],te=new Set;for(let e=h.top;e<=Math.min(h.bottom,g);e++)for(let t=h.left;t<=Math.min(h.right,_);t++){let n=a?{row:e+m,col:t}:{row:e,col:t+m};p.at(e,t)!==void 0&&v.push({...n,text:Tp(f,p,e,t)}),ee.push({from:{row:e,col:t},to:n}),te.add(Te(n))}let y=ep(f,t,c);if(y.refused!==void 0)return y;let b=PA(f,y),ne=Zf(b,t,v);if(ne.refused!==void 0)return ne;let re=PA(b,ne),ie=[d,y,ne],ae=re.workbook.sheet(t);if(ae){let e=new z(re);EA(e,p,ae,ee);let t=[];for(let e=c.top;e<=g;e++)for(let n=c.left;n<=_;n++)!te.has(Te({row:e,col:n}))&&Object.keys(p.lookAt(e,n)).length>0&&t.push({row:e,col:n});for(let n of iA(t))up(e,ae,n,TA);ie.push(e.finish())}return NA(ie)}export{bO as $,S as $n,fu as $t,yk as A,Et as An,pp as At,wk as B,et as Bn,Cf as Bt,Rk as C,Va as Cn,yp as Ct,Nk as D,Wt as Dn,Sp as Dt,pk as E,Gt as En,Dp as Et,Bk as F,_t as Fn,kp as Ft,jO as G,Xe as Gn,_f as Gt,sk as H,w as Hn,xf as Ht,Lk as I,ut as In,Op as It,AO as J,Se as Jn,wu as Jt,kO as K,ze as Kn,Xu as Kt,xk as L,$e as Ln,rp as Lt,bk as M,At as Mn,Mp as Mt,Ik as N,jt as Nn,mp as Nt,zk as O,vt as On,Qf as Ot,Fk as P,zt as Pn,Yf as Pt,yO as Q,Ce as Qn,ql as Qt,Sk as R,nt as Rn,Zf as Rt,hk as S,io as Sn,bp as St,mk as T,Bt as Tn,Tp as Tt,IO as U,je as Un,Df as Ut,vk as V,C as Vn,bf as Vt,PO as W,Ue as Wn,Tf as Wt,SO as X,Te as Xn,Zl as Xt,CO as Y,xe as Yn,M as Yt,xO as Z,we as Zn,Xl as Zt,Mk as _,Bc as _n,Cp as _t,AA as a,qc as an,Om as at,Ek as b,Qa as bn,wp as bt,nA as c,Jc as cn,_m as ct,Wk as d,Pc as dn,hm as dt,Hl as en,Ee as er,_O as et,Gk as f,Gc as fn,em as ft,ck as g,Vc as gn,_p as gt,Kk as h,Nc as hn,Bp as ht,FA as i,rl as in,rO as it,Ck as j,It as jn,lp as jt,Tk as k,Rt as kn,gp as kt,rA as l,Fc as ln,dm as lt,Zk as m,Rc as mn,Hp as mt,DA as n,wl as nn,x as nr,mO as nt,IA as o,$c as on,km as ot,Xk as p,Wc as pn,cm as pt,EO as q,Ze as qn,gu as qt,jA as r,_l as rn,Oe as rr,gO as rt,tA as s,Qc as sn,um as st,TA as t,Cl as tn,De as tr,hO as tt,Yk as u,Uc as un,fm as ut,Dk as v,Hc as vn,ep as vt,Pk as w,za as wn,np as wt,gk as x,Za as xn,Np as xt,Ak as y,Ka as yn,vp as yt,jk as z,tt as zn,gf as zt};
|