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.
Files changed (580) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/bin/allyhub.js +10 -0
  3. package/dist/args.js +1 -1
  4. package/dist/command.js +1 -1
  5. package/dist/commands/add.js +1 -1
  6. package/dist/commands/auth.js +1 -1
  7. package/dist/commands/cloud-tools.js +1 -1
  8. package/dist/commands/cloud.js +1 -1
  9. package/dist/commands/contributed.js +1 -1
  10. package/dist/commands/found-extensions.js +2 -0
  11. package/dist/commands/frames/common.js +1 -1
  12. package/dist/commands/frames/doc.js +1 -1
  13. package/dist/commands/frames.js +9 -9
  14. package/dist/commands/index.js +1 -1
  15. package/dist/commands/inspect/common.js +3 -3
  16. package/dist/commands/inspect/index.js +1 -1
  17. package/dist/commands/inspect/layout.js +1 -1
  18. package/dist/commands/inspect/views.js +1 -1
  19. package/dist/commands/list.js +2 -0
  20. package/dist/commands/mail.js +1 -1
  21. package/dist/commands/render.js +1 -1
  22. package/dist/commands/run-context.js +2 -0
  23. package/dist/commands.json +1 -0
  24. package/dist/fields.js +1 -1
  25. package/dist/main.js +7 -7
  26. package/dist/node_modules/@allyhub/3d-extension/dist/build.js +1 -1
  27. package/dist/node_modules/@allyhub/3d-extension/dist/scenery-build.js +1 -1
  28. package/dist/node_modules/@allyhub/3d-extension/package.json +3 -2
  29. package/dist/node_modules/@allyhub/audio/package.json +1 -1
  30. package/dist/node_modules/@allyhub/browser/package.json +1 -1
  31. package/dist/node_modules/@allyhub/build/dist/build-plugins.js +1 -1
  32. package/dist/node_modules/@allyhub/build/dist/index.js +1 -1
  33. package/dist/node_modules/@allyhub/build/dist/meta-worker.js +1 -1
  34. package/dist/node_modules/@allyhub/build/dist/plugin.js +9 -9
  35. package/dist/node_modules/@allyhub/build/dist/prepare.js +3 -3
  36. package/dist/node_modules/@allyhub/build/dist/project-root.js +1 -1
  37. package/dist/node_modules/@allyhub/build/dist/scan.js +1 -1
  38. package/dist/node_modules/@allyhub/build/dist/sdk-parts.js +2 -0
  39. package/dist/node_modules/@allyhub/build/dist/vite.js +2 -2
  40. package/dist/node_modules/@allyhub/build/package.json +9 -1
  41. package/dist/node_modules/@allyhub/canvas-extension/package.json +1 -1
  42. package/dist/node_modules/@allyhub/canvas-model/package.json +1 -1
  43. package/dist/node_modules/@allyhub/chart/package.json +1 -1
  44. package/dist/node_modules/@allyhub/check/dist/check.js +2 -2
  45. package/dist/node_modules/@allyhub/check/package.json +1 -1
  46. package/dist/node_modules/@allyhub/cloud/dist/blobs.js +1 -1
  47. package/dist/node_modules/@allyhub/cloud/dist/call.js +1 -1
  48. package/dist/node_modules/@allyhub/cloud/dist/catalog.js +1 -1
  49. package/dist/node_modules/@allyhub/cloud/dist/client.js +1 -1
  50. package/dist/node_modules/@allyhub/cloud/dist/config.js +1 -1
  51. package/dist/node_modules/@allyhub/cloud/dist/credentials.js +1 -1
  52. package/dist/node_modules/@allyhub/cloud/dist/device.js +1 -1
  53. package/dist/node_modules/@allyhub/cloud/dist/errors.js +1 -1
  54. package/dist/node_modules/@allyhub/cloud/dist/index.js +1 -1
  55. package/dist/node_modules/@allyhub/cloud/dist/loopback.js +2 -2
  56. package/dist/node_modules/@allyhub/cloud/dist/mail.js +1 -1
  57. package/dist/node_modules/@allyhub/cloud/dist/records.js +1 -1
  58. package/dist/node_modules/@allyhub/cloud/dist/signin.js +2 -2
  59. package/dist/node_modules/@allyhub/cloud/dist/sites.js +1 -1
  60. package/dist/node_modules/@allyhub/cloud/dist/token.js +1 -1
  61. package/dist/node_modules/@allyhub/cloud/dist/tools.js +2 -0
  62. package/dist/node_modules/@allyhub/cloud/dist/uploads.js +1 -1
  63. package/dist/node_modules/@allyhub/cloud/dist/voice.js +1 -1
  64. package/dist/node_modules/@allyhub/cloud/package.json +5 -1
  65. package/dist/node_modules/@allyhub/components/package.json +1 -1
  66. package/dist/node_modules/@allyhub/dev-server/package.json +1 -1
  67. package/dist/node_modules/@allyhub/diagnostics/package.json +1 -1
  68. package/dist/node_modules/@allyhub/doc/package.json +1 -1
  69. package/dist/node_modules/@allyhub/doc-extension/dist/cli/find.js +1 -1
  70. package/dist/node_modules/@allyhub/doc-extension/dist/workspace.js +1 -1
  71. package/dist/node_modules/@allyhub/doc-extension/package.json +1 -1
  72. package/dist/node_modules/@allyhub/doc-print/package.json +1 -1
  73. package/dist/node_modules/@allyhub/export/package.json +1 -1
  74. package/dist/node_modules/@allyhub/extension-api/package.json +1 -1
  75. package/dist/node_modules/@allyhub/extension-host/dist/points.js +1 -1
  76. package/dist/node_modules/@allyhub/extension-host/package.json +1 -1
  77. package/dist/node_modules/@allyhub/formats/dist/items.d.ts +24 -7
  78. package/dist/node_modules/@allyhub/formats/dist/items.js +1 -1
  79. package/dist/node_modules/@allyhub/formats/dist/note-shape.d.ts +1 -1
  80. package/dist/node_modules/@allyhub/formats/package.json +25 -1
  81. package/dist/node_modules/@allyhub/html-extension/package.json +1 -1
  82. package/dist/node_modules/@allyhub/i18n/package.json +1 -1
  83. package/dist/node_modules/@allyhub/image-draw/package.json +1 -1
  84. package/dist/node_modules/@allyhub/image-extension/package.json +1 -1
  85. package/dist/node_modules/@allyhub/image-measure/package.json +1 -1
  86. package/dist/node_modules/@allyhub/image-psd/package.json +1 -1
  87. package/dist/node_modules/@allyhub/image-render/package.json +1 -1
  88. package/dist/node_modules/@allyhub/image-runtime/package.json +1 -1
  89. package/dist/node_modules/@allyhub/image-sdk/package.json +1 -1
  90. package/dist/node_modules/@allyhub/jobs/package.json +1 -1
  91. package/dist/node_modules/@allyhub/linkedin-extension/package.json +1 -1
  92. package/dist/node_modules/@allyhub/linkedin-model/package.json +1 -1
  93. package/dist/node_modules/@allyhub/linkedin-view/package.json +1 -1
  94. package/dist/node_modules/@allyhub/linkedin-view/src/style.css +1 -600
  95. package/dist/node_modules/@allyhub/measure/package.json +1 -1
  96. package/dist/node_modules/@allyhub/media/package.json +5 -1
  97. package/dist/node_modules/@allyhub/media-extension/dist/asr/hear.js +1 -1
  98. package/dist/node_modules/@allyhub/media-extension/dist/vision/track.js +1 -1
  99. package/dist/node_modules/@allyhub/media-extension/package.json +1 -1
  100. package/dist/node_modules/@allyhub/model/package.json +1 -1
  101. package/dist/node_modules/@allyhub/office-extension/package.json +1 -1
  102. package/dist/node_modules/@allyhub/ooxml/package.json +1 -1
  103. package/dist/node_modules/@allyhub/piece/dist/layer.d.ts +1 -2
  104. package/dist/node_modules/@allyhub/piece/dist/media.d.ts +1 -1
  105. package/dist/node_modules/@allyhub/piece/dist/source.d.ts +2 -2
  106. package/dist/node_modules/@allyhub/piece/dist/stage.d.ts +2 -2
  107. package/dist/node_modules/@allyhub/piece/package.json +1 -1
  108. package/dist/node_modules/@allyhub/project/package.json +1 -1
  109. package/dist/node_modules/@allyhub/protocol/dist/auth.js +1 -1
  110. package/dist/node_modules/@allyhub/protocol/dist/blobs.js +1 -1
  111. package/dist/node_modules/@allyhub/protocol/dist/cli.js +1 -1
  112. package/dist/node_modules/@allyhub/protocol/dist/cloud.js +1 -1
  113. package/dist/node_modules/@allyhub/protocol/dist/errors.js +1 -1
  114. package/dist/node_modules/@allyhub/protocol/dist/events.js +1 -1
  115. package/dist/node_modules/@allyhub/protocol/dist/index.js +1 -1
  116. package/dist/node_modules/@allyhub/protocol/dist/jsonrpc.js +1 -1
  117. package/dist/node_modules/@allyhub/protocol/dist/kinds.js +1 -1
  118. package/dist/node_modules/@allyhub/protocol/dist/mail.js +1 -1
  119. package/dist/node_modules/@allyhub/protocol/dist/notes.js +1 -1
  120. package/dist/node_modules/@allyhub/protocol/dist/paywall.js +1 -1
  121. package/dist/node_modules/@allyhub/protocol/dist/purposes.js +1 -1
  122. package/dist/node_modules/@allyhub/protocol/dist/registry.js +1 -1
  123. package/dist/node_modules/@allyhub/protocol/dist/sites.js +1 -1
  124. package/dist/node_modules/@allyhub/protocol/dist/snapshots.js +1 -1
  125. package/dist/node_modules/@allyhub/protocol/dist/teams.js +1 -1
  126. package/dist/node_modules/@allyhub/protocol/dist/tools.js +1 -1
  127. package/dist/node_modules/@allyhub/protocol/package.json +41 -1
  128. package/dist/node_modules/@allyhub/registry/package.json +1 -1
  129. package/dist/node_modules/@allyhub/render/dist/errors.js +1 -1
  130. package/dist/node_modules/@allyhub/render/dist/post-probe.js +1 -1
  131. package/dist/node_modules/@allyhub/render/package.json +9 -1
  132. package/dist/node_modules/@allyhub/runtime/package.json +1 -1
  133. package/dist/node_modules/@allyhub/runtimes/dist/bundled.js +1 -1
  134. package/dist/node_modules/@allyhub/runtimes/dist/declared.js +1 -1
  135. package/dist/node_modules/@allyhub/runtimes/dist/index.js +1 -1
  136. package/dist/node_modules/@allyhub/runtimes/dist/manifest.js +1 -1
  137. package/dist/node_modules/@allyhub/runtimes/dist/runtimes.js +1 -1
  138. package/dist/node_modules/@allyhub/runtimes/package.json +9 -1
  139. package/dist/node_modules/@allyhub/scaffold/package.json +1 -1
  140. package/dist/node_modules/@allyhub/scenery/package.json +1 -1
  141. package/dist/node_modules/@allyhub/scenery-host/dist/bundle.js +3 -3
  142. package/dist/node_modules/@allyhub/scenery-host/dist/fact.d.ts +1 -1
  143. package/dist/node_modules/@allyhub/scenery-host/dist/model-stage.js +2 -2
  144. package/dist/node_modules/@allyhub/scenery-host/package.json +1 -1
  145. package/dist/node_modules/@allyhub/sheet/dist/annotations.js +1 -1
  146. package/dist/node_modules/@allyhub/sheet/dist/api/workbook.js +1 -1
  147. package/dist/node_modules/@allyhub/sheet/dist/arrange.js +1 -1
  148. package/dist/node_modules/@allyhub/sheet/dist/calc/engine.js +1 -1
  149. package/dist/node_modules/@allyhub/sheet/dist/filter.js +1 -1
  150. package/dist/node_modules/@allyhub/sheet/dist/generated.js +1 -1
  151. package/dist/node_modules/@allyhub/sheet/dist/html.js +6 -6
  152. package/dist/node_modules/@allyhub/sheet/dist/workbook.js +1 -1
  153. package/dist/node_modules/@allyhub/sheet/package.json +1 -1
  154. package/dist/node_modules/@allyhub/sheet-extension/dist/cli/open.js +1 -1
  155. package/dist/node_modules/@allyhub/sheet-extension/dist/code.js +1 -1
  156. package/dist/node_modules/@allyhub/sheet-extension/dist/export.js +2 -2
  157. package/dist/node_modules/@allyhub/sheet-extension/package.json +1 -1
  158. package/dist/node_modules/@allyhub/slides-core/package.json +1 -1
  159. package/dist/node_modules/@allyhub/slides-extension/package.json +1 -1
  160. package/dist/node_modules/@allyhub/slides-pptx/package.json +1 -1
  161. package/dist/node_modules/@allyhub/slides-runtime/package.json +1 -1
  162. package/dist/node_modules/@allyhub/stage/package.json +1 -1
  163. package/dist/node_modules/@allyhub/stage-page/dist/fonts/arimo/400-italic.css +1 -79
  164. package/dist/node_modules/@allyhub/stage-page/dist/fonts/arimo/400.css +1 -79
  165. package/dist/node_modules/@allyhub/stage-page/dist/fonts/arimo/700-italic.css +1 -79
  166. package/dist/node_modules/@allyhub/stage-page/dist/fonts/arimo/700.css +1 -79
  167. package/dist/node_modules/@allyhub/stage-page/dist/fonts/arimo/arial.css +1 -316
  168. package/dist/node_modules/@allyhub/stage-page/dist/fonts/caladea/400-italic.css +1 -19
  169. package/dist/node_modules/@allyhub/stage-page/dist/fonts/caladea/400.css +1 -19
  170. package/dist/node_modules/@allyhub/stage-page/dist/fonts/caladea/700-italic.css +1 -19
  171. package/dist/node_modules/@allyhub/stage-page/dist/fonts/caladea/700.css +1 -19
  172. package/dist/node_modules/@allyhub/stage-page/dist/fonts/caladea/cambria.css +1 -76
  173. package/dist/node_modules/@allyhub/stage-page/dist/fonts/carlito/400-italic.css +1 -69
  174. package/dist/node_modules/@allyhub/stage-page/dist/fonts/carlito/400.css +1 -69
  175. package/dist/node_modules/@allyhub/stage-page/dist/fonts/carlito/700-italic.css +1 -69
  176. package/dist/node_modules/@allyhub/stage-page/dist/fonts/carlito/700.css +1 -69
  177. package/dist/node_modules/@allyhub/stage-page/dist/fonts/carlito/calibri.css +1 -276
  178. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/400-italic.css +1 -79
  179. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/400.css +1 -79
  180. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/700-italic.css +1 -79
  181. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/700.css +1 -79
  182. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/courier-new.css +1 -316
  183. package/dist/node_modules/@allyhub/stage-page/dist/fonts/noto-color-emoji/emoji.css +1 -8
  184. package/dist/node_modules/@allyhub/stage-page/dist/fonts/noto-sans-sc/400.css +1 -1009
  185. package/dist/node_modules/@allyhub/stage-page/dist/fonts/noto-sans-sc/700.css +1 -1009
  186. package/dist/node_modules/@allyhub/stage-page/dist/fonts/noto-sans-sc/microsoft-yahei.css +1 -2018
  187. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/400-italic.css +1 -79
  188. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/400.css +1 -79
  189. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/700-italic.css +1 -79
  190. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/700.css +1 -79
  191. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/times-new-roman.css +1 -316
  192. package/dist/node_modules/@allyhub/stage-page/package.json +1 -1
  193. package/dist/node_modules/@allyhub/stage-runtime/package.json +1 -1
  194. package/dist/node_modules/@allyhub/telemetry/dist/doc.js +1 -1
  195. package/dist/node_modules/@allyhub/telemetry/dist/errors.js +1 -1
  196. package/dist/node_modules/@allyhub/telemetry/dist/telemetry.js +2 -2
  197. package/dist/node_modules/@allyhub/telemetry/package.json +1 -1
  198. package/dist/node_modules/@allyhub/text-extension/package.json +1 -1
  199. package/dist/node_modules/@allyhub/video-core/package.json +1 -1
  200. package/dist/node_modules/@allyhub/video-extension/dist/build-plugins.js +1 -1
  201. package/dist/node_modules/@allyhub/video-extension/package.json +6 -2
  202. package/dist/node_modules/@allyhub/video-measure/dist/plans.js +2 -2
  203. package/dist/node_modules/@allyhub/video-measure/dist/reference/video.js +1 -1
  204. package/dist/node_modules/@allyhub/video-measure/package.json +5 -1
  205. package/dist/node_modules/@allyhub/video-sdk/dist/config.js +2 -0
  206. package/dist/node_modules/@allyhub/video-sdk/dist/piece.js +1 -1
  207. package/dist/node_modules/@allyhub/video-sdk/package.json +5 -1
  208. package/dist/node_modules/@allyhub/website/package.json +1 -1
  209. package/dist/node_modules/@allyhub/website-extension/dist/build.js +1 -1
  210. package/dist/node_modules/@allyhub/website-extension/package.json +4 -4
  211. package/dist/node_modules/@allyhub/x-extension/dist/build.js +1 -1
  212. package/dist/node_modules/@allyhub/x-extension/package.json +8 -2
  213. package/dist/node_modules/@allyhub/x-model/package.json +1 -1
  214. package/dist/node_modules/@allyhub/x-view/package.json +1 -1
  215. package/dist/node_modules/@allyhub/x-view/src/style.css +1 -709
  216. package/dist/package.json +14 -14
  217. package/dist/project.js +1 -1
  218. package/dist/resources.js +1 -1
  219. package/dist/sdk-docs.js +1 -1
  220. package/dist/slot.js +4 -0
  221. package/dist/telemetry.js +1 -1
  222. package/dist/version.js +1 -1
  223. package/editor-web/assets/{abnfDiagram-WEYOIA3C-Hy4-O0wN.js → abnfDiagram-WEYOIA3C-DYaMS_BB.js} +1 -1
  224. package/editor-web/assets/{architecture-WOLXFQ4H-43JEVxqz.js → architecture-WOLXFQ4H-g_Tjfl_y.js} +1 -1
  225. package/editor-web/assets/{architectureDiagram-ZHVYKT53-7bFTl41n.js → architectureDiagram-ZHVYKT53-CqdhofOL.js} +1 -1
  226. package/editor-web/assets/{article-CS48wwvk.js → article-8evPh712.js} +1 -1
  227. package/editor-web/assets/{article-Cyle57uq.js → article-BhRtWYMd.js} +1 -1
  228. package/editor-web/assets/{blockDiagram-RJAE7QA3-DcoNo1WH.js → blockDiagram-RJAE7QA3-Bc-28Bci.js} +1 -1
  229. package/editor-web/assets/{c4Diagram-XDPPPE54-CsMt61gx.js → c4Diagram-XDPPPE54-CTGJb8FB.js} +1 -1
  230. package/editor-web/assets/{calc-worker-BdHh5LXM.js → calc-worker-oEIqrrTM.js} +1 -1
  231. package/editor-web/assets/channel-wIj_OqDm.js +1 -0
  232. package/editor-web/assets/{chart-file-CfbWK9l1.js → chart-file-dGiRgFcH.js} +1 -1
  233. package/editor-web/assets/{chunk-2E7WHVMD-fj-TJIRG.js → chunk-2E7WHVMD-B2MPOVTU.js} +1 -1
  234. package/editor-web/assets/{chunk-4EMNKR2T-Du5cRy-Y.js → chunk-4EMNKR2T-BUV1ZHP0.js} +1 -1
  235. package/editor-web/assets/{chunk-55XCU76K-BHXxBBtm.js → chunk-55XCU76K-BZlpspL5.js} +1 -1
  236. package/editor-web/assets/{chunk-7S6XSTFO-R5HW6X5I.js → chunk-7S6XSTFO-CpKeisWE.js} +1 -1
  237. package/editor-web/assets/{chunk-AQDTSKZB-C98F2BUb.js → chunk-AQDTSKZB-BJqwAPyo.js} +1 -1
  238. package/editor-web/assets/{chunk-DSNLSHJZ-NIGsJ2cK.js → chunk-DSNLSHJZ-D6oPWl_W.js} +1 -1
  239. package/editor-web/assets/{chunk-HAGFOTED-BtHxtfW5.js → chunk-HAGFOTED-B5pk4MZF.js} +1 -1
  240. package/editor-web/assets/{chunk-HNE4Q36P-BI8i7Vkk.js → chunk-HNE4Q36P-DHbSPvxQ.js} +1 -1
  241. package/editor-web/assets/{chunk-NQOKRVIF-DP_Z_zEA.js → chunk-NQOKRVIF-CcL_GcRA.js} +1 -1
  242. package/editor-web/assets/{chunk-UHW7PFBP-C_8bui28.js → chunk-UHW7PFBP-YgiOL6XE.js} +1 -1
  243. package/editor-web/assets/{chunk-VQ5W62QI-CKZgzWB2.js → chunk-VQ5W62QI-p14b4UYc.js} +1 -1
  244. package/editor-web/assets/{chunk-WQQL4CDK-Ff4DgCht.js → chunk-WQQL4CDK-BWW0x-XH.js} +1 -1
  245. package/editor-web/assets/{chunk-YZO67HFG-Csbx1-pi.js → chunk-YZO67HFG-oG3qd68C.js} +1 -1
  246. package/editor-web/assets/{chunk-ZAUX2LTX-BO1kcV3w.js → chunk-ZAUX2LTX-CpcheH0u.js} +1 -1
  247. package/editor-web/assets/{chunk-ZCHMQSOR-CxeNZYZG.js → chunk-ZCHMQSOR-cWQvLl1w.js} +1 -1
  248. package/editor-web/assets/{classDiagram-v2-4MYWR3UA-D8eHQa5i.js → classDiagram-v2-4MYWR3UA-7PG7YcdU.js} +1 -1
  249. package/editor-web/assets/{cynefin-EF2NZ3EQ-lIUY3WQQ.js → cynefin-EF2NZ3EQ-CtcknEQ_.js} +1 -1
  250. package/editor-web/assets/{cynefinDiagram-WF24UDRP-CFOOhEEs.js → cynefinDiagram-WF24UDRP-Ca7VIsjN.js} +1 -1
  251. package/editor-web/assets/{dagre-NK4GIZVX-DdHVup2I.js → dagre-NK4GIZVX-BzcSLtsr.js} +1 -1
  252. package/editor-web/assets/deck-C7fN0Qtn.js +1 -0
  253. package/editor-web/assets/{diagram-CBK3MWTC-CFAD9Y2B.js → diagram-CBK3MWTC-DpRmTGlG.js} +1 -1
  254. package/editor-web/assets/{diagram-I5XIIV2D-DZJAn95A.js → diagram-I5XIIV2D-BTrs_AX8.js} +1 -1
  255. package/editor-web/assets/{diagram-ODIL2UCW-BcIeYTaY.js → diagram-ODIL2UCW-CkIVjPqH.js} +1 -1
  256. package/editor-web/assets/{diagram-PFBEJUXE-CnZmh_fl.js → diagram-PFBEJUXE-BlFMbAG1.js} +1 -1
  257. package/editor-web/assets/{diagram-RJA3I4VV-DpDd9rGx.js → diagram-RJA3I4VV-D3f8VJ-D.js} +1 -1
  258. package/editor-web/assets/{diagram-TYUNFSNR-ouGiUQcR.js → diagram-TYUNFSNR-Bbpngj6F.js} +1 -1
  259. package/editor-web/assets/{dist-DGKjn59H.js → dist-3iovns9K.js} +1 -1
  260. package/editor-web/assets/dist-BkHnbOEj.js +4 -0
  261. package/editor-web/assets/dist-BvOrNcK-.js +19 -0
  262. package/editor-web/assets/dist-CEIszq39.js +1 -0
  263. package/editor-web/assets/{dist-BI8QjOsV.js → dist-CU5RbLNH.js} +1 -1
  264. package/editor-web/assets/dist-CWZj8IAm.js +1 -0
  265. package/editor-web/assets/{dist-NQNQ5HqZ.js → dist-C_Mtrnif.js} +3 -3
  266. package/editor-web/assets/{dist-BajH5QfK.js → dist-CdqpwdCV.js} +4 -4
  267. package/editor-web/assets/{dist-SV0sOVIC.js → dist-CjT76RAw.js} +1 -1
  268. package/editor-web/assets/{dist-elglzHMT.js → dist-CpzEn9T8.js} +1 -1
  269. package/editor-web/assets/dist-CrFYWl5-.js +3 -0
  270. package/editor-web/assets/{dist-hHcrvNn9.js → dist-D4eBFGVL.js} +1 -1
  271. package/editor-web/assets/dist-DTcjb3cP.js +18 -0
  272. package/editor-web/assets/dist-D_WSM29I.js +17 -0
  273. package/editor-web/assets/{dist-Y_XZZa8q.js → dist-Dp_9ISjP.js} +10 -10
  274. package/editor-web/assets/{dist-BBshIz1Q.js → dist-J-tPYKGS.js} +4 -4
  275. package/editor-web/assets/{docx-draw-C4aiB8HI.js → docx-draw-CoK1oqQD.js} +1 -1
  276. package/editor-web/assets/{ebnfDiagram-V4P3TTPT-HRjVlbUf.js → ebnfDiagram-V4P3TTPT-BaKj-yL6.js} +1 -1
  277. package/editor-web/assets/{elk-QONTBCTQ-BFmtKyOf.js → elk-QONTBCTQ-Cn2qv1_U.js} +1 -1
  278. package/editor-web/assets/{erDiagram-KYQIGQAA-C9gcGEgK.js → erDiagram-KYQIGQAA-Bd7AEIDo.js} +1 -1
  279. package/editor-web/assets/{esm-DzxAod8Q.js → esm-Cjv8ogpP.js} +1 -1
  280. package/editor-web/assets/{eventmodeling-K75KTNOO-Bpma5Bdb.js → eventmodeling-K75KTNOO-Sfp7_461.js} +1 -1
  281. package/editor-web/assets/flowDiagram-IUGLLWBU-BlVUglzw.js +1 -0
  282. package/editor-web/assets/{ganttDiagram-R7GPNTJY-CE5ut4C3.js → ganttDiagram-R7GPNTJY-CBqcGdHI.js} +1 -1
  283. package/editor-web/assets/{gitGraph-VSP46ZUC-Dva3iGx2.js → gitGraph-VSP46ZUC-WTokXKTW.js} +1 -1
  284. package/editor-web/assets/{gitGraphDiagram-PDYL7XHY-CJXFsAWp.js → gitGraphDiagram-PDYL7XHY-BIWZHD9q.js} +1 -1
  285. package/editor-web/assets/index-BQWZnyAQ.js +28 -0
  286. package/editor-web/assets/{info-OHQRW6UA-BY0AOfex.js → info-OHQRW6UA-COC6G-_J.js} +1 -1
  287. package/editor-web/assets/{infoDiagram-MVDRKAX5-4Up1gMvC.js → infoDiagram-MVDRKAX5-DpaqdKBD.js} +1 -1
  288. package/editor-web/assets/{ishikawaDiagram-HPEHV2GE-BkvB9Qbn.js → ishikawaDiagram-HPEHV2GE-Dyn2MAy1.js} +1 -1
  289. package/editor-web/assets/{iso-ahTwmFwH.js → iso-DoC-ZoBr.js} +1 -1
  290. package/editor-web/assets/{journeyDiagram-BOSHW7O7-BxV09WdR.js → journeyDiagram-BOSHW7O7-DeSVfmm7.js} +1 -1
  291. package/editor-web/assets/{kanban-definition-FNSA4HC5-zTJtIDPG.js → kanban-definition-FNSA4HC5-Bfg0lj7B.js} +1 -1
  292. package/editor-web/assets/{mermaid-parser.core-BWT9UQh_.js → mermaid-parser.core-CyhovuYE.js} +3 -3
  293. package/editor-web/assets/{mermaid.core-DFf_Vg5X.js → mermaid.core-Dx1fBVUG.js} +4 -4
  294. package/editor-web/assets/{mindmap-definition-6OY57UG3-BYexiugS.js → mindmap-definition-6OY57UG3-QEU2HF_m.js} +1 -1
  295. package/editor-web/assets/{packet-JDAUHWVQ-DX_kSrI6.js → packet-JDAUHWVQ-ReJTa_hw.js} +1 -1
  296. package/editor-web/assets/{pegDiagram-ECIUJNBX-I3SrcMLp.js → pegDiagram-ECIUJNBX-Bo1jFrvb.js} +1 -1
  297. package/editor-web/assets/{pie-XZMESJXO-BmAFSw3E.js → pie-XZMESJXO-BrtYafNA.js} +1 -1
  298. package/editor-web/assets/{pieDiagram-GNMPY74T-DIZKcme5.js → pieDiagram-GNMPY74T-Cj0zQqs_.js} +1 -1
  299. package/editor-web/assets/{props-form-DUFxM5eb.js → props-form-BpSXbrSF.js} +1 -1
  300. package/editor-web/assets/{quadrantDiagram-D57K4MC3-CO3oSqpQ.js → quadrantDiagram-D57K4MC3-D5npDAVn.js} +1 -1
  301. package/editor-web/assets/{radar-ABXABTNO-D5CkFrrb.js → radar-ABXABTNO-C8RDrRqi.js} +1 -1
  302. package/editor-web/assets/{railroad-I3PHUGI6-BeKY1p0K.js → railroad-I3PHUGI6-ebDrmYTK.js} +1 -1
  303. package/editor-web/assets/{railroad-abnf-LNEFI6M7-CIYV9_3-.js → railroad-abnf-LNEFI6M7-BxKuqg6V.js} +1 -1
  304. package/editor-web/assets/{railroad-ebnf-DWYD2UWJ-DN0zDl6d.js → railroad-ebnf-DWYD2UWJ-DOclnfpr.js} +1 -1
  305. package/editor-web/assets/{railroad-peg-JR7BVNR7-Bd_GcO24.js → railroad-peg-JR7BVNR7-DN0A1fpq.js} +1 -1
  306. package/editor-web/assets/{railroadDiagram-Y72NRBL7-DlFoiMhb.js → railroadDiagram-Y72NRBL7-B3PjoVWw.js} +1 -1
  307. package/editor-web/assets/{requirementDiagram-EQYSW5RA-LWAEz8Gy.js → requirementDiagram-EQYSW5RA-DLdzkQk5.js} +1 -1
  308. package/editor-web/assets/{sankeyDiagram-SY24JHO5-B_pZGwUK.js → sankeyDiagram-SY24JHO5-Dip4Piv_.js} +1 -1
  309. package/editor-web/assets/schemas-CQ_UU8-Z.js +1 -0
  310. package/editor-web/assets/{sequenceDiagram-BLEHNHQU-bNhyCq0C.js → sequenceDiagram-BLEHNHQU-QnPcoybL.js} +1 -1
  311. package/editor-web/assets/{session-Beijw9EK.js → session-DMlLCFWg.js} +1 -1
  312. package/editor-web/assets/slides-7xWhREpt.js +1 -0
  313. package/editor-web/assets/snapshots-BLX4NTQC.js +1 -0
  314. package/editor-web/assets/{split-zARio3J8.js → split-tFGKk-x8.js} +1 -1
  315. package/editor-web/assets/{stateDiagram-v2-A6IESKWZ-DI-oM3qz.js → stateDiagram-v2-A6IESKWZ-D103CiMX.js} +1 -1
  316. package/editor-web/assets/{swimlanes-B3ENRKFQ-awDmoLdW.js → swimlanes-B3ENRKFQ-y4gCqEoa.js} +1 -1
  317. package/editor-web/assets/swimlanesDiagram-AYQRV4AK-DKzB_wSf.js +8 -0
  318. package/editor-web/assets/{tabs-BHBvbekZ.js → tabs-CuEawka3.js} +1 -1
  319. package/editor-web/assets/{timeline-definition-JXYKGLGB-CayduPvL.js → timeline-definition-JXYKGLGB-BMp76v4V.js} +1 -1
  320. package/editor-web/assets/{treeView-D4JQ5SDB-BVEuNzCO.js → treeView-D4JQ5SDB-Q_GYyk0b.js} +1 -1
  321. package/editor-web/assets/{treemap-SAJKECNS-BOB14HP3.js → treemap-SAJKECNS-B5lRWdQB.js} +1 -1
  322. package/editor-web/assets/{usecaseDiagram-WPOLBNNX-DxT99uaq.js → usecaseDiagram-WPOLBNNX--QRllA-U.js} +1 -1
  323. package/editor-web/assets/{vennDiagram-Q3Y3IDCW-CWUKom-r.js → vennDiagram-Q3Y3IDCW-CzkATPA3.js} +1 -1
  324. package/editor-web/assets/{video-oJ3qa1Qv.js → video-D0uTbHWx.js} +1 -1
  325. package/editor-web/assets/{wardley-7MLQ67FV-BAQyTneD.js → wardley-7MLQ67FV-BXzwcdJa.js} +1 -1
  326. package/editor-web/assets/{wardleyDiagram-IVAIDKWA-CiIYz4lZ.js → wardleyDiagram-IVAIDKWA-BQvC8Agx.js} +1 -1
  327. package/editor-web/assets/{words-0Ww2RyT4.js → words-CaUHhQHf.js} +1 -1
  328. package/editor-web/assets/workbook-CiCXkjmN.js +45 -0
  329. package/editor-web/assets/{xychartDiagram-4URNHDU4-D_D5IGmd.js → xychartDiagram-4URNHDU4-aY-lsD5o.js} +1 -1
  330. package/editor-web/index.html +3 -3
  331. package/package.json +2 -2
  332. package/dist/node_modules/@allyhub/browser/dist/browser.d.ts +0 -24
  333. package/dist/node_modules/@allyhub/browser/dist/capture.d.ts +0 -61
  334. package/dist/node_modules/@allyhub/browser/dist/cdp.d.ts +0 -51
  335. package/dist/node_modules/@allyhub/browser/dist/emoji.d.ts +0 -29
  336. package/dist/node_modules/@allyhub/browser/dist/flags.d.ts +0 -13
  337. package/dist/node_modules/@allyhub/browser/dist/frames.d.ts +0 -35
  338. package/dist/node_modules/@allyhub/browser/dist/html.d.ts +0 -19
  339. package/dist/node_modules/@allyhub/browser/dist/index.d.ts +0 -10
  340. package/dist/node_modules/@allyhub/browser/dist/launch.d.ts +0 -35
  341. package/dist/node_modules/@allyhub/browser/dist/page.d.ts +0 -74
  342. package/dist/node_modules/@allyhub/browser/dist/picture.d.ts +0 -18
  343. package/dist/node_modules/@allyhub/browser/dist/server.d.ts +0 -26
  344. package/dist/node_modules/@allyhub/build/dist/build-plugins.d.ts +0 -91
  345. package/dist/node_modules/@allyhub/build/dist/cli-command.d.ts +0 -84
  346. package/dist/node_modules/@allyhub/build/dist/code.d.ts +0 -26
  347. package/dist/node_modules/@allyhub/build/dist/content.d.ts +0 -64
  348. package/dist/node_modules/@allyhub/build/dist/data.d.ts +0 -11
  349. package/dist/node_modules/@allyhub/build/dist/evaluate.d.ts +0 -44
  350. package/dist/node_modules/@allyhub/build/dist/file-check.d.ts +0 -35
  351. package/dist/node_modules/@allyhub/build/dist/files.d.ts +0 -4
  352. package/dist/node_modules/@allyhub/build/dist/fonts.d.ts +0 -26
  353. package/dist/node_modules/@allyhub/build/dist/generated.d.ts +0 -29
  354. package/dist/node_modules/@allyhub/build/dist/imports.d.ts +0 -17
  355. package/dist/node_modules/@allyhub/build/dist/index.d.ts +0 -37
  356. package/dist/node_modules/@allyhub/build/dist/inspect-view.d.ts +0 -119
  357. package/dist/node_modules/@allyhub/build/dist/kind-build.d.ts +0 -530
  358. package/dist/node_modules/@allyhub/build/dist/made-notes.d.ts +0 -9
  359. package/dist/node_modules/@allyhub/build/dist/matrix.d.ts +0 -19
  360. package/dist/node_modules/@allyhub/build/dist/media.d.ts +0 -10
  361. package/dist/node_modules/@allyhub/build/dist/messages.d.ts +0 -60
  362. package/dist/node_modules/@allyhub/build/dist/meta-worker.d.ts +0 -59
  363. package/dist/node_modules/@allyhub/build/dist/meta.d.ts +0 -24
  364. package/dist/node_modules/@allyhub/build/dist/model-info.d.ts +0 -6
  365. package/dist/node_modules/@allyhub/build/dist/move-refs.d.ts +0 -16
  366. package/dist/node_modules/@allyhub/build/dist/places.d.ts +0 -23
  367. package/dist/node_modules/@allyhub/build/dist/plugin.d.ts +0 -50
  368. package/dist/node_modules/@allyhub/build/dist/prepare.d.ts +0 -138
  369. package/dist/node_modules/@allyhub/build/dist/project-root.d.ts +0 -19
  370. package/dist/node_modules/@allyhub/build/dist/project-tool.d.ts +0 -136
  371. package/dist/node_modules/@allyhub/build/dist/references.d.ts +0 -6
  372. package/dist/node_modules/@allyhub/build/dist/scan.d.ts +0 -45
  373. package/dist/node_modules/@allyhub/build/dist/stage-route.d.ts +0 -80
  374. package/dist/node_modules/@allyhub/build/dist/takes.d.ts +0 -9
  375. package/dist/node_modules/@allyhub/build/dist/types.d.ts +0 -11
  376. package/dist/node_modules/@allyhub/build/dist/uses.d.ts +0 -44
  377. package/dist/node_modules/@allyhub/build/dist/version.d.ts +0 -56
  378. package/dist/node_modules/@allyhub/build/dist/vite.d.ts +0 -115
  379. package/dist/node_modules/@allyhub/build/dist/work.d.ts +0 -38
  380. package/dist/node_modules/@allyhub/cloud/dist/blobs.d.ts +0 -48
  381. package/dist/node_modules/@allyhub/cloud/dist/call.d.ts +0 -91
  382. package/dist/node_modules/@allyhub/cloud/dist/catalog.d.ts +0 -12
  383. package/dist/node_modules/@allyhub/cloud/dist/client.d.ts +0 -64
  384. package/dist/node_modules/@allyhub/cloud/dist/config.d.ts +0 -40
  385. package/dist/node_modules/@allyhub/cloud/dist/credentials.d.ts +0 -76
  386. package/dist/node_modules/@allyhub/cloud/dist/device.d.ts +0 -14
  387. package/dist/node_modules/@allyhub/cloud/dist/errors.d.ts +0 -24
  388. package/dist/node_modules/@allyhub/cloud/dist/hashes.d.ts +0 -43
  389. package/dist/node_modules/@allyhub/cloud/dist/index.d.ts +0 -19
  390. package/dist/node_modules/@allyhub/cloud/dist/keychain.d.ts +0 -18
  391. package/dist/node_modules/@allyhub/cloud/dist/loopback.d.ts +0 -22
  392. package/dist/node_modules/@allyhub/cloud/dist/mail.d.ts +0 -16
  393. package/dist/node_modules/@allyhub/cloud/dist/pkce.d.ts +0 -11
  394. package/dist/node_modules/@allyhub/cloud/dist/records.d.ts +0 -42
  395. package/dist/node_modules/@allyhub/cloud/dist/signin-worker.d.ts +0 -2
  396. package/dist/node_modules/@allyhub/cloud/dist/signin.d.ts +0 -48
  397. package/dist/node_modules/@allyhub/cloud/dist/sites.d.ts +0 -20
  398. package/dist/node_modules/@allyhub/cloud/dist/token.d.ts +0 -20
  399. package/dist/node_modules/@allyhub/cloud/dist/uploads.d.ts +0 -58
  400. package/dist/node_modules/@allyhub/cloud/dist/voice.d.ts +0 -22
  401. package/dist/node_modules/@allyhub/jobs/dist/index.d.ts +0 -3
  402. package/dist/node_modules/@allyhub/jobs/dist/jobs.d.ts +0 -139
  403. package/dist/node_modules/@allyhub/jobs/dist/show.d.ts +0 -41
  404. package/dist/node_modules/@allyhub/measure/dist/compare.d.ts +0 -195
  405. package/dist/node_modules/@allyhub/measure/dist/grain.d.ts +0 -8
  406. package/dist/node_modules/@allyhub/measure/dist/image.d.ts +0 -16
  407. package/dist/node_modules/@allyhub/measure/dist/index.d.ts +0 -4
  408. package/dist/node_modules/@allyhub/media/dist/analysis.d.ts +0 -25
  409. package/dist/node_modules/@allyhub/media/dist/audio.d.ts +0 -16
  410. package/dist/node_modules/@allyhub/media/dist/beats.d.ts +0 -100
  411. package/dist/node_modules/@allyhub/media/dist/cache.d.ts +0 -26
  412. package/dist/node_modules/@allyhub/media/dist/errors.d.ts +0 -34
  413. package/dist/node_modules/@allyhub/media/dist/fetch.d.ts +0 -11
  414. package/dist/node_modules/@allyhub/media/dist/grid.d.ts +0 -101
  415. package/dist/node_modules/@allyhub/media/dist/index.d.ts +0 -21
  416. package/dist/node_modules/@allyhub/media/dist/picture.d.ts +0 -130
  417. package/dist/node_modules/@allyhub/media/dist/probe.d.ts +0 -52
  418. package/dist/node_modules/@allyhub/media/dist/progress.d.ts +0 -16
  419. package/dist/node_modules/@allyhub/media/dist/run.d.ts +0 -25
  420. package/dist/node_modules/@allyhub/media/dist/sheet.d.ts +0 -67
  421. package/dist/node_modules/@allyhub/media/dist/shots.d.ts +0 -110
  422. package/dist/node_modules/@allyhub/media/dist/sync.d.ts +0 -156
  423. package/dist/node_modules/@allyhub/media/dist/tools.d.ts +0 -25
  424. package/dist/node_modules/@allyhub/media/dist/video.d.ts +0 -35
  425. package/dist/node_modules/@allyhub/media/dist/vision/cache.d.ts +0 -42
  426. package/dist/node_modules/@allyhub/media/dist/vision/probe.d.ts +0 -39
  427. package/dist/node_modules/@allyhub/media/dist/vision/types.d.ts +0 -2
  428. package/dist/node_modules/@allyhub/media/dist/voice-shape.d.ts +0 -51
  429. package/dist/node_modules/@allyhub/model/dist/authoring.d.ts +0 -48
  430. package/dist/node_modules/@allyhub/model/dist/bevel-attributes.d.ts +0 -19
  431. package/dist/node_modules/@allyhub/model/dist/bevel-collapse.d.ts +0 -12
  432. package/dist/node_modules/@allyhub/model/dist/bevel-corner-plan.d.ts +0 -24
  433. package/dist/node_modules/@allyhub/model/dist/bevel-deform.d.ts +0 -5
  434. package/dist/node_modules/@allyhub/model/dist/bevel-fans.d.ts +0 -12
  435. package/dist/node_modules/@allyhub/model/dist/bevel-junction.d.ts +0 -16
  436. package/dist/node_modules/@allyhub/model/dist/bevel-marks.d.ts +0 -14
  437. package/dist/node_modules/@allyhub/model/dist/bevel-metric.d.ts +0 -4
  438. package/dist/node_modules/@allyhub/model/dist/bevel-mixed.d.ts +0 -12
  439. package/dist/node_modules/@allyhub/model/dist/bevel-offsets.d.ts +0 -22
  440. package/dist/node_modules/@allyhub/model/dist/bevel-patch.d.ts +0 -45
  441. package/dist/node_modules/@allyhub/model/dist/bevel-profile.d.ts +0 -13
  442. package/dist/node_modules/@allyhub/model/dist/bevel-projection.d.ts +0 -10
  443. package/dist/node_modules/@allyhub/model/dist/bevel-reflex.d.ts +0 -10
  444. package/dist/node_modules/@allyhub/model/dist/bevel-square-out.d.ts +0 -18
  445. package/dist/node_modules/@allyhub/model/dist/bevel-strips.d.ts +0 -8
  446. package/dist/node_modules/@allyhub/model/dist/bmesh-cycles.d.ts +0 -52
  447. package/dist/node_modules/@allyhub/model/dist/build-cache.d.ts +0 -42
  448. package/dist/node_modules/@allyhub/model/dist/build-job.d.ts +0 -34
  449. package/dist/node_modules/@allyhub/model/dist/build-worker.d.ts +0 -2
  450. package/dist/node_modules/@allyhub/model/dist/build.d.ts +0 -67
  451. package/dist/node_modules/@allyhub/model/dist/cancel.d.ts +0 -8
  452. package/dist/node_modules/@allyhub/model/dist/curve-math.d.ts +0 -21
  453. package/dist/node_modules/@allyhub/model/dist/curve-mesh.d.ts +0 -30
  454. package/dist/node_modules/@allyhub/model/dist/evaluation-guard.d.ts +0 -11
  455. package/dist/node_modules/@allyhub/model/dist/export.d.ts +0 -12
  456. package/dist/node_modules/@allyhub/model/dist/mesh-queries.d.ts +0 -34
  457. package/dist/node_modules/@allyhub/model/dist/names.d.ts +0 -9
  458. package/dist/node_modules/@allyhub/model/dist/png.d.ts +0 -12
  459. package/dist/node_modules/@allyhub/model/dist/polygon-triangulation.d.ts +0 -4
  460. package/dist/node_modules/@allyhub/model/dist/program-location.d.ts +0 -7
  461. package/dist/node_modules/@allyhub/model/dist/report.d.ts +0 -70
  462. package/dist/node_modules/@allyhub/piece/dist/page/console.d.ts +0 -21
  463. package/dist/node_modules/@allyhub/piece/dist/page/index.d.ts +0 -4
  464. package/dist/node_modules/@allyhub/piece/dist/page/locate.d.ts +0 -17
  465. package/dist/node_modules/@allyhub/piece/dist/page/runtimes.d.ts +0 -9
  466. package/dist/node_modules/@allyhub/protocol/dist/account.d.ts +0 -661
  467. package/dist/node_modules/@allyhub/protocol/dist/account.js +0 -2
  468. package/dist/node_modules/@allyhub/protocol/dist/app.d.ts +0 -30
  469. package/dist/node_modules/@allyhub/protocol/dist/auth.d.ts +0 -200
  470. package/dist/node_modules/@allyhub/protocol/dist/blobs.d.ts +0 -44
  471. package/dist/node_modules/@allyhub/protocol/dist/cli.d.ts +0 -68
  472. package/dist/node_modules/@allyhub/protocol/dist/cloud-computer.d.ts +0 -77
  473. package/dist/node_modules/@allyhub/protocol/dist/cloud-computer.js +0 -2
  474. package/dist/node_modules/@allyhub/protocol/dist/cloud.d.ts +0 -577
  475. package/dist/node_modules/@allyhub/protocol/dist/editor.d.ts +0 -674
  476. package/dist/node_modules/@allyhub/protocol/dist/errors.d.ts +0 -7
  477. package/dist/node_modules/@allyhub/protocol/dist/events.d.ts +0 -803
  478. package/dist/node_modules/@allyhub/protocol/dist/files.d.ts +0 -103
  479. package/dist/node_modules/@allyhub/protocol/dist/frame.d.ts +0 -247
  480. package/dist/node_modules/@allyhub/protocol/dist/image.d.ts +0 -8
  481. package/dist/node_modules/@allyhub/protocol/dist/index.d.ts +0 -38
  482. package/dist/node_modules/@allyhub/protocol/dist/jobs.d.ts +0 -91
  483. package/dist/node_modules/@allyhub/protocol/dist/jsonrpc.d.ts +0 -83
  484. package/dist/node_modules/@allyhub/protocol/dist/kinds.d.ts +0 -144
  485. package/dist/node_modules/@allyhub/protocol/dist/mail.d.ts +0 -274
  486. package/dist/node_modules/@allyhub/protocol/dist/notes.d.ts +0 -211
  487. package/dist/node_modules/@allyhub/protocol/dist/open.d.ts +0 -13
  488. package/dist/node_modules/@allyhub/protocol/dist/paywall.d.ts +0 -134
  489. package/dist/node_modules/@allyhub/protocol/dist/peer.d.ts +0 -59
  490. package/dist/node_modules/@allyhub/protocol/dist/peer.js +0 -2
  491. package/dist/node_modules/@allyhub/protocol/dist/place.d.ts +0 -21
  492. package/dist/node_modules/@allyhub/protocol/dist/presence.d.ts +0 -125
  493. package/dist/node_modules/@allyhub/protocol/dist/purposes.d.ts +0 -47
  494. package/dist/node_modules/@allyhub/protocol/dist/registry.d.ts +0 -191
  495. package/dist/node_modules/@allyhub/protocol/dist/routes.d.ts +0 -14
  496. package/dist/node_modules/@allyhub/protocol/dist/routes.js +0 -2
  497. package/dist/node_modules/@allyhub/protocol/dist/runtimes.d.ts +0 -96
  498. package/dist/node_modules/@allyhub/protocol/dist/shape.d.ts +0 -35
  499. package/dist/node_modules/@allyhub/protocol/dist/shape.js +0 -2
  500. package/dist/node_modules/@allyhub/protocol/dist/shares.d.ts +0 -156
  501. package/dist/node_modules/@allyhub/protocol/dist/shares.js +0 -2
  502. package/dist/node_modules/@allyhub/protocol/dist/sidebar-deletion.d.ts +0 -34
  503. package/dist/node_modules/@allyhub/protocol/dist/sidebar-deletion.js +0 -2
  504. package/dist/node_modules/@allyhub/protocol/dist/sites.d.ts +0 -298
  505. package/dist/node_modules/@allyhub/protocol/dist/snapshots.d.ts +0 -503
  506. package/dist/node_modules/@allyhub/protocol/dist/sources.d.ts +0 -14
  507. package/dist/node_modules/@allyhub/protocol/dist/studio-server.d.ts +0 -264
  508. package/dist/node_modules/@allyhub/protocol/dist/studio-server.js +0 -2
  509. package/dist/node_modules/@allyhub/protocol/dist/studio-tool-calls.d.ts +0 -18
  510. package/dist/node_modules/@allyhub/protocol/dist/studio-tool-calls.js +0 -2
  511. package/dist/node_modules/@allyhub/protocol/dist/studio-window-requests.d.ts +0 -97
  512. package/dist/node_modules/@allyhub/protocol/dist/studio-window-requests.js +0 -2
  513. package/dist/node_modules/@allyhub/protocol/dist/teams.d.ts +0 -196
  514. package/dist/node_modules/@allyhub/protocol/dist/tools.d.ts +0 -578
  515. package/dist/node_modules/@allyhub/protocol/dist/turns.d.ts +0 -71
  516. package/dist/node_modules/@allyhub/protocol/dist/turns.js +0 -2
  517. package/dist/node_modules/@allyhub/runtimes/dist/bundled.d.ts +0 -10
  518. package/dist/node_modules/@allyhub/runtimes/dist/declared.d.ts +0 -14
  519. package/dist/node_modules/@allyhub/runtimes/dist/download.d.ts +0 -38
  520. package/dist/node_modules/@allyhub/runtimes/dist/errors.d.ts +0 -20
  521. package/dist/node_modules/@allyhub/runtimes/dist/ffmpeg.d.ts +0 -15
  522. package/dist/node_modules/@allyhub/runtimes/dist/home.d.ts +0 -2
  523. package/dist/node_modules/@allyhub/runtimes/dist/index.d.ts +0 -12
  524. package/dist/node_modules/@allyhub/runtimes/dist/lock.d.ts +0 -14
  525. package/dist/node_modules/@allyhub/runtimes/dist/manifest.d.ts +0 -3
  526. package/dist/node_modules/@allyhub/runtimes/dist/node-program.d.ts +0 -12
  527. package/dist/node_modules/@allyhub/runtimes/dist/packages.d.ts +0 -101
  528. package/dist/node_modules/@allyhub/runtimes/dist/runtimes.d.ts +0 -73
  529. package/dist/node_modules/@allyhub/runtimes/dist/unpack.d.ts +0 -14
  530. package/dist/node_modules/@allyhub/scenery-host/dist/allyhub.d.ts +0 -20
  531. package/dist/node_modules/@allyhub/scenery-host/dist/bake/digest.d.ts +0 -14
  532. package/dist/node_modules/@allyhub/scenery-host/dist/bake/envmap.d.ts +0 -21
  533. package/dist/node_modules/@allyhub/scenery-host/dist/bake/run.d.ts +0 -63
  534. package/dist/node_modules/@allyhub/scenery-host/dist/budget.d.ts +0 -40
  535. package/dist/node_modules/@allyhub/scenery-host/dist/bundle.d.ts +0 -92
  536. package/dist/node_modules/@allyhub/scenery-host/dist/commands.d.ts +0 -54
  537. package/dist/node_modules/@allyhub/scenery-host/dist/draw2d.d.ts +0 -47
  538. package/dist/node_modules/@allyhub/scenery-host/dist/glass.d.ts +0 -39
  539. package/dist/node_modules/@allyhub/scenery-host/dist/index.d.ts +0 -25
  540. package/dist/node_modules/@allyhub/scenery-host/dist/inventory.d.ts +0 -18
  541. package/dist/node_modules/@allyhub/scenery-host/dist/layer/fidelity.d.ts +0 -70
  542. package/dist/node_modules/@allyhub/scenery-host/dist/layer/grade.d.ts +0 -7
  543. package/dist/node_modules/@allyhub/scenery-host/dist/layer/moire.d.ts +0 -6
  544. package/dist/node_modules/@allyhub/scenery-host/dist/measure/contacts.d.ts +0 -45
  545. package/dist/node_modules/@allyhub/scenery-host/dist/measure/health.d.ts +0 -10
  546. package/dist/node_modules/@allyhub/scenery-host/dist/measure/index.d.ts +0 -110
  547. package/dist/node_modules/@allyhub/scenery-host/dist/measure/relations.d.ts +0 -17
  548. package/dist/node_modules/@allyhub/scenery-host/dist/measure/solid.d.ts +0 -32
  549. package/dist/node_modules/@allyhub/scenery-host/dist/measure/support.d.ts +0 -11
  550. package/dist/node_modules/@allyhub/scenery-host/dist/model-stage.d.ts +0 -32
  551. package/dist/node_modules/@allyhub/scenery-host/dist/queries/inventory.d.ts +0 -5
  552. package/dist/node_modules/@allyhub/scenery-host/dist/queries/map.d.ts +0 -5
  553. package/dist/node_modules/@allyhub/scenery-host/dist/queries/view.d.ts +0 -10
  554. package/dist/node_modules/@allyhub/scenery-host/dist/scene.d.ts +0 -35
  555. package/dist/node_modules/@allyhub/scenery-host/dist/screen-dom.d.ts +0 -24
  556. package/dist/node_modules/@allyhub/scenery-host/dist/stage/bakes.d.ts +0 -42
  557. package/dist/node_modules/@allyhub/scenery-host/dist/stage/index.d.ts +0 -6
  558. package/dist/node_modules/@allyhub/scenery-host/dist/stage/page.d.ts +0 -70
  559. package/dist/node_modules/@allyhub/scenery-host/dist/stage/solve.d.ts +0 -49
  560. package/dist/node_modules/@allyhub/scenery-host/dist/stage/version.d.ts +0 -73
  561. package/dist/node_modules/@allyhub/scenery-host/dist/stage/view.d.ts +0 -18
  562. package/dist/node_modules/@allyhub/scenery-host/dist/steady.d.ts +0 -4
  563. package/dist/node_modules/@allyhub/scenery-host/dist/viewer.d.ts +0 -134
  564. package/editor-web/assets/channel-HUlo15J7.js +0 -1
  565. package/editor-web/assets/deck-CtEtDHo2.js +0 -1
  566. package/editor-web/assets/dist-Bl74xqMW.js +0 -19
  567. package/editor-web/assets/dist-BrUtQth3.js +0 -18
  568. package/editor-web/assets/dist-CN5A7Au2.js +0 -1
  569. package/editor-web/assets/dist-CcL6r6l3.js +0 -1
  570. package/editor-web/assets/dist-D2E3cgRP.js +0 -4
  571. package/editor-web/assets/dist-ZrBAbqyJ.js +0 -3
  572. package/editor-web/assets/dist-d4dayaWE.js +0 -17
  573. package/editor-web/assets/flowDiagram-IUGLLWBU-tz5ewhC5.js +0 -1
  574. package/editor-web/assets/index-q7X6hdHp.js +0 -28
  575. package/editor-web/assets/schemas-moE_A7Nj.js +0 -1
  576. package/editor-web/assets/slides-oQ_C0SVJ.js +0 -1
  577. package/editor-web/assets/snapshots-Dd0Wd_qM.js +0 -1
  578. package/editor-web/assets/swimlanesDiagram-AYQRV4AK-X35m3xN6.js +0 -8
  579. package/editor-web/assets/workbook-DznVDqoE.js +0 -45
  580. /package/dist/node_modules/@allyhub/{protocol/dist/runtimes.js → runtimes/dist/schema.js} +0 -0
@@ -42,4 +42,4 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
42
42
  `}}return e?(p+=`
43
43
  `+ii(l(e),c),s&&s()):d&&o&&o(),p}function Ii({items:e},t,{flowChars:n,itemIndent:r}){let{indent:i,indentStep:a,flowCollectionPadding:o,options:{commentString:s}}=t;r+=a;let c=Object.assign({},t,{indent:r,inFlow:!0,type:null}),l=!1,u=0,d=[];for(let n=0;n<e.length;++n){let i=e[n],a=null;if(Pr(i))i.spaceBefore&&d.push(``),Li(t,d,i.commentBefore,!1),i.comment&&(a=i.comment);else if(Ar(i)){let e=Pr(i.key)?i.key:null;e&&(e.spaceBefore&&d.push(``),Li(t,d,e.commentBefore,!1),e.comment&&(l=!0));let n=Pr(i.value)?i.value:null;n?(n.comment&&(a=n.comment),n.commentBefore&&(l=!0)):i.value==null&&e?.comment&&(a=e.comment)}a&&(l=!0);let o=Si(i,c,()=>a=null);l||=d.length>u||o.includes(`
44
44
  `),n<e.length-1?o+=`,`:t.options.trailingComma&&(t.options.lineWidth>0&&(l||=d.reduce((e,t)=>e+t.length+2,2)+(o.length+2)>t.options.lineWidth),l&&(o+=`,`)),a&&(o+=ai(o,r,s(a))),d.push(o),u=d.length}let{start:f,end:p}=n;if(d.length===0)return f+p;if(!l){let e=d.reduce((e,t)=>e+t.length+2,2);l=t.options.lineWidth>0&&e>t.options.lineWidth}if(l){let e=f;for(let t of d)e+=t?`\n${a}${i}${t}`:`
45
- `;return`${e}\n${i}${p}`}return`${f}${o}${d.join(` `)}${o}${p}`}function Li({indent:e,options:{commentString:t}},n,r,i){if(r&&i&&(r=r.replace(/^\n+/,``)),r){let i=ii(t(r),e);n.push(i.trimStart())}}function Ri(e,t){let n=jr(t)?t.value:t;for(let r of e)if(Ar(r)&&(r.key===t||r.key===n||jr(r.key)&&r.key.value===n))return r}var zi=class extends ni{static get tagName(){return`tag:yaml.org,2002:map`}constructor(e){super(Sr,e),this.items=[]}static from(e,t,n){let{keepUndefined:r,replacer:i}=n,a=new this(e),o=(e,o)=>{if(typeof i==`function`)o=i.call(t,e,o);else if(Array.isArray(i)&&!i.includes(e))return;(o!==void 0||r)&&a.items.push(Mi(e,o,n))};if(t instanceof Map)for(let[e,n]of t)o(e,n);else if(t&&typeof t==`object`)for(let e of Object.keys(t))o(e,t[e]);return typeof e.sortMapEntries==`function`&&a.items.sort(e.sortMapEntries),a}add(e,t){let n;n=Ar(e)?e:!e||typeof e!=`object`||!(`key`in e)?new Ni(e,e?.value):new Ni(e.key,e.value);let r=Ri(this.items,n.key),i=this.schema?.sortMapEntries;if(r){if(!t)throw Error(`Key ${n.key} already set`);jr(r.value)&&Xr(n.value)?r.value.value=n.value:r.value=n.value}else if(i){let e=this.items.findIndex(e=>i(n,e)<0);e===-1?this.items.push(n):this.items.splice(e,0,n)}else this.items.push(n)}delete(e){let t=Ri(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){let n=Ri(this.items,e)?.value;return(!t&&jr(n)?n.value:n)??void 0}has(e){return!!Ri(this.items,e)}set(e,t){this.add(new Ni(e,t),!0)}toJSON(e,t,n){let r=n?new n:t?.mapAsMap?/* @__PURE__ */ new Map:{};t?.onCreate&&t.onCreate(r);for(let e of this.items)Ai(t,r,e);return r}toString(e,t,n){if(!e)return JSON.stringify(this);for(let e of this.items)if(!Ar(e))throw Error(`Map items must all be pairs; found ${JSON.stringify(e)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),Pi(this,e,{blockItemPrefix:``,flowChars:{start:`{`,end:`}`},itemIndent:e.indent||``,onChompKeep:n,onComment:t})}};let Bi={collection:`map`,default:!0,nodeClass:zi,tag:`tag:yaml.org,2002:map`,resolve(e,t){return kr(e)||t(`Expected a mapping for this tag`),e},createNode:(e,t,n)=>zi.from(e,t,n)};var Vi=class extends ni{static get tagName(){return`tag:yaml.org,2002:seq`}constructor(e){super(Tr,e),this.items=[]}add(e){this.items.push(e)}delete(e){let t=Hi(e);return typeof t==`number`&&this.items.splice(t,1).length>0}get(e,t){let n=Hi(e);if(typeof n!=`number`)return;let r=this.items[n];return!t&&jr(r)?r.value:r}has(e){let t=Hi(e);return typeof t==`number`&&t<this.items.length}set(e,t){let n=Hi(e);if(typeof n!=`number`)throw Error(`Expected a valid index, not ${e}.`);let r=this.items[n];jr(r)&&Xr(t)?r.value=t:this.items[n]=t}toJSON(e,t){let n=[];t?.onCreate&&t.onCreate(n);let r=0;for(let e of this.items)n.push(Kr(e,String(r++),t));return n}toString(e,t,n){return e?Pi(this,e,{blockItemPrefix:`- `,flowChars:{start:`[`,end:`]`},itemIndent:(e.indent||``)+` `,onChompKeep:n,onComment:t}):JSON.stringify(this)}static from(e,t,n){let{replacer:r}=n,i=new this(e);if(t&&Symbol.iterator in Object(t)){let e=0;for(let a of t){if(typeof r==`function`){let n=t instanceof Set?a:String(e++);a=r.call(t,n,a)}i.items.push($r(a,void 0,n))}}return i}};function Hi(e){let t=jr(e)?e.value:e;return t&&typeof t==`string`&&(t=Number(t)),typeof t==`number`&&Number.isInteger(t)&&t>=0?t:null}let Ui={collection:`seq`,default:!0,nodeClass:Vi,tag:`tag:yaml.org,2002:seq`,resolve(e,t){return Mr(e)||t(`Expected a sequence for this tag`),e},createNode:(e,t,n)=>Vi.from(e,t,n)};function Wi(e){return typeof e==`bigint`||Number.isInteger(e)}let Gi=({value:e})=>JSON.stringify(e),Ki=[{identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify:Gi},{identify:e=>e==null,createNode:()=>new Zr(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^null$/,resolve:()=>null,stringify:Gi},{identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^true$|^false$/,resolve:e=>e===`true`,stringify:Gi},{identify:Wi,default:!0,tag:`tag:yaml.org,2002:int`,test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:n})=>n?BigInt(e):parseInt(e,10),stringify:({value:e})=>Wi(e)?e.toString():JSON.stringify(e)},{identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:e=>parseFloat(e),stringify:Gi}];[Bi,Ui].concat(Ki,{default:!0,tag:``,test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}});function qi(e,t,n){let{replacer:r}=n,i=new Vi(e);i.tag=`tag:yaml.org,2002:pairs`;let a=0;if(t&&Symbol.iterator in Object(t))for(let e of t){typeof r==`function`&&(e=r.call(t,String(a++),e));let o,s;if(Array.isArray(e)){if(e.length===2)o=e[0],s=e[1];else throw TypeError(`Expected [key, value] tuple: ${e}`)}else if(e&&e instanceof Object){let t=Object.keys(e);if(t.length===1)o=t[0],s=e[o];else throw TypeError(`Expected tuple with one key, not ${t.length} keys`)}else o=e;i.items.push(Mi(o,s,n))}return i}var Ji=class e extends Vi{constructor(){super(),this.add=zi.prototype.add.bind(this),this.delete=zi.prototype.delete.bind(this),this.get=zi.prototype.get.bind(this),this.has=zi.prototype.has.bind(this),this.set=zi.prototype.set.bind(this),this.tag=e.tag}toJSON(e,t){if(!t)return super.toJSON(e);let n=/* @__PURE__ */ new Map;t?.onCreate&&t.onCreate(n);for(let e of this.items){let r,i;if(Ar(e)?(r=Kr(e.key,``,t),i=Kr(e.value,r,t)):r=Kr(e,``,t),n.has(r))throw Error(`Ordered maps must not include duplicate keys`);n.set(r,i)}return n}static from(e,t,n){let r=qi(e,t,n),i=new this;return i.items=r.items,i}};Ji.tag=`tag:yaml.org,2002:omap`;var Yi=class e extends zi{constructor(t){super(t),this.tag=e.tag}add(e){let t;t=Ar(e)?e:e&&typeof e==`object`&&`key`in e&&`value`in e&&e.value===null?new Ni(e.key,null):new Ni(e,null),Ri(this.items,t.key)||this.items.push(t)}get(e,t){let n=Ri(this.items,e);return!t&&Ar(n)?jr(n.key)?n.key.value:n.key:n}set(e,t){if(typeof t!=`boolean`)throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let n=Ri(this.items,e);n&&!t?this.items.splice(this.items.indexOf(n),1):!n&&t&&this.items.push(new Ni(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,n);throw Error(`Set items must all have null values`)}static from(e,t,n){let{replacer:r}=n,i=new this(e);if(t&&Symbol.iterator in Object(t))for(let e of t)typeof r==`function`&&(e=r.call(t,e,e)),i.items.push(Mi(e,null,n));return i}};Yi.tag=`tag:yaml.org,2002:set`;let Xi=Symbol(`break visit`),Zi=Symbol(`skip children`),Qi=Symbol(`remove item`);function $i(e,t){`type`in e&&e.type===`document`&&(e={start:e.start,value:e.value}),ea(Object.freeze([]),e,t)}$i.BREAK=Xi,$i.SKIP=Zi,$i.REMOVE=Qi,$i.itemAtPath=(e,t)=>{let n=e;for(let[e,r]of t){let t=n?.[e];if(t&&`items`in t)n=t.items[r];else return}return n},$i.parentCollection=(e,t)=>{let n=$i.itemAtPath(e,t.slice(0,-1)),r=t[t.length-1][0],i=n?.[r];if(i&&`items`in i)return i;throw Error(`Parent collection not found`)};function ea(e,t,n){let r=n(t,e);if(typeof r==`symbol`)return r;for(let i of[`key`,`value`]){let a=t[i];if(a&&`items`in a){for(let t=0;t<a.items.length;++t){let r=ea(Object.freeze(e.concat([[i,t]])),a.items[t],n);if(typeof r==`number`)t=r-1;else if(r===Xi)return Xi;else r===Qi&&(a.items.splice(t,1),--t)}typeof r==`function`&&i===`key`&&(r=r(t,e))}}return typeof r==`function`?r(t,e):r}let ta=`sheet.yaml`,na=`sheet.ts`,ra=e=>e.toLowerCase();function ia(e,t){let n=e.sheets.length;if(!t)return{file:e,own:n,names:/* @__PURE__ */ new Set,ordinary:[]};let r=new Set(e.sheets.map(e=>ra(e.name))),i=t.sheets.filter(e=>!r.has(ra(e.name))),a=t.sheets.filter(e=>r.has(ra(e.name))).map(e=>e.name),o=new Set(Object.keys(e.names??{}).map(ra)),s=Object.entries(t.names??{}).filter(([e])=>!o.has(ra(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}}function aa(e,t){return t(oa(e,t))}function oa(e,t){switch(e.kind){case`unary`:case`postfix`:case`paren`:{let n=aa(e.arg,t);return n===e.arg?e:{...e,arg:n}}case`binary`:{let n=aa(e.left,t),r=aa(e.right,t);return n===e.left&&r===e.right?e:{...e,left:n,right:r}}case`call`:{let n=e.args.map(e=>aa(e,t));return n.every((t,n)=>t===e.args[n])?e:{...e,args:n}}case`invoke`:{let n=aa(e.callee,t),r=e.args.map(e=>aa(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=>aa(e,t)));return n.every((t,n)=>t.every((t,r)=>t===e.rows[n]?.[r]))?e:{...e,rows:n}}default:return e}}function sa(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 ca(e,t,n){let r=e.col&&sa(e.col,n,16384),i=e.col2&&sa(e.col2,n,16384),a=e.row&&sa(e.row,t,1048576),o=e.row2&&sa(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 la(e,t,n){return t===0&&n===0?e:aa(e,e=>e.kind===`ref`?ca(e,t,n):e)}let ua=[`#All`,`#Data`,`#Headers`,`#Totals`,`#This Row`];var da=class extends Error{at;constructor(e,t){super(e),this.at=t}};let fa=/* @__PURE__ */ new Set([`=`,`<>`,`<`,`<=`,`>`,`>=`]),pa={"=":1,"<>":1,"<":1,"<=":1,">":1,">=":1,"&":2,"+":3,"-":3,"*":4,"/":4,"^":5},ma=e=>e>=`0`&&e<=`9`,ha=e=>/[\p{L}_\\]/u.test(e)||e>=`\ud800`&&e<=`\udfff`,ga=e=>/[\p{L}\p{N}\p{M}_.?\\]/u.test(e)||e>=`\ud800`&&e<=`\udfff`,_a=(e,t)=>({index:e,abs:t});function va(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 ya=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 da(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,fa.has(n)?{op:n,inner:t}:pa[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=pa[r]??0;if(a<=e)return t;this.at+=i.length+r.length;let o=this.expression(a);t=va({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 va({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(`#`)&&!Sa(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(`#`)||Sa(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(xa(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===`[`||ha(e)}primary(){let e=this.space();return va(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(ma(e)||e===`.`){let e=Ea(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===`'`||ha(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=va({kind:`binary`,op:`,`,left:t,right:e},{inner:n}),n=this.space()}return this.eat(`)`)||this.stop(`a ( that is never closed`,e),va({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=Sa(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(ma(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&&ga(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=Ea(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:wa(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=Ea(this.s,this.at);if(r)return this.at=r.end,{kind:`ref`,...n,...r.ref};let i=wa(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=>va({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=ba.test(e)?/* @__PURE__ */ 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=va({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(va(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&&ha(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=ua.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)}};let ba=/^(?:_xlfn\.)?(?:LET|LAMBDA)$/iu,xa=e=>e.kind===`ref`||e.kind===`name`||e.kind===`structured`||e.kind===`call`||e.kind===`paren`||e.kind===`binary`&&(e.op===`:`||e.op===` `);function Sa(e,t){let n=/^#[A-Za-z0-9_/]+[!?]?/u.exec(e.slice(t));return n?zn(n[0])?.code:void 0}let Ca=(e,t)=>{let n=e.charAt(t);return n!==``&&(ga(n)||n===`(`||n===`!`||n===`[`)};function wa(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=p(r[2]??``),a=p(r[4]??``);if(i!==void 0&&a!==void 0&&!Ca(e,n))return{ref:{col:_a(i,r[1]===`$`),col2:_a(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=Ta(i),o=t+i[0].length;if(a&&!Ca(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=Ta(t),r=o+1+t[0].length;if(n&&!Ca(e,r))return{ref:{...a,col2:n.col,row2:n.row,range:!0},end:r}}}return{ref:{...a,range:!1},end:o}}}function Ta(e){let t=p(e[2]??``),n=Number(e[4])-1;if(!(t===void 0||t>=16384||n>=1048576))return{col:_a(t,e[1]===`$`),row:_a(n,e[3]===`$`)}}function Ea(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||Ca(e,r)))return{ref:{row:_a(i,n[1]===`$`),row2:_a(a,n[3]===`$`),range:!0},end:r}}function Da(e){try{return{ok:!0,node:new ya(e).parse()}}catch(e){if(e instanceof da)return{ok:!1,error:{message:e.message,at:e.at}};throw e}}var Oa=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=Da(e);i.ok?this.node=i.node:this.error=i.error}},ka=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 la(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:yr(this.moved)}},Aa=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 ka&&(this.formulas[t]=(this.formulas[t]??1)-1),n instanceof ka&&(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}},ja=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)}};let Ma=(e,t)=>e*16384+t;function Na(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 Pa=class{tables=[];blocks=[];merges=[];formulas=/* @__PURE__ */ new Set;implied=/* @__PURE__ */ new Map;keys=/* @__PURE__ */ new Map;fills=[];blanks=/* @__PURE__ */ new Set;conditions=[];validations=[];filters=[];charts=[];names=/* @__PURE__ */ new Map;freeze;generated=!1;grid=new Aa;expanded=!1;lowest=-1;ghosts=/* @__PURE__ */ new Map;spills=/* @__PURE__ */ new Set;stopped=/* @__PURE__ */ 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=Ha(e,t,[],()=>void 0);n&&this.charts.push(n)}))}put(e,t,n){n instanceof ka&&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 ka&&this.formulas.delete(r),n instanceof ka&&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(Ma(e,t))){if(r){let n=new ka(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(Ma(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(Ma(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&&y(t.spill,e));let t=/* @__PURE__ */ 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(Ma(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&&y(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(Ma(n,r),e);this.reach&&Na(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(Ma(n,r))===e&&this.ghosts.delete(Ma(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:/* @__PURE__ */ new Map,bottom:-1,right:-1};for(let{spill:t}of this.spills)t&&Na(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=>v(n.area,e,t))}blockAt(e,t){return this.blocks.find(n=>v(n.area,e,t))}looks(){if(this.lookAreas)return this.lookAreas;let e=[];for(let t of this.spec.format??[]){let n=g(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=g(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=>Fa.has(e)))]}lookAt(e,t){let n={},r=e=>{if(e)for(let[t,r]of Object.entries(e))Fa.has(t)&&r!==void 0&&(n[t]=t===`border`?{...n.border,...r}:r)},i=this.implied.get(Ma(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[f(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)v(n.area,e,t)&&r(n.entry);for(let n of l)v(n.area,e,t)&&r(n.entry);let u=this.keys.get(Ma(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(Ma(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=>v(n,e,t))}validationAt(e,t){return this.validations.find(n=>n.areas.some(n=>v(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=>v(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?.[f(t)]?.files}};let Fa=/* @__PURE__ */ new Set([`bold`,`italic`,`underline`,`strike`,`font`,`size`,`color`,`fill`,`align`,`valign`,`wrap`,`shrink`,`indent`,`rotation`,`border`,`locked`,`hide_formula`,`format`]);var Ia=class{title;sheets=[];names=/* @__PURE__ */ new Map;checks=[];bySheet=/* @__PURE__ */ new Map;byTable=/* @__PURE__ */ new Map;file;generated;ordinary=[];constructor(e,t){this.file=e,this.title=e.title,this.generated=t}respec(e){this.file=ia(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:na};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(Ma(t,n));if(o!==void 0)return{file:ta,path:[`sheets`,r,`cells`,o]};for(let i of Object.keys(e.spec.cells??{})){if(!i.includes(`:`))continue;let e=g(i);if(e&&v(e,t,n))return{file:ta,path:[`sheets`,r,`cells`,i]}}}};let La=/^[\p{L}_\\][\p{L}\p{N}_.\\?]*$/u;function Ra(e){return La.test(e)&&h(e)===void 0&&!/^(?:TRUE|FALSE)$/iu.test(e)&&!/^[Rr](?:\d+)?(?:[Cc]\d*)?$/u.test(e)&&!/^[Cc]\d*$/u.test(e)}let za=`made`,Ba=e=>e[0]===za?na:ta;var Va=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:Ba(e),...n===void 0?{}:{line:n},message:t})}sheetPath(e){return e<this.own?[`sheets`,e]:[za,`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 Pa(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:ta,path:[`checks`,t,`formula`]};this.wb.checks.push({name:e.name,formula:new Oa(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)?[za,`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(!Ra(t)){this.yaml(e,`${t} cannot be a name`);continue}let s={file:Ba(e),path:e},c=typeof o==`string`&&o.startsWith(`=`)?{name:t,formula:new Oa(o,0,0,s),source:s}:{name:t,value:typeof o==`string`?nr(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=h(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))y(n.area,r.area)&&this.problems.push({file:ta,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=g(n);i?e.merges.push(i):this.yaml([...t,`merges`,r],`${n} is not a range`)}),n.format?.forEach((e,n)=>{g(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??{}))p(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=Ha(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 Oa(e,t?.top??0,t?.left??0,{file:Ba(n),path:n})}condition(e,t,n){let r=_(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=_(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=g(n.filter.range);if(!i)this.yaml([...r,`range`],`${n.filter.range} is not a range`);else{let t=/* @__PURE__ */ new Map;for(let[e,a]of Object.entries(n.filter.columns??{})){let o=p(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=>y(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=/* @__PURE__ */ 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=>y(e.area,t));if(n)return`table ${n.name}`;let r=e.blocks.find(e=>y(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 ka(new Oa(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(Ma(t,n),r.format))}table(e,t,n){let r=h(t.at);if(!r){this.yaml([...n,`at`],`${t.at} is not a cell`);return}if(!Ra(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 ja(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=/* @__PURE__ */ 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 Oa(s,m,o,{file:Ba(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,nr(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=/* @__PURE__ */ 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=h(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,nr(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=g(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=Ka(i),s=Ma(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:Ba(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(!Ra(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:Ba(r),path:r},a=m(t).replace(/^([A-Z]+)(\d+)$/u,`$$$1$$$2`),o=`='${e.name.replaceAll(`'`,`''`)}'!${a}`;this.wb.names.set(n.toLowerCase(),{name:n,formula:new Oa(o,0,0,i),source:i})}fill(e,t,n,r){let i=Ka(n),a={file:Ba(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 Oa(i.formula,t.top,t.left,a),...i.start===void 0?{}:{start:i.start}})}};function Ha(e,t,n,r){let i=h(e.at);if(!i){r([...n,`at`],`${e.at} is not a cell`);return}let a=(e,t)=>{let n=new Oa(Ua(e),0,0,{file:Ba(t),path:t});return n.node&&!Wa(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}:{}}})}}let Ua=e=>e.startsWith(`=`)?e:`=${e}`;function Wa(e){switch(e.kind){case`error`:case`ref`:case`structured`:case`name`:return!0;case`paren`:case`postfix`:return Wa(e.arg);case`binary`:return e.op===`:`||e.op===`,`;default:return!1}}let Ga=e=>e.map(e=>e.text).join(``);function Ka(e){if(e===null)return{value:null};if(typeof e==`string`)return nr(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`?nr(e.start).value:e.start}};if(e.runs!==void 0)return{value:Ga(e.runs)};let{value:t}=e;return typeof t==`string`?nr(t):{value:t??null}}function qa(e){let t=ia(e.file,e.generated),n=new Ia(t.file,e.generated);return n.ordinary=t.ordinary,new Va(n,t=>{let n=e.generated?.csv[t];if(n!==void 0)return{rows:b(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}let Ja=e=>e instanceof j?{error:e.code}:e;function Ya(e){return typeof e!=`object`||!e?e:zn(e.error)??M.VALUE}let Xa=e=>({rows:e.rows,cols:e.cols,data:e.data.map(Ja)}),Za=e=>new N(e.rows,e.cols,e.data.map(Ya));function Qa(e,t){let n=t.formula?.text;if(n===void 0)return;let r=Da(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}}let $a=e=>typeof e==`string`?nr(e):{value:e??null};function eo(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=$a(r),a=Qa(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 Oa(i.formula,0,0,n.source),delete n.value)}return!0}let to=/* @__PURE__ */ new Map;function no(e){if(!/\d/u.test(e))return;if(to.has(e))return to.get(e);to.size>=5e4&&to.clear();let t=ro(e);return to.set(e,t),t}function ro(e){let t=nr(e.trim());if(typeof t.value==`number`)return t.value;if(e.trim()===``)return;let n=ln(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=ln(`${r[1]??``} ${r[2]??``}`);return typeof i?.value==`number`?i.value:void 0}function I(e){return typeof e==`number`?e:e==null?0:typeof e==`boolean`?+!!e:e instanceof j?e:no(e)??M.VALUE}function L(e){return typeof e==`string`?e:e==null?``:typeof e==`number`?Yn(e):typeof e==`boolean`?e?`TRUE`:`FALSE`:e}function io(e){if(typeof e==`boolean`)return e;if(e==null)return!1;if(typeof e==`number`)return e!==0;if(e instanceof j)return e;let t=e.trim().toUpperCase();return t===`TRUE`||t!==`FALSE`&&M.VALUE}let ao=e=>typeof e==`number`?0:typeof e==`string`?1:2,oo=(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 so(e,t){let n=e??(typeof t==`string`?``:typeof t!=`boolean`&&0),r=t??(typeof e==`string`?``:typeof e!=`boolean`&&0),i=ao(n),a=ao(r);if(i!==a)return i<a?-1:1;if(typeof n==`number`&&typeof r==`number`)return oo(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}let co=e=>Number.isFinite(e)?e:M.NUM;function lo(e,t,n){return Math.abs(e)<=Math.max(Math.abs(t),Math.abs(n))*89e-17?0:e}function uo(e,t,n){let r=I(t);if(r instanceof j)return r;let i=I(n);if(i instanceof j)return i;switch(e){case`+`:return co(lo(r+i,r,i));case`-`:return co(lo(r-i,r,i));case`*`:return co(r*i);case`/`:return i===0?M.DIV0:co(r/i);default:return r===0&&i===0?M.NUM:r===0&&i<0?M.DIV0:co(r**i)}}function fo(e,t,n){if(t instanceof j)return t;if(n instanceof j)return n;switch(e){case`&`:{let e=L(t);if(e instanceof j)return e;let r=L(n);return r instanceof j?r:`${e}${r}`}case`=`:return so(t,n)===0;case`<>`:return so(t,n)!==0;case`<`:return so(t,n)<0;case`<=`:return so(t,n)<=0;case`>`:return so(t,n)>0;case`>=`:return so(t,n)>=0;default:return uo(e,t,n)}}function po(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?M.NA:n(c,l)}return new N(r,i,a)}let mo=e=>({top:e.top,left:e.left,bottom:e.bottom,right:e.right});var ho=class{kept=/* @__PURE__ */ 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:mo(e)})),value:i}),i}asked=/* @__PURE__ */ 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:mo(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&&y(n.area,t))&&this.kept.delete(n)}clear(){this.kept.clear(),this.asked.clear()}};let go=(e,t)=>`${e}:${t.key}`,_o=/* @__PURE__ */ new Map;function vo(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?255:i.length}}function yo(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 bo(e,t){return e.group.length===0||t<=e.fixed.length||(t-e.fixed.length)%e.group.length===0}function R(e,t,n,r,i={}){_o.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 z(e,t,n,r={}){let{min:i,max:a,fixed:o,group:s}=vo(t);_o.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 xo(e,t,n,r){_o.set(e,{name:e,min:t,max:n,kind:`lazy`,call:r,from:`allyhub`})}function So(e,t){let n=_o.get(t);n&&_o.set(e,{...n,name:e})}function B(e,t){if(e instanceof j)return e;if(e instanceof or)return M.VALUE;if(e instanceof P){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 N)return{rows:e.rows,cols:e.cols,at:(t,n)=>e.at(t,n),array:e};if(e instanceof sr)return M.VALUE;let n=e instanceof F?null:e;return{rows:1,cols:1,at:()=>n}}function Co(e,t,n){for(let r of e)if(r instanceof P)t.calc.each(r,e=>{n(e,!1)});else if(r instanceof or)for(let e of r.parts)t.calc.each(e,e=>{n(e,!1)});else if(r instanceof N)for(let e of r.data)e!==null&&n(e,!1);else r instanceof F?n(null,!0):r instanceof sr?n(M.VALUE,!0):n(r,!0)}function wo(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 P)r(t);else if(t instanceof or)t.parts.forEach(r);else if(t instanceof N)for(let e of t.data)n(e,!1);else t instanceof F?n(null,!0):t instanceof sr?n(M.VALUE,!0):n(t,!0)}function To(e,t){let n=[],r;return Co(e,t,(e,t)=>{if(!r){if(e instanceof j)r=e;else if(typeof e==`number`)n.push(e);else if(t){let t=I(e);t instanceof j?r=t:n.push(t)}}}),r??n}function Eo(e,t){let n=[],r;return Co(e,t,(e,t)=>{if(!r){if(e instanceof j)r=e;else if(typeof e==`number`)n.push(e);else if(typeof e==`boolean`)n.push(+!!e);else if(t){let t=I(e);t instanceof j?r=t:n.push(t)}else typeof e==`string`&&n.push(0)}}),r??n}let Do=e=>(...t)=>{let n=[];for(let e of t){let t=I(e);if(t instanceof j)return t;n.push(t)}return e(...n)};function Oo(e,t){return e===void 0?t:I(e)}function ko(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`}let Ao=/* @__PURE__ */ new Map;function jo(e){let t=Ao.get(e);if(t)return t;Ao.size>=1e4&&Ao.clear();let n=Mo(e);return Ao.set(e,n),n}function Mo(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)}let No=e=>/[*?~]/u.test(e);function Po(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 Fo(e){return t=>{if(typeof t==`number`)return oo(t,e);if(typeof t!=`string`)return!1;let n=no(t);return n!==void 0&&oo(n,e)}}function Io(e,t){let n=t=>e===`>`?t>0:e===`>=`?t>=0:e===`<`?t<0:t<=0;return e=>typeof e==typeof t&&n(so(e,t))}function Lo(e){if(e===null)return{test:Fo(0),key:`n0`};if(typeof e==`number`)return{test:Fo(e),key:`n${String(Number(e.toPrecision(15)))}`};if(typeof e==`boolean`)return{test:t=>t===e,key:e?`bT`:`bF`};if(e instanceof j)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=no(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=Fo(a),t=ko(a);else if(o!==void 0)e=e=>e===o,t=ko(o);else if(zn(r)!==void 0)e=e=>e instanceof j&&e.code===r.toUpperCase();else if(No(r)){let t=jo(r);e=e=>typeof e==`string`&&t(e)}else{let n=r.toUpperCase();e=e=>typeof e==`string`&&e.toUpperCase()===n,t=ko(r)}return n===`=`?t===void 0?{test:e}:{test:e,key:t}:{test:t=>!e(t)}}return{test:Io(n,s??r)}}function Ro(e,t){let n=e.reference;if(!(n?.cols!==1||e.rows<64))return t.calc.indexes.ofRepeated(go(`crit`,n),[n],()=>{let t=/* @__PURE__ */ 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(ko(r),t),typeof r==`string`){let e=no(r);e!==void 0&&n(ko(e),t)}}return t})}function zo(e,t){return Lo(t.calc.scalar(e,t.frame))}function Bo(e,t){let n=[];for(let r=0;r+1<e.length;r+=2){let i=B(e[r],t);if(i instanceof j)return i;let a=zo(e[r+1],t);if(a instanceof j)return a;n.push({cells:i,crit:a})}let r=n[0]?.cells;return r&&n.some(e=>!Vo(e.cells,r))?M.VALUE:n}let Vo=(e,t)=>e.cols===t.cols&&(e.reference?.rows??e.rows)===(t.reference?.rows??t.rows);function Ho(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=Ro(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 Uo(e,t){return e instanceof P?(e.rows-t.rows)*e.cols:0}function Wo(e,t,n,r){let i;return Ho(t,n,(t,n)=>{if(i)return;let a=e.at(t,n);a instanceof j?i=a:typeof a==`number`&&r(a)}),i}function Go(e,t){let n=B(e[0],t);if(n instanceof j)return n;let r=e[2];return r===void 0?n:B(r,t)}let Ko=e=>(t,n)=>{let r=B(t[0],n);if(r instanceof j)return r;let i=zo(t[1],n);if(i instanceof j)return i;let a=Go(t,n);if(a instanceof j)return a;let o=[];return Wo(a,[{cells:r,crit:i}],n,e=>{o.push(e)})??e(o)},qo=e=>(t,n)=>{let r=B(t[0],n);if(r instanceof j)return r;let i=Bo(t.slice(1),n);if(i instanceof j)return i;let a=i[0]?.cells;if(a&&!Vo(r,a))return M.VALUE;let o=[];return Wo(r,i,n,e=>{o.push(e)})??e(o)},Jo=(e,t)=>(n,r)=>{let i=[],a=[e];for(let e of n)if(e instanceof P)i.push(e),a.push(`r${e.key}`);else if(e instanceof F)a.push(`-`);else if(e instanceof j)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 j)&&r.calc.results.set(o,i,c),c},Yo=e=>e.reduce((e,t)=>e+t,0),Xo=e=>e.length===0?M.DIV0:Yo(e)/e.length;z(`SUMIF`,`rv?r`,Jo(`SUMIF`,Ko(Yo))),z(`AVERAGEIF`,`rv?r`,Jo(`AVERAGEIF`,Ko(Xo))),z(`SUMIFS`,`r(rv)`,Jo(`SUMIFS`,qo(Yo))),z(`AVERAGEIFS`,`r(rv)`,Jo(`AVERAGEIFS`,qo(Xo))),z(`MINIFS`,`r(rv)`,Jo(`MINIFS`,qo(e=>e.length===0?0:e.reduce((e,t)=>t<e?t:e)))),z(`MAXIFS`,`r(rv)`,Jo(`MAXIFS`,qo(e=>e.length===0?0:e.reduce((e,t)=>t>e?t:e)))),z(`COUNTIF`,`rv`,Jo(`COUNTIF`,(e,t)=>{let n=B(e[0],t);if(n instanceof j)return n;let r=zo(e[1],t);if(r instanceof j)return r;let i=0;return Ho([{cells:n,crit:r}],t,()=>{i+=1}),i+(r.test(null)?Uo(e[0],n):0)})),z(`COUNTIFS`,`(rv)`,Jo(`COUNTIFS`,(e,t)=>{let n=Bo(e,t);if(n instanceof j)return n;let r=0;return Ho(n,t,()=>{r+=1}),r}));let Zo=e=>typeof e==`number`?0:typeof e==`string`?1:typeof e==`boolean`?2:3;function Qo(e,t){let n=Zo(e),r=Zo(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 j&&t instanceof j?e.code<t.code?-1:+(e.code>t.code):0}let $o=e=>e.separator??`, `;function es(e,t){let n=$o(t);return e.split(n.trim()===``?n:n.trim()).map(e=>e.trim()).filter(e=>e!==``)}let ts=(e,t,n,r)=>ar(t.value(e,n,r),e.lookAt(n,r).format),ns=(e,t)=>{if(t===``)return e.blanks===!0;let n=t.toLowerCase();return e.values?.some(e=>e.toLowerCase()===n)===!0};function rs(e,t,n,r){let i=e.validations.length===0?void 0:e.validationAt(t,n);return i?.spec.multiple===!0?es(r,i.spec):[r]}function is(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=No(a)?jo(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 as(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=ts(e,t,n,r);return a===``?i.blanks===!0:rs(e,n,r,a).some(e=>ns(i,e))};let c=i.conditions;if(c)return n=>{let a=t.value(e,n,r),o=ts(e,t,n,r),s=c.map(e=>is(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 os(e,t,n,r){return[...n.columns].filter(([e])=>e!==r).map(([r,i])=>as(e,t,n,r,i))}let ss=(e,t)=>e.every(e=>e(t));function cs(e,t){let n=/* @__PURE__ */ 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=os(e,t,r);for(let e=i+1;e<=o;e++)ss(s,e)||n.add(e)}return n}let ls=(e,t)=>e?t.calc.eval(e,t.frame):!1;function us(e,t,n){if(!(e instanceof N))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):M.NA}function ds(e,t,n){let r=[e,...t].filter(e=>e instanceof N),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(us(e,r,i));o[r*a+i]=s instanceof j?s:us(t[s]??M.VALUE,r,i)}return new N(i,a,o)}xo(`IF`,1,3,(e,t)=>{let n=t.calc.flat(ls(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 F?null:i};if(n instanceof N){let i=n=>n<e.length?t.calc.flat(r(n))??0:!1;return ds(n,[i(1),i(2)],e=>{let t=io(e);return t instanceof j?t:+!t})}let i=io(n);return i instanceof j?i:r(i?1:2)}),xo(`IFS`,2,255,(e,t)=>{for(let n=0;n+1<e.length;n+=2){let r=io(t.calc.scalar(ls(e[n],t),t.frame));if(r instanceof j)return r;if(r)return ls(e[n+1],t)}return M.NA});let fs=e=>(t,n)=>{let r=n.calc.flat(ls(t[0],n)),i=t=>t instanceof j&&(e===void 0||t===e),a=()=>t[1]?n.calc.flat(n.calc.eval(t[1],n.frame)):``;return r instanceof N?ds(r,[r,a()],e=>+!!i(e)):i(r)?a():r};xo(`IFERROR`,2,2,fs()),xo(`IFNA`,2,2,fs(M.NA)),xo(`CHOOSE`,2,255,(e,t)=>{let n=t.calc.flat(ls(e[0],t));if(n instanceof N){let r=e.slice(1).map(e=>t.calc.flat(t.calc.eval(e,t.frame)));return ds(n,r,e=>{let t=I(e);if(t instanceof j)return t;let n=Math.trunc(t)-1;return n<0||n>=r.length?M.VALUE:n})}let r=I(n);if(r instanceof j)return r;let i=Math.trunc(r),a=e[i];return i<1||a===void 0?M.VALUE:t.calc.eval(a,t.frame)}),xo(`SWITCH`,3,255,(e,t)=>{let n=t.calc.scalar(ls(e[0],t),t.frame);if(n instanceof j)return n;let r=1;for(;r+1<e.length;r+=2){let i=t.calc.scalar(ls(e[r],t),t.frame);if(i instanceof j)return i;if(so(n,i)===0)return ls(e[r+1],t)}return r<e.length?ls(e[r],t):M.NA});function ps(e,t){let n=[],r;return Co(e,t,(e,t)=>{if(r)return;if(e instanceof j){r=e;return}if(typeof e==`string`&&!t||e===null)return;let i=io(e);i instanceof j?r=i:n.push(i)}),r||(n.length===0?M.VALUE:n)}z(`AND`,`(r)`,(e,t)=>{let n=ps(e,t);return n instanceof j?n:n.every(Boolean)}),z(`OR`,`(r)`,(e,t)=>{let n=ps(e,t);return n instanceof j?n:n.some(Boolean)}),z(`XOR`,`(r)`,(e,t)=>{let n=ps(e,t);return n instanceof j?n:n.filter(Boolean).length%2==1}),R(`NOT`,1,1,e=>{let t=io(e);return t instanceof j?t:!t}),z(`TRUE`,``,()=>!0),z(`FALSE`,``,()=>!1);let ms=(e,t)=>t?{names:e,parent:t}:{names:e};xo(`LET`,3,255,(e,t)=>{if(e.length%2==0)return M.VALUE;let n=/* @__PURE__ */ new Map,r={...t.frame,scope:ms(n,t.frame.scope)};for(let i=0;i+1<e.length;i+=2){let a=e[i];if(a?.kind!==`name`)return M.VALUE;n.set(a.name.toLowerCase(),ls(e[i+1],{...t,frame:r}))}return ls(e[e.length-1],{...t,frame:r})}),xo(`LAMBDA`,1,254,(e,t)=>{let n=[];for(let t of e.slice(0,-1)){if(t.kind!==`name`)return M.VALUE;n.push(t.name.toLowerCase())}let r=e[e.length-1];return r?new sr(n,r,t.frame):M.VALUE});function hs(e){let t=0;for(let n of e)t=lo(t+n,t,n);return t}z(`SUM`,`(r)`,(e,t)=>{let n=0,r;return Co(e,t,(e,i)=>{if(!r){if(typeof e==`number`)n=lo(n+e,n,e);else if(e instanceof j)r=e;else if(i){let i=To([e],t);i instanceof j?r=i:n+=i[0]??0}}}),r??co(n)}),z(`AVERAGE`,`(r)`,(e,t)=>{let n=To(e,t);return n instanceof j?n:n.length===0?M.DIV0:hs(n)/n.length}),z(`AVERAGEA`,`(r)`,(e,t)=>{let n=Eo(e,t);return n instanceof j?n:n.length===0?M.DIV0:hs(n)/n.length}),z(`COUNT`,`(r)`,(e,t)=>{let n=0;return Co(e,t,(e,r)=>{typeof e==`number`?n+=1:r&&!(e instanceof j)&&e!==null&&(To([e],t)instanceof j||(n+=1))}),n}),z(`COUNTA`,`(r)`,(e,t)=>{let n=0;return Co(e,t,()=>{n+=1}),n}),z(`COUNTBLANK`,`r`,(e,t)=>{let n=e[0];if(n instanceof j)return n;if(n instanceof P){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 N?r.data.filter(e=>e===null||e===``).length:+(r===null||r===``)});let gs=e=>t=>{if(t instanceof j)return t;if(t.length===0)return 0;let n=t[0]??0;for(let r of t)n=e(n,r);return n},_s=gs((e,t)=>t<e?t:e),vs=gs((e,t)=>t>e?t:e);z(`MIN`,`(r)`,(e,t)=>_s(To(e,t))),z(`MAX`,`(r)`,(e,t)=>vs(To(e,t))),z(`MINA`,`(r)`,(e,t)=>_s(Eo(e,t))),z(`MAXA`,`(r)`,(e,t)=>vs(Eo(e,t))),z(`PRODUCT`,`(r)`,(e,t)=>{let n=To(e,t);return n instanceof j?n:n.length===0?0:co(n.reduce((e,t)=>e*t,1))}),z(`SUMSQ`,`(r)`,(e,t)=>{let n=To(e,t);return n instanceof j?n:co(hs(n.map(e=>e*e)))}),z(`SUMPRODUCT`,`(r)`,(e,t)=>{let n=e.map(e=>B(e,t)),r=n[0];if(r===void 0||r instanceof j)return r??M.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 j)return e;if(e.cols!==a||o(e)!==o(r))return M.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 j)return n;r*=typeof n==`number`?n:0}s+=r}return co(s)});let ys={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 bs(e){if(!(e instanceof ka))return!1;let{node:t}=e.shared;return t?.kind===`call`&&t.name===`SUBTOTAL`}z(`SUBTOTAL`,`v(r)`,(e,t)=>{let n=t.calc.scalar(e[0],t.frame);if(n instanceof j)return n;if(typeof n!=`number`)return M.VALUE;let r=n<100,i=ys[r?n:n-100],a=i===void 0?void 0:_o.get(i);if(a?.kind!==`raw`)return M.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(bs(e.sheet.at(o,n))?null:t.calc.read(e.sheet,o,n));o.push(new N(a.length,1,a))};for(let t of e.slice(1)){if(t instanceof j)return t;if(t instanceof P)s(t);else if(t instanceof or)t.parts.forEach(s);else return M.VALUE}return a.call(o,t)});let xs=(e,t)=>typeof e==typeof t&&!(e instanceof j)&&e!==null;function Ss(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)}}let Cs=/* @__PURE__ */ new WeakMap;function ws(e,t){let n=Cs.get(e);if(n)return n;if(n===void 0){Cs.set(e,null);return}let r=t();return Cs.set(e,r),r}function Ts(e,t,n,r,i,a=0,o=1){let s=typeof e==`string`?e:void 0,c=i&&s!==void 0&&No(s)?Po(s):s;if(s!==void 0&&c===void 0){let e=jo(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=ko(c??e);if(l===void 0)return-1;if(t.length>=64&&a===0&&o===1){let e=()=>{let e=/* @__PURE__ */ new Map;for(let n=t.length-1;n>=0;n--){let r=ko(t.at(n));r!==void 0&&e.set(r,[n])}return e},i=n.reference,a=i?r.calc.indexes.ofRepeated(go(`find`,i),[i],e):n.array&&ws(n.array,e);if(a)return a.get(l)?.[0]??-1}for(let e=a;e>=0&&e<t.length;e+=o)if(ko(t.at(e))===l)return e;return-1}function Es(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&&!xs(t.at(s),e);)--s;if(s<r){r=o+1;continue}let c=so(t.at(s),e);(n?c>=0:c<=0)?(a=s,r=o+1):i=s-1}return a}let Ds=(e,t)=>t.calc.scalar(e??null,t.frame),Os=(e,t,n)=>e===void 0?n:e instanceof F?!1:io(t.calc.scalar(e,t.frame));function ks(e){return(t,n)=>{let r=Ds(t[0],n);if(r instanceof j)return r;let i=B(t[1],n);if(i instanceof j)return i;let a=I(n.calc.scalar(t[2],n.frame));if(a instanceof j)return a;let o=Math.trunc(a);if(o<1)return M.VALUE;let s=i.reference,c=s?s.bottom-s.top+1:i.rows;if(o>(e?i.cols:c))return M.REF;let l=Os(t[3],n,!0);if(l instanceof j)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 P(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?Es(r,u):Ts(r,u,d,n,!0);return f<0?M.NA:e?i.at(f,o-1):i.at(o-1,f)}}z(`VLOOKUP`,`vrv?v`,ks(!0)),z(`HLOOKUP`,`vrv?v`,ks(!1)),z(`MATCH`,`vr?v`,(e,t)=>{let n=Ds(e[0],t);if(n instanceof j)return n;let r=B(e[1],t);if(r instanceof j)return r;let i=Ss(r);if(!i)return M.NA;let a=e[2]===void 0?1:e[2]instanceof F?0:I(t.calc.scalar(e[2],t.frame));if(a instanceof j)return a;let o=a===0?Ts(n,i,r,t,!0):Es(n,i,a<0);return o<0?M.NA:o+1}),z(`LOOKUP`,`vr?r`,(e,t)=>{let n=Ds(e[0],t);if(n instanceof j)return n;let r=B(e[1],t);if(r instanceof j)return r;let i=r.rows>=r.cols,a=Es(n,{length:i?r.rows:r.cols,at:e=>i?r.at(e,0):r.at(0,e)});if(a<0)return M.NA;if(e[2]===void 0)return i?r.at(a,r.cols-1):r.at(r.rows-1,a);let o=B(e[2],t);if(o instanceof j)return o;let s=Ss(o);return s?s.at(a):M.NA});function As(e,t,n,r,i){let a=Ss(t);if(!a)return-1;let o=i===-1;if(Math.abs(i)===2){let t=Es(e,a,i<0);if(t>=0&&so(a.at(t),e)===0)return t;if(r===0)return-1}let s=Ts(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(!xs(n,e))continue;let i=so(n,e),o=c<0||(r<0?so(n,a.at(c))>0:so(n,a.at(c))<0);(r<0?i<0:i>0)&&o&&(c=t)}return c}let js=(e,t,n)=>{let r=(e,t)=>e===void 0||e instanceof F?t:I(n.calc.scalar(e,n.frame)),i=r(e,0);if(i instanceof j)return i;let a=r(t,1);return a instanceof j?a:[i,a]};z(`XLOOKUP`,`vrr?rvv`,(e,t)=>{let n=Ds(e[0],t);if(n instanceof j)return n;let r=B(e[1],t);if(r instanceof j)return r;let i=B(e[2],t);if(i instanceof j)return i;let a=js(e[4],e[5],t);if(a instanceof j)return a;let o=As(n,r,t,a[0],a[1]);if(o<0){let n=e[3];return n===void 0||n instanceof F?M.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 N(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 N(i.rows,1,s)}),z(`XMATCH`,`vr?vv`,(e,t)=>{let n=Ds(e[0],t);if(n instanceof j)return n;let r=B(e[1],t);if(r instanceof j)return r;let i=js(e[2],e[3],t);if(i instanceof j)return i;let a=As(n,r,t,i[0],i[1]);return a<0?M.NA:a+1}),z(`INDEX`,`rv?vv`,(e,t)=>{let n=e[0],r=e=>{if(e===void 0||e instanceof F)return 0;let n=I(t.calc.scalar(e,t.frame));return n instanceof j?n:Math.trunc(n)};if(n instanceof or){let t=r(e[3]??1);if(t instanceof j)return t;let i=n.parts[t-1];if(!i)return M.REF;n=i}if(n instanceof j)return n;let i=r(e[1]);if(i instanceof j)return i;let a=r(e[2]);if(a instanceof j)return a;if(i<0||a<0)return M.VALUE;if(n instanceof P){let t=e[2]===void 0&&n.rows===1,r=t?1:i,o=t?i:a;return r>n.rows||o>n.cols?M.REF:new P(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=B(n,t);if(o instanceof j)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 M.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 N(u,d,f)}),z(`OFFSET`,`rvv?vv`,(e,t)=>{let n=e[0];if(n instanceof j)return n;if(!(n instanceof P))return M.VALUE;let r=(e,n)=>{if(e===void 0||e instanceof F)return n;let r=I(t.calc.scalar(e,t.frame));return r instanceof j?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 j)return e;let[c,l,u,d]=[i,a,o,s];if(u===0||d===0)return M.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?M.REF:new P(n.sheet,Math.min(f,m),Math.min(p,h),Math.max(f,m),Math.max(p,h))},{volatile:!0});let Ms=/^(?:(.*)!)?R(\[-?\d+\]|\d+)?C(\[-?\d+\]|\d+)?(?::R(\[-?\d+\]|\d+)?C(\[-?\d+\]|\d+)?)?$/iu,Ns=(e,t)=>e===void 0?t:e.startsWith(`[`)?t+Number(e.slice(1,-1)):Number(e)-1;function Ps(e,t,n){let r=Ms.exec(e.trim());if(!r)return;let[,i,a,o,s,c]=r,l={row:Ns(a,t),col:Ns(o,n)};if(l.row<0||l.col<0)return;let u=m(l),d=i===void 0?``:`${i}!`;if(s===void 0&&c===void 0)return`${d}${u}`;let f={row:Ns(s,t),col:Ns(c,n)};return f.row<0||f.col<0?void 0:`${d}${u}:${m(f)}`}z(`INDIRECT`,`v?v`,(e,t)=>{let n=L(t.calc.scalar(e[0],t.frame));if(n instanceof j)return n;let r=e[1]===void 0||io(t.calc.scalar(e[1],t.frame));if(r instanceof j)return r;let i=r?n:Ps(n,t.frame.row,t.frame.col);if(i===void 0)return M.REF;let a=Da(i);if(!a.ok)return M.REF;let{node:o}=a;if(o.kind!==`ref`&&o.kind!==`structured`&&o.kind!==`name`&&(o.kind!==`binary`||o.op!==`:`))return M.REF;let s=t.calc.eval(o,{...t.frame,dr:0,dc:0});return s instanceof P||s instanceof or?s:M.REF},{volatile:!0});let Fs=(e,t,n)=>{if(e===void 0||e instanceof F)return t+1;if(e instanceof j)return e;if(e instanceof N)return new N(e.rows,e.cols,e.data.map(e=>e instanceof j?e:M.VALUE));if(!(e instanceof P))return M.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===Is?new N(i,1,a):new N(1,i,a)},Is=e=>[e.top,e.bottom===1048575?Math.min(e.rows,e.sheet.lastRow-e.top+1):e.rows],Ls=e=>[e.left,e.cols];z(`ROW`,`?r`,(e,t)=>Fs(e[0],t.frame.row,Is)),z(`COLUMN`,`?r`,(e,t)=>Fs(e[0],t.frame.col,Ls)),z(`ROWS`,`r`,(e,t)=>{let n=e[0];if(n instanceof P)return n.rows;let r=B(n,t);return r instanceof j?r:r.rows}),z(`COLUMNS`,`r`,(e,t)=>{let n=e[0];if(n instanceof P)return n.cols;let r=B(n,t);return r instanceof j?r:r.cols}),z(`AREAS`,`r`,e=>{let t=e[0];return t instanceof P?1:t instanceof or?t.parts.length:M.VALUE}),R(`ADDRESS`,2,5,(e,t,n,r,i)=>{let a=I(e),o=I(t),s=n==null?1:I(n);for(let e of[a,o,s])if(e instanceof j)return e;let[c,l,u]=[a,o,s];if((c??0)<1||(l??0)<1||(c??0)>1048576||(l??0)>16384)return M.VALUE;let d=r==null||io(r);if(d instanceof j)return d;let p=u===1||u===2,m=u===1||u===3,h=d?`${m?`$`:``}${f((l??1)-1)}${p?`$`:``}${String(c)}`:`R${p?String(c):`[${String(c)}]`}C${m?String(l):`[${String(l)}]`}`;if(i==null)return h;let g=L(i);return g instanceof j?g:`${fr(g)}${h}`}),z(`TRANSPOSE`,`r`,(e,t)=>{let n=B(e[0],t);if(n instanceof j)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 N(n.cols,n.rows,r)}),xo(`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 P)return r.sheet.index+1;let i=t.calc.scalar(r,t.frame);if(typeof i!=`string`)return M.NA;let a=t.calc.wb.sheet(i);return a?a.index+1:M.NA}),z(`SHEETS`,`?r`,(e,t)=>t.calc.wb.sheets.length);let Rs=(e,t)=>Array.from(e,e=>{let n=t(e);return n.length===e.length?n:e}).join(``),zs=e=>Rs(e,e=>e.toLowerCase());function Bs(e,t){if(e===void 0||e instanceof F)return[];let n=B(e,t);if(n instanceof j)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=L(i);if(a instanceof j)return a;r.push(a)}return r}function Vs(e,t,n){let r=n?zs(e):e,i=(n?t.map(zs):[...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 Hs(e,t,n){let r=[],i=0;for(let a of Vs(e,t,n))r.push(e.slice(i,a.at)),i=a.at+a.length;return r.push(e.slice(i)),r}let Us=e=>t=>{let n=L(t);return n instanceof j?n:e(n)},Ws=(e,t)=>{if(e===void 0)return t;let n=I(e);return n instanceof j?n:n<0?M.VALUE:Math.trunc(n)},Gs=e=>Rs(e,e=>e.toUpperCase()),Ks=zs;R(`LEFT`,1,2,(e,t)=>{let n=L(e),r=Ws(t,1);return n instanceof j?n:r instanceof j?r:n.slice(0,r)}),R(`RIGHT`,1,2,(e,t)=>{let n=L(e),r=Ws(t,1);return n instanceof j?n:r instanceof j?r:r===0?``:n.slice(-r)}),R(`MID`,3,3,(e,t,n)=>{let r=L(e),i=I(t),a=Ws(n,0);if(r instanceof j)return r;if(i instanceof j)return i;if(a instanceof j)return a;if(i<1)return M.VALUE;let o=Math.trunc(i)-1;return r.slice(o,o+a)}),R(`LEN`,1,1,Us(e=>e.length)),R(`LOWER`,1,1,Us(Ks)),R(`UPPER`,1,1,Us(Gs)),R(`PROPER`,1,1,Us(e=>Ks(e).replace(/(^|[^\p{L}])(\p{L})/gu,(e,t,n)=>`${t}${Gs(n)}`))),R(`TRIM`,1,1,Us(e=>e.replace(/ +/gu,` `).replace(/^ | $/gu,``))),R(`CLEAN`,1,1,Us(e=>e.replace(/[\u0000-\u001f]/gu,``))),R(`T`,1,1,e=>typeof e==`string`?e:``),R(`EXACT`,2,2,(e,t)=>{let n=L(e),r=L(t);return n instanceof j?n:r instanceof j?r:n===r}),R(`REPT`,2,2,(e,t)=>{let n=L(e),r=Ws(t,0);return n instanceof j?n:r instanceof j?r:n.length*r>32767?M.VALUE:n.repeat(r)}),R(`CHAR`,1,1,Do(e=>{let t=Math.trunc(e);return t<1||t>255?M.VALUE:qs(t)})),R(`UNICHAR`,1,1,Do(e=>{let t=Math.trunc(e);return t<1||t>1114111?M.VALUE:String.fromCodePoint(t)})),R(`CODE`,1,1,Us(e=>e===``?M.VALUE:e.charCodeAt(0))),R(`UNICODE`,1,1,Us(e=>e.codePointAt(0)??M.VALUE));function qs(e){return e>=128&&e<160?`€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ`.charAt(e-128):String.fromCharCode(e)}z(`CONCAT`,`(r)`,(e,t)=>{let n=``,r;return wo(e,t,e=>{if(r)return;let t=L(e);t instanceof j?r=t:n+=t}),r??n}),R(`CONCATENATE`,1,255,(...e)=>{let t=``;for(let n of e){let e=L(n);if(e instanceof j)return e;t+=e}return t}),z(`TEXTJOIN`,`rv(r)`,(e,t)=>{let[n,r,...i]=e,a=B(n??``,t);if(a instanceof j)return a;let o=[];for(let e=0;e<a.rows;e++)for(let t=0;t<a.cols;t++){let n=L(a.at(e,t));if(n instanceof j)return n;o.push(n)}let s=io(t.calc.scalar(r===void 0||r instanceof F||r,t.frame));if(s instanceof j)return s;let c=[],l;if(wo(i,t,e=>{if(l)return;let t=L(e);t instanceof j?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}),R(`SUBSTITUTE`,3,4,(e,t,n,r)=>{let i=L(e),a=L(t),o=L(n);if(i instanceof j)return i;if(a instanceof j)return a;if(o instanceof j)return o;if(a===``)return i;if(r===void 0)return i.split(a).join(o);let s=I(r);if(s instanceof j)return s;if(s<1)return M.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)}`}),R(`REPLACE`,4,4,(e,t,n,r)=>{let i=L(e),a=I(t),o=Ws(n,0),s=L(r);if(i instanceof j)return i;if(a instanceof j)return a;if(o instanceof j)return o;if(s instanceof j)return s;if(a<1)return M.VALUE;let c=Math.trunc(a)-1;return`${i.slice(0,c)}${s}${i.slice(c+o)}`}),R(`FIND`,2,3,(e,t,n)=>{let r=L(e),i=L(t),a=n===void 0?1:I(n);if(r instanceof j)return r;if(i instanceof j)return i;if(a instanceof j)return a;if(a<1||a>i.length+1)return M.VALUE;let o=i.indexOf(r,Math.trunc(a)-1);return o<0?M.VALUE:o+1}),R(`SEARCH`,2,3,(e,t,n)=>{let r=L(e),i=L(t),a=n===void 0?1:I(n);if(r instanceof j)return r;if(i instanceof j)return i;if(a instanceof j)return a;if(a<1||a>i.length+1)return M.VALUE;let o=Math.trunc(a)-1,s=Po(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?M.VALUE:n+1}}let c=jo(`${r}*`);for(let e=o;e<=i.length;e++)if(c(i.slice(e)))return e+1;return M.VALUE}),R(`VALUE`,1,1,e=>typeof e==`number`?e:e==null?0:typeof e==`string`?no(e)??M.VALUE:M.VALUE),R(`NUMBERVALUE`,1,3,(e,t,n)=>{let r=L(e),i=L(t??`.`),a=L(n??`,`);if(r instanceof j)return r;if(i instanceof j)return i;if(a instanceof j)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)?M.VALUE:c/100**s}),R(`TEXT`,2,2,(e,t)=>{let n=L(t);if(n instanceof j)return n;if(!Ln(n))return M.VALUE;if(typeof e==`boolean`)return e?`TRUE`:`FALSE`;let r=typeof e==`string`?no(e)??e:e??0;if(r instanceof j)return r;try{return In(n,r)}catch{return M.VALUE}});function Js(e,t,n){return In(`${n?`#,##0`:`0`}${t>0?`.${`0`.repeat(t)}`:``}`,e)}let Ys=(e,t)=>{let n=10**t;return Math.sign(e)*Math.round(Math.abs(e)*n+1e-9)/n};R(`FIXED`,1,3,(e,t,n)=>{let r=I(e),i=t==null?2:I(t),a=n!==void 0&&io(n);if(r instanceof j)return r;if(i instanceof j)return i;if(a instanceof j)return a;let o=Math.trunc(i);return Js(Ys(r,o),Math.max(0,o),!a)}),R(`DOLLAR`,1,2,(e,t)=>{let n=I(e),r=t==null?2:I(t);if(n instanceof j)return n;if(r instanceof j)return r;let i=Math.trunc(r),a=Js(Math.abs(Ys(n,i)),Math.max(0,i),!0);return n<0?`($${a})`:`$${a}`});function Xs(e,t,n,r,i){let a=Vs(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 Zs(e){return(t,n)=>{let[r,i,a,o,s,c]=t.map(e=>e instanceof F?void 0:e),l=L(r??null),u=Bs(i,n),d=Oo(a,1),f=Oo(o,0),p=Oo(s,0);if(l instanceof j)return l;if(u instanceof j)return u;if(d instanceof j)return d;if(f instanceof j)return f;if(p instanceof j)return p;let m=Math.trunc(d);if(m===0||Math.abs(m)>Math.max(l.length,1))return M.VALUE;if(u.length>0&&u.every(e=>e===``))return m>0==(e===`before`)?``:l;let h=Xs(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?M.NA:c}}z(`TEXTBEFORE`,`vr?vvvv`,Zs(`before`)),z(`TEXTAFTER`,`vr?vvvv`,Zs(`after`)),R(`HYPERLINK`,1,2,(e,t)=>t===void 0?e??``:t),R(`ENCODEURL`,1,1,Us(e=>encodeURIComponent(e)));for(let e of[`LEN`,`LEFT`,`RIGHT`,`MID`,`FIND`,`SEARCH`,`REPLACE`])So(`${e}B`,e);let Qs=e=>{let t=I(e);return t instanceof j?t:t<0||t>=2958466?M.NUM:Math.floor(t)},$s=e=>e%4==0&&e%100!=0||e%400==0,ec=(e,t)=>t===2?$s(e)?29:28:[4,6,9,11].includes(t)?30:31,tc=e=>e.month===2&&e.day===ec(e.year,2);R(`DATE`,3,3,Do((e=0,t=1,n=1)=>{let r=Math.trunc(e);if(r<0||r>9999)return M.NUM;let i=Wn(r<1900?r+1900:r,Math.trunc(t),Math.trunc(n));return Number.isFinite(i)&&i>=0&&i<=2958465?i:M.NUM})),R(`TIME`,3,3,Do((e=0,t=0,n=0)=>{let r=Math.trunc(e)*3600+Math.trunc(t)*60+Math.trunc(n);return r<0?M.NUM:r%86400/86400})),R(`YEAR`,1,1,e=>{let t=Qs(e);return t instanceof j?t:Gn(t).year}),R(`MONTH`,1,1,e=>{let t=Qs(e);return t instanceof j?t:Gn(t).month}),R(`DAY`,1,1,e=>{let t=Qs(e);return t instanceof j?t:Gn(t).day});let nc=e=>{let t=I(e);return t instanceof j?t:t<0?M.NUM:Math.round((t-Math.floor(t))*86400)%86400};R(`HOUR`,1,1,e=>{let t=nc(e);return t instanceof j?t:Math.floor(t/3600)}),R(`MINUTE`,1,1,e=>{let t=nc(e);return t instanceof j?t:Math.floor(t/60)%60}),R(`SECOND`,1,1,e=>{let t=nc(e);return t instanceof j?t:t%60}),R(`DATEVALUE`,1,1,e=>{let t=L(e);if(t instanceof j)return t;let n=an(t)??ln(t);return typeof n?.value==`number`?Math.floor(n.value):M.VALUE}),R(`TIMEVALUE`,1,1,e=>{let t=L(e);if(t instanceof j)return t;let n=on(t)??ln(t);return typeof n?.value==`number`?n.value-Math.floor(n.value):M.VALUE});let rc=e=>(e%7+6)%7;R(`WEEKDAY`,1,2,(e,t)=>{let n=Qs(e);if(n instanceof j)return n;let r=t==null?1:I(t);if(r instanceof j)return r;let i=rc(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:M.NUM});let ic=e=>{let t=e-(rc(e)+6)%7+3,{year:n}=Gn(t);return Math.floor((t-Wn(n,1,1))/7)+1};R(`ISOWEEKNUM`,1,1,e=>{let t=Qs(e);return t instanceof j?t:ic(t)}),R(`WEEKNUM`,1,2,(e,t)=>{let n=Qs(e);if(n instanceof j)return n;let r=t==null?1:I(t);if(r instanceof j)return r;if(r===21)return ic(n);let i=r===1?0:r===2?1:r>=11&&r<=17?(r-10)%7:-1;if(i<0)return M.NUM;let a=Wn(Gn(n).year,1,1),o=(rc(a)+7-i)%7;return Math.floor((n-a+o)/7)+1});let ac=(e,t)=>{let{year:n,month:r,day:i}=Gn(e),a=n*12+r-1+t,o=Math.floor(a/12),s=a-o*12+1;return Wn(o,s,Math.min(i,ec(o,s)))};R(`EDATE`,2,2,(e,t)=>{let n=Qs(e),r=I(t);if(n instanceof j)return n;if(r instanceof j)return r;let i=ac(n,Math.trunc(r));return i<0?M.NUM:i}),R(`EOMONTH`,2,2,(e,t)=>{let n=Qs(e),r=I(t);if(n instanceof j)return n;if(r instanceof j)return r;let i=Gn(ac(n,Math.trunc(r))),a=Wn(i.year,i.month,ec(i.year,i.month));return a<0?M.NUM:a}),R(`DAYS`,2,2,(e,t)=>{let n=Qs(e),r=Qs(t);return n instanceof j?n:r instanceof j?r:n-r}),R(`DATEDIF`,3,3,(e,t,n)=>{let r=Qs(e),i=Qs(t),a=L(n);if(r instanceof j)return r;if(i instanceof j)return i;if(a instanceof j)return a;if(r>i)return M.NUM;let o=Gn(r),s=Gn(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,t=s.month===1?s.year-1:s.year;return ec(t,e)-o.day+s.day}case`YD`:{let e=s.year-o.year-+(c%12<0),t=Math.floor(c/12),n=ac(r,t*12);return e>=0?i-n:M.NUM}default:return M.NUM}});function oc(e,t,n){let r=Gn(e),i=Gn(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===ec(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}R(`DAYS360`,2,3,(e,t,n)=>{let r=Qs(e),i=Qs(t),a=n!==void 0&&io(n);return r instanceof j?r:i instanceof j?i:a instanceof j?a:oc(r,i,a)});function sc(e,t,n){let[r,i]=e<=t?[e,t]:[t,e],a=Gn(r),o=Gn(i),s=i-r;switch(n){case 0:{let e=a.day,t=o.day;return tc(a)&&(tc(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 oc(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=$s(a.year);else{let t=e=>$s(e)?Wn(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/((Wn(o.year+1,1,1)-Wn(a.year,1,1))/e)}}}R(`YEARFRAC`,2,3,(e,t,n)=>{let r=Qs(e),i=Qs(t),a=n==null?0:I(n);if(r instanceof j)return r;if(i instanceof j)return i;if(a instanceof j)return a;let o=Math.trunc(a);return o<0||o>4?M.NUM:sc(r,i,o)});function cc(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 M.VALUE;let t=e.split(``).map(e=>e===`1`);return[t[6]??!1,...t.slice(0,6)]}let n=I(e);return n instanceof j?n:n>=1&&n<=7?t((n+5)%7,(n+6)%7):n>=11&&n<=17?t(n-11):M.NUM}function lc(e,t){if(e===void 0||e instanceof F)return/* @__PURE__ */ new Set;let n=To([e],t);return n instanceof j?n:new Set(n.map(e=>Math.floor(e)))}function uc(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[rc(o)]!==!0&&!r.has(o)&&(a+=i);return a}function dc(e,t,n,r){if(n.every(Boolean))return M.VALUE;let i=t<0?-1:1,a=e;for(let e=Math.abs(t);e>0;)a+=i,n[rc(a)]!==!0&&!r.has(a)&&--e;return a<0?M.NUM:a}let fc=e=>(t,n)=>{let r=Qs(n.calc.scalar(t[0],n.frame)),i=Qs(n.calc.scalar(t[1],n.frame));if(r instanceof j)return r;if(i instanceof j)return i;let a=e?t[2]:void 0,o=cc(a===void 0||a instanceof F?void 0:n.calc.scalar(a,n.frame));if(o instanceof j)return o;let s=lc(t[e?3:2],n);return s instanceof j?s:uc(r,i,o,s)},pc=e=>(t,n)=>{let r=Qs(n.calc.scalar(t[0],n.frame)),i=I(n.calc.scalar(t[1],n.frame));if(r instanceof j)return r;if(i instanceof j)return i;let a=e?t[2]:void 0,o=cc(a===void 0||a instanceof F?void 0:n.calc.scalar(a,n.frame));if(o instanceof j)return o;let s=lc(t[e?3:2],n);return s instanceof j?s:dc(r,Math.trunc(i),o,s)};z(`NETWORKDAYS`,`vv?r`,fc(!1)),z(`NETWORKDAYS.INTL`,`vv?vr`,fc(!0)),z(`WORKDAY`,`vv?r`,pc(!1)),z(`WORKDAY.INTL`,`vv?vr`,pc(!0)),z(`NOW`,``,(e,t)=>t.calc.nowSerial(),{volatile:!0}),z(`TODAY`,``,(e,t)=>Math.floor(t.calc.nowSerial()),{volatile:!0});function mc(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}let hc=(e,t)=>{let n=[];return wo([e],t,e=>n.push(e)),n},gc=(e,t)=>{let n=hc(e[0],t),r=hc(e[1],t);if(n.length!==r.length)return M.NUM;let i=[],a=[];for(let[e,t]of n.entries()){let n=r[e]??null;if(t instanceof j)return t;if(n instanceof j)return n;if(typeof t==`number`){if(typeof n!=`number`)return M.VALUE;i.push(t),a.push(Math.floor(n))}}return i.length===0?M.NUM:{values:i,dates:a}};z(`XNPV`,`vrr`,(e,t)=>{let n=I(t.calc.scalar(e[0],t.frame));if(n instanceof j)return n;let r=gc(e.slice(1),t);return r instanceof j?r:n<=0?M.NUM:mc(n,r.values,r.dates)}),z(`XIRR`,`rr?v`,(e,t)=>{let n=gc(e,t);if(n instanceof j)return n;let{values:r,dates:i}=n;if(!r.some(e=>e>0)||!r.some(e=>e<0))return M.NUM;let a=e[2]===void 0||e[2]instanceof F?.1:I(t.calc.scalar(e[2],t.frame));if(a instanceof j)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 M.NUM;if(Math.abs(n-s)<1e-10)return n;s=n<=-1?(s-1)/2:n}return M.NUM});let _c=(e,t)=>{R(e,1,1,e=>t(e),{errors:!0})};_c(`ISBLANK`,e=>e==null),_c(`ISNUMBER`,e=>typeof e==`number`),_c(`ISTEXT`,e=>typeof e==`string`),_c(`ISNONTEXT`,e=>typeof e!=`string`),_c(`ISLOGICAL`,e=>typeof e==`boolean`),_c(`ISERROR`,e=>e instanceof j),_c(`ISERR`,e=>e instanceof j&&e!==M.NA),_c(`ISNA`,e=>e===M.NA);let vc=(e,t)=>{let n=I(e);return n instanceof j?n:Math.abs(Math.trunc(n))%2===t};R(`ISEVEN`,1,1,e=>vc(e,0)),R(`ISODD`,1,1,e=>vc(e,1)),R(`N`,1,1,e=>typeof e==`number`?e:typeof e==`boolean`?+!!e:e instanceof j?e:0,{errors:!0}),z(`NA`,``,()=>M.NA),z(`TYPE`,`r`,(e,t)=>{let n=t.calc.flat(e[0]);return n instanceof N?64:typeof n==`number`||n===null?1:typeof n==`string`?2:typeof n==`boolean`?4:16});let yc=[M.NULL,M.DIV0,M.VALUE,M.REF,M.NAME,M.NUM,M.NA];R(`ERROR.TYPE`,1,1,e=>{let t=e instanceof j?yc.indexOf(e):-1;return t<0?M.NA:t+1},{errors:!0}),xo(`ISREF`,1,1,(e,t)=>{let n=e[0];if(!n)return!1;let r=t.calc.eval(n,t.frame);return r instanceof P||r instanceof or});let bc=e=>e instanceof P?e.sheet.at(e.top,e.left):void 0;xo(`ISFORMULA`,1,1,(e,t)=>{let n=e[0];if(!n)return M.VALUE;let r=t.calc.eval(n,t.frame);return r instanceof sr?M.VALUE:bc(r)instanceof ka}),xo(`FORMULATEXT`,1,1,(e,t)=>{let n=e[0];if(!n)return M.VALUE;let r=bc(t.calc.eval(n,t.frame));return r instanceof ka?r.text:M.NA}),z(`CELL`,`v?r`,(e,t)=>{let n=L(t.calc.scalar(e[0],t.frame));if(n instanceof j)return n;let r=e[1],i=r instanceof P?r:new P(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 m({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 M.VALUE}}),z(`TABLE`,`?rrrrr`,()=>M.NA);var xc=/* @__PURE__ */ o(((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,y;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)),y=-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)+y),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,y=g,b=(u-g)/v,x=y+b,S=0,ee=i-1,C=1;C<=v;C++){for(var te=0,ne=.5*(x+y),w=.5*(x-y),re=1;re<=a;re++){var ie,ae;o<re?(ie=a-re+1,ae=m[ie-1]):(ie=re,ae=-m[ie-1]);var oe=ne+w*ae,se=oe*oe;if(se>l)break;var ce=2*e.normal.cdf(oe,0,1,1,0),T=2*e.normal.cdf(oe,n,1,1,0),E=ce*.5-T*.5;E>=t.exp(s/ee)&&(E=h[ie-1]*t.exp(-(.5*se))*t.pow(E,ee),te+=E)}te*=2*w*i/t.sqrt(2*t.PI),S+=te,y=x,x+=b}return _+=S,_<=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,y=120,b=.5-.5*e,x=t.sqrt(t.log(1/(b*b))),S=x+((((x*f+u)*x+c)*x+o)*x+i)/((((x*p+d)*x+l)*x+s)*x+a);r<y&&(S+=(S*S*S+S)/r/4);var ee=m-h*S;return r<y&&(ee+=-g/r+_*S/r),S*(ee*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,y=.125,b=[.9894009349916499,.9445750230732326,.8656312023878318,.755404408355003,.6178762444026438,.45801677765722737,.2816035507792589,.09501250983763744],x=[.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 S=a*.5,ee=S*t.log(a)-a*t.log(2)-e.gammaln(S),C=S-1,te=a*.25,ne=a<=f?g:a<=p?_:a<=m?v:y;ee+=t.log(ne);for(var w=0,re=1;re<=50;re++){for(var ie=0,ae=(2*re-1)*ne,oe=1;oe<=c;oe++){var se,ce;l<oe?(se=oe-l-1,ce=ee+C*t.log(ae+b[se]*ne)-(b[se]*ne+ae)*te):(se=oe-1,ce=ee+C*t.log(ae-b[se]*ne)+(b[se]*ne-ae)*te);var T;if(ce>=u){T=l<oe?n*t.sqrt((b[se]*ne+ae)*.5):n*t.sqrt((-(b[se]*ne)+ae)*.5);var E=i(T,o,s)*x[se]*t.exp(ce);ie+=E}}if(re*ne>=1&&ie<=d)break;w+=ie}if(ie>d)throw Error(`tukey.cdf failed to converge`);return w>1&&(w=1),w},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})})),Sc=/* @__PURE__ */ o((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})})),Cc=/* @__PURE__ */ s({ABS:()=>Kd,ACCRINT:()=>Tg,ACOS:()=>qd,ACOSH:()=>Jd,ACOT:()=>Yd,ACOTH:()=>Xd,AGGREGATE:()=>Zd,AND:()=>i_,ARABIC:()=>Qd,ASIN:()=>$d,ASINH:()=>ef,ATAN:()=>tf,ATAN2:()=>nf,ATANH:()=>rf,AVEDEV:()=>Du,AVERAGE:()=>Ou,AVERAGEA:()=>ku,AVERAGEIF:()=>Au,AVERAGEIFS:()=>ju,BASE:()=>af,BESSELI:()=>nm,BESSELJ:()=>rm,BESSELK:()=>im,BESSELY:()=>am,BETA:()=>Mu,BETADIST:()=>eh,BETAINV:()=>th,BIN2DEC:()=>om,BIN2HEX:()=>sm,BIN2OCT:()=>cm,BINOM:()=>Nu,BINOMDIST:()=>nh,BITAND:()=>lm,BITLSHIFT:()=>um,BITOR:()=>dm,BITRSHIFT:()=>fm,BITXOR:()=>pm,CEILING:()=>of,CEILINGMATH:()=>rh,CEILINGPRECISE:()=>ih,CHAR:()=>$l,CHIDIST:()=>ah,CHIDISTRT:()=>oh,CHIINV:()=>sh,CHIINVRT:()=>ch,CHISQ:()=>Pu,CHITEST:()=>lh,CHOOSE:()=>Pl,CHOOSECOLS:()=>Fl,CHOOSEROWS:()=>Il,CLEAN:()=>eu,CODE:()=>tu,COLUMN:()=>Ll,COLUMNS:()=>Rl,COMBIN:()=>sf,COMBINA:()=>cf,COMPLEX:()=>mm,CONCAT:()=>ru,CONCATENATE:()=>nu,CONFIDENCE:()=>Fu,CONVERT:()=>hm,CORREL:()=>Iu,COS:()=>lf,COSH:()=>uf,COT:()=>df,COTH:()=>ff,COUNT:()=>Lu,COUNTA:()=>Ru,COUNTBLANK:()=>zu,COUNTIF:()=>Bu,COUNTIFS:()=>Vu,COUPDAYS:()=>Eg,COVAR:()=>uh,COVARIANCE:()=>Hu,COVARIANCEP:()=>dh,COVARIANCES:()=>fh,CRITBINOM:()=>ph,CSC:()=>pf,CSCH:()=>mf,CUMIPMT:()=>Dg,CUMPRINC:()=>Og,DATE:()=>kp,DATEDIF:()=>Ap,DATEVALUE:()=>jp,DAVERAGE:()=>cg,DAY:()=>Mp,DAYS:()=>Pp,DAYS360:()=>Fp,DB:()=>kg,DCOUNT:()=>lg,DCOUNTA:()=>ug,DDB:()=>Ag,DEC2BIN:()=>gm,DEC2HEX:()=>_m,DEC2OCT:()=>vm,DECIMAL:()=>hf,DEGREES:()=>gf,DELTA:()=>ym,DEVSQ:()=>Uu,DGET:()=>dg,DISC:()=>jg,DMAX:()=>fg,DMIN:()=>pg,DOLLAR:()=>iu,DOLLARDE:()=>Mg,DOLLARFR:()=>Ng,DPRODUCT:()=>mg,DROP:()=>zl,DSTDEV:()=>hg,DSTDEVP:()=>gg,DSUM:()=>_g,DVAR:()=>vg,DVARP:()=>yg,EDATE:()=>Ip,EFFECT:()=>Pg,EOMONTH:()=>Lp,ERF:()=>bm,ERFC:()=>xm,ERFCPRECISE:()=>mh,ERFPRECISE:()=>hh,ERROR:()=>bl,EVEN:()=>_f,EXACT:()=>au,EXP:()=>vf,EXPAND:()=>Bl,EXPON:()=>Wu,EXPONDIST:()=>gh,F:()=>Gu,FACT:()=>bf,FACTDOUBLE:()=>xf,FALSE:()=>a_,FDIST:()=>_h,FDISTRT:()=>vh,FIND:()=>ou,FINV:()=>yh,FINVRT:()=>bh,FISHER:()=>Ku,FISHERINV:()=>qu,FIXED:()=>su,FLOOR:()=>Sf,FLOORMATH:()=>xh,FLOORPRECISE:()=>Sh,FORECAST:()=>Ju,FREQUENCY:()=>Yu,FTEST:()=>Ch,FV:()=>Fg,FVSCHEDULE:()=>Ig,GAMMA:()=>Xu,GAMMADIST:()=>wh,GAMMAINV:()=>Th,GAMMALN:()=>Zu,GAMMALNPRECISE:()=>Eh,GAUSS:()=>Qu,GCD:()=>Cf,GEOMEAN:()=>$u,GESTEP:()=>Sm,GROWTH:()=>ed,HARMEAN:()=>td,HEX2BIN:()=>Cm,HEX2DEC:()=>wm,HEX2OCT:()=>Tm,HLOOKUP:()=>Vl,HOUR:()=>Rp,HSTACK:()=>Zl,HYPGEOM:()=>nd,HYPGEOMDIST:()=>Dh,IF:()=>o_,IFERROR:()=>c_,IFNA:()=>l_,IFS:()=>s_,IMABS:()=>Em,IMAGINARY:()=>Dm,IMARGUMENT:()=>Om,IMCONJUGATE:()=>km,IMCOS:()=>Am,IMCOSH:()=>jm,IMCOT:()=>Mm,IMCSC:()=>Km,IMCSCH:()=>qm,IMDIV:()=>Nm,IMEXP:()=>Pm,IMLN:()=>Fm,IMLOG10:()=>Im,IMLOG2:()=>Lm,IMPOWER:()=>Rm,IMPRODUCT:()=>zm,IMREAL:()=>Bm,IMSEC:()=>Vm,IMSECH:()=>Hm,IMSIN:()=>Um,IMSINH:()=>Wm,IMSQRT:()=>Gm,IMSUB:()=>Jm,IMSUM:()=>Ym,IMTAN:()=>Xm,INDEX:()=>Hl,INT:()=>wf,INTERCEPT:()=>rd,IPMT:()=>Lg,IRR:()=>Rg,ISBLANK:()=>xl,ISERR:()=>Sl,ISERROR:()=>Cl,ISEVEN:()=>wl,ISLOGICAL:()=>Tl,ISNA:()=>El,ISNONTEXT:()=>Dl,ISNUMBER:()=>Ol,ISO:()=>Tf,ISODD:()=>kl,ISOWEEKNUM:()=>zp,ISPMT:()=>zg,ISTEXT:()=>Al,KURT:()=>id,LARGE:()=>ad,LCM:()=>Ef,LEFT:()=>cu,LEN:()=>lu,LINEST:()=>od,LN:()=>Df,LOG:()=>Of,LOG10:()=>kf,LOGEST:()=>sd,LOGINV:()=>Oh,LOGNORM:()=>cd,LOGNORMDIST:()=>kh,LOGNORMINV:()=>Ah,LOOKUP:()=>Ul,LOWER:()=>uu,MATCH:()=>Wl,MAX:()=>ld,MAXA:()=>ud,MAXIFS:()=>dd,MEDIAN:()=>fd,MID:()=>du,MIN:()=>pd,MINA:()=>md,MINIFS:()=>hd,MINUTE:()=>Bp,MIRR:()=>Bg,MMULT:()=>Af,MOD:()=>jf,MODE:()=>gd,MODEMULT:()=>jh,MODESNGL:()=>Mh,MONTH:()=>Vp,MROUND:()=>Mf,MULTINOMIAL:()=>Nf,MUNIT:()=>Pf,N:()=>jl,NA:()=>Ml,NEGBINOM:()=>_d,NEGBINOMDIST:()=>Nh,NETWORKDAYS:()=>Hp,NETWORKDAYSINTL:()=>Ph,NOMINAL:()=>Vg,NORM:()=>vd,NORMDIST:()=>Fh,NORMINV:()=>Ih,NORMSDIST:()=>Lh,NORMSINV:()=>Rh,NOT:()=>u_,NOW:()=>Up,NPER:()=>Hg,NPV:()=>Ug,NUMBERVALUE:()=>fu,OCT2BIN:()=>Zm,OCT2DEC:()=>Qm,OCT2HEX:()=>$m,ODD:()=>Ff,OR:()=>d_,PDURATION:()=>Wg,PEARSON:()=>yd,PERCENTILE:()=>bd,PERCENTILEEXC:()=>zh,PERCENTILEINC:()=>Bh,PERCENTRANK:()=>xd,PERCENTRANKEXC:()=>Vh,PERCENTRANKINC:()=>Hh,PERMUT:()=>Sd,PERMUTATIONA:()=>Cd,PHI:()=>wd,PI:()=>If,PMT:()=>Gg,POISSON:()=>Td,POISSONDIST:()=>Uh,POWER:()=>Lf,PPMT:()=>Kg,PRICEDISC:()=>qg,PROB:()=>Ed,PRODUCT:()=>Rf,PROPER:()=>pu,PV:()=>Jg,QUARTILE:()=>Dd,QUARTILEEXC:()=>Wh,QUARTILEINC:()=>Gh,QUOTIENT:()=>zf,RADIANS:()=>Bf,RAND:()=>Vf,RANDBETWEEN:()=>Hf,RANK:()=>Od,RANKAVG:()=>Kh,RANKEQ:()=>qh,RATE:()=>Yg,REPLACE:()=>mu,REPT:()=>hu,RIGHT:()=>gu,ROMAN:()=>Uf,ROUND:()=>Gf,ROUNDDOWN:()=>Kf,ROUNDUP:()=>qf,ROW:()=>kd,ROWS:()=>Gl,RRI:()=>Xg,RSQ:()=>Ad,SEARCH:()=>_u,SEC:()=>Jf,SECH:()=>Yf,SECOND:()=>Wp,SERIESSUM:()=>Xf,SIGN:()=>Zf,SIN:()=>Qf,SINH:()=>$f,SKEW:()=>jd,SKEWP:()=>Jh,SLN:()=>Zg,SLOPE:()=>Md,SMALL:()=>Nd,SORT:()=>Kl,SQRT:()=>ep,SQRTPI:()=>tp,STANDARDIZE:()=>Pd,STDEV:()=>Fd,STDEVA:()=>Id,STDEVP:()=>Yh,STDEVPA:()=>Ld,STDEVS:()=>Xh,STEYX:()=>Rd,SUBSTITUTE:()=>vu,SUBTOTAL:()=>np,SUM:()=>rp,SUMIF:()=>ip,SUMIFS:()=>ap,SUMPRODUCT:()=>op,SUMSQ:()=>sp,SUMX2MY2:()=>cp,SUMX2PY2:()=>lp,SUMXMY2:()=>up,SWITCH:()=>m_,SYD:()=>Qg,T:()=>yu,TAKE:()=>ql,TAN:()=>dp,TANH:()=>fp,TBILLEQ:()=>$g,TBILLPRICE:()=>e_,TBILLYIELD:()=>t_,TDIST:()=>Zh,TDISTRT:()=>Qh,TEXT:()=>bu,TEXTJOIN:()=>xu,TIME:()=>Gp,TIMEVALUE:()=>Kp,TINV:()=>$h,TODAY:()=>qp,TRANSPOSE:()=>Jl,TREND:()=>zd,TRIM:()=>Su,TRIMMEAN:()=>Bd,TRUE:()=>f_,TRUNC:()=>pp,TTEST:()=>eg,TYPE:()=>Nl,UNICHAR:()=>Cu,UNICODE:()=>wu,UNIQUE:()=>Yl,UPPER:()=>Tu,VALUE:()=>Eu,VAR:()=>Vd,VARA:()=>Hd,VARP:()=>tg,VARPA:()=>Ud,VARS:()=>ng,VLOOKUP:()=>Xl,VSTACK:()=>Ql,WEEKDAY:()=>Jp,WEEKNUM:()=>Yp,WEIBULL:()=>Wd,WEIBULLDIST:()=>rg,WORKDAY:()=>Xp,WORKDAYINTL:()=>ig,XIRR:()=>n_,XNPV:()=>r_,XOR:()=>p_,YEAR:()=>Zp,YEARFRAC:()=>em,Z:()=>Gd,ZTEST:()=>ag,utils:()=>h_}),V=/* @__PURE__ */ l(xc(),1),wc=/* @__PURE__ */ l(Sc(),1);let Tc=/* @__PURE__ */ Error(`#NULL!`),Ec=/* @__PURE__ */ Error(`#DIV/0!`),H=/* @__PURE__ */ Error(`#VALUE!`),Dc=/* @__PURE__ */ Error(`#REF!`),Oc=/* @__PURE__ */ Error(`#NAME?`),U=/* @__PURE__ */ Error(`#NUM!`),W=/* @__PURE__ */ Error(`#N/A`),kc=/* @__PURE__ */ Error(`#ERROR!`),Ac=/* @__PURE__ */ Error(`#GETTING_DATA`),jc=/* @__PURE__ */ Error(`#CALC!`);var Mc=/*#__PURE__*/ Object.freeze({__proto__:null,calc:jc,data:Ac,div0:Ec,error:kc,na:W,name:Oc,nil:Tc,num:U,ref:Dc,value:H});let Nc=!1;function Pc(){Nc=!0}function Fc(){Nc=!1}function Ic(e){e<60&&(e+=1);let t=Math.floor(e-25569)*86400,n=/* @__PURE__ */ 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 Lc(e){let t=new Date(1900,0,1),n=e>-22038912e5?2:1;return Math.ceil((e-t)/864e5)+n}var Rc=/*#__PURE__*/ Object.freeze({__proto__:null,dateToSerial:Lc,get returnSerial(){return Nc},serialToDate:Ic,useDate:Fc,useSerial:Pc});let zc=[`>`,`>=`,`<`,`<=`,`=`,`<>`],Bc=`operator`,Vc=`literal`,Hc=[Bc,Vc],Uc=Bc,Wc=Vc;function Gc(e,t){if(Hc.indexOf(t)===-1)throw Error(`Unsupported token type: `+t);return{value:e,type:t}}function Kc(e){return typeof e==`string`&&/^\d+(\.\d+)?$/.test(e)&&(e=e.indexOf(`.`)===-1?parseInt(e,10):parseFloat(e)),e}function qc(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 Jc(e){let t=``,n=[];for(let r=0;r<e.length;r++){let i=e[r];r===0&&zc.indexOf(i)>=0?n.push(Gc(i,Uc)):t+=i}return t.length>0&&n.push(Gc(Kc(t),Wc)),n.length>0&&n[0].type!==Uc&&n.unshift(Gc(`=`,Uc)),n}function Yc(e){let t=[],n;for(let r=0;r<e.length;r++){let i=e[r];switch(i.type){case Uc:n=i.value;break;case Wc:t.push(i.value)}}return Xc(t,n)}function Xc(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 Zc(e){return Jc(qc(e))}let Qc=Yc;function $c(e){let t=[];return el(e,e=>{t.push(e)}),t}function el(e,t){let n=-1,r=e.length;for(;++n<r&&t(e[n],n,e)!==!1;);return e}function tl(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=Y(n);e[t]=r instanceof Error?0:r}}return e}function nl(e){return[e.length,e.reduce((e,t)=>Math.max(e,t.length),0)]}function rl(e,t){let n=[e,t];return n.some(e=>!yl(e))?W:n.some(e=>e<=0)?H:Array.from({length:e},()=>Array.from({length:t},()=>void 0))}function il(e,t){if(!e)return H;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 G(){let e;if(arguments.length===1){let t=arguments[0];e=sl(t)?$c.apply(null,arguments):[t]}else e=Array.from(arguments);for(;!cl(e);)e=al(e);return e}function al(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 ol(e,t){return t||=1,!e||typeof e.slice!=`function`?e:e.slice(0,e.length-t)}function sl(e){return e!=null&&typeof e.length==`number`&&typeof e!=`string`}function cl(e){if(!e)return!1;for(let t=0;t<e.length;++t)if(Array.isArray(e[t]))return!1;return!0}function ll(e,t){return t||=1,!e||typeof e.slice!=`function`?e:e.slice(t)}function ul(e){return e?e[0].map((t,n)=>e.map(e=>e[n])):H}function dl(e,t){let n=null;return el(e,(e,r)=>{if(e[0]===t)return n=r,!1}),n??H}function K(){for(let e=0;e<arguments.length;e++)if(arguments[e]instanceof Error)return arguments[e]}function q(){let e=arguments.length;for(;e--;)if(arguments[e]instanceof Error)return!0;return!1}function fl(e){let t=0x5af3107a4000;return Math.round(e*t)/t}function pl(){return G.apply(null,arguments).filter(e=>typeof e==`number`)}function ml(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)||H}function J(e){if(!isNaN(e)){if(e instanceof Date)return new Date(e);let t=parseFloat(e);return t<0||t>=2958466?U:Ic(t)}return typeof e==`string`&&(e=/(\d{4})-(\d\d?)-(\d\d?)$/.test(e)?/* @__PURE__ */ new Date(e+`T00:00:00.000`):new Date(e),!isNaN(e))?e:H}function hl(e){let t=e.length,n;for(;t--;){if(n=J(e[t]),n===H)return n;e[t]=n}return e}function Y(e){return e instanceof Error?e:e==null?0:(typeof e==`boolean`&&(e=+e),!isNaN(e)&&e!==``?parseFloat(e):H)}function X(e){let t;if(!e||(t=e.length)===0)return H;let n;for(;t--;){if(e[t]instanceof Error)return e[t];if(n=Y(e[t]),n instanceof Error)return n;e[t]=n}return e}function gl(e){return e instanceof Error?e:e==null?``:e.toString()}function _l(){let e=arguments.length;for(;e--;)if(typeof arguments[e]==`string`)return!0;return!1}function vl(){let e=$c(arguments),t=X(G(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]=G(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=Zc(i+``),t=[Gc(r,Wc)].concat(e);s=Qc(t)}if(!s){a=!1;break}a=!0}a&&i.push(t[e])}return i}function yl(e){return e!=null}let bl={};bl.TYPE=e=>{switch(e){case Tc:return 1;case Ec:return 2;case H:return 3;case Dc:return 4;case Oc:return 5;case U:return 6;case W:return 7;case Ac:return 8}return W};function xl(e){return e===null}function Sl(e){return[H,Dc,Ec,U,Oc,Tc].indexOf(e)>=0||typeof e==`number`&&(isNaN(e)||!isFinite(e))}function Cl(e){return Sl(e)||e===W}function wl(e){return!(Math.floor(Math.abs(e))&1)}function Tl(e){return e===!0||e===!1}function El(e){return e===W}function Dl(e){return typeof e!=`string`}function Ol(e){return typeof e==`number`&&!isNaN(e)&&isFinite(e)}function kl(e){return!!(Math.floor(Math.abs(e))&1)}function Al(e){return typeof e==`string`}function jl(e){return Ol(e)?e:e instanceof Date?e.getTime():e===!0?1:e===!1?0:Cl(e)?e:0}function Ml(){return W}function Nl(e){if(Ol(e))return 1;if(Al(e))return 2;if(Tl(e))return 4;if(Cl(e))return 16;if(Array.isArray(e))return 64}function Pl(){if(arguments.length<2)return W;let e=arguments[0];return e<1||e>254||arguments.length<e+1?H:arguments[e]}function Fl(e,t,...n){if(!Array.isArray(e))return H;let r=G([t,...n]),[i,a]=nl(e);if(r.some(e=>{if(!yl(e))return!0;let t=Math.abs(e);return!(0<t&&t<=a)}))return H;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 Il(e,t,...n){if(!Array.isArray(e))return H;let r=G([t,...n]);return r.some(t=>{if(!yl(t))return!0;let n=Math.abs(t);return!(0<n&&n<=e.length)})?H:r.map(t=>t<0?t+e.length+1:t).reduce((t,n)=>{let r=[...e[--n]].map(e=>yl(e)?e:0);return t.push(r),t},[])}function Ll(e,t){if(arguments.length!==2)return W;if(t<0)return U;if(!(e instanceof Array)||typeof t!=`number`)return H;if(e.length!==0)return V.default.col(e,t)}function Rl(e){return arguments.length===1?e instanceof Array?e.length===0?0:V.default.cols(e):H:W}function zl(e,t,n){if(q(e,t,n))return K(e,t,n);if(!(e instanceof Array))return H;let r=[],[i,a]=nl(e),o=0,s=i;if(typeof t==`number`){if(Math.abs(t)>i)return jc;t>0?o=t:t<0&&(s+=t)}let c=0,l=a;if(typeof n==`number`){if(Math.abs(n)>a)return jc;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 Bl(e,t,n,r){let[i,a]=nl(e);if(yl(t)||(t=i),yl(n)||(n=a),t<i||n<a)return H;let o=rl(t,n);for(let s=0;s<t;s++)for(let t=0;t<n;t++){let n=e[s]?.[t];yl(n)||(n=s<i&&t<a?0:r??W),o[s][t]=n}return o}function Vl(e,t,n,r){return Xl(e,ul(t),n,r)}function Hl(e,t,n){let r=K(e,t,n);if(r)return r;if(!Array.isArray(e))return H;let i=e.length>0&&!Array.isArray(e[0]);return i&&!n?(n=t,t=1):(n||=1,t||=1),n<0||t<0?H:i&&t===1&&n<=e.length?e[n-1]:t<=e.length&&n<=e[t-1].length?e[t-1][n-1]:Dc}function Ul(e,t,n){t=G(t),n=n?G(n):t;let r=typeof e==`number`,i=W;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 Wl(e,t,n){if(!e&&e!==0||!t||(arguments.length===2&&(n=1),t=G(t),!(t instanceof Array))||n!==-1&&n!==0&&n!==1)return W;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||W}function Gl(e){return arguments.length===1?e instanceof Array?e.length===0?0:V.default.rows(e):H:W}function Kl(e,t=1,n=1,r=!1){if(!e||!Array.isArray(e))return W;if(e.length===0)return 0;if(t=Y(t),!t||t<1||(n=Y(n),n!==1&&n!==-1))return H;if(r=ml(r),typeof r!=`boolean`)return Oc;let i=e=>e.sort((e,r)=>(e=gl(e[t-1]),r=gl(r[t-1]),n===1?e<r?n*-1:n:e>r?n:n*-1)),a=il(e),o=r?ul(a):a;return t>=1&&t<=o[0].length?r?ul(i(o)):i(o):H}function ql(e,t,n){if(q(e,t,n))return K(e,t,n);if(!(e instanceof Array))return H;let[r,i]=nl(e),a=0,o=r-1;if(typeof t==`number`){if(t===0)return jc;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 jc;Math.abs(n)<=i&&(n<0?s=i+n:c=n-1)}let l=rl(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 Jl(e){return e?ul(il(e)):W}function Yl(){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 Xl(e,t,n,r){if(!t||!n)return W;r=r!==0&&r!==!1;let i=W,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]:Dc;break}!a&&(o&&r&&u<=e||r&&typeof u==`string`&&u.localeCompare(e)<0)&&(i=n<l.length+1?l[n-1]:Dc),o&&u>e&&(a=!0)}return i}function Zl(e,...t){let n=[e,...t],r=0,i=0,a=[];for(let e of n){let[t,n]=nl(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:W);s++}}return o}function Ql(e,...t){let n=[e,...t],r=0,i=0;for(let e of n){let[t,n]=nl(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:W)}return a}function $l(e){return e=Y(e),e===0?H:e instanceof Error?e:String.fromCharCode(e)}function eu(e){return q(e)?e:(e||=``,e.replace(/[\0-\x1F]/g,``))}function tu(e){if(q(e))return e;e||=``;let t=e.charCodeAt(0);return isNaN(t)&&(t=H),t}function nu(){let e=G(arguments),t=K.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(``)}let ru=nu;function iu(e,t=2){if(e=Y(e),isNaN(e))return H;e=Gf(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 au(e,t){return arguments.length===2?K(e,t)||(e=gl(e),t=gl(t),e===t):W}function ou(e,t,n){if(arguments.length<2)return W;e=gl(e),t=gl(t),n=n===void 0?0:n;let r=t.indexOf(e,n-1);return r===-1?H:r+1}function su(e,t=2,n=!1){if(e=Y(e),isNaN(e)||(t=Y(t),isNaN(t)))return H;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 cu(e,t){return K(e,t)||(e=gl(e),t=t===void 0?1:t,t=Y(t),t instanceof Error||typeof e!=`string`?H:e.substring(0,t))}function lu(e){return arguments.length===0?kc:e instanceof Error?e:Array.isArray(e)?H:gl(e).length}function uu(e){return arguments.length===1?(e=gl(e),q(e)?e:e.toLowerCase()):H}function du(e,t,n){if(q(e,t,n))return K(e,t,n);let r=[t,n].map(e=>Y(e));if(!r.every(e=>!(e instanceof Error)&&e>0))return H;yl(e)?typeof e!=`string`&&(e=String(e)):e=``,[t,n]=r;let i=t-1,a=i+n;return e.substring(i,a)}function fu(e,t,n){return e=yl(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,``))):W}function pu(e){return q(e)?e:isNaN(e)&&typeof e==`number`?H:(e=gl(e),e.replace(/\w\S*/g,e=>e.charAt(0).toUpperCase()+e.substr(1).toLowerCase()))}function mu(e,t,n,r){return t=Y(t),n=Y(n),q(t,n)||typeof e!=`string`||typeof r!=`string`?H:e.substr(0,t-1)+r+e.substr(t-1+n)}function hu(e,t){return K(e,t)||(e=gl(e),t=Y(t),t instanceof Error?t:Array(t+1).join(e))}function gu(e,t){return K(e,t)||(e=gl(e),t=t===void 0?1:t,t=Y(t),t instanceof Error?t:e.substring(e.length-t))}function _u(e,t,n){let r;return typeof e!=`string`||typeof t!=`string`?H:(n=n===void 0?0:n,r=t.toLowerCase().indexOf(e.toLowerCase(),n-1)+1,r===0?H:r)}function vu(e,t,n,r){if(arguments.length<3)return W;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 H;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 yu(e){return e instanceof Error||typeof e==`string`?e:``}function bu(e,t){if(e===void 0||e instanceof Error||t instanceof Error)return W;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 H;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=su(e,i,a),e.startsWith(`-`)?(e=e.replace(`-`,``),e=`-`+n+e):e=n+e,r&&(e+=`%`),e}function xu(e,t,...n){if(typeof t!=`boolean`&&(t=ml(t)),arguments.length<3)return W;e??=``;let r=G(n),i=t?r.filter(e=>e):r;if(Array.isArray(e)){e=G(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=G(t),i.join(``)}return i.join(e)}function Su(e){return e=gl(e),e instanceof Error?e:e.replace(/\s+/g,` `).trim()}let Cu=$l,wu=tu;function Tu(e){return e=gl(e),e instanceof Error?e:e.toUpperCase()}function Eu(e){let t=K(e);if(t)return t;if(typeof e==`number`)return e;if(yl(e)||(e=``),typeof e!=`string`)return H;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)?H:(r||=0,n&&(r*=.01),r)}function Du(){let e=G(arguments).filter(yl);if(e.length===0)return U;let t=X(e);return t instanceof Error?t:V.default.sum((0,V.default)(t).subtract(V.default.mean(t)).abs()[0])/t.length}function Ou(){let e=G(arguments).filter(yl);if(e.length===0)return Ec;let t=K.apply(void 0,e);if(t)return t;let n=pl(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=U),o}function ku(){let e=G(arguments).filter(yl);if(e.length===0)return Ec;let t=K.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=U),o}function Au(e,t,n){if(arguments.length<=1)return W;if(n||=e,n=X(G(n).filter(yl)),e=G(e),n instanceof Error)return n;let r=0,i=0,a=t===void 0||t===`*`,o=a?null:Zc(t+``);for(let t=0;t<e.length;t++){let s=e[t];if(a)i+=n[t],r++;else{let e=[Gc(s,Wc)].concat(o);Qc(e)&&(i+=n[t],r++)}}return i/r}function ju(){let e=vl(...arguments),t=e.reduce((e,t)=>e+t,0)/e.length;return isNaN(t)?0:t}let Mu={};Mu.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=Y(e),t=Y(t),n=Y(n),i=Y(i),a=Y(a),q(e,t,n,i,a))?H:(e=(e-i)/(a-i),r?V.default.beta.cdf(e,t,n):V.default.beta.pdf(e,t,n))},Mu.INV=(e,t,n,r,i)=>(r=r===void 0?0:r,i=i===void 0?1:i,e=Y(e),t=Y(t),n=Y(n),r=Y(r),i=Y(i),q(e,t,n,r,i)?H:V.default.beta.inv(e,t,n)*(i-r)+r);let Nu={};Nu.DIST=(e,t,n,r)=>(e=Y(e),t=Y(t),n=Y(n),r=Y(r),q(e,t,n,r)?H:r?V.default.binomial.cdf(e,t,n):V.default.binomial.pdf(e,t,n)),Nu.DIST.RANGE=(e,t,n,r)=>{if(r=r===void 0?n:r,e=Y(e),t=Y(t),n=Y(n),r=Y(r),q(e,t,n,r))return H;let i=0;for(let a=n;a<=r;a++)i+=sf(e,a)*t**+a*(1-t)**(e-a);return i},Nu.INV=(e,t,n)=>{if(e=Y(e),t=Y(t),n=Y(n),q(e,t,n))return H;let r=0;for(;r<=e;){if(V.default.binomial.cdf(r,e,t)>=n)return r;r++}};let Pu={};Pu.DIST=(e,t,n)=>(e=Y(e),t=Y(t),q(e,t)?H:n?V.default.chisquare.cdf(e,t):V.default.chisquare.pdf(e,t)),Pu.DIST.RT=(e,t)=>!e|!t?W:e<1||t>10**10?U:typeof e!=`number`||typeof t!=`number`?H:1-V.default.chisquare.cdf(e,t),Pu.INV=(e,t)=>(e=Y(e),t=Y(t),q(e,t)?H:V.default.chisquare.inv(e,t)),Pu.INV.RT=(e,t)=>!e|!t?W:e<0||e>1||t<1||t>10**10?U:typeof e!=`number`||typeof t!=`number`?H:V.default.chisquare.inv(1-e,t),Pu.TEST=function(e,t){if(arguments.length!==2)return W;if(!(e instanceof Array)||!(t instanceof Array)||e.length!==t.length||e[0]&&t[0]&&e[0].length!==t[0].length)return H;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};let Fu={};Fu.NORM=(e,t,n)=>(e=Y(e),t=Y(t),n=Y(n),q(e,t,n)?H:V.default.normalci(1,e,t,n)[1]-1),Fu.T=(e,t,n)=>(e=Y(e),t=Y(t),n=Y(n),q(e,t,n)?H:V.default.tci(1,e,t,n)[1]-1);function Iu(e,t){return e=X(G(e)),t=X(G(t)),q(e,t)?H:V.default.corrcoeff(e,t)}function Lu(){return pl(G(arguments)).length}function Ru(){let e=G(arguments);return e.length-zu(e)}function zu(){let e=G(arguments),t=0,n;for(let r=0;r<e.length;r++)n=e[r],(n==null||n===``)&&t++;return t}function Bu(e,t){if(e=G(e),t===void 0||t===`*`)return e.length;let n=0,r=Zc(t+``);for(let t=0;t<e.length;t++){let i=e[t],a=[Gc(i,Wc)].concat(r);Qc(a)&&n++}return n}function Vu(){let e=$c(arguments),t=Array(G(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=G(e[n]),i=e[n+1];if(i!==void 0&&i!==`*`){let e=Zc(i+``);for(let n=0;n<r.length;n++){let i=r[n],a=[Gc(i,Wc)].concat(e);t[n]=t[n]&&Qc(a)}}}let n=0;for(let e=0;e<t.length;e++)t[e]&&n++;return n}let Hu={};Hu.P=(e,t)=>{if(e=X(G(e)),t=X(G(t)),q(e,t))return H;let n=V.default.mean(e),r=V.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},Hu.S=(e,t)=>(e=X(G(e)),t=X(G(t)),q(e,t)?H:V.default.covariance(e,t));function Uu(){let e=X(G(arguments));if(e instanceof Error)return e;let t=V.default.mean(e),n=0;for(let r=0;r<e.length;r++)n+=(e[r]-t)**2;return n}let Wu={};Wu.DIST=(e,t,n)=>(e=Y(e),t=Y(t),q(e,t)?H:n?V.default.exponential.cdf(e,t):V.default.exponential.pdf(e,t));let Gu={};Gu.DIST=(e,t,n,r)=>(e=Y(e),t=Y(t),n=Y(n),q(e,t,n)?H:r?V.default.centralF.cdf(e,t,n):V.default.centralF.pdf(e,t,n)),Gu.DIST.RT=function(e,t,n){return arguments.length===3?e<0||t<1||n<1?U:typeof e!=`number`||typeof t!=`number`||typeof n!=`number`?H:1-V.default.centralF.cdf(e,t,n):W},Gu.INV=(e,t,n)=>(e=Y(e),t=Y(t),n=Y(n),q(e,t,n)?H:e<=0||e>1?U:V.default.centralF.inv(e,t,n)),Gu.INV.RT=function(e,t,n){return arguments.length===3?e<0||e>1||t<1||t>10**10||n<1||n>10**10?U:typeof e!=`number`||typeof t!=`number`||typeof n!=`number`?H:V.default.centralF.inv(1-e,t,n):W},Gu.TEST=(e,t)=>{if(!e||!t||!(e instanceof Array)||!(t instanceof Array))return W;if(e.length<2||t.length<2)return Ec;let n=(e,t)=>{let n=0;for(let r=0;r<e.length;r++)n+=(e[r]-t)**2;return n},r=rp(e)/e.length,i=rp(t)/t.length;return n(e,r)/(e.length-1)/(n(t,i)/(t.length-1))};function Ku(e){return e=Y(e),e instanceof Error?e:Math.log((1+e)/(1-e))/2}function qu(e){if(e=Y(e),e instanceof Error)return e;let t=Math.exp(2*e);return(t-1)/(t+1)}function Ju(e,t,n){if(e=Y(e),t=X(G(t)),n=X(G(n)),q(e,t,n))return H;let r=V.default.mean(n),i=V.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 Yu(e,t){if(e=X(G(e)),t=X(G(t)),q(e,t))return H;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 Xu(e){return e=Y(e),e instanceof Error?e:e===0||parseInt(e,10)===e&&e<0?U:V.default.gammafn(e)}Xu.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`?H:r?V.default.gamma.cdf(e,t,n,!0):V.default.gamma.pdf(e,t,n,!1):W},Xu.INV=function(e,t,n){return arguments.length===3?e<0||e>1||t<=0||n<=0?U:typeof e!=`number`||typeof t!=`number`||typeof n!=`number`?H:V.default.gamma.inv(e,t,n):W};function Zu(e){return e=Y(e),e instanceof Error?e:V.default.gammaln(e)}Zu.PRECISE=function(e){return arguments.length===1?e<=0?U:typeof e==`number`?V.default.gammaln(e):H:W};function Qu(e){return e=Y(e),e instanceof Error?e:V.default.normal.cdf(e,0,1)-.5}function $u(){let e=X(G(arguments));return e instanceof Error?e:V.default.geomean(e)}function ed(e,t,n,r){if(e=X(G(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=X(G(t)),n=X(G(n)),q(t,n))return H;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 td(){let e=X(G(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}let nd={};nd.DIST=(e,t,n,r,i)=>{if(e=Y(e),t=Y(t),n=Y(n),r=Y(r),q(e,t,n,r))return H;function a(e,t,n,r){return sf(n,e)*sf(r-n,t-e)/sf(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 rd(e,t){return e=X(e),t=X(t),q(e,t)?H:e.length===t.length?Ju(0,e,t):W}function id(){let e=X(G(arguments));if(e instanceof Error)return e;let t=V.default.mean(e),n=e.length,r=0;for(let i=0;i<n;i++)r+=(e[i]-t)**4;return r/=V.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 ad(e,t){return K.apply(void 0,e)||(q(t)?t:(e=pl(G(e)),t=Y(t),t<0||e.length<t?H:e.sort((e,t)=>t-e)[t-1]))}function od(e,t){if(e=X(G(e)),t=X(G(t)),q(e,t))return H;let n=V.default.mean(e),r=V.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 sd(e,t){if(e=X(G(e)),t=X(G(t)),q(e,t)||e.length!==t.length)return H;for(let t=0;t<e.length;t++)e[t]=Math.log(e[t]);let n=od(e,t);return n[0]=Math.round(Math.exp(n[0])*1e6)/1e6,n[1]=Math.round(Math.exp(n[1])*1e6)/1e6,n}let cd={};cd.DIST=(e,t,n,r)=>(e=Y(e),t=Y(t),n=Y(n),q(e,t,n)?H:r?V.default.lognormal.cdf(e,t,n):V.default.lognormal.pdf(e,t,n)),cd.INV=(e,t,n)=>(e=Y(e),t=Y(t),n=Y(n),q(e,t,n)?H:V.default.lognormal.inv(e,t,n));function ld(){let e=G(arguments),t=K.apply(void 0,e);if(t)return t;let n=pl(e);return n.length===0?0:Math.max.apply(Math,n)}function ud(){let e=G(arguments),t=K.apply(void 0,e);if(t)return t;let n=tl(e);return n=n.map(e=>e??0),n.length===0?0:Math.max.apply(Math,n)}function dd(){let e=vl(...arguments);return e.length===0?0:Math.max.apply(Math,e)}function fd(){let e=G(arguments),t=K.apply(void 0,e);if(t)return t;let n=tl(e),r=V.default.median(n);return isNaN(r)&&(r=U),r}function pd(){let e=G(arguments),t=K.apply(void 0,e);if(t)return t;let n=pl(e);return n.length===0?0:Math.min.apply(Math,n)}function md(){let e=G(arguments),t=K.apply(void 0,e);if(t)return t;let n=tl(e);return n=n.map(e=>e??0),n.length===0?0:Math.min.apply(Math,n)}function hd(){let e=vl(...arguments);return e.length===0?0:Math.min.apply(Math,e)}let gd={};gd.MULT=function(){let e=X(G(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},gd.SNGL=function(){let e=X(G(arguments));return e instanceof Error?e:gd.MULT(e).sort((e,t)=>e-t)[0]};let _d={};_d.DIST=(e,t,n,r)=>(e=Y(e),t=Y(t),n=Y(n),q(e,t,n)?H:r?V.default.negbin.cdf(e,t,n):V.default.negbin.pdf(e,t,n));let vd={};vd.DIST=(e,t,n,r)=>(e=Y(e),t=Y(t),n=Y(n),q(e,t,n)?H:n<=0?U:r?V.default.normal.cdf(e,t,n):V.default.normal.pdf(e,t,n)),vd.INV=(e,t,n)=>(e=Y(e),t=Y(t),n=Y(n),q(e,t,n)?H:V.default.normal.inv(e,t,n)),vd.S={},vd.S.DIST=(e,t)=>(e=Y(e),e instanceof Error?H:t?V.default.normal.cdf(e,0,1):V.default.normal.pdf(e,0,1)),vd.S.INV=e=>(e=Y(e),e instanceof Error?H:V.default.normal.inv(e,0,1));function yd(e,t){if(t=X(G(t)),e=X(G(e)),q(t,e))return H;let n=V.default.mean(e),r=V.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)}let bd={};bd.EXC=(e,t)=>{if(e=X(G(e)),t=Y(t),q(e,t))return H;e=e.sort((e,t)=>e-t);let n=e.length;if(t<1/(n+1)||t>1-1/(n+1))return U;let r=t*(n+1)-1,i=Math.floor(r);return fl(r===i?e[r]:e[i]+(r-i)*(e[i+1]-e[i]))},bd.INC=(e,t)=>{if(e=X(G(e)),t=Y(t),q(e,t))return H;e=e.sort((e,t)=>e-t);let n=e.length,r=t*(n-1),i=Math.floor(r);return fl(r===i?e[r]:e[i]+(r-i)*(e[i+1]-e[i]))};let xd={};xd.EXC=(e,t,n)=>{if(n=n===void 0?3:n,e=X(G(e)),t=Y(t),n=Y(n),q(e,t,n))return H;e=e.sort((e,t)=>e-t);let r=Yl.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},xd.INC=(e,t,n)=>{if(n=n===void 0?3:n,e=X(G(e)),t=Y(t),n=Y(n),q(e,t,n))return H;e=e.sort((e,t)=>e-t);let r=Yl.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 Sd(e,t){return e=Y(e),t=Y(t),q(e,t)?H:bf(e)/bf(e-t)}function Cd(e,t){return e=Y(e),t=Y(t),q(e,t)?H:e**+t}function wd(e){return e=Y(e),e instanceof Error?H:Math.exp(-.5*e*e)/2.5066282746310002}let Td={};Td.DIST=(e,t,n)=>(e=Y(e),t=Y(t),q(e,t)?H:n?V.default.poisson.cdf(e,t):V.default.poisson.pdf(e,t));function Ed(e,t,n,r){if(n===void 0)return 0;if(r=r===void 0?n:r,e=X(G(e)),t=X(G(t)),n=Y(n),r=Y(r),q(e,t,n,r))return H;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}let Dd={};Dd.EXC=(e,t)=>{if(e=X(pl(G(e))),t=Y(t),q(e,t))return H;switch(t){case 1:return bd.EXC(e,.25);case 2:return bd.EXC(e,.5);case 3:return bd.EXC(e,.75);default:return U}},Dd.INC=(e,t)=>{if(e=X(pl(G(e))),t=Y(t),q(e,t))return H;switch(t){case 1:return bd.INC(e,.25);case 2:return bd.INC(e,.5);case 3:return bd.INC(e,.75);default:return U}};let Od={};Od.AVG=(e,t,n)=>{if(e=Y(e),t=X(G(t)),q(e,t))return H;t=G(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},Od.EQ=(e,t,n)=>{if(e=Y(e),t=X(G(t)),q(e,t))return H;n||=!1;let r=n?(e,t)=>e-t:(e,t)=>t-e;return t=t.sort(r),t.indexOf(e)+1};function kd(e,t){if(arguments.length!==2)return W;if(t<0)return U;if(!(e instanceof Array)||typeof t!=`number`)return H;if(e.length!==0)return V.default.row(e,t)}function Ad(e,t){return e=X(G(e)),t=X(G(t)),q(e,t)?H:yd(e,t)**2}function jd(){let e=X(G(arguments));if(e instanceof Error)return e;let t=V.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)*V.default.stdev(e,!0)**3)}jd.P=function(){let e=X(G(arguments));if(e instanceof Error)return e;let t=V.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 Md(e,t){if(e=X(G(e)),t=X(G(t)),q(e,t))return H;let n=V.default.mean(t),r=V.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 Nd(e,t){return e=X(G(e)),t=Y(t),q(e,t)?e:e.sort((e,t)=>e-t)[t-1]}function Pd(e,t,n){return e=Y(e),t=Y(t),n=Y(n),q(e,t,n)?H:(e-t)/n}let Fd={};Fd.P=function(){let e=Vd.P.apply(this,arguments),t=Math.sqrt(e);return isNaN(t)&&(t=U),t},Fd.S=function(){let e=Vd.S.apply(this,arguments);return Math.sqrt(e)};function Id(){let e=Hd.apply(this,arguments);return Math.sqrt(e)}function Ld(){let e=Ud.apply(this,arguments),t=Math.sqrt(e);return isNaN(t)&&(t=U),t}function Rd(e,t){if(e=X(G(e)),t=X(G(t)),q(e,t))return H;let n=V.default.mean(t),r=V.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))}yu.DIST=(e,t,n)=>n!==1&&n!==2?U:n===1?yu.DIST.RT(e,t):yu.DIST[`2T`](e,t),yu.DIST[`2T`]=function(e,t){return arguments.length===2?e<0||t<1?U:typeof e!=`number`||typeof t!=`number`?H:(1-V.default.studentt.cdf(e,t))*2:W},yu.DIST.RT=function(e,t){return arguments.length===2?e<0||t<1?U:typeof e!=`number`||typeof t!=`number`?H:1-V.default.studentt.cdf(e,t):W},yu.INV=(e,t)=>(e=Y(e),t=Y(t),q(e,t)?H:V.default.studentt.inv(e,t)),yu.INV[`2T`]=(e,t)=>(e=Y(e),t=Y(t),e<=0||e>1||t<1?U:q(e,t)?H:Math.abs(V.default.studentt.inv(e/2,t))),yu.TEST=(e,t)=>{if(e=X(G(e)),t=X(G(t)),q(e,t))return H;let n=V.default.mean(e),r=V.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 yu.DIST[`2T`](s,e.length+t.length-2)};function zd(e,t,n){if(e=X(G(e)),t=X(G(t)),n=X(G(n)),q(e,t,n))return H;let r=od(e,t),i=r[0],a=r[1],o=[];return n.forEach(e=>{o.push(i*e+a)}),o}function Bd(e,t){if(e=X(G(e)),t=Y(t),q(e,t))return H;let n=Sf(e.length*t,2)/2;return V.default.mean(ol(ll(e.sort((e,t)=>e-t),n),n))}let Vd={};Vd.P=function(){let e=pl(G(arguments)),t=e.length,n=0,r=Ou(e),i;for(let i=0;i<t;i++)n+=(e[i]-r)**2;return i=n/t,isNaN(i)&&(i=U),i},Vd.S=function(){let e=pl(G(arguments)),t=e.length,n=0,r=Ou(e);for(let i=0;i<t;i++)n+=(e[i]-r)**2;return n/(t-1)};function Hd(){let e=G(arguments),t=e.length,n=0,r=0,i=ku(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 Ud(){let e=G(arguments),t=e.length,n=0,r=0,i=ku(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=U),a}let Wd={};Wd.DIST=(e,t,n,r)=>(e=Y(e),t=Y(t),n=Y(n),q(e,t,n)?H:r?1-Math.exp(-((e/n)**+t)):e**(t-1)*Math.exp(-((e/n)**+t))*t/n**+t);let Gd={};Gd.TEST=(e,t,n)=>{if(e=X(G(e)),t=Y(t),q(e,t))return H;n||=Fd.S(e);let r=e.length;return 1-vd.S.DIST((Ou(e)-t)/(n/Math.sqrt(r)),!0)};function Kd(e){return e=Y(e),e instanceof Error?e:Math.abs(e)}function qd(e){if(e=Y(e),e instanceof Error)return e;let t=Math.acos(e);return isNaN(t)&&(t=U),t}function Jd(e){if(e=Y(e),e instanceof Error)return e;let t=Math.log(e+Math.sqrt(e*e-1));return isNaN(t)&&(t=U),t}function Yd(e){return e=Y(e),e instanceof Error?e:Math.atan(1/e)}function Xd(e){if(e=Y(e),e instanceof Error)return e;let t=.5*Math.log((e+1)/(e-1));return isNaN(t)&&(t=U),t}function Zd(e,t,n,r){if(e=Y(e),t=Y(e),q(e,t))return H;switch(e){case 1:return Ou(n);case 2:return Lu(n);case 3:return Ru(n);case 4:return ld(n);case 5:return pd(n);case 6:return Rf(n);case 7:return Fd.S(n);case 8:return Fd.P(n);case 9:return rp(n);case 10:return Vd.S(n);case 11:return Vd.P(n);case 12:return fd(n);case 13:return gd.SNGL(n);case 14:return ad(n,r);case 15:return Nd(n,r);case 16:return bd.INC(n,r);case 17:return Dd.INC(n,r);case 18:return bd.EXC(n,r);case 19:return Dd.EXC(n,r)}}function Qd(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 H;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 $d(e){if(e=Y(e),e instanceof Error)return e;let t=Math.asin(e);return isNaN(t)&&(t=U),t}function ef(e){return e=Y(e),e instanceof Error?e:Math.log(e+Math.sqrt(e*e+1))}function tf(e){return e=Y(e),e instanceof Error?e:Math.atan(e)}function nf(e,t){return e=Y(e),t=Y(t),K(e,t)||Math.atan2(e,t)}function rf(e){if(e=Y(e),e instanceof Error)return e;let t=Math.log((1+e)/(1-e))/2;return isNaN(t)&&(t=U),t}function af(e,t,n){e=Y(e),t=Y(t),n=Y(n);let r=K(e,t,n);if(r)return r;if(t===0)return U;let i=e.toString(t);return Array(Math.max(n+1-i.length,0)).join(`0`)+i}function of(e,t){return e=Y(e),t=Y(t),K(e,t)||(t===0?0:e>0&&t<0?U:Math.ceil(e/t)*t)}of.MATH=(e,t,n=0)=>(t===void 0&&(t=e>0?1:-1),e=Y(e),t=Y(t),n=Y(n),K(e,t,n)||(t===0?0:(t=Math.abs(t),n===0||e>0?Math.ceil(e/t)*t:Math.floor(e/t)*t))),of.PRECISE=(e,t)=>of.MATH(e,t);function sf(e,t){return e=Y(e),t=Y(t),K(e,t)||(e<t?U:bf(e)/(bf(t)*bf(e-t)))}function cf(e,t){return e=Y(e),t=Y(t),K(e,t)||(e<t?U:e===0&&t===0?1:sf(e+t-1,e-1))}function lf(e){return e=Y(e),e instanceof Error?e:Math.cos(e)}function uf(e){return e=Y(e),e instanceof Error?e:(Math.exp(e)+Math.exp(-e))/2}function df(e){return e=Y(e),e instanceof Error?e:e===0?Ec:1/Math.tan(e)}function ff(e){if(e=Y(e),e instanceof Error)return e;if(e===0)return Ec;let t=Math.exp(2*e);return(t+1)/(t-1)}function pf(e){return e=Y(e),e instanceof Error?e:e===0?Ec:1/Math.sin(e)}function mf(e){return e=Y(e),e instanceof Error?e:e===0?Ec:2/(Math.exp(e)-Math.exp(-e))}function hf(e,t){if(arguments.length<2)return W;e||=`0`,t=Y(t);let n=K(e,t);if(n)return n;if(t===0)return U;let r=parseInt(e,t);return isNaN(r)?U:r}function gf(e){return e=Y(e),e instanceof Error?e:e*180/Math.PI}function _f(e){return e=Y(e),e instanceof Error?e:of.MATH(e,-2,-1)}function vf(e){return arguments.length<1?W:arguments.length>1?kc:(e=Y(e),e instanceof Error||(e=Math.exp(e)),e)}let yf=[];function bf(e){if(e=Y(e),e instanceof Error)return e;let t=Math.floor(e);return t===0||t===1?1:(yf[t]>0||(yf[t]=bf(t-1)*t),yf[t])}function xf(e){if(e=Y(e),e instanceof Error)return e;let t=Math.floor(e);return t<=0?1:t*xf(t-2)}function Sf(e,t){return e=Y(e),t=Y(t),K(e,t)||(t?e>0&&t<0?U:Math.floor(e/t)*t:Ec)}Sf.MATH=(e,t=1,n=0)=>(e=Y(e),t=Y(t),n=Y(n),K(e,t,n)||(t===0?0:(t=Math.abs(t),n===0||e>0?Math.floor(e/t)*t:Math.ceil(e/t)*t))),Sf.PRECISE=(e,t)=>Sf.MATH(e,t);function Cf(){let e=X(G(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 wf(e){return e=Y(e),e instanceof Error?e:Math.floor(e)}let Tf={CEILING:of};function Ef(){let e=X(G(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 Df(e){return e=Y(e),e instanceof Error?e:e===0?U:Math.log(e)}function Of(e,t){return e=Y(e),t=t?Y(t):10,K(e,t)||(e===0||t===0?U:Math.log(e)/Math.log(t))}function kf(e){return e=Y(e),e instanceof Error?e:e===0?U:Math.log(e)/Math.log(10)}function Af(e,t){return!Array.isArray(e)||!Array.isArray(t)||e.some(e=>!e.length)||t.some(e=>!e.length)||al(e).some(e=>typeof e!=`number`)||al(t).some(e=>typeof e!=`number`)||e[0].length!==t.length?H: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 jf(e,t){e=Y(e),t=Y(t);let n=K(e,t);if(n)return n;if(t===0)return Ec;let r=Math.abs(e%t);return r=e<0?t-r:r,t>0?r:-r}function Mf(e,t){return e=Y(e),t=Y(t),K(e,t)||(e*t===0?0:e*t<0?U:Math.round(e/t)*t)}function Nf(){let e=X(G(arguments));if(e instanceof Error)return e;let t=0,n=1;for(let r=0;r<e.length;r++)t+=e[r],n*=bf(e[r]);return bf(t)/n}function Pf(e){return arguments.length>1?W:(e=parseInt(e),!e||e<=0?H:Array(e).fill(0).map(()=>Array(e).fill(0)).map((e,t)=>(e[t]=1,e)))}function Ff(e){if(e=Y(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 If(){return Math.PI}function Lf(e,t){e=Y(e),t=Y(t);let n=K(e,t);if(n)return n;if(e===0&&t===0)return U;let r=e**+t;return isNaN(r)?U:r}function Rf(){let e=G(arguments).filter(e=>e!=null);if(e.length===0)return 0;let t=X(e);if(t instanceof Error)return t;let n=1;for(let e=0;e<t.length;e++)n*=t[e];return n}function zf(e,t){return e=Y(e),t=Y(t),K(e,t)||parseInt(e/t,10)}function Bf(e){return e=Y(e),e instanceof Error?e:e*Math.PI/180}function Vf(){return Math.random()}function Hf(e,t){return e=Y(e),t=Y(t),K(e,t)||e+Math.ceil((t-e+1)*Math.random())-1}function Uf(e){if(e=Y(e),e instanceof Error)return e;let t=String(e).split(``),n=/* @__PURE__ */ `.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 Wf(e,t,n){e=Y(e),t=Y(t);let r=K(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 Gf(e,t){return Wf(e,t,Math.round)}function Kf(e,t){return Wf(e,t,Math.floor)}function qf(e,t){return Wf(e,t,Math.ceil)}function Jf(e){return e=Y(e),e instanceof Error?e:1/Math.cos(e)}function Yf(e){return e=Y(e),e instanceof Error?e:2/(Math.exp(e)+Math.exp(-e))}function Xf(e,t,n,r){if(e=Y(e),t=Y(t),n=Y(n),r=X(r),q(e,t,n,r))return H;let i=r[0]*e**+t;for(let a=1;a<r.length;a++)i+=r[a]*e**+(t+a*n);return i}function Zf(e){return e=Y(e),e instanceof Error?e:e<0?-1:e===0?0:1}function Qf(e){return e=Y(e),e instanceof Error?e:Math.sin(e)}function $f(e){return e=Y(e),e instanceof Error?e:(Math.exp(e)-Math.exp(-e))/2}function ep(e){return e=Y(e),e instanceof Error?e:e<0?U:Math.sqrt(e)}function tp(e){return e=Y(e),e instanceof Error?e:Math.sqrt(e*Math.PI)}function np(e,t){if(e=Y(e),e instanceof Error)return e;switch(e){case 1:return Ou(t);case 2:return Lu(t);case 3:return Ru(t);case 4:return ld(t);case 5:return pd(t);case 6:return Rf(t);case 7:return Fd.S(t);case 8:return Fd.P(t);case 9:return rp(t);case 10:return Vd.S(t);case 11:return Vd.P(t);case 101:return Ou(t);case 102:return Lu(t);case 103:return Ru(t);case 104:return ld(t);case 105:return pd(t);case 106:return Rf(t);case 107:return Fd.S(t);case 108:return Fd.P(t);case 109:return rp(t);case 110:return Vd.S(t);case 111:return Vd.P(t)}}function rp(){let e=0;return el($c(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=rp.apply(null,t);n instanceof Error?e=n:e+=n}}),e}function ip(e,t,n){if(e=G(e),n=n?G(n):e,e instanceof Error)return e;if(t==null||t instanceof Error)return 0;let r=0,i=t===`*`,a=i?null:Zc(t+``);for(let t=0;t<e.length;t++){let o=e[t],s=n[t];if(i)r+=o;else{let e=[Gc(o,Wc)].concat(a);r+=Qc(e)?s:0}}return r}function ap(){let e=$c(arguments);return e[0]=tl(G(e[0])),rp(vl(...e))}function op(){if(!arguments||arguments.length===0)return H;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=Y(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=Y(e),i instanceof Error)return i;n*=i}t+=n}return t}function sp(){let e=X(G(arguments));if(e instanceof Error)return e;let t=0,n=e.length;for(let r=0;r<n;r++)t+=Ol(e[r])?e[r]*e[r]:0;return t}function cp(e,t){if(e=X(G(e)),t=X(G(t)),q(e,t))return H;let n=0;for(let r=0;r<e.length;r++)n+=e[r]*e[r]-t[r]*t[r];return n}function lp(e,t){if(e=X(G(e)),t=X(G(t)),q(e,t))return H;let n=0;e=X(G(e)),t=X(G(t));for(let r=0;r<e.length;r++)n+=e[r]*e[r]+t[r]*t[r];return n}function up(e,t){if(e=X(G(e)),t=X(G(t)),q(e,t))return H;let n=0;e=G(e),t=G(t);for(let r=0;r<e.length;r++)n+=(e[r]-t[r])**2;return n}function dp(e){return e=Y(e),e instanceof Error?e:Math.tan(e)}function fp(e){if(e=Y(e),e instanceof Error)return e;let t=Math.exp(2*e);return(t-1)/(t+1)}function pp(e,t){return e=Y(e),t=Y(t),K(e,t)||(e>0?1:-1)*Math.floor(Math.abs(e)*10**t)/10**t}function mp(e,t){return arguments.length===2?(e=Y(e),t=Y(t),K(e,t)||e+t):W}function hp(e,t){return arguments.length===2?(e=Y(e),t=Y(t),K(e,t)||(t===0?Ec:e/t)):W}function gp(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):W}function _p(e,t){return arguments.length===2?e instanceof Error?e:t instanceof Error?t:(_l(e,t)?(e=gl(e),t=gl(t)):(e=Y(e),t=Y(t)),K(e,t)||e>t):W}function vp(e,t){return arguments.length===2?(_l(e,t)?(e=gl(e),t=gl(t)):(e=Y(e),t=Y(t)),K(e,t)||e>=t):W}function yp(e,t){return arguments.length===2?(_l(e,t)?(e=gl(e),t=gl(t)):(e=Y(e),t=Y(t)),K(e,t)||e<t):W}function bp(e,t){return arguments.length===2?(_l(e,t)?(e=gl(e),t=gl(t)):(e=Y(e),t=Y(t)),K(e,t)||e<=t):W}function xp(e,t){return arguments.length===2?(e=Y(e),t=Y(t),K(e,t)||e-t):W}function Sp(e,t){return arguments.length===2?(e=Y(e),t=Y(t),K(e,t)||e*t):W}function Cp(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):W}function wp(e,t){return arguments.length===2?Lf(e,t):W}var Tp=/*#__PURE__*/ Object.freeze({__proto__:null,ADD:mp,DIVIDE:hp,EQ:gp,GT:_p,GTE:vp,LT:yp,LTE:bp,MINUS:xp,MULTIPLY:Sp,NE:Cp,POW:wp});let Ep=[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],Dp=[[],[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]],Op=[[],[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 kp(e,t,n){let r;return e=Y(e),t=Y(t),n=Y(n),q(e,t,n)?r=H:(r=new Date(e,t-1,n),r.getFullYear()<0&&(r=U)),Nc?Lc(r):r}function Ap(e,t,n){n=n.toUpperCase(),e=J(e),t=J(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(em(e,t));break;case`D`:l=Pp(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=Pp(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=Pp(t,e)}return l}function jp(e){if(typeof e!=`string`||isNaN(Date.parse(e)))return H;let t=new Date(e);return Nc?Lc(t):t}function Mp(e){let t=J(e);return t instanceof Error?t:t.getDate()}function Np(e){let t=new Date(e);return t.setHours(0,0,0,0),t}function Pp(e,t){return e=J(e),t=J(t),e instanceof Error?e:t instanceof Error?t:Lc(Np(e))-Lc(Np(t))}function Fp(e,t,n){if(n=ml(n||`false`),e=J(e),t=J(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 Ip(e,t){if(e=J(e),e instanceof Error)return e;if(isNaN(t))return H;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),Nc?Lc(e):e}function Lp(e,t){if(e=J(e),e instanceof Error)return e;if(isNaN(t))return H;t=parseInt(t,10);let n=new Date(e.getFullYear(),e.getMonth()+t+1,0);return Nc?Lc(n):n}function Rp(e){return e=J(e),e instanceof Error?e:e.getHours()}function zp(e){if(e=J(e),e instanceof Error)return e;e=Np(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 Bp(e){return e=J(e),e instanceof Error?e:e.getMinutes()}function Vp(e){return e=J(e),e instanceof Error?e:e.getMonth()+1}function Hp(e,t,n){return Hp.INTL(e,t,1,n)}Hp.INTL=(e,t,n,r)=>{if(e=J(e),e instanceof Error)return e;if(t=J(t),t instanceof Error)return t;let i=!1,a=[],o=[1,2,3,4,5,6,0],s=/* @__PURE__ */ RegExp(`^[0|1]{7}$`);if(n===void 0)n=Op[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=Op[n];if(!(n instanceof Array))return H;r===void 0?r=[]:r instanceof Array||(r=[r]);for(let e=0;e<r.length;e++){let t=J(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=(/* @__PURE__ */ 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 Up(){return Nc?Lc(/* @__PURE__ */ new Date):/* @__PURE__ */ new Date}function Wp(e){return e=J(e),e instanceof Error?e:e.getSeconds()}function Gp(e,t,n){return e=Y(e),t=Y(t),n=Y(n),q(e,t,n)?H:e<0||t<0||n<0?U:(3600*e+60*t+n)/86400}function Kp(e){return e=J(e),e instanceof Error?e:(3600*e.getHours()+60*e.getMinutes()+e.getSeconds())/86400}function qp(){let e=Np(/* @__PURE__ */ new Date);return Nc?Lc(e):e}function Jp(e,t){if(e=J(e),e instanceof Error)return e;t===void 0&&(t=1);let n=e.getDay();return Dp[t][n]}function Yp(e,t){if(e=J(e),e instanceof Error)return e;if(t===void 0&&(t=1),t===21)return zp(e);let n=Ep[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 Xp(e,t,n){return Xp.INTL(e,t,1,n)}Xp.INTL=(e,t,n,r)=>{if(e=J(e),e instanceof Error)return e;if(t=Y(t),t instanceof Error)return t;if(n=n===void 0?Op[1]:Op[n],!(n instanceof Array))return H;r===void 0?r=[]:r instanceof Array||(r=[r]);for(let e=0;e<r.length;e++){let t=J(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?H:e};function Zp(e){return e=J(e),e instanceof Error?e:e.getFullYear()}function Qp(e){return new Date(e,1,29).getMonth()===1}function $p(e,t){return Math.ceil((t-e)/1e3/60/60/24)}function em(e,t,n){if(e=J(e),e instanceof Error)return e;if(t=J(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(Qp(n)&&e<r&&t>=r)return!0;let i=t.getFullYear(),a=new Date(i,2,1);return Qp(i)&&t>=a&&e<a},l=365;if(a===c||a+1===c&&(i>s||i===s&&r>=o))return(a===c&&Qp(a)||n(e,t)||s===1&&o===29)&&(l=366),$p(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 $p(e,t)/d}case 2:return $p(e,t)/360;case 3:return $p(e,t)/365;case 4:return(o+s*30+c*360-(r+i*30+a*360))/360}}function tm(e){return/^[01]{1,10}$/.test(e)}function nm(e,t){return e=Y(e),t=Y(t),q(e,t)?H:wc.default.besseli(e,t)}function rm(e,t){return e=Y(e),t=Y(t),q(e,t)?H:wc.default.besselj(e,t)}function im(e,t){return e=Y(e),t=Y(t),q(e,t)?H:wc.default.besselk(e,t)}function am(e,t){return e=Y(e),t=Y(t),q(e,t)?H:wc.default.bessely(e,t)}function om(e){if(!tm(e))return U;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 sm(e,t){if(!tm(e))return U;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)?H:t<0?U:(t=Math.floor(t),t>=r.length?hu(`0`,t-r.length)+r:U)}function cm(e,t){if(!tm(e))return U;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)?H:t<0?U:(t=Math.floor(t),t>=r.length?hu(`0`,t-r.length)+r:U)}function lm(e,t){return e=Y(e),t=Y(t),q(e,t)?H:e<0||t<0||Math.floor(e)!==e||Math.floor(t)!==t||e>0xffffffffffff||t>0xffffffffffff?U:e&t}function um(e,t){return e=Y(e),t=Y(t),q(e,t)?H:e<0||Math.floor(e)!==e||e>0xffffffffffff||Math.abs(t)>53?U:t>=0?e<<t:e>>-t}function dm(e,t){return e=Y(e),t=Y(t),q(e,t)?H:e<0||t<0||Math.floor(e)!==e||Math.floor(t)!==t||e>0xffffffffffff||t>0xffffffffffff?U:e|t}function fm(e,t){return e=Y(e),t=Y(t),q(e,t)?H:e<0||Math.floor(e)!==e||e>0xffffffffffff||Math.abs(t)>53?U:t>=0?e>>t:e<<-t}function pm(e,t){return e=Y(e),t=Y(t),q(e,t)?H:e<0||t<0||Math.floor(e)!==e||Math.floor(t)!==t||e>0xffffffffffff||t>0xffffffffffff?U:e^t}function mm(e,t,n){if(e=Y(e),t=Y(t),q(e,t))return e;if(n=n===void 0?`i`:n,n!==`i`&&n!==`j`)return H;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 hm(e,t,n){if(e=Y(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]?W:e*o[6]*u/(s[6]*d)}function gm(e,t){if(e=Y(e),e instanceof Error)return e;if(!/^-?[0-9]{1,3}$/.test(e)||e<-512||e>511)return U;if(e<0)return`1`+hu(`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)?H:t<0?U:(t=Math.floor(t),t>=n.length?hu(`0`,t-n.length)+n:U)}function _m(e,t){if(e=Y(e),e instanceof Error)return e;if(!/^-?[0-9]{1,12}$/.test(e)||e<-549755813888||e>549755813887)return U;if(e<0)return(1099511627776+e).toString(16);let n=parseInt(e,10).toString(16);return t===void 0?n:isNaN(t)?H:t<0?U:(t=Math.floor(t),t>=n.length?hu(`0`,t-n.length)+n:U)}function vm(e,t){if(e=Y(e),e instanceof Error)return e;if(!/^-?[0-9]{1,9}$/.test(e)||e<-536870912||e>536870911)return U;if(e<0)return(1073741824+e).toString(8);let n=parseInt(e,10).toString(8);return t===void 0?n:isNaN(t)?H:t<0?U:(t=Math.floor(t),t>=n.length?hu(`0`,t-n.length)+n:U)}function ym(e,t){return t=t===void 0?0:t,e=Y(e),t=Y(t),q(e,t)?H:+(e===t)}function bm(e,t){return t=t===void 0?0:t,e=Y(e),t=Y(t),q(e,t)?H:V.default.erf(e)}function xm(e){return isNaN(e)?H:V.default.erfc(e)}function Sm(e,t){return t||=0,e=Y(e),q(t,e)?e:+(e>=t)}function Cm(e,t){if(!/^[0-9A-Fa-f]{1,10}$/.test(e))return U;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 U;if(n)return`1`+hu(`0`,9-(512+r).toString(2).length)+(512+r).toString(2);let i=r.toString(2);return t===void 0?i:isNaN(t)?H:t<0?U:(t=Math.floor(t),t>=i.length?hu(`0`,t-i.length)+i:U)}function wm(e){if(!/^[0-9A-Fa-f]{1,10}$/.test(e))return U;let t=parseInt(e,16);return t>=549755813888?t-1099511627776:t}function Tm(e,t){if(!/^[0-9A-Fa-f]{1,10}$/.test(e))return U;let n=parseInt(e,16);if(n>536870911&&n<0xffe0000000)return U;if(n>=0xffe0000000)return(n-0xffc0000000).toString(8);let r=n.toString(8);return t===void 0?r:isNaN(t)?H:t<0?U:(t=Math.floor(t),t>=r.length?hu(`0`,t-r.length)+r:U)}function Em(e){let t=Bm(e),n=Dm(e);return q(t,n)?H:Math.sqrt(t**2+n**2)}function Dm(e){if(e===void 0||e===!0||e===!1)return H;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))?U:Number(e.substring(t+1,e.length-1)):isNaN(e.substring(0,n))||isNaN(e.substring(n+1,e.length-1))?U:-Number(e.substring(n+1,e.length-1)):U:i?isNaN(e.substring(0,e.length-1))?U:e.substring(0,e.length-1):isNaN(e)?U:0}function Om(e){let t=Bm(e),n=Dm(e);return q(t,n)?H:t===0&&n===0?Ec: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 km(e){let t=Bm(e),n=Dm(e);if(q(t,n))return H;let r=e.substring(e.length-1);return r=r===`i`||r===`j`?r:`i`,n===0?e:mm(t,-n,r)}function Am(e){let t=Bm(e),n=Dm(e);if(q(t,n))return H;let r=e.substring(e.length-1);return r=r===`i`||r===`j`?r:`i`,mm(Math.cos(t)*(Math.exp(n)+Math.exp(-n))/2,-Math.sin(t)*(Math.exp(n)-Math.exp(-n))/2,r)}function jm(e){let t=Bm(e),n=Dm(e);if(q(t,n))return H;let r=e.substring(e.length-1);return r=r===`i`||r===`j`?r:`i`,mm(Math.cos(n)*(Math.exp(t)+Math.exp(-t))/2,Math.sin(n)*(Math.exp(t)-Math.exp(-t))/2,r)}function Mm(e){return q(Bm(e),Dm(e))?H:Nm(Am(e),Um(e))}function Nm(e,t){let n=Bm(e),r=Dm(e),i=Bm(t),a=Dm(t);if(q(n,r,i,a))return H;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 U;let l=i*i+a*a;return mm((n*i+r*a)/l,(r*i-n*a)/l,c)}function Pm(e){let t=Bm(e),n=Dm(e);if(q(t,n))return H;let r=e.substring(e.length-1);r=r===`i`||r===`j`?r:`i`;let i=Math.exp(t);return mm(i*Math.cos(n),i*Math.sin(n),r)}function Fm(e){let t=Bm(e),n=Dm(e);if(q(t,n))return H;let r=e.substring(e.length-1);return r=r===`i`||r===`j`?r:`i`,mm(Math.log(Math.sqrt(t*t+n*n)),Math.atan(n/t),r)}function Im(e){let t=Bm(e),n=Dm(e);if(q(t,n))return H;let r=e.substring(e.length-1);return r=r===`i`||r===`j`?r:`i`,mm(Math.log(Math.sqrt(t*t+n*n))/Math.log(10),Math.atan(n/t)/Math.log(10),r)}function Lm(e){let t=Bm(e),n=Dm(e);if(q(t,n))return H;let r=e.substring(e.length-1);return r=r===`i`||r===`j`?r:`i`,mm(Math.log(Math.sqrt(t*t+n*n))/Math.log(2),Math.atan(n/t)/Math.log(2),r)}function Rm(e,t){t=Y(t);let n=Bm(e),r=Dm(e);if(q(t,n,r))return H;let i=e.substring(e.length-1);i=i===`i`||i===`j`?i:`i`;let a=Em(e)**+t,o=Om(e);return mm(a*Math.cos(t*o),a*Math.sin(t*o),i)}function zm(){let e=arguments[0];if(!arguments.length)return H;for(let t=1;t<arguments.length;t++){let n=Bm(e),r=Dm(e),i=Bm(arguments[t]),a=Dm(arguments[t]);if(q(n,r,i,a))return H;e=mm(n*i-r*a,n*a+r*i)}return e}function Bm(e){if(e===void 0||e===!0||e===!1)return H;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))?U:Number(e.substring(0,t)):isNaN(e.substring(0,n))||isNaN(e.substring(n+1,e.length-1))?U:Number(e.substring(0,n)):U:i?isNaN(e.substring(0,e.length-1))?U:0:isNaN(e)?U:e}function Vm(e){return e===!0||e===!1||q(Bm(e),Dm(e))?H:Nm(`1`,Am(e))}function Hm(e){return q(Bm(e),Dm(e))?H:Nm(`1`,jm(e))}function Um(e){let t=Bm(e),n=Dm(e);if(q(t,n))return H;let r=e.substring(e.length-1);return r=r===`i`||r===`j`?r:`i`,mm(Math.sin(t)*(Math.exp(n)+Math.exp(-n))/2,Math.cos(t)*(Math.exp(n)-Math.exp(-n))/2,r)}function Wm(e){let t=Bm(e),n=Dm(e);if(q(t,n))return H;let r=e.substring(e.length-1);return r=r===`i`||r===`j`?r:`i`,mm(Math.cos(n)*(Math.exp(t)-Math.exp(-t))/2,Math.sin(n)*(Math.exp(t)+Math.exp(-t))/2,r)}function Gm(e){if(q(Bm(e),Dm(e)))return H;let t=e.substring(e.length-1);t=t===`i`||t===`j`?t:`i`;let n=Math.sqrt(Em(e)),r=Om(e);return mm(n*Math.cos(r/2),n*Math.sin(r/2),t)}function Km(e){return e===!0||e===!1?H:q(Bm(e),Dm(e))?U:Nm(`1`,Um(e))}function qm(e){return e===!0||e===!1?H:q(Bm(e),Dm(e))?U:Nm(`1`,Wm(e))}function Jm(e,t){let n=Bm(e),r=Dm(e),i=Bm(t),a=Dm(t);if(q(n,r,i,a))return H;let o=e.substring(e.length-1),s=t.substring(t.length-1),c=`i`;return(o===`j`||s===`j`)&&(c=`j`),mm(n-i,r-a,c)}function Ym(){if(!arguments.length)return H;let e=G(arguments),t=0,n=0;for(let r of e){let e=+Bm(r),i=+Dm(r);if(q(e,i))return H;t+=e,n+=i}return mm(t,n,`i`)}function Xm(e){return e===!0||e===!1||q(Bm(e),Dm(e))?H:Nm(Um(e),Am(e))}function Zm(e,t){if(!/^[0-7]{1,10}$/.test(e))return U;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 U;if(n)return`1`+hu(`0`,9-(512+r).toString(2).length)+(512+r).toString(2);let i=r.toString(2);return t===void 0?i:isNaN(t)?H:t<0?U:(t=Math.floor(t),t>=i.length?hu(`0`,t-i.length)+i:U)}function Qm(e){if(!/^[0-7]{1,10}$/.test(e))return U;let t=parseInt(e,8);return t>=536870912?t-1073741824:t}function $m(e,t){if(!/^[0-7]{1,10}$/.test(e))return U;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)?H:t<0?U:(t=Math.floor(t),t>=r.length?hu(`0`,t-r.length)+r:U)}let eh=Mu.DIST,th=Mu.INV,nh=Nu.DIST,rh=of.MATH,ih=of.PRECISE,ah=Pu.DIST,oh=Pu.DIST.RT,sh=Pu.INV,ch=Pu.INV.RT,lh=Pu.TEST,uh=Hu.P,dh=Hu.P,fh=Hu.S,ph=Nu.INV,mh=xm.PRECISE,hh=bm.PRECISE,gh=Wu.DIST,_h=Gu.DIST,vh=Gu.DIST.RT,yh=Gu.INV,bh=Gu.INV.RT,xh=Sf.MATH,Sh=Sf.PRECISE,Ch=Gu.TEST,wh=Xu.DIST,Th=Xu.INV,Eh=Zu.PRECISE,Dh=nd.DIST,Oh=cd.INV,kh=cd.DIST,Ah=cd.INV,jh=gd.MULT,Mh=gd.SNGL,Nh=_d.DIST,Ph=Hp.INTL,Fh=vd.DIST,Ih=vd.INV,Lh=vd.S.DIST,Rh=vd.S.INV,zh=bd.EXC,Bh=bd.INC,Vh=xd.EXC,Hh=xd.INC,Uh=Td.DIST,Wh=Dd.EXC,Gh=Dd.INC,Kh=Od.AVG,qh=Od.EQ,Jh=jd.P,Yh=Fd.P,Xh=Fd.S,Zh=yu.DIST,Qh=yu.DIST.RT,$h=yu.INV,eg=yu.TEST,tg=Vd.P,ng=Vd.S,rg=Wd.DIST,ig=Xp.INTL,ag=Gd.TEST;function og(e){let t=[];return el(e,e=>{e&&t.push(e)}),t}function sg(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=Zc(c[t]+``),r=[Gc(e[i][a],Wc)].concat(n);o=Qc(r)}}}}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 cg(e,t,n){if(isNaN(t)&&typeof t!=`string`)return H;let r=sg(e,n),i=[];i=ll(typeof t==`string`?e[dl(e,t)]:e[t]);let a=0;return el(r,e=>{a+=i[e]}),r.length===0?Ec:a/r.length}function lg(e,t,n){if(isNaN(t)&&typeof t!=`string`)return H;let r=sg(e,n),i=[];i=ll(typeof t==`string`?e[dl(e,t)]:e[t]);let a=[];return el(r,e=>{a.push(i[e])}),Lu(a)}function ug(e,t,n){if(isNaN(t)&&typeof t!=`string`)return H;let r=sg(e,n),i=[];i=ll(typeof t==`string`?e[dl(e,t)]:e[t]);let a=[];return el(r,e=>{a.push(i[e])}),Ru(a)}function dg(e,t,n){if(isNaN(t)&&typeof t!=`string`)return H;let r=sg(e,n),i=[];return i=ll(typeof t==`string`?e[dl(e,t)]:e[t]),r.length===0?H:r.length>1?U:i[r[0]]}function fg(e,t,n){if(isNaN(t)&&typeof t!=`string`)return H;let r=sg(e,n),i=[];i=ll(typeof t==`string`?e[dl(e,t)]:e[t]);let a=i[r[0]];return el(r,e=>{a<i[e]&&(a=i[e])}),a}function pg(e,t,n){if(isNaN(t)&&typeof t!=`string`)return H;let r=sg(e,n),i=[];i=ll(typeof t==`string`?e[dl(e,t)]:e[t]);let a=i[r[0]];return el(r,e=>{a>i[e]&&(a=i[e])}),a}function mg(e,t,n){if(isNaN(t)&&typeof t!=`string`)return H;let r=sg(e,n),i=[];i=ll(typeof t==`string`?e[dl(e,t)]:e[t]);let a=[];el(r,e=>{a.push(i[e])}),a=og(a);let o=1;return el(a,e=>{o*=e}),o}function hg(e,t,n){if(isNaN(t)&&typeof t!=`string`)return H;let r=sg(e,n),i=[];i=ll(typeof t==`string`?e[dl(e,t)]:e[t]);let a=[];return el(r,e=>{a.push(i[e])}),a=og(a),Fd.S(a)}function gg(e,t,n){if(isNaN(t)&&typeof t!=`string`)return H;let r=sg(e,n),i=[];i=ll(typeof t==`string`?e[dl(e,t)]:e[t]);let a=[];return el(r,e=>{a.push(i[e])}),a=og(a),Fd.P(a)}function _g(e,t,n){if(isNaN(t)&&typeof t!=`string`)return H;let r=sg(e,n),i=[];i=ll(typeof t==`string`?e[dl(e,t)]:e[t]);let a=[];return el(r,e=>{a.push(i[e])}),rp(a)}function vg(e,t,n){if(isNaN(t)&&typeof t!=`string`)return H;let r=sg(e,n),i=[];i=ll(typeof t==`string`?e[dl(e,t)]:e[t]);let a=[];return el(r,e=>{a.push(i[e])}),Vd.S(a)}function yg(e,t,n){if(isNaN(t)&&typeof t!=`string`)return H;let r=sg(e,n),i=[];i=ll(typeof t==`string`?e[dl(e,t)]:e[t]);let a=[];return el(r,e=>{a.push(i[e])}),Vd.P(a)}function bg(e){return e&&e.getTime&&!isNaN(e.getTime())}function xg(e){return e instanceof Date?e:new Date(e)}function Sg(e,t,n){let r=J(t);for(r.setFullYear(e.getFullYear()),r<e&&r.setFullYear(r.getFullYear()+1);r>e;)r.setMonth(r.getMonth()+-12/n);return r}function Cg(e){return e=Y(e),[1,2,4].indexOf(e)===-1?U:e}function wg(e){return e=Y(e),[0,1,2,3,4].indexOf(e)===-1?U:e}function Tg(e,t,n,r,i,a,o){return e=xg(e),t=xg(t),n=xg(n),a=Cg(a),o=wg(o),K(a,o)?U:!bg(e)||!bg(t)||!bg(n)?H:r<=0||i<=0||n<=e?U:(i||=0,o||=0,i*r*em(e,n,o))}function Eg(e,t,n,r){if(r=wg(r),n=Cg(n),e=J(e),t=J(t),K(e,t))return H;if(K(n,r)||e>=t)return U;if(r===1){let r=Sg(e,t,n),i=J(r);return i.setMonth(i.getMonth()+12/n),Ap(r,i,`D`)}let i;switch(r){case 0:case 2:case 4:i=360;break;case 3:i=365;break;default:return U}return i/n}function Dg(e,t,n,r,i,a){if(e=Y(e),t=Y(t),n=Y(n),q(e,t,n))return H;if(e<=0||t<=0||n<=0||r<1||i<1||r>i||a!==0&&a!==1)return U;let o=Gg(e,t,n,0,a),s=0;r===1&&(a===0&&(s=-n),r++);for(let t=r;t<=i;t++)s+=a===1?Fg(e,t-2,o,n,1)-o:Fg(e,t-1,o,n,0);return s*=e,s}function Og(e,t,n,r,i,a){if(e=Y(e),t=Y(t),n=Y(n),q(e,t,n))return H;if(e<=0||t<=0||n<=0||r<1||i<1||r>i||a!==0&&a!==1)return U;let o=Gg(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-(Fg(e,t-2,o,n,1)-o)*e:o-Fg(e,t-1,o,n,0)*e;return s}function kg(e,t,n,r,i){if(i=i===void 0?12:i,e=Y(e),t=Y(t),n=Y(n),r=Y(r),i=Y(i),q(e,t,n,r,i))return H;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 U;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 Ag(e,t,n,r,i){if(i=i===void 0?2:i,e=Y(e),t=Y(t),n=Y(n),r=Y(r),i=Y(i),q(e,t,n,r,i))return H;if(e<0||t<0||n<0||r<0||i<=0||r>n)return U;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 jg(e,t,n,r,i){if(e=J(e),t=J(t),n=Y(n),r=Y(r),i=Y(i),i||=0,q(e,t,n,r,i))return H;if(n<=0||r<=0)return U;if(e>=t)return H;let a,o;switch(i){case 0:a=360,o=Fp(e,t,!1);break;case 1:a=365,o=Ap(e,t,`D`);break;case 2:a=360,o=Ap(e,t,`D`);break;case 3:a=365,o=Ap(e,t,`D`);break;case 4:a=360,o=Fp(e,t,!0);break;default:return U}return(r-n)/r*a/o}function Mg(e,t){if(e=Y(e),t=Y(t),q(e,t))return H;if(t<0)return U;if(t>=0&&t<1)return Ec;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 Ng(e,t){if(e=Y(e),t=Y(t),q(e,t))return H;if(t<0)return U;if(t>=0&&t<1)return Ec;t=parseInt(t,10);let n=parseInt(e,10);return n+=e%1*10**-Math.ceil(Math.log(t)/Math.LN10)*t,n}function Pg(e,t){return e=Y(e),t=Y(t),q(e,t)?H:e<=0||t<1?U:(t=parseInt(t,10),(1+e/t)**+t-1)}function Fg(e,t,n,r,i){if(r||=0,i||=0,e=Y(e),t=Y(t),n=Y(n),r=Y(r),i=Y(i),q(e,t,n,r,i))return H;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 Ig(e,t){if(e=Y(e),t=X(G(t)),q(e,t))return H;let n=t.length,r=e;for(let e=0;e<n;e++)r*=1+t[e];return r}function Lg(e,t,n,r,i,a){if(i||=0,a||=0,e=Y(e),t=Y(t),n=Y(n),r=Y(r),i=Y(i),a=Y(a),q(e,t,n,r,i,a))return H;let o=Gg(e,n,r,i,a);return(t===1?a===1?0:-r:a===1?Fg(e,t-2,o,r,1)-o:Fg(e,t-1,o,r,0))*e}function Rg(e,t){if(t=typeof t==`number`?t:t===void 0?.1:Y(t),e=G(e).filter(yl),e=X(e),q(e,t))return H;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 U;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=/* @__PURE__ */ 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 zg(e,t,n,r){return e=Y(e),t=Y(t),n=Y(n),r=Y(r),q(e,t,n,r)?H:r*e*(t/n-1)}function Bg(e,t,n){if(e=X(G(e)),t=Y(t),n=Y(n),q(e,t,n))return H;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(-Ug(n,a)*(1+n)**(r-1)/(Ug(t,i)*(1+t)))**(1/(r-1))-1}function Vg(e,t){return e=Y(e),t=Y(t),q(e,t)?H:e<=0||t<1?U:(t=parseInt(t,10),((e+1)**(1/t)-1)*t)}function Hg(e,t,n,r,i){if(i=i===void 0?0:i,r=r===void 0?0:r,e=Y(e),t=Y(t),n=Y(n),r=Y(r),i=Y(i),q(e,t,n,r,i))return H;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 Ug(){let e=X(G(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 Wg(e,t,n){return e=Y(e),t=Y(t),n=Y(n),q(e,t,n)?H:e<=0?U:(Math.log(n)-Math.log(t))/Math.log(1+e)}function Gg(e,t,n,r,i){if(r||=0,i||=0,e=Y(e),t=Y(t),n=Y(n),r=Y(r),i=Y(i),q(e,t,n,r,i))return H;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 Kg(e,t,n,r,i,a){return i||=0,a||=0,e=Y(e),n=Y(n),r=Y(r),i=Y(i),a=Y(a),q(e,n,r,i,a)?H:Gg(e,n,r,i,a)-Lg(e,t,n,r,i,a)}function qg(e,t,n,r,i){if(e=J(e),t=J(t),n=Y(n),r=Y(r),i=Y(i),i||=0,q(e,t,n,r,i))return H;if(n<=0||r<=0)return U;if(e>=t)return H;let a,o;switch(i){case 0:a=360,o=Fp(e,t,!1);break;case 1:a=365,o=Ap(e,t,`D`);break;case 2:a=360,o=Ap(e,t,`D`);break;case 3:a=365,o=Ap(e,t,`D`);break;case 4:a=360,o=Fp(e,t,!0);break;default:return U}return r-n*r*o/a}function Jg(e,t,n,r,i){return r||=0,i||=0,e=Y(e),t=Y(t),n=Y(n),r=Y(r),i=Y(i),q(e,t,n,r,i)?H:e===0?-n*t-r:((1-(1+e)**+t)/e*n*(1+e*i)-r)/(1+e)**+t}function Yg(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=Y(e),t=Y(t),n=Y(n),r=Y(r),i=Y(i),a=Y(a),q(e,t,n,r,i,a))return H;let o=1e-10,s=a;i=+!!i;for(let a=0;a<100;a++){if(s<=-1)return U;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 Xg(e,t,n){return e=Y(e),t=Y(t),n=Y(n),q(e,t,n)?H:e===0||t===0?U:(n/t)**(1/e)-1}function Zg(e,t,n){return e=Y(e),t=Y(t),n=Y(n),q(e,t,n)?H:n===0?U:(e-t)/n}function Qg(e,t,n,r){return e=Y(e),t=Y(t),n=Y(n),r=Y(r),q(e,t,n,r)?H:n===0||r<1||r>n?U:(r=parseInt(r,10),(e-t)*(n-r+1)*2/(n*(n+1)))}function $g(e,t,n){return e=J(e),t=J(t),n=Y(n),q(e,t,n)?H:n<=0||e>t||t-e>31536e6?U:365*n/(360-n*Fp(e,t,!1))}function e_(e,t,n){return e=J(e),t=J(t),n=Y(n),q(e,t,n)?H:n<=0||e>t||t-e>31536e6?U:100*(1-n*Fp(e,t,!1)/360)}function t_(e,t,n){return e=J(e),t=J(t),n=Y(n),q(e,t,n)?H:n<=0||e>t||t-e>31536e6?U:(100-n)*360/(n*Fp(e,t,!1))}function n_(e,t,n){if(e=X(G(e)),t=hl(G(t)),n=Y(n),q(e,t,n))return H;let r=(e,t,n)=>{let r=n+1,i=e[0];for(let n=1;n<e.length;n++)i+=e[n]/r**(Pp(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=Pp(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 U;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 r_(e,t,n){if(e=Y(e),t=X(G(t)),n=hl(G(n)),q(e,t,n))return H;let r=0;for(let i=0;i<t.length;i++)r+=t[i]/(1+e)**(Pp(n[i],n[0])/365);return r}function i_(){let e=G(arguments),t=H;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===H&&(t=!0),e[n]||(t=!1))}return t}function a_(){return!1}function o_(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 s_(){for(let e=0;e<arguments.length/2;e++)if(arguments[e*2])return arguments[e*2+1];return W}function c_(e,t){return Cl(e)?t:e}function l_(e,t){return e===W?t:e}function u_(e){return typeof e==`string`?H:e instanceof Error?e:!e}function d_(){let e=G(arguments),t=H;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===H&&(t=!1),e[n]&&(t=!0))}return t}function f_(){return!0}function p_(){let e=G(arguments),t=H;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===H&&(t=0),e[n]&&t++)}return t===H?t:!!(Math.floor(Math.abs(t))&1)}function m_(){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:W)}else e=H;return e}let h_={errors:Mc,symbols:Tp,date:Rc},g_=Cc;function __(e){let t=e.split(`.`).reduce((e,t)=>e?.[t],g_);if(typeof t!=`function`)throw Error(`@formulajs/formulajs has no ${e}.`);return t}function v_(e){return typeof e==`number`?Number.isFinite(e)?e:M.NUM:e instanceof Error?zn(e.message)??M.VALUE:typeof e==`boolean`||typeof e==`string`?e:M.VALUE}let y_=(e,t)=>{try{return v_(e(...t))}catch{return M.VALUE}};function b_(e,t){return To([e],t)}function x_(e,t){let n=B(e,t);if(n instanceof j)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 j)return i;t.push(typeof i==`number`?i:0)}r.push(t)}return r}function Z(e,t,n){let r=t.split(`?`)[0]?.length??0,i=t.replace(`?`,``),a=__(n);R(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`?I(r):e===`b`?io(r):L(r);if(a instanceof j)return a;t.push(a)}return y_(a,t)},{from:`formulajs`})}function S_(e,t,n){let r=t.replace(`?`,``),i=r.endsWith(`r`),a=__(n);z(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=To(e.slice(a),t);if(r instanceof j)return r;n.push(r);break}if(o instanceof F){n.push(void 0);continue}let c;if(s===`l`)c=b_(o,t);else if(s===`m`)c=x_(o,t);else{let e=t.calc.scalar(o,t.frame);c=s===`n`?I(e):s===`b`?io(e):L(e)}if(c instanceof j)return c;n.push(c)}return y_(a,n)},{from:`formulajs`})}function C_(e,t,n=``,r=1){let i=__(t),a=n.length;z(e,`${`v`.repeat(a)}rr`,(e,t)=>{let n=[];for(let r of e.slice(0,a)){let e=I(t.calc.scalar(r,t.frame));if(e instanceof j)return e;n.push(e)}let o=B(e[a],t),s=B(e[a+1],t);if(o instanceof j)return o;if(s instanceof j)return s;if(o.rows*o.cols!==s.rows*s.cols)return M.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 j)return n;if(r instanceof j)return r;typeof n==`number`&&typeof r==`number`&&(c.push(n),l.push(r))}if(c.length<r)return M.DIV0;let u=y_(i,[...n,c,l]);return u===M.NUM?M.DIV0:u},{from:`formulajs`})}function w_(e,t,n=!1,r=1,i=M.DIV0){let a=__(t);z(e,`(r)`,(e,t)=>{let o=n?Eo(e,t):To(e,t);if(o instanceof j)return o;if(o.length<r)return i;let s=y_(a,[o]);return s===M.NUM&&i===M.DIV0?M.DIV0:s},{from:`formulajs`})}function T_(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?``:Yn(Number(n));if(a===void 0)return o;let s=i===void 0?``:Yn(Number(i));return`${o}${r??``}${s===`1`?``:s}${a}`}function E_(e,t){let n=__(e);R(e,t.length,t.length,(...e)=>{let r=[];for(let[n,i]of e.entries()){let e=t.charAt(n)===`n`?I(i):L(i);if(e instanceof j)return e;r.push(e)}let i=y_(n,r);return typeof i==`string`?T_(i):i},{from:`formulajs`})}for(let e of/* @__PURE__ */ `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(`.`))Z(e,`n`,e);for(let e of[`COMBIN`,`COMBINA`,`MROUND`,`PERMUT`,`PERMUTATIONA`,`POWER`])Z(e,`nn`,e);Z(`TRUNC`,`n?n`,`TRUNC`),Z(`CEILING`,`nn`,`CEILING`),R(`FLOOR`,2,2,(e,t)=>{let n=I(e??0);if(n instanceof j)return n;let r=I(t??0);return r instanceof j?r:n===0&&r===0?0:y_(__(`FLOOR`),[n,r])}),Z(`CEILING.MATH`,`n?nn`,`CEILINGMATH`),Z(`FLOOR.MATH`,`n?nn`,`FLOORMATH`),Z(`CEILING.PRECISE`,`n?n`,`CEILINGPRECISE`),Z(`FLOOR.PRECISE`,`n?n`,`FLOORPRECISE`),So(`ISO.CEILING`,`CEILING.PRECISE`),R(`PI`,0,0,()=>Math.PI),z(`RAND`,``,(e,t)=>t.calc.random(),{volatile:!0}),z(`RANDBETWEEN`,`vv`,(e,t)=>{let n=I(t.calc.scalar(e[0],t.frame)),r=I(t.calc.scalar(e[1],t.frame));if(n instanceof j)return n;if(r instanceof j)return r;let i=Math.ceil(n),a=Math.floor(r);return i>a?M.NUM:i+Math.floor(t.calc.random()*(a-i+1))},{volatile:!0}),w_(`MULTINOMIAL`,`MULTINOMIAL`),w_(`AVEDEV`,`AVEDEV`,!1,1,M.NUM),w_(`DEVSQ`,`DEVSQ`,!1,1,M.NUM),w_(`MEDIAN`,`MEDIAN`,!1,1,M.NUM),w_(`SKEW`,`SKEW`,!1,3),w_(`SKEW.P`,`SKEW.P`,!1,3),w_(`STDEV.S`,`STDEV.S`,!1,2),w_(`STDEV.P`,`STDEV.P`,!1,1),w_(`VAR.S`,`VAR.S`,!1,2),w_(`VAR.P`,`VAR.P`,!1,1),w_(`STDEVA`,`STDEVA`,!0,2),w_(`STDEVPA`,`STDEVPA`,!0,1),w_(`VARA`,`VARA`,!0,2),w_(`VARPA`,`VARPA`,!0,1);for(let[e,t]of[[`STDEV`,`STDEV.S`],[`STDEVP`,`STDEV.P`],[`VAR`,`VAR.S`],[`VARP`,`VAR.P`]])So(e,t);S_(`PERCENTILE.INC`,`ln`,`PERCENTILE.INC`),S_(`PERCENTILE.EXC`,`ln`,`PERCENTILE.EXC`),S_(`PERCENTRANK.INC`,`ln?n`,`PERCENTRANK.INC`),S_(`PERCENTRANK.EXC`,`ln?n`,`PERCENTRANK.EXC`),S_(`QUARTILE.EXC`,`ln`,`QUARTILE.EXC`),z(`TRIMMEAN`,`rv`,(e,t)=>{let n=To([e[0]],t);if(n instanceof j)return n;let r=I(t.calc.scalar(e[1],t.frame));if(r instanceof j)return r;if(r<0||r>=1||n.length===0)return M.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}),So(`PERCENTILE`,`PERCENTILE.INC`),So(`PERCENTRANK`,`PERCENTRANK.INC`),C_(`CORREL`,`CORREL`),C_(`PEARSON`,`PEARSON`),C_(`RSQ`,`RSQ`),C_(`SLOPE`,`SLOPE`),C_(`INTERCEPT`,`INTERCEPT`),C_(`STEYX`,`STEYX`,``,3),C_(`COVARIANCE.P`,`COVARIANCE.P`),C_(`COVARIANCE.S`,`COVARIANCE.S`,``,2),C_(`FORECAST`,`FORECAST`,`n`),So(`FORECAST.LINEAR`,`FORECAST`),So(`COVAR`,`COVARIANCE.P`),Z(`PV`,`nnn?nn`,`PV`),Z(`NPER`,`nnn?nn`,`NPER`),Z(`RATE`,`nnn?nnn`,`RATE`),Z(`SYD`,`nnnn`,`SYD`),Z(`DDB`,`nnnn?n`,`DDB`),Z(`ISPMT`,`nnnn`,`ISPMT`),Z(`EFFECT`,`nn`,`EFFECT`),Z(`NOMINAL`,`nn`,`NOMINAL`),Z(`CUMIPMT`,`nnnnnn`,`CUMIPMT`),Z(`CUMPRINC`,`nnnnnn`,`CUMPRINC`),Z(`DOLLARDE`,`nn`,`DOLLARDE`),Z(`DOLLARFR`,`nn`,`DOLLARFR`),Z(`PDURATION`,`nnn`,`PDURATION`),Z(`RRI`,`nnn`,`RRI`),S_(`IRR`,`l?n`,`IRR`),S_(`MIRR`,`lnn`,`MIRR`),S_(`NPV`,`nr`,`NPV`),S_(`FVSCHEDULE`,`nl`,`FVSCHEDULE`);for(let e of[`BIN2DEC`,`HEX2DEC`,`OCT2DEC`,`IMABS`,`IMAGINARY`,`IMARGUMENT`,`IMREAL`])Z(e,`t`,e);for(let e of[`IMCONJUGATE`,`IMCOS`,`IMCOSH`,`IMCOT`,`IMCSC`,`IMCSCH`,`IMEXP`,`IMLN`,`IMLOG10`,`IMLOG2`,`IMSEC`,`IMSECH`,`IMSIN`,`IMSINH`,`IMSQRT`,`IMTAN`])E_(e,`t`);for(let e of[`BIN2OCT`,`HEX2BIN`,`HEX2OCT`,`OCT2BIN`])Z(e,`t?n`,e);for(let e of[`DEC2BIN`,`DEC2OCT`])Z(e,`n?n`,e);for(let[e,t]of[[`BIN2HEX`,`t`],[`OCT2HEX`,`t`],[`DEC2HEX`,`n`]]){let n=__(e);R(e,1,2,(e,r)=>{let i=t===`n`?I(e):L(e);if(i instanceof j)return i;let a=r===void 0?void 0:I(r);if(a instanceof j)return a;let o=y_(n,[i,a]);return typeof o==`string`?o.toUpperCase():o},{from:`formulajs`})}E_(`IMDIV`,`tt`),E_(`IMSUB`,`tt`),E_(`IMPOWER`,`tn`),Z(`COMPLEX`,`nn?t`,`COMPLEX`),Z(`DECIMAL`,`tn`,`DECIMAL`),Z(`ARABIC`,`t`,`ARABIC`);for(let e of[`IMSUM`,`IMPRODUCT`]){let t=__(e);z(e,`(r)`,(e,n)=>{let r=[],i;if(Co(e,n,e=>{if(i||e===null)return;let t=L(e);t instanceof j?i=t:r.push(t)}),i)return i;let a=y_(t,r);return typeof a==`string`?T_(a):a},{from:`formulajs`})}Z(`DELTA`,`n?n`,`DELTA`),Z(`GESTEP`,`n?n`,`GESTEP`);let D_=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.00016431823292116355,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22],O_=.5*Math.log(2*Math.PI);function k_(e){if(Number.isInteger(e)&&e<=171)return Math.log(A_(e));let t=D_[0]??0;for(let n=1;n<D_.length;n++)t+=(D_[n]??0)/(e+n);let n=e+4.7421875+.5;return O_+Math.log(t/e)+(e+.5)*Math.log(n)-n}function A_(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)*A_(1-e)):Math.exp(k_(e))}let j_=1e-16,M_=1e-300,N_=1e5;function P_(e,t){if(t<=0)return 0;if(t<e+1){let n=1/e,r=n,i=e;for(let e=0;e<N_&&(i+=1,n*=t/i,r+=n,!(Math.abs(n)<Math.abs(r)*j_));e++);return r*Math.exp(-t+e*Math.log(t)-k_(e))}return 1-F_(e,t)}function F_(e,t){if(t<=0)return 1;if(t<e+1)return 1-P_(e,t);let n=t+1-e,r=1/M_,i=1/n,a=i;for(let t=1;t<N_;t++){let o=-t*(t-e);n+=2,i=o*i+n,Math.abs(i)<M_&&(i=M_),r=n+o/r,Math.abs(r)<M_&&(r=M_),i=1/i;let s=i*r;if(a*=s,Math.abs(s-1)<j_)break}return Math.exp(-t+e*Math.log(t)-k_(e))*a}function I_(e,t,n){let r=e+t,i=e+1,a=e-1,o=1,s=1-r*n/i;Math.abs(s)<M_&&(s=M_),s=1/s;let c=s;for(let l=1;l<N_;l++){let u=2*l,d=l*(t-l)*n/((a+u)*(e+u));s=1+d*s,Math.abs(s)<M_&&(s=M_),o=1+d/o,Math.abs(o)<M_&&(o=M_),s=1/s,c*=s*o,d=-(e+l)*(r+l)*n/((e+u)*(i+u)),s=1+d*s,Math.abs(s)<M_&&(s=M_),o=1+d/o,Math.abs(o)<M_&&(o=M_),s=1/s;let f=s*o;if(c*=f,Math.abs(f-1)<j_)break}return c}function L_(e,t,n){if(n<=0)return 0;if(n>=1)return 1;let r=Math.exp(k_(e+t)-k_(e)-k_(t)+e*Math.log(n)+t*Math.log1p(-n));return n<(e+1)/(e+t+2)?r*I_(e,t,n)/e:1-r*I_(t,e,1-n)/t}let R_=e=>e===0?0:(e<0?-1:1)*P_(.5,e*e),z_=e=>e<0?2-z_(-e):F_(.5,e*e),B_=e=>Math.exp(-e*e/2)/Math.sqrt(2*Math.PI),V_=e=>z_(-e/Math.SQRT2)/2,H_=(e,t)=>e.reduce((e,n)=>e*t+n,0),U_={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 W_(e){let t=e-.5;if(t===0)return 0;if(Math.abs(t)<=.425){let e=.180625-t*t;return t*H_(U_.a,e)/H_(U_.b,e)}let n=t<0?e:1-e,r=Math.sqrt(-Math.log(n)),i=r<=5?H_(U_.c,r-1.6)/H_(U_.d,r-1.6):H_(U_.e,r-5)/H_(U_.f,r-5);return t<0?-i:i}function G_(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 K_(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}let q_=4e4;function J_(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 Y_(e,t){let n=K_(n=>Math.sin(t*Math.sin(n)-e*n),0,Math.PI,q_),r=Math.asinh((760+2*e*e)/t)+2,i=e%2==0?1:-1;return(n-K_(n=>(Math.exp(e*n)+i*Math.exp(-e*n))*Math.exp(-t*Math.sinh(n)),0,r,q_))/Math.PI}function X_(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 Z_(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 Q(e,t,n,r){R(e,t,n,(...e)=>{let t=[];for(let n of e){let e=n===void 0?NaN:I(n);if(e instanceof j)return e;t.push(e)}return r(...t)})}function Q_(e,t,n,r=0){R(e,t+1,t+1+r,(...e)=>{let r=io(e[t]);if(r instanceof j)return r;let i=[];for(let[n,r]of e.entries()){if(n===t)continue;let e=r===void 0?NaN:I(r);if(e instanceof j)return e;i.push(e)}return n(r,...i)})}let $_=e=>Number.isFinite(e)?e:M.NUM;Q_(`NORM.DIST`,3,(e,t=0,n=0,r=0)=>{if(r<=0)return M.NUM;let i=(t-n)/r;return e?V_(i):B_(i)/r}),Q(`NORM.INV`,3,3,(e=0,t=0,n=0)=>e<=0||e>=1||n<=0?M.NUM:t+n*W_(e)),R(`NORM.S.DIST`,1,2,(e,t)=>{let n=I(e);if(n instanceof j)return n;let r=t===void 0||io(t);return r instanceof j?r:r?V_(n):B_(n)}),Q(`NORMSDIST`,1,1,(e=0)=>V_(e)),Q(`NORM.S.INV`,1,1,(e=0)=>e<=0||e>=1?M.NUM:W_(e)),Q_(`LOGNORM.DIST`,3,(e,t=0,n=0,r=0)=>{if(t<=0||r<=0)return M.NUM;let i=(Math.log(t)-n)/r;return e?V_(i):B_(i)/(t*r)}),Q(`LOGNORMDIST`,3,3,(e=0,t=0,n=0)=>e<=0||n<=0?M.NUM:V_((Math.log(e)-t)/n)),Q(`LOGNORM.INV`,3,3,(e=0,t=0,n=0)=>e<=0||e>=1||n<=0?M.NUM:Math.exp(t+n*W_(e))),Q(`STANDARDIZE`,3,3,(e=0,t=0,n=0)=>n<=0?M.NUM:(e-t)/n),Q(`GAUSS`,1,1,(e=0)=>V_(e)-.5),Q(`PHI`,1,1,(e=0)=>B_(e)),Q(`FISHER`,1,1,(e=0)=>e<=-1||e>=1?M.NUM:.5*Math.log((1+e)/(1-e))),Q(`FISHERINV`,1,1,(e=0)=>{let t=Math.exp(2*e);return(t-1)/(t+1)}),Q(`CONFIDENCE.NORM`,3,3,(e=0,t=0,n=0)=>{let r=Math.trunc(n);return e<=0||e>=1||t<=0||r<1?M.NUM:W_(1-e/2)*t/Math.sqrt(r)});let ev=(e,t)=>L_(t/2,.5,t/(t+e*e)),tv=(e,t)=>e<0?ev(e,t)/2:1-ev(e,t)/2;Q_(`T.DIST`,2,(e,t=0,n=0)=>{let r=Math.trunc(n);return r<1?M.NUM:e?tv(t,r):Math.exp(k_((r+1)/2)-k_(r/2))/Math.sqrt(r*Math.PI)*(1+t*t/r)**(-(r+1)/2)}),Q(`T.DIST.2T`,2,2,(e=0,t=0)=>{let n=Math.trunc(t);return e<0||n<1?M.NUM:ev(e,n)}),Q(`T.DIST.RT`,2,2,(e=0,t=0)=>{let n=Math.trunc(t);return n<1?M.NUM:e<0?1-ev(e,n)/2:ev(e,n)/2}),Q(`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?M.NUM:ev(e,r)*i/2}),Q(`T.INV`,2,2,(e=0,t=0)=>{let n=Math.trunc(t);return e<=0||e>=1||n<1?M.NUM:e===.5?0:e<.5?-nv(2*e,n):nv(2*(1-e),n)});let nv=(e,t)=>G_(e=>-ev(e,t),-e,0,1);Q(`T.INV.2T`,2,2,(e=0,t=0)=>{let n=Math.trunc(t);return e<=0||e>1||n<1?M.NUM:nv(e,n)}),Q(`CONFIDENCE.T`,3,3,(e=0,t=0,n=0)=>{let r=Math.trunc(n);return e<=0||e>=1||t<=0||r<1?M.NUM:r===1?M.DIV0:nv(e,r-1)*t/Math.sqrt(r)}),Q_(`CHISQ.DIST`,2,(e,t=0,n=0)=>{let r=Math.trunc(n);return t<0||r<1?M.NUM:e?P_(r/2,t/2):t===0?r===2?.5:r<2?M.NUM:0:Math.exp((r/2-1)*Math.log(t)-t/2-r/2*Math.LN2-k_(r/2))}),Q(`CHISQ.DIST.RT`,2,2,(e=0,t=0)=>{let n=Math.trunc(t);return e<0||n<1?M.NUM:F_(n/2,e/2)}),Q(`CHISQ.INV`,2,2,(e=0,t=0)=>{let n=Math.trunc(t);return e<0||e>=1||n<1?M.NUM:e===0?0:G_(e=>P_(n/2,e/2),e,0,n)}),Q(`CHISQ.INV.RT`,2,2,(e=0,t=0)=>{let n=Math.trunc(t);return e<=0||e>1||n<1?M.NUM:e===1?0:G_(e=>-F_(n/2,e/2),-e,0,n)});let rv=(e,t,n)=>L_(t/2,n/2,t*e/(t*e+n)),iv=(e,t,n)=>L_(n/2,t/2,n/(t*e+n));Q_(`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 M.NUM;if(e)return rv(t,i,a);if(t===0)return i===2?1:i<2?M.NUM:0;let o=k_((i+a)/2)-k_(i/2)-k_(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)}),Q(`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?M.NUM:iv(e,r,i)}),Q(`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?M.NUM:e===0?0:e===1?M.NUM:G_(e=>rv(e,r,i),e,0,1)}),Q(`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?M.NUM:e===1?0:G_(e=>-iv(e,r,i),-e,0,1)}),Q_(`GAMMA.DIST`,3,(e,t=0,n=0,r=0)=>t<0||n<=0||r<=0?M.NUM:e?P_(n,t/r):t===0?n===1?1/r:n<1?M.NUM:0:Math.exp((n-1)*Math.log(t)-t/r-n*Math.log(r)-k_(n))),Q(`GAMMA.INV`,3,3,(e=0,t=0,n=0)=>e<0||e>=1||t<=0||n<=0?M.NUM:e===0?0:n*G_(e=>P_(t,e),e,0,t));let av=(e,t,n)=>Math.exp(k_(t+n)-k_(t)-k_(n)+(t-1)*Math.log(e)+(n-1)*Math.log1p(-e));Q_(`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 M.NUM;let c=(t-o)/(s-o);return e?L_(n,r,c):av(c,n,r)/(s-o)},2),Q(`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?M.NUM:L_(t,n,(e-a)/(o-a))}),Q(`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?M.NUM:a+(o-a)*G_(e=>L_(t,n,e),e,0,.5,1)}),So(`BETAINV`,`BETA.INV`);let ov=(e,t)=>k_(e+1)-k_(t+1)-k_(e-t+1),sv=(e,t,n)=>n===0?+(e===0):n===1?+(e===t):Math.exp(ov(t,e)+e*Math.log(n)+(t-e)*Math.log1p(-n)),cv=(e,t,n)=>e>=t||n===0?1:n===1?0:1-L_(e+1,t-e,n);Q_(`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?M.NUM:e?cv(i,a,r):sv(i,a,r)}),Q(`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 M.NUM;for(let e=0;e<r;e++)if(cv(e,r,t)>=n)return e;return r}),Q(`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 M.NUM;let s=0;for(let e=a;e<=o;e++)s+=sv(e,i,t);return s}),Q_(`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?M.NUM:e?L_(a,i+1,r):r===0||r===1?+(r===1&&i===0):Math.exp(ov(i+a-1,a-1)+a*Math.log(r)+i*Math.log1p(-r))}),Q(`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?M.NUM:n===0||n===1?+(n===1&&r===0):Math.exp(ov(r+i-1,i-1)+i*Math.log(n)+r*Math.log1p(-n))}),Q_(`POISSON.DIST`,2,(e,t=0,n=0)=>{let r=Math.trunc(t);return r<0||n<0?M.NUM:n===0?e||r===0?1:0:e?F_(r+1,n):Math.exp(r*Math.log(n)-n-k_(r+1))}),Q_(`EXPON.DIST`,2,(e,t=0,n=0)=>t<0||n<=0?M.NUM:e?-Math.expm1(-n*t):n*Math.exp(-n*t)),Q_(`WEIBULL.DIST`,3,(e,t=0,n=0,r=0)=>{if(t<0||n<=0||r<=0)return M.NUM;let i=(t/r)**n;return e?-Math.expm1(-i):n/r**n*t**(n-1)*Math.exp(-i)});let lv=(e,t,n,r)=>Math.exp(ov(n,e)+ov(r-n,t-e)-ov(r,t));Q_(`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 M.NUM;if(!e)return lv(a,o,s,c);let l=0;for(let e=Math.max(0,o-c+s);e<=a;e++)l+=lv(e,o,s,c);return Math.min(1,l)}),Q(`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?M.NUM:lv(i,a,o,s)}),Q(`GAMMA`,1,1,(e=0)=>$_(A_(e))),Q(`GAMMALN`,1,1,(e=0)=>e<=0?M.NUM:k_(e)),So(`GAMMALN.PRECISE`,`GAMMALN`),Q(`ERF`,1,2,(e=0,t=NaN)=>Number.isNaN(t)?R_(e):R_(t)-R_(e)),Q(`ERFC`,1,1,(e=0)=>z_(e)),So(`ERF.PRECISE`,`ERF`),So(`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`]])So(e,t);let uv=2**48;function dv(e,t){let[n=`0`,r=`0`]=e.toExponential().split(`e`);return Number(`${n}e${String(Number(r)+t)}`)}let fv=e=>Number(e.toPrecision(15));function pv(e,t,n){let r=Math.trunc(t),i=dv(Math.abs(fv(e)),r);if(i>=2**53)return e;let a=dv(n(i),-r);return e<0?-a:a}R(`ROUND`,2,2,Do((e=0,t=0)=>pv(e,t,e=>Math.floor(e+.5)))),R(`ROUNDUP`,2,2,Do((e=0,t=0)=>pv(e,t,Math.ceil))),R(`ROUNDDOWN`,2,2,Do((e=0,t=0)=>pv(e,t,Math.floor))),R(`MOD`,2,2,Do((e=0,t=0)=>{if(t===0)return M.DIV0;let n=e%t;return n!==0&&n<0!=t<0?n+t:n})),R(`QUOTIENT`,2,2,Do((e=0,t=0)=>t===0?M.DIV0:Math.trunc(e/t))),R(`POWER`,2,2,Do((e=0,t=0)=>{if(e===0&&t===0)return M.NUM;if(e===0&&t<0)return M.DIV0;let n=e**t;return Number.isFinite(n)?n:M.NUM})),R(`LOG`,1,2,(e,t)=>{let n=I(e),r=t==null?10:I(t);return n instanceof j?n:r instanceof j?r:n<=0||r<=0?M.NUM:r===1?M.DIV0:r===10?Math.log10(n):r===2?Math.log2(n):Math.log(n)/Math.log(r)});function mv(e,t){let[n,r]=[e,t];for(;r!==0;)[n,r]=[r,n%r];return n}function hv(e,t){let n=To(e,t);if(n instanceof j)return n;let r=n.map(Math.trunc);return r.some(e=>e<0||e>=2**53)?M.NUM:r}z(`GCD`,`(r)`,(e,t)=>{let n=hv(e,t);return n instanceof j?n:n.reduce(mv,0)}),z(`LCM`,`(r)`,(e,t)=>{let n=hv(e,t);if(n instanceof j)return n;if(n.includes(0))return 0;let r=n.reduce((e,t)=>e*t/mv(e,t),1);return Number.isFinite(r)?r:M.NUM}),R(`BASE`,2,3,Do((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?M.NUM:r.toString(i).toUpperCase().padStart(a,`0`)}));let gv=[1e3,500,100,50,10,5,1];function _v(e,t){let n=e=>gv[e]??1,r=e=>`MDCLXVI`.charAt(e),i=gv.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}R(`ROMAN`,1,2,(e,t)=>{let n=I(e);if(n instanceof j)return n;let r=0;if(typeof t==`boolean`)r=t?0:4;else if(t!=null){let e=I(t);if(e instanceof j)return e;r=Math.trunc(e)}let i=Math.trunc(n);return i<0||i>3999||r<0||r>4?M.VALUE:_v(i,r)});function vv(e){return!Number.isInteger(e)||e<0||e>=uv?M.NUM:BigInt(e)}for(let[e,t]of[[`BITAND`,(e,t)=>e&t],[`BITOR`,(e,t)=>e|t],[`BITXOR`,(e,t)=>e^t]])R(e,2,2,Do((e=0,n=0)=>{let r=vv(e),i=vv(n);return r instanceof j?r:i instanceof j?i:Number(t(r,i))}));for(let[e,t]of[[`BITLSHIFT`,1],[`BITRSHIFT`,-1]])R(e,2,2,Do((e=0,n=0)=>{let r=vv(e);if(r instanceof j)return r;let i=Math.trunc(n)*t;if(Math.abs(i)>53)return M.NUM;let a=i>=0?r<<BigInt(i):r>>BigInt(-i);return a>=BigInt(uv)?M.NUM:Number(a)}));for(let[e,t,n]of[[`BESSELJ`,J_,!1],[`BESSELI`,X_,!1],[`BESSELY`,Y_,!0],[`BESSELK`,Z_,!0]])R(e,2,2,Do((e=0,r=0)=>{let i=Math.trunc(r);if(i<0||n&&e<=0)return M.NUM;let a=t(i,e);return Number.isFinite(a)?a:M.NUM}));R(`SLN`,3,3,Do((e=0,t=0,n=0)=>n===0?M.DIV0:(e-t)/n)),z(`GEOMEAN`,`(r)`,(e,t)=>{let n=To(e,t);return n instanceof j?n:n.length===0||n.some(e=>e<=0)?M.NUM:Math.exp(n.reduce((e,t)=>e+Math.log(t),0)/n.length)}),z(`HARMEAN`,`(r)`,(e,t)=>{let n=To(e,t);return n instanceof j?n:n.length===0||n.some(e=>e<=0)?M.NUM:n.length/n.reduce((e,t)=>e+1/t,0)}),z(`KURT`,`(r)`,(e,t)=>{let n=To(e,t);if(n instanceof j)return n;let r=n.length;if(r<4)return M.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 M.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 yv(e,t){let n=[],r;return wo(e,t,(e,t)=>{if(!r){if(e instanceof j)r=e;else if(typeof e==`number`)n.push(e);else if(t&&e!==null){let t=I(e);t instanceof j?r=t:n.push(t)}}}),r??n}z(`MODE.SNGL`,`(r)`,(e,t)=>{let n=yv(e,t);if(n instanceof j)return n;let r=/* @__PURE__ */ 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??M.NA}),So(`MODE`,`MODE.SNGL`),z(`MODE.MULT`,`(r)`,(e,t)=>{let n=yv(e,t);if(n instanceof j)return n;let r=/* @__PURE__ */ 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 M.NA;let a=[...r].filter(([,e])=>e===i).map(([e])=>e);return new N(a.length,1,a)});function bv(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)}z(`QUARTILE.INC`,`rv`,(e,t)=>{let n=To([e[0]],t);if(n instanceof j)return n;let r=I(t.calc.scalar(e[1],t.frame));if(r instanceof j)return r;let i=Math.trunc(r);return n.length===0||i<0||i>4?M.NUM:bv([...n].sort((e,t)=>e-t),i/4)}),So(`QUARTILE`,`QUARTILE.INC`);function xv(e,t){let n=I(t.calc.scalar(e[0],t.frame));if(n instanceof j)return n;let r=To([e[1]],t);if(r instanceof j)return r;let i=e[2]===void 0?0:I(t.calc.scalar(e[2],t.frame));if(i instanceof j)return i;let a=r.filter(e=>e===n).length;return a===0?M.NA:{before:r.filter(e=>i===0?e>n:e<n).length,ties:a}}z(`RANK.EQ`,`vr?v`,(e,t)=>{let n=xv(e,t);return n instanceof j?n:n.before+1}),z(`RANK.AVG`,`vr?v`,(e,t)=>{let n=xv(e,t);return n instanceof j?n:n.before+(n.ties+1)/2}),So(`RANK`,`RANK.EQ`);function Sv(e,t){let n=B(e,t);if(n instanceof j)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 j)return i;if(typeof i!=`number`)return M.VALUE;t.push(i)}r.push(t)}return r}let Cv=e=>new N(e.length,e[0]?.length??0,e.flat());function wv(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)))}z(`MMULT`,`rr`,(e,t)=>{let n=Sv(e[0],t),r=Sv(e[1],t);return n instanceof j?n:r instanceof j?r:(n[0]?.length??0)===r.length?Cv(wv(n,r)):M.VALUE});function Tv(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))}}let Ev=e=>e.length>0&&e.every(t=>t.length===e.length);z(`MDETERM`,`r`,(e,t)=>{let n=Sv(e[0],t);return n instanceof j?n:Ev(n)?Tv(n).determinant:M.VALUE}),z(`MINVERSE`,`r`,(e,t)=>{let n=Sv(e[0],t);if(n instanceof j)return n;if(!Ev(n))return M.VALUE;let{inverse:r}=Tv(n);return r?Cv(r):M.NUM}),R(`MUNIT`,1,1,Do((e=0)=>{let t=Math.trunc(e);return t<1||t>73?M.VALUE:Cv(Array.from({length:t},(e,n)=>Array.from({length:t},(e,t)=>+(n===t))))}));function Dv(e,t,n){let r=B(e,n),i=B(t,n);if(r instanceof j)return r;if(i instanceof j)return i;if(r.rows*r.cols!==i.rows*i.cols)return M.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 j)return n;if(s instanceof j)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]])z(e,`rr`,(e,n)=>{let r=Dv(e[0],e[1],n);return r instanceof j?r:r.xs.length===0?M.DIV0:r.xs.reduce((e,n,i)=>e+t(n,r.ys[i]??0),0)});z(`SERIESSUM`,`vvvr`,(e,t)=>{let[n,r,i]=e.slice(0,3).map(e=>I(t.calc.scalar(e,t.frame)));if(n instanceof j)return n;if(r instanceof j)return r;if(i instanceof j)return i;let a=To([e[3]],t);return a instanceof j?a:a.reduce((e,t,a)=>e+t*(n??0)**((r??0)+a*(i??0)),0)}),z(`FREQUENCY`,`rr`,(e,t)=>{let n=To([e[0]],t);if(n instanceof j)return n;let r=[];Co([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 N(a.length,1,a)}),z(`PROB`,`rrv?v`,(e,t)=>{let n=Dv(e[0],e[1],t);if(n instanceof j)return n;let r=I(t.calc.scalar(e[2],t.frame));if(r instanceof j)return r;let i=e[3]===void 0?r:I(t.calc.scalar(e[3],t.frame));if(i instanceof j)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?M.NUM:n.xs.reduce((e,t,a)=>t>=r&&t<=i?e+(n.ys[a]??0):e,0)});let Ov=e=>e.reduce((e,t)=>e+t,0);function kv(e,t,n){let r=t.map(e=>n?[...e,1]:[...e]),i=r[0]?.length??0,{inverse:a}=Tv(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 Av(e,t,n){let r=Sv(e[0],t);if(r instanceof j)return r;let i=r.length===1,a=r.flat();if(n&&a.some(e=>e<=0))return M.NUM;let o=n?a.map(Math.log):a,s=e[1];if(s===void 0||!jv(s))return{ys:o,xs:a.map((e,t)=>[t+1]),byRow:i};let c=Sv(s,t);if(c instanceof j)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}:M.REF:c.length===o.length?{ys:o,xs:c,byRow:i}:M.REF}let jv=e=>e instanceof P||e instanceof N||typeof e==`number`,Mv=(e,t)=>e===void 0||!jv(e)&&typeof e!=`boolean`||io(t.calc.scalar(e,t.frame));function Nv(e){return(t,n)=>{let r=Av(t,n,e);if(r instanceof j)return r;let i=Mv(t[3],n);if(i instanceof j)return i;let a=kv(r.ys,r.xs,i);if(!a)return M.NUM;let o=t[2],s=r.xs;if(o!==void 0&&jv(o)){let e=Sv(o,n);if(e instanceof j)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 N(1,c.length,c):new N(c.length,1,c)}}z(`TREND`,`r?rrv`,Nv(!1)),z(`GROWTH`,`r?rrv`,Nv(!0));function Pv(e,t,n,r){let i=t.map(e=>r?[...e,1]:[...e]),a=i[0]?.length??0,{inverse:o}=Tv(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?Ov(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 Fv(e){return(t,n)=>{let r=Av(t,n,e);if(r instanceof j)return r;let i=Mv(t[2],n);if(i instanceof j)return i;let a=kv(r.ys,r.xs,i);if(!a)return M.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||!Iv(c)?!1:io(n.calc.scalar(c,n.frame));if(l instanceof j)return l;if(!l)return new N(1,s.length,s);let u=Pv(r.ys,r.xs,a,i);if(!u)return M.NUM;let d=s.length,f=e=>[...e,...Array(d-e.length).fill(M.NA)],p=i?[...u.errors.slice(0,-1).reverse(),u.errors[u.errors.length-1]??0]:[...[...u.errors].reverse(),M.NA];return new N(5,d,[...s,...p,...f([u.r2,u.sey]),...f([u.f,u.df]),...f([u.ssreg,u.ssresid])])}}let Iv=e=>jv(e)||typeof e==`boolean`;z(`LINEST`,`r?rvv`,Fv(!1)),z(`LOGEST`,`r?rvv`,Fv(!0));let Lv=e=>Ov(e)/e.length,Rv=e=>{let t=Lv(e);return e.reduce((e,n)=>e+(n-t)**2,0)/(e.length-1)};z(`CHISQ.TEST`,`rr`,(e,t)=>{let n=Sv(e[0],t),r=Sv(e[1],t);if(n instanceof j)return n;if(r instanceof j)return r;let i=n.length,a=n[0]?.length??0;if(r.length!==i||(r[0]?.length??0)!==a||i*a<2)return M.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 M.NUM;if(i===0)return M.DIV0;o+=((n[e]?.[t]??0)-i)**2/i}return F_((i>1&&a>1?(i-1)*(a-1):i>1?i-1:a-1)/2,o/2)}),So(`CHITEST`,`CHISQ.TEST`),z(`T.TEST`,`rrvv`,(e,t)=>{let n=I(t.calc.scalar(e[2],t.frame)),r=I(t.calc.scalar(e[3],t.frame));if(n instanceof j)return n;if(r instanceof j)return r;let i=Math.trunc(n),a=Math.trunc(r);if(i!==1&&i!==2||a<1||a>3)return M.NUM;let o,s;if(a===1){let n=Dv(e[0],e[1],t);if(n instanceof j)return n;let r=n.xs.map((e,t)=>e-(n.ys[t]??0));if(r.length<2)return M.DIV0;o=Lv(r)/Math.sqrt(Rv(r)/r.length),s=r.length-1}else{let n=To([e[0]],t),r=To([e[1]],t);if(n instanceof j)return n;if(r instanceof j)return r;if(n.length<2||r.length<2)return M.DIV0;let[i,c,l,u]=[Rv(n),Rv(r),n.length,r.length],d=Math.abs(Lv(n)-Lv(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)?L_(s/2,.5,s/(s+o*o))*i/2:M.DIV0}),So(`TTEST`,`T.TEST`),z(`F.TEST`,`rr`,(e,t)=>{let n=To([e[0]],t),r=To([e[1]],t);if(n instanceof j)return n;if(r instanceof j)return r;if(n.length<2||r.length<2)return M.DIV0;let[i,a]=[Rv(n),Rv(r)];if(i===0||a===0)return M.DIV0;let o=i/a,[s,c]=[n.length-1,r.length-1],l=L_(c/2,s/2,c/(s*o+c));return 2*Math.min(l,1-l)}),So(`FTEST`,`F.TEST`),z(`Z.TEST`,`rv?v`,(e,t)=>{let n=To([e[0]],t);if(n instanceof j)return n;let r=I(t.calc.scalar(e[1],t.frame));if(r instanceof j)return r;if(n.length===0)return M.NA;let i=e[2]===void 0?n.length<2?M.DIV0:Math.sqrt(Rv(n)):I(t.calc.scalar(e[2],t.frame));return i instanceof j?i:i===0?M.DIV0:1-V_((Lv(n)-r)/(i/Math.sqrt(n.length)))}),So(`ZTEST`,`Z.TEST`);let zv={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`};z(`AGGREGATE`,`vv(r)`,(e,t)=>{let n=I(t.calc.scalar(e[0],t.frame)),r=I(t.calc.scalar(e[1],t.frame));if(n instanceof j)return n;if(r instanceof j)return r;let i=zv[Math.trunc(n)],a=i===void 0?void 0:_o.get(i);if(a===void 0)return M.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 or?e.parts:[e],r=[];for(let e of n)if(e instanceof P){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 N?lr(r,n.data):r.push(n)}let i=o?r:r.filter(e=>!(e instanceof j));return new N(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)}),R(`FACT`,1,1,Do(e=>{if(e<0)return M.NUM;let t=1;for(let n=2;n<=Math.trunc(e);n++)t*=n;return Number.isFinite(t)?t:M.NUM})),R(`FACTDOUBLE`,1,1,Do(e=>{if(e<0)return M.NUM;let t=1;for(let n=Math.trunc(e);n>1;n-=2)t*=n;return Number.isFinite(t)?t:M.NUM})),R(`ATAN2`,2,2,Do((e,t)=>e===0&&t===0?M.DIV0:Math.atan2(t,e)));let Bv={largest:/* @__PURE__ */ new WeakMap,smallest:/* @__PURE__ */ new WeakMap};function Vv(e,t,n){let r=()=>{let r=To([e],n);return r instanceof j?r:r.sort((e,n)=>t?n-e:e-n)};if(e instanceof P)return n.calc.indexes.ofRepeated(go(t?`large`:`small`,e),[e],()=>{let e=r();return new Map(e instanceof j?[]:[[``,e]])})?.get(``)??r();if(!(e instanceof N))return r();let i=t?Bv.largest:Bv.smallest,a=i.get(e);if(a)return a;let o=r();return o instanceof j||i.set(e,a===null?o:null),o}for(let[e,t]of[[`LARGE`,!0],[`SMALL`,!1]])z(e,`rv`,(e,n)=>{let r=Vv(e[0],t,n);if(r instanceof j)return r;let i=I(e[1]);if(i instanceof j)return i;let a=Math.ceil(i);return a<1||a>r.length?M.NUM:r[a-1]??M.NUM});let Hv=.0254,Uv=12*Hv,Wv=3*Uv,Gv=5280*Uv,Kv=1852,qv=9460730472580800,Jv=Hv/72,Yv=453.59237,Xv=9.80665,Zv=Yv/1e3*Xv,Qv=Uv*Zv,$v=231*Hv**3/128,ey=.00454609,ty=101325,ny=550*Qv,ry=/* @__PURE__ */ new Map;function $(e,t){for(let n of e)ry.set(n,t)}let iy=(e,t)=>({quantity:e,factor:t,prefix:1});$([`g`],iy(`mass`,1)),$([`sg`],{quantity:`mass`,factor:Zv*1e3/Uv}),$([`lbm`],{quantity:`mass`,factor:Yv}),$([`u`],iy(`mass`,1660538782e-33)),$([`ozm`],{quantity:`mass`,factor:Yv/16}),$([`grain`],{quantity:`mass`,factor:Yv/7e3}),$([`cwt`,`shweight`],{quantity:`mass`,factor:100*Yv}),$([`uk_cwt`,`lcwt`,`hweight`],{quantity:`mass`,factor:112*Yv}),$([`stone`],{quantity:`mass`,factor:14*Yv}),$([`ton`],{quantity:`mass`,factor:2e3*Yv}),$([`uk_ton`,`LTON`,`brton`],{quantity:`mass`,factor:2240*Yv}),$([`m`],iy(`distance`,1)),$([`mi`],{quantity:`distance`,factor:Gv}),$([`Nmi`],{quantity:`distance`,factor:Kv}),$([`in`],{quantity:`distance`,factor:Hv}),$([`ft`],{quantity:`distance`,factor:Uv}),$([`yd`],{quantity:`distance`,factor:Wv}),$([`ang`],iy(`distance`,1e-10)),$([`ell`],{quantity:`distance`,factor:45*Hv}),$([`ly`],iy(`distance`,qv)),$([`parsec`,`pc`],iy(`distance`,648e3/Math.PI*149597870700)),$([`Picapt`,`Pica`],{quantity:`distance`,factor:Jv}),$([`pica`],{quantity:`distance`,factor:Hv/6}),$([`survey_mi`],{quantity:`distance`,factor:6336e3/3937}),$([`yr`],{quantity:`time`,factor:31557600}),$([`day`,`d`],{quantity:`time`,factor:86400}),$([`hr`],{quantity:`time`,factor:3600}),$([`mn`,`min`],{quantity:`time`,factor:60}),$([`sec`,`s`],iy(`time`,1)),$([`Pa`,`p`],iy(`pressure`,1)),$([`atm`,`at`],iy(`pressure`,ty)),$([`mmHg`],iy(`pressure`,ty/760)),$([`psi`],{quantity:`pressure`,factor:Zv/Hv**2}),$([`Torr`],{quantity:`pressure`,factor:ty/760}),$([`N`],iy(`force`,1)),$([`dyn`,`dy`],iy(`force`,1e-5)),$([`lbf`],{quantity:`force`,factor:Zv}),$([`pond`],iy(`force`,Xv/1e3)),$([`J`],iy(`energy`,1)),$([`e`],iy(`energy`,1e-7)),$([`c`],iy(`energy`,4.184)),$([`cal`],iy(`energy`,4.1868)),$([`eV`,`ev`],iy(`energy`,1602176487e-28)),$([`HPh`,`hh`],{quantity:`energy`,factor:ny*3600}),$([`Wh`,`wh`],iy(`energy`,3600)),$([`flb`],{quantity:`energy`,factor:Qv}),$([`BTU`,`btu`],{quantity:`energy`,factor:1055.05585262}),$([`HP`,`h`],{quantity:`power`,factor:ny}),$([`PS`],{quantity:`power`,factor:75*Xv}),$([`W`,`w`],iy(`power`,1)),$([`T`],iy(`magnetism`,1)),$([`ga`],iy(`magnetism`,1e-4));let ay=(e,t,n=!1)=>{$(e,{quantity:`volume`,factor:t**3,...n?{prefix:3}:{}})};$([`tsp`],{quantity:`volume`,factor:$v/6}),$([`tspm`],{quantity:`volume`,factor:5e-6}),$([`tbs`],{quantity:`volume`,factor:$v/2}),$([`oz`],{quantity:`volume`,factor:$v}),$([`cup`],{quantity:`volume`,factor:8*$v}),$([`pt`,`us_pt`],{quantity:`volume`,factor:16*$v}),$([`uk_pt`],{quantity:`volume`,factor:ey/8}),$([`qt`],{quantity:`volume`,factor:32*$v}),$([`uk_qt`],{quantity:`volume`,factor:ey/4}),$([`gal`],{quantity:`volume`,factor:128*$v}),$([`uk_gal`],{quantity:`volume`,factor:ey}),$([`l`,`L`,`lt`],iy(`volume`,.001)),$([`barrel`],{quantity:`volume`,factor:5376*$v}),$([`bushel`],{quantity:`volume`,factor:2150.42*Hv**3}),$([`GRT`,`regton`],{quantity:`volume`,factor:100*Uv**3}),$([`MTON`],{quantity:`volume`,factor:40*Uv**3}),ay([`m3`,`m^3`],1,!0),ay([`ang3`,`ang^3`],1e-10,!0),ay([`ft3`,`ft^3`],Uv),ay([`in3`,`in^3`],Hv),ay([`ly3`,`ly^3`],qv),ay([`mi3`,`mi^3`],Gv),ay([`yd3`,`yd^3`],Wv),ay([`Nmi3`,`Nmi^3`],Kv),ay([`Pica3`,`Picapt3`,`Pica^3`,`Picapt^3`],Jv);let oy=(e,t,n=!1)=>{$(e,{quantity:`area`,factor:t**2,...n?{prefix:2}:{}})};$([`uk_acre`],{quantity:`area`,factor:4840*Wv**2}),$([`us_acre`],{quantity:`area`,factor:43560*(1200/3937)**2}),$([`ar`],iy(`area`,100)),$([`ha`],{quantity:`area`,factor:1e4}),$([`Morgen`],{quantity:`area`,factor:2500}),oy([`m2`,`m^2`],1,!0),oy([`ang2`,`ang^2`],1e-10,!0),oy([`ft2`,`ft^2`],Uv),oy([`in2`,`in^2`],Hv),oy([`ly2`,`ly^2`],qv),oy([`mi2`,`mi^2`],Gv),oy([`yd2`,`yd^2`],Wv),oy([`Nmi2`,`Nmi^2`],Kv),oy([`Pica2`,`Picapt2`,`Pica^2`,`Picapt^2`],Jv),$([`bit`],{quantity:`information`,factor:1,prefix:1,binary:!0}),$([`byte`],{quantity:`information`,factor:8,prefix:1,binary:!0}),$([`admkn`],{quantity:`speed`,factor:6080*Uv/3600}),$([`kn`],{quantity:`speed`,factor:Kv/3600}),$([`m/h`,`m/hr`],iy(`speed`,1/3600)),$([`m/s`,`m/sec`],iy(`speed`,1)),$([`mph`],{quantity:`speed`,factor:Gv/3600});let sy={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},cy={Yi:2**80,Zi:2**70,Ei:2**60,Pi:2**50,Ti:2**40,Gi:2**30,Mi:2**20,ki:1024},ly={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}},uy={C:`C`,cel:`C`,F:`F`,fah:`F`,K:`K`,kel:`K`,Rank:`Rank`,Reau:`Reau`};function dy(e){let t=uy[e];if(t!==void 0)return{kind:`temperature`,scale:t,times:1};let n=ry.get(e);if(n)return{kind:`unit`,quantity:n.quantity,factor:n.factor};for(let[t,n]of Object.entries(sy)){if(!e.startsWith(t))continue;let r=e.slice(t.length);if(uy[r]===`K`)return{kind:`temperature`,scale:`K`,times:n};let i=ry.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(cy)){if(!e.startsWith(t))continue;let r=ry.get(e.slice(t.length));if(r?.binary===!0)return{kind:`unit`,quantity:r.quantity,factor:r.factor*n}}}function fy(e,t,n){let r=dy(t),i=dy(n);if(!r||!i)return M.NA;if(r.kind===`temperature`||i.kind===`temperature`){if(r.kind!==`temperature`||i.kind!==`temperature`)return M.NA;let t=ly[r.scale],n=ly[i.scale];return!t||!n?M.NA:n.fromK(t.toK(e*r.times))/i.times}return r.quantity===i.quantity?e*r.factor/i.factor:M.NA}R(`CONVERT`,3,3,(e,t,n)=>{let r=I(e),i=L(t),a=L(n);return r instanceof j?r:i instanceof j?i:a instanceof j?a:fy(r,i,a)});let py=5e6,my=e=>Array.from({length:e.rows},(t,n)=>Array.from({length:e.cols},(t,r)=>e.at(n,r))),hy=e=>{let t=e[0]?.length??0;return new N(e.length,t,e.flat())},gy=e=>{let t=e[0]?.length??0;return Array.from({length:t},(t,n)=>e.map(e=>e[n]??null))};function _y(e,t){if(!(e===void 0||e instanceof F))return t.calc.scalar(e,t.frame)}function vy(e,t,n){let r=_y(e,t);return r==null?n:I(r)}function yy(e,t,n){let r=_y(e,t);return r==null?n:io(r)}function by(e,t,n){if(e===void 0||e instanceof F)return[n];let r=B(e,t);if(r instanceof j)return r;let i=[];for(let e=0;e<r.rows;e++)for(let t=0;t<r.cols;t++){let n=I(r.at(e,t));if(n instanceof j)return n;i.push(Math.trunc(n))}return i}let xy=e=>e===null||e===``;function Sy(e,t,n){if(xy(e)||xy(t))return xy(e)&&xy(t)?0:xy(e)?1:-1;let r=Qo(e,t);return n?-r:r}function Cy(e){return e instanceof j?e:e===null?!1:typeof e==`boolean`?e:typeof e==`number`?e!==0:M.VALUE}z(`FILTER`,`rr?r`,(e,t)=>{let n=B(e[0],t),r=B(e[1],t);if(n instanceof j)return n;if(r instanceof j)return r;if(r.rows>1&&r.cols>1)return M.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 M.VALUE;let a=my(n),o=i?a:gy(a),s=[];for(let e=0;e<o.length;e++){let t=Cy(i?r.at(e,0):r.at(0,e));if(t instanceof j)return t;t&&s.push(o[e]??[])}return s.length===0?e[2]===void 0||e[2]instanceof F?M.CALC:e[2]:hy(i?s:gy(s))}),z(`SORT`,`r?rrr`,(e,t)=>{let n=B(e[0],t);if(n instanceof j)return n;let r=by(e[1],t,1);if(r instanceof j)return r;let i=by(e[2],t,1);if(i instanceof j)return i;let a=yy(e[3],t,!1);if(a instanceof j)return a;let o=my(n),s=a?gy(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 M.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=Sy(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 hy(a?gy(l):l)}),z(`SORTBY`,`r(r)`,(e,t)=>{let n=B(e[0],t);if(n instanceof j)return n;let r=[],i;for(let a=1;a<e.length;a+=2){let o=B(e[a],t);if(o instanceof j)return o;if(o.rows>1&&o.cols>1)return M.VALUE;let s=o.cols===1&&o.rows===n.rows,c=o.rows===1&&o.cols===n.cols;if(!s&&!c)return M.VALUE;let l=i??s;if(l?!s:!c)return M.VALUE;i=l;let u=vy(e[a+1],t,1);if(u instanceof j)return u;if(u!==1&&u!==-1)return M.VALUE;r.push({values:my(o).flat(),descending:u<0})}let a=my(n),o=(i===!1?gy(a):a).map((e,t)=>({line:e,index:t})).sort((e,t)=>{for(let{values:n,descending:i}of r){let r=Sy(n[e.index]??null,n[t.index]??null,i);if(r!==0)return r}return e.index-t.index}).map(e=>e.line);return hy(i===!1?gy(o):o)});let wy=e=>e instanceof j?`e${e.code}`:typeof e==`string`?`s${e.toLowerCase()}`:`${typeof e}${String(e)}`;z(`UNIQUE`,`r?rr`,(e,t)=>{let n=B(e[0],t);if(n instanceof j)return n;let r=yy(e[1],t,!1);if(r instanceof j)return r;let i=yy(e[2],t,!1);if(i instanceof j)return i;let a=my(n),o=(n.reference?.rows??n.rows)-n.rows,s=e=>Array(e).fill(null);if(o>0&&r&&(a.length+o)*n.cols<=py)for(let e=0;e<o;e++)a.push(s(n.cols));let c=r?gy(a):a,l=/* @__PURE__ */ new Map,u=(e,t)=>{let n=e.map(wy).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?M.CALC:hy(r?gy(d):d)});function Ty(e,t){if(e instanceof j)return e;if(t instanceof j)return t;let n=Math.trunc(e),r=Math.trunc(t);return n<0||r<0?M.VALUE:n===0||r===0?M.CALC:n>1048576||r>16384||n*r>py?M.VALUE:{rows:n,cols:r}}z(`SEQUENCE`,`r?rrr`,(e,t)=>{let n=Ty(vy(e[0],t,1),vy(e[1],t,1));if(n instanceof j)return n;let r=vy(e[2],t,1);if(r instanceof j)return r;let i=vy(e[3],t,1);if(i instanceof j)return i;let a=Array(n.rows*n.cols);for(let e=0;e<a.length;e++)a[e]=r+e*i;return new N(n.rows,n.cols,a)}),z(`RANDARRAY`,`?rrrrr`,(e,t)=>{let n=Ty(vy(e[0],t,1),vy(e[1],t,1));if(n instanceof j)return n;let r=vy(e[2],t,0);if(r instanceof j)return r;let i=vy(e[3],t,1);if(i instanceof j)return i;let a=yy(e[4],t,!1);if(a instanceof j)return a;if(r>i||a&&(!Number.isInteger(r)||!Number.isInteger(i)))return M.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 N(n.rows,n.cols,o)},{volatile:!0}),z(`TEXTSPLIT`,`vr?rvvv`,(e,t)=>{let n=_y(e[0],t);if(n instanceof j)return n;let r=L(n??``);if(r instanceof j)return r;let i=Bs(e[1],t);if(i instanceof j)return i;let a=Bs(e[2],t);if(a instanceof j)return a;if(i.length===0&&a.length===0||i.includes(``)||a.includes(``))return M.VALUE;let o=yy(e[3],t,!1);if(o instanceof j)return o;let s=vy(e[4],t,0);if(s instanceof j)return s;let c=_y(e[5],t)??M.NA,l=s===1,u=(a.length===0?[r]:Hs(r,a,l)).filter(e=>!(o&&e===``)).map(e=>{let t=i.length===0?[e]:Hs(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?M.CALC:hy(u.map(e=>Array.from({length:d},(t,n)=>e[n]??c)))});let Ey=(e,t)=>{let n=t.calc.flat(e);return n instanceof N?n.at(0,0):n};z(`MAP`,`r(r)`,(e,t)=>{let n=e[e.length-1];if(!(n instanceof sr))return M.VALUE;let r=[];for(let n of e.slice(0,-1)){let e=B(n,t);if(e instanceof j)return e;r.push(e)}let i=r[0];if(!i)return M.VALUE;let{rows:a,cols:o}=i;if(r.some(e=>e.rows!==a||e.cols!==o))return M.VALUE;let s=Array(a*o);for(let e=0;e<a;e++)for(let i=0;i<o;i++)s[e*o+i]=Ey(t.calc.apply(n,r.map(t=>t.at(e,i))),t);return new N(a,o,s)});function Dy(e,t){let n=e.length===3,r=e[e.length-1];if(!(r instanceof sr))return M.VALUE;let i=B(e[+!!n],t);return i instanceof j?i:{start:n?_y(e[0],t)??null:i.at(0,0),cells:i,fn:r}}z(`REDUCE`,`rr?r`,(e,t)=>{let n=Dy(e,t);if(n instanceof j)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=Ey(t.calc.apply(i,[o,r.at(Math.floor(e/r.cols),e%r.cols)]),t);return o}),z(`SCAN`,`rr?r`,(e,t)=>{let n=Dy(e,t);if(n instanceof j)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=Ey(t.calc.apply(i,[c,r.at(Math.floor(e/r.cols),e%r.cols)]),t),s[e]=c;return new N(r.rows,r.cols,s)});let Oy=e=>(t,n)=>{let r=B(t[0],n);if(r instanceof j)return r;let i=t[1];if(!(i instanceof sr))return M.VALUE;let a=my(r),o=(e?a:gy(a)).map(t=>Ey(n.calc.apply(i,[e?new N(1,t.length,t):new N(t.length,1,t)]),n));return e?new N(o.length,1,o):new N(1,o.length,o)};z(`BYROW`,`rr`,Oy(!0)),z(`BYCOL`,`rr`,Oy(!1)),z(`MAKEARRAY`,`rrr`,(e,t)=>{let n=Ty(vy(e[0],t,1),vy(e[1],t,1));if(n instanceof j)return n;let r=e[2];if(!(r instanceof sr))return M.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]=Ey(t.calc.apply(r,[e+1,a+1]),t);return new N(n.rows,n.cols,i)});function ky(e){return(t,n)=>{let r=[];for(let i of t){let t=B(i,n);if(t instanceof j)return t;let a=my(t);r.push(e?a:gy(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:M.NA)));return a.length===0?M.CALC:hy(e?a:gy(a))}}z(`VSTACK`,`(r)`,ky(!0)),z(`HSTACK`,`(r)`,ky(!1));function Ay(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 jy(e){return(t,n)=>{let r=B(t[0],n);if(r instanceof j)return r;let i=e=>e===void 0||e instanceof F,a=vy(t[1],n,e?r.rows:0);if(a instanceof j)return a;let o=vy(t[2],n,e?r.cols:0);if(o instanceof j)return o;if(e&&!i(t[1])&&Math.trunc(a)===0||e&&!i(t[2])&&Math.trunc(o)===0)return M.CALC;let[s,c]=Ay(r.rows,Math.trunc(a),e),[l,u]=Ay(r.cols,Math.trunc(o),e);return c<=s||u<=l?M.CALC:hy(my(r).slice(s,c).map(e=>e.slice(l,u)))}}z(`TAKE`,`rr?r`,jy(!0)),z(`DROP`,`rr?r`,jy(!1));function My(e){return(t,n)=>{let r=B(t[0],n);if(r instanceof j)return r;let i=vy(t[1],n,0);if(i instanceof j)return i;let a=yy(t[2],n,!1);if(a instanceof j)return a;if(![0,1,2,3].includes(i))return M.VALUE;let o=my(r),s=(a?gy(o):o).flat().filter(e=>!((i===1||i===3)&&e===null||(i===2||i===3)&&e instanceof j));return s.length===0?M.CALC:e?new N(s.length,1,s):new N(1,s.length,s)}}z(`TOCOL`,`r?rr`,My(!0)),z(`TOROW`,`r?rr`,My(!1));function Ny(e){return(t,n)=>{let r=B(t[0],n);if(r instanceof j)return r;let i=my(r),a=e?i:gy(i),o=[];for(let e of t.slice(1)){let t=by(e,n,1);if(t instanceof j)return t;for(let e of t){let t=a[e>0?e-1:a.length+e];if(e===0||!t)return M.VALUE;o.push(t)}}return hy(e?o:gy(o))}}z(`CHOOSEROWS`,`r(r)`,Ny(!0)),z(`CHOOSECOLS`,`r(r)`,Ny(!1)),z(`EXPAND`,`rr?rr`,(e,t)=>{let n=B(e[0],t);if(n instanceof j)return n;let r=Ty(vy(e[1],t,n.rows),vy(e[2],t,n.cols));if(r instanceof j)return r;if(r.rows<n.rows||r.cols<n.cols)return M.VALUE;let i=_y(e[3],t)??M.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 N(r.rows,r.cols,a)});function Py(e){return(t,n)=>{let r=B(t[0],n);if(r instanceof j)return r;if(r.rows>1&&r.cols>1)return M.VALUE;let i=vy(t[1],n,1);if(i instanceof j)return i;let a=Math.trunc(i);if(a<1)return M.NUM;let o=_y(t[2],n)??M.NA,s=my(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 hy(e?c:gy(c))}}z(`WRAPROWS`,`rr?r`,Py(!0)),z(`WRAPCOLS`,`rr?r`,Py(!1));function Fy(e,t,n){let r=L(e);if(r instanceof j)return r;let i=t==null?0:I(t);if(i instanceof j)return i;if(i!==0&&i!==1)return M.VALUE;try{return new RegExp(r,`${i===1?`i`:``}${n?`g`:``}`)}catch{return M.VALUE}}R(`REGEXTEST`,2,3,(e,t,n)=>{let r=L(e);if(r instanceof j)return r;let i=Fy(t,n,!1);return i instanceof j?i:i.test(r)}),z(`REGEXEXTRACT`,`vv?vv`,(e,t)=>{let n=L(e[0]instanceof F?null:e[0]);if(n instanceof j)return n;let r=vy(e[2],t,0);if(r instanceof j)return r;let i=e[3]instanceof F?void 0:e[3],a=Fy(e[1],i,r===1);if(a instanceof j)return a;if(r===0)return a.exec(n)?.[0]??M.NA;if(r===1){let e=[...n.matchAll(a)].map(e=>e[0]);return e.length===0?M.NA:new N(e.length,1,e)}if(r===2){let e=a.exec(n);if(!e)return M.NA;let t=e.slice(1).map(e=>e??``);return t.length===0?M.NA:new N(1,t.length,t)}return M.VALUE}),R(`REGEXREPLACE`,3,5,(e,t,n,r,i)=>{let a=L(e),o=L(n);if(a instanceof j)return a;if(o instanceof j)return o;let s=r==null?0:I(r);if(s instanceof j)return s;let c=Fy(t,i,!0);if(c instanceof j)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)}),z(`PERCENTOF`,`rr`,(e,t)=>{let n=_o.get(`SUM`);if(!n)return M.NAME;let r=I(Ey(t.calc.applyFunction(n,[e[0]],t.frame),t)),i=I(Ey(t.calc.applyFunction(n,[e[1]],t.frame),t));return r instanceof j?r:i instanceof j?i:i===0?M.DIV0:r/i}),z(`TRIMRANGE`,`r?vv`,(e,t)=>{let n=e[0];if(!(n instanceof P))return n instanceof j?n:M.VALUE;let r=vy(e[1],t,3),i=vy(e[2],t,3);if(r instanceof j)return r;if(i instanceof j)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?M.REF:new P(n.sheet,n.top+c,n.left+u,n.top+l,n.left+d)});function Iy(e,t,n){let r=/* @__PURE__ */ new Map;for(let i of n){let n=e[i]?.[t]??null,a=wy(n),o=r.get(a);o?o.records.push(i):r.set(a,{key:n,records:[i],children:[]})}return[...r.values()]}function Ly(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?Sy(e.key,n.key,r.down):0:Sy(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=/* @__PURE__ */ new Map;for(let i of n){let n=(e[i]??[]).slice(0,t).map(wy).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?Sy(e[t.records[0]??0]?.[r.field]??null,e[n.records[0]??0]?.[r.field]??null,r.down):Sy(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(Iy(e,i+1,u.records),i+1,n),d&&!c&&s.push(o)}};r(Iy(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 Ry(e,t,n,r){let i=e=>new N(e.length,1,[...e]),a=e.named===void 0?void 0:_o.get(e.named),o=(a?a.min>=2:e.params.length>=2)?[i(t),i(n)]:[i(t)];return Ey(r.calc.apply(e,o),r)}function zy(e,t,n){if(e===void 0||e instanceof F){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=vy(e,n,0);return r instanceof j?r:[0,1,2,3].includes(r)?{has:r===1||r===3,show:r===2||r===3,named:r===2}:M.VALUE}function By(e,t,n,r){let i=Array.from({length:t},(e,t)=>t);if(e===void 0||e instanceof F)return i;let a=B(e,r);if(a instanceof j)return a;if(a.rows*a.cols!==t+n)return M.VALUE;let o=[];for(let e of i){let t=e+n,r=Cy(a.cols===1?a.at(t,0):a.at(0,t));if(r instanceof j)return r;r&&o.push(e)}return o}function Vy(e,t,n,r){let i=e===void 0||e instanceof F?[]:by(e,r,1);if(i instanceof j)return i;let a=[];for(let e of i){let r=Math.abs(e)-1,i=e<0;if(r<0)return M.VALUE;if(r<t)a.push({field:r,down:i});else{let e=n(r-t);if(!e)return M.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}let Hy=(e,t,n)=>vy(e,t,n);z(`GROUPBY`,`rrr?vvrrv`,(e,t)=>{let n=B(e[0],t),r=B(e[1],t),i=e[2];if(n instanceof j)return n;if(r instanceof j)return r;if(!(i instanceof sr)||n.rows!==r.rows)return M.VALUE;let a=n.cols===0?[]:my(n),o=my(r),s=zy(e[3],o,t);if(s instanceof j)return s;let c=+!!s.has,l=a.slice(c),u=o.slice(c),d=Hy(e[4],t,1);if(d instanceof j)return d;let f=vy(e[7],t,0);if(f instanceof j)return f;let p=By(e[6],l.length,c,t);if(p instanceof j)return p;if(p.length===0)return M.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),y=(e,n)=>Ry(i,n.map(t=>_[e]?.[t]??null),v(e),t),b=Vy(e[5],m,e=>e<h?t=>y(e,t):void 0,t);if(b instanceof j)return b;let x=Ly(l,m,p,d,b,f===1),S=[];s.show&&S.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 x)S.push([...e.keys,...Array.from({length:h},(t,n)=>y(n,e.records))]);return hy(S)}),z(`PIVOTBY`,`rrrr?vvrvrrv`,(e,t)=>{let n=B(e[0],t),r=B(e[1],t),i=B(e[2],t),a=e[3];if(n instanceof j)return n;if(r instanceof j)return r;if(i instanceof j)return i;if(!(a instanceof sr)||n.rows!==i.rows||r.rows!==i.rows)return M.VALUE;let o=my(n),s=my(r),c=my(i),l=zy(e[4],c,t);if(l instanceof j)return l;let u=+!!l.has,d=o.slice(u),f=s.slice(u),p=c.slice(u),m=Hy(e[5],t,1),h=Hy(e[7],t,1),g=vy(e[10],t,0);if(m instanceof j)return m;if(h instanceof j)return h;if(g instanceof j)return g;let _=By(e[9],p.length,u,t);if(_ instanceof j)return _;if(_.length===0)return M.CALC;let v=i.cols,y=Vy(e[6],n.cols,()=>void 0,t),b=Vy(e[8],r.cols,()=>void 0,t);if(y instanceof j)return y;if(b instanceof j)return b;let x=Ly(d,n.cols,_,m,y,!1),S=Ly(f,r.cols,_,h,b,!1),ee=(e,t)=>{let n=new Set(t);return e.filter(e=>n.has(e))},C=(e,t)=>p[t]?.[e]??null,te=(e,n,r)=>{let i=ee(n.records,r.records);if(i.length===0)return null;let o=g===1?n.records:g===2?_:r.records;return Ry(a,i.map(t=>C(e,t)),o.map(t=>C(e,t)),t)},ne=n.cols,w=[];for(let e=0;e<r.cols;e++)w.push([...Array(ne).fill(null),...S.flatMap(t=>Array.from({length:v},(n,r)=>r===0?t.keys[e]??null:null))]);(v>1||l.show)&&w.push([...Array.from({length:ne},(e,t)=>l.show?o[0]?.[t]??null:null),...S.flatMap(()=>Array.from({length:v},(e,t)=>l.has?c[0]?.[t]??null:`Value ${String(t+1)}`))]);for(let e of x)w.push([...e.keys,...S.flatMap(t=>Array.from({length:v},(n,r)=>te(r,e,t)))]);return hy(w)});let Uy=(e,t)=>Gn(Wn(e,t+1,0)).day,Wy=(e,t,n)=>n===0||n===4?Math.round(sc(e,t,n)*360):t-e;function Gy(e,t,n){let r=Gn(e),i=r.year*12+r.month-1+t,a=Math.floor(i/12),o=i-a*12+1,s=Uy(a,o);return Wn(a,o,n?s:Math.min(r.day,s))}let Ky=e=>{let t=Gn(e);return t.day===Uy(t.year,t.month)};function qy(e,t,n,r){let i=12/n,a=Ky(t),o=0,s=t;for(;s>e;)o+=1,s=Gy(t,-i*o,a);let c=Gy(t,-i*(o-1),a),l=r===1?c-s:r===3?365/n:360/n,u=Wy(s,e,r);return{previous:s,next:c,count:o,period:l,since:u,until:r===0||r===4?l-u:c-e}}function Jy(e,t){let n=[];for(let[r,i]of t.entries()){let t=e[r],a=t==null?i??0:I(t);if(a instanceof j)return a;n.push(a)}return n}let Yy=e=>Number.isInteger(e)&&e>=0&&e<=4,Xy=e=>e===1||e===2||e===4;function Zy(e,t,n,r){R(e,t,n.length,(...e)=>{let t=Jy(e,n);if(t instanceof j)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||!Yy(l)?M.NUM:r(s,c,...o.slice(0,-1),l)})}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]])Zy(e,3,[void 0,void 0,void 0,0],(e,n,r=0,i=0)=>Xy(r)?t(qy(e,n,r,i)):M.NUM);function Qy(e,t,n,r,i,a,o){let s=qy(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}Zy(`PRICE`,6,[void 0,void 0,void 0,void 0,void 0,void 0,0],(e,t,n=0,r=0,i=0,a=0,o=0)=>n<0||r<0||i<=0||!Xy(a)?M.NUM:Qy(e,t,n,r,i,a,o)),Zy(`YIELD`,6,[void 0,void 0,void 0,void 0,void 0,void 0,0],(e,t,n=0,r=0,i=0,a=0,o=0)=>{if(n<0||r<=0||i<=0||!Xy(a))return M.NUM;let s=-.99,c=1;for(;Qy(e,t,n,c,i,a,o)>r&&c<1e6;)c*=2;for(let l=0;l<200;l++){let l=(s+c)/2;Qy(e,t,n,l,i,a,o)>r?s=l:c=l}return(s+c)/2});function $y(e,t,n,r,i,a){let o=qy(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}Zy(`DURATION`,5,[void 0,void 0,void 0,void 0,void 0,0],(e,t,n=0,r=0,i=0,a=0)=>n<0||r<0||!Xy(i)?M.NUM:$y(e,t,n,r,i,a)),Zy(`MDURATION`,5,[void 0,void 0,void 0,void 0,void 0,0],(e,t,n=0,r=0,i=0,a=0)=>n<0||r<0||!Xy(i)?M.NUM:$y(e,t,n,r,i,a)/(1+r/i)),Zy(`DISC`,4,[void 0,void 0,void 0,void 0,0],(e,t,n=0,r=0,i=0)=>n<=0||r<=0?M.NUM:(r-n)/r/sc(e,t,i)),Zy(`INTRATE`,4,[void 0,void 0,void 0,void 0,0],(e,t,n=0,r=0,i=0)=>n<=0||r<=0?M.NUM:(r-n)/n/sc(e,t,i)),Zy(`RECEIVED`,4,[void 0,void 0,void 0,void 0,0],(e,t,n=0,r=0,i=0)=>{let a=1-r*sc(e,t,i);return n<=0||r<=0||a<=0?M.NUM:n/a}),Zy(`PRICEDISC`,4,[void 0,void 0,void 0,void 0,0],(e,t,n=0,r=0,i=0)=>n<=0||r<=0?M.NUM:r*(1-n*sc(e,t,i))),Zy(`YIELDDISC`,4,[void 0,void 0,void 0,void 0,0],(e,t,n=0,r=0,i=0)=>n<=0||r<=0?M.NUM:(r-n)/n/sc(e,t,i));function eb(e,t){R(e,3,3,Do((e=0,n=0,r=0)=>{let i=Math.trunc(e),a=Math.trunc(n);return i>=a||r<=0||a>Gy(i,12,!1)?M.NUM:t(a-i,r)}))}eb(`TBILLPRICE`,(e,t)=>{let n=100*(1-t*e/360);return n<=0?M.NUM:n}),eb(`TBILLYIELD`,(e,t)=>(100-t)/t*360/e),eb(`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)}),R(`ACCRINTM`,3,5,(...e)=>{let t=Jy(e,[void 0,void 0,void 0,1e3,0]);if(t instanceof j)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||!Yy(o)?M.NUM:a*i*sc(s,c,o)}),R(`ACCRINT`,6,8,(...e)=>{let t=Jy(e.slice(0,7),[void 0,void 0,void 0,void 0,1e3,void 0,0]);if(t instanceof j)return t;let[n=0,r=0,i=0,a=0,o=0,s=0,c=0]=t,l=e[7]===void 0||io(e[7]);if(l instanceof j)return l;let u=Math.trunc(n),d=Math.trunc(i),f=Math.trunc(r);if(u>=d||a<=0||o<=0||!Xy(s)||!Yy(c))return M.NUM;let p=12/s,m=f,h=f;for(let e=1;m>u;e++)m=Gy(f,-p*e,!1);let g=0;for(;m<d;){h=Gy(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+=Wy(e,t,c)/n),m=h}return o*a*g/s});let tb=(e,t)=>(1+e)**t,nb=e=>e===0?0:1,rb=e=>Number.isFinite(e)?e:M.NUM;function ib(e,t,n,r,i){if(e===0)return-(n+r)/t;let a=tb(e,t);return-(n*a+r)*e/((1+e*i)*(a-1))}function ab(e,t,n,r,i){if(e===0)return-(r+n*t);let a=tb(e,t);return-(r*a+n*(1+e*i)*(a-1)/e)}function ob(e,t,n,r,i,a){if(t<1||t>n)return M.NUM;if(a===1&&t===1)return 0;let o=ib(e,n,r,i,a),s=a===1?ab(e,t-2,o,r,1)-o:ab(e,t-1,o,r,0);return rb(s*e)}R(`PMT`,3,5,Do((e,t,n,r=0,i=0)=>t===0?M.NUM:rb(ib(e,t,n,r,nb(i))))),R(`FV`,3,5,Do((e,t,n,r=0,i=0)=>rb(ab(e,t,n,r,nb(i))))),R(`IPMT`,4,6,Do((e,t,n,r,i=0,a=0)=>ob(e,t,n,r,i,nb(a)))),R(`PPMT`,4,6,Do((e,t,n,r,i=0,a=0)=>{let o=nb(a),s=ob(e,t,n,r,i,o);return s instanceof j?s:rb(ib(e,n,r,i,o)-s)})),R(`DB`,4,5,Do((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 M.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 rb(c)})),R(`VDB`,5,7,(...e)=>{let t=Jy(e.slice(0,6),[void 0,void 0,void 0,void 0,void 0,2]);if(t instanceof j)return t;let[n=0,r=0,i=0,a=0,o=0,s=0]=t,c=e[6]!==void 0&&io(e[6]);if(c instanceof j)return c;if(n<0||r<0||i<=0||a<0||o>i||a>o||s<=0)return M.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});let sb=(e,t,n,r,i)=>({whole:sc(n,t,i),accrued:sc(n,e,i),left:sc(e,t,i),rate:r});Zy(`PRICEMAT`,5,[void 0,void 0,void 0,void 0,void 0,0],(e,t,n=0,r=0,i=0,a=0)=>{let o=Math.trunc(n);if(o>=e||r<0||i<0)return M.NUM;let{whole:s,accrued:c,left:l}=sb(e,t,o,r,a);return(100+s*r*100)/(1+l*i)-c*r*100}),Zy(`YIELDMAT`,5,[void 0,void 0,void 0,void 0,void 0,0],(e,t,n=0,r=0,i=0,a=0)=>{let o=Math.trunc(n);if(o>=e||r<0||i<=0)return M.NUM;let{whole:s,accrued:c,left:l}=sb(e,t,o,r,a);return((1+s*r)/(i/100+c*r)-1)/l});function cb(e,t,n,r,i){let a=12/r,o=Ky(t),s={held:0,accrued:0,left:0,count:0},c=0,l=t;for(;l>e;){c+=1;let u=Gy(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?Wy(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 lb(e,t,n,r,i,a,o,s,c){let l=100*i/s,u=qy(r,t,s,c).count+1,d=cb(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 ub(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 db(e,t){R(e,8,9,(...e)=>{let n=Jy(e,[void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,0]);if(n instanceof j)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!Yy(d)||!Xy(u)||!(p>h&&h>f&&f>m)||s<0||c<0||l<=0?M.NUM:t(e=>lb(f,p,m,h,s,e,l,u,d),c)})}db(`ODDFPRICE`,(e,t)=>e(t)),db(`ODDFYIELD`,(e,t)=>ub(e,t,.1)??M.NUM);function fb(e,t){R(e,7,8,(...e)=>{let n=Jy(e,[void 0,void 0,void 0,void 0,void 0,void 0,void 0,0]);if(n instanceof j)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!Yy(u)||!Xy(l)||!(f>d&&d>p)||o<0||s<0||c<=0?M.NUM:t({odd:cb(p,f,d,l,u),coupon:100*o/l,last:s,red:c,f:l})})}fb(`ODDLPRICE`,({odd:e,coupon:t,last:n,red:r,f:i})=>(r+e.held*t)/(1+e.left*n/i)-e.accrued*t),fb(`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}),R(`AMORLINC`,6,7,(...e)=>{let t=Jy(e,[void 0,void 0,void 0,void 0,void 0,void 0,0]);if(t instanceof j)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(!Yy(c)||c===2||n<0||a<0||a>n||l<0||s<=0||r>i)return M.NUM;let u=n*s,d=sc(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}),R(`AMORDEGRC`,6,7,(...e)=>{let t=Jy(e,[void 0,void 0,void 0,void 0,void 0,void 0,0]);if(t instanceof j)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(!Yy(c)||c===2||n<0||a<0||a>n||l<0||s<=0||r>i)return M.NUM;let u=1/s,d=s*(u<3?1:u<5?1.5:u<=6?2:2.5),f=Math.round(sc(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 pb(e,t){let n=[];for(let t=0;t<e.cols;t++){let r=L(e.at(0,t));if(r instanceof j)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=L(t.at(0,a));if(c instanceof j)return c;let l=n.indexOf(c.toLowerCase());if(l<0){o=!1;continue}let u=Lo(s);if(u instanceof j)return u;u.test(e.at(i,l))||(o=!1)}o&&(a=!0)}a&&r.push(i)}return r}function mb(e,t){if(typeof t==`number`){let n=Math.trunc(t)-1;return n<0||n>=e.cols?M.VALUE:n}let n=L(t);if(n instanceof j)return n;for(let t=0;t<e.cols;t++){let r=e.at(0,t);if(typeof r==`string`&&so(r,n)===0)return t}return M.VALUE}function hb(e,t){let n=B(e[0],t);if(n instanceof j)return n;let r=B(e[2],t);if(r instanceof j)return r;let i=pb(n,r);if(i instanceof j)return i;let a=e[1];if(a===void 0)return{list:i.map(()=>null),db:n};let o=mb(n,t.calc.scalar(a,t.frame));return o instanceof j?o:{list:i.map(e=>n.at(e,o)),db:n}}function gb(e,t){z(e,`rvr`,(e,n)=>{let r=hb(e,n);if(r instanceof j)return r;let i=_o.get(t);if(i?.kind!==`raw`)return M.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`]])gb(e,t);for(let[e,t]of[[`DAVERAGE`,`AVERAGE`],[`DSTDEV`,`STDEV.S`],[`DSTDEVP`,`STDEV.P`],[`DVAR`,`VAR.S`],[`DVARP`,`VAR.P`]])z(e,`rvr`,(e,n)=>{let r=hb(e,n);if(r instanceof j)return r;let i=_o.get(t);if(i?.kind!==`raw`)return M.VALUE;let a=r.list.filter(e=>typeof e==`number`);return a.length===0?M.DIV0:i.call(a,n)});z(`DCOUNT`,`rv?r`,(e,t)=>{let n=hb(e.length===2?[e[0],void 0,e[1]]:e,t);return n instanceof j?n:n.list.filter(e=>typeof e==`number`).length}),z(`DCOUNTA`,`rv?r`,(e,t)=>{let n=hb(e.length===2?[e[0],void 0,e[1]]:e,t);return n instanceof j?n:n.list.filter(e=>e!==null).length}),z(`DGET`,`rvr`,(e,t)=>{let n=hb(e,t);return n instanceof j?n:n.list.length===0?M.VALUE:n.list.length>1?M.NUM:n.list[0]??null});function _b(e,t,n){let r={reads:[],names:/* @__PURE__ */ new Set,volatile:!1,unknownNames:[],unknownFunctions:[],arguments:[]},i=/* @__PURE__ */ 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,/* @__PURE__ */ new Set)}return!0}if(_o.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=_o.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`&&!bo(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,/* @__PURE__ */ new Set),r}var vb=class{cells=/* @__PURE__ */ 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&&y(this.reference,t))for(let e of this.cells)n(e)}},yb=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=bb(r.group.top,r.group.bottom,r.t,r.kt,r.b,r.kb,t.top,t.bottom);if(!i)return;let a=bb(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 ka&&i.shared===r.shared&&n(i)}}};function bb(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 xb=class{single=/* @__PURE__ */ new Map;ranges=/* @__PURE__ */ new Map;byColumn=/* @__PURE__ */ new Map;wide=[];source;constructor(e){this.source=e}build(e){let t=/* @__PURE__ */ 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=/* @__PURE__ */ new Map,this.single.set(t.sheet,n));let r=Ma(t.top,t.left),i=n.get(r);i||(i=/* @__PURE__ */ new Set,n.set(r,i)),i.add(e)}else{let n=this.ranges.get(t.key);n||(n=new vb(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(Ma(t.top,t.left))?.delete(e):this.ranges.get(t.key)?.cells.delete(e)}readersIn(e,t){let n=/* @__PURE__ */ 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(Ma(e,r))??[])n.add(t);let a=/* @__PURE__ */ 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>32){this.wide.push(e);return}let r=this.byColumn.get(t);r||(r=/* @__PURE__ */ 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,y=h?p(d.right,i.right):0;if(g===void 0||_===void 0||v===void 0||y===void 0)return!1;let b=i.top-g*r.top,x=i.bottom-_*r.top,S=i.left-v*r.left,ee=i.right-y*r.left;if(f.top!==b+g*r.bottom||f.bottom!==x+_*r.bottom||f.left!==S+v*r.right||f.right!==ee+y*r.right)return!1;l.push(new yb({shared:e,on:n,group:r,reads:i.sheet,t:b,kt:g,b:x,kb:_,l:S,kl:v,r:ee,kr:y}))}for(let e of l)this.list(e);return!0}};function Sb(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}}let Cb=/* @__PURE__ */ new Set,wb=/\b(?:SUBTOTAL|AGGREGATE)\(/iu,Tb=2e3;var Eb=class extends Error{cell;constructor(e){super(`computed first`),this.cell=e}};let Db={max_iterations:100,max_change:.001};function Ob(e,t){return typeof e==`number`&&typeof t==`number`?Math.abs(t-e):e===t||e instanceof j&&t instanceof j&&e.code===t.code?0:1/0}let kb=(e,t)=>!e||!t?e===t:e.rows!==t.rows||e.cols!==t.cols?!1:e.data.every((e,n)=>e===t.data[n]),Ab=(e,t)=>e.row<t.row||e.row===t.row&&e.col<t.col;var jb=class{cycles=[];computed=0;iterated;nowSerial;random;pass=0;lambdaSlots=0;stack=[];inCycle=/* @__PURE__ */ new Set;waiting=/* @__PURE__ */ new Set;work=[];unwound=/* @__PURE__ */ new Map;counted=/* @__PURE__ */ new Set;looping=/* @__PURE__ */ new Set;tablesOf;inTables=!1;loop=/* @__PURE__ */ new Set;around=/* @__PURE__ */ new Set;namesAt=/* @__PURE__ */ new Set;graph=new xb({readsOf:e=>this.readsOf(e),readsAt:(e,t,n,r)=>this.readsAt(e,t,n,r)});graphMade=!1;reports;replica;settled=/* @__PURE__ */ new Set;moved=[];unsettled=/* @__PURE__ */ new Set;hiddenBy=/* @__PURE__ */ new Map;volatiles=/* @__PURE__ */ new Set;indexes=new ho;results=new ho;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=()=>qn(n??/* @__PURE__ */ 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)??Cb}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=/* @__PURE__ */ 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)??Db.max_iterations,max_change:(e===!0?void 0:e.max_change)??Db.max_change}}applyFilters(e){for(let e of this.wb.sheets){if(e.filters.every(e=>e.columns.size===0))continue;let t=cs(e,this);t.size>0&&this.hiddenBy.set(e,t)}if(this.hiddenBy.size!==0&&e.some(e=>wb.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 j?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=/* @__PURE__ */ new Map;for(let t of this.allCells())if(Pb(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=/* @__PURE__ */ 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=/* @__PURE__ */ new Map,n=(e,t)=>{let n=e===void 0?void 0:this.eval(e,t);return n instanceof P&&n.single?n:void 0},r=e.map(e=>{let r=e.shared.node;if(r?.kind!==`call`)return M.REF;let i=Fb(e),a=n(r.args[0],i);if(!a)return M.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 M.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 P&&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(M.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,Ob(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>=12)for(let{sheet:e,area:n}of t)for(let t of e.spillsIn(n))this.unsettled.add(t);this.build();let n=/* @__PURE__ */ new Set,r=[...this.unsettled];for(let{sheet:e,area:n}of t)lr(r,this.readersIn(e,n)),lr(r,e.blockedBy(n));for(;;){let e=r.pop();if(!e)break;n.has(e)||(n.add(e),lr(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=>y(e.area,a))||n.merges.some(e=>y(e,a))||o.some(t=>Ab(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=M.SPILL,this.moved.push({sheet:n,area:r}),this.reports&&this.settled.add(e))}analysisOf(e){return e.analysis??=_b(this.wb,e)}readsOf(e){let t=[],n=Fb(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 P?t.push(e):e instanceof or&&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 P?a.push(e):e instanceof or?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 P?n.push(e):e instanceof or&&n.push(...e.parts)}return n}order(e){this.pass+=1;let{pass:t}=this,n=[],r=/* @__PURE__ */ 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 ka&&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 ka&&n.push(i)}}}return n}computeNow(e){if(this.stack.length>0){if(this.stack.length>=50&&this.stack.length<Tb)throw new Eb(e);this.compute(e);return}let t=[e],n=/* @__PURE__ */ 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 Eb))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=M.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>=Tb){e.value=M.CALC,e.state=0;return}e.state=2,this.stack.push(e),this.computed+=1;let{node:t}=e.shared,n=Pb(t)?e.value:t?this.top(this.eval(t,Fb(e))):M.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 N){let n=Nb(t);n.rows*n.cols<=1||this.spillOut(e,n)?(e.array=n,e.value=n.at(0,0)??0):e.value=M.SPILL}else e.value=t;this.inCycle.has(e)&&(n.clearSpill(e),e.value=M.CYCLE,e.array=void 0);let a=e.spill;kb(i,e.array)&&Mb(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 P?e.single?this.read(e.sheet,e.top,e.left):this.matrix(e):e instanceof or?M.VALUE:e instanceof sr?M.CALC:e instanceof F?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 N(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 j)?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})):M.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})):M.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 M.REF;let r=0,i=16383,a=0,o=1048575;if(e.col){let n=this.bound(e.col,t.dc,d),a=this.bound(e.col2??e.col,t.dc,d);if(n===void 0||a===void 0)return M.REF;r=Math.min(n,a),i=Math.max(n,a)}if(e.row){let n=this.bound(e.row,t.dr,u),r=this.bound(e.row2??e.row,t.dr,u);if(n===void 0||r===void 0)return M.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 M.REF;let[s,c]=[Math.min(n.index,t.index),Math.max(n.index,t.index)];return new or(this.wb.sheets.slice(s,c+1).map(e=>new P(e,a,r,o,i)))}return new P(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?Ib(n,e,t):e.table===void 0?M.REF:M.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 M.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 M.NAME;if(this.namesAt.has(r))return M.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 P(o.sheet,e,t,n,r)}let s=_o.get(e.toUpperCase());return s&&s.kind!==`lazy`?Lb(s,e,t):M.NAME}intersect(e,t){return!(e instanceof P)||e.single?e:e.cols===1&&t.row>=e.top&&t.row<=e.bottom?new P(e.sheet,t.row,e.left,t.row,e.left):e.rows===1&&t.col>=e.left&&t.col<=e.right?new P(e.sheet,e.top,t.col,e.top,t.col):M.VALUE}unary(e,t){let n=this.flat(e);return n instanceof N?new N(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 N||i instanceof N?po(r instanceof N?r:new N(1,1,[r]),i instanceof N?i:new N(1,1,[i]),(t,n)=>fo(e,t,n)):fo(e,r,i)}rangeOf(e,t){return e instanceof j?e:t instanceof j?t:!(e instanceof P)||!(t instanceof P)||e.sheet!==t.sheet?M.REF:new P(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 j)return e;if(t instanceof j)return t;if(!(e instanceof P)||!(t instanceof P))return M.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?M.NULL:new P(e.sheet,n,r,i,a)}union(e,t){if(e instanceof j)return e;if(t instanceof j)return t;let n=e=>e instanceof P?[e]:e instanceof or?e.parts:[],r=[...n(e),...n(t)];return r.length===0?M.VALUE:new or(r)}eval(e,t){switch(e.kind){case`number`:case`string`:case`boolean`:return e.value;case`error`:return j.of(e.code);case`missing`:return cr;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=>fo(`*`,e,-1))}case`postfix`:{let n=this.eval(e.arg,t);if(e.op===`%`)return this.unary(n,e=>fo(`/`,e,100));if(n instanceof P&&n.single){let e=n.sheet.at(n.top,n.left);if(e instanceof ka){this.read(n.sheet,n.top,n.left);let{spill:t}=e;if(t)return new P(n.sheet,t.top,t.left,t.bottom,t.right);if(e.array)return n}}return M.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 N(e.rows.length,e.rows[0]?.length??0,e.rows.flatMap(e=>e.map(e=>{let n=this.eval(e,t);return n instanceof N||n instanceof P||n instanceof or||n instanceof sr||n instanceof F?M.VALUE:n})));case`invoke`:{let n=this.eval(e.callee,t);return n instanceof sr?this.invoke(n,e.args,t):n instanceof j?n:M.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=_o.get(e.named);return!n||n.kind===`lazy`?M.NAME:t.length<n.min||t.length>n.max?M.VALUE:this.applyFunction(n,t,e.frame)}if(t.length>e.params.length)return M.VALUE;let n=e.params.length+1;if(this.lambdaSlots+n>1024)return M.NUM;let r=/* @__PURE__ */ new Map;e.params.forEach((e,n)=>{r.set(e,t[n]??cr)}),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 M.NUM}finally{this.lambdaSlots-=n}}call(e,t,n){let r=_o.get(e);if(!r){let r=this.nameValue(e,n);return r instanceof sr?this.invoke(r,t,n):M.NAME}return t.length<r.min||t.length>r.max?M.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 M.VALUE;if(e.kind===`raw`)return bo(e.params,t.length)?this.over(t,t=>yo(e.params,t)===`value`,t=>e.call(t,r)):M.VALUE;let i=e.errors===!0;return this.over(t,()=>!0,t=>{let n=t.map(e=>e instanceof F?void 0:e);if(!i){for(let e of n)if(e instanceof j)return e}return e.call(...n)})}over(e,t,n){let r=[],i=/* @__PURE__ */ new Map;for(let[n,a]of e.entries()){if(!t(n)||a instanceof F){r.push(a);continue}let e=this.flat(a);e instanceof N&&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 M.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):M.NA});c[e*s+t]=this.element(n(a))}return new N(o,s,c)}element(e){let t=this.flat(e);return t instanceof N?t.rows>0&&t.cols>0?t.at(0,0):M.CALC:t}scalar(e,t){if(e instanceof F)return null;if(e instanceof P){let n=this.intersect(e,t);return n instanceof P?this.read(n.sheet,n.top,n.left):M.VALUE}return e instanceof N?e.at(0,0):e instanceof or||e instanceof sr?M.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 ka(new Oa(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 ka&&t.clearSpill(e),t.replace(n,r,i),i instanceof ka&&(i.state=0)}return}this.build();let t=/* @__PURE__ */ new Set,n=[...this.unsettled];this.unsettled.clear();let r=/* @__PURE__ */ new Set;for(let{sheet:i,row:a,col:o,slot:s}of e){let e=i.at(a,o);(e instanceof ka&&Pb(e.shared.node)||s instanceof ka&&Pb(s.shared.node))&&(this.tablesOf=void 0),e instanceof ka&&(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 ka&&(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)lr(n,this.readers(t,r,i));for(lr(n,this.volatiles);;){let e=n.pop();if(!e)break;t.has(e)||this.inTables&&Pb(e.shared.node)||(t.add(e),lr(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:Ja(t.value),...t.array?{array:Xa(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 ka&&(e.clearSpill(n),n.value=Ya(t.value),n.array=t.array?Za(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 ka?[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 I(e)}};let Mb=(e,t)=>e?.top===t?.top&&e?.left===t?.left&&e?.bottom===t?.bottom&&e?.right===t?.right;function Nb(e){return e.data.some(e=>e===null)?new N(e.rows,e.cols,e.data.map(e=>e??0)):e}function Pb(e){return e?.kind===`call`&&e.name===`TABLE`}function Fb(e){return{sheet:e.sheet,row:e.row,col:e.col,dr:e.row-e.shared.row,dc:e.col-e.shared.col}}function Ib(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 M.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?M.VALUE:new P(r,n.row,a,n.row,o);let l=t.sections;if(l.includes(`#Totals`))return M.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 P(r,f,a,p,o)}function Lb(e,t,n){return new sr([],{kind:`call`,name:e.name,written:t,args:[]},n,e.name)}function Rb(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=Ma(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 ka(s,n,r,a)});continue}let c=nr(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 ka(new Oa(c.formula,r,a,{file:``}),n,r,a)})}t.change(i)}function zb(e,t={}){let n=new Map(e.rows),r=qa({file:e.file,rows:e=>n.get(e),generated:e.generated});return e.scenario!==void 0&&eo(r,e.scenario),{workbook:r,calc:new jb(r,{random:Sb(e.seed),...t}).calculate()}}var Bb=class{model;generation=-1;handle(e){if(e.kind===`open`)this.model=zb(e,{report:!0}),this.generation=e.generation;else{if(e.generation!==this.generation||!this.model)return;e.kind===`cells`?Rb(this.model.workbook,this.model.calc,e.cells,e.file):this.model.calc.recalculate()}return{generation:this.generation,computed:this.model.calc.takeComputed()}}};let Vb=[[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`],[`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`,`Sunday`],[`周一`,`周二`,`周三`,`周四`,`周五`,`周六`,`周日`],[`星期一`,`星期二`,`星期三`,`星期四`,`星期五`,`星期六`,`星期日`]],Hb=[[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],[`一月`,`二月`,`三月`,`四月`,`五月`,`六月`,`七月`,`八月`,`九月`,`十月`,`十一月`,`十二月`]];[...Vb,...Hb],Object.fromEntries([`bold`,`italic`,`underline`,`strike`,`font`,`size`,`color`,`fill`,`align`,`valign`,`wrap`,`shrink`,`indent`,`rotation`,`border`,`locked`,`hide_formula`,`format`].map(e=>[e,void 0]));let Ub=new Bb;addEventListener(`message`,e=>{let t=Ub.handle(e.data);t&&postMessage(t)})})();
45
+ `;return`${e}\n${i}${p}`}return`${f}${o}${d.join(` `)}${o}${p}`}function Li({indent:e,options:{commentString:t}},n,r,i){if(r&&i&&(r=r.replace(/^\n+/,``)),r){let i=ii(t(r),e);n.push(i.trimStart())}}function Ri(e,t){let n=jr(t)?t.value:t;for(let r of e)if(Ar(r)&&(r.key===t||r.key===n||jr(r.key)&&r.key.value===n))return r}var zi=class extends ni{static get tagName(){return`tag:yaml.org,2002:map`}constructor(e){super(Sr,e),this.items=[]}static from(e,t,n){let{keepUndefined:r,replacer:i}=n,a=new this(e),o=(e,o)=>{if(typeof i==`function`)o=i.call(t,e,o);else if(Array.isArray(i)&&!i.includes(e))return;(o!==void 0||r)&&a.items.push(Mi(e,o,n))};if(t instanceof Map)for(let[e,n]of t)o(e,n);else if(t&&typeof t==`object`)for(let e of Object.keys(t))o(e,t[e]);return typeof e.sortMapEntries==`function`&&a.items.sort(e.sortMapEntries),a}add(e,t){let n;n=Ar(e)?e:!e||typeof e!=`object`||!(`key`in e)?new Ni(e,e?.value):new Ni(e.key,e.value);let r=Ri(this.items,n.key),i=this.schema?.sortMapEntries;if(r){if(!t)throw Error(`Key ${n.key} already set`);jr(r.value)&&Xr(n.value)?r.value.value=n.value:r.value=n.value}else if(i){let e=this.items.findIndex(e=>i(n,e)<0);e===-1?this.items.push(n):this.items.splice(e,0,n)}else this.items.push(n)}delete(e){let t=Ri(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){let n=Ri(this.items,e)?.value;return(!t&&jr(n)?n.value:n)??void 0}has(e){return!!Ri(this.items,e)}set(e,t){this.add(new Ni(e,t),!0)}toJSON(e,t,n){let r=n?new n:t?.mapAsMap?/* @__PURE__ */ new Map:{};t?.onCreate&&t.onCreate(r);for(let e of this.items)Ai(t,r,e);return r}toString(e,t,n){if(!e)return JSON.stringify(this);for(let e of this.items)if(!Ar(e))throw Error(`Map items must all be pairs; found ${JSON.stringify(e)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),Pi(this,e,{blockItemPrefix:``,flowChars:{start:`{`,end:`}`},itemIndent:e.indent||``,onChompKeep:n,onComment:t})}};let Bi={collection:`map`,default:!0,nodeClass:zi,tag:`tag:yaml.org,2002:map`,resolve(e,t){return kr(e)||t(`Expected a mapping for this tag`),e},createNode:(e,t,n)=>zi.from(e,t,n)};var Vi=class extends ni{static get tagName(){return`tag:yaml.org,2002:seq`}constructor(e){super(Tr,e),this.items=[]}add(e){this.items.push(e)}delete(e){let t=Hi(e);return typeof t==`number`&&this.items.splice(t,1).length>0}get(e,t){let n=Hi(e);if(typeof n!=`number`)return;let r=this.items[n];return!t&&jr(r)?r.value:r}has(e){let t=Hi(e);return typeof t==`number`&&t<this.items.length}set(e,t){let n=Hi(e);if(typeof n!=`number`)throw Error(`Expected a valid index, not ${e}.`);let r=this.items[n];jr(r)&&Xr(t)?r.value=t:this.items[n]=t}toJSON(e,t){let n=[];t?.onCreate&&t.onCreate(n);let r=0;for(let e of this.items)n.push(Kr(e,String(r++),t));return n}toString(e,t,n){return e?Pi(this,e,{blockItemPrefix:`- `,flowChars:{start:`[`,end:`]`},itemIndent:(e.indent||``)+` `,onChompKeep:n,onComment:t}):JSON.stringify(this)}static from(e,t,n){let{replacer:r}=n,i=new this(e);if(t&&Symbol.iterator in Object(t)){let e=0;for(let a of t){if(typeof r==`function`){let n=t instanceof Set?a:String(e++);a=r.call(t,n,a)}i.items.push($r(a,void 0,n))}}return i}};function Hi(e){let t=jr(e)?e.value:e;return t&&typeof t==`string`&&(t=Number(t)),typeof t==`number`&&Number.isInteger(t)&&t>=0?t:null}let Ui={collection:`seq`,default:!0,nodeClass:Vi,tag:`tag:yaml.org,2002:seq`,resolve(e,t){return Mr(e)||t(`Expected a sequence for this tag`),e},createNode:(e,t,n)=>Vi.from(e,t,n)};function Wi(e){return typeof e==`bigint`||Number.isInteger(e)}let Gi=({value:e})=>JSON.stringify(e),Ki=[{identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify:Gi},{identify:e=>e==null,createNode:()=>new Zr(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^null$/,resolve:()=>null,stringify:Gi},{identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^true$|^false$/,resolve:e=>e===`true`,stringify:Gi},{identify:Wi,default:!0,tag:`tag:yaml.org,2002:int`,test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:n})=>n?BigInt(e):parseInt(e,10),stringify:({value:e})=>Wi(e)?e.toString():JSON.stringify(e)},{identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:e=>parseFloat(e),stringify:Gi}];[Bi,Ui].concat(Ki,{default:!0,tag:``,test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}});function qi(e,t,n){let{replacer:r}=n,i=new Vi(e);i.tag=`tag:yaml.org,2002:pairs`;let a=0;if(t&&Symbol.iterator in Object(t))for(let e of t){typeof r==`function`&&(e=r.call(t,String(a++),e));let o,s;if(Array.isArray(e)){if(e.length===2)o=e[0],s=e[1];else throw TypeError(`Expected [key, value] tuple: ${e}`)}else if(e&&e instanceof Object){let t=Object.keys(e);if(t.length===1)o=t[0],s=e[o];else throw TypeError(`Expected tuple with one key, not ${t.length} keys`)}else o=e;i.items.push(Mi(o,s,n))}return i}var Ji=class e extends Vi{constructor(){super(),this.add=zi.prototype.add.bind(this),this.delete=zi.prototype.delete.bind(this),this.get=zi.prototype.get.bind(this),this.has=zi.prototype.has.bind(this),this.set=zi.prototype.set.bind(this),this.tag=e.tag}toJSON(e,t){if(!t)return super.toJSON(e);let n=/* @__PURE__ */ new Map;t?.onCreate&&t.onCreate(n);for(let e of this.items){let r,i;if(Ar(e)?(r=Kr(e.key,``,t),i=Kr(e.value,r,t)):r=Kr(e,``,t),n.has(r))throw Error(`Ordered maps must not include duplicate keys`);n.set(r,i)}return n}static from(e,t,n){let r=qi(e,t,n),i=new this;return i.items=r.items,i}};Ji.tag=`tag:yaml.org,2002:omap`;var Yi=class e extends zi{constructor(t){super(t),this.tag=e.tag}add(e){let t;t=Ar(e)?e:e&&typeof e==`object`&&`key`in e&&`value`in e&&e.value===null?new Ni(e.key,null):new Ni(e,null),Ri(this.items,t.key)||this.items.push(t)}get(e,t){let n=Ri(this.items,e);return!t&&Ar(n)?jr(n.key)?n.key.value:n.key:n}set(e,t){if(typeof t!=`boolean`)throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let n=Ri(this.items,e);n&&!t?this.items.splice(this.items.indexOf(n),1):!n&&t&&this.items.push(new Ni(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,n);throw Error(`Set items must all have null values`)}static from(e,t,n){let{replacer:r}=n,i=new this(e);if(t&&Symbol.iterator in Object(t))for(let e of t)typeof r==`function`&&(e=r.call(t,e,e)),i.items.push(Mi(e,null,n));return i}};Yi.tag=`tag:yaml.org,2002:set`;let Xi=Symbol(`break visit`),Zi=Symbol(`skip children`),Qi=Symbol(`remove item`);function $i(e,t){`type`in e&&e.type===`document`&&(e={start:e.start,value:e.value}),ea(Object.freeze([]),e,t)}$i.BREAK=Xi,$i.SKIP=Zi,$i.REMOVE=Qi,$i.itemAtPath=(e,t)=>{let n=e;for(let[e,r]of t){let t=n?.[e];if(t&&`items`in t)n=t.items[r];else return}return n},$i.parentCollection=(e,t)=>{let n=$i.itemAtPath(e,t.slice(0,-1)),r=t[t.length-1][0],i=n?.[r];if(i&&`items`in i)return i;throw Error(`Parent collection not found`)};function ea(e,t,n){let r=n(t,e);if(typeof r==`symbol`)return r;for(let i of[`key`,`value`]){let a=t[i];if(a&&`items`in a){for(let t=0;t<a.items.length;++t){let r=ea(Object.freeze(e.concat([[i,t]])),a.items[t],n);if(typeof r==`number`)t=r-1;else if(r===Xi)return Xi;else r===Qi&&(a.items.splice(t,1),--t)}typeof r==`function`&&i===`key`&&(r=r(t,e))}}return typeof r==`function`?r(t,e):r}let ta=`sheet.yaml`,na=`sheet.ts`,ra=e=>e.toLowerCase();function ia(e,t){let n=e.sheets.length;if(!t)return{file:e,own:n,names:/* @__PURE__ */ new Set,ordinary:[]};let r=new Set(e.sheets.map(e=>ra(e.name))),i=t.sheets.filter(e=>!r.has(ra(e.name))),a=t.sheets.filter(e=>r.has(ra(e.name))).map(e=>e.name),o=new Set(Object.keys(e.names??{}).map(ra)),s=Object.entries(t.names??{}).filter(([e])=>!o.has(ra(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}}function aa(e,t){return t(oa(e,t))}function oa(e,t){switch(e.kind){case`unary`:case`postfix`:case`paren`:{let n=aa(e.arg,t);return n===e.arg?e:{...e,arg:n}}case`binary`:{let n=aa(e.left,t),r=aa(e.right,t);return n===e.left&&r===e.right?e:{...e,left:n,right:r}}case`call`:{let n=e.args.map(e=>aa(e,t));return n.every((t,n)=>t===e.args[n])?e:{...e,args:n}}case`invoke`:{let n=aa(e.callee,t),r=e.args.map(e=>aa(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=>aa(e,t)));return n.every((t,n)=>t.every((t,r)=>t===e.rows[n]?.[r]))?e:{...e,rows:n}}default:return e}}function sa(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 ca(e,t,n){let r=e.col&&sa(e.col,n,16384),i=e.col2&&sa(e.col2,n,16384),a=e.row&&sa(e.row,t,1048576),o=e.row2&&sa(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 la(e,t,n){return t===0&&n===0?e:aa(e,e=>e.kind===`ref`?ca(e,t,n):e)}let ua=[`#All`,`#Data`,`#Headers`,`#Totals`,`#This Row`];var da=class extends Error{at;constructor(e,t){super(e),this.at=t}};let fa=/* @__PURE__ */ new Set([`=`,`<>`,`<`,`<=`,`>`,`>=`]),pa={"=":1,"<>":1,"<":1,"<=":1,">":1,">=":1,"&":2,"+":3,"-":3,"*":4,"/":4,"^":5},ma=e=>e>=`0`&&e<=`9`,ha=e=>/[\p{L}_\\]/u.test(e)||e>=`\ud800`&&e<=`\udfff`,ga=e=>/[\p{L}\p{N}\p{M}_.?\\]/u.test(e)||e>=`\ud800`&&e<=`\udfff`,_a=(e,t)=>({index:e,abs:t});function va(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 ya=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 da(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,fa.has(n)?{op:n,inner:t}:pa[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=pa[r]??0;if(a<=e)return t;this.at+=i.length+r.length;let o=this.expression(a);t=va({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 va({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(`#`)&&!Sa(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(`#`)||Sa(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(xa(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===`[`||ha(e)}primary(){let e=this.space();return va(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(ma(e)||e===`.`){let e=Ea(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===`'`||ha(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=va({kind:`binary`,op:`,`,left:t,right:e},{inner:n}),n=this.space()}return this.eat(`)`)||this.stop(`a ( that is never closed`,e),va({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=Sa(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(ma(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&&ga(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=Ea(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:wa(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=Ea(this.s,this.at);if(r)return this.at=r.end,{kind:`ref`,...n,...r.ref};let i=wa(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=>va({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=ba.test(e)?/* @__PURE__ */ 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=va({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(va(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&&ha(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=ua.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)}};let ba=/^(?:_xlfn\.)?(?:LET|LAMBDA)$/iu,xa=e=>e.kind===`ref`||e.kind===`name`||e.kind===`structured`||e.kind===`call`||e.kind===`paren`||e.kind===`binary`&&(e.op===`:`||e.op===` `);function Sa(e,t){let n=/^#[A-Za-z0-9_/]+[!?]?/u.exec(e.slice(t));return n?zn(n[0])?.code:void 0}let Ca=(e,t)=>{let n=e.charAt(t);return n!==``&&(ga(n)||n===`(`||n===`!`||n===`[`)};function wa(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=p(r[2]??``),a=p(r[4]??``);if(i!==void 0&&a!==void 0&&!Ca(e,n))return{ref:{col:_a(i,r[1]===`$`),col2:_a(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=Ta(i),o=t+i[0].length;if(a&&!Ca(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=Ta(t),r=o+1+t[0].length;if(n&&!Ca(e,r))return{ref:{...a,col2:n.col,row2:n.row,range:!0},end:r}}}return{ref:{...a,range:!1},end:o}}}function Ta(e){let t=p(e[2]??``),n=Number(e[4])-1;if(!(t===void 0||t>=16384||n>=1048576))return{col:_a(t,e[1]===`$`),row:_a(n,e[3]===`$`)}}function Ea(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||Ca(e,r)))return{ref:{row:_a(i,n[1]===`$`),row2:_a(a,n[3]===`$`),range:!0},end:r}}function Da(e){try{return{ok:!0,node:new ya(e).parse()}}catch(e){if(e instanceof da)return{ok:!1,error:{message:e.message,at:e.at}};throw e}}var Oa=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=Da(e);i.ok?this.node=i.node:this.error=i.error}},ka=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 la(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:yr(this.moved)}},Aa=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 ka&&(this.formulas[t]=(this.formulas[t]??1)-1),n instanceof ka&&(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}},ja=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)}};let Ma=(e,t)=>e*16384+t;function Na(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 Pa=class{tables=[];blocks=[];merges=[];formulas=/* @__PURE__ */ new Set;implied=/* @__PURE__ */ new Map;keys=/* @__PURE__ */ new Map;fills=[];blanks=/* @__PURE__ */ new Set;conditions=[];validations=[];filters=[];charts=[];names=/* @__PURE__ */ new Map;freeze;generated=!1;grid=new Aa;expanded=!1;lowest=-1;ghosts=/* @__PURE__ */ new Map;spills=/* @__PURE__ */ new Set;stopped=/* @__PURE__ */ 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=Ha(e,t,[],()=>void 0);n&&this.charts.push(n)}))}put(e,t,n){n instanceof ka&&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 ka&&this.formulas.delete(r),n instanceof ka&&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(Ma(e,t))){if(r){let n=new ka(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(Ma(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(Ma(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&&y(t.spill,e));let t=/* @__PURE__ */ 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(Ma(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&&y(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(Ma(n,r),e);this.reach&&Na(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(Ma(n,r))===e&&this.ghosts.delete(Ma(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:/* @__PURE__ */ new Map,bottom:-1,right:-1};for(let{spill:t}of this.spills)t&&Na(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=>v(n.area,e,t))}blockAt(e,t){return this.blocks.find(n=>v(n.area,e,t))}looks(){if(this.lookAreas)return this.lookAreas;let e=[];for(let t of this.spec.format??[]){let n=g(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=g(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=>Fa.has(e)))]}lookAt(e,t){let n={},r=e=>{if(e)for(let[t,r]of Object.entries(e))Fa.has(t)&&r!==void 0&&(n[t]=t===`border`?{...n.border,...r}:r)},i=this.implied.get(Ma(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[f(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)v(n.area,e,t)&&r(n.entry);for(let n of l)v(n.area,e,t)&&r(n.entry);let u=this.keys.get(Ma(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(Ma(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=>v(n,e,t))}validationAt(e,t){return this.validations.find(n=>n.areas.some(n=>v(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=>v(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?.[f(t)]?.files}};let Fa=/* @__PURE__ */ new Set([`bold`,`italic`,`underline`,`strike`,`font`,`size`,`color`,`fill`,`align`,`valign`,`wrap`,`shrink`,`indent`,`rotation`,`border`,`locked`,`hide_formula`,`format`]);var Ia=class{title;sheets=[];names=/* @__PURE__ */ new Map;checks=[];bySheet=/* @__PURE__ */ new Map;byTable=/* @__PURE__ */ new Map;file;generated;ordinary=[];constructor(e,t){this.file=e,this.title=e.title,this.generated=t}respec(e){this.file=ia(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:na};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(Ma(t,n));if(o!==void 0)return{file:ta,path:[`sheets`,r,`cells`,o]};for(let i of Object.keys(e.spec.cells??{})){if(!i.includes(`:`))continue;let e=g(i);if(e&&v(e,t,n))return{file:ta,path:[`sheets`,r,`cells`,i]}}}};let La=/^[\p{L}_\\][\p{L}\p{N}_.\\?]*$/u;function Ra(e){return La.test(e)&&h(e)===void 0&&!/^(?:TRUE|FALSE)$/iu.test(e)&&!/^[Rr](?:\d+)?(?:[Cc]\d*)?$/u.test(e)&&!/^[Cc]\d*$/u.test(e)}let za=`made`,Ba=e=>e[0]===za?na:ta;var Va=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:Ba(e),...n===void 0?{}:{line:n},message:t})}sheetPath(e){return e<this.own?[`sheets`,e]:[za,`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 Pa(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:ta,path:[`checks`,t,`formula`]};this.wb.checks.push({name:e.name,formula:new Oa(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)?[za,`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(!Ra(t)){this.yaml(e,`${t} cannot be a name`);continue}let s={file:Ba(e),path:e},c=typeof o==`string`&&o.startsWith(`=`)?{name:t,formula:new Oa(o,0,0,s),source:s}:{name:t,value:typeof o==`string`?nr(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=h(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))y(n.area,r.area)&&this.problems.push({file:ta,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=g(n);i?e.merges.push(i):this.yaml([...t,`merges`,r],`${n} is not a range`)}),n.format?.forEach((e,n)=>{g(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??{}))p(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=Ha(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 Oa(e,t?.top??0,t?.left??0,{file:Ba(n),path:n})}condition(e,t,n){let r=_(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=_(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=g(n.filter.range);if(!i)this.yaml([...r,`range`],`${n.filter.range} is not a range`);else{let t=/* @__PURE__ */ new Map;for(let[e,a]of Object.entries(n.filter.columns??{})){let o=p(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=>y(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=/* @__PURE__ */ 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=>y(e.area,t));if(n)return`table ${n.name}`;let r=e.blocks.find(e=>y(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 ka(new Oa(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(Ma(t,n),r.format))}table(e,t,n){let r=h(t.at);if(!r){this.yaml([...n,`at`],`${t.at} is not a cell`);return}if(!Ra(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 ja(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=/* @__PURE__ */ 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 Oa(s,m,o,{file:Ba(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,nr(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=/* @__PURE__ */ 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=h(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,nr(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=g(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=Ka(i),s=Ma(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:Ba(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(!Ra(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:Ba(r),path:r},a=m(t).replace(/^([A-Z]+)(\d+)$/u,`$$$1$$$2`),o=`='${e.name.replaceAll(`'`,`''`)}'!${a}`;this.wb.names.set(n.toLowerCase(),{name:n,formula:new Oa(o,0,0,i),source:i})}fill(e,t,n,r){let i=Ka(n),a={file:Ba(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 Oa(i.formula,t.top,t.left,a),...i.start===void 0?{}:{start:i.start}})}};function Ha(e,t,n,r){let i=h(e.at);if(!i){r([...n,`at`],`${e.at} is not a cell`);return}let a=(e,t)=>{let n=new Oa(Ua(e),0,0,{file:Ba(t),path:t});return n.node&&!Wa(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}:{}}})}}let Ua=e=>e.startsWith(`=`)?e:`=${e}`;function Wa(e){switch(e.kind){case`error`:case`ref`:case`structured`:case`name`:return!0;case`paren`:case`postfix`:return Wa(e.arg);case`binary`:return e.op===`:`||e.op===`,`;default:return!1}}let Ga=e=>e.map(e=>e.text).join(``);function Ka(e){if(e===null)return{value:null};if(typeof e==`string`)return nr(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`?nr(e.start).value:e.start}};if(e.runs!==void 0)return{value:Ga(e.runs)};let{value:t}=e;return typeof t==`string`?nr(t):{value:t??null}}function qa(e){let t=ia(e.file,e.generated),n=new Ia(t.file,e.generated);return n.ordinary=t.ordinary,new Va(n,t=>{let n=e.generated?.csv[t];if(n!==void 0)return{rows:b(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}let Ja=e=>e instanceof j?{error:e.code}:e;function Ya(e){return typeof e!=`object`||!e?e:zn(e.error)??M.VALUE}let Xa=e=>({rows:e.rows,cols:e.cols,data:e.data.map(Ja)}),Za=e=>new N(e.rows,e.cols,e.data.map(Ya));function Qa(e,t){let n=t.formula?.text;if(n===void 0)return;let r=Da(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}}let $a=e=>typeof e==`string`?nr(e):{value:e??null};function eo(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=$a(r),a=Qa(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 Oa(i.formula,0,0,n.source),delete n.value)}return!0}let to=/* @__PURE__ */ new Map;function no(e){if(!/\d/u.test(e))return;if(to.has(e))return to.get(e);to.size>=5e4&&to.clear();let t=ro(e);return to.set(e,t),t}function ro(e){let t=nr(e.trim());if(typeof t.value==`number`)return t.value;if(e.trim()===``)return;let n=ln(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=ln(`${r[1]??``} ${r[2]??``}`);return typeof i?.value==`number`?i.value:void 0}function I(e){return typeof e==`number`?e:e==null?0:typeof e==`boolean`?+!!e:e instanceof j?e:no(e)??M.VALUE}function L(e){return typeof e==`string`?e:e==null?``:typeof e==`number`?Yn(e):typeof e==`boolean`?e?`TRUE`:`FALSE`:e}function io(e){if(typeof e==`boolean`)return e;if(e==null)return!1;if(typeof e==`number`)return e!==0;if(e instanceof j)return e;let t=e.trim().toUpperCase();return t===`TRUE`||t!==`FALSE`&&M.VALUE}let ao=e=>typeof e==`number`?0:typeof e==`string`?1:2,oo=(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 so(e,t){let n=e??(typeof t==`string`?``:typeof t!=`boolean`&&0),r=t??(typeof e==`string`?``:typeof e!=`boolean`&&0),i=ao(n),a=ao(r);if(i!==a)return i<a?-1:1;if(typeof n==`number`&&typeof r==`number`)return oo(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}let co=e=>Number.isFinite(e)?e:M.NUM;function lo(e,t,n){return Math.abs(e)<=Math.max(Math.abs(t),Math.abs(n))*89e-17?0:e}function uo(e,t,n){let r=I(t);if(r instanceof j)return r;let i=I(n);if(i instanceof j)return i;switch(e){case`+`:return co(lo(r+i,r,i));case`-`:return co(lo(r-i,r,i));case`*`:return co(r*i);case`/`:return i===0?M.DIV0:co(r/i);default:return r===0&&i===0?M.NUM:r===0&&i<0?M.DIV0:co(r**i)}}function fo(e,t,n){if(t instanceof j)return t;if(n instanceof j)return n;switch(e){case`&`:{let e=L(t);if(e instanceof j)return e;let r=L(n);return r instanceof j?r:`${e}${r}`}case`=`:return so(t,n)===0;case`<>`:return so(t,n)!==0;case`<`:return so(t,n)<0;case`<=`:return so(t,n)<=0;case`>`:return so(t,n)>0;case`>=`:return so(t,n)>=0;default:return uo(e,t,n)}}function po(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?M.NA:n(c,l)}return new N(r,i,a)}let mo=e=>({top:e.top,left:e.left,bottom:e.bottom,right:e.right});var ho=class{kept=/* @__PURE__ */ 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:mo(e)})),value:i}),i}asked=/* @__PURE__ */ 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:mo(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&&y(n.area,t))&&this.kept.delete(n)}clear(){this.kept.clear(),this.asked.clear()}};let go=(e,t)=>`${e}:${t.key}`,_o=/* @__PURE__ */ new Map;function vo(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?255:i.length}}function yo(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 bo(e,t){return e.group.length===0||t<=e.fixed.length||(t-e.fixed.length)%e.group.length===0}function R(e,t,n,r,i={}){_o.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 z(e,t,n,r={}){let{min:i,max:a,fixed:o,group:s}=vo(t);_o.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 xo(e,t,n,r){_o.set(e,{name:e,min:t,max:n,kind:`lazy`,call:r,from:`allyhub`})}function So(e,t){let n=_o.get(t);n&&_o.set(e,{...n,name:e})}function B(e,t){if(e instanceof j)return e;if(e instanceof or)return M.VALUE;if(e instanceof P){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 N)return{rows:e.rows,cols:e.cols,at:(t,n)=>e.at(t,n),array:e};if(e instanceof sr)return M.VALUE;let n=e instanceof F?null:e;return{rows:1,cols:1,at:()=>n}}function Co(e,t,n){for(let r of e)if(r instanceof P)t.calc.each(r,e=>{n(e,!1)});else if(r instanceof or)for(let e of r.parts)t.calc.each(e,e=>{n(e,!1)});else if(r instanceof N)for(let e of r.data)e!==null&&n(e,!1);else r instanceof F?n(null,!0):r instanceof sr?n(M.VALUE,!0):n(r,!0)}function wo(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 P)r(t);else if(t instanceof or)t.parts.forEach(r);else if(t instanceof N)for(let e of t.data)n(e,!1);else t instanceof F?n(null,!0):t instanceof sr?n(M.VALUE,!0):n(t,!0)}function To(e,t){let n=[],r;return Co(e,t,(e,t)=>{if(!r){if(e instanceof j)r=e;else if(typeof e==`number`)n.push(e);else if(t){let t=I(e);t instanceof j?r=t:n.push(t)}}}),r??n}function Eo(e,t){let n=[],r;return Co(e,t,(e,t)=>{if(!r){if(e instanceof j)r=e;else if(typeof e==`number`)n.push(e);else if(typeof e==`boolean`)n.push(+!!e);else if(t){let t=I(e);t instanceof j?r=t:n.push(t)}else typeof e==`string`&&n.push(0)}}),r??n}let Do=e=>(...t)=>{let n=[];for(let e of t){let t=I(e);if(t instanceof j)return t;n.push(t)}return e(...n)};function Oo(e,t){return e===void 0?t:I(e)}function ko(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`}let Ao=/* @__PURE__ */ new Map;function jo(e){let t=Ao.get(e);if(t)return t;Ao.size>=1e4&&Ao.clear();let n=Mo(e);return Ao.set(e,n),n}function Mo(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)}let No=e=>/[*?~]/u.test(e);function Po(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 Fo(e){return t=>{if(typeof t==`number`)return oo(t,e);if(typeof t!=`string`)return!1;let n=no(t);return n!==void 0&&oo(n,e)}}function Io(e,t){let n=t=>e===`>`?t>0:e===`>=`?t>=0:e===`<`?t<0:t<=0;return e=>typeof e==typeof t&&n(so(e,t))}function Lo(e){if(e===null)return{test:Fo(0),key:`n0`};if(typeof e==`number`)return{test:Fo(e),key:`n${String(Number(e.toPrecision(15)))}`};if(typeof e==`boolean`)return{test:t=>t===e,key:e?`bT`:`bF`};if(e instanceof j)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=no(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=Fo(a),t=ko(a);else if(o!==void 0)e=e=>e===o,t=ko(o);else if(zn(r)!==void 0)e=e=>e instanceof j&&e.code===r.toUpperCase();else if(No(r)){let t=jo(r);e=e=>typeof e==`string`&&t(e)}else{let n=r.toUpperCase();e=e=>typeof e==`string`&&e.toUpperCase()===n,t=ko(r)}return n===`=`?t===void 0?{test:e}:{test:e,key:t}:{test:t=>!e(t)}}return{test:Io(n,s??r)}}function Ro(e,t){let n=e.reference;if(!(n?.cols!==1||e.rows<64))return t.calc.indexes.ofRepeated(go(`crit`,n),[n],()=>{let t=/* @__PURE__ */ 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(ko(r),t),typeof r==`string`){let e=no(r);e!==void 0&&n(ko(e),t)}}return t})}function zo(e,t){return Lo(t.calc.scalar(e,t.frame))}function Bo(e,t){let n=[];for(let r=0;r+1<e.length;r+=2){let i=B(e[r],t);if(i instanceof j)return i;let a=zo(e[r+1],t);if(a instanceof j)return a;n.push({cells:i,crit:a})}let r=n[0]?.cells;return r&&n.some(e=>!Vo(e.cells,r))?M.VALUE:n}let Vo=(e,t)=>e.cols===t.cols&&(e.reference?.rows??e.rows)===(t.reference?.rows??t.rows);function Ho(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=Ro(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 Uo(e,t){return e instanceof P?(e.rows-t.rows)*e.cols:0}function Wo(e,t,n,r){let i;return Ho(t,n,(t,n)=>{if(i)return;let a=e.at(t,n);a instanceof j?i=a:typeof a==`number`&&r(a)}),i}function Go(e,t){let n=B(e[0],t);if(n instanceof j)return n;let r=e[2];return r===void 0?n:B(r,t)}let Ko=e=>(t,n)=>{let r=B(t[0],n);if(r instanceof j)return r;let i=zo(t[1],n);if(i instanceof j)return i;let a=Go(t,n);if(a instanceof j)return a;let o=[];return Wo(a,[{cells:r,crit:i}],n,e=>{o.push(e)})??e(o)},qo=e=>(t,n)=>{let r=B(t[0],n);if(r instanceof j)return r;let i=Bo(t.slice(1),n);if(i instanceof j)return i;let a=i[0]?.cells;if(a&&!Vo(r,a))return M.VALUE;let o=[];return Wo(r,i,n,e=>{o.push(e)})??e(o)},Jo=(e,t)=>(n,r)=>{let i=[],a=[e];for(let e of n)if(e instanceof P)i.push(e),a.push(`r${e.key}`);else if(e instanceof F)a.push(`-`);else if(e instanceof j)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 j)&&r.calc.results.set(o,i,c),c},Yo=e=>e.reduce((e,t)=>e+t,0),Xo=e=>e.length===0?M.DIV0:Yo(e)/e.length;z(`SUMIF`,`rv?r`,Jo(`SUMIF`,Ko(Yo))),z(`AVERAGEIF`,`rv?r`,Jo(`AVERAGEIF`,Ko(Xo))),z(`SUMIFS`,`r(rv)`,Jo(`SUMIFS`,qo(Yo))),z(`AVERAGEIFS`,`r(rv)`,Jo(`AVERAGEIFS`,qo(Xo))),z(`MINIFS`,`r(rv)`,Jo(`MINIFS`,qo(e=>e.length===0?0:e.reduce((e,t)=>t<e?t:e)))),z(`MAXIFS`,`r(rv)`,Jo(`MAXIFS`,qo(e=>e.length===0?0:e.reduce((e,t)=>t>e?t:e)))),z(`COUNTIF`,`rv`,Jo(`COUNTIF`,(e,t)=>{let n=B(e[0],t);if(n instanceof j)return n;let r=zo(e[1],t);if(r instanceof j)return r;let i=0;return Ho([{cells:n,crit:r}],t,()=>{i+=1}),i+(r.test(null)?Uo(e[0],n):0)})),z(`COUNTIFS`,`(rv)`,Jo(`COUNTIFS`,(e,t)=>{let n=Bo(e,t);if(n instanceof j)return n;let r=0;return Ho(n,t,()=>{r+=1}),r}));let Zo=e=>typeof e==`number`?0:typeof e==`string`?1:typeof e==`boolean`?2:3;function Qo(e,t){let n=Zo(e),r=Zo(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 j&&t instanceof j?e.code<t.code?-1:+(e.code>t.code):0}let $o=e=>e.separator??`, `;function es(e,t){let n=$o(t);return e.split(n.trim()===``?n:n.trim()).map(e=>e.trim()).filter(e=>e!==``)}let ts=(e,t,n,r)=>ar(t.value(e,n,r),e.lookAt(n,r).format),ns=(e,t)=>{if(t===``)return e.blanks===!0;let n=t.toLowerCase();return e.values?.some(e=>e.toLowerCase()===n)===!0};function rs(e,t,n,r){let i=e.validations.length===0?void 0:e.validationAt(t,n);return i?.spec.multiple===!0?es(r,i.spec):[r]}function is(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=No(a)?jo(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 as(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=ts(e,t,n,r);return a===``?i.blanks===!0:rs(e,n,r,a).some(e=>ns(i,e))};let c=i.conditions;if(c)return n=>{let a=t.value(e,n,r),o=ts(e,t,n,r),s=c.map(e=>is(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 os(e,t,n,r){return[...n.columns].filter(([e])=>e!==r).map(([r,i])=>as(e,t,n,r,i))}let ss=(e,t)=>e.every(e=>e(t));function cs(e,t){let n=/* @__PURE__ */ 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=os(e,t,r);for(let e=i+1;e<=o;e++)ss(s,e)||n.add(e)}return n}let ls=(e,t)=>e?t.calc.eval(e,t.frame):!1;function us(e,t,n){if(!(e instanceof N))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):M.NA}function ds(e,t,n){let r=[e,...t].filter(e=>e instanceof N),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(us(e,r,i));o[r*a+i]=s instanceof j?s:us(t[s]??M.VALUE,r,i)}return new N(i,a,o)}xo(`IF`,1,3,(e,t)=>{let n=t.calc.flat(ls(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 F?null:i};if(n instanceof N){let i=n=>n<e.length?t.calc.flat(r(n))??0:!1;return ds(n,[i(1),i(2)],e=>{let t=io(e);return t instanceof j?t:+!t})}let i=io(n);return i instanceof j?i:r(i?1:2)}),xo(`IFS`,2,255,(e,t)=>{for(let n=0;n+1<e.length;n+=2){let r=io(t.calc.scalar(ls(e[n],t),t.frame));if(r instanceof j)return r;if(r)return ls(e[n+1],t)}return M.NA});let fs=e=>(t,n)=>{let r=n.calc.flat(ls(t[0],n)),i=t=>t instanceof j&&(e===void 0||t===e),a=()=>t[1]?n.calc.flat(n.calc.eval(t[1],n.frame)):``;return r instanceof N?ds(r,[r,a()],e=>+!!i(e)):i(r)?a():r};xo(`IFERROR`,2,2,fs()),xo(`IFNA`,2,2,fs(M.NA)),xo(`CHOOSE`,2,255,(e,t)=>{let n=t.calc.flat(ls(e[0],t));if(n instanceof N){let r=e.slice(1).map(e=>t.calc.flat(t.calc.eval(e,t.frame)));return ds(n,r,e=>{let t=I(e);if(t instanceof j)return t;let n=Math.trunc(t)-1;return n<0||n>=r.length?M.VALUE:n})}let r=I(n);if(r instanceof j)return r;let i=Math.trunc(r),a=e[i];return i<1||a===void 0?M.VALUE:t.calc.eval(a,t.frame)}),xo(`SWITCH`,3,255,(e,t)=>{let n=t.calc.scalar(ls(e[0],t),t.frame);if(n instanceof j)return n;let r=1;for(;r+1<e.length;r+=2){let i=t.calc.scalar(ls(e[r],t),t.frame);if(i instanceof j)return i;if(so(n,i)===0)return ls(e[r+1],t)}return r<e.length?ls(e[r],t):M.NA});function ps(e,t){let n=[],r;return Co(e,t,(e,t)=>{if(r)return;if(e instanceof j){r=e;return}if(typeof e==`string`&&!t||e===null)return;let i=io(e);i instanceof j?r=i:n.push(i)}),r||(n.length===0?M.VALUE:n)}z(`AND`,`(r)`,(e,t)=>{let n=ps(e,t);return n instanceof j?n:n.every(Boolean)}),z(`OR`,`(r)`,(e,t)=>{let n=ps(e,t);return n instanceof j?n:n.some(Boolean)}),z(`XOR`,`(r)`,(e,t)=>{let n=ps(e,t);return n instanceof j?n:n.filter(Boolean).length%2==1}),R(`NOT`,1,1,e=>{let t=io(e);return t instanceof j?t:!t}),z(`TRUE`,``,()=>!0),z(`FALSE`,``,()=>!1);let ms=(e,t)=>t?{names:e,parent:t}:{names:e};xo(`LET`,3,255,(e,t)=>{if(e.length%2==0)return M.VALUE;let n=/* @__PURE__ */ new Map,r={...t.frame,scope:ms(n,t.frame.scope)};for(let i=0;i+1<e.length;i+=2){let a=e[i];if(a?.kind!==`name`)return M.VALUE;n.set(a.name.toLowerCase(),ls(e[i+1],{...t,frame:r}))}return ls(e[e.length-1],{...t,frame:r})}),xo(`LAMBDA`,1,254,(e,t)=>{let n=[];for(let t of e.slice(0,-1)){if(t.kind!==`name`)return M.VALUE;n.push(t.name.toLowerCase())}let r=e[e.length-1];return r?new sr(n,r,t.frame):M.VALUE});function hs(e){let t=0;for(let n of e)t=lo(t+n,t,n);return t}z(`SUM`,`(r)`,(e,t)=>{let n=0,r;return Co(e,t,(e,i)=>{if(!r){if(typeof e==`number`)n=lo(n+e,n,e);else if(e instanceof j)r=e;else if(i){let i=To([e],t);i instanceof j?r=i:n+=i[0]??0}}}),r??co(n)}),z(`AVERAGE`,`(r)`,(e,t)=>{let n=To(e,t);return n instanceof j?n:n.length===0?M.DIV0:hs(n)/n.length}),z(`AVERAGEA`,`(r)`,(e,t)=>{let n=Eo(e,t);return n instanceof j?n:n.length===0?M.DIV0:hs(n)/n.length}),z(`COUNT`,`(r)`,(e,t)=>{let n=0;return Co(e,t,(e,r)=>{typeof e==`number`?n+=1:r&&!(e instanceof j)&&e!==null&&(To([e],t)instanceof j||(n+=1))}),n}),z(`COUNTA`,`(r)`,(e,t)=>{let n=0;return Co(e,t,()=>{n+=1}),n}),z(`COUNTBLANK`,`r`,(e,t)=>{let n=e[0];if(n instanceof j)return n;if(n instanceof P){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 N?r.data.filter(e=>e===null||e===``).length:+(r===null||r===``)});let gs=e=>t=>{if(t instanceof j)return t;if(t.length===0)return 0;let n=t[0]??0;for(let r of t)n=e(n,r);return n},_s=gs((e,t)=>t<e?t:e),vs=gs((e,t)=>t>e?t:e);z(`MIN`,`(r)`,(e,t)=>_s(To(e,t))),z(`MAX`,`(r)`,(e,t)=>vs(To(e,t))),z(`MINA`,`(r)`,(e,t)=>_s(Eo(e,t))),z(`MAXA`,`(r)`,(e,t)=>vs(Eo(e,t))),z(`PRODUCT`,`(r)`,(e,t)=>{let n=To(e,t);return n instanceof j?n:n.length===0?0:co(n.reduce((e,t)=>e*t,1))}),z(`SUMSQ`,`(r)`,(e,t)=>{let n=To(e,t);return n instanceof j?n:co(hs(n.map(e=>e*e)))}),z(`SUMPRODUCT`,`(r)`,(e,t)=>{let n=e.map(e=>B(e,t)),r=n[0];if(r===void 0||r instanceof j)return r??M.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 j)return e;if(e.cols!==a||o(e)!==o(r))return M.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 j)return n;r*=typeof n==`number`?n:0}s+=r}return co(s)});let ys={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 bs(e){if(!(e instanceof ka))return!1;let{node:t}=e.shared;return t?.kind===`call`&&t.name===`SUBTOTAL`}z(`SUBTOTAL`,`v(r)`,(e,t)=>{let n=t.calc.scalar(e[0],t.frame);if(n instanceof j)return n;if(typeof n!=`number`)return M.VALUE;let r=n<100,i=ys[r?n:n-100],a=i===void 0?void 0:_o.get(i);if(a?.kind!==`raw`)return M.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(bs(e.sheet.at(o,n))?null:t.calc.read(e.sheet,o,n));o.push(new N(a.length,1,a))};for(let t of e.slice(1)){if(t instanceof j)return t;if(t instanceof P)s(t);else if(t instanceof or)t.parts.forEach(s);else return M.VALUE}return a.call(o,t)});let xs=(e,t)=>typeof e==typeof t&&!(e instanceof j)&&e!==null;function Ss(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)}}let Cs=/* @__PURE__ */ new WeakMap;function ws(e,t){let n=Cs.get(e);if(n)return n;if(n===void 0){Cs.set(e,null);return}let r=t();return Cs.set(e,r),r}function Ts(e,t,n,r,i,a=0,o=1){let s=typeof e==`string`?e:void 0,c=i&&s!==void 0&&No(s)?Po(s):s;if(s!==void 0&&c===void 0){let e=jo(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=ko(c??e);if(l===void 0)return-1;if(t.length>=64&&a===0&&o===1){let e=()=>{let e=/* @__PURE__ */ new Map;for(let n=t.length-1;n>=0;n--){let r=ko(t.at(n));r!==void 0&&e.set(r,[n])}return e},i=n.reference,a=i?r.calc.indexes.ofRepeated(go(`find`,i),[i],e):n.array&&ws(n.array,e);if(a)return a.get(l)?.[0]??-1}for(let e=a;e>=0&&e<t.length;e+=o)if(ko(t.at(e))===l)return e;return-1}function Es(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&&!xs(t.at(s),e);)--s;if(s<r){r=o+1;continue}let c=so(t.at(s),e);(n?c>=0:c<=0)?(a=s,r=o+1):i=s-1}return a}let Ds=(e,t)=>t.calc.scalar(e??null,t.frame),Os=(e,t,n)=>e===void 0?n:e instanceof F?!1:io(t.calc.scalar(e,t.frame));function ks(e){return(t,n)=>{let r=Ds(t[0],n);if(r instanceof j)return r;let i=B(t[1],n);if(i instanceof j)return i;let a=I(n.calc.scalar(t[2],n.frame));if(a instanceof j)return a;let o=Math.trunc(a);if(o<1)return M.VALUE;let s=i.reference,c=s?s.bottom-s.top+1:i.rows;if(o>(e?i.cols:c))return M.REF;let l=Os(t[3],n,!0);if(l instanceof j)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 P(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?Es(r,u):Ts(r,u,d,n,!0);return f<0?M.NA:e?i.at(f,o-1):i.at(o-1,f)}}z(`VLOOKUP`,`vrv?v`,ks(!0)),z(`HLOOKUP`,`vrv?v`,ks(!1)),z(`MATCH`,`vr?v`,(e,t)=>{let n=Ds(e[0],t);if(n instanceof j)return n;let r=B(e[1],t);if(r instanceof j)return r;let i=Ss(r);if(!i)return M.NA;let a=e[2]===void 0?1:e[2]instanceof F?0:I(t.calc.scalar(e[2],t.frame));if(a instanceof j)return a;let o=a===0?Ts(n,i,r,t,!0):Es(n,i,a<0);return o<0?M.NA:o+1}),z(`LOOKUP`,`vr?r`,(e,t)=>{let n=Ds(e[0],t);if(n instanceof j)return n;let r=B(e[1],t);if(r instanceof j)return r;let i=r.rows>=r.cols,a=Es(n,{length:i?r.rows:r.cols,at:e=>i?r.at(e,0):r.at(0,e)});if(a<0)return M.NA;if(e[2]===void 0)return i?r.at(a,r.cols-1):r.at(r.rows-1,a);let o=B(e[2],t);if(o instanceof j)return o;let s=Ss(o);return s?s.at(a):M.NA});function As(e,t,n,r,i){let a=Ss(t);if(!a)return-1;let o=i===-1;if(Math.abs(i)===2){let t=Es(e,a,i<0);if(t>=0&&so(a.at(t),e)===0)return t;if(r===0)return-1}let s=Ts(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(!xs(n,e))continue;let i=so(n,e),o=c<0||(r<0?so(n,a.at(c))>0:so(n,a.at(c))<0);(r<0?i<0:i>0)&&o&&(c=t)}return c}let js=(e,t,n)=>{let r=(e,t)=>e===void 0||e instanceof F?t:I(n.calc.scalar(e,n.frame)),i=r(e,0);if(i instanceof j)return i;let a=r(t,1);return a instanceof j?a:[i,a]};z(`XLOOKUP`,`vrr?rvv`,(e,t)=>{let n=Ds(e[0],t);if(n instanceof j)return n;let r=B(e[1],t);if(r instanceof j)return r;let i=B(e[2],t);if(i instanceof j)return i;let a=js(e[4],e[5],t);if(a instanceof j)return a;let o=As(n,r,t,a[0],a[1]);if(o<0){let n=e[3];return n===void 0||n instanceof F?M.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 N(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 N(i.rows,1,s)}),z(`XMATCH`,`vr?vv`,(e,t)=>{let n=Ds(e[0],t);if(n instanceof j)return n;let r=B(e[1],t);if(r instanceof j)return r;let i=js(e[2],e[3],t);if(i instanceof j)return i;let a=As(n,r,t,i[0],i[1]);return a<0?M.NA:a+1}),z(`INDEX`,`rv?vv`,(e,t)=>{let n=e[0],r=e=>{if(e===void 0||e instanceof F)return 0;let n=I(t.calc.scalar(e,t.frame));return n instanceof j?n:Math.trunc(n)};if(n instanceof or){let t=r(e[3]??1);if(t instanceof j)return t;let i=n.parts[t-1];if(!i)return M.REF;n=i}if(n instanceof j)return n;let i=r(e[1]);if(i instanceof j)return i;let a=r(e[2]);if(a instanceof j)return a;if(i<0||a<0)return M.VALUE;if(n instanceof P){let t=e[2]===void 0&&n.rows===1,r=t?1:i,o=t?i:a;return r>n.rows||o>n.cols?M.REF:new P(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=B(n,t);if(o instanceof j)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 M.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 N(u,d,f)}),z(`OFFSET`,`rvv?vv`,(e,t)=>{let n=e[0];if(n instanceof j)return n;if(!(n instanceof P))return M.VALUE;let r=(e,n)=>{if(e===void 0||e instanceof F)return n;let r=I(t.calc.scalar(e,t.frame));return r instanceof j?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 j)return e;let[c,l,u,d]=[i,a,o,s];if(u===0||d===0)return M.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?M.REF:new P(n.sheet,Math.min(f,m),Math.min(p,h),Math.max(f,m),Math.max(p,h))},{volatile:!0});let Ms=/^(?:(.*)!)?R(\[-?\d+\]|\d+)?C(\[-?\d+\]|\d+)?(?::R(\[-?\d+\]|\d+)?C(\[-?\d+\]|\d+)?)?$/iu,Ns=(e,t)=>e===void 0?t:e.startsWith(`[`)?t+Number(e.slice(1,-1)):Number(e)-1;function Ps(e,t,n){let r=Ms.exec(e.trim());if(!r)return;let[,i,a,o,s,c]=r,l={row:Ns(a,t),col:Ns(o,n)};if(l.row<0||l.col<0)return;let u=m(l),d=i===void 0?``:`${i}!`;if(s===void 0&&c===void 0)return`${d}${u}`;let f={row:Ns(s,t),col:Ns(c,n)};return f.row<0||f.col<0?void 0:`${d}${u}:${m(f)}`}z(`INDIRECT`,`v?v`,(e,t)=>{let n=L(t.calc.scalar(e[0],t.frame));if(n instanceof j)return n;let r=e[1]===void 0||io(t.calc.scalar(e[1],t.frame));if(r instanceof j)return r;let i=r?n:Ps(n,t.frame.row,t.frame.col);if(i===void 0)return M.REF;let a=Da(i);if(!a.ok)return M.REF;let{node:o}=a;if(o.kind!==`ref`&&o.kind!==`structured`&&o.kind!==`name`&&(o.kind!==`binary`||o.op!==`:`))return M.REF;let s=t.calc.eval(o,{...t.frame,dr:0,dc:0});return s instanceof P||s instanceof or?s:M.REF},{volatile:!0});let Fs=(e,t,n)=>{if(e===void 0||e instanceof F)return t+1;if(e instanceof j)return e;if(e instanceof N)return new N(e.rows,e.cols,e.data.map(e=>e instanceof j?e:M.VALUE));if(!(e instanceof P))return M.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===Is?new N(i,1,a):new N(1,i,a)},Is=e=>[e.top,e.bottom===1048575?Math.min(e.rows,e.sheet.lastRow-e.top+1):e.rows],Ls=e=>[e.left,e.cols];z(`ROW`,`?r`,(e,t)=>Fs(e[0],t.frame.row,Is)),z(`COLUMN`,`?r`,(e,t)=>Fs(e[0],t.frame.col,Ls)),z(`ROWS`,`r`,(e,t)=>{let n=e[0];if(n instanceof P)return n.rows;let r=B(n,t);return r instanceof j?r:r.rows}),z(`COLUMNS`,`r`,(e,t)=>{let n=e[0];if(n instanceof P)return n.cols;let r=B(n,t);return r instanceof j?r:r.cols}),z(`AREAS`,`r`,e=>{let t=e[0];return t instanceof P?1:t instanceof or?t.parts.length:M.VALUE}),R(`ADDRESS`,2,5,(e,t,n,r,i)=>{let a=I(e),o=I(t),s=n==null?1:I(n);for(let e of[a,o,s])if(e instanceof j)return e;let[c,l,u]=[a,o,s];if((c??0)<1||(l??0)<1||(c??0)>1048576||(l??0)>16384)return M.VALUE;let d=r==null||io(r);if(d instanceof j)return d;let p=u===1||u===2,m=u===1||u===3,h=d?`${m?`$`:``}${f((l??1)-1)}${p?`$`:``}${String(c)}`:`R${p?String(c):`[${String(c)}]`}C${m?String(l):`[${String(l)}]`}`;if(i==null)return h;let g=L(i);return g instanceof j?g:`${fr(g)}${h}`}),z(`TRANSPOSE`,`r`,(e,t)=>{let n=B(e[0],t);if(n instanceof j)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 N(n.cols,n.rows,r)}),xo(`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 P)return r.sheet.index+1;let i=t.calc.scalar(r,t.frame);if(typeof i!=`string`)return M.NA;let a=t.calc.wb.sheet(i);return a?a.index+1:M.NA}),z(`SHEETS`,`?r`,(e,t)=>t.calc.wb.sheets.length);let Rs=(e,t)=>Array.from(e,e=>{let n=t(e);return n.length===e.length?n:e}).join(``),zs=e=>Rs(e,e=>e.toLowerCase());function Bs(e,t){if(e===void 0||e instanceof F)return[];let n=B(e,t);if(n instanceof j)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=L(i);if(a instanceof j)return a;r.push(a)}return r}function Vs(e,t,n){let r=n?zs(e):e,i=(n?t.map(zs):[...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 Hs(e,t,n){let r=[],i=0;for(let a of Vs(e,t,n))r.push(e.slice(i,a.at)),i=a.at+a.length;return r.push(e.slice(i)),r}let Us=e=>t=>{let n=L(t);return n instanceof j?n:e(n)},Ws=(e,t)=>{if(e===void 0)return t;let n=I(e);return n instanceof j?n:n<0?M.VALUE:Math.trunc(n)},Gs=e=>Rs(e,e=>e.toUpperCase()),Ks=zs;R(`LEFT`,1,2,(e,t)=>{let n=L(e),r=Ws(t,1);return n instanceof j?n:r instanceof j?r:n.slice(0,r)}),R(`RIGHT`,1,2,(e,t)=>{let n=L(e),r=Ws(t,1);return n instanceof j?n:r instanceof j?r:r===0?``:n.slice(-r)}),R(`MID`,3,3,(e,t,n)=>{let r=L(e),i=I(t),a=Ws(n,0);if(r instanceof j)return r;if(i instanceof j)return i;if(a instanceof j)return a;if(i<1)return M.VALUE;let o=Math.trunc(i)-1;return r.slice(o,o+a)}),R(`LEN`,1,1,Us(e=>e.length)),R(`LOWER`,1,1,Us(Ks)),R(`UPPER`,1,1,Us(Gs)),R(`PROPER`,1,1,Us(e=>Ks(e).replace(/(^|[^\p{L}])(\p{L})/gu,(e,t,n)=>`${t}${Gs(n)}`))),R(`TRIM`,1,1,Us(e=>e.replace(/ +/gu,` `).replace(/^ | $/gu,``))),R(`CLEAN`,1,1,Us(e=>e.replace(/[\u0000-\u001f]/gu,``))),R(`T`,1,1,e=>typeof e==`string`?e:``),R(`EXACT`,2,2,(e,t)=>{let n=L(e),r=L(t);return n instanceof j?n:r instanceof j?r:n===r}),R(`REPT`,2,2,(e,t)=>{let n=L(e),r=Ws(t,0);return n instanceof j?n:r instanceof j?r:n.length*r>32767?M.VALUE:n.repeat(r)}),R(`CHAR`,1,1,Do(e=>{let t=Math.trunc(e);return t<1||t>255?M.VALUE:qs(t)})),R(`UNICHAR`,1,1,Do(e=>{let t=Math.trunc(e);return t<1||t>1114111?M.VALUE:String.fromCodePoint(t)})),R(`CODE`,1,1,Us(e=>e===``?M.VALUE:e.charCodeAt(0))),R(`UNICODE`,1,1,Us(e=>e.codePointAt(0)??M.VALUE));function qs(e){return e>=128&&e<160?`€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ`.charAt(e-128):String.fromCharCode(e)}z(`CONCAT`,`(r)`,(e,t)=>{let n=``,r;return wo(e,t,e=>{if(r)return;let t=L(e);t instanceof j?r=t:n+=t}),r??n}),R(`CONCATENATE`,1,255,(...e)=>{let t=``;for(let n of e){let e=L(n);if(e instanceof j)return e;t+=e}return t}),z(`TEXTJOIN`,`rv(r)`,(e,t)=>{let[n,r,...i]=e,a=B(n??``,t);if(a instanceof j)return a;let o=[];for(let e=0;e<a.rows;e++)for(let t=0;t<a.cols;t++){let n=L(a.at(e,t));if(n instanceof j)return n;o.push(n)}let s=io(t.calc.scalar(r===void 0||r instanceof F||r,t.frame));if(s instanceof j)return s;let c=[],l;if(wo(i,t,e=>{if(l)return;let t=L(e);t instanceof j?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}),R(`SUBSTITUTE`,3,4,(e,t,n,r)=>{let i=L(e),a=L(t),o=L(n);if(i instanceof j)return i;if(a instanceof j)return a;if(o instanceof j)return o;if(a===``)return i;if(r===void 0)return i.split(a).join(o);let s=I(r);if(s instanceof j)return s;if(s<1)return M.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)}`}),R(`REPLACE`,4,4,(e,t,n,r)=>{let i=L(e),a=I(t),o=Ws(n,0),s=L(r);if(i instanceof j)return i;if(a instanceof j)return a;if(o instanceof j)return o;if(s instanceof j)return s;if(a<1)return M.VALUE;let c=Math.trunc(a)-1;return`${i.slice(0,c)}${s}${i.slice(c+o)}`}),R(`FIND`,2,3,(e,t,n)=>{let r=L(e),i=L(t),a=n===void 0?1:I(n);if(r instanceof j)return r;if(i instanceof j)return i;if(a instanceof j)return a;if(a<1||a>i.length+1)return M.VALUE;let o=i.indexOf(r,Math.trunc(a)-1);return o<0?M.VALUE:o+1}),R(`SEARCH`,2,3,(e,t,n)=>{let r=L(e),i=L(t),a=n===void 0?1:I(n);if(r instanceof j)return r;if(i instanceof j)return i;if(a instanceof j)return a;if(a<1||a>i.length+1)return M.VALUE;let o=Math.trunc(a)-1,s=Po(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?M.VALUE:n+1}}let c=jo(`${r}*`);for(let e=o;e<=i.length;e++)if(c(i.slice(e)))return e+1;return M.VALUE}),R(`VALUE`,1,1,e=>typeof e==`number`?e:e==null?0:typeof e==`string`?no(e)??M.VALUE:M.VALUE),R(`NUMBERVALUE`,1,3,(e,t,n)=>{let r=L(e),i=L(t??`.`),a=L(n??`,`);if(r instanceof j)return r;if(i instanceof j)return i;if(a instanceof j)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)?M.VALUE:c/100**s}),R(`TEXT`,2,2,(e,t)=>{let n=L(t);if(n instanceof j)return n;if(!Ln(n))return M.VALUE;if(typeof e==`boolean`)return e?`TRUE`:`FALSE`;let r=typeof e==`string`?no(e)??e:e??0;if(r instanceof j)return r;try{return In(n,r)}catch{return M.VALUE}});function Js(e,t,n){return In(`${n?`#,##0`:`0`}${t>0?`.${`0`.repeat(t)}`:``}`,e)}let Ys=(e,t)=>{let n=10**t;return Math.sign(e)*Math.round(Math.abs(e)*n+1e-9)/n};R(`FIXED`,1,3,(e,t,n)=>{let r=I(e),i=t==null?2:I(t),a=n!==void 0&&io(n);if(r instanceof j)return r;if(i instanceof j)return i;if(a instanceof j)return a;let o=Math.trunc(i);return Js(Ys(r,o),Math.max(0,o),!a)}),R(`DOLLAR`,1,2,(e,t)=>{let n=I(e),r=t==null?2:I(t);if(n instanceof j)return n;if(r instanceof j)return r;let i=Math.trunc(r),a=Js(Math.abs(Ys(n,i)),Math.max(0,i),!0);return n<0?`($${a})`:`$${a}`});function Xs(e,t,n,r,i){let a=Vs(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 Zs(e){return(t,n)=>{let[r,i,a,o,s,c]=t.map(e=>e instanceof F?void 0:e),l=L(r??null),u=Bs(i,n),d=Oo(a,1),f=Oo(o,0),p=Oo(s,0);if(l instanceof j)return l;if(u instanceof j)return u;if(d instanceof j)return d;if(f instanceof j)return f;if(p instanceof j)return p;let m=Math.trunc(d);if(m===0||Math.abs(m)>Math.max(l.length,1))return M.VALUE;if(u.length>0&&u.every(e=>e===``))return m>0==(e===`before`)?``:l;let h=Xs(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?M.NA:c}}z(`TEXTBEFORE`,`vr?vvvv`,Zs(`before`)),z(`TEXTAFTER`,`vr?vvvv`,Zs(`after`)),R(`HYPERLINK`,1,2,(e,t)=>t===void 0?e??``:t),R(`ENCODEURL`,1,1,Us(e=>encodeURIComponent(e)));for(let e of[`LEN`,`LEFT`,`RIGHT`,`MID`,`FIND`,`SEARCH`,`REPLACE`])So(`${e}B`,e);let Qs=e=>{let t=I(e);return t instanceof j?t:t<0||t>=2958466?M.NUM:Math.floor(t)},$s=e=>e%4==0&&e%100!=0||e%400==0,ec=(e,t)=>t===2?$s(e)?29:28:[4,6,9,11].includes(t)?30:31,tc=e=>e.month===2&&e.day===ec(e.year,2);R(`DATE`,3,3,Do((e=0,t=1,n=1)=>{let r=Math.trunc(e);if(r<0||r>9999)return M.NUM;let i=Wn(r<1900?r+1900:r,Math.trunc(t),Math.trunc(n));return Number.isFinite(i)&&i>=0&&i<=2958465?i:M.NUM})),R(`TIME`,3,3,Do((e=0,t=0,n=0)=>{let r=Math.trunc(e)*3600+Math.trunc(t)*60+Math.trunc(n);return r<0?M.NUM:r%86400/86400})),R(`YEAR`,1,1,e=>{let t=Qs(e);return t instanceof j?t:Gn(t).year}),R(`MONTH`,1,1,e=>{let t=Qs(e);return t instanceof j?t:Gn(t).month}),R(`DAY`,1,1,e=>{let t=Qs(e);return t instanceof j?t:Gn(t).day});let nc=e=>{let t=I(e);return t instanceof j?t:t<0?M.NUM:Math.round((t-Math.floor(t))*86400)%86400};R(`HOUR`,1,1,e=>{let t=nc(e);return t instanceof j?t:Math.floor(t/3600)}),R(`MINUTE`,1,1,e=>{let t=nc(e);return t instanceof j?t:Math.floor(t/60)%60}),R(`SECOND`,1,1,e=>{let t=nc(e);return t instanceof j?t:t%60}),R(`DATEVALUE`,1,1,e=>{let t=L(e);if(t instanceof j)return t;let n=an(t)??ln(t);return typeof n?.value==`number`?Math.floor(n.value):M.VALUE}),R(`TIMEVALUE`,1,1,e=>{let t=L(e);if(t instanceof j)return t;let n=on(t)??ln(t);return typeof n?.value==`number`?n.value-Math.floor(n.value):M.VALUE});let rc=e=>(e%7+6)%7;R(`WEEKDAY`,1,2,(e,t)=>{let n=Qs(e);if(n instanceof j)return n;let r=t==null?1:I(t);if(r instanceof j)return r;let i=rc(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:M.NUM});let ic=e=>{let t=e-(rc(e)+6)%7+3,{year:n}=Gn(t);return Math.floor((t-Wn(n,1,1))/7)+1};R(`ISOWEEKNUM`,1,1,e=>{let t=Qs(e);return t instanceof j?t:ic(t)}),R(`WEEKNUM`,1,2,(e,t)=>{let n=Qs(e);if(n instanceof j)return n;let r=t==null?1:I(t);if(r instanceof j)return r;if(r===21)return ic(n);let i=r===1?0:r===2?1:r>=11&&r<=17?(r-10)%7:-1;if(i<0)return M.NUM;let a=Wn(Gn(n).year,1,1),o=(rc(a)+7-i)%7;return Math.floor((n-a+o)/7)+1});let ac=(e,t)=>{let{year:n,month:r,day:i}=Gn(e),a=n*12+r-1+t,o=Math.floor(a/12),s=a-o*12+1;return Wn(o,s,Math.min(i,ec(o,s)))};R(`EDATE`,2,2,(e,t)=>{let n=Qs(e),r=I(t);if(n instanceof j)return n;if(r instanceof j)return r;let i=ac(n,Math.trunc(r));return i<0?M.NUM:i}),R(`EOMONTH`,2,2,(e,t)=>{let n=Qs(e),r=I(t);if(n instanceof j)return n;if(r instanceof j)return r;let i=Gn(ac(n,Math.trunc(r))),a=Wn(i.year,i.month,ec(i.year,i.month));return a<0?M.NUM:a}),R(`DAYS`,2,2,(e,t)=>{let n=Qs(e),r=Qs(t);return n instanceof j?n:r instanceof j?r:n-r}),R(`DATEDIF`,3,3,(e,t,n)=>{let r=Qs(e),i=Qs(t),a=L(n);if(r instanceof j)return r;if(i instanceof j)return i;if(a instanceof j)return a;if(r>i)return M.NUM;let o=Gn(r),s=Gn(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,t=s.month===1?s.year-1:s.year;return ec(t,e)-o.day+s.day}case`YD`:{let e=s.year-o.year-+(c%12<0),t=Math.floor(c/12),n=ac(r,t*12);return e>=0?i-n:M.NUM}default:return M.NUM}});function oc(e,t,n){let r=Gn(e),i=Gn(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===ec(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}R(`DAYS360`,2,3,(e,t,n)=>{let r=Qs(e),i=Qs(t),a=n!==void 0&&io(n);return r instanceof j?r:i instanceof j?i:a instanceof j?a:oc(r,i,a)});function sc(e,t,n){let[r,i]=e<=t?[e,t]:[t,e],a=Gn(r),o=Gn(i),s=i-r;switch(n){case 0:{let e=a.day,t=o.day;return tc(a)&&(tc(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 oc(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=$s(a.year);else{let t=e=>$s(e)?Wn(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/((Wn(o.year+1,1,1)-Wn(a.year,1,1))/e)}}}R(`YEARFRAC`,2,3,(e,t,n)=>{let r=Qs(e),i=Qs(t),a=n==null?0:I(n);if(r instanceof j)return r;if(i instanceof j)return i;if(a instanceof j)return a;let o=Math.trunc(a);return o<0||o>4?M.NUM:sc(r,i,o)});function cc(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 M.VALUE;let t=e.split(``).map(e=>e===`1`);return[t[6]??!1,...t.slice(0,6)]}let n=I(e);return n instanceof j?n:n>=1&&n<=7?t((n+5)%7,(n+6)%7):n>=11&&n<=17?t(n-11):M.NUM}function lc(e,t){if(e===void 0||e instanceof F)return/* @__PURE__ */ new Set;let n=To([e],t);return n instanceof j?n:new Set(n.map(e=>Math.floor(e)))}function uc(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[rc(o)]!==!0&&!r.has(o)&&(a+=i);return a}function dc(e,t,n,r){if(n.every(Boolean))return M.VALUE;let i=t<0?-1:1,a=e;for(let e=Math.abs(t);e>0;)a+=i,n[rc(a)]!==!0&&!r.has(a)&&--e;return a<0?M.NUM:a}let fc=e=>(t,n)=>{let r=Qs(n.calc.scalar(t[0],n.frame)),i=Qs(n.calc.scalar(t[1],n.frame));if(r instanceof j)return r;if(i instanceof j)return i;let a=e?t[2]:void 0,o=cc(a===void 0||a instanceof F?void 0:n.calc.scalar(a,n.frame));if(o instanceof j)return o;let s=lc(t[e?3:2],n);return s instanceof j?s:uc(r,i,o,s)},pc=e=>(t,n)=>{let r=Qs(n.calc.scalar(t[0],n.frame)),i=I(n.calc.scalar(t[1],n.frame));if(r instanceof j)return r;if(i instanceof j)return i;let a=e?t[2]:void 0,o=cc(a===void 0||a instanceof F?void 0:n.calc.scalar(a,n.frame));if(o instanceof j)return o;let s=lc(t[e?3:2],n);return s instanceof j?s:dc(r,Math.trunc(i),o,s)};z(`NETWORKDAYS`,`vv?r`,fc(!1)),z(`NETWORKDAYS.INTL`,`vv?vr`,fc(!0)),z(`WORKDAY`,`vv?r`,pc(!1)),z(`WORKDAY.INTL`,`vv?vr`,pc(!0)),z(`NOW`,``,(e,t)=>t.calc.nowSerial(),{volatile:!0}),z(`TODAY`,``,(e,t)=>Math.floor(t.calc.nowSerial()),{volatile:!0});function mc(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}let hc=(e,t)=>{let n=[];return wo([e],t,e=>n.push(e)),n},gc=(e,t)=>{let n=hc(e[0],t),r=hc(e[1],t);if(n.length!==r.length)return M.NUM;let i=[],a=[];for(let[e,t]of n.entries()){let n=r[e]??null;if(t instanceof j)return t;if(n instanceof j)return n;if(typeof t==`number`){if(typeof n!=`number`)return M.VALUE;i.push(t),a.push(Math.floor(n))}}return i.length===0?M.NUM:{values:i,dates:a}};z(`XNPV`,`vrr`,(e,t)=>{let n=I(t.calc.scalar(e[0],t.frame));if(n instanceof j)return n;let r=gc(e.slice(1),t);return r instanceof j?r:n<=0?M.NUM:mc(n,r.values,r.dates)}),z(`XIRR`,`rr?v`,(e,t)=>{let n=gc(e,t);if(n instanceof j)return n;let{values:r,dates:i}=n;if(!r.some(e=>e>0)||!r.some(e=>e<0))return M.NUM;let a=e[2]===void 0||e[2]instanceof F?.1:I(t.calc.scalar(e[2],t.frame));if(a instanceof j)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 M.NUM;if(Math.abs(n-s)<1e-10)return n;s=n<=-1?(s-1)/2:n}return M.NUM});let _c=(e,t)=>{R(e,1,1,e=>t(e),{errors:!0})};_c(`ISBLANK`,e=>e==null),_c(`ISNUMBER`,e=>typeof e==`number`),_c(`ISTEXT`,e=>typeof e==`string`),_c(`ISNONTEXT`,e=>typeof e!=`string`),_c(`ISLOGICAL`,e=>typeof e==`boolean`),_c(`ISERROR`,e=>e instanceof j),_c(`ISERR`,e=>e instanceof j&&e!==M.NA),_c(`ISNA`,e=>e===M.NA);let vc=(e,t)=>{let n=I(e);return n instanceof j?n:Math.abs(Math.trunc(n))%2===t};R(`ISEVEN`,1,1,e=>vc(e,0)),R(`ISODD`,1,1,e=>vc(e,1)),R(`N`,1,1,e=>typeof e==`number`?e:typeof e==`boolean`?+!!e:e instanceof j?e:0,{errors:!0}),z(`NA`,``,()=>M.NA),z(`TYPE`,`r`,(e,t)=>{let n=t.calc.flat(e[0]);return n instanceof N?64:typeof n==`number`||n===null?1:typeof n==`string`?2:typeof n==`boolean`?4:16});let yc=[M.NULL,M.DIV0,M.VALUE,M.REF,M.NAME,M.NUM,M.NA];R(`ERROR.TYPE`,1,1,e=>{let t=e instanceof j?yc.indexOf(e):-1;return t<0?M.NA:t+1},{errors:!0}),xo(`ISREF`,1,1,(e,t)=>{let n=e[0];if(!n)return!1;let r=t.calc.eval(n,t.frame);return r instanceof P||r instanceof or});let bc=e=>e instanceof P?e.sheet.at(e.top,e.left):void 0;xo(`ISFORMULA`,1,1,(e,t)=>{let n=e[0];if(!n)return M.VALUE;let r=t.calc.eval(n,t.frame);return r instanceof sr?M.VALUE:bc(r)instanceof ka}),xo(`FORMULATEXT`,1,1,(e,t)=>{let n=e[0];if(!n)return M.VALUE;let r=bc(t.calc.eval(n,t.frame));return r instanceof ka?r.text:M.NA}),z(`CELL`,`v?r`,(e,t)=>{let n=L(t.calc.scalar(e[0],t.frame));if(n instanceof j)return n;let r=e[1],i=r instanceof P?r:new P(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 m({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 M.VALUE}}),z(`TABLE`,`?rrrrr`,()=>M.NA);var xc=/* @__PURE__ */ o(((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,y;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)),y=-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)+y),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,y=g,b=(u-g)/v,x=y+b,S=0,ee=i-1,C=1;C<=v;C++){for(var te=0,ne=.5*(x+y),w=.5*(x-y),re=1;re<=a;re++){var ie,ae;o<re?(ie=a-re+1,ae=m[ie-1]):(ie=re,ae=-m[ie-1]);var oe=ne+w*ae,se=oe*oe;if(se>l)break;var ce=2*e.normal.cdf(oe,0,1,1,0),T=2*e.normal.cdf(oe,n,1,1,0),E=ce*.5-T*.5;E>=t.exp(s/ee)&&(E=h[ie-1]*t.exp(-(.5*se))*t.pow(E,ee),te+=E)}te*=2*w*i/t.sqrt(2*t.PI),S+=te,y=x,x+=b}return _+=S,_<=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,y=120,b=.5-.5*e,x=t.sqrt(t.log(1/(b*b))),S=x+((((x*f+u)*x+c)*x+o)*x+i)/((((x*p+d)*x+l)*x+s)*x+a);r<y&&(S+=(S*S*S+S)/r/4);var ee=m-h*S;return r<y&&(ee+=-g/r+_*S/r),S*(ee*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,y=.125,b=[.9894009349916499,.9445750230732326,.8656312023878318,.755404408355003,.6178762444026438,.45801677765722737,.2816035507792589,.09501250983763744],x=[.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 S=a*.5,ee=S*t.log(a)-a*t.log(2)-e.gammaln(S),C=S-1,te=a*.25,ne=a<=f?g:a<=p?_:a<=m?v:y;ee+=t.log(ne);for(var w=0,re=1;re<=50;re++){for(var ie=0,ae=(2*re-1)*ne,oe=1;oe<=c;oe++){var se,ce;l<oe?(se=oe-l-1,ce=ee+C*t.log(ae+b[se]*ne)-(b[se]*ne+ae)*te):(se=oe-1,ce=ee+C*t.log(ae-b[se]*ne)+(b[se]*ne-ae)*te);var T;if(ce>=u){T=l<oe?n*t.sqrt((b[se]*ne+ae)*.5):n*t.sqrt((-(b[se]*ne)+ae)*.5);var E=i(T,o,s)*x[se]*t.exp(ce);ie+=E}}if(re*ne>=1&&ie<=d)break;w+=ie}if(ie>d)throw Error(`tukey.cdf failed to converge`);return w>1&&(w=1),w},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})})),Sc=/* @__PURE__ */ o((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})})),Cc=/* @__PURE__ */ s({ABS:()=>Kd,ACCRINT:()=>Tg,ACOS:()=>qd,ACOSH:()=>Jd,ACOT:()=>Yd,ACOTH:()=>Xd,AGGREGATE:()=>Zd,AND:()=>i_,ARABIC:()=>Qd,ASIN:()=>$d,ASINH:()=>ef,ATAN:()=>tf,ATAN2:()=>nf,ATANH:()=>rf,AVEDEV:()=>Du,AVERAGE:()=>Ou,AVERAGEA:()=>ku,AVERAGEIF:()=>Au,AVERAGEIFS:()=>ju,BASE:()=>af,BESSELI:()=>nm,BESSELJ:()=>rm,BESSELK:()=>im,BESSELY:()=>am,BETA:()=>Mu,BETADIST:()=>eh,BETAINV:()=>th,BIN2DEC:()=>om,BIN2HEX:()=>sm,BIN2OCT:()=>cm,BINOM:()=>Nu,BINOMDIST:()=>nh,BITAND:()=>lm,BITLSHIFT:()=>um,BITOR:()=>dm,BITRSHIFT:()=>fm,BITXOR:()=>pm,CEILING:()=>of,CEILINGMATH:()=>rh,CEILINGPRECISE:()=>ih,CHAR:()=>$l,CHIDIST:()=>ah,CHIDISTRT:()=>oh,CHIINV:()=>sh,CHIINVRT:()=>ch,CHISQ:()=>Pu,CHITEST:()=>lh,CHOOSE:()=>Pl,CHOOSECOLS:()=>Fl,CHOOSEROWS:()=>Il,CLEAN:()=>eu,CODE:()=>tu,COLUMN:()=>Ll,COLUMNS:()=>Rl,COMBIN:()=>sf,COMBINA:()=>cf,COMPLEX:()=>mm,CONCAT:()=>ru,CONCATENATE:()=>nu,CONFIDENCE:()=>Fu,CONVERT:()=>hm,CORREL:()=>Iu,COS:()=>lf,COSH:()=>uf,COT:()=>df,COTH:()=>ff,COUNT:()=>Lu,COUNTA:()=>Ru,COUNTBLANK:()=>zu,COUNTIF:()=>Bu,COUNTIFS:()=>Vu,COUPDAYS:()=>Eg,COVAR:()=>uh,COVARIANCE:()=>Hu,COVARIANCEP:()=>dh,COVARIANCES:()=>fh,CRITBINOM:()=>ph,CSC:()=>pf,CSCH:()=>mf,CUMIPMT:()=>Dg,CUMPRINC:()=>Og,DATE:()=>kp,DATEDIF:()=>Ap,DATEVALUE:()=>jp,DAVERAGE:()=>cg,DAY:()=>Mp,DAYS:()=>Pp,DAYS360:()=>Fp,DB:()=>kg,DCOUNT:()=>lg,DCOUNTA:()=>ug,DDB:()=>Ag,DEC2BIN:()=>gm,DEC2HEX:()=>_m,DEC2OCT:()=>vm,DECIMAL:()=>hf,DEGREES:()=>gf,DELTA:()=>ym,DEVSQ:()=>Uu,DGET:()=>dg,DISC:()=>jg,DMAX:()=>fg,DMIN:()=>pg,DOLLAR:()=>iu,DOLLARDE:()=>Mg,DOLLARFR:()=>Ng,DPRODUCT:()=>mg,DROP:()=>zl,DSTDEV:()=>hg,DSTDEVP:()=>gg,DSUM:()=>_g,DVAR:()=>vg,DVARP:()=>yg,EDATE:()=>Ip,EFFECT:()=>Pg,EOMONTH:()=>Lp,ERF:()=>bm,ERFC:()=>xm,ERFCPRECISE:()=>mh,ERFPRECISE:()=>hh,ERROR:()=>bl,EVEN:()=>_f,EXACT:()=>au,EXP:()=>vf,EXPAND:()=>Bl,EXPON:()=>Wu,EXPONDIST:()=>gh,F:()=>Gu,FACT:()=>bf,FACTDOUBLE:()=>xf,FALSE:()=>a_,FDIST:()=>_h,FDISTRT:()=>vh,FIND:()=>ou,FINV:()=>yh,FINVRT:()=>bh,FISHER:()=>Ku,FISHERINV:()=>qu,FIXED:()=>su,FLOOR:()=>Sf,FLOORMATH:()=>xh,FLOORPRECISE:()=>Sh,FORECAST:()=>Ju,FREQUENCY:()=>Yu,FTEST:()=>Ch,FV:()=>Fg,FVSCHEDULE:()=>Ig,GAMMA:()=>Xu,GAMMADIST:()=>wh,GAMMAINV:()=>Th,GAMMALN:()=>Zu,GAMMALNPRECISE:()=>Eh,GAUSS:()=>Qu,GCD:()=>Cf,GEOMEAN:()=>$u,GESTEP:()=>Sm,GROWTH:()=>ed,HARMEAN:()=>td,HEX2BIN:()=>Cm,HEX2DEC:()=>wm,HEX2OCT:()=>Tm,HLOOKUP:()=>Vl,HOUR:()=>Rp,HSTACK:()=>Zl,HYPGEOM:()=>nd,HYPGEOMDIST:()=>Dh,IF:()=>o_,IFERROR:()=>c_,IFNA:()=>l_,IFS:()=>s_,IMABS:()=>Em,IMAGINARY:()=>Dm,IMARGUMENT:()=>Om,IMCONJUGATE:()=>km,IMCOS:()=>Am,IMCOSH:()=>jm,IMCOT:()=>Mm,IMCSC:()=>Km,IMCSCH:()=>qm,IMDIV:()=>Nm,IMEXP:()=>Pm,IMLN:()=>Fm,IMLOG10:()=>Im,IMLOG2:()=>Lm,IMPOWER:()=>Rm,IMPRODUCT:()=>zm,IMREAL:()=>Bm,IMSEC:()=>Vm,IMSECH:()=>Hm,IMSIN:()=>Um,IMSINH:()=>Wm,IMSQRT:()=>Gm,IMSUB:()=>Jm,IMSUM:()=>Ym,IMTAN:()=>Xm,INDEX:()=>Hl,INT:()=>wf,INTERCEPT:()=>rd,IPMT:()=>Lg,IRR:()=>Rg,ISBLANK:()=>xl,ISERR:()=>Sl,ISERROR:()=>Cl,ISEVEN:()=>wl,ISLOGICAL:()=>Tl,ISNA:()=>El,ISNONTEXT:()=>Dl,ISNUMBER:()=>Ol,ISO:()=>Tf,ISODD:()=>kl,ISOWEEKNUM:()=>zp,ISPMT:()=>zg,ISTEXT:()=>Al,KURT:()=>id,LARGE:()=>ad,LCM:()=>Ef,LEFT:()=>cu,LEN:()=>lu,LINEST:()=>od,LN:()=>Df,LOG:()=>Of,LOG10:()=>kf,LOGEST:()=>sd,LOGINV:()=>Oh,LOGNORM:()=>cd,LOGNORMDIST:()=>kh,LOGNORMINV:()=>Ah,LOOKUP:()=>Ul,LOWER:()=>uu,MATCH:()=>Wl,MAX:()=>ld,MAXA:()=>ud,MAXIFS:()=>dd,MEDIAN:()=>fd,MID:()=>du,MIN:()=>pd,MINA:()=>md,MINIFS:()=>hd,MINUTE:()=>Bp,MIRR:()=>Bg,MMULT:()=>Af,MOD:()=>jf,MODE:()=>gd,MODEMULT:()=>jh,MODESNGL:()=>Mh,MONTH:()=>Vp,MROUND:()=>Mf,MULTINOMIAL:()=>Nf,MUNIT:()=>Pf,N:()=>jl,NA:()=>Ml,NEGBINOM:()=>_d,NEGBINOMDIST:()=>Nh,NETWORKDAYS:()=>Hp,NETWORKDAYSINTL:()=>Ph,NOMINAL:()=>Vg,NORM:()=>vd,NORMDIST:()=>Fh,NORMINV:()=>Ih,NORMSDIST:()=>Lh,NORMSINV:()=>Rh,NOT:()=>u_,NOW:()=>Up,NPER:()=>Hg,NPV:()=>Ug,NUMBERVALUE:()=>fu,OCT2BIN:()=>Zm,OCT2DEC:()=>Qm,OCT2HEX:()=>$m,ODD:()=>Ff,OR:()=>d_,PDURATION:()=>Wg,PEARSON:()=>yd,PERCENTILE:()=>bd,PERCENTILEEXC:()=>zh,PERCENTILEINC:()=>Bh,PERCENTRANK:()=>xd,PERCENTRANKEXC:()=>Vh,PERCENTRANKINC:()=>Hh,PERMUT:()=>Sd,PERMUTATIONA:()=>Cd,PHI:()=>wd,PI:()=>If,PMT:()=>Gg,POISSON:()=>Td,POISSONDIST:()=>Uh,POWER:()=>Lf,PPMT:()=>Kg,PRICEDISC:()=>qg,PROB:()=>Ed,PRODUCT:()=>Rf,PROPER:()=>pu,PV:()=>Jg,QUARTILE:()=>Dd,QUARTILEEXC:()=>Wh,QUARTILEINC:()=>Gh,QUOTIENT:()=>zf,RADIANS:()=>Bf,RAND:()=>Vf,RANDBETWEEN:()=>Hf,RANK:()=>Od,RANKAVG:()=>Kh,RANKEQ:()=>qh,RATE:()=>Yg,REPLACE:()=>mu,REPT:()=>hu,RIGHT:()=>gu,ROMAN:()=>Uf,ROUND:()=>Gf,ROUNDDOWN:()=>Kf,ROUNDUP:()=>qf,ROW:()=>kd,ROWS:()=>Gl,RRI:()=>Xg,RSQ:()=>Ad,SEARCH:()=>_u,SEC:()=>Jf,SECH:()=>Yf,SECOND:()=>Wp,SERIESSUM:()=>Xf,SIGN:()=>Zf,SIN:()=>Qf,SINH:()=>$f,SKEW:()=>jd,SKEWP:()=>Jh,SLN:()=>Zg,SLOPE:()=>Md,SMALL:()=>Nd,SORT:()=>Kl,SQRT:()=>ep,SQRTPI:()=>tp,STANDARDIZE:()=>Pd,STDEV:()=>Fd,STDEVA:()=>Id,STDEVP:()=>Yh,STDEVPA:()=>Ld,STDEVS:()=>Xh,STEYX:()=>Rd,SUBSTITUTE:()=>vu,SUBTOTAL:()=>np,SUM:()=>rp,SUMIF:()=>ip,SUMIFS:()=>ap,SUMPRODUCT:()=>op,SUMSQ:()=>sp,SUMX2MY2:()=>cp,SUMX2PY2:()=>lp,SUMXMY2:()=>up,SWITCH:()=>m_,SYD:()=>Qg,T:()=>yu,TAKE:()=>ql,TAN:()=>dp,TANH:()=>fp,TBILLEQ:()=>$g,TBILLPRICE:()=>e_,TBILLYIELD:()=>t_,TDIST:()=>Zh,TDISTRT:()=>Qh,TEXT:()=>bu,TEXTJOIN:()=>xu,TIME:()=>Gp,TIMEVALUE:()=>Kp,TINV:()=>$h,TODAY:()=>qp,TRANSPOSE:()=>Jl,TREND:()=>zd,TRIM:()=>Su,TRIMMEAN:()=>Bd,TRUE:()=>f_,TRUNC:()=>pp,TTEST:()=>eg,TYPE:()=>Nl,UNICHAR:()=>Cu,UNICODE:()=>wu,UNIQUE:()=>Yl,UPPER:()=>Tu,VALUE:()=>Eu,VAR:()=>Vd,VARA:()=>Hd,VARP:()=>tg,VARPA:()=>Ud,VARS:()=>ng,VLOOKUP:()=>Xl,VSTACK:()=>Ql,WEEKDAY:()=>Jp,WEEKNUM:()=>Yp,WEIBULL:()=>Wd,WEIBULLDIST:()=>rg,WORKDAY:()=>Xp,WORKDAYINTL:()=>ig,XIRR:()=>n_,XNPV:()=>r_,XOR:()=>p_,YEAR:()=>Zp,YEARFRAC:()=>em,Z:()=>Gd,ZTEST:()=>ag,utils:()=>h_}),V=/* @__PURE__ */ l(xc(),1),wc=/* @__PURE__ */ l(Sc(),1);let Tc=/* @__PURE__ */ Error(`#NULL!`),Ec=/* @__PURE__ */ Error(`#DIV/0!`),H=/* @__PURE__ */ Error(`#VALUE!`),Dc=/* @__PURE__ */ Error(`#REF!`),Oc=/* @__PURE__ */ Error(`#NAME?`),U=/* @__PURE__ */ Error(`#NUM!`),W=/* @__PURE__ */ Error(`#N/A`),kc=/* @__PURE__ */ Error(`#ERROR!`),Ac=/* @__PURE__ */ Error(`#GETTING_DATA`),jc=/* @__PURE__ */ Error(`#CALC!`);var Mc=/*#__PURE__*/ Object.freeze({__proto__:null,calc:jc,data:Ac,div0:Ec,error:kc,na:W,name:Oc,nil:Tc,num:U,ref:Dc,value:H});let Nc=!1;function Pc(){Nc=!0}function Fc(){Nc=!1}function Ic(e){e<60&&(e+=1);let t=Math.floor(e-25569)*86400,n=/* @__PURE__ */ 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 Lc(e){let t=new Date(1900,0,1),n=e>-22038912e5?2:1;return Math.ceil((e-t)/864e5)+n}var Rc=/*#__PURE__*/ Object.freeze({__proto__:null,dateToSerial:Lc,get returnSerial(){return Nc},serialToDate:Ic,useDate:Fc,useSerial:Pc});let zc=[`>`,`>=`,`<`,`<=`,`=`,`<>`],Bc=`operator`,Vc=`literal`,Hc=[Bc,Vc],Uc=Bc,Wc=Vc;function Gc(e,t){if(Hc.indexOf(t)===-1)throw Error(`Unsupported token type: `+t);return{value:e,type:t}}function Kc(e){return typeof e==`string`&&/^\d+(\.\d+)?$/.test(e)&&(e=e.indexOf(`.`)===-1?parseInt(e,10):parseFloat(e)),e}function qc(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 Jc(e){let t=``,n=[];for(let r=0;r<e.length;r++){let i=e[r];r===0&&zc.indexOf(i)>=0?n.push(Gc(i,Uc)):t+=i}return t.length>0&&n.push(Gc(Kc(t),Wc)),n.length>0&&n[0].type!==Uc&&n.unshift(Gc(`=`,Uc)),n}function Yc(e){let t=[],n;for(let r=0;r<e.length;r++){let i=e[r];switch(i.type){case Uc:n=i.value;break;case Wc:t.push(i.value)}}return Xc(t,n)}function Xc(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 Zc(e){return Jc(qc(e))}let Qc=Yc;function $c(e){let t=[];return el(e,e=>{t.push(e)}),t}function el(e,t){let n=-1,r=e.length;for(;++n<r&&t(e[n],n,e)!==!1;);return e}function tl(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=Y(n);e[t]=r instanceof Error?0:r}}return e}function nl(e){return[e.length,e.reduce((e,t)=>Math.max(e,t.length),0)]}function rl(e,t){let n=[e,t];return n.some(e=>!yl(e))?W:n.some(e=>e<=0)?H:Array.from({length:e},()=>Array.from({length:t},()=>void 0))}function il(e,t){if(!e)return H;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 G(){let e;if(arguments.length===1){let t=arguments[0];e=sl(t)?$c.apply(null,arguments):[t]}else e=Array.from(arguments);for(;!cl(e);)e=al(e);return e}function al(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 ol(e,t){return t||=1,!e||typeof e.slice!=`function`?e:e.slice(0,e.length-t)}function sl(e){return e!=null&&typeof e.length==`number`&&typeof e!=`string`}function cl(e){if(!e)return!1;for(let t=0;t<e.length;++t)if(Array.isArray(e[t]))return!1;return!0}function ll(e,t){return t||=1,!e||typeof e.slice!=`function`?e:e.slice(t)}function ul(e){return e?e[0].map((t,n)=>e.map(e=>e[n])):H}function dl(e,t){let n=null;return el(e,(e,r)=>{if(e[0]===t)return n=r,!1}),n??H}function K(){for(let e=0;e<arguments.length;e++)if(arguments[e]instanceof Error)return arguments[e]}function q(){let e=arguments.length;for(;e--;)if(arguments[e]instanceof Error)return!0;return!1}function fl(e){let t=0x5af3107a4000;return Math.round(e*t)/t}function pl(){return G.apply(null,arguments).filter(e=>typeof e==`number`)}function ml(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)||H}function J(e){if(!isNaN(e)){if(e instanceof Date)return new Date(e);let t=parseFloat(e);return t<0||t>=2958466?U:Ic(t)}return typeof e==`string`&&(e=/(\d{4})-(\d\d?)-(\d\d?)$/.test(e)?/* @__PURE__ */ new Date(e+`T00:00:00.000`):new Date(e),!isNaN(e))?e:H}function hl(e){let t=e.length,n;for(;t--;){if(n=J(e[t]),n===H)return n;e[t]=n}return e}function Y(e){return e instanceof Error?e:e==null?0:(typeof e==`boolean`&&(e=+e),!isNaN(e)&&e!==``?parseFloat(e):H)}function X(e){let t;if(!e||(t=e.length)===0)return H;let n;for(;t--;){if(e[t]instanceof Error)return e[t];if(n=Y(e[t]),n instanceof Error)return n;e[t]=n}return e}function gl(e){return e instanceof Error?e:e==null?``:e.toString()}function _l(){let e=arguments.length;for(;e--;)if(typeof arguments[e]==`string`)return!0;return!1}function vl(){let e=$c(arguments),t=X(G(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]=G(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=Zc(i+``),t=[Gc(r,Wc)].concat(e);s=Qc(t)}if(!s){a=!1;break}a=!0}a&&i.push(t[e])}return i}function yl(e){return e!=null}let bl={};bl.TYPE=e=>{switch(e){case Tc:return 1;case Ec:return 2;case H:return 3;case Dc:return 4;case Oc:return 5;case U:return 6;case W:return 7;case Ac:return 8}return W};function xl(e){return e===null}function Sl(e){return[H,Dc,Ec,U,Oc,Tc].indexOf(e)>=0||typeof e==`number`&&(isNaN(e)||!isFinite(e))}function Cl(e){return Sl(e)||e===W}function wl(e){return!(Math.floor(Math.abs(e))&1)}function Tl(e){return e===!0||e===!1}function El(e){return e===W}function Dl(e){return typeof e!=`string`}function Ol(e){return typeof e==`number`&&!isNaN(e)&&isFinite(e)}function kl(e){return!!(Math.floor(Math.abs(e))&1)}function Al(e){return typeof e==`string`}function jl(e){return Ol(e)?e:e instanceof Date?e.getTime():e===!0?1:e===!1?0:Cl(e)?e:0}function Ml(){return W}function Nl(e){if(Ol(e))return 1;if(Al(e))return 2;if(Tl(e))return 4;if(Cl(e))return 16;if(Array.isArray(e))return 64}function Pl(){if(arguments.length<2)return W;let e=arguments[0];return e<1||e>254||arguments.length<e+1?H:arguments[e]}function Fl(e,t,...n){if(!Array.isArray(e))return H;let r=G([t,...n]),[i,a]=nl(e);if(r.some(e=>{if(!yl(e))return!0;let t=Math.abs(e);return!(0<t&&t<=a)}))return H;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 Il(e,t,...n){if(!Array.isArray(e))return H;let r=G([t,...n]);return r.some(t=>{if(!yl(t))return!0;let n=Math.abs(t);return!(0<n&&n<=e.length)})?H:r.map(t=>t<0?t+e.length+1:t).reduce((t,n)=>{let r=[...e[--n]].map(e=>yl(e)?e:0);return t.push(r),t},[])}function Ll(e,t){if(arguments.length!==2)return W;if(t<0)return U;if(!(e instanceof Array)||typeof t!=`number`)return H;if(e.length!==0)return V.default.col(e,t)}function Rl(e){return arguments.length===1?e instanceof Array?e.length===0?0:V.default.cols(e):H:W}function zl(e,t,n){if(q(e,t,n))return K(e,t,n);if(!(e instanceof Array))return H;let r=[],[i,a]=nl(e),o=0,s=i;if(typeof t==`number`){if(Math.abs(t)>i)return jc;t>0?o=t:t<0&&(s+=t)}let c=0,l=a;if(typeof n==`number`){if(Math.abs(n)>a)return jc;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 Bl(e,t,n,r){let[i,a]=nl(e);if(yl(t)||(t=i),yl(n)||(n=a),t<i||n<a)return H;let o=rl(t,n);for(let s=0;s<t;s++)for(let t=0;t<n;t++){let n=e[s]?.[t];yl(n)||(n=s<i&&t<a?0:r??W),o[s][t]=n}return o}function Vl(e,t,n,r){return Xl(e,ul(t),n,r)}function Hl(e,t,n){let r=K(e,t,n);if(r)return r;if(!Array.isArray(e))return H;let i=e.length>0&&!Array.isArray(e[0]);return i&&!n?(n=t,t=1):(n||=1,t||=1),n<0||t<0?H:i&&t===1&&n<=e.length?e[n-1]:t<=e.length&&n<=e[t-1].length?e[t-1][n-1]:Dc}function Ul(e,t,n){t=G(t),n=n?G(n):t;let r=typeof e==`number`,i=W;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 Wl(e,t,n){if(!e&&e!==0||!t||(arguments.length===2&&(n=1),t=G(t),!(t instanceof Array))||n!==-1&&n!==0&&n!==1)return W;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||W}function Gl(e){return arguments.length===1?e instanceof Array?e.length===0?0:V.default.rows(e):H:W}function Kl(e,t=1,n=1,r=!1){if(!e||!Array.isArray(e))return W;if(e.length===0)return 0;if(t=Y(t),!t||t<1||(n=Y(n),n!==1&&n!==-1))return H;if(r=ml(r),typeof r!=`boolean`)return Oc;let i=e=>e.sort((e,r)=>(e=gl(e[t-1]),r=gl(r[t-1]),n===1?e<r?n*-1:n:e>r?n:n*-1)),a=il(e),o=r?ul(a):a;return t>=1&&t<=o[0].length?r?ul(i(o)):i(o):H}function ql(e,t,n){if(q(e,t,n))return K(e,t,n);if(!(e instanceof Array))return H;let[r,i]=nl(e),a=0,o=r-1;if(typeof t==`number`){if(t===0)return jc;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 jc;Math.abs(n)<=i&&(n<0?s=i+n:c=n-1)}let l=rl(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 Jl(e){return e?ul(il(e)):W}function Yl(){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 Xl(e,t,n,r){if(!t||!n)return W;r=r!==0&&r!==!1;let i=W,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]:Dc;break}!a&&(o&&r&&u<=e||r&&typeof u==`string`&&u.localeCompare(e)<0)&&(i=n<l.length+1?l[n-1]:Dc),o&&u>e&&(a=!0)}return i}function Zl(e,...t){let n=[e,...t],r=0,i=0,a=[];for(let e of n){let[t,n]=nl(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:W);s++}}return o}function Ql(e,...t){let n=[e,...t],r=0,i=0;for(let e of n){let[t,n]=nl(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:W)}return a}function $l(e){return e=Y(e),e===0?H:e instanceof Error?e:String.fromCharCode(e)}function eu(e){return q(e)?e:(e||=``,e.replace(/[\0-\x1F]/g,``))}function tu(e){if(q(e))return e;e||=``;let t=e.charCodeAt(0);return isNaN(t)&&(t=H),t}function nu(){let e=G(arguments),t=K.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(``)}let ru=nu;function iu(e,t=2){if(e=Y(e),isNaN(e))return H;e=Gf(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 au(e,t){return arguments.length===2?K(e,t)||(e=gl(e),t=gl(t),e===t):W}function ou(e,t,n){if(arguments.length<2)return W;e=gl(e),t=gl(t),n=n===void 0?0:n;let r=t.indexOf(e,n-1);return r===-1?H:r+1}function su(e,t=2,n=!1){if(e=Y(e),isNaN(e)||(t=Y(t),isNaN(t)))return H;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 cu(e,t){return K(e,t)||(e=gl(e),t=t===void 0?1:t,t=Y(t),t instanceof Error||typeof e!=`string`?H:e.substring(0,t))}function lu(e){return arguments.length===0?kc:e instanceof Error?e:Array.isArray(e)?H:gl(e).length}function uu(e){return arguments.length===1?(e=gl(e),q(e)?e:e.toLowerCase()):H}function du(e,t,n){if(q(e,t,n))return K(e,t,n);let r=[t,n].map(e=>Y(e));if(!r.every(e=>!(e instanceof Error)&&e>0))return H;yl(e)?typeof e!=`string`&&(e=String(e)):e=``,[t,n]=r;let i=t-1,a=i+n;return e.substring(i,a)}function fu(e,t,n){return e=yl(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,``))):W}function pu(e){return q(e)?e:isNaN(e)&&typeof e==`number`?H:(e=gl(e),e.replace(/\w\S*/g,e=>e.charAt(0).toUpperCase()+e.substr(1).toLowerCase()))}function mu(e,t,n,r){return t=Y(t),n=Y(n),q(t,n)||typeof e!=`string`||typeof r!=`string`?H:e.substr(0,t-1)+r+e.substr(t-1+n)}function hu(e,t){return K(e,t)||(e=gl(e),t=Y(t),t instanceof Error?t:Array(t+1).join(e))}function gu(e,t){return K(e,t)||(e=gl(e),t=t===void 0?1:t,t=Y(t),t instanceof Error?t:e.substring(e.length-t))}function _u(e,t,n){let r;return typeof e!=`string`||typeof t!=`string`?H:(n=n===void 0?0:n,r=t.toLowerCase().indexOf(e.toLowerCase(),n-1)+1,r===0?H:r)}function vu(e,t,n,r){if(arguments.length<3)return W;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 H;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 yu(e){return e instanceof Error||typeof e==`string`?e:``}function bu(e,t){if(e===void 0||e instanceof Error||t instanceof Error)return W;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 H;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=su(e,i,a),e.startsWith(`-`)?(e=e.replace(`-`,``),e=`-`+n+e):e=n+e,r&&(e+=`%`),e}function xu(e,t,...n){if(typeof t!=`boolean`&&(t=ml(t)),arguments.length<3)return W;e??=``;let r=G(n),i=t?r.filter(e=>e):r;if(Array.isArray(e)){e=G(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=G(t),i.join(``)}return i.join(e)}function Su(e){return e=gl(e),e instanceof Error?e:e.replace(/\s+/g,` `).trim()}let Cu=$l,wu=tu;function Tu(e){return e=gl(e),e instanceof Error?e:e.toUpperCase()}function Eu(e){let t=K(e);if(t)return t;if(typeof e==`number`)return e;if(yl(e)||(e=``),typeof e!=`string`)return H;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)?H:(r||=0,n&&(r*=.01),r)}function Du(){let e=G(arguments).filter(yl);if(e.length===0)return U;let t=X(e);return t instanceof Error?t:V.default.sum((0,V.default)(t).subtract(V.default.mean(t)).abs()[0])/t.length}function Ou(){let e=G(arguments).filter(yl);if(e.length===0)return Ec;let t=K.apply(void 0,e);if(t)return t;let n=pl(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=U),o}function ku(){let e=G(arguments).filter(yl);if(e.length===0)return Ec;let t=K.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=U),o}function Au(e,t,n){if(arguments.length<=1)return W;if(n||=e,n=X(G(n).filter(yl)),e=G(e),n instanceof Error)return n;let r=0,i=0,a=t===void 0||t===`*`,o=a?null:Zc(t+``);for(let t=0;t<e.length;t++){let s=e[t];if(a)i+=n[t],r++;else{let e=[Gc(s,Wc)].concat(o);Qc(e)&&(i+=n[t],r++)}}return i/r}function ju(){let e=vl(...arguments),t=e.reduce((e,t)=>e+t,0)/e.length;return isNaN(t)?0:t}let Mu={};Mu.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=Y(e),t=Y(t),n=Y(n),i=Y(i),a=Y(a),q(e,t,n,i,a))?H:(e=(e-i)/(a-i),r?V.default.beta.cdf(e,t,n):V.default.beta.pdf(e,t,n))},Mu.INV=(e,t,n,r,i)=>(r=r===void 0?0:r,i=i===void 0?1:i,e=Y(e),t=Y(t),n=Y(n),r=Y(r),i=Y(i),q(e,t,n,r,i)?H:V.default.beta.inv(e,t,n)*(i-r)+r);let Nu={};Nu.DIST=(e,t,n,r)=>(e=Y(e),t=Y(t),n=Y(n),r=Y(r),q(e,t,n,r)?H:r?V.default.binomial.cdf(e,t,n):V.default.binomial.pdf(e,t,n)),Nu.DIST.RANGE=(e,t,n,r)=>{if(r=r===void 0?n:r,e=Y(e),t=Y(t),n=Y(n),r=Y(r),q(e,t,n,r))return H;let i=0;for(let a=n;a<=r;a++)i+=sf(e,a)*t**+a*(1-t)**(e-a);return i},Nu.INV=(e,t,n)=>{if(e=Y(e),t=Y(t),n=Y(n),q(e,t,n))return H;let r=0;for(;r<=e;){if(V.default.binomial.cdf(r,e,t)>=n)return r;r++}};let Pu={};Pu.DIST=(e,t,n)=>(e=Y(e),t=Y(t),q(e,t)?H:n?V.default.chisquare.cdf(e,t):V.default.chisquare.pdf(e,t)),Pu.DIST.RT=(e,t)=>!e|!t?W:e<1||t>10**10?U:typeof e!=`number`||typeof t!=`number`?H:1-V.default.chisquare.cdf(e,t),Pu.INV=(e,t)=>(e=Y(e),t=Y(t),q(e,t)?H:V.default.chisquare.inv(e,t)),Pu.INV.RT=(e,t)=>!e|!t?W:e<0||e>1||t<1||t>10**10?U:typeof e!=`number`||typeof t!=`number`?H:V.default.chisquare.inv(1-e,t),Pu.TEST=function(e,t){if(arguments.length!==2)return W;if(!(e instanceof Array)||!(t instanceof Array)||e.length!==t.length||e[0]&&t[0]&&e[0].length!==t[0].length)return H;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};let Fu={};Fu.NORM=(e,t,n)=>(e=Y(e),t=Y(t),n=Y(n),q(e,t,n)?H:V.default.normalci(1,e,t,n)[1]-1),Fu.T=(e,t,n)=>(e=Y(e),t=Y(t),n=Y(n),q(e,t,n)?H:V.default.tci(1,e,t,n)[1]-1);function Iu(e,t){return e=X(G(e)),t=X(G(t)),q(e,t)?H:V.default.corrcoeff(e,t)}function Lu(){return pl(G(arguments)).length}function Ru(){let e=G(arguments);return e.length-zu(e)}function zu(){let e=G(arguments),t=0,n;for(let r=0;r<e.length;r++)n=e[r],(n==null||n===``)&&t++;return t}function Bu(e,t){if(e=G(e),t===void 0||t===`*`)return e.length;let n=0,r=Zc(t+``);for(let t=0;t<e.length;t++){let i=e[t],a=[Gc(i,Wc)].concat(r);Qc(a)&&n++}return n}function Vu(){let e=$c(arguments),t=Array(G(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=G(e[n]),i=e[n+1];if(i!==void 0&&i!==`*`){let e=Zc(i+``);for(let n=0;n<r.length;n++){let i=r[n],a=[Gc(i,Wc)].concat(e);t[n]=t[n]&&Qc(a)}}}let n=0;for(let e=0;e<t.length;e++)t[e]&&n++;return n}let Hu={};Hu.P=(e,t)=>{if(e=X(G(e)),t=X(G(t)),q(e,t))return H;let n=V.default.mean(e),r=V.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},Hu.S=(e,t)=>(e=X(G(e)),t=X(G(t)),q(e,t)?H:V.default.covariance(e,t));function Uu(){let e=X(G(arguments));if(e instanceof Error)return e;let t=V.default.mean(e),n=0;for(let r=0;r<e.length;r++)n+=(e[r]-t)**2;return n}let Wu={};Wu.DIST=(e,t,n)=>(e=Y(e),t=Y(t),q(e,t)?H:n?V.default.exponential.cdf(e,t):V.default.exponential.pdf(e,t));let Gu={};Gu.DIST=(e,t,n,r)=>(e=Y(e),t=Y(t),n=Y(n),q(e,t,n)?H:r?V.default.centralF.cdf(e,t,n):V.default.centralF.pdf(e,t,n)),Gu.DIST.RT=function(e,t,n){return arguments.length===3?e<0||t<1||n<1?U:typeof e!=`number`||typeof t!=`number`||typeof n!=`number`?H:1-V.default.centralF.cdf(e,t,n):W},Gu.INV=(e,t,n)=>(e=Y(e),t=Y(t),n=Y(n),q(e,t,n)?H:e<=0||e>1?U:V.default.centralF.inv(e,t,n)),Gu.INV.RT=function(e,t,n){return arguments.length===3?e<0||e>1||t<1||t>10**10||n<1||n>10**10?U:typeof e!=`number`||typeof t!=`number`||typeof n!=`number`?H:V.default.centralF.inv(1-e,t,n):W},Gu.TEST=(e,t)=>{if(!e||!t||!(e instanceof Array)||!(t instanceof Array))return W;if(e.length<2||t.length<2)return Ec;let n=(e,t)=>{let n=0;for(let r=0;r<e.length;r++)n+=(e[r]-t)**2;return n},r=rp(e)/e.length,i=rp(t)/t.length;return n(e,r)/(e.length-1)/(n(t,i)/(t.length-1))};function Ku(e){return e=Y(e),e instanceof Error?e:Math.log((1+e)/(1-e))/2}function qu(e){if(e=Y(e),e instanceof Error)return e;let t=Math.exp(2*e);return(t-1)/(t+1)}function Ju(e,t,n){if(e=Y(e),t=X(G(t)),n=X(G(n)),q(e,t,n))return H;let r=V.default.mean(n),i=V.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 Yu(e,t){if(e=X(G(e)),t=X(G(t)),q(e,t))return H;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 Xu(e){return e=Y(e),e instanceof Error?e:e===0||parseInt(e,10)===e&&e<0?U:V.default.gammafn(e)}Xu.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`?H:r?V.default.gamma.cdf(e,t,n,!0):V.default.gamma.pdf(e,t,n,!1):W},Xu.INV=function(e,t,n){return arguments.length===3?e<0||e>1||t<=0||n<=0?U:typeof e!=`number`||typeof t!=`number`||typeof n!=`number`?H:V.default.gamma.inv(e,t,n):W};function Zu(e){return e=Y(e),e instanceof Error?e:V.default.gammaln(e)}Zu.PRECISE=function(e){return arguments.length===1?e<=0?U:typeof e==`number`?V.default.gammaln(e):H:W};function Qu(e){return e=Y(e),e instanceof Error?e:V.default.normal.cdf(e,0,1)-.5}function $u(){let e=X(G(arguments));return e instanceof Error?e:V.default.geomean(e)}function ed(e,t,n,r){if(e=X(G(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=X(G(t)),n=X(G(n)),q(t,n))return H;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 td(){let e=X(G(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}let nd={};nd.DIST=(e,t,n,r,i)=>{if(e=Y(e),t=Y(t),n=Y(n),r=Y(r),q(e,t,n,r))return H;function a(e,t,n,r){return sf(n,e)*sf(r-n,t-e)/sf(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 rd(e,t){return e=X(e),t=X(t),q(e,t)?H:e.length===t.length?Ju(0,e,t):W}function id(){let e=X(G(arguments));if(e instanceof Error)return e;let t=V.default.mean(e),n=e.length,r=0;for(let i=0;i<n;i++)r+=(e[i]-t)**4;return r/=V.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 ad(e,t){return K.apply(void 0,e)||(q(t)?t:(e=pl(G(e)),t=Y(t),t<0||e.length<t?H:e.sort((e,t)=>t-e)[t-1]))}function od(e,t){if(e=X(G(e)),t=X(G(t)),q(e,t))return H;let n=V.default.mean(e),r=V.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 sd(e,t){if(e=X(G(e)),t=X(G(t)),q(e,t)||e.length!==t.length)return H;for(let t=0;t<e.length;t++)e[t]=Math.log(e[t]);let n=od(e,t);return n[0]=Math.round(Math.exp(n[0])*1e6)/1e6,n[1]=Math.round(Math.exp(n[1])*1e6)/1e6,n}let cd={};cd.DIST=(e,t,n,r)=>(e=Y(e),t=Y(t),n=Y(n),q(e,t,n)?H:r?V.default.lognormal.cdf(e,t,n):V.default.lognormal.pdf(e,t,n)),cd.INV=(e,t,n)=>(e=Y(e),t=Y(t),n=Y(n),q(e,t,n)?H:V.default.lognormal.inv(e,t,n));function ld(){let e=G(arguments),t=K.apply(void 0,e);if(t)return t;let n=pl(e);return n.length===0?0:Math.max.apply(Math,n)}function ud(){let e=G(arguments),t=K.apply(void 0,e);if(t)return t;let n=tl(e);return n=n.map(e=>e??0),n.length===0?0:Math.max.apply(Math,n)}function dd(){let e=vl(...arguments);return e.length===0?0:Math.max.apply(Math,e)}function fd(){let e=G(arguments),t=K.apply(void 0,e);if(t)return t;let n=tl(e),r=V.default.median(n);return isNaN(r)&&(r=U),r}function pd(){let e=G(arguments),t=K.apply(void 0,e);if(t)return t;let n=pl(e);return n.length===0?0:Math.min.apply(Math,n)}function md(){let e=G(arguments),t=K.apply(void 0,e);if(t)return t;let n=tl(e);return n=n.map(e=>e??0),n.length===0?0:Math.min.apply(Math,n)}function hd(){let e=vl(...arguments);return e.length===0?0:Math.min.apply(Math,e)}let gd={};gd.MULT=function(){let e=X(G(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},gd.SNGL=function(){let e=X(G(arguments));return e instanceof Error?e:gd.MULT(e).sort((e,t)=>e-t)[0]};let _d={};_d.DIST=(e,t,n,r)=>(e=Y(e),t=Y(t),n=Y(n),q(e,t,n)?H:r?V.default.negbin.cdf(e,t,n):V.default.negbin.pdf(e,t,n));let vd={};vd.DIST=(e,t,n,r)=>(e=Y(e),t=Y(t),n=Y(n),q(e,t,n)?H:n<=0?U:r?V.default.normal.cdf(e,t,n):V.default.normal.pdf(e,t,n)),vd.INV=(e,t,n)=>(e=Y(e),t=Y(t),n=Y(n),q(e,t,n)?H:V.default.normal.inv(e,t,n)),vd.S={},vd.S.DIST=(e,t)=>(e=Y(e),e instanceof Error?H:t?V.default.normal.cdf(e,0,1):V.default.normal.pdf(e,0,1)),vd.S.INV=e=>(e=Y(e),e instanceof Error?H:V.default.normal.inv(e,0,1));function yd(e,t){if(t=X(G(t)),e=X(G(e)),q(t,e))return H;let n=V.default.mean(e),r=V.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)}let bd={};bd.EXC=(e,t)=>{if(e=X(G(e)),t=Y(t),q(e,t))return H;e=e.sort((e,t)=>e-t);let n=e.length;if(t<1/(n+1)||t>1-1/(n+1))return U;let r=t*(n+1)-1,i=Math.floor(r);return fl(r===i?e[r]:e[i]+(r-i)*(e[i+1]-e[i]))},bd.INC=(e,t)=>{if(e=X(G(e)),t=Y(t),q(e,t))return H;e=e.sort((e,t)=>e-t);let n=e.length,r=t*(n-1),i=Math.floor(r);return fl(r===i?e[r]:e[i]+(r-i)*(e[i+1]-e[i]))};let xd={};xd.EXC=(e,t,n)=>{if(n=n===void 0?3:n,e=X(G(e)),t=Y(t),n=Y(n),q(e,t,n))return H;e=e.sort((e,t)=>e-t);let r=Yl.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},xd.INC=(e,t,n)=>{if(n=n===void 0?3:n,e=X(G(e)),t=Y(t),n=Y(n),q(e,t,n))return H;e=e.sort((e,t)=>e-t);let r=Yl.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 Sd(e,t){return e=Y(e),t=Y(t),q(e,t)?H:bf(e)/bf(e-t)}function Cd(e,t){return e=Y(e),t=Y(t),q(e,t)?H:e**+t}function wd(e){return e=Y(e),e instanceof Error?H:Math.exp(-.5*e*e)/2.5066282746310002}let Td={};Td.DIST=(e,t,n)=>(e=Y(e),t=Y(t),q(e,t)?H:n?V.default.poisson.cdf(e,t):V.default.poisson.pdf(e,t));function Ed(e,t,n,r){if(n===void 0)return 0;if(r=r===void 0?n:r,e=X(G(e)),t=X(G(t)),n=Y(n),r=Y(r),q(e,t,n,r))return H;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}let Dd={};Dd.EXC=(e,t)=>{if(e=X(pl(G(e))),t=Y(t),q(e,t))return H;switch(t){case 1:return bd.EXC(e,.25);case 2:return bd.EXC(e,.5);case 3:return bd.EXC(e,.75);default:return U}},Dd.INC=(e,t)=>{if(e=X(pl(G(e))),t=Y(t),q(e,t))return H;switch(t){case 1:return bd.INC(e,.25);case 2:return bd.INC(e,.5);case 3:return bd.INC(e,.75);default:return U}};let Od={};Od.AVG=(e,t,n)=>{if(e=Y(e),t=X(G(t)),q(e,t))return H;t=G(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},Od.EQ=(e,t,n)=>{if(e=Y(e),t=X(G(t)),q(e,t))return H;n||=!1;let r=n?(e,t)=>e-t:(e,t)=>t-e;return t=t.sort(r),t.indexOf(e)+1};function kd(e,t){if(arguments.length!==2)return W;if(t<0)return U;if(!(e instanceof Array)||typeof t!=`number`)return H;if(e.length!==0)return V.default.row(e,t)}function Ad(e,t){return e=X(G(e)),t=X(G(t)),q(e,t)?H:yd(e,t)**2}function jd(){let e=X(G(arguments));if(e instanceof Error)return e;let t=V.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)*V.default.stdev(e,!0)**3)}jd.P=function(){let e=X(G(arguments));if(e instanceof Error)return e;let t=V.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 Md(e,t){if(e=X(G(e)),t=X(G(t)),q(e,t))return H;let n=V.default.mean(t),r=V.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 Nd(e,t){return e=X(G(e)),t=Y(t),q(e,t)?e:e.sort((e,t)=>e-t)[t-1]}function Pd(e,t,n){return e=Y(e),t=Y(t),n=Y(n),q(e,t,n)?H:(e-t)/n}let Fd={};Fd.P=function(){let e=Vd.P.apply(this,arguments),t=Math.sqrt(e);return isNaN(t)&&(t=U),t},Fd.S=function(){let e=Vd.S.apply(this,arguments);return Math.sqrt(e)};function Id(){let e=Hd.apply(this,arguments);return Math.sqrt(e)}function Ld(){let e=Ud.apply(this,arguments),t=Math.sqrt(e);return isNaN(t)&&(t=U),t}function Rd(e,t){if(e=X(G(e)),t=X(G(t)),q(e,t))return H;let n=V.default.mean(t),r=V.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))}yu.DIST=(e,t,n)=>n!==1&&n!==2?U:n===1?yu.DIST.RT(e,t):yu.DIST[`2T`](e,t),yu.DIST[`2T`]=function(e,t){return arguments.length===2?e<0||t<1?U:typeof e!=`number`||typeof t!=`number`?H:(1-V.default.studentt.cdf(e,t))*2:W},yu.DIST.RT=function(e,t){return arguments.length===2?e<0||t<1?U:typeof e!=`number`||typeof t!=`number`?H:1-V.default.studentt.cdf(e,t):W},yu.INV=(e,t)=>(e=Y(e),t=Y(t),q(e,t)?H:V.default.studentt.inv(e,t)),yu.INV[`2T`]=(e,t)=>(e=Y(e),t=Y(t),e<=0||e>1||t<1?U:q(e,t)?H:Math.abs(V.default.studentt.inv(e/2,t))),yu.TEST=(e,t)=>{if(e=X(G(e)),t=X(G(t)),q(e,t))return H;let n=V.default.mean(e),r=V.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 yu.DIST[`2T`](s,e.length+t.length-2)};function zd(e,t,n){if(e=X(G(e)),t=X(G(t)),n=X(G(n)),q(e,t,n))return H;let r=od(e,t),i=r[0],a=r[1],o=[];return n.forEach(e=>{o.push(i*e+a)}),o}function Bd(e,t){if(e=X(G(e)),t=Y(t),q(e,t))return H;let n=Sf(e.length*t,2)/2;return V.default.mean(ol(ll(e.sort((e,t)=>e-t),n),n))}let Vd={};Vd.P=function(){let e=pl(G(arguments)),t=e.length,n=0,r=Ou(e),i;for(let i=0;i<t;i++)n+=(e[i]-r)**2;return i=n/t,isNaN(i)&&(i=U),i},Vd.S=function(){let e=pl(G(arguments)),t=e.length,n=0,r=Ou(e);for(let i=0;i<t;i++)n+=(e[i]-r)**2;return n/(t-1)};function Hd(){let e=G(arguments),t=e.length,n=0,r=0,i=ku(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 Ud(){let e=G(arguments),t=e.length,n=0,r=0,i=ku(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=U),a}let Wd={};Wd.DIST=(e,t,n,r)=>(e=Y(e),t=Y(t),n=Y(n),q(e,t,n)?H:r?1-Math.exp(-((e/n)**+t)):e**(t-1)*Math.exp(-((e/n)**+t))*t/n**+t);let Gd={};Gd.TEST=(e,t,n)=>{if(e=X(G(e)),t=Y(t),q(e,t))return H;n||=Fd.S(e);let r=e.length;return 1-vd.S.DIST((Ou(e)-t)/(n/Math.sqrt(r)),!0)};function Kd(e){return e=Y(e),e instanceof Error?e:Math.abs(e)}function qd(e){if(e=Y(e),e instanceof Error)return e;let t=Math.acos(e);return isNaN(t)&&(t=U),t}function Jd(e){if(e=Y(e),e instanceof Error)return e;let t=Math.log(e+Math.sqrt(e*e-1));return isNaN(t)&&(t=U),t}function Yd(e){return e=Y(e),e instanceof Error?e:Math.atan(1/e)}function Xd(e){if(e=Y(e),e instanceof Error)return e;let t=.5*Math.log((e+1)/(e-1));return isNaN(t)&&(t=U),t}function Zd(e,t,n,r){if(e=Y(e),t=Y(e),q(e,t))return H;switch(e){case 1:return Ou(n);case 2:return Lu(n);case 3:return Ru(n);case 4:return ld(n);case 5:return pd(n);case 6:return Rf(n);case 7:return Fd.S(n);case 8:return Fd.P(n);case 9:return rp(n);case 10:return Vd.S(n);case 11:return Vd.P(n);case 12:return fd(n);case 13:return gd.SNGL(n);case 14:return ad(n,r);case 15:return Nd(n,r);case 16:return bd.INC(n,r);case 17:return Dd.INC(n,r);case 18:return bd.EXC(n,r);case 19:return Dd.EXC(n,r)}}function Qd(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 H;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 $d(e){if(e=Y(e),e instanceof Error)return e;let t=Math.asin(e);return isNaN(t)&&(t=U),t}function ef(e){return e=Y(e),e instanceof Error?e:Math.log(e+Math.sqrt(e*e+1))}function tf(e){return e=Y(e),e instanceof Error?e:Math.atan(e)}function nf(e,t){return e=Y(e),t=Y(t),K(e,t)||Math.atan2(e,t)}function rf(e){if(e=Y(e),e instanceof Error)return e;let t=Math.log((1+e)/(1-e))/2;return isNaN(t)&&(t=U),t}function af(e,t,n){e=Y(e),t=Y(t),n=Y(n);let r=K(e,t,n);if(r)return r;if(t===0)return U;let i=e.toString(t);return Array(Math.max(n+1-i.length,0)).join(`0`)+i}function of(e,t){return e=Y(e),t=Y(t),K(e,t)||(t===0?0:e>0&&t<0?U:Math.ceil(e/t)*t)}of.MATH=(e,t,n=0)=>(t===void 0&&(t=e>0?1:-1),e=Y(e),t=Y(t),n=Y(n),K(e,t,n)||(t===0?0:(t=Math.abs(t),n===0||e>0?Math.ceil(e/t)*t:Math.floor(e/t)*t))),of.PRECISE=(e,t)=>of.MATH(e,t);function sf(e,t){return e=Y(e),t=Y(t),K(e,t)||(e<t?U:bf(e)/(bf(t)*bf(e-t)))}function cf(e,t){return e=Y(e),t=Y(t),K(e,t)||(e<t?U:e===0&&t===0?1:sf(e+t-1,e-1))}function lf(e){return e=Y(e),e instanceof Error?e:Math.cos(e)}function uf(e){return e=Y(e),e instanceof Error?e:(Math.exp(e)+Math.exp(-e))/2}function df(e){return e=Y(e),e instanceof Error?e:e===0?Ec:1/Math.tan(e)}function ff(e){if(e=Y(e),e instanceof Error)return e;if(e===0)return Ec;let t=Math.exp(2*e);return(t+1)/(t-1)}function pf(e){return e=Y(e),e instanceof Error?e:e===0?Ec:1/Math.sin(e)}function mf(e){return e=Y(e),e instanceof Error?e:e===0?Ec:2/(Math.exp(e)-Math.exp(-e))}function hf(e,t){if(arguments.length<2)return W;e||=`0`,t=Y(t);let n=K(e,t);if(n)return n;if(t===0)return U;let r=parseInt(e,t);return isNaN(r)?U:r}function gf(e){return e=Y(e),e instanceof Error?e:e*180/Math.PI}function _f(e){return e=Y(e),e instanceof Error?e:of.MATH(e,-2,-1)}function vf(e){return arguments.length<1?W:arguments.length>1?kc:(e=Y(e),e instanceof Error||(e=Math.exp(e)),e)}let yf=[];function bf(e){if(e=Y(e),e instanceof Error)return e;let t=Math.floor(e);return t===0||t===1?1:(yf[t]>0||(yf[t]=bf(t-1)*t),yf[t])}function xf(e){if(e=Y(e),e instanceof Error)return e;let t=Math.floor(e);return t<=0?1:t*xf(t-2)}function Sf(e,t){return e=Y(e),t=Y(t),K(e,t)||(t?e>0&&t<0?U:Math.floor(e/t)*t:Ec)}Sf.MATH=(e,t=1,n=0)=>(e=Y(e),t=Y(t),n=Y(n),K(e,t,n)||(t===0?0:(t=Math.abs(t),n===0||e>0?Math.floor(e/t)*t:Math.ceil(e/t)*t))),Sf.PRECISE=(e,t)=>Sf.MATH(e,t);function Cf(){let e=X(G(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 wf(e){return e=Y(e),e instanceof Error?e:Math.floor(e)}let Tf={CEILING:of};function Ef(){let e=X(G(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 Df(e){return e=Y(e),e instanceof Error?e:e===0?U:Math.log(e)}function Of(e,t){return e=Y(e),t=t?Y(t):10,K(e,t)||(e===0||t===0?U:Math.log(e)/Math.log(t))}function kf(e){return e=Y(e),e instanceof Error?e:e===0?U:Math.log(e)/Math.log(10)}function Af(e,t){return!Array.isArray(e)||!Array.isArray(t)||e.some(e=>!e.length)||t.some(e=>!e.length)||al(e).some(e=>typeof e!=`number`)||al(t).some(e=>typeof e!=`number`)||e[0].length!==t.length?H: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 jf(e,t){e=Y(e),t=Y(t);let n=K(e,t);if(n)return n;if(t===0)return Ec;let r=Math.abs(e%t);return r=e<0?t-r:r,t>0?r:-r}function Mf(e,t){return e=Y(e),t=Y(t),K(e,t)||(e*t===0?0:e*t<0?U:Math.round(e/t)*t)}function Nf(){let e=X(G(arguments));if(e instanceof Error)return e;let t=0,n=1;for(let r=0;r<e.length;r++)t+=e[r],n*=bf(e[r]);return bf(t)/n}function Pf(e){return arguments.length>1?W:(e=parseInt(e),!e||e<=0?H:Array(e).fill(0).map(()=>Array(e).fill(0)).map((e,t)=>(e[t]=1,e)))}function Ff(e){if(e=Y(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 If(){return Math.PI}function Lf(e,t){e=Y(e),t=Y(t);let n=K(e,t);if(n)return n;if(e===0&&t===0)return U;let r=e**+t;return isNaN(r)?U:r}function Rf(){let e=G(arguments).filter(e=>e!=null);if(e.length===0)return 0;let t=X(e);if(t instanceof Error)return t;let n=1;for(let e=0;e<t.length;e++)n*=t[e];return n}function zf(e,t){return e=Y(e),t=Y(t),K(e,t)||parseInt(e/t,10)}function Bf(e){return e=Y(e),e instanceof Error?e:e*Math.PI/180}function Vf(){return Math.random()}function Hf(e,t){return e=Y(e),t=Y(t),K(e,t)||e+Math.ceil((t-e+1)*Math.random())-1}function Uf(e){if(e=Y(e),e instanceof Error)return e;let t=String(e).split(``),n=/* @__PURE__ */ `.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 Wf(e,t,n){e=Y(e),t=Y(t);let r=K(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 Gf(e,t){return Wf(e,t,Math.round)}function Kf(e,t){return Wf(e,t,Math.floor)}function qf(e,t){return Wf(e,t,Math.ceil)}function Jf(e){return e=Y(e),e instanceof Error?e:1/Math.cos(e)}function Yf(e){return e=Y(e),e instanceof Error?e:2/(Math.exp(e)+Math.exp(-e))}function Xf(e,t,n,r){if(e=Y(e),t=Y(t),n=Y(n),r=X(r),q(e,t,n,r))return H;let i=r[0]*e**+t;for(let a=1;a<r.length;a++)i+=r[a]*e**+(t+a*n);return i}function Zf(e){return e=Y(e),e instanceof Error?e:e<0?-1:e===0?0:1}function Qf(e){return e=Y(e),e instanceof Error?e:Math.sin(e)}function $f(e){return e=Y(e),e instanceof Error?e:(Math.exp(e)-Math.exp(-e))/2}function ep(e){return e=Y(e),e instanceof Error?e:e<0?U:Math.sqrt(e)}function tp(e){return e=Y(e),e instanceof Error?e:Math.sqrt(e*Math.PI)}function np(e,t){if(e=Y(e),e instanceof Error)return e;switch(e){case 1:return Ou(t);case 2:return Lu(t);case 3:return Ru(t);case 4:return ld(t);case 5:return pd(t);case 6:return Rf(t);case 7:return Fd.S(t);case 8:return Fd.P(t);case 9:return rp(t);case 10:return Vd.S(t);case 11:return Vd.P(t);case 101:return Ou(t);case 102:return Lu(t);case 103:return Ru(t);case 104:return ld(t);case 105:return pd(t);case 106:return Rf(t);case 107:return Fd.S(t);case 108:return Fd.P(t);case 109:return rp(t);case 110:return Vd.S(t);case 111:return Vd.P(t)}}function rp(){let e=0;return el($c(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=rp.apply(null,t);n instanceof Error?e=n:e+=n}}),e}function ip(e,t,n){if(e=G(e),n=n?G(n):e,e instanceof Error)return e;if(t==null||t instanceof Error)return 0;let r=0,i=t===`*`,a=i?null:Zc(t+``);for(let t=0;t<e.length;t++){let o=e[t],s=n[t];if(i)r+=o;else{let e=[Gc(o,Wc)].concat(a);r+=Qc(e)?s:0}}return r}function ap(){let e=$c(arguments);return e[0]=tl(G(e[0])),rp(vl(...e))}function op(){if(!arguments||arguments.length===0)return H;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=Y(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=Y(e),i instanceof Error)return i;n*=i}t+=n}return t}function sp(){let e=X(G(arguments));if(e instanceof Error)return e;let t=0,n=e.length;for(let r=0;r<n;r++)t+=Ol(e[r])?e[r]*e[r]:0;return t}function cp(e,t){if(e=X(G(e)),t=X(G(t)),q(e,t))return H;let n=0;for(let r=0;r<e.length;r++)n+=e[r]*e[r]-t[r]*t[r];return n}function lp(e,t){if(e=X(G(e)),t=X(G(t)),q(e,t))return H;let n=0;e=X(G(e)),t=X(G(t));for(let r=0;r<e.length;r++)n+=e[r]*e[r]+t[r]*t[r];return n}function up(e,t){if(e=X(G(e)),t=X(G(t)),q(e,t))return H;let n=0;e=G(e),t=G(t);for(let r=0;r<e.length;r++)n+=(e[r]-t[r])**2;return n}function dp(e){return e=Y(e),e instanceof Error?e:Math.tan(e)}function fp(e){if(e=Y(e),e instanceof Error)return e;let t=Math.exp(2*e);return(t-1)/(t+1)}function pp(e,t){return e=Y(e),t=Y(t),K(e,t)||(e>0?1:-1)*Math.floor(Math.abs(e)*10**t)/10**t}function mp(e,t){return arguments.length===2?(e=Y(e),t=Y(t),K(e,t)||e+t):W}function hp(e,t){return arguments.length===2?(e=Y(e),t=Y(t),K(e,t)||(t===0?Ec:e/t)):W}function gp(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):W}function _p(e,t){return arguments.length===2?e instanceof Error?e:t instanceof Error?t:(_l(e,t)?(e=gl(e),t=gl(t)):(e=Y(e),t=Y(t)),K(e,t)||e>t):W}function vp(e,t){return arguments.length===2?(_l(e,t)?(e=gl(e),t=gl(t)):(e=Y(e),t=Y(t)),K(e,t)||e>=t):W}function yp(e,t){return arguments.length===2?(_l(e,t)?(e=gl(e),t=gl(t)):(e=Y(e),t=Y(t)),K(e,t)||e<t):W}function bp(e,t){return arguments.length===2?(_l(e,t)?(e=gl(e),t=gl(t)):(e=Y(e),t=Y(t)),K(e,t)||e<=t):W}function xp(e,t){return arguments.length===2?(e=Y(e),t=Y(t),K(e,t)||e-t):W}function Sp(e,t){return arguments.length===2?(e=Y(e),t=Y(t),K(e,t)||e*t):W}function Cp(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):W}function wp(e,t){return arguments.length===2?Lf(e,t):W}var Tp=/*#__PURE__*/ Object.freeze({__proto__:null,ADD:mp,DIVIDE:hp,EQ:gp,GT:_p,GTE:vp,LT:yp,LTE:bp,MINUS:xp,MULTIPLY:Sp,NE:Cp,POW:wp});let Ep=[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],Dp=[[],[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]],Op=[[],[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 kp(e,t,n){let r;return e=Y(e),t=Y(t),n=Y(n),q(e,t,n)?r=H:(r=new Date(e,t-1,n),r.getFullYear()<0&&(r=U)),Nc?Lc(r):r}function Ap(e,t,n){n=n.toUpperCase(),e=J(e),t=J(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(em(e,t));break;case`D`:l=Pp(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=Pp(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=Pp(t,e)}return l}function jp(e){if(typeof e!=`string`||isNaN(Date.parse(e)))return H;let t=new Date(e);return Nc?Lc(t):t}function Mp(e){let t=J(e);return t instanceof Error?t:t.getDate()}function Np(e){let t=new Date(e);return t.setHours(0,0,0,0),t}function Pp(e,t){return e=J(e),t=J(t),e instanceof Error?e:t instanceof Error?t:Lc(Np(e))-Lc(Np(t))}function Fp(e,t,n){if(n=ml(n||`false`),e=J(e),t=J(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 Ip(e,t){if(e=J(e),e instanceof Error)return e;if(isNaN(t))return H;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),Nc?Lc(e):e}function Lp(e,t){if(e=J(e),e instanceof Error)return e;if(isNaN(t))return H;t=parseInt(t,10);let n=new Date(e.getFullYear(),e.getMonth()+t+1,0);return Nc?Lc(n):n}function Rp(e){return e=J(e),e instanceof Error?e:e.getHours()}function zp(e){if(e=J(e),e instanceof Error)return e;e=Np(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 Bp(e){return e=J(e),e instanceof Error?e:e.getMinutes()}function Vp(e){return e=J(e),e instanceof Error?e:e.getMonth()+1}function Hp(e,t,n){return Hp.INTL(e,t,1,n)}Hp.INTL=(e,t,n,r)=>{if(e=J(e),e instanceof Error)return e;if(t=J(t),t instanceof Error)return t;let i=!1,a=[],o=[1,2,3,4,5,6,0],s=/* @__PURE__ */ RegExp(`^[0|1]{7}$`);if(n===void 0)n=Op[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=Op[n];if(!(n instanceof Array))return H;r===void 0?r=[]:r instanceof Array||(r=[r]);for(let e=0;e<r.length;e++){let t=J(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=(/* @__PURE__ */ 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 Up(){return Nc?Lc(/* @__PURE__ */ new Date):/* @__PURE__ */ new Date}function Wp(e){return e=J(e),e instanceof Error?e:e.getSeconds()}function Gp(e,t,n){return e=Y(e),t=Y(t),n=Y(n),q(e,t,n)?H:e<0||t<0||n<0?U:(3600*e+60*t+n)/86400}function Kp(e){return e=J(e),e instanceof Error?e:(3600*e.getHours()+60*e.getMinutes()+e.getSeconds())/86400}function qp(){let e=Np(/* @__PURE__ */ new Date);return Nc?Lc(e):e}function Jp(e,t){if(e=J(e),e instanceof Error)return e;t===void 0&&(t=1);let n=e.getDay();return Dp[t][n]}function Yp(e,t){if(e=J(e),e instanceof Error)return e;if(t===void 0&&(t=1),t===21)return zp(e);let n=Ep[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 Xp(e,t,n){return Xp.INTL(e,t,1,n)}Xp.INTL=(e,t,n,r)=>{if(e=J(e),e instanceof Error)return e;if(t=Y(t),t instanceof Error)return t;if(n=n===void 0?Op[1]:Op[n],!(n instanceof Array))return H;r===void 0?r=[]:r instanceof Array||(r=[r]);for(let e=0;e<r.length;e++){let t=J(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?H:e};function Zp(e){return e=J(e),e instanceof Error?e:e.getFullYear()}function Qp(e){return new Date(e,1,29).getMonth()===1}function $p(e,t){return Math.ceil((t-e)/1e3/60/60/24)}function em(e,t,n){if(e=J(e),e instanceof Error)return e;if(t=J(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(Qp(n)&&e<r&&t>=r)return!0;let i=t.getFullYear(),a=new Date(i,2,1);return Qp(i)&&t>=a&&e<a},l=365;if(a===c||a+1===c&&(i>s||i===s&&r>=o))return(a===c&&Qp(a)||n(e,t)||s===1&&o===29)&&(l=366),$p(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 $p(e,t)/d}case 2:return $p(e,t)/360;case 3:return $p(e,t)/365;case 4:return(o+s*30+c*360-(r+i*30+a*360))/360}}function tm(e){return/^[01]{1,10}$/.test(e)}function nm(e,t){return e=Y(e),t=Y(t),q(e,t)?H:wc.default.besseli(e,t)}function rm(e,t){return e=Y(e),t=Y(t),q(e,t)?H:wc.default.besselj(e,t)}function im(e,t){return e=Y(e),t=Y(t),q(e,t)?H:wc.default.besselk(e,t)}function am(e,t){return e=Y(e),t=Y(t),q(e,t)?H:wc.default.bessely(e,t)}function om(e){if(!tm(e))return U;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 sm(e,t){if(!tm(e))return U;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)?H:t<0?U:(t=Math.floor(t),t>=r.length?hu(`0`,t-r.length)+r:U)}function cm(e,t){if(!tm(e))return U;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)?H:t<0?U:(t=Math.floor(t),t>=r.length?hu(`0`,t-r.length)+r:U)}function lm(e,t){return e=Y(e),t=Y(t),q(e,t)?H:e<0||t<0||Math.floor(e)!==e||Math.floor(t)!==t||e>0xffffffffffff||t>0xffffffffffff?U:e&t}function um(e,t){return e=Y(e),t=Y(t),q(e,t)?H:e<0||Math.floor(e)!==e||e>0xffffffffffff||Math.abs(t)>53?U:t>=0?e<<t:e>>-t}function dm(e,t){return e=Y(e),t=Y(t),q(e,t)?H:e<0||t<0||Math.floor(e)!==e||Math.floor(t)!==t||e>0xffffffffffff||t>0xffffffffffff?U:e|t}function fm(e,t){return e=Y(e),t=Y(t),q(e,t)?H:e<0||Math.floor(e)!==e||e>0xffffffffffff||Math.abs(t)>53?U:t>=0?e>>t:e<<-t}function pm(e,t){return e=Y(e),t=Y(t),q(e,t)?H:e<0||t<0||Math.floor(e)!==e||Math.floor(t)!==t||e>0xffffffffffff||t>0xffffffffffff?U:e^t}function mm(e,t,n){if(e=Y(e),t=Y(t),q(e,t))return e;if(n=n===void 0?`i`:n,n!==`i`&&n!==`j`)return H;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 hm(e,t,n){if(e=Y(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]?W:e*o[6]*u/(s[6]*d)}function gm(e,t){if(e=Y(e),e instanceof Error)return e;if(!/^-?[0-9]{1,3}$/.test(e)||e<-512||e>511)return U;if(e<0)return`1`+hu(`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)?H:t<0?U:(t=Math.floor(t),t>=n.length?hu(`0`,t-n.length)+n:U)}function _m(e,t){if(e=Y(e),e instanceof Error)return e;if(!/^-?[0-9]{1,12}$/.test(e)||e<-549755813888||e>549755813887)return U;if(e<0)return(1099511627776+e).toString(16);let n=parseInt(e,10).toString(16);return t===void 0?n:isNaN(t)?H:t<0?U:(t=Math.floor(t),t>=n.length?hu(`0`,t-n.length)+n:U)}function vm(e,t){if(e=Y(e),e instanceof Error)return e;if(!/^-?[0-9]{1,9}$/.test(e)||e<-536870912||e>536870911)return U;if(e<0)return(1073741824+e).toString(8);let n=parseInt(e,10).toString(8);return t===void 0?n:isNaN(t)?H:t<0?U:(t=Math.floor(t),t>=n.length?hu(`0`,t-n.length)+n:U)}function ym(e,t){return t=t===void 0?0:t,e=Y(e),t=Y(t),q(e,t)?H:+(e===t)}function bm(e,t){return t=t===void 0?0:t,e=Y(e),t=Y(t),q(e,t)?H:V.default.erf(e)}function xm(e){return isNaN(e)?H:V.default.erfc(e)}function Sm(e,t){return t||=0,e=Y(e),q(t,e)?e:+(e>=t)}function Cm(e,t){if(!/^[0-9A-Fa-f]{1,10}$/.test(e))return U;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 U;if(n)return`1`+hu(`0`,9-(512+r).toString(2).length)+(512+r).toString(2);let i=r.toString(2);return t===void 0?i:isNaN(t)?H:t<0?U:(t=Math.floor(t),t>=i.length?hu(`0`,t-i.length)+i:U)}function wm(e){if(!/^[0-9A-Fa-f]{1,10}$/.test(e))return U;let t=parseInt(e,16);return t>=549755813888?t-1099511627776:t}function Tm(e,t){if(!/^[0-9A-Fa-f]{1,10}$/.test(e))return U;let n=parseInt(e,16);if(n>536870911&&n<0xffe0000000)return U;if(n>=0xffe0000000)return(n-0xffc0000000).toString(8);let r=n.toString(8);return t===void 0?r:isNaN(t)?H:t<0?U:(t=Math.floor(t),t>=r.length?hu(`0`,t-r.length)+r:U)}function Em(e){let t=Bm(e),n=Dm(e);return q(t,n)?H:Math.sqrt(t**2+n**2)}function Dm(e){if(e===void 0||e===!0||e===!1)return H;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))?U:Number(e.substring(t+1,e.length-1)):isNaN(e.substring(0,n))||isNaN(e.substring(n+1,e.length-1))?U:-Number(e.substring(n+1,e.length-1)):U:i?isNaN(e.substring(0,e.length-1))?U:e.substring(0,e.length-1):isNaN(e)?U:0}function Om(e){let t=Bm(e),n=Dm(e);return q(t,n)?H:t===0&&n===0?Ec: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 km(e){let t=Bm(e),n=Dm(e);if(q(t,n))return H;let r=e.substring(e.length-1);return r=r===`i`||r===`j`?r:`i`,n===0?e:mm(t,-n,r)}function Am(e){let t=Bm(e),n=Dm(e);if(q(t,n))return H;let r=e.substring(e.length-1);return r=r===`i`||r===`j`?r:`i`,mm(Math.cos(t)*(Math.exp(n)+Math.exp(-n))/2,-Math.sin(t)*(Math.exp(n)-Math.exp(-n))/2,r)}function jm(e){let t=Bm(e),n=Dm(e);if(q(t,n))return H;let r=e.substring(e.length-1);return r=r===`i`||r===`j`?r:`i`,mm(Math.cos(n)*(Math.exp(t)+Math.exp(-t))/2,Math.sin(n)*(Math.exp(t)-Math.exp(-t))/2,r)}function Mm(e){return q(Bm(e),Dm(e))?H:Nm(Am(e),Um(e))}function Nm(e,t){let n=Bm(e),r=Dm(e),i=Bm(t),a=Dm(t);if(q(n,r,i,a))return H;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 U;let l=i*i+a*a;return mm((n*i+r*a)/l,(r*i-n*a)/l,c)}function Pm(e){let t=Bm(e),n=Dm(e);if(q(t,n))return H;let r=e.substring(e.length-1);r=r===`i`||r===`j`?r:`i`;let i=Math.exp(t);return mm(i*Math.cos(n),i*Math.sin(n),r)}function Fm(e){let t=Bm(e),n=Dm(e);if(q(t,n))return H;let r=e.substring(e.length-1);return r=r===`i`||r===`j`?r:`i`,mm(Math.log(Math.sqrt(t*t+n*n)),Math.atan(n/t),r)}function Im(e){let t=Bm(e),n=Dm(e);if(q(t,n))return H;let r=e.substring(e.length-1);return r=r===`i`||r===`j`?r:`i`,mm(Math.log(Math.sqrt(t*t+n*n))/Math.log(10),Math.atan(n/t)/Math.log(10),r)}function Lm(e){let t=Bm(e),n=Dm(e);if(q(t,n))return H;let r=e.substring(e.length-1);return r=r===`i`||r===`j`?r:`i`,mm(Math.log(Math.sqrt(t*t+n*n))/Math.log(2),Math.atan(n/t)/Math.log(2),r)}function Rm(e,t){t=Y(t);let n=Bm(e),r=Dm(e);if(q(t,n,r))return H;let i=e.substring(e.length-1);i=i===`i`||i===`j`?i:`i`;let a=Em(e)**+t,o=Om(e);return mm(a*Math.cos(t*o),a*Math.sin(t*o),i)}function zm(){let e=arguments[0];if(!arguments.length)return H;for(let t=1;t<arguments.length;t++){let n=Bm(e),r=Dm(e),i=Bm(arguments[t]),a=Dm(arguments[t]);if(q(n,r,i,a))return H;e=mm(n*i-r*a,n*a+r*i)}return e}function Bm(e){if(e===void 0||e===!0||e===!1)return H;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))?U:Number(e.substring(0,t)):isNaN(e.substring(0,n))||isNaN(e.substring(n+1,e.length-1))?U:Number(e.substring(0,n)):U:i?isNaN(e.substring(0,e.length-1))?U:0:isNaN(e)?U:e}function Vm(e){return e===!0||e===!1||q(Bm(e),Dm(e))?H:Nm(`1`,Am(e))}function Hm(e){return q(Bm(e),Dm(e))?H:Nm(`1`,jm(e))}function Um(e){let t=Bm(e),n=Dm(e);if(q(t,n))return H;let r=e.substring(e.length-1);return r=r===`i`||r===`j`?r:`i`,mm(Math.sin(t)*(Math.exp(n)+Math.exp(-n))/2,Math.cos(t)*(Math.exp(n)-Math.exp(-n))/2,r)}function Wm(e){let t=Bm(e),n=Dm(e);if(q(t,n))return H;let r=e.substring(e.length-1);return r=r===`i`||r===`j`?r:`i`,mm(Math.cos(n)*(Math.exp(t)-Math.exp(-t))/2,Math.sin(n)*(Math.exp(t)+Math.exp(-t))/2,r)}function Gm(e){if(q(Bm(e),Dm(e)))return H;let t=e.substring(e.length-1);t=t===`i`||t===`j`?t:`i`;let n=Math.sqrt(Em(e)),r=Om(e);return mm(n*Math.cos(r/2),n*Math.sin(r/2),t)}function Km(e){return e===!0||e===!1?H:q(Bm(e),Dm(e))?U:Nm(`1`,Um(e))}function qm(e){return e===!0||e===!1?H:q(Bm(e),Dm(e))?U:Nm(`1`,Wm(e))}function Jm(e,t){let n=Bm(e),r=Dm(e),i=Bm(t),a=Dm(t);if(q(n,r,i,a))return H;let o=e.substring(e.length-1),s=t.substring(t.length-1),c=`i`;return(o===`j`||s===`j`)&&(c=`j`),mm(n-i,r-a,c)}function Ym(){if(!arguments.length)return H;let e=G(arguments),t=0,n=0;for(let r of e){let e=+Bm(r),i=+Dm(r);if(q(e,i))return H;t+=e,n+=i}return mm(t,n,`i`)}function Xm(e){return e===!0||e===!1||q(Bm(e),Dm(e))?H:Nm(Um(e),Am(e))}function Zm(e,t){if(!/^[0-7]{1,10}$/.test(e))return U;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 U;if(n)return`1`+hu(`0`,9-(512+r).toString(2).length)+(512+r).toString(2);let i=r.toString(2);return t===void 0?i:isNaN(t)?H:t<0?U:(t=Math.floor(t),t>=i.length?hu(`0`,t-i.length)+i:U)}function Qm(e){if(!/^[0-7]{1,10}$/.test(e))return U;let t=parseInt(e,8);return t>=536870912?t-1073741824:t}function $m(e,t){if(!/^[0-7]{1,10}$/.test(e))return U;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)?H:t<0?U:(t=Math.floor(t),t>=r.length?hu(`0`,t-r.length)+r:U)}let eh=Mu.DIST,th=Mu.INV,nh=Nu.DIST,rh=of.MATH,ih=of.PRECISE,ah=Pu.DIST,oh=Pu.DIST.RT,sh=Pu.INV,ch=Pu.INV.RT,lh=Pu.TEST,uh=Hu.P,dh=Hu.P,fh=Hu.S,ph=Nu.INV,mh=xm.PRECISE,hh=bm.PRECISE,gh=Wu.DIST,_h=Gu.DIST,vh=Gu.DIST.RT,yh=Gu.INV,bh=Gu.INV.RT,xh=Sf.MATH,Sh=Sf.PRECISE,Ch=Gu.TEST,wh=Xu.DIST,Th=Xu.INV,Eh=Zu.PRECISE,Dh=nd.DIST,Oh=cd.INV,kh=cd.DIST,Ah=cd.INV,jh=gd.MULT,Mh=gd.SNGL,Nh=_d.DIST,Ph=Hp.INTL,Fh=vd.DIST,Ih=vd.INV,Lh=vd.S.DIST,Rh=vd.S.INV,zh=bd.EXC,Bh=bd.INC,Vh=xd.EXC,Hh=xd.INC,Uh=Td.DIST,Wh=Dd.EXC,Gh=Dd.INC,Kh=Od.AVG,qh=Od.EQ,Jh=jd.P,Yh=Fd.P,Xh=Fd.S,Zh=yu.DIST,Qh=yu.DIST.RT,$h=yu.INV,eg=yu.TEST,tg=Vd.P,ng=Vd.S,rg=Wd.DIST,ig=Xp.INTL,ag=Gd.TEST;function og(e){let t=[];return el(e,e=>{e&&t.push(e)}),t}function sg(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=Zc(c[t]+``),r=[Gc(e[i][a],Wc)].concat(n);o=Qc(r)}}}}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 cg(e,t,n){if(isNaN(t)&&typeof t!=`string`)return H;let r=sg(e,n),i=[];i=ll(typeof t==`string`?e[dl(e,t)]:e[t]);let a=0;return el(r,e=>{a+=i[e]}),r.length===0?Ec:a/r.length}function lg(e,t,n){if(isNaN(t)&&typeof t!=`string`)return H;let r=sg(e,n),i=[];i=ll(typeof t==`string`?e[dl(e,t)]:e[t]);let a=[];return el(r,e=>{a.push(i[e])}),Lu(a)}function ug(e,t,n){if(isNaN(t)&&typeof t!=`string`)return H;let r=sg(e,n),i=[];i=ll(typeof t==`string`?e[dl(e,t)]:e[t]);let a=[];return el(r,e=>{a.push(i[e])}),Ru(a)}function dg(e,t,n){if(isNaN(t)&&typeof t!=`string`)return H;let r=sg(e,n),i=[];return i=ll(typeof t==`string`?e[dl(e,t)]:e[t]),r.length===0?H:r.length>1?U:i[r[0]]}function fg(e,t,n){if(isNaN(t)&&typeof t!=`string`)return H;let r=sg(e,n),i=[];i=ll(typeof t==`string`?e[dl(e,t)]:e[t]);let a=i[r[0]];return el(r,e=>{a<i[e]&&(a=i[e])}),a}function pg(e,t,n){if(isNaN(t)&&typeof t!=`string`)return H;let r=sg(e,n),i=[];i=ll(typeof t==`string`?e[dl(e,t)]:e[t]);let a=i[r[0]];return el(r,e=>{a>i[e]&&(a=i[e])}),a}function mg(e,t,n){if(isNaN(t)&&typeof t!=`string`)return H;let r=sg(e,n),i=[];i=ll(typeof t==`string`?e[dl(e,t)]:e[t]);let a=[];el(r,e=>{a.push(i[e])}),a=og(a);let o=1;return el(a,e=>{o*=e}),o}function hg(e,t,n){if(isNaN(t)&&typeof t!=`string`)return H;let r=sg(e,n),i=[];i=ll(typeof t==`string`?e[dl(e,t)]:e[t]);let a=[];return el(r,e=>{a.push(i[e])}),a=og(a),Fd.S(a)}function gg(e,t,n){if(isNaN(t)&&typeof t!=`string`)return H;let r=sg(e,n),i=[];i=ll(typeof t==`string`?e[dl(e,t)]:e[t]);let a=[];return el(r,e=>{a.push(i[e])}),a=og(a),Fd.P(a)}function _g(e,t,n){if(isNaN(t)&&typeof t!=`string`)return H;let r=sg(e,n),i=[];i=ll(typeof t==`string`?e[dl(e,t)]:e[t]);let a=[];return el(r,e=>{a.push(i[e])}),rp(a)}function vg(e,t,n){if(isNaN(t)&&typeof t!=`string`)return H;let r=sg(e,n),i=[];i=ll(typeof t==`string`?e[dl(e,t)]:e[t]);let a=[];return el(r,e=>{a.push(i[e])}),Vd.S(a)}function yg(e,t,n){if(isNaN(t)&&typeof t!=`string`)return H;let r=sg(e,n),i=[];i=ll(typeof t==`string`?e[dl(e,t)]:e[t]);let a=[];return el(r,e=>{a.push(i[e])}),Vd.P(a)}function bg(e){return e&&e.getTime&&!isNaN(e.getTime())}function xg(e){return e instanceof Date?e:new Date(e)}function Sg(e,t,n){let r=J(t);for(r.setFullYear(e.getFullYear()),r<e&&r.setFullYear(r.getFullYear()+1);r>e;)r.setMonth(r.getMonth()+-12/n);return r}function Cg(e){return e=Y(e),[1,2,4].indexOf(e)===-1?U:e}function wg(e){return e=Y(e),[0,1,2,3,4].indexOf(e)===-1?U:e}function Tg(e,t,n,r,i,a,o){return e=xg(e),t=xg(t),n=xg(n),a=Cg(a),o=wg(o),K(a,o)?U:!bg(e)||!bg(t)||!bg(n)?H:r<=0||i<=0||n<=e?U:(i||=0,o||=0,i*r*em(e,n,o))}function Eg(e,t,n,r){if(r=wg(r),n=Cg(n),e=J(e),t=J(t),K(e,t))return H;if(K(n,r)||e>=t)return U;if(r===1){let r=Sg(e,t,n),i=J(r);return i.setMonth(i.getMonth()+12/n),Ap(r,i,`D`)}let i;switch(r){case 0:case 2:case 4:i=360;break;case 3:i=365;break;default:return U}return i/n}function Dg(e,t,n,r,i,a){if(e=Y(e),t=Y(t),n=Y(n),q(e,t,n))return H;if(e<=0||t<=0||n<=0||r<1||i<1||r>i||a!==0&&a!==1)return U;let o=Gg(e,t,n,0,a),s=0;r===1&&(a===0&&(s=-n),r++);for(let t=r;t<=i;t++)s+=a===1?Fg(e,t-2,o,n,1)-o:Fg(e,t-1,o,n,0);return s*=e,s}function Og(e,t,n,r,i,a){if(e=Y(e),t=Y(t),n=Y(n),q(e,t,n))return H;if(e<=0||t<=0||n<=0||r<1||i<1||r>i||a!==0&&a!==1)return U;let o=Gg(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-(Fg(e,t-2,o,n,1)-o)*e:o-Fg(e,t-1,o,n,0)*e;return s}function kg(e,t,n,r,i){if(i=i===void 0?12:i,e=Y(e),t=Y(t),n=Y(n),r=Y(r),i=Y(i),q(e,t,n,r,i))return H;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 U;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 Ag(e,t,n,r,i){if(i=i===void 0?2:i,e=Y(e),t=Y(t),n=Y(n),r=Y(r),i=Y(i),q(e,t,n,r,i))return H;if(e<0||t<0||n<0||r<0||i<=0||r>n)return U;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 jg(e,t,n,r,i){if(e=J(e),t=J(t),n=Y(n),r=Y(r),i=Y(i),i||=0,q(e,t,n,r,i))return H;if(n<=0||r<=0)return U;if(e>=t)return H;let a,o;switch(i){case 0:a=360,o=Fp(e,t,!1);break;case 1:a=365,o=Ap(e,t,`D`);break;case 2:a=360,o=Ap(e,t,`D`);break;case 3:a=365,o=Ap(e,t,`D`);break;case 4:a=360,o=Fp(e,t,!0);break;default:return U}return(r-n)/r*a/o}function Mg(e,t){if(e=Y(e),t=Y(t),q(e,t))return H;if(t<0)return U;if(t>=0&&t<1)return Ec;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 Ng(e,t){if(e=Y(e),t=Y(t),q(e,t))return H;if(t<0)return U;if(t>=0&&t<1)return Ec;t=parseInt(t,10);let n=parseInt(e,10);return n+=e%1*10**-Math.ceil(Math.log(t)/Math.LN10)*t,n}function Pg(e,t){return e=Y(e),t=Y(t),q(e,t)?H:e<=0||t<1?U:(t=parseInt(t,10),(1+e/t)**+t-1)}function Fg(e,t,n,r,i){if(r||=0,i||=0,e=Y(e),t=Y(t),n=Y(n),r=Y(r),i=Y(i),q(e,t,n,r,i))return H;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 Ig(e,t){if(e=Y(e),t=X(G(t)),q(e,t))return H;let n=t.length,r=e;for(let e=0;e<n;e++)r*=1+t[e];return r}function Lg(e,t,n,r,i,a){if(i||=0,a||=0,e=Y(e),t=Y(t),n=Y(n),r=Y(r),i=Y(i),a=Y(a),q(e,t,n,r,i,a))return H;let o=Gg(e,n,r,i,a);return(t===1?a===1?0:-r:a===1?Fg(e,t-2,o,r,1)-o:Fg(e,t-1,o,r,0))*e}function Rg(e,t){if(t=typeof t==`number`?t:t===void 0?.1:Y(t),e=G(e).filter(yl),e=X(e),q(e,t))return H;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 U;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=/* @__PURE__ */ 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 zg(e,t,n,r){return e=Y(e),t=Y(t),n=Y(n),r=Y(r),q(e,t,n,r)?H:r*e*(t/n-1)}function Bg(e,t,n){if(e=X(G(e)),t=Y(t),n=Y(n),q(e,t,n))return H;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(-Ug(n,a)*(1+n)**(r-1)/(Ug(t,i)*(1+t)))**(1/(r-1))-1}function Vg(e,t){return e=Y(e),t=Y(t),q(e,t)?H:e<=0||t<1?U:(t=parseInt(t,10),((e+1)**(1/t)-1)*t)}function Hg(e,t,n,r,i){if(i=i===void 0?0:i,r=r===void 0?0:r,e=Y(e),t=Y(t),n=Y(n),r=Y(r),i=Y(i),q(e,t,n,r,i))return H;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 Ug(){let e=X(G(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 Wg(e,t,n){return e=Y(e),t=Y(t),n=Y(n),q(e,t,n)?H:e<=0?U:(Math.log(n)-Math.log(t))/Math.log(1+e)}function Gg(e,t,n,r,i){if(r||=0,i||=0,e=Y(e),t=Y(t),n=Y(n),r=Y(r),i=Y(i),q(e,t,n,r,i))return H;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 Kg(e,t,n,r,i,a){return i||=0,a||=0,e=Y(e),n=Y(n),r=Y(r),i=Y(i),a=Y(a),q(e,n,r,i,a)?H:Gg(e,n,r,i,a)-Lg(e,t,n,r,i,a)}function qg(e,t,n,r,i){if(e=J(e),t=J(t),n=Y(n),r=Y(r),i=Y(i),i||=0,q(e,t,n,r,i))return H;if(n<=0||r<=0)return U;if(e>=t)return H;let a,o;switch(i){case 0:a=360,o=Fp(e,t,!1);break;case 1:a=365,o=Ap(e,t,`D`);break;case 2:a=360,o=Ap(e,t,`D`);break;case 3:a=365,o=Ap(e,t,`D`);break;case 4:a=360,o=Fp(e,t,!0);break;default:return U}return r-n*r*o/a}function Jg(e,t,n,r,i){return r||=0,i||=0,e=Y(e),t=Y(t),n=Y(n),r=Y(r),i=Y(i),q(e,t,n,r,i)?H:e===0?-n*t-r:((1-(1+e)**+t)/e*n*(1+e*i)-r)/(1+e)**+t}function Yg(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=Y(e),t=Y(t),n=Y(n),r=Y(r),i=Y(i),a=Y(a),q(e,t,n,r,i,a))return H;let o=1e-10,s=a;i=+!!i;for(let a=0;a<100;a++){if(s<=-1)return U;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 Xg(e,t,n){return e=Y(e),t=Y(t),n=Y(n),q(e,t,n)?H:e===0||t===0?U:(n/t)**(1/e)-1}function Zg(e,t,n){return e=Y(e),t=Y(t),n=Y(n),q(e,t,n)?H:n===0?U:(e-t)/n}function Qg(e,t,n,r){return e=Y(e),t=Y(t),n=Y(n),r=Y(r),q(e,t,n,r)?H:n===0||r<1||r>n?U:(r=parseInt(r,10),(e-t)*(n-r+1)*2/(n*(n+1)))}function $g(e,t,n){return e=J(e),t=J(t),n=Y(n),q(e,t,n)?H:n<=0||e>t||t-e>31536e6?U:365*n/(360-n*Fp(e,t,!1))}function e_(e,t,n){return e=J(e),t=J(t),n=Y(n),q(e,t,n)?H:n<=0||e>t||t-e>31536e6?U:100*(1-n*Fp(e,t,!1)/360)}function t_(e,t,n){return e=J(e),t=J(t),n=Y(n),q(e,t,n)?H:n<=0||e>t||t-e>31536e6?U:(100-n)*360/(n*Fp(e,t,!1))}function n_(e,t,n){if(e=X(G(e)),t=hl(G(t)),n=Y(n),q(e,t,n))return H;let r=(e,t,n)=>{let r=n+1,i=e[0];for(let n=1;n<e.length;n++)i+=e[n]/r**(Pp(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=Pp(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 U;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 r_(e,t,n){if(e=Y(e),t=X(G(t)),n=hl(G(n)),q(e,t,n))return H;let r=0;for(let i=0;i<t.length;i++)r+=t[i]/(1+e)**(Pp(n[i],n[0])/365);return r}function i_(){let e=G(arguments),t=H;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===H&&(t=!0),e[n]||(t=!1))}return t}function a_(){return!1}function o_(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 s_(){for(let e=0;e<arguments.length/2;e++)if(arguments[e*2])return arguments[e*2+1];return W}function c_(e,t){return Cl(e)?t:e}function l_(e,t){return e===W?t:e}function u_(e){return typeof e==`string`?H:e instanceof Error?e:!e}function d_(){let e=G(arguments),t=H;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===H&&(t=!1),e[n]&&(t=!0))}return t}function f_(){return!0}function p_(){let e=G(arguments),t=H;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===H&&(t=0),e[n]&&t++)}return t===H?t:!!(Math.floor(Math.abs(t))&1)}function m_(){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:W)}else e=H;return e}let h_={errors:Mc,symbols:Tp,date:Rc},g_=Cc;function __(e){let t=e.split(`.`).reduce((e,t)=>e?.[t],g_);if(typeof t!=`function`)throw Error(`@formulajs/formulajs has no ${e}.`);return t}function v_(e){return typeof e==`number`?Number.isFinite(e)?e:M.NUM:e instanceof Error?zn(e.message)??M.VALUE:typeof e==`boolean`||typeof e==`string`?e:M.VALUE}let y_=(e,t)=>{try{return v_(e(...t))}catch{return M.VALUE}};function b_(e,t){return To([e],t)}function x_(e,t){let n=B(e,t);if(n instanceof j)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 j)return i;t.push(typeof i==`number`?i:0)}r.push(t)}return r}function Z(e,t,n){let r=t.split(`?`)[0]?.length??0,i=t.replace(`?`,``),a=__(n);R(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`?I(r):e===`b`?io(r):L(r);if(a instanceof j)return a;t.push(a)}return y_(a,t)},{from:`formulajs`})}function S_(e,t,n){let r=t.replace(`?`,``),i=r.endsWith(`r`),a=__(n);z(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=To(e.slice(a),t);if(r instanceof j)return r;n.push(r);break}if(o instanceof F){n.push(void 0);continue}let c;if(s===`l`)c=b_(o,t);else if(s===`m`)c=x_(o,t);else{let e=t.calc.scalar(o,t.frame);c=s===`n`?I(e):s===`b`?io(e):L(e)}if(c instanceof j)return c;n.push(c)}return y_(a,n)},{from:`formulajs`})}function C_(e,t,n=``,r=1){let i=__(t),a=n.length;z(e,`${`v`.repeat(a)}rr`,(e,t)=>{let n=[];for(let r of e.slice(0,a)){let e=I(t.calc.scalar(r,t.frame));if(e instanceof j)return e;n.push(e)}let o=B(e[a],t),s=B(e[a+1],t);if(o instanceof j)return o;if(s instanceof j)return s;if(o.rows*o.cols!==s.rows*s.cols)return M.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 j)return n;if(r instanceof j)return r;typeof n==`number`&&typeof r==`number`&&(c.push(n),l.push(r))}if(c.length<r)return M.DIV0;let u=y_(i,[...n,c,l]);return u===M.NUM?M.DIV0:u},{from:`formulajs`})}function w_(e,t,n=!1,r=1,i=M.DIV0){let a=__(t);z(e,`(r)`,(e,t)=>{let o=n?Eo(e,t):To(e,t);if(o instanceof j)return o;if(o.length<r)return i;let s=y_(a,[o]);return s===M.NUM&&i===M.DIV0?M.DIV0:s},{from:`formulajs`})}function T_(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?``:Yn(Number(n));if(a===void 0)return o;let s=i===void 0?``:Yn(Number(i));return`${o}${r??``}${s===`1`?``:s}${a}`}function E_(e,t){let n=__(e);R(e,t.length,t.length,(...e)=>{let r=[];for(let[n,i]of e.entries()){let e=t.charAt(n)===`n`?I(i):L(i);if(e instanceof j)return e;r.push(e)}let i=y_(n,r);return typeof i==`string`?T_(i):i},{from:`formulajs`})}for(let e of/* @__PURE__ */ `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(`.`))Z(e,`n`,e);for(let e of[`COMBIN`,`COMBINA`,`MROUND`,`PERMUT`,`PERMUTATIONA`,`POWER`])Z(e,`nn`,e);Z(`TRUNC`,`n?n`,`TRUNC`),Z(`CEILING`,`nn`,`CEILING`),R(`FLOOR`,2,2,(e,t)=>{let n=I(e??0);if(n instanceof j)return n;let r=I(t??0);return r instanceof j?r:n===0&&r===0?0:y_(__(`FLOOR`),[n,r])}),Z(`CEILING.MATH`,`n?nn`,`CEILINGMATH`),Z(`FLOOR.MATH`,`n?nn`,`FLOORMATH`),Z(`CEILING.PRECISE`,`n?n`,`CEILINGPRECISE`),Z(`FLOOR.PRECISE`,`n?n`,`FLOORPRECISE`),So(`ISO.CEILING`,`CEILING.PRECISE`),R(`PI`,0,0,()=>Math.PI),z(`RAND`,``,(e,t)=>t.calc.random(),{volatile:!0}),z(`RANDBETWEEN`,`vv`,(e,t)=>{let n=I(t.calc.scalar(e[0],t.frame)),r=I(t.calc.scalar(e[1],t.frame));if(n instanceof j)return n;if(r instanceof j)return r;let i=Math.ceil(n),a=Math.floor(r);return i>a?M.NUM:i+Math.floor(t.calc.random()*(a-i+1))},{volatile:!0}),w_(`MULTINOMIAL`,`MULTINOMIAL`),w_(`AVEDEV`,`AVEDEV`,!1,1,M.NUM),w_(`DEVSQ`,`DEVSQ`,!1,1,M.NUM),w_(`MEDIAN`,`MEDIAN`,!1,1,M.NUM),w_(`SKEW`,`SKEW`,!1,3),w_(`SKEW.P`,`SKEW.P`,!1,3),w_(`STDEV.S`,`STDEV.S`,!1,2),w_(`STDEV.P`,`STDEV.P`,!1,1),w_(`VAR.S`,`VAR.S`,!1,2),w_(`VAR.P`,`VAR.P`,!1,1),w_(`STDEVA`,`STDEVA`,!0,2),w_(`STDEVPA`,`STDEVPA`,!0,1),w_(`VARA`,`VARA`,!0,2),w_(`VARPA`,`VARPA`,!0,1);for(let[e,t]of[[`STDEV`,`STDEV.S`],[`STDEVP`,`STDEV.P`],[`VAR`,`VAR.S`],[`VARP`,`VAR.P`]])So(e,t);S_(`PERCENTILE.INC`,`ln`,`PERCENTILE.INC`),S_(`PERCENTILE.EXC`,`ln`,`PERCENTILE.EXC`),S_(`PERCENTRANK.INC`,`ln?n`,`PERCENTRANK.INC`),S_(`PERCENTRANK.EXC`,`ln?n`,`PERCENTRANK.EXC`),S_(`QUARTILE.EXC`,`ln`,`QUARTILE.EXC`),z(`TRIMMEAN`,`rv`,(e,t)=>{let n=To([e[0]],t);if(n instanceof j)return n;let r=I(t.calc.scalar(e[1],t.frame));if(r instanceof j)return r;if(r<0||r>=1||n.length===0)return M.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}),So(`PERCENTILE`,`PERCENTILE.INC`),So(`PERCENTRANK`,`PERCENTRANK.INC`),C_(`CORREL`,`CORREL`),C_(`PEARSON`,`PEARSON`),C_(`RSQ`,`RSQ`),C_(`SLOPE`,`SLOPE`),C_(`INTERCEPT`,`INTERCEPT`),C_(`STEYX`,`STEYX`,``,3),C_(`COVARIANCE.P`,`COVARIANCE.P`),C_(`COVARIANCE.S`,`COVARIANCE.S`,``,2),C_(`FORECAST`,`FORECAST`,`n`),So(`FORECAST.LINEAR`,`FORECAST`),So(`COVAR`,`COVARIANCE.P`),Z(`PV`,`nnn?nn`,`PV`),Z(`NPER`,`nnn?nn`,`NPER`),Z(`RATE`,`nnn?nnn`,`RATE`),Z(`SYD`,`nnnn`,`SYD`),Z(`DDB`,`nnnn?n`,`DDB`),Z(`ISPMT`,`nnnn`,`ISPMT`),Z(`EFFECT`,`nn`,`EFFECT`),Z(`NOMINAL`,`nn`,`NOMINAL`),Z(`CUMIPMT`,`nnnnnn`,`CUMIPMT`),Z(`CUMPRINC`,`nnnnnn`,`CUMPRINC`),Z(`DOLLARDE`,`nn`,`DOLLARDE`),Z(`DOLLARFR`,`nn`,`DOLLARFR`),Z(`PDURATION`,`nnn`,`PDURATION`),Z(`RRI`,`nnn`,`RRI`),S_(`IRR`,`l?n`,`IRR`),S_(`MIRR`,`lnn`,`MIRR`),S_(`NPV`,`nr`,`NPV`),S_(`FVSCHEDULE`,`nl`,`FVSCHEDULE`);for(let e of[`BIN2DEC`,`HEX2DEC`,`OCT2DEC`,`IMABS`,`IMAGINARY`,`IMARGUMENT`,`IMREAL`])Z(e,`t`,e);for(let e of[`IMCONJUGATE`,`IMCOS`,`IMCOSH`,`IMCOT`,`IMCSC`,`IMCSCH`,`IMEXP`,`IMLN`,`IMLOG10`,`IMLOG2`,`IMSEC`,`IMSECH`,`IMSIN`,`IMSINH`,`IMSQRT`,`IMTAN`])E_(e,`t`);for(let e of[`BIN2OCT`,`HEX2BIN`,`HEX2OCT`,`OCT2BIN`])Z(e,`t?n`,e);for(let e of[`DEC2BIN`,`DEC2OCT`])Z(e,`n?n`,e);for(let[e,t]of[[`BIN2HEX`,`t`],[`OCT2HEX`,`t`],[`DEC2HEX`,`n`]]){let n=__(e);R(e,1,2,(e,r)=>{let i=t===`n`?I(e):L(e);if(i instanceof j)return i;let a=r===void 0?void 0:I(r);if(a instanceof j)return a;let o=y_(n,[i,a]);return typeof o==`string`?o.toUpperCase():o},{from:`formulajs`})}E_(`IMDIV`,`tt`),E_(`IMSUB`,`tt`),E_(`IMPOWER`,`tn`),Z(`COMPLEX`,`nn?t`,`COMPLEX`),Z(`DECIMAL`,`tn`,`DECIMAL`),Z(`ARABIC`,`t`,`ARABIC`);for(let e of[`IMSUM`,`IMPRODUCT`]){let t=__(e);z(e,`(r)`,(e,n)=>{let r=[],i;if(Co(e,n,e=>{if(i||e===null)return;let t=L(e);t instanceof j?i=t:r.push(t)}),i)return i;let a=y_(t,r);return typeof a==`string`?T_(a):a},{from:`formulajs`})}Z(`DELTA`,`n?n`,`DELTA`),Z(`GESTEP`,`n?n`,`GESTEP`);let D_=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.00016431823292116355,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22],O_=.5*Math.log(2*Math.PI);function k_(e){if(Number.isInteger(e)&&e<=171)return Math.log(A_(e));let t=D_[0]??0;for(let n=1;n<D_.length;n++)t+=(D_[n]??0)/(e+n);let n=e+4.7421875+.5;return O_+Math.log(t/e)+(e+.5)*Math.log(n)-n}function A_(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)*A_(1-e)):Math.exp(k_(e))}let j_=1e-16,M_=1e-300,N_=1e5;function P_(e,t){if(t<=0)return 0;if(t<e+1){let n=1/e,r=n,i=e;for(let e=0;e<N_&&(i+=1,n*=t/i,r+=n,!(Math.abs(n)<Math.abs(r)*j_));e++);return r*Math.exp(-t+e*Math.log(t)-k_(e))}return 1-F_(e,t)}function F_(e,t){if(t<=0)return 1;if(t<e+1)return 1-P_(e,t);let n=t+1-e,r=1/M_,i=1/n,a=i;for(let t=1;t<N_;t++){let o=-t*(t-e);n+=2,i=o*i+n,Math.abs(i)<M_&&(i=M_),r=n+o/r,Math.abs(r)<M_&&(r=M_),i=1/i;let s=i*r;if(a*=s,Math.abs(s-1)<j_)break}return Math.exp(-t+e*Math.log(t)-k_(e))*a}function I_(e,t,n){let r=e+t,i=e+1,a=e-1,o=1,s=1-r*n/i;Math.abs(s)<M_&&(s=M_),s=1/s;let c=s;for(let l=1;l<N_;l++){let u=2*l,d=l*(t-l)*n/((a+u)*(e+u));s=1+d*s,Math.abs(s)<M_&&(s=M_),o=1+d/o,Math.abs(o)<M_&&(o=M_),s=1/s,c*=s*o,d=-(e+l)*(r+l)*n/((e+u)*(i+u)),s=1+d*s,Math.abs(s)<M_&&(s=M_),o=1+d/o,Math.abs(o)<M_&&(o=M_),s=1/s;let f=s*o;if(c*=f,Math.abs(f-1)<j_)break}return c}function L_(e,t,n){if(n<=0)return 0;if(n>=1)return 1;let r=Math.exp(k_(e+t)-k_(e)-k_(t)+e*Math.log(n)+t*Math.log1p(-n));return n<(e+1)/(e+t+2)?r*I_(e,t,n)/e:1-r*I_(t,e,1-n)/t}let R_=e=>e===0?0:(e<0?-1:1)*P_(.5,e*e),z_=e=>e<0?2-z_(-e):F_(.5,e*e),B_=e=>Math.exp(-e*e/2)/Math.sqrt(2*Math.PI),V_=e=>z_(-e/Math.SQRT2)/2,H_=(e,t)=>e.reduce((e,n)=>e*t+n,0),U_={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 W_(e){let t=e-.5;if(t===0)return 0;if(Math.abs(t)<=.425){let e=.180625-t*t;return t*H_(U_.a,e)/H_(U_.b,e)}let n=t<0?e:1-e,r=Math.sqrt(-Math.log(n)),i=r<=5?H_(U_.c,r-1.6)/H_(U_.d,r-1.6):H_(U_.e,r-5)/H_(U_.f,r-5);return t<0?-i:i}function G_(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 K_(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}let q_=4e4;function J_(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 Y_(e,t){let n=K_(n=>Math.sin(t*Math.sin(n)-e*n),0,Math.PI,q_),r=Math.asinh((760+2*e*e)/t)+2,i=e%2==0?1:-1;return(n-K_(n=>(Math.exp(e*n)+i*Math.exp(-e*n))*Math.exp(-t*Math.sinh(n)),0,r,q_))/Math.PI}function X_(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 Z_(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 Q(e,t,n,r){R(e,t,n,(...e)=>{let t=[];for(let n of e){let e=n===void 0?NaN:I(n);if(e instanceof j)return e;t.push(e)}return r(...t)})}function Q_(e,t,n,r=0){R(e,t+1,t+1+r,(...e)=>{let r=io(e[t]);if(r instanceof j)return r;let i=[];for(let[n,r]of e.entries()){if(n===t)continue;let e=r===void 0?NaN:I(r);if(e instanceof j)return e;i.push(e)}return n(r,...i)})}let $_=e=>Number.isFinite(e)?e:M.NUM;Q_(`NORM.DIST`,3,(e,t=0,n=0,r=0)=>{if(r<=0)return M.NUM;let i=(t-n)/r;return e?V_(i):B_(i)/r}),Q(`NORM.INV`,3,3,(e=0,t=0,n=0)=>e<=0||e>=1||n<=0?M.NUM:t+n*W_(e)),R(`NORM.S.DIST`,1,2,(e,t)=>{let n=I(e);if(n instanceof j)return n;let r=t===void 0||io(t);return r instanceof j?r:r?V_(n):B_(n)}),Q(`NORMSDIST`,1,1,(e=0)=>V_(e)),Q(`NORM.S.INV`,1,1,(e=0)=>e<=0||e>=1?M.NUM:W_(e)),Q_(`LOGNORM.DIST`,3,(e,t=0,n=0,r=0)=>{if(t<=0||r<=0)return M.NUM;let i=(Math.log(t)-n)/r;return e?V_(i):B_(i)/(t*r)}),Q(`LOGNORMDIST`,3,3,(e=0,t=0,n=0)=>e<=0||n<=0?M.NUM:V_((Math.log(e)-t)/n)),Q(`LOGNORM.INV`,3,3,(e=0,t=0,n=0)=>e<=0||e>=1||n<=0?M.NUM:Math.exp(t+n*W_(e))),Q(`STANDARDIZE`,3,3,(e=0,t=0,n=0)=>n<=0?M.NUM:(e-t)/n),Q(`GAUSS`,1,1,(e=0)=>V_(e)-.5),Q(`PHI`,1,1,(e=0)=>B_(e)),Q(`FISHER`,1,1,(e=0)=>e<=-1||e>=1?M.NUM:.5*Math.log((1+e)/(1-e))),Q(`FISHERINV`,1,1,(e=0)=>{let t=Math.exp(2*e);return(t-1)/(t+1)}),Q(`CONFIDENCE.NORM`,3,3,(e=0,t=0,n=0)=>{let r=Math.trunc(n);return e<=0||e>=1||t<=0||r<1?M.NUM:W_(1-e/2)*t/Math.sqrt(r)});let ev=(e,t)=>L_(t/2,.5,t/(t+e*e)),tv=(e,t)=>e<0?ev(e,t)/2:1-ev(e,t)/2;Q_(`T.DIST`,2,(e,t=0,n=0)=>{let r=Math.trunc(n);return r<1?M.NUM:e?tv(t,r):Math.exp(k_((r+1)/2)-k_(r/2))/Math.sqrt(r*Math.PI)*(1+t*t/r)**(-(r+1)/2)}),Q(`T.DIST.2T`,2,2,(e=0,t=0)=>{let n=Math.trunc(t);return e<0||n<1?M.NUM:ev(e,n)}),Q(`T.DIST.RT`,2,2,(e=0,t=0)=>{let n=Math.trunc(t);return n<1?M.NUM:e<0?1-ev(e,n)/2:ev(e,n)/2}),Q(`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?M.NUM:ev(e,r)*i/2}),Q(`T.INV`,2,2,(e=0,t=0)=>{let n=Math.trunc(t);return e<=0||e>=1||n<1?M.NUM:e===.5?0:e<.5?-nv(2*e,n):nv(2*(1-e),n)});let nv=(e,t)=>G_(e=>-ev(e,t),-e,0,1);Q(`T.INV.2T`,2,2,(e=0,t=0)=>{let n=Math.trunc(t);return e<=0||e>1||n<1?M.NUM:nv(e,n)}),Q(`CONFIDENCE.T`,3,3,(e=0,t=0,n=0)=>{let r=Math.trunc(n);return e<=0||e>=1||t<=0||r<1?M.NUM:r===1?M.DIV0:nv(e,r-1)*t/Math.sqrt(r)}),Q_(`CHISQ.DIST`,2,(e,t=0,n=0)=>{let r=Math.trunc(n);return t<0||r<1?M.NUM:e?P_(r/2,t/2):t===0?r===2?.5:r<2?M.NUM:0:Math.exp((r/2-1)*Math.log(t)-t/2-r/2*Math.LN2-k_(r/2))}),Q(`CHISQ.DIST.RT`,2,2,(e=0,t=0)=>{let n=Math.trunc(t);return e<0||n<1?M.NUM:F_(n/2,e/2)}),Q(`CHISQ.INV`,2,2,(e=0,t=0)=>{let n=Math.trunc(t);return e<0||e>=1||n<1?M.NUM:e===0?0:G_(e=>P_(n/2,e/2),e,0,n)}),Q(`CHISQ.INV.RT`,2,2,(e=0,t=0)=>{let n=Math.trunc(t);return e<=0||e>1||n<1?M.NUM:e===1?0:G_(e=>-F_(n/2,e/2),-e,0,n)});let rv=(e,t,n)=>L_(t/2,n/2,t*e/(t*e+n)),iv=(e,t,n)=>L_(n/2,t/2,n/(t*e+n));Q_(`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 M.NUM;if(e)return rv(t,i,a);if(t===0)return i===2?1:i<2?M.NUM:0;let o=k_((i+a)/2)-k_(i/2)-k_(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)}),Q(`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?M.NUM:iv(e,r,i)}),Q(`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?M.NUM:e===0?0:e===1?M.NUM:G_(e=>rv(e,r,i),e,0,1)}),Q(`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?M.NUM:e===1?0:G_(e=>-iv(e,r,i),-e,0,1)}),Q_(`GAMMA.DIST`,3,(e,t=0,n=0,r=0)=>t<0||n<=0||r<=0?M.NUM:e?P_(n,t/r):t===0?n===1?1/r:n<1?M.NUM:0:Math.exp((n-1)*Math.log(t)-t/r-n*Math.log(r)-k_(n))),Q(`GAMMA.INV`,3,3,(e=0,t=0,n=0)=>e<0||e>=1||t<=0||n<=0?M.NUM:e===0?0:n*G_(e=>P_(t,e),e,0,t));let av=(e,t,n)=>Math.exp(k_(t+n)-k_(t)-k_(n)+(t-1)*Math.log(e)+(n-1)*Math.log1p(-e));Q_(`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 M.NUM;let c=(t-o)/(s-o);return e?L_(n,r,c):av(c,n,r)/(s-o)},2),Q(`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?M.NUM:L_(t,n,(e-a)/(o-a))}),Q(`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?M.NUM:a+(o-a)*G_(e=>L_(t,n,e),e,0,.5,1)}),So(`BETAINV`,`BETA.INV`);let ov=(e,t)=>k_(e+1)-k_(t+1)-k_(e-t+1),sv=(e,t,n)=>n===0?+(e===0):n===1?+(e===t):Math.exp(ov(t,e)+e*Math.log(n)+(t-e)*Math.log1p(-n)),cv=(e,t,n)=>e>=t||n===0?1:n===1?0:1-L_(e+1,t-e,n);Q_(`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?M.NUM:e?cv(i,a,r):sv(i,a,r)}),Q(`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 M.NUM;for(let e=0;e<r;e++)if(cv(e,r,t)>=n)return e;return r}),Q(`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 M.NUM;let s=0;for(let e=a;e<=o;e++)s+=sv(e,i,t);return s}),Q_(`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?M.NUM:e?L_(a,i+1,r):r===0||r===1?+(r===1&&i===0):Math.exp(ov(i+a-1,a-1)+a*Math.log(r)+i*Math.log1p(-r))}),Q(`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?M.NUM:n===0||n===1?+(n===1&&r===0):Math.exp(ov(r+i-1,i-1)+i*Math.log(n)+r*Math.log1p(-n))}),Q_(`POISSON.DIST`,2,(e,t=0,n=0)=>{let r=Math.trunc(t);return r<0||n<0?M.NUM:n===0?e||r===0?1:0:e?F_(r+1,n):Math.exp(r*Math.log(n)-n-k_(r+1))}),Q_(`EXPON.DIST`,2,(e,t=0,n=0)=>t<0||n<=0?M.NUM:e?-Math.expm1(-n*t):n*Math.exp(-n*t)),Q_(`WEIBULL.DIST`,3,(e,t=0,n=0,r=0)=>{if(t<0||n<=0||r<=0)return M.NUM;let i=(t/r)**n;return e?-Math.expm1(-i):n/r**n*t**(n-1)*Math.exp(-i)});let lv=(e,t,n,r)=>Math.exp(ov(n,e)+ov(r-n,t-e)-ov(r,t));Q_(`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 M.NUM;if(!e)return lv(a,o,s,c);let l=0;for(let e=Math.max(0,o-c+s);e<=a;e++)l+=lv(e,o,s,c);return Math.min(1,l)}),Q(`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?M.NUM:lv(i,a,o,s)}),Q(`GAMMA`,1,1,(e=0)=>$_(A_(e))),Q(`GAMMALN`,1,1,(e=0)=>e<=0?M.NUM:k_(e)),So(`GAMMALN.PRECISE`,`GAMMALN`),Q(`ERF`,1,2,(e=0,t=NaN)=>Number.isNaN(t)?R_(e):R_(t)-R_(e)),Q(`ERFC`,1,1,(e=0)=>z_(e)),So(`ERF.PRECISE`,`ERF`),So(`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`]])So(e,t);let uv=2**48;function dv(e,t){let[n=`0`,r=`0`]=e.toExponential().split(`e`);return Number(`${n}e${String(Number(r)+t)}`)}let fv=e=>Number(e.toPrecision(15));function pv(e,t,n){let r=Math.trunc(t),i=dv(Math.abs(fv(e)),r);if(i>=2**53)return e;let a=dv(n(i),-r);return e<0?-a:a}R(`ROUND`,2,2,Do((e=0,t=0)=>pv(e,t,e=>Math.floor(e+.5)))),R(`ROUNDUP`,2,2,Do((e=0,t=0)=>pv(e,t,Math.ceil))),R(`ROUNDDOWN`,2,2,Do((e=0,t=0)=>pv(e,t,Math.floor))),R(`MOD`,2,2,Do((e=0,t=0)=>{if(t===0)return M.DIV0;let n=e%t;return n!==0&&n<0!=t<0?n+t:n})),R(`QUOTIENT`,2,2,Do((e=0,t=0)=>t===0?M.DIV0:Math.trunc(e/t))),R(`POWER`,2,2,Do((e=0,t=0)=>{if(e===0&&t===0)return M.NUM;if(e===0&&t<0)return M.DIV0;let n=e**t;return Number.isFinite(n)?n:M.NUM})),R(`LOG`,1,2,(e,t)=>{let n=I(e),r=t==null?10:I(t);return n instanceof j?n:r instanceof j?r:n<=0||r<=0?M.NUM:r===1?M.DIV0:r===10?Math.log10(n):r===2?Math.log2(n):Math.log(n)/Math.log(r)});function mv(e,t){let[n,r]=[e,t];for(;r!==0;)[n,r]=[r,n%r];return n}function hv(e,t){let n=To(e,t);if(n instanceof j)return n;let r=n.map(Math.trunc);return r.some(e=>e<0||e>=2**53)?M.NUM:r}z(`GCD`,`(r)`,(e,t)=>{let n=hv(e,t);return n instanceof j?n:n.reduce(mv,0)}),z(`LCM`,`(r)`,(e,t)=>{let n=hv(e,t);if(n instanceof j)return n;if(n.includes(0))return 0;let r=n.reduce((e,t)=>e*t/mv(e,t),1);return Number.isFinite(r)?r:M.NUM}),R(`BASE`,2,3,Do((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?M.NUM:r.toString(i).toUpperCase().padStart(a,`0`)}));let gv=[1e3,500,100,50,10,5,1];function _v(e,t){let n=e=>gv[e]??1,r=e=>`MDCLXVI`.charAt(e),i=gv.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}R(`ROMAN`,1,2,(e,t)=>{let n=I(e);if(n instanceof j)return n;let r=0;if(typeof t==`boolean`)r=t?0:4;else if(t!=null){let e=I(t);if(e instanceof j)return e;r=Math.trunc(e)}let i=Math.trunc(n);return i<0||i>3999||r<0||r>4?M.VALUE:_v(i,r)});function vv(e){return!Number.isInteger(e)||e<0||e>=uv?M.NUM:BigInt(e)}for(let[e,t]of[[`BITAND`,(e,t)=>e&t],[`BITOR`,(e,t)=>e|t],[`BITXOR`,(e,t)=>e^t]])R(e,2,2,Do((e=0,n=0)=>{let r=vv(e),i=vv(n);return r instanceof j?r:i instanceof j?i:Number(t(r,i))}));for(let[e,t]of[[`BITLSHIFT`,1],[`BITRSHIFT`,-1]])R(e,2,2,Do((e=0,n=0)=>{let r=vv(e);if(r instanceof j)return r;let i=Math.trunc(n)*t;if(Math.abs(i)>53)return M.NUM;let a=i>=0?r<<BigInt(i):r>>BigInt(-i);return a>=BigInt(uv)?M.NUM:Number(a)}));for(let[e,t,n]of[[`BESSELJ`,J_,!1],[`BESSELI`,X_,!1],[`BESSELY`,Y_,!0],[`BESSELK`,Z_,!0]])R(e,2,2,Do((e=0,r=0)=>{let i=Math.trunc(r);if(i<0||n&&e<=0)return M.NUM;let a=t(i,e);return Number.isFinite(a)?a:M.NUM}));R(`SLN`,3,3,Do((e=0,t=0,n=0)=>n===0?M.DIV0:(e-t)/n)),z(`GEOMEAN`,`(r)`,(e,t)=>{let n=To(e,t);return n instanceof j?n:n.length===0||n.some(e=>e<=0)?M.NUM:Math.exp(n.reduce((e,t)=>e+Math.log(t),0)/n.length)}),z(`HARMEAN`,`(r)`,(e,t)=>{let n=To(e,t);return n instanceof j?n:n.length===0||n.some(e=>e<=0)?M.NUM:n.length/n.reduce((e,t)=>e+1/t,0)}),z(`KURT`,`(r)`,(e,t)=>{let n=To(e,t);if(n instanceof j)return n;let r=n.length;if(r<4)return M.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 M.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 yv(e,t){let n=[],r;return wo(e,t,(e,t)=>{if(!r){if(e instanceof j)r=e;else if(typeof e==`number`)n.push(e);else if(t&&e!==null){let t=I(e);t instanceof j?r=t:n.push(t)}}}),r??n}z(`MODE.SNGL`,`(r)`,(e,t)=>{let n=yv(e,t);if(n instanceof j)return n;let r=/* @__PURE__ */ 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??M.NA}),So(`MODE`,`MODE.SNGL`),z(`MODE.MULT`,`(r)`,(e,t)=>{let n=yv(e,t);if(n instanceof j)return n;let r=/* @__PURE__ */ 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 M.NA;let a=[...r].filter(([,e])=>e===i).map(([e])=>e);return new N(a.length,1,a)});function bv(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)}z(`QUARTILE.INC`,`rv`,(e,t)=>{let n=To([e[0]],t);if(n instanceof j)return n;let r=I(t.calc.scalar(e[1],t.frame));if(r instanceof j)return r;let i=Math.trunc(r);return n.length===0||i<0||i>4?M.NUM:bv([...n].sort((e,t)=>e-t),i/4)}),So(`QUARTILE`,`QUARTILE.INC`);function xv(e,t){let n=I(t.calc.scalar(e[0],t.frame));if(n instanceof j)return n;let r=To([e[1]],t);if(r instanceof j)return r;let i=e[2]===void 0?0:I(t.calc.scalar(e[2],t.frame));if(i instanceof j)return i;let a=r.filter(e=>e===n).length;return a===0?M.NA:{before:r.filter(e=>i===0?e>n:e<n).length,ties:a}}z(`RANK.EQ`,`vr?v`,(e,t)=>{let n=xv(e,t);return n instanceof j?n:n.before+1}),z(`RANK.AVG`,`vr?v`,(e,t)=>{let n=xv(e,t);return n instanceof j?n:n.before+(n.ties+1)/2}),So(`RANK`,`RANK.EQ`);function Sv(e,t){let n=B(e,t);if(n instanceof j)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 j)return i;if(typeof i!=`number`)return M.VALUE;t.push(i)}r.push(t)}return r}let Cv=e=>new N(e.length,e[0]?.length??0,e.flat());function wv(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)))}z(`MMULT`,`rr`,(e,t)=>{let n=Sv(e[0],t),r=Sv(e[1],t);return n instanceof j?n:r instanceof j?r:(n[0]?.length??0)===r.length?Cv(wv(n,r)):M.VALUE});function Tv(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))}}let Ev=e=>e.length>0&&e.every(t=>t.length===e.length);z(`MDETERM`,`r`,(e,t)=>{let n=Sv(e[0],t);return n instanceof j?n:Ev(n)?Tv(n).determinant:M.VALUE}),z(`MINVERSE`,`r`,(e,t)=>{let n=Sv(e[0],t);if(n instanceof j)return n;if(!Ev(n))return M.VALUE;let{inverse:r}=Tv(n);return r?Cv(r):M.NUM}),R(`MUNIT`,1,1,Do((e=0)=>{let t=Math.trunc(e);return t<1||t>73?M.VALUE:Cv(Array.from({length:t},(e,n)=>Array.from({length:t},(e,t)=>+(n===t))))}));function Dv(e,t,n){let r=B(e,n),i=B(t,n);if(r instanceof j)return r;if(i instanceof j)return i;if(r.rows*r.cols!==i.rows*i.cols)return M.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 j)return n;if(s instanceof j)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]])z(e,`rr`,(e,n)=>{let r=Dv(e[0],e[1],n);return r instanceof j?r:r.xs.length===0?M.DIV0:r.xs.reduce((e,n,i)=>e+t(n,r.ys[i]??0),0)});z(`SERIESSUM`,`vvvr`,(e,t)=>{let[n,r,i]=e.slice(0,3).map(e=>I(t.calc.scalar(e,t.frame)));if(n instanceof j)return n;if(r instanceof j)return r;if(i instanceof j)return i;let a=To([e[3]],t);return a instanceof j?a:a.reduce((e,t,a)=>e+t*(n??0)**((r??0)+a*(i??0)),0)}),z(`FREQUENCY`,`rr`,(e,t)=>{let n=To([e[0]],t);if(n instanceof j)return n;let r=[];Co([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 N(a.length,1,a)}),z(`PROB`,`rrv?v`,(e,t)=>{let n=Dv(e[0],e[1],t);if(n instanceof j)return n;let r=I(t.calc.scalar(e[2],t.frame));if(r instanceof j)return r;let i=e[3]===void 0?r:I(t.calc.scalar(e[3],t.frame));if(i instanceof j)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?M.NUM:n.xs.reduce((e,t,a)=>t>=r&&t<=i?e+(n.ys[a]??0):e,0)});let Ov=e=>e.reduce((e,t)=>e+t,0);function kv(e,t,n){let r=t.map(e=>n?[...e,1]:[...e]),i=r[0]?.length??0,{inverse:a}=Tv(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 Av(e,t,n){let r=Sv(e[0],t);if(r instanceof j)return r;let i=r.length===1,a=r.flat();if(n&&a.some(e=>e<=0))return M.NUM;let o=n?a.map(Math.log):a,s=e[1];if(s===void 0||!jv(s))return{ys:o,xs:a.map((e,t)=>[t+1]),byRow:i};let c=Sv(s,t);if(c instanceof j)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}:M.REF:c.length===o.length?{ys:o,xs:c,byRow:i}:M.REF}let jv=e=>e instanceof P||e instanceof N||typeof e==`number`,Mv=(e,t)=>e===void 0||!jv(e)&&typeof e!=`boolean`||io(t.calc.scalar(e,t.frame));function Nv(e){return(t,n)=>{let r=Av(t,n,e);if(r instanceof j)return r;let i=Mv(t[3],n);if(i instanceof j)return i;let a=kv(r.ys,r.xs,i);if(!a)return M.NUM;let o=t[2],s=r.xs;if(o!==void 0&&jv(o)){let e=Sv(o,n);if(e instanceof j)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 N(1,c.length,c):new N(c.length,1,c)}}z(`TREND`,`r?rrv`,Nv(!1)),z(`GROWTH`,`r?rrv`,Nv(!0));function Pv(e,t,n,r){let i=t.map(e=>r?[...e,1]:[...e]),a=i[0]?.length??0,{inverse:o}=Tv(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?Ov(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 Fv(e){return(t,n)=>{let r=Av(t,n,e);if(r instanceof j)return r;let i=Mv(t[2],n);if(i instanceof j)return i;let a=kv(r.ys,r.xs,i);if(!a)return M.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||!Iv(c)?!1:io(n.calc.scalar(c,n.frame));if(l instanceof j)return l;if(!l)return new N(1,s.length,s);let u=Pv(r.ys,r.xs,a,i);if(!u)return M.NUM;let d=s.length,f=e=>[...e,...Array(d-e.length).fill(M.NA)],p=i?[...u.errors.slice(0,-1).reverse(),u.errors[u.errors.length-1]??0]:[...[...u.errors].reverse(),M.NA];return new N(5,d,[...s,...p,...f([u.r2,u.sey]),...f([u.f,u.df]),...f([u.ssreg,u.ssresid])])}}let Iv=e=>jv(e)||typeof e==`boolean`;z(`LINEST`,`r?rvv`,Fv(!1)),z(`LOGEST`,`r?rvv`,Fv(!0));let Lv=e=>Ov(e)/e.length,Rv=e=>{let t=Lv(e);return e.reduce((e,n)=>e+(n-t)**2,0)/(e.length-1)};z(`CHISQ.TEST`,`rr`,(e,t)=>{let n=Sv(e[0],t),r=Sv(e[1],t);if(n instanceof j)return n;if(r instanceof j)return r;let i=n.length,a=n[0]?.length??0;if(r.length!==i||(r[0]?.length??0)!==a||i*a<2)return M.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 M.NUM;if(i===0)return M.DIV0;o+=((n[e]?.[t]??0)-i)**2/i}return F_((i>1&&a>1?(i-1)*(a-1):i>1?i-1:a-1)/2,o/2)}),So(`CHITEST`,`CHISQ.TEST`),z(`T.TEST`,`rrvv`,(e,t)=>{let n=I(t.calc.scalar(e[2],t.frame)),r=I(t.calc.scalar(e[3],t.frame));if(n instanceof j)return n;if(r instanceof j)return r;let i=Math.trunc(n),a=Math.trunc(r);if(i!==1&&i!==2||a<1||a>3)return M.NUM;let o,s;if(a===1){let n=Dv(e[0],e[1],t);if(n instanceof j)return n;let r=n.xs.map((e,t)=>e-(n.ys[t]??0));if(r.length<2)return M.DIV0;o=Lv(r)/Math.sqrt(Rv(r)/r.length),s=r.length-1}else{let n=To([e[0]],t),r=To([e[1]],t);if(n instanceof j)return n;if(r instanceof j)return r;if(n.length<2||r.length<2)return M.DIV0;let[i,c,l,u]=[Rv(n),Rv(r),n.length,r.length],d=Math.abs(Lv(n)-Lv(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)?L_(s/2,.5,s/(s+o*o))*i/2:M.DIV0}),So(`TTEST`,`T.TEST`),z(`F.TEST`,`rr`,(e,t)=>{let n=To([e[0]],t),r=To([e[1]],t);if(n instanceof j)return n;if(r instanceof j)return r;if(n.length<2||r.length<2)return M.DIV0;let[i,a]=[Rv(n),Rv(r)];if(i===0||a===0)return M.DIV0;let o=i/a,[s,c]=[n.length-1,r.length-1],l=L_(c/2,s/2,c/(s*o+c));return 2*Math.min(l,1-l)}),So(`FTEST`,`F.TEST`),z(`Z.TEST`,`rv?v`,(e,t)=>{let n=To([e[0]],t);if(n instanceof j)return n;let r=I(t.calc.scalar(e[1],t.frame));if(r instanceof j)return r;if(n.length===0)return M.NA;let i=e[2]===void 0?n.length<2?M.DIV0:Math.sqrt(Rv(n)):I(t.calc.scalar(e[2],t.frame));return i instanceof j?i:i===0?M.DIV0:1-V_((Lv(n)-r)/(i/Math.sqrt(n.length)))}),So(`ZTEST`,`Z.TEST`);let zv={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`};z(`AGGREGATE`,`vv(r)`,(e,t)=>{let n=I(t.calc.scalar(e[0],t.frame)),r=I(t.calc.scalar(e[1],t.frame));if(n instanceof j)return n;if(r instanceof j)return r;let i=zv[Math.trunc(n)],a=i===void 0?void 0:_o.get(i);if(a===void 0)return M.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 or?e.parts:[e],r=[];for(let e of n)if(e instanceof P){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 N?lr(r,n.data):r.push(n)}let i=o?r:r.filter(e=>!(e instanceof j));return new N(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)}),R(`FACT`,1,1,Do(e=>{if(e<0)return M.NUM;let t=1;for(let n=2;n<=Math.trunc(e);n++)t*=n;return Number.isFinite(t)?t:M.NUM})),R(`FACTDOUBLE`,1,1,Do(e=>{if(e<0)return M.NUM;let t=1;for(let n=Math.trunc(e);n>1;n-=2)t*=n;return Number.isFinite(t)?t:M.NUM})),R(`ATAN2`,2,2,Do((e,t)=>e===0&&t===0?M.DIV0:Math.atan2(t,e)));let Bv={largest:/* @__PURE__ */ new WeakMap,smallest:/* @__PURE__ */ new WeakMap};function Vv(e,t,n){let r=()=>{let r=To([e],n);return r instanceof j?r:r.sort((e,n)=>t?n-e:e-n)};if(e instanceof P)return n.calc.indexes.ofRepeated(go(t?`large`:`small`,e),[e],()=>{let e=r();return new Map(e instanceof j?[]:[[``,e]])})?.get(``)??r();if(!(e instanceof N))return r();let i=t?Bv.largest:Bv.smallest,a=i.get(e);if(a)return a;let o=r();return o instanceof j||i.set(e,a===null?o:null),o}for(let[e,t]of[[`LARGE`,!0],[`SMALL`,!1]])z(e,`rv`,(e,n)=>{let r=Vv(e[0],t,n);if(r instanceof j)return r;let i=I(e[1]);if(i instanceof j)return i;let a=Math.ceil(i);return a<1||a>r.length?M.NUM:r[a-1]??M.NUM});let Hv=.0254,Uv=12*Hv,Wv=3*Uv,Gv=5280*Uv,Kv=1852,qv=9460730472580800,Jv=Hv/72,Yv=453.59237,Xv=9.80665,Zv=Yv/1e3*Xv,Qv=Uv*Zv,$v=231*Hv**3/128,ey=.00454609,ty=101325,ny=550*Qv,ry=/* @__PURE__ */ new Map;function $(e,t){for(let n of e)ry.set(n,t)}let iy=(e,t)=>({quantity:e,factor:t,prefix:1});$([`g`],iy(`mass`,1)),$([`sg`],{quantity:`mass`,factor:Zv*1e3/Uv}),$([`lbm`],{quantity:`mass`,factor:Yv}),$([`u`],iy(`mass`,1660538782e-33)),$([`ozm`],{quantity:`mass`,factor:Yv/16}),$([`grain`],{quantity:`mass`,factor:Yv/7e3}),$([`cwt`,`shweight`],{quantity:`mass`,factor:100*Yv}),$([`uk_cwt`,`lcwt`,`hweight`],{quantity:`mass`,factor:112*Yv}),$([`stone`],{quantity:`mass`,factor:14*Yv}),$([`ton`],{quantity:`mass`,factor:2e3*Yv}),$([`uk_ton`,`LTON`,`brton`],{quantity:`mass`,factor:2240*Yv}),$([`m`],iy(`distance`,1)),$([`mi`],{quantity:`distance`,factor:Gv}),$([`Nmi`],{quantity:`distance`,factor:Kv}),$([`in`],{quantity:`distance`,factor:Hv}),$([`ft`],{quantity:`distance`,factor:Uv}),$([`yd`],{quantity:`distance`,factor:Wv}),$([`ang`],iy(`distance`,1e-10)),$([`ell`],{quantity:`distance`,factor:45*Hv}),$([`ly`],iy(`distance`,qv)),$([`parsec`,`pc`],iy(`distance`,648e3/Math.PI*149597870700)),$([`Picapt`,`Pica`],{quantity:`distance`,factor:Jv}),$([`pica`],{quantity:`distance`,factor:Hv/6}),$([`survey_mi`],{quantity:`distance`,factor:6336e3/3937}),$([`yr`],{quantity:`time`,factor:31557600}),$([`day`,`d`],{quantity:`time`,factor:86400}),$([`hr`],{quantity:`time`,factor:3600}),$([`mn`,`min`],{quantity:`time`,factor:60}),$([`sec`,`s`],iy(`time`,1)),$([`Pa`,`p`],iy(`pressure`,1)),$([`atm`,`at`],iy(`pressure`,ty)),$([`mmHg`],iy(`pressure`,ty/760)),$([`psi`],{quantity:`pressure`,factor:Zv/Hv**2}),$([`Torr`],{quantity:`pressure`,factor:ty/760}),$([`N`],iy(`force`,1)),$([`dyn`,`dy`],iy(`force`,1e-5)),$([`lbf`],{quantity:`force`,factor:Zv}),$([`pond`],iy(`force`,Xv/1e3)),$([`J`],iy(`energy`,1)),$([`e`],iy(`energy`,1e-7)),$([`c`],iy(`energy`,4.184)),$([`cal`],iy(`energy`,4.1868)),$([`eV`,`ev`],iy(`energy`,1602176487e-28)),$([`HPh`,`hh`],{quantity:`energy`,factor:ny*3600}),$([`Wh`,`wh`],iy(`energy`,3600)),$([`flb`],{quantity:`energy`,factor:Qv}),$([`BTU`,`btu`],{quantity:`energy`,factor:1055.05585262}),$([`HP`,`h`],{quantity:`power`,factor:ny}),$([`PS`],{quantity:`power`,factor:75*Xv}),$([`W`,`w`],iy(`power`,1)),$([`T`],iy(`magnetism`,1)),$([`ga`],iy(`magnetism`,1e-4));let ay=(e,t,n=!1)=>{$(e,{quantity:`volume`,factor:t**3,...n?{prefix:3}:{}})};$([`tsp`],{quantity:`volume`,factor:$v/6}),$([`tspm`],{quantity:`volume`,factor:5e-6}),$([`tbs`],{quantity:`volume`,factor:$v/2}),$([`oz`],{quantity:`volume`,factor:$v}),$([`cup`],{quantity:`volume`,factor:8*$v}),$([`pt`,`us_pt`],{quantity:`volume`,factor:16*$v}),$([`uk_pt`],{quantity:`volume`,factor:ey/8}),$([`qt`],{quantity:`volume`,factor:32*$v}),$([`uk_qt`],{quantity:`volume`,factor:ey/4}),$([`gal`],{quantity:`volume`,factor:128*$v}),$([`uk_gal`],{quantity:`volume`,factor:ey}),$([`l`,`L`,`lt`],iy(`volume`,.001)),$([`barrel`],{quantity:`volume`,factor:5376*$v}),$([`bushel`],{quantity:`volume`,factor:2150.42*Hv**3}),$([`GRT`,`regton`],{quantity:`volume`,factor:100*Uv**3}),$([`MTON`],{quantity:`volume`,factor:40*Uv**3}),ay([`m3`,`m^3`],1,!0),ay([`ang3`,`ang^3`],1e-10,!0),ay([`ft3`,`ft^3`],Uv),ay([`in3`,`in^3`],Hv),ay([`ly3`,`ly^3`],qv),ay([`mi3`,`mi^3`],Gv),ay([`yd3`,`yd^3`],Wv),ay([`Nmi3`,`Nmi^3`],Kv),ay([`Pica3`,`Picapt3`,`Pica^3`,`Picapt^3`],Jv);let oy=(e,t,n=!1)=>{$(e,{quantity:`area`,factor:t**2,...n?{prefix:2}:{}})};$([`uk_acre`],{quantity:`area`,factor:4840*Wv**2}),$([`us_acre`],{quantity:`area`,factor:43560*(1200/3937)**2}),$([`ar`],iy(`area`,100)),$([`ha`],{quantity:`area`,factor:1e4}),$([`Morgen`],{quantity:`area`,factor:2500}),oy([`m2`,`m^2`],1,!0),oy([`ang2`,`ang^2`],1e-10,!0),oy([`ft2`,`ft^2`],Uv),oy([`in2`,`in^2`],Hv),oy([`ly2`,`ly^2`],qv),oy([`mi2`,`mi^2`],Gv),oy([`yd2`,`yd^2`],Wv),oy([`Nmi2`,`Nmi^2`],Kv),oy([`Pica2`,`Picapt2`,`Pica^2`,`Picapt^2`],Jv),$([`bit`],{quantity:`information`,factor:1,prefix:1,binary:!0}),$([`byte`],{quantity:`information`,factor:8,prefix:1,binary:!0}),$([`admkn`],{quantity:`speed`,factor:6080*Uv/3600}),$([`kn`],{quantity:`speed`,factor:Kv/3600}),$([`m/h`,`m/hr`],iy(`speed`,1/3600)),$([`m/s`,`m/sec`],iy(`speed`,1)),$([`mph`],{quantity:`speed`,factor:Gv/3600});let sy={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},cy={Yi:2**80,Zi:2**70,Ei:2**60,Pi:2**50,Ti:2**40,Gi:2**30,Mi:2**20,ki:1024},ly={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}},uy={C:`C`,cel:`C`,F:`F`,fah:`F`,K:`K`,kel:`K`,Rank:`Rank`,Reau:`Reau`};function dy(e){let t=uy[e];if(t!==void 0)return{kind:`temperature`,scale:t,times:1};let n=ry.get(e);if(n)return{kind:`unit`,quantity:n.quantity,factor:n.factor};for(let[t,n]of Object.entries(sy)){if(!e.startsWith(t))continue;let r=e.slice(t.length);if(uy[r]===`K`)return{kind:`temperature`,scale:`K`,times:n};let i=ry.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(cy)){if(!e.startsWith(t))continue;let r=ry.get(e.slice(t.length));if(r?.binary===!0)return{kind:`unit`,quantity:r.quantity,factor:r.factor*n}}}function fy(e,t,n){let r=dy(t),i=dy(n);if(!r||!i)return M.NA;if(r.kind===`temperature`||i.kind===`temperature`){if(r.kind!==`temperature`||i.kind!==`temperature`)return M.NA;let t=ly[r.scale],n=ly[i.scale];return!t||!n?M.NA:n.fromK(t.toK(e*r.times))/i.times}return r.quantity===i.quantity?e*r.factor/i.factor:M.NA}R(`CONVERT`,3,3,(e,t,n)=>{let r=I(e),i=L(t),a=L(n);return r instanceof j?r:i instanceof j?i:a instanceof j?a:fy(r,i,a)});let py=5e6,my=e=>Array.from({length:e.rows},(t,n)=>Array.from({length:e.cols},(t,r)=>e.at(n,r))),hy=e=>{let t=e[0]?.length??0;return new N(e.length,t,e.flat())},gy=e=>{let t=e[0]?.length??0;return Array.from({length:t},(t,n)=>e.map(e=>e[n]??null))};function _y(e,t){if(!(e===void 0||e instanceof F))return t.calc.scalar(e,t.frame)}function vy(e,t,n){let r=_y(e,t);return r==null?n:I(r)}function yy(e,t,n){let r=_y(e,t);return r==null?n:io(r)}function by(e,t,n){if(e===void 0||e instanceof F)return[n];let r=B(e,t);if(r instanceof j)return r;let i=[];for(let e=0;e<r.rows;e++)for(let t=0;t<r.cols;t++){let n=I(r.at(e,t));if(n instanceof j)return n;i.push(Math.trunc(n))}return i}let xy=e=>e===null||e===``;function Sy(e,t,n){if(xy(e)||xy(t))return xy(e)&&xy(t)?0:xy(e)?1:-1;let r=Qo(e,t);return n?-r:r}function Cy(e){return e instanceof j?e:e===null?!1:typeof e==`boolean`?e:typeof e==`number`?e!==0:M.VALUE}z(`FILTER`,`rr?r`,(e,t)=>{let n=B(e[0],t),r=B(e[1],t);if(n instanceof j)return n;if(r instanceof j)return r;if(r.rows>1&&r.cols>1)return M.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 M.VALUE;let a=my(n),o=i?a:gy(a),s=[];for(let e=0;e<o.length;e++){let t=Cy(i?r.at(e,0):r.at(0,e));if(t instanceof j)return t;t&&s.push(o[e]??[])}return s.length===0?e[2]===void 0||e[2]instanceof F?M.CALC:e[2]:hy(i?s:gy(s))}),z(`SORT`,`r?rrr`,(e,t)=>{let n=B(e[0],t);if(n instanceof j)return n;let r=by(e[1],t,1);if(r instanceof j)return r;let i=by(e[2],t,1);if(i instanceof j)return i;let a=yy(e[3],t,!1);if(a instanceof j)return a;let o=my(n),s=a?gy(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 M.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=Sy(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 hy(a?gy(l):l)}),z(`SORTBY`,`r(r)`,(e,t)=>{let n=B(e[0],t);if(n instanceof j)return n;let r=[],i;for(let a=1;a<e.length;a+=2){let o=B(e[a],t);if(o instanceof j)return o;if(o.rows>1&&o.cols>1)return M.VALUE;let s=o.cols===1&&o.rows===n.rows,c=o.rows===1&&o.cols===n.cols;if(!s&&!c)return M.VALUE;let l=i??s;if(l?!s:!c)return M.VALUE;i=l;let u=vy(e[a+1],t,1);if(u instanceof j)return u;if(u!==1&&u!==-1)return M.VALUE;r.push({values:my(o).flat(),descending:u<0})}let a=my(n),o=(i===!1?gy(a):a).map((e,t)=>({line:e,index:t})).sort((e,t)=>{for(let{values:n,descending:i}of r){let r=Sy(n[e.index]??null,n[t.index]??null,i);if(r!==0)return r}return e.index-t.index}).map(e=>e.line);return hy(i===!1?gy(o):o)});let wy=e=>e instanceof j?`e${e.code}`:typeof e==`string`?`s${e.toLowerCase()}`:`${typeof e}${String(e)}`;z(`UNIQUE`,`r?rr`,(e,t)=>{let n=B(e[0],t);if(n instanceof j)return n;let r=yy(e[1],t,!1);if(r instanceof j)return r;let i=yy(e[2],t,!1);if(i instanceof j)return i;let a=my(n),o=(n.reference?.rows??n.rows)-n.rows,s=e=>Array(e).fill(null);if(o>0&&r&&(a.length+o)*n.cols<=py)for(let e=0;e<o;e++)a.push(s(n.cols));let c=r?gy(a):a,l=/* @__PURE__ */ new Map,u=(e,t)=>{let n=e.map(wy).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?M.CALC:hy(r?gy(d):d)});function Ty(e,t){if(e instanceof j)return e;if(t instanceof j)return t;let n=Math.trunc(e),r=Math.trunc(t);return n<0||r<0?M.VALUE:n===0||r===0?M.CALC:n>1048576||r>16384||n*r>py?M.VALUE:{rows:n,cols:r}}z(`SEQUENCE`,`r?rrr`,(e,t)=>{let n=Ty(vy(e[0],t,1),vy(e[1],t,1));if(n instanceof j)return n;let r=vy(e[2],t,1);if(r instanceof j)return r;let i=vy(e[3],t,1);if(i instanceof j)return i;let a=Array(n.rows*n.cols);for(let e=0;e<a.length;e++)a[e]=r+e*i;return new N(n.rows,n.cols,a)}),z(`RANDARRAY`,`?rrrrr`,(e,t)=>{let n=Ty(vy(e[0],t,1),vy(e[1],t,1));if(n instanceof j)return n;let r=vy(e[2],t,0);if(r instanceof j)return r;let i=vy(e[3],t,1);if(i instanceof j)return i;let a=yy(e[4],t,!1);if(a instanceof j)return a;if(r>i||a&&(!Number.isInteger(r)||!Number.isInteger(i)))return M.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 N(n.rows,n.cols,o)},{volatile:!0}),z(`TEXTSPLIT`,`vr?rvvv`,(e,t)=>{let n=_y(e[0],t);if(n instanceof j)return n;let r=L(n??``);if(r instanceof j)return r;let i=Bs(e[1],t);if(i instanceof j)return i;let a=Bs(e[2],t);if(a instanceof j)return a;if(i.length===0&&a.length===0||i.includes(``)||a.includes(``))return M.VALUE;let o=yy(e[3],t,!1);if(o instanceof j)return o;let s=vy(e[4],t,0);if(s instanceof j)return s;let c=_y(e[5],t)??M.NA,l=s===1,u=(a.length===0?[r]:Hs(r,a,l)).filter(e=>!(o&&e===``)).map(e=>{let t=i.length===0?[e]:Hs(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?M.CALC:hy(u.map(e=>Array.from({length:d},(t,n)=>e[n]??c)))});let Ey=(e,t)=>{let n=t.calc.flat(e);return n instanceof N?n.at(0,0):n};z(`MAP`,`r(r)`,(e,t)=>{let n=e[e.length-1];if(!(n instanceof sr))return M.VALUE;let r=[];for(let n of e.slice(0,-1)){let e=B(n,t);if(e instanceof j)return e;r.push(e)}let i=r[0];if(!i)return M.VALUE;let{rows:a,cols:o}=i;if(r.some(e=>e.rows!==a||e.cols!==o))return M.VALUE;let s=Array(a*o);for(let e=0;e<a;e++)for(let i=0;i<o;i++)s[e*o+i]=Ey(t.calc.apply(n,r.map(t=>t.at(e,i))),t);return new N(a,o,s)});function Dy(e,t){let n=e.length===3,r=e[e.length-1];if(!(r instanceof sr))return M.VALUE;let i=B(e[+!!n],t);return i instanceof j?i:{start:n?_y(e[0],t)??null:i.at(0,0),cells:i,fn:r}}z(`REDUCE`,`rr?r`,(e,t)=>{let n=Dy(e,t);if(n instanceof j)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=Ey(t.calc.apply(i,[o,r.at(Math.floor(e/r.cols),e%r.cols)]),t);return o}),z(`SCAN`,`rr?r`,(e,t)=>{let n=Dy(e,t);if(n instanceof j)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=Ey(t.calc.apply(i,[c,r.at(Math.floor(e/r.cols),e%r.cols)]),t),s[e]=c;return new N(r.rows,r.cols,s)});let Oy=e=>(t,n)=>{let r=B(t[0],n);if(r instanceof j)return r;let i=t[1];if(!(i instanceof sr))return M.VALUE;let a=my(r),o=(e?a:gy(a)).map(t=>Ey(n.calc.apply(i,[e?new N(1,t.length,t):new N(t.length,1,t)]),n));return e?new N(o.length,1,o):new N(1,o.length,o)};z(`BYROW`,`rr`,Oy(!0)),z(`BYCOL`,`rr`,Oy(!1)),z(`MAKEARRAY`,`rrr`,(e,t)=>{let n=Ty(vy(e[0],t,1),vy(e[1],t,1));if(n instanceof j)return n;let r=e[2];if(!(r instanceof sr))return M.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]=Ey(t.calc.apply(r,[e+1,a+1]),t);return new N(n.rows,n.cols,i)});function ky(e){return(t,n)=>{let r=[];for(let i of t){let t=B(i,n);if(t instanceof j)return t;let a=my(t);r.push(e?a:gy(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:M.NA)));return a.length===0?M.CALC:hy(e?a:gy(a))}}z(`VSTACK`,`(r)`,ky(!0)),z(`HSTACK`,`(r)`,ky(!1));function Ay(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 jy(e){return(t,n)=>{let r=B(t[0],n);if(r instanceof j)return r;let i=e=>e===void 0||e instanceof F,a=vy(t[1],n,e?r.rows:0);if(a instanceof j)return a;let o=vy(t[2],n,e?r.cols:0);if(o instanceof j)return o;if(e&&!i(t[1])&&Math.trunc(a)===0||e&&!i(t[2])&&Math.trunc(o)===0)return M.CALC;let[s,c]=Ay(r.rows,Math.trunc(a),e),[l,u]=Ay(r.cols,Math.trunc(o),e);return c<=s||u<=l?M.CALC:hy(my(r).slice(s,c).map(e=>e.slice(l,u)))}}z(`TAKE`,`rr?r`,jy(!0)),z(`DROP`,`rr?r`,jy(!1));function My(e){return(t,n)=>{let r=B(t[0],n);if(r instanceof j)return r;let i=vy(t[1],n,0);if(i instanceof j)return i;let a=yy(t[2],n,!1);if(a instanceof j)return a;if(![0,1,2,3].includes(i))return M.VALUE;let o=my(r),s=(a?gy(o):o).flat().filter(e=>!((i===1||i===3)&&e===null||(i===2||i===3)&&e instanceof j));return s.length===0?M.CALC:e?new N(s.length,1,s):new N(1,s.length,s)}}z(`TOCOL`,`r?rr`,My(!0)),z(`TOROW`,`r?rr`,My(!1));function Ny(e){return(t,n)=>{let r=B(t[0],n);if(r instanceof j)return r;let i=my(r),a=e?i:gy(i),o=[];for(let e of t.slice(1)){let t=by(e,n,1);if(t instanceof j)return t;for(let e of t){let t=a[e>0?e-1:a.length+e];if(e===0||!t)return M.VALUE;o.push(t)}}return hy(e?o:gy(o))}}z(`CHOOSEROWS`,`r(r)`,Ny(!0)),z(`CHOOSECOLS`,`r(r)`,Ny(!1)),z(`EXPAND`,`rr?rr`,(e,t)=>{let n=B(e[0],t);if(n instanceof j)return n;let r=Ty(vy(e[1],t,n.rows),vy(e[2],t,n.cols));if(r instanceof j)return r;if(r.rows<n.rows||r.cols<n.cols)return M.VALUE;let i=_y(e[3],t)??M.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 N(r.rows,r.cols,a)});function Py(e){return(t,n)=>{let r=B(t[0],n);if(r instanceof j)return r;if(r.rows>1&&r.cols>1)return M.VALUE;let i=vy(t[1],n,1);if(i instanceof j)return i;let a=Math.trunc(i);if(a<1)return M.NUM;let o=_y(t[2],n)??M.NA,s=my(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 hy(e?c:gy(c))}}z(`WRAPROWS`,`rr?r`,Py(!0)),z(`WRAPCOLS`,`rr?r`,Py(!1));function Fy(e,t,n){let r=L(e);if(r instanceof j)return r;let i=t==null?0:I(t);if(i instanceof j)return i;if(i!==0&&i!==1)return M.VALUE;try{return new RegExp(r,`${i===1?`i`:``}${n?`g`:``}`)}catch{return M.VALUE}}R(`REGEXTEST`,2,3,(e,t,n)=>{let r=L(e);if(r instanceof j)return r;let i=Fy(t,n,!1);return i instanceof j?i:i.test(r)}),z(`REGEXEXTRACT`,`vv?vv`,(e,t)=>{let n=L(e[0]instanceof F?null:e[0]);if(n instanceof j)return n;let r=vy(e[2],t,0);if(r instanceof j)return r;let i=e[3]instanceof F?void 0:e[3],a=Fy(e[1],i,r===1);if(a instanceof j)return a;if(r===0)return a.exec(n)?.[0]??M.NA;if(r===1){let e=[...n.matchAll(a)].map(e=>e[0]);return e.length===0?M.NA:new N(e.length,1,e)}if(r===2){let e=a.exec(n);if(!e)return M.NA;let t=e.slice(1).map(e=>e??``);return t.length===0?M.NA:new N(1,t.length,t)}return M.VALUE}),R(`REGEXREPLACE`,3,5,(e,t,n,r,i)=>{let a=L(e),o=L(n);if(a instanceof j)return a;if(o instanceof j)return o;let s=r==null?0:I(r);if(s instanceof j)return s;let c=Fy(t,i,!0);if(c instanceof j)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)}),z(`PERCENTOF`,`rr`,(e,t)=>{let n=_o.get(`SUM`);if(!n)return M.NAME;let r=I(Ey(t.calc.applyFunction(n,[e[0]],t.frame),t)),i=I(Ey(t.calc.applyFunction(n,[e[1]],t.frame),t));return r instanceof j?r:i instanceof j?i:i===0?M.DIV0:r/i}),z(`TRIMRANGE`,`r?vv`,(e,t)=>{let n=e[0];if(!(n instanceof P))return n instanceof j?n:M.VALUE;let r=vy(e[1],t,3),i=vy(e[2],t,3);if(r instanceof j)return r;if(i instanceof j)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?M.REF:new P(n.sheet,n.top+c,n.left+u,n.top+l,n.left+d)});function Iy(e,t,n){let r=/* @__PURE__ */ new Map;for(let i of n){let n=e[i]?.[t]??null,a=wy(n),o=r.get(a);o?o.records.push(i):r.set(a,{key:n,records:[i],children:[]})}return[...r.values()]}function Ly(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?Sy(e.key,n.key,r.down):0:Sy(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=/* @__PURE__ */ new Map;for(let i of n){let n=(e[i]??[]).slice(0,t).map(wy).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?Sy(e[t.records[0]??0]?.[r.field]??null,e[n.records[0]??0]?.[r.field]??null,r.down):Sy(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(Iy(e,i+1,u.records),i+1,n),d&&!c&&s.push(o)}};r(Iy(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 Ry(e,t,n,r){let i=e=>new N(e.length,1,[...e]),a=e.named===void 0?void 0:_o.get(e.named),o=(a?a.min>=2:e.params.length>=2)?[i(t),i(n)]:[i(t)];return Ey(r.calc.apply(e,o),r)}function zy(e,t,n){if(e===void 0||e instanceof F){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=vy(e,n,0);return r instanceof j?r:[0,1,2,3].includes(r)?{has:r===1||r===3,show:r===2||r===3,named:r===2}:M.VALUE}function By(e,t,n,r){let i=Array.from({length:t},(e,t)=>t);if(e===void 0||e instanceof F)return i;let a=B(e,r);if(a instanceof j)return a;if(a.rows*a.cols!==t+n)return M.VALUE;let o=[];for(let e of i){let t=e+n,r=Cy(a.cols===1?a.at(t,0):a.at(0,t));if(r instanceof j)return r;r&&o.push(e)}return o}function Vy(e,t,n,r){let i=e===void 0||e instanceof F?[]:by(e,r,1);if(i instanceof j)return i;let a=[];for(let e of i){let r=Math.abs(e)-1,i=e<0;if(r<0)return M.VALUE;if(r<t)a.push({field:r,down:i});else{let e=n(r-t);if(!e)return M.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}let Hy=(e,t,n)=>vy(e,t,n);z(`GROUPBY`,`rrr?vvrrv`,(e,t)=>{let n=B(e[0],t),r=B(e[1],t),i=e[2];if(n instanceof j)return n;if(r instanceof j)return r;if(!(i instanceof sr)||n.rows!==r.rows)return M.VALUE;let a=n.cols===0?[]:my(n),o=my(r),s=zy(e[3],o,t);if(s instanceof j)return s;let c=+!!s.has,l=a.slice(c),u=o.slice(c),d=Hy(e[4],t,1);if(d instanceof j)return d;let f=vy(e[7],t,0);if(f instanceof j)return f;let p=By(e[6],l.length,c,t);if(p instanceof j)return p;if(p.length===0)return M.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),y=(e,n)=>Ry(i,n.map(t=>_[e]?.[t]??null),v(e),t),b=Vy(e[5],m,e=>e<h?t=>y(e,t):void 0,t);if(b instanceof j)return b;let x=Ly(l,m,p,d,b,f===1),S=[];s.show&&S.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 x)S.push([...e.keys,...Array.from({length:h},(t,n)=>y(n,e.records))]);return hy(S)}),z(`PIVOTBY`,`rrrr?vvrvrrv`,(e,t)=>{let n=B(e[0],t),r=B(e[1],t),i=B(e[2],t),a=e[3];if(n instanceof j)return n;if(r instanceof j)return r;if(i instanceof j)return i;if(!(a instanceof sr)||n.rows!==i.rows||r.rows!==i.rows)return M.VALUE;let o=my(n),s=my(r),c=my(i),l=zy(e[4],c,t);if(l instanceof j)return l;let u=+!!l.has,d=o.slice(u),f=s.slice(u),p=c.slice(u),m=Hy(e[5],t,1),h=Hy(e[7],t,1),g=vy(e[10],t,0);if(m instanceof j)return m;if(h instanceof j)return h;if(g instanceof j)return g;let _=By(e[9],p.length,u,t);if(_ instanceof j)return _;if(_.length===0)return M.CALC;let v=i.cols,y=Vy(e[6],n.cols,()=>void 0,t),b=Vy(e[8],r.cols,()=>void 0,t);if(y instanceof j)return y;if(b instanceof j)return b;let x=Ly(d,n.cols,_,m,y,!1),S=Ly(f,r.cols,_,h,b,!1),ee=(e,t)=>{let n=new Set(t);return e.filter(e=>n.has(e))},C=(e,t)=>p[t]?.[e]??null,te=(e,n,r)=>{let i=ee(n.records,r.records);if(i.length===0)return null;let o=g===1?n.records:g===2?_:r.records;return Ry(a,i.map(t=>C(e,t)),o.map(t=>C(e,t)),t)},ne=n.cols,w=[];for(let e=0;e<r.cols;e++)w.push([...Array(ne).fill(null),...S.flatMap(t=>Array.from({length:v},(n,r)=>r===0?t.keys[e]??null:null))]);(v>1||l.show)&&w.push([...Array.from({length:ne},(e,t)=>l.show?o[0]?.[t]??null:null),...S.flatMap(()=>Array.from({length:v},(e,t)=>l.has?c[0]?.[t]??null:`Value ${String(t+1)}`))]);for(let e of x)w.push([...e.keys,...S.flatMap(t=>Array.from({length:v},(n,r)=>te(r,e,t)))]);return hy(w)});let Uy=(e,t)=>Gn(Wn(e,t+1,0)).day,Wy=(e,t,n)=>n===0||n===4?Math.round(sc(e,t,n)*360):t-e;function Gy(e,t,n){let r=Gn(e),i=r.year*12+r.month-1+t,a=Math.floor(i/12),o=i-a*12+1,s=Uy(a,o);return Wn(a,o,n?s:Math.min(r.day,s))}let Ky=e=>{let t=Gn(e);return t.day===Uy(t.year,t.month)};function qy(e,t,n,r){let i=12/n,a=Ky(t),o=0,s=t;for(;s>e;)o+=1,s=Gy(t,-i*o,a);let c=Gy(t,-i*(o-1),a),l=r===1?c-s:r===3?365/n:360/n,u=Wy(s,e,r);return{previous:s,next:c,count:o,period:l,since:u,until:r===0||r===4?l-u:c-e}}function Jy(e,t){let n=[];for(let[r,i]of t.entries()){let t=e[r],a=t==null?i??0:I(t);if(a instanceof j)return a;n.push(a)}return n}let Yy=e=>Number.isInteger(e)&&e>=0&&e<=4,Xy=e=>e===1||e===2||e===4;function Zy(e,t,n,r){R(e,t,n.length,(...e)=>{let t=Jy(e,n);if(t instanceof j)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||!Yy(l)?M.NUM:r(s,c,...o.slice(0,-1),l)})}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]])Zy(e,3,[void 0,void 0,void 0,0],(e,n,r=0,i=0)=>Xy(r)?t(qy(e,n,r,i)):M.NUM);function Qy(e,t,n,r,i,a,o){let s=qy(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}Zy(`PRICE`,6,[void 0,void 0,void 0,void 0,void 0,void 0,0],(e,t,n=0,r=0,i=0,a=0,o=0)=>n<0||r<0||i<=0||!Xy(a)?M.NUM:Qy(e,t,n,r,i,a,o)),Zy(`YIELD`,6,[void 0,void 0,void 0,void 0,void 0,void 0,0],(e,t,n=0,r=0,i=0,a=0,o=0)=>{if(n<0||r<=0||i<=0||!Xy(a))return M.NUM;let s=-.99,c=1;for(;Qy(e,t,n,c,i,a,o)>r&&c<1e6;)c*=2;for(let l=0;l<200;l++){let l=(s+c)/2;Qy(e,t,n,l,i,a,o)>r?s=l:c=l}return(s+c)/2});function $y(e,t,n,r,i,a){let o=qy(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}Zy(`DURATION`,5,[void 0,void 0,void 0,void 0,void 0,0],(e,t,n=0,r=0,i=0,a=0)=>n<0||r<0||!Xy(i)?M.NUM:$y(e,t,n,r,i,a)),Zy(`MDURATION`,5,[void 0,void 0,void 0,void 0,void 0,0],(e,t,n=0,r=0,i=0,a=0)=>n<0||r<0||!Xy(i)?M.NUM:$y(e,t,n,r,i,a)/(1+r/i)),Zy(`DISC`,4,[void 0,void 0,void 0,void 0,0],(e,t,n=0,r=0,i=0)=>n<=0||r<=0?M.NUM:(r-n)/r/sc(e,t,i)),Zy(`INTRATE`,4,[void 0,void 0,void 0,void 0,0],(e,t,n=0,r=0,i=0)=>n<=0||r<=0?M.NUM:(r-n)/n/sc(e,t,i)),Zy(`RECEIVED`,4,[void 0,void 0,void 0,void 0,0],(e,t,n=0,r=0,i=0)=>{let a=1-r*sc(e,t,i);return n<=0||r<=0||a<=0?M.NUM:n/a}),Zy(`PRICEDISC`,4,[void 0,void 0,void 0,void 0,0],(e,t,n=0,r=0,i=0)=>n<=0||r<=0?M.NUM:r*(1-n*sc(e,t,i))),Zy(`YIELDDISC`,4,[void 0,void 0,void 0,void 0,0],(e,t,n=0,r=0,i=0)=>n<=0||r<=0?M.NUM:(r-n)/n/sc(e,t,i));function eb(e,t){R(e,3,3,Do((e=0,n=0,r=0)=>{let i=Math.trunc(e),a=Math.trunc(n);return i>=a||r<=0||a>Gy(i,12,!1)?M.NUM:t(a-i,r)}))}eb(`TBILLPRICE`,(e,t)=>{let n=100*(1-t*e/360);return n<=0?M.NUM:n}),eb(`TBILLYIELD`,(e,t)=>(100-t)/t*360/e),eb(`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)}),R(`ACCRINTM`,3,5,(...e)=>{let t=Jy(e,[void 0,void 0,void 0,1e3,0]);if(t instanceof j)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||!Yy(o)?M.NUM:a*i*sc(s,c,o)}),R(`ACCRINT`,6,8,(...e)=>{let t=Jy(e.slice(0,7),[void 0,void 0,void 0,void 0,1e3,void 0,0]);if(t instanceof j)return t;let[n=0,r=0,i=0,a=0,o=0,s=0,c=0]=t,l=e[7]===void 0||io(e[7]);if(l instanceof j)return l;let u=Math.trunc(n),d=Math.trunc(i),f=Math.trunc(r);if(u>=d||a<=0||o<=0||!Xy(s)||!Yy(c))return M.NUM;let p=12/s,m=f,h=f;for(let e=1;m>u;e++)m=Gy(f,-p*e,!1);let g=0;for(;m<d;){h=Gy(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+=Wy(e,t,c)/n),m=h}return o*a*g/s});let tb=(e,t)=>(1+e)**t,nb=e=>e===0?0:1,rb=e=>Number.isFinite(e)?e:M.NUM;function ib(e,t,n,r,i){if(e===0)return-(n+r)/t;let a=tb(e,t);return-(n*a+r)*e/((1+e*i)*(a-1))}function ab(e,t,n,r,i){if(e===0)return-(r+n*t);let a=tb(e,t);return-(r*a+n*(1+e*i)*(a-1)/e)}function ob(e,t,n,r,i,a){if(t<1||t>n)return M.NUM;if(a===1&&t===1)return 0;let o=ib(e,n,r,i,a),s=a===1?ab(e,t-2,o,r,1)-o:ab(e,t-1,o,r,0);return rb(s*e)}R(`PMT`,3,5,Do((e,t,n,r=0,i=0)=>t===0?M.NUM:rb(ib(e,t,n,r,nb(i))))),R(`FV`,3,5,Do((e,t,n,r=0,i=0)=>rb(ab(e,t,n,r,nb(i))))),R(`IPMT`,4,6,Do((e,t,n,r,i=0,a=0)=>ob(e,t,n,r,i,nb(a)))),R(`PPMT`,4,6,Do((e,t,n,r,i=0,a=0)=>{let o=nb(a),s=ob(e,t,n,r,i,o);return s instanceof j?s:rb(ib(e,n,r,i,o)-s)})),R(`DB`,4,5,Do((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 M.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 rb(c)})),R(`VDB`,5,7,(...e)=>{let t=Jy(e.slice(0,6),[void 0,void 0,void 0,void 0,void 0,2]);if(t instanceof j)return t;let[n=0,r=0,i=0,a=0,o=0,s=0]=t,c=e[6]!==void 0&&io(e[6]);if(c instanceof j)return c;if(n<0||r<0||i<=0||a<0||o>i||a>o||s<=0)return M.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});let sb=(e,t,n,r,i)=>({whole:sc(n,t,i),accrued:sc(n,e,i),left:sc(e,t,i),rate:r});Zy(`PRICEMAT`,5,[void 0,void 0,void 0,void 0,void 0,0],(e,t,n=0,r=0,i=0,a=0)=>{let o=Math.trunc(n);if(o>=e||r<0||i<0)return M.NUM;let{whole:s,accrued:c,left:l}=sb(e,t,o,r,a);return(100+s*r*100)/(1+l*i)-c*r*100}),Zy(`YIELDMAT`,5,[void 0,void 0,void 0,void 0,void 0,0],(e,t,n=0,r=0,i=0,a=0)=>{let o=Math.trunc(n);if(o>=e||r<0||i<=0)return M.NUM;let{whole:s,accrued:c,left:l}=sb(e,t,o,r,a);return((1+s*r)/(i/100+c*r)-1)/l});function cb(e,t,n,r,i){let a=12/r,o=Ky(t),s={held:0,accrued:0,left:0,count:0},c=0,l=t;for(;l>e;){c+=1;let u=Gy(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?Wy(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 lb(e,t,n,r,i,a,o,s,c){let l=100*i/s,u=qy(r,t,s,c).count+1,d=cb(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 ub(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 db(e,t){R(e,8,9,(...e)=>{let n=Jy(e,[void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,0]);if(n instanceof j)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!Yy(d)||!Xy(u)||!(p>h&&h>f&&f>m)||s<0||c<0||l<=0?M.NUM:t(e=>lb(f,p,m,h,s,e,l,u,d),c)})}db(`ODDFPRICE`,(e,t)=>e(t)),db(`ODDFYIELD`,(e,t)=>ub(e,t,.1)??M.NUM);function fb(e,t){R(e,7,8,(...e)=>{let n=Jy(e,[void 0,void 0,void 0,void 0,void 0,void 0,void 0,0]);if(n instanceof j)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!Yy(u)||!Xy(l)||!(f>d&&d>p)||o<0||s<0||c<=0?M.NUM:t({odd:cb(p,f,d,l,u),coupon:100*o/l,last:s,red:c,f:l})})}fb(`ODDLPRICE`,({odd:e,coupon:t,last:n,red:r,f:i})=>(r+e.held*t)/(1+e.left*n/i)-e.accrued*t),fb(`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}),R(`AMORLINC`,6,7,(...e)=>{let t=Jy(e,[void 0,void 0,void 0,void 0,void 0,void 0,0]);if(t instanceof j)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(!Yy(c)||c===2||n<0||a<0||a>n||l<0||s<=0||r>i)return M.NUM;let u=n*s,d=sc(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}),R(`AMORDEGRC`,6,7,(...e)=>{let t=Jy(e,[void 0,void 0,void 0,void 0,void 0,void 0,0]);if(t instanceof j)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(!Yy(c)||c===2||n<0||a<0||a>n||l<0||s<=0||r>i)return M.NUM;let u=1/s,d=s*(u<3?1:u<5?1.5:u<=6?2:2.5),f=Math.round(sc(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 pb(e,t){let n=[];for(let t=0;t<e.cols;t++){let r=L(e.at(0,t));if(r instanceof j)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=L(t.at(0,a));if(c instanceof j)return c;let l=n.indexOf(c.toLowerCase());if(l<0){o=!1;continue}let u=Lo(s);if(u instanceof j)return u;u.test(e.at(i,l))||(o=!1)}o&&(a=!0)}a&&r.push(i)}return r}function mb(e,t){if(typeof t==`number`){let n=Math.trunc(t)-1;return n<0||n>=e.cols?M.VALUE:n}let n=L(t);if(n instanceof j)return n;for(let t=0;t<e.cols;t++){let r=e.at(0,t);if(typeof r==`string`&&so(r,n)===0)return t}return M.VALUE}function hb(e,t){let n=B(e[0],t);if(n instanceof j)return n;let r=B(e[2],t);if(r instanceof j)return r;let i=pb(n,r);if(i instanceof j)return i;let a=e[1];if(a===void 0)return{list:i.map(()=>null),db:n};let o=mb(n,t.calc.scalar(a,t.frame));return o instanceof j?o:{list:i.map(e=>n.at(e,o)),db:n}}function gb(e,t){z(e,`rvr`,(e,n)=>{let r=hb(e,n);if(r instanceof j)return r;let i=_o.get(t);if(i?.kind!==`raw`)return M.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`]])gb(e,t);for(let[e,t]of[[`DAVERAGE`,`AVERAGE`],[`DSTDEV`,`STDEV.S`],[`DSTDEVP`,`STDEV.P`],[`DVAR`,`VAR.S`],[`DVARP`,`VAR.P`]])z(e,`rvr`,(e,n)=>{let r=hb(e,n);if(r instanceof j)return r;let i=_o.get(t);if(i?.kind!==`raw`)return M.VALUE;let a=r.list.filter(e=>typeof e==`number`);return a.length===0?M.DIV0:i.call(a,n)});z(`DCOUNT`,`rv?r`,(e,t)=>{let n=hb(e.length===2?[e[0],void 0,e[1]]:e,t);return n instanceof j?n:n.list.filter(e=>typeof e==`number`).length}),z(`DCOUNTA`,`rv?r`,(e,t)=>{let n=hb(e.length===2?[e[0],void 0,e[1]]:e,t);return n instanceof j?n:n.list.filter(e=>e!==null).length}),z(`DGET`,`rvr`,(e,t)=>{let n=hb(e,t);return n instanceof j?n:n.list.length===0?M.VALUE:n.list.length>1?M.NUM:n.list[0]??null});function _b(e,t,n){let r={reads:[],names:/* @__PURE__ */ new Set,volatile:!1,unknownNames:[],unknownFunctions:[],arguments:[]},i=/* @__PURE__ */ 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,/* @__PURE__ */ new Set)}return!0}if(_o.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=_o.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`&&!bo(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,/* @__PURE__ */ new Set),r}var vb=class{cells=/* @__PURE__ */ 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&&y(this.reference,t))for(let e of this.cells)n(e)}},yb=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=bb(r.group.top,r.group.bottom,r.t,r.kt,r.b,r.kb,t.top,t.bottom);if(!i)return;let a=bb(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 ka&&i.shared===r.shared&&n(i)}}};function bb(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 xb=class{single=/* @__PURE__ */ new Map;ranges=/* @__PURE__ */ new Map;byColumn=/* @__PURE__ */ new Map;wide=[];source;constructor(e){this.source=e}build(e){let t=/* @__PURE__ */ 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=/* @__PURE__ */ new Map,this.single.set(t.sheet,n));let r=Ma(t.top,t.left),i=n.get(r);i||(i=/* @__PURE__ */ new Set,n.set(r,i)),i.add(e)}else{let n=this.ranges.get(t.key);n||(n=new vb(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(Ma(t.top,t.left))?.delete(e):this.ranges.get(t.key)?.cells.delete(e)}readersIn(e,t){let n=/* @__PURE__ */ 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(Ma(e,r))??[])n.add(t);let a=/* @__PURE__ */ 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>32){this.wide.push(e);return}let r=this.byColumn.get(t);r||(r=/* @__PURE__ */ 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,y=h?p(d.right,i.right):0;if(g===void 0||_===void 0||v===void 0||y===void 0)return!1;let b=i.top-g*r.top,x=i.bottom-_*r.top,S=i.left-v*r.left,ee=i.right-y*r.left;if(f.top!==b+g*r.bottom||f.bottom!==x+_*r.bottom||f.left!==S+v*r.right||f.right!==ee+y*r.right)return!1;l.push(new yb({shared:e,on:n,group:r,reads:i.sheet,t:b,kt:g,b:x,kb:_,l:S,kl:v,r:ee,kr:y}))}for(let e of l)this.list(e);return!0}};function Sb(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}}let Cb=/* @__PURE__ */ new Set,wb=/\b(?:SUBTOTAL|AGGREGATE)\(/iu,Tb=2e3;var Eb=class extends Error{cell;constructor(e){super(`computed first`),this.cell=e}};let Db={max_iterations:100,max_change:.001};function Ob(e,t){return typeof e==`number`&&typeof t==`number`?Math.abs(t-e):e===t||e instanceof j&&t instanceof j&&e.code===t.code?0:1/0}let kb=(e,t)=>!e||!t?e===t:e.rows!==t.rows||e.cols!==t.cols?!1:e.data.every((e,n)=>e===t.data[n]),Ab=(e,t)=>e.row<t.row||e.row===t.row&&e.col<t.col;var jb=class{cycles=[];computed=0;iterated;nowSerial;random;pass=0;lambdaSlots=0;stack=[];inCycle=/* @__PURE__ */ new Set;waiting=/* @__PURE__ */ new Set;work=[];unwound=/* @__PURE__ */ new Map;counted=/* @__PURE__ */ new Set;looping=/* @__PURE__ */ new Set;tablesOf;inTables=!1;loop=/* @__PURE__ */ new Set;around=/* @__PURE__ */ new Set;namesAt=/* @__PURE__ */ new Set;graph=new xb({readsOf:e=>this.readsOf(e),readsAt:(e,t,n,r)=>this.readsAt(e,t,n,r)});graphMade=!1;reports;replica;settled=/* @__PURE__ */ new Set;moved=[];unsettled=/* @__PURE__ */ new Set;hiddenBy=/* @__PURE__ */ new Map;volatiles=/* @__PURE__ */ new Set;indexes=new ho;results=new ho;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=()=>qn(n??/* @__PURE__ */ 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)??Cb}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=/* @__PURE__ */ 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)??Db.max_iterations,max_change:(e===!0?void 0:e.max_change)??Db.max_change}}applyFilters(e){for(let e of this.wb.sheets){if(e.filters.every(e=>e.columns.size===0))continue;let t=cs(e,this);t.size>0&&this.hiddenBy.set(e,t)}if(this.hiddenBy.size!==0&&e.some(e=>wb.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 j?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=/* @__PURE__ */ new Map;for(let t of this.allCells())if(Pb(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=/* @__PURE__ */ 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=/* @__PURE__ */ new Map,n=(e,t)=>{let n=e===void 0?void 0:this.eval(e,t);return n instanceof P&&n.single?n:void 0},r=e.map(e=>{let r=e.shared.node;if(r?.kind!==`call`)return M.REF;let i=Fb(e),a=n(r.args[0],i);if(!a)return M.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 M.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 P&&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(M.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,Ob(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>=12)for(let{sheet:e,area:n}of t)for(let t of e.spillsIn(n))this.unsettled.add(t);this.build();let n=/* @__PURE__ */ new Set,r=[...this.unsettled];for(let{sheet:e,area:n}of t)lr(r,this.readersIn(e,n)),lr(r,e.blockedBy(n));for(;;){let e=r.pop();if(!e)break;n.has(e)||(n.add(e),lr(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=>y(e.area,a))||n.merges.some(e=>y(e,a))||o.some(t=>Ab(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=M.SPILL,this.moved.push({sheet:n,area:r}),this.reports&&this.settled.add(e))}analysisOf(e){return e.analysis??=_b(this.wb,e)}readsOf(e){let t=[],n=Fb(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 P?t.push(e):e instanceof or&&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 P?a.push(e):e instanceof or?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 P?n.push(e):e instanceof or&&n.push(...e.parts)}return n}order(e){this.pass+=1;let{pass:t}=this,n=[],r=/* @__PURE__ */ 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 ka&&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 ka&&n.push(i)}}}return n}computeNow(e){if(this.stack.length>0){if(this.stack.length>=50&&this.stack.length<Tb)throw new Eb(e);this.compute(e);return}let t=[e],n=/* @__PURE__ */ 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 Eb))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=M.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>=Tb){e.value=M.CALC,e.state=0;return}e.state=2,this.stack.push(e),this.computed+=1;let{node:t}=e.shared,n=Pb(t)?e.value:t?this.top(this.eval(t,Fb(e))):M.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 N){let n=Nb(t);n.rows*n.cols<=1||this.spillOut(e,n)?(e.array=n,e.value=n.at(0,0)??0):e.value=M.SPILL}else e.value=t;this.inCycle.has(e)&&(n.clearSpill(e),e.value=M.CYCLE,e.array=void 0);let a=e.spill;kb(i,e.array)&&Mb(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 P?e.single?this.read(e.sheet,e.top,e.left):this.matrix(e):e instanceof or?M.VALUE:e instanceof sr?M.CALC:e instanceof F?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 N(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 j)?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})):M.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})):M.NAME}hyperlinkTarget(e){let t=e.shared.node;for(;t?.kind===`paren`;)t=t.arg;if(t?.kind!==`call`||t.name!==`HYPERLINK`)return;let[n]=t.args;if(n===void 0)return;let r=Fb(e);return this.scalar(this.eval(n,r),r)}bound(e,t,n){let r=e.abs?e.index:e.index+t;return r<0||r>=n?void 0:r}resolveRef(e,t){let n=e.sheet===void 0?t.sheet:this.wb.sheet(e.sheet);if(!n)return M.REF;let r=0,i=16383,a=0,o=1048575;if(e.col){let n=this.bound(e.col,t.dc,d),a=this.bound(e.col2??e.col,t.dc,d);if(n===void 0||a===void 0)return M.REF;r=Math.min(n,a),i=Math.max(n,a)}if(e.row){let n=this.bound(e.row,t.dr,u),r=this.bound(e.row2??e.row,t.dr,u);if(n===void 0||r===void 0)return M.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 M.REF;let[s,c]=[Math.min(n.index,t.index),Math.max(n.index,t.index)];return new or(this.wb.sheets.slice(s,c+1).map(e=>new P(e,a,r,o,i)))}return new P(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?Ib(n,e,t):e.table===void 0?M.REF:M.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 M.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 M.NAME;if(this.namesAt.has(r))return M.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 P(o.sheet,e,t,n,r)}let s=_o.get(e.toUpperCase());return s&&s.kind!==`lazy`?Lb(s,e,t):M.NAME}intersect(e,t){return!(e instanceof P)||e.single?e:e.cols===1&&t.row>=e.top&&t.row<=e.bottom?new P(e.sheet,t.row,e.left,t.row,e.left):e.rows===1&&t.col>=e.left&&t.col<=e.right?new P(e.sheet,e.top,t.col,e.top,t.col):M.VALUE}unary(e,t){let n=this.flat(e);return n instanceof N?new N(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 N||i instanceof N?po(r instanceof N?r:new N(1,1,[r]),i instanceof N?i:new N(1,1,[i]),(t,n)=>fo(e,t,n)):fo(e,r,i)}rangeOf(e,t){return e instanceof j?e:t instanceof j?t:!(e instanceof P)||!(t instanceof P)||e.sheet!==t.sheet?M.REF:new P(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 j)return e;if(t instanceof j)return t;if(!(e instanceof P)||!(t instanceof P))return M.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?M.NULL:new P(e.sheet,n,r,i,a)}union(e,t){if(e instanceof j)return e;if(t instanceof j)return t;let n=e=>e instanceof P?[e]:e instanceof or?e.parts:[],r=[...n(e),...n(t)];return r.length===0?M.VALUE:new or(r)}eval(e,t){switch(e.kind){case`number`:case`string`:case`boolean`:return e.value;case`error`:return j.of(e.code);case`missing`:return cr;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=>fo(`*`,e,-1))}case`postfix`:{let n=this.eval(e.arg,t);if(e.op===`%`)return this.unary(n,e=>fo(`/`,e,100));if(n instanceof P&&n.single){let e=n.sheet.at(n.top,n.left);if(e instanceof ka){this.read(n.sheet,n.top,n.left);let{spill:t}=e;if(t)return new P(n.sheet,t.top,t.left,t.bottom,t.right);if(e.array)return n}}return M.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 N(e.rows.length,e.rows[0]?.length??0,e.rows.flatMap(e=>e.map(e=>{let n=this.eval(e,t);return n instanceof N||n instanceof P||n instanceof or||n instanceof sr||n instanceof F?M.VALUE:n})));case`invoke`:{let n=this.eval(e.callee,t);return n instanceof sr?this.invoke(n,e.args,t):n instanceof j?n:M.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=_o.get(e.named);return!n||n.kind===`lazy`?M.NAME:t.length<n.min||t.length>n.max?M.VALUE:this.applyFunction(n,t,e.frame)}if(t.length>e.params.length)return M.VALUE;let n=e.params.length+1;if(this.lambdaSlots+n>1024)return M.NUM;let r=/* @__PURE__ */ new Map;e.params.forEach((e,n)=>{r.set(e,t[n]??cr)}),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 M.NUM}finally{this.lambdaSlots-=n}}call(e,t,n){let r=_o.get(e);if(!r){let r=this.nameValue(e,n);return r instanceof sr?this.invoke(r,t,n):M.NAME}return t.length<r.min||t.length>r.max?M.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 M.VALUE;if(e.kind===`raw`)return bo(e.params,t.length)?this.over(t,t=>yo(e.params,t)===`value`,t=>e.call(t,r)):M.VALUE;let i=e.errors===!0;return this.over(t,()=>!0,t=>{let n=t.map(e=>e instanceof F?void 0:e);if(!i){for(let e of n)if(e instanceof j)return e}return e.call(...n)})}over(e,t,n){let r=[],i=/* @__PURE__ */ new Map;for(let[n,a]of e.entries()){if(!t(n)||a instanceof F){r.push(a);continue}let e=this.flat(a);e instanceof N&&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 M.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):M.NA});c[e*s+t]=this.element(n(a))}return new N(o,s,c)}element(e){let t=this.flat(e);return t instanceof N?t.rows>0&&t.cols>0?t.at(0,0):M.CALC:t}scalar(e,t){if(e instanceof F)return null;if(e instanceof P){let n=this.intersect(e,t);return n instanceof P?this.read(n.sheet,n.top,n.left):M.VALUE}return e instanceof N?e.at(0,0):e instanceof or||e instanceof sr?M.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 ka(new Oa(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 ka&&t.clearSpill(e),t.replace(n,r,i),i instanceof ka&&(i.state=0)}return}this.build();let t=/* @__PURE__ */ new Set,n=[...this.unsettled];this.unsettled.clear();let r=/* @__PURE__ */ new Set;for(let{sheet:i,row:a,col:o,slot:s}of e){let e=i.at(a,o);(e instanceof ka&&Pb(e.shared.node)||s instanceof ka&&Pb(s.shared.node))&&(this.tablesOf=void 0),e instanceof ka&&(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 ka&&(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)lr(n,this.readers(t,r,i));for(lr(n,this.volatiles);;){let e=n.pop();if(!e)break;t.has(e)||this.inTables&&Pb(e.shared.node)||(t.add(e),lr(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:Ja(t.value),...t.array?{array:Xa(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 ka&&(e.clearSpill(n),n.value=Ya(t.value),n.array=t.array?Za(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 ka?[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 I(e)}};let Mb=(e,t)=>e?.top===t?.top&&e?.left===t?.left&&e?.bottom===t?.bottom&&e?.right===t?.right;function Nb(e){return e.data.some(e=>e===null)?new N(e.rows,e.cols,e.data.map(e=>e??0)):e}function Pb(e){return e?.kind===`call`&&e.name===`TABLE`}function Fb(e){return{sheet:e.sheet,row:e.row,col:e.col,dr:e.row-e.shared.row,dc:e.col-e.shared.col}}function Ib(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 M.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?M.VALUE:new P(r,n.row,a,n.row,o);let l=t.sections;if(l.includes(`#Totals`))return M.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 P(r,f,a,p,o)}function Lb(e,t,n){return new sr([],{kind:`call`,name:e.name,written:t,args:[]},n,e.name)}function Rb(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=Ma(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 ka(s,n,r,a)});continue}let c=nr(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 ka(new Oa(c.formula,r,a,{file:``}),n,r,a)})}t.change(i)}function zb(e,t={}){let n=new Map(e.rows),r=qa({file:e.file,rows:e=>n.get(e),generated:e.generated});return e.scenario!==void 0&&eo(r,e.scenario),{workbook:r,calc:new jb(r,{random:Sb(e.seed),...t}).calculate()}}var Bb=class{model;generation=-1;handle(e){if(e.kind===`open`)this.model=zb(e,{report:!0}),this.generation=e.generation;else{if(e.generation!==this.generation||!this.model)return;e.kind===`cells`?Rb(this.model.workbook,this.model.calc,e.cells,e.file):this.model.calc.recalculate()}return{generation:this.generation,computed:this.model.calc.takeComputed()}}};let Vb=[[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`],[`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`,`Sunday`],[`周一`,`周二`,`周三`,`周四`,`周五`,`周六`,`周日`],[`星期一`,`星期二`,`星期三`,`星期四`,`星期五`,`星期六`,`星期日`]],Hb=[[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],[`一月`,`二月`,`三月`,`四月`,`五月`,`六月`,`七月`,`八月`,`九月`,`十月`,`十一月`,`十二月`]];[...Vb,...Hb],Object.fromEntries([`bold`,`italic`,`underline`,`strike`,`font`,`size`,`color`,`fill`,`align`,`valign`,`wrap`,`shrink`,`indent`,`rotation`,`border`,`locked`,`hide_formula`,`format`].map(e=>[e,void 0]));let Ub=new Bb;addEventListener(`message`,e=>{let t=Ub.handle(e.data);t&&postMessage(t)})})();