@synnaxlabs/pluto 0.40.1 → 0.42.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 (569) hide show
  1. package/dist/{Center-CFEPOi_x.js → Center-CNcAEDgS.js} +3 -3
  2. package/dist/Center-Map6aflE.cjs +1 -0
  3. package/dist/ContextMenu-DmRPxhnI.cjs +1 -0
  4. package/dist/ContextMenu-fLU0wr9S.js +95 -0
  5. package/dist/DateTime-CP3OmEGY.cjs +1 -0
  6. package/dist/{DateTime-Djw6pb3W.js → DateTime-CWAcEwXO.js} +2 -2
  7. package/dist/{Divider-CMyzWvRC.js → Divider-BTLn5ucU.js} +597 -512
  8. package/dist/Divider-Dvb6dsgX.cjs +22 -0
  9. package/dist/Dropdown-CaGzfZRa.cjs +1 -0
  10. package/dist/Dropdown-nw8kRSbl.js +327 -0
  11. package/dist/Haul-B8zGWk0I.cjs +1 -0
  12. package/dist/{Haul-CaLW9ULm.js → Haul-Cnuzk7Z-.js} +34 -35
  13. package/dist/Item-BzrQqxRC.cjs +1 -0
  14. package/dist/Item-FmwC-twg.js +109 -0
  15. package/dist/Keyboard-BfvjkBgh.cjs +1 -0
  16. package/dist/{Keyboard--YA9DHRz.js → Keyboard-Cevv7vrQ.js} +11 -9
  17. package/dist/{Link-Bhto2KVL.cjs → Link-DI7BZ5dL.cjs} +1 -1
  18. package/dist/{Link-BT_Kwmlr.js → Link-Dljdu4e9.js} +1 -1
  19. package/dist/Pack-lJqoOmHx.cjs +1 -0
  20. package/dist/Pack-to0DG2iP.js +48 -0
  21. package/dist/Provider-BlM1x1cF.cjs +1 -0
  22. package/dist/Provider-C_B463cg.js +461 -0
  23. package/dist/Space-C2oZDkE1.js +100 -0
  24. package/dist/Space-DfcVsxz8.cjs +1 -0
  25. package/dist/Text-BXADoWYY.js +137 -0
  26. package/dist/Text-BiYpGaEZ.js +35 -0
  27. package/dist/Text-BjHlLKsp.cjs +1 -0
  28. package/dist/{Text-B7AC8Z1e.js → Text-CWiPrDI1.js} +320 -308
  29. package/dist/Text-DrIBbnml.cjs +1 -0
  30. package/dist/Text-ZJqK1cI3.cjs +4 -0
  31. package/dist/Toggle-CeUVv58o.js +377 -0
  32. package/dist/Toggle-CfwYy9fe.cjs +1 -0
  33. package/dist/{Video-TjJf_tXI.js → Video-BZ1XTEez.js} +1 -1
  34. package/dist/{Video-hdvNT3La.cjs → Video-C7YoF37-.cjs} +1 -1
  35. package/dist/WithIcon-DG7VJxsE.cjs +1 -0
  36. package/dist/WithIcon-pBZ7H9Lq.js +98 -0
  37. package/dist/align.cjs +1 -1
  38. package/dist/align.js +1 -1
  39. package/dist/button.cjs +1 -1
  40. package/dist/button.js +1 -1
  41. package/dist/color.cjs +1 -1
  42. package/dist/color.js +1 -1
  43. package/dist/css-B7c7_G5h.js +4746 -0
  44. package/dist/css-hg3QdDDt.cjs +15 -0
  45. package/dist/css.cjs +1 -1
  46. package/dist/css.js +2 -2
  47. package/dist/deep-B1etRzze.cjs +1 -0
  48. package/dist/deep-BytImVW-.js +102 -0
  49. package/dist/dimensions-Cz-q0Mok.cjs +1 -0
  50. package/dist/dimensions-DcjW7X3n.js +19 -0
  51. package/dist/dropdown.cjs +1 -1
  52. package/dist/dropdown.js +1 -1
  53. package/dist/eraser-BOx6Xhwn.cjs +11 -0
  54. package/dist/eraser-Bsb4kKS3.js +1148 -0
  55. package/dist/ether.cjs +1 -1
  56. package/dist/ether.js +68 -75
  57. package/dist/{external-DTjOTICM.js → external-1KJXZcr9.js} +2 -2
  58. package/dist/{external-dLVcM8tt.cjs → external-BHHC7TQ_.cjs} +1 -1
  59. package/dist/external-BLEs2AYM.cjs +46 -0
  60. package/dist/external-BdVuZd3H.cjs +1 -0
  61. package/dist/external-BiBhgCdz.cjs +1 -0
  62. package/dist/external-C75Z9Zbn.cjs +1 -0
  63. package/dist/external-CEfSeJMr.js +432 -0
  64. package/dist/external-CLTPcWrI.cjs +1 -0
  65. package/dist/{external-C3e9emVy.js → external-CRNR1bD0.js} +29 -28
  66. package/dist/{external-D_21zZAf.cjs → external-Cfj1plcw.cjs} +1 -1
  67. package/dist/{external-B9nbHICv.js → external-Ck1rVwUu.js} +3263 -3285
  68. package/dist/external-Cni9ftkW.cjs +1 -0
  69. package/dist/external-DCcp3sQD.js +28 -0
  70. package/dist/{external-Cs8oKwvw.cjs → external-DCfs7IFi.cjs} +1 -1
  71. package/dist/external-DDD_nc3x.js +400 -0
  72. package/dist/external-DNT-gmZx.cjs +1 -0
  73. package/dist/{external-CcIx4j5m.js → external-DeCeUbqe.js} +18 -17
  74. package/dist/{external-DCflyFdb.js → external-DgSaeiBz.js} +3 -3
  75. package/dist/{external-ClyfPgqG.cjs → external-DhfASB4W.cjs} +37 -37
  76. package/dist/{external-upiAayc4.js → external-bkwgRzLc.js} +29 -29
  77. package/dist/{external-_b4lTCfZ.js → external-hgzjVlDR.js} +2171 -2184
  78. package/dist/external-pUEPQrp_.cjs +1 -0
  79. package/dist/{external-D12g_huj.js → external-qwaFowDe.js} +14 -14
  80. package/dist/{external-JNlv7kxI.js → external-sUHGRdqd.js} +2 -2
  81. package/dist/{font-Bas26Jn-.cjs → font-BFTKtIQk.cjs} +1 -1
  82. package/dist/{font-CcRdsA3n.js → font-Crn-D_ua.js} +2 -2
  83. package/dist/fontString-DQLaRHQV.cjs +1 -0
  84. package/dist/fontString-DjnDxFrE.js +28 -0
  85. package/dist/header.cjs +1 -1
  86. package/dist/header.js +1 -1
  87. package/dist/hooks-CM9HWxYc.js +296 -0
  88. package/dist/hooks-CTKCi-OE.cjs +1 -0
  89. package/dist/index.cjs +7 -7
  90. package/dist/index.js +10618 -9594
  91. package/dist/input.cjs +1 -1
  92. package/dist/input.js +1 -1
  93. package/dist/list.cjs +1 -1
  94. package/dist/list.js +1 -1
  95. package/dist/menu.cjs +1 -1
  96. package/dist/menu.js +1 -1
  97. package/dist/pluto.css +1 -1
  98. package/dist/provider-BDFfcHVT.js +12851 -0
  99. package/dist/provider-XPRFhwnl.cjs +58 -0
  100. package/dist/src/aether/aether/aether.d.ts +17 -18
  101. package/dist/src/aether/aether/aether.d.ts.map +1 -1
  102. package/dist/src/aether/aether/aether.spec.spec.d.ts +1 -5
  103. package/dist/src/aether/aether/aether.spec.spec.d.ts.map +1 -1
  104. package/dist/src/aether/main.d.ts +48 -0
  105. package/dist/src/aether/main.d.ts.map +1 -1
  106. package/dist/src/aether/main.spec.d.ts +1 -5
  107. package/dist/src/aether/main.spec.d.ts.map +1 -1
  108. package/dist/src/aether/message.d.ts +11 -1
  109. package/dist/src/aether/message.d.ts.map +1 -1
  110. package/dist/src/alamos/aether/alamos.d.ts +19 -25
  111. package/dist/src/alamos/aether/alamos.d.ts.map +1 -1
  112. package/dist/src/align/Center.d.ts +2 -2
  113. package/dist/src/align/Center.d.ts.map +1 -1
  114. package/dist/src/align/Pack.d.ts +3 -3
  115. package/dist/src/align/Pack.d.ts.map +1 -1
  116. package/dist/src/align/Space.d.ts +25 -10
  117. package/dist/src/align/Space.d.ts.map +1 -1
  118. package/dist/src/align/Stack.d.ts +7 -0
  119. package/dist/src/align/Stack.d.ts.map +1 -0
  120. package/dist/src/align/external.d.ts +1 -0
  121. package/dist/src/align/external.d.ts.map +1 -1
  122. package/dist/src/breadcrumb/Breadcrumb.d.ts +2 -2
  123. package/dist/src/breadcrumb/Breadcrumb.d.ts.map +1 -1
  124. package/dist/src/button/Button.d.ts +4 -6
  125. package/dist/src/button/Button.d.ts.map +1 -1
  126. package/dist/src/button/Icon.d.ts +4 -1
  127. package/dist/src/button/Icon.d.ts.map +1 -1
  128. package/dist/src/button/Toggle.d.ts +0 -1
  129. package/dist/src/button/Toggle.d.ts.map +1 -1
  130. package/dist/src/button/color.d.ts +2 -2
  131. package/dist/src/button/color.d.ts.map +1 -1
  132. package/dist/src/caret/Animated.d.ts +3 -2
  133. package/dist/src/caret/Animated.d.ts.map +1 -1
  134. package/dist/src/channel/LinePlot.d.ts +5 -5
  135. package/dist/src/channel/LinePlot.d.ts.map +1 -1
  136. package/dist/src/channel/Select.d.ts +3 -3
  137. package/dist/src/channel/Select.d.ts.map +1 -1
  138. package/dist/src/color/BaseSwatch.d.ts +3 -3
  139. package/dist/src/color/BaseSwatch.d.ts.map +1 -1
  140. package/dist/src/color/GradientPicker.d.ts +1 -2
  141. package/dist/src/color/GradientPicker.d.ts.map +1 -1
  142. package/dist/src/color/Picker.d.ts +1 -1
  143. package/dist/src/color/Picker.d.ts.map +1 -1
  144. package/dist/src/color/Provider.d.ts +8 -100
  145. package/dist/src/color/Provider.d.ts.map +1 -1
  146. package/dist/src/color/external.d.ts +0 -4
  147. package/dist/src/color/external.d.ts.map +1 -1
  148. package/dist/src/css/color.d.ts +2 -2
  149. package/dist/src/css/color.d.ts.map +1 -1
  150. package/dist/src/css/css.d.ts +2 -1
  151. package/dist/src/css/css.d.ts.map +1 -1
  152. package/dist/src/divider/Divider.d.ts +6 -5
  153. package/dist/src/divider/Divider.d.ts.map +1 -1
  154. package/dist/src/dropdown/Dropdown.d.ts +2 -1
  155. package/dist/src/dropdown/Dropdown.d.ts.map +1 -1
  156. package/dist/src/ether.d.ts +0 -1
  157. package/dist/src/ether.d.ts.map +1 -1
  158. package/dist/src/form/Form.d.ts +1 -1
  159. package/dist/src/form/Form.d.ts.map +1 -1
  160. package/dist/src/generic/Generic.d.ts +4 -5
  161. package/dist/src/generic/Generic.d.ts.map +1 -1
  162. package/dist/src/hardware/device/Select.d.ts.map +1 -1
  163. package/dist/src/haul/Haul.d.ts +7 -63
  164. package/dist/src/haul/Haul.d.ts.map +1 -1
  165. package/dist/src/hooks/useResize.d.ts.map +1 -1
  166. package/dist/src/icon/Icon.d.ts.map +1 -1
  167. package/dist/src/index.d.ts +1 -0
  168. package/dist/src/index.d.ts.map +1 -1
  169. package/dist/src/input/DateTime.d.ts.map +1 -1
  170. package/dist/src/input/Item.d.ts +1 -1
  171. package/dist/src/input/Item.d.ts.map +1 -1
  172. package/dist/src/input/Text.d.ts +4 -4
  173. package/dist/src/input/Text.d.ts.map +1 -1
  174. package/dist/src/input/types.d.ts +0 -1
  175. package/dist/src/input/types.d.ts.map +1 -1
  176. package/dist/src/list/Column.d.ts +3 -3
  177. package/dist/src/list/Column.d.ts.map +1 -1
  178. package/dist/src/list/Core.d.ts +1 -1
  179. package/dist/src/list/Core.d.ts.map +1 -1
  180. package/dist/src/list/Hover.d.ts +3 -2
  181. package/dist/src/list/Hover.d.ts.map +1 -1
  182. package/dist/src/list/Item.d.ts +1 -1
  183. package/dist/src/list/Item.d.ts.map +1 -1
  184. package/dist/src/main.d.ts.map +1 -1
  185. package/dist/src/menu/ContextMenu.d.ts +5 -3
  186. package/dist/src/menu/ContextMenu.d.ts.map +1 -1
  187. package/dist/src/menu/Item.d.ts.map +1 -1
  188. package/dist/src/menu/Menu.d.ts +3 -2
  189. package/dist/src/menu/Menu.d.ts.map +1 -1
  190. package/dist/src/modal/Modal.d.ts +7 -3
  191. package/dist/src/modal/Modal.d.ts.map +1 -1
  192. package/dist/src/mosaic/Mosaic.d.ts +5 -3
  193. package/dist/src/mosaic/Mosaic.d.ts.map +1 -1
  194. package/dist/src/mosaic/tree.d.ts +4 -3
  195. package/dist/src/mosaic/tree.d.ts.map +1 -1
  196. package/dist/src/mosaic/types.d.ts +6 -66
  197. package/dist/src/mosaic/types.d.ts.map +1 -1
  198. package/dist/src/nav/Bar.d.ts +2 -1
  199. package/dist/src/nav/Bar.d.ts.map +1 -1
  200. package/dist/src/nav/Drawer.d.ts +3 -2
  201. package/dist/src/nav/Drawer.d.ts.map +1 -1
  202. package/dist/src/notation/Select.d.ts +2 -3
  203. package/dist/src/notation/Select.d.ts.map +1 -1
  204. package/dist/src/notation/index.d.ts +1 -1
  205. package/dist/src/notation/index.d.ts.map +1 -1
  206. package/dist/src/os/Controls/Windows.d.ts +1 -1
  207. package/dist/src/os/Controls/Windows.d.ts.map +1 -1
  208. package/dist/src/os/Controls/types.d.ts +2 -0
  209. package/dist/src/os/Controls/types.d.ts.map +1 -1
  210. package/dist/src/pluto/Pluto.d.ts.map +1 -1
  211. package/dist/src/pluto/aether/pluto.d.ts.map +1 -1
  212. package/dist/src/ranger/TimeRangeChip.d.ts +2 -1
  213. package/dist/src/ranger/TimeRangeChip.d.ts.map +1 -1
  214. package/dist/src/resize/Core.d.ts +5 -4
  215. package/dist/src/resize/Core.d.ts.map +1 -1
  216. package/dist/src/resize/Multiple.d.ts.map +1 -1
  217. package/dist/src/resize/Single.d.ts.map +1 -1
  218. package/dist/src/select/Button.d.ts.map +1 -1
  219. package/dist/src/select/List.d.ts.map +1 -1
  220. package/dist/src/select/Multiple.d.ts +2 -3
  221. package/dist/src/select/Multiple.d.ts.map +1 -1
  222. package/dist/src/state/state.d.ts +1 -2
  223. package/dist/src/state/state.d.ts.map +1 -1
  224. package/dist/src/status/Circle.d.ts.map +1 -1
  225. package/dist/src/status/Notification.d.ts.map +1 -1
  226. package/dist/src/status/aether/aggregator.d.ts +34 -96
  227. package/dist/src/status/aether/aggregator.d.ts.map +1 -1
  228. package/dist/src/status/aether/types.d.ts +23 -27
  229. package/dist/src/status/aether/types.d.ts.map +1 -1
  230. package/dist/src/status/colors.d.ts +1 -1
  231. package/dist/src/status/colors.d.ts.map +1 -1
  232. package/dist/src/synnax/Provider.d.ts +4 -0
  233. package/dist/src/synnax/Provider.d.ts.map +1 -1
  234. package/dist/src/synnax/aether/provider.d.ts +54 -388
  235. package/dist/src/synnax/aether/provider.d.ts.map +1 -1
  236. package/dist/src/table/aether/Table.d.ts +58 -418
  237. package/dist/src/table/aether/Table.d.ts.map +1 -1
  238. package/dist/src/table/cells/Cells.d.ts +38 -153
  239. package/dist/src/table/cells/Cells.d.ts.map +1 -1
  240. package/dist/src/table/cells/Forms.d.ts.map +1 -1
  241. package/dist/src/table/cells/registry.d.ts +6 -3
  242. package/dist/src/table/cells/registry.d.ts.map +1 -1
  243. package/dist/src/tabs/Selector.d.ts +5 -2
  244. package/dist/src/tabs/Selector.d.ts.map +1 -1
  245. package/dist/src/tabs/Tabs.d.ts +2 -3
  246. package/dist/src/tabs/Tabs.d.ts.map +1 -1
  247. package/dist/src/tabs/types.d.ts +5 -38
  248. package/dist/src/tabs/types.d.ts.map +1 -1
  249. package/dist/src/tag/Tag.d.ts +3 -4
  250. package/dist/src/tag/Tag.d.ts.map +1 -1
  251. package/dist/src/telem/aether/context.d.ts +8 -8
  252. package/dist/src/telem/aether/context.d.ts.map +1 -1
  253. package/dist/src/telem/aether/factory.d.ts +6 -2
  254. package/dist/src/telem/aether/factory.d.ts.map +1 -1
  255. package/dist/src/telem/aether/noop.d.ts.map +1 -1
  256. package/dist/src/telem/aether/pipeline.d.ts +25 -215
  257. package/dist/src/telem/aether/pipeline.d.ts.map +1 -1
  258. package/dist/src/telem/aether/provider.d.ts +7 -5
  259. package/dist/src/telem/aether/provider.d.ts.map +1 -1
  260. package/dist/src/telem/aether/remote.d.ts +62 -183
  261. package/dist/src/telem/aether/remote.d.ts.map +1 -1
  262. package/dist/src/telem/aether/static.d.ts +21 -74
  263. package/dist/src/telem/aether/static.d.ts.map +1 -1
  264. package/dist/src/telem/aether/telem.d.ts +60 -284
  265. package/dist/src/telem/aether/telem.d.ts.map +1 -1
  266. package/dist/src/telem/aether/transformers.d.ts +79 -321
  267. package/dist/src/telem/aether/transformers.d.ts.map +1 -1
  268. package/dist/src/telem/client/cache/cache.d.ts +1 -1
  269. package/dist/src/telem/client/cache/cache.d.ts.map +1 -1
  270. package/dist/src/telem/client/cache/dynamic.d.ts +5 -5
  271. package/dist/src/telem/client/cache/dynamic.d.ts.map +1 -1
  272. package/dist/src/telem/client/cache/static.d.ts +3 -3
  273. package/dist/src/telem/client/cache/static.d.ts.map +1 -1
  274. package/dist/src/telem/client/cache/unary.d.ts +3 -3
  275. package/dist/src/telem/client/cache/unary.d.ts.map +1 -1
  276. package/dist/src/telem/client/client.d.ts +8 -12
  277. package/dist/src/telem/client/client.d.ts.map +1 -1
  278. package/dist/src/telem/client/external.d.ts +0 -1
  279. package/dist/src/telem/client/external.d.ts.map +1 -1
  280. package/dist/src/telem/client/reader.d.ts +28 -10
  281. package/dist/src/telem/client/reader.d.ts.map +1 -1
  282. package/dist/src/telem/client/reader.spec.d.ts +6 -1
  283. package/dist/src/telem/client/reader.spec.d.ts.map +1 -1
  284. package/dist/src/telem/client/streamer.d.ts +6 -6
  285. package/dist/src/telem/client/streamer.d.ts.map +1 -1
  286. package/dist/src/telem/client/streamer.spec.d.ts +2 -0
  287. package/dist/src/telem/client/streamer.spec.d.ts.map +1 -0
  288. package/dist/src/telem/control/Indicator.d.ts.map +1 -1
  289. package/dist/src/telem/control/aether/chip.d.ts +44 -232
  290. package/dist/src/telem/control/aether/chip.d.ts.map +1 -1
  291. package/dist/src/telem/control/aether/controller.d.ts +36 -73
  292. package/dist/src/telem/control/aether/controller.d.ts.map +1 -1
  293. package/dist/src/telem/control/aether/indicator.d.ts +49 -257
  294. package/dist/src/telem/control/aether/indicator.d.ts.map +1 -1
  295. package/dist/src/telem/control/aether/legend.d.ts +18 -132
  296. package/dist/src/telem/control/aether/legend.d.ts.map +1 -1
  297. package/dist/src/telem/control/aether/state.d.ts +10 -44
  298. package/dist/src/telem/control/aether/state.d.ts.map +1 -1
  299. package/dist/src/text/Editable.d.ts.map +1 -1
  300. package/dist/src/text/Keyboard.d.ts +1 -1
  301. package/dist/src/text/Keyboard.d.ts.map +1 -1
  302. package/dist/src/text/Text.d.ts +5 -4
  303. package/dist/src/text/Text.d.ts.map +1 -1
  304. package/dist/src/text/WithIcon.d.ts +3 -2
  305. package/dist/src/text/WithIcon.d.ts.map +1 -1
  306. package/dist/src/text/core/types.d.ts +17 -14
  307. package/dist/src/text/core/types.d.ts.map +1 -1
  308. package/dist/src/text/dimensions.d.ts +1 -0
  309. package/dist/src/text/dimensions.d.ts.map +1 -1
  310. package/dist/src/theming/Provider.d.ts.map +1 -1
  311. package/dist/src/theming/aether/provider.d.ts +899 -5915
  312. package/dist/src/theming/aether/provider.d.ts.map +1 -1
  313. package/dist/src/theming/core/fontString.d.ts.map +1 -1
  314. package/dist/src/theming/core/theme.d.ts +368 -1860
  315. package/dist/src/theming/core/theme.d.ts.map +1 -1
  316. package/dist/src/theming/css.d.ts +1 -1
  317. package/dist/src/theming/css.d.ts.map +1 -1
  318. package/dist/src/theming/static/generate.d.ts +2 -0
  319. package/dist/src/theming/static/generate.d.ts.map +1 -0
  320. package/dist/src/tooltip/Dialog.d.ts.map +1 -1
  321. package/dist/src/tree/Tree.d.ts +1 -1
  322. package/dist/src/tree/Tree.d.ts.map +1 -1
  323. package/dist/src/tree/core.d.ts +2 -2
  324. package/dist/src/tree/core.d.ts.map +1 -1
  325. package/dist/src/triggers/Provider.d.ts.map +1 -1
  326. package/dist/src/triggers/Text.d.ts.map +1 -1
  327. package/dist/src/triggers/hooks.d.ts +1 -0
  328. package/dist/src/triggers/hooks.d.ts.map +1 -1
  329. package/dist/src/triggers/triggers.d.ts +248 -9
  330. package/dist/src/triggers/triggers.d.ts.map +1 -1
  331. package/dist/src/util/component.d.ts +8 -2
  332. package/dist/src/util/component.d.ts.map +1 -1
  333. package/dist/src/viewport/use.d.ts +8 -1
  334. package/dist/src/viewport/use.d.ts.map +1 -1
  335. package/dist/src/vis/axis/axis.d.ts +17 -48
  336. package/dist/src/vis/axis/axis.d.ts.map +1 -1
  337. package/dist/src/vis/axis/canvas.d.ts +17 -20
  338. package/dist/src/vis/axis/canvas.d.ts.map +1 -1
  339. package/dist/src/vis/axis/preciseTimeScale.d.ts +1 -2
  340. package/dist/src/vis/axis/preciseTimeScale.d.ts.map +1 -1
  341. package/dist/src/vis/axis/ticks.d.ts +11 -11
  342. package/dist/src/vis/axis/ticks.d.ts.map +1 -1
  343. package/dist/src/vis/button/aether/button.d.ts +10 -80
  344. package/dist/src/vis/button/aether/button.d.ts.map +1 -1
  345. package/dist/src/vis/canvas/Canvas.d.ts +2 -2
  346. package/dist/src/vis/canvas/Canvas.d.ts.map +1 -1
  347. package/dist/src/vis/canvas/aether/canvas.d.ts +45 -193
  348. package/dist/src/vis/canvas/aether/canvas.d.ts.map +1 -1
  349. package/dist/src/vis/diagram/Diagram.d.ts.map +1 -1
  350. package/dist/src/vis/diagram/aether/Diagram.d.ts +62 -469
  351. package/dist/src/vis/diagram/aether/Diagram.d.ts.map +1 -1
  352. package/dist/src/vis/diagram/aether/types.d.ts +29 -249
  353. package/dist/src/vis/diagram/aether/types.d.ts.map +1 -1
  354. package/dist/src/vis/diagram/edge/Edge.d.ts +2 -3
  355. package/dist/src/vis/diagram/edge/Edge.d.ts.map +1 -1
  356. package/dist/src/vis/diagram/edge/connector/connector.d.ts +5 -8
  357. package/dist/src/vis/diagram/edge/connector/connector.d.ts.map +1 -1
  358. package/dist/src/vis/diagram/edge/paths.d.ts +3 -4
  359. package/dist/src/vis/diagram/edge/paths.d.ts.map +1 -1
  360. package/dist/src/vis/draw2d/canvas.d.ts +21 -3
  361. package/dist/src/vis/draw2d/canvas.d.ts.map +1 -1
  362. package/dist/src/vis/draw2d/index.d.ts +18 -4
  363. package/dist/src/vis/draw2d/index.d.ts.map +1 -1
  364. package/dist/src/vis/eraser/aether/eraser.d.ts +30 -170
  365. package/dist/src/vis/eraser/aether/eraser.d.ts.map +1 -1
  366. package/dist/src/vis/eraser/use.d.ts +2 -2
  367. package/dist/src/vis/eraser/use.d.ts.map +1 -1
  368. package/dist/src/vis/grid/grid.d.ts +14 -24
  369. package/dist/src/vis/grid/grid.d.ts.map +1 -1
  370. package/dist/src/vis/legend/Container.d.ts +41 -85
  371. package/dist/src/vis/legend/Container.d.ts.map +1 -1
  372. package/dist/src/vis/legend/Simple.d.ts +11 -4
  373. package/dist/src/vis/legend/Simple.d.ts.map +1 -1
  374. package/dist/src/vis/light/aether/light.d.ts +10 -80
  375. package/dist/src/vis/light/aether/light.d.ts.map +1 -1
  376. package/dist/src/vis/line/aether/line.d.ts +19 -101
  377. package/dist/src/vis/line/aether/line.d.ts.map +1 -1
  378. package/dist/src/vis/lineplot/Axis.d.ts.map +1 -1
  379. package/dist/src/vis/lineplot/Legend.d.ts.map +1 -1
  380. package/dist/src/vis/lineplot/LinePlot.d.ts +2 -3
  381. package/dist/src/vis/lineplot/LinePlot.d.ts.map +1 -1
  382. package/dist/src/vis/lineplot/aether/BoundQuerier.d.ts +35 -0
  383. package/dist/src/vis/lineplot/aether/BoundQuerier.d.ts.map +1 -0
  384. package/dist/src/vis/lineplot/aether/LinePlot.d.ts +82 -489
  385. package/dist/src/vis/lineplot/aether/LinePlot.d.ts.map +1 -1
  386. package/dist/src/vis/lineplot/aether/XAxis.d.ts +51 -191
  387. package/dist/src/vis/lineplot/aether/XAxis.d.ts.map +1 -1
  388. package/dist/src/vis/lineplot/aether/YAxis.d.ts +49 -194
  389. package/dist/src/vis/lineplot/aether/YAxis.d.ts.map +1 -1
  390. package/dist/src/vis/lineplot/aether/axis.d.ts +27 -98
  391. package/dist/src/vis/lineplot/aether/axis.d.ts.map +1 -1
  392. package/dist/src/vis/lineplot/aether/external.d.ts +1 -0
  393. package/dist/src/vis/lineplot/aether/external.d.ts.map +1 -1
  394. package/dist/src/vis/lineplot/external.d.ts +1 -0
  395. package/dist/src/vis/lineplot/external.d.ts.map +1 -1
  396. package/dist/src/vis/lineplot/range/Provider.d.ts.map +1 -1
  397. package/dist/src/vis/lineplot/range/aether/annotation.d.ts +15 -52
  398. package/dist/src/vis/lineplot/range/aether/annotation.d.ts.map +1 -1
  399. package/dist/src/vis/lineplot/range/aether/provider.d.ts +43 -294
  400. package/dist/src/vis/lineplot/range/aether/provider.d.ts.map +1 -1
  401. package/dist/src/vis/lineplot/tooltip/aether/tooltip.d.ts +17 -154
  402. package/dist/src/vis/lineplot/tooltip/aether/tooltip.d.ts.map +1 -1
  403. package/dist/src/vis/lineplot/useBoundQuerier.d.ts +11 -0
  404. package/dist/src/vis/lineplot/useBoundQuerier.d.ts.map +1 -0
  405. package/dist/src/vis/log/Log.d.ts.map +1 -1
  406. package/dist/src/vis/log/aether/Log.d.ts +82 -461
  407. package/dist/src/vis/log/aether/Log.d.ts.map +1 -1
  408. package/dist/src/vis/measure/aether/measure.d.ts +24 -249
  409. package/dist/src/vis/measure/aether/measure.d.ts.map +1 -1
  410. package/dist/src/vis/performance/Performance.d.ts +2 -0
  411. package/dist/src/vis/performance/Performance.d.ts.map +1 -0
  412. package/dist/src/vis/performance/aether/index.d.ts +2 -0
  413. package/dist/src/vis/performance/aether/index.d.ts.map +1 -0
  414. package/dist/src/vis/performance/aether/performance.d.ts +15 -0
  415. package/dist/src/vis/performance/aether/performance.d.ts.map +1 -0
  416. package/dist/src/vis/performance/index.d.ts +2 -0
  417. package/dist/src/vis/performance/index.d.ts.map +1 -0
  418. package/dist/src/vis/render/GLProgram.d.ts +1 -2
  419. package/dist/src/vis/render/GLProgram.d.ts.map +1 -1
  420. package/dist/src/vis/render/context.d.ts +1 -0
  421. package/dist/src/vis/render/context.d.ts.map +1 -1
  422. package/dist/src/vis/render/controller.d.ts +7 -12
  423. package/dist/src/vis/render/controller.d.ts.map +1 -1
  424. package/dist/src/vis/render/loop.d.ts +15 -5
  425. package/dist/src/vis/render/loop.d.ts.map +1 -1
  426. package/dist/src/vis/rule/Rule.d.ts +1 -1
  427. package/dist/src/vis/rule/Rule.d.ts.map +1 -1
  428. package/dist/src/vis/rule/aether/aether.d.ts +8 -57
  429. package/dist/src/vis/rule/aether/aether.d.ts.map +1 -1
  430. package/dist/src/vis/schematic/Forms.d.ts +7 -1
  431. package/dist/src/vis/schematic/Forms.d.ts.map +1 -1
  432. package/dist/src/vis/schematic/Symbols.d.ts +57 -9
  433. package/dist/src/vis/schematic/Symbols.d.ts.map +1 -1
  434. package/dist/src/vis/schematic/primitives/Primitives.d.ts +68 -29
  435. package/dist/src/vis/schematic/primitives/Primitives.d.ts.map +1 -1
  436. package/dist/src/vis/schematic/registry.d.ts +96 -1
  437. package/dist/src/vis/schematic/registry.d.ts.map +1 -1
  438. package/dist/src/vis/setpoint/aether/setpoint.d.ts +16 -155
  439. package/dist/src/vis/setpoint/aether/setpoint.d.ts.map +1 -1
  440. package/dist/src/vis/text/atlas.d.ts +32 -0
  441. package/dist/src/vis/text/atlas.d.ts.map +1 -0
  442. package/dist/src/vis/text/index.d.ts +2 -0
  443. package/dist/src/vis/text/index.d.ts.map +1 -0
  444. package/dist/src/vis/toggle/aether/toggle.d.ts +16 -150
  445. package/dist/src/vis/toggle/aether/toggle.d.ts.map +1 -1
  446. package/dist/src/vis/value/Form.d.ts.map +1 -1
  447. package/dist/src/vis/value/aether/value.d.ts +144 -569
  448. package/dist/src/vis/value/aether/value.d.ts.map +1 -1
  449. package/dist/src/vis/value/use.d.ts +55 -199
  450. package/dist/src/vis/value/use.d.ts.map +1 -1
  451. package/dist/state-CjGemC7S.js +88 -0
  452. package/dist/state-_FFrG5nH.cjs +1 -0
  453. package/dist/tabs.cjs +1 -1
  454. package/dist/tabs.js +1 -1
  455. package/dist/text.cjs +1 -1
  456. package/dist/text.js +2 -2
  457. package/dist/theme.css +1600 -0
  458. package/dist/theming.cjs +1 -1
  459. package/dist/theming.js +2 -2
  460. package/dist/{toArray-Dvn9FA_3.js → toArray-B7nD2CTw.js} +1 -1
  461. package/dist/{toArray-DRKOku1s.cjs → toArray-BvVYuN_b.cjs} +1 -1
  462. package/dist/tree.cjs +1 -1
  463. package/dist/tree.js +1 -1
  464. package/dist/triggers.cjs +1 -1
  465. package/dist/triggers.js +1 -1
  466. package/dist/units-CKKNRQlP.cjs +1 -0
  467. package/dist/units-a8CggrTe.js +11 -0
  468. package/dist/{useClickOutside-N6MHxbOe.js → useClickOutside-CKMnqdvH.js} +20 -21
  469. package/dist/useClickOutside-CPAEkvf8.cjs +1 -0
  470. package/dist/{useDebouncedCallback-D4Ec7whQ.js → useDebouncedCallback-Cyd6pZ59.js} +1 -1
  471. package/dist/useDebouncedCallback-DsKlBI86.cjs +1 -0
  472. package/dist/{useMemoCompare-Cq_C2ddc.js → useMemoCompare-B930TM0g.js} +2 -2
  473. package/dist/useMemoCompare-DprA41gC.cjs +1 -0
  474. package/dist/{useVirtualCursorDragWebKit-BBTGd7Xe.js → useVirtualCursorDragWebKit-BrSOJpYY.js} +5 -5
  475. package/dist/useVirtualCursorDragWebKit-Cvp93Pya.cjs +1 -0
  476. package/dist/value-B7u8K1CW.cjs +57 -0
  477. package/dist/value-BdZLWVof.js +5974 -0
  478. package/dist/video.cjs +1 -1
  479. package/dist/video.js +1 -1
  480. package/package.json +22 -19
  481. package/dist/Center-bD2cOjI8.cjs +0 -1
  482. package/dist/ContextMenu-BXNN2_7t.js +0 -101
  483. package/dist/ContextMenu-CNSewKSD.cjs +0 -1
  484. package/dist/DateTime-BfnGq6C2.cjs +0 -1
  485. package/dist/Divider-CJNDIsD4.cjs +0 -22
  486. package/dist/Dropdown-CL7BefC8.cjs +0 -1
  487. package/dist/Dropdown-D-aMufnM.js +0 -261
  488. package/dist/Haul-4OcHX8__.cjs +0 -1
  489. package/dist/Item-CW2A2nuL.js +0 -108
  490. package/dist/Item-CpAZC-dF.cjs +0 -1
  491. package/dist/Keyboard-DHGtnfsf.cjs +0 -1
  492. package/dist/Pack-C4NdZWyf.cjs +0 -1
  493. package/dist/Pack-UzJJ9OhY.js +0 -46
  494. package/dist/Provider-BH1uv6QX.js +0 -436
  495. package/dist/Provider-lJARiq5i.cjs +0 -1
  496. package/dist/Space-BrQoodma.cjs +0 -1
  497. package/dist/Space-I_hidXYi.js +0 -76
  498. package/dist/Text-C-o1z9sP.js +0 -124
  499. package/dist/Text-C_j_F67Q.cjs +0 -1
  500. package/dist/Text-ClTuQXMF.cjs +0 -4
  501. package/dist/Text-DEbr1cmH.cjs +0 -1
  502. package/dist/Text-DVv04lTs.js +0 -32
  503. package/dist/Toggle-CYB9Vt6b.cjs +0 -1
  504. package/dist/Toggle-v77mEVLE.js +0 -356
  505. package/dist/WithIcon-BnDZ-Qu7.js +0 -92
  506. package/dist/WithIcon-tr8ELI3W.cjs +0 -1
  507. package/dist/aggregator-AgOKLWHz.js +0 -83
  508. package/dist/aggregator-QqWwGnYH.cjs +0 -1
  509. package/dist/css-CU7tous7.cjs +0 -1
  510. package/dist/css-rxwBYwM1.js +0 -1194
  511. package/dist/deep-DsH2ji6Z.cjs +0 -1
  512. package/dist/deep-T1-57GfG.js +0 -105
  513. package/dist/dimensions-C9PXLcE0.js +0 -18
  514. package/dist/dimensions-e5IPRZhn.cjs +0 -1
  515. package/dist/eraser-D2I1qgOg.cjs +0 -11
  516. package/dist/eraser-Dmishn8h.js +0 -823
  517. package/dist/external-B1ttDWzy.cjs +0 -1
  518. package/dist/external-BWb18P9x.cjs +0 -46
  519. package/dist/external-BdxbwUpI.js +0 -343
  520. package/dist/external-BpvGU0dZ.cjs +0 -1
  521. package/dist/external-C7Hy9XdI.js +0 -418
  522. package/dist/external-CqhOyYDl.cjs +0 -1
  523. package/dist/external-Csg4_wkz.js +0 -15
  524. package/dist/external-CwvJvXL5.cjs +0 -1
  525. package/dist/external-Cztvb3-K.cjs +0 -1
  526. package/dist/external-DMEzx_kb.cjs +0 -1
  527. package/dist/external-DkQnAvKo.cjs +0 -1
  528. package/dist/fontString-C7H8Imxd.cjs +0 -1
  529. package/dist/fontString-DdV9bi9l.js +0 -12
  530. package/dist/hooks-B7ZV7Hz6.js +0 -293
  531. package/dist/hooks-CJnV8Pt4.cjs +0 -1
  532. package/dist/provider-BrBEjlx5.cjs +0 -53
  533. package/dist/provider-Dq9t3iAH.js +0 -10312
  534. package/dist/src/color/core/color.d.ts +0 -143
  535. package/dist/src/color/core/color.d.ts.map +0 -1
  536. package/dist/src/color/core/color.spec.d.ts +0 -2
  537. package/dist/src/color/core/color.spec.d.ts.map +0 -1
  538. package/dist/src/color/core/external.d.ts +0 -5
  539. package/dist/src/color/core/external.d.ts.map +0 -1
  540. package/dist/src/color/core/gradient.d.ts +0 -58
  541. package/dist/src/color/core/gradient.d.ts.map +0 -1
  542. package/dist/src/color/core/index.d.ts +0 -2
  543. package/dist/src/color/core/index.d.ts.map +0 -1
  544. package/dist/src/color/core/palette.d.ts +0 -74
  545. package/dist/src/color/core/palette.d.ts.map +0 -1
  546. package/dist/src/color/core/transformColorsToHex.d.ts +0 -6
  547. package/dist/src/color/core/transformColorsToHex.d.ts.map +0 -1
  548. package/dist/src/notation/external.d.ts +0 -3
  549. package/dist/src/notation/external.d.ts.map +0 -1
  550. package/dist/src/notation/notation.d.ts +0 -33
  551. package/dist/src/notation/notation.d.ts.map +0 -1
  552. package/dist/src/notation/notation.spec.d.ts +0 -2
  553. package/dist/src/notation/notation.spec.d.ts.map +0 -1
  554. package/dist/src/telem/client/types.d.ts +0 -20
  555. package/dist/src/telem/client/types.d.ts.map +0 -1
  556. package/dist/state-CUPEHHgf.js +0 -2405
  557. package/dist/state-LaBGf4_k.cjs +0 -15
  558. package/dist/transformColorsToHex-B2Bui-Wf.cjs +0 -1
  559. package/dist/transformColorsToHex-B6dG2LA6.js +0 -14
  560. package/dist/units-CvIf5nF_.cjs +0 -1
  561. package/dist/units-D7qkgH-s.js +0 -8
  562. package/dist/useClickOutside-PFl3AvPU.cjs +0 -1
  563. package/dist/useDebouncedCallback-vg2DKTH7.cjs +0 -1
  564. package/dist/useMemoCompare-BGEWpAJU.cjs +0 -1
  565. package/dist/useVirtualCursorDragWebKit-Rnok8Nft.cjs +0 -1
  566. package/dist/value-C6JZdCF2.cjs +0 -57
  567. package/dist/value-Dk2DJbst.js +0 -5911
  568. /package/dist/{Pack-BbwDtaE6.cjs → Stack-BbwDtaE6.cjs} +0 -0
  569. /package/dist/{Pack-D50qN0Vu.js → Stack-D50qN0Vu.js} +0 -0
@@ -0,0 +1,4746 @@
1
+ var Fn = Object.defineProperty;
2
+ var _n = (r, e, t) => e in r ? Fn(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
+ var je = (r, e, t) => _n(r, typeof e != "symbol" ? e + "" : e, t);
4
+ import se, { z as a } from "zod";
5
+ const Xe = a.tuple([a.number(), a.number()]);
6
+ a.tuple([a.bigint(), a.bigint()]);
7
+ const Lt = a.object({ width: a.number(), height: a.number() }), qn = a.object({
8
+ signedWidth: a.number(),
9
+ signedHeight: a.number()
10
+ }), Wn = ["width", "height"];
11
+ a.enum(Wn);
12
+ const Vn = ["start", "center", "end"], Yn = ["signedWidth", "signedHeight"];
13
+ a.enum(Yn);
14
+ const Ne = a.object({ x: a.number(), y: a.number() }), Ir = a.object({ clientX: a.number(), clientY: a.number() }), Rt = ["x", "y"], jt = a.enum(Rt), Nr = ["top", "right", "bottom", "left"], Zn = a.enum(Nr), Qe = ["left", "right"], kt = a.enum(Qe), et = ["top", "bottom"], Dt = a.enum(et), Pt = ["center"], dt = a.enum(Pt), Hn = [...Nr, ...Pt], zt = a.enum(Hn);
15
+ a.enum(Vn);
16
+ const Gn = ["first", "last"];
17
+ a.enum(Gn);
18
+ const Ur = a.object({ lower: a.number(), upper: a.number() }), Kn = a.object({ lower: a.bigint(), upper: a.bigint() });
19
+ a.union([Ur, Xe]);
20
+ a.union([Kn, Xe]);
21
+ const Jn = a.enum([...jt.options, ...zt.options]), Xn = a.union([jt, zt, a.instanceof(String)]), K = (r) => typeof r == "bigint" || r instanceof BigInt, $e = (r, e) => K(r) ? r.valueOf() - BigInt(e.valueOf().valueOf()) : r.valueOf() - Number(e.valueOf()), Br = (r, e) => K(r) ? r.valueOf() + BigInt(e.valueOf().valueOf()) : r + Number(e.valueOf()), Qn = (r, e, t = 1e-4) => Math.abs(r - e) < t, gt = (r, e) => K(r) ? r === BigInt(e.valueOf().valueOf()) : r === Number(e.valueOf()), es = (r) => {
22
+ const e = 10 ** Math.floor(Math.log10(r));
23
+ return Math.round(r / e) * e;
24
+ }, Er = (r, e) => K(r) ? r.valueOf() < BigInt(e.valueOf()) ? r : BigInt(e.valueOf()) : r.valueOf() < Number(e.valueOf()) ? r : Number(e.valueOf()), ts = (r, e) => K(r) ? r.valueOf() > BigInt(e.valueOf()) ? r : BigInt(e.valueOf()) : r.valueOf() > Number(e.valueOf()) ? r : Number(e.valueOf()), Ar = (r) => K(r) || r instanceof BigInt ? r.valueOf() < 0n ? -r : r : r.valueOf() < 0 ? -r : r, X = (r, e) => K(r) ? r.valueOf() * BigInt(e.valueOf()) : r.valueOf() * Number(e.valueOf()), rs = (r, e) => K(r) ? r.valueOf() / BigInt(e.valueOf()) : r.valueOf() / Number(e.valueOf()), m = (r, e) => {
25
+ const t = {};
26
+ if (typeof r == "number" || typeof r == "bigint")
27
+ e != null ? (t.lower = r, t.upper = e) : (t.lower = typeof r == "bigint" ? 0n : 0, t.upper = r);
28
+ else if (Array.isArray(r)) {
29
+ if (r.length !== 2) throw new Error("bounds: expected array of length 2");
30
+ [t.lower, t.upper] = r;
31
+ } else return pt(r);
32
+ return pt(t);
33
+ }, ns = Object.freeze({ lower: 0, upper: 0 }), ss = Object.freeze({ lower: -1 / 0, upper: 1 / 0 }), is = Object.freeze({ lower: 0, upper: 1 }), os = Object.freeze({ lower: -1, upper: 1 }), as = (r, e) => {
34
+ if (r == null && e == null) return !0;
35
+ if (r == null || e == null) return !1;
36
+ const t = m(r), n = m(e);
37
+ return (t == null ? void 0 : t.lower) === (n == null ? void 0 : n.lower) && (t == null ? void 0 : t.upper) === (n == null ? void 0 : n.upper);
38
+ }, pt = (r) => r.lower > r.upper ? { lower: r.upper, upper: r.lower } : r, yt = (r, e) => {
39
+ const t = m(r);
40
+ return e < t.lower ? t.lower : e >= t.upper ? t.upper - (typeof t.upper == "number" ? 1 : 1n) : e;
41
+ }, C = (r, e) => {
42
+ const t = m(r);
43
+ if (typeof e == "number" || typeof e == "bigint")
44
+ return e >= t.lower && e < t.upper;
45
+ const n = m(e);
46
+ return n.lower >= t.lower && n.upper <= t.upper;
47
+ }, us = (r, e) => {
48
+ const t = m(r), n = m(e);
49
+ return t.lower === n.lower ? !0 : n.upper === t.lower || n.lower === t.upper ? !1 : C(t, n.upper) || C(t, n.lower) || C(n, t.upper) || C(n, t.lower);
50
+ }, Me = (r) => {
51
+ const e = m(r);
52
+ return e.upper - e.lower;
53
+ }, ls = (r) => {
54
+ const e = m(r);
55
+ return typeof e.lower == "bigint" ? e.lower === 0n && e.upper === 0n : e.lower === 0 && e.upper === 0;
56
+ }, hs = (r) => {
57
+ const e = Me(r);
58
+ return typeof e == "number" ? e === 0 : e === 0n;
59
+ }, cs = (r) => {
60
+ const e = m(r);
61
+ return typeof e.lower == "bigint" ? !0 : Number.isFinite(e.lower) && Number.isFinite(e.upper);
62
+ }, fs = (r) => {
63
+ const e = m(r);
64
+ return (e.upper + e.lower) / 2;
65
+ }, Mr = (r) => ({
66
+ lower: Math.min(...r.map((e) => m(e).lower)),
67
+ upper: Math.max(...r.map((e) => m(e).upper))
68
+ }), ds = (r) => ({
69
+ lower: Math.max(...r.map((e) => m(e).lower)),
70
+ upper: Math.min(...r.map((e) => m(e).upper))
71
+ }), gs = (r) => {
72
+ const e = m(r), t = typeof e.lower == "bigint";
73
+ return Array.from({ length: Number(Me(r)) }, (n, s) => t ? e.lower + BigInt(s) : e.lower + s);
74
+ }, mt = (r, e) => {
75
+ const t = r.map((i) => m(i)), n = t.findIndex((i) => C(i, e) || e < i.lower);
76
+ if (n === -1) return { index: r.length, position: 0 };
77
+ const s = t[n];
78
+ return C(s, e) ? { index: n, position: Number(e - s.lower) } : { index: n, position: 0 };
79
+ }, at = {
80
+ removeBefore: 0,
81
+ removeAfter: 0,
82
+ insertInto: 0,
83
+ deleteInBetween: 0
84
+ }, ps = (r, e) => {
85
+ const t = r.map((f) => m(f)), n = m(e);
86
+ if (t.length === 0) return at;
87
+ const s = mt(t, n.lower), i = mt(t, n.upper);
88
+ if (s.index === r.length) return { ...at, insertInto: r.length };
89
+ if (i.index === 0) return { ...at, removeAfter: i.position };
90
+ if (s.index === i.index)
91
+ return s.position !== 0 && i.position !== 0 ? null : {
92
+ removeAfter: i.position,
93
+ removeBefore: s.position,
94
+ insertInto: s.index,
95
+ deleteInBetween: 0
96
+ };
97
+ let o = i.index - s.index, u = s.index, h = $e(Number(Me(t[s.index])), s.position);
98
+ return s.position !== 0 ? (o -= 1, u += 1) : h = 0, {
99
+ removeBefore: h,
100
+ removeAfter: i.position,
101
+ insertInto: u,
102
+ deleteInBetween: o
103
+ };
104
+ }, Cr = (r, e, t) => {
105
+ const n = r.map((u) => m(u)), s = t > 0 ? 1 : t < 0 ? -1 : 0;
106
+ if (s === 0) return e;
107
+ let i = t, o = e;
108
+ for (; gt(i, 0) === !1; ) {
109
+ const u = n.findIndex((h) => s > 0 ? o >= h.lower && o < h.upper : o > h.lower && o <= h.upper);
110
+ if (u !== -1) {
111
+ const h = n[u];
112
+ let f;
113
+ if (s > 0 ? f = $e(h.upper, o) : f = $e(o, h.lower), f > 0) {
114
+ const g = Er(Ar(i), f);
115
+ if (o = Br(
116
+ o,
117
+ s > 0 ? g : -g
118
+ ), i = $e(i, s > 0 ? g : -g), gt(i, 0)) return o;
119
+ continue;
120
+ }
121
+ }
122
+ if (s > 0) {
123
+ const h = n.filter((f) => f.lower > o);
124
+ if (h.length > 0) o = h[0].lower;
125
+ else return o;
126
+ } else {
127
+ const h = n.filter((f) => f.upper < o);
128
+ if (h.length > 0)
129
+ o = h[h.length - 1].upper;
130
+ else return o;
131
+ }
132
+ }
133
+ return o;
134
+ }, Lr = (r, e, t) => {
135
+ const n = r.map((o) => m(o));
136
+ if (e === t) return typeof e == "bigint" ? 0n : 0;
137
+ const s = e < t ? m([e, t]) : m([t, e]);
138
+ let i = typeof e == "bigint" ? 0n : 0;
139
+ for (const o of n) {
140
+ const u = o.lower > s.lower ? o.lower : s.lower, h = o.upper < s.upper ? o.upper : s.upper;
141
+ if (u < h) {
142
+ const f = h - u;
143
+ i = i + f;
144
+ }
145
+ }
146
+ return i;
147
+ }, zu = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
148
+ __proto__: null,
149
+ CLIP: os,
150
+ DECIMAL: is,
151
+ INFINITE: ss,
152
+ ZERO: ns,
153
+ bounds: Ur,
154
+ buildInsertionPlan: ps,
155
+ clamp: yt,
156
+ construct: m,
157
+ contains: C,
158
+ distance: Lr,
159
+ equals: as,
160
+ findInsertPosition: mt,
161
+ isFinite: cs,
162
+ isZero: ls,
163
+ linspace: gs,
164
+ makeValid: pt,
165
+ max: Mr,
166
+ mean: fs,
167
+ min: ds,
168
+ overlapsWith: us,
169
+ span: Me,
170
+ spanIsZero: hs,
171
+ traverse: Cr
172
+ }, Symbol.toStringTag, { value: "Module" })), Rr = Jn, J = (r) => Rt.includes(r) ? r : et.includes(r) ? "y" : "x", ys = (r) => J(r) === "x" ? "y" : "x", ms = (r) => J(r) === "x" ? "width" : "height", ws = (r) => J(r) === "x" ? "left" : "top", bs = (r) => Rr.safeParse(r).success, vs = (r) => J(r) === "x" ? "signedWidth" : "signedHeight", $s = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
173
+ __proto__: null,
174
+ construct: J,
175
+ crude: Rr,
176
+ dimension: ms,
177
+ direction: jt,
178
+ isDirection: bs,
179
+ location: ws,
180
+ signedDimension: vs,
181
+ swap: ys
182
+ }, Symbol.toStringTag, { value: "Module" })), xs = (r) => {
183
+ const e = r.replace(/_[a-z]/g, (t) => t[1].toUpperCase());
184
+ return e.length > 1 && e[0] === e[0].toUpperCase() && e[1] === e[1].toUpperCase() || e.length === 0 ? e : e[0].toLowerCase() + e.slice(1);
185
+ }, Ft = (r) => {
186
+ const e = (t, n = wt) => {
187
+ if (typeof t == "string") return r(t);
188
+ if (Array.isArray(t)) return t.map((o) => e(o, n));
189
+ if (!ut(t)) return t;
190
+ n = Ts(n);
191
+ const s = {}, i = t;
192
+ return Object.keys(i).forEach((o) => {
193
+ let u = i[o];
194
+ const h = r(o);
195
+ n.recursive && (ut(u) ? lr(u, n.keepTypesOnRecursion) || (u = e(u, n)) : n.recursiveInArray && ur(u) && (u = [...u].map((f) => {
196
+ let g = f;
197
+ return ut(f) ? lr(g, n.keepTypesOnRecursion) || (g = e(f, n)) : ur(f) && (g = e({ key: f }, n).key), g;
198
+ }))), s[h] = u;
199
+ }), s;
200
+ };
201
+ return e;
202
+ }, tt = Ft(xs), Os = (r) => (
203
+ // Don't convert the first character and don't convert a character that is after a
204
+ // non-alphanumeric character
205
+ r.replace(
206
+ /([a-z0-9])([A-Z])/g,
207
+ (e, t, n) => `${t}_${n.toLowerCase()}`
208
+ )
209
+ ), _t = Ft(Os), jr = (r) => r.length === 0 ? r : r[0].toUpperCase() + r.slice(1), wt = {
210
+ recursive: !0,
211
+ recursiveInArray: !0,
212
+ keepTypesOnRecursion: [Number, String, Uint8Array]
213
+ }, Ts = (r = wt) => (r.recursive == null ? r = wt : r.recursiveInArray ?? (r.recursiveInArray = !1), r), ur = (r) => r != null && Array.isArray(r), ut = (r) => r != null && typeof r == "object" && !Array.isArray(r), lr = (r, e) => (e || []).some((t) => r instanceof t), Ss = (r) => r.replace(/\s+/g, "-").replace(
214
+ /([a-z0-9])([A-Z])/g,
215
+ (e, t, n) => `${t}-${n.toLowerCase()}`
216
+ ).toLowerCase(), Is = Ft(Ss), Fu = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
217
+ __proto__: null,
218
+ camelToSnake: _t,
219
+ capitalize: jr,
220
+ snakeToCamel: tt,
221
+ toKebab: Is
222
+ }, Symbol.toStringTag, { value: "Module" })), Ns = kt, Us = Dt, Bs = dt, Es = {
223
+ top: "bottom",
224
+ right: "left",
225
+ bottom: "top",
226
+ left: "right",
227
+ center: "center"
228
+ }, As = {
229
+ top: "left",
230
+ right: "top",
231
+ bottom: "right",
232
+ left: "bottom",
233
+ center: "center"
234
+ }, Ms = Xn, Z = (r) => r instanceof String || !Rt.includes(r) ? r : r === "x" ? "left" : "top", Cs = (r) => Es[Z(r)], Ls = (r) => As[Z(r)], Ue = (r) => {
235
+ const e = Z(r);
236
+ return e === "top" || e === "bottom" ? "y" : "x";
237
+ }, Rs = a.object({
238
+ x: kt.or(dt),
239
+ y: Dt.or(dt)
240
+ }), kr = a.object({ x: kt, y: Dt }), Ce = Object.freeze({ x: "left", y: "top" }), qt = Object.freeze({ x: "right", y: "top" }), rt = Object.freeze({ x: "left", y: "bottom" }), Wt = Object.freeze({ x: "right", y: "bottom" }), Vt = Object.freeze({ x: "center", y: "center" }), Yt = Object.freeze({ x: "center", y: "top" }), Zt = Object.freeze({ x: "center", y: "bottom" }), Ht = Object.freeze({ x: "right", y: "center" }), Gt = Object.freeze({ x: "left", y: "center" }), js = Object.freeze([
241
+ Gt,
242
+ Ht,
243
+ Yt,
244
+ Zt,
245
+ Ce,
246
+ qt,
247
+ rt,
248
+ Wt,
249
+ Vt
250
+ ]), Kt = (r, e) => r.x === e.x && r.y === e.y, ks = (r, e) => {
251
+ if (typeof e == "object") {
252
+ let t = !0;
253
+ return "x" in e && (r.x === e.x || (t = !1)), "y" in e && (r.y === e.y || (t = !1)), t;
254
+ }
255
+ return r.x === e || r.y === e;
256
+ }, Dr = (r) => [r.x, r.y], _e = (r) => Ue(Z(r)) === "x", Ds = (r) => Ue(Z(r)) === "y", Ps = (r) => `${r.x}${jr(r.y)}`, zs = (r, e) => {
257
+ let t, n;
258
+ if (typeof r == "object" && "x" in r ? (t = r.x, n = r.y) : (t = Z(r), n = Z(e ?? r)), Ue(t) === Ue(n) && t !== "center" && n !== "center")
259
+ throw new Error(
260
+ `[XYLocation] - encountered two locations with the same direction: ${t.toString()} - ${n.toString()}`
261
+ );
262
+ const s = { ...Vt };
263
+ return t === "center" ? _e(n) ? [s.x, s.y] = [n, t] : [s.x, s.y] = [t, n] : n === "center" ? _e(t) ? [s.x, s.y] = [t, n] : [s.x, s.y] = [n, t] : _e(t) ? [s.x, s.y] = [t, n] : [s.x, s.y] = [n, t], s;
264
+ }, Fs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
265
+ __proto__: null,
266
+ BOTTOM_CENTER: Zt,
267
+ BOTTOM_LEFT: rt,
268
+ BOTTOM_RIGHT: Wt,
269
+ CENTER: Vt,
270
+ CENTER_LEFT: Gt,
271
+ CENTER_LOCATIONS: Pt,
272
+ CENTER_RIGHT: Ht,
273
+ TOP_CENTER: Yt,
274
+ TOP_LEFT: Ce,
275
+ TOP_RIGHT: qt,
276
+ XY_LOCATIONS: js,
277
+ X_LOCATIONS: Qe,
278
+ Y_LOCATIONS: et,
279
+ center: Bs,
280
+ construct: Z,
281
+ constructXY: zs,
282
+ corner: kr,
283
+ crude: Ms,
284
+ direction: Ue,
285
+ isX: _e,
286
+ isY: Ds,
287
+ location: zt,
288
+ outer: Zn,
289
+ rotate90: Ls,
290
+ swap: Cs,
291
+ x: Ns,
292
+ xy: Rs,
293
+ xyCouple: Dr,
294
+ xyEquals: Kt,
295
+ xyMatches: ks,
296
+ xyToString: Ps,
297
+ y: Us
298
+ }, Symbol.toStringTag, { value: "Module" })), bt = a.union([
299
+ a.number(),
300
+ Ne,
301
+ Xe,
302
+ Lt,
303
+ qn,
304
+ Ir
305
+ ]), T = (r, e) => {
306
+ if (typeof r == "string") {
307
+ if (e === void 0) throw new Error("The y coordinate must be given.");
308
+ return r === "x" ? { x: e, y: 0 } : { x: 0, y: e };
309
+ }
310
+ return typeof r == "number" ? { x: r, y: e ?? r } : Array.isArray(r) ? { x: r[0], y: r[1] } : "signedWidth" in r ? { x: r.signedWidth, y: r.signedHeight } : "clientX" in r ? { x: r.clientX, y: r.clientY } : "width" in r ? { x: r.width, y: r.height } : { x: r.x, y: r.y };
311
+ }, D = Object.freeze({ x: 0, y: 0 }), Pr = Object.freeze({ x: 1, y: 1 }), _s = Object.freeze({ x: 1 / 0, y: 1 / 0 }), qs = Object.freeze({ x: NaN, y: NaN }), Ge = (r, e, t = 0) => {
312
+ const n = T(r), s = T(e);
313
+ return t === 0 ? n.x === s.x && n.y === s.y : Math.abs(n.x - s.x) <= t && Math.abs(n.y - s.y) <= t;
314
+ }, Ws = (r) => Ge(r, D), Jt = (r, e, t) => {
315
+ const n = T(r), s = T(e, t);
316
+ return { x: n.x * s.x, y: n.y * s.y };
317
+ }, zr = (r, e) => {
318
+ const t = T(r);
319
+ return { x: t.x + e, y: t.y };
320
+ }, Fr = (r, e) => {
321
+ const t = T(r);
322
+ return { x: t.x, y: t.y + e };
323
+ }, Be = (r, e, t, ...n) => typeof e == "string" && typeof t == "number" ? e === "x" ? zr(r, t) : Fr(r, t) : [r, e, t ?? D, ...n].reduce((s, i) => {
324
+ const o = T(i);
325
+ return { x: s.x + o.x, y: s.y + o.y };
326
+ }, D), Vs = (r, e, t) => {
327
+ const n = T(r);
328
+ return e === "x" ? { x: t, y: n.y } : { x: n.x, y: t };
329
+ }, Ys = (r, e) => {
330
+ const t = T(r), n = T(e);
331
+ return Math.sqrt((t.x - n.x) ** 2 + (t.y - n.y) ** 2);
332
+ }, Zs = (r, e) => {
333
+ const t = T(r), n = T(e);
334
+ return { x: n.x - t.x, y: n.y - t.y };
335
+ }, Hs = (r) => {
336
+ const e = T(r);
337
+ return Number.isNaN(e.x) || Number.isNaN(e.y);
338
+ }, Gs = (r) => {
339
+ const e = T(r);
340
+ return Number.isFinite(e.x) && Number.isFinite(e.y);
341
+ }, Ks = (r) => {
342
+ const e = T(r);
343
+ return [e.x, e.y];
344
+ }, Js = (r) => {
345
+ const e = T(r);
346
+ return { left: e.x, top: e.y };
347
+ }, vt = (r, e = 0) => {
348
+ const t = T(r);
349
+ return { x: Number(t.x.toFixed(e)), y: Number(t.y.toFixed(e)) };
350
+ }, fe = (r, e) => {
351
+ const t = T(r), n = T(e);
352
+ return { x: t.x - n.x, y: t.y - n.y };
353
+ }, de = (r) => {
354
+ const e = T(r), t = Math.hypot(e.x, e.y);
355
+ return t === 0 ? { x: 0, y: 0 } : { x: -e.y / t, y: e.x / t };
356
+ }, _r = (r) => {
357
+ const e = T(r), t = Math.hypot(e.x, e.y);
358
+ return t === 0 ? { x: 0, y: 0 } : { x: e.x / t, y: e.y / t };
359
+ }, qr = (...r) => {
360
+ const e = r.reduce((t, n) => Be(t, n), D);
361
+ return Jt(e, 1 / r.length);
362
+ }, Xs = (r, e) => {
363
+ const t = [];
364
+ for (let n = 0; n < r.length; n++) {
365
+ const s = r[n];
366
+ let i, o, u, h;
367
+ if (n === 0) {
368
+ const f = r[n + 1], g = fe(f, s);
369
+ o = de(g), u = o, h = e;
370
+ } else if (n === r.length - 1) {
371
+ const f = r[n - 1], g = fe(s, f);
372
+ i = de(g), u = i, h = e;
373
+ } else {
374
+ const f = r[n - 1], g = r[n + 1], d = fe(s, f), B = fe(g, s);
375
+ i = de(d), o = de(B);
376
+ const M = Math.acos(
377
+ (d.x * B.x + d.y * B.y) / (Math.hypot(d.x, d.y) * Math.hypot(B.x, B.y))
378
+ ), ue = Math.sin(M / 2);
379
+ ue === 0 ? h = e : h = e / ue, u = _r(qr(i, o));
380
+ }
381
+ t.push(Jt(u, h));
382
+ }
383
+ return t;
384
+ }, Qs = (r) => {
385
+ const e = T(r);
386
+ return { x: e.y, y: e.x };
387
+ }, _u = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
388
+ __proto__: null,
389
+ INFINITY: _s,
390
+ NAN: qs,
391
+ ONE: Pr,
392
+ ZERO: D,
393
+ average: qr,
394
+ calculateMiters: Xs,
395
+ clientXY: Ir,
396
+ construct: T,
397
+ couple: Ks,
398
+ crudeZ: bt,
399
+ css: Js,
400
+ distance: Ys,
401
+ equals: Ge,
402
+ isFinite: Gs,
403
+ isNan: Hs,
404
+ isZero: Ws,
405
+ normal: de,
406
+ normalize: _r,
407
+ scale: Jt,
408
+ set: Vs,
409
+ sub: fe,
410
+ swap: Qs,
411
+ translate: Be,
412
+ translateX: zr,
413
+ translateY: Fr,
414
+ translation: Zs,
415
+ truncate: vt,
416
+ xy: Ne
417
+ }, Symbol.toStringTag, { value: "Module" })), ke = a.union([a.number(), a.string()]), ei = a.object({
418
+ top: ke,
419
+ left: ke,
420
+ width: ke,
421
+ height: ke
422
+ }), ti = a.object({
423
+ left: a.number(),
424
+ top: a.number(),
425
+ right: a.number(),
426
+ bottom: a.number()
427
+ }), ri = a.object({
428
+ one: Ne,
429
+ two: Ne,
430
+ root: kr
431
+ }), Wr = { one: D, two: D, root: Ce }, ni = { one: D, two: Pr, root: rt }, Vr = (r, e) => ({
432
+ one: r.one,
433
+ two: r.two,
434
+ root: e ?? r.root
435
+ }), S = (r, e, t = 0, n = 0, s) => {
436
+ const i = {
437
+ one: { ...D },
438
+ two: { ...D },
439
+ root: s ?? Ce
440
+ };
441
+ if (typeof r == "number") {
442
+ if (typeof e != "number")
443
+ throw new Error("Box constructor called with invalid arguments");
444
+ return i.one = { x: r, y: e }, i.two = { x: i.one.x + t, y: i.one.y + n }, i;
445
+ }
446
+ return "one" in r && "two" in r && "root" in r ? { ...r, root: s ?? r.root } : ("getBoundingClientRect" in r && (r = r.getBoundingClientRect()), "left" in r ? (i.one = { x: r.left, y: r.top }, i.two = { x: r.right, y: r.bottom }, i) : (i.one = r, e == null ? i.two = { x: i.one.x + t, y: i.one.y + n } : typeof e == "number" ? i.two = { x: i.one.x + e, y: i.one.y + t } : "width" in e ? i.two = {
447
+ x: i.one.x + e.width,
448
+ y: i.one.y + e.height
449
+ } : "signedWidth" in e ? i.two = {
450
+ x: i.one.x + e.signedWidth,
451
+ y: i.one.y + e.signedHeight
452
+ } : i.two = e, i));
453
+ }, si = (r, e, t) => {
454
+ const n = S(r);
455
+ if (typeof e == "string") {
456
+ if (t == null) throw new Error("Invalid arguments for resize");
457
+ const s = J(e);
458
+ return S(
459
+ n.one,
460
+ void 0,
461
+ s === "x" ? t : H(n),
462
+ s === "y" ? t : G(n),
463
+ n.root
464
+ );
465
+ }
466
+ return S(n.one, e, void 0, void 0, n.root);
467
+ }, ii = (r, e, t = !0) => {
468
+ const n = S(r);
469
+ let s = (i, o) => i < o;
470
+ return t && (s = (i, o) => i <= o), "one" in e ? s(V(n), V(e)) && s(ee(e), ee(n)) && s(Y(n), Y(e)) && s(te(e), te(n)) : s(V(n), e.x) && s(e.x, ee(n)) && s(Y(n), e.y) && s(e.y, te(n));
471
+ }, oi = (r, e) => Ge(r.one, e.one) && Ge(r.two, e.two) && Kt(r.root, e.root), Yr = (r) => ({
472
+ width: H(r),
473
+ height: G(r)
474
+ }), ai = (r) => ({
475
+ signedWidth: nt(r),
476
+ signedHeight: st(r)
477
+ }), ui = (r) => ({
478
+ top: Y(r),
479
+ left: V(r),
480
+ width: H(r),
481
+ height: G(r)
482
+ }), Xt = (r, e, t = !1) => {
483
+ const n = J(e) === "y" ? st(r) : nt(r);
484
+ return t ? n : Math.abs(n);
485
+ }, F = (r, e) => {
486
+ const t = S(r);
487
+ return {
488
+ x: e.x === "center" ? $t(t).x : ne(t, e.x),
489
+ y: e.y === "center" ? $t(t).y : ne(t, e.y)
490
+ };
491
+ }, ne = (r, e) => {
492
+ const t = S(r), n = Dr(t.root).includes(e) ? Math.min : Math.max;
493
+ return Qe.includes(e) ? n(t.one.x, t.two.x) : n(t.one.y, t.two.y);
494
+ }, li = (r) => r.one.x === r.two.x && r.one.y === r.two.y, H = (r) => Xt(r, "x"), G = (r) => Xt(r, "y"), nt = (r) => {
495
+ const e = S(r);
496
+ return e.two.x - e.one.x;
497
+ }, st = (r) => {
498
+ const e = S(r);
499
+ return e.two.y - e.one.y;
500
+ }, Zr = (r) => F(r, Ce), hi = (r) => F(r, Yt), ci = (r) => F(r, qt), fi = (r) => F(r, rt), di = (r) => F(r, Zt), gi = (r) => F(r, Wt), pi = (r) => F(r, Gt), yi = (r) => F(r, Ht), ee = (r) => ne(r, "right"), te = (r) => ne(r, "bottom"), V = (r) => ne(r, "left"), Y = (r) => ne(r, "top"), $t = (r) => Be(Zr(r), {
501
+ x: nt(r) / 2,
502
+ y: st(r) / 2
503
+ }), Qt = (r) => {
504
+ const e = S(r);
505
+ return e.root.x === "left" ? V(e) : ee(e);
506
+ }, er = (r) => {
507
+ const e = S(r);
508
+ return e.root.y === "top" ? Y(e) : te(e);
509
+ }, mi = (r) => ({ x: Qt(r), y: er(r) }), qe = (r) => {
510
+ const e = S(r);
511
+ return { lower: e.one.x, upper: e.two.x };
512
+ }, We = (r) => {
513
+ const e = S(r);
514
+ return { lower: e.one.y, upper: e.two.y };
515
+ }, wi = (r, e) => Vr(r, e), bi = (r, e) => {
516
+ const t = S(r), n = Qe.includes(e) ? "x" : et.includes(e) ? "y" : null;
517
+ if (n === null) throw new Error(`Invalid location: ${e}`);
518
+ const s = e === "top" || e === "left" ? Math.min : Math.max, i = { ...t.one }, o = { ...t.two };
519
+ return i[n] = s(t.one[n], t.two[n]), o[n] = s(t.one[n], t.two[n]), [i, o];
520
+ }, vi = (r, e) => {
521
+ const t = S(r), n = S(e), s = Qt(n) + (H(n) - H(t)) / 2, i = er(n) + (G(n) - G(t)) / 2;
522
+ return S({ x: s, y: i }, Yr(t));
523
+ }, Hr = (r) => typeof r != "object" || r == null ? !1 : "one" in r && "two" in r && "root" in r, $i = (r) => H(r) / G(r), xi = (r, e, t) => {
524
+ if (typeof e == "string") {
525
+ if (t == null) throw new Error("Undefined amount passed into box.translate");
526
+ const s = J(e);
527
+ e = T(s, t);
528
+ }
529
+ const n = S(r);
530
+ return S(
531
+ Be(n.one, e),
532
+ Be(n.two, e),
533
+ void 0,
534
+ void 0,
535
+ n.root
536
+ );
537
+ }, Oi = (r, e) => {
538
+ const t = Math.max(V(r), V(e)), n = Math.max(Y(r), Y(e)), s = Math.min(ee(r), ee(e)), i = Math.min(te(r), te(e));
539
+ return t > s || n > i ? Wr : S({ x: t, y: n }, { x: s, y: i }, void 0, void 0, r.root);
540
+ }, Ti = (r) => H(r) * G(r), Si = (r, e) => {
541
+ const t = S(r);
542
+ return S(
543
+ vt(t.one, e),
544
+ vt(t.two, e),
545
+ void 0,
546
+ void 0,
547
+ t.root
548
+ );
549
+ }, Ii = (r, e, t, n, s, i) => {
550
+ const o = { x: r, y: e }, u = { x: r + t, y: e + n };
551
+ return s.x !== i.x && (s.x === "center" ? (o.x -= t / 2, u.x -= t / 2) : (o.x -= t, u.x -= t)), s.y !== i.y && (s.y === "center" ? (o.y -= n / 2, u.y -= n / 2) : (o.y -= n, u.y -= n)), S(o, u, void 0, void 0, i);
552
+ }, qu = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
553
+ __proto__: null,
554
+ DECIMAL: ni,
555
+ ZERO: Wr,
556
+ area: Ti,
557
+ areaIsZero: li,
558
+ aspect: $i,
559
+ bottom: te,
560
+ bottomCenter: di,
561
+ bottomLeft: fi,
562
+ bottomRight: gi,
563
+ box: ri,
564
+ center: $t,
565
+ centerLeft: pi,
566
+ centerRight: yi,
567
+ construct: S,
568
+ constructWithAlternateRoot: Ii,
569
+ contains: ii,
570
+ copy: Vr,
571
+ css: ui,
572
+ cssBox: ei,
573
+ dim: Xt,
574
+ dims: Yr,
575
+ domRect: ti,
576
+ edgePoints: bi,
577
+ equals: oi,
578
+ height: G,
579
+ intersection: Oi,
580
+ isBox: Hr,
581
+ left: V,
582
+ loc: ne,
583
+ positionInCenter: vi,
584
+ reRoot: wi,
585
+ resize: si,
586
+ right: ee,
587
+ root: mi,
588
+ signedDims: ai,
589
+ signedHeight: st,
590
+ signedWidth: nt,
591
+ top: Y,
592
+ topCenter: hi,
593
+ topLeft: Zr,
594
+ topRight: ci,
595
+ translate: xi,
596
+ truncate: Si,
597
+ width: H,
598
+ x: Qt,
599
+ xBounds: qe,
600
+ xyLoc: F,
601
+ y: er,
602
+ yBounds: We
603
+ }, Symbol.toStringTag, { value: "Module" })), Gr = a.object({ signedWidth: a.number(), signedHeight: a.number() }), Ni = a.union([Lt, Gr, Ne, Xe]), Ui = { width: 0, height: 0 }, Bi = { width: 1, height: 1 }, L = (r, e) => typeof r == "number" ? { width: r, height: e ?? r } : Array.isArray(r) ? { width: r[0], height: r[1] } : "x" in r ? { width: r.x, height: r.y } : "signedWidth" in r ? { width: r.signedWidth, height: r.signedHeight } : { ...r }, Ei = (r, e) => {
604
+ if (e == null) return !1;
605
+ const t = L(r), n = L(e);
606
+ return t.width === n.width && t.height === n.height;
607
+ }, Ai = (r) => {
608
+ const e = L(r);
609
+ return { width: e.height, height: e.width };
610
+ }, Mi = (r) => {
611
+ const e = L(r);
612
+ return `0 0 ${e.width} ${e.height}`;
613
+ }, Ci = (r) => {
614
+ const e = L(r);
615
+ return [e.width, e.height];
616
+ }, Li = (r) => ({
617
+ width: Math.max(...r.map((e) => L(e).width)),
618
+ height: Math.max(...r.map((e) => L(e).height))
619
+ }), Ri = (r) => ({
620
+ width: Math.min(...r.map((e) => L(e).width)),
621
+ height: Math.min(...r.map((e) => L(e).height))
622
+ }), ji = (r, e) => {
623
+ const t = L(r);
624
+ return { width: t.width * e, height: t.height * e };
625
+ }, Wu = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
626
+ __proto__: null,
627
+ DECIMAL: Bi,
628
+ ZERO: Ui,
629
+ construct: L,
630
+ couple: Ci,
631
+ crude: Ni,
632
+ dimensions: Lt,
633
+ equals: Ei,
634
+ max: Li,
635
+ min: Ri,
636
+ scale: ji,
637
+ signed: Gr,
638
+ svgViewBox: Mi,
639
+ swap: Ai
640
+ }, Symbol.toStringTag, { value: "Module" }));
641
+ var ki = Object.defineProperty, Di = (r, e, t) => e in r ? ki(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, z = (r, e, t) => Di(r, typeof e != "symbol" ? e + "" : e, t);
642
+ const Pi = (r, e, t) => e !== void 0 && r < e ? e : t !== void 0 && r > t ? t : r, zi = a.object({ offset: bt, scale: bt }), Fi = a.object({ offset: a.number(), scale: a.number() }), _i = (r) => (e, t, n, s) => t === "dimension" ? [e, n] : [
643
+ e,
644
+ s ? n - r : n + r
645
+ ], qi = (r) => (e, t, n, s) => [
646
+ e,
647
+ s ? n / r : n * r
648
+ ], Wi = (r) => (e, t, n) => {
649
+ if (e === null) return [r, n];
650
+ const { lower: s, upper: i } = e, { lower: o, upper: u } = r, h = i - s, f = u - o;
651
+ if (t === "dimension") return [r, n * (f / h)];
652
+ const g = (n - s) * (f / h) + o;
653
+ return [r, g];
654
+ }, Vi = (r) => (e, t, n) => [r, n], Yi = () => (r, e, t) => {
655
+ if (r === null) throw new Error("cannot invert without bounds");
656
+ if (e === "dimension") return [r, t];
657
+ const { lower: n, upper: s } = r;
658
+ return [r, s - (t - n)];
659
+ }, Zi = (r) => (e, t, n) => {
660
+ const { lower: s, upper: i } = r;
661
+ return n = Pi(n, s, i), [e, n];
662
+ }, xt = class ge {
663
+ constructor() {
664
+ z(this, "ops", []), z(this, "currBounds", null), z(this, "currType", null), z(this, "reversed", !1), this.ops = [];
665
+ }
666
+ /**
667
+ * @returns a new scale with a translation as its first operation. Any number provided
668
+ * to the {@link pos} operation on the scale will be translated by the specified value.
669
+ * @param value - The amount to translate by.
670
+ */
671
+ static translate(e) {
672
+ return new ge().translate(e);
673
+ }
674
+ /**
675
+ * @returns a new scale with a magnification as its first operation. Any number provided
676
+ * to the {@link pos} or {@link dim} operation will be multiplied by the specified value.
677
+ * @param value - The amount to translate by.
678
+ */
679
+ static magnify(e) {
680
+ return new ge().magnify(e);
681
+ }
682
+ static scale(e, t) {
683
+ return new ge().scale(e, t);
684
+ }
685
+ /**
686
+ * @returns a copy of the scale with a translation as its next operation. Any
687
+ * number provided to the {@link pos} method on the scale will be translated by the
688
+ * specified value.
689
+ * @param value - The amount to translate by.
690
+ */
691
+ translate(e) {
692
+ const t = this.new(), n = _i(e);
693
+ return n.type = "translate", t.ops.push(n), t;
694
+ }
695
+ /**
696
+ * @returns a copy of the scale with a translation as its next operation. Any number
697
+ * provided to the {@link pos} or {@link dim} method on the scale will be multiplied
698
+ * by the specified value.
699
+ * @param value - The amount to magnify by.
700
+ */
701
+ magnify(e) {
702
+ const t = this.new(), n = qi(e);
703
+ return n.type = "magnify", t.ops.push(n), t;
704
+ }
705
+ scale(e, t) {
706
+ const n = m(e, t), s = this.new(), i = Wi(n);
707
+ return i.type = "scale", s.ops.push(i), s;
708
+ }
709
+ clamp(e, t) {
710
+ const n = m(e, t), s = this.new(), i = Zi(n);
711
+ return i.type = "clamp", s.ops.push(i), s;
712
+ }
713
+ reBound(e, t) {
714
+ const n = m(e, t), s = this.new(), i = Vi(n);
715
+ return i.type = "re-bound", s.ops.push(i), s;
716
+ }
717
+ invert() {
718
+ const e = Yi();
719
+ e.type = "invert";
720
+ const t = this.new();
721
+ return t.ops.push(e), t;
722
+ }
723
+ pos(e) {
724
+ return this.exec("position", e);
725
+ }
726
+ dim(e) {
727
+ return this.exec("dimension", e);
728
+ }
729
+ new() {
730
+ const e = new ge();
731
+ return e.ops = this.ops.slice(), e.reversed = this.reversed, e;
732
+ }
733
+ exec(e, t) {
734
+ return this.currBounds = null, this.ops.reduce(
735
+ ([n, s], i) => i(n, e, s, this.reversed),
736
+ [null, t]
737
+ )[1];
738
+ }
739
+ reverse() {
740
+ const e = this.new();
741
+ e.ops.reverse();
742
+ const t = [];
743
+ return e.ops.forEach((n, s) => {
744
+ if (n.type === "scale" || t.some(([o, u]) => s >= o && s <= u))
745
+ return;
746
+ const i = e.ops.findIndex((o, u) => o.type === "scale" && u > s);
747
+ i !== -1 && t.push([s, i]);
748
+ }), t.forEach(([n, s]) => {
749
+ const i = e.ops.slice(n, s);
750
+ i.unshift(e.ops[s]), e.ops.splice(n, s - n + 1, ...i);
751
+ }), e.reversed = !e.reversed, e;
752
+ }
753
+ get transform() {
754
+ return { scale: this.dim(1), offset: this.pos(0) };
755
+ }
756
+ };
757
+ z(xt, "IDENTITY", new xt());
758
+ let Ot = xt;
759
+ const Tt = class P {
760
+ constructor(e = new Ot(), t = new Ot(), n = null) {
761
+ z(this, "x"), z(this, "y"), z(this, "currRoot"), this.x = e, this.y = t, this.currRoot = n;
762
+ }
763
+ static translate(e, t) {
764
+ return new P().translate(e, t);
765
+ }
766
+ static translateX(e) {
767
+ return new P().translateX(e);
768
+ }
769
+ static translateY(e) {
770
+ return new P().translateY(e);
771
+ }
772
+ static clamp(e) {
773
+ return new P().clamp(e);
774
+ }
775
+ static magnify(e) {
776
+ return new P().magnify(e);
777
+ }
778
+ static scale(e) {
779
+ return new P().scale(e);
780
+ }
781
+ static reBound(e) {
782
+ return new P().reBound(e);
783
+ }
784
+ translate(e, t) {
785
+ const n = T(e, t), s = this.copy();
786
+ return s.x = this.x.translate(n.x), s.y = this.y.translate(n.y), s;
787
+ }
788
+ translateX(e) {
789
+ const t = this.copy();
790
+ return t.x = this.x.translate(e), t;
791
+ }
792
+ translateY(e) {
793
+ const t = this.copy();
794
+ return t.y = this.y.translate(e), t;
795
+ }
796
+ magnify(e) {
797
+ const t = this.copy();
798
+ return t.x = this.x.magnify(e.x), t.y = this.y.magnify(e.y), t;
799
+ }
800
+ scale(e) {
801
+ const t = this.copy();
802
+ if (Hr(e)) {
803
+ const n = this.currRoot;
804
+ return t.currRoot = e.root, n != null && !Kt(n, e.root) && (n.x !== e.root.x && (t.x = t.x.invert()), n.y !== e.root.y && (t.y = t.y.invert())), t.x = t.x.scale(qe(e)), t.y = t.y.scale(We(e)), t;
805
+ }
806
+ return t.x = t.x.scale(e.width), t.y = t.y.scale(e.height), t;
807
+ }
808
+ reBound(e) {
809
+ const t = this.copy();
810
+ return t.x = this.x.reBound(qe(e)), t.y = this.y.reBound(We(e)), t;
811
+ }
812
+ clamp(e) {
813
+ const t = this.copy();
814
+ return t.x = this.x.clamp(qe(e)), t.y = this.y.clamp(We(e)), t;
815
+ }
816
+ copy() {
817
+ const e = new P();
818
+ return e.currRoot = this.currRoot, e.x = this.x, e.y = this.y, e;
819
+ }
820
+ reverse() {
821
+ const e = this.copy();
822
+ return e.x = this.x.reverse(), e.y = this.y.reverse(), e;
823
+ }
824
+ pos(e) {
825
+ return { x: this.x.pos(e.x), y: this.y.pos(e.y) };
826
+ }
827
+ dim(e) {
828
+ return { x: this.x.dim(e.x), y: this.y.dim(e.y) };
829
+ }
830
+ box(e) {
831
+ return S(
832
+ this.pos(e.one),
833
+ this.pos(e.two),
834
+ 0,
835
+ 0,
836
+ this.currRoot ?? e.root
837
+ );
838
+ }
839
+ get transform() {
840
+ return {
841
+ scale: this.dim({ x: 1, y: 1 }),
842
+ offset: this.pos({ x: 0, y: 0 })
843
+ };
844
+ }
845
+ };
846
+ z(Tt, "IDENTITY", new Tt());
847
+ let Hi = Tt;
848
+ const Vu = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
849
+ __proto__: null,
850
+ Scale: Ot,
851
+ XY: Hi,
852
+ crudeXYTransform: zi,
853
+ transform: Fi
854
+ }, Symbol.toStringTag, { value: "Module" }));
855
+ function Kr(r) {
856
+ var e, t, n = "";
857
+ if (typeof r == "string" || typeof r == "number") n += r;
858
+ else if (typeof r == "object") if (Array.isArray(r)) {
859
+ var s = r.length;
860
+ for (e = 0; e < s; e++) r[e] && (t = Kr(r[e])) && (n && (n += " "), n += t);
861
+ } else for (t in r) r[t] && (n && (n += " "), n += t);
862
+ return n;
863
+ }
864
+ function Gi() {
865
+ for (var r, e, t = 0, n = "", s = arguments.length; t < s; t++) (r = arguments[t]) && (e = Kr(r)) && (n && (n += " "), n += e);
866
+ return n;
867
+ }
868
+ const Ki = Gi, hr = "-", cr = "__", De = "--", Jr = (r) => {
869
+ const e = (...t) => Ki(...t);
870
+ return e.B = (t) => r + hr + t, e.E = (t) => r + cr + t, e.M = (t) => r + De + t, e.BM = (t, n) => e.B(t) + De + n, e.BE = (t, n) => e.B(t) + cr + n, e.BEM = (t, n, s) => e.BE(t, n) + De + s, e.extend = (t) => Jr(e.B(t)), e.var = (t) => De + r + hr + t, e;
871
+ }, tr = (r) => r != null && typeof r == "object" && !Array.isArray(r);
872
+ var Ji = Object.defineProperty, Xi = (r, e, t) => e in r ? Ji(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, ie = (r, e, t) => Xi(r, typeof e != "symbol" ? e + "" : e, t);
873
+ function Qi(r) {
874
+ const e = r.length;
875
+ let t = 0, n = 0;
876
+ for (; n < e; ) {
877
+ let s = r.charCodeAt(n++);
878
+ if ((s & 4294967168) === 0) {
879
+ t++;
880
+ continue;
881
+ } else if ((s & 4294965248) === 0)
882
+ t += 2;
883
+ else {
884
+ if (s >= 55296 && s <= 56319 && n < e) {
885
+ const i = r.charCodeAt(n);
886
+ (i & 64512) === 56320 && (++n, s = ((s & 1023) << 10) + (i & 1023) + 65536);
887
+ }
888
+ (s & 4294901760) === 0 ? t += 3 : t += 4;
889
+ }
890
+ }
891
+ return t;
892
+ }
893
+ function eo(r, e, t) {
894
+ const n = r.length;
895
+ let s = t, i = 0;
896
+ for (; i < n; ) {
897
+ let o = r.charCodeAt(i++);
898
+ if ((o & 4294967168) === 0) {
899
+ e[s++] = o;
900
+ continue;
901
+ } else if ((o & 4294965248) === 0)
902
+ e[s++] = o >> 6 & 31 | 192;
903
+ else {
904
+ if (o >= 55296 && o <= 56319 && i < n) {
905
+ const u = r.charCodeAt(i);
906
+ (u & 64512) === 56320 && (++i, o = ((o & 1023) << 10) + (u & 1023) + 65536);
907
+ }
908
+ (o & 4294901760) === 0 ? (e[s++] = o >> 12 & 15 | 224, e[s++] = o >> 6 & 63 | 128) : (e[s++] = o >> 18 & 7 | 240, e[s++] = o >> 12 & 63 | 128, e[s++] = o >> 6 & 63 | 128);
909
+ }
910
+ e[s++] = o & 63 | 128;
911
+ }
912
+ }
913
+ const to = new TextEncoder(), ro = 50;
914
+ function no(r, e, t) {
915
+ to.encodeInto(r, e.subarray(t));
916
+ }
917
+ function so(r, e, t) {
918
+ r.length > ro ? no(r, e, t) : eo(r, e, t);
919
+ }
920
+ const io = 4096;
921
+ function Xr(r, e, t) {
922
+ let n = e;
923
+ const s = n + t, i = [];
924
+ let o = "";
925
+ for (; n < s; ) {
926
+ const u = r[n++];
927
+ if ((u & 128) === 0)
928
+ i.push(u);
929
+ else if ((u & 224) === 192) {
930
+ const h = r[n++] & 63;
931
+ i.push((u & 31) << 6 | h);
932
+ } else if ((u & 240) === 224) {
933
+ const h = r[n++] & 63, f = r[n++] & 63;
934
+ i.push((u & 31) << 12 | h << 6 | f);
935
+ } else if ((u & 248) === 240) {
936
+ const h = r[n++] & 63, f = r[n++] & 63, g = r[n++] & 63;
937
+ let d = (u & 7) << 18 | h << 12 | f << 6 | g;
938
+ d > 65535 && (d -= 65536, i.push(d >>> 10 & 1023 | 55296), d = 56320 | d & 1023), i.push(d);
939
+ } else
940
+ i.push(u);
941
+ i.length >= io && (o += String.fromCharCode(...i), i.length = 0);
942
+ }
943
+ return i.length > 0 && (o += String.fromCharCode(...i)), o;
944
+ }
945
+ const oo = new TextDecoder(), ao = 200;
946
+ function uo(r, e, t) {
947
+ const n = r.subarray(e, e + t);
948
+ return oo.decode(n);
949
+ }
950
+ function lo(r, e, t) {
951
+ return t > ao ? uo(r, e, t) : Xr(r, e, t);
952
+ }
953
+ let Pe = class {
954
+ constructor(e, t) {
955
+ this.type = e, this.data = t;
956
+ }
957
+ }, k = class St extends Error {
958
+ constructor(e) {
959
+ super(e);
960
+ const t = Object.create(St.prototype);
961
+ Object.setPrototypeOf(this, t), Object.defineProperty(this, "name", {
962
+ configurable: !0,
963
+ enumerable: !1,
964
+ value: St.name
965
+ });
966
+ }
967
+ };
968
+ const le = 4294967295;
969
+ function ho(r, e, t) {
970
+ const n = t / 4294967296, s = t;
971
+ r.setUint32(e, n), r.setUint32(e + 4, s);
972
+ }
973
+ function Qr(r, e, t) {
974
+ const n = Math.floor(t / 4294967296), s = t;
975
+ r.setUint32(e, n), r.setUint32(e + 4, s);
976
+ }
977
+ function en(r, e) {
978
+ const t = r.getInt32(e), n = r.getUint32(e + 4);
979
+ return t * 4294967296 + n;
980
+ }
981
+ function co(r, e) {
982
+ const t = r.getUint32(e), n = r.getUint32(e + 4);
983
+ return t * 4294967296 + n;
984
+ }
985
+ const fo = -1, go = 4294967296 - 1, po = 17179869184 - 1;
986
+ function yo({ sec: r, nsec: e }) {
987
+ if (r >= 0 && e >= 0 && r <= po)
988
+ if (e === 0 && r <= go) {
989
+ const t = new Uint8Array(4);
990
+ return new DataView(t.buffer).setUint32(0, r), t;
991
+ } else {
992
+ const t = r / 4294967296, n = r & 4294967295, s = new Uint8Array(8), i = new DataView(s.buffer);
993
+ return i.setUint32(0, e << 2 | t & 3), i.setUint32(4, n), s;
994
+ }
995
+ else {
996
+ const t = new Uint8Array(12), n = new DataView(t.buffer);
997
+ return n.setUint32(0, e), Qr(n, 4, r), t;
998
+ }
999
+ }
1000
+ function mo(r) {
1001
+ const e = r.getTime(), t = Math.floor(e / 1e3), n = (e - t * 1e3) * 1e6, s = Math.floor(n / 1e9);
1002
+ return {
1003
+ sec: t + s,
1004
+ nsec: n - s * 1e9
1005
+ };
1006
+ }
1007
+ function wo(r) {
1008
+ if (r instanceof Date) {
1009
+ const e = mo(r);
1010
+ return yo(e);
1011
+ } else
1012
+ return null;
1013
+ }
1014
+ function bo(r) {
1015
+ const e = new DataView(r.buffer, r.byteOffset, r.byteLength);
1016
+ switch (r.byteLength) {
1017
+ case 4:
1018
+ return { sec: e.getUint32(0), nsec: 0 };
1019
+ case 8: {
1020
+ const t = e.getUint32(0), n = e.getUint32(4), s = (t & 3) * 4294967296 + n, i = t >>> 2;
1021
+ return { sec: s, nsec: i };
1022
+ }
1023
+ case 12: {
1024
+ const t = en(e, 4), n = e.getUint32(0);
1025
+ return { sec: t, nsec: n };
1026
+ }
1027
+ default:
1028
+ throw new k(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${r.length}`);
1029
+ }
1030
+ }
1031
+ function vo(r) {
1032
+ const e = bo(r);
1033
+ return new Date(e.sec * 1e3 + e.nsec / 1e6);
1034
+ }
1035
+ const $o = {
1036
+ type: fo,
1037
+ encode: wo,
1038
+ decode: vo
1039
+ };
1040
+ let Ee = class {
1041
+ constructor() {
1042
+ this.builtInEncoders = [], this.builtInDecoders = [], this.encoders = [], this.decoders = [], this.register($o);
1043
+ }
1044
+ register({ type: e, encode: t, decode: n }) {
1045
+ if (e >= 0)
1046
+ this.encoders[e] = t, this.decoders[e] = n;
1047
+ else {
1048
+ const s = -1 - e;
1049
+ this.builtInEncoders[s] = t, this.builtInDecoders[s] = n;
1050
+ }
1051
+ }
1052
+ tryToEncode(e, t) {
1053
+ for (let n = 0; n < this.builtInEncoders.length; n++) {
1054
+ const s = this.builtInEncoders[n];
1055
+ if (s != null) {
1056
+ const i = s(e, t);
1057
+ if (i != null) {
1058
+ const o = -1 - n;
1059
+ return new Pe(o, i);
1060
+ }
1061
+ }
1062
+ }
1063
+ for (let n = 0; n < this.encoders.length; n++) {
1064
+ const s = this.encoders[n];
1065
+ if (s != null) {
1066
+ const i = s(e, t);
1067
+ if (i != null) {
1068
+ const o = n;
1069
+ return new Pe(o, i);
1070
+ }
1071
+ }
1072
+ }
1073
+ return e instanceof Pe ? e : null;
1074
+ }
1075
+ decode(e, t, n) {
1076
+ const s = t < 0 ? this.builtInDecoders[-1 - t] : this.decoders[t];
1077
+ return s ? s(e, t, n) : new Pe(t, e);
1078
+ }
1079
+ };
1080
+ Ee.defaultCodec = new Ee();
1081
+ function xo(r) {
1082
+ return r instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && r instanceof SharedArrayBuffer;
1083
+ }
1084
+ function It(r) {
1085
+ return r instanceof Uint8Array ? r : ArrayBuffer.isView(r) ? new Uint8Array(r.buffer, r.byteOffset, r.byteLength) : xo(r) ? new Uint8Array(r) : Uint8Array.from(r);
1086
+ }
1087
+ const Oo = 100, To = 2048;
1088
+ let So = class tn {
1089
+ constructor(e) {
1090
+ this.entered = !1, this.extensionCodec = (e == null ? void 0 : e.extensionCodec) ?? Ee.defaultCodec, this.context = e == null ? void 0 : e.context, this.useBigInt64 = (e == null ? void 0 : e.useBigInt64) ?? !1, this.maxDepth = (e == null ? void 0 : e.maxDepth) ?? Oo, this.initialBufferSize = (e == null ? void 0 : e.initialBufferSize) ?? To, this.sortKeys = (e == null ? void 0 : e.sortKeys) ?? !1, this.forceFloat32 = (e == null ? void 0 : e.forceFloat32) ?? !1, this.ignoreUndefined = (e == null ? void 0 : e.ignoreUndefined) ?? !1, this.forceIntegerToFloat = (e == null ? void 0 : e.forceIntegerToFloat) ?? !1, this.pos = 0, this.view = new DataView(new ArrayBuffer(this.initialBufferSize)), this.bytes = new Uint8Array(this.view.buffer);
1091
+ }
1092
+ clone() {
1093
+ return new tn({
1094
+ extensionCodec: this.extensionCodec,
1095
+ context: this.context,
1096
+ useBigInt64: this.useBigInt64,
1097
+ maxDepth: this.maxDepth,
1098
+ initialBufferSize: this.initialBufferSize,
1099
+ sortKeys: this.sortKeys,
1100
+ forceFloat32: this.forceFloat32,
1101
+ ignoreUndefined: this.ignoreUndefined,
1102
+ forceIntegerToFloat: this.forceIntegerToFloat
1103
+ });
1104
+ }
1105
+ reinitializeState() {
1106
+ this.pos = 0;
1107
+ }
1108
+ /**
1109
+ * This is almost equivalent to {@link Encoder#encode}, but it returns an reference of the encoder's internal buffer and thus much faster than {@link Encoder#encode}.
1110
+ *
1111
+ * @returns Encodes the object and returns a shared reference the encoder's internal buffer.
1112
+ */
1113
+ encodeSharedRef(e) {
1114
+ if (this.entered)
1115
+ return this.clone().encodeSharedRef(e);
1116
+ try {
1117
+ return this.entered = !0, this.reinitializeState(), this.doEncode(e, 1), this.bytes.subarray(0, this.pos);
1118
+ } finally {
1119
+ this.entered = !1;
1120
+ }
1121
+ }
1122
+ /**
1123
+ * @returns Encodes the object and returns a copy of the encoder's internal buffer.
1124
+ */
1125
+ encode(e) {
1126
+ if (this.entered)
1127
+ return this.clone().encode(e);
1128
+ try {
1129
+ return this.entered = !0, this.reinitializeState(), this.doEncode(e, 1), this.bytes.slice(0, this.pos);
1130
+ } finally {
1131
+ this.entered = !1;
1132
+ }
1133
+ }
1134
+ doEncode(e, t) {
1135
+ if (t > this.maxDepth)
1136
+ throw new Error(`Too deep objects in depth ${t}`);
1137
+ e == null ? this.encodeNil() : typeof e == "boolean" ? this.encodeBoolean(e) : typeof e == "number" ? this.forceIntegerToFloat ? this.encodeNumberAsFloat(e) : this.encodeNumber(e) : typeof e == "string" ? this.encodeString(e) : this.useBigInt64 && typeof e == "bigint" ? this.encodeBigInt64(e) : this.encodeObject(e, t);
1138
+ }
1139
+ ensureBufferSizeToWrite(e) {
1140
+ const t = this.pos + e;
1141
+ this.view.byteLength < t && this.resizeBuffer(t * 2);
1142
+ }
1143
+ resizeBuffer(e) {
1144
+ const t = new ArrayBuffer(e), n = new Uint8Array(t), s = new DataView(t);
1145
+ n.set(this.bytes), this.view = s, this.bytes = n;
1146
+ }
1147
+ encodeNil() {
1148
+ this.writeU8(192);
1149
+ }
1150
+ encodeBoolean(e) {
1151
+ e === !1 ? this.writeU8(194) : this.writeU8(195);
1152
+ }
1153
+ encodeNumber(e) {
1154
+ !this.forceIntegerToFloat && Number.isSafeInteger(e) ? e >= 0 ? e < 128 ? this.writeU8(e) : e < 256 ? (this.writeU8(204), this.writeU8(e)) : e < 65536 ? (this.writeU8(205), this.writeU16(e)) : e < 4294967296 ? (this.writeU8(206), this.writeU32(e)) : this.useBigInt64 ? this.encodeNumberAsFloat(e) : (this.writeU8(207), this.writeU64(e)) : e >= -32 ? this.writeU8(224 | e + 32) : e >= -128 ? (this.writeU8(208), this.writeI8(e)) : e >= -32768 ? (this.writeU8(209), this.writeI16(e)) : e >= -2147483648 ? (this.writeU8(210), this.writeI32(e)) : this.useBigInt64 ? this.encodeNumberAsFloat(e) : (this.writeU8(211), this.writeI64(e)) : this.encodeNumberAsFloat(e);
1155
+ }
1156
+ encodeNumberAsFloat(e) {
1157
+ this.forceFloat32 ? (this.writeU8(202), this.writeF32(e)) : (this.writeU8(203), this.writeF64(e));
1158
+ }
1159
+ encodeBigInt64(e) {
1160
+ e >= BigInt(0) ? (this.writeU8(207), this.writeBigUint64(e)) : (this.writeU8(211), this.writeBigInt64(e));
1161
+ }
1162
+ writeStringHeader(e) {
1163
+ if (e < 32)
1164
+ this.writeU8(160 + e);
1165
+ else if (e < 256)
1166
+ this.writeU8(217), this.writeU8(e);
1167
+ else if (e < 65536)
1168
+ this.writeU8(218), this.writeU16(e);
1169
+ else if (e < 4294967296)
1170
+ this.writeU8(219), this.writeU32(e);
1171
+ else
1172
+ throw new Error(`Too long string: ${e} bytes in UTF-8`);
1173
+ }
1174
+ encodeString(e) {
1175
+ const t = Qi(e);
1176
+ this.ensureBufferSizeToWrite(5 + t), this.writeStringHeader(t), so(e, this.bytes, this.pos), this.pos += t;
1177
+ }
1178
+ encodeObject(e, t) {
1179
+ const n = this.extensionCodec.tryToEncode(e, this.context);
1180
+ if (n != null)
1181
+ this.encodeExtension(n);
1182
+ else if (Array.isArray(e))
1183
+ this.encodeArray(e, t);
1184
+ else if (ArrayBuffer.isView(e))
1185
+ this.encodeBinary(e);
1186
+ else if (typeof e == "object")
1187
+ this.encodeMap(e, t);
1188
+ else
1189
+ throw new Error(`Unrecognized object: ${Object.prototype.toString.apply(e)}`);
1190
+ }
1191
+ encodeBinary(e) {
1192
+ const t = e.byteLength;
1193
+ if (t < 256)
1194
+ this.writeU8(196), this.writeU8(t);
1195
+ else if (t < 65536)
1196
+ this.writeU8(197), this.writeU16(t);
1197
+ else if (t < 4294967296)
1198
+ this.writeU8(198), this.writeU32(t);
1199
+ else
1200
+ throw new Error(`Too large binary: ${t}`);
1201
+ const n = It(e);
1202
+ this.writeU8a(n);
1203
+ }
1204
+ encodeArray(e, t) {
1205
+ const n = e.length;
1206
+ if (n < 16)
1207
+ this.writeU8(144 + n);
1208
+ else if (n < 65536)
1209
+ this.writeU8(220), this.writeU16(n);
1210
+ else if (n < 4294967296)
1211
+ this.writeU8(221), this.writeU32(n);
1212
+ else
1213
+ throw new Error(`Too large array: ${n}`);
1214
+ for (const s of e)
1215
+ this.doEncode(s, t + 1);
1216
+ }
1217
+ countWithoutUndefined(e, t) {
1218
+ let n = 0;
1219
+ for (const s of t)
1220
+ e[s] !== void 0 && n++;
1221
+ return n;
1222
+ }
1223
+ encodeMap(e, t) {
1224
+ const n = Object.keys(e);
1225
+ this.sortKeys && n.sort();
1226
+ const s = this.ignoreUndefined ? this.countWithoutUndefined(e, n) : n.length;
1227
+ if (s < 16)
1228
+ this.writeU8(128 + s);
1229
+ else if (s < 65536)
1230
+ this.writeU8(222), this.writeU16(s);
1231
+ else if (s < 4294967296)
1232
+ this.writeU8(223), this.writeU32(s);
1233
+ else
1234
+ throw new Error(`Too large map object: ${s}`);
1235
+ for (const i of n) {
1236
+ const o = e[i];
1237
+ this.ignoreUndefined && o === void 0 || (this.encodeString(i), this.doEncode(o, t + 1));
1238
+ }
1239
+ }
1240
+ encodeExtension(e) {
1241
+ if (typeof e.data == "function") {
1242
+ const n = e.data(this.pos + 6), s = n.length;
1243
+ if (s >= 4294967296)
1244
+ throw new Error(`Too large extension object: ${s}`);
1245
+ this.writeU8(201), this.writeU32(s), this.writeI8(e.type), this.writeU8a(n);
1246
+ return;
1247
+ }
1248
+ const t = e.data.length;
1249
+ if (t === 1)
1250
+ this.writeU8(212);
1251
+ else if (t === 2)
1252
+ this.writeU8(213);
1253
+ else if (t === 4)
1254
+ this.writeU8(214);
1255
+ else if (t === 8)
1256
+ this.writeU8(215);
1257
+ else if (t === 16)
1258
+ this.writeU8(216);
1259
+ else if (t < 256)
1260
+ this.writeU8(199), this.writeU8(t);
1261
+ else if (t < 65536)
1262
+ this.writeU8(200), this.writeU16(t);
1263
+ else if (t < 4294967296)
1264
+ this.writeU8(201), this.writeU32(t);
1265
+ else
1266
+ throw new Error(`Too large extension object: ${t}`);
1267
+ this.writeI8(e.type), this.writeU8a(e.data);
1268
+ }
1269
+ writeU8(e) {
1270
+ this.ensureBufferSizeToWrite(1), this.view.setUint8(this.pos, e), this.pos++;
1271
+ }
1272
+ writeU8a(e) {
1273
+ const t = e.length;
1274
+ this.ensureBufferSizeToWrite(t), this.bytes.set(e, this.pos), this.pos += t;
1275
+ }
1276
+ writeI8(e) {
1277
+ this.ensureBufferSizeToWrite(1), this.view.setInt8(this.pos, e), this.pos++;
1278
+ }
1279
+ writeU16(e) {
1280
+ this.ensureBufferSizeToWrite(2), this.view.setUint16(this.pos, e), this.pos += 2;
1281
+ }
1282
+ writeI16(e) {
1283
+ this.ensureBufferSizeToWrite(2), this.view.setInt16(this.pos, e), this.pos += 2;
1284
+ }
1285
+ writeU32(e) {
1286
+ this.ensureBufferSizeToWrite(4), this.view.setUint32(this.pos, e), this.pos += 4;
1287
+ }
1288
+ writeI32(e) {
1289
+ this.ensureBufferSizeToWrite(4), this.view.setInt32(this.pos, e), this.pos += 4;
1290
+ }
1291
+ writeF32(e) {
1292
+ this.ensureBufferSizeToWrite(4), this.view.setFloat32(this.pos, e), this.pos += 4;
1293
+ }
1294
+ writeF64(e) {
1295
+ this.ensureBufferSizeToWrite(8), this.view.setFloat64(this.pos, e), this.pos += 8;
1296
+ }
1297
+ writeU64(e) {
1298
+ this.ensureBufferSizeToWrite(8), ho(this.view, this.pos, e), this.pos += 8;
1299
+ }
1300
+ writeI64(e) {
1301
+ this.ensureBufferSizeToWrite(8), Qr(this.view, this.pos, e), this.pos += 8;
1302
+ }
1303
+ writeBigUint64(e) {
1304
+ this.ensureBufferSizeToWrite(8), this.view.setBigUint64(this.pos, e), this.pos += 8;
1305
+ }
1306
+ writeBigInt64(e) {
1307
+ this.ensureBufferSizeToWrite(8), this.view.setBigInt64(this.pos, e), this.pos += 8;
1308
+ }
1309
+ };
1310
+ function pe(r, e) {
1311
+ return new So(e).encodeSharedRef(r);
1312
+ }
1313
+ function lt(r) {
1314
+ return `${r < 0 ? "-" : ""}0x${Math.abs(r).toString(16).padStart(2, "0")}`;
1315
+ }
1316
+ const Io = 16, No = 16;
1317
+ class Uo {
1318
+ constructor(e = Io, t = No) {
1319
+ this.hit = 0, this.miss = 0, this.maxKeyLength = e, this.maxLengthPerKey = t, this.caches = [];
1320
+ for (let n = 0; n < this.maxKeyLength; n++)
1321
+ this.caches.push([]);
1322
+ }
1323
+ canBeCached(e) {
1324
+ return e > 0 && e <= this.maxKeyLength;
1325
+ }
1326
+ find(e, t, n) {
1327
+ const s = this.caches[n - 1];
1328
+ e: for (const i of s) {
1329
+ const o = i.bytes;
1330
+ for (let u = 0; u < n; u++)
1331
+ if (o[u] !== e[t + u])
1332
+ continue e;
1333
+ return i.str;
1334
+ }
1335
+ return null;
1336
+ }
1337
+ store(e, t) {
1338
+ const n = this.caches[e.length - 1], s = { bytes: e, str: t };
1339
+ n.length >= this.maxLengthPerKey ? n[Math.random() * n.length | 0] = s : n.push(s);
1340
+ }
1341
+ decode(e, t, n) {
1342
+ const s = this.find(e, t, n);
1343
+ if (s != null)
1344
+ return this.hit++, s;
1345
+ this.miss++;
1346
+ const i = Xr(e, t, n), o = Uint8Array.prototype.slice.call(e, t, t + n);
1347
+ return this.store(o, i), i;
1348
+ }
1349
+ }
1350
+ const Nt = "array", xe = "map_key", rn = "map_value", Bo = (r) => {
1351
+ if (typeof r == "string" || typeof r == "number")
1352
+ return r;
1353
+ throw new k("The type of key must be string or number but " + typeof r);
1354
+ };
1355
+ class Eo {
1356
+ constructor() {
1357
+ this.stack = [], this.stackHeadPosition = -1;
1358
+ }
1359
+ get length() {
1360
+ return this.stackHeadPosition + 1;
1361
+ }
1362
+ top() {
1363
+ return this.stack[this.stackHeadPosition];
1364
+ }
1365
+ pushArrayState(e) {
1366
+ const t = this.getUninitializedStateFromPool();
1367
+ t.type = Nt, t.position = 0, t.size = e, t.array = new Array(e);
1368
+ }
1369
+ pushMapState(e) {
1370
+ const t = this.getUninitializedStateFromPool();
1371
+ t.type = xe, t.readCount = 0, t.size = e, t.map = {};
1372
+ }
1373
+ getUninitializedStateFromPool() {
1374
+ if (this.stackHeadPosition++, this.stackHeadPosition === this.stack.length) {
1375
+ const e = {
1376
+ type: void 0,
1377
+ size: 0,
1378
+ array: void 0,
1379
+ position: 0,
1380
+ readCount: 0,
1381
+ map: void 0,
1382
+ key: null
1383
+ };
1384
+ this.stack.push(e);
1385
+ }
1386
+ return this.stack[this.stackHeadPosition];
1387
+ }
1388
+ release(e) {
1389
+ if (this.stack[this.stackHeadPosition] !== e)
1390
+ throw new Error("Invalid stack state. Released state is not on top of the stack.");
1391
+ if (e.type === Nt) {
1392
+ const t = e;
1393
+ t.size = 0, t.array = void 0, t.position = 0, t.type = void 0;
1394
+ }
1395
+ if (e.type === xe || e.type === rn) {
1396
+ const t = e;
1397
+ t.size = 0, t.map = void 0, t.readCount = 0, t.type = void 0;
1398
+ }
1399
+ this.stackHeadPosition--;
1400
+ }
1401
+ reset() {
1402
+ this.stack.length = 0, this.stackHeadPosition = -1;
1403
+ }
1404
+ }
1405
+ const he = -1, rr = new DataView(new ArrayBuffer(0)), Ao = new Uint8Array(rr.buffer);
1406
+ try {
1407
+ rr.getInt8(0);
1408
+ } catch (r) {
1409
+ if (!(r instanceof RangeError))
1410
+ throw new Error("This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access");
1411
+ }
1412
+ const fr = new RangeError("Insufficient data"), Mo = new Uo();
1413
+ let Co = class nn {
1414
+ constructor(e) {
1415
+ this.totalPos = 0, this.pos = 0, this.view = rr, this.bytes = Ao, this.headByte = he, this.stack = new Eo(), this.entered = !1, this.extensionCodec = (e == null ? void 0 : e.extensionCodec) ?? Ee.defaultCodec, this.context = e == null ? void 0 : e.context, this.useBigInt64 = (e == null ? void 0 : e.useBigInt64) ?? !1, this.rawStrings = (e == null ? void 0 : e.rawStrings) ?? !1, this.maxStrLength = (e == null ? void 0 : e.maxStrLength) ?? le, this.maxBinLength = (e == null ? void 0 : e.maxBinLength) ?? le, this.maxArrayLength = (e == null ? void 0 : e.maxArrayLength) ?? le, this.maxMapLength = (e == null ? void 0 : e.maxMapLength) ?? le, this.maxExtLength = (e == null ? void 0 : e.maxExtLength) ?? le, this.keyDecoder = (e == null ? void 0 : e.keyDecoder) !== void 0 ? e.keyDecoder : Mo, this.mapKeyConverter = (e == null ? void 0 : e.mapKeyConverter) ?? Bo;
1416
+ }
1417
+ clone() {
1418
+ return new nn({
1419
+ extensionCodec: this.extensionCodec,
1420
+ context: this.context,
1421
+ useBigInt64: this.useBigInt64,
1422
+ rawStrings: this.rawStrings,
1423
+ maxStrLength: this.maxStrLength,
1424
+ maxBinLength: this.maxBinLength,
1425
+ maxArrayLength: this.maxArrayLength,
1426
+ maxMapLength: this.maxMapLength,
1427
+ maxExtLength: this.maxExtLength,
1428
+ keyDecoder: this.keyDecoder
1429
+ });
1430
+ }
1431
+ reinitializeState() {
1432
+ this.totalPos = 0, this.headByte = he, this.stack.reset();
1433
+ }
1434
+ setBuffer(e) {
1435
+ const t = It(e);
1436
+ this.bytes = t, this.view = new DataView(t.buffer, t.byteOffset, t.byteLength), this.pos = 0;
1437
+ }
1438
+ appendBuffer(e) {
1439
+ if (this.headByte === he && !this.hasRemaining(1))
1440
+ this.setBuffer(e);
1441
+ else {
1442
+ const t = this.bytes.subarray(this.pos), n = It(e), s = new Uint8Array(t.length + n.length);
1443
+ s.set(t), s.set(n, t.length), this.setBuffer(s);
1444
+ }
1445
+ }
1446
+ hasRemaining(e) {
1447
+ return this.view.byteLength - this.pos >= e;
1448
+ }
1449
+ createExtraByteError(e) {
1450
+ const { view: t, pos: n } = this;
1451
+ return new RangeError(`Extra ${t.byteLength - n} of ${t.byteLength} byte(s) found at buffer[${e}]`);
1452
+ }
1453
+ /**
1454
+ * @throws {@link DecodeError}
1455
+ * @throws {@link RangeError}
1456
+ */
1457
+ decode(e) {
1458
+ if (this.entered)
1459
+ return this.clone().decode(e);
1460
+ try {
1461
+ this.entered = !0, this.reinitializeState(), this.setBuffer(e);
1462
+ const t = this.doDecodeSync();
1463
+ if (this.hasRemaining(1))
1464
+ throw this.createExtraByteError(this.pos);
1465
+ return t;
1466
+ } finally {
1467
+ this.entered = !1;
1468
+ }
1469
+ }
1470
+ *decodeMulti(e) {
1471
+ if (this.entered) {
1472
+ yield* this.clone().decodeMulti(e);
1473
+ return;
1474
+ }
1475
+ try {
1476
+ for (this.entered = !0, this.reinitializeState(), this.setBuffer(e); this.hasRemaining(1); )
1477
+ yield this.doDecodeSync();
1478
+ } finally {
1479
+ this.entered = !1;
1480
+ }
1481
+ }
1482
+ async decodeAsync(e) {
1483
+ if (this.entered)
1484
+ return this.clone().decodeAsync(e);
1485
+ try {
1486
+ this.entered = !0;
1487
+ let t = !1, n;
1488
+ for await (const u of e) {
1489
+ if (t)
1490
+ throw this.entered = !1, this.createExtraByteError(this.totalPos);
1491
+ this.appendBuffer(u);
1492
+ try {
1493
+ n = this.doDecodeSync(), t = !0;
1494
+ } catch (h) {
1495
+ if (!(h instanceof RangeError))
1496
+ throw h;
1497
+ }
1498
+ this.totalPos += this.pos;
1499
+ }
1500
+ if (t) {
1501
+ if (this.hasRemaining(1))
1502
+ throw this.createExtraByteError(this.totalPos);
1503
+ return n;
1504
+ }
1505
+ const { headByte: s, pos: i, totalPos: o } = this;
1506
+ throw new RangeError(`Insufficient data in parsing ${lt(s)} at ${o} (${i} in the current buffer)`);
1507
+ } finally {
1508
+ this.entered = !1;
1509
+ }
1510
+ }
1511
+ decodeArrayStream(e) {
1512
+ return this.decodeMultiAsync(e, !0);
1513
+ }
1514
+ decodeStream(e) {
1515
+ return this.decodeMultiAsync(e, !1);
1516
+ }
1517
+ async *decodeMultiAsync(e, t) {
1518
+ if (this.entered) {
1519
+ yield* this.clone().decodeMultiAsync(e, t);
1520
+ return;
1521
+ }
1522
+ try {
1523
+ this.entered = !0;
1524
+ let n = t, s = -1;
1525
+ for await (const i of e) {
1526
+ if (t && s === 0)
1527
+ throw this.createExtraByteError(this.totalPos);
1528
+ this.appendBuffer(i), n && (s = this.readArraySize(), n = !1, this.complete());
1529
+ try {
1530
+ for (; yield this.doDecodeSync(), --s !== 0; )
1531
+ ;
1532
+ } catch (o) {
1533
+ if (!(o instanceof RangeError))
1534
+ throw o;
1535
+ }
1536
+ this.totalPos += this.pos;
1537
+ }
1538
+ } finally {
1539
+ this.entered = !1;
1540
+ }
1541
+ }
1542
+ doDecodeSync() {
1543
+ e: for (; ; ) {
1544
+ const e = this.readHeadByte();
1545
+ let t;
1546
+ if (e >= 224)
1547
+ t = e - 256;
1548
+ else if (e < 192)
1549
+ if (e < 128)
1550
+ t = e;
1551
+ else if (e < 144) {
1552
+ const s = e - 128;
1553
+ if (s !== 0) {
1554
+ this.pushMapState(s), this.complete();
1555
+ continue e;
1556
+ } else
1557
+ t = {};
1558
+ } else if (e < 160) {
1559
+ const s = e - 144;
1560
+ if (s !== 0) {
1561
+ this.pushArrayState(s), this.complete();
1562
+ continue e;
1563
+ } else
1564
+ t = [];
1565
+ } else {
1566
+ const s = e - 160;
1567
+ t = this.decodeString(s, 0);
1568
+ }
1569
+ else if (e === 192)
1570
+ t = null;
1571
+ else if (e === 194)
1572
+ t = !1;
1573
+ else if (e === 195)
1574
+ t = !0;
1575
+ else if (e === 202)
1576
+ t = this.readF32();
1577
+ else if (e === 203)
1578
+ t = this.readF64();
1579
+ else if (e === 204)
1580
+ t = this.readU8();
1581
+ else if (e === 205)
1582
+ t = this.readU16();
1583
+ else if (e === 206)
1584
+ t = this.readU32();
1585
+ else if (e === 207)
1586
+ this.useBigInt64 ? t = this.readU64AsBigInt() : t = this.readU64();
1587
+ else if (e === 208)
1588
+ t = this.readI8();
1589
+ else if (e === 209)
1590
+ t = this.readI16();
1591
+ else if (e === 210)
1592
+ t = this.readI32();
1593
+ else if (e === 211)
1594
+ this.useBigInt64 ? t = this.readI64AsBigInt() : t = this.readI64();
1595
+ else if (e === 217) {
1596
+ const s = this.lookU8();
1597
+ t = this.decodeString(s, 1);
1598
+ } else if (e === 218) {
1599
+ const s = this.lookU16();
1600
+ t = this.decodeString(s, 2);
1601
+ } else if (e === 219) {
1602
+ const s = this.lookU32();
1603
+ t = this.decodeString(s, 4);
1604
+ } else if (e === 220) {
1605
+ const s = this.readU16();
1606
+ if (s !== 0) {
1607
+ this.pushArrayState(s), this.complete();
1608
+ continue e;
1609
+ } else
1610
+ t = [];
1611
+ } else if (e === 221) {
1612
+ const s = this.readU32();
1613
+ if (s !== 0) {
1614
+ this.pushArrayState(s), this.complete();
1615
+ continue e;
1616
+ } else
1617
+ t = [];
1618
+ } else if (e === 222) {
1619
+ const s = this.readU16();
1620
+ if (s !== 0) {
1621
+ this.pushMapState(s), this.complete();
1622
+ continue e;
1623
+ } else
1624
+ t = {};
1625
+ } else if (e === 223) {
1626
+ const s = this.readU32();
1627
+ if (s !== 0) {
1628
+ this.pushMapState(s), this.complete();
1629
+ continue e;
1630
+ } else
1631
+ t = {};
1632
+ } else if (e === 196) {
1633
+ const s = this.lookU8();
1634
+ t = this.decodeBinary(s, 1);
1635
+ } else if (e === 197) {
1636
+ const s = this.lookU16();
1637
+ t = this.decodeBinary(s, 2);
1638
+ } else if (e === 198) {
1639
+ const s = this.lookU32();
1640
+ t = this.decodeBinary(s, 4);
1641
+ } else if (e === 212)
1642
+ t = this.decodeExtension(1, 0);
1643
+ else if (e === 213)
1644
+ t = this.decodeExtension(2, 0);
1645
+ else if (e === 214)
1646
+ t = this.decodeExtension(4, 0);
1647
+ else if (e === 215)
1648
+ t = this.decodeExtension(8, 0);
1649
+ else if (e === 216)
1650
+ t = this.decodeExtension(16, 0);
1651
+ else if (e === 199) {
1652
+ const s = this.lookU8();
1653
+ t = this.decodeExtension(s, 1);
1654
+ } else if (e === 200) {
1655
+ const s = this.lookU16();
1656
+ t = this.decodeExtension(s, 2);
1657
+ } else if (e === 201) {
1658
+ const s = this.lookU32();
1659
+ t = this.decodeExtension(s, 4);
1660
+ } else
1661
+ throw new k(`Unrecognized type byte: ${lt(e)}`);
1662
+ this.complete();
1663
+ const n = this.stack;
1664
+ for (; n.length > 0; ) {
1665
+ const s = n.top();
1666
+ if (s.type === Nt)
1667
+ if (s.array[s.position] = t, s.position++, s.position === s.size)
1668
+ t = s.array, n.release(s);
1669
+ else
1670
+ continue e;
1671
+ else if (s.type === xe) {
1672
+ if (t === "__proto__")
1673
+ throw new k("The key __proto__ is not allowed");
1674
+ s.key = this.mapKeyConverter(t), s.type = rn;
1675
+ continue e;
1676
+ } else if (s.map[s.key] = t, s.readCount++, s.readCount === s.size)
1677
+ t = s.map, n.release(s);
1678
+ else {
1679
+ s.key = null, s.type = xe;
1680
+ continue e;
1681
+ }
1682
+ }
1683
+ return t;
1684
+ }
1685
+ }
1686
+ readHeadByte() {
1687
+ return this.headByte === he && (this.headByte = this.readU8()), this.headByte;
1688
+ }
1689
+ complete() {
1690
+ this.headByte = he;
1691
+ }
1692
+ readArraySize() {
1693
+ const e = this.readHeadByte();
1694
+ switch (e) {
1695
+ case 220:
1696
+ return this.readU16();
1697
+ case 221:
1698
+ return this.readU32();
1699
+ default: {
1700
+ if (e < 160)
1701
+ return e - 144;
1702
+ throw new k(`Unrecognized array type byte: ${lt(e)}`);
1703
+ }
1704
+ }
1705
+ }
1706
+ pushMapState(e) {
1707
+ if (e > this.maxMapLength)
1708
+ throw new k(`Max length exceeded: map length (${e}) > maxMapLengthLength (${this.maxMapLength})`);
1709
+ this.stack.pushMapState(e);
1710
+ }
1711
+ pushArrayState(e) {
1712
+ if (e > this.maxArrayLength)
1713
+ throw new k(`Max length exceeded: array length (${e}) > maxArrayLength (${this.maxArrayLength})`);
1714
+ this.stack.pushArrayState(e);
1715
+ }
1716
+ decodeString(e, t) {
1717
+ return !this.rawStrings || this.stateIsMapKey() ? this.decodeUtf8String(e, t) : this.decodeBinary(e, t);
1718
+ }
1719
+ /**
1720
+ * @throws {@link RangeError}
1721
+ */
1722
+ decodeUtf8String(e, t) {
1723
+ var n;
1724
+ if (e > this.maxStrLength)
1725
+ throw new k(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);
1726
+ if (this.bytes.byteLength < this.pos + t + e)
1727
+ throw fr;
1728
+ const s = this.pos + t;
1729
+ let i;
1730
+ return this.stateIsMapKey() && (n = this.keyDecoder) != null && n.canBeCached(e) ? i = this.keyDecoder.decode(this.bytes, s, e) : i = lo(this.bytes, s, e), this.pos += t + e, i;
1731
+ }
1732
+ stateIsMapKey() {
1733
+ return this.stack.length > 0 ? this.stack.top().type === xe : !1;
1734
+ }
1735
+ /**
1736
+ * @throws {@link RangeError}
1737
+ */
1738
+ decodeBinary(e, t) {
1739
+ if (e > this.maxBinLength)
1740
+ throw new k(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);
1741
+ if (!this.hasRemaining(e + t))
1742
+ throw fr;
1743
+ const n = this.pos + t, s = this.bytes.subarray(n, n + e);
1744
+ return this.pos += t + e, s;
1745
+ }
1746
+ decodeExtension(e, t) {
1747
+ if (e > this.maxExtLength)
1748
+ throw new k(`Max length exceeded: ext length (${e}) > maxExtLength (${this.maxExtLength})`);
1749
+ const n = this.view.getInt8(this.pos + t), s = this.decodeBinary(
1750
+ e,
1751
+ t + 1
1752
+ /* extType */
1753
+ );
1754
+ return this.extensionCodec.decode(s, n, this.context);
1755
+ }
1756
+ lookU8() {
1757
+ return this.view.getUint8(this.pos);
1758
+ }
1759
+ lookU16() {
1760
+ return this.view.getUint16(this.pos);
1761
+ }
1762
+ lookU32() {
1763
+ return this.view.getUint32(this.pos);
1764
+ }
1765
+ readU8() {
1766
+ const e = this.view.getUint8(this.pos);
1767
+ return this.pos++, e;
1768
+ }
1769
+ readI8() {
1770
+ const e = this.view.getInt8(this.pos);
1771
+ return this.pos++, e;
1772
+ }
1773
+ readU16() {
1774
+ const e = this.view.getUint16(this.pos);
1775
+ return this.pos += 2, e;
1776
+ }
1777
+ readI16() {
1778
+ const e = this.view.getInt16(this.pos);
1779
+ return this.pos += 2, e;
1780
+ }
1781
+ readU32() {
1782
+ const e = this.view.getUint32(this.pos);
1783
+ return this.pos += 4, e;
1784
+ }
1785
+ readI32() {
1786
+ const e = this.view.getInt32(this.pos);
1787
+ return this.pos += 4, e;
1788
+ }
1789
+ readU64() {
1790
+ const e = co(this.view, this.pos);
1791
+ return this.pos += 8, e;
1792
+ }
1793
+ readI64() {
1794
+ const e = en(this.view, this.pos);
1795
+ return this.pos += 8, e;
1796
+ }
1797
+ readU64AsBigInt() {
1798
+ const e = this.view.getBigUint64(this.pos);
1799
+ return this.pos += 8, e;
1800
+ }
1801
+ readI64AsBigInt() {
1802
+ const e = this.view.getBigInt64(this.pos);
1803
+ return this.pos += 8, e;
1804
+ }
1805
+ readF32() {
1806
+ const e = this.view.getFloat32(this.pos);
1807
+ return this.pos += 4, e;
1808
+ }
1809
+ readF64() {
1810
+ const e = this.view.getFloat64(this.pos);
1811
+ return this.pos += 8, e;
1812
+ }
1813
+ };
1814
+ function sn(r, e) {
1815
+ return new Co(e).decode(r);
1816
+ }
1817
+ let Lo = class {
1818
+ constructor() {
1819
+ ie(this, "contentType", "application/json"), ie(this, "decoder"), ie(this, "encoder"), this.decoder = new TextDecoder(), this.encoder = new TextEncoder();
1820
+ }
1821
+ encode(e) {
1822
+ return this.encoder.encode(this.encodeString(e));
1823
+ }
1824
+ decode(e, t) {
1825
+ return this.decodeString(this.decoder.decode(e), t);
1826
+ }
1827
+ decodeString(e, t) {
1828
+ const n = JSON.parse(e), s = tt(n);
1829
+ return t != null ? t.parse(s) : s;
1830
+ }
1831
+ encodeString(e) {
1832
+ const t = _t(e);
1833
+ return JSON.stringify(t, (n, s) => ArrayBuffer.isView(s) ? Array.from(s) : tr(s) && "encode_value" in s ? typeof s.value == "bigint" ? s.value.toString() : s.value : typeof s == "bigint" ? s.toString() : s);
1834
+ }
1835
+ static registerCustomType() {
1836
+ }
1837
+ }, Ro = class {
1838
+ constructor() {
1839
+ ie(this, "contentType", "text/csv");
1840
+ }
1841
+ encode(e) {
1842
+ const t = this.encodeString(e);
1843
+ return new TextEncoder().encode(t);
1844
+ }
1845
+ decode(e, t) {
1846
+ const n = new TextDecoder().decode(e);
1847
+ return this.decodeString(n, t);
1848
+ }
1849
+ encodeString(e) {
1850
+ if (!Array.isArray(e) || e.length === 0 || !tr(e[0]))
1851
+ throw new Error("Payload must be an array of objects");
1852
+ const t = Object.keys(e[0]), n = [t.join(",")];
1853
+ return e.forEach((s) => {
1854
+ const i = t.map((o) => JSON.stringify(s[o] ?? ""));
1855
+ n.push(i.join(","));
1856
+ }), n.join(`
1857
+ `);
1858
+ }
1859
+ decodeString(e, t) {
1860
+ const [n, ...s] = e.trim().split(`
1861
+ `).map((u) => u.trim());
1862
+ if (n.length === 0)
1863
+ return t != null ? t.parse({}) : {};
1864
+ const i = n.split(",").map((u) => u.trim()), o = {};
1865
+ return i.forEach((u) => {
1866
+ o[u] = [];
1867
+ }), s.forEach((u) => {
1868
+ const h = u.split(",").map((f) => f.trim());
1869
+ i.forEach((f, g) => {
1870
+ const d = this.parseValue(h[g]);
1871
+ d != null && o[f].push(d);
1872
+ });
1873
+ }), t != null ? t.parse(o) : o;
1874
+ }
1875
+ parseValue(e) {
1876
+ if (e == null || e.length === 0) return null;
1877
+ const t = Number(e);
1878
+ return isNaN(t) ? e.startsWith('"') && e.endsWith('"') ? e.slice(1, -1) : e : t;
1879
+ }
1880
+ static registerCustomType() {
1881
+ }
1882
+ }, jo = class {
1883
+ constructor() {
1884
+ ie(this, "contentType", "text/plain");
1885
+ }
1886
+ encode(e) {
1887
+ return new TextEncoder().encode(e);
1888
+ }
1889
+ decode(e, t) {
1890
+ const n = new TextDecoder().decode(e);
1891
+ return t != null ? t.parse(n) : n;
1892
+ }
1893
+ };
1894
+ const W = new Ee();
1895
+ W.register({
1896
+ type: 0,
1897
+ encode: (r) => {
1898
+ if (ArrayBuffer.isView(r)) {
1899
+ const e = Array.from(r);
1900
+ return pe(e, { extensionCodec: W });
1901
+ }
1902
+ return tr(r) && "encode_value" in r ? typeof r.value == "bigint" ? pe(r.value.toString(), { extensionCodec: W }) : pe(r.value, { extensionCodec: W }) : typeof r == "bigint" ? pe(r.toString(), { extensionCodec: W }) : null;
1903
+ },
1904
+ decode: (r) => sn(r, { extensionCodec: W })
1905
+ });
1906
+ let ko = class {
1907
+ constructor() {
1908
+ ie(this, "contentType", "application/msgpack");
1909
+ }
1910
+ encode(e) {
1911
+ const t = _t(e);
1912
+ return pe(t, { extensionCodec: W }).slice();
1913
+ }
1914
+ decode(e, t) {
1915
+ const n = sn(e, { extensionCodec: W }), s = tt(n);
1916
+ return t != null ? t.parse(s) : s;
1917
+ }
1918
+ static registerCustomType() {
1919
+ }
1920
+ };
1921
+ const Ve = new Lo();
1922
+ new Ro();
1923
+ new jo();
1924
+ new ko();
1925
+ const Ut = (r) => [...new Set(r)], Do = (r, e, t = !0) => {
1926
+ const n = /* @__PURE__ */ new Map();
1927
+ return r.forEach((s) => {
1928
+ const i = e(s);
1929
+ if (n.has(i)) {
1930
+ if (t) return;
1931
+ n.delete(i);
1932
+ }
1933
+ n.set(i, s);
1934
+ }), Array.from(n.values());
1935
+ }, Xu = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1936
+ __proto__: null,
1937
+ by: Do,
1938
+ unique: Ut
1939
+ }, Symbol.toStringTag, { value: "Module" })), on = (r) => r != null && typeof r == "object" && "toString" in r, Qu = (r) => {
1940
+ if (on(r)) return (r == null ? void 0 : r.toString().length) === 0;
1941
+ switch (typeof r) {
1942
+ case "string":
1943
+ return r.length === 0;
1944
+ case "number":
1945
+ return r === 0;
1946
+ case "bigint":
1947
+ return r === 0n;
1948
+ case "boolean":
1949
+ return !r;
1950
+ case "undefined":
1951
+ return !0;
1952
+ case "object":
1953
+ return !0;
1954
+ }
1955
+ }, it = (r, e = !1) => {
1956
+ const t = on(r) ? "stringer" : typeof r;
1957
+ let n;
1958
+ switch (t) {
1959
+ case "string":
1960
+ n = (s, i) => s.localeCompare(i);
1961
+ break;
1962
+ case "stringer":
1963
+ n = (s, i) => s.toString().localeCompare(i.toString());
1964
+ break;
1965
+ case "number":
1966
+ n = (s, i) => Number(s) - Number(i);
1967
+ break;
1968
+ case "bigint":
1969
+ n = (s, i) => BigInt(s) - BigInt(i) > 0n ? 1 : -1;
1970
+ break;
1971
+ case "boolean":
1972
+ n = (s, i) => Number(s) - Number(i);
1973
+ break;
1974
+ case "undefined":
1975
+ n = () => 0;
1976
+ break;
1977
+ default:
1978
+ return console.warn(`sortFunc: unknown type ${t}`), () => -1;
1979
+ }
1980
+ return e ? un(n) : n;
1981
+ }, Po = (r, e, t) => {
1982
+ const n = it(e[r], t);
1983
+ return (s, i) => n(s[r], i[r]);
1984
+ }, zo = (r, e) => r.length !== e.length ? r.length - e.length : r.every((t, n) => t === e[n]) ? 0 : -1, an = (r, e) => {
1985
+ if (r.length !== e.length) return r.length - e.length;
1986
+ if (r.length === 0) return 0;
1987
+ const t = it(r[0]), n = [...r].sort(t), s = [...e].sort(t);
1988
+ return n.every((i, o) => i === s[o]) ? 0 : -1;
1989
+ }, Fo = (r, e) => {
1990
+ const t = Ut(r), n = Ut(e);
1991
+ return an(t, n);
1992
+ }, _o = (r, e) => r === e ? 0 : r === "first" && e === "last" ? 1 : -1, un = (r) => (e, t) => r(t, e), ae = 0, Ye = -1, Ze = 1, ln = (r) => r < ae, hn = (r) => r > ae, qo = (r) => r >= ae, cn = (r) => r === ae, Wo = (r, e) => {
1993
+ const t = /([a-zA-Z]+)|(\d+)/g, n = r.replace(/[\s_.-]+/g, "").match(t), s = e.replace(/[\s_.-]+/g, "").match(t);
1994
+ if (!n || !s) return 0;
1995
+ for (let i = 0; i < Math.min(n.length, s.length); i++) {
1996
+ const o = n[i], u = s[i];
1997
+ if (isNaN(Number(o)) && isNaN(Number(u))) {
1998
+ const h = o.localeCompare(u);
1999
+ if (h !== 0) return h;
2000
+ } else if (!isNaN(Number(o)) && !isNaN(Number(u))) {
2001
+ const h = Number(o) - Number(u);
2002
+ if (h !== 0) return h;
2003
+ } else return isNaN(Number(o)) ? -1 : 1;
2004
+ }
2005
+ return n.length - s.length;
2006
+ }, el = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2007
+ __proto__: null,
2008
+ EQUAL: ae,
2009
+ GREATER_THAN: Ze,
2010
+ LESS_THAN: Ye,
2011
+ isEqualTo: cn,
2012
+ isGreaterThan: hn,
2013
+ isGreaterThanEqual: qo,
2014
+ isLessThan: ln,
2015
+ newF: it,
2016
+ newFieldF: Po,
2017
+ order: _o,
2018
+ primitiveArrays: zo,
2019
+ reverseF: un,
2020
+ stringsWithNumbers: Wo,
2021
+ uniqueUnorderedPrimitiveArrays: Fo,
2022
+ unorderedPrimitiveArrays: an
2023
+ }, Symbol.toStringTag, { value: "Module" }));
2024
+ var Vo = Object.defineProperty, Yo = (r, e, t) => e in r ? Vo(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, l = (r, e, t) => Yo(r, typeof e != "symbol" ? e + "" : e, t);
2025
+ let Zo = (r, e = 21) => (t = e) => {
2026
+ let n = "", s = t | 0;
2027
+ for (; s--; )
2028
+ n += r[Math.random() * r.length | 0];
2029
+ return n;
2030
+ };
2031
+ const Ho = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", Go = Zo(Ho, 11), fn = () => Go(), tl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2032
+ __proto__: null,
2033
+ create: fn
2034
+ }, Symbol.toStringTag, { value: "Module" })), Ko = a.enum(["static", "dynamic"]), dn = (r, e) => {
2035
+ const t = new x(e);
2036
+ if (![
2037
+ O.DAY,
2038
+ O.HOUR,
2039
+ O.MINUTE,
2040
+ O.SECOND,
2041
+ O.MILLISECOND,
2042
+ O.MICROSECOND,
2043
+ O.NANOSECOND
2044
+ ].some((s) => s.equals(t)))
2045
+ throw new Error(
2046
+ "Invalid argument for remainder. Must be an even TimeSpan or Timestamp"
2047
+ );
2048
+ const n = r.valueOf() % t.valueOf();
2049
+ return r instanceof x ? new x(n) : new O(n);
2050
+ }, b = class p {
2051
+ constructor(e, t = "UTC") {
2052
+ if (l(this, "value"), l(this, "encodeValue", !0), e == null) this.value = p.now().valueOf();
2053
+ else if (e instanceof Date)
2054
+ this.value = BigInt(e.getTime()) * p.MILLISECOND.valueOf();
2055
+ else if (typeof e == "string")
2056
+ this.value = p.parseDateTimeString(e, t).valueOf();
2057
+ else if (Array.isArray(e)) this.value = p.parseDate(e);
2058
+ else {
2059
+ let n = BigInt(0);
2060
+ e instanceof Number && (e = e.valueOf()), t === "local" && (n = p.utcOffset.valueOf()), typeof e == "number" && (isFinite(e) ? e = Math.trunc(e) : (isNaN(e) && (e = 0), e === 1 / 0 ? e = p.MAX : e = p.MIN)), this.value = BigInt(e.valueOf()) + n;
2061
+ }
2062
+ }
2063
+ static parseDate([e = 1970, t = 1, n = 1]) {
2064
+ const s = new Date(e, t - 1, n, 0, 0, 0, 0);
2065
+ return new p(BigInt(s.getTime()) * p.MILLISECOND.valueOf()).truncate(p.DAY).valueOf();
2066
+ }
2067
+ valueOf() {
2068
+ return this.value;
2069
+ }
2070
+ static parseTimeString(e, t = "UTC") {
2071
+ const [n, s, i] = e.split(":");
2072
+ let o = "00", u = "00";
2073
+ i != null && ([o, u] = i.split("."));
2074
+ let h = p.hours(parseInt(n ?? "00")).add(p.minutes(parseInt(s ?? "00"))).add(p.seconds(parseInt(o ?? "00"))).add(p.milliseconds(parseInt(u ?? "00")));
2075
+ return t === "local" && (h = h.add(p.utcOffset)), h.valueOf();
2076
+ }
2077
+ static parseDateTimeString(e, t = "UTC") {
2078
+ if (!e.includes("/") && !e.includes("-"))
2079
+ return p.parseTimeString(e, t);
2080
+ const n = new Date(e);
2081
+ return e.includes(":") || n.setUTCHours(0, 0, 0, 0), new p(
2082
+ BigInt(n.getTime()) * p.MILLISECOND.valueOf(),
2083
+ t
2084
+ ).valueOf();
2085
+ }
2086
+ fString(e = "ISO", t = "UTC") {
2087
+ switch (e) {
2088
+ case "ISODate":
2089
+ return this.toISOString(t).slice(0, 10);
2090
+ case "ISOTime":
2091
+ return this.toISOString(t).slice(11, 23);
2092
+ case "time":
2093
+ return this.timeString(!1, t);
2094
+ case "preciseTime":
2095
+ return this.timeString(!0, t);
2096
+ case "date":
2097
+ return this.dateString();
2098
+ case "preciseDate":
2099
+ return `${this.dateString()} ${this.timeString(!0, t)}`;
2100
+ case "dateTime":
2101
+ return `${this.dateString()} ${this.timeString(!1, t)}`;
2102
+ default:
2103
+ return this.toISOString(t);
2104
+ }
2105
+ }
2106
+ toISOString(e = "UTC") {
2107
+ return e === "UTC" ? this.date().toISOString() : this.sub(p.utcOffset).date().toISOString();
2108
+ }
2109
+ timeString(e = !1, t = "UTC") {
2110
+ const n = this.toISOString(t);
2111
+ return e ? n.slice(11, 23) : n.slice(11, 19);
2112
+ }
2113
+ dateString() {
2114
+ const e = this.date(), t = e.toLocaleString("default", { month: "short" }), n = e.toLocaleString("default", { day: "numeric" });
2115
+ return `${t} ${n}`;
2116
+ }
2117
+ static get utcOffset() {
2118
+ return new O(
2119
+ BigInt((/* @__PURE__ */ new Date()).getTimezoneOffset()) * p.MINUTE.valueOf()
2120
+ );
2121
+ }
2122
+ /**
2123
+ * @returns a TimeSpan representing the amount time elapsed since
2124
+ * the other timestamp.
2125
+ * @param other - The other timestamp.
2126
+ */
2127
+ static since(e) {
2128
+ return new p().span(e);
2129
+ }
2130
+ /** @returns A JavaScript Date object representing the TimeStamp. */
2131
+ date() {
2132
+ return new Date(this.milliseconds);
2133
+ }
2134
+ /**
2135
+ * Checks if the TimeStamp is equal to another TimeStamp.
2136
+ *
2137
+ * @param other - The other TimeStamp to compare to.
2138
+ * @returns True if the TimeStamps are equal, false otherwise.
2139
+ */
2140
+ equals(e) {
2141
+ return this.valueOf() === new p(e).valueOf();
2142
+ }
2143
+ /**
2144
+ * Creates a TimeSpan representing the duration between the two timestamps.
2145
+ *
2146
+ * @param other - The other TimeStamp to compare to.
2147
+ * @returns A TimeSpan representing the duration between the two timestamps.
2148
+ * The span is guaranteed to be positive.
2149
+ */
2150
+ span(e) {
2151
+ return this.range(e).span;
2152
+ }
2153
+ /**
2154
+ * Creates a TimeRange spanning the given TimeStamp.
2155
+ *
2156
+ * @param other - The other TimeStamp to compare to.
2157
+ * @returns A TimeRange spanning the given TimeStamp that is guaranteed to be
2158
+ * valid, regardless of the TimeStamp order.
2159
+ */
2160
+ range(e) {
2161
+ return new re(this, e).makeValid();
2162
+ }
2163
+ /**
2164
+ * Creates a TimeRange starting at the TimeStamp and spanning the given
2165
+ * TimeSpan.
2166
+ *
2167
+ * @param other - The TimeSpan to span.
2168
+ * @returns A TimeRange starting at the TimeStamp and spanning the given
2169
+ * TimeSpan. The TimeRange is guaranteed to be valid.
2170
+ */
2171
+ spanRange(e) {
2172
+ return this.range(this.add(e)).makeValid();
2173
+ }
2174
+ /**
2175
+ * Checks if the TimeStamp represents the unix epoch.
2176
+ *
2177
+ * @returns True if the TimeStamp represents the unix epoch, false otherwise.
2178
+ */
2179
+ get isZero() {
2180
+ return this.valueOf() === BigInt(0);
2181
+ }
2182
+ /**
2183
+ * Checks if the TimeStamp is after the given TimeStamp.
2184
+ *
2185
+ * @param other - The other TimeStamp to compare to.
2186
+ * @returns True if the TimeStamp is after the given TimeStamp, false
2187
+ * otherwise.
2188
+ */
2189
+ after(e) {
2190
+ return this.valueOf() > new p(e).valueOf();
2191
+ }
2192
+ /**
2193
+ * Checks if the TimeStamp is after or equal to the given TimeStamp.
2194
+ *
2195
+ * @param other - The other TimeStamp to compare to.
2196
+ * @returns True if the TimeStamp is after or equal to the given TimeStamp,
2197
+ * false otherwise.
2198
+ */
2199
+ afterEq(e) {
2200
+ return this.valueOf() >= new p(e).valueOf();
2201
+ }
2202
+ /**
2203
+ * Checks if the TimeStamp is before the given TimeStamp.
2204
+ *
2205
+ * @param other - The other TimeStamp to compare to.
2206
+ * @returns True if the TimeStamp is before the given TimeStamp, false
2207
+ * otherwise.
2208
+ */
2209
+ before(e) {
2210
+ return this.valueOf() < new p(e).valueOf();
2211
+ }
2212
+ /**
2213
+ * Checks if TimeStamp is before or equal to the current timestamp.
2214
+ *
2215
+ * @param other - The other TimeStamp to compare to.
2216
+ * @returns True if TimeStamp is before or equal to the current timestamp,
2217
+ * false otherwise.
2218
+ */
2219
+ beforeEq(e) {
2220
+ return this.valueOf() <= new p(e).valueOf();
2221
+ }
2222
+ /**
2223
+ * Adds a TimeSpan to the TimeStamp.
2224
+ *
2225
+ * @param span - The TimeSpan to add.
2226
+ * @returns A new TimeStamp representing the sum of the TimeStamp and
2227
+ * TimeSpan.
2228
+ */
2229
+ add(e) {
2230
+ return new p(this.valueOf() + BigInt(e.valueOf()));
2231
+ }
2232
+ /**
2233
+ * Subtracts a TimeSpan from the TimeStamp.
2234
+ *
2235
+ * @param span - The TimeSpan to subtract.
2236
+ * @returns A new TimeStamp representing the difference of the TimeStamp and
2237
+ * TimeSpan.
2238
+ */
2239
+ sub(e) {
2240
+ return new p(this.valueOf() - BigInt(e.valueOf()));
2241
+ }
2242
+ /**
2243
+ * @returns the floating point number of hours since the unix epoch to the timestamp
2244
+ * value.
2245
+ */
2246
+ get hours() {
2247
+ return Number(this.valueOf()) / Number(O.HOUR.valueOf());
2248
+ }
2249
+ /**
2250
+ * @returns the floating point number of minutes since the unix epoch to the timestamp
2251
+ * value.
2252
+ */
2253
+ get minutes() {
2254
+ return Number(this.valueOf()) / Number(O.MINUTE.valueOf());
2255
+ }
2256
+ /**
2257
+ * @returns the floating point number of days since the unix epoch to the timestamp
2258
+ * value.
2259
+ */
2260
+ get days() {
2261
+ return Number(this.valueOf()) / Number(O.DAY.valueOf());
2262
+ }
2263
+ /**
2264
+ * @returns the floating point number of seconds since the unix epoch to the timestamp
2265
+ * value.
2266
+ */
2267
+ get seconds() {
2268
+ return Number(this.valueOf()) / Number(O.SECOND.valueOf());
2269
+ }
2270
+ /** @returns the floating point number of milliseconds since the unix epoch. */
2271
+ get milliseconds() {
2272
+ return Number(this.valueOf()) / Number(p.MILLISECOND.valueOf());
2273
+ }
2274
+ /** @returns the floating point number of microseconds since the unix epoch */
2275
+ get microseconds() {
2276
+ return Number(this.valueOf()) / Number(p.MICROSECOND.valueOf());
2277
+ }
2278
+ /**
2279
+ * @returns the floating point number of nanoseconds since the unix epoch.
2280
+ * Note that since we're converting to float64, this reduces the resolution
2281
+ * to a quarter of a microsecond.
2282
+ */
2283
+ get nanoseconds() {
2284
+ return Number(this.valueOf());
2285
+ }
2286
+ /** @returns the integer year that the timestamp corresponds to. */
2287
+ get year() {
2288
+ return this.date().getFullYear();
2289
+ }
2290
+ /**
2291
+ * @returns a copy of the timestamp with the year changed.
2292
+ * @param year the value to set the year to.
2293
+ */
2294
+ setYear(e) {
2295
+ const t = this.date();
2296
+ return t.setFullYear(e), new p(t);
2297
+ }
2298
+ /** @returns the integer month that the timestamp corresponds to with its year. */
2299
+ get month() {
2300
+ return this.date().getUTCMonth();
2301
+ }
2302
+ /**
2303
+ * @returns a copy of the timestamp with the month changed.
2304
+ * @param month the value to set the month to.
2305
+ */
2306
+ setMonth(e) {
2307
+ const t = this.date();
2308
+ return t.setUTCMonth(e), new p(t);
2309
+ }
2310
+ /** @returns the integer day that the timestamp corresponds to within its month. */
2311
+ get day() {
2312
+ return this.date().getUTCDate();
2313
+ }
2314
+ /**
2315
+ * @returns a copy of the timestamp with the day changed.
2316
+ * @param day the value the set the day to.
2317
+ */
2318
+ setDay(e) {
2319
+ const t = this.date();
2320
+ return t.setUTCDate(e), new p(t);
2321
+ }
2322
+ /**
2323
+ * @returns the integer hour that the timestamp corresponds to within its day.
2324
+ */
2325
+ get hour() {
2326
+ return this.date().getUTCHours();
2327
+ }
2328
+ /**
2329
+ * @returns a copy of the timestamp with the hour changed.
2330
+ * @param hour the value to set the hour to.
2331
+ */
2332
+ setHour(e) {
2333
+ const t = this.date();
2334
+ return t.setUTCHours(e), new p(t, "UTC");
2335
+ }
2336
+ /** @returns the integer minute that the timestamp corresponds to within its hour. */
2337
+ get minute() {
2338
+ return this.date().getMinutes();
2339
+ }
2340
+ /**
2341
+ * @returns a copy of the timestamp with the minute changed.
2342
+ * @param minute the value to set the minute to.
2343
+ */
2344
+ setMinute(e) {
2345
+ const t = this.date();
2346
+ return t.setUTCMinutes(e), new p(t);
2347
+ }
2348
+ /**
2349
+ * @returns the integer second that the timestamp corresponds to within its
2350
+ * minute.
2351
+ */
2352
+ get second() {
2353
+ return this.date().getSeconds();
2354
+ }
2355
+ /**
2356
+ * @returns a copy of the timestamp with the second changed.
2357
+ * @param second the value to set the second to.
2358
+ */
2359
+ setSecond(e) {
2360
+ const t = this.date();
2361
+ return t.setUTCSeconds(e), new p(t);
2362
+ }
2363
+ /**
2364
+ * @reutrns the integer millisecond that the timestamp corresponds to within
2365
+ * its second.
2366
+ */
2367
+ get millisecond() {
2368
+ return this.date().getMilliseconds();
2369
+ }
2370
+ /**
2371
+ * @returns a copy of the timestamp with the milliseconds changed.
2372
+ * @param millisecond the value to set the millisecond to.
2373
+ */
2374
+ setMillisecond(e) {
2375
+ const t = this.date();
2376
+ return t.setMilliseconds(e), new p(t);
2377
+ }
2378
+ /** @returns the time stamp formatted as an ISO string. */
2379
+ toString() {
2380
+ return this.date().toISOString();
2381
+ }
2382
+ /**
2383
+ * @returns A new TimeStamp that is the remainder of the TimeStamp divided by the
2384
+ * given span. This is useful in cases where you want only part of a TimeStamp's value
2385
+ * i.e., the hours, minutes, seconds, milliseconds, microseconds, and nanoseconds but
2386
+ * not the days, years, etc.
2387
+ *
2388
+ * @param divisor - The TimeSpan to divide by. Must be an even TimeSpan or TimeStamp. Even
2389
+ * means it must be a day, hour, minute, second, millisecond, or microsecond, etc.
2390
+ *
2391
+ * @example TimeStamp.now().remainder(TimeStamp.DAY) // => TimeStamp representing the current day
2392
+ */
2393
+ remainder(e) {
2394
+ return dn(this, e);
2395
+ }
2396
+ /** @returns true if the day portion TimeStamp is today, false otherwise. */
2397
+ get isToday() {
2398
+ return this.truncate(O.DAY).equals(p.now().truncate(O.DAY));
2399
+ }
2400
+ truncate(e) {
2401
+ return this.sub(this.remainder(e));
2402
+ }
2403
+ /**
2404
+ * @returns A new TimeStamp representing the current time in UTC. It's important to
2405
+ * note that this TimeStamp is only accurate to the millisecond level (that's the best
2406
+ * JavaScript can do).
2407
+ */
2408
+ static now() {
2409
+ return new p(/* @__PURE__ */ new Date());
2410
+ }
2411
+ /** @returns the maximum value of all the timestamps. */
2412
+ static max(...e) {
2413
+ let t = p.MIN;
2414
+ for (const n of e) {
2415
+ const s = new p(n);
2416
+ s.after(t) && (t = s);
2417
+ }
2418
+ return t;
2419
+ }
2420
+ /** @returns the minimum value of all the timestamps. */
2421
+ static min(...e) {
2422
+ let t = p.MAX;
2423
+ for (const n of e) {
2424
+ const s = new p(n);
2425
+ s.before(t) && (t = s);
2426
+ }
2427
+ return t;
2428
+ }
2429
+ /** @returns a new TimeStamp n nanoseconds after the unix epoch */
2430
+ static nanoseconds(e, t = "UTC") {
2431
+ return new p(e, t);
2432
+ }
2433
+ /** @returns a new TimeStamp n microseconds after the unix epoch */
2434
+ static microseconds(e, t = "UTC") {
2435
+ return p.nanoseconds(e * 1e3, t);
2436
+ }
2437
+ /** @returns a new TimeStamp n milliseconds after the unix epoch */
2438
+ static milliseconds(e, t = "UTC") {
2439
+ return p.microseconds(e * 1e3, t);
2440
+ }
2441
+ /** @returns a new TimeStamp n seconds after the unix epoch */
2442
+ static seconds(e, t = "UTC") {
2443
+ return p.milliseconds(e * 1e3, t);
2444
+ }
2445
+ /** @returns a new TimeStamp n minutes after the unix epoch */
2446
+ static minutes(e, t = "UTC") {
2447
+ return p.seconds(e * 60, t);
2448
+ }
2449
+ /** @returns a new TimeStamp n hours after the unix epoch */
2450
+ static hours(e, t = "UTC") {
2451
+ return p.minutes(e * 60, t);
2452
+ }
2453
+ /** @returns a new TimeStamp n days after the unix epoch */
2454
+ static days(e, t = "UTC") {
2455
+ return p.hours(e * 24, t);
2456
+ }
2457
+ };
2458
+ l(b, "NANOSECOND", b.nanoseconds(1)), /** One microsecond after the unix epoch */
2459
+ l(b, "MICROSECOND", b.microseconds(1)), /** One millisecond after the unix epoch */
2460
+ l(b, "MILLISECOND", b.milliseconds(1)), /** One second after the unix epoch */
2461
+ l(b, "SECOND", b.seconds(1)), /** One minute after the unix epoch */
2462
+ l(b, "MINUTE", b.minutes(1)), /** One hour after the unix epoch */
2463
+ l(b, "HOUR", b.hours(1)), /** One day after the unix epoch */
2464
+ l(b, "DAY", b.days(1)), /** The maximum possible value for a timestamp */
2465
+ l(b, "MAX", new b((1n << 63n) - 1n)), /** The minimum possible value for a timestamp */
2466
+ l(b, "MIN", new b(0)), /** The unix epoch */
2467
+ l(b, "ZERO", new b(0)), /** A zod schema for validating timestamps */
2468
+ l(b, "z", a.union([
2469
+ a.object({ value: a.bigint() }).transform((r) => new b(r.value)),
2470
+ a.string().transform((r) => new b(BigInt(r))),
2471
+ a.instanceof(Number).transform((r) => new b(r)),
2472
+ a.number().transform((r) => new b(r)),
2473
+ a.instanceof(b)
2474
+ ]));
2475
+ let x = b;
2476
+ const v = class y {
2477
+ constructor(e) {
2478
+ l(this, "value"), l(this, "encodeValue", !0), typeof e == "number" && (e = Math.trunc(e.valueOf())), this.value = BigInt(e.valueOf());
2479
+ }
2480
+ static fromSeconds(e) {
2481
+ return e instanceof y ? e : e instanceof dr ? e.period : e instanceof x ? new y(e) : ["number", "bigint"].includes(typeof e) ? y.seconds(e) : new y(e);
2482
+ }
2483
+ static fromMilliseconds(e) {
2484
+ return e instanceof y ? e : e instanceof dr ? e.period : e instanceof x ? new y(e) : ["number", "bigint"].includes(typeof e) ? y.milliseconds(e) : new y(e);
2485
+ }
2486
+ encode() {
2487
+ return this.value.toString();
2488
+ }
2489
+ valueOf() {
2490
+ return this.value;
2491
+ }
2492
+ lessThan(e) {
2493
+ return this.valueOf() < new y(e).valueOf();
2494
+ }
2495
+ greaterThan(e) {
2496
+ return this.valueOf() > new y(e).valueOf();
2497
+ }
2498
+ lessThanOrEqual(e) {
2499
+ return this.valueOf() <= new y(e).valueOf();
2500
+ }
2501
+ greaterThanOrEqual(e) {
2502
+ return this.valueOf() >= new y(e).valueOf();
2503
+ }
2504
+ remainder(e) {
2505
+ return dn(this, e);
2506
+ }
2507
+ truncate(e) {
2508
+ return new y(
2509
+ BigInt(Math.trunc(Number(this.valueOf() / e.valueOf()))) * e.valueOf()
2510
+ );
2511
+ }
2512
+ toString() {
2513
+ const e = this.truncate(y.DAY), t = this.truncate(y.HOUR), n = this.truncate(y.MINUTE), s = this.truncate(y.SECOND), i = this.truncate(y.MILLISECOND), o = this.truncate(y.MICROSECOND), u = this.truncate(y.NANOSECOND), h = e, f = t.sub(e), g = n.sub(t), d = s.sub(n), B = i.sub(s), M = o.sub(i), ue = u.sub(o);
2514
+ let _ = "";
2515
+ return h.isZero || (_ += `${h.days}d `), f.isZero || (_ += `${f.hours}h `), g.isZero || (_ += `${g.minutes}m `), d.isZero || (_ += `${d.seconds}s `), B.isZero || (_ += `${B.milliseconds}ms `), M.isZero || (_ += `${M.microseconds}µs `), ue.isZero || (_ += `${ue.nanoseconds}ns`), _.trim();
2516
+ }
2517
+ mult(e) {
2518
+ return new y(this.valueOf() * BigInt(e));
2519
+ }
2520
+ /** @returns the decimal number of days in the timespan */
2521
+ get days() {
2522
+ return Number(this.valueOf()) / Number(y.DAY.valueOf());
2523
+ }
2524
+ /** @returns the decimal number of hours in the timespan */
2525
+ get hours() {
2526
+ return Number(this.valueOf()) / Number(y.HOUR.valueOf());
2527
+ }
2528
+ /** @returns the decimal number of minutes in the timespan */
2529
+ get minutes() {
2530
+ return Number(this.valueOf()) / Number(y.MINUTE.valueOf());
2531
+ }
2532
+ /** @returns The number of seconds in the TimeSpan. */
2533
+ get seconds() {
2534
+ return Number(this.valueOf()) / Number(y.SECOND.valueOf());
2535
+ }
2536
+ /** @returns The number of milliseconds in the TimeSpan. */
2537
+ get milliseconds() {
2538
+ return Number(this.valueOf()) / Number(y.MILLISECOND.valueOf());
2539
+ }
2540
+ get microseconds() {
2541
+ return Number(this.valueOf()) / Number(y.MICROSECOND.valueOf());
2542
+ }
2543
+ get nanoseconds() {
2544
+ return Number(this.valueOf());
2545
+ }
2546
+ /**
2547
+ * Checks if the TimeSpan represents a zero duration.
2548
+ *
2549
+ * @returns True if the TimeSpan represents a zero duration, false otherwise.
2550
+ */
2551
+ get isZero() {
2552
+ return this.valueOf() === BigInt(0);
2553
+ }
2554
+ /**
2555
+ * Checks if the TimeSpan is equal to another TimeSpan.
2556
+ *
2557
+ * @returns True if the TimeSpans are equal, false otherwise.
2558
+ */
2559
+ equals(e) {
2560
+ return this.valueOf() === new y(e).valueOf();
2561
+ }
2562
+ /**
2563
+ * Adds a TimeSpan to the TimeSpan.
2564
+ *
2565
+ * @returns A new TimeSpan representing the sum of the two TimeSpans.
2566
+ */
2567
+ add(e) {
2568
+ return new y(this.valueOf() + new y(e).valueOf());
2569
+ }
2570
+ /**
2571
+ * Creates a TimeSpan representing the duration between the two timestamps.
2572
+ *
2573
+ * @param other
2574
+ */
2575
+ sub(e) {
2576
+ return new y(this.valueOf() - new y(e).valueOf());
2577
+ }
2578
+ /**
2579
+ * Creates a TimeSpan representing the given number of nanoseconds.
2580
+ *
2581
+ * @param value - The number of nanoseconds.
2582
+ * @returns A TimeSpan representing the given number of nanoseconds.
2583
+ */
2584
+ static nanoseconds(e = 1) {
2585
+ return new y(e);
2586
+ }
2587
+ /**
2588
+ * Creates a TimeSpan representing the given number of microseconds.
2589
+ *
2590
+ * @param value - The number of microseconds.
2591
+ * @returns A TimeSpan representing the given number of microseconds.
2592
+ */
2593
+ static microseconds(e = 1) {
2594
+ return y.nanoseconds(X(e, 1e3));
2595
+ }
2596
+ /**
2597
+ * Creates a TimeSpan representing the given number of milliseconds.
2598
+ *
2599
+ * @param value - The number of milliseconds.
2600
+ * @returns A TimeSpan representing the given number of milliseconds.
2601
+ */
2602
+ static milliseconds(e = 1) {
2603
+ return y.microseconds(X(e, 1e3));
2604
+ }
2605
+ /**
2606
+ * Creates a TimeSpan representing the given number of seconds.
2607
+ *
2608
+ * @param value - The number of seconds.
2609
+ * @returns A TimeSpan representing the given number of seconds.
2610
+ */
2611
+ static seconds(e = 1) {
2612
+ return y.milliseconds(X(e, 1e3));
2613
+ }
2614
+ /**
2615
+ * Creates a TimeSpan representing the given number of minutes.
2616
+ *
2617
+ * @param value - The number of minutes.
2618
+ * @returns A TimeSpan representing the given number of minutes.
2619
+ */
2620
+ static minutes(e = 1) {
2621
+ return y.seconds(X(e, 60));
2622
+ }
2623
+ /**
2624
+ * Creates a TimeSpan representing the given number of hours.
2625
+ *
2626
+ * @param value - The number of hours.
2627
+ * @returns A TimeSpan representing the given number of hours.
2628
+ */
2629
+ static hours(e) {
2630
+ return y.minutes(X(e, 60));
2631
+ }
2632
+ /**
2633
+ * Creates a TimeSpan representing the given number of days.
2634
+ *
2635
+ * @param value - The number of days.
2636
+ * @returns A TimeSpan representing the given number of days.
2637
+ */
2638
+ static days(e) {
2639
+ return y.hours(X(e, 24));
2640
+ }
2641
+ };
2642
+ l(v, "NANOSECOND", v.nanoseconds(1)), /** A microsecond. */
2643
+ l(v, "MICROSECOND", v.microseconds(1)), /** A millisecond. */
2644
+ l(v, "MILLISECOND", v.milliseconds(1)), /** A second. */
2645
+ l(v, "SECOND", v.seconds(1)), /** A minute. */
2646
+ l(v, "MINUTE", v.minutes(1)), /** Represents an hour. */
2647
+ l(v, "HOUR", v.hours(1)), /** Represents a day. */
2648
+ l(v, "DAY", v.days(1)), /** The maximum possible value for a TimeSpan. */
2649
+ l(v, "MAX", new v((1n << 63n) - 1n)), /** The minimum possible value for a TimeSpan. */
2650
+ l(v, "MIN", new v(0)), /** The zero value for a TimeSpan. */
2651
+ l(v, "ZERO", new v(0)), /** A zod schema for validating and transforming timespans */
2652
+ l(v, "z", a.union([
2653
+ a.object({ value: a.bigint() }).transform((r) => new v(r.value)),
2654
+ a.string().transform((r) => new v(BigInt(r))),
2655
+ a.instanceof(Number).transform((r) => new v(r)),
2656
+ a.number().transform((r) => new v(r)),
2657
+ a.instanceof(v)
2658
+ ]));
2659
+ let O = v;
2660
+ const ye = class He extends Number {
2661
+ constructor(e) {
2662
+ e instanceof Number ? super(e.valueOf()) : super(e);
2663
+ }
2664
+ /** @returns a pretty string representation of the rate in the format "X Hz". */
2665
+ toString() {
2666
+ return `${this.valueOf()} Hz`;
2667
+ }
2668
+ /** @returns The number of seconds in the Rate. */
2669
+ equals(e) {
2670
+ return this.valueOf() === new He(e).valueOf();
2671
+ }
2672
+ /**
2673
+ * Calculates the period of the Rate as a TimeSpan.
2674
+ *
2675
+ * @returns A TimeSpan representing the period of the Rate.
2676
+ */
2677
+ get period() {
2678
+ return O.seconds(1 / this.valueOf());
2679
+ }
2680
+ /**
2681
+ * Calculates the number of samples in the given TimeSpan at this rate.
2682
+ *
2683
+ * @param duration - The duration to calculate the sample count from.
2684
+ * @returns The number of samples in the given TimeSpan at this rate.
2685
+ */
2686
+ sampleCount(e) {
2687
+ return new O(e).seconds * this.valueOf();
2688
+ }
2689
+ /**
2690
+ * Calculates the number of bytes in the given TimeSpan at this rate.
2691
+ *
2692
+ * @param span - The duration to calculate the byte count from.
2693
+ * @param density - The density of the data in bytes per sample.
2694
+ * @returns The number of bytes in the given TimeSpan at this rate.
2695
+ */
2696
+ byteCount(e, t) {
2697
+ return this.sampleCount(e) * new A(t).valueOf();
2698
+ }
2699
+ /**
2700
+ * Calculates a TimeSpan given the number of samples at this rate.
2701
+ *
2702
+ * @param sampleCount - The number of samples in the span.
2703
+ * @returns A TimeSpan that corresponds to the given number of samples.
2704
+ */
2705
+ span(e) {
2706
+ return O.seconds(e / this.valueOf());
2707
+ }
2708
+ /**
2709
+ * Calculates a TimeSpan given the number of bytes at this rate.
2710
+ *
2711
+ * @param size - The number of bytes in the span.
2712
+ * @param density - The density of the data in bytes per sample.
2713
+ * @returns A TimeSpan that corresponds to the given number of bytes.
2714
+ */
2715
+ byteSpan(e, t) {
2716
+ return this.span(e.valueOf() / t.valueOf());
2717
+ }
2718
+ /**
2719
+ * Creates a Rate representing the given number of Hz.
2720
+ *
2721
+ * @param value - The number of Hz.
2722
+ * @returns A Rate representing the given number of Hz.
2723
+ */
2724
+ static hz(e) {
2725
+ return new He(e);
2726
+ }
2727
+ /**
2728
+ * Creates a Rate representing the given number of kHz.
2729
+ *
2730
+ * @param value - The number of kHz.
2731
+ * @returns A Rate representing the given number of kHz.
2732
+ */
2733
+ static khz(e) {
2734
+ return He.hz(e * 1e3);
2735
+ }
2736
+ };
2737
+ l(ye, "z", a.union([
2738
+ a.number().transform((r) => new ye(r)),
2739
+ a.instanceof(Number).transform((r) => new ye(r)),
2740
+ a.instanceof(ye)
2741
+ ]));
2742
+ let dr = ye;
2743
+ const U = class extends Number {
2744
+ /**
2745
+ * Creates a Density representing the given number of bytes per value.
2746
+ *
2747
+ * @class
2748
+ * @param value - The number of bytes per value.
2749
+ * @returns A Density representing the given number of bytes per value.
2750
+ */
2751
+ constructor(e) {
2752
+ e instanceof Number ? super(e.valueOf()) : super(e);
2753
+ }
2754
+ length(e) {
2755
+ return e.valueOf() / this.valueOf();
2756
+ }
2757
+ size(e) {
2758
+ return new Ke(e * this.valueOf());
2759
+ }
2760
+ };
2761
+ l(U, "UNKNOWN", new U(0)), /** 128 bits per value. */
2762
+ l(U, "BIT128", new U(16)), /** 64 bits per value. */
2763
+ l(U, "BIT64", new U(8)), /** 32 bits per value. */
2764
+ l(U, "BIT32", new U(4)), /** 16 bits per value. */
2765
+ l(U, "BIT16", new U(2)), /** 8 bits per value. */
2766
+ l(U, "BIT8", new U(1)), /** A zod schema for validating and transforming densities */
2767
+ l(U, "z", a.union([
2768
+ a.number().transform((r) => new U(r)),
2769
+ a.instanceof(Number).transform((r) => new U(r)),
2770
+ a.instanceof(U)
2771
+ ]));
2772
+ let A = U;
2773
+ const R = class me {
2774
+ /**
2775
+ * Creates a TimeRange from the given start and end TimeStamps.
2776
+ *
2777
+ * @param start - A TimeStamp representing the start of the range.
2778
+ * @param end - A TimeStamp representing the end of the range.
2779
+ */
2780
+ constructor(e, t) {
2781
+ l(this, "start"), l(this, "end"), typeof e == "object" && "start" in e ? (this.start = new x(e.start), this.end = new x(e.end)) : (this.start = new x(e), this.end = new x(t));
2782
+ }
2783
+ /** @returns The TimeSpan occupied by the TimeRange. */
2784
+ get span() {
2785
+ return new O(this.end.valueOf() - this.start.valueOf());
2786
+ }
2787
+ /**
2788
+ * Checks if the timestamp is valid i.e. the start is before the end.
2789
+ *
2790
+ * @returns True if the TimeRange is valid.
2791
+ */
2792
+ get isValid() {
2793
+ return this.start.valueOf() <= this.end.valueOf();
2794
+ }
2795
+ /**
2796
+ * Makes sure the TimeRange is valid i.e. the start is before the end.
2797
+ *
2798
+ * @returns A TimeRange that is valid.
2799
+ */
2800
+ makeValid() {
2801
+ return this.isValid ? this : this.swap();
2802
+ }
2803
+ /**
2804
+ * Checks if the TimeRange has a zero span.
2805
+ *
2806
+ * @returns True if the TimeRange has a zero span.
2807
+ */
2808
+ get isZero() {
2809
+ return this.span.isZero;
2810
+ }
2811
+ /**
2812
+ * @returns the TimeRange as a numeric object with start and end properties.
2813
+ */
2814
+ get numeric() {
2815
+ return { start: Number(this.start.valueOf()), end: Number(this.end.valueOf()) };
2816
+ }
2817
+ /**
2818
+ * Creates a new TimeRange with the start and end swapped.
2819
+ *
2820
+ * @returns A TimeRange with the start and end swapped.
2821
+ */
2822
+ swap() {
2823
+ return new me(this.end, this.start);
2824
+ }
2825
+ get numericBounds() {
2826
+ return {
2827
+ lower: Number(this.start.valueOf()),
2828
+ upper: Number(this.end.valueOf())
2829
+ };
2830
+ }
2831
+ /**
2832
+ * Checks if the TimeRange is equal to the given TimeRange.
2833
+ *
2834
+ * @param other - The TimeRange to compare to.
2835
+ * @returns True if the TimeRange is equal to the given TimeRange.
2836
+ */
2837
+ equals(e, t = O.ZERO) {
2838
+ if (t.isZero)
2839
+ return this.start.equals(e.start) && this.end.equals(e.end);
2840
+ let n = this.start.sub(e.start).valueOf(), s = this.end.sub(e.end).valueOf();
2841
+ return n < 0 && (n = -n), s < 0 && (s = -s), n <= t.valueOf() && s <= t.valueOf();
2842
+ }
2843
+ toString() {
2844
+ return `${this.start.toString()} - ${this.end.toString()}`;
2845
+ }
2846
+ toPrettyString() {
2847
+ return `${this.start.fString("preciseDate")} - ${this.span.toString()}`;
2848
+ }
2849
+ /**
2850
+ * Checks if the two time ranges overlap. If the two time ranges are equal, returns
2851
+ * true. If the start of one range is equal to the end of the other, it returns false.
2852
+ * Just follow the rule [start, end), i.e., start is inclusive, and the end is exclusive.
2853
+ *
2854
+ * @param other - The other TimeRange to compare to.
2855
+ * @param delta - A TimeSpan representing the minimum amount of overlap for
2856
+ * overlap to return true. This allows for a slight amount of leeway when
2857
+ * checking for overlap.
2858
+ * @returns True if the two TimeRanges overlap, false otherwise.
2859
+ */
2860
+ overlapsWith(e, t = O.ZERO) {
2861
+ e = e.makeValid();
2862
+ const n = this.makeValid();
2863
+ if (this.equals(e)) return !0;
2864
+ if (e.end.equals(n.start) || n.end.equals(e.start)) return !1;
2865
+ const s = x.max(n.start, e.start), i = x.min(n.end, e.end);
2866
+ return i.before(s) ? !1 : new O(i.sub(s)).greaterThanOrEqual(t);
2867
+ }
2868
+ contains(e) {
2869
+ return e instanceof me ? this.contains(e.start) && this.contains(e.end) : this.start.beforeEq(e) && this.end.after(e);
2870
+ }
2871
+ boundBy(e) {
2872
+ const t = new me(this.start, this.end);
2873
+ return e.start.after(this.start) && (t.start = e.start), e.start.after(this.end) && (t.end = e.start), e.end.before(this.end) && (t.end = e.end), e.end.before(this.start) && (t.start = e.end), t;
2874
+ }
2875
+ static max(...e) {
2876
+ return new me(
2877
+ x.min(...e.map((t) => t.start)),
2878
+ x.max(...e.map((t) => t.end))
2879
+ );
2880
+ }
2881
+ };
2882
+ l(R, "MAX", new R(x.MIN, x.MAX)), /** The minimum possible time range. */
2883
+ l(R, "MIN", new R(x.MAX, x.MIN)), /** A time range whose start and end are both zero. */
2884
+ l(R, "ZERO", new R(x.ZERO, x.ZERO)), /** A zod schema for validating and transforming time ranges */
2885
+ l(R, "z", a.union([
2886
+ a.object({ start: x.z, end: x.z }).transform((r) => new R(r.start, r.end)),
2887
+ a.instanceof(R)
2888
+ ]));
2889
+ let re = R;
2890
+ const c = class I {
2891
+ constructor(e) {
2892
+ if (l(this, "value"), l(this, "encodeValue", !0), e instanceof I || typeof e == "string" || typeof e.valueOf() == "string") {
2893
+ this.value = e.valueOf();
2894
+ return;
2895
+ }
2896
+ const t = I.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);
2897
+ if (t != null) {
2898
+ this.value = t.valueOf();
2899
+ return;
2900
+ }
2901
+ throw this.value = I.UNKNOWN.valueOf(), new Error(`unable to find data type for ${e.toString()}`);
2902
+ }
2903
+ valueOf() {
2904
+ return this.value;
2905
+ }
2906
+ /**
2907
+ * @returns the TypedArray constructor for the DataType.
2908
+ */
2909
+ get Array() {
2910
+ const e = I.ARRAY_CONSTRUCTORS.get(this.toString());
2911
+ if (e == null)
2912
+ throw new Error(`unable to find array constructor for ${this.valueOf()}`);
2913
+ return e;
2914
+ }
2915
+ /**
2916
+ * @returns true if the DataType is equal to the given DataType.
2917
+ */
2918
+ equals(e) {
2919
+ return this.valueOf() === e.valueOf();
2920
+ }
2921
+ /**
2922
+ * @returns true if the DataType is equal to any of the given DataTypes.
2923
+ */
2924
+ matches(...e) {
2925
+ return e.some((t) => this.equals(t));
2926
+ }
2927
+ /** @returns a string representation of the DataType. */
2928
+ toString() {
2929
+ return this.valueOf();
2930
+ }
2931
+ get isVariable() {
2932
+ return this.equals(I.JSON) || this.equals(I.STRING);
2933
+ }
2934
+ get isNumeric() {
2935
+ return !this.isVariable && !this.equals(I.UUID);
2936
+ }
2937
+ get isInteger() {
2938
+ const e = this.toString();
2939
+ return e.startsWith("int") || e.startsWith("uint");
2940
+ }
2941
+ get isFloat() {
2942
+ return this.toString().startsWith("float");
2943
+ }
2944
+ get density() {
2945
+ const e = I.DENSITIES.get(this.toString());
2946
+ if (e == null) throw new Error(`unable to find density for ${this.valueOf()}`);
2947
+ return e;
2948
+ }
2949
+ /** @returns ture if the data type is an unsigned numeric integer type */
2950
+ get isUnsigned() {
2951
+ return this.equals(I.UINT8) || this.equals(I.UINT16) || this.equals(I.UINT32) || this.equals(I.UINT64);
2952
+ }
2953
+ /** @returns true if the data type is a signed numeric integer type */
2954
+ get isSigned() {
2955
+ return this.equals(I.INT8) || this.equals(I.INT16) || this.equals(I.INT32) || this.equals(I.INT64);
2956
+ }
2957
+ /** @returns true if the data type can be cast to the other data type without loss of precision. */
2958
+ canSafelyCastTo(e) {
2959
+ return this.equals(e) ? !0 : !this.isNumeric || !e.isNumeric || this.isVariable || e.isVariable || this.isUnsigned && e.isSigned ? !1 : this.isFloat ? e.isFloat && this.density.valueOf() <= e.density.valueOf() : this.equals(I.INT32) && e.equals(I.FLOAT64) || this.equals(I.INT8) && e.equals(I.FLOAT32) ? !0 : this.isInteger && e.isInteger ? this.density.valueOf() <= e.density.valueOf() && this.isUnsigned === e.isUnsigned : !1;
2960
+ }
2961
+ /** @returns true if the data type can be cast to the other data type, even if there is a loss of precision. */
2962
+ canCastTo(e) {
2963
+ return this.isNumeric && e.isNumeric ? !0 : this.equals(e);
2964
+ }
2965
+ toJSON() {
2966
+ return this.toString();
2967
+ }
2968
+ get usesBigInt() {
2969
+ return I.BIG_INT_TYPES.some((e) => e.equals(this));
2970
+ }
2971
+ };
2972
+ l(c, "UNKNOWN", new c("unknown")), /** Represents a 64-bit floating point value. */
2973
+ l(c, "FLOAT64", new c("float64")), /** Represents a 32-bit floating point value. */
2974
+ l(c, "FLOAT32", new c("float32")), /** Represents a 64-bit signed integer value. */
2975
+ l(c, "INT64", new c("int64")), /** Represents a 32-bit signed integer value. */
2976
+ l(c, "INT32", new c("int32")), /** Represents a 16-bit signed integer value. */
2977
+ l(c, "INT16", new c("int16")), /** Represents a 8-bit signed integer value. */
2978
+ l(c, "INT8", new c("int8")), /** Represents a 64-bit unsigned integer value. */
2979
+ l(c, "UINT64", new c("uint64")), /** Represents a 32-bit unsigned integer value. */
2980
+ l(c, "UINT32", new c("uint32")), /** Represents a 16-bit unsigned integer value. */
2981
+ l(c, "UINT16", new c("uint16")), /** Represents a 8-bit unsigned integer value. */
2982
+ l(c, "UINT8", new c("uint8")), /** Represents a boolean value. Alias for UINT8. */
2983
+ l(c, "BOOLEAN", c.UINT8), /** Represents a 64-bit unix epoch. */
2984
+ l(c, "TIMESTAMP", new c("timestamp")), /** Represents a UUID data type */
2985
+ l(c, "UUID", new c("uuid")), /** Represents a string data type. Strings have an unknown density, and are separate
2986
+ * by a newline character. */
2987
+ l(c, "STRING", new c("string")), /** Represents a JSON data type. JSON has an unknown density, and is separated by a
2988
+ * newline character. */
2989
+ l(c, "JSON", new c("json")), l(c, "ARRAY_CONSTRUCTORS", /* @__PURE__ */ new Map([
2990
+ [c.UINT8.toString(), Uint8Array],
2991
+ [c.UINT16.toString(), Uint16Array],
2992
+ [c.UINT32.toString(), Uint32Array],
2993
+ [c.UINT64.toString(), BigUint64Array],
2994
+ [c.FLOAT32.toString(), Float32Array],
2995
+ [c.FLOAT64.toString(), Float64Array],
2996
+ [c.INT8.toString(), Int8Array],
2997
+ [c.INT16.toString(), Int16Array],
2998
+ [c.INT32.toString(), Int32Array],
2999
+ [c.INT64.toString(), BigInt64Array],
3000
+ [c.TIMESTAMP.toString(), BigInt64Array],
3001
+ [c.STRING.toString(), Uint8Array],
3002
+ [c.JSON.toString(), Uint8Array],
3003
+ [c.UUID.toString(), Uint8Array]
3004
+ ])), l(c, "ARRAY_CONSTRUCTOR_DATA_TYPES", /* @__PURE__ */ new Map([
3005
+ [Uint8Array.name, c.UINT8],
3006
+ [Uint16Array.name, c.UINT16],
3007
+ [Uint32Array.name, c.UINT32],
3008
+ [BigUint64Array.name, c.UINT64],
3009
+ [Float32Array.name, c.FLOAT32],
3010
+ [Float64Array.name, c.FLOAT64],
3011
+ [Int8Array.name, c.INT8],
3012
+ [Int16Array.name, c.INT16],
3013
+ [Int32Array.name, c.INT32],
3014
+ [BigInt64Array.name, c.INT64]
3015
+ ])), l(c, "DENSITIES", /* @__PURE__ */ new Map([
3016
+ [c.UINT8.toString(), A.BIT8],
3017
+ [c.UINT16.toString(), A.BIT16],
3018
+ [c.UINT32.toString(), A.BIT32],
3019
+ [c.UINT64.toString(), A.BIT64],
3020
+ [c.FLOAT32.toString(), A.BIT32],
3021
+ [c.FLOAT64.toString(), A.BIT64],
3022
+ [c.INT8.toString(), A.BIT8],
3023
+ [c.INT16.toString(), A.BIT16],
3024
+ [c.INT32.toString(), A.BIT32],
3025
+ [c.INT64.toString(), A.BIT64],
3026
+ [c.TIMESTAMP.toString(), A.BIT64],
3027
+ [c.STRING.toString(), A.UNKNOWN],
3028
+ [c.JSON.toString(), A.UNKNOWN],
3029
+ [c.UUID.toString(), A.BIT128]
3030
+ ])), /** All the data types. */
3031
+ l(c, "ALL", [
3032
+ c.UNKNOWN,
3033
+ c.FLOAT64,
3034
+ c.FLOAT32,
3035
+ c.INT64,
3036
+ c.INT32,
3037
+ c.INT16,
3038
+ c.INT8,
3039
+ c.UINT64,
3040
+ c.UINT32,
3041
+ c.UINT16,
3042
+ c.UINT8,
3043
+ c.TIMESTAMP,
3044
+ c.UUID,
3045
+ c.STRING,
3046
+ c.JSON
3047
+ ]), l(c, "BIG_INT_TYPES", [c.INT64, c.UINT64, c.TIMESTAMP]), /** A zod schema for a DataType. */
3048
+ l(c, "z", a.union([
3049
+ a.string().transform((r) => new c(r)),
3050
+ a.instanceof(c)
3051
+ ]));
3052
+ let w = c;
3053
+ const E = class N extends Number {
3054
+ constructor(e) {
3055
+ super(e.valueOf());
3056
+ }
3057
+ /** @returns true if the Size is larger than the other size. */
3058
+ largerThan(e) {
3059
+ return this.valueOf() > e.valueOf();
3060
+ }
3061
+ /** @returns true if the Size is smaller than the other size. */
3062
+ smallerThan(e) {
3063
+ return this.valueOf() < e.valueOf();
3064
+ }
3065
+ add(e) {
3066
+ return N.bytes(this.valueOf() + e.valueOf());
3067
+ }
3068
+ sub(e) {
3069
+ return N.bytes(this.valueOf() - e.valueOf());
3070
+ }
3071
+ truncate(e) {
3072
+ return new N(Math.trunc(this.valueOf() / e.valueOf()) * e.valueOf());
3073
+ }
3074
+ remainder(e) {
3075
+ return N.bytes(this.valueOf() % e.valueOf());
3076
+ }
3077
+ get gigabytes() {
3078
+ return this.valueOf() / N.GIGABYTE.valueOf();
3079
+ }
3080
+ get megabytes() {
3081
+ return this.valueOf() / N.MEGABYTE.valueOf();
3082
+ }
3083
+ get kilobytes() {
3084
+ return this.valueOf() / N.KILOBYTE.valueOf();
3085
+ }
3086
+ get terabytes() {
3087
+ return this.valueOf() / N.TERABYTE.valueOf();
3088
+ }
3089
+ toString() {
3090
+ const e = this.truncate(N.TERABYTE), t = this.truncate(N.GIGABYTE), n = this.truncate(N.MEGABYTE), s = this.truncate(N.KILOBYTE), i = this.truncate(N.BYTE), o = e, u = t.sub(e), h = n.sub(t), f = s.sub(n), g = i.sub(s);
3091
+ let d = "";
3092
+ return o.isZero || (d += `${o.terabytes}TB `), u.isZero || (d += `${u.gigabytes}GB `), h.isZero || (d += `${h.megabytes}MB `), f.isZero || (d += `${f.kilobytes}KB `), (!g.isZero || d === "") && (d += `${g.valueOf()}B`), d.trim();
3093
+ }
3094
+ /**
3095
+ * Creates a Size from the given number of bytes.
3096
+ *
3097
+ * @param value - The number of bytes.
3098
+ * @returns A Size representing the given number of bytes.
3099
+ */
3100
+ static bytes(e = 1) {
3101
+ return new N(e);
3102
+ }
3103
+ /**
3104
+ * Creates a Size from the given number if kilobytes.
3105
+ *
3106
+ * @param value - The number of kilobytes.
3107
+ * @returns A Size representing the given number of kilobytes.
3108
+ */
3109
+ static kilobytes(e = 1) {
3110
+ return N.bytes(e.valueOf() * 1e3);
3111
+ }
3112
+ /**
3113
+ * Creates a Size from the given number of megabytes.
3114
+ *
3115
+ * @param value - The number of megabytes.
3116
+ * @returns A Size representing the given number of megabytes.
3117
+ */
3118
+ static megabytes(e = 1) {
3119
+ return N.kilobytes(e.valueOf() * 1e3);
3120
+ }
3121
+ /**
3122
+ * Creates a Size from the given number of gigabytes.
3123
+ *
3124
+ * @param value - The number of gigabytes.
3125
+ * @returns A Size representing the given number of gigabytes.
3126
+ */
3127
+ static gigabytes(e = 1) {
3128
+ return N.megabytes(e.valueOf() * 1e3);
3129
+ }
3130
+ /**
3131
+ * Creates a Size from the given number of terabytes.
3132
+ *
3133
+ * @param value - The number of terabytes.
3134
+ * @returns A Size representing the given number of terabytes.
3135
+ */
3136
+ static terabytes(e) {
3137
+ return N.gigabytes(e.valueOf() * 1e3);
3138
+ }
3139
+ get isZero() {
3140
+ return this.valueOf() === 0;
3141
+ }
3142
+ };
3143
+ l(E, "BYTE", new E(1)), /** A kilobyte */
3144
+ l(E, "KILOBYTE", E.kilobytes(1)), /** A megabyte */
3145
+ l(E, "MEGABYTE", E.megabytes(1)), /** A gigabyte */
3146
+ l(E, "GIGABYTE", E.gigabytes(1)), /** A terabyte. */
3147
+ l(E, "TERABYTE", E.terabytes(1)), /** The zero value for Size */
3148
+ l(E, "ZERO", new E(0)), /** A zod schema for a Size. */
3149
+ l(E, "z", a.union([
3150
+ a.number().transform((r) => new E(r)),
3151
+ a.instanceof(E)
3152
+ ]));
3153
+ let Ke = E;
3154
+ const nl = a.union([
3155
+ a.instanceof(Uint8Array),
3156
+ a.instanceof(Uint16Array),
3157
+ a.instanceof(Uint32Array),
3158
+ a.instanceof(BigUint64Array),
3159
+ a.instanceof(Float32Array),
3160
+ a.instanceof(Float64Array),
3161
+ a.instanceof(Int8Array),
3162
+ a.instanceof(Int16Array),
3163
+ a.instanceof(Int32Array),
3164
+ a.instanceof(BigInt64Array)
3165
+ ]), gn = (r) => {
3166
+ const e = typeof r;
3167
+ return e === "string" || e === "number" || e === "boolean" || e === "bigint" || r instanceof x || r instanceof O || r instanceof Date;
3168
+ }, Jo = (r, e, t, n = 0) => r.usesBigInt && !e.usesBigInt ? Number(t) - Number(n) : !r.usesBigInt && e.usesBigInt ? BigInt(t.valueOf()) - BigInt(n.valueOf()) : we(t, -n).valueOf(), we = (r, e) => e == 0 ? r : r == 0 ? e : typeof r == "bigint" && typeof e == "bigint" || typeof r == "number" && typeof e == "number" ? r + e : Number(r) + Number(e), Xo = (r) => r == null ? !1 : Array.isArray(r) || r instanceof ArrayBuffer || ArrayBuffer.isView(r) && !(r instanceof DataView) || r instanceof ta ? !0 : gn(r), q = -1, Bt = {
3169
+ [Symbol.iterator]: () => Bt,
3170
+ next: () => ({ done: !0, value: void 0 })
3171
+ }, Qo = a.string().transform(
3172
+ (r) => new Uint8Array(
3173
+ atob(r).split("").map((e) => e.charCodeAt(0))
3174
+ ).buffer
3175
+ ), ea = a.union([a.null(), a.undefined()]).transform(() => new Uint8Array().buffer), Et = 10, pn = (r, e) => {
3176
+ if (r === "string" && !e.isVariable)
3177
+ throw new Error(`cannot convert series of type ${e.toString()} to string`);
3178
+ if (r === "number" && !e.isNumeric)
3179
+ throw new Error(`cannot convert series of type ${e.toString()} to number`);
3180
+ if (r === "bigint" && !e.usesBigInt)
3181
+ throw new Error(`cannot convert series of type ${e.toString()} to bigint`);
3182
+ }, be = class j {
3183
+ constructor(e) {
3184
+ l(this, "key", ""), l(this, "isSynnaxSeries", !0), l(this, "dataType"), l(this, "sampleOffset"), l(this, "gl"), l(this, "_data"), l(this, "timeRange", re.ZERO), l(this, "alignment", 0n), l(this, "_cachedMin"), l(this, "_cachedMax"), l(this, "writePos", q), l(this, "_refCount", 0), l(this, "_cachedLength"), l(this, "_cachedIndexes"), Xo(e) && (e = { data: e });
3185
+ const {
3186
+ dataType: t,
3187
+ timeRange: n,
3188
+ sampleOffset: s = 0,
3189
+ glBufferUsage: i = "static",
3190
+ alignment: o = 0n,
3191
+ key: u = fn()
3192
+ } = e, h = e.data ?? [];
3193
+ if (h instanceof j || typeof h == "object" && "isSynnaxSeries" in h && h.isSynnaxSeries === !0) {
3194
+ const d = h;
3195
+ this.key = d.key, this.dataType = d.dataType, this.sampleOffset = d.sampleOffset, this.gl = d.gl, this._data = d._data, this.timeRange = d.timeRange, this.alignment = d.alignment, this._cachedMin = d._cachedMin, this._cachedMax = d._cachedMax, this.writePos = d.writePos, this._refCount = d._refCount, this._cachedLength = d._cachedLength;
3196
+ return;
3197
+ }
3198
+ const f = gn(h), g = Array.isArray(h);
3199
+ if (t != null) this.dataType = new w(t);
3200
+ else {
3201
+ if (h instanceof ArrayBuffer)
3202
+ throw new Error(
3203
+ "cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type."
3204
+ );
3205
+ if (g || f) {
3206
+ let d = h;
3207
+ if (!f) {
3208
+ if (h.length === 0)
3209
+ throw new Error(
3210
+ "cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type."
3211
+ );
3212
+ d = h[0];
3213
+ }
3214
+ if (typeof d == "string") this.dataType = w.STRING;
3215
+ else if (typeof d == "number") this.dataType = w.FLOAT64;
3216
+ else if (typeof d == "bigint") this.dataType = w.INT64;
3217
+ else if (typeof d == "boolean") this.dataType = w.BOOLEAN;
3218
+ else if (d instanceof x || d instanceof Date || d instanceof x)
3219
+ this.dataType = w.TIMESTAMP;
3220
+ else if (typeof d == "object") this.dataType = w.JSON;
3221
+ else
3222
+ throw new Error(
3223
+ `cannot infer data type of ${typeof d} when constructing a Series from a JS array`
3224
+ );
3225
+ } else this.dataType = new w(h);
3226
+ }
3227
+ if (!g && !f) this._data = h;
3228
+ else {
3229
+ let d = f ? [h] : h;
3230
+ const B = d[0];
3231
+ (B instanceof x || B instanceof Date || B instanceof O) && (d = d.map((M) => new x(M).valueOf())), this.dataType.equals(w.STRING) ? (this._cachedLength = d.length, this._data = new TextEncoder().encode(`${d.join(`
3232
+ `)}
3233
+ `).buffer) : this.dataType.equals(w.JSON) ? (this._cachedLength = d.length, this._data = new TextEncoder().encode(
3234
+ `${d.map((M) => Ve.encodeString(M)).join(`
3235
+ `)}
3236
+ `
3237
+ ).buffer) : this.dataType.usesBigInt && typeof B == "number" ? this._data = new this.dataType.Array(
3238
+ d.map((M) => BigInt(Math.round(M)))
3239
+ ).buffer : !this.dataType.usesBigInt && typeof B == "bigint" ? this._data = new this.dataType.Array(
3240
+ d.map((M) => Number(M))
3241
+ ).buffer : this._data = new this.dataType.Array(d).buffer;
3242
+ }
3243
+ this.key = u, this.alignment = o, this.sampleOffset = s ?? 0, this.timeRange = n ?? re.ZERO, this.gl = {
3244
+ control: null,
3245
+ buffer: null,
3246
+ prevBuffer: 0,
3247
+ bufferUsage: i
3248
+ };
3249
+ }
3250
+ static alloc({ capacity: e, dataType: t, ...n }) {
3251
+ if (e === 0)
3252
+ throw new Error("[Series] - cannot allocate an array of length 0");
3253
+ const s = new new w(t).Array(e), i = new j({
3254
+ data: s.buffer,
3255
+ dataType: t,
3256
+ ...n
3257
+ });
3258
+ return i.writePos = 0, i;
3259
+ }
3260
+ static createTimestamps(e, t, n) {
3261
+ const s = n.spanRange(t.span(e)), i = new BigInt64Array(e);
3262
+ for (let o = 0; o < e; o++)
3263
+ i[o] = BigInt(n.add(t.span(o)).valueOf());
3264
+ return new j({ data: i, dataType: w.TIMESTAMP, timeRange: s });
3265
+ }
3266
+ get refCount() {
3267
+ return this._refCount;
3268
+ }
3269
+ static fromStrings(e, t) {
3270
+ const n = new TextEncoder().encode(
3271
+ `${e.join(`
3272
+ `)}
3273
+ `
3274
+ );
3275
+ return new j({ data: n, dataType: w.STRING, timeRange: t });
3276
+ }
3277
+ static fromJSON(e, t) {
3278
+ const n = new TextEncoder().encode(
3279
+ `${e.map((s) => Ve.encodeString(s)).join(`
3280
+ `)}
3281
+ `
3282
+ );
3283
+ return new j({ data: n, dataType: w.JSON, timeRange: t });
3284
+ }
3285
+ acquire(e) {
3286
+ this._refCount++, e != null && this.updateGLBuffer(e);
3287
+ }
3288
+ release() {
3289
+ if (this._refCount <= 0) {
3290
+ console.warn("attempted to release a series with a negative reference count");
3291
+ return;
3292
+ }
3293
+ this._refCount--, this._refCount === 0 && this.gl.control != null && this.maybeGarbageCollectGLBuffer(this.gl.control);
3294
+ }
3295
+ /**
3296
+ * Writes the given series to this series. If the series being written exceeds the
3297
+ * remaining of series being written to, only the portion that fits will be written.
3298
+ * @param other the series to write to this series. The data type of the series written
3299
+ * must be the same as the data type of the series being written to.
3300
+ * @returns the number of samples written. If the entire series fits, this value is
3301
+ * equal to the length of the series being written.
3302
+ */
3303
+ write(e) {
3304
+ if (!e.dataType.equals(this.dataType))
3305
+ throw new Error("buffer must be of the same type as this array");
3306
+ return this.dataType.isVariable ? this.writeVariable(e) : this.writeFixed(e);
3307
+ }
3308
+ writeVariable(e) {
3309
+ if (this.writePos === q) return 0;
3310
+ const t = this.byteCapacity.valueOf() - this.writePos, n = e.subBytes(0, t);
3311
+ return this.writeToUnderlyingData(n), this.writePos += n.byteLength.valueOf(), this._cachedLength != null && (this._cachedLength += n.length, this.calculateCachedLength()), n.length;
3312
+ }
3313
+ writeFixed(e) {
3314
+ if (this.writePos === q) return 0;
3315
+ const t = this.capacity - this.writePos, n = e.sub(0, t);
3316
+ return this.writeToUnderlyingData(n), this._cachedLength = void 0, this.maybeRecomputeMinMax(n), this.writePos += n.length, n.length;
3317
+ }
3318
+ writeToUnderlyingData(e) {
3319
+ this.underlyingData.set(
3320
+ e.data,
3321
+ this.writePos
3322
+ );
3323
+ }
3324
+ /** @returns the underlying buffer backing this array. */
3325
+ get buffer() {
3326
+ return typeof this._data == "object" && "buffer" in this._data ? this._data.buffer : this._data;
3327
+ }
3328
+ get underlyingData() {
3329
+ return new this.dataType.Array(this._data);
3330
+ }
3331
+ /** @returns a native typed array with the proper data type. */
3332
+ get data() {
3333
+ return this.writePos === q ? this.underlyingData : new this.dataType.Array(this._data, 0, this.writePos);
3334
+ }
3335
+ toStrings() {
3336
+ if (!this.dataType.matches(w.STRING, w.UUID))
3337
+ throw new Error("cannot convert non-string series to strings");
3338
+ return new TextDecoder().decode(this.underlyingData).split(`
3339
+ `).slice(0, -1);
3340
+ }
3341
+ toUUIDs() {
3342
+ if (!this.dataType.equals(w.UUID))
3343
+ throw new Error("cannot convert non-uuid series to uuids");
3344
+ const e = w.UUID.density.valueOf(), t = Array(this.length);
3345
+ for (let n = 0; n < this.length; n++) {
3346
+ const s = this.underlyingData.slice(n * e, (n + 1) * e), i = Array.from(
3347
+ new Uint8Array(s.buffer),
3348
+ (o) => o.toString(16).padStart(2, "0")
3349
+ ).join("").replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/, "$1-$2-$3-$4-$5");
3350
+ t[n] = i;
3351
+ }
3352
+ return t;
3353
+ }
3354
+ parseJSON(e) {
3355
+ if (!this.dataType.equals(w.JSON))
3356
+ throw new Error("cannot parse non-JSON series as JSON");
3357
+ return new TextDecoder().decode(this.underlyingData).split(`
3358
+ `).slice(0, -1).map((t) => e.parse(Ve.decodeString(t)));
3359
+ }
3360
+ /** @returns the capacity of the series in bytes. */
3361
+ get byteCapacity() {
3362
+ return new Ke(this.underlyingData.byteLength);
3363
+ }
3364
+ /** @returns the capacity of the series in samples. */
3365
+ get capacity() {
3366
+ return this.dataType.isVariable ? this.byteCapacity.valueOf() : this.dataType.density.length(this.byteCapacity);
3367
+ }
3368
+ /** @returns the length of the series in bytes. */
3369
+ get byteLength() {
3370
+ return this.writePos === q ? this.byteCapacity : this.dataType.isVariable ? new Ke(this.writePos) : this.dataType.density.size(this.writePos);
3371
+ }
3372
+ /** @returns the number of samples in this array. */
3373
+ get length() {
3374
+ return this._cachedLength != null ? this._cachedLength : this.dataType.isVariable ? this.calculateCachedLength() : this.writePos === q ? this.data.length : this.writePos;
3375
+ }
3376
+ calculateCachedLength() {
3377
+ if (!this.dataType.isVariable)
3378
+ throw new Error("cannot calculate length of a non-variable length data type");
3379
+ let e = 0;
3380
+ const t = [0];
3381
+ return this.data.forEach((n, s) => {
3382
+ n === Et && (e++, t.push(s + 1));
3383
+ }), this._cachedIndexes = t, this._cachedLength = e, e;
3384
+ }
3385
+ /**
3386
+ * Creates a new array with a different data type.
3387
+ * @param target the data type to convert to.
3388
+ * @param sampleOffset an offset to apply to each sample. This can help with precision
3389
+ * issues when converting between data types.
3390
+ *
3391
+ * WARNING: This method is expensive and copies the entire underlying array. There
3392
+ * also may be untimely precision issues when converting between data types.
3393
+ */
3394
+ convert(e, t = 0) {
3395
+ if (this.dataType.equals(e)) return this;
3396
+ const n = new e.Array(this.length);
3397
+ for (let s = 0; s < this.length; s++)
3398
+ n[s] = Jo(this.dataType, e, this.data[s], t);
3399
+ return new j({
3400
+ data: n.buffer,
3401
+ dataType: e,
3402
+ timeRange: this.timeRange,
3403
+ sampleOffset: t,
3404
+ glBufferUsage: this.gl.bufferUsage,
3405
+ alignment: this.alignment
3406
+ });
3407
+ }
3408
+ calcRawMax() {
3409
+ if (this.length === 0) return -1 / 0;
3410
+ if (this.dataType.equals(w.TIMESTAMP))
3411
+ this._cachedMax = this.data[this.data.length - 1];
3412
+ else if (this.dataType.usesBigInt) {
3413
+ const e = this.data;
3414
+ this._cachedMax = e.reduce((t, n) => t > n ? t : n);
3415
+ } else {
3416
+ const e = this.data;
3417
+ this._cachedMax = e.reduce((t, n) => t > n ? t : n);
3418
+ }
3419
+ return this._cachedMax;
3420
+ }
3421
+ /** @returns the maximum value in the array */
3422
+ get max() {
3423
+ if (this.dataType.isVariable)
3424
+ throw new Error("cannot calculate maximum on a variable length data type");
3425
+ return this.writePos === 0 ? -1 / 0 : (this._cachedMax ?? (this._cachedMax = this.calcRawMax()), we(this._cachedMax, this.sampleOffset));
3426
+ }
3427
+ calcRawMin() {
3428
+ if (this.length === 0) return 1 / 0;
3429
+ if (this.dataType.equals(w.TIMESTAMP)) this._cachedMin = this.data[0];
3430
+ else if (this.dataType.usesBigInt) {
3431
+ const e = this.data;
3432
+ this._cachedMin = e.reduce((t, n) => t < n ? t : n);
3433
+ } else {
3434
+ const e = this.data;
3435
+ this._cachedMin = e.reduce((t, n) => t < n ? t : n);
3436
+ }
3437
+ return this._cachedMin;
3438
+ }
3439
+ /** @returns the minimum value in the array */
3440
+ get min() {
3441
+ if (this.dataType.isVariable)
3442
+ throw new Error("cannot calculate minimum on a variable length data type");
3443
+ return this.writePos === 0 ? 1 / 0 : (this._cachedMin ?? (this._cachedMin = this.calcRawMin()), we(this._cachedMin, this.sampleOffset));
3444
+ }
3445
+ /** @returns the bounds of this array. */
3446
+ get bounds() {
3447
+ return m(Number(this.min), Number(this.max));
3448
+ }
3449
+ maybeRecomputeMinMax(e) {
3450
+ if (this._cachedMin != null) {
3451
+ const t = e._cachedMin ?? e.calcRawMin();
3452
+ t < this._cachedMin && (this._cachedMin = t);
3453
+ }
3454
+ if (this._cachedMax != null) {
3455
+ const t = e._cachedMax ?? e.calcRawMax();
3456
+ t > this._cachedMax && (this._cachedMax = t);
3457
+ }
3458
+ }
3459
+ enrich() {
3460
+ this.max, this.min;
3461
+ }
3462
+ get range() {
3463
+ return we(this.max, -this.min);
3464
+ }
3465
+ atAlignment(e, t) {
3466
+ const n = Number(e - this.alignment);
3467
+ if (n < 0 || n >= this.length) {
3468
+ if (t === !0) throw new Error(`[series] - no value at index ${n}`);
3469
+ return;
3470
+ }
3471
+ return this.at(n, t);
3472
+ }
3473
+ at(e, t) {
3474
+ if (this.dataType.isVariable) return this.atVariable(e, t ?? !1);
3475
+ e < 0 && (e = this.length + e);
3476
+ const n = this.data[e];
3477
+ if (n == null) {
3478
+ if (t === !0) throw new Error(`[series] - no value at index ${e}`);
3479
+ return;
3480
+ }
3481
+ return we(n, this.sampleOffset);
3482
+ }
3483
+ atVariable(e, t) {
3484
+ let n = 0, s = 0;
3485
+ if (this._cachedIndexes != null)
3486
+ n = this._cachedIndexes[e], s = this._cachedIndexes[e + 1] - 1;
3487
+ else {
3488
+ e < 0 && (e = this.length + e);
3489
+ for (let o = 0; o < this.data.length; o++)
3490
+ if (this.data[o] === Et) {
3491
+ if (e === 0) {
3492
+ s = o;
3493
+ break;
3494
+ }
3495
+ n = o + 1, e--;
3496
+ }
3497
+ if (s === 0 && (s = this.data.length), n >= s || e > 0) {
3498
+ if (t) throw new Error(`[series] - no value at index ${e}`);
3499
+ return;
3500
+ }
3501
+ }
3502
+ const i = this.data.slice(n, s);
3503
+ return this.dataType.equals(w.STRING) ? new TextDecoder().decode(i) : tt(JSON.parse(new TextDecoder().decode(i)));
3504
+ }
3505
+ /**
3506
+ * @returns the index of the first sample that is greater than or equal to the given value.
3507
+ * The underlying array must be sorted. If it is not, the behavior of this method is undefined.
3508
+ * @param value the value to search for.
3509
+ */
3510
+ binarySearch(e) {
3511
+ let t = 0, n = this.length - 1;
3512
+ const s = it(e);
3513
+ for (; t <= n; ) {
3514
+ const i = Math.floor((t + n) / 2), o = s(this.at(i, !0), e);
3515
+ if (o === 0) return i;
3516
+ o < 0 ? t = i + 1 : n = i - 1;
3517
+ }
3518
+ return t;
3519
+ }
3520
+ updateGLBuffer(e) {
3521
+ if (this.gl.control = e, !this.dataType.equals(w.FLOAT32) && !this.dataType.equals(w.UINT8))
3522
+ throw new Error("Only FLOAT32 and UINT8 arrays can be used in WebGL");
3523
+ const { buffer: t, bufferUsage: n, prevBuffer: s } = this.gl;
3524
+ if (t == null && (this.gl.buffer = e.createBuffer()), this.writePos !== s)
3525
+ if (e.bindBuffer(e.ARRAY_BUFFER, this.gl.buffer), this.writePos !== q) {
3526
+ s === 0 && e.bufferData(e.ARRAY_BUFFER, this.byteCapacity.valueOf(), e.STATIC_DRAW);
3527
+ const i = this.dataType.density.size(s).valueOf(), o = this.underlyingData.slice(this.gl.prevBuffer, this.writePos);
3528
+ e.bufferSubData(e.ARRAY_BUFFER, i, o.buffer), this.gl.prevBuffer = this.writePos;
3529
+ } else
3530
+ e.bufferData(
3531
+ e.ARRAY_BUFFER,
3532
+ this.buffer,
3533
+ n === "static" ? e.STATIC_DRAW : e.DYNAMIC_DRAW
3534
+ ), this.gl.prevBuffer = q;
3535
+ }
3536
+ as(e) {
3537
+ return pn(e, this.dataType), this;
3538
+ }
3539
+ get digest() {
3540
+ var e;
3541
+ return {
3542
+ key: this.key,
3543
+ dataType: this.dataType.toString(),
3544
+ sampleOffset: this.sampleOffset,
3545
+ alignment: {
3546
+ lower: $r(this.alignmentBounds.lower),
3547
+ upper: $r(this.alignmentBounds.upper)
3548
+ },
3549
+ timeRange: (e = this.timeRange) == null ? void 0 : e.toString(),
3550
+ length: this.length,
3551
+ capacity: this.capacity
3552
+ };
3553
+ }
3554
+ get memInfo() {
3555
+ return {
3556
+ key: this.key,
3557
+ length: this.length,
3558
+ byteLength: this.byteLength,
3559
+ glBuffer: this.gl.buffer != null
3560
+ };
3561
+ }
3562
+ get alignmentBounds() {
3563
+ return m(this.alignment, this.alignment + BigInt(this.length));
3564
+ }
3565
+ maybeGarbageCollectGLBuffer(e) {
3566
+ this.gl.buffer != null && (e.deleteBuffer(this.gl.buffer), this.gl.buffer = null, this.gl.prevBuffer = 0, this.gl.control = null);
3567
+ }
3568
+ get glBuffer() {
3569
+ if (this.gl.buffer == null) throw new Error("gl buffer not initialized");
3570
+ return this.gl.prevBuffer !== this.writePos && console.warn("buffer not updated"), this.gl.buffer;
3571
+ }
3572
+ [Symbol.iterator]() {
3573
+ if (this.dataType.isVariable) {
3574
+ const e = new ra(this);
3575
+ return this.dataType.equals(w.JSON) ? new na(e) : e;
3576
+ }
3577
+ return new sa(this);
3578
+ }
3579
+ slice(e, t) {
3580
+ return this.sliceSub(!1, e, t);
3581
+ }
3582
+ sub(e, t) {
3583
+ return this.sliceSub(!0, e, t);
3584
+ }
3585
+ subIterator(e, t) {
3586
+ return new gr(this, e, t ?? this.length);
3587
+ }
3588
+ subAlignmentIterator(e, t) {
3589
+ return new gr(
3590
+ this,
3591
+ Number(e - this.alignment),
3592
+ Number(t - this.alignment)
3593
+ );
3594
+ }
3595
+ subBytes(e, t) {
3596
+ if (e >= 0 && (t == null || t >= this.byteLength.valueOf())) return this;
3597
+ const n = this.data.subarray(e, t);
3598
+ return new j({
3599
+ data: n,
3600
+ dataType: this.dataType,
3601
+ timeRange: this.timeRange,
3602
+ sampleOffset: this.sampleOffset,
3603
+ glBufferUsage: this.gl.bufferUsage,
3604
+ alignment: this.alignment + BigInt(e)
3605
+ });
3606
+ }
3607
+ sliceSub(e, t, n) {
3608
+ if (t <= 0 && (n == null || n >= this.length)) return this;
3609
+ let s;
3610
+ return e ? s = this.data.subarray(t, n) : s = this.data.slice(t, n), new j({
3611
+ data: s,
3612
+ dataType: this.dataType,
3613
+ timeRange: this.timeRange,
3614
+ sampleOffset: this.sampleOffset,
3615
+ glBufferUsage: this.gl.bufferUsage,
3616
+ alignment: this.alignment + BigInt(t)
3617
+ });
3618
+ }
3619
+ reAlign(e) {
3620
+ return new j({
3621
+ data: this.buffer,
3622
+ dataType: this.dataType,
3623
+ timeRange: re.ZERO,
3624
+ sampleOffset: this.sampleOffset,
3625
+ glBufferUsage: "static",
3626
+ alignment: e
3627
+ });
3628
+ }
3629
+ toString() {
3630
+ var e, t;
3631
+ let n = `${this.dataType.toString()} ${this.length} [`;
3632
+ if (this.length <= 10) n += Array.from(this).map((s) => s.toString());
3633
+ else {
3634
+ for (let s = 0; s < 5; s++)
3635
+ n += `${(e = this.at(s)) == null ? void 0 : e.toString()}`, s < 4 && (n += ",");
3636
+ n += "...";
3637
+ for (let s = -5; s < 0; s++)
3638
+ n += (t = this.at(s)) == null ? void 0 : t.toString(), s < -1 && (n += ",");
3639
+ }
3640
+ return n += "]", n;
3641
+ }
3642
+ };
3643
+ l(be, "crudeZ", a.object({
3644
+ timeRange: re.z.optional(),
3645
+ dataType: w.z,
3646
+ alignment: a.coerce.bigint().optional(),
3647
+ data: a.union([
3648
+ Qo,
3649
+ ea,
3650
+ a.instanceof(ArrayBuffer),
3651
+ a.instanceof(Uint8Array)
3652
+ ]),
3653
+ glBufferUsage: Ko.optional().default("static").optional()
3654
+ })), l(be, "z", be.crudeZ.transform((r) => new be(r)));
3655
+ let ta = be, gr = class {
3656
+ constructor(e, t, n) {
3657
+ l(this, "series"), l(this, "end"), l(this, "index"), this.series = e;
3658
+ const s = m(0, e.length);
3659
+ this.end = yt(s, n), this.index = yt(s, t);
3660
+ }
3661
+ next() {
3662
+ return this.index >= this.end ? { done: !0, value: void 0 } : { done: !1, value: this.series.at(this.index++, !0) };
3663
+ }
3664
+ [Symbol.iterator]() {
3665
+ return this;
3666
+ }
3667
+ }, ra = class {
3668
+ constructor(e) {
3669
+ if (l(this, "series"), l(this, "index"), l(this, "decoder"), !e.dataType.isVariable)
3670
+ throw new Error(
3671
+ "cannot create a variable series iterator for a non-variable series"
3672
+ );
3673
+ this.series = e, this.index = 0, this.decoder = new TextDecoder();
3674
+ }
3675
+ next() {
3676
+ const e = this.index, t = this.series.data;
3677
+ for (; this.index < t.length && t[this.index] !== Et; ) this.index++;
3678
+ const n = this.index;
3679
+ return e === n ? { done: !0, value: void 0 } : (this.index++, { done: !1, value: this.decoder.decode(this.series.buffer.slice(e, n)) });
3680
+ }
3681
+ [Symbol.iterator]() {
3682
+ return this;
3683
+ }
3684
+ };
3685
+ var pr, yr;
3686
+ const yn = class mn {
3687
+ constructor(e) {
3688
+ l(this, "wrapped"), l(this, pr, "JSONSeriesIterator"), this.wrapped = e;
3689
+ }
3690
+ next() {
3691
+ const e = this.wrapped.next();
3692
+ return e.done === !0 ? { done: !0, value: void 0 } : {
3693
+ done: !1,
3694
+ value: Ve.decodeString(e.value, mn.SCHEMA)
3695
+ };
3696
+ }
3697
+ [(yr = Symbol.iterator, pr = Symbol.toStringTag, yr)]() {
3698
+ return this;
3699
+ }
3700
+ };
3701
+ l(yn, "SCHEMA", a.record(a.string(), a.unknown()));
3702
+ let na = yn;
3703
+ var mr, wr;
3704
+ class sa {
3705
+ constructor(e) {
3706
+ l(this, "series"), l(this, "index"), l(this, mr, "SeriesIterator"), this.series = e, this.index = 0;
3707
+ }
3708
+ next() {
3709
+ return this.index >= this.series.length ? { done: !0, value: void 0 } : {
3710
+ done: !1,
3711
+ value: this.series.at(this.index++, !0)
3712
+ };
3713
+ }
3714
+ [(wr = Symbol.iterator, mr = Symbol.toStringTag, wr)]() {
3715
+ return this;
3716
+ }
3717
+ }
3718
+ class ol {
3719
+ constructor(e = []) {
3720
+ if (l(this, "series"), e.length !== 0) {
3721
+ const t = e[0].dataType;
3722
+ for (let n = 1; n < e.length; n++)
3723
+ if (!e[n].dataType.equals(t))
3724
+ throw new Error("[multi-series] - series must have the same data type");
3725
+ }
3726
+ this.series = e;
3727
+ }
3728
+ as(e) {
3729
+ return pn(e, this.dataType), this;
3730
+ }
3731
+ get dataType() {
3732
+ return this.series.length === 0 ? w.UNKNOWN : this.series[0].dataType;
3733
+ }
3734
+ get timeRange() {
3735
+ return this.series.length === 0 ? re.ZERO : new re(
3736
+ this.series[0].timeRange.start,
3737
+ this.series[this.series.length - 1].timeRange.end
3738
+ );
3739
+ }
3740
+ get alignment() {
3741
+ return this.series.length === 0 ? 0n : this.series[0].alignment;
3742
+ }
3743
+ get alignmentBounds() {
3744
+ return this.series.length === 0 ? m(0n, 0n) : m(
3745
+ this.series[0].alignmentBounds.lower,
3746
+ this.series[this.series.length - 1].alignmentBounds.upper
3747
+ );
3748
+ }
3749
+ push(e) {
3750
+ "isSynnaxSeries" in e && e.isSynnaxSeries ? this.series.push(e) : this.series.push(...e.series);
3751
+ }
3752
+ get length() {
3753
+ return this.series.reduce((e, t) => e + t.length, 0);
3754
+ }
3755
+ atAlignment(e, t) {
3756
+ if (this.series.length === 0) {
3757
+ if (t) throw new Error(`[series] - no value at alignment ${e}`);
3758
+ return;
3759
+ }
3760
+ for (const n of this.series)
3761
+ if (C(n.alignmentBounds, e))
3762
+ return n.atAlignment(e, t);
3763
+ if (t) throw new Error(`[series] - no value at alignment ${e}`);
3764
+ }
3765
+ at(e, t = !1) {
3766
+ e < 0 && (e = this.length + e);
3767
+ for (const n of this.series) {
3768
+ if (e < n.length) return n.at(e, t);
3769
+ e -= n.length;
3770
+ }
3771
+ if (t) throw new Error(`[series] - no value at index ${e}`);
3772
+ }
3773
+ subIterator(e, t) {
3774
+ return new ht(this, e, t ?? this.length);
3775
+ }
3776
+ subAlignmentIterator(e, t) {
3777
+ if (e >= this.alignmentBounds.upper || t <= this.alignmentBounds.lower)
3778
+ return Bt;
3779
+ let n = 0;
3780
+ for (let i = 0; i < this.series.length; i++) {
3781
+ const o = this.series[i];
3782
+ if (e < o.alignment) break;
3783
+ if (e >= o.alignmentBounds.upper) n += o.length;
3784
+ else if (C(o.alignmentBounds, e)) {
3785
+ n += Number(e - o.alignment);
3786
+ break;
3787
+ }
3788
+ }
3789
+ let s = 0;
3790
+ for (let i = 0; i < this.series.length; i++) {
3791
+ const o = this.series[i];
3792
+ if (t < o.alignment) break;
3793
+ if (t >= o.alignmentBounds.upper) s += o.length;
3794
+ else if (C(o.alignmentBounds, t)) {
3795
+ s += Number(t - o.alignment);
3796
+ break;
3797
+ }
3798
+ }
3799
+ return new ht(this, n, s);
3800
+ }
3801
+ subAlignmentSpanIterator(e, t) {
3802
+ if (e >= this.alignmentBounds.upper) return Bt;
3803
+ let n = 0;
3804
+ for (let s = 0; s < this.series.length; s++) {
3805
+ const i = this.series[s];
3806
+ if (e < i.alignment) break;
3807
+ if (e >= i.alignmentBounds.upper) n += i.length;
3808
+ else if (C(i.alignmentBounds, e)) {
3809
+ n += Number(e - i.alignment);
3810
+ break;
3811
+ }
3812
+ }
3813
+ return new ht(this, n, n + t);
3814
+ }
3815
+ updateGLBuffer(e) {
3816
+ this.series.forEach((t) => t.updateGLBuffer(e));
3817
+ }
3818
+ get bounds() {
3819
+ return Mr(this.series.map((e) => e.bounds));
3820
+ }
3821
+ get byteLength() {
3822
+ return new Ke(this.series.reduce((e, t) => e + t.byteLength.valueOf(), 0));
3823
+ }
3824
+ get data() {
3825
+ const e = new this.dataType.Array(this.length);
3826
+ let t = 0;
3827
+ for (const n of this.series)
3828
+ e.set(n.data, t), t += n.length;
3829
+ return new this.dataType.Array(e.buffer);
3830
+ }
3831
+ traverseAlignment(e, t) {
3832
+ const n = this.series.map((s) => s.alignmentBounds);
3833
+ return Cr(n, e, t);
3834
+ }
3835
+ acquire() {
3836
+ this.series.forEach((e) => e.acquire());
3837
+ }
3838
+ release() {
3839
+ this.series.forEach((e) => e.release());
3840
+ }
3841
+ distance(e, t) {
3842
+ const n = this.series.map((s) => s.alignmentBounds);
3843
+ return Lr(n, e, t);
3844
+ }
3845
+ parseJSON(e) {
3846
+ if (!this.dataType.equals(w.JSON))
3847
+ throw new Error("cannot parse non-JSON series as JSON");
3848
+ return this.series.flatMap((t) => t.parseJSON(e));
3849
+ }
3850
+ [Symbol.iterator]() {
3851
+ return this.series.length === 0 ? {
3852
+ next() {
3853
+ return { done: !0, value: void 0 };
3854
+ }
3855
+ } : new ia(this.series);
3856
+ }
3857
+ }
3858
+ var br, vr;
3859
+ let ia = class {
3860
+ constructor(e) {
3861
+ l(this, "series"), l(this, "seriesIndex"), l(this, "internal"), l(this, br, "MultiSeriesIterator"), this.series = e, this.seriesIndex = 0, this.internal = e[0][Symbol.iterator]();
3862
+ }
3863
+ next() {
3864
+ const e = this.internal.next();
3865
+ return e.done === !1 ? e : this.seriesIndex === this.series.length - 1 ? { done: !0, value: void 0 } : (this.internal = this.series[++this.seriesIndex][Symbol.iterator](), this.next());
3866
+ }
3867
+ [(vr = Symbol.iterator, br = Symbol.toStringTag, vr)]() {
3868
+ return this;
3869
+ }
3870
+ }, ht = class {
3871
+ constructor(e, t, n) {
3872
+ l(this, "series"), l(this, "index"), l(this, "end"), this.series = e, this.end = n, this.index = t;
3873
+ }
3874
+ next() {
3875
+ return this.index >= this.end ? { done: !0, value: void 0 } : { done: !1, value: this.series.at(this.index++, !0) };
3876
+ }
3877
+ [Symbol.iterator]() {
3878
+ return this;
3879
+ }
3880
+ };
3881
+ const $r = (r) => {
3882
+ const e = r >> 32n, t = r & 0xffffffffn;
3883
+ return { domain: e, sample: t };
3884
+ }, oa = (r, e, t = ".") => {
3885
+ const n = r.split(t);
3886
+ return n.map((s, i) => {
3887
+ const o = e(s, i, n);
3888
+ return o == null ? null : typeof o == "string" ? o : o.join(t);
3889
+ }).filter((s) => s != null).join(t);
3890
+ }, wn = (r, e, t = { optional: !1, separator: "." }) => {
3891
+ t.separator ?? (t.separator = ".");
3892
+ const { optional: n, getter: s = (u, h) => u[h] } = t, i = e.split(t.separator);
3893
+ if (i.length === 1 && i[0] === "") return r;
3894
+ let o = r;
3895
+ for (const u of i) {
3896
+ const h = s(o, u);
3897
+ if (h == null) {
3898
+ if (n) return null;
3899
+ throw new Error(`Path ${e} does not exist. ${u} is null`);
3900
+ }
3901
+ o = h;
3902
+ }
3903
+ return o;
3904
+ }, ll = (r, e, t) => {
3905
+ const n = e.split(".");
3906
+ let s = r;
3907
+ for (let i = 0; i < n.length - 1; i++) {
3908
+ const o = n[i];
3909
+ s[o] ?? (s[o] = {}), s = s[o];
3910
+ }
3911
+ try {
3912
+ s[n[n.length - 1]] = t;
3913
+ } catch (i) {
3914
+ throw console.error("failed to set value", t, "at path", e, "on object", r), i;
3915
+ }
3916
+ }, hl = (r, e) => {
3917
+ const t = e.split(".");
3918
+ let n = r;
3919
+ for (let s = 0; s < t.length - 1; s++) {
3920
+ const i = t[s];
3921
+ if (n[i] == null) return;
3922
+ n = n[i];
3923
+ }
3924
+ if (Array.isArray(n)) {
3925
+ const s = parseInt(t[t.length - 1]);
3926
+ if (isNaN(s)) return;
3927
+ n.splice(s, 1);
3928
+ return;
3929
+ }
3930
+ delete n[t[t.length - 1]];
3931
+ }, cl = (r, e) => {
3932
+ const t = r.split(".");
3933
+ return e < 0 ? t[t.length + e] : t[e];
3934
+ }, fl = (r, e) => {
3935
+ try {
3936
+ return wn(r, e), !0;
3937
+ } catch {
3938
+ return !1;
3939
+ }
3940
+ }, dl = (r, e) => {
3941
+ if (e.length === 0) return !0;
3942
+ const t = r.split("."), n = e.split(".");
3943
+ if (n.length > t.length) return !1;
3944
+ for (let s = 0; s < n.length; s++) {
3945
+ const i = t[s], o = n[s];
3946
+ if (o !== "*" && i !== o)
3947
+ return !1;
3948
+ }
3949
+ return !0;
3950
+ };
3951
+ a.object({ key: a.string(), value: a.string() });
3952
+ const gl = a.record(
3953
+ a.union([a.number(), a.string(), a.symbol()]),
3954
+ a.unknown()
3955
+ ), bn = () => typeof process < "u" && process.versions != null && process.versions.node != null ? "node" : typeof window > "u" || window.document === void 0 ? "webworker" : "browser", aa = bn(), vn = ["macOS", "Windows", "Linux"], ua = ["macos", "windows", "linux"], la = {
3956
+ macos: "macOS",
3957
+ windows: "Windows",
3958
+ linux: "Linux"
3959
+ }, ha = a.enum(vn).or(
3960
+ a.enum(ua).transform((r) => la[r])
3961
+ ), ca = () => {
3962
+ if (typeof window > "u") return;
3963
+ const r = window.navigator.userAgent.toLowerCase();
3964
+ if (r.includes("mac")) return "macOS";
3965
+ if (r.includes("win")) return "Windows";
3966
+ if (r.includes("linux")) return "Linux";
3967
+ };
3968
+ let ct;
3969
+ const fa = (r = {}) => {
3970
+ const { force: e, default: t } = r;
3971
+ return e ?? ct ?? (ct = ca(), ct ?? t);
3972
+ }, pl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3973
+ __proto__: null,
3974
+ OPERATING_SYSTEMS: vn,
3975
+ RUNTIME: aa,
3976
+ detect: bn,
3977
+ getOS: fa,
3978
+ osZ: ha
3979
+ }, Symbol.toStringTag, { value: "Module" }));
3980
+ var da = Object.defineProperty, ga = (r, e, t) => e in r ? da(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, ve = (r, e, t) => ga(r, typeof e != "symbol" ? e + "" : e, t);
3981
+ const pa = (...r) => r.map($n).join(""), $n = (r) => (r.endsWith("/") || (r += "/"), r.startsWith("/") && (r = r.slice(1)), r), ya = (r) => r.endsWith("/") ? r.slice(0, -1) : r, xr = class At {
3982
+ /**
3983
+ * @param host - The hostname or IP address of the server.
3984
+ * @param port - The port number of the server.
3985
+ * @param protocol - The protocol to use for all requests. Defaults to "".
3986
+ * @param pathPrefix - A path prefix to use for all requests. Defaults to "".
3987
+ */
3988
+ constructor({ host: e, port: t, protocol: n = "", pathPrefix: s = "" }) {
3989
+ ve(this, "protocol"), ve(this, "host"), ve(this, "port"), ve(this, "path"), this.protocol = n, this.host = e, this.port = t, this.path = $n(s);
3990
+ }
3991
+ /**
3992
+ * Replaces creates a new URL with the specified properties replaced.
3993
+ * @param props - The properties to replace.
3994
+ * @returns a new URL.
3995
+ */
3996
+ replace(e) {
3997
+ return new At({
3998
+ host: e.host ?? this.host,
3999
+ port: e.port ?? this.port,
4000
+ protocol: e.protocol ?? this.protocol,
4001
+ pathPrefix: e.pathPrefix ?? this.path
4002
+ });
4003
+ }
4004
+ /**
4005
+ * Creates a new url with the given path appended to the current path.
4006
+ * @param path - the path to append to the URL.
4007
+ * @returns a new URL.
4008
+ */
4009
+ child(e) {
4010
+ return new At({
4011
+ ...this,
4012
+ pathPrefix: pa(this.path, e)
4013
+ });
4014
+ }
4015
+ /** @returns a string representation of the url */
4016
+ toString() {
4017
+ return ya(
4018
+ `${this.protocol}://${this.host}:${this.port}/${this.path}`
4019
+ );
4020
+ }
4021
+ };
4022
+ ve(xr, "UNKNOWN", new xr({ host: "unknown", port: 0 }));
4023
+ const ma = -128, wa = 127, ba = a.number().int().min(ma).max(wa), va = -32768, $a = 32767, xa = a.number().int().min(va).max($a), Oa = -2147483648, Ta = 2147483647, Sa = a.number().int().min(Oa).max(Ta), Ia = -9223372036854775808n, Na = 9223372036854775807n, Ua = a.bigint().min(Ia).max(Na), Ba = 255, Ea = a.number().int().min(0).max(Ba), Aa = 65535, Ma = a.number().int().min(0).max(Aa), Ca = 4294967295, La = a.number().int().min(0).max(Ca), Ra = 18446744073709551615n, ja = a.bigint().min(0n).max(Ra), xn = (r) => oa(r, (e, t, n) => {
4024
+ const s = t === n.length - 1, i = !isNaN(parseInt(e)), o = !isNaN(parseInt(n[t + 1]));
4025
+ return i && (e = "element"), s || o ? e : [e, "shape"];
4026
+ }), Or = (r, e) => {
4027
+ if (r == null) return null;
4028
+ const t = r[e];
4029
+ return t == null && typeof r == "object" && "sourceType" in r ? r.sourceType()[e] : t;
4030
+ }, ka = (r, e, t) => wn(
4031
+ Or(r, "shape"),
4032
+ xn(e),
4033
+ { ...t, getter: Or }
4034
+ ), yl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4035
+ __proto__: null,
4036
+ getFieldSchema: ka,
4037
+ getFieldSchemaPath: xn,
4038
+ int16: xa,
4039
+ int32: Sa,
4040
+ int64: Ua,
4041
+ int8: ba,
4042
+ uint16: Ma,
4043
+ uint32: La,
4044
+ uint64: ja,
4045
+ uint8: Ea
4046
+ }, Symbol.toStringTag, { value: "Module" }));
4047
+ var Da = Object.defineProperty, Pa = (r, e, t) => e in r ? Da(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, Q = (r, e, t) => Pa(r, typeof e != "symbol" ? e + "" : e, t);
4048
+ const za = 2, Fa = 3, _a = 2, qa = (r, e) => {
4049
+ if (Number.isNaN(r) || !Number.isFinite(r)) return r;
4050
+ const t = Me(e);
4051
+ if (t == 0) return r;
4052
+ let n;
4053
+ t >= 1e3 ? n = za : t >= 1 ? n = Fa : n = Math.ceil(-Math.log10(t)) + _a;
4054
+ const s = 10 ** n;
4055
+ return Math.round(r * s) / s;
4056
+ }, ml = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4057
+ __proto__: null,
4058
+ abs: Ar,
4059
+ add: Br,
4060
+ closeTo: Qn,
4061
+ div: rs,
4062
+ equal: gt,
4063
+ max: ts,
4064
+ min: Er,
4065
+ mult: X,
4066
+ roundBySpan: qa,
4067
+ roundToNearestMagnitude: es,
4068
+ sub: $e
4069
+ }, Symbol.toStringTag, { value: "Module" }));
4070
+ a.object({
4071
+ baseInterval: O.z.optional(),
4072
+ maxRetries: a.number().optional(),
4073
+ scale: a.number().optional()
4074
+ });
4075
+ const Wa = /^#?([0-9a-f]{6}|[0-9a-f]{8})$/i, nr = a.string().regex(Wa), oe = a.number().min(0).max(255), Va = a.number().min(0).max(1), sr = a.tuple([oe, oe, oe, Va]), On = a.tuple([oe, oe, oe]), Ya = (r) => Le.safeParse(r).success, Za = (r) => sr.safeParse(r).success, Ha = (r) => {
4076
+ if (r == null) return;
4077
+ const e = Le.safeParse(r);
4078
+ if (e.success) return In(e.data);
4079
+ if (typeof r == "string") return r;
4080
+ throw e.error;
4081
+ }, $ = (r, e = 1) => {
4082
+ if (typeof r == "string") return nu(r, e);
4083
+ if (Array.isArray(r)) {
4084
+ if (r.length < 3 || r.length > 4)
4085
+ throw new Error(`Invalid color: [${r.join(", ")}]`);
4086
+ return r.length === 3 ? [...r, e] : r;
4087
+ }
4088
+ throw new Error(`Invalid color: ${JSON.stringify(r)}`);
4089
+ }, Tn = (r, e) => {
4090
+ if (r == null || e == null) return !1;
4091
+ const t = $(r), n = $(e);
4092
+ return t.every((s, i) => s === n[i]);
4093
+ }, Sn = (r) => {
4094
+ if (r == null) return;
4095
+ const [e, t, n, s] = $(r);
4096
+ return `#${ze(e)}${ze(t)}${ze(n)}${s === 1 ? "" : ze(s * 255)}`;
4097
+ }, In = (r) => {
4098
+ const [e, t, n, s] = $(r);
4099
+ return `rgba(${e}, ${t}, ${n}, ${s})`;
4100
+ }, Ga = (r) => `rgb(${Nn(r)})`, Nn = (r) => {
4101
+ const [e, t, n] = $(r);
4102
+ return `${e}, ${t}, ${n}`;
4103
+ }, Ka = (r) => [...ir(r), Ie(r)], ir = (r) => [
4104
+ Oe(r) / 255,
4105
+ Te(r) / 255,
4106
+ Se(r) / 255
4107
+ ], Oe = (r) => $(r)[0], Te = (r) => $(r)[1], Se = (r) => $(r)[2], Ie = (r) => $(r)[3], Ja = (r) => Tn(or, r), Xa = (r) => ou($(r)), Qa = (r, e) => {
4108
+ const [t, n, s] = $(r);
4109
+ if (e > 100)
4110
+ throw new Error(`Color opacity must be between 0 and 100, got ${e}`);
4111
+ return e > 1 && (e /= 100), [t, n, s, e];
4112
+ }, Je = (r) => {
4113
+ const [e, t, n] = ir(r).map(
4114
+ (s) => s <= 0.03928 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4
4115
+ );
4116
+ return Number((0.2126 * e + 0.7152 * t + 0.0722 * n).toFixed(3));
4117
+ }, eu = (r) => {
4118
+ const [e, t, n] = ir(r);
4119
+ return 1 - (Math.max(e, t, n) - Math.min(e, t, n));
4120
+ }, Mt = (r, e) => {
4121
+ const t = $(r), n = $(e), s = Je(t), i = Je(n);
4122
+ return (Math.max(s, i) + 0.5) / (Math.min(s, i) + 0.5);
4123
+ }, tu = (r, ...e) => {
4124
+ if (e.length === 0)
4125
+ throw new Error("[Color.pickByContrast] - must provide at least one color");
4126
+ const t = $(r), [n] = e.map((s) => $(s)).sort((s, i) => Mt(t, i) - Mt(t, s));
4127
+ return n;
4128
+ }, Un = (r) => Je(r) < 0.5, ru = (r) => !Un(r), Le = a.union([nr, sr, On]).transform((r) => $(r)), nu = (r, e = 1) => {
4129
+ if (!nr.safeParse(r).success) throw new Error(`Invalid hex color: ${r}`);
4130
+ return r = su(r), [
4131
+ Fe(r, 0),
4132
+ Fe(r, 2),
4133
+ Fe(r, 4),
4134
+ r.length === 8 ? Fe(r, 6) / 255 : e
4135
+ ];
4136
+ }, or = [0, 0, 0, 0], ze = (r) => Math.floor(r).toString(16).padStart(2, "0"), Fe = (r, e) => parseInt(r.slice(e, e + 2), 16), su = (r) => r.startsWith("#") ? r.slice(1) : r, iu = (r) => {
4137
+ let [e, t, n] = r;
4138
+ const s = r[3];
4139
+ e /= 360, t /= 100, n /= 100;
4140
+ let i, o, u;
4141
+ if (t === 0)
4142
+ i = o = u = n;
4143
+ else {
4144
+ const h = n < 0.5 ? n * (1 + t) : n + t - n * t, f = 2 * n - h;
4145
+ i = ft(f, h, e + 1 / 3), o = ft(f, h, e), u = ft(f, h, e - 1 / 3);
4146
+ }
4147
+ return [Math.round(i * 255), Math.round(o * 255), Math.round(u * 255), s];
4148
+ }, ft = (r, e, t) => (t < 0 && (t += 1), t > 1 && (t -= 1), t < 1 / 6 ? r + (e - r) * 6 * t : t < 1 / 2 ? e : t < 2 / 3 ? r + (e - r) * (2 / 3 - t) * 6 : r), ou = (r) => {
4149
+ let [e, t, n] = r;
4150
+ const s = r[3];
4151
+ e /= 255, t /= 255, n /= 255;
4152
+ const i = Math.max(e, t, n), o = Math.min(e, t, n);
4153
+ let u, h, f = (i + o) / 2;
4154
+ if (i === o)
4155
+ u = h = 0;
4156
+ else {
4157
+ const g = i - o;
4158
+ h = f > 0.5 ? g / (2 - i - o) : g / (i + o), i === e ? u = (t - n) / g + (t < n ? 6 : 0) : i === t ? u = (n - e) / g + 2 : u = (e - t) / g + 4, u /= 6;
4159
+ }
4160
+ return u *= 360, h *= 100, f *= 100, [Math.round(u), Math.round(h), Math.round(f), s];
4161
+ }, Bn = a.union([nr, sr, a.string(), On]), au = $("#000000"), uu = $("#ffffff"), En = a.object({
4162
+ key: a.string(),
4163
+ color: Bn,
4164
+ position: a.number(),
4165
+ switched: a.boolean().optional()
4166
+ }), lu = a.array(En), hu = (r, e) => {
4167
+ if (r.length === 0) return or;
4168
+ if (r = r.slice().sort((t, n) => t.position - n.position), e <= r[0].position) return $(r[0].color);
4169
+ if (e >= r[r.length - 1].position)
4170
+ return $(r[r.length - 1].color);
4171
+ for (let t = 0; t < r.length - 1; t++) {
4172
+ const n = r[t], s = r[t + 1];
4173
+ if (e >= n.position && e <= s.position) {
4174
+ if (e === n.position) return $(n.color);
4175
+ if (e === s.position) return $(s.color);
4176
+ const i = (e - n.position) / (s.position - n.position), o = $(n.color), u = $(s.color), h = Math.round(
4177
+ Oe(o) + i * (Oe(u) - Oe(o))
4178
+ ), f = Math.round(
4179
+ Te(o) + i * (Te(u) - Te(o))
4180
+ ), g = Math.round(
4181
+ Se(o) + i * (Se(u) - Se(o))
4182
+ ), d = Ie(o) + i * (Ie(u) - Ie(o));
4183
+ return $([h, f, g, d]);
4184
+ }
4185
+ }
4186
+ return $(r[r.length - 1].color);
4187
+ }, cu = a.object({
4188
+ key: a.string(),
4189
+ name: a.string(),
4190
+ color: Le
4191
+ }), fu = a.object({
4192
+ key: a.string(),
4193
+ name: a.string(),
4194
+ swatches: a.array(cu)
4195
+ }), An = (r) => {
4196
+ const e = Le.safeParse(r);
4197
+ if (e.success) return Sn(e.data);
4198
+ if (typeof r == "object" && r != null) {
4199
+ const t = Array.isArray(r) ? [] : {};
4200
+ for (const n of Object.keys(r))
4201
+ t[n] = An(r[n]);
4202
+ return t;
4203
+ }
4204
+ return r;
4205
+ }, wl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4206
+ __proto__: null,
4207
+ BLACK: au,
4208
+ WHITE: uu,
4209
+ ZERO: or,
4210
+ aValue: Ie,
4211
+ bValue: Se,
4212
+ colorZ: Le,
4213
+ construct: $,
4214
+ contrast: Mt,
4215
+ crudeZ: Bn,
4216
+ cssString: Ha,
4217
+ equals: Tn,
4218
+ fromGradient: hu,
4219
+ fromHSLA: iu,
4220
+ gValue: Te,
4221
+ gradientZ: lu,
4222
+ grayness: eu,
4223
+ hex: Sn,
4224
+ hsla: Xa,
4225
+ isColor: Za,
4226
+ isCrude: Ya,
4227
+ isDark: Un,
4228
+ isLight: ru,
4229
+ isZero: Ja,
4230
+ luminance: Je,
4231
+ paletteZ: fu,
4232
+ pickByContrast: tu,
4233
+ rValue: Oe,
4234
+ rgbCSS: Ga,
4235
+ rgbString: Nn,
4236
+ rgba1: Ka,
4237
+ rgbaCSS: In,
4238
+ setAlpha: Qa,
4239
+ stopZ: En,
4240
+ transformColorsToHex: An
4241
+ }, Symbol.toStringTag, { value: "Module" })), Mn = a.number().int().min(0).max(255), Cn = 255, Ln = 0, du = {
4242
+ lower: Ln,
4243
+ upper: Cn + 1
4244
+ }, Rn = a.object({
4245
+ name: a.string(),
4246
+ key: a.string()
4247
+ }), Ae = (r) => a.object({
4248
+ subject: Rn,
4249
+ resource: r,
4250
+ authority: Mn
4251
+ }), gu = (...r) => (e) => e.filter((t) => {
4252
+ let n = !1;
4253
+ return t.to != null && (n = r.includes(t.to.resource)), t.from != null && !n && (n = r.includes(t.from.resource)), n;
4254
+ }), jn = a.object({
4255
+ from: Ae(a.any()),
4256
+ to: a.null()
4257
+ }), kn = a.object({
4258
+ from: a.null(),
4259
+ to: Ae(a.any())
4260
+ }), pu = a.union([
4261
+ jn,
4262
+ kn,
4263
+ a.object({
4264
+ from: Ae(a.any()),
4265
+ to: Ae(a.any())
4266
+ })
4267
+ ]), bl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4268
+ __proto__: null,
4269
+ ABSOLUTE_AUTHORITY: Cn,
4270
+ AUTHORITY_BOUNDS: du,
4271
+ ZERO_AUTHORITY: Ln,
4272
+ acquireZ: kn,
4273
+ authorityZ: Mn,
4274
+ filterTransfersByChannelKey: gu,
4275
+ releaseZ: jn,
4276
+ stateZ: Ae,
4277
+ subjectZ: Rn,
4278
+ transferZ: pu
4279
+ }, Symbol.toStringTag, { value: "Module" })), yu = (r) => Object.getOwnPropertySymbols(globalThis).includes(r), mu = (r, e) => {
4280
+ const t = Symbol.for(r);
4281
+ if (!yu(t)) {
4282
+ const n = e();
4283
+ Object.defineProperty(globalThis, t, { value: n });
4284
+ }
4285
+ return () => globalThis[t];
4286
+ }, wu = (r) => (e) => e != null && typeof e == "object" && "type" in e && typeof e.type == "string" ? e.type.startsWith(r) : e instanceof Error ? e.message.startsWith(r) : typeof e != "string" ? !1 : e.startsWith(r), ar = (r) => {
4287
+ var e;
4288
+ return e = class extends Error {
4289
+ constructor(t, n) {
4290
+ super(t, n), Q(this, "discriminator", e.discriminator), Q(this, "type", e.TYPE), Q(this, "matches", e.matches), this.name = e.TYPE;
4291
+ }
4292
+ static sub(t) {
4293
+ return ar(`${r}.${t}`);
4294
+ }
4295
+ }, Q(e, "discriminator", "FreighterError"), Q(e, "TYPE", r), Q(e, "matches", wu(r)), e;
4296
+ }, bu = (r) => {
4297
+ if (r == null || typeof r != "object") return !1;
4298
+ const e = r;
4299
+ if (e.discriminator !== "FreighterError") return !1;
4300
+ if (!("type" in e))
4301
+ throw new Error(
4302
+ `Freighter error is missing its type property: ${JSON.stringify(e)}`
4303
+ );
4304
+ return !0;
4305
+ }, ce = "unknown", Tr = "nil";
4306
+ class vu {
4307
+ constructor() {
4308
+ Q(this, "providers", []);
4309
+ }
4310
+ register(e) {
4311
+ this.providers.push(e);
4312
+ }
4313
+ encode(e) {
4314
+ if (e == null) return { type: Tr, data: "" };
4315
+ if (bu(e))
4316
+ for (const t of this.providers) {
4317
+ const n = t.encode(e);
4318
+ if (n != null) return n;
4319
+ }
4320
+ if (e instanceof Error) return { type: ce, data: e.message };
4321
+ if (typeof e == "string") return { type: ce, data: e };
4322
+ try {
4323
+ return { type: ce, data: JSON.stringify(e) };
4324
+ } catch {
4325
+ return { type: ce, data: "unable to encode error information" };
4326
+ }
4327
+ }
4328
+ decode(e) {
4329
+ if (e == null || e.type === Tr) return null;
4330
+ if (e.type === ce) return new Sr(e.data);
4331
+ for (const t of this.providers) {
4332
+ const n = t.decode(e);
4333
+ if (n != null) return n;
4334
+ }
4335
+ return new Sr(e.data);
4336
+ }
4337
+ }
4338
+ mu("synnax-error-registry", () => new vu());
4339
+ class Sr extends ar("unknown") {
4340
+ }
4341
+ a.object({ type: a.string(), data: a.string() });
4342
+ class vl extends ar("canceled") {
4343
+ }
4344
+ const $l = (r) => r ? -1 : 1;
4345
+ se.object({
4346
+ jsonrpc: se.string(),
4347
+ id: se.number().optional(),
4348
+ method: se.string().optional(),
4349
+ params: se.unknown().optional(),
4350
+ result: se.unknown().optional()
4351
+ });
4352
+ const Ct = a.string().regex(/^\d+\.\d+\.\d+$/), Re = (r, e, t = {}) => {
4353
+ t.checkMajor ?? (t.checkMajor = !0), t.checkMinor ?? (t.checkMinor = !0), t.checkPatch ?? (t.checkPatch = !0);
4354
+ const n = Ct.parse(r), s = Ct.parse(e), [i, o, u] = n.split(".").map(Number), [h, f, g] = s.split(".").map(Number);
4355
+ if (t.checkMajor) {
4356
+ if (i < h) return Ye;
4357
+ if (i > h) return Ze;
4358
+ }
4359
+ if (t.checkMinor) {
4360
+ if (o < f) return Ye;
4361
+ if (o > f) return Ze;
4362
+ }
4363
+ if (t.checkPatch) {
4364
+ if (u < g) return Ye;
4365
+ if (u > g) return Ze;
4366
+ }
4367
+ return ae;
4368
+ }, $u = (r, e, t = {}) => cn(Re(r, e, t)), Dn = (r, e, t = {}) => hn(Re(r, e, t)), xu = (r, e, t = {}) => ln(Re(r, e, t)), Ou = ({
4369
+ name: r,
4370
+ migrate: e
4371
+ }) => (t) => {
4372
+ try {
4373
+ const n = e(t);
4374
+ return console.log(`${r} migrated: ${t.version} -> ${n.version}`), n;
4375
+ } catch (n) {
4376
+ throw console.log(`${r} failed to migrate from ${t.version}`), console.error(n), n;
4377
+ }
4378
+ }, Tu = ({
4379
+ name: r,
4380
+ migrations: e,
4381
+ targetSchema: t,
4382
+ defaultVersion: n,
4383
+ def: s
4384
+ }) => {
4385
+ const i = Object.keys(e).sort(Re).pop();
4386
+ if (i == null)
4387
+ return (f) => {
4388
+ if (f.version ?? (f.version = n), f.version !== s.version)
4389
+ return console.log(
4390
+ `${r} version ${f.version} is newer than latest version of ${s.version}.
4391
+ Returning default instead.
4392
+ `
4393
+ ), s;
4394
+ try {
4395
+ return t != null ? t.parse(f) : f;
4396
+ } catch (g) {
4397
+ return console.log(`${r} failed to parse default. Exiting with default`), console.error(g), s;
4398
+ }
4399
+ };
4400
+ const o = Object.keys(e).length;
4401
+ let u = !1;
4402
+ const h = (f) => {
4403
+ try {
4404
+ if (o === 0 || Dn(f.version, i))
4405
+ return console.log(u ? `${r} ${f.version} now up to date` : `${r} version ${f.version} is up to date with target version ${s.version}`), f;
4406
+ const g = f.version, d = e[g], B = d(f);
4407
+ return u = !0, h(B);
4408
+ } catch (g) {
4409
+ return console.log(
4410
+ `${r} failed to migrate from ${f.version} to ${i}`
4411
+ ), console.error(g), s;
4412
+ }
4413
+ };
4414
+ return (f) => {
4415
+ try {
4416
+ if (f.version == null)
4417
+ if (n != null)
4418
+ console.log(
4419
+ `${r} version is null. Setting version to default of ${n}`
4420
+ ), f.version = n;
4421
+ else
4422
+ return console.log(
4423
+ `${r} version is null and no default version set. Exiting with default`
4424
+ ), s;
4425
+ return h(f);
4426
+ } catch (g) {
4427
+ return console.log(`${r} failed to parse final result. Exiting with default`), console.error(g), s;
4428
+ }
4429
+ };
4430
+ }, xl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4431
+ __proto__: null,
4432
+ compareSemVer: Re,
4433
+ createMigration: Ou,
4434
+ migrator: Tu,
4435
+ semVerNewer: Dn,
4436
+ semVerOlder: xu,
4437
+ semVerZ: Ct,
4438
+ versionsEqual: $u
4439
+ }, Symbol.toStringTag, { value: "Module" })), Pn = ["standard", "scientific", "engineering"], Su = a.enum(Pn), Iu = (r, e, t) => {
4440
+ if (Number.isNaN(r)) return "NaN";
4441
+ if (r === 1 / 0) return "∞";
4442
+ if (r === -1 / 0) return "-∞";
4443
+ if (t === "standard") return r.toFixed(e);
4444
+ if (r === 0)
4445
+ return e === 0 ? "0ᴇ0" : `0.${"0".repeat(e)}ᴇ0`;
4446
+ let n;
4447
+ return t === "scientific" ? n = Math.floor(Math.log10(Math.abs(r))) : n = Math.floor(Math.log10(Math.abs(r)) / 3) * 3, `${(r / 10 ** n).toFixed(e)}ᴇ${n}`;
4448
+ }, Ol = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4449
+ __proto__: null,
4450
+ NOTATIONS: Pn,
4451
+ notationZ: Su,
4452
+ stringifyNumber: Iu
4453
+ }, Symbol.toStringTag, { value: "Module" })), Tl = (r) => {
4454
+ if (r === void 0 || typeof r == "string" || typeof r == "number")
4455
+ return r;
4456
+ if (r.toString === void 0) throw new Error("invalid renderer");
4457
+ return r.toString();
4458
+ }, Sl = (r) => Array.isArray(r) ? [...r] : typeof r == "object" && r !== null ? { ...r } : r, Nu = new Error("request for lock canceled");
4459
+ var Uu = function(r, e, t, n) {
4460
+ function s(i) {
4461
+ return i instanceof t ? i : new t(function(o) {
4462
+ o(i);
4463
+ });
4464
+ }
4465
+ return new (t || (t = Promise))(function(i, o) {
4466
+ function u(g) {
4467
+ try {
4468
+ f(n.next(g));
4469
+ } catch (d) {
4470
+ o(d);
4471
+ }
4472
+ }
4473
+ function h(g) {
4474
+ try {
4475
+ f(n.throw(g));
4476
+ } catch (d) {
4477
+ o(d);
4478
+ }
4479
+ }
4480
+ function f(g) {
4481
+ g.done ? i(g.value) : s(g.value).then(u, h);
4482
+ }
4483
+ f((n = n.apply(r, e || [])).next());
4484
+ });
4485
+ };
4486
+ class Bu {
4487
+ constructor(e, t = Nu) {
4488
+ this._value = e, this._cancelError = t, this._queue = [], this._weightedWaiters = [];
4489
+ }
4490
+ acquire(e = 1, t = 0) {
4491
+ if (e <= 0)
4492
+ throw new Error(`invalid weight ${e}: must be positive`);
4493
+ return new Promise((n, s) => {
4494
+ const i = { resolve: n, reject: s, weight: e, priority: t }, o = zn(this._queue, (u) => t <= u.priority);
4495
+ o === -1 && e <= this._value ? this._dispatchItem(i) : this._queue.splice(o + 1, 0, i);
4496
+ });
4497
+ }
4498
+ runExclusive(e) {
4499
+ return Uu(this, arguments, void 0, function* (t, n = 1, s = 0) {
4500
+ const [i, o] = yield this.acquire(n, s);
4501
+ try {
4502
+ return yield t(i);
4503
+ } finally {
4504
+ o();
4505
+ }
4506
+ });
4507
+ }
4508
+ waitForUnlock(e = 1, t = 0) {
4509
+ if (e <= 0)
4510
+ throw new Error(`invalid weight ${e}: must be positive`);
4511
+ return this._couldLockImmediately(e, t) ? Promise.resolve() : new Promise((n) => {
4512
+ this._weightedWaiters[e - 1] || (this._weightedWaiters[e - 1] = []), Eu(this._weightedWaiters[e - 1], { resolve: n, priority: t });
4513
+ });
4514
+ }
4515
+ isLocked() {
4516
+ return this._value <= 0;
4517
+ }
4518
+ getValue() {
4519
+ return this._value;
4520
+ }
4521
+ setValue(e) {
4522
+ this._value = e, this._dispatchQueue();
4523
+ }
4524
+ release(e = 1) {
4525
+ if (e <= 0)
4526
+ throw new Error(`invalid weight ${e}: must be positive`);
4527
+ this._value += e, this._dispatchQueue();
4528
+ }
4529
+ cancel() {
4530
+ this._queue.forEach((e) => e.reject(this._cancelError)), this._queue = [];
4531
+ }
4532
+ _dispatchQueue() {
4533
+ for (this._drainUnlockWaiters(); this._queue.length > 0 && this._queue[0].weight <= this._value; )
4534
+ this._dispatchItem(this._queue.shift()), this._drainUnlockWaiters();
4535
+ }
4536
+ _dispatchItem(e) {
4537
+ const t = this._value;
4538
+ this._value -= e.weight, e.resolve([t, this._newReleaser(e.weight)]);
4539
+ }
4540
+ _newReleaser(e) {
4541
+ let t = !1;
4542
+ return () => {
4543
+ t || (t = !0, this.release(e));
4544
+ };
4545
+ }
4546
+ _drainUnlockWaiters() {
4547
+ if (this._queue.length === 0)
4548
+ for (let e = this._value; e > 0; e--) {
4549
+ const t = this._weightedWaiters[e - 1];
4550
+ t && (t.forEach((n) => n.resolve()), this._weightedWaiters[e - 1] = []);
4551
+ }
4552
+ else {
4553
+ const e = this._queue[0].priority;
4554
+ for (let t = this._value; t > 0; t--) {
4555
+ const n = this._weightedWaiters[t - 1];
4556
+ if (!n)
4557
+ continue;
4558
+ const s = n.findIndex((i) => i.priority <= e);
4559
+ (s === -1 ? n : n.splice(0, s)).forEach((i) => i.resolve());
4560
+ }
4561
+ }
4562
+ }
4563
+ _couldLockImmediately(e, t) {
4564
+ return (this._queue.length === 0 || this._queue[0].priority < t) && e <= this._value;
4565
+ }
4566
+ }
4567
+ function Eu(r, e) {
4568
+ const t = zn(r, (n) => e.priority <= n.priority);
4569
+ r.splice(t + 1, 0, e);
4570
+ }
4571
+ function zn(r, e) {
4572
+ for (let t = r.length - 1; t >= 0; t--)
4573
+ if (e(r[t]))
4574
+ return t;
4575
+ return -1;
4576
+ }
4577
+ var Au = function(r, e, t, n) {
4578
+ function s(i) {
4579
+ return i instanceof t ? i : new t(function(o) {
4580
+ o(i);
4581
+ });
4582
+ }
4583
+ return new (t || (t = Promise))(function(i, o) {
4584
+ function u(g) {
4585
+ try {
4586
+ f(n.next(g));
4587
+ } catch (d) {
4588
+ o(d);
4589
+ }
4590
+ }
4591
+ function h(g) {
4592
+ try {
4593
+ f(n.throw(g));
4594
+ } catch (d) {
4595
+ o(d);
4596
+ }
4597
+ }
4598
+ function f(g) {
4599
+ g.done ? i(g.value) : s(g.value).then(u, h);
4600
+ }
4601
+ f((n = n.apply(r, e || [])).next());
4602
+ });
4603
+ };
4604
+ class Mu {
4605
+ constructor(e) {
4606
+ this._semaphore = new Bu(1, e);
4607
+ }
4608
+ acquire() {
4609
+ return Au(this, arguments, void 0, function* (e = 0) {
4610
+ const [, t] = yield this._semaphore.acquire(1, e);
4611
+ return t;
4612
+ });
4613
+ }
4614
+ runExclusive(e, t = 0) {
4615
+ return this._semaphore.runExclusive(() => e(), 1, t);
4616
+ }
4617
+ isLocked() {
4618
+ return this._semaphore.isLocked();
4619
+ }
4620
+ waitForUnlock(e = 0) {
4621
+ return this._semaphore.waitForUnlock(1, e);
4622
+ }
4623
+ release() {
4624
+ this._semaphore.isLocked() && this._semaphore.release();
4625
+ }
4626
+ cancel() {
4627
+ return this._semaphore.cancel();
4628
+ }
4629
+ }
4630
+ class ot extends Mu {
4631
+ static new(e) {
4632
+ return new ot(e);
4633
+ }
4634
+ constructor(e) {
4635
+ super(), Object.assign(this, e);
4636
+ }
4637
+ }
4638
+ const Cu = (r) => new ot(r), Il = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4639
+ __proto__: null,
4640
+ mutex: ot,
4641
+ newMutex: Cu
4642
+ }, Symbol.toStringTag, { value: "Module" }));
4643
+ class Lu {
4644
+ constructor(e = "") {
4645
+ je(this, "rows", []);
4646
+ je(this, "columns", []);
4647
+ je(this, "prefix");
4648
+ this.prefix = e;
4649
+ }
4650
+ row(e, t, n) {
4651
+ const { prefix: s } = this;
4652
+ return this.rows.push({ startLabel: s + e, endLabel: s + t, size: n }), this;
4653
+ }
4654
+ col(e, t, n) {
4655
+ const { prefix: s } = this;
4656
+ return this.columns.push({ startLabel: s + e, endLabel: s + t, size: n }), this;
4657
+ }
4658
+ build() {
4659
+ return {
4660
+ display: "grid",
4661
+ gridTemplateRows: this.rows.map((e, t) => {
4662
+ let n = t === 0 ? "[" : "";
4663
+ return n += `${e.startLabel}] ${e.size}${typeof e.size == "number" ? "px" : ""} [${e.endLabel}`, n += t === this.rows.length - 1 ? "]" : "", n;
4664
+ }).join(" "),
4665
+ gridTemplateColumns: this.columns.map((e, t) => {
4666
+ let n = t === 0 ? "[" : "";
4667
+ return n += `${e.startLabel}] ${e.size}${typeof e.size == "number" ? "px" : ""} [${e.endLabel}`, n += t === this.columns.length - 1 ? "]" : "", n;
4668
+ }).join(" ")
4669
+ };
4670
+ }
4671
+ }
4672
+ const Ru = (r, e) => Object.entries(e).forEach(
4673
+ ([t, n]) => n != null && r.style.setProperty(t, `${n}`)
4674
+ ), ju = (r, e) => Array.from(r.style).forEach((t) => {
4675
+ t.startsWith(e) && r.style.removeProperty(t);
4676
+ }), ku = (r) => {
4677
+ const e = Jr(r);
4678
+ return e.visible = (t) => e.M(t ? "visible" : "hidden"), e.expanded = (t) => e.M(t ? "expanded" : "collapsed"), e.loc = (t) => e.M(Fs.construct(t)), e.disabled = (t) => t === !0 && e.M("disabled"), e.align = (t) => e.M(t), e.dir = (t) => t != null && e.M($s.construct(t)), e.size = (t) => typeof t == "string" && e.M(t), e.sharp = (t) => t !== !1 && e.M("sharp"), e.rounded = (t) => t !== !1 && e.M("rounded"), e.bordered = (t) => typeof t == "boolean" ? t && e.M("bordered") : t != null ? e.M(`bordered-${t.toString()}`) : e.M("bordered"), e.selected = (t) => t && e.M("selected"), e.altColor = (t) => t && e.M("alt-color"), e.editable = (t) => t && e.M("editable"), e.noSelect = e.M("no-select"), e.noWrap = (t) => t && e.M("no-wrap"), e.applyVars = Ru, e.removeVars = ju, e.newGridBuilder = (t) => new Lu(t), e.dropRegion = (t) => t && e.B("haul-drop-region"), e.px = (t) => `${t}px`, e.inheritDims = (t = !0) => t && e.M("inherit-dims"), e.shade = (t) => t != null && e.M(`shade-${t}`), e.shadeVar = (t) => {
4679
+ if (t != null)
4680
+ return `var(--${r}-gray-l${t})`;
4681
+ }, e.levelSizeVar = (t) => `var(--${r}-${t}-size)`, e;
4682
+ }, Nl = ku("pluto");
4683
+ export {
4684
+ qu as $,
4685
+ Gi as A,
4686
+ Kt as B,
4687
+ Nl as C,
4688
+ ks as D,
4689
+ Ti as E,
4690
+ el as F,
4691
+ Sl as G,
4692
+ Fu as H,
4693
+ zu as I,
4694
+ _u as J,
4695
+ Fs as K,
4696
+ tl as L,
4697
+ Ii as M,
4698
+ ol as N,
4699
+ O,
4700
+ Cs as P,
4701
+ re as Q,
4702
+ Qu as R,
4703
+ pl as S,
4704
+ Ce as T,
4705
+ w as U,
4706
+ nl as V,
4707
+ dr as W,
4708
+ ta as X,
4709
+ Tl as Y,
4710
+ Ol as Z,
4711
+ Wu as _,
4712
+ fl as a,
4713
+ Ke as a0,
4714
+ ml as a1,
4715
+ Il as a2,
4716
+ Pi as a3,
4717
+ bl as a4,
4718
+ xl as a5,
4719
+ yl as a6,
4720
+ A as a7,
4721
+ Xu as b,
4722
+ wn as c,
4723
+ gl as d,
4724
+ js as e,
4725
+ ll as f,
4726
+ $s as g,
4727
+ hl as h,
4728
+ zt as i,
4729
+ S as j,
4730
+ F as k,
4731
+ G as l,
4732
+ x as m,
4733
+ Jr as n,
4734
+ tr as o,
4735
+ cl as p,
4736
+ H as q,
4737
+ Oi as r,
4738
+ Vu as s,
4739
+ J as t,
4740
+ oa as u,
4741
+ $l as v,
4742
+ Rs as w,
4743
+ Vt as x,
4744
+ dl as y,
4745
+ wl as z
4746
+ };