@synnaxlabs/pluto 0.41.0 → 0.42.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (442) hide show
  1. package/dist/{Center-Dr9Np3yZ.js → Center-CNcAEDgS.js} +2 -2
  2. package/dist/{Center-sJghNsrv.cjs → Center-Map6aflE.cjs} +1 -1
  3. package/dist/ContextMenu-DmRPxhnI.cjs +1 -0
  4. package/dist/{ContextMenu-GUed89mt.js → ContextMenu-fLU0wr9S.js} +19 -20
  5. package/dist/DateTime-CP3OmEGY.cjs +1 -0
  6. package/dist/{DateTime-DEbT6v4l.js → DateTime-CWAcEwXO.js} +2 -2
  7. package/dist/{Divider-Bpe7zJig.js → Divider-BTLn5ucU.js} +103 -97
  8. package/dist/{Divider-CloQr3vQ.cjs → Divider-Dvb6dsgX.cjs} +4 -4
  9. package/dist/Dropdown-CaGzfZRa.cjs +1 -0
  10. package/dist/{Dropdown-4Cti-bbQ.js → Dropdown-nw8kRSbl.js} +110 -111
  11. package/dist/Haul-B8zGWk0I.cjs +1 -0
  12. package/dist/{Haul-Bw54Yj6J.js → Haul-Cnuzk7Z-.js} +37 -38
  13. package/dist/Item-BzrQqxRC.cjs +1 -0
  14. package/dist/{Item-9WCCzBv2.js → Item-FmwC-twg.js} +10 -11
  15. package/dist/{Keyboard-CZFi6COK.cjs → Keyboard-BfvjkBgh.cjs} +1 -1
  16. package/dist/{Keyboard-634856lT.js → Keyboard-Cevv7vrQ.js} +2 -2
  17. package/dist/{Link-fkoogssj.cjs → Link-DI7BZ5dL.cjs} +1 -1
  18. package/dist/{Link-BEheZd26.js → Link-Dljdu4e9.js} +1 -1
  19. package/dist/{Pack-D6Z6WuZl.cjs → Pack-lJqoOmHx.cjs} +1 -1
  20. package/dist/{Pack-DhZO_rza.js → Pack-to0DG2iP.js} +2 -2
  21. package/dist/Provider-BlM1x1cF.cjs +1 -0
  22. package/dist/{Provider-UAXPVomG.js → Provider-C_B463cg.js} +301 -292
  23. package/dist/{Space-DunsWl06.js → Space-C2oZDkE1.js} +1 -1
  24. package/dist/{Space-BtaH1buB.cjs → Space-DfcVsxz8.cjs} +1 -1
  25. package/dist/{Text-CaRMYy3U.js → Text-BXADoWYY.js} +54 -52
  26. package/dist/Text-BiYpGaEZ.js +35 -0
  27. package/dist/Text-BjHlLKsp.cjs +1 -0
  28. package/dist/{Text-3PiRcn8q.js → Text-CWiPrDI1.js} +75 -77
  29. package/dist/Text-DrIBbnml.cjs +1 -0
  30. package/dist/Text-ZJqK1cI3.cjs +4 -0
  31. package/dist/{Toggle-CZd8L4GI.js → Toggle-CeUVv58o.js} +102 -104
  32. package/dist/Toggle-CfwYy9fe.cjs +1 -0
  33. package/dist/{Video-4XQ1qozd.js → Video-BZ1XTEez.js} +1 -1
  34. package/dist/{Video-BM9uJLaQ.cjs → Video-C7YoF37-.cjs} +1 -1
  35. package/dist/WithIcon-DG7VJxsE.cjs +1 -0
  36. package/dist/WithIcon-pBZ7H9Lq.js +98 -0
  37. package/dist/align.cjs +1 -1
  38. package/dist/align.js +1 -1
  39. package/dist/button.cjs +1 -1
  40. package/dist/button.js +1 -1
  41. package/dist/color.cjs +1 -1
  42. package/dist/color.js +1 -1
  43. package/dist/css-B7c7_G5h.js +4746 -0
  44. package/dist/css-hg3QdDDt.cjs +15 -0
  45. package/dist/css.cjs +1 -1
  46. package/dist/css.js +2 -2
  47. package/dist/deep-B1etRzze.cjs +1 -0
  48. package/dist/deep-BytImVW-.js +102 -0
  49. package/dist/dimensions-Cz-q0Mok.cjs +1 -0
  50. package/dist/dimensions-DcjW7X3n.js +19 -0
  51. package/dist/dropdown.cjs +1 -1
  52. package/dist/dropdown.js +1 -1
  53. package/dist/eraser-BOx6Xhwn.cjs +11 -0
  54. package/dist/eraser-Bsb4kKS3.js +1148 -0
  55. package/dist/ether.cjs +1 -1
  56. package/dist/ether.js +67 -75
  57. package/dist/{external-CVGidiDt.js → external-1KJXZcr9.js} +2 -2
  58. package/dist/{external-DVajt6X6.cjs → external-BHHC7TQ_.cjs} +1 -1
  59. package/dist/external-BLEs2AYM.cjs +46 -0
  60. package/dist/external-BdVuZd3H.cjs +1 -0
  61. package/dist/external-BiBhgCdz.cjs +1 -0
  62. package/dist/external-C75Z9Zbn.cjs +1 -0
  63. package/dist/external-CEfSeJMr.js +432 -0
  64. package/dist/external-CLTPcWrI.cjs +1 -0
  65. package/dist/{external-C0ZRdtdj.js → external-CRNR1bD0.js} +28 -28
  66. package/dist/{external-CnxSp7fm.cjs → external-Cfj1plcw.cjs} +1 -1
  67. package/dist/{external-DNF8yEwq.js → external-Ck1rVwUu.js} +27 -28
  68. package/dist/external-Cni9ftkW.cjs +1 -0
  69. package/dist/{external-BlUic3Vz.js → external-DCcp3sQD.js} +7 -8
  70. package/dist/{external-B-Cao-ae.cjs → external-DCfs7IFi.cjs} +1 -1
  71. package/dist/external-DDD_nc3x.js +400 -0
  72. package/dist/external-DNT-gmZx.cjs +1 -0
  73. package/dist/{external-BY2AjzRx.js → external-DeCeUbqe.js} +20 -19
  74. package/dist/{external-BFOrrNde.js → external-DgSaeiBz.js} +3 -3
  75. package/dist/{external-kZf9CjYn.cjs → external-DhfASB4W.cjs} +37 -37
  76. package/dist/{external-BCUxzSzk.js → external-bkwgRzLc.js} +9 -10
  77. package/dist/{external-BIwhkj24.js → external-hgzjVlDR.js} +1996 -2011
  78. package/dist/external-pUEPQrp_.cjs +1 -0
  79. package/dist/{external-CH66YjTZ.js → external-qwaFowDe.js} +12 -13
  80. package/dist/{external-BbrPEGJw.js → external-sUHGRdqd.js} +2 -2
  81. package/dist/{font-DCE90lco.cjs → font-BFTKtIQk.cjs} +1 -1
  82. package/dist/{font-BXKdXsr5.js → font-Crn-D_ua.js} +2 -2
  83. package/dist/{fontString-BBvH9Ypy.cjs → fontString-DQLaRHQV.cjs} +1 -1
  84. package/dist/{fontString-C7Q9Laqk.js → fontString-DjnDxFrE.js} +1 -1
  85. package/dist/header.cjs +1 -1
  86. package/dist/header.js +1 -1
  87. package/dist/hooks-CM9HWxYc.js +296 -0
  88. package/dist/hooks-CTKCi-OE.cjs +1 -0
  89. package/dist/index.cjs +7 -7
  90. package/dist/index.js +8599 -8514
  91. package/dist/input.cjs +1 -1
  92. package/dist/input.js +1 -1
  93. package/dist/list.cjs +1 -1
  94. package/dist/list.js +1 -1
  95. package/dist/menu.cjs +1 -1
  96. package/dist/menu.js +1 -1
  97. package/dist/pluto.css +1 -1
  98. package/dist/provider-BDFfcHVT.js +12851 -0
  99. package/dist/provider-XPRFhwnl.cjs +58 -0
  100. package/dist/src/aether/aether/aether.d.ts +17 -18
  101. package/dist/src/aether/aether/aether.d.ts.map +1 -1
  102. package/dist/src/aether/aether/aether.spec.spec.d.ts +1 -5
  103. package/dist/src/aether/aether/aether.spec.spec.d.ts.map +1 -1
  104. package/dist/src/aether/main.d.ts.map +1 -1
  105. package/dist/src/aether/main.spec.d.ts +1 -5
  106. package/dist/src/aether/main.spec.d.ts.map +1 -1
  107. package/dist/src/aether/message.d.ts +11 -1
  108. package/dist/src/aether/message.d.ts.map +1 -1
  109. package/dist/src/alamos/aether/alamos.d.ts +19 -25
  110. package/dist/src/alamos/aether/alamos.d.ts.map +1 -1
  111. package/dist/src/button/Button.d.ts +2 -2
  112. package/dist/src/button/Button.d.ts.map +1 -1
  113. package/dist/src/button/color.d.ts +2 -2
  114. package/dist/src/button/color.d.ts.map +1 -1
  115. package/dist/src/channel/LinePlot.d.ts +4 -4
  116. package/dist/src/channel/LinePlot.d.ts.map +1 -1
  117. package/dist/src/color/BaseSwatch.d.ts +3 -3
  118. package/dist/src/color/BaseSwatch.d.ts.map +1 -1
  119. package/dist/src/color/GradientPicker.d.ts +1 -2
  120. package/dist/src/color/GradientPicker.d.ts.map +1 -1
  121. package/dist/src/color/Picker.d.ts +1 -1
  122. package/dist/src/color/Picker.d.ts.map +1 -1
  123. package/dist/src/color/Provider.d.ts +8 -100
  124. package/dist/src/color/Provider.d.ts.map +1 -1
  125. package/dist/src/color/external.d.ts +0 -4
  126. package/dist/src/color/external.d.ts.map +1 -1
  127. package/dist/src/css/color.d.ts +2 -2
  128. package/dist/src/css/color.d.ts.map +1 -1
  129. package/dist/src/divider/Divider.d.ts +2 -1
  130. package/dist/src/divider/Divider.d.ts.map +1 -1
  131. package/dist/src/ether.d.ts +0 -1
  132. package/dist/src/ether.d.ts.map +1 -1
  133. package/dist/src/form/Form.d.ts +1 -1
  134. package/dist/src/form/Form.d.ts.map +1 -1
  135. package/dist/src/haul/Haul.d.ts +7 -63
  136. package/dist/src/haul/Haul.d.ts.map +1 -1
  137. package/dist/src/hooks/useResize.d.ts.map +1 -1
  138. package/dist/src/index.d.ts +1 -0
  139. package/dist/src/index.d.ts.map +1 -1
  140. package/dist/src/input/Text.d.ts +4 -4
  141. package/dist/src/input/Text.d.ts.map +1 -1
  142. package/dist/src/mosaic/types.d.ts +6 -66
  143. package/dist/src/mosaic/types.d.ts.map +1 -1
  144. package/dist/src/pluto/Pluto.d.ts.map +1 -1
  145. package/dist/src/pluto/aether/pluto.d.ts.map +1 -1
  146. package/dist/src/select/Multiple.d.ts +2 -3
  147. package/dist/src/select/Multiple.d.ts.map +1 -1
  148. package/dist/src/state/state.d.ts +1 -2
  149. package/dist/src/state/state.d.ts.map +1 -1
  150. package/dist/src/status/Circle.d.ts.map +1 -1
  151. package/dist/src/status/aether/aggregator.d.ts +34 -96
  152. package/dist/src/status/aether/aggregator.d.ts.map +1 -1
  153. package/dist/src/status/aether/types.d.ts +23 -27
  154. package/dist/src/status/aether/types.d.ts.map +1 -1
  155. package/dist/src/synnax/Provider.d.ts +4 -0
  156. package/dist/src/synnax/Provider.d.ts.map +1 -1
  157. package/dist/src/synnax/aether/provider.d.ts +54 -388
  158. package/dist/src/synnax/aether/provider.d.ts.map +1 -1
  159. package/dist/src/table/aether/Table.d.ts +58 -418
  160. package/dist/src/table/aether/Table.d.ts.map +1 -1
  161. package/dist/src/table/cells/Cells.d.ts +38 -153
  162. package/dist/src/table/cells/Cells.d.ts.map +1 -1
  163. package/dist/src/table/cells/Forms.d.ts.map +1 -1
  164. package/dist/src/table/cells/registry.d.ts +6 -3
  165. package/dist/src/table/cells/registry.d.ts.map +1 -1
  166. package/dist/src/tabs/Selector.d.ts.map +1 -1
  167. package/dist/src/tabs/types.d.ts +5 -38
  168. package/dist/src/tabs/types.d.ts.map +1 -1
  169. package/dist/src/tag/Tag.d.ts +3 -4
  170. package/dist/src/tag/Tag.d.ts.map +1 -1
  171. package/dist/src/telem/aether/context.d.ts +8 -8
  172. package/dist/src/telem/aether/context.d.ts.map +1 -1
  173. package/dist/src/telem/aether/factory.d.ts +6 -2
  174. package/dist/src/telem/aether/factory.d.ts.map +1 -1
  175. package/dist/src/telem/aether/noop.d.ts.map +1 -1
  176. package/dist/src/telem/aether/pipeline.d.ts +25 -215
  177. package/dist/src/telem/aether/pipeline.d.ts.map +1 -1
  178. package/dist/src/telem/aether/provider.d.ts +7 -5
  179. package/dist/src/telem/aether/provider.d.ts.map +1 -1
  180. package/dist/src/telem/aether/remote.d.ts +62 -183
  181. package/dist/src/telem/aether/remote.d.ts.map +1 -1
  182. package/dist/src/telem/aether/static.d.ts +21 -74
  183. package/dist/src/telem/aether/static.d.ts.map +1 -1
  184. package/dist/src/telem/aether/telem.d.ts +60 -284
  185. package/dist/src/telem/aether/telem.d.ts.map +1 -1
  186. package/dist/src/telem/aether/transformers.d.ts +79 -321
  187. package/dist/src/telem/aether/transformers.d.ts.map +1 -1
  188. package/dist/src/telem/client/cache/cache.d.ts +1 -1
  189. package/dist/src/telem/client/cache/cache.d.ts.map +1 -1
  190. package/dist/src/telem/client/cache/dynamic.d.ts +5 -5
  191. package/dist/src/telem/client/cache/dynamic.d.ts.map +1 -1
  192. package/dist/src/telem/client/cache/static.d.ts +3 -3
  193. package/dist/src/telem/client/cache/static.d.ts.map +1 -1
  194. package/dist/src/telem/client/cache/unary.d.ts +3 -3
  195. package/dist/src/telem/client/cache/unary.d.ts.map +1 -1
  196. package/dist/src/telem/client/client.d.ts +8 -12
  197. package/dist/src/telem/client/client.d.ts.map +1 -1
  198. package/dist/src/telem/client/external.d.ts +0 -1
  199. package/dist/src/telem/client/external.d.ts.map +1 -1
  200. package/dist/src/telem/client/reader.d.ts +28 -10
  201. package/dist/src/telem/client/reader.d.ts.map +1 -1
  202. package/dist/src/telem/client/reader.spec.d.ts +6 -1
  203. package/dist/src/telem/client/reader.spec.d.ts.map +1 -1
  204. package/dist/src/telem/client/streamer.d.ts +6 -6
  205. package/dist/src/telem/client/streamer.d.ts.map +1 -1
  206. package/dist/src/telem/client/streamer.spec.d.ts +2 -0
  207. package/dist/src/telem/client/streamer.spec.d.ts.map +1 -0
  208. package/dist/src/telem/control/Indicator.d.ts.map +1 -1
  209. package/dist/src/telem/control/aether/chip.d.ts +44 -232
  210. package/dist/src/telem/control/aether/chip.d.ts.map +1 -1
  211. package/dist/src/telem/control/aether/controller.d.ts +36 -73
  212. package/dist/src/telem/control/aether/controller.d.ts.map +1 -1
  213. package/dist/src/telem/control/aether/indicator.d.ts +49 -257
  214. package/dist/src/telem/control/aether/indicator.d.ts.map +1 -1
  215. package/dist/src/telem/control/aether/legend.d.ts +18 -132
  216. package/dist/src/telem/control/aether/legend.d.ts.map +1 -1
  217. package/dist/src/telem/control/aether/state.d.ts +10 -44
  218. package/dist/src/telem/control/aether/state.d.ts.map +1 -1
  219. package/dist/src/text/Text.d.ts +5 -4
  220. package/dist/src/text/Text.d.ts.map +1 -1
  221. package/dist/src/text/core/types.d.ts +17 -14
  222. package/dist/src/text/core/types.d.ts.map +1 -1
  223. package/dist/src/text/dimensions.d.ts +1 -0
  224. package/dist/src/text/dimensions.d.ts.map +1 -1
  225. package/dist/src/theming/aether/provider.d.ts +755 -5891
  226. package/dist/src/theming/aether/provider.d.ts.map +1 -1
  227. package/dist/src/theming/core/theme.d.ts +314 -1848
  228. package/dist/src/theming/core/theme.d.ts.map +1 -1
  229. package/dist/src/theming/css.d.ts.map +1 -1
  230. package/dist/src/tree/Tree.d.ts +1 -1
  231. package/dist/src/tree/Tree.d.ts.map +1 -1
  232. package/dist/src/tree/core.d.ts.map +1 -1
  233. package/dist/src/triggers/Provider.d.ts.map +1 -1
  234. package/dist/src/triggers/triggers.d.ts +248 -9
  235. package/dist/src/triggers/triggers.d.ts.map +1 -1
  236. package/dist/src/util/component.d.ts +7 -1
  237. package/dist/src/util/component.d.ts.map +1 -1
  238. package/dist/src/viewport/use.d.ts +8 -1
  239. package/dist/src/viewport/use.d.ts.map +1 -1
  240. package/dist/src/vis/axis/axis.d.ts +17 -48
  241. package/dist/src/vis/axis/axis.d.ts.map +1 -1
  242. package/dist/src/vis/axis/canvas.d.ts +17 -20
  243. package/dist/src/vis/axis/canvas.d.ts.map +1 -1
  244. package/dist/src/vis/axis/preciseTimeScale.d.ts +1 -2
  245. package/dist/src/vis/axis/preciseTimeScale.d.ts.map +1 -1
  246. package/dist/src/vis/axis/ticks.d.ts +11 -11
  247. package/dist/src/vis/axis/ticks.d.ts.map +1 -1
  248. package/dist/src/vis/button/aether/button.d.ts +10 -80
  249. package/dist/src/vis/button/aether/button.d.ts.map +1 -1
  250. package/dist/src/vis/canvas/Canvas.d.ts +2 -2
  251. package/dist/src/vis/canvas/Canvas.d.ts.map +1 -1
  252. package/dist/src/vis/canvas/aether/canvas.d.ts +45 -193
  253. package/dist/src/vis/canvas/aether/canvas.d.ts.map +1 -1
  254. package/dist/src/vis/diagram/Diagram.d.ts.map +1 -1
  255. package/dist/src/vis/diagram/aether/Diagram.d.ts +62 -469
  256. package/dist/src/vis/diagram/aether/Diagram.d.ts.map +1 -1
  257. package/dist/src/vis/diagram/aether/types.d.ts +29 -249
  258. package/dist/src/vis/diagram/aether/types.d.ts.map +1 -1
  259. package/dist/src/vis/diagram/edge/Edge.d.ts +2 -3
  260. package/dist/src/vis/diagram/edge/Edge.d.ts.map +1 -1
  261. package/dist/src/vis/diagram/edge/connector/connector.d.ts +5 -8
  262. package/dist/src/vis/diagram/edge/connector/connector.d.ts.map +1 -1
  263. package/dist/src/vis/diagram/edge/paths.d.ts +3 -4
  264. package/dist/src/vis/diagram/edge/paths.d.ts.map +1 -1
  265. package/dist/src/vis/draw2d/canvas.d.ts +21 -3
  266. package/dist/src/vis/draw2d/canvas.d.ts.map +1 -1
  267. package/dist/src/vis/draw2d/index.d.ts +3 -4
  268. package/dist/src/vis/draw2d/index.d.ts.map +1 -1
  269. package/dist/src/vis/eraser/aether/eraser.d.ts +30 -170
  270. package/dist/src/vis/eraser/aether/eraser.d.ts.map +1 -1
  271. package/dist/src/vis/grid/grid.d.ts +14 -24
  272. package/dist/src/vis/grid/grid.d.ts.map +1 -1
  273. package/dist/src/vis/legend/Container.d.ts +42 -86
  274. package/dist/src/vis/legend/Container.d.ts.map +1 -1
  275. package/dist/src/vis/legend/Simple.d.ts +3 -4
  276. package/dist/src/vis/legend/Simple.d.ts.map +1 -1
  277. package/dist/src/vis/light/aether/light.d.ts +10 -80
  278. package/dist/src/vis/light/aether/light.d.ts.map +1 -1
  279. package/dist/src/vis/line/aether/line.d.ts +18 -101
  280. package/dist/src/vis/line/aether/line.d.ts.map +1 -1
  281. package/dist/src/vis/lineplot/Axis.d.ts.map +1 -1
  282. package/dist/src/vis/lineplot/LinePlot.d.ts +2 -3
  283. package/dist/src/vis/lineplot/LinePlot.d.ts.map +1 -1
  284. package/dist/src/vis/lineplot/aether/BoundQuerier.d.ts +35 -0
  285. package/dist/src/vis/lineplot/aether/BoundQuerier.d.ts.map +1 -0
  286. package/dist/src/vis/lineplot/aether/LinePlot.d.ts +82 -489
  287. package/dist/src/vis/lineplot/aether/LinePlot.d.ts.map +1 -1
  288. package/dist/src/vis/lineplot/aether/XAxis.d.ts +51 -191
  289. package/dist/src/vis/lineplot/aether/XAxis.d.ts.map +1 -1
  290. package/dist/src/vis/lineplot/aether/YAxis.d.ts +49 -194
  291. package/dist/src/vis/lineplot/aether/YAxis.d.ts.map +1 -1
  292. package/dist/src/vis/lineplot/aether/axis.d.ts +27 -98
  293. package/dist/src/vis/lineplot/aether/axis.d.ts.map +1 -1
  294. package/dist/src/vis/lineplot/aether/external.d.ts +1 -0
  295. package/dist/src/vis/lineplot/aether/external.d.ts.map +1 -1
  296. package/dist/src/vis/lineplot/external.d.ts +1 -0
  297. package/dist/src/vis/lineplot/external.d.ts.map +1 -1
  298. package/dist/src/vis/lineplot/range/Provider.d.ts.map +1 -1
  299. package/dist/src/vis/lineplot/range/aether/annotation.d.ts +15 -52
  300. package/dist/src/vis/lineplot/range/aether/annotation.d.ts.map +1 -1
  301. package/dist/src/vis/lineplot/range/aether/provider.d.ts +43 -294
  302. package/dist/src/vis/lineplot/range/aether/provider.d.ts.map +1 -1
  303. package/dist/src/vis/lineplot/tooltip/aether/tooltip.d.ts +17 -154
  304. package/dist/src/vis/lineplot/tooltip/aether/tooltip.d.ts.map +1 -1
  305. package/dist/src/vis/lineplot/useBoundQuerier.d.ts +11 -0
  306. package/dist/src/vis/lineplot/useBoundQuerier.d.ts.map +1 -0
  307. package/dist/src/vis/log/aether/Log.d.ts +82 -461
  308. package/dist/src/vis/log/aether/Log.d.ts.map +1 -1
  309. package/dist/src/vis/measure/aether/measure.d.ts +24 -249
  310. package/dist/src/vis/measure/aether/measure.d.ts.map +1 -1
  311. package/dist/src/vis/performance/Performance.d.ts +2 -0
  312. package/dist/src/vis/performance/Performance.d.ts.map +1 -0
  313. package/dist/src/vis/performance/aether/index.d.ts +2 -0
  314. package/dist/src/vis/performance/aether/index.d.ts.map +1 -0
  315. package/dist/src/vis/performance/aether/performance.d.ts +15 -0
  316. package/dist/src/vis/performance/aether/performance.d.ts.map +1 -0
  317. package/dist/src/vis/performance/index.d.ts +2 -0
  318. package/dist/src/vis/performance/index.d.ts.map +1 -0
  319. package/dist/src/vis/render/GLProgram.d.ts +1 -2
  320. package/dist/src/vis/render/GLProgram.d.ts.map +1 -1
  321. package/dist/src/vis/render/context.d.ts +1 -0
  322. package/dist/src/vis/render/context.d.ts.map +1 -1
  323. package/dist/src/vis/render/controller.d.ts +7 -12
  324. package/dist/src/vis/render/controller.d.ts.map +1 -1
  325. package/dist/src/vis/render/loop.d.ts +15 -5
  326. package/dist/src/vis/render/loop.d.ts.map +1 -1
  327. package/dist/src/vis/rule/Rule.d.ts +1 -1
  328. package/dist/src/vis/rule/Rule.d.ts.map +1 -1
  329. package/dist/src/vis/rule/aether/aether.d.ts +8 -57
  330. package/dist/src/vis/rule/aether/aether.d.ts.map +1 -1
  331. package/dist/src/vis/schematic/Forms.d.ts.map +1 -1
  332. package/dist/src/vis/schematic/Symbols.d.ts +3 -4
  333. package/dist/src/vis/schematic/Symbols.d.ts.map +1 -1
  334. package/dist/src/vis/schematic/primitives/Primitives.d.ts +34 -35
  335. package/dist/src/vis/schematic/primitives/Primitives.d.ts.map +1 -1
  336. package/dist/src/vis/schematic/registry.d.ts +96 -1
  337. package/dist/src/vis/schematic/registry.d.ts.map +1 -1
  338. package/dist/src/vis/setpoint/aether/setpoint.d.ts +16 -155
  339. package/dist/src/vis/setpoint/aether/setpoint.d.ts.map +1 -1
  340. package/dist/src/vis/text/atlas.d.ts +32 -0
  341. package/dist/src/vis/text/atlas.d.ts.map +1 -0
  342. package/dist/src/vis/text/index.d.ts +2 -0
  343. package/dist/src/vis/text/index.d.ts.map +1 -0
  344. package/dist/src/vis/toggle/aether/toggle.d.ts +16 -150
  345. package/dist/src/vis/toggle/aether/toggle.d.ts.map +1 -1
  346. package/dist/src/vis/value/aether/value.d.ts +144 -569
  347. package/dist/src/vis/value/aether/value.d.ts.map +1 -1
  348. package/dist/src/vis/value/use.d.ts +55 -199
  349. package/dist/src/vis/value/use.d.ts.map +1 -1
  350. package/dist/{state-Bd_8X2jl.cjs → state-_FFrG5nH.cjs} +1 -1
  351. package/dist/tabs.cjs +1 -1
  352. package/dist/tabs.js +1 -1
  353. package/dist/text.cjs +1 -1
  354. package/dist/text.js +2 -2
  355. package/dist/theming.cjs +1 -1
  356. package/dist/theming.js +2 -2
  357. package/dist/{toArray-Dvn9FA_3.js → toArray-B7nD2CTw.js} +1 -1
  358. package/dist/{toArray-DRKOku1s.cjs → toArray-BvVYuN_b.cjs} +1 -1
  359. package/dist/tree.cjs +1 -1
  360. package/dist/tree.js +1 -1
  361. package/dist/triggers.cjs +1 -1
  362. package/dist/triggers.js +1 -1
  363. package/dist/units-CKKNRQlP.cjs +1 -0
  364. package/dist/units-a8CggrTe.js +11 -0
  365. package/dist/{useClickOutside-BYjsXGgb.js → useClickOutside-CKMnqdvH.js} +29 -30
  366. package/dist/useClickOutside-CPAEkvf8.cjs +1 -0
  367. package/dist/{useDebouncedCallback-Dg4BDGP-.js → useDebouncedCallback-Cyd6pZ59.js} +1 -1
  368. package/dist/useDebouncedCallback-DsKlBI86.cjs +1 -0
  369. package/dist/{useMemoCompare-BEDaTIXL.js → useMemoCompare-B930TM0g.js} +2 -2
  370. package/dist/useMemoCompare-DprA41gC.cjs +1 -0
  371. package/dist/{useVirtualCursorDragWebKit-BixysrXI.js → useVirtualCursorDragWebKit-BrSOJpYY.js} +22 -23
  372. package/dist/useVirtualCursorDragWebKit-Cvp93Pya.cjs +1 -0
  373. package/dist/value-B7u8K1CW.cjs +57 -0
  374. package/dist/value-BdZLWVof.js +5974 -0
  375. package/dist/video.cjs +1 -1
  376. package/dist/video.js +1 -1
  377. package/package.json +9 -8
  378. package/dist/ContextMenu-DCxj35_j.cjs +0 -1
  379. package/dist/DateTime-D6J8sRSH.cjs +0 -1
  380. package/dist/Dropdown-C7Im-qW-.cjs +0 -1
  381. package/dist/Haul-hv7TLQ7N.cjs +0 -1
  382. package/dist/Item-piF6rFAm.cjs +0 -1
  383. package/dist/Provider-DNTq46b0.cjs +0 -1
  384. package/dist/Text-BTEov6di.cjs +0 -1
  385. package/dist/Text-DNspRcte.js +0 -36
  386. package/dist/Text-DylGoRKw.cjs +0 -4
  387. package/dist/Text-X_BHez8W.cjs +0 -1
  388. package/dist/Toggle-BKKBcuTj.cjs +0 -1
  389. package/dist/WithIcon-CC-RSx6r.js +0 -93
  390. package/dist/WithIcon-Dn8eAoMj.cjs +0 -1
  391. package/dist/aggregator-74jWxDne.cjs +0 -1
  392. package/dist/aggregator-DMvP8cai.js +0 -83
  393. package/dist/css-Cj2UCGXB.cjs +0 -1
  394. package/dist/css-Dyt-QnKy.js +0 -1199
  395. package/dist/deep-Cvb4bVYY.js +0 -105
  396. package/dist/deep-ICSlPm58.cjs +0 -1
  397. package/dist/dimensions-Cc0z-IDd.js +0 -18
  398. package/dist/dimensions-Djqdrqi0.cjs +0 -1
  399. package/dist/eraser-9-LOWZvk.cjs +0 -11
  400. package/dist/eraser-BjtEI-1I.js +0 -823
  401. package/dist/external-B-UNCzPY.cjs +0 -1
  402. package/dist/external-B18FBGpk.cjs +0 -1
  403. package/dist/external-BG1mV1W8.cjs +0 -1
  404. package/dist/external-BWeX0nyq.js +0 -399
  405. package/dist/external-BbmpRAH3.cjs +0 -1
  406. package/dist/external-D2vS6j9c.cjs +0 -46
  407. package/dist/external-DHmQqAfL.js +0 -435
  408. package/dist/external-DRGfSFQT.cjs +0 -1
  409. package/dist/external-DX4m-5qT.cjs +0 -1
  410. package/dist/external-DlywBW-S.cjs +0 -1
  411. package/dist/hooks-BQJQyGWV.js +0 -293
  412. package/dist/hooks-ClXSlga9.cjs +0 -1
  413. package/dist/index-CSKP1UPN.js +0 -2343
  414. package/dist/index-Ch3utIMa.cjs +0 -15
  415. package/dist/provider-CH0eoGfz.js +0 -10358
  416. package/dist/provider-D054LCpB.cjs +0 -53
  417. package/dist/src/color/core/color.d.ts +0 -143
  418. package/dist/src/color/core/color.d.ts.map +0 -1
  419. package/dist/src/color/core/color.spec.d.ts +0 -2
  420. package/dist/src/color/core/color.spec.d.ts.map +0 -1
  421. package/dist/src/color/core/external.d.ts +0 -5
  422. package/dist/src/color/core/external.d.ts.map +0 -1
  423. package/dist/src/color/core/gradient.d.ts +0 -58
  424. package/dist/src/color/core/gradient.d.ts.map +0 -1
  425. package/dist/src/color/core/index.d.ts +0 -2
  426. package/dist/src/color/core/index.d.ts.map +0 -1
  427. package/dist/src/color/core/palette.d.ts +0 -74
  428. package/dist/src/color/core/palette.d.ts.map +0 -1
  429. package/dist/src/color/core/transformColorsToHex.d.ts +0 -6
  430. package/dist/src/color/core/transformColorsToHex.d.ts.map +0 -1
  431. package/dist/src/telem/client/types.d.ts +0 -20
  432. package/dist/src/telem/client/types.d.ts.map +0 -1
  433. package/dist/transformColorsToHex-DE7uEs1w.cjs +0 -1
  434. package/dist/transformColorsToHex-UBrryWh5.js +0 -14
  435. package/dist/units-DjoHPrqM.cjs +0 -1
  436. package/dist/units-MBd0L3ff.js +0 -8
  437. package/dist/useClickOutside-4k9PAT_i.cjs +0 -1
  438. package/dist/useDebouncedCallback-BBsAgC9k.cjs +0 -1
  439. package/dist/useMemoCompare-DORTZbzY.cjs +0 -1
  440. package/dist/useVirtualCursorDragWebKit-BSafZVD_.cjs +0 -1
  441. package/dist/value-CudL8z5e.js +0 -5957
  442. package/dist/value-DT0qJqgQ.cjs +0 -57
@@ -0,0 +1,58 @@
1
+ "use strict";var Bl=Object.defineProperty;var jl=(s,e,t)=>e in s?Bl(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var L=(s,e,t)=>jl(s,typeof e!="symbol"?e+"":e,t);const i=require("zod"),S=require("./css-hg3QdDDt.cjs"),Rl=require("./deep-B1etRzze.cjs"),We=require("./state-_FFrG5nH.cjs");var Ml=Object.defineProperty,Pl=(s,e,t)=>e in s?Ml(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Ks=(s,e,t)=>Pl(s,typeof e!="symbol"?e+"":e,t);let Dl=class{constructor(e){Ks(this,"sender"),Ks(this,"handlers"),this.sender=e,this.handlers=new Map}handle({data:e}){var t;const n=(t=this.handlers.get(e.type))==null?void 0:t.handler;n==null?console.warn(`No handler for ${e.type}`):n(e.payload)}route(e){const t=$l(e,this.sender),n=new Ll(t);return this.handlers.set(e,n),n}};const $l=(s,e)=>(t,n)=>e({type:s,payload:t},n);class Ll{constructor(e){Ks(this,"_send"),Ks(this,"handler"),this._send=e,this.handler=null}send(e,t=[]){this._send(e,t)}handle(e){this.handler=e}}const Fl=i.z.object({l0:S.zt.colorZ,l1:S.zt.colorZ,l2:S.zt.colorZ,l3:S.zt.colorZ,l4:S.zt.colorZ,l5:S.zt.colorZ,l6:S.zt.colorZ,l7:S.zt.colorZ,l8:S.zt.colorZ,l9:S.zt.colorZ,l10:S.zt.colorZ,l11:S.zt.colorZ}),ye=(s,e)=>[s[0],s[1],e,s[3]],_l=i.z.object({m2:S.zt.colorZ,m1:S.zt.colorZ,z:S.zt.colorZ,p1:S.zt.colorZ,p2:S.zt.colorZ}),Es=_l.or(S.zt.colorZ.transform(s=>{const e=S.zt.hsla(s);return{m2:S.zt.fromHSLA(ye(e,40)),m1:S.zt.fromHSLA(ye(e,45)),z:s,p1:S.zt.fromHSLA(ye(e,55)),p2:S.zt.fromHSLA(ye(e,65))}})),Ka=i.z.object({name:i.z.string(),key:i.z.string(),colors:i.z.object({border:S.zt.colorZ,primary:Es,gray:Fl,error:Es,secondary:Es,warning:Es,palettes:i.z.record(i.z.string(),S.zt.paletteZ),visualization:i.z.object({palettes:i.z.record(i.z.string(),i.z.array(S.zt.colorZ))}).optional().default({palettes:{}}),white:S.zt.colorZ,black:S.zt.colorZ,text:S.zt.colorZ,textInverted:S.zt.colorZ,textOnPrimary:S.zt.colorZ.optional().default(S.zt.ZERO),logo:i.z.string()}),sizes:i.z.object({base:i.z.number(),border:i.z.object({radius:i.z.number(),width:i.z.number(),thickWidth:i.z.number()}),schematic:i.z.object({elementStrokeWidth:i.z.number()})}),typography:i.z.object({family:i.z.string(),codeFamily:i.z.string(),h1:We.specZ,h2:We.specZ,h3:We.specZ,h4:We.specZ,h5:We.specZ,p:We.specZ,small:We.specZ})}).transform(s=>((s.colors.textOnPrimary==null||S.zt.isZero(s.colors.textOnPrimary))&&(s.colors.textOnPrimary=S.zt.pickByContrast(s.colors.primary.z,s.colors.text,s.colors.textInverted)),s)),ql="'Inter Variable', sans-serif",Wl="'Geist Mono', monospace",Vl=6,Nt=[357,91,55,1],At=[58,100,50,1],Yl=["#FEFEFE","#FAFAFA","#F2F2F2","#ECECEC","#E4E4E4","#D1D1D1","#BCBCBC","#ACACAC","#8F8F8F","#4F4F4F","#292929","#050505"],Ut=Object.fromEntries(Yl.map((s,e)=>[`l${e}`,s])),Zl=()=>typeof window>"u"?!1:window.devicePixelRatio>1,Kl=Zl(),nr={key:"synnaxBase",name:"Synnax Base",colors:{primary:{m2:"#041B3D",m1:"#356fc5",z:"#3774D0",p1:"#5E94EE",p2:"#8AB8FF"},secondary:{m2:"#2D8F4E",m1:"#38B261",z:"#50C878",p1:"#73D393",p2:"#96DEAE"},gray:Ut,border:Ut.l4,error:{m2:S.zt.fromHSLA(ye(Nt,30)),m1:S.zt.fromHSLA(ye(Nt,40)),z:S.zt.fromHSLA(Nt),p1:S.zt.fromHSLA(ye(Nt,65)),p2:S.zt.fromHSLA(ye(Nt,77))},warning:{m2:S.zt.fromHSLA(ye(At,30)),m1:S.zt.fromHSLA(ye(At,40)),z:S.zt.fromHSLA(At),p1:S.zt.fromHSLA(ye(At,65)),p2:S.zt.fromHSLA(ye(At,75))},palettes:{recent:{key:"recent",name:"Recent",swatches:[]}},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:Ut.l11,textInverted:Ut.l0,textOnPrimary:Ut.l0},sizes:{base:Vl,border:{radius:3,width:Kl?.5:1,thickWidth:1},schematic:{elementStrokeWidth:2}},typography:{family:ql,codeFamily:Wl,h1:{size:6,weight:"500",lineHeight:6*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.6666,weight:"medium",lineHeight:2.6666*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:2.3333333}}},Ha=Object.freeze({...nr,key:"synnaxLight",name:"Synnax Light"}),Hl=["#020202","#080808","#151515","#242424","#2F2F2F","#3B3B3B","#4A4A4A","#5C5C5C","#767676","#959595","#dadada","#FAFAFA"],Ct=Object.fromEntries(Hl.map((s,e)=>[`l${e}`,s])),Ga=Object.freeze({...nr,key:"synnaxDark",name:"Synnax Dark",colors:{...nr.colors,gray:Ct,logo:"var(--pluto-text-color)",border:Ct.l3,text:Ct.l11,textInverted:Ct.l0,textOnPrimary:Ct.l11}}),Gl={synnaxDark:Ga,synnaxLight:Ha},Jl=["tiny","small","medium","large","huge"],Xl=i.z.enum(Jl),Ql=s=>Xl.safeParse(s).success;var eh=Object.defineProperty,th=(s,e,t)=>e in s?eh(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,l=(s,e,t)=>th(s,typeof e!="symbol"?e+"":e,t);const b=s=>Array.isArray(s)?s:[s],sh="policy",Ja="allow_all";var nh=Object.defineProperty,rh=(s,e,t)=>e in s?nh(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,G=(s,e,t)=>rh(s,typeof e!="symbol"?e+"":e,t);const ih=s=>{const e=s.replace(/_[a-z]/g,t=>t[1].toUpperCase());return e.length>1&&e[0]===e[0].toUpperCase()&&e[1]===e[1].toUpperCase()||e.length===0?e:e[0].toLowerCase()+e.slice(1)},Xa=s=>{const e=(t,n=rr)=>{if(typeof t=="string")return s(t);if(Array.isArray(t))return t.map(o=>e(o,n));if(!kn(t))return t;n=oh(n);const r={},a=t;return Object.keys(a).forEach(o=>{let c=a[o];const h=s(o);n.recursive&&(kn(c)?Ri(c,n.keepTypesOnRecursion)||(c=e(c,n)):n.recursiveInArray&&ji(c)&&(c=[...c].map(d=>{let f=d;return kn(d)?Ri(f,n.keepTypesOnRecursion)||(f=e(d,n)):ji(d)&&(f=e({key:d},n).key),f}))),r[h]=c}),r};return e},Yr=Xa(ih),ah=s=>s.replace(/([a-z0-9])([A-Z])/g,(e,t,n)=>`${t}_${n.toLowerCase()}`),Qa=Xa(ah),rr={recursive:!0,recursiveInArray:!0,keepTypesOnRecursion:[Number,String,Uint8Array]},oh=(s=rr)=>(s.recursive==null?s=rr:s.recursiveInArray??(s.recursiveInArray=!1),s),ji=s=>s!=null&&Array.isArray(s),kn=s=>s!=null&&typeof s=="object"&&!Array.isArray(s),Ri=(s,e)=>(e||[]).some(t=>s instanceof t),Zr=s=>s!=null&&typeof s=="object"&&!Array.isArray(s);var ch=Object.defineProperty,lh=(s,e,t)=>e in s?ch(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,ft=(s,e,t)=>lh(s,typeof e!="symbol"?e+"":e,t);function hh(s){const e=s.length;let t=0,n=0;for(;n<e;){let r=s.charCodeAt(n++);if((r&4294967168)===0){t++;continue}else if((r&4294965248)===0)t+=2;else{if(r>=55296&&r<=56319&&n<e){const a=s.charCodeAt(n);(a&64512)===56320&&(++n,r=((r&1023)<<10)+(a&1023)+65536)}(r&4294901760)===0?t+=3:t+=4}}return t}function uh(s,e,t){const n=s.length;let r=t,a=0;for(;a<n;){let o=s.charCodeAt(a++);if((o&4294967168)===0){e[r++]=o;continue}else if((o&4294965248)===0)e[r++]=o>>6&31|192;else{if(o>=55296&&o<=56319&&a<n){const c=s.charCodeAt(a);(c&64512)===56320&&(++a,o=((o&1023)<<10)+(c&1023)+65536)}(o&4294901760)===0?(e[r++]=o>>12&15|224,e[r++]=o>>6&63|128):(e[r++]=o>>18&7|240,e[r++]=o>>12&63|128,e[r++]=o>>6&63|128)}e[r++]=o&63|128}}const dh=new TextEncoder,fh=50;function yh(s,e,t){dh.encodeInto(s,e.subarray(t))}function ph(s,e,t){s.length>fh?yh(s,e,t):uh(s,e,t)}const gh=4096;function eo(s,e,t){let n=e;const r=n+t,a=[];let o="";for(;n<r;){const c=s[n++];if((c&128)===0)a.push(c);else if((c&224)===192){const h=s[n++]&63;a.push((c&31)<<6|h)}else if((c&240)===224){const h=s[n++]&63,d=s[n++]&63;a.push((c&31)<<12|h<<6|d)}else if((c&248)===240){const h=s[n++]&63,d=s[n++]&63,f=s[n++]&63;let u=(c&7)<<18|h<<12|d<<6|f;u>65535&&(u-=65536,a.push(u>>>10&1023|55296),u=56320|u&1023),a.push(u)}else a.push(c);a.length>=gh&&(o+=String.fromCharCode(...a),a.length=0)}return a.length>0&&(o+=String.fromCharCode(...a)),o}const mh=new TextDecoder,wh=200;function bh(s,e,t){const n=s.subarray(e,e+t);return mh.decode(n)}function vh(s,e,t){return t>wh?bh(s,e,t):eo(s,e,t)}let Ns=class{constructor(s,e){this.type=s,this.data=e}},Te=class ir extends Error{constructor(e){super(e);const t=Object.create(ir.prototype);Object.setPrototypeOf(this,t),Object.defineProperty(this,"name",{configurable:!0,enumerable:!1,value:ir.name})}};const Bt=4294967295;function zh(s,e,t){const n=t/4294967296,r=t;s.setUint32(e,n),s.setUint32(e+4,r)}function to(s,e,t){const n=Math.floor(t/4294967296),r=t;s.setUint32(e,n),s.setUint32(e+4,r)}function so(s,e){const t=s.getInt32(e),n=s.getUint32(e+4);return t*4294967296+n}function Sh(s,e){const t=s.getUint32(e),n=s.getUint32(e+4);return t*4294967296+n}const Th=-1,Oh=4294967296-1,kh=17179869184-1;function xh({sec:s,nsec:e}){if(s>=0&&e>=0&&s<=kh)if(e===0&&s<=Oh){const t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,s),t}else{const t=s/4294967296,n=s&4294967295,r=new Uint8Array(8),a=new DataView(r.buffer);return a.setUint32(0,e<<2|t&3),a.setUint32(4,n),r}else{const t=new Uint8Array(12),n=new DataView(t.buffer);return n.setUint32(0,e),to(n,4,s),t}}function Ih(s){const e=s.getTime(),t=Math.floor(e/1e3),n=(e-t*1e3)*1e6,r=Math.floor(n/1e9);return{sec:t+r,nsec:n-r*1e9}}function Eh(s){if(s instanceof Date){const e=Ih(s);return xh(e)}else return null}function Nh(s){const e=new DataView(s.buffer,s.byteOffset,s.byteLength);switch(s.byteLength){case 4:return{sec:e.getUint32(0),nsec:0};case 8:{const t=e.getUint32(0),n=e.getUint32(4),r=(t&3)*4294967296+n,a=t>>>2;return{sec:r,nsec:a}}case 12:{const t=so(e,4),n=e.getUint32(0);return{sec:t,nsec:n}}default:throw new Te(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${s.length}`)}}function Ah(s){const e=Nh(s);return new Date(e.sec*1e3+e.nsec/1e6)}const Uh={type:Th,encode:Eh,decode:Ah};let cs=class{constructor(){this.builtInEncoders=[],this.builtInDecoders=[],this.encoders=[],this.decoders=[],this.register(Uh)}register({type:s,encode:e,decode:t}){if(s>=0)this.encoders[s]=e,this.decoders[s]=t;else{const n=-1-s;this.builtInEncoders[n]=e,this.builtInDecoders[n]=t}}tryToEncode(s,e){for(let t=0;t<this.builtInEncoders.length;t++){const n=this.builtInEncoders[t];if(n!=null){const r=n(s,e);if(r!=null){const a=-1-t;return new Ns(a,r)}}}for(let t=0;t<this.encoders.length;t++){const n=this.encoders[t];if(n!=null){const r=n(s,e);if(r!=null){const a=t;return new Ns(a,r)}}}return s instanceof Ns?s:null}decode(s,e,t){const n=e<0?this.builtInDecoders[-1-e]:this.decoders[e];return n?n(s,e,t):new Ns(e,s)}};cs.defaultCodec=new cs;function Ch(s){return s instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&s instanceof SharedArrayBuffer}function ar(s){return s instanceof Uint8Array?s:ArrayBuffer.isView(s)?new Uint8Array(s.buffer,s.byteOffset,s.byteLength):Ch(s)?new Uint8Array(s):Uint8Array.from(s)}const Bh=100,jh=2048;let Rh=class no{constructor(e){this.entered=!1,this.extensionCodec=(e==null?void 0:e.extensionCodec)??cs.defaultCodec,this.context=e==null?void 0:e.context,this.useBigInt64=(e==null?void 0:e.useBigInt64)??!1,this.maxDepth=(e==null?void 0:e.maxDepth)??Bh,this.initialBufferSize=(e==null?void 0:e.initialBufferSize)??jh,this.sortKeys=(e==null?void 0:e.sortKeys)??!1,this.forceFloat32=(e==null?void 0:e.forceFloat32)??!1,this.ignoreUndefined=(e==null?void 0:e.ignoreUndefined)??!1,this.forceIntegerToFloat=(e==null?void 0:e.forceIntegerToFloat)??!1,this.pos=0,this.view=new DataView(new ArrayBuffer(this.initialBufferSize)),this.bytes=new Uint8Array(this.view.buffer)}clone(){return new no({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,maxDepth:this.maxDepth,initialBufferSize:this.initialBufferSize,sortKeys:this.sortKeys,forceFloat32:this.forceFloat32,ignoreUndefined:this.ignoreUndefined,forceIntegerToFloat:this.forceIntegerToFloat})}reinitializeState(){this.pos=0}encodeSharedRef(e){if(this.entered)return this.clone().encodeSharedRef(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.subarray(0,this.pos)}finally{this.entered=!1}}encode(e){if(this.entered)return this.clone().encode(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.slice(0,this.pos)}finally{this.entered=!1}}doEncode(e,t){if(t>this.maxDepth)throw new Error(`Too deep objects in depth ${t}`);e==null?this.encodeNil():typeof e=="boolean"?this.encodeBoolean(e):typeof e=="number"?this.forceIntegerToFloat?this.encodeNumberAsFloat(e):this.encodeNumber(e):typeof e=="string"?this.encodeString(e):this.useBigInt64&&typeof e=="bigint"?this.encodeBigInt64(e):this.encodeObject(e,t)}ensureBufferSizeToWrite(e){const t=this.pos+e;this.view.byteLength<t&&this.resizeBuffer(t*2)}resizeBuffer(e){const t=new ArrayBuffer(e),n=new Uint8Array(t),r=new DataView(t);n.set(this.bytes),this.view=r,this.bytes=n}encodeNil(){this.writeU8(192)}encodeBoolean(e){e===!1?this.writeU8(194):this.writeU8(195)}encodeNumber(e){!this.forceIntegerToFloat&&Number.isSafeInteger(e)?e>=0?e<128?this.writeU8(e):e<256?(this.writeU8(204),this.writeU8(e)):e<65536?(this.writeU8(205),this.writeU16(e)):e<4294967296?(this.writeU8(206),this.writeU32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(207),this.writeU64(e)):e>=-32?this.writeU8(224|e+32):e>=-128?(this.writeU8(208),this.writeI8(e)):e>=-32768?(this.writeU8(209),this.writeI16(e)):e>=-2147483648?(this.writeU8(210),this.writeI32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(211),this.writeI64(e)):this.encodeNumberAsFloat(e)}encodeNumberAsFloat(e){this.forceFloat32?(this.writeU8(202),this.writeF32(e)):(this.writeU8(203),this.writeF64(e))}encodeBigInt64(e){e>=BigInt(0)?(this.writeU8(207),this.writeBigUint64(e)):(this.writeU8(211),this.writeBigInt64(e))}writeStringHeader(e){if(e<32)this.writeU8(160+e);else if(e<256)this.writeU8(217),this.writeU8(e);else if(e<65536)this.writeU8(218),this.writeU16(e);else if(e<4294967296)this.writeU8(219),this.writeU32(e);else throw new Error(`Too long string: ${e} bytes in UTF-8`)}encodeString(e){const t=hh(e);this.ensureBufferSizeToWrite(5+t),this.writeStringHeader(t),ph(e,this.bytes,this.pos),this.pos+=t}encodeObject(e,t){const n=this.extensionCodec.tryToEncode(e,this.context);if(n!=null)this.encodeExtension(n);else if(Array.isArray(e))this.encodeArray(e,t);else if(ArrayBuffer.isView(e))this.encodeBinary(e);else if(typeof e=="object")this.encodeMap(e,t);else throw new Error(`Unrecognized object: ${Object.prototype.toString.apply(e)}`)}encodeBinary(e){const t=e.byteLength;if(t<256)this.writeU8(196),this.writeU8(t);else if(t<65536)this.writeU8(197),this.writeU16(t);else if(t<4294967296)this.writeU8(198),this.writeU32(t);else throw new Error(`Too large binary: ${t}`);const n=ar(e);this.writeU8a(n)}encodeArray(e,t){const n=e.length;if(n<16)this.writeU8(144+n);else if(n<65536)this.writeU8(220),this.writeU16(n);else if(n<4294967296)this.writeU8(221),this.writeU32(n);else throw new Error(`Too large array: ${n}`);for(const r of e)this.doEncode(r,t+1)}countWithoutUndefined(e,t){let n=0;for(const r of t)e[r]!==void 0&&n++;return n}encodeMap(e,t){const n=Object.keys(e);this.sortKeys&&n.sort();const r=this.ignoreUndefined?this.countWithoutUndefined(e,n):n.length;if(r<16)this.writeU8(128+r);else if(r<65536)this.writeU8(222),this.writeU16(r);else if(r<4294967296)this.writeU8(223),this.writeU32(r);else throw new Error(`Too large map object: ${r}`);for(const a of n){const o=e[a];this.ignoreUndefined&&o===void 0||(this.encodeString(a),this.doEncode(o,t+1))}}encodeExtension(e){if(typeof e.data=="function"){const n=e.data(this.pos+6),r=n.length;if(r>=4294967296)throw new Error(`Too large extension object: ${r}`);this.writeU8(201),this.writeU32(r),this.writeI8(e.type),this.writeU8a(n);return}const t=e.data.length;if(t===1)this.writeU8(212);else if(t===2)this.writeU8(213);else if(t===4)this.writeU8(214);else if(t===8)this.writeU8(215);else if(t===16)this.writeU8(216);else if(t<256)this.writeU8(199),this.writeU8(t);else if(t<65536)this.writeU8(200),this.writeU16(t);else if(t<4294967296)this.writeU8(201),this.writeU32(t);else throw new Error(`Too large extension object: ${t}`);this.writeI8(e.type),this.writeU8a(e.data)}writeU8(e){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,e),this.pos++}writeU8a(e){const t=e.length;this.ensureBufferSizeToWrite(t),this.bytes.set(e,this.pos),this.pos+=t}writeI8(e){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,e),this.pos++}writeU16(e){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,e),this.pos+=2}writeI16(e){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,e),this.pos+=2}writeU32(e){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,e),this.pos+=4}writeI32(e){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,e),this.pos+=4}writeF32(e){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,e),this.pos+=4}writeF64(e){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,e),this.pos+=8}writeU64(e){this.ensureBufferSizeToWrite(8),zh(this.view,this.pos,e),this.pos+=8}writeI64(e){this.ensureBufferSizeToWrite(8),to(this.view,this.pos,e),this.pos+=8}writeBigUint64(e){this.ensureBufferSizeToWrite(8),this.view.setBigUint64(this.pos,e),this.pos+=8}writeBigInt64(e){this.ensureBufferSizeToWrite(8),this.view.setBigInt64(this.pos,e),this.pos+=8}};function $t(s,e){return new Rh(e).encodeSharedRef(s)}function xn(s){return`${s<0?"-":""}0x${Math.abs(s).toString(16).padStart(2,"0")}`}const Mh=16,Ph=16;class Dh{constructor(e=Mh,t=Ph){this.hit=0,this.miss=0,this.maxKeyLength=e,this.maxLengthPerKey=t,this.caches=[];for(let n=0;n<this.maxKeyLength;n++)this.caches.push([])}canBeCached(e){return e>0&&e<=this.maxKeyLength}find(e,t,n){const r=this.caches[n-1];e:for(const a of r){const o=a.bytes;for(let c=0;c<n;c++)if(o[c]!==e[t+c])continue e;return a.str}return null}store(e,t){const n=this.caches[e.length-1],r={bytes:e,str:t};n.length>=this.maxLengthPerKey?n[Math.random()*n.length|0]=r:n.push(r)}decode(e,t,n){const r=this.find(e,t,n);if(r!=null)return this.hit++,r;this.miss++;const a=eo(e,t,n),o=Uint8Array.prototype.slice.call(e,t,t+n);return this.store(o,a),a}}const or="array",ss="map_key",ro="map_value",$h=s=>{if(typeof s=="string"||typeof s=="number")return s;throw new Te("The type of key must be string or number but "+typeof s)};class Lh{constructor(){this.stack=[],this.stackHeadPosition=-1}get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState(e){const t=this.getUninitializedStateFromPool();t.type=or,t.position=0,t.size=e,t.array=new Array(e)}pushMapState(e){const t=this.getUninitializedStateFromPool();t.type=ss,t.readCount=0,t.size=e,t.map={}}getUninitializedStateFromPool(){if(this.stackHeadPosition++,this.stackHeadPosition===this.stack.length){const e={type:void 0,size:0,array:void 0,position:0,readCount:0,map:void 0,key:null};this.stack.push(e)}return this.stack[this.stackHeadPosition]}release(e){if(this.stack[this.stackHeadPosition]!==e)throw new Error("Invalid stack state. Released state is not on top of the stack.");if(e.type===or){const t=e;t.size=0,t.array=void 0,t.position=0,t.type=void 0}if(e.type===ss||e.type===ro){const t=e;t.size=0,t.map=void 0,t.readCount=0,t.type=void 0}this.stackHeadPosition--}reset(){this.stack.length=0,this.stackHeadPosition=-1}}const jt=-1,Kr=new DataView(new ArrayBuffer(0)),Fh=new Uint8Array(Kr.buffer);try{Kr.getInt8(0)}catch(s){if(!(s instanceof RangeError))throw new Error("This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access")}const Mi=new RangeError("Insufficient data"),_h=new Dh;let qh=class io{constructor(e){this.totalPos=0,this.pos=0,this.view=Kr,this.bytes=Fh,this.headByte=jt,this.stack=new Lh,this.entered=!1,this.extensionCodec=(e==null?void 0:e.extensionCodec)??cs.defaultCodec,this.context=e==null?void 0:e.context,this.useBigInt64=(e==null?void 0:e.useBigInt64)??!1,this.rawStrings=(e==null?void 0:e.rawStrings)??!1,this.maxStrLength=(e==null?void 0:e.maxStrLength)??Bt,this.maxBinLength=(e==null?void 0:e.maxBinLength)??Bt,this.maxArrayLength=(e==null?void 0:e.maxArrayLength)??Bt,this.maxMapLength=(e==null?void 0:e.maxMapLength)??Bt,this.maxExtLength=(e==null?void 0:e.maxExtLength)??Bt,this.keyDecoder=(e==null?void 0:e.keyDecoder)!==void 0?e.keyDecoder:_h,this.mapKeyConverter=(e==null?void 0:e.mapKeyConverter)??$h}clone(){return new io({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,rawStrings:this.rawStrings,maxStrLength:this.maxStrLength,maxBinLength:this.maxBinLength,maxArrayLength:this.maxArrayLength,maxMapLength:this.maxMapLength,maxExtLength:this.maxExtLength,keyDecoder:this.keyDecoder})}reinitializeState(){this.totalPos=0,this.headByte=jt,this.stack.reset()}setBuffer(e){const t=ar(e);this.bytes=t,this.view=new DataView(t.buffer,t.byteOffset,t.byteLength),this.pos=0}appendBuffer(e){if(this.headByte===jt&&!this.hasRemaining(1))this.setBuffer(e);else{const t=this.bytes.subarray(this.pos),n=ar(e),r=new Uint8Array(t.length+n.length);r.set(t),r.set(n,t.length),this.setBuffer(r)}}hasRemaining(e){return this.view.byteLength-this.pos>=e}createExtraByteError(e){const{view:t,pos:n}=this;return new RangeError(`Extra ${t.byteLength-n} of ${t.byteLength} byte(s) found at buffer[${e}]`)}decode(e){if(this.entered)return this.clone().decode(e);try{this.entered=!0,this.reinitializeState(),this.setBuffer(e);const t=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return t}finally{this.entered=!1}}*decodeMulti(e){if(this.entered){yield*this.clone().decodeMulti(e);return}try{for(this.entered=!0,this.reinitializeState(),this.setBuffer(e);this.hasRemaining(1);)yield this.doDecodeSync()}finally{this.entered=!1}}async decodeAsync(e){if(this.entered)return this.clone().decodeAsync(e);try{this.entered=!0;let t=!1,n;for await(const c of e){if(t)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(c);try{n=this.doDecodeSync(),t=!0}catch(h){if(!(h instanceof RangeError))throw h}this.totalPos+=this.pos}if(t){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return n}const{headByte:r,pos:a,totalPos:o}=this;throw new RangeError(`Insufficient data in parsing ${xn(r)} at ${o} (${a} in the current buffer)`)}finally{this.entered=!1}}decodeArrayStream(e){return this.decodeMultiAsync(e,!0)}decodeStream(e){return this.decodeMultiAsync(e,!1)}async*decodeMultiAsync(e,t){if(this.entered){yield*this.clone().decodeMultiAsync(e,t);return}try{this.entered=!0;let n=t,r=-1;for await(const a of e){if(t&&r===0)throw this.createExtraByteError(this.totalPos);this.appendBuffer(a),n&&(r=this.readArraySize(),n=!1,this.complete());try{for(;yield this.doDecodeSync(),--r!==0;);}catch(o){if(!(o instanceof RangeError))throw o}this.totalPos+=this.pos}}finally{this.entered=!1}}doDecodeSync(){e:for(;;){const e=this.readHeadByte();let t;if(e>=224)t=e-256;else if(e<192)if(e<128)t=e;else if(e<144){const r=e-128;if(r!==0){this.pushMapState(r),this.complete();continue e}else t={}}else if(e<160){const r=e-144;if(r!==0){this.pushArrayState(r),this.complete();continue e}else t=[]}else{const r=e-160;t=this.decodeString(r,0)}else if(e===192)t=null;else if(e===194)t=!1;else if(e===195)t=!0;else if(e===202)t=this.readF32();else if(e===203)t=this.readF64();else if(e===204)t=this.readU8();else if(e===205)t=this.readU16();else if(e===206)t=this.readU32();else if(e===207)this.useBigInt64?t=this.readU64AsBigInt():t=this.readU64();else if(e===208)t=this.readI8();else if(e===209)t=this.readI16();else if(e===210)t=this.readI32();else if(e===211)this.useBigInt64?t=this.readI64AsBigInt():t=this.readI64();else if(e===217){const r=this.lookU8();t=this.decodeString(r,1)}else if(e===218){const r=this.lookU16();t=this.decodeString(r,2)}else if(e===219){const r=this.lookU32();t=this.decodeString(r,4)}else if(e===220){const r=this.readU16();if(r!==0){this.pushArrayState(r),this.complete();continue e}else t=[]}else if(e===221){const r=this.readU32();if(r!==0){this.pushArrayState(r),this.complete();continue e}else t=[]}else if(e===222){const r=this.readU16();if(r!==0){this.pushMapState(r),this.complete();continue e}else t={}}else if(e===223){const r=this.readU32();if(r!==0){this.pushMapState(r),this.complete();continue e}else t={}}else if(e===196){const r=this.lookU8();t=this.decodeBinary(r,1)}else if(e===197){const r=this.lookU16();t=this.decodeBinary(r,2)}else if(e===198){const r=this.lookU32();t=this.decodeBinary(r,4)}else if(e===212)t=this.decodeExtension(1,0);else if(e===213)t=this.decodeExtension(2,0);else if(e===214)t=this.decodeExtension(4,0);else if(e===215)t=this.decodeExtension(8,0);else if(e===216)t=this.decodeExtension(16,0);else if(e===199){const r=this.lookU8();t=this.decodeExtension(r,1)}else if(e===200){const r=this.lookU16();t=this.decodeExtension(r,2)}else if(e===201){const r=this.lookU32();t=this.decodeExtension(r,4)}else throw new Te(`Unrecognized type byte: ${xn(e)}`);this.complete();const n=this.stack;for(;n.length>0;){const r=n.top();if(r.type===or)if(r.array[r.position]=t,r.position++,r.position===r.size)t=r.array,n.release(r);else continue e;else if(r.type===ss){if(t==="__proto__")throw new Te("The key __proto__ is not allowed");r.key=this.mapKeyConverter(t),r.type=ro;continue e}else if(r.map[r.key]=t,r.readCount++,r.readCount===r.size)t=r.map,n.release(r);else{r.key=null,r.type=ss;continue e}}return t}}readHeadByte(){return this.headByte===jt&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=jt}readArraySize(){const e=this.readHeadByte();switch(e){case 220:return this.readU16();case 221:return this.readU32();default:{if(e<160)return e-144;throw new Te(`Unrecognized array type byte: ${xn(e)}`)}}}pushMapState(e){if(e>this.maxMapLength)throw new Te(`Max length exceeded: map length (${e}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState(e)}pushArrayState(e){if(e>this.maxArrayLength)throw new Te(`Max length exceeded: array length (${e}) > maxArrayLength (${this.maxArrayLength})`);this.stack.pushArrayState(e)}decodeString(e,t){return!this.rawStrings||this.stateIsMapKey()?this.decodeUtf8String(e,t):this.decodeBinary(e,t)}decodeUtf8String(e,t){var n;if(e>this.maxStrLength)throw new Te(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+t+e)throw Mi;const r=this.pos+t;let a;return this.stateIsMapKey()&&(n=this.keyDecoder)!=null&&n.canBeCached(e)?a=this.keyDecoder.decode(this.bytes,r,e):a=vh(this.bytes,r,e),this.pos+=t+e,a}stateIsMapKey(){return this.stack.length>0?this.stack.top().type===ss:!1}decodeBinary(e,t){if(e>this.maxBinLength)throw new Te(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(e+t))throw Mi;const n=this.pos+t,r=this.bytes.subarray(n,n+e);return this.pos+=t+e,r}decodeExtension(e,t){if(e>this.maxExtLength)throw new Te(`Max length exceeded: ext length (${e}) > maxExtLength (${this.maxExtLength})`);const n=this.view.getInt8(this.pos+t),r=this.decodeBinary(e,t+1);return this.extensionCodec.decode(r,n,this.context)}lookU8(){return this.view.getUint8(this.pos)}lookU16(){return this.view.getUint16(this.pos)}lookU32(){return this.view.getUint32(this.pos)}readU8(){const e=this.view.getUint8(this.pos);return this.pos++,e}readI8(){const e=this.view.getInt8(this.pos);return this.pos++,e}readU16(){const e=this.view.getUint16(this.pos);return this.pos+=2,e}readI16(){const e=this.view.getInt16(this.pos);return this.pos+=2,e}readU32(){const e=this.view.getUint32(this.pos);return this.pos+=4,e}readI32(){const e=this.view.getInt32(this.pos);return this.pos+=4,e}readU64(){const e=Sh(this.view,this.pos);return this.pos+=8,e}readI64(){const e=so(this.view,this.pos);return this.pos+=8,e}readU64AsBigInt(){const e=this.view.getBigUint64(this.pos);return this.pos+=8,e}readI64AsBigInt(){const e=this.view.getBigInt64(this.pos);return this.pos+=8,e}readF32(){const e=this.view.getFloat32(this.pos);return this.pos+=4,e}readF64(){const e=this.view.getFloat64(this.pos);return this.pos+=8,e}};function ao(s,e){return new qh(e).decode(s)}let Wh=class{constructor(){ft(this,"contentType","application/json"),ft(this,"decoder"),ft(this,"encoder"),this.decoder=new TextDecoder,this.encoder=new TextEncoder}encode(s){return this.encoder.encode(this.encodeString(s))}decode(s,e){return this.decodeString(this.decoder.decode(s),e)}decodeString(s,e){const t=JSON.parse(s),n=Yr(t);return e!=null?e.parse(n):n}encodeString(s){const e=Qa(s);return JSON.stringify(e,(t,n)=>ArrayBuffer.isView(n)?Array.from(n):Zr(n)&&"encode_value"in n?typeof n.value=="bigint"?n.value.toString():n.value:typeof n=="bigint"?n.toString():n)}static registerCustomType(){}},Vh=class{constructor(){ft(this,"contentType","text/csv")}encode(s){const e=this.encodeString(s);return new TextEncoder().encode(e)}decode(s,e){const t=new TextDecoder().decode(s);return this.decodeString(t,e)}encodeString(s){if(!Array.isArray(s)||s.length===0||!Zr(s[0]))throw new Error("Payload must be an array of objects");const e=Object.keys(s[0]),t=[e.join(",")];return s.forEach(n=>{const r=e.map(a=>JSON.stringify(n[a]??""));t.push(r.join(","))}),t.join(`
2
+ `)}decodeString(s,e){const[t,...n]=s.trim().split(`
3
+ `).map(o=>o.trim());if(t.length===0)return e!=null?e.parse({}):{};const r=t.split(",").map(o=>o.trim()),a={};return r.forEach(o=>{a[o]=[]}),n.forEach(o=>{const c=o.split(",").map(h=>h.trim());r.forEach((h,d)=>{const f=this.parseValue(c[d]);f!=null&&a[h].push(f)})}),e!=null?e.parse(a):a}parseValue(s){if(s==null||s.length===0)return null;const e=Number(s);return isNaN(e)?s.startsWith('"')&&s.endsWith('"')?s.slice(1,-1):s:e}static registerCustomType(){}},Yh=class{constructor(){ft(this,"contentType","text/plain")}encode(s){return new TextEncoder().encode(s)}decode(s,e){const t=new TextDecoder().decode(s);return e!=null?e.parse(t):t}};const Ve=new cs;Ve.register({type:0,encode:s=>{if(ArrayBuffer.isView(s)){const e=Array.from(s);return $t(e,{extensionCodec:Ve})}return Zr(s)&&"encode_value"in s?typeof s.value=="bigint"?$t(s.value.toString(),{extensionCodec:Ve}):$t(s.value,{extensionCodec:Ve}):typeof s=="bigint"?$t(s.toString(),{extensionCodec:Ve}):null},decode:s=>ao(s,{extensionCodec:Ve})});let Zh=class{constructor(){ft(this,"contentType","application/msgpack")}encode(s){const e=Qa(s);return $t(e,{extensionCodec:Ve}).slice()}decode(s,e){const t=ao(s,{extensionCodec:Ve}),n=Yr(t);return e!=null?e.parse(n):n}static registerCustomType(){}};const Ls=new Wh;new Vh;new Yh;new Zh;const Kh=s=>s!=null&&typeof s=="object"&&"toString"in s,Hh=(s,e=!1)=>{const t=Kh(s)?"stringer":typeof s;let n;switch(t){case"string":n=(r,a)=>r.localeCompare(a);break;case"stringer":n=(r,a)=>r.toString().localeCompare(a.toString());break;case"number":n=(r,a)=>Number(r)-Number(a);break;case"bigint":n=(r,a)=>BigInt(r)-BigInt(a)>0n?1:-1;break;case"boolean":n=(r,a)=>Number(r)-Number(a);break;case"undefined":n=()=>0;break;default:return console.warn(`sortFunc: unknown type ${t}`),()=>-1}return e?Gh(n):n},Gh=s=>(e,t)=>s(t,e),sn=i.z.tuple([i.z.number(),i.z.number()]);i.z.tuple([i.z.bigint(),i.z.bigint()]);const oo=i.z.object({width:i.z.number(),height:i.z.number()}),Jh=i.z.object({signedWidth:i.z.number(),signedHeight:i.z.number()}),Xh=["width","height"];i.z.enum(Xh);const Qh=["start","center","end"],eu=["signedWidth","signedHeight"];i.z.enum(eu);const Hs=i.z.object({x:i.z.number(),y:i.z.number()}),tu=i.z.object({clientX:i.z.number(),clientY:i.z.number()}),su=["x","y"],co=i.z.enum(su),lo=["top","right","bottom","left"];i.z.enum(lo);const nu=["left","right"],ho=i.z.enum(nu),ru=["top","bottom"],uo=i.z.enum(ru),fo=["center"],Pi=i.z.enum(fo),iu=[...lo,...fo],yo=i.z.enum(iu);i.z.enum(Qh);const au=["first","last"];i.z.enum(au);const ou=i.z.object({lower:i.z.number(),upper:i.z.number()}),cu=i.z.object({lower:i.z.bigint(),upper:i.z.bigint()});i.z.union([ou,sn]);i.z.union([cu,sn]);i.z.enum([...co.options,...yo.options]);i.z.union([co,yo,i.z.instanceof(String)]);const lu=s=>typeof s=="bigint"||s instanceof BigInt,ot=(s,e)=>lu(s)?s.valueOf()*BigInt(e.valueOf()):s.valueOf()*Number(e.valueOf()),Qe=(s,e)=>{const t={};if(typeof s=="number"||typeof s=="bigint")e!=null?(t.lower=s,t.upper=e):(t.lower=typeof s=="bigint"?0n:0,t.upper=s);else if(Array.isArray(s)){if(s.length!==2)throw new Error("bounds: expected array of length 2");[t.lower,t.upper]=s}else return Di(s);return Di(t)},Di=s=>s.lower>s.upper?{lower:s.upper,upper:s.lower}:s,$i=(s,e)=>{const t=Qe(s);return e<t.lower?t.lower:e>=t.upper?t.upper-(typeof t.upper=="number"?1:1n):e};i.z.object({x:ho.or(Pi),y:uo.or(Pi)});const hu=i.z.object({x:ho,y:uo}),uu=Object.freeze({x:"left",y:"top"}),du=(s,e)=>s.x===e.x&&s.y===e.y,Li=i.z.union([i.z.number(),Hs,sn,oo,Jh,tu]),fu=(s,e)=>{if(typeof s=="string"){if(e===void 0)throw new Error("The y coordinate must be given.");return s==="x"?{x:e,y:0}:{x:0,y:e}}return typeof s=="number"?{x:s,y:e??s}:Array.isArray(s)?{x:s[0],y:s[1]}:"signedWidth"in s?{x:s.signedWidth,y:s.signedHeight}:"clientX"in s?{x:s.clientX,y:s.clientY}:"width"in s?{x:s.width,y:s.height}:{x:s.x,y:s.y}},Fi=Object.freeze({x:0,y:0}),As=i.z.union([i.z.number(),i.z.string()]);i.z.object({top:As,left:As,width:As,height:As});i.z.object({left:i.z.number(),top:i.z.number(),right:i.z.number(),bottom:i.z.number()});i.z.object({one:Hs,two:Hs,root:hu});const Hr=(s,e,t=0,n=0,r)=>{const a={one:{...Fi},two:{...Fi},root:r??uu};if(typeof s=="number"){if(typeof e!="number")throw new Error("Box constructor called with invalid arguments");return a.one={x:s,y:e},a.two={x:a.one.x+t,y:a.one.y+n},a}return"one"in s&&"two"in s&&"root"in s?{...s,root:r??s.root}:("getBoundingClientRect"in s&&(s=s.getBoundingClientRect()),"left"in s?(a.one={x:s.left,y:s.top},a.two={x:s.right,y:s.bottom},a):(a.one=s,e==null?a.two={x:a.one.x+t,y:a.one.y+n}:typeof e=="number"?a.two={x:a.one.x+e,y:a.one.y+t}:"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))},In=s=>{const e=Hr(s);return{lower:e.one.x,upper:e.two.x}},En=s=>{const e=Hr(s);return{lower:e.one.y,upper:e.two.y}},yu=s=>typeof s!="object"||s==null?!1:"one"in s&&"two"in s&&"root"in s,pu=i.z.object({signedWidth:i.z.number(),signedHeight:i.z.number()});i.z.union([oo,pu,Hs,sn]);var gu=Object.defineProperty,mu=(s,e,t)=>e in s?gu(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Be=(s,e,t)=>mu(s,typeof e!="symbol"?e+"":e,t);const wu=(s,e,t)=>e!==void 0&&s<e?e:t!==void 0&&s>t?t:s;i.z.object({offset:Li,scale:Li});i.z.object({offset:i.z.number(),scale:i.z.number()});const bu=s=>(e,t,n,r)=>t==="dimension"?[e,n]:[e,r?n-s:n+s],vu=s=>(e,t,n,r)=>[e,r?n/s:n*s],zu=s=>(e,t,n)=>{if(e===null)return[s,n];const{lower:r,upper:a}=e,{lower:o,upper:c}=s,h=a-r,d=c-o;if(t==="dimension")return[s,n*(d/h)];const f=(n-r)*(d/h)+o;return[s,f]},Su=s=>(e,t,n)=>[s,n],Tu=()=>(s,e,t)=>{if(s===null)throw new Error("cannot invert without bounds");if(e==="dimension")return[s,t];const{lower:n,upper:r}=s;return[s,r-(t-n)]},Ou=s=>(e,t,n)=>{const{lower:r,upper:a}=s;return n=wu(n,r,a),[e,n]},cr=class Lt{constructor(){Be(this,"ops",[]),Be(this,"currBounds",null),Be(this,"currType",null),Be(this,"reversed",!1),this.ops=[]}static translate(e){return new Lt().translate(e)}static magnify(e){return new Lt().magnify(e)}static scale(e,t){return new Lt().scale(e,t)}translate(e){const t=this.new(),n=bu(e);return n.type="translate",t.ops.push(n),t}magnify(e){const t=this.new(),n=vu(e);return n.type="magnify",t.ops.push(n),t}scale(e,t){const n=Qe(e,t),r=this.new(),a=zu(n);return a.type="scale",r.ops.push(a),r}clamp(e,t){const n=Qe(e,t),r=this.new(),a=Ou(n);return a.type="clamp",r.ops.push(a),r}reBound(e,t){const n=Qe(e,t),r=this.new(),a=Su(n);return a.type="re-bound",r.ops.push(a),r}invert(){const e=Tu();e.type="invert";const t=this.new();return t.ops.push(e),t}pos(e){return this.exec("position",e)}dim(e){return this.exec("dimension",e)}new(){const e=new Lt;return e.ops=this.ops.slice(),e.reversed=this.reversed,e}exec(e,t){return this.currBounds=null,this.ops.reduce(([n,r],a)=>a(n,e,r,this.reversed),[null,t])[1]}reverse(){const e=this.new();e.ops.reverse();const t=[];return e.ops.forEach((n,r)=>{if(n.type==="scale"||t.some(([o,c])=>r>=o&&r<=c))return;const a=e.ops.findIndex((o,c)=>o.type==="scale"&&c>r);a!==-1&&t.push([r,a])}),t.forEach(([n,r])=>{const a=e.ops.slice(n,r);a.unshift(e.ops[r]),e.ops.splice(n,r-n+1,...a)}),e.reversed=!e.reversed,e}get transform(){return{scale:this.dim(1),offset:this.pos(0)}}};Be(cr,"IDENTITY",new cr);let _i=cr;const qi=class Ue{constructor(e=new _i,t=new _i,n=null){Be(this,"x"),Be(this,"y"),Be(this,"currRoot"),this.x=e,this.y=t,this.currRoot=n}static translate(e,t){return new Ue().translate(e,t)}static translateX(e){return new Ue().translateX(e)}static translateY(e){return new Ue().translateY(e)}static clamp(e){return new Ue().clamp(e)}static magnify(e){return new Ue().magnify(e)}static scale(e){return new Ue().scale(e)}static reBound(e){return new Ue().reBound(e)}translate(e,t){const n=fu(e,t),r=this.copy();return r.x=this.x.translate(n.x),r.y=this.y.translate(n.y),r}translateX(e){const t=this.copy();return t.x=this.x.translate(e),t}translateY(e){const t=this.copy();return t.y=this.y.translate(e),t}magnify(e){const t=this.copy();return t.x=this.x.magnify(e.x),t.y=this.y.magnify(e.y),t}scale(e){const t=this.copy();if(yu(e)){const n=this.currRoot;return t.currRoot=e.root,n!=null&&!du(n,e.root)&&(n.x!==e.root.x&&(t.x=t.x.invert()),n.y!==e.root.y&&(t.y=t.y.invert())),t.x=t.x.scale(In(e)),t.y=t.y.scale(En(e)),t}return t.x=t.x.scale(e.width),t.y=t.y.scale(e.height),t}reBound(e){const t=this.copy();return t.x=this.x.reBound(In(e)),t.y=this.y.reBound(En(e)),t}clamp(e){const t=this.copy();return t.x=this.x.clamp(In(e)),t.y=this.y.clamp(En(e)),t}copy(){const e=new Ue;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)}}dim(e){return{x:this.x.dim(e.x),y:this.y.dim(e.y)}}box(e){return Hr(this.pos(e.one),this.pos(e.two),0,0,this.currRoot??e.root)}get transform(){return{scale:this.dim({x:1,y:1}),offset:this.pos({x:0,y:0})}}};Be(qi,"IDENTITY",new qi);var ku=Object.defineProperty,xu=(s,e,t)=>e in s?ku(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,p=(s,e,t)=>xu(s,typeof e!="symbol"?e+"":e,t);let Iu=(s,e=21)=>(t=e)=>{let n="",r=t|0;for(;r--;)n+=s[Math.random()*s.length|0];return n};const Eu="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",Nu=Iu(Eu,11),Au=()=>Nu(),Uu=i.z.enum(["static","dynamic"]),po=(s,e)=>{const t=new $(e);if(![C.DAY,C.HOUR,C.MINUTE,C.SECOND,C.MILLISECOND,C.MICROSECOND,C.NANOSECOND].some(r=>r.equals(t)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const n=s.valueOf()%t.valueOf();return s instanceof $?new $(n):new C(n)},j=class v{constructor(e,t="UTC"){if(p(this,"value"),p(this,"encodeValue",!0),e==null)this.value=v.now().valueOf();else if(e instanceof Date)this.value=BigInt(e.getTime())*v.MILLISECOND.valueOf();else if(typeof e=="string")this.value=v.parseDateTimeString(e,t).valueOf();else if(Array.isArray(e))this.value=v.parseDate(e);else{let n=BigInt(0);e instanceof Number&&(e=e.valueOf()),t==="local"&&(n=v.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=v.MAX:e=v.MIN)),this.value=BigInt(e.valueOf())+n}}static parseDate([e=1970,t=1,n=1]){const r=new Date(e,t-1,n,0,0,0,0);return new v(BigInt(r.getTime())*v.MILLISECOND.valueOf()).truncate(v.DAY).valueOf()}valueOf(){return this.value}static parseTimeString(e,t="UTC"){const[n,r,a]=e.split(":");let o="00",c="00";a!=null&&([o,c]=a.split("."));let h=v.hours(parseInt(n??"00")).add(v.minutes(parseInt(r??"00"))).add(v.seconds(parseInt(o??"00"))).add(v.milliseconds(parseInt(c??"00")));return t==="local"&&(h=h.add(v.utcOffset)),h.valueOf()}static parseDateTimeString(e,t="UTC"){if(!e.includes("/")&&!e.includes("-"))return v.parseTimeString(e,t);const n=new Date(e);return e.includes(":")||n.setUTCHours(0,0,0,0),new v(BigInt(n.getTime())*v.MILLISECOND.valueOf(),t).valueOf()}fString(e="ISO",t="UTC"){switch(e){case"ISODate":return this.toISOString(t).slice(0,10);case"ISOTime":return this.toISOString(t).slice(11,23);case"time":return this.timeString(!1,t);case"preciseTime":return this.timeString(!0,t);case"date":return this.dateString();case"preciseDate":return`${this.dateString()} ${this.timeString(!0,t)}`;case"dateTime":return`${this.dateString()} ${this.timeString(!1,t)}`;default:return this.toISOString(t)}}toISOString(e="UTC"){return e==="UTC"?this.date().toISOString():this.sub(v.utcOffset).date().toISOString()}timeString(e=!1,t="UTC"){const n=this.toISOString(t);return e?n.slice(11,23):n.slice(11,19)}dateString(){const e=this.date(),t=e.toLocaleString("default",{month:"short"}),n=e.toLocaleString("default",{day:"numeric"});return`${t} ${n}`}static get utcOffset(){return new C(BigInt(new Date().getTimezoneOffset())*v.MINUTE.valueOf())}static since(e){return new v().span(e)}date(){return new Date(this.milliseconds)}equals(e){return this.valueOf()===new v(e).valueOf()}span(e){return this.range(e).span}range(e){return new ns(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 v(e).valueOf()}afterEq(e){return this.valueOf()>=new v(e).valueOf()}before(e){return this.valueOf()<new v(e).valueOf()}beforeEq(e){return this.valueOf()<=new v(e).valueOf()}add(e){return new v(this.valueOf()+BigInt(e.valueOf()))}sub(e){return new v(this.valueOf()-BigInt(e.valueOf()))}get hours(){return Number(this.valueOf())/Number(C.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(C.MINUTE.valueOf())}get days(){return Number(this.valueOf())/Number(C.DAY.valueOf())}get seconds(){return Number(this.valueOf())/Number(C.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(v.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(v.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get year(){return this.date().getFullYear()}setYear(e){const t=this.date();return t.setFullYear(e),new v(t)}get month(){return this.date().getUTCMonth()}setMonth(e){const t=this.date();return t.setUTCMonth(e),new v(t)}get day(){return this.date().getUTCDate()}setDay(e){const t=this.date();return t.setUTCDate(e),new v(t)}get hour(){return this.date().getUTCHours()}setHour(e){const t=this.date();return t.setUTCHours(e),new v(t,"UTC")}get minute(){return this.date().getMinutes()}setMinute(e){const t=this.date();return t.setUTCMinutes(e),new v(t)}get second(){return this.date().getSeconds()}setSecond(e){const t=this.date();return t.setUTCSeconds(e),new v(t)}get millisecond(){return this.date().getMilliseconds()}setMillisecond(e){const t=this.date();return t.setMilliseconds(e),new v(t)}toString(){return this.date().toISOString()}remainder(e){return po(this,e)}get isToday(){return this.truncate(C.DAY).equals(v.now().truncate(C.DAY))}truncate(e){return this.sub(this.remainder(e))}static now(){return new v(new Date)}static max(...e){let t=v.MIN;for(const n of e){const r=new v(n);r.after(t)&&(t=r)}return t}static min(...e){let t=v.MAX;for(const n of e){const r=new v(n);r.before(t)&&(t=r)}return t}static nanoseconds(e,t="UTC"){return new v(e,t)}static microseconds(e,t="UTC"){return v.nanoseconds(e*1e3,t)}static milliseconds(e,t="UTC"){return v.microseconds(e*1e3,t)}static seconds(e,t="UTC"){return v.milliseconds(e*1e3,t)}static minutes(e,t="UTC"){return v.seconds(e*60,t)}static hours(e,t="UTC"){return v.minutes(e*60,t)}static days(e,t="UTC"){return v.hours(e*24,t)}};p(j,"NANOSECOND",j.nanoseconds(1)),p(j,"MICROSECOND",j.microseconds(1)),p(j,"MILLISECOND",j.milliseconds(1)),p(j,"SECOND",j.seconds(1)),p(j,"MINUTE",j.minutes(1)),p(j,"HOUR",j.hours(1)),p(j,"DAY",j.days(1)),p(j,"MAX",new j((1n<<63n)-1n)),p(j,"MIN",new j(0)),p(j,"ZERO",new j(0)),p(j,"z",i.z.union([i.z.object({value:i.z.bigint()}).transform(s=>new j(s.value)),i.z.string().transform(s=>new j(BigInt(s))),i.z.instanceof(Number).transform(s=>new j(s)),i.z.number().transform(s=>new j(s)),i.z.instanceof(j)]));let $=j;const R=class I{constructor(e){p(this,"value"),p(this,"encodeValue",!0),typeof e=="number"&&(e=Math.trunc(e.valueOf())),this.value=BigInt(e.valueOf())}static fromSeconds(e){return e instanceof I?e:e instanceof Wi?e.period:e instanceof $?new I(e):["number","bigint"].includes(typeof e)?I.seconds(e):new I(e)}static fromMilliseconds(e){return e instanceof I?e:e instanceof Wi?e.period:e instanceof $?new I(e):["number","bigint"].includes(typeof e)?I.milliseconds(e):new I(e)}encode(){return this.value.toString()}valueOf(){return this.value}lessThan(e){return this.valueOf()<new I(e).valueOf()}greaterThan(e){return this.valueOf()>new I(e).valueOf()}lessThanOrEqual(e){return this.valueOf()<=new I(e).valueOf()}greaterThanOrEqual(e){return this.valueOf()>=new I(e).valueOf()}remainder(e){return po(this,e)}truncate(e){return new I(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(){const e=this.truncate(I.DAY),t=this.truncate(I.HOUR),n=this.truncate(I.MINUTE),r=this.truncate(I.SECOND),a=this.truncate(I.MILLISECOND),o=this.truncate(I.MICROSECOND),c=this.truncate(I.NANOSECOND),h=e,d=t.sub(e),f=n.sub(t),u=r.sub(n),T=a.sub(r),k=o.sub(a),Y=c.sub(o);let U="";return h.isZero||(U+=`${h.days}d `),d.isZero||(U+=`${d.hours}h `),f.isZero||(U+=`${f.minutes}m `),u.isZero||(U+=`${u.seconds}s `),T.isZero||(U+=`${T.milliseconds}ms `),k.isZero||(U+=`${k.microseconds}µs `),Y.isZero||(U+=`${Y.nanoseconds}ns`),U.trim()}mult(e){return new I(this.valueOf()*BigInt(e))}get days(){return Number(this.valueOf())/Number(I.DAY.valueOf())}get hours(){return Number(this.valueOf())/Number(I.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(I.MINUTE.valueOf())}get seconds(){return Number(this.valueOf())/Number(I.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(I.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(I.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===BigInt(0)}equals(e){return this.valueOf()===new I(e).valueOf()}add(e){return new I(this.valueOf()+new I(e).valueOf())}sub(e){return new I(this.valueOf()-new I(e).valueOf())}static nanoseconds(e=1){return new I(e)}static microseconds(e=1){return I.nanoseconds(ot(e,1e3))}static milliseconds(e=1){return I.microseconds(ot(e,1e3))}static seconds(e=1){return I.milliseconds(ot(e,1e3))}static minutes(e=1){return I.seconds(ot(e,60))}static hours(e){return I.minutes(ot(e,60))}static days(e){return I.hours(ot(e,24))}};p(R,"NANOSECOND",R.nanoseconds(1)),p(R,"MICROSECOND",R.microseconds(1)),p(R,"MILLISECOND",R.milliseconds(1)),p(R,"SECOND",R.seconds(1)),p(R,"MINUTE",R.minutes(1)),p(R,"HOUR",R.hours(1)),p(R,"DAY",R.days(1)),p(R,"MAX",new R((1n<<63n)-1n)),p(R,"MIN",new R(0)),p(R,"ZERO",new R(0)),p(R,"z",i.z.union([i.z.object({value:i.z.bigint()}).transform(s=>new R(s.value)),i.z.string().transform(s=>new R(BigInt(s))),i.z.instanceof(Number).transform(s=>new R(s)),i.z.number().transform(s=>new R(s)),i.z.instanceof(R)]));let C=R;const Ft=class Fs extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new Fs(e).valueOf()}get period(){return C.seconds(1/this.valueOf())}sampleCount(e){return new C(e).seconds*this.valueOf()}byteCount(e,t){return this.sampleCount(e)*new ie(t).valueOf()}span(e){return C.seconds(e/this.valueOf())}byteSpan(e,t){return this.span(e.valueOf()/t.valueOf())}static hz(e){return new Fs(e)}static khz(e){return Fs.hz(e*1e3)}};p(Ft,"z",i.z.union([i.z.number().transform(s=>new Ft(s)),i.z.instanceof(Number).transform(s=>new Ft(s)),i.z.instanceof(Ft)]));let Wi=Ft;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 lr(e*this.valueOf())}};p(X,"UNKNOWN",new X(0)),p(X,"BIT128",new X(16)),p(X,"BIT64",new X(8)),p(X,"BIT32",new X(4)),p(X,"BIT16",new X(2)),p(X,"BIT8",new X(1)),p(X,"z",i.z.union([i.z.number().transform(s=>new X(s)),i.z.instanceof(Number).transform(s=>new X(s)),i.z.instanceof(X)]));let ie=X;const be=class _t{constructor(e,t){p(this,"start"),p(this,"end"),typeof e=="object"&&"start"in e?(this.start=new $(e.start),this.end=new $(e.end)):(this.start=new $(e),this.end=new $(t))}get span(){return new C(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}get numeric(){return{start:Number(this.start.valueOf()),end:Number(this.end.valueOf())}}swap(){return new _t(this.end,this.start)}get numericBounds(){return{lower:Number(this.start.valueOf()),upper:Number(this.end.valueOf())}}equals(e,t=C.ZERO){if(t.isZero)return this.start.equals(e.start)&&this.end.equals(e.end);let n=this.start.sub(e.start).valueOf(),r=this.end.sub(e.end).valueOf();return n<0&&(n=-n),r<0&&(r=-r),n<=t.valueOf()&&r<=t.valueOf()}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.fString("preciseDate")} - ${this.span.toString()}`}overlapsWith(e,t=C.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 r=$.max(n.start,e.start),a=$.min(n.end,e.end);return a.before(r)?!1:new C(a.sub(r)).greaterThanOrEqual(t)}contains(e){return e instanceof _t?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const t=new _t(this.start,this.end);return e.start.after(this.start)&&(t.start=e.start),e.start.after(this.end)&&(t.end=e.start),e.end.before(this.end)&&(t.end=e.end),e.end.before(this.start)&&(t.start=e.end),t}static max(...e){return new _t($.min(...e.map(t=>t.start)),$.max(...e.map(t=>t.end)))}};p(be,"MAX",new be($.MIN,$.MAX)),p(be,"MIN",new be($.MAX,$.MIN)),p(be,"ZERO",new be($.ZERO,$.ZERO)),p(be,"z",i.z.union([i.z.object({start:$.z,end:$.z}).transform(s=>new be(s.start,s.end)),i.z.instanceof(be)]));let ns=be;const g=class _{constructor(e){if(p(this,"value"),p(this,"encodeValue",!0),e instanceof _||typeof e=="string"||typeof e.valueOf()=="string"){this.value=e.valueOf();return}const t=_.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(t!=null){this.value=t.valueOf();return}throw this.value=_.UNKNOWN.valueOf(),new Error(`unable to find data type for ${e.toString()}`)}valueOf(){return this.value}get Array(){const e=_.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()}matches(...e){return e.some(t=>this.equals(t))}toString(){return this.valueOf()}get isVariable(){return this.equals(_.JSON)||this.equals(_.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(_.UUID)}get isInteger(){const e=this.toString();return e.startsWith("int")||e.startsWith("uint")}get isFloat(){return this.toString().startsWith("float")}get density(){const e=_.DENSITIES.get(this.toString());if(e==null)throw new Error(`unable to find density for ${this.valueOf()}`);return e}get isUnsigned(){return this.equals(_.UINT8)||this.equals(_.UINT16)||this.equals(_.UINT32)||this.equals(_.UINT64)}get isSigned(){return this.equals(_.INT8)||this.equals(_.INT16)||this.equals(_.INT32)||this.equals(_.INT64)}canSafelyCastTo(e){return this.equals(e)?!0:!this.isNumeric||!e.isNumeric||this.isVariable||e.isVariable||this.isUnsigned&&e.isSigned?!1:this.isFloat?e.isFloat&&this.density.valueOf()<=e.density.valueOf():this.equals(_.INT32)&&e.equals(_.FLOAT64)||this.equals(_.INT8)&&e.equals(_.FLOAT32)?!0:this.isInteger&&e.isInteger?this.density.valueOf()<=e.density.valueOf()&&this.isUnsigned===e.isUnsigned:!1}canCastTo(e){return this.isNumeric&&e.isNumeric?!0:this.equals(e)}toJSON(){return this.toString()}get usesBigInt(){return _.BIG_INT_TYPES.some(e=>e.equals(this))}};p(g,"UNKNOWN",new g("unknown")),p(g,"FLOAT64",new g("float64")),p(g,"FLOAT32",new g("float32")),p(g,"INT64",new g("int64")),p(g,"INT32",new g("int32")),p(g,"INT16",new g("int16")),p(g,"INT8",new g("int8")),p(g,"UINT64",new g("uint64")),p(g,"UINT32",new g("uint32")),p(g,"UINT16",new g("uint16")),p(g,"UINT8",new g("uint8")),p(g,"BOOLEAN",g.UINT8),p(g,"TIMESTAMP",new g("timestamp")),p(g,"UUID",new g("uuid")),p(g,"STRING",new g("string")),p(g,"JSON",new g("json")),p(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]])),p(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]])),p(g,"DENSITIES",new Map([[g.UINT8.toString(),ie.BIT8],[g.UINT16.toString(),ie.BIT16],[g.UINT32.toString(),ie.BIT32],[g.UINT64.toString(),ie.BIT64],[g.FLOAT32.toString(),ie.BIT32],[g.FLOAT64.toString(),ie.BIT64],[g.INT8.toString(),ie.BIT8],[g.INT16.toString(),ie.BIT16],[g.INT32.toString(),ie.BIT32],[g.INT64.toString(),ie.BIT64],[g.TIMESTAMP.toString(),ie.BIT64],[g.STRING.toString(),ie.UNKNOWN],[g.JSON.toString(),ie.UNKNOWN],[g.UUID.toString(),ie.BIT128]])),p(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]),p(g,"BIG_INT_TYPES",[g.INT64,g.UINT64,g.TIMESTAMP]),p(g,"z",i.z.union([i.z.string().transform(s=>new g(s)),i.z.instanceof(g)]));let D=g;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),t=this.truncate(Z.GIGABYTE),n=this.truncate(Z.MEGABYTE),r=this.truncate(Z.KILOBYTE),a=this.truncate(Z.BYTE),o=e,c=t.sub(e),h=n.sub(t),d=r.sub(n),f=a.sub(r);let u="";return o.isZero||(u+=`${o.terabytes}TB `),c.isZero||(u+=`${c.gigabytes}GB `),h.isZero||(u+=`${h.megabytes}MB `),d.isZero||(u+=`${d.kilobytes}KB `),(!f.isZero||u==="")&&(u+=`${f.valueOf()}B`),u.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",i.z.union([i.z.number().transform(s=>new ne(s)),i.z.instanceof(ne)]));let lr=ne;i.z.union([i.z.instanceof(Uint8Array),i.z.instanceof(Uint16Array),i.z.instanceof(Uint32Array),i.z.instanceof(BigUint64Array),i.z.instanceof(Float32Array),i.z.instanceof(Float64Array),i.z.instanceof(Int8Array),i.z.instanceof(Int16Array),i.z.instanceof(Int32Array),i.z.instanceof(BigInt64Array)]);const go=s=>{const e=typeof s;return e==="string"||e==="number"||e==="boolean"||e==="bigint"||s instanceof $||s instanceof C||s instanceof Date},Cu=(s,e,t,n=0)=>s.usesBigInt&&!e.usesBigInt?Number(t)-Number(n):!s.usesBigInt&&e.usesBigInt?BigInt(t.valueOf())-BigInt(n.valueOf()):qt(t,-n).valueOf(),qt=(s,e)=>e==0?s:s==0?e:typeof s=="bigint"&&typeof e=="bigint"||typeof s=="number"&&typeof e=="number"?s+e:Number(s)+Number(e),Bu=s=>s==null?!1:Array.isArray(s)||s instanceof ArrayBuffer||ArrayBuffer.isView(s)&&!(s instanceof DataView)||s instanceof Pu?!0:go(s),$e=-1,ju=i.z.string().transform(s=>new Uint8Array(atob(s).split("").map(e=>e.charCodeAt(0))).buffer),Ru=i.z.union([i.z.null(),i.z.undefined()]).transform(()=>new Uint8Array().buffer),hr=10,Mu=(s,e)=>{if(s==="string"&&!e.isVariable)throw new Error(`cannot convert series of type ${e.toString()} to string`);if(s==="number"&&!e.isNumeric)throw new Error(`cannot convert series of type ${e.toString()} to number`);if(s==="bigint"&&!e.usesBigInt)throw new Error(`cannot convert series of type ${e.toString()} to bigint`)},Wt=class ve{constructor(e){p(this,"key",""),p(this,"isSynnaxSeries",!0),p(this,"dataType"),p(this,"sampleOffset"),p(this,"gl"),p(this,"_data"),p(this,"timeRange",ns.ZERO),p(this,"alignment",0n),p(this,"_cachedMin"),p(this,"_cachedMax"),p(this,"writePos",$e),p(this,"_refCount",0),p(this,"_cachedLength"),p(this,"_cachedIndexes"),Bu(e)&&(e={data:e});const{dataType:t,timeRange:n,sampleOffset:r=0,glBufferUsage:a="static",alignment:o=0n,key:c=Au()}=e,h=e.data??[];if(h instanceof ve||typeof h=="object"&&"isSynnaxSeries"in h&&h.isSynnaxSeries===!0){const u=h;this.key=u.key,this.dataType=u.dataType,this.sampleOffset=u.sampleOffset,this.gl=u.gl,this._data=u._data,this.timeRange=u.timeRange,this.alignment=u.alignment,this._cachedMin=u._cachedMin,this._cachedMax=u._cachedMax,this.writePos=u.writePos,this._refCount=u._refCount,this._cachedLength=u._cachedLength;return}const d=go(h),f=Array.isArray(h);if(t!=null)this.dataType=new D(t);else{if(h instanceof ArrayBuffer)throw new Error("cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type.");if(f||d){let u=h;if(!d){if(h.length===0)throw new Error("cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type.");u=h[0]}if(typeof u=="string")this.dataType=D.STRING;else if(typeof u=="number")this.dataType=D.FLOAT64;else if(typeof u=="bigint")this.dataType=D.INT64;else if(typeof u=="boolean")this.dataType=D.BOOLEAN;else if(u instanceof $||u instanceof Date||u instanceof $)this.dataType=D.TIMESTAMP;else if(typeof u=="object")this.dataType=D.JSON;else throw new Error(`cannot infer data type of ${typeof u} when constructing a Series from a JS array`)}else this.dataType=new D(h)}if(!f&&!d)this._data=h;else{let u=d?[h]:h;const T=u[0];(T instanceof $||T instanceof Date||T instanceof C)&&(u=u.map(k=>new $(k).valueOf())),this.dataType.equals(D.STRING)?(this._cachedLength=u.length,this._data=new TextEncoder().encode(`${u.join(`
4
+ `)}
5
+ `).buffer):this.dataType.equals(D.JSON)?(this._cachedLength=u.length,this._data=new TextEncoder().encode(`${u.map(k=>Ls.encodeString(k)).join(`
6
+ `)}
7
+ `).buffer):this.dataType.usesBigInt&&typeof T=="number"?this._data=new this.dataType.Array(u.map(k=>BigInt(Math.round(k)))).buffer:!this.dataType.usesBigInt&&typeof T=="bigint"?this._data=new this.dataType.Array(u.map(k=>Number(k))).buffer:this._data=new this.dataType.Array(u).buffer}this.key=c,this.alignment=o,this.sampleOffset=r??0,this.timeRange=n??ns.ZERO,this.gl={control:null,buffer:null,prevBuffer:0,bufferUsage:a}}static alloc({capacity:e,dataType:t,...n}){if(e===0)throw new Error("[Series] - cannot allocate an array of length 0");const r=new new D(t).Array(e),a=new ve({data:r.buffer,dataType:t,...n});return a.writePos=0,a}static createTimestamps(e,t,n){const r=n.spanRange(t.span(e)),a=new BigInt64Array(e);for(let o=0;o<e;o++)a[o]=BigInt(n.add(t.span(o)).valueOf());return new ve({data:a,dataType:D.TIMESTAMP,timeRange:r})}get refCount(){return this._refCount}static fromStrings(e,t){const n=new TextEncoder().encode(`${e.join(`
8
+ `)}
9
+ `);return new ve({data:n,dataType:D.STRING,timeRange:t})}static fromJSON(e,t){const n=new TextEncoder().encode(`${e.map(r=>Ls.encodeString(r)).join(`
10
+ `)}
11
+ `);return new ve({data:n,dataType:D.JSON,timeRange:t})}acquire(e){this._refCount++,e!=null&&this.updateGLBuffer(e)}release(){if(this._refCount<=0){console.warn("attempted to release a series with a negative reference count");return}this._refCount--,this._refCount===0&&this.gl.control!=null&&this.maybeGarbageCollectGLBuffer(this.gl.control)}write(e){if(!e.dataType.equals(this.dataType))throw new Error("buffer must be of the same type as this array");return this.dataType.isVariable?this.writeVariable(e):this.writeFixed(e)}writeVariable(e){if(this.writePos===$e)return 0;const t=this.byteCapacity.valueOf()-this.writePos,n=e.subBytes(0,t);return this.writeToUnderlyingData(n),this.writePos+=n.byteLength.valueOf(),this._cachedLength!=null&&(this._cachedLength+=n.length,this.calculateCachedLength()),n.length}writeFixed(e){if(this.writePos===$e)return 0;const t=this.capacity-this.writePos,n=e.sub(0,t);return this.writeToUnderlyingData(n),this._cachedLength=void 0,this.maybeRecomputeMinMax(n),this.writePos+=n.length,n.length}writeToUnderlyingData(e){this.underlyingData.set(e.data,this.writePos)}get buffer(){return typeof this._data=="object"&&"buffer"in this._data?this._data.buffer:this._data}get underlyingData(){return new this.dataType.Array(this._data)}get data(){return this.writePos===$e?this.underlyingData:new this.dataType.Array(this._data,0,this.writePos)}toStrings(){if(!this.dataType.matches(D.STRING,D.UUID))throw new Error("cannot convert non-string series to strings");return new TextDecoder().decode(this.underlyingData).split(`
12
+ `).slice(0,-1)}toUUIDs(){if(!this.dataType.equals(D.UUID))throw new Error("cannot convert non-uuid series to uuids");const e=D.UUID.density.valueOf(),t=Array(this.length);for(let n=0;n<this.length;n++){const r=this.underlyingData.slice(n*e,(n+1)*e),a=Array.from(new Uint8Array(r.buffer),o=>o.toString(16).padStart(2,"0")).join("").replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/,"$1-$2-$3-$4-$5");t[n]=a}return t}parseJSON(e){if(!this.dataType.equals(D.JSON))throw new Error("cannot parse non-JSON series as JSON");return new TextDecoder().decode(this.underlyingData).split(`
13
+ `).slice(0,-1).map(t=>e.parse(Ls.decodeString(t)))}get byteCapacity(){return new lr(this.underlyingData.byteLength)}get capacity(){return this.dataType.isVariable?this.byteCapacity.valueOf():this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===$e?this.byteCapacity:this.dataType.isVariable?new lr(this.writePos):this.dataType.density.size(this.writePos)}get length(){return this._cachedLength!=null?this._cachedLength:this.dataType.isVariable?this.calculateCachedLength():this.writePos===$e?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;const t=[0];return this.data.forEach((n,r)=>{n===hr&&(e++,t.push(r+1))}),this._cachedIndexes=t,this._cachedLength=e,e}convert(e,t=0){if(this.dataType.equals(e))return this;const n=new e.Array(this.length);for(let r=0;r<this.length;r++)n[r]=Cu(this.dataType,e,this.data[r],t);return new ve({data:n.buffer,dataType:e,timeRange:this.timeRange,sampleOffset:t,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment})}calcRawMax(){if(this.length===0)return-1/0;if(this.dataType.equals(D.TIMESTAMP))this._cachedMax=this.data[this.data.length-1];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMax=e.reduce((t,n)=>t>n?t:n)}else{const e=this.data;this._cachedMax=e.reduce((t,n)=>t>n?t: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??(this._cachedMax=this.calcRawMax()),qt(this._cachedMax,this.sampleOffset))}calcRawMin(){if(this.length===0)return 1/0;if(this.dataType.equals(D.TIMESTAMP))this._cachedMin=this.data[0];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMin=e.reduce((t,n)=>t<n?t:n)}else{const e=this.data;this._cachedMin=e.reduce((t,n)=>t<n?t: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??(this._cachedMin=this.calcRawMin()),qt(this._cachedMin,this.sampleOffset))}get bounds(){return Qe(Number(this.min),Number(this.max))}maybeRecomputeMinMax(e){if(this._cachedMin!=null){const t=e._cachedMin??e.calcRawMin();t<this._cachedMin&&(this._cachedMin=t)}if(this._cachedMax!=null){const t=e._cachedMax??e.calcRawMax();t>this._cachedMax&&(this._cachedMax=t)}}enrich(){this.max,this.min}get range(){return qt(this.max,-this.min)}atAlignment(e,t){const n=Number(e-this.alignment);if(n<0||n>=this.length){if(t===!0)throw new Error(`[series] - no value at index ${n}`);return}return this.at(n,t)}at(e,t){if(this.dataType.isVariable)return this.atVariable(e,t??!1);e<0&&(e=this.length+e);const n=this.data[e];if(n==null){if(t===!0)throw new Error(`[series] - no value at index ${e}`);return}return qt(n,this.sampleOffset)}atVariable(e,t){let n=0,r=0;if(this._cachedIndexes!=null)n=this._cachedIndexes[e],r=this._cachedIndexes[e+1]-1;else{e<0&&(e=this.length+e);for(let o=0;o<this.data.length;o++)if(this.data[o]===hr){if(e===0){r=o;break}n=o+1,e--}if(r===0&&(r=this.data.length),n>=r||e>0){if(t)throw new Error(`[series] - no value at index ${e}`);return}}const a=this.data.slice(n,r);return this.dataType.equals(D.STRING)?new TextDecoder().decode(a):Yr(JSON.parse(new TextDecoder().decode(a)))}binarySearch(e){let t=0,n=this.length-1;const r=Hh(e);for(;t<=n;){const a=Math.floor((t+n)/2),o=r(this.at(a,!0),e);if(o===0)return a;o<0?t=a+1:n=a-1}return t}updateGLBuffer(e){if(this.gl.control=e,!this.dataType.equals(D.FLOAT32)&&!this.dataType.equals(D.UINT8))throw new Error("Only FLOAT32 and UINT8 arrays can be used in WebGL");const{buffer:t,bufferUsage:n,prevBuffer:r}=this.gl;if(t==null&&(this.gl.buffer=e.createBuffer()),this.writePos!==r)if(e.bindBuffer(e.ARRAY_BUFFER,this.gl.buffer),this.writePos!==$e){r===0&&e.bufferData(e.ARRAY_BUFFER,this.byteCapacity.valueOf(),e.STATIC_DRAW);const a=this.dataType.density.size(r).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=$e}as(e){return Mu(e,this.dataType),this}get digest(){var e;return{key:this.key,dataType:this.dataType.toString(),sampleOffset:this.sampleOffset,alignment:{lower:Gi(this.alignmentBounds.lower),upper:Gi(this.alignmentBounds.upper)},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 Qe(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 Du(this);return this.dataType.equals(D.JSON)?new $u(e):e}return new Lu(this)}slice(e,t){return this.sliceSub(!1,e,t)}sub(e,t){return this.sliceSub(!0,e,t)}subIterator(e,t){return new Vi(this,e,t??this.length)}subAlignmentIterator(e,t){return new Vi(this,Number(e-this.alignment),Number(t-this.alignment))}subBytes(e,t){if(e>=0&&(t==null||t>=this.byteLength.valueOf()))return this;const n=this.data.subarray(e,t);return new ve({data:n,dataType:this.dataType,timeRange:this.timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(e)})}sliceSub(e,t,n){if(t<=0&&(n==null||n>=this.length))return this;let r;return e?r=this.data.subarray(t,n):r=this.data.slice(t,n),new ve({data:r,dataType:this.dataType,timeRange:this.timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(t)})}reAlign(e){return new ve({data:this.buffer,dataType:this.dataType,timeRange:ns.ZERO,sampleOffset:this.sampleOffset,glBufferUsage:"static",alignment:e})}toString(){var e,t;let n=`${this.dataType.toString()} ${this.length} [`;if(this.length<=10)n+=Array.from(this).map(r=>r.toString());else{for(let r=0;r<5;r++)n+=`${(e=this.at(r))==null?void 0:e.toString()}`,r<4&&(n+=",");n+="...";for(let r=-5;r<0;r++)n+=(t=this.at(r))==null?void 0:t.toString(),r<-1&&(n+=",")}return n+="]",n}};p(Wt,"crudeZ",i.z.object({timeRange:ns.z.optional(),dataType:D.z,alignment:i.z.coerce.bigint().optional(),data:i.z.union([ju,Ru,i.z.instanceof(ArrayBuffer),i.z.instanceof(Uint8Array)]),glBufferUsage:Uu.optional().default("static").optional()})),p(Wt,"z",Wt.crudeZ.transform(s=>new Wt(s)));let Pu=Wt,Vi=class{constructor(s,e,t){p(this,"series"),p(this,"end"),p(this,"index"),this.series=s;const n=Qe(0,s.length);this.end=$i(n,t),this.index=$i(n,e)}next(){return this.index>=this.end?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}[Symbol.iterator](){return this}};class Du{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,t=this.series.data;for(;this.index<t.length&&t[this.index]!==hr;)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 Yi,Zi;const mo=class wo{constructor(e){p(this,"wrapped"),p(this,Yi,"JSONSeriesIterator"),this.wrapped=e}next(){const e=this.wrapped.next();return e.done===!0?{done:!0,value:void 0}:{done:!1,value:Ls.decodeString(e.value,wo.SCHEMA)}}[(Zi=Symbol.iterator,Yi=Symbol.toStringTag,Zi)](){return this}};p(mo,"SCHEMA",i.z.record(i.z.string(),i.z.unknown()));let $u=mo;var Ki,Hi;class Lu{constructor(e){p(this,"series"),p(this,"index"),p(this,Ki,"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)}}[(Hi=Symbol.iterator,Ki=Symbol.toStringTag,Hi)](){return this}}const Gi=s=>{const e=s>>32n,t=s&0xffffffffn;return{domain:e,sample:t}};i.z.object({key:i.z.string(),value:i.z.string()});i.z.record(i.z.union([i.z.number(),i.z.string(),i.z.symbol()]),i.z.unknown());const bo=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser",Fu=bo(),vo=["macOS","Windows","Linux"],_u=["macos","windows","linux"],qu={macos:"macOS",windows:"Windows",linux:"Linux"},Wu=i.z.enum(vo).or(i.z.enum(_u).transform(s=>qu[s])),Vu=()=>{if(typeof window>"u")return;const s=window.navigator.userAgent.toLowerCase();if(s.includes("mac"))return"macOS";if(s.includes("win"))return"Windows";if(s.includes("linux"))return"Linux"};let Nn;const Yu=(s={})=>{const{force:e,default:t}=s;return e??Nn??(Nn=Vu(),Nn??t)},zo=Object.freeze(Object.defineProperty({__proto__:null,OPERATING_SYSTEMS:vo,RUNTIME:Fu,detect:bo,getOS:Yu,osZ:Wu},Symbol.toStringTag,{value:"Module"}));var Zu=Object.defineProperty,Ku=(s,e,t)=>e in s?Zu(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Vt=(s,e,t)=>Ku(s,typeof e!="symbol"?e+"":e,t);const Hu=(...s)=>s.map(So).join(""),So=s=>(s.endsWith("/")||(s+="/"),s.startsWith("/")&&(s=s.slice(1)),s),Gu=s=>s.endsWith("/")?s.slice(0,-1):s,Ju=(s,e="")=>s===null?"":`?${Object.entries(s).filter(([,t])=>t==null?!1:Array.isArray(t)?t.length>0:!0).map(([t,n])=>`${e}${t}=${n}`).join("&")}`,ur=class dr{constructor({host:e,port:t,protocol:n="",pathPrefix:r=""}){Vt(this,"protocol"),Vt(this,"host"),Vt(this,"port"),Vt(this,"path"),this.protocol=n,this.host=e,this.port=t,this.path=So(r)}replace(e){return new dr({host:e.host??this.host,port:e.port??this.port,protocol:e.protocol??this.protocol,pathPrefix:e.pathPrefix??this.path})}child(e){return new dr({...this,pathPrefix:Hu(this.path,e)})}toString(){return Gu(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}};Vt(ur,"UNKNOWN",new ur({host:"unknown",port:0}));let Xu=ur;const Qu=-128,ed=127;i.z.number().int().min(Qu).max(ed);const td=-32768,sd=32767;i.z.number().int().min(td).max(sd);const nd=-2147483648,rd=2147483647;i.z.number().int().min(nd).max(rd);const id=-9223372036854775808n,ad=9223372036854775807n;i.z.bigint().min(id).max(ad);const od=255;i.z.number().int().min(0).max(od);const cd=65535;i.z.number().int().min(0).max(cd);const ld=4294967295;i.z.number().int().min(0).max(ld);const hd=18446744073709551615n;i.z.bigint().min(0n).max(hd);var ud=Object.defineProperty,dd=(s,e,t)=>e in s?ud(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,ke=(s,e,t)=>dd(s,typeof e!="symbol"?e+"":e,t);const fd=async s=>await new Promise(e=>setTimeout(e,C.fromMilliseconds(s).milliseconds));class yd{constructor(e){ke(this,"config"),ke(this,"retries"),ke(this,"interval"),this.config={baseInterval:new C((e==null?void 0:e.baseInterval)??C.seconds(1)),maxRetries:(e==null?void 0:e.maxRetries)??5,scale:(e==null?void 0:e.scale)??1,sleepFn:(e==null?void 0:e.sleepFn)??fd},this.retries=0,this.interval=new C(this.config.baseInterval)}async wait(){const{maxRetries:e,scale:t,sleepFn:n}=this.config;return this.retries>=e?!1:(await n(this.interval),this.interval=this.interval.mult(t),this.retries++,!0)}reset(){this.retries=0,this.interval=this.config.baseInterval}}const pd=i.z.object({baseInterval:C.z.optional(),maxRetries:i.z.number().optional(),scale:i.z.number().optional()}),gd=Object.freeze(Object.defineProperty({__proto__:null,Breaker:yd,breakerConfig:pd},Symbol.toStringTag,{value:"Module"})),md=/^#?([0-9a-f]{6}|[0-9a-f]{8})$/i,Gr=i.z.string().regex(md),yt=i.z.number().min(0).max(255),wd=i.z.number().min(0).max(1),To=i.z.tuple([yt,yt,yt,wd]),Oo=i.z.tuple([yt,yt,yt]),Jr=(s,e=1)=>{if(typeof s=="string")return vd(s,e);if(Array.isArray(s)){if(s.length<3||s.length>4)throw new Error(`Invalid color: [${s.join(", ")}]`);return s.length===3?[...s,e]:s}throw new Error(`Invalid color: ${JSON.stringify(s)}`)},bd=i.z.union([Gr,To,Oo]).transform(s=>Jr(s)),vd=(s,e=1)=>{if(!Gr.safeParse(s).success)throw new Error(`Invalid hex color: ${s}`);return s=zd(s),[Us(s,0),Us(s,2),Us(s,4),s.length===8?Us(s,6)/255:e]},Us=(s,e)=>parseInt(s.slice(e,e+2),16),zd=s=>s.startsWith("#")?s.slice(1):s,Sd=i.z.union([Gr,To,i.z.string(),Oo]);Jr("#000000");Jr("#ffffff");const Td=i.z.object({key:i.z.string(),color:Sd,position:i.z.number(),switched:i.z.boolean().optional()});i.z.array(Td);const Od=i.z.object({key:i.z.string(),name:i.z.string(),color:bd});i.z.object({key:i.z.string(),name:i.z.string(),swatches:i.z.array(Od)});const kd=i.z.number().int().min(0).max(255),xd=i.z.object({name:i.z.string(),key:i.z.string()}),Gs=s=>i.z.object({subject:xd,resource:s,authority:kd}),Id=i.z.object({from:Gs(i.z.any()),to:i.z.null()}),Ed=i.z.object({from:i.z.null(),to:Gs(i.z.any())});i.z.union([Id,Ed,i.z.object({from:Gs(i.z.any()),to:Gs(i.z.any())})]);const Nd=s=>Object.getOwnPropertySymbols(globalThis).includes(s),Ad=(s,e)=>{const t=Symbol.for(s);if(!Nd(t)){const n=e();Object.defineProperty(globalThis,t,{value:n})}return()=>globalThis[t]},Ud=s=>e=>e!=null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"?e.type.startsWith(s):e instanceof Error?e.message.startsWith(s):typeof e!="string"?!1:e.startsWith(s),nn=s=>{var e;return e=class extends Error{constructor(t,n){super(t,n),ke(this,"discriminator",e.discriminator),ke(this,"type",e.TYPE),ke(this,"matches",e.matches),this.name=e.TYPE}static sub(t){return nn(`${s}.${t}`)}},ke(e,"discriminator","FreighterError"),ke(e,"TYPE",s),ke(e,"matches",Ud(s)),e},ko=s=>{if(s==null||typeof s!="object")return!1;const e=s;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},lt="unknown",fr="nil";class Cd{constructor(){ke(this,"providers",[])}register(e){this.providers.push(e)}encode(e){if(e==null)return{type:fr,data:""};if(ko(e))for(const t of this.providers){const n=t.encode(e);if(n!=null)return n}if(e instanceof Error)return{type:lt,data:e.message};if(typeof e=="string")return{type:lt,data:e};try{return{type:lt,data:JSON.stringify(e)}}catch{return{type:lt,data:"unable to encode error information"}}}decode(e){if(e==null||e.type===fr)return null;if(e.type===lt)return new yr(e.data);for(const t of this.providers){const n=t.decode(e);if(n!=null)return n}return new yr(e.data)}}const Xr=Ad("synnax-error-registry",()=>new Cd),Bd=({encode:s,decode:e})=>Xr().register({encode:s,decode:e}),jd=s=>Xr().encode(s),Rd=s=>s==null?null:Xr().decode(s);class yr extends nn("unknown"){}const Md=i.z.object({type:i.z.string(),data:i.z.string()});class Pd extends nn("canceled"){}const He=Object.freeze(Object.defineProperty({__proto__:null,Canceled:Pd,NONE:fr,UNKNOWN:lt,Unknown:yr,createTyped:nn,decode:Rd,encode:jd,isTyped:ko,payloadZ:Md,register:Bd},Symbol.toStringTag,{value:"Module"}));i.object({jsonrpc:i.string(),id:i.number().optional(),method:i.string().optional(),params:i.unknown().optional(),result:i.unknown().optional()});i.z.string().regex(/^\d+\.\d+\.\d+$/);const Dd=["standard","scientific","engineering"];i.z.enum(Dd);let ms=class extends He.createTyped("freighter"){},ge=class extends ms.sub("eof"){constructor(){super("EOF")}},mt=class extends ms.sub("stream_closed"){constructor(){super("StreamClosed")}},Ge=class extends ms.sub("unreachable"){constructor(s={}){const{message:e="Unreachable",url:t=Xu.UNKNOWN}=s;super(e),G(this,"url"),this.url=t}};const $d=s=>{if(!s.type.startsWith(ms.TYPE))return null;if(ge.matches(s))return{type:ge.TYPE,data:"EOF"};if(mt.matches(s))return{type:mt.TYPE,data:"StreamClosed"};if(Ge.matches(s))return{type:Ge.TYPE,data:"Unreachable"};throw new Error(`Unknown error type: ${s.type}: ${s.message}`)},Ld=s=>{if(!s.type.startsWith(ms.TYPE))return null;switch(s.type){case ge.TYPE:return new ge;case mt.TYPE:return new mt;case Ge.TYPE:return new Ge;default:throw new He.Unknown(`Unknown error type: ${s.data}`)}};He.register({encode:$d,decode:Ld});class xo{constructor(){G(this,"middleware",[])}use(...e){this.middleware.push(...e)}async executeMiddleware(e,t){let n=0;const r=async a=>{if(n===this.middleware.length)return await t(a);const o=this.middleware[n];return n++,await o(a,r)};return await r(e)}}const Io="Content-Type",Ji=s=>{if(zo.RUNTIME!=="node")return fetch;const e=require("node-fetch");if(s==="http")return e;const t=require("https"),n=new t.Agent({rejectUnauthorized:!1});return async(r,a)=>await e(r,{...a,agent:n})},Fd=s=>"code"in s&&s.code==="ECONNREFUSED"||s.message.toLowerCase().includes("load failed"),_d=400;class qd extends xo{constructor(e,t,n=!1){return super(),G(this,"endpoint"),G(this,"encoder"),G(this,"fetch"),this.endpoint=e.replace({protocol:n?"https":"http"}),this.encoder=t,this.fetch=Ji(this.endpoint.protocol),new Proxy(this,{get:(r,a,o)=>a==="endpoint"?this.endpoint:Reflect.get(r,a,o)})}get headers(){return{[Io]:this.encoder.contentType}}async send(e,t,n,r){t=n==null?void 0:n.parse(t);let a=null;const o=this.endpoint.child(e),c={};c.method="POST",c.body=this.encoder.encode(t??{});const[,h]=await this.executeMiddleware({target:o.toString(),protocol:this.endpoint.protocol,params:{},role:"client"},async d=>{const f={...d,params:{}};c.headers={...this.headers,...d.params};let u;try{u=await Ji(d.protocol)(d.target,c)}catch(k){let Y=k;return Fd(Y)&&(Y=new Ge({url:o})),[f,Y]}const T=new Uint8Array(await(await u.blob()).arrayBuffer());if(u!=null&&u.ok)return r!=null&&(a=this.encoder.decode(T,r)),[f,null];try{if(u.status!==_d)return[f,new Error(u.statusText)];const k=this.encoder.decode(T,He.payloadZ),Y=He.decode(k);return[f,Y]}catch(k){return[f,new Error(`[freighter] - failed to decode error: ${u.statusText}: ${k.message}`)]}});return h!=null?[null,h]:[a,null]}}const Wd=(s,e)=>{class t{constructor(r){G(this,"wrapped"),this.wrapped=r}use(...r){this.wrapped.use(...r)}async send(r,a,o,c){const h=new gd.Breaker(e);do{const[d,f]=await this.wrapped.send(r,a,o,c);if(f==null)return[d,null];if(!Ge.matches(f))return[null,f];if(!await h.wait())return[d,f]}while(!0)}}return new t(s)},w=async(s,e,t,n,r)=>{const[a,o]=await s.send(e,t,n,r);if(o!=null)throw o;return a},Vd=()=>zo.RUNTIME!=="node"?s=>new WebSocket(s):s=>new(require("ws")).WebSocket(s,{rejectUnauthorized:!1}),Yd=i.z.object({type:i.z.enum(["data","close","open"]),payload:i.z.unknown(),error:i.z.optional(He.payloadZ)});class Zd{constructor(e,t,n,r){G(this,"codec"),G(this,"reqSchema"),G(this,"resSchema"),G(this,"ws"),G(this,"serverClosed"),G(this,"sendClosed"),G(this,"receiveDataQueue",[]),G(this,"receiveCallbacksQueue",[]),this.codec=t,this.reqSchema=n,this.resSchema=r,this.ws=e,this.sendClosed=!1,this.serverClosed=null,this.listenForMessages()}async receiveOpenAck(){const e=await this.receiveMsg();if(e.type!=="open"){if(e.error==null)throw new Error("Message error must be defined");return He.decode(e.error)}return null}send(e){if(this.serverClosed!=null)return new ge;if(this.sendClosed)throw new mt;return this.ws.send(this.codec.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=He.decode(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.codec.encode(e))}finally{this.sendClosed=!0}}async receiveMsg(){return this.receiveDataQueue.shift()??await new Promise((e,t)=>this.receiveCallbacksQueue.push({resolve:e,reject:t}))}addMessage(e){const t=this.receiveCallbacksQueue.shift();t!=null?t.resolve(e):this.receiveDataQueue.push(e)}listenForMessages(){this.ws.onmessage=this.onMessage.bind(this),this.ws.onclose=this.onClose.bind(this)}onMessage(e){this.addMessage(this.codec.decode(e.data,Yd))}onClose(e){this.addMessage({type:"close",error:{type:e.code===Hd?ge.TYPE:mt.TYPE,data:""}})}}const Kd="freighterctx",Hd=1e3,Eo=class pr extends xo{constructor(e,t,n=!1){super(),G(this,"baseUrl"),G(this,"encoder"),G(this,"secure"),this.secure=n,this.baseUrl=e.replace({protocol:n?"wss":"ws"}),this.encoder=t}withCodec(e){const t=new pr(this.baseUrl,e,this.secure);return t.use(...this.middleware),t}async stream(e,t,n){const r=Vd();let a;const[,o]=await this.executeMiddleware({target:e,protocol:"websocket",params:{},role:"client"},async c=>{const h=r(this.buildURL(e,c)),d={...c,params:{}};h.binaryType=pr.MESSAGE_TYPE;const f=await this.wrapSocket(h,t,n);return f instanceof Error?[d,f]:(a=f,[d,null])});if(o!=null)throw o;return a}buildURL(e,t){const n=Ju({[Io]:this.encoder.contentType,...t.params},Kd);return this.baseUrl.child(e).toString()+n}async wrapSocket(e,t,n){return await new Promise(r=>{e.onopen=()=>{const a=new Zd(e,this.encoder,t,n);a.receiveOpenAck().then(o=>{o!=null?r(o):r(a)}).catch(o=>r(o))},e.onerror=a=>{const o=a;r(new Error(o.message))}})}};G(Eo,"MESSAGE_TYPE","arraybuffer");let Gd=Eo;const Jd="all",Xd="create",Qd="delete",ef="retrieve",tf="update",gr=i.z.enum([Jd,Xd,Qd,ef,tf]),sf=s=>{const e=s.replace(/_[a-z]/g,t=>t[1].toUpperCase());return e.length>1&&e[0]===e[0].toUpperCase()&&e[1]===e[1].toUpperCase()||e.length===0?e:e[0].toLowerCase()+e.slice(1)},No=s=>{const e=(t,n=mr)=>{if(typeof t=="string")return s(t);if(Array.isArray(t))return t.map(o=>e(o,n));if(!An(t))return t;n=rf(n);const r={},a=t;return Object.keys(a).forEach(o=>{let c=a[o];const h=s(o);n.recursive&&(An(c)?Qi(c,n.keepTypesOnRecursion)||(c=e(c,n)):n.recursiveInArray&&Xi(c)&&(c=[...c].map(d=>{let f=d;return An(d)?Qi(f,n.keepTypesOnRecursion)||(f=e(d,n)):Xi(d)&&(f=e({key:d},n).key),f}))),r[h]=c}),r};return e},Qr=No(sf),nf=s=>s.replace(/([a-z0-9])([A-Z])/g,(e,t,n)=>`${t}_${n.toLowerCase()}`),Ao=No(nf),mr={recursive:!0,recursiveInArray:!0,keepTypesOnRecursion:[Number,String,Uint8Array]},rf=(s=mr)=>(s.recursive==null?s=mr:s.recursiveInArray??(s.recursiveInArray=!1),s),Xi=s=>s!=null&&Array.isArray(s),An=s=>s!=null&&typeof s=="object"&&!Array.isArray(s),Qi=(s,e)=>(e||[]).some(t=>s instanceof t),rn=s=>s!=null&&typeof s=="object"&&!Array.isArray(s);var af=Object.defineProperty,of=(s,e,t)=>e in s?af(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,pt=(s,e,t)=>of(s,typeof e!="symbol"?e+"":e,t);function cf(s){const e=s.length;let t=0,n=0;for(;n<e;){let r=s.charCodeAt(n++);if((r&4294967168)===0){t++;continue}else if((r&4294965248)===0)t+=2;else{if(r>=55296&&r<=56319&&n<e){const a=s.charCodeAt(n);(a&64512)===56320&&(++n,r=((r&1023)<<10)+(a&1023)+65536)}(r&4294901760)===0?t+=3:t+=4}}return t}function lf(s,e,t){const n=s.length;let r=t,a=0;for(;a<n;){let o=s.charCodeAt(a++);if((o&4294967168)===0){e[r++]=o;continue}else if((o&4294965248)===0)e[r++]=o>>6&31|192;else{if(o>=55296&&o<=56319&&a<n){const c=s.charCodeAt(a);(c&64512)===56320&&(++a,o=((o&1023)<<10)+(c&1023)+65536)}(o&4294901760)===0?(e[r++]=o>>12&15|224,e[r++]=o>>6&63|128):(e[r++]=o>>18&7|240,e[r++]=o>>12&63|128,e[r++]=o>>6&63|128)}e[r++]=o&63|128}}const hf=new TextEncoder,uf=50;function df(s,e,t){hf.encodeInto(s,e.subarray(t))}function ff(s,e,t){s.length>uf?df(s,e,t):lf(s,e,t)}const yf=4096;function Uo(s,e,t){let n=e;const r=n+t,a=[];let o="";for(;n<r;){const c=s[n++];if((c&128)===0)a.push(c);else if((c&224)===192){const h=s[n++]&63;a.push((c&31)<<6|h)}else if((c&240)===224){const h=s[n++]&63,d=s[n++]&63;a.push((c&31)<<12|h<<6|d)}else if((c&248)===240){const h=s[n++]&63,d=s[n++]&63,f=s[n++]&63;let u=(c&7)<<18|h<<12|d<<6|f;u>65535&&(u-=65536,a.push(u>>>10&1023|55296),u=56320|u&1023),a.push(u)}else a.push(c);a.length>=yf&&(o+=String.fromCharCode(...a),a.length=0)}return a.length>0&&(o+=String.fromCharCode(...a)),o}const pf=new TextDecoder,gf=200;function mf(s,e,t){const n=s.subarray(e,e+t);return pf.decode(n)}function wf(s,e,t){return t>gf?mf(s,e,t):Uo(s,e,t)}let Cs=class{constructor(s,e){this.type=s,this.data=e}},Oe=class wr extends Error{constructor(e){super(e);const t=Object.create(wr.prototype);Object.setPrototypeOf(this,t),Object.defineProperty(this,"name",{configurable:!0,enumerable:!1,value:wr.name})}};const Rt=4294967295;function bf(s,e,t){const n=t/4294967296,r=t;s.setUint32(e,n),s.setUint32(e+4,r)}function Co(s,e,t){const n=Math.floor(t/4294967296),r=t;s.setUint32(e,n),s.setUint32(e+4,r)}function Bo(s,e){const t=s.getInt32(e),n=s.getUint32(e+4);return t*4294967296+n}function vf(s,e){const t=s.getUint32(e),n=s.getUint32(e+4);return t*4294967296+n}const zf=-1,Sf=4294967296-1,Tf=17179869184-1;function Of({sec:s,nsec:e}){if(s>=0&&e>=0&&s<=Tf)if(e===0&&s<=Sf){const t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,s),t}else{const t=s/4294967296,n=s&4294967295,r=new Uint8Array(8),a=new DataView(r.buffer);return a.setUint32(0,e<<2|t&3),a.setUint32(4,n),r}else{const t=new Uint8Array(12),n=new DataView(t.buffer);return n.setUint32(0,e),Co(n,4,s),t}}function kf(s){const e=s.getTime(),t=Math.floor(e/1e3),n=(e-t*1e3)*1e6,r=Math.floor(n/1e9);return{sec:t+r,nsec:n-r*1e9}}function xf(s){if(s instanceof Date){const e=kf(s);return Of(e)}else return null}function If(s){const e=new DataView(s.buffer,s.byteOffset,s.byteLength);switch(s.byteLength){case 4:return{sec:e.getUint32(0),nsec:0};case 8:{const t=e.getUint32(0),n=e.getUint32(4),r=(t&3)*4294967296+n,a=t>>>2;return{sec:r,nsec:a}}case 12:{const t=Bo(e,4),n=e.getUint32(0);return{sec:t,nsec:n}}default:throw new Oe(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${s.length}`)}}function Ef(s){const e=If(s);return new Date(e.sec*1e3+e.nsec/1e6)}const Nf={type:zf,encode:xf,decode:Ef};let ls=class{constructor(){this.builtInEncoders=[],this.builtInDecoders=[],this.encoders=[],this.decoders=[],this.register(Nf)}register({type:s,encode:e,decode:t}){if(s>=0)this.encoders[s]=e,this.decoders[s]=t;else{const n=-1-s;this.builtInEncoders[n]=e,this.builtInDecoders[n]=t}}tryToEncode(s,e){for(let t=0;t<this.builtInEncoders.length;t++){const n=this.builtInEncoders[t];if(n!=null){const r=n(s,e);if(r!=null){const a=-1-t;return new Cs(a,r)}}}for(let t=0;t<this.encoders.length;t++){const n=this.encoders[t];if(n!=null){const r=n(s,e);if(r!=null){const a=t;return new Cs(a,r)}}}return s instanceof Cs?s:null}decode(s,e,t){const n=e<0?this.builtInDecoders[-1-e]:this.decoders[e];return n?n(s,e,t):new Cs(e,s)}};ls.defaultCodec=new ls;function Af(s){return s instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&s instanceof SharedArrayBuffer}function br(s){return s instanceof Uint8Array?s:ArrayBuffer.isView(s)?new Uint8Array(s.buffer,s.byteOffset,s.byteLength):Af(s)?new Uint8Array(s):Uint8Array.from(s)}const Uf=100,Cf=2048;let Bf=class jo{constructor(e){this.entered=!1,this.extensionCodec=(e==null?void 0:e.extensionCodec)??ls.defaultCodec,this.context=e==null?void 0:e.context,this.useBigInt64=(e==null?void 0:e.useBigInt64)??!1,this.maxDepth=(e==null?void 0:e.maxDepth)??Uf,this.initialBufferSize=(e==null?void 0:e.initialBufferSize)??Cf,this.sortKeys=(e==null?void 0:e.sortKeys)??!1,this.forceFloat32=(e==null?void 0:e.forceFloat32)??!1,this.ignoreUndefined=(e==null?void 0:e.ignoreUndefined)??!1,this.forceIntegerToFloat=(e==null?void 0:e.forceIntegerToFloat)??!1,this.pos=0,this.view=new DataView(new ArrayBuffer(this.initialBufferSize)),this.bytes=new Uint8Array(this.view.buffer)}clone(){return new jo({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,maxDepth:this.maxDepth,initialBufferSize:this.initialBufferSize,sortKeys:this.sortKeys,forceFloat32:this.forceFloat32,ignoreUndefined:this.ignoreUndefined,forceIntegerToFloat:this.forceIntegerToFloat})}reinitializeState(){this.pos=0}encodeSharedRef(e){if(this.entered)return this.clone().encodeSharedRef(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.subarray(0,this.pos)}finally{this.entered=!1}}encode(e){if(this.entered)return this.clone().encode(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.slice(0,this.pos)}finally{this.entered=!1}}doEncode(e,t){if(t>this.maxDepth)throw new Error(`Too deep objects in depth ${t}`);e==null?this.encodeNil():typeof e=="boolean"?this.encodeBoolean(e):typeof e=="number"?this.forceIntegerToFloat?this.encodeNumberAsFloat(e):this.encodeNumber(e):typeof e=="string"?this.encodeString(e):this.useBigInt64&&typeof e=="bigint"?this.encodeBigInt64(e):this.encodeObject(e,t)}ensureBufferSizeToWrite(e){const t=this.pos+e;this.view.byteLength<t&&this.resizeBuffer(t*2)}resizeBuffer(e){const t=new ArrayBuffer(e),n=new Uint8Array(t),r=new DataView(t);n.set(this.bytes),this.view=r,this.bytes=n}encodeNil(){this.writeU8(192)}encodeBoolean(e){e===!1?this.writeU8(194):this.writeU8(195)}encodeNumber(e){!this.forceIntegerToFloat&&Number.isSafeInteger(e)?e>=0?e<128?this.writeU8(e):e<256?(this.writeU8(204),this.writeU8(e)):e<65536?(this.writeU8(205),this.writeU16(e)):e<4294967296?(this.writeU8(206),this.writeU32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(207),this.writeU64(e)):e>=-32?this.writeU8(224|e+32):e>=-128?(this.writeU8(208),this.writeI8(e)):e>=-32768?(this.writeU8(209),this.writeI16(e)):e>=-2147483648?(this.writeU8(210),this.writeI32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(211),this.writeI64(e)):this.encodeNumberAsFloat(e)}encodeNumberAsFloat(e){this.forceFloat32?(this.writeU8(202),this.writeF32(e)):(this.writeU8(203),this.writeF64(e))}encodeBigInt64(e){e>=BigInt(0)?(this.writeU8(207),this.writeBigUint64(e)):(this.writeU8(211),this.writeBigInt64(e))}writeStringHeader(e){if(e<32)this.writeU8(160+e);else if(e<256)this.writeU8(217),this.writeU8(e);else if(e<65536)this.writeU8(218),this.writeU16(e);else if(e<4294967296)this.writeU8(219),this.writeU32(e);else throw new Error(`Too long string: ${e} bytes in UTF-8`)}encodeString(e){const t=cf(e);this.ensureBufferSizeToWrite(5+t),this.writeStringHeader(t),ff(e,this.bytes,this.pos),this.pos+=t}encodeObject(e,t){const n=this.extensionCodec.tryToEncode(e,this.context);if(n!=null)this.encodeExtension(n);else if(Array.isArray(e))this.encodeArray(e,t);else if(ArrayBuffer.isView(e))this.encodeBinary(e);else if(typeof e=="object")this.encodeMap(e,t);else throw new Error(`Unrecognized object: ${Object.prototype.toString.apply(e)}`)}encodeBinary(e){const t=e.byteLength;if(t<256)this.writeU8(196),this.writeU8(t);else if(t<65536)this.writeU8(197),this.writeU16(t);else if(t<4294967296)this.writeU8(198),this.writeU32(t);else throw new Error(`Too large binary: ${t}`);const n=br(e);this.writeU8a(n)}encodeArray(e,t){const n=e.length;if(n<16)this.writeU8(144+n);else if(n<65536)this.writeU8(220),this.writeU16(n);else if(n<4294967296)this.writeU8(221),this.writeU32(n);else throw new Error(`Too large array: ${n}`);for(const r of e)this.doEncode(r,t+1)}countWithoutUndefined(e,t){let n=0;for(const r of t)e[r]!==void 0&&n++;return n}encodeMap(e,t){const n=Object.keys(e);this.sortKeys&&n.sort();const r=this.ignoreUndefined?this.countWithoutUndefined(e,n):n.length;if(r<16)this.writeU8(128+r);else if(r<65536)this.writeU8(222),this.writeU16(r);else if(r<4294967296)this.writeU8(223),this.writeU32(r);else throw new Error(`Too large map object: ${r}`);for(const a of n){const o=e[a];this.ignoreUndefined&&o===void 0||(this.encodeString(a),this.doEncode(o,t+1))}}encodeExtension(e){if(typeof e.data=="function"){const n=e.data(this.pos+6),r=n.length;if(r>=4294967296)throw new Error(`Too large extension object: ${r}`);this.writeU8(201),this.writeU32(r),this.writeI8(e.type),this.writeU8a(n);return}const t=e.data.length;if(t===1)this.writeU8(212);else if(t===2)this.writeU8(213);else if(t===4)this.writeU8(214);else if(t===8)this.writeU8(215);else if(t===16)this.writeU8(216);else if(t<256)this.writeU8(199),this.writeU8(t);else if(t<65536)this.writeU8(200),this.writeU16(t);else if(t<4294967296)this.writeU8(201),this.writeU32(t);else throw new Error(`Too large extension object: ${t}`);this.writeI8(e.type),this.writeU8a(e.data)}writeU8(e){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,e),this.pos++}writeU8a(e){const t=e.length;this.ensureBufferSizeToWrite(t),this.bytes.set(e,this.pos),this.pos+=t}writeI8(e){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,e),this.pos++}writeU16(e){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,e),this.pos+=2}writeI16(e){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,e),this.pos+=2}writeU32(e){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,e),this.pos+=4}writeI32(e){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,e),this.pos+=4}writeF32(e){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,e),this.pos+=4}writeF64(e){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,e),this.pos+=8}writeU64(e){this.ensureBufferSizeToWrite(8),bf(this.view,this.pos,e),this.pos+=8}writeI64(e){this.ensureBufferSizeToWrite(8),Co(this.view,this.pos,e),this.pos+=8}writeBigUint64(e){this.ensureBufferSizeToWrite(8),this.view.setBigUint64(this.pos,e),this.pos+=8}writeBigInt64(e){this.ensureBufferSizeToWrite(8),this.view.setBigInt64(this.pos,e),this.pos+=8}};function Yt(s,e){return new Bf(e).encodeSharedRef(s)}function Un(s){return`${s<0?"-":""}0x${Math.abs(s).toString(16).padStart(2,"0")}`}const jf=16,Rf=16;class Mf{constructor(e=jf,t=Rf){this.hit=0,this.miss=0,this.maxKeyLength=e,this.maxLengthPerKey=t,this.caches=[];for(let n=0;n<this.maxKeyLength;n++)this.caches.push([])}canBeCached(e){return e>0&&e<=this.maxKeyLength}find(e,t,n){const r=this.caches[n-1];e:for(const a of r){const o=a.bytes;for(let c=0;c<n;c++)if(o[c]!==e[t+c])continue e;return a.str}return null}store(e,t){const n=this.caches[e.length-1],r={bytes:e,str:t};n.length>=this.maxLengthPerKey?n[Math.random()*n.length|0]=r:n.push(r)}decode(e,t,n){const r=this.find(e,t,n);if(r!=null)return this.hit++,r;this.miss++;const a=Uo(e,t,n),o=Uint8Array.prototype.slice.call(e,t,t+n);return this.store(o,a),a}}const vr="array",rs="map_key",Ro="map_value",Pf=s=>{if(typeof s=="string"||typeof s=="number")return s;throw new Oe("The type of key must be string or number but "+typeof s)};class Df{constructor(){this.stack=[],this.stackHeadPosition=-1}get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState(e){const t=this.getUninitializedStateFromPool();t.type=vr,t.position=0,t.size=e,t.array=new Array(e)}pushMapState(e){const t=this.getUninitializedStateFromPool();t.type=rs,t.readCount=0,t.size=e,t.map={}}getUninitializedStateFromPool(){if(this.stackHeadPosition++,this.stackHeadPosition===this.stack.length){const e={type:void 0,size:0,array:void 0,position:0,readCount:0,map:void 0,key:null};this.stack.push(e)}return this.stack[this.stackHeadPosition]}release(e){if(this.stack[this.stackHeadPosition]!==e)throw new Error("Invalid stack state. Released state is not on top of the stack.");if(e.type===vr){const t=e;t.size=0,t.array=void 0,t.position=0,t.type=void 0}if(e.type===rs||e.type===Ro){const t=e;t.size=0,t.map=void 0,t.readCount=0,t.type=void 0}this.stackHeadPosition--}reset(){this.stack.length=0,this.stackHeadPosition=-1}}const Mt=-1,ei=new DataView(new ArrayBuffer(0)),$f=new Uint8Array(ei.buffer);try{ei.getInt8(0)}catch(s){if(!(s instanceof RangeError))throw new Error("This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access")}const ea=new RangeError("Insufficient data"),Lf=new Mf;let Ff=class Mo{constructor(e){this.totalPos=0,this.pos=0,this.view=ei,this.bytes=$f,this.headByte=Mt,this.stack=new Df,this.entered=!1,this.extensionCodec=(e==null?void 0:e.extensionCodec)??ls.defaultCodec,this.context=e==null?void 0:e.context,this.useBigInt64=(e==null?void 0:e.useBigInt64)??!1,this.rawStrings=(e==null?void 0:e.rawStrings)??!1,this.maxStrLength=(e==null?void 0:e.maxStrLength)??Rt,this.maxBinLength=(e==null?void 0:e.maxBinLength)??Rt,this.maxArrayLength=(e==null?void 0:e.maxArrayLength)??Rt,this.maxMapLength=(e==null?void 0:e.maxMapLength)??Rt,this.maxExtLength=(e==null?void 0:e.maxExtLength)??Rt,this.keyDecoder=(e==null?void 0:e.keyDecoder)!==void 0?e.keyDecoder:Lf,this.mapKeyConverter=(e==null?void 0:e.mapKeyConverter)??Pf}clone(){return new Mo({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,rawStrings:this.rawStrings,maxStrLength:this.maxStrLength,maxBinLength:this.maxBinLength,maxArrayLength:this.maxArrayLength,maxMapLength:this.maxMapLength,maxExtLength:this.maxExtLength,keyDecoder:this.keyDecoder})}reinitializeState(){this.totalPos=0,this.headByte=Mt,this.stack.reset()}setBuffer(e){const t=br(e);this.bytes=t,this.view=new DataView(t.buffer,t.byteOffset,t.byteLength),this.pos=0}appendBuffer(e){if(this.headByte===Mt&&!this.hasRemaining(1))this.setBuffer(e);else{const t=this.bytes.subarray(this.pos),n=br(e),r=new Uint8Array(t.length+n.length);r.set(t),r.set(n,t.length),this.setBuffer(r)}}hasRemaining(e){return this.view.byteLength-this.pos>=e}createExtraByteError(e){const{view:t,pos:n}=this;return new RangeError(`Extra ${t.byteLength-n} of ${t.byteLength} byte(s) found at buffer[${e}]`)}decode(e){if(this.entered)return this.clone().decode(e);try{this.entered=!0,this.reinitializeState(),this.setBuffer(e);const t=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return t}finally{this.entered=!1}}*decodeMulti(e){if(this.entered){yield*this.clone().decodeMulti(e);return}try{for(this.entered=!0,this.reinitializeState(),this.setBuffer(e);this.hasRemaining(1);)yield this.doDecodeSync()}finally{this.entered=!1}}async decodeAsync(e){if(this.entered)return this.clone().decodeAsync(e);try{this.entered=!0;let t=!1,n;for await(const c of e){if(t)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(c);try{n=this.doDecodeSync(),t=!0}catch(h){if(!(h instanceof RangeError))throw h}this.totalPos+=this.pos}if(t){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return n}const{headByte:r,pos:a,totalPos:o}=this;throw new RangeError(`Insufficient data in parsing ${Un(r)} at ${o} (${a} in the current buffer)`)}finally{this.entered=!1}}decodeArrayStream(e){return this.decodeMultiAsync(e,!0)}decodeStream(e){return this.decodeMultiAsync(e,!1)}async*decodeMultiAsync(e,t){if(this.entered){yield*this.clone().decodeMultiAsync(e,t);return}try{this.entered=!0;let n=t,r=-1;for await(const a of e){if(t&&r===0)throw this.createExtraByteError(this.totalPos);this.appendBuffer(a),n&&(r=this.readArraySize(),n=!1,this.complete());try{for(;yield this.doDecodeSync(),--r!==0;);}catch(o){if(!(o instanceof RangeError))throw o}this.totalPos+=this.pos}}finally{this.entered=!1}}doDecodeSync(){e:for(;;){const e=this.readHeadByte();let t;if(e>=224)t=e-256;else if(e<192)if(e<128)t=e;else if(e<144){const r=e-128;if(r!==0){this.pushMapState(r),this.complete();continue e}else t={}}else if(e<160){const r=e-144;if(r!==0){this.pushArrayState(r),this.complete();continue e}else t=[]}else{const r=e-160;t=this.decodeString(r,0)}else if(e===192)t=null;else if(e===194)t=!1;else if(e===195)t=!0;else if(e===202)t=this.readF32();else if(e===203)t=this.readF64();else if(e===204)t=this.readU8();else if(e===205)t=this.readU16();else if(e===206)t=this.readU32();else if(e===207)this.useBigInt64?t=this.readU64AsBigInt():t=this.readU64();else if(e===208)t=this.readI8();else if(e===209)t=this.readI16();else if(e===210)t=this.readI32();else if(e===211)this.useBigInt64?t=this.readI64AsBigInt():t=this.readI64();else if(e===217){const r=this.lookU8();t=this.decodeString(r,1)}else if(e===218){const r=this.lookU16();t=this.decodeString(r,2)}else if(e===219){const r=this.lookU32();t=this.decodeString(r,4)}else if(e===220){const r=this.readU16();if(r!==0){this.pushArrayState(r),this.complete();continue e}else t=[]}else if(e===221){const r=this.readU32();if(r!==0){this.pushArrayState(r),this.complete();continue e}else t=[]}else if(e===222){const r=this.readU16();if(r!==0){this.pushMapState(r),this.complete();continue e}else t={}}else if(e===223){const r=this.readU32();if(r!==0){this.pushMapState(r),this.complete();continue e}else t={}}else if(e===196){const r=this.lookU8();t=this.decodeBinary(r,1)}else if(e===197){const r=this.lookU16();t=this.decodeBinary(r,2)}else if(e===198){const r=this.lookU32();t=this.decodeBinary(r,4)}else if(e===212)t=this.decodeExtension(1,0);else if(e===213)t=this.decodeExtension(2,0);else if(e===214)t=this.decodeExtension(4,0);else if(e===215)t=this.decodeExtension(8,0);else if(e===216)t=this.decodeExtension(16,0);else if(e===199){const r=this.lookU8();t=this.decodeExtension(r,1)}else if(e===200){const r=this.lookU16();t=this.decodeExtension(r,2)}else if(e===201){const r=this.lookU32();t=this.decodeExtension(r,4)}else throw new Oe(`Unrecognized type byte: ${Un(e)}`);this.complete();const n=this.stack;for(;n.length>0;){const r=n.top();if(r.type===vr)if(r.array[r.position]=t,r.position++,r.position===r.size)t=r.array,n.release(r);else continue e;else if(r.type===rs){if(t==="__proto__")throw new Oe("The key __proto__ is not allowed");r.key=this.mapKeyConverter(t),r.type=Ro;continue e}else if(r.map[r.key]=t,r.readCount++,r.readCount===r.size)t=r.map,n.release(r);else{r.key=null,r.type=rs;continue e}}return t}}readHeadByte(){return this.headByte===Mt&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=Mt}readArraySize(){const e=this.readHeadByte();switch(e){case 220:return this.readU16();case 221:return this.readU32();default:{if(e<160)return e-144;throw new Oe(`Unrecognized array type byte: ${Un(e)}`)}}}pushMapState(e){if(e>this.maxMapLength)throw new Oe(`Max length exceeded: map length (${e}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState(e)}pushArrayState(e){if(e>this.maxArrayLength)throw new Oe(`Max length exceeded: array length (${e}) > maxArrayLength (${this.maxArrayLength})`);this.stack.pushArrayState(e)}decodeString(e,t){return!this.rawStrings||this.stateIsMapKey()?this.decodeUtf8String(e,t):this.decodeBinary(e,t)}decodeUtf8String(e,t){var n;if(e>this.maxStrLength)throw new Oe(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+t+e)throw ea;const r=this.pos+t;let a;return this.stateIsMapKey()&&(n=this.keyDecoder)!=null&&n.canBeCached(e)?a=this.keyDecoder.decode(this.bytes,r,e):a=wf(this.bytes,r,e),this.pos+=t+e,a}stateIsMapKey(){return this.stack.length>0?this.stack.top().type===rs:!1}decodeBinary(e,t){if(e>this.maxBinLength)throw new Oe(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(e+t))throw ea;const n=this.pos+t,r=this.bytes.subarray(n,n+e);return this.pos+=t+e,r}decodeExtension(e,t){if(e>this.maxExtLength)throw new Oe(`Max length exceeded: ext length (${e}) > maxExtLength (${this.maxExtLength})`);const n=this.view.getInt8(this.pos+t),r=this.decodeBinary(e,t+1);return this.extensionCodec.decode(r,n,this.context)}lookU8(){return this.view.getUint8(this.pos)}lookU16(){return this.view.getUint16(this.pos)}lookU32(){return this.view.getUint32(this.pos)}readU8(){const e=this.view.getUint8(this.pos);return this.pos++,e}readI8(){const e=this.view.getInt8(this.pos);return this.pos++,e}readU16(){const e=this.view.getUint16(this.pos);return this.pos+=2,e}readI16(){const e=this.view.getInt16(this.pos);return this.pos+=2,e}readU32(){const e=this.view.getUint32(this.pos);return this.pos+=4,e}readI32(){const e=this.view.getInt32(this.pos);return this.pos+=4,e}readU64(){const e=vf(this.view,this.pos);return this.pos+=8,e}readI64(){const e=Bo(this.view,this.pos);return this.pos+=8,e}readU64AsBigInt(){const e=this.view.getBigUint64(this.pos);return this.pos+=8,e}readI64AsBigInt(){const e=this.view.getBigInt64(this.pos);return this.pos+=8,e}readF32(){const e=this.view.getFloat32(this.pos);return this.pos+=4,e}readF64(){const e=this.view.getFloat64(this.pos);return this.pos+=8,e}};function Po(s,e){return new Ff(e).decode(s)}let Do=class{constructor(){pt(this,"contentType","application/json"),pt(this,"decoder"),pt(this,"encoder"),this.decoder=new TextDecoder,this.encoder=new TextEncoder}encode(s){return this.encoder.encode(this.encodeString(s))}decode(s,e){return this.decodeString(this.decoder.decode(s),e)}decodeString(s,e){const t=JSON.parse(s),n=Qr(t);return e!=null?e.parse(n):n}encodeString(s){const e=Ao(s);return JSON.stringify(e,(t,n)=>ArrayBuffer.isView(n)?Array.from(n):rn(n)&&"encode_value"in n?typeof n.value=="bigint"?n.value.toString():n.value:typeof n=="bigint"?n.toString():n)}static registerCustomType(){}},$o=class{constructor(){pt(this,"contentType","text/csv")}encode(s){const e=this.encodeString(s);return new TextEncoder().encode(e)}decode(s,e){const t=new TextDecoder().decode(s);return this.decodeString(t,e)}encodeString(s){if(!Array.isArray(s)||s.length===0||!rn(s[0]))throw new Error("Payload must be an array of objects");const e=Object.keys(s[0]),t=[e.join(",")];return s.forEach(n=>{const r=e.map(a=>JSON.stringify(n[a]??""));t.push(r.join(","))}),t.join(`
14
+ `)}decodeString(s,e){const[t,...n]=s.trim().split(`
15
+ `).map(o=>o.trim());if(t.length===0)return e!=null?e.parse({}):{};const r=t.split(",").map(o=>o.trim()),a={};return r.forEach(o=>{a[o]=[]}),n.forEach(o=>{const c=o.split(",").map(h=>h.trim());r.forEach((h,d)=>{const f=this.parseValue(c[d]);f!=null&&a[h].push(f)})}),e!=null?e.parse(a):a}parseValue(s){if(s==null||s.length===0)return null;const e=Number(s);return isNaN(e)?s.startsWith('"')&&s.endsWith('"')?s.slice(1,-1):s:e}static registerCustomType(){}},Lo=class{constructor(){pt(this,"contentType","text/plain")}encode(s){return new TextEncoder().encode(s)}decode(s,e){const t=new TextDecoder().decode(s);return e!=null?e.parse(t):t}};const Ye=new ls;Ye.register({type:0,encode:s=>{if(ArrayBuffer.isView(s)){const e=Array.from(s);return Yt(e,{extensionCodec:Ye})}return rn(s)&&"encode_value"in s?typeof s.value=="bigint"?Yt(s.value.toString(),{extensionCodec:Ye}):Yt(s.value,{extensionCodec:Ye}):typeof s=="bigint"?Yt(s.toString(),{extensionCodec:Ye}):null},decode:s=>Po(s,{extensionCodec:Ye})});let Fo=class{constructor(){pt(this,"contentType","application/msgpack")}encode(s){const e=Ao(s);return Yt(e,{extensionCodec:Ye}).slice()}decode(s,e){const t=Po(s,{extensionCodec:Ye}),n=Qr(t);return e!=null?e.parse(n):n}static registerCustomType(){}};const is=new Do,_f=new $o,qf=new Lo,Wf=new Fo,rt=Object.freeze(Object.defineProperty({__proto__:null,CSVCodec:$o,CSV_CODEC:_f,JSONCodec:Do,JSON_CODEC:is,MSGPACK_CODEC:Wf,MsgPackCodec:Fo,TEXT_CODEC:qf,TextCodec:Lo},Symbol.toStringTag,{value:"Module"})),Vf=s=>[...new Set(s)],Yf=(s,e,t=!0)=>{const n=new Map;return s.forEach(r=>{const a=e(r);if(n.has(a)){if(t)return;n.delete(a)}n.set(a,r)}),Array.from(n.values())},ta=Object.freeze(Object.defineProperty({__proto__:null,by:Yf,unique:Vf},Symbol.toStringTag,{value:"Module"})),Zf=s=>s!=null&&typeof s=="object"&&"toString"in s,Kf=(s,e=!1)=>{const t=Zf(s)?"stringer":typeof s;let n;switch(t){case"string":n=(r,a)=>r.localeCompare(a);break;case"stringer":n=(r,a)=>r.toString().localeCompare(a.toString());break;case"number":n=(r,a)=>Number(r)-Number(a);break;case"bigint":n=(r,a)=>BigInt(r)-BigInt(a)>0n?1:-1;break;case"boolean":n=(r,a)=>Number(r)-Number(a);break;case"undefined":n=()=>0;break;default:return console.warn(`sortFunc: unknown type ${t}`),()=>-1}return e?Hf(n):n},Hf=s=>(e,t)=>s(t,e),an=0,Cn=-1,Bn=1,Gf=s=>s<an,Jf=s=>s>an,Xf=s=>s===an,on=i.z.tuple([i.z.number(),i.z.number()]);i.z.tuple([i.z.bigint(),i.z.bigint()]);const _o=i.z.object({width:i.z.number(),height:i.z.number()}),Qf=i.z.object({signedWidth:i.z.number(),signedHeight:i.z.number()}),ey=["width","height"];i.z.enum(ey);const ty=["start","center","end"],sy=["signedWidth","signedHeight"];i.z.enum(sy);const Js=i.z.object({x:i.z.number(),y:i.z.number()}),ny=i.z.object({clientX:i.z.number(),clientY:i.z.number()}),ry=["x","y"],qo=i.z.enum(ry),Wo=["top","right","bottom","left"];i.z.enum(Wo);const iy=["left","right"],Vo=i.z.enum(iy),ay=["top","bottom"],Yo=i.z.enum(ay),Zo=["center"],sa=i.z.enum(Zo),oy=[...Wo,...Zo],Ko=i.z.enum(oy);i.z.enum(ty);const cy=["first","last"];i.z.enum(cy);const ly=i.z.object({lower:i.z.number(),upper:i.z.number()}),hy=i.z.object({lower:i.z.bigint(),upper:i.z.bigint()});i.z.union([ly,on]);i.z.union([hy,on]);i.z.enum([...qo.options,...Ko.options]);i.z.union([qo,Ko,i.z.instanceof(String)]);const Tt=s=>typeof s=="bigint"||s instanceof BigInt,jn=(s,e)=>Tt(s)?s.valueOf()-BigInt(e.valueOf().valueOf()):s.valueOf()-Number(e.valueOf()),uy=(s,e)=>Tt(s)?s.valueOf()+BigInt(e.valueOf().valueOf()):s+Number(e.valueOf()),na=(s,e)=>Tt(s)?s===BigInt(e.valueOf().valueOf()):s===Number(e.valueOf()),dy=(s,e)=>Tt(s)?s.valueOf()<BigInt(e.valueOf())?s:BigInt(e.valueOf()):s.valueOf()<Number(e.valueOf())?s:Number(e.valueOf()),fy=s=>Tt(s)||s instanceof BigInt?s.valueOf()<0n?-s:s:s.valueOf()<0?-s:s,ct=(s,e)=>Tt(s)?s.valueOf()*BigInt(e.valueOf()):s.valueOf()*Number(e.valueOf()),ee=(s,e)=>{const t={};if(typeof s=="number"||typeof s=="bigint")e!=null?(t.lower=s,t.upper=e):(t.lower=typeof s=="bigint"?0n:0,t.upper=s);else if(Array.isArray(s)){if(s.length!==2)throw new Error("bounds: expected array of length 2");[t.lower,t.upper]=s}else return ra(s);return ra(t)},ra=s=>s.lower>s.upper?{lower:s.upper,upper:s.lower}:s,ia=(s,e)=>{const t=ee(s);return e<t.lower?t.lower:e>=t.upper?t.upper-(typeof t.upper=="number"?1:1n):e},Bs=(s,e)=>{const t=ee(s);if(typeof e=="number"||typeof e=="bigint")return e>=t.lower&&e<t.upper;const n=ee(e);return n.lower>=t.lower&&n.upper<=t.upper},yy=s=>({lower:Math.min(...s.map(e=>ee(e).lower)),upper:Math.max(...s.map(e=>ee(e).upper))}),py=(s,e,t)=>{const n=s.map(c=>ee(c)),r=t>0?1:t<0?-1:0;if(r===0)return e;let a=t,o=e;for(;na(a,0)===!1;){const c=n.findIndex(h=>r>0?o>=h.lower&&o<h.upper:o>h.lower&&o<=h.upper);if(c!==-1){const h=n[c];let d;if(r>0?d=jn(h.upper,o):d=jn(o,h.lower),d>0){const f=dy(fy(a),d);if(o=uy(o,r>0?f:-f),a=jn(a,r>0?f:-f),na(a,0))return o;continue}}if(r>0){const h=n.filter(d=>d.lower>o);if(h.length>0)o=h[0].lower;else return o}else{const h=n.filter(d=>d.upper<o);if(h.length>0)o=h[h.length-1].upper;else return o}}return o},gy=(s,e,t)=>{const n=s.map(o=>ee(o));if(e===t)return typeof e=="bigint"?0n:0;const r=e<t?ee([e,t]):ee([t,e]);let a=typeof e=="bigint"?0n:0;for(const o of n){const c=o.lower>r.lower?o.lower:r.lower,h=o.upper<r.upper?o.upper:r.upper;if(c<h){const d=h-c;a=a+d}}return a};i.z.object({x:Vo.or(sa),y:Yo.or(sa)});const my=i.z.object({x:Vo,y:Yo}),wy=Object.freeze({x:"left",y:"top"}),by=(s,e)=>s.x===e.x&&s.y===e.y,aa=i.z.union([i.z.number(),Js,on,_o,Qf,ny]),vy=(s,e)=>{if(typeof s=="string"){if(e===void 0)throw new Error("The y coordinate must be given.");return s==="x"?{x:e,y:0}:{x:0,y:e}}return typeof s=="number"?{x:s,y:e??s}:Array.isArray(s)?{x:s[0],y:s[1]}:"signedWidth"in s?{x:s.signedWidth,y:s.signedHeight}:"clientX"in s?{x:s.clientX,y:s.clientY}:"width"in s?{x:s.width,y:s.height}:{x:s.x,y:s.y}},oa=Object.freeze({x:0,y:0}),js=i.z.union([i.z.number(),i.z.string()]);i.z.object({top:js,left:js,width:js,height:js});i.z.object({left:i.z.number(),top:i.z.number(),right:i.z.number(),bottom:i.z.number()});i.z.object({one:Js,two:Js,root:my});const ti=(s,e,t=0,n=0,r)=>{const a={one:{...oa},two:{...oa},root:r??wy};if(typeof s=="number"){if(typeof e!="number")throw new Error("Box constructor called with invalid arguments");return a.one={x:s,y:e},a.two={x:a.one.x+t,y:a.one.y+n},a}return"one"in s&&"two"in s&&"root"in s?{...s,root:r??s.root}:("getBoundingClientRect"in s&&(s=s.getBoundingClientRect()),"left"in s?(a.one={x:s.left,y:s.top},a.two={x:s.right,y:s.bottom},a):(a.one=s,e==null?a.two={x:a.one.x+t,y:a.one.y+n}:typeof e=="number"?a.two={x:a.one.x+e,y:a.one.y+t}:"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))},Rn=s=>{const e=ti(s);return{lower:e.one.x,upper:e.two.x}},Mn=s=>{const e=ti(s);return{lower:e.one.y,upper:e.two.y}},zy=s=>typeof s!="object"||s==null?!1:"one"in s&&"two"in s&&"root"in s,Sy=i.z.object({signedWidth:i.z.number(),signedHeight:i.z.number()});i.z.union([_o,Sy,Js,on]);var Ty=Object.defineProperty,Oy=(s,e,t)=>e in s?Ty(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,je=(s,e,t)=>Oy(s,typeof e!="symbol"?e+"":e,t);const ky=(s,e,t)=>e!==void 0&&s<e?e:t!==void 0&&s>t?t:s;i.z.object({offset:aa,scale:aa});i.z.object({offset:i.z.number(),scale:i.z.number()});const xy=s=>(e,t,n,r)=>t==="dimension"?[e,n]:[e,r?n-s:n+s],Iy=s=>(e,t,n,r)=>[e,r?n/s:n*s],Ey=s=>(e,t,n)=>{if(e===null)return[s,n];const{lower:r,upper:a}=e,{lower:o,upper:c}=s,h=a-r,d=c-o;if(t==="dimension")return[s,n*(d/h)];const f=(n-r)*(d/h)+o;return[s,f]},Ny=s=>(e,t,n)=>[s,n],Ay=()=>(s,e,t)=>{if(s===null)throw new Error("cannot invert without bounds");if(e==="dimension")return[s,t];const{lower:n,upper:r}=s;return[s,r-(t-n)]},Uy=s=>(e,t,n)=>{const{lower:r,upper:a}=s;return n=ky(n,r,a),[e,n]},zr=class Zt{constructor(){je(this,"ops",[]),je(this,"currBounds",null),je(this,"currType",null),je(this,"reversed",!1),this.ops=[]}static translate(e){return new Zt().translate(e)}static magnify(e){return new Zt().magnify(e)}static scale(e,t){return new Zt().scale(e,t)}translate(e){const t=this.new(),n=xy(e);return n.type="translate",t.ops.push(n),t}magnify(e){const t=this.new(),n=Iy(e);return n.type="magnify",t.ops.push(n),t}scale(e,t){const n=ee(e,t),r=this.new(),a=Ey(n);return a.type="scale",r.ops.push(a),r}clamp(e,t){const n=ee(e,t),r=this.new(),a=Uy(n);return a.type="clamp",r.ops.push(a),r}reBound(e,t){const n=ee(e,t),r=this.new(),a=Ny(n);return a.type="re-bound",r.ops.push(a),r}invert(){const e=Ay();e.type="invert";const t=this.new();return t.ops.push(e),t}pos(e){return this.exec("position",e)}dim(e){return this.exec("dimension",e)}new(){const e=new Zt;return e.ops=this.ops.slice(),e.reversed=this.reversed,e}exec(e,t){return this.currBounds=null,this.ops.reduce(([n,r],a)=>a(n,e,r,this.reversed),[null,t])[1]}reverse(){const e=this.new();e.ops.reverse();const t=[];return e.ops.forEach((n,r)=>{if(n.type==="scale"||t.some(([o,c])=>r>=o&&r<=c))return;const a=e.ops.findIndex((o,c)=>o.type==="scale"&&c>r);a!==-1&&t.push([r,a])}),t.forEach(([n,r])=>{const a=e.ops.slice(n,r);a.unshift(e.ops[r]),e.ops.splice(n,r-n+1,...a)}),e.reversed=!e.reversed,e}get transform(){return{scale:this.dim(1),offset:this.pos(0)}}};je(zr,"IDENTITY",new zr);let ca=zr;const la=class Ce{constructor(e=new ca,t=new ca,n=null){je(this,"x"),je(this,"y"),je(this,"currRoot"),this.x=e,this.y=t,this.currRoot=n}static translate(e,t){return new Ce().translate(e,t)}static translateX(e){return new Ce().translateX(e)}static translateY(e){return new Ce().translateY(e)}static clamp(e){return new Ce().clamp(e)}static magnify(e){return new Ce().magnify(e)}static scale(e){return new Ce().scale(e)}static reBound(e){return new Ce().reBound(e)}translate(e,t){const n=vy(e,t),r=this.copy();return r.x=this.x.translate(n.x),r.y=this.y.translate(n.y),r}translateX(e){const t=this.copy();return t.x=this.x.translate(e),t}translateY(e){const t=this.copy();return t.y=this.y.translate(e),t}magnify(e){const t=this.copy();return t.x=this.x.magnify(e.x),t.y=this.y.magnify(e.y),t}scale(e){const t=this.copy();if(zy(e)){const n=this.currRoot;return t.currRoot=e.root,n!=null&&!by(n,e.root)&&(n.x!==e.root.x&&(t.x=t.x.invert()),n.y!==e.root.y&&(t.y=t.y.invert())),t.x=t.x.scale(Rn(e)),t.y=t.y.scale(Mn(e)),t}return t.x=t.x.scale(e.width),t.y=t.y.scale(e.height),t}reBound(e){const t=this.copy();return t.x=this.x.reBound(Rn(e)),t.y=this.y.reBound(Mn(e)),t}clamp(e){const t=this.copy();return t.x=this.x.clamp(Rn(e)),t.y=this.y.clamp(Mn(e)),t}copy(){const e=new Ce;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)}}dim(e){return{x:this.x.dim(e.x),y:this.y.dim(e.y)}}box(e){return ti(this.pos(e.one),this.pos(e.two),0,0,this.currRoot??e.root)}get transform(){return{scale:this.dim({x:1,y:1}),offset:this.pos({x:0,y:0})}}};je(la,"IDENTITY",new la);var Cy=Object.defineProperty,By=(s,e,t)=>e in s?Cy(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,y=(s,e,t)=>By(s,typeof e!="symbol"?e+"":e,t);let jy=(s,e=21)=>(t=e)=>{let n="",r=t|0;for(;r--;)n+=s[Math.random()*s.length|0];return n};const Ry="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",My=jy(Ry,11),Ho=()=>My(),Py=Object.freeze(Object.defineProperty({__proto__:null,create:Ho},Symbol.toStringTag,{value:"Module"})),Dy=i.z.enum(["static","dynamic"]),Go=(s,e)=>{const t=new x(e);if(![O.DAY,O.HOUR,O.MINUTE,O.SECOND,O.MILLISECOND,O.MICROSECOND,O.NANOSECOND].some(r=>r.equals(t)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const n=s.valueOf()%t.valueOf();return s instanceof x?new x(n):new O(n)},M=class z{constructor(e,t="UTC"){if(y(this,"value"),y(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,t).valueOf();else if(Array.isArray(e))this.value=z.parseDate(e);else{let n=BigInt(0);e instanceof Number&&(e=e.valueOf()),t==="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,t=1,n=1]){const r=new Date(e,t-1,n,0,0,0,0);return new z(BigInt(r.getTime())*z.MILLISECOND.valueOf()).truncate(z.DAY).valueOf()}valueOf(){return this.value}static parseTimeString(e,t="UTC"){const[n,r,a]=e.split(":");let o="00",c="00";a!=null&&([o,c]=a.split("."));let h=z.hours(parseInt(n??"00")).add(z.minutes(parseInt(r??"00"))).add(z.seconds(parseInt(o??"00"))).add(z.milliseconds(parseInt(c??"00")));return t==="local"&&(h=h.add(z.utcOffset)),h.valueOf()}static parseDateTimeString(e,t="UTC"){if(!e.includes("/")&&!e.includes("-"))return z.parseTimeString(e,t);const n=new Date(e);return e.includes(":")||n.setUTCHours(0,0,0,0),new z(BigInt(n.getTime())*z.MILLISECOND.valueOf(),t).valueOf()}fString(e="ISO",t="UTC"){switch(e){case"ISODate":return this.toISOString(t).slice(0,10);case"ISOTime":return this.toISOString(t).slice(11,23);case"time":return this.timeString(!1,t);case"preciseTime":return this.timeString(!0,t);case"date":return this.dateString();case"preciseDate":return`${this.dateString()} ${this.timeString(!0,t)}`;case"dateTime":return`${this.dateString()} ${this.timeString(!1,t)}`;default:return this.toISOString(t)}}toISOString(e="UTC"){return e==="UTC"?this.date().toISOString():this.sub(z.utcOffset).date().toISOString()}timeString(e=!1,t="UTC"){const n=this.toISOString(t);return e?n.slice(11,23):n.slice(11,19)}dateString(){const e=this.date(),t=e.toLocaleString("default",{month:"short"}),n=e.toLocaleString("default",{day:"numeric"});return`${t} ${n}`}static get utcOffset(){return new O(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 V(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()))}get hours(){return Number(this.valueOf())/Number(O.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(O.MINUTE.valueOf())}get days(){return Number(this.valueOf())/Number(O.DAY.valueOf())}get seconds(){return Number(this.valueOf())/Number(O.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(z.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(z.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get year(){return this.date().getFullYear()}setYear(e){const t=this.date();return t.setFullYear(e),new z(t)}get month(){return this.date().getUTCMonth()}setMonth(e){const t=this.date();return t.setUTCMonth(e),new z(t)}get day(){return this.date().getUTCDate()}setDay(e){const t=this.date();return t.setUTCDate(e),new z(t)}get hour(){return this.date().getUTCHours()}setHour(e){const t=this.date();return t.setUTCHours(e),new z(t,"UTC")}get minute(){return this.date().getMinutes()}setMinute(e){const t=this.date();return t.setUTCMinutes(e),new z(t)}get second(){return this.date().getSeconds()}setSecond(e){const t=this.date();return t.setUTCSeconds(e),new z(t)}get millisecond(){return this.date().getMilliseconds()}setMillisecond(e){const t=this.date();return t.setMilliseconds(e),new z(t)}toString(){return this.date().toISOString()}remainder(e){return Go(this,e)}get isToday(){return this.truncate(O.DAY).equals(z.now().truncate(O.DAY))}truncate(e){return this.sub(this.remainder(e))}static now(){return new z(new Date)}static max(...e){let t=z.MIN;for(const n of e){const r=new z(n);r.after(t)&&(t=r)}return t}static min(...e){let t=z.MAX;for(const n of e){const r=new z(n);r.before(t)&&(t=r)}return t}static nanoseconds(e,t="UTC"){return new z(e,t)}static microseconds(e,t="UTC"){return z.nanoseconds(e*1e3,t)}static milliseconds(e,t="UTC"){return z.microseconds(e*1e3,t)}static seconds(e,t="UTC"){return z.milliseconds(e*1e3,t)}static minutes(e,t="UTC"){return z.seconds(e*60,t)}static hours(e,t="UTC"){return z.minutes(e*60,t)}static days(e,t="UTC"){return z.hours(e*24,t)}};y(M,"NANOSECOND",M.nanoseconds(1)),y(M,"MICROSECOND",M.microseconds(1)),y(M,"MILLISECOND",M.milliseconds(1)),y(M,"SECOND",M.seconds(1)),y(M,"MINUTE",M.minutes(1)),y(M,"HOUR",M.hours(1)),y(M,"DAY",M.days(1)),y(M,"MAX",new M((1n<<63n)-1n)),y(M,"MIN",new M(0)),y(M,"ZERO",new M(0)),y(M,"z",i.z.union([i.z.object({value:i.z.bigint()}).transform(s=>new M(s.value)),i.z.string().transform(s=>new M(BigInt(s))),i.z.instanceof(Number).transform(s=>new M(s)),i.z.number().transform(s=>new M(s)),i.z.instanceof(M)]));let x=M;const P=class E{constructor(e){y(this,"value"),y(this,"encodeValue",!0),typeof e=="number"&&(e=Math.trunc(e.valueOf())),this.value=BigInt(e.valueOf())}static fromSeconds(e){return e instanceof E?e:e instanceof ha?e.period:e instanceof x?new E(e):["number","bigint"].includes(typeof e)?E.seconds(e):new E(e)}static fromMilliseconds(e){return e instanceof E?e:e instanceof ha?e.period:e instanceof x?new E(e):["number","bigint"].includes(typeof e)?E.milliseconds(e):new E(e)}encode(){return this.value.toString()}valueOf(){return this.value}lessThan(e){return this.valueOf()<new E(e).valueOf()}greaterThan(e){return this.valueOf()>new E(e).valueOf()}lessThanOrEqual(e){return this.valueOf()<=new E(e).valueOf()}greaterThanOrEqual(e){return this.valueOf()>=new E(e).valueOf()}remainder(e){return Go(this,e)}truncate(e){return new E(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(){const e=this.truncate(E.DAY),t=this.truncate(E.HOUR),n=this.truncate(E.MINUTE),r=this.truncate(E.SECOND),a=this.truncate(E.MILLISECOND),o=this.truncate(E.MICROSECOND),c=this.truncate(E.NANOSECOND),h=e,d=t.sub(e),f=n.sub(t),u=r.sub(n),T=a.sub(r),k=o.sub(a),Y=c.sub(o);let U="";return h.isZero||(U+=`${h.days}d `),d.isZero||(U+=`${d.hours}h `),f.isZero||(U+=`${f.minutes}m `),u.isZero||(U+=`${u.seconds}s `),T.isZero||(U+=`${T.milliseconds}ms `),k.isZero||(U+=`${k.microseconds}µs `),Y.isZero||(U+=`${Y.nanoseconds}ns`),U.trim()}mult(e){return new E(this.valueOf()*BigInt(e))}get days(){return Number(this.valueOf())/Number(E.DAY.valueOf())}get hours(){return Number(this.valueOf())/Number(E.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(E.MINUTE.valueOf())}get seconds(){return Number(this.valueOf())/Number(E.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(E.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(E.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===BigInt(0)}equals(e){return this.valueOf()===new E(e).valueOf()}add(e){return new E(this.valueOf()+new E(e).valueOf())}sub(e){return new E(this.valueOf()-new E(e).valueOf())}static nanoseconds(e=1){return new E(e)}static microseconds(e=1){return E.nanoseconds(ct(e,1e3))}static milliseconds(e=1){return E.microseconds(ct(e,1e3))}static seconds(e=1){return E.milliseconds(ct(e,1e3))}static minutes(e=1){return E.seconds(ct(e,60))}static hours(e){return E.minutes(ct(e,60))}static days(e){return E.hours(ct(e,24))}};y(P,"NANOSECOND",P.nanoseconds(1)),y(P,"MICROSECOND",P.microseconds(1)),y(P,"MILLISECOND",P.milliseconds(1)),y(P,"SECOND",P.seconds(1)),y(P,"MINUTE",P.minutes(1)),y(P,"HOUR",P.hours(1)),y(P,"DAY",P.days(1)),y(P,"MAX",new P((1n<<63n)-1n)),y(P,"MIN",new P(0)),y(P,"ZERO",new P(0)),y(P,"z",i.z.union([i.z.object({value:i.z.bigint()}).transform(s=>new P(s.value)),i.z.string().transform(s=>new P(BigInt(s))),i.z.instanceof(Number).transform(s=>new P(s)),i.z.number().transform(s=>new P(s)),i.z.instanceof(P)]));let O=P;const Kt=class _s extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new _s(e).valueOf()}get period(){return O.seconds(1/this.valueOf())}sampleCount(e){return new O(e).seconds*this.valueOf()}byteCount(e,t){return this.sampleCount(e)*new ae(t).valueOf()}span(e){return O.seconds(e/this.valueOf())}byteSpan(e,t){return this.span(e.valueOf()/t.valueOf())}static hz(e){return new _s(e)}static khz(e){return _s.hz(e*1e3)}};y(Kt,"z",i.z.union([i.z.number().transform(s=>new Kt(s)),i.z.instanceof(Number).transform(s=>new Kt(s)),i.z.instanceof(Kt)]));let ha=Kt;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 wt(e*this.valueOf())}};y(Q,"UNKNOWN",new Q(0)),y(Q,"BIT128",new Q(16)),y(Q,"BIT64",new Q(8)),y(Q,"BIT32",new Q(4)),y(Q,"BIT16",new Q(2)),y(Q,"BIT8",new Q(1)),y(Q,"z",i.z.union([i.z.number().transform(s=>new Q(s)),i.z.instanceof(Number).transform(s=>new Q(s)),i.z.instanceof(Q)]));let ae=Q;const ze=class Ht{constructor(e,t){y(this,"start"),y(this,"end"),typeof e=="object"&&"start"in e?(this.start=new x(e.start),this.end=new x(e.end)):(this.start=new x(e),this.end=new x(t))}get span(){return new O(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}get numeric(){return{start:Number(this.start.valueOf()),end:Number(this.end.valueOf())}}swap(){return new Ht(this.end,this.start)}get numericBounds(){return{lower:Number(this.start.valueOf()),upper:Number(this.end.valueOf())}}equals(e,t=O.ZERO){if(t.isZero)return this.start.equals(e.start)&&this.end.equals(e.end);let n=this.start.sub(e.start).valueOf(),r=this.end.sub(e.end).valueOf();return n<0&&(n=-n),r<0&&(r=-r),n<=t.valueOf()&&r<=t.valueOf()}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.fString("preciseDate")} - ${this.span.toString()}`}overlapsWith(e,t=O.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 r=x.max(n.start,e.start),a=x.min(n.end,e.end);return a.before(r)?!1:new O(a.sub(r)).greaterThanOrEqual(t)}contains(e){return e instanceof Ht?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const t=new Ht(this.start,this.end);return e.start.after(this.start)&&(t.start=e.start),e.start.after(this.end)&&(t.end=e.start),e.end.before(this.end)&&(t.end=e.end),e.end.before(this.start)&&(t.start=e.end),t}static max(...e){return new Ht(x.min(...e.map(t=>t.start)),x.max(...e.map(t=>t.end)))}};y(ze,"MAX",new ze(x.MIN,x.MAX)),y(ze,"MIN",new ze(x.MAX,x.MIN)),y(ze,"ZERO",new ze(x.ZERO,x.ZERO)),y(ze,"z",i.z.union([i.z.object({start:x.z,end:x.z}).transform(s=>new ze(s.start,s.end)),i.z.instanceof(ze)]));let V=ze;const $y=(s,e)=>s.start.before(e.start)?-1:s.start.after(e.start)?1:s.end.before(e.end)?-1:s.end.after(e.end)?1:0,m=class q{constructor(e){if(y(this,"value"),y(this,"encodeValue",!0),e instanceof q||typeof e=="string"||typeof e.valueOf()=="string"){this.value=e.valueOf();return}const t=q.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(t!=null){this.value=t.valueOf();return}throw this.value=q.UNKNOWN.valueOf(),new Error(`unable to find data type for ${e.toString()}`)}valueOf(){return this.value}get Array(){const e=q.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()}matches(...e){return e.some(t=>this.equals(t))}toString(){return this.valueOf()}get isVariable(){return this.equals(q.JSON)||this.equals(q.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(q.UUID)}get isInteger(){const e=this.toString();return e.startsWith("int")||e.startsWith("uint")}get isFloat(){return this.toString().startsWith("float")}get density(){const e=q.DENSITIES.get(this.toString());if(e==null)throw new Error(`unable to find density for ${this.valueOf()}`);return e}get isUnsigned(){return this.equals(q.UINT8)||this.equals(q.UINT16)||this.equals(q.UINT32)||this.equals(q.UINT64)}get isSigned(){return this.equals(q.INT8)||this.equals(q.INT16)||this.equals(q.INT32)||this.equals(q.INT64)}canSafelyCastTo(e){return this.equals(e)?!0:!this.isNumeric||!e.isNumeric||this.isVariable||e.isVariable||this.isUnsigned&&e.isSigned?!1:this.isFloat?e.isFloat&&this.density.valueOf()<=e.density.valueOf():this.equals(q.INT32)&&e.equals(q.FLOAT64)||this.equals(q.INT8)&&e.equals(q.FLOAT32)?!0:this.isInteger&&e.isInteger?this.density.valueOf()<=e.density.valueOf()&&this.isUnsigned===e.isUnsigned:!1}canCastTo(e){return this.isNumeric&&e.isNumeric?!0:this.equals(e)}toJSON(){return this.toString()}get usesBigInt(){return q.BIG_INT_TYPES.some(e=>e.equals(this))}};y(m,"UNKNOWN",new m("unknown")),y(m,"FLOAT64",new m("float64")),y(m,"FLOAT32",new m("float32")),y(m,"INT64",new m("int64")),y(m,"INT32",new m("int32")),y(m,"INT16",new m("int16")),y(m,"INT8",new m("int8")),y(m,"UINT64",new m("uint64")),y(m,"UINT32",new m("uint32")),y(m,"UINT16",new m("uint16")),y(m,"UINT8",new m("uint8")),y(m,"BOOLEAN",m.UINT8),y(m,"TIMESTAMP",new m("timestamp")),y(m,"UUID",new m("uuid")),y(m,"STRING",new m("string")),y(m,"JSON",new m("json")),y(m,"ARRAY_CONSTRUCTORS",new Map([[m.UINT8.toString(),Uint8Array],[m.UINT16.toString(),Uint16Array],[m.UINT32.toString(),Uint32Array],[m.UINT64.toString(),BigUint64Array],[m.FLOAT32.toString(),Float32Array],[m.FLOAT64.toString(),Float64Array],[m.INT8.toString(),Int8Array],[m.INT16.toString(),Int16Array],[m.INT32.toString(),Int32Array],[m.INT64.toString(),BigInt64Array],[m.TIMESTAMP.toString(),BigInt64Array],[m.STRING.toString(),Uint8Array],[m.JSON.toString(),Uint8Array],[m.UUID.toString(),Uint8Array]])),y(m,"ARRAY_CONSTRUCTOR_DATA_TYPES",new Map([[Uint8Array.name,m.UINT8],[Uint16Array.name,m.UINT16],[Uint32Array.name,m.UINT32],[BigUint64Array.name,m.UINT64],[Float32Array.name,m.FLOAT32],[Float64Array.name,m.FLOAT64],[Int8Array.name,m.INT8],[Int16Array.name,m.INT16],[Int32Array.name,m.INT32],[BigInt64Array.name,m.INT64]])),y(m,"DENSITIES",new Map([[m.UINT8.toString(),ae.BIT8],[m.UINT16.toString(),ae.BIT16],[m.UINT32.toString(),ae.BIT32],[m.UINT64.toString(),ae.BIT64],[m.FLOAT32.toString(),ae.BIT32],[m.FLOAT64.toString(),ae.BIT64],[m.INT8.toString(),ae.BIT8],[m.INT16.toString(),ae.BIT16],[m.INT32.toString(),ae.BIT32],[m.INT64.toString(),ae.BIT64],[m.TIMESTAMP.toString(),ae.BIT64],[m.STRING.toString(),ae.UNKNOWN],[m.JSON.toString(),ae.UNKNOWN],[m.UUID.toString(),ae.BIT128]])),y(m,"ALL",[m.UNKNOWN,m.FLOAT64,m.FLOAT32,m.INT64,m.INT32,m.INT16,m.INT8,m.UINT64,m.UINT32,m.UINT16,m.UINT8,m.TIMESTAMP,m.UUID,m.STRING,m.JSON]),y(m,"BIG_INT_TYPES",[m.INT64,m.UINT64,m.TIMESTAMP]),y(m,"z",i.z.union([i.z.string().transform(s=>new m(s)),i.z.instanceof(m)]));let N=m;const re=class K extends Number{constructor(e){super(e.valueOf())}largerThan(e){return this.valueOf()>e.valueOf()}smallerThan(e){return this.valueOf()<e.valueOf()}add(e){return K.bytes(this.valueOf()+e.valueOf())}sub(e){return K.bytes(this.valueOf()-e.valueOf())}truncate(e){return new K(Math.trunc(this.valueOf()/e.valueOf())*e.valueOf())}remainder(e){return K.bytes(this.valueOf()%e.valueOf())}get gigabytes(){return this.valueOf()/K.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/K.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/K.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/K.TERABYTE.valueOf()}toString(){const e=this.truncate(K.TERABYTE),t=this.truncate(K.GIGABYTE),n=this.truncate(K.MEGABYTE),r=this.truncate(K.KILOBYTE),a=this.truncate(K.BYTE),o=e,c=t.sub(e),h=n.sub(t),d=r.sub(n),f=a.sub(r);let u="";return o.isZero||(u+=`${o.terabytes}TB `),c.isZero||(u+=`${c.gigabytes}GB `),h.isZero||(u+=`${h.megabytes}MB `),d.isZero||(u+=`${d.kilobytes}KB `),(!f.isZero||u==="")&&(u+=`${f.valueOf()}B`),u.trim()}static bytes(e=1){return new K(e)}static kilobytes(e=1){return K.bytes(e.valueOf()*1e3)}static megabytes(e=1){return K.kilobytes(e.valueOf()*1e3)}static gigabytes(e=1){return K.megabytes(e.valueOf()*1e3)}static terabytes(e){return K.gigabytes(e.valueOf()*1e3)}get isZero(){return this.valueOf()===0}};y(re,"BYTE",new re(1)),y(re,"KILOBYTE",re.kilobytes(1)),y(re,"MEGABYTE",re.megabytes(1)),y(re,"GIGABYTE",re.gigabytes(1)),y(re,"TERABYTE",re.terabytes(1)),y(re,"ZERO",new re(0)),y(re,"z",i.z.union([i.z.number().transform(s=>new re(s)),i.z.instanceof(re)]));let wt=re;i.z.union([i.z.instanceof(Uint8Array),i.z.instanceof(Uint16Array),i.z.instanceof(Uint32Array),i.z.instanceof(BigUint64Array),i.z.instanceof(Float32Array),i.z.instanceof(Float64Array),i.z.instanceof(Int8Array),i.z.instanceof(Int16Array),i.z.instanceof(Int32Array),i.z.instanceof(BigInt64Array)]);const Jo=s=>{const e=typeof s;return e==="string"||e==="number"||e==="boolean"||e==="bigint"||s instanceof x||s instanceof O||s instanceof Date},Ly=(s,e,t,n=0)=>s.usesBigInt&&!e.usesBigInt?Number(t)-Number(n):!s.usesBigInt&&e.usesBigInt?BigInt(t.valueOf())-BigInt(n.valueOf()):Gt(t,-n).valueOf(),Gt=(s,e)=>e==0?s:s==0?e:typeof s=="bigint"&&typeof e=="bigint"||typeof s=="number"&&typeof e=="number"?s+e:Number(s)+Number(e),Fy=s=>s==null?!1:Array.isArray(s)||s instanceof ArrayBuffer||ArrayBuffer.isView(s)&&!(s instanceof DataView)||s instanceof Je?!0:Jo(s),Le=-1,Sr={[Symbol.iterator]:()=>Sr,next:()=>({done:!0,value:void 0})},_y=i.z.string().transform(s=>new Uint8Array(atob(s).split("").map(e=>e.charCodeAt(0))).buffer),qy=i.z.union([i.z.null(),i.z.undefined()]).transform(()=>new Uint8Array().buffer),Tr=10,Xo=(s,e)=>{if(s==="string"&&!e.isVariable)throw new Error(`cannot convert series of type ${e.toString()} to string`);if(s==="number"&&!e.isNumeric)throw new Error(`cannot convert series of type ${e.toString()} to number`);if(s==="bigint"&&!e.usesBigInt)throw new Error(`cannot convert series of type ${e.toString()} to bigint`)},Jt=class Se{constructor(e){y(this,"key",""),y(this,"isSynnaxSeries",!0),y(this,"dataType"),y(this,"sampleOffset"),y(this,"gl"),y(this,"_data"),y(this,"timeRange",V.ZERO),y(this,"alignment",0n),y(this,"_cachedMin"),y(this,"_cachedMax"),y(this,"writePos",Le),y(this,"_refCount",0),y(this,"_cachedLength"),y(this,"_cachedIndexes"),Fy(e)&&(e={data:e});const{dataType:t,timeRange:n,sampleOffset:r=0,glBufferUsage:a="static",alignment:o=0n,key:c=Ho()}=e,h=e.data??[];if(h instanceof Se||typeof h=="object"&&"isSynnaxSeries"in h&&h.isSynnaxSeries===!0){const u=h;this.key=u.key,this.dataType=u.dataType,this.sampleOffset=u.sampleOffset,this.gl=u.gl,this._data=u._data,this.timeRange=u.timeRange,this.alignment=u.alignment,this._cachedMin=u._cachedMin,this._cachedMax=u._cachedMax,this.writePos=u.writePos,this._refCount=u._refCount,this._cachedLength=u._cachedLength;return}const d=Jo(h),f=Array.isArray(h);if(t!=null)this.dataType=new N(t);else{if(h instanceof ArrayBuffer)throw new Error("cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type.");if(f||d){let u=h;if(!d){if(h.length===0)throw new Error("cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type.");u=h[0]}if(typeof u=="string")this.dataType=N.STRING;else if(typeof u=="number")this.dataType=N.FLOAT64;else if(typeof u=="bigint")this.dataType=N.INT64;else if(typeof u=="boolean")this.dataType=N.BOOLEAN;else if(u instanceof x||u instanceof Date||u instanceof x)this.dataType=N.TIMESTAMP;else if(typeof u=="object")this.dataType=N.JSON;else throw new Error(`cannot infer data type of ${typeof u} when constructing a Series from a JS array`)}else this.dataType=new N(h)}if(!f&&!d)this._data=h;else{let u=d?[h]:h;const T=u[0];(T instanceof x||T instanceof Date||T instanceof O)&&(u=u.map(k=>new x(k).valueOf())),this.dataType.equals(N.STRING)?(this._cachedLength=u.length,this._data=new TextEncoder().encode(`${u.join(`
16
+ `)}
17
+ `).buffer):this.dataType.equals(N.JSON)?(this._cachedLength=u.length,this._data=new TextEncoder().encode(`${u.map(k=>is.encodeString(k)).join(`
18
+ `)}
19
+ `).buffer):this.dataType.usesBigInt&&typeof T=="number"?this._data=new this.dataType.Array(u.map(k=>BigInt(Math.round(k)))).buffer:!this.dataType.usesBigInt&&typeof T=="bigint"?this._data=new this.dataType.Array(u.map(k=>Number(k))).buffer:this._data=new this.dataType.Array(u).buffer}this.key=c,this.alignment=o,this.sampleOffset=r??0,this.timeRange=n??V.ZERO,this.gl={control:null,buffer:null,prevBuffer:0,bufferUsage:a}}static alloc({capacity:e,dataType:t,...n}){if(e===0)throw new Error("[Series] - cannot allocate an array of length 0");const r=new new N(t).Array(e),a=new Se({data:r.buffer,dataType:t,...n});return a.writePos=0,a}static createTimestamps(e,t,n){const r=n.spanRange(t.span(e)),a=new BigInt64Array(e);for(let o=0;o<e;o++)a[o]=BigInt(n.add(t.span(o)).valueOf());return new Se({data:a,dataType:N.TIMESTAMP,timeRange:r})}get refCount(){return this._refCount}static fromStrings(e,t){const n=new TextEncoder().encode(`${e.join(`
20
+ `)}
21
+ `);return new Se({data:n,dataType:N.STRING,timeRange:t})}static fromJSON(e,t){const n=new TextEncoder().encode(`${e.map(r=>is.encodeString(r)).join(`
22
+ `)}
23
+ `);return new Se({data:n,dataType:N.JSON,timeRange:t})}acquire(e){this._refCount++,e!=null&&this.updateGLBuffer(e)}release(){if(this._refCount<=0){console.warn("attempted to release a series with a negative reference count");return}this._refCount--,this._refCount===0&&this.gl.control!=null&&this.maybeGarbageCollectGLBuffer(this.gl.control)}write(e){if(!e.dataType.equals(this.dataType))throw new Error("buffer must be of the same type as this array");return this.dataType.isVariable?this.writeVariable(e):this.writeFixed(e)}writeVariable(e){if(this.writePos===Le)return 0;const t=this.byteCapacity.valueOf()-this.writePos,n=e.subBytes(0,t);return this.writeToUnderlyingData(n),this.writePos+=n.byteLength.valueOf(),this._cachedLength!=null&&(this._cachedLength+=n.length,this.calculateCachedLength()),n.length}writeFixed(e){if(this.writePos===Le)return 0;const t=this.capacity-this.writePos,n=e.sub(0,t);return this.writeToUnderlyingData(n),this._cachedLength=void 0,this.maybeRecomputeMinMax(n),this.writePos+=n.length,n.length}writeToUnderlyingData(e){this.underlyingData.set(e.data,this.writePos)}get buffer(){return typeof this._data=="object"&&"buffer"in this._data?this._data.buffer: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.matches(N.STRING,N.UUID))throw new Error("cannot convert non-string series to strings");return new TextDecoder().decode(this.underlyingData).split(`
24
+ `).slice(0,-1)}toUUIDs(){if(!this.dataType.equals(N.UUID))throw new Error("cannot convert non-uuid series to uuids");const e=N.UUID.density.valueOf(),t=Array(this.length);for(let n=0;n<this.length;n++){const r=this.underlyingData.slice(n*e,(n+1)*e),a=Array.from(new Uint8Array(r.buffer),o=>o.toString(16).padStart(2,"0")).join("").replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/,"$1-$2-$3-$4-$5");t[n]=a}return t}parseJSON(e){if(!this.dataType.equals(N.JSON))throw new Error("cannot parse non-JSON series as JSON");return new TextDecoder().decode(this.underlyingData).split(`
25
+ `).slice(0,-1).map(t=>e.parse(is.decodeString(t)))}get byteCapacity(){return new wt(this.underlyingData.byteLength)}get capacity(){return this.dataType.isVariable?this.byteCapacity.valueOf():this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===Le?this.byteCapacity:this.dataType.isVariable?new wt(this.writePos):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;const t=[0];return this.data.forEach((n,r)=>{n===Tr&&(e++,t.push(r+1))}),this._cachedIndexes=t,this._cachedLength=e,e}convert(e,t=0){if(this.dataType.equals(e))return this;const n=new e.Array(this.length);for(let r=0;r<this.length;r++)n[r]=Ly(this.dataType,e,this.data[r],t);return new Se({data:n.buffer,dataType:e,timeRange:this.timeRange,sampleOffset:t,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment})}calcRawMax(){if(this.length===0)return-1/0;if(this.dataType.equals(N.TIMESTAMP))this._cachedMax=this.data[this.data.length-1];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMax=e.reduce((t,n)=>t>n?t:n)}else{const e=this.data;this._cachedMax=e.reduce((t,n)=>t>n?t: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??(this._cachedMax=this.calcRawMax()),Gt(this._cachedMax,this.sampleOffset))}calcRawMin(){if(this.length===0)return 1/0;if(this.dataType.equals(N.TIMESTAMP))this._cachedMin=this.data[0];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMin=e.reduce((t,n)=>t<n?t:n)}else{const e=this.data;this._cachedMin=e.reduce((t,n)=>t<n?t: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??(this._cachedMin=this.calcRawMin()),Gt(this._cachedMin,this.sampleOffset))}get bounds(){return ee(Number(this.min),Number(this.max))}maybeRecomputeMinMax(e){if(this._cachedMin!=null){const t=e._cachedMin??e.calcRawMin();t<this._cachedMin&&(this._cachedMin=t)}if(this._cachedMax!=null){const t=e._cachedMax??e.calcRawMax();t>this._cachedMax&&(this._cachedMax=t)}}enrich(){this.max,this.min}get range(){return Gt(this.max,-this.min)}atAlignment(e,t){const n=Number(e-this.alignment);if(n<0||n>=this.length){if(t===!0)throw new Error(`[series] - no value at index ${n}`);return}return this.at(n,t)}at(e,t){if(this.dataType.isVariable)return this.atVariable(e,t??!1);e<0&&(e=this.length+e);const n=this.data[e];if(n==null){if(t===!0)throw new Error(`[series] - no value at index ${e}`);return}return Gt(n,this.sampleOffset)}atVariable(e,t){let n=0,r=0;if(this._cachedIndexes!=null)n=this._cachedIndexes[e],r=this._cachedIndexes[e+1]-1;else{e<0&&(e=this.length+e);for(let o=0;o<this.data.length;o++)if(this.data[o]===Tr){if(e===0){r=o;break}n=o+1,e--}if(r===0&&(r=this.data.length),n>=r||e>0){if(t)throw new Error(`[series] - no value at index ${e}`);return}}const a=this.data.slice(n,r);return this.dataType.equals(N.STRING)?new TextDecoder().decode(a):Qr(JSON.parse(new TextDecoder().decode(a)))}binarySearch(e){let t=0,n=this.length-1;const r=Kf(e);for(;t<=n;){const a=Math.floor((t+n)/2),o=r(this.at(a,!0),e);if(o===0)return a;o<0?t=a+1:n=a-1}return t}updateGLBuffer(e){if(this.gl.control=e,!this.dataType.equals(N.FLOAT32)&&!this.dataType.equals(N.UINT8))throw new Error("Only FLOAT32 and UINT8 arrays can be used in WebGL");const{buffer:t,bufferUsage:n,prevBuffer:r}=this.gl;if(t==null&&(this.gl.buffer=e.createBuffer()),this.writePos!==r)if(e.bindBuffer(e.ARRAY_BUFFER,this.gl.buffer),this.writePos!==Le){r===0&&e.bufferData(e.ARRAY_BUFFER,this.byteCapacity.valueOf(),e.STATIC_DRAW);const a=this.dataType.density.size(r).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){return Xo(e,this.dataType),this}get digest(){var e;return{key:this.key,dataType:this.dataType.toString(),sampleOffset:this.sampleOffset,alignment:{lower:wa(this.alignmentBounds.lower),upper:wa(this.alignmentBounds.upper)},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 ee(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 Wy(this);return this.dataType.equals(N.JSON)?new Vy(e):e}return new Yy(this)}slice(e,t){return this.sliceSub(!1,e,t)}sub(e,t){return this.sliceSub(!0,e,t)}subIterator(e,t){return new ua(this,e,t??this.length)}subAlignmentIterator(e,t){return new ua(this,Number(e-this.alignment),Number(t-this.alignment))}subBytes(e,t){if(e>=0&&(t==null||t>=this.byteLength.valueOf()))return this;const n=this.data.subarray(e,t);return new Se({data:n,dataType:this.dataType,timeRange:this.timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(e)})}sliceSub(e,t,n){if(t<=0&&(n==null||n>=this.length))return this;let r;return e?r=this.data.subarray(t,n):r=this.data.slice(t,n),new Se({data:r,dataType:this.dataType,timeRange:this.timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(t)})}reAlign(e){return new Se({data:this.buffer,dataType:this.dataType,timeRange:V.ZERO,sampleOffset:this.sampleOffset,glBufferUsage:"static",alignment:e})}toString(){var e,t;let n=`${this.dataType.toString()} ${this.length} [`;if(this.length<=10)n+=Array.from(this).map(r=>r.toString());else{for(let r=0;r<5;r++)n+=`${(e=this.at(r))==null?void 0:e.toString()}`,r<4&&(n+=",");n+="...";for(let r=-5;r<0;r++)n+=(t=this.at(r))==null?void 0:t.toString(),r<-1&&(n+=",")}return n+="]",n}};y(Jt,"crudeZ",i.z.object({timeRange:V.z.optional(),dataType:N.z,alignment:i.z.coerce.bigint().optional(),data:i.z.union([_y,qy,i.z.instanceof(ArrayBuffer),i.z.instanceof(Uint8Array)]),glBufferUsage:Dy.optional().default("static").optional()})),y(Jt,"z",Jt.crudeZ.transform(s=>new Jt(s)));let Je=Jt,ua=class{constructor(s,e,t){y(this,"series"),y(this,"end"),y(this,"index"),this.series=s;const n=ee(0,s.length);this.end=ia(n,t),this.index=ia(n,e)}next(){return this.index>=this.end?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}[Symbol.iterator](){return this}},Wy=class{constructor(s){if(y(this,"series"),y(this,"index"),y(this,"decoder"),!s.dataType.isVariable)throw new Error("cannot create a variable series iterator for a non-variable series");this.series=s,this.index=0,this.decoder=new TextDecoder}next(){const s=this.index,e=this.series.data;for(;this.index<e.length&&e[this.index]!==Tr;)this.index++;const t=this.index;return s===t?{done:!0,value:void 0}:(this.index++,{done:!1,value:this.decoder.decode(this.series.buffer.slice(s,t))})}[Symbol.iterator](){return this}};var da,fa;const Qo=class ec{constructor(e){y(this,"wrapped"),y(this,da,"JSONSeriesIterator"),this.wrapped=e}next(){const e=this.wrapped.next();return e.done===!0?{done:!0,value:void 0}:{done:!1,value:is.decodeString(e.value,ec.SCHEMA)}}[(fa=Symbol.iterator,da=Symbol.toStringTag,fa)](){return this}};y(Qo,"SCHEMA",i.z.record(i.z.string(),i.z.unknown()));let Vy=Qo;var ya,pa;class Yy{constructor(e){y(this,"series"),y(this,"index"),y(this,ya,"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)}}[(pa=Symbol.iterator,ya=Symbol.toStringTag,pa)](){return this}}let Zy=class{constructor(s=[]){if(y(this,"series"),s.length!==0){const e=s[0].dataType;for(let t=1;t<s.length;t++)if(!s[t].dataType.equals(e))throw new Error("[multi-series] - series must have the same data type")}this.series=s}as(s){return Xo(s,this.dataType),this}get dataType(){return this.series.length===0?N.UNKNOWN:this.series[0].dataType}get timeRange(){return this.series.length===0?V.ZERO:new V(this.series[0].timeRange.start,this.series[this.series.length-1].timeRange.end)}get alignment(){return this.series.length===0?0n:this.series[0].alignment}get alignmentBounds(){return this.series.length===0?ee(0n,0n):ee(this.series[0].alignmentBounds.lower,this.series[this.series.length-1].alignmentBounds.upper)}push(s){"isSynnaxSeries"in s&&s.isSynnaxSeries?this.series.push(s):this.series.push(...s.series)}get length(){return this.series.reduce((s,e)=>s+e.length,0)}atAlignment(s,e){if(this.series.length===0){if(e)throw new Error(`[series] - no value at alignment ${s}`);return}for(const t of this.series)if(Bs(t.alignmentBounds,s))return t.atAlignment(s,e);if(e)throw new Error(`[series] - no value at alignment ${s}`)}at(s,e=!1){s<0&&(s=this.length+s);for(const t of this.series){if(s<t.length)return t.at(s,e);s-=t.length}if(e)throw new Error(`[series] - no value at index ${s}`)}subIterator(s,e){return new Pn(this,s,e??this.length)}subAlignmentIterator(s,e){if(s>=this.alignmentBounds.upper||e<=this.alignmentBounds.lower)return Sr;let t=0;for(let r=0;r<this.series.length;r++){const a=this.series[r];if(s<a.alignment)break;if(s>=a.alignmentBounds.upper)t+=a.length;else if(Bs(a.alignmentBounds,s)){t+=Number(s-a.alignment);break}}let n=0;for(let r=0;r<this.series.length;r++){const a=this.series[r];if(e<a.alignment)break;if(e>=a.alignmentBounds.upper)n+=a.length;else if(Bs(a.alignmentBounds,e)){n+=Number(e-a.alignment);break}}return new Pn(this,t,n)}subAlignmentSpanIterator(s,e){if(s>=this.alignmentBounds.upper)return Sr;let t=0;for(let n=0;n<this.series.length;n++){const r=this.series[n];if(s<r.alignment)break;if(s>=r.alignmentBounds.upper)t+=r.length;else if(Bs(r.alignmentBounds,s)){t+=Number(s-r.alignment);break}}return new Pn(this,t,t+e)}updateGLBuffer(s){this.series.forEach(e=>e.updateGLBuffer(s))}get bounds(){return yy(this.series.map(s=>s.bounds))}get byteLength(){return new wt(this.series.reduce((s,e)=>s+e.byteLength.valueOf(),0))}get data(){const s=new this.dataType.Array(this.length);let e=0;for(const t of this.series)s.set(t.data,e),e+=t.length;return new this.dataType.Array(s.buffer)}traverseAlignment(s,e){const t=this.series.map(n=>n.alignmentBounds);return py(t,s,e)}acquire(){this.series.forEach(s=>s.acquire())}release(){this.series.forEach(s=>s.release())}distance(s,e){const t=this.series.map(n=>n.alignmentBounds);return gy(t,s,e)}parseJSON(s){if(!this.dataType.equals(N.JSON))throw new Error("cannot parse non-JSON series as JSON");return this.series.flatMap(e=>e.parseJSON(s))}[Symbol.iterator](){return this.series.length===0?{next(){return{done:!0,value:void 0}}}:new Ky(this.series)}};var ga,ma;class Ky{constructor(e){y(this,"series"),y(this,"seriesIndex"),y(this,"internal"),y(this,ga,"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())}[(ma=Symbol.iterator,ga=Symbol.toStringTag,ma)](){return this}}let Pn=class{constructor(s,e,t){y(this,"series"),y(this,"index"),y(this,"end"),this.series=s,this.end=t,this.index=e}next(){return this.index>=this.end?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}[Symbol.iterator](){return this}};const wa=s=>{const e=s>>32n,t=s&0xffffffffn;return{domain:e,sample:t}},Hy=(s,e)=>{let t=null;return e===0?s:(...n)=>{t!==null&&(clearTimeout(t),t=null),t=setTimeout(()=>s(...n),e)}},Gy=(s,e,t=".")=>{const n=s.split(t);return n.map((r,a)=>{const o=e(r,a,n);return o==null?null:typeof o=="string"?o:o.join(t)}).filter(r=>r!=null).join(t)},Jy=(s,e,t={optional:!1,separator:"."})=>{t.separator??(t.separator=".");const{optional:n,getter:r=(c,h)=>c[h]}=t,a=e.split(t.separator);if(a.length===1&&a[0]==="")return s;let o=s;for(const c of a){const h=r(o,c);if(h==null){if(n)return null;throw new Error(`Path ${e} does not exist. ${c} is null`)}o=h}return o};i.z.object({key:i.z.string(),value:i.z.string()});var Xy=Object.defineProperty,Qy=(s,e,t)=>e in s?Xy(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,qs=(s,e,t)=>Qy(s,typeof e!="symbol"?e+"":e,t);let ep=class{constructor(s,e){qs(this,"handlers"),qs(this,"transform"),qs(this,"closer"),this.transform=s,this.handlers=e??new Map}onChange(s){return this.handlers.set(s,null),()=>this.handlers.delete(s)}notify(s){let e=s;if(this.transform!=null){const[t,n]=this.transform(s);if(!n)return;e=t}this.handlers.forEach((t,n)=>n(e))}setCloser(s){this.closer=s}async close(){var s;return await((s=this.closer)==null?void 0:s.call(this))}},tp=class{constructor(s){qs(this,"handlers"),this.handlers=s??new Map}onChange(s){return this.handlers.set(s,null),()=>this.handlers.delete(s)}notify(s){this.handlers.forEach((e,t)=>t(s))}};const tt=Object.freeze(Object.defineProperty({__proto__:null,BaseObserver:tp,Observer:ep},Symbol.toStringTag,{value:"Module"})),pe=i.z.record(i.z.union([i.z.number(),i.z.string(),i.z.symbol()]),i.z.unknown()),sp=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser";sp();const np=["macOS","Windows","Linux"],rp=["macos","windows","linux"],ip={macos:"macOS",windows:"Windows",linux:"Linux"};i.z.enum(np).or(i.z.enum(rp).transform(s=>ip[s]));var ap=Object.defineProperty,op=(s,e,t)=>e in s?ap(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Xt=(s,e,t)=>op(s,typeof e!="symbol"?e+"":e,t);const cp=(...s)=>s.map(tc).join(""),tc=s=>(s.endsWith("/")||(s+="/"),s.startsWith("/")&&(s=s.slice(1)),s),lp=s=>s.endsWith("/")?s.slice(0,-1):s,Or=class kr{constructor({host:e,port:t,protocol:n="",pathPrefix:r=""}){Xt(this,"protocol"),Xt(this,"host"),Xt(this,"port"),Xt(this,"path"),this.protocol=n,this.host=e,this.port=t,this.path=tc(r)}replace(e){return new kr({host:e.host??this.host,port:e.port??this.port,protocol:e.protocol??this.protocol,pathPrefix:e.pathPrefix??this.path})}child(e){return new kr({...this,pathPrefix:cp(this.path,e)})}toString(){return lp(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}};Xt(Or,"UNKNOWN",new Or({host:"unknown",port:0}));let hp=Or;const up=-128,dp=127,fp=i.z.number().int().min(up).max(dp),yp=-32768,pp=32767,gp=i.z.number().int().min(yp).max(pp),mp=-2147483648,wp=2147483647,bp=i.z.number().int().min(mp).max(wp),vp=-9223372036854775808n,zp=9223372036854775807n,Sp=i.z.bigint().min(vp).max(zp),Tp=255,Op=i.z.number().int().min(0).max(Tp),kp=65535,xp=i.z.number().int().min(0).max(kp),Ip=4294967295,Ep=i.z.number().int().min(0).max(Ip),Np=18446744073709551615n,Ap=i.z.bigint().min(0n).max(Np),sc=s=>Gy(s,(e,t,n)=>{const r=t===n.length-1,a=!isNaN(parseInt(e)),o=!isNaN(parseInt(n[t+1]));return a&&(e="element"),r||o?e:[e,"shape"]}),ba=(s,e)=>{if(s==null)return null;const t=s[e];return t==null&&typeof s=="object"&&"sourceType"in s?s.sourceType()[e]:t},Up=(s,e,t)=>Jy(ba(s,"shape"),sc(e),{...t,getter:ba}),Cp=Object.freeze(Object.defineProperty({__proto__:null,getFieldSchema:Up,getFieldSchemaPath:sc,int16:gp,int32:bp,int64:Sp,int8:fp,uint16:xp,uint32:Ep,uint64:Ap,uint8:Op},Symbol.toStringTag,{value:"Module"}));var Bp=Object.defineProperty,jp=(s,e,t)=>e in s?Bp(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,xe=(s,e,t)=>jp(s,typeof e!="symbol"?e+"":e,t);const Rp=async s=>await new Promise(e=>setTimeout(e,O.fromMilliseconds(s).milliseconds));class Mp{constructor(e){xe(this,"config"),xe(this,"retries"),xe(this,"interval"),this.config={baseInterval:new O((e==null?void 0:e.baseInterval)??O.seconds(1)),maxRetries:(e==null?void 0:e.maxRetries)??5,scale:(e==null?void 0:e.scale)??1,sleepFn:(e==null?void 0:e.sleepFn)??Rp},this.retries=0,this.interval=new O(this.config.baseInterval)}async wait(){const{maxRetries:e,scale:t,sleepFn:n}=this.config;return this.retries>=e?!1:(await n(this.interval),this.interval=this.interval.mult(t),this.retries++,!0)}reset(){this.retries=0,this.interval=this.config.baseInterval}}const Pp=i.z.object({baseInterval:O.z.optional(),maxRetries:i.z.number().optional(),scale:i.z.number().optional()}),nc=Object.freeze(Object.defineProperty({__proto__:null,Breaker:Mp,breakerConfig:Pp},Symbol.toStringTag,{value:"Module"})),Dp=/^#?([0-9a-f]{6}|[0-9a-f]{8})$/i,si=i.z.string().regex(Dp),gt=i.z.number().min(0).max(255),$p=i.z.number().min(0).max(1),rc=i.z.tuple([gt,gt,gt,$p]),ic=i.z.tuple([gt,gt,gt]),ni=(s,e=1)=>{if(typeof s=="string")return Fp(s,e);if(Array.isArray(s)){if(s.length<3||s.length>4)throw new Error(`Invalid color: [${s.join(", ")}]`);return s.length===3?[...s,e]:s}throw new Error(`Invalid color: ${JSON.stringify(s)}`)},Lp=i.z.union([si,rc,ic]).transform(s=>ni(s)),Fp=(s,e=1)=>{if(!si.safeParse(s).success)throw new Error(`Invalid hex color: ${s}`);return s=_p(s),[Rs(s,0),Rs(s,2),Rs(s,4),s.length===8?Rs(s,6)/255:e]},Rs=(s,e)=>parseInt(s.slice(e,e+2),16),_p=s=>s.startsWith("#")?s.slice(1):s,qp=i.z.union([si,rc,i.z.string(),ic]);ni("#000000");ni("#ffffff");const Wp=i.z.object({key:i.z.string(),color:qp,position:i.z.number(),switched:i.z.boolean().optional()});i.z.array(Wp);const Vp=i.z.object({key:i.z.string(),name:i.z.string(),color:Lp});i.z.object({key:i.z.string(),name:i.z.string(),swatches:i.z.array(Vp)});const ac=i.z.number().int().min(0).max(255),oc=255,cc=0,Yp={lower:cc,upper:oc+1},lc=i.z.object({name:i.z.string(),key:i.z.string()}),hs=s=>i.z.object({subject:lc,resource:s,authority:ac}),Zp=(...s)=>e=>e.filter(t=>{let n=!1;return t.to!=null&&(n=s.includes(t.to.resource)),t.from!=null&&!n&&(n=s.includes(t.from.resource)),n}),hc=i.z.object({from:hs(i.z.any()),to:i.z.null()}),uc=i.z.object({from:i.z.null(),to:hs(i.z.any())}),Kp=i.z.union([hc,uc,i.z.object({from:hs(i.z.any()),to:hs(i.z.any())})]),st=Object.freeze(Object.defineProperty({__proto__:null,ABSOLUTE_AUTHORITY:oc,AUTHORITY_BOUNDS:Yp,ZERO_AUTHORITY:cc,acquireZ:uc,authorityZ:ac,filterTransfersByChannelKey:Zp,releaseZ:hc,stateZ:hs,subjectZ:lc,transferZ:Kp},Symbol.toStringTag,{value:"Module"})),Hp=s=>Object.getOwnPropertySymbols(globalThis).includes(s),Gp=(s,e)=>{const t=Symbol.for(s);if(!Hp(t)){const n=e();Object.defineProperty(globalThis,t,{value:n})}return()=>globalThis[t]},Jp=s=>e=>e!=null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"?e.type.startsWith(s):e instanceof Error?e.message.startsWith(s):typeof e!="string"?!1:e.startsWith(s),cn=s=>{var e;return e=class extends Error{constructor(t,n){super(t,n),xe(this,"discriminator",e.discriminator),xe(this,"type",e.TYPE),xe(this,"matches",e.matches),this.name=e.TYPE}static sub(t){return cn(`${s}.${t}`)}},xe(e,"discriminator","FreighterError"),xe(e,"TYPE",s),xe(e,"matches",Jp(s)),e},dc=s=>{if(s==null||typeof s!="object")return!1;const e=s;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},ht="unknown",xr="nil";class Xp{constructor(){xe(this,"providers",[])}register(e){this.providers.push(e)}encode(e){if(e==null)return{type:xr,data:""};if(dc(e))for(const t of this.providers){const n=t.encode(e);if(n!=null)return n}if(e instanceof Error)return{type:ht,data:e.message};if(typeof e=="string")return{type:ht,data:e};try{return{type:ht,data:JSON.stringify(e)}}catch{return{type:ht,data:"unable to encode error information"}}}decode(e){if(e==null||e.type===xr)return null;if(e.type===ht)return new Ir(e.data);for(const t of this.providers){const n=t.decode(e);if(n!=null)return n}return new Ir(e.data)}}const ri=Gp("synnax-error-registry",()=>new Xp),Qp=({encode:s,decode:e})=>ri().register({encode:s,decode:e}),eg=s=>ri().encode(s),tg=s=>s==null?null:ri().decode(s);class Ir extends cn("unknown"){}const sg=i.z.object({type:i.z.string(),data:i.z.string()});class ng extends cn("canceled"){}const bt=Object.freeze(Object.defineProperty({__proto__:null,Canceled:ng,NONE:xr,UNKNOWN:ht,Unknown:Ir,createTyped:cn,decode:tg,encode:eg,isTyped:dc,payloadZ:sg,register:Qp},Symbol.toStringTag,{value:"Module"}));i.object({jsonrpc:i.string(),id:i.number().optional(),method:i.string().optional(),params:i.unknown().optional(),result:i.unknown().optional()});const Er=i.z.string().regex(/^\d+\.\d+\.\d+$/),ws=(s,e,t={})=>{t.checkMajor??(t.checkMajor=!0),t.checkMinor??(t.checkMinor=!0),t.checkPatch??(t.checkPatch=!0);const n=Er.parse(s),r=Er.parse(e),[a,o,c]=n.split(".").map(Number),[h,d,f]=r.split(".").map(Number);if(t.checkMajor){if(a<h)return Cn;if(a>h)return Bn}if(t.checkMinor){if(o<d)return Cn;if(o>d)return Bn}if(t.checkPatch){if(c<f)return Cn;if(c>f)return Bn}return an},rg=(s,e,t={})=>Xf(ws(s,e,t)),fc=(s,e,t={})=>Jf(ws(s,e,t)),ig=(s,e,t={})=>Gf(ws(s,e,t)),ag=({name:s,migrate:e})=>t=>{try{const n=e(t);return console.log(`${s} migrated: ${t.version} -> ${n.version}`),n}catch(n){throw console.log(`${s} failed to migrate from ${t.version}`),console.error(n),n}},og=({name:s,migrations:e,targetSchema:t,defaultVersion:n,def:r})=>{const a=Object.keys(e).sort(ws).pop();if(a==null)return d=>{if(d.version??(d.version=n),d.version!==r.version)return console.log(`${s} version ${d.version} is newer than latest version of ${r.version}.
26
+ Returning default instead.
27
+ `),r;try{return t!=null?t.parse(d):d}catch(f){return console.log(`${s} failed to parse default. Exiting with default`),console.error(f),r}};const o=Object.keys(e).length;let c=!1;const h=d=>{try{if(o===0||fc(d.version,a))return console.log(c?`${s} ${d.version} now up to date`:`${s} version ${d.version} is up to date with target version ${r.version}`),d;const f=d.version,u=e[f],T=u(d);return c=!0,h(T)}catch(f){return console.log(`${s} failed to migrate from ${d.version} to ${a}`),console.error(f),r}};return d=>{try{if(d.version==null)if(n!=null)console.log(`${s} version is null. Setting version to default of ${n}`),d.version=n;else return console.log(`${s} version is null and no default version set. Exiting with default`),r;return h(d)}catch(f){return console.log(`${s} failed to parse final result. Exiting with default`),console.error(f),r}}},va=Object.freeze(Object.defineProperty({__proto__:null,compareSemVer:ws,createMigration:ag,migrator:og,semVerNewer:fc,semVerOlder:ig,semVerZ:Er,versionsEqual:rg},Symbol.toStringTag,{value:"Module"})),cg=["standard","scientific","engineering"];i.z.enum(cg);const lg=(s,e="")=>{const t=s.length;return t===0?e:t===1?s[0]:t===2?`${s[0]} and ${s[1]}`:`${s.slice(0,-1).join(", ")}, and ${s[t-1]}`},hg=s=>{const e=s.split(" "),t=new Set,n=e.map(o=>o.charAt(0).toLowerCase()).join("");t.add(n.replace(/-/g,"_")),t.add(n.replace(/(.)(.)/g,"$1_$2").replace(/-/g,"_"));const r=/\d+/g;s.match(r)&&e.forEach((o,c)=>{if(r.test(o)){const h=e.map((d,f)=>f!==c?d.charAt(0).toLowerCase():d).join("");t.add(h.replace(/-/g,"_")),t.add(h.replace(/(.)(.)/g,"$1_$2").replace(/-/g,"_"))}});const a=e.map(o=>(o.length>3?o.substring(0,3):o).toLowerCase());return t.add(a.join("").replace(/-/g,"_")),t.add(a.join("_").replace(/-/g,"_")),Array.from(t).filter(o=>o.length>=2&&o.length<=12&&!/^\d/.test(o))},ug=Object.freeze(Object.defineProperty({__proto__:null,createShortIdentifiers:hg,naturalLanguageJoin:lg},Symbol.toStringTag,{value:"Module"}));class Pe extends bt.createTyped("sy"){}let W=class extends Pe.sub("validation"){};class za extends W.sub("field"){constructor(e,t){super(`${e}: ${t}`),l(this,"field"),l(this,"message"),this.field=e,this.message=t}}class Xs extends Pe.sub("auth"){}class Nr extends Xs.sub("invalid-token"){}class Ar extends Xs.sub("expired-token"){}class ue extends Pe.sub("unexpected"){constructor(e){super(`
28
+ Unexpected error encountered:
29
+
30
+ ${e}
31
+
32
+ Please report this to the Synnax team.
33
+ `)}}class Re extends Pe.sub("query"){}class nt extends Re.sub("not_found"){}class vt extends Re.sub("multiple_results"){}class Sa extends Pe.sub("route"){constructor(e,t){super(e),l(this,"path"),this.path=t}}class Ur extends Pe.sub("control"){}class Ta extends Ur.sub("unauthorized"){}class C0 extends Pe.sub("contiguity"){}const dg=s=>{if(!s.type.startsWith(Pe.TYPE))return null;if(s.type.startsWith(W.TYPE)){if(s.type===za.TYPE){const e=s.data.split(": ");return e.length<2?new W(s.data):new za(e[0],e[1])}return new W(s.data)}return s.type.startsWith(Xs.TYPE)?s.type.startsWith(Nr.TYPE)?new Nr(s.data):s.type.startsWith(Ar.TYPE)?new Ar(s.data):new Xs(s.data):s.type.startsWith(ue.TYPE)?new ue(s.data):s.type.startsWith(Re.TYPE)?s.type.startsWith(nt.TYPE)?new nt(s.data):s.type.startsWith(vt.TYPE)?new vt(s.data):new Re(s.data):s.type.startsWith(Ur.TYPE)?s.type.startsWith(Ta.TYPE)?new Ta(s.data):new Ur(s.data):s.type.startsWith(Sa.TYPE)?new Sa(s.data,s.data):new ue(s.data)},fg=()=>{throw new Error("Not implemented")};bt.register({encode:fg,decode:dg});const yg=async(s,e)=>{const[t,n]=await e(s);return n==null?[t,n]:n instanceof Ge?[t,new Ge({message:`Cannot reach cluster at ${n.url.host}:${n.url.port}`,url:n.url})]:[t,n]},ln=i.z.string().uuid(),ii=i.z.string(),yc=i.z.object({key:ln,name:ii}),pc="group",te=s=>i.z.union([i.z.union([i.z.null(),i.z.undefined()]).transform(()=>[]),s.array()]),se=i.z.number(),bs=i.z.string(),vs=i.z.object({name:bs,key:se,dataType:N.z,leaseholder:i.z.number(),index:se,isIndex:i.z.boolean(),internal:i.z.boolean(),virtual:i.z.boolean(),alias:i.z.string().optional(),expression:i.z.string().default(""),requires:te(se)}),gc=vs.extend({key:se.optional(),leaseholder:i.z.number().optional(),index:se.optional(),isIndex:i.z.boolean().optional(),internal:i.z.boolean().optional().default(!1),virtual:i.z.boolean().optional().default(!1),expression:i.z.string().optional().default(""),requires:te(se).optional().default([])}),hn="channel",ai="framer",Oa=s=>{const e=b(s);return e.length===0?null:typeof e[0]=="number"||!isNaN(parseInt(e[0]))?"key":"name"},ka=(s,e)=>{const t=b(s);if(t.length===e.length)return;const n=Oa(s);throw Oa===null?new W("[Frame] - channel keys or names must be provided when constructing a frame."):new W(`[Frame] - ${n}s and series must be the same length.
34
+ Got ${t.length} ${n}s and ${e.length} series.`)};class J{constructor(e=[],t=[]){if(l(this,"columns",[]),l(this,"series",[]),e instanceof J){this.columns=e.columns,this.series=e.series;return}if(e instanceof Map){e.forEach((n,r)=>this.push(r,...b(n)));return}if(typeof e=="object"&&!Array.isArray(e)){if("keys"in e&&"series"in e){const n=e;n.series??(n.series=[]),n.keys??(n.keys=[]);const r=n.series.map(a=>mc(a));ka(n.keys,r),n.keys.forEach((a,o)=>this.push(a,r[o]))}else Object.entries(e).forEach(([n,r])=>{const a=parseInt(n);if(!isNaN(a))return this.push(a,...b(r));this.push(n,...b(r))});return}if(Array.isArray(e)||["string","number"].includes(typeof e)){const n=b(t),r=b(e);ka(r,n),n.forEach((a,o)=>this.push(r[o],a));return}throw new W(`[Frame] - invalid frame construction parameters. data parameter ust be a frame
35
+ payload, a list of lazy series, 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 ue("colType is not key");return this.columns??[]}get uniqueKeys(){return ta.unique(this.keys)}get names(){if(this.colType==="key")throw new ue("colType is not name");return this.columns??[]}get uniqueNames(){return ta.unique(this.names)}get uniqueColumns(){return this.colType==="key"?this.uniqueKeys:this.uniqueNames}toPayload(){return{series:this.series.map(e=>wc(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(t=>t.equals(e[0]))}timeRange(e){if(e==null){if(this.columns.length===0)return V.ZERO;const n=x.min(...this.series.map(a=>a.timeRange.start)),r=x.max(...this.series.map(a=>a.timeRange.end));return new V(n,r)}const t=this.get(e);return t==null?V.ZERO:t.timeRange}latest(){return this.at(-1)}get timeRanges(){return this.uniqueColumns.map(e=>this.timeRange(e))}get(e){return Array.isArray(e)?this.filter(t=>e.includes(t)):new Zy(this.series.filter((t,n)=>this.columns[n]===e))}push(e,...t){if(e instanceof J){if(this.colType!==null&&e.colType!==this.colType)throw new W("keyVariant must match");this.series.push(...e.series),this.columns.push(...e.columns)}else{if(this.series.push(...t),typeof e=="string"&&this.colType==="key")throw new W("keyVariant must match");if(typeof e!="string"&&this.colType==="name")throw new W("keyVariant must match");this.columns.push(...Array.from({length:t.length},()=>e))}}concat(e){return new J([...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 t=new J;return this.forEach((n,r,a)=>t.push(...e(n,r,a))),t}forEach(e){this.columns.forEach((t,n)=>{const r=this.series[n];e(t,r,n)})}at(e,t=!1){const n={};return this.uniqueColumns.forEach(r=>{n[r]=this.get(r).at(e,t)}),n}filter(e){const t=new J;return this.columns.forEach((n,r)=>{const a=this.series[r];e(n,a,r)&&t.push(n,a)}),t}get byteLength(){return new wt(this.series.reduce((e,t)=>e.add(t.byteLength),wt.ZERO))}get digest(){const e={};return this.keys.forEach((t,n)=>{const r=this.series[n].digest;t in e?e[t].push(r):e[t]=[r]}),e}get length(){return this.series.reduce((e,t)=>e+t.length,0)}toString(){let e=`Frame{
37
+ `;return this.uniqueColumns.forEach(t=>{e+=` ${t}: ${this.get(t).series.map(n=>n.toString()).join(",")}
38
+ `}),e+="}",e}}const un=i.z.object({keys:i.z.union([i.z.null().transform(()=>[]),i.z.number().array().optional().default([])]),series:i.z.union([i.z.null().transform(()=>[]),Je.crudeZ.array().optional().default([])])}),mc=s=>{const{dataType:e,data:t,timeRange:n,alignment:r}=s;return new Je({data:t,dataType:e,timeRange:n,glBufferUsage:"static",alignment:r})},wc=s=>({timeRange:s.timeRange,dataType:s.dataType,data:new Uint8Array(s.data.buffer),alignment:s.alignment}),it=Cp.uint32,bc=i.z.object({key:it,variant:i.z.string(),message:i.z.string(),lastReceived:x.z.optional()}),oi=i.z.object({key:it,name:i.z.string(),state:bc.optional()}),pg=oi.partial({key:!0}),vc="rack",ci=s=>s?rt.JSON_CODEC.decodeString(s,pe):{},dn=i.z.string(),zc=i.z.object({key:dn,variant:i.z.string(),details:pe.or(i.z.string().transform(ci))}),fn=i.z.object({key:dn,rack:it,name:i.z.string(),make:i.z.string(),model:i.z.string(),location:i.z.string(),configured:i.z.boolean().optional(),properties:pe.or(i.z.string().transform(ci)),state:zc.optional()}),gg=fn.extend({properties:i.z.unknown().transform(s=>rt.JSON_CODEC.encodeString(s))}),Sc="device",Ee=s=>s?JSON.parse(s):{},at=i.z.union([i.z.string(),i.z.bigint().transform(s=>s.toString()),i.z.number().transform(s=>s.toString())]),mg=i.z.enum(["info","success","error","warning"]),Qs=i.z.object({task:at,variant:mg,key:i.z.string().optional(),details:pe.or(i.z.string().transform(Ee)).or(i.z.array(i.z.unknown())).or(i.z.null())}),yn=i.z.object({key:at,name:i.z.string(),type:i.z.string(),internal:i.z.boolean().optional(),config:pe.or(i.z.string().transform(ci)),state:Qs.optional().nullable(),snapshot:i.z.boolean().optional()}),wg=yn.omit({key:!0}).extend({key:at.transform(s=>s.toString()).optional(),config:i.z.unknown().transform(s=>rt.JSON_CODEC.encodeString(s))}),Tc=i.z.object({task:at,type:i.z.string(),key:i.z.string(),args:pe.or(i.z.string().transform(Ee)).or(i.z.array(i.z.unknown())).or(i.z.null()).optional()}),li="task",Ot=i.z.string().uuid(),pn=i.z.object({key:Ot,name:i.z.string().min(1),color:i.z.string()}),Oc="label",oe=i.z.string().uuid(),hi=i.z.string().min(1),zs=i.z.object({key:oe,name:hi,timeRange:V.z,color:i.z.string().optional()}),kc=zs.partial({key:!0}),xc=s=>{const e=b(s),t=e.length===0;let n=!1;return t||(n=oe.safeParse(e[0]).success),{single:!Array.isArray(s),variant:n?"keys":"names",normalized:e,actual:s,empty:t}},ui="range",di="range-alias",kt=i.z.string().uuid(),gn=i.z.object({key:kt,username:i.z.string().min(1),firstName:i.z.string().default(""),lastName:i.z.string().default(""),rootUser:i.z.boolean().default(!0)}),bg=gn.partial({key:!0,firstName:!0,lastName:!0}).omit({rootUser:!0}).extend({password:i.z.string().min(1)}),vg="user",Ss=i.z.string().uuid(),fi=i.z.object({key:Ss,name:i.z.string(),data:pe.or(i.z.string().transform(Ee))}),zg=fi.partial({key:!0}).transform(s=>({...s,data:JSON.stringify(s.data)})),Sg="lineplot",Ts=i.z.string().uuid(),yi=i.z.object({key:Ts,name:i.z.string(),data:pe.or(i.z.string().transform(Ee))}),Tg=yi.partial({key:!0}).transform(s=>({...s,data:JSON.stringify(s.data)})),Og="log",De=i.z.string().uuid(),pi=i.z.object({key:De,name:i.z.string(),layout:pe.or(i.z.string().transform(Ee))}),Ic="workspace",kg=pi.partial({key:!0}).transform(s=>({...s,layout:JSON.stringify(s.layout)})),xg=pi.omit({layout:!0}).extend({layout:i.z.string().transform(Ee)}),xt=i.z.string().uuid(),gi=i.z.object({key:xt,name:i.z.string(),data:pe.or(i.z.string().transform(Ee)),snapshot:i.z.boolean()}),Ig=gi.partial({key:!0,snapshot:!0}).transform(s=>({...s,data:JSON.stringify(s.data)})),Ec=gi.extend({data:i.z.string().transform(Ee)}),Eg="schematic",Os=i.z.string().uuid(),Nc=i.z.object({key:Os,name:i.z.string(),data:pe.or(i.z.string().transform(Ee))}),Ng=Nc.partial({key:!0}).transform(s=>({...s,data:JSON.stringify(s.data)})),Ac=Nc.extend({data:i.z.string().transform(Ee)}),Ag="table",Uc="builtin",Ug="cluster",Cg="node",mn=i.z.enum([Oc,Og,Ja,Uc,Ug,hn,Cg,pc,ui,ai,di,vg,Ic,Eg,Sg,vc,Sc,li,sh,Ag]),ce=i.z.object({type:mn,key:i.z.string()}),Bg=i.z.string().transform(s=>{const[e,t]=s.split(":");return{type:mn.parse(e),key:t??""}}),Qt=i.z.union([Bg,ce]),Ws=class Cc{constructor(e){if(l(this,"type"),l(this,"key"),e instanceof Cc){this.type=e.type,this.key=e.key;return}if(typeof e=="string"){const[t,n]=e.split(":");this.type=t,this.key=n??"";return}this.type=e.type,this.key=e.key}toString(){return`${this.type}:${this.key}`}isType(){return this.key===""}matchesType(e){return this.type===e&&this.isType()}get payload(){return{type:this.type,key:this.key}}};l(Ws,"z",i.z.union([i.z.instanceof(Ws),Qt.transform(s=>new Ws(s))]));let A=Ws;new A({type:Uc,key:"root"});const jg=i.z.object({type:i.z.number()}),Rg=i.z.object({type:mn,fields:i.z.record(i.z.string(),jg)}),Mg=i.z.object({id:A.z,name:i.z.string(),schema:Rg.optional().nullable(),data:pe.optional().nullable()}).transform(s=>({key:s.id.toString(),...s}));i.z.object({from:A.z,type:i.z.string(),to:A.z});const xa=s=>{const[e,t,n]=s.split("->");return{from:new A(e),type:t,to:new A(n)}};class Bc{constructor(e,t){l(this,"key"),l(this,"name"),this.key=t,this.name=e}get ontologyID(){return Pg(this.key)}}const Pg=s=>new A({type:pc,key:s}),Dg=i.z.object({group:yc}),$g=i.z.object({parent:ce,key:ln.optional(),name:ii}),Lg=i.z.object({key:ln,name:ii}),Fg=i.z.object({keys:i.z.array(ln)});var Fe;let _g=(Fe=class{constructor(s){l(this,"client"),this.client=s}async create(s,e,t){return(await w(this.client,Fe.CREATE_ENDPOINT,{parent:s,name:e,key:t},$g,Dg)).group}async rename(s,e){await w(this.client,Fe.RENAME_ENDPOINT,{key:s,name:e},Lg,i.z.object({}))}async delete(s){await w(this.client,Fe.DELETE_ENDPOINT,{keys:s},Fg,i.z.object({}))}},l(Fe,"CREATE_ENDPOINT","/ontology/create-group"),l(Fe,"RENAME_ENDPOINT","/ontology/rename-group"),l(Fe,"DELETE_ENDPOINT","/ontology/delete-group"),Fe),qg=class{constructor(s){l(this,"creator"),this.creator=new _g(s)}async create(s,e,t){return this.sugar(await this.creator.create(s,e,t))}async rename(s,e){return await this.creator.rename(s,e)}async delete(...s){return await this.creator.delete(s)}sugar(s){return new Bc(s.name,s.key)}};const Wg="/ontology/add-children",Vg="/ontology/remove-children",Yg="/ontology/move-children",Ia=i.z.object({id:ce,children:ce.array()}),Zg=i.z.object({from:ce,to:ce,children:ce.array()}),Dn=i.z.object({});let Kg=class{constructor(s){l(this,"client"),this.client=s}async addChildren(s,...e){await w(this.client,Wg,{id:new A(s).payload,children:e.map(t=>new A(t).payload)},Ia,Dn)}async removeChildren(s,...e){await w(this.client,Vg,{id:new A(s).payload,children:e.map(t=>new A(t).payload)},Ia,Dn)}async moveChildren(s,e,...t){const n={from:new A(s).payload,to:new A(e).payload,children:t.map(r=>new A(r).payload)};await w(this.client,Yg,n,Zg,Dn)}};const Hg="/ontology/retrieve",Gg=i.z.object({ids:ce.array().optional(),children:i.z.boolean().optional(),parents:i.z.boolean().optional(),includeSchema:i.z.boolean().optional(),excludeFieldData:i.z.boolean().optional(),term:i.z.string().optional(),limit:i.z.number().optional(),offset:i.z.number().optional(),types:mn.array().optional()}),Jg=i.z.object({resources:Mg.array()}),$n=s=>b(s).map(e=>new A(e).payload);let Xg=class{constructor(s,e){l(this,"type","ontology"),l(this,"groups"),l(this,"client"),l(this,"writer"),l(this,"framer"),this.client=s,this.writer=new Kg(s),this.groups=new qg(s),this.framer=e}async search(s,e){return await this.execRetrieve({term:s,...e})}async retrieve(s,e){const t=await this.execRetrieve({ids:$n(s),...e});if(Array.isArray(s))return t;if(t.length===0)throw new Re(`No resource found with ID ${ug.naturalLanguageJoin(b(s).map(n=>new A(n).toString()))}`);return t[0]}async page(s,e,t){return await this.execRetrieve({offset:s,limit:e,...t})}async retrieveChildren(s,e){return await this.execRetrieve({ids:$n(s),children:!0,...e})}async retrieveParents(s,e){return await this.execRetrieve({ids:$n(s),parents:!0,...e})}async addChildren(s,...e){return await this.writer.addChildren(s,...e)}async removeChildren(s,...e){return await this.writer.removeChildren(s,...e)}async moveChildren(s,e,...t){return await this.writer.moveChildren(s,e,...t)}async openChangeTracker(){return await wn.open(this.framer,this)}async openDependentTracker(s){return await mi.open(s,this.framer,this)}newSearcherWithOptions(s){return{type:this.type,search:e=>this.search(e,s),retrieve:e=>this.retrieve(e,s),page:(e,t)=>this.page(e,t,s)}}async execRetrieve(s){const{resources:e}=await w(this.client,Hg,s,Gg,Jg);return e}};const Ea="sy_ontology_resource_set",Na="sy_ontology_resource_delete",Aa="sy_ontology_relationship_set",Ua="sy_ontology_relationship_delete";class wn{constructor(e,t){l(this,"relationships"),l(this,"resources"),l(this,"resourceObs"),l(this,"relationshipObs"),l(this,"streamer"),l(this,"client"),l(this,"closePromise"),this.relationshipObs=new tt.Observer,this.relationships=this.relationshipObs,this.resourceObs=new tt.Observer,this.resources=this.resourceObs,this.client=t,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 t=await this.parseResourceSets(e),n=this.parseResourceDeletes(e);t.concat(n).length>0&&this.resourceObs.notify(t.concat(n));const r=this.parseRelationshipSets(e),a=this.parseRelationshipDeletes(e);r.concat(a).length>0&&this.relationshipObs.notify(r.concat(a))}parseRelationshipSets(e){const t=e.get(Aa);return t.length===0?[]:Array.from(t.as("string")).map(n=>({variant:"set",key:xa(n),value:void 0}))}parseRelationshipDeletes(e){const t=e.get(Ua);return t.length===0?[]:Array.from(t.as("string")).map(n=>({variant:"delete",key:xa(n)}))}async parseResourceSets(e){const t=e.get(Ea);if(t.length===0)return[];const n=Array.from(t.as("string")).map(r=>new A(r));try{return(await this.client.retrieve(n)).map(r=>({variant:"set",key:r.id,value:r}))}catch(r){if(r instanceof Re)return[];throw r}}parseResourceDeletes(e){const t=e.get(Na);return t.length===0?[]:Array.from(t.as("string")).map(n=>({variant:"delete",key:new A(n)}))}static async open(e,t){const n=await e.openStreamer([Ea,Na,Aa,Ua]);return new wn(n,t)}}const Ca=s=>s==="from"?"to":"from";class mi extends tt.Observer{constructor({target:e,dependents:t,relationshipType:n="parent",relationshipDirection:r="from",resourceType:a},o,c){super(),l(this,"internal"),l(this,"target"),l(this,"relDir"),l(this,"resourceType"),l(this,"dependents"),l(this,"client"),l(this,"relType"),l(this,"handleResourceChange",h=>{this.dependents=this.dependents.map(d=>{const f=h.find(u=>u.key.toString()==d.id.toString());return f==null||f.variant==="delete"?d:f.value}),this.notify(this.dependents)}),l(this,"handleRelationshipChange",h=>{const d=h.filter(u=>u.variant==="delete"&&u.key[this.relDir].toString()===this.target.toString()&&(this.resourceType==null||u.key[Ca(this.relDir)].type===this.resourceType));this.dependents=this.dependents.filter(u=>!d.some(T=>T.key.to.toString()===u.id.toString()&&T.key.type===this.relType));const f=h.filter(u=>u.variant==="set"&&u.key.type===this.relType&&u.key[this.relDir].toString()===this.target.toString()&&(this.resourceType==null||u.key[Ca(this.relDir)].type===this.resourceType));if(f.length===0)return this.notify(this.dependents);this.client.retrieve(f.map(u=>u.key.to)).then(u=>{this.dependents=this.dependents.concat(u),this.notify(this.dependents)}).catch(console.error)}),this.resourceType=a,this.internal=o,this.target=e,this.dependents=t,this.resourceType!=null&&(this.dependents=this.dependents.filter(h=>h.id.type===this.resourceType)),this.client=c,this.relType=n,this.relDir=r,this.internal.resources.onChange(this.handleResourceChange),this.internal.relationships.onChange(this.handleRelationshipChange)}static async open(e,t,n){const r=await wn.open(t,n);return new mi(e,r,n)}async close(){await this.internal.close()}}const bn=i.z.string().uuid(),wi=i.z.object({key:bn,subjects:te(ce),objects:te(ce),actions:te(gr)}),Qg=i.z.object({key:bn.optional(),subjects:Qt.array().or(Qt),objects:Qt.array().or(Qt),actions:gr.array().or(gr)}),em=i.z.object({keys:bn.array().optional(),subjects:ce.array().optional()}),tm=i.z.object({policies:te(wi)}),sm="/access/policy/retrieve";let nm=class{constructor(s){l(this,"client"),this.client=s}async retrieve(s){return(await w(this.client,sm,s,em,tm)).policies}};const rm=i.z.object({policies:wi.partial({key:!0}).array()}),im=i.z.object({policies:wi.array()}),am=i.z.object({keys:bn.array()}),om=i.z.object({}),cm="/access/policy/create",lm="/access/policy/delete";let hm=class{constructor(s){l(this,"client"),this.client=s}async create(s){const e=Qg.array().parse(b(s)).map(t=>({objects:b(t.objects),actions:b(t.actions),subjects:b(t.subjects)}));return(await w(this.client,cm,{policies:e},rm,im)).policies}async delete(s){await w(this.client,lm,{keys:b(s)},am,om)}},um=class{constructor(s){l(this,"retriever"),l(this,"writer"),this.retriever=new nm(s),this.writer=new hm(s)}async create(s){const e=Array.isArray(s),t=await this.writer.create(s);return e?t:t[0]}async retrieve(s){const e=Array.isArray(s),t=await this.retriever.retrieve({keys:b(s)});return e?t:t[0]}async retrieveFor(s){const e=b(s).map(t=>new A(t).payload);return await this.retriever.retrieve({subjects:e})}async delete(s){await this.writer.delete(s)}};new A({type:Ja,key:""});let dm=class{constructor(s){l(this,"policy"),this.policy=new um(s)}};const fm=new Error("request for lock canceled");var ym=function(s,e,t,n){function r(a){return a instanceof t?a:new t(function(o){o(a)})}return new(t||(t=Promise))(function(a,o){function c(f){try{d(n.next(f))}catch(u){o(u)}}function h(f){try{d(n.throw(f))}catch(u){o(u)}}function d(f){f.done?a(f.value):r(f.value).then(c,h)}d((n=n.apply(s,e||[])).next())})};class pm{constructor(e,t=fm){this._value=e,this._cancelError=t,this._queue=[],this._weightedWaiters=[]}acquire(e=1,t=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return new Promise((n,r)=>{const a={resolve:n,reject:r,weight:e,priority:t},o=jc(this._queue,c=>t<=c.priority);o===-1&&e<=this._value?this._dispatchItem(a):this._queue.splice(o+1,0,a)})}runExclusive(e){return ym(this,arguments,void 0,function*(t,n=1,r=0){const[a,o]=yield this.acquire(n,r);try{return yield t(a)}finally{o()}})}waitForUnlock(e=1,t=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return this._couldLockImmediately(e,t)?Promise.resolve():new Promise(n=>{this._weightedWaiters[e-1]||(this._weightedWaiters[e-1]=[]),gm(this._weightedWaiters[e-1],{resolve:n,priority:t})})}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 t=this._value;this._value-=e.weight,e.resolve([t,this._newReleaser(e.weight)])}_newReleaser(e){let t=!1;return()=>{t||(t=!0,this.release(e))}}_drainUnlockWaiters(){if(this._queue.length===0)for(let e=this._value;e>0;e--){const t=this._weightedWaiters[e-1];t&&(t.forEach(n=>n.resolve()),this._weightedWaiters[e-1]=[])}else{const e=this._queue[0].priority;for(let t=this._value;t>0;t--){const n=this._weightedWaiters[t-1];if(!n)continue;const r=n.findIndex(a=>a.priority<=e);(r===-1?n:n.splice(0,r)).forEach(a=>a.resolve())}}}_couldLockImmediately(e,t){return(this._queue.length===0||this._queue[0].priority<t)&&e<=this._value}}function gm(s,e){const t=jc(s,n=>e.priority<=n.priority);s.splice(t+1,0,e)}function jc(s,e){for(let t=s.length-1;t>=0;t--)if(e(s[t]))return t;return-1}var mm=function(s,e,t,n){function r(a){return a instanceof t?a:new t(function(o){o(a)})}return new(t||(t=Promise))(function(a,o){function c(f){try{d(n.next(f))}catch(u){o(u)}}function h(f){try{d(n.throw(f))}catch(u){o(u)}}function d(f){f.done?a(f.value):r(f.value).then(c,h)}d((n=n.apply(s,e||[])).next())})};class wm{constructor(e){this._semaphore=new pm(1,e)}acquire(){return mm(this,arguments,void 0,function*(e=0){const[,t]=yield this._semaphore.acquire(1,e);return t})}runExclusive(e,t=0){return this._semaphore.runExclusive(()=>e(),1,t)}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 bi=(s,e,{convertNumericStrings:t=!0}={})=>{const n=!Array.isArray(s);let r=b(s);const a=r[0],o=typeof a;let c;return o==="string"&&t&&!isNaN(parseInt(a))&&"number"in e?(c=e.number,r=r.map(h=>parseInt(h))):c=e[o],{single:n,variant:c,normalized:r,actual:s}},vn=(s,e,t,n)=>{if(n){if(t.length===0)throw new nt(`${s} not found matching ${JSON.stringify(e)}`);if(t.length>1)throw new vt(`Expected one ${s} matching ${JSON.stringify(e)}, but found ${t.length}`)}},bm=i.z.object({leaseholder:i.z.number().optional(),keys:se.array().optional(),names:i.z.string().array().optional(),search:i.z.string().optional(),rangeKey:i.z.string().optional(),limit:i.z.number().optional(),offset:i.z.number().optional(),dataTypes:N.z.array().optional(),notDataTypes:N.z.array().optional(),virtual:i.z.boolean().optional(),isIndex:i.z.boolean().optional(),internal:i.z.boolean().optional()}),vm=i.z.object({channels:te(vs)}),Ie=s=>(Array.isArray(s)&&s.length>0&&typeof s[0]=="object"?s=s.map(e=>e.key):typeof s=="object"&&"key"in s&&(s=[s.key]),bi(s,{number:"keys",string:"names"})),Rc=class Mc{constructor(e){l(this,"client"),this.client=e}async search(e,t){return await this.execute({search:e,...t})}async retrieve(e,t){const n=Ie(e),{variant:r}=n;let{normalized:a}=n;return r==="keys"&&a.indexOf(0)!==-1&&(a=a.filter(o=>o!==0)),a.length===0?[]:await this.execute({[r]:a,...t})}async page(e,t,n){return await this.execute({offset:e,limit:t,...n})}async execute(e){const[t,n]=await this.client.send(Mc.ENDPOINT,e,bm,vm);if(n!=null)throw n;return t.channels}};l(Rc,"ENDPOINT","/channel/retrieve");let vi=Rc;class zi{constructor(e){l(this,"cache"),l(this,"namesToKeys"),l(this,"wrapped"),this.cache=new Map,this.namesToKeys=new Map,this.wrapped=e}async search(e,t){return await this.wrapped.search(e,t)}async page(e,t,n){return await this.wrapped.page(e,t,n)}async retrieve(e,t){const{normalized:n}=Ie(e),r=[],a=[];if(n.forEach(c=>{const h=this.get(c);h!=null?r.push(...h):a.push(c)}),a.length===0)return r;const o=await this.wrapped.retrieve(a,t);return this.set(o),r.concat(o)}delete(e){const{variant:t,normalized:n}=Ie(e);t==="names"?n.forEach(r=>{const a=this.namesToKeys.get(r);a!=null&&(a.forEach(o=>this.cache.delete(o)),this.namesToKeys.delete(r))}):n.forEach(r=>{const a=this.cache.get(r);a!=null&&(this.cache.delete(r),this.namesToKeys.delete(a.name))})}rename(e,t){e.forEach((n,r)=>{const a=t[r],o=this.cache.get(n);if(o==null)return;this.cache.delete(n);const c=this.namesToKeys.get(o.name);c!=null&&(c.delete(n),c.size===0&&this.namesToKeys.delete(o.name)),o.name=a,this.cache.set(n,o);const h=this.namesToKeys.get(a);h==null?this.namesToKeys.set(a,new Set([n])):h.add(n)})}set(e){e.forEach(t=>{this.cache.set(t.key,t);const n=this.namesToKeys.get(t.name);n==null?this.namesToKeys.set(t.name,new Set([t.key])):n.add(t.key)})}get(e){if(typeof e=="number"){const r=this.cache.get(e);return r==null?void 0:[r]}const t=this.namesToKeys.get(e);if(t==null)return;const n=[];if(t.forEach(r=>{const a=this.cache.get(r);a!=null&&n.push(a)}),n.length!==0)return n}}class Pc{constructor(e,t){l(this,"mu",new wm),l(this,"requests",new Map),l(this,"wrapped"),l(this,"debouncedRun"),this.wrapped=e,this.debouncedRun=Hy(()=>{this.run()},t)}async search(e,t){return await this.wrapped.search(e,t)}async page(e,t,n){return await this.wrapped.page(e,t,n)}async retrieve(e){const{normalized:t,variant:n}=Ie(e);return n==="names"?await this.wrapped.retrieve(t):await new Promise((r,a)=>{this.mu.runExclusive(()=>{this.requests.set(t,{resolve:r,reject:a}),this.debouncedRun()})})}async run(){await this.mu.runExclusive(async()=>{const e=new Set;this.requests.forEach((t,n)=>n.forEach(r=>e.add(r)));try{const t=await this.wrapped.retrieve(Array.from(e));this.requests.forEach((n,r)=>n.resolve(t.filter(a=>r.includes(a.key))))}catch(t){this.requests.forEach(n=>n.reject(t))}finally{this.requests.clear()}})}}const Dc=async(s,e)=>{const{normalized:t}=Ie(e),n=await s.retrieve(t),r=[];if(t.forEach(a=>{n.find(o=>o.name===a||o.key===a)==null&&r.push(a)}),r.length>0)throw new Re(`Could not find channels: ${JSON.stringify(r)}`);return n};class $c{constructor({dataType:e,name:t,leaseholder:n=0,key:r=0,isIndex:a=!1,index:o=0,internal:c=!1,virtual:h=!1,frameClient:d,alias:f,expression:u="",requires:T=[]}){l(this,"_frameClient"),l(this,"key"),l(this,"name"),l(this,"dataType"),l(this,"leaseholder"),l(this,"index"),l(this,"isIndex"),l(this,"internal"),l(this,"alias"),l(this,"virtual"),l(this,"expression"),l(this,"requires"),this.key=r,this.name=t,this.dataType=new N(e),this.leaseholder=n,this.index=o,this.isIndex=a,this.internal=c,this.alias=f,this.virtual=h,this.expression=u,this.requires=T??[],this._frameClient=d??null}get framer(){if(this._frameClient==null)throw new W("cannot read from a channel that has not been created");return this._frameClient}get payload(){return vs.parse({key:this.key,name:this.name,dataType:this.dataType.valueOf(),leaseholder:this.leaseholder,index:this.index,isIndex:this.isIndex,internal:this.internal,virtual:this.virtual,expression:this.expression,requires:this.requires})}get isCalculated(){return en(this.payload)}get ontologyID(){return _c(this.key)}async read(e){return await this.framer.read(e,this.key)}async write(e,t){return await this.framer.write(e,this.key,t)}}const zm="/channel/retrieve-group",Sm=i.z.object({}),Tm=i.z.object({group:yc});let Lc=class{constructor(s,e,t,n){l(this,"type",hn),l(this,"frameClient"),l(this,"client"),l(this,"retriever"),l(this,"writer"),this.frameClient=s,this.retriever=e,this.client=t,this.writer=n}async create(s,e={}){const{retrieveIfNameExists:t=!1}=e,n=!Array.isArray(s);let r=b(s),a=[];if(t){const o=await this.retriever.retrieve(r.map(h=>h.name)),c=new Set(o.map(h=>h.name));r=r.filter(h=>!c.has(h.name)),a=this.sugar(o)}return a=a.concat(this.sugar(await this.writer.create(r))),n?a[0]:a}async retrieve(s,e){const t=!Array.isArray(s),n=this.sugar(await this.retriever.retrieve(s,e));return vn("channel",s,n,t),t?n[0]:n}async search(s,e){return this.sugar(await this.retriever.search(s,e))}async delete(s){const{normalized:e,variant:t}=Ie(s);return t==="keys"?await this.writer.delete({keys:e}):await this.writer.delete({names:e})}async rename(s,e){return await this.writer.rename(b(s),b(e))}newSearcherWithOptions(s){return{type:this.type,search:async e=>await this.search(e,s),retrieve:async e=>await this.retrieve(e,s),page:async(e,t)=>await this.page(e,t,s)}}async page(s,e,t){return this.sugar(await this.retriever.page(s,e,t))}createDebouncedBatchRetriever(s=10){return new zi(new Pc(new vi(this.client),s))}sugar(s){const{frameClient:e}=this;return s.map(t=>new $c({...t,frameClient:e}))}async retrieveGroup(){const s=await w(this.client,zm,{},Sm,Tm);return new Bc(s.group.name,s.group.key)}};const en=({virtual:s,expression:e})=>s&&e!=="",Fc=async(s,e)=>{if(!en(e))return e.index;for(const t of e.requires){const n=await s(t);if(n==null)return null;if(!n.virtual)return n.index}for(const t of e.requires){const n=await s(t);if(n==null)return null;if(en(n)){const r=await Fc(s,n);if(r!=null)return r}}return null},_c=s=>new A({type:hn,key:s.toString()}),Om=i.z.object({channels:gc.array()}),km=i.z.object({channels:vs.array()}),xm=i.z.object({keys:se.array().optional(),names:bs.array().optional()}),Im=i.z.object({}),Em=i.z.object({keys:se.array(),names:bs.array()}),Nm=i.z.object({}),Am="/channel/create",Um="/channel/delete",Cm="/channel/rename";let qc=class{constructor(s,e){l(this,"client"),l(this,"cache"),this.client=s,this.cache=e}async create(s){const{channels:e}=await w(this.client,Am,{channels:s},Om,km);return this.cache.set(e),e}async delete(s){await w(this.client,Um,s,xm,Im),s.keys!=null&&this.cache.delete(s.keys),s.names!=null&&this.cache.delete(s.names)}async rename(s,e){await w(this.client,Cm,{keys:s,names:e},Em,Nm),this.cache.rename(s,e)}};const Bm=Object.freeze(Object.defineProperty({__proto__:null,CacheRetriever:zi,Channel:$c,Client:Lc,ClusterRetriever:vi,DebouncedBatchRetriever:Pc,ONTOLOGY_TYPE:hn,Writer:qc,analyzeParams:Ie,channelZ:vs,isCalculated:en,keyZ:se,nameZ:bs,newZ:gc,ontologyID:_c,resolveCalculatedIndex:Fc,retrieveRequired:Dc},Symbol.toStringTag,{value:"Module"})),jm=i.z.object({keys:kt.array().optional(),usernames:i.z.string().array().optional()}),Rm=i.z.object({users:te(gn)}),Mm="/user/retrieve";let Pm=class{constructor(s){l(this,"client"),this.client=s}async retrieve(s){return(await w(this.client,Mm,s,jm,Rm)).users}};const Dm=i.z.object({users:bg.array()}),$m=i.z.object({users:gn.array()}),Lm=i.z.object({key:kt,username:i.z.string().min(1)}),Fm=i.z.object({}),_m=i.z.object({key:kt,firstName:i.z.string().optional(),lastName:i.z.string().optional()}),qm=i.z.object({}),Wm=i.z.object({keys:kt.array()}),Vm=i.z.object({}),Ym="/user/create",Zm="/user/change-username",Km="/user/rename",Hm="/user/delete";let Gm=class{constructor(s){l(this,"client"),this.client=s}async create(s){return(await w(this.client,Ym,{users:b(s)},Dm,$m)).users}async changeUsername(s,e){await w(this.client,Zm,{key:s,username:e},Lm,Fm)}async rename(s,e,t){await w(this.client,Km,{key:s,firstName:e,lastName:t},_m,qm)}async delete(s){await w(this.client,Hm,{keys:b(s)},Wm,Vm)}},Jm=class{constructor(s){l(this,"reader"),l(this,"writer"),this.writer=new Gm(s),this.reader=new Pm(s)}async create(s){const e=Array.isArray(s),t=await this.writer.create(s);return e?t:t[0]}async changeUsername(s,e){await this.writer.changeUsername(s,e)}async retrieve(s){const e=Array.isArray(s),t=await this.reader.retrieve({keys:b(s)});if(e)return t;if(t.length===0)throw new nt(`No user with key ${s} found`);if(t.length>1)throw new vt(`Multiple users found with key ${s}`);return t[0]}async retrieveByName(s){const e=Array.isArray(s),t=await this.reader.retrieve({usernames:b(s)});if(e)return t;if(t.length===0)throw new nt(`No user with username ${s} found`);if(t.length>1)throw new vt(`Multiple users found with username ${s}`);return t[0]}async rename(s,e,t){await this.writer.rename(s,e,t)}async delete(s){await this.writer.delete(s)}};const Xm=i.z.object({username:i.z.string(),password:i.z.string()}),Qm=i.z.object({token:i.z.string(),user:gn}),Ba="/auth/login",ew=3,tw="/auth/change-password",sw=i.z.object({username:i.z.string(),password:i.z.string(),newPassword:i.z.string().min(1)}),nw=i.z.object({}),rw=[Nr,Ar];let iw=class{constructor(s,e){l(this,"token"),l(this,"client"),l(this,"credentials"),l(this,"authenticating"),l(this,"authenticated"),l(this,"user"),l(this,"retryCount"),this.client=s,this.authenticated=!1,this.credentials=e,this.retryCount=0}async changePassword(s){if(!this.authenticated)throw new Error("Not authenticated");await w(this.client,tw,{username:this.credentials.username,password:this.credentials.password,newPassword:s},sw,nw),this.credentials.password=s}middleware(){const s=async(e,t)=>{if(!this.authenticated&&!e.target.endsWith(Ba)){this.authenticating??(this.authenticating=new Promise((o,c)=>{this.client.send(Ba,this.credentials,Xm,Qm).then(([h,d])=>{if(d!=null)return o(d);this.token=h==null?void 0:h.token,this.user=h==null?void 0:h.user,this.authenticated=!0,o(null)}).catch(c)}));const a=await this.authenticating;if(a!=null)return[e,a]}e.params.Authorization=`Bearer ${this.token}`;const[n,r]=await t(e);return rw.some(a=>a.matches(r))&&this.retryCount<ew?(this.authenticated=!1,this.authenticating=void 0,this.retryCount+=1,s(e,t)):(this.retryCount=0,[n,r])};return s}};const aw=i.z.enum(["disconnected","connecting","connected","failed"]),ow=i.z.object({status:aw,error:i.z.instanceof(Error).optional(),message:i.z.string().optional(),clusterKey:i.z.string(),clientVersion:i.z.string(),clientServerCompatible:i.z.boolean(),nodeVersion:i.z.string().optional()}),cw=i.z.object({clusterKey:i.z.string(),nodeVersion:i.z.string().optional()}),Wc={clusterKey:"",status:"disconnected",error:void 0,message:"Disconnected",clientServerCompatible:!1,clientVersion:"0.42.0"},ja=(s,e,t)=>{const n=t?"cluster":"client";return`Synnax cluster node version ${s!=null?`${s} `:""}is too ${t?"old":"new"} for client version ${e}.
39
+ This may cause compatibility issues. We recommend updating the ${n}. For more information, see
40
+ https://docs.synnaxlabs.com/reference/typescript-client/troubleshooting#old-${n}-version`},Vs=class Vc{constructor(e,t=O.seconds(30),n,r){l(this,"_state"),l(this,"pollFrequency",O.seconds(30)),l(this,"client"),l(this,"name"),l(this,"interval"),l(this,"clientVersion"),l(this,"onChangeHandlers",[]),l(this,"versionWarned",!1),this._state={...Wc},this.client=e,this.pollFrequency=t,this.clientVersion=n,this.name=r,this.check(),this.startChecking()}stopChecking(){this.interval!=null&&clearInterval(this.interval)}async check(){var e;const t=this._state.status;try{const[n,r]=await this.client.send(Vc.ENDPOINT,{},i.z.object({}),cw);if(r!=null)throw r;const a=n.nodeVersion,o=this.clientVersion,c=this.versionWarned;a==null?(this._state.clientServerCompatible=!1,c||(console.warn(ja(null,o,!0)),this.versionWarned=!0)):va.versionsEqual(o,a,{checkMajor:!0,checkMinor:!0,checkPatch:!1})?this._state.clientServerCompatible=!0:(this._state.clientServerCompatible=!1,c||(console.warn(ja(a,o,va.semVerNewer(o,a))),this.versionWarned=!0)),this._state.status="connected",this._state.message=`Connected to ${this.name??"cluster"}`,this._state.clusterKey=n.clusterKey,this._state.nodeVersion=n.nodeVersion,this._state.clientVersion=this.clientVersion}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&&t!==this._state.status&&this.onChangeHandlers.forEach(n=>n(this.state)),this.state}get state(){return{...this._state}}onChange(e){this.onChangeHandlers.push(e)}startChecking(){this.interval=setInterval(()=>{this.check()},this.pollFrequency.milliseconds)}};l(Vs,"ENDPOINT","/connectivity/check"),l(Vs,"DEFAULT",Wc),l(Vs,"connectionStateZ",ow);let Yc=Vs;const lw=i.z.object({keys:se.array().optional(),bounds:V.z,names:bs.array().optional()}),hw=i.z.object({}),uw="/frame/delete";class dw{constructor(e){l(this,"client"),this.client=e}async delete(e){await w(this.client,uw,e,lw,hw)}}var zt=(s=>(s[s.Open=0]="Open",s[s.Write=1]="Write",s[s.Commit=2]="Commit",s[s.SetAuthority=3]="SetAuthority",s))(zt||{}),St=(s=>(s[s.PersistStream=1]="PersistStream",s[s.Persist=2]="Persist",s[s.Stream=3]="Stream",s))(St||{});const fw=s=>{switch(s){case"persist":return 2;case"stream":return 3;case"persistStream":return 1;default:if(typeof s=="number"&&s in St)return s;throw new Error(`invalid writer mode: ${s}`)}},yw=new O(-1);class Cr extends Pe.sub("writer_closed"){constructor(){super("WriterClosed")}}const pw=i.z.object({start:x.z.optional(),controlSubject:st.subjectZ.optional(),keys:se.array().optional(),authorities:st.authorityZ.array().optional(),mode:i.z.enum(St).optional(),errOnUnauthorized:i.z.boolean().optional(),enableAutoCommit:i.z.boolean().optional(),autoIndexPersistInterval:O.z.optional()}),gw=i.z.object({command:i.z.enum(zt),config:pw.optional(),frame:un.optional(),buffer:i.z.instanceof(Uint8Array).optional()}),mw=i.z.object({command:i.z.enum(zt),end:x.z,err:bt.payloadZ.optional()});var Pt;let Zc=(Pt=class{constructor(s,e){l(this,"stream"),l(this,"adapter"),l(this,"closeErr",null),this.stream=s,this.adapter=e}static async _open(s,e,{channels:t,start:n=x.now(),authorities:r=st.ABSOLUTE_AUTHORITY,controlSubject:a,mode:o=1,errOnUnauthorized:c=!1,enableAutoCommit:h=!1,autoIndexPersistInterval:d=O.SECOND,useExperimentalCodec:f=!0}){const u=await Ti.open(s,t);f&&(e=e.withCodec(new Tw(u.codec)));const T=await e.stream(Pt.ENDPOINT,gw,mw),k=new Pt(T,u);return await k.execute({command:0,config:{start:new x(n),keys:u.keys,controlSubject:a,authorities:b(r),mode:fw(o),errOnUnauthorized:c,enableAutoCommit:h,autoIndexPersistInterval:d}}),k}async write(s,e){if(this.closeErr!=null)throw this.closeErr;if(this.stream.received())return await this.close();const t=await this.adapter.adapt(s,e);this.stream.send({command:1,frame:t.toPayload()})}async setAuthority(s,e){if(this.closeErr!=null)throw this.closeErr;let t;if(typeof s=="number"&&e==null)t={keys:[],authorities:[s]};else{let n;typeof s=="string"||typeof s=="number"?n={[s]:e}:n=s,n=await this.adapter.adaptObjectKeys(n),t={keys:Object.keys(n).map(r=>Number(r)),authorities:Object.values(n)}}await this.execute({command:3,config:t})}async commit(){if(this.closeErr!=null)throw this.closeErr;return this.stream.received()?(await this.closeInternal(null),x.ZERO):(await this.execute({command:2})).end}async close(){await this.closeInternal(null)}async closeInternal(s){if(this.closeErr!=null)throw this.closeErr;for(this.closeErr=s,this.stream.closeSend();;){if(this.closeErr!=null){if(Cr.matches(this.closeErr))return null;throw this.closeErr}const[e,t]=await this.stream.receive();t!=null?this.closeErr=ge.matches(t)?new Cr:t:this.closeErr=bt.decode(e==null?void 0:e.err)}}async execute(s){const e=this.stream.send(s);for(e!=null&&await this.closeInternal(e);;){const[t,n]=await this.stream.receive();n!=null&&await this.closeInternal(n);const r=bt.decode(t==null?void 0:t.err);if(r!=null&&await this.closeInternal(r),(t==null?void 0:t.command)==s.command)return t}}},l(Pt,"ENDPOINT","/frame/write"),Pt);const Ra=s=>s.data.byteLength/s.dataType.density.valueOf(),ww=s=>{const{keys:e,series:t}=s;e.forEach((n,r)=>{t[r].key=n}),t.sort((n,r)=>n.key-r.key),e.sort((n,r)=>n-r),t.forEach(n=>delete n.key)},Ma=5,Pa=4,Da=3,$a=2,La=1,Fa=0,we=N.TIMESTAMP.density.valueOf(),_e=8,qe=4,Ln=4,Fn=4,bw=1;class Kc{constructor(e=[],t=[]){l(this,"contentType","application/sy-framer"),l(this,"states",new Map),l(this,"currState"),l(this,"seqNum",0),(e.length>0||t.length>0)&&this.update(e,t)}update(e,t){this.seqNum++;const n={keys:e,keyDataTypes:new Map,hasVariableDataTypes:!1};e.forEach((r,a)=>{const o=t[a];n.keyDataTypes.set(r,o),o.isVariable&&(n.hasVariableDataTypes=!0)}),n.keys.sort(),this.states.set(this.seqNum,n),this.currState=n}throwIfNotUpdated(e){if(this.seqNum<1)throw new W(`
41
+ The codec has not been updated with a list of channels and data types.
42
+ Please call the update method before calling ${e}.
43
+ `)}encode(e,t=0){var n,r;this.throwIfNotUpdated("encode");let a=e;e!=null&&typeof e=="object"&&"toPayload"in e&&(a=e.toPayload()),ww(a);let o=-1,c,h,d,f=t+bw+Fn,u=!((n=this.currState)!=null&&n.hasVariableDataTypes),T=!0,k=!0,Y=!0,U=!0,de=!0;a.keys.length!==((r=this.currState)==null?void 0:r.keys.length)&&(Y=!1,f+=a.keys.length*Ln),a.series.forEach((F,Et)=>{var Ae,me,le,xs,Is;const Bi=Ra(F),Tn=a.keys[Et],On=(Ae=this.currState)==null?void 0:Ae.keyDataTypes.get(Tn);if(On==null)throw new W(`Channel ${Tn} was not provided in the list of channels when opening the writer`);if(!On.equals(F.dataType))throw new W(`Series data type of ${F.dataType.toString()} does not match the data type of ${On.toString()} for channel ${Tn}`);if(f+=F.data.byteLength,o===-1){o=Bi,c=(me=F.timeRange)==null?void 0:me.start,h=(le=F.timeRange)==null?void 0:le.end,d=BigInt(F.alignment??0n);return}o!==Bi&&(u=!1),((c==null?void 0:c.valueOf())!==((xs=F.timeRange)==null?void 0:xs.start.valueOf())||(h==null?void 0:h.valueOf())!==((Is=F.timeRange)==null?void 0:Is.end.valueOf()))&&(T=!1),d!==BigInt(F.alignment??0)&&(U=!1)}),k=T&&c==null&&h==null,de=U&&(d===void 0||d===0n),u?f+=qe:f+=a.keys.length*qe,k||(T?f+=we*2:f+=a.keys.length*we*2),de||(U?f+=_e:f+=a.keys.length*_e);const Ne=new Uint8Array(f),fe=new DataView(Ne.buffer);let B=t;return Ne[B]=Number(de)<<Ma|Number(U)<<Pa|Number(u)<<Da|Number(T)<<$a|Number(k)<<La|Number(Y)<<Fa,B++,fe.setUint32(B,this.seqNum,!0),B+=Fn,u&&(fe.setUint32(B,o,!0),B+=qe),T&&!k&&(fe.setBigUint64(B,(c==null?void 0:c.valueOf())??0n,!0),fe.setBigUint64(B,(h==null?void 0:h.valueOf())??0n,!0),B+=we*2),U&&!de&&(fe.setBigUint64(B,d??0n,!0),B+=_e),a.series.forEach((F,Et)=>{var Ae,me;if(Y||(fe.setUint32(B,a.keys[Et],!0),B+=Ln),!u){let le=F.data.byteLength;F.dataType.isVariable||(le=Ra(F)),fe.setUint32(B,le,!0),B+=qe}Ne.set(new Uint8Array(F.data),B),B+=F.data.byteLength,!T&&!k&&(fe.setBigUint64(B,((Ae=F.timeRange)==null?void 0:Ae.start.valueOf())??0n,!0),fe.setBigUint64(B,((me=F.timeRange)==null?void 0:me.end.valueOf())??0n,!0),B+=we*2),!U&&!de&&(fe.setBigUint64(B,F.alignment??0n,!0),B+=_e)}),Ne}decode(e,t=0){this.throwIfNotUpdated("decode");const n=e instanceof Uint8Array?e:new Uint8Array(e),r={keys:[],series:[]};let a=t,o=0,c=0,h,d,f;const u=new DataView(n.buffer,n.byteOffset,n.byteLength),T=!!(n[a]>>Ma&1),k=!!(n[a]>>Pa&1),Y=!!(n[a]>>Da&1),U=!!(n[a]>>$a&1),de=!!(n[a]>>La&1),Ne=!!(n[a]>>Fa&1);a++;const fe=u.getUint32(a,!0);a+=Fn;const B=this.states.get(fe);if(B==null)return r;if(Y){if(a+qe>u.byteLength)return r;o=u.getUint32(a,!0),a+=qe}if(U&&!de){if(a+we>u.byteLength)return r;h=new x(u.getBigUint64(a,!0)),a+=we,d=new x(u.getBigUint64(a,!0)),a+=we}if(k&&!T){if(a+_e>u.byteLength)return r;f=u.getBigUint64(a,!0),a+=_e}return Ne&&(r.keys=[...B.keys]),B.keys.forEach((F,Et)=>{if(!Ne){if(a>=u.byteLength||u.getUint32(a,!0)!==F)return;a+=Ln,r.keys.push(F)}const Ae=B.keyDataTypes.get(F);if(c=0,Y)c=o;else{if(a+qe>u.byteLength)return;c=u.getUint32(a,!0),a+=qe}let me=c;if(Ae.isVariable||(me*=Ae.density.valueOf()),a+me>u.byteLength){r.keys.splice(Et,1);return}const le={dataType:Ae,data:n.slice(a,a+me).buffer};if(a+=me,!U&&!de){if(a+we*2>u.byteLength)return;const xs=u.getBigUint64(a,!0);a+=we;const Is=u.getBigUint64(a,!0);a+=we,le.timeRange=new V({start:xs,end:Is})}else de?le.timeRange=new V({start:0n,end:0n}):le.timeRange=new V({start:(h==null?void 0:h.valueOf())??0n,end:(d==null?void 0:d.valueOf())??0n});if(!k&&!T){if(a+_e>u.byteLength)return;f=u.getBigUint64(a,!0),a+=_e,le.alignment=f}else T?le.alignment=0n:le.alignment=f;r.series.push(le)}),r}}const Si=254,vw=new Uint8Array([Si]),zw=255,Sw=new Uint8Array([zw]),Hc="application/sy-framer";class Tw{constructor(e){l(this,"contentType",Hc),l(this,"base"),l(this,"lowPerfCodec"),this.base=e,this.lowPerfCodec=rt.JSON_CODEC}encode(e){var t,n;const r=e;if(r.type=="close"||((t=r.payload)==null?void 0:t.command)!=zt.Write){const o=this.lowPerfCodec.encode(r),c=new Uint8Array({length:o.byteLength+1});return c.set(vw,0),c.set(new Uint8Array(o),1),c}const a=this.base.encode((n=r.payload)==null?void 0:n.frame,1);return a.set(Sw,0),a}decode(e,t){if(new DataView(e instanceof Uint8Array?e.buffer:e).getUint8(0)===Si)return this.lowPerfCodec.decode(e.slice(1),t);const n={type:"data"},r=this.base.decode(e,1);return n.payload={command:zt.Write,frame:r},n}}class Ow{constructor(e){l(this,"contentType",Hc),l(this,"base"),l(this,"lowPerfCodec"),this.base=e,this.lowPerfCodec=rt.JSON_CODEC}encode(e){return this.lowPerfCodec.encode(e)}decode(e,t){return new DataView(e instanceof Uint8Array?e.buffer:e).getUint8(0)===Si?this.lowPerfCodec.decode(e.slice(1),t):{type:"data",payload:{frame:this.base.decode(e,1)}}}}class zn{constructor(e){l(this,"adapter"),l(this,"retriever"),l(this,"keys"),l(this,"codec"),this.retriever=e,this.adapter=null,this.keys=[],this.codec=new Kc}static async open(e,t){const n=new zn(e);return await n.update(t),n}async update(e){const{variant:t,normalized:n}=Ie(e),r=await this.retriever.retrieve(n);if(this.codec.update(r.map(o=>o.key),r.map(o=>o.dataType)),t==="keys"){this.adapter=null,this.keys=n;return}const a=new Map;this.adapter=a,n.forEach(o=>{const c=r.find(h=>h.name===o);if(c==null)throw new Error(`Channel ${o} not found`);a.set(c.key,c.name)}),this.keys=Array.from(this.adapter.keys())}adapt(e){if(this.adapter==null)return e;const t=this.adapter;return e.map((n,r)=>{if(typeof n=="number"){const a=t.get(n);if(a==null)throw new Error(`Channel ${n} not found`);return[a,r]}return[n,r]})}}class Ti{constructor(e){l(this,"adapter"),l(this,"retriever"),l(this,"keys"),l(this,"codec"),this.retriever=e,this.adapter=null,this.keys=[],this.codec=new Kc}static async open(e,t){const n=new Ti(e);return await n.update(t),n}async adaptObjectKeys(e){const t={};for(const[n,r]of Object.entries(e))t[await this.adaptToKey(n)]=r;return t}async update(e){const t=await Dc(this.retriever,e);this.adapter=new Map(t.map(n=>[n.name,n.key])),this.keys=t.map(n=>n.key),this.codec.update(this.keys,t.map(n=>n.dataType))}async fetchChannel(e){const t=await this.retriever.retrieve(e);if(t.length===0)throw new Error(`Channel ${JSON.stringify(e)} not found`);return t[0]}async adaptToKey(e){return typeof e=="number"?e:(await this.fetchChannel(e)).key}encode(e){return this.codec.encode(e.toPayload())}async adapt(e,t){if(typeof e=="string"||typeof e=="number"){if(t==null)throw new W(`
44
+ Received a single channel name or key but no series.
45
+ `);if(Array.isArray(t)){if(t.some(h=>h instanceof Je||Array.isArray(h)))throw new W(`
46
+ Received a single channel name or key but multiple series.
47
+ `);t=t}const o=await this.fetchChannel(e),c=new Je({data:t,dataType:o.dataType});return new J(o.key,c)}if(Array.isArray(e)){if(t==null)throw new W(`
48
+ Received an array of channel names or keys but no series.
49
+ `);if(!Array.isArray(t))throw new W(`
50
+ Received an array of channel names or keys but no array of series.
51
+ `);const o=[],c=[];for(let h=0;h<e.length;h++){const d=await this.fetchChannel(e[h]);if(h>=t.length)throw new W(`
52
+ Received an array of channel names or keys but not enough series.
53
+ `);const f=new Je({data:t[h],dataType:d.dataType});o.push(d.key),c.push(f)}return new J(o,c)}if(e instanceof J||e instanceof Map){const o=new J(e);if(this.adapter==null)return o;const c=o.columns.map(h=>{var d;const f=typeof h=="string"?(d=this.adapter)==null?void 0:d.get(h):h;if(f==null)throw new W(`
54
+ Channel ${h} was not provided in the list of channels when opening the writer
55
+ `);return f});return new J(c,o.series)}const n=[],r=[],a=Object.entries(e);for(let o=0;o<a.length;o++){const[c,h]=a[o],d=await this.fetchChannel(c),f=new Je({data:h,dataType:d.dataType});n.push(d.key),r.push(f)}return new J(n,r)}}class Gc{constructor(e,t){l(this,"name"),l(this,"stream"),this.stream=t,this.name=e}async receive(){const[e,t]=await this.stream.receive();if(t!=null)throw t;return e}received(){return this.stream.received()}async closeAndAck(){for(this.stream.closeSend();;){const[e,t]=await this.stream.receive();if(e!=null&&console.warn(`${this.name} received unexpected response on closure.
56
+ Please report this error to the Synnax team.`),t!=null){if(ge.matches(t))return;throw t}}}closeSend(){this.stream.closeSend()}send(e){const t=this.stream.send(e);if(t!=null)throw t}}const Br=new O(-1);var Oi=(s=>(s[s.Open=0]="Open",s[s.Next=1]="Next",s[s.Prev=2]="Prev",s[s.SeekFirst=3]="SeekFirst",s[s.SeekLast=4]="SeekLast",s[s.SeekLE=5]="SeekLE",s[s.SeekGE=6]="SeekGE",s[s.Valid=7]="Valid",s[s.Error=8]="Error",s))(Oi||{}),Jc=(s=>(s[s.None=0]="None",s[s.Ack=1]="Ack",s[s.Data=2]="Data",s))(Jc||{});const kw=i.z.object({command:i.z.enum(Oi),span:O.z.optional(),bounds:V.z.optional(),stamp:x.z.optional(),keys:se.array().optional(),chunkSize:i.z.number().optional()}),xw=i.z.object({variant:i.z.enum(Jc),ack:i.z.boolean(),command:i.z.enum(Oi),error:bt.payloadZ.optional().nullable(),frame:un.optional()}),Xc=class jr{constructor(e,t){l(this,"stream"),l(this,"adapter"),l(this,"value"),this.stream=new Gc("Iterator",e),this.value=new J,this.adapter=t}static async _open(e,t,n,r,a={}){const o=await zn.open(n,t),c=await r.stream(jr.ENDPOINT,kw,xw),h=new jr(c,o);return await h.execute({command:0,keys:o.keys,bounds:new V(e),chunkSize:a.chunkSize??1e5}),h}async next(e=Br){return await this.execute({command:1,span:new O(e)})}async prev(e=Br){return await this.execute({command:2,span:new O(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 x(e)})}async seekGE(e){return await this.execute({command:6,stamp:new x(e)})}async valid(){return await this.execute({command:7})}async close(){await this.stream.closeAndAck()}[Symbol.asyncIterator](){return new Iw(this)}async execute(e){for(this.stream.send(e),this.value=new J;;){const t=await this.stream.receive();if(t.variant===1)return t.ack;this.value.push(this.adapter.adapt(new J(t.frame)))}}};l(Xc,"ENDPOINT","/frame/iterate");let Qc=Xc;class Iw{constructor(e){l(this,"iter"),l(this,"open",!1),this.iter=e}async next(){try{let e=!0;return this.open||(await this.iter.seekFirst()||(e=!1),this.open=!0),await this.iter.next()||(e=!1),e||await this.iter.close(),{done:!e,value:this.iter.value}}catch(e){throw await this.iter.close(),e}}}const Ew=i.z.object({keys:i.z.number().array(),downSampleFactor:i.z.number()}),Nw=i.z.object({frame:un}),Aw="/frame/stream",el=(s,e)=>async t=>{let n;Array.isArray(t)||typeof t!="object"?n={channels:t,downSampleFactor:1}:n=t;const r=await zn.open(s,n.channels);n.useExperimentalCodec&&(e=e.withCodec(new Ow(r.codec)));const a=await e.stream(Aw,Ew,Nw),o=new Uw(a,r);a.send({keys:r.keys,downSampleFactor:n.downSampleFactor??1});const[,c]=await a.receive();if(c!=null)throw c;return o},tl=async(s,e,t)=>await el(s,e)(t);class Uw{constructor(e,t){l(this,"stream"),l(this,"adapter"),l(this,"downsampleFactor"),this.stream=new Gc("Streamer",e),this.adapter=t,this.downsampleFactor=1}get keys(){return this.adapter.keys}async next(){try{return{done:!1,value:await this.read()}}catch(e){if(ge.matches(e))return{done:!0,value:void 0};throw e}}async read(){return this.adapter.adapt(new J((await this.stream.receive()).frame))}async update(e){await this.adapter.update(e),this.stream.send({keys:this.adapter.keys,downSampleFactor:this.downsampleFactor})}close(){this.stream.closeSend()}[Symbol.asyncIterator](){return this}}class Sn{constructor(e,t){l(this,"wrapped_",null),l(this,"breaker"),l(this,"opener"),l(this,"config"),this.opener=e,Array.isArray(t)||typeof t!="object"?this.config={channels:t,downSampleFactor:1}:this.config=t,this.breaker=new nc.Breaker({maxRetries:5e3,baseInterval:O.seconds(1),scale:1})}static async open(e,t){const n=new Sn(e,t);return await n.runStreamer(),n}async runStreamer(){for(;;)try{this.wrapped_!=null&&this.wrapped_.close(),this.wrapped_=await this.opener(this.config),this.breaker.reset();return}catch(e){if(this.wrapped_=null,!await this.breaker.wait())throw e;continue}}get wrapped(){if(this.wrapped_==null)throw new Error("stream closed");return this.wrapped_}async update(e){this.config.channels=e;try{await this.wrapped.update(e)}catch{return await this.runStreamer(),await this.update(e)}}async next(){try{return{done:!1,value:await this.read()}}catch(e){if(ge.matches(e))return{done:!0,value:void 0};throw e}}async read(){try{const e=await this.wrapped.read();return this.breaker.reset(),e}catch(e){if(ge.matches(e))throw e;return await this.runStreamer(),await this.read()}}close(){this.wrapped.close()}get keys(){return this.wrapped.keys}[Symbol.asyncIterator](){return this}}class Me extends tt.Observer{constructor(e,t){super(t),l(this,"streamer"),l(this,"closePromise"),this.streamer=e,this.closePromise=this.stream()}async close(){this.streamer.close(),await this.closePromise}async stream(){for await(const e of this.streamer)this.notify(e)}}const Cw=s=>new A({type:ai,key:s.toString()}),_a=s=>Array.isArray(s)||typeof s!="object"||typeof s=="object"&&"key"in s?{channels:s}:s;let sl=class{constructor(s,e,t){l(this,"streamClient"),l(this,"retriever"),l(this,"deleter"),this.streamClient=s,this.retriever=t,this.deleter=new dw(e)}async openIterator(s,e,t){return await Qc._open(s,e,this.retriever,this.streamClient,t)}async openWriter(s){return await Zc._open(this.retriever,this.streamClient,_a(s))}async openStreamer(s){return await tl(this.retriever,this.streamClient,_a(s))}async write(s,e,t){if(t==null){const r=e,a=await this.openWriter({start:s,channels:Object.keys(r),mode:St.Persist,errOnUnauthorized:!0,enableAutoCommit:!0,autoIndexPersistInterval:O.MAX});await a.write(r),await a.commit(),await a.close();return}const n=await this.openWriter({start:s,channels:e,mode:St.Persist,errOnUnauthorized:!0,enableAutoCommit:!0,autoIndexPersistInterval:O.MAX});await n.write(e,t),await n.close()}async read(s,e){const{single:t}=Ie(e),n=await this.readFrame(s,e);return t?n.get(e):n}async readFrame(s,e){const t=await this.openIterator(s,e),n=new J;try{for await(const r of t)n.push(r)}finally{await t.close()}return n}async delete(s,e){const{normalized:t,variant:n}=Ie(s);return n==="keys"?await this.deleter.delete({keys:t,bounds:e}):await this.deleter.delete({names:t,bounds:e})}};const Bw=Object.freeze(Object.defineProperty({__proto__:null,ALWAYS_INDEX_PERSIST_ON_AUTO_COMMIT:yw,AUTO_SPAN:Br,Client:sl,Frame:J,HardenedStreamer:Sn,Iterator:Qc,ONTOLOGY_TYPE:ai,ObservableStreamer:Me,Writer:Zc,WriterClosedError:Cr,WriterCommand:zt,WriterMode:St,createStreamOpener:el,frameZ:un,ontologyID:Cw,openStreamer:tl,seriesFromPayload:mc,seriesToPayload:wc},Symbol.toStringTag,{value:"Module"})),jw=st.ABSOLUTE_AUTHORITY,Rw=st.ZERO_AUTHORITY,Mw=st.stateZ(i.z.number()),Pw=s=>{var e,t;return s.to==null?`${(e=s.from)==null?void 0:e.resource} - ${(t=s.from)==null?void 0:t.subject.name} -> released`:s.from==null?`${s.to.resource} - released -> ${s.to.subject.name} (${s.to.authority.toString()})`:`${s.to.resource} - ${s.from.subject.name} -> ${s.to.subject.name} (${s.to.authority.toString()})`},Dw=i.z.object({transfers:i.z.array(st.transferZ)});class nl extends Me{constructor(e){super(e,t=>{const n=this.codec.decode(t.series[0].buffer,Dw);return this.merge(n),[n.transfers,!0]}),l(this,"states"),l(this,"codec"),this.states=new Map,this.codec=new rt.JSONCodec}subjects(){const e=new Map;return this.states.forEach(t=>e.set(t.subject.key,t.subject)),Array.from(e.values())}merge(e){e.transfers.forEach(t=>{t.from==null&&t.to==null&&console.warn("Invalid transfer: ",t),t.to==null?this.states.delete(t.from.resource):this.states.set(t.to.resource,t.to)})}}const qa="sy_node_1_control";let rl=class{constructor(s){l(this,"framer"),this.framer=s}async openStateTracker(){const s=await Sn.open(async()=>await this.framer.openStreamer(qa),qa);return new nl(s)}};const $w=Object.freeze(Object.defineProperty({__proto__:null,ABSOLUTE_AUTHORITY:jw,Client:rl,StateTracker:nl,ZERO_AUTHORITY:Rw,stateZ:Mw,transferString:Pw},Symbol.toStringTag,{value:"Module"}));let Lw=class{constructor(s,e,t){l(this,"tasks"),l(this,"racks"),l(this,"devices"),this.tasks=s,this.racks=e,this.devices=t}};const It=async(s,e,t,n)=>{const r=await s.openStreamer([e,t]),a=o=>{const c=[];return t!=null&&c.push(...o.get(t).series.flatMap(h=>n("delete",h))),e!=null&&c.push(...o.get(e).series.flatMap(h=>n("set",h))),[c,c.length>0]};return new Me(r,a)},Fw="sy_device_set",_w="sy_device_delete",Wa="sy_device_state",_n="/hardware/device/retrieve",qw="/hardware/device/create",Ww="/hardware/device/delete",Vw=i.z.object({devices:gg.array()}),Yw=i.z.object({devices:fn.array()}),Zw=i.z.object({keys:dn.array()}),Kw=i.z.object({}),qn=i.z.object({keys:dn.array().optional(),names:i.z.string().array().optional(),makes:i.z.string().array().optional(),models:i.z.string().array().optional(),locations:i.z.string().array().optional(),racks:it.array().optional(),search:i.z.string().optional(),limit:i.z.number().optional(),offset:i.z.number().optional(),ignoreNotFound:i.z.boolean().optional(),includeState:i.z.boolean().optional()}),Wn=i.z.object({devices:te(fn)});let Hw=class{constructor(s,e){l(this,"type",Sc),l(this,"client"),l(this,"frameClient"),this.client=s,this.frameClient=e}async retrieve(s,e){const t=!Array.isArray(s),n=await w(this.client,_n,{keys:b(s),...e},qn,Wn);return vn("Device",s,n.devices,t),t?n.devices[0]:n.devices}async search(s,e){return(await w(this.client,_n,{search:s,...e},qn,Wn)).devices}async page(s,e,t){return(await w(this.client,_n,{offset:s,limit:e,...t},qn,Wn)).devices}async create(s){const e=!Array.isArray(s),t=await w(this.client,qw,{devices:b(s)},Vw,Yw);return e?t.devices[0]:t.devices}async delete(s){await w(this.client,Ww,{keys:b(s)},Zw,Kw)}async openDeviceTracker(){return await It(this.frameClient,Fw,_w,Gw)}async openStateObserver(){return new Me(await this.frameClient.openStreamer(Wa),s=>{const e=s.get(Wa);return e.length===0?[null,!1]:[e.parseJSON(zc),!0]})}newSearcherWithOptions(s){return{type:this.type,search:async e=>await this.search(e,s),retrieve:async e=>await this.retrieve(e,s),page:async(e,t)=>await this.page(e,t,s)}}};const Gw=(s,e)=>s==="delete"?e.toStrings().map(t=>({variant:s,key:t,value:void 0})):e.parseJSON(fn).map(t=>({variant:s,key:t.key,value:t})),Vn="/hardware/rack/retrieve",Jw="/hardware/rack/create",Xw="/hardware/rack/delete",Va="sy_rack_state",Yn=i.z.object({keys:it.array().optional(),names:i.z.string().array().optional(),search:i.z.string().optional(),embedded:i.z.boolean().optional(),hostIsNode:i.z.boolean().optional(),limit:i.z.number().optional(),offset:i.z.number().optional(),includeState:i.z.boolean().optional()}),Zn=i.z.object({racks:te(oi)}),Qw=i.z.object({racks:pg.array()}),eb=i.z.object({racks:oi.array()}),tb=i.z.object({keys:it.array()}),sb=i.z.object({});let nb=class{constructor(s,e,t){l(this,"type",vc),l(this,"client"),l(this,"tasks"),l(this,"frameClient"),this.client=s,this.tasks=e,this.frameClient=t}async delete(s){await w(this.client,Xw,{keys:b(s)},tb,sb)}async create(s){const e=!Array.isArray(s),t=await w(this.client,Jw,{racks:b(s)},Qw,eb),n=this.sugar(t.racks);return e?n[0]:n}async search(s){const e=await w(this.client,Vn,{search:s},Yn,Zn);return this.sugar(e.racks)}async page(s,e){const t=await w(this.client,Vn,{offset:s,limit:e},Yn,Zn);return this.sugar(t.racks)}async retrieve(s,e){const{variant:t,normalized:n,single:r}=bi(s,{string:"names",number:"keys"}),a=await w(this.client,Vn,{[t]:n,includeState:e==null?void 0:e.includeState},Yn,Zn),o=this.sugar(a.racks);return vn("Rack",s,o,r),r?o[0]:o}async openStateObserver(){return new Me(await this.frameClient.openStreamer(Va),s=>{const e=s.get(Va);return e.length===0?[[],!1]:[e.parseJSON(bc),!0]})}sugar(s){return s.map(({key:e,name:t,state:n})=>new rb(e,t,this.tasks,n))}};class rb{constructor(e,t,n,r){l(this,"key"),l(this,"name"),l(this,"state"),l(this,"tasks"),this.key=e,this.name=t,this.tasks=n,this.state=r}async listTasks(){return await this.tasks.retrieve(this.key)}async retrieveTaskByName(e){return await this.tasks.retrieveByName(e,this.key)}async retrieveTaskByType(e){return await this.tasks.retrieveByType(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 as="sy_task_state",dt="sy_task_cmd",ib="sy_task_set",ab="sy_task_delete",ut=new Error("Task not created"),il=async(s,e)=>{const t=await e.retrieveParents(s);return t.length===0?null:t[0]};class ob{constructor(e,t,n,r,a=!1,o=!1,c,h=null,d=null,f=null){l(this,"key"),l(this,"name"),l(this,"internal"),l(this,"type"),l(this,"config"),l(this,"snapshot"),l(this,"state"),l(this,"frameClient"),l(this,"ontologyClient"),l(this,"rangeClient"),this.key=e,this.name=t,this.type=n,this.config=r,this.internal=a,this.snapshot=o,c!==null&&(this.state=c),this.frameClient=h,this.ontologyClient=d,this.rangeClient=f}get payload(){return{key:this.key,name:this.name,type:this.type,config:this.config,state:this.state,internal:this.internal}}get ontologyID(){return zb(this.key)}async executeCommand(e,t){if(this.frameClient==null)throw ut;const n=await this.frameClient.openWriter(dt),r=Py.create();return await n.write(dt,[{task:this.key,type:e,key:r,args:t}]),await n.close(),r}async executeCommandSync(e,t,n){if(this.frameClient==null)throw ut;const r=await this.frameClient.openStreamer(as),a=await this.executeCommand(e,t);let o;const c=new Promise(h=>setTimeout(()=>h(!1),new O(n).milliseconds));for(;;){const h=await Promise.any([r.read(),c]);if(h===!1)throw new Error("Command timed out");const d=Qs.safeParse(h.at(-1).sy_task_state);if(d.success){if(o=d.data,o.key===a)break}else throw d.error}return r.close(),o}async openStateObserver(){if(this.frameClient==null)throw ut;return new Me(await this.frameClient.openStreamer(as),e=>{const t=e.get(as);if(t.length===0)return[null,!1];const n=Qs.safeParse(t.at(-1));if(!n.success)return console.error(n.error),[null,!1];const r=n.data;return r.task!==this.key?[null,!1]:[r,!0]})}async openCommandObserver(){if(this.frameClient==null)throw ut;return new Me(await this.frameClient.openStreamer(dt),e=>{const t=e.get(dt);if(t.length===0)return[null,!1];const n=Tc.safeParse(t.at(-1));if(!n.success)return console.error(n.error),[null,!1];const r=n.data;return r.task!==this.key?[null,!1]:[r,!0]})}async snapshottedTo(){if(this.ontologyClient==null||this.rangeClient==null)throw ut;return this.snapshot?await il(this.key,this.ontologyClient):null}}const cb=i.z.object({rack:it.optional(),keys:at.array().optional(),names:i.z.string().array().optional(),types:i.z.string().array().optional(),includeState:i.z.boolean().optional(),offset:i.z.number().optional(),limit:i.z.number().optional()}),lb=i.z.object({tasks:te(yn)}),hb="/hardware/task/retrieve",ub="/hardware/task/create",db="/hardware/task/delete",fb="/hardware/task/copy",yb=i.z.object({tasks:wg.array()}),pb=i.z.object({tasks:yn.array()}),gb=i.z.object({keys:at.array()}),mb=i.z.object({}),wb=i.z.object({key:at,name:i.z.string(),snapshot:i.z.boolean()}),bb=i.z.object({task:yn});let vb=class{constructor(s,e,t,n){l(this,"type",li),l(this,"client"),l(this,"frameClient"),l(this,"ontologyClient"),l(this,"rangeClient"),this.client=s,this.frameClient=e,this.ontologyClient=t,this.rangeClient=n}async create(s){const e=!Array.isArray(s),t=await w(this.client,ub,{tasks:b(s)},yb,pb),n=this.sugar(t.tasks);return e?n[0]:n}async delete(s){await w(this.client,db,{keys:b(s)},gb,mb)}async search(s){return await this.execRetrieve({keys:[s]})}async page(s,e){return await this.execRetrieve({offset:s,limit:e})}async list(s={}){return this.sugar(await this.execRetrieve(s))}async retrieve(s,e){const{single:t,normalized:n,variant:r}=bi(s,{number:"rack",string:"keys"},{convertNumericStrings:!1}),a={...e};r==="rack"?a.rack=s:a.keys=n;const o=await this.execRetrieve(a),c=this.sugar(o);return t&&r!=="rack"?c[0]:c}async copy(s,e,t){const n=await w(this.client,fb,{key:s,name:e,snapshot:t},wb,bb);return this.sugar([n.task])[0]}async retrieveByName(s,e){const t=await this.execRetrieve({names:[s],rack:e});return vn("Task",s,t,!0),this.sugar(t)[0]}async retrieveByType(s,e){const t=await this.execRetrieve({types:[s],rack:e});return this.sugar(t)}async retrieveSnapshottedTo(s){if(this.ontologyClient==null)throw ut;return await il(s,this.ontologyClient)}async execRetrieve(s){return(await w(this.client,hb,s,cb,lb)).tasks}sugar(s){const e=!Array.isArray(s),t=b(s).map(({key:n,name:r,type:a,config:o,state:c,internal:h,snapshot:d})=>new ob(n,r,a,o,h,d,c,this.frameClient,this.ontologyClient,this.rangeClient));return e?t[0]:t}async openTracker(){return await It(this.frameClient,ib,ab,(s,e)=>Array.from(e).map(t=>({variant:s,key:t.toString(),value:t.toString()})))}async openStateObserver(){return new Me(await this.frameClient.openStreamer(as),s=>{const e=s.get(as);if(e.length===0)return[null,!1];const t=Qs.safeParse(e.at(-1));return t.success?[t.data,!0]:(console.error(t.error),[null,!1])})}async openCommandObserver(){return new Me(await this.frameClient.openStreamer(dt),s=>{const e=s.get(dt);if(e.length===0)return[null,!1];const t=Tc.safeParse(e.at(-1));return t.success?[t.data,!0]:(console.error(t.error),[null,!1])})}};const zb=s=>new A({type:li,key:s}),Sb=i.z.object({keys:Ot.array().optional(),for:ce.optional(),search:i.z.string().optional(),offset:i.z.number().optional(),limit:i.z.number().optional()}),Tb=i.z.object({labels:te(pn)}),al=class ol{constructor(e){l(this,"client"),this.client=e}async retrieve(e){return await this.execute({keys:b(e)})}async retrieveFor(e){return await this.execute({for:e})}async search(e){return await this.execute({search:e})}async page(e,t){return await this.execute({offset:e,limit:t})}async execute(e){const[t,n]=await this.client.send(ol.ENDPOINT,e,Sb,Tb);if(n!=null)throw n;return t.labels}};l(al,"ENDPOINT","/label/retrieve");let Ob=al;const kb=pn.extend({key:Ot.optional()}),xb=i.z.object({labels:kb.array()}),Ib=i.z.object({labels:pn.array()}),Eb=i.z.object({keys:Ot.array()}),cl=i.z.object({id:ce,labels:Ot.array(),replace:i.z.boolean().optional()}),Nb=cl.omit({replace:!0}),Kn=i.z.object({}),Ab="/label/create",Ub="/label/delete",Cb="/label/set",Bb="/label/remove";let jb=class{constructor(s){l(this,"client"),this.client=s}async create(s){return(await w(this.client,Ab,{labels:b(s)},xb,Ib)).labels}async delete(s){await w(this.client,Ub,{keys:b(s)},Eb,Kn)}async set(s,e,{replace:t}={}){await w(this.client,Cb,{id:s,labels:e,replace:t},cl,Kn)}async remove(s,e){await w(this.client,Bb,{id:s,labels:e},Nb,Kn)}};const Rb="sy_label_set",Mb="sy_label_delete";let Pb=class{constructor(s,e,t){l(this,"type","label"),l(this,"retriever"),l(this,"writer"),l(this,"frameClient"),l(this,"ontology"),this.writer=new jb(s),this.retriever=new Ob(s),this.frameClient=e,this.ontology=t}async search(s){return await this.retriever.search(s)}async retrieve(s){const e=Array.isArray(s),t=await this.retriever.retrieve(s);return e?t:t[0]}async retrieveFor(s){return await this.retriever.retrieveFor(new A(s))}async label(s,e,t={}){await this.writer.set(new A(s),e,t)}async removeLabels(s,e){await this.writer.remove(new A(s),e)}async page(s,e){return await this.retriever.page(s,e)}async create(s){const e=Array.isArray(s),t=await this.writer.create(s);return e?t:t[0]}async delete(s){await this.writer.delete(s)}async openChangeTracker(){return await It(this.frameClient,Rb,Mb,Db)}async trackLabelsOf(s){const e=new tt.Observer,t=(await this.retrieveFor(s)).map(n=>({id:$b(n.key),key:n.key,name:n.name,data:n}));return(await this.ontology.openDependentTracker({target:new A(s),dependents:t,relationshipType:"labeled_by"})).onChange(n=>e.notify(n.map(r=>{var a,o;return{key:r.id.key,color:(a=r.data)==null?void 0:a.color,name:(o=r.data)==null?void 0:o.name}}))),e}};const Db=(s,e)=>s==="delete"?e.toUUIDs().map(t=>({variant:s,key:t})):e.parseJSON(pn).map(t=>({variant:s,key:t.key,value:t})),$b=s=>new A({type:Oc,key:s}),Lb="sy_range_alias_set",Fb="sy_range_alias_delete",_b=i.z.object({range:oe,aliases:i.z.string().array()}),qb=i.z.object({aliases:i.z.record(i.z.string(),se)}),Wb=i.z.object({range:oe,aliases:i.z.record(se.or(i.z.string()),i.z.string())}),Vb=i.z.unknown(),Yb=i.z.object({range:oe,channels:se.array()}),Zb=i.z.unknown(),Kb=i.z.object({range:oe}),Hb=i.z.object({aliases:i.z.record(i.z.string(),i.z.string())}),es=class ts{constructor(e,t,n){l(this,"frameClient"),l(this,"cache",new Map),l(this,"client"),l(this,"rangeKey"),this.rangeKey=e,this.cache=new Map,this.client=n,this.frameClient=t}async resolve(e){const t=[],n=typeof e=="string",r={};if(n){const o=this.cache.get(e);if(o!=null)return o;t.push(e)}else e.forEach(o=>{const c=this.cache.get(o);c!=null?r[o]=c:t.push(o)});if(t.length===0)return r;const a=await w(this.client,ts.RESOLVE_ENDPOINT,{range:this.rangeKey,aliases:t},_b,qb);return Object.entries(a.aliases).forEach(([o,c])=>this.cache.set(o,c)),n?a.aliases[t[0]]:{...r,...a.aliases}}async set(e){await w(this.client,ts.SET_ENDPOINT,{range:this.rangeKey,aliases:e},Wb,Vb)}async list(){return(await w(this.client,ts.LIST_ENDPOINT,{range:this.rangeKey},Kb,Hb)).aliases}async delete(e){await w(this.client,ts.DELETE_ENDPOINT,{range:this.rangeKey,channels:e},Yb,Zb)}async openChangeTracker(){return await It(this.frameClient,Lb,Fb,Qb(this.rangeKey))}};l(es,"SET_ENDPOINT","/range/alias/set"),l(es,"RESOLVE_ENDPOINT","/range/alias/resolve"),l(es,"LIST_ENDPOINT","/range/alias/list"),l(es,"DELETE_ENDPOINT","/range/alias/delete");let Gb=es;const Jb=i.z.object({range:oe,channel:se,alias:i.z.string()}),Xb="---",Qb=s=>(e,t)=>e==="delete"?t.toStrings().filter(n=>n.split(Xb)[0]===s).map(n=>({variant:e,key:n,value:void 0})):t.parseJSON(Jb).map(n=>({variant:e,key:n.alias,value:n})),ki=i.z.object({range:oe,key:i.z.string(),value:i.z.string()}),ev=i.z.object({range:oe,keys:i.z.string().array()}),tv=i.z.object({pairs:te(ki)}),sv=i.z.object({range:oe,pairs:ki.array()}),nv=i.z.object({range:oe,keys:i.z.string().array()}),Ys=class Zs{constructor(e,t,n){l(this,"rangeKey"),l(this,"client"),l(this,"frameClient"),this.rangeKey=e,this.client=t,this.frameClient=n}async get(e){const t=await w(this.client,Zs.GET_ENDPOINT,{range:this.rangeKey,keys:b(e)},ev,tv);return typeof e=="string"?t.pairs[0].value:Object.fromEntries(t.pairs.map(n=>[n.key,n.value]))}async list(){return this.get([])}async set(e,t=""){let n;rn(e)?n=Object.entries(e).map(([r,a])=>({range:this.rangeKey,key:r,value:a})):n=[{range:this.rangeKey,key:e,value:t}],await w(this.client,Zs.SET_ENDPOINT,{range:this.rangeKey,pairs:n},sv,i.z.unknown())}async delete(e){await w(this.client,Zs.DELETE_ENDPOINT,{range:this.rangeKey,keys:b(e)},nv,i.z.unknown())}async openTracker(){return await It(this.frameClient,"sy_range_kv_set","sy_range_kv_delete",(e,t)=>e==="delete"?t.toStrings().map(n=>{const[r,a]=n.split("<--->",2);return{variant:e,key:n,value:{range:r,key:a,value:""}}}):t.parseJSON(ki).map(n=>({variant:e,key:`${n.range}${n.key}`,value:n})))}};l(Ys,"GET_ENDPOINT","/range/kv/get"),l(Ys,"SET_ENDPOINT","/range/kv/set"),l(Ys,"DELETE_ENDPOINT","/range/kv/delete");let Rr=Ys;class ll{constructor(e,t=V.ZERO,n,r,a,o,c,h,d,f,u){l(this,"key"),l(this,"name"),l(this,"kv"),l(this,"timeRange"),l(this,"color"),l(this,"channels"),l(this,"aliaser"),l(this,"frameClient"),l(this,"labelClient"),l(this,"ontologyClient"),l(this,"rangeClient"),this.key=n,this.name=e,this.timeRange=t,this.frameClient=a,this.color=r,this.kv=o,this.aliaser=c,this.channels=h,this.labelClient=d,this.ontologyClient=f,this.rangeClient=u}get ontologyID(){return Ze(this.key)}get payload(){return{key:this.key,name:this.name,timeRange:this.timeRange,color:this.color}}async setAlias(e,t){const n=await this.channels.retrieve(e);if(n.length===0)throw new Re(`Channel ${e} does not exist`);await this.aliaser.set({[n[0].key]:t})}async deleteAlias(...e){await this.aliaser.delete(e)}async listAliases(){return await this.aliaser.list()}async resolveAlias(e){return await this.aliaser.resolve(e)}async openAliasTracker(){return await this.aliaser.openChangeTracker()}async retrieveParent(){return this.rangeClient.retrieveParent(this.key)}async retrieveChildren(){const e=(await this.ontologyClient.retrieveChildren(this.ontologyID,{excludeFieldData:!0,types:["range"]})).map(t=>t.id.key);return await this.rangeClient.retrieve(e)}async read(e){return await this.frameClient.read(this.timeRange,e)}async labels(){return await this.labelClient.retrieveFor(Ze(this.key))}async addLabel(...e){await this.labelClient.label(Ze(this.key),e)}async removeLabel(...e){await this.labelClient.removeLabels(Ze(this.key),e)}async openChildRangeTracker(){const e=new tt.Observer,t=(await this.retrieveChildren()).map(r=>{const a=Ze(r.key);return{id:a,key:a.toString(),name:r.name,data:r.payload}}),n=await this.ontologyClient.openDependentTracker({target:this.ontologyID,dependents:t,resourceType:"range"});return n.onChange(r=>e.notify(this.rangeClient.resourcesToRanges(r))),e.setCloser(async()=>await n.close()),e}async openParentRangeTracker(){const e=new tt.Observer,t=await this.retrieveParent();if(t==null)return null;const n=Ze(t.key),r={id:n,key:n.toString(),name:t.name,data:t.payload},a=await this.ontologyClient.openDependentTracker({target:this.ontologyID,dependents:[r],relationshipDirection:"to"});return a.onChange(o=>{const c=this.rangeClient.resourcesToRanges(o);if(c.length===0)return;const h=c[0];e.notify(h)}),e.setCloser(async()=>await a.close()),e}}const rv=(s,e)=>$y(s.timeRange,e.timeRange),iv=i.z.object({keys:oe.array().optional(),names:i.z.array(i.z.string()).optional(),term:i.z.string().optional(),overlapsWith:V.z.optional(),limit:i.z.number().int().optional(),offset:i.z.number().int().optional(),hasLabels:Ot.array().optional()}),av="/range/retrieve",ov=i.z.object({ranges:te(zs)});let hl=class{constructor(s,e,t,n,r,a){l(this,"type","range"),l(this,"frameClient"),l(this,"writer"),l(this,"unaryClient"),l(this,"channels"),l(this,"labelClient"),l(this,"ontologyClient"),this.frameClient=s,this.writer=e,this.unaryClient=t,this.channels=n,this.labelClient=r,this.ontologyClient=a}async create(s,e){const t=!Array.isArray(s),n=this.sugarMany(await this.writer.create(b(s),e));return t?n[0]:n}async rename(s,e){await this.writer.rename(s,e)}async delete(s){await this.writer.delete(b(s))}async search(s){return this.sugarMany(await this.execRetrieve({term:s}))}async page(s,e){return this.sugarMany(await this.execRetrieve({offset:s,limit:e}))}async retrieve(s){if(typeof s=="object"&&"start"in s)return await this.execRetrieve({overlapsWith:new V(s)});const{single:e,actual:t,variant:n,normalized:r,empty:a}=xc(s);if(a)return[];const o=await this.execRetrieve({[n]:r});if(!e)return o;if(o.length===0)throw new nt(`range matching ${t} not found`);if(o.length>1)throw new vt(`multiple ranges matching ${t} found`);return o[0]}getKV(s){return new Rr(s,this.unaryClient,this.frameClient)}async execRetrieve(s){const{ranges:e}=await w(this.unaryClient,av,s,iv,ov);return this.sugarMany(e)}async retrieveParent(s){const e=await this.ontologyClient.retrieveParents(Ze(s));if(e.length===0)return null;const t=e[0];return t.id.type!=="range"?null:await this.retrieve(t.id.key)}sugarOne(s){return new ll(s.name,s.timeRange,s.key,s.color,this.frameClient,new Rr(s.key,this.unaryClient,this.frameClient),new Gb(s.key,this.frameClient,this.unaryClient),this.channels,this.labelClient,this.ontologyClient,this)}sugarMany(s){return s.map(e=>this.sugarOne(e))}async openTracker(){return await It(this.frameClient,"sy_range_set","sy_range_delete",(s,e)=>s==="delete"?e.toUUIDs().map(t=>({variant:s,key:t,value:void 0})):this.sugarMany(e.parseJSON(zs)).map(t=>({variant:s,key:t.key,value:t})))}resourcesToRanges(s){return s.map(e=>this.resourceToRange(e))}resourceToRange(s){var e,t,n;return this.sugarOne({key:s.id.key,name:(e=s.data)==null?void 0:e.name,timeRange:new V((t=s.data)==null?void 0:t.timeRange),color:(n=s.data)==null?void 0:n.color})}};const Ze=s=>new A({type:ui,key:s}),cv=s=>new A({type:di,key:s}),lv=i.z.object({ranges:zs.array()}),hv=i.z.object({parent:ce.optional(),ranges:kc.array()}),uv=i.z.object({keys:oe.array()}),dv=i.z.object({}),fv=i.z.object({key:oe,name:hi}),yv=i.z.object({}),pv="/range/create",gv="/range/delete",mv="/range/rename";class ul{constructor(e){l(this,"client"),this.client=e}async rename(e,t){await w(this.client,mv,{key:e,name:t},fv,yv)}async create(e,t){return(await w(this.client,pv,{ranges:e,...t},hv,lv)).ranges}async delete(e){await w(this.client,gv,{keys:e},uv,dv)}}const wv=Object.freeze(Object.defineProperty({__proto__:null,ALIAS_ONTOLOGY_TYPE:di,Client:hl,KV:Rr,ONTOLOGY_TYPE:ui,Range:ll,Writer:ul,aliasOntologyID:cv,analyzeParams:xc,keyZ:oe,nameZ:hi,newZ:kc,ontologyID:Ze,payloadZ:zs,sort:rv},Symbol.toStringTag,{value:"Module"})),bv="/api/v1/";class vv{constructor(e,t={},n=!1){l(this,"url"),l(this,"unary"),l(this,"stream"),l(this,"secure"),this.secure=n,this.url=e.child(bv);const r=new rt.JSONCodec;this.unary=Wd(new qd(this.url,r,this.secure),t),this.stream=new Gd(this.url,r,this.secure)}use(...e){this.unary.use(...e),this.stream.use(...e)}}const zv="/workspace/lineplot/retrieve",Sv="/workspace/lineplot/create",Tv="/workspace/lineplot/rename",Ov="/workspace/lineplot/set-data",kv="/workspace/lineplot/delete",xv=i.z.object({keys:Ss.array()}),Iv=i.z.object({workspace:De,linePlots:zg.array()}),Ev=i.z.object({key:Ss,name:i.z.string()}),Nv=i.z.object({key:Ss,data:i.z.string()}),Av=i.z.object({keys:Ss.array()}),Uv=i.z.object({linePlots:te(fi)}),Cv=i.z.object({linePlots:fi.array()}),Hn=i.z.object({});let Bv=class{constructor(s){l(this,"client"),this.client=s}async create(s,e){const t=Array.isArray(e),n=await w(this.client,Sv,{workspace:s,linePlots:b(e)},Iv,Cv);return t?n.linePlots:n.linePlots[0]}async rename(s,e){await w(this.client,Tv,{key:s,name:e},Ev,Hn)}async setData(s,e){await w(this.client,Ov,{key:s,data:JSON.stringify(e)},Nv,Hn)}async retrieve(s){const e=Array.isArray(s),t=await w(this.client,zv,{keys:b(s)},xv,Uv);return e?t.linePlots:t.linePlots[0]}async delete(s){await w(this.client,kv,{keys:b(s)},Av,Hn)}};const jv="/workspace/log/retrieve",Rv="/workspace/log/create",Mv="/workspace/log/rename",Pv="/workspace/log/set-data",Dv="/workspace/log/delete",$v=i.z.object({keys:Ts.array()}),Lv=i.z.object({workspace:De,logs:Tg.array()}),Fv=i.z.object({key:Ts,name:i.z.string()}),_v=i.z.object({key:Ts,data:i.z.string()}),qv=i.z.object({keys:Ts.array()}),Wv=i.z.object({logs:yi.array()}),Vv=i.z.object({logs:yi.array()}),Gn=i.z.object({});let Yv=class{constructor(s){l(this,"client"),this.client=s}async create(s,e){const t=Array.isArray(e),n=await w(this.client,Rv,{workspace:s,logs:b(e)},Lv,Vv);return t?n.logs:n.logs[0]}async rename(s,e){await w(this.client,Mv,{key:s,name:e},Fv,Gn)}async setData(s,e){await w(this.client,Pv,{key:s,data:JSON.stringify(e)},_v,Gn)}async retrieve(s){const e=Array.isArray(s),t=await w(this.client,jv,{keys:b(s)},$v,Wv);return e?t.logs:t.logs[0]}async delete(s){await w(this.client,Dv,{keys:b(s)},qv,Gn)}};const Zv="/workspace/schematic/retrieve",Kv="/workspace/schematic/create",Hv="/workspace/schematic/rename",Gv="/workspace/schematic/set-data",Jv="/workspace/schematic/delete",Xv="/workspace/schematic/copy",Qv=i.z.object({keys:xt.array()}),ez=i.z.object({workspace:De,schematics:Ig.array()}),tz=i.z.object({key:xt,name:i.z.string()}),sz=i.z.object({key:xt,data:i.z.string()}),nz=i.z.object({keys:xt.array()}),rz=i.z.object({key:xt,name:i.z.string(),snapshot:i.z.boolean()}),iz=i.z.object({schematics:te(Ec)}),az=i.z.object({schematics:Ec.array()}),oz=i.z.object({schematic:gi}),Jn=i.z.object({});let cz=class{constructor(s){l(this,"client"),this.client=s}async create(s,e){const t=Array.isArray(e),n=await w(this.client,Kv,{workspace:s,schematics:b(e)},ez,az);return t?n.schematics:n.schematics[0]}async rename(s,e){await w(this.client,Hv,{key:s,name:e},tz,Jn)}async setData(s,e){await w(this.client,Gv,{key:s,data:JSON.stringify(e)},sz,Jn)}async retrieve(s){const e=Array.isArray(s),t=await w(this.client,Zv,{keys:b(s)},Qv,iz);return e?t.schematics:t.schematics[0]}async delete(s){await w(this.client,Jv,{keys:b(s)},nz,Jn)}async copy(s,e,t){return(await w(this.client,Xv,{key:s,name:e,snapshot:t},rz,oz)).schematic}};const lz="/workspace/table/retrieve",hz="/workspace/table/create",uz="/workspace/table/rename",dz="/workspace/table/set-data",fz="/workspace/table/delete",yz=i.z.object({keys:Os.array()}),pz=i.z.object({workspace:De,tables:Ng.array()}),gz=i.z.object({key:Os,name:i.z.string()}),mz=i.z.object({key:Os,data:i.z.string()}),wz=i.z.object({keys:Os.array()}),bz=i.z.object({tables:Ac.array()}),vz=i.z.object({tables:Ac.array()}),Xn=i.z.object({});let zz=class{constructor(s){l(this,"client"),this.client=s}async create(s,e){const t=Array.isArray(e),n=await w(this.client,hz,{workspace:s,tables:b(e)},pz,vz);return t?n.tables:n.tables[0]}async rename(s,e){await w(this.client,uz,{key:s,name:e},gz,Xn)}async setData(s,e){await w(this.client,dz,{key:s,data:JSON.stringify(e)},mz,Xn)}async retrieve(s){const e=Array.isArray(s),t=await w(this.client,lz,{keys:b(s)},yz,bz);return e?t.tables:t.tables[0]}async delete(s){await w(this.client,fz,{keys:b(s)},wz,Xn)}};const Ms="/workspace/retrieve",Sz="/workspace/create",Tz="/workspace/rename",Oz="/workspace/set-layout",kz="/workspace/delete",Ps=i.z.object({keys:De.array().optional(),search:i.z.string().optional(),author:kt.optional(),offset:i.z.number().optional(),limit:i.z.number().optional()}),xz=i.z.object({workspaces:kg.array()}),Iz=i.z.object({key:De,name:i.z.string()}),Ez=i.z.object({key:De,layout:i.z.string()}),Nz=i.z.object({keys:De.array()}),Ds=i.z.object({workspaces:te(pi)}),Az=i.z.object({workspaces:xg.array()}),Qn=i.z.object({});class Uz{constructor(e){l(this,"type",Ic),l(this,"schematic"),l(this,"linePlot"),l(this,"log"),l(this,"table"),l(this,"client"),this.client=e,this.schematic=new cz(e),this.linePlot=new Bv(e),this.log=new Yv(e),this.table=new zz(e)}async create(e){const t=Array.isArray(e),n=await w(this.client,Sz,{workspaces:b(e)},xz,Az);return t?n.workspaces:n.workspaces[0]}async rename(e,t){await w(this.client,Tz,{key:e,name:t},Iz,Qn)}async setLayout(e,t){await w(this.client,Oz,{key:e,layout:JSON.stringify(t)},Ez,Qn)}async retrieve(e){const t=Array.isArray(e),n=await w(this.client,Ms,{keys:b(e)},Ps,Ds);return t?n.workspaces:n.workspaces[0]}async retrieveByAuthor(e){return(await w(this.client,Ms,{author:e},Ps,Ds)).workspaces}async search(e){return(await w(this.client,Ms,{search:e},Ps,Ds)).workspaces}async page(e,t){return(await w(this.client,Ms,{offset:e,limit:t},Ps,Ds)).workspaces}async delete(e){await w(this.client,kz,{keys:b(e)},Nz,Qn)}}const dl=i.z.object({host:i.z.string({error:"Host is required"}).min(1,"Host is required"),port:i.z.number({error:"Port is required"}).or(i.z.string({error:"Port is required"})),username:i.z.string().min(1,"Username is required"),password:i.z.string().min(1,"Password is required"),connectivityPollFrequency:O.z.default(O.seconds(30)),secure:i.z.boolean().optional().default(!1),name:i.z.string().optional(),retry:nc.breakerConfig.optional()});class fl extends sl{constructor(e){const t=dl.parse(e),{host:n,port:r,username:a,password:o,connectivityPollFrequency:c,secure:h,retry:d}=t,f=new vv(new hp({host:n,port:Number(r)}),d,h);f.use(yg);let u;a!=null&&o!=null&&(u=new iw(f.unary,{username:a,password:o}),f.use(u.middleware()));const T=new zi(new vi(f.unary)),k=new qc(f.unary,T);super(f.stream,f.unary,T),l(this,"createdAt"),l(this,"props"),l(this,"ranges"),l(this,"channels"),l(this,"auth"),l(this,"user"),l(this,"access"),l(this,"connectivity"),l(this,"ontology"),l(this,"workspaces"),l(this,"labels"),l(this,"hardware"),l(this,"control"),l(this,"transport"),l(this,"clientVersion","0.42.0"),this.createdAt=x.now(),this.props=t,this.auth=u,this.transport=f,this.channels=new Lc(this,T,f.unary,k),this.connectivity=new Yc(f.unary,c,this.clientVersion,t.name),this.control=new rl(this),this.ontology=new Xg(f.unary,this);const Y=new ul(this.transport.unary);this.labels=new Pb(this.transport.unary,this,this.ontology),this.ranges=new hl(this,Y,this.transport.unary,T,this.labels,this.ontology),this.access=new dm(this.transport.unary),this.user=new Jm(this.transport.unary),this.workspaces=new Uz(this.transport.unary);const U=new Hw(this.transport.unary,this),de=new vb(this.transport.unary,this,this.ontology,this.ranges),Ne=new nb(this.transport.unary,de,this);this.hardware=new Lw(de,Ne,U)}get key(){return this.createdAt.valueOf().toString()}close(){this.connectivity.stopChecking()}}l(fl,"connectivity",Yc);const Mr=(s,e,t="")=>{try{return s.parse(e)}catch(n){if(n instanceof i.z.ZodError){const r=n.issues.map(a=>a.path.length===0?a.message:`${a.path.join(".")}: ${a.message}`);throw new Error(`${t} - ${r.join(`
57
+ `)}`)}else throw n}};var Cz=Object.defineProperty,Bz=(s,e,t)=>e in s?Cz(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,H=(s,e,t)=>Bz(s,typeof e!="symbol"?e+"":e,t);const Pr=class yl{constructor(e,t,n="",r=!1){H(this,"_noop",!1),H(this,"key"),H(this,"path"),H(this,"serviceName"),this.key=e,this.path=t,this.serviceName=n,this._noop=r}child(e){return new yl(e,this.extendPath(e),this.serviceName,this.noop)}extendPath(e){return`${this.path}.${e}`}get noop(){return this._noop}};H(Pr,"NOOP",new Pr("","",""));let xi=Pr;const Dr=["debug","info","warn","error"],pl=s=>{const e=Dr.indexOf(s);return({level:t})=>Dr.indexOf(t)>=e},jz=s=>{const{include:e,exclude:t}=s;return({path:n})=>!(e!=null&&!e.some(r=>n.startsWith(r))||t!=null&&t.some(r=>n.startsWith(r)))},$r=class gl{constructor(e={}){H(this,"meta",xi.NOOP),H(this,"filters");const{filters:t=[]}=e;this.filters=t}filter(e){return!this.meta.noop&&this.filters.every(t=>t({key:this.meta.key,path:this.meta.path,level:e}))}child(e){const t=new gl({filters:this.filters});return t.meta=e,t}debug(e,t,n=!1){!this.filter("debug")&&!n||(t==null?console.log("%cDEBUG","color: #8c00f0;",this.meta.path,e):console.log("%cDEBUG","color: #8c00f0;",this.meta.path,e,$s(t)))}info(e,t,n=!1){!this.filter("info")&&!n||(t==null?console.log("%cINFO","color: #005eff;",this.meta.path,e):console.log("%cINFO","color: #005eff;",this.meta.path,e,$s(t)))}warn(e,t,n=!1){!this.filter("warn")&&!n||(t==null?console.warn("WARN",this.meta.path,e):console.warn("WARN",this.meta.path,e,$s(t)))}error(e,t,n=!1){!this.filter("error")&&!n||(t==null?console.error("ERROR",this.meta.path,e):console.error("ERROR",this.meta.path,e,$s(t)))}};H($r,"NOOP",new $r);let Ii=$r;const $s=s=>typeof s=="function"?s():s;var Rz=typeof globalThis=="object"?globalThis:typeof self=="object"?self:typeof window=="object"?window:typeof global=="object"?global:{},Xe="1.9.0",Ya=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function Mz(s){var e=new Set([s]),t=new Set,n=s.match(Ya);if(!n)return function(){return!1};var r={major:+n[1],minor:+n[2],patch:+n[3],prerelease:n[4]};if(r.prerelease!=null)return function(c){return c===s};function a(c){return t.add(c),!1}function o(c){return e.add(c),!0}return function(c){if(e.has(c))return!0;if(t.has(c))return!1;var h=c.match(Ya);if(!h)return a(c);var d={major:+h[1],minor:+h[2],patch:+h[3],prerelease:h[4]};return d.prerelease!=null||r.major!==d.major?a(c):r.major===0?r.minor===d.minor&&r.patch<=d.patch?o(c):a(c):r.minor<=d.minor?o(c):a(c)}}var Pz=Mz(Xe),Dz=Xe.split(".")[0],us=Symbol.for("opentelemetry.js.api."+Dz),ds=Rz;function Ei(s,e,t,n){var r;n===void 0&&(n=!1);var a=ds[us]=(r=ds[us])!==null&&r!==void 0?r:{version:Xe};if(!n&&a[s]){var o=new Error("@opentelemetry/api: Attempted duplicate registration of API: "+s);return t.error(o.stack||o.message),!1}if(a.version!==Xe){var o=new Error("@opentelemetry/api: Registration of version v"+a.version+" for "+s+" does not match previously registered API v"+Xe);return t.error(o.stack||o.message),!1}return a[s]=e,t.debug("@opentelemetry/api: Registered a global for "+s+" v"+Xe+"."),!0}function fs(s){var e,t,n=(e=ds[us])===null||e===void 0?void 0:e.version;if(!(!n||!Pz(n)))return(t=ds[us])===null||t===void 0?void 0:t[s]}function Ni(s,e){e.debug("@opentelemetry/api: Unregistering a global for "+s+" v"+Xe+".");var t=ds[us];t&&delete t[s]}var $z=function(s,e){var t=typeof Symbol=="function"&&s[Symbol.iterator];if(!t)return s;var n=t.call(s),r,a=[],o;try{for(;(e===void 0||e-- >0)&&!(r=n.next()).done;)a.push(r.value)}catch(c){o={error:c}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(o)throw o.error}}return a},Lz=function(s,e,t){if(arguments.length===2)for(var n=0,r=e.length,a;n<r;n++)(a||!(n in e))&&(a||(a=Array.prototype.slice.call(e,0,n)),a[n]=e[n]);return s.concat(a||Array.prototype.slice.call(e))},Fz=function(){function s(e){this._namespace=e.namespace||"DiagComponentLogger"}return s.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Dt("debug",this._namespace,e)},s.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Dt("error",this._namespace,e)},s.prototype.info=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Dt("info",this._namespace,e)},s.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Dt("warn",this._namespace,e)},s.prototype.verbose=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Dt("verbose",this._namespace,e)},s}();function Dt(s,e,t){var n=fs("diag");if(n)return t.unshift(e),n[s].apply(n,Lz([],$z(t),!1))}var he;(function(s){s[s.NONE=0]="NONE",s[s.ERROR=30]="ERROR",s[s.WARN=50]="WARN",s[s.INFO=60]="INFO",s[s.DEBUG=70]="DEBUG",s[s.VERBOSE=80]="VERBOSE",s[s.ALL=9999]="ALL"})(he||(he={}));function _z(s,e){s<he.NONE?s=he.NONE:s>he.ALL&&(s=he.ALL),e=e||{};function t(n,r){var a=e[n];return typeof a=="function"&&s>=r?a.bind(e):function(){}}return{error:t("error",he.ERROR),warn:t("warn",he.WARN),info:t("info",he.INFO),debug:t("debug",he.DEBUG),verbose:t("verbose",he.VERBOSE)}}var qz=function(s,e){var t=typeof Symbol=="function"&&s[Symbol.iterator];if(!t)return s;var n=t.call(s),r,a=[],o;try{for(;(e===void 0||e-- >0)&&!(r=n.next()).done;)a.push(r.value)}catch(c){o={error:c}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(o)throw o.error}}return a},Wz=function(s,e,t){if(arguments.length===2)for(var n=0,r=e.length,a;n<r;n++)(a||!(n in e))&&(a||(a=Array.prototype.slice.call(e,0,n)),a[n]=e[n]);return s.concat(a||Array.prototype.slice.call(e))},Vz="diag",ys=function(){function s(){function e(r){return function(){for(var a=[],o=0;o<arguments.length;o++)a[o]=arguments[o];var c=fs("diag");if(c)return c[r].apply(c,Wz([],qz(a),!1))}}var t=this,n=function(r,a){var o,c,h;if(a===void 0&&(a={logLevel:he.INFO}),r===t){var d=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return t.error((o=d.stack)!==null&&o!==void 0?o:d.message),!1}typeof a=="number"&&(a={logLevel:a});var f=fs("diag"),u=_z((c=a.logLevel)!==null&&c!==void 0?c:he.INFO,r);if(f&&!a.suppressOverrideMessage){var T=(h=new Error().stack)!==null&&h!==void 0?h:"<failed to generate stacktrace>";f.warn("Current logger will be overwritten from "+T),u.warn("Current logger will overwrite one already registered from "+T)}return Ei("diag",u,t,!0)};t.setLogger=n,t.disable=function(){Ni(Vz,t)},t.createComponentLogger=function(r){return new Fz(r)},t.verbose=e("verbose"),t.debug=e("debug"),t.info=e("info"),t.warn=e("warn"),t.error=e("error")}return s.instance=function(){return this._instance||(this._instance=new s),this._instance},s}(),Yz=function(s,e){var t=typeof Symbol=="function"&&s[Symbol.iterator];if(!t)return s;var n=t.call(s),r,a=[],o;try{for(;(e===void 0||e-- >0)&&!(r=n.next()).done;)a.push(r.value)}catch(c){o={error:c}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(o)throw o.error}}return a},Zz=function(s){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&s[e],n=0;if(t)return t.call(s);if(s&&typeof s.length=="number")return{next:function(){return s&&n>=s.length&&(s=void 0),{value:s&&s[n++],done:!s}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Kz=function(){function s(e){this._entries=e?new Map(e):new Map}return s.prototype.getEntry=function(e){var t=this._entries.get(e);if(t)return Object.assign({},t)},s.prototype.getAllEntries=function(){return Array.from(this._entries.entries()).map(function(e){var t=Yz(e,2),n=t[0],r=t[1];return[n,r]})},s.prototype.setEntry=function(e,t){var n=new s(this._entries);return n._entries.set(e,t),n},s.prototype.removeEntry=function(e){var t=new s(this._entries);return t._entries.delete(e),t},s.prototype.removeEntries=function(){for(var e,t,n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];var a=new s(this._entries);try{for(var o=Zz(n),c=o.next();!c.done;c=o.next()){var h=c.value;a._entries.delete(h)}}catch(d){e={error:d}}finally{try{c&&!c.done&&(t=o.return)&&t.call(o)}finally{if(e)throw e.error}}return a},s.prototype.clear=function(){return new s},s}();ys.instance();function Hz(s){return s===void 0&&(s={}),new Kz(new Map(Object.entries(s)))}function Gz(s){return Symbol.for(s)}var Jz=function(){function s(e){var t=this;t._currentContext=e?new Map(e):new Map,t.getValue=function(n){return t._currentContext.get(n)},t.setValue=function(n,r){var a=new s(t._currentContext);return a._currentContext.set(n,r),a},t.deleteValue=function(n){var r=new s(t._currentContext);return r._currentContext.delete(n),r}}return s}(),Xz=new Jz,Qz={get:function(s,e){if(s!=null)return s[e]},keys:function(s){return s==null?[]:Object.keys(s)}},e0={set:function(s,e,t){s!=null&&(s[e]=t)}},t0=function(s,e){var t=typeof Symbol=="function"&&s[Symbol.iterator];if(!t)return s;var n=t.call(s),r,a=[],o;try{for(;(e===void 0||e-- >0)&&!(r=n.next()).done;)a.push(r.value)}catch(c){o={error:c}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(o)throw o.error}}return a},s0=function(s,e,t){if(arguments.length===2)for(var n=0,r=e.length,a;n<r;n++)(a||!(n in e))&&(a||(a=Array.prototype.slice.call(e,0,n)),a[n]=e[n]);return s.concat(a||Array.prototype.slice.call(e))},n0=function(){function s(){}return s.prototype.active=function(){return Xz},s.prototype.with=function(e,t,n){for(var r=[],a=3;a<arguments.length;a++)r[a-3]=arguments[a];return t.call.apply(t,s0([n],t0(r),!1))},s.prototype.bind=function(e,t){return t},s.prototype.enable=function(){return this},s.prototype.disable=function(){return this},s}(),r0=function(s,e){var t=typeof Symbol=="function"&&s[Symbol.iterator];if(!t)return s;var n=t.call(s),r,a=[],o;try{for(;(e===void 0||e-- >0)&&!(r=n.next()).done;)a.push(r.value)}catch(c){o={error:c}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(o)throw o.error}}return a},i0=function(s,e,t){if(arguments.length===2)for(var n=0,r=e.length,a;n<r;n++)(a||!(n in e))&&(a||(a=Array.prototype.slice.call(e,0,n)),a[n]=e[n]);return s.concat(a||Array.prototype.slice.call(e))},er="context",a0=new n0,ml=function(){function s(){}return s.getInstance=function(){return this._instance||(this._instance=new s),this._instance},s.prototype.setGlobalContextManager=function(e){return Ei(er,e,ys.instance())},s.prototype.active=function(){return this._getContextManager().active()},s.prototype.with=function(e,t,n){for(var r,a=[],o=3;o<arguments.length;o++)a[o-3]=arguments[o];return(r=this._getContextManager()).with.apply(r,i0([e,t,n],r0(a),!1))},s.prototype.bind=function(e,t){return this._getContextManager().bind(e,t)},s.prototype._getContextManager=function(){return fs(er)||a0},s.prototype.disable=function(){this._getContextManager().disable(),Ni(er,ys.instance())},s}(),Lr;(function(s){s[s.UNSET=0]="UNSET",s[s.OK=1]="OK",s[s.ERROR=2]="ERROR"})(Lr||(Lr={}));var o0=ml.getInstance(),c0=function(){function s(){}return s.prototype.inject=function(e,t){},s.prototype.extract=function(e,t){return e},s.prototype.fields=function(){return[]},s}(),Ai=Gz("OpenTelemetry Baggage Key");function wl(s){return s.getValue(Ai)||void 0}function l0(){return wl(ml.getInstance().active())}function h0(s,e){return s.setValue(Ai,e)}function u0(s){return s.deleteValue(Ai)}var tr="propagation",d0=new c0,f0=function(){function s(){this.createBaggage=Hz,this.getBaggage=wl,this.getActiveBaggage=l0,this.setBaggage=h0,this.deleteBaggage=u0}return s.getInstance=function(){return this._instance||(this._instance=new s),this._instance},s.prototype.setGlobalPropagator=function(e){return Ei(tr,e,ys.instance())},s.prototype.inject=function(e,t,n){return n===void 0&&(n=e0),this._getGlobalPropagator().inject(e,t,n)},s.prototype.extract=function(e,t,n){return n===void 0&&(n=Qz),this._getGlobalPropagator().extract(e,t,n)},s.prototype.fields=function(){return this._getGlobalPropagator().fields()},s.prototype.disable=function(){Ni(tr,ys.instance())},s.prototype._getGlobalPropagator=function(){return fs(tr)||d0},s}(),y0=f0.getInstance();const Za=["bench","debug","prod"],p0=s=>e=>Za.indexOf(e)>=Za.indexOf(s),Fr=class bl{constructor(e,t=p0("debug")){H(this,"meta",xi.NOOP),H(this,"otelTracer"),H(this,"filter"),this.otelTracer=e,this.filter=t}child(e){const t=new bl(this.otelTracer,this.filter);return t.meta=e,t}debug(e,t){return this.trace(e,"debug",t)}bench(e,t){return this.trace(e,"bench",t)}prod(e,t){return this.trace(e,"prod",t)}trace(e,t,n){if(n==null){if(this.meta.noop||!this.filter(t)||this.otelTracer==null)return()=>{};const r=new _r(e,this.otelTracer.startSpan(e));return r.start(),()=>r.end()}return this.meta.noop||!this.filter(t)||this.otelTracer==null?n(new zl(e)):this.otelTracer.startActiveSpan(e,r=>{const a=new _r(e,r);return n(a)})}propagate(e){if(this.meta.noop)return;const t=o0.active();y0.inject(t,e,{set:(n,r,a)=>{n[r]=a}})}};H(Fr,"NOOP",new Fr);let vl=Fr;class _r{constructor(e,t){H(this,"key"),H(this,"otel"),this.key=e,this.otel=t}set(e,t){this.otel.setAttribute(e,t)}recordError(e){e!=null&&(this.otel.recordException(e),this.otel.setStatus({code:Lr.ERROR}))}start(){performance.mark(`alamos.trace.start.${this.key}`)}end(){try{performance.mark(`alamos.trace.end.${this.key}`);const e=performance.measure(`alamos.trace.duration.${this.key}`,`alamos.trace.start.${this.key}`,`alamos.trace.end.${this.key}`);this.set("duration",e.duration),this.set("duration",e.duration),this.otel.end()}catch(e){console.error(e)}}}class zl{constructor(e){H(this,"key"),this.key=e}set(){}recordError(e){}}const qr=class Sl{constructor({key:e="",serviceName:t="",logger:n=Ii.NOOP,tracer:r=vl.NOOP,noop:a=!1,__meta:o}){H(this,"meta"),H(this,"T"),H(this,"L"),this.meta=o??new xi(e,e,t,a),this.T=r.child(this.meta),this.L=n.child(this.meta)}child(e){const t=this.meta.child(e);return new Sl({__meta:t,tracer:this.T,logger:this.L})}};H(qr,"NOOP",new qr({noop:!0}));let Ui=qr;const g0=Ui.NOOP,Tl=Object.freeze(Object.defineProperty({__proto__:null,Instrumentation:Ui,LOG_LEVELS:Dr,Logger:Ii,NOOP:g0,NoopSpan:zl,Tracer:vl,_Span:_r,logLevelKeyFiler:jz,logThresholdFilter:pl},Symbol.toStringTag,{value:"Module"})),sr=(s,e)=>s instanceof Error?(s.message=`[${e}] - ${s.message}`,s):new Error(e??"unknown error",{cause:s});class Ci{constructor({key:e,type:t,sender:n,instrumentation:r,parentCtxValues:a}){L(this,"type");L(this,"key");L(this,"sender");L(this,"_internalState");L(this,"_state");L(this,"_prevState");L(this,"_deleted",!1);L(this,"parentCtxValues");L(this,"childCtxValues");L(this,"childCtxChangedKeys");L(this,"instrumentation");L(this,"schema");this.type=t,this.key=e,this.sender=n,this._internalState={},this.instrumentation=r.child(`${this.type}(${this.key})`),this.parentCtxValues=new Map,a==null||a.forEach((o,c)=>this.parentCtxValues.set(c,o)),this.childCtxValues=new Map,this.childCtxChangedKeys=new Set}get _schema(){if(this.schema==null)throw new W(`[AetherLeaf] - expected subclass to define component schema, but none was found.
58
+ Make sure to define a property 'schema' on the class.`);return this.schema}setState(e){const t=We.executeSetter(e,this._state);this._prevState=S.Gt(this._state),this._state=Mr(this._schema,t,`${this.type}:${this.key}`),this.sender.send({variant:"update",key:this.key,state:t})}get state(){if(this._state==null)throw new ue(`[AetherLeaf] - state not defined in ${this.type}:${this.key}`);return this._state}get internal(){return this._internalState}get prevState(){return this._prevState}get deleted(){return this._deleted}get ctx(){return{get:e=>this.parentCtxValues.get(e),getOptional:e=>this.parentCtxValues.get(e),has:e=>this.parentCtxValues.has(e),wasSetPreviously:e=>this.childCtxValues.has(e),set:(e,t,n=!0)=>{this.childCtxValues.set(e,t),n&&this.childCtxChangedKeys.add(e)}}}_updateState(e,t,n){if(!this.deleted)try{const r=this.instrumentation.T.debug(`${this.type}:${this.key}:updateState`);this.validatePath(e);const a=Mr(this._schema,t,`${this.type}:${this.key}`);this._state!=null?this.instrumentation.L.debug("updating state",()=>({diff:Rl._.difference(this.state,a)})):this.instrumentation.L.debug("setting initial state",{state:t}),this._prevState=this._state??a,this._state=a,this.afterUpdate(this.ctx),r()}catch(r){throw sr(r,`${this.type}.${this.key}.updateState`)}}_updateContext(e){try{const t=this.instrumentation.T.debug(`${this.type}:${this.key}:updateContext`);e.forEach((n,r)=>this.parentCtxValues.set(r,n)),this.afterUpdate(this.ctx),t()}catch(t){throw sr(t,`${this.type}.${this.key}.updateContext`)}}_delete(e){try{const t=this.instrumentation.T.debug(`${this.type}:${this.key}:delete`);this.validatePath(e),this._deleted=!0,this.afterDelete(this.ctx),t()}catch(t){throw sr(t,`[${this.type}:${this.key}:delete]`)}}afterUpdate(e){}afterDelete(e){}validatePath(e){if(e.length===0)throw new ue(`[Leaf.setState] - ${this.type}:${this.key} received an empty path`);const t=e[e.length-1];if(e.length>1)throw new ue(`[Leaf.setState] - ${this.type}:${this.key} received a subPath ${e.join(".")} but is a leaf`);if(t!==this.key)throw new ue(`[Leaf.setState] - ${this.type}:${this.key} received a key ${t} but expected ${this.key}`)}}class ks extends Ci{constructor(){super(...arguments);L(this,"_children",new Map)}get children(){return Array.from(this._children.values())}getChild(t){return this._children.get(t)??null}childrenOfType(...t){return this.children.filter(n=>t.includes(n.type))}_updateState(t,n,r){if(this.deleted)return;const a=this.parsePath(t);if(a.length===0){if(this.childCtxChangedKeys.clear(),super._updateState(t,n,r),this.childCtxChangedKeys.size==0)return;this.updateChildContexts();return}const c=a[0],h=this.getChild(c);if(h!=null)return h._updateState(a,n,r);if(a.length>1)throw new ue(`[Composite.update] - ${this.type}:${this.key} received a subPath ${a.join(".")} but found now child with key ${c}`);const d=r(this.childCtx());d._updateState(a,n,r),this._children.set(c,d)}_updateContext(t){super._updateContext(t),this.updateChildContexts()}childCtx(){return{get:t=>this.childCtxValues.get(t)??this.parentCtxValues.get(t),forEach:t=>{this.childCtxValues.forEach((n,r)=>t(n,r,this.childCtxValues)),this.parentCtxValues.forEach((n,r)=>{this.childCtxValues.has(r)||t(n,r,this.parentCtxValues)})}}}updateChildContexts(){for(const t of this.children)t._updateContext(this.childCtx())}_delete(t){const n=this.parsePath(t);if(n.length===0){for(const a of this.children)a._delete([a.key]);this._children.clear(),super._delete([this.key])}const r=this.getChild(n[0]);if(r!=null){if(n.length>1)return r._delete(n);this._children.delete(r.key),r._delete(n)}}parsePath(t,n){const[r,...a]=t;if(r==null)throw new Error(`Composite ${this.type}:${this.key} received an empty path${n!=null?` for ${n}`:""}`);if(r!==this.key)throw new ue(`[Composite.getRequiredKey] - ${this.type}:${this.key} received a key ${r} but expected ${this.key}`);return a}}const m0=i.z.object({}),w0=()=>{throw new Error("should not call create")},Ke=class Ke extends ks{constructor({comms:t,instrumentation:n=Tl.Instrumentation.NOOP,registry:r}){super({key:Ke.KEY,type:Ke.TYPE,sender:t,instrumentation:n,parentCtxValues:null});L(this,"comms");L(this,"registry");L(this,"schema",m0);this.comms=t,this.registry=r}static render(t){const n=new Ke(t);return n._updateState([Ke.KEY],{},w0),n.comms.handle(r=>{try{n.handle(r)}catch(a){const o={name:"unknown",message:JSON.stringify(a),stack:"unknown"};a instanceof Error&&(o.name=a.name,o.message=a.message,o.stack=a.stack),n.comms.send({variant:"error",error:o})}}),n}handle(t){try{const{path:n,variant:r,type:a}=t;r==="delete"?this._delete(n):this._updateState(n,t.state,o=>{const c=n[n.length-1];return this.create({key:c,type:a,parentCtxValues:o})})}catch(n){console.error("failed to handle message",{error:n,msg:t})}}create({key:t,type:n,parentCtxValues:r}){const a=this.registry[n];if(a==null)throw new ue(`[Root.create] - ${n} not found in registry`);return new a({key:t,type:n,sender:this.comms,instrumentation:this.instrumentation,parentCtxValues:r})}};L(Ke,"TYPE","root"),L(Ke,"KEY","root");let ps=Ke;const Ol=ps.render.bind(ps),b0=Object.freeze(Object.defineProperty({__proto__:null,Composite:ks,Leaf:Ci,Root:ps,render:Ol},Symbol.toStringTag,{value:"Module"})),kl=["success","error","warning","info","loading","disabled","secondary"],xl=i.z.enum(kl),Il=i.z.object({key:i.z.string(),variant:xl,message:i.z.string(),description:i.z.string().optional(),time:S.m.z,data:S.m$1.optional()}),El=i.z.object({statuses:Il.array()}),et="status.aggregator";class tn extends ks{constructor(){super(...arguments);L(this,"schema",El)}afterUpdate(t){t.wasSetPreviously(et)||t.set(et,{add:this.add.bind(this),parse:this.parse.bind(this)})}parse(t){return{time:S.m.now(),...t,key:S.Lt.create()}}add(t){this.setState(n=>({...n,statuses:[...n.statuses,this.parse(t)]}))}}L(tn,"TYPE","status.Aggregator");const Nl=s=>s.get(et).add,v0=s=>{const e=s.getOptional(et);return e!=null?e.add:()=>{}},Wr=(s,e)=>{if(!(s instanceof Error))throw s;return{variant:"error",message:e??s.message,description:e!=null?s.message:void 0}},Al=s=>(e,t)=>{if(typeof e!="function")return s(Wr(e,t));(async()=>{try{await e()}catch(n){s(Wr(n,t))}})()},Ul=s=>Al(Nl(s)),z0={[tn.TYPE]:tn},S0=(s,e)=>{if(s.wasSetPreviously(et))return;const t=s.get(et),n=r=>{const a=e(r,t.parse);a!=null&&t.add(a)};s.set(et,{add:n,parse:t.parse})},Vr="pluto-theming-context",Cl=i.z.object({name:i.z.string(),url:i.z.string()}),T0=i.z.object({theme:Ka,fontURLs:i.z.array(Cl)}),os=class os extends ks{constructor(){super(...arguments);L(this,"schema",os.z)}afterUpdate(t){if(t.getOptional(Vr)!=null&&this.state.theme.key===this.prevState.theme.key)return;t.set(Vr,this.state.theme),Ul(t)(async()=>{await this.loadFonts()})}async loadFonts(){await Promise.all(this.state.fontURLs.map(async({name:t,url:n})=>{const r=new FontFace(t,`url(${n})`);try{await r.load(),self.fonts.add(r)}catch(a){console.error(a)}}))}};L(os,"TYPE","theming.Provider"),L(os,"z",T0);let gs=os;const O0=s=>s.get(Vr),k0={[gs.TYPE]:gs};exports.Aggregator=tn;exports.C=Ui;exports.Composite=ks;exports.Dv=Bm;exports.F=W;exports.Fe=Re;exports.Fv=Bw;exports.Leaf=Ci;exports.P=Ii;exports.Pe=pl;exports.Provider=gs;exports.Qb=fl;exports.Qt=ue;exports.REGISTRY=k0;exports.REGISTRY$1=z0;exports.S=O;exports.SYNNAX_DARK=Ga;exports.SYNNAX_LIGHT=Ha;exports.SYNNAX_THEMES=Gl;exports.VARIANTS=kl;exports.Wv=$w;exports.Xb=dl;exports.aT=wv;exports.aether=b0;exports.aggregatorStateZ=El;exports.createErrorHandler=Al;exports.fontSpecZ=Cl;exports.fromException=Wr;exports.g=Tl;exports.isComponentSize=Ql;exports.l=Dl;exports.prettyParse=Mr;exports.render=Ol;exports.specZ=Il;exports.themeZ=Ka;exports.use=O0;exports.useAdder=Nl;exports.useErrorHandler=Ul;exports.useInterceptor=S0;exports.useOptionalAdder=v0;exports.variantZ=xl;exports.vt=nt;exports.x=x;