@synnaxlabs/pluto 0.24.0 → 0.25.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 (457) hide show
  1. package/dist/{Animated-DGp8qHGT.js → Animated-BpuQZROI.js} +3 -3
  2. package/dist/{Animated-Cbt7tqBk.cjs → Animated-DqAjXT8r.cjs} +1 -1
  3. package/dist/{Keyboard-HZ6Llqo5.js → Keyboard-BTyEk3pg.js} +3 -3
  4. package/dist/{Keyboard-BjnOIJ5V.cjs → Keyboard-GDYsV4-x.cjs} +1 -1
  5. package/dist/{LinePlot-Dw8vQLJw.js → LinePlot-CQAK-dkX.js} +4133 -3935
  6. package/dist/LinePlot-DnLLplw_.cjs +66 -0
  7. package/dist/{Link-j-xpQ9HD.js → Link-BrhOiMiE.js} +2 -2
  8. package/dist/Link-CpMcH9c1.cjs +1 -0
  9. package/dist/List-BS57aL1n.js +22 -0
  10. package/dist/{List-BX3MLMNz.cjs → List-Dux7qweq.cjs} +1 -1
  11. package/dist/{Pack-B5JX1aqf.js → Pack-CCCsIeot.js} +2 -2
  12. package/dist/{Pack-D93gFUU9.cjs → Pack-_i2cfPYc.cjs} +1 -1
  13. package/dist/{Toggle-Cq3FTFfq.js → Toggle-CpLFBHo7.js} +16471 -16522
  14. package/dist/Toggle-DlNzb7nt.cjs +143 -0
  15. package/dist/{Video-DIIo17du.js → Video-Bi9kFIHV.js} +2 -2
  16. package/dist/{Video-D382cbrn.cjs → Video-THwAEuOy.cjs} +1 -1
  17. package/dist/{aggregator-BIhLPgXc.js → aggregator-CoD5WrqU.js} +3687 -4501
  18. package/dist/aggregator-D47lwtdn.cjs +51 -0
  19. package/dist/align.cjs +1 -1
  20. package/dist/align.js +1 -1
  21. package/dist/button.cjs +1 -1
  22. package/dist/button.js +1 -1
  23. package/dist/color.cjs +1 -1
  24. package/dist/color.js +1 -1
  25. package/dist/css-CC1MhhH7.cjs +1 -0
  26. package/dist/css-Ce6IGevn.js +1042 -0
  27. package/dist/css.cjs +1 -1
  28. package/dist/css.js +2 -2
  29. package/dist/dropdown.cjs +1 -1
  30. package/dist/dropdown.js +1 -1
  31. package/dist/ether.cjs +1 -1
  32. package/dist/ether.js +9 -9
  33. package/dist/{external-DUeGQ4si.cjs → external-B7RXnD0a.cjs} +1 -1
  34. package/dist/{external-IpylADnr.cjs → external-B815mDB0.cjs} +1 -1
  35. package/dist/{external-DVg6hQ24.js → external-BxBMVx6g.js} +13 -14
  36. package/dist/{external-CZiW7AR4.js → external-C6v1z0ty.js} +24 -38
  37. package/dist/{external-CDZA7f7F.js → external-C8CIAjMj.js} +2 -2
  38. package/dist/external-CLwP0eXe.cjs +1 -0
  39. package/dist/{external-CFqe6ymi.cjs → external-CMk1k986.cjs} +1 -1
  40. package/dist/{external-DKxxR-uc.cjs → external-CUJXIrxM.cjs} +1 -1
  41. package/dist/{external-lDVnD7Yi.js → external-CXrgzQf5.js} +2 -2
  42. package/dist/external-Cv5GChi6.js +344 -0
  43. package/dist/{external-B5j7Ee09.cjs → external-DMYExlt2.cjs} +1 -1
  44. package/dist/{external-C3TJ5wKl.js → external-DQ4EhNBA.js} +12 -12
  45. package/dist/{external-CjjdhnS5.cjs → external-DRvtVPhp.cjs} +1 -1
  46. package/dist/{external-RIKGjo5R.js → external-DShO9063.js} +4 -4
  47. package/dist/external-DU5Xqqld.cjs +1 -0
  48. package/dist/{external-DvFgLm4v.js → external-D_WKlwCh.js} +42 -33
  49. package/dist/{external-CD2dFTTj.cjs → external-DjSiwSCE.cjs} +1 -1
  50. package/dist/{external-D9eq1UnF.cjs → external-Dm3eiIEN.cjs} +1 -1
  51. package/dist/external-Do75w1Zt.cjs +1 -0
  52. package/dist/{external-BCyTR9bj.cjs → external-DqnUE4mV.cjs} +1 -1
  53. package/dist/external-DyTzmzSc.js +93 -0
  54. package/dist/{external-B4-opRnY.js → external-NHkWeW29.js} +1 -1
  55. package/dist/{external-D6mqXF0b.js → external-NeMo53nv.js} +18 -19
  56. package/dist/{external-BJI4w1QU.js → external-e0OPlFyY.js} +5 -5
  57. package/dist/header.cjs +1 -1
  58. package/dist/header.js +1 -1
  59. package/dist/index.cjs +1 -1
  60. package/dist/index.js +4805 -4318
  61. package/dist/input.cjs +1 -1
  62. package/dist/input.js +1 -1
  63. package/dist/{jsx-runtime-DqxPLdyS.js → jsx-runtime-B6kdoens.js} +225 -214
  64. package/dist/jsx-runtime-Cek9Ww4S.cjs +30 -0
  65. package/dist/list.cjs +1 -1
  66. package/dist/list.js +1 -1
  67. package/dist/menu.cjs +1 -1
  68. package/dist/menu.js +1 -1
  69. package/dist/src/accordion/Accordion.d.ts +2 -2
  70. package/dist/src/aether/aether/aether.d.ts +5 -5
  71. package/dist/src/aether/main.d.ts +4 -4
  72. package/dist/src/aether/main.d.ts.map +1 -1
  73. package/dist/src/aether/test/test.d.ts +1 -1
  74. package/dist/src/aether/test/test.d.ts.map +1 -1
  75. package/dist/src/alamos/Provider.d.ts +3 -3
  76. package/dist/src/alamos/aether/alamos.d.ts +2 -2
  77. package/dist/src/alamos/aether/alamos.d.ts.map +1 -1
  78. package/dist/src/align/Center.d.ts +1 -1
  79. package/dist/src/align/Center.d.ts.map +1 -1
  80. package/dist/src/align/Pack.d.ts +1 -1
  81. package/dist/src/align/Pack.d.ts.map +1 -1
  82. package/dist/src/align/Space.d.ts +3 -3
  83. package/dist/src/align/Space.d.ts.map +1 -1
  84. package/dist/src/button/Button.d.ts +13 -11
  85. package/dist/src/button/Button.d.ts.map +1 -1
  86. package/dist/src/button/Icon.d.ts +2 -2
  87. package/dist/src/button/Link.d.ts +3 -3
  88. package/dist/src/button/Link.d.ts.map +1 -1
  89. package/dist/src/button/Toggle.d.ts +8 -8
  90. package/dist/src/button/color.d.ts +2 -2
  91. package/dist/src/button/color.d.ts.map +1 -1
  92. package/dist/src/channel/AliasProvider.d.ts +2 -2
  93. package/dist/src/channel/AliasProvider.d.ts.map +1 -1
  94. package/dist/src/channel/LinePlot.d.ts +8 -8
  95. package/dist/src/channel/Select.d.ts +2 -2
  96. package/dist/src/color/Picker/Picker.d.ts +2 -2
  97. package/dist/src/color/Swatch/Swatch.d.ts +4 -4
  98. package/dist/src/color/core/color.d.ts +7 -0
  99. package/dist/src/color/core/color.d.ts.map +1 -1
  100. package/dist/src/css/color.d.ts.map +1 -1
  101. package/dist/src/css/css.d.ts +4 -4
  102. package/dist/src/css/css.d.ts.map +1 -1
  103. package/dist/src/css/vars.d.ts.map +1 -1
  104. package/dist/src/dialog/use.d.ts.map +1 -1
  105. package/dist/src/divider/Divider.d.ts +1 -1
  106. package/dist/src/dropdown/Dropdown.d.ts +5 -5
  107. package/dist/src/dropdown/Dropdown.d.ts.map +1 -1
  108. package/dist/src/form/Field.d.ts +7 -7
  109. package/dist/src/form/Field.d.ts.map +1 -1
  110. package/dist/src/form/Form.d.ts +7 -7
  111. package/dist/src/form/Form.d.ts.map +1 -1
  112. package/dist/src/generic/Generic.d.ts +1 -1
  113. package/dist/src/generic/Generic.d.ts.map +1 -1
  114. package/dist/src/hardware/device/Select.d.ts +2 -2
  115. package/dist/src/haul/Haul.d.ts +20 -16
  116. package/dist/src/haul/Haul.d.ts.map +1 -1
  117. package/dist/src/header/Actions.d.ts +1 -1
  118. package/dist/src/header/ButtonTitle.d.ts +1 -1
  119. package/dist/src/header/Header.d.ts +2 -2
  120. package/dist/src/header/Title.d.ts +1 -1
  121. package/dist/src/hooks/effect.d.ts.map +1 -1
  122. package/dist/src/hooks/ref.d.ts +3 -3
  123. package/dist/src/hooks/ref.d.ts.map +1 -1
  124. package/dist/src/hooks/useCursorDrag/types.d.ts +1 -1
  125. package/dist/src/hooks/useCursorDrag/useCursorDrag.d.ts +2 -2
  126. package/dist/src/hooks/useDebouncedCallback.d.ts.map +1 -1
  127. package/dist/src/hooks/useFilter.d.ts +1 -1
  128. package/dist/src/hooks/useFilter.d.ts.map +1 -1
  129. package/dist/src/hooks/useRequiredContext.d.ts.map +1 -1
  130. package/dist/src/hooks/useResize.d.ts +1 -1
  131. package/dist/src/hooks/useResize.d.ts.map +1 -1
  132. package/dist/src/hooks/useTransforms.d.ts.map +1 -1
  133. package/dist/src/hooks/useUniqueKey.d.ts.map +1 -1
  134. package/dist/src/icon/Icon.d.ts +14 -0
  135. package/dist/src/icon/Icon.d.ts.map +1 -0
  136. package/dist/src/icon/index.d.ts +2 -0
  137. package/dist/src/icon/index.d.ts.map +1 -0
  138. package/dist/src/index.d.ts +2 -0
  139. package/dist/src/index.d.ts.map +1 -1
  140. package/dist/src/input/Date.d.ts +1 -1
  141. package/dist/src/input/Date.d.ts.map +1 -1
  142. package/dist/src/input/DateTime.d.ts +1 -1
  143. package/dist/src/input/DragButton.d.ts +3 -3
  144. package/dist/src/input/HelpText.d.ts +2 -2
  145. package/dist/src/input/Item.d.ts +2 -2
  146. package/dist/src/input/Numeric.d.ts +3 -3
  147. package/dist/src/input/Numeric.d.ts.map +1 -1
  148. package/dist/src/input/Switch.d.ts.map +1 -1
  149. package/dist/src/input/Text.d.ts +1 -1
  150. package/dist/src/input/Text.d.ts.map +1 -1
  151. package/dist/src/input/TextArea.d.ts +1 -1
  152. package/dist/src/input/Time.d.ts +2 -2
  153. package/dist/src/input/Time.d.ts.map +1 -1
  154. package/dist/src/input/types.d.ts +2 -2
  155. package/dist/src/list/Column.d.ts +6 -6
  156. package/dist/src/list/Column.d.ts.map +1 -1
  157. package/dist/src/list/Core.d.ts +4 -4
  158. package/dist/src/list/Core.d.ts.map +1 -1
  159. package/dist/src/list/Data.d.ts +5 -3
  160. package/dist/src/list/Data.d.ts.map +1 -1
  161. package/dist/src/list/Filter.d.ts +4 -4
  162. package/dist/src/list/Filter.d.ts.map +1 -1
  163. package/dist/src/list/Hover.d.ts +1 -1
  164. package/dist/src/list/Hover.d.ts.map +1 -1
  165. package/dist/src/list/Item.d.ts +3 -3
  166. package/dist/src/list/Item.d.ts.map +1 -1
  167. package/dist/src/list/List.d.ts +1 -1
  168. package/dist/src/list/List.d.ts.map +1 -1
  169. package/dist/src/list/Search.d.ts +3 -3
  170. package/dist/src/list/Search.d.ts.map +1 -1
  171. package/dist/src/list/Selector.d.ts +2 -2
  172. package/dist/src/list/Selector.d.ts.map +1 -1
  173. package/dist/src/list/types.d.ts.map +1 -1
  174. package/dist/src/list/useSelect.d.ts +1 -1
  175. package/dist/src/list/useSelect.d.ts.map +1 -1
  176. package/dist/src/memo/useMemoCompare.d.ts +1 -1
  177. package/dist/src/memo/useMemoCompare.d.ts.map +1 -1
  178. package/dist/src/menu/ContextMenu.d.ts +2 -2
  179. package/dist/src/menu/Item.d.ts +7 -7
  180. package/dist/src/menu/Item.d.ts.map +1 -1
  181. package/dist/src/menu/Menu.d.ts +2 -2
  182. package/dist/src/mock/MockGLBufferController.d.ts +1 -1
  183. package/dist/src/modal/Modal.d.ts +3 -3
  184. package/dist/src/modal/Modal.d.ts.map +1 -1
  185. package/dist/src/mosaic/Mosaic.d.ts +5 -4
  186. package/dist/src/mosaic/Mosaic.d.ts.map +1 -1
  187. package/dist/src/mosaic/tree.d.ts +2 -2
  188. package/dist/src/mosaic/tree.d.ts.map +1 -1
  189. package/dist/src/mosaic/types.d.ts +2 -2
  190. package/dist/src/mosaic/use.d.ts +1 -1
  191. package/dist/src/nav/Bar.d.ts +2 -2
  192. package/dist/src/nav/Bar.d.ts.map +1 -1
  193. package/dist/src/nav/Drawer.d.ts +3 -3
  194. package/dist/src/note/Note.d.ts +1 -1
  195. package/dist/src/note/Note.d.ts.map +1 -1
  196. package/dist/src/observe/use.d.ts.map +1 -1
  197. package/dist/src/os/Controls/Controls.d.ts +2 -2
  198. package/dist/src/os/Controls/Mac.d.ts +1 -1
  199. package/dist/src/os/Controls/Windows.d.ts +1 -1
  200. package/dist/src/os/Controls/types.d.ts +1 -1
  201. package/dist/src/os/use.d.ts.map +1 -1
  202. package/dist/src/pluto/Pluto.d.ts +8 -8
  203. package/dist/src/portal/Portal.d.ts +0 -1
  204. package/dist/src/portal/Portal.d.ts.map +1 -1
  205. package/dist/src/ranger/SelectLabel.d.ts +2 -2
  206. package/dist/src/ranger/TimeRangeChip.d.ts +2 -2
  207. package/dist/src/resize/Core.d.ts +1 -1
  208. package/dist/src/resize/Multiple.d.ts +2 -2
  209. package/dist/src/resize/Single.d.ts +2 -2
  210. package/dist/src/select/Button.d.ts +8 -8
  211. package/dist/src/select/Button.d.ts.map +1 -1
  212. package/dist/src/select/ClearButton.d.ts +1 -1
  213. package/dist/src/select/ClearButton.d.ts.map +1 -1
  214. package/dist/src/select/DataType.d.ts +1 -1
  215. package/dist/src/select/DataType.d.ts.map +1 -1
  216. package/dist/src/select/Direction.d.ts +2 -2
  217. package/dist/src/select/List.d.ts +3 -3
  218. package/dist/src/select/List.d.ts.map +1 -1
  219. package/dist/src/select/Multiple.d.ts +7 -7
  220. package/dist/src/select/Multiple.d.ts.map +1 -1
  221. package/dist/src/select/Single.d.ts +5 -5
  222. package/dist/src/select/Single.d.ts.map +1 -1
  223. package/dist/src/state/state.d.ts +1 -1
  224. package/dist/src/state/state.d.ts.map +1 -1
  225. package/dist/src/status/Aggregator.d.ts +4 -4
  226. package/dist/src/status/Circle.d.ts +2 -2
  227. package/dist/src/status/Notification.d.ts +3 -3
  228. package/dist/src/status/Text.d.ts +2 -2
  229. package/dist/src/status/Text.d.ts.map +1 -1
  230. package/dist/src/status/aether/aggregator.d.ts +3 -3
  231. package/dist/src/status/aether/aggregator.d.ts.map +1 -1
  232. package/dist/src/status/aether/types.d.ts +1 -1
  233. package/dist/src/steps/Steps.d.ts +2 -2
  234. package/dist/src/synnax/Provider.d.ts +2 -2
  235. package/dist/src/synnax/Provider.d.ts.map +1 -1
  236. package/dist/src/synnax/aether/provider.d.ts +14 -14
  237. package/dist/src/synnax/aether/provider.d.ts.map +1 -1
  238. package/dist/src/tabs/Selector.d.ts +3 -3
  239. package/dist/src/tabs/Tabs.d.ts +3 -3
  240. package/dist/src/tabs/types.d.ts +2 -2
  241. package/dist/src/tag/Tag.d.ts +3 -3
  242. package/dist/src/telem/Provider.d.ts +1 -1
  243. package/dist/src/telem/aether/context.d.ts +4 -4
  244. package/dist/src/telem/aether/context.d.ts.map +1 -1
  245. package/dist/src/telem/aether/factory.d.ts +1 -1
  246. package/dist/src/telem/aether/factory.d.ts.map +1 -1
  247. package/dist/src/telem/aether/noop.d.ts +1 -1
  248. package/dist/src/telem/aether/pipeline.d.ts +3 -3
  249. package/dist/src/telem/aether/pipeline.d.ts.map +1 -1
  250. package/dist/src/telem/aether/provider.d.ts +6 -6
  251. package/dist/src/telem/aether/remote.d.ts +3 -3
  252. package/dist/src/telem/aether/remote.d.ts.map +1 -1
  253. package/dist/src/telem/aether/static.d.ts +3 -3
  254. package/dist/src/telem/aether/telem.d.ts +3 -3
  255. package/dist/src/telem/aether/transformers.d.ts +3 -3
  256. package/dist/src/telem/aether/transformers.d.ts.map +1 -1
  257. package/dist/src/telem/client/cache/cache.d.ts +3 -3
  258. package/dist/src/telem/client/cache/static.d.ts +1 -1
  259. package/dist/src/telem/client/cache/unary.d.ts +3 -3
  260. package/dist/src/telem/client/client.d.ts +4 -5
  261. package/dist/src/telem/client/client.d.ts.map +1 -1
  262. package/dist/src/telem/client/reader.d.ts +4 -4
  263. package/dist/src/telem/client/streamer.d.ts +4 -4
  264. package/dist/src/telem/client/types.d.ts +1 -1
  265. package/dist/src/telem/control/Chip.d.ts +3 -3
  266. package/dist/src/telem/control/Chip.d.ts.map +1 -1
  267. package/dist/src/telem/control/Controller.d.ts +4 -4
  268. package/dist/src/telem/control/Indicator.d.ts +3 -3
  269. package/dist/src/telem/control/Legend.d.ts +1 -1
  270. package/dist/src/telem/control/Legend.d.ts.map +1 -1
  271. package/dist/src/telem/control/StateProvider.d.ts +3 -3
  272. package/dist/src/telem/control/aether/chip.d.ts +3 -3
  273. package/dist/src/telem/control/aether/controller.d.ts +8 -8
  274. package/dist/src/telem/control/aether/controller.d.ts.map +1 -1
  275. package/dist/src/telem/control/aether/indicator.d.ts +3 -3
  276. package/dist/src/telem/control/aether/legend.d.ts +3 -3
  277. package/dist/src/telem/control/aether/state.d.ts +5 -5
  278. package/dist/src/telem/test/mock.d.ts +2 -2
  279. package/dist/src/testutil/dom.d.ts.map +1 -1
  280. package/dist/src/text/DateTime.d.ts +5 -5
  281. package/dist/src/text/DateTime.d.ts.map +1 -1
  282. package/dist/src/text/Editable.d.ts +7 -10
  283. package/dist/src/text/Editable.d.ts.map +1 -1
  284. package/dist/src/text/Keyboard.d.ts +3 -3
  285. package/dist/src/text/Keyboard.d.ts.map +1 -1
  286. package/dist/src/text/Link.d.ts +3 -3
  287. package/dist/src/text/Link.d.ts.map +1 -1
  288. package/dist/src/text/SelectLevel.d.ts +2 -2
  289. package/dist/src/text/Text.d.ts +4 -4
  290. package/dist/src/text/Text.d.ts.map +1 -1
  291. package/dist/src/text/WithIcon.d.ts +5 -5
  292. package/dist/src/text/WithIcon.d.ts.map +1 -1
  293. package/dist/src/text/core/types.d.ts +1 -1
  294. package/dist/src/text/dimensions.d.ts.map +1 -1
  295. package/dist/src/theming/Provider.d.ts +4 -4
  296. package/dist/src/theming/Provider.d.ts.map +1 -1
  297. package/dist/src/theming/aether/provider.d.ts +2 -2
  298. package/dist/src/theming/aether/provider.d.ts.map +1 -1
  299. package/dist/src/theming/core/fontString.d.ts +2 -2
  300. package/dist/src/theming/core/fontString.d.ts.map +1 -1
  301. package/dist/src/theming/core/theme.d.ts +1 -1
  302. package/dist/src/theming/css.d.ts.map +1 -1
  303. package/dist/src/theming/font.d.ts.map +1 -1
  304. package/dist/src/tooltip/Config.d.ts +1 -1
  305. package/dist/src/tooltip/Dialog.d.ts +2 -2
  306. package/dist/src/tooltip/Dialog.d.ts.map +1 -1
  307. package/dist/src/tooltip/wrap.d.ts +1 -1
  308. package/dist/src/tooltip/wrap.d.ts.map +1 -1
  309. package/dist/src/tree/Tree.d.ts +14 -14
  310. package/dist/src/tree/Tree.d.ts.map +1 -1
  311. package/dist/src/tree/core.d.ts +1 -1
  312. package/dist/src/triggers/Provider.d.ts +2 -2
  313. package/dist/src/triggers/Status.d.ts +1 -1
  314. package/dist/src/triggers/Text.d.ts +4 -4
  315. package/dist/src/triggers/Text.d.ts.map +1 -1
  316. package/dist/src/triggers/hooks.d.ts +3 -3
  317. package/dist/src/triggers/hooks.d.ts.map +1 -1
  318. package/dist/src/triggers/triggers.d.ts +2 -2
  319. package/dist/src/triggers/triggers.d.ts.map +1 -1
  320. package/dist/src/triggers/useDrag.d.ts +2 -2
  321. package/dist/src/util/children.d.ts +2 -2
  322. package/dist/src/util/children.d.ts.map +1 -1
  323. package/dist/src/util/component.d.ts +1 -1
  324. package/dist/src/util/component.d.ts.map +1 -1
  325. package/dist/src/util/renderProp.d.ts +1 -1
  326. package/dist/src/util/renderProp.d.ts.map +1 -1
  327. package/dist/src/util/zod.d.ts.map +1 -1
  328. package/dist/src/viewport/Mask.d.ts.map +1 -1
  329. package/dist/src/viewport/SelectMode.d.ts +2 -2
  330. package/dist/src/viewport/use.d.ts +3 -3
  331. package/dist/src/vis/axis/axis.d.ts +3 -3
  332. package/dist/src/vis/axis/canvas.d.ts +2 -2
  333. package/dist/src/vis/axis/ticks.d.ts +1 -1
  334. package/dist/src/vis/button/aether/button.d.ts +2 -2
  335. package/dist/src/vis/button/use.d.ts +1 -1
  336. package/dist/src/vis/canvas/Canvas.d.ts +2 -2
  337. package/dist/src/vis/canvas/Canvas.d.ts.map +1 -1
  338. package/dist/src/vis/canvas/aether/canvas.d.ts +25 -25
  339. package/dist/src/vis/diagram/Diagram.d.ts +6 -6
  340. package/dist/src/vis/diagram/Diagram.d.ts.map +1 -1
  341. package/dist/src/vis/diagram/aether/Diagram.d.ts +41 -41
  342. package/dist/src/vis/diagram/aether/Diagram.d.ts.map +1 -1
  343. package/dist/src/vis/diagram/aether/types.d.ts +331 -0
  344. package/dist/src/vis/diagram/aether/types.d.ts.map +1 -0
  345. package/dist/src/vis/diagram/align.d.ts +1 -1
  346. package/dist/src/vis/diagram/align.d.ts.map +1 -1
  347. package/dist/src/vis/diagram/edge/Edge.d.ts +4 -4
  348. package/dist/src/vis/diagram/edge/Edge.d.ts.map +1 -1
  349. package/dist/src/vis/diagram/edge/connector/connector.d.ts +12 -4
  350. package/dist/src/vis/diagram/edge/connector/connector.d.ts.map +1 -1
  351. package/dist/src/vis/diagram/external.d.ts +1 -1
  352. package/dist/src/vis/diagram/external.d.ts.map +1 -1
  353. package/dist/src/vis/diagram/util.d.ts +1 -1
  354. package/dist/src/vis/diagram/util.d.ts.map +1 -1
  355. package/dist/src/vis/draw2d/index.d.ts +4 -4
  356. package/dist/src/vis/eraser/aether/eraser.d.ts +26 -26
  357. package/dist/src/vis/eraser/use.d.ts +2 -2
  358. package/dist/src/vis/legend/Container.d.ts +20 -20
  359. package/dist/src/vis/legend/Container.d.ts.map +1 -1
  360. package/dist/src/vis/legend/Simple.d.ts +2 -2
  361. package/dist/src/vis/line/Line.d.ts +2 -2
  362. package/dist/src/vis/line/Line.d.ts.map +1 -1
  363. package/dist/src/vis/line/aether/line.d.ts +8 -7
  364. package/dist/src/vis/line/aether/line.d.ts.map +1 -1
  365. package/dist/src/vis/lineplot/Axis.d.ts +5 -5
  366. package/dist/src/vis/lineplot/Axis.d.ts.map +1 -1
  367. package/dist/src/vis/lineplot/Legend.d.ts +2 -2
  368. package/dist/src/vis/lineplot/Line.d.ts +1 -1
  369. package/dist/src/vis/lineplot/Line.d.ts.map +1 -1
  370. package/dist/src/vis/lineplot/LinePlot.d.ts +7 -7
  371. package/dist/src/vis/lineplot/LinePlot.d.ts.map +1 -1
  372. package/dist/src/vis/lineplot/Title.d.ts +2 -2
  373. package/dist/src/vis/lineplot/Title.d.ts.map +1 -1
  374. package/dist/src/vis/lineplot/Viewport.d.ts +1 -1
  375. package/dist/src/vis/lineplot/aether/LinePlot.d.ts +57 -57
  376. package/dist/src/vis/lineplot/aether/LinePlot.d.ts.map +1 -1
  377. package/dist/src/vis/lineplot/aether/XAxis.d.ts +4 -3
  378. package/dist/src/vis/lineplot/aether/XAxis.d.ts.map +1 -1
  379. package/dist/src/vis/lineplot/aether/YAxis.d.ts +5 -4
  380. package/dist/src/vis/lineplot/aether/YAxis.d.ts.map +1 -1
  381. package/dist/src/vis/lineplot/aether/axis.d.ts +6 -6
  382. package/dist/src/vis/lineplot/aether/axis.d.ts.map +1 -1
  383. package/dist/src/vis/lineplot/aether/grid.d.ts +1 -1
  384. package/dist/src/vis/lineplot/aether/grid.d.ts.map +1 -1
  385. package/dist/src/vis/lineplot/range/Annotation.d.ts +2 -2
  386. package/dist/src/vis/lineplot/range/Annotation.d.ts.map +1 -1
  387. package/dist/src/vis/lineplot/range/Provider.d.ts +2 -2
  388. package/dist/src/vis/lineplot/range/Provider.d.ts.map +1 -1
  389. package/dist/src/vis/lineplot/range/aether/annotation.d.ts +4 -4
  390. package/dist/src/vis/lineplot/range/aether/provider.d.ts +19 -19
  391. package/dist/src/vis/lineplot/tooltip/Tooltip.d.ts +2 -2
  392. package/dist/src/vis/lineplot/tooltip/Tooltip.d.ts.map +1 -1
  393. package/dist/src/vis/lineplot/tooltip/aether/tooltip.d.ts +6 -6
  394. package/dist/src/vis/measure/Measure.d.ts +1 -2
  395. package/dist/src/vis/measure/Measure.d.ts.map +1 -1
  396. package/dist/src/vis/measure/aether/measure.d.ts +7 -7
  397. package/dist/src/vis/render/GLProgram.d.ts +2 -2
  398. package/dist/src/vis/render/clear/program.d.ts +1 -1
  399. package/dist/src/vis/render/context.d.ts +4 -7
  400. package/dist/src/vis/render/context.d.ts.map +1 -1
  401. package/dist/src/vis/render/eraser.d.ts +3 -3
  402. package/dist/src/vis/render/performance.d.ts +11 -0
  403. package/dist/src/vis/render/performance.d.ts.map +1 -0
  404. package/dist/src/vis/render/util.d.ts.map +1 -1
  405. package/dist/src/vis/rule/Rule.d.ts +2 -2
  406. package/dist/src/vis/rule/Rule.d.ts.map +1 -1
  407. package/dist/src/vis/rule/aether/aether.d.ts +5 -5
  408. package/dist/src/vis/schematic/Forms.d.ts +1 -0
  409. package/dist/src/vis/schematic/Forms.d.ts.map +1 -1
  410. package/dist/src/vis/schematic/Labeled.d.ts +2 -2
  411. package/dist/src/vis/schematic/Labeled.d.ts.map +1 -1
  412. package/dist/src/vis/schematic/SelectOrientation.d.ts +3 -3
  413. package/dist/src/vis/schematic/Symbols.d.ts +113 -19
  414. package/dist/src/vis/schematic/Symbols.d.ts.map +1 -1
  415. package/dist/src/vis/schematic/primitives/Primitives.d.ts +27 -3
  416. package/dist/src/vis/schematic/primitives/Primitives.d.ts.map +1 -1
  417. package/dist/src/vis/schematic/registry.d.ts +5 -6
  418. package/dist/src/vis/schematic/registry.d.ts.map +1 -1
  419. package/dist/src/vis/toggle/aether/toggle.d.ts +5 -5
  420. package/dist/src/vis/toggle/use.d.ts +1 -1
  421. package/dist/src/vis/value/aether/value.d.ts +43 -43
  422. package/dist/src/vis/value/use.d.ts +12 -12
  423. package/dist/src/worker/Context.d.ts +1 -1
  424. package/dist/src/worker/Context.d.ts.map +1 -1
  425. package/dist/style.css +1 -1
  426. package/dist/tabs.cjs +1 -1
  427. package/dist/tabs.js +1 -1
  428. package/dist/text.cjs +1 -1
  429. package/dist/text.js +2 -2
  430. package/dist/theming.cjs +1 -1
  431. package/dist/theming.js +2 -2
  432. package/dist/tree.cjs +1 -1
  433. package/dist/tree.js +1 -1
  434. package/dist/triggers.cjs +1 -1
  435. package/dist/triggers.js +1 -1
  436. package/dist/{units-MTRY0KtD.cjs → units-CoE6Mywf.cjs} +1 -1
  437. package/dist/{units-DeLVJ01P.js → units-DlP7zkaE.js} +1 -1
  438. package/dist/video.cjs +1 -1
  439. package/dist/video.js +1 -1
  440. package/package.json +23 -24
  441. package/dist/LinePlot-tnVASicV.cjs +0 -66
  442. package/dist/Link-CmzvCQDi.cjs +0 -1
  443. package/dist/List-BlgM15Pf.js +0 -22
  444. package/dist/Toggle-BvWOTk9-.cjs +0 -188
  445. package/dist/aggregator-CaPKb9Zv.cjs +0 -51
  446. package/dist/css-BNL3vU5o.cjs +0 -1
  447. package/dist/css-CDB-JY4S.js +0 -1370
  448. package/dist/external-BK0QWtit.cjs +0 -1
  449. package/dist/external-CRbJq-i4.js +0 -92
  450. package/dist/external-jSb_axxw.js +0 -346
  451. package/dist/external-v3jmKHoB.cjs +0 -1
  452. package/dist/external-zDAAJJHM.cjs +0 -1
  453. package/dist/jsx-runtime-fmb_vB8K.cjs +0 -25
  454. package/dist/src/util/case.d.ts +0 -2
  455. package/dist/src/util/case.d.ts.map +0 -1
  456. package/dist/src/vis/diagram/types.d.ts +0 -73
  457. package/dist/src/vis/diagram/types.d.ts.map +0 -1
@@ -1,51 +0,0 @@
1
- "use strict";var hl=Object.defineProperty;var fl=(t,e,r)=>e in t?hl(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var U=(t,e,r)=>(fl(t,typeof e!="symbol"?e+"":e,r),r);const a=require("zod"),O=require("./css-BNL3vU5o.cjs"),Os=require("react");var dl=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function yl(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function pl(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var r=function n(){return this instanceof n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach(function(n){var s=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(r,n,s.get?s:{enumerable:!0,get:function(){return t[n]}})}),r}const $t=t=>t!=null&&typeof t=="object"&&!Array.isArray(t);var gl=Object.defineProperty,ml=(t,e,r)=>e in t?gl(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Rt=(t,e,r)=>(ml(t,typeof e!="symbol"?e+"":e,r),r);let wl=class{constructor(){Rt(this,"contentType","application/json"),Rt(this,"decoder"),Rt(this,"encoder"),this.decoder=new TextDecoder,this.encoder=new TextEncoder}encode(e){return this.encoder.encode(this.encodeString(e)).buffer}decode(e,r){return this.decodeString(this.decoder.decode(e),r)}decodeString(e,r){const n=O.Te(JSON.parse(e));return r!=null?r.parse(n):n}encodeString(e){return JSON.stringify(O.ke(e),(r,n)=>ArrayBuffer.isView(n)?Array.from(n):$t(n)&&"encode_value"in n?typeof n.value=="bigint"?n.value.toString():n.value:typeof n=="bigint"?n.toString():n)}static registerCustomType(){}},vl=class{constructor(){Rt(this,"contentType","text/csv")}encode(e){const r=this.encodeString(e);return new TextEncoder().encode(r).buffer}decode(e,r){const n=new TextDecoder().decode(e);return this.decodeString(n,r)}encodeString(e){if(!Array.isArray(e)||e.length===0||!$t(e[0]))throw new Error("Payload must be an array of objects");const r=Object.keys(e[0]),n=[r.join(",")];return e.forEach(s=>{const i=r.map(o=>JSON.stringify(s[o]??""));n.push(i.join(","))}),n.join(`
2
- `)}decodeString(e,r){const[n,...s]=e.trim().split(`
3
- `).map(c=>c.trim());if(n.length===0)return r!=null?r.parse({}):{};const i=n.split(",").map(c=>c.trim()),o={};return i.forEach(c=>{o[c]=[]}),s.forEach(c=>{const u=c.split(",").map(f=>f.trim());i.forEach((f,w)=>{const h=this.parseValue(u[w]);h!=null&&o[f].push(h)})}),r!=null?r.parse(o):o}parseValue(e){if(e==null||e.length===0)return null;const r=Number(e);return isNaN(r)?e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1):e:r}static registerCustomType(){}},bl=class{constructor(){Rt(this,"contentType","text/plain")}encode(e){return new TextEncoder().encode(e).buffer}decode(e,r){const n=new TextDecoder().decode(e);return r!=null?r.parse(n):n}};new wl;new vl;new bl;const Qa=t=>t!=null&&typeof t=="object"&&"toString"in t,Ol=t=>{if(Qa(t))return(t==null?void 0:t.toString().length)===0;switch(typeof t){case"string":return t.length===0;case"number":return t===0;case"bigint":return t===0n;case"boolean":return!t;case"undefined":return!0;case"object":return t===null}},an=(t,e=!1)=>{const r=Qa(t)?"stringer":typeof t;let n;switch(r){case"string":n=(s,i)=>s.localeCompare(i);break;case"stringer":n=(s,i)=>s.toString().localeCompare(i.toString());break;case"number":n=(s,i)=>Number(s)-Number(i);break;case"bigint":n=(s,i)=>BigInt(s)-BigInt(i)>0n?1:-1;break;case"boolean":n=(s,i)=>Number(s)-Number(i);break;case"undefined":n=()=>0;break;default:return console.warn(`sortFunc: unknown type ${r}`),()=>-1}return e?ei(n):n},Tl=(t,e,r)=>{const n=an(e[t],r);return(s,i)=>n(s[t],i[t])},zl=(t,e)=>t.length!==e.length?t.length-e.length:t.every((r,n)=>r===e[n])?0:-1,Sl=(t,e)=>{if(t.length!==e.length)return t.length-e.length;if(t.length===0)return 0;const r=an(t[0]),n=[...t].sort(r),s=[...e].sort(r);return n.every((i,o)=>i===s[o])?0:-1},Nl=(t,e)=>t===e?0:t==="first"&&e==="last"?1:-1,ei=t=>(e,r)=>t(r,e),Al=t=>t<0,El=t=>t>0,Il=t=>t>=0,kl=(t,e)=>{const r=/([a-zA-Z]+)|(\d+)/g,n=t.replace(/[\s_.\-]+/g,"").match(r),s=e.replace(/[\s_.\-]+/g,"").match(r);if(!n||!s)return 0;for(let i=0;i<Math.min(n.length,s.length);i++){const o=n[i],c=s[i];if(isNaN(Number(o))&&isNaN(Number(c))){const u=o.localeCompare(c);if(u!==0)return u}else if(!isNaN(Number(o))&&!isNaN(Number(c))){const u=Number(o)-Number(c);if(u!==0)return u}else return isNaN(Number(o))?-1:1}return n.length-s.length},xl=Object.freeze(Object.defineProperty({__proto__:null,EQUAL:0,GREATER_THAN:1,LESS_THAN:-1,isGreaterThan:El,isGreaterThanEqual:Il,isLessThan:Al,newF:an,newFieldF:Tl,order:Nl,primitiveArrays:zl,reverseF:ei,stringsWithNumbers:kl,unorderedPrimitiveArrays:Sl},Symbol.toStringTag,{value:"Module"})),Cl=(t,e)=>{let r=null;return e===0?t:(...n)=>{r!==null&&(clearTimeout(r),r=null),r=setTimeout(()=>t(...n),e)}},jl=(t,e)=>{let r=null;return e===0?t:(...n)=>{r===null&&(r=setTimeout(()=>{t(...n),r=null},e))}},on=(t,e)=>{const r=t.split(".");return r.map((n,s)=>{const i=e(n,s,r);return i==null?null:typeof i=="string"?i:i.join(".")}).filter(n=>n!=null).join(".")},$l=t=>on(t,O.Ke),Rl=t=>on(t,O.Ze),Ts=(t,e,r={optional:!1})=>{const{optional:n,getter:s=(c,u)=>c[u]}=r,i=e.split(".");if(i.length===1&&i[0]==="")return t;let o=t;for(const c of i){const u=s(o,c);if(u==null){if(n)return null;throw new Error(`Path ${e} does not exist. ${c} is null`)}o=u}return o},Ml=(t,e,r)=>{const n=e.split(".");let s=t;for(let i=0;i<n.length-1;i++){const o=n[i];if(s[o]==null)throw new Error(`Path ${e} does not exist`);s=s[o]}s[n[n.length-1]]=r},Pl=(t,e)=>{const r=t.split(".");return e<0?r[r.length+e]:r[e]},Dl=t=>t.join("."),Ul=(t,e)=>{try{return Ts(t,e),!0}catch{return!1}},Bl=(t,e)=>{if(e.length===0)return!0;const r=t.split("."),n=e.split(".");if(n.length>r.length)return!1;for(let s=0;s<n.length;s++){const i=r[s],o=n[s];if(o!=="*"&&i!==o)return!1}return!0},Ll=t=>JSON.parse(JSON.stringify(t)),_l=(t,...e)=>(e.forEach(r=>{let n=t;const s=r.split(".");s.forEach((i,o)=>{o===s.length-1?delete n[i]:n=n[i]})}),t),Yl=(t,e,r="")=>{const n={},s=(i,o,c)=>{if(typeof i!=typeof o||i===null||o===null){n[c]=[i,o];return}if(typeof i=="object"&&typeof o=="object")if(Array.isArray(i)&&Array.isArray(o)){if(i.length!==o.length){n[c]=[i,o];return}for(let u=0;u<i.length;u++)s(i[u],o[u],`${c}[${u}]`)}else new Set([...Object.keys(i),...Object.keys(o)]).forEach(u=>{s(i[u],o[u],c!==""?`${c}.${u}`:u)});else i!==o&&(n[c]=[i,o])};return s(t,e,r),n},Qn=(t,e)=>{const r=Array.isArray(t),n=Array.isArray(e);if(r!==n)return!1;if(r&&n){const o=t,c=e;if(o.length!==c.length)return!1;for(let u=0;u<o.length;u++)if(!Qn(o[u],c[u]))return!1;return!0}if(t==null||e==null||typeof t!="object"||typeof e!="object")return t===e;if("equals"in t)return t.equals(e);const s=Object.keys(t),i=Object.keys(e);if(s.length!==i.length)return!1;for(const o of s){const c=t[o],u=e[o];if(typeof c=="object"&&typeof u=="object"){if(!Qn(c,u))return!1}else if(c!==u)return!1}return!0},ti=(t,e)=>{if(typeof t!="object"||t==null)return t===e;const r=Object.keys(t),n=Object.keys(e);if(n.length>r.length)return!1;for(const s of n){const i=t[s],o=e[s];if(typeof i=="object"&&typeof o=="object"){if(!ti(i,o))return!1}else if(i!==o)return!1}return!0},es=(t,...e)=>{if(e.length===0)return t;const r=e.shift();if($t(t)&&$t(r))for(const n in r)try{$t(r[n])?(n in t||Object.assign(t,{[n]:{}}),es(t[n],r[n])):Object.assign(t,{[n]:r[n]})}catch(s){throw s instanceof TypeError?new TypeError(`.${n}: ${s.message}`):s}return es(t,...e)},Zl=(t,e,r)=>{const n=(s,i,o)=>{for(const c in i){const u=i[c];if(o!=null&&o.shape[c]){const f=o.shape[c].safeParse(u);f.success&&(s[c]=f.data)}else typeof u=="object"&&!Array.isArray(u)&&u!==null&&o&&o.shape&&o.shape[c]&&(s[c]||(s[c]={}),n(s[c],u,o.shape[c]))}return s};return n({...t},e,r)},ri=Object.freeze(Object.defineProperty({__proto__:null,copy:Ll,deleteD:_l,difference:Yl,element:Pl,equal:Qn,get:Ts,has:Ul,join:Dl,override:es,overrideValidItems:Zl,partialEqual:ti,pathToCamel:Rl,pathToSnake:$l,pathsMatch:Bl,set:Ml,transformPath:on},Symbol.toStringTag,{value:"Module"}));a.z.record(a.z.union([a.z.number(),a.z.string(),a.z.symbol()]),a.z.unknown());const ni=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser",ql=ni(),si=["MacOS","Windows","Linux","Docker"],Fl=a.z.enum(si);let kn;const Vl=()=>{if(typeof window>"u")return;const t=window.navigator.userAgent.toLowerCase();if(t.includes("mac"))return"MacOS";if(t.includes("win"))return"Windows";if(t.includes("linux"))return"Linux"},Kl=(t={})=>{const{force:e,default:r}=t;return e??kn??(kn=Vl(),kn??r)},ai=Object.freeze(Object.defineProperty({__proto__:null,OPERATING_SYSTEMS:si,RUNTIME:ql,detect:ni,getOS:Kl,osZ:Fl},Symbol.toStringTag,{value:"Module"}));var Wl=Object.defineProperty,Gl=(t,e,r)=>e in t?Wl(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,g=(t,e,r)=>(Gl(t,typeof e!="symbol"?e+"":e,r),r);let Jl="_-0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",Hl=(t=21)=>{let e="",r=t;for(;r--;)e+=Jl[Math.random()*64|0];return e};const ii=(t,e)=>{const r=new F(e);if(![K.DAY,K.HOUR,K.MINUTE,K.SECOND,K.MILLISECOND,K.MICROSECOND,K.NANOSECOND].some(s=>s.equals(r)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const n=t.valueOf()%r.valueOf();return t instanceof F?new F(n):new K(n)},B=class T{constructor(e,r="UTC"){if(g(this,"value"),g(this,"encodeValue",!0),e==null)this.value=T.now().valueOf();else if(e instanceof Date)this.value=BigInt(e.getTime())*T.MILLISECOND.valueOf();else if(typeof e=="string")this.value=T.parseDateTimeString(e,r).valueOf();else if(Array.isArray(e))this.value=T.parseDate(e);else{let n=BigInt(0);e instanceof Number&&(e=e.valueOf()),r==="local"&&(n=T.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=T.MAX:e=T.MIN)),this.value=BigInt(e.valueOf())+n}}static parseDate([e=1970,r=1,n=1]){const s=new Date(e,r-1,n,0,0,0,0);return new T(BigInt(s.getTime())*T.MILLISECOND.valueOf()).truncate(T.DAY).valueOf()}encode(){return this.value.toString()}valueOf(){return this.value}static parseTimeString(e,r="UTC"){const[n,s,i]=e.split(":");let o="00",c="00";i!=null&&([o,c]=i.split("."));let u=T.hours(parseInt(n??"00",10)).add(T.minutes(parseInt(s??"00",10))).add(T.seconds(parseInt(o??"00",10))).add(T.milliseconds(parseInt(c??"00",10)));return r==="local"&&(u=u.add(T.utcOffset)),u.valueOf()}static parseDateTimeString(e,r="UTC"){if(!e.includes("/")&&!e.includes("-"))return T.parseTimeString(e,r);const n=new Date(e);return e.includes(":")||n.setUTCHours(0,0,0,0),new T(BigInt(n.getTime())*T.MILLISECOND.valueOf(),r).valueOf()}fString(e="ISO",r="UTC"){switch(e){case"ISODate":return this.toISOString(r).slice(0,10);case"ISOTime":return this.toISOString(r).slice(11,23);case"time":return this.timeString(!1,r);case"preciseTime":return this.timeString(!0,r);case"date":return this.dateString();case"preciseDate":return`${this.dateString()} ${this.timeString(!0,r)}`;case"dateTime":return`${this.dateString()} ${this.timeString(!1,r)}`;default:return this.toISOString(r)}}toISOString(e="UTC"){return e==="UTC"?this.date().toISOString():this.sub(T.utcOffset).date().toISOString()}timeString(e=!1,r="UTC"){const n=this.toISOString(r);return e?n.slice(11,23):n.slice(11,19)}dateString(){const e=this.date(),r=e.toLocaleString("default",{month:"short"}),n=e.toLocaleString("default",{day:"numeric"});return`${r} ${n}`}static get utcOffset(){return new K(BigInt(new Date().getTimezoneOffset())*T.MINUTE.valueOf())}static since(e){return new T().span(e)}date(){return new Date(this.milliseconds())}equals(e){return this.valueOf()===new T(e).valueOf()}span(e){return this.range(e).span}range(e){return new Lt(this,e).makeValid()}spanRange(e){return this.range(this.add(e)).makeValid()}get isZero(){return this.valueOf()===BigInt(0)}after(e){return this.valueOf()>new T(e).valueOf()}afterEq(e){return this.valueOf()>=new T(e).valueOf()}before(e){return this.valueOf()<new T(e).valueOf()}beforeEq(e){return this.valueOf()<=new T(e).valueOf()}add(e){return new T(this.valueOf()+BigInt(e.valueOf()))}sub(e){return new T(this.valueOf()-BigInt(e.valueOf()))}milliseconds(){return Number(this.valueOf())/Number(T.MILLISECOND.valueOf())}toString(){return this.date().toISOString()}remainder(e){return ii(this,e)}get isToday(){return this.truncate(K.DAY).equals(T.now().truncate(K.DAY))}truncate(e){return this.sub(this.remainder(e))}static now(){return new T(new Date)}static max(...e){let r=T.MIN;for(const n of e){const s=new T(n);s.after(r)&&(r=s)}return r}static min(...e){let r=T.MAX;for(const n of e){const s=new T(n);s.before(r)&&(r=s)}return r}static nanoseconds(e){return new T(e)}static microseconds(e){return T.nanoseconds(e*1e3)}static milliseconds(e){return T.microseconds(e*1e3)}static seconds(e){return T.milliseconds(e*1e3)}static minutes(e){return T.seconds(e*60)}static hours(e){return T.minutes(e*60)}static days(e){return T.hours(e*24)}};g(B,"NANOSECOND",B.nanoseconds(1)),g(B,"MICROSECOND",B.microseconds(1)),g(B,"MILLISECOND",B.milliseconds(1)),g(B,"SECOND",B.seconds(1)),g(B,"MINUTE",B.minutes(1)),g(B,"HOUR",B.hours(1)),g(B,"DAY",B.days(1)),g(B,"MAX",new B((1n<<63n)-1n)),g(B,"MIN",new B(0)),g(B,"ZERO",new B(0)),g(B,"z",a.z.union([a.z.object({value:a.z.bigint()}).transform(t=>new B(t.value)),a.z.string().transform(t=>new B(BigInt(t))),a.z.instanceof(Number).transform(t=>new B(t)),a.z.number().transform(t=>new B(t)),a.z.instanceof(B)]));let F=B;const L=class C{constructor(e){g(this,"value"),g(this,"encodeValue",!0),typeof e=="number"&&(e=Math.trunc(e.valueOf())),this.value=BigInt(e.valueOf())}encode(){return this.value.toString()}valueOf(){return this.value}lessThan(e){return this.valueOf()<new C(e).valueOf()}greaterThan(e){return this.valueOf()>new C(e).valueOf()}lessThanOrEqual(e){return this.valueOf()<=new C(e).valueOf()}greaterThanOrEqual(e){return this.valueOf()>=new C(e).valueOf()}remainder(e){return ii(this,e)}truncate(e){return new C(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(){const e=this.truncate(C.DAY),r=this.truncate(C.HOUR),n=this.truncate(C.MINUTE),s=this.truncate(C.SECOND),i=this.truncate(C.MILLISECOND),o=this.truncate(C.MICROSECOND),c=this.truncate(C.NANOSECOND),u=e,f=r.sub(e),w=n.sub(r),h=s.sub(n),D=i.sub(s),V=o.sub(i),se=c.sub(o);let R="";return u.isZero||(R+=`${u.days}d `),f.isZero||(R+=`${f.hours}h `),w.isZero||(R+=`${w.minutes}m `),h.isZero||(R+=`${h.seconds}s `),D.isZero||(R+=`${D.milliseconds}ms `),V.isZero||(R+=`${V.microseconds}µs `),se.isZero||(R+=`${se.nanoseconds}ns`),R.trim()}get days(){return Number(this.valueOf())/Number(C.DAY.valueOf())}get hours(){return Number(this.valueOf())/Number(C.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(C.MINUTE.valueOf())}get seconds(){return Number(this.valueOf())/Number(C.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(C.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(C.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===BigInt(0)}equals(e){return this.valueOf()===new C(e).valueOf()}add(e){return new C(this.valueOf()+new C(e).valueOf())}sub(e){return new C(this.valueOf()-new C(e).valueOf())}static nanoseconds(e=1){return new C(e)}static microseconds(e=1){return C.nanoseconds(e*1e3)}static milliseconds(e=1){return C.microseconds(e*1e3)}static seconds(e=1){return C.milliseconds(e*1e3)}static minutes(e){return C.seconds(e.valueOf()*60)}static hours(e){return C.minutes(e*60)}static days(e){return C.hours(e*24)}};g(L,"NANOSECOND",L.nanoseconds(1)),g(L,"MICROSECOND",L.microseconds(1)),g(L,"MILLISECOND",L.milliseconds(1)),g(L,"SECOND",L.seconds(1)),g(L,"MINUTE",L.minutes(1)),g(L,"HOUR",L.hours(1)),g(L,"DAY",L.days(1)),g(L,"MAX",new L((1n<<63n)-1n)),g(L,"MIN",new L(0)),g(L,"ZERO",new L(0)),g(L,"z",a.z.union([a.z.object({value:a.z.bigint()}).transform(t=>new L(t.value)),a.z.string().transform(t=>new L(BigInt(t))),a.z.instanceof(Number).transform(t=>new L(t)),a.z.number().transform(t=>new L(t)),a.z.instanceof(L)]));let K=L;const Tt=class fr extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new fr(e).valueOf()}get period(){return K.seconds(1/this.valueOf())}sampleCount(e){return new K(e).seconds*this.valueOf()}byteCount(e,r){return this.sampleCount(e)*new ce(r).valueOf()}span(e){return K.seconds(e/this.valueOf())}byteSpan(e,r){return this.span(e.valueOf()/r.valueOf())}static hz(e){return new fr(e)}static khz(e){return fr.hz(e*1e3)}};g(Tt,"z",a.z.union([a.z.number().transform(t=>new Tt(t)),a.z.instanceof(Number).transform(t=>new Tt(t)),a.z.instanceof(Tt)]));let Xl=Tt;const Q=class extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}length(e){return e.valueOf()/this.valueOf()}size(e){return new cn(e*this.valueOf())}};g(Q,"UNKNOWN",new Q(0)),g(Q,"BIT128",new Q(16)),g(Q,"BIT64",new Q(8)),g(Q,"BIT32",new Q(4)),g(Q,"BIT16",new Q(2)),g(Q,"BIT8",new Q(1)),g(Q,"z",a.z.union([a.z.number().transform(t=>new Q(t)),a.z.instanceof(Number).transform(t=>new Q(t)),a.z.instanceof(Q)]));let ce=Q;const ze=class dr{constructor(e,r){g(this,"start"),g(this,"end"),typeof e=="object"&&"start"in e?(this.start=new F(e.start),this.end=new F(e.end)):(this.start=new F(e),this.end=new F(r))}get span(){return new K(this.end.valueOf()-this.start.valueOf())}get isValid(){return this.start.valueOf()<=this.end.valueOf()}makeValid(){return this.isValid?this:this.swap()}get isZero(){return this.span.isZero}swap(){return new dr(this.end,this.start)}equals(e){return this.start.equals(e.start)&&this.end.equals(e.end)}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.fString("preciseDate")} - ${this.span.toString()}`}overlapsWith(e,r=K.ZERO){e=e.makeValid();const n=this.makeValid();if(this.equals(e))return!0;if(e.end.equals(n.start)||n.end.equals(e.start))return!1;const s=F.max(n.start,e.start),i=F.min(n.end,e.end);return i.before(s)?!1:new K(i.sub(s)).greaterThanOrEqual(r)}roughlyEquals(e,r){let n=this.start.sub(e.start).valueOf(),s=this.end.sub(e.end).valueOf();return n<0&&(n=-n),s<0&&(s=-s),n<=r.valueOf()&&s<=r.valueOf()}contains(e){return e instanceof dr?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const r=new dr(this.start,this.end);return e.start.after(this.start)&&(r.start=e.start),e.start.after(this.end)&&(r.end=e.start),e.end.before(this.end)&&(r.end=e.end),e.end.before(this.start)&&(r.start=e.end),r}};g(ze,"MAX",new ze(F.MIN,F.MAX)),g(ze,"MIN",new ze(F.MAX,F.MIN)),g(ze,"ZERO",new ze(F.ZERO,F.ZERO)),g(ze,"z",a.z.union([a.z.object({start:F.z,end:F.z}).transform(t=>new ze(t.start,t.end)),a.z.instanceof(ze)]));let Lt=ze;const d=class Se extends String{constructor(e){if(e instanceof Se||typeof e=="string"||typeof e.valueOf()=="string"){super(e.valueOf());return}else{const r=Se.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(r!=null){super(r.valueOf());return}}throw super(Se.UNKNOWN.valueOf()),new Error(`unable to find data type for ${e.toString()}`)}get Array(){const e=Se.ARRAY_CONSTRUCTORS.get(this.toString());if(e==null)throw new Error(`unable to find array constructor for ${this.valueOf()}`);return e}equals(e){return this.valueOf()===e.valueOf()}toString(){return this.valueOf()}get isVariable(){return this.equals(Se.JSON)||this.equals(Se.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(Se.UUID)}get isInteger(){return this.toString().startsWith("int")}get isFloat(){return this.toString().startsWith("float")}get density(){const e=Se.DENSITIES.get(this.toString());if(e==null)throw new Error(`unable to find density for ${this.valueOf()}`);return e}canSafelyCastTo(e){return this.equals(e)?!0:this.isVariable&&!e.isVariable||!this.isVariable&&e.isVariable?!1:this.isFloat&&e.isInteger||this.isInteger&&e.isFloat?this.density.valueOf()<e.density.valueOf():this.isFloat&&e.isFloat||this.isInteger&&e.isInteger?this.density.valueOf()<=e.density.valueOf():!1}canCastTo(e){return this.isNumeric&&e.isNumeric?!0:this.equals(e)}checkArray(e){return e.constructor===this.Array}toJSON(){return this.toString()}get usesBigInt(){return Se.BIG_INT_TYPES.some(e=>e.equals(this))}};g(d,"UNKNOWN",new d("unknown")),g(d,"FLOAT64",new d("float64")),g(d,"FLOAT32",new d("float32")),g(d,"INT64",new d("int64")),g(d,"INT32",new d("int32")),g(d,"INT16",new d("int16")),g(d,"INT8",new d("int8")),g(d,"UINT64",new d("uint64")),g(d,"UINT32",new d("uint32")),g(d,"UINT16",new d("uint16")),g(d,"UINT8",new d("uint8")),g(d,"BOOLEAN",d.UINT8),g(d,"TIMESTAMP",new d("timestamp")),g(d,"UUID",new d("uuid")),g(d,"STRING",new d("string")),g(d,"JSON",new d("json")),g(d,"ARRAY_CONSTRUCTORS",new Map([[d.UINT8.toString(),Uint8Array],[d.UINT16.toString(),Uint16Array],[d.UINT32.toString(),Uint32Array],[d.UINT64.toString(),BigUint64Array],[d.FLOAT32.toString(),Float32Array],[d.FLOAT64.toString(),Float64Array],[d.INT8.toString(),Int8Array],[d.INT16.toString(),Int16Array],[d.INT32.toString(),Int32Array],[d.INT64.toString(),BigInt64Array],[d.TIMESTAMP.toString(),BigInt64Array],[d.STRING.toString(),Uint8Array],[d.JSON.toString(),Uint8Array],[d.UUID.toString(),Uint8Array]])),g(d,"ARRAY_CONSTRUCTOR_DATA_TYPES",new Map([[Uint8Array.name,d.UINT8],[Uint16Array.name,d.UINT16],[Uint32Array.name,d.UINT32],[BigUint64Array.name,d.UINT64],[Float32Array.name,d.FLOAT32],[Float64Array.name,d.FLOAT64],[Int8Array.name,d.INT8],[Int16Array.name,d.INT16],[Int32Array.name,d.INT32],[BigInt64Array.name,d.INT64]])),g(d,"DENSITIES",new Map([[d.UINT8.toString(),ce.BIT8],[d.UINT16.toString(),ce.BIT16],[d.UINT32.toString(),ce.BIT32],[d.UINT64.toString(),ce.BIT64],[d.FLOAT32.toString(),ce.BIT32],[d.FLOAT64.toString(),ce.BIT64],[d.INT8.toString(),ce.BIT8],[d.INT16.toString(),ce.BIT16],[d.INT32.toString(),ce.BIT32],[d.INT64.toString(),ce.BIT64],[d.TIMESTAMP.toString(),ce.BIT64],[d.STRING.toString(),ce.UNKNOWN],[d.JSON.toString(),ce.UNKNOWN],[d.UUID.toString(),ce.BIT128]])),g(d,"ALL",[d.UNKNOWN,d.FLOAT64,d.FLOAT32,d.INT64,d.INT32,d.INT16,d.INT8,d.UINT64,d.UINT32,d.UINT16,d.UINT8,d.TIMESTAMP,d.UUID,d.STRING,d.JSON]),g(d,"BIG_INT_TYPES",[d.INT64,d.UINT64,d.TIMESTAMP]),g(d,"z",a.z.union([a.z.string().transform(t=>new d(t)),a.z.instanceof(d)]));let P=d;const ae=class G extends Number{constructor(e){super(e.valueOf())}largerThan(e){return this.valueOf()>e.valueOf()}smallerThan(e){return this.valueOf()<e.valueOf()}add(e){return G.bytes(this.valueOf()+e.valueOf())}sub(e){return G.bytes(this.valueOf()-e.valueOf())}truncate(e){return new G(Math.trunc(this.valueOf()/e.valueOf())*e.valueOf())}remainder(e){return G.bytes(this.valueOf()%e.valueOf())}get gigabytes(){return this.valueOf()/G.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/G.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/G.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/G.TERABYTE.valueOf()}toString(){const e=this.truncate(G.TERABYTE),r=this.truncate(G.GIGABYTE),n=this.truncate(G.MEGABYTE),s=this.truncate(G.KILOBYTE),i=this.truncate(G.BYTE),o=e,c=r.sub(e),u=n.sub(r),f=s.sub(n),w=i.sub(s);let h="";return o.isZero||(h+=`${o.terabytes}TB `),c.isZero||(h+=`${c.gigabytes}GB `),u.isZero||(h+=`${u.megabytes}MB `),f.isZero||(h+=`${f.kilobytes}KB `),(!w.isZero||h==="")&&(h+=`${w.valueOf()}B`),h.trim()}static bytes(e=1){return new G(e)}static kilobytes(e=1){return G.bytes(e.valueOf()*1e3)}static megabytes(e=1){return G.kilobytes(e.valueOf()*1e3)}static gigabytes(e=1){return G.megabytes(e.valueOf()*1e3)}static terabytes(e){return G.gigabytes(e.valueOf()*1e3)}get isZero(){return this.valueOf()===0}};g(ae,"BYTE",new ae(1)),g(ae,"KILOBYTE",ae.kilobytes(1)),g(ae,"MEGABYTE",ae.megabytes(1)),g(ae,"GIGABYTE",ae.gigabytes(1)),g(ae,"TERABYTE",ae.terabytes(1)),g(ae,"ZERO",new ae(0)),g(ae,"z",a.z.union([a.z.number().transform(t=>new ae(t)),a.z.instanceof(ae)]));let cn=ae;const Ql=a.z.union([a.z.instanceof(Uint8Array),a.z.instanceof(Uint16Array),a.z.instanceof(Uint32Array),a.z.instanceof(BigUint64Array),a.z.instanceof(Float32Array),a.z.instanceof(Float64Array),a.z.instanceof(Int8Array),a.z.instanceof(Int16Array),a.z.instanceof(Int32Array),a.z.instanceof(BigInt64Array)]),oi=t=>{const e=typeof t;return e==="string"||e==="number"||e==="boolean"||e==="bigint"||t instanceof F||t instanceof K||t instanceof Date},eu=(t,e,r,n=0)=>t.usesBigInt&&!e.usesBigInt?Number(r)-Number(n):!t.usesBigInt&&e.usesBigInt?BigInt(r)-BigInt(n):zt(r,-n),tu=t=>t==null?!1:Array.isArray(t)||t instanceof ArrayBuffer||ArrayBuffer.isView(t)&&!(t instanceof DataView)||t instanceof ci?!0:oi(t),tt=-1;let ci=class Ze{constructor(e){g(this,"key",""),g(this,"isSynnaxSeries",!0),g(this,"dataType"),g(this,"sampleOffset"),g(this,"gl"),g(this,"_data"),g(this,"_timeRange"),g(this,"alignment",0n),g(this,"_cachedMin"),g(this,"_cachedMax"),g(this,"writePos",tt),g(this,"_refCount",0),g(this,"_cachedLength"),tu(e)&&(e={data:e});const{dataType:r,timeRange:n,sampleOffset:s=0,glBufferUsage:i="static",alignment:o=0n,key:c=Hl()}=e,{data:u}=e;if(u instanceof Ze||typeof u=="object"&&"isSynnaxSeries"in u&&u.isSynnaxSeries===!0){const h=u;this.key=h.key,this.dataType=h.dataType,this.sampleOffset=h.sampleOffset,this.gl=h.gl,this._data=h._data,this._timeRange=h._timeRange,this.alignment=h.alignment,this._cachedMin=h._cachedMin,this._cachedMax=h._cachedMax,this.writePos=h.writePos,this._refCount=h._refCount,this._cachedLength=h._cachedLength;return}const f=oi(u),w=Array.isArray(u);if(r!=null)this.dataType=new P(r);else{if(u instanceof ArrayBuffer)throw new Error("cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type.");if(w||f){let h=u;if(!f){if(u.length===0)throw new Error("cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type.");h=u[0]}if(typeof h=="string")this.dataType=P.STRING;else if(typeof h=="number")this.dataType=P.FLOAT64;else if(typeof h=="bigint")this.dataType=P.INT64;else if(typeof h=="boolean")this.dataType=P.BOOLEAN;else if(h instanceof F||h instanceof Date||h instanceof F)this.dataType=P.TIMESTAMP;else if(typeof h=="object")this.dataType=P.JSON;else throw new Error(`cannot infer data type of ${typeof h} when constructing a Series from a JS array`)}else this.dataType=new P(u)}if(!w&&!f)this._data=u;else{let h=f?[u]:u;const D=h[0];(D instanceof F||D instanceof Date||D instanceof K)&&(h=h.map(V=>new F(V).valueOf())),this.dataType.equals(P.STRING)?(this._cachedLength=h.length,this._data=new TextEncoder().encode(h.join(`
4
- `)+`
5
- `)):this.dataType.equals(P.JSON)?(this._cachedLength=h.length,this._data=new TextEncoder().encode(h.map(V=>JSON.stringify(V)).join(`
6
- `)+`
7
- `)):this._data=new this.dataType.Array(h).buffer}this.key=c,this.alignment=o,this.sampleOffset=s??0,this._timeRange=n,this.gl={control:null,buffer:null,prevBuffer:0,bufferUsage:i}}static alloc({capacity:e,dataType:r,...n}){if(e===0)throw new Error("[Series] - cannot allocate an array of length 0");const s=new new P(r).Array(e),i=new Ze({data:s.buffer,dataType:r,...n});return i.writePos=0,i}static generateTimestamps(e,r,n){const s=n.spanRange(r.span(e)),i=new BigInt64Array(e);for(let o=0;o<e;o++)i[o]=BigInt(n.add(r.span(o)).valueOf());return new Ze({data:i,dataType:P.TIMESTAMP,timeRange:s})}get refCount(){return this._refCount}static fromStrings(e,r){const n=new TextEncoder().encode(e.join(`
8
- `)+`
9
- `);return new Ze({data:n,dataType:P.STRING,timeRange:r})}static fromJSON(e,r){const n=new TextEncoder().encode(e.map(s=>JSON.stringify(s)).join(`
10
- `)+`
11
- `);return new Ze({data:n,dataType:P.JSON,timeRange:r})}acquire(e){this._refCount++,e!=null&&this.updateGLBuffer(e)}release(){if(this._refCount--,this._refCount===0&&this.gl.control!=null)this.maybeGarbageCollectGLBuffer(this.gl.control);else if(this._refCount<0)throw new Error("cannot release an array with a negative reference count")}write(e){if(!e.dataType.equals(this.dataType))throw new Error("buffer must be of the same type as this array");if(this.writePos===tt)return 0;const r=this.capacity-this.writePos,n=r<e.length?e.slice(0,r):e;return this.underlyingData.set(n.data,this.writePos),this.maybeRecomputeMinMax(n),this._cachedLength=void 0,this.writePos+=n.length,n.length}get buffer(){return this._data}get underlyingData(){return new this.dataType.Array(this._data)}get data(){return this.writePos===tt?this.underlyingData:new this.dataType.Array(this._data,0,this.writePos)}toStrings(){if(!this.dataType.equals(P.STRING))throw new Error("cannot convert non-string series to strings");return new TextDecoder().decode(this.buffer).split(`
12
- `).slice(0,-1)}toUUIDs(){if(!this.dataType.equals(P.UUID))throw new Error("cannot convert non-uuid series to uuids");const e=P.UUID.density.valueOf(),r=Array(this.length);for(let n=0;n<this.length;n++){const s=this.buffer.slice(n*e,(n+1)*e),i=Array.from(new Uint8Array(s),o=>o.toString(16).padStart(2,"0")).join("").replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/,"$1-$2-$3-$4-$5");r[n]=i}return r}parseJSON(e){if(!this.dataType.equals(P.JSON))throw new Error("cannot convert non-string series to strings");return new TextDecoder().decode(this.buffer).split(`
13
- `).slice(0,-1).map(r=>e.parse(O.Te(JSON.parse(r))))}get timeRange(){if(this._timeRange==null)throw new Error("time range not set on series");return this._timeRange}get byteCapacity(){return new cn(this.buffer.byteLength)}get capacity(){return this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===tt?this.byteCapacity:this.dataType.density.size(this.writePos)}get length(){return this._cachedLength!=null?this._cachedLength:this.dataType.isVariable?this.calculateCachedLength():this.writePos===tt?this.data.length:this.writePos}calculateCachedLength(){if(!this.dataType.isVariable)throw new Error("cannot calculate length of a non-variable length data type");let e=0;return this.data.forEach(r=>{r===10&&e++}),this._cachedLength=e,e}convert(e,r=0){if(this.dataType.equals(e))return this;const n=new e.Array(this.length);for(let s=0;s<this.length;s++)n[s]=eu(this.dataType,e,this.data[s],r);return new Ze({data:n.buffer,dataType:e,timeRange:this._timeRange,sampleOffset:r,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment})}calcRawMax(){if(this.length===0)return-1/0;if(this.dataType.equals(P.TIMESTAMP))this._cachedMax=this.data[this.data.length-1];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMax=e.reduce((r,n)=>r>n?r:n)}else{const e=this.data;this._cachedMax=e.reduce((r,n)=>r>n?r:n)}return this._cachedMax}get max(){if(this.dataType.isVariable)throw new Error("cannot calculate maximum on a variable length data type");return this.writePos===0?-1/0:(this._cachedMax==null&&(this._cachedMax=this.calcRawMax()),zt(this._cachedMax,this.sampleOffset))}calcRawMin(){if(this.length===0)return 1/0;if(this.dataType.equals(P.TIMESTAMP))this._cachedMin=this.data[0];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMin=e.reduce((r,n)=>r<n?r:n)}else{const e=this.data;this._cachedMin=e.reduce((r,n)=>r<n?r:n)}return this._cachedMin}get min(){if(this.dataType.isVariable)throw new Error("cannot calculate minimum on a variable length data type");return this.writePos===0?1/0:(this._cachedMin==null&&(this._cachedMin=this.calcRawMin()),zt(this._cachedMin,this.sampleOffset))}get bounds(){return O.i(Number(this.min),Number(this.max))}maybeRecomputeMinMax(e){if(this._cachedMin!=null){const r=e._cachedMin??e.calcRawMin();r<this._cachedMin&&(this._cachedMin=r)}if(this._cachedMax!=null){const r=e._cachedMax??e.calcRawMax();r>this._cachedMax&&(this._cachedMax=r)}}enrich(){this.max,this.min}get range(){return zt(this.max,-this.min)}at(e,r){if(this.dataType.isVariable)return this.atVariable(e,r??!1);e<0&&(e=this.length+e);const n=this.data[e];if(n==null){if(r===!0)throw new Error(`[series] - no value at index ${e}`);return}return zt(n,this.sampleOffset)}atVariable(e,r){e<0&&(e=this.length+e);let n=0,s=0;for(let o=0;o<this.data.length;o++)if(this.data[o]===10){if(e===0){s=o;break}n=o+1,e--}if(s===0&&(s=this.data.length),n>=s||e>0){if(r)throw new Error(`[series] - no value at index ${e}`);return}const i=this.data.slice(n,s);return this.dataType.equals(P.STRING)?new TextDecoder().decode(i):O.Te(JSON.parse(new TextDecoder().decode(i)))}binarySearch(e){let r=0,n=this.length-1;const s=an(e);for(;r<=n;){const i=Math.floor((r+n)/2),o=s(this.at(i,!0),e);if(o===0)return i;o<0?r=i+1:n=i-1}return r}updateGLBuffer(e){if(this.gl.control=e,!this.dataType.equals(P.FLOAT32))throw new Error("Only FLOAT32 arrays can be used in WebGL");const{buffer:r,bufferUsage:n,prevBuffer:s}=this.gl;if(r==null&&(this.gl.buffer=e.createBuffer()),this.writePos!==s)if(e.bindBuffer(e.ARRAY_BUFFER,this.gl.buffer),this.writePos!==tt){s===0&&e.bufferData(e.ARRAY_BUFFER,this.byteCapacity.valueOf(),e.STATIC_DRAW);const i=this.dataType.density.size(s).valueOf(),o=this.underlyingData.slice(this.gl.prevBuffer,this.writePos);e.bufferSubData(e.ARRAY_BUFFER,i,o.buffer),this.gl.prevBuffer=this.writePos}else e.bufferData(e.ARRAY_BUFFER,this.buffer,n==="static"?e.STATIC_DRAW:e.DYNAMIC_DRAW),this.gl.prevBuffer=tt}as(e){if(e==="string"){if(!this.dataType.equals(P.STRING))throw new Error(`cannot convert series of type ${this.dataType.toString()} to string`);return this}if(e==="number"){if(!this.dataType.isNumeric)throw new Error(`cannot convert series of type ${this.dataType.toString()} to number`);return this}if(e==="bigint"){if(!this.dataType.equals(P.INT64))throw new Error(`cannot convert series of type ${this.dataType.toString()} to bigint`);return this}throw new Error(`cannot convert series to ${e}`)}get digest(){var e;return{key:this.key,dataType:this.dataType.toString(),sampleOffset:this.sampleOffset,alignment:this.alignmentBounds,timeRange:(e=this._timeRange)==null?void 0:e.toString(),length:this.length,capacity:this.capacity}}get memInfo(){return{key:this.key,length:this.length,byteLength:this.byteLength,glBuffer:this.gl.buffer!=null}}get alignmentBounds(){return O.i(this.alignment,this.alignment+BigInt(this.length))}maybeGarbageCollectGLBuffer(e){this.gl.buffer!=null&&(e.deleteBuffer(this.gl.buffer),this.gl.buffer=null,this.gl.prevBuffer=0,this.gl.control=null)}get glBuffer(){if(this.gl.buffer==null)throw new Error("gl buffer not initialized");return this.gl.prevBuffer!==this.writePos&&console.warn("buffer not updated"),this.gl.buffer}[Symbol.iterator](){if(this.dataType.isVariable){const e=new ru(this);return this.dataType.equals(P.JSON)?new nu(e):e}return new su(this)}slice(e,r){if(e<=0&&(r==null||r>=this.length))return this;const n=this.data.slice(e,r);return new Ze({data:n,dataType:this.dataType,timeRange:this._timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(e)})}reAlign(e){return new Ze({data:this.buffer,dataType:this.dataType,timeRange:Lt.ZERO,sampleOffset:this.sampleOffset,glBufferUsage:"static",alignment:e})}},ru=class{constructor(e){if(g(this,"series"),g(this,"index"),g(this,"decoder"),!e.dataType.isVariable)throw new Error("cannot create a variable series iterator for a non-variable series");this.series=e,this.index=0,this.decoder=new TextDecoder}next(){const e=this.index,r=this.series.data;for(;this.index<r.length&&r[this.index]!==10;)this.index++;const n=this.index;return e===n?{done:!0,value:void 0}:(this.index++,{done:!1,value:this.decoder.decode(this.series.buffer.slice(e,n))})}[Symbol.iterator](){return this}};var li;let nu=class{constructor(e){g(this,"wrapped"),g(this,li,"JSONSeriesIterator"),this.wrapped=e}next(){const e=this.wrapped.next();return e.done===!0?{done:!0,value:void 0}:{done:!1,value:O.Te(JSON.parse(e.value))}}[Symbol.iterator](){return this}};li=Symbol.toStringTag;var ui;let su=class{constructor(e){g(this,"series"),g(this,"index"),g(this,ui,"SeriesIterator"),this.series=e,this.index=0}next(){return this.index>=this.series.length?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}[Symbol.iterator](){return this}};ui=Symbol.toStringTag;const zt=(t,e)=>typeof t=="bigint"&&typeof e=="bigint"||typeof t=="number"&&typeof e=="number"?t+e:e===0?t:t===0?e:Number(t)+Number(e);let au=class{constructor(e){if(g(this,"series"),e.length!==0){const r=e[0].dataType;for(let n=1;n<e.length;n++)if(!e[n].dataType.equals(r))throw new Error("[multi-series] - series must have the same data type")}this.series=e}as(e){if(!new P(e).equals(this.dataType))throw new Error(`cannot convert series of type ${this.dataType.toString()} to ${e.toString()}`);return this}get dataType(){return this.series.length===0?P.UNKNOWN:this.series[0].dataType}get timeRange(){return this.series.length===0?Lt.ZERO:new Lt(this.series[0].timeRange.start,this.series[this.series.length-1].timeRange.end)}push(e){this.series.push(e)}get length(){return this.series.reduce((e,r)=>e+r.length,0)}at(e,r=!1){e<0&&(e=this.length+e);for(const n of this.series){if(e<n.length)return n.at(e,r);e-=n.length}if(r)throw new Error(`[series] - no value at index ${e}`)}get byteLength(){return new cn(this.series.reduce((e,r)=>e+r.byteLength.valueOf(),0))}get data(){const e=new this.dataType.Array(this.length);let r=0;for(const n of this.series)e.set(n.data,r),r+=n.length;return new this.dataType.Array(e)}[Symbol.iterator](){return this.series.length===0?{next(){return{done:!0,value:void 0}}}:new iu(this.series)}};var hi;let iu=class{constructor(e){g(this,"series"),g(this,"seriesIndex"),g(this,"internal"),g(this,hi,"MultiSeriesIterator"),this.series=e,this.seriesIndex=0,this.internal=e[0][Symbol.iterator]()}next(){const e=this.internal.next();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())}[Symbol.iterator](){return this}};hi=Symbol.toStringTag;const ou=t=>Array.isArray(t)?t:[t],cu=t=>Array.isArray(t)?t:t===null?[]:[t],lu=t=>[...new Set(t)];var uu=Object.defineProperty,hu=(t,e,r)=>e in t?uu(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,St=(t,e,r)=>(hu(t,typeof e!="symbol"?e+"":e,r),r);const fu=(...t)=>t.map(fi).join(""),fi=t=>(t.endsWith("/")||(t+="/"),t.startsWith("/")&&(t=t.slice(1)),t),du=t=>t.endsWith("/")?t.slice(0,-1):t,va=class ts{constructor({host:e,port:r,protocol:n="",pathPrefix:s=""}){St(this,"protocol"),St(this,"host"),St(this,"port"),St(this,"path"),this.protocol=n,this.host=e,this.port=r,this.path=fi(s)}replace(e){return new ts({host:e.host??this.host,port:e.port??this.port,protocol:e.protocol??this.protocol,pathPrefix:e.pathPrefix??this.path})}child(e){return new ts({...this,pathPrefix:fu(this.path,e)})}toString(){return du(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}};St(va,"UNKNOWN",new va({host:"unknown",port:0}));var yu=Object.defineProperty,pu=(t,e,r)=>e in t?yu(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Wr=(t,e,r)=>(pu(t,typeof e!="symbol"?e+"":e,r),r);let gu=class{constructor(e){Wr(this,"sender"),Wr(this,"handlers"),this.sender=e,this.handlers=new Map}handle({data:e}){var r;const n=(r=this.handlers.get(e.type))==null?void 0:r.handler;n==null?console.warn(`No handler for ${e.type}`):n(e.payload)}route(e){const r=mu(e,this.sender),n=new wu(r);return this.handlers.set(e,n),n}};const mu=(t,e)=>(r,n)=>e({type:t,payload:r},n);let wu=class{constructor(e){Wr(this,"_send"),Wr(this,"handler"),this._send=e,this.handler=null}send(e,r=[]){this._send(e,r)}handle(e){this.handler=e}};var vu=Object.defineProperty,bu=(t,e,r)=>e in t?vu(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,xn=(t,e,r)=>(bu(t,typeof e!="symbol"?e+"":e,r),r);const nt=class extends Number{};xn(nt,"Absolute",255),xn(nt,"Default",1),xn(nt,"z",a.z.union([a.z.instanceof(nt),a.z.number().int().min(0).max(255).transform(t=>new nt(t)),a.z.instanceof(Number).transform(t=>new nt(t))]));let di=nt;const yi=a.z.object({name:a.z.string(),key:a.z.string()}),Ou=t=>a.z.object({subject:yi,resource:t,authority:di.z}),Tu=(...t)=>e=>e.filter(r=>{let n=!1;return r.to!=null&&(n=t.includes(r.to.resource)),r.from!=null&&!n&&(n=t.includes(r.from.resource)),n}),zu=Object.freeze(Object.defineProperty({__proto__:null,Authority:di,filterTransfersByChannelKey:Tu,stateZ:Ou,subjectZ:yi},Symbol.toStringTag,{value:"Module"})),Su=t=>t?-1:1;a.z.string().regex(/^\d+\.\d+\.\d+$/);const Nu=t=>{if(t===void 0||typeof t=="string"||typeof t=="number")return t;if(t.toString===void 0)throw new Error("invalid renderer");return t.toString()},Au=t=>Array.isArray(t)?[...t]:typeof t=="object"&&t!==null?{...t}:t,zs=t=>typeof t=="function",Ss=(t,e)=>zs(t)?t(e):t,Wt=t=>pi(t)?t():t,pi=t=>typeof t=="function",gi=({initial:t,value:e,onChange:r})=>{const[n,s]=Os.useState(Wt(e??t));return e!=null&&r!=null?[e,r]:[n,s]},mi=({initial:t,value:e,onChange:r})=>{const[n,s]=Os.useState(Wt(e??t));return e!=null&&r!=null?[e,r]:[n,s]},Eu=(t,e)=>{const[r,n]=Os.useState(()=>{const s=localStorage.getItem(e);return s==null?Wt(t):JSON.parse(s)});return[r,s=>{n(s),localStorage.setItem(e,JSON.stringify(s))}]},Iu=Object.freeze(Object.defineProperty({__proto__:null,executeInitialSetter:Wt,executeSetter:Ss,isInitialSetter:pi,isSetter:zs,usePassthrough:gi,usePersisted:Eu,usePurePassthrough:mi},Symbol.toStringTag,{value:"Module"})),wi=["h1","h2","h3","h4","h5","p","small"],ku=a.z.enum(wi),He=a.z.object({size:a.z.number(),weight:a.z.union([a.z.number(),a.z.string()]),lineHeight:a.z.number(),textTransform:a.z.string().optional()}),vi={small:"small",medium:"p",large:"h5",huge:"h2"},xu={h1:"huge",h2:"huge",h3:"huge",h4:"large",h5:"small",p:"medium",small:"small"};let Cn=null;const Cu=()=>(Cn==null&&(Cn=document.createElement("canvas")),Cn),ju=(t,e,r)=>{if(ai.RUNTIME==="node")return{width:0,height:0};r==null&&(r=Cu().getContext("2d")),r.font=e;const n=r.measureText(t);return{width:Math.trunc(Math.abs(n.actualBoundingBoxLeft)+Math.abs(n.actualBoundingBoxRight)),height:Math.trunc(Math.abs(n.actualBoundingBoxAscent)+Math.abs(n.actualBoundingBoxDescent))}},$u=a.z.object({l0:O.Color.z,l1:O.Color.z,l2:O.Color.z,l3:O.Color.z,l4:O.Color.z,l5:O.Color.z,l6:O.Color.z,l7:O.Color.z,l8:O.Color.z,l9:O.Color.z,l10:O.Color.z}),pe=(t,e)=>[t[0],t[1],e,t[3]],Ru=a.z.object({m2:O.Color.z,m1:O.Color.z,z:O.Color.z,p1:O.Color.z,p2:O.Color.z}),nr=Ru.or(O.Color.z.transform(t=>{const e=t.hsla;return{m2:new O.Color(O.fromHSLA(pe(e,40))),m1:new O.Color(O.fromHSLA(pe(e,45))),z:t,p1:new O.Color(O.fromHSLA(pe(e,55))),p2:new O.Color(O.fromHSLA(pe(e,65)))}})),bi=a.z.object({name:a.z.string(),key:a.z.string(),colors:a.z.object({border:O.Color.z,primary:nr,gray:$u,error:nr,secondary:nr,warning:nr,visualization:a.z.object({palettes:a.z.record(a.z.array(O.Color.z))}).optional().default({palettes:{}}),white:O.Color.z,black:O.Color.z,text:O.Color.z,textInverted:O.Color.z,textOnPrimary:O.Color.z.optional().default(O.ZERO),logo:a.z.string()}),sizes:a.z.object({base:a.z.number(),border:a.z.object({radius:a.z.number(),width:a.z.number()}),schematic:a.z.object({elementStrokeWidth:a.z.number()})}),typography:a.z.object({family:a.z.string(),h1:He,h2:He,h3:He,h4:He,h5:He,p:He,small:He})}).transform(t=>((t.colors.textOnPrimary==null||t.colors.textOnPrimary.isZero)&&(t.colors.textOnPrimary=t.colors.primary.z.pickByContrast(t.colors.text,t.colors.textInverted)),t)),Mu="'Inter Variable', sans-serif",Pu=6,wt=[357,91,55,1],vt=[42,100,50,1],Du=["#FCFCFC","#F9F9F9","#F4F4F4","#ededed","#d9d9d9","#ADADAD","#878787","#616161","#404040","#1C1C1C","#050505"],sr=Object.fromEntries(Du.map((t,e)=>[`l${e}`,t])),rs={key:"synnaxBase",name:"Synnax Base",colors:{primary:{m2:"#041B3D",m1:"#164FA0",z:"#3774D0",p1:"#5E94EE",p2:"#8AB8FF"},secondary:{m2:"#2D8F4E",m1:"#38B261",z:"#50C878",p1:"#73D393",p2:"#96DEAE"},gray:sr,border:sr.l3,error:{m2:O.fromHSLA(pe(wt,30)),m1:O.fromHSLA(pe(wt,40)),z:O.fromHSLA(wt),p1:O.fromHSLA(pe(wt,60)),p2:O.fromHSLA(pe(wt,70))},warning:{m2:O.fromHSLA(pe(vt,30)),m1:O.fromHSLA(pe(vt,40)),z:O.fromHSLA(vt),p1:O.fromHSLA(pe(vt,60)),p2:O.fromHSLA(pe(vt,70))},visualization:{palettes:{default:["#DC136C","#20A4F3","#7AC74F","#FFC43D","#FE5F55","#8075FF","#D90429","#f7aef8","#f18f01","#791e94","#279af1","#d9fff5","#ff6b6b","#52ffb8"]}},logo:"url(#synnax-linear-gradient)",white:"#FFFFFF",black:"#000000",text:sr.l9,textInverted:sr.l0},sizes:{base:Pu,border:{radius:2,width:1},schematic:{elementStrokeWidth:2}},typography:{family:Mu,h1:{size:7,weight:"500",lineHeight:7*1.5},h2:{size:4.5,weight:"medium",lineHeight:4.5*1.5},h3:{size:3.5,weight:"medium",lineHeight:3.5*1.5},h4:{size:2.5,weight:"medium",lineHeight:2.5*1.5},h5:{size:2.333333,weight:450,lineHeight:2.333333*1.5},p:{size:2.1666666666,weight:"regular",lineHeight:2*1.5},small:{size:1.916666,weight:"regular",lineHeight:1.9166666*1.5}}},Oi=Object.freeze({...rs,key:"synnaxLight",name:"Synnax Light"}),Uu=["#020202","#080808","#141414","#1a1a1a","#242424","#515151","#7f7f7f","#9D9D9D","#BFBFBF","#EDEDED","#FDFDFD"],ar=Object.fromEntries(Uu.map((t,e)=>[`l${e}`,t])),Ti=Object.freeze({...rs,key:"synnaxDark",name:"Synnax Dark",colors:{...rs.colors,gray:ar,logo:"var(--pluto-text-color)",border:ar.l3,text:ar.l9,textInverted:ar.l0}}),Bu={synnaxDark:Ti,synnaxLight:Oi},Lu=["small","medium","large","huge"],_u=a.z.enum(Lu),Yu=t=>_u.safeParse(t).success,Zu=(t,e,r)=>{const{typography:n,sizes:{base:s}}=t,i=n[Yu(e)?vi[e]:e].size,o=s*i,[c,u]=n.family.split(", ");return r!=null?` ${r} ${o}px ${c}, ${u}`:` ${o}px ${n.family}`};var qu=Object.defineProperty,Fu=(t,e,r)=>e in t?qu(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,l=(t,e,r)=>(Fu(t,typeof e!="symbol"?e+"":e,r),r),Vu=Object.defineProperty,Ku=(t,e,r)=>e in t?Vu(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,M=(t,e,r)=>(Ku(t,typeof e!="symbol"?e+"":e,r),r),we=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},N={},ln={};Object.defineProperty(ln,"__esModule",{value:!0});function Wu(t){return t===void 0&&(t=""),t?String(t).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/[^A-Za-z0-9]+/g,"$").replace(/([a-z])([A-Z])/g,function(e,r,n){return r+"$"+n}).toLowerCase().replace(/(\$)(\w)/g,function(e,r,n){return n.toUpperCase()}):""}ln.default=Wu;var un={};Object.defineProperty(un,"__esModule",{value:!0});function Gu(t){return t===void 0&&(t=""),t?String(t).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,r,n){return r+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"_").toLowerCase():""}un.default=Gu;var hn={};Object.defineProperty(hn,"__esModule",{value:!0});function Ju(t){return t===void 0&&(t=""),t?String(t).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"$").replace(/[^A-Za-z0-9]+/g,"$").replace(/([a-z])([A-Z])/g,function(e,r,n){return r+"$"+n}).toLowerCase().replace(/(\$)(\w?)/g,function(e,r,n){return n.toUpperCase()}):""}hn.default=Ju;var Ns={};Object.defineProperty(Ns,"__esModule",{value:!0});function Hu(t){return t===void 0&&(t=""),t?String(t).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,r,n){return r+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,".").toLowerCase():""}Ns.default=Hu;var As={};Object.defineProperty(As,"__esModule",{value:!0});function Xu(t){return t===void 0&&(t=""),t?String(t).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,r,n){return r+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"/").toLowerCase():""}As.default=Xu;var Es={};Object.defineProperty(Es,"__esModule",{value:!0});function Qu(t){return t===void 0&&(t=""),t?String(t).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,r,n){return r+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase():""}Es.default=Qu;var Is={};Object.defineProperty(Is,"__esModule",{value:!0});function eh(t){if(t===void 0&&(t=""),!t)return"";var e=String(t).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(r,n,s){return n+"_"+s.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase();return e.charAt(0).toUpperCase()+e.slice(1)}Is.default=eh;var ks={};Object.defineProperty(ks,"__esModule",{value:!0});function th(t){return t===void 0&&(t=""),t?String(t).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,r,n){return r+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase().replace(/( ?)(\w+)( ?)/g,function(e,r,n,s){return r+n.charAt(0).toUpperCase()+n.slice(1)+s}):""}ks.default=th;var fn={};Object.defineProperty(fn,"__esModule",{value:!0});function rh(t){return t===void 0&&(t=""),t?String(t).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,r,n){return r+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"-").toLowerCase():""}fn.default=rh;var xs={},ct={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.belongToTypes=t.isValidObject=t.isArrayObject=t.validateOptions=t.DefaultOption=void 0,t.DefaultOption={recursive:!1,recursiveInArray:!1,keepTypesOnRecursion:[]},t.validateOptions=function(e){return e===void 0&&(e=t.DefaultOption),e.recursive==null?e=t.DefaultOption:e.recursiveInArray==null&&(e.recursiveInArray=!1),e},t.isArrayObject=function(e){return e!=null&&Array.isArray(e)},t.isValidObject=function(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)},t.belongToTypes=function(e,r){return(r||[]).some(function(n){return e instanceof n})}})(ct);var nh=we&&we.__spreadArrays||function(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var n=Array(t),s=0,e=0;e<r;e++)for(var i=arguments[e],o=0,c=i.length;o<c;o++,s++)n[s]=i[o];return n};Object.defineProperty(xs,"__esModule",{value:!0});var Ce=ct;function yr(t,e){if(e===void 0&&(e=Ce.DefaultOption),!Ce.isValidObject(t))return null;e=Ce.validateOptions(e);var r={};return Object.keys(t).forEach(function(n){var s=t[n],i=n.toLowerCase();e.recursive&&(Ce.isValidObject(s)?Ce.belongToTypes(s,e.keepTypesOnRecursion)||(s=yr(s,e)):e.recursiveInArray&&Ce.isArrayObject(s)&&(s=nh(s).map(function(o){var c=o;if(Ce.isValidObject(o))Ce.belongToTypes(c,e.keepTypesOnRecursion)||(c=yr(o,e));else if(Ce.isArrayObject(o)){var u=yr({key:o},e);c=u.key}return c}))),r[i]=s}),r}xs.default=yr;var Cs={},sh=we&&we.__spreadArrays||function(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var n=Array(t),s=0,e=0;e<r;e++)for(var i=arguments[e],o=0,c=i.length;o<c;o++,s++)n[s]=i[o];return n};Object.defineProperty(Cs,"__esModule",{value:!0});var je=ct;function pr(t,e){if(e===void 0&&(e=je.DefaultOption),!je.isValidObject(t))return null;e=je.validateOptions(e);var r={};return Object.keys(t).forEach(function(n){var s=t[n],i=n.toUpperCase();e.recursive&&(je.isValidObject(s)?je.belongToTypes(s,e.keepTypesOnRecursion)||(s=pr(s,e)):e.recursiveInArray&&je.isArrayObject(s)&&(s=sh(s).map(function(o){var c=o;if(je.isValidObject(o))je.belongToTypes(c,e.keepTypesOnRecursion)||(c=pr(o,e));else if(je.isArrayObject(o)){var u=pr({key:o},e);c=u.key}return c}))),r[i]=s}),r}Cs.default=pr;var js={},ah=we&&we.__spreadArrays||function(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var n=Array(t),s=0,e=0;e<r;e++)for(var i=arguments[e],o=0,c=i.length;o<c;o++,s++)n[s]=i[o];return n};Object.defineProperty(js,"__esModule",{value:!0});var $e=ct,ih=ln;function gr(t,e){if(e===void 0&&(e=$e.DefaultOption),!$e.isValidObject(t))return null;e=$e.validateOptions(e);var r={};return Object.keys(t).forEach(function(n){var s=t[n],i=ih.default(n);e.recursive&&($e.isValidObject(s)?$e.belongToTypes(s,e.keepTypesOnRecursion)||(s=gr(s,e)):e.recursiveInArray&&$e.isArrayObject(s)&&(s=ah(s).map(function(o){var c=o;if($e.isValidObject(o))$e.belongToTypes(c,e.keepTypesOnRecursion)||(c=gr(o,e));else if($e.isArrayObject(o)){var u=gr({key:o},e);c=u.key}return c}))),r[i]=s}),r}js.default=gr;var $s={},oh=we&&we.__spreadArrays||function(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var n=Array(t),s=0,e=0;e<r;e++)for(var i=arguments[e],o=0,c=i.length;o<c;o++,s++)n[s]=i[o];return n};Object.defineProperty($s,"__esModule",{value:!0});var Re=ct,ch=un;function mr(t,e){if(e===void 0&&(e=Re.DefaultOption),!Re.isValidObject(t))return null;e=Re.validateOptions(e);var r={};return Object.keys(t).forEach(function(n){var s=t[n],i=ch.default(n);e.recursive&&(Re.isValidObject(s)?Re.belongToTypes(s,e.keepTypesOnRecursion)||(s=mr(s,e)):e.recursiveInArray&&Re.isArrayObject(s)&&(s=oh(s).map(function(o){var c=o;if(Re.isValidObject(o))Re.belongToTypes(c,e.keepTypesOnRecursion)||(c=mr(o,e));else if(Re.isArrayObject(o)){var u=mr({key:o},e);c=u.key}return c}))),r[i]=s}),r}$s.default=mr;var Rs={},lh=we&&we.__spreadArrays||function(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var n=Array(t),s=0,e=0;e<r;e++)for(var i=arguments[e],o=0,c=i.length;o<c;o++,s++)n[s]=i[o];return n};Object.defineProperty(Rs,"__esModule",{value:!0});var Me=ct,uh=hn;function wr(t,e){if(e===void 0&&(e=Me.DefaultOption),!Me.isValidObject(t))return null;e=Me.validateOptions(e);var r={};return Object.keys(t).forEach(function(n){var s=t[n],i=uh.default(n);e.recursive&&(Me.isValidObject(s)?Me.belongToTypes(s,e.keepTypesOnRecursion)||(s=wr(s,e)):e.recursiveInArray&&Me.isArrayObject(s)&&(s=lh(s).map(function(o){var c=o;if(Me.isValidObject(o))Me.belongToTypes(c,e.keepTypesOnRecursion)||(c=wr(o,e));else if(Me.isArrayObject(o)){var u=wr({key:o},e);c=u.key}return c}))),r[i]=s}),r}Rs.default=wr;var Ms={},hh=we&&we.__spreadArrays||function(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var n=Array(t),s=0,e=0;e<r;e++)for(var i=arguments[e],o=0,c=i.length;o<c;o++,s++)n[s]=i[o];return n};Object.defineProperty(Ms,"__esModule",{value:!0});var Pe=ct,fh=fn;function vr(t,e){if(e===void 0&&(e=Pe.DefaultOption),!Pe.isValidObject(t))return null;e=Pe.validateOptions(e);var r={};return Object.keys(t).forEach(function(n){var s=t[n],i=fh.default(n);e.recursive&&(Pe.isValidObject(s)?Pe.belongToTypes(s,e.keepTypesOnRecursion)||(s=vr(s,e)):e.recursiveInArray&&Pe.isArrayObject(s)&&(s=hh(s).map(function(o){var c=o;if(Pe.isValidObject(o))Pe.belongToTypes(c,e.keepTypesOnRecursion)||(c=vr(o,e));else if(Pe.isArrayObject(o)){var u=vr({key:o},e);c=u.key}return c}))),r[i]=s}),r}Ms.default=vr;Object.defineProperty(N,"__esModule",{value:!0});N.kebabKeys=N.pascalKeys=N.snakeKeys=N.camelKeys=N.upperKeys=N.lowerKeys=N.toLowerCase=N.toUpperCase=N.toKebabCase=N.toHeaderCase=N.toSentenceCase=N.toTextCase=N.toPathCase=N.toDotCase=N.toPascalCase=N.toSnakeCase=N.toCamelCase=void 0;var zi=ln;N.toCamelCase=zi.default;var Si=un;N.toSnakeCase=Si.default;var Ni=hn;N.toPascalCase=Ni.default;var Ai=Ns;N.toDotCase=Ai.default;var Ei=As;N.toPathCase=Ei.default;var Ii=Es;N.toTextCase=Ii.default;var ki=Is;N.toSentenceCase=ki.default;var xi=ks;N.toHeaderCase=xi.default;var Ci=fn;N.toKebabCase=Ci.default;var ji=xs;N.lowerKeys=ji.default;var $i=Cs;N.upperKeys=$i.default;var Ri=js;N.camelKeys=Ri.default;var Mi=$s;N.snakeKeys=Mi.default;var Pi=Rs;N.pascalKeys=Pi.default;var Di=Ms;N.kebabKeys=Di.default;var Ui=function(t){return String(t||"").toLowerCase()};N.toLowerCase=Ui;var Bi=function(t){return String(t||"").toUpperCase()};N.toUpperCase=Bi;var dh={toCamelCase:zi.default,toSnakeCase:Si.default,toPascalCase:Ni.default,toDotCase:Ai.default,toPathCase:Ei.default,toTextCase:Ii.default,toSentenceCase:ki.default,toHeaderCase:xi.default,toKebabCase:Ci.default,toUpperCase:Bi,toLowerCase:Ui,lowerKeys:ji.default,upperKeys:$i.default,camelKeys:Ri.default,snakeKeys:Mi.default,pascalKeys:Pi.default,kebabKeys:Di.default};N.default=dh;var Li=N;const _i={recursive:!0,recursiveInArray:!0,keepTypesOnRecursion:[Number,String,Uint8Array]},yh=t=>Li.snakeKeys(t,_i),ph=t=>Li.camelKeys(t,_i),Yi=t=>t!=null&&typeof t=="object"&&!Array.isArray(t);var gh=Object.defineProperty,mh=(t,e,r)=>e in t?gh(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Mt=(t,e,r)=>(mh(t,typeof e!="symbol"?e+"":e,r),r);let wh=class{constructor(){Mt(this,"contentType","application/json"),Mt(this,"decoder"),Mt(this,"encoder"),this.decoder=new TextDecoder,this.encoder=new TextEncoder}encode(t){return this.encoder.encode(this.encodeString(t)).buffer}decode(t,e){return this.decodeString(this.decoder.decode(t),e)}decodeString(t,e){const r=ph(JSON.parse(t));return e!=null?e.parse(r):r}encodeString(t){return JSON.stringify(yh(t),(e,r)=>ArrayBuffer.isView(r)?Array.from(r):Yi(r)&&"encode_value"in r?typeof r.value=="bigint"?r.value.toString():r.value:typeof r=="bigint"?r.toString():r)}static registerCustomType(){}},vh=class{constructor(){Mt(this,"contentType","text/csv")}encode(t){const e=this.encodeString(t);return new TextEncoder().encode(e).buffer}decode(t,e){const r=new TextDecoder().decode(t);return this.decodeString(r,e)}encodeString(t){if(!Array.isArray(t)||t.length===0||!Yi(t[0]))throw new Error("Payload must be an array of objects");const e=Object.keys(t[0]),r=[e.join(",")];return t.forEach(n=>{const s=e.map(i=>JSON.stringify(n[i]??""));r.push(s.join(","))}),r.join(`
14
- `)}decodeString(t,e){const[r,...n]=t.trim().split(`
15
- `).map(o=>o.trim());if(r.length===0)return e!=null?e.parse({}):{};const s=r.split(",").map(o=>o.trim()),i={};return s.forEach(o=>{i[o]=[]}),n.forEach(o=>{const c=o.split(",").map(u=>u.trim());s.forEach((u,f)=>{const w=this.parseValue(c[f]);w!=null&&i[u].push(w)})}),e!=null?e.parse(i):i}parseValue(t){if(t==null||t.length===0)return null;const e=Number(t);return isNaN(e)?t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1):t:e}static registerCustomType(){}},bh=class{constructor(){Mt(this,"contentType","text/plain")}encode(t){return new TextEncoder().encode(t).buffer}decode(t,e){const r=new TextDecoder().decode(t);return e!=null?e.parse(r):r}};new wh;new vh;new bh;const dn=a.z.tuple([a.z.number(),a.z.number()]);a.z.tuple([a.z.bigint(),a.z.bigint()]);const Zi=a.z.object({width:a.z.number(),height:a.z.number()}),Oh=a.z.object({signedWidth:a.z.number(),signedHeight:a.z.number()}),Th=["width","height"];a.z.enum(Th);const zh=["start","center","end"],Sh=["signedWidth","signedHeight"];a.z.enum(Sh);const Gr=a.z.object({x:a.z.number(),y:a.z.number()}),Nh=a.z.object({clientX:a.z.number(),clientY:a.z.number()}),Ah=["x","y"],qi=a.z.enum(Ah),Fi=["top","right","bottom","left"];a.z.enum(Fi);const Eh=["left","right"],Vi=a.z.enum(Eh),Ih=["top","bottom"],Ki=a.z.enum(Ih),Wi=["center"],ba=a.z.enum(Wi),kh=[...Fi,...Wi],Gi=a.z.enum(kh);a.z.enum(zh);const xh=["first","last"];a.z.enum(xh);const Ch=a.z.object({lower:a.z.number(),upper:a.z.number()}),jh=a.z.object({lower:a.z.bigint(),upper:a.z.bigint()});a.z.union([Ch,dn]);a.z.union([jh,dn]);a.z.union([qi,Gi]);a.z.union([qi,Gi,a.z.instanceof(String)]);const jn=(t,e)=>{const r={};if(typeof t=="number"||typeof t=="bigint")e!=null?(r.lower=t,r.upper=e):(r.lower=typeof t=="bigint"?0n:0,r.upper=t);else if(Array.isArray(t)){if(t.length!==2)throw new Error("bounds: expected array of length 2");[r.lower,r.upper]=t}else return Oa(t);return Oa(r)},Oa=t=>t.lower>t.upper?{lower:t.upper,upper:t.lower}:t;a.z.object({x:Vi.or(ba),y:Ki.or(ba)});const $h=a.z.object({x:Vi,y:Ki}),Rh=Object.freeze({x:"left",y:"top"}),Mh=(t,e)=>t.x===e.x&&t.y===e.y,Ta=a.z.union([a.z.number(),Gr,dn,Zi,Oh,Nh]),Ph=(t,e)=>{if(typeof t=="string"){if(e===void 0)throw new Error("The y coordinate must be given.");return t==="x"?{x:e,y:0}:{x:0,y:e}}return typeof t=="number"?{x:t,y:e??t}:Array.isArray(t)?{x:t[0],y:t[1]}:"signedWidth"in t?{x:t.signedWidth,y:t.signedHeight}:"clientX"in t?{x:t.clientX,y:t.clientY}:"width"in t?{x:t.width,y:t.height}:{x:t.x,y:t.y}},za=Object.freeze({x:0,y:0}),ir=a.z.union([a.z.number(),a.z.string()]);a.z.object({top:ir,left:ir,width:ir,height:ir});a.z.object({left:a.z.number(),top:a.z.number(),right:a.z.number(),bottom:a.z.number()});a.z.object({one:Gr,two:Gr,root:$h});const Ps=(t,e,r=0,n=0,s)=>{const i={one:{...za},two:{...za},root:s??Rh};if(typeof t=="number"){if(typeof e!="number")throw new Error("Box constructor called with invalid arguments");return i.one={x:t,y:e},i.two={x:i.one.x+r,y:i.one.y+n},i}return"one"in t&&"two"in t&&"root"in t?{...t,root:s??t.root}:("getBoundingClientRect"in t&&(t=t.getBoundingClientRect()),"left"in t?(i.one={x:t.left,y:t.top},i.two={x:t.right,y:t.bottom},i):(i.one=t,e==null?i.two={x:i.one.x+r,y:i.one.y+n}:typeof e=="number"?i.two={x:i.one.x+e,y:i.one.y+r}:"width"in e?i.two={x:i.one.x+e.width,y:i.one.y+e.height}:"signedWidth"in e?i.two={x:i.one.x+e.signedWidth,y:i.one.y+e.signedHeight}:i.two=e,i))},$n=t=>{const e=Ps(t);return{lower:e.one.x,upper:e.two.x}},Rn=t=>{const e=Ps(t);return{lower:e.one.y,upper:e.two.y}},Dh=t=>typeof t!="object"||t==null?!1:"one"in t&&"two"in t&&"root"in t;var Uh=Object.defineProperty,Bh=(t,e,r)=>e in t?Uh(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ke=(t,e,r)=>(Bh(t,typeof e!="symbol"?e+"":e,r),r);const Lh=(t,e,r)=>(e!=null&&(t=Math.max(t,e)),r!=null&&(t=Math.min(t,r)),t);a.z.object({offset:Ta,scale:Ta});const _h=t=>(e,r,n,s)=>r==="dimension"?[e,n]:[e,s?n-t:n+t],Yh=t=>(e,r,n,s)=>[e,s?n/t:n*t],Zh=t=>(e,r,n)=>{if(e===null)return[t,n];const{lower:s,upper:i}=e,{lower:o,upper:c}=t,u=i-s,f=c-o;if(r==="dimension")return[t,n*(f/u)];const w=(n-s)*(f/u)+o;return[t,w]},qh=t=>(e,r,n)=>[t,n],Fh=()=>(t,e,r)=>{if(t===null)throw new Error("cannot invert without bounds");if(e==="dimension")return[t,r];const{lower:n,upper:s}=t;return[t,s-(r-n)]},Vh=t=>(e,r,n)=>{const{lower:s,upper:i}=t;return n=Lh(n,s,i),[e,n]},ns=class Nt{constructor(){Ke(this,"ops",[]),Ke(this,"currBounds",null),Ke(this,"currType",null),Ke(this,"reversed",!1),this.ops=[]}static translate(e){return new Nt().translate(e)}static magnify(e){return new Nt().magnify(e)}static scale(e,r){return new Nt().scale(e,r)}translate(e){const r=this.new(),n=_h(e);return n.type="translate",r.ops.push(n),r}magnify(e){const r=this.new(),n=Yh(e);return n.type="magnify",r.ops.push(n),r}scale(e,r){const n=jn(e,r),s=this.new(),i=Zh(n);return i.type="scale",s.ops.push(i),s}clamp(e,r){const n=jn(e,r),s=this.new(),i=Vh(n);return i.type="clamp",s.ops.push(i),s}reBound(e,r){const n=jn(e,r),s=this.new(),i=qh(n);return i.type="re-bound",s.ops.push(i),s}invert(){const e=Fh();e.type="invert";const r=this.new();return r.ops.push(e),r}pos(e){return this.exec("position",e)}dim(e){return this.exec("dimension",e)}new(){const e=new Nt;return e.ops=this.ops.slice(),e.reversed=this.reversed,e}exec(e,r){return this.currBounds=null,this.ops.reduce(([n,s],i)=>i(n,e,s,this.reversed),[null,r])[1]}reverse(){const e=this.new();e.ops.reverse();const r=[];return e.ops.forEach((n,s)=>{if(n.type==="scale"||r.some(([o,c])=>s>=o&&s<=c))return;const i=e.ops.findIndex((o,c)=>o.type==="scale"&&c>s);i!==-1&&r.push([s,i])}),r.forEach(([n,s])=>{const i=e.ops.slice(n,s);i.unshift(e.ops[s]),e.ops.splice(n,s-n+1,...i)}),e.reversed=!e.reversed,e}};Ke(ns,"IDENTITY",new ns);let Sa=ns;const Na=class qe{constructor(e=new Sa,r=new Sa,n=null){Ke(this,"x"),Ke(this,"y"),Ke(this,"currRoot"),this.x=e,this.y=r,this.currRoot=n}static translate(e,r){return new qe().translate(e,r)}static translateX(e){return new qe().translateX(e)}static translateY(e){return new qe().translateY(e)}static clamp(e){return new qe().clamp(e)}static magnify(e){return new qe().magnify(e)}static scale(e){return new qe().scale(e)}static reBound(e){return new qe().reBound(e)}translate(e,r){const n=Ph(e,r),s=this.copy();return s.x=this.x.translate(n.x),s.y=this.y.translate(n.y),s}translateX(e){const r=this.copy();return r.x=this.x.translate(e),r}translateY(e){const r=this.copy();return r.y=this.y.translate(e),r}magnify(e){const r=this.copy();return r.x=this.x.magnify(e.x),r.y=this.y.magnify(e.y),r}scale(e){const r=this.copy();if(Dh(e)){const n=this.currRoot;return r.currRoot=e.root,n!=null&&!Mh(n,e.root)&&(n.x!==e.root.x&&(r.x=r.x.invert()),n.y!==e.root.y&&(r.y=r.y.invert())),r.x=r.x.scale($n(e)),r.y=r.y.scale(Rn(e)),r}return r.x=r.x.scale(e.width),r.y=r.y.scale(e.height),r}reBound(e){const r=this.copy();return r.x=this.x.reBound($n(e)),r.y=this.y.reBound(Rn(e)),r}clamp(e){const r=this.copy();return r.x=this.x.clamp($n(e)),r.y=this.y.clamp(Rn(e)),r}copy(){const e=new qe;return e.currRoot=this.currRoot,e.x=this.x,e.y=this.y,e}reverse(){const e=this.copy();return e.x=this.x.reverse(),e.y=this.y.reverse(),e}pos(e){return{x:this.x.pos(e.x),y:this.y.pos(e.y)}}box(e){return Ps(this.pos(e.one),this.pos(e.two),0,0,this.currRoot??e.root)}};Ke(Na,"IDENTITY",new Na);a.z.record(a.z.union([a.z.number(),a.z.string(),a.z.symbol()]),a.z.unknown());const Ji=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser",Kh=Ji(),Hi=["MacOS","Windows","Linux","Docker"],Wh=a.z.enum(Hi);let Mn;const Gh=()=>{if(typeof window>"u")return;const t=window.navigator.userAgent.toLowerCase();if(t.includes("mac"))return"MacOS";if(t.includes("win"))return"Windows";if(t.includes("linux"))return"Linux"},Jh=(t={})=>{const{force:e,default:r}=t;return e??Mn??(Mn=Gh(),Mn??r)},Xi=Object.freeze(Object.defineProperty({__proto__:null,OPERATING_SYSTEMS:Hi,RUNTIME:Kh,detect:Ji,getOS:Jh,osZ:Wh},Symbol.toStringTag,{value:"Module"})),Hh=a.z.object({signedWidth:a.z.number(),signedHeight:a.z.number()});a.z.union([Zi,Hh,Gr,dn]);var Xh=Object.defineProperty,Qh=(t,e,r)=>e in t?Xh(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,v=(t,e,r)=>(Qh(t,typeof e!="symbol"?e+"":e,r),r);const Qi=(t,e)=>{const r=new re(e);if(![ne.DAY,ne.HOUR,ne.MINUTE,ne.SECOND,ne.MILLISECOND,ne.MICROSECOND,ne.NANOSECOND].some(s=>s.equals(r)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const n=t.valueOf()%r.valueOf();return t instanceof re?new re(n):new ne(n)},_=class z{constructor(e,r="UTC"){if(v(this,"value"),v(this,"encodeValue",!0),e==null)this.value=z.now().valueOf();else if(e instanceof Date)this.value=BigInt(e.getTime())*z.MILLISECOND.valueOf();else if(typeof e=="string")this.value=z.parseDateTimeString(e,r).valueOf();else if(Array.isArray(e))this.value=z.parseDate(e);else{let n=BigInt(0);e instanceof Number&&(e=e.valueOf()),r==="local"&&(n=z.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=z.MAX:e=z.MIN)),this.value=BigInt(e.valueOf())+n}}static parseDate([e=1970,r=1,n=1]){const s=new Date(e,r-1,n,0,0,0,0);return new z(BigInt(s.getTime())*z.MILLISECOND.valueOf()).truncate(z.DAY).valueOf()}encode(){return this.value.toString()}valueOf(){return this.value}static parseTimeString(e,r="UTC"){const[n,s,i]=e.split(":");let o="00",c="00";i!=null&&([o,c]=i.split("."));let u=z.hours(parseInt(n??"00",10)).add(z.minutes(parseInt(s??"00",10))).add(z.seconds(parseInt(o??"00",10))).add(z.milliseconds(parseInt(c??"00",10)));return r==="local"&&(u=u.add(z.utcOffset)),u.valueOf()}static parseDateTimeString(e,r="UTC"){if(!e.includes("/")&&!e.includes("-"))return z.parseTimeString(e,r);const n=new Date(e);return e.includes(":")||n.setUTCHours(0,0,0,0),new z(BigInt(n.getTime())*z.MILLISECOND.valueOf(),r).valueOf()}fString(e="ISO",r="UTC"){switch(e){case"ISODate":return this.toISOString(r).slice(0,10);case"ISOTime":return this.toISOString(r).slice(11,23);case"time":return this.timeString(!1,r);case"preciseTime":return this.timeString(!0,r);case"date":return this.dateString();case"preciseDate":return`${this.dateString()} ${this.timeString(!0,r)}`;case"dateTime":return`${this.dateString()} ${this.timeString(!1,r)}`;default:return this.toISOString(r)}}toISOString(e="UTC"){return e==="UTC"?this.date().toISOString():this.sub(z.utcOffset).date().toISOString()}timeString(e=!1,r="UTC"){const n=this.toISOString(r);return e?n.slice(11,23):n.slice(11,19)}dateString(){const e=this.date(),r=e.toLocaleString("default",{month:"short"}),n=e.toLocaleString("default",{day:"numeric"});return`${r} ${n}`}static get utcOffset(){return new ne(BigInt(new Date().getTimezoneOffset())*z.MINUTE.valueOf())}static since(e){return new z().span(e)}date(){return new Date(this.milliseconds())}equals(e){return this.valueOf()===new z(e).valueOf()}span(e){return this.range(e).span}range(e){return new ef(this,e).makeValid()}spanRange(e){return this.range(this.add(e)).makeValid()}get isZero(){return this.valueOf()===BigInt(0)}after(e){return this.valueOf()>new z(e).valueOf()}afterEq(e){return this.valueOf()>=new z(e).valueOf()}before(e){return this.valueOf()<new z(e).valueOf()}beforeEq(e){return this.valueOf()<=new z(e).valueOf()}add(e){return new z(this.valueOf()+BigInt(e.valueOf()))}sub(e){return new z(this.valueOf()-BigInt(e.valueOf()))}milliseconds(){return Number(this.valueOf())/Number(z.MILLISECOND.valueOf())}toString(){return this.date().toISOString()}remainder(e){return Qi(this,e)}get isToday(){return this.truncate(ne.DAY).equals(z.now().truncate(ne.DAY))}truncate(e){return this.sub(this.remainder(e))}static now(){return new z(new Date)}static max(...e){let r=z.MIN;for(const n of e){const s=new z(n);s.after(r)&&(r=s)}return r}static min(...e){let r=z.MAX;for(const n of e){const s=new z(n);s.before(r)&&(r=s)}return r}static nanoseconds(e){return new z(e)}static microseconds(e){return z.nanoseconds(e*1e3)}static milliseconds(e){return z.microseconds(e*1e3)}static seconds(e){return z.milliseconds(e*1e3)}static minutes(e){return z.seconds(e*60)}static hours(e){return z.minutes(e*60)}static days(e){return z.hours(e*24)}};v(_,"NANOSECOND",_.nanoseconds(1)),v(_,"MICROSECOND",_.microseconds(1)),v(_,"MILLISECOND",_.milliseconds(1)),v(_,"SECOND",_.seconds(1)),v(_,"MINUTE",_.minutes(1)),v(_,"HOUR",_.hours(1)),v(_,"DAY",_.days(1)),v(_,"MAX",new _((1n<<63n)-1n)),v(_,"MIN",new _(0)),v(_,"ZERO",new _(0)),v(_,"z",a.z.union([a.z.object({value:a.z.bigint()}).transform(t=>new _(t.value)),a.z.string().transform(t=>new _(BigInt(t))),a.z.instanceof(Number).transform(t=>new _(t)),a.z.number().transform(t=>new _(t)),a.z.instanceof(_)]));let re=_;const Y=class j{constructor(e){v(this,"value"),v(this,"encodeValue",!0),typeof e=="number"&&(e=Math.trunc(e.valueOf())),this.value=BigInt(e.valueOf())}encode(){return this.value.toString()}valueOf(){return this.value}lessThan(e){return this.valueOf()<new j(e).valueOf()}greaterThan(e){return this.valueOf()>new j(e).valueOf()}lessThanOrEqual(e){return this.valueOf()<=new j(e).valueOf()}greaterThanOrEqual(e){return this.valueOf()>=new j(e).valueOf()}remainder(e){return Qi(this,e)}truncate(e){return new j(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(){const e=this.truncate(j.DAY),r=this.truncate(j.HOUR),n=this.truncate(j.MINUTE),s=this.truncate(j.SECOND),i=this.truncate(j.MILLISECOND),o=this.truncate(j.MICROSECOND),c=this.truncate(j.NANOSECOND),u=e,f=r.sub(e),w=n.sub(r),h=s.sub(n),D=i.sub(s),V=o.sub(i),se=c.sub(o);let R="";return u.isZero||(R+=`${u.days}d `),f.isZero||(R+=`${f.hours}h `),w.isZero||(R+=`${w.minutes}m `),h.isZero||(R+=`${h.seconds}s `),D.isZero||(R+=`${D.milliseconds}ms `),V.isZero||(R+=`${V.microseconds}µs `),se.isZero||(R+=`${se.nanoseconds}ns`),R.trim()}get days(){return Number(this.valueOf())/Number(j.DAY.valueOf())}get hours(){return Number(this.valueOf())/Number(j.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(j.MINUTE.valueOf())}get seconds(){return Number(this.valueOf())/Number(j.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(j.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(j.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===BigInt(0)}equals(e){return this.valueOf()===new j(e).valueOf()}add(e){return new j(this.valueOf()+new j(e).valueOf())}sub(e){return new j(this.valueOf()-new j(e).valueOf())}static nanoseconds(e=1){return new j(e)}static microseconds(e=1){return j.nanoseconds(e*1e3)}static milliseconds(e=1){return j.microseconds(e*1e3)}static seconds(e=1){return j.milliseconds(e*1e3)}static minutes(e){return j.seconds(e.valueOf()*60)}static hours(e){return j.minutes(e*60)}static days(e){return j.hours(e*24)}};v(Y,"NANOSECOND",Y.nanoseconds(1)),v(Y,"MICROSECOND",Y.microseconds(1)),v(Y,"MILLISECOND",Y.milliseconds(1)),v(Y,"SECOND",Y.seconds(1)),v(Y,"MINUTE",Y.minutes(1)),v(Y,"HOUR",Y.hours(1)),v(Y,"DAY",Y.days(1)),v(Y,"MAX",new Y((1n<<63n)-1n)),v(Y,"MIN",new Y(0)),v(Y,"ZERO",new Y(0)),v(Y,"z",a.z.union([a.z.object({value:a.z.bigint()}).transform(t=>new Y(t.value)),a.z.string().transform(t=>new Y(BigInt(t))),a.z.instanceof(Number).transform(t=>new Y(t)),a.z.number().transform(t=>new Y(t)),a.z.instanceof(Y)]));let ne=Y;const or=class br extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new br(e).valueOf()}get period(){return ne.seconds(1/this.valueOf())}sampleCount(e){return new ne(e).seconds*this.valueOf()}byteCount(e,r){return this.sampleCount(e)*new he(r).valueOf()}span(e){return ne.seconds(e/this.valueOf())}byteSpan(e,r){return this.span(e.valueOf()/r.valueOf())}static hz(e){return new br(e)}static khz(e){return br.hz(e*1e3)}};v(or,"z",a.z.union([a.z.number().transform(t=>new or(t)),a.z.instanceof(Number).transform(t=>new or(t)),a.z.instanceof(or)]));const ee=class extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}length(e){return e.valueOf()/this.valueOf()}size(e){return new tf(e*this.valueOf())}};v(ee,"UNKNOWN",new ee(0)),v(ee,"BIT128",new ee(16)),v(ee,"BIT64",new ee(8)),v(ee,"BIT32",new ee(4)),v(ee,"BIT16",new ee(2)),v(ee,"BIT8",new ee(1)),v(ee,"z",a.z.union([a.z.number().transform(t=>new ee(t)),a.z.instanceof(Number).transform(t=>new ee(t)),a.z.instanceof(ee)]));let he=ee;const Ne=class Or{constructor(e,r){v(this,"start"),v(this,"end"),typeof e=="object"&&"start"in e?(this.start=new re(e.start),this.end=new re(e.end)):(this.start=new re(e),this.end=new re(r))}get span(){return new ne(this.end.valueOf()-this.start.valueOf())}get isValid(){return this.start.valueOf()<=this.end.valueOf()}makeValid(){return this.isValid?this:this.swap()}get isZero(){return this.span.isZero}swap(){return new Or(this.end,this.start)}equals(e){return this.start.equals(e.start)&&this.end.equals(e.end)}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.fString("preciseDate")} - ${this.span.toString()}`}overlapsWith(e,r=ne.ZERO){e=e.makeValid();const n=this.makeValid();if(this.equals(e))return!0;if(e.end.equals(n.start)||n.end.equals(e.start))return!1;const s=re.max(n.start,e.start),i=re.min(n.end,e.end);return i.before(s)?!1:new ne(i.sub(s)).greaterThanOrEqual(r)}roughlyEquals(e,r){let n=this.start.sub(e.start).valueOf(),s=this.end.sub(e.end).valueOf();return n<0&&(n=-n),s<0&&(s=-s),n<=r.valueOf()&&s<=r.valueOf()}contains(e){return e instanceof Or?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const r=new Or(this.start,this.end);return e.start.after(this.start)&&(r.start=e.start),e.start.after(this.end)&&(r.end=e.start),e.end.before(this.end)&&(r.end=e.end),e.end.before(this.start)&&(r.start=e.end),r}};v(Ne,"MAX",new Ne(re.MIN,re.MAX)),v(Ne,"MIN",new Ne(re.MAX,re.MIN)),v(Ne,"ZERO",new Ne(re.ZERO,re.ZERO)),v(Ne,"z",a.z.union([a.z.object({start:re.z,end:re.z}).transform(t=>new Ne(t.start,t.end)),a.z.instanceof(Ne)]));let ef=Ne;const p=class Ae extends String{constructor(e){if(e instanceof Ae||typeof e=="string"||typeof e.valueOf()=="string"){super(e.valueOf());return}else{const r=Ae.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(r!=null){super(r.valueOf());return}}throw super(Ae.UNKNOWN.valueOf()),new Error(`unable to find data type for ${e.toString()}`)}get Array(){const e=Ae.ARRAY_CONSTRUCTORS.get(this.toString());if(e==null)throw new Error(`unable to find array constructor for ${this.valueOf()}`);return e}equals(e){return this.valueOf()===e.valueOf()}toString(){return this.valueOf()}get isVariable(){return this.equals(Ae.JSON)||this.equals(Ae.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(Ae.UUID)}get isInteger(){return this.toString().startsWith("int")}get isFloat(){return this.toString().startsWith("float")}get density(){const e=Ae.DENSITIES.get(this.toString());if(e==null)throw new Error(`unable to find density for ${this.valueOf()}`);return e}canSafelyCastTo(e){return this.equals(e)?!0:this.isVariable&&!e.isVariable||!this.isVariable&&e.isVariable?!1:this.isFloat&&e.isInteger||this.isInteger&&e.isFloat?this.density.valueOf()<e.density.valueOf():this.isFloat&&e.isFloat||this.isInteger&&e.isInteger?this.density.valueOf()<=e.density.valueOf():!1}canCastTo(e){return this.isNumeric&&e.isNumeric?!0:this.equals(e)}checkArray(e){return e.constructor===this.Array}toJSON(){return this.toString()}get usesBigInt(){return Ae.BIG_INT_TYPES.some(e=>e.equals(this))}};v(p,"UNKNOWN",new p("unknown")),v(p,"FLOAT64",new p("float64")),v(p,"FLOAT32",new p("float32")),v(p,"INT64",new p("int64")),v(p,"INT32",new p("int32")),v(p,"INT16",new p("int16")),v(p,"INT8",new p("int8")),v(p,"UINT64",new p("uint64")),v(p,"UINT32",new p("uint32")),v(p,"UINT16",new p("uint16")),v(p,"UINT8",new p("uint8")),v(p,"BOOLEAN",p.UINT8),v(p,"TIMESTAMP",new p("timestamp")),v(p,"UUID",new p("uuid")),v(p,"STRING",new p("string")),v(p,"JSON",new p("json")),v(p,"ARRAY_CONSTRUCTORS",new Map([[p.UINT8.toString(),Uint8Array],[p.UINT16.toString(),Uint16Array],[p.UINT32.toString(),Uint32Array],[p.UINT64.toString(),BigUint64Array],[p.FLOAT32.toString(),Float32Array],[p.FLOAT64.toString(),Float64Array],[p.INT8.toString(),Int8Array],[p.INT16.toString(),Int16Array],[p.INT32.toString(),Int32Array],[p.INT64.toString(),BigInt64Array],[p.TIMESTAMP.toString(),BigInt64Array],[p.STRING.toString(),Uint8Array],[p.JSON.toString(),Uint8Array],[p.UUID.toString(),Uint8Array]])),v(p,"ARRAY_CONSTRUCTOR_DATA_TYPES",new Map([[Uint8Array.name,p.UINT8],[Uint16Array.name,p.UINT16],[Uint32Array.name,p.UINT32],[BigUint64Array.name,p.UINT64],[Float32Array.name,p.FLOAT32],[Float64Array.name,p.FLOAT64],[Int8Array.name,p.INT8],[Int16Array.name,p.INT16],[Int32Array.name,p.INT32],[BigInt64Array.name,p.INT64]])),v(p,"DENSITIES",new Map([[p.UINT8.toString(),he.BIT8],[p.UINT16.toString(),he.BIT16],[p.UINT32.toString(),he.BIT32],[p.UINT64.toString(),he.BIT64],[p.FLOAT32.toString(),he.BIT32],[p.FLOAT64.toString(),he.BIT64],[p.INT8.toString(),he.BIT8],[p.INT16.toString(),he.BIT16],[p.INT32.toString(),he.BIT32],[p.INT64.toString(),he.BIT64],[p.TIMESTAMP.toString(),he.BIT64],[p.STRING.toString(),he.UNKNOWN],[p.JSON.toString(),he.UNKNOWN],[p.UUID.toString(),he.BIT128]])),v(p,"ALL",[p.UNKNOWN,p.FLOAT64,p.FLOAT32,p.INT64,p.INT32,p.INT16,p.INT8,p.UINT64,p.UINT32,p.UINT16,p.UINT8,p.TIMESTAMP,p.UUID,p.STRING,p.JSON]),v(p,"BIG_INT_TYPES",[p.INT64,p.UINT64,p.TIMESTAMP]),v(p,"z",a.z.union([a.z.string().transform(t=>new p(t)),a.z.instanceof(p)]));const ie=class J extends Number{constructor(e){super(e.valueOf())}largerThan(e){return this.valueOf()>e.valueOf()}smallerThan(e){return this.valueOf()<e.valueOf()}add(e){return J.bytes(this.valueOf()+e.valueOf())}sub(e){return J.bytes(this.valueOf()-e.valueOf())}truncate(e){return new J(Math.trunc(this.valueOf()/e.valueOf())*e.valueOf())}remainder(e){return J.bytes(this.valueOf()%e.valueOf())}get gigabytes(){return this.valueOf()/J.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/J.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/J.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/J.TERABYTE.valueOf()}toString(){const e=this.truncate(J.TERABYTE),r=this.truncate(J.GIGABYTE),n=this.truncate(J.MEGABYTE),s=this.truncate(J.KILOBYTE),i=this.truncate(J.BYTE),o=e,c=r.sub(e),u=n.sub(r),f=s.sub(n),w=i.sub(s);let h="";return o.isZero||(h+=`${o.terabytes}TB `),c.isZero||(h+=`${c.gigabytes}GB `),u.isZero||(h+=`${u.megabytes}MB `),f.isZero||(h+=`${f.kilobytes}KB `),(!w.isZero||h==="")&&(h+=`${w.valueOf()}B`),h.trim()}static bytes(e=1){return new J(e)}static kilobytes(e=1){return J.bytes(e.valueOf()*1e3)}static megabytes(e=1){return J.kilobytes(e.valueOf()*1e3)}static gigabytes(e=1){return J.megabytes(e.valueOf()*1e3)}static terabytes(e){return J.gigabytes(e.valueOf()*1e3)}get isZero(){return this.valueOf()===0}};v(ie,"BYTE",new ie(1)),v(ie,"KILOBYTE",ie.kilobytes(1)),v(ie,"MEGABYTE",ie.megabytes(1)),v(ie,"GIGABYTE",ie.gigabytes(1)),v(ie,"TERABYTE",ie.terabytes(1)),v(ie,"ZERO",new ie(0)),v(ie,"z",a.z.union([a.z.number().transform(t=>new ie(t)),a.z.instanceof(ie)]));let tf=ie;a.z.union([a.z.instanceof(Uint8Array),a.z.instanceof(Uint16Array),a.z.instanceof(Uint32Array),a.z.instanceof(BigUint64Array),a.z.instanceof(Float32Array),a.z.instanceof(Float64Array),a.z.instanceof(Int8Array),a.z.instanceof(Int16Array),a.z.instanceof(Int32Array),a.z.instanceof(BigInt64Array)]);var rf=Object.defineProperty,nf=(t,e,r)=>e in t?rf(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,At=(t,e,r)=>(nf(t,typeof e!="symbol"?e+"":e,r),r);const sf=(...t)=>t.map(eo).join(""),eo=t=>(t.endsWith("/")||(t+="/"),t.startsWith("/")&&(t=t.slice(1)),t),af=t=>t.endsWith("/")?t.slice(0,-1):t,of=(t,e="")=>t===null?"":"?"+Object.entries(t).filter(([,r])=>r==null?!1:Array.isArray(r)?r.length>0:!0).map(([r,n])=>`${e}${r}=${n}`).join("&"),ss=class as{constructor({host:e,port:r,protocol:n="",pathPrefix:s=""}){At(this,"protocol"),At(this,"host"),At(this,"port"),At(this,"path"),this.protocol=n,this.host=e,this.port=r,this.path=eo(s)}replace(e){return new as({host:e.host??this.host,port:e.port??this.port,protocol:e.protocol??this.protocol,pathPrefix:e.pathPrefix??this.path})}child(e){return new as({...this,pathPrefix:sf(this.path,e)})}toString(){return af(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}};At(ss,"UNKNOWN",new ss({host:"unknown",port:0}));let cf=ss;var lf=Object.defineProperty,uf=(t,e,r)=>e in t?lf(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Pn=(t,e,r)=>(uf(t,typeof e!="symbol"?e+"":e,r),r);const ht=class extends Number{};Pn(ht,"Absolute",255),Pn(ht,"Default",1),Pn(ht,"z",a.z.union([a.z.instanceof(ht),a.z.number().int().min(0).max(255).transform(t=>new ht(t)),a.z.instanceof(Number).transform(t=>new ht(t))]));a.z.object({name:a.z.string(),key:a.z.string()});a.z.string().regex(/^\d+\.\d+\.\d+$/);const de=t=>e=>e!=null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"?e.type.includes(t):e instanceof Error?e.message.includes(t):typeof e!="string"?!1:e.includes(t);let Te=class extends Error{constructor(e){super(e),M(this,"discriminator","FreighterError"),M(this,"type","")}};const hf=t=>{if(t==null||typeof t!="object")return!1;const e=t;if(e.discriminator!=="FreighterError")return!1;if(!("type"in e))throw new Error(`Freighter error is missing its type property: ${JSON.stringify(e)}`);return!0},Aa="unknown",Ea="nil",ff="freighter",Gt=a.z.object({type:a.z.string(),data:a.z.string()});class df{constructor(){M(this,"providers",[])}register(e){this.providers.push(e)}encode(e){if(e==null)return{type:Ea,data:""};if(hf(e))for(const r of this.providers){const n=r.encode(e);if(n!=null)return n}return{type:Aa,data:JSON.stringify(e)}}decode(e){if(e==null||e.type===Ea)return null;if(e.type===Aa)return new Ia(e.data);for(const r of this.providers){const n=r.decode(e);if(n!=null)return n}return new Ia(e.data)}}const to=new df,ro=({encode:t,decode:e})=>to.register({encode:t,decode:e}),Ds=t=>to.decode(t);class Ia extends Te{constructor(e){super(e),M(this,"type","unknown")}}const yn="freighter.",Tr=class no extends Te{constructor(){super("EOF"),M(this,"type",no.TYPE)}};M(Tr,"TYPE",yn+"eof"),M(Tr,"matches",de(Tr.TYPE));let Xe=Tr;const zr=class so extends Te{constructor(){super("StreamClosed"),M(this,"type",so.TYPE)}};M(zr,"TYPE",yn+"stream_closed"),M(zr,"matches",de(zr.TYPE));let dt=zr;const Sr=class ao extends Te{constructor(e={}){const{message:r="Unreachable",url:n=cf.UNKNOWN}=e;super(r),M(this,"type",ao.TYPE),M(this,"url"),this.url=n}};M(Sr,"TYPE",yn+"unreachable"),M(Sr,"matches",de(Sr.TYPE));let ot=Sr;const yf=t=>{if(!t.type.startsWith(ff))return null;if(Xe.matches(t))return{type:Xe.TYPE,data:"EOF"};if(dt.matches(t))return{type:dt.TYPE,data:"StreamClosed"};if(ot.matches(t))return{type:ot.TYPE,data:"Unreachable"};throw new Error(`Unknown error type: ${t.type}: ${t.message}`)},pf=t=>{if(!t.type.startsWith(yn))return null;switch(t.type){case Xe.TYPE:return new Xe;case dt.TYPE:return new dt;case ot.TYPE:return new ot;default:throw new Error(`Unknown error type: ${t.data}`)}};ro({encode:yf,decode:pf});class io{constructor(){M(this,"middleware",[])}use(...e){this.middleware.push(...e)}async executeMiddleware(e,r){let n=0;const s=async i=>{if(n===this.middleware.length)return await r(i);const o=this.middleware[n];return n++,await o(i,s)};return await s(e)}}const oo="Content-Type",ka=t=>{if(Xi.RUNTIME!=="node")return fetch;const e=require("node-fetch");if(t==="http")return e;const r=require("https"),n=new r.Agent({rejectUnauthorized:!1});return async(s,i)=>await e(s,{...i,agent:n})};class gf extends io{constructor(e,r,n=!1){return super(),M(this,"endpoint"),M(this,"encoder"),M(this,"fetch"),this.endpoint=e.replace({protocol:n?"https":"http"}),this.encoder=r,this.fetch=ka(this.endpoint.protocol),new Proxy(this,{get:(s,i,o)=>i==="endpoint"?this.endpoint:Reflect.get(s,i,o)})}get headers(){return{[oo]:this.encoder.contentType}}async send(e,r,n,s){r=n==null?void 0:n.parse(r);let i=null;const o=this.endpoint.child(e),c={};c.method="POST",c.body=this.encoder.encode(r??{});const[,u]=await this.executeMiddleware({target:o.toString(),protocol:this.endpoint.protocol,params:{},role:"client"},async f=>{const w={...f,params:{}};c.headers={...this.headers,...f.params};let h;try{h=await ka(f.protocol)(f.target,c)}catch(V){let se=V;return se.message==="Load failed"&&(se=new ot({url:o})),[w,se]}const D=await h.arrayBuffer();if(h!=null&&h.ok)return s!=null&&(i=this.encoder.decode(D,s)),[w,null];try{if(h.status!==400)return[w,new Error(h.statusText)];const V=this.encoder.decode(D,Gt),se=Ds(V);return[w,se]}catch(V){return[w,new Error(`[freighter] - failed to decode error: ${h.statusText}: ${V.message}`)]}});return[i,u]}}const b=async(t,e,r,n,s)=>{const[i,o]=await t.send(e,r,n,s);if(o!=null)throw o;return i},mf=()=>Xi.RUNTIME!=="node"?t=>new WebSocket(t):t=>new(require("ws")).WebSocket(t,{rejectUnauthorized:!1}),wf=a.z.object({type:a.z.union([a.z.literal("data"),a.z.literal("close")]),payload:a.z.unknown().optional(),error:a.z.optional(Gt)});class vf{constructor(e,r,n,s){M(this,"encoder"),M(this,"reqSchema"),M(this,"resSchema"),M(this,"ws"),M(this,"serverClosed"),M(this,"sendClosed"),M(this,"receiveDataQueue",[]),M(this,"receiveCallbacksQueue",[]),this.encoder=r,this.reqSchema=n,this.resSchema=s,this.ws=e,this.sendClosed=!1,this.serverClosed=null,this.listenForMessages()}send(e){if(this.serverClosed!=null)return new Xe;if(this.sendClosed)throw new dt;return this.ws.send(this.encoder.encode({type:"data",payload:e})),null}async receive(){if(this.serverClosed!=null)return[null,this.serverClosed];const e=await this.receiveMsg();if(e.type==="close"){if(e.error==null)throw new Error("Message error must be defined");return this.serverClosed=Ds(e.error),[null,this.serverClosed]}return[this.resSchema.parse(e.payload),null]}received(){return this.receiveDataQueue.length!==0}closeSend(){if(this.sendClosed||this.serverClosed!=null)return;const e={type:"close"};try{this.ws.send(this.encoder.encode(e))}finally{this.sendClosed=!0}}async receiveMsg(){return this.receiveDataQueue.shift()??await new Promise((e,r)=>this.receiveCallbacksQueue.push({resolve:e,reject:r}))}addMessage(e){const r=this.receiveCallbacksQueue.shift();r!=null?r.resolve(e):this.receiveDataQueue.push(e)}listenForMessages(){this.ws.onmessage=e=>this.addMessage(this.encoder.decode(e.data,wf)),this.ws.onclose=e=>this.addMessage({type:"close",error:{type:Sf(e)?Xe.TYPE:dt.TYPE,data:""}})}}const bf="freighterctx",Of=1e3,Tf=1001,zf=[Of,Tf],Sf=t=>zf.includes(t.code),co=class lo extends io{constructor(e,r,n=!1){super(),M(this,"baseUrl"),M(this,"encoder"),this.baseUrl=e.replace({protocol:n?"wss":"ws"}),this.encoder=r}async stream(e,r,n){const s=mf();let i;const[,o]=await this.executeMiddleware({target:e,protocol:"websocket",params:{},role:"client"},async c=>{const u=s(this.buildURL(e,c)),f={...c,params:{}};u.binaryType=lo.MESSAGE_TYPE;const w=await this.wrapSocket(u,r,n);return w instanceof Error?[f,w]:(i=w,[f,null])});if(o!=null)throw o;return i}buildURL(e,r){const n=of({[oo]:this.encoder.contentType,...r.params},bf);return this.baseUrl.child(e).toString()+n}async wrapSocket(e,r,n){return await new Promise(s=>{e.onopen=()=>{s(new vf(e,this.encoder,r,n))},e.onerror=i=>{const o=i;s(new Error(o.message))}})}};M(co,"MESSAGE_TYPE","arraybuffer");let Nf=co;var ve=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},A={},pn={};Object.defineProperty(pn,"__esModule",{value:!0});function Af(t){return t===void 0&&(t=""),t?String(t).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/[^A-Za-z0-9]+/g,"$").replace(/([a-z])([A-Z])/g,function(e,r,n){return r+"$"+n}).toLowerCase().replace(/(\$)(\w)/g,function(e,r,n){return n.toUpperCase()}):""}pn.default=Af;var gn={};Object.defineProperty(gn,"__esModule",{value:!0});function Ef(t){return t===void 0&&(t=""),t?String(t).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,r,n){return r+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"_").toLowerCase():""}gn.default=Ef;var mn={};Object.defineProperty(mn,"__esModule",{value:!0});function If(t){return t===void 0&&(t=""),t?String(t).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"$").replace(/[^A-Za-z0-9]+/g,"$").replace(/([a-z])([A-Z])/g,function(e,r,n){return r+"$"+n}).toLowerCase().replace(/(\$)(\w?)/g,function(e,r,n){return n.toUpperCase()}):""}mn.default=If;var Us={};Object.defineProperty(Us,"__esModule",{value:!0});function kf(t){return t===void 0&&(t=""),t?String(t).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,r,n){return r+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,".").toLowerCase():""}Us.default=kf;var Bs={};Object.defineProperty(Bs,"__esModule",{value:!0});function xf(t){return t===void 0&&(t=""),t?String(t).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,r,n){return r+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"/").toLowerCase():""}Bs.default=xf;var Ls={};Object.defineProperty(Ls,"__esModule",{value:!0});function Cf(t){return t===void 0&&(t=""),t?String(t).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,r,n){return r+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase():""}Ls.default=Cf;var _s={};Object.defineProperty(_s,"__esModule",{value:!0});function jf(t){if(t===void 0&&(t=""),!t)return"";var e=String(t).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(r,n,s){return n+"_"+s.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase();return e.charAt(0).toUpperCase()+e.slice(1)}_s.default=jf;var Ys={};Object.defineProperty(Ys,"__esModule",{value:!0});function $f(t){return t===void 0&&(t=""),t?String(t).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,r,n){return r+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase().replace(/( ?)(\w+)( ?)/g,function(e,r,n,s){return r+n.charAt(0).toUpperCase()+n.slice(1)+s}):""}Ys.default=$f;var wn={};Object.defineProperty(wn,"__esModule",{value:!0});function Rf(t){return t===void 0&&(t=""),t?String(t).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,r,n){return r+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"-").toLowerCase():""}wn.default=Rf;var Zs={},lt={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.belongToTypes=t.isValidObject=t.isArrayObject=t.validateOptions=t.DefaultOption=void 0,t.DefaultOption={recursive:!1,recursiveInArray:!1,keepTypesOnRecursion:[]},t.validateOptions=function(e){return e===void 0&&(e=t.DefaultOption),e.recursive==null?e=t.DefaultOption:e.recursiveInArray==null&&(e.recursiveInArray=!1),e},t.isArrayObject=function(e){return e!=null&&Array.isArray(e)},t.isValidObject=function(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)},t.belongToTypes=function(e,r){return(r||[]).some(function(n){return e instanceof n})}})(lt);var Mf=ve&&ve.__spreadArrays||function(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var n=Array(t),s=0,e=0;e<r;e++)for(var i=arguments[e],o=0,c=i.length;o<c;o++,s++)n[s]=i[o];return n};Object.defineProperty(Zs,"__esModule",{value:!0});var De=lt;function Nr(t,e){if(e===void 0&&(e=De.DefaultOption),!De.isValidObject(t))return null;e=De.validateOptions(e);var r={};return Object.keys(t).forEach(function(n){var s=t[n],i=n.toLowerCase();e.recursive&&(De.isValidObject(s)?De.belongToTypes(s,e.keepTypesOnRecursion)||(s=Nr(s,e)):e.recursiveInArray&&De.isArrayObject(s)&&(s=Mf(s).map(function(o){var c=o;if(De.isValidObject(o))De.belongToTypes(c,e.keepTypesOnRecursion)||(c=Nr(o,e));else if(De.isArrayObject(o)){var u=Nr({key:o},e);c=u.key}return c}))),r[i]=s}),r}Zs.default=Nr;var qs={},Pf=ve&&ve.__spreadArrays||function(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var n=Array(t),s=0,e=0;e<r;e++)for(var i=arguments[e],o=0,c=i.length;o<c;o++,s++)n[s]=i[o];return n};Object.defineProperty(qs,"__esModule",{value:!0});var Ue=lt;function Ar(t,e){if(e===void 0&&(e=Ue.DefaultOption),!Ue.isValidObject(t))return null;e=Ue.validateOptions(e);var r={};return Object.keys(t).forEach(function(n){var s=t[n],i=n.toUpperCase();e.recursive&&(Ue.isValidObject(s)?Ue.belongToTypes(s,e.keepTypesOnRecursion)||(s=Ar(s,e)):e.recursiveInArray&&Ue.isArrayObject(s)&&(s=Pf(s).map(function(o){var c=o;if(Ue.isValidObject(o))Ue.belongToTypes(c,e.keepTypesOnRecursion)||(c=Ar(o,e));else if(Ue.isArrayObject(o)){var u=Ar({key:o},e);c=u.key}return c}))),r[i]=s}),r}qs.default=Ar;var Fs={},Df=ve&&ve.__spreadArrays||function(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var n=Array(t),s=0,e=0;e<r;e++)for(var i=arguments[e],o=0,c=i.length;o<c;o++,s++)n[s]=i[o];return n};Object.defineProperty(Fs,"__esModule",{value:!0});var Be=lt,Uf=pn;function Er(t,e){if(e===void 0&&(e=Be.DefaultOption),!Be.isValidObject(t))return null;e=Be.validateOptions(e);var r={};return Object.keys(t).forEach(function(n){var s=t[n],i=Uf.default(n);e.recursive&&(Be.isValidObject(s)?Be.belongToTypes(s,e.keepTypesOnRecursion)||(s=Er(s,e)):e.recursiveInArray&&Be.isArrayObject(s)&&(s=Df(s).map(function(o){var c=o;if(Be.isValidObject(o))Be.belongToTypes(c,e.keepTypesOnRecursion)||(c=Er(o,e));else if(Be.isArrayObject(o)){var u=Er({key:o},e);c=u.key}return c}))),r[i]=s}),r}Fs.default=Er;var Vs={},Bf=ve&&ve.__spreadArrays||function(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var n=Array(t),s=0,e=0;e<r;e++)for(var i=arguments[e],o=0,c=i.length;o<c;o++,s++)n[s]=i[o];return n};Object.defineProperty(Vs,"__esModule",{value:!0});var Le=lt,Lf=gn;function Ir(t,e){if(e===void 0&&(e=Le.DefaultOption),!Le.isValidObject(t))return null;e=Le.validateOptions(e);var r={};return Object.keys(t).forEach(function(n){var s=t[n],i=Lf.default(n);e.recursive&&(Le.isValidObject(s)?Le.belongToTypes(s,e.keepTypesOnRecursion)||(s=Ir(s,e)):e.recursiveInArray&&Le.isArrayObject(s)&&(s=Bf(s).map(function(o){var c=o;if(Le.isValidObject(o))Le.belongToTypes(c,e.keepTypesOnRecursion)||(c=Ir(o,e));else if(Le.isArrayObject(o)){var u=Ir({key:o},e);c=u.key}return c}))),r[i]=s}),r}Vs.default=Ir;var Ks={},_f=ve&&ve.__spreadArrays||function(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var n=Array(t),s=0,e=0;e<r;e++)for(var i=arguments[e],o=0,c=i.length;o<c;o++,s++)n[s]=i[o];return n};Object.defineProperty(Ks,"__esModule",{value:!0});var _e=lt,Yf=mn;function kr(t,e){if(e===void 0&&(e=_e.DefaultOption),!_e.isValidObject(t))return null;e=_e.validateOptions(e);var r={};return Object.keys(t).forEach(function(n){var s=t[n],i=Yf.default(n);e.recursive&&(_e.isValidObject(s)?_e.belongToTypes(s,e.keepTypesOnRecursion)||(s=kr(s,e)):e.recursiveInArray&&_e.isArrayObject(s)&&(s=_f(s).map(function(o){var c=o;if(_e.isValidObject(o))_e.belongToTypes(c,e.keepTypesOnRecursion)||(c=kr(o,e));else if(_e.isArrayObject(o)){var u=kr({key:o},e);c=u.key}return c}))),r[i]=s}),r}Ks.default=kr;var Ws={},Zf=ve&&ve.__spreadArrays||function(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var n=Array(t),s=0,e=0;e<r;e++)for(var i=arguments[e],o=0,c=i.length;o<c;o++,s++)n[s]=i[o];return n};Object.defineProperty(Ws,"__esModule",{value:!0});var Ye=lt,qf=wn;function xr(t,e){if(e===void 0&&(e=Ye.DefaultOption),!Ye.isValidObject(t))return null;e=Ye.validateOptions(e);var r={};return Object.keys(t).forEach(function(n){var s=t[n],i=qf.default(n);e.recursive&&(Ye.isValidObject(s)?Ye.belongToTypes(s,e.keepTypesOnRecursion)||(s=xr(s,e)):e.recursiveInArray&&Ye.isArrayObject(s)&&(s=Zf(s).map(function(o){var c=o;if(Ye.isValidObject(o))Ye.belongToTypes(c,e.keepTypesOnRecursion)||(c=xr(o,e));else if(Ye.isArrayObject(o)){var u=xr({key:o},e);c=u.key}return c}))),r[i]=s}),r}Ws.default=xr;Object.defineProperty(A,"__esModule",{value:!0});A.kebabKeys=A.pascalKeys=A.snakeKeys=A.camelKeys=A.upperKeys=A.lowerKeys=A.toLowerCase=A.toUpperCase=A.toKebabCase=A.toHeaderCase=A.toSentenceCase=A.toTextCase=A.toPathCase=A.toDotCase=A.toPascalCase=A.toSnakeCase=A.toCamelCase=void 0;var uo=pn;A.toCamelCase=uo.default;var ho=gn;A.toSnakeCase=ho.default;var fo=mn;A.toPascalCase=fo.default;var yo=Us;A.toDotCase=yo.default;var po=Bs;A.toPathCase=po.default;var go=Ls;A.toTextCase=go.default;var mo=_s;A.toSentenceCase=mo.default;var wo=Ys;A.toHeaderCase=wo.default;var vo=wn;A.toKebabCase=vo.default;var bo=Zs;A.lowerKeys=bo.default;var Oo=qs;A.upperKeys=Oo.default;var To=Fs;A.camelKeys=To.default;var zo=Vs;A.snakeKeys=zo.default;var So=Ks;A.pascalKeys=So.default;var No=Ws;A.kebabKeys=No.default;var Ao=function(t){return String(t||"").toLowerCase()};A.toLowerCase=Ao;var Eo=function(t){return String(t||"").toUpperCase()};A.toUpperCase=Eo;var Ff={toCamelCase:uo.default,toSnakeCase:ho.default,toPascalCase:fo.default,toDotCase:yo.default,toPathCase:po.default,toTextCase:go.default,toSentenceCase:mo.default,toHeaderCase:wo.default,toKebabCase:vo.default,toUpperCase:Eo,toLowerCase:Ao,lowerKeys:bo.default,upperKeys:Oo.default,camelKeys:To.default,snakeKeys:zo.default,pascalKeys:So.default,kebabKeys:No.default};A.default=Ff;var Io=A;const ko={recursive:!0,recursiveInArray:!0,keepTypesOnRecursion:[Number,String,Uint8Array]},Vf=t=>Io.snakeKeys(t,ko),Jr=t=>Io.camelKeys(t,ko),Kf=t=>t!=null&&typeof t=="object"&&"toString"in t,Wf=(t,e=!1)=>{const r=Kf(t)?"stringer":typeof t;let n;switch(r){case"string":n=(s,i)=>s.localeCompare(i);break;case"stringer":n=(s,i)=>s.toString().localeCompare(i.toString());break;case"number":n=(s,i)=>Number(s)-Number(i);break;case"bigint":n=(s,i)=>BigInt(s)-BigInt(i)>0n?1:-1;break;case"boolean":n=(s,i)=>Number(s)-Number(i);break;case"undefined":n=()=>0;break;default:return console.warn(`sortFunc: unknown type ${r}`),()=>-1}return e?Gf(n):n},Gf=t=>(e,r)=>t(r,e),vn=a.z.tuple([a.z.number(),a.z.number()]);a.z.tuple([a.z.bigint(),a.z.bigint()]);const xo=a.z.object({width:a.z.number(),height:a.z.number()}),Jf=a.z.object({signedWidth:a.z.number(),signedHeight:a.z.number()}),Hf=["width","height"];a.z.enum(Hf);const Xf=["start","center","end"],Qf=["signedWidth","signedHeight"];a.z.enum(Qf);const Hr=a.z.object({x:a.z.number(),y:a.z.number()}),ed=a.z.object({clientX:a.z.number(),clientY:a.z.number()}),td=["x","y"],Co=a.z.enum(td),jo=["top","right","bottom","left"];a.z.enum(jo);const rd=["left","right"],$o=a.z.enum(rd),nd=["top","bottom"],Ro=a.z.enum(nd),Mo=["center"],xa=a.z.enum(Mo),sd=[...jo,...Mo],Po=a.z.enum(sd);a.z.enum(Xf);const ad=["first","last"];a.z.enum(ad);const id=a.z.object({lower:a.z.number(),upper:a.z.number()}),od=a.z.object({lower:a.z.bigint(),upper:a.z.bigint()});a.z.union([id,vn]);a.z.union([od,vn]);a.z.union([Co,Po]);a.z.union([Co,Po,a.z.instanceof(String)]);const Pt=(t,e)=>{const r={};if(typeof t=="number"||typeof t=="bigint")e!=null?(r.lower=t,r.upper=e):(r.lower=typeof t=="bigint"?0n:0,r.upper=t);else if(Array.isArray(t)){if(t.length!==2)throw new Error("bounds: expected array of length 2");[r.lower,r.upper]=t}else return Ca(t);return Ca(r)},Ca=t=>t.lower>t.upper?{lower:t.upper,upper:t.lower}:t;a.z.object({x:$o.or(xa),y:Ro.or(xa)});const cd=a.z.object({x:$o,y:Ro}),ld=Object.freeze({x:"left",y:"top"}),ud=(t,e)=>t.x===e.x&&t.y===e.y,ja=a.z.union([a.z.number(),Hr,vn,xo,Jf,ed]),hd=(t,e)=>{if(typeof t=="string"){if(e===void 0)throw new Error("The y coordinate must be given.");return t==="x"?{x:e,y:0}:{x:0,y:e}}return typeof t=="number"?{x:t,y:e??t}:Array.isArray(t)?{x:t[0],y:t[1]}:"signedWidth"in t?{x:t.signedWidth,y:t.signedHeight}:"clientX"in t?{x:t.clientX,y:t.clientY}:"width"in t?{x:t.width,y:t.height}:{x:t.x,y:t.y}},$a=Object.freeze({x:0,y:0}),cr=a.z.union([a.z.number(),a.z.string()]);a.z.object({top:cr,left:cr,width:cr,height:cr});a.z.object({left:a.z.number(),top:a.z.number(),right:a.z.number(),bottom:a.z.number()});a.z.object({one:Hr,two:Hr,root:cd});const Gs=(t,e,r=0,n=0,s)=>{const i={one:{...$a},two:{...$a},root:s??ld};if(typeof t=="number"){if(typeof e!="number")throw new Error("Box constructor called with invalid arguments");return i.one={x:t,y:e},i.two={x:i.one.x+r,y:i.one.y+n},i}return"one"in t&&"two"in t&&"root"in t?{...t,root:s??t.root}:("getBoundingClientRect"in t&&(t=t.getBoundingClientRect()),"left"in t?(i.one={x:t.left,y:t.top},i.two={x:t.right,y:t.bottom},i):(i.one=t,e==null?i.two={x:i.one.x+r,y:i.one.y+n}:typeof e=="number"?i.two={x:i.one.x+e,y:i.one.y+r}:"width"in e?i.two={x:i.one.x+e.width,y:i.one.y+e.height}:"signedWidth"in e?i.two={x:i.one.x+e.signedWidth,y:i.one.y+e.signedHeight}:i.two=e,i))},Dn=t=>{const e=Gs(t);return{lower:e.one.x,upper:e.two.x}},Un=t=>{const e=Gs(t);return{lower:e.one.y,upper:e.two.y}},fd=t=>typeof t!="object"||t==null?!1:"one"in t&&"two"in t&&"root"in t,dd=a.z.object({signedWidth:a.z.number(),signedHeight:a.z.number()});a.z.union([xo,dd,Hr,vn]);var yd=Object.defineProperty,pd=(t,e,r)=>e in t?yd(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,We=(t,e,r)=>(pd(t,typeof e!="symbol"?e+"":e,r),r);const gd=(t,e,r)=>(e!=null&&(t=Math.max(t,e)),r!=null&&(t=Math.min(t,r)),t);a.z.object({offset:ja,scale:ja});const md=t=>(e,r,n,s)=>r==="dimension"?[e,n]:[e,s?n-t:n+t],wd=t=>(e,r,n,s)=>[e,s?n/t:n*t],vd=t=>(e,r,n)=>{if(e===null)return[t,n];const{lower:s,upper:i}=e,{lower:o,upper:c}=t,u=i-s,f=c-o;if(r==="dimension")return[t,n*(f/u)];const w=(n-s)*(f/u)+o;return[t,w]},bd=t=>(e,r,n)=>[t,n],Od=()=>(t,e,r)=>{if(t===null)throw new Error("cannot invert without bounds");if(e==="dimension")return[t,r];const{lower:n,upper:s}=t;return[t,s-(r-n)]},Td=t=>(e,r,n)=>{const{lower:s,upper:i}=t;return n=gd(n,s,i),[e,n]},is=class Et{constructor(){We(this,"ops",[]),We(this,"currBounds",null),We(this,"currType",null),We(this,"reversed",!1),this.ops=[]}static translate(e){return new Et().translate(e)}static magnify(e){return new Et().magnify(e)}static scale(e,r){return new Et().scale(e,r)}translate(e){const r=this.new(),n=md(e);return n.type="translate",r.ops.push(n),r}magnify(e){const r=this.new(),n=wd(e);return n.type="magnify",r.ops.push(n),r}scale(e,r){const n=Pt(e,r),s=this.new(),i=vd(n);return i.type="scale",s.ops.push(i),s}clamp(e,r){const n=Pt(e,r),s=this.new(),i=Td(n);return i.type="clamp",s.ops.push(i),s}reBound(e,r){const n=Pt(e,r),s=this.new(),i=bd(n);return i.type="re-bound",s.ops.push(i),s}invert(){const e=Od();e.type="invert";const r=this.new();return r.ops.push(e),r}pos(e){return this.exec("position",e)}dim(e){return this.exec("dimension",e)}new(){const e=new Et;return e.ops=this.ops.slice(),e.reversed=this.reversed,e}exec(e,r){return this.currBounds=null,this.ops.reduce(([n,s],i)=>i(n,e,s,this.reversed),[null,r])[1]}reverse(){const e=this.new();e.ops.reverse();const r=[];return e.ops.forEach((n,s)=>{if(n.type==="scale"||r.some(([o,c])=>s>=o&&s<=c))return;const i=e.ops.findIndex((o,c)=>o.type==="scale"&&c>s);i!==-1&&r.push([s,i])}),r.forEach(([n,s])=>{const i=e.ops.slice(n,s);i.unshift(e.ops[s]),e.ops.splice(n,s-n+1,...i)}),e.reversed=!e.reversed,e}};We(is,"IDENTITY",new is);let Ra=is;const Ma=class Fe{constructor(e=new Ra,r=new Ra,n=null){We(this,"x"),We(this,"y"),We(this,"currRoot"),this.x=e,this.y=r,this.currRoot=n}static translate(e,r){return new Fe().translate(e,r)}static translateX(e){return new Fe().translateX(e)}static translateY(e){return new Fe().translateY(e)}static clamp(e){return new Fe().clamp(e)}static magnify(e){return new Fe().magnify(e)}static scale(e){return new Fe().scale(e)}static reBound(e){return new Fe().reBound(e)}translate(e,r){const n=hd(e,r),s=this.copy();return s.x=this.x.translate(n.x),s.y=this.y.translate(n.y),s}translateX(e){const r=this.copy();return r.x=this.x.translate(e),r}translateY(e){const r=this.copy();return r.y=this.y.translate(e),r}magnify(e){const r=this.copy();return r.x=this.x.magnify(e.x),r.y=this.y.magnify(e.y),r}scale(e){const r=this.copy();if(fd(e)){const n=this.currRoot;return r.currRoot=e.root,n!=null&&!ud(n,e.root)&&(n.x!==e.root.x&&(r.x=r.x.invert()),n.y!==e.root.y&&(r.y=r.y.invert())),r.x=r.x.scale(Dn(e)),r.y=r.y.scale(Un(e)),r}return r.x=r.x.scale(e.width),r.y=r.y.scale(e.height),r}reBound(e){const r=this.copy();return r.x=this.x.reBound(Dn(e)),r.y=this.y.reBound(Un(e)),r}clamp(e){const r=this.copy();return r.x=this.x.clamp(Dn(e)),r.y=this.y.clamp(Un(e)),r}copy(){const e=new Fe;return e.currRoot=this.currRoot,e.x=this.x,e.y=this.y,e}reverse(){const e=this.copy();return e.x=this.x.reverse(),e.y=this.y.reverse(),e}pos(e){return{x:this.x.pos(e.x),y:this.y.pos(e.y)}}box(e){return Gs(this.pos(e.one),this.pos(e.two),0,0,this.currRoot??e.root)}};We(Ma,"IDENTITY",new Ma);var zd=Object.defineProperty,Sd=(t,e,r)=>e in t?zd(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,m=(t,e,r)=>(Sd(t,typeof e!="symbol"?e+"":e,r),r);let Nd="_-0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",Ad=(t=21)=>{let e="",r=t;for(;r--;)e+=Nd[Math.random()*64|0];return e};const Do=(t,e)=>{const r=new I(e);if(![k.DAY,k.HOUR,k.MINUTE,k.SECOND,k.MILLISECOND,k.MICROSECOND,k.NANOSECOND].some(s=>s.equals(r)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const n=t.valueOf()%r.valueOf();return t instanceof I?new I(n):new k(n)},Z=class S{constructor(e,r="UTC"){if(m(this,"value"),m(this,"encodeValue",!0),e==null)this.value=S.now().valueOf();else if(e instanceof Date)this.value=BigInt(e.getTime())*S.MILLISECOND.valueOf();else if(typeof e=="string")this.value=S.parseDateTimeString(e,r).valueOf();else if(Array.isArray(e))this.value=S.parseDate(e);else{let n=BigInt(0);e instanceof Number&&(e=e.valueOf()),r==="local"&&(n=S.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=S.MAX:e=S.MIN)),this.value=BigInt(e.valueOf())+n}}static parseDate([e=1970,r=1,n=1]){const s=new Date(e,r-1,n,0,0,0,0);return new S(BigInt(s.getTime())*S.MILLISECOND.valueOf()).truncate(S.DAY).valueOf()}encode(){return this.value.toString()}valueOf(){return this.value}static parseTimeString(e,r="UTC"){const[n,s,i]=e.split(":");let o="00",c="00";i!=null&&([o,c]=i.split("."));let u=S.hours(parseInt(n??"00",10)).add(S.minutes(parseInt(s??"00",10))).add(S.seconds(parseInt(o??"00",10))).add(S.milliseconds(parseInt(c??"00",10)));return r==="local"&&(u=u.add(S.utcOffset)),u.valueOf()}static parseDateTimeString(e,r="UTC"){if(!e.includes("/")&&!e.includes("-"))return S.parseTimeString(e,r);const n=new Date(e);return e.includes(":")||n.setUTCHours(0,0,0,0),new S(BigInt(n.getTime())*S.MILLISECOND.valueOf(),r).valueOf()}fString(e="ISO",r="UTC"){switch(e){case"ISODate":return this.toISOString(r).slice(0,10);case"ISOTime":return this.toISOString(r).slice(11,23);case"time":return this.timeString(!1,r);case"preciseTime":return this.timeString(!0,r);case"date":return this.dateString();case"preciseDate":return`${this.dateString()} ${this.timeString(!0,r)}`;case"dateTime":return`${this.dateString()} ${this.timeString(!1,r)}`;default:return this.toISOString(r)}}toISOString(e="UTC"){return e==="UTC"?this.date().toISOString():this.sub(S.utcOffset).date().toISOString()}timeString(e=!1,r="UTC"){const n=this.toISOString(r);return e?n.slice(11,23):n.slice(11,19)}dateString(){const e=this.date(),r=e.toLocaleString("default",{month:"short"}),n=e.toLocaleString("default",{day:"numeric"});return`${r} ${n}`}static get utcOffset(){return new k(BigInt(new Date().getTimezoneOffset())*S.MINUTE.valueOf())}static since(e){return new S().span(e)}date(){return new Date(this.milliseconds())}equals(e){return this.valueOf()===new S(e).valueOf()}span(e){return this.range(e).span}range(e){return new le(this,e).makeValid()}spanRange(e){return this.range(this.add(e)).makeValid()}get isZero(){return this.valueOf()===BigInt(0)}after(e){return this.valueOf()>new S(e).valueOf()}afterEq(e){return this.valueOf()>=new S(e).valueOf()}before(e){return this.valueOf()<new S(e).valueOf()}beforeEq(e){return this.valueOf()<=new S(e).valueOf()}add(e){return new S(this.valueOf()+BigInt(e.valueOf()))}sub(e){return new S(this.valueOf()-BigInt(e.valueOf()))}milliseconds(){return Number(this.valueOf())/Number(S.MILLISECOND.valueOf())}toString(){return this.date().toISOString()}remainder(e){return Do(this,e)}get isToday(){return this.truncate(k.DAY).equals(S.now().truncate(k.DAY))}truncate(e){return this.sub(this.remainder(e))}static now(){return new S(new Date)}static max(...e){let r=S.MIN;for(const n of e){const s=new S(n);s.after(r)&&(r=s)}return r}static min(...e){let r=S.MAX;for(const n of e){const s=new S(n);s.before(r)&&(r=s)}return r}static nanoseconds(e){return new S(e)}static microseconds(e){return S.nanoseconds(e*1e3)}static milliseconds(e){return S.microseconds(e*1e3)}static seconds(e){return S.milliseconds(e*1e3)}static minutes(e){return S.seconds(e*60)}static hours(e){return S.minutes(e*60)}static days(e){return S.hours(e*24)}};m(Z,"NANOSECOND",Z.nanoseconds(1)),m(Z,"MICROSECOND",Z.microseconds(1)),m(Z,"MILLISECOND",Z.milliseconds(1)),m(Z,"SECOND",Z.seconds(1)),m(Z,"MINUTE",Z.minutes(1)),m(Z,"HOUR",Z.hours(1)),m(Z,"DAY",Z.days(1)),m(Z,"MAX",new Z((1n<<63n)-1n)),m(Z,"MIN",new Z(0)),m(Z,"ZERO",new Z(0)),m(Z,"z",a.z.union([a.z.object({value:a.z.bigint()}).transform(t=>new Z(t.value)),a.z.string().transform(t=>new Z(BigInt(t))),a.z.instanceof(Number).transform(t=>new Z(t)),a.z.number().transform(t=>new Z(t)),a.z.instanceof(Z)]));let I=Z;const q=class ${constructor(e){m(this,"value"),m(this,"encodeValue",!0),typeof e=="number"&&(e=Math.trunc(e.valueOf())),this.value=BigInt(e.valueOf())}encode(){return this.value.toString()}valueOf(){return this.value}lessThan(e){return this.valueOf()<new $(e).valueOf()}greaterThan(e){return this.valueOf()>new $(e).valueOf()}lessThanOrEqual(e){return this.valueOf()<=new $(e).valueOf()}greaterThanOrEqual(e){return this.valueOf()>=new $(e).valueOf()}remainder(e){return Do(this,e)}truncate(e){return new $(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(){const e=this.truncate($.DAY),r=this.truncate($.HOUR),n=this.truncate($.MINUTE),s=this.truncate($.SECOND),i=this.truncate($.MILLISECOND),o=this.truncate($.MICROSECOND),c=this.truncate($.NANOSECOND),u=e,f=r.sub(e),w=n.sub(r),h=s.sub(n),D=i.sub(s),V=o.sub(i),se=c.sub(o);let R="";return u.isZero||(R+=`${u.days}d `),f.isZero||(R+=`${f.hours}h `),w.isZero||(R+=`${w.minutes}m `),h.isZero||(R+=`${h.seconds}s `),D.isZero||(R+=`${D.milliseconds}ms `),V.isZero||(R+=`${V.microseconds}µs `),se.isZero||(R+=`${se.nanoseconds}ns`),R.trim()}get days(){return Number(this.valueOf())/Number($.DAY.valueOf())}get hours(){return Number(this.valueOf())/Number($.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number($.MINUTE.valueOf())}get seconds(){return Number(this.valueOf())/Number($.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number($.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number($.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===BigInt(0)}equals(e){return this.valueOf()===new $(e).valueOf()}add(e){return new $(this.valueOf()+new $(e).valueOf())}sub(e){return new $(this.valueOf()-new $(e).valueOf())}static nanoseconds(e=1){return new $(e)}static microseconds(e=1){return $.nanoseconds(e*1e3)}static milliseconds(e=1){return $.microseconds(e*1e3)}static seconds(e=1){return $.milliseconds(e*1e3)}static minutes(e){return $.seconds(e.valueOf()*60)}static hours(e){return $.minutes(e*60)}static days(e){return $.hours(e*24)}};m(q,"NANOSECOND",q.nanoseconds(1)),m(q,"MICROSECOND",q.microseconds(1)),m(q,"MILLISECOND",q.milliseconds(1)),m(q,"SECOND",q.seconds(1)),m(q,"MINUTE",q.minutes(1)),m(q,"HOUR",q.hours(1)),m(q,"DAY",q.days(1)),m(q,"MAX",new q((1n<<63n)-1n)),m(q,"MIN",new q(0)),m(q,"ZERO",new q(0)),m(q,"z",a.z.union([a.z.object({value:a.z.bigint()}).transform(t=>new q(t.value)),a.z.string().transform(t=>new q(BigInt(t))),a.z.instanceof(Number).transform(t=>new q(t)),a.z.number().transform(t=>new q(t)),a.z.instanceof(q)]));let k=q;const It=class Cr extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new Cr(e).valueOf()}get period(){return k.seconds(1/this.valueOf())}sampleCount(e){return new k(e).seconds*this.valueOf()}byteCount(e,r){return this.sampleCount(e)*new fe(r).valueOf()}span(e){return k.seconds(e/this.valueOf())}byteSpan(e,r){return this.span(e.valueOf()/r.valueOf())}static hz(e){return new Cr(e)}static khz(e){return Cr.hz(e*1e3)}};m(It,"z",a.z.union([a.z.number().transform(t=>new It(t)),a.z.instanceof(Number).transform(t=>new It(t)),a.z.instanceof(It)]));let Js=It;const te=class extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}length(e){return e.valueOf()/this.valueOf()}size(e){return new _t(e*this.valueOf())}};m(te,"UNKNOWN",new te(0)),m(te,"BIT128",new te(16)),m(te,"BIT64",new te(8)),m(te,"BIT32",new te(4)),m(te,"BIT16",new te(2)),m(te,"BIT8",new te(1)),m(te,"z",a.z.union([a.z.number().transform(t=>new te(t)),a.z.instanceof(Number).transform(t=>new te(t)),a.z.instanceof(te)]));let fe=te;const Ee=class jr{constructor(e,r){m(this,"start"),m(this,"end"),typeof e=="object"&&"start"in e?(this.start=new I(e.start),this.end=new I(e.end)):(this.start=new I(e),this.end=new I(r))}get span(){return new k(this.end.valueOf()-this.start.valueOf())}get isValid(){return this.start.valueOf()<=this.end.valueOf()}makeValid(){return this.isValid?this:this.swap()}get isZero(){return this.span.isZero}swap(){return new jr(this.end,this.start)}equals(e){return this.start.equals(e.start)&&this.end.equals(e.end)}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.fString("preciseDate")} - ${this.span.toString()}`}overlapsWith(e,r=k.ZERO){e=e.makeValid();const n=this.makeValid();if(this.equals(e))return!0;if(e.end.equals(n.start)||n.end.equals(e.start))return!1;const s=I.max(n.start,e.start),i=I.min(n.end,e.end);return i.before(s)?!1:new k(i.sub(s)).greaterThanOrEqual(r)}roughlyEquals(e,r){let n=this.start.sub(e.start).valueOf(),s=this.end.sub(e.end).valueOf();return n<0&&(n=-n),s<0&&(s=-s),n<=r.valueOf()&&s<=r.valueOf()}contains(e){return e instanceof jr?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const r=new jr(this.start,this.end);return e.start.after(this.start)&&(r.start=e.start),e.start.after(this.end)&&(r.end=e.start),e.end.before(this.end)&&(r.end=e.end),e.end.before(this.start)&&(r.start=e.end),r}};m(Ee,"MAX",new Ee(I.MIN,I.MAX)),m(Ee,"MIN",new Ee(I.MAX,I.MIN)),m(Ee,"ZERO",new Ee(I.ZERO,I.ZERO)),m(Ee,"z",a.z.union([a.z.object({start:I.z,end:I.z}).transform(t=>new Ee(t.start,t.end)),a.z.instanceof(Ee)]));let le=Ee;const y=class Ie extends String{constructor(e){if(e instanceof Ie||typeof e=="string"||typeof e.valueOf()=="string"){super(e.valueOf());return}else{const r=Ie.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(r!=null){super(r.valueOf());return}}throw super(Ie.UNKNOWN.valueOf()),new Error(`unable to find data type for ${e.toString()}`)}get Array(){const e=Ie.ARRAY_CONSTRUCTORS.get(this.toString());if(e==null)throw new Error(`unable to find array constructor for ${this.valueOf()}`);return e}equals(e){return this.valueOf()===e.valueOf()}toString(){return this.valueOf()}get isVariable(){return this.equals(Ie.JSON)||this.equals(Ie.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(Ie.UUID)}get isInteger(){return this.toString().startsWith("int")}get isFloat(){return this.toString().startsWith("float")}get density(){const e=Ie.DENSITIES.get(this.toString());if(e==null)throw new Error(`unable to find density for ${this.valueOf()}`);return e}canSafelyCastTo(e){return this.equals(e)?!0:this.isVariable&&!e.isVariable||!this.isVariable&&e.isVariable?!1:this.isFloat&&e.isInteger||this.isInteger&&e.isFloat?this.density.valueOf()<e.density.valueOf():this.isFloat&&e.isFloat||this.isInteger&&e.isInteger?this.density.valueOf()<=e.density.valueOf():!1}canCastTo(e){return this.isNumeric&&e.isNumeric?!0:this.equals(e)}checkArray(e){return e.constructor===this.Array}toJSON(){return this.toString()}get usesBigInt(){return Ie.BIG_INT_TYPES.some(e=>e.equals(this))}};m(y,"UNKNOWN",new y("unknown")),m(y,"FLOAT64",new y("float64")),m(y,"FLOAT32",new y("float32")),m(y,"INT64",new y("int64")),m(y,"INT32",new y("int32")),m(y,"INT16",new y("int16")),m(y,"INT8",new y("int8")),m(y,"UINT64",new y("uint64")),m(y,"UINT32",new y("uint32")),m(y,"UINT16",new y("uint16")),m(y,"UINT8",new y("uint8")),m(y,"BOOLEAN",y.UINT8),m(y,"TIMESTAMP",new y("timestamp")),m(y,"UUID",new y("uuid")),m(y,"STRING",new y("string")),m(y,"JSON",new y("json")),m(y,"ARRAY_CONSTRUCTORS",new Map([[y.UINT8.toString(),Uint8Array],[y.UINT16.toString(),Uint16Array],[y.UINT32.toString(),Uint32Array],[y.UINT64.toString(),BigUint64Array],[y.FLOAT32.toString(),Float32Array],[y.FLOAT64.toString(),Float64Array],[y.INT8.toString(),Int8Array],[y.INT16.toString(),Int16Array],[y.INT32.toString(),Int32Array],[y.INT64.toString(),BigInt64Array],[y.TIMESTAMP.toString(),BigInt64Array],[y.STRING.toString(),Uint8Array],[y.JSON.toString(),Uint8Array],[y.UUID.toString(),Uint8Array]])),m(y,"ARRAY_CONSTRUCTOR_DATA_TYPES",new Map([[Uint8Array.name,y.UINT8],[Uint16Array.name,y.UINT16],[Uint32Array.name,y.UINT32],[BigUint64Array.name,y.UINT64],[Float32Array.name,y.FLOAT32],[Float64Array.name,y.FLOAT64],[Int8Array.name,y.INT8],[Int16Array.name,y.INT16],[Int32Array.name,y.INT32],[BigInt64Array.name,y.INT64]])),m(y,"DENSITIES",new Map([[y.UINT8.toString(),fe.BIT8],[y.UINT16.toString(),fe.BIT16],[y.UINT32.toString(),fe.BIT32],[y.UINT64.toString(),fe.BIT64],[y.FLOAT32.toString(),fe.BIT32],[y.FLOAT64.toString(),fe.BIT64],[y.INT8.toString(),fe.BIT8],[y.INT16.toString(),fe.BIT16],[y.INT32.toString(),fe.BIT32],[y.INT64.toString(),fe.BIT64],[y.TIMESTAMP.toString(),fe.BIT64],[y.STRING.toString(),fe.UNKNOWN],[y.JSON.toString(),fe.UNKNOWN],[y.UUID.toString(),fe.BIT128]])),m(y,"ALL",[y.UNKNOWN,y.FLOAT64,y.FLOAT32,y.INT64,y.INT32,y.INT16,y.INT8,y.UINT64,y.UINT32,y.UINT16,y.UINT8,y.TIMESTAMP,y.UUID,y.STRING,y.JSON]),m(y,"BIG_INT_TYPES",[y.INT64,y.UINT64,y.TIMESTAMP]),m(y,"z",a.z.union([a.z.string().transform(t=>new y(t)),a.z.instanceof(y)]));let x=y;const oe=class H extends Number{constructor(e){super(e.valueOf())}largerThan(e){return this.valueOf()>e.valueOf()}smallerThan(e){return this.valueOf()<e.valueOf()}add(e){return H.bytes(this.valueOf()+e.valueOf())}sub(e){return H.bytes(this.valueOf()-e.valueOf())}truncate(e){return new H(Math.trunc(this.valueOf()/e.valueOf())*e.valueOf())}remainder(e){return H.bytes(this.valueOf()%e.valueOf())}get gigabytes(){return this.valueOf()/H.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/H.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/H.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/H.TERABYTE.valueOf()}toString(){const e=this.truncate(H.TERABYTE),r=this.truncate(H.GIGABYTE),n=this.truncate(H.MEGABYTE),s=this.truncate(H.KILOBYTE),i=this.truncate(H.BYTE),o=e,c=r.sub(e),u=n.sub(r),f=s.sub(n),w=i.sub(s);let h="";return o.isZero||(h+=`${o.terabytes}TB `),c.isZero||(h+=`${c.gigabytes}GB `),u.isZero||(h+=`${u.megabytes}MB `),f.isZero||(h+=`${f.kilobytes}KB `),(!w.isZero||h==="")&&(h+=`${w.valueOf()}B`),h.trim()}static bytes(e=1){return new H(e)}static kilobytes(e=1){return H.bytes(e.valueOf()*1e3)}static megabytes(e=1){return H.kilobytes(e.valueOf()*1e3)}static gigabytes(e=1){return H.megabytes(e.valueOf()*1e3)}static terabytes(e){return H.gigabytes(e.valueOf()*1e3)}get isZero(){return this.valueOf()===0}};m(oe,"BYTE",new oe(1)),m(oe,"KILOBYTE",oe.kilobytes(1)),m(oe,"MEGABYTE",oe.megabytes(1)),m(oe,"GIGABYTE",oe.gigabytes(1)),m(oe,"TERABYTE",oe.terabytes(1)),m(oe,"ZERO",new oe(0)),m(oe,"z",a.z.union([a.z.number().transform(t=>new oe(t)),a.z.instanceof(oe)]));let _t=oe;a.z.union([a.z.instanceof(Uint8Array),a.z.instanceof(Uint16Array),a.z.instanceof(Uint32Array),a.z.instanceof(BigUint64Array),a.z.instanceof(Float32Array),a.z.instanceof(Float64Array),a.z.instanceof(Int8Array),a.z.instanceof(Int16Array),a.z.instanceof(Int32Array),a.z.instanceof(BigInt64Array)]);const Uo=t=>{const e=typeof t;return e==="string"||e==="number"||e==="boolean"||e==="bigint"||t instanceof I||t instanceof k||t instanceof Date},Ed=(t,e,r,n=0)=>t.usesBigInt&&!e.usesBigInt?Number(r)-Number(n):!t.usesBigInt&&e.usesBigInt?BigInt(r)-BigInt(n):kt(r,-n),Id=t=>t==null?!1:Array.isArray(t)||t instanceof ArrayBuffer||ArrayBuffer.isView(t)&&!(t instanceof DataView)||t instanceof at?!0:Uo(t),rt=-1;let at=class Ve{constructor(e){m(this,"key",""),m(this,"isSynnaxSeries",!0),m(this,"dataType"),m(this,"sampleOffset"),m(this,"gl"),m(this,"_data"),m(this,"_timeRange"),m(this,"alignment",0n),m(this,"_cachedMin"),m(this,"_cachedMax"),m(this,"writePos",rt),m(this,"_refCount",0),m(this,"_cachedLength"),Id(e)&&(e={data:e});const{dataType:r,timeRange:n,sampleOffset:s=0,glBufferUsage:i="static",alignment:o=0n,key:c=Ad()}=e,{data:u}=e;if(u instanceof Ve||typeof u=="object"&&"isSynnaxSeries"in u&&u.isSynnaxSeries===!0){const h=u;this.key=h.key,this.dataType=h.dataType,this.sampleOffset=h.sampleOffset,this.gl=h.gl,this._data=h._data,this._timeRange=h._timeRange,this.alignment=h.alignment,this._cachedMin=h._cachedMin,this._cachedMax=h._cachedMax,this.writePos=h.writePos,this._refCount=h._refCount,this._cachedLength=h._cachedLength;return}const f=Uo(u),w=Array.isArray(u);if(r!=null)this.dataType=new x(r);else{if(u instanceof ArrayBuffer)throw new Error("cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type.");if(w||f){let h=u;if(!f){if(u.length===0)throw new Error("cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type.");h=u[0]}if(typeof h=="string")this.dataType=x.STRING;else if(typeof h=="number")this.dataType=x.FLOAT64;else if(typeof h=="bigint")this.dataType=x.INT64;else if(typeof h=="boolean")this.dataType=x.BOOLEAN;else if(h instanceof I||h instanceof Date||h instanceof I)this.dataType=x.TIMESTAMP;else if(typeof h=="object")this.dataType=x.JSON;else throw new Error(`cannot infer data type of ${typeof h} when constructing a Series from a JS array`)}else this.dataType=new x(u)}if(!w&&!f)this._data=u;else{let h=f?[u]:u;const D=h[0];(D instanceof I||D instanceof Date||D instanceof k)&&(h=h.map(V=>new I(V).valueOf())),this.dataType.equals(x.STRING)?(this._cachedLength=h.length,this._data=new TextEncoder().encode(h.join(`
16
- `)+`
17
- `)):this.dataType.equals(x.JSON)?(this._cachedLength=h.length,this._data=new TextEncoder().encode(h.map(V=>JSON.stringify(V)).join(`
18
- `)+`
19
- `)):this._data=new this.dataType.Array(h).buffer}this.key=c,this.alignment=o,this.sampleOffset=s??0,this._timeRange=n,this.gl={control:null,buffer:null,prevBuffer:0,bufferUsage:i}}static alloc({capacity:e,dataType:r,...n}){if(e===0)throw new Error("[Series] - cannot allocate an array of length 0");const s=new new x(r).Array(e),i=new Ve({data:s.buffer,dataType:r,...n});return i.writePos=0,i}static generateTimestamps(e,r,n){const s=n.spanRange(r.span(e)),i=new BigInt64Array(e);for(let o=0;o<e;o++)i[o]=BigInt(n.add(r.span(o)).valueOf());return new Ve({data:i,dataType:x.TIMESTAMP,timeRange:s})}get refCount(){return this._refCount}static fromStrings(e,r){const n=new TextEncoder().encode(e.join(`
20
- `)+`
21
- `);return new Ve({data:n,dataType:x.STRING,timeRange:r})}static fromJSON(e,r){const n=new TextEncoder().encode(e.map(s=>JSON.stringify(s)).join(`
22
- `)+`
23
- `);return new Ve({data:n,dataType:x.JSON,timeRange:r})}acquire(e){this._refCount++,e!=null&&this.updateGLBuffer(e)}release(){if(this._refCount--,this._refCount===0&&this.gl.control!=null)this.maybeGarbageCollectGLBuffer(this.gl.control);else if(this._refCount<0)throw new Error("cannot release an array with a negative reference count")}write(e){if(!e.dataType.equals(this.dataType))throw new Error("buffer must be of the same type as this array");if(this.writePos===rt)return 0;const r=this.capacity-this.writePos,n=r<e.length?e.slice(0,r):e;return this.underlyingData.set(n.data,this.writePos),this.maybeRecomputeMinMax(n),this._cachedLength=void 0,this.writePos+=n.length,n.length}get buffer(){return this._data}get underlyingData(){return new this.dataType.Array(this._data)}get data(){return this.writePos===rt?this.underlyingData:new this.dataType.Array(this._data,0,this.writePos)}toStrings(){if(!this.dataType.equals(x.STRING))throw new Error("cannot convert non-string series to strings");return new TextDecoder().decode(this.buffer).split(`
24
- `).slice(0,-1)}toUUIDs(){if(!this.dataType.equals(x.UUID))throw new Error("cannot convert non-uuid series to uuids");const e=x.UUID.density.valueOf(),r=Array(this.length);for(let n=0;n<this.length;n++){const s=this.buffer.slice(n*e,(n+1)*e),i=Array.from(new Uint8Array(s),o=>o.toString(16).padStart(2,"0")).join("").replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/,"$1-$2-$3-$4-$5");r[n]=i}return r}parseJSON(e){if(!this.dataType.equals(x.JSON))throw new Error("cannot convert non-string series to strings");return new TextDecoder().decode(this.buffer).split(`
25
- `).slice(0,-1).map(r=>e.parse(Jr(JSON.parse(r))))}get timeRange(){if(this._timeRange==null)throw new Error("time range not set on series");return this._timeRange}get byteCapacity(){return new _t(this.buffer.byteLength)}get capacity(){return this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===rt?this.byteCapacity:this.dataType.density.size(this.writePos)}get length(){return this._cachedLength!=null?this._cachedLength:this.dataType.isVariable?this.calculateCachedLength():this.writePos===rt?this.data.length:this.writePos}calculateCachedLength(){if(!this.dataType.isVariable)throw new Error("cannot calculate length of a non-variable length data type");let e=0;return this.data.forEach(r=>{r===10&&e++}),this._cachedLength=e,e}convert(e,r=0){if(this.dataType.equals(e))return this;const n=new e.Array(this.length);for(let s=0;s<this.length;s++)n[s]=Ed(this.dataType,e,this.data[s],r);return new Ve({data:n.buffer,dataType:e,timeRange:this._timeRange,sampleOffset:r,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment})}calcRawMax(){if(this.length===0)return-1/0;if(this.dataType.equals(x.TIMESTAMP))this._cachedMax=this.data[this.data.length-1];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMax=e.reduce((r,n)=>r>n?r:n)}else{const e=this.data;this._cachedMax=e.reduce((r,n)=>r>n?r:n)}return this._cachedMax}get max(){if(this.dataType.isVariable)throw new Error("cannot calculate maximum on a variable length data type");return this.writePos===0?-1/0:(this._cachedMax==null&&(this._cachedMax=this.calcRawMax()),kt(this._cachedMax,this.sampleOffset))}calcRawMin(){if(this.length===0)return 1/0;if(this.dataType.equals(x.TIMESTAMP))this._cachedMin=this.data[0];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMin=e.reduce((r,n)=>r<n?r:n)}else{const e=this.data;this._cachedMin=e.reduce((r,n)=>r<n?r:n)}return this._cachedMin}get min(){if(this.dataType.isVariable)throw new Error("cannot calculate minimum on a variable length data type");return this.writePos===0?1/0:(this._cachedMin==null&&(this._cachedMin=this.calcRawMin()),kt(this._cachedMin,this.sampleOffset))}get bounds(){return Pt(Number(this.min),Number(this.max))}maybeRecomputeMinMax(e){if(this._cachedMin!=null){const r=e._cachedMin??e.calcRawMin();r<this._cachedMin&&(this._cachedMin=r)}if(this._cachedMax!=null){const r=e._cachedMax??e.calcRawMax();r>this._cachedMax&&(this._cachedMax=r)}}enrich(){this.max,this.min}get range(){return kt(this.max,-this.min)}at(e,r){if(this.dataType.isVariable)return this.atVariable(e,r??!1);e<0&&(e=this.length+e);const n=this.data[e];if(n==null){if(r===!0)throw new Error(`[series] - no value at index ${e}`);return}return kt(n,this.sampleOffset)}atVariable(e,r){e<0&&(e=this.length+e);let n=0,s=0;for(let o=0;o<this.data.length;o++)if(this.data[o]===10){if(e===0){s=o;break}n=o+1,e--}if(s===0&&(s=this.data.length),n>=s||e>0){if(r)throw new Error(`[series] - no value at index ${e}`);return}const i=this.data.slice(n,s);return this.dataType.equals(x.STRING)?new TextDecoder().decode(i):Jr(JSON.parse(new TextDecoder().decode(i)))}binarySearch(e){let r=0,n=this.length-1;const s=Wf(e);for(;r<=n;){const i=Math.floor((r+n)/2),o=s(this.at(i,!0),e);if(o===0)return i;o<0?r=i+1:n=i-1}return r}updateGLBuffer(e){if(this.gl.control=e,!this.dataType.equals(x.FLOAT32))throw new Error("Only FLOAT32 arrays can be used in WebGL");const{buffer:r,bufferUsage:n,prevBuffer:s}=this.gl;if(r==null&&(this.gl.buffer=e.createBuffer()),this.writePos!==s)if(e.bindBuffer(e.ARRAY_BUFFER,this.gl.buffer),this.writePos!==rt){s===0&&e.bufferData(e.ARRAY_BUFFER,this.byteCapacity.valueOf(),e.STATIC_DRAW);const i=this.dataType.density.size(s).valueOf(),o=this.underlyingData.slice(this.gl.prevBuffer,this.writePos);e.bufferSubData(e.ARRAY_BUFFER,i,o.buffer),this.gl.prevBuffer=this.writePos}else e.bufferData(e.ARRAY_BUFFER,this.buffer,n==="static"?e.STATIC_DRAW:e.DYNAMIC_DRAW),this.gl.prevBuffer=rt}as(e){if(e==="string"){if(!this.dataType.equals(x.STRING))throw new Error(`cannot convert series of type ${this.dataType.toString()} to string`);return this}if(e==="number"){if(!this.dataType.isNumeric)throw new Error(`cannot convert series of type ${this.dataType.toString()} to number`);return this}if(e==="bigint"){if(!this.dataType.equals(x.INT64))throw new Error(`cannot convert series of type ${this.dataType.toString()} to bigint`);return this}throw new Error(`cannot convert series to ${e}`)}get digest(){var e;return{key:this.key,dataType:this.dataType.toString(),sampleOffset:this.sampleOffset,alignment:this.alignmentBounds,timeRange:(e=this._timeRange)==null?void 0:e.toString(),length:this.length,capacity:this.capacity}}get memInfo(){return{key:this.key,length:this.length,byteLength:this.byteLength,glBuffer:this.gl.buffer!=null}}get alignmentBounds(){return Pt(this.alignment,this.alignment+BigInt(this.length))}maybeGarbageCollectGLBuffer(e){this.gl.buffer!=null&&(e.deleteBuffer(this.gl.buffer),this.gl.buffer=null,this.gl.prevBuffer=0,this.gl.control=null)}get glBuffer(){if(this.gl.buffer==null)throw new Error("gl buffer not initialized");return this.gl.prevBuffer!==this.writePos&&console.warn("buffer not updated"),this.gl.buffer}[Symbol.iterator](){if(this.dataType.isVariable){const e=new kd(this);return this.dataType.equals(x.JSON)?new xd(e):e}return new Cd(this)}slice(e,r){if(e<=0&&(r==null||r>=this.length))return this;const n=this.data.slice(e,r);return new Ve({data:n,dataType:this.dataType,timeRange:this._timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(e)})}reAlign(e){return new Ve({data:this.buffer,dataType:this.dataType,timeRange:le.ZERO,sampleOffset:this.sampleOffset,glBufferUsage:"static",alignment:e})}};class kd{constructor(e){if(m(this,"series"),m(this,"index"),m(this,"decoder"),!e.dataType.isVariable)throw new Error("cannot create a variable series iterator for a non-variable series");this.series=e,this.index=0,this.decoder=new TextDecoder}next(){const e=this.index,r=this.series.data;for(;this.index<r.length&&r[this.index]!==10;)this.index++;const n=this.index;return e===n?{done:!0,value:void 0}:(this.index++,{done:!1,value:this.decoder.decode(this.series.buffer.slice(e,n))})}[Symbol.iterator](){return this}}var Bo;class xd{constructor(e){m(this,"wrapped"),m(this,Bo,"JSONSeriesIterator"),this.wrapped=e}next(){const e=this.wrapped.next();return e.done===!0?{done:!0,value:void 0}:{done:!1,value:Jr(JSON.parse(e.value))}}[Symbol.iterator](){return this}}Bo=Symbol.toStringTag;var Lo;class Cd{constructor(e){m(this,"series"),m(this,"index"),m(this,Lo,"SeriesIterator"),this.series=e,this.index=0}next(){return this.index>=this.series.length?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}[Symbol.iterator](){return this}}Lo=Symbol.toStringTag;const kt=(t,e)=>typeof t=="bigint"&&typeof e=="bigint"||typeof t=="number"&&typeof e=="number"?t+e:e===0?t:t===0?e:Number(t)+Number(e);class jd{constructor(e){if(m(this,"series"),e.length!==0){const r=e[0].dataType;for(let n=1;n<e.length;n++)if(!e[n].dataType.equals(r))throw new Error("[multi-series] - series must have the same data type")}this.series=e}as(e){if(!new x(e).equals(this.dataType))throw new Error(`cannot convert series of type ${this.dataType.toString()} to ${e.toString()}`);return this}get dataType(){return this.series.length===0?x.UNKNOWN:this.series[0].dataType}get timeRange(){return this.series.length===0?le.ZERO:new le(this.series[0].timeRange.start,this.series[this.series.length-1].timeRange.end)}push(e){this.series.push(e)}get length(){return this.series.reduce((e,r)=>e+r.length,0)}at(e,r=!1){e<0&&(e=this.length+e);for(const n of this.series){if(e<n.length)return n.at(e,r);e-=n.length}if(r)throw new Error(`[series] - no value at index ${e}`)}get byteLength(){return new _t(this.series.reduce((e,r)=>e+r.byteLength.valueOf(),0))}get data(){const e=new this.dataType.Array(this.length);let r=0;for(const n of this.series)e.set(n.data,r),r+=n.length;return new this.dataType.Array(e)}[Symbol.iterator](){return this.series.length===0?{next(){return{done:!0,value:void 0}}}:new $d(this.series)}}var _o;class $d{constructor(e){m(this,"series"),m(this,"seriesIndex"),m(this,"internal"),m(this,_o,"MultiSeriesIterator"),this.series=e,this.seriesIndex=0,this.internal=e[0][Symbol.iterator]()}next(){const e=this.internal.next();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())}[Symbol.iterator](){return this}}_o=Symbol.toStringTag;const E=t=>Array.isArray(t)?t:[t],Qe=a.z.number(),Jt=a.z.object({name:a.z.string(),key:a.z.number(),rate:Js.z,dataType:x.z,leaseholder:a.z.number(),index:a.z.number(),isIndex:a.z.boolean(),internal:a.z.boolean(),alias:a.z.string().optional()}),Yo=Jt.extend({key:a.z.number().optional(),leaseholder:a.z.number().optional(),index:a.z.number().optional(),rate:Js.z.optional().default(0),isIndex:a.z.boolean().optional(),internal:a.z.boolean().optional().default(!1),virtual:a.z.boolean().optional().default(!1)}),Rd=(t,e)=>{let r=null;return e===0?t:(...n)=>{r!==null&&(clearTimeout(r),r=null),r=setTimeout(()=>t(...n),e)}},Md=new Error("request for lock canceled");var Pd=function(t,e,r,n){function s(i){return i instanceof r?i:new r(function(o){o(i)})}return new(r||(r=Promise))(function(i,o){function c(w){try{f(n.next(w))}catch(h){o(h)}}function u(w){try{f(n.throw(w))}catch(h){o(h)}}function f(w){w.done?i(w.value):s(w.value).then(c,u)}f((n=n.apply(t,e||[])).next())})};class Dd{constructor(e,r=Md){this._value=e,this._cancelError=r,this._queue=[],this._weightedWaiters=[]}acquire(e=1,r=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return new Promise((n,s)=>{const i={resolve:n,reject:s,weight:e,priority:r},o=Zo(this._queue,c=>r<=c.priority);o===-1&&e<=this._value?this._dispatchItem(i):this._queue.splice(o+1,0,i)})}runExclusive(e){return Pd(this,arguments,void 0,function*(r,n=1,s=0){const[i,o]=yield this.acquire(n,s);try{return yield r(i)}finally{o()}})}waitForUnlock(e=1,r=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return this._couldLockImmediately(e,r)?Promise.resolve():new Promise(n=>{this._weightedWaiters[e-1]||(this._weightedWaiters[e-1]=[]),Ud(this._weightedWaiters[e-1],{resolve:n,priority:r})})}isLocked(){return this._value<=0}getValue(){return this._value}setValue(e){this._value=e,this._dispatchQueue()}release(e=1){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);this._value+=e,this._dispatchQueue()}cancel(){this._queue.forEach(e=>e.reject(this._cancelError)),this._queue=[]}_dispatchQueue(){for(this._drainUnlockWaiters();this._queue.length>0&&this._queue[0].weight<=this._value;)this._dispatchItem(this._queue.shift()),this._drainUnlockWaiters()}_dispatchItem(e){const r=this._value;this._value-=e.weight,e.resolve([r,this._newReleaser(e.weight)])}_newReleaser(e){let r=!1;return()=>{r||(r=!0,this.release(e))}}_drainUnlockWaiters(){if(this._queue.length===0)for(let e=this._value;e>0;e--){const r=this._weightedWaiters[e-1];r&&(r.forEach(n=>n.resolve()),this._weightedWaiters[e-1]=[])}else{const e=this._queue[0].priority;for(let r=this._value;r>0;r--){const n=this._weightedWaiters[r-1];if(!n)continue;const s=n.findIndex(i=>i.priority<=e);(s===-1?n:n.splice(0,s)).forEach(i=>i.resolve())}}}_couldLockImmediately(e,r){return(this._queue.length===0||this._queue[0].priority<r)&&e<=this._value}}function Ud(t,e){const r=Zo(t,n=>e.priority<=n.priority);t.splice(r+1,0,e)}function Zo(t,e){for(let r=t.length-1;r>=0;r--)if(e(t[r]))return r;return-1}var Bd=function(t,e,r,n){function s(i){return i instanceof r?i:new r(function(o){o(i)})}return new(r||(r=Promise))(function(i,o){function c(w){try{f(n.next(w))}catch(h){o(h)}}function u(w){try{f(n.throw(w))}catch(h){o(h)}}function f(w){w.done?i(w.value):s(w.value).then(c,u)}f((n=n.apply(t,e||[])).next())})};class Ld{constructor(e){this._semaphore=new Dd(1,e)}acquire(){return Bd(this,arguments,void 0,function*(e=0){const[,r]=yield this._semaphore.acquire(1,e);return r})}runExclusive(e,r=0){return this._semaphore.runExclusive(()=>e(),1,r)}isLocked(){return this._semaphore.isLocked()}waitForUnlock(e=0){return this._semaphore.waitForUnlock(1,e)}release(){this._semaphore.isLocked()&&this._semaphore.release()}cancel(){return this._semaphore.cancel()}}const et="sy.",$r=class qo extends Te{constructor(){super(...arguments),l(this,"type",qo.TYPE)}};l($r,"TYPE",et+"validation"),l($r,"matches",de($r.TYPE));let W=$r;const Rr=class Fo extends W{constructor(e,r){super(e+": "+r),l(this,"type",Fo.TYPE),l(this,"field"),l(this,"message"),this.field=e,this.message=r}};l(Rr,"TYPE",W.TYPE+".field"),l(Rr,"matches",de(Rr.TYPE));let Pa=Rr;const Mr=class Vo extends Te{constructor(){super(...arguments),l(this,"type",Vo.TYPE)}};l(Mr,"TYPE",et+"auth"),l(Mr,"matches",de(Mr.TYPE));let Xr=Mr;const Pr=class Ko extends Xr{constructor(){super(...arguments),l(this,"type",Ko.TYPE)}};l(Pr,"TYPE",Xr.TYPE+".invalid-token"),l(Pr,"matches",de(Pr.TYPE));let os=Pr;const Dr=class Wo extends Te{constructor(e){super(`
26
- Unexpected error encountered:
27
-
28
- ${e}
29
-
30
- Please report this to the Synnax team.
31
- `),l(this,"type",Wo.TYPE)}};l(Dr,"TYPE",et+"unexpected"),l(Dr,"matches",de(Dr.TYPE));let me=Dr;const Ur=class Go extends Te{constructor(){super(...arguments),l(this,"type",Go.TYPE)}};l(Ur,"TYPE",et+"query"),l(Ur,"matches",de(Ur.TYPE));let be=Ur;const Br=class Jo extends be{constructor(){super(...arguments),l(this,"type",Jo.TYPE)}};l(Br,"TYPE",be.TYPE+".not_found"),l(Br,"matches",de(Br.TYPE));let Qr=Br;const Lr=class Ho extends be{constructor(){super(...arguments),l(this,"type",Ho.TYPE)}};l(Lr,"TYPE",be.TYPE+".multiple_results"),l(Lr,"matches",de(Lr.TYPE));let en=Lr;const _r=class Xo extends Te{constructor(e,r){super(e),l(this,"type",Xo.TYPE),l(this,"path"),this.path=r}};l(_r,"TYPE",et+"route"),l(_r,"matches",de(_r.TYPE));let Da=_r;const Yr=class Qo extends Te{constructor(){super(...arguments),l(this,"type",Qo.TYPE)}};l(Yr,"TYPE",et+"control"),l(Yr,"matches",de(Yr.TYPE));let tn=Yr;const Zr=class ec extends tn{constructor(){super(...arguments),l(this,"type",ec.TYPE)}};l(Zr,"TYPE",tn.TYPE+".unauthorized"),l(Zr,"matches",de(Zr.TYPE));let Ua=Zr;const Bn=class tc extends Te{constructor(){super(...arguments),l(this,"type",tc.TYPE)}};l(Bn,"TYPE",et+"contiguity"),l(Bn,"matches",de(Bn.TYPE));const _d=t=>{if(!t.type.startsWith(et))return null;if(t.type.startsWith(W.TYPE)){if(t.type===Pa.TYPE){const e=t.data.split(": ");return e.length<2?new W(t.data):new Pa(e[0],e[1])}return new W(t.data)}return t.type.startsWith(Xr.TYPE)?t.type.startsWith(os.TYPE)?new os(t.data):new Xr(t.data):t.type.startsWith(me.TYPE)?new me(t.data):t.type.startsWith(be.TYPE)?t.type.startsWith(Qr.TYPE)?new Qr(t.data):t.type.startsWith(en.TYPE)?new en(t.data):new be(t.data):t.type.startsWith(tn.TYPE)?t.type.startsWith(Ua.TYPE)?new Ua(t.data):new tn(t.data):t.type.startsWith(Da.TYPE)?new Da(t.data,t.data):new me(t.data)},Yd=()=>{throw new Error("Not implemented")};ro({encode:Yd,decode:_d});const Zd=async(t,e)=>{const[r,n]=await e(t);return n==null?[r,n]:n instanceof ot?[r,new ot({message:`Cannot reach cluster at ${n.url.host}:${n.url.port}`,url:n.url})]:[r,n]},Hs=t=>t!=null&&typeof t=="object"&&!Array.isArray(t);var qd=Object.defineProperty,Fd=(t,e,r)=>e in t?qd(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Dt=(t,e,r)=>(Fd(t,typeof e!="symbol"?e+"":e,r),r);class rc{constructor(){Dt(this,"contentType","application/json"),Dt(this,"decoder"),Dt(this,"encoder"),this.decoder=new TextDecoder,this.encoder=new TextEncoder}encode(e){return this.encoder.encode(this.encodeString(e)).buffer}decode(e,r){return this.decodeString(this.decoder.decode(e),r)}decodeString(e,r){const n=Jr(JSON.parse(e));return r!=null?r.parse(n):n}encodeString(e){return JSON.stringify(Vf(e),(r,n)=>ArrayBuffer.isView(n)?Array.from(n):Hs(n)&&"encode_value"in n?typeof n.value=="bigint"?n.value.toString():n.value:typeof n=="bigint"?n.toString():n)}static registerCustomType(){}}let nc=class{constructor(){Dt(this,"contentType","text/csv")}encode(t){const e=this.encodeString(t);return new TextEncoder().encode(e).buffer}decode(t,e){const r=new TextDecoder().decode(t);return this.decodeString(r,e)}encodeString(t){if(!Array.isArray(t)||t.length===0||!Hs(t[0]))throw new Error("Payload must be an array of objects");const e=Object.keys(t[0]),r=[e.join(",")];return t.forEach(n=>{const s=e.map(i=>JSON.stringify(n[i]??""));r.push(s.join(","))}),r.join(`
32
- `)}decodeString(t,e){const[r,...n]=t.trim().split(`
33
- `).map(o=>o.trim());if(r.length===0)return e!=null?e.parse({}):{};const s=r.split(",").map(o=>o.trim()),i={};return s.forEach(o=>{i[o]=[]}),n.forEach(o=>{const c=o.split(",").map(u=>u.trim());s.forEach((u,f)=>{const w=this.parseValue(c[f]);w!=null&&i[u].push(w)})}),e!=null?e.parse(i):i}parseValue(t){if(t==null||t.length===0)return null;const e=Number(t);return isNaN(e)?t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1):t:e}static registerCustomType(){}};class sc{constructor(){Dt(this,"contentType","text/plain")}encode(e){return new TextEncoder().encode(e).buffer}decode(e,r){const n=new TextDecoder().decode(e);return r!=null?r.parse(n):n}}const ac=new rc,Vd=new nc,Kd=new sc,Wd=[ac],pt=Object.freeze(Object.defineProperty({__proto__:null,CSVEncoderDecoder:nc,CSV_ECD:Vd,ENCODERS:Wd,JSONEncoderDecoder:rc,JSON_ECD:ac,TEXT_ECD:Kd,TextEncoderDecoder:sc},Symbol.toStringTag,{value:"Module"}));var Gd=Object.defineProperty,Jd=(t,e,r)=>e in t?Gd(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,cs=(t,e,r)=>(Jd(t,typeof e!="symbol"?e+"":e,r),r);class Hd{constructor(e,r){cs(this,"handlers"),cs(this,"transform"),this.transform=e,this.handlers=r??new Map}onChange(e){return this.handlers.set(e,null),()=>this.handlers.delete(e)}notify(e){let r=e;if(this.transform!=null){const[n,s]=this.transform(e);if(!s)return;r=n}this.handlers.forEach((n,s)=>s(r))}}let Xd=class{constructor(t){cs(this,"handlers"),this.handlers=t??new Map}onChange(t){return this.handlers.set(t,null),()=>this.handlers.delete(t)}notify(t){this.handlers.forEach((e,r)=>r(t))}};const ls=Object.freeze(Object.defineProperty({__proto__:null,BaseObserver:Xd,Observer:Hd},Symbol.toStringTag,{value:"Module"})),Xs=a.z.record(a.z.union([a.z.number(),a.z.string(),a.z.symbol()]),a.z.unknown()),Qd=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser";Qd();const ey=["MacOS","Windows","Linux","Docker"];a.z.enum(ey);const Ba=t=>[...new Set(t)];var ty=Object.defineProperty,ry=(t,e,r)=>e in t?ty(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,xt=(t,e,r)=>(ry(t,typeof e!="symbol"?e+"":e,r),r);const ny=(...t)=>t.map(ic).join(""),ic=t=>(t.endsWith("/")||(t+="/"),t.startsWith("/")&&(t=t.slice(1)),t),sy=t=>t.endsWith("/")?t.slice(0,-1):t,us=class hs{constructor({host:e,port:r,protocol:n="",pathPrefix:s=""}){xt(this,"protocol"),xt(this,"host"),xt(this,"port"),xt(this,"path"),this.protocol=n,this.host=e,this.port=r,this.path=ic(s)}replace(e){return new hs({host:e.host??this.host,port:e.port??this.port,protocol:e.protocol??this.protocol,pathPrefix:e.pathPrefix??this.path})}child(e){return new hs({...this,pathPrefix:ny(this.path,e)})}toString(){return sy(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}};xt(us,"UNKNOWN",new us({host:"unknown",port:0}));let ay=us;var iy=Object.defineProperty,oy=(t,e,r)=>e in t?iy(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ln=(t,e,r)=>(oy(t,typeof e!="symbol"?e+"":e,r),r);const st=class extends Number{};Ln(st,"Absolute",255),Ln(st,"Default",1),Ln(st,"z",a.z.union([a.z.instanceof(st),a.z.number().int().min(0).max(255).transform(t=>new st(t)),a.z.instanceof(Number).transform(t=>new st(t))]));let oc=st;const cc=a.z.object({name:a.z.string(),key:a.z.string()}),cy=t=>a.z.object({subject:cc,resource:t,authority:oc.z}),ly=(...t)=>e=>e.filter(r=>{let n=!1;return r.to!=null&&(n=t.includes(r.to.resource)),r.from!=null&&!n&&(n=t.includes(r.from.resource)),n}),yt=Object.freeze(Object.defineProperty({__proto__:null,Authority:oc,filterTransfersByChannelKey:ly,stateZ:cy,subjectZ:cc},Symbol.toStringTag,{value:"Module"}));a.z.string().regex(/^\d+\.\d+\.\d+$/);const bn=(t,e,{convertNumericStrings:r=!0}={})=>{const n=!Array.isArray(t);let s=E(t);const i=s[0],o=typeof i;let c;return o==="string"&&r&&!isNaN(parseInt(i))&&"number"in e?(c=e.number,s=s.map(u=>parseInt(u))):c=e[o],{single:n,variant:c,normalized:s,actual:t}},On=(t,e,r,n)=>{if(n){if(r.length===0)throw new Qr(`${t} not found matching ${JSON.stringify(e)}`);if(r.length>1)throw new en(`Expected one ${t} matching ${JSON.stringify(e)}, but found ${r.length}`)}},gt=t=>a.z.union([a.z.null().transform(()=>[]),t.array()]),uy=a.z.object({leaseholder:a.z.number().optional(),keys:a.z.number().array().optional(),names:a.z.string().array().optional(),search:a.z.string().optional(),rangeKey:a.z.string().optional(),limit:a.z.number().optional(),offset:a.z.number().optional(),dataTypes:x.z.array().optional(),notDataTypes:x.z.array().optional(),virtual:a.z.boolean().optional(),isIndex:a.z.boolean().optional(),internal:a.z.boolean().optional()}),hy=a.z.object({channels:gt(Jt)}),Ge=t=>bn(t,{number:"keys",string:"names"}),lc=class uc{constructor(e){l(this,"client"),this.client=e}async search(e,r){return await this.execute({search:e,...r})}async retrieve(e,r){const n=Ge(e),{variant:s}=n;let{normalized:i}=n;return s==="keys"&&i.indexOf(0)!==-1&&(i=i.filter(o=>o!==0)),i.length===0?[]:await this.execute({[s]:i,...r})}async page(e,r,n){return await this.execute({offset:e,limit:r,...n})}async execute(e){const[r,n]=await this.client.send(uc.ENDPOINT,e,uy,hy);if(n!=null)throw n;return r.channels}};l(lc,"ENDPOINT","/channel/retrieve");let Qs=lc;class ea{constructor(e){l(this,"cache"),l(this,"namesToKeys"),l(this,"wrapped"),this.cache=new Map,this.namesToKeys=new Map,this.wrapped=e}async search(e,r){return await this.wrapped.search(e,r)}async page(e,r,n){return await this.wrapped.page(e,r,n)}async retrieve(e,r){const{normalized:n}=bn(e,{string:"names",number:"keys"}),s=[],i=[];if(n.forEach(c=>{const u=this.get(c);u!=null?s.push(...u):i.push(c)}),i.length===0)return s;const o=await this.wrapped.retrieve(i,r);return this.set(o),s.concat(o)}delete(e){const{variant:r,normalized:n}=Ge(e);r==="names"?n.forEach(s=>{const i=this.namesToKeys.get(s);i!=null&&(i.forEach(o=>this.cache.delete(o)),this.namesToKeys.delete(s))}):n.forEach(s=>{const i=this.cache.get(s);i!=null&&(this.cache.delete(s),this.namesToKeys.delete(i.name))})}rename(e,r){e.forEach((n,s)=>{const i=r[s],o=this.cache.get(n);if(o==null)return;this.cache.delete(n);const c=this.namesToKeys.get(o.name);c!=null&&(c.delete(n),c.size===0&&this.namesToKeys.delete(o.name)),o.name=i,this.cache.set(n,o);const u=this.namesToKeys.get(i);u==null?this.namesToKeys.set(i,new Set([n])):u.add(n)})}set(e){e.forEach(r=>{this.cache.set(r.key,r);const n=this.namesToKeys.get(r.name);n==null?this.namesToKeys.set(r.name,new Set([r.key])):n.add(r.key)})}get(e){if(typeof e=="number"){const s=this.cache.get(e);return s==null?void 0:[s]}const r=this.namesToKeys.get(e);if(r==null)return;const n=[];if(r.forEach(s=>{const i=this.cache.get(s);i!=null&&n.push(i)}),n.length!==0)return n}}class hc{constructor(e,r){l(this,"mu",new Ld),l(this,"requests",new Map),l(this,"wrapped"),l(this,"debouncedRun"),this.wrapped=e,this.debouncedRun=Rd(()=>{this.run()},r)}async search(e,r){return await this.wrapped.search(e,r)}async page(e,r,n){return await this.wrapped.page(e,r,n)}async retrieve(e){const{normalized:r,variant:n}=Ge(e);return n==="names"?await this.wrapped.retrieve(r):await new Promise((s,i)=>{this.mu.runExclusive(()=>{this.requests.set(r,{resolve:s,reject:i}),this.debouncedRun()})})}async run(){await this.mu.runExclusive(async()=>{const e=new Set;this.requests.forEach((r,n)=>n.forEach(s=>e.add(s)));try{const r=await this.wrapped.retrieve(Array.from(e));this.requests.forEach((n,s)=>n.resolve(r.filter(i=>s.includes(i.key))))}catch(r){this.requests.forEach(n=>n.reject(r))}finally{this.requests.clear()}})}}const fc=async(t,e)=>{const{normalized:r}=Ge(e),n=await t.retrieve(r),s=[];if(r.forEach(i=>{n.find(o=>o.name===i||o.key===i)==null&&s.push(i)}),s.length>0)throw new be(`Could not find channels: ${JSON.stringify(s)}`);return n};class dc{constructor(e,r){l(this,"key"),l(this,"name"),this.key=r,this.name=e}get ontologyID(){return new Oe({type:"group",key:this.key})}}const fy=a.z.string().uuid(),yc=a.z.object({key:fy,name:a.z.string()}),pc=a.z.union([a.z.literal("label"),a.z.literal("builtin"),a.z.literal("cluster"),a.z.literal("channel"),a.z.literal("node"),a.z.literal("group"),a.z.literal("range"),a.z.literal("range-alias"),a.z.literal("user"),a.z.literal("workspace"),a.z.literal("schematic"),a.z.literal("lineplot"),a.z.literal("rack"),a.z.literal("device"),a.z.literal("task")]),xe=a.z.object({type:pc,key:a.z.string()}),dy=a.z.string().transform(t=>{const[e,r]=t.split(":");return{type:e,key:r}}),yy=a.z.union([dy,xe]),qr=class gc{constructor(e){if(l(this,"type"),l(this,"key"),e instanceof gc)this.type=e.type,this.key=e.key;else if(typeof e=="string"){const[r,n]=e.split(":");this.type=r,this.key=n}else this.type=e.type,this.key=e.key}toString(){return`${this.type}:${this.key}`}get payload(){return{type:this.type,key:this.key}}};l(qr,"z",a.z.union([yy,a.z.instanceof(qr)]).transform(t=>new qr(t)));let Oe=qr;new Oe({type:"builtin",key:"root"});const py=a.z.object({type:a.z.number()}),gy=a.z.object({type:pc,fields:a.z.record(py)}),my=a.z.object({id:Oe.z,name:a.z.string(),schema:gy.optional().nullable(),data:a.z.record(a.z.unknown()).optional().nullable()}).transform(t=>({key:t.id.toString(),...t}));a.z.object({from:Oe.z,type:a.z.string(),to:Oe.z});const La=t=>{const[e,r,n]=t.split("->");return{from:new Oe(e),type:r,to:new Oe(n)}},wy=a.z.object({group:yc}),vy=a.z.object({parent:xe,key:a.z.string().uuid().optional(),name:a.z.string()}),by=a.z.object({key:a.z.string(),name:a.z.string()}),Oy=a.z.object({keys:a.z.array(a.z.string())});var Je;let Ty=(Je=class{constructor(t){l(this,"client"),this.client=t}async create(t,e,r){const[n,s]=await this.client.send(Je.ENDPOINT,{parent:t,name:e,key:r},vy,wy);if(s!=null)throw s;return n.group}async rename(t,e){const r={key:t,name:e},[,n]=await this.client.send(Je.ENDPOINT_RENAME,r,by,a.z.object({}));if(n!=null)throw n}async delete(t){const e={keys:t},[,r]=await this.client.send(Je.ENDPOINT_DELETE,e,Oy,a.z.object({}));if(r!=null)throw r}},l(Je,"ENDPOINT","/ontology/create-group"),l(Je,"ENDPOINT_RENAME","/ontology/rename-group"),l(Je,"ENDPOINT_DELETE","/ontology/delete-group"),Je),zy=class{constructor(t){l(this,"creator"),this.creator=new Ty(t)}async create(t,e,r){return this.sugar(await this.creator.create(t,e,r))}async rename(t,e){return await this.creator.rename(t,e)}async delete(...t){return await this.creator.delete(t)}sugar(t){return new dc(t.name,t.key)}};const _n={ADD_CHILDREN:"/ontology/add-children",REMOVE_CHILDREN:"/ontology/remove-children",MOVE_CHILDREN:"/ontology/move-children"},_a=a.z.object({id:xe,children:xe.array()}),Sy=a.z.object({from:xe,to:xe,children:xe.array()});let Ny=class{constructor(t){l(this,"client"),this.client=t}async addChildren(t,...e){await b(this.client,_n.ADD_CHILDREN,{id:t,children:e},_a,a.z.object({}))}async removeChildren(t,...e){await b(this.client,_n.REMOVE_CHILDREN,{id:t,children:e},_a,a.z.object({}))}async moveChildren(t,e,...r){const n={from:t,to:e,children:r};await b(this.client,_n.MOVE_CHILDREN,n,Sy,a.z.object({}))}};const Ay="/ontology/retrieve",Ey=a.z.object({ids:xe.array().optional(),children:a.z.boolean().optional(),parents:a.z.boolean().optional(),includeSchema:a.z.boolean().optional(),excludeFieldData:a.z.boolean().optional(),term:a.z.string().optional(),limit:a.z.number().optional(),offset:a.z.number().optional()}),Iy=a.z.object({resources:my.array()}),Yn=t=>E(t).map(e=>new Oe(e).payload);let ky=class{constructor(t,e){l(this,"type","ontology"),l(this,"groups"),l(this,"client"),l(this,"writer"),l(this,"framer"),this.client=t,this.writer=new Ny(t),this.groups=new zy(t),this.framer=e}async search(t,e){return await this.execRetrieve({term:t,...e})}async retrieve(t,e){const r=await this.execRetrieve({ids:Yn(t),...e});if(Array.isArray(t))return r;if(r.length===0)throw new be(`No resource found with ID ${t.toString()}`);return r[0]}async page(t,e,r){return await this.execRetrieve({offset:t,limit:e,...r})}async retrieveChildren(t,e){return await this.execRetrieve({ids:Yn(t),children:!0,...e})}async retrieveParents(t,e){return await this.execRetrieve({ids:Yn(t),parents:!0,...e})}async addChildren(t,...e){return await this.writer.addChildren(t,...e)}async removeChildren(t,...e){return await this.writer.removeChildren(t,...e)}async moveChildren(t,e,...r){return await this.writer.moveChildren(t,e,...r)}async openChangeTracker(){return await ta.open(this.framer,this)}newSearcherWithOptions(t){return{type:this.type,search:e=>this.search(e,t),retrieve:e=>this.retrieve(e,t),page:(e,r)=>this.page(e,r,t)}}async execRetrieve(t){const{resources:e}=await b(this.client,Ay,t,Ey,Iy);return e}};const Ya="sy_ontology_resource_set",Za="sy_ontology_resource_delete",qa="sy_ontology_relationship_set",Fa="sy_ontology_relationship_delete";class ta{constructor(e,r){l(this,"resourceObs"),l(this,"relationshipObs"),l(this,"relationships"),l(this,"resources"),l(this,"streamer"),l(this,"client"),l(this,"closePromise"),this.relationshipObs=new ls.Observer,this.relationships=this.relationshipObs,this.resourceObs=new ls.Observer,this.resources=this.resourceObs,this.client=r,this.streamer=e,this.closePromise=this.start()}async close(){this.streamer.close(),await this.closePromise}async start(){for await(const e of this.streamer)await this.update(e)}async update(e){const r=await this.parseResourceSets(e),n=this.parseResourceDeletes(e);r.concat(n).length>0&&this.resourceObs.notify(r.concat(n));const s=this.parseRelationshipSets(e),i=this.parseRelationshipDeletes(e);s.concat(i).length>0&&this.relationshipObs.notify(s.concat(i))}parseRelationshipSets(e){const r=e.get(qa);return r.length===0?[]:Array.from(r.as("string")).map(n=>({variant:"set",key:La(n),value:void 0}))}parseRelationshipDeletes(e){const r=e.get(Fa);return r.length===0?[]:Array.from(r.as("string")).map(n=>({variant:"delete",key:La(n)}))}async parseResourceSets(e){const r=e.get(Ya);if(r.length===0)return[];const n=Array.from(r.as("string")).map(s=>new Oe(s));try{return(await this.client.retrieve(n)).map(s=>({variant:"set",key:s.id,value:s}))}catch(s){if(s instanceof be)return[];throw s}}parseResourceDeletes(e){const r=e.get(Za);return r.length===0?[]:Array.from(r.as("string")).map(n=>({variant:"delete",key:new Oe(n)}))}static async open(e,r){const n=await e.openStreamer([Ya,Za,qa,Fa]);return new ta(n,r)}}class mc{constructor({dataType:e,rate:r,name:n,leaseholder:s=0,key:i=0,isIndex:o=!1,index:c=0,internal:u=!1,frameClient:f,alias:w}){l(this,"_frameClient"),l(this,"key"),l(this,"name"),l(this,"rate"),l(this,"dataType"),l(this,"leaseholder"),l(this,"index"),l(this,"isIndex"),l(this,"internal"),l(this,"alias"),this.key=i,this.name=n,this.rate=new Js(r??0),this.dataType=new x(e),this.leaseholder=s,this.index=c,this.isIndex=o,this.internal=u,this.alias=w,this._frameClient=f??null}get framer(){if(this._frameClient==null)throw new W("cannot read from a channel that has not been created");return this._frameClient}get payload(){return Jt.parse({key:this.key,name:this.name,rate:this.rate.valueOf(),dataType:this.dataType.valueOf(),leaseholder:this.leaseholder,index:this.index,isIndex:this.isIndex,internal:this.internal})}get ontologyID(){return new Oe({type:"channel",key:this.key.toString()})}async read(e){return await this.framer.read(e,this.key)}async write(e,r){return await this.framer.write(e,this.key,r)}}const xy="/channel/retrieve-group",Cy=a.z.object({}),jy=a.z.object({group:yc});let wc=class{constructor(t,e,r,n){l(this,"type","channel"),l(this,"frameClient"),l(this,"client"),l(this,"retriever"),l(this,"writer"),this.frameClient=t,this.retriever=e,this.client=r,this.writer=n}async create(t,e={}){const{retrieveIfNameExists:r=!1}=e,n=!Array.isArray(t);let s=E(t),i=[];if(r){const o=await this.retriever.retrieve(s.map(u=>u.name)),c=new Set(o.map(u=>u.name));s=s.filter(u=>!c.has(u.name)),i=this.sugar(o)}return i=i.concat(this.sugar(await this.writer.create(s))),n?i[0]:i}async retrieve(t,e){const r=!Array.isArray(t),n=this.sugar(await this.retriever.retrieve(t,e));return On("channel",t,n,r),r?n[0]:n}async search(t,e){return this.sugar(await this.retriever.search(t,e))}async delete(t){const{normalized:e,variant:r}=Ge(t);return r==="keys"?await this.writer.delete({keys:e}):await this.writer.delete({names:e})}async rename(t,e){return await this.writer.rename(E(t),E(e))}newSearcherWithOptions(t){return{type:this.type,search:async e=>await this.search(e,t),retrieve:async e=>await this.retrieve(e,t),page:async(e,r)=>await this.page(e,r,t)}}async page(t,e,r){return this.sugar(await this.retriever.page(t,e,r))}createDebouncedBatchRetriever(t=10){return new ea(new hc(new Qs(this.client),t))}sugar(t){const{frameClient:e}=this;return t.map(r=>new mc({...r,frameClient:e}))}async retrieveGroup(){const t=await b(this.client,xy,{},Cy,jy);return new dc(t.group.name,t.group.key)}};const $y=a.z.object({channels:Yo.array()}),Ry=a.z.object({channels:Jt.array()}),My=a.z.object({keys:Qe.array().optional(),names:a.z.string().array().optional()}),Py=a.z.object({}),Dy=a.z.object({keys:Qe.array(),names:a.z.string().array()}),Uy=a.z.object({}),By="/channel/create",Ly="/channel/delete",_y="/channel/rename";let vc=class{constructor(t,e){l(this,"client"),l(this,"cache"),this.client=t,this.cache=e}async create(t){const{channels:e}=await b(this.client,By,{channels:t},$y,Ry);return this.cache.set(e),e}async delete(t){await b(this.client,Ly,t,My,Py),t.keys!=null&&this.cache.delete(t.keys),t.names!=null&&this.cache.delete(t.names)}async rename(t,e){await b(this.client,_y,{keys:t,names:e},Dy,Uy),this.cache.rename(t,e)}};const Yy=Object.freeze(Object.defineProperty({__proto__:null,CacheRetriever:ea,Channel:mc,Client:wc,ClusterRetriever:Qs,DebouncedBatchRetriever:hc,Writer:vc,analyzeChannelParams:Ge,keyZ:Qe,newPayload:Yo,payload:Jt,retrieveRequired:fc},Symbol.toStringTag,{value:"Module"})),Zy=a.z.object({key:a.z.string(),username:a.z.string()}),qy=a.z.object({username:a.z.string(),password:a.z.string()}),Fy=a.z.object({token:a.z.string(),user:Zy}),Va="/auth/login",Vy=3;let Ky=class{constructor(t,e){l(this,"token"),l(this,"client"),l(this,"credentials"),l(this,"authenticating"),l(this,"authenticated"),l(this,"user"),l(this,"retryCount"),this.client=t,this.authenticated=!1,this.credentials=e,this.retryCount=0}middleware(){const t=async(e,r)=>{if(!this.authenticated&&!e.target.endsWith(Va)){this.authenticating==null&&(this.authenticating=new Promise((o,c)=>{this.client.send(Va,this.credentials,qy,Fy).then(([u,f])=>{if(f!=null)return o(f);this.token=u==null?void 0:u.token,this.user=u==null?void 0:u.user,this.authenticated=!0,o(null)}).catch(c)}));const i=await this.authenticating;if(i!=null)return[e,i]}e.params.Authorization=`Bearer ${this.token}`;const[n,s]=await r(e);return os.matches(s)&&this.retryCount<Vy?(this.authenticated=!1,this.authenticating=void 0,this.retryCount+=1,t(e,r)):(this.retryCount=0,[n,s])};return t}};const Wy=["disconnected","connecting","connected","failed"],Gy=a.z.enum(Wy),Jy=a.z.object({status:Gy,error:a.z.instanceof(Error).optional(),message:a.z.string().optional(),clusterKey:a.z.string()}),Hy=a.z.object({clusterKey:a.z.string()}),bc={clusterKey:"",status:"disconnected",error:void 0,message:"Disconnected"},Fr=class Oc{constructor(e,r=k.seconds(30),n){l(this,"_state"),l(this,"pollFrequency",k.seconds(30)),l(this,"client"),l(this,"name"),l(this,"interval"),l(this,"onChangeHandlers",[]),this._state={...bc},this.client=e,this.pollFrequency=r,this.name=n,this.check(),this.startChecking()}stopChecking(){this.interval!=null&&clearInterval(this.interval)}async check(){var e;const r=this._state.status;try{const[n,s]=await this.client.send(Oc.ENDPOINT,{},a.z.object({}),Hy);if(s!=null)throw s;this._state.status="connected",this._state.message=`Connected to ${this.name??"cluster"}`,this._state.clusterKey=n.clusterKey}catch(n){this._state.status="failed",this._state.error=n,this._state.message=(e=this.state.error)==null?void 0:e.message}return this.onChangeHandlers.length>0&&r!==this._state.status&&this.onChangeHandlers.forEach(n=>n(this.state)),this.state}get state(){return{...this._state}}onChange(e){this.onChangeHandlers.push(e)}startChecking(){this.interval=setInterval(()=>{this.check()},this.pollFrequency.milliseconds)}};l(Fr,"ENDPOINT","/connectivity/check"),l(Fr,"DEFAULT",bc),l(Fr,"connectionStateZ",Jy);let Tc=Fr;const Xy=a.z.object({keys:Qe.array().optional(),names:a.z.string().array().optional(),bounds:le.z}),Qy=a.z.object({}),ep="/frame/delete";class tp{constructor(e){l(this,"client"),this.client=e}async delete(e){await b(this.client,ep,e,Xy,Qy)}}const Ka=t=>{const e=E(t);return e.length===0?null:typeof e[0]=="number"||!isNaN(parseInt(e[0]))?"key":"name"},Wa=(t,e)=>{const r=E(t);if(r.length===e.length)return;const n=Ka(t);throw Ka===null?new W("[Frame] - channel keys or names must be provided when constructing a frame."):new W(`[Frame] - ${n}s and arrays must be the same length.
34
- Got ${r.length} ${n}s and ${e.length} arrays.`)};let ge=class ft{constructor(e=[],r=[]){if(l(this,"columns",[]),l(this,"series",[]),e instanceof ft){this.columns=e.columns,this.series=e.series;return}if(e instanceof Map){e.forEach((n,s)=>this.push(s,...E(n)));return}if(typeof e=="object"&&!Array.isArray(e)){if("keys"in e&&"series"in e){const n=e,s=n.series.map(i=>Sc(i));Wa(n.keys,s),n.keys.forEach((i,o)=>this.push(i,s[o]))}else Object.entries(e).forEach(([n,s])=>{const i=parseInt(n);if(isNaN(i))this.push(n,...E(s));else return this.push(i,...E(s))});return}if(Array.isArray(e)||["string","number"].includes(typeof e)){const n=E(r),s=E(e);Wa(s,n),n.forEach((i,o)=>this.push(s[o],i));return}throw new W(`[Frame] - invalid frame construction parameters. data parameter ust be a frame
35
- payload, a list of lazy arrays, a lazy array, a map, or a record keyed by channel
36
- name. keys parameter must be a set of channel keys or channel names.`)}get colType(){return this.columns.length===0?null:typeof this.columns[0]=="string"?"name":"key"}get keys(){if(this.colType==="name")throw new me("colType is not key");return this.columns??[]}get uniqueKeys(){return Ba(this.keys)}get names(){if(this.colType==="key")throw new me("colType is not name");return this.columns??[]}get uniqueNames(){return Ba(this.names)}get uniqueColumns(){return this.colType==="key"?this.uniqueKeys:this.uniqueNames}toPayload(){return{series:this.series.map(e=>Nc(e)),keys:this.keys}}get isVertical(){return this.uniqueColumns.length===this.columns.length}get isHorizontal(){return this.uniqueColumns.length===1}get isSquare(){return this.isHorizontal&&this.isVertical}get isWeaklyAligned(){if(this.columns.length<=1)return!0;const e=this.timeRanges;return e.every(r=>r.equals(e[0]))}timeRange(e){if(e==null){if(this.columns.length===0)return le.ZERO;const n=I.min(...this.series.map(i=>i.timeRange.start)),s=I.max(...this.series.map(i=>i.timeRange.end));return new le(n,s)}const r=this.get(e);return r==null?le.ZERO:r.timeRange}latest(){return this.at(-1)}get timeRanges(){return this.uniqueColumns.map(e=>this.timeRange(e))}get(e){return Array.isArray(e)?this.filter(r=>e.includes(r)):new jd(this.series.filter((r,n)=>this.columns[n]===e))}push(e,...r){if(e instanceof ft){if(this.colType!==null&&e.colType!==this.colType)throw new W("keyVariant must match");this.series.push(...e.series),this.columns.push(...e.columns)}else{if(this.series.push(...r),typeof e=="string"&&this.colType==="key")throw new W("keyVariant must match");if(typeof e!="string"&&this.colType==="name")throw new W("keyVariant must match");this.columns.push(...Array.from({length:r.length},()=>e))}}concat(e){return new ft([...this.columns,...e.columns],[...this.series,...e.series])}has(e){return typeof e=="string"&&this.colType==="key"||typeof e=="number"&&this.colType==="name"?!1:this.columns.includes(e)}map(e){const r=new ft;return this.forEach((n,s,i)=>r.push(...e(n,s,i))),r}forEach(e){this.columns.forEach((r,n)=>{const s=this.series[n];e(r,s,n)})}at(e,r=!1){const n={};return this.uniqueColumns.forEach(s=>{n[s]=this.get(s).at(e,r)}),n}filter(e){const r=new ft;return this.columns.forEach((n,s)=>{const i=this.series[s];e(n,i,s)&&r.push(n,i)}),r}get byteLength(){return new _t(this.series.reduce((e,r)=>e.add(r.byteLength),_t.ZERO))}get length(){return this.series.reduce((e,r)=>e+r.length,0)}};const zc=a.z.object({timeRange:le.z.optional(),alignment:a.z.bigint().or(a.z.string().transform(t=>BigInt(t))).optional(),dataType:x.z,data:a.z.string().transform(t=>new Uint8Array(atob(t).split("").map(e=>e.charCodeAt(0))).buffer)}),Tn=a.z.object({keys:a.z.union([a.z.null().transform(()=>[]),a.z.number().array().optional().default([])]),series:a.z.union([a.z.null().transform(()=>[]),zc.array().optional().default([])])}),Sc=t=>{const{dataType:e,data:r,timeRange:n,alignment:s}=t;return new at({data:r,dataType:e,timeRange:n,glBufferUsage:"static",alignment:s})},Nc=t=>({timeRange:t._timeRange,dataType:t.dataType,data:new Uint8Array(t.data.buffer),alignment:t.alignment});class zn{constructor(e){l(this,"adapter"),l(this,"retriever"),l(this,"keys"),this.retriever=e,this.adapter=null,this.keys=[]}static async open(e,r){const n=new zn(e);return await n.update(r),n}async update(e){const{variant:r,normalized:n}=Ge(e);if(r==="keys"){this.adapter=null,this.keys=n;return}const s=await this.retriever.retrieve(n),i=new Map;this.adapter=i,n.forEach(o=>{const c=s.find(u=>u.name===o);if(c==null)throw new Error(`Channel ${o} not found`);i.set(c.key,c.name)}),this.keys=Array.from(this.adapter.keys())}adapt(e){if(this.adapter==null)return e;const r=this.adapter;return e.map((n,s)=>{if(typeof n=="number"){const i=r.get(n);if(i==null)throw new Error(`Channel ${n} not found`);return[i,s]}return[n,s]})}}class ra{constructor(e){l(this,"adapter"),l(this,"retriever"),l(this,"keys"),this.retriever=e,this.adapter=null,this.keys=[]}static async open(e,r){const n=new ra(e);return await n.update(r),n}async update(e){const r=await fc(this.retriever,e);this.adapter=new Map(r.map(n=>[n.name,n.key])),this.keys=r.map(n=>n.key)}async fetchChannel(e){const r=await this.retriever.retrieve(e);if(r.length===0)throw new Error(`Channel ${e} not found`);return r[0]}async adapt(e,r){if(typeof e=="string"||typeof e=="number"){if(r==null)throw new W(`
37
- Received a single channel name or key but no series.
38
- `);if(Array.isArray(r)){if(r.some(u=>u instanceof at||Array.isArray(u)))throw new W(`
39
- Received a single channel name or key but multiple series.
40
- `);r=r}const o=await this.fetchChannel(e),c=new at({data:r,dataType:o.dataType});return new ge(o.key,c)}if(Array.isArray(e)){if(r==null)throw new W(`
41
- Received an array of channel names or keys but no series.
42
- `);if(!Array.isArray(r))throw new W(`
43
- Received an array of channel names or keys but no array of series.
44
- `);const o=[],c=[];for(let u=0;u<e.length;u++){const f=await this.fetchChannel(e[u]);if(u>=r.length)throw new W(`
45
- Received an array of channel names or keys but not enough series.
46
- `);const w=new at({data:r[u],dataType:f.dataType});o.push(f.key),c.push(w)}return new ge(o,c)}if(e instanceof ge||e instanceof Map){const o=new ge(e);if(this.adapter==null)return o;let c=[];return c=o.columns.map(u=>{var f;const w=typeof u=="string"?(f=this.adapter)==null?void 0:f.get(u):u;if(w==null)throw new W(`
47
- Channel ${u} was not provided in the list of channels when opening the writer
48
- `);return w}),new ge(c,o.series)}const n=[],s=[],i=Object.entries(e);for(let o=0;o<i.length;o++){const[c,u]=i[o],f=await this.fetchChannel(c),w=new at({data:u,dataType:f.dataType});n.push(f.key),s.push(w)}return new ge(n,s)}}class na{constructor(e,r){l(this,"name"),l(this,"stream"),this.stream=r,this.name=e}async receive(){const[e,r]=await this.stream.receive();if(r!=null)throw r;return e}received(){return this.stream.received()}async closeAndAck(){for(this.stream.closeSend();;){const[e,r]=await this.stream.receive();if(e!=null&&console.warn(`${this.name} received unexpected response on closure.
49
- Please report this error to the Synnax team. ${JSON.stringify(e)}`),r!=null){if(Xe.matches(r))return;throw r}}}closeSend(){this.stream.closeSend()}send(e){const r=this.stream.send(e);if(r!=null)throw r}}const fs=new k(-1);var sa=(t=>(t[t.Open=0]="Open",t[t.Next=1]="Next",t[t.Prev=2]="Prev",t[t.SeekFirst=3]="SeekFirst",t[t.SeekLast=4]="SeekLast",t[t.SeekLE=5]="SeekLE",t[t.SeekGE=6]="SeekGE",t[t.Valid=7]="Valid",t[t.Error=8]="Error",t))(sa||{}),Ac=(t=>(t[t.None=0]="None",t[t.Ack=1]="Ack",t[t.Data=2]="Data",t))(Ac||{});const rp=a.z.object({command:a.z.nativeEnum(sa),span:k.z.optional(),bounds:le.z.optional(),stamp:I.z.optional(),keys:a.z.number().array().optional(),chunkSize:a.z.number().optional()}),np=a.z.object({variant:a.z.nativeEnum(Ac),ack:a.z.boolean(),command:a.z.nativeEnum(sa),error:Gt.optional().nullable(),frame:Tn.optional()}),Ec=class ds{constructor(e,r){l(this,"stream"),l(this,"adapter"),l(this,"value"),this.stream=new na("Iterator",e),this.value=new ge,this.adapter=r}static async _open(e,r,n,s,i={}){const o=await zn.open(n,r),c=await s.stream(ds.ENDPOINT,rp,np),u=new ds(c,o);return await u.execute({command:0,keys:o.keys,bounds:new le(e),chunkSize:i.chunkSize??1e5}),u}async next(e=fs){return await this.execute({command:1,span:new k(e)})}async prev(e=fs){return await this.execute({command:2,span:new k(e)})}async seekFirst(){return await this.execute({command:3})}async seekLast(){return await this.execute({command:4})}async seekLE(e){return await this.execute({command:5,stamp:new I(e)})}async seekGE(e){return await this.execute({command:6,stamp:new I(e)})}async valid(){return await this.execute({command:7})}async close(){await this.stream.closeAndAck()}[Symbol.asyncIterator](){return new sp(this)}async execute(e){for(this.stream.send(e),this.value=new ge;;){const r=await this.stream.receive();if(r.variant===1)return r.ack;this.value.push(this.adapter.adapt(new ge(r.frame)))}}};l(Ec,"ENDPOINT","/frame/iterate");let Ic=Ec;class sp{constructor(e){l(this,"iter"),l(this,"open",!1),this.iter=e}async next(){try{let e=!0;return this.open||(await this.iter.seekFirst()||(e=!1),this.open=!0),await this.iter.next()||(e=!1),e||await this.iter.close(),{done:!e,value:this.iter.value}}catch(e){throw await this.iter.close(),e}}}const ap=a.z.object({start:I.z.optional(),keys:a.z.number().array()}),ip=a.z.object({frame:Tn,error:Gt.optional().nullable()}),op="/frame/stream";class Sn{constructor(e,r){l(this,"stream"),l(this,"adapter"),this.stream=new na("Streamer",e),this.adapter=r}get keys(){return this.adapter.keys}static async _open(e,r,{channels:n,from:s}){const i=await zn.open(e,n),o=await r.stream(op,ap,ip),c=new Sn(o,i);return o.send({start:new I(s),keys:i.keys}),c}async next(){try{return{done:!1,value:await this.read()}}catch(e){if(Xe.matches(e))return{done:!0,value:void 0};throw e}}async read(){return this.adapter.adapt(new ge((await this.stream.receive()).frame))}async update(e){await this.adapter.update(e),this.stream.send({keys:this.adapter.keys})}close(){this.stream.closeSend()}[Symbol.asyncIterator](){return this}}class Ht extends ls.Observer{constructor(e,r){super(r),l(this,"streamer"),l(this,"closePromise"),this.streamer=e,this.closePromise=this.stream()}async close(){this.streamer.close(),await this.closePromise}async stream(){for await(const e of this.streamer)this.notify(e)}}var aa=(t=>(t[t.Open=0]="Open",t[t.Write=1]="Write",t[t.Commit=2]="Commit",t[t.Error=3]="Error",t[t.SetAuthority=4]="SetAuthority",t))(aa||{}),Yt=(t=>(t[t.PersistStream=1]="PersistStream",t[t.PersistOnly=2]="PersistOnly",t[t.StreamOnly=3]="StreamOnly",t))(Yt||{});const cp=new k(-1),lp=a.z.object({start:I.z.optional(),controlSubject:yt.subjectZ.optional(),keys:a.z.number().array().optional(),authorities:yt.Authority.z.array().optional(),mode:a.z.nativeEnum(Yt).optional(),errOnUnauthorized:a.z.boolean().optional(),enableAutoCommit:a.z.boolean().optional(),autoIndexPersistInterval:k.z.optional()}),up=a.z.object({command:a.z.nativeEnum(aa),config:lp.optional(),frame:Tn.optional()}),hp=a.z.object({ack:a.z.boolean(),command:a.z.nativeEnum(aa),error:Gt.optional().nullable()});var bt;let kc=(bt=class{constructor(t,e){l(this,"stream"),l(this,"adapter"),this.stream=new na("Writer",t),this.adapter=e}static async _open(t,e,{channels:r,start:n=I.now(),authorities:s=yt.Authority.Absolute,controlSubject:i,mode:o=1,errOnUnauthorized:c=!1,enableAutoCommit:u=!1,autoIndexPersistInterval:f=k.SECOND}){const w=await ra.open(t,r),h=await e.stream(bt.ENDPOINT,up,hp),D=new bt(h,w);return await D.execute({command:0,config:{start:new I(n),keys:w.keys,controlSubject:i,authorities:E(s),mode:o,errOnUnauthorized:c,enableAutoCommit:u,autoIndexPersistInterval:f}}),D}async write(t,e){const r=await this.adapter.adapt(t,e);return this.stream.send({command:1,frame:r.toPayload()}),!0}async setAuthority(t){return(await this.execute({command:4,config:{keys:Object.keys(t).map(e=>Number(e)),authorities:Object.values(t)}})).ack}async commit(){return this.errorAccumulated?!1:(await this.execute({command:2})).ack}async error(){this.stream.send({command:3});const t=await this.execute({command:3});return t.error!=null?Ds(t.error):null}async close(){await this.stream.closeAndAck()}async execute(t){for(this.stream.send(t);;){const e=await this.stream.receive();if(e.command===t.command)return e;console.warn("writer received unexpected response",e)}}get errorAccumulated(){return this.stream.received()}},l(bt,"ENDPOINT","/frame/write"),bt),xc=class{constructor(t,e,r){l(this,"streamClient"),l(this,"retriever"),l(this,"deleter"),this.streamClient=t,this.retriever=r,this.deleter=new tp(e)}async openIterator(t,e,r){return await Ic._open(t,e,this.retriever,this.streamClient,r)}async openWriter(t){return(Array.isArray(t)||typeof t!="object")&&(t={channels:t}),await kc._open(this.retriever,this.streamClient,t)}async openStreamer(t){return(Array.isArray(t)||typeof t!="object")&&(t={channels:t}),await Sn._open(this.retriever,this.streamClient,t)}async write(t,e,r){if(r==null){const s=e,i=await this.openWriter({start:t,channels:Object.keys(s),mode:Yt.PersistOnly});try{await i.write(s),await i.commit()}finally{await i.close()}return}const n=await this.openWriter({start:t,channels:e,mode:Yt.PersistOnly,errOnUnauthorized:!0,enableAutoCommit:!0,autoIndexPersistInterval:k.MAX});try{await n.write(e,r)}finally{await n.close()}}async read(t,e){const{single:r}=Ge(e),n=await this.readFrame(t,e);return r?n.get(e):n}async readFrame(t,e){const r=await this.openIterator(t,e),n=new ge;try{for await(const s of r)n.push(s)}finally{await r.close()}return n}async delete(t,e){const{normalized:r,variant:n}=Ge(t);return n==="keys"?await this.deleter.delete({keys:r,bounds:e}):await this.deleter.delete({names:r,bounds:e})}};const fp=Object.freeze(Object.defineProperty({__proto__:null,ALWAYS_INDEX_PERSIST_ON_AUTO_COMMIT:cp,AUTO_SPAN:fs,Client:xc,Frame:ge,Iterator:Ic,ObservableStreamer:Ht,Streamer:Sn,Writer:kc,WriterMode:Yt,frameZ:Tn,series:zc,seriesFromPayload:Sc,seriesToPayload:Nc},Symbol.toStringTag,{value:"Module"})),dp=yt.Authority,yp=yt.stateZ(a.z.number()),pp=t=>{var e,r;return t.to==null?`${(e=t.from)==null?void 0:e.resource} - ${(r=t.from)==null?void 0:r.subject.name} -> released`:t.from==null?`${t.to.resource} - released -> ${t.to.subject.name} (${t.to.authority.toString()})`:`${t.to.resource} - ${t.from.subject.name} -> ${t.to.subject.name} (${t.to.authority.toString()})`};class Cc extends Ht{constructor(e){super(e,r=>{const n=this.ecd.decode(r.series[0].buffer);return this.merge(n),[n.transfers,!0]}),l(this,"states"),l(this,"ecd"),this.states=new Map,this.ecd=new pt.JSONEncoderDecoder}subjects(){const e=new Map;return this.states.forEach(r=>e.set(r.subject.key,r.subject)),Array.from(e.values())}merge(e){e.transfers.forEach(r=>{r.from==null&&r.to==null&&console.warn("Invalid transfer: ",r),r.to==null?this.states.delete(r.from.resource):this.states.set(r.to.resource,r.to)})}}const gp="sy_node_1_control";let jc=class{constructor(t){l(this,"framer"),this.framer=t}async openStateTracker(){const t=await this.framer.openStreamer(gp);return new Cc(t)}};const mp=Object.freeze(Object.defineProperty({__proto__:null,Authority:dp,Client:jc,StateTracker:Cc,stateZ:yp,transferString:pp},Symbol.toStringTag,{value:"Module"}));let wp=class{constructor(t,e,r){l(this,"tasks"),l(this,"racks"),l(this,"devices"),this.tasks=t,this.racks=e,this.devices=r}};const Xt=a.z.number(),ia=a.z.object({key:Xt,name:a.z.string()}),vp=ia.partial({key:!0}),Zn="/hardware/rack/retrieve",bp="/hardware/rack/create",Op="/hardware/rack/delete",qn=a.z.object({keys:Xt.array().optional(),names:a.z.string().array().optional(),search:a.z.string().optional(),offset:a.z.number().optional(),limit:a.z.number().optional()}),Fn=a.z.object({racks:gt(ia)}),Tp=a.z.object({racks:vp.array()}),zp=a.z.object({racks:ia.array()}),Sp=a.z.object({keys:Xt.array()}),Np=a.z.object({});let Ap=class{constructor(t,e,r){l(this,"type","rack"),l(this,"client"),l(this,"frameClient"),l(this,"tasks"),this.client=t,this.frameClient=e,this.tasks=r}async delete(t){await b(this.client,Op,{keys:E(t)},Sp,Np)}async create(t){const e=!Array.isArray(t),r=await b(this.client,bp,{racks:E(t)},Tp,zp),n=this.sugar(r.racks);return e?n[0]:n}async search(t){const e=await b(this.client,Zn,{search:t},qn,Fn);return this.sugar(e.racks)}async page(t,e){const r=await b(this.client,Zn,{offset:t,limit:e},qn,Fn);return this.sugar(r.racks)}async retrieve(t){const{variant:e,normalized:r,single:n}=bn(t,{string:"names",number:"keys"}),s=await b(this.client,Zn,{[e]:r},qn,Fn),i=this.sugar(s.racks);return On("Rack",t,i,n),n?i[0]:i}sugar(t){return t.map(({key:e,name:r})=>new Ep(e,r,this.tasks))}};class Ep{constructor(e,r,n){l(this,"key"),l(this,"name"),l(this,"tasks"),this.key=e,this.name=r,this.tasks=n}async listTasks(){return await this.tasks.retrieve(this.key)}async retrieveTaskByName(e){return await this.tasks.retrieveByName(e,this.key)}async createTask(e){return e.key=((BigInt(this.key)<<32n)+(BigInt(e.key??0)&0xffffffffn)).toString(),await this.tasks.create(e)}async deleteTask(e){await this.tasks.delete([e])}}const Qt=async(t,e,r,n)=>{const s=await t.openStreamer([e,r]),i=o=>{const c=[];return r!=null&&c.push(...o.get(r).series.flatMap(u=>n("delete",u))),e!=null&&c.push(...o.get(e).series.flatMap(u=>n("set",u))),[c,c.length>0]};return new Ht(s,i)},Ip="sy_device_set",kp="sy_device_delete",Vn="/hardware/device/retrieve",xp="/hardware/device/create",Cp="/hardware/device/delete",oa=a.z.string(),Nn=a.z.object({key:oa,rack:Xt,name:a.z.string(),make:a.z.string(),model:a.z.string(),location:a.z.string(),configured:a.z.boolean().optional(),properties:a.z.record(a.z.unknown()).or(a.z.string().transform(t=>t===""?{}:pt.JSON_ECD.decodeString(t)))}),jp=Nn.extend({properties:a.z.unknown().transform(t=>pt.JSON_ECD.encodeString(t))}),$p=a.z.object({devices:jp.array()}),Rp=a.z.object({devices:Nn.array()}),Mp=a.z.object({keys:oa.array()}),Pp=a.z.object({}),Kn=a.z.object({search:a.z.string().optional(),limit:a.z.number().optional(),offset:a.z.number().optional(),keys:oa.array().optional(),names:a.z.string().array().optional(),makes:a.z.string().array().optional()}),Wn=a.z.object({devices:gt(Nn)});let Dp=class{constructor(t,e){l(this,"type","device"),l(this,"client"),l(this,"frameClient"),this.client=t,this.frameClient=e}async retrieve(t,e){const r=!Array.isArray(t),n=await b(this.client,Vn,{keys:E(t),...e},Kn,Wn);return On("Device",t,n.devices,r),r?n.devices[0]:n.devices}async search(t,e){return(await b(this.client,Vn,{search:t,...e},Kn,Wn)).devices}async page(t,e,r){return(await b(this.client,Vn,{offset:t,limit:e,...r},Kn,Wn)).devices}async create(t){const e=!Array.isArray(t),r=await b(this.client,xp,{devices:E(t)},$p,Rp);return e?r.devices[0]:r.devices}async delete(t){await b(this.client,Cp,{keys:E(t)},Mp,Pp)}async openDeviceTracker(){return await Qt(this.frameClient,Ip,kp,Up)}newSearcherWithOptions(t){return{type:this.type,search:async e=>await this.search(e,t),retrieve:async e=>await this.retrieve(e,t),page:async(e,r)=>await this.page(e,r,t)}}};const Up=(t,e)=>t==="delete"?e.toStrings().map(r=>({variant:t,key:r,value:void 0})):e.parseJSON(Nn).map(r=>({variant:t,key:r.key,value:r}));let Bp="_-0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",Lp=(t=21)=>{let e="",r=t;for(;r--;)e+=Bp[Math.random()*64|0];return e};const Ut="sy_task_state",Ga="sy_task_cmd",er=a.z.union([a.z.string(),a.z.bigint().transform(t=>t.toString()),a.z.number().transform(t=>t.toString())]),rn=a.z.object({task:er,variant:a.z.string(),key:a.z.string().optional(),details:a.z.record(a.z.unknown()).or(a.z.string().transform(t=>t===""?{}:JSON.parse(t))).or(a.z.array(a.z.unknown())).or(a.z.null())}),ca=a.z.object({key:er,name:a.z.string(),type:a.z.string(),internal:a.z.boolean().optional(),config:a.z.record(a.z.unknown()).or(a.z.string().transform(t=>t===""?{}:pt.JSON_ECD.decodeString(t))),state:rn.optional().nullable()}),_p=ca.omit({key:!0}).extend({key:er.transform(t=>t.toString()).optional(),config:a.z.unknown().transform(t=>pt.JSON_ECD.encodeString(t))});a.z.object({task:er,type:a.z.string(),key:a.z.string(),args:a.z.record(a.z.unknown()).or(a.z.string().transform(t=>t===""?{}:JSON.parse(t)))});class Yp{constructor(e,r,n,s,i,o=!1,c){l(this,"key"),l(this,"name"),l(this,"internal"),l(this,"type"),l(this,"config"),l(this,"state"),l(this,"frameClient"),this.key=e,this.name=r,this.type=n,this.config=s,this.internal=o,c!==null&&(this.state=c),this.frameClient=i}get payload(){return{key:this.key,name:this.name,type:this.type,config:this.config,state:this.state,internal:this.internal}}async executeCommand(e,r){const n=await this.frameClient.openWriter(Ga),s=Lp();return await n.write(Ga,[{task:this.key,type:e,key:s,args:r}]),await n.close(),s}async executeCommandSync(e,r,n){const s=await this.frameClient.openStreamer(Ut),i=await this.executeCommand(e,r);let o;const c=new Promise(u=>setTimeout(()=>u(!1),new k(n).milliseconds));for(;;){const u=await Promise.any([s.read(),c]);if(u===!1)throw new Error("Command timed out");const f=rn.safeParse(u.at(-1).sy_task_state);if(f.success){if(o=f.data,o.key===i)break}else console.error(f.error)}return s.close(),o}async openStateObserver(){return new Ht(await this.frameClient.openStreamer(Ut),e=>{const r=e.get(Ut);if(r.length===0)return[null,!1];const n=rn.safeParse(r.at(-1));if(!n.success)return[null,!1];const s=n.data;return s.task!==this.key?[null,!1]:[s,!0]})}}const Zp=a.z.object({rack:Xt.optional(),keys:a.z.string().array().optional(),names:a.z.string().array().optional(),offset:a.z.number().optional(),limit:a.z.number().optional(),includeState:a.z.boolean().optional()}),qp=a.z.object({tasks:gt(ca)}),Fp="/hardware/task/retrieve",Vp="/hardware/task/create",Kp="/hardware/task/delete",Wp=a.z.object({tasks:_p.array()}),Gp=a.z.object({tasks:ca.array()}),Jp=a.z.object({keys:er.array()}),Hp=a.z.object({});let Xp=class{constructor(t,e){l(this,"type","task"),l(this,"client"),l(this,"frameClient"),this.client=t,this.frameClient=e}async create(t){const e=!Array.isArray(t),r=await b(this.client,Vp,{tasks:E(t)},Wp,Gp),n=this.sugar(r.tasks);return e?n[0]:n}async delete(t){await b(this.client,Kp,{keys:E(t)},Jp,Hp)}async search(t){return await this.execRetrieve({keys:[t]})}async page(t,e){return await this.execRetrieve({offset:t,limit:e})}async list(t={}){return this.sugar(await this.execRetrieve(t))}async retrieve(t,e){const{single:r,normalized:n,variant:s}=bn(t,{number:"rack",string:"keys"},{convertNumericStrings:!1}),i={...e};s==="rack"?i.rack=t:i.keys=n;const o=await this.execRetrieve(i),c=this.sugar(o);return r&&s!=="rack"?c[0]:c}async retrieveByName(t,e){const r=await this.execRetrieve({names:[t],rack:e});return On("Task",t,r,!0),this.sugar(r)[0]}async execRetrieve(t){return(await b(this.client,Fp,t,Zp,qp)).tasks}sugar(t){return t.map(({key:e,name:r,type:n,config:s,state:i,internal:o})=>new Yp(e,r,n,s,this.frameClient,o,i))}async openTracker(){return await Qt(this.frameClient,"sy_task_set","sy_task_delete",(t,e)=>Array.from(e).map(r=>({variant:t,key:r.toString(),value:r.toString()})))}async openStateObserver(){return new Ht(await this.frameClient.openStreamer(Ut),t=>{const e=t.get(Ut);if(e.length===0)return[null,!1];const r=rn.safeParse(e.at(-1));return r.success?[r.data,!0]:[null,!1]})}};const tr=a.z.string().uuid(),An=a.z.object({key:tr,name:a.z.string().min(1),color:a.z.string()}),Qp=a.z.object({keys:tr.array().optional(),for:xe.optional(),search:a.z.string().optional(),offset:a.z.number().optional(),limit:a.z.number().optional()}),eg=a.z.object({labels:An.array().optional().default([])});var lr;let tg=(lr=class{constructor(t){l(this,"client"),this.client=t}async retrieve(t){const e=E(t);return await this.execute({keys:e})}async retrieveFor(t){return await this.execute({for:t})}async search(t){return await this.execute({search:t})}async page(t,e){return await this.execute({offset:t,limit:e})}async execute(t){const[e,r]=await this.client.send(lr.ENDPOINT,t,Qp,eg);if(r!=null)throw r;return e.labels}},l(lr,"ENDPOINT","/label/retrieve"),lr);const rg=An.extend({key:tr.optional()}),ng=a.z.object({labels:rg.array()}),sg=a.z.object({labels:An.array()}),ag=a.z.object({keys:tr.array()}),$c=a.z.object({id:xe,labels:tr.array()}),ig=$c,Gn=a.z.object({}),og="/label/create",cg="/label/delete",lg="/label/set",ug="/label/remove";let hg=class{constructor(t){l(this,"client"),this.client=t}async create(t){return(await b(this.client,og,{labels:E(t)},ng,sg)).labels}async delete(t){await b(this.client,cg,{keys:E(t)},ag,Gn)}async set(t,e){await b(this.client,lg,{id:t,labels:e},$c,Gn)}async remove(t,e){await b(this.client,ug,{id:t,labels:e},ig,Gn)}};const fg="sy_label_set",dg="sy_label_delete";let yg=class{constructor(t,e){l(this,"type","label"),l(this,"retriever"),l(this,"writer"),l(this,"frameClient"),this.writer=new hg(t),this.retriever=new tg(t),this.frameClient=e}async search(t){return await this.retriever.search(t)}async retrieve(t){const e=Array.isArray(t),r=await this.retriever.retrieve(t);return e?r:r[0]}async retrieveFor(t){return await this.retriever.retrieveFor(t)}async label(t,e){await this.writer.set(t,e)}async removeLabels(t,e){await this.writer.remove(t,e)}async page(t,e){return await this.retriever.page(t,e)}async create(t){const e=Array.isArray(t),r=await this.writer.create(t);return e?r:r[0]}async delete(t){await this.writer.delete(t)}async openChangeTracker(){return await Qt(this.frameClient,fg,dg,pg)}};const pg=(t,e)=>t==="delete"?e.toUUIDs().map(r=>({variant:t,key:r})):e.parseJSON(An).map(r=>({variant:t,key:r.key,value:r})),ue=a.z.string().uuid(),mt=a.z.object({key:ue,name:a.z.string().min(1),timeRange:le.z,color:a.z.string().optional()}),Rc=mt.extend({key:a.z.string().uuid().optional()}),Mc=t=>{const e=E(t);if(e.length===0)throw new Error("Range params must not be empty");const r=ue.safeParse(e[0]).success;return{single:!Array.isArray(t),variant:r?"keys":"names",normalized:e,actual:t}},gg=a.z.object({}),mg=a.z.object({range:mt}),wg=a.z.object({range:ue}),vg=a.z.object({range:ue}),bg=a.z.object({}),Og="/range/set-active",Tg="/range/retrieve-active",zg="/range/clear-active";class Sg{constructor(e){l(this,"client"),this.client=e}async setActive(e){await b(this.client,Og,{range:e},wg,gg)}async retrieveActive(){const[e,r]=await this.client.send(Tg,{},a.z.object({}),mg);if(be.matches(r))return null;if(r!=null)throw r;return e.range}async clearActive(e){await b(this.client,zg,{range:e},vg,bg)}}const Ng="sy_range_alias_set",Ag="sy_range_alias_delete",Eg=a.z.object({range:ue,aliases:a.z.string().array()}),Ig=a.z.object({aliases:a.z.record(a.z.string(),Qe)}),kg=a.z.object({range:ue,aliases:a.z.record(Qe.or(a.z.string()),a.z.string())}),xg=a.z.unknown(),Cg=a.z.object({range:ue,channels:Qe.array()}),jg=a.z.unknown(),$g=a.z.object({range:ue}),Rg=a.z.object({aliases:a.z.record(a.z.string(),a.z.string())}),Ct=class jt{constructor(e,r,n){l(this,"frameClient"),l(this,"cache",new Map),l(this,"client"),l(this,"rangeKey"),this.rangeKey=e,this.cache=new Map,this.client=n,this.frameClient=r}async resolve(e){const r=[],n=typeof e=="string",s={};if(n){const o=this.cache.get(e);if(o!=null)return o;r.push(e)}else e.forEach(o=>{const c=this.cache.get(o);c!=null?s[o]=c:r.push(o)});if(r.length===0)return s;const i=await b(this.client,jt.RESOLVE_ENDPOINT,{range:this.rangeKey,aliases:r},Eg,Ig);return Object.entries(i.aliases).forEach(([o,c])=>this.cache.set(o,c)),n?i.aliases[r[0]]:{...s,...i.aliases}}async set(e){await b(this.client,jt.SET_ENDPOINT,{range:this.rangeKey,aliases:e},kg,xg)}async list(){return(await b(this.client,jt.LIST_ENDPOINT,{range:this.rangeKey},$g,Rg)).aliases}async delete(e){await b(this.client,jt.DELETE_ENDPOINT,{range:this.rangeKey,channels:e},Cg,jg)}async openChangeTracker(){return await Qt(this.frameClient,Ng,Ag,Ug(this.rangeKey))}};l(Ct,"SET_ENDPOINT","/range/alias/set"),l(Ct,"RESOLVE_ENDPOINT","/range/alias/resolve"),l(Ct,"LIST_ENDPOINT","/range/alias/list"),l(Ct,"DELETE_ENDPOINT","/range/alias/delete");let Mg=Ct;const Pg=a.z.object({range:ue,channel:Qe,alias:a.z.string()}),Dg="---",Ug=t=>(e,r)=>e==="delete"?r.toStrings().filter(n=>n.split(Dg)[0]===t).map(n=>({variant:e,key:n,value:void 0})):r.parseJSON(Pg).map(n=>({variant:e,key:n.alias,value:n})),Bg=a.z.object({range:ue,keys:a.z.string().array()}),Lg=a.z.object({pairs:a.z.record(a.z.string(),a.z.string())}),_g=a.z.object({range:ue,pairs:a.z.record(a.z.string(),a.z.string())}),Yg=a.z.object({range:ue,keys:a.z.string().array()}),Vr=class Kr{constructor(e,r){l(this,"rangeKey"),l(this,"client"),this.rangeKey=e,this.client=r}async get(e){const[r,n]=await this.client.send(Kr.GET_ENDPOINT,{range:this.rangeKey,keys:E(e)},Bg,Lg);if(n!=null)throw n;return Array.isArray(e)?r.pairs:r.pairs[e]}async list(){return this.get([])}async set(e,r=""){await b(this.client,Kr.SET_ENDPOINT,{range:this.rangeKey,pairs:Hs(e)?e:{[e]:r}},_g,a.z.unknown())}async delete(e){await b(this.client,Kr.DELETE_ENDPOINT,{range:this.rangeKey,keys:E(e)},Yg,a.z.unknown())}};l(Vr,"GET_ENDPOINT","/range/kv/get"),l(Vr,"SET_ENDPOINT","/range/kv/set"),l(Vr,"DELETE_ENDPOINT","/range/kv/delete");let Zg=Vr;const Jn=t=>new Oe({type:"range",key:t});class Pc{constructor(e,r=le.ZERO,n,s,i,o,c,u,f){l(this,"key"),l(this,"name"),l(this,"kv"),l(this,"timeRange"),l(this,"color"),l(this,"channels"),l(this,"aliaser"),l(this,"frameClient"),l(this,"labelClient"),this.key=n,this.name=e,this.timeRange=r,this.frameClient=i,this.color=s,this.kv=o,this.aliaser=c,this.channels=u,this.labelClient=f}async setAlias(e,r){const n=await this.channels.retrieve(e);if(n.length===0)throw new be(`Channel ${e} does not exist`);await this.aliaser.set({[n[0].key]:r})}async deleteAlias(...e){await this.aliaser.delete(e)}async listAliases(){return await this.aliaser.list()}async openAliasTracker(){return await this.aliaser.openChangeTracker()}async read(e){return await this.frameClient.read(this.timeRange,e)}async labels(){return await this.labelClient.retrieveFor(Jn(this.key))}async addLabel(...e){await this.labelClient.label(Jn(this.key),e)}async removeLabel(...e){await this.labelClient.removeLabels(Jn(this.key),e)}}const qg=a.z.object({keys:ue.array().optional(),names:a.z.array(a.z.string()).optional(),term:a.z.string().optional(),overlapsWith:le.z.optional()}),Fg="/range/retrieve",Vg=a.z.object({ranges:gt(mt)});let Dc=class{constructor(t,e,r,n,s){l(this,"type","range"),l(this,"frameClient"),l(this,"writer"),l(this,"unaryClient"),l(this,"channels"),l(this,"active"),l(this,"labelClient"),this.frameClient=t,this.writer=e,this.unaryClient=r,this.channels=n,this.active=new Sg(r),this.labelClient=s}async create(t){const e=!Array.isArray(t),r=this.sugar(await this.writer.create(E(t)));return e?r[0]:r}async rename(t,e){await this.writer.rename(t,e)}async delete(t){await this.writer.delete(E(t))}async search(t){return this.sugar(await this.execRetrieve({term:t}))}async page(){return[]}async retrieve(t){if(typeof t=="object"&&"start"in t)return await this.execRetrieve({overlapsWith:new le(t)});const{single:e,actual:r,variant:n,normalized:s}=Mc(t),i=await this.execRetrieve({[n]:s});if(!e)return i;if(i.length===0)throw new Qr(`range matching ${r} not found`);if(i.length>1)throw new en(`multiple ranges matching ${r} found`);return i[0]}async execRetrieve(t){const{ranges:e}=await b(this.unaryClient,Fg,t,qg,Vg);return this.sugar(e)}async setActive(t){await this.active.setActive(t)}async retrieveActive(){const t=await this.active.retrieveActive();return t==null?null:this.sugar([t])[0]}async clearActive(t){await this.active.clearActive(t)}sugar(t){return t.map(e=>new Pc(e.name,e.timeRange,e.key,e.color,this.frameClient,new Zg(e.key,this.unaryClient),new Mg(e.key,this.frameClient,this.unaryClient),this.channels,this.labelClient))}async openTracker(){return await Qt(this.frameClient,"sy_range_set","sy_range_delete",(t,e)=>t==="delete"?e.toStrings().map(r=>({variant:t,key:r,value:void 0})):this.sugar(e.parseJSON(mt)).map(r=>({variant:t,key:r.key,value:r})))}};const Kg=a.z.object({ranges:mt.array()}),Wg=a.z.object({ranges:Rc.array()}),Gg=a.z.object({keys:ue.array()}),Jg=a.z.object({}),Hg=a.z.object({key:ue,name:a.z.string()}),Xg=a.z.object({}),Qg="/range/create",em="/range/delete",tm="/range/rename";let Uc=class{constructor(t){l(this,"client"),this.client=t}async rename(t,e){await b(this.client,tm,{key:t,name:e},Hg,Xg)}async create(t){return(await b(this.client,Qg,{ranges:t},Wg,Kg)).ranges}async delete(t){await b(this.client,em,{keys:t},Gg,Jg)}};const rm=Object.freeze(Object.defineProperty({__proto__:null,Client:Dc,Range:Pc,Writer:Uc,analyzeParams:Mc,keyZ:ue,newPayloadZ:Rc,payloadZ:mt},Symbol.toStringTag,{value:"Module"})),nm="/api/v1/";class sm{constructor(e,r=!1){l(this,"url"),l(this,"unary"),l(this,"stream"),l(this,"secure"),this.secure=r,this.url=e.child(nm);const n=new pt.JSONEncoderDecoder;this.unary=new gf(this.url,n,this.secure),this.stream=new Nf(this.url,n,this.secure)}use(...e){this.unary.use(...e),this.stream.use(...e)}}const la=a.z.string().uuid(),ua=a.z.object({key:a.z.string(),name:a.z.string(),data:Xs.or(a.z.string().transform(t=>JSON.parse(t)))}),am=a.z.object({keys:a.z.string().array()}),im=a.z.object({linePlots:ua.array()});let om=class{constructor(t){l(this,"ENDPOINT","/workspace/lineplot/retrieve"),l(this,"client"),this.client=t}async retrieve(t){const e=E(t);return(await b(this.client,this.ENDPOINT,{keys:e},am,im)).linePlots}};const ut=a.z.string().uuid(),Bc=t=>JSON.parse(t),Lc=a.z.object({name:a.z.string(),key:ut,layout:Xs.or(a.z.string().transform(t=>Bc(t)))}),_c=Lc.omit({layout:!0}).extend({layout:a.z.string().transform(t=>Bc(t))}),cm=ua.partial({key:!0}).transform(t=>({...t,data:JSON.stringify(t.data)})),lm=a.z.object({workspace:ut,linePlots:cm.array()}),um=a.z.object({linePlots:ua.array()}),hm=a.z.object({keys:la.array()}),fm=a.z.object({}),dm=a.z.object({key:la,name:a.z.string()}),ym=a.z.object({}),pm=a.z.object({key:la,data:a.z.string()}),gm=a.z.object({}),mm="/workspace/lineplot/create",wm="/workspace/lineplot/delete",vm="/workspace/lineplot/rename",bm="/workspace/lineplot/set-data";let Om=class{constructor(t){l(this,"client"),this.client=t}async create(t,e){const r={...e,data:JSON.stringify(e.data)};return(await b(this.client,mm,{workspace:t,linePlots:[r]},lm,um)).linePlots[0]}async delete(t){const e=E(t);await b(this.client,wm,{keys:e},hm,fm)}async rename(t,e){await b(this.client,vm,{key:t,name:e},dm,ym)}async setData(t,e){await b(this.client,bm,{key:t,data:JSON.stringify(e)},pm,gm)}},Tm=class{constructor(t){l(this,"writer"),l(this,"retriever"),this.writer=new Om(t),this.retriever=new om(t)}async create(t,e){return await this.writer.create(t,e)}async rename(t,e){await this.writer.rename(t,e)}async setData(t,e){await this.writer.setData(t,e)}async retrieve(t){const e=Array.isArray(t),r=await this.retriever.retrieve(t);return e?r:r[0]}async delete(t){await this.writer.delete(t)}};const zm=a.z.object({keys:ut.array().optional(),search:a.z.string().optional(),author:a.z.string().uuid().optional(),offset:a.z.number().optional(),limit:a.z.number().optional()}),Sm=a.z.object({workspaces:gt(_c)});var ur;let Nm=(ur=class{constructor(t){l(this,"client"),this.client=t}async retrieve(t){const e=E(t);return await this.execute({keys:e})}async retrieveByAuthor(t){return await this.execute({author:t})}async search(t){return await this.execute({search:t})}async page(t,e){return await this.execute({offset:t,limit:e})}async execute(t){return(await b(this.client,ur.ENDPOINT,t,zm,Sm)).workspaces}},l(ur,"ENDPOINT","/workspace/retrieve"),ur);const En=a.z.string().uuid(),Am=a.z.object({key:a.z.string(),name:a.z.string(),data:Xs.or(a.z.string().transform(t=>JSON.parse(t))),snapshot:a.z.boolean()}),ha=a.z.object({key:a.z.string(),name:a.z.string(),snapshot:a.z.boolean(),data:a.z.string().transform(t=>JSON.parse(t))}),Em=a.z.object({keys:a.z.string().array()}),Im=a.z.object({schematics:ha.array()});class km{constructor(e){l(this,"ENDPOINT","/workspace/schematic/retrieve"),l(this,"client"),this.client=e}async retrieve(e){return(await b(this.client,this.ENDPOINT,{keys:E(e)},Em,Im)).schematics}}const xm=Am.partial({key:!0,snapshot:!0}).transform(t=>({...t,data:JSON.stringify(t.data)})),Cm=a.z.object({workspace:ut,schematics:xm.array()}),jm=a.z.object({schematics:ha.array()}),$m=a.z.object({keys:En.array()}),Rm=a.z.object({}),Mm=a.z.object({key:En,name:a.z.string()}),Ja=a.z.object({}),Pm=a.z.object({key:En,data:a.z.string()});a.z.object({});const Dm=a.z.object({key:En,name:a.z.string(),snapshot:a.z.boolean()}),Um=a.z.object({schematic:ha}),Bm="/workspace/schematic/create",Lm="/workspace/schematic/delete",_m="/workspace/schematic/rename",Ym="/workspace/schematic/set-data",Zm="/workspace/schematic/copy";let qm=class{constructor(t){l(this,"client"),this.client=t}async create(t,e){const r={...e,data:JSON.stringify(e.data)};return(await b(this.client,Bm,{workspace:t,schematics:[r]},Cm,jm)).schematics[0]}async copy(t,e,r){return(await b(this.client,Zm,{key:t,name:e,snapshot:r},Dm,Um)).schematic}async delete(t){const e=E(t);await b(this.client,Lm,{keys:e},$m,Rm)}async rename(t,e){await b(this.client,_m,{key:t,name:e},Mm,Ja)}async setData(t,e){await b(this.client,Ym,{key:t,data:JSON.stringify(e)},Pm,Ja)}},Fm=class{constructor(t){l(this,"writer"),l(this,"retriever"),this.writer=new qm(t),this.retriever=new km(t)}async create(t,e){return await this.writer.create(t,e)}async rename(t,e){await this.writer.rename(t,e)}async setData(t,e){await this.writer.setData(t,e)}async retrieve(t){const e=Array.isArray(t),r=await this.retriever.retrieve(t);return e?r:r[0]}async delete(t){await this.writer.delete(t)}async copy(t,e,r){return await this.writer.copy(t,e,r)}};const Vm=Lc.partial({key:!0}).transform(t=>({...t,layout:JSON.stringify(t.layout)})),Km=a.z.object({workspaces:Vm.array()}),Wm=a.z.object({workspaces:_c.array()}),Gm=a.z.object({keys:ut.array()}),Jm=a.z.object({}),Hm=a.z.object({key:ut,name:a.z.string()}),Xm=a.z.object({}),Qm=a.z.object({key:ut,layout:a.z.string()}),ew=a.z.object({}),tw="/workspace/create",rw="/workspace/delete",nw="/workspace/rename",sw="/workspace/set-layout";class aw{constructor(e){l(this,"client"),this.client=e}async create(e){return(await b(this.client,tw,{workspaces:E(e)},Km,Wm)).workspaces}async delete(e){await b(this.client,rw,{keys:E(e)},Gm,Jm)}async rename(e,r){await b(this.client,nw,{key:e,name:r},Hm,Xm)}async setLayout(e,r){await b(this.client,sw,{key:e,layout:JSON.stringify(r)},Qm,ew)}}class iw{constructor(e){l(this,"type","workspace"),l(this,"schematic"),l(this,"linePlot"),l(this,"retriever"),l(this,"writer"),this.schematic=new Fm(e),this.linePlot=new Tm(e),this.retriever=new Nm(e),this.writer=new aw(e)}async search(e){return await this.retriever.search(e)}async retrieveByAuthor(e){return await this.retriever.retrieveByAuthor(e)}async retrieve(e){const r=Array.isArray(e),n=await this.retriever.retrieve(e);return r?n:n[0]}async page(e,r){return await this.retriever.page(e,r)}async create(e){const r=Array.isArray(e),n=await this.writer.create(e);return r?n:n[0]}async rename(e,r){await this.writer.rename(e,r)}async setLayout(e,r){await this.writer.setLayout(e,r)}async delete(...e){await this.writer.delete(e)}}const Yc=a.z.object({host:a.z.string({required_error:"Host is required"}).min(1,"Host is required"),port:a.z.number({required_error:"Port is required"}).or(a.z.string({required_error:"Port is required"})),username:a.z.string().optional(),password:a.z.string().optional(),connectivityPollFrequency:k.z.default(k.seconds(30)),secure:a.z.boolean().optional().default(!1),name:a.z.string().optional()});class Zc extends xc{constructor(e){const r=Yc.parse(e),{host:n,port:s,username:i,password:o,connectivityPollFrequency:c,secure:u}=r,f=new sm(new ay({host:n,port:Number(s)}),u);f.use(Zd);let w;if(i!=null&&o!=null){const ul=new Ky(f.unary,{username:i,password:o});f.use(ul.middleware())}const h=new ea(new Qs(f.unary)),D=new vc(f.unary,h);super(f.stream,f.unary,h),l(this,"createdAt"),l(this,"props"),l(this,"ranges"),l(this,"channels"),l(this,"auth"),l(this,"connectivity"),l(this,"ontology"),l(this,"workspaces"),l(this,"labels"),l(this,"hardware"),l(this,"control"),l(this,"transport"),this.createdAt=I.now(),this.props=r,this.auth=w,this.transport=f,this.channels=new wc(this,h,f.unary,D),this.connectivity=new Tc(f.unary,c,r.name),this.control=new jc(this),this.ontology=new ky(f.unary,this);const V=new Uc(this.transport.unary);this.labels=new yg(this.transport.unary,this),this.ranges=new Dc(this,V,this.transport.unary,h,this.labels),this.workspaces=new iw(this.transport.unary);const se=new Dp(this.transport.unary,this),R=new Xp(this.transport.unary,this),ll=new Ap(this.transport.unary,this,R);this.hardware=new wp(R,ll,se)}get key(){return this.createdAt.valueOf().toString()}close(){this.connectivity.stopChecking()}}l(Zc,"connectivity",Tc);const ow=yt.Authority;let cw="_-0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",lw=(t,e)=>()=>{let r="",n=e;for(;n--;)r+=t[Math.random()*t.length|0];return r},uw=(t=21)=>{let e="",r=t;for(;r--;)e+=cw[Math.random()*64|0];return e};const ys=(t,e,r="")=>{try{return t.parse(e)}catch(n){if(n instanceof a.z.ZodError){const s=n.errors.map(i=>i.path.length===0?i.message:`${i.path.join(".")}: ${i.message}`);throw new Error(`${r} - ${s.join(`
50
- `)}`)}else throw n}};var hw=Object.defineProperty,fw=(t,e,r)=>e in t?hw(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,X=(t,e,r)=>(fw(t,typeof e!="symbol"?e+"":e,r),r);const ps=class qc{constructor(e,r,n="",s=!1){X(this,"_noop",!1),X(this,"key"),X(this,"path"),X(this,"serviceName"),this.key=e,this.path=r,this.serviceName=n,this._noop=s}child(e){return new qc(e,this.extendPath(e),this.serviceName,this.noop)}extendPath(e){return`${this.path}.${e}`}get noop(){return this._noop}};X(ps,"NOOP",new ps("","",""));let fa=ps;const gs=["debug","info","warn","error"],dw=t=>{const e=gs.indexOf(t);return({level:r})=>gs.indexOf(r)>=e},yw=t=>{const{include:e,exclude:r}=t;return({path:n})=>!(e!=null&&!e.some(s=>n.startsWith(s))||r!=null&&r.some(s=>n.startsWith(s)))},ms=class Fc{constructor(e={}){X(this,"meta",fa.NOOP),X(this,"filters");const{filters:r=[]}=e;this.filters=r}filter(e){return!this.meta.noop&&this.filters.every(r=>r({key:this.meta.key,path:this.meta.path,level:e}))}child(e){const r=new Fc({filters:this.filters});return r.meta=e,r}debug(e,r,n=!1){!this.filter("debug")&&!n||(r==null?console.log("%cDEBUG","color: #8c00f0;",this.meta.path,e):console.log("%cDEBUG","color: #8c00f0;",this.meta.path,e,hr(r)))}info(e,r,n=!1){!this.filter("info")&&!n||(r==null?console.log("%cINFO","color: #005eff;",this.meta.path,e):console.log("%cINFO","color: #005eff;",this.meta.path,e,hr(r)))}warn(e,r,n=!1){!this.filter("warn")&&!n||(r==null?console.warn("WARN",this.meta.path,e):console.warn("WARN",this.meta.path,e,hr(r)))}error(e,r,n=!1){!this.filter("error")&&!n||(r==null?console.error("ERROR",this.meta.path,e):console.error("ERROR",this.meta.path,e,hr(r)))}};X(ms,"NOOP",new ms);let Vc=ms;const hr=t=>typeof t=="function"?t():t;var pw=typeof globalThis=="object"?globalThis:typeof self=="object"?self:typeof window=="object"?window:typeof global=="object"?global:{},it="1.8.0",Ha=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function gw(t){var e=new Set([t]),r=new Set,n=t.match(Ha);if(!n)return function(){return!1};var s={major:+n[1],minor:+n[2],patch:+n[3],prerelease:n[4]};if(s.prerelease!=null)return function(c){return c===t};function i(c){return r.add(c),!1}function o(c){return e.add(c),!0}return function(c){if(e.has(c))return!0;if(r.has(c))return!1;var u=c.match(Ha);if(!u)return i(c);var f={major:+u[1],minor:+u[2],patch:+u[3],prerelease:u[4]};return f.prerelease!=null||s.major!==f.major?i(c):s.major===0?s.minor===f.minor&&s.patch<=f.patch?o(c):i(c):s.minor<=f.minor?o(c):i(c)}}var mw=gw(it),ww=it.split(".")[0],Zt=Symbol.for("opentelemetry.js.api."+ww),qt=pw;function da(t,e,r,n){var s;n===void 0&&(n=!1);var i=qt[Zt]=(s=qt[Zt])!==null&&s!==void 0?s:{version:it};if(!n&&i[t]){var o=new Error("@opentelemetry/api: Attempted duplicate registration of API: "+t);return r.error(o.stack||o.message),!1}if(i.version!==it){var o=new Error("@opentelemetry/api: Registration of version v"+i.version+" for "+t+" does not match previously registered API v"+it);return r.error(o.stack||o.message),!1}return i[t]=e,r.debug("@opentelemetry/api: Registered a global for "+t+" v"+it+"."),!0}function Ft(t){var e,r,n=(e=qt[Zt])===null||e===void 0?void 0:e.version;if(!(!n||!mw(n)))return(r=qt[Zt])===null||r===void 0?void 0:r[t]}function ya(t,e){e.debug("@opentelemetry/api: Unregistering a global for "+t+" v"+it+".");var r=qt[Zt];r&&delete r[t]}var vw=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),s,i=[],o;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)i.push(s.value)}catch(c){o={error:c}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return i},bw=function(t,e,r){if(arguments.length===2)for(var n=0,s=e.length,i;n<s;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))},Ow=function(){function t(e){this._namespace=e.namespace||"DiagComponentLogger"}return t.prototype.debug=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Ot("debug",this._namespace,e)},t.prototype.error=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Ot("error",this._namespace,e)},t.prototype.info=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Ot("info",this._namespace,e)},t.prototype.warn=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Ot("warn",this._namespace,e)},t.prototype.verbose=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Ot("verbose",this._namespace,e)},t}();function Ot(t,e,r){var n=Ft("diag");if(n)return r.unshift(e),n[t].apply(n,bw([],vw(r),!1))}var ye;(function(t){t[t.NONE=0]="NONE",t[t.ERROR=30]="ERROR",t[t.WARN=50]="WARN",t[t.INFO=60]="INFO",t[t.DEBUG=70]="DEBUG",t[t.VERBOSE=80]="VERBOSE",t[t.ALL=9999]="ALL"})(ye||(ye={}));function Tw(t,e){t<ye.NONE?t=ye.NONE:t>ye.ALL&&(t=ye.ALL),e=e||{};function r(n,s){var i=e[n];return typeof i=="function"&&t>=s?i.bind(e):function(){}}return{error:r("error",ye.ERROR),warn:r("warn",ye.WARN),info:r("info",ye.INFO),debug:r("debug",ye.DEBUG),verbose:r("verbose",ye.VERBOSE)}}var zw=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),s,i=[],o;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)i.push(s.value)}catch(c){o={error:c}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return i},Sw=function(t,e,r){if(arguments.length===2)for(var n=0,s=e.length,i;n<s;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))},Nw="diag",Vt=function(){function t(){function e(s){return function(){for(var i=[],o=0;o<arguments.length;o++)i[o]=arguments[o];var c=Ft("diag");if(c)return c[s].apply(c,Sw([],zw(i),!1))}}var r=this,n=function(s,i){var o,c,u;if(i===void 0&&(i={logLevel:ye.INFO}),s===r){var f=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return r.error((o=f.stack)!==null&&o!==void 0?o:f.message),!1}typeof i=="number"&&(i={logLevel:i});var w=Ft("diag"),h=Tw((c=i.logLevel)!==null&&c!==void 0?c:ye.INFO,s);if(w&&!i.suppressOverrideMessage){var D=(u=new Error().stack)!==null&&u!==void 0?u:"<failed to generate stacktrace>";w.warn("Current logger will be overwritten from "+D),h.warn("Current logger will overwrite one already registered from "+D)}return da("diag",h,r,!0)};r.setLogger=n,r.disable=function(){ya(Nw,r)},r.createComponentLogger=function(s){return new Ow(s)},r.verbose=e("verbose"),r.debug=e("debug"),r.info=e("info"),r.warn=e("warn"),r.error=e("error")}return t.instance=function(){return this._instance||(this._instance=new t),this._instance},t}(),Aw=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),s,i=[],o;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)i.push(s.value)}catch(c){o={error:c}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return i},Ew=function(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Iw=function(){function t(e){this._entries=e?new Map(e):new Map}return t.prototype.getEntry=function(e){var r=this._entries.get(e);if(r)return Object.assign({},r)},t.prototype.getAllEntries=function(){return Array.from(this._entries.entries()).map(function(e){var r=Aw(e,2),n=r[0],s=r[1];return[n,s]})},t.prototype.setEntry=function(e,r){var n=new t(this._entries);return n._entries.set(e,r),n},t.prototype.removeEntry=function(e){var r=new t(this._entries);return r._entries.delete(e),r},t.prototype.removeEntries=function(){for(var e,r,n=[],s=0;s<arguments.length;s++)n[s]=arguments[s];var i=new t(this._entries);try{for(var o=Ew(n),c=o.next();!c.done;c=o.next()){var u=c.value;i._entries.delete(u)}}catch(f){e={error:f}}finally{try{c&&!c.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}return i},t.prototype.clear=function(){return new t},t}();Vt.instance();function kw(t){return t===void 0&&(t={}),new Iw(new Map(Object.entries(t)))}function xw(t){return Symbol.for(t)}var Cw=function(){function t(e){var r=this;r._currentContext=e?new Map(e):new Map,r.getValue=function(n){return r._currentContext.get(n)},r.setValue=function(n,s){var i=new t(r._currentContext);return i._currentContext.set(n,s),i},r.deleteValue=function(n){var s=new t(r._currentContext);return s._currentContext.delete(n),s}}return t}(),jw=new Cw,$w={get:function(t,e){if(t!=null)return t[e]},keys:function(t){return t==null?[]:Object.keys(t)}},Rw={set:function(t,e,r){t!=null&&(t[e]=r)}},Mw=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),s,i=[],o;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)i.push(s.value)}catch(c){o={error:c}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return i},Pw=function(t,e,r){if(arguments.length===2)for(var n=0,s=e.length,i;n<s;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))},Dw=function(){function t(){}return t.prototype.active=function(){return jw},t.prototype.with=function(e,r,n){for(var s=[],i=3;i<arguments.length;i++)s[i-3]=arguments[i];return r.call.apply(r,Pw([n],Mw(s),!1))},t.prototype.bind=function(e,r){return r},t.prototype.enable=function(){return this},t.prototype.disable=function(){return this},t}(),Uw=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),s,i=[],o;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)i.push(s.value)}catch(c){o={error:c}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return i},Bw=function(t,e,r){if(arguments.length===2)for(var n=0,s=e.length,i;n<s;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))},Hn="context",Lw=new Dw,Kc=function(){function t(){}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalContextManager=function(e){return da(Hn,e,Vt.instance())},t.prototype.active=function(){return this._getContextManager().active()},t.prototype.with=function(e,r,n){for(var s,i=[],o=3;o<arguments.length;o++)i[o-3]=arguments[o];return(s=this._getContextManager()).with.apply(s,Bw([e,r,n],Uw(i),!1))},t.prototype.bind=function(e,r){return this._getContextManager().bind(e,r)},t.prototype._getContextManager=function(){return Ft(Hn)||Lw},t.prototype.disable=function(){this._getContextManager().disable(),ya(Hn,Vt.instance())},t}(),ws;(function(t){t[t.UNSET=0]="UNSET",t[t.OK=1]="OK",t[t.ERROR=2]="ERROR"})(ws||(ws={}));var _w=Kc.getInstance(),Yw=function(){function t(){}return t.prototype.inject=function(e,r){},t.prototype.extract=function(e,r){return e},t.prototype.fields=function(){return[]},t}(),pa=xw("OpenTelemetry Baggage Key");function Wc(t){return t.getValue(pa)||void 0}function Zw(){return Wc(Kc.getInstance().active())}function qw(t,e){return t.setValue(pa,e)}function Fw(t){return t.deleteValue(pa)}var Xn="propagation",Vw=new Yw,Kw=function(){function t(){this.createBaggage=kw,this.getBaggage=Wc,this.getActiveBaggage=Zw,this.setBaggage=qw,this.deleteBaggage=Fw}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalPropagator=function(e){return da(Xn,e,Vt.instance())},t.prototype.inject=function(e,r,n){return n===void 0&&(n=Rw),this._getGlobalPropagator().inject(e,r,n)},t.prototype.extract=function(e,r,n){return n===void 0&&(n=$w),this._getGlobalPropagator().extract(e,r,n)},t.prototype.fields=function(){return this._getGlobalPropagator().fields()},t.prototype.disable=function(){ya(Xn,Vt.instance())},t.prototype._getGlobalPropagator=function(){return Ft(Xn)||Vw},t}(),Ww=Kw.getInstance();const Xa=["bench","debug","prod"],Gw=t=>e=>Xa.indexOf(e)>=Xa.indexOf(t),vs=class Gc{constructor(e,r=Gw("debug")){X(this,"meta",fa.NOOP),X(this,"tracer"),X(this,"filter"),this.tracer=e,this.filter=r}child(e){const r=new Gc(this.tracer,this.filter);return r.meta=e,r}debug(e,r){return this.trace(e,"debug",r)}bench(e,r){return this.trace(e,"bench",r)}prod(e,r){return this.trace(e,"prod",r)}trace(e,r,n){return this.meta.noop||!this.filter(r)?n(new Xc(e)):this.tracer.startActiveSpan(e,s=>{const i=new Hc(e,s),o=n(i);return s.end(),o})}propagate(e){if(this.meta.noop)return;const r=_w.active();Ww.inject(r,e,{set:(n,s,i)=>{n[s]=i}})}};X(vs,"NOOP",new vs);let Jc=vs;class Hc{constructor(e,r){X(this,"key"),X(this,"otel"),this.key=e,this.otel=r}set(e,r){this.otel.setAttribute(e,r)}recordError(e){e!=null&&(this.otel.recordException(e),this.otel.setStatus({code:ws.ERROR}))}}class Xc{constructor(e){X(this,"key"),this.key=e}set(){}recordError(e){}}const bs=class Qc{constructor({key:e="",serviceName:r="",logger:n=Vc.NOOP,tracer:s=Jc.NOOP,noop:i=!1,__meta:o}){X(this,"meta"),X(this,"T"),X(this,"L"),this.meta=o??new fa(e,e,r,i),this.T=s.child(this.meta),this.L=n.child(this.meta)}child(e){const r=this.meta.child(e);return new Qc({__meta:r,tracer:this.T,logger:this.L})}};X(bs,"NOOP",new bs({noop:!0}));let ga=bs;const Jw=ga.NOOP,el=Object.freeze(Object.defineProperty({__proto__:null,Instrumentation:ga,LOG_LEVELS:gs,Logger:Vc,NOOP:Jw,NoopSpan:Xc,Tracer:Jc,_Span:Hc,logLevelKeyFiler:yw,logThresholdFilter:dw},Symbol.toStringTag,{value:"Module"})),Hw=new Error("request for lock canceled");var Xw=function(t,e,r,n){function s(i){return i instanceof r?i:new r(function(o){o(i)})}return new(r||(r=Promise))(function(i,o){function c(w){try{f(n.next(w))}catch(h){o(h)}}function u(w){try{f(n.throw(w))}catch(h){o(h)}}function f(w){w.done?i(w.value):s(w.value).then(c,u)}f((n=n.apply(t,e||[])).next())})};class Qw{constructor(e,r=Hw){this._value=e,this._cancelError=r,this._queue=[],this._weightedWaiters=[]}acquire(e=1,r=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return new Promise((n,s)=>{const i={resolve:n,reject:s,weight:e,priority:r},o=tl(this._queue,c=>r<=c.priority);o===-1&&e<=this._value?this._dispatchItem(i):this._queue.splice(o+1,0,i)})}runExclusive(e){return Xw(this,arguments,void 0,function*(r,n=1,s=0){const[i,o]=yield this.acquire(n,s);try{return yield r(i)}finally{o()}})}waitForUnlock(e=1,r=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return this._couldLockImmediately(e,r)?Promise.resolve():new Promise(n=>{this._weightedWaiters[e-1]||(this._weightedWaiters[e-1]=[]),ev(this._weightedWaiters[e-1],{resolve:n,priority:r})})}isLocked(){return this._value<=0}getValue(){return this._value}setValue(e){this._value=e,this._dispatchQueue()}release(e=1){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);this._value+=e,this._dispatchQueue()}cancel(){this._queue.forEach(e=>e.reject(this._cancelError)),this._queue=[]}_dispatchQueue(){for(this._drainUnlockWaiters();this._queue.length>0&&this._queue[0].weight<=this._value;)this._dispatchItem(this._queue.shift()),this._drainUnlockWaiters()}_dispatchItem(e){const r=this._value;this._value-=e.weight,e.resolve([r,this._newReleaser(e.weight)])}_newReleaser(e){let r=!1;return()=>{r||(r=!0,this.release(e))}}_drainUnlockWaiters(){if(this._queue.length===0)for(let e=this._value;e>0;e--){const r=this._weightedWaiters[e-1];r&&(r.forEach(n=>n.resolve()),this._weightedWaiters[e-1]=[])}else{const e=this._queue[0].priority;for(let r=this._value;r>0;r--){const n=this._weightedWaiters[r-1];if(!n)continue;const s=n.findIndex(i=>i.priority<=e);(s===-1?n:n.splice(0,s)).forEach(i=>i.resolve())}}}_couldLockImmediately(e,r){return(this._queue.length===0||this._queue[0].priority<r)&&e<=this._value}}function ev(t,e){const r=tl(t,n=>e.priority<=n.priority);t.splice(r+1,0,e)}function tl(t,e){for(let r=t.length-1;r>=0;r--)if(e(t[r]))return r;return-1}var tv=function(t,e,r,n){function s(i){return i instanceof r?i:new r(function(o){o(i)})}return new(r||(r=Promise))(function(i,o){function c(w){try{f(n.next(w))}catch(h){o(h)}}function u(w){try{f(n.throw(w))}catch(h){o(h)}}function f(w){w.done?i(w.value):s(w.value).then(c,u)}f((n=n.apply(t,e||[])).next())})};class rl{constructor(e){this._semaphore=new Qw(1,e)}acquire(){return tv(this,arguments,void 0,function*(e=0){const[,r]=yield this._semaphore.acquire(1,e);return r})}runExclusive(e,r=0){return this._semaphore.runExclusive(()=>e(),1,r)}isLocked(){return this._semaphore.isLocked()}waitForUnlock(e=0){return this._semaphore.waitForUnlock(1,e)}release(){this._semaphore.isLocked()&&this._semaphore.release()}cancel(){return this._semaphore.cancel()}}class In{constructor(e,r,n=new Map){U(this,"providers");U(this,"registry");U(this,"sender");U(this,"changedKeys");this.providers=n,this.registry=r,this.changedKeys=[],this.sender=e}propagateState(e,r,n=[]){this.sender.send({key:e,state:r},n)}copyAndMerge(e){const r=new In(this.sender,this.registry,new Map);return e==null||e.providers.forEach((n,s)=>r.providers.set(s,n)),this.providers.forEach((n,s)=>r.providers.set(s,n)),r.changedKeys=[],r}get changed(){return this.changedKeys.length>0}set(e,r,n=!0){this.providers.set(e,r),n&&this.changedKeys.push(e)}setIfNotHas(e,r){this.providers.has(e)||this.set(e,r)}async create(e){const r=this.registry[e.type];if(r==null)throw new Error(`[AetherRoot.create] - could not find component ${e.type}`);const n=new r(e);return await n.internalUpdate(e),n}getOptional(e){return this.providers.get(e)??null}has(e){return this.providers.has(e)}get(e){const r=this.getOptional(e);if(r==null)throw new Error(`[AetherRoot.get] - could not find provider ${e}`);return r}}class ma{constructor(e){U(this,"type");U(this,"key");U(this,"_ctx");U(this,"_internalState");U(this,"_state");U(this,"_prevState");U(this,"_deleted",!1);U(this,"instrumentation");U(this,"schema");this.type=e.type,this.key=e.path[0],this._ctx=e.ctx,this._internalState={},this.instrumentation=e.instrumentation.child(`${this.type}(${this.key})`)}get _schema(){if(this.schema==null)throw new W(`[AetherLeaf] - expected subclass to define component schema, but none was found.
51
- Make sure to defne a property 'schema' on the class.`);return this.schema}setState(e){const r=Ss(e,this._state);this._prevState={...this._state},this._state=ys(this._schema,r,`${this.type}:${this.key}`),this.ctx.propagateState(this.key,r)}get ctx(){if(this._ctx==null)throw new me("context not defined");return this._ctx}get state(){if(this._state==null)throw new me("state not defined");return this._state}get internal(){return this._internalState}get prevState(){return this._prevState}get deleted(){return this._deleted}async internalUpdate({variant:e,path:r,ctx:n,state:s}){if(!this.deleted){if(this._ctx=n,e==="state"){this.validatePath(r);const i=ys(this._schema,s,`${this.type}:${this.key}`);this._state!=null?this.instrumentation.L.debug("updating state",()=>({diff:ri.difference(this.state,i)})):this.instrumentation.L.debug("setting initial state",{state:s}),this._prevState=this._state??i,this._state=i}else this.instrumentation.L.debug("updating context");await this.afterUpdate()}}async internalDelete(e){this.validatePath(e),this._deleted=!0,await this.afterDelete()}beforeUpdate(){}async afterUpdate(){}async afterDelete(){}validatePath(e){if(e.length===0)throw new me(`[Leaf.setState] - ${this.type}:${this.key} received an empty path`);const r=e[e.length-1];if(e.length>1)throw new me(`[Leaf.setState] - ${this.type}:${this.key} received a subPath ${e.join(".")} but is a leaf`);if(r!==this.key)throw new me(`[Leaf.setState] - ${this.type}:${this.key} received a key ${r} but expected ${this.key}`)}}class rr extends ma{constructor(r){super(r);U(this,"_children");this._children=new Map}get children(){return Array.from(this._children.values())}async internalUpdate(r){const{variant:n,path:s}=r;if(n==="context")return this._ctx=r.ctx.copyAndMerge(this._ctx),await this.updateContext({...r,ctx:this.ctx});const[i,o]=this.getRequiredKey(s),c={...r,ctx:this.ctx};return o.length===0?await this.updateThis(i,c):await this.updateChild(o,c)}async updateContext(r){await super.internalUpdate(r);for(const n of this.children)await n.internalUpdate({...r,ctx:this.ctx,variant:"context"})}async updateChild(r,n){const s=r[0],i=this.getChild(s);if(i!=null)return await i.internalUpdate({...n,path:r});if(r.length>1)throw new Error(`[Composite.setState] - ${this.type}:${this.key} could not find child with key ${s} while updating `);this._children.set(s,await n.ctx.create({...n,path:r}))}async updateThis(r,n){const s=n.ctx.copyAndMerge(this._ctx);if(r!==this.key)throw new me(`[Composite.update] - ${this.type}:${this.key} received a key ${r} but expected ${this.key}`);if(await super.internalUpdate({...n,ctx:s}),!!s.changed){this.instrumentation.L.debug("context changed",{changedKeys:s.changedKeys});for(const i of this.children)await i.internalUpdate({...n,ctx:this.ctx,variant:"context"})}}async internalDelete(r){const[n,s]=this.getRequiredKey(r);if(s.length===0){if(n!==this.key)throw new Error(`[Composite.delete] - ${this.type}:${this.key} received a key ${n} but expected ${this.key}`);const o=this.children;this._children=new Map;for(const c of o)await c.internalDelete([c.key]);await super.internalDelete([this.key])}const i=this.getChild(s[0]);i!=null&&(s.length>1?await i.internalDelete(s):(this._children.delete(i.key),await i.internalDelete(s)))}getRequiredKey(r,n){const[s,...i]=r;if(s==null)throw new Error(`Composite ${this.type}:${this.key} received an empty path`+(n!=null?` for ${n}`:""));return[s,i]}getChild(r){return this._children.get(r)??null}childrenOfType(...r){return this.children.filter(n=>r.includes(n.type))}}const rv=a.z.object({}),ke=class ke extends rr{constructor({worker:r,registry:n,instrumentation:s=el.Instrumentation.NOOP}){const o={ctx:new In(r,n,new Map),...ke.ZERO_UPDATE,instrumentation:s};super(o);U(this,"wrap");U(this,"schema",ke.schema);U(this,"mu",new rl);this.mu.runExclusive(async()=>await this.internalUpdate(o)),this.wrap=r,this.wrap.handle(c=>{this.mu.runExclusive(async()=>await this.handle(c))})}async handle(r){if(r.variant==="delete")await this.internalDelete(r.path);else{const n={...r,variant:"state",ctx:this.ctx,instrumentation:this.instrumentation};await this.internalUpdate(n)}}};U(ke,"TYPE","root"),U(ke,"KEY","root"),U(ke,"ZERO_UPDATE",{path:[ke.KEY],type:ke.TYPE,variant:"state",state:{}}),U(ke,"schema",rv);let nn=ke;const nl=t=>new nn(t),nv=Object.freeze(Object.defineProperty({__proto__:null,Composite:rr,Context:In,Leaf:ma,Root:nn,render:nl},Symbol.toStringTag,{value:"Module"})),sl="pluto-theming-context",sv=a.z.object({theme:bi}),Bt=class Bt extends rr{constructor(){super(...arguments);U(this,"schema",Bt.z)}async afterUpdate(){this.ctx.set(sl,this.state.theme)}};U(Bt,"TYPE","theming.Provider"),U(Bt,"z",sv);let Kt=Bt;const av=t=>t.get(sl),iv={[Kt.TYPE]:Kt},al=["success","error","warning","info","loading","disabled","secondary"],il=a.z.enum(al),ol=a.z.object({key:a.z.string(),variant:il,message:a.z.string(),description:a.z.string().optional(),time:F.z,data:a.z.record(a.z.unknown()).optional()}),cl=a.z.object({statuses:ol.array()}),wa="status.aggregator";class sn extends rr{constructor(){super(...arguments);U(this,"schema",cl)}async afterUpdate(){this.ctx.set(wa,this)}add(r){const n=F.now();this.setState(s=>({...s,statuses:[...s.statuses,{time:n,key:n.toString(),...r}]}))}}U(sn,"TYPE","status.Aggregator");const ov=t=>{const e=t.get(wa);return e.add.bind(e)},cv=t=>{const e=t.getOptional(wa);return e!=null?e.add.bind(e):()=>{}},lv={[sn.TYPE]:sn};exports.A=ou;exports.A$1=k;exports.Aggregator=sn;exports.Ay=rm;exports.B=ga;exports.C=cn;exports.ComponentSizeLevels=vi;exports.Composite=rr;exports.D=Nu;exports.D$1=W;exports.E=xl;exports.H=le;exports.I=ce;exports.LEVELS=wi;exports.Leaf=ma;exports.LevelComponentSizes=xu;exports.Mutex=rl;exports.N=Au;exports.N$1=ci;exports.Provider=Kt;exports.REGISTRY=iv;exports.REGISTRY$1=lv;exports.S=Ol;exports.S$1=I;exports.SYNNAX_DARK=Ti;exports.SYNNAX_LIGHT=Oi;exports.SYNNAX_THEMES=Bu;exports.U=Lt;exports.V=Su;exports.VARIANTS=al;exports.Ze=me;exports.aether=nv;exports.aggregatorStateZ=cl;exports.ay=Yy;exports.commonjsGlobal=dl;exports.customAlphabet=lw;exports.dimensions=ju;exports.ee=be;exports.executeInitialSetter=Wt;exports.executeSetter=Ss;exports.fontString=Zu;exports.ft=Ql;exports.g=P;exports.g$1=el;exports.getAugmentedNamespace=pl;exports.getDefaultExportFromCjs=yl;exports.hy=mp;exports.isSetter=zs;exports.l=gu;exports.levelZ=ku;exports.lt=au;exports.ly=fp;exports.m=F;exports.m$1=ri;exports.n=lu;exports.nanoid=uw;exports.o=cu;exports.o$1=Cl;exports.p=Ts;exports.prettyParse=ys;exports.q=Xl;exports.qd=Zc;exports.r=jl;exports.render=nl;exports.specZ=He;exports.specZ$1=ol;exports.state=Iu;exports.themeZ=bi;exports.u=on;exports.use=av;exports.useAggregate=ov;exports.useOptionalAggregate=cv;exports.usePassthrough=gi;exports.usePurePassthrough=mi;exports.variantZ=il;exports.w=K;exports.w$1=ai;exports.xy=ow;exports.z=zu;exports.zd=Yc;exports.ze=at;