@synnaxlabs/pluto 0.45.0 → 0.46.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 (626) hide show
  1. package/dist/{Toggle-BNABJ5M2.js → Toggle-BZQSuhA3.js} +2 -2
  2. package/dist/{Toggle-BKrbt8lh.cjs → Toggle-D7uuc8BY.cjs} +1 -1
  3. package/dist/{Video-CgaO8bTm.cjs → Video-BgaQjOlJ.cjs} +1 -1
  4. package/dist/{Video-B4UWip-3.js → Video-Com7iIjJ.js} +2 -2
  5. package/dist/button.cjs +1 -1
  6. package/dist/button.js +1 -1
  7. package/dist/color.cjs +1 -1
  8. package/dist/color.js +1 -1
  9. package/dist/css-DA2F4zE4.cjs +8 -0
  10. package/dist/{css-BUXMI9PB.js → css-qKD7ZG81.js} +1450 -1285
  11. package/dist/css.cjs +1 -1
  12. package/dist/css.js +2 -2
  13. package/dist/dialog.cjs +1 -1
  14. package/dist/dialog.js +1 -1
  15. package/dist/ether.cjs +1 -1
  16. package/dist/ether.js +72 -69
  17. package/dist/external-B3j4WcRx.js +42 -0
  18. package/dist/{external-BEkAplsH.cjs → external-BH7AW9vg.cjs} +1 -1
  19. package/dist/{external-_ninRYLQ.js → external-BHDJdA7E.js} +10 -10
  20. package/dist/external-BaO1j7U1.cjs +1 -0
  21. package/dist/external-BatQDwpn.cjs +1 -0
  22. package/dist/external-Bfddv9ir.cjs +1 -0
  23. package/dist/{external-DLo-151g.js → external-Bnn6kifu.js} +206 -206
  24. package/dist/external-BoMP9V9w.js +14 -0
  25. package/dist/{external-DTLy0px_.js → external-Bor2llbx.js} +62 -62
  26. package/dist/external-Bp0LGk7L.cjs +1 -0
  27. package/dist/{external-BKOEKFd7.js → external-C0EjmEmQ.js} +25 -25
  28. package/dist/{external-BSeWLcfY.js → external-CBwmQS9D.js} +137 -122
  29. package/dist/external-CV0q6V-F.js +87 -0
  30. package/dist/external-CaehDJtX.cjs +1 -0
  31. package/dist/external-DLIuO7_6.cjs +1 -0
  32. package/dist/{external-W69NXl-R.js → external-DO--52ul.js} +26 -26
  33. package/dist/external-DZ9ZLLOd.cjs +1 -0
  34. package/dist/external-JI_JLXE9.cjs +46 -0
  35. package/dist/{external-BOvnkwzO.js → external-KX4HsfeC.js} +12 -12
  36. package/dist/external-LuDrHOj0.js +89 -0
  37. package/dist/{external-CGX7u75x.js → external-ObqQM9Wz.js} +2 -2
  38. package/dist/external-R1DnhHJ8.cjs +1 -0
  39. package/dist/external-iLU86byd.cjs +1 -0
  40. package/dist/external-iTOHqKBf.js +23 -0
  41. package/dist/external-ok-onqCX.cjs +1 -0
  42. package/dist/external-qAqWNZPd.cjs +1 -0
  43. package/dist/flex.cjs +1 -1
  44. package/dist/flex.js +1 -1
  45. package/dist/fontString-BpD7ezh8.cjs +1 -0
  46. package/dist/{fontString-D_jEa-uI.js → fontString-DXsCV3Wx.js} +2 -2
  47. package/dist/header.cjs +1 -1
  48. package/dist/header.js +1 -1
  49. package/dist/index.cjs +35 -7
  50. package/dist/index.js +32678 -21392
  51. package/dist/input.cjs +1 -1
  52. package/dist/input.js +1 -1
  53. package/dist/jsx-runtime-Dszzpdy0.cjs +22 -0
  54. package/dist/{jsx-runtime-C5mzlN2N.js → jsx-runtime-OVHDjVDe.js} +14 -14
  55. package/dist/list.cjs +1 -1
  56. package/dist/list.js +1 -1
  57. package/dist/main-20msMsI6.cjs +92 -0
  58. package/dist/{main-jKCzbrWn.js → main-ClIRTLfC.js} +17685 -17077
  59. package/dist/menu.cjs +1 -1
  60. package/dist/menu.js +1 -1
  61. package/dist/pluto.css +1 -1
  62. package/dist/provider-D295Uocj.cjs +52 -0
  63. package/dist/provider-DVqod4rl.cjs +83 -0
  64. package/dist/provider-RFk778pl.js +18803 -0
  65. package/dist/provider-laSzOgag.js +4673 -0
  66. package/dist/src/arc/Arc.d.ts +6 -0
  67. package/dist/src/arc/Arc.d.ts.map +1 -0
  68. package/dist/src/arc/external.d.ts +4 -0
  69. package/dist/src/arc/external.d.ts.map +1 -0
  70. package/dist/src/arc/handle/Core.d.ts +8 -0
  71. package/dist/src/arc/handle/Core.d.ts.map +1 -0
  72. package/dist/src/arc/handle/Sink.d.ts +5 -0
  73. package/dist/src/arc/handle/Sink.d.ts.map +1 -0
  74. package/dist/src/arc/handle/Source.d.ts +5 -0
  75. package/dist/src/arc/handle/Source.d.ts.map +1 -0
  76. package/dist/src/arc/handle/external.d.ts +3 -0
  77. package/dist/src/arc/handle/external.d.ts.map +1 -0
  78. package/dist/src/arc/handle/index.d.ts +2 -0
  79. package/dist/src/arc/handle/index.d.ts.map +1 -0
  80. package/dist/src/arc/index.d.ts +2 -0
  81. package/dist/src/arc/index.d.ts.map +1 -0
  82. package/dist/src/arc/queries.d.ts +89 -0
  83. package/dist/src/arc/queries.d.ts.map +1 -0
  84. package/dist/src/arc/stage/Base.d.ts +32 -0
  85. package/dist/src/arc/stage/Base.d.ts.map +1 -0
  86. package/dist/src/arc/stage/constant/Constant.d.ts +9 -0
  87. package/dist/src/arc/stage/constant/Constant.d.ts.map +1 -0
  88. package/dist/src/arc/stage/constant/Form.d.ts +2 -0
  89. package/dist/src/arc/stage/constant/Form.d.ts.map +1 -0
  90. package/dist/src/arc/stage/constant/external.d.ts +3 -0
  91. package/dist/src/arc/stage/constant/external.d.ts.map +1 -0
  92. package/dist/src/arc/stage/constant/index.d.ts +2 -0
  93. package/dist/src/arc/stage/constant/index.d.ts.map +1 -0
  94. package/dist/src/arc/stage/external.d.ts +4 -0
  95. package/dist/src/arc/stage/external.d.ts.map +1 -0
  96. package/dist/src/arc/stage/index.d.ts +2 -0
  97. package/dist/src/arc/stage/index.d.ts.map +1 -0
  98. package/dist/src/arc/stage/operator/Operator.d.ts +17 -0
  99. package/dist/src/arc/stage/operator/Operator.d.ts.map +1 -0
  100. package/dist/src/arc/stage/operator/external.d.ts +242 -0
  101. package/dist/src/arc/stage/operator/external.d.ts.map +1 -0
  102. package/dist/src/arc/stage/operator/index.d.ts +2 -0
  103. package/dist/src/arc/stage/operator/index.d.ts.map +1 -0
  104. package/dist/src/arc/stage/read/Form.d.ts +3 -0
  105. package/dist/src/arc/stage/read/Form.d.ts.map +1 -0
  106. package/dist/src/arc/stage/read/Read.d.ts +10 -0
  107. package/dist/src/arc/stage/read/Read.d.ts.map +1 -0
  108. package/dist/src/arc/stage/read/external.d.ts +9 -0
  109. package/dist/src/arc/stage/read/external.d.ts.map +1 -0
  110. package/dist/src/arc/stage/read/index.d.ts +2 -0
  111. package/dist/src/arc/stage/read/index.d.ts.map +1 -0
  112. package/dist/src/arc/stage/registry.d.ts +11 -0
  113. package/dist/src/arc/stage/registry.d.ts.map +1 -0
  114. package/dist/src/arc/stage/select/Select.d.ts +2 -0
  115. package/dist/src/arc/stage/select/Select.d.ts.map +1 -0
  116. package/dist/src/arc/stage/select/external.d.ts +12 -0
  117. package/dist/src/arc/stage/select/external.d.ts.map +1 -0
  118. package/dist/src/arc/stage/select/index.d.ts +2 -0
  119. package/dist/src/arc/stage/select/index.d.ts.map +1 -0
  120. package/dist/src/arc/stage/source/Form.d.ts +3 -0
  121. package/dist/src/arc/stage/source/Form.d.ts.map +1 -0
  122. package/dist/src/arc/stage/source/Source.d.ts +10 -0
  123. package/dist/src/arc/stage/source/Source.d.ts.map +1 -0
  124. package/dist/src/arc/stage/source/external.d.ts +9 -0
  125. package/dist/src/arc/stage/source/external.d.ts.map +1 -0
  126. package/dist/src/arc/stage/source/index.d.ts +2 -0
  127. package/dist/src/arc/stage/source/index.d.ts.map +1 -0
  128. package/dist/src/arc/stage/stable/Form.d.ts +2 -0
  129. package/dist/src/arc/stage/stable/Form.d.ts.map +1 -0
  130. package/dist/src/arc/stage/stable/StableFor.d.ts +9 -0
  131. package/dist/src/arc/stage/stable/StableFor.d.ts.map +1 -0
  132. package/dist/src/arc/stage/stable/external.d.ts +3 -0
  133. package/dist/src/arc/stage/stable/external.d.ts.map +1 -0
  134. package/dist/src/arc/stage/stable/index.d.ts +2 -0
  135. package/dist/src/arc/stage/stable/index.d.ts.map +1 -0
  136. package/dist/src/arc/stage/status/Change.d.ts +21 -0
  137. package/dist/src/arc/stage/status/Change.d.ts.map +1 -0
  138. package/dist/src/arc/stage/status/Form.d.ts +3 -0
  139. package/dist/src/arc/stage/status/Form.d.ts.map +1 -0
  140. package/dist/src/arc/stage/status/external.d.ts +7 -0
  141. package/dist/src/arc/stage/status/external.d.ts.map +1 -0
  142. package/dist/src/arc/stage/status/index.d.ts +2 -0
  143. package/dist/src/arc/stage/status/index.d.ts.map +1 -0
  144. package/dist/src/arc/stage/types/index.d.ts +2 -0
  145. package/dist/src/arc/stage/types/index.d.ts.map +1 -0
  146. package/dist/src/arc/stage/types/spec.d.ts +25 -0
  147. package/dist/src/arc/stage/types/spec.d.ts.map +1 -0
  148. package/dist/src/button/color.d.ts +1 -2
  149. package/dist/src/button/color.d.ts.map +1 -1
  150. package/dist/src/channel/AliasInput.d.ts +3 -3
  151. package/dist/src/channel/AliasInput.d.ts.map +1 -1
  152. package/dist/src/channel/LinePlot.d.ts +4 -4
  153. package/dist/src/channel/LinePlot.d.ts.map +1 -1
  154. package/dist/src/channel/Select.d.ts +5 -5
  155. package/dist/src/channel/Select.d.ts.map +1 -1
  156. package/dist/src/channel/queries.d.ts +37 -70
  157. package/dist/src/channel/queries.d.ts.map +1 -1
  158. package/dist/src/css/bem.d.ts +1 -2
  159. package/dist/src/css/bem.d.ts.map +1 -1
  160. package/dist/src/dialog/Frame.d.ts.map +1 -1
  161. package/dist/src/divider/Divider.d.ts +1 -1
  162. package/dist/src/divider/Divider.d.ts.map +1 -1
  163. package/dist/src/ether.d.ts +2 -2
  164. package/dist/src/ether.d.ts.map +1 -1
  165. package/dist/src/flux/Provider.d.ts.map +1 -1
  166. package/dist/src/flux/aether/external.d.ts +1 -1
  167. package/dist/src/flux/aether/external.d.ts.map +1 -1
  168. package/dist/src/flux/aether/provider.d.ts +1 -1
  169. package/dist/src/flux/aether/provider.d.ts.map +1 -1
  170. package/dist/src/flux/core/external.d.ts +1 -0
  171. package/dist/src/flux/core/external.d.ts.map +1 -1
  172. package/dist/src/flux/core/store.d.ts +19 -13
  173. package/dist/src/flux/core/store.d.ts.map +1 -1
  174. package/dist/src/flux/core/streamer.d.ts +1 -1
  175. package/dist/src/flux/core/streamer.d.ts.map +1 -1
  176. package/dist/src/flux/core/types.d.ts +42 -0
  177. package/dist/src/flux/core/types.d.ts.map +1 -0
  178. package/dist/src/flux/external.d.ts +1 -1
  179. package/dist/src/flux/external.d.ts.map +1 -1
  180. package/dist/src/flux/form.d.ts +29 -127
  181. package/dist/src/flux/form.d.ts.map +1 -1
  182. package/dist/src/flux/list.d.ts +28 -228
  183. package/dist/src/flux/list.d.ts.map +1 -1
  184. package/dist/src/flux/result.d.ts +32 -90
  185. package/dist/src/flux/result.d.ts.map +1 -1
  186. package/dist/src/flux/retrieve.d.ts +47 -176
  187. package/dist/src/flux/retrieve.d.ts.map +1 -1
  188. package/dist/src/flux/update.d.ts +45 -134
  189. package/dist/src/flux/update.d.ts.map +1 -1
  190. package/dist/src/form/Context.d.ts +2 -2
  191. package/dist/src/form/Context.d.ts.map +1 -1
  192. package/dist/src/form/Context.spec.d.ts +2 -0
  193. package/dist/src/form/Context.spec.d.ts.map +1 -0
  194. package/dist/src/group/queries.d.ts +18 -18
  195. package/dist/src/group/queries.d.ts.map +1 -1
  196. package/dist/src/hardware/device/Select.d.ts +2 -2
  197. package/dist/src/hardware/device/Select.d.ts.map +1 -1
  198. package/dist/src/hardware/device/queries.d.ts +369 -9
  199. package/dist/src/hardware/device/queries.d.ts.map +1 -1
  200. package/dist/src/hardware/rack/Select.d.ts +3 -3
  201. package/dist/src/hardware/rack/Select.d.ts.map +1 -1
  202. package/dist/src/hardware/rack/queries.d.ts +15 -11
  203. package/dist/src/hardware/rack/queries.d.ts.map +1 -1
  204. package/dist/src/hardware/task/queries.d.ts +70 -17
  205. package/dist/src/hardware/task/queries.d.ts.map +1 -1
  206. package/dist/src/hooks/useRequiredContext.d.ts.map +1 -1
  207. package/dist/src/hooks/useRequiredContext.spec.d.ts +2 -0
  208. package/dist/src/hooks/useRequiredContext.spec.d.ts.map +1 -0
  209. package/dist/src/icon/Modbus.d.ts +2 -0
  210. package/dist/src/icon/Modbus.d.ts.map +1 -0
  211. package/dist/src/icon/registry.d.ts +16 -3
  212. package/dist/src/icon/registry.d.ts.map +1 -1
  213. package/dist/src/index.d.ts +4 -3
  214. package/dist/src/index.d.ts.map +1 -1
  215. package/dist/src/input/Boolean.d.ts +3 -2
  216. package/dist/src/input/Boolean.d.ts.map +1 -1
  217. package/dist/src/input/Checkbox.d.ts +2 -3
  218. package/dist/src/input/Checkbox.d.ts.map +1 -1
  219. package/dist/src/input/DateTime.d.ts +1 -18
  220. package/dist/src/input/DateTime.d.ts.map +1 -1
  221. package/dist/src/input/Switch.d.ts +2 -3
  222. package/dist/src/input/Switch.d.ts.map +1 -1
  223. package/dist/src/input/Text.d.ts +2 -1
  224. package/dist/src/input/Text.d.ts.map +1 -1
  225. package/dist/src/input/external.d.ts +0 -1
  226. package/dist/src/input/external.d.ts.map +1 -1
  227. package/dist/src/label/Select.d.ts +5 -5
  228. package/dist/src/label/Select.d.ts.map +1 -1
  229. package/dist/src/label/queries.d.ts +35 -20
  230. package/dist/src/label/queries.d.ts.map +1 -1
  231. package/dist/src/{vis/lineplot → lineplot}/Axis.d.ts +3 -3
  232. package/dist/src/lineplot/Axis.d.ts.map +1 -0
  233. package/dist/src/{vis/lineplot → lineplot}/Legend.d.ts +1 -1
  234. package/dist/src/lineplot/Legend.d.ts.map +1 -0
  235. package/dist/src/{vis/lineplot → lineplot}/Line.d.ts +2 -2
  236. package/dist/src/lineplot/Line.d.ts.map +1 -0
  237. package/dist/src/{vis/lineplot → lineplot}/LinePlot.d.ts +3 -3
  238. package/dist/src/lineplot/LinePlot.d.ts.map +1 -0
  239. package/dist/src/{vis/lineplot → lineplot}/Title.d.ts +1 -1
  240. package/dist/src/lineplot/Title.d.ts.map +1 -0
  241. package/dist/src/{vis/lineplot → lineplot}/Viewport.d.ts +1 -1
  242. package/dist/src/lineplot/Viewport.d.ts.map +1 -0
  243. package/dist/src/{vis/lineplot → lineplot}/aether/BoundQuerier.d.ts +1 -1
  244. package/dist/src/lineplot/aether/BoundQuerier.d.ts.map +1 -0
  245. package/dist/src/{vis/lineplot → lineplot}/aether/LinePlot.d.ts +5 -5
  246. package/dist/src/lineplot/aether/LinePlot.d.ts.map +1 -0
  247. package/dist/src/{vis/lineplot → lineplot}/aether/XAxis.d.ts +3 -3
  248. package/dist/src/lineplot/aether/XAxis.d.ts.map +1 -0
  249. package/dist/src/{vis/lineplot → lineplot}/aether/YAxis.d.ts +2 -2
  250. package/dist/src/lineplot/aether/YAxis.d.ts.map +1 -0
  251. package/dist/src/{vis/lineplot → lineplot}/aether/axis.d.ts +6 -6
  252. package/dist/src/lineplot/aether/axis.d.ts.map +1 -0
  253. package/dist/src/lineplot/aether/external.d.ts.map +1 -0
  254. package/dist/src/lineplot/aether/index.d.ts.map +1 -0
  255. package/dist/src/{vis/lineplot → lineplot}/external.d.ts +1 -0
  256. package/dist/src/lineplot/external.d.ts.map +1 -0
  257. package/dist/src/lineplot/index.d.ts.map +1 -0
  258. package/dist/src/lineplot/queries.d.ts +33 -0
  259. package/dist/src/lineplot/queries.d.ts.map +1 -0
  260. package/dist/src/lineplot/queries.spec.d.ts +2 -0
  261. package/dist/src/lineplot/queries.spec.d.ts.map +1 -0
  262. package/dist/src/{vis/lineplot → lineplot}/range/Annotation.d.ts +1 -1
  263. package/dist/src/lineplot/range/Annotation.d.ts.map +1 -0
  264. package/dist/src/{vis/lineplot → lineplot}/range/Provider.d.ts +2 -2
  265. package/dist/src/lineplot/range/Provider.d.ts.map +1 -0
  266. package/dist/src/{vis/lineplot → lineplot}/range/aether/annotation.d.ts +3 -3
  267. package/dist/src/lineplot/range/aether/annotation.d.ts.map +1 -0
  268. package/dist/src/{vis/lineplot → lineplot}/range/aether/external.d.ts +1 -1
  269. package/dist/src/lineplot/range/aether/external.d.ts.map +1 -0
  270. package/dist/src/lineplot/range/aether/index.d.ts.map +1 -0
  271. package/dist/src/{vis/lineplot → lineplot}/range/aether/provider.d.ts +10 -10
  272. package/dist/src/lineplot/range/aether/provider.d.ts.map +1 -0
  273. package/dist/src/lineplot/range/external.d.ts.map +1 -0
  274. package/dist/src/lineplot/range/index.d.ts.map +1 -0
  275. package/dist/src/{vis/lineplot → lineplot}/tooltip/Tooltip.d.ts +1 -1
  276. package/dist/src/lineplot/tooltip/Tooltip.d.ts.map +1 -0
  277. package/dist/src/lineplot/tooltip/aether/index.d.ts.map +1 -0
  278. package/dist/src/{vis/lineplot → lineplot}/tooltip/aether/tooltip.d.ts +4 -4
  279. package/dist/src/lineplot/tooltip/aether/tooltip.d.ts.map +1 -0
  280. package/dist/src/lineplot/tooltip/index.d.ts.map +1 -0
  281. package/dist/src/lineplot/useBoundQuerier.d.ts.map +1 -0
  282. package/dist/src/list/Frame.d.ts +16 -1
  283. package/dist/src/list/Frame.d.ts.map +1 -1
  284. package/dist/src/list/pager.d.ts +7 -1
  285. package/dist/src/list/pager.d.ts.map +1 -1
  286. package/dist/src/list/useCombinedData.d.ts.map +1 -1
  287. package/dist/src/list/useKeysData.d.ts.map +1 -1
  288. package/dist/src/list/useMapData.d.ts.map +1 -1
  289. package/dist/src/list/useStaticData.d.ts.map +1 -1
  290. package/dist/src/{vis/log → log}/Log.d.ts +2 -2
  291. package/dist/src/log/Log.d.ts.map +1 -0
  292. package/dist/src/{vis/log → log}/aether/Log.d.ts +4 -4
  293. package/dist/src/log/aether/Log.d.ts.map +1 -0
  294. package/dist/src/log/aether/index.d.ts.map +1 -0
  295. package/dist/src/log/external.d.ts +3 -0
  296. package/dist/src/log/external.d.ts.map +1 -0
  297. package/dist/src/log/index.d.ts +2 -0
  298. package/dist/src/log/index.d.ts.map +1 -0
  299. package/dist/src/log/queries.d.ts +33 -0
  300. package/dist/src/log/queries.d.ts.map +1 -0
  301. package/dist/src/log/queries.spec.d.ts +2 -0
  302. package/dist/src/log/queries.spec.d.ts.map +1 -0
  303. package/dist/src/menu/ContextMenu.d.ts.map +1 -1
  304. package/dist/src/ontology/aether/index.d.ts +2 -0
  305. package/dist/src/ontology/aether/index.d.ts.map +1 -0
  306. package/dist/src/ontology/aether/queries.d.ts +15 -0
  307. package/dist/src/ontology/aether/queries.d.ts.map +1 -0
  308. package/dist/src/ontology/external.d.ts +1 -0
  309. package/dist/src/ontology/external.d.ts.map +1 -1
  310. package/dist/src/ontology/queries.d.ts +27 -23
  311. package/dist/src/ontology/queries.d.ts.map +1 -1
  312. package/dist/src/pluto/Pluto.d.ts +13 -0
  313. package/dist/src/pluto/Pluto.d.ts.map +1 -1
  314. package/dist/src/pluto/aether/pluto.d.ts.map +1 -1
  315. package/dist/src/ranger/Breadcrumb.d.ts +3 -1
  316. package/dist/src/ranger/Breadcrumb.d.ts.map +1 -1
  317. package/dist/src/ranger/CreateIcon.d.ts +3 -0
  318. package/dist/src/ranger/CreateIcon.d.ts.map +1 -0
  319. package/dist/src/ranger/Select.d.ts +4 -14
  320. package/dist/src/ranger/Select.d.ts.map +1 -1
  321. package/dist/src/ranger/SelectStage.d.ts +7 -0
  322. package/dist/src/ranger/SelectStage.d.ts.map +1 -0
  323. package/dist/src/ranger/StageIcon.d.ts +8 -0
  324. package/dist/src/ranger/StageIcon.d.ts.map +1 -0
  325. package/dist/src/ranger/aether/index.d.ts.map +1 -1
  326. package/dist/src/ranger/aether/queries.d.ts +2 -2
  327. package/dist/src/ranger/aether/queries.d.ts.map +1 -1
  328. package/dist/src/ranger/external.d.ts +5 -1
  329. package/dist/src/ranger/external.d.ts.map +1 -1
  330. package/dist/src/ranger/queries.d.ts +41 -41
  331. package/dist/src/ranger/queries.d.ts.map +1 -1
  332. package/dist/src/ranger/stage.d.ts +20 -0
  333. package/dist/src/ranger/stage.d.ts.map +1 -0
  334. package/dist/src/ranger/stage.spec.d.ts +2 -0
  335. package/dist/src/ranger/stage.spec.d.ts.map +1 -0
  336. package/dist/src/resize/Core.d.ts.map +1 -1
  337. package/dist/src/schematic/Schematic.d.ts +6 -0
  338. package/dist/src/schematic/Schematic.d.ts.map +1 -0
  339. package/dist/src/schematic/edge/Edge.d.ts +15 -0
  340. package/dist/src/schematic/edge/Edge.d.ts.map +1 -0
  341. package/dist/src/schematic/edge/connector/connector.d.ts.map +1 -0
  342. package/dist/src/schematic/edge/connector/connector.spec.d.ts.map +1 -0
  343. package/dist/src/schematic/edge/connector/index.d.ts.map +1 -0
  344. package/dist/src/schematic/edge/index.d.ts +3 -0
  345. package/dist/src/schematic/edge/index.d.ts.map +1 -0
  346. package/dist/src/schematic/edge/paths.d.ts +28 -0
  347. package/dist/src/schematic/edge/paths.d.ts.map +1 -0
  348. package/dist/src/schematic/external.d.ts +3 -0
  349. package/dist/src/schematic/external.d.ts.map +1 -1
  350. package/dist/src/schematic/queries.d.ts +43 -0
  351. package/dist/src/schematic/queries.d.ts.map +1 -0
  352. package/dist/src/schematic/queries.spec.d.ts +2 -0
  353. package/dist/src/schematic/queries.spec.d.ts.map +1 -0
  354. package/dist/src/schematic/symbol/Custom.d.ts.map +1 -1
  355. package/dist/src/schematic/symbol/Forms.d.ts +1 -0
  356. package/dist/src/schematic/symbol/Forms.d.ts.map +1 -1
  357. package/dist/src/schematic/symbol/Primitives.d.ts +1 -1
  358. package/dist/src/schematic/symbol/Primitives.d.ts.map +1 -1
  359. package/dist/src/schematic/symbol/Symbols.d.ts +11 -1
  360. package/dist/src/schematic/symbol/Symbols.d.ts.map +1 -1
  361. package/dist/src/schematic/symbol/queries.d.ts +20 -19
  362. package/dist/src/schematic/symbol/queries.d.ts.map +1 -1
  363. package/dist/src/schematic/symbol/registry.d.ts +2 -1
  364. package/dist/src/schematic/symbol/registry.d.ts.map +1 -1
  365. package/dist/src/select/Dialog.d.ts +1 -1
  366. package/dist/src/select/Dialog.d.ts.map +1 -1
  367. package/dist/src/select/Frame.d.ts +4 -1
  368. package/dist/src/select/Frame.d.ts.map +1 -1
  369. package/dist/src/select/ListItem.d.ts.map +1 -1
  370. package/dist/src/select/MultipleTrigger.d.ts +5 -2
  371. package/dist/src/select/MultipleTrigger.d.ts.map +1 -1
  372. package/dist/src/showcase/DividerShowcase.d.ts.map +1 -1
  373. package/dist/src/showcase/InputShowcase.d.ts +1 -1
  374. package/dist/src/showcase/InputShowcase.d.ts.map +1 -1
  375. package/dist/src/showcase/SelectShowcase.d.ts.map +1 -1
  376. package/dist/src/showcase/TagShowcase.d.ts.map +1 -1
  377. package/dist/src/state/state.d.ts +2 -1
  378. package/dist/src/state/state.d.ts.map +1 -1
  379. package/dist/src/status/CreateIcon.d.ts +1 -0
  380. package/dist/src/status/CreateIcon.d.ts.map +1 -0
  381. package/dist/src/status/Select.d.ts +12 -0
  382. package/dist/src/status/Select.d.ts.map +1 -0
  383. package/dist/src/status/SelectVariant.d.ts +7 -0
  384. package/dist/src/status/SelectVariant.d.ts.map +1 -0
  385. package/dist/src/status/aether/aggregator.d.ts +3 -25
  386. package/dist/src/status/aether/aggregator.d.ts.map +1 -1
  387. package/dist/src/status/aether/errorHandler.d.ts +1 -1
  388. package/dist/src/status/aether/errorHandler.d.ts.map +1 -1
  389. package/dist/src/status/{Aggregator.d.ts → core/Aggregator.d.ts} +4 -4
  390. package/dist/src/status/core/Aggregator.d.ts.map +1 -0
  391. package/dist/src/status/core/Aggregator.spec.d.ts.map +1 -0
  392. package/dist/src/status/core/CreateIcon.d.ts +3 -0
  393. package/dist/src/status/core/CreateIcon.d.ts.map +1 -0
  394. package/dist/src/status/{Indicator.d.ts → core/Indicator.d.ts} +1 -1
  395. package/dist/src/status/core/Indicator.d.ts.map +1 -0
  396. package/dist/src/status/{Notification.d.ts → core/Notification.d.ts} +3 -3
  397. package/dist/src/status/core/Notification.d.ts.map +1 -0
  398. package/dist/src/status/core/Notification.spec.d.ts.map +1 -0
  399. package/dist/src/status/core/SelectVariant.d.ts +7 -0
  400. package/dist/src/status/core/SelectVariant.d.ts.map +1 -0
  401. package/dist/src/status/core/Summary.d.ts +12 -0
  402. package/dist/src/status/core/Summary.d.ts.map +1 -0
  403. package/dist/src/status/core/colors.d.ts.map +1 -0
  404. package/dist/src/status/core/external.d.ts +8 -0
  405. package/dist/src/status/core/external.d.ts.map +1 -0
  406. package/dist/src/status/core/index.d.ts +2 -0
  407. package/dist/src/status/core/index.d.ts.map +1 -0
  408. package/dist/src/status/external.d.ts +3 -5
  409. package/dist/src/status/external.d.ts.map +1 -1
  410. package/dist/src/status/index.d.ts.map +1 -1
  411. package/dist/src/status/queries.d.ts +64 -0
  412. package/dist/src/status/queries.d.ts.map +1 -0
  413. package/dist/src/status/queries.spec.d.ts +2 -0
  414. package/dist/src/status/queries.spec.d.ts.map +1 -0
  415. package/dist/src/synnax/Provider.d.ts +8 -5
  416. package/dist/src/synnax/Provider.d.ts.map +1 -1
  417. package/dist/src/table/external.d.ts +1 -0
  418. package/dist/src/table/external.d.ts.map +1 -1
  419. package/dist/src/table/queries.d.ts +35 -0
  420. package/dist/src/table/queries.d.ts.map +1 -0
  421. package/dist/src/table/queries.spec.d.ts +2 -0
  422. package/dist/src/table/queries.spec.d.ts.map +1 -0
  423. package/dist/src/tag/Tags.d.ts +1 -1
  424. package/dist/src/tag/Tags.d.ts.map +1 -1
  425. package/dist/src/telem/aether/noop.d.ts.map +1 -1
  426. package/dist/src/telem/aether/remote.d.ts +4 -4
  427. package/dist/src/telem/aether/telem.d.ts +1 -1
  428. package/dist/src/telem/aether/telem.d.ts.map +1 -1
  429. package/dist/src/telem/client/streamer.d.ts +1 -0
  430. package/dist/src/telem/client/streamer.d.ts.map +1 -1
  431. package/dist/src/telem/control/Chip.d.ts.map +1 -1
  432. package/dist/src/telem/control/aether/chip.d.ts +9 -32
  433. package/dist/src/telem/control/aether/chip.d.ts.map +1 -1
  434. package/dist/src/telem/control/aether/controller.d.ts.map +1 -1
  435. package/dist/src/telem/control/aether/indicator.d.ts +15 -38
  436. package/dist/src/telem/control/aether/indicator.d.ts.map +1 -1
  437. package/dist/src/telem/external.d.ts +1 -0
  438. package/dist/src/telem/external.d.ts.map +1 -1
  439. package/dist/src/telem/text/TimeRange.d.ts +10 -0
  440. package/dist/src/telem/text/TimeRange.d.ts.map +1 -0
  441. package/dist/src/telem/text/TimeRange.spec.d.ts +2 -0
  442. package/dist/src/telem/text/TimeRange.spec.d.ts.map +1 -0
  443. package/dist/src/telem/text/TimeSpan.d.ts +10 -0
  444. package/dist/src/telem/text/TimeSpan.d.ts.map +1 -0
  445. package/dist/src/telem/text/TimeSpan.spec.d.ts +2 -0
  446. package/dist/src/telem/text/TimeSpan.spec.d.ts.map +1 -0
  447. package/dist/src/telem/text/TimeSpanSince.d.ts +11 -0
  448. package/dist/src/telem/text/TimeSpanSince.d.ts.map +1 -0
  449. package/dist/src/telem/text/TimeStamp.d.ts +12 -0
  450. package/dist/src/telem/text/TimeStamp.d.ts.map +1 -0
  451. package/dist/src/telem/text/TimeStamp.spec.d.ts +2 -0
  452. package/dist/src/telem/text/TimeStamp.spec.d.ts.map +1 -0
  453. package/dist/src/telem/text/external.d.ts +5 -0
  454. package/dist/src/telem/text/external.d.ts.map +1 -0
  455. package/dist/src/telem/text/index.d.ts +2 -0
  456. package/dist/src/telem/text/index.d.ts.map +1 -0
  457. package/dist/src/text/Editable.d.ts.map +1 -1
  458. package/dist/src/text/external.d.ts +0 -1
  459. package/dist/src/text/external.d.ts.map +1 -1
  460. package/dist/src/tooltip/Dialog.d.ts.map +1 -1
  461. package/dist/src/tree/Context.d.ts +13 -0
  462. package/dist/src/tree/Context.d.ts.map +1 -0
  463. package/dist/src/tree/Item.d.ts +2 -3
  464. package/dist/src/tree/Item.d.ts.map +1 -1
  465. package/dist/src/tree/Tree.d.ts +2 -2
  466. package/dist/src/tree/Tree.d.ts.map +1 -1
  467. package/dist/src/tree/core.d.ts +2 -1
  468. package/dist/src/tree/core.d.ts.map +1 -1
  469. package/dist/src/tree/core.spec.d.ts +2 -0
  470. package/dist/src/tree/core.spec.d.ts.map +1 -0
  471. package/dist/src/user/index.d.ts +2 -0
  472. package/dist/src/user/index.d.ts.map +1 -0
  473. package/dist/src/user/queries.d.ts +50 -0
  474. package/dist/src/user/queries.d.ts.map +1 -0
  475. package/dist/src/user/queries.spec.d.ts +2 -0
  476. package/dist/src/user/queries.spec.d.ts.map +1 -0
  477. package/dist/src/viewport/use.d.ts.map +1 -1
  478. package/dist/src/vis/diagram/Diagram.d.ts +16 -4
  479. package/dist/src/vis/diagram/Diagram.d.ts.map +1 -1
  480. package/dist/src/vis/diagram/aether/Diagram.d.ts.map +1 -1
  481. package/dist/src/vis/diagram/aether/types.d.ts +6 -49
  482. package/dist/src/vis/diagram/aether/types.d.ts.map +1 -1
  483. package/dist/src/vis/diagram/external.d.ts +1 -1
  484. package/dist/src/vis/diagram/external.d.ts.map +1 -1
  485. package/dist/src/vis/diagram/useTriggers.d.ts +12 -0
  486. package/dist/src/vis/diagram/useTriggers.d.ts.map +1 -0
  487. package/dist/src/vis/diagram/util.d.ts +2 -0
  488. package/dist/src/vis/diagram/util.d.ts.map +1 -1
  489. package/dist/src/vis/draw2d/canvas.d.ts.map +1 -1
  490. package/dist/src/vis/draw2d/index.d.ts +16 -6
  491. package/dist/src/vis/draw2d/index.d.ts.map +1 -1
  492. package/dist/src/vis/gauge/aether/gauge.d.ts +297 -0
  493. package/dist/src/vis/gauge/aether/gauge.d.ts.map +1 -0
  494. package/dist/src/vis/gauge/aether/index.d.ts +2 -0
  495. package/dist/src/vis/gauge/aether/index.d.ts.map +1 -0
  496. package/dist/src/vis/gauge/index.d.ts +2 -0
  497. package/dist/src/vis/gauge/index.d.ts.map +1 -0
  498. package/dist/src/vis/gauge/use.d.ts +84 -0
  499. package/dist/src/vis/gauge/use.d.ts.map +1 -0
  500. package/dist/src/vis/text/atlas.d.ts.map +1 -1
  501. package/dist/src/vis/value/TelemForm.d.ts.map +1 -1
  502. package/dist/src/workspace/queries.d.ts +37 -4
  503. package/dist/src/workspace/queries.d.ts.map +1 -1
  504. package/dist/tabs.cjs +1 -1
  505. package/dist/tabs.js +1 -1
  506. package/dist/text.cjs +1 -1
  507. package/dist/text.js +2 -2
  508. package/dist/theme.css +1593 -1594
  509. package/dist/theming.cjs +1 -1
  510. package/dist/theming.js +2 -2
  511. package/dist/tree.cjs +1 -1
  512. package/dist/tree.js +1 -1
  513. package/dist/triggers.cjs +1 -1
  514. package/dist/triggers.js +1 -1
  515. package/dist/units-CLbZ5ejs.cjs +1 -0
  516. package/dist/{units-BPvO622s.js → units-WtYBE1br.js} +1 -1
  517. package/dist/useKeysData-DXXVQfXZ.js +18 -0
  518. package/dist/useKeysData-Do63LaI0.cjs +1 -0
  519. package/dist/video.cjs +1 -1
  520. package/dist/video.js +1 -1
  521. package/package.json +20 -20
  522. package/README.md +0 -35
  523. package/dist/Animated-B9bcEALW.js +0 -27
  524. package/dist/Animated-EQN_Zecr.cjs +0 -1
  525. package/dist/LinePlot-82qQ7-BC.js +0 -6263
  526. package/dist/LinePlot-Do2q5AyX.cjs +0 -53
  527. package/dist/css-CmXY6iPo.cjs +0 -8
  528. package/dist/eraser-C1jjA5cv.cjs +0 -63
  529. package/dist/eraser-DXDDmPgV.js +0 -14108
  530. package/dist/external-5DC2xiKR.cjs +0 -1
  531. package/dist/external-65blLb4-.js +0 -42
  532. package/dist/external-B8KPEzPt.cjs +0 -1
  533. package/dist/external-BIykXq97.cjs +0 -1
  534. package/dist/external-Bqmws2bv.cjs +0 -1
  535. package/dist/external-CFsDBQGs.cjs +0 -1
  536. package/dist/external-CJKfUQ-9.cjs +0 -1
  537. package/dist/external-CPW2TrSs.js +0 -124
  538. package/dist/external-CijGOPm7.cjs +0 -1
  539. package/dist/external-DCQ725nK.cjs +0 -1
  540. package/dist/external-DWfn7Yhk.cjs +0 -1
  541. package/dist/external-DcNW5o-8.cjs +0 -1
  542. package/dist/external-Gh_0tAJ0.js +0 -24
  543. package/dist/external-J1Ji-Eku.js +0 -92
  544. package/dist/external-SQa3Pr0s.js +0 -44
  545. package/dist/external-kaUzEm1U.cjs +0 -46
  546. package/dist/external-mOr1FzAd.cjs +0 -1
  547. package/dist/fontString-4EFXWlQp.cjs +0 -1
  548. package/dist/jsx-runtime-CITbqOLs.cjs +0 -22
  549. package/dist/main-2qH2bggR.cjs +0 -92
  550. package/dist/src/flux/core/params.d.ts +0 -31
  551. package/dist/src/flux/core/params.d.ts.map +0 -1
  552. package/dist/src/input/TextArea.d.ts +0 -25
  553. package/dist/src/input/TextArea.d.ts.map +0 -1
  554. package/dist/src/ranger/TimeRangeChip.d.ts +0 -10
  555. package/dist/src/ranger/TimeRangeChip.d.ts.map +0 -1
  556. package/dist/src/status/Aggregator.d.ts.map +0 -1
  557. package/dist/src/status/Aggregator.spec.d.ts.map +0 -1
  558. package/dist/src/status/Indicator.d.ts.map +0 -1
  559. package/dist/src/status/Notification.d.ts.map +0 -1
  560. package/dist/src/status/Notification.spec.d.ts.map +0 -1
  561. package/dist/src/status/Summary.d.ts +0 -8
  562. package/dist/src/status/Summary.d.ts.map +0 -1
  563. package/dist/src/status/colors.d.ts.map +0 -1
  564. package/dist/src/text/DateTime.d.ts +0 -12
  565. package/dist/src/text/DateTime.d.ts.map +0 -1
  566. package/dist/src/vis/diagram/edge/Edge.d.ts +0 -15
  567. package/dist/src/vis/diagram/edge/Edge.d.ts.map +0 -1
  568. package/dist/src/vis/diagram/edge/connector/connector.d.ts.map +0 -1
  569. package/dist/src/vis/diagram/edge/connector/connector.spec.d.ts.map +0 -1
  570. package/dist/src/vis/diagram/edge/connector/index.d.ts.map +0 -1
  571. package/dist/src/vis/diagram/edge/index.d.ts +0 -2
  572. package/dist/src/vis/diagram/edge/index.d.ts.map +0 -1
  573. package/dist/src/vis/diagram/edge/paths.d.ts +0 -18
  574. package/dist/src/vis/diagram/edge/paths.d.ts.map +0 -1
  575. package/dist/src/vis/lineplot/Axis.d.ts.map +0 -1
  576. package/dist/src/vis/lineplot/Legend.d.ts.map +0 -1
  577. package/dist/src/vis/lineplot/Line.d.ts.map +0 -1
  578. package/dist/src/vis/lineplot/LinePlot.d.ts.map +0 -1
  579. package/dist/src/vis/lineplot/Title.d.ts.map +0 -1
  580. package/dist/src/vis/lineplot/Viewport.d.ts.map +0 -1
  581. package/dist/src/vis/lineplot/aether/BoundQuerier.d.ts.map +0 -1
  582. package/dist/src/vis/lineplot/aether/LinePlot.d.ts.map +0 -1
  583. package/dist/src/vis/lineplot/aether/XAxis.d.ts.map +0 -1
  584. package/dist/src/vis/lineplot/aether/YAxis.d.ts.map +0 -1
  585. package/dist/src/vis/lineplot/aether/axis.d.ts.map +0 -1
  586. package/dist/src/vis/lineplot/aether/external.d.ts.map +0 -1
  587. package/dist/src/vis/lineplot/aether/index.d.ts.map +0 -1
  588. package/dist/src/vis/lineplot/external.d.ts.map +0 -1
  589. package/dist/src/vis/lineplot/index.d.ts.map +0 -1
  590. package/dist/src/vis/lineplot/range/Annotation.d.ts.map +0 -1
  591. package/dist/src/vis/lineplot/range/Provider.d.ts.map +0 -1
  592. package/dist/src/vis/lineplot/range/aether/annotation.d.ts.map +0 -1
  593. package/dist/src/vis/lineplot/range/aether/external.d.ts.map +0 -1
  594. package/dist/src/vis/lineplot/range/aether/index.d.ts.map +0 -1
  595. package/dist/src/vis/lineplot/range/aether/provider.d.ts.map +0 -1
  596. package/dist/src/vis/lineplot/range/external.d.ts.map +0 -1
  597. package/dist/src/vis/lineplot/range/index.d.ts.map +0 -1
  598. package/dist/src/vis/lineplot/tooltip/Tooltip.d.ts.map +0 -1
  599. package/dist/src/vis/lineplot/tooltip/aether/index.d.ts.map +0 -1
  600. package/dist/src/vis/lineplot/tooltip/aether/tooltip.d.ts.map +0 -1
  601. package/dist/src/vis/lineplot/tooltip/index.d.ts.map +0 -1
  602. package/dist/src/vis/lineplot/useBoundQuerier.d.ts.map +0 -1
  603. package/dist/src/vis/log/Log.d.ts.map +0 -1
  604. package/dist/src/vis/log/aether/Log.d.ts.map +0 -1
  605. package/dist/src/vis/log/aether/index.d.ts.map +0 -1
  606. package/dist/src/vis/log/index.d.ts +0 -2
  607. package/dist/src/vis/log/index.d.ts.map +0 -1
  608. package/dist/units-DkdMPsxa.cjs +0 -1
  609. package/dist/useKeysData-B1kiZOOw.js +0 -14
  610. package/dist/useKeysData-G9Mk3mA6.cjs +0 -1
  611. /package/dist/src/{vis/lineplot → lineplot}/aether/external.d.ts +0 -0
  612. /package/dist/src/{vis/lineplot → lineplot}/aether/index.d.ts +0 -0
  613. /package/dist/src/{vis/lineplot → lineplot}/index.d.ts +0 -0
  614. /package/dist/src/{vis/lineplot → lineplot}/range/aether/index.d.ts +0 -0
  615. /package/dist/src/{vis/lineplot → lineplot}/range/external.d.ts +0 -0
  616. /package/dist/src/{vis/lineplot → lineplot}/range/index.d.ts +0 -0
  617. /package/dist/src/{vis/lineplot → lineplot}/tooltip/aether/index.d.ts +0 -0
  618. /package/dist/src/{vis/lineplot → lineplot}/tooltip/index.d.ts +0 -0
  619. /package/dist/src/{vis/lineplot → lineplot}/useBoundQuerier.d.ts +0 -0
  620. /package/dist/src/{vis/log → log}/aether/index.d.ts +0 -0
  621. /package/dist/src/{vis/diagram → schematic}/edge/connector/connector.d.ts +0 -0
  622. /package/dist/src/{vis/diagram → schematic}/edge/connector/connector.spec.d.ts +0 -0
  623. /package/dist/src/{vis/diagram → schematic}/edge/connector/index.d.ts +0 -0
  624. /package/dist/src/status/{Aggregator.spec.d.ts → core/Aggregator.spec.d.ts} +0 -0
  625. /package/dist/src/status/{Notification.spec.d.ts → core/Notification.spec.d.ts} +0 -0
  626. /package/dist/src/status/{colors.d.ts → core/colors.d.ts} +0 -0
@@ -1,63 +0,0 @@
1
- "use strict";const s=require("zod"),p=require("./css-CmXY6iPo.cjs"),ws=require("react"),Ic=t=>{const e=t.replace(/_[a-z]/g,r=>r[1].toUpperCase());return e.length>1&&e[0]===e[0].toUpperCase()&&e[1]===e[1].toUpperCase()||e.length===0?e:e[0].toLowerCase()+e.slice(1)},ri=t=>{const e=(r,n=Mn)=>{if(typeof r=="string")return t(r);if(Array.isArray(r))return r.map(o=>e(o,n));if(!dn(r))return r;n=Uc(n);const a={},i=r;return"toJSON"in i&&typeof i.toJSON=="function"?e(i.toJSON(),n):(Object.keys(i).forEach(o=>{let l=i[o];const c=t(o);n.recursive&&(dn(l)?la(l)||(l=e(l,n)):n.recursiveInArray&&oa(l)&&(l=[...l].map(u=>{let h=u;return dn(u)?la(h)||(h=e(u,n)):oa(u)&&(h=e({key:u},n).key),h}))),a[c]=l}),a)};return e},ni=ri(Ic),jc=t=>t.replace(/([a-z0-9])([A-Z])/g,(e,r,n)=>`${r}_${n.toLowerCase()}`),Rc=ri(jc),Mc=[Number,String,Uint8Array],Mn={recursive:!0,recursiveInArray:!0},Uc=(t=Mn)=>(t.recursive==null?t=Mn:t.recursiveInArray??=!1,t),oa=t=>t!=null&&Array.isArray(t),dn=t=>t!=null&&typeof t=="object"&&!Array.isArray(t),la=t=>Mc.some(e=>t instanceof e);let Lc=class{contentType="application/json";decoder;encoder;constructor(){this.decoder=new TextDecoder,this.encoder=new TextEncoder}encode(t){return this.encoder.encode(this.encodeString(t))}decode(t,e){return this.decodeString(this.decoder.decode(t),e)}decodeString(t,e){const r=JSON.parse(t),n=ni(r);return e!=null?e.parse(n):n}encodeString(t){const e=Rc(t);return JSON.stringify(e,(r,n)=>ArrayBuffer.isView(n)?Array.from(n):typeof n=="bigint"?n.toString():n)}};const Un=new Lc,ne=t=>t!=null&&typeof t=="object"&&"value"in t;let wt=class{value;constructor(t){this.value=t}valueOf(){return this.value}toJSON(){return this.value}toString(){return this.value.toString()}};const Pc=t=>t!=null&&typeof t=="object"&&"toString"in t,Dc=(t,e=!1)=>{const r=Pc(t)?"stringer":typeof t;let n;switch(r){case"string":n=(a,i)=>a.localeCompare(i);break;case"stringer":n=(a,i)=>a.toString().localeCompare(i.toString());break;case"number":n=(a,i)=>Number(a)-Number(i);break;case"bigint":n=(a,i)=>BigInt(a)-BigInt(i)>0n?1:-1;break;case"boolean":n=(a,i)=>Number(a)-Number(i);break;case"undefined":n=()=>0;break;default:return console.warn(`sortFunc: unknown type ${r}`),()=>-1}return e?$c(n):n},$c=t=>(e,r)=>t(r,e),Br=s.z.tuple([s.z.number(),s.z.number()]);s.z.tuple([s.z.bigint(),s.z.bigint()]);const si=s.z.object({width:s.z.number(),height:s.z.number()}),Bc=s.z.object({signedWidth:s.z.number(),signedHeight:s.z.number()}),Zc=["width","height"];s.z.enum(Zc);const Fc=["start","center","end"],qc=["signedWidth","signedHeight"];s.z.enum(qc);const Ir=s.z.object({x:s.z.number(),y:s.z.number()}),Yc=s.z.object({clientX:s.z.number(),clientY:s.z.number()}),Hc=["x","y"],ai=s.z.enum(Hc),ii=["top","right","bottom","left"];s.z.enum(ii);const _c=["left","right"],oi=s.z.enum(_c),Vc=["top","bottom"],li=s.z.enum(Vc),ci=["center"],ca=s.z.enum(ci),Wc=[...ii,...ci],ui=s.z.enum(Wc);s.z.enum(Fc);const Gc=["first","last"];s.z.enum(Gc);const Kc=s.z.object({lower:s.z.number(),upper:s.z.number()}),Jc=s.z.object({lower:s.z.bigint(),upper:s.z.bigint()});s.z.union([Kc,Br]);s.z.union([Jc,Br]);s.z.enum([...ai.options,...ui.options]);s.z.enum(["x","left","right"]);s.z.enum(["y","top","bottom"]);s.z.union([ai,ui,s.z.instanceof(String)]);const Zr=t=>(e,r)=>{if(typeof e=="bigint"){if(Xc(r))return t(e,BigInt(r));const n=t(Number(e),Number(r));return typeof n=="number"?BigInt(Math.round(n)):n}return t(Number(e),Number(r))},Fr=Zr((t,e)=>t-e),qr=Zr((t,e)=>t+e),Xc=t=>typeof t=="bigint"?!0:Number.isInteger(t),ye=Zr((t,e)=>t*e),Yr=Zr((t,e)=>t/e),_e=(t,e,r)=>{const n={};if(typeof e=="object"&&(r=e,e=void 0),r={makeValid:!0,...r},typeof t=="number"||typeof t=="bigint")e!=null?(n.lower=t,n.upper=e):(n.lower=typeof t=="bigint"?0n:0,n.upper=t);else if(Array.isArray(t)){if(t.length!==2)throw new Error("bounds: expected array of length 2");[n.lower,n.upper]=t}else n.lower=t.lower,n.upper=t.upper;return r?.makeValid?Qc(n):n},Qc=t=>t.lower>t.upper?{lower:t.upper,upper:t.lower}:t,ua=(t,e)=>{const r=_e(t);return e<r.lower?r.lower:e>=r.upper?r.upper-(typeof r.upper=="number"?1:1n):e};s.z.object({x:oi.or(ca),y:li.or(ca)});const eu=s.z.object({x:oi,y:li}),tu=Object.freeze({x:"left",y:"top"}),ru=(t,e)=>t.x===e.x&&t.y===e.y,ha=s.z.union([s.z.number(),Ir,Br,si,Bc,Yc]),nu=(t,e)=>{if(typeof t=="string"){if(e===void 0)throw new Error("The y coordinate must be given.");return t==="x"?{x:e,y:0}:{x:0,y:e}}return typeof t=="number"?{x:t,y:e??t}:Array.isArray(t)?{x:t[0],y:t[1]}:"signedWidth"in t?{x:t.signedWidth,y:t.signedHeight}:"clientX"in t?{x:t.clientX,y:t.clientY}:"width"in t?{x:t.width,y:t.height}:{x:t.x,y:t.y}},da=Object.freeze({x:0,y:0}),yr=s.z.union([s.z.number(),s.z.string()]);s.z.object({top:yr,left:yr,width:yr,height:yr});s.z.object({left:s.z.number(),top:s.z.number(),right:s.z.number(),bottom:s.z.number()});s.z.object({one:Ir,two:Ir,root:eu});const bs=(t,e,r=0,n=0,a)=>{const i={one:{...da},two:{...da},root:a??tu};if(typeof t=="number"){if(typeof e!="number")throw new Error("Box constructor called with invalid arguments");return i.one={x:t,y:e},i.two={x:i.one.x+r,y:i.one.y+n},i}return"one"in t&&"two"in t&&"root"in t?{...t,root:a??t.root}:("getBoundingClientRect"in t&&(t=t.getBoundingClientRect()),"left"in t?(i.one={x:t.left,y:t.top},i.two={x:t.right,y:t.bottom},i):(i.one=t,e==null?i.two={x:i.one.x+r,y:i.one.y+n}:typeof e=="number"?i.two={x:i.one.x+e,y:i.one.y+r}:"width"in e?i.two={x:i.one.x+e.width,y:i.one.y+e.height}:"signedWidth"in e?i.two={x:i.one.x+e.signedWidth,y:i.one.y+e.signedHeight}:i.two=e,i))},fn=t=>{const e=bs(t);return{lower:e.one.x,upper:e.two.x}},pn=t=>{const e=bs(t);return{lower:e.one.y,upper:e.two.y}},su=t=>typeof t!="object"||t==null?!1:"one"in t&&"two"in t&&"root"in t,au=s.z.object({signedWidth:s.z.number(),signedHeight:s.z.number()});s.z.union([si,au,Ir,Br]);const iu=(t,e,r)=>e!==void 0&&t<e?e:r!==void 0&&t>r?r:t;s.z.object({offset:ha,scale:ha});s.z.object({offset:s.z.number(),scale:s.z.number()});const ou=t=>(e,r,n,a)=>r==="dimension"?[e,n]:[e,a?n-t:n+t],lu=t=>(e,r,n,a)=>[e,a?n/t:n*t],cu=t=>(e,r,n)=>{if(e===null)return[t,n];const{lower:a,upper:i}=e,{lower:o,upper:l}=t,c=i-a,u=l-o;if(r==="dimension")return[t,n*(u/c)];const h=(n-a)*(u/c)+o;return[t,h]},uu=t=>(e,r,n)=>[t,n],hu=()=>(t,e,r)=>{if(t===null)throw new Error("cannot invert without bounds");if(e==="dimension")return[t,r];const{lower:n,upper:a}=t;return[t,a-(r-n)]},du=t=>(e,r,n)=>{const{lower:a,upper:i}=t;return n=iu(n,a,i),[e,n]};let fa=class tt{ops=[];currBounds=null;currType=null;reversed=!1;constructor(){this.ops=[]}static translate(e){return new tt().translate(e)}static magnify(e){return new tt().magnify(e)}static scale(e,r){return new tt().scale(e,r)}translate(e){const r=this.new(),n=ou(e);return n.type="translate",r.ops.push(n),r}magnify(e){const r=this.new(),n=lu(e);return n.type="magnify",r.ops.push(n),r}scale(e,r){const n=_e(e,r),a=this.new(),i=cu(n);return i.type="scale",a.ops.push(i),a}clamp(e,r){const n=_e(e,r),a=this.new(),i=du(n);return i.type="clamp",a.ops.push(i),a}reBound(e,r){const n=_e(e,r),a=this.new(),i=uu(n);return i.type="re-bound",a.ops.push(i),a}invert(){const e=hu();e.type="invert";const r=this.new();return r.ops.push(e),r}pos(e){return this.exec("position",e)}dim(e){return this.exec("dimension",e)}new(){const e=new tt;return e.ops=this.ops.slice(),e.reversed=this.reversed,e}exec(e,r){return this.currBounds=null,this.ops.reduce(([n,a],i)=>i(n,e,a,this.reversed),[null,r])[1]}reverse(){const e=this.new();e.ops.reverse();const r=[];return e.ops.forEach((n,a)=>{if(n.type==="scale"||r.some(([o,l])=>a>=o&&a<=l))return;const i=e.ops.findIndex((o,l)=>o.type==="scale"&&l>a);i!==-1&&r.push([a,i])}),r.forEach(([n,a])=>{const i=e.ops.slice(n,a);i.unshift(e.ops[a]),e.ops.splice(n,a-n+1,...i)}),e.reversed=!e.reversed,e}get transform(){return{scale:this.dim(1),offset:this.pos(0)}}static IDENTITY=new tt};(class fe{x;y;currRoot;constructor(e=new fa,r=new fa,n=null){this.x=e,this.y=r,this.currRoot=n}static translate(e,r){return new fe().translate(e,r)}static translateX(e){return new fe().translateX(e)}static translateY(e){return new fe().translateY(e)}static clamp(e){return new fe().clamp(e)}static magnify(e){return new fe().magnify(e)}static scale(e){return new fe().scale(e)}static reBound(e){return new fe().reBound(e)}translate(e,r){const n=nu(e,r),a=this.copy();return a.x=this.x.translate(n.x),a.y=this.y.translate(n.y),a}translateX(e){const r=this.copy();return r.x=this.x.translate(e),r}translateY(e){const r=this.copy();return r.y=this.y.translate(e),r}magnify(e){const r=this.copy();return r.x=this.x.magnify(e.x),r.y=this.y.magnify(e.y),r}scale(e){const r=this.copy();if(su(e)){const n=this.currRoot;return r.currRoot=e.root,n!=null&&!ru(n,e.root)&&(n.x!==e.root.x&&(r.x=r.x.invert()),n.y!==e.root.y&&(r.y=r.y.invert())),r.x=r.x.scale(fn(e)),r.y=r.y.scale(pn(e)),r}return r.x=r.x.scale(e.width),r.y=r.y.scale(e.height),r}reBound(e){const r=this.copy();return r.x=this.x.reBound(fn(e)),r.y=this.y.reBound(pn(e)),r}clamp(e){const r=this.copy();return r.x=this.x.clamp(fn(e)),r.y=this.y.clamp(pn(e)),r}copy(){const e=new fe;return e.currRoot=this.currRoot,e.x=this.x,e.y=this.y,e}reverse(){const e=this.copy();return e.x=this.x.reverse(),e.y=this.y.reverse(),e}pos(e){return{x:this.x.pos(e.x),y:this.y.pos(e.y)}}dim(e){return{x:this.x.dim(e.x),y:this.y.dim(e.y)}}box(e){return bs(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})}}static IDENTITY=new fe});let hi=(t,e=21)=>(r=e)=>{let n="",a=r|0;for(;a--;)n+=t[Math.random()*t.length|0];return n};const di="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",fu=`0123456789${di}`,pu=11,yu=hi(di,1),gu=hi(fu,pu-1),mu=()=>`${yu()}${gu()}`,wu=(t,e)=>r=>r instanceof e||typeof r=="object"&&r!==null&&"discriminator"in r&&r.discriminator===t,bu=s.z.enum(["static","dynamic"]),vu=s.z.union([s.z.tuple([s.z.int()]),s.z.tuple([s.z.int(),s.z.int().min(1).max(12)]),s.z.tuple([s.z.int(),s.z.int().min(1).max(12),s.z.int().min(1).max(31)])]),fi=(t,e)=>{const r=new j(e);if(![k.DAY,k.HOUR,k.MINUTE,k.SECOND,k.MILLISECOND,k.MICROSECOND,k.NANOSECOND].some(a=>a.equals(r)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const n=t.valueOf()%r.valueOf();return t instanceof j?new j(n):new k(n)};let j=class w extends wt{constructor(e,r="UTC"){if(e==null)super(w.now().valueOf());else if(e instanceof Date)super(BigInt(e.getTime())*w.MILLISECOND.valueOf());else if(typeof e=="string")super(w.parseDateTimeString(e,r).valueOf());else if(Array.isArray(e))super(w.parseDate(e));else{let n=0n;e instanceof Number&&(e=e.valueOf()),r==="local"&&(n=w.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=w.MAX:e=w.MIN)),ne(e)&&(e=e.value),super(BigInt(e.valueOf())+n)}}static parseDate([e=1970,r=1,n=1]){const a=new Date(e,r-1,n,0,0,0,0);return new w(BigInt(a.getTime())*w.MILLISECOND.valueOf()).truncate(w.DAY).valueOf()}valueOf(){return this.value}static parseTimeString(e,r="UTC"){const[n,a,i]=e.split(":");let o="00",l="00";i!=null&&([o,l]=i.split("."));let c=w.hours(parseInt(n??"00")).add(w.minutes(parseInt(a??"00"))).add(w.seconds(parseInt(o??"00"))).add(w.milliseconds(parseInt(l??"00")));return r==="local"&&(c=c.add(w.utcOffset)),c.valueOf()}static parseDateTimeString(e,r="UTC"){if(!e.includes("/")&&!e.includes("-"))return w.parseTimeString(e,r);const n=new Date(e);return e.includes(":")||n.setUTCHours(0,0,0,0),new w(BigInt(n.getTime())*w.MILLISECOND.valueOf(),r).valueOf()}fString(e="ISO",r="UTC"){switch(e){case"ISODate":return this.toISOString(r).slice(0,10);case"ISOTime":return this.toISOString(r).slice(11,23);case"time":return this.timeString(!1,r);case"preciseTime":return this.timeString(!0,r);case"date":return this.dateString();case"preciseDate":return`${this.dateString()} ${this.timeString(!0,r)}`;case"dateTime":return`${this.dateString()} ${this.timeString(!1,r)}`;default:return this.toISOString(r)}}toISOString(e="UTC"){return e==="UTC"?this.date().toISOString():this.sub(w.utcOffset).date().toISOString()}timeString(e=!1,r="UTC"){const n=this.toISOString(r);return e?n.slice(11,23):n.slice(11,19)}dateString(){const e=this.date(),r=e.toLocaleString("default",{month:"short"}),n=e.toLocaleString("default",{day:"numeric"});return`${r} ${n}`}static get utcOffset(){return new k(BigInt(new Date().getTimezoneOffset())*w.MINUTE.valueOf())}static since(e){return new w().span(e)}date(){return new Date(this.milliseconds)}equals(e){return this.valueOf()===new w(e).valueOf()}span(e){return this.range(e).span}range(e){return new It(this,e).makeValid()}spanRange(e){return this.range(this.add(e)).makeValid()}get isZero(){return this.valueOf()===0n}after(e){return this.valueOf()>new w(e).valueOf()}afterEq(e){return this.valueOf()>=new w(e).valueOf()}before(e){return this.valueOf()<new w(e).valueOf()}beforeEq(e){return this.valueOf()<=new w(e).valueOf()}add(e){return new w(qr(this.valueOf(),new k(e).valueOf()))}sub(e){return new w(Fr(this.valueOf(),new k(e).valueOf()))}get hours(){return Number(this.valueOf())/Number(k.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(k.MINUTE.valueOf())}get days(){return Number(this.valueOf())/Number(k.DAY.valueOf())}get seconds(){return Number(this.valueOf())/Number(k.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(w.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(w.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get year(){return this.date().getUTCFullYear()}setYear(e){const r=this.date();return r.setUTCFullYear(e),new w(r)}get month(){return this.date().getUTCMonth()}setMonth(e){const r=this.date();return r.setUTCMonth(e),new w(r)}get day(){return this.date().getUTCDate()}setDay(e){const r=this.date();return r.setUTCDate(e),new w(r)}get hour(){return this.date().getUTCHours()}get localHour(){return this.date().getHours()}setLocalHour(e){const r=this.date();return r.setHours(e),new w(r)}setHour(e){const r=this.date();return r.setUTCHours(e),new w(r)}get minute(){return this.date().getUTCMinutes()}setMinute(e){const r=this.date();return r.setUTCMinutes(e),new w(r)}get second(){return this.date().getUTCSeconds()}setSecond(e){const r=this.date();return r.setUTCSeconds(e),new w(r)}get millisecond(){return this.date().getUTCMilliseconds()}setMillisecond(e){const r=this.date();return r.setUTCMilliseconds(e),new w(r)}toString(){return this.date().toISOString()}remainder(e){return fi(this,e)}get isToday(){return this.truncate(k.DAY).equals(w.now().truncate(k.DAY))}truncate(e){return this.sub(this.remainder(e))}static now(){return new w(new Date)}static max(...e){let r=w.MIN;for(const n of e){const a=new w(n);a.after(r)&&(r=a)}return r}static min(...e){let r=w.MAX;for(const n of e){const a=new w(n);a.before(r)&&(r=a)}return r}static nanoseconds(e,r="UTC"){return new w(e,r)}static NANOSECOND=w.nanoseconds(1);static microseconds(e,r="UTC"){return w.nanoseconds(e*1e3,r)}static MICROSECOND=w.microseconds(1);static milliseconds(e,r="UTC"){return w.microseconds(e*1e3,r)}static MILLISECOND=w.milliseconds(1);static seconds(e,r="UTC"){return w.milliseconds(e*1e3,r)}static SECOND=w.seconds(1);static minutes(e,r="UTC"){return w.seconds(e*60,r)}static MINUTE=w.minutes(1);static hours(e,r="UTC"){return w.minutes(e*60,r)}static HOUR=w.hours(1);static days(e,r="UTC"){return w.hours(e*24,r)}static DAY=w.days(1);static MAX=new w((1n<<63n)-1n);static MIN=new w(0);static ZERO=new w(0);static z=s.z.union([s.z.instanceof(w),s.z.object({value:s.z.bigint()}).transform(e=>new w(e.value)),s.z.string().transform(e=>new w(BigInt(e))),s.z.number().transform(e=>new w(e)),s.z.bigint().transform(e=>new w(e)),s.z.date().transform(e=>new w(e)),s.z.custom(e=>e instanceof k).transform(e=>new w(e)),vu.transform(e=>new w(e))]);static sort(e,r){return Number(e.valueOf()-r.valueOf())}},k=class v extends wt{constructor(e){typeof e=="number"&&(e=Math.trunc(e.valueOf())),ne(e)&&(e=e.value),super(BigInt(e.valueOf()))}static fromSeconds(e){return e instanceof v?e:e instanceof yn?e.period:e instanceof j?new v(e):(ne(e)&&(e=e.value),["number","bigint"].includes(typeof e)?v.seconds(e):new v(e))}static fromMilliseconds(e){return e instanceof v?e:e instanceof yn?e.period:e instanceof j?new v(e):(ne(e)&&(e=e.value),["number","bigint"].includes(typeof e)?v.milliseconds(e):new v(e))}valueOf(){return this.value}lessThan(e){return this.valueOf()<new v(e).valueOf()}greaterThan(e){return this.valueOf()>new v(e).valueOf()}lessThanOrEqual(e){return this.valueOf()<=new v(e).valueOf()}greaterThanOrEqual(e){return this.valueOf()>=new v(e).valueOf()}remainder(e){return fi(this,e)}truncate(e){return new v(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(){const e=this.truncate(v.DAY),r=this.truncate(v.HOUR),n=this.truncate(v.MINUTE),a=this.truncate(v.SECOND),i=this.truncate(v.MILLISECOND),o=this.truncate(v.MICROSECOND),l=this.truncate(v.NANOSECOND),c=e,u=r.sub(e),h=n.sub(r),f=a.sub(n),d=i.sub(a),z=o.sub(i),N=l.sub(o);let I="";return c.isZero||(I+=`${c.days}d `),u.isZero||(I+=`${u.hours}h `),h.isZero||(I+=`${h.minutes}m `),f.isZero||(I+=`${f.seconds}s `),d.isZero||(I+=`${d.milliseconds}ms `),z.isZero||(I+=`${z.microseconds}µs `),N.isZero||(I+=`${N.nanoseconds}ns`),I.trim()}mult(e){return new v(ye(this.valueOf(),e))}div(e){return new v(Yr(this.valueOf(),e))}get days(){return Number(this.valueOf())/Number(v.DAY.valueOf())}get hours(){return Number(this.valueOf())/Number(v.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(v.MINUTE.valueOf())}get seconds(){return Number(this.valueOf())/Number(v.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 isZero(){return this.valueOf()===0n}equals(e){return this.valueOf()===new v(e).valueOf()}add(e){return new v(this.valueOf()+new v(e).valueOf())}sub(e){return new v(this.valueOf()-new v(e).valueOf())}static nanoseconds(e=1){return new v(e)}static NANOSECOND=v.nanoseconds(1);static microseconds(e=1){return v.nanoseconds(ye(e,1e3))}static MICROSECOND=v.microseconds(1);static milliseconds(e=1){return v.microseconds(ye(e,1e3))}static MILLISECOND=v.milliseconds(1);static seconds(e=1){return v.milliseconds(ye(e,1e3))}static SECOND=v.seconds(1);static minutes(e=1){return v.seconds(ye(e,60))}static MINUTE=v.minutes(1);static hours(e){return v.minutes(ye(e,60))}static HOUR=v.hours(1);static days(e){return v.hours(ye(e,24))}static DAY=v.days(1);static MAX=new v((1n<<63n)-1n);static MIN=new v(0);static ZERO=new v(0);static z=s.z.union([s.z.object({value:s.z.bigint()}).transform(e=>new v(e.value)),s.z.string().transform(e=>new v(BigInt(e))),s.z.number().transform(e=>new v(e)),s.z.bigint().transform(e=>new v(e)),s.z.instanceof(v),s.z.instanceof(j).transform(e=>new v(e)),s.z.custom(e=>e instanceof yn).transform(e=>new v(e))])},yn=class ee extends wt{constructor(e){ne(e)&&(e=e.value),super(e.valueOf())}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new ee(e).valueOf()}get period(){return k.seconds(1/this.valueOf())}sampleCount(e){return new k(e).seconds*this.valueOf()}byteCount(e,r){return this.sampleCount(e)*new V(r).valueOf()}span(e){return k.seconds(e/this.valueOf())}byteSpan(e,r){return this.span(e.valueOf()/new V(r).valueOf())}add(e){return new ee(qr(this.valueOf(),new ee(e).valueOf()))}sub(e){return new ee(Fr(this.valueOf(),new ee(e).valueOf()))}mult(e){return new ee(ye(this.valueOf(),e))}div(e){return new ee(Yr(this.valueOf(),e))}static hz(e){return new ee(e)}static khz(e){return ee.hz(e*1e3)}static z=s.z.union([s.z.number().transform(e=>new ee(e)),s.z.instanceof(ee)])},V=class G extends wt{constructor(e){ne(e)&&(e=e.value),super(e.valueOf())}length(e){return e.valueOf()/this.valueOf()}size(e){return new Ln(e*this.valueOf())}add(e){return new G(qr(this.valueOf(),new G(e).valueOf()))}sub(e){return new G(Fr(this.valueOf(),new G(e).valueOf()))}mult(e){return new G(ye(this.valueOf(),e))}div(e){return new G(Yr(this.valueOf(),e))}static UNKNOWN=new G(0);static BIT128=new G(16);static BIT64=new G(8);static BIT32=new G(4);static BIT16=new G(2);static BIT8=new G(1);static z=s.z.union([s.z.number().transform(e=>new G(e)),s.z.instanceof(G)])},It=class oe{start;end;constructor(e,r){typeof e=="object"&&"start"in e?(this.start=new j(e.start),this.end=new j(e.end)):(this.start=new j(e),this.end=new j(r))}get span(){return new k(this.end.valueOf()-this.start.valueOf())}get isValid(){return this.start.valueOf()<=this.end.valueOf()}makeValid(){return this.isValid?this:this.swap()}get isZero(){return this.span.isZero}get numeric(){return{start:Number(this.start.valueOf()),end:Number(this.end.valueOf())}}swap(){return new oe(this.end,this.start)}get numericBounds(){return{lower:Number(this.start.valueOf()),upper:Number(this.end.valueOf())}}equals(e,r=k.ZERO){if(r.isZero)return this.start.equals(e.start)&&this.end.equals(e.end);let n=this.start.sub(e.start).valueOf(),a=this.end.sub(e.end).valueOf();return n<0&&(n=-n),a<0&&(a=-a),n<=r.valueOf()&&a<=r.valueOf()}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.fString("preciseDate")} - ${this.span.toString()}`}overlapsWith(e,r=k.ZERO){e=e.makeValid();const n=this.makeValid();if(this.equals(e))return!0;if(e.end.equals(n.start)||n.end.equals(e.start))return!1;const a=j.max(n.start,e.start),i=j.min(n.end,e.end);return i.before(a)?!1:new k(i.sub(a)).greaterThanOrEqual(r)}contains(e){return e instanceof oe?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const r=new oe(this.start,this.end);return e.start.after(this.start)&&(r.start=e.start),e.start.after(this.end)&&(r.end=e.start),e.end.before(this.end)&&(r.end=e.end),e.end.before(this.start)&&(r.start=e.end),r}static max(...e){return new oe(j.min(...e.map(r=>r.start)),j.max(...e.map(r=>r.end)))}static MAX=new oe(j.MIN,j.MAX);static MIN=new oe(j.MAX,j.MIN);static ZERO=new oe(j.ZERO,j.ZERO);static z=s.z.union([s.z.object({start:j.z,end:j.z}).transform(e=>new oe(e.start,e.end)),s.z.instanceof(oe)]);static sort(e,r){return j.sort(e.start,r.start)||j.sort(e.end,r.end)}static simplify(e){return e.map(r=>r.makeValid()).sort((r,n)=>oe.sort(r,n)).reduce((r,n)=>{if(n.isZero)return r;if(r.length===0)return r.push(n),r;const a=r[r.length-1];return a.overlapsWith(n)||a.end.equals(n.start)?a.end=j.max(a.end,n.end):r.push(n),r},[])}},$=class y extends wt{constructor(e){if(ne(e)&&(e=e.value),e instanceof y||typeof e=="string"||typeof e.valueOf()=="string")super(e.valueOf());else{const r=y.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(r==null)throw new Error(`unable to find data type for ${e.toString()}`);super(r.valueOf())}}get Array(){const e=y.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(r=>this.equals(r))}toString(){return this.valueOf()}get isVariable(){return this.equals(y.JSON)||this.equals(y.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(y.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=y.DENSITIES.get(this.toString());if(e==null)throw new Error(`unable to find density for ${this.valueOf()}`);return e}get isUnsignedInteger(){return this.equals(y.UINT8)||this.equals(y.UINT16)||this.equals(y.UINT32)||this.equals(y.UINT64)}get isSignedInteger(){return this.equals(y.INT8)||this.equals(y.INT16)||this.equals(y.INT32)||this.equals(y.INT64)}canSafelyCastTo(e){return this.equals(e)?!0:!this.isNumeric||!e.isNumeric||this.isVariable||e.isVariable||this.isUnsignedInteger&&e.isSignedInteger?!1:this.isFloat?e.isFloat&&this.density.valueOf()<=e.density.valueOf():this.equals(y.INT32)&&e.equals(y.FLOAT64)||this.equals(y.INT8)&&e.equals(y.FLOAT32)?!0:this.isInteger&&e.isInteger?this.density.valueOf()<=e.density.valueOf()&&this.isUnsignedInteger===e.isUnsignedInteger:!1}canCastTo(e){return this.isNumeric&&e.isNumeric?!0:this.equals(e)}checkArray(e){return e.constructor===this.Array}get usesBigInt(){return y.BIG_INT_TYPES.some(e=>e.equals(this))}static UNKNOWN=new y("unknown");static FLOAT64=new y("float64");static FLOAT32=new y("float32");static INT64=new y("int64");static INT32=new y("int32");static INT16=new y("int16");static INT8=new y("int8");static UINT64=new y("uint64");static UINT32=new y("uint32");static UINT16=new y("uint16");static UINT8=new y("uint8");static BOOLEAN=this.UINT8;static TIMESTAMP=new y("timestamp");static UUID=new y("uuid");static STRING=new y("string");static JSON=new y("json");static ARRAY_CONSTRUCTORS=new Map([[y.UINT8.toString(),Uint8Array],[y.UINT16.toString(),Uint16Array],[y.UINT32.toString(),Uint32Array],[y.UINT64.toString(),BigUint64Array],[y.FLOAT32.toString(),Float32Array],[y.FLOAT64.toString(),Float64Array],[y.INT8.toString(),Int8Array],[y.INT16.toString(),Int16Array],[y.INT32.toString(),Int32Array],[y.INT64.toString(),BigInt64Array],[y.TIMESTAMP.toString(),BigInt64Array],[y.STRING.toString(),Uint8Array],[y.JSON.toString(),Uint8Array],[y.UUID.toString(),Uint8Array]]);static ARRAY_CONSTRUCTOR_DATA_TYPES=new Map([[Uint8Array.name,y.UINT8],[Uint16Array.name,y.UINT16],[Uint32Array.name,y.UINT32],[BigUint64Array.name,y.UINT64],[Float32Array.name,y.FLOAT32],[Float64Array.name,y.FLOAT64],[Int8Array.name,y.INT8],[Int16Array.name,y.INT16],[Int32Array.name,y.INT32],[BigInt64Array.name,y.INT64]]);static DENSITIES=new Map([[y.UINT8.toString(),V.BIT8],[y.UINT16.toString(),V.BIT16],[y.UINT32.toString(),V.BIT32],[y.UINT64.toString(),V.BIT64],[y.FLOAT32.toString(),V.BIT32],[y.FLOAT64.toString(),V.BIT64],[y.INT8.toString(),V.BIT8],[y.INT16.toString(),V.BIT16],[y.INT32.toString(),V.BIT32],[y.INT64.toString(),V.BIT64],[y.TIMESTAMP.toString(),V.BIT64],[y.STRING.toString(),V.UNKNOWN],[y.JSON.toString(),V.UNKNOWN],[y.UUID.toString(),V.BIT128]]);static ALL=[y.UNKNOWN,y.FLOAT64,y.FLOAT32,y.INT64,y.INT32,y.INT16,y.INT8,y.UINT64,y.UINT32,y.UINT16,y.UINT8,y.TIMESTAMP,y.UUID,y.STRING,y.JSON];static BIG_INT_TYPES=[y.INT64,y.UINT64,y.TIMESTAMP];static z=s.z.union([s.z.string().transform(e=>new y(e)),s.z.instanceof(y)])},Ln=class x extends wt{constructor(e){ne(e)&&(e=e.value),super(e.valueOf())}largerThan(e){return ne(e)&&(e=e.value),this.valueOf()>e.valueOf()}smallerThan(e){return ne(e)&&(e=e.value),this.valueOf()<e.valueOf()}add(e){return ne(e)&&(e=e.value),new x(qr(this.valueOf(),e.valueOf()))}sub(e){return ne(e)&&(e=e.value),new x(Fr(this.valueOf(),e.valueOf()))}mult(e){return new x(ye(this.valueOf(),e))}div(e){return new x(Yr(this.valueOf(),e))}truncate(e){return new x(Math.trunc(this.valueOf()/new x(e).valueOf())*new x(e).valueOf())}remainder(e){return x.bytes(this.valueOf()%new x(e).valueOf())}get gigabytes(){return this.valueOf()/x.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/x.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/x.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/x.TERABYTE.valueOf()}toString(){const e=this.truncate(x.TERABYTE),r=this.truncate(x.GIGABYTE),n=this.truncate(x.MEGABYTE),a=this.truncate(x.KILOBYTE),i=this.truncate(x.BYTE),o=e,l=r.sub(e),c=n.sub(r),u=a.sub(n),h=i.sub(a);let f="";return o.isZero||(f+=`${o.terabytes}TB `),l.isZero||(f+=`${l.gigabytes}GB `),c.isZero||(f+=`${c.megabytes}MB `),u.isZero||(f+=`${u.kilobytes}KB `),(!h.isZero||f==="")&&(f+=`${h.valueOf()}B`),f.trim()}static bytes(e=1){return new x(e)}static BYTE=new x(1);static kilobytes(e=1){return x.bytes(new x(e).valueOf()*1e3)}static KILOBYTE=x.kilobytes(1);static megabytes(e=1){return x.kilobytes(new x(e).valueOf()*1e3)}static MEGABYTE=x.megabytes(1);static gigabytes(e=1){return x.megabytes(new x(e).valueOf()*1e3)}static GIGABYTE=x.gigabytes(1);static terabytes(e){return x.gigabytes(new x(e).valueOf()*1e3)}static TERABYTE=x.terabytes(1);static ZERO=new x(0);static z=s.z.union([s.z.number().transform(e=>new x(e)),s.z.instanceof(x)]);get isZero(){return this.valueOf()===0}};s.z.union([s.z.instanceof(Uint8Array),s.z.instanceof(Uint16Array),s.z.instanceof(Uint32Array),s.z.instanceof(BigUint64Array),s.z.instanceof(Float32Array),s.z.instanceof(Float64Array),s.z.instanceof(Int8Array),s.z.instanceof(Int16Array),s.z.instanceof(Int32Array),s.z.instanceof(BigInt64Array)]);const pi=t=>{const e=typeof t;return e==="string"||e==="number"||e==="boolean"||e==="bigint"||t instanceof j||t instanceof k||t instanceof Date},Tu=(t,e,r,n=0)=>t.usesBigInt&&!e.usesBigInt?Number(r)-Number(n):!t.usesBigInt&&e.usesBigInt?BigInt(r.valueOf())-BigInt(n.valueOf()):zr(r,-n),zr=(t,e)=>e==0?t:t==0?e:typeof t=="bigint"&&typeof e=="bigint"||typeof t=="number"&&typeof e=="number"?t+e:Number(t)+Number(e),Ou=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;function zu(t){return typeof t=="string"&&Ou.test(t)}const q=[];for(let t=0;t<256;++t)q.push((t+256).toString(16).slice(1));function Su(t,e=0){return(q[t[e+0]]+q[t[e+1]]+q[t[e+2]]+q[t[e+3]]+"-"+q[t[e+4]]+q[t[e+5]]+"-"+q[t[e+6]]+q[t[e+7]]+"-"+q[t[e+8]]+q[t[e+9]]+"-"+q[t[e+10]]+q[t[e+11]]+q[t[e+12]]+q[t[e+13]]+q[t[e+14]]+q[t[e+15]]).toLowerCase()}function Eu(t,e=0){const r=Su(t,e);if(!zu(r))throw TypeError("Stringified UUID is invalid");return r}typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const yi=(t,e)=>Eu(t,e),Ne=-1,Nu=s.z.string().transform(t=>new Uint8Array(atob(t).split("").map(e=>e.charCodeAt(0))).buffer),xu=s.z.union([s.z.null(),s.z.undefined()]).transform(()=>new Uint8Array().buffer),Pn=10,Au=(t,e)=>{if(t==="number"&&!e.isNumeric)throw new Error(`cannot convert series of type ${e.toString()} to number`);if(t==="bigint"&&!e.usesBigInt)throw new Error(`cannot convert series of type ${e.toString()} to bigint`)},gi="sy_x_telem_series";let mi=class Ce{key;discriminator=gi;dataType;sampleOffset;gl;_data;timeRange=It.ZERO;alignment=0n;alignmentMultiple=1n;cachedMin;cachedMax;writePos=Ne;_refCount=0;cachedLength;_cachedIndexes;static crudeZ=s.z.object({timeRange:It.z.optional(),dataType:$.z,alignment:s.z.coerce.bigint().optional(),data:s.z.union([Nu,xu,s.z.instanceof(ArrayBuffer),s.z.instanceof(Uint8Array)]),glBufferUsage:bu.optional().default("static").optional()});static z=Ce.crudeZ.transform(e=>new Ce(e));constructor(e){ku(e)&&(e={data:e}),e.data??=[];const{dataType:r,timeRange:n,sampleOffset:a=0,glBufferUsage:i="static",alignment:o=0n,alignmentMultiple:l=1n,key:c=mu(),data:u}=e;if(Cu(u)){const d=u;this.key=d.key,this.dataType=d.dataType,this.sampleOffset=d.sampleOffset,this.gl=d.gl,this._data=d._data,this.timeRange=d.timeRange,this.alignment=d.alignment,this.alignmentMultiple=d.alignmentMultiple,this.cachedMin=d.cachedMin,this.cachedMax=d.cachedMax,this.writePos=d.writePos,this._refCount=d._refCount,this.cachedLength=d.cachedLength;return}const h=pi(u),f=Array.isArray(u);if(r!=null)this.dataType=new $(r);else{if(u instanceof ArrayBuffer)throw new Error("cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type.");if(f||h){let d=u;if(!h){if(u.length===0)throw new Error("cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type.");d=u[0]}if(typeof d=="string")this.dataType=$.STRING;else if(typeof d=="number")this.dataType=$.FLOAT64;else if(typeof d=="bigint")this.dataType=$.INT64;else if(typeof d=="boolean")this.dataType=$.BOOLEAN;else if(d instanceof j||d instanceof Date||d instanceof j)this.dataType=$.TIMESTAMP;else if(typeof d=="object")this.dataType=$.JSON;else throw new Error(`cannot infer data type of ${typeof d} when constructing a Series from a JS array`)}else this.dataType=new $(u)}if(!f&&!h)this._data=u;else if(f&&u.length===0)this._data=new this.dataType.Array([]).buffer;else{let d=h?[u]:u;const z=d[0];(z instanceof j||z instanceof Date||z instanceof k)&&(d=d.map(N=>new j(N).valueOf())),this.dataType.equals($.STRING)?(this.cachedLength=d.length,this._data=new TextEncoder().encode(`${d.join(`
2
- `)}
3
- `).buffer):this.dataType.equals($.JSON)?(this.cachedLength=d.length,this._data=new TextEncoder().encode(`${d.map(N=>Un.encodeString(N)).join(`
4
- `)}
5
- `).buffer):this.dataType.usesBigInt&&typeof z=="number"?this._data=new this.dataType.Array(d.map(N=>BigInt(Math.round(N)))).buffer:!this.dataType.usesBigInt&&typeof z=="bigint"?this._data=new this.dataType.Array(d.map(Number)).buffer:this._data=new this.dataType.Array(d).buffer}this.key=c,this.alignment=o,this.alignmentMultiple=l,this.sampleOffset=a??0,this.timeRange=n??It.ZERO,this.gl={control:null,buffer:null,prevBuffer:0,bufferUsage:i}}static alloc({capacity:e,dataType:r,...n}){if(e===0)throw new Error("[Series] - cannot allocate an array of length 0");const a=new new $(r).Array(e),i=new Ce({data:a.buffer,dataType:r,...n});return i.writePos=0,i}get refCount(){return this._refCount}acquire(e){this._refCount++,e!=null&&this.updateGLBuffer(e)}release(){this._refCount--,this.refCount===0&&this.gl.control!=null?this.maybeGarbageCollectGLBuffer(this.gl.control):this.refCount<0&&console.warn("cannot release a series with a negative reference count")}write(e){if(!e.dataType.equals(this.dataType))throw new Error("buffer must be of the same type as this array");return this.dataType.isVariable?this.writeVariable(e):this.writeFixed(e)}writeVariable(e){if(this.writePos===Ne)return 0;const r=this.byteCapacity.valueOf()-this.writePos,n=e.subBytes(0,r);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===Ne)return 0;const r=this.capacity-this.writePos,n=e.sub(0,r);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===Ne?this.underlyingData:new this.dataType.Array(this._data,0,this.writePos)}toStrings(){return this.dataType.isVariable?new TextDecoder().decode(this.underlyingData).split(`
6
- `).slice(0,-1):Array.from(this).map(e=>e.toString())}parseJSON(e){if(!this.dataType.equals($.JSON))throw new Error("cannot parse non-JSON series as JSON");return this.toStrings().map(r=>e.parse(Un.decodeString(r)))}get byteCapacity(){return new Ln(this.underlyingData.byteLength)}get capacity(){return this.dataType.isVariable?this.byteCapacity.valueOf():this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===Ne?this.byteCapacity:this.dataType.isVariable?new Ln(this.writePos):this.dataType.density.size(this.writePos)}get length(){return this.cachedLength!=null?this.cachedLength:this.dataType.isVariable?this.calculateCachedLength():this.writePos===Ne?this.byteCapacity.valueOf()/this.dataType.density.valueOf():this.writePos}calculateCachedLength(){if(!this.dataType.isVariable)throw new Error("cannot calculate length of a non-variable length data type");let e=0;const r=[0];return this.data.forEach((n,a)=>{n===Pn&&(e++,r.push(a+1))}),this._cachedIndexes=r,this.cachedLength=e,e}convert(e,r=0){if(this.dataType.equals(e))return this;const n=new e.Array(this.length);for(let a=0;a<this.length;a++)n[a]=Tu(this.dataType,e,this.data[a],r);return new Ce({data:n.buffer,dataType:e,timeRange:this.timeRange,sampleOffset:r,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment})}calcRawMax(){if(this.length===0)return-1/0;if(this.dataType.equals($.TIMESTAMP))this.cachedMax=this.data[this.data.length-1];else if(this.dataType.usesBigInt){const e=this.data;this.cachedMax=e.reduce((r,n)=>r>n?r:n)}else{const e=this.data;this.cachedMax=e.reduce((r,n)=>r>n?r:n)}return this.cachedMax}get max(){return this.calcMax()}calcMax(){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.calcRawMax(),zr(this.cachedMax,this.sampleOffset))}calcRawMin(){if(this.length===0)return 1/0;if(this.dataType.equals($.TIMESTAMP))this.cachedMin=this.data[0];else if(this.dataType.usesBigInt){const e=this.data;this.cachedMin=e.reduce((r,n)=>r<n?r:n)}else{const e=this.data;this.cachedMin=e.reduce((r,n)=>r<n?r:n)}return this.cachedMin}get min(){return this.calcMin()}calcMin(){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.calcRawMin(),zr(this.cachedMin,this.sampleOffset))}get bounds(){return _e(Number(this.min),Number(this.max),{makeValid:!1})}maybeRecomputeMinMax(e){if(this.cachedMin!=null){const r=e.cachedMin??e.calcRawMin();r<this.cachedMin&&(this.cachedMin=r)}if(this.cachedMax!=null){const r=e.cachedMax??e.calcRawMax();r>this.cachedMax&&(this.cachedMax=r)}}atAlignment(e,r){const n=Number((e-this.alignment)/this.alignmentMultiple);if(n<0||n>=this.length){if(r===!0)throw new Error(`[series] - no value at index ${n}`);return}return this.at(n,r)}at(e,r=!1){if(this.dataType.isVariable)return this.atVariable(e,r??!1);if(this.dataType.equals($.UUID))return this.atUUID(e,r);e<0&&(e=this.length+e);const n=this.data[e];if(n==null){if(r===!0)throw new Error(`[series] - no value at index ${e}`);return}return zr(n,this.sampleOffset)}atUUID(e,r){e<0&&(e=this.length+e);const n=yi(new Uint8Array(this.buffer,e*this.dataType.density.valueOf()));if(n==null){if(r)throw new Error(`[series] - no value at index ${e}`);return}return n}atVariable(e,r){let n=0,a=0;if(this._cachedIndexes!=null)n=this._cachedIndexes[e],a=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]===Pn){if(e===0){a=o;break}n=o+1,e--}if(a===0&&(a=this.data.length),n>=a||e>0){if(r)throw new Error(`[series] - no value at index ${e}`);return}}const i=this.data.slice(n,a);return this.dataType.equals($.STRING)?new TextDecoder().decode(i):ni(JSON.parse(new TextDecoder().decode(i)))}binarySearch(e){let r=0,n=this.length-1;const a=Dc(e);for(;r<=n;){const i=Math.floor((r+n)/2),o=a(this.at(i,!0),e);if(o===0)return i;o<0?r=i+1:n=i-1}return r}updateGLBuffer(e){if(this.gl.control=e,!this.dataType.equals($.FLOAT32)&&!this.dataType.equals($.UINT8))throw new Error("Only FLOAT32 and UINT8 arrays can be used in WebGL");const{buffer:r,bufferUsage:n,prevBuffer:a}=this.gl;if(r==null&&(this.gl.buffer=e.createBuffer()),this.writePos!==a)if(e.bindBuffer(e.ARRAY_BUFFER,this.gl.buffer),this.writePos!==Ne){a===0&&e.bufferData(e.ARRAY_BUFFER,this.byteCapacity.valueOf(),e.STATIC_DRAW);const i=this.dataType.density.size(a).valueOf(),o=this.underlyingData.slice(this.gl.prevBuffer,this.writePos);e.bufferSubData(e.ARRAY_BUFFER,i,o.buffer),this.gl.prevBuffer=this.writePos}else e.bufferData(e.ARRAY_BUFFER,this.buffer,n==="static"?e.STATIC_DRAW:e.DYNAMIC_DRAW),this.gl.prevBuffer=Ne}as(e){return Au(e,this.dataType),this}get digest(){return{key:this.key,dataType:this.dataType.toString(),sampleOffset:this.sampleOffset,alignment:{lower:ya(this.alignmentBounds.lower),upper:ya(this.alignmentBounds.upper),multiple:this.alignmentMultiple},timeRange:this.timeRange.toString(),length:this.length,capacity:this.capacity}}get alignmentBounds(){return _e(this.alignment,this.alignment+BigInt(this.length)*this.alignmentMultiple)}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 Iu(this);return this.dataType.equals($.JSON)?new ju(e):e}return this.dataType.equals($.UUID)?new Ru(this):new Mu(this)}slice(e,r){return this.sliceSub(!1,e,r)}sub(e,r){return this.sliceSub(!0,e,r)}subIterator(e,r){return new pa(this,e,r??this.length)}subAlignmentIterator(e,r){const n=Math.ceil(Number(e-this.alignment)/Number(this.alignmentMultiple)),a=Math.ceil(Number(r-this.alignment)/Number(this.alignmentMultiple));return new pa(this,n,a)}subBytes(e,r){if(e>=0&&(r==null||r>=this.byteLength.valueOf()))return this;const n=this.data.subarray(e,r);return new Ce({data:n,dataType:this.dataType,timeRange:this.timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(e)})}sliceSub(e,r,n){if(r<=0&&(n==null||n>=this.length))return this;let a;return e?a=this.data.subarray(r,n):a=this.data.slice(r,n),new Ce({data:a,dataType:this.dataType,timeRange:this.timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(r)})}reAlign(e){return new Ce({data:this.buffer,dataType:this.dataType,timeRange:It.ZERO,sampleOffset:this.sampleOffset,glBufferUsage:"static",alignment:e})}toString(){let e=`Series(${this.dataType.toString()} ${this.length} [`;if(this.length<=10)e+=Array.from(this).map(r=>r.toString());else{for(let r=0;r<5;r++)e+=`${this.at(r)?.toString()}`,e+=",";e+="...,";for(let r=-5;r<0;r++)e+=this.at(r)?.toString(),r<-1&&(e+=",")}return e+="])",e}};const ku=t=>t==null?!1:Array.isArray(t)||t instanceof ArrayBuffer||ArrayBuffer.isView(t)&&!(t instanceof DataView)||t instanceof mi?!0:pi(t),Cu=wu(gi,mi);let pa=class{series;end;index;constructor(t,e,r){this.series=t;const n=_e(0,t.length+1);this.end=ua(n,r),this.index=ua(n,e)}next(){return this.index>=this.end?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}};class Iu{series;index;decoder;constructor(e){if(!e.dataType.isVariable)throw new Error("cannot create a variable series iterator for a non-variable series");this.series=e,this.index=0,this.decoder=new TextDecoder}next(){const e=this.index,r=this.series.data;for(;this.index<r.length&&r[this.index]!==Pn;)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))})}}let ju=class wi{wrapped;static schema=s.z.record(s.z.string(),s.z.unknown());constructor(e){this.wrapped=e}next(){const e=this.wrapped.next();return e.done===!0?{done:!0,value:void 0}:{done:!1,value:Un.decodeString(e.value,wi.schema)}}},Ru=class{series;index;data;density;constructor(t){if(!t.dataType.equals($.UUID))throw new Error("cannot create a UUID series iterator for a non-UUID series");this.series=t,this.index=0,this.data=new Uint8Array(t.buffer),this.density=$.UUID.density.valueOf()}next(){if(this.index>=this.series.length)return{done:!0,value:void 0};const t=yi(this.data,this.index*this.density);return this.index++,{done:!1,value:t}}};class Mu{series;index;constructor(e){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)}}}const ya=t=>{const e=t>>32n,r=t&0xffffffffn;return{domain:e,sample:r}};s.z.object({key:s.z.string(),value:s.z.string()});s.z.record(s.z.union([s.z.number(),s.z.string(),s.z.symbol()]),s.z.unknown());const Uu=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser";Uu();const Lu=["macOS","Windows","Linux"],Pu=["macos","windows","linux"],Du={macos:"macOS",windows:"Windows",linux:"Linux"};s.z.enum(Lu).or(s.z.enum(Pu).transform(t=>Du[t]));const $u=(...t)=>t.map(bi).join(""),bi=t=>(t.endsWith("/")||(t+="/"),t.startsWith("/")&&(t=t.slice(1)),t),Bu=t=>t.endsWith("/")?t.slice(0,-1):t,Zu=(t,e="")=>t===null?"":`?${Object.entries(t).filter(([,r])=>r==null?!1:Array.isArray(r)?r.length>0:!0).map(([r,n])=>`${e}${r}=${n}`).join("&")}`;let Fu=class Sr{protocol;host;port;path;constructor({host:e,port:r,protocol:n="",pathPrefix:a=""}){this.protocol=n,this.host=e,this.port=r,this.path=bi(a)}replace(e){return new Sr({host:e.host??this.host,port:e.port??this.port,protocol:e.protocol??this.protocol,pathPrefix:e.pathPrefix??this.path})}child(e){return new Sr({...this,pathPrefix:$u(this.path,e)})}toString(){return Bu(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}static UNKNOWN=new Sr({host:"unknown",port:0})};const qu=async t=>await new Promise(e=>setTimeout(e,k.fromMilliseconds(t).milliseconds));class Yu{config;retries;interval;constructor(e){this.config={baseInterval:new k(e?.baseInterval??k.seconds(1)),maxRetries:e?.maxRetries??5,scale:e?.scale??1,sleepFn:e?.sleepFn??qu},this.retries=0,this.interval=new k(this.config.baseInterval)}async wait(){const{maxRetries:e,scale:r,sleepFn:n}=this.config;return this.retries>=e?!1:(await n(this.interval),this.interval=this.interval.mult(r),this.retries++,!0)}get retryMessage(){return`breaker triggered ${this.retries+1}/${this.config.maxRetries} times, retrying in ${this.interval.toString()}`}reset(){this.retries=0,this.interval=this.config.baseInterval}}const Hu=s.z.object({baseInterval:k.z.optional(),maxRetries:s.z.number().optional(),scale:s.z.number().optional()}),_u=Object.freeze(Object.defineProperty({__proto__:null,Breaker:Yu,breakerConfigZ:Hu},Symbol.toStringTag,{value:"Module"})),Vu=/^#?([0-9a-f]{6}|[0-9a-f]{8})$/i,vi=s.z.string().regex(Vu),ct=s.z.number().min(0).max(255),Ti=s.z.number().min(0).max(1),Oi=s.z.tuple([ct,ct,ct,Ti]),Wu=s.z.tuple([ct,ct,ct]),Gu=s.z.object({rgba255:Oi}),Ku=s.z.number().min(0).max(360),Ju=s.z.number().min(0).max(100),Xu=s.z.number().min(0).max(100),Qu=s.z.tuple([Ku,Ju,Xu,Ti]),vs=s.z.union([vi,Wu,Oi,Qu,Gu]),eh=vs.transform(t=>Ts(t)),Ts=(t,e=1)=>{if(t=vs.parse(t),typeof t=="string")return th(t,e);if(Array.isArray(t)){if(t.length<3||t.length>4)throw new Error(`Invalid color: [${t.join(", ")}]`);return t.length===3?[...t,e]:t}return t.rgba255},th=(t,e=1)=>(t=vi.parse(t),t=rh(t),[gr(t,0),gr(t,2),gr(t,4),t.length===8?gr(t,6)/255:e]),gr=(t,e)=>parseInt(t.slice(e,e+2),16),rh=t=>t.startsWith("#")?t.slice(1):t;Ts("#000000");Ts("#ffffff");const nh=s.z.object({key:s.z.string(),color:vs,position:s.z.number(),switched:s.z.boolean().optional()});s.z.array(nh);const sh=s.z.object({key:s.z.string(),name:s.z.string(),color:eh});s.z.object({key:s.z.string(),name:s.z.string(),swatches:s.z.array(sh)});s.z.int().min(0).max(255);s.z.object({name:s.z.string(),key:s.z.string()});const ah=t=>Object.getOwnPropertySymbols(globalThis).includes(t),ih=(t,e)=>{const r=Symbol.for(t);if(!ah(r)){const n=e();Object.defineProperty(globalThis,r,{value:n})}return()=>globalThis[r]},zi="sy_x_error",oh=t=>e=>e!=null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"?e.type.startsWith(t):e instanceof Error?e.message.startsWith(t):typeof e!="string"?!1:e.startsWith(t),Xt=t=>class jt extends Error{static discriminator=zi;discriminator=jt.discriminator;static TYPE=t;type=jt.TYPE;static matches=oh(t);matches=jt.matches;constructor(r,n){super(r,n),this.name=jt.TYPE}static sub(r){return Xt(`${t}.${r}`)}},Si=t=>{if(t==null||typeof t!="object")return!1;const e=t;if(e.discriminator!==zi)return!1;if(!("type"in e))throw new Error(`X Error is missing its type property: ${JSON.stringify(e)}`);return!0},rt="unknown",Dn="nil";class lh{providers=[];register(e){this.providers.push(e)}encode(e){if(e==null)return{type:Dn,data:""};if(Si(e))for(const r of this.providers){const n=r.encode(e);if(n!=null)return n}if(e instanceof Error)return{type:rt,data:e.message};if(typeof e=="string")return{type:rt,data:e};try{return{type:rt,data:JSON.stringify(e)}}catch{return{type:rt,data:"unable to encode error information"}}}decode(e){if(e==null||e.type===Dn)return null;if(e.type===rt)return new $n(e.data);for(const r of this.providers){const n=r.decode(e);if(n!=null)return n}return new $n(e.data)}}const Os=ih("synnax-error-registry",()=>new lh),ch=({encode:t,decode:e})=>Os().register({encode:t,decode:e}),uh=t=>Os().encode(t),hh=t=>t==null?null:Os().decode(t);let $n=class extends Xt("unknown"){};const dh=s.z.object({type:s.z.string(),data:s.z.string()});class fh extends Xt("canceled"){}class ph extends Xt("not_implemented"){}const Pe=Object.freeze(Object.defineProperty({__proto__:null,Canceled:fh,NONE:Dn,NotImplemented:ph,UNKNOWN:rt,Unknown:$n,createTyped:Xt,decode:hh,encode:uh,isTyped:Si,payloadZ:dh,register:ch},Symbol.toStringTag,{value:"Module"})),yh=s.object({jsonrpc:s.literal("2.0"),method:s.string(),params:s.any().optional(),id:s.union([s.string(),s.number(),s.null()]).optional()}),Ei=s.object({jsonrpc:s.literal("2.0"),id:s.union([s.string(),s.number(),s.null()])}),gh=Ei.extend({result:s.json()}),mh=Ei.extend({error:s.object({code:s.number().int(),message:s.string().optional(),data:s.json().optional()})}),wh=s.union([gh,mh]);s.union([yh,wh]);s.z.string().regex(/^\d+\.\d+\.\d+$/);const bh=["standard","scientific","engineering"];s.z.enum(bh);s.z.enum(["success","info","warning","error","loading","disabled"]);let Qt=class extends Pe.createTyped("freighter"){},ue=class extends Qt.sub("eof"){constructor(){super("EOF")}},ht=class extends Qt.sub("stream_closed"){constructor(){super("StreamClosed")}},De=class extends Qt.sub("unreachable"){url;constructor(t={}){const{message:e="Unreachable",url:r=Fu.UNKNOWN}=t;super(e),this.url=r}};const vh=t=>{if(!t.type.startsWith(Qt.TYPE))return null;if(ue.matches(t))return{type:ue.TYPE,data:"EOF"};if(ht.matches(t))return{type:ht.TYPE,data:"StreamClosed"};if(De.matches(t))return{type:De.TYPE,data:"Unreachable"};throw new Error(`Unknown error type: ${t.type}: ${t.message}`)},Th=t=>{if(!t.type.startsWith(Qt.TYPE))return null;switch(t.type){case ue.TYPE:return new ue;case ht.TYPE:return new ht;case De.TYPE:return new De;default:throw new Pe.Unknown(`Unknown error type: ${t.data}`)}};Pe.register({encode:vh,decode:Th});class Ni{middleware=[];use(...e){this.middleware.push(...e)}async executeMiddleware(e,r){let n=0;const a=async i=>{if(n===this.middleware.length)return await r(i);const o=this.middleware[n];return n++,await o(i,a)};return await a(e)}}const xi="Content-Type",Oh=new Set(["ECONNREFUSED","ECONNRESET","ETIMEDOUT","EPIPE","UND_ERR_CONNECT_TIMEOUT","UND_ERR_SOCKET"]),zh=t=>{const e=t?.cause?.code??t?.code??t?.errno;if(typeof e=="string"&&Oh.has(e))return!0;if(t.name==="TypeError"){const r=String(t.message||"").toLowerCase();if(/load failed|failed to fetch|networkerror|network error/.test(r))return!0}return t?.name==="AbortError"||t?.code,!1},Sh=400;class Eh extends Ni{endpoint;encoder;constructor(e,r,n=!1){return super(),this.endpoint=e.replace({protocol:n?"https":"http"}),this.encoder=r,new Proxy(this,{get:(a,i,o)=>i==="endpoint"?this.endpoint:Reflect.get(a,i,o)})}get headers(){return{[xi]:this.encoder.contentType}}async send(e,r,n,a){r=n?.parse(r);let i=null;const o=this.endpoint.child(e),l={};l.method="POST",l.body=this.encoder.encode(r??{});const[,c]=await this.executeMiddleware({target:o.toString(),protocol:this.endpoint.protocol,params:{},role:"client"},async u=>{const h={...u,params:{}};l.headers={...this.headers,...u.params};let f;try{f=await fetch(u.target,l)}catch(z){if(!(z instanceof Error))throw z;return[h,zh(z)?new De({url:o}):z]}const d=await f.arrayBuffer();if(f?.ok)return a!=null&&(i=this.encoder.decode(d,a)),[h,null];try{if(f.status!==Sh)return[h,new Error(f.statusText)];const z=this.encoder.decode(d,Pe.payloadZ),N=Pe.decode(z);return[h,N]}catch(z){return[h,new Error(`[freighter] - failed to decode error: ${f.statusText}: ${z.message}`)]}});if(c!=null)return[null,c];if(i==null)throw new Error("Response must be defined");return[i,null]}}const Nh=(t,e)=>{class r{wrapped;constructor(a){this.wrapped=a}use(...a){this.wrapped.use(...a)}async send(a,i,o,l){const c=new _u.Breaker(e);do{const[u,h]=await this.wrapped.send(a,i,o,l);if(h==null)return[u,null];if(!De.matches(h))return[null,h];if(console.warn(`[freighter] ${c.retryMessage}`,h),!await c.wait())return[u,h]}while(!0)}}return new r(t)},m=async(t,e,r,n,a)=>{const[i,o]=await t.send(e,r,n,a);if(o!=null)throw o;return i},xh=s.z.object({type:s.z.enum(["data","close","open"]),payload:s.z.unknown(),error:s.z.optional(Pe.payloadZ)});class Ah{codec;reqSchema;resSchema;ws;serverClosed;sendClosed;receiveDataQueue=[];receiveCallbacksQueue=[];constructor(e,r,n,a){this.codec=r,this.reqSchema=n,this.resSchema=a,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 Pe.decode(e.error)}return null}send(e){if(this.serverClosed!=null)return new ue;if(this.sendClosed)throw new ht;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");if(this.serverClosed=Pe.decode(e.error),this.serverClosed==null)throw new Error("Message error must be defined");return[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,r)=>this.receiveCallbacksQueue.push({resolve:e,reject:r}))}addMessage(e){const r=this.receiveCallbacksQueue.shift();r!=null?r.resolve(e):this.receiveDataQueue.push(e)}listenForMessages(){this.ws.onmessage=this.onMessage.bind(this),this.ws.onclose=this.onClose.bind(this)}onMessage(e){this.addMessage(this.codec.decode(e.data,xh))}onClose(e){this.addMessage({type:"close",error:{type:e.code===Ch?ue.TYPE:ht.TYPE,data:""}})}}const kh="freighterctx",Ch=1e3;class jr extends Ni{baseUrl;encoder;secure;static MESSAGE_TYPE="arraybuffer";constructor(e,r,n=!1){super(),this.secure=n,this.baseUrl=e.replace({protocol:n?"wss":"ws"}),this.encoder=r}withCodec(e){const r=new jr(this.baseUrl,e,this.secure);return r.use(...this.middleware),r}async stream(e,r,n){let a;const[,i]=await this.executeMiddleware({target:e,protocol:"websocket",params:{},role:"client"},async o=>{const l=new WebSocket(this.buildURL(e,o)),c={...o,params:{}};l.binaryType=jr.MESSAGE_TYPE;const u=await this.wrapSocket(l,r,n);return u instanceof Error?[c,u]:(a=u,[c,null])});if(i!=null)throw i;return a}buildURL(e,r){const n=Zu({[xi]:this.encoder.contentType,...r.params},kh);return this.baseUrl.child(e).toString()+n}async wrapSocket(e,r,n){return await new Promise(a=>{e.onopen=()=>{const i=new Ah(e,this.encoder,r,n);i.receiveOpenAck().then(o=>{o!=null?a(o):a(i)}).catch(o=>a(o))},e.onerror=i=>{const o=i;a(new Error(o.message))}})}}const Ih=t=>Array.isArray(t)?t:t==null?[]:[t],O=Object.freeze(Object.defineProperty({__proto__:null,toArray:Ih},Symbol.toStringTag,{value:"Module"})),jh=t=>{const e=t.replace(/_[a-z]/g,r=>r[1].toUpperCase());return e.length>1&&e[0]===e[0].toUpperCase()&&e[1]===e[1].toUpperCase()||e.length===0?e:e[0].toLowerCase()+e.slice(1)},Hr=t=>{const e=(r,n=Bn)=>{if(typeof r=="string")return t(r);if(Array.isArray(r))return r.map(o=>e(o,n));if(!gn(r))return r;n=Uh(n);const a={},i=r;return"toJSON"in i&&typeof i.toJSON=="function"?e(i.toJSON(),n):(Object.keys(i).forEach(o=>{let l=i[o];const c=t(o);n.recursive&&(gn(l)?ma(l)||(l=e(l,n)):n.recursiveInArray&&ga(l)&&(l=[...l].map(u=>{let h=u;return gn(u)?ma(h)||(h=e(u,n)):ga(u)&&(h=e({key:u},n).key),h}))),a[c]=l}),a)};return e},zs=Hr(jh),Rh=t=>t.replace(/([a-z0-9])([A-Z])/g,(e,r,n)=>`${r}_${n.toLowerCase()}`),Ai=Hr(Rh),ki=t=>t.length===0?t:t[0].toUpperCase()+t.slice(1),Mh=[Number,String,Uint8Array],Bn={recursive:!0,recursiveInArray:!0},Uh=(t=Bn)=>(t.recursive==null?t=Bn:t.recursiveInArray??=!1,t),ga=t=>t!=null&&Array.isArray(t),gn=t=>t!=null&&typeof t=="object"&&!Array.isArray(t),ma=t=>Mh.some(e=>t instanceof e),Lh=t=>t.replace(/\s+/g,"-").replace(/([a-z0-9])([A-Z])/g,(e,r,n)=>`${r}-${n.toLowerCase()}`).toLowerCase(),Ph=Hr(Lh),Dh=t=>{if(t.length===0)return t;let e=t.replace(/[_-]/g," ");return e=e.replace(/([a-z0-9])([A-Z])/g,(r,n,a)=>`${n} ${a}`),e=e.replace(/([A-Z]+)([A-Z][a-z])/g,(r,n,a)=>`${n} ${a}`),e=e.replace(/\s+/g," ").trim(),e=e.replace(/\b\w/g,r=>r.toUpperCase()),e},$h=Hr(Dh),Bh=Object.freeze(Object.defineProperty({__proto__:null,camelToSnake:Ai,capitalize:ki,snakeToCamel:zs,toKebab:Ph,toProperNoun:$h},Symbol.toStringTag,{value:"Module"})),Ci=t=>t!=null&&typeof t=="object"&&!Array.isArray(t);let Ii=class{contentType="application/json";decoder;encoder;constructor(){this.decoder=new TextDecoder,this.encoder=new TextEncoder}encode(t){return this.encoder.encode(this.encodeString(t))}decode(t,e){return this.decodeString(this.decoder.decode(t),e)}decodeString(t,e){const r=JSON.parse(t),n=zs(r);return e!=null?e.parse(n):n}encodeString(t){const e=Ai(t);return JSON.stringify(e,(r,n)=>ArrayBuffer.isView(n)?Array.from(n):typeof n=="bigint"?n.toString():n)}},ji=class{contentType="text/csv";encode(t){const e=this.encodeString(t);return new TextEncoder().encode(e)}decode(t,e){const r=new TextDecoder().decode(t);return this.decodeString(r,e)}encodeString(t){if(!Array.isArray(t)||t.length===0||!Ci(t[0]))throw new Error("Payload must be an array of objects");const e=Object.keys(t[0]),r=[e.join(",")];return t.forEach(n=>{const a=e.map(i=>JSON.stringify(n[i]??""));r.push(a.join(","))}),r.join(`
7
- `)}decodeString(t,e){const[r,...n]=t.trim().split(`
8
- `).map(o=>o.trim());if(r.length===0)return e!=null?e.parse({}):{};const a=r.split(",").map(o=>o.trim()),i={};return a.forEach(o=>{i[o]=[]}),n.forEach(o=>{const l=o.split(",").map(c=>c.trim());a.forEach((c,u)=>{const h=this.parseValue(l[u]);h!=null&&i[c].push(h)})}),e!=null?e.parse(i):i}parseValue(t){if(t==null||t.length===0)return null;const e=Number(t);return isNaN(e)?t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1):t:e}},Ri=class{contentType="text/plain";encode(t){if(typeof t!="string")throw new Error("TextCodec.encode payload must be a string");return new TextEncoder().encode(t)}decode(t,e){const r=new TextDecoder().decode(t);return e!=null?e.parse(r):r}};const $t=new Ii,Zh=new ji,Fh=new Ri,qh=[$t],Ke=Object.freeze(Object.defineProperty({__proto__:null,CSVCodec:ji,CSV_CODEC:Zh,ENCODERS:qh,JSONCodec:Ii,JSON_CODEC:$t,TEXT_CODEC:Fh,TextCodec:Ri},Symbol.toStringTag,{value:"Module"})),Zn=t=>[...new Set(t)],Yh=(t,e,r=!0)=>{const n=new Map;return t.forEach(a=>{const i=e(a);if(n.has(i)){if(r)return;n.delete(i)}n.set(i,a)}),Array.from(n.values())},wa=Object.freeze(Object.defineProperty({__proto__:null,by:Yh,unique:Zn},Symbol.toStringTag,{value:"Module"})),se=t=>t!=null&&typeof t=="object"&&"value"in t;let bt=class{value;constructor(t){this.value=t}valueOf(){return this.value}toJSON(){return this.value}toString(){return this.value.toString()}};const Hh=t=>t!=null&&typeof t=="object"&&"toString"in t,_r=(t,e=!1)=>{const r=Hh(t)?"stringer":typeof t;let n;switch(r){case"string":n=(a,i)=>a.localeCompare(i);break;case"stringer":n=(a,i)=>a.toString().localeCompare(i.toString());break;case"number":n=(a,i)=>Number(a)-Number(i);break;case"bigint":n=(a,i)=>BigInt(a)-BigInt(i)>0n?1:-1;break;case"boolean":n=(a,i)=>Number(a)-Number(i);break;case"undefined":n=()=>0;break;default:return console.warn(`sortFunc: unknown type ${r}`),()=>-1}return e?Ui(n):n},_h=(t,e,r)=>{const n=_r(e[t],r);return(a,i)=>n(a[t],i[t])},Vh=(t,e)=>t.length!==e.length?t.length-e.length:t.every((r,n)=>r===e[n])?0:-1,Mi=(t,e)=>{if(t.length!==e.length)return t.length-e.length;if(t.length===0)return 0;const r=_r(t[0]),n=[...t].sort(r),a=[...e].sort(r);return n.every((i,o)=>i===a[o])?0:-1},Wh=(t,e)=>{const r=Zn(t),n=Zn(e);return Mi(r,n)},Gh=(t,e)=>t===e?0:t==="first"&&e==="last"?1:-1,Ui=t=>(e,r)=>t(r,e),vt=0,Er=-1,Nr=1,Li=t=>t<vt,Pi=t=>t>vt,Kh=t=>t>=vt,Di=t=>t===vt,Jh=(t,e)=>{const r=/([a-zA-Z]+)|(\d+)/g,n=t.replace(/[\s_.-]+/g,"").match(r),a=e.replace(/[\s_.-]+/g,"").match(r);if(!n||!a)return 0;for(let i=0;i<Math.min(n.length,a.length);i++){const o=n[i],l=a[i];if(isNaN(Number(o))&&isNaN(Number(l))){const c=o.localeCompare(l);if(c!==0)return c}else if(!isNaN(Number(o))&&!isNaN(Number(l))){const c=Number(o)-Number(l);if(c!==0)return c}else return isNaN(Number(o))?-1:1}return n.length-a.length},ba=Object.freeze(Object.defineProperty({__proto__:null,EQUAL:vt,GREATER_THAN:Nr,LESS_THAN:Er,isEqualTo:Di,isGreaterThan:Pi,isGreaterThanEqual:Kh,isLessThan:Li,newF:_r,newFieldF:_h,order:Gh,primitiveArrays:Vh,reverseF:Ui,stringsWithNumbers:Jh,uniqueUnorderedPrimitiveArrays:Wh,unorderedPrimitiveArrays:Mi},Symbol.toStringTag,{value:"Module"})),Vr=s.z.tuple([s.z.number(),s.z.number()]);s.z.tuple([s.z.bigint(),s.z.bigint()]);const $i=s.z.object({width:s.z.number(),height:s.z.number()}),Xh=s.z.object({signedWidth:s.z.number(),signedHeight:s.z.number()}),Qh=["width","height"];s.z.enum(Qh);const ed=["start","center","end"],td=["signedWidth","signedHeight"];s.z.enum(td);const Bt=s.z.object({x:s.z.number(),y:s.z.number()}),Bi=s.z.object({clientX:s.z.number(),clientY:s.z.number()}),Zi=["x","y"],Fi=s.z.enum(Zi),Ss=["top","right","bottom","left"],rd=s.z.enum(Ss),qi=["left","right"],Es=s.z.enum(qi),Yi=["top","bottom"],Ns=s.z.enum(Yi),xs=["center"],Fn=s.z.enum(xs),nd=[...Ss,...xs],As=s.z.enum(nd);s.z.enum(ed);const sd=["first","last"];s.z.enum(sd);const ad=s.z.object({lower:s.z.number(),upper:s.z.number()}),id=s.z.object({lower:s.z.bigint(),upper:s.z.bigint()});s.z.union([ad,Vr]);s.z.union([id,Vr]);s.z.enum([...Fi.options,...As.options]);s.z.enum(["x","left","right"]);s.z.enum(["y","top","bottom"]);const od=s.z.union([Fi,As,s.z.instanceof(String)]),er=t=>(e,r)=>{if(typeof e=="bigint"){if(Hi(r))return t(e,BigInt(r));const n=t(Number(e),Number(r));return typeof n=="number"?BigInt(Math.round(n)):n}return t(Number(e),Number(r))},Ve=er((t,e)=>t-e),tr=er((t,e)=>t+e),va=(t,e)=>{const r=typeof t=="bigint";return r&&typeof e=="bigint"?t===e:r&&Hi(e)?t===BigInt(e):t===e},ld=er((t,e)=>t<=e?t:e),Hi=t=>typeof t=="bigint"?!0:Number.isInteger(t),cd=t=>typeof t=="bigint"?t<0n?-t:t:t<0?-t:t,ge=er((t,e)=>t*e),Wr=er((t,e)=>t/e),H=(t,e,r)=>{const n={};if(typeof e=="object"&&(r=e,e=void 0),r={makeValid:!0,...r},typeof t=="number"||typeof t=="bigint")e!=null?(n.lower=t,n.upper=e):(n.lower=typeof t=="bigint"?0n:0,n.upper=t);else if(Array.isArray(t)){if(t.length!==2)throw new Error("bounds: expected array of length 2");[n.lower,n.upper]=t}else n.lower=t.lower,n.upper=t.upper;return r?.makeValid?ud(n):n},ud=t=>t.lower>t.upper?{lower:t.upper,upper:t.lower}:t,Ta=(t,e)=>{const r=H(t);return e<r.lower?r.lower:e>=r.upper?r.upper-(typeof r.upper=="number"?1:1n):e},mr=(t,e)=>{const r=H(t);if(typeof e=="number"||typeof e=="bigint")return e>=r.lower&&e<r.upper;const n=H(e);return n.lower>=r.lower&&n.upper<=r.upper},hd=t=>({lower:Math.min(...t.map(e=>H(e).lower)),upper:Math.max(...t.map(e=>H(e).upper))}),dd=(t,e,r)=>{const n=t.map(l=>H(l)),a=r>0?1:r<0?-1:0;if(a===0)return e;let i=r,o=e;for(;va(i,0)===!1;){const l=n.findIndex(c=>a>0?o>=c.lower&&o<c.upper:o>c.lower&&o<=c.upper);if(l!==-1){const c=n[l];let u;if(a>0?u=Ve(c.upper,o):u=Ve(o,c.lower),u>0){const h=ld(cd(i),u);if(o=tr(o,a>0?h:-h),i=Ve(i,a>0?h:-h),va(i,0))return o;continue}}if(a>0){const c=n.filter(u=>u.lower>o);if(c.length>0)o=c[0].lower;else return o}else{const c=n.filter(u=>u.upper<o);if(c.length>0)o=c[c.length-1].upper;else return o}}return o},fd=(t,e,r)=>{const n=t.map(o=>H(o));if(e===r)return typeof e=="bigint"?0n:0;const a=e<r?H([e,r]):H([r,e]);let i=typeof e=="bigint"?0n:0;for(const o of n){const l=o.lower>a.lower?o.lower:a.lower,c=o.upper<a.upper?o.upper:a.upper;if(l<c){const u=c-l;i=i+u}}return i},pd=Es,yd=Ns,gd=Fn,md={top:"bottom",right:"left",bottom:"top",left:"right",center:"center"},wd={top:"left",right:"top",bottom:"right",left:"bottom",center:"center"},bd=od,$e=t=>t instanceof String||!Zi.includes(t)?t:t==="x"?"left":"top",vd=t=>md[$e(t)],Td=t=>wd[$e(t)],Zt=t=>{const e=$e(t);return e==="top"||e==="bottom"?"y":"x"},Od=s.z.object({x:Es.or(Fn),y:Ns.or(Fn)}),_i=s.z.object({x:Es,y:Ns}),ks=Object.freeze({x:"left",y:"top"}),Vi=Object.freeze({x:"right",y:"top"}),Wi=Object.freeze({x:"left",y:"bottom"}),Gi=Object.freeze({x:"right",y:"bottom"}),Cs=Object.freeze({x:"center",y:"center"}),Ki=Object.freeze({x:"center",y:"top"}),Ji=Object.freeze({x:"center",y:"bottom"}),Xi=Object.freeze({x:"right",y:"center"}),Qi=Object.freeze({x:"left",y:"center"}),zd=Object.freeze([Qi,Xi,Ki,Ji,ks,Vi,Wi,Gi,Cs]),eo=(t,e)=>t.x===e.x&&t.y===e.y,Sd=(t,e)=>{if(typeof e=="object"){let r=!0;return"x"in e&&(t.x===e.x||(r=!1)),"y"in e&&(t.y===e.y||(r=!1)),r}return t.x===e||t.y===e},Ed=t=>[t.x,t.y],xr=t=>Zt($e(t))==="x",Nd=t=>Zt($e(t))==="y",xd=t=>`${t.x}${ki(t.y)}`,Ad=(t,e)=>{let r,n;if(typeof t=="object"&&"x"in t?(r=t.x,n=t.y):(r=$e(t),n=$e(e??t)),Zt(r)===Zt(n)&&r!=="center"&&n!=="center")throw new Error(`[XYLocation] - encountered two locations with the same direction: ${r.toString()} - ${n.toString()}`);const a={...Cs};return r==="center"?xr(n)?[a.x,a.y]=[n,r]:[a.x,a.y]=[r,n]:n==="center"?xr(r)?[a.x,a.y]=[r,n]:[a.x,a.y]=[n,r]:xr(r)?[a.x,a.y]=[r,n]:[a.x,a.y]=[n,r],a},kd=Object.freeze(Object.defineProperty({__proto__:null,BOTTOM_CENTER:Ji,BOTTOM_LEFT:Wi,BOTTOM_RIGHT:Gi,CENTER:Cs,CENTER_LEFT:Qi,CENTER_LOCATIONS:xs,CENTER_RIGHT:Xi,OUTER_LOCATIONS:Ss,TOP_CENTER:Ki,TOP_LEFT:ks,TOP_RIGHT:Vi,XY_LOCATIONS:zd,X_LOCATIONS:qi,Y_LOCATIONS:Yi,center:gd,construct:$e,constructXY:Ad,corner:_i,crude:bd,direction:Zt,isX:xr,isY:Nd,location:As,outer:rd,rotate90:Td,swap:vd,x:pd,xy:Od,xyCouple:Ed,xyEquals:eo,xyMatches:Sd,xyToString:xd,y:yd},Symbol.toStringTag,{value:"Module"})),qn=s.z.union([s.z.number(),Bt,Vr,$i,Xh,Bi]),U=(t,e)=>{if(typeof t=="string"){if(e===void 0)throw new Error("The y coordinate must be given.");return t==="x"?{x:e,y:0}:{x:0,y:e}}return typeof t=="number"?{x:t,y:e??t}:Array.isArray(t)?{x:t[0],y:t[1]}:"signedWidth"in t?{x:t.signedWidth,y:t.signedHeight}:"clientX"in t?{x:t.clientX,y:t.clientY}:"width"in t?{x:t.width,y:t.height}:{x:t.x,y:t.y}},Ge=Object.freeze({x:0,y:0}),Cd=Object.freeze({x:1,y:1}),Id=Object.freeze({x:1/0,y:1/0}),jd=Object.freeze({x:NaN,y:NaN}),to=(t,e,r=0)=>{const n=U(t),a=U(e);return r===0?n.x===a.x&&n.y===a.y:Math.abs(n.x-a.x)<=r&&Math.abs(n.y-a.y)<=r},Rd=t=>to(t,Ge),Is=(t,e,r)=>{const n=U(t),a=U(e,r);return{x:n.x*a.x,y:n.y*a.y}},ro=(t,e)=>{const r=U(t);return{x:r.x+e,y:r.y}},no=(t,e)=>{const r=U(t);return{x:r.x,y:r.y+e}},so=(t,e,r,...n)=>{if(typeof e=="string"){if(typeof r!="number")throw new Error("The value must be a number.");return e==="x"?ro(t,r):no(t,r)}if(typeof e=="object"&&"x"in e&&typeof e.x=="string"){const a=U(r),i=U(t);return e.x==="left"?a.x=-a.x:e.x==="center"&&(a.x=0),e.y==="top"?a.y=-a.y:e.y==="center"&&(a.y=0),{x:i.x+a.x,y:i.y+a.y}}return[t,e,r??Ge,...n].reduce((a,i)=>{const o=U(i);return{x:a.x+o.x,y:a.y+o.y}},Ge)},Md=(t,e,r)=>{const n=U(t);return e==="x"?{x:r,y:n.y}:{x:n.x,y:r}},Ud=(t,e)=>{const r=U(t),n=U(e);return Math.sqrt((r.x-n.x)**2+(r.y-n.y)**2)},Ld=(t,e)=>{const r=U(t),n=U(e);return{x:n.x-r.x,y:n.y-r.y}},Pd=t=>{const e=U(t);return Number.isNaN(e.x)||Number.isNaN(e.y)},Dd=t=>{const e=U(t);return Number.isFinite(e.x)&&Number.isFinite(e.y)},$d=t=>{const e=U(t);return[e.x,e.y]},Bd=t=>{const e=U(t);return{left:e.x,top:e.y}},Zd=(t,e=0)=>{const r=U(t);return{x:Number(r.x.toFixed(e)),y:Number(r.y.toFixed(e))}},Rt=(t,e)=>{const r=U(t),n=U(e);return{x:r.x-n.x,y:r.y-n.y}},Mt=t=>{const e=U(t),r=Math.hypot(e.x,e.y);return r===0?{x:0,y:0}:{x:-e.y/r,y:e.x/r}},ao=t=>{const e=U(t),r=Math.hypot(e.x,e.y);return r===0?{x:0,y:0}:{x:e.x/r,y:e.y/r}},io=(...t)=>{const e=t.reduce((r,n)=>so(r,n),Ge);return Is(e,1/t.length)},Fd=(t,e)=>{const r=[];for(let n=0;n<t.length;n++){const a=t[n];let i,o,l,c;if(n===0){const u=t[n+1],h=Rt(u,a);o=Mt(h),l=o,c=e}else if(n===t.length-1){const u=t[n-1],h=Rt(a,u);i=Mt(h),l=i,c=e}else{const u=t[n-1],h=t[n+1],f=Rt(a,u),d=Rt(h,a);i=Mt(f),o=Mt(d);const z=Math.acos((f.x*d.x+f.y*d.y)/(Math.hypot(f.x,f.y)*Math.hypot(d.x,d.y))),N=Math.sin(z/2);N===0?c=e:c=e/N,l=ao(io(i,o))}r.push(Is(l,c))}return r},qd=t=>{const e=U(t);return{x:e.y,y:e.x}},Yd=t=>{const e=U(t);return{x:Math.round(e.x),y:Math.round(e.y)}},oo=Object.freeze(Object.defineProperty({__proto__:null,INFINITY:Id,NAN:jd,ONE:Cd,ZERO:Ge,average:io,calculateMiters:Fd,clientXY:Bi,construct:U,couple:$d,crudeZ:qn,css:Bd,distance:Ud,equals:to,isFinite:Dd,isNan:Pd,isZero:Rd,normal:Mt,normalize:ao,round:Yd,scale:Is,set:Md,sub:Rt,swap:qd,translate:so,translateX:ro,translateY:no,translation:Ld,truncate:Zd,xy:Bt},Symbol.toStringTag,{value:"Module"})),wr=s.z.union([s.z.number(),s.z.string()]);s.z.object({top:wr,left:wr,width:wr,height:wr});s.z.object({left:s.z.number(),top:s.z.number(),right:s.z.number(),bottom:s.z.number()});s.z.object({one:Bt,two:Bt,root:_i});const js=(t,e,r=0,n=0,a)=>{const i={one:{...Ge},two:{...Ge},root:a??ks};if(typeof t=="number"){if(typeof e!="number")throw new Error("Box constructor called with invalid arguments");return i.one={x:t,y:e},i.two={x:i.one.x+r,y:i.one.y+n},i}return"one"in t&&"two"in t&&"root"in t?{...t,root:a??t.root}:("getBoundingClientRect"in t&&(t=t.getBoundingClientRect()),"left"in t?(i.one={x:t.left,y:t.top},i.two={x:t.right,y:t.bottom},i):(i.one=t,e==null?i.two={x:i.one.x+r,y:i.one.y+n}:typeof e=="number"?i.two={x:i.one.x+e,y:i.one.y+r}:"width"in e?i.two={x:i.one.x+e.width,y:i.one.y+e.height}:"signedWidth"in e?i.two={x:i.one.x+e.signedWidth,y:i.one.y+e.signedHeight}:i.two=e,i))},mn=t=>{const e=js(t);return{lower:e.one.x,upper:e.two.x}},wn=t=>{const e=js(t);return{lower:e.one.y,upper:e.two.y}},Hd=t=>typeof t!="object"||t==null?!1:"one"in t&&"two"in t&&"root"in t,_d=s.z.object({signedWidth:s.z.number(),signedHeight:s.z.number()});s.z.union([$i,_d,Bt,Vr]);const Vd=(t,e,r)=>e!==void 0&&t<e?e:r!==void 0&&t>r?r:t;s.z.object({offset:qn,scale:qn});s.z.object({offset:s.z.number(),scale:s.z.number()});const Wd=t=>(e,r,n,a)=>r==="dimension"?[e,n]:[e,a?n-t:n+t],Gd=t=>(e,r,n,a)=>[e,a?n/t:n*t],Kd=t=>(e,r,n)=>{if(e===null)return[t,n];const{lower:a,upper:i}=e,{lower:o,upper:l}=t,c=i-a,u=l-o;if(r==="dimension")return[t,n*(u/c)];const h=(n-a)*(u/c)+o;return[t,h]},Jd=t=>(e,r,n)=>[t,n],Xd=()=>(t,e,r)=>{if(t===null)throw new Error("cannot invert without bounds");if(e==="dimension")return[t,r];const{lower:n,upper:a}=t;return[t,a-(r-n)]},Qd=t=>(e,r,n)=>{const{lower:a,upper:i}=t;return n=Vd(n,a,i),[e,n]};let Oa=class nt{ops=[];currBounds=null;currType=null;reversed=!1;constructor(){this.ops=[]}static translate(e){return new nt().translate(e)}static magnify(e){return new nt().magnify(e)}static scale(e,r){return new nt().scale(e,r)}translate(e){const r=this.new(),n=Wd(e);return n.type="translate",r.ops.push(n),r}magnify(e){const r=this.new(),n=Gd(e);return n.type="magnify",r.ops.push(n),r}scale(e,r){const n=H(e,r),a=this.new(),i=Kd(n);return i.type="scale",a.ops.push(i),a}clamp(e,r){const n=H(e,r),a=this.new(),i=Qd(n);return i.type="clamp",a.ops.push(i),a}reBound(e,r){const n=H(e,r),a=this.new(),i=Jd(n);return i.type="re-bound",a.ops.push(i),a}invert(){const e=Xd();e.type="invert";const r=this.new();return r.ops.push(e),r}pos(e){return this.exec("position",e)}dim(e){return this.exec("dimension",e)}new(){const e=new nt;return e.ops=this.ops.slice(),e.reversed=this.reversed,e}exec(e,r){return this.currBounds=null,this.ops.reduce(([n,a],i)=>i(n,e,a,this.reversed),[null,r])[1]}reverse(){const e=this.new();e.ops.reverse();const r=[];return e.ops.forEach((n,a)=>{if(n.type==="scale"||r.some(([o,l])=>a>=o&&a<=l))return;const i=e.ops.findIndex((o,l)=>o.type==="scale"&&l>a);i!==-1&&r.push([a,i])}),r.forEach(([n,a])=>{const i=e.ops.slice(n,a);i.unshift(e.ops[a]),e.ops.splice(n,a-n+1,...i)}),e.reversed=!e.reversed,e}get transform(){return{scale:this.dim(1),offset:this.pos(0)}}static IDENTITY=new nt};(class pe{x;y;currRoot;constructor(e=new Oa,r=new Oa,n=null){this.x=e,this.y=r,this.currRoot=n}static translate(e,r){return new pe().translate(e,r)}static translateX(e){return new pe().translateX(e)}static translateY(e){return new pe().translateY(e)}static clamp(e){return new pe().clamp(e)}static magnify(e){return new pe().magnify(e)}static scale(e){return new pe().scale(e)}static reBound(e){return new pe().reBound(e)}translate(e,r){const n=U(e,r),a=this.copy();return a.x=this.x.translate(n.x),a.y=this.y.translate(n.y),a}translateX(e){const r=this.copy();return r.x=this.x.translate(e),r}translateY(e){const r=this.copy();return r.y=this.y.translate(e),r}magnify(e){const r=this.copy();return r.x=this.x.magnify(e.x),r.y=this.y.magnify(e.y),r}scale(e){const r=this.copy();if(Hd(e)){const n=this.currRoot;return r.currRoot=e.root,n!=null&&!eo(n,e.root)&&(n.x!==e.root.x&&(r.x=r.x.invert()),n.y!==e.root.y&&(r.y=r.y.invert())),r.x=r.x.scale(mn(e)),r.y=r.y.scale(wn(e)),r}return r.x=r.x.scale(e.width),r.y=r.y.scale(e.height),r}reBound(e){const r=this.copy();return r.x=this.x.reBound(mn(e)),r.y=this.y.reBound(wn(e)),r}clamp(e){const r=this.copy();return r.x=this.x.clamp(mn(e)),r.y=this.y.clamp(wn(e)),r}copy(){const e=new pe;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 js(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})}}static IDENTITY=new pe});let lo=(t,e=21)=>(r=e)=>{let n="",a=r|0;for(;a--;)n+=t[Math.random()*t.length|0];return n};const co="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",ef=`0123456789${co}`,uo=11,tf=lo(co,1),rf=lo(ef,uo-1),Rs=()=>`${tf()}${rf()}`,nf=Object.freeze(Object.defineProperty({__proto__:null,LENGTH:uo,create:Rs},Symbol.toStringTag,{value:"Module"})),sf=(t,e)=>r=>r instanceof e||typeof r=="object"&&r!==null&&"discriminator"in r&&r.discriminator===t,af=s.z.enum(["static","dynamic"]),of=s.z.union([s.z.tuple([s.z.int()]),s.z.tuple([s.z.int(),s.z.int().min(1).max(12)]),s.z.tuple([s.z.int(),s.z.int().min(1).max(12),s.z.int().min(1).max(31)])]),ho=(t,e)=>{const r=new E(e);if(![S.DAY,S.HOUR,S.MINUTE,S.SECOND,S.MILLISECOND,S.MICROSECOND,S.NANOSECOND].some(a=>a.equals(r)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const n=t.valueOf()%r.valueOf();return t instanceof E?new E(n):new S(n)};let E=class b extends bt{constructor(e,r="UTC"){if(e==null)super(b.now().valueOf());else if(e instanceof Date)super(BigInt(e.getTime())*b.MILLISECOND.valueOf());else if(typeof e=="string")super(b.parseDateTimeString(e,r).valueOf());else if(Array.isArray(e))super(b.parseDate(e));else{let n=0n;e instanceof Number&&(e=e.valueOf()),r==="local"&&(n=b.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=b.MAX:e=b.MIN)),se(e)&&(e=e.value),super(BigInt(e.valueOf())+n)}}static parseDate([e=1970,r=1,n=1]){const a=new Date(e,r-1,n,0,0,0,0);return new b(BigInt(a.getTime())*b.MILLISECOND.valueOf()).truncate(b.DAY).valueOf()}valueOf(){return this.value}static parseTimeString(e,r="UTC"){const[n,a,i]=e.split(":");let o="00",l="00";i!=null&&([o,l]=i.split("."));let c=b.hours(parseInt(n??"00")).add(b.minutes(parseInt(a??"00"))).add(b.seconds(parseInt(o??"00"))).add(b.milliseconds(parseInt(l??"00")));return r==="local"&&(c=c.add(b.utcOffset)),c.valueOf()}static parseDateTimeString(e,r="UTC"){if(!e.includes("/")&&!e.includes("-"))return b.parseTimeString(e,r);const n=new Date(e);return e.includes(":")||n.setUTCHours(0,0,0,0),new b(BigInt(n.getTime())*b.MILLISECOND.valueOf(),r).valueOf()}fString(e="ISO",r="UTC"){switch(e){case"ISODate":return this.toISOString(r).slice(0,10);case"ISOTime":return this.toISOString(r).slice(11,23);case"time":return this.timeString(!1,r);case"preciseTime":return this.timeString(!0,r);case"date":return this.dateString();case"preciseDate":return`${this.dateString()} ${this.timeString(!0,r)}`;case"dateTime":return`${this.dateString()} ${this.timeString(!1,r)}`;default:return this.toISOString(r)}}toISOString(e="UTC"){return e==="UTC"?this.date().toISOString():this.sub(b.utcOffset).date().toISOString()}timeString(e=!1,r="UTC"){const n=this.toISOString(r);return e?n.slice(11,23):n.slice(11,19)}dateString(){const e=this.date(),r=e.toLocaleString("default",{month:"short"}),n=e.toLocaleString("default",{day:"numeric"});return`${r} ${n}`}static get utcOffset(){return new S(BigInt(new Date().getTimezoneOffset())*b.MINUTE.valueOf())}static since(e){return new b().span(e)}date(){return new Date(this.milliseconds)}equals(e){return this.valueOf()===new b(e).valueOf()}span(e){return this.range(e).span}range(e){return new P(this,e).makeValid()}spanRange(e){return this.range(this.add(e)).makeValid()}get isZero(){return this.valueOf()===0n}after(e){return this.valueOf()>new b(e).valueOf()}afterEq(e){return this.valueOf()>=new b(e).valueOf()}before(e){return this.valueOf()<new b(e).valueOf()}beforeEq(e){return this.valueOf()<=new b(e).valueOf()}add(e){return new b(tr(this.valueOf(),new S(e).valueOf()))}sub(e){return new b(Ve(this.valueOf(),new S(e).valueOf()))}get hours(){return Number(this.valueOf())/Number(S.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(S.MINUTE.valueOf())}get days(){return Number(this.valueOf())/Number(S.DAY.valueOf())}get seconds(){return Number(this.valueOf())/Number(S.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(b.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(b.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get year(){return this.date().getUTCFullYear()}setYear(e){const r=this.date();return r.setUTCFullYear(e),new b(r)}get month(){return this.date().getUTCMonth()}setMonth(e){const r=this.date();return r.setUTCMonth(e),new b(r)}get day(){return this.date().getUTCDate()}setDay(e){const r=this.date();return r.setUTCDate(e),new b(r)}get hour(){return this.date().getUTCHours()}get localHour(){return this.date().getHours()}setLocalHour(e){const r=this.date();return r.setHours(e),new b(r)}setHour(e){const r=this.date();return r.setUTCHours(e),new b(r)}get minute(){return this.date().getUTCMinutes()}setMinute(e){const r=this.date();return r.setUTCMinutes(e),new b(r)}get second(){return this.date().getUTCSeconds()}setSecond(e){const r=this.date();return r.setUTCSeconds(e),new b(r)}get millisecond(){return this.date().getUTCMilliseconds()}setMillisecond(e){const r=this.date();return r.setUTCMilliseconds(e),new b(r)}toString(){return this.date().toISOString()}remainder(e){return ho(this,e)}get isToday(){return this.truncate(S.DAY).equals(b.now().truncate(S.DAY))}truncate(e){return this.sub(this.remainder(e))}static now(){return new b(new Date)}static max(...e){let r=b.MIN;for(const n of e){const a=new b(n);a.after(r)&&(r=a)}return r}static min(...e){let r=b.MAX;for(const n of e){const a=new b(n);a.before(r)&&(r=a)}return r}static nanoseconds(e,r="UTC"){return new b(e,r)}static NANOSECOND=b.nanoseconds(1);static microseconds(e,r="UTC"){return b.nanoseconds(e*1e3,r)}static MICROSECOND=b.microseconds(1);static milliseconds(e,r="UTC"){return b.microseconds(e*1e3,r)}static MILLISECOND=b.milliseconds(1);static seconds(e,r="UTC"){return b.milliseconds(e*1e3,r)}static SECOND=b.seconds(1);static minutes(e,r="UTC"){return b.seconds(e*60,r)}static MINUTE=b.minutes(1);static hours(e,r="UTC"){return b.minutes(e*60,r)}static HOUR=b.hours(1);static days(e,r="UTC"){return b.hours(e*24,r)}static DAY=b.days(1);static MAX=new b((1n<<63n)-1n);static MIN=new b(0);static ZERO=new b(0);static z=s.z.union([s.z.instanceof(b),s.z.object({value:s.z.bigint()}).transform(e=>new b(e.value)),s.z.string().transform(e=>new b(BigInt(e))),s.z.number().transform(e=>new b(e)),s.z.bigint().transform(e=>new b(e)),s.z.date().transform(e=>new b(e)),s.z.custom(e=>e instanceof S).transform(e=>new b(e)),of.transform(e=>new b(e))]);static sort(e,r){return Number(e.valueOf()-r.valueOf())}},S=class T extends bt{constructor(e){typeof e=="number"&&(e=Math.trunc(e.valueOf())),se(e)&&(e=e.value),super(BigInt(e.valueOf()))}static fromSeconds(e){return e instanceof T?e:e instanceof bn?e.period:e instanceof E?new T(e):(se(e)&&(e=e.value),["number","bigint"].includes(typeof e)?T.seconds(e):new T(e))}static fromMilliseconds(e){return e instanceof T?e:e instanceof bn?e.period:e instanceof E?new T(e):(se(e)&&(e=e.value),["number","bigint"].includes(typeof e)?T.milliseconds(e):new T(e))}valueOf(){return this.value}lessThan(e){return this.valueOf()<new T(e).valueOf()}greaterThan(e){return this.valueOf()>new T(e).valueOf()}lessThanOrEqual(e){return this.valueOf()<=new T(e).valueOf()}greaterThanOrEqual(e){return this.valueOf()>=new T(e).valueOf()}remainder(e){return ho(this,e)}truncate(e){return new T(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(){const e=this.truncate(T.DAY),r=this.truncate(T.HOUR),n=this.truncate(T.MINUTE),a=this.truncate(T.SECOND),i=this.truncate(T.MILLISECOND),o=this.truncate(T.MICROSECOND),l=this.truncate(T.NANOSECOND),c=e,u=r.sub(e),h=n.sub(r),f=a.sub(n),d=i.sub(a),z=o.sub(i),N=l.sub(o);let I="";return c.isZero||(I+=`${c.days}d `),u.isZero||(I+=`${u.hours}h `),h.isZero||(I+=`${h.minutes}m `),f.isZero||(I+=`${f.seconds}s `),d.isZero||(I+=`${d.milliseconds}ms `),z.isZero||(I+=`${z.microseconds}µs `),N.isZero||(I+=`${N.nanoseconds}ns`),I.trim()}mult(e){return new T(ge(this.valueOf(),e))}div(e){return new T(Wr(this.valueOf(),e))}get days(){return Number(this.valueOf())/Number(T.DAY.valueOf())}get hours(){return Number(this.valueOf())/Number(T.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(T.MINUTE.valueOf())}get seconds(){return Number(this.valueOf())/Number(T.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(T.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(T.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===0n}equals(e){return this.valueOf()===new T(e).valueOf()}add(e){return new T(this.valueOf()+new T(e).valueOf())}sub(e){return new T(this.valueOf()-new T(e).valueOf())}static nanoseconds(e=1){return new T(e)}static NANOSECOND=T.nanoseconds(1);static microseconds(e=1){return T.nanoseconds(ge(e,1e3))}static MICROSECOND=T.microseconds(1);static milliseconds(e=1){return T.microseconds(ge(e,1e3))}static MILLISECOND=T.milliseconds(1);static seconds(e=1){return T.milliseconds(ge(e,1e3))}static SECOND=T.seconds(1);static minutes(e=1){return T.seconds(ge(e,60))}static MINUTE=T.minutes(1);static hours(e){return T.minutes(ge(e,60))}static HOUR=T.hours(1);static days(e){return T.hours(ge(e,24))}static DAY=T.days(1);static MAX=new T((1n<<63n)-1n);static MIN=new T(0);static ZERO=new T(0);static z=s.z.union([s.z.object({value:s.z.bigint()}).transform(e=>new T(e.value)),s.z.string().transform(e=>new T(BigInt(e))),s.z.number().transform(e=>new T(e)),s.z.bigint().transform(e=>new T(e)),s.z.instanceof(T),s.z.instanceof(E).transform(e=>new T(e)),s.z.custom(e=>e instanceof bn).transform(e=>new T(e))])},bn=class te extends bt{constructor(e){se(e)&&(e=e.value),super(e.valueOf())}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new te(e).valueOf()}get period(){return S.seconds(1/this.valueOf())}sampleCount(e){return new S(e).seconds*this.valueOf()}byteCount(e,r){return this.sampleCount(e)*new W(r).valueOf()}span(e){return S.seconds(e/this.valueOf())}byteSpan(e,r){return this.span(e.valueOf()/new W(r).valueOf())}add(e){return new te(tr(this.valueOf(),new te(e).valueOf()))}sub(e){return new te(Ve(this.valueOf(),new te(e).valueOf()))}mult(e){return new te(ge(this.valueOf(),e))}div(e){return new te(Wr(this.valueOf(),e))}static hz(e){return new te(e)}static khz(e){return te.hz(e*1e3)}static z=s.z.union([s.z.number().transform(e=>new te(e)),s.z.instanceof(te)])},W=class K extends bt{constructor(e){se(e)&&(e=e.value),super(e.valueOf())}length(e){return e.valueOf()/this.valueOf()}size(e){return new dt(e*this.valueOf())}add(e){return new K(tr(this.valueOf(),new K(e).valueOf()))}sub(e){return new K(Ve(this.valueOf(),new K(e).valueOf()))}mult(e){return new K(ge(this.valueOf(),e))}div(e){return new K(Wr(this.valueOf(),e))}static UNKNOWN=new K(0);static BIT128=new K(16);static BIT64=new K(8);static BIT32=new K(4);static BIT16=new K(2);static BIT8=new K(1);static z=s.z.union([s.z.number().transform(e=>new K(e)),s.z.instanceof(K)])},P=class le{start;end;constructor(e,r){typeof e=="object"&&"start"in e?(this.start=new E(e.start),this.end=new E(e.end)):(this.start=new E(e),this.end=new E(r))}get span(){return new S(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 le(this.end,this.start)}get numericBounds(){return{lower:Number(this.start.valueOf()),upper:Number(this.end.valueOf())}}equals(e,r=S.ZERO){if(r.isZero)return this.start.equals(e.start)&&this.end.equals(e.end);let n=this.start.sub(e.start).valueOf(),a=this.end.sub(e.end).valueOf();return n<0&&(n=-n),a<0&&(a=-a),n<=r.valueOf()&&a<=r.valueOf()}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.fString("preciseDate")} - ${this.span.toString()}`}overlapsWith(e,r=S.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 a=E.max(n.start,e.start),i=E.min(n.end,e.end);return i.before(a)?!1:new S(i.sub(a)).greaterThanOrEqual(r)}contains(e){return e instanceof le?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const r=new le(this.start,this.end);return e.start.after(this.start)&&(r.start=e.start),e.start.after(this.end)&&(r.end=e.start),e.end.before(this.end)&&(r.end=e.end),e.end.before(this.start)&&(r.start=e.end),r}static max(...e){return new le(E.min(...e.map(r=>r.start)),E.max(...e.map(r=>r.end)))}static MAX=new le(E.MIN,E.MAX);static MIN=new le(E.MAX,E.MIN);static ZERO=new le(E.ZERO,E.ZERO);static z=s.z.union([s.z.object({start:E.z,end:E.z}).transform(e=>new le(e.start,e.end)),s.z.instanceof(le)]);static sort(e,r){return E.sort(e.start,r.start)||E.sort(e.end,r.end)}static simplify(e){return e.map(r=>r.makeValid()).sort((r,n)=>le.sort(r,n)).reduce((r,n)=>{if(n.isZero)return r;if(r.length===0)return r.push(n),r;const a=r[r.length-1];return a.overlapsWith(n)||a.end.equals(n.start)?a.end=E.max(a.end,n.end):r.push(n),r},[])}},C=class g extends bt{constructor(e){if(se(e)&&(e=e.value),e instanceof g||typeof e=="string"||typeof e.valueOf()=="string")super(e.valueOf());else{const r=g.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(r==null)throw new Error(`unable to find data type for ${e.toString()}`);super(r.valueOf())}}get Array(){const e=g.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(r=>this.equals(r))}toString(){return this.valueOf()}get isVariable(){return this.equals(g.JSON)||this.equals(g.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(g.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=g.DENSITIES.get(this.toString());if(e==null)throw new Error(`unable to find density for ${this.valueOf()}`);return e}get isUnsignedInteger(){return this.equals(g.UINT8)||this.equals(g.UINT16)||this.equals(g.UINT32)||this.equals(g.UINT64)}get isSignedInteger(){return this.equals(g.INT8)||this.equals(g.INT16)||this.equals(g.INT32)||this.equals(g.INT64)}canSafelyCastTo(e){return this.equals(e)?!0:!this.isNumeric||!e.isNumeric||this.isVariable||e.isVariable||this.isUnsignedInteger&&e.isSignedInteger?!1:this.isFloat?e.isFloat&&this.density.valueOf()<=e.density.valueOf():this.equals(g.INT32)&&e.equals(g.FLOAT64)||this.equals(g.INT8)&&e.equals(g.FLOAT32)?!0:this.isInteger&&e.isInteger?this.density.valueOf()<=e.density.valueOf()&&this.isUnsignedInteger===e.isUnsignedInteger:!1}canCastTo(e){return this.isNumeric&&e.isNumeric?!0:this.equals(e)}checkArray(e){return e.constructor===this.Array}get usesBigInt(){return g.BIG_INT_TYPES.some(e=>e.equals(this))}static UNKNOWN=new g("unknown");static FLOAT64=new g("float64");static FLOAT32=new g("float32");static INT64=new g("int64");static INT32=new g("int32");static INT16=new g("int16");static INT8=new g("int8");static UINT64=new g("uint64");static UINT32=new g("uint32");static UINT16=new g("uint16");static UINT8=new g("uint8");static BOOLEAN=this.UINT8;static TIMESTAMP=new g("timestamp");static UUID=new g("uuid");static STRING=new g("string");static JSON=new g("json");static 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]]);static 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]]);static DENSITIES=new Map([[g.UINT8.toString(),W.BIT8],[g.UINT16.toString(),W.BIT16],[g.UINT32.toString(),W.BIT32],[g.UINT64.toString(),W.BIT64],[g.FLOAT32.toString(),W.BIT32],[g.FLOAT64.toString(),W.BIT64],[g.INT8.toString(),W.BIT8],[g.INT16.toString(),W.BIT16],[g.INT32.toString(),W.BIT32],[g.INT64.toString(),W.BIT64],[g.TIMESTAMP.toString(),W.BIT64],[g.STRING.toString(),W.UNKNOWN],[g.JSON.toString(),W.UNKNOWN],[g.UUID.toString(),W.BIT128]]);static 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];static BIG_INT_TYPES=[g.INT64,g.UINT64,g.TIMESTAMP];static z=s.z.union([s.z.string().transform(e=>new g(e)),s.z.instanceof(g)])},dt=class A extends bt{constructor(e){se(e)&&(e=e.value),super(e.valueOf())}largerThan(e){return se(e)&&(e=e.value),this.valueOf()>e.valueOf()}smallerThan(e){return se(e)&&(e=e.value),this.valueOf()<e.valueOf()}add(e){return se(e)&&(e=e.value),new A(tr(this.valueOf(),e.valueOf()))}sub(e){return se(e)&&(e=e.value),new A(Ve(this.valueOf(),e.valueOf()))}mult(e){return new A(ge(this.valueOf(),e))}div(e){return new A(Wr(this.valueOf(),e))}truncate(e){return new A(Math.trunc(this.valueOf()/new A(e).valueOf())*new A(e).valueOf())}remainder(e){return A.bytes(this.valueOf()%new A(e).valueOf())}get gigabytes(){return this.valueOf()/A.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/A.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/A.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/A.TERABYTE.valueOf()}toString(){const e=this.truncate(A.TERABYTE),r=this.truncate(A.GIGABYTE),n=this.truncate(A.MEGABYTE),a=this.truncate(A.KILOBYTE),i=this.truncate(A.BYTE),o=e,l=r.sub(e),c=n.sub(r),u=a.sub(n),h=i.sub(a);let f="";return o.isZero||(f+=`${o.terabytes}TB `),l.isZero||(f+=`${l.gigabytes}GB `),c.isZero||(f+=`${c.megabytes}MB `),u.isZero||(f+=`${u.kilobytes}KB `),(!h.isZero||f==="")&&(f+=`${h.valueOf()}B`),f.trim()}static bytes(e=1){return new A(e)}static BYTE=new A(1);static kilobytes(e=1){return A.bytes(new A(e).valueOf()*1e3)}static KILOBYTE=A.kilobytes(1);static megabytes(e=1){return A.kilobytes(new A(e).valueOf()*1e3)}static MEGABYTE=A.megabytes(1);static gigabytes(e=1){return A.megabytes(new A(e).valueOf()*1e3)}static GIGABYTE=A.gigabytes(1);static terabytes(e){return A.gigabytes(new A(e).valueOf()*1e3)}static TERABYTE=A.terabytes(1);static ZERO=new A(0);static z=s.z.union([s.z.number().transform(e=>new A(e)),s.z.instanceof(A)]);get isZero(){return this.valueOf()===0}};s.z.union([s.z.instanceof(Uint8Array),s.z.instanceof(Uint16Array),s.z.instanceof(Uint32Array),s.z.instanceof(BigUint64Array),s.z.instanceof(Float32Array),s.z.instanceof(Float64Array),s.z.instanceof(Int8Array),s.z.instanceof(Int16Array),s.z.instanceof(Int32Array),s.z.instanceof(BigInt64Array)]);const fo=t=>{const e=typeof t;return e==="string"||e==="number"||e==="boolean"||e==="bigint"||t instanceof E||t instanceof S||t instanceof Date},lf=(t,e,r,n=0)=>t.usesBigInt&&!e.usesBigInt?Number(r)-Number(n):!t.usesBigInt&&e.usesBigInt?BigInt(r.valueOf())-BigInt(n.valueOf()):Ar(r,-n),Ar=(t,e)=>e==0?t:t==0?e:typeof t=="bigint"&&typeof e=="bigint"||typeof t=="number"&&typeof e=="number"?t+e:Number(t)+Number(e),cf=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;function uf(t){return typeof t=="string"&&cf.test(t)}const Y=[];for(let t=0;t<256;++t)Y.push((t+256).toString(16).slice(1));function hf(t,e=0){return(Y[t[e+0]]+Y[t[e+1]]+Y[t[e+2]]+Y[t[e+3]]+"-"+Y[t[e+4]]+Y[t[e+5]]+"-"+Y[t[e+6]]+Y[t[e+7]]+"-"+Y[t[e+8]]+Y[t[e+9]]+"-"+Y[t[e+10]]+Y[t[e+11]]+Y[t[e+12]]+Y[t[e+13]]+Y[t[e+14]]+Y[t[e+15]]).toLowerCase()}function df(t,e=0){const r=hf(t,e);if(!uf(r))throw TypeError("Stringified UUID is invalid");return r}typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const po=(t,e)=>df(t,e),xe=-1,Yn={[Symbol.iterator]:()=>Yn,next:()=>({done:!0,value:void 0})},ff=s.z.string().transform(t=>new Uint8Array(atob(t).split("").map(e=>e.charCodeAt(0))).buffer),pf=s.z.union([s.z.null(),s.z.undefined()]).transform(()=>new Uint8Array().buffer),Hn=10,yo=(t,e)=>{if(t==="number"&&!e.isNumeric)throw new Error(`cannot convert series of type ${e.toString()} to number`);if(t==="bigint"&&!e.usesBigInt)throw new Error(`cannot convert series of type ${e.toString()} to bigint`)},go="sy_x_telem_series";let Me=class Ie{key;discriminator=go;dataType;sampleOffset;gl;_data;timeRange=P.ZERO;alignment=0n;alignmentMultiple=1n;cachedMin;cachedMax;writePos=xe;_refCount=0;cachedLength;_cachedIndexes;static crudeZ=s.z.object({timeRange:P.z.optional(),dataType:C.z,alignment:s.z.coerce.bigint().optional(),data:s.z.union([ff,pf,s.z.instanceof(ArrayBuffer),s.z.instanceof(Uint8Array)]),glBufferUsage:af.optional().default("static").optional()});static z=Ie.crudeZ.transform(e=>new Ie(e));constructor(e){yf(e)&&(e={data:e}),e.data??=[];const{dataType:r,timeRange:n,sampleOffset:a=0,glBufferUsage:i="static",alignment:o=0n,alignmentMultiple:l=1n,key:c=Rs(),data:u}=e;if(mo(u)){const d=u;this.key=d.key,this.dataType=d.dataType,this.sampleOffset=d.sampleOffset,this.gl=d.gl,this._data=d._data,this.timeRange=d.timeRange,this.alignment=d.alignment,this.alignmentMultiple=d.alignmentMultiple,this.cachedMin=d.cachedMin,this.cachedMax=d.cachedMax,this.writePos=d.writePos,this._refCount=d._refCount,this.cachedLength=d.cachedLength;return}const h=fo(u),f=Array.isArray(u);if(r!=null)this.dataType=new C(r);else{if(u instanceof ArrayBuffer)throw new Error("cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type.");if(f||h){let d=u;if(!h){if(u.length===0)throw new Error("cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type.");d=u[0]}if(typeof d=="string")this.dataType=C.STRING;else if(typeof d=="number")this.dataType=C.FLOAT64;else if(typeof d=="bigint")this.dataType=C.INT64;else if(typeof d=="boolean")this.dataType=C.BOOLEAN;else if(d instanceof E||d instanceof Date||d instanceof E)this.dataType=C.TIMESTAMP;else if(typeof d=="object")this.dataType=C.JSON;else throw new Error(`cannot infer data type of ${typeof d} when constructing a Series from a JS array`)}else this.dataType=new C(u)}if(!f&&!h)this._data=u;else if(f&&u.length===0)this._data=new this.dataType.Array([]).buffer;else{let d=h?[u]:u;const z=d[0];(z instanceof E||z instanceof Date||z instanceof S)&&(d=d.map(N=>new E(N).valueOf())),this.dataType.equals(C.STRING)?(this.cachedLength=d.length,this._data=new TextEncoder().encode(`${d.join(`
9
- `)}
10
- `).buffer):this.dataType.equals(C.JSON)?(this.cachedLength=d.length,this._data=new TextEncoder().encode(`${d.map(N=>$t.encodeString(N)).join(`
11
- `)}
12
- `).buffer):this.dataType.usesBigInt&&typeof z=="number"?this._data=new this.dataType.Array(d.map(N=>BigInt(Math.round(N)))).buffer:!this.dataType.usesBigInt&&typeof z=="bigint"?this._data=new this.dataType.Array(d.map(Number)).buffer:this._data=new this.dataType.Array(d).buffer}this.key=c,this.alignment=o,this.alignmentMultiple=l,this.sampleOffset=a??0,this.timeRange=n??P.ZERO,this.gl={control:null,buffer:null,prevBuffer:0,bufferUsage:i}}static alloc({capacity:e,dataType:r,...n}){if(e===0)throw new Error("[Series] - cannot allocate an array of length 0");const a=new new C(r).Array(e),i=new Ie({data:a.buffer,dataType:r,...n});return i.writePos=0,i}get refCount(){return this._refCount}acquire(e){this._refCount++,e!=null&&this.updateGLBuffer(e)}release(){this._refCount--,this.refCount===0&&this.gl.control!=null?this.maybeGarbageCollectGLBuffer(this.gl.control):this.refCount<0&&console.warn("cannot release a series with a negative reference count")}write(e){if(!e.dataType.equals(this.dataType))throw new Error("buffer must be of the same type as this array");return this.dataType.isVariable?this.writeVariable(e):this.writeFixed(e)}writeVariable(e){if(this.writePos===xe)return 0;const r=this.byteCapacity.valueOf()-this.writePos,n=e.subBytes(0,r);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===xe)return 0;const r=this.capacity-this.writePos,n=e.sub(0,r);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===xe?this.underlyingData:new this.dataType.Array(this._data,0,this.writePos)}toStrings(){return this.dataType.isVariable?new TextDecoder().decode(this.underlyingData).split(`
13
- `).slice(0,-1):Array.from(this).map(e=>e.toString())}parseJSON(e){if(!this.dataType.equals(C.JSON))throw new Error("cannot parse non-JSON series as JSON");return this.toStrings().map(r=>e.parse($t.decodeString(r)))}get byteCapacity(){return new dt(this.underlyingData.byteLength)}get capacity(){return this.dataType.isVariable?this.byteCapacity.valueOf():this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===xe?this.byteCapacity:this.dataType.isVariable?new dt(this.writePos):this.dataType.density.size(this.writePos)}get length(){return this.cachedLength!=null?this.cachedLength:this.dataType.isVariable?this.calculateCachedLength():this.writePos===xe?this.byteCapacity.valueOf()/this.dataType.density.valueOf():this.writePos}calculateCachedLength(){if(!this.dataType.isVariable)throw new Error("cannot calculate length of a non-variable length data type");let e=0;const r=[0];return this.data.forEach((n,a)=>{n===Hn&&(e++,r.push(a+1))}),this._cachedIndexes=r,this.cachedLength=e,e}convert(e,r=0){if(this.dataType.equals(e))return this;const n=new e.Array(this.length);for(let a=0;a<this.length;a++)n[a]=lf(this.dataType,e,this.data[a],r);return new Ie({data:n.buffer,dataType:e,timeRange:this.timeRange,sampleOffset:r,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment})}calcRawMax(){if(this.length===0)return-1/0;if(this.dataType.equals(C.TIMESTAMP))this.cachedMax=this.data[this.data.length-1];else if(this.dataType.usesBigInt){const e=this.data;this.cachedMax=e.reduce((r,n)=>r>n?r:n)}else{const e=this.data;this.cachedMax=e.reduce((r,n)=>r>n?r:n)}return this.cachedMax}get max(){return this.calcMax()}calcMax(){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.calcRawMax(),Ar(this.cachedMax,this.sampleOffset))}calcRawMin(){if(this.length===0)return 1/0;if(this.dataType.equals(C.TIMESTAMP))this.cachedMin=this.data[0];else if(this.dataType.usesBigInt){const e=this.data;this.cachedMin=e.reduce((r,n)=>r<n?r:n)}else{const e=this.data;this.cachedMin=e.reduce((r,n)=>r<n?r:n)}return this.cachedMin}get min(){return this.calcMin()}calcMin(){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.calcRawMin(),Ar(this.cachedMin,this.sampleOffset))}get bounds(){return H(Number(this.min),Number(this.max),{makeValid:!1})}maybeRecomputeMinMax(e){if(this.cachedMin!=null){const r=e.cachedMin??e.calcRawMin();r<this.cachedMin&&(this.cachedMin=r)}if(this.cachedMax!=null){const r=e.cachedMax??e.calcRawMax();r>this.cachedMax&&(this.cachedMax=r)}}atAlignment(e,r){const n=Number((e-this.alignment)/this.alignmentMultiple);if(n<0||n>=this.length){if(r===!0)throw new Error(`[series] - no value at index ${n}`);return}return this.at(n,r)}at(e,r=!1){if(this.dataType.isVariable)return this.atVariable(e,r??!1);if(this.dataType.equals(C.UUID))return this.atUUID(e,r);e<0&&(e=this.length+e);const n=this.data[e];if(n==null){if(r===!0)throw new Error(`[series] - no value at index ${e}`);return}return Ar(n,this.sampleOffset)}atUUID(e,r){e<0&&(e=this.length+e);const n=po(new Uint8Array(this.buffer,e*this.dataType.density.valueOf()));if(n==null){if(r)throw new Error(`[series] - no value at index ${e}`);return}return n}atVariable(e,r){let n=0,a=0;if(this._cachedIndexes!=null)n=this._cachedIndexes[e],a=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]===Hn){if(e===0){a=o;break}n=o+1,e--}if(a===0&&(a=this.data.length),n>=a||e>0){if(r)throw new Error(`[series] - no value at index ${e}`);return}}const i=this.data.slice(n,a);return this.dataType.equals(C.STRING)?new TextDecoder().decode(i):zs(JSON.parse(new TextDecoder().decode(i)))}binarySearch(e){let r=0,n=this.length-1;const a=_r(e);for(;r<=n;){const i=Math.floor((r+n)/2),o=a(this.at(i,!0),e);if(o===0)return i;o<0?r=i+1:n=i-1}return r}updateGLBuffer(e){if(this.gl.control=e,!this.dataType.equals(C.FLOAT32)&&!this.dataType.equals(C.UINT8))throw new Error("Only FLOAT32 and UINT8 arrays can be used in WebGL");const{buffer:r,bufferUsage:n,prevBuffer:a}=this.gl;if(r==null&&(this.gl.buffer=e.createBuffer()),this.writePos!==a)if(e.bindBuffer(e.ARRAY_BUFFER,this.gl.buffer),this.writePos!==xe){a===0&&e.bufferData(e.ARRAY_BUFFER,this.byteCapacity.valueOf(),e.STATIC_DRAW);const i=this.dataType.density.size(a).valueOf(),o=this.underlyingData.slice(this.gl.prevBuffer,this.writePos);e.bufferSubData(e.ARRAY_BUFFER,i,o.buffer),this.gl.prevBuffer=this.writePos}else e.bufferData(e.ARRAY_BUFFER,this.buffer,n==="static"?e.STATIC_DRAW:e.DYNAMIC_DRAW),this.gl.prevBuffer=xe}as(e){return yo(e,this.dataType),this}get digest(){return{key:this.key,dataType:this.dataType.toString(),sampleOffset:this.sampleOffset,alignment:{lower:Sa(this.alignmentBounds.lower),upper:Sa(this.alignmentBounds.upper),multiple:this.alignmentMultiple},timeRange:this.timeRange.toString(),length:this.length,capacity:this.capacity}}get alignmentBounds(){return H(this.alignment,this.alignment+BigInt(this.length)*this.alignmentMultiple)}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 gf(this);return this.dataType.equals(C.JSON)?new mf(e):e}return this.dataType.equals(C.UUID)?new wf(this):new bf(this)}slice(e,r){return this.sliceSub(!1,e,r)}sub(e,r){return this.sliceSub(!0,e,r)}subIterator(e,r){return new za(this,e,r??this.length)}subAlignmentIterator(e,r){const n=Math.ceil(Number(e-this.alignment)/Number(this.alignmentMultiple)),a=Math.ceil(Number(r-this.alignment)/Number(this.alignmentMultiple));return new za(this,n,a)}subBytes(e,r){if(e>=0&&(r==null||r>=this.byteLength.valueOf()))return this;const n=this.data.subarray(e,r);return new Ie({data:n,dataType:this.dataType,timeRange:this.timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(e)})}sliceSub(e,r,n){if(r<=0&&(n==null||n>=this.length))return this;let a;return e?a=this.data.subarray(r,n):a=this.data.slice(r,n),new Ie({data:a,dataType:this.dataType,timeRange:this.timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(r)})}reAlign(e){return new Ie({data:this.buffer,dataType:this.dataType,timeRange:P.ZERO,sampleOffset:this.sampleOffset,glBufferUsage:"static",alignment:e})}toString(){let e=`Series(${this.dataType.toString()} ${this.length} [`;if(this.length<=10)e+=Array.from(this).map(r=>r.toString());else{for(let r=0;r<5;r++)e+=`${this.at(r)?.toString()}`,e+=",";e+="...,";for(let r=-5;r<0;r++)e+=this.at(r)?.toString(),r<-1&&(e+=",")}return e+="])",e}};const yf=t=>t==null?!1:Array.isArray(t)||t instanceof ArrayBuffer||ArrayBuffer.isView(t)&&!(t instanceof DataView)||t instanceof Me?!0:fo(t),mo=sf(go,Me);let za=class{series;end;index;constructor(t,e,r){this.series=t;const n=H(0,t.length+1);this.end=Ta(n,r),this.index=Ta(n,e)}next(){return this.index>=this.end?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}},gf=class{series;index;decoder;constructor(t){if(!t.dataType.isVariable)throw new Error("cannot create a variable series iterator for a non-variable series");this.series=t,this.index=0,this.decoder=new TextDecoder}next(){const t=this.index,e=this.series.data;for(;this.index<e.length&&e[this.index]!==Hn;)this.index++;const r=this.index;return t===r?{done:!0,value:void 0}:(this.index++,{done:!1,value:this.decoder.decode(this.series.buffer.slice(t,r))})}},mf=class wo{wrapped;static schema=s.z.record(s.z.string(),s.z.unknown());constructor(e){this.wrapped=e}next(){const e=this.wrapped.next();return e.done===!0?{done:!0,value:void 0}:{done:!1,value:$t.decodeString(e.value,wo.schema)}}},wf=class{series;index;data;density;constructor(t){if(!t.dataType.equals(C.UUID))throw new Error("cannot create a UUID series iterator for a non-UUID series");this.series=t,this.index=0,this.data=new Uint8Array(t.buffer),this.density=C.UUID.density.valueOf()}next(){if(this.index>=this.series.length)return{done:!0,value:void 0};const t=po(this.data,this.index*this.density);return this.index++,{done:!1,value:t}}},bf=class{series;index;constructor(t){this.series=t,this.index=0}next(){return this.index>=this.series.length?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}};class vf{series;constructor(e=[]){if(e.length!==0){const r=e[0].dataType;for(let n=1;n<e.length;n++)if(!e[n].dataType.equals(r))throw new Error("[multi-series] - series must have the same data type")}this.series=e}as(e){return yo(e,this.dataType),this}get dataType(){return this.series.length===0?C.UNKNOWN:this.series[0].dataType}get timeRange(){return this.series.length===0?P.ZERO:new P(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?H(0n,0n):H(this.series[0].alignmentBounds.lower,this.series[this.series.length-1].alignmentBounds.upper)}push(e){const r=()=>new Error(`cannot push a ${e.dataType.toString()} series to a ${this.dataType.toString()} multi-series`),n=e.dataType.equals(this.dataType);if(mo(e)){if(this.series.length!==0&&!n)throw r();this.series.push(e)}else{if(this.series.length!==0&&e.series.length!==0&&!n)throw r();this.series.push(...e.series)}}get length(){return this.series.reduce((e,r)=>e+r.length,0)}atAlignment(e,r){for(const n of this.series)if(mr(n.alignmentBounds,e))return n.atAlignment(e,r);if(r)throw new Error(`[series] - no value at alignment ${e}`)}at(e,r=!1){e<0&&(e=this.length+e);for(const n of this.series){if(e<n.length)return n.at(e,r);e-=n.length}if(r)throw new Error(`[series] - no value at index ${e}`)}subIterator(e,r){return new vn(this,e,r??this.length)}subAlignmentIterator(e,r){if(e>=this.alignmentBounds.upper||r<=this.alignmentBounds.lower)return Yn;let n=0;for(let i=0;i<this.series.length;i++){const o=this.series[i];if(e<o.alignment)break;if(e>=o.alignmentBounds.upper)n+=o.length;else if(mr(o.alignmentBounds,e)){n+=Math.ceil(Number(e-o.alignment)/Number(o.alignmentMultiple));break}}let a=0;for(let i=0;i<this.series.length;i++){const o=this.series[i];if(r<o.alignment)break;if(r>=o.alignmentBounds.upper)a+=o.length;else if(mr(o.alignmentBounds,r)){a+=Math.ceil(Number(r-o.alignment)/Number(o.alignmentMultiple));break}}return new vn(this,n,a)}subAlignmentSpanIterator(e,r){if(e>=this.alignmentBounds.upper)return Yn;r=Math.min(r,Number(this.distance(e,this.alignmentBounds.upper)));let n=0;for(let a=0;a<this.series.length;a++){const i=this.series[a];if(e<i.alignment)break;if(e>=i.alignmentBounds.upper)n+=i.length;else if(mr(i.alignmentBounds,e)){n+=Number(e-i.alignment);break}}return new vn(this,n,n+r)}updateGLBuffer(e){this.series.forEach(r=>r.updateGLBuffer(e))}get bounds(){return hd(this.series.map(e=>e.bounds))}get byteLength(){return new dt(this.series.reduce((e,r)=>e+r.byteLength.valueOf(),0))}get data(){const e=new this.dataType.Array(this.length);let r=0;for(const n of this.series)e.set(n.data,r),r+=n.length;return new this.dataType.Array(e.buffer)}traverseAlignment(e,r){const n=this.series.map(a=>a.alignmentBounds);return dd(n,e,r)}acquire(e){this.series.forEach(r=>r.acquire(e))}release(){this.series.forEach(e=>e.release())}distance(e,r){const n=this.series.map(a=>a.alignmentBounds);return fd(n,e,r)}parseJSON(e){if(!this.dataType.equals(C.JSON))throw new Error("cannot parse non-JSON series as JSON");return this.series.flatMap(r=>r.parseJSON(e))}[Symbol.iterator](){return this.series.length===0?{next(){return{done:!0,value:void 0}}}:new Tf(this.series)}toStrings(){return this.series.flatMap(e=>e.toStrings())}}let Tf=class{series;seriesIndex;internal;constructor(t){this.series=t,this.seriesIndex=0,this.internal=t[0][Symbol.iterator]()}next(){const t=this.internal.next();return t.done===!1?t:this.seriesIndex===this.series.length-1?{done:!0,value:void 0}:(this.internal=this.series[++this.seriesIndex][Symbol.iterator](),this.next())}[Symbol.iterator](){return this}},vn=class{series;index;end;constructor(t,e,r){this.series=t,this.end=r,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 Sa=t=>{const e=t>>32n,r=t&0xffffffffn;return{domain:e,sample:r}},Of=(t,e)=>{let r=null;return e===0?t:(...n)=>{r!==null&&(clearTimeout(r),r=null),r=setTimeout(()=>t(...n),e)}},zf=(t,e,r=".")=>{const n=t.split(r);return n.map((a,i)=>{const o=e(a,i,n);return o==null?null:typeof o=="string"?o:o.join(r)}).filter(a=>a!=null).join(r)},Sf=(t,e)=>{if(!Array.isArray(t))return t[e];const r=t[e];if(r!=null||t.length==0)return r;const n=t[0];if(typeof n=="object"&&"key"in n)return t.find(a=>a.key===e)},Ef=(t,e,r={optional:!1,separator:"."})=>{r.separator??=".";const{optional:n,getter:a=Sf}=r,i=e.split(r.separator);if(i.length===1&&i[0]==="")return t;let o=t;for(const l of i){const c=a(o,l);if(c==null){if(n)return null;throw new Error(`Path ${e} does not exist. ${l} is null`)}o=c}return o};s.z.object({key:s.z.string(),value:s.z.string()});let Nf=class{handlers;transform;closer;constructor(t,e){this.transform=t,this.handlers=e??new Map}onChange(t){return this.handlers.set(t,null),()=>this.handlers.delete(t)}notify(t){let e=t;if(this.transform!=null){const[r,n]=this.transform(t);if(!n)return;e=r}this.handlers.forEach((r,n)=>n(e))}setCloser(t){this.closer=t}async close(){return await this.closer?.()}},xf=class{handlers;constructor(t){this.handlers=t??new Map}onChange(t){return this.handlers.set(t,null),()=>this.handlers.delete(t)}notify(t){this.handlers.forEach((e,r)=>r(t))}};const Af=Object.freeze(Object.defineProperty({__proto__:null,BaseObserver:xf,Observer:Nf},Symbol.toStringTag,{value:"Module"})),kf=s.z.record(s.z.union([s.z.number(),s.z.string(),s.z.symbol()]),s.z.unknown()),Ms=t=>Object.entries(t),Cf=(t,e)=>Object.fromEntries(Ms(t).map(([r,n])=>[r,e(n,r)])),If=t=>Object.fromEntries(Ms(t).filter(([e,r])=>r!==void 0)),jf=(t,...e)=>{const r={...t};for(const n of e)delete r[n];return r},ze=Object.freeze(Object.defineProperty({__proto__:null,entries:Ms,map:Cf,omit:jf,purgeUndefined:If,unknownZ:kf},Symbol.toStringTag,{value:"Module"})),Rf=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser";Rf();const Mf=["macOS","Windows","Linux"],Uf=["macos","windows","linux"],Lf={macos:"macOS",windows:"Windows",linux:"Linux"};s.z.enum(Mf).or(s.z.enum(Uf).transform(t=>Lf[t]));const Pf=(...t)=>t.map(bo).join(""),bo=t=>(t.endsWith("/")||(t+="/"),t.startsWith("/")&&(t=t.slice(1)),t),Df=t=>t.endsWith("/")?t.slice(0,-1):t;class Lt{protocol;host;port;path;constructor({host:e,port:r,protocol:n="",pathPrefix:a=""}){this.protocol=n,this.host=e,this.port=r,this.path=bo(a)}replace(e){return new Lt({host:e.host??this.host,port:e.port??this.port,protocol:e.protocol??this.protocol,pathPrefix:e.pathPrefix??this.path})}child(e){return new Lt({...this,pathPrefix:Pf(this.path,e)})}toString(){return Df(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}static UNKNOWN=new Lt({host:"unknown",port:0})}const $f=t=>t.nullable().transform(e=>e===null?void 0:e).optional(),Bf=t=>s.array(t).or(t.transform(e=>[e])),vo=t=>zf(t,(e,r,n)=>{const a=r===n.length-1,i=!isNaN(parseInt(e)),o=!isNaN(parseInt(n[r+1]));return i&&(e="element"),a||o?e:[e,"shape"]}),Ea=(t,e)=>{if(t==null)return null;const r=t[e];return r==null&&typeof t=="object"&&"sourceType"in t?t.sourceType()[e]:r},Zf=(t,e,r)=>e===""?t:Ef(Ea(t,"shape"),vo(e),{...r,getter:Ea}),Pt=Object.freeze(Object.defineProperty({__proto__:null,getFieldSchema:Zf,getFieldSchemaPath:vo,nullToUndefined:$f,toArray:Bf},Symbol.toStringTag,{value:"Module"})),Ff=async t=>await new Promise(e=>setTimeout(e,S.fromMilliseconds(t).milliseconds));class qf{config;retries;interval;constructor(e){this.config={baseInterval:new S(e?.baseInterval??S.seconds(1)),maxRetries:e?.maxRetries??5,scale:e?.scale??1,sleepFn:e?.sleepFn??Ff},this.retries=0,this.interval=new S(this.config.baseInterval)}async wait(){const{maxRetries:e,scale:r,sleepFn:n}=this.config;return this.retries>=e?!1:(await n(this.interval),this.interval=this.interval.mult(r),this.retries++,!0)}get retryMessage(){return`breaker triggered ${this.retries+1}/${this.config.maxRetries} times, retrying in ${this.interval.toString()}`}reset(){this.retries=0,this.interval=this.config.baseInterval}}const Yf=s.z.object({baseInterval:S.z.optional(),maxRetries:s.z.number().optional(),scale:s.z.number().optional()}),To=Object.freeze(Object.defineProperty({__proto__:null,Breaker:qf,breakerConfigZ:Yf},Symbol.toStringTag,{value:"Module"})),Hf=/^#?([0-9a-f]{6}|[0-9a-f]{8})$/i,Oo=s.z.string().regex(Hf),ut=s.z.number().min(0).max(255),zo=s.z.number().min(0).max(1),So=s.z.tuple([ut,ut,ut,zo]),_f=s.z.tuple([ut,ut,ut]),Vf=s.z.object({rgba255:So}),Wf=s.z.number().min(0).max(360),Gf=s.z.number().min(0).max(100),Kf=s.z.number().min(0).max(100),Jf=s.z.tuple([Wf,Gf,Kf,zo]),Us=s.z.union([Oo,_f,So,Jf,Vf]),Xf=Us.transform(t=>Ls(t)),Ls=(t,e=1)=>{if(t=Us.parse(t),typeof t=="string")return Qf(t,e);if(Array.isArray(t)){if(t.length<3||t.length>4)throw new Error(`Invalid color: [${t.join(", ")}]`);return t.length===3?[...t,e]:t}return t.rgba255},Qf=(t,e=1)=>(t=Oo.parse(t),t=ep(t),[br(t,0),br(t,2),br(t,4),t.length===8?br(t,6)/255:e]),br=(t,e)=>parseInt(t.slice(e,e+2),16),ep=t=>t.startsWith("#")?t.slice(1):t;Ls("#000000");Ls("#ffffff");const tp=s.z.object({key:s.z.string(),color:Us,position:s.z.number(),switched:s.z.boolean().optional()});s.z.array(tp);const rp=s.z.object({key:s.z.string(),name:s.z.string(),color:Xf});s.z.object({key:s.z.string(),name:s.z.string(),swatches:s.z.array(rp)});const Eo=s.z.int().min(0).max(255),No=255,xo=0,np={lower:xo,upper:No+1},Ao=s.z.object({name:s.z.string(),key:s.z.string()}),Ft=t=>s.z.object({subject:Ao,resource:t,authority:Eo}),sp=(...t)=>e=>e.filter(r=>{let n=!1;return r.to!=null&&(n=t.includes(r.to.resource)),r.from!=null&&!n&&(n=t.includes(r.from.resource)),n}),ko=t=>s.z.object({from:Ft(t),to:s.z.null()}),Co=t=>s.z.object({from:s.z.null(),to:Ft(t)}),ap=t=>s.z.union([ko(t),Co(t),s.z.object({from:Ft(t),to:Ft(t)})]),ae=Object.freeze(Object.defineProperty({__proto__:null,ABSOLUTE_AUTHORITY:No,AUTHORITY_BOUNDS:np,ZERO_AUTHORITY:xo,acquireZ:Co,authorityZ:Eo,filterTransfersByChannelKey:sp,releaseZ:ko,stateZ:Ft,subjectZ:Ao,transferZ:ap},Symbol.toStringTag,{value:"Module"})),ip=t=>Object.getOwnPropertySymbols(globalThis).includes(t),op=(t,e)=>{const r=Symbol.for(t);if(!ip(r)){const n=e();Object.defineProperty(globalThis,r,{value:n})}return()=>globalThis[r]},Io="sy_x_error",lp=t=>e=>e!=null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"?e.type.startsWith(t):e instanceof Error?e.message.startsWith(t):typeof e!="string"?!1:e.startsWith(t),rr=t=>class Ut extends Error{static discriminator=Io;discriminator=Ut.discriminator;static TYPE=t;type=Ut.TYPE;static matches=lp(t);matches=Ut.matches;constructor(r,n){super(r,n),this.name=Ut.TYPE}static sub(r){return rr(`${t}.${r}`)}},jo=t=>{if(t==null||typeof t!="object")return!1;const e=t;if(e.discriminator!==Io)return!1;if(!("type"in e))throw new Error(`X Error is missing its type property: ${JSON.stringify(e)}`);return!0},st="unknown",_n="nil";class cp{providers=[];register(e){this.providers.push(e)}encode(e){if(e==null)return{type:_n,data:""};if(jo(e))for(const r of this.providers){const n=r.encode(e);if(n!=null)return n}if(e instanceof Error)return{type:st,data:e.message};if(typeof e=="string")return{type:st,data:e};try{return{type:st,data:JSON.stringify(e)}}catch{return{type:st,data:"unable to encode error information"}}}decode(e){if(e==null||e.type===_n)return null;if(e.type===st)return new Vn(e.data);for(const r of this.providers){const n=r.decode(e);if(n!=null)return n}return new Vn(e.data)}}const Ps=op("synnax-error-registry",()=>new cp),up=({encode:t,decode:e})=>Ps().register({encode:t,decode:e}),hp=t=>Ps().encode(t),dp=t=>t==null?null:Ps().decode(t);class Vn extends rr("unknown"){}const fp=s.z.object({type:s.z.string(),data:s.z.string()});class pp extends rr("canceled"){}class yp extends rr("not_implemented"){}const Oe=Object.freeze(Object.defineProperty({__proto__:null,Canceled:pp,NONE:_n,NotImplemented:yp,UNKNOWN:st,Unknown:Vn,createTyped:rr,decode:dp,encode:hp,isTyped:jo,payloadZ:fp,register:up},Symbol.toStringTag,{value:"Module"})),gp=s.object({jsonrpc:s.literal("2.0"),method:s.string(),params:s.any().optional(),id:s.union([s.string(),s.number(),s.null()]).optional()}),Ro=s.object({jsonrpc:s.literal("2.0"),id:s.union([s.string(),s.number(),s.null()])}),mp=Ro.extend({result:s.json()}),wp=Ro.extend({error:s.object({code:s.number().int(),message:s.string().optional(),data:s.json().optional()})}),bp=s.union([mp,wp]);s.union([gp,bp]);const Wn=s.z.string().regex(/^\d+\.\d+\.\d+$/),nr=(t,e,r={})=>{r.checkMajor??=!0,r.checkMinor??=!0,r.checkPatch??=!0;const n=Wn.parse(t),a=Wn.parse(e),[i,o,l]=n.split(".").map(Number),[c,u,h]=a.split(".").map(Number);if(r.checkMajor){if(i<c)return Er;if(i>c)return Nr}if(r.checkMinor){if(o<u)return Er;if(o>u)return Nr}if(r.checkPatch){if(l<h)return Er;if(l>h)return Nr}return vt},vp=(t,e,r={})=>Di(nr(t,e,r)),Mo=(t,e,r={})=>Pi(nr(t,e,r)),Tp=(t,e,r={})=>Li(nr(t,e,r)),Op=({name:t,migrate:e})=>r=>{try{const n=e(r);return console.log(`${t} migrated: ${r.version} -> ${n.version}`),n}catch(n){throw console.log(`${t} failed to migrate from ${r.version}`),console.error(n),n}},zp=({name:t,migrations:e,targetSchema:r,defaultVersion:n,def:a})=>{const i=Object.keys(e).sort(nr).pop();if(i==null)return u=>{if(u.version??=n,u.version!==a.version)return console.log(`${t} version ${u.version} is newer than latest version of ${a.version}.
14
- Returning default instead.
15
- `),a;try{return r!=null?r.parse(u):u}catch(h){return console.log(`${t} failed to parse default. Exiting with default`),console.error(h),a}};const o=Object.keys(e).length;let l=!1;const c=u=>{try{if(o===0||Mo(u.version,i))return console.log(l?`${t} ${u.version} now up to date`:`${t} version ${u.version} is up to date with target version ${a.version}`),u;const h=u.version,f=e[h],d=f(u);return l=!0,c(d)}catch(h){return console.log(`${t} failed to migrate from ${u.version} to ${i}`),console.error(h),a}};return u=>{try{if(u.version==null)if(n!=null)console.log(`${t} version is null. Setting version to default of ${n}`),u.version=n;else return console.log(`${t} version is null and no default version set. Exiting with default`),a;return c(u)}catch(h){return console.log(`${t} failed to parse final result. Exiting with default`),console.error(h),a}}},Na=Object.freeze(Object.defineProperty({__proto__:null,compareSemVer:nr,createMigration:Op,migrator:zp,semVerNewer:Mo,semVerOlder:Tp,semVerZ:Wn,versionsEqual:vp},Symbol.toStringTag,{value:"Module"})),Sp=["standard","scientific","engineering"];s.z.enum(Sp);const Uo=s.z.enum(["success","info","warning","error","loading","disabled"]),Ep=t=>s.z.object({key:s.z.string(),variant:Uo,message:s.z.string(),description:s.z.string().optional(),time:E.z,details:t??s.z.unknown().optional()}),Np=(t,e)=>{if(!(t instanceof Error))throw t;return Lo({variant:"error",message:e??t.message,description:e!=null?t.message:void 0,details:{stack:t.stack??""}})},Lo=t=>({key:Rs(),time:E.now(),...t}),xp=(t,e=[])=>{if(t!=null)return Array.isArray(e)?e.includes(t)?t:void 0:e===t?t:void 0},Ap=(t,e=[])=>{if(t!=null)return Array.isArray(e)?e.includes(t)?void 0:t:e===t?void 0:t},sr=Object.freeze(Object.defineProperty({__proto__:null,create:Lo,fromException:Np,keepVariants:xp,removeVariants:Ap,statusZ:Ep,variantZ:Uo},Symbol.toStringTag,{value:"Module"})),kp=(t,e="")=>{if(typeof t=="string")return t;const r=t.length;return r===0?e:r===1?t[0]:r===2?`${t[0]} and ${t[1]}`:`${t.slice(0,-1).join(", ")}, and ${t[r-1]}`},Cp=t=>{const e=t.split(" "),r=new Set,n=e.map(o=>o.charAt(0).toLowerCase()).join("");r.add(n.replace(/-/g,"_")),r.add(n.replace(/(.)(.)/g,"$1_$2").replace(/-/g,"_"));const a=/\d+/g;t.match(a)&&e.forEach((o,l)=>{if(a.test(o)){const c=e.map((u,h)=>h!==l?u.charAt(0).toLowerCase():u).join("");r.add(c.replace(/-/g,"_")),r.add(c.replace(/(.)(.)/g,"$1_$2").replace(/-/g,"_"))}});const i=e.map(o=>(o.length>3?o.substring(0,3):o).toLowerCase());return r.add(i.join("").replace(/-/g,"_")),r.add(i.join("_").replace(/-/g,"_")),Array.from(r).filter(o=>o.length>=2&&o.length<=12&&!/^\d/.test(o))},Ip=(t,e)=>t.startsWith(e)?t.slice(e.length):t,Gn=Object.freeze(Object.defineProperty({__proto__:null,createShortIdentifiers:Cp,naturalLanguageJoin:kp,trimPrefix:Ip},Symbol.toStringTag,{value:"Module"})),jp="all",Rp="create",Mp="delete",Up="retrieve",Lp="update",Kn=s.z.enum([jp,Rp,Mp,Up,Lp]);let me=class extends Oe.createTyped("sy"){},Z=class extends me.sub("validation"){};class qt extends Z.sub("path"){path;error;static encodedSchema=s.z.object({path:s.z.string().array(),error:Oe.payloadZ});constructor(e,r){const n=O.toArray(e);super(`${n.join(".")}: ${r.message}`),this.path=n.flatMap(a=>a.split(".")),this.error=r}static decode(e){const r=qt.encodedSchema.parse(JSON.parse(e.data));return new qt(r.path,Oe.decode(r.error))}}class Rr extends me.sub("auth"){}class Jn extends Rr.sub("invalid_token"){}class Xn extends Rr.sub("expired_token"){}class J extends me.sub("unexpected"){constructor(e){super(`
16
- Unexpected error encountered:
17
-
18
- ${e}
19
-
20
- Please report this to the Synnax team.
21
- `)}}class Be extends me.sub("query"){}class ft extends Be.sub("not_found"){}class Mr extends Be.sub("multiple_results"){}class xa extends me.sub("route"){path;constructor(e,r){super(e),this.path=r}}class Qn extends me.sub("control"){}class Aa extends Qn.sub("unauthorized"){}class Pp extends me.sub("disconnected"){constructor(e="Operation failed because no cluster is connected."){super(e)}}class WO extends me.sub("contiguity"){}const Dp=t=>t.type.startsWith(me.TYPE)?t.type.startsWith(Z.TYPE)?t.type===qt.TYPE?qt.decode(t):new Z(t.data):t.type.startsWith(Rr.TYPE)?t.type.startsWith(Jn.TYPE)?new Jn(t.data):t.type.startsWith(Xn.TYPE)?new Xn(t.data):new Rr(t.data):t.type.startsWith(J.TYPE)?new J(t.data):t.type.startsWith(Be.TYPE)?t.type.startsWith(ft.TYPE)?new ft(t.data):t.type.startsWith(Mr.TYPE)?new Mr(t.data):new Be(t.data):t.type.startsWith(Qn.TYPE)?t.type.startsWith(Aa.TYPE)?new Aa(t.data):new Qn(t.data):t.type.startsWith(xa.TYPE)?new xa(t.data,t.data):new J(t.data):null,$p=()=>{throw new Oe.NotImplemented};Oe.register({encode:$p,decode:Dp});const Bp=async(t,e)=>{const[r,n]=await e(t);return n==null?[r,n]:n instanceof De?[r,new De({message:`Cannot reach cluster at ${n.url.host}:${n.url.port}`,url:n.url})]:[r,n]};class Ds{key;name;constructor(e,r){this.key=r,this.name=e}get ontologyID(){return Po(this.key)}}const Po=t=>({type:"group",key:t}),ar=s.z.uuid(),Gr=s.z.string(),Kr=s.z.object({key:ar,name:Gr}),Do="builtin",Zp="cluster",Fp="node",Jr=s.z.enum(["label","log","allow_all","builtin","cluster","channel","node","group","range","framer","range-alias","user","workspace","schematic","lineplot","rack","device","task","policy","table","schematic_symbol"]),qp=s.z.string().transform(t=>{const[e,r]=t.split(":");return{type:Jr.parse(e),key:r??""}}),M=s.z.object({type:Jr,key:s.z.string()}).or(qp),Yp={type:Do,key:"root"},Yt=t=>`${t.type}:${t.key}`,Hp=(t,e)=>t.type===e.type&&t.key===e.key,$o=t=>{const e=O.toArray(t);return e.length===0?[]:typeof e[0]=="object"&&"id"in e[0]?e.map(({id:r})=>r):e.map(r=>M.parse(r))},Bo=s.z.object({id:M,name:s.z.string(),data:ze.unknownZ.optional().nullable()}).transform(t=>({key:Yt(t.id),...t})),_p=t=>t==="to"?"from":"to",Vp=s.z.object({from:M,type:s.z.string(),to:M}).or(s.z.string().transform(t=>{const[e,r,n]=t.split("->");return{from:M.parse(e),type:r,to:M.parse(n)}})),Wp=t=>`${Yt(t.from)}->${t.type}->${Yt(t.to)}`,Gp="parent",Kp=(t,e)=>!(e.type!=null&&e.type!==t.type||e.from?.type!=null&&e.from.type!==t.from.type||e.to?.type!=null&&e.to.type!==t.to.type||e.from?.key!=null&&e.from.key!==t.from.key||e.to?.key!=null&&e.to.key!==t.to.key),Jp=s.z.object({group:Kr}),Xp=s.z.object({parent:M,key:ar.optional(),name:Gr}),Qp=s.z.object({key:ar,name:Gr}),ey=s.z.object({keys:s.z.array(ar)});let ty=class kr{static CREATE_ENDPOINT="/ontology/create-group";static RENAME_ENDPOINT="/ontology/rename-group";static DELETE_ENDPOINT="/ontology/delete-group";client;constructor(e){this.client=e}async create(e,r,n){return(await m(this.client,kr.CREATE_ENDPOINT,{parent:e,name:r,key:n},Xp,Jp)).group}async rename(e,r){await m(this.client,kr.RENAME_ENDPOINT,{key:e,name:r},Qp,s.z.object({}))}async delete(e){await m(this.client,kr.DELETE_ENDPOINT,{keys:e},ey,s.z.object({}))}};const ry="sy_group_set",ny="sy_group_delete";let Zo=class{creator;constructor(t){this.creator=new ty(t)}async create(t,e,r){return this.sugar(await this.creator.create(t,e,r))}async rename(t,e){return await this.creator.rename(t,e)}async delete(...t){return await this.creator.delete(t)}sugar(t){return new Ds(t.name,t.key)}};const sy=Object.freeze(Object.defineProperty({__proto__:null,Client:Zo,DELETE_CHANNEL_NAME:ny,Group:Ds,SET_CHANNEL_NAME:ry,groupZ:Kr,keyZ:ar,nameZ:Gr,ontologyID:Po},Symbol.toStringTag,{value:"Module"})),ay="/ontology/add-children",iy="/ontology/remove-children",oy="/ontology/move-children",ka=s.z.object({id:M,children:M.array()}),ly=s.z.object({from:M,to:M,children:M.array()}),Tn=s.z.object({});let cy=class{client;constructor(t){this.client=t}async addChildren(t,...e){await m(this.client,ay,{id:t,children:e},ka,Tn)}async removeChildren(t,...e){await m(this.client,iy,{id:t,children:e},ka,Tn)}async moveChildren(t,e,...r){await m(this.client,oy,{from:t,to:e,children:r},ly,Tn)}};const uy="/ontology/retrieve",hy=s.z.object({ids:M.array().optional(),children:s.z.boolean().optional(),parents:s.z.boolean().optional(),excludeFieldData:s.z.boolean().optional(),searchTerm:s.z.string().optional(),limit:s.z.number().optional(),offset:s.z.number().optional(),types:Jr.array().optional()}),dy=s.z.object({resources:Bo.array()});let Fo=class{type="ontology";groups;client;writer;framer;constructor(t,e){this.client=t,this.writer=new cy(t),this.groups=new Zo(t),this.framer=e}async retrieve(t,e){if(!Array.isArray(t)&&typeof t=="object"&&!("key"in t))return this.execRetrieve(t);const r=$o(t),n=await this.execRetrieve({ids:r,...e});if(Array.isArray(t))return n;if(n.length===0)throw new Be(`No resource found with ID ${Gn.naturalLanguageJoin(r.map(a=>Yt(a)))}`);return n[0]}async retrieveChildren(t,e){return await this.execRetrieve({ids:O.toArray(t),children:!0,...e})}async retrieveParents(t,e){return await this.execRetrieve({ids:O.toArray(t),parents:!0,...e})}async addChildren(t,...e){return await this.writer.addChildren(t,...e)}async removeChildren(t,...e){return await this.writer.removeChildren(t,...e)}async moveChildren(t,e,...r){return await this.writer.moveChildren(t,e,...r)}async execRetrieve(t){const{resources:e}=await m(this.client,uy,t,hy,dy);return e}};const fy="sy_ontology_resource_set",py="sy_ontology_resource_delete",yy="sy_ontology_relationship_set",gy="sy_ontology_relationship_delete",my=Object.freeze(Object.defineProperty({__proto__:null,BUILTIN_TYPE:Do,CLUSTER_TYPE:Zp,Client:Fo,NODE_TYPE:Fp,PARENT_OF_RELATIONSHIP_TYPE:Gp,RELATIONSHIP_DELETE_CHANNEL_NAME:gy,RELATIONSHIP_SET_CHANNEL_NAME:yy,RESOURCE_DELETE_CHANNEL_NAME:py,RESOURCE_SET_CHANNEL_NAME:fy,ROOT_ID:Yp,idToString:Yt,idZ:M,idsEqual:Hp,matchRelationship:Kp,oppositeRelationshipDirection:_p,parseIDs:$o,relationshipToString:Wp,relationshipZ:Vp,resourceTypeZ:Jr,resourceZ:Bo},Symbol.toStringTag,{value:"Module"})),F=t=>s.z.union([s.z.union([s.z.null(),s.z.undefined()]).transform(()=>[]),t.array()]),ir=s.z.uuid(),$s=s.z.object({key:ir,subjects:F(M),objects:F(M),actions:F(Kn)}),wy=s.z.object({key:ir.optional(),subjects:M.array().or(M),objects:M.array().or(M),actions:Kn.array().or(Kn)}),by=s.z.object({keys:ir.array().optional(),subjects:M.array().optional()}),vy=s.z.object({key:ir}).transform(({key:t})=>({keys:[t]})),Ty=s.z.union([s.z.object({for:M}).transform(({for:t})=>({subjects:[t]})),s.z.object({for:M.array()}).transform(({for:t})=>({subjects:t})),by]),Oy=s.z.union([vy,Ty]),zy=s.z.object({policies:F($s)}),Sy=s.z.object({policies:$s.partial({key:!0}).array()}),Ey=s.z.object({policies:$s.array()}),Ny=s.z.object({keys:ir.array()}),xy=s.z.object({}),Ay="/access/policy/retrieve",ky="/access/policy/create",Cy="/access/policy/delete";let Iy=class{client;constructor(t){this.client=t}async create(t){const e=Array.isArray(t),r=wy.array().parse(O.toArray(t)).map(a=>({objects:O.toArray(a.objects),actions:O.toArray(a.actions),subjects:O.toArray(a.subjects)})),n=await m(this.client,ky,{policies:r},Sy,Ey);return e?n.policies:n.policies[0]}async retrieve(t){const e="key"in t,r=await m(this.client,Ay,t,Oy,zy);return e?r.policies[0]:r.policies}async delete(t){await m(this.client,Cy,{keys:O.toArray(t)},Ny,xy)}},jy=class{policy;constructor(t){this.policy=new Iy(t)}};const Ca="Channel key must be a valid uint32.",L=s.z.uint32().or(s.z.string().refine(t=>!isNaN(Number(t)),{message:Ca}).transform(Number).refine(t=>t<2**32-1,{message:Ca})),Te=s.z.string(),qo=sr.statusZ(),Tt=s.z.object({name:Te,key:L,dataType:C.z,leaseholder:s.z.number(),index:L,isIndex:s.z.boolean(),internal:s.z.boolean(),virtual:s.z.boolean(),alias:s.z.string().optional(),expression:s.z.string().default(""),requires:F(L),status:qo.optional()}),Yo=Tt.extend({key:L.optional(),leaseholder:s.z.number().optional(),index:L.optional(),isIndex:s.z.boolean().optional(),internal:s.z.boolean().optional().default(!1),virtual:s.z.boolean().optional().default(!1),expression:s.z.string().optional().default(""),requires:F(L).optional().default([])}),Je=s.z.union([Pt.toArray(L),Pt.toArray(Te),Pt.toArray(Tt).transform(t=>t.map(e=>e.key))]),Ry=new Error("request for lock canceled");var My=function(t,e,r,n){function a(i){return i instanceof r?i:new r(function(o){o(i)})}return new(r||(r=Promise))(function(i,o){function l(h){try{u(n.next(h))}catch(f){o(f)}}function c(h){try{u(n.throw(h))}catch(f){o(f)}}function u(h){h.done?i(h.value):a(h.value).then(l,c)}u((n=n.apply(t,e||[])).next())})};class Uy{constructor(e,r=Ry){this._value=e,this._cancelError=r,this._queue=[],this._weightedWaiters=[]}acquire(e=1,r=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return new Promise((n,a)=>{const i={resolve:n,reject:a,weight:e,priority:r},o=Ho(this._queue,l=>r<=l.priority);o===-1&&e<=this._value?this._dispatchItem(i):this._queue.splice(o+1,0,i)})}runExclusive(e){return My(this,arguments,void 0,function*(r,n=1,a=0){const[i,o]=yield this.acquire(n,a);try{return yield r(i)}finally{o()}})}waitForUnlock(e=1,r=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return this._couldLockImmediately(e,r)?Promise.resolve():new Promise(n=>{this._weightedWaiters[e-1]||(this._weightedWaiters[e-1]=[]),Ly(this._weightedWaiters[e-1],{resolve:n,priority:r})})}isLocked(){return this._value<=0}getValue(){return this._value}setValue(e){this._value=e,this._dispatchQueue()}release(e=1){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);this._value+=e,this._dispatchQueue()}cancel(){this._queue.forEach(e=>e.reject(this._cancelError)),this._queue=[]}_dispatchQueue(){for(this._drainUnlockWaiters();this._queue.length>0&&this._queue[0].weight<=this._value;)this._dispatchItem(this._queue.shift()),this._drainUnlockWaiters()}_dispatchItem(e){const r=this._value;this._value-=e.weight,e.resolve([r,this._newReleaser(e.weight)])}_newReleaser(e){let r=!1;return()=>{r||(r=!0,this.release(e))}}_drainUnlockWaiters(){if(this._queue.length===0)for(let e=this._value;e>0;e--){const r=this._weightedWaiters[e-1];r&&(r.forEach(n=>n.resolve()),this._weightedWaiters[e-1]=[])}else{const e=this._queue[0].priority;for(let r=this._value;r>0;r--){const n=this._weightedWaiters[r-1];if(!n)continue;const a=n.findIndex(i=>i.priority<=e);(a===-1?n:n.splice(0,a)).forEach(i=>i.resolve())}}}_couldLockImmediately(e,r){return(this._queue.length===0||this._queue[0].priority<r)&&e<=this._value}}function Ly(t,e){const r=Ho(t,n=>e.priority<=n.priority);t.splice(r+1,0,e)}function Ho(t,e){for(let r=t.length-1;r>=0;r--)if(e(t[r]))return r;return-1}var Py=function(t,e,r,n){function a(i){return i instanceof r?i:new r(function(o){o(i)})}return new(r||(r=Promise))(function(i,o){function l(h){try{u(n.next(h))}catch(f){o(f)}}function c(h){try{u(n.throw(h))}catch(f){o(f)}}function u(h){h.done?i(h.value):a(h.value).then(l,c)}u((n=n.apply(t,e||[])).next())})};class Dy{constructor(e){this._semaphore=new Uy(1,e)}acquire(){return Py(this,arguments,void 0,function*(e=0){const[,r]=yield this._semaphore.acquire(1,e);return r})}runExclusive(e,r=0){return this._semaphore.runExclusive(()=>e(),1,r)}isLocked(){return this._semaphore.isLocked()}waitForUnlock(e=0){return this._semaphore.waitForUnlock(1,e)}release(){this._semaphore.isLocked()&&this._semaphore.release()}cancel(){return this._semaphore.cancel()}}const $y=(t,e,{convertNumericStrings:r=!0}={})=>{const n=!Array.isArray(t);let a=O.toArray(t);const i=a[0],o=typeof i;let l;return o==="string"&&r&&!isNaN(parseInt(i))&&"number"in e?(l=e.number,a=a.map(c=>parseInt(c))):l=e[o],{single:n,variant:l,normalized:a,actual:t}},Xe=(t,e,r,n)=>{if(n){if(r.length===0)throw new ft(`${t} not found matching ${JSON.stringify(e)}`);if(r.length>1)throw new Mr(`Expected one ${t} matching ${JSON.stringify(e)}, but found ${r.length}`)}},By=s.z.object({leaseholder:s.z.number().optional(),keys:L.array().optional(),names:s.z.string().array().optional(),searchTerm:s.z.string().optional(),rangeKey:s.z.string().optional(),limit:s.z.number().optional(),offset:s.z.number().optional(),dataTypes:C.z.array().optional(),notDataTypes:C.z.array().optional(),virtual:s.z.boolean().optional(),isIndex:s.z.boolean().optional(),internal:s.z.boolean().optional(),calculated:s.z.boolean().optional()}),Zy=s.z.object({channels:F(Tt)}),ce=t=>(Array.isArray(t)&&t.length>0&&typeof t[0]=="object"?t=t.map(e=>e.key):typeof t=="object"&&"key"in t&&(t=[t.key]),$y(t,{number:"keys",string:"names"}));class or{static ENDPOINT="/channel/retrieve";client;constructor(e){this.client=e}async retrieve(e,r){if(!Array.isArray(e)&&typeof e=="object")return await this.execute(e);const n=ce(e),{variant:a}=n;let{normalized:i}=n;return a==="keys"&&i.indexOf(0)!==-1&&(i=i.filter(o=>o!==0)),i.length===0?[]:await this.execute({[a]:i,...r})}async execute(e){const[r,n]=await this.client.send(or.ENDPOINT,e,By,Zy);if(n!=null)throw n;return r.channels}}class Bs{cache;namesToKeys;wrapped;constructor(e){this.cache=new Map,this.namesToKeys=new Map,this.wrapped=e}async retrieve(e,r){if(!Array.isArray(e)&&typeof e=="object")return await this.wrapped.retrieve(e);const{normalized:n}=ce(e),a=[],i=[];if(n.forEach(l=>{const c=this.get(l);c!=null?a.push(...c):i.push(l)}),i.length===0)return a;const o=await this.wrapped.retrieve(i,r);return this.set(o),a.concat(o)}delete(e){const{variant:r,normalized:n}=ce(e);r==="names"?n.forEach(a=>{const i=this.namesToKeys.get(a);i!=null&&(i.forEach(o=>this.cache.delete(o)),this.namesToKeys.delete(a))}):n.forEach(a=>{const i=this.cache.get(a);i!=null&&(this.cache.delete(a),this.namesToKeys.delete(i.name))})}rename(e,r){e.forEach((n,a)=>{const i=r[a],o=this.cache.get(n);if(o==null)return;this.cache.delete(n);const l=this.namesToKeys.get(o.name);l!=null&&(l.delete(n),l.size===0&&this.namesToKeys.delete(o.name)),o.name=i,this.cache.set(n,o);const c=this.namesToKeys.get(i);c==null?this.namesToKeys.set(i,new Set([n])):c.add(n)})}set(e){e.forEach(r=>{this.cache.set(r.key,r);const n=this.namesToKeys.get(r.name);n==null?this.namesToKeys.set(r.name,new Set([r.key])):n.add(r.key)})}get(e){if(typeof e=="number"){const a=this.cache.get(e);return a==null?void 0:[a]}const r=this.namesToKeys.get(e);if(r==null)return;const n=[];if(r.forEach(a=>{const i=this.cache.get(a);i!=null&&n.push(i)}),n.length!==0)return n}}class _o{mu=new Dy;requests=new Map;wrapped;debouncedRun;constructor(e,r){this.wrapped=e,this.debouncedRun=Of(()=>{this.run()},r)}async retrieve(e){if(!Array.isArray(e)&&typeof e=="object")return await this.wrapped.retrieve(e);const{normalized:r,variant:n}=ce(e);return n==="names"?await this.wrapped.retrieve(r):await new Promise((a,i)=>{this.mu.runExclusive(()=>{this.requests.set(r,{resolve:a,reject:i}),this.debouncedRun()})})}async run(){await this.mu.runExclusive(async()=>{const e=new Set;this.requests.forEach((r,n)=>n.forEach(a=>e.add(a)));try{const r=await this.wrapped.retrieve(Array.from(e));this.requests.forEach((n,a)=>n.resolve(r.filter(i=>a.includes(i.key))))}catch(r){this.requests.forEach(n=>n.reject(r))}finally{this.requests.clear()}})}}const Vo=async(t,e)=>{const{normalized:r}=ce(e),n=await t.retrieve(r),a=[];if(r.forEach(i=>{n.find(o=>o.name===i||o.key===i)==null&&a.push(i)}),a.length>0)throw new Be(`Could not find channels: ${JSON.stringify(a)}`);return n},Fy="sy_channel_set",qy="sy_channel_delete";class es{_frameClient;key;name;dataType;leaseholder;index;isIndex;internal;alias;virtual;expression;requires;status;constructor({dataType:e,name:r,leaseholder:n=0,key:a=0,isIndex:i=!1,index:o=0,internal:l=!1,virtual:c=!1,frameClient:u,alias:h,status:f,expression:d="",requires:z=[]}){this.key=L.parse(a),this.name=r,this.dataType=new C(e),this.leaseholder=n,this.index=L.parse(o),this.isIndex=i,this.internal=l,this.alias=h,this.virtual=c,this.expression=d,this.requires=L.array().parse(z??[]),f!=null&&(this.status=sr.create(f)),this._frameClient=u??null}get framer(){if(this._frameClient==null)throw new Z("cannot read from a channel that has not been created");return this._frameClient}get payload(){return Tt.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,status:this.status})}get isCalculated(){return Ur(this.payload)}get ontologyID(){return Ko(this.key)}async read(e){return await this.framer.read(e,this.key)}async write(e,r){return await this.framer.write(e,this.key,r)}}const Yy="sy_calculation_status",Hy="/channel/retrieve-group",_y=s.z.object({}),Vy=s.z.object({group:Kr});let Wo=class{type="channel";frameClient;client;retriever;writer;constructor(t,e,r,n){this.frameClient=t,this.retriever=e,this.client=r,this.writer=n}async create(t,e={}){const{retrieveIfNameExists:r=!1}=e,n=!Array.isArray(t);let a=O.toArray(t),i=[];if(r){const o=await this.retriever.retrieve(a.map(c=>c.name)),l=new Set(o.map(c=>c.name));a=a.filter(c=>!l.has(c.name)),i=this.sugar(o)}return i=i.concat(this.sugar(await this.writer.create(a))),n?i[0]:i}async retrieve(t,e){if(typeof t=="object"&&!Array.isArray(t))return this.sugar(await this.retriever.retrieve(t));const r=!Array.isArray(t),n=this.sugar(await this.retriever.retrieve(t,e));return Xe("channel",t,n,r),r?n[0]:n}async delete(t){const{normalized:e,variant:r}=ce(t);return r==="keys"?await this.writer.delete({keys:e}):await this.writer.delete({names:e})}async rename(t,e){return await this.writer.rename(O.toArray(t),O.toArray(e))}createDebouncedBatchRetriever(t=10){return new Bs(new _o(new or(this.client),t))}sugar(t){const{frameClient:e}=this;return Array.isArray(t)?t.map(r=>new es({...r,frameClient:e})):new es({...t,frameClient:e})}async retrieveGroup(){const t=await m(this.client,Hy,{},_y,Vy);return new Ds(t.group.name,t.group.key)}};const Ur=({virtual:t,expression:e})=>t&&e!=="",Go=async(t,e)=>{if(!Ur(e))return e.index;for(const r of e.requires){const n=await t(r);if(n==null)return null;if(!n.virtual)return n.index}for(const r of e.requires){const n=await t(r);if(n==null)return null;if(Ur(n)){const a=await Go(t,n);if(a!=null)return a}}return null},Ko=t=>({type:"channel",key:t.toString()}),Wy=s.z.object({channels:Yo.array()}),Gy=s.z.object({channels:Tt.array()}),Ky=s.z.object({keys:L.array().optional(),names:Te.array().optional()}),Jy=s.z.object({}),Xy=s.z.object({keys:L.array(),names:Te.array()}),Qy=s.z.object({}),eg="/channel/create",tg="/channel/delete",rg="/channel/rename";let Jo=class{client;cache;constructor(t,e){this.client=t,this.cache=e}async create(t){const{channels:e}=await m(this.client,eg,{channels:t.map(r=>({...r,dataType:r.dataType}))},Wy,Gy);return this.cache.set(e),e}async delete(t){const e=L.array().parse(t.keys??[]);await m(this.client,tg,t,Ky,Jy),e.length>0&&this.cache.delete(e),t.names!=null&&this.cache.delete(t.names)}async rename(t,e){await m(this.client,rg,{keys:t,names:e},Xy,Qy),this.cache.rename(t,e)}};const ng=Object.freeze(Object.defineProperty({__proto__:null,CALCULATION_STATUS_CHANNEL_NAME:Yy,CacheRetriever:Bs,Channel:es,Client:Wo,ClusterRetriever:or,DELETE_CHANNEL_NAME:qy,DebouncedBatchRetriever:_o,SET_CHANNEL_NAME:Fy,Writer:Jo,analyzeParams:ce,isCalculated:Ur,keyZ:L,nameZ:Te,newZ:Yo,ontologyID:Ko,paramsZ:Je,payloadZ:Tt,resolveCalculatedIndex:Go,retrieveRequired:Vo,statusZ:qo},Symbol.toStringTag,{value:"Module"})),Qe=s.z.uuid(),Xr=s.z.object({key:Qe,username:s.z.string().min(1),firstName:s.z.string().default(""),lastName:s.z.string().default(""),rootUser:s.z.boolean().default(!0)}),sg=Xr.partial({key:!0,firstName:!0,lastName:!0}).omit({rootUser:!0}).extend({password:s.z.string().min(1)}),ag=s.z.object({keys:Qe.array().optional(),usernames:s.z.string().array().optional()}),ig=s.z.object({key:Qe}).transform(({key:t})=>({keys:[t]})),og=s.z.object({username:s.z.string()}).transform(({username:t})=>({usernames:[t]})),lg=s.z.object({usernames:s.z.string().array()}).transform(({usernames:t})=>({usernames:t})),cg=s.z.union([ig,og,lg,ag]),ug=s.z.object({users:F(Xr)}),hg=s.z.object({users:sg.array()}),dg=s.z.object({users:Xr.array()}),fg=s.z.object({key:Qe,username:s.z.string().min(1)}),pg=s.z.object({}),yg=s.z.object({key:Qe,firstName:s.z.string().optional(),lastName:s.z.string().optional()}),gg=s.z.object({}),mg=s.z.object({keys:Qe.array()}),wg=s.z.object({}),bg="/user/retrieve",vg="/user/create",Tg="/user/change-username",Og="/user/rename",zg="/user/delete";let Sg=class{client;constructor(t){this.client=t}async create(t){const e=Array.isArray(t),r=await m(this.client,vg,{users:O.toArray(t)},hg,dg);return e?r.users:r.users[0]}async changeUsername(t,e){await m(this.client,Tg,{key:t,username:e},fg,pg)}async retrieve(t){const e="key"in t||"username"in t,r=await m(this.client,bg,t,cg,ug);if(!e)return r.users;if(r.users.length===0){const n="key"in t?`key ${t.key}`:`username ${t.username}`;throw new ft(`No user with ${n} found`)}if(r.users.length>1){const n="key"in t?`key ${t.key}`:`username ${t.username}`;throw new Mr(`Multiple users found with ${n}`)}return r.users[0]}async rename(t,e,r){await m(this.client,Og,{key:t,firstName:e,lastName:r},yg,gg)}async delete(t){await m(this.client,zg,{keys:O.toArray(t)},mg,wg)}};const Eg=s.z.object({username:s.z.string(),password:s.z.string()}),Ng=s.z.object({token:s.z.string(),user:Xr}),Ia="/auth/login",xg=3,Ag="/auth/change-password",kg=s.z.object({username:s.z.string(),password:s.z.string(),newPassword:s.z.string().min(1)}),Cg=s.z.object({}),Ig=[Jn,Xn];let jg=class{token;client;credentials;authenticating;authenticated;user;retryCount;constructor(t,e){this.client=t,this.authenticated=!1,this.credentials=e,this.retryCount=0}async changePassword(t){if(!this.authenticated)throw new Error("Not authenticated");await m(this.client,Ag,{username:this.credentials.username,password:this.credentials.password,newPassword:t},kg,Cg),this.credentials.password=t}middleware(){const t=async(e,r)=>{if(!this.authenticated&&!e.target.endsWith(Ia)){this.authenticating??=new Promise((o,l)=>{this.client.send(Ia,this.credentials,Eg,Ng).then(([c,u])=>{if(u!=null)return o(u);this.token=c?.token,this.user=c?.user,this.authenticated=!0,o(null)}).catch(l)});const i=await this.authenticating;if(i!=null)return[e,i]}e.params.Authorization=`Bearer ${this.token}`;const[n,a]=await r(e);return Ig.some(i=>i.matches(a))&&this.retryCount<xg?(this.authenticated=!1,this.authenticating=void 0,this.retryCount+=1,t(e,r)):(this.retryCount=0,[n,a])};return t}};const Rg=s.z.enum(["disconnected","connecting","connected","failed"]),Mg=s.z.object({status:Rg,error:s.z.instanceof(Error).optional(),message:s.z.string().optional(),clusterKey:s.z.string(),clientVersion:s.z.string(),clientServerCompatible:s.z.boolean(),nodeVersion:s.z.string().optional()}),Ug=s.z.object({clusterKey:s.z.string(),nodeVersion:s.z.string().optional()}),ja={clusterKey:"",status:"disconnected",error:void 0,message:"Disconnected",clientServerCompatible:!1,clientVersion:"0.45.0"},Ra=(t,e,r)=>{const n=r?"cluster":"client";return`Synnax cluster node version ${t!=null?`${t} `:""}is too ${r?"old":"new"} for client version ${e}.
22
- This may cause compatibility issues. We recommend updating the ${n}. For more information, see
23
- https://docs.synnaxlabs.com/reference/typescript-client/troubleshooting#old-${n}-version`};class Lr{static ENDPOINT="/connectivity/check";static DEFAULT=ja;_state;pollFrequency=S.seconds(30);client;name;interval;clientVersion;onChangeHandlers=[];static connectionStateZ=Mg;versionWarned=!1;constructor(e,r=S.seconds(30),n,a){this._state={...ja},this.client=e,this.pollFrequency=r,this.clientVersion=n,this.name=a,this.check(),this.startChecking()}stopChecking(){this.interval!=null&&clearInterval(this.interval)}async check(){const e=this._state.status;try{const[r,n]=await this.client.send(Lr.ENDPOINT,{},s.z.object({}),Ug);if(n!=null)throw n;const a=r.nodeVersion,i=this.clientVersion,o=this.versionWarned;a==null?(this._state.clientServerCompatible=!1,o||(console.warn(Ra(null,i,!0)),this.versionWarned=!0)):Na.versionsEqual(i,a,{checkMajor:!0,checkMinor:!0,checkPatch:!1})?this._state.clientServerCompatible=!0:(this._state.clientServerCompatible=!1,o||(console.warn(Ra(a,i,Na.semVerNewer(i,a))),this.versionWarned=!0)),this._state.status="connected",this._state.message=`Connected to ${this.name??"cluster"}`,this._state.clusterKey=r.clusterKey,this._state.nodeVersion=r.nodeVersion,this._state.clientVersion=this.clientVersion}catch(r){this._state.status="failed",this._state.error=r,this._state.message=this.state.error?.message}return this.onChangeHandlers.length>0&&e!==this._state.status&&this.onChangeHandlers.forEach(r=>r(this.state)),this.state}get state(){return{...this._state}}onChange(e){this.onChangeHandlers.push(e)}startChecking(){this.interval=setInterval(()=>{this.check()},this.pollFrequency.milliseconds)}}const Lg=s.z.object({keys:L.array().optional(),bounds:P.z,names:Te.array().optional()}),Pg=s.z.object({}),Dg="/frame/delete";class $g{client;constructor(e){this.client=e}async delete(e){await m(this.client,Dg,e,Lg,Pg)}}const Ma=t=>{const e=O.toArray(t);return e.length===0?null:typeof e[0]=="number"||!isNaN(parseInt(e[0]))?"key":"name"},Ua=(t,e)=>{const r=O.toArray(t);if(r.length===e.length)return;const n=Ma(t);throw Ma===null?new Z("[Frame] - channel keys or names must be provided when constructing a frame."):new Z(`[Frame] - ${n}s and series must be the same length.
24
- Got ${r.length} ${n}s and ${e.length} series.`)};let Q=class at{columns=[];series=[];constructor(e=[],r=[]){if(e instanceof at){this.columns=e.columns,this.series=e.series;return}if(e instanceof Map){e.forEach((n,a)=>this.push(a,...O.toArray(n)));return}if(typeof e=="object"&&!Array.isArray(e)){if("keys"in e&&"series"in e){const n=e;n.series??=[],n.keys??=[];const a=n.series.map(i=>Xo(i));Ua(n.keys,a),n.keys.forEach((i,o)=>this.push(i,a[o]))}else Object.entries(e).forEach(([n,a])=>{const i=parseInt(n);if(!isNaN(i))return this.push(i,...O.toArray(a));this.push(n,...O.toArray(a))});return}if(Array.isArray(e)||["string","number"].includes(typeof e)){const n=O.toArray(r),a=O.toArray(e);Ua(a,n),n.forEach((i,o)=>this.push(a[o],i));return}throw new Z(`[Frame] - invalid frame construction parameters. data parameter ust be a frame
25
- payload, a list of lazy series, a lazy array, a map, or a record keyed by channel
26
- 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 J("colType is not key");return this.columns??[]}get uniqueKeys(){return wa.unique(this.keys)}get names(){if(this.colType==="key")throw new J("colType is not name");return this.columns??[]}get uniqueNames(){return wa.unique(this.names)}get uniqueColumns(){return this.colType==="key"?this.uniqueKeys:this.uniqueNames}toPayload(){return{series:this.series.map(e=>Qo(e)),keys:[...this.keys]}}get isVertical(){return this.uniqueColumns.length===this.columns.length}get isHorizontal(){return this.uniqueColumns.length===1}get isSquare(){return this.isHorizontal&&this.isVertical}get isWeaklyAligned(){if(this.columns.length<=1)return!0;const e=this.timeRanges;return e.every(r=>r.equals(e[0]))}timeRange(e){if(e==null){if(this.columns.length===0)return P.ZERO;const n=E.min(...this.series.map(i=>i.timeRange.start)),a=E.max(...this.series.map(i=>i.timeRange.end));return new P(n,a)}const r=this.get(e);return r==null?P.ZERO:r.timeRange}latest(){return this.at(-1)}get timeRanges(){return this.uniqueColumns.map(e=>this.timeRange(e))}get(e){return Array.isArray(e)?this.filter(r=>e.includes(r)):new vf(this.series.filter((r,n)=>this.columns[n]===e))}push(e,...r){if(e instanceof at){if(this.colType!==null&&e.colType!==this.colType)throw new Z("keyVariant must match");this.series.push(...e.series),this.columns.push(...e.columns)}else{if(this.series.push(...r),typeof e=="string"&&this.colType==="key")throw new Z("keyVariant must match");if(typeof e!="string"&&this.colType==="name")throw new Z("keyVariant must match");this.columns.push(...Array.from({length:r.length},()=>e))}}concat(e){return new at([...this.columns,...e.columns],[...this.series,...e.series])}has(e){return typeof e=="string"&&this.colType==="key"||typeof e=="number"&&this.colType==="name"?!1:this.columns.includes(e)}map(e){const r=new at;return this.forEach((n,a,i)=>r.push(...e(n,a,i))),r}forEach(e){this.columns.forEach((r,n)=>{const a=this.series[n];e(r,a,n)})}at(e,r=!1){const n={};return this.uniqueColumns.forEach(a=>{n[a]=this.get(a).at(e,r)}),n}filter(e){const r=new at;return this.columns.forEach((n,a)=>{const i=this.series[a];e(n,i,a)&&r.push(n,i)}),r}get byteLength(){return new dt(this.series.reduce((e,r)=>e.add(r.byteLength),dt.ZERO))}get digest(){const e={};return this.keys.forEach((r,n)=>{const a=this.series[n].digest;r in e?e[r].push(a):e[r]=[a]}),e}get length(){return this.series.reduce((e,r)=>e+r.length,0)}toString(){let e=`Frame{
27
- `;return this.uniqueColumns.forEach(r=>{e+=` ${r}: ${this.get(r).series.map(n=>n.toString()).join(",")}
28
- `}),e+="}",e}};const Qr=s.z.object({keys:s.z.union([s.z.null().transform(()=>[]),s.z.number().array().optional().default([])]),series:s.z.union([s.z.null().transform(()=>[]),Me.crudeZ.array().optional().default([])])}),Xo=t=>{const{dataType:e,data:r,timeRange:n,alignment:a}=t;return new Me({data:r,dataType:e,timeRange:n,glBufferUsage:"static",alignment:a})},Qo=t=>({timeRange:t.timeRange,dataType:t.dataType,data:new Uint8Array(t.data.buffer),alignment:t.alignment});var pt=(t=>(t[t.Open=0]="Open",t[t.Write=1]="Write",t[t.Commit=2]="Commit",t[t.SetAuthority=3]="SetAuthority",t))(pt||{}),Ht=(t=>(t[t.PersistStream=1]="PersistStream",t[t.Persist=2]="Persist",t[t.Stream=3]="Stream",t))(Ht||{});const Bg=new S(-1);class ts extends me.sub("writer_closed"){constructor(){super("WriterClosed")}}const Zg=s.z.enum(Ht).or(s.z.enum(["persist","stream","persistStream"]).transform(t=>{switch(t){case"persist":return 2;case"stream":return 3;case"persistStream":return 1}})),el=s.z.object({start:E.z.optional(),controlSubject:ae.subjectZ.optional(),authorities:s.z.union([ae.authorityZ.transform(t=>[t]),ae.authorityZ.array()]).default([ae.ABSOLUTE_AUTHORITY]),mode:Zg.default(1),errOnUnauthorized:s.z.boolean().default(!1),enableAutoCommit:s.z.boolean().default(!1),autoIndexPersistInterval:S.z.default(S.SECOND),useHighPerformanceCodec:s.z.boolean().default(!0)}),Fg=el.extend({keys:L.array().optional()}),La=el.extend({channels:Je}),tl=La.or(Je.transform(t=>La.parse({channels:t,start:E.now()}))),qg=s.z.object({command:s.z.enum(pt),config:Fg.optional(),frame:Qr.optional(),buffer:s.z.instanceof(Uint8Array).optional()}),Yg=s.z.object({command:s.z.enum(pt),end:E.z,err:Oe.payloadZ.optional()}),Hg=s.z.tuple([s.z.union([s.z.record(L.or(Te),ae.authorityZ),L.or(Te),ae.authorityZ]),ae.authorityZ.optional()]).transform(([t,e])=>{if(ae.authorityZ.safeParse(t).success)return{keys:[],authorities:[t]};if(L.or(Te).safeParse(t).success){if(e==null)throw new Error("authority is required when setting authority for a single channel");return{keys:[t],authorities:[e]}}const r=t;return{keys:Object.keys(r),authorities:Object.values(r)}});let rl=class rs{static ENDPOINT="/frame/write";stream;adapter;closeErr=null;constructor(e,r){this.stream=e,this.adapter=r}static async _open(e,r,n){const a=tl.parse(n),i=await Fs.open(e,a.channels);a.useHighPerformanceCodec&&(r=r.withCodec(new Jg(i.codec)));const o=await r.stream(rs.ENDPOINT,qg,Yg),l=new rs(o,i);return await l.execute({command:0,config:{...a,keys:i.keys}}),l}async write(e,r){if(this.closeErr!=null)throw this.closeErr;if(this.stream.received())return await this.close();const n=await this.adapter.adapt(e,r);this.stream.send({command:1,frame:n.toPayload()})}async setAuthority(e,r){if(this.closeErr!=null)throw this.closeErr;const n=Hg.parse([e,r]),a={keys:await this.adapter.adaptParams(n.keys),authorities:n.authorities};await this.execute({command:3,config:a})}async commit(){if(this.closeErr!=null)throw this.closeErr;return this.stream.received()?(await this.closeInternal(null),E.ZERO):(await this.execute({command:2})).end}async close(){await this.closeInternal(null)}async closeInternal(e){if(this.closeErr!=null)throw this.closeErr;for(this.closeErr=e,this.stream.closeSend();;){if(this.closeErr!=null){if(ts.matches(this.closeErr))return null;throw this.closeErr}const[r,n]=await this.stream.receive();n!=null?this.closeErr=ue.matches(n)?new ts:n:this.closeErr=Oe.decode(r?.err)}}async execute(e){const r=this.stream.send(e);for(r!=null&&await this.closeInternal(r);;){const[n,a]=await this.stream.receive();a!=null&&await this.closeInternal(a);const i=Oe.decode(n?.err);if(i!=null&&await this.closeInternal(i),n?.command==e.command)return n}}};const Pa=t=>t.data.byteLength/t.dataType.density.valueOf(),_g=t=>{const{keys:e,series:r}=t;e.forEach((n,a)=>{r[a].key=n}),r.sort((n,a)=>n.key-a.key),e.sort((n,a)=>n-a),r.forEach(n=>delete n.key)},Da=5,$a=4,Ba=3,Za=2,Fa=1,qa=0,de=C.TIMESTAMP.density.valueOf(),Ae=8,ke=4,On=4,zn=4,Vg=1;class nl{contentType="application/sy-framer";states=new Map;currState;seqNum=0;constructor(e=[],r=[]){(e.length>0||r.length>0)&&this.update(e,r)}update(e,r){this.seqNum++;const n={keys:e,keyDataTypes:new Map,hasVariableDataTypes:!1};e.forEach((a,i)=>{const o=r[i];n.keyDataTypes.set(a,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 Z(`
29
- The codec has not been updated with a list of channels and data types.
30
- Please call the update method before calling ${e}.
31
- `)}encode(e,r=0){this.throwIfNotUpdated("encode");let n=e;e!=null&&typeof e=="object"&&"toPayload"in e&&(n=e.toPayload()),_g(n);let a=-1,i,o,l,c=r+Vg+zn,u=!this.currState?.hasVariableDataTypes,h=!0,f=!0,d=!0,z=!0,N=!0;n.keys.length!==this.currState?.keys.length&&(d=!1,c+=n.keys.length*On),n.series.forEach((D,he)=>{const ie=Pa(D),Et=n.keys[he],Fe=this.currState?.keyDataTypes.get(Et);if(Fe==null)throw new Z(`Channel ${Et} was not provided in the list of channels when opening the writer`);if(!Fe.equals(D.dataType))throw new Z(`Series data type of ${D.dataType.toString()} does not match the data type of ${Fe.toString()} for channel ${Et}`);if(c+=D.data.byteLength,a===-1){a=ie,i=D.timeRange?.start,o=D.timeRange?.end,l=BigInt(D.alignment??0n);return}a!==ie&&(u=!1),(i?.valueOf()!==D.timeRange?.start.valueOf()||o?.valueOf()!==D.timeRange?.end.valueOf())&&(h=!1),l!==BigInt(D.alignment??0)&&(z=!1)}),f=h&&i==null&&o==null,N=z&&(l===void 0||l===0n),u?c+=ke:c+=n.keys.length*ke,f||(h?c+=de*2:c+=n.keys.length*de*2),N||(z?c+=Ae:c+=n.keys.length*Ae);const I=new Uint8Array(c),B=new DataView(I.buffer);let R=r;return I[R]=Number(N)<<Da|Number(z)<<$a|Number(u)<<Ba|Number(h)<<Za|Number(f)<<Fa|Number(d)<<qa,R++,B.setUint32(R,this.seqNum,!0),R+=zn,u&&(B.setUint32(R,a,!0),R+=ke),h&&!f&&(B.setBigUint64(R,i?.valueOf()??0n,!0),B.setBigUint64(R,o?.valueOf()??0n,!0),R+=de*2),z&&!N&&(B.setBigUint64(R,l??0n,!0),R+=Ae),n.series.forEach((D,he)=>{if(d||(B.setUint32(R,n.keys[he],!0),R+=On),!u){let ie=D.data.byteLength;D.dataType.isVariable||(ie=Pa(D)),B.setUint32(R,ie,!0),R+=ke}I.set(new Uint8Array(D.data),R),R+=D.data.byteLength,!h&&!f&&(B.setBigUint64(R,D.timeRange?.start.valueOf()??0n,!0),B.setBigUint64(R,D.timeRange?.end.valueOf()??0n,!0),R+=de*2),!z&&!N&&(B.setBigUint64(R,D.alignment??0n,!0),R+=Ae)}),I}decode(e,r=0){this.throwIfNotUpdated("decode");const n=e instanceof Uint8Array?e:new Uint8Array(e),a={keys:[],series:[]};let i=r,o=0,l=0,c,u,h;const f=new DataView(n.buffer,n.byteOffset,n.byteLength),d=!!(n[i]>>Da&1),z=!!(n[i]>>$a&1),N=!!(n[i]>>Ba&1),I=!!(n[i]>>Za&1),B=!!(n[i]>>Fa&1),R=!!(n[i]>>qa&1);i++;const D=f.getUint32(i,!0);i+=zn;const he=this.states.get(D);if(he==null)return a;if(N){if(i+ke>f.byteLength)return a;o=f.getUint32(i,!0),i+=ke}if(I&&!B){if(i+de>f.byteLength)return a;c=new E(f.getBigUint64(i,!0)),i+=de,u=new E(f.getBigUint64(i,!0)),i+=de}if(z&&!d){if(i+Ae>f.byteLength)return a;h=f.getBigUint64(i,!0),i+=Ae}return R&&(a.keys=[...he.keys]),he.keys.forEach((ie,Et)=>{if(!R){if(i>=f.byteLength||f.getUint32(i,!0)!==ie)return;i+=On,a.keys.push(ie)}const Fe=he.keyDataTypes.get(ie);if(l=0,N)l=o;else{if(i+ke>f.byteLength)return;l=f.getUint32(i,!0),i+=ke}let pr=l;if(Fe.isVariable||(pr*=Fe.density.valueOf()),i+pr>f.byteLength){a.keys.splice(Et,1);return}const qe={dataType:Fe,data:n.slice(i,i+pr).buffer};if(i+=pr,!I&&!B){if(i+de*2>f.byteLength)return;const kc=f.getBigUint64(i,!0);i+=de;const Cc=f.getBigUint64(i,!0);i+=de,qe.timeRange=new P({start:kc,end:Cc})}else B?qe.timeRange=new P({start:0n,end:0n}):qe.timeRange=new P({start:c?.valueOf()??0n,end:u?.valueOf()??0n});if(!z&&!d){if(i+Ae>f.byteLength)return;h=f.getBigUint64(i,!0),i+=Ae,qe.alignment=h}else d?qe.alignment=0n:qe.alignment=h;a.series.push(qe)}),a}}const Zs=254,Wg=new Uint8Array([Zs]),Gg=255,Kg=new Uint8Array([Gg]),sl="application/sy-framer";class Jg{contentType=sl;base;lowPerfCodec;constructor(e){this.base=e,this.lowPerfCodec=Ke.JSON_CODEC}encode(e){const r=e;if(r.type=="close"||r.payload?.command!=pt.Write){const a=this.lowPerfCodec.encode(r),i=new Uint8Array({length:a.byteLength+1});return i.set(Wg,0),i.set(new Uint8Array(a),1),i}const n=this.base.encode(r.payload?.frame,1);return n.set(Kg,0),n}decode(e,r){if(new DataView(e instanceof Uint8Array?e.buffer:e).getUint8(0)===Zs)return this.lowPerfCodec.decode(e.slice(1),r);const n={type:"data"},a=this.base.decode(e,1);return n.payload={command:pt.Write,frame:a},n}}class Xg{contentType=sl;base;lowPerfCodec;constructor(e){this.base=e,this.lowPerfCodec=Ke.JSON_CODEC}encode(e){return this.lowPerfCodec.encode(e)}decode(e,r){return new DataView(e instanceof Uint8Array?e.buffer:e).getUint8(0)===Zs?this.lowPerfCodec.decode(e.slice(1),r):{type:"data",payload:{frame:this.base.decode(e,1)}}}}class en{adapter;retriever;keys;codec;constructor(e){this.retriever=e,this.adapter=null,this.keys=[],this.codec=new nl}static async open(e,r){const n=new en(e);return await n.update(r),n}async update(e){const{variant:r,normalized:n}=ce(e),a=await this.retriever.retrieve(n),i=a.map(l=>l.key);if(ba.uniqueUnorderedPrimitiveArrays(this.keys,i)===ba.EQUAL)return!1;if(this.codec.update(i,a.map(l=>l.dataType)),r==="keys")return this.adapter=null,this.keys=n,!0;const o=new Map;return this.adapter=o,n.forEach(l=>{const c=a.find(u=>u.name===l);if(c==null)throw new Error(`Channel ${l} not found`);o.set(c.key,c.name)}),this.keys=Array.from(this.adapter.keys()),!0}adapt(e){if(this.adapter==null)return e;const r=this.adapter;return e.map((n,a)=>{if(typeof n=="number"){const i=r.get(n);if(i==null)throw new Error(`Channel ${n} not found`);return[i,a]}return[n,a]})}}class Fs{adapter;retriever;keys;codec;constructor(e){this.retriever=e,this.adapter=null,this.keys=[],this.codec=new nl}static async open(e,r){const n=new Fs(e);return await n.update(r),n}async adaptParams(e){const r=Je.parse(e);return await Promise.all(r.map(async n=>await this.adaptToKey(n)))}async update(e){const r=await Vo(this.retriever,e),n=r.map(c=>c.key),a=new Set(this.keys),i=new Set(n),o=!i.isSubsetOf(a),l=!a.isSubsetOf(i);return o||l?(this.adapter=new Map(r.map(c=>[c.name,c.key])),this.keys=n,this.codec.update(this.keys,r.map(c=>c.dataType)),!0):!1}async fetchChannel(e){const r=await this.retriever.retrieve(e);if(r.length===0)throw new Error(`Channel ${JSON.stringify(e)} not found`);return r[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,r){if(typeof e=="string"||typeof e=="number"){if(r==null)throw new Z(`
32
- Received a single channel name or key but no series.
33
- `);if(Array.isArray(r)){if(r.some(c=>c instanceof Me||Array.isArray(c)))throw new Z(`
34
- Received a single channel name or key but multiple series.
35
- `);r=r}const o=await this.fetchChannel(e),l=new Me({data:r,dataType:o.dataType});return new Q(o.key,l)}if(Array.isArray(e)){if(r==null)throw new Z(`
36
- Received an array of channel names or keys but no series.
37
- `);if(!Array.isArray(r))throw new Z(`
38
- Received an array of channel names or keys but no array of series.
39
- `);const o=[],l=[];for(let c=0;c<e.length;c++){const u=await this.fetchChannel(e[c]);if(c>=r.length)throw new Z(`
40
- Received an array of channel names or keys but not enough series.
41
- `);const h=new Me({data:r[c],dataType:u.dataType});o.push(u.key),l.push(h)}return new Q(o,l)}if(e instanceof Q||e instanceof Map){const o=new Q(e);if(this.adapter==null)return o;const l=o.columns.map(c=>{const u=typeof c=="string"?this.adapter?.get(c):c;if(u==null)throw new Z(`
42
- Channel ${c} was not provided in the list of channels when opening the writer
43
- `);return u});return new Q(l,o.series)}const n=[],a=[],i=Object.entries(e);for(let o=0;o<i.length;o++){const[l,c]=i[o],u=await this.fetchChannel(l),h=new Me({data:c,dataType:u.dataType});n.push(u.key),a.push(h)}return new Q(n,a)}}class al{name;stream;constructor(e,r){this.stream=r,this.name=e}async receive(){const[e,r]=await this.stream.receive();if(r!=null)throw r;return e}received(){return this.stream.received()}async closeAndAck(){for(this.stream.closeSend();;){const[e,r]=await this.stream.receive();if(e!=null&&console.warn(`${this.name} received unexpected response on ${JSON.stringify(e)} closure.
44
- Please report this error to the Synnax team.`),r!=null){if(ue.matches(r))return;throw r}}}closeSend(){this.stream.closeSend()}send(e){const r=this.stream.send(e);if(r!=null)throw r}}const Pr=new S(-1);var qs=(t=>(t[t.Open=0]="Open",t[t.Next=1]="Next",t[t.Prev=2]="Prev",t[t.SeekFirst=3]="SeekFirst",t[t.SeekLast=4]="SeekLast",t[t.SeekLE=5]="SeekLE",t[t.SeekGE=6]="SeekGE",t[t.Valid=7]="Valid",t[t.Error=8]="Error",t))(qs||{}),il=(t=>(t[t.None=0]="None",t[t.Ack=1]="Ack",t[t.Data=2]="Data",t))(il||{});const Qg=s.z.object({command:s.z.enum(qs),span:S.z.optional(),bounds:P.z.optional(),stamp:E.z.optional(),keys:L.array().optional(),chunkSize:s.z.number().optional()}),em=s.z.object({variant:s.z.enum(il),ack:s.z.boolean(),command:s.z.enum(qs),error:Oe.payloadZ.optional().nullable(),frame:Qr.optional()});class _t{static ENDPOINT="/frame/iterate";stream;adapter;value;constructor(e,r){this.stream=new al("Iterator",e),this.value=new Q,this.adapter=r}static async _open(e,r,n,a,i={}){const o=await en.open(n,r),l=await a.stream(_t.ENDPOINT,Qg,em),c=new _t(l,o);return await c.execute({command:0,keys:o.keys,bounds:new P(e),chunkSize:i.chunkSize??1e5}),c}async next(e=Pr){return await this.execute({command:1,span:new S(e)})}async prev(e=Pr){return await this.execute({command:2,span:new S(e)})}async seekFirst(){return await this.execute({command:3})}async seekLast(){return await this.execute({command:4})}async seekLE(e){return await this.execute({command:5,stamp:new E(e)})}async seekGE(e){return await this.execute({command:6,stamp:new E(e)})}async valid(){return await this.execute({command:7})}async close(){await this.stream.closeAndAck()}[Symbol.asyncIterator](){return new tm(this)}async execute(e){for(this.stream.send(e),this.value=new Q;;){const r=await this.stream.receive();if(r.variant===1)return r.ack;this.value.push(this.adapter.adapt(new Q(r.frame)))}}}class tm{iter;open=!1;constructor(e){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 rm=s.z.object({keys:s.z.number().array(),downsampleFactor:s.z.number()}),nm=s.z.object({frame:Qr}),sm="/frame/stream",Ya=s.z.object({channels:Je,downsampleFactor:s.z.number().optional().default(1),useHighPerformanceCodec:s.z.boolean().optional().default(!0)}),Ys=Ya.or(Je.transform(t=>Ya.parse({channels:t}))),ol=(t,e)=>async r=>{const n=Ys.parse(r),a=await en.open(t,n.channels);n.useHighPerformanceCodec&&(e=e.withCodec(new Xg(a.codec)));const i=await e.stream(sm,rm,nm),o=new am(i,a);i.send({keys:a.keys,downsampleFactor:n.downsampleFactor??1});const[,l]=await i.receive();if(l!=null)throw l;return o},ll=async(t,e,r)=>await ol(t,e)(r);class am{stream;adapter;downsampleFactor;constructor(e,r){this.stream=new al("Streamer",e),this.adapter=r,this.downsampleFactor=1}get keys(){return this.adapter.keys}async next(){try{return{done:!1,value:await this.read()}}catch(e){if(ue.matches(e))return{done:!0,value:void 0};throw e}}async read(){return this.adapter.adapt(new Q((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 tn{wrapped_=null;breaker;opener;config;constructor(e,r,n={}){this.opener=e,this.config=Ys.parse(r);const{maxRetries:a=5e3,baseInterval:i=S.seconds(1),scale:o=1}=n??{};this.breaker=new To.Breaker({maxRetries:a,baseInterval:i,scale:o})}static async open(e,r,n){const a=new tn(e,r,n);return await a.runStreamer(),a}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;console.error("failed to open streamer",e);continue}}get wrapped(){if(this.wrapped_==null)throw new Error("stream closed");return this.wrapped_}async update(e){this.config.channels=Je.parse(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(ue.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(ue.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 cl extends Af.Observer{streamer;closePromise;constructor(e,r){super(r),this.streamer=e,this.closePromise=this.stream()}async update(e){await this.streamer.update(e)}async close(){this.streamer.close(),await this.closePromise}async stream(){for await(const e of this.streamer)this.notify(e)}}const im=t=>({type:"framer",key:t.toString()});let ul=class{streamClient;retriever;deleter;constructor(t,e,r){this.streamClient=t,this.retriever=r,this.deleter=new $g(e)}async openIterator(t,e,r){return await _t._open(t,e,this.retriever,this.streamClient,r)}async openWriter(t){return await rl._open(this.retriever,this.streamClient,t)}async openStreamer(t){return await ll(this.retriever,this.streamClient,t)}async write(t,e,r){if(r==null){const a=e,i=await this.openWriter({start:t,channels:Object.keys(a),mode:Ht.Persist,errOnUnauthorized:!0,enableAutoCommit:!0,autoIndexPersistInterval:S.MAX});return await i.write(a),await i.close()}const n=await this.openWriter({start:t,channels:e,mode:Ht.Persist,errOnUnauthorized:!0,enableAutoCommit:!0,autoIndexPersistInterval:S.MAX});await n.write(e,r),await n.close()}async read(t,e){const{single:r}=ce(e),n=await this.readFrame(t,e);return r?n.get(e):n}async readFrame(t,e){const r=await this.openIterator(t,e),n=new Q;try{for await(const a of r)n.push(a)}finally{await r.close()}return n}async readLatest(t,e=1){const{single:r}=ce(t),n=await this.readLatestNFrame(t,e);return r?n.get(t):n}async readLatestNFrame(t,e){const r=await this.openIterator(P.MAX,t,{chunkSize:e}),n=new Q;if(e>0)try{await r.seekLast(),await r.prev(Pr),n.push(r.value)}finally{await r.close()}return n}async delete(t,e){const{normalized:r,variant:n}=ce(t);return n==="keys"?await this.deleter.delete({keys:r,bounds:e}):await this.deleter.delete({names:r,bounds:e})}};const om=Object.freeze(Object.defineProperty({__proto__:null,ALWAYS_INDEX_PERSIST_ON_AUTO_COMMIT:Bg,AUTO_SPAN:Pr,Client:ul,Frame:Q,HardenedStreamer:tn,Iterator:_t,ObservableStreamer:cl,Writer:rl,WriterClosedError:ts,WriterCommand:pt,WriterMode:Ht,createStreamOpener:ol,frameZ:Qr,ontologyID:im,openStreamer:ll,seriesFromPayload:Xo,seriesToPayload:Qo,streamerConfigZ:Ys,writerConfigZ:tl},Symbol.toStringTag,{value:"Module"})),lm=ae.ABSOLUTE_AUTHORITY,cm=ae.ZERO_AUTHORITY,um=ae.stateZ(s.z.number()),hm=t=>t.to==null?`${t.from?.resource} - ${t.from?.subject.name} -> released`:t.from==null?`${t.to.resource} - released -> ${t.to.subject.name} (${t.to.authority.toString()})`:`${t.to.resource} - ${t.from.subject.name} -> ${t.to.subject.name} (${t.to.authority.toString()})`,dm=s.z.object({transfers:s.z.array(ae.transferZ(L))});class hl extends cl{states;codec;constructor(e){super(e,r=>{const n=this.codec.decode(r.series[0].buffer,dm);return this.merge(n),[n.transfers,!0]}),this.states=new Map,this.codec=new Ke.JSONCodec}subjects(){const e=new Map;return this.states.forEach(r=>e.set(r.subject.key,r.subject)),Array.from(e.values())}merge(e){e.transfers.forEach(r=>{r.from==null&&r.to==null&&console.warn("Invalid transfer: ",r),r.to==null?this.states.delete(r.from.resource):this.states.set(r.to.resource,r.to)})}}const dl="sy_node_1_control";let fl=class{framer;constructor(t){this.framer=t}async openStateTracker(){const t=await tn.open(async e=>await this.framer.openStreamer(e),dl);return new hl(t)}};const fm=Object.freeze(Object.defineProperty({__proto__:null,ABSOLUTE_AUTHORITY:lm,CONTROL_STATE_CHANNEL_NAME:dl,Client:fl,StateTracker:hl,ZERO_AUTHORITY:cm,stateZ:um,transferString:hm},Symbol.toStringTag,{value:"Module"}));let pm=class{tasks;racks;devices;constructor(t,e,r){this.tasks=t,this.racks=e,this.devices=r}};const we=s.z.uint32(),pl=sr.statusZ(s.z.object({rack:we})),rn=s.z.object({key:we,name:s.z.string(),status:Pt.nullToUndefined(pl)}),yl=rn.partial({key:!0}),gl=t=>t?Ke.JSON_CODEC.decodeString(t,ze.unknownZ):{},Ot=s.z.string(),ml=sr.statusZ(s.z.object({rack:we,device:Ot})),nn=s.z.object({key:Ot,rack:we,name:s.z.string(),make:s.z.string(),model:s.z.string(),location:s.z.string(),configured:s.z.boolean().optional(),properties:ze.unknownZ.or(s.z.string().transform(gl)),status:Pt.nullToUndefined(ml)}),wl=nn.extend({properties:s.z.unknown().transform(t=>Ke.JSON_CODEC.encodeString(t))}),ym="sy_device_set",gm="sy_device_delete",mm="sy_device_status",wm="/hardware/device/retrieve",bm="/hardware/device/create",vm="/hardware/device/delete",Tm=s.z.object({devices:wl.array()}),Om=s.z.object({devices:nn.array()}),zm=s.z.object({keys:Ot.array()}),Sm=s.z.object({}),Em=s.z.object({keys:Ot.array().optional(),names:s.z.string().array().optional(),makes:s.z.string().array().optional(),models:s.z.string().array().optional(),locations:s.z.string().array().optional(),racks:we.array().optional(),searchTerm:s.z.string().optional(),limit:s.z.number().optional(),offset:s.z.number().optional(),includeStatus:s.z.boolean().optional()}),Nm=s.z.object({devices:F(nn)}),xm=s.z.object({key:Ot,includeStatus:s.z.boolean().optional()}).transform(({key:t,includeStatus:e})=>({keys:[t],includeStatus:e})),Am=s.z.union([xm,Em]);let bl=class{type="device";client;constructor(t){this.client=t}async retrieve(t){const e=typeof t=="object"&&"key"in t,r=await m(this.client,wm,t,Am,Nm);Xe("Device",t,r.devices,e);const n=r.devices;return e?n[0]:n}async create(t){const e=!Array.isArray(t),r=(await m(this.client,bm,{devices:O.toArray(t)},Tm,Om)).devices;return e?r[0]:r}async delete(t){await m(this.client,vm,{keys:O.toArray(t)},zm,Sm)}};const km=t=>({type:"device",key:t}),Cm=Object.freeze(Object.defineProperty({__proto__:null,Client:bl,DELETE_CHANNEL_NAME:gm,SET_CHANNEL_NAME:ym,STATUS_CHANNEL_NAME:mm,deviceZ:nn,keyZ:Ot,newZ:wl,ontologyID:km,statusZ:ml},Symbol.toStringTag,{value:"Module"})),Im="/hardware/rack/retrieve",jm="/hardware/rack/create",Rm="/hardware/rack/delete",Mm="sy_rack_status",Um="sy_rack_set",Lm="sy_rack_delete",Pm=s.z.object({keys:we.array().optional(),names:s.z.string().array().optional(),searchTerm:s.z.string().optional(),embedded:s.z.boolean().optional(),hostIsNode:s.z.boolean().optional(),limit:s.z.number().optional(),offset:s.z.number().optional(),includeStatus:s.z.boolean().optional()}),Dm=s.z.object({racks:F(rn)}),$m=s.z.union([s.z.object({key:we,includeStatus:s.z.boolean().optional()}).transform(({key:t,includeStatus:e})=>({keys:[t],includeStatus:e})),s.z.object({name:s.z.string(),includeStatus:s.z.boolean().optional()}).transform(({name:t,includeStatus:e})=>({names:[t],includeStatus:e}))]),Bm=Pm,Zm=s.z.union([$m,Bm]),Fm=s.z.object({racks:yl.array()}),qm=s.z.object({racks:rn.array()}),Ym=s.z.object({keys:we.array()}),Hm=s.z.object({});let vl=class{type="rack";client;tasks;constructor(t,e){this.client=t,this.tasks=e}async delete(t){await m(this.client,Rm,{keys:O.toArray(t)},Ym,Hm)}async create(t){const e=!Array.isArray(t),r=await m(this.client,jm,{racks:O.toArray(t)},Fm,qm),n=this.sugar(r.racks);return e?n[0]:n}async retrieve(t){const e="key"in t||"name"in t,r=await m(this.client,Im,t,Zm,Dm),n=this.sugar(r.racks);return Xe("Rack",t,n,e),e?n[0]:n}sugar(t){const e=!Array.isArray(t),r=O.toArray(t).map(({key:n,name:a,status:i})=>new Tl(n,a,this.tasks,i));return e?r[0]:r}};class Tl{key;name;status;tasks;constructor(e,r,n,a){this.key=e,this.name=r,this.tasks=n,this.status=a}async listTasks(){return await this.tasks.retrieve({rack:this.key})}async createTask(e,r){return e.key=((BigInt(this.key)<<32n)+(BigInt(e.key??0)&0xffffffffn)).toString(),await this.tasks.create(e,r)}async deleteTask(e){await this.tasks.delete([e])}get payload(){return{key:this.key,name:this.name,status:this.status}}}const _m=t=>({type:"rack",key:t.toString()}),Vm=Object.freeze(Object.defineProperty({__proto__:null,Client:vl,DELETE_CHANNEL_NAME:Lm,Rack:Tl,SET_CHANNEL_NAME:Um,STATUS_CHANNEL_NAME:Mm,keyZ:we,newZ:yl,ontologyID:_m,rackZ:rn,statusZ:pl},Symbol.toStringTag,{value:"Module"})),Se=t=>t?JSON.parse(t):{},Ee=s.z.union([s.z.string(),s.z.bigint().transform(t=>t.toString()),s.z.number().transform(t=>t.toString())]),Ol=t=>s.z.object({task:Ee,running:s.z.boolean(),data:t}),Hs=t=>sr.statusZ(Ol(t)),lr=(t={typeSchema:s.z.string(),configSchema:s.z.unknown(),statusDataSchema:s.z.unknown()})=>s.z.object({key:Ee,name:s.z.string(),type:t.typeSchema,internal:s.z.boolean().optional(),config:s.z.string().transform(gl).or(t.configSchema),status:Hs(t.statusDataSchema).optional().nullable(),snapshot:s.z.boolean().optional()}),zl=t=>lr(t).omit({key:!0}).extend({key:Ee.transform(e=>e.toString()).optional(),config:s.z.unknown().transform(e=>Ke.JSON_CODEC.encodeString(e))}),Wm=s.z.object({task:Ee,type:s.z.string(),key:s.z.string(),args:ze.unknownZ.or(s.z.string().transform(Se)).or(s.z.array(s.z.unknown())).or(s.z.null()).optional()}),Gm=t=>Number(BigInt(t)>>32n),ns="sy_task_status",ss="sy_task_cmd",Km="sy_task_set",Jm="sy_task_delete",Ye=new Error("Task not created"),Sl=async(t,e)=>{const r=await e.retrieveParents(_s(t));return r.length===0?null:r[0]};class El{key;name;internal;type;snapshot;config;status;schemas;frameClient_;ontologyClient_;rangeClient_;get frameClient(){if(this.frameClient_==null)throw Ye;return this.frameClient_}get ontologyClient(){if(this.ontologyClient_==null)throw Ye;return this.ontologyClient_}get rangeClient(){if(this.rangeClient_==null)throw Ye;return this.rangeClient_}constructor({key:e,type:r,name:n,config:a,internal:i=!1,snapshot:o=!1,status:l},c,u,h,f){this.key=e,this.name=n,this.type=r,this.config=a,this.schemas=c??{typeSchema:s.z.string(),configSchema:s.z.unknown(),statusDataSchema:s.z.unknown()},this.internal=i,this.snapshot=o,this.status=l,this.frameClient_=u,this.ontologyClient_=h,this.rangeClient_=f}get payload(){return{key:this.key,name:this.name,type:this.type,config:this.config,status:this.status,internal:this.internal}}get ontologyID(){return _s(this.key)}async executeCommand(e,r){return await xl(this.frameClient,this.key,e,r)}async executeCommandSync(e,r,n){return await Al(this.frameClient,this.key,e,r,this.name,this.schemas?.statusDataSchema,n)}async snapshottedTo(){if(this.ontologyClient==null||this.rangeClient==null)throw Ye;return this.snapshot?await Sl(this.key,this.ontologyClient):null}}const Xm=s.z.object({rack:we.optional(),keys:Ee.array().optional(),names:s.z.string().array().optional(),types:s.z.string().array().optional(),includeStatus:s.z.boolean().optional(),offset:s.z.number().optional(),limit:s.z.number().optional()}),Qm=s.z.union([s.z.object({key:Ee,includeStatus:s.z.boolean().optional()}).transform(({key:t,includeStatus:e})=>({keys:[t],includeStatus:e})),s.z.object({name:s.z.string(),includeStatus:s.z.boolean().optional()}).transform(({name:t,includeStatus:e})=>({names:[t],includeStatus:e}))]),ew=Xm,tw=s.z.union([Qm,ew]),rw=t=>s.z.object({tasks:F(lr(t))}),nw="/hardware/task/retrieve",sw="/hardware/task/create",aw="/hardware/task/delete",iw="/hardware/task/copy",ow=t=>s.z.object({tasks:zl(t).array()}),lw=t=>s.z.object({tasks:lr(t).array()}),cw=s.z.object({keys:Ee.array()}),uw=s.z.object({}),hw=s.z.object({key:Ee,name:s.z.string(),snapshot:s.z.boolean()}),dw=t=>s.z.object({task:lr(t)});let Nl=class{type="task";client;frameClient;ontologyClient;rangeClient;constructor(t,e,r,n){this.client=t,this.frameClient=e,this.ontologyClient=r,this.rangeClient=n}async create(t,e){const r=!Array.isArray(t),n=ow(e),a=lw(e),i=await m(this.client,sw,{tasks:O.toArray(t)},n,a),o=this.sugar(i.tasks,e);return r?o[0]:o}async delete(t){await m(this.client,aw,{keys:O.toArray(t)},cw,uw)}async retrieve({schemas:t,...e}){const r="key"in e||"name"in e,n=(await m(this.client,nw,e,tw,rw(t))).tasks,a=this.sugar(n,t);return Xe("Task",e,a,r),r?a[0]:a}async copy(t,e,r){const n=dw(),a=await m(this.client,iw,{key:t,name:e,snapshot:r},hw,n);return this.sugar(a.task)}async retrieveSnapshottedTo(t){if(this.ontologyClient==null)throw Ye;return await Sl(t,this.ontologyClient)}sugar(t,e){const r=!Array.isArray(t),n=O.toArray(t).map(({key:a,name:i,type:o,config:l,status:c,internal:u,snapshot:h})=>new El({key:a,name:i,type:o,config:l,internal:u,snapshot:h,status:c},e,this.frameClient,this.ontologyClient,this.rangeClient));return r?n[0]:n}async executeCommand(t,e,r){if(Array.isArray(t))return await Vs(this.frameClient,t);if(e==null)throw new Error("Type is required");return await xl(this.frameClient,t,e,r)}async executeCommandSync(t,e,r,n,a,i=s.z.unknown()){if(Array.isArray(t)){const l=async()=>(await this.retrieve({keys:t.map(c=>c.task)})).map(c=>c.name);return await kl(this.frameClient,t,e,i,l)}const o=async()=>(await this.retrieve({key:t})).name;return await Al(this.frameClient,t,e,r,a??o,i,n)}};const _s=t=>({type:"task",key:t}),xl=async(t,e,r,n)=>(await Vs(t,[{args:n,task:e,type:r}]))[0],Vs=async(t,e)=>{if(t==null)throw Ye;const r=await t.openWriter(ss),n=e.map(a=>({...a,key:nf.create()}));return await r.write(ss,n),await r.close(),n.map(a=>a.key)},Al=async(t,e,r,n,a,i,o)=>(await kl(t,[{args:o,task:e,type:r}],n,i,a))[0],kl=async(t,e,r,n,a)=>{if(t==null)throw Ye;const i=await t.openStreamer(ns),o=await Vs(t,e),l=new S(r);let c=[],u;const h=new Promise((f,d)=>{u=setTimeout(()=>{(async()=>{const z=e.map(N=>N.task);d(await fw("command",a,l,z))})()},l.milliseconds)});try{for(;;){const f=await Promise.race([i.read(),h]),d=Hs(n).parse(f.at(-1)[ns]);if(o.includes(d.key)&&(c=[...c.filter(z=>z.key!==d.key),d],c.length===o.length))return c}}finally{clearTimeout(u),i.close()}},fw=async(t,e,r,n)=>{const a=Bh.capitalize(t),i=r.toString();try{let o;typeof e=="string"?o=[e]:Array.isArray(e)?o=e:o=O.toArray(await e());const l=Gn.naturalLanguageJoin(o);return new Error(`${a} command to ${l} timed out after ${i}`)}catch(o){return console.error("Failed to retrieve task name for timeout error:",o),new Error(`${a} command to task with key ${Gn.naturalLanguageJoin(n)} timed out after ${i}`)}},pw=Object.freeze(Object.defineProperty({__proto__:null,COMMAND_CHANNEL_NAME:ss,Client:Nl,DELETE_CHANNEL_NAME:Jm,SET_CHANNEL_NAME:Km,STATUS_CHANNEL_NAME:ns,Task:El,commandZ:Wm,keyZ:Ee,newZ:zl,ontologyID:_s,rackKey:Gm,statusDetailsZ:Ol,statusZ:Hs,taskZ:lr},Symbol.toStringTag,{value:"Module"})),Ze=s.z.uuid(),cr=s.z.object({key:Ze,name:s.z.string().min(1),color:s.z.string()}),yw="labeled_by",gw="sy_label_set",mw="sy_label_delete",Cl=cr.extend({key:Ze.optional()}),ww=s.object({labels:Cl.array()}),bw=s.object({labels:cr.array()}),vw=s.object({keys:Ze.array()}),Il=s.object({id:M,labels:Ze.array(),replace:s.boolean().optional()}),Tw=Il.omit({replace:!0}),Sn=s.object({}),Ow="/label/create",zw="/label/delete",Sw="/label/set",Ew="/label/remove",Nw="/label/retrieve",xw=s.object({keys:Ze.array().optional(),for:M.optional(),searchTerm:s.string().optional(),offset:s.number().optional(),limit:s.number().optional()}),Aw=s.object({key:Ze}).transform(({key:t})=>({keys:[t]})),kw=s.union([Aw,xw]),Cw=s.object({labels:F(cr)});let jl=class{type="label";client;constructor(t){this.client=t}async retrieve(t){const e="key"in t,r=await m(this.client,Nw,t,kw,Cw);return Xe("Label",t,r.labels,e),e?r.labels[0]:r.labels}async label(t,e,r={}){await m(this.client,Sw,{id:t,labels:e,replace:r.replace},Il,Sn)}async remove(t,e){await m(this.client,Ew,{id:t,labels:e},Tw,Sn)}async create(t){const e=Array.isArray(t),r=await m(this.client,Ow,{labels:O.toArray(t)},ww,bw);return e?r.labels:r.labels[0]}async delete(t){await m(this.client,zw,{keys:O.toArray(t)},vw,Sn)}};const Iw=t=>({type:"label",key:t}),jw=Object.freeze(Object.defineProperty({__proto__:null,Client:jl,DELETE_CHANNEL_NAME:mw,LABELED_BY_ONTOLOGY_RELATIONSHIP_TYPE:yw,SET_CHANNEL_NAME:gw,keyZ:Ze,labelZ:cr,newZ:Cl,ontologyID:Iw},Symbol.toStringTag,{value:"Module"})),_=s.z.uuid(),Ws=s.z.string().min(1),ur=s.z.object({key:_,name:Ws,timeRange:P.z,color:s.z.string().optional(),labels:cr.array().or(s.z.null().transform(()=>{})).optional(),get parent(){return ur.optional().nullable().transform(t=>t===void 0?null:t)}}),Rl=ur.omit({parent:!0,labels:!0}).partial({key:!0}),Rw="sy_range_alias_set",Mw="sy_range_alias_delete",Uw=s.z.object({range:_,aliases:s.z.string().array()}),Lw=s.z.object({aliases:s.z.record(s.z.string(),L)}),Pw=s.z.object({range:_,aliases:s.z.record(L,s.z.string())}),Dw=s.z.unknown(),$w=s.z.object({range:_,channels:L.array()}),Bw=s.z.unknown(),Zw=s.z.object({range:_}),Fw=s.z.object({aliases:s.z.record(s.z.string(),s.z.string())}),qw=s.z.object({range:_,channels:L.array()}),Yw=s.z.object({aliases:s.z.record(s.z.string(),s.z.string())});let it=class ot{static SET_ENDPOINT="/range/alias/set";static RESOLVE_ENDPOINT="/range/alias/resolve";static LIST_ENDPOINT="/range/alias/list";static RETRIEVE_ENDPOINT="/range/alias/retrieve";static DELETE_ENDPOINT="/range/alias/delete";frameClient;cache=new Map;client;rangeKey;constructor(e,r,n){this.rangeKey=e,this.cache=new Map,this.client=n,this.frameClient=r}async resolve(e){const r=[],n=typeof e=="string",a={};if(n){const o=this.cache.get(e);if(o!=null)return o;r.push(e)}else e.forEach(o=>{const l=this.cache.get(o);l!=null?a[o]=l:r.push(o)});if(r.length===0)return a;const i=await m(this.client,ot.RESOLVE_ENDPOINT,{range:this.rangeKey,aliases:r},Uw,Lw);return Object.entries(i.aliases).forEach(([o,l])=>this.cache.set(o,l)),n?i.aliases[r[0]]:{...a,...i.aliases}}async set(e){await m(this.client,ot.SET_ENDPOINT,{range:this.rangeKey,aliases:e},Pw,Dw)}async list(){return(await m(this.client,ot.LIST_ENDPOINT,{range:this.rangeKey},Zw,Fw)).aliases}async retrieve(e){const r=typeof e=="number",n=await m(this.client,ot.RETRIEVE_ENDPOINT,{range:this.rangeKey,channels:O.toArray(e)},qw,Yw);return r?n.aliases[e]:n.aliases}async delete(e){await m(this.client,ot.DELETE_ENDPOINT,{range:this.rangeKey,channels:e},$w,Bw)}};const Hw=s.z.object({alias:s.z.string().optional(),channel:L,range:_}),Ml="---",_w=t=>`${t.range}${Ml}${t.channel}`,Vw=t=>{const[e,r]=t.split(Ml);return{range:e,channel:Number(r)}},Ww="sy_range_kv_set",Gw="sy_range_kv_delete",Gs=s.z.object({range:_,key:s.z.string(),value:s.z.string()}),Kw=({range:t,key:e})=>`${t}<--->${e}`,Jw=s.z.object({range:_,keys:s.z.string().array()}),Xw=s.z.object({pairs:F(Gs)}),Qw=s.z.object({range:_,pairs:Gs.array()}),eb=s.z.object({range:_,keys:s.z.string().array()});class We{static GET_ENDPOINT="/range/kv/get";static SET_ENDPOINT="/range/kv/set";static DELETE_ENDPOINT="/range/kv/delete";rangeKey;client;constructor(e,r){this.rangeKey=e,this.client=r}async get(e){const r=await m(this.client,We.GET_ENDPOINT,{range:this.rangeKey,keys:O.toArray(e)},Jw,Xw);return typeof e=="string"?r.pairs[0].value:Object.fromEntries(r.pairs.map(n=>[n.key,n.value]))}async list(){return this.get([])}async set(e,r=""){let n;Ci(e)?n=Object.entries(e).map(([a,i])=>({range:this.rangeKey,key:a,value:i})):n=[{range:this.rangeKey,key:e,value:r}],await m(this.client,We.SET_ENDPOINT,{range:this.rangeKey,pairs:n},Qw,s.z.unknown())}async delete(e){await m(this.client,We.DELETE_ENDPOINT,{range:this.rangeKey,keys:O.toArray(e)},eb,s.z.unknown())}}const tb="sy_range_set",rb="sy_range_delete";class Ul{key;name;kv;timeRange;color;parent;labels;channels;aliaser;frameClient;labelClient;ontologyClient;rangeClient;constructor({name:e,timeRange:r=P.ZERO,key:n,color:a,parent:i,labels:o},{frameClient:l,kv:c,aliaser:u,channels:h,labelClient:f,ontologyClient:d,rangeClient:z}){this.key=n,this.name=e,this.timeRange=r,this.parent=i,this.labels=o,this.frameClient=l,this.color=a,this.kv=c,this.aliaser=u,this.channels=h,this.labelClient=f,this.ontologyClient=d,this.rangeClient=z}get ontologyID(){return lt(this.key)}get payload(){let e=null;return this.parent!=null&&("payload"in this.parent?e=this.parent.payload:e=this.parent),{key:this.key,name:this.name,timeRange:this.timeRange,color:this.color,labels:this.labels,parent:e}}async setAlias(e,r){const n=await this.channels.retrieve(e);if(n.length===0)throw new Be(`Channel ${e} does not exist`);await this.aliaser.set({[n[0].key]:r})}async deleteAlias(...e){await this.aliaser.delete(e)}async listAliases(){return await this.aliaser.list()}async resolveAlias(e){return await this.aliaser.resolve(e)}async retrieveParent(){return this.rangeClient.retrieveParent(this.key)}async retrieveChildren(){const e=(await this.ontologyClient.retrieveChildren(this.ontologyID,{excludeFieldData:!0,types:["range"]})).map(r=>r.id.key);return await this.rangeClient.retrieve(e)}async read(e){return await this.frameClient.read(this.timeRange,e)}async retrieveLabels(){return await this.labelClient.retrieve({for:lt(this.key)})}async addLabel(...e){await this.labelClient.label(lt(this.key),e)}async removeLabel(...e){await this.labelClient.remove(lt(this.key),e)}static sort(e,r){return P.sort(e.timeRange,r.timeRange)}}const nb=s.z.object({keys:_.array().optional(),names:s.z.array(s.z.string()).optional(),searchTerm:s.z.string().optional(),overlapsWith:P.z.optional(),limit:s.z.number().int().optional(),offset:s.z.number().int().optional(),hasLabels:Ze.array().optional(),includeLabels:s.z.boolean().optional(),includeParent:s.z.boolean().optional()}),sb=nb.or(_.array().transform(t=>({keys:t}))).or(_.transform(t=>({keys:[t]}))).or(s.z.string().transform(t=>({names:[t]}))).or(s.z.string().array().transform(t=>({names:t}))).or(P.z.transform(t=>({overlapsWith:t}))),ab="/range/retrieve",ib=s.z.object({ranges:F(ur)});let Ll=class{type="range";frameClient;writer;unaryClient;channels;labelClient;ontologyClient;constructor(t,e,r,n,a,i){this.frameClient=t,this.writer=e,this.unaryClient=r,this.channels=n,this.labelClient=a,this.ontologyClient=i}async create(t,e){const r=!Array.isArray(t),n=this.sugarMany(await this.writer.create(O.toArray(t),e));return r?n[0]:n}async rename(t,e){await this.writer.rename(t,e)}async delete(t){await this.writer.delete(O.toArray(t))}async retrieve(t){const e=typeof t=="string",{ranges:r}=await m(this.unaryClient,ab,t,sb,ib);return Xe("Range",t,r,e),e?this.sugarMany(r)[0]:this.sugarMany(r)}getKV(t){return new We(t,this.unaryClient)}async retrieveParent(t){const e=await this.ontologyClient.retrieveParents(lt(t));if(e.length===0)return null;const r=e[0];return r.id.type!=="range"?null:await this.retrieve(r.id.key)}sugarOntologyResource(t){return this.sugarOne(Pl(t))}async retrieveAlias(t,e){return await new it(t,this.frameClient,this.unaryClient).retrieve(e)}async retrieveAliases(t,e){return await new it(t,this.frameClient,this.unaryClient).retrieve(e)}async listAliases(t){return await new it(t,this.frameClient,this.unaryClient).list()}async setAlias(t,e,r){await new it(t,this.frameClient,this.unaryClient).set({[e]:r})}sugarOne(t){return new Ul(t,{frameClient:this.frameClient,kv:new We(t.key,this.unaryClient),aliaser:new it(t.key,this.frameClient,this.unaryClient),channels:this.channels,labelClient:this.labelClient,ontologyClient:this.ontologyClient,rangeClient:this})}sugarMany(t){return t.map(e=>this.sugarOne(e))}resourceToRange(t){return this.sugarOne({key:t.id.key,name:t.data?.name,timeRange:new P(t.data?.timeRange),color:t.data?.color,labels:[],parent:null})}};const lt=t=>({type:"range",key:t}),ob=t=>({type:"range-alias",key:t}),Pl=({data:t,id:{key:e},name:r})=>{const n=P.z.parse(t?.timeRange);return{key:e,name:r,timeRange:n,color:typeof t?.color=="string"?t.color:void 0,labels:[],parent:null}},lb=s.z.object({ranges:ur.array()}),cb=s.z.object({parent:M.optional(),ranges:Rl.array()}),ub=s.z.object({keys:_.array()}),hb=s.z.object({}),db=s.z.object({key:_,name:Ws}),fb=s.z.object({}),pb="/range/create",yb="/range/delete",gb="/range/rename";class Dl{client;constructor(e){this.client=e}async rename(e,r){await m(this.client,gb,{key:e,name:r},db,fb)}async create(e,r){return(await m(this.client,pb,{ranges:e,...r},cb,lb)).ranges}async delete(e){await m(this.client,yb,{keys:e},ub,hb)}}const mb=Object.freeze(Object.defineProperty({__proto__:null,Aliaser:it,Client:Ll,DELETE_ALIAS_CHANNEL_NAME:Mw,DELETE_CHANNEL_NAME:rb,KV:We,KV_DELETE_CHANNEL:Gw,KV_SET_CHANNEL:Ww,Range:Ul,SET_ALIAS_CHANNEL_NAME:Rw,SET_CHANNEL_NAME:tb,Writer:Dl,aliasKey:_w,aliasOntologyID:ob,aliasZ:Hw,convertOntologyResourceToPayload:Pl,decodeDeleteAliasChange:Vw,keyZ:_,kvPairKey:Kw,kvPairZ:Gs,nameZ:Ws,newZ:Rl,ontologyID:lt,payloadZ:ur},Symbol.toStringTag,{value:"Module"})),wb="/api/v1/";class bb{url;unary;stream;secure;constructor(e,r={},n=!1){this.secure=n,this.url=e.child(wb);const a=new Ke.JSONCodec;this.unary=Nh(new Eh(this.url,a,this.secure),r),this.stream=new jr(this.url,a,this.secure)}use(...e){this.unary.use(...e),this.stream.use(...e)}}const hr=s.z.uuid(),Ks=s.z.object({key:hr,name:s.z.string(),data:ze.unknownZ.or(s.z.string().transform(Se))}),vb=Ks.partial({key:!0}).transform(t=>({...t,data:JSON.stringify(t.data)})),be=s.z.uuid(),sn=s.z.object({key:be,name:s.z.string(),layout:ze.unknownZ.or(s.z.string().transform(Se))}),$l=sn.partial({key:!0}).transform(t=>({...t,layout:JSON.stringify(t.layout)})),Bl=sn.omit({layout:!0}).extend({layout:s.z.string().transform(Se)}),Tb="/workspace/lineplot/retrieve",Ob="/workspace/lineplot/create",zb="/workspace/lineplot/rename",Sb="/workspace/lineplot/set-data",Eb="/workspace/lineplot/delete",Nb=s.z.object({keys:hr.array()}),xb=s.z.object({workspace:be,linePlots:vb.array()}),Ab=s.z.object({key:hr,name:s.z.string()}),kb=s.z.object({key:hr,data:s.z.string()}),Cb=s.z.object({keys:hr.array()}),Ib=s.z.object({linePlots:F(Ks)}),jb=s.z.object({linePlots:Ks.array()}),En=s.z.object({});let Rb=class{client;constructor(t){this.client=t}async create(t,e){const r=Array.isArray(e),n=await m(this.client,Ob,{workspace:t,linePlots:O.toArray(e)},xb,jb);return r?n.linePlots:n.linePlots[0]}async rename(t,e){await m(this.client,zb,{key:t,name:e},Ab,En)}async setData(t,e){await m(this.client,Sb,{key:t,data:JSON.stringify(e)},kb,En)}async retrieve(t){const e=Array.isArray(t),r=await m(this.client,Tb,{keys:O.toArray(t)},Nb,Ib);return e?r.linePlots:r.linePlots[0]}async delete(t){await m(this.client,Eb,{keys:O.toArray(t)},Cb,En)}};const dr=s.z.uuid(),Js=s.z.object({key:dr,name:s.z.string(),data:ze.unknownZ.or(s.z.string().transform(Se))}),Mb=Js.partial({key:!0}).transform(t=>({...t,data:JSON.stringify(t.data)})),Ub="/workspace/log/retrieve",Lb="/workspace/log/create",Pb="/workspace/log/rename",Db="/workspace/log/set-data",$b="/workspace/log/delete",Bb=s.z.object({keys:dr.array()}),Zb=s.z.object({workspace:be,logs:Mb.array()}),Fb=s.z.object({key:dr,name:s.z.string()}),qb=s.z.object({key:dr,data:s.z.string()}),Yb=s.z.object({keys:dr.array()}),Hb=s.z.object({logs:Js.array()}),_b=s.z.object({logs:Js.array()}),Nn=s.z.object({});let Vb=class{client;constructor(t){this.client=t}async create(t,e){const r=Array.isArray(e),n=await m(this.client,Lb,{workspace:t,logs:O.toArray(e)},Zb,_b);return r?n.logs:n.logs[0]}async rename(t,e){await m(this.client,Pb,{key:t,name:e},Fb,Nn)}async setData(t,e){await m(this.client,Db,{key:t,data:JSON.stringify(e)},qb,Nn)}async retrieve(t){const e=Array.isArray(t),r=await m(this.client,Ub,{keys:O.toArray(t)},Bb,Hb);return e?r.logs:r.logs[0]}async delete(t){await m(this.client,$b,{keys:O.toArray(t)},Yb,Nn)}};const et=s.z.uuid(),an=s.z.object({key:et,name:s.z.string(),data:ze.unknownZ.or(s.z.string().transform(Se)),snapshot:s.z.boolean()}),Zl=an.partial({key:!0,snapshot:!0}).transform(t=>({...t,data:JSON.stringify(t.data)})),Xs=an.extend({data:s.z.string().transform(Se)}),zt=s.z.uuid(),Fl=s.z.object({key:s.z.string(),name:s.z.string(),selectors:s.z.string().array().default([]),strokeColor:s.z.string().optional(),fillColor:s.z.string().optional()}),ql=s.z.object({key:s.z.string(),name:s.z.string(),regions:Fl.array()}),Yl=s.z.object({key:s.z.string(),position:oo.xy,orientation:kd.outer}),Wb=s.z.object({zoom:s.z.number().positive().default(1),position:oo.xy}),Hl=s.z.object({svg:s.z.string().min(1,"SVG is required"),states:ql.array(),variant:s.z.string().min(1,"Variant is required"),handles:Yl.array(),scale:s.z.number().positive().default(1),scaleStroke:s.z.boolean().default(!1),previewViewport:Wb.default({zoom:1,position:{x:0,y:0}})}),on=s.z.object({key:zt,version:s.z.literal(1).optional().default(1),name:s.z.string().min(1,"Name is required"),data:Hl}),_l=on.partial({key:!0}),Gb="/workspace/schematic/symbol/retrieve",Kb="/workspace/schematic/symbol/create",Jb="/workspace/schematic/symbol/rename",Xb="/workspace/schematic/symbol/delete",Qb="/workspace/schematic/symbol/retrieve_group",ev=s.z.object({symbols:_l.array(),parent:M}),tv=s.z.object({key:zt,name:s.z.string()}),rv=s.z.object({keys:zt.array()}),nv=s.z.object({keys:zt.array().optional(),searchTerm:s.z.string().optional(),offset:s.z.number().optional(),limit:s.z.number().optional()}),sv=s.z.object({key:zt}).transform(({key:t})=>({keys:[t]})),av=s.z.union([sv,nv]),iv=s.z.object({symbols:F(on)}),ov=s.z.object({symbols:on.array()}),Ha=s.z.object({}),lv=s.z.object({}),cv=s.z.object({group:Kr}),uv="sy_schematic_symbol_set",hv="sy_schematic_symbol_delete";let Vl=class{client;constructor(t){this.client=t}async create(t){const e="symbols"in t,r=e?t.symbols:[t],n=await m(this.client,Kb,{symbols:r,parent:t.parent},ev,ov);return e?n.symbols:n.symbols[0]}async rename(t,e){await m(this.client,Jb,{key:t,name:e},tv,Ha)}async retrieve(t){const e="key"in t,r=await m(this.client,Gb,t,av,iv);return Xe("Schematic Symbol",t,r.symbols,e),e?r.symbols[0]:r.symbols}async delete(t){await m(this.client,Xb,{keys:O.toArray(t)},rv,Ha)}async retrieveGroup(){return(await m(this.client,Qb,{},lv,cv)).group}};const dv=t=>({type:"schematic_symbol",key:t}),fv=Object.freeze(Object.defineProperty({__proto__:null,Client:Vl,DELETE_CHANNEL_NAME:hv,SET_CHANNEL_NAME:uv,handleZ:Yl,keyZ:zt,newZ:_l,ontologyID:dv,regionZ:Fl,specZ:Hl,stateZ:ql,symbolZ:on},Symbol.toStringTag,{value:"Module"})),pv="/workspace/schematic/retrieve",yv="/workspace/schematic/create",gv="/workspace/schematic/rename",mv="/workspace/schematic/set-data",wv="/workspace/schematic/delete",bv="/workspace/schematic/copy",vv=s.z.object({keys:et.array()}),Tv=s.z.object({workspace:be,schematics:Zl.array()}),Ov=s.z.object({key:et,name:s.z.string()}),zv=s.z.object({key:et,data:s.z.string()}),Sv=s.z.object({keys:et.array()}),Ev=s.z.object({key:et,name:s.z.string(),snapshot:s.z.boolean()}),Nv=s.z.object({schematics:F(Xs)}),xv=s.z.object({schematics:Xs.array()}),Av=s.z.object({schematic:an}),xn=s.z.object({});let Wl=class{symbols;client;constructor(t){this.client=t,this.symbols=new Vl(t)}async create(t,e){const r=Array.isArray(e),n=await m(this.client,yv,{workspace:t,schematics:O.toArray(e)},Tv,xv);return r?n.schematics:n.schematics[0]}async rename(t,e){await m(this.client,gv,{key:t,name:e},Ov,xn)}async setData(t,e){await m(this.client,mv,{key:t,data:JSON.stringify(e)},zv,xn)}async retrieve(t){const e=Array.isArray(t),r=await m(this.client,pv,{keys:O.toArray(t)},vv,Nv);return e?r.schematics:r.schematics[0]}async delete(t){await m(this.client,wv,{keys:O.toArray(t)},Sv,xn)}async copy(t,e,r){return(await m(this.client,bv,{key:t,name:e,snapshot:r},Ev,Av)).schematic}};const kv=t=>({type:"schematic",key:t}),Cv=Object.freeze(Object.defineProperty({__proto__:null,Client:Wl,keyZ:et,newZ:Zl,ontologyID:kv,remoteZ:Xs,schematicZ:an,symbol:fv},Symbol.toStringTag,{value:"Module"})),fr=s.z.uuid(),Gl=s.z.object({key:fr,name:s.z.string(),data:ze.unknownZ.or(s.z.string().transform(Se))}),Iv=Gl.partial({key:!0}).transform(t=>({...t,data:JSON.stringify(t.data)})),Kl=Gl.extend({data:s.z.string().transform(Se)}),jv="/workspace/table/retrieve",Rv="/workspace/table/create",Mv="/workspace/table/rename",Uv="/workspace/table/set-data",Lv="/workspace/table/delete",Pv=s.z.object({keys:fr.array()}),Dv=s.z.object({workspace:be,tables:Iv.array()}),$v=s.z.object({key:fr,name:s.z.string()}),Bv=s.z.object({key:fr,data:s.z.string()}),Zv=s.z.object({keys:fr.array()}),Fv=s.z.object({tables:Kl.array()}),qv=s.z.object({tables:Kl.array()}),An=s.z.object({});let Yv=class{client;constructor(t){this.client=t}async create(t,e){const r=Array.isArray(e),n=await m(this.client,Rv,{workspace:t,tables:O.toArray(e)},Dv,qv);return r?n.tables:n.tables[0]}async rename(t,e){await m(this.client,Mv,{key:t,name:e},$v,An)}async setData(t,e){await m(this.client,Uv,{key:t,data:JSON.stringify(e)},Bv,An)}async retrieve(t){const e=Array.isArray(t),r=await m(this.client,jv,{keys:O.toArray(t)},Pv,Fv);return e?r.tables:r.tables[0]}async delete(t){await m(this.client,Lv,{keys:O.toArray(t)},Zv,An)}};const _a="/workspace/retrieve",Hv="/workspace/create",_v="/workspace/rename",Vv="/workspace/set-layout",Wv="/workspace/delete",Va=s.z.object({keys:be.array().optional(),searchTerm:s.z.string().optional(),author:Qe.optional(),offset:s.z.number().optional(),limit:s.z.number().optional()}),Gv=s.z.object({workspaces:$l.array()}),Kv=s.z.object({key:be,name:s.z.string()}),Jv=s.z.object({key:be,layout:s.z.string()}),Xv=s.z.object({keys:be.array()}),Wa=s.z.object({workspaces:F(sn)}),Qv=s.z.object({workspaces:Bl.array()}),kn=s.z.object({}),eT="sy_workspace_set",tT="sy_workspace_delete";class Jl{type="workspace";schematic;linePlot;log;table;client;constructor(e){this.client=e,this.schematic=new Wl(e),this.linePlot=new Rb(e),this.log=new Vb(e),this.table=new Yv(e)}async create(e){const r=Array.isArray(e),n=await m(this.client,Hv,{workspaces:O.toArray(e)},Gv,Qv);return r?n.workspaces:n.workspaces[0]}async rename(e,r){await m(this.client,_v,{key:e,name:r},Kv,kn)}async setLayout(e,r){await m(this.client,Vv,{key:e,layout:JSON.stringify(r)},Jv,kn)}async retrieve(e){let r;const n=typeof e!="string";typeof e=="string"||Array.isArray(e)?r={keys:O.toArray(e)}:r=e;const a=await m(this.client,_a,r,Va,Wa);return n?a.workspaces:a.workspaces[0]}async retrieveByAuthor(e){return(await m(this.client,_a,{author:e},Va,Wa)).workspaces}async delete(e){await m(this.client,Wv,{keys:O.toArray(e)},Xv,kn)}}const rT=t=>({type:"workspace",key:t}),nT=Object.freeze(Object.defineProperty({__proto__:null,Client:Jl,DELETE_CHANNEL_NAME:tT,SET_CHANNEL_NAME:eT,keyZ:be,newZ:$l,ontologyID:rT,remoteZ:Bl,workspaceZ:sn},Symbol.toStringTag,{value:"Module"})),Xl=s.z.object({host:s.z.string({error:"Host is required"}).min(1,"Host is required"),port:s.z.number({error:"Port is required"}).or(s.z.string({error:"Port is required"})),username:s.z.string().min(1,"Username is required"),password:s.z.string().min(1,"Password is required"),connectivityPollFrequency:S.z.default(S.seconds(30)),secure:s.z.boolean().optional().default(!1),name:s.z.string().optional(),retry:To.breakerConfigZ.optional()});class sT extends ul{createdAt;props;ranges;channels;auth;user;access;connectivity;ontology;workspaces;labels;hardware;control;static connectivity=Lr;transport;clientVersion="0.45.0";constructor(e){const r=Xl.parse(e),{host:n,port:a,username:i,password:o,connectivityPollFrequency:l,secure:c,retry:u}=r,h=new bb(new Lt({host:n,port:Number(a)}),u,c);h.use(Bp);let f;i!=null&&o!=null&&(f=new jg(h.unary,{username:i,password:o}),h.use(f.middleware()));const d=new Bs(new or(h.unary)),z=new Jo(h.unary,d);super(h.stream,h.unary,d),this.createdAt=E.now(),this.props=r,this.auth=f,this.transport=h,this.channels=new Wo(this,d,h.unary,z),this.connectivity=new Lr(h.unary,l,this.clientVersion,r.name),this.control=new fl(this),this.ontology=new Fo(h.unary,this);const N=new Dl(this.transport.unary);this.labels=new jl(this.transport.unary),this.ranges=new Ll(this,N,this.transport.unary,d,this.labels,this.ontology),this.access=new jy(this.transport.unary),this.user=new Sg(this.transport.unary),this.workspaces=new Jl(this.transport.unary);const I=new bl(this.transport.unary),B=new Nl(this.transport.unary,this,this.ontology,this.ranges),R=new vl(this.transport.unary,B);this.hardware=new pm(B,R,I)}get key(){return this.createdAt.valueOf().toString()}close(){this.connectivity.stopChecking()}}S.seconds(1);const aT=t=>Array.isArray(t)?t:t==null?[]:[t],iT=Object.freeze(Object.defineProperty({__proto__:null,toArray:aT},Symbol.toStringTag,{value:"Module"})),Cn=t=>t!=null&&typeof t=="object"&&!Array.isArray(t),oT=(t,e)=>{let r=null;return e===0?t:(...n)=>{r!==null&&(clearTimeout(r),r=null),r=setTimeout(()=>t(...n),e)}},lT=(t,e)=>{let r=null;return e===0?t:(...n)=>{r===null&&(r=setTimeout(()=>{t(...n),r=null},e))}},Ql=(t,e,r=".")=>{const n=t.split(r);return n.map((a,i)=>{const o=e(a,i,n);return o==null?null:typeof o=="string"?o:o.join(r)}).filter(a=>a!=null).join(r)},Qs=(t,e)=>{if(!Array.isArray(t))return t[e];const r=t[e];if(r!=null||t.length==0)return r;const n=t[0];if(typeof n=="object"&&"key"in n)return t.find(a=>a.key===e)},cT=(t,e)=>{const r=t.split(".");return r.forEach((n,a)=>{e=Qs(e,n),e!=null&&typeof e=="object"&&"key"in e&&(r[a]=e.key)}),r.join(".")},ea=(t,e,r={optional:!1,separator:"."})=>{r.separator??=".";const{optional:n,getter:a=Qs}=r,i=e.split(r.separator);if(i.length===1&&i[0]==="")return t;let o=t;for(const l of i){const c=a(o,l);if(c==null){if(n)return null;throw new Error(`Path ${e} does not exist. ${l} is null`)}o=c}return o},uT=t=>{for(const e of t)if(isNaN(parseInt(e)))return null;return parseInt(t)},hT=(t,e,r)=>{const n=e.split(".");let a=t;for(let i=0;i<n.length-1;i++){const o=n[i],l=Qs(a,o);if(l==null)throw new Error(`Path ${e} does not exist. ${o} is null`);a=l}try{if(!Array.isArray(a)){a[n[n.length-1]]=r;return}if(a.length===0)return;const i=uT(n[n.length-1]);if(i==null){const o=a[0];if(typeof o=="object"&&"key"in o){const l=a.findIndex(c=>c.key===n[n.length-1]);if(l!==-1){a[l]=r;return}}return}a[i]=r}catch(i){throw console.error("failed to set value",r,"at path",e,"on object",t),i}},dT=(t,e)=>{const r=e.split(".");let n=t;for(let a=0;a<r.length-1;a++){const i=r[a];if(n[i]==null)return;n=n[i]}if(Array.isArray(n)){const a=parseInt(r[r.length-1]);if(isNaN(a))return;n.splice(a,1);return}delete n[r[r.length-1]]},fT=(t,e)=>{const r=t.split(".");return e<0?r[r.length+e]:r[e]},pT=(t,e)=>{try{return ea(t,e),!0}catch{return!1}},yT=(t,e)=>{if(e.length===0)return!0;const r=t.split("."),n=e.split(".");if(n.length>r.length)return!1;for(let a=0;a<n.length;a++){const i=r[a],o=n[a];if(o!=="*"&&i!==o)return!1}return!0},gT=t=>{try{return structuredClone(t)}catch{return console.warn("Failed to deep copy object, falling back to JSON.parse(JSON.stringify)",t),console.trace(),JSON.parse(JSON.stringify(t))}},mT=(t,...e)=>(e.forEach(r=>{let n=t;const a=r.split(".");a.forEach((i,o)=>{typeof n!="object"||n===null||(o===a.length-1?delete n[i]:i in n&&(n=n[i]))})}),t),wT=(t,e,r="")=>{const n={},a=(i,o,l)=>{if(typeof i!=typeof o||i===null||o===null){n[l]=[i,o];return}if(typeof i=="object"&&typeof o=="object")if(Array.isArray(i)&&Array.isArray(o)){if(i.length!==o.length){n[l]=[i,o];return}for(let c=0;c<i.length;c++)a(i[c],o[c],`${l}[${c}]`)}else new Set([...Object.keys(i),...Object.keys(o)]).forEach(c=>{a(i[c],o[c],l!==""?`${l}.${c}`:c)});else i!==o&&(n[l]=[i,o])};return a(t,e,r),n},as=(t,e)=>{const r=Array.isArray(t),n=Array.isArray(e);if(r!==n)return!1;if(r&&n){const o=t,l=e;if(o.length!==l.length)return!1;for(let c=0;c<o.length;c++)if(!as(o[c],l[c]))return!1;return!0}if(t==null||e==null||typeof t!="object"||typeof e!="object")return t===e;if("equals"in t)return t.equals(e);const a=Object.keys(t),i=Object.keys(e);if(a.length!==i.length)return!1;for(const o of a){const l=t[o],c=e[o];if(typeof l=="object"&&typeof c=="object"){if(!as(l,c))return!1}else if(l!==c)return!1}return!0},ec=(t,e)=>{if(typeof t!="object"||t==null)return t===e;const r=Object.keys(t),n=Object.keys(e);if(n.length>r.length)return!1;for(const a of n){const i=t[a],o=e[a];if(typeof i=="object"&&typeof o=="object"){if(!ec(i,o))return!1}else if(i!==o)return!1}return!0},is=(t,...e)=>{if(e.length===0)return t;const r=e.shift();if(Cn(t)&&Cn(r))for(const n in r)try{Cn(r[n])?(n in t||Object.assign(t,{[n]:{}}),is(t[n],r[n])):Object.assign(t,{[n]:r[n]})}catch(a){throw a instanceof TypeError?new TypeError(`.${n}: ${a.message}`):a}return is(t,...e)},bT=(t,e,r)=>{const n=(a,i,o)=>{if(o.def?.type==="union")return o.def.options.reduce((l,c)=>n(l,i,c),a);if(o.def?.type==="intersection"){const l=n(a,i,o.def.left);return n(l,i,o.def.right)}for(const l in i){const c=i[l];let u=o?.shape;if(u!=null)for(;u!=null;){if(u[l]!=null){const h=u[l].safeParse(c);if(h.success){a[l]=h.data;break}}u=u.def?.shape}typeof c=="object"&&!Array.isArray(c)&&c!==null&&o&&o.shape&&o.shape[l]&&(a[l]||={},n(a[l],c,o.shape[l]))}return a};return n({...t},e,r)},tc=Object.freeze(Object.defineProperty({__proto__:null,copy:gT,deleteD:mT,difference:wT,element:fT,equal:as,get:ea,has:pT,override:is,overrideValidItems:bT,partialEqual:ec,pathsMatch:yT,remove:dT,resolvePath:cT,set:hT,transformPath:Ql},Symbol.toStringTag,{value:"Module"}));let vT=class{sender;handlers;constructor(e){this.sender=e,this.handlers=new Map}handle({data:e}){const r=this.handlers.get(e.type)?.handler;r==null?console.warn(`No handler for ${e.type}`):r(e.payload)}route(e){const r=TT(e,this.sender),n=new OT(r);return this.handlers.set(e,n),n}};const TT=(t,e)=>(r,n)=>e({type:t,payload:r},n);class OT{_send;handler;constructor(e){this._send=e,this.handler=null}send(e,r=[]){this._send(e,r)}handle(e){this.handler=e}}const os=(t,e,r="")=>{try{return t.parse(e)}catch(n){if(n instanceof s.z.ZodError){const a=n.issues.map(i=>i.path.length===0?i.message:`${i.path.join(".")}: ${i.message}`);throw new Error(`${r} - ${a.join(`
45
- `)}`)}else throw n}},rc=t=>typeof t=="function",ta=(t,e)=>rc(t)?t(e):t,ln=t=>nc(t)?t():t,nc=t=>typeof t=="function",sc=({initial:t,value:e,onChange:r})=>{const[n,a]=ws.useState(e??t);return e!=null&&r!=null?[e,r]:[n,a]},ac=({initial:t,value:e,onChange:r})=>{const[n,a]=ws.useState(ln(e??t));return e!=null&&r!=null?[e,r]:[n,a]},zT=(t,e)=>{const[r,n]=ws.useState(()=>{const a=localStorage.getItem(e);return a==null?ln(t):JSON.parse(a)});return[r,a=>{n(a),localStorage.setItem(e,JSON.stringify(a))}]},ST=Object.freeze(Object.defineProperty({__proto__:null,executeInitialSetter:ln,executeSetter:ta,isInitialSetter:nc,isSetter:rc,usePassthrough:sc,usePersisted:zT,usePurePassthrough:ac},Symbol.toStringTag,{value:"Module"}));let Ga=null;const ET=()=>(Ga??=document.createElement("canvas"),Ga),NT=(t,e,r)=>{if(p.S.RUNTIME==="node")return{width:0,height:0};r??=ET().getContext("2d"),r.font=e;const n=r.measureText(t);return cn(n)},cn=t=>({width:Math.trunc(Math.abs(t.actualBoundingBoxLeft)+Math.abs(t.actualBoundingBoxRight)),height:Math.trunc(Math.abs(t.actualBoundingBoxAscent)+Math.abs(t.actualBoundingBoxDescent))}),Dt=["h1","h2","h3","h4","h5","p","small"],xT=s.z.enum(Dt),AT=t=>{const e=Dt.indexOf(t);return e===-1||e===Dt.length-1?t:Dt[e+1]},kT=s.z.union([s.z.number(),s.z.enum(["normal","bold","bolder","lighter"])]),je=s.z.object({size:s.z.number(),weight:s.z.union([s.z.number(),s.z.string()]),lineHeight:s.z.number(),textTransform:s.z.string().optional()}),CT={tiny:"small",small:"small",medium:"p",large:"h5",huge:"h2"},IT={h1:"huge",h2:"huge",h3:"huge",h4:"large",h5:"small",p:"medium",small:"small"},jT=s.z.object({l0:p.fr.colorZ,l1:p.fr.colorZ,l2:p.fr.colorZ,l3:p.fr.colorZ,l4:p.fr.colorZ,l5:p.fr.colorZ,l6:p.fr.colorZ,l7:p.fr.colorZ,l8:p.fr.colorZ,l9:p.fr.colorZ,l10:p.fr.colorZ,l11:p.fr.colorZ}),re=(t,e)=>[t[0],t[1],e,t[3]],RT=s.z.object({m2:p.fr.colorZ,m1:p.fr.colorZ,z:p.fr.colorZ,p1:p.fr.colorZ,p2:p.fr.colorZ}),vr=RT.or(p.fr.colorZ.transform(t=>{const e=p.fr.hsla(t);return{m2:p.fr.fromHSLA(re(e,40)),m1:p.fr.fromHSLA(re(e,45)),z:t,p1:p.fr.fromHSLA(re(e,55)),p2:p.fr.fromHSLA(re(e,65))}})),ic=s.z.object({name:s.z.string(),key:s.z.string(),colors:s.z.object({border:p.fr.colorZ,primary:vr,gray:jT,error:vr,secondary:vr,warning:vr,palettes:s.z.record(s.z.string(),p.fr.paletteZ),visualization:s.z.object({palettes:s.z.record(s.z.string(),s.z.array(p.fr.colorZ))}).optional().default({palettes:{}}),white:p.fr.colorZ,black:p.fr.colorZ,text:p.fr.colorZ,textInverted:p.fr.colorZ,textOnPrimary:p.fr.colorZ.optional().default(p.fr.ZERO),logo:s.z.string()}),sizes:s.z.object({base:s.z.number(),border:s.z.object({radius:s.z.number(),width:s.z.number(),thickWidth:s.z.number()}),schematic:s.z.object({elementStrokeWidth:s.z.number()})}),typography:s.z.object({family:s.z.string(),codeFamily:s.z.string(),h1:je,h2:je,h3:je,h4:je,h5:je,p:je,small:je})}).transform(t=>((t.colors.textOnPrimary==null||p.fr.isZero(t.colors.textOnPrimary))&&(t.colors.textOnPrimary=p.fr.pickByContrast(t.colors.primary.z,t.colors.text,t.colors.textInverted)),t)),MT="'Inter Variable', sans-serif",UT="'Geist Mono', monospace",LT=6,Nt=[357,91,55,1],xt=[48,90,55,1],PT=["#FEFEFE","#FAFAFA","#F2F2F2","#ECECEC","#E4E4E4","#D1D1D1","#BCBCBC","#ACACAC","#8F8F8F","#4F4F4F","#292929","#050505"],At=Object.fromEntries(PT.map((t,e)=>[`l${e}`,t])),DT=()=>typeof window>"u"?!1:window.devicePixelRatio>1,$T=DT(),ls={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:At,border:At.l4,error:{m2:p.fr.fromHSLA(re(Nt,30)),m1:p.fr.fromHSLA(re(Nt,40)),z:p.fr.fromHSLA(Nt),p1:p.fr.fromHSLA(re(Nt,65)),p2:p.fr.fromHSLA(re(Nt,77))},warning:{m2:p.fr.fromHSLA(re(xt,30)),m1:p.fr.fromHSLA(re(xt,40)),z:p.fr.fromHSLA(xt),p1:p.fr.fromHSLA(re(xt,65)),p2:p.fr.fromHSLA(re(xt,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:At.l11,textInverted:At.l0,textOnPrimary:At.l0},sizes:{base:LT,border:{radius:3,width:$T?.5:1,thickWidth:1},schematic:{elementStrokeWidth:2}},typography:{family:MT,codeFamily:UT,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}}},oc=Object.freeze({...ls,key:"synnaxLight",name:"Synnax Light"}),BT=["#020202","#080808","#151515","#242424","#2F2F2F","#3B3B3B","#4A4A4A","#5C5C5C","#767676","#959595","#dadada","#FAFAFA"],kt=Object.fromEntries(BT.map((t,e)=>[`l${e}`,t])),lc=Object.freeze({...ls,key:"synnaxDark",name:"Synnax Dark",colors:{...ls.colors,gray:kt,logo:"var(--pluto-text-color)",border:kt.l3,text:kt.l11,textInverted:kt.l0,textOnPrimary:kt.l11}}),ZT={synnaxDark:lc,synnaxLight:oc},cc=["tiny","small","medium","large","huge"],uc=s.z.enum(cc),FT=t=>uc.safeParse(t).success;class yt{_noop=!1;key;path;serviceName;constructor(e,r,n="",a=!1){this.key=e,this.path=r,this.serviceName=n,this._noop=a}child(e){return new yt(e,this.extendPath(e),this.serviceName,this.noop)}extendPath(e){return`${this.path}.${e}`}get noop(){return this._noop}static NOOP=new yt("","","")}const cs=["debug","info","warn","error"],hc=t=>{const e=cs.indexOf(t);return({level:r})=>cs.indexOf(r)>=e},qT=t=>{const{include:e,exclude:r}=t;return({path:n})=>!(e!=null&&!e.some(a=>n.startsWith(a))||r!=null&&r.some(a=>n.startsWith(a)))};class gt{meta=yt.NOOP;filters;constructor(e={}){const{filters:r=[]}=e;this.filters=r}filter(e){return!this.meta.noop&&this.filters.every(r=>r({key:this.meta.key,path:this.meta.path,level:e}))}child(e){const r=new gt({filters:this.filters});return r.meta=e,r}debug(e,r,n=!1){!this.filter("debug")&&!n||(r==null?console.log("%cDEBUG","color: #8c00f0;",this.meta.path,e):console.log("%cDEBUG","color: #8c00f0;",this.meta.path,e,Tr(r)))}info(e,r,n=!1){!this.filter("info")&&!n||(r==null?console.log("%cINFO","color: #005eff;",this.meta.path,e):console.log("%cINFO","color: #005eff;",this.meta.path,e,Tr(r)))}warn(e,r,n=!1){!this.filter("warn")&&!n||(r==null?console.warn("WARN",this.meta.path,e):console.warn("WARN",this.meta.path,e,Tr(r)))}error(e,r,n=!1){!this.filter("error")&&!n||(r==null?console.error("ERROR",this.meta.path,e):console.error("ERROR",this.meta.path,e,Tr(r)))}static NOOP=new gt}const Tr=t=>typeof t=="function"?t():t;var YT=typeof globalThis=="object"?globalThis:typeof self=="object"?self:typeof window=="object"?window:typeof global=="object"?global:{},He="1.9.0",Ka=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function HT(t){var e=new Set([t]),r=new Set,n=t.match(Ka);if(!n)return function(){return!1};var a={major:+n[1],minor:+n[2],patch:+n[3],prerelease:n[4]};if(a.prerelease!=null)return function(l){return l===t};function i(l){return r.add(l),!1}function o(l){return e.add(l),!0}return function(l){if(e.has(l))return!0;if(r.has(l))return!1;var c=l.match(Ka);if(!c)return i(l);var u={major:+c[1],minor:+c[2],patch:+c[3],prerelease:c[4]};return u.prerelease!=null||a.major!==u.major?i(l):a.major===0?a.minor===u.minor&&a.patch<=u.patch?o(l):i(l):a.minor<=u.minor?o(l):i(l)}}var _T=HT(He),VT=He.split(".")[0],Vt=Symbol.for("opentelemetry.js.api."+VT),Wt=YT;function ra(t,e,r,n){var a;n===void 0&&(n=!1);var i=Wt[Vt]=(a=Wt[Vt])!==null&&a!==void 0?a:{version:He};if(!n&&i[t]){var o=new Error("@opentelemetry/api: Attempted duplicate registration of API: "+t);return r.error(o.stack||o.message),!1}if(i.version!==He){var o=new Error("@opentelemetry/api: Registration of version v"+i.version+" for "+t+" does not match previously registered API v"+He);return r.error(o.stack||o.message),!1}return i[t]=e,r.debug("@opentelemetry/api: Registered a global for "+t+" v"+He+"."),!0}function Gt(t){var e,r,n=(e=Wt[Vt])===null||e===void 0?void 0:e.version;if(!(!n||!_T(n)))return(r=Wt[Vt])===null||r===void 0?void 0:r[t]}function na(t,e){e.debug("@opentelemetry/api: Unregistering a global for "+t+" v"+He+".");var r=Wt[Vt];r&&delete r[t]}var WT=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),a,i=[],o;try{for(;(e===void 0||e-- >0)&&!(a=n.next()).done;)i.push(a.value)}catch(l){o={error:l}}finally{try{a&&!a.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return i},GT=function(t,e,r){if(arguments.length===2)for(var n=0,a=e.length,i;n<a;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))},KT=function(){function t(e){this._namespace=e.namespace||"DiagComponentLogger"}return t.prototype.debug=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Ct("debug",this._namespace,e)},t.prototype.error=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Ct("error",this._namespace,e)},t.prototype.info=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Ct("info",this._namespace,e)},t.prototype.warn=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Ct("warn",this._namespace,e)},t.prototype.verbose=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Ct("verbose",this._namespace,e)},t}();function Ct(t,e,r){var n=Gt("diag");if(n)return r.unshift(e),n[t].apply(n,GT([],WT(r),!1))}var X;(function(t){t[t.NONE=0]="NONE",t[t.ERROR=30]="ERROR",t[t.WARN=50]="WARN",t[t.INFO=60]="INFO",t[t.DEBUG=70]="DEBUG",t[t.VERBOSE=80]="VERBOSE",t[t.ALL=9999]="ALL"})(X||(X={}));function JT(t,e){t<X.NONE?t=X.NONE:t>X.ALL&&(t=X.ALL),e=e||{};function r(n,a){var i=e[n];return typeof i=="function"&&t>=a?i.bind(e):function(){}}return{error:r("error",X.ERROR),warn:r("warn",X.WARN),info:r("info",X.INFO),debug:r("debug",X.DEBUG),verbose:r("verbose",X.VERBOSE)}}var XT=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),a,i=[],o;try{for(;(e===void 0||e-- >0)&&!(a=n.next()).done;)i.push(a.value)}catch(l){o={error:l}}finally{try{a&&!a.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return i},QT=function(t,e,r){if(arguments.length===2)for(var n=0,a=e.length,i;n<a;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))},eO="diag",Kt=function(){function t(){function e(a){return function(){for(var i=[],o=0;o<arguments.length;o++)i[o]=arguments[o];var l=Gt("diag");if(l)return l[a].apply(l,QT([],XT(i),!1))}}var r=this,n=function(a,i){var o,l,c;if(i===void 0&&(i={logLevel:X.INFO}),a===r){var u=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return r.error((o=u.stack)!==null&&o!==void 0?o:u.message),!1}typeof i=="number"&&(i={logLevel:i});var h=Gt("diag"),f=JT((l=i.logLevel)!==null&&l!==void 0?l:X.INFO,a);if(h&&!i.suppressOverrideMessage){var d=(c=new Error().stack)!==null&&c!==void 0?c:"<failed to generate stacktrace>";h.warn("Current logger will be overwritten from "+d),f.warn("Current logger will overwrite one already registered from "+d)}return ra("diag",f,r,!0)};r.setLogger=n,r.disable=function(){na(eO,r)},r.createComponentLogger=function(a){return new KT(a)},r.verbose=e("verbose"),r.debug=e("debug"),r.info=e("info"),r.warn=e("warn"),r.error=e("error")}return t.instance=function(){return this._instance||(this._instance=new t),this._instance},t}(),tO=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),a,i=[],o;try{for(;(e===void 0||e-- >0)&&!(a=n.next()).done;)i.push(a.value)}catch(l){o={error:l}}finally{try{a&&!a.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return i},rO=function(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},nO=function(){function t(e){this._entries=e?new Map(e):new Map}return t.prototype.getEntry=function(e){var r=this._entries.get(e);if(r)return Object.assign({},r)},t.prototype.getAllEntries=function(){return Array.from(this._entries.entries()).map(function(e){var r=tO(e,2),n=r[0],a=r[1];return[n,a]})},t.prototype.setEntry=function(e,r){var n=new t(this._entries);return n._entries.set(e,r),n},t.prototype.removeEntry=function(e){var r=new t(this._entries);return r._entries.delete(e),r},t.prototype.removeEntries=function(){for(var e,r,n=[],a=0;a<arguments.length;a++)n[a]=arguments[a];var i=new t(this._entries);try{for(var o=rO(n),l=o.next();!l.done;l=o.next()){var c=l.value;i._entries.delete(c)}}catch(u){e={error:u}}finally{try{l&&!l.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}return i},t.prototype.clear=function(){return new t},t}();Kt.instance();function sO(t){return t===void 0&&(t={}),new nO(new Map(Object.entries(t)))}function aO(t){return Symbol.for(t)}var iO=function(){function t(e){var r=this;r._currentContext=e?new Map(e):new Map,r.getValue=function(n){return r._currentContext.get(n)},r.setValue=function(n,a){var i=new t(r._currentContext);return i._currentContext.set(n,a),i},r.deleteValue=function(n){var a=new t(r._currentContext);return a._currentContext.delete(n),a}}return t}(),oO=new iO,lO={get:function(t,e){if(t!=null)return t[e]},keys:function(t){return t==null?[]:Object.keys(t)}},cO={set:function(t,e,r){t!=null&&(t[e]=r)}},uO=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),a,i=[],o;try{for(;(e===void 0||e-- >0)&&!(a=n.next()).done;)i.push(a.value)}catch(l){o={error:l}}finally{try{a&&!a.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return i},hO=function(t,e,r){if(arguments.length===2)for(var n=0,a=e.length,i;n<a;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))},dO=function(){function t(){}return t.prototype.active=function(){return oO},t.prototype.with=function(e,r,n){for(var a=[],i=3;i<arguments.length;i++)a[i-3]=arguments[i];return r.call.apply(r,hO([n],uO(a),!1))},t.prototype.bind=function(e,r){return r},t.prototype.enable=function(){return this},t.prototype.disable=function(){return this},t}(),fO=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),a,i=[],o;try{for(;(e===void 0||e-- >0)&&!(a=n.next()).done;)i.push(a.value)}catch(l){o={error:l}}finally{try{a&&!a.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return i},pO=function(t,e,r){if(arguments.length===2)for(var n=0,a=e.length,i;n<a;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))},In="context",yO=new dO,dc=function(){function t(){}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalContextManager=function(e){return ra(In,e,Kt.instance())},t.prototype.active=function(){return this._getContextManager().active()},t.prototype.with=function(e,r,n){for(var a,i=[],o=3;o<arguments.length;o++)i[o-3]=arguments[o];return(a=this._getContextManager()).with.apply(a,pO([e,r,n],fO(i),!1))},t.prototype.bind=function(e,r){return this._getContextManager().bind(e,r)},t.prototype._getContextManager=function(){return Gt(In)||yO},t.prototype.disable=function(){this._getContextManager().disable(),na(In,Kt.instance())},t}(),us;(function(t){t[t.UNSET=0]="UNSET",t[t.OK=1]="OK",t[t.ERROR=2]="ERROR"})(us||(us={}));var gO=dc.getInstance(),mO=function(){function t(){}return t.prototype.inject=function(e,r){},t.prototype.extract=function(e,r){return e},t.prototype.fields=function(){return[]},t}(),sa=aO("OpenTelemetry Baggage Key");function fc(t){return t.getValue(sa)||void 0}function wO(){return fc(dc.getInstance().active())}function bO(t,e){return t.setValue(sa,e)}function vO(t){return t.deleteValue(sa)}var jn="propagation",TO=new mO,OO=function(){function t(){this.createBaggage=sO,this.getBaggage=fc,this.getActiveBaggage=wO,this.setBaggage=bO,this.deleteBaggage=vO}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalPropagator=function(e){return ra(jn,e,Kt.instance())},t.prototype.inject=function(e,r,n){return n===void 0&&(n=cO),this._getGlobalPropagator().inject(e,r,n)},t.prototype.extract=function(e,r,n){return n===void 0&&(n=lO),this._getGlobalPropagator().extract(e,r,n)},t.prototype.fields=function(){return this._getGlobalPropagator().fields()},t.prototype.disable=function(){na(jn,Kt.instance())},t.prototype._getGlobalPropagator=function(){return Gt(jn)||TO},t}(),zO=OO.getInstance();const Ja=["bench","debug","prod"],SO=t=>e=>Ja.indexOf(e)>=Ja.indexOf(t);class Jt{meta=yt.NOOP;otelTracer;filter;constructor(e,r=SO("debug")){this.otelTracer=e,this.filter=r}child(e){const r=new Jt(this.otelTracer,this.filter);return r.meta=e,r}debug(e,r){return this.trace(e,"debug",r)}bench(e,r){return this.trace(e,"bench",r)}prod(e,r){return this.trace(e,"prod",r)}trace(e,r,n){const a=this.meta.noop||!this.filter(r)||this.otelTracer==null;if(n==null){if(a)return()=>{};const i=new hs(e,this.otelTracer.startSpan(e));return i.start(),()=>i.end()}return a?n(new pc(e)):this.otelTracer.startActiveSpan(e,i=>{const o=new hs(e,i);return n(o)})}propagate(e){if(this.meta.noop)return;const r=gO.active();zO.inject(r,e,{set:(n,a,i)=>{n[a]=i}})}static NOOP=new Jt}class hs{key;otel;constructor(e,r){this.key=e,this.otel=r}set(e,r){this.otel.setAttribute(e,r)}recordError(e){e!=null&&(this.otel.recordException(e),this.otel.setStatus({code:us.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.otel.end()}catch(e){console.error(e)}}}class pc{key;constructor(e){this.key=e}set(){}recordError(e){}}class mt{meta;T;L;constructor({key:e="",serviceName:r="",logger:n=gt.NOOP,tracer:a=Jt.NOOP,noop:i=!1,__meta:o}){this.meta=o??new yt(e,e,r,i),this.T=a.child(this.meta),this.L=n.child(this.meta)}child(e){const r=this.meta.child(e);return new mt({__meta:r,tracer:this.T,logger:this.L})}static NOOP=new mt({noop:!0})}const EO=mt.NOOP,Ue=Object.freeze(Object.defineProperty({__proto__:null,Instrumentation:mt,LOG_LEVELS:cs,Logger:gt,NOOP:EO,NoopSpan:pc,Tracer:Jt,_Span:hs,logLevelKeyFiler:qT,logThresholdFilter:hc},Symbol.toStringTag,{value:"Module"})),Rn=(t,e)=>t instanceof Error?(t.message=`[${e}] - ${t.message}`,t):new Error(e??"unknown error",{cause:t});class un{type;key;sender;_internalState;_state;_prevState;_deleted=!1;parentCtxValues;childCtxValues;childCtxChangedKeys;instrumentation;schema=void 0;constructor({key:e,type:r,sender:n,instrumentation:a,parentCtxValues:i}){this.type=r,this.key=e,this.sender=n,this._internalState={},this.instrumentation=a.child(this.toString()),this.parentCtxValues=new Map,i?.forEach((o,l)=>this.parentCtxValues.set(l,o)),this.childCtxValues=new Map,this.childCtxChangedKeys=new Set}get _schema(){if(this.schema==null)throw new Z(`[AetherLeaf] - expected subclass to define component schema, but none was found.
46
- Make sure to define a property 'schema' on the class.`);return this.schema}setState(e){const r=ta(e,this.state);this._prevState=p.Sr(this._state),this._state=os(this._schema,r,`${this.toString()}`),this.sender.send({variant:"update",key:this.key,state:this._state})}get state(){if(this._state==null)throw new J(`[AetherLeaf] - state not defined in ${this.toString()}`);return this._state}get internal(){return this._internalState}get prevState(){if(this._prevState===void 0)throw new Error("prevState not defined");return this._prevState}get deleted(){return this._deleted}get ctx(){return{get:e=>{const r=this.parentCtxValues.get(e);if(r===void 0)throw new ft(`Context value for ${e} not found on ${this.toString()}`);return r},getOptional:e=>this.parentCtxValues.get(e),has:e=>this.parentCtxValues.has(e),wasSetPreviously:e=>this.childCtxValues.has(e),set:(e,r,n=!0)=>{this.childCtxValues.set(e,r),n&&this.childCtxChangedKeys.add(e)}}}toString(){return`${this.type}(${this.key})`}_updateState({path:e,state:r}){if(!this.deleted)try{const n=this.instrumentation.T.debug(`${this.toString()}:updateState`);this.validatePath(e);const a=os(this._schema,r,`${this.toString()}`);this._state!=null?this.instrumentation.L.debug("updating state",()=>({diff:tc.difference(this.state,a)})):this.instrumentation.L.debug("setting initial state",{state:r,path:e}),this._prevState=this._state??a,this._state=a,this.afterUpdate(this.ctx),n()}catch(n){throw Rn(n,`${this.toString()}.updateState`)}}_updateContext(e){try{const r=this.instrumentation.T.debug(`${this.toString()}:updateContext`);e.forEach((n,a)=>this.parentCtxValues.set(a,n)),this.afterUpdate(this.ctx),r()}catch(r){throw Rn(r,`${this.type}.${this.key}.updateContext`)}}_delete(e){try{const r=this.instrumentation.T.debug(`${this.toString()}:delete`);this.validatePath(e),this._deleted=!0,this.afterDelete(this.ctx),r()}catch(r){throw Rn(r,`[${this.toString()}:delete]`)}}afterUpdate(e){}afterDelete(e){}validatePath(e){if(e.length===0)throw new J(`[Leaf.setState] - ${this.toString()} received an empty path`);const r=e[e.length-1];if(e.length>1)throw new J(`[Leaf.setState] - ${this.toString()} received a subPath ${e.join(".")} but is a leaf`);if(r!==this.key)throw new J(`[Leaf.setState] - ${this.toString()} received a key ${r} but expected ${this.key}`)}}class St extends un{_children=new Map;get children(){return Array.from(this._children.values())}getChild(e){return this._children.get(e)??null}childrenOfType(...e){return this.children.filter(r=>e.includes(r.type))}_updateState(e){const{path:r,type:n,create:a}=e;if(this.deleted)return;const i=this.parsePath(r);if(i.length===0){if(this.childCtxChangedKeys.clear(),super._updateState(e),this.childCtxChangedKeys.size==0)return;this.updateChildContexts();return}const l=i[0],c=this.getChild(l);if(c!=null)return c._updateState({...e,path:i});if(i.length>1){const h=r.slice(0,r.indexOf(l)+1).join("."),f=r.join(".");throw new J(`Child of ${this.toString()} at path ${h} does not exist,
47
- but an extended path ${f} was provided. This means that the aether
48
- tree is attempting to create a new child of type ${n} (or nested children)
49
- on a child that does not exist.
50
-
51
- Children present: ${this.children.map(d=>`${d.type}:${d.key}`).join(".")}
52
-
53
- `)}const u=a(this.childCtx());u._updateState({...e,path:i}),this._children.set(l,u)}_updateContext(e){super._updateContext(e),this.updateChildContexts()}childCtx(){return{get:e=>this.childCtxValues.get(e)??this.parentCtxValues.get(e),forEach:e=>{this.childCtxValues.forEach((r,n)=>e(r,n,this.childCtxValues)),this.parentCtxValues.forEach((r,n)=>{this.childCtxValues.has(n)||e(r,n,this.parentCtxValues)})}}}updateChildContexts(){const e=this.childCtx();this.children.forEach(r=>r._updateContext(e))}_delete(e){const r=this.parsePath(e);if(r.length===0){for(const a of this.children)a._delete([a.key]);this._children.clear(),super._delete([this.key])}const n=this.getChild(r[0]);if(n!=null){if(r.length>1)return n._delete(r);this._children.delete(n.key),n._delete(r)}}parsePath(e,r){const[n,...a]=e;if(n==null)throw new Error(`Composite ${this.toString()} received an empty path${r!=null?` for ${r}`:""}`);if(n!==this.key)throw new J(`[Composite.getRequiredKey] - ${this.toString()} received a key ${n} but expected ${this.key}`);return a}}const NO=s.z.object({}),xO=()=>{throw new Error("should not call create")};class Le extends St{static TYPE="root";static KEY="root";comms;registry;schema=NO;constructor({comms:e,instrumentation:r=Ue.Instrumentation.NOOP,registry:n}){super({key:Le.KEY,type:Le.TYPE,sender:e,instrumentation:r,parentCtxValues:null}),this.comms=e,this.registry=n}static render(e){const r=new Le(e);return r._updateState({path:[Le.KEY],type:"",state:{},create:xO}),r.comms.handle(n=>{try{r.handle(n)}catch(a){const i={name:"unknown",message:JSON.stringify(a),stack:"unknown"};a instanceof Error&&(i.name=a.name,i.message=a.message,i.stack=a.stack),r.comms.send({variant:"error",error:i})}}),r}handle(e){const{path:r,variant:n,type:a}=e;if(n==="delete"){this._delete(r);return}const{state:i}=e;this._updateState({path:r,type:a,state:i,create:o=>{const l=r[r.length-1];return this.create({key:l,type:a,parentCtxValues:o})}})}create({key:e,type:r,parentCtxValues:n}){const a=this.registry[r];if(a==null)throw new J(`[Root.create] - ${r} not found in registry`);return new a({key:e,type:r,sender:this.comms,instrumentation:this.instrumentation,parentCtxValues:n})}}const yc=Le.render.bind(Le),AO=Object.freeze(Object.defineProperty({__proto__:null,Composite:St,Leaf:un,Root:Le,render:yc},Symbol.toStringTag,{value:"Module"})),kO=(t,e)=>Array.isArray(e)?e.some(r=>r.matches(t)):e?.matches(t)??!1,gc=(t,e,r)=>{const n=p.xr.fromException(t,e);return console.error(n),kO(t,r)?null:n},mc=(t,e,r,n)=>{if(typeof t=="function")return!0;const a=gc(t,r,n);return a!=null&&e(a),!1},wc=async(t,e,r,n)=>{try{const a=t();a!=null&&await a}catch(a){const i=gc(a,r,n);if(i!=null)return e(i)}},bc=t=>(e,r,n)=>{mc(e,t,r,n)&&wc(e,t,r,n)},vc=t=>async(e,r,n)=>{mc(e,t,r,n)&&await wc(e,t,r,n)},Tc=s.z.object({statuses:p.xr.statusZ().array()}),Dr="status.aggregator";class ds extends St{static TYPE="status.Aggregator";schema=Tc;afterUpdate(e){e.wasSetPreviously(Dr)||e.set(Dr,{add:this.add.bind(this),create:p.xr.create})}add(e){this.setState(r=>({...r,statuses:[...r.statuses,p.xr.create(e)]}))}}const hn=t=>t.get(Dr).add,CO=t=>{const e=t.getOptional(Dr);return e!=null?e.add:()=>{}},aa=t=>bc(hn(t)),IO=t=>vc(hn(t)),jO={[ds.TYPE]:ds},fs="pluto-theming-context",Oc=s.z.object({name:s.z.string(),url:s.z.string()}),RO=s.z.object({theme:ic,fontURLs:s.z.array(Oc)});let ps=class zc extends St{static TYPE="theming.Provider";static z=RO;schema=zc.z;afterUpdate(e){if(e.getOptional(fs)!=null&&this.state.theme.key===this.prevState.theme.key)return;e.set(fs,this.state.theme),aa(e)(async()=>{await this.loadFonts()},"failed to load theme fonts")}async loadFonts(){await Promise.all(this.state.fontURLs.map(async({name:e,url:r})=>{const n=new FontFace(e,`url(${r})`);try{await n.load(),self.fonts.add(n)}catch(a){console.error(a)}}))}};const MO=t=>t.get(fs),UO={[ps.TYPE]:ps},Sc=s.z.object({include:s.z.string().array().optional(),exclude:s.z.string().array().optional(),level:s.z.enum(Ue.LOG_LEVELS).optional().default("info")}),ys="alamos-provider";class gs extends St{static TYPE="alamos.Provider";schema=Sc;afterUpdate(e){if(e.getOptional(ys)!=null)return;const n=[],{include:a,exclude:i,level:o}=this.state;(a!=null||i!=null)&&n.push(Ue.logLevelKeyFiler({include:a,exclude:i})),o!=null&&n.push(Ue.logThresholdFilter(o)),n.length===0&&n.push(()=>!1),this.internal.ins=new Ue.Instrumentation({key:"aether",logger:new Ue.Logger({filters:n})}),e.set(ys,this.internal.ins)}}const Ec=(t,e)=>{const r=t.get(ys);if(r==null)throw new Error("No instrumentation provider");return e==null?r:r.child(e)},LO={[gs.TYPE]:gs},Cr=(t,e)=>p.Ho.construct(p.Ho.left(t)-e.x,p.Ho.top(t)-e.y,p.Ho.width(t)+e.x*2,p.Ho.height(t)+e.y*2);class $r{scale_;wrapped;atlasRegistry;cachedFont=null;cachedFillStyle=null;cachedStrokeStyle=null;cachedLineWidth=null;cachedGlobalAlpha=null;cachedTextAlign=null;cachedTextBaseline=null;cachedLineCap=null;cachedLineJoin=null;cachedMiterLimit=null;dpr;constructor(e,r,n,a=p.C.XY.IDENTITY){this.wrapped=e,this.scale_=a,this.atlasRegistry=r,this.dpr=n}get fontStretch(){return this.wrapped.fontStretch}set fontStretch(e){this.wrapped.fontStretch=e}get fontVariantCaps(){return this.wrapped.fontVariantCaps}set fontVariantCaps(e){this.wrapped.fontVariantCaps=e}isContextLost(){return this.wrapped.isContextLost()}get wordSpacing(){return this.wrapped.wordSpacing}set wordSpacing(e){this.wrapped.wordSpacing=e}get letterSpacing(){return this.wrapped.letterSpacing}set letterSpacing(e){this.wrapped.letterSpacing=e}get textRendering(){return this.wrapped.textRendering}set textRendering(e){this.wrapped.textRendering=e}checkAtlasFillStyle(e=!1){return e&&typeof this.fillStyle=="string"?[!0,this.fillStyle]:(e&&console.warn("attempted to use a text atlas with a gradient fill style. This is not supported. Falling back to default canvas fill."),[!1,null])}reset(){this.wrapped.reset()}applyScale(e){return new $r(this,this.atlasRegistry,this.dpr,e)}get canvas(){return this.wrapped.canvas}get miterLimit(){return this.cachedMiterLimit??this.wrapped.miterLimit}set miterLimit(e){const r=this.scale_.x.dim(e);r!==this.cachedMiterLimit&&(this.cachedMiterLimit=r,this.wrapped.miterLimit=r)}get globalAlpha(){return this.cachedGlobalAlpha??this.wrapped.globalAlpha}set globalAlpha(e){e!==this.cachedGlobalAlpha&&(this.cachedGlobalAlpha=e,this.wrapped.globalAlpha=e)}get globalCompositeOperation(){return this.wrapped.globalCompositeOperation}set globalCompositeOperation(e){this.wrapped.globalCompositeOperation=e}get fillStyle(){return this.cachedFillStyle??this.wrapped.fillStyle}set fillStyle(e){e!==this.cachedFillStyle&&(this.cachedFillStyle=e,this.wrapped.fillStyle=e)}get strokeStyle(){return this.cachedStrokeStyle??this.wrapped.strokeStyle}set strokeStyle(e){e!==this.cachedStrokeStyle&&(this.cachedStrokeStyle=e,this.wrapped.strokeStyle=e)}drawImage(e,r,n,a,i,o,l,c,u){this.wrapped.drawImage(e,r,n,a,i,o!=null?this.scale_.x.pos(o):o,l!=null?this.scale_.y.pos(l):l,c!=null?this.scale_.x.dim(c):c,u!=null?this.scale_.y.dim(u):u)}beginPath(){this.wrapped.beginPath()}clip(e,r){this.wrapped.clip(e,r)}fill(e,r){if(e==null)return this.wrapped.fill();this.wrapped.fill(e,r)}isPointInPath(e,r,n,a){return this.wrapped.isPointInPath(e,r,n,a)}isPointInStroke(e,r,n){return this.wrapped.isPointInStroke(e,r,n)}stroke(e){if(e==null)return this.wrapped.stroke();this.wrapped.stroke(e)}createConicGradient(e,r,n){return this.wrapped.createConicGradient(e,r,n)}createLinearGradient(e,r,n,a){return this.wrapped.createLinearGradient(e,r,n,a)}createPattern(e,r){return this.wrapped.createPattern(e,r)}createRadialGradient(e,r,n,a,i,o){return this.wrapped.createRadialGradient(e,r,n,a,i,o)}get filter(){return this.wrapped.filter}set filter(e){this.wrapped.filter=e}createImageData(e,r,n){return this.wrapped.createImageData(e,r,n)}getImageData(e,r,n,a,i){return this.wrapped.getImageData(e,r,n,a,i)}putImageData(e,r,n,a,i,o,l){this.wrapped.putImageData(e,r,n,a,i,o,l)}get imageSmoothingEnabled(){return this.wrapped.imageSmoothingEnabled}set imageSmoothingEnabled(e){this.wrapped.imageSmoothingEnabled=e}get imageSmoothingQuality(){return this.wrapped.imageSmoothingQuality}set imageSmoothingQuality(e){this.wrapped.imageSmoothingQuality=e}arc(e,r,n,a,i,o){this.wrapped.arc(this.scale_.x.pos(e),this.scale_.y.pos(r),this.scale_.x.dim(n),a,i,o)}arcTo(e,r,n,a,i){this.wrapped.arcTo(this.scale_.x.pos(e),this.scale_.y.pos(r),this.scale_.x.pos(n),this.scale_.y.pos(a),this.scale_.x.dim(i))}bezierCurveTo(e,r,n,a,i,o){this.wrapped.bezierCurveTo(this.scale_.x.pos(e),this.scale_.y.pos(r),this.scale_.x.pos(n),this.scale_.y.pos(a),this.scale_.x.pos(i),this.scale_.y.pos(o))}closePath(){this.wrapped.closePath()}ellipse(e,r,n,a,i,o,l,c){this.wrapped.ellipse(this.scale_.x.pos(e),this.scale_.y.pos(r),this.scale_.x.dim(n),this.scale_.y.dim(a),i,o,l,c)}lineTo(e,r){this.wrapped.lineTo(this.scale_.x.pos(e),this.scale_.y.pos(r))}moveTo(e,r){this.wrapped.moveTo(this.scale_.x.pos(e),this.scale_.y.pos(r))}quadraticCurveTo(e,r,n,a){this.wrapped.quadraticCurveTo(this.scale_.x.pos(e),this.scale_.y.pos(r),this.scale_.x.pos(n),this.scale_.y.pos(a))}rect(e,r,n,a){this.wrapped.rect(this.scale_.x.pos(e),this.scale_.y.pos(r),this.scale_.x.dim(n),this.scale_.y.dim(a))}roundRect(e,r,n,a,i){this.wrapped.roundRect(this.scale_.x.pos(e),this.scale_.y.pos(r),this.scale_.x.dim(n),this.scale_.y.dim(a),typeof i=="number"?this.scale_.x.dim(i):i)}get lineCap(){return this.cachedLineCap??this.wrapped.lineCap}set lineCap(e){e!==this.cachedLineCap&&(this.cachedLineCap=e,this.wrapped.lineCap=e)}get lineDashOffset(){return this.wrapped.lineDashOffset}set lineDashOffset(e){this.wrapped.lineDashOffset=this.scale_.x.dim(e)}get lineJoin(){return this.cachedLineJoin??this.wrapped.lineJoin}set lineJoin(e){e!==this.cachedLineJoin&&(this.cachedLineJoin=e,this.wrapped.lineJoin=e)}get lineWidth(){return this.cachedLineWidth??this.wrapped.lineWidth}set lineWidth(e){const r=this.scale_.x.dim(e);r!==this.cachedLineWidth&&(this.cachedLineWidth=r,this.wrapped.lineWidth=r)}getLineDash(){return this.wrapped.getLineDash()}setLineDash(e){const r=Array.from(e).map(n=>this.scale_.x.dim(n));this.wrapped.setLineDash(r)}clearRect(e,r,n,a){this.wrapped.clearRect(e,r,n,a)}fillRect(e,r,n,a){this.wrapped.fillRect(this.scale_.x.pos(e),this.scale_.y.pos(r),this.scale_.x.dim(n),this.scale_.y.dim(a))}strokeRect(e,r,n,a){this.wrapped.strokeRect(this.scale_.x.pos(e),this.scale_.y.pos(r),this.scale_.x.dim(n),this.scale_.y.dim(a))}get shadowBlur(){return this.wrapped.shadowBlur}set shadowBlur(e){this.wrapped.shadowBlur=e}get shadowColor(){return this.wrapped.shadowColor}set shadowColor(e){this.wrapped.shadowColor=e}get shadowOffsetX(){return this.wrapped.shadowOffsetX}set shadowOffsetX(e){this.wrapped.shadowOffsetX=e}get shadowOffsetY(){return this.wrapped.shadowOffsetY}restore(){this.cachedFillStyle=null,this.cachedStrokeStyle=null,this.cachedLineWidth=null,this.cachedGlobalAlpha=null,this.cachedTextAlign=null,this.cachedTextBaseline=null,this.cachedLineCap=null,this.cachedLineJoin=null,this.cachedMiterLimit=null,this.cachedFont=null,this.wrapped.restore()}save(){this.wrapped.save()}fillText(e,r,n,a,i={}){const[o,l]=this.checkAtlasFillStyle(i.useAtlas);if(o){this.atlasRegistry.get({font:this.font,textColor:l}).fillText(this,e,r,n);return}this.wrapped.fillText(e,this.scale_.x.pos(r),this.scale_.y.pos(n),a!=null?this.scale_.x.dim(a):void 0)}measureText(e){return this.wrapped.measureText(e)}textDimensions(e,r={}){const[n,a]=this.checkAtlasFillStyle(r.useAtlas);return n?this.atlasRegistry.get({font:this.font,textColor:a}).measureText(e):cn(this.measureText(e))}strokeText(e,r,n,a){this.wrapped.strokeText(e,this.scale_.x.pos(r),this.scale_.y.pos(n),a!=null?this.scale_.x.dim(a):void 0)}get direction(){return this.wrapped.direction}set direction(e){this.wrapped.direction=e}get font(){return this.cachedFont!=null?this.cachedFont:this.wrapped.font}set font(e){e!==this.cachedFont&&(this.cachedFont=e,this.wrapped.font=this.cachedFont)}get fontKerning(){return this.wrapped.fontKerning}set fontKerning(e){this.wrapped.fontKerning=e}get textAlign(){return this.cachedTextAlign??this.wrapped.textAlign}set textAlign(e){e!==this.cachedTextAlign&&(this.cachedTextAlign=e,this.wrapped.textAlign=e)}get textBaseline(){return this.cachedTextBaseline??this.wrapped.textBaseline}set textBaseline(e){e!==this.cachedTextBaseline&&(this.cachedTextBaseline=e,this.wrapped.textBaseline=e)}getTransform(){return this.wrapped.getTransform()}resetTransform(){this.wrapped.resetTransform()}rotate(e){this.wrapped.rotate(e)}scale(e,r){this.wrapped.scale(e,r),this.dpr=e}scissor(e,r=p.K.ZERO){const n=new PO(this.scale_);return e=Cr(e,r),n.rect(...p.K.couple(p.Ho.topLeft(e)),...p._.couple(p.Ho.dims(e))),this.save(),this.clip(n.getPath()),()=>this.restore()}setTransform(e,r,n,a,i,o){this.wrapped.setTransform(e,r,n,a,i,o)}transform(e,r,n,a,i,o){this.wrapped.transform(e,r,n,a,i,o)}translate(e,r){this.wrapped.translate(e,r)}}class PO{scale_;path;constructor(e=p.C.XY.IDENTITY,r){this.scale_=e,r instanceof Path2D||typeof r=="string"?this.path=new Path2D(r):this.path=new Path2D}addPath(e,r){this.path.addPath(e,r)}arc(e,r,n,a,i,o){this.path.arc(this.scale_.x.pos(e),this.scale_.y.pos(r),this.scale_.x.dim(n),a,i,o)}arcTo(e,r,n,a,i){this.path.arcTo(this.scale_.x.pos(e),this.scale_.y.pos(r),this.scale_.x.pos(n),this.scale_.y.pos(a),this.scale_.x.dim(i))}bezierCurveTo(e,r,n,a,i,o){this.path.bezierCurveTo(this.scale_.x.pos(e),this.scale_.y.pos(r),this.scale_.x.pos(n),this.scale_.y.pos(a),this.scale_.x.pos(i),this.scale_.y.pos(o))}closePath(){this.path.closePath()}ellipse(e,r,n,a,i,o,l,c){this.path.ellipse(this.scale_.x.pos(e),this.scale_.y.pos(r),this.scale_.x.dim(n),this.scale_.y.dim(a),i,o,l,c)}lineTo(e,r){this.path.lineTo(this.scale_.x.pos(e),this.scale_.y.pos(r))}moveTo(e,r){this.path.moveTo(this.scale_.x.pos(e),this.scale_.y.pos(r))}quadraticCurveTo(e,r,n,a){this.path.quadraticCurveTo(this.scale_.x.pos(e),this.scale_.y.pos(r),this.scale_.x.pos(n),this.scale_.y.pos(a))}rect(e,r,n,a){this.path.rect(this.scale_.x.pos(e),this.scale_.y.pos(r),this.scale_.x.dim(n),this.scale_.y.dim(a))}roundRect(e,r,n,a,i){const o=this.scaleRadii(i);this.path.roundRect(this.scale_.x.pos(e),this.scale_.y.pos(r),this.scale_.x.dim(n),this.scale_.y.dim(a),o)}scaleRadii(e){return e==null?e:typeof e=="number"?this.scale_.x.dim(e):Array.isArray(e)?e.map(r=>this.scaleRadius(r)):this.scaleRadius(e)}scaleRadius(e){return typeof e=="number"?this.scale_.x.dim(e):{x:this.scale_.x.dim(e.x??0),y:this.scale_.y.dim(e.y??0)}}getPath(){return this.path}}const DO=`precision mediump float;
54
-
55
- void main(void) {
56
- gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
57
- }
58
- `,$O=`attribute vec4 a_position;
59
-
60
- void main(void) {
61
- gl_Position = a_position;
62
- }
63
- `,Xa=t=>new Error(`failed to compile webgl program: ${t}`),BO=new Error("null shader encountered");let Nc=class{renderCtx;prog;vertShader;fragShader;uniformLocCache=new Map;constructor(e,r,n){this.renderCtx=e;const a=e.gl.createProgram();if(a==null)throw Xa("failed to create program");this.prog=a,this.vertShader=r,this.fragShader=n,this.compile()}setAsActive(){return this.renderCtx.gl.useProgram(this.prog),()=>this.renderCtx.gl.useProgram(null)}uniformXY(e,r){this.renderCtx.gl.uniform2fv(this.getUniformLoc(e),p.K.couple(r))}uniformColor(e,r){this.renderCtx.gl.uniform4fv(this.getUniformLoc(e),p.fr.rgba1(r))}getUniformLoc(e){const r=this.uniformLocCache.get(e);if(r!=null)return r;const n=this.renderCtx.gl.getUniformLocation(this.prog,e);if(n==null)throw new Error(`unexpected missing uniform ${e}`);return this.uniformLocCache.set(e,n),n}compile(){const e=this.renderCtx.gl;this.compileShader(this.vertShader,e.VERTEX_SHADER),this.compileShader(this.fragShader,e.FRAGMENT_SHADER),e.linkProgram(this.prog)}compileShader(e,r){const n=this.renderCtx.gl,a=n.createShader(r);if(a==null)throw BO;if(n.shaderSource(a,e),n.compileShader(a),!n.getShaderParameter(a,n.COMPILE_STATUS)){const o=n.getShaderInfoLog(a);throw n.deleteShader(a),Xa(o??"unknown")}n.attachShader(this.prog,a)}};const ZO=new Float32Array([0,0,0,0,0,0]);class FO extends Nc{positionBuffer;constructor(e){super(e,$O,DO);const r=e.gl.createBuffer();if(r==null)throw new J("webgl: failed to create buffer");this.positionBuffer=r,e.gl.bindBuffer(e.gl.ARRAY_BUFFER,this.positionBuffer),e.gl.bufferData(e.gl.ARRAY_BUFFER,ZO,e.gl.STATIC_DRAW)}exec(){const{gl:e}=this.renderCtx,r=e.getAttribLocation(this.prog,"a_position");e.bindBuffer(e.ARRAY_BUFFER,this.positionBuffer);const n=e.createVertexArray();e.bindVertexArray(n),e.enableVertexAttribArray(r),e.vertexAttribPointer(r,2,e.FLOAT,!1,0,0),this.setAsActive(),e.drawArrays(e.TRIANGLES,0,3)}}const Qa={high:1,low:0};class xc{requests=new Map;cleanup=new Map;afterRender;instrumentation;handleError;constructor({afterRender:e,instrumentation:r=Ue.Instrumentation.NOOP,handleError:n}){this.afterRender=e,this.instrumentation=r,this.handleError=n,this.start()}set(e){const r=this.requests.get(e.key);if(r==null)this.requests.set(e.key,e);else{const n=Qa[e.priority]>=Qa[r.priority],a=e.canvases.length>=r.canvases.length;n&&a&&this.requests.set(e.key,e)}}render(){const{requests:e}=this;e.size!==0&&(this.runCleanupsSync(),this.renderSync(),this.requests.clear(),this.afterRender?.())}runCleanupsSync(){const{cleanup:e,requests:r}=this;e.forEach((n,a)=>{const i=r.get(a);i!=null&&(n(i),e.delete(a))})}renderSync(){const{requests:e}=this;e.forEach(r=>{try{const n=r.render();n!=null&&this.cleanup.set(r.key,n)}catch(n){this.handleError(n,"render loop failed")}})}start(){const e=()=>{try{this.render()}catch(r){this.handleError(r,"render loop failed")}requestAnimationFrame(e)};requestAnimationFrame(e)}}const Or=2,ve=2;class ia{atlas;charDims;charMap;static DEFAULT_CHARS="0123456789.:-µmsNa∞ᴇ";constructor(e){const{font:r,characters:n=ia.DEFAULT_CHARS,textColor:a}=e;this.charMap=new Map;const i=p.c.unique(Array.from(n)),l=new OffscreenCanvas(1,1).getContext("2d");l.font=r;const c=l.measureText("0");this.charDims=cn(c),this.charDims.width+=Or,this.charDims.height+=Or;const u=i.length,h=this.charDims.width,f=this.charDims.height,d=Math.ceil(Math.sqrt(u)),z=Math.ceil(u/d);this.atlas=new OffscreenCanvas(h*d*ve,f*(z+1)*ve);const N=this.atlas.getContext("2d");N.scale(ve,ve),N.font=r,N.textBaseline="alphabetic",N.textAlign="left",N.fillStyle=p.fr.hex(a),N.clearRect(0,0,this.atlas.width,this.atlas.height),i.forEach((I,B)=>{const R=B%d,D=Math.floor(B/d),he=R*h,ie=(D+1)*f;N.fillText(I,he,ie),this.charMap.set(I,B)})}fillText(e,r,n,a){const{width:i,height:o}=this.charDims,l=Math.ceil(Math.sqrt(this.charMap.size));for(let c=0;c<r.length;c++){const u=r[c],h=this.charMap.get(u);if(h===void 0)continue;const f=h%l,d=Math.floor(h/l);e.drawImage(this.atlas,f*i*ve,d*o*ve+Or,i*ve,o*ve,n+c*i,a-o-Or/ve,i,o)}}measureText(e){return{width:e.length*this.charDims.width,height:this.charDims.height}}}class qO{atlases;constructor(){this.atlases=new Map}get(e){const r=`${e.font}-${p.fr.hex(e.textColor)}-${e.characters}`;if(this.atlases.has(r))return this.atlases.get(r);const n=new ia(e);return this.atlases.set(r,n),n}}const ei=t=>(t.textRendering="optimizeSpeed",t.imageSmoothingEnabled=!1,t);class Re{glCanvas;upper2dCanvas;lower2dCanvas;gl;lower2d;upper2d;region;dpr;loop;clearProgram;os;static CONTEXT_KEY=p.CSS.B("render-context");instrumentation;static create(e,r,n,a,i){const o=Ec(e,"render_context"),l=new Re(r,n,a,i,o,hn(e),aa(e));return e.set(Re.CONTEXT_KEY,l),l}constructor(e,r,n,a,i,o,l){this.upper2dCanvas=n,this.lower2dCanvas=r,this.glCanvas=e,this.os=a,this.instrumentation=i,this.dpr=1;const c=this.lower2dCanvas.getContext("2d");if(c==null)throw new Error("Could not get 2D context");const u=new qO;this.lower2d=ei(new $r(c,u,this.dpr));const h=this.upper2dCanvas.getContext("2d");if(h==null)throw new Error("Could not get 2D context");this.upper2d=ei(new $r(h,u,this.dpr));const f={preserveDrawingBuffer:!0,powerPreference:"high-performance",stencil:!1,depth:!1},d=this.glCanvas.getContext("webgl2",f);if(d==null)throw new Error("Could not get WebGL context");d.disable(d.DEPTH_TEST),d.disable(d.STENCIL_TEST),d.disable(d.CULL_FACE),d.disable(d.DITHER),this.gl=d,this.glCanvas.oncontextlost=()=>o({variant:"error",message:"WebGL context lost"});const z=()=>{this.gl.flush(),this.gl.finish()};this.loop=new xc({afterRender:z,instrumentation:this.instrumentation,handleError:l}),this.region=p.Ho.ZERO,this.os==="Windows"&&(this.clearProgram=new FO(this))}static useOptional(e){return e.getOptional(Re.CONTEXT_KEY)}static use(e){return e.get(Re.CONTEXT_KEY)}update(e){e.set(Re.CONTEXT_KEY,this)}resize(e,r){p.Ho.equals(this.region,e)&&this.dpr===r||(this.region=e,this.dpr=r,this.resizeCanvas(this.glCanvas),this.resizeCanvas(this.upper2dCanvas),this.resizeCanvas(this.lower2dCanvas),this.lower2d.scale(this.dpr,this.dpr),this.upper2d.scale(this.dpr,this.dpr),this.gl.viewport(0,0,p.Ho.width(e)*r,p.Ho.height(e)*r))}resizeCanvas(e){e.width=p.Ho.width(this.region)*this.dpr,e.height=p.Ho.height(this.region)*this.dpr}get aspect(){return p.Ho.aspect(this.region)}scaleRegion(e){return new p.C.XY(p.C.Scale.scale(0,1).scale(p.Ho.width(e)).translate(p.Ho.left(e)).reBound(p.Ho.width(this.region)).scale(-1,1),p.C.Scale.scale(0,1).scale(p.Ho.height(e)).invert().translate(p.Ho.top(e)).reBound(p.Ho.height(this.region)).scale(-1,1).invert())}scissor(e,r=p.K.ZERO,n){const a=[];return n.includes("upper2d")&&a.push(this.upper2d.scissor(e,r)),n.includes("lower2d")&&a.push(this.lower2d.scissor(e,r)),n.includes("gl")&&a.push(this.scissorGL(e,r)),()=>a.forEach(i=>i())}scissorGL(e,r=p.K.ZERO){return this.gl.enable(this.gl.SCISSOR_TEST),e=Cr(e,r),this.gl.scissor(p.Ho.left(e)*this.dpr,(p.Ho.height(this.region)-p.Ho.bottom(e))*this.dpr,p.Ho.width(e)*this.dpr,p.Ho.height(e)*this.dpr),()=>this.gl.disable(this.gl.SCISSOR_TEST)}erase(e,r=p.K.ZERO,...n){r=p.K.construct(r),n.length===0&&(n=["upper2d","lower2d","gl"]),n.includes("upper2d")&&this.eraseCanvas(this.upper2d,e,r),n.includes("lower2d")&&this.eraseCanvas(this.lower2d,e,r),n.includes("gl")&&this.eraseGL(e,r)}eraseGL(e,r=p.K.ZERO){const{gl:n}=this,a=this.scissorGL(Cr(e,r));n.clearColor(...p.fr.rgba1(p.fr.ZERO)),n.clear(n.COLOR_BUFFER_BIT),this.os==="Windows"&&this.clearProgram?.exec(),a()}eraseCanvas(e,r,n=p.K.ZERO){const a=Cr(r,n);e.clearRect(...p.K.couple(p.Ho.topLeft(a)),...p._.couple(p.Ho.dims(a)))}}const Ac=s.z.object({region:p.Ho.box,enabled:s.z.boolean().optional().default(!1)}),ti=["gl","lower2d","upper2d"];class ms extends un{static TYPE="eraser";schema=Ac;afterUpdate(e){this.deleted||(this.internal.renderCtx=Re.use(e),this.renderOnLifecycleChange())}afterDelete(){this.renderOnLifecycleChange()}renderOnLifecycleChange(){this.internal.renderCtx.loop.set({key:`${this.type}-${this.key}`,render:this.render.bind(this),priority:"high",canvases:ti})}render(){this.deleted||!this.state.enabled||this.internal.renderCtx.erase(this.state.region,p.K.construct(0),...ti)}}const YO={[ms.TYPE]:ms};exports.$b=Pp;exports.Aggregator=ds;exports.Bb=ng;exports.COMPONENT_SIZE_LEVELS=CT;exports.Composite=St;exports.Context=Re;exports.Eraser=ms;exports.GLProgram=Nc;exports.L=Z;exports.LEVELS=Dt;exports.LEVEL_COMPONENT_SIZES=IT;exports.Leaf=un;exports.Loop=xc;exports.N=tc;exports.O=mt;exports.O$1=S;exports.Provider=ps;exports.Provider$1=gs;exports.REGISTRY=UO;exports.REGISTRY$1=jO;exports.REGISTRY$2=YO;exports.REGISTRY$3=LO;exports.SIZES=cc;exports.SYNNAX_DARK=lc;exports.SYNNAX_LIGHT=oc;exports.SYNNAX_THEMES=ZT;exports.Tt=J;exports.Vb=om;exports.Wb=fm;exports.Xb=Cm;exports._=gt;exports.ab=sT;exports.aether=AO;exports.aggregatorStateZ=Tc;exports.be=hc;exports.c=ea;exports.createAsyncErrorHandler=vc;exports.createErrorHandler=bc;exports.d=vT;exports.dT=Cv;exports.dimensions=NT;exports.dimensionsFromMetrics=cn;exports.downLevel=AT;exports.eT=Vm;exports.eraserStateZ=Ac;exports.executeInitialSetter=ln;exports.executeSetter=ta;exports.f=E;exports.fontSpecZ=Oc;exports.g=Ue;exports.iT=mb;exports.ir=ft;exports.isSize=FT;exports.jb=my;exports.k=C;exports.levelZ=xT;exports.o=oT;exports.p=Ql;exports.pT=nT;exports.prettyParse=os;exports.providerStateZ=Sc;exports.qe=Be;exports.r=lT;exports.rT=pw;exports.render=yc;exports.sT=jw;exports.sb=Xl;exports.size=uc;exports.specZ=je;exports.state=ST;exports.t=iT;exports.themeZ=ic;exports.use=MO;exports.useAdder=hn;exports.useAsyncErrorHandler=IO;exports.useErrorHandler=aa;exports.useInstrumentation=Ec;exports.useOptionalAdder=CO;exports.usePassthrough=sc;exports.usePurePassthrough=ac;exports.weightZ=kT;exports.xb=sy;