@synnaxlabs/pluto 0.23.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 (493) hide show
  1. package/dist/{Animated-DPIV1IH6.js → Animated-BpuQZROI.js} +3 -3
  2. package/dist/{Animated-DjcnDVGC.cjs → Animated-DqAjXT8r.cjs} +1 -1
  3. package/dist/{Keyboard-BLHHROrq.js → Keyboard-BTyEk3pg.js} +3 -3
  4. package/dist/{Keyboard-CJLEUbYu.cjs → Keyboard-GDYsV4-x.cjs} +1 -1
  5. package/dist/{LinePlot-C9MVJErC.js → LinePlot-CQAK-dkX.js} +4110 -3906
  6. package/dist/LinePlot-DnLLplw_.cjs +66 -0
  7. package/dist/{Link-BsqVxj6V.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-Dux7qweq.cjs +1 -0
  11. package/dist/{Pack-mkZBsSIU.js → Pack-CCCsIeot.js} +6 -6
  12. package/dist/{Pack-CBNcamuh.cjs → Pack-_i2cfPYc.cjs} +1 -1
  13. package/dist/{Toggle-W4K3cLf7.js → Toggle-CpLFBHo7.js} +17239 -17153
  14. package/dist/Toggle-DlNzb7nt.cjs +143 -0
  15. package/dist/{Video-C2EYBKLN.js → Video-Bi9kFIHV.js} +2 -2
  16. package/dist/{Video-Kb-c-N69.cjs → Video-THwAEuOy.cjs} +1 -1
  17. package/dist/{aggregator-BZJAV5yZ.js → aggregator-CoD5WrqU.js} +5151 -5636
  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-DjjMU4Z6.cjs → external-B7RXnD0a.cjs} +1 -1
  34. package/dist/external-B815mDB0.cjs +1 -0
  35. package/dist/external-BxBMVx6g.js +97 -0
  36. package/dist/{external-CduvGaPN.js → external-C6v1z0ty.js} +37 -51
  37. package/dist/{external-XoJlPNFB.js → external-C8CIAjMj.js} +2 -2
  38. package/dist/external-CLwP0eXe.cjs +1 -0
  39. package/dist/{external-mlV4Onnq.cjs → external-CMk1k986.cjs} +1 -1
  40. package/dist/external-CUJXIrxM.cjs +1 -0
  41. package/dist/{external-0w2SHXg_.js → external-CXrgzQf5.js} +2 -2
  42. package/dist/external-Cv5GChi6.js +344 -0
  43. package/dist/{external-BKWizK6o.cjs → external-DMYExlt2.cjs} +1 -1
  44. package/dist/{external-WGyRiKbb.js → external-DQ4EhNBA.js} +32 -32
  45. package/dist/external-DRvtVPhp.cjs +1 -0
  46. package/dist/external-DShO9063.js +74 -0
  47. package/dist/external-DU5Xqqld.cjs +1 -0
  48. package/dist/external-D_WKlwCh.js +231 -0
  49. package/dist/{external-DlCoToEB.cjs → external-DjSiwSCE.cjs} +1 -1
  50. package/dist/external-Dm3eiIEN.cjs +1 -0
  51. package/dist/external-Do75w1Zt.cjs +1 -0
  52. package/dist/{external-DsNtnR-y.cjs → external-DqnUE4mV.cjs} +1 -1
  53. package/dist/external-DyTzmzSc.js +93 -0
  54. package/dist/{external-BB2SaR1o.js → external-NHkWeW29.js} +1 -1
  55. package/dist/external-NeMo53nv.js +271 -0
  56. package/dist/{external-TNsi3_BK.js → external-e0OPlFyY.js} +26 -26
  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 +4937 -4262
  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 +15 -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 +11 -8
  95. package/dist/src/channel/LinePlot.d.ts.map +1 -1
  96. package/dist/src/channel/Select.d.ts +2 -2
  97. package/dist/src/color/Picker/Picker.d.ts +2 -2
  98. package/dist/src/color/Swatch/Swatch.d.ts +4 -4
  99. package/dist/src/color/core/color.d.ts +7 -0
  100. package/dist/src/color/core/color.d.ts.map +1 -1
  101. package/dist/src/css/color.d.ts.map +1 -1
  102. package/dist/src/css/css.d.ts +4 -4
  103. package/dist/src/css/css.d.ts.map +1 -1
  104. package/dist/src/css/vars.d.ts.map +1 -1
  105. package/dist/src/dialog/index.d.ts +2 -0
  106. package/dist/src/dialog/index.d.ts.map +1 -0
  107. package/dist/src/dialog/use.d.ts +28 -0
  108. package/dist/src/dialog/use.d.ts.map +1 -0
  109. package/dist/src/divider/Divider.d.ts +2 -2
  110. package/dist/src/divider/Divider.d.ts.map +1 -1
  111. package/dist/src/dropdown/Dropdown.d.ts +8 -30
  112. package/dist/src/dropdown/Dropdown.d.ts.map +1 -1
  113. package/dist/src/form/Field.d.ts +35 -0
  114. package/dist/src/form/Field.d.ts.map +1 -0
  115. package/dist/src/form/Form.d.ts +19 -49
  116. package/dist/src/form/Form.d.ts.map +1 -1
  117. package/dist/src/form/external.d.ts +1 -0
  118. package/dist/src/form/external.d.ts.map +1 -1
  119. package/dist/src/generic/Generic.d.ts +1 -1
  120. package/dist/src/generic/Generic.d.ts.map +1 -1
  121. package/dist/src/hardware/device/Select.d.ts +2 -2
  122. package/dist/src/haul/Haul.d.ts +84 -3
  123. package/dist/src/haul/Haul.d.ts.map +1 -1
  124. package/dist/src/header/Actions.d.ts +1 -1
  125. package/dist/src/header/ButtonTitle.d.ts +1 -1
  126. package/dist/src/header/Header.d.ts +2 -2
  127. package/dist/src/header/Title.d.ts +1 -1
  128. package/dist/src/hooks/effect.d.ts.map +1 -1
  129. package/dist/src/hooks/ref.d.ts +3 -3
  130. package/dist/src/hooks/ref.d.ts.map +1 -1
  131. package/dist/src/hooks/useCursorDrag/types.d.ts +1 -1
  132. package/dist/src/hooks/useCursorDrag/useCursorDrag.d.ts +2 -2
  133. package/dist/src/hooks/useDebouncedCallback.d.ts.map +1 -1
  134. package/dist/src/hooks/useFilter.d.ts +1 -1
  135. package/dist/src/hooks/useFilter.d.ts.map +1 -1
  136. package/dist/src/hooks/useRequiredContext.d.ts.map +1 -1
  137. package/dist/src/hooks/useResize.d.ts +1 -1
  138. package/dist/src/hooks/useResize.d.ts.map +1 -1
  139. package/dist/src/hooks/useTransforms.d.ts.map +1 -1
  140. package/dist/src/hooks/useUniqueKey.d.ts.map +1 -1
  141. package/dist/src/icon/Icon.d.ts +14 -0
  142. package/dist/src/icon/Icon.d.ts.map +1 -0
  143. package/dist/src/icon/index.d.ts +2 -0
  144. package/dist/src/icon/index.d.ts.map +1 -0
  145. package/dist/src/index.d.ts +6 -0
  146. package/dist/src/index.d.ts.map +1 -1
  147. package/dist/src/input/Date.d.ts +1 -1
  148. package/dist/src/input/Date.d.ts.map +1 -1
  149. package/dist/src/input/DateTime.d.ts +1 -1
  150. package/dist/src/input/DragButton.d.ts +3 -3
  151. package/dist/src/input/HelpText.d.ts +2 -2
  152. package/dist/src/input/Item.d.ts +2 -2
  153. package/dist/src/input/Numeric.d.ts +3 -3
  154. package/dist/src/input/Numeric.d.ts.map +1 -1
  155. package/dist/src/input/Switch.d.ts.map +1 -1
  156. package/dist/src/input/Text.d.ts +2 -0
  157. package/dist/src/input/Text.d.ts.map +1 -1
  158. package/dist/src/input/TextArea.d.ts +1 -1
  159. package/dist/src/input/Time.d.ts +2 -2
  160. package/dist/src/input/Time.d.ts.map +1 -1
  161. package/dist/src/input/types.d.ts +2 -2
  162. package/dist/src/list/Column.d.ts +7 -6
  163. package/dist/src/list/Column.d.ts.map +1 -1
  164. package/dist/src/list/Core.d.ts +4 -4
  165. package/dist/src/list/Core.d.ts.map +1 -1
  166. package/dist/src/list/Data.d.ts +5 -3
  167. package/dist/src/list/Data.d.ts.map +1 -1
  168. package/dist/src/list/Filter.d.ts +4 -4
  169. package/dist/src/list/Filter.d.ts.map +1 -1
  170. package/dist/src/list/Hover.d.ts +1 -1
  171. package/dist/src/list/Hover.d.ts.map +1 -1
  172. package/dist/src/list/Item.d.ts +3 -3
  173. package/dist/src/list/Item.d.ts.map +1 -1
  174. package/dist/src/list/List.d.ts +1 -1
  175. package/dist/src/list/List.d.ts.map +1 -1
  176. package/dist/src/list/Search.d.ts +3 -3
  177. package/dist/src/list/Search.d.ts.map +1 -1
  178. package/dist/src/list/Selector.d.ts +3 -9
  179. package/dist/src/list/Selector.d.ts.map +1 -1
  180. package/dist/src/list/types.d.ts.map +1 -1
  181. package/dist/src/list/useSelect.d.ts +6 -2
  182. package/dist/src/list/useSelect.d.ts.map +1 -1
  183. package/dist/src/memo/useMemoCompare.d.ts +1 -1
  184. package/dist/src/memo/useMemoCompare.d.ts.map +1 -1
  185. package/dist/src/menu/ContextMenu.d.ts +2 -2
  186. package/dist/src/menu/Item.d.ts +7 -7
  187. package/dist/src/menu/Item.d.ts.map +1 -1
  188. package/dist/src/menu/Menu.d.ts +7 -5
  189. package/dist/src/menu/Menu.d.ts.map +1 -1
  190. package/dist/src/mock/MockGLBufferController.d.ts +1 -1
  191. package/dist/src/modal/Modal.d.ts +8 -0
  192. package/dist/src/modal/Modal.d.ts.map +1 -0
  193. package/dist/src/modal/index.d.ts +2 -0
  194. package/dist/src/modal/index.d.ts.map +1 -0
  195. package/dist/src/mosaic/Mosaic.d.ts +6 -5
  196. package/dist/src/mosaic/Mosaic.d.ts.map +1 -1
  197. package/dist/src/mosaic/tree.d.ts +3 -2
  198. package/dist/src/mosaic/tree.d.ts.map +1 -1
  199. package/dist/src/mosaic/types.d.ts +63 -1
  200. package/dist/src/mosaic/types.d.ts.map +1 -1
  201. package/dist/src/mosaic/use.d.ts +1 -1
  202. package/dist/src/nav/Bar.d.ts +2 -2
  203. package/dist/src/nav/Bar.d.ts.map +1 -1
  204. package/dist/src/nav/Drawer.d.ts +3 -3
  205. package/dist/src/note/Note.d.ts +1 -1
  206. package/dist/src/note/Note.d.ts.map +1 -1
  207. package/dist/src/observe/index.d.ts +2 -0
  208. package/dist/src/observe/index.d.ts.map +1 -0
  209. package/dist/src/observe/use.d.ts +19 -0
  210. package/dist/src/observe/use.d.ts.map +1 -0
  211. package/dist/src/os/Controls/Controls.d.ts +2 -2
  212. package/dist/src/os/Controls/Mac.d.ts +1 -1
  213. package/dist/src/os/Controls/Windows.d.ts +2 -2
  214. package/dist/src/os/Controls/Windows.d.ts.map +1 -1
  215. package/dist/src/os/Controls/types.d.ts +1 -1
  216. package/dist/src/os/use.d.ts.map +1 -1
  217. package/dist/src/pluto/Pluto.d.ts +8 -8
  218. package/dist/src/portal/Portal.d.ts +0 -1
  219. package/dist/src/portal/Portal.d.ts.map +1 -1
  220. package/dist/src/ranger/SelectLabel.d.ts +2 -2
  221. package/dist/src/ranger/TimeRangeChip.d.ts +4 -3
  222. package/dist/src/ranger/TimeRangeChip.d.ts.map +1 -1
  223. package/dist/src/resize/Core.d.ts +1 -1
  224. package/dist/src/resize/Multiple.d.ts +2 -2
  225. package/dist/src/resize/Single.d.ts +2 -2
  226. package/dist/src/select/Button.d.ts +8 -8
  227. package/dist/src/select/Button.d.ts.map +1 -1
  228. package/dist/src/select/ClearButton.d.ts +1 -1
  229. package/dist/src/select/ClearButton.d.ts.map +1 -1
  230. package/dist/src/select/DataType.d.ts +1 -1
  231. package/dist/src/select/DataType.d.ts.map +1 -1
  232. package/dist/src/select/Direction.d.ts +2 -2
  233. package/dist/src/select/List.d.ts +6 -5
  234. package/dist/src/select/List.d.ts.map +1 -1
  235. package/dist/src/select/Multiple.d.ts +10 -9
  236. package/dist/src/select/Multiple.d.ts.map +1 -1
  237. package/dist/src/select/Select.spec.d.ts.map +1 -1
  238. package/dist/src/select/Single.d.ts +9 -7
  239. package/dist/src/select/Single.d.ts.map +1 -1
  240. package/dist/src/state/state.d.ts +2 -1
  241. package/dist/src/state/state.d.ts.map +1 -1
  242. package/dist/src/status/Aggregator.d.ts +4 -4
  243. package/dist/src/status/Circle.d.ts +2 -2
  244. package/dist/src/status/Notification.d.ts +4 -4
  245. package/dist/src/status/Notification.d.ts.map +1 -1
  246. package/dist/src/status/Text.d.ts +2 -2
  247. package/dist/src/status/Text.d.ts.map +1 -1
  248. package/dist/src/status/aether/aggregator.d.ts +3 -3
  249. package/dist/src/status/aether/aggregator.d.ts.map +1 -1
  250. package/dist/src/status/aether/types.d.ts +1 -1
  251. package/dist/src/steps/Steps.d.ts +2 -2
  252. package/dist/src/synnax/Provider.d.ts +2 -2
  253. package/dist/src/synnax/Provider.d.ts.map +1 -1
  254. package/dist/src/synnax/aether/provider.d.ts +14 -14
  255. package/dist/src/synnax/aether/provider.d.ts.map +1 -1
  256. package/dist/src/tabs/Selector.d.ts +6 -12
  257. package/dist/src/tabs/Selector.d.ts.map +1 -1
  258. package/dist/src/tabs/Tabs.d.ts +8 -13
  259. package/dist/src/tabs/Tabs.d.ts.map +1 -1
  260. package/dist/src/tabs/external.d.ts +1 -0
  261. package/dist/src/tabs/external.d.ts.map +1 -1
  262. package/dist/src/tabs/types.d.ts +54 -0
  263. package/dist/src/tabs/types.d.ts.map +1 -0
  264. package/dist/src/tag/Tag.d.ts +3 -3
  265. package/dist/src/telem/Provider.d.ts +1 -1
  266. package/dist/src/telem/aether/context.d.ts +4 -4
  267. package/dist/src/telem/aether/context.d.ts.map +1 -1
  268. package/dist/src/telem/aether/factory.d.ts +1 -1
  269. package/dist/src/telem/aether/factory.d.ts.map +1 -1
  270. package/dist/src/telem/aether/noop.d.ts +1 -1
  271. package/dist/src/telem/aether/pipeline.d.ts +3 -3
  272. package/dist/src/telem/aether/pipeline.d.ts.map +1 -1
  273. package/dist/src/telem/aether/provider.d.ts +6 -6
  274. package/dist/src/telem/aether/remote.d.ts +3 -3
  275. package/dist/src/telem/aether/remote.d.ts.map +1 -1
  276. package/dist/src/telem/aether/static.d.ts +3 -3
  277. package/dist/src/telem/aether/telem.d.ts +3 -3
  278. package/dist/src/telem/aether/transformers.d.ts +3 -3
  279. package/dist/src/telem/aether/transformers.d.ts.map +1 -1
  280. package/dist/src/telem/client/cache/cache.d.ts +3 -3
  281. package/dist/src/telem/client/cache/static.d.ts +1 -1
  282. package/dist/src/telem/client/cache/unary.d.ts +3 -3
  283. package/dist/src/telem/client/client.d.ts +4 -5
  284. package/dist/src/telem/client/client.d.ts.map +1 -1
  285. package/dist/src/telem/client/reader.d.ts +4 -4
  286. package/dist/src/telem/client/streamer.d.ts +4 -4
  287. package/dist/src/telem/client/types.d.ts +1 -1
  288. package/dist/src/telem/control/Chip.d.ts +3 -3
  289. package/dist/src/telem/control/Chip.d.ts.map +1 -1
  290. package/dist/src/telem/control/Controller.d.ts +4 -4
  291. package/dist/src/telem/control/Indicator.d.ts +3 -3
  292. package/dist/src/telem/control/Legend.d.ts +1 -1
  293. package/dist/src/telem/control/Legend.d.ts.map +1 -1
  294. package/dist/src/telem/control/StateProvider.d.ts +3 -3
  295. package/dist/src/telem/control/aether/chip.d.ts +3 -3
  296. package/dist/src/telem/control/aether/controller.d.ts +8 -8
  297. package/dist/src/telem/control/aether/controller.d.ts.map +1 -1
  298. package/dist/src/telem/control/aether/indicator.d.ts +3 -3
  299. package/dist/src/telem/control/aether/legend.d.ts +3 -3
  300. package/dist/src/telem/control/aether/state.d.ts +5 -5
  301. package/dist/src/telem/test/mock.d.ts +2 -2
  302. package/dist/src/testutil/dom.d.ts.map +1 -1
  303. package/dist/src/text/DateTime.d.ts +5 -5
  304. package/dist/src/text/DateTime.d.ts.map +1 -1
  305. package/dist/src/text/Editable.d.ts +8 -7
  306. package/dist/src/text/Editable.d.ts.map +1 -1
  307. package/dist/src/text/Keyboard.d.ts +3 -3
  308. package/dist/src/text/Keyboard.d.ts.map +1 -1
  309. package/dist/src/text/Link.d.ts +3 -3
  310. package/dist/src/text/Link.d.ts.map +1 -1
  311. package/dist/src/text/SelectLevel.d.ts +2 -2
  312. package/dist/src/text/Text.d.ts +4 -4
  313. package/dist/src/text/Text.d.ts.map +1 -1
  314. package/dist/src/text/WithIcon.d.ts +5 -5
  315. package/dist/src/text/WithIcon.d.ts.map +1 -1
  316. package/dist/src/text/core/types.d.ts +1 -1
  317. package/dist/src/text/dimensions.d.ts.map +1 -1
  318. package/dist/src/theming/Provider.d.ts +4 -4
  319. package/dist/src/theming/Provider.d.ts.map +1 -1
  320. package/dist/src/theming/aether/provider.d.ts +2 -2
  321. package/dist/src/theming/aether/provider.d.ts.map +1 -1
  322. package/dist/src/theming/core/fontString.d.ts +2 -2
  323. package/dist/src/theming/core/fontString.d.ts.map +1 -1
  324. package/dist/src/theming/core/theme.d.ts +1 -1
  325. package/dist/src/theming/css.d.ts.map +1 -1
  326. package/dist/src/theming/font.d.ts.map +1 -1
  327. package/dist/src/tooltip/Config.d.ts +1 -1
  328. package/dist/src/tooltip/Dialog.d.ts +2 -2
  329. package/dist/src/tooltip/Dialog.d.ts.map +1 -1
  330. package/dist/src/tooltip/wrap.d.ts +1 -1
  331. package/dist/src/tooltip/wrap.d.ts.map +1 -1
  332. package/dist/src/tree/Tree.d.ts +16 -11
  333. package/dist/src/tree/Tree.d.ts.map +1 -1
  334. package/dist/src/tree/core.d.ts +2 -1
  335. package/dist/src/tree/core.d.ts.map +1 -1
  336. package/dist/src/triggers/Provider.d.ts +2 -2
  337. package/dist/src/triggers/Status.d.ts +1 -1
  338. package/dist/src/triggers/Text.d.ts +4 -4
  339. package/dist/src/triggers/Text.d.ts.map +1 -1
  340. package/dist/src/triggers/hooks.d.ts +4 -4
  341. package/dist/src/triggers/hooks.d.ts.map +1 -1
  342. package/dist/src/triggers/triggers.d.ts +3 -2
  343. package/dist/src/triggers/triggers.d.ts.map +1 -1
  344. package/dist/src/triggers/useDrag.d.ts +2 -2
  345. package/dist/src/util/children.d.ts +2 -2
  346. package/dist/src/util/children.d.ts.map +1 -1
  347. package/dist/src/util/component.d.ts +1 -1
  348. package/dist/src/util/component.d.ts.map +1 -1
  349. package/dist/src/util/renderProp.d.ts +1 -1
  350. package/dist/src/util/renderProp.d.ts.map +1 -1
  351. package/dist/src/util/rootElement.d.ts +2 -0
  352. package/dist/src/util/rootElement.d.ts.map +1 -0
  353. package/dist/src/util/zod.d.ts.map +1 -1
  354. package/dist/src/viewport/Mask.d.ts.map +1 -1
  355. package/dist/src/viewport/SelectMode.d.ts +2 -2
  356. package/dist/src/viewport/use.d.ts +4 -2
  357. package/dist/src/viewport/use.d.ts.map +1 -1
  358. package/dist/src/vis/axis/axis.d.ts +3 -3
  359. package/dist/src/vis/axis/canvas.d.ts +2 -2
  360. package/dist/src/vis/axis/ticks.d.ts +1 -1
  361. package/dist/src/vis/button/aether/button.d.ts +2 -2
  362. package/dist/src/vis/button/use.d.ts +1 -1
  363. package/dist/src/vis/canvas/Canvas.d.ts +2 -2
  364. package/dist/src/vis/canvas/Canvas.d.ts.map +1 -1
  365. package/dist/src/vis/canvas/aether/canvas.d.ts +25 -25
  366. package/dist/src/vis/diagram/Diagram.d.ts +6 -6
  367. package/dist/src/vis/diagram/Diagram.d.ts.map +1 -1
  368. package/dist/src/vis/diagram/aether/Diagram.d.ts +41 -41
  369. package/dist/src/vis/diagram/aether/Diagram.d.ts.map +1 -1
  370. package/dist/src/vis/diagram/aether/types.d.ts +331 -0
  371. package/dist/src/vis/diagram/aether/types.d.ts.map +1 -0
  372. package/dist/src/vis/diagram/align.d.ts +1 -1
  373. package/dist/src/vis/diagram/align.d.ts.map +1 -1
  374. package/dist/src/vis/diagram/edge/Edge.d.ts +4 -4
  375. package/dist/src/vis/diagram/edge/Edge.d.ts.map +1 -1
  376. package/dist/src/vis/diagram/edge/connector/connector.d.ts +12 -4
  377. package/dist/src/vis/diagram/edge/connector/connector.d.ts.map +1 -1
  378. package/dist/src/vis/diagram/external.d.ts +1 -1
  379. package/dist/src/vis/diagram/external.d.ts.map +1 -1
  380. package/dist/src/vis/diagram/util.d.ts +1 -1
  381. package/dist/src/vis/diagram/util.d.ts.map +1 -1
  382. package/dist/src/vis/draw2d/index.d.ts +4 -4
  383. package/dist/src/vis/eraser/aether/eraser.d.ts +26 -26
  384. package/dist/src/vis/eraser/use.d.ts +2 -2
  385. package/dist/src/vis/legend/Container.d.ts +101 -7
  386. package/dist/src/vis/legend/Container.d.ts.map +1 -1
  387. package/dist/src/vis/legend/Simple.d.ts +2 -2
  388. package/dist/src/vis/line/Line.d.ts +2 -2
  389. package/dist/src/vis/line/Line.d.ts.map +1 -1
  390. package/dist/src/vis/line/aether/line.d.ts +10 -9
  391. package/dist/src/vis/line/aether/line.d.ts.map +1 -1
  392. package/dist/src/vis/lineplot/Axis.d.ts +5 -5
  393. package/dist/src/vis/lineplot/Axis.d.ts.map +1 -1
  394. package/dist/src/vis/lineplot/Legend.d.ts +2 -2
  395. package/dist/src/vis/lineplot/Line.d.ts +1 -1
  396. package/dist/src/vis/lineplot/Line.d.ts.map +1 -1
  397. package/dist/src/vis/lineplot/LinePlot.d.ts +7 -7
  398. package/dist/src/vis/lineplot/LinePlot.d.ts.map +1 -1
  399. package/dist/src/vis/lineplot/Title.d.ts +2 -2
  400. package/dist/src/vis/lineplot/Title.d.ts.map +1 -1
  401. package/dist/src/vis/lineplot/Viewport.d.ts +1 -1
  402. package/dist/src/vis/lineplot/aether/LinePlot.d.ts +57 -57
  403. package/dist/src/vis/lineplot/aether/LinePlot.d.ts.map +1 -1
  404. package/dist/src/vis/lineplot/aether/XAxis.d.ts +4 -3
  405. package/dist/src/vis/lineplot/aether/XAxis.d.ts.map +1 -1
  406. package/dist/src/vis/lineplot/aether/YAxis.d.ts +5 -4
  407. package/dist/src/vis/lineplot/aether/YAxis.d.ts.map +1 -1
  408. package/dist/src/vis/lineplot/aether/axis.d.ts +6 -6
  409. package/dist/src/vis/lineplot/aether/axis.d.ts.map +1 -1
  410. package/dist/src/vis/lineplot/aether/grid.d.ts +1 -1
  411. package/dist/src/vis/lineplot/aether/grid.d.ts.map +1 -1
  412. package/dist/src/vis/lineplot/range/Annotation.d.ts +2 -2
  413. package/dist/src/vis/lineplot/range/Annotation.d.ts.map +1 -1
  414. package/dist/src/vis/lineplot/range/Provider.d.ts +2 -2
  415. package/dist/src/vis/lineplot/range/Provider.d.ts.map +1 -1
  416. package/dist/src/vis/lineplot/range/aether/annotation.d.ts +4 -4
  417. package/dist/src/vis/lineplot/range/aether/provider.d.ts +19 -19
  418. package/dist/src/vis/lineplot/tooltip/Tooltip.d.ts +2 -2
  419. package/dist/src/vis/lineplot/tooltip/Tooltip.d.ts.map +1 -1
  420. package/dist/src/vis/lineplot/tooltip/aether/tooltip.d.ts +6 -6
  421. package/dist/src/vis/measure/Measure.d.ts +1 -2
  422. package/dist/src/vis/measure/Measure.d.ts.map +1 -1
  423. package/dist/src/vis/measure/aether/measure.d.ts +7 -7
  424. package/dist/src/vis/render/GLProgram.d.ts +2 -2
  425. package/dist/src/vis/render/clear/program.d.ts +1 -1
  426. package/dist/src/vis/render/context.d.ts +4 -7
  427. package/dist/src/vis/render/context.d.ts.map +1 -1
  428. package/dist/src/vis/render/eraser.d.ts +3 -3
  429. package/dist/src/vis/render/performance.d.ts +11 -0
  430. package/dist/src/vis/render/performance.d.ts.map +1 -0
  431. package/dist/src/vis/render/util.d.ts.map +1 -1
  432. package/dist/src/vis/rule/Rule.d.ts +2 -2
  433. package/dist/src/vis/rule/Rule.d.ts.map +1 -1
  434. package/dist/src/vis/rule/aether/aether.d.ts +5 -5
  435. package/dist/src/vis/schematic/Forms.d.ts +1 -0
  436. package/dist/src/vis/schematic/Forms.d.ts.map +1 -1
  437. package/dist/src/vis/schematic/Labeled.d.ts +2 -2
  438. package/dist/src/vis/schematic/Labeled.d.ts.map +1 -1
  439. package/dist/src/vis/schematic/SelectOrientation.d.ts +3 -3
  440. package/dist/src/vis/schematic/Symbols.d.ts +113 -19
  441. package/dist/src/vis/schematic/Symbols.d.ts.map +1 -1
  442. package/dist/src/vis/schematic/primitives/Primitives.d.ts +27 -3
  443. package/dist/src/vis/schematic/primitives/Primitives.d.ts.map +1 -1
  444. package/dist/src/vis/schematic/registry.d.ts +5 -6
  445. package/dist/src/vis/schematic/registry.d.ts.map +1 -1
  446. package/dist/src/vis/toggle/aether/toggle.d.ts +5 -5
  447. package/dist/src/vis/toggle/use.d.ts +1 -1
  448. package/dist/src/vis/value/aether/value.d.ts +43 -43
  449. package/dist/src/vis/value/use.d.ts +12 -12
  450. package/dist/src/worker/Context.d.ts +1 -1
  451. package/dist/src/worker/Context.d.ts.map +1 -1
  452. package/dist/style.css +1 -1
  453. package/dist/tabs.cjs +1 -1
  454. package/dist/tabs.js +1 -1
  455. package/dist/text.cjs +1 -1
  456. package/dist/text.js +2 -2
  457. package/dist/theming.cjs +1 -1
  458. package/dist/theming.js +2 -2
  459. package/dist/tree.cjs +1 -1
  460. package/dist/tree.js +1 -1
  461. package/dist/triggers.cjs +1 -1
  462. package/dist/triggers.js +1 -1
  463. package/dist/{units-BsHX82D_.cjs → units-CoE6Mywf.cjs} +1 -1
  464. package/dist/{units-DechjShe.js → units-DlP7zkaE.js} +1 -1
  465. package/dist/video.cjs +1 -1
  466. package/dist/video.js +1 -1
  467. package/package.json +23 -24
  468. package/dist/LinePlot-DkAUE5Nq.cjs +0 -68
  469. package/dist/Link-C3NUk5cp.cjs +0 -1
  470. package/dist/List-BbB1S5Vo.cjs +0 -1
  471. package/dist/List-DPugi06W.js +0 -22
  472. package/dist/Toggle-BBGPiXIA.cjs +0 -188
  473. package/dist/aggregator-DueF6Q-Z.cjs +0 -45
  474. package/dist/css-DZx3bWkH.cjs +0 -1
  475. package/dist/css-TXuXKs3A.js +0 -1364
  476. package/dist/external-B-CtJFCn.js +0 -96
  477. package/dist/external-B39SmpRo.js +0 -201
  478. package/dist/external-BbnWD0Pc.js +0 -66
  479. package/dist/external-BphNoXuB.js +0 -92
  480. package/dist/external-CsPOXIEm.cjs +0 -1
  481. package/dist/external-CyiLaYmg.js +0 -322
  482. package/dist/external-CztU6wom.cjs +0 -1
  483. package/dist/external-D1NnASGa.cjs +0 -1
  484. package/dist/external-DrS33VU5.cjs +0 -1
  485. package/dist/external-WzX6JA2j.cjs +0 -1
  486. package/dist/external-fg-pJfZR.js +0 -260
  487. package/dist/external-vZfda3xX.cjs +0 -1
  488. package/dist/external-vgqH7hLg.cjs +0 -1
  489. package/dist/jsx-runtime-fmb_vB8K.cjs +0 -25
  490. package/dist/src/util/case.d.ts +0 -2
  491. package/dist/src/util/case.d.ts.map +0 -1
  492. package/dist/src/vis/diagram/types.d.ts +0 -73
  493. package/dist/src/vis/diagram/types.d.ts.map +0 -1
@@ -0,0 +1,51 @@
1
+ "use strict";var Wo=Object.defineProperty;var Go=(t,e,r)=>e in t?Wo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var D=(t,e,r)=>Go(t,typeof e!="symbol"?e+"":e,r);const s=require("zod"),O=require("./css-CC1MhhH7.cjs"),Fn=require("react");var Zo=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Vo(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Jo(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 i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(r,n,i.get?i:{enumerable:!0,get:function(){return t[n]}})}),r}const wt=t=>t!=null&&typeof t=="object"&&!Array.isArray(t);var Ko=Object.defineProperty,Ho=(t,e,r)=>e in t?Ko(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,bt=(t,e,r)=>Ho(t,typeof e!="symbol"?e+"":e,r);let Xo=class{constructor(){bt(this,"contentType","application/json"),bt(this,"decoder"),bt(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=JSON.parse(e),i=O.O(n);return r!=null?r.parse(i):i}encodeString(e){const r=O.v(e);return JSON.stringify(r,(n,i)=>ArrayBuffer.isView(i)?Array.from(i):wt(i)&&"encode_value"in i?typeof i.value=="bigint"?i.value.toString():i.value:typeof i=="bigint"?i.toString():i)}static registerCustomType(){}},Qo=class{constructor(){bt(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||!wt(e[0]))throw new Error("Payload must be an array of objects");const r=Object.keys(e[0]),n=[r.join(",")];return e.forEach(i=>{const a=r.map(o=>JSON.stringify(i[o]??""));n.push(a.join(","))}),n.join(`
2
+ `)}decodeString(e,r){const[n,...i]=e.trim().split(`
3
+ `).map(l=>l.trim());if(n.length===0)return r!=null?r.parse({}):{};const a=n.split(",").map(l=>l.trim()),o={};return a.forEach(l=>{o[l]=[]}),i.forEach(l=>{const u=l.split(",").map(f=>f.trim());a.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(){}},ec=class{constructor(){bt(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 Xo;new Qo;new ec;const gi=t=>t!=null&&typeof t=="object"&&"toString"in t,tc=t=>{if(gi(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}},Mr=(t,e=!1)=>{const r=gi(t)?"stringer":typeof t;let n;switch(r){case"string":n=(i,a)=>i.localeCompare(a);break;case"stringer":n=(i,a)=>i.toString().localeCompare(a.toString());break;case"number":n=(i,a)=>Number(i)-Number(a);break;case"bigint":n=(i,a)=>BigInt(i)-BigInt(a)>0n?1:-1;break;case"boolean":n=(i,a)=>Number(i)-Number(a);break;case"undefined":n=()=>0;break;default:return console.warn(`sortFunc: unknown type ${r}`),()=>-1}return e?pi(n):n},rc=(t,e,r)=>{const n=Mr(e[t],r);return(i,a)=>n(i[t],a[t])},nc=(t,e)=>t.length!==e.length?t.length-e.length:t.every((r,n)=>r===e[n])?0:-1,sc=(t,e)=>{if(t.length!==e.length)return t.length-e.length;if(t.length===0)return 0;const r=Mr(t[0]),n=[...t].sort(r),i=[...e].sort(r);return n.every((a,o)=>a===i[o])?0:-1},ic=(t,e)=>t===e?0:t==="first"&&e==="last"?1:-1,pi=t=>(e,r)=>t(r,e),ac=t=>t<0,oc=t=>t>0,cc=t=>t>=0,lc=(t,e)=>{const r=/([a-zA-Z]+)|(\d+)/g,n=t.replace(/[\s_.-]+/g,"").match(r),i=e.replace(/[\s_.-]+/g,"").match(r);if(!n||!i)return 0;for(let a=0;a<Math.min(n.length,i.length);a++){const o=n[a],l=i[a];if(isNaN(Number(o))&&isNaN(Number(l))){const u=o.localeCompare(l);if(u!==0)return u}else if(!isNaN(Number(o))&&!isNaN(Number(l))){const u=Number(o)-Number(l);if(u!==0)return u}else return isNaN(Number(o))?-1:1}return n.length-i.length},uc=Object.freeze(Object.defineProperty({__proto__:null,EQUAL:0,GREATER_THAN:1,LESS_THAN:-1,isGreaterThan:oc,isGreaterThanEqual:cc,isLessThan:ac,newF:Mr,newFieldF:rc,order:ic,primitiveArrays:nc,reverseF:pi,stringsWithNumbers:lc,unorderedPrimitiveArrays:sc},Symbol.toStringTag,{value:"Module"})),hc=(t,e)=>{let r=null;return e===0?t:(...n)=>{r!==null&&(clearTimeout(r),r=null),r=setTimeout(()=>t(...n),e)}},fc=(t,e)=>{let r=null;return e===0?t:(...n)=>{r===null&&(r=setTimeout(()=>{t(...n),r=null},e))}},mi=(t,e)=>{const r=t.split(".");return r.map((n,i)=>{const a=e(n,i,r);return a==null?null:typeof a=="string"?a:a.join(".")}).filter(n=>n!=null).join(".")},_n=(t,e,r={optional:!1})=>{const{optional:n,getter:i=(l,u)=>l[u]}=r,a=e.split(".");if(a.length===1&&a[0]==="")return t;let o=t;for(const l of a){const u=i(o,l);if(u==null){if(n)return null;throw new Error(`Path ${e} does not exist. ${l} is null`)}o=u}return o},dc=(t,e,r)=>{const n=e.split(".");let i=t;for(let a=0;a<n.length-1;a++){const o=n[a];if(i[o]==null)throw new Error(`Path ${e} does not exist`);i=i[o]}i[n[n.length-1]]=r},yc=(t,e)=>{const r=t.split(".");return e<0?r[r.length+e]:r[e]},gc=t=>t.join("."),pc=(t,e)=>{try{return _n(t,e),!0}catch{return!1}},mc=(t,e)=>{if(e.length===0)return!0;const r=t.split("."),n=e.split(".");if(n.length>r.length)return!1;for(let i=0;i<n.length;i++){const a=r[i],o=n[i];if(o!=="*"&&a!==o)return!1}return!0},wc=t=>JSON.parse(JSON.stringify(t)),bc=(t,...e)=>(e.forEach(r=>{let n=t;const i=r.split(".");i.forEach((a,o)=>{o===i.length-1?delete n[a]:a in n&&(n=n[a])})}),t),vc=(t,e,r="")=>{const n={},i=(a,o,l)=>{if(typeof a!=typeof o||a===null||o===null){n[l]=[a,o];return}if(typeof a=="object"&&typeof o=="object")if(Array.isArray(a)&&Array.isArray(o)){if(a.length!==o.length){n[l]=[a,o];return}for(let u=0;u<a.length;u++)i(a[u],o[u],`${l}[${u}]`)}else new Set([...Object.keys(a),...Object.keys(o)]).forEach(u=>{i(a[u],o[u],l!==""?`${l}.${u}`:u)});else a!==o&&(n[l]=[a,o])};return i(t,e,r),n},bn=(t,e)=>{const r=Array.isArray(t),n=Array.isArray(e);if(r!==n)return!1;if(r&&n){const o=t,l=e;if(o.length!==l.length)return!1;for(let u=0;u<o.length;u++)if(!bn(o[u],l[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 i=Object.keys(t),a=Object.keys(e);if(i.length!==a.length)return!1;for(const o of i){const l=t[o],u=e[o];if(typeof l=="object"&&typeof u=="object"){if(!bn(l,u))return!1}else if(l!==u)return!1}return!0},wi=(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 i of n){const a=t[i],o=e[i];if(typeof a=="object"&&typeof o=="object"){if(!wi(a,o))return!1}else if(a!==o)return!1}return!0},vn=(t,...e)=>{if(e.length===0)return t;const r=e.shift();if(wt(t)&&wt(r))for(const n in r)try{wt(r[n])?(n in t||Object.assign(t,{[n]:{}}),vn(t[n],r[n])):Object.assign(t,{[n]:r[n]})}catch(i){throw i instanceof TypeError?new TypeError(`.${n}: ${i.message}`):i}return vn(t,...e)},Oc=(t,e,r)=>{const n=(i,a,o)=>{for(const l in a){const u=a[l];if(o!=null&&o.shape[l]){const f=o.shape[l].safeParse(u);f.success&&(i[l]=f.data)}else typeof u=="object"&&!Array.isArray(u)&&u!==null&&o&&o.shape&&o.shape[l]&&(i[l]||(i[l]={}),n(i[l],u,o.shape[l]))}return i};return n({...t},e,r)},bi=Object.freeze(Object.defineProperty({__proto__:null,copy:wc,deleteD:bc,difference:vc,element:yc,equal:bn,get:_n,has:pc,join:gc,override:vn,overrideValidItems:Oc,partialEqual:wi,pathsMatch:mc,set:dc,transformPath:mi},Symbol.toStringTag,{value:"Module"}));var Tc=Object.defineProperty,Sc=(t,e,r)=>e in t?Tc(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,p=(t,e,r)=>Sc(t,typeof e!="symbol"?e+"":e,r);let zc=(t,e=21)=>(r=e)=>{let n="",i=r;for(;i--;)n+=t[Math.random()*t.length|0];return n};const Nc="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",vi=zc(Nc,11),Ec=Object.freeze(Object.defineProperty({__proto__:null,id:vi},Symbol.toStringTag,{value:"Module"})),Oi=(t,e)=>{const r=new F(e);if(![W.DAY,W.HOUR,W.MINUTE,W.SECOND,W.MILLISECOND,W.MICROSECOND,W.NANOSECOND].some(i=>i.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 W(n)},P=class T{constructor(e,r="UTC"){if(p(this,"value"),p(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 i=new Date(e,r-1,n,0,0,0,0);return new T(BigInt(i.getTime())*T.MILLISECOND.valueOf()).truncate(T.DAY).valueOf()}encode(){return this.value.toString()}valueOf(){return this.value}static parseTimeString(e,r="UTC"){const[n,i,a]=e.split(":");let o="00",l="00";a!=null&&([o,l]=a.split("."));let u=T.hours(parseInt(n??"00",10)).add(T.minutes(parseInt(i??"00",10))).add(T.seconds(parseInt(o??"00",10))).add(T.milliseconds(parseInt(l??"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 W(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 Nt(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 Oi(this,e)}get isToday(){return this.truncate(W.DAY).equals(T.now().truncate(W.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 i=new T(n);i.after(r)&&(r=i)}return r}static min(...e){let r=T.MAX;for(const n of e){const i=new T(n);i.before(r)&&(r=i)}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)}};p(P,"NANOSECOND",P.nanoseconds(1)),p(P,"MICROSECOND",P.microseconds(1)),p(P,"MILLISECOND",P.milliseconds(1)),p(P,"SECOND",P.seconds(1)),p(P,"MINUTE",P.minutes(1)),p(P,"HOUR",P.hours(1)),p(P,"DAY",P.days(1)),p(P,"MAX",new P((1n<<63n)-1n)),p(P,"MIN",new P(0)),p(P,"ZERO",new P(0)),p(P,"z",s.z.union([s.z.object({value:s.z.bigint()}).transform(t=>new P(t.value)),s.z.string().transform(t=>new P(BigInt(t))),s.z.instanceof(Number).transform(t=>new P(t)),s.z.number().transform(t=>new P(t)),s.z.instanceof(P)]));let F=P;const B=class k{constructor(e){p(this,"value"),p(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 k(e).valueOf()}greaterThan(e){return this.valueOf()>new k(e).valueOf()}lessThanOrEqual(e){return this.valueOf()<=new k(e).valueOf()}greaterThanOrEqual(e){return this.valueOf()>=new k(e).valueOf()}remainder(e){return Oi(this,e)}truncate(e){return new k(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(){const e=this.truncate(k.DAY),r=this.truncate(k.HOUR),n=this.truncate(k.MINUTE),i=this.truncate(k.SECOND),a=this.truncate(k.MILLISECOND),o=this.truncate(k.MICROSECOND),l=this.truncate(k.NANOSECOND),u=e,f=r.sub(e),w=n.sub(r),h=i.sub(n),M=a.sub(i),_=o.sub(a),re=l.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 `),M.isZero||(R+=`${M.milliseconds}ms `),_.isZero||(R+=`${_.microseconds}µs `),re.isZero||(R+=`${re.nanoseconds}ns`),R.trim()}get days(){return Number(this.valueOf())/Number(k.DAY.valueOf())}get hours(){return Number(this.valueOf())/Number(k.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(k.MINUTE.valueOf())}get seconds(){return Number(this.valueOf())/Number(k.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(k.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(k.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===BigInt(0)}equals(e){return this.valueOf()===new k(e).valueOf()}add(e){return new k(this.valueOf()+new k(e).valueOf())}sub(e){return new k(this.valueOf()-new k(e).valueOf())}static nanoseconds(e=1){return new k(e)}static microseconds(e=1){return k.nanoseconds(e*1e3)}static milliseconds(e=1){return k.microseconds(e*1e3)}static seconds(e=1){return k.milliseconds(e*1e3)}static minutes(e){return k.seconds(e.valueOf()*60)}static hours(e){return k.minutes(e*60)}static days(e){return k.hours(e*24)}};p(B,"NANOSECOND",B.nanoseconds(1)),p(B,"MICROSECOND",B.microseconds(1)),p(B,"MILLISECOND",B.milliseconds(1)),p(B,"SECOND",B.seconds(1)),p(B,"MINUTE",B.minutes(1)),p(B,"HOUR",B.hours(1)),p(B,"DAY",B.days(1)),p(B,"MAX",new B((1n<<63n)-1n)),p(B,"MIN",new B(0)),p(B,"ZERO",new B(0)),p(B,"z",s.z.union([s.z.object({value:s.z.bigint()}).transform(t=>new B(t.value)),s.z.string().transform(t=>new B(BigInt(t))),s.z.instanceof(Number).transform(t=>new B(t)),s.z.number().transform(t=>new B(t)),s.z.instanceof(B)]));let W=B;const st=class Ht extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new Ht(e).valueOf()}get period(){return W.seconds(1/this.valueOf())}sampleCount(e){return new W(e).seconds*this.valueOf()}byteCount(e,r){return this.sampleCount(e)*new ae(r).valueOf()}span(e){return W.seconds(e/this.valueOf())}byteSpan(e,r){return this.span(e.valueOf()/r.valueOf())}static hz(e){return new Ht(e)}static khz(e){return Ht.hz(e*1e3)}};p(st,"z",s.z.union([s.z.number().transform(t=>new st(t)),s.z.instanceof(Number).transform(t=>new st(t)),s.z.instanceof(st)]));let Ic=st;const H=class extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}length(e){return e.valueOf()/this.valueOf()}size(e){return new Dr(e*this.valueOf())}};p(H,"UNKNOWN",new H(0)),p(H,"BIT128",new H(16)),p(H,"BIT64",new H(8)),p(H,"BIT32",new H(4)),p(H,"BIT16",new H(2)),p(H,"BIT8",new H(1)),p(H,"z",s.z.union([s.z.number().transform(t=>new H(t)),s.z.instanceof(Number).transform(t=>new H(t)),s.z.instanceof(H)]));let ae=H;const be=class Xt{constructor(e,r){p(this,"start"),p(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 W(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 Xt(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=W.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 i=F.max(n.start,e.start),a=F.min(n.end,e.end);return a.before(i)?!1:new W(a.sub(i)).greaterThanOrEqual(r)}roughlyEquals(e,r){let n=this.start.sub(e.start).valueOf(),i=this.end.sub(e.end).valueOf();return n<0&&(n=-n),i<0&&(i=-i),n<=r.valueOf()&&i<=r.valueOf()}contains(e){return e instanceof Xt?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const r=new Xt(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}};p(be,"MAX",new be(F.MIN,F.MAX)),p(be,"MIN",new be(F.MAX,F.MIN)),p(be,"ZERO",new be(F.ZERO,F.ZERO)),p(be,"z",s.z.union([s.z.object({start:F.z,end:F.z}).transform(t=>new be(t.start,t.end)),s.z.instanceof(be)]));let Nt=be;const d=class ve extends String{constructor(e){if(e instanceof ve||typeof e=="string"||typeof e.valueOf()=="string"){super(e.valueOf());return}else{const r=ve.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(r!=null){super(r.valueOf());return}}throw super(ve.UNKNOWN.valueOf()),new Error(`unable to find data type for ${e.toString()}`)}get Array(){const e=ve.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(ve.JSON)||this.equals(ve.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(ve.UUID)}get isInteger(){return this.toString().startsWith("int")}get isFloat(){return this.toString().startsWith("float")}get density(){const e=ve.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 ve.BIG_INT_TYPES.some(e=>e.equals(this))}};p(d,"UNKNOWN",new d("unknown")),p(d,"FLOAT64",new d("float64")),p(d,"FLOAT32",new d("float32")),p(d,"INT64",new d("int64")),p(d,"INT32",new d("int32")),p(d,"INT16",new d("int16")),p(d,"INT8",new d("int8")),p(d,"UINT64",new d("uint64")),p(d,"UINT32",new d("uint32")),p(d,"UINT16",new d("uint16")),p(d,"UINT8",new d("uint8")),p(d,"BOOLEAN",d.UINT8),p(d,"TIMESTAMP",new d("timestamp")),p(d,"UUID",new d("uuid")),p(d,"STRING",new d("string")),p(d,"JSON",new d("json")),p(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]])),p(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]])),p(d,"DENSITIES",new Map([[d.UINT8.toString(),ae.BIT8],[d.UINT16.toString(),ae.BIT16],[d.UINT32.toString(),ae.BIT32],[d.UINT64.toString(),ae.BIT64],[d.FLOAT32.toString(),ae.BIT32],[d.FLOAT64.toString(),ae.BIT64],[d.INT8.toString(),ae.BIT8],[d.INT16.toString(),ae.BIT16],[d.INT32.toString(),ae.BIT32],[d.INT64.toString(),ae.BIT64],[d.TIMESTAMP.toString(),ae.BIT64],[d.STRING.toString(),ae.UNKNOWN],[d.JSON.toString(),ae.UNKNOWN],[d.UUID.toString(),ae.BIT128]])),p(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]),p(d,"BIG_INT_TYPES",[d.INT64,d.UINT64,d.TIMESTAMP]),p(d,"z",s.z.union([s.z.string().transform(t=>new d(t)),s.z.instanceof(d)]));let $=d;const ne=class Z extends Number{constructor(e){super(e.valueOf())}largerThan(e){return this.valueOf()>e.valueOf()}smallerThan(e){return this.valueOf()<e.valueOf()}add(e){return Z.bytes(this.valueOf()+e.valueOf())}sub(e){return Z.bytes(this.valueOf()-e.valueOf())}truncate(e){return new Z(Math.trunc(this.valueOf()/e.valueOf())*e.valueOf())}remainder(e){return Z.bytes(this.valueOf()%e.valueOf())}get gigabytes(){return this.valueOf()/Z.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/Z.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/Z.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/Z.TERABYTE.valueOf()}toString(){const e=this.truncate(Z.TERABYTE),r=this.truncate(Z.GIGABYTE),n=this.truncate(Z.MEGABYTE),i=this.truncate(Z.KILOBYTE),a=this.truncate(Z.BYTE),o=e,l=r.sub(e),u=n.sub(r),f=i.sub(n),w=a.sub(i);let h="";return o.isZero||(h+=`${o.terabytes}TB `),l.isZero||(h+=`${l.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 Z(e)}static kilobytes(e=1){return Z.bytes(e.valueOf()*1e3)}static megabytes(e=1){return Z.kilobytes(e.valueOf()*1e3)}static gigabytes(e=1){return Z.megabytes(e.valueOf()*1e3)}static terabytes(e){return Z.gigabytes(e.valueOf()*1e3)}get isZero(){return this.valueOf()===0}};p(ne,"BYTE",new ne(1)),p(ne,"KILOBYTE",ne.kilobytes(1)),p(ne,"MEGABYTE",ne.megabytes(1)),p(ne,"GIGABYTE",ne.gigabytes(1)),p(ne,"TERABYTE",ne.terabytes(1)),p(ne,"ZERO",new ne(0)),p(ne,"z",s.z.union([s.z.number().transform(t=>new ne(t)),s.z.instanceof(ne)]));let Dr=ne;const Ac=s.z.union([s.z.instanceof(Uint8Array),s.z.instanceof(Uint16Array),s.z.instanceof(Uint32Array),s.z.instanceof(BigUint64Array),s.z.instanceof(Float32Array),s.z.instanceof(Float64Array),s.z.instanceof(Int8Array),s.z.instanceof(Int16Array),s.z.instanceof(Int32Array),s.z.instanceof(BigInt64Array)]),Ti=t=>{const e=typeof t;return e==="string"||e==="number"||e==="boolean"||e==="bigint"||t instanceof F||t instanceof W||t instanceof Date},kc=(t,e,r,n=0)=>t.usesBigInt&&!e.usesBigInt?Number(r)-Number(n):!t.usesBigInt&&e.usesBigInt?BigInt(r)-BigInt(n):it(r,-n),xc=t=>t==null?!1:Array.isArray(t)||t instanceof ArrayBuffer||ArrayBuffer.isView(t)&&!(t instanceof DataView)||t instanceof Si?!0:Ti(t),Ue=-1;let Si=class Ie{constructor(e){p(this,"key",""),p(this,"isSynnaxSeries",!0),p(this,"dataType"),p(this,"sampleOffset"),p(this,"gl"),p(this,"_data"),p(this,"_timeRange"),p(this,"alignment",0n),p(this,"_cachedMin"),p(this,"_cachedMax"),p(this,"writePos",Ue),p(this,"_refCount",0),p(this,"_cachedLength"),xc(e)&&(e={data:e});const{dataType:r,timeRange:n,sampleOffset:i=0,glBufferUsage:a="static",alignment:o=0n,key:l=vi()}=e,{data:u}=e;if(u instanceof Ie||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=Ti(u),w=Array.isArray(u);if(r!=null)this.dataType=new $(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=$.STRING;else if(typeof h=="number")this.dataType=$.FLOAT64;else if(typeof h=="bigint")this.dataType=$.INT64;else if(typeof h=="boolean")this.dataType=$.BOOLEAN;else if(h instanceof F||h instanceof Date||h instanceof F)this.dataType=$.TIMESTAMP;else if(typeof h=="object")this.dataType=$.JSON;else throw new Error(`cannot infer data type of ${typeof h} when constructing a Series from a JS array`)}else this.dataType=new $(u)}if(!w&&!f)this._data=u;else{let h=f?[u]:u;const M=h[0];(M instanceof F||M instanceof Date||M instanceof W)&&(h=h.map(_=>new F(_).valueOf())),this.dataType.equals($.STRING)?(this._cachedLength=h.length,this._data=new TextEncoder().encode(h.join(`
4
+ `)+`
5
+ `)):this.dataType.equals($.JSON)?(this._cachedLength=h.length,this._data=new TextEncoder().encode(h.map(_=>JSON.stringify(_)).join(`
6
+ `)+`
7
+ `)):this._data=new this.dataType.Array(h).buffer}this.key=l,this.alignment=o,this.sampleOffset=i??0,this._timeRange=n,this.gl={control:null,buffer:null,prevBuffer:0,bufferUsage:a}}static alloc({capacity:e,dataType:r,...n}){if(e===0)throw new Error("[Series] - cannot allocate an array of length 0");const i=new new $(r).Array(e),a=new Ie({data:i.buffer,dataType:r,...n});return a.writePos=0,a}static generateTimestamps(e,r,n){const i=n.spanRange(r.span(e)),a=new BigInt64Array(e);for(let o=0;o<e;o++)a[o]=BigInt(n.add(r.span(o)).valueOf());return new Ie({data:a,dataType:$.TIMESTAMP,timeRange:i})}get refCount(){return this._refCount}static fromStrings(e,r){const n=new TextEncoder().encode(e.join(`
8
+ `)+`
9
+ `);return new Ie({data:n,dataType:$.STRING,timeRange:r})}static fromJSON(e,r){const n=new TextEncoder().encode(e.map(i=>JSON.stringify(i)).join(`
10
+ `)+`
11
+ `);return new Ie({data:n,dataType:$.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===Ue)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===Ue?this.underlyingData:new this.dataType.Array(this._data,0,this.writePos)}toStrings(){if(!this.dataType.equals($.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($.UUID))throw new Error("cannot convert non-uuid series to uuids");const e=$.UUID.density.valueOf(),r=Array(this.length);for(let n=0;n<this.length;n++){const i=this.buffer.slice(n*e,(n+1)*e),a=Array.from(new Uint8Array(i),o=>o.toString(16).padStart(2,"0")).join("").replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/,"$1-$2-$3-$4-$5");r[n]=a}return r}parseJSON(e){if(!this.dataType.equals($.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.O(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 Dr(this.buffer.byteLength)}get capacity(){return this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===Ue?this.byteCapacity:this.dataType.density.size(this.writePos)}get length(){return this._cachedLength!=null?this._cachedLength:this.dataType.isVariable?this.calculateCachedLength():this.writePos===Ue?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 i=0;i<this.length;i++)n[i]=kc(this.dataType,e,this.data[i],r);return new Ie({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($.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()),it(this._cachedMax,this.sampleOffset))}calcRawMin(){if(this.length===0)return 1/0;if(this.dataType.equals($.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()),it(this._cachedMin,this.sampleOffset))}get bounds(){return O.o(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 it(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 it(n,this.sampleOffset)}atVariable(e,r){e<0&&(e=this.length+e);let n=0,i=0;for(let o=0;o<this.data.length;o++)if(this.data[o]===10){if(e===0){i=o;break}n=o+1,e--}if(i===0&&(i=this.data.length),n>=i||e>0){if(r)throw new Error(`[series] - no value at index ${e}`);return}const a=this.data.slice(n,i);return this.dataType.equals($.STRING)?new TextDecoder().decode(a):O.O(JSON.parse(new TextDecoder().decode(a)))}binarySearch(e){let r=0,n=this.length-1;const i=Mr(e);for(;r<=n;){const a=Math.floor((r+n)/2),o=i(this.at(a,!0),e);if(o===0)return a;o<0?r=a+1:n=a-1}return r}updateGLBuffer(e){if(this.gl.control=e,!this.dataType.equals($.FLOAT32))throw new Error("Only FLOAT32 arrays can be used in WebGL");const{buffer:r,bufferUsage:n,prevBuffer:i}=this.gl;if(r==null&&(this.gl.buffer=e.createBuffer()),this.writePos!==i)if(e.bindBuffer(e.ARRAY_BUFFER,this.gl.buffer),this.writePos!==Ue){i===0&&e.bufferData(e.ARRAY_BUFFER,this.byteCapacity.valueOf(),e.STATIC_DRAW);const a=this.dataType.density.size(i).valueOf(),o=this.underlyingData.slice(this.gl.prevBuffer,this.writePos);e.bufferSubData(e.ARRAY_BUFFER,a,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=Ue}as(e){if(e==="string"){if(!this.dataType.equals($.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($.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.o(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 Cc(this);return this.dataType.equals($.JSON)?new Rc(e):e}return new jc(this)}slice(e,r){if(e<=0&&(r==null||r>=this.length))return this;const n=this.data.slice(e,r);return new Ie({data:n,dataType:this.dataType,timeRange:this._timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(e)})}reAlign(e){return new Ie({data:this.buffer,dataType:this.dataType,timeRange:Nt.ZERO,sampleOffset:this.sampleOffset,glBufferUsage:"static",alignment:e})}},Cc=class{constructor(e){if(p(this,"series"),p(this,"index"),p(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 bs,vs;let Rc=class{constructor(e){p(this,"wrapped"),p(this,bs,"JSONSeriesIterator"),this.wrapped=e}next(){const e=this.wrapped.next();return e.done===!0?{done:!0,value:void 0}:{done:!1,value:O.O(JSON.parse(e.value))}}[(vs=Symbol.iterator,bs=Symbol.toStringTag,vs)](){return this}};var Os,Ts;class jc{constructor(e){p(this,"series"),p(this,"index"),p(this,Os,"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)}}[(Ts=Symbol.iterator,Os=Symbol.toStringTag,Ts)](){return this}}const it=(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 $c=class{constructor(e){if(p(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 $(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?$.UNKNOWN:this.series[0].dataType}get timeRange(){return this.series.length===0?Nt.ZERO:new Nt(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 Dr(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 Mc(this.series)}};var Ss,zs;class Mc{constructor(e){p(this,"series"),p(this,"seriesIndex"),p(this,"internal"),p(this,Ss,"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())}[(zs=Symbol.iterator,Ss=Symbol.toStringTag,zs)](){return this}}s.z.record(s.z.union([s.z.number(),s.z.string(),s.z.symbol()]),s.z.unknown());const zi=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser",Dc=zi(),Ni=["MacOS","Windows","Linux","Docker"],Pc=s.z.enum(Ni);let Jr;const Bc=()=>{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"},Uc=(t={})=>{const{force:e,default:r}=t;return e??Jr??(Jr=Bc(),Jr??r)},Ei=Object.freeze(Object.defineProperty({__proto__:null,OPERATING_SYSTEMS:Ni,RUNTIME:Dc,detect:zi,getOS:Uc,osZ:Pc},Symbol.toStringTag,{value:"Module"})),Lc=t=>Array.isArray(t)?t:[t],Yc=t=>Array.isArray(t)?t:t===null?[]:[t],qc=t=>[...new Set(t)];var Fc=Object.defineProperty,_c=(t,e,r)=>e in t?Fc(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,at=(t,e,r)=>_c(t,typeof e!="symbol"?e+"":e,r);const Wc=(...t)=>t.map(Ii).join(""),Ii=t=>(t.endsWith("/")||(t+="/"),t.startsWith("/")&&(t=t.slice(1)),t),Gc=t=>t.endsWith("/")?t.slice(0,-1):t,Ns=class On{constructor({host:e,port:r,protocol:n="",pathPrefix:i=""}){at(this,"protocol"),at(this,"host"),at(this,"port"),at(this,"path"),this.protocol=n,this.host=e,this.port=r,this.path=Ii(i)}replace(e){return new On({host:e.host??this.host,port:e.port??this.port,protocol:e.protocol??this.protocol,pathPrefix:e.pathPrefix??this.path})}child(e){return new On({...this,pathPrefix:Wc(this.path,e)})}toString(){return Gc(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}};at(Ns,"UNKNOWN",new Ns({host:"unknown",port:0}));var Zc=Object.defineProperty,Vc=(t,e,r)=>e in t?Zc(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,zr=(t,e,r)=>Vc(t,typeof e!="symbol"?e+"":e,r);let Jc=class{constructor(e){zr(this,"sender"),zr(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=Kc(e,this.sender),n=new Hc(r);return this.handlers.set(e,n),n}};const Kc=(t,e)=>(r,n)=>e({type:t,payload:r},n);let Hc=class{constructor(e){zr(this,"_send"),zr(this,"handler"),this._send=e,this.handler=null}send(e,r=[]){this._send(e,r)}handle(e){this.handler=e}};var Xc=Object.defineProperty,Qc=(t,e,r)=>e in t?Xc(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Qt=(t,e,r)=>Qc(t,typeof e!="symbol"?e+"":e,r);const Ye=class extends Number{};Qt(Ye,"Absolute",255),Qt(Ye,"Default",1),Qt(Ye,"z",s.z.union([s.z.instanceof(Ye),s.z.number().int().min(0).max(255).transform(t=>new Ye(t)),s.z.instanceof(Number).transform(t=>new Ye(t))]));let Ai=Ye;const ki=s.z.object({name:s.z.string(),key:s.z.string()}),el=t=>s.z.object({subject:ki,resource:t,authority:Ai.z}),tl=(...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}),rl=Object.freeze(Object.defineProperty({__proto__:null,Authority:Ai,filterTransfersByChannelKey:tl,stateZ:el,subjectZ:ki},Symbol.toStringTag,{value:"Module"})),xi=class ot extends Error{constructor(){super(ot.MESSAGE)}matches(e){return typeof e=="string"?e.includes(ot.MESSAGE):e instanceof ot||e.message.includes(ot.MESSAGE)}};Qt(xi,"MESSAGE","canceled");let nl=xi;new nl;const sl=t=>t?-1:1;s.z.string().regex(/^\d+\.\d+\.\d+$/);const il=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()},al=t=>Array.isArray(t)?[...t]:typeof t=="object"&&t!==null?{...t}:t,Wn=t=>typeof t=="function",Gn=(t,e)=>Wn(t)?t(e):t,jt=t=>Ci(t)?t():t,Ci=t=>typeof t=="function",Ri=({initial:t,value:e,onChange:r})=>{const[n,i]=Fn.useState(jt(e??t));return e!=null&&r!=null?[e,r]:[n,i]},ji=({initial:t,value:e,onChange:r})=>{const[n,i]=Fn.useState(jt(e??t));return e!=null&&r!=null?[e,r]:[n,i]},ol=(t,e)=>{const[r,n]=Fn.useState(()=>{const i=localStorage.getItem(e);return i==null?jt(t):JSON.parse(i)});return[r,i=>{n(i),localStorage.setItem(e,JSON.stringify(i))}]},cl=Object.freeze(Object.defineProperty({__proto__:null,executeInitialSetter:jt,executeSetter:Gn,isInitialSetter:Ci,isSetter:Wn,usePassthrough:Ri,usePersisted:ol,usePurePassthrough:ji},Symbol.toStringTag,{value:"Module"})),$i=["h1","h2","h3","h4","h5","p","small"],ll=s.z.enum($i),Me=s.z.object({size:s.z.number(),weight:s.z.union([s.z.number(),s.z.string()]),lineHeight:s.z.number(),textTransform:s.z.string().optional()}),Mi={small:"small",medium:"p",large:"h5",huge:"h2"},ul={h1:"huge",h2:"huge",h3:"huge",h4:"large",h5:"small",p:"medium",small:"small"};let Kr=null;const hl=()=>(Kr==null&&(Kr=document.createElement("canvas")),Kr),fl=(t,e,r)=>{if(Ei.RUNTIME==="node")return{width:0,height:0};r==null&&(r=hl().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))}},dl=s.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}),de=(t,e)=>[t[0],t[1],e,t[3]],yl=s.z.object({m2:O.Color.z,m1:O.Color.z,z:O.Color.z,p1:O.Color.z,p2:O.Color.z}),qt=yl.or(O.Color.z.transform(t=>{const e=t.hsla;return{m2:new O.Color(O.fromHSLA(de(e,40))),m1:new O.Color(O.fromHSLA(de(e,45))),z:t,p1:new O.Color(O.fromHSLA(de(e,55))),p2:new O.Color(O.fromHSLA(de(e,65)))}})),Di=s.z.object({name:s.z.string(),key:s.z.string(),colors:s.z.object({border:O.Color.z,primary:qt,gray:dl,error:qt,secondary:qt,warning:qt,visualization:s.z.object({palettes:s.z.record(s.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:s.z.string()}),sizes:s.z.object({base:s.z.number(),border:s.z.object({radius:s.z.number(),width:s.z.number()}),schematic:s.z.object({elementStrokeWidth:s.z.number()})}),typography:s.z.object({family:s.z.string(),h1:Me,h2:Me,h3:Me,h4:Me,h5:Me,p:Me,small:Me})}).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)),gl="'Inter Variable', sans-serif",pl=6,et=[357,91,55,1],tt=[42,100,50,1],ml=["#FCFCFC","#F9F9F9","#F4F4F4","#ededed","#d9d9d9","#ADADAD","#878787","#616161","#404040","#1C1C1C","#050505"],Ft=Object.fromEntries(ml.map((t,e)=>[`l${e}`,t])),Tn={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:Ft,border:Ft.l3,error:{m2:O.fromHSLA(de(et,30)),m1:O.fromHSLA(de(et,40)),z:O.fromHSLA(et),p1:O.fromHSLA(de(et,60)),p2:O.fromHSLA(de(et,70))},warning:{m2:O.fromHSLA(de(tt,30)),m1:O.fromHSLA(de(tt,40)),z:O.fromHSLA(tt),p1:O.fromHSLA(de(tt,60)),p2:O.fromHSLA(de(tt,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:Ft.l9,textInverted:Ft.l0},sizes:{base:pl,border:{radius:2,width:1},schematic:{elementStrokeWidth:2}},typography:{family:gl,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}}},Pi=Object.freeze({...Tn,key:"synnaxLight",name:"Synnax Light"}),wl=["#020202","#080808","#141414","#1a1a1a","#242424","#515151","#7f7f7f","#9D9D9D","#BFBFBF","#EDEDED","#FDFDFD"],_t=Object.fromEntries(wl.map((t,e)=>[`l${e}`,t])),Bi=Object.freeze({...Tn,key:"synnaxDark",name:"Synnax Dark",colors:{...Tn.colors,gray:_t,logo:"var(--pluto-text-color)",border:_t.l3,text:_t.l9,textInverted:_t.l0}}),bl={synnaxDark:Bi,synnaxLight:Pi},vl=["small","medium","large","huge"],Ol=s.z.enum(vl),Tl=t=>Ol.safeParse(t).success,Sl=(t,e,r)=>{const{typography:n,sizes:{base:i}}=t,a=n[Tl(e)?Mi[e]:e].size,o=i*a,[l,u]=n.family.split(", ");return r!=null?` ${r} ${o}px ${l}, ${u}`:` ${o}px ${n.family}`};var zl=Object.defineProperty,Nl=(t,e,r)=>e in t?zl(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,c=(t,e,r)=>Nl(t,typeof e!="symbol"?e+"":e,r),El=Object.defineProperty,Il=(t,e,r)=>e in t?El(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,j=(t,e,r)=>Il(t,typeof e!="symbol"?e+"":e,r);const Al=t=>{const e=t.replace(/_[a-z]/g,r=>r[1].toUpperCase());return e.length>1&&e[0]===e[0].toUpperCase()&&e[1]===e[1].toUpperCase()?e:e[0].toLowerCase()+e.slice(1)},Ui=t=>{const e=(r,n=Sn)=>{if(typeof r=="string")return t(r);if(Array.isArray(r))return r.map(a=>e(a,n));if(!Hr(r))return null;n=Rl(n);const i={};return Object.keys(r).forEach(a=>{let o=r[a];const l=t(a);n.recursive&&(Hr(o)?Is(o,n.keepTypesOnRecursion)||(o=e(o,n)):n.recursiveInArray&&Es(o)&&(o=[...o].map(u=>{let f=u;return Hr(u)?Is(f,n.keepTypesOnRecursion)||(f=e(u,n)):Es(u)&&(f=e({key:u},n).key),f}))),i[l]=o}),i};return e},kl=Ui(Al),xl=t=>t.replace(/([a-z0-9])([A-Z])/g,(e,r,n)=>`${r}_${n.toLowerCase()}`),Cl=Ui(xl),Sn={recursive:!0,recursiveInArray:!0,keepTypesOnRecursion:[Number,String,Uint8Array]},Rl=(t=Sn)=>(t.recursive==null?t=Sn:t.recursiveInArray==null&&(t.recursiveInArray=!1),t),Es=t=>t!=null&&Array.isArray(t),Hr=t=>t!=null&&typeof t=="object"&&!Array.isArray(t),Is=(t,e)=>(e||[]).some(r=>t instanceof r),Li=t=>t!=null&&typeof t=="object"&&!Array.isArray(t);var jl=Object.defineProperty,$l=(t,e,r)=>e in t?jl(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,vt=(t,e,r)=>$l(t,typeof e!="symbol"?e+"":e,r);let Ml=class{constructor(){vt(this,"contentType","application/json"),vt(this,"decoder"),vt(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=JSON.parse(t),n=kl(r);return e!=null?e.parse(n):n}encodeString(t){const e=Cl(t);return JSON.stringify(e,(r,n)=>ArrayBuffer.isView(n)?Array.from(n):Li(n)&&"encode_value"in n?typeof n.value=="bigint"?n.value.toString():n.value:typeof n=="bigint"?n.toString():n)}static registerCustomType(){}},Dl=class{constructor(){vt(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||!Li(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 i=e.map(a=>JSON.stringify(n[a]??""));r.push(i.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 i=r.split(",").map(o=>o.trim()),a={};return i.forEach(o=>{a[o]=[]}),n.forEach(o=>{const l=o.split(",").map(u=>u.trim());i.forEach((u,f)=>{const w=this.parseValue(l[f]);w!=null&&a[u].push(w)})}),e!=null?e.parse(a):a}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(){}},Pl=class{constructor(){vt(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 Ml;new Dl;new Pl;const Pr=s.z.tuple([s.z.number(),s.z.number()]);s.z.tuple([s.z.bigint(),s.z.bigint()]);const Yi=s.z.object({width:s.z.number(),height:s.z.number()}),Bl=s.z.object({signedWidth:s.z.number(),signedHeight:s.z.number()}),Ul=["width","height"];s.z.enum(Ul);const Ll=["start","center","end"],Yl=["signedWidth","signedHeight"];s.z.enum(Yl);const Nr=s.z.object({x:s.z.number(),y:s.z.number()}),ql=s.z.object({clientX:s.z.number(),clientY:s.z.number()}),Fl=["x","y"],qi=s.z.enum(Fl),Fi=["top","right","bottom","left"];s.z.enum(Fi);const _l=["left","right"],_i=s.z.enum(_l),Wl=["top","bottom"],Wi=s.z.enum(Wl),Gi=["center"],As=s.z.enum(Gi),Gl=[...Fi,...Gi],Zi=s.z.enum(Gl);s.z.enum(Ll);const Zl=["first","last"];s.z.enum(Zl);const Vl=s.z.object({lower:s.z.number(),upper:s.z.number()}),Jl=s.z.object({lower:s.z.bigint(),upper:s.z.bigint()});s.z.union([Vl,Pr]);s.z.union([Jl,Pr]);s.z.union([qi,Zi]);s.z.union([qi,Zi,s.z.instanceof(String)]);const Xr=(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 ks(t);return ks(r)},ks=t=>t.lower>t.upper?{lower:t.upper,upper:t.lower}:t;s.z.object({x:_i.or(As),y:Wi.or(As)});const Kl=s.z.object({x:_i,y:Wi}),Hl=Object.freeze({x:"left",y:"top"}),Xl=(t,e)=>t.x===e.x&&t.y===e.y,xs=s.z.union([s.z.number(),Nr,Pr,Yi,Bl,ql]),Ql=(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}},Cs=Object.freeze({x:0,y:0}),Wt=s.z.union([s.z.number(),s.z.string()]);s.z.object({top:Wt,left:Wt,width:Wt,height:Wt});s.z.object({left:s.z.number(),top:s.z.number(),right:s.z.number(),bottom:s.z.number()});s.z.object({one:Nr,two:Nr,root:Kl});const Zn=(t,e,r=0,n=0,i)=>{const a={one:{...Cs},two:{...Cs},root:i??Hl};if(typeof t=="number"){if(typeof e!="number")throw new Error("Box constructor called with invalid arguments");return a.one={x:t,y:e},a.two={x:a.one.x+r,y:a.one.y+n},a}return"one"in t&&"two"in t&&"root"in t?{...t,root:i??t.root}:("getBoundingClientRect"in t&&(t=t.getBoundingClientRect()),"left"in t?(a.one={x:t.left,y:t.top},a.two={x:t.right,y:t.bottom},a):(a.one=t,e==null?a.two={x:a.one.x+r,y:a.one.y+n}:typeof e=="number"?a.two={x:a.one.x+e,y:a.one.y+r}:"width"in e?a.two={x:a.one.x+e.width,y:a.one.y+e.height}:"signedWidth"in e?a.two={x:a.one.x+e.signedWidth,y:a.one.y+e.signedHeight}:a.two=e,a))},Qr=t=>{const e=Zn(t);return{lower:e.one.x,upper:e.two.x}},en=t=>{const e=Zn(t);return{lower:e.one.y,upper:e.two.y}},eu=t=>typeof t!="object"||t==null?!1:"one"in t&&"two"in t&&"root"in t;var tu=Object.defineProperty,ru=(t,e,r)=>e in t?tu(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ce=(t,e,r)=>ru(t,typeof e!="symbol"?e+"":e,r);const nu=(t,e,r)=>e!==void 0&&t<e?e:r!==void 0&&t>r?r:t;s.z.object({offset:xs,scale:xs});const su=t=>(e,r,n,i)=>r==="dimension"?[e,n]:[e,i?n-t:n+t],iu=t=>(e,r,n,i)=>[e,i?n/t:n*t],au=t=>(e,r,n)=>{if(e===null)return[t,n];const{lower:i,upper:a}=e,{lower:o,upper:l}=t,u=a-i,f=l-o;if(r==="dimension")return[t,n*(f/u)];const w=(n-i)*(f/u)+o;return[t,w]},ou=t=>(e,r,n)=>[t,n],cu=()=>(t,e,r)=>{if(t===null)throw new Error("cannot invert without bounds");if(e==="dimension")return[t,r];const{lower:n,upper:i}=t;return[t,i-(r-n)]},lu=t=>(e,r,n)=>{const{lower:i,upper:a}=t;return n=nu(n,i,a),[e,n]},zn=class ct{constructor(){Ce(this,"ops",[]),Ce(this,"currBounds",null),Ce(this,"currType",null),Ce(this,"reversed",!1),this.ops=[]}static translate(e){return new ct().translate(e)}static magnify(e){return new ct().magnify(e)}static scale(e,r){return new ct().scale(e,r)}translate(e){const r=this.new(),n=su(e);return n.type="translate",r.ops.push(n),r}magnify(e){const r=this.new(),n=iu(e);return n.type="magnify",r.ops.push(n),r}scale(e,r){const n=Xr(e,r),i=this.new(),a=au(n);return a.type="scale",i.ops.push(a),i}clamp(e,r){const n=Xr(e,r),i=this.new(),a=lu(n);return a.type="clamp",i.ops.push(a),i}reBound(e,r){const n=Xr(e,r),i=this.new(),a=ou(n);return a.type="re-bound",i.ops.push(a),i}invert(){const e=cu();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 ct;return e.ops=this.ops.slice(),e.reversed=this.reversed,e}exec(e,r){return this.currBounds=null,this.ops.reduce(([n,i],a)=>a(n,e,i,this.reversed),[null,r])[1]}reverse(){const e=this.new();e.ops.reverse();const r=[];return e.ops.forEach((n,i)=>{if(n.type==="scale"||r.some(([o,l])=>i>=o&&i<=l))return;const a=e.ops.findIndex((o,l)=>o.type==="scale"&&l>i);a!==-1&&r.push([i,a])}),r.forEach(([n,i])=>{const a=e.ops.slice(n,i);a.unshift(e.ops[i]),e.ops.splice(n,i-n+1,...a)}),e.reversed=!e.reversed,e}};Ce(zn,"IDENTITY",new zn);let Rs=zn;const js=class Ae{constructor(e=new Rs,r=new Rs,n=null){Ce(this,"x"),Ce(this,"y"),Ce(this,"currRoot"),this.x=e,this.y=r,this.currRoot=n}static translate(e,r){return new Ae().translate(e,r)}static translateX(e){return new Ae().translateX(e)}static translateY(e){return new Ae().translateY(e)}static clamp(e){return new Ae().clamp(e)}static magnify(e){return new Ae().magnify(e)}static scale(e){return new Ae().scale(e)}static reBound(e){return new Ae().reBound(e)}translate(e,r){const n=Ql(e,r),i=this.copy();return i.x=this.x.translate(n.x),i.y=this.y.translate(n.y),i}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(eu(e)){const n=this.currRoot;return r.currRoot=e.root,n!=null&&!Xl(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(Qr(e)),r.y=r.y.scale(en(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(Qr(e)),r.y=this.y.reBound(en(e)),r}clamp(e){const r=this.copy();return r.x=this.x.clamp(Qr(e)),r.y=this.y.clamp(en(e)),r}copy(){const e=new Ae;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 Zn(this.pos(e.one),this.pos(e.two),0,0,this.currRoot??e.root)}};Ce(js,"IDENTITY",new js);const uu=s.z.object({signedWidth:s.z.number(),signedHeight:s.z.number()});s.z.union([Yi,uu,Nr,Pr]);var hu=Object.defineProperty,fu=(t,e,r)=>e in t?hu(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,b=(t,e,r)=>fu(t,typeof e!="symbol"?e+"":e,r);const Vi=(t,e)=>{const r=new ee(e);if(![te.DAY,te.HOUR,te.MINUTE,te.SECOND,te.MILLISECOND,te.MICROSECOND,te.NANOSECOND].some(i=>i.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 ee?new ee(n):new te(n)},U=class S{constructor(e,r="UTC"){if(b(this,"value"),b(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 i=new Date(e,r-1,n,0,0,0,0);return new S(BigInt(i.getTime())*S.MILLISECOND.valueOf()).truncate(S.DAY).valueOf()}encode(){return this.value.toString()}valueOf(){return this.value}static parseTimeString(e,r="UTC"){const[n,i,a]=e.split(":");let o="00",l="00";a!=null&&([o,l]=a.split("."));let u=S.hours(parseInt(n??"00",10)).add(S.minutes(parseInt(i??"00",10))).add(S.seconds(parseInt(o??"00",10))).add(S.milliseconds(parseInt(l??"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 te(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 du(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 Vi(this,e)}get isToday(){return this.truncate(te.DAY).equals(S.now().truncate(te.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 i=new S(n);i.after(r)&&(r=i)}return r}static min(...e){let r=S.MAX;for(const n of e){const i=new S(n);i.before(r)&&(r=i)}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)}};b(U,"NANOSECOND",U.nanoseconds(1)),b(U,"MICROSECOND",U.microseconds(1)),b(U,"MILLISECOND",U.milliseconds(1)),b(U,"SECOND",U.seconds(1)),b(U,"MINUTE",U.minutes(1)),b(U,"HOUR",U.hours(1)),b(U,"DAY",U.days(1)),b(U,"MAX",new U((1n<<63n)-1n)),b(U,"MIN",new U(0)),b(U,"ZERO",new U(0)),b(U,"z",s.z.union([s.z.object({value:s.z.bigint()}).transform(t=>new U(t.value)),s.z.string().transform(t=>new U(BigInt(t))),s.z.instanceof(Number).transform(t=>new U(t)),s.z.number().transform(t=>new U(t)),s.z.instanceof(U)]));let ee=U;const L=class x{constructor(e){b(this,"value"),b(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 x(e).valueOf()}greaterThan(e){return this.valueOf()>new x(e).valueOf()}lessThanOrEqual(e){return this.valueOf()<=new x(e).valueOf()}greaterThanOrEqual(e){return this.valueOf()>=new x(e).valueOf()}remainder(e){return Vi(this,e)}truncate(e){return new x(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(){const e=this.truncate(x.DAY),r=this.truncate(x.HOUR),n=this.truncate(x.MINUTE),i=this.truncate(x.SECOND),a=this.truncate(x.MILLISECOND),o=this.truncate(x.MICROSECOND),l=this.truncate(x.NANOSECOND),u=e,f=r.sub(e),w=n.sub(r),h=i.sub(n),M=a.sub(i),_=o.sub(a),re=l.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 `),M.isZero||(R+=`${M.milliseconds}ms `),_.isZero||(R+=`${_.microseconds}µs `),re.isZero||(R+=`${re.nanoseconds}ns`),R.trim()}get days(){return Number(this.valueOf())/Number(x.DAY.valueOf())}get hours(){return Number(this.valueOf())/Number(x.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(x.MINUTE.valueOf())}get seconds(){return Number(this.valueOf())/Number(x.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(x.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(x.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===BigInt(0)}equals(e){return this.valueOf()===new x(e).valueOf()}add(e){return new x(this.valueOf()+new x(e).valueOf())}sub(e){return new x(this.valueOf()-new x(e).valueOf())}static nanoseconds(e=1){return new x(e)}static microseconds(e=1){return x.nanoseconds(e*1e3)}static milliseconds(e=1){return x.microseconds(e*1e3)}static seconds(e=1){return x.milliseconds(e*1e3)}static minutes(e){return x.seconds(e.valueOf()*60)}static hours(e){return x.minutes(e*60)}static days(e){return x.hours(e*24)}};b(L,"NANOSECOND",L.nanoseconds(1)),b(L,"MICROSECOND",L.microseconds(1)),b(L,"MILLISECOND",L.milliseconds(1)),b(L,"SECOND",L.seconds(1)),b(L,"MINUTE",L.minutes(1)),b(L,"HOUR",L.hours(1)),b(L,"DAY",L.days(1)),b(L,"MAX",new L((1n<<63n)-1n)),b(L,"MIN",new L(0)),b(L,"ZERO",new L(0)),b(L,"z",s.z.union([s.z.object({value:s.z.bigint()}).transform(t=>new L(t.value)),s.z.string().transform(t=>new L(BigInt(t))),s.z.instanceof(Number).transform(t=>new L(t)),s.z.number().transform(t=>new L(t)),s.z.instanceof(L)]));let te=L;const Gt=class er extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new er(e).valueOf()}get period(){return te.seconds(1/this.valueOf())}sampleCount(e){return new te(e).seconds*this.valueOf()}byteCount(e,r){return this.sampleCount(e)*new le(r).valueOf()}span(e){return te.seconds(e/this.valueOf())}byteSpan(e,r){return this.span(e.valueOf()/r.valueOf())}static hz(e){return new er(e)}static khz(e){return er.hz(e*1e3)}};b(Gt,"z",s.z.union([s.z.number().transform(t=>new Gt(t)),s.z.instanceof(Number).transform(t=>new Gt(t)),s.z.instanceof(Gt)]));const X=class extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}length(e){return e.valueOf()/this.valueOf()}size(e){return new yu(e*this.valueOf())}};b(X,"UNKNOWN",new X(0)),b(X,"BIT128",new X(16)),b(X,"BIT64",new X(8)),b(X,"BIT32",new X(4)),b(X,"BIT16",new X(2)),b(X,"BIT8",new X(1)),b(X,"z",s.z.union([s.z.number().transform(t=>new X(t)),s.z.instanceof(Number).transform(t=>new X(t)),s.z.instanceof(X)]));let le=X;const Oe=class tr{constructor(e,r){b(this,"start"),b(this,"end"),typeof e=="object"&&"start"in e?(this.start=new ee(e.start),this.end=new ee(e.end)):(this.start=new ee(e),this.end=new ee(r))}get span(){return new te(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 tr(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=te.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 i=ee.max(n.start,e.start),a=ee.min(n.end,e.end);return a.before(i)?!1:new te(a.sub(i)).greaterThanOrEqual(r)}roughlyEquals(e,r){let n=this.start.sub(e.start).valueOf(),i=this.end.sub(e.end).valueOf();return n<0&&(n=-n),i<0&&(i=-i),n<=r.valueOf()&&i<=r.valueOf()}contains(e){return e instanceof tr?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const r=new tr(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}};b(Oe,"MAX",new Oe(ee.MIN,ee.MAX)),b(Oe,"MIN",new Oe(ee.MAX,ee.MIN)),b(Oe,"ZERO",new Oe(ee.ZERO,ee.ZERO)),b(Oe,"z",s.z.union([s.z.object({start:ee.z,end:ee.z}).transform(t=>new Oe(t.start,t.end)),s.z.instanceof(Oe)]));let du=Oe;const g=class Te extends String{constructor(e){if(e instanceof Te||typeof e=="string"||typeof e.valueOf()=="string"){super(e.valueOf());return}else{const r=Te.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(r!=null){super(r.valueOf());return}}throw super(Te.UNKNOWN.valueOf()),new Error(`unable to find data type for ${e.toString()}`)}get Array(){const e=Te.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(Te.JSON)||this.equals(Te.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(Te.UUID)}get isInteger(){return this.toString().startsWith("int")}get isFloat(){return this.toString().startsWith("float")}get density(){const e=Te.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 Te.BIG_INT_TYPES.some(e=>e.equals(this))}};b(g,"UNKNOWN",new g("unknown")),b(g,"FLOAT64",new g("float64")),b(g,"FLOAT32",new g("float32")),b(g,"INT64",new g("int64")),b(g,"INT32",new g("int32")),b(g,"INT16",new g("int16")),b(g,"INT8",new g("int8")),b(g,"UINT64",new g("uint64")),b(g,"UINT32",new g("uint32")),b(g,"UINT16",new g("uint16")),b(g,"UINT8",new g("uint8")),b(g,"BOOLEAN",g.UINT8),b(g,"TIMESTAMP",new g("timestamp")),b(g,"UUID",new g("uuid")),b(g,"STRING",new g("string")),b(g,"JSON",new g("json")),b(g,"ARRAY_CONSTRUCTORS",new Map([[g.UINT8.toString(),Uint8Array],[g.UINT16.toString(),Uint16Array],[g.UINT32.toString(),Uint32Array],[g.UINT64.toString(),BigUint64Array],[g.FLOAT32.toString(),Float32Array],[g.FLOAT64.toString(),Float64Array],[g.INT8.toString(),Int8Array],[g.INT16.toString(),Int16Array],[g.INT32.toString(),Int32Array],[g.INT64.toString(),BigInt64Array],[g.TIMESTAMP.toString(),BigInt64Array],[g.STRING.toString(),Uint8Array],[g.JSON.toString(),Uint8Array],[g.UUID.toString(),Uint8Array]])),b(g,"ARRAY_CONSTRUCTOR_DATA_TYPES",new Map([[Uint8Array.name,g.UINT8],[Uint16Array.name,g.UINT16],[Uint32Array.name,g.UINT32],[BigUint64Array.name,g.UINT64],[Float32Array.name,g.FLOAT32],[Float64Array.name,g.FLOAT64],[Int8Array.name,g.INT8],[Int16Array.name,g.INT16],[Int32Array.name,g.INT32],[BigInt64Array.name,g.INT64]])),b(g,"DENSITIES",new Map([[g.UINT8.toString(),le.BIT8],[g.UINT16.toString(),le.BIT16],[g.UINT32.toString(),le.BIT32],[g.UINT64.toString(),le.BIT64],[g.FLOAT32.toString(),le.BIT32],[g.FLOAT64.toString(),le.BIT64],[g.INT8.toString(),le.BIT8],[g.INT16.toString(),le.BIT16],[g.INT32.toString(),le.BIT32],[g.INT64.toString(),le.BIT64],[g.TIMESTAMP.toString(),le.BIT64],[g.STRING.toString(),le.UNKNOWN],[g.JSON.toString(),le.UNKNOWN],[g.UUID.toString(),le.BIT128]])),b(g,"ALL",[g.UNKNOWN,g.FLOAT64,g.FLOAT32,g.INT64,g.INT32,g.INT16,g.INT8,g.UINT64,g.UINT32,g.UINT16,g.UINT8,g.TIMESTAMP,g.UUID,g.STRING,g.JSON]),b(g,"BIG_INT_TYPES",[g.INT64,g.UINT64,g.TIMESTAMP]),b(g,"z",s.z.union([s.z.string().transform(t=>new g(t)),s.z.instanceof(g)]));const se=class V extends Number{constructor(e){super(e.valueOf())}largerThan(e){return this.valueOf()>e.valueOf()}smallerThan(e){return this.valueOf()<e.valueOf()}add(e){return V.bytes(this.valueOf()+e.valueOf())}sub(e){return V.bytes(this.valueOf()-e.valueOf())}truncate(e){return new V(Math.trunc(this.valueOf()/e.valueOf())*e.valueOf())}remainder(e){return V.bytes(this.valueOf()%e.valueOf())}get gigabytes(){return this.valueOf()/V.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/V.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/V.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/V.TERABYTE.valueOf()}toString(){const e=this.truncate(V.TERABYTE),r=this.truncate(V.GIGABYTE),n=this.truncate(V.MEGABYTE),i=this.truncate(V.KILOBYTE),a=this.truncate(V.BYTE),o=e,l=r.sub(e),u=n.sub(r),f=i.sub(n),w=a.sub(i);let h="";return o.isZero||(h+=`${o.terabytes}TB `),l.isZero||(h+=`${l.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 V(e)}static kilobytes(e=1){return V.bytes(e.valueOf()*1e3)}static megabytes(e=1){return V.kilobytes(e.valueOf()*1e3)}static gigabytes(e=1){return V.megabytes(e.valueOf()*1e3)}static terabytes(e){return V.gigabytes(e.valueOf()*1e3)}get isZero(){return this.valueOf()===0}};b(se,"BYTE",new se(1)),b(se,"KILOBYTE",se.kilobytes(1)),b(se,"MEGABYTE",se.megabytes(1)),b(se,"GIGABYTE",se.gigabytes(1)),b(se,"TERABYTE",se.terabytes(1)),b(se,"ZERO",new se(0)),b(se,"z",s.z.union([s.z.number().transform(t=>new se(t)),s.z.instanceof(se)]));let yu=se;s.z.union([s.z.instanceof(Uint8Array),s.z.instanceof(Uint16Array),s.z.instanceof(Uint32Array),s.z.instanceof(BigUint64Array),s.z.instanceof(Float32Array),s.z.instanceof(Float64Array),s.z.instanceof(Int8Array),s.z.instanceof(Int16Array),s.z.instanceof(Int32Array),s.z.instanceof(BigInt64Array)]);s.z.record(s.z.union([s.z.number(),s.z.string(),s.z.symbol()]),s.z.unknown());const Ji=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser",gu=Ji(),Ki=["MacOS","Windows","Linux","Docker"],pu=s.z.enum(Ki);let tn;const mu=()=>{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"},wu=(t={})=>{const{force:e,default:r}=t;return e??tn??(tn=mu(),tn??r)},Hi=Object.freeze(Object.defineProperty({__proto__:null,OPERATING_SYSTEMS:Ki,RUNTIME:gu,detect:Ji,getOS:wu,osZ:pu},Symbol.toStringTag,{value:"Module"}));var bu=Object.defineProperty,vu=(t,e,r)=>e in t?bu(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,lt=(t,e,r)=>vu(t,typeof e!="symbol"?e+"":e,r);const Ou=(...t)=>t.map(Xi).join(""),Xi=t=>(t.endsWith("/")||(t+="/"),t.startsWith("/")&&(t=t.slice(1)),t),Tu=t=>t.endsWith("/")?t.slice(0,-1):t,Su=(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("&"),Nn=class En{constructor({host:e,port:r,protocol:n="",pathPrefix:i=""}){lt(this,"protocol"),lt(this,"host"),lt(this,"port"),lt(this,"path"),this.protocol=n,this.host=e,this.port=r,this.path=Xi(i)}replace(e){return new En({host:e.host??this.host,port:e.port??this.port,protocol:e.protocol??this.protocol,pathPrefix:e.pathPrefix??this.path})}child(e){return new En({...this,pathPrefix:Ou(this.path,e)})}toString(){return Tu(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}};lt(Nn,"UNKNOWN",new Nn({host:"unknown",port:0}));let zu=Nn;var Nu=Object.defineProperty,Eu=(t,e,r)=>e in t?Nu(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,rr=(t,e,r)=>Eu(t,typeof e!="symbol"?e+"":e,r);const Ze=class extends Number{};rr(Ze,"Absolute",255),rr(Ze,"Default",1),rr(Ze,"z",s.z.union([s.z.instanceof(Ze),s.z.number().int().min(0).max(255).transform(t=>new Ze(t)),s.z.instanceof(Number).transform(t=>new Ze(t))]));s.z.object({name:s.z.string(),key:s.z.string()});const Qi=class ut extends Error{constructor(){super(ut.MESSAGE)}matches(e){return typeof e=="string"?e.includes(ut.MESSAGE):e instanceof ut||e.message.includes(ut.MESSAGE)}};rr(Qi,"MESSAGE","canceled");let Iu=Qi;new Iu;s.z.string().regex(/^\d+\.\d+\.\d+$/);const he=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 we=class extends Error{constructor(e){super(e),j(this,"discriminator","FreighterError"),j(this,"type","")}};const Au=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},$s="unknown",Ms="nil",ku="freighter",$t=s.z.object({type:s.z.string(),data:s.z.string()});class xu{constructor(){j(this,"providers",[])}register(e){this.providers.push(e)}encode(e){if(e==null)return{type:Ms,data:""};if(Au(e))for(const r of this.providers){const n=r.encode(e);if(n!=null)return n}return{type:$s,data:JSON.stringify(e)}}decode(e){if(e==null||e.type===Ms)return null;if(e.type===$s)return new Ds(e.data);for(const r of this.providers){const n=r.decode(e);if(n!=null)return n}return new Ds(e.data)}}const ea=new xu,ta=({encode:t,decode:e})=>ea.register({encode:t,decode:e}),Vn=t=>ea.decode(t);class Ds extends we{constructor(e){super(e),j(this,"type","unknown")}}const Br="freighter.",nr=class ra extends we{constructor(){super("EOF"),j(this,"type",ra.TYPE)}};j(nr,"TYPE",Br+"eof"),j(nr,"matches",he(nr.TYPE));let De=nr;const sr=class na extends we{constructor(){super("StreamClosed"),j(this,"type",na.TYPE)}};j(sr,"TYPE",Br+"stream_closed"),j(sr,"matches",he(sr.TYPE));let Je=sr;const ir=class sa extends we{constructor(e={}){const{message:r="Unreachable",url:n=zu.UNKNOWN}=e;super(r),j(this,"type",sa.TYPE),j(this,"url"),this.url=n}};j(ir,"TYPE",Br+"unreachable"),j(ir,"matches",he(ir.TYPE));let We=ir;const Cu=t=>{if(!t.type.startsWith(ku))return null;if(De.matches(t))return{type:De.TYPE,data:"EOF"};if(Je.matches(t))return{type:Je.TYPE,data:"StreamClosed"};if(We.matches(t))return{type:We.TYPE,data:"Unreachable"};throw new Error(`Unknown error type: ${t.type}: ${t.message}`)},Ru=t=>{if(!t.type.startsWith(Br))return null;switch(t.type){case De.TYPE:return new De;case Je.TYPE:return new Je;case We.TYPE:return new We;default:throw new Error(`Unknown error type: ${t.data}`)}};ta({encode:Cu,decode:Ru});class ia{constructor(){j(this,"middleware",[])}use(...e){this.middleware.push(...e)}async executeMiddleware(e,r){let n=0;const i=async a=>{if(n===this.middleware.length)return await r(a);const o=this.middleware[n];return n++,await o(a,i)};return await i(e)}}const aa="Content-Type",Ps=t=>{if(Hi.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(i,a)=>await e(i,{...a,agent:n})};class ju extends ia{constructor(e,r,n=!1){return super(),j(this,"endpoint"),j(this,"encoder"),j(this,"fetch"),this.endpoint=e.replace({protocol:n?"https":"http"}),this.encoder=r,this.fetch=Ps(this.endpoint.protocol),new Proxy(this,{get:(i,a,o)=>a==="endpoint"?this.endpoint:Reflect.get(i,a,o)})}get headers(){return{[aa]:this.encoder.contentType}}async send(e,r,n,i){r=n==null?void 0:n.parse(r);let a=null;const o=this.endpoint.child(e),l={};l.method="POST",l.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:{}};l.headers={...this.headers,...f.params};let h;try{h=await Ps(f.protocol)(f.target,l)}catch(_){let re=_;return re.message==="Load failed"&&(re=new We({url:o})),[w,re]}const M=await h.arrayBuffer();if(h!=null&&h.ok)return i!=null&&(a=this.encoder.decode(M,i)),[w,null];try{if(h.status!==400)return[w,new Error(h.statusText)];const _=this.encoder.decode(M,$t),re=Vn(_);return[w,re]}catch(_){return[w,new Error(`[freighter] - failed to decode error: ${h.statusText}: ${_.message}`)]}});return[a,u]}}const v=async(t,e,r,n,i)=>{const[a,o]=await t.send(e,r,n,i);if(o!=null)throw o;return a},$u=()=>Hi.RUNTIME!=="node"?t=>new WebSocket(t):t=>new(require("ws")).WebSocket(t,{rejectUnauthorized:!1}),Mu=s.z.object({type:s.z.union([s.z.literal("data"),s.z.literal("close")]),payload:s.z.unknown().optional(),error:s.z.optional($t)});class Du{constructor(e,r,n,i){j(this,"encoder"),j(this,"reqSchema"),j(this,"resSchema"),j(this,"ws"),j(this,"serverClosed"),j(this,"sendClosed"),j(this,"receiveDataQueue",[]),j(this,"receiveCallbacksQueue",[]),this.encoder=r,this.reqSchema=n,this.resSchema=i,this.ws=e,this.sendClosed=!1,this.serverClosed=null,this.listenForMessages()}send(e){if(this.serverClosed!=null)return new De;if(this.sendClosed)throw new Je;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=Vn(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,Mu)),this.ws.onclose=e=>this.addMessage({type:"close",error:{type:Yu(e)?De.TYPE:Je.TYPE,data:""}})}}const Pu="freighterctx",Bu=1e3,Uu=1001,Lu=[Bu,Uu],Yu=t=>Lu.includes(t.code),oa=class ca extends ia{constructor(e,r,n=!1){super(),j(this,"baseUrl"),j(this,"encoder"),this.baseUrl=e.replace({protocol:n?"wss":"ws"}),this.encoder=r}async stream(e,r,n){const i=$u();let a;const[,o]=await this.executeMiddleware({target:e,protocol:"websocket",params:{},role:"client"},async l=>{const u=i(this.buildURL(e,l)),f={...l,params:{}};u.binaryType=ca.MESSAGE_TYPE;const w=await this.wrapSocket(u,r,n);return w instanceof Error?[f,w]:(a=w,[f,null])});if(o!=null)throw o;return a}buildURL(e,r){const n=Su({[aa]:this.encoder.contentType,...r.params},Pu);return this.baseUrl.child(e).toString()+n}async wrapSocket(e,r,n){return await new Promise(i=>{e.onopen=()=>{i(new Du(e,this.encoder,r,n))},e.onerror=a=>{const o=a;i(new Error(o.message))}})}};j(oa,"MESSAGE_TYPE","arraybuffer");let qu=oa;const Fu=t=>{const e=t.replace(/_[a-z]/g,r=>r[1].toUpperCase());return e.length>1&&e[0]===e[0].toUpperCase()&&e[1]===e[1].toUpperCase()?e:e[0].toLowerCase()+e.slice(1)},la=t=>{const e=(r,n=In)=>{if(typeof r=="string")return t(r);if(Array.isArray(r))return r.map(a=>e(a,n));if(!rn(r))return null;n=Gu(n);const i={};return Object.keys(r).forEach(a=>{let o=r[a];const l=t(a);n.recursive&&(rn(o)?Us(o,n.keepTypesOnRecursion)||(o=e(o,n)):n.recursiveInArray&&Bs(o)&&(o=[...o].map(u=>{let f=u;return rn(u)?Us(f,n.keepTypesOnRecursion)||(f=e(u,n)):Bs(u)&&(f=e({key:u},n).key),f}))),i[l]=o}),i};return e},Er=la(Fu),_u=t=>t.replace(/([a-z0-9])([A-Z])/g,(e,r,n)=>`${r}_${n.toLowerCase()}`),Wu=la(_u),In={recursive:!0,recursiveInArray:!0,keepTypesOnRecursion:[Number,String,Uint8Array]},Gu=(t=In)=>(t.recursive==null?t=In:t.recursiveInArray==null&&(t.recursiveInArray=!1),t),Bs=t=>t!=null&&Array.isArray(t),rn=t=>t!=null&&typeof t=="object"&&!Array.isArray(t),Us=(t,e)=>(e||[]).some(r=>t instanceof r),Zu=t=>t!=null&&typeof t=="object"&&"toString"in t,Vu=(t,e=!1)=>{const r=Zu(t)?"stringer":typeof t;let n;switch(r){case"string":n=(i,a)=>i.localeCompare(a);break;case"stringer":n=(i,a)=>i.toString().localeCompare(a.toString());break;case"number":n=(i,a)=>Number(i)-Number(a);break;case"bigint":n=(i,a)=>BigInt(i)-BigInt(a)>0n?1:-1;break;case"boolean":n=(i,a)=>Number(i)-Number(a);break;case"undefined":n=()=>0;break;default:return console.warn(`sortFunc: unknown type ${r}`),()=>-1}return e?Ju(n):n},Ju=t=>(e,r)=>t(r,e),Ur=s.z.tuple([s.z.number(),s.z.number()]);s.z.tuple([s.z.bigint(),s.z.bigint()]);const ua=s.z.object({width:s.z.number(),height:s.z.number()}),Ku=s.z.object({signedWidth:s.z.number(),signedHeight:s.z.number()}),Hu=["width","height"];s.z.enum(Hu);const Xu=["start","center","end"],Qu=["signedWidth","signedHeight"];s.z.enum(Qu);const Ir=s.z.object({x:s.z.number(),y:s.z.number()}),eh=s.z.object({clientX:s.z.number(),clientY:s.z.number()}),th=["x","y"],ha=s.z.enum(th),fa=["top","right","bottom","left"];s.z.enum(fa);const rh=["left","right"],da=s.z.enum(rh),nh=["top","bottom"],ya=s.z.enum(nh),ga=["center"],Ls=s.z.enum(ga),sh=[...fa,...ga],pa=s.z.enum(sh);s.z.enum(Xu);const ih=["first","last"];s.z.enum(ih);const ah=s.z.object({lower:s.z.number(),upper:s.z.number()}),oh=s.z.object({lower:s.z.bigint(),upper:s.z.bigint()});s.z.union([ah,Ur]);s.z.union([oh,Ur]);s.z.union([ha,pa]);s.z.union([ha,pa,s.z.instanceof(String)]);const Ot=(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 Ys(t);return Ys(r)},Ys=t=>t.lower>t.upper?{lower:t.upper,upper:t.lower}:t;s.z.object({x:da.or(Ls),y:ya.or(Ls)});const ch=s.z.object({x:da,y:ya}),lh=Object.freeze({x:"left",y:"top"}),uh=(t,e)=>t.x===e.x&&t.y===e.y,qs=s.z.union([s.z.number(),Ir,Ur,ua,Ku,eh]),hh=(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}},Fs=Object.freeze({x:0,y:0}),Zt=s.z.union([s.z.number(),s.z.string()]);s.z.object({top:Zt,left:Zt,width:Zt,height:Zt});s.z.object({left:s.z.number(),top:s.z.number(),right:s.z.number(),bottom:s.z.number()});s.z.object({one:Ir,two:Ir,root:ch});const Jn=(t,e,r=0,n=0,i)=>{const a={one:{...Fs},two:{...Fs},root:i??lh};if(typeof t=="number"){if(typeof e!="number")throw new Error("Box constructor called with invalid arguments");return a.one={x:t,y:e},a.two={x:a.one.x+r,y:a.one.y+n},a}return"one"in t&&"two"in t&&"root"in t?{...t,root:i??t.root}:("getBoundingClientRect"in t&&(t=t.getBoundingClientRect()),"left"in t?(a.one={x:t.left,y:t.top},a.two={x:t.right,y:t.bottom},a):(a.one=t,e==null?a.two={x:a.one.x+r,y:a.one.y+n}:typeof e=="number"?a.two={x:a.one.x+e,y:a.one.y+r}:"width"in e?a.two={x:a.one.x+e.width,y:a.one.y+e.height}:"signedWidth"in e?a.two={x:a.one.x+e.signedWidth,y:a.one.y+e.signedHeight}:a.two=e,a))},nn=t=>{const e=Jn(t);return{lower:e.one.x,upper:e.two.x}},sn=t=>{const e=Jn(t);return{lower:e.one.y,upper:e.two.y}},fh=t=>typeof t!="object"||t==null?!1:"one"in t&&"two"in t&&"root"in t,dh=s.z.object({signedWidth:s.z.number(),signedHeight:s.z.number()});s.z.union([ua,dh,Ir,Ur]);var yh=Object.defineProperty,gh=(t,e,r)=>e in t?yh(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Re=(t,e,r)=>gh(t,typeof e!="symbol"?e+"":e,r);const ph=(t,e,r)=>e!==void 0&&t<e?e:r!==void 0&&t>r?r:t;s.z.object({offset:qs,scale:qs});const mh=t=>(e,r,n,i)=>r==="dimension"?[e,n]:[e,i?n-t:n+t],wh=t=>(e,r,n,i)=>[e,i?n/t:n*t],bh=t=>(e,r,n)=>{if(e===null)return[t,n];const{lower:i,upper:a}=e,{lower:o,upper:l}=t,u=a-i,f=l-o;if(r==="dimension")return[t,n*(f/u)];const w=(n-i)*(f/u)+o;return[t,w]},vh=t=>(e,r,n)=>[t,n],Oh=()=>(t,e,r)=>{if(t===null)throw new Error("cannot invert without bounds");if(e==="dimension")return[t,r];const{lower:n,upper:i}=t;return[t,i-(r-n)]},Th=t=>(e,r,n)=>{const{lower:i,upper:a}=t;return n=ph(n,i,a),[e,n]},An=class ht{constructor(){Re(this,"ops",[]),Re(this,"currBounds",null),Re(this,"currType",null),Re(this,"reversed",!1),this.ops=[]}static translate(e){return new ht().translate(e)}static magnify(e){return new ht().magnify(e)}static scale(e,r){return new ht().scale(e,r)}translate(e){const r=this.new(),n=mh(e);return n.type="translate",r.ops.push(n),r}magnify(e){const r=this.new(),n=wh(e);return n.type="magnify",r.ops.push(n),r}scale(e,r){const n=Ot(e,r),i=this.new(),a=bh(n);return a.type="scale",i.ops.push(a),i}clamp(e,r){const n=Ot(e,r),i=this.new(),a=Th(n);return a.type="clamp",i.ops.push(a),i}reBound(e,r){const n=Ot(e,r),i=this.new(),a=vh(n);return a.type="re-bound",i.ops.push(a),i}invert(){const e=Oh();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 ht;return e.ops=this.ops.slice(),e.reversed=this.reversed,e}exec(e,r){return this.currBounds=null,this.ops.reduce(([n,i],a)=>a(n,e,i,this.reversed),[null,r])[1]}reverse(){const e=this.new();e.ops.reverse();const r=[];return e.ops.forEach((n,i)=>{if(n.type==="scale"||r.some(([o,l])=>i>=o&&i<=l))return;const a=e.ops.findIndex((o,l)=>o.type==="scale"&&l>i);a!==-1&&r.push([i,a])}),r.forEach(([n,i])=>{const a=e.ops.slice(n,i);a.unshift(e.ops[i]),e.ops.splice(n,i-n+1,...a)}),e.reversed=!e.reversed,e}};Re(An,"IDENTITY",new An);let _s=An;const Ws=class ke{constructor(e=new _s,r=new _s,n=null){Re(this,"x"),Re(this,"y"),Re(this,"currRoot"),this.x=e,this.y=r,this.currRoot=n}static translate(e,r){return new ke().translate(e,r)}static translateX(e){return new ke().translateX(e)}static translateY(e){return new ke().translateY(e)}static clamp(e){return new ke().clamp(e)}static magnify(e){return new ke().magnify(e)}static scale(e){return new ke().scale(e)}static reBound(e){return new ke().reBound(e)}translate(e,r){const n=hh(e,r),i=this.copy();return i.x=this.x.translate(n.x),i.y=this.y.translate(n.y),i}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(fh(e)){const n=this.currRoot;return r.currRoot=e.root,n!=null&&!uh(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(nn(e)),r.y=r.y.scale(sn(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(nn(e)),r.y=this.y.reBound(sn(e)),r}clamp(e){const r=this.copy();return r.x=this.x.clamp(nn(e)),r.y=this.y.clamp(sn(e)),r}copy(){const e=new ke;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 Jn(this.pos(e.one),this.pos(e.two),0,0,this.currRoot??e.root)}};Re(Ws,"IDENTITY",new Ws);var Sh=Object.defineProperty,zh=(t,e,r)=>e in t?Sh(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,m=(t,e,r)=>zh(t,typeof e!="symbol"?e+"":e,r);let Nh=(t,e=21)=>(r=e)=>{let n="",i=r;for(;i--;)n+=t[Math.random()*t.length|0];return n};const Eh="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",ma=Nh(Eh,11),Ih=Object.freeze(Object.defineProperty({__proto__:null,id:ma},Symbol.toStringTag,{value:"Module"})),wa=(t,e)=>{const r=new E(e);if(![I.DAY,I.HOUR,I.MINUTE,I.SECOND,I.MILLISECOND,I.MICROSECOND,I.NANOSECOND].some(i=>i.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 E?new E(n):new I(n)},Y=class z{constructor(e,r="UTC"){if(m(this,"value"),m(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 i=new Date(e,r-1,n,0,0,0,0);return new z(BigInt(i.getTime())*z.MILLISECOND.valueOf()).truncate(z.DAY).valueOf()}encode(){return this.value.toString()}valueOf(){return this.value}static parseTimeString(e,r="UTC"){const[n,i,a]=e.split(":");let o="00",l="00";a!=null&&([o,l]=a.split("."));let u=z.hours(parseInt(n??"00",10)).add(z.minutes(parseInt(i??"00",10))).add(z.seconds(parseInt(o??"00",10))).add(z.milliseconds(parseInt(l??"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 I(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 oe(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 wa(this,e)}get isToday(){return this.truncate(I.DAY).equals(z.now().truncate(I.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 i=new z(n);i.after(r)&&(r=i)}return r}static min(...e){let r=z.MAX;for(const n of e){const i=new z(n);i.before(r)&&(r=i)}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)}};m(Y,"NANOSECOND",Y.nanoseconds(1)),m(Y,"MICROSECOND",Y.microseconds(1)),m(Y,"MILLISECOND",Y.milliseconds(1)),m(Y,"SECOND",Y.seconds(1)),m(Y,"MINUTE",Y.minutes(1)),m(Y,"HOUR",Y.hours(1)),m(Y,"DAY",Y.days(1)),m(Y,"MAX",new Y((1n<<63n)-1n)),m(Y,"MIN",new Y(0)),m(Y,"ZERO",new Y(0)),m(Y,"z",s.z.union([s.z.object({value:s.z.bigint()}).transform(t=>new Y(t.value)),s.z.string().transform(t=>new Y(BigInt(t))),s.z.instanceof(Number).transform(t=>new Y(t)),s.z.number().transform(t=>new Y(t)),s.z.instanceof(Y)]));let E=Y;const q=class C{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 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 wa(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),i=this.truncate(C.SECOND),a=this.truncate(C.MILLISECOND),o=this.truncate(C.MICROSECOND),l=this.truncate(C.NANOSECOND),u=e,f=r.sub(e),w=n.sub(r),h=i.sub(n),M=a.sub(i),_=o.sub(a),re=l.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 `),M.isZero||(R+=`${M.milliseconds}ms `),_.isZero||(R+=`${_.microseconds}µs `),re.isZero||(R+=`${re.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)}};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",s.z.union([s.z.object({value:s.z.bigint()}).transform(t=>new q(t.value)),s.z.string().transform(t=>new q(BigInt(t))),s.z.instanceof(Number).transform(t=>new q(t)),s.z.number().transform(t=>new q(t)),s.z.instanceof(q)]));let I=q;const ft=class ar extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new ar(e).valueOf()}get period(){return I.seconds(1/this.valueOf())}sampleCount(e){return new I(e).seconds*this.valueOf()}byteCount(e,r){return this.sampleCount(e)*new ue(r).valueOf()}span(e){return I.seconds(e/this.valueOf())}byteSpan(e,r){return this.span(e.valueOf()/r.valueOf())}static hz(e){return new ar(e)}static khz(e){return ar.hz(e*1e3)}};m(ft,"z",s.z.union([s.z.number().transform(t=>new ft(t)),s.z.instanceof(Number).transform(t=>new ft(t)),s.z.instanceof(ft)]));let Kn=ft;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 Et(e*this.valueOf())}};m(Q,"UNKNOWN",new Q(0)),m(Q,"BIT128",new Q(16)),m(Q,"BIT64",new Q(8)),m(Q,"BIT32",new Q(4)),m(Q,"BIT16",new Q(2)),m(Q,"BIT8",new Q(1)),m(Q,"z",s.z.union([s.z.number().transform(t=>new Q(t)),s.z.instanceof(Number).transform(t=>new Q(t)),s.z.instanceof(Q)]));let ue=Q;const Se=class or{constructor(e,r){m(this,"start"),m(this,"end"),typeof e=="object"&&"start"in e?(this.start=new E(e.start),this.end=new E(e.end)):(this.start=new E(e),this.end=new E(r))}get span(){return new I(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=I.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 i=E.max(n.start,e.start),a=E.min(n.end,e.end);return a.before(i)?!1:new I(a.sub(i)).greaterThanOrEqual(r)}roughlyEquals(e,r){let n=this.start.sub(e.start).valueOf(),i=this.end.sub(e.end).valueOf();return n<0&&(n=-n),i<0&&(i=-i),n<=r.valueOf()&&i<=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}};m(Se,"MAX",new Se(E.MIN,E.MAX)),m(Se,"MIN",new Se(E.MAX,E.MIN)),m(Se,"ZERO",new Se(E.ZERO,E.ZERO)),m(Se,"z",s.z.union([s.z.object({start:E.z,end:E.z}).transform(t=>new Se(t.start,t.end)),s.z.instanceof(Se)]));let oe=Se;const y=class ze extends String{constructor(e){if(e instanceof ze||typeof e=="string"||typeof e.valueOf()=="string"){super(e.valueOf());return}else{const r=ze.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(r!=null){super(r.valueOf());return}}throw super(ze.UNKNOWN.valueOf()),new Error(`unable to find data type for ${e.toString()}`)}get Array(){const e=ze.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(ze.JSON)||this.equals(ze.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(ze.UUID)}get isInteger(){return this.toString().startsWith("int")}get isFloat(){return this.toString().startsWith("float")}get density(){const e=ze.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 ze.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(),ue.BIT8],[y.UINT16.toString(),ue.BIT16],[y.UINT32.toString(),ue.BIT32],[y.UINT64.toString(),ue.BIT64],[y.FLOAT32.toString(),ue.BIT32],[y.FLOAT64.toString(),ue.BIT64],[y.INT8.toString(),ue.BIT8],[y.INT16.toString(),ue.BIT16],[y.INT32.toString(),ue.BIT32],[y.INT64.toString(),ue.BIT64],[y.TIMESTAMP.toString(),ue.BIT64],[y.STRING.toString(),ue.UNKNOWN],[y.JSON.toString(),ue.UNKNOWN],[y.UUID.toString(),ue.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",s.z.union([s.z.string().transform(t=>new y(t)),s.z.instanceof(y)]));let A=y;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),i=this.truncate(J.KILOBYTE),a=this.truncate(J.BYTE),o=e,l=r.sub(e),u=n.sub(r),f=i.sub(n),w=a.sub(i);let h="";return o.isZero||(h+=`${o.terabytes}TB `),l.isZero||(h+=`${l.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}};m(ie,"BYTE",new ie(1)),m(ie,"KILOBYTE",ie.kilobytes(1)),m(ie,"MEGABYTE",ie.megabytes(1)),m(ie,"GIGABYTE",ie.gigabytes(1)),m(ie,"TERABYTE",ie.terabytes(1)),m(ie,"ZERO",new ie(0)),m(ie,"z",s.z.union([s.z.number().transform(t=>new ie(t)),s.z.instanceof(ie)]));let Et=ie;s.z.union([s.z.instanceof(Uint8Array),s.z.instanceof(Uint16Array),s.z.instanceof(Uint32Array),s.z.instanceof(BigUint64Array),s.z.instanceof(Float32Array),s.z.instanceof(Float64Array),s.z.instanceof(Int8Array),s.z.instanceof(Int16Array),s.z.instanceof(Int32Array),s.z.instanceof(BigInt64Array)]);const ba=t=>{const e=typeof t;return e==="string"||e==="number"||e==="boolean"||e==="bigint"||t instanceof E||t instanceof I||t instanceof Date},Ah=(t,e,r,n=0)=>t.usesBigInt&&!e.usesBigInt?Number(r)-Number(n):!t.usesBigInt&&e.usesBigInt?BigInt(r)-BigInt(n):dt(r,-n),kh=t=>t==null?!1:Array.isArray(t)||t instanceof ArrayBuffer||ArrayBuffer.isView(t)&&!(t instanceof DataView)||t instanceof Fe?!0:ba(t),Le=-1;let Fe=class xe{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",Le),m(this,"_refCount",0),m(this,"_cachedLength"),kh(e)&&(e={data:e});const{dataType:r,timeRange:n,sampleOffset:i=0,glBufferUsage:a="static",alignment:o=0n,key:l=ma()}=e,{data:u}=e;if(u instanceof xe||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=ba(u),w=Array.isArray(u);if(r!=null)this.dataType=new A(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=A.STRING;else if(typeof h=="number")this.dataType=A.FLOAT64;else if(typeof h=="bigint")this.dataType=A.INT64;else if(typeof h=="boolean")this.dataType=A.BOOLEAN;else if(h instanceof E||h instanceof Date||h instanceof E)this.dataType=A.TIMESTAMP;else if(typeof h=="object")this.dataType=A.JSON;else throw new Error(`cannot infer data type of ${typeof h} when constructing a Series from a JS array`)}else this.dataType=new A(u)}if(!w&&!f)this._data=u;else{let h=f?[u]:u;const M=h[0];(M instanceof E||M instanceof Date||M instanceof I)&&(h=h.map(_=>new E(_).valueOf())),this.dataType.equals(A.STRING)?(this._cachedLength=h.length,this._data=new TextEncoder().encode(h.join(`
16
+ `)+`
17
+ `)):this.dataType.equals(A.JSON)?(this._cachedLength=h.length,this._data=new TextEncoder().encode(h.map(_=>JSON.stringify(_)).join(`
18
+ `)+`
19
+ `)):this._data=new this.dataType.Array(h).buffer}this.key=l,this.alignment=o,this.sampleOffset=i??0,this._timeRange=n,this.gl={control:null,buffer:null,prevBuffer:0,bufferUsage:a}}static alloc({capacity:e,dataType:r,...n}){if(e===0)throw new Error("[Series] - cannot allocate an array of length 0");const i=new new A(r).Array(e),a=new xe({data:i.buffer,dataType:r,...n});return a.writePos=0,a}static generateTimestamps(e,r,n){const i=n.spanRange(r.span(e)),a=new BigInt64Array(e);for(let o=0;o<e;o++)a[o]=BigInt(n.add(r.span(o)).valueOf());return new xe({data:a,dataType:A.TIMESTAMP,timeRange:i})}get refCount(){return this._refCount}static fromStrings(e,r){const n=new TextEncoder().encode(e.join(`
20
+ `)+`
21
+ `);return new xe({data:n,dataType:A.STRING,timeRange:r})}static fromJSON(e,r){const n=new TextEncoder().encode(e.map(i=>JSON.stringify(i)).join(`
22
+ `)+`
23
+ `);return new xe({data:n,dataType:A.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===Le)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===Le?this.underlyingData:new this.dataType.Array(this._data,0,this.writePos)}toStrings(){if(!this.dataType.equals(A.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(A.UUID))throw new Error("cannot convert non-uuid series to uuids");const e=A.UUID.density.valueOf(),r=Array(this.length);for(let n=0;n<this.length;n++){const i=this.buffer.slice(n*e,(n+1)*e),a=Array.from(new Uint8Array(i),o=>o.toString(16).padStart(2,"0")).join("").replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/,"$1-$2-$3-$4-$5");r[n]=a}return r}parseJSON(e){if(!this.dataType.equals(A.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(Er(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 Et(this.buffer.byteLength)}get capacity(){return this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===Le?this.byteCapacity:this.dataType.density.size(this.writePos)}get length(){return this._cachedLength!=null?this._cachedLength:this.dataType.isVariable?this.calculateCachedLength():this.writePos===Le?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 i=0;i<this.length;i++)n[i]=Ah(this.dataType,e,this.data[i],r);return new xe({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(A.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()),dt(this._cachedMax,this.sampleOffset))}calcRawMin(){if(this.length===0)return 1/0;if(this.dataType.equals(A.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()),dt(this._cachedMin,this.sampleOffset))}get bounds(){return Ot(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 dt(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 dt(n,this.sampleOffset)}atVariable(e,r){e<0&&(e=this.length+e);let n=0,i=0;for(let o=0;o<this.data.length;o++)if(this.data[o]===10){if(e===0){i=o;break}n=o+1,e--}if(i===0&&(i=this.data.length),n>=i||e>0){if(r)throw new Error(`[series] - no value at index ${e}`);return}const a=this.data.slice(n,i);return this.dataType.equals(A.STRING)?new TextDecoder().decode(a):Er(JSON.parse(new TextDecoder().decode(a)))}binarySearch(e){let r=0,n=this.length-1;const i=Vu(e);for(;r<=n;){const a=Math.floor((r+n)/2),o=i(this.at(a,!0),e);if(o===0)return a;o<0?r=a+1:n=a-1}return r}updateGLBuffer(e){if(this.gl.control=e,!this.dataType.equals(A.FLOAT32))throw new Error("Only FLOAT32 arrays can be used in WebGL");const{buffer:r,bufferUsage:n,prevBuffer:i}=this.gl;if(r==null&&(this.gl.buffer=e.createBuffer()),this.writePos!==i)if(e.bindBuffer(e.ARRAY_BUFFER,this.gl.buffer),this.writePos!==Le){i===0&&e.bufferData(e.ARRAY_BUFFER,this.byteCapacity.valueOf(),e.STATIC_DRAW);const a=this.dataType.density.size(i).valueOf(),o=this.underlyingData.slice(this.gl.prevBuffer,this.writePos);e.bufferSubData(e.ARRAY_BUFFER,a,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=Le}as(e){if(e==="string"){if(!this.dataType.equals(A.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(A.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 Ot(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 xh(this);return this.dataType.equals(A.JSON)?new Ch(e):e}return new Rh(this)}slice(e,r){if(e<=0&&(r==null||r>=this.length))return this;const n=this.data.slice(e,r);return new xe({data:n,dataType:this.dataType,timeRange:this._timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(e)})}reAlign(e){return new xe({data:this.buffer,dataType:this.dataType,timeRange:oe.ZERO,sampleOffset:this.sampleOffset,glBufferUsage:"static",alignment:e})}};class xh{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 Gs,Zs;class Ch{constructor(e){m(this,"wrapped"),m(this,Gs,"JSONSeriesIterator"),this.wrapped=e}next(){const e=this.wrapped.next();return e.done===!0?{done:!0,value:void 0}:{done:!1,value:Er(JSON.parse(e.value))}}[(Zs=Symbol.iterator,Gs=Symbol.toStringTag,Zs)](){return this}}var Vs,Js;class Rh{constructor(e){m(this,"series"),m(this,"index"),m(this,Vs,"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)}}[(Js=Symbol.iterator,Vs=Symbol.toStringTag,Js)](){return this}}const dt=(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 jh{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 A(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?A.UNKNOWN:this.series[0].dataType}get timeRange(){return this.series.length===0?oe.ZERO:new oe(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 Et(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 $h(this.series)}}var Ks,Hs;class $h{constructor(e){m(this,"series"),m(this,"seriesIndex"),m(this,"internal"),m(this,Ks,"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())}[(Hs=Symbol.iterator,Ks=Symbol.toStringTag,Hs)](){return this}}const N=t=>Array.isArray(t)?t:[t],Pe=s.z.number(),Mt=s.z.object({name:s.z.string(),key:s.z.number(),rate:Kn.z,dataType:A.z,leaseholder:s.z.number(),index:s.z.number(),isIndex:s.z.boolean(),internal:s.z.boolean(),alias:s.z.string().optional()}),va=Mt.extend({key:s.z.number().optional(),leaseholder:s.z.number().optional(),index:s.z.number().optional(),rate:Kn.z.optional().default(0),isIndex:s.z.boolean().optional(),internal:s.z.boolean().optional().default(!1),virtual:s.z.boolean().optional().default(!1)}),Mh=(t,e)=>{let r=null;return e===0?t:(...n)=>{r!==null&&(clearTimeout(r),r=null),r=setTimeout(()=>t(...n),e)}},Dh=new Error("request for lock canceled");var Ph=function(t,e,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function l(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?a(w.value):i(w.value).then(l,u)}f((n=n.apply(t,e||[])).next())})};class Bh{constructor(e,r=Dh){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,i)=>{const a={resolve:n,reject:i,weight:e,priority:r},o=Oa(this._queue,l=>r<=l.priority);o===-1&&e<=this._value?this._dispatchItem(a):this._queue.splice(o+1,0,a)})}runExclusive(e){return Ph(this,arguments,void 0,function*(r,n=1,i=0){const[a,o]=yield this.acquire(n,i);try{return yield r(a)}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]=[]),Uh(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 i=n.findIndex(a=>a.priority<=e);(i===-1?n:n.splice(0,i)).forEach(a=>a.resolve())}}}_couldLockImmediately(e,r){return(this._queue.length===0||this._queue[0].priority<r)&&e<=this._value}}function Uh(t,e){const r=Oa(t,n=>e.priority<=n.priority);t.splice(r+1,0,e)}function Oa(t,e){for(let r=t.length-1;r>=0;r--)if(e(t[r]))return r;return-1}var Lh=function(t,e,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function l(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?a(w.value):i(w.value).then(l,u)}f((n=n.apply(t,e||[])).next())})};class Yh{constructor(e){this._semaphore=new Bh(1,e)}acquire(){return Lh(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 Be="sy.",cr=class Ta extends we{constructor(){super(...arguments),c(this,"type",Ta.TYPE)}};c(cr,"TYPE",Be+"validation"),c(cr,"matches",he(cr.TYPE));let G=cr;const lr=class Sa extends G{constructor(e,r){super(e+": "+r),c(this,"type",Sa.TYPE),c(this,"field"),c(this,"message"),this.field=e,this.message=r}};c(lr,"TYPE",G.TYPE+".field"),c(lr,"matches",he(lr.TYPE));let Xs=lr;const ur=class za extends we{constructor(){super(...arguments),c(this,"type",za.TYPE)}};c(ur,"TYPE",Be+"auth"),c(ur,"matches",he(ur.TYPE));let Ar=ur;const hr=class Na extends Ar{constructor(){super(...arguments),c(this,"type",Na.TYPE)}};c(hr,"TYPE",Ar.TYPE+".invalid-token"),c(hr,"matches",he(hr.TYPE));let kn=hr;const fr=class Ea extends we{constructor(e){super(`
26
+ Unexpected error encountered:
27
+
28
+ ${e}
29
+
30
+ Please report this to the Synnax team.
31
+ `),c(this,"type",Ea.TYPE)}};c(fr,"TYPE",Be+"unexpected"),c(fr,"matches",he(fr.TYPE));let ge=fr;const dr=class Ia extends we{constructor(){super(...arguments),c(this,"type",Ia.TYPE)}};c(dr,"TYPE",Be+"query"),c(dr,"matches",he(dr.TYPE));let pe=dr;const yr=class Aa extends pe{constructor(){super(...arguments),c(this,"type",Aa.TYPE)}};c(yr,"TYPE",pe.TYPE+".not_found"),c(yr,"matches",he(yr.TYPE));let kr=yr;const gr=class ka extends pe{constructor(){super(...arguments),c(this,"type",ka.TYPE)}};c(gr,"TYPE",pe.TYPE+".multiple_results"),c(gr,"matches",he(gr.TYPE));let xr=gr;const pr=class xa extends we{constructor(e,r){super(e),c(this,"type",xa.TYPE),c(this,"path"),this.path=r}};c(pr,"TYPE",Be+"route"),c(pr,"matches",he(pr.TYPE));let Qs=pr;const mr=class Ca extends we{constructor(){super(...arguments),c(this,"type",Ca.TYPE)}};c(mr,"TYPE",Be+"control"),c(mr,"matches",he(mr.TYPE));let Cr=mr;const wr=class Ra extends Cr{constructor(){super(...arguments),c(this,"type",Ra.TYPE)}};c(wr,"TYPE",Cr.TYPE+".unauthorized"),c(wr,"matches",he(wr.TYPE));let ei=wr;const an=class ja extends we{constructor(){super(...arguments),c(this,"type",ja.TYPE)}};c(an,"TYPE",Be+"contiguity"),c(an,"matches",he(an.TYPE));const qh=t=>{if(!t.type.startsWith(Be))return null;if(t.type.startsWith(G.TYPE)){if(t.type===Xs.TYPE){const e=t.data.split(": ");return e.length<2?new G(t.data):new Xs(e[0],e[1])}return new G(t.data)}return t.type.startsWith(Ar.TYPE)?t.type.startsWith(kn.TYPE)?new kn(t.data):new Ar(t.data):t.type.startsWith(ge.TYPE)?new ge(t.data):t.type.startsWith(pe.TYPE)?t.type.startsWith(kr.TYPE)?new kr(t.data):t.type.startsWith(xr.TYPE)?new xr(t.data):new pe(t.data):t.type.startsWith(Cr.TYPE)?t.type.startsWith(ei.TYPE)?new ei(t.data):new Cr(t.data):t.type.startsWith(Qs.TYPE)?new Qs(t.data,t.data):new ge(t.data)},Fh=()=>{throw new Error("Not implemented")};ta({encode:Fh,decode:qh});const _h=async(t,e)=>{const[r,n]=await e(t);return n==null?[r,n]:n instanceof We?[r,new We({message:`Cannot reach cluster at ${n.url.host}:${n.url.port}`,url:n.url})]:[r,n]},Hn=t=>t!=null&&typeof t=="object"&&!Array.isArray(t);var Wh=Object.defineProperty,Gh=(t,e,r)=>e in t?Wh(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Tt=(t,e,r)=>Gh(t,typeof e!="symbol"?e+"":e,r);class $a{constructor(){Tt(this,"contentType","application/json"),Tt(this,"decoder"),Tt(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=JSON.parse(e),i=Er(n);return r!=null?r.parse(i):i}encodeString(e){const r=Wu(e);return JSON.stringify(r,(n,i)=>ArrayBuffer.isView(i)?Array.from(i):Hn(i)&&"encode_value"in i?typeof i.value=="bigint"?i.value.toString():i.value:typeof i=="bigint"?i.toString():i)}static registerCustomType(){}}let Ma=class{constructor(){Tt(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||!Hn(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 i=e.map(a=>JSON.stringify(n[a]??""));r.push(i.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 i=r.split(",").map(o=>o.trim()),a={};return i.forEach(o=>{a[o]=[]}),n.forEach(o=>{const l=o.split(",").map(u=>u.trim());i.forEach((u,f)=>{const w=this.parseValue(l[f]);w!=null&&a[u].push(w)})}),e!=null?e.parse(a):a}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(){}},Da=class{constructor(){Tt(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}};const Pa=new $a,Zh=new Ma,Vh=new Da,Jh=[Pa],He=Object.freeze(Object.defineProperty({__proto__:null,CSVEncoderDecoder:Ma,CSV_ECD:Zh,ENCODERS:Jh,JSONEncoderDecoder:$a,JSON_ECD:Pa,TEXT_ECD:Vh,TextEncoderDecoder:Da},Symbol.toStringTag,{value:"Module"}));var Kh=Object.defineProperty,Hh=(t,e,r)=>e in t?Kh(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,xn=(t,e,r)=>Hh(t,typeof e!="symbol"?e+"":e,r);class Xh{constructor(e,r){xn(this,"handlers"),xn(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,i]=this.transform(e);if(!i)return;r=n}this.handlers.forEach((n,i)=>i(r))}}let Qh=class{constructor(t){xn(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 Cn=Object.freeze(Object.defineProperty({__proto__:null,BaseObserver:Qh,Observer:Xh},Symbol.toStringTag,{value:"Module"})),Xn=s.z.record(s.z.union([s.z.number(),s.z.string(),s.z.symbol()]),s.z.unknown()),ef=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser";ef();const tf=["MacOS","Windows","Linux","Docker"];s.z.enum(tf);const ti=t=>[...new Set(t)];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,yt=(t,e,r)=>nf(t,typeof e!="symbol"?e+"":e,r);const sf=(...t)=>t.map(Ba).join(""),Ba=t=>(t.endsWith("/")||(t+="/"),t.startsWith("/")&&(t=t.slice(1)),t),af=t=>t.endsWith("/")?t.slice(0,-1):t,Rn=class jn{constructor({host:e,port:r,protocol:n="",pathPrefix:i=""}){yt(this,"protocol"),yt(this,"host"),yt(this,"port"),yt(this,"path"),this.protocol=n,this.host=e,this.port=r,this.path=Ba(i)}replace(e){return new jn({host:e.host??this.host,port:e.port??this.port,protocol:e.protocol??this.protocol,pathPrefix:e.pathPrefix??this.path})}child(e){return new jn({...this,pathPrefix:sf(this.path,e)})}toString(){return af(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}};yt(Rn,"UNKNOWN",new Rn({host:"unknown",port:0}));let of=Rn;var cf=Object.defineProperty,lf=(t,e,r)=>e in t?cf(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,br=(t,e,r)=>lf(t,typeof e!="symbol"?e+"":e,r);const qe=class extends Number{};br(qe,"Absolute",255),br(qe,"Default",1),br(qe,"z",s.z.union([s.z.instanceof(qe),s.z.number().int().min(0).max(255).transform(t=>new qe(t)),s.z.instanceof(Number).transform(t=>new qe(t))]));let Ua=qe;const La=s.z.object({name:s.z.string(),key:s.z.string()}),uf=t=>s.z.object({subject:La,resource:t,authority:Ua.z}),hf=(...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}),Ke=Object.freeze(Object.defineProperty({__proto__:null,Authority:Ua,filterTransfersByChannelKey:hf,stateZ:uf,subjectZ:La},Symbol.toStringTag,{value:"Module"})),Ya=class gt extends Error{constructor(){super(gt.MESSAGE)}matches(e){return typeof e=="string"?e.includes(gt.MESSAGE):e instanceof gt||e.message.includes(gt.MESSAGE)}};br(Ya,"MESSAGE","canceled");let ff=Ya;new ff;s.z.string().regex(/^\d+\.\d+\.\d+$/);const Lr=(t,e,{convertNumericStrings:r=!0}={})=>{const n=!Array.isArray(t);let i=N(t);const a=i[0],o=typeof a;let l;return o==="string"&&r&&!isNaN(parseInt(a))&&"number"in e?(l=e.number,i=i.map(u=>parseInt(u))):l=e[o],{single:n,variant:l,normalized:i,actual:t}},Yr=(t,e,r,n)=>{if(n){if(r.length===0)throw new kr(`${t} not found matching ${JSON.stringify(e)}`);if(r.length>1)throw new xr(`Expected one ${t} matching ${JSON.stringify(e)}, but found ${r.length}`)}},Xe=t=>s.z.union([s.z.null().transform(()=>[]),t.array()]),df=s.z.object({leaseholder:s.z.number().optional(),keys:s.z.number().array().optional(),names:s.z.string().array().optional(),search:s.z.string().optional(),rangeKey:s.z.string().optional(),limit:s.z.number().optional(),offset:s.z.number().optional(),dataTypes:A.z.array().optional(),notDataTypes:A.z.array().optional(),virtual:s.z.boolean().optional(),isIndex:s.z.boolean().optional(),internal:s.z.boolean().optional()}),yf=s.z.object({channels:Xe(Mt)}),je=t=>Lr(t,{number:"keys",string:"names"}),qa=class Fa{constructor(e){c(this,"client"),this.client=e}async search(e,r){return await this.execute({search:e,...r})}async retrieve(e,r){const n=je(e),{variant:i}=n;let{normalized:a}=n;return i==="keys"&&a.indexOf(0)!==-1&&(a=a.filter(o=>o!==0)),a.length===0?[]:await this.execute({[i]:a,...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(Fa.ENDPOINT,e,df,yf);if(n!=null)throw n;return r.channels}};c(qa,"ENDPOINT","/channel/retrieve");let Qn=qa;class es{constructor(e){c(this,"cache"),c(this,"namesToKeys"),c(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}=Lr(e,{string:"names",number:"keys"}),i=[],a=[];if(n.forEach(l=>{const u=this.get(l);u!=null?i.push(...u):a.push(l)}),a.length===0)return i;const o=await this.wrapped.retrieve(a,r);return this.set(o),i.concat(o)}delete(e){const{variant:r,normalized:n}=je(e);r==="names"?n.forEach(i=>{const a=this.namesToKeys.get(i);a!=null&&(a.forEach(o=>this.cache.delete(o)),this.namesToKeys.delete(i))}):n.forEach(i=>{const a=this.cache.get(i);a!=null&&(this.cache.delete(i),this.namesToKeys.delete(a.name))})}rename(e,r){e.forEach((n,i)=>{const a=r[i],o=this.cache.get(n);if(o==null)return;this.cache.delete(n);const l=this.namesToKeys.get(o.name);l!=null&&(l.delete(n),l.size===0&&this.namesToKeys.delete(o.name)),o.name=a,this.cache.set(n,o);const u=this.namesToKeys.get(a);u==null?this.namesToKeys.set(a,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 i=this.cache.get(e);return i==null?void 0:[i]}const r=this.namesToKeys.get(e);if(r==null)return;const n=[];if(r.forEach(i=>{const a=this.cache.get(i);a!=null&&n.push(a)}),n.length!==0)return n}}class _a{constructor(e,r){c(this,"mu",new Yh),c(this,"requests",new Map),c(this,"wrapped"),c(this,"debouncedRun"),this.wrapped=e,this.debouncedRun=Mh(()=>{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}=je(e);return n==="names"?await this.wrapped.retrieve(r):await new Promise((i,a)=>{this.mu.runExclusive(()=>{this.requests.set(r,{resolve:i,reject:a}),this.debouncedRun()})})}async run(){await this.mu.runExclusive(async()=>{const e=new Set;this.requests.forEach((r,n)=>n.forEach(i=>e.add(i)));try{const r=await this.wrapped.retrieve(Array.from(e));this.requests.forEach((n,i)=>n.resolve(r.filter(a=>i.includes(a.key))))}catch(r){this.requests.forEach(n=>n.reject(r))}finally{this.requests.clear()}})}}const Wa=async(t,e)=>{const{normalized:r}=je(e),n=await t.retrieve(r),i=[];if(r.forEach(a=>{n.find(o=>o.name===a||o.key===a)==null&&i.push(a)}),i.length>0)throw new pe(`Could not find channels: ${JSON.stringify(i)}`);return n};class Ga{constructor(e,r){c(this,"key"),c(this,"name"),this.key=r,this.name=e}get ontologyID(){return new me({type:"group",key:this.key})}}const gf=s.z.string().uuid(),Za=s.z.object({key:gf,name:s.z.string()}),Va=s.z.union([s.z.literal("label"),s.z.literal("builtin"),s.z.literal("cluster"),s.z.literal("channel"),s.z.literal("node"),s.z.literal("group"),s.z.literal("range"),s.z.literal("range-alias"),s.z.literal("user"),s.z.literal("workspace"),s.z.literal("schematic"),s.z.literal("lineplot"),s.z.literal("rack"),s.z.literal("device"),s.z.literal("task")]),Ee=s.z.object({type:Va,key:s.z.string()}),pf=s.z.string().transform(t=>{const[e,r]=t.split(":");return{type:e,key:r}}),mf=s.z.union([pf,Ee]),vr=class Ja{constructor(e){if(c(this,"type"),c(this,"key"),e instanceof Ja)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}}};c(vr,"z",s.z.union([mf,s.z.instanceof(vr)]).transform(t=>new vr(t)));let me=vr;new me({type:"builtin",key:"root"});const wf=s.z.object({type:s.z.number()}),bf=s.z.object({type:Va,fields:s.z.record(wf)}),vf=s.z.object({id:me.z,name:s.z.string(),schema:bf.optional().nullable(),data:s.z.record(s.z.unknown()).optional().nullable()}).transform(t=>({key:t.id.toString(),...t}));s.z.object({from:me.z,type:s.z.string(),to:me.z});const ri=t=>{const[e,r,n]=t.split("->");return{from:new me(e),type:r,to:new me(n)}},Of=s.z.object({group:Za}),Tf=s.z.object({parent:Ee,key:s.z.string().uuid().optional(),name:s.z.string()}),Sf=s.z.object({key:s.z.string(),name:s.z.string()}),zf=s.z.object({keys:s.z.array(s.z.string())});var $e;let Nf=($e=class{constructor(t){c(this,"client"),this.client=t}async create(t,e,r){const[n,i]=await this.client.send($e.ENDPOINT,{parent:t,name:e,key:r},Tf,Of);if(i!=null)throw i;return n.group}async rename(t,e){const r={key:t,name:e},[,n]=await this.client.send($e.ENDPOINT_RENAME,r,Sf,s.z.object({}));if(n!=null)throw n}async delete(t){const e={keys:t},[,r]=await this.client.send($e.ENDPOINT_DELETE,e,zf,s.z.object({}));if(r!=null)throw r}},c($e,"ENDPOINT","/ontology/create-group"),c($e,"ENDPOINT_RENAME","/ontology/rename-group"),c($e,"ENDPOINT_DELETE","/ontology/delete-group"),$e),Ef=class{constructor(t){c(this,"creator"),this.creator=new Nf(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 Ga(t.name,t.key)}};const on={ADD_CHILDREN:"/ontology/add-children",REMOVE_CHILDREN:"/ontology/remove-children",MOVE_CHILDREN:"/ontology/move-children"},ni=s.z.object({id:Ee,children:Ee.array()}),If=s.z.object({from:Ee,to:Ee,children:Ee.array()});let Af=class{constructor(t){c(this,"client"),this.client=t}async addChildren(t,...e){await v(this.client,on.ADD_CHILDREN,{id:t,children:e},ni,s.z.object({}))}async removeChildren(t,...e){await v(this.client,on.REMOVE_CHILDREN,{id:t,children:e},ni,s.z.object({}))}async moveChildren(t,e,...r){const n={from:t,to:e,children:r};await v(this.client,on.MOVE_CHILDREN,n,If,s.z.object({}))}};const kf="/ontology/retrieve",xf=s.z.object({ids:Ee.array().optional(),children:s.z.boolean().optional(),parents:s.z.boolean().optional(),includeSchema:s.z.boolean().optional(),excludeFieldData:s.z.boolean().optional(),term:s.z.string().optional(),limit:s.z.number().optional(),offset:s.z.number().optional()}),Cf=s.z.object({resources:vf.array()}),cn=t=>N(t).map(e=>new me(e).payload);let Rf=class{constructor(t,e){c(this,"type","ontology"),c(this,"groups"),c(this,"client"),c(this,"writer"),c(this,"framer"),this.client=t,this.writer=new Af(t),this.groups=new Ef(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:cn(t),...e});if(Array.isArray(t))return r;if(r.length===0)throw new pe(`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:cn(t),children:!0,...e})}async retrieveParents(t,e){return await this.execRetrieve({ids:cn(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 ts.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 v(this.client,kf,t,xf,Cf);return e}};const si="sy_ontology_resource_set",ii="sy_ontology_resource_delete",ai="sy_ontology_relationship_set",oi="sy_ontology_relationship_delete";class ts{constructor(e,r){c(this,"resourceObs"),c(this,"relationshipObs"),c(this,"relationships"),c(this,"resources"),c(this,"streamer"),c(this,"client"),c(this,"closePromise"),this.relationshipObs=new Cn.Observer,this.relationships=this.relationshipObs,this.resourceObs=new Cn.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 i=this.parseRelationshipSets(e),a=this.parseRelationshipDeletes(e);i.concat(a).length>0&&this.relationshipObs.notify(i.concat(a))}parseRelationshipSets(e){const r=e.get(ai);return r.length===0?[]:Array.from(r.as("string")).map(n=>({variant:"set",key:ri(n),value:void 0}))}parseRelationshipDeletes(e){const r=e.get(oi);return r.length===0?[]:Array.from(r.as("string")).map(n=>({variant:"delete",key:ri(n)}))}async parseResourceSets(e){const r=e.get(si);if(r.length===0)return[];const n=Array.from(r.as("string")).map(i=>new me(i));try{return(await this.client.retrieve(n)).map(i=>({variant:"set",key:i.id,value:i}))}catch(i){if(i instanceof pe)return[];throw i}}parseResourceDeletes(e){const r=e.get(ii);return r.length===0?[]:Array.from(r.as("string")).map(n=>({variant:"delete",key:new me(n)}))}static async open(e,r){const n=await e.openStreamer([si,ii,ai,oi]);return new ts(n,r)}}class Ka{constructor({dataType:e,rate:r,name:n,leaseholder:i=0,key:a=0,isIndex:o=!1,index:l=0,internal:u=!1,frameClient:f,alias:w}){c(this,"_frameClient"),c(this,"key"),c(this,"name"),c(this,"rate"),c(this,"dataType"),c(this,"leaseholder"),c(this,"index"),c(this,"isIndex"),c(this,"internal"),c(this,"alias"),this.key=a,this.name=n,this.rate=new Kn(r??0),this.dataType=new A(e),this.leaseholder=i,this.index=l,this.isIndex=o,this.internal=u,this.alias=w,this._frameClient=f??null}get framer(){if(this._frameClient==null)throw new G("cannot read from a channel that has not been created");return this._frameClient}get payload(){return Mt.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 me({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 jf="/channel/retrieve-group",$f=s.z.object({}),Mf=s.z.object({group:Za});let Ha=class{constructor(t,e,r,n){c(this,"type","channel"),c(this,"frameClient"),c(this,"client"),c(this,"retriever"),c(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 i=N(t),a=[];if(r){const o=await this.retriever.retrieve(i.map(u=>u.name)),l=new Set(o.map(u=>u.name));i=i.filter(u=>!l.has(u.name)),a=this.sugar(o)}return a=a.concat(this.sugar(await this.writer.create(i))),n?a[0]:a}async retrieve(t,e){const r=!Array.isArray(t),n=this.sugar(await this.retriever.retrieve(t,e));return Yr("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}=je(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(N(t),N(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 es(new _a(new Qn(this.client),t))}sugar(t){const{frameClient:e}=this;return t.map(r=>new Ka({...r,frameClient:e}))}async retrieveGroup(){const t=await v(this.client,jf,{},$f,Mf);return new Ga(t.group.name,t.group.key)}};const Df=s.z.object({channels:va.array()}),Pf=s.z.object({channels:Mt.array()}),Bf=s.z.object({keys:Pe.array().optional(),names:s.z.string().array().optional()}),Uf=s.z.object({}),Lf=s.z.object({keys:Pe.array(),names:s.z.string().array()}),Yf=s.z.object({}),qf="/channel/create",Ff="/channel/delete",_f="/channel/rename";let Xa=class{constructor(t,e){c(this,"client"),c(this,"cache"),this.client=t,this.cache=e}async create(t){const{channels:e}=await v(this.client,qf,{channels:t},Df,Pf);return this.cache.set(e),e}async delete(t){await v(this.client,Ff,t,Bf,Uf),t.keys!=null&&this.cache.delete(t.keys),t.names!=null&&this.cache.delete(t.names)}async rename(t,e){await v(this.client,_f,{keys:t,names:e},Lf,Yf),this.cache.rename(t,e)}};const Wf=Object.freeze(Object.defineProperty({__proto__:null,CacheRetriever:es,Channel:Ka,Client:Ha,ClusterRetriever:Qn,DebouncedBatchRetriever:_a,Writer:Xa,analyzeChannelParams:je,keyZ:Pe,newPayload:va,payload:Mt,retrieveRequired:Wa},Symbol.toStringTag,{value:"Module"})),Gf=s.z.object({key:s.z.string(),username:s.z.string()}),Zf=s.z.object({username:s.z.string(),password:s.z.string()}),Vf=s.z.object({token:s.z.string(),user:Gf}),ci="/auth/login",Jf=3;let Kf=class{constructor(t,e){c(this,"token"),c(this,"client"),c(this,"credentials"),c(this,"authenticating"),c(this,"authenticated"),c(this,"user"),c(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(ci)){this.authenticating==null&&(this.authenticating=new Promise((o,l)=>{this.client.send(ci,this.credentials,Zf,Vf).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(l)}));const a=await this.authenticating;if(a!=null)return[e,a]}e.params.Authorization=`Bearer ${this.token}`;const[n,i]=await r(e);return kn.matches(i)&&this.retryCount<Jf?(this.authenticated=!1,this.authenticating=void 0,this.retryCount+=1,t(e,r)):(this.retryCount=0,[n,i])};return t}};const Hf=["disconnected","connecting","connected","failed"],Xf=s.z.enum(Hf),Qf=s.z.object({status:Xf,error:s.z.instanceof(Error).optional(),message:s.z.string().optional(),clusterKey:s.z.string()}),ed=s.z.object({clusterKey:s.z.string()}),Qa={clusterKey:"",status:"disconnected",error:void 0,message:"Disconnected"},Or=class eo{constructor(e,r=I.seconds(30),n){c(this,"_state"),c(this,"pollFrequency",I.seconds(30)),c(this,"client"),c(this,"name"),c(this,"interval"),c(this,"onChangeHandlers",[]),this._state={...Qa},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,i]=await this.client.send(eo.ENDPOINT,{},s.z.object({}),ed);if(i!=null)throw i;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)}};c(Or,"ENDPOINT","/connectivity/check"),c(Or,"DEFAULT",Qa),c(Or,"connectionStateZ",Qf);let to=Or;const td=s.z.object({keys:Pe.array().optional(),names:s.z.string().array().optional(),bounds:oe.z}),rd=s.z.object({}),nd="/frame/delete";class sd{constructor(e){c(this,"client"),this.client=e}async delete(e){await v(this.client,nd,e,td,rd)}}const li=t=>{const e=N(t);return e.length===0?null:typeof e[0]=="number"||!isNaN(parseInt(e[0]))?"key":"name"},ui=(t,e)=>{const r=N(t);if(r.length===e.length)return;const n=li(t);throw li===null?new G("[Frame] - channel keys or names must be provided when constructing a frame."):new G(`[Frame] - ${n}s and arrays must be the same length.
34
+ Got ${r.length} ${n}s and ${e.length} arrays.`)};let ye=class Ve{constructor(e=[],r=[]){if(c(this,"columns",[]),c(this,"series",[]),e instanceof Ve){this.columns=e.columns,this.series=e.series;return}if(e instanceof Map){e.forEach((n,i)=>this.push(i,...N(n)));return}if(typeof e=="object"&&!Array.isArray(e)){if("keys"in e&&"series"in e){const n=e,i=n.series.map(a=>no(a));ui(n.keys,i),n.keys.forEach((a,o)=>this.push(a,i[o]))}else Object.entries(e).forEach(([n,i])=>{const a=parseInt(n);if(isNaN(a))this.push(n,...N(i));else return this.push(a,...N(i))});return}if(Array.isArray(e)||["string","number"].includes(typeof e)){const n=N(r),i=N(e);ui(i,n),n.forEach((a,o)=>this.push(i[o],a));return}throw new G(`[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 ge("colType is not key");return this.columns??[]}get uniqueKeys(){return ti(this.keys)}get names(){if(this.colType==="key")throw new ge("colType is not name");return this.columns??[]}get uniqueNames(){return ti(this.names)}get uniqueColumns(){return this.colType==="key"?this.uniqueKeys:this.uniqueNames}toPayload(){return{series:this.series.map(e=>so(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 oe.ZERO;const n=E.min(...this.series.map(a=>a.timeRange.start)),i=E.max(...this.series.map(a=>a.timeRange.end));return new oe(n,i)}const r=this.get(e);return r==null?oe.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 jh(this.series.filter((r,n)=>this.columns[n]===e))}push(e,...r){if(e instanceof Ve){if(this.colType!==null&&e.colType!==this.colType)throw new G("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 G("keyVariant must match");if(typeof e!="string"&&this.colType==="name")throw new G("keyVariant must match");this.columns.push(...Array.from({length:r.length},()=>e))}}concat(e){return new Ve([...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 Ve;return this.forEach((n,i,a)=>r.push(...e(n,i,a))),r}forEach(e){this.columns.forEach((r,n)=>{const i=this.series[n];e(r,i,n)})}at(e,r=!1){const n={};return this.uniqueColumns.forEach(i=>{n[i]=this.get(i).at(e,r)}),n}filter(e){const r=new Ve;return this.columns.forEach((n,i)=>{const a=this.series[i];e(n,a,i)&&r.push(n,a)}),r}get byteLength(){return new Et(this.series.reduce((e,r)=>e.add(r.byteLength),Et.ZERO))}get length(){return this.series.reduce((e,r)=>e+r.length,0)}};const ro=s.z.object({timeRange:oe.z.optional(),alignment:s.z.bigint().or(s.z.string().transform(t=>BigInt(t))).optional(),dataType:A.z,data:s.z.string().transform(t=>new Uint8Array(atob(t).split("").map(e=>e.charCodeAt(0))).buffer)}),qr=s.z.object({keys:s.z.union([s.z.null().transform(()=>[]),s.z.number().array().optional().default([])]),series:s.z.union([s.z.null().transform(()=>[]),ro.array().optional().default([])])}),no=t=>{const{dataType:e,data:r,timeRange:n,alignment:i}=t;return new Fe({data:r,dataType:e,timeRange:n,glBufferUsage:"static",alignment:i})},so=t=>({timeRange:t._timeRange,dataType:t.dataType,data:new Uint8Array(t.data.buffer),alignment:t.alignment});class Fr{constructor(e){c(this,"adapter"),c(this,"retriever"),c(this,"keys"),this.retriever=e,this.adapter=null,this.keys=[]}static async open(e,r){const n=new Fr(e);return await n.update(r),n}async update(e){const{variant:r,normalized:n}=je(e);if(r==="keys"){this.adapter=null,this.keys=n;return}const i=await this.retriever.retrieve(n),a=new Map;this.adapter=a,n.forEach(o=>{const l=i.find(u=>u.name===o);if(l==null)throw new Error(`Channel ${o} not found`);a.set(l.key,l.name)}),this.keys=Array.from(this.adapter.keys())}adapt(e){if(this.adapter==null)return e;const r=this.adapter;return e.map((n,i)=>{if(typeof n=="number"){const a=r.get(n);if(a==null)throw new Error(`Channel ${n} not found`);return[a,i]}return[n,i]})}}class rs{constructor(e){c(this,"adapter"),c(this,"retriever"),c(this,"keys"),this.retriever=e,this.adapter=null,this.keys=[]}static async open(e,r){const n=new rs(e);return await n.update(r),n}async update(e){const r=await Wa(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 G(`
37
+ Received a single channel name or key but no series.
38
+ `);if(Array.isArray(r)){if(r.some(u=>u instanceof Fe||Array.isArray(u)))throw new G(`
39
+ Received a single channel name or key but multiple series.
40
+ `);r=r}const o=await this.fetchChannel(e),l=new Fe({data:r,dataType:o.dataType});return new ye(o.key,l)}if(Array.isArray(e)){if(r==null)throw new G(`
41
+ Received an array of channel names or keys but no series.
42
+ `);if(!Array.isArray(r))throw new G(`
43
+ Received an array of channel names or keys but no array of series.
44
+ `);const o=[],l=[];for(let u=0;u<e.length;u++){const f=await this.fetchChannel(e[u]);if(u>=r.length)throw new G(`
45
+ Received an array of channel names or keys but not enough series.
46
+ `);const w=new Fe({data:r[u],dataType:f.dataType});o.push(f.key),l.push(w)}return new ye(o,l)}if(e instanceof ye||e instanceof Map){const o=new ye(e);if(this.adapter==null)return o;let l=[];return l=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 G(`
47
+ Channel ${u} was not provided in the list of channels when opening the writer
48
+ `);return w}),new ye(l,o.series)}const n=[],i=[],a=Object.entries(e);for(let o=0;o<a.length;o++){const[l,u]=a[o],f=await this.fetchChannel(l),w=new Fe({data:u,dataType:f.dataType});n.push(f.key),i.push(w)}return new ye(n,i)}}class ns{constructor(e,r){c(this,"name"),c(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(De.matches(r))return;throw r}}}closeSend(){this.stream.closeSend()}send(e){const r=this.stream.send(e);if(r!=null)throw r}}const $n=new I(-1);var ss=(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))(ss||{}),io=(t=>(t[t.None=0]="None",t[t.Ack=1]="Ack",t[t.Data=2]="Data",t))(io||{});const id=s.z.object({command:s.z.nativeEnum(ss),span:I.z.optional(),bounds:oe.z.optional(),stamp:E.z.optional(),keys:s.z.number().array().optional(),chunkSize:s.z.number().optional()}),ad=s.z.object({variant:s.z.nativeEnum(io),ack:s.z.boolean(),command:s.z.nativeEnum(ss),error:$t.optional().nullable(),frame:qr.optional()}),ao=class Mn{constructor(e,r){c(this,"stream"),c(this,"adapter"),c(this,"value"),this.stream=new ns("Iterator",e),this.value=new ye,this.adapter=r}static async _open(e,r,n,i,a={}){const o=await Fr.open(n,r),l=await i.stream(Mn.ENDPOINT,id,ad),u=new Mn(l,o);return await u.execute({command:0,keys:o.keys,bounds:new oe(e),chunkSize:a.chunkSize??1e5}),u}async next(e=$n){return await this.execute({command:1,span:new I(e)})}async prev(e=$n){return await this.execute({command:2,span:new I(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 E(e)})}async seekGE(e){return await this.execute({command:6,stamp:new E(e)})}async valid(){return await this.execute({command:7})}async close(){await this.stream.closeAndAck()}[Symbol.asyncIterator](){return new od(this)}async execute(e){for(this.stream.send(e),this.value=new ye;;){const r=await this.stream.receive();if(r.variant===1)return r.ack;this.value.push(this.adapter.adapt(new ye(r.frame)))}}};c(ao,"ENDPOINT","/frame/iterate");let oo=ao;class od{constructor(e){c(this,"iter"),c(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 cd=s.z.object({start:E.z.optional(),keys:s.z.number().array()}),ld=s.z.object({frame:qr,error:$t.optional().nullable()}),ud="/frame/stream";class _r{constructor(e,r){c(this,"stream"),c(this,"adapter"),this.stream=new ns("Streamer",e),this.adapter=r}get keys(){return this.adapter.keys}static async _open(e,r,{channels:n,from:i}){const a=await Fr.open(e,n),o=await r.stream(ud,cd,ld),l=new _r(o,a);return o.send({start:new E(i),keys:a.keys}),l}async next(){try{return{done:!1,value:await this.read()}}catch(e){if(De.matches(e))return{done:!0,value:void 0};throw e}}async read(){return this.adapter.adapt(new ye((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 Dt extends Cn.Observer{constructor(e,r){super(r),c(this,"streamer"),c(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 is=(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))(is||{}),It=(t=>(t[t.PersistStream=1]="PersistStream",t[t.PersistOnly=2]="PersistOnly",t[t.StreamOnly=3]="StreamOnly",t))(It||{});const hd=new I(-1),fd=s.z.object({start:E.z.optional(),controlSubject:Ke.subjectZ.optional(),keys:s.z.number().array().optional(),authorities:Ke.Authority.z.array().optional(),mode:s.z.nativeEnum(It).optional(),errOnUnauthorized:s.z.boolean().optional(),enableAutoCommit:s.z.boolean().optional(),autoIndexPersistInterval:I.z.optional()}),dd=s.z.object({command:s.z.nativeEnum(is),config:fd.optional(),frame:qr.optional()}),yd=s.z.object({ack:s.z.boolean(),command:s.z.nativeEnum(is),error:$t.optional().nullable()});var rt;let co=(rt=class{constructor(t,e){c(this,"stream"),c(this,"adapter"),this.stream=new ns("Writer",t),this.adapter=e}static async _open(t,e,{channels:r,start:n=E.now(),authorities:i=Ke.Authority.Absolute,controlSubject:a,mode:o=1,errOnUnauthorized:l=!1,enableAutoCommit:u=!1,autoIndexPersistInterval:f=I.SECOND}){const w=await rs.open(t,r),h=await e.stream(rt.ENDPOINT,dd,yd),M=new rt(h,w);return await M.execute({command:0,config:{start:new E(n),keys:w.keys,controlSubject:a,authorities:N(i),mode:o,errOnUnauthorized:l,enableAutoCommit:u,autoIndexPersistInterval:f}}),M}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?Vn(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()}},c(rt,"ENDPOINT","/frame/write"),rt),lo=class{constructor(t,e,r){c(this,"streamClient"),c(this,"retriever"),c(this,"deleter"),this.streamClient=t,this.retriever=r,this.deleter=new sd(e)}async openIterator(t,e,r){return await oo._open(t,e,this.retriever,this.streamClient,r)}async openWriter(t){return(Array.isArray(t)||typeof t!="object")&&(t={channels:t}),await co._open(this.retriever,this.streamClient,t)}async openStreamer(t){return(Array.isArray(t)||typeof t!="object")&&(t={channels:t}),await _r._open(this.retriever,this.streamClient,t)}async write(t,e,r){if(r==null){const i=e,a=await this.openWriter({start:t,channels:Object.keys(i),mode:It.PersistOnly});try{await a.write(i),await a.commit()}finally{await a.close()}return}const n=await this.openWriter({start:t,channels:e,mode:It.PersistOnly,errOnUnauthorized:!0,enableAutoCommit:!0,autoIndexPersistInterval:I.MAX});try{await n.write(e,r)}finally{await n.close()}}async read(t,e){const{single:r}=je(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 ye;try{for await(const i of r)n.push(i)}finally{await r.close()}return n}async delete(t,e){const{normalized:r,variant:n}=je(t);return n==="keys"?await this.deleter.delete({keys:r,bounds:e}):await this.deleter.delete({names:r,bounds:e})}};const gd=Object.freeze(Object.defineProperty({__proto__:null,ALWAYS_INDEX_PERSIST_ON_AUTO_COMMIT:hd,AUTO_SPAN:$n,Client:lo,Frame:ye,Iterator:oo,ObservableStreamer:Dt,Streamer:_r,Writer:co,WriterMode:It,frameZ:qr,series:ro,seriesFromPayload:no,seriesToPayload:so},Symbol.toStringTag,{value:"Module"})),pd=Ke.Authority,md=Ke.stateZ(s.z.number()),wd=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 uo extends Dt{constructor(e){super(e,r=>{const n=this.ecd.decode(r.series[0].buffer);return this.merge(n),[n.transfers,!0]}),c(this,"states"),c(this,"ecd"),this.states=new Map,this.ecd=new He.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 bd="sy_node_1_control";let ho=class{constructor(t){c(this,"framer"),this.framer=t}async openStateTracker(){const t=await this.framer.openStreamer(bd);return new uo(t)}};const vd=Object.freeze(Object.defineProperty({__proto__:null,Authority:pd,Client:ho,StateTracker:uo,stateZ:md,transferString:wd},Symbol.toStringTag,{value:"Module"}));let Od=class{constructor(t,e,r){c(this,"tasks"),c(this,"racks"),c(this,"devices"),this.tasks=t,this.racks=e,this.devices=r}};const Pt=s.z.number(),as=s.z.object({key:Pt,name:s.z.string()}),Td=as.partial({key:!0}),ln="/hardware/rack/retrieve",Sd="/hardware/rack/create",zd="/hardware/rack/delete",un=s.z.object({keys:Pt.array().optional(),names:s.z.string().array().optional(),search:s.z.string().optional(),offset:s.z.number().optional(),limit:s.z.number().optional()}),hn=s.z.object({racks:Xe(as)}),Nd=s.z.object({racks:Td.array()}),Ed=s.z.object({racks:as.array()}),Id=s.z.object({keys:Pt.array()}),Ad=s.z.object({});let kd=class{constructor(t,e,r){c(this,"type","rack"),c(this,"client"),c(this,"frameClient"),c(this,"tasks"),this.client=t,this.frameClient=e,this.tasks=r}async delete(t){await v(this.client,zd,{keys:N(t)},Id,Ad)}async create(t){const e=!Array.isArray(t),r=await v(this.client,Sd,{racks:N(t)},Nd,Ed),n=this.sugar(r.racks);return e?n[0]:n}async search(t){const e=await v(this.client,ln,{search:t},un,hn);return this.sugar(e.racks)}async page(t,e){const r=await v(this.client,ln,{offset:t,limit:e},un,hn);return this.sugar(r.racks)}async retrieve(t){const{variant:e,normalized:r,single:n}=Lr(t,{string:"names",number:"keys"}),i=await v(this.client,ln,{[e]:r},un,hn),a=this.sugar(i.racks);return Yr("Rack",t,a,n),n?a[0]:a}sugar(t){return t.map(({key:e,name:r})=>new xd(e,r,this.tasks))}};class xd{constructor(e,r,n){c(this,"key"),c(this,"name"),c(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 Bt=async(t,e,r,n)=>{const i=await t.openStreamer([e,r]),a=o=>{const l=[];return r!=null&&l.push(...o.get(r).series.flatMap(u=>n("delete",u))),e!=null&&l.push(...o.get(e).series.flatMap(u=>n("set",u))),[l,l.length>0]};return new Dt(i,a)},Cd="sy_device_set",Rd="sy_device_delete",fn="/hardware/device/retrieve",jd="/hardware/device/create",$d="/hardware/device/delete",os=s.z.string(),Wr=s.z.object({key:os,rack:Pt,name:s.z.string(),make:s.z.string(),model:s.z.string(),location:s.z.string(),configured:s.z.boolean().optional(),properties:s.z.record(s.z.unknown()).or(s.z.string().transform(t=>t===""?{}:He.JSON_ECD.decodeString(t)))}),Md=Wr.extend({properties:s.z.unknown().transform(t=>He.JSON_ECD.encodeString(t))}),Dd=s.z.object({devices:Md.array()}),Pd=s.z.object({devices:Wr.array()}),Bd=s.z.object({keys:os.array()}),Ud=s.z.object({}),dn=s.z.object({search:s.z.string().optional(),limit:s.z.number().optional(),offset:s.z.number().optional(),keys:os.array().optional(),names:s.z.string().array().optional(),makes:s.z.string().array().optional()}),yn=s.z.object({devices:Xe(Wr)});let Ld=class{constructor(t,e){c(this,"type","device"),c(this,"client"),c(this,"frameClient"),this.client=t,this.frameClient=e}async retrieve(t,e){const r=!Array.isArray(t),n=await v(this.client,fn,{keys:N(t),...e},dn,yn);return Yr("Device",t,n.devices,r),r?n.devices[0]:n.devices}async search(t,e){return(await v(this.client,fn,{search:t,...e},dn,yn)).devices}async page(t,e,r){return(await v(this.client,fn,{offset:t,limit:e,...r},dn,yn)).devices}async create(t){const e=!Array.isArray(t),r=await v(this.client,jd,{devices:N(t)},Dd,Pd);return e?r.devices[0]:r.devices}async delete(t){await v(this.client,$d,{keys:N(t)},Bd,Ud)}async openDeviceTracker(){return await Bt(this.frameClient,Cd,Rd,Yd)}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 Yd=(t,e)=>t==="delete"?e.toStrings().map(r=>({variant:t,key:r,value:void 0})):e.parseJSON(Wr).map(r=>({variant:t,key:r.key,value:r})),St="sy_task_state",hi="sy_task_cmd",Ut=s.z.union([s.z.string(),s.z.bigint().transform(t=>t.toString()),s.z.number().transform(t=>t.toString())]),Rr=s.z.object({task:Ut,variant:s.z.string(),key:s.z.string().optional(),details:s.z.record(s.z.unknown()).or(s.z.string().transform(t=>t===""?{}:JSON.parse(t))).or(s.z.array(s.z.unknown())).or(s.z.null())}),cs=s.z.object({key:Ut,name:s.z.string(),type:s.z.string(),internal:s.z.boolean().optional(),config:s.z.record(s.z.unknown()).or(s.z.string().transform(t=>t===""?{}:He.JSON_ECD.decodeString(t))),state:Rr.optional().nullable()}),qd=cs.omit({key:!0}).extend({key:Ut.transform(t=>t.toString()).optional(),config:s.z.unknown().transform(t=>He.JSON_ECD.encodeString(t))});s.z.object({task:Ut,type:s.z.string(),key:s.z.string(),args:s.z.record(s.z.unknown()).or(s.z.string().transform(t=>t===""?{}:JSON.parse(t)))});class Fd{constructor(e,r,n,i,a,o=!1,l){c(this,"key"),c(this,"name"),c(this,"internal"),c(this,"type"),c(this,"config"),c(this,"state"),c(this,"frameClient"),this.key=e,this.name=r,this.type=n,this.config=i,this.internal=o,l!==null&&(this.state=l),this.frameClient=a}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(hi),i=Ih.id();return await n.write(hi,[{task:this.key,type:e,key:i,args:r}]),await n.close(),i}async executeCommandSync(e,r,n){const i=await this.frameClient.openStreamer(St),a=await this.executeCommand(e,r);let o;const l=new Promise(u=>setTimeout(()=>u(!1),new I(n).milliseconds));for(;;){const u=await Promise.any([i.read(),l]);if(u===!1)throw new Error("Command timed out");const f=Rr.safeParse(u.at(-1).sy_task_state);if(f.success){if(o=f.data,o.key===a)break}else console.error(f.error)}return i.close(),o}async openStateObserver(){return new Dt(await this.frameClient.openStreamer(St),e=>{const r=e.get(St);if(r.length===0)return[null,!1];const n=Rr.safeParse(r.at(-1));if(!n.success)return[null,!1];const i=n.data;return i.task!==this.key?[null,!1]:[i,!0]})}}const _d=s.z.object({rack:Pt.optional(),keys:s.z.string().array().optional(),names:s.z.string().array().optional(),offset:s.z.number().optional(),limit:s.z.number().optional(),includeState:s.z.boolean().optional()}),Wd=s.z.object({tasks:Xe(cs)}),Gd="/hardware/task/retrieve",Zd="/hardware/task/create",Vd="/hardware/task/delete",Jd=s.z.object({tasks:qd.array()}),Kd=s.z.object({tasks:cs.array()}),Hd=s.z.object({keys:Ut.array()}),Xd=s.z.object({});let Qd=class{constructor(t,e){c(this,"type","task"),c(this,"client"),c(this,"frameClient"),this.client=t,this.frameClient=e}async create(t){const e=!Array.isArray(t),r=await v(this.client,Zd,{tasks:N(t)},Jd,Kd),n=this.sugar(r.tasks);return e?n[0]:n}async delete(t){await v(this.client,Vd,{keys:N(t)},Hd,Xd)}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:i}=Lr(t,{number:"rack",string:"keys"},{convertNumericStrings:!1}),a={...e};i==="rack"?a.rack=t:a.keys=n;const o=await this.execRetrieve(a),l=this.sugar(o);return r&&i!=="rack"?l[0]:l}async retrieveByName(t,e){const r=await this.execRetrieve({names:[t],rack:e});return Yr("Task",t,r,!0),this.sugar(r)[0]}async execRetrieve(t){return(await v(this.client,Gd,t,_d,Wd)).tasks}sugar(t){return t.map(({key:e,name:r,type:n,config:i,state:a,internal:o})=>new Fd(e,r,n,i,this.frameClient,o,a))}async openTracker(){return await Bt(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 Dt(await this.frameClient.openStreamer(St),t=>{const e=t.get(St);if(e.length===0)return[null,!1];const r=Rr.safeParse(e.at(-1));return r.success?[r.data,!0]:[null,!1]})}};const Lt=s.z.string().uuid(),Gr=s.z.object({key:Lt,name:s.z.string().min(1),color:s.z.string()}),ey=s.z.object({keys:Lt.array().optional(),for:Ee.optional(),search:s.z.string().optional(),offset:s.z.number().optional(),limit:s.z.number().optional()}),ty=s.z.object({labels:Gr.array().optional().default([])});var Vt;let ry=(Vt=class{constructor(t){c(this,"client"),this.client=t}async retrieve(t){const e=N(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(Vt.ENDPOINT,t,ey,ty);if(r!=null)throw r;return e.labels}},c(Vt,"ENDPOINT","/label/retrieve"),Vt);const ny=Gr.extend({key:Lt.optional()}),sy=s.z.object({labels:ny.array()}),iy=s.z.object({labels:Gr.array()}),ay=s.z.object({keys:Lt.array()}),fo=s.z.object({id:Ee,labels:Lt.array()}),oy=fo,gn=s.z.object({}),cy="/label/create",ly="/label/delete",uy="/label/set",hy="/label/remove";let fy=class{constructor(t){c(this,"client"),this.client=t}async create(t){return(await v(this.client,cy,{labels:N(t)},sy,iy)).labels}async delete(t){await v(this.client,ly,{keys:N(t)},ay,gn)}async set(t,e){await v(this.client,uy,{id:t,labels:e},fo,gn)}async remove(t,e){await v(this.client,hy,{id:t,labels:e},oy,gn)}};const dy="sy_label_set",yy="sy_label_delete";let gy=class{constructor(t,e){c(this,"type","label"),c(this,"retriever"),c(this,"writer"),c(this,"frameClient"),this.writer=new fy(t),this.retriever=new ry(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 Bt(this.frameClient,dy,yy,py)}};const py=(t,e)=>t==="delete"?e.toUUIDs().map(r=>({variant:t,key:r})):e.parseJSON(Gr).map(r=>({variant:t,key:r.key,value:r})),ce=s.z.string().uuid(),Qe=s.z.object({key:ce,name:s.z.string().min(1),timeRange:oe.z,color:s.z.string().optional()}),yo=Qe.extend({key:s.z.string().uuid().optional()}),go=t=>{const e=N(t);if(e.length===0)throw new Error("Range params must not be empty");const r=ce.safeParse(e[0]).success;return{single:!Array.isArray(t),variant:r?"keys":"names",normalized:e,actual:t}},my=s.z.object({}),wy=s.z.object({range:Qe}),by=s.z.object({range:ce}),vy=s.z.object({range:ce}),Oy=s.z.object({}),Ty="/range/set-active",Sy="/range/retrieve-active",zy="/range/clear-active";class Ny{constructor(e){c(this,"client"),this.client=e}async setActive(e){await v(this.client,Ty,{range:e},by,my)}async retrieveActive(){const[e,r]=await this.client.send(Sy,{},s.z.object({}),wy);if(pe.matches(r))return null;if(r!=null)throw r;return e.range}async clearActive(e){await v(this.client,zy,{range:e},vy,Oy)}}const Ey="sy_range_alias_set",Iy="sy_range_alias_delete",Ay=s.z.object({range:ce,aliases:s.z.string().array()}),ky=s.z.object({aliases:s.z.record(s.z.string(),Pe)}),xy=s.z.object({range:ce,aliases:s.z.record(Pe.or(s.z.string()),s.z.string())}),Cy=s.z.unknown(),Ry=s.z.object({range:ce,channels:Pe.array()}),jy=s.z.unknown(),$y=s.z.object({range:ce}),My=s.z.object({aliases:s.z.record(s.z.string(),s.z.string())}),pt=class mt{constructor(e,r,n){c(this,"frameClient"),c(this,"cache",new Map),c(this,"client"),c(this,"rangeKey"),this.rangeKey=e,this.cache=new Map,this.client=n,this.frameClient=r}async resolve(e){const r=[],n=typeof e=="string",i={};if(n){const o=this.cache.get(e);if(o!=null)return o;r.push(e)}else e.forEach(o=>{const l=this.cache.get(o);l!=null?i[o]=l:r.push(o)});if(r.length===0)return i;const a=await v(this.client,mt.RESOLVE_ENDPOINT,{range:this.rangeKey,aliases:r},Ay,ky);return Object.entries(a.aliases).forEach(([o,l])=>this.cache.set(o,l)),n?a.aliases[r[0]]:{...i,...a.aliases}}async set(e){await v(this.client,mt.SET_ENDPOINT,{range:this.rangeKey,aliases:e},xy,Cy)}async list(){return(await v(this.client,mt.LIST_ENDPOINT,{range:this.rangeKey},$y,My)).aliases}async delete(e){await v(this.client,mt.DELETE_ENDPOINT,{range:this.rangeKey,channels:e},Ry,jy)}async openChangeTracker(){return await Bt(this.frameClient,Ey,Iy,Uy(this.rangeKey))}};c(pt,"SET_ENDPOINT","/range/alias/set"),c(pt,"RESOLVE_ENDPOINT","/range/alias/resolve"),c(pt,"LIST_ENDPOINT","/range/alias/list"),c(pt,"DELETE_ENDPOINT","/range/alias/delete");let Dy=pt;const Py=s.z.object({range:ce,channel:Pe,alias:s.z.string()}),By="---",Uy=t=>(e,r)=>e==="delete"?r.toStrings().filter(n=>n.split(By)[0]===t).map(n=>({variant:e,key:n,value:void 0})):r.parseJSON(Py).map(n=>({variant:e,key:n.alias,value:n})),Ly=s.z.object({range:ce,keys:s.z.string().array()}),Yy=s.z.object({pairs:s.z.record(s.z.string(),s.z.string())}),qy=s.z.object({range:ce,pairs:s.z.record(s.z.string(),s.z.string())}),Fy=s.z.object({range:ce,keys:s.z.string().array()}),Tr=class Sr{constructor(e,r){c(this,"rangeKey"),c(this,"client"),this.rangeKey=e,this.client=r}async get(e){const[r,n]=await this.client.send(Sr.GET_ENDPOINT,{range:this.rangeKey,keys:N(e)},Ly,Yy);if(n!=null)throw n;return Array.isArray(e)?r.pairs:r.pairs[e]}async list(){return this.get([])}async set(e,r=""){await v(this.client,Sr.SET_ENDPOINT,{range:this.rangeKey,pairs:Hn(e)?e:{[e]:r}},qy,s.z.unknown())}async delete(e){await v(this.client,Sr.DELETE_ENDPOINT,{range:this.rangeKey,keys:N(e)},Fy,s.z.unknown())}};c(Tr,"GET_ENDPOINT","/range/kv/get"),c(Tr,"SET_ENDPOINT","/range/kv/set"),c(Tr,"DELETE_ENDPOINT","/range/kv/delete");let _y=Tr;const pn=t=>new me({type:"range",key:t});class po{constructor(e,r=oe.ZERO,n,i,a,o,l,u,f){c(this,"key"),c(this,"name"),c(this,"kv"),c(this,"timeRange"),c(this,"color"),c(this,"channels"),c(this,"aliaser"),c(this,"frameClient"),c(this,"labelClient"),this.key=n,this.name=e,this.timeRange=r,this.frameClient=a,this.color=i,this.kv=o,this.aliaser=l,this.channels=u,this.labelClient=f}async setAlias(e,r){const n=await this.channels.retrieve(e);if(n.length===0)throw new pe(`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(pn(this.key))}async addLabel(...e){await this.labelClient.label(pn(this.key),e)}async removeLabel(...e){await this.labelClient.removeLabels(pn(this.key),e)}}const Wy=s.z.object({keys:ce.array().optional(),names:s.z.array(s.z.string()).optional(),term:s.z.string().optional(),overlapsWith:oe.z.optional()}),Gy="/range/retrieve",Zy=s.z.object({ranges:Xe(Qe)});let mo=class{constructor(t,e,r,n,i){c(this,"type","range"),c(this,"frameClient"),c(this,"writer"),c(this,"unaryClient"),c(this,"channels"),c(this,"active"),c(this,"labelClient"),this.frameClient=t,this.writer=e,this.unaryClient=r,this.channels=n,this.active=new Ny(r),this.labelClient=i}async create(t){const e=!Array.isArray(t),r=this.sugar(await this.writer.create(N(t)));return e?r[0]:r}async rename(t,e){await this.writer.rename(t,e)}async delete(t){await this.writer.delete(N(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 oe(t)});const{single:e,actual:r,variant:n,normalized:i}=go(t),a=await this.execRetrieve({[n]:i});if(!e)return a;if(a.length===0)throw new kr(`range matching ${r} not found`);if(a.length>1)throw new xr(`multiple ranges matching ${r} found`);return a[0]}async execRetrieve(t){const{ranges:e}=await v(this.unaryClient,Gy,t,Wy,Zy);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 po(e.name,e.timeRange,e.key,e.color,this.frameClient,new _y(e.key,this.unaryClient),new Dy(e.key,this.frameClient,this.unaryClient),this.channels,this.labelClient))}async openTracker(){return await Bt(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(Qe)).map(r=>({variant:t,key:r.key,value:r})))}};const Vy=s.z.object({ranges:Qe.array()}),Jy=s.z.object({ranges:yo.array()}),Ky=s.z.object({keys:ce.array()}),Hy=s.z.object({}),Xy=s.z.object({key:ce,name:s.z.string()}),Qy=s.z.object({}),eg="/range/create",tg="/range/delete",rg="/range/rename";let wo=class{constructor(t){c(this,"client"),this.client=t}async rename(t,e){await v(this.client,rg,{key:t,name:e},Xy,Qy)}async create(t){return(await v(this.client,eg,{ranges:t},Jy,Vy)).ranges}async delete(t){await v(this.client,tg,{keys:t},Ky,Hy)}};const ng=Object.freeze(Object.defineProperty({__proto__:null,Client:mo,Range:po,Writer:wo,analyzeParams:go,keyZ:ce,newPayloadZ:yo,payloadZ:Qe},Symbol.toStringTag,{value:"Module"})),sg="/api/v1/";class ig{constructor(e,r=!1){c(this,"url"),c(this,"unary"),c(this,"stream"),c(this,"secure"),this.secure=r,this.url=e.child(sg);const n=new He.JSONEncoderDecoder;this.unary=new ju(this.url,n,this.secure),this.stream=new qu(this.url,n,this.secure)}use(...e){this.unary.use(...e),this.stream.use(...e)}}const ls=s.z.string().uuid(),us=s.z.object({key:s.z.string(),name:s.z.string(),data:Xn.or(s.z.string().transform(t=>JSON.parse(t)))}),ag=s.z.object({keys:s.z.string().array()}),og=s.z.object({linePlots:us.array()});let cg=class{constructor(t){c(this,"ENDPOINT","/workspace/lineplot/retrieve"),c(this,"client"),this.client=t}async retrieve(t){const e=N(t);return(await v(this.client,this.ENDPOINT,{keys:e},ag,og)).linePlots}};const Ge=s.z.string().uuid(),bo=t=>JSON.parse(t),vo=s.z.object({name:s.z.string(),key:Ge,layout:Xn.or(s.z.string().transform(t=>bo(t)))}),Oo=vo.omit({layout:!0}).extend({layout:s.z.string().transform(t=>bo(t))}),lg=us.partial({key:!0}).transform(t=>({...t,data:JSON.stringify(t.data)})),ug=s.z.object({workspace:Ge,linePlots:lg.array()}),hg=s.z.object({linePlots:us.array()}),fg=s.z.object({keys:ls.array()}),dg=s.z.object({}),yg=s.z.object({key:ls,name:s.z.string()}),gg=s.z.object({}),pg=s.z.object({key:ls,data:s.z.string()}),mg=s.z.object({}),wg="/workspace/lineplot/create",bg="/workspace/lineplot/delete",vg="/workspace/lineplot/rename",Og="/workspace/lineplot/set-data";let Tg=class{constructor(t){c(this,"client"),this.client=t}async create(t,e){const r={...e,data:JSON.stringify(e.data)};return(await v(this.client,wg,{workspace:t,linePlots:[r]},ug,hg)).linePlots[0]}async delete(t){const e=N(t);await v(this.client,bg,{keys:e},fg,dg)}async rename(t,e){await v(this.client,vg,{key:t,name:e},yg,gg)}async setData(t,e){await v(this.client,Og,{key:t,data:JSON.stringify(e)},pg,mg)}},Sg=class{constructor(t){c(this,"writer"),c(this,"retriever"),this.writer=new Tg(t),this.retriever=new cg(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 zg=s.z.object({keys:Ge.array().optional(),search:s.z.string().optional(),author:s.z.string().uuid().optional(),offset:s.z.number().optional(),limit:s.z.number().optional()}),Ng=s.z.object({workspaces:Xe(Oo)});var Jt;let Eg=(Jt=class{constructor(t){c(this,"client"),this.client=t}async retrieve(t){const e=N(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 v(this.client,Jt.ENDPOINT,t,zg,Ng)).workspaces}},c(Jt,"ENDPOINT","/workspace/retrieve"),Jt);const Zr=s.z.string().uuid(),Ig=s.z.object({key:s.z.string(),name:s.z.string(),data:Xn.or(s.z.string().transform(t=>JSON.parse(t))),snapshot:s.z.boolean()}),hs=s.z.object({key:s.z.string(),name:s.z.string(),snapshot:s.z.boolean(),data:s.z.string().transform(t=>JSON.parse(t))}),Ag=s.z.object({keys:s.z.string().array()}),kg=s.z.object({schematics:hs.array()});class xg{constructor(e){c(this,"ENDPOINT","/workspace/schematic/retrieve"),c(this,"client"),this.client=e}async retrieve(e){return(await v(this.client,this.ENDPOINT,{keys:N(e)},Ag,kg)).schematics}}const Cg=Ig.partial({key:!0,snapshot:!0}).transform(t=>({...t,data:JSON.stringify(t.data)})),Rg=s.z.object({workspace:Ge,schematics:Cg.array()}),jg=s.z.object({schematics:hs.array()}),$g=s.z.object({keys:Zr.array()}),Mg=s.z.object({}),Dg=s.z.object({key:Zr,name:s.z.string()}),fi=s.z.object({}),Pg=s.z.object({key:Zr,data:s.z.string()});s.z.object({});const Bg=s.z.object({key:Zr,name:s.z.string(),snapshot:s.z.boolean()}),Ug=s.z.object({schematic:hs}),Lg="/workspace/schematic/create",Yg="/workspace/schematic/delete",qg="/workspace/schematic/rename",Fg="/workspace/schematic/set-data",_g="/workspace/schematic/copy";let Wg=class{constructor(t){c(this,"client"),this.client=t}async create(t,e){const r={...e,data:JSON.stringify(e.data)};return(await v(this.client,Lg,{workspace:t,schematics:[r]},Rg,jg)).schematics[0]}async copy(t,e,r){return(await v(this.client,_g,{key:t,name:e,snapshot:r},Bg,Ug)).schematic}async delete(t){const e=N(t);await v(this.client,Yg,{keys:e},$g,Mg)}async rename(t,e){await v(this.client,qg,{key:t,name:e},Dg,fi)}async setData(t,e){await v(this.client,Fg,{key:t,data:JSON.stringify(e)},Pg,fi)}},Gg=class{constructor(t){c(this,"writer"),c(this,"retriever"),this.writer=new Wg(t),this.retriever=new xg(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 Zg=vo.partial({key:!0}).transform(t=>({...t,layout:JSON.stringify(t.layout)})),Vg=s.z.object({workspaces:Zg.array()}),Jg=s.z.object({workspaces:Oo.array()}),Kg=s.z.object({keys:Ge.array()}),Hg=s.z.object({}),Xg=s.z.object({key:Ge,name:s.z.string()}),Qg=s.z.object({}),ep=s.z.object({key:Ge,layout:s.z.string()}),tp=s.z.object({}),rp="/workspace/create",np="/workspace/delete",sp="/workspace/rename",ip="/workspace/set-layout";class ap{constructor(e){c(this,"client"),this.client=e}async create(e){return(await v(this.client,rp,{workspaces:N(e)},Vg,Jg)).workspaces}async delete(e){await v(this.client,np,{keys:N(e)},Kg,Hg)}async rename(e,r){await v(this.client,sp,{key:e,name:r},Xg,Qg)}async setLayout(e,r){await v(this.client,ip,{key:e,layout:JSON.stringify(r)},ep,tp)}}class op{constructor(e){c(this,"type","workspace"),c(this,"schematic"),c(this,"linePlot"),c(this,"retriever"),c(this,"writer"),this.schematic=new Gg(e),this.linePlot=new Sg(e),this.retriever=new Eg(e),this.writer=new ap(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 To=s.z.object({host:s.z.string({required_error:"Host is required"}).min(1,"Host is required"),port:s.z.number({required_error:"Port is required"}).or(s.z.string({required_error:"Port is required"})),username:s.z.string().optional(),password:s.z.string().optional(),connectivityPollFrequency:I.z.default(I.seconds(30)),secure:s.z.boolean().optional().default(!1),name:s.z.string().optional()});class So extends lo{constructor(e){const r=To.parse(e),{host:n,port:i,username:a,password:o,connectivityPollFrequency:l,secure:u}=r,f=new ig(new of({host:n,port:Number(i)}),u);f.use(_h);let w;if(a!=null&&o!=null){const _o=new Kf(f.unary,{username:a,password:o});f.use(_o.middleware())}const h=new es(new Qn(f.unary)),M=new Xa(f.unary,h);super(f.stream,f.unary,h),c(this,"createdAt"),c(this,"props"),c(this,"ranges"),c(this,"channels"),c(this,"auth"),c(this,"connectivity"),c(this,"ontology"),c(this,"workspaces"),c(this,"labels"),c(this,"hardware"),c(this,"control"),c(this,"transport"),this.createdAt=E.now(),this.props=r,this.auth=w,this.transport=f,this.channels=new Ha(this,h,f.unary,M),this.connectivity=new to(f.unary,l,r.name),this.control=new ho(this),this.ontology=new Rf(f.unary,this);const _=new wo(this.transport.unary);this.labels=new gy(this.transport.unary,this),this.ranges=new mo(this,_,this.transport.unary,h,this.labels),this.workspaces=new op(this.transport.unary);const re=new Ld(this.transport.unary,this),R=new Qd(this.transport.unary,this),Fo=new kd(this.transport.unary,this,R);this.hardware=new Od(R,Fo,re)}get key(){return this.createdAt.valueOf().toString()}close(){this.connectivity.stopChecking()}}c(So,"connectivity",to);const cp=Ke.Authority,Dn=(t,e,r="")=>{try{return t.parse(e)}catch(n){if(n instanceof s.z.ZodError){const i=n.errors.map(a=>a.path.length===0?a.message:`${a.path.join(".")}: ${a.message}`);throw new Error(`${r} - ${i.join(`
50
+ `)}`)}else throw n}};var lp=Object.defineProperty,up=(t,e,r)=>e in t?lp(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,K=(t,e,r)=>up(t,typeof e!="symbol"?e+"":e,r);const Pn=class zo{constructor(e,r,n="",i=!1){K(this,"_noop",!1),K(this,"key"),K(this,"path"),K(this,"serviceName"),this.key=e,this.path=r,this.serviceName=n,this._noop=i}child(e){return new zo(e,this.extendPath(e),this.serviceName,this.noop)}extendPath(e){return`${this.path}.${e}`}get noop(){return this._noop}};K(Pn,"NOOP",new Pn("","",""));let fs=Pn;const Bn=["debug","info","warn","error"],hp=t=>{const e=Bn.indexOf(t);return({level:r})=>Bn.indexOf(r)>=e},fp=t=>{const{include:e,exclude:r}=t;return({path:n})=>!(e!=null&&!e.some(i=>n.startsWith(i))||r!=null&&r.some(i=>n.startsWith(i)))},Un=class No{constructor(e={}){K(this,"meta",fs.NOOP),K(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 No({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,Kt(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,Kt(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,Kt(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,Kt(r)))}};K(Un,"NOOP",new Un);let Eo=Un;const Kt=t=>typeof t=="function"?t():t;var dp=typeof globalThis=="object"?globalThis:typeof self=="object"?self:typeof window=="object"?window:typeof global=="object"?global:{},_e="1.8.0",di=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function yp(t){var e=new Set([t]),r=new Set,n=t.match(di);if(!n)return function(){return!1};var i={major:+n[1],minor:+n[2],patch:+n[3],prerelease:n[4]};if(i.prerelease!=null)return function(l){return l===t};function a(l){return r.add(l),!1}function o(l){return e.add(l),!0}return function(l){if(e.has(l))return!0;if(r.has(l))return!1;var u=l.match(di);if(!u)return a(l);var f={major:+u[1],minor:+u[2],patch:+u[3],prerelease:u[4]};return f.prerelease!=null||i.major!==f.major?a(l):i.major===0?i.minor===f.minor&&i.patch<=f.patch?o(l):a(l):i.minor<=f.minor?o(l):a(l)}}var gp=yp(_e),pp=_e.split(".")[0],At=Symbol.for("opentelemetry.js.api."+pp),kt=dp;function ds(t,e,r,n){var i;n===void 0&&(n=!1);var a=kt[At]=(i=kt[At])!==null&&i!==void 0?i:{version:_e};if(!n&&a[t]){var o=new Error("@opentelemetry/api: Attempted duplicate registration of API: "+t);return r.error(o.stack||o.message),!1}if(a.version!==_e){var o=new Error("@opentelemetry/api: Registration of version v"+a.version+" for "+t+" does not match previously registered API v"+_e);return r.error(o.stack||o.message),!1}return a[t]=e,r.debug("@opentelemetry/api: Registered a global for "+t+" v"+_e+"."),!0}function xt(t){var e,r,n=(e=kt[At])===null||e===void 0?void 0:e.version;if(!(!n||!gp(n)))return(r=kt[At])===null||r===void 0?void 0:r[t]}function ys(t,e){e.debug("@opentelemetry/api: Unregistering a global for "+t+" v"+_e+".");var r=kt[At];r&&delete r[t]}var mp=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,a=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)a.push(i.value)}catch(l){o={error:l}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return a},wp=function(t,e,r){if(arguments.length===2)for(var n=0,i=e.length,a;n<i;n++)(a||!(n in e))&&(a||(a=Array.prototype.slice.call(e,0,n)),a[n]=e[n]);return t.concat(a||Array.prototype.slice.call(e))},bp=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 nt("debug",this._namespace,e)},t.prototype.error=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return nt("error",this._namespace,e)},t.prototype.info=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return nt("info",this._namespace,e)},t.prototype.warn=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return nt("warn",this._namespace,e)},t.prototype.verbose=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return nt("verbose",this._namespace,e)},t}();function nt(t,e,r){var n=xt("diag");if(n)return r.unshift(e),n[t].apply(n,wp([],mp(r),!1))}var fe;(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"})(fe||(fe={}));function vp(t,e){t<fe.NONE?t=fe.NONE:t>fe.ALL&&(t=fe.ALL),e=e||{};function r(n,i){var a=e[n];return typeof a=="function"&&t>=i?a.bind(e):function(){}}return{error:r("error",fe.ERROR),warn:r("warn",fe.WARN),info:r("info",fe.INFO),debug:r("debug",fe.DEBUG),verbose:r("verbose",fe.VERBOSE)}}var Op=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,a=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)a.push(i.value)}catch(l){o={error:l}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return a},Tp=function(t,e,r){if(arguments.length===2)for(var n=0,i=e.length,a;n<i;n++)(a||!(n in e))&&(a||(a=Array.prototype.slice.call(e,0,n)),a[n]=e[n]);return t.concat(a||Array.prototype.slice.call(e))},Sp="diag",Ct=function(){function t(){function e(i){return function(){for(var a=[],o=0;o<arguments.length;o++)a[o]=arguments[o];var l=xt("diag");if(l)return l[i].apply(l,Tp([],Op(a),!1))}}var r=this,n=function(i,a){var o,l,u;if(a===void 0&&(a={logLevel:fe.INFO}),i===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 a=="number"&&(a={logLevel:a});var w=xt("diag"),h=vp((l=a.logLevel)!==null&&l!==void 0?l:fe.INFO,i);if(w&&!a.suppressOverrideMessage){var M=(u=new Error().stack)!==null&&u!==void 0?u:"<failed to generate stacktrace>";w.warn("Current logger will be overwritten from "+M),h.warn("Current logger will overwrite one already registered from "+M)}return ds("diag",h,r,!0)};r.setLogger=n,r.disable=function(){ys(Sp,r)},r.createComponentLogger=function(i){return new bp(i)},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}(),zp=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,a=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)a.push(i.value)}catch(l){o={error:l}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return a},Np=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.")},Ep=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=zp(e,2),n=r[0],i=r[1];return[n,i]})},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=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var a=new t(this._entries);try{for(var o=Np(n),l=o.next();!l.done;l=o.next()){var u=l.value;a._entries.delete(u)}}catch(f){e={error:f}}finally{try{l&&!l.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}return a},t.prototype.clear=function(){return new t},t}();Ct.instance();function Ip(t){return t===void 0&&(t={}),new Ep(new Map(Object.entries(t)))}function Ap(t){return Symbol.for(t)}var kp=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,i){var a=new t(r._currentContext);return a._currentContext.set(n,i),a},r.deleteValue=function(n){var i=new t(r._currentContext);return i._currentContext.delete(n),i}}return t}(),xp=new kp,Cp={get:function(t,e){if(t!=null)return t[e]},keys:function(t){return t==null?[]:Object.keys(t)}},Rp={set:function(t,e,r){t!=null&&(t[e]=r)}},jp=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,a=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)a.push(i.value)}catch(l){o={error:l}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return a},$p=function(t,e,r){if(arguments.length===2)for(var n=0,i=e.length,a;n<i;n++)(a||!(n in e))&&(a||(a=Array.prototype.slice.call(e,0,n)),a[n]=e[n]);return t.concat(a||Array.prototype.slice.call(e))},Mp=function(){function t(){}return t.prototype.active=function(){return xp},t.prototype.with=function(e,r,n){for(var i=[],a=3;a<arguments.length;a++)i[a-3]=arguments[a];return r.call.apply(r,$p([n],jp(i),!1))},t.prototype.bind=function(e,r){return r},t.prototype.enable=function(){return this},t.prototype.disable=function(){return this},t}(),Dp=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,a=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)a.push(i.value)}catch(l){o={error:l}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return a},Pp=function(t,e,r){if(arguments.length===2)for(var n=0,i=e.length,a;n<i;n++)(a||!(n in e))&&(a||(a=Array.prototype.slice.call(e,0,n)),a[n]=e[n]);return t.concat(a||Array.prototype.slice.call(e))},mn="context",Bp=new Mp,Io=function(){function t(){}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalContextManager=function(e){return ds(mn,e,Ct.instance())},t.prototype.active=function(){return this._getContextManager().active()},t.prototype.with=function(e,r,n){for(var i,a=[],o=3;o<arguments.length;o++)a[o-3]=arguments[o];return(i=this._getContextManager()).with.apply(i,Pp([e,r,n],Dp(a),!1))},t.prototype.bind=function(e,r){return this._getContextManager().bind(e,r)},t.prototype._getContextManager=function(){return xt(mn)||Bp},t.prototype.disable=function(){this._getContextManager().disable(),ys(mn,Ct.instance())},t}(),Ln;(function(t){t[t.UNSET=0]="UNSET",t[t.OK=1]="OK",t[t.ERROR=2]="ERROR"})(Ln||(Ln={}));var Up=Io.getInstance(),Lp=function(){function t(){}return t.prototype.inject=function(e,r){},t.prototype.extract=function(e,r){return e},t.prototype.fields=function(){return[]},t}(),gs=Ap("OpenTelemetry Baggage Key");function Ao(t){return t.getValue(gs)||void 0}function Yp(){return Ao(Io.getInstance().active())}function qp(t,e){return t.setValue(gs,e)}function Fp(t){return t.deleteValue(gs)}var wn="propagation",_p=new Lp,Wp=function(){function t(){this.createBaggage=Ip,this.getBaggage=Ao,this.getActiveBaggage=Yp,this.setBaggage=qp,this.deleteBaggage=Fp}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalPropagator=function(e){return ds(wn,e,Ct.instance())},t.prototype.inject=function(e,r,n){return n===void 0&&(n=Rp),this._getGlobalPropagator().inject(e,r,n)},t.prototype.extract=function(e,r,n){return n===void 0&&(n=Cp),this._getGlobalPropagator().extract(e,r,n)},t.prototype.fields=function(){return this._getGlobalPropagator().fields()},t.prototype.disable=function(){ys(wn,Ct.instance())},t.prototype._getGlobalPropagator=function(){return xt(wn)||_p},t}(),Gp=Wp.getInstance();const yi=["bench","debug","prod"],Zp=t=>e=>yi.indexOf(e)>=yi.indexOf(t),Yn=class ko{constructor(e,r=Zp("debug")){K(this,"meta",fs.NOOP),K(this,"tracer"),K(this,"filter"),this.tracer=e,this.filter=r}child(e){const r=new ko(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 Ro(e)):this.tracer.startActiveSpan(e,i=>{const a=new Co(e,i),o=n(a);return i.end(),o})}propagate(e){if(this.meta.noop)return;const r=Up.active();Gp.inject(r,e,{set:(n,i,a)=>{n[i]=a}})}};K(Yn,"NOOP",new Yn);let xo=Yn;class Co{constructor(e,r){K(this,"key"),K(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:Ln.ERROR}))}}class Ro{constructor(e){K(this,"key"),this.key=e}set(){}recordError(e){}}const qn=class jo{constructor({key:e="",serviceName:r="",logger:n=Eo.NOOP,tracer:i=xo.NOOP,noop:a=!1,__meta:o}){K(this,"meta"),K(this,"T"),K(this,"L"),this.meta=o??new fs(e,e,r,a),this.T=i.child(this.meta),this.L=n.child(this.meta)}child(e){const r=this.meta.child(e);return new jo({__meta:r,tracer:this.T,logger:this.L})}};K(qn,"NOOP",new qn({noop:!0}));let ps=qn;const Vp=ps.NOOP,$o=Object.freeze(Object.defineProperty({__proto__:null,Instrumentation:ps,LOG_LEVELS:Bn,Logger:Eo,NOOP:Vp,NoopSpan:Ro,Tracer:xo,_Span:Co,logLevelKeyFiler:fp,logThresholdFilter:hp},Symbol.toStringTag,{value:"Module"})),Jp=new Error("request for lock canceled");var Kp=function(t,e,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function l(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?a(w.value):i(w.value).then(l,u)}f((n=n.apply(t,e||[])).next())})};class Hp{constructor(e,r=Jp){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,i)=>{const a={resolve:n,reject:i,weight:e,priority:r},o=Mo(this._queue,l=>r<=l.priority);o===-1&&e<=this._value?this._dispatchItem(a):this._queue.splice(o+1,0,a)})}runExclusive(e){return Kp(this,arguments,void 0,function*(r,n=1,i=0){const[a,o]=yield this.acquire(n,i);try{return yield r(a)}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]=[]),Xp(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 i=n.findIndex(a=>a.priority<=e);(i===-1?n:n.splice(0,i)).forEach(a=>a.resolve())}}}_couldLockImmediately(e,r){return(this._queue.length===0||this._queue[0].priority<r)&&e<=this._value}}function Xp(t,e){const r=Mo(t,n=>e.priority<=n.priority);t.splice(r+1,0,e)}function Mo(t,e){for(let r=t.length-1;r>=0;r--)if(e(t[r]))return r;return-1}var Qp=function(t,e,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function l(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?a(w.value):i(w.value).then(l,u)}f((n=n.apply(t,e||[])).next())})};class Do{constructor(e){this._semaphore=new Hp(1,e)}acquire(){return Qp(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 Vr{constructor(e,r,n=new Map){D(this,"providers");D(this,"registry");D(this,"sender");D(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 Vr(this.sender,this.registry,new Map);return e==null||e.providers.forEach((n,i)=>r.providers.set(i,n)),this.providers.forEach((n,i)=>r.providers.set(i,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 ms{constructor(e){D(this,"type");D(this,"key");D(this,"_ctx");D(this,"_internalState");D(this,"_state");D(this,"_prevState");D(this,"_deleted",!1);D(this,"instrumentation");D(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 G(`[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=Gn(e,this._state);this._prevState={...this._state},this._state=Dn(this._schema,r,`${this.type}:${this.key}`),this.ctx.propagateState(this.key,r)}get ctx(){if(this._ctx==null)throw new ge("context not defined");return this._ctx}get state(){if(this._state==null)throw new ge("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:i}){if(!this.deleted){if(this._ctx=n,e==="state"){this.validatePath(r);const a=Dn(this._schema,i,`${this.type}:${this.key}`);this._state!=null?this.instrumentation.L.debug("updating state",()=>({diff:bi.difference(this.state,a)})):this.instrumentation.L.debug("setting initial state",{state:i}),this._prevState=this._state??a,this._state=a}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 ge(`[Leaf.setState] - ${this.type}:${this.key} received an empty path`);const r=e[e.length-1];if(e.length>1)throw new ge(`[Leaf.setState] - ${this.type}:${this.key} received a subPath ${e.join(".")} but is a leaf`);if(r!==this.key)throw new ge(`[Leaf.setState] - ${this.type}:${this.key} received a key ${r} but expected ${this.key}`)}}class Yt extends ms{constructor(r){super(r);D(this,"_children");this._children=new Map}get children(){return Array.from(this._children.values())}async internalUpdate(r){const{variant:n,path:i}=r;if(n==="context")return this._ctx=r.ctx.copyAndMerge(this._ctx),await this.updateContext({...r,ctx:this.ctx});const[a,o]=this.getRequiredKey(i),l={...r,ctx:this.ctx};return o.length===0?await this.updateThis(a,l):await this.updateChild(o,l)}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 i=r[0],a=this.getChild(i);if(a!=null)return await a.internalUpdate({...n,path:r});if(r.length>1)throw new Error(`[Composite.setState] - ${this.type}:${this.key} could not find child with key ${i} while updating `);this._children.set(i,await n.ctx.create({...n,path:r}))}async updateThis(r,n){const i=n.ctx.copyAndMerge(this._ctx);if(r!==this.key)throw new ge(`[Composite.update] - ${this.type}:${this.key} received a key ${r} but expected ${this.key}`);if(await super.internalUpdate({...n,ctx:i}),!!i.changed){this.instrumentation.L.debug("context changed",{changedKeys:i.changedKeys});for(const a of this.children)await a.internalUpdate({...n,ctx:this.ctx,variant:"context"})}}async internalDelete(r){const[n,i]=this.getRequiredKey(r);if(i.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 l of o)await l.internalDelete([l.key]);await super.internalDelete([this.key])}const a=this.getChild(i[0]);a!=null&&(i.length>1?await a.internalDelete(i):(this._children.delete(a.key),await a.internalDelete(i)))}getRequiredKey(r,n){const[i,...a]=r;if(i==null)throw new Error(`Composite ${this.type}:${this.key} received an empty path`+(n!=null?` for ${n}`:""));return[i,a]}getChild(r){return this._children.get(r)??null}childrenOfType(...r){return this.children.filter(n=>r.includes(n.type))}}const em=s.z.object({}),Ne=class Ne extends Yt{constructor({worker:r,registry:n,instrumentation:i=$o.Instrumentation.NOOP}){const o={ctx:new Vr(r,n,new Map),...Ne.ZERO_UPDATE,instrumentation:i};super(o);D(this,"wrap");D(this,"schema",Ne.schema);D(this,"mu",new Do);this.mu.runExclusive(async()=>await this.internalUpdate(o)),this.wrap=r,this.wrap.handle(l=>{this.mu.runExclusive(async()=>await this.handle(l))})}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)}}};D(Ne,"TYPE","root"),D(Ne,"KEY","root"),D(Ne,"ZERO_UPDATE",{path:[Ne.KEY],type:Ne.TYPE,variant:"state",state:{}}),D(Ne,"schema",em);let jr=Ne;const Po=t=>new jr(t),tm=Object.freeze(Object.defineProperty({__proto__:null,Composite:Yt,Context:Vr,Leaf:ms,Root:jr,render:Po},Symbol.toStringTag,{value:"Module"})),Bo="pluto-theming-context",rm=s.z.object({theme:Di}),zt=class zt extends Yt{constructor(){super(...arguments);D(this,"schema",zt.z)}async afterUpdate(){this.ctx.set(Bo,this.state.theme)}};D(zt,"TYPE","theming.Provider"),D(zt,"z",rm);let Rt=zt;const nm=t=>t.get(Bo),sm={[Rt.TYPE]:Rt},Uo=["success","error","warning","info","loading","disabled","secondary"],Lo=s.z.enum(Uo),Yo=s.z.object({key:s.z.string(),variant:Lo,message:s.z.string(),description:s.z.string().optional(),time:F.z,data:s.z.record(s.z.unknown()).optional()}),qo=s.z.object({statuses:Yo.array()}),ws="status.aggregator";class $r extends Yt{constructor(){super(...arguments);D(this,"schema",qo)}async afterUpdate(){this.ctx.set(ws,this)}add(r){const n=F.now();this.setState(i=>({...i,statuses:[...i.statuses,{time:n,key:n.toString(),...r}]}))}}D($r,"TYPE","status.Aggregator");const im=t=>{const e=t.get(ws);return e.add.bind(e)},am=t=>{const e=t.getOptional(ws);return e!=null?e.add.bind(e):()=>{}},om={[$r.TYPE]:$r};exports.$=Ic;exports.A=Lc;exports.Aggregator=$r;exports.B=ps;exports.C=al;exports.C$1=Dr;exports.ComponentSizeLevels=Mi;exports.Composite=Yt;exports.E=uc;exports.Ee=ge;exports.G=sl;exports.I=ae;exports.Ie=Fe;exports.J=oe;exports.L=il;exports.LEVELS=$i;exports.Leaf=ms;exports.LevelComponentSizes=ul;exports.Mh=To;exports.Mutex=Do;exports.N=Si;exports.N$1=rl;exports.O=E;exports.Ot=Ac;exports.P=G;exports.Provider=Rt;exports.REGISTRY=sm;exports.REGISTRY$1=om;exports.S=I;exports.S$1=tc;exports.SYNNAX_DARK=Bi;exports.SYNNAX_LIGHT=Pi;exports.SYNNAX_THEMES=bl;exports.Sy=ng;exports.U=Nt;exports.VARIANTS=Uo;exports.X=pe;exports.Zh=So;exports._=bi;exports.aether=tm;exports.aggregatorStateZ=qo;exports.c=mi;exports.commonjsGlobal=Zo;exports.dimensions=fl;exports.executeInitialSetter=jt;exports.executeSetter=Gn;exports.fontString=Sl;exports.g=$;exports.g$1=$o;exports.getAugmentedNamespace=Jo;exports.getDefaultExportFromCjs=Vo;exports.gt=Ec;exports.i=_n;exports.isSetter=Wn;exports.l=Jc;exports.levelZ=ll;exports.ly=vd;exports.m=F;exports.mt=$c;exports.n=qc;exports.ny=Wf;exports.o=Yc;exports.o$1=hc;exports.oy=gd;exports.prettyParse=Dn;exports.r=fc;exports.render=Po;exports.specZ=Me;exports.specZ$1=Yo;exports.state=cl;exports.themeZ=Di;exports.use=nm;exports.useAggregate=im;exports.useOptionalAggregate=am;exports.usePassthrough=Ri;exports.usePurePassthrough=ji;exports.variantZ=Lo;exports.w=Ei;exports.xy=cp;exports.y=W;
package/dist/align.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./external-DsNtnR-y.cjs");exports.Align=e.external;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./external-DqnUE4mV.cjs");exports.Align=e.external;
package/dist/align.js CHANGED
@@ -1,4 +1,4 @@
1
- import { e as r } from "./external-BB2SaR1o.js";
1
+ import { e as r } from "./external-NHkWeW29.js";
2
2
  export {
3
3
  r as Align
4
4
  };