allyhub 0.18.0 → 0.19.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/CHANGELOG.md +8 -0
- package/bin/allyhub.js +10 -0
- package/dist/args.js +1 -1
- package/dist/command.js +1 -1
- package/dist/commands/add.js +1 -1
- package/dist/commands/auth.js +1 -1
- package/dist/commands/cloud-tools.js +1 -1
- package/dist/commands/cloud.js +1 -1
- package/dist/commands/contributed.js +1 -1
- package/dist/commands/found-extensions.js +2 -0
- package/dist/commands/frames/common.js +1 -1
- package/dist/commands/frames/doc.js +1 -1
- package/dist/commands/frames.js +9 -9
- package/dist/commands/index.js +1 -1
- package/dist/commands/inspect/common.js +3 -3
- package/dist/commands/inspect/index.js +1 -1
- package/dist/commands/inspect/layout.js +1 -1
- package/dist/commands/inspect/views.js +1 -1
- package/dist/commands/list.js +2 -0
- package/dist/commands/mail.js +1 -1
- package/dist/commands/render.js +1 -1
- package/dist/commands/run-context.js +2 -0
- package/dist/commands.json +1 -0
- package/dist/fields.js +1 -1
- package/dist/main.js +7 -7
- package/dist/node_modules/@allyhub/3d-extension/dist/build.js +1 -1
- package/dist/node_modules/@allyhub/3d-extension/dist/scenery-build.js +1 -1
- package/dist/node_modules/@allyhub/3d-extension/package.json +3 -2
- package/dist/node_modules/@allyhub/audio/package.json +1 -1
- package/dist/node_modules/@allyhub/browser/package.json +1 -1
- package/dist/node_modules/@allyhub/build/dist/build-plugins.js +1 -1
- package/dist/node_modules/@allyhub/build/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/build/dist/meta-worker.js +1 -1
- package/dist/node_modules/@allyhub/build/dist/plugin.js +9 -9
- 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/scan.js +1 -1
- package/dist/node_modules/@allyhub/build/dist/sdk-parts.js +2 -0
- package/dist/node_modules/@allyhub/build/dist/vite.js +2 -2
- package/dist/node_modules/@allyhub/build/package.json +9 -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/dist/check.js +2 -2
- package/dist/node_modules/@allyhub/check/package.json +1 -1
- package/dist/node_modules/@allyhub/cloud/dist/blobs.js +1 -1
- package/dist/node_modules/@allyhub/cloud/dist/call.js +1 -1
- package/dist/node_modules/@allyhub/cloud/dist/catalog.js +1 -1
- package/dist/node_modules/@allyhub/cloud/dist/client.js +1 -1
- package/dist/node_modules/@allyhub/cloud/dist/config.js +1 -1
- package/dist/node_modules/@allyhub/cloud/dist/credentials.js +1 -1
- package/dist/node_modules/@allyhub/cloud/dist/device.js +1 -1
- package/dist/node_modules/@allyhub/cloud/dist/errors.js +1 -1
- package/dist/node_modules/@allyhub/cloud/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/cloud/dist/loopback.js +2 -2
- package/dist/node_modules/@allyhub/cloud/dist/mail.js +1 -1
- package/dist/node_modules/@allyhub/cloud/dist/records.js +1 -1
- package/dist/node_modules/@allyhub/cloud/dist/signin.js +2 -2
- package/dist/node_modules/@allyhub/cloud/dist/sites.js +1 -1
- package/dist/node_modules/@allyhub/cloud/dist/token.js +1 -1
- package/dist/node_modules/@allyhub/cloud/dist/tools.js +2 -0
- package/dist/node_modules/@allyhub/cloud/dist/uploads.js +1 -1
- package/dist/node_modules/@allyhub/cloud/dist/voice.js +1 -1
- package/dist/node_modules/@allyhub/cloud/package.json +5 -1
- package/dist/node_modules/@allyhub/components/package.json +1 -1
- 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/package.json +1 -1
- package/dist/node_modules/@allyhub/doc-extension/dist/cli/find.js +1 -1
- package/dist/node_modules/@allyhub/doc-extension/dist/workspace.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/dist/points.js +1 -1
- package/dist/node_modules/@allyhub/extension-host/package.json +1 -1
- package/dist/node_modules/@allyhub/formats/dist/items.d.ts +24 -7
- package/dist/node_modules/@allyhub/formats/dist/items.js +1 -1
- package/dist/node_modules/@allyhub/formats/dist/note-shape.d.ts +1 -1
- package/dist/node_modules/@allyhub/formats/package.json +25 -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-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 -600
- package/dist/node_modules/@allyhub/measure/package.json +1 -1
- package/dist/node_modules/@allyhub/media/package.json +5 -1
- package/dist/node_modules/@allyhub/media-extension/dist/asr/hear.js +1 -1
- package/dist/node_modules/@allyhub/media-extension/dist/vision/track.js +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/dist/layer.d.ts +1 -2
- package/dist/node_modules/@allyhub/piece/dist/media.d.ts +1 -1
- package/dist/node_modules/@allyhub/piece/dist/source.d.ts +2 -2
- package/dist/node_modules/@allyhub/piece/dist/stage.d.ts +2 -2
- 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/auth.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/blobs.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/cli.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/cloud.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/errors.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/events.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/jsonrpc.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/kinds.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/mail.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/notes.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/paywall.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/purposes.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/registry.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/sites.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/snapshots.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/teams.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/tools.js +1 -1
- package/dist/node_modules/@allyhub/protocol/package.json +41 -1
- package/dist/node_modules/@allyhub/registry/package.json +1 -1
- package/dist/node_modules/@allyhub/render/dist/errors.js +1 -1
- package/dist/node_modules/@allyhub/render/dist/post-probe.js +1 -1
- package/dist/node_modules/@allyhub/render/package.json +9 -1
- package/dist/node_modules/@allyhub/runtime/package.json +1 -1
- package/dist/node_modules/@allyhub/runtimes/dist/bundled.js +1 -1
- package/dist/node_modules/@allyhub/runtimes/dist/declared.js +1 -1
- package/dist/node_modules/@allyhub/runtimes/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/runtimes/dist/manifest.js +1 -1
- package/dist/node_modules/@allyhub/runtimes/dist/runtimes.js +1 -1
- package/dist/node_modules/@allyhub/runtimes/package.json +9 -1
- 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/dist/bundle.js +3 -3
- package/dist/node_modules/@allyhub/scenery-host/dist/fact.d.ts +1 -1
- package/dist/node_modules/@allyhub/scenery-host/dist/model-stage.js +2 -2
- package/dist/node_modules/@allyhub/scenery-host/package.json +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/annotations.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/api/workbook.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/arrange.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/engine.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/filter.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/generated.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/html.js +6 -6
- package/dist/node_modules/@allyhub/sheet/dist/workbook.js +1 -1
- package/dist/node_modules/@allyhub/sheet/package.json +1 -1
- package/dist/node_modules/@allyhub/sheet-extension/dist/cli/open.js +1 -1
- package/dist/node_modules/@allyhub/sheet-extension/dist/code.js +1 -1
- package/dist/node_modules/@allyhub/sheet-extension/dist/export.js +2 -2
- package/dist/node_modules/@allyhub/sheet-extension/package.json +1 -1
- package/dist/node_modules/@allyhub/slides-core/package.json +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/dist/fonts/arimo/400-italic.css +1 -79
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/arimo/400.css +1 -79
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/arimo/700-italic.css +1 -79
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/arimo/700.css +1 -79
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/arimo/arial.css +1 -316
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/caladea/400-italic.css +1 -19
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/caladea/400.css +1 -19
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/caladea/700-italic.css +1 -19
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/caladea/700.css +1 -19
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/caladea/cambria.css +1 -76
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/carlito/400-italic.css +1 -69
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/carlito/400.css +1 -69
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/carlito/700-italic.css +1 -69
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/carlito/700.css +1 -69
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/carlito/calibri.css +1 -276
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/400-italic.css +1 -79
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/400.css +1 -79
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/700-italic.css +1 -79
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/700.css +1 -79
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/courier-new.css +1 -316
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/noto-color-emoji/emoji.css +1 -8
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/noto-sans-sc/400.css +1 -1009
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/noto-sans-sc/700.css +1 -1009
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/noto-sans-sc/microsoft-yahei.css +1 -2018
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/400-italic.css +1 -79
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/400.css +1 -79
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/700-italic.css +1 -79
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/700.css +1 -79
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/times-new-roman.css +1 -316
- package/dist/node_modules/@allyhub/stage-page/package.json +1 -1
- package/dist/node_modules/@allyhub/stage-runtime/package.json +1 -1
- package/dist/node_modules/@allyhub/telemetry/dist/doc.js +1 -1
- package/dist/node_modules/@allyhub/telemetry/dist/errors.js +1 -1
- package/dist/node_modules/@allyhub/telemetry/dist/telemetry.js +2 -2
- 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/dist/build-plugins.js +1 -1
- package/dist/node_modules/@allyhub/video-extension/package.json +6 -2
- package/dist/node_modules/@allyhub/video-measure/dist/plans.js +2 -2
- package/dist/node_modules/@allyhub/video-measure/dist/reference/video.js +1 -1
- package/dist/node_modules/@allyhub/video-measure/package.json +5 -1
- package/dist/node_modules/@allyhub/video-sdk/dist/config.js +2 -0
- package/dist/node_modules/@allyhub/video-sdk/dist/piece.js +1 -1
- package/dist/node_modules/@allyhub/video-sdk/package.json +5 -1
- package/dist/node_modules/@allyhub/website/package.json +1 -1
- package/dist/node_modules/@allyhub/website-extension/dist/build.js +1 -1
- package/dist/node_modules/@allyhub/website-extension/package.json +4 -4
- package/dist/node_modules/@allyhub/x-extension/dist/build.js +1 -1
- package/dist/node_modules/@allyhub/x-extension/package.json +8 -2
- package/dist/node_modules/@allyhub/x-model/package.json +1 -1
- package/dist/node_modules/@allyhub/x-view/package.json +1 -1
- package/dist/node_modules/@allyhub/x-view/src/style.css +1 -709
- package/dist/package.json +14 -14
- package/dist/project.js +1 -1
- package/dist/resources.js +1 -1
- package/dist/sdk-docs.js +1 -1
- package/dist/slot.js +4 -0
- package/dist/telemetry.js +1 -1
- package/dist/version.js +1 -1
- package/editor-web/assets/{abnfDiagram-WEYOIA3C-Hy4-O0wN.js → abnfDiagram-WEYOIA3C-DYaMS_BB.js} +1 -1
- package/editor-web/assets/{architecture-WOLXFQ4H-43JEVxqz.js → architecture-WOLXFQ4H-g_Tjfl_y.js} +1 -1
- package/editor-web/assets/{architectureDiagram-ZHVYKT53-7bFTl41n.js → architectureDiagram-ZHVYKT53-CqdhofOL.js} +1 -1
- package/editor-web/assets/{article-CS48wwvk.js → article-8evPh712.js} +1 -1
- package/editor-web/assets/{article-Cyle57uq.js → article-BhRtWYMd.js} +1 -1
- package/editor-web/assets/{blockDiagram-RJAE7QA3-DcoNo1WH.js → blockDiagram-RJAE7QA3-Bc-28Bci.js} +1 -1
- package/editor-web/assets/{c4Diagram-XDPPPE54-CsMt61gx.js → c4Diagram-XDPPPE54-CTGJb8FB.js} +1 -1
- package/editor-web/assets/{calc-worker-BdHh5LXM.js → calc-worker-oEIqrrTM.js} +1 -1
- package/editor-web/assets/channel-wIj_OqDm.js +1 -0
- package/editor-web/assets/{chart-file-CfbWK9l1.js → chart-file-dGiRgFcH.js} +1 -1
- package/editor-web/assets/{chunk-2E7WHVMD-fj-TJIRG.js → chunk-2E7WHVMD-B2MPOVTU.js} +1 -1
- package/editor-web/assets/{chunk-4EMNKR2T-Du5cRy-Y.js → chunk-4EMNKR2T-BUV1ZHP0.js} +1 -1
- package/editor-web/assets/{chunk-55XCU76K-BHXxBBtm.js → chunk-55XCU76K-BZlpspL5.js} +1 -1
- package/editor-web/assets/{chunk-7S6XSTFO-R5HW6X5I.js → chunk-7S6XSTFO-CpKeisWE.js} +1 -1
- package/editor-web/assets/{chunk-AQDTSKZB-C98F2BUb.js → chunk-AQDTSKZB-BJqwAPyo.js} +1 -1
- package/editor-web/assets/{chunk-DSNLSHJZ-NIGsJ2cK.js → chunk-DSNLSHJZ-D6oPWl_W.js} +1 -1
- package/editor-web/assets/{chunk-HAGFOTED-BtHxtfW5.js → chunk-HAGFOTED-B5pk4MZF.js} +1 -1
- package/editor-web/assets/{chunk-HNE4Q36P-BI8i7Vkk.js → chunk-HNE4Q36P-DHbSPvxQ.js} +1 -1
- package/editor-web/assets/{chunk-NQOKRVIF-DP_Z_zEA.js → chunk-NQOKRVIF-CcL_GcRA.js} +1 -1
- package/editor-web/assets/{chunk-UHW7PFBP-C_8bui28.js → chunk-UHW7PFBP-YgiOL6XE.js} +1 -1
- package/editor-web/assets/{chunk-VQ5W62QI-CKZgzWB2.js → chunk-VQ5W62QI-p14b4UYc.js} +1 -1
- package/editor-web/assets/{chunk-WQQL4CDK-Ff4DgCht.js → chunk-WQQL4CDK-BWW0x-XH.js} +1 -1
- package/editor-web/assets/{chunk-YZO67HFG-Csbx1-pi.js → chunk-YZO67HFG-oG3qd68C.js} +1 -1
- package/editor-web/assets/{chunk-ZAUX2LTX-BO1kcV3w.js → chunk-ZAUX2LTX-CpcheH0u.js} +1 -1
- package/editor-web/assets/{chunk-ZCHMQSOR-CxeNZYZG.js → chunk-ZCHMQSOR-cWQvLl1w.js} +1 -1
- package/editor-web/assets/{classDiagram-v2-4MYWR3UA-D8eHQa5i.js → classDiagram-v2-4MYWR3UA-7PG7YcdU.js} +1 -1
- package/editor-web/assets/{cynefin-EF2NZ3EQ-lIUY3WQQ.js → cynefin-EF2NZ3EQ-CtcknEQ_.js} +1 -1
- package/editor-web/assets/{cynefinDiagram-WF24UDRP-CFOOhEEs.js → cynefinDiagram-WF24UDRP-Ca7VIsjN.js} +1 -1
- package/editor-web/assets/{dagre-NK4GIZVX-DdHVup2I.js → dagre-NK4GIZVX-BzcSLtsr.js} +1 -1
- package/editor-web/assets/deck-C7fN0Qtn.js +1 -0
- package/editor-web/assets/{diagram-CBK3MWTC-CFAD9Y2B.js → diagram-CBK3MWTC-DpRmTGlG.js} +1 -1
- package/editor-web/assets/{diagram-I5XIIV2D-DZJAn95A.js → diagram-I5XIIV2D-BTrs_AX8.js} +1 -1
- package/editor-web/assets/{diagram-ODIL2UCW-BcIeYTaY.js → diagram-ODIL2UCW-CkIVjPqH.js} +1 -1
- package/editor-web/assets/{diagram-PFBEJUXE-CnZmh_fl.js → diagram-PFBEJUXE-BlFMbAG1.js} +1 -1
- package/editor-web/assets/{diagram-RJA3I4VV-DpDd9rGx.js → diagram-RJA3I4VV-D3f8VJ-D.js} +1 -1
- package/editor-web/assets/{diagram-TYUNFSNR-ouGiUQcR.js → diagram-TYUNFSNR-Bbpngj6F.js} +1 -1
- package/editor-web/assets/{dist-DGKjn59H.js → dist-3iovns9K.js} +1 -1
- package/editor-web/assets/dist-BkHnbOEj.js +4 -0
- package/editor-web/assets/dist-BvOrNcK-.js +19 -0
- package/editor-web/assets/dist-CEIszq39.js +1 -0
- package/editor-web/assets/{dist-BI8QjOsV.js → dist-CU5RbLNH.js} +1 -1
- package/editor-web/assets/dist-CWZj8IAm.js +1 -0
- package/editor-web/assets/{dist-NQNQ5HqZ.js → dist-C_Mtrnif.js} +3 -3
- package/editor-web/assets/{dist-BajH5QfK.js → dist-CdqpwdCV.js} +4 -4
- package/editor-web/assets/{dist-SV0sOVIC.js → dist-CjT76RAw.js} +1 -1
- package/editor-web/assets/{dist-elglzHMT.js → dist-CpzEn9T8.js} +1 -1
- package/editor-web/assets/dist-CrFYWl5-.js +3 -0
- package/editor-web/assets/{dist-hHcrvNn9.js → dist-D4eBFGVL.js} +1 -1
- package/editor-web/assets/dist-DTcjb3cP.js +18 -0
- package/editor-web/assets/dist-D_WSM29I.js +17 -0
- package/editor-web/assets/{dist-Y_XZZa8q.js → dist-Dp_9ISjP.js} +10 -10
- package/editor-web/assets/{dist-BBshIz1Q.js → dist-J-tPYKGS.js} +4 -4
- package/editor-web/assets/{docx-draw-C4aiB8HI.js → docx-draw-CoK1oqQD.js} +1 -1
- package/editor-web/assets/{ebnfDiagram-V4P3TTPT-HRjVlbUf.js → ebnfDiagram-V4P3TTPT-BaKj-yL6.js} +1 -1
- package/editor-web/assets/{elk-QONTBCTQ-BFmtKyOf.js → elk-QONTBCTQ-Cn2qv1_U.js} +1 -1
- package/editor-web/assets/{erDiagram-KYQIGQAA-C9gcGEgK.js → erDiagram-KYQIGQAA-Bd7AEIDo.js} +1 -1
- package/editor-web/assets/{esm-DzxAod8Q.js → esm-Cjv8ogpP.js} +1 -1
- package/editor-web/assets/{eventmodeling-K75KTNOO-Bpma5Bdb.js → eventmodeling-K75KTNOO-Sfp7_461.js} +1 -1
- package/editor-web/assets/flowDiagram-IUGLLWBU-BlVUglzw.js +1 -0
- package/editor-web/assets/{ganttDiagram-R7GPNTJY-CE5ut4C3.js → ganttDiagram-R7GPNTJY-CBqcGdHI.js} +1 -1
- package/editor-web/assets/{gitGraph-VSP46ZUC-Dva3iGx2.js → gitGraph-VSP46ZUC-WTokXKTW.js} +1 -1
- package/editor-web/assets/{gitGraphDiagram-PDYL7XHY-CJXFsAWp.js → gitGraphDiagram-PDYL7XHY-BIWZHD9q.js} +1 -1
- package/editor-web/assets/index-BQWZnyAQ.js +28 -0
- package/editor-web/assets/{info-OHQRW6UA-BY0AOfex.js → info-OHQRW6UA-COC6G-_J.js} +1 -1
- package/editor-web/assets/{infoDiagram-MVDRKAX5-4Up1gMvC.js → infoDiagram-MVDRKAX5-DpaqdKBD.js} +1 -1
- package/editor-web/assets/{ishikawaDiagram-HPEHV2GE-BkvB9Qbn.js → ishikawaDiagram-HPEHV2GE-Dyn2MAy1.js} +1 -1
- package/editor-web/assets/{iso-ahTwmFwH.js → iso-DoC-ZoBr.js} +1 -1
- package/editor-web/assets/{journeyDiagram-BOSHW7O7-BxV09WdR.js → journeyDiagram-BOSHW7O7-DeSVfmm7.js} +1 -1
- package/editor-web/assets/{kanban-definition-FNSA4HC5-zTJtIDPG.js → kanban-definition-FNSA4HC5-Bfg0lj7B.js} +1 -1
- package/editor-web/assets/{mermaid-parser.core-BWT9UQh_.js → mermaid-parser.core-CyhovuYE.js} +3 -3
- package/editor-web/assets/{mermaid.core-DFf_Vg5X.js → mermaid.core-Dx1fBVUG.js} +4 -4
- package/editor-web/assets/{mindmap-definition-6OY57UG3-BYexiugS.js → mindmap-definition-6OY57UG3-QEU2HF_m.js} +1 -1
- package/editor-web/assets/{packet-JDAUHWVQ-DX_kSrI6.js → packet-JDAUHWVQ-ReJTa_hw.js} +1 -1
- package/editor-web/assets/{pegDiagram-ECIUJNBX-I3SrcMLp.js → pegDiagram-ECIUJNBX-Bo1jFrvb.js} +1 -1
- package/editor-web/assets/{pie-XZMESJXO-BmAFSw3E.js → pie-XZMESJXO-BrtYafNA.js} +1 -1
- package/editor-web/assets/{pieDiagram-GNMPY74T-DIZKcme5.js → pieDiagram-GNMPY74T-Cj0zQqs_.js} +1 -1
- package/editor-web/assets/{props-form-DUFxM5eb.js → props-form-BpSXbrSF.js} +1 -1
- package/editor-web/assets/{quadrantDiagram-D57K4MC3-CO3oSqpQ.js → quadrantDiagram-D57K4MC3-D5npDAVn.js} +1 -1
- package/editor-web/assets/{radar-ABXABTNO-D5CkFrrb.js → radar-ABXABTNO-C8RDrRqi.js} +1 -1
- package/editor-web/assets/{railroad-I3PHUGI6-BeKY1p0K.js → railroad-I3PHUGI6-ebDrmYTK.js} +1 -1
- package/editor-web/assets/{railroad-abnf-LNEFI6M7-CIYV9_3-.js → railroad-abnf-LNEFI6M7-BxKuqg6V.js} +1 -1
- package/editor-web/assets/{railroad-ebnf-DWYD2UWJ-DN0zDl6d.js → railroad-ebnf-DWYD2UWJ-DOclnfpr.js} +1 -1
- package/editor-web/assets/{railroad-peg-JR7BVNR7-Bd_GcO24.js → railroad-peg-JR7BVNR7-DN0A1fpq.js} +1 -1
- package/editor-web/assets/{railroadDiagram-Y72NRBL7-DlFoiMhb.js → railroadDiagram-Y72NRBL7-B3PjoVWw.js} +1 -1
- package/editor-web/assets/{requirementDiagram-EQYSW5RA-LWAEz8Gy.js → requirementDiagram-EQYSW5RA-DLdzkQk5.js} +1 -1
- package/editor-web/assets/{sankeyDiagram-SY24JHO5-B_pZGwUK.js → sankeyDiagram-SY24JHO5-Dip4Piv_.js} +1 -1
- package/editor-web/assets/schemas-CQ_UU8-Z.js +1 -0
- package/editor-web/assets/{sequenceDiagram-BLEHNHQU-bNhyCq0C.js → sequenceDiagram-BLEHNHQU-QnPcoybL.js} +1 -1
- package/editor-web/assets/{session-Beijw9EK.js → session-DMlLCFWg.js} +1 -1
- package/editor-web/assets/slides-7xWhREpt.js +1 -0
- package/editor-web/assets/snapshots-BLX4NTQC.js +1 -0
- package/editor-web/assets/{split-zARio3J8.js → split-tFGKk-x8.js} +1 -1
- package/editor-web/assets/{stateDiagram-v2-A6IESKWZ-DI-oM3qz.js → stateDiagram-v2-A6IESKWZ-D103CiMX.js} +1 -1
- package/editor-web/assets/{swimlanes-B3ENRKFQ-awDmoLdW.js → swimlanes-B3ENRKFQ-y4gCqEoa.js} +1 -1
- package/editor-web/assets/swimlanesDiagram-AYQRV4AK-DKzB_wSf.js +8 -0
- package/editor-web/assets/{tabs-BHBvbekZ.js → tabs-CuEawka3.js} +1 -1
- package/editor-web/assets/{timeline-definition-JXYKGLGB-CayduPvL.js → timeline-definition-JXYKGLGB-BMp76v4V.js} +1 -1
- package/editor-web/assets/{treeView-D4JQ5SDB-BVEuNzCO.js → treeView-D4JQ5SDB-Q_GYyk0b.js} +1 -1
- package/editor-web/assets/{treemap-SAJKECNS-BOB14HP3.js → treemap-SAJKECNS-B5lRWdQB.js} +1 -1
- package/editor-web/assets/{usecaseDiagram-WPOLBNNX-DxT99uaq.js → usecaseDiagram-WPOLBNNX--QRllA-U.js} +1 -1
- package/editor-web/assets/{vennDiagram-Q3Y3IDCW-CWUKom-r.js → vennDiagram-Q3Y3IDCW-CzkATPA3.js} +1 -1
- package/editor-web/assets/{video-oJ3qa1Qv.js → video-D0uTbHWx.js} +1 -1
- package/editor-web/assets/{wardley-7MLQ67FV-BAQyTneD.js → wardley-7MLQ67FV-BXzwcdJa.js} +1 -1
- package/editor-web/assets/{wardleyDiagram-IVAIDKWA-CiIYz4lZ.js → wardleyDiagram-IVAIDKWA-BQvC8Agx.js} +1 -1
- package/editor-web/assets/{words-0Ww2RyT4.js → words-CaUHhQHf.js} +1 -1
- package/editor-web/assets/workbook-CiCXkjmN.js +45 -0
- package/editor-web/assets/{xychartDiagram-4URNHDU4-D_D5IGmd.js → xychartDiagram-4URNHDU4-aY-lsD5o.js} +1 -1
- package/editor-web/index.html +3 -3
- package/package.json +2 -2
- package/dist/node_modules/@allyhub/browser/dist/browser.d.ts +0 -24
- package/dist/node_modules/@allyhub/browser/dist/capture.d.ts +0 -61
- package/dist/node_modules/@allyhub/browser/dist/cdp.d.ts +0 -51
- package/dist/node_modules/@allyhub/browser/dist/emoji.d.ts +0 -29
- package/dist/node_modules/@allyhub/browser/dist/flags.d.ts +0 -13
- package/dist/node_modules/@allyhub/browser/dist/frames.d.ts +0 -35
- package/dist/node_modules/@allyhub/browser/dist/html.d.ts +0 -19
- package/dist/node_modules/@allyhub/browser/dist/index.d.ts +0 -10
- package/dist/node_modules/@allyhub/browser/dist/launch.d.ts +0 -35
- package/dist/node_modules/@allyhub/browser/dist/page.d.ts +0 -74
- package/dist/node_modules/@allyhub/browser/dist/picture.d.ts +0 -18
- package/dist/node_modules/@allyhub/browser/dist/server.d.ts +0 -26
- package/dist/node_modules/@allyhub/build/dist/build-plugins.d.ts +0 -91
- package/dist/node_modules/@allyhub/build/dist/cli-command.d.ts +0 -84
- package/dist/node_modules/@allyhub/build/dist/code.d.ts +0 -26
- package/dist/node_modules/@allyhub/build/dist/content.d.ts +0 -64
- package/dist/node_modules/@allyhub/build/dist/data.d.ts +0 -11
- package/dist/node_modules/@allyhub/build/dist/evaluate.d.ts +0 -44
- package/dist/node_modules/@allyhub/build/dist/file-check.d.ts +0 -35
- package/dist/node_modules/@allyhub/build/dist/files.d.ts +0 -4
- package/dist/node_modules/@allyhub/build/dist/fonts.d.ts +0 -26
- package/dist/node_modules/@allyhub/build/dist/generated.d.ts +0 -29
- package/dist/node_modules/@allyhub/build/dist/imports.d.ts +0 -17
- package/dist/node_modules/@allyhub/build/dist/index.d.ts +0 -37
- package/dist/node_modules/@allyhub/build/dist/inspect-view.d.ts +0 -119
- package/dist/node_modules/@allyhub/build/dist/kind-build.d.ts +0 -530
- package/dist/node_modules/@allyhub/build/dist/made-notes.d.ts +0 -9
- package/dist/node_modules/@allyhub/build/dist/matrix.d.ts +0 -19
- package/dist/node_modules/@allyhub/build/dist/media.d.ts +0 -10
- package/dist/node_modules/@allyhub/build/dist/messages.d.ts +0 -60
- package/dist/node_modules/@allyhub/build/dist/meta-worker.d.ts +0 -59
- package/dist/node_modules/@allyhub/build/dist/meta.d.ts +0 -24
- package/dist/node_modules/@allyhub/build/dist/model-info.d.ts +0 -6
- package/dist/node_modules/@allyhub/build/dist/move-refs.d.ts +0 -16
- package/dist/node_modules/@allyhub/build/dist/places.d.ts +0 -23
- package/dist/node_modules/@allyhub/build/dist/plugin.d.ts +0 -50
- package/dist/node_modules/@allyhub/build/dist/prepare.d.ts +0 -138
- package/dist/node_modules/@allyhub/build/dist/project-root.d.ts +0 -19
- package/dist/node_modules/@allyhub/build/dist/project-tool.d.ts +0 -136
- package/dist/node_modules/@allyhub/build/dist/references.d.ts +0 -6
- package/dist/node_modules/@allyhub/build/dist/scan.d.ts +0 -45
- package/dist/node_modules/@allyhub/build/dist/stage-route.d.ts +0 -80
- package/dist/node_modules/@allyhub/build/dist/takes.d.ts +0 -9
- package/dist/node_modules/@allyhub/build/dist/types.d.ts +0 -11
- package/dist/node_modules/@allyhub/build/dist/uses.d.ts +0 -44
- package/dist/node_modules/@allyhub/build/dist/version.d.ts +0 -56
- package/dist/node_modules/@allyhub/build/dist/vite.d.ts +0 -115
- package/dist/node_modules/@allyhub/build/dist/work.d.ts +0 -38
- package/dist/node_modules/@allyhub/cloud/dist/blobs.d.ts +0 -48
- package/dist/node_modules/@allyhub/cloud/dist/call.d.ts +0 -91
- package/dist/node_modules/@allyhub/cloud/dist/catalog.d.ts +0 -12
- package/dist/node_modules/@allyhub/cloud/dist/client.d.ts +0 -64
- package/dist/node_modules/@allyhub/cloud/dist/config.d.ts +0 -40
- package/dist/node_modules/@allyhub/cloud/dist/credentials.d.ts +0 -76
- package/dist/node_modules/@allyhub/cloud/dist/device.d.ts +0 -14
- package/dist/node_modules/@allyhub/cloud/dist/errors.d.ts +0 -24
- package/dist/node_modules/@allyhub/cloud/dist/hashes.d.ts +0 -43
- package/dist/node_modules/@allyhub/cloud/dist/index.d.ts +0 -19
- package/dist/node_modules/@allyhub/cloud/dist/keychain.d.ts +0 -18
- package/dist/node_modules/@allyhub/cloud/dist/loopback.d.ts +0 -22
- package/dist/node_modules/@allyhub/cloud/dist/mail.d.ts +0 -16
- package/dist/node_modules/@allyhub/cloud/dist/pkce.d.ts +0 -11
- package/dist/node_modules/@allyhub/cloud/dist/records.d.ts +0 -42
- package/dist/node_modules/@allyhub/cloud/dist/signin-worker.d.ts +0 -2
- package/dist/node_modules/@allyhub/cloud/dist/signin.d.ts +0 -48
- package/dist/node_modules/@allyhub/cloud/dist/sites.d.ts +0 -20
- package/dist/node_modules/@allyhub/cloud/dist/token.d.ts +0 -20
- package/dist/node_modules/@allyhub/cloud/dist/uploads.d.ts +0 -58
- package/dist/node_modules/@allyhub/cloud/dist/voice.d.ts +0 -22
- package/dist/node_modules/@allyhub/jobs/dist/index.d.ts +0 -3
- package/dist/node_modules/@allyhub/jobs/dist/jobs.d.ts +0 -139
- package/dist/node_modules/@allyhub/jobs/dist/show.d.ts +0 -41
- package/dist/node_modules/@allyhub/measure/dist/compare.d.ts +0 -195
- package/dist/node_modules/@allyhub/measure/dist/grain.d.ts +0 -8
- package/dist/node_modules/@allyhub/measure/dist/image.d.ts +0 -16
- package/dist/node_modules/@allyhub/measure/dist/index.d.ts +0 -4
- package/dist/node_modules/@allyhub/media/dist/analysis.d.ts +0 -25
- package/dist/node_modules/@allyhub/media/dist/audio.d.ts +0 -16
- package/dist/node_modules/@allyhub/media/dist/beats.d.ts +0 -100
- package/dist/node_modules/@allyhub/media/dist/cache.d.ts +0 -26
- package/dist/node_modules/@allyhub/media/dist/errors.d.ts +0 -34
- package/dist/node_modules/@allyhub/media/dist/fetch.d.ts +0 -11
- package/dist/node_modules/@allyhub/media/dist/grid.d.ts +0 -101
- package/dist/node_modules/@allyhub/media/dist/index.d.ts +0 -21
- package/dist/node_modules/@allyhub/media/dist/picture.d.ts +0 -130
- package/dist/node_modules/@allyhub/media/dist/probe.d.ts +0 -52
- package/dist/node_modules/@allyhub/media/dist/progress.d.ts +0 -16
- package/dist/node_modules/@allyhub/media/dist/run.d.ts +0 -25
- package/dist/node_modules/@allyhub/media/dist/sheet.d.ts +0 -67
- package/dist/node_modules/@allyhub/media/dist/shots.d.ts +0 -110
- package/dist/node_modules/@allyhub/media/dist/sync.d.ts +0 -156
- package/dist/node_modules/@allyhub/media/dist/tools.d.ts +0 -25
- package/dist/node_modules/@allyhub/media/dist/video.d.ts +0 -35
- package/dist/node_modules/@allyhub/media/dist/vision/cache.d.ts +0 -42
- package/dist/node_modules/@allyhub/media/dist/vision/probe.d.ts +0 -39
- package/dist/node_modules/@allyhub/media/dist/vision/types.d.ts +0 -2
- package/dist/node_modules/@allyhub/media/dist/voice-shape.d.ts +0 -51
- package/dist/node_modules/@allyhub/model/dist/authoring.d.ts +0 -48
- package/dist/node_modules/@allyhub/model/dist/bevel-attributes.d.ts +0 -19
- package/dist/node_modules/@allyhub/model/dist/bevel-collapse.d.ts +0 -12
- package/dist/node_modules/@allyhub/model/dist/bevel-corner-plan.d.ts +0 -24
- package/dist/node_modules/@allyhub/model/dist/bevel-deform.d.ts +0 -5
- package/dist/node_modules/@allyhub/model/dist/bevel-fans.d.ts +0 -12
- package/dist/node_modules/@allyhub/model/dist/bevel-junction.d.ts +0 -16
- package/dist/node_modules/@allyhub/model/dist/bevel-marks.d.ts +0 -14
- package/dist/node_modules/@allyhub/model/dist/bevel-metric.d.ts +0 -4
- package/dist/node_modules/@allyhub/model/dist/bevel-mixed.d.ts +0 -12
- package/dist/node_modules/@allyhub/model/dist/bevel-offsets.d.ts +0 -22
- package/dist/node_modules/@allyhub/model/dist/bevel-patch.d.ts +0 -45
- package/dist/node_modules/@allyhub/model/dist/bevel-profile.d.ts +0 -13
- package/dist/node_modules/@allyhub/model/dist/bevel-projection.d.ts +0 -10
- package/dist/node_modules/@allyhub/model/dist/bevel-reflex.d.ts +0 -10
- package/dist/node_modules/@allyhub/model/dist/bevel-square-out.d.ts +0 -18
- package/dist/node_modules/@allyhub/model/dist/bevel-strips.d.ts +0 -8
- package/dist/node_modules/@allyhub/model/dist/bmesh-cycles.d.ts +0 -52
- package/dist/node_modules/@allyhub/model/dist/build-cache.d.ts +0 -42
- package/dist/node_modules/@allyhub/model/dist/build-job.d.ts +0 -34
- package/dist/node_modules/@allyhub/model/dist/build-worker.d.ts +0 -2
- package/dist/node_modules/@allyhub/model/dist/build.d.ts +0 -67
- package/dist/node_modules/@allyhub/model/dist/cancel.d.ts +0 -8
- package/dist/node_modules/@allyhub/model/dist/curve-math.d.ts +0 -21
- package/dist/node_modules/@allyhub/model/dist/curve-mesh.d.ts +0 -30
- package/dist/node_modules/@allyhub/model/dist/evaluation-guard.d.ts +0 -11
- package/dist/node_modules/@allyhub/model/dist/export.d.ts +0 -12
- package/dist/node_modules/@allyhub/model/dist/mesh-queries.d.ts +0 -34
- package/dist/node_modules/@allyhub/model/dist/names.d.ts +0 -9
- package/dist/node_modules/@allyhub/model/dist/png.d.ts +0 -12
- package/dist/node_modules/@allyhub/model/dist/polygon-triangulation.d.ts +0 -4
- package/dist/node_modules/@allyhub/model/dist/program-location.d.ts +0 -7
- package/dist/node_modules/@allyhub/model/dist/report.d.ts +0 -70
- package/dist/node_modules/@allyhub/piece/dist/page/console.d.ts +0 -21
- package/dist/node_modules/@allyhub/piece/dist/page/index.d.ts +0 -4
- package/dist/node_modules/@allyhub/piece/dist/page/locate.d.ts +0 -17
- package/dist/node_modules/@allyhub/piece/dist/page/runtimes.d.ts +0 -9
- package/dist/node_modules/@allyhub/protocol/dist/account.d.ts +0 -661
- package/dist/node_modules/@allyhub/protocol/dist/account.js +0 -2
- package/dist/node_modules/@allyhub/protocol/dist/app.d.ts +0 -30
- package/dist/node_modules/@allyhub/protocol/dist/auth.d.ts +0 -200
- package/dist/node_modules/@allyhub/protocol/dist/blobs.d.ts +0 -44
- package/dist/node_modules/@allyhub/protocol/dist/cli.d.ts +0 -68
- package/dist/node_modules/@allyhub/protocol/dist/cloud-computer.d.ts +0 -77
- package/dist/node_modules/@allyhub/protocol/dist/cloud-computer.js +0 -2
- package/dist/node_modules/@allyhub/protocol/dist/cloud.d.ts +0 -577
- package/dist/node_modules/@allyhub/protocol/dist/editor.d.ts +0 -674
- package/dist/node_modules/@allyhub/protocol/dist/errors.d.ts +0 -7
- package/dist/node_modules/@allyhub/protocol/dist/events.d.ts +0 -803
- package/dist/node_modules/@allyhub/protocol/dist/files.d.ts +0 -103
- package/dist/node_modules/@allyhub/protocol/dist/frame.d.ts +0 -247
- package/dist/node_modules/@allyhub/protocol/dist/image.d.ts +0 -8
- package/dist/node_modules/@allyhub/protocol/dist/index.d.ts +0 -38
- package/dist/node_modules/@allyhub/protocol/dist/jobs.d.ts +0 -91
- package/dist/node_modules/@allyhub/protocol/dist/jsonrpc.d.ts +0 -83
- package/dist/node_modules/@allyhub/protocol/dist/kinds.d.ts +0 -144
- package/dist/node_modules/@allyhub/protocol/dist/mail.d.ts +0 -274
- package/dist/node_modules/@allyhub/protocol/dist/notes.d.ts +0 -211
- package/dist/node_modules/@allyhub/protocol/dist/open.d.ts +0 -13
- package/dist/node_modules/@allyhub/protocol/dist/paywall.d.ts +0 -134
- package/dist/node_modules/@allyhub/protocol/dist/peer.d.ts +0 -59
- package/dist/node_modules/@allyhub/protocol/dist/peer.js +0 -2
- package/dist/node_modules/@allyhub/protocol/dist/place.d.ts +0 -21
- package/dist/node_modules/@allyhub/protocol/dist/presence.d.ts +0 -125
- package/dist/node_modules/@allyhub/protocol/dist/purposes.d.ts +0 -47
- package/dist/node_modules/@allyhub/protocol/dist/registry.d.ts +0 -191
- package/dist/node_modules/@allyhub/protocol/dist/routes.d.ts +0 -14
- package/dist/node_modules/@allyhub/protocol/dist/routes.js +0 -2
- package/dist/node_modules/@allyhub/protocol/dist/runtimes.d.ts +0 -96
- package/dist/node_modules/@allyhub/protocol/dist/shape.d.ts +0 -35
- package/dist/node_modules/@allyhub/protocol/dist/shape.js +0 -2
- package/dist/node_modules/@allyhub/protocol/dist/shares.d.ts +0 -156
- package/dist/node_modules/@allyhub/protocol/dist/shares.js +0 -2
- package/dist/node_modules/@allyhub/protocol/dist/sidebar-deletion.d.ts +0 -34
- package/dist/node_modules/@allyhub/protocol/dist/sidebar-deletion.js +0 -2
- package/dist/node_modules/@allyhub/protocol/dist/sites.d.ts +0 -298
- package/dist/node_modules/@allyhub/protocol/dist/snapshots.d.ts +0 -503
- package/dist/node_modules/@allyhub/protocol/dist/sources.d.ts +0 -14
- package/dist/node_modules/@allyhub/protocol/dist/studio-server.d.ts +0 -264
- package/dist/node_modules/@allyhub/protocol/dist/studio-server.js +0 -2
- package/dist/node_modules/@allyhub/protocol/dist/studio-tool-calls.d.ts +0 -18
- package/dist/node_modules/@allyhub/protocol/dist/studio-tool-calls.js +0 -2
- package/dist/node_modules/@allyhub/protocol/dist/studio-window-requests.d.ts +0 -97
- package/dist/node_modules/@allyhub/protocol/dist/studio-window-requests.js +0 -2
- package/dist/node_modules/@allyhub/protocol/dist/teams.d.ts +0 -196
- package/dist/node_modules/@allyhub/protocol/dist/tools.d.ts +0 -578
- package/dist/node_modules/@allyhub/protocol/dist/turns.d.ts +0 -71
- package/dist/node_modules/@allyhub/protocol/dist/turns.js +0 -2
- package/dist/node_modules/@allyhub/runtimes/dist/bundled.d.ts +0 -10
- package/dist/node_modules/@allyhub/runtimes/dist/declared.d.ts +0 -14
- package/dist/node_modules/@allyhub/runtimes/dist/download.d.ts +0 -38
- package/dist/node_modules/@allyhub/runtimes/dist/errors.d.ts +0 -20
- package/dist/node_modules/@allyhub/runtimes/dist/ffmpeg.d.ts +0 -15
- package/dist/node_modules/@allyhub/runtimes/dist/home.d.ts +0 -2
- package/dist/node_modules/@allyhub/runtimes/dist/index.d.ts +0 -12
- package/dist/node_modules/@allyhub/runtimes/dist/lock.d.ts +0 -14
- package/dist/node_modules/@allyhub/runtimes/dist/manifest.d.ts +0 -3
- package/dist/node_modules/@allyhub/runtimes/dist/node-program.d.ts +0 -12
- package/dist/node_modules/@allyhub/runtimes/dist/packages.d.ts +0 -101
- package/dist/node_modules/@allyhub/runtimes/dist/runtimes.d.ts +0 -73
- package/dist/node_modules/@allyhub/runtimes/dist/unpack.d.ts +0 -14
- package/dist/node_modules/@allyhub/scenery-host/dist/allyhub.d.ts +0 -20
- package/dist/node_modules/@allyhub/scenery-host/dist/bake/digest.d.ts +0 -14
- package/dist/node_modules/@allyhub/scenery-host/dist/bake/envmap.d.ts +0 -21
- package/dist/node_modules/@allyhub/scenery-host/dist/bake/run.d.ts +0 -63
- package/dist/node_modules/@allyhub/scenery-host/dist/budget.d.ts +0 -40
- package/dist/node_modules/@allyhub/scenery-host/dist/bundle.d.ts +0 -92
- package/dist/node_modules/@allyhub/scenery-host/dist/commands.d.ts +0 -54
- package/dist/node_modules/@allyhub/scenery-host/dist/draw2d.d.ts +0 -47
- package/dist/node_modules/@allyhub/scenery-host/dist/glass.d.ts +0 -39
- package/dist/node_modules/@allyhub/scenery-host/dist/index.d.ts +0 -25
- package/dist/node_modules/@allyhub/scenery-host/dist/inventory.d.ts +0 -18
- package/dist/node_modules/@allyhub/scenery-host/dist/layer/fidelity.d.ts +0 -70
- package/dist/node_modules/@allyhub/scenery-host/dist/layer/grade.d.ts +0 -7
- package/dist/node_modules/@allyhub/scenery-host/dist/layer/moire.d.ts +0 -6
- package/dist/node_modules/@allyhub/scenery-host/dist/measure/contacts.d.ts +0 -45
- package/dist/node_modules/@allyhub/scenery-host/dist/measure/health.d.ts +0 -10
- package/dist/node_modules/@allyhub/scenery-host/dist/measure/index.d.ts +0 -110
- package/dist/node_modules/@allyhub/scenery-host/dist/measure/relations.d.ts +0 -17
- package/dist/node_modules/@allyhub/scenery-host/dist/measure/solid.d.ts +0 -32
- package/dist/node_modules/@allyhub/scenery-host/dist/measure/support.d.ts +0 -11
- package/dist/node_modules/@allyhub/scenery-host/dist/model-stage.d.ts +0 -32
- package/dist/node_modules/@allyhub/scenery-host/dist/queries/inventory.d.ts +0 -5
- package/dist/node_modules/@allyhub/scenery-host/dist/queries/map.d.ts +0 -5
- package/dist/node_modules/@allyhub/scenery-host/dist/queries/view.d.ts +0 -10
- package/dist/node_modules/@allyhub/scenery-host/dist/scene.d.ts +0 -35
- package/dist/node_modules/@allyhub/scenery-host/dist/screen-dom.d.ts +0 -24
- package/dist/node_modules/@allyhub/scenery-host/dist/stage/bakes.d.ts +0 -42
- package/dist/node_modules/@allyhub/scenery-host/dist/stage/index.d.ts +0 -6
- package/dist/node_modules/@allyhub/scenery-host/dist/stage/page.d.ts +0 -70
- package/dist/node_modules/@allyhub/scenery-host/dist/stage/solve.d.ts +0 -49
- package/dist/node_modules/@allyhub/scenery-host/dist/stage/version.d.ts +0 -73
- package/dist/node_modules/@allyhub/scenery-host/dist/stage/view.d.ts +0 -18
- package/dist/node_modules/@allyhub/scenery-host/dist/steady.d.ts +0 -4
- package/dist/node_modules/@allyhub/scenery-host/dist/viewer.d.ts +0 -134
- package/editor-web/assets/channel-HUlo15J7.js +0 -1
- package/editor-web/assets/deck-CtEtDHo2.js +0 -1
- package/editor-web/assets/dist-Bl74xqMW.js +0 -19
- package/editor-web/assets/dist-BrUtQth3.js +0 -18
- package/editor-web/assets/dist-CN5A7Au2.js +0 -1
- package/editor-web/assets/dist-CcL6r6l3.js +0 -1
- package/editor-web/assets/dist-D2E3cgRP.js +0 -4
- package/editor-web/assets/dist-ZrBAbqyJ.js +0 -3
- package/editor-web/assets/dist-d4dayaWE.js +0 -17
- package/editor-web/assets/flowDiagram-IUGLLWBU-tz5ewhC5.js +0 -1
- package/editor-web/assets/index-q7X6hdHp.js +0 -28
- package/editor-web/assets/schemas-moE_A7Nj.js +0 -1
- package/editor-web/assets/slides-oQ_C0SVJ.js +0 -1
- package/editor-web/assets/snapshots-Dd0Wd_qM.js +0 -1
- package/editor-web/assets/swimlanesDiagram-AYQRV4AK-X35m3xN6.js +0 -8
- package/editor-web/assets/workbook-DznVDqoE.js +0 -45
- /package/dist/node_modules/@allyhub/{protocol/dist/runtimes.js → runtimes/dist/schema.js} +0 -0
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import{i as e,n as t,t as n}from"./rolldown-runtime-COiEfhsA.js";import{t as r}from"./schemas-moE_A7Nj.js";import{r as i}from"./csv-Bwre9FdI.js";import{d as a,f as o,g as s,h as c,m as l,o as u,p as d,s as f,u as p}from"./chart-amT4lgX3.js";import{t as m}from"./svg-CWIBMIQ9.js";import{a as h,c as g,d as _,f as v,i as ee,n as y,u as b}from"./browser-C9NP0ZYz.js";var x=1048576,te=16384;function ne(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 re(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 S=e=>`${ne(e.col)}${String(e.row+1)}`;function C(e){let t=S({row:e.top,col:e.left});return e.top===e.bottom&&e.left===e.right?t:`${t}:${S({row:e.bottom,col:e.right})}`}function ie(e){let t=/^\$?([A-Za-z]{1,3})\$?([1-9]\d*)$/u.exec(e.trim());if(!t)return;let n=re(t[1]??``),r=Number(t[2])-1;return n===void 0||r>=1048576?void 0:{row:r,col:n}}function w(e){let[t=``,n,r]=e.split(`:`);if(r!==void 0)return;let i=ie(t),a=n===void 0?i:ie(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 ae(e){let t=[];for(let n of e.trim().split(/\s+/u)){let e=w(n);if(!e)return;t.push(e)}return t}var oe=(e,t,n)=>t>=e.top&&t<=e.bottom&&n>=e.left&&n<=e.right,T=(e,t)=>e.top<=t.bottom&&t.top<=e.bottom&&e.left<=t.right&&t.left<=e.right,E=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}},D={NULL:E.of(`#NULL!`),DIV0:E.of(`#DIV/0!`),VALUE:E.of(`#VALUE!`),REF:E.of(`#REF!`),NAME:E.of(`#NAME?`),NUM:E.of(`#NUM!`),NA:E.of(`#N/A`),SPILL:E.of(`#SPILL!`),CALC:E.of(`#CALC!`),CYCLE:E.of(`#CYCLE!`)},se=[`#NULL!`,`#DIV/0!`,`#VALUE!`,`#REF!`,`#NAME?`,`#NUM!`,`#N/A`,`#GETTING_DATA`,`#SPILL!`,`#CALC!`,`#CYCLE!`];function ce(e){let t=e.toUpperCase(),n=se.find(e=>e===t);return n===void 0?void 0:E.of(n)}var O=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}},le=864e5,ue=25569;function de(e){let t=e+ue;return t<61?t-1:t}function fe(e){let t=Math.floor(e);if(t!==60)return(t<60?t+1:t)-ue}function pe(e,t,n){let r=new Date(Date.UTC(2e3,t-1,1));return r.setUTCFullYear(r.getUTCFullYear()-2e3+e),de(Math.floor(r.getTime()/le))+n-1}function me(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}:he(t)}function he(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 ge(e){let t=e.getTime(),n=Math.floor(t/le);return de(n)+(t-n*le)/le}function _e(e){let t=fe(e);if(t===void 0)return;let n=e-Math.floor(e);return new Date(t*le+Math.round(n*le))}var ve=(e,t=2)=>String(e).padStart(t,`0`);function ye(e){let{year:t,month:n,day:r}=me(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 be(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 xe=/^[+-]?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?$/u,Se=/^[+-]?\d{1,3}(?:,\d{3})+(?:\.\d+)?$/u,Ce=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?)?$/u,we=e=>/^[+-]?\d+$/u.test(e)&&e.replace(/^[+-]?0*/u,``).length>15;function Te(e){let t=Ce.exec(e);if(!t)return;let[n,r,i]=[Number(t[1]),Number(t[2]),Number(t[3])],a=pe(n,r,i),o=me(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 Ee(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 De(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(xe.test(t))return we(t)?{value:e}:{value:Number(t)};if(t.endsWith(`%`)){let e=t.slice(0,-1).trim();if(xe.test(e))return{value:Number(e)/100,format:e.includes(`.`)?`0.00%`:`0%`}}if(Se.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=Te(t);if(a)return a;let o=Ee(t);if(o)return o;let s=ce(t);return s?{value:s}:{value:e}}function Oe(e){if(e===null)return``;if(typeof e==`number`){let t=String(e);return we(t)?e.toExponential():t}if(typeof e==`boolean`)return e?`TRUE`:`FALSE`;if(e instanceof E)return e.code;let t=De(e);return t.value===e&&t.formula===void 0?e:`'${e}`}function ke(e){let t=p(`General`,e),n=[t];for(let r=10;r>=1;r--){let i=p(`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 Ae(e,t){let n=ke(e);return t?n.find(t):n[0]}function je(e,t){if(e===null)return``;if(e instanceof E)return e.code;if(typeof e==`boolean`)return e?`TRUE`:`FALSE`;let n=t??`General`;if(typeof e==`string`)return t!==void 0&&d(t)?p(t,e):e;if(n===`General`||!d(n))return Ae(e)??be(e);try{return p(n,e)}catch{return Ae(e)??be(e)}}function Me(e,t){if(typeof e!=`number`||t===void 0||!d(t))return;let n=a(t,e);return typeof n==`string`?n:void 0}var Ne=e=>e!==void 0&&d(e)&&o(e),k=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)}`}},Pe=class{parts;constructor(e){this.parts=e}},Fe=class{params;body;frame;named;constructor(e,t,n,r){this.params=e,this.body=t,this.frame=n,this.named=r}},A=class{missing=!0},Ie=new A;function Le(e,t){for(let n of t)e.push(n)}var Re=e=>`${e.abs?`$`:``}${ne(e.index)}`,ze=e=>`${e.abs?`$`:``}${String(e.index+1)}`;function Be(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 Ve(e){let t=e.sheet===void 0?``:Be(e.sheet,e.lastSheet);if(e.row===void 0&&e.col&&e.col2)return`${t}${Re(e.col)}:${Re(e.col2)}`;if(e.col===void 0&&e.row&&e.row2)return`${t}${ze(e.row)}:${ze(e.row2)}`;if(!e.col||!e.row)return`${t}#REF!`;let n=`${Re(e.col)}${ze(e.row)}`;return e.col2&&e.row2?`${t}${n}:${Re(e.col2)}${ze(e.row2)}`:`${t}${n}`}var He=e=>e.replace(/([[\]#'@])/gu,`'$1`),Ue=e=>/^[\p{L}\p{N}_]+$/u.test(e);function We(e){let t=e.table??``,[n,r]=e.columns,i=e.columns.map(e=>`[${He(e)}]`).join(`:`);if(e.sections.length===0)return e.thisRow?n===void 0?`${t}[@]`:r===void 0?`${t}[@${Ue(n)?He(n):i}]`:`${t}[@${i}]`:n===void 0?t===``?`[]`:t:r===void 0?`${t}[${He(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 Ge(e){let{before:t=``,after:n=``}=e.space??{};return`${t}${Ke(e)}${n}`}function Ke(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?``:Be(e.sheet)}${e.code}`;case`missing`:return``;case`ref`:return Ve(e);case`structured`:return We(e);case`name`:return`${e.sheet===void 0?``:Be(e.sheet)}${e.name}`;case`unary`:return`${e.op}${Ge(e.arg)}`;case`postfix`:return`${Ge(e.arg)}${e.op}`;case`binary`:return`${Ge(e.left)}${t}${e.op}${Ge(e.right)}`;case`call`:return`${e.written}(${e.args.map(Ge).join(`,`)}${t})`;case`invoke`:return`${Ge(e.callee)}(${e.args.map(Ge).join(`,`)}${t})`;case`array`:return`{${e.rows.map(e=>e.map(Ge).join(`,`)).join(`;`)}}`;case`paren`:return`(${Ge(e.arg)}${t})`}}var qe=e=>`=${Ge(e)}`,Je={width:480,height:288,size:9,titleSize:14,ink:`#595959`,pixelsToPoints:.75};function Ye(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?.[ne(r)]?.hidden!==!0&&i.push({value:e.value(n,s,r),sheet:n,row:s,col:r});return i};if(i instanceof k)return a(i);if(i instanceof Pe)return i.parts.flatMap(a);if(i instanceof O)return i.data.map(e=>({value:e}));let o=e.flat(i);return o instanceof O?o.data.map(e=>({value:e})):[{value:o}]}var Xe=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 je(e.value,t)};function Ze(e){return typeof e==`number`?Number.isFinite(e)?e:null:e===null||e instanceof E?null:typeof e==`boolean`?+!!e:0}var Qe=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}},$e=e=>e===void 0?void 0:{rgb:e};function et(e){if(e===void 0||e===!1)return;if(e===!0)return{show_value:!0};let t=typeof e.color==`string`?$e(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 nt(e,t,n){let{spec:r}=n,i=f(r.type),a=n.categories?Ye(e,t,n.categories):void 0,o=n.series.map((n,o)=>{let s=r.series[o],c=Ye(e,t,n.values),l=n.name?Ye(e,t,n.name)[0]:void 0,u=n.x?Ye(e,t,n.x):i?a:void 0,d=s.format??tt(c),f=$e(s.color);return{name:(l?Xe(l):s.name)??`Series${String(o+1)}`,values:c.map(e=>Ze(e.value)),...u?{x:u.map(e=>Ze(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=a?a.map(Xe):Array.from({length:s},(e,t)=>String(t+1)),l=n.title?Ye(e,t,n.title)[0]:void 0,u=l?Xe(l):r.title,d=et(r.labels),p=Qe(r.value_axis),m=Qe(r.category_axis),h=Qe(r.secondary_axis);return{type:r.type,categories:c,series:o,...u===void 0||u===``?{}:{title:u},...r.legend===void 0?{}:{legend:r.legend},...d?{labels:d}:{},...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},...p?{value_axis:p}:{},...m?{category_axis:m}:{},...h?{secondary_axis:h}:{},font_size:r.size??Je.size,title_size:r.title_size??Je.titleSize,font_color:$e(r.color)??{rgb:Je.ink}}}var rt=e=>({width:e.width??Je.width,height:e.height??Je.height}),it=(e,t,n,r={})=>m(e,t,n,{pointsPerPixel:Je.pixelsToPoints,...r});function at(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)},...r===void 0?{}:{name:r}}})}}function ot(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?``:Be(t.name)}${C(n)}`}var st=(e,t,n,r)=>typeof e.value(t,n,r)==`number`,ct=(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 lt(e,t,n,r,i){let a=r.bottom-r.top+1,o=r.right-r.left+1,s=t.tables.find(e=>oe(e.area,r.top,r.left)),c=e=>ot(n,t,e,s),l=f(i),d=a>1&&Array.from({length:o},(e,t)=>r.left+t).some(n=>!st(e,t,r.top,n)),p=o>1&&(l||Array.from({length:a-+!!d},(e,t)=>t).every(n=>ct(e,t,r.top+ +!!d+n,r.left)||e.value(t,r.top+ +!!d+n,r.left)===null)),m=r.top+ +!!d,h=r.left+ +!!p;if(m>r.bottom||h>r.right)return;let g=!l&&!u(i)&&r.right-h>r.bottom-m,_=[],v=(r,i)=>e.value(t,r,i)===null?void 0:`=${t===n?``:Be(t.name)}${S({row:r,col:i})}`,ee=g?{first:m,last:r.bottom}:{first:h,last:r.right};for(let e=ee.first;e<=ee.last;e++){let t=g?{top:e,left:h,bottom:e,right:r.right}:{top:m,left:e,bottom:r.bottom,right:e},n=g?p?v(e,r.left):void 0:d?v(r.top,e):void 0;_.push({values:c(t),...n===void 0?{}:{name:n}})}let y=g?d?{top:r.top,left:h,bottom:r.top,right:r.right}:void 0:p?{top:m,left:r.left,bottom:r.bottom,right:r.left}:void 0,b=_.length>1&&!u(i),x=u(i)?_.slice(0,1):_,te=x.length===1?x[0]?.name:void 0;return{type:i,...y?{categories:c(y)}:{},series:x,...b||u(i)?{legend:`bottom`}:{},...te===void 0?{}:{title:te}}}function ut(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 k?{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 dt(e,t,n){let r=[ut(e,t,n.categories),...n.series.flatMap(n=>[ut(e,t,n.values),ut(e,t,n.name),ut(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?``:Be(i.sheet.name)}${C(a)}`}function ft(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=w(n.slice(r+1).replaceAll(`$`,``));return a&&o?{sheet:a,area:o}:void 0}var pt=`sheet.yaml`,mt=`sheet.ts`;function ht(e){let{file:t}=_t(e);return[...new Set(t?.sheets.flatMap(e=>[...(e.tables??[]).map(e=>e.rows),...(e.blocks??[]).map(e=>e.rows)])??[])]}function gt(e){let t=[];return g(e,{Map(e,n){if(!b(n))return;let r=new Set;for(let e of n.items){let n=_(e.key)?String(e.key.value):void 0;if(n!==void 0){if(r.has(n)){let r=_(e.key)?e.key.range?.[0]??0:0;t.push({at:r,key:n})}else r.add(n)}}}}),t}function _t(e){let t=new ee,n=y(e,{lineCounter:t,uniqueKeys:!1}),i=e=>{for(let r=e.length;r>=0;r--){let i=n.getIn(e.slice(0,r),!0)?.range?.[0];if(i!==void 0)return t.linePos(i).line}},a=gt(n);if(n.errors.length>0||a.length>0)return{problems:[...n.errors.map(e=>({file:pt,line:t.linePos(e.pos[0]).line,message:`not YAML: ${e.message.split(`
|
|
2
|
-
`)[0]??``}`})),...a.map(e=>({file:pt,line:t.linePos(e.at).line,message:`not YAML: Map keys must be unique (${e.key})`}))],lineOf:i};let o=r(`sheet`,n.toJS()??{});return o.ok?{file:o.value,problems:[],lineOf:i}:{problems:o.problems.map(e=>{let t=i(e.path===``?[]:e.path.split(`.`).map(e=>/^\d+$/u.test(e)?Number(e):e));return{file:pt,...t===void 0?{}:{line:t},message:`${e.path===``?``:`${e.path}: `}${e.message}`}}),lineOf:i}}var vt=e=>e.toLowerCase();function yt(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=>vt(e.name))),i=t.sheets.filter(e=>!r.has(vt(e.name))),a=t.sheets.filter(e=>r.has(vt(e.name))).map(e=>e.name),o=new Set(Object.keys(e.names??{}).map(vt)),s=Object.entries(t.names??{}).filter(([e])=>!o.has(vt(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 bt=e=>[...(e.tables??[]).map(e=>e.rows),...(e.blocks??[]).map(e=>e.rows)],xt=e=>e.toLowerCase().replace(/[^\p{L}\p{N}]+/gu,`-`).replace(/^-|-$/gu,``);function St(e,t,n,r=()=>!1){let a=t.sheets.find(e=>vt(e.name)===vt(n));if(!a)return{rows:new Map,cells:[],whole:!1,refused:`no-sheet`};let o=new Map,s=new Map;for(let e of bt(a)){let n=t.csv[e];if(n===void 0)continue;let c=xt(`${a.name} ${e.split(`/`).pop()??``}`).replace(/-csv$/u,``),l=`${c}.csv`;for(let e=2;r(l)||o.has(l);e++)l=`${c}-${String(e)}.csv`;s.set(e,l),o.set(l,i(n).records.map(e=>e.end===e.start?[]:e.fields))}let c=e=>s.get(e)??e,l=structuredClone(a);for(let e of l.tables??[])e.rows=c(e.rows);for(let e of l.blocks??[])e.rows=c(e.rows);return{file:{...e.file,sheets:[...e.file.sheets,l]},rows:o,cells:[],whole:!0}}function Ct(e,t){return t(wt(e,t))}function wt(e,t){switch(e.kind){case`unary`:case`postfix`:case`paren`:{let n=Ct(e.arg,t);return n===e.arg?e:{...e,arg:n}}case`binary`:{let n=Ct(e.left,t),r=Ct(e.right,t);return n===e.left&&r===e.right?e:{...e,left:n,right:r}}case`call`:{let n=e.args.map(e=>Ct(e,t));return n.every((t,n)=>t===e.args[n])?e:{...e,args:n}}case`invoke`:{let n=Ct(e.callee,t),r=e.args.map(e=>Ct(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=>Ct(e,t)));return n.every((t,n)=>t.every((t,r)=>t===e.rows[n]?.[r]))?e:{...e,rows:n}}default:return e}}function Tt(e,t){switch(t(e),e.kind){case`unary`:case`postfix`:case`paren`:Tt(e.arg,t);break;case`binary`:Tt(e.left,t),Tt(e.right,t);break;case`call`:for(let n of e.args)Tt(n,t);break;case`invoke`:Tt(e.callee,t);for(let n of e.args)Tt(n,t);break;case`array`:for(let n of e.rows)for(let e of n)Tt(e,t)}}function Et(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 Dt(e,t,n){let r=e.col&&Et(e.col,n,16384),i=e.col2&&Et(e.col2,n,16384),a=e.row&&Et(e.row,t,1048576),o=e.row2&&Et(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 Ot(e,t,n){return t===0&&n===0?e:Ct(e,e=>e.kind===`ref`?Dt(e,t,n):e)}function kt(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 At=[`#All`,`#Data`,`#Headers`,`#Totals`,`#This Row`],jt=class extends Error{at;constructor(e,t){super(e),this.at=t}},Mt=new Set([`=`,`<>`,`<`,`<=`,`>`,`>=`]),Nt={"=":1,"<>":1,"<":1,"<=":1,">":1,">=":1,"&":2,"+":3,"-":3,"*":4,"/":4,"^":5},Pt=e=>e>=`0`&&e<=`9`,Ft=e=>/[\p{L}_\\]/u.test(e)||e>=`\ud800`&&e<=`\udfff`,It=e=>/[\p{L}\p{N}\p{M}_.?\\]/u.test(e)||e>=`\ud800`&&e<=`\udfff`,Lt=(e,t)=>({index:e,abs:t});function Rt(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 zt=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 jt(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,Mt.has(n)?{op:n,inner:t}:Nt[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=Nt[r]??0;if(a<=e)return t;this.at+=i.length+r.length;let o=this.expression(a);t=Rt({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 Rt({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(`#`)&&!Ht(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(`#`)||Ht(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(Vt(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===`[`||Ft(e)}primary(){let e=this.space();return Rt(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(Pt(e)||e===`.`){let e=Kt(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===`'`||Ft(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=Rt({kind:`binary`,op:`,`,left:t,right:e},{inner:n}),n=this.space()}return this.eat(`)`)||this.stop(`a ( that is never closed`,e),Rt({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=Ht(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(Pt(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&&It(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=Kt(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:Wt(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=Kt(this.s,this.at);if(r)return this.at=r.end,{kind:`ref`,...n,...r.ref};let i=Wt(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=>Rt({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=Bt.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=Rt({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(Rt(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&&Ft(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=At.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)}},Bt=/^(?:_xlfn\.)?(?:LET|LAMBDA)$/iu,Vt=e=>e.kind===`ref`||e.kind===`name`||e.kind===`structured`||e.kind===`call`||e.kind===`paren`||e.kind===`binary`&&(e.op===`:`||e.op===` `);function Ht(e,t){let n=/^#[A-Za-z0-9_/]+[!?]?/u.exec(e.slice(t));return n?ce(n[0])?.code:void 0}var Ut=(e,t)=>{let n=e.charAt(t);return n!==``&&(It(n)||n===`(`||n===`!`||n===`[`)};function Wt(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=re(r[2]??``),a=re(r[4]??``);if(i!==void 0&&a!==void 0&&!Ut(e,n))return{ref:{col:Lt(i,r[1]===`$`),col2:Lt(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=Gt(i),o=t+i[0].length;if(a&&!Ut(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=Gt(t),r=o+1+t[0].length;if(n&&!Ut(e,r))return{ref:{...a,col2:n.col,row2:n.row,range:!0},end:r}}}return{ref:{...a,range:!1},end:o}}}function Gt(e){let t=re(e[2]??``),n=Number(e[4])-1;if(!(t===void 0||t>=16384||n>=1048576))return{col:Lt(t,e[1]===`$`),row:Lt(n,e[3]===`$`)}}function Kt(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||Ut(e,r)))return{ref:{row:Lt(i,n[1]===`$`),row2:Lt(a,n[3]===`$`),range:!0},end:r}}function qt(e){try{return{ok:!0,node:new zt(e).parse()}}catch(e){if(e instanceof jt)return{ok:!1,error:{message:e.message,at:e.at}};throw e}}var Jt=class{node;error;analysis;text;row;col;source;constructor(e,t,n,r){this.text=e,this.row=t,this.col=n,this.source=r;let i=qt(e);i.ok?this.node=i.node:this.error=i.error}},j=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 Ot(e,this.row-t,this.col-n)}get text(){let{node:e,text:t,row:n,col:r}=this.shared;return!e||n===this.row&&r===this.col?t:qe(this.moved)}},Yt=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 j&&(this.formulas[t]=(this.formulas[t]??1)-1),n instanceof j&&(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}},Xt=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)}},Zt=(e,t)=>e*16384+t;function Qt(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 $t=class{tables=[];blocks=[];merges=[];formulas=new Set;implied=new Map;keys=new Map;fills=[];blanks=new Set;conditions=[];validations=[];filters=[];charts=[];names=new Map;freeze;generated=!1;grid=new Yt;expanded=!1;lowest=-1;ghosts=new Map;spills=new Set;stopped=new Set;reach;lookAreas;name;index;spec;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=un(e,t,[],()=>void 0);n&&this.charts.push(n)}))}put(e,t,n){n instanceof j&&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 j&&this.formulas.delete(r),n instanceof j&&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(Zt(e,t))){if(r){let n=new j(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(Zt(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(Zt(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&&T(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(Zt(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&&T(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(Zt(n,r),e);this.reach&&Qt(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(Zt(n,r))===e&&this.ghosts.delete(Zt(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&&Qt(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=>oe(n.area,e,t))}blockAt(e,t){return this.blocks.find(n=>oe(n.area,e,t))}looks(){if(this.lookAreas)return this.lookAreas;let e=[];for(let t of this.spec.format??[]){let n=w(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=w(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=>nn.has(e)))]}lookAt(e,t){let n={},r=e=>{if(e)for(let[t,r]of Object.entries(e))nn.has(t)&&r!==void 0&&(n[t]=t===`border`?{...n.border,...r}:r)},i=this.implied.get(Zt(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[ne(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)oe(n.area,e,t)&&r(n.entry);for(let n of l)oe(n.area,e,t)&&r(n.entry);let u=this.keys.get(Zt(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 n}runsAt(e,t){let n=this.keys.get(Zt(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=>oe(n,e,t))}validationAt(e,t){return this.validations.find(n=>n.areas.some(n=>oe(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=>oe(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?.[ne(t)]?.files}},en=e=>(typeof e==`object`?e.separator:void 0)??`, `;function tn(e,t){let n=en(t);return e.split(n.trim()===``?n:n.trim()).map(e=>e.trim()).filter(e=>e!==``)}var nn=new Set([`bold`,`italic`,`underline`,`strike`,`font`,`size`,`color`,`fill`,`align`,`valign`,`wrap`,`shrink`,`indent`,`rotation`,`border`,`locked`,`hide_formula`,`format`]),rn=class{title;sheets=[];names=new Map;checks=[];bySheet=new Map;byTable=new Map;file;generated;ordinary=[];constructor(e,t){this.file=e,this.title=e.title,this.generated=t}respec(e){this.file=yt(e,this.generated).file,this.title=e.title,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())}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){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:mt};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(Zt(t,n));if(o!==void 0)return{file:pt,path:[`sheets`,r,`cells`,o]};for(let i of Object.keys(e.spec.cells??{})){if(!i.includes(`:`))continue;let e=w(i);if(e&&oe(e,t,n))return{file:pt,path:[`sheets`,r,`cells`,i]}}}},an=/^[\p{L}_\\][\p{L}\p{N}_.\\?]*$/u;function on(e){return an.test(e)&&ie(e)===void 0&&!/^(?:TRUE|FALSE)$/iu.test(e)&&!/^[Rr](?:\d+)?(?:[Cc]\d*)?$/u.test(e)&&!/^[Cc]\d*$/u.test(e)}var sn=`made`,cn=e=>e[0]===sn?mt:pt,ln=class{problems=[];wb;read_;lineOf;own;madeNames;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:cn(e),...n===void 0?{}:{line:n},message:t})}sheetPath(e){return e<this.own?[`sheets`,e]:[sn,`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 $t(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))}e.checks?.forEach((e,t)=>{let n={file:pt,path:[`checks`,t,`formula`]};this.wb.checks.push({name:e.name,formula:new Jt(e.formula,0,0,n),source:n})})}names(){let{file:e}=this.wb;this.namesOf(e.names,e.hidden_names,e=>this.madeNames.has(e)?[sn,`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(!on(t)){this.yaml(e,`${t} cannot be a name`);continue}let s={file:cn(e),path:e},c=typeof o==`string`&&o.startsWith(`=`)?{name:t,formula:new Jt(o,0,0,s),source:s}:{name:t,value:typeof o==`string`?De(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=ie(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))T(n.area,r.area)&&this.problems.push({file:pt,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=w(n);i?e.merges.push(i):this.yaml([...t,`merges`,r],`${n} is not a range`)}),n.format?.forEach((e,n)=>{w(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])});for(let e of Object.keys(n.columns??{}))re(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=un(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 Jt(e,t?.top??0,t?.left??0,{file:cn(n),path:n})}condition(e,t,n){let r=ae(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=ae(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=w(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=re(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=>T(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.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`),r}overlapping(e,t){let n=e.tables.find(e=>T(e.area,t));if(n)return`table ${n.name}`;let r=e.blocks.find(e=>T(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 j(new Jt(r.formula,t,n,i),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(Zt(t,n),r.format))}table(e,t,n){let r=ie(t.at);if(!r){this.yaml([...n,`at`],`${t.at} is not a cell`);return}if(!on(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 Xt(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=c?.length===0?[``]:c??[];d.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 a=i.column(e),o=a??{name:e,index:i.columns.length};a||(r.formula===void 0&&this.yaml([...n,`columns`,e],`table ${t.name} has no column ${e}`),i.columns.push(o)),o.spec=r}let f=d.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.length>f&&this.problems.push({file:t.rows,line:r,message:`this row has ${String(n.length)} fields and the header ${String(f)}`})}i.rows=i.records.length;let p=this.overlapping(e,i.area);p&&this.yaml(n,`table ${t.name} overlaps ${p} on ${e.name}`),this.wb.addTable(i),this.tableKey(i,n);let m=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 Jt(s,m,o,{file:cn(n),path:[...n,`columns`,a.name,`formula`]}),i.rows>0&&e.fills.push({area:{top:m,left:o,bottom:m+i.rows-1,right:o},shared:a.formula})),a.csv!==void 0&&i.records.forEach((n,r)=>{this.typed(e,m+r,o,De(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=ie(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,De(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=w(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=mn(i),s=Zt(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:cn(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(!on(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:cn(r),path:r},a=S(t).replace(/^([A-Z]+)(\d+)$/u,`$$$1$$$2`),o=`='${e.name.replaceAll(`'`,`''`)}'!${a}`;this.wb.names.set(n.toLowerCase(),{name:n,formula:new Jt(o,0,0,i),source:i})}fill(e,t,n,r){let i=mn(n),a={file:cn(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 Jt(i.formula,t.top,t.left,a),...i.start===void 0?{}:{start:i.start}})}};function un(e,t,n,r){let i=ie(e.at);if(!i){r([...n,`at`],`${e.at} is not a cell`);return}let a=(e,t)=>{let n=new Jt(dn(e),0,0,{file:cn(t),path:t});return n.node&&!fn(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`])},...i?{name:i}:{}}})}}var dn=e=>e.startsWith(`=`)?e:`=${e}`;function fn(e){switch(e.kind){case`error`:case`ref`:case`structured`:case`name`:return!0;case`paren`:case`postfix`:return fn(e.arg);case`binary`:return e.op===`:`||e.op===`,`;default:return!1}}var pn=e=>e.map(e=>e.text).join(``);function mn(e){if(e===null)return{value:null};if(typeof e==`string`)return De(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`?De(e.start).value:e.start}};if(e.runs!==void 0)return{value:pn(e.runs)};let{value:t}=e;return typeof t==`string`?De(t):{value:t??null}}function hn(e){let t=yt(e.file,e.generated),n=new rn(t.file,e.generated);return n.ordinary=t.ordinary,new ln(n,t=>{let n=e.generated?.csv[t];if(n!==void 0)return{rows:i(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 gn=e=>e instanceof E?{error:e.code}:e;function _n(e){return typeof e!=`object`||!e?e:ce(e.error)??D.VALUE}var vn=e=>({rows:e.rows,cols:e.cols,data:e.data.map(gn)}),yn=e=>new O(e.rows,e.cols,e.data.map(_n));function bn(e,t){let n=t.formula?.text;if(n===void 0)return;let r=qt(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 xn=e=>typeof e==`string`?De(e):{value:e??null};function Sn(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=xn(r),a=bn(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 Jt(i.formula,0,0,n.source),delete n.value)}return!0}var Cn=new Map,wn=5e4;function Tn(e){if(!/\d/u.test(e))return;if(Cn.has(e))return Cn.get(e);Cn.size>=wn&&Cn.clear();let t=En(e);return Cn.set(e,t),t}function En(e){let t=De(e.trim());if(typeof t.value==`number`)return t.value;if(e.trim()===``)return;let n=s(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=s(`${r[1]??``} ${r[2]??``}`);return typeof i?.value==`number`?i.value:void 0}function M(e){return typeof e==`number`?e:e==null?0:typeof e==`boolean`?+!!e:e instanceof E?e:Tn(e)??D.VALUE}function N(e){return typeof e==`string`?e:e==null?``:typeof e==`number`?be(e):typeof e==`boolean`?e?`TRUE`:`FALSE`:e}function Dn(e){if(typeof e==`boolean`)return e;if(e==null)return!1;if(typeof e==`number`)return e!==0;if(e instanceof E)return e;let t=e.trim().toUpperCase();return t===`TRUE`||t!==`FALSE`&&D.VALUE}var On=e=>typeof e==`number`?0:typeof e==`string`?1:2,kn=(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 An(e,t){let n=e??(typeof t==`string`?``:typeof t!=`boolean`&&0),r=t??(typeof e==`string`?``:typeof e!=`boolean`&&0),i=On(n),a=On(r);if(i!==a)return i<a?-1:1;if(typeof n==`number`&&typeof r==`number`)return kn(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 jn=e=>Number.isFinite(e)?e:D.NUM;function Mn(e,t,n){return Math.abs(e)<=Math.max(Math.abs(t),Math.abs(n))*89e-17?0:e}function Nn(e,t,n){let r=M(t);if(r instanceof E)return r;let i=M(n);if(i instanceof E)return i;switch(e){case`+`:return jn(Mn(r+i,r,i));case`-`:return jn(Mn(r-i,r,i));case`*`:return jn(r*i);case`/`:return i===0?D.DIV0:jn(r/i);default:return r===0&&i===0?D.NUM:r===0&&i<0?D.DIV0:jn(r**i)}}function Pn(e,t,n){if(t instanceof E)return t;if(n instanceof E)return n;switch(e){case`&`:{let e=N(t);if(e instanceof E)return e;let r=N(n);return r instanceof E?r:`${e}${r}`}case`=`:return An(t,n)===0;case`<>`:return An(t,n)!==0;case`<`:return An(t,n)<0;case`<=`:return An(t,n)<=0;case`>`:return An(t,n)>0;case`>=`:return An(t,n)>=0;default:return Nn(e,t,n)}}function Fn(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?D.NA:n(c,l)}return new O(r,i,a)}var In=e=>({top:e.top,left:e.left,bottom:e.bottom,right:e.right}),Ln=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:In(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:In(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&&T(n.area,t))&&this.kept.delete(n)}clear(){this.kept.clear(),this.asked.clear()}},Rn=(e,t)=>`${e}:${t.key}`,zn=new Map,Bn=255;function Vn(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?Bn:i.length}}function Hn(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 Un(e,t){return e.group.length===0||t<=e.fixed.length||(t-e.fixed.length)%e.group.length===0}function P(e,t,n,r,i={}){zn.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 F(e,t,n,r={}){let{min:i,max:a,fixed:o,group:s}=Vn(t);zn.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 Wn(e,t,n,r){zn.set(e,{name:e,min:t,max:n,kind:`lazy`,call:r,from:`allyhub`})}function Gn(e,t){let n=zn.get(t);n&&zn.set(e,{...n,name:e})}function I(e,t){if(e instanceof E)return e;if(e instanceof Pe)return D.VALUE;if(e instanceof k){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 O)return{rows:e.rows,cols:e.cols,at:(t,n)=>e.at(t,n),array:e};if(e instanceof Fe)return D.VALUE;let n=e instanceof A?null:e;return{rows:1,cols:1,at:()=>n}}function Kn(e,t,n){for(let r of e)if(r instanceof k)t.calc.each(r,e=>{n(e,!1)});else if(r instanceof Pe)for(let e of r.parts)t.calc.each(e,e=>{n(e,!1)});else if(r instanceof O)for(let e of r.data)e!==null&&n(e,!1);else r instanceof A?n(null,!0):r instanceof Fe?n(D.VALUE,!0):n(r,!0)}function qn(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 k)r(t);else if(t instanceof Pe)t.parts.forEach(r);else if(t instanceof O)for(let e of t.data)n(e,!1);else t instanceof A?n(null,!0):t instanceof Fe?n(D.VALUE,!0):n(t,!0)}function Jn(e,t){let n=[],r;return Kn(e,t,(e,t)=>{if(!r){if(e instanceof E)r=e;else if(typeof e==`number`)n.push(e);else if(t){let t=M(e);t instanceof E?r=t:n.push(t)}}}),r??n}function Yn(e,t){let n=[],r;return Kn(e,t,(e,t)=>{if(!r){if(e instanceof E)r=e;else if(typeof e==`number`)n.push(e);else if(typeof e==`boolean`)n.push(+!!e);else if(t){let t=M(e);t instanceof E?r=t:n.push(t)}else typeof e==`string`&&n.push(0)}}),r??n}var Xn=e=>(...t)=>{let n=[];for(let e of t){let t=M(e);if(t instanceof E)return t;n.push(t)}return e(...n)};function Zn(e,t){return e===void 0?t:M(e)}function Qn(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 $n=new Map,er=1e4;function tr(e){let t=$n.get(e);if(t)return t;$n.size>=er&&$n.clear();let n=nr(e);return $n.set(e,n),n}function nr(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 rr=e=>/[*?~]/u.test(e);function ir(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 ar(e){return t=>{if(typeof t==`number`)return kn(t,e);if(typeof t!=`string`)return!1;let n=Tn(t);return n!==void 0&&kn(n,e)}}function or(e,t){let n=t=>e===`>`?t>0:e===`>=`?t>=0:e===`<`?t<0:t<=0;return e=>typeof e==typeof t&&n(An(e,t))}function sr(e){if(e===null)return{test:ar(0),key:`n0`};if(typeof e==`number`)return{test:ar(e),key:`n${String(Number(e.toPrecision(15)))}`};if(typeof e==`boolean`)return{test:t=>t===e,key:e?`bT`:`bF`};if(e instanceof E)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=Tn(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=ar(a),t=Qn(a);else if(o!==void 0)e=e=>e===o,t=Qn(o);else if(ce(r)!==void 0)e=e=>e instanceof E&&e.code===r.toUpperCase();else if(rr(r)){let t=tr(r);e=e=>typeof e==`string`&&t(e)}else{let n=r.toUpperCase();e=e=>typeof e==`string`&&e.toUpperCase()===n,t=Qn(r)}return n===`=`?t===void 0?{test:e}:{test:e,key:t}:{test:t=>!e(t)}}return{test:or(n,s??r)}}function cr(e,t){let n=e.reference;if(!(n?.cols!==1||e.rows<64))return t.calc.indexes.ofRepeated(Rn(`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(Qn(r),t),typeof r==`string`){let e=Tn(r);e!==void 0&&n(Qn(e),t)}}return t})}function lr(e,t){return sr(t.calc.scalar(e,t.frame))}function ur(e,t){let n=[];for(let r=0;r+1<e.length;r+=2){let i=I(e[r],t);if(i instanceof E)return i;let a=lr(e[r+1],t);if(a instanceof E)return a;n.push({cells:i,crit:a})}let r=n[0]?.cells;return r&&n.some(e=>!dr(e.cells,r))?D.VALUE:n}var dr=(e,t)=>e.cols===t.cols&&(e.reference?.rows??e.rows)===(t.reference?.rows??t.rows);function fr(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=cr(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 pr(e,t){return e instanceof k?(e.rows-t.rows)*e.cols:0}function mr(e,t,n,r){let i;return fr(t,n,(t,n)=>{if(i)return;let a=e.at(t,n);a instanceof E?i=a:typeof a==`number`&&r(a)}),i}function hr(e,t){let n=I(e[0],t);if(n instanceof E)return n;let r=e[2];return r===void 0?n:I(r,t)}var gr=e=>(t,n)=>{let r=I(t[0],n);if(r instanceof E)return r;let i=lr(t[1],n);if(i instanceof E)return i;let a=hr(t,n);if(a instanceof E)return a;let o=[];return mr(a,[{cells:r,crit:i}],n,e=>{o.push(e)})??e(o)},_r=e=>(t,n)=>{let r=I(t[0],n);if(r instanceof E)return r;let i=ur(t.slice(1),n);if(i instanceof E)return i;let a=i[0]?.cells;if(a&&!dr(r,a))return D.VALUE;let o=[];return mr(r,i,n,e=>{o.push(e)})??e(o)},vr=(e,t)=>(n,r)=>{let i=[],a=[e];for(let e of n)if(e instanceof k)i.push(e),a.push(`r${e.key}`);else if(e instanceof A)a.push(`-`);else if(e instanceof E)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 E)&&r.calc.results.set(o,i,c),c},yr=e=>e.reduce((e,t)=>e+t,0),br=e=>e.length===0?D.DIV0:yr(e)/e.length;F(`SUMIF`,`rv?r`,vr(`SUMIF`,gr(yr))),F(`AVERAGEIF`,`rv?r`,vr(`AVERAGEIF`,gr(br))),F(`SUMIFS`,`r(rv)`,vr(`SUMIFS`,_r(yr))),F(`AVERAGEIFS`,`r(rv)`,vr(`AVERAGEIFS`,_r(br))),F(`MINIFS`,`r(rv)`,vr(`MINIFS`,_r(e=>e.length===0?0:e.reduce((e,t)=>t<e?t:e)))),F(`MAXIFS`,`r(rv)`,vr(`MAXIFS`,_r(e=>e.length===0?0:e.reduce((e,t)=>t>e?t:e)))),F(`COUNTIF`,`rv`,vr(`COUNTIF`,(e,t)=>{let n=I(e[0],t);if(n instanceof E)return n;let r=lr(e[1],t);if(r instanceof E)return r;let i=0;return fr([{cells:n,crit:r}],t,()=>{i+=1}),i+(r.test(null)?pr(e[0],n):0)})),F(`COUNTIFS`,`(rv)`,vr(`COUNTIFS`,(e,t)=>{let n=ur(e,t);if(n instanceof E)return n;let r=0;return fr(n,t,()=>{r+=1}),r}));var xr=(e,t)=>e?.toLowerCase()===t?.toLowerCase(),Sr=(e,t,n)=>e.index>=t?{...e,index:e.index+n}:e;function Cr(e,t,n){if(e.index<t)return e;if(e.index>=t+n)return{...e,index:e.index-n}}function wr(e,t,n,r){let i=e.index<=t.index?e:t,a=i===e?t:e,o=Sr(i,n,r),s=a.index>=n?{...a,index:a.index+r}:a;return i===e?[o,s]:[s,o]}function Tr(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 Er(e){return{kind:`error`,code:`#REF!`,...e.sheet===void 0?{}:{sheet:e.sheet}}}var Dr={kind:`error`,code:`#REF!`};function Or(e,t,n){if(!xr(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:xr(u,n)?Object.fromEntries(Object.entries(f).filter(([e])=>e!==`sheet`)):{...f,sheet:u}}function kr(e,t,n){if(!xr(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?x:te;if(a===void 0){let n=s?Sr(i,t.at,t.count):Cr(i,t.at,t.count);return!n||n.index>=c?Er(e):n===i?e:{...e,[o[0]]:n}}let l=s?wr(i,a,t.at,t.count):Tr(i,a,t.at,t.count);return!l||l[0].index>=c||l[1].index>=c?Er(e):l[0]===i&&l[1]===a?e:{...e,[o[0]]:l[0],[o[1]]:l[1]}}function Ar(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:kr(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 jr(e,t,n,r){let i=(e,t)=>e===void 0?r===void 0||xr(r,t):xr(e,t);return Ct(e,e=>{switch(t.op){case`rename-sheet`:return(e.kind===`ref`||e.kind===`name`||e.kind===`error`)&&xr(e.sheet,t.from)?{...e,sheet:t.to}:e.kind===`ref`&&xr(e.lastSheet,t.from)?{...e,lastSheet:t.to}:e;case`rename-table`:return e.kind===`structured`&&xr(e.table,t.from)?{...e,table:t.to}:e;case`delete-sheet`:return e.kind===`ref`&&xr(e.sheet,t.name)||e.kind===`ref`&&xr(e.lastSheet,t.name)?Er(e):e.kind===`name`&&xr(e.sheet,t.name)?Dr:e;case`delete-table`:return e.kind===`structured`&&xr(e.table,t.name)||e.kind===`name`&&xr(e.name,t.name)?Dr:e;case`delete-column`:return e.kind===`structured`&&i(e.table,t.table)&&e.columns.some(e=>xr(e,t.name))?Dr:e;case`rename-column`:return e.kind===`structured`&&i(e.table,t.table)&&e.columns.some(e=>xr(e,t.from))?{...e,columns:e.columns.map(e=>xr(e,t.from)?t.to:e)}:e;case`rename-name`:return e.kind===`name`&&xr(e.name,t.from)?{...e,name:t.to}:e.kind===`call`&&xr(e.name,t.from)?{...e,name:t.to.toUpperCase(),written:t.to}:e;case`move-cells`:return e.kind===`ref`?Or(e,t,n):e;case`shift-cells`:return e.kind===`ref`?Ar(e,t,n):e;default:return e.kind===`ref`?kr(e,t,n):e}})}var Mr=e=>e.op===`insert-rows`||e.op===`delete-rows`||e.op===`insert-columns`||e.op===`delete-columns`,Nr=e=>e.op===`insert-rows`||e.op===`insert-columns`,Pr=e=>e.op===`insert-rows`||e.op===`delete-rows`;function Fr(e,t){return Nr(t)?e>=t.at?e+t.count:e:e<t.at?e:e>=t.at+t.count?e-t.count:void 0}function Ir(e,t){let n=ie(e);if(!n)return e;let r=Fr(Pr(t)?n.row:n.col,t);if(r!==void 0)return S(Pr(t)?{...n,row:r}:{...n,col:r})}function Lr(e,t){return Object.fromEntries(Object.entries(e).flatMap(([e,n])=>{let r=Ir(e,t);return r===void 0?[]:[[r,n]]}))}var Rr=e=>Pr(e)?x:te;function zr(e,t,n){let r=Rr(n);if(Nr(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 Br(e,t){let n=Pr(t)?zr(e.top,e.bottom,t):zr(e.left,e.right,t);if(n)return Pr(t)?{...e,top:n[0],bottom:n[1]}:{...e,left:n[0],right:n[1]}}function Vr(e,t,n,r){let i=0,a=(e,t)=>{e&&!e.abs&&(i=Math.max(i,Math.abs(e.index-t)))};return Tt(e,e=>{e.kind===`ref`&&(t?(a(e.row,n),a(e.row2,n)):(a(e.col,r),a(e.col2,r)))}),i}function Hr(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 Ur(e,t,n,r,i){let a=qt(t);if(!a.ok){let n=i?Br(e,r):e;return n?[{area:n,text:t}]:[]}let o=Pr(r),[s,c]=o?[e.top,e.bottom]:[e.left,e.right],l=Vr(a.node,o,e.top,e.left),u=[],d=!0;for(let[t,f]of Hr(s,c,r,l)){let s=o?t:e.top,c=o?e.left:t,l=i?Fr(t,r):t;if(l===void 0)continue;let p=i?Fr(f,r):f;if(p===void 0)continue;let m=Ot(a.node,s-e.top,c-e.left),h=jr(m,r,n);h!==m&&(d=!1);let g=kt(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:qe(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 Wr(e,t){return typeof e==`object`&&e?{...e,formula:t}:t}var Gr=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 Kr(e,t,n,r){let i=qt(e);if(!i.ok)return e;let a=jr(i.node,t,n,r);return a===i.node?e:qe(a)}function qr(e,t,n,r){let i={},a=Mr(n)?n:void 0;for(let[o,s]of Object.entries(e)){let e=Gr(s),c=w(o);if(!c){i[o]=s;continue}let l=r&&a!==void 0;if(o.includes(`:`)){if(!a){i[o]=e===void 0?s:Wr(s,Kr(e,n,t));continue}if(e!==void 0){for(let n of Ur(c,e,t,a,l))i[C(n.area)]=Wr(s,n.text);continue}if(!l){i[o]=s;continue}if(!Nr(a)){let e=Br(c,a);e&&(i[C(e)]=s);continue}let r=Pr(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[C(o)]=s}continue}let u={row:c.top,col:c.left},d=u;if(l){let e=Fr(Pr(a)?u.row:u.col,a);d=e===void 0?void 0:Pr(a)?{...u,row:e}:{...u,col:e}}d&&(i[S(d)]=e===void 0?s:Wr(s,Kr(e,n,t)))}return i}function Jr(e,t){let n=ie(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 Yr=e=>e.reduce((e,t)=>Math.max(e,t.length),0);function Xr(e,t,n){let r=Math.max(Yr(e),1),i=Array.from({length:n},()=>Array(r).fill(``));return[...e.slice(0,t),...i,...e.slice(t)]}function Zr(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 Qr(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 $r(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 ei=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]=Kr(r,e,t));for(let n of this.file.checks??[])n.formula=Kr(n.formula,e,t);for(let t of this.sheets())this.rewriteSheet(t,e)}rewriteSheet(e,t){let n=Mr(t)&&ti(e.name,t.sheet);if(e.names)for(let[n,r]of Object.entries(e.names))typeof r==`string`&&r.startsWith(`=`)&&(e.names[n]=Kr(r,t,e.name));e.cells&&=qr(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=Kr(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=>ti(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=>ti(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(`=`)?Kr(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:Kr(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),Mr(t)&&t.sheet===e.name&&(e.links&&=Lr(e.links,t),e.notes&&=Lr(e.notes,t),e.pictures&&=e.pictures.flatMap(e=>{let n=Ir(e.at,t);return n===void 0?[]:[{...e,at:n}]})),e.charts&&=e.charts.map(n=>at(n,n=>{let r=n.startsWith(`=`),i=Kr(dn(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=>De(e).formula===void 0?e:Kr(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=Pr(t),r=[];for(let i of e.tables??[]){let e=this.rows.get(i.rows),a=e&&Jr(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(!Nr(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(Nr(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,Xr(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(Nr(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=S(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?$r(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=Zr(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=Pr(t),r=(e.blocks??[]).flatMap(e=>{let r=ie(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(Yr(i),1))-1,s=zr(a,o,t);if(!s)return[];let c=n?{...r,row:s[0]}:{...r,col:s[0]};if(Nr(t)&&t.at>a&&t.at<=o){let r=t.at-a;this.rows.set(e.rows,n?Xr(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(!Nr(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:S(c)}]});e.blocks=r,r.length===0&&delete e.blocks}looksOn(e,t){let n=Pr(t);e.format&&=e.format.flatMap(e=>{let n=w(e.range);if(!n)return[e];let r=Br(n,t);return r?[{...e,range:C(r)}]:[]}),e.format?.length===0&&delete e.format,e.merges&&=e.merges.flatMap(e=>{let n=w(e);if(!n)return[e];let r=Br(n,t);return r?[C(r)]:[]}),e.merges?.length===0&&delete e.merges;let r=e=>{let n=ae(e);if(!n)return e;let r=n.flatMap(e=>{let n=Br(e,t);return n?[C(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=ie(e.at);if(!r)return e;let i=Fr(n?r.row:r.col,t)??t.at;return{...e,at:S(n?{...r,row:i}:{...r,col:i})}}),e.filter){let r=w(e.filter.range),i=r&&Br(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=re(e),i=r===void 0?void 0:Fr(r,t);return i===void 0?[]:[[ne(i),n]]}));e.filter={range:C(i),...r&&Object.keys(r).length>0?{columns:r}:{}}}}if(e.freeze!==void 0){let r=ie(e.freeze);if(r){let i=n?r.row:r.col,a=zr(0,i-1,t),o=i===0?0:a?a[1]+1:0;e.freeze=S(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:Fr(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,re,ne);t&&(e.columns=t)}}run(){let e=this.edit;if(Mr(e)){let t=this.sheets().find(t=>ti(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=>ti(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=>ti(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=>ti(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]))}}},ti=(e,t)=>e.toLowerCase()===t.toLowerCase();function ni(e,t){let n=new ei(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 ri(e,t,n){let r=new ei(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 ii=[`bold`,`italic`,`underline`,`strike`,`font`,`size`,`color`,`script`];function ai(e){return Object.fromEntries(Object.entries(e).filter(([e])=>e!==`text`))}var oi=(e,t)=>ii.every(n=>e[n]===t[n]);function si(e){let t={text:e.text};for(let n of ii)e[n]!==void 0&&(t[n]=e[n]);return t}function ci(e){let t=[];for(let n of e){if(n.text===``)continue;let e=t[t.length-1];e&&oi(ai(e),ai(n))?t[t.length-1]={...e,text:e.text+n.text}:t.push(si(n))}return t}var li=e=>e.every(e=>ii.every(t=>e[t]===void 0));function ui(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 di(e,t,n,r){let i=ui(ui(e,t),n),a=0;return ci(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 fi(e,t){let n=new Set(t);return ci(e.map(e=>Object.fromEntries(Object.entries(e).filter(([e])=>!n.has(e)))))}function pi(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 mi(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 hi(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=pi(e,n.length-a>i?i+1:i);return ci([...mi(e,0,i),{...o?ai(o):{},text:t.slice(i,t.length-a)},...mi(e,n.length-a,n.length)])}var gi=(e,t)=>e.top<=t.top&&e.left<=t.left&&e.bottom>=t.bottom&&e.right>=t.right,_i=(e,t)=>Object.fromEntries(Object.entries(e).filter(([e])=>e!==t)),vi=e=>_i(e,`formula`),yi=(e,t)=>Object.fromEntries(Object.entries(e).filter(([e])=>e!==t)),bi=()=>({rows:new Map,cells:[],whole:!1}),L=e=>({...bi(),refused:e}),xi=e=>De(e).formula!==void 0;function Si(e){let t=De(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 Ci=e=>typeof e==`object`&&e?Object.fromEntries(Object.entries(e).filter(([e])=>e!==`value`&&e!==`formula`&&e!==`runs`)):{},R=class{book;specs=new Map;file;fileChanged=!1;grown=new Map;added=new Map;edit=bi();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 wi(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 Ti(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 Ei=(e,t,n)=>{let r=qt(e);return r.ok?qe(Ot(r.node,t,n)):e};function Di(e,t,n,r,i,a){let o=n.at.row+1,s=e.table(t,n),c=Ei(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 Oi(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 ki(e,t,n,r,i){let a=i.trim();if(a===``)return L(`column-name`);if(a===r.name)return e.finish();let o=Qr(n.columns.filter(e=>e!==r).map(e=>e.name),a),s=ni(t,{op:`rename-column`,table:n.name,from:r.name,to:o});return{...bi(),file:s.file,rows:new Map(s.rows),whole:!0}}function Ai(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(xi(a)){if(o.formula||!Oi(e,n,o,s)){Di(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,$r(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 ji(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 Mi(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?Qr(o,i.trim()===``?Zr(o):i.trim()):Zr(o);if(e.edit.whole=!0,!s&&xi(i)){a.columns={...a.columns,[c]:{formula:Ei(i,n.at.row+1-r,0)}};return}let l=o.length,u=$r(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 Ni(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 Pi(e,t,n){return Object.keys(e.spec.cells??{}).some(e=>{if(!e.includes(`:`))return!1;let r=w(e);return r!==void 0&&oe(r,t,n)})}function Fi(e,t,n,r,i){let a=e.spec(t),o=S({row:n,col:r}),s={...a.cells},c=s[o];if(typeof c==`object`&&c&&c.runs!==void 0&&pn(c.runs)===i){e.edit.cells.push({sheet:t,row:n,col:r,input:i,key:o});return}let l=c===void 0?{}:Ci(c),u=Si(i),d=Object.keys(l).length===0,f;if(u===null){let e=Pi(t,n,r);f=!d||e,d&&!e?s=yi(s,o):s[o]=d?null:l}else f=!0,s[o]=d?u:{...l,...xi(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 Ii(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?ki(e,t,s,o,a):void 0;Ai(e,n,s,r,i,a);return}if(a!==``){let t=wi(e,n,r,i);if(t){ji(e,t,r,i,a);return}let o=Ti(n,r,i);if(o){Mi(e,n,o,r,a);return}}let c=n.blockAt(r,i);c?Ni(e,n,c.file,c.area,r,i,a):Fi(e,n,r,i,a)}function Li(e,t,n,r,i){let a=e.workbook.sheet(t);if(!a)return L(`no-sheet`);let o=ci(i),s=pn(o);if(o.length===0||li(o))return zi(e,t,[{row:n,col:r,text:s}]);if(a.tableAt(n,r)||a.blockAt(n,r))return L(`rich-loose`);let c=new R(e),l=c.spec(a),u=S({row:n,col:r}),d=l.cells?.[u],f=d===void 0?{}:Ci(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 Ri(e,t){if(typeof e!=`object`||!e||!e.runs)return e;let n=fi(e.runs,t);if(!li(n))return{...e,runs:n};let r=pn(n),i=Ci(e);return De(r).value===r&&De(r).format===void 0?Object.keys(i).length===0?r:{...i,value:r}:{...i,runs:[{text:r}]}}function zi(e,t,n){let r=e.workbook.sheet(t);if(!r)return L(`no-sheet`);let i=new R(e);for(let{row:t,col:a,text:o}of[...n].sort((e,t)=>e.row-t.row||e.col-t.col)){let n=Ii(i,e,r,t,a,o);if(n)return n}return i.finish()}function Bi(e,t,n,r,i){let a=e.workbook.sheet(t),o=a?.tableAt(n,r);if(!a||!o)return L(`no-sheet`);let s=o.columns[r-o.at.col];if(!s)return L(`no-sheet`);let c=new R(e);Di(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*Vi(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 Hi(e,t,n){let r=e.workbook.sheet(t);if(!r)return L(`no-sheet`);let i=new R(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,$r(i.rows(e.file),s,t.index));let c=vi(o.columns?.[t.name]??{}),l=yi(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 Vi(r,n)){if(r.tableAt(t,a)?.at.row===t)continue;let n=Ii(i,e,r,t,a,``);if(n)return n}return i.finish()}function Ui(e,t){e.cells&&=Object.fromEntries(Object.entries(e.cells).filter(([e])=>{let n=w(e);return!n||!gi(t,n)}))}function Wi(e,t,n,r,i){let a=e.workbook.sheet(t);if(!a)return L(`no-sheet`);if(!a.tables.some(e=>T(e.area,r))&&!a.blocks.some(e=>T(e.area,r))&&xi(i)){let t=new R(e),o=t.spec(a);Ui(o,r);let s=Ei(i,r.top-n.row,r.left-n.col),c=C(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:xi(i)?Ei(i,e-n.row,t-n.col):i});return zi(e,t,o)}function Gi(e,t,n,r,i){let a=e.workbook.sheet(t);if(!a)return L(`no-sheet`);let o=new R(e),s=o.spec(a);return s.blocks=[...s.blocks??[],{at:S(n),rows:i}],o.edit.rows.set(i,r),o.edit.whole=!0,o.finish()}var Ki=(e,t)=>Object.keys(t).some(t=>t in e),qi=(e,t)=>Object.fromEntries(Object.entries(e).filter(([e])=>!(e in t)));function Ji(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 Yi={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 Xi(e,t,n,r){for(let[t,i]of Object.entries(e.columns??{})){let e=ie(`${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=>T(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 Zi(e,t,n,r){let i=e.workbook.sheet(t);if(!i)return L(`no-sheet`);let a=new R(e);return Qi(a,i,n,r),a.finish()}function Qi(e,t,n,r){let i=e.spec(t);$i(e,t,i,n,r),ea(i)}function $i(e,t,n,r,i){let a=ii.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=w(e);i&&T(i,r)&&(n.cells={...n.cells,[e]:Ri(t,a)})}if(n.cells){let e={...n.cells},t=[];for(let[n,a]of Object.entries(e)){if(typeof a!=`object`||!a||!Ki(a,i))continue;let o=w(n);o&&T(o,r)&&(n.includes(`:`)&&!gi(r,o)&&t.push({range:n,...Object.fromEntries(Object.entries(a).filter(([e])=>e in i))}),e[n]=Ji(qi(a,i)))}n.cells=e,t.length>0&&(n.format=[...n.format??[],...t])}let o=n.format??[],s=e=>{let t=w(e.range);return t!==void 0&&T(t,r)},c=o.some(e=>s(e)&&Ki(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=ne(t),r={...qi(e[n]??{},i),...l};e=Object.keys(r).length===0?yi(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={...qi(e[n]??{},i),...l};e=Object.keys(r).length===0?yi(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={...qi(a[t]??{},i),...l};a=Object.keys(n).length===0?yi(a,t):{...a,[t]:n}}n.columns=a,Object.keys(a).length===0&&delete n.columns,e.edit.whole=!0;return}let p=C(r),m=o.find(e=>{let t=w(e.range);return t!==void 0&&C(t)===p}),h=(m?o.slice(o.indexOf(m)+1):[]).some(e=>s(e)&&Ki(e,i)),g={};for(let[e,a]of Object.entries(i)){let i=o.some(t=>t!==m&&s(t)&&e in t)||Xi(n,t,r,e);a===void 0?i&&(g[e]=Yi[e]):g[e]=a}if(m&&!h){let e={...qi(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 ea(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 ta(e,t,n,r){let i=e.workbook.sheet(t);if(!i)return L(`no-sheet`);let a=new R(e),o=a.spec(i),s=ne(n),c=_i(o.columns?.[s]??{},`width`),l=r===void 0?c:{...c,width:r},u=yi(o.columns??{},s);return o.columns=Object.keys(l).length===0?u:{...u,[s]:l},ea(o),a.finish()}function na(e,t,n,r){let i=e.workbook.sheet(t);if(!i)return L(`no-sheet`);let a=new R(e),o=a.spec(i),s=String(n+1),c=_i(o.rows?.[s]??{},`height`),l=r===void 0?c:{...c,height:r},u=yi(o.rows??{},s);return o.rows=Object.keys(l).length===0?u:{...u,[s]:l},ea(o),a.finish()}function ra(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 ia(e,t,n){let r=ra(e,n,t);if(r)return L(r);let i=ni(e,{op:`rename-sheet`,from:t,to:n});return{...bi(),file:i.file,rows:new Map(i.rows),whole:!0}}function aa(e,t,n){let r=ra(e,t);if(r)return L(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}),{...bi(),file:{...e.file,sheets:i},whole:!0}}function oa(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 sa(e,t){let n=ri(e,t,oa(e,t));return n.refused?L(n.refused):{...bi(),file:n.file,rows:new Map(n.rows),whole:!0}}function ca(e,t){let n=ni(e,{op:`delete-sheet`,name:t});if(n.refused)return L(n.refused);let r=la(e.file,n.file);for(let e of r)n.rows.delete(e);return{...bi(),file:n.file,rows:new Map(n.rows),whole:!0,...r.length===0?{}:{removed:r}}}function la(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 ua(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),{...bi(),file:{...e.file,sheets:r},whole:!0}):L(`no-sheet`)}function da(e,t){let n=ni(e,t);return n.refused?L(n.refused):{...bi(),file:n.file,rows:new Map(n.rows),whole:!0}}function fa(e,t,n,r){if(!on(t)||e.workbook.name(t)||e.workbook.table(t))return L(`name-invalid`);let i=(e,t)=>`$${ne(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{...bi(),file:{...e.file,names:{...e.file.names,[t]:`=${o}!${a}`}},whole:!0}}function pa(e,t,n,r){let i=t.at(n,r);if(i===void 0)return``;if(i instanceof j)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(Zt(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 ma(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 ha(e,t,n,r){let i=e.workbook.sheet(t);if(!i)return L(`no-sheet`);if(i.tables.some(e=>T(e.area,n)))return L(`table-overlap`);let a=n.right-n.left+1,o=(t,n)=>pa(e,i,t,n);if(!r.header){if(n.top===0)return L(`table-room`);for(let e=0;e<a;e++)if(o(n.top-1,n.left+e)!==``)return L(`table-room`)}let s=new R(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 Vi(i,n)){let n=Ii(s,e,i,t,r,``);if(n)return n}let f=ma(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:S({row:g,col:n.left}),rows:m,...r.style!==void 0&&r.style!==`TableStyleMedium2`?{style:r.style}:{}}],s.edit.whole=!0,s.finish()}function ga(e,t,n,r){let i=e.workbook.sheet(t),a=i?.tables.find(e=>e.name===n);if(!i||!a)return L(`no-sheet`);let o=new R(e),s=o.table(i,a);return r===`TableStyleMedium2`?delete s.style:s.style=r,o.edit.whole=!0,o.finish()}function _a(e,t,n,r){let i=e.workbook.sheet(t),a=i?.tables.find(e=>e.name===n);if(!i||!a)return L(`no-sheet`);let o=new R(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 va(e,t){return t===void 0?e.names:e.sheets.find(e=>e.name===t)?.names}function ya(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 ba(e,t){let n=t.name.trim(),r=t.was!==void 0&&t.was.name.toLowerCase()!==n.toLowerCase(),i=Object.keys(va(e.file,t.scope)??{}).some(e=>e.toLowerCase()===n.toLowerCase()&&(e.toLowerCase()!==t.was?.name.toLowerCase()||t.was.scope!==t.scope));if(!on(n)||i||e.workbook.table(n))return L(`name-invalid`);let a=t.value.trim(),o=De(a).value,s=a.startsWith(`=`)||o instanceof E?a:o,c=r&&t.was?da(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={...va(l,t.was.scope)};for(let n of Object.keys(e))n.toLowerCase()===t.was.name.toLowerCase()&&(e[n]=null);l=ya(l,t.was.scope,Object.fromEntries(Object.entries(e).filter(([,e])=>e!==null)))}return l=ya(l,t.scope,{...va(l,t.scope),[n]:s}),{...bi(),file:l,rows:c?.rows??new Map,whole:!0}}function xa(e,t,n){let r=va(e.file,n)??{},i=Object.fromEntries(Object.entries(r).filter(([e])=>e.toLowerCase()!==t.toLowerCase()));return{...bi(),file:ya(e.file,n,i),whole:!0}}var Sa=e=>typeof e==`number`?0:typeof e==`string`?1:typeof e==`boolean`?2:3;function Ca(e,t){let n=Sa(e),r=Sa(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 E&&t instanceof E?e.code<t.code?-1:+(e.code>t.code):0}var wa=e=>e===null||e===``;function Ta(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(wa(t)||wa(o)){if(wa(t)&&wa(o))continue;return wa(t)?1:-1}let s=Ca(t,o);if(s!==0)return a===!0?-s:s}return e.index-r.index}).map(e=>e.row)}function Ea(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=>De(e).formula===void 0?e:Ei(e,u,0))}),e.edit.whole=!0}var Da=(e,t,n)=>{let r=[];for(let i=e;i<=t;i++)n?.has(i)||r.push(i);return r};function Oa(e,t,n,r,i,a){let o=e.workbook.sheet(n);if(!o)return L(`no-sheet`);if(i.length===0)return bi();let s=(e,n)=>t.value(o,e,n),c=o.tables.find(e=>e.rows>0&&oe(e.area,r.top,r.left)),l=new R(e);if(c){let{top:e,bottom:t}=c.data,n=Da(e,t,a),r=Ta(n,i,s);return r.every((e,t)=>e===n[t])?bi():(Ea(l,c,n,r,e),l.finish())}let u=Da(r.top,Math.min(r.bottom,o.lastRow),a);return ka(l,e,o,r,u,Ta(u,i,s)),l.finish()}function ka(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=pa(t,n,a,i),o=De(r).formula===void 0?r:Ei(r,c-a,0);o!==pa(t,n,c,i)&&Ii(e,t,n,c,i,o)}})}function Aa(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 ja=.1,Ma={3:[0,33,67],4:[0,25,50,75],5:[0,20,40,60,80]},Na=e=>{if(e!==null&&e!==``&&!(e instanceof E))return typeof e==`string`?`s${e.toLowerCase()}`:`${typeof e}${String(e)}`},Pa=e=>Math.round(e).toString(16).padStart(2,`0`);function Fa(e,t,n){let r=(e,t)=>Number.parseInt(e.slice(t,t+2),16),i=i=>Pa(r(e,i)+(r(t,i)-r(e,i))*n);return`#${i(1)}${i(3)}${i(5)}`.toUpperCase()}function Ia(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 La(e,t,n,r){if(t instanceof E)return!1;let i=()=>Ia(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&&Ia(t,r)<=0;return e===`notBetween`?!n:n}}}var Ra=e=>e===null||e instanceof E?``:typeof e==`boolean`?e?`TRUE`:`FALSE`:String(e);function za(e,t,n){if(t instanceof E)return!1;let r=Ra(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 Ba(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 Va(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 Ha=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=Na(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=De(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 O?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 Va(a,(l??i)/100);default:return l??i}}whether(e,t,n,r){let{spec:i}=e;switch(i.type){case`cellIs`:return La(i.operator,t,this.boundAt(e,i.formula[0],n,r),this.boundAt(e,i.formula[1],n,r));case`containsText`:return za(i.operator,t,i.text);case`duplicateValues`:case`uniqueValues`:{let n=Na(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 Dn(i instanceof O?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 Fa(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?ja:ja+.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??(Ma[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=>oe(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={...Ba(n),...a.look},n.stop===!0))break}return a}},Ua=`#00A651`,Wa=`#FFC000`,Ga=`#E03C32`,Ka=`#7F7F7F`,qa=`#000000`,Ja=`#2F75B5`,Ya=e=>e===3?[Ga,Wa,Ua]:e===4?[qa,Ga,Wa,Ua]:[Ga,`#ED7D31`,Wa,`#92D050`,Ua];function Xa(e,t){let n=Number.parseInt(e,10),r=Ya(n)[t]??Ka,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`?Ka: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:Ja,level:t+1}:i===`Quarters`?{shape:`quarter`,color:Ka,level:t}:i===`RedToBlack`?{shape:`circle`,color:[`#000000`,`#7F7F7F`,`#F4B6B6`,`#E03C32`][t]??Ka}:{shape:`circle`,color:r}}var Za=e=>e.separator??`, `;function Qa(e,t){let n=Za(t);return e.split(n.trim()===``?n:n.trim()).map(e=>e.trim()).filter(e=>e!==``)}var $a=(e,t)=>e.join(Za(t));function eo(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=>je(e,void 0);return c instanceof O?c.data.map(l).filter(e=>e!==``):c===null?[]:[l(c)]}function to(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 O?n.at(0,0):n}if(typeof o==`number`)return o;let c=De(o);return c.formula===void 0?c.value:null}function no(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 j);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}]),Dn(l instanceof O?l.at(0,0):l)===!0}function ro(e,t,n,r,i,a){let{spec:o}=n;if(a===null||a===``)return o.blank!==!1;if(a instanceof E)return!1;let s=o.operator??`between`,c=a=>to(e,t,n,a,r,i);switch(o.type){case`list`:{let s=je(a,void 0),c=eo(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?Qa(s,o).every(l):l(s)}case`custom`:return no(e,t,n,r,i,a);case`textLength`:return La(s,(typeof a==`string`?a:je(a)).length,c(0),c(1));case`whole`:return typeof a==`number`&&Number.isInteger(a)&&La(s,a,c(0),c(1));case`time`:return typeof a==`number`&&a>=0&&a<1&&La(s,a,c(0),c(1));default:return typeof a==`number`&&La(s,a,c(0),c(1))}}function io(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 ao(e,t){let n=[];for(let r of e.sheets)for(let e of r.validations)for(let i of e.areas)io(r,i,(i,a)=>{let o=t.value(r,i,a);ro(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 oo=(e,t,n,r)=>je(t.value(e,n,r),e.lookAt(n,r).format),so=(e,t)=>{if(t===``)return e.blanks===!0;let n=t.toLowerCase();return e.values?.some(e=>e.toLowerCase()===n)===!0},co=e=>e.values!==void 0||e.blanks!==void 0,lo=(e,t)=>!co(e)||so(e,t);function uo(e,t,n,r){let i=e.validations.length===0?void 0:e.validationAt(t,n);return i?.spec.multiple===!0?Qa(r,i.spec):[r]}function fo(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=rr(a)?tr(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 po(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=oo(e,t,n,r);return a===``?i.blanks===!0:uo(e,n,r,a).some(e=>so(i,e))};let c=i.conditions;if(c)return n=>{let a=t.value(e,n,r),o=oo(e,t,n,r),s=c.map(e=>fo(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 mo(e,t,n,r){return[...n.columns].filter(([e])=>e!==r).map(([r,i])=>po(e,t,n,r,i))}var ho=(e,t)=>e.every(e=>e(t));function go(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=mo(e,t,r);for(let e=i+1;e<=o;e++)ho(s,e)||n.add(e)}return n}function _o(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=mo(e,t,n,r);for(let n=s+1;n<=l;n++){if(!ho(u,n))continue;let s=oo(e,t,n,r);if(s===``){o+=1;continue}let c=uo(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||lo(i,o),value:c.length>1?o:t.value(e,n,r)})}}return{values:[...a.values()].sort((e,t)=>Ca(e.value,t.value)),blanks:o===0?void 0:{count:o,on:i===void 0||i.blanks===!0||!co(i)}}}function vo(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 yo=(e,t)=>e?t.calc.eval(e,t.frame):!1;function bo(e,t,n){if(!(e instanceof O))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):D.NA}function xo(e,t,n){let r=[e,...t].filter(e=>e instanceof O),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(bo(e,r,i));o[r*a+i]=s instanceof E?s:bo(t[s]??D.VALUE,r,i)}return new O(i,a,o)}Wn(`IF`,1,3,(e,t)=>{let n=t.calc.flat(yo(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 A?null:i};if(n instanceof O){let i=n=>n<e.length?t.calc.flat(r(n))??0:!1;return xo(n,[i(1),i(2)],e=>{let t=Dn(e);return t instanceof E?t:+!t})}let i=Dn(n);return i instanceof E?i:r(i?1:2)}),Wn(`IFS`,2,255,(e,t)=>{for(let n=0;n+1<e.length;n+=2){let r=Dn(t.calc.scalar(yo(e[n],t),t.frame));if(r instanceof E)return r;if(r)return yo(e[n+1],t)}return D.NA});var So=e=>(t,n)=>{let r=n.calc.flat(yo(t[0],n)),i=t=>t instanceof E&&(e===void 0||t===e),a=()=>t[1]?n.calc.flat(n.calc.eval(t[1],n.frame)):``;return r instanceof O?xo(r,[r,a()],e=>+!!i(e)):i(r)?a():r};Wn(`IFERROR`,2,2,So()),Wn(`IFNA`,2,2,So(D.NA)),Wn(`CHOOSE`,2,255,(e,t)=>{let n=t.calc.flat(yo(e[0],t));if(n instanceof O){let r=e.slice(1).map(e=>t.calc.flat(t.calc.eval(e,t.frame)));return xo(n,r,e=>{let t=M(e);if(t instanceof E)return t;let n=Math.trunc(t)-1;return n<0||n>=r.length?D.VALUE:n})}let r=M(n);if(r instanceof E)return r;let i=Math.trunc(r),a=e[i];return i<1||a===void 0?D.VALUE:t.calc.eval(a,t.frame)}),Wn(`SWITCH`,3,255,(e,t)=>{let n=t.calc.scalar(yo(e[0],t),t.frame);if(n instanceof E)return n;let r=1;for(;r+1<e.length;r+=2){let i=t.calc.scalar(yo(e[r],t),t.frame);if(i instanceof E)return i;if(An(n,i)===0)return yo(e[r+1],t)}return r<e.length?yo(e[r],t):D.NA});function Co(e,t){let n=[],r;return Kn(e,t,(e,t)=>{if(r)return;if(e instanceof E){r=e;return}if(typeof e==`string`&&!t||e===null)return;let i=Dn(e);i instanceof E?r=i:n.push(i)}),r||(n.length===0?D.VALUE:n)}F(`AND`,`(r)`,(e,t)=>{let n=Co(e,t);return n instanceof E?n:n.every(Boolean)}),F(`OR`,`(r)`,(e,t)=>{let n=Co(e,t);return n instanceof E?n:n.some(Boolean)}),F(`XOR`,`(r)`,(e,t)=>{let n=Co(e,t);return n instanceof E?n:n.filter(Boolean).length%2==1}),P(`NOT`,1,1,e=>{let t=Dn(e);return t instanceof E?t:!t}),F(`TRUE`,``,()=>!0),F(`FALSE`,``,()=>!1);var wo=(e,t)=>t?{names:e,parent:t}:{names:e};Wn(`LET`,3,255,(e,t)=>{if(e.length%2==0)return D.VALUE;let n=new Map,r={...t.frame,scope:wo(n,t.frame.scope)};for(let i=0;i+1<e.length;i+=2){let a=e[i];if(a?.kind!==`name`)return D.VALUE;n.set(a.name.toLowerCase(),yo(e[i+1],{...t,frame:r}))}return yo(e[e.length-1],{...t,frame:r})}),Wn(`LAMBDA`,1,254,(e,t)=>{let n=[];for(let t of e.slice(0,-1)){if(t.kind!==`name`)return D.VALUE;n.push(t.name.toLowerCase())}let r=e[e.length-1];return r?new Fe(n,r,t.frame):D.VALUE});function To(e){let t=0;for(let n of e)t=Mn(t+n,t,n);return t}F(`SUM`,`(r)`,(e,t)=>{let n=0,r;return Kn(e,t,(e,i)=>{if(!r){if(typeof e==`number`)n=Mn(n+e,n,e);else if(e instanceof E)r=e;else if(i){let i=Jn([e],t);i instanceof E?r=i:n+=i[0]??0}}}),r??jn(n)}),F(`AVERAGE`,`(r)`,(e,t)=>{let n=Jn(e,t);return n instanceof E?n:n.length===0?D.DIV0:To(n)/n.length}),F(`AVERAGEA`,`(r)`,(e,t)=>{let n=Yn(e,t);return n instanceof E?n:n.length===0?D.DIV0:To(n)/n.length}),F(`COUNT`,`(r)`,(e,t)=>{let n=0;return Kn(e,t,(e,r)=>{typeof e==`number`?n+=1:r&&!(e instanceof E)&&e!==null&&(Jn([e],t)instanceof E||(n+=1))}),n}),F(`COUNTA`,`(r)`,(e,t)=>{let n=0;return Kn(e,t,()=>{n+=1}),n}),F(`COUNTBLANK`,`r`,(e,t)=>{let n=e[0];if(n instanceof E)return n;if(n instanceof k){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 O?r.data.filter(e=>e===null||e===``).length:+(r===null||r===``)});var Eo=e=>t=>{if(t instanceof E)return t;if(t.length===0)return 0;let n=t[0]??0;for(let r of t)n=e(n,r);return n},Do=Eo((e,t)=>t<e?t:e),Oo=Eo((e,t)=>t>e?t:e);F(`MIN`,`(r)`,(e,t)=>Do(Jn(e,t))),F(`MAX`,`(r)`,(e,t)=>Oo(Jn(e,t))),F(`MINA`,`(r)`,(e,t)=>Do(Yn(e,t))),F(`MAXA`,`(r)`,(e,t)=>Oo(Yn(e,t))),F(`PRODUCT`,`(r)`,(e,t)=>{let n=Jn(e,t);return n instanceof E?n:n.length===0?0:jn(n.reduce((e,t)=>e*t,1))}),F(`SUMSQ`,`(r)`,(e,t)=>{let n=Jn(e,t);return n instanceof E?n:jn(To(n.map(e=>e*e)))}),F(`SUMPRODUCT`,`(r)`,(e,t)=>{let n=e.map(e=>I(e,t)),r=n[0];if(r===void 0||r instanceof E)return r??D.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 E)return e;if(e.cols!==a||o(e)!==o(r))return D.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 E)return n;r*=typeof n==`number`?n:0}s+=r}return jn(s)});var ko={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 Ao(e){if(!(e instanceof j))return!1;let{node:t}=e.shared;return t?.kind===`call`&&t.name===`SUBTOTAL`}F(`SUBTOTAL`,`v(r)`,(e,t)=>{let n=t.calc.scalar(e[0],t.frame);if(n instanceof E)return n;if(typeof n!=`number`)return D.VALUE;let r=n<100,i=ko[r?n:n-100],a=i===void 0?void 0:zn.get(i);if(a?.kind!==`raw`)return D.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(Ao(e.sheet.at(o,n))?null:t.calc.read(e.sheet,o,n));o.push(new O(a.length,1,a))};for(let t of e.slice(1)){if(t instanceof E)return t;if(t instanceof k)s(t);else if(t instanceof Pe)t.parts.forEach(s);else return D.VALUE}return a.call(o,t)});var jo=(e,t)=>typeof e==typeof t&&!(e instanceof E)&&e!==null;function Mo(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 No=new WeakMap;function Po(e,t){let n=No.get(e);if(n)return n;if(n===void 0){No.set(e,null);return}let r=t();return No.set(e,r),r}function Fo(e,t,n,r,i,a=0,o=1){let s=typeof e==`string`?e:void 0,c=i&&s!==void 0&&rr(s)?ir(s):s;if(s!==void 0&&c===void 0){let e=tr(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=Qn(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=Qn(t.at(n));r!==void 0&&e.set(r,[n])}return e},i=n.reference,a=i?r.calc.indexes.ofRepeated(Rn(`find`,i),[i],e):n.array&&Po(n.array,e);if(a)return a.get(l)?.[0]??-1}for(let e=a;e>=0&&e<t.length;e+=o)if(Qn(t.at(e))===l)return e;return-1}function Io(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&&!jo(t.at(s),e);)--s;if(s<r){r=o+1;continue}let c=An(t.at(s),e);(n?c>=0:c<=0)?(a=s,r=o+1):i=s-1}return a}var Lo=(e,t)=>t.calc.scalar(e??null,t.frame),Ro=(e,t,n)=>e===void 0?n:e instanceof A?!1:Dn(t.calc.scalar(e,t.frame));function zo(e){return(t,n)=>{let r=Lo(t[0],n);if(r instanceof E)return r;let i=I(t[1],n);if(i instanceof E)return i;let a=M(n.calc.scalar(t[2],n.frame));if(a instanceof E)return a;let o=Math.trunc(a);if(o<1)return D.VALUE;let s=i.reference,c=s?s.bottom-s.top+1:i.rows;if(o>(e?i.cols:c))return D.REF;let l=Ro(t[3],n,!0);if(l instanceof E)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 k(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?Io(r,u):Fo(r,u,d,n,!0);return f<0?D.NA:e?i.at(f,o-1):i.at(o-1,f)}}F(`VLOOKUP`,`vrv?v`,zo(!0)),F(`HLOOKUP`,`vrv?v`,zo(!1)),F(`MATCH`,`vr?v`,(e,t)=>{let n=Lo(e[0],t);if(n instanceof E)return n;let r=I(e[1],t);if(r instanceof E)return r;let i=Mo(r);if(!i)return D.NA;let a=e[2]===void 0?1:e[2]instanceof A?0:M(t.calc.scalar(e[2],t.frame));if(a instanceof E)return a;let o=a===0?Fo(n,i,r,t,!0):Io(n,i,a<0);return o<0?D.NA:o+1}),F(`LOOKUP`,`vr?r`,(e,t)=>{let n=Lo(e[0],t);if(n instanceof E)return n;let r=I(e[1],t);if(r instanceof E)return r;let i=r.rows>=r.cols,a=Io(n,{length:i?r.rows:r.cols,at:e=>i?r.at(e,0):r.at(0,e)});if(a<0)return D.NA;if(e[2]===void 0)return i?r.at(a,r.cols-1):r.at(r.rows-1,a);let o=I(e[2],t);if(o instanceof E)return o;let s=Mo(o);return s?s.at(a):D.NA});function Bo(e,t,n,r,i){let a=Mo(t);if(!a)return-1;let o=i===-1;if(Math.abs(i)===2){let t=Io(e,a,i<0);if(t>=0&&An(a.at(t),e)===0)return t;if(r===0)return-1}let s=Fo(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(!jo(n,e))continue;let i=An(n,e),o=c<0||(r<0?An(n,a.at(c))>0:An(n,a.at(c))<0);(r<0?i<0:i>0)&&o&&(c=t)}return c}var Vo=(e,t,n)=>{let r=(e,t)=>e===void 0||e instanceof A?t:M(n.calc.scalar(e,n.frame)),i=r(e,0);if(i instanceof E)return i;let a=r(t,1);return a instanceof E?a:[i,a]};F(`XLOOKUP`,`vrr?rvv`,(e,t)=>{let n=Lo(e[0],t);if(n instanceof E)return n;let r=I(e[1],t);if(r instanceof E)return r;let i=I(e[2],t);if(i instanceof E)return i;let a=Vo(e[4],e[5],t);if(a instanceof E)return a;let o=Bo(n,r,t,a[0],a[1]);if(o<0){let n=e[3];return n===void 0||n instanceof A?D.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 O(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 O(i.rows,1,s)}),F(`XMATCH`,`vr?vv`,(e,t)=>{let n=Lo(e[0],t);if(n instanceof E)return n;let r=I(e[1],t);if(r instanceof E)return r;let i=Vo(e[2],e[3],t);if(i instanceof E)return i;let a=Bo(n,r,t,i[0],i[1]);return a<0?D.NA:a+1}),F(`INDEX`,`rv?vv`,(e,t)=>{let n=e[0],r=e=>{if(e===void 0||e instanceof A)return 0;let n=M(t.calc.scalar(e,t.frame));return n instanceof E?n:Math.trunc(n)};if(n instanceof Pe){let t=r(e[3]??1);if(t instanceof E)return t;let i=n.parts[t-1];if(!i)return D.REF;n=i}if(n instanceof E)return n;let i=r(e[1]);if(i instanceof E)return i;let a=r(e[2]);if(a instanceof E)return a;if(i<0||a<0)return D.VALUE;if(n instanceof k){let t=e[2]===void 0&&n.rows===1,r=t?1:i,o=t?i:a;return r>n.rows||o>n.cols?D.REF:new k(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=I(n,t);if(o instanceof E)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 D.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 O(u,d,f)}),F(`OFFSET`,`rvv?vv`,(e,t)=>{let n=e[0];if(n instanceof E)return n;if(!(n instanceof k))return D.VALUE;let r=(e,n)=>{if(e===void 0||e instanceof A)return n;let r=M(t.calc.scalar(e,t.frame));return r instanceof E?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 E)return e;let[c,l,u,d]=[i,a,o,s];if(u===0||d===0)return D.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?D.REF:new k(n.sheet,Math.min(f,m),Math.min(p,h),Math.max(f,m),Math.max(p,h))},{volatile:!0});var Ho=/^(?:(.*)!)?R(\[-?\d+\]|\d+)?C(\[-?\d+\]|\d+)?(?::R(\[-?\d+\]|\d+)?C(\[-?\d+\]|\d+)?)?$/iu,Uo=(e,t)=>e===void 0?t:e.startsWith(`[`)?t+Number(e.slice(1,-1)):Number(e)-1;function Wo(e,t,n){let r=Ho.exec(e.trim());if(!r)return;let[,i,a,o,s,c]=r,l={row:Uo(a,t),col:Uo(o,n)};if(l.row<0||l.col<0)return;let u=S(l),d=i===void 0?``:`${i}!`;if(s===void 0&&c===void 0)return`${d}${u}`;let f={row:Uo(s,t),col:Uo(c,n)};return f.row<0||f.col<0?void 0:`${d}${u}:${S(f)}`}F(`INDIRECT`,`v?v`,(e,t)=>{let n=N(t.calc.scalar(e[0],t.frame));if(n instanceof E)return n;let r=e[1]===void 0||Dn(t.calc.scalar(e[1],t.frame));if(r instanceof E)return r;let i=r?n:Wo(n,t.frame.row,t.frame.col);if(i===void 0)return D.REF;let a=qt(i);if(!a.ok)return D.REF;let{node:o}=a;if(o.kind!==`ref`&&o.kind!==`structured`&&o.kind!==`name`&&(o.kind!==`binary`||o.op!==`:`))return D.REF;let s=t.calc.eval(o,{...t.frame,dr:0,dc:0});return s instanceof k||s instanceof Pe?s:D.REF},{volatile:!0});var Go=(e,t,n)=>{if(e===void 0||e instanceof A)return t+1;if(e instanceof E)return e;if(e instanceof O)return new O(e.rows,e.cols,e.data.map(e=>e instanceof E?e:D.VALUE));if(!(e instanceof k))return D.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===Ko?new O(i,1,a):new O(1,i,a)},Ko=e=>[e.top,e.bottom===1048575?Math.min(e.rows,e.sheet.lastRow-e.top+1):e.rows],qo=e=>[e.left,e.cols];F(`ROW`,`?r`,(e,t)=>Go(e[0],t.frame.row,Ko)),F(`COLUMN`,`?r`,(e,t)=>Go(e[0],t.frame.col,qo)),F(`ROWS`,`r`,(e,t)=>{let n=e[0];if(n instanceof k)return n.rows;let r=I(n,t);return r instanceof E?r:r.rows}),F(`COLUMNS`,`r`,(e,t)=>{let n=e[0];if(n instanceof k)return n.cols;let r=I(n,t);return r instanceof E?r:r.cols}),F(`AREAS`,`r`,e=>{let t=e[0];return t instanceof k?1:t instanceof Pe?t.parts.length:D.VALUE}),P(`ADDRESS`,2,5,(e,t,n,r,i)=>{let a=M(e),o=M(t),s=n==null?1:M(n);for(let e of[a,o,s])if(e instanceof E)return e;let[c,l,u]=[a,o,s];if((c??0)<1||(l??0)<1||(c??0)>1048576||(l??0)>16384)return D.VALUE;let d=r==null||Dn(r);if(d instanceof E)return d;let f=u===1||u===2,p=u===1||u===3,m=d?`${p?`$`:``}${ne((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=N(i);return h instanceof E?h:`${Be(h)}${m}`}),F(`TRANSPOSE`,`r`,(e,t)=>{let n=I(e[0],t);if(n instanceof E)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 O(n.cols,n.rows,r)}),Wn(`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 k)return r.sheet.index+1;let i=t.calc.scalar(r,t.frame);if(typeof i!=`string`)return D.NA;let a=t.calc.wb.sheet(i);return a?a.index+1:D.NA}),F(`SHEETS`,`?r`,(e,t)=>t.calc.wb.sheets.length);var Jo=(e,t)=>Array.from(e,e=>{let n=t(e);return n.length===e.length?n:e}).join(``),Yo=e=>Jo(e,e=>e.toLowerCase());function Xo(e,t){if(e===void 0||e instanceof A)return[];let n=I(e,t);if(n instanceof E)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=N(i);if(a instanceof E)return a;r.push(a)}return r}function Zo(e,t,n){let r=n?Yo(e):e,i=(n?t.map(Yo):[...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 Qo(e,t,n){let r=[],i=0;for(let a of Zo(e,t,n))r.push(e.slice(i,a.at)),i=a.at+a.length;return r.push(e.slice(i)),r}var $o=e=>t=>{let n=N(t);return n instanceof E?n:e(n)},es=(e,t)=>{if(e===void 0)return t;let n=M(e);return n instanceof E?n:n<0?D.VALUE:Math.trunc(n)},ts=e=>Jo(e,e=>e.toUpperCase()),ns=Yo;P(`LEFT`,1,2,(e,t)=>{let n=N(e),r=es(t,1);return n instanceof E?n:r instanceof E?r:n.slice(0,r)}),P(`RIGHT`,1,2,(e,t)=>{let n=N(e),r=es(t,1);return n instanceof E?n:r instanceof E?r:r===0?``:n.slice(-r)}),P(`MID`,3,3,(e,t,n)=>{let r=N(e),i=M(t),a=es(n,0);if(r instanceof E)return r;if(i instanceof E)return i;if(a instanceof E)return a;if(i<1)return D.VALUE;let o=Math.trunc(i)-1;return r.slice(o,o+a)}),P(`LEN`,1,1,$o(e=>e.length)),P(`LOWER`,1,1,$o(ns)),P(`UPPER`,1,1,$o(ts)),P(`PROPER`,1,1,$o(e=>ns(e).replace(/(^|[^\p{L}])(\p{L})/gu,(e,t,n)=>`${t}${ts(n)}`))),P(`TRIM`,1,1,$o(e=>e.replace(/ +/gu,` `).replace(/^ | $/gu,``))),P(`CLEAN`,1,1,$o(e=>e.replace(/[\u0000-\u001f]/gu,``))),P(`T`,1,1,e=>typeof e==`string`?e:``),P(`EXACT`,2,2,(e,t)=>{let n=N(e),r=N(t);return n instanceof E?n:r instanceof E?r:n===r}),P(`REPT`,2,2,(e,t)=>{let n=N(e),r=es(t,0);return n instanceof E?n:r instanceof E?r:n.length*r>32767?D.VALUE:n.repeat(r)}),P(`CHAR`,1,1,Xn(e=>{let t=Math.trunc(e);return t<1||t>255?D.VALUE:is(t)})),P(`UNICHAR`,1,1,Xn(e=>{let t=Math.trunc(e);return t<1||t>1114111?D.VALUE:String.fromCodePoint(t)})),P(`CODE`,1,1,$o(e=>e===``?D.VALUE:e.charCodeAt(0))),P(`UNICODE`,1,1,$o(e=>e.codePointAt(0)??D.VALUE));var rs=`€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ`;function is(e){return e>=128&&e<160?rs.charAt(e-128):String.fromCharCode(e)}F(`CONCAT`,`(r)`,(e,t)=>{let n=``,r;return qn(e,t,e=>{if(r)return;let t=N(e);t instanceof E?r=t:n+=t}),r??n}),P(`CONCATENATE`,1,255,(...e)=>{let t=``;for(let n of e){let e=N(n);if(e instanceof E)return e;t+=e}return t}),F(`TEXTJOIN`,`rv(r)`,(e,t)=>{let[n,r,...i]=e,a=I(n??``,t);if(a instanceof E)return a;let o=[];for(let e=0;e<a.rows;e++)for(let t=0;t<a.cols;t++){let n=N(a.at(e,t));if(n instanceof E)return n;o.push(n)}let s=Dn(t.calc.scalar(r===void 0||r instanceof A||r,t.frame));if(s instanceof E)return s;let c=[],l;if(qn(i,t,e=>{if(l)return;let t=N(e);t instanceof E?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}),P(`SUBSTITUTE`,3,4,(e,t,n,r)=>{let i=N(e),a=N(t),o=N(n);if(i instanceof E)return i;if(a instanceof E)return a;if(o instanceof E)return o;if(a===``)return i;if(r===void 0)return i.split(a).join(o);let s=M(r);if(s instanceof E)return s;if(s<1)return D.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)}`}),P(`REPLACE`,4,4,(e,t,n,r)=>{let i=N(e),a=M(t),o=es(n,0),s=N(r);if(i instanceof E)return i;if(a instanceof E)return a;if(o instanceof E)return o;if(s instanceof E)return s;if(a<1)return D.VALUE;let c=Math.trunc(a)-1;return`${i.slice(0,c)}${s}${i.slice(c+o)}`}),P(`FIND`,2,3,(e,t,n)=>{let r=N(e),i=N(t),a=n===void 0?1:M(n);if(r instanceof E)return r;if(i instanceof E)return i;if(a instanceof E)return a;if(a<1||a>i.length+1)return D.VALUE;let o=i.indexOf(r,Math.trunc(a)-1);return o<0?D.VALUE:o+1}),P(`SEARCH`,2,3,(e,t,n)=>{let r=N(e),i=N(t),a=n===void 0?1:M(n);if(r instanceof E)return r;if(i instanceof E)return i;if(a instanceof E)return a;if(a<1||a>i.length+1)return D.VALUE;let o=Math.trunc(a)-1,s=ir(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?D.VALUE:n+1}}let c=tr(`${r}*`);for(let e=o;e<=i.length;e++)if(c(i.slice(e)))return e+1;return D.VALUE}),P(`VALUE`,1,1,e=>typeof e==`number`?e:e==null?0:typeof e==`string`?Tn(e)??D.VALUE:D.VALUE),P(`NUMBERVALUE`,1,3,(e,t,n)=>{let r=N(e),i=N(t??`.`),a=N(n??`,`);if(r instanceof E)return r;if(i instanceof E)return i;if(a instanceof E)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)?D.VALUE:c/100**s}),P(`TEXT`,2,2,(e,t)=>{let n=N(t);if(n instanceof E)return n;if(!d(n))return D.VALUE;if(typeof e==`boolean`)return e?`TRUE`:`FALSE`;let r=typeof e==`string`?Tn(e)??e:e??0;if(r instanceof E)return r;try{return p(n,r)}catch{return D.VALUE}});function as(e,t,n){let r=n?`#,##0`:`0`,i=t>0?`.${`0`.repeat(t)}`:``;return p(`${r}${i}`,e)}var os=(e,t)=>{let n=10**t;return Math.sign(e)*Math.round(Math.abs(e)*n+1e-9)/n};P(`FIXED`,1,3,(e,t,n)=>{let r=M(e),i=t==null?2:M(t),a=n!==void 0&&Dn(n);if(r instanceof E)return r;if(i instanceof E)return i;if(a instanceof E)return a;let o=Math.trunc(i);return as(os(r,o),Math.max(0,o),!a)}),P(`DOLLAR`,1,2,(e,t)=>{let n=M(e),r=t==null?2:M(t);if(n instanceof E)return n;if(r instanceof E)return r;let i=Math.trunc(r),a=as(Math.abs(os(n,i)),Math.max(0,i),!0);return n<0?`($${a})`:`$${a}`});function ss(e,t,n,r,i){let a=Zo(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 cs(e){return(t,n)=>{let[r,i,a,o,s,c]=t.map(e=>e instanceof A?void 0:e),l=N(r??null),u=Xo(i,n),d=Zn(a,1),f=Zn(o,0),p=Zn(s,0);if(l instanceof E)return l;if(u instanceof E)return u;if(d instanceof E)return d;if(f instanceof E)return f;if(p instanceof E)return p;let m=Math.trunc(d);if(m===0||Math.abs(m)>Math.max(l.length,1))return D.VALUE;if(u.length>0&&u.every(e=>e===``))return m>0==(e===`before`)?``:l;let h=ss(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?D.NA:c}}F(`TEXTBEFORE`,`vr?vvvv`,cs(`before`)),F(`TEXTAFTER`,`vr?vvvv`,cs(`after`)),P(`HYPERLINK`,1,2,(e,t)=>t===void 0?e??``:t),P(`ENCODEURL`,1,1,$o(e=>encodeURIComponent(e)));for(let e of[`LEN`,`LEFT`,`RIGHT`,`MID`,`FIND`,`SEARCH`,`REPLACE`])Gn(`${e}B`,e);var ls=2958465,us=e=>{let t=M(e);return t instanceof E?t:t<0||t>=2958466?D.NUM:Math.floor(t)},ds=e=>e%4==0&&e%100!=0||e%400==0,fs=(e,t)=>t===2?ds(e)?29:28:[4,6,9,11].includes(t)?30:31,ps=e=>e.month===2&&e.day===fs(e.year,2);P(`DATE`,3,3,Xn((e=0,t=1,n=1)=>{let r=Math.trunc(e);if(r<0||r>9999)return D.NUM;let i=pe(r<1900?r+1900:r,Math.trunc(t),Math.trunc(n));return Number.isFinite(i)&&i>=0&&i<=ls?i:D.NUM})),P(`TIME`,3,3,Xn((e=0,t=0,n=0)=>{let r=Math.trunc(e)*3600+Math.trunc(t)*60+Math.trunc(n);return r<0?D.NUM:r%86400/86400})),P(`YEAR`,1,1,e=>{let t=us(e);return t instanceof E?t:me(t).year}),P(`MONTH`,1,1,e=>{let t=us(e);return t instanceof E?t:me(t).month}),P(`DAY`,1,1,e=>{let t=us(e);return t instanceof E?t:me(t).day});var ms=e=>{let t=M(e);return t instanceof E?t:t<0?D.NUM:Math.round((t-Math.floor(t))*86400)%86400};P(`HOUR`,1,1,e=>{let t=ms(e);return t instanceof E?t:Math.floor(t/3600)}),P(`MINUTE`,1,1,e=>{let t=ms(e);return t instanceof E?t:Math.floor(t/60)%60}),P(`SECOND`,1,1,e=>{let t=ms(e);return t instanceof E?t:t%60}),P(`DATEVALUE`,1,1,e=>{let t=N(e);if(t instanceof E)return t;let n=l(t)??s(t);return typeof n?.value==`number`?Math.floor(n.value):D.VALUE}),P(`TIMEVALUE`,1,1,e=>{let t=N(e);if(t instanceof E)return t;let n=c(t)??s(t);return typeof n?.value==`number`?n.value-Math.floor(n.value):D.VALUE});var hs=e=>(e%7+6)%7;P(`WEEKDAY`,1,2,(e,t)=>{let n=us(e);if(n instanceof E)return n;let r=t==null?1:M(t);if(r instanceof E)return r;let i=hs(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:D.NUM});var gs=e=>{let t=e-(hs(e)+6)%7+3,{year:n}=me(t);return Math.floor((t-pe(n,1,1))/7)+1};P(`ISOWEEKNUM`,1,1,e=>{let t=us(e);return t instanceof E?t:gs(t)}),P(`WEEKNUM`,1,2,(e,t)=>{let n=us(e);if(n instanceof E)return n;let r=t==null?1:M(t);if(r instanceof E)return r;if(r===21)return gs(n);let i=r===1?0:r===2?1:r>=11&&r<=17?(r-10)%7:-1;if(i<0)return D.NUM;let a=pe(me(n).year,1,1),o=(hs(a)+7-i)%7;return Math.floor((n-a+o)/7)+1});var _s=(e,t)=>{let{year:n,month:r,day:i}=me(e),a=n*12+r-1+t,o=Math.floor(a/12),s=a-o*12+1;return pe(o,s,Math.min(i,fs(o,s)))};P(`EDATE`,2,2,(e,t)=>{let n=us(e),r=M(t);if(n instanceof E)return n;if(r instanceof E)return r;let i=_s(n,Math.trunc(r));return i<0?D.NUM:i}),P(`EOMONTH`,2,2,(e,t)=>{let n=us(e),r=M(t);if(n instanceof E)return n;if(r instanceof E)return r;let i=me(_s(n,Math.trunc(r))),a=pe(i.year,i.month,fs(i.year,i.month));return a<0?D.NUM:a}),P(`DAYS`,2,2,(e,t)=>{let n=us(e),r=us(t);return n instanceof E?n:r instanceof E?r:n-r}),P(`DATEDIF`,3,3,(e,t,n)=>{let r=us(e),i=us(t),a=N(n);if(r instanceof E)return r;if(i instanceof E)return i;if(a instanceof E)return a;if(r>i)return D.NUM;let o=me(r),s=me(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 fs(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=_s(r,Math.floor(c/12)*12);return e>=0?i-t:D.NUM}default:return D.NUM}});function vs(e,t,n){let r=me(e),i=me(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===fs(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}P(`DAYS360`,2,3,(e,t,n)=>{let r=us(e),i=us(t),a=n!==void 0&&Dn(n);return r instanceof E?r:i instanceof E?i:a instanceof E?a:vs(r,i,a)});function ys(e,t,n){let[r,i]=e<=t?[e,t]:[t,e],a=me(r),o=me(i),s=i-r;switch(n){case 0:{let e=a.day,t=o.day;return ps(a)&&(ps(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 vs(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=ds(a.year);else{let t=e=>ds(e)?pe(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/((pe(o.year+1,1,1)-pe(a.year,1,1))/e)}}}P(`YEARFRAC`,2,3,(e,t,n)=>{let r=us(e),i=us(t),a=n==null?0:M(n);if(r instanceof E)return r;if(i instanceof E)return i;if(a instanceof E)return a;let o=Math.trunc(a);return o<0||o>4?D.NUM:ys(r,i,o)});function bs(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 D.VALUE;let t=e.split(``).map(e=>e===`1`);return[t[6]??!1,...t.slice(0,6)]}let n=M(e);return n instanceof E?n:n>=1&&n<=7?t((n+5)%7,(n+6)%7):n>=11&&n<=17?t(n-11):D.NUM}function xs(e,t){if(e===void 0||e instanceof A)return new Set;let n=Jn([e],t);return n instanceof E?n:new Set(n.map(e=>Math.floor(e)))}function Ss(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[hs(o)]!==!0&&!r.has(o)&&(a+=i);return a}function Cs(e,t,n,r){if(n.every(Boolean))return D.VALUE;let i=t<0?-1:1,a=e;for(let e=Math.abs(t);e>0;)a+=i,n[hs(a)]!==!0&&!r.has(a)&&--e;return a<0?D.NUM:a}var ws=e=>(t,n)=>{let r=us(n.calc.scalar(t[0],n.frame)),i=us(n.calc.scalar(t[1],n.frame));if(r instanceof E)return r;if(i instanceof E)return i;let a=e?t[2]:void 0,o=bs(a===void 0||a instanceof A?void 0:n.calc.scalar(a,n.frame));if(o instanceof E)return o;let s=xs(t[e?3:2],n);return s instanceof E?s:Ss(r,i,o,s)},Ts=e=>(t,n)=>{let r=us(n.calc.scalar(t[0],n.frame)),i=M(n.calc.scalar(t[1],n.frame));if(r instanceof E)return r;if(i instanceof E)return i;let a=e?t[2]:void 0,o=bs(a===void 0||a instanceof A?void 0:n.calc.scalar(a,n.frame));if(o instanceof E)return o;let s=xs(t[e?3:2],n);return s instanceof E?s:Cs(r,Math.trunc(i),o,s)};F(`NETWORKDAYS`,`vv?r`,ws(!1)),F(`NETWORKDAYS.INTL`,`vv?vr`,ws(!0)),F(`WORKDAY`,`vv?r`,Ts(!1)),F(`WORKDAY.INTL`,`vv?vr`,Ts(!0)),F(`NOW`,``,(e,t)=>t.calc.nowSerial(),{volatile:!0}),F(`TODAY`,``,(e,t)=>Math.floor(t.calc.nowSerial()),{volatile:!0});function Es(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 Ds=(e,t)=>{let n=[];return qn([e],t,e=>n.push(e)),n},Os=(e,t)=>{let n=Ds(e[0],t),r=Ds(e[1],t);if(n.length!==r.length)return D.NUM;let i=[],a=[];for(let[e,t]of n.entries()){let n=r[e]??null;if(t instanceof E)return t;if(n instanceof E)return n;if(typeof t==`number`){if(typeof n!=`number`)return D.VALUE;i.push(t),a.push(Math.floor(n))}}return i.length===0?D.NUM:{values:i,dates:a}};F(`XNPV`,`vrr`,(e,t)=>{let n=M(t.calc.scalar(e[0],t.frame));if(n instanceof E)return n;let r=Os(e.slice(1),t);return r instanceof E?r:n<=0?D.NUM:Es(n,r.values,r.dates)}),F(`XIRR`,`rr?v`,(e,t)=>{let n=Os(e,t);if(n instanceof E)return n;let{values:r,dates:i}=n;if(!r.some(e=>e>0)||!r.some(e=>e<0))return D.NUM;let a=e[2]===void 0||e[2]instanceof A?.1:M(t.calc.scalar(e[2],t.frame));if(a instanceof E)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 D.NUM;if(Math.abs(n-s)<1e-10)return n;s=n<=-1?(s-1)/2:n}return D.NUM});var ks=(e,t)=>{P(e,1,1,e=>t(e),{errors:!0})};ks(`ISBLANK`,e=>e==null),ks(`ISNUMBER`,e=>typeof e==`number`),ks(`ISTEXT`,e=>typeof e==`string`),ks(`ISNONTEXT`,e=>typeof e!=`string`),ks(`ISLOGICAL`,e=>typeof e==`boolean`),ks(`ISERROR`,e=>e instanceof E),ks(`ISERR`,e=>e instanceof E&&e!==D.NA),ks(`ISNA`,e=>e===D.NA);var As=(e,t)=>{let n=M(e);return n instanceof E?n:Math.abs(Math.trunc(n))%2===t};P(`ISEVEN`,1,1,e=>As(e,0)),P(`ISODD`,1,1,e=>As(e,1)),P(`N`,1,1,e=>typeof e==`number`?e:typeof e==`boolean`?+!!e:e instanceof E?e:0,{errors:!0}),F(`NA`,``,()=>D.NA),F(`TYPE`,`r`,(e,t)=>{let n=t.calc.flat(e[0]);return n instanceof O?64:typeof n==`number`||n===null?1:typeof n==`string`?2:typeof n==`boolean`?4:16});var js=[D.NULL,D.DIV0,D.VALUE,D.REF,D.NAME,D.NUM,D.NA];P(`ERROR.TYPE`,1,1,e=>{let t=e instanceof E?js.indexOf(e):-1;return t<0?D.NA:t+1},{errors:!0}),Wn(`ISREF`,1,1,(e,t)=>{let n=e[0];if(!n)return!1;let r=t.calc.eval(n,t.frame);return r instanceof k||r instanceof Pe});var Ms=e=>e instanceof k?e.sheet.at(e.top,e.left):void 0;Wn(`ISFORMULA`,1,1,(e,t)=>{let n=e[0];if(!n)return D.VALUE;let r=t.calc.eval(n,t.frame);return r instanceof Fe?D.VALUE:Ms(r)instanceof j}),Wn(`FORMULATEXT`,1,1,(e,t)=>{let n=e[0];if(!n)return D.VALUE;let r=Ms(t.calc.eval(n,t.frame));return r instanceof j?r.text:D.NA}),F(`CELL`,`v?r`,(e,t)=>{let n=N(t.calc.scalar(e[0],t.frame));if(n instanceof E)return n;let r=e[1],i=r instanceof k?r:new k(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 S({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 D.VALUE}}),F(`TABLE`,`?rrrrr`,()=>D.NA);var Ns=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,y=(u-g)/v,b=ee+y,x=0,te=i-1,ne=1;ne<=v;ne++){for(var re=0,S=.5*(b+ee),C=.5*(b-ee),ie=1;ie<=a;ie++){var w,ae;o<ie?(w=a-ie+1,ae=m[w-1]):(w=ie,ae=-m[w-1]);var oe=S+C*ae,T=oe*oe;if(T>l)break;var E=2*e.normal.cdf(oe,0,1,1,0),D=2*e.normal.cdf(oe,n,1,1,0),se=E*.5-D*.5;se>=t.exp(s/te)&&(se=h[w-1]*t.exp(-(.5*T))*t.pow(se,te),re+=se)}re*=2*C*i/t.sqrt(2*t.PI),x+=re,ee=b,b+=y}return _+=x,_<=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,y=.5-.5*e,b=t.sqrt(t.log(1/(y*y))),x=b+((((b*f+u)*b+c)*b+o)*b+i)/((((b*p+d)*b+l)*b+s)*b+a);r<ee&&(x+=(x*x*x+x)/r/4);var te=m-h*x;return r<ee&&(te+=-g/r+_*x/r),x*(te*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,y=[.9894009349916499,.9445750230732326,.8656312023878318,.755404408355003,.6178762444026438,.45801677765722737,.2816035507792589,.09501250983763744],b=[.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 x=a*.5,te=x*t.log(a)-a*t.log(2)-e.gammaln(x),ne=x-1,re=a*.25,S=a<=f?g:a<=p?_:a<=m?v:ee;te+=t.log(S);for(var C=0,ie=1;ie<=50;ie++){for(var w=0,ae=(2*ie-1)*S,oe=1;oe<=c;oe++){var T,E;l<oe?(T=oe-l-1,E=te+ne*t.log(ae+y[T]*S)-(y[T]*S+ae)*re):(T=oe-1,E=te+ne*t.log(ae-y[T]*S)+(y[T]*S-ae)*re);var D;if(E>=u){D=l<oe?n*t.sqrt((y[T]*S+ae)*.5):n*t.sqrt((-(y[T]*S)+ae)*.5);var se=i(D,o,s)*b[T]*t.exp(E);w+=se}}if(ie*S>=1&&w<=d)break;C+=w}if(w>d)throw Error(`tukey.cdf failed to converge`);return C>1&&(C=1),C},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})})),Ps=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})})),Fs=t({ABS:()=>od,ACCRINT:()=>Rh,ACOS:()=>sd,ACOSH:()=>cd,ACOT:()=>ld,ACOTH:()=>ud,AGGREGATE:()=>dd,AND:()=>_g,ARABIC:()=>fd,ASIN:()=>pd,ASINH:()=>md,ATAN:()=>hd,ATAN2:()=>gd,ATANH:()=>_d,AVEDEV:()=>Vl,AVERAGE:()=>Hl,AVERAGEA:()=>Ul,AVERAGEIF:()=>Wl,AVERAGEIFS:()=>Gl,BASE:()=>vd,BESSELI:()=>gp,BESSELJ:()=>_p,BESSELK:()=>vp,BESSELY:()=>yp,BETA:()=>Kl,BETADIST:()=>pm,BETAINV:()=>mm,BIN2DEC:()=>bp,BIN2HEX:()=>xp,BIN2OCT:()=>Sp,BINOM:()=>ql,BINOMDIST:()=>hm,BITAND:()=>Cp,BITLSHIFT:()=>wp,BITOR:()=>Tp,BITRSHIFT:()=>Ep,BITXOR:()=>Dp,CEILING:()=>yd,CEILINGMATH:()=>gm,CEILINGPRECISE:()=>_m,CHAR:()=>fl,CHIDIST:()=>vm,CHIDISTRT:()=>ym,CHIINV:()=>bm,CHIINVRT:()=>xm,CHISQ:()=>Jl,CHITEST:()=>Sm,CHOOSE:()=>qc,CHOOSECOLS:()=>Jc,CHOOSEROWS:()=>Yc,CLEAN:()=>pl,CODE:()=>ml,COLUMN:()=>Xc,COLUMNS:()=>Zc,COMBIN:()=>bd,COMBINA:()=>xd,COMPLEX:()=>Op,CONCAT:()=>gl,CONCATENATE:()=>hl,CONFIDENCE:()=>Yl,CONVERT:()=>kp,CORREL:()=>Xl,COS:()=>Sd,COSH:()=>Cd,COT:()=>wd,COTH:()=>Td,COUNT:()=>Zl,COUNTA:()=>Ql,COUNTBLANK:()=>$l,COUNTIF:()=>eu,COUNTIFS:()=>tu,COUPDAYS:()=>zh,COVAR:()=>Cm,COVARIANCE:()=>nu,COVARIANCEP:()=>wm,COVARIANCES:()=>Tm,CRITBINOM:()=>Em,CSC:()=>Ed,CSCH:()=>Dd,CUMIPMT:()=>Bh,CUMPRINC:()=>Vh,DATE:()=>Uf,DATEDIF:()=>Wf,DATEVALUE:()=>Gf,DAVERAGE:()=>xh,DAY:()=>Kf,DAYS:()=>Jf,DAYS360:()=>Yf,DB:()=>Hh,DCOUNT:()=>Sh,DCOUNTA:()=>Ch,DDB:()=>Uh,DEC2BIN:()=>Ap,DEC2HEX:()=>jp,DEC2OCT:()=>Mp,DECIMAL:()=>Od,DEGREES:()=>kd,DELTA:()=>Np,DEVSQ:()=>ru,DGET:()=>wh,DISC:()=>Wh,DMAX:()=>Th,DMIN:()=>Eh,DOLLAR:()=>_l,DOLLARDE:()=>Gh,DOLLARFR:()=>Kh,DPRODUCT:()=>Dh,DROP:()=>Qc,DSTDEV:()=>Oh,DSTDEVP:()=>kh,DSUM:()=>Ah,DVAR:()=>jh,DVARP:()=>Mh,EDATE:()=>Xf,EFFECT:()=>qh,EOMONTH:()=>Zf,ERF:()=>Pp,ERFC:()=>Fp,ERFCPRECISE:()=>Dm,ERFPRECISE:()=>Om,ERROR:()=>Nc,EVEN:()=>Ad,EXACT:()=>vl,EXP:()=>jd,EXPAND:()=>$c,EXPON:()=>iu,EXPONDIST:()=>km,F:()=>au,FACT:()=>Nd,FACTDOUBLE:()=>Pd,FALSE:()=>vg,FDIST:()=>Am,FDISTRT:()=>jm,FIND:()=>yl,FINV:()=>Mm,FINVRT:()=>Nm,FISHER:()=>ou,FISHERINV:()=>su,FIXED:()=>bl,FLOOR:()=>Fd,FLOORMATH:()=>Pm,FLOORPRECISE:()=>Fm,FORECAST:()=>cu,FREQUENCY:()=>lu,FTEST:()=>Im,FV:()=>Jh,FVSCHEDULE:()=>Yh,GAMMA:()=>uu,GAMMADIST:()=>Lm,GAMMAINV:()=>Rm,GAMMALN:()=>du,GAMMALNPRECISE:()=>zm,GAUSS:()=>fu,GCD:()=>Id,GEOMEAN:()=>pu,GESTEP:()=>Ip,GROWTH:()=>mu,HARMEAN:()=>hu,HEX2BIN:()=>Lp,HEX2DEC:()=>Rp,HEX2OCT:()=>zp,HLOOKUP:()=>el,HOUR:()=>Qf,HSTACK:()=>ul,HYPGEOM:()=>gu,HYPGEOMDIST:()=>Bm,IF:()=>yg,IFERROR:()=>xg,IFNA:()=>Sg,IFS:()=>bg,IMABS:()=>Bp,IMAGINARY:()=>Vp,IMARGUMENT:()=>Hp,IMCONJUGATE:()=>Up,IMCOS:()=>Wp,IMCOSH:()=>Gp,IMCOT:()=>Kp,IMCSC:()=>am,IMCSCH:()=>om,IMDIV:()=>qp,IMEXP:()=>Jp,IMLN:()=>Yp,IMLOG10:()=>Xp,IMLOG2:()=>Zp,IMPOWER:()=>Qp,IMPRODUCT:()=>$p,IMREAL:()=>Y,IMSEC:()=>em,IMSECH:()=>tm,IMSIN:()=>nm,IMSINH:()=>rm,IMSQRT:()=>im,IMSUB:()=>sm,IMSUM:()=>cm,IMTAN:()=>lm,INDEX:()=>tl,INT:()=>Ld,INTERCEPT:()=>_u,IPMT:()=>Xh,IRR:()=>Zh,ISBLANK:()=>Pc,ISERR:()=>Fc,ISERROR:()=>Ic,ISEVEN:()=>Lc,ISLOGICAL:()=>Rc,ISNA:()=>zc,ISNONTEXT:()=>Bc,ISNUMBER:()=>Vc,ISO:()=>Rd,ISODD:()=>Hc,ISOWEEKNUM:()=>$f,ISPMT:()=>Qh,ISTEXT:()=>Uc,KURT:()=>vu,LARGE:()=>yu,LCM:()=>zd,LEFT:()=>xl,LEN:()=>Sl,LINEST:()=>bu,LN:()=>Bd,LOG:()=>Vd,LOG10:()=>Hd,LOGEST:()=>xu,LOGINV:()=>Vm,LOGNORM:()=>Su,LOGNORMDIST:()=>Hm,LOGNORMINV:()=>Um,LOOKUP:()=>nl,LOWER:()=>Cl,MATCH:()=>rl,MAX:()=>Cu,MAXA:()=>wu,MAXIFS:()=>Tu,MEDIAN:()=>Eu,MID:()=>wl,MIN:()=>Du,MINA:()=>Ou,MINIFS:()=>ku,MINUTE:()=>ep,MIRR:()=>$h,MMULT:()=>Ud,MOD:()=>Wd,MODE:()=>Au,MODEMULT:()=>Wm,MODESNGL:()=>Gm,MONTH:()=>tp,MROUND:()=>Gd,MULTINOMIAL:()=>Kd,MUNIT:()=>qd,N:()=>Wc,NA:()=>Gc,NEGBINOM:()=>ju,NEGBINOMDIST:()=>Km,NETWORKDAYS:()=>np,NETWORKDAYSINTL:()=>qm,NOMINAL:()=>eg,NORM:()=>Mu,NORMDIST:()=>Jm,NORMINV:()=>Ym,NORMSDIST:()=>Xm,NORMSINV:()=>Zm,NOT:()=>Cg,NOW:()=>rp,NPER:()=>tg,NPV:()=>ng,NUMBERVALUE:()=>Tl,OCT2BIN:()=>um,OCT2DEC:()=>dm,OCT2HEX:()=>fm,ODD:()=>Jd,OR:()=>wg,PDURATION:()=>rg,PEARSON:()=>Nu,PERCENTILE:()=>Pu,PERCENTILEEXC:()=>Qm,PERCENTILEINC:()=>$m,PERCENTRANK:()=>Fu,PERCENTRANKEXC:()=>eh,PERCENTRANKINC:()=>th,PERMUT:()=>Iu,PERMUTATIONA:()=>Lu,PHI:()=>Ru,PI:()=>Yd,PMT:()=>ig,POISSON:()=>zu,POISSONDIST:()=>nh,POWER:()=>Xd,PPMT:()=>ag,PRICEDISC:()=>og,PROB:()=>Bu,PRODUCT:()=>Zd,PROPER:()=>El,PV:()=>sg,QUARTILE:()=>Vu,QUARTILEEXC:()=>rh,QUARTILEINC:()=>ih,QUOTIENT:()=>Qd,RADIANS:()=>$d,RAND:()=>ef,RANDBETWEEN:()=>tf,RANK:()=>Hu,RANKAVG:()=>ah,RANKEQ:()=>oh,RATE:()=>cg,REPLACE:()=>Dl,REPT:()=>Ol,RIGHT:()=>kl,ROMAN:()=>nf,ROUND:()=>af,ROUNDDOWN:()=>of,ROUNDUP:()=>sf,ROW:()=>Uu,ROWS:()=>il,RRI:()=>lg,RSQ:()=>Wu,SEARCH:()=>Al,SEC:()=>cf,SECH:()=>lf,SECOND:()=>ip,SERIESSUM:()=>uf,SIGN:()=>df,SIN:()=>ff,SINH:()=>pf,SKEW:()=>Gu,SKEWP:()=>sh,SLN:()=>ug,SLOPE:()=>Ku,SMALL:()=>qu,SORT:()=>al,SQRT:()=>mf,SQRTPI:()=>hf,STANDARDIZE:()=>Ju,STDEV:()=>Yu,STDEVA:()=>Xu,STDEVP:()=>ch,STDEVPA:()=>Zu,STDEVS:()=>lh,STEYX:()=>Qu,SUBSTITUTE:()=>jl,SUBTOTAL:()=>gf,SUM:()=>_f,SUMIF:()=>vf,SUMIFS:()=>yf,SUMPRODUCT:()=>bf,SUMSQ:()=>xf,SUMX2MY2:()=>Sf,SUMX2PY2:()=>Cf,SUMXMY2:()=>wf,SWITCH:()=>Dg,SYD:()=>dg,T:()=>Ml,TAKE:()=>ol,TAN:()=>Tf,TANH:()=>Ef,TBILLEQ:()=>fg,TBILLPRICE:()=>pg,TBILLYIELD:()=>mg,TDIST:()=>uh,TDISTRT:()=>dh,TEXT:()=>Nl,TEXTJOIN:()=>Pl,TIME:()=>ap,TIMEVALUE:()=>op,TINV:()=>fh,TODAY:()=>sp,TRANSPOSE:()=>sl,TREND:()=>$u,TRIM:()=>Fl,TRIMMEAN:()=>ed,TRUE:()=>Tg,TRUNC:()=>Df,TTEST:()=>ph,TYPE:()=>Kc,UNICHAR:()=>Il,UNICODE:()=>Ll,UNIQUE:()=>cl,UPPER:()=>Rl,VALUE:()=>zl,VAR:()=>td,VARA:()=>nd,VARP:()=>mh,VARPA:()=>rd,VARS:()=>hh,VLOOKUP:()=>ll,VSTACK:()=>dl,WEEKDAY:()=>cp,WEEKNUM:()=>lp,WEIBULL:()=>id,WEIBULLDIST:()=>gh,WORKDAY:()=>up,WORKDAYINTL:()=>_h,XIRR:()=>hg,XNPV:()=>gg,XOR:()=>Eg,YEAR:()=>dp,YEARFRAC:()=>mp,Z:()=>ad,ZTEST:()=>vh,utils:()=>Og}),z=e(Ns(),1),Is=e(Ps(),1),Ls=Error(`#NULL!`),Rs=Error(`#DIV/0!`),B=Error(`#VALUE!`),zs=Error(`#REF!`),Bs=Error(`#NAME?`),V=Error(`#NUM!`),H=Error(`#N/A`),Vs=Error(`#ERROR!`),Hs=Error(`#GETTING_DATA`),Us=Error(`#CALC!`),Ws=Object.freeze({__proto__:null,calc:Us,data:Hs,div0:Rs,error:Vs,na:H,name:Bs,nil:Ls,num:V,ref:zs,value:B}),Gs=!1;function Ks(){Gs=!0}function qs(){Gs=!1}function Js(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 Ys(e){let t=new Date(1900,0,1),n=e>-22038912e5?2:1;return Math.ceil((e-t)/864e5)+n}var Xs=Object.freeze({__proto__:null,dateToSerial:Ys,get returnSerial(){return Gs},serialToDate:Js,useDate:qs,useSerial:Ks}),Zs=`=`,Qs=[`>`,`>=`,`<`,`<=`,`=`,`<>`],$s=`operator`,ec=`literal`,tc=[$s,ec],nc=$s,rc=ec;function ic(e,t){if(tc.indexOf(t)===-1)throw Error(`Unsupported token type: `+t);return{value:e,type:t}}function ac(e){return typeof e==`string`&&/^\d+(\.\d+)?$/.test(e)&&(e=e.indexOf(`.`)===-1?parseInt(e,10):parseFloat(e)),e}function oc(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 sc(e){let t=``,n=[];for(let r=0;r<e.length;r++){let i=e[r];r===0&&Qs.indexOf(i)>=0?n.push(ic(i,nc)):t+=i}return t.length>0&&n.push(ic(ac(t),rc)),n.length>0&&n[0].type!==nc&&n.unshift(ic(Zs,nc)),n}function cc(e){let t=[],n;for(let r=0;r<e.length;r++){let i=e[r];switch(i.type){case nc:n=i.value;break;case rc:t.push(i.value)}}return lc(t,n)}function lc(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 uc(e){return sc(oc(e))}var dc=cc;function fc(e){let t=[];return pc(e,e=>{t.push(e)}),t}function pc(e,t){let n=-1,r=e.length;for(;++n<r&&t(e[n],n,e)!==!1;);return e}function mc(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=q(n);e[t]=r instanceof Error?0:r}}return e}function hc(e){return[e.length,e.reduce((e,t)=>Math.max(e,t.length),0)]}function gc(e,t){let n=[e,t];return n.some(e=>!Mc(e))?H:n.some(e=>e<=0)?B:Array.from({length:e},()=>Array.from({length:t},()=>void 0))}function _c(e,t){if(!e)return B;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 U(){let e;if(arguments.length===1){let t=arguments[0];e=bc(t)?fc.apply(null,arguments):[t]}else e=Array.from(arguments);for(;!xc(e);)e=vc(e);return e}function vc(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 yc(e,t){return t||=1,!e||typeof e.slice!=`function`?e:e.slice(0,e.length-t)}function bc(e){return e!=null&&typeof e.length==`number`&&typeof e!=`string`}function xc(e){if(!e)return!1;for(let t=0;t<e.length;++t)if(Array.isArray(e[t]))return!1;return!0}function Sc(e,t){return t||=1,!e||typeof e.slice!=`function`?e:e.slice(t)}function Cc(e){return e?e[0].map((t,n)=>e.map(e=>e[n])):B}function wc(e,t){let n=null;return pc(e,(e,r)=>{if(e[0]===t)return n=r,!1}),n??B}function W(){for(let e=0;e<arguments.length;e++)if(arguments[e]instanceof Error)return arguments[e]}function G(){let e=arguments.length;for(;e--;)if(arguments[e]instanceof Error)return!0;return!1}function Tc(e){let t=0x5af3107a4000;return Math.round(e*t)/t}function Ec(){return U.apply(null,arguments).filter(e=>typeof e==`number`)}function Dc(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)||B}function K(e){if(!isNaN(e)){if(e instanceof Date)return new Date(e);let t=parseFloat(e);return t<0||t>=2958466?V:Js(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:B}function Oc(e){let t=e.length,n;for(;t--;){if(n=K(e[t]),n===B)return n;e[t]=n}return e}function q(e){return e instanceof Error?e:e==null?0:(typeof e==`boolean`&&(e=+e),!isNaN(e)&&e!==``?parseFloat(e):B)}function J(e){let t;if(!e||(t=e.length)===0)return B;let n;for(;t--;){if(e[t]instanceof Error)return e[t];if(n=q(e[t]),n instanceof Error)return n;e[t]=n}return e}function kc(e){return e instanceof Error?e:e==null?``:e.toString()}function Ac(){let e=arguments.length;for(;e--;)if(typeof arguments[e]==`string`)return!0;return!1}function jc(){let e=fc(arguments),t=J(U(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]=U(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=uc(i+``);s=dc([ic(r,rc)].concat(e))}if(!s){a=!1;break}a=!0}a&&i.push(t[e])}return i}function Mc(e){return e!=null}var Nc={};Nc.TYPE=e=>{switch(e){case Ls:return 1;case Rs:return 2;case B:return 3;case zs:return 4;case Bs:return 5;case V:return 6;case H:return 7;case Hs:return 8}return H};function Pc(e){return e===null}function Fc(e){return[B,zs,Rs,V,Bs,Ls].indexOf(e)>=0||typeof e==`number`&&(isNaN(e)||!isFinite(e))}function Ic(e){return Fc(e)||e===H}function Lc(e){return!(Math.floor(Math.abs(e))&1)}function Rc(e){return e===!0||e===!1}function zc(e){return e===H}function Bc(e){return typeof e!=`string`}function Vc(e){return typeof e==`number`&&!isNaN(e)&&isFinite(e)}function Hc(e){return!!(Math.floor(Math.abs(e))&1)}function Uc(e){return typeof e==`string`}function Wc(e){return Vc(e)?e:e instanceof Date?e.getTime():e===!0?1:e===!1?0:Ic(e)?e:0}function Gc(){return H}function Kc(e){if(Vc(e))return 1;if(Uc(e))return 2;if(Rc(e))return 4;if(Ic(e))return 16;if(Array.isArray(e))return 64}function qc(){if(arguments.length<2)return H;let e=arguments[0];return e<1||e>254||arguments.length<e+1?B:arguments[e]}function Jc(e,t,...n){if(!Array.isArray(e))return B;let r=U([t,...n]),[i,a]=hc(e);if(r.some(e=>{if(!Mc(e))return!0;let t=Math.abs(e);return!(0<t&&t<=a)}))return B;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 Yc(e,t,...n){if(!Array.isArray(e))return B;let r=U([t,...n]);return r.some(t=>{if(!Mc(t))return!0;let n=Math.abs(t);return!(0<n&&n<=e.length)})?B:r.map(t=>t<0?t+e.length+1:t).reduce((t,n)=>{let r=[...e[--n]].map(e=>Mc(e)?e:0);return t.push(r),t},[])}function Xc(e,t){if(arguments.length!==2)return H;if(t<0)return V;if(!(e instanceof Array)||typeof t!=`number`)return B;if(e.length!==0)return z.default.col(e,t)}function Zc(e){return arguments.length===1?e instanceof Array?e.length===0?0:z.default.cols(e):B:H}function Qc(e,t,n){if(G(e,t,n))return W(e,t,n);if(!(e instanceof Array))return B;let r=[],[i,a]=hc(e),o=0,s=i;if(typeof t==`number`){if(Math.abs(t)>i)return Us;t>0?o=t:t<0&&(s+=t)}let c=0,l=a;if(typeof n==`number`){if(Math.abs(n)>a)return Us;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 $c(e,t,n,r){let[i,a]=hc(e);if(Mc(t)||(t=i),Mc(n)||(n=a),t<i||n<a)return B;let o=gc(t,n);for(let s=0;s<t;s++)for(let t=0;t<n;t++){let n=e[s]?.[t];Mc(n)||(n=s<i&&t<a?0:r??H),o[s][t]=n}return o}function el(e,t,n,r){return ll(e,Cc(t),n,r)}function tl(e,t,n){let r=W(e,t,n);if(r)return r;if(!Array.isArray(e))return B;let i=e.length>0&&!Array.isArray(e[0]);return i&&!n?(n=t,t=1):(n||=1,t||=1),n<0||t<0?B:i&&t===1&&n<=e.length?e[n-1]:t<=e.length&&n<=e[t-1].length?e[t-1][n-1]:zs}function nl(e,t,n){t=U(t),n=n?U(n):t;let r=typeof e==`number`,i=H;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 rl(e,t,n){if(!e&&e!==0||!t||(arguments.length===2&&(n=1),t=U(t),!(t instanceof Array))||n!==-1&&n!==0&&n!==1)return H;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||H}function il(e){return arguments.length===1?e instanceof Array?e.length===0?0:z.default.rows(e):B:H}function al(e,t=1,n=1,r=!1){if(!e||!Array.isArray(e))return H;if(e.length===0)return 0;if(t=q(t),!t||t<1||(n=q(n),n!==1&&n!==-1))return B;if(r=Dc(r),typeof r!=`boolean`)return Bs;let i=e=>e.sort((e,r)=>(e=kc(e[t-1]),r=kc(r[t-1]),n===1?e<r?n*-1:n:e>r?n:n*-1)),a=_c(e),o=r?Cc(a):a;return t>=1&&t<=o[0].length?r?Cc(i(o)):i(o):B}function ol(e,t,n){if(G(e,t,n))return W(e,t,n);if(!(e instanceof Array))return B;let[r,i]=hc(e),a=0,o=r-1;if(typeof t==`number`){if(t===0)return Us;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 Us;Math.abs(n)<=i&&(n<0?s=i+n:c=n-1)}let l=gc(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 sl(e){return e?Cc(_c(e)):H}function cl(){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 ll(e,t,n,r){if(!t||!n)return H;r=r!==0&&r!==!1;let i=H,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]:zs;break}!a&&(o&&r&&u<=e||r&&typeof u==`string`&&u.localeCompare(e)<0)&&(i=n<l.length+1?l[n-1]:zs),o&&u>e&&(a=!0)}return i}function ul(e,...t){let n=[e,...t],r=0,i=0,a=[];for(let e of n){let[t,n]=hc(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:H);s++}}return o}function dl(e,...t){let n=[e,...t],r=0,i=0;for(let e of n){let[t,n]=hc(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:H)}return a}function fl(e){return e=q(e),e===0?B:e instanceof Error?e:String.fromCharCode(e)}function pl(e){return G(e)?e:(e||=``,e.replace(/[\0-\x1F]/g,``))}function ml(e){if(G(e))return e;e||=``;let t=e.charCodeAt(0);return isNaN(t)&&(t=B),t}function hl(){let e=U(arguments),t=W.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 gl=hl;function _l(e,t=2){if(e=q(e),isNaN(e))return B;e=af(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 vl(e,t){return arguments.length===2?W(e,t)||(e=kc(e),t=kc(t),e===t):H}function yl(e,t,n){if(arguments.length<2)return H;e=kc(e),t=kc(t),n=n===void 0?0:n;let r=t.indexOf(e,n-1);return r===-1?B:r+1}function bl(e,t=2,n=!1){if(e=q(e),isNaN(e)||(t=q(t),isNaN(t)))return B;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 xl(e,t){return W(e,t)||(e=kc(e),t=t===void 0?1:t,t=q(t),t instanceof Error||typeof e!=`string`?B:e.substring(0,t))}function Sl(e){return arguments.length===0?Vs:e instanceof Error?e:Array.isArray(e)?B:kc(e).length}function Cl(e){return arguments.length===1?(e=kc(e),G(e)?e:e.toLowerCase()):B}function wl(e,t,n){if(G(e,t,n))return W(e,t,n);let r=[t,n].map(e=>q(e));if(!r.every(e=>!(e instanceof Error)&&e>0))return B;Mc(e)?typeof e!=`string`&&(e=String(e)):e=``,[t,n]=r;let i=t-1,a=i+n;return e.substring(i,a)}function Tl(e,t,n){return e=Mc(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,``))):H}function El(e){return G(e)?e:isNaN(e)&&typeof e==`number`?B:(e=kc(e),e.replace(/\w\S*/g,e=>e.charAt(0).toUpperCase()+e.substr(1).toLowerCase()))}function Dl(e,t,n,r){return t=q(t),n=q(n),G(t,n)||typeof e!=`string`||typeof r!=`string`?B:e.substr(0,t-1)+r+e.substr(t-1+n)}function Ol(e,t){return W(e,t)||(e=kc(e),t=q(t),t instanceof Error?t:Array(t+1).join(e))}function kl(e,t){return W(e,t)||(e=kc(e),t=t===void 0?1:t,t=q(t),t instanceof Error?t:e.substring(e.length-t))}function Al(e,t,n){let r;return typeof e!=`string`||typeof t!=`string`?B:(n=n===void 0?0:n,r=t.toLowerCase().indexOf(e.toLowerCase(),n-1)+1,r===0?B:r)}function jl(e,t,n,r){if(arguments.length<3)return H;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 B;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 Ml(e){return e instanceof Error||typeof e==`string`?e:``}function Nl(e,t){if(e===void 0||e instanceof Error||t instanceof Error)return H;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 B;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=bl(e,i,a),e.startsWith(`-`)?(e=e.replace(`-`,``),e=`-`+n+e):e=n+e,r&&(e+=`%`),e}function Pl(e,t,...n){if(typeof t!=`boolean`&&(t=Dc(t)),arguments.length<3)return H;e??=``;let r=U(n),i=t?r.filter(e=>e):r;if(Array.isArray(e)){e=U(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=U(t),i.join(``)}return i.join(e)}function Fl(e){return e=kc(e),e instanceof Error?e:e.replace(/\s+/g,` `).trim()}var Il=fl,Ll=ml;function Rl(e){return e=kc(e),e instanceof Error?e:e.toUpperCase()}function zl(e){let t=W(e);if(t)return t;if(typeof e==`number`)return e;if(Mc(e)||(e=``),typeof e!=`string`)return B;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)?B:(r||=0,n&&(r*=.01),r)}var Bl=2.5066282746310002;function Vl(){let e=U(arguments).filter(Mc);if(e.length===0)return V;let t=J(e);return t instanceof Error?t:z.default.sum((0,z.default)(t).subtract(z.default.mean(t)).abs()[0])/t.length}function Hl(){let e=U(arguments).filter(Mc);if(e.length===0)return Rs;let t=W.apply(void 0,e);if(t)return t;let n=Ec(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=V),o}function Ul(){let e=U(arguments).filter(Mc);if(e.length===0)return Rs;let t=W.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=V),o}function Wl(e,t,n){if(arguments.length<=1)return H;if(n||=e,n=J(U(n).filter(Mc)),e=U(e),n instanceof Error)return n;let r=0,i=0,a=t===void 0||t===`*`,o=a?null:uc(t+``);for(let t=0;t<e.length;t++){let s=e[t];(a||dc([ic(s,rc)].concat(o)))&&(i+=n[t],r++)}return i/r}function Gl(){let e=jc(...arguments),t=e.reduce((e,t)=>e+t,0)/e.length;return isNaN(t)?0:t}var Kl={};Kl.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=q(e),t=q(t),n=q(n),i=q(i),a=q(a),G(e,t,n,i,a))?B:(e=(e-i)/(a-i),r?z.default.beta.cdf(e,t,n):z.default.beta.pdf(e,t,n))},Kl.INV=(e,t,n,r,i)=>(r=r===void 0?0:r,i=i===void 0?1:i,e=q(e),t=q(t),n=q(n),r=q(r),i=q(i),G(e,t,n,r,i)?B:z.default.beta.inv(e,t,n)*(i-r)+r);var ql={};ql.DIST=(e,t,n,r)=>(e=q(e),t=q(t),n=q(n),r=q(r),G(e,t,n,r)?B:r?z.default.binomial.cdf(e,t,n):z.default.binomial.pdf(e,t,n)),ql.DIST.RANGE=(e,t,n,r)=>{if(r=r===void 0?n:r,e=q(e),t=q(t),n=q(n),r=q(r),G(e,t,n,r))return B;let i=0;for(let a=n;a<=r;a++)i+=bd(e,a)*t**+a*(1-t)**(e-a);return i},ql.INV=(e,t,n)=>{if(e=q(e),t=q(t),n=q(n),G(e,t,n))return B;let r=0;for(;r<=e;){if(z.default.binomial.cdf(r,e,t)>=n)return r;r++}};var Jl={};Jl.DIST=(e,t,n)=>(e=q(e),t=q(t),G(e,t)?B:n?z.default.chisquare.cdf(e,t):z.default.chisquare.pdf(e,t)),Jl.DIST.RT=(e,t)=>!e|!t?H:e<1||t>10**10?V:typeof e!=`number`||typeof t!=`number`?B:1-z.default.chisquare.cdf(e,t),Jl.INV=(e,t)=>(e=q(e),t=q(t),G(e,t)?B:z.default.chisquare.inv(e,t)),Jl.INV.RT=(e,t)=>!e|!t?H:e<0||e>1||t<1||t>10**10?V:typeof e!=`number`||typeof t!=`number`?B:z.default.chisquare.inv(1-e,t),Jl.TEST=function(e,t){if(arguments.length!==2)return H;if(!(e instanceof Array)||!(t instanceof Array)||e.length!==t.length||e[0]&&t[0]&&e[0].length!==t[0].length)return B;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 Yl={};Yl.NORM=(e,t,n)=>(e=q(e),t=q(t),n=q(n),G(e,t,n)?B:z.default.normalci(1,e,t,n)[1]-1),Yl.T=(e,t,n)=>(e=q(e),t=q(t),n=q(n),G(e,t,n)?B:z.default.tci(1,e,t,n)[1]-1);function Xl(e,t){return e=J(U(e)),t=J(U(t)),G(e,t)?B:z.default.corrcoeff(e,t)}function Zl(){return Ec(U(arguments)).length}function Ql(){let e=U(arguments);return e.length-$l(e)}function $l(){let e=U(arguments),t=0,n;for(let r=0;r<e.length;r++)n=e[r],(n==null||n===``)&&t++;return t}function eu(e,t){if(e=U(e),t===void 0||t===`*`)return e.length;let n=0,r=uc(t+``);for(let t=0;t<e.length;t++){let i=e[t];dc([ic(i,rc)].concat(r))&&n++}return n}function tu(){let e=fc(arguments),t=Array(U(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=U(e[n]),i=e[n+1];if(i!==void 0&&i!==`*`){let e=uc(i+``);for(let n=0;n<r.length;n++){let i=r[n],a=[ic(i,rc)].concat(e);t[n]=t[n]&&dc(a)}}}let n=0;for(let e=0;e<t.length;e++)t[e]&&n++;return n}var nu={};nu.P=(e,t)=>{if(e=J(U(e)),t=J(U(t)),G(e,t))return B;let n=z.default.mean(e),r=z.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},nu.S=(e,t)=>(e=J(U(e)),t=J(U(t)),G(e,t)?B:z.default.covariance(e,t));function ru(){let e=J(U(arguments));if(e instanceof Error)return e;let t=z.default.mean(e),n=0;for(let r=0;r<e.length;r++)n+=(e[r]-t)**2;return n}var iu={};iu.DIST=(e,t,n)=>(e=q(e),t=q(t),G(e,t)?B:n?z.default.exponential.cdf(e,t):z.default.exponential.pdf(e,t));var au={};au.DIST=(e,t,n,r)=>(e=q(e),t=q(t),n=q(n),G(e,t,n)?B:r?z.default.centralF.cdf(e,t,n):z.default.centralF.pdf(e,t,n)),au.DIST.RT=function(e,t,n){return arguments.length===3?e<0||t<1||n<1?V:typeof e!=`number`||typeof t!=`number`||typeof n!=`number`?B:1-z.default.centralF.cdf(e,t,n):H},au.INV=(e,t,n)=>(e=q(e),t=q(t),n=q(n),G(e,t,n)?B:e<=0||e>1?V:z.default.centralF.inv(e,t,n)),au.INV.RT=function(e,t,n){return arguments.length===3?e<0||e>1||t<1||t>10**10||n<1||n>10**10?V:typeof e!=`number`||typeof t!=`number`||typeof n!=`number`?B:z.default.centralF.inv(1-e,t,n):H},au.TEST=(e,t)=>{if(!e||!t||!(e instanceof Array)||!(t instanceof Array))return H;if(e.length<2||t.length<2)return Rs;let n=(e,t)=>{let n=0;for(let r=0;r<e.length;r++)n+=(e[r]-t)**2;return n},r=_f(e)/e.length,i=_f(t)/t.length;return n(e,r)/(e.length-1)/(n(t,i)/(t.length-1))};function ou(e){return e=q(e),e instanceof Error?e:Math.log((1+e)/(1-e))/2}function su(e){if(e=q(e),e instanceof Error)return e;let t=Math.exp(2*e);return(t-1)/(t+1)}function cu(e,t,n){if(e=q(e),t=J(U(t)),n=J(U(n)),G(e,t,n))return B;let r=z.default.mean(n),i=z.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 lu(e,t){if(e=J(U(e)),t=J(U(t)),G(e,t))return B;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 uu(e){return e=q(e),e instanceof Error?e:e===0||parseInt(e,10)===e&&e<0?V:z.default.gammafn(e)}uu.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`?B:r?z.default.gamma.cdf(e,t,n,!0):z.default.gamma.pdf(e,t,n,!1):H},uu.INV=function(e,t,n){return arguments.length===3?e<0||e>1||t<=0||n<=0?V:typeof e!=`number`||typeof t!=`number`||typeof n!=`number`?B:z.default.gamma.inv(e,t,n):H};function du(e){return e=q(e),e instanceof Error?e:z.default.gammaln(e)}du.PRECISE=function(e){return arguments.length===1?e<=0?V:typeof e==`number`?z.default.gammaln(e):B:H};function fu(e){return e=q(e),e instanceof Error?e:z.default.normal.cdf(e,0,1)-.5}function pu(){let e=J(U(arguments));return e instanceof Error?e:z.default.geomean(e)}function mu(e,t,n,r){if(e=J(U(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=J(U(t)),n=J(U(n)),G(t,n))return B;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 hu(){let e=J(U(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 gu={};gu.DIST=(e,t,n,r,i)=>{if(e=q(e),t=q(t),n=q(n),r=q(r),G(e,t,n,r))return B;function a(e,t,n,r){return bd(n,e)*bd(r-n,t-e)/bd(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 _u(e,t){return e=J(e),t=J(t),G(e,t)?B:e.length===t.length?cu(0,e,t):H}function vu(){let e=J(U(arguments));if(e instanceof Error)return e;let t=z.default.mean(e),n=e.length,r=0;for(let i=0;i<n;i++)r+=(e[i]-t)**4;return r/=z.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 yu(e,t){return W.apply(void 0,e)||(G(t)?t:(e=Ec(U(e)),t=q(t),t<0||e.length<t?B:e.sort((e,t)=>t-e)[t-1]))}function bu(e,t){if(e=J(U(e)),t=J(U(t)),G(e,t))return B;let n=z.default.mean(e),r=z.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 xu(e,t){if(e=J(U(e)),t=J(U(t)),G(e,t)||e.length!==t.length)return B;for(let t=0;t<e.length;t++)e[t]=Math.log(e[t]);let n=bu(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 Su={};Su.DIST=(e,t,n,r)=>(e=q(e),t=q(t),n=q(n),G(e,t,n)?B:r?z.default.lognormal.cdf(e,t,n):z.default.lognormal.pdf(e,t,n)),Su.INV=(e,t,n)=>(e=q(e),t=q(t),n=q(n),G(e,t,n)?B:z.default.lognormal.inv(e,t,n));function Cu(){let e=U(arguments),t=W.apply(void 0,e);if(t)return t;let n=Ec(e);return n.length===0?0:Math.max.apply(Math,n)}function wu(){let e=U(arguments),t=W.apply(void 0,e);if(t)return t;let n=mc(e);return n=n.map(e=>e??0),n.length===0?0:Math.max.apply(Math,n)}function Tu(){let e=jc(...arguments);return e.length===0?0:Math.max.apply(Math,e)}function Eu(){let e=U(arguments),t=W.apply(void 0,e);if(t)return t;let n=mc(e),r=z.default.median(n);return isNaN(r)&&(r=V),r}function Du(){let e=U(arguments),t=W.apply(void 0,e);if(t)return t;let n=Ec(e);return n.length===0?0:Math.min.apply(Math,n)}function Ou(){let e=U(arguments),t=W.apply(void 0,e);if(t)return t;let n=mc(e);return n=n.map(e=>e??0),n.length===0?0:Math.min.apply(Math,n)}function ku(){let e=jc(...arguments);return e.length===0?0:Math.min.apply(Math,e)}var Au={};Au.MULT=function(){let e=J(U(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},Au.SNGL=function(){let e=J(U(arguments));return e instanceof Error?e:Au.MULT(e).sort((e,t)=>e-t)[0]};var ju={};ju.DIST=(e,t,n,r)=>(e=q(e),t=q(t),n=q(n),G(e,t,n)?B:r?z.default.negbin.cdf(e,t,n):z.default.negbin.pdf(e,t,n));var Mu={};Mu.DIST=(e,t,n,r)=>(e=q(e),t=q(t),n=q(n),G(e,t,n)?B:n<=0?V:r?z.default.normal.cdf(e,t,n):z.default.normal.pdf(e,t,n)),Mu.INV=(e,t,n)=>(e=q(e),t=q(t),n=q(n),G(e,t,n)?B:z.default.normal.inv(e,t,n)),Mu.S={},Mu.S.DIST=(e,t)=>(e=q(e),e instanceof Error?B:t?z.default.normal.cdf(e,0,1):z.default.normal.pdf(e,0,1)),Mu.S.INV=e=>(e=q(e),e instanceof Error?B:z.default.normal.inv(e,0,1));function Nu(e,t){if(t=J(U(t)),e=J(U(e)),G(t,e))return B;let n=z.default.mean(e),r=z.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 Pu={};Pu.EXC=(e,t)=>{if(e=J(U(e)),t=q(t),G(e,t))return B;e=e.sort((e,t)=>e-t);let n=e.length;if(t<1/(n+1)||t>1-1/(n+1))return V;let r=t*(n+1)-1,i=Math.floor(r);return Tc(r===i?e[r]:e[i]+(r-i)*(e[i+1]-e[i]))},Pu.INC=(e,t)=>{if(e=J(U(e)),t=q(t),G(e,t))return B;e=e.sort((e,t)=>e-t);let n=e.length,r=t*(n-1),i=Math.floor(r);return Tc(r===i?e[r]:e[i]+(r-i)*(e[i+1]-e[i]))};var Fu={};Fu.EXC=(e,t,n)=>{if(n=n===void 0?3:n,e=J(U(e)),t=q(t),n=q(n),G(e,t,n))return B;e=e.sort((e,t)=>e-t);let r=cl.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},Fu.INC=(e,t,n)=>{if(n=n===void 0?3:n,e=J(U(e)),t=q(t),n=q(n),G(e,t,n))return B;e=e.sort((e,t)=>e-t);let r=cl.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 Iu(e,t){return e=q(e),t=q(t),G(e,t)?B:Nd(e)/Nd(e-t)}function Lu(e,t){return e=q(e),t=q(t),G(e,t)?B:e**+t}function Ru(e){return e=q(e),e instanceof Error?B:Math.exp(-.5*e*e)/Bl}var zu={};zu.DIST=(e,t,n)=>(e=q(e),t=q(t),G(e,t)?B:n?z.default.poisson.cdf(e,t):z.default.poisson.pdf(e,t));function Bu(e,t,n,r){if(n===void 0)return 0;if(r=r===void 0?n:r,e=J(U(e)),t=J(U(t)),n=q(n),r=q(r),G(e,t,n,r))return B;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 Vu={};Vu.EXC=(e,t)=>{if(e=J(Ec(U(e))),t=q(t),G(e,t))return B;switch(t){case 1:return Pu.EXC(e,.25);case 2:return Pu.EXC(e,.5);case 3:return Pu.EXC(e,.75);default:return V}},Vu.INC=(e,t)=>{if(e=J(Ec(U(e))),t=q(t),G(e,t))return B;switch(t){case 1:return Pu.INC(e,.25);case 2:return Pu.INC(e,.5);case 3:return Pu.INC(e,.75);default:return V}};var Hu={};Hu.AVG=(e,t,n)=>{if(e=q(e),t=J(U(t)),G(e,t))return B;t=U(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},Hu.EQ=(e,t,n)=>{if(e=q(e),t=J(U(t)),G(e,t))return B;n||=!1;let r=n?(e,t)=>e-t:(e,t)=>t-e;return t=t.sort(r),t.indexOf(e)+1};function Uu(e,t){if(arguments.length!==2)return H;if(t<0)return V;if(!(e instanceof Array)||typeof t!=`number`)return B;if(e.length!==0)return z.default.row(e,t)}function Wu(e,t){return e=J(U(e)),t=J(U(t)),G(e,t)?B:Nu(e,t)**2}function Gu(){let e=J(U(arguments));if(e instanceof Error)return e;let t=z.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)*z.default.stdev(e,!0)**3)}Gu.P=function(){let e=J(U(arguments));if(e instanceof Error)return e;let t=z.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 Ku(e,t){if(e=J(U(e)),t=J(U(t)),G(e,t))return B;let n=z.default.mean(t),r=z.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 qu(e,t){return e=J(U(e)),t=q(t),G(e,t)?e:e.sort((e,t)=>e-t)[t-1]}function Ju(e,t,n){return e=q(e),t=q(t),n=q(n),G(e,t,n)?B:(e-t)/n}var Yu={};Yu.P=function(){let e=td.P.apply(this,arguments),t=Math.sqrt(e);return isNaN(t)&&(t=V),t},Yu.S=function(){let e=td.S.apply(this,arguments);return Math.sqrt(e)};function Xu(){let e=nd.apply(this,arguments);return Math.sqrt(e)}function Zu(){let e=rd.apply(this,arguments),t=Math.sqrt(e);return isNaN(t)&&(t=V),t}function Qu(e,t){if(e=J(U(e)),t=J(U(t)),G(e,t))return B;let n=z.default.mean(t),r=z.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))}Ml.DIST=(e,t,n)=>n!==1&&n!==2?V:n===1?Ml.DIST.RT(e,t):Ml.DIST[`2T`](e,t),Ml.DIST[`2T`]=function(e,t){return arguments.length===2?e<0||t<1?V:typeof e!=`number`||typeof t!=`number`?B:(1-z.default.studentt.cdf(e,t))*2:H},Ml.DIST.RT=function(e,t){return arguments.length===2?e<0||t<1?V:typeof e!=`number`||typeof t!=`number`?B:1-z.default.studentt.cdf(e,t):H},Ml.INV=(e,t)=>(e=q(e),t=q(t),G(e,t)?B:z.default.studentt.inv(e,t)),Ml.INV[`2T`]=(e,t)=>(e=q(e),t=q(t),e<=0||e>1||t<1?V:G(e,t)?B:Math.abs(z.default.studentt.inv(e/2,t))),Ml.TEST=(e,t)=>{if(e=J(U(e)),t=J(U(t)),G(e,t))return B;let n=z.default.mean(e),r=z.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 Ml.DIST[`2T`](s,e.length+t.length-2)};function $u(e,t,n){if(e=J(U(e)),t=J(U(t)),n=J(U(n)),G(e,t,n))return B;let r=bu(e,t),i=r[0],a=r[1],o=[];return n.forEach(e=>{o.push(i*e+a)}),o}function ed(e,t){if(e=J(U(e)),t=q(t),G(e,t))return B;let n=Fd(e.length*t,2)/2;return z.default.mean(yc(Sc(e.sort((e,t)=>e-t),n),n))}var td={};td.P=function(){let e=Ec(U(arguments)),t=e.length,n=0,r=Hl(e),i;for(let i=0;i<t;i++)n+=(e[i]-r)**2;return i=n/t,isNaN(i)&&(i=V),i},td.S=function(){let e=Ec(U(arguments)),t=e.length,n=0,r=Hl(e);for(let i=0;i<t;i++)n+=(e[i]-r)**2;return n/(t-1)};function nd(){let e=U(arguments),t=e.length,n=0,r=0,i=Ul(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 rd(){let e=U(arguments),t=e.length,n=0,r=0,i=Ul(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=V),a}var id={};id.DIST=(e,t,n,r)=>(e=q(e),t=q(t),n=q(n),G(e,t,n)?B:r?1-Math.exp(-((e/n)**+t)):e**(t-1)*Math.exp(-((e/n)**+t))*t/n**+t);var ad={};ad.TEST=(e,t,n)=>{if(e=J(U(e)),t=q(t),G(e,t))return B;n||=Yu.S(e);let r=e.length;return 1-Mu.S.DIST((Hl(e)-t)/(n/Math.sqrt(r)),!0)};function od(e){return e=q(e),e instanceof Error?e:Math.abs(e)}function sd(e){if(e=q(e),e instanceof Error)return e;let t=Math.acos(e);return isNaN(t)&&(t=V),t}function cd(e){if(e=q(e),e instanceof Error)return e;let t=Math.log(e+Math.sqrt(e*e-1));return isNaN(t)&&(t=V),t}function ld(e){return e=q(e),e instanceof Error?e:Math.atan(1/e)}function ud(e){if(e=q(e),e instanceof Error)return e;let t=.5*Math.log((e+1)/(e-1));return isNaN(t)&&(t=V),t}function dd(e,t,n,r){if(e=q(e),t=q(e),G(e,t))return B;switch(e){case 1:return Hl(n);case 2:return Zl(n);case 3:return Ql(n);case 4:return Cu(n);case 5:return Du(n);case 6:return Zd(n);case 7:return Yu.S(n);case 8:return Yu.P(n);case 9:return _f(n);case 10:return td.S(n);case 11:return td.P(n);case 12:return Eu(n);case 13:return Au.SNGL(n);case 14:return yu(n,r);case 15:return qu(n,r);case 16:return Pu.INC(n,r);case 17:return Vu.INC(n,r);case 18:return Pu.EXC(n,r);case 19:return Vu.EXC(n,r)}}function fd(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 B;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 pd(e){if(e=q(e),e instanceof Error)return e;let t=Math.asin(e);return isNaN(t)&&(t=V),t}function md(e){return e=q(e),e instanceof Error?e:Math.log(e+Math.sqrt(e*e+1))}function hd(e){return e=q(e),e instanceof Error?e:Math.atan(e)}function gd(e,t){return e=q(e),t=q(t),W(e,t)||Math.atan2(e,t)}function _d(e){if(e=q(e),e instanceof Error)return e;let t=Math.log((1+e)/(1-e))/2;return isNaN(t)&&(t=V),t}function vd(e,t,n){e=q(e),t=q(t),n=q(n);let r=W(e,t,n);if(r)return r;if(t===0)return V;let i=e.toString(t);return Array(Math.max(n+1-i.length,0)).join(`0`)+i}function yd(e,t){return e=q(e),t=q(t),W(e,t)||(t===0?0:e>0&&t<0?V:Math.ceil(e/t)*t)}yd.MATH=(e,t,n=0)=>(t===void 0&&(t=e>0?1:-1),e=q(e),t=q(t),n=q(n),W(e,t,n)||(t===0?0:(t=Math.abs(t),n===0||e>0?Math.ceil(e/t)*t:Math.floor(e/t)*t))),yd.PRECISE=(e,t)=>yd.MATH(e,t);function bd(e,t){return e=q(e),t=q(t),W(e,t)||(e<t?V:Nd(e)/(Nd(t)*Nd(e-t)))}function xd(e,t){return e=q(e),t=q(t),W(e,t)||(e<t?V:e===0&&t===0?1:bd(e+t-1,e-1))}function Sd(e){return e=q(e),e instanceof Error?e:Math.cos(e)}function Cd(e){return e=q(e),e instanceof Error?e:(Math.exp(e)+Math.exp(-e))/2}function wd(e){return e=q(e),e instanceof Error?e:e===0?Rs:1/Math.tan(e)}function Td(e){if(e=q(e),e instanceof Error)return e;if(e===0)return Rs;let t=Math.exp(2*e);return(t+1)/(t-1)}function Ed(e){return e=q(e),e instanceof Error?e:e===0?Rs:1/Math.sin(e)}function Dd(e){return e=q(e),e instanceof Error?e:e===0?Rs:2/(Math.exp(e)-Math.exp(-e))}function Od(e,t){if(arguments.length<2)return H;e||=`0`,t=q(t);let n=W(e,t);if(n)return n;if(t===0)return V;let r=parseInt(e,t);return isNaN(r)?V:r}function kd(e){return e=q(e),e instanceof Error?e:e*180/Math.PI}function Ad(e){return e=q(e),e instanceof Error?e:yd.MATH(e,-2,-1)}function jd(e){return arguments.length<1?H:arguments.length>1?Vs:(e=q(e),e instanceof Error||(e=Math.exp(e)),e)}var Md=[];function Nd(e){if(e=q(e),e instanceof Error)return e;let t=Math.floor(e);return t===0||t===1?1:(Md[t]>0||(Md[t]=Nd(t-1)*t),Md[t])}function Pd(e){if(e=q(e),e instanceof Error)return e;let t=Math.floor(e);return t<=0?1:t*Pd(t-2)}function Fd(e,t){return e=q(e),t=q(t),W(e,t)||(t?e>0&&t<0?V:Math.floor(e/t)*t:Rs)}Fd.MATH=(e,t=1,n=0)=>(e=q(e),t=q(t),n=q(n),W(e,t,n)||(t===0?0:(t=Math.abs(t),n===0||e>0?Math.floor(e/t)*t:Math.ceil(e/t)*t))),Fd.PRECISE=(e,t)=>Fd.MATH(e,t);function Id(){let e=J(U(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 Ld(e){return e=q(e),e instanceof Error?e:Math.floor(e)}var Rd={CEILING:yd};function zd(){let e=J(U(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 Bd(e){return e=q(e),e instanceof Error?e:e===0?V:Math.log(e)}function Vd(e,t){return e=q(e),t=t?q(t):10,W(e,t)||(e===0||t===0?V:Math.log(e)/Math.log(t))}function Hd(e){return e=q(e),e instanceof Error?e:e===0?V:Math.log(e)/Math.log(10)}function Ud(e,t){return!Array.isArray(e)||!Array.isArray(t)||e.some(e=>!e.length)||t.some(e=>!e.length)||vc(e).some(e=>typeof e!=`number`)||vc(t).some(e=>typeof e!=`number`)||e[0].length!==t.length?B: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 Wd(e,t){e=q(e),t=q(t);let n=W(e,t);if(n)return n;if(t===0)return Rs;let r=Math.abs(e%t);return r=e<0?t-r:r,t>0?r:-r}function Gd(e,t){return e=q(e),t=q(t),W(e,t)||(e*t===0?0:e*t<0?V:Math.round(e/t)*t)}function Kd(){let e=J(U(arguments));if(e instanceof Error)return e;let t=0,n=1;for(let r=0;r<e.length;r++)t+=e[r],n*=Nd(e[r]);return Nd(t)/n}function qd(e){return arguments.length>1?H:(e=parseInt(e),!e||e<=0?B:Array(e).fill(0).map(()=>Array(e).fill(0)).map((e,t)=>(e[t]=1,e)))}function Jd(e){if(e=q(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 Yd(){return Math.PI}function Xd(e,t){e=q(e),t=q(t);let n=W(e,t);if(n)return n;if(e===0&&t===0)return V;let r=e**+t;return isNaN(r)?V:r}function Zd(){let e=U(arguments).filter(e=>e!=null);if(e.length===0)return 0;let t=J(e);if(t instanceof Error)return t;let n=1;for(let e=0;e<t.length;e++)n*=t[e];return n}function Qd(e,t){return e=q(e),t=q(t),W(e,t)||parseInt(e/t,10)}function $d(e){return e=q(e),e instanceof Error?e:e*Math.PI/180}function ef(){return Math.random()}function tf(e,t){return e=q(e),t=q(t),W(e,t)||e+Math.ceil((t-e+1)*Math.random())-1}function nf(e){if(e=q(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 rf(e,t,n){e=q(e),t=q(t);let r=W(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 af(e,t){return rf(e,t,Math.round)}function of(e,t){return rf(e,t,Math.floor)}function sf(e,t){return rf(e,t,Math.ceil)}function cf(e){return e=q(e),e instanceof Error?e:1/Math.cos(e)}function lf(e){return e=q(e),e instanceof Error?e:2/(Math.exp(e)+Math.exp(-e))}function uf(e,t,n,r){if(e=q(e),t=q(t),n=q(n),r=J(r),G(e,t,n,r))return B;let i=r[0]*e**+t;for(let a=1;a<r.length;a++)i+=r[a]*e**+(t+a*n);return i}function df(e){return e=q(e),e instanceof Error?e:e<0?-1:e===0?0:1}function ff(e){return e=q(e),e instanceof Error?e:Math.sin(e)}function pf(e){return e=q(e),e instanceof Error?e:(Math.exp(e)-Math.exp(-e))/2}function mf(e){return e=q(e),e instanceof Error?e:e<0?V:Math.sqrt(e)}function hf(e){return e=q(e),e instanceof Error?e:Math.sqrt(e*Math.PI)}function gf(e,t){if(e=q(e),e instanceof Error)return e;switch(e){case 1:return Hl(t);case 2:return Zl(t);case 3:return Ql(t);case 4:return Cu(t);case 5:return Du(t);case 6:return Zd(t);case 7:return Yu.S(t);case 8:return Yu.P(t);case 9:return _f(t);case 10:return td.S(t);case 11:return td.P(t);case 101:return Hl(t);case 102:return Zl(t);case 103:return Ql(t);case 104:return Cu(t);case 105:return Du(t);case 106:return Zd(t);case 107:return Yu.S(t);case 108:return Yu.P(t);case 109:return _f(t);case 110:return td.S(t);case 111:return td.P(t)}}function _f(){let e=0;return pc(fc(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=_f.apply(null,t);n instanceof Error?e=n:e+=n}}),e}function vf(e,t,n){if(e=U(e),n=n?U(n):e,e instanceof Error)return e;if(t==null||t instanceof Error)return 0;let r=0,i=t===`*`,a=i?null:uc(t+``);for(let t=0;t<e.length;t++){let o=e[t],s=n[t];if(i)r+=o;else{let e=[ic(o,rc)].concat(a);r+=dc(e)?s:0}}return r}function yf(){let e=fc(arguments);return e[0]=mc(U(e[0])),_f(jc(...e))}function bf(){if(!arguments||arguments.length===0)return B;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=q(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=q(e),i instanceof Error)return i;n*=i}t+=n}return t}function xf(){let e=J(U(arguments));if(e instanceof Error)return e;let t=0,n=e.length;for(let r=0;r<n;r++)t+=Vc(e[r])?e[r]*e[r]:0;return t}function Sf(e,t){if(e=J(U(e)),t=J(U(t)),G(e,t))return B;let n=0;for(let r=0;r<e.length;r++)n+=e[r]*e[r]-t[r]*t[r];return n}function Cf(e,t){if(e=J(U(e)),t=J(U(t)),G(e,t))return B;let n=0;e=J(U(e)),t=J(U(t));for(let r=0;r<e.length;r++)n+=e[r]*e[r]+t[r]*t[r];return n}function wf(e,t){if(e=J(U(e)),t=J(U(t)),G(e,t))return B;let n=0;e=U(e),t=U(t);for(let r=0;r<e.length;r++)n+=(e[r]-t[r])**2;return n}function Tf(e){return e=q(e),e instanceof Error?e:Math.tan(e)}function Ef(e){if(e=q(e),e instanceof Error)return e;let t=Math.exp(2*e);return(t-1)/(t+1)}function Df(e,t){return e=q(e),t=q(t),W(e,t)||(e>0?1:-1)*Math.floor(Math.abs(e)*10**t)/10**t}function Of(e,t){return arguments.length===2?(e=q(e),t=q(t),W(e,t)||e+t):H}function kf(e,t){return arguments.length===2?(e=q(e),t=q(t),W(e,t)||(t===0?Rs:e/t)):H}function Af(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):H}function jf(e,t){return arguments.length===2?e instanceof Error?e:t instanceof Error?t:(Ac(e,t)?(e=kc(e),t=kc(t)):(e=q(e),t=q(t)),W(e,t)||e>t):H}function Mf(e,t){return arguments.length===2?(Ac(e,t)?(e=kc(e),t=kc(t)):(e=q(e),t=q(t)),W(e,t)||e>=t):H}function Nf(e,t){return arguments.length===2?(Ac(e,t)?(e=kc(e),t=kc(t)):(e=q(e),t=q(t)),W(e,t)||e<t):H}function Pf(e,t){return arguments.length===2?(Ac(e,t)?(e=kc(e),t=kc(t)):(e=q(e),t=q(t)),W(e,t)||e<=t):H}function Ff(e,t){return arguments.length===2?(e=q(e),t=q(t),W(e,t)||e-t):H}function If(e,t){return arguments.length===2?(e=q(e),t=q(t),W(e,t)||e*t):H}function Lf(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):H}function Rf(e,t){return arguments.length===2?Xd(e,t):H}var zf=Object.freeze({__proto__:null,ADD:Of,DIVIDE:kf,EQ:Af,GT:jf,GTE:Mf,LT:Nf,LTE:Pf,MINUS:Ff,MULTIPLY:If,NE:Lf,POW:Rf}),Bf=[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],Vf=[[],[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]],Hf=[[],[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 Uf(e,t,n){let r;return e=q(e),t=q(t),n=q(n),G(e,t,n)?r=B:(r=new Date(e,t-1,n),r.getFullYear()<0&&(r=V)),Gs?Ys(r):r}function Wf(e,t,n){n=n.toUpperCase(),e=K(e),t=K(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(mp(e,t));break;case`D`:l=Jf(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=Jf(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=Jf(t,e)}return l}function Gf(e){if(typeof e!=`string`||isNaN(Date.parse(e)))return B;let t=new Date(e);return Gs?Ys(t):t}function Kf(e){let t=K(e);return t instanceof Error?t:t.getDate()}function qf(e){let t=new Date(e);return t.setHours(0,0,0,0),t}function Jf(e,t){return e=K(e),t=K(t),e instanceof Error?e:t instanceof Error?t:Ys(qf(e))-Ys(qf(t))}function Yf(e,t,n){if(n=Dc(n||`false`),e=K(e),t=K(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 Xf(e,t){if(e=K(e),e instanceof Error)return e;if(isNaN(t))return B;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),Gs?Ys(e):e}function Zf(e,t){if(e=K(e),e instanceof Error)return e;if(isNaN(t))return B;t=parseInt(t,10);let n=new Date(e.getFullYear(),e.getMonth()+t+1,0);return Gs?Ys(n):n}function Qf(e){return e=K(e),e instanceof Error?e:e.getHours()}function $f(e){if(e=K(e),e instanceof Error)return e;e=qf(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 ep(e){return e=K(e),e instanceof Error?e:e.getMinutes()}function tp(e){return e=K(e),e instanceof Error?e:e.getMonth()+1}function np(e,t,n){return np.INTL(e,t,1,n)}np.INTL=(e,t,n,r)=>{if(e=K(e),e instanceof Error)return e;if(t=K(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=Hf[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=Hf[n];if(!(n instanceof Array))return B;r===void 0?r=[]:r instanceof Array||(r=[r]);for(let e=0;e<r.length;e++){let t=K(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 rp(){return Gs?Ys(new Date):new Date}function ip(e){return e=K(e),e instanceof Error?e:e.getSeconds()}function ap(e,t,n){return e=q(e),t=q(t),n=q(n),G(e,t,n)?B:e<0||t<0||n<0?V:(3600*e+60*t+n)/86400}function op(e){return e=K(e),e instanceof Error?e:(3600*e.getHours()+60*e.getMinutes()+e.getSeconds())/86400}function sp(){let e=qf(new Date);return Gs?Ys(e):e}function cp(e,t){if(e=K(e),e instanceof Error)return e;t===void 0&&(t=1);let n=e.getDay();return Vf[t][n]}function lp(e,t){if(e=K(e),e instanceof Error)return e;if(t===void 0&&(t=1),t===21)return $f(e);let n=Bf[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 up(e,t,n){return up.INTL(e,t,1,n)}up.INTL=(e,t,n,r)=>{if(e=K(e),e instanceof Error)return e;if(t=q(t),t instanceof Error)return t;if(n=n===void 0?Hf[1]:Hf[n],!(n instanceof Array))return B;r===void 0?r=[]:r instanceof Array||(r=[r]);for(let e=0;e<r.length;e++){let t=K(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?B:e};function dp(e){return e=K(e),e instanceof Error?e:e.getFullYear()}function fp(e){return new Date(e,1,29).getMonth()===1}function pp(e,t){return Math.ceil((t-e)/1e3/60/60/24)}function mp(e,t,n){if(e=K(e),e instanceof Error)return e;if(t=K(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(fp(n)&&e<r&&t>=r)return!0;let i=t.getFullYear(),a=new Date(i,2,1);return fp(i)&&t>=a&&e<a},l=365;if(a===c||a+1===c&&(i>s||i===s&&r>=o))return(a===c&&fp(a)||n(e,t)||s===1&&o===29)&&(l=366),pp(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 pp(e,t)/d}case 2:return pp(e,t)/360;case 3:return pp(e,t)/365;case 4:return(o+s*30+c*360-(r+i*30+a*360))/360}}function hp(e){return/^[01]{1,10}$/.test(e)}function gp(e,t){return e=q(e),t=q(t),G(e,t)?B:Is.default.besseli(e,t)}function _p(e,t){return e=q(e),t=q(t),G(e,t)?B:Is.default.besselj(e,t)}function vp(e,t){return e=q(e),t=q(t),G(e,t)?B:Is.default.besselk(e,t)}function yp(e,t){return e=q(e),t=q(t),G(e,t)?B:Is.default.bessely(e,t)}function bp(e){if(!hp(e))return V;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 xp(e,t){if(!hp(e))return V;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)?B:t<0?V:(t=Math.floor(t),t>=r.length?Ol(`0`,t-r.length)+r:V)}function Sp(e,t){if(!hp(e))return V;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)?B:t<0?V:(t=Math.floor(t),t>=r.length?Ol(`0`,t-r.length)+r:V)}function Cp(e,t){return e=q(e),t=q(t),G(e,t)?B:e<0||t<0||Math.floor(e)!==e||Math.floor(t)!==t||e>0xffffffffffff||t>0xffffffffffff?V:e&t}function wp(e,t){return e=q(e),t=q(t),G(e,t)?B:e<0||Math.floor(e)!==e||e>0xffffffffffff||Math.abs(t)>53?V:t>=0?e<<t:e>>-t}function Tp(e,t){return e=q(e),t=q(t),G(e,t)?B:e<0||t<0||Math.floor(e)!==e||Math.floor(t)!==t||e>0xffffffffffff||t>0xffffffffffff?V:e|t}function Ep(e,t){return e=q(e),t=q(t),G(e,t)?B:e<0||Math.floor(e)!==e||e>0xffffffffffff||Math.abs(t)>53?V:t>=0?e>>t:e<<-t}function Dp(e,t){return e=q(e),t=q(t),G(e,t)?B:e<0||t<0||Math.floor(e)!==e||Math.floor(t)!==t||e>0xffffffffffff||t>0xffffffffffff?V:e^t}function Op(e,t,n){if(e=q(e),t=q(t),G(e,t))return e;if(n=n===void 0?`i`:n,n!==`i`&&n!==`j`)return B;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 kp(e,t,n){if(e=q(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]?H:e*o[6]*u/(s[6]*d)}function Ap(e,t){if(e=q(e),e instanceof Error)return e;if(!/^-?[0-9]{1,3}$/.test(e)||e<-512||e>511)return V;if(e<0)return`1`+Ol(`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)?B:t<0?V:(t=Math.floor(t),t>=n.length?Ol(`0`,t-n.length)+n:V)}function jp(e,t){if(e=q(e),e instanceof Error)return e;if(!/^-?[0-9]{1,12}$/.test(e)||e<-549755813888||e>549755813887)return V;if(e<0)return(1099511627776+e).toString(16);let n=parseInt(e,10).toString(16);return t===void 0?n:isNaN(t)?B:t<0?V:(t=Math.floor(t),t>=n.length?Ol(`0`,t-n.length)+n:V)}function Mp(e,t){if(e=q(e),e instanceof Error)return e;if(!/^-?[0-9]{1,9}$/.test(e)||e<-536870912||e>536870911)return V;if(e<0)return(1073741824+e).toString(8);let n=parseInt(e,10).toString(8);return t===void 0?n:isNaN(t)?B:t<0?V:(t=Math.floor(t),t>=n.length?Ol(`0`,t-n.length)+n:V)}function Np(e,t){return t=t===void 0?0:t,e=q(e),t=q(t),G(e,t)?B:+(e===t)}function Pp(e,t){return t=t===void 0?0:t,e=q(e),t=q(t),G(e,t)?B:z.default.erf(e)}function Fp(e){return isNaN(e)?B:z.default.erfc(e)}function Ip(e,t){return t||=0,e=q(e),G(t,e)?e:+(e>=t)}function Lp(e,t){if(!/^[0-9A-Fa-f]{1,10}$/.test(e))return V;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 V;if(n)return`1`+Ol(`0`,9-(512+r).toString(2).length)+(512+r).toString(2);let i=r.toString(2);return t===void 0?i:isNaN(t)?B:t<0?V:(t=Math.floor(t),t>=i.length?Ol(`0`,t-i.length)+i:V)}function Rp(e){if(!/^[0-9A-Fa-f]{1,10}$/.test(e))return V;let t=parseInt(e,16);return t>=549755813888?t-1099511627776:t}function zp(e,t){if(!/^[0-9A-Fa-f]{1,10}$/.test(e))return V;let n=parseInt(e,16);if(n>536870911&&n<0xffe0000000)return V;if(n>=0xffe0000000)return(n-0xffc0000000).toString(8);let r=n.toString(8);return t===void 0?r:isNaN(t)?B:t<0?V:(t=Math.floor(t),t>=r.length?Ol(`0`,t-r.length)+r:V)}function Bp(e){let t=Y(e),n=Vp(e);return G(t,n)?B:Math.sqrt(t**2+n**2)}function Vp(e){if(e===void 0||e===!0||e===!1)return B;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))?V:Number(e.substring(t+1,e.length-1)):isNaN(e.substring(0,n))||isNaN(e.substring(n+1,e.length-1))?V:-Number(e.substring(n+1,e.length-1)):V:i?isNaN(e.substring(0,e.length-1))?V:e.substring(0,e.length-1):isNaN(e)?V:0}function Hp(e){let t=Y(e),n=Vp(e);return G(t,n)?B:t===0&&n===0?Rs: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 Up(e){let t=Y(e),n=Vp(e);if(G(t,n))return B;let r=e.substring(e.length-1);return r=r===`i`||r===`j`?r:`i`,n===0?e:Op(t,-n,r)}function Wp(e){let t=Y(e),n=Vp(e);if(G(t,n))return B;let r=e.substring(e.length-1);return r=r===`i`||r===`j`?r:`i`,Op(Math.cos(t)*(Math.exp(n)+Math.exp(-n))/2,-Math.sin(t)*(Math.exp(n)-Math.exp(-n))/2,r)}function Gp(e){let t=Y(e),n=Vp(e);if(G(t,n))return B;let r=e.substring(e.length-1);return r=r===`i`||r===`j`?r:`i`,Op(Math.cos(n)*(Math.exp(t)+Math.exp(-t))/2,Math.sin(n)*(Math.exp(t)-Math.exp(-t))/2,r)}function Kp(e){return G(Y(e),Vp(e))?B:qp(Wp(e),nm(e))}function qp(e,t){let n=Y(e),r=Vp(e),i=Y(t),a=Vp(t);if(G(n,r,i,a))return B;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 V;let l=i*i+a*a;return Op((n*i+r*a)/l,(r*i-n*a)/l,c)}function Jp(e){let t=Y(e),n=Vp(e);if(G(t,n))return B;let r=e.substring(e.length-1);r=r===`i`||r===`j`?r:`i`;let i=Math.exp(t);return Op(i*Math.cos(n),i*Math.sin(n),r)}function Yp(e){let t=Y(e),n=Vp(e);if(G(t,n))return B;let r=e.substring(e.length-1);return r=r===`i`||r===`j`?r:`i`,Op(Math.log(Math.sqrt(t*t+n*n)),Math.atan(n/t),r)}function Xp(e){let t=Y(e),n=Vp(e);if(G(t,n))return B;let r=e.substring(e.length-1);return r=r===`i`||r===`j`?r:`i`,Op(Math.log(Math.sqrt(t*t+n*n))/Math.log(10),Math.atan(n/t)/Math.log(10),r)}function Zp(e){let t=Y(e),n=Vp(e);if(G(t,n))return B;let r=e.substring(e.length-1);return r=r===`i`||r===`j`?r:`i`,Op(Math.log(Math.sqrt(t*t+n*n))/Math.log(2),Math.atan(n/t)/Math.log(2),r)}function Qp(e,t){t=q(t);let n=Y(e),r=Vp(e);if(G(t,n,r))return B;let i=e.substring(e.length-1);i=i===`i`||i===`j`?i:`i`;let a=Bp(e)**+t,o=Hp(e);return Op(a*Math.cos(t*o),a*Math.sin(t*o),i)}function $p(){let e=arguments[0];if(!arguments.length)return B;for(let t=1;t<arguments.length;t++){let n=Y(e),r=Vp(e),i=Y(arguments[t]),a=Vp(arguments[t]);if(G(n,r,i,a))return B;e=Op(n*i-r*a,n*a+r*i)}return e}function Y(e){if(e===void 0||e===!0||e===!1)return B;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))?V:Number(e.substring(0,t)):isNaN(e.substring(0,n))||isNaN(e.substring(n+1,e.length-1))?V:Number(e.substring(0,n)):V:i?isNaN(e.substring(0,e.length-1))?V:0:isNaN(e)?V:e}function em(e){return e===!0||e===!1||G(Y(e),Vp(e))?B:qp(`1`,Wp(e))}function tm(e){return G(Y(e),Vp(e))?B:qp(`1`,Gp(e))}function nm(e){let t=Y(e),n=Vp(e);if(G(t,n))return B;let r=e.substring(e.length-1);return r=r===`i`||r===`j`?r:`i`,Op(Math.sin(t)*(Math.exp(n)+Math.exp(-n))/2,Math.cos(t)*(Math.exp(n)-Math.exp(-n))/2,r)}function rm(e){let t=Y(e),n=Vp(e);if(G(t,n))return B;let r=e.substring(e.length-1);return r=r===`i`||r===`j`?r:`i`,Op(Math.cos(n)*(Math.exp(t)-Math.exp(-t))/2,Math.sin(n)*(Math.exp(t)+Math.exp(-t))/2,r)}function im(e){if(G(Y(e),Vp(e)))return B;let t=e.substring(e.length-1);t=t===`i`||t===`j`?t:`i`;let n=Math.sqrt(Bp(e)),r=Hp(e);return Op(n*Math.cos(r/2),n*Math.sin(r/2),t)}function am(e){return e===!0||e===!1?B:G(Y(e),Vp(e))?V:qp(`1`,nm(e))}function om(e){return e===!0||e===!1?B:G(Y(e),Vp(e))?V:qp(`1`,rm(e))}function sm(e,t){let n=Y(e),r=Vp(e),i=Y(t),a=Vp(t);if(G(n,r,i,a))return B;let o=e.substring(e.length-1),s=t.substring(t.length-1),c=`i`;return(o===`j`||s===`j`)&&(c=`j`),Op(n-i,r-a,c)}function cm(){if(!arguments.length)return B;let e=U(arguments),t=0,n=0;for(let r of e){let e=+Y(r),i=+Vp(r);if(G(e,i))return B;t+=e,n+=i}return Op(t,n,`i`)}function lm(e){return e===!0||e===!1||G(Y(e),Vp(e))?B:qp(nm(e),Wp(e))}function um(e,t){if(!/^[0-7]{1,10}$/.test(e))return V;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 V;if(n)return`1`+Ol(`0`,9-(512+r).toString(2).length)+(512+r).toString(2);let i=r.toString(2);return t===void 0?i:isNaN(t)?B:t<0?V:(t=Math.floor(t),t>=i.length?Ol(`0`,t-i.length)+i:V)}function dm(e){if(!/^[0-7]{1,10}$/.test(e))return V;let t=parseInt(e,8);return t>=536870912?t-1073741824:t}function fm(e,t){if(!/^[0-7]{1,10}$/.test(e))return V;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)?B:t<0?V:(t=Math.floor(t),t>=r.length?Ol(`0`,t-r.length)+r:V)}var pm=Kl.DIST,mm=Kl.INV,hm=ql.DIST,gm=yd.MATH,_m=yd.PRECISE,vm=Jl.DIST,ym=Jl.DIST.RT,bm=Jl.INV,xm=Jl.INV.RT,Sm=Jl.TEST,Cm=nu.P,wm=nu.P,Tm=nu.S,Em=ql.INV,Dm=Fp.PRECISE,Om=Pp.PRECISE,km=iu.DIST,Am=au.DIST,jm=au.DIST.RT,Mm=au.INV,Nm=au.INV.RT,Pm=Fd.MATH,Fm=Fd.PRECISE,Im=au.TEST,Lm=uu.DIST,Rm=uu.INV,zm=du.PRECISE,Bm=gu.DIST,Vm=Su.INV,Hm=Su.DIST,Um=Su.INV,Wm=Au.MULT,Gm=Au.SNGL,Km=ju.DIST,qm=np.INTL,Jm=Mu.DIST,Ym=Mu.INV,Xm=Mu.S.DIST,Zm=Mu.S.INV,Qm=Pu.EXC,$m=Pu.INC,eh=Fu.EXC,th=Fu.INC,nh=zu.DIST,rh=Vu.EXC,ih=Vu.INC,ah=Hu.AVG,oh=Hu.EQ,sh=Gu.P,ch=Yu.P,lh=Yu.S,uh=Ml.DIST,dh=Ml.DIST.RT,fh=Ml.INV,ph=Ml.TEST,mh=td.P,hh=td.S,gh=id.DIST,_h=up.INTL,vh=ad.TEST;function yh(e){let t=[];return pc(e,e=>{e&&t.push(e)}),t}function bh(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=uc(c[t]+``);o=dc([ic(e[i][a],rc)].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 xh(e,t,n){if(isNaN(t)&&typeof t!=`string`)return B;let r=bh(e,n),i=[];i=Sc(typeof t==`string`?e[wc(e,t)]:e[t]);let a=0;return pc(r,e=>{a+=i[e]}),r.length===0?Rs:a/r.length}function Sh(e,t,n){if(isNaN(t)&&typeof t!=`string`)return B;let r=bh(e,n),i=[];i=Sc(typeof t==`string`?e[wc(e,t)]:e[t]);let a=[];return pc(r,e=>{a.push(i[e])}),Zl(a)}function Ch(e,t,n){if(isNaN(t)&&typeof t!=`string`)return B;let r=bh(e,n),i=[];i=Sc(typeof t==`string`?e[wc(e,t)]:e[t]);let a=[];return pc(r,e=>{a.push(i[e])}),Ql(a)}function wh(e,t,n){if(isNaN(t)&&typeof t!=`string`)return B;let r=bh(e,n),i=[];return i=Sc(typeof t==`string`?e[wc(e,t)]:e[t]),r.length===0?B:r.length>1?V:i[r[0]]}function Th(e,t,n){if(isNaN(t)&&typeof t!=`string`)return B;let r=bh(e,n),i=[];i=Sc(typeof t==`string`?e[wc(e,t)]:e[t]);let a=i[r[0]];return pc(r,e=>{a<i[e]&&(a=i[e])}),a}function Eh(e,t,n){if(isNaN(t)&&typeof t!=`string`)return B;let r=bh(e,n),i=[];i=Sc(typeof t==`string`?e[wc(e,t)]:e[t]);let a=i[r[0]];return pc(r,e=>{a>i[e]&&(a=i[e])}),a}function Dh(e,t,n){if(isNaN(t)&&typeof t!=`string`)return B;let r=bh(e,n),i=[];i=Sc(typeof t==`string`?e[wc(e,t)]:e[t]);let a=[];pc(r,e=>{a.push(i[e])}),a=yh(a);let o=1;return pc(a,e=>{o*=e}),o}function Oh(e,t,n){if(isNaN(t)&&typeof t!=`string`)return B;let r=bh(e,n),i=[];i=Sc(typeof t==`string`?e[wc(e,t)]:e[t]);let a=[];return pc(r,e=>{a.push(i[e])}),a=yh(a),Yu.S(a)}function kh(e,t,n){if(isNaN(t)&&typeof t!=`string`)return B;let r=bh(e,n),i=[];i=Sc(typeof t==`string`?e[wc(e,t)]:e[t]);let a=[];return pc(r,e=>{a.push(i[e])}),a=yh(a),Yu.P(a)}function Ah(e,t,n){if(isNaN(t)&&typeof t!=`string`)return B;let r=bh(e,n),i=[];i=Sc(typeof t==`string`?e[wc(e,t)]:e[t]);let a=[];return pc(r,e=>{a.push(i[e])}),_f(a)}function jh(e,t,n){if(isNaN(t)&&typeof t!=`string`)return B;let r=bh(e,n),i=[];i=Sc(typeof t==`string`?e[wc(e,t)]:e[t]);let a=[];return pc(r,e=>{a.push(i[e])}),td.S(a)}function Mh(e,t,n){if(isNaN(t)&&typeof t!=`string`)return B;let r=bh(e,n),i=[];i=Sc(typeof t==`string`?e[wc(e,t)]:e[t]);let a=[];return pc(r,e=>{a.push(i[e])}),td.P(a)}function Nh(e){return e&&e.getTime&&!isNaN(e.getTime())}function Ph(e){return e instanceof Date?e:new Date(e)}function Fh(e,t,n){let r=K(t);for(r.setFullYear(e.getFullYear()),r<e&&r.setFullYear(r.getFullYear()+1);r>e;)r.setMonth(r.getMonth()+-12/n);return r}function Ih(e){return e=q(e),[1,2,4].indexOf(e)===-1?V:e}function Lh(e){return e=q(e),[0,1,2,3,4].indexOf(e)===-1?V:e}function Rh(e,t,n,r,i,a,o){return e=Ph(e),t=Ph(t),n=Ph(n),a=Ih(a),o=Lh(o),W(a,o)?V:!Nh(e)||!Nh(t)||!Nh(n)?B:r<=0||i<=0||n<=e?V:(i||=0,o||=0,i*r*mp(e,n,o))}function zh(e,t,n,r){if(r=Lh(r),n=Ih(n),e=K(e),t=K(t),W(e,t))return B;if(W(n,r)||e>=t)return V;if(r===1){let r=Fh(e,t,n),i=K(r);return i.setMonth(i.getMonth()+12/n),Wf(r,i,`D`)}let i;switch(r){case 0:case 2:case 4:i=360;break;case 3:i=365;break;default:return V}return i/n}function Bh(e,t,n,r,i,a){if(e=q(e),t=q(t),n=q(n),G(e,t,n))return B;if(e<=0||t<=0||n<=0||r<1||i<1||r>i||a!==0&&a!==1)return V;let o=ig(e,t,n,0,a),s=0;r===1&&(a===0&&(s=-n),r++);for(let t=r;t<=i;t++)s+=a===1?Jh(e,t-2,o,n,1)-o:Jh(e,t-1,o,n,0);return s*=e,s}function Vh(e,t,n,r,i,a){if(e=q(e),t=q(t),n=q(n),G(e,t,n))return B;if(e<=0||t<=0||n<=0||r<1||i<1||r>i||a!==0&&a!==1)return V;let o=ig(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-(Jh(e,t-2,o,n,1)-o)*e:o-Jh(e,t-1,o,n,0)*e;return s}function Hh(e,t,n,r,i){if(i=i===void 0?12:i,e=q(e),t=q(t),n=q(n),r=q(r),i=q(i),G(e,t,n,r,i))return B;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 V;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 Uh(e,t,n,r,i){if(i=i===void 0?2:i,e=q(e),t=q(t),n=q(n),r=q(r),i=q(i),G(e,t,n,r,i))return B;if(e<0||t<0||n<0||r<0||i<=0||r>n)return V;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 Wh(e,t,n,r,i){if(e=K(e),t=K(t),n=q(n),r=q(r),i=q(i),i||=0,G(e,t,n,r,i))return B;if(n<=0||r<=0)return V;if(e>=t)return B;let a,o;switch(i){case 0:a=360,o=Yf(e,t,!1);break;case 1:a=365,o=Wf(e,t,`D`);break;case 2:a=360,o=Wf(e,t,`D`);break;case 3:a=365,o=Wf(e,t,`D`);break;case 4:a=360,o=Yf(e,t,!0);break;default:return V}return(r-n)/r*a/o}function Gh(e,t){if(e=q(e),t=q(t),G(e,t))return B;if(t<0)return V;if(t>=0&&t<1)return Rs;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 Kh(e,t){if(e=q(e),t=q(t),G(e,t))return B;if(t<0)return V;if(t>=0&&t<1)return Rs;t=parseInt(t,10);let n=parseInt(e,10);return n+=e%1*10**-Math.ceil(Math.log(t)/Math.LN10)*t,n}function qh(e,t){return e=q(e),t=q(t),G(e,t)?B:e<=0||t<1?V:(t=parseInt(t,10),(1+e/t)**+t-1)}function Jh(e,t,n,r,i){if(r||=0,i||=0,e=q(e),t=q(t),n=q(n),r=q(r),i=q(i),G(e,t,n,r,i))return B;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 Yh(e,t){if(e=q(e),t=J(U(t)),G(e,t))return B;let n=t.length,r=e;for(let e=0;e<n;e++)r*=1+t[e];return r}function Xh(e,t,n,r,i,a){if(i||=0,a||=0,e=q(e),t=q(t),n=q(n),r=q(r),i=q(i),a=q(a),G(e,t,n,r,i,a))return B;let o=ig(e,n,r,i,a);return(t===1?a===1?0:-r:a===1?Jh(e,t-2,o,r,1)-o:Jh(e,t-1,o,r,0))*e}function Zh(e,t){if(t=typeof t==`number`?t:t===void 0?.1:q(t),e=U(e).filter(Mc),e=J(e),G(e,t))return B;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 V;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 Qh(e,t,n,r){return e=q(e),t=q(t),n=q(n),r=q(r),G(e,t,n,r)?B:r*e*(t/n-1)}function $h(e,t,n){if(e=J(U(e)),t=q(t),n=q(n),G(e,t,n))return B;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(-ng(n,a)*(1+n)**(r-1)/(ng(t,i)*(1+t)))**(1/(r-1))-1}function eg(e,t){return e=q(e),t=q(t),G(e,t)?B:e<=0||t<1?V:(t=parseInt(t,10),((e+1)**(1/t)-1)*t)}function tg(e,t,n,r,i){if(i=i===void 0?0:i,r=r===void 0?0:r,e=q(e),t=q(t),n=q(n),r=q(r),i=q(i),G(e,t,n,r,i))return B;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 ng(){let e=J(U(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 rg(e,t,n){return e=q(e),t=q(t),n=q(n),G(e,t,n)?B:e<=0?V:(Math.log(n)-Math.log(t))/Math.log(1+e)}function ig(e,t,n,r,i){if(r||=0,i||=0,e=q(e),t=q(t),n=q(n),r=q(r),i=q(i),G(e,t,n,r,i))return B;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 ag(e,t,n,r,i,a){return i||=0,a||=0,e=q(e),n=q(n),r=q(r),i=q(i),a=q(a),G(e,n,r,i,a)?B:ig(e,n,r,i,a)-Xh(e,t,n,r,i,a)}function og(e,t,n,r,i){if(e=K(e),t=K(t),n=q(n),r=q(r),i=q(i),i||=0,G(e,t,n,r,i))return B;if(n<=0||r<=0)return V;if(e>=t)return B;let a,o;switch(i){case 0:a=360,o=Yf(e,t,!1);break;case 1:a=365,o=Wf(e,t,`D`);break;case 2:a=360,o=Wf(e,t,`D`);break;case 3:a=365,o=Wf(e,t,`D`);break;case 4:a=360,o=Yf(e,t,!0);break;default:return V}return r-n*r*o/a}function sg(e,t,n,r,i){return r||=0,i||=0,e=q(e),t=q(t),n=q(n),r=q(r),i=q(i),G(e,t,n,r,i)?B:e===0?-n*t-r:((1-(1+e)**+t)/e*n*(1+e*i)-r)/(1+e)**+t}function cg(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=q(e),t=q(t),n=q(n),r=q(r),i=q(i),a=q(a),G(e,t,n,r,i,a))return B;let o=1e-10,s=a;i=+!!i;for(let a=0;a<100;a++){if(s<=-1)return V;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 lg(e,t,n){return e=q(e),t=q(t),n=q(n),G(e,t,n)?B:e===0||t===0?V:(n/t)**(1/e)-1}function ug(e,t,n){return e=q(e),t=q(t),n=q(n),G(e,t,n)?B:n===0?V:(e-t)/n}function dg(e,t,n,r){return e=q(e),t=q(t),n=q(n),r=q(r),G(e,t,n,r)?B:n===0||r<1||r>n?V:(r=parseInt(r,10),(e-t)*(n-r+1)*2/(n*(n+1)))}function fg(e,t,n){return e=K(e),t=K(t),n=q(n),G(e,t,n)?B:n<=0||e>t||t-e>31536e6?V:365*n/(360-n*Yf(e,t,!1))}function pg(e,t,n){return e=K(e),t=K(t),n=q(n),G(e,t,n)?B:n<=0||e>t||t-e>31536e6?V:100*(1-n*Yf(e,t,!1)/360)}function mg(e,t,n){return e=K(e),t=K(t),n=q(n),G(e,t,n)?B:n<=0||e>t||t-e>31536e6?V:(100-n)*360/(n*Yf(e,t,!1))}function hg(e,t,n){if(e=J(U(e)),t=Oc(U(t)),n=q(n),G(e,t,n))return B;let r=(e,t,n)=>{let r=n+1,i=e[0];for(let n=1;n<e.length;n++)i+=e[n]/r**(Jf(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=Jf(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 V;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 gg(e,t,n){if(e=q(e),t=J(U(t)),n=Oc(U(n)),G(e,t,n))return B;let r=0;for(let i=0;i<t.length;i++)r+=t[i]/(1+e)**(Jf(n[i],n[0])/365);return r}function _g(){let e=U(arguments),t=B;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===B&&(t=!0),e[n]||(t=!1))}return t}function vg(){return!1}function yg(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 bg(){for(let e=0;e<arguments.length/2;e++)if(arguments[e*2])return arguments[e*2+1];return H}function xg(e,t){return Ic(e)?t:e}function Sg(e,t){return e===H?t:e}function Cg(e){return typeof e==`string`?B:e instanceof Error?e:!e}function wg(){let e=U(arguments),t=B;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===B&&(t=!1),e[n]&&(t=!0))}return t}function Tg(){return!0}function Eg(){let e=U(arguments),t=B;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===B&&(t=0),e[n]&&t++)}return t===B?t:!!(Math.floor(Math.abs(t))&1)}function Dg(){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:H)}else e=B;return e}var Og={errors:Ws,symbols:zf,date:Xs},kg=Fs;function Ag(e){let t=e.split(`.`).reduce((e,t)=>e?.[t],kg);if(typeof t!=`function`)throw Error(`@formulajs/formulajs has no ${e}.`);return t}function jg(e){return typeof e==`number`?Number.isFinite(e)?e:D.NUM:e instanceof Error?ce(e.message)??D.VALUE:typeof e==`boolean`||typeof e==`string`?e:D.VALUE}var Mg=(e,t)=>{try{return jg(e(...t))}catch{return D.VALUE}};function Ng(e,t){return Jn([e],t)}function Pg(e,t){let n=I(e,t);if(n instanceof E)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 E)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=Ag(n);P(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`?M(r):e===`b`?Dn(r):N(r);if(a instanceof E)return a;t.push(a)}return Mg(a,t)},{from:`formulajs`})}function Fg(e,t,n){let r=t.replace(`?`,``),i=r.endsWith(`r`),a=Ag(n);F(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=Jn(e.slice(a),t);if(r instanceof E)return r;n.push(r);break}if(o instanceof A){n.push(void 0);continue}let c;if(s===`l`)c=Ng(o,t);else if(s===`m`)c=Pg(o,t);else{let e=t.calc.scalar(o,t.frame);c=s===`n`?M(e):s===`b`?Dn(e):N(e)}if(c instanceof E)return c;n.push(c)}return Mg(a,n)},{from:`formulajs`})}function Ig(e,t,n=``,r=1){let i=Ag(t),a=n.length;F(e,`${`v`.repeat(a)}rr`,(e,t)=>{let n=[];for(let r of e.slice(0,a)){let e=M(t.calc.scalar(r,t.frame));if(e instanceof E)return e;n.push(e)}let o=I(e[a],t),s=I(e[a+1],t);if(o instanceof E)return o;if(s instanceof E)return s;if(o.rows*o.cols!==s.rows*s.cols)return D.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 E)return n;if(r instanceof E)return r;typeof n==`number`&&typeof r==`number`&&(c.push(n),l.push(r))}if(c.length<r)return D.DIV0;let u=Mg(i,[...n,c,l]);return u===D.NUM?D.DIV0:u},{from:`formulajs`})}function Lg(e,t,n=!1,r=1,i=D.DIV0){let a=Ag(t);F(e,`(r)`,(e,t)=>{let o=n?Yn(e,t):Jn(e,t);if(o instanceof E)return o;if(o.length<r)return i;let s=Mg(a,[o]);return s===D.NUM&&i===D.DIV0?D.DIV0:s},{from:`formulajs`})}function Rg(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?``:be(Number(n));if(a===void 0)return o;let s=i===void 0?``:be(Number(i));return`${o}${r??``}${s===`1`?``:s}${a}`}function zg(e,t){let n=Ag(e);P(e,t.length,t.length,(...e)=>{let r=[];for(let[n,i]of e.entries()){let e=t.charAt(n)===`n`?M(i):N(i);if(e instanceof E)return e;r.push(e)}let i=Mg(n,r);return typeof i==`string`?Rg(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`),P(`FLOOR`,2,2,(e,t)=>{let n=M(e??0);if(n instanceof E)return n;let r=M(t??0);return r instanceof E?r:n===0&&r===0?0:Mg(Ag(`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`),Gn(`ISO.CEILING`,`CEILING.PRECISE`),P(`PI`,0,0,()=>Math.PI),F(`RAND`,``,(e,t)=>t.calc.random(),{volatile:!0}),F(`RANDBETWEEN`,`vv`,(e,t)=>{let n=M(t.calc.scalar(e[0],t.frame)),r=M(t.calc.scalar(e[1],t.frame));if(n instanceof E)return n;if(r instanceof E)return r;let i=Math.ceil(n),a=Math.floor(r);return i>a?D.NUM:i+Math.floor(t.calc.random()*(a-i+1))},{volatile:!0}),Lg(`MULTINOMIAL`,`MULTINOMIAL`),Lg(`AVEDEV`,`AVEDEV`,!1,1,D.NUM),Lg(`DEVSQ`,`DEVSQ`,!1,1,D.NUM),Lg(`MEDIAN`,`MEDIAN`,!1,1,D.NUM),Lg(`SKEW`,`SKEW`,!1,3),Lg(`SKEW.P`,`SKEW.P`,!1,3),Lg(`STDEV.S`,`STDEV.S`,!1,2),Lg(`STDEV.P`,`STDEV.P`,!1,1),Lg(`VAR.S`,`VAR.S`,!1,2),Lg(`VAR.P`,`VAR.P`,!1,1),Lg(`STDEVA`,`STDEVA`,!0,2),Lg(`STDEVPA`,`STDEVPA`,!0,1),Lg(`VARA`,`VARA`,!0,2),Lg(`VARPA`,`VARPA`,!0,1);for(let[e,t]of[[`STDEV`,`STDEV.S`],[`STDEVP`,`STDEV.P`],[`VAR`,`VAR.S`],[`VARP`,`VAR.P`]])Gn(e,t);Fg(`PERCENTILE.INC`,`ln`,`PERCENTILE.INC`),Fg(`PERCENTILE.EXC`,`ln`,`PERCENTILE.EXC`),Fg(`PERCENTRANK.INC`,`ln?n`,`PERCENTRANK.INC`),Fg(`PERCENTRANK.EXC`,`ln?n`,`PERCENTRANK.EXC`),Fg(`QUARTILE.EXC`,`ln`,`QUARTILE.EXC`),F(`TRIMMEAN`,`rv`,(e,t)=>{let n=Jn([e[0]],t);if(n instanceof E)return n;let r=M(t.calc.scalar(e[1],t.frame));if(r instanceof E)return r;if(r<0||r>=1||n.length===0)return D.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}),Gn(`PERCENTILE`,`PERCENTILE.INC`),Gn(`PERCENTRANK`,`PERCENTRANK.INC`),Ig(`CORREL`,`CORREL`),Ig(`PEARSON`,`PEARSON`),Ig(`RSQ`,`RSQ`),Ig(`SLOPE`,`SLOPE`),Ig(`INTERCEPT`,`INTERCEPT`),Ig(`STEYX`,`STEYX`,``,3),Ig(`COVARIANCE.P`,`COVARIANCE.P`),Ig(`COVARIANCE.S`,`COVARIANCE.S`,``,2),Ig(`FORECAST`,`FORECAST`,`n`),Gn(`FORECAST.LINEAR`,`FORECAST`),Gn(`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`),Fg(`IRR`,`l?n`,`IRR`),Fg(`MIRR`,`lnn`,`MIRR`),Fg(`NPV`,`nr`,`NPV`),Fg(`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`])zg(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=Ag(e);P(e,1,2,(e,r)=>{let i=t===`n`?M(e):N(e);if(i instanceof E)return i;let a=r===void 0?void 0:M(r);if(a instanceof E)return a;let o=Mg(n,[i,a]);return typeof o==`string`?o.toUpperCase():o},{from:`formulajs`})}zg(`IMDIV`,`tt`),zg(`IMSUB`,`tt`),zg(`IMPOWER`,`tn`),X(`COMPLEX`,`nn?t`,`COMPLEX`),X(`DECIMAL`,`tn`,`DECIMAL`),X(`ARABIC`,`t`,`ARABIC`);for(let e of[`IMSUM`,`IMPRODUCT`]){let t=Ag(e);F(e,`(r)`,(e,n)=>{let r=[],i;if(Kn(e,n,e=>{if(i||e===null)return;let t=N(e);t instanceof E?i=t:r.push(t)}),i)return i;let a=Mg(t,r);return typeof a==`string`?Rg(a):a},{from:`formulajs`})}X(`DELTA`,`n?n`,`DELTA`),X(`GESTEP`,`n?n`,`GESTEP`);var Bg=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.00016431823292116355,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22],Vg=607/128,Hg=.5*Math.log(2*Math.PI);function Ug(e){if(Number.isInteger(e)&&e<=171)return Math.log(Wg(e));let t=Bg[0]??0;for(let n=1;n<Bg.length;n++)t+=(Bg[n]??0)/(e+n);let n=e+Vg+.5;return Hg+Math.log(t/e)+(e+.5)*Math.log(n)-n}function Wg(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)*Wg(1-e)):Math.exp(Ug(e))}var Gg=1e-16,Kg=1e-300,qg=1e5;function Jg(e,t){if(t<=0)return 0;if(t<e+1){let n=1/e,r=n,i=e;for(let e=0;e<qg&&(i+=1,n*=t/i,r+=n,!(Math.abs(n)<Math.abs(r)*Gg));e++);return r*Math.exp(-t+e*Math.log(t)-Ug(e))}return 1-Yg(e,t)}function Yg(e,t){if(t<=0)return 1;if(t<e+1)return 1-Jg(e,t);let n=t+1-e,r=1/Kg,i=1/n,a=i;for(let t=1;t<qg;t++){let o=-t*(t-e);n+=2,i=o*i+n,Math.abs(i)<Kg&&(i=Kg),r=n+o/r,Math.abs(r)<Kg&&(r=Kg),i=1/i;let s=i*r;if(a*=s,Math.abs(s-1)<Gg)break}return Math.exp(-t+e*Math.log(t)-Ug(e))*a}function Xg(e,t,n){let r=e+t,i=e+1,a=e-1,o=1,s=1-r*n/i;Math.abs(s)<Kg&&(s=Kg),s=1/s;let c=s;for(let l=1;l<qg;l++){let u=2*l,d=l*(t-l)*n/((a+u)*(e+u));s=1+d*s,Math.abs(s)<Kg&&(s=Kg),o=1+d/o,Math.abs(o)<Kg&&(o=Kg),s=1/s,c*=s*o,d=-(e+l)*(r+l)*n/((e+u)*(i+u)),s=1+d*s,Math.abs(s)<Kg&&(s=Kg),o=1+d/o,Math.abs(o)<Kg&&(o=Kg),s=1/s;let f=s*o;if(c*=f,Math.abs(f-1)<Gg)break}return c}function Zg(e,t,n){if(n<=0)return 0;if(n>=1)return 1;let r=Math.exp(Ug(e+t)-Ug(e)-Ug(t)+e*Math.log(n)+t*Math.log1p(-n));return n<(e+1)/(e+t+2)?r*Xg(e,t,n)/e:1-r*Xg(t,e,1-n)/t}var Qg=e=>e===0?0:(e<0?-1:1)*Jg(.5,e*e),$g=e=>e<0?2-$g(-e):Yg(.5,e*e),e_=e=>Math.exp(-e*e/2)/Math.sqrt(2*Math.PI),t_=e=>$g(-e/Math.SQRT2)/2,n_=(e,t)=>e.reduce((e,n)=>e*t+n,0),r_={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 i_(e){let t=e-.5;if(t===0)return 0;if(Math.abs(t)<=.425){let e=.180625-t*t;return t*n_(r_.a,e)/n_(r_.b,e)}let n=t<0?e:1-e,r=Math.sqrt(-Math.log(n)),i=r<=5?n_(r_.c,r-1.6)/n_(r_.d,r-1.6):n_(r_.e,r-5)/n_(r_.f,r-5);return t<0?-i:i}function a_(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 o_(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 s_=4e4;function c_(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 l_(e,t){let n=o_(n=>Math.sin(t*Math.sin(n)-e*n),0,Math.PI,s_),r=Math.asinh((760+2*e*e)/t)+2,i=e%2==0?1:-1;return(n-o_(n=>(Math.exp(e*n)+i*Math.exp(-e*n))*Math.exp(-t*Math.sinh(n)),0,r,s_))/Math.PI}function u_(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 d_(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){P(e,t,n,(...e)=>{let t=[];for(let n of e){let e=n===void 0?NaN:M(n);if(e instanceof E)return e;t.push(e)}return r(...t)})}function f_(e,t,n,r=0){P(e,t+1,t+1+r,(...e)=>{let r=Dn(e[t]);if(r instanceof E)return r;let i=[];for(let[n,r]of e.entries()){if(n===t)continue;let e=r===void 0?NaN:M(r);if(e instanceof E)return e;i.push(e)}return n(r,...i)})}var p_=e=>Number.isFinite(e)?e:D.NUM;f_(`NORM.DIST`,3,(e,t=0,n=0,r=0)=>{if(r<=0)return D.NUM;let i=(t-n)/r;return e?t_(i):e_(i)/r}),Z(`NORM.INV`,3,3,(e=0,t=0,n=0)=>e<=0||e>=1||n<=0?D.NUM:t+n*i_(e)),P(`NORM.S.DIST`,1,2,(e,t)=>{let n=M(e);if(n instanceof E)return n;let r=t===void 0||Dn(t);return r instanceof E?r:r?t_(n):e_(n)}),Z(`NORMSDIST`,1,1,(e=0)=>t_(e)),Z(`NORM.S.INV`,1,1,(e=0)=>e<=0||e>=1?D.NUM:i_(e)),f_(`LOGNORM.DIST`,3,(e,t=0,n=0,r=0)=>{if(t<=0||r<=0)return D.NUM;let i=(Math.log(t)-n)/r;return e?t_(i):e_(i)/(t*r)}),Z(`LOGNORMDIST`,3,3,(e=0,t=0,n=0)=>e<=0||n<=0?D.NUM:t_((Math.log(e)-t)/n)),Z(`LOGNORM.INV`,3,3,(e=0,t=0,n=0)=>e<=0||e>=1||n<=0?D.NUM:Math.exp(t+n*i_(e))),Z(`STANDARDIZE`,3,3,(e=0,t=0,n=0)=>n<=0?D.NUM:(e-t)/n),Z(`GAUSS`,1,1,(e=0)=>t_(e)-.5),Z(`PHI`,1,1,(e=0)=>e_(e)),Z(`FISHER`,1,1,(e=0)=>e<=-1||e>=1?D.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?D.NUM:i_(1-e/2)*t/Math.sqrt(r)});var m_=(e,t)=>Zg(t/2,.5,t/(t+e*e)),h_=(e,t)=>e<0?m_(e,t)/2:1-m_(e,t)/2;f_(`T.DIST`,2,(e,t=0,n=0)=>{let r=Math.trunc(n);return r<1?D.NUM:e?h_(t,r):Math.exp(Ug((r+1)/2)-Ug(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?D.NUM:m_(e,n)}),Z(`T.DIST.RT`,2,2,(e=0,t=0)=>{let n=Math.trunc(t);return n<1?D.NUM:e<0?1-m_(e,n)/2:m_(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?D.NUM:m_(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?D.NUM:e===.5?0:e<.5?-g_(2*e,n):g_(2*(1-e),n)});var g_=(e,t)=>a_(e=>-m_(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?D.NUM:g_(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?D.NUM:r===1?D.DIV0:g_(e,r-1)*t/Math.sqrt(r)}),f_(`CHISQ.DIST`,2,(e,t=0,n=0)=>{let r=Math.trunc(n);return t<0||r<1?D.NUM:e?Jg(r/2,t/2):t===0?r===2?.5:r<2?D.NUM:0:Math.exp((r/2-1)*Math.log(t)-t/2-r/2*Math.LN2-Ug(r/2))}),Z(`CHISQ.DIST.RT`,2,2,(e=0,t=0)=>{let n=Math.trunc(t);return e<0||n<1?D.NUM:Yg(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?D.NUM:e===0?0:a_(e=>Jg(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?D.NUM:e===1?0:a_(e=>-Yg(n/2,e/2),-e,0,n)});var __=(e,t,n)=>Zg(t/2,n/2,t*e/(t*e+n)),v_=(e,t,n)=>Zg(n/2,t/2,n/(t*e+n));f_(`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 D.NUM;if(e)return __(t,i,a);if(t===0)return i===2?1:i<2?D.NUM:0;let o=Ug((i+a)/2)-Ug(i/2)-Ug(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?D.NUM:v_(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?D.NUM:e===0?0:e===1?D.NUM:a_(e=>__(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?D.NUM:e===1?0:a_(e=>-v_(e,r,i),-e,0,1)}),f_(`GAMMA.DIST`,3,(e,t=0,n=0,r=0)=>t<0||n<=0||r<=0?D.NUM:e?Jg(n,t/r):t===0?n===1?1/r:n<1?D.NUM:0:Math.exp((n-1)*Math.log(t)-t/r-n*Math.log(r)-Ug(n))),Z(`GAMMA.INV`,3,3,(e=0,t=0,n=0)=>e<0||e>=1||t<=0||n<=0?D.NUM:e===0?0:n*a_(e=>Jg(t,e),e,0,t));var y_=(e,t,n)=>Math.exp(Ug(t+n)-Ug(t)-Ug(n)+(t-1)*Math.log(e)+(n-1)*Math.log1p(-e));f_(`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 D.NUM;let c=(t-o)/(s-o);return e?Zg(n,r,c):y_(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?D.NUM:Zg(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?D.NUM:a+(o-a)*a_(e=>Zg(t,n,e),e,0,.5,1)}),Gn(`BETAINV`,`BETA.INV`);var b_=(e,t)=>Ug(e+1)-Ug(t+1)-Ug(e-t+1),x_=(e,t,n)=>n===0?+(e===0):n===1?+(e===t):Math.exp(b_(t,e)+e*Math.log(n)+(t-e)*Math.log1p(-n)),S_=(e,t,n)=>e>=t||n===0?1:n===1?0:1-Zg(e+1,t-e,n);f_(`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?D.NUM:e?S_(i,a,r):x_(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 D.NUM;for(let e=0;e<r;e++)if(S_(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 D.NUM;let s=0;for(let e=a;e<=o;e++)s+=x_(e,i,t);return s}),f_(`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?D.NUM:e?Zg(a,i+1,r):r===0||r===1?+(r===1&&i===0):Math.exp(b_(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?D.NUM:n===0||n===1?+(n===1&&r===0):Math.exp(b_(r+i-1,i-1)+i*Math.log(n)+r*Math.log1p(-n))}),f_(`POISSON.DIST`,2,(e,t=0,n=0)=>{let r=Math.trunc(t);return r<0||n<0?D.NUM:n===0?e||r===0?1:0:e?Yg(r+1,n):Math.exp(r*Math.log(n)-n-Ug(r+1))}),f_(`EXPON.DIST`,2,(e,t=0,n=0)=>t<0||n<=0?D.NUM:e?-Math.expm1(-n*t):n*Math.exp(-n*t)),f_(`WEIBULL.DIST`,3,(e,t=0,n=0,r=0)=>{if(t<0||n<=0||r<=0)return D.NUM;let i=(t/r)**n;return e?-Math.expm1(-i):n/r**n*t**(n-1)*Math.exp(-i)});var C_=(e,t,n,r)=>Math.exp(b_(n,e)+b_(r-n,t-e)-b_(r,t));f_(`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 D.NUM;if(!e)return C_(a,o,s,c);let l=0;for(let e=Math.max(0,o-c+s);e<=a;e++)l+=C_(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?D.NUM:C_(i,a,o,s)}),Z(`GAMMA`,1,1,(e=0)=>p_(Wg(e))),Z(`GAMMALN`,1,1,(e=0)=>e<=0?D.NUM:Ug(e)),Gn(`GAMMALN.PRECISE`,`GAMMALN`),Z(`ERF`,1,2,(e=0,t=NaN)=>Number.isNaN(t)?Qg(e):Qg(t)-Qg(e)),Z(`ERFC`,1,1,(e=0)=>$g(e)),Gn(`ERF.PRECISE`,`ERF`),Gn(`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`]])Gn(e,t);var w_=2**48;function T_(e,t){let[n=`0`,r=`0`]=e.toExponential().split(`e`);return Number(`${n}e${String(Number(r)+t)}`)}var E_=e=>Number(e.toPrecision(15));function D_(e,t,n){let r=Math.trunc(t),i=T_(Math.abs(E_(e)),r);if(i>=2**53)return e;let a=T_(n(i),-r);return e<0?-a:a}P(`ROUND`,2,2,Xn((e=0,t=0)=>D_(e,t,e=>Math.floor(e+.5)))),P(`ROUNDUP`,2,2,Xn((e=0,t=0)=>D_(e,t,Math.ceil))),P(`ROUNDDOWN`,2,2,Xn((e=0,t=0)=>D_(e,t,Math.floor))),P(`MOD`,2,2,Xn((e=0,t=0)=>{if(t===0)return D.DIV0;let n=e%t;return n!==0&&n<0!=t<0?n+t:n})),P(`QUOTIENT`,2,2,Xn((e=0,t=0)=>t===0?D.DIV0:Math.trunc(e/t))),P(`POWER`,2,2,Xn((e=0,t=0)=>{if(e===0&&t===0)return D.NUM;if(e===0&&t<0)return D.DIV0;let n=e**t;return Number.isFinite(n)?n:D.NUM})),P(`LOG`,1,2,(e,t)=>{let n=M(e),r=t==null?10:M(t);return n instanceof E?n:r instanceof E?r:n<=0||r<=0?D.NUM:r===1?D.DIV0:r===10?Math.log10(n):r===2?Math.log2(n):Math.log(n)/Math.log(r)});function O_(e,t){let[n,r]=[e,t];for(;r!==0;)[n,r]=[r,n%r];return n}function k_(e,t){let n=Jn(e,t);if(n instanceof E)return n;let r=n.map(Math.trunc);return r.some(e=>e<0||e>=2**53)?D.NUM:r}F(`GCD`,`(r)`,(e,t)=>{let n=k_(e,t);return n instanceof E?n:n.reduce(O_,0)}),F(`LCM`,`(r)`,(e,t)=>{let n=k_(e,t);if(n instanceof E)return n;if(n.includes(0))return 0;let r=n.reduce((e,t)=>e*t/O_(e,t),1);return Number.isFinite(r)?r:D.NUM}),P(`BASE`,2,3,Xn((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?D.NUM:r.toString(i).toUpperCase().padStart(a,`0`)}));var A_=`MDCLXVI`,j_=[1e3,500,100,50,10,5,1];function M_(e,t){let n=e=>j_[e]??1,r=e=>A_.charAt(e),i=j_.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}P(`ROMAN`,1,2,(e,t)=>{let n=M(e);if(n instanceof E)return n;let r=0;if(typeof t==`boolean`)r=t?0:4;else if(t!=null){let e=M(t);if(e instanceof E)return e;r=Math.trunc(e)}let i=Math.trunc(n);return i<0||i>3999||r<0||r>4?D.VALUE:M_(i,r)});function N_(e){return!Number.isInteger(e)||e<0||e>=w_?D.NUM:BigInt(e)}for(let[e,t]of[[`BITAND`,(e,t)=>e&t],[`BITOR`,(e,t)=>e|t],[`BITXOR`,(e,t)=>e^t]])P(e,2,2,Xn((e=0,n=0)=>{let r=N_(e),i=N_(n);return r instanceof E?r:i instanceof E?i:Number(t(r,i))}));for(let[e,t]of[[`BITLSHIFT`,1],[`BITRSHIFT`,-1]])P(e,2,2,Xn((e=0,n=0)=>{let r=N_(e);if(r instanceof E)return r;let i=Math.trunc(n)*t;if(Math.abs(i)>53)return D.NUM;let a=i>=0?r<<BigInt(i):r>>BigInt(-i);return a>=BigInt(w_)?D.NUM:Number(a)}));for(let[e,t,n]of[[`BESSELJ`,c_,!1],[`BESSELI`,u_,!1],[`BESSELY`,l_,!0],[`BESSELK`,d_,!0]])P(e,2,2,Xn((e=0,r=0)=>{let i=Math.trunc(r);if(i<0||n&&e<=0)return D.NUM;let a=t(i,e);return Number.isFinite(a)?a:D.NUM}));P(`SLN`,3,3,Xn((e=0,t=0,n=0)=>n===0?D.DIV0:(e-t)/n)),F(`GEOMEAN`,`(r)`,(e,t)=>{let n=Jn(e,t);return n instanceof E?n:n.length===0||n.some(e=>e<=0)?D.NUM:Math.exp(n.reduce((e,t)=>e+Math.log(t),0)/n.length)}),F(`HARMEAN`,`(r)`,(e,t)=>{let n=Jn(e,t);return n instanceof E?n:n.length===0||n.some(e=>e<=0)?D.NUM:n.length/n.reduce((e,t)=>e+1/t,0)}),F(`KURT`,`(r)`,(e,t)=>{let n=Jn(e,t);if(n instanceof E)return n;let r=n.length;if(r<4)return D.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 D.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 P_(e,t){let n=[],r;return qn(e,t,(e,t)=>{if(!r){if(e instanceof E)r=e;else if(typeof e==`number`)n.push(e);else if(t&&e!==null){let t=M(e);t instanceof E?r=t:n.push(t)}}}),r??n}F(`MODE.SNGL`,`(r)`,(e,t)=>{let n=P_(e,t);if(n instanceof E)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??D.NA}),Gn(`MODE`,`MODE.SNGL`),F(`MODE.MULT`,`(r)`,(e,t)=>{let n=P_(e,t);if(n instanceof E)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 D.NA;let a=[...r].filter(([,e])=>e===i).map(([e])=>e);return new O(a.length,1,a)});function F_(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)}F(`QUARTILE.INC`,`rv`,(e,t)=>{let n=Jn([e[0]],t);if(n instanceof E)return n;let r=M(t.calc.scalar(e[1],t.frame));if(r instanceof E)return r;let i=Math.trunc(r);return n.length===0||i<0||i>4?D.NUM:F_([...n].sort((e,t)=>e-t),i/4)}),Gn(`QUARTILE`,`QUARTILE.INC`);function I_(e,t){let n=M(t.calc.scalar(e[0],t.frame));if(n instanceof E)return n;let r=Jn([e[1]],t);if(r instanceof E)return r;let i=e[2]===void 0?0:M(t.calc.scalar(e[2],t.frame));if(i instanceof E)return i;let a=r.filter(e=>e===n).length;return a===0?D.NA:{before:r.filter(e=>i===0?e>n:e<n).length,ties:a}}F(`RANK.EQ`,`vr?v`,(e,t)=>{let n=I_(e,t);return n instanceof E?n:n.before+1}),F(`RANK.AVG`,`vr?v`,(e,t)=>{let n=I_(e,t);return n instanceof E?n:n.before+(n.ties+1)/2}),Gn(`RANK`,`RANK.EQ`);function L_(e,t){let n=I(e,t);if(n instanceof E)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 E)return i;if(typeof i!=`number`)return D.VALUE;t.push(i)}r.push(t)}return r}var R_=e=>new O(e.length,e[0]?.length??0,e.flat());function z_(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)))}F(`MMULT`,`rr`,(e,t)=>{let n=L_(e[0],t),r=L_(e[1],t);return n instanceof E?n:r instanceof E?r:(n[0]?.length??0)===r.length?R_(z_(n,r)):D.VALUE});function B_(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 V_=e=>e.length>0&&e.every(t=>t.length===e.length);F(`MDETERM`,`r`,(e,t)=>{let n=L_(e[0],t);return n instanceof E?n:V_(n)?B_(n).determinant:D.VALUE}),F(`MINVERSE`,`r`,(e,t)=>{let n=L_(e[0],t);if(n instanceof E)return n;if(!V_(n))return D.VALUE;let{inverse:r}=B_(n);return r?R_(r):D.NUM}),P(`MUNIT`,1,1,Xn((e=0)=>{let t=Math.trunc(e);return t<1||t>73?D.VALUE:R_(Array.from({length:t},(e,n)=>Array.from({length:t},(e,t)=>+(n===t))))}));function H_(e,t,n){let r=I(e,n),i=I(t,n);if(r instanceof E)return r;if(i instanceof E)return i;if(r.rows*r.cols!==i.rows*i.cols)return D.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 E)return n;if(s instanceof E)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]])F(e,`rr`,(e,n)=>{let r=H_(e[0],e[1],n);return r instanceof E?r:r.xs.length===0?D.DIV0:r.xs.reduce((e,n,i)=>e+t(n,r.ys[i]??0),0)});F(`SERIESSUM`,`vvvr`,(e,t)=>{let[n,r,i]=e.slice(0,3).map(e=>M(t.calc.scalar(e,t.frame)));if(n instanceof E)return n;if(r instanceof E)return r;if(i instanceof E)return i;let a=Jn([e[3]],t);return a instanceof E?a:a.reduce((e,t,a)=>e+t*(n??0)**((r??0)+a*(i??0)),0)}),F(`FREQUENCY`,`rr`,(e,t)=>{let n=Jn([e[0]],t);if(n instanceof E)return n;let r=[];Kn([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 O(a.length,1,a)}),F(`PROB`,`rrv?v`,(e,t)=>{let n=H_(e[0],e[1],t);if(n instanceof E)return n;let r=M(t.calc.scalar(e[2],t.frame));if(r instanceof E)return r;let i=e[3]===void 0?r:M(t.calc.scalar(e[3],t.frame));if(i instanceof E)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?D.NUM:n.xs.reduce((e,t,a)=>t>=r&&t<=i?e+(n.ys[a]??0):e,0)});var U_=e=>e.reduce((e,t)=>e+t,0);function W_(e,t,n){let r=t.map(e=>n?[...e,1]:[...e]),i=r[0]?.length??0,{inverse:a}=B_(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 G_(e,t,n){let r=L_(e[0],t);if(r instanceof E)return r;let i=r.length===1,a=r.flat();if(n&&a.some(e=>e<=0))return D.NUM;let o=n?a.map(Math.log):a,s=e[1];if(s===void 0||!K_(s))return{ys:o,xs:a.map((e,t)=>[t+1]),byRow:i};let c=L_(s,t);if(c instanceof E)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}:D.REF:c.length===o.length?{ys:o,xs:c,byRow:i}:D.REF}var K_=e=>e instanceof k||e instanceof O||typeof e==`number`,q_=(e,t)=>e===void 0||!K_(e)&&typeof e!=`boolean`||Dn(t.calc.scalar(e,t.frame));function J_(e){return(t,n)=>{let r=G_(t,n,e);if(r instanceof E)return r;let i=q_(t[3],n);if(i instanceof E)return i;let a=W_(r.ys,r.xs,i);if(!a)return D.NUM;let o=t[2],s=r.xs;if(o!==void 0&&K_(o)){let e=L_(o,n);if(e instanceof E)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 O(1,c.length,c):new O(c.length,1,c)}}F(`TREND`,`r?rrv`,J_(!1)),F(`GROWTH`,`r?rrv`,J_(!0));function Y_(e,t,n,r){let i=t.map(e=>r?[...e,1]:[...e]),a=i[0]?.length??0,{inverse:o}=B_(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?U_(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 X_(e){return(t,n)=>{let r=G_(t,n,e);if(r instanceof E)return r;let i=q_(t[2],n);if(i instanceof E)return i;let a=W_(r.ys,r.xs,i);if(!a)return D.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||!Z_(c)?!1:Dn(n.calc.scalar(c,n.frame));if(l instanceof E)return l;if(!l)return new O(1,s.length,s);let u=Y_(r.ys,r.xs,a,i);if(!u)return D.NUM;let d=s.length,f=e=>[...e,...Array(d-e.length).fill(D.NA)],p=i?[...u.errors.slice(0,-1).reverse(),u.errors[u.errors.length-1]??0]:[...[...u.errors].reverse(),D.NA];return new O(5,d,[...s,...p,...f([u.r2,u.sey]),...f([u.f,u.df]),...f([u.ssreg,u.ssresid])])}}var Z_=e=>K_(e)||typeof e==`boolean`;F(`LINEST`,`r?rvv`,X_(!1)),F(`LOGEST`,`r?rvv`,X_(!0));var Q_=e=>U_(e)/e.length,$_=e=>{let t=Q_(e);return e.reduce((e,n)=>e+(n-t)**2,0)/(e.length-1)};F(`CHISQ.TEST`,`rr`,(e,t)=>{let n=L_(e[0],t),r=L_(e[1],t);if(n instanceof E)return n;if(r instanceof E)return r;let i=n.length,a=n[0]?.length??0;if(r.length!==i||(r[0]?.length??0)!==a||i*a<2)return D.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 D.NUM;if(i===0)return D.DIV0;o+=((n[e]?.[t]??0)-i)**2/i}return Yg((i>1&&a>1?(i-1)*(a-1):i>1?i-1:a-1)/2,o/2)}),Gn(`CHITEST`,`CHISQ.TEST`),F(`T.TEST`,`rrvv`,(e,t)=>{let n=M(t.calc.scalar(e[2],t.frame)),r=M(t.calc.scalar(e[3],t.frame));if(n instanceof E)return n;if(r instanceof E)return r;let i=Math.trunc(n),a=Math.trunc(r);if(i!==1&&i!==2||a<1||a>3)return D.NUM;let o,s;if(a===1){let n=H_(e[0],e[1],t);if(n instanceof E)return n;let r=n.xs.map((e,t)=>e-(n.ys[t]??0));if(r.length<2)return D.DIV0;o=Q_(r)/Math.sqrt($_(r)/r.length),s=r.length-1}else{let n=Jn([e[0]],t),r=Jn([e[1]],t);if(n instanceof E)return n;if(r instanceof E)return r;if(n.length<2||r.length<2)return D.DIV0;let[i,c,l,u]=[$_(n),$_(r),n.length,r.length],d=Math.abs(Q_(n)-Q_(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)?Zg(s/2,.5,s/(s+o*o))*i/2:D.DIV0}),Gn(`TTEST`,`T.TEST`),F(`F.TEST`,`rr`,(e,t)=>{let n=Jn([e[0]],t),r=Jn([e[1]],t);if(n instanceof E)return n;if(r instanceof E)return r;if(n.length<2||r.length<2)return D.DIV0;let[i,a]=[$_(n),$_(r)];if(i===0||a===0)return D.DIV0;let o=i/a,[s,c]=[n.length-1,r.length-1],l=Zg(c/2,s/2,c/(s*o+c));return 2*Math.min(l,1-l)}),Gn(`FTEST`,`F.TEST`),F(`Z.TEST`,`rv?v`,(e,t)=>{let n=Jn([e[0]],t);if(n instanceof E)return n;let r=M(t.calc.scalar(e[1],t.frame));if(r instanceof E)return r;if(n.length===0)return D.NA;let i=e[2]===void 0?n.length<2?D.DIV0:Math.sqrt($_(n)):M(t.calc.scalar(e[2],t.frame));return i instanceof E?i:i===0?D.DIV0:1-t_((Q_(n)-r)/(i/Math.sqrt(n.length)))}),Gn(`ZTEST`,`Z.TEST`);var ev={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`};F(`AGGREGATE`,`vv(r)`,(e,t)=>{let n=M(t.calc.scalar(e[0],t.frame)),r=M(t.calc.scalar(e[1],t.frame));if(n instanceof E)return n;if(r instanceof E)return r;let i=ev[Math.trunc(n)],a=i===void 0?void 0:zn.get(i);if(a===void 0)return D.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 Pe?e.parts:[e],r=[];for(let e of n)if(e instanceof k){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 O?Le(r,n.data):r.push(n)}let i=o?r:r.filter(e=>!(e instanceof E));return new O(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)}),P(`FACT`,1,1,Xn(e=>{if(e<0)return D.NUM;let t=1;for(let n=2;n<=Math.trunc(e);n++)t*=n;return Number.isFinite(t)?t:D.NUM})),P(`FACTDOUBLE`,1,1,Xn(e=>{if(e<0)return D.NUM;let t=1;for(let n=Math.trunc(e);n>1;n-=2)t*=n;return Number.isFinite(t)?t:D.NUM})),P(`ATAN2`,2,2,Xn((e,t)=>e===0&&t===0?D.DIV0:Math.atan2(t,e)));var tv={largest:new WeakMap,smallest:new WeakMap};function nv(e,t,n){let r=()=>{let r=Jn([e],n);return r instanceof E?r:r.sort((e,n)=>t?n-e:e-n)};if(e instanceof k)return n.calc.indexes.ofRepeated(Rn(t?`large`:`small`,e),[e],()=>{let e=r();return new Map(e instanceof E?[]:[[``,e]])})?.get(``)??r();if(!(e instanceof O))return r();let i=t?tv.largest:tv.smallest,a=i.get(e);if(a)return a;let o=r();return o instanceof E||i.set(e,a===null?o:null),o}for(let[e,t]of[[`LARGE`,!0],[`SMALL`,!1]])F(e,`rv`,(e,n)=>{let r=nv(e[0],t,n);if(r instanceof E)return r;let i=M(e[1]);if(i instanceof E)return i;let a=Math.ceil(i);return a<1||a>r.length?D.NUM:r[a-1]??D.NUM});var rv=.0254,iv=12*rv,av=3*iv,ov=5280*iv,sv=1852,cv=9460730472580800,lv=rv/72,uv=453.59237,dv=9.80665,fv=uv/1e3*dv,pv=iv*fv,mv=231*rv**3/128,hv=.00454609,gv=101325,_v=550*pv,vv=new Map;function Q(e,t){for(let n of e)vv.set(n,t)}var yv=(e,t)=>({quantity:e,factor:t,prefix:1});Q([`g`],yv(`mass`,1)),Q([`sg`],{quantity:`mass`,factor:fv*1e3/iv}),Q([`lbm`],{quantity:`mass`,factor:uv}),Q([`u`],yv(`mass`,1660538782e-33)),Q([`ozm`],{quantity:`mass`,factor:uv/16}),Q([`grain`],{quantity:`mass`,factor:uv/7e3}),Q([`cwt`,`shweight`],{quantity:`mass`,factor:100*uv}),Q([`uk_cwt`,`lcwt`,`hweight`],{quantity:`mass`,factor:112*uv}),Q([`stone`],{quantity:`mass`,factor:14*uv}),Q([`ton`],{quantity:`mass`,factor:2e3*uv}),Q([`uk_ton`,`LTON`,`brton`],{quantity:`mass`,factor:2240*uv}),Q([`m`],yv(`distance`,1)),Q([`mi`],{quantity:`distance`,factor:ov}),Q([`Nmi`],{quantity:`distance`,factor:sv}),Q([`in`],{quantity:`distance`,factor:rv}),Q([`ft`],{quantity:`distance`,factor:iv}),Q([`yd`],{quantity:`distance`,factor:av}),Q([`ang`],yv(`distance`,1e-10)),Q([`ell`],{quantity:`distance`,factor:45*rv}),Q([`ly`],yv(`distance`,cv)),Q([`parsec`,`pc`],yv(`distance`,648e3/Math.PI*149597870700)),Q([`Picapt`,`Pica`],{quantity:`distance`,factor:lv}),Q([`pica`],{quantity:`distance`,factor:rv/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`],yv(`time`,1)),Q([`Pa`,`p`],yv(`pressure`,1)),Q([`atm`,`at`],yv(`pressure`,gv)),Q([`mmHg`],yv(`pressure`,gv/760)),Q([`psi`],{quantity:`pressure`,factor:fv/rv**2}),Q([`Torr`],{quantity:`pressure`,factor:gv/760}),Q([`N`],yv(`force`,1)),Q([`dyn`,`dy`],yv(`force`,1e-5)),Q([`lbf`],{quantity:`force`,factor:fv}),Q([`pond`],yv(`force`,dv/1e3)),Q([`J`],yv(`energy`,1)),Q([`e`],yv(`energy`,1e-7)),Q([`c`],yv(`energy`,4.184)),Q([`cal`],yv(`energy`,4.1868)),Q([`eV`,`ev`],yv(`energy`,1602176487e-28)),Q([`HPh`,`hh`],{quantity:`energy`,factor:_v*3600}),Q([`Wh`,`wh`],yv(`energy`,3600)),Q([`flb`],{quantity:`energy`,factor:pv}),Q([`BTU`,`btu`],{quantity:`energy`,factor:1055.05585262}),Q([`HP`,`h`],{quantity:`power`,factor:_v}),Q([`PS`],{quantity:`power`,factor:75*dv}),Q([`W`,`w`],yv(`power`,1)),Q([`T`],yv(`magnetism`,1)),Q([`ga`],yv(`magnetism`,1e-4));var bv=(e,t,n=!1)=>{Q(e,{quantity:`volume`,factor:t**3,...n?{prefix:3}:{}})};Q([`tsp`],{quantity:`volume`,factor:mv/6}),Q([`tspm`],{quantity:`volume`,factor:5e-6}),Q([`tbs`],{quantity:`volume`,factor:mv/2}),Q([`oz`],{quantity:`volume`,factor:mv}),Q([`cup`],{quantity:`volume`,factor:8*mv}),Q([`pt`,`us_pt`],{quantity:`volume`,factor:16*mv}),Q([`uk_pt`],{quantity:`volume`,factor:hv/8}),Q([`qt`],{quantity:`volume`,factor:32*mv}),Q([`uk_qt`],{quantity:`volume`,factor:hv/4}),Q([`gal`],{quantity:`volume`,factor:128*mv}),Q([`uk_gal`],{quantity:`volume`,factor:hv}),Q([`l`,`L`,`lt`],yv(`volume`,.001)),Q([`barrel`],{quantity:`volume`,factor:5376*mv}),Q([`bushel`],{quantity:`volume`,factor:2150.42*rv**3}),Q([`GRT`,`regton`],{quantity:`volume`,factor:100*iv**3}),Q([`MTON`],{quantity:`volume`,factor:40*iv**3}),bv([`m3`,`m^3`],1,!0),bv([`ang3`,`ang^3`],1e-10,!0),bv([`ft3`,`ft^3`],iv),bv([`in3`,`in^3`],rv),bv([`ly3`,`ly^3`],cv),bv([`mi3`,`mi^3`],ov),bv([`yd3`,`yd^3`],av),bv([`Nmi3`,`Nmi^3`],sv),bv([`Pica3`,`Picapt3`,`Pica^3`,`Picapt^3`],lv);var xv=(e,t,n=!1)=>{Q(e,{quantity:`area`,factor:t**2,...n?{prefix:2}:{}})};Q([`uk_acre`],{quantity:`area`,factor:4840*av**2}),Q([`us_acre`],{quantity:`area`,factor:43560*(1200/3937)**2}),Q([`ar`],yv(`area`,100)),Q([`ha`],{quantity:`area`,factor:1e4}),Q([`Morgen`],{quantity:`area`,factor:2500}),xv([`m2`,`m^2`],1,!0),xv([`ang2`,`ang^2`],1e-10,!0),xv([`ft2`,`ft^2`],iv),xv([`in2`,`in^2`],rv),xv([`ly2`,`ly^2`],cv),xv([`mi2`,`mi^2`],ov),xv([`yd2`,`yd^2`],av),xv([`Nmi2`,`Nmi^2`],sv),xv([`Pica2`,`Picapt2`,`Pica^2`,`Picapt^2`],lv),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*iv/3600}),Q([`kn`],{quantity:`speed`,factor:sv/3600}),Q([`m/h`,`m/hr`],yv(`speed`,1/3600)),Q([`m/s`,`m/sec`],yv(`speed`,1)),Q([`mph`],{quantity:`speed`,factor:ov/3600});var Sv={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},Cv={Yi:2**80,Zi:2**70,Ei:2**60,Pi:2**50,Ti:2**40,Gi:2**30,Mi:2**20,ki:1024},wv={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}},Tv={C:`C`,cel:`C`,F:`F`,fah:`F`,K:`K`,kel:`K`,Rank:`Rank`,Reau:`Reau`};function Ev(e){let t=Tv[e];if(t!==void 0)return{kind:`temperature`,scale:t,times:1};let n=vv.get(e);if(n)return{kind:`unit`,quantity:n.quantity,factor:n.factor};for(let[t,n]of Object.entries(Sv)){if(!e.startsWith(t))continue;let r=e.slice(t.length);if(Tv[r]===`K`)return{kind:`temperature`,scale:`K`,times:n};let i=vv.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(Cv)){if(!e.startsWith(t))continue;let r=vv.get(e.slice(t.length));if(r?.binary===!0)return{kind:`unit`,quantity:r.quantity,factor:r.factor*n}}}function Dv(e,t,n){let r=Ev(t),i=Ev(n);if(!r||!i)return D.NA;if(r.kind===`temperature`||i.kind===`temperature`){if(r.kind!==`temperature`||i.kind!==`temperature`)return D.NA;let t=wv[r.scale],n=wv[i.scale];return!t||!n?D.NA:n.fromK(t.toK(e*r.times))/i.times}return r.quantity===i.quantity?e*r.factor/i.factor:D.NA}P(`CONVERT`,3,3,(e,t,n)=>{let r=M(e),i=N(t),a=N(n);return r instanceof E?r:i instanceof E?i:a instanceof E?a:Dv(r,i,a)});var Ov=5e6,kv=e=>Array.from({length:e.rows},(t,n)=>Array.from({length:e.cols},(t,r)=>e.at(n,r))),Av=e=>{let t=e[0]?.length??0;return new O(e.length,t,e.flat())},jv=e=>{let t=e[0]?.length??0;return Array.from({length:t},(t,n)=>e.map(e=>e[n]??null))};function Mv(e,t){if(!(e===void 0||e instanceof A))return t.calc.scalar(e,t.frame)}function Nv(e,t,n){let r=Mv(e,t);return r==null?n:M(r)}function Pv(e,t,n){let r=Mv(e,t);return r==null?n:Dn(r)}function Fv(e,t,n){if(e===void 0||e instanceof A)return[n];let r=I(e,t);if(r instanceof E)return r;let i=[];for(let e=0;e<r.rows;e++)for(let t=0;t<r.cols;t++){let n=M(r.at(e,t));if(n instanceof E)return n;i.push(Math.trunc(n))}return i}var Iv=e=>e===null||e===``;function Lv(e,t,n){if(Iv(e)||Iv(t))return Iv(e)&&Iv(t)?0:Iv(e)?1:-1;let r=Ca(e,t);return n?-r:r}function Rv(e){return e instanceof E?e:e===null?!1:typeof e==`boolean`?e:typeof e==`number`?e!==0:D.VALUE}F(`FILTER`,`rr?r`,(e,t)=>{let n=I(e[0],t),r=I(e[1],t);if(n instanceof E)return n;if(r instanceof E)return r;if(r.rows>1&&r.cols>1)return D.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 D.VALUE;let a=kv(n),o=i?a:jv(a),s=[];for(let e=0;e<o.length;e++){let t=Rv(i?r.at(e,0):r.at(0,e));if(t instanceof E)return t;t&&s.push(o[e]??[])}return s.length===0?e[2]===void 0||e[2]instanceof A?D.CALC:e[2]:Av(i?s:jv(s))}),F(`SORT`,`r?rrr`,(e,t)=>{let n=I(e[0],t);if(n instanceof E)return n;let r=Fv(e[1],t,1);if(r instanceof E)return r;let i=Fv(e[2],t,1);if(i instanceof E)return i;let a=Pv(e[3],t,!1);if(a instanceof E)return a;let o=kv(n),s=a?jv(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 D.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=Lv(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 Av(a?jv(l):l)}),F(`SORTBY`,`r(r)`,(e,t)=>{let n=I(e[0],t);if(n instanceof E)return n;let r=[],i;for(let a=1;a<e.length;a+=2){let o=I(e[a],t);if(o instanceof E)return o;if(o.rows>1&&o.cols>1)return D.VALUE;let s=o.cols===1&&o.rows===n.rows,c=o.rows===1&&o.cols===n.cols;if(!s&&!c)return D.VALUE;let l=i??s;if(l?!s:!c)return D.VALUE;i=l;let u=Nv(e[a+1],t,1);if(u instanceof E)return u;if(u!==1&&u!==-1)return D.VALUE;r.push({values:kv(o).flat(),descending:u<0})}let a=kv(n),o=(i===!1?jv(a):a).map((e,t)=>({line:e,index:t})).sort((e,t)=>{for(let{values:n,descending:i}of r){let r=Lv(n[e.index]??null,n[t.index]??null,i);if(r!==0)return r}return e.index-t.index}).map(e=>e.line);return Av(i===!1?jv(o):o)});var zv=e=>e instanceof E?`e${e.code}`:typeof e==`string`?`s${e.toLowerCase()}`:`${typeof e}${String(e)}`;F(`UNIQUE`,`r?rr`,(e,t)=>{let n=I(e[0],t);if(n instanceof E)return n;let r=Pv(e[1],t,!1);if(r instanceof E)return r;let i=Pv(e[2],t,!1);if(i instanceof E)return i;let a=kv(n),o=(n.reference?.rows??n.rows)-n.rows,s=e=>Array(e).fill(null);if(o>0&&r&&(a.length+o)*n.cols<=Ov)for(let e=0;e<o;e++)a.push(s(n.cols));let c=r?jv(a):a,l=new Map,u=(e,t)=>{let n=e.map(zv).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?D.CALC:Av(r?jv(d):d)});function Bv(e,t){if(e instanceof E)return e;if(t instanceof E)return t;let n=Math.trunc(e),r=Math.trunc(t);return n<0||r<0?D.VALUE:n===0||r===0?D.CALC:n>1048576||r>16384||n*r>Ov?D.VALUE:{rows:n,cols:r}}F(`SEQUENCE`,`r?rrr`,(e,t)=>{let n=Bv(Nv(e[0],t,1),Nv(e[1],t,1));if(n instanceof E)return n;let r=Nv(e[2],t,1);if(r instanceof E)return r;let i=Nv(e[3],t,1);if(i instanceof E)return i;let a=Array(n.rows*n.cols);for(let e=0;e<a.length;e++)a[e]=r+e*i;return new O(n.rows,n.cols,a)}),F(`RANDARRAY`,`?rrrrr`,(e,t)=>{let n=Bv(Nv(e[0],t,1),Nv(e[1],t,1));if(n instanceof E)return n;let r=Nv(e[2],t,0);if(r instanceof E)return r;let i=Nv(e[3],t,1);if(i instanceof E)return i;let a=Pv(e[4],t,!1);if(a instanceof E)return a;if(r>i||a&&(!Number.isInteger(r)||!Number.isInteger(i)))return D.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 O(n.rows,n.cols,o)},{volatile:!0}),F(`TEXTSPLIT`,`vr?rvvv`,(e,t)=>{let n=Mv(e[0],t);if(n instanceof E)return n;let r=N(n??``);if(r instanceof E)return r;let i=Xo(e[1],t);if(i instanceof E)return i;let a=Xo(e[2],t);if(a instanceof E)return a;if(i.length===0&&a.length===0||i.includes(``)||a.includes(``))return D.VALUE;let o=Pv(e[3],t,!1);if(o instanceof E)return o;let s=Nv(e[4],t,0);if(s instanceof E)return s;let c=Mv(e[5],t)??D.NA,l=s===1,u=(a.length===0?[r]:Qo(r,a,l)).filter(e=>!(o&&e===``)).map(e=>{let t=i.length===0?[e]:Qo(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?D.CALC:Av(u.map(e=>Array.from({length:d},(t,n)=>e[n]??c)))});var Vv=(e,t)=>{let n=t.calc.flat(e);return n instanceof O?n.at(0,0):n};F(`MAP`,`r(r)`,(e,t)=>{let n=e[e.length-1];if(!(n instanceof Fe))return D.VALUE;let r=[];for(let n of e.slice(0,-1)){let e=I(n,t);if(e instanceof E)return e;r.push(e)}let i=r[0];if(!i)return D.VALUE;let{rows:a,cols:o}=i;if(r.some(e=>e.rows!==a||e.cols!==o))return D.VALUE;let s=Array(a*o);for(let e=0;e<a;e++)for(let i=0;i<o;i++)s[e*o+i]=Vv(t.calc.apply(n,r.map(t=>t.at(e,i))),t);return new O(a,o,s)});function Hv(e,t){let n=e.length===3,r=e[e.length-1];if(!(r instanceof Fe))return D.VALUE;let i=I(e[+!!n],t);return i instanceof E?i:{start:n?Mv(e[0],t)??null:i.at(0,0),cells:i,fn:r}}F(`REDUCE`,`rr?r`,(e,t)=>{let n=Hv(e,t);if(n instanceof E)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=Vv(t.calc.apply(i,[o,r.at(Math.floor(e/r.cols),e%r.cols)]),t);return o}),F(`SCAN`,`rr?r`,(e,t)=>{let n=Hv(e,t);if(n instanceof E)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=Vv(t.calc.apply(i,[c,r.at(Math.floor(e/r.cols),e%r.cols)]),t),s[e]=c;return new O(r.rows,r.cols,s)});var Uv=e=>(t,n)=>{let r=I(t[0],n);if(r instanceof E)return r;let i=t[1];if(!(i instanceof Fe))return D.VALUE;let a=kv(r),o=(e?a:jv(a)).map(t=>Vv(n.calc.apply(i,[e?new O(1,t.length,t):new O(t.length,1,t)]),n));return e?new O(o.length,1,o):new O(1,o.length,o)};F(`BYROW`,`rr`,Uv(!0)),F(`BYCOL`,`rr`,Uv(!1)),F(`MAKEARRAY`,`rrr`,(e,t)=>{let n=Bv(Nv(e[0],t,1),Nv(e[1],t,1));if(n instanceof E)return n;let r=e[2];if(!(r instanceof Fe))return D.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]=Vv(t.calc.apply(r,[e+1,a+1]),t);return new O(n.rows,n.cols,i)});function Wv(e){return(t,n)=>{let r=[];for(let i of t){let t=I(i,n);if(t instanceof E)return t;let a=kv(t);r.push(e?a:jv(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:D.NA)));return a.length===0?D.CALC:Av(e?a:jv(a))}}F(`VSTACK`,`(r)`,Wv(!0)),F(`HSTACK`,`(r)`,Wv(!1));function Gv(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 Kv(e){return(t,n)=>{let r=I(t[0],n);if(r instanceof E)return r;let i=e=>e===void 0||e instanceof A,a=Nv(t[1],n,e?r.rows:0);if(a instanceof E)return a;let o=Nv(t[2],n,e?r.cols:0);if(o instanceof E)return o;if(e&&!i(t[1])&&Math.trunc(a)===0||e&&!i(t[2])&&Math.trunc(o)===0)return D.CALC;let[s,c]=Gv(r.rows,Math.trunc(a),e),[l,u]=Gv(r.cols,Math.trunc(o),e);return c<=s||u<=l?D.CALC:Av(kv(r).slice(s,c).map(e=>e.slice(l,u)))}}F(`TAKE`,`rr?r`,Kv(!0)),F(`DROP`,`rr?r`,Kv(!1));function qv(e){return(t,n)=>{let r=I(t[0],n);if(r instanceof E)return r;let i=Nv(t[1],n,0);if(i instanceof E)return i;let a=Pv(t[2],n,!1);if(a instanceof E)return a;if(![0,1,2,3].includes(i))return D.VALUE;let o=kv(r),s=(a?jv(o):o).flat().filter(e=>!((i===1||i===3)&&e===null||(i===2||i===3)&&e instanceof E));return s.length===0?D.CALC:e?new O(s.length,1,s):new O(1,s.length,s)}}F(`TOCOL`,`r?rr`,qv(!0)),F(`TOROW`,`r?rr`,qv(!1));function Jv(e){return(t,n)=>{let r=I(t[0],n);if(r instanceof E)return r;let i=kv(r),a=e?i:jv(i),o=[];for(let e of t.slice(1)){let t=Fv(e,n,1);if(t instanceof E)return t;for(let e of t){let t=a[e>0?e-1:a.length+e];if(e===0||!t)return D.VALUE;o.push(t)}}return Av(e?o:jv(o))}}F(`CHOOSEROWS`,`r(r)`,Jv(!0)),F(`CHOOSECOLS`,`r(r)`,Jv(!1)),F(`EXPAND`,`rr?rr`,(e,t)=>{let n=I(e[0],t);if(n instanceof E)return n;let r=Bv(Nv(e[1],t,n.rows),Nv(e[2],t,n.cols));if(r instanceof E)return r;if(r.rows<n.rows||r.cols<n.cols)return D.VALUE;let i=Mv(e[3],t)??D.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 O(r.rows,r.cols,a)});function Yv(e){return(t,n)=>{let r=I(t[0],n);if(r instanceof E)return r;if(r.rows>1&&r.cols>1)return D.VALUE;let i=Nv(t[1],n,1);if(i instanceof E)return i;let a=Math.trunc(i);if(a<1)return D.NUM;let o=Mv(t[2],n)??D.NA,s=kv(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 Av(e?c:jv(c))}}F(`WRAPROWS`,`rr?r`,Yv(!0)),F(`WRAPCOLS`,`rr?r`,Yv(!1));function Xv(e,t,n){let r=N(e);if(r instanceof E)return r;let i=t==null?0:M(t);if(i instanceof E)return i;if(i!==0&&i!==1)return D.VALUE;try{return new RegExp(r,`${i===1?`i`:``}${n?`g`:``}`)}catch{return D.VALUE}}P(`REGEXTEST`,2,3,(e,t,n)=>{let r=N(e);if(r instanceof E)return r;let i=Xv(t,n,!1);return i instanceof E?i:i.test(r)}),F(`REGEXEXTRACT`,`vv?vv`,(e,t)=>{let n=N(e[0]instanceof A?null:e[0]);if(n instanceof E)return n;let r=Nv(e[2],t,0);if(r instanceof E)return r;let i=e[3]instanceof A?void 0:e[3],a=Xv(e[1],i,r===1);if(a instanceof E)return a;if(r===0)return a.exec(n)?.[0]??D.NA;if(r===1){let e=[...n.matchAll(a)].map(e=>e[0]);return e.length===0?D.NA:new O(e.length,1,e)}if(r===2){let e=a.exec(n);if(!e)return D.NA;let t=e.slice(1).map(e=>e??``);return t.length===0?D.NA:new O(1,t.length,t)}return D.VALUE}),P(`REGEXREPLACE`,3,5,(e,t,n,r,i)=>{let a=N(e),o=N(n);if(a instanceof E)return a;if(o instanceof E)return o;let s=r==null?0:M(r);if(s instanceof E)return s;let c=Xv(t,i,!0);if(c instanceof E)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)}),F(`PERCENTOF`,`rr`,(e,t)=>{let n=zn.get(`SUM`);if(!n)return D.NAME;let r=M(Vv(t.calc.applyFunction(n,[e[0]],t.frame),t)),i=M(Vv(t.calc.applyFunction(n,[e[1]],t.frame),t));return r instanceof E?r:i instanceof E?i:i===0?D.DIV0:r/i}),F(`TRIMRANGE`,`r?vv`,(e,t)=>{let n=e[0];if(!(n instanceof k))return n instanceof E?n:D.VALUE;let r=Nv(e[1],t,3),i=Nv(e[2],t,3);if(r instanceof E)return r;if(i instanceof E)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?D.REF:new k(n.sheet,n.top+c,n.left+u,n.top+l,n.left+d)});function Zv(e,t,n){let r=new Map;for(let i of n){let n=e[i]?.[t]??null,a=zv(n),o=r.get(a);o?o.records.push(i):r.set(a,{key:n,records:[i],children:[]})}return[...r.values()]}function Qv(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?Lv(e.key,n.key,r.down):0:Lv(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(zv).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?Lv(e[t.records[0]??0]?.[r.field]??null,e[n.records[0]??0]?.[r.field]??null,r.down):Lv(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(Zv(e,i+1,u.records),i+1,n),d&&!c&&s.push(o)}};r(Zv(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 $v(e,t,n,r){let i=e=>new O(e.length,1,[...e]),a=e.named===void 0?void 0:zn.get(e.named),o=(a?a.min>=2:e.params.length>=2)?[i(t),i(n)]:[i(t)];return Vv(r.calc.apply(e,o),r)}function ey(e,t,n){if(e===void 0||e instanceof A){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=Nv(e,n,0);return r instanceof E?r:[0,1,2,3].includes(r)?{has:r===1||r===3,show:r===2||r===3,named:r===2}:D.VALUE}function ty(e,t,n,r){let i=Array.from({length:t},(e,t)=>t);if(e===void 0||e instanceof A)return i;let a=I(e,r);if(a instanceof E)return a;if(a.rows*a.cols!==t+n)return D.VALUE;let o=[];for(let e of i){let t=e+n,r=Rv(a.cols===1?a.at(t,0):a.at(0,t));if(r instanceof E)return r;r&&o.push(e)}return o}function ny(e,t,n,r){let i=e===void 0||e instanceof A?[]:Fv(e,r,1);if(i instanceof E)return i;let a=[];for(let e of i){let r=Math.abs(e)-1,i=e<0;if(r<0)return D.VALUE;if(r<t)a.push({field:r,down:i});else{let e=n(r-t);if(!e)return D.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 ry=(e,t,n)=>Nv(e,t,n);F(`GROUPBY`,`rrr?vvrrv`,(e,t)=>{let n=I(e[0],t),r=I(e[1],t),i=e[2];if(n instanceof E)return n;if(r instanceof E)return r;if(!(i instanceof Fe)||n.rows!==r.rows)return D.VALUE;let a=n.cols===0?[]:kv(n),o=kv(r),s=ey(e[3],o,t);if(s instanceof E)return s;let c=+!!s.has,l=a.slice(c),u=o.slice(c),d=ry(e[4],t,1);if(d instanceof E)return d;let f=Nv(e[7],t,0);if(f instanceof E)return f;let p=ty(e[6],l.length,c,t);if(p instanceof E)return p;if(p.length===0)return D.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)=>$v(i,n.map(t=>_[e]?.[t]??null),v(e),t),y=ny(e[5],m,e=>e<h?t=>ee(e,t):void 0,t);if(y instanceof E)return y;let b=Qv(l,m,p,d,y,f===1),x=[];s.show&&x.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 b)x.push([...e.keys,...Array.from({length:h},(t,n)=>ee(n,e.records))]);return Av(x)}),F(`PIVOTBY`,`rrrr?vvrvrrv`,(e,t)=>{let n=I(e[0],t),r=I(e[1],t),i=I(e[2],t),a=e[3];if(n instanceof E)return n;if(r instanceof E)return r;if(i instanceof E)return i;if(!(a instanceof Fe)||n.rows!==i.rows||r.rows!==i.rows)return D.VALUE;let o=kv(n),s=kv(r),c=kv(i),l=ey(e[4],c,t);if(l instanceof E)return l;let u=+!!l.has,d=o.slice(u),f=s.slice(u),p=c.slice(u),m=ry(e[5],t,1),h=ry(e[7],t,1),g=Nv(e[10],t,0);if(m instanceof E)return m;if(h instanceof E)return h;if(g instanceof E)return g;let _=ty(e[9],p.length,u,t);if(_ instanceof E)return _;if(_.length===0)return D.CALC;let v=i.cols,ee=ny(e[6],n.cols,()=>void 0,t),y=ny(e[8],r.cols,()=>void 0,t);if(ee instanceof E)return ee;if(y instanceof E)return y;let b=Qv(d,n.cols,_,m,ee,!1),x=Qv(f,r.cols,_,h,y,!1),te=(e,t)=>{let n=new Set(t);return e.filter(e=>n.has(e))},ne=(e,t)=>p[t]?.[e]??null,re=(e,n,r)=>{let i=te(n.records,r.records);if(i.length===0)return null;let o=g===1?n.records:g===2?_:r.records;return $v(a,i.map(t=>ne(e,t)),o.map(t=>ne(e,t)),t)},S=n.cols,C=[];for(let e=0;e<r.cols;e++)C.push([...Array(S).fill(null),...x.flatMap(t=>Array.from({length:v},(n,r)=>r===0?t.keys[e]??null:null))]);(v>1||l.show)&&C.push([...Array.from({length:S},(e,t)=>l.show?o[0]?.[t]??null:null),...x.flatMap(()=>Array.from({length:v},(e,t)=>l.has?c[0]?.[t]??null:`Value ${String(t+1)}`))]);for(let e of b)C.push([...e.keys,...x.flatMap(t=>Array.from({length:v},(n,r)=>re(r,e,t)))]);return Av(C)});var iy=(e,t)=>me(pe(e,t+1,0)).day,ay=(e,t,n)=>n===0||n===4?Math.round(ys(e,t,n)*360):t-e;function oy(e,t,n){let r=me(e),i=r.year*12+r.month-1+t,a=Math.floor(i/12),o=i-a*12+1,s=iy(a,o);return pe(a,o,n?s:Math.min(r.day,s))}var sy=e=>{let t=me(e);return t.day===iy(t.year,t.month)};function cy(e,t,n,r){let i=12/n,a=sy(t),o=0,s=t;for(;s>e;)o+=1,s=oy(t,-i*o,a);let c=oy(t,-i*(o-1),a),l=r===1?c-s:r===3?365/n:360/n,u=ay(s,e,r);return{previous:s,next:c,count:o,period:l,since:u,until:r===0||r===4?l-u:c-e}}function ly(e,t){let n=[];for(let[r,i]of t.entries()){let t=e[r],a=t==null?i??0:M(t);if(a instanceof E)return a;n.push(a)}return n}var uy=e=>Number.isInteger(e)&&e>=0&&e<=4,dy=e=>e===1||e===2||e===4;function fy(e,t,n,r){P(e,t,n.length,(...e)=>{let t=ly(e,n);if(t instanceof E)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||!uy(l)?D.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]])fy(e,3,[$,$,$,0],(e,n,r=0,i=0)=>dy(r)?t(cy(e,n,r,i)):D.NUM);function py(e,t,n,r,i,a,o){let s=cy(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}fy(`PRICE`,6,[$,$,$,$,$,$,0],(e,t,n=0,r=0,i=0,a=0,o=0)=>n<0||r<0||i<=0||!dy(a)?D.NUM:py(e,t,n,r,i,a,o)),fy(`YIELD`,6,[$,$,$,$,$,$,0],(e,t,n=0,r=0,i=0,a=0,o=0)=>{if(n<0||r<=0||i<=0||!dy(a))return D.NUM;let s=-.99,c=1;for(;py(e,t,n,c,i,a,o)>r&&c<1e6;)c*=2;for(let l=0;l<200;l++){let l=(s+c)/2;py(e,t,n,l,i,a,o)>r?s=l:c=l}return(s+c)/2});function my(e,t,n,r,i,a){let o=cy(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}fy(`DURATION`,5,[$,$,$,$,$,0],(e,t,n=0,r=0,i=0,a=0)=>n<0||r<0||!dy(i)?D.NUM:my(e,t,n,r,i,a)),fy(`MDURATION`,5,[$,$,$,$,$,0],(e,t,n=0,r=0,i=0,a=0)=>n<0||r<0||!dy(i)?D.NUM:my(e,t,n,r,i,a)/(1+r/i)),fy(`DISC`,4,[$,$,$,$,0],(e,t,n=0,r=0,i=0)=>n<=0||r<=0?D.NUM:(r-n)/r/ys(e,t,i)),fy(`INTRATE`,4,[$,$,$,$,0],(e,t,n=0,r=0,i=0)=>n<=0||r<=0?D.NUM:(r-n)/n/ys(e,t,i)),fy(`RECEIVED`,4,[$,$,$,$,0],(e,t,n=0,r=0,i=0)=>{let a=1-r*ys(e,t,i);return n<=0||r<=0||a<=0?D.NUM:n/a}),fy(`PRICEDISC`,4,[$,$,$,$,0],(e,t,n=0,r=0,i=0)=>n<=0||r<=0?D.NUM:r*(1-n*ys(e,t,i))),fy(`YIELDDISC`,4,[$,$,$,$,0],(e,t,n=0,r=0,i=0)=>n<=0||r<=0?D.NUM:(r-n)/n/ys(e,t,i));function hy(e,t){P(e,3,3,Xn((e=0,n=0,r=0)=>{let i=Math.trunc(e),a=Math.trunc(n);return i>=a||r<=0||a>oy(i,12,!1)?D.NUM:t(a-i,r)}))}hy(`TBILLPRICE`,(e,t)=>{let n=100*(1-t*e/360);return n<=0?D.NUM:n}),hy(`TBILLYIELD`,(e,t)=>(100-t)/t*360/e),hy(`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)}),P(`ACCRINTM`,3,5,(...e)=>{let t=ly(e,[$,$,$,1e3,0]);if(t instanceof E)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||!uy(o)?D.NUM:a*i*ys(s,c,o)}),P(`ACCRINT`,6,8,(...e)=>{let t=ly(e.slice(0,7),[$,$,$,$,1e3,$,0]);if(t instanceof E)return t;let[n=0,r=0,i=0,a=0,o=0,s=0,c=0]=t,l=e[7]===void 0||Dn(e[7]);if(l instanceof E)return l;let u=Math.trunc(n),d=Math.trunc(i),f=Math.trunc(r);if(u>=d||a<=0||o<=0||!dy(s)||!uy(c))return D.NUM;let p=12/s,m=f,h=f;for(let e=1;m>u;e++)m=oy(f,-p*e,!1);let g=0;for(;m<d;){h=oy(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+=ay(e,t,c)/n),m=h}return o*a*g/s});var gy=(e,t)=>(1+e)**t,_y=e=>e===0?0:1,vy=e=>Number.isFinite(e)?e:D.NUM;function yy(e,t,n,r,i){if(e===0)return-(n+r)/t;let a=gy(e,t);return-(n*a+r)*e/((1+e*i)*(a-1))}function by(e,t,n,r,i){if(e===0)return-(r+n*t);let a=gy(e,t);return-(r*a+n*(1+e*i)*(a-1)/e)}function xy(e,t,n,r,i,a){if(t<1||t>n)return D.NUM;if(a===1&&t===1)return 0;let o=yy(e,n,r,i,a);return vy((a===1?by(e,t-2,o,r,1)-o:by(e,t-1,o,r,0))*e)}P(`PMT`,3,5,Xn((e,t,n,r=0,i=0)=>t===0?D.NUM:vy(yy(e,t,n,r,_y(i))))),P(`FV`,3,5,Xn((e,t,n,r=0,i=0)=>vy(by(e,t,n,r,_y(i))))),P(`IPMT`,4,6,Xn((e,t,n,r,i=0,a=0)=>xy(e,t,n,r,i,_y(a)))),P(`PPMT`,4,6,Xn((e,t,n,r,i=0,a=0)=>{let o=_y(a),s=xy(e,t,n,r,i,o);return s instanceof E?s:vy(yy(e,n,r,i,o)-s)})),P(`DB`,4,5,Xn((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 D.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 vy(c)})),P(`VDB`,5,7,(...e)=>{let t=ly(e.slice(0,6),[$,$,$,$,$,2]);if(t instanceof E)return t;let[n=0,r=0,i=0,a=0,o=0,s=0]=t,c=e[6]!==void 0&&Dn(e[6]);if(c instanceof E)return c;if(n<0||r<0||i<=0||a<0||o>i||a>o||s<=0)return D.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 Sy=(e,t,n,r,i)=>({whole:ys(n,t,i),accrued:ys(n,e,i),left:ys(e,t,i),rate:r});fy(`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 D.NUM;let{whole:s,accrued:c,left:l}=Sy(e,t,o,r,a);return(100+s*r*100)/(1+l*i)-c*r*100}),fy(`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 D.NUM;let{whole:s,accrued:c,left:l}=Sy(e,t,o,r,a);return((1+s*r)/(i/100+c*r)-1)/l});function Cy(e,t,n,r,i){let a=12/r,o=sy(t),s={held:0,accrued:0,left:0,count:0},c=0,l=t;for(;l>e;){c+=1;let u=oy(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?ay(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 wy(e,t,n,r,i,a,o,s,c){let l=100*i/s,u=cy(r,t,s,c).count+1,d=Cy(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 Ty(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 Ey(e,t){P(e,8,9,(...e)=>{let n=ly(e,[$,$,$,$,$,$,$,$,0]);if(n instanceof E)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!uy(d)||!dy(u)||!(p>h&&h>f&&f>m)||s<0||c<0||l<=0?D.NUM:t(e=>wy(f,p,m,h,s,e,l,u,d),c)})}Ey(`ODDFPRICE`,(e,t)=>e(t)),Ey(`ODDFYIELD`,(e,t)=>Ty(e,t,.1)??D.NUM);function Dy(e,t){P(e,7,8,(...e)=>{let n=ly(e,[$,$,$,$,$,$,$,0]);if(n instanceof E)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!uy(u)||!dy(l)||!(f>d&&d>p)||o<0||s<0||c<=0?D.NUM:t({odd:Cy(p,f,d,l,u),coupon:100*o/l,last:s,red:c,f:l})})}Dy(`ODDLPRICE`,({odd:e,coupon:t,last:n,red:r,f:i})=>(r+e.held*t)/(1+e.left*n/i)-e.accrued*t),Dy(`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}),P(`AMORLINC`,6,7,(...e)=>{let t=ly(e,[$,$,$,$,$,$,0]);if(t instanceof E)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(!uy(c)||c===2||n<0||a<0||a>n||l<0||s<=0||r>i)return D.NUM;let u=n*s,d=ys(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}),P(`AMORDEGRC`,6,7,(...e)=>{let t=ly(e,[$,$,$,$,$,$,0]);if(t instanceof E)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(!uy(c)||c===2||n<0||a<0||a>n||l<0||s<=0||r>i)return D.NUM;let u=1/s,d=s*(u<3?1:u<5?1.5:u<=6?2:2.5),f=Math.round(ys(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 Oy(e,t){let n=[];for(let t=0;t<e.cols;t++){let r=N(e.at(0,t));if(r instanceof E)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=N(t.at(0,a));if(c instanceof E)return c;let l=n.indexOf(c.toLowerCase());if(l<0){o=!1;continue}let u=sr(s);if(u instanceof E)return u;u.test(e.at(i,l))||(o=!1)}o&&(a=!0)}a&&r.push(i)}return r}function ky(e,t){if(typeof t==`number`){let n=Math.trunc(t)-1;return n<0||n>=e.cols?D.VALUE:n}let n=N(t);if(n instanceof E)return n;for(let t=0;t<e.cols;t++){let r=e.at(0,t);if(typeof r==`string`&&An(r,n)===0)return t}return D.VALUE}function Ay(e,t){let n=I(e[0],t);if(n instanceof E)return n;let r=I(e[2],t);if(r instanceof E)return r;let i=Oy(n,r);if(i instanceof E)return i;let a=e[1];if(a===void 0)return{list:i.map(()=>null),db:n};let o=ky(n,t.calc.scalar(a,t.frame));return o instanceof E?o:{list:i.map(e=>n.at(e,o)),db:n}}function jy(e,t){F(e,`rvr`,(e,n)=>{let r=Ay(e,n);if(r instanceof E)return r;let i=zn.get(t);if(i?.kind!==`raw`)return D.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`]])jy(e,t);for(let[e,t]of[[`DAVERAGE`,`AVERAGE`],[`DSTDEV`,`STDEV.S`],[`DSTDEVP`,`STDEV.P`],[`DVAR`,`VAR.S`],[`DVARP`,`VAR.P`]])F(e,`rvr`,(e,n)=>{let r=Ay(e,n);if(r instanceof E)return r;let i=zn.get(t);if(i?.kind!==`raw`)return D.VALUE;let a=r.list.filter(e=>typeof e==`number`);return a.length===0?D.DIV0:i.call(a,n)});F(`DCOUNT`,`rv?r`,(e,t)=>{let n=Ay(e.length===2?[e[0],void 0,e[1]]:e,t);return n instanceof E?n:n.list.filter(e=>typeof e==`number`).length}),F(`DCOUNTA`,`rv?r`,(e,t)=>{let n=Ay(e.length===2?[e[0],void 0,e[1]]:e,t);return n instanceof E?n:n.list.filter(e=>e!==null).length}),F(`DGET`,`rvr`,(e,t)=>{let n=Ay(e,t);return n instanceof E?n:n.list.length===0?D.VALUE:n.list.length>1?D.NUM:n.list[0]??null});function My(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(zn.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=zn.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`&&!Un(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 Ny=32,Py=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&&T(this.reference,t))for(let e of this.cells)n(e)}},Fy=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=Iy(r.group.top,r.group.bottom,r.t,r.kt,r.b,r.kb,t.top,t.bottom);if(!i)return;let a=Iy(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 j&&i.shared===r.shared&&n(i)}}};function Iy(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 Ly=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=Zt(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 Py(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(Zt(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(Zt(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>Ny){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 y=i.top-g*r.top,b=i.bottom-_*r.top,x=i.left-v*r.left,te=i.right-ee*r.left;if(f.top!==y+g*r.bottom||f.bottom!==b+_*r.bottom||f.left!==x+v*r.right||f.right!==te+ee*r.right)return!1;l.push(new Fy({shared:e,on:n,group:r,reads:i.sheet,t:y,kt:g,b,kb:_,l:x,kl:v,r:te,kr:ee}))}for(let e of l)this.list(e);return!0}};function Ry(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 zy=new Set,By=/\b(?:SUBTOTAL|AGGREGATE)\(/iu,Vy=2e3,Hy=50,Uy=1024,Wy=class extends Error{cell;constructor(e){super(`computed first`),this.cell=e}},Gy=12,Ky={max_iterations:100,max_change:.001};function qy(e,t){return typeof e==`number`&&typeof t==`number`?Math.abs(t-e):e===t||e instanceof E&&t instanceof E&&e.code===t.code?0:1/0}var Jy=(e,t)=>!e||!t?e===t:e.rows!==t.rows||e.cols!==t.cols?!1:e.data.every((e,n)=>e===t.data[n]),Yy=(e,t)=>e.row<t.row||e.row===t.row&&e.col<t.col,Xy=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 Ly({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 Ln;results=new Ln;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=()=>ge(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)??zy}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)??Ky.max_iterations,max_change:(e===!0?void 0:e.max_change)??Ky.max_change}}applyFilters(e){for(let e of this.wb.sheets){if(e.filters.every(e=>e.columns.size===0))continue;let t=go(e,this);t.size>0&&this.hiddenBy.set(e,t)}if(this.hiddenBy.size!==0&&e.some(e=>By.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 E?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($y(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 k&&n.single?n:void 0},r=e.map(e=>{let r=e.shared.node;if(r?.kind!==`call`)return D.REF;let i=eb(e),a=n(r.args[0],i);if(!a)return D.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 D.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 k&&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(D.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,qy(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>=Gy)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)Le(r,this.readersIn(e,n)),Le(r,e.blockedBy(n));for(;;){let e=r.pop();if(!e)break;n.has(e)||(n.add(e),Le(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=>T(e.area,a))||n.merges.some(e=>T(e,a))||o.some(t=>Yy(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=D.SPILL,this.moved.push({sheet:n,area:r}),this.reports&&this.settled.add(e))}analysisOf(e){return e.analysis??=My(this.wb,e)}readsOf(e){let t=[],n=eb(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 k?t.push(e):e instanceof Pe&&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 k?a.push(e):e instanceof Pe?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 k?n.push(e):e instanceof Pe&&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 j&&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 j&&n.push(i)}}}return n}computeNow(e){if(this.stack.length>0){if(this.stack.length>=Hy&&this.stack.length<Vy)throw new Wy(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 Wy))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=D.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>=Vy){e.value=D.CALC,e.state=0;return}e.state=2,this.stack.push(e),this.computed+=1;let{node:t}=e.shared,n=$y(t)?e.value:t?this.top(this.eval(t,eb(e))):D.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 O){let n=Qy(t);n.rows*n.cols<=1||this.spillOut(e,n)?(e.array=n,e.value=n.at(0,0)??0):e.value=D.SPILL}else e.value=t;this.inCycle.has(e)&&(n.clearSpill(e),e.value=D.CYCLE,e.array=void 0);let a=e.spill;Jy(i,e.array)&&Zy(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 k?e.single?this.read(e.sheet,e.top,e.left):this.matrix(e):e instanceof Pe?D.VALUE:e instanceof Fe?D.CALC:e instanceof A?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 O(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 E)?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})):D.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})):D.NAME}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 D.REF;let r=0,i=te-1,a=0,o=x-1;if(e.col){let n=this.bound(e.col,t.dc,te),a=this.bound(e.col2??e.col,t.dc,te);if(n===void 0||a===void 0)return D.REF;r=Math.min(n,a),i=Math.max(n,a)}if(e.row){let n=this.bound(e.row,t.dr,x),r=this.bound(e.row2??e.row,t.dr,x);if(n===void 0||r===void 0)return D.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 D.REF;let[s,c]=[Math.min(n.index,t.index),Math.max(n.index,t.index)];return new Pe(this.wb.sheets.slice(s,c+1).map(e=>new k(e,a,r,o,i)))}return new k(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?tb(n,e,t):e.table===void 0?D.REF:D.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 D.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 D.NAME;if(this.namesAt.has(r))return D.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 k(o.sheet,e,t,n,r)}let s=zn.get(e.toUpperCase());return s&&s.kind!==`lazy`?nb(s,e,t):D.NAME}intersect(e,t){return!(e instanceof k)||e.single?e:e.cols===1&&t.row>=e.top&&t.row<=e.bottom?new k(e.sheet,t.row,e.left,t.row,e.left):e.rows===1&&t.col>=e.left&&t.col<=e.right?new k(e.sheet,e.top,t.col,e.top,t.col):D.VALUE}unary(e,t){let n=this.flat(e);return n instanceof O?new O(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 O||i instanceof O?Fn(r instanceof O?r:new O(1,1,[r]),i instanceof O?i:new O(1,1,[i]),(t,n)=>Pn(e,t,n)):Pn(e,r,i)}rangeOf(e,t){return e instanceof E?e:t instanceof E?t:!(e instanceof k)||!(t instanceof k)||e.sheet!==t.sheet?D.REF:new k(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 E)return e;if(t instanceof E)return t;if(!(e instanceof k)||!(t instanceof k))return D.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?D.NULL:new k(e.sheet,n,r,i,a)}union(e,t){if(e instanceof E)return e;if(t instanceof E)return t;let n=e=>e instanceof k?[e]:e instanceof Pe?e.parts:[],r=[...n(e),...n(t)];return r.length===0?D.VALUE:new Pe(r)}eval(e,t){switch(e.kind){case`number`:case`string`:case`boolean`:return e.value;case`error`:return E.of(e.code);case`missing`:return Ie;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=>Pn(`*`,e,-1))}case`postfix`:{let n=this.eval(e.arg,t);if(e.op===`%`)return this.unary(n,e=>Pn(`/`,e,100));if(n instanceof k&&n.single){let e=n.sheet.at(n.top,n.left);if(e instanceof j){this.read(n.sheet,n.top,n.left);let{spill:t}=e;if(t)return new k(n.sheet,t.top,t.left,t.bottom,t.right);if(e.array)return n}}return D.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 O(e.rows.length,e.rows[0]?.length??0,e.rows.flatMap(e=>e.map(e=>{let n=this.eval(e,t);return n instanceof O||n instanceof k||n instanceof Pe||n instanceof Fe||n instanceof A?D.VALUE:n})));case`invoke`:{let n=this.eval(e.callee,t);return n instanceof Fe?this.invoke(n,e.args,t):n instanceof E?n:D.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=zn.get(e.named);return!n||n.kind===`lazy`?D.NAME:t.length<n.min||t.length>n.max?D.VALUE:this.applyFunction(n,t,e.frame)}if(t.length>e.params.length)return D.VALUE;let n=e.params.length+1;if(this.lambdaSlots+n>Uy)return D.NUM;let r=new Map;e.params.forEach((e,n)=>{r.set(e,t[n]??Ie)}),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 D.NUM}finally{this.lambdaSlots-=n}}call(e,t,n){let r=zn.get(e);if(!r){let r=this.nameValue(e,n);return r instanceof Fe?this.invoke(r,t,n):D.NAME}return t.length<r.min||t.length>r.max?D.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 D.VALUE;if(e.kind===`raw`)return Un(e.params,t.length)?this.over(t,t=>Hn(e.params,t)===`value`,t=>e.call(t,r)):D.VALUE;let i=e.errors===!0;return this.over(t,()=>!0,t=>{let n=t.map(e=>e instanceof A?void 0:e);if(!i){for(let e of n)if(e instanceof E)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 A){r.push(a);continue}let e=this.flat(a);e instanceof O&&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 D.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):D.NA});c[e*s+t]=this.element(n(a))}return new O(o,s,c)}element(e){let t=this.flat(e);return t instanceof O?t.rows>0&&t.cols>0?t.at(0,0):D.CALC:t}scalar(e,t){if(e instanceof A)return null;if(e instanceof k){let n=this.intersect(e,t);return n instanceof k?this.read(n.sheet,n.top,n.left):D.VALUE}return e instanceof O?e.at(0,0):e instanceof Pe||e instanceof Fe?D.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 j(new Jt(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 j&&t.clearSpill(e),t.replace(n,r,i),i instanceof j&&(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 j&&$y(e.shared.node)||s instanceof j&&$y(s.shared.node))&&(this.tablesOf=void 0),e instanceof j&&(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 j&&(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)Le(n,this.readers(t,r,i));for(Le(n,this.volatiles);;){let e=n.pop();if(!e)break;t.has(e)||this.inTables&&$y(e.shared.node)||(t.add(e),Le(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:gn(t.value),...t.array?{array:vn(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 j&&(e.clearSpill(n),n.value=_n(t.value),n.array=t.array?yn(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 j?[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 M(e)}},Zy=(e,t)=>e?.top===t?.top&&e?.left===t?.left&&e?.bottom===t?.bottom&&e?.right===t?.right;function Qy(e){return e.data.some(e=>e===null)?new O(e.rows,e.cols,e.data.map(e=>e??0)):e}function $y(e){return e?.kind===`call`&&e.name===`TABLE`}function eb(e){return{sheet:e.sheet,row:e.row,col:e.col,dr:e.row-e.shared.row,dc:e.col-e.shared.col}}function tb(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 D.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?D.VALUE:new k(r,n.row,a,n.row,o);let l=t.sections;if(l.includes(`#Totals`))return D.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 k(r,f,a,p,o)}function nb(e,t,n){return new Fe([],{kind:`call`,name:e.name,written:t,args:[]},n,e.name)}function rb(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 ib(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=Zt(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 j(s,n,r,a)});continue}let c=De(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 j(new Jt(c.formula,r,a,{file:``}),n,r,a)})}t.change(i)}function ab(e,t={}){let n=new Map(e.rows),r=hn({file:e.file,rows:e=>n.get(e),generated:e.generated});return e.scenario!==void 0&&Sn(r,e.scenario),{workbook:r,calc:new Xy(r,{random:Ry(e.seed),...t}).calculate()}}var ob=class{model;generation=-1;handle(e){if(e.kind===`open`)this.model=ab(e,{report:!0}),this.generation=e.generation;else{if(e.generation!==this.generation||!this.model)return;e.kind===`cells`?ib(this.model.workbook,this.model.calc,e.cells,e.file):this.model.calc.recalculate()}return{generation:this.generation,computed:this.model.calc.takeComputed()}}},sb=/\.(?:png|jpe?g|gif|webp|bmp|svg)$/iu,cb=e=>sb.test(e),lb=e=>(typeof e==`object`?e.height:void 0)??60;function ub(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 db(e,t){if(!ub(e))return[];let n=[],r=(r,i,a)=>{let o=t.value(e,r,i);if(typeof o!=`string`)return;let s=tn(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=re(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?.[ne(i)]?.files;if(a!==void 0)for(let e=t.data.top;e<=t.data.bottom;e++)r(e,i,a)}return n}var fb=e=>_(e.key)?String(e.key.value):void 0,pb=96,mb=e=>_(e)&&!(typeof e.value==`string`&&/[\n\r]/u.test(e.value)),hb=e=>mb(e)||v(e)&&e.items.every(mb),gb=new Set([``,`sheets[]`,`tables[]`,`cells`,`columns`,`rows`,`names`,`scenarios`]);function _b(e,t){if(v(e)){for(let n of e.items)_b(n,`${t}[]`);e.flow=e.items.every(mb)}else if(b(e)){for(let t of e.items)_b(t.value,fb(t)??``);e.flow=!gb.has(t)&&e.items.length>0&&e.items.every(e=>hb(e.value)||b(e.value)&&e.value.flow===!0),e.flow&&new h(e).toString({lineWidth:0,flowCollectionPadding:!0}).length>pb&&(e.flow=!1)}}var vb={lineWidth:0,flowCollectionPadding:!0};function yb(e){let t=new h(e,{aliasDuplicateObjects:!1});_b(t.contents,``);let n=t.toString(vb);return n===`{}
|
|
3
|
-
`?``:bb(n)}function bb(e){let t=y(e,{uniqueKeys:!1});if(t.errors.length>0)return e;let n=[];xb(t.contents,t=>{if(!v(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 xb(e,t){if(t(e),b(e))for(let n of e.items)xb(n.key,t),xb(n.value,t);else if(v(e))for(let n of e.items)xb(n,t)}var Sb=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function Cb(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((e,n)=>Cb(e,t[n]));if(!Sb(e)||!Sb(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&&Cb(e[n],t[n]))}function wb(e,t,n,r,i){if(!Cb(t,n)){if(b(e)&&!e.flow&&Sb(t)&&Sb(n))for(let a of new Set([...Object.keys(t),...Object.keys(n)])){let o=e.items.find(e=>fb(e)===a)?.value;Cb(t[a],n[a])||wb(o,t[a],n[a],[...r,a],i)}else if(v(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&&Cb(t[o],n[o]);)o++;let s=0;for(;s<a-o&&Cb(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++)wb(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 Tb=(e,t)=>e.lastIndexOf(`
|
|
4
|
-
`,t-1)+1,Eb=(e,t)=>{let n=e.indexOf(`
|
|
5
|
-
`,t);return n<0?e.length:n+1},Db=(e,t)=>e.split(`
|
|
6
|
-
`).map((e,n)=>n===0||e===``?e:` `.repeat(t)+e).join(`
|
|
7
|
-
`);function Ob(e,t,n,r){let i=new h({[e]:t},{aliasDuplicateObjects:!1}),a=i.contents;_b(a,``);let o=a.items[0];return(b(r)||v(r))&&(b(o?.value)||v(o?.value))&&(o.value.flow=r.flow??!1),Db(bb(i.toString(vb).replace(/\n$/,``)),n)}function kb(e,t,n){let r=new h([e],{aliasDuplicateObjects:!1}),i=r.contents;return _b(i,n),i.flow=!1,Db(bb(r.toString(vb).replace(/\n$/,``)),t)}function Ab(e,t){let n=e.contents;for(let e of t.slice(0,-1))if(b(n)){if(n.flow)return;n=n.items.find(t=>fb(t)===String(e))?.value}else if(v(n)){if(n.flow)return;n=n.items[Number(e)]}else return;return b(n)||v(n)?n:void 0}function jb(e,t){let n=t.items[0]?.range?.[0];if(n===void 0)return;let r=Tb(e,n),i=e.indexOf(`-`,r);return i>=0&&i<n?i-r:void 0}function Mb(e,t){let n=y(e);if(n.errors.length>0)return;let{path:r,value:i}=t,a=r[r.length-1],o=Ab(n,r);if(a===void 0||!o||o.flow)return;if(v(o)){let n=Number(a),s=jb(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,Tb(e,t))+e.slice(Eb(e,n-1))}if(t.insert===!0){let t=c?.range?.[0];if(t===void 0)return;let n=Tb(e,t);return`${e.slice(0,n)}${` `.repeat(s)}${kb(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)===`
|
|
8
|
-
`?l:Eb(e,l),d=u>0&&e.charAt(u-1)!==`
|
|
9
|
-
`?`
|
|
10
|
-
`:``;return`${e.slice(0,u)}${d}${` `.repeat(s)}${kb(i,s,String(r[r.length-2]??``))}\n${e.slice(u)}`}let s=String(a),c=o.items.find(e=>fb(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-Tb(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,Tb(e,t))+e.slice(Eb(e,n-1));let r=e.charAt(n-1)===`
|
|
11
|
-
`?`
|
|
12
|
-
`:``;return e.slice(0,t)+Ob(s,i,f,u)+r+e.slice(n)}if(i===void 0)return e;let p=Ob(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(`
|
|
13
|
-
`)?``:`
|
|
14
|
-
`}${` `.repeat(f)}${p}\n`;let g=e.charAt(h-1)===`
|
|
15
|
-
`?h:Eb(e,h),_=g>0&&e.charAt(g-1)!==`
|
|
16
|
-
`?`
|
|
17
|
-
`:``;return`${e.slice(0,g)}${_}${` `.repeat(f)}${p}\n${e.slice(g)}`}var Nb=400;function Pb(e,t){let n=y(e);if(n.errors.length>0||e.trim()!==``&&!b(n.contents)||e.trim()===``)return yb(t);let r=[];if(wb(n.contents,n.toJS(),t,[],r),r.length===0)return e;if(r.length>Nb)return yb(t);let i=e;for(let e of r){let n=Mb(i,e);if(n===void 0)return yb(t);i=n}let a=y(i);return a.errors.length===0&&Cb(a.toJS(),Fb(t))?i:yb(t)}var Fb=e=>JSON.parse(JSON.stringify(e)),Ib=[`bottom`,`top`,`left`,`right`,`none`,`all`,`outside`,`thickOutside`,`bottomDouble`,`thickBottom`,`topBottom`,`topThickBottom`,`topDoubleBottom`],Lb=(e,t)=>Object.fromEntries(Object.entries(e).filter(([e])=>e!==t)),Rb={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 zb(e,t,n){let r=e=>({...n,style:e});switch(e){case`bottom`:return[{area:Rb.bottom(t),sides:{bottom:n}}];case`top`:return[{area:Rb.top(t),sides:{top:n}}];case`left`:return[{area:Rb.left(t),sides:{left:n}}];case`right`:return[{area:Rb.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:Rb.top(t),sides:{top:i}},{area:Rb.bottom(t),sides:{bottom:i}},{area:Rb.left(t),sides:{left:i}},{area:Rb.right(t),sides:{right:i}}]}case`bottomDouble`:return[{area:Rb.bottom(t),sides:{bottom:r(`double`)}}];case`thickBottom`:return[{area:Rb.bottom(t),sides:{bottom:r(`thick`)}}];case`topBottom`:return[{area:Rb.top(t),sides:{top:n}},{area:Rb.bottom(t),sides:{bottom:n}}];case`topThickBottom`:return[{area:Rb.top(t),sides:{top:n}},{area:Rb.bottom(t),sides:{bottom:r(`thick`)}}];case`topDoubleBottom`:return[{area:Rb.top(t),sides:{top:n}},{area:Rb.bottom(t),sides:{bottom:r(`double`)}}];case`none`:return[]}}function Bb(e,t,n,r){let i=e.spec(t),a=C(n),o=i.format?.find(e=>e.range===a)?.border;Qi(e,t,n,{border:{...o,...r}})}function Vb(e,t,n,r,i={}){let a=e.workbook.sheet(t);if(!a)return L(`no-sheet`);let o=new R(e);if(r===`none`)return Qi(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 zb(r,n,s))Bb(o,a,e.area,e.sides);return o.finish()}function Hb(e,t,n,r){let i=e.workbook.sheet(t);if(!i)return L(`no-sheet`);let a=new R(e),o=e=>e??{style:`none`},{top:s,bottom:c,left:l,right:u,horizontal:d,vertical:f}=r;return s!==void 0&&Bb(a,i,Rb.top(n),{top:o(s)}),c!==void 0&&Bb(a,i,Rb.bottom(n),{bottom:o(c)}),l!==void 0&&Bb(a,i,Rb.left(n),{left:o(l)}),u!==void 0&&Bb(a,i,Rb.right(n),{right:o(u)}),d!==void 0&&n.bottom>n.top&&Bb(a,i,{...n,bottom:n.bottom-1},{bottom:o(d)}),f!==void 0&&n.right>n.left&&Bb(a,i,{...n,right:n.right-1},{right:o(f)}),a.finish()}function Ub(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 Wb(e,t,n,r){let i=e.workbook.sheet(t);if(!i)return L(`no-sheet`);if(i.tables.some(e=>T(e.area,n)))return L(`merge-table`);let a=new R(e),o=a.spec(i),s=(o.merges??[]).filter(e=>{let t=w(e);return!t||!T(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(C(t)),Gb(a,e,i,t));return l.length===0?bi():(o.merges=[...s,...l],r===`center`&&Qi(a,i,n,{align:`center`}),a.edit.whole=!0,a.finish())}function Gb(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=pa(t,n,s,o)),(s!==r.top||o!==r.left)&&Ii(e,t,n,s,o,``));i!==pa(t,n,r.top,r.left)&&Ii(e,t,n,r.top,r.left,i)}function Kb(e,t,n){let r=e.workbook.sheet(t);if(!r)return L(`no-sheet`);let i=new R(e),a=i.spec(r),o=(a.merges??[]).filter(e=>{let t=w(e);return!t||!T(t,n)});return o.length===0?delete a.merges:a.merges=o,i.edit.whole=!0,i.finish()}function qb(e,t,n){let r=e.workbook.sheet(t);if(!r)return L(`no-sheet`);let i=new R(e),a=i.spec(r);return n&&(n.row>0||n.col>0)?a.freeze=S(n):delete a.freeze,i.edit.whole=!0,i.finish()}function Jb(e,t,n,r,i,a){let o=e.workbook.sheet(t);if(!o)return L(`no-sheet`);let s=new R(e),c=s.spec(o),l=(e,t)=>{let n=Lb(e[t]??{},`hidden`);return a?{...e,[t]:{...n,hidden:!0}}:Object.keys(n).length===0?Lb(e,t):{...e,[t]:n}};if(n===`columns`){let e={...c.columns},t=a?Array.from({length:i-r+1},(e,t)=>ne(r+t)):Object.keys(e).filter(e=>{let t=re(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 ea(c),s.edit.whole=!0,s.finish()}function Yb(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 L(`no-sheet`);if(n&&i.length<=1)return L(`last-sheet`);let s=Lb(o,`hidden`),c=n?{...s,hidden:!0}:s;return{...bi(),file:{...e.file,sheets:r.map((e,t)=>t===a?c:e)},whole:!0}}function Xb(e,t,n){let r=e.workbook.sheet(t);if(!r)return L(`no-sheet`);let i=new R(e),a=i.spec(r);return n===void 0?delete a.tab:a.tab=n,i.finish()}function Zb(e,t,n){let r=e.workbook.sheet(t);if(!r)return L(`no-sheet`);let i=new R(e),a=i.spec(r);return n?delete a.gridlines:a.gridlines=!1,i.finish()}function Qb(e,t,n){let r=e.workbook.sheet(t);if(!r)return L(`no-sheet`);let i=new R(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?vo(r,a):n;if(!c)return L(`no-data`);let l=r.used;return s.filter={range:C({...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 $b(e,t,n,r,i){let a=e.workbook.sheet(t);if(!a)return L(`no-sheet`);let o=new R(e),{table:s}=n;if(s){let e=o.table(a,s),t=s.columns[r-s.at.col]?.name??``,n=Lb(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 L(`no-sheet`);let t=ne(r),n=Lb(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 ex(e,t){let n=e.workbook.sheet(t);if(!n)return L(`no-sheet`);let r=new R(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 tx(e,t,n){let r=e.workbook.sheet(t);if(!r)return L(`no-sheet`);let i=new R(e),a=i.spec(r);return a.conditional=[n,...a.conditional??[]],i.edit.whole=!0,i.finish()}function nx(e,t){if(!T(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 rx(e,t){let n=ae(e);if(!n)return e;let r=n.flatMap(e=>nx(e,t));return r.length===0?void 0:r.map(C).join(` `)}function ix(e,t,n){let r=e.workbook.sheet(t);if(!r)return L(`no-sheet`);let i=new R(e),a=i.spec(r),o=n?(a.conditional??[]).flatMap(e=>{let t=rx(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 ax(e,t,n,r){let i=e.workbook.sheet(t);if(!i)return L(`no-sheet`);let a=new R(e),o=a.spec(i),s=(o.validations??[]).flatMap(e=>{let t=rx(e.range,n);return t===void 0?[]:[{...e,range:t}]}),c=r?[...s,{...r,range:C(n)}]:s;return c.length===0?delete o.validations:o.validations=c,a.edit.whole=!0,a.finish()}function ox(e,t,n){let r=e.workbook.sheet(t);if(!r)return L(`no-sheet`);let i=new R(e),a=i.spec(r);return a.charts=[...a.charts??[],n],i.finish()}function sx(e,t,n,r){let i=e.workbook.sheet(t),a=i?.spec.charts?.[n];if(!i||!a)return L(`no-sheet`);let o=new R(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 cx(e,t,n){let r=e.workbook.sheet(t);if(!r)return L(`no-sheet`);let i=new R(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 lx(e,t,n,r){let i=e.workbook.sheet(t);if(!i)return L(`no-sheet`);let a=new R(e),o=a.spec(i),s=S(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 ux(e,t,n,r){let i=e.workbook.sheet(t);if(!i)return L(`no-sheet`);let a=new R(e),o=a.spec(i),s=Object.fromEntries(Object.entries(o.links??{}).filter(([e])=>{let t=w(e);return t===void 0||!T(t,n)}));if(r!==void 0&&r.trim()!==``){s[C(n)]=r.trim();let e=i.lookAt(n.top,n.left);e.color===void 0&&e.underline===void 0&&Qi(a,i,n,dx)}return Object.keys(s).length===0?delete o.links:o.links=s,ea(o),a.finish()}var dx={color:`#0563C1`,underline:!0};function fx(e,t,n){let r=e.workbook.sheet(t);if(!r)return L(`no-sheet`);let i=new R(e),a=i.spec(r);return n?a.protect=!0:delete a.protect,i.finish()}function px(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 mx(e,t,n){let r=e.workbook.sheet(t);if(!r)return L(`no-sheet`);let i=new R(e),a=i.spec(r);return n.length===0?delete a.conditional:a.conditional=[...n],i.edit.whole=!0,i.finish()}function hx(e,t,n){let r=e.workbook.sheet(t);if(!r)return L(`no-sheet`);let i=new R(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 gx=(e,t)=>e===`rows`?Number(t)-1:re(t),_x=(e,t)=>e===`rows`?String(t+1):ne(t);function vx(e,t){let n=new Map,r=(t===`rows`?e.rows:e.columns)??{};for(let[e,i]of Object.entries(r)){let r=gx(t,e);r!==void 0&&Number.isInteger(r)&&r>=0&&n.set(r,i)}return n}function yx(e,t){let n=0;for(let r of vx(e,t).values())n=Math.max(n,r.level??0);return n}function bx(e,t){let n=vx(e,t),r=[...n].filter(([,e])=>(e.level??0)>0).map(([e])=>e).sort((e,t)=>e-t),i=[],a=yx(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 xx(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 Sx(e,t,n,r,i){let a=e.workbook.sheet(t);if(!a)return L(`no-sheet`);let o=new R(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=_x(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 Cx=(e,t)=>Array.from({length:t-e+1},(t,n)=>e+n);function wx(e,t,n,r,i,a){return Sx(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}},Cx(r,i))}function Tx(e,t,n,r,i){return Sx(e,t,n,(e,t)=>({...t,hidden:!i||void 0}),Cx(r.from,r.to))}function Ex(e,t,n,r){let i=e.workbook.sheet(t);return i?Sx(e,t,n,(e,t)=>({...t,hidden:(t.level??0)>=r||void 0}),[...vx(i.spec,n)].filter(([,e])=>(e.level??0)>0).map(([e])=>e)):L(`no-sheet`)}var Dx=e=>e===null?``:typeof e==`string`?`s${e.toLowerCase()}`:e instanceof E?`e${e.code}`:`${typeof e}${String(e)}`;function Ox(e,t){let n=new Set;return e.map(e=>{let r=(t.length===0?e.map((e,t)=>t):t).map(t=>Dx(e[t]??null)).join(`\0`);return!n.has(r)&&(n.add(r),!0)})}function kx(e,t){if(t===0||!e.startsWith(`=`))return e;let n=qt(e);return n.ok?qe(Ot(n.node,t,0)):e}function Ax(e,t,n,r,i){let a=e.workbook.sheet(n);if(!a)return{...L(`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)=>pa(e,a,n,r.left+i)));let u=Ox(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:kx(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{...zi(e,n,d),duplicates:u.length-p,unique:p}}function jx(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 Mx(e,t,n,r,i){let a=e.workbook.sheet(n);if(!a)return L(`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&&jx(typeof c==`string`?c:pa(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?L(`no-data`):zi(e,n,s)}function Nx(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 Px=[[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`],[`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`,`Sunday`],[`周一`,`周二`,`周三`,`周四`,`周五`,`周六`,`周日`],[`星期一`,`星期二`,`星期三`,`星期四`,`星期五`,`星期六`,`星期日`]],Fx=[[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],[`一月`,`二月`,`三月`,`四月`,`五月`,`六月`,`七月`,`八月`,`九月`,`十月`,`十一月`,`十二月`]],Ix=[...Px,...Fx];function Lx(e){let t=e.trim().toLowerCase();for(let e of Ix){let n=e.findIndex(e=>e.toLowerCase()===t);if(n>=0)return{list:e,at:n}}}function Rx(e,t){return t===t.toUpperCase()&&t!==t.toLowerCase()?e.toUpperCase():t===t.toLowerCase()&&t!==t.toUpperCase()?e.toLowerCase():e}var zx=/^\d{4}-\d{2}-\d{2}/u;function Bx(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 Vx(e,t,n){let r=e.map(e=>_e(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(ge(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 Bx(e,t,n)}var Hx=(e,t)=>t.length>10?ye(e):ye(Math.round(e)),Ux=(e,t,n)=>`${e}${String(Math.max(n,0)).padStart(t.length,`0`)}`,Wx=/^(.*?)(\d+)$/su;function Gx(e,t,n){let r=e.map(e=>Wx.exec(e)),[i]=r;if(!i||r.some(e=>!e||e[1]!==i[1]))return;let a=i[1]??``,o=i[2]??``,s=Bx(r.map(e=>Number(e?.[2])),t,n),c=/^q$/iu.test(a);return s.map(e=>Ux(a,o,c?(Math.round(e)+399)%4+1:Math.round(e)))}function Kx(e,t,n){let r=e.map(Lx),[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(Rx(r,c))}return l}var qx=(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 Jx(e,t,n={}){let r=n.mode??`auto`,i=n.back===!0;if(r===`copy`||e.length===0)return qx(e,t,i);let a=e.map(e=>De(e).value),o=e.length===1,s=a.flatMap(e=>typeof e==`number`?[e]:[]);if(s.length===a.length){if(e.every(e=>zx.test(e)))return Vx(s,t,i).map(t=>Hx(t,e[0]??``));if(o&&r===`auto`)return qx(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):Bx(n,t,i)).map(String)}return a.every(e=>typeof e==`string`)?Kx(e,t,i)??Gx(e,t,i)??qx(e,t,i):qx(e,t,i)}var Yx=e=>De(e).formula!==void 0;function Xx(e,t,n){let r=qt(e);return r.ok?kt(r.node,t,n):void 0}var Zx=(e,t)=>!e.tables.some(e=>T(e.area,t))&&!e.blocks.some(e=>T(e.area,t));function Qx(e,t,n,r){if(e.some(e=>Yx(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?Ei(o,t.row-a.row,t.col-a.col):o}})}let i=Jx(e.map(e=>e.text),t.length,{mode:r,back:n});return t.map((e,t)=>({...e,text:i[t]??``}))}var $x=[`bold`,`italic`,`underline`,`strike`,`font`,`size`,`color`,`fill`,`align`,`valign`,`wrap`,`shrink`,`indent`,`rotation`,`border`,`locked`,`hide_formula`,`format`],eS=Object.fromEntries($x.map(e=>[e,void 0]));function tS(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 $x)i[e]=t[e];for(let t of Nx(r))Qi(e,n,t,i)}}function nS(e,t,n,r,i=`auto`){let a=e.workbook.sheet(t);if(!a)return L(`no-sheet`);let o=r.bottom>n.bottom||r.top<n.top,s=r.top<n.top||r.left<n.left,c=new R(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=pa(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);Yx(n)&&p.add(Xx(n,e,t)??``)}if(p.size===1&&f>0&&Zx(a,r)&&rS(d,n)){let e=c.spec(a);return Ui(e,r),e.cells={...e.cells,[C(r)]:Ei(d(n.top,n.left),r.top-n.top,r.left-n.left)},c.edit.whole=!0,iS(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 Qx(l,u,s,i))Ii(c,e,a,t.row,t.col,t.text)}return iS(c,a,n,r,o),c.finish()}function rS(e,t){for(let n=t.top;n<=t.bottom;n++)for(let r=t.left;r<=t.right;r++)if(!Yx(e(n,r)))return!1;return!0}function iS(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(oe(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}})}tS(e,t,t,a)}function aS(e,t,n,r){let i=e.workbook.sheet(t),a=e.workbook.sheet(n);if(!i||!a)return L(`no-sheet`);let o=new R(e);return tS(o,i,a,r),o.finish()}function oS(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 sS(e,t,n){if(!Yx(e))return e;let r=qt(e);return r.ok?qe(Ct(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 cS(e){let t=bi();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 lS(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:hn({file:n,rows:e=>r.get(e)})}}function uS(e,t,n,r,i){let a=e.workbook.sheet(t),o=e.workbook.sheet(r);if(!a||!o)return L(`no-sheet`);let s=i.row-n.top,c=i.col-n.left;if(s===0&&c===0&&a===o)return bi();let l={top:i.row,left:i.col,bottom:n.bottom+s,right:n.right+c},u=a.tables.filter(e=>oe(n,e.area.top,e.area.left)&&oe(n,e.area.bottom,e.area.right));for(let e of a.tables)if(!u.includes(e)&&T(e.area,n)&&n.top<=e.at.row)return L(`table-move`);if(u.length>0&&a!==o)return L(`table-move`);for(let e of o.tables)if(!u.includes(e)&&T(e.area,l)&&l.top<=e.at.row)return L(`table-move`);let d=ni(e,{op:`move-cells`,sheet:t,area:n,rows:s,columns:c,...a===o?{}:{to:r}}),f={...bi(),file:d.file,rows:new Map(d.rows)},p=lS(e,f),m=p.workbook.sheet(t),h=p.workbook.sheet(r);if(!m||!h)return L(`no-sheet`);let g=[],_=[],v=Math.min(n.right,m.columnsUsed-1),ee=Math.min(n.bottom,m.lastRow),y=(e,t)=>u.some(n=>oe(n.area,e,t));for(let e=n.top;e<=ee;e++)for(let i=n.left;i<=v;i++)if(!y(e,i)){if(m.at(e,i)!==void 0){let n=pa(p,m,e,i);g.push({row:e+s,col:i+c,text:a===o?n:sS(n,t,r)})}_.push({from:{row:e,col:i},to:{row:e+s,col:i+c}})}let b=Hi(p,t,n);if(b.refused!==void 0)return b;let x=lS(p,b),te=[f,b],ne=x;if(u.length>0){let e=new R(x),n=x.workbook.sheet(t);if(!n)return L(`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=S({row:t.at.row+s,col:t.at.col+c})}let r=e.finish();te.push(r),ne=lS(x,r)}let re=zi(ne,r,g);if(re.refused!==void 0)return re;te.push(re);let C=lS(ne,re),ie=C.workbook.sheet(t),w=C.workbook.sheet(r);if(ie&&w){let e=new R(C);tS(e,m,w,_);let t=_.map(e=>e.from).filter(e=>!(a===o&&oe(l,e.row,e.col))&&Object.keys(m.lookAt(e.row,e.col)).length>0);for(let n of Nx(t))Qi(e,ie,n,eS);te.push(e.finish())}return cS(te)}function dS(e,t,n,r){let i=e.workbook.sheet(t);if(!i)return L(`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:x-1}:{...n,right:te-1};if(i.tables.some(e=>T(e.area,l)))return L(`table-shift`);if(i.merges.some(e=>T(e,l)))return L(`merge-shift`);let u=ni(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 L(u.refused);let d={...bi(),file:u.file,rows:new Map(u.rows)},f=lS(e,d),p=f.workbook.sheet(t);if(!p)return L(`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=[],y=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:pa(f,p,e,t)}),ee.push({from:{row:e,col:t},to:n}),y.add(S(n))}let b=Hi(f,t,c);if(b.refused!==void 0)return b;let ne=lS(f,b),re=zi(ne,t,v);if(re.refused!==void 0)return re;let C=lS(ne,re),ie=[d,b,re],w=C.workbook.sheet(t);if(w){let e=new R(C);tS(e,p,w,ee);let t=[];for(let e=c.top;e<=g;e++)for(let n=c.left;n<=_;n++)!y.has(S({row:e,col:n}))&&Object.keys(p.lookAt(e,n)).length>0&&t.push({row:e,col:n});for(let n of Nx(t))Qi(e,w,n,eS);ie.push(e.finish())}return cS(ie)}export{vo as $,dt as $t,qb as A,Gi as At,Qb as B,j as Bt,px as C,T as Cn,ta as Ct,sx as D,ae as Dn,Li as Dt,Vb as E,w as En,na as Et,hx as F,li as Ft,cb as G,qt as Gt,Pb as H,en as Ht,fx as I,hi as It,ib as J,St as Jt,lb as K,Ot as Kt,Yb as L,pi as Lt,Jb as M,ii as Mt,ux as N,di as Nt,mx as O,_a as Ot,lx as P,ci as Pt,_o as Q,Je as Qt,Xb as R,ai as Rt,Ub as S,ne as Sn,ia as St,Hb as T,ie as Tn,ba as Tt,db as U,Zt as Ut,Kb as V,tn as Vt,ub as W,pn as Wt,ab as X,ht as Xt,rb as Y,pt as Yt,Ky as Z,_t as Zt,ox as _,Oe as _n,Wi as _t,aS as a,qe as an,Ha as at,ex as b,S as bn,ua as bt,jx as c,Ne as cn,Oa as ct,yx as d,E as dn,Hi as dt,nt as en,Qa as et,bx as f,D as fn,oa as ft,Ib as g,ge as gn,sa as gt,xx as h,De as hn,ca as ht,uS as i,ft as in,ro as it,Zb as j,zi as jt,$b as k,ga as kt,Mx as l,Me as ln,aa as lt,Ex as m,be as mn,xa as mt,nS as n,rt as nn,$a as nt,dS as o,Be as on,Xa as ot,Tx as p,ce as pn,fa as pt,ob as q,kt as qt,oS as r,it as rn,eo as rt,Ax as s,Ae as sn,Aa as st,eS as t,lt as tn,ao as tt,wx as u,je as un,da as ut,tx as v,te as vn,pa as vt,cx as w,C as wn,Zi as wt,Wb as x,re as xn,Bi as xt,ix as y,x as yn,ha as yt,ax as z,zn as zt};
|