@synnaxlabs/pluto 0.45.1 → 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.
- package/dist/{Toggle-CzRMXK-K.js → Toggle-BZQSuhA3.js} +2 -2
- package/dist/{Toggle-DY4PmA0_.cjs → Toggle-D7uuc8BY.cjs} +1 -1
- package/dist/{Video-CgaO8bTm.cjs → Video-BgaQjOlJ.cjs} +1 -1
- package/dist/{Video-B4UWip-3.js → Video-Com7iIjJ.js} +2 -2
- package/dist/button.cjs +1 -1
- package/dist/button.js +1 -1
- package/dist/color.cjs +1 -1
- package/dist/color.js +1 -1
- package/dist/css-DA2F4zE4.cjs +8 -0
- package/dist/{css-BUXMI9PB.js → css-qKD7ZG81.js} +1450 -1285
- package/dist/css.cjs +1 -1
- package/dist/css.js +2 -2
- package/dist/dialog.cjs +1 -1
- package/dist/dialog.js +1 -1
- package/dist/ether.cjs +1 -1
- package/dist/ether.js +72 -69
- package/dist/external-B3j4WcRx.js +42 -0
- package/dist/{external-S6GiiOBy.cjs → external-BH7AW9vg.cjs} +1 -1
- package/dist/{external-BY99QanC.js → external-BHDJdA7E.js} +10 -10
- package/dist/external-BaO1j7U1.cjs +1 -0
- package/dist/external-BatQDwpn.cjs +1 -0
- package/dist/external-Bfddv9ir.cjs +1 -0
- package/dist/{external-D_PgcvDj.js → external-Bnn6kifu.js} +206 -206
- package/dist/external-BoMP9V9w.js +14 -0
- package/dist/{external-Du8Z1FRh.js → external-Bor2llbx.js} +62 -62
- package/dist/external-Bp0LGk7L.cjs +1 -0
- package/dist/{external-C-0pnmB4.js → external-C0EjmEmQ.js} +25 -25
- package/dist/{external-DzuRmcYi.js → external-CBwmQS9D.js} +137 -122
- package/dist/external-CV0q6V-F.js +87 -0
- package/dist/external-CaehDJtX.cjs +1 -0
- package/dist/external-DLIuO7_6.cjs +1 -0
- package/dist/{external-ByxpHVEA.js → external-DO--52ul.js} +26 -26
- package/dist/external-DZ9ZLLOd.cjs +1 -0
- package/dist/external-JI_JLXE9.cjs +46 -0
- package/dist/{external-CBLyUVI_.js → external-KX4HsfeC.js} +12 -12
- package/dist/external-LuDrHOj0.js +89 -0
- package/dist/{external-CJrxLSWV.js → external-ObqQM9Wz.js} +2 -2
- package/dist/external-R1DnhHJ8.cjs +1 -0
- package/dist/external-iLU86byd.cjs +1 -0
- package/dist/external-iTOHqKBf.js +23 -0
- package/dist/external-ok-onqCX.cjs +1 -0
- package/dist/external-qAqWNZPd.cjs +1 -0
- package/dist/flex.cjs +1 -1
- package/dist/flex.js +1 -1
- package/dist/fontString-BpD7ezh8.cjs +1 -0
- package/dist/{fontString-B3WuZ-o6.js → fontString-DXsCV3Wx.js} +2 -2
- package/dist/header.cjs +1 -1
- package/dist/header.js +1 -1
- package/dist/index.cjs +35 -7
- package/dist/index.js +32678 -21392
- package/dist/input.cjs +1 -1
- package/dist/input.js +1 -1
- package/dist/jsx-runtime-Dszzpdy0.cjs +22 -0
- package/dist/{jsx-runtime-C5mzlN2N.js → jsx-runtime-OVHDjVDe.js} +14 -14
- package/dist/list.cjs +1 -1
- package/dist/list.js +1 -1
- package/dist/main-20msMsI6.cjs +92 -0
- package/dist/{main-mGfIFfsW.js → main-ClIRTLfC.js} +17685 -17077
- package/dist/menu.cjs +1 -1
- package/dist/menu.js +1 -1
- package/dist/pluto.css +1 -1
- package/dist/provider-D295Uocj.cjs +52 -0
- package/dist/provider-DVqod4rl.cjs +83 -0
- package/dist/provider-RFk778pl.js +18803 -0
- package/dist/provider-laSzOgag.js +4673 -0
- package/dist/src/arc/Arc.d.ts +6 -0
- package/dist/src/arc/Arc.d.ts.map +1 -0
- package/dist/src/arc/external.d.ts +4 -0
- package/dist/src/arc/external.d.ts.map +1 -0
- package/dist/src/arc/handle/Core.d.ts +8 -0
- package/dist/src/arc/handle/Core.d.ts.map +1 -0
- package/dist/src/arc/handle/Sink.d.ts +5 -0
- package/dist/src/arc/handle/Sink.d.ts.map +1 -0
- package/dist/src/arc/handle/Source.d.ts +5 -0
- package/dist/src/arc/handle/Source.d.ts.map +1 -0
- package/dist/src/arc/handle/external.d.ts +3 -0
- package/dist/src/arc/handle/external.d.ts.map +1 -0
- package/dist/src/arc/handle/index.d.ts +2 -0
- package/dist/src/arc/handle/index.d.ts.map +1 -0
- package/dist/src/arc/index.d.ts +2 -0
- package/dist/src/arc/index.d.ts.map +1 -0
- package/dist/src/arc/queries.d.ts +89 -0
- package/dist/src/arc/queries.d.ts.map +1 -0
- package/dist/src/arc/stage/Base.d.ts +32 -0
- package/dist/src/arc/stage/Base.d.ts.map +1 -0
- package/dist/src/arc/stage/constant/Constant.d.ts +9 -0
- package/dist/src/arc/stage/constant/Constant.d.ts.map +1 -0
- package/dist/src/arc/stage/constant/Form.d.ts +2 -0
- package/dist/src/arc/stage/constant/Form.d.ts.map +1 -0
- package/dist/src/arc/stage/constant/external.d.ts +3 -0
- package/dist/src/arc/stage/constant/external.d.ts.map +1 -0
- package/dist/src/arc/stage/constant/index.d.ts +2 -0
- package/dist/src/arc/stage/constant/index.d.ts.map +1 -0
- package/dist/src/arc/stage/external.d.ts +4 -0
- package/dist/src/arc/stage/external.d.ts.map +1 -0
- package/dist/src/arc/stage/index.d.ts +2 -0
- package/dist/src/arc/stage/index.d.ts.map +1 -0
- package/dist/src/arc/stage/operator/Operator.d.ts +17 -0
- package/dist/src/arc/stage/operator/Operator.d.ts.map +1 -0
- package/dist/src/arc/stage/operator/external.d.ts +242 -0
- package/dist/src/arc/stage/operator/external.d.ts.map +1 -0
- package/dist/src/arc/stage/operator/index.d.ts +2 -0
- package/dist/src/arc/stage/operator/index.d.ts.map +1 -0
- package/dist/src/arc/stage/read/Form.d.ts +3 -0
- package/dist/src/arc/stage/read/Form.d.ts.map +1 -0
- package/dist/src/arc/stage/read/Read.d.ts +10 -0
- package/dist/src/arc/stage/read/Read.d.ts.map +1 -0
- package/dist/src/arc/stage/read/external.d.ts +9 -0
- package/dist/src/arc/stage/read/external.d.ts.map +1 -0
- package/dist/src/arc/stage/read/index.d.ts +2 -0
- package/dist/src/arc/stage/read/index.d.ts.map +1 -0
- package/dist/src/arc/stage/registry.d.ts +11 -0
- package/dist/src/arc/stage/registry.d.ts.map +1 -0
- package/dist/src/arc/stage/select/Select.d.ts +2 -0
- package/dist/src/arc/stage/select/Select.d.ts.map +1 -0
- package/dist/src/arc/stage/select/external.d.ts +12 -0
- package/dist/src/arc/stage/select/external.d.ts.map +1 -0
- package/dist/src/arc/stage/select/index.d.ts +2 -0
- package/dist/src/arc/stage/select/index.d.ts.map +1 -0
- package/dist/src/arc/stage/source/Form.d.ts +3 -0
- package/dist/src/arc/stage/source/Form.d.ts.map +1 -0
- package/dist/src/arc/stage/source/Source.d.ts +10 -0
- package/dist/src/arc/stage/source/Source.d.ts.map +1 -0
- package/dist/src/arc/stage/source/external.d.ts +9 -0
- package/dist/src/arc/stage/source/external.d.ts.map +1 -0
- package/dist/src/arc/stage/source/index.d.ts +2 -0
- package/dist/src/arc/stage/source/index.d.ts.map +1 -0
- package/dist/src/arc/stage/stable/Form.d.ts +2 -0
- package/dist/src/arc/stage/stable/Form.d.ts.map +1 -0
- package/dist/src/arc/stage/stable/StableFor.d.ts +9 -0
- package/dist/src/arc/stage/stable/StableFor.d.ts.map +1 -0
- package/dist/src/arc/stage/stable/external.d.ts +3 -0
- package/dist/src/arc/stage/stable/external.d.ts.map +1 -0
- package/dist/src/arc/stage/stable/index.d.ts +2 -0
- package/dist/src/arc/stage/stable/index.d.ts.map +1 -0
- package/dist/src/arc/stage/status/Change.d.ts +21 -0
- package/dist/src/arc/stage/status/Change.d.ts.map +1 -0
- package/dist/src/arc/stage/status/Form.d.ts +3 -0
- package/dist/src/arc/stage/status/Form.d.ts.map +1 -0
- package/dist/src/arc/stage/status/external.d.ts +7 -0
- package/dist/src/arc/stage/status/external.d.ts.map +1 -0
- package/dist/src/arc/stage/status/index.d.ts +2 -0
- package/dist/src/arc/stage/status/index.d.ts.map +1 -0
- package/dist/src/arc/stage/types/index.d.ts +2 -0
- package/dist/src/arc/stage/types/index.d.ts.map +1 -0
- package/dist/src/arc/stage/types/spec.d.ts +25 -0
- package/dist/src/arc/stage/types/spec.d.ts.map +1 -0
- package/dist/src/button/color.d.ts +1 -2
- package/dist/src/button/color.d.ts.map +1 -1
- package/dist/src/channel/AliasInput.d.ts +3 -3
- package/dist/src/channel/AliasInput.d.ts.map +1 -1
- package/dist/src/channel/LinePlot.d.ts +4 -4
- package/dist/src/channel/LinePlot.d.ts.map +1 -1
- package/dist/src/channel/Select.d.ts +5 -5
- package/dist/src/channel/Select.d.ts.map +1 -1
- package/dist/src/channel/queries.d.ts +37 -70
- package/dist/src/channel/queries.d.ts.map +1 -1
- package/dist/src/css/bem.d.ts +1 -2
- package/dist/src/css/bem.d.ts.map +1 -1
- package/dist/src/dialog/Frame.d.ts.map +1 -1
- package/dist/src/divider/Divider.d.ts +1 -1
- package/dist/src/divider/Divider.d.ts.map +1 -1
- package/dist/src/ether.d.ts +2 -2
- package/dist/src/ether.d.ts.map +1 -1
- package/dist/src/flux/Provider.d.ts.map +1 -1
- package/dist/src/flux/aether/external.d.ts +1 -1
- package/dist/src/flux/aether/external.d.ts.map +1 -1
- package/dist/src/flux/aether/provider.d.ts +1 -1
- package/dist/src/flux/aether/provider.d.ts.map +1 -1
- package/dist/src/flux/core/external.d.ts +1 -0
- package/dist/src/flux/core/external.d.ts.map +1 -1
- package/dist/src/flux/core/store.d.ts +19 -13
- package/dist/src/flux/core/store.d.ts.map +1 -1
- package/dist/src/flux/core/streamer.d.ts +1 -1
- package/dist/src/flux/core/streamer.d.ts.map +1 -1
- package/dist/src/flux/core/types.d.ts +42 -0
- package/dist/src/flux/core/types.d.ts.map +1 -0
- package/dist/src/flux/external.d.ts +1 -1
- package/dist/src/flux/external.d.ts.map +1 -1
- package/dist/src/flux/form.d.ts +29 -127
- package/dist/src/flux/form.d.ts.map +1 -1
- package/dist/src/flux/list.d.ts +28 -228
- package/dist/src/flux/list.d.ts.map +1 -1
- package/dist/src/flux/result.d.ts +32 -90
- package/dist/src/flux/result.d.ts.map +1 -1
- package/dist/src/flux/retrieve.d.ts +47 -176
- package/dist/src/flux/retrieve.d.ts.map +1 -1
- package/dist/src/flux/update.d.ts +45 -134
- package/dist/src/flux/update.d.ts.map +1 -1
- package/dist/src/form/Context.d.ts +2 -2
- package/dist/src/form/Context.d.ts.map +1 -1
- package/dist/src/form/Context.spec.d.ts +2 -0
- package/dist/src/form/Context.spec.d.ts.map +1 -0
- package/dist/src/group/queries.d.ts +18 -18
- package/dist/src/group/queries.d.ts.map +1 -1
- package/dist/src/hardware/device/Select.d.ts +2 -2
- package/dist/src/hardware/device/Select.d.ts.map +1 -1
- package/dist/src/hardware/device/queries.d.ts +369 -9
- package/dist/src/hardware/device/queries.d.ts.map +1 -1
- package/dist/src/hardware/rack/Select.d.ts +3 -3
- package/dist/src/hardware/rack/Select.d.ts.map +1 -1
- package/dist/src/hardware/rack/queries.d.ts +15 -11
- package/dist/src/hardware/rack/queries.d.ts.map +1 -1
- package/dist/src/hardware/task/queries.d.ts +70 -17
- package/dist/src/hardware/task/queries.d.ts.map +1 -1
- package/dist/src/hooks/useRequiredContext.d.ts.map +1 -1
- package/dist/src/hooks/useRequiredContext.spec.d.ts +2 -0
- package/dist/src/hooks/useRequiredContext.spec.d.ts.map +1 -0
- package/dist/src/icon/Modbus.d.ts +2 -0
- package/dist/src/icon/Modbus.d.ts.map +1 -0
- package/dist/src/icon/registry.d.ts +16 -3
- package/dist/src/icon/registry.d.ts.map +1 -1
- package/dist/src/index.d.ts +4 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/input/Boolean.d.ts +3 -2
- package/dist/src/input/Boolean.d.ts.map +1 -1
- package/dist/src/input/Checkbox.d.ts +2 -3
- package/dist/src/input/Checkbox.d.ts.map +1 -1
- package/dist/src/input/DateTime.d.ts +1 -18
- package/dist/src/input/DateTime.d.ts.map +1 -1
- package/dist/src/input/Switch.d.ts +2 -3
- package/dist/src/input/Switch.d.ts.map +1 -1
- package/dist/src/input/Text.d.ts +2 -1
- package/dist/src/input/Text.d.ts.map +1 -1
- package/dist/src/input/external.d.ts +0 -1
- package/dist/src/input/external.d.ts.map +1 -1
- package/dist/src/label/Select.d.ts +5 -5
- package/dist/src/label/Select.d.ts.map +1 -1
- package/dist/src/label/queries.d.ts +35 -20
- package/dist/src/label/queries.d.ts.map +1 -1
- package/dist/src/{vis/lineplot → lineplot}/Axis.d.ts +3 -3
- package/dist/src/lineplot/Axis.d.ts.map +1 -0
- package/dist/src/{vis/lineplot → lineplot}/Legend.d.ts +1 -1
- package/dist/src/lineplot/Legend.d.ts.map +1 -0
- package/dist/src/{vis/lineplot → lineplot}/Line.d.ts +2 -2
- package/dist/src/lineplot/Line.d.ts.map +1 -0
- package/dist/src/{vis/lineplot → lineplot}/LinePlot.d.ts +3 -3
- package/dist/src/lineplot/LinePlot.d.ts.map +1 -0
- package/dist/src/{vis/lineplot → lineplot}/Title.d.ts +1 -1
- package/dist/src/lineplot/Title.d.ts.map +1 -0
- package/dist/src/{vis/lineplot → lineplot}/Viewport.d.ts +1 -1
- package/dist/src/lineplot/Viewport.d.ts.map +1 -0
- package/dist/src/{vis/lineplot → lineplot}/aether/BoundQuerier.d.ts +1 -1
- package/dist/src/lineplot/aether/BoundQuerier.d.ts.map +1 -0
- package/dist/src/{vis/lineplot → lineplot}/aether/LinePlot.d.ts +5 -5
- package/dist/src/lineplot/aether/LinePlot.d.ts.map +1 -0
- package/dist/src/{vis/lineplot → lineplot}/aether/XAxis.d.ts +3 -3
- package/dist/src/lineplot/aether/XAxis.d.ts.map +1 -0
- package/dist/src/{vis/lineplot → lineplot}/aether/YAxis.d.ts +2 -2
- package/dist/src/lineplot/aether/YAxis.d.ts.map +1 -0
- package/dist/src/{vis/lineplot → lineplot}/aether/axis.d.ts +6 -6
- package/dist/src/lineplot/aether/axis.d.ts.map +1 -0
- package/dist/src/lineplot/aether/external.d.ts.map +1 -0
- package/dist/src/lineplot/aether/index.d.ts.map +1 -0
- package/dist/src/{vis/lineplot → lineplot}/external.d.ts +1 -0
- package/dist/src/lineplot/external.d.ts.map +1 -0
- package/dist/src/lineplot/index.d.ts.map +1 -0
- package/dist/src/lineplot/queries.d.ts +33 -0
- package/dist/src/lineplot/queries.d.ts.map +1 -0
- package/dist/src/lineplot/queries.spec.d.ts +2 -0
- package/dist/src/lineplot/queries.spec.d.ts.map +1 -0
- package/dist/src/{vis/lineplot → lineplot}/range/Annotation.d.ts +1 -1
- package/dist/src/lineplot/range/Annotation.d.ts.map +1 -0
- package/dist/src/{vis/lineplot → lineplot}/range/Provider.d.ts +2 -2
- package/dist/src/lineplot/range/Provider.d.ts.map +1 -0
- package/dist/src/{vis/lineplot → lineplot}/range/aether/annotation.d.ts +3 -3
- package/dist/src/lineplot/range/aether/annotation.d.ts.map +1 -0
- package/dist/src/{vis/lineplot → lineplot}/range/aether/external.d.ts +1 -1
- package/dist/src/lineplot/range/aether/external.d.ts.map +1 -0
- package/dist/src/lineplot/range/aether/index.d.ts.map +1 -0
- package/dist/src/{vis/lineplot → lineplot}/range/aether/provider.d.ts +10 -10
- package/dist/src/lineplot/range/aether/provider.d.ts.map +1 -0
- package/dist/src/lineplot/range/external.d.ts.map +1 -0
- package/dist/src/lineplot/range/index.d.ts.map +1 -0
- package/dist/src/{vis/lineplot → lineplot}/tooltip/Tooltip.d.ts +1 -1
- package/dist/src/lineplot/tooltip/Tooltip.d.ts.map +1 -0
- package/dist/src/lineplot/tooltip/aether/index.d.ts.map +1 -0
- package/dist/src/{vis/lineplot → lineplot}/tooltip/aether/tooltip.d.ts +4 -4
- package/dist/src/lineplot/tooltip/aether/tooltip.d.ts.map +1 -0
- package/dist/src/lineplot/tooltip/index.d.ts.map +1 -0
- package/dist/src/lineplot/useBoundQuerier.d.ts.map +1 -0
- package/dist/src/list/Frame.d.ts +16 -1
- package/dist/src/list/Frame.d.ts.map +1 -1
- package/dist/src/list/pager.d.ts +7 -1
- package/dist/src/list/pager.d.ts.map +1 -1
- package/dist/src/list/useCombinedData.d.ts.map +1 -1
- package/dist/src/list/useKeysData.d.ts.map +1 -1
- package/dist/src/list/useMapData.d.ts.map +1 -1
- package/dist/src/list/useStaticData.d.ts.map +1 -1
- package/dist/src/{vis/log → log}/Log.d.ts +2 -2
- package/dist/src/log/Log.d.ts.map +1 -0
- package/dist/src/{vis/log → log}/aether/Log.d.ts +4 -4
- package/dist/src/log/aether/Log.d.ts.map +1 -0
- package/dist/src/log/aether/index.d.ts.map +1 -0
- package/dist/src/log/external.d.ts +3 -0
- package/dist/src/log/external.d.ts.map +1 -0
- package/dist/src/log/index.d.ts +2 -0
- package/dist/src/log/index.d.ts.map +1 -0
- package/dist/src/log/queries.d.ts +33 -0
- package/dist/src/log/queries.d.ts.map +1 -0
- package/dist/src/log/queries.spec.d.ts +2 -0
- package/dist/src/log/queries.spec.d.ts.map +1 -0
- package/dist/src/menu/ContextMenu.d.ts.map +1 -1
- package/dist/src/ontology/aether/index.d.ts +2 -0
- package/dist/src/ontology/aether/index.d.ts.map +1 -0
- package/dist/src/ontology/aether/queries.d.ts +15 -0
- package/dist/src/ontology/aether/queries.d.ts.map +1 -0
- package/dist/src/ontology/external.d.ts +1 -0
- package/dist/src/ontology/external.d.ts.map +1 -1
- package/dist/src/ontology/queries.d.ts +27 -23
- package/dist/src/ontology/queries.d.ts.map +1 -1
- package/dist/src/pluto/Pluto.d.ts +13 -0
- package/dist/src/pluto/Pluto.d.ts.map +1 -1
- package/dist/src/pluto/aether/pluto.d.ts.map +1 -1
- package/dist/src/ranger/Breadcrumb.d.ts +3 -1
- package/dist/src/ranger/Breadcrumb.d.ts.map +1 -1
- package/dist/src/ranger/CreateIcon.d.ts +3 -0
- package/dist/src/ranger/CreateIcon.d.ts.map +1 -0
- package/dist/src/ranger/Select.d.ts +4 -14
- package/dist/src/ranger/Select.d.ts.map +1 -1
- package/dist/src/ranger/SelectStage.d.ts +7 -0
- package/dist/src/ranger/SelectStage.d.ts.map +1 -0
- package/dist/src/ranger/StageIcon.d.ts +8 -0
- package/dist/src/ranger/StageIcon.d.ts.map +1 -0
- package/dist/src/ranger/aether/index.d.ts.map +1 -1
- package/dist/src/ranger/aether/queries.d.ts +2 -2
- package/dist/src/ranger/aether/queries.d.ts.map +1 -1
- package/dist/src/ranger/external.d.ts +5 -1
- package/dist/src/ranger/external.d.ts.map +1 -1
- package/dist/src/ranger/queries.d.ts +41 -41
- package/dist/src/ranger/queries.d.ts.map +1 -1
- package/dist/src/ranger/stage.d.ts +20 -0
- package/dist/src/ranger/stage.d.ts.map +1 -0
- package/dist/src/ranger/stage.spec.d.ts +2 -0
- package/dist/src/ranger/stage.spec.d.ts.map +1 -0
- package/dist/src/resize/Core.d.ts.map +1 -1
- package/dist/src/schematic/Schematic.d.ts +6 -0
- package/dist/src/schematic/Schematic.d.ts.map +1 -0
- package/dist/src/schematic/edge/Edge.d.ts +15 -0
- package/dist/src/schematic/edge/Edge.d.ts.map +1 -0
- package/dist/src/schematic/edge/connector/connector.d.ts.map +1 -0
- package/dist/src/schematic/edge/connector/connector.spec.d.ts.map +1 -0
- package/dist/src/schematic/edge/connector/index.d.ts.map +1 -0
- package/dist/src/schematic/edge/index.d.ts +3 -0
- package/dist/src/schematic/edge/index.d.ts.map +1 -0
- package/dist/src/schematic/edge/paths.d.ts +28 -0
- package/dist/src/schematic/edge/paths.d.ts.map +1 -0
- package/dist/src/schematic/external.d.ts +3 -0
- package/dist/src/schematic/external.d.ts.map +1 -1
- package/dist/src/schematic/queries.d.ts +43 -0
- package/dist/src/schematic/queries.d.ts.map +1 -0
- package/dist/src/schematic/queries.spec.d.ts +2 -0
- package/dist/src/schematic/queries.spec.d.ts.map +1 -0
- package/dist/src/schematic/symbol/Custom.d.ts.map +1 -1
- package/dist/src/schematic/symbol/Forms.d.ts +1 -0
- package/dist/src/schematic/symbol/Forms.d.ts.map +1 -1
- package/dist/src/schematic/symbol/Primitives.d.ts +1 -1
- package/dist/src/schematic/symbol/Primitives.d.ts.map +1 -1
- package/dist/src/schematic/symbol/Symbols.d.ts +11 -1
- package/dist/src/schematic/symbol/Symbols.d.ts.map +1 -1
- package/dist/src/schematic/symbol/queries.d.ts +20 -19
- package/dist/src/schematic/symbol/queries.d.ts.map +1 -1
- package/dist/src/schematic/symbol/registry.d.ts +2 -1
- package/dist/src/schematic/symbol/registry.d.ts.map +1 -1
- package/dist/src/select/Dialog.d.ts +1 -1
- package/dist/src/select/Dialog.d.ts.map +1 -1
- package/dist/src/select/Frame.d.ts +4 -1
- package/dist/src/select/Frame.d.ts.map +1 -1
- package/dist/src/select/ListItem.d.ts.map +1 -1
- package/dist/src/select/MultipleTrigger.d.ts +5 -2
- package/dist/src/select/MultipleTrigger.d.ts.map +1 -1
- package/dist/src/showcase/DividerShowcase.d.ts.map +1 -1
- package/dist/src/showcase/InputShowcase.d.ts +1 -1
- package/dist/src/showcase/InputShowcase.d.ts.map +1 -1
- package/dist/src/showcase/SelectShowcase.d.ts.map +1 -1
- package/dist/src/showcase/TagShowcase.d.ts.map +1 -1
- package/dist/src/state/state.d.ts +2 -1
- package/dist/src/state/state.d.ts.map +1 -1
- package/dist/src/status/CreateIcon.d.ts +1 -0
- package/dist/src/status/CreateIcon.d.ts.map +1 -0
- package/dist/src/status/Select.d.ts +12 -0
- package/dist/src/status/Select.d.ts.map +1 -0
- package/dist/src/status/SelectVariant.d.ts +7 -0
- package/dist/src/status/SelectVariant.d.ts.map +1 -0
- package/dist/src/status/aether/aggregator.d.ts +3 -25
- package/dist/src/status/aether/aggregator.d.ts.map +1 -1
- package/dist/src/status/aether/errorHandler.d.ts +1 -1
- package/dist/src/status/aether/errorHandler.d.ts.map +1 -1
- package/dist/src/status/{Aggregator.d.ts → core/Aggregator.d.ts} +4 -4
- package/dist/src/status/core/Aggregator.d.ts.map +1 -0
- package/dist/src/status/core/Aggregator.spec.d.ts.map +1 -0
- package/dist/src/status/core/CreateIcon.d.ts +3 -0
- package/dist/src/status/core/CreateIcon.d.ts.map +1 -0
- package/dist/src/status/{Indicator.d.ts → core/Indicator.d.ts} +1 -1
- package/dist/src/status/core/Indicator.d.ts.map +1 -0
- package/dist/src/status/{Notification.d.ts → core/Notification.d.ts} +3 -3
- package/dist/src/status/core/Notification.d.ts.map +1 -0
- package/dist/src/status/core/Notification.spec.d.ts.map +1 -0
- package/dist/src/status/core/SelectVariant.d.ts +7 -0
- package/dist/src/status/core/SelectVariant.d.ts.map +1 -0
- package/dist/src/status/core/Summary.d.ts +12 -0
- package/dist/src/status/core/Summary.d.ts.map +1 -0
- package/dist/src/status/core/colors.d.ts.map +1 -0
- package/dist/src/status/core/external.d.ts +8 -0
- package/dist/src/status/core/external.d.ts.map +1 -0
- package/dist/src/status/core/index.d.ts +2 -0
- package/dist/src/status/core/index.d.ts.map +1 -0
- package/dist/src/status/external.d.ts +3 -5
- package/dist/src/status/external.d.ts.map +1 -1
- package/dist/src/status/index.d.ts.map +1 -1
- package/dist/src/status/queries.d.ts +64 -0
- package/dist/src/status/queries.d.ts.map +1 -0
- package/dist/src/status/queries.spec.d.ts +2 -0
- package/dist/src/status/queries.spec.d.ts.map +1 -0
- package/dist/src/synnax/Provider.d.ts +8 -5
- package/dist/src/synnax/Provider.d.ts.map +1 -1
- package/dist/src/table/external.d.ts +1 -0
- package/dist/src/table/external.d.ts.map +1 -1
- package/dist/src/table/queries.d.ts +35 -0
- package/dist/src/table/queries.d.ts.map +1 -0
- package/dist/src/table/queries.spec.d.ts +2 -0
- package/dist/src/table/queries.spec.d.ts.map +1 -0
- package/dist/src/tag/Tags.d.ts +1 -1
- package/dist/src/tag/Tags.d.ts.map +1 -1
- package/dist/src/telem/aether/noop.d.ts.map +1 -1
- package/dist/src/telem/aether/remote.d.ts +4 -4
- package/dist/src/telem/aether/telem.d.ts +1 -1
- package/dist/src/telem/aether/telem.d.ts.map +1 -1
- package/dist/src/telem/client/streamer.d.ts +1 -0
- package/dist/src/telem/client/streamer.d.ts.map +1 -1
- package/dist/src/telem/control/Chip.d.ts.map +1 -1
- package/dist/src/telem/control/aether/chip.d.ts +9 -32
- package/dist/src/telem/control/aether/chip.d.ts.map +1 -1
- package/dist/src/telem/control/aether/controller.d.ts.map +1 -1
- package/dist/src/telem/control/aether/indicator.d.ts +15 -38
- package/dist/src/telem/control/aether/indicator.d.ts.map +1 -1
- package/dist/src/telem/external.d.ts +1 -0
- package/dist/src/telem/external.d.ts.map +1 -1
- package/dist/src/telem/text/TimeRange.d.ts +10 -0
- package/dist/src/telem/text/TimeRange.d.ts.map +1 -0
- package/dist/src/telem/text/TimeRange.spec.d.ts +2 -0
- package/dist/src/telem/text/TimeRange.spec.d.ts.map +1 -0
- package/dist/src/telem/text/TimeSpan.d.ts +10 -0
- package/dist/src/telem/text/TimeSpan.d.ts.map +1 -0
- package/dist/src/telem/text/TimeSpan.spec.d.ts +2 -0
- package/dist/src/telem/text/TimeSpan.spec.d.ts.map +1 -0
- package/dist/src/telem/text/TimeSpanSince.d.ts +11 -0
- package/dist/src/telem/text/TimeSpanSince.d.ts.map +1 -0
- package/dist/src/telem/text/TimeStamp.d.ts +12 -0
- package/dist/src/telem/text/TimeStamp.d.ts.map +1 -0
- package/dist/src/telem/text/TimeStamp.spec.d.ts +2 -0
- package/dist/src/telem/text/TimeStamp.spec.d.ts.map +1 -0
- package/dist/src/telem/text/external.d.ts +5 -0
- package/dist/src/telem/text/external.d.ts.map +1 -0
- package/dist/src/telem/text/index.d.ts +2 -0
- package/dist/src/telem/text/index.d.ts.map +1 -0
- package/dist/src/text/Editable.d.ts.map +1 -1
- package/dist/src/text/external.d.ts +0 -1
- package/dist/src/text/external.d.ts.map +1 -1
- package/dist/src/tooltip/Dialog.d.ts.map +1 -1
- package/dist/src/tree/Context.d.ts +13 -0
- package/dist/src/tree/Context.d.ts.map +1 -0
- package/dist/src/tree/Item.d.ts +2 -3
- package/dist/src/tree/Item.d.ts.map +1 -1
- package/dist/src/tree/Tree.d.ts +2 -2
- package/dist/src/tree/Tree.d.ts.map +1 -1
- package/dist/src/tree/core.d.ts +2 -1
- package/dist/src/tree/core.d.ts.map +1 -1
- package/dist/src/tree/core.spec.d.ts +2 -0
- package/dist/src/tree/core.spec.d.ts.map +1 -0
- package/dist/src/user/index.d.ts +2 -0
- package/dist/src/user/index.d.ts.map +1 -0
- package/dist/src/user/queries.d.ts +50 -0
- package/dist/src/user/queries.d.ts.map +1 -0
- package/dist/src/user/queries.spec.d.ts +2 -0
- package/dist/src/user/queries.spec.d.ts.map +1 -0
- package/dist/src/viewport/use.d.ts.map +1 -1
- package/dist/src/vis/diagram/Diagram.d.ts +16 -4
- package/dist/src/vis/diagram/Diagram.d.ts.map +1 -1
- package/dist/src/vis/diagram/aether/Diagram.d.ts.map +1 -1
- package/dist/src/vis/diagram/aether/types.d.ts +6 -49
- package/dist/src/vis/diagram/aether/types.d.ts.map +1 -1
- package/dist/src/vis/diagram/external.d.ts +1 -1
- package/dist/src/vis/diagram/external.d.ts.map +1 -1
- package/dist/src/vis/diagram/useTriggers.d.ts +12 -0
- package/dist/src/vis/diagram/useTriggers.d.ts.map +1 -0
- package/dist/src/vis/diagram/util.d.ts +2 -0
- package/dist/src/vis/diagram/util.d.ts.map +1 -1
- package/dist/src/vis/draw2d/canvas.d.ts.map +1 -1
- package/dist/src/vis/draw2d/index.d.ts +16 -6
- package/dist/src/vis/draw2d/index.d.ts.map +1 -1
- package/dist/src/vis/gauge/aether/gauge.d.ts +297 -0
- package/dist/src/vis/gauge/aether/gauge.d.ts.map +1 -0
- package/dist/src/vis/gauge/aether/index.d.ts +2 -0
- package/dist/src/vis/gauge/aether/index.d.ts.map +1 -0
- package/dist/src/vis/gauge/index.d.ts +2 -0
- package/dist/src/vis/gauge/index.d.ts.map +1 -0
- package/dist/src/vis/gauge/use.d.ts +84 -0
- package/dist/src/vis/gauge/use.d.ts.map +1 -0
- package/dist/src/vis/text/atlas.d.ts.map +1 -1
- package/dist/src/vis/value/TelemForm.d.ts.map +1 -1
- package/dist/src/workspace/queries.d.ts +37 -4
- package/dist/src/workspace/queries.d.ts.map +1 -1
- package/dist/tabs.cjs +1 -1
- package/dist/tabs.js +1 -1
- package/dist/text.cjs +1 -1
- package/dist/text.js +2 -2
- package/dist/theme.css +1593 -1594
- package/dist/theming.cjs +1 -1
- package/dist/theming.js +2 -2
- package/dist/tree.cjs +1 -1
- package/dist/tree.js +1 -1
- package/dist/triggers.cjs +1 -1
- package/dist/triggers.js +1 -1
- package/dist/units-CLbZ5ejs.cjs +1 -0
- package/dist/{units-BPvO622s.js → units-WtYBE1br.js} +1 -1
- package/dist/useKeysData-DXXVQfXZ.js +18 -0
- package/dist/useKeysData-Do63LaI0.cjs +1 -0
- package/dist/video.cjs +1 -1
- package/dist/video.js +1 -1
- package/package.json +20 -20
- package/README.md +0 -35
- package/dist/Animated-BT-w0cPF.cjs +0 -1
- package/dist/Animated-B_xTpw9g.js +0 -27
- package/dist/LinePlot-De-VLJHL.cjs +0 -53
- package/dist/LinePlot-mRCOU5PM.js +0 -6263
- package/dist/css-CmXY6iPo.cjs +0 -8
- package/dist/eraser-BcLVtorx.js +0 -14206
- package/dist/eraser-h8NIswGM.cjs +0 -63
- package/dist/external-BA4cUJmi.js +0 -42
- package/dist/external-BBGCooyz.cjs +0 -1
- package/dist/external-BF3OTViJ.js +0 -44
- package/dist/external-BNitHfU5.js +0 -24
- package/dist/external-CGbANgXa.cjs +0 -1
- package/dist/external-CMtT44YA.cjs +0 -1
- package/dist/external-CNbPkF53.cjs +0 -1
- package/dist/external-CbHzHgtw.js +0 -92
- package/dist/external-CiJ7RsGt.cjs +0 -1
- package/dist/external-D2VXaXzu.cjs +0 -1
- package/dist/external-DNwQ_1PT.js +0 -124
- package/dist/external-DYC1EK6G.cjs +0 -1
- package/dist/external-Dl5JyJaH.cjs +0 -1
- package/dist/external-DynvKrxv.cjs +0 -46
- package/dist/external-ETemCKjS.cjs +0 -1
- package/dist/external-aXmXhGMj.cjs +0 -1
- package/dist/external-zzhrikgD.cjs +0 -1
- package/dist/fontString-C4QgiFXy.cjs +0 -1
- package/dist/jsx-runtime-CITbqOLs.cjs +0 -22
- package/dist/main-DCvw0wt3.cjs +0 -92
- package/dist/src/flux/core/params.d.ts +0 -31
- package/dist/src/flux/core/params.d.ts.map +0 -1
- package/dist/src/input/TextArea.d.ts +0 -25
- package/dist/src/input/TextArea.d.ts.map +0 -1
- package/dist/src/ranger/TimeRangeChip.d.ts +0 -10
- package/dist/src/ranger/TimeRangeChip.d.ts.map +0 -1
- package/dist/src/status/Aggregator.d.ts.map +0 -1
- package/dist/src/status/Aggregator.spec.d.ts.map +0 -1
- package/dist/src/status/Indicator.d.ts.map +0 -1
- package/dist/src/status/Notification.d.ts.map +0 -1
- package/dist/src/status/Notification.spec.d.ts.map +0 -1
- package/dist/src/status/Summary.d.ts +0 -8
- package/dist/src/status/Summary.d.ts.map +0 -1
- package/dist/src/status/colors.d.ts.map +0 -1
- package/dist/src/text/DateTime.d.ts +0 -12
- package/dist/src/text/DateTime.d.ts.map +0 -1
- package/dist/src/vis/diagram/edge/Edge.d.ts +0 -15
- package/dist/src/vis/diagram/edge/Edge.d.ts.map +0 -1
- package/dist/src/vis/diagram/edge/connector/connector.d.ts.map +0 -1
- package/dist/src/vis/diagram/edge/connector/connector.spec.d.ts.map +0 -1
- package/dist/src/vis/diagram/edge/connector/index.d.ts.map +0 -1
- package/dist/src/vis/diagram/edge/index.d.ts +0 -2
- package/dist/src/vis/diagram/edge/index.d.ts.map +0 -1
- package/dist/src/vis/diagram/edge/paths.d.ts +0 -18
- package/dist/src/vis/diagram/edge/paths.d.ts.map +0 -1
- package/dist/src/vis/lineplot/Axis.d.ts.map +0 -1
- package/dist/src/vis/lineplot/Legend.d.ts.map +0 -1
- package/dist/src/vis/lineplot/Line.d.ts.map +0 -1
- package/dist/src/vis/lineplot/LinePlot.d.ts.map +0 -1
- package/dist/src/vis/lineplot/Title.d.ts.map +0 -1
- package/dist/src/vis/lineplot/Viewport.d.ts.map +0 -1
- package/dist/src/vis/lineplot/aether/BoundQuerier.d.ts.map +0 -1
- package/dist/src/vis/lineplot/aether/LinePlot.d.ts.map +0 -1
- package/dist/src/vis/lineplot/aether/XAxis.d.ts.map +0 -1
- package/dist/src/vis/lineplot/aether/YAxis.d.ts.map +0 -1
- package/dist/src/vis/lineplot/aether/axis.d.ts.map +0 -1
- package/dist/src/vis/lineplot/aether/external.d.ts.map +0 -1
- package/dist/src/vis/lineplot/aether/index.d.ts.map +0 -1
- package/dist/src/vis/lineplot/external.d.ts.map +0 -1
- package/dist/src/vis/lineplot/index.d.ts.map +0 -1
- package/dist/src/vis/lineplot/range/Annotation.d.ts.map +0 -1
- package/dist/src/vis/lineplot/range/Provider.d.ts.map +0 -1
- package/dist/src/vis/lineplot/range/aether/annotation.d.ts.map +0 -1
- package/dist/src/vis/lineplot/range/aether/external.d.ts.map +0 -1
- package/dist/src/vis/lineplot/range/aether/index.d.ts.map +0 -1
- package/dist/src/vis/lineplot/range/aether/provider.d.ts.map +0 -1
- package/dist/src/vis/lineplot/range/external.d.ts.map +0 -1
- package/dist/src/vis/lineplot/range/index.d.ts.map +0 -1
- package/dist/src/vis/lineplot/tooltip/Tooltip.d.ts.map +0 -1
- package/dist/src/vis/lineplot/tooltip/aether/index.d.ts.map +0 -1
- package/dist/src/vis/lineplot/tooltip/aether/tooltip.d.ts.map +0 -1
- package/dist/src/vis/lineplot/tooltip/index.d.ts.map +0 -1
- package/dist/src/vis/lineplot/useBoundQuerier.d.ts.map +0 -1
- package/dist/src/vis/log/Log.d.ts.map +0 -1
- package/dist/src/vis/log/aether/Log.d.ts.map +0 -1
- package/dist/src/vis/log/aether/index.d.ts.map +0 -1
- package/dist/src/vis/log/index.d.ts +0 -2
- package/dist/src/vis/log/index.d.ts.map +0 -1
- package/dist/units-DkdMPsxa.cjs +0 -1
- package/dist/useKeysData-B1kiZOOw.js +0 -14
- package/dist/useKeysData-G9Mk3mA6.cjs +0 -1
- /package/dist/src/{vis/lineplot → lineplot}/aether/external.d.ts +0 -0
- /package/dist/src/{vis/lineplot → lineplot}/aether/index.d.ts +0 -0
- /package/dist/src/{vis/lineplot → lineplot}/index.d.ts +0 -0
- /package/dist/src/{vis/lineplot → lineplot}/range/aether/index.d.ts +0 -0
- /package/dist/src/{vis/lineplot → lineplot}/range/external.d.ts +0 -0
- /package/dist/src/{vis/lineplot → lineplot}/range/index.d.ts +0 -0
- /package/dist/src/{vis/lineplot → lineplot}/tooltip/aether/index.d.ts +0 -0
- /package/dist/src/{vis/lineplot → lineplot}/tooltip/index.d.ts +0 -0
- /package/dist/src/{vis/lineplot → lineplot}/useBoundQuerier.d.ts +0 -0
- /package/dist/src/{vis/log → log}/aether/index.d.ts +0 -0
- /package/dist/src/{vis/diagram → schematic}/edge/connector/connector.d.ts +0 -0
- /package/dist/src/{vis/diagram → schematic}/edge/connector/connector.spec.d.ts +0 -0
- /package/dist/src/{vis/diagram → schematic}/edge/connector/index.d.ts +0 -0
- /package/dist/src/status/{Aggregator.spec.d.ts → core/Aggregator.spec.d.ts} +0 -0
- /package/dist/src/status/{Notification.spec.d.ts → core/Notification.spec.d.ts} +0 -0
- /package/dist/src/status/{colors.d.ts → core/colors.d.ts} +0 -0
package/dist/eraser-h8NIswGM.cjs
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use strict";const s=require("zod"),p=require("./css-CmXY6iPo.cjs"),Os=require("react"),Mc=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)},ai=t=>{const e=(r,n=Ln)=>{if(typeof r=="string")return t(r);if(Array.isArray(r))return r.map(o=>e(o,n));if(!yn(r))return r;n=Dc(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&&(yn(l)?ha(l)||(l=e(l,n)):n.recursiveInArray&&ua(l)&&(l=[...l].map(u=>{let h=u;return yn(u)?ha(h)||(h=e(u,n)):ua(u)&&(h=e({key:u},n).key),h}))),a[c]=l}),a)};return e},ii=ai(Mc),Uc=t=>t.replace(/([a-z0-9])([A-Z])/g,(e,r,n)=>`${r}_${n.toLowerCase()}`),Lc=ai(Uc),Pc=[Number,String,Uint8Array],Ln={recursive:!0,recursiveInArray:!0},Dc=(t=Ln)=>(t.recursive==null?t=Ln:t.recursiveInArray??=!1,t),ua=t=>t!=null&&Array.isArray(t),yn=t=>t!=null&&typeof t=="object"&&!Array.isArray(t),ha=t=>Pc.some(e=>t instanceof e);let $c=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=ii(r);return e!=null?e.parse(n):n}encodeString(t){const e=Lc(t);return JSON.stringify(e,(r,n)=>ArrayBuffer.isView(n)?Array.from(n):typeof n=="bigint"?n.toString():n)}};const Pn=new $c,ne=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 Bc=t=>t!=null&&typeof t=="object"&&"toString"in t,Zc=(t,e=!1)=>{const r=Bc(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?Fc(n):n},Fc=t=>(e,r)=>t(r,e),Fr=s.z.tuple([s.z.number(),s.z.number()]);s.z.tuple([s.z.bigint(),s.z.bigint()]);const oi=s.z.object({width:s.z.number(),height:s.z.number()}),qc=s.z.object({signedWidth:s.z.number(),signedHeight:s.z.number()}),Yc=["width","height"];s.z.enum(Yc);const _c=["start","center","end"],Hc=["signedWidth","signedHeight"];s.z.enum(Hc);const Rr=s.z.object({x:s.z.number(),y:s.z.number()}),Vc=s.z.object({clientX:s.z.number(),clientY:s.z.number()}),Wc=["x","y"],li=s.z.enum(Wc),ci=["top","right","bottom","left"];s.z.enum(ci);const Gc=["left","right"],ui=s.z.enum(Gc),Kc=["top","bottom"],hi=s.z.enum(Kc),di=["center"],da=s.z.enum(di),Jc=[...ci,...di],fi=s.z.enum(Jc);s.z.enum(_c);const Xc=["first","last"];s.z.enum(Xc);const Qc=s.z.object({lower:s.z.number(),upper:s.z.number()}),eu=s.z.object({lower:s.z.bigint(),upper:s.z.bigint()});s.z.union([Qc,Fr]);s.z.union([eu,Fr]);s.z.enum([...li.options,...fi.options]);s.z.enum(["x","left","right"]);s.z.enum(["y","top","bottom"]);s.z.union([li,fi,s.z.instanceof(String)]);const qr=t=>(e,r)=>{if(typeof e=="bigint"){if(tu(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))},Yr=qr((t,e)=>t-e),_r=qr((t,e)=>t+e),tu=t=>typeof t=="bigint"?!0:Number.isInteger(t),pe=qr((t,e)=>t*e),Hr=qr((t,e)=>t/e),He=(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?ru(n):n},ru=t=>t.lower>t.upper?{lower:t.upper,upper:t.lower}:t,fa=(t,e)=>{const r=He(t);return e<r.lower?r.lower:e>=r.upper?r.upper-(typeof r.upper=="number"?1:1n):e};s.z.object({x:ui.or(da),y:hi.or(da)});const nu=s.z.object({x:ui,y:hi}),su=Object.freeze({x:"left",y:"top"}),au=(t,e)=>t.x===e.x&&t.y===e.y,ya=s.z.union([s.z.number(),Rr,Fr,oi,qc,Vc]),iu=(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}},pa=Object.freeze({x:0,y:0}),mr=s.z.union([s.z.number(),s.z.string()]);s.z.object({top:mr,left:mr,width:mr,height:mr});s.z.object({left:s.z.number(),top:s.z.number(),right:s.z.number(),bottom:s.z.number()});s.z.object({one:Rr,two:Rr,root:nu});const zs=(t,e,r=0,n=0,a)=>{const i={one:{...pa},two:{...pa},root:a??su};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))},pn=t=>{const e=zs(t);return{lower:e.one.x,upper:e.two.x}},gn=t=>{const e=zs(t);return{lower:e.one.y,upper:e.two.y}},ou=t=>typeof t!="object"||t==null?!1:"one"in t&&"two"in t&&"root"in t,lu=s.z.object({signedWidth:s.z.number(),signedHeight:s.z.number()});s.z.union([oi,lu,Rr,Fr]);const cu=(t,e,r)=>e!==void 0&&t<e?e:r!==void 0&&t>r?r:t;s.z.object({offset:ya,scale:ya});s.z.object({offset:s.z.number(),scale:s.z.number()});const uu=t=>(e,r,n,a)=>r==="dimension"?[e,n]:[e,a?n-t:n+t],hu=t=>(e,r,n,a)=>[e,a?n/t:n*t],du=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]},fu=t=>(e,r,n)=>[t,n],yu=()=>(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)]},pu=t=>(e,r,n)=>{const{lower:a,upper:i}=t;return n=cu(n,a,i),[e,n]};let ga=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=uu(e);return n.type="translate",r.ops.push(n),r}magnify(e){const r=this.new(),n=hu(e);return n.type="magnify",r.ops.push(n),r}scale(e,r){const n=He(e,r),a=this.new(),i=du(n);return i.type="scale",a.ops.push(i),a}clamp(e,r){const n=He(e,r),a=this.new(),i=pu(n);return i.type="clamp",a.ops.push(i),a}reBound(e,r){const n=He(e,r),a=this.new(),i=fu(n);return i.type="re-bound",a.ops.push(i),a}invert(){const e=yu();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 ga,r=new ga,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=iu(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(ou(e)){const n=this.currRoot;return r.currRoot=e.root,n!=null&&!au(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(pn(e)),r.y=r.y.scale(gn(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(pn(e)),r.y=this.y.reBound(gn(e)),r}clamp(e){const r=this.copy();return r.x=this.x.clamp(pn(e)),r.y=this.y.clamp(gn(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 zs(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 yi=(t,e=21)=>(r=e)=>{let n="",a=r|0;for(;a--;)n+=t[Math.random()*t.length|0];return n};const pi="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",gu=`0123456789${pi}`,mu=11,wu=yi(pi,1),bu=yi(gu,mu-1),vu=()=>`${wu()}${bu()}`,Tu=(t,e)=>r=>r instanceof e||typeof r=="object"&&r!==null&&"discriminator"in r&&r.discriminator===t,Ou=s.z.enum(["static","dynamic"]),zu=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)])]),gi=(t,e)=>{const r=new I(e);if(![A.DAY,A.HOUR,A.MINUTE,A.SECOND,A.MILLISECOND,A.MICROSECOND,A.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 I?new I(n):new A(n)};let I=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)),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 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 A(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 Rt(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(_r(this.valueOf(),new A(e).valueOf()))}sub(e){return new b(Yr(this.valueOf(),new A(e).valueOf()))}get hours(){return Number(this.valueOf())/Number(A.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(A.MINUTE.valueOf())}get days(){return Number(this.valueOf())/Number(A.DAY.valueOf())}get seconds(){return Number(this.valueOf())/Number(A.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 gi(this,e)}get isToday(){return this.truncate(A.DAY).equals(b.now().truncate(A.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 A).transform(e=>new b(e)),zu.transform(e=>new b(e))]);static sort(e,r){return Number(e.valueOf()-r.valueOf())}},A=class v extends bt{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 mn?e.period:e instanceof I?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 mn?e.period:e instanceof I?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 gi(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),E=l.sub(o);let C="";return c.isZero||(C+=`${c.days}d `),u.isZero||(C+=`${u.hours}h `),h.isZero||(C+=`${h.minutes}m `),f.isZero||(C+=`${f.seconds}s `),d.isZero||(C+=`${d.milliseconds}ms `),z.isZero||(C+=`${z.microseconds}µs `),E.isZero||(C+=`${E.nanoseconds}ns`),C.trim()}mult(e){return new v(pe(this.valueOf(),e))}div(e){return new v(Hr(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(pe(e,1e3))}static MICROSECOND=v.microseconds(1);static milliseconds(e=1){return v.microseconds(pe(e,1e3))}static MILLISECOND=v.milliseconds(1);static seconds(e=1){return v.milliseconds(pe(e,1e3))}static SECOND=v.seconds(1);static minutes(e=1){return v.seconds(pe(e,60))}static MINUTE=v.minutes(1);static hours(e){return v.minutes(pe(e,60))}static HOUR=v.hours(1);static days(e){return v.hours(pe(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(I).transform(e=>new v(e)),s.z.custom(e=>e instanceof mn).transform(e=>new v(e))])},mn=class ee extends bt{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 A.seconds(1/this.valueOf())}sampleCount(e){return new A(e).seconds*this.valueOf()}byteCount(e,r){return this.sampleCount(e)*new H(r).valueOf()}span(e){return A.seconds(e/this.valueOf())}byteSpan(e,r){return this.span(e.valueOf()/new H(r).valueOf())}add(e){return new ee(_r(this.valueOf(),new ee(e).valueOf()))}sub(e){return new ee(Yr(this.valueOf(),new ee(e).valueOf()))}mult(e){return new ee(pe(this.valueOf(),e))}div(e){return new ee(Hr(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)])},H=class W extends bt{constructor(e){ne(e)&&(e=e.value),super(e.valueOf())}length(e){return e.valueOf()/this.valueOf()}size(e){return new Dn(e*this.valueOf())}add(e){return new W(_r(this.valueOf(),new W(e).valueOf()))}sub(e){return new W(Yr(this.valueOf(),new W(e).valueOf()))}mult(e){return new W(pe(this.valueOf(),e))}div(e){return new W(Hr(this.valueOf(),e))}static UNKNOWN=new W(0);static BIT128=new W(16);static BIT64=new W(8);static BIT32=new W(4);static BIT16=new W(2);static BIT8=new W(1);static z=s.z.union([s.z.number().transform(e=>new W(e)),s.z.instanceof(W)])},Rt=class oe{start;end;constructor(e,r){typeof e=="object"&&"start"in e?(this.start=new I(e.start),this.end=new I(e.end)):(this.start=new I(e),this.end=new I(r))}get span(){return new A(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=A.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=A.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=I.max(n.start,e.start),i=I.min(n.end,e.end);return i.before(a)?!1:new A(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(I.min(...e.map(r=>r.start)),I.max(...e.map(r=>r.end)))}static MAX=new oe(I.MIN,I.MAX);static MIN=new oe(I.MAX,I.MIN);static ZERO=new oe(I.ZERO,I.ZERO);static z=s.z.union([s.z.object({start:I.z,end:I.z}).transform(e=>new oe(e.start,e.end)),s.z.instanceof(oe)]);static sort(e,r){return I.sort(e.start,r.start)||I.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=I.max(a.end,n.end):r.push(n),r},[])}},D=class g extends bt{constructor(e){if(ne(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(),H.BIT8],[g.UINT16.toString(),H.BIT16],[g.UINT32.toString(),H.BIT32],[g.UINT64.toString(),H.BIT64],[g.FLOAT32.toString(),H.BIT32],[g.FLOAT64.toString(),H.BIT64],[g.INT8.toString(),H.BIT8],[g.INT16.toString(),H.BIT16],[g.INT32.toString(),H.BIT32],[g.INT64.toString(),H.BIT64],[g.TIMESTAMP.toString(),H.BIT64],[g.STRING.toString(),H.UNKNOWN],[g.JSON.toString(),H.UNKNOWN],[g.UUID.toString(),H.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)])},Dn=class N extends bt{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 N(_r(this.valueOf(),e.valueOf()))}sub(e){return ne(e)&&(e=e.value),new N(Yr(this.valueOf(),e.valueOf()))}mult(e){return new N(pe(this.valueOf(),e))}div(e){return new N(Hr(this.valueOf(),e))}truncate(e){return new N(Math.trunc(this.valueOf()/new N(e).valueOf())*new N(e).valueOf())}remainder(e){return N.bytes(this.valueOf()%new N(e).valueOf())}get gigabytes(){return this.valueOf()/N.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/N.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/N.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/N.TERABYTE.valueOf()}toString(){const e=this.truncate(N.TERABYTE),r=this.truncate(N.GIGABYTE),n=this.truncate(N.MEGABYTE),a=this.truncate(N.KILOBYTE),i=this.truncate(N.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 N(e)}static BYTE=new N(1);static kilobytes(e=1){return N.bytes(new N(e).valueOf()*1e3)}static KILOBYTE=N.kilobytes(1);static megabytes(e=1){return N.kilobytes(new N(e).valueOf()*1e3)}static MEGABYTE=N.megabytes(1);static gigabytes(e=1){return N.megabytes(new N(e).valueOf()*1e3)}static GIGABYTE=N.gigabytes(1);static terabytes(e){return N.gigabytes(new N(e).valueOf()*1e3)}static TERABYTE=N.terabytes(1);static ZERO=new N(0);static z=s.z.union([s.z.number().transform(e=>new N(e)),s.z.instanceof(N)]);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 mi=t=>{const e=typeof t;return e==="string"||e==="number"||e==="boolean"||e==="bigint"||t instanceof I||t instanceof A||t instanceof Date},Su=(t,e,r,n=0)=>t.usesBigInt&&!e.usesBigInt?Number(r)-Number(n):!t.usesBigInt&&e.usesBigInt?BigInt(r.valueOf())-BigInt(n.valueOf()):Er(r,-n),Er=(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),Eu=/^(?:[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 Nu(t){return typeof t=="string"&&Eu.test(t)}const F=[];for(let t=0;t<256;++t)F.push((t+256).toString(16).slice(1));function xu(t,e=0){return(F[t[e+0]]+F[t[e+1]]+F[t[e+2]]+F[t[e+3]]+"-"+F[t[e+4]]+F[t[e+5]]+"-"+F[t[e+6]]+F[t[e+7]]+"-"+F[t[e+8]]+F[t[e+9]]+"-"+F[t[e+10]]+F[t[e+11]]+F[t[e+12]]+F[t[e+13]]+F[t[e+14]]+F[t[e+15]]).toLowerCase()}function Au(t,e=0){const r=xu(t,e);if(!Nu(r))throw TypeError("Stringified UUID is invalid");return r}typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const wi=(t,e)=>Au(t,e),Ne=-1,ku=s.z.string().transform(t=>new Uint8Array(atob(t).split("").map(e=>e.charCodeAt(0))).buffer),Cu=s.z.union([s.z.null(),s.z.undefined()]).transform(()=>new Uint8Array().buffer),$n=10,Iu=(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`)},bi="sy_x_telem_series";let vi=class Ce{key;discriminator=bi;dataType;sampleOffset;gl;_data;timeRange=Rt.ZERO;alignment=0n;alignmentMultiple=1n;cachedMin;cachedMax;writePos=Ne;_refCount=0;cachedLength;_cachedIndexes;static crudeZ=s.z.object({timeRange:Rt.z.optional(),dataType:D.z,alignment:s.z.coerce.bigint().optional(),data:s.z.union([ku,Cu,s.z.instanceof(ArrayBuffer),s.z.instanceof(Uint8Array)]),glBufferUsage:Ou.optional().default("static").optional()});static z=Ce.crudeZ.transform(e=>new Ce(e));constructor(e){ju(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=vu(),data:u}=e;if(Ru(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=mi(u),f=Array.isArray(u);if(r!=null)this.dataType=new D(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=D.STRING;else if(typeof d=="number")this.dataType=D.FLOAT64;else if(typeof d=="bigint")this.dataType=D.INT64;else if(typeof d=="boolean")this.dataType=D.BOOLEAN;else if(d instanceof I||d instanceof Date||d instanceof I)this.dataType=D.TIMESTAMP;else if(typeof d=="object")this.dataType=D.JSON;else throw new Error(`cannot infer data type of ${typeof d} when constructing a Series from a JS array`)}else this.dataType=new D(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 I||z instanceof Date||z instanceof A)&&(d=d.map(E=>new I(E).valueOf())),this.dataType.equals(D.STRING)?(this.cachedLength=d.length,this._data=new TextEncoder().encode(`${d.join(`
|
|
2
|
-
`)}
|
|
3
|
-
`).buffer):this.dataType.equals(D.JSON)?(this.cachedLength=d.length,this._data=new TextEncoder().encode(`${d.map(E=>Pn.encodeString(E)).join(`
|
|
4
|
-
`)}
|
|
5
|
-
`).buffer):this.dataType.usesBigInt&&typeof z=="number"?this._data=new this.dataType.Array(d.map(E=>BigInt(Math.round(E)))).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??Rt.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 D(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(D.JSON))throw new Error("cannot parse non-JSON series as JSON");return this.toStrings().map(r=>e.parse(Pn.decodeString(r)))}get byteCapacity(){return new Dn(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 Dn(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===$n&&(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]=Su(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(D.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(),Er(this.cachedMax,this.sampleOffset))}calcRawMin(){if(this.length===0)return 1/0;if(this.dataType.equals(D.TIMESTAMP))this.cachedMin=this.data[0];else if(this.dataType.usesBigInt){const e=this.data;this.cachedMin=e.reduce((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(),Er(this.cachedMin,this.sampleOffset))}get bounds(){return He(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(D.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 Er(n,this.sampleOffset)}atUUID(e,r){e<0&&(e=this.length+e);const n=wi(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]===$n){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(D.STRING)?new TextDecoder().decode(i):ii(JSON.parse(new TextDecoder().decode(i)))}binarySearch(e){let r=0,n=this.length-1;const a=Zc(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(D.FLOAT32)&&!this.dataType.equals(D.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 Iu(e,this.dataType),this}get digest(){return{key:this.key,dataType:this.dataType.toString(),sampleOffset:this.sampleOffset,alignment:{lower:wa(this.alignmentBounds.lower),upper:wa(this.alignmentBounds.upper),multiple:this.alignmentMultiple},timeRange:this.timeRange.toString(),length:this.length,capacity:this.capacity}}get alignmentBounds(){return He(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 Mu(this);return this.dataType.equals(D.JSON)?new Uu(e):e}return this.dataType.equals(D.UUID)?new Lu(this):new Pu(this)}slice(e,r){return this.sliceSub(!1,e,r)}sub(e,r){return this.sliceSub(!0,e,r)}subIterator(e,r){return new ma(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 ma(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:Rt.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 ju=t=>t==null?!1:Array.isArray(t)||t instanceof ArrayBuffer||ArrayBuffer.isView(t)&&!(t instanceof DataView)||t instanceof vi?!0:mi(t),Ru=Tu(bi,vi);let ma=class{series;end;index;constructor(t,e,r){this.series=t;const n=He(0,t.length+1);this.end=fa(n,r),this.index=fa(n,e)}next(){return this.index>=this.end?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}};class Mu{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]!==$n;)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 Uu=class Ti{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:Pn.decodeString(e.value,Ti.schema)}}},Lu=class{series;index;data;density;constructor(t){if(!t.dataType.equals(D.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=D.UUID.density.valueOf()}next(){if(this.index>=this.series.length)return{done:!0,value:void 0};const t=wi(this.data,this.index*this.density);return this.index++,{done:!1,value:t}}};class Pu{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 wa=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 Du=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser";Du();const $u=["macOS","Windows","Linux"],Bu=["macos","windows","linux"],Zu={macos:"macOS",windows:"Windows",linux:"Linux"};s.z.enum($u).or(s.z.enum(Bu).transform(t=>Zu[t]));const Fu=(...t)=>t.map(Oi).join(""),Oi=t=>(t.endsWith("/")||(t+="/"),t.startsWith("/")&&(t=t.slice(1)),t),qu=t=>t.endsWith("/")?t.slice(0,-1):t,Yu=(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 _u=class Nr{protocol;host;port;path;constructor({host:e,port:r,protocol:n="",pathPrefix:a=""}){this.protocol=n,this.host=e,this.port=r,this.path=Oi(a)}replace(e){return new Nr({host:e.host??this.host,port:e.port??this.port,protocol:e.protocol??this.protocol,pathPrefix:e.pathPrefix??this.path})}child(e){return new Nr({...this,pathPrefix:Fu(this.path,e)})}toString(){return qu(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}static UNKNOWN=new Nr({host:"unknown",port:0})};const Hu=async t=>await new Promise(e=>setTimeout(e,A.fromMilliseconds(t).milliseconds));class Vu{config;retries;interval;constructor(e){this.config={baseInterval:new A(e?.baseInterval??A.seconds(1)),maxRetries:e?.maxRetries??5,scale:e?.scale??1,sleepFn:e?.sleepFn??Hu},this.retries=0,this.interval=new A(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 Wu=s.z.object({baseInterval:A.z.optional(),maxRetries:s.z.number().optional(),scale:s.z.number().optional()}),Gu=Object.freeze(Object.defineProperty({__proto__:null,Breaker:Vu,breakerConfigZ:Wu},Symbol.toStringTag,{value:"Module"})),Ku=/^#?([0-9a-f]{6}|[0-9a-f]{8})$/i,zi=s.z.string().regex(Ku),ut=s.z.number().min(0).max(255),Si=s.z.number().min(0).max(1),Ei=s.z.tuple([ut,ut,ut,Si]),Ju=s.z.tuple([ut,ut,ut]),Xu=s.z.object({rgba255:Ei}),Qu=s.z.number().min(0).max(360),eh=s.z.number().min(0).max(100),th=s.z.number().min(0).max(100),rh=s.z.tuple([Qu,eh,th,Si]),Ss=s.z.union([zi,Ju,Ei,rh,Xu]),nh=Ss.transform(t=>Es(t)),Es=(t,e=1)=>{if(t=Ss.parse(t),typeof t=="string")return sh(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},sh=(t,e=1)=>(t=zi.parse(t),t=ah(t),[wr(t,0),wr(t,2),wr(t,4),t.length===8?wr(t,6)/255:e]),wr=(t,e)=>parseInt(t.slice(e,e+2),16),ah=t=>t.startsWith("#")?t.slice(1):t;Es("#000000");Es("#ffffff");const ih=s.z.object({key:s.z.string(),color:Ss,position:s.z.number(),switched:s.z.boolean().optional()});s.z.array(ih);const oh=s.z.object({key:s.z.string(),name:s.z.string(),color:nh});s.z.object({key:s.z.string(),name:s.z.string(),swatches:s.z.array(oh)});s.z.int().min(0).max(255);s.z.object({name:s.z.string(),key:s.z.string()});const lh=t=>Object.getOwnPropertySymbols(globalThis).includes(t),ch=(t,e)=>{const r=Symbol.for(t);if(!lh(r)){const n=e();Object.defineProperty(globalThis,r,{value:n})}return()=>globalThis[r]},Ni="sy_x_error",uh=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),er=t=>class Mt extends Error{static discriminator=Ni;discriminator=Mt.discriminator;static TYPE=t;type=Mt.TYPE;static matches=uh(t);matches=Mt.matches;constructor(r,n){super(r,n),this.name=Mt.TYPE}static sub(r){return er(`${t}.${r}`)}},xi=t=>{if(t==null||typeof t!="object")return!1;const e=t;if(e.discriminator!==Ni)return!1;if(!("type"in e))throw new Error(`X Error is missing its type property: ${JSON.stringify(e)}`);return!0},rt="unknown",Bn="nil";class hh{providers=[];register(e){this.providers.push(e)}encode(e){if(e==null)return{type:Bn,data:""};if(xi(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===Bn)return null;if(e.type===rt)return new Zn(e.data);for(const r of this.providers){const n=r.decode(e);if(n!=null)return n}return new Zn(e.data)}}const Ns=ch("synnax-error-registry",()=>new hh),dh=({encode:t,decode:e})=>Ns().register({encode:t,decode:e}),fh=t=>Ns().encode(t),yh=t=>t==null?null:Ns().decode(t);let Zn=class extends er("unknown"){};const ph=s.z.object({type:s.z.string(),data:s.z.string()});class gh extends er("canceled"){}class mh extends er("not_implemented"){}const Pe=Object.freeze(Object.defineProperty({__proto__:null,Canceled:gh,NONE:Bn,NotImplemented:mh,UNKNOWN:rt,Unknown:Zn,createTyped:er,decode:yh,encode:fh,isTyped:xi,payloadZ:ph,register:dh},Symbol.toStringTag,{value:"Module"})),wh=s.object({jsonrpc:s.literal("2.0"),method:s.string(),params:s.any().optional(),id:s.union([s.string(),s.number(),s.null()]).optional()}),Ai=s.object({jsonrpc:s.literal("2.0"),id:s.union([s.string(),s.number(),s.null()])}),bh=Ai.extend({result:s.json()}),vh=Ai.extend({error:s.object({code:s.number().int(),message:s.string().optional(),data:s.json().optional()})}),Th=s.union([bh,vh]);s.union([wh,Th]);s.z.string().regex(/^\d+\.\d+\.\d+$/);const Oh=["standard","scientific","engineering"];s.z.enum(Oh);s.z.enum(["success","info","warning","error","loading","disabled"]);let tr=class extends Pe.createTyped("freighter"){},ue=class extends tr.sub("eof"){constructor(){super("EOF")}},dt=class extends tr.sub("stream_closed"){constructor(){super("StreamClosed")}},De=class extends tr.sub("unreachable"){url;constructor(t={}){const{message:e="Unreachable",url:r=_u.UNKNOWN}=t;super(e),this.url=r}};const zh=t=>{if(!t.type.startsWith(tr.TYPE))return null;if(ue.matches(t))return{type:ue.TYPE,data:"EOF"};if(dt.matches(t))return{type:dt.TYPE,data:"StreamClosed"};if(De.matches(t))return{type:De.TYPE,data:"Unreachable"};throw new Error(`Unknown error type: ${t.type}: ${t.message}`)},Sh=t=>{if(!t.type.startsWith(tr.TYPE))return null;switch(t.type){case ue.TYPE:return new ue;case dt.TYPE:return new dt;case De.TYPE:return new De;default:throw new Pe.Unknown(`Unknown error type: ${t.data}`)}};Pe.register({encode:zh,decode:Sh});class ki{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 Ci="Content-Type",Eh=new Set(["ECONNREFUSED","ECONNRESET","ETIMEDOUT","EPIPE","UND_ERR_CONNECT_TIMEOUT","UND_ERR_SOCKET"]),Nh=t=>{const e=t?.cause?.code??t?.code??t?.errno;if(typeof e=="string"&&Eh.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},xh=400;class Ah extends ki{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{[Ci]: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,Nh(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!==xh)return[h,new Error(f.statusText)];const z=this.encoder.decode(d,Pe.payloadZ),E=Pe.decode(z);return[h,E]}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 kh=(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 Gu.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)},w=async(t,e,r,n,a)=>{const[i,o]=await t.send(e,r,n,a);if(o!=null)throw o;return i},Ch=s.z.object({type:s.z.enum(["data","close","open"]),payload:s.z.unknown(),error:s.z.optional(Pe.payloadZ)});class Ih{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 dt;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,Ch))}onClose(e){this.addMessage({type:"close",error:{type:e.code===Rh?ue.TYPE:dt.TYPE,data:""}})}}const jh="freighterctx",Rh=1e3;class Mr extends ki{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 Mr(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=Mr.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=Yu({[Ci]:this.encoder.contentType,...r.params},jh);return this.baseUrl.child(e).toString()+n}async wrapSocket(e,r,n){return await new Promise(a=>{e.onopen=()=>{const i=new Ih(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 Mh=t=>Array.isArray(t)?t:t==null?[]:[t],O=Object.freeze(Object.defineProperty({__proto__:null,toArray:Mh},Symbol.toStringTag,{value:"Module"})),Uh=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)},Vr=t=>{const e=(r,n=Fn)=>{if(typeof r=="string")return t(r);if(Array.isArray(r))return r.map(o=>e(o,n));if(!wn(r))return r;n=Dh(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&&(wn(l)?va(l)||(l=e(l,n)):n.recursiveInArray&&ba(l)&&(l=[...l].map(u=>{let h=u;return wn(u)?va(h)||(h=e(u,n)):ba(u)&&(h=e({key:u},n).key),h}))),a[c]=l}),a)};return e},xs=Vr(Uh),Lh=t=>t.replace(/([a-z0-9])([A-Z])/g,(e,r,n)=>`${r}_${n.toLowerCase()}`),Ii=Vr(Lh),ji=t=>t.length===0?t:t[0].toUpperCase()+t.slice(1),Ph=[Number,String,Uint8Array],Fn={recursive:!0,recursiveInArray:!0},Dh=(t=Fn)=>(t.recursive==null?t=Fn:t.recursiveInArray??=!1,t),ba=t=>t!=null&&Array.isArray(t),wn=t=>t!=null&&typeof t=="object"&&!Array.isArray(t),va=t=>Ph.some(e=>t instanceof e),$h=t=>t.replace(/\s+/g,"-").replace(/([a-z0-9])([A-Z])/g,(e,r,n)=>`${r}-${n.toLowerCase()}`).toLowerCase(),Bh=Vr($h),Zh=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},Fh=Vr(Zh),qh=Object.freeze(Object.defineProperty({__proto__:null,camelToSnake:Ii,capitalize:ji,snakeToCamel:xs,toKebab:Bh,toProperNoun:Fh},Symbol.toStringTag,{value:"Module"})),Ri=t=>t!=null&&typeof t=="object"&&!Array.isArray(t);let Mi=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=xs(r);return e!=null?e.parse(n):n}encodeString(t){const e=Ii(t);return JSON.stringify(e,(r,n)=>ArrayBuffer.isView(n)?Array.from(n):typeof n=="bigint"?n.toString():n)}},Ui=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||!Ri(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}},Li=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 Zt=new Mi,Yh=new Ui,_h=new Li,Hh=[Zt],Ke=Object.freeze(Object.defineProperty({__proto__:null,CSVCodec:Ui,CSV_CODEC:Yh,ENCODERS:Hh,JSONCodec:Mi,JSON_CODEC:Zt,TEXT_CODEC:_h,TextCodec:Li},Symbol.toStringTag,{value:"Module"})),qn=t=>[...new Set(t)],Vh=(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())},Ta=Object.freeze(Object.defineProperty({__proto__:null,by:Vh,unique:qn},Symbol.toStringTag,{value:"Module"})),se=t=>t!=null&&typeof t=="object"&&"value"in t;let vt=class{value;constructor(t){this.value=t}valueOf(){return this.value}toJSON(){return this.value}toString(){return this.value.toString()}};const Wh=t=>t!=null&&typeof t=="object"&&"toString"in t,Wr=(t,e=!1)=>{const r=Wh(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?Di(n):n},Gh=(t,e,r)=>{const n=Wr(e[t],r);return(a,i)=>n(a[t],i[t])},Kh=(t,e)=>t.length!==e.length?t.length-e.length:t.every((r,n)=>r===e[n])?0:-1,Pi=(t,e)=>{if(t.length!==e.length)return t.length-e.length;if(t.length===0)return 0;const r=Wr(t[0]),n=[...t].sort(r),a=[...e].sort(r);return n.every((i,o)=>i===a[o])?0:-1},Jh=(t,e)=>{const r=qn(t),n=qn(e);return Pi(r,n)},Xh=(t,e)=>t===e?0:t==="first"&&e==="last"?1:-1,Di=t=>(e,r)=>t(r,e),Tt=0,xr=-1,Ar=1,$i=t=>t<Tt,Bi=t=>t>Tt,Qh=t=>t>=Tt,Zi=t=>t===Tt,ed=(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},Oa=Object.freeze(Object.defineProperty({__proto__:null,EQUAL:Tt,GREATER_THAN:Ar,LESS_THAN:xr,isEqualTo:Zi,isGreaterThan:Bi,isGreaterThanEqual:Qh,isLessThan:$i,newF:Wr,newFieldF:Gh,order:Xh,primitiveArrays:Kh,reverseF:Di,stringsWithNumbers:ed,uniqueUnorderedPrimitiveArrays:Jh,unorderedPrimitiveArrays:Pi},Symbol.toStringTag,{value:"Module"})),Gr=s.z.tuple([s.z.number(),s.z.number()]);s.z.tuple([s.z.bigint(),s.z.bigint()]);const Fi=s.z.object({width:s.z.number(),height:s.z.number()}),td=s.z.object({signedWidth:s.z.number(),signedHeight:s.z.number()}),rd=["width","height"];s.z.enum(rd);const nd=["start","center","end"],sd=["signedWidth","signedHeight"];s.z.enum(sd);const Ft=s.z.object({x:s.z.number(),y:s.z.number()}),qi=s.z.object({clientX:s.z.number(),clientY:s.z.number()}),Yi=["x","y"],_i=s.z.enum(Yi),As=["top","right","bottom","left"],ad=s.z.enum(As),Hi=["left","right"],ks=s.z.enum(Hi),Vi=["top","bottom"],Cs=s.z.enum(Vi),Is=["center"],Yn=s.z.enum(Is),id=[...As,...Is],js=s.z.enum(id);s.z.enum(nd);const od=["first","last"];s.z.enum(od);const ld=s.z.object({lower:s.z.number(),upper:s.z.number()}),cd=s.z.object({lower:s.z.bigint(),upper:s.z.bigint()});s.z.union([ld,Gr]);s.z.union([cd,Gr]);s.z.enum([..._i.options,...js.options]);s.z.enum(["x","left","right"]);s.z.enum(["y","top","bottom"]);const ud=s.z.union([_i,js,s.z.instanceof(String)]),rr=t=>(e,r)=>{if(typeof e=="bigint"){if(Wi(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=rr((t,e)=>t-e),nr=rr((t,e)=>t+e),za=(t,e)=>{const r=typeof t=="bigint";return r&&typeof e=="bigint"?t===e:r&&Wi(e)?t===BigInt(e):t===e},hd=rr((t,e)=>t<=e?t:e),Wi=t=>typeof t=="bigint"?!0:Number.isInteger(t),dd=t=>typeof t=="bigint"?t<0n?-t:t:t<0?-t:t,ge=rr((t,e)=>t*e),Kr=rr((t,e)=>t/e),Y=(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?fd(n):n},fd=t=>t.lower>t.upper?{lower:t.upper,upper:t.lower}:t,Sa=(t,e)=>{const r=Y(t);return e<r.lower?r.lower:e>=r.upper?r.upper-(typeof r.upper=="number"?1:1n):e},br=(t,e)=>{const r=Y(t);if(typeof e=="number"||typeof e=="bigint")return e>=r.lower&&e<r.upper;const n=Y(e);return n.lower>=r.lower&&n.upper<=r.upper},yd=t=>({lower:Math.min(...t.map(e=>Y(e).lower)),upper:Math.max(...t.map(e=>Y(e).upper))}),pd=(t,e,r)=>{const n=t.map(l=>Y(l)),a=r>0?1:r<0?-1:0;if(a===0)return e;let i=r,o=e;for(;za(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=hd(dd(i),u);if(o=nr(o,a>0?h:-h),i=Ve(i,a>0?h:-h),za(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},gd=(t,e,r)=>{const n=t.map(o=>Y(o));if(e===r)return typeof e=="bigint"?0n:0;const a=e<r?Y([e,r]):Y([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},md=ks,wd=Cs,bd=Yn,vd={top:"bottom",right:"left",bottom:"top",left:"right",center:"center"},Td={top:"left",right:"top",bottom:"right",left:"bottom",center:"center"},Od=ud,$e=t=>t instanceof String||!Yi.includes(t)?t:t==="x"?"left":"top",zd=t=>vd[$e(t)],Sd=t=>Td[$e(t)],qt=t=>{const e=$e(t);return e==="top"||e==="bottom"?"y":"x"},Ed=s.z.object({x:ks.or(Yn),y:Cs.or(Yn)}),Gi=s.z.object({x:ks,y:Cs}),Rs=Object.freeze({x:"left",y:"top"}),Ki=Object.freeze({x:"right",y:"top"}),Ji=Object.freeze({x:"left",y:"bottom"}),Xi=Object.freeze({x:"right",y:"bottom"}),Ms=Object.freeze({x:"center",y:"center"}),Qi=Object.freeze({x:"center",y:"top"}),eo=Object.freeze({x:"center",y:"bottom"}),to=Object.freeze({x:"right",y:"center"}),ro=Object.freeze({x:"left",y:"center"}),Nd=Object.freeze([ro,to,Qi,eo,Rs,Ki,Ji,Xi,Ms]),no=(t,e)=>t.x===e.x&&t.y===e.y,xd=(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},Ad=t=>[t.x,t.y],kr=t=>qt($e(t))==="x",kd=t=>qt($e(t))==="y",Cd=t=>`${t.x}${ji(t.y)}`,Id=(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)),qt(r)===qt(n)&&r!=="center"&&n!=="center")throw new Error(`[XYLocation] - encountered two locations with the same direction: ${r.toString()} - ${n.toString()}`);const a={...Ms};return r==="center"?kr(n)?[a.x,a.y]=[n,r]:[a.x,a.y]=[r,n]:n==="center"?kr(r)?[a.x,a.y]=[r,n]:[a.x,a.y]=[n,r]:kr(r)?[a.x,a.y]=[r,n]:[a.x,a.y]=[n,r],a},jd=Object.freeze(Object.defineProperty({__proto__:null,BOTTOM_CENTER:eo,BOTTOM_LEFT:Ji,BOTTOM_RIGHT:Xi,CENTER:Ms,CENTER_LEFT:ro,CENTER_LOCATIONS:Is,CENTER_RIGHT:to,OUTER_LOCATIONS:As,TOP_CENTER:Qi,TOP_LEFT:Rs,TOP_RIGHT:Ki,XY_LOCATIONS:Nd,X_LOCATIONS:Hi,Y_LOCATIONS:Vi,center:bd,construct:$e,constructXY:Id,corner:Gi,crude:Od,direction:qt,isX:kr,isY:kd,location:js,outer:ad,rotate90:Sd,swap:zd,x:md,xy:Ed,xyCouple:Ad,xyEquals:no,xyMatches:xd,xyToString:Cd,y:wd},Symbol.toStringTag,{value:"Module"})),_n=s.z.union([s.z.number(),Ft,Gr,Fi,td,qi]),M=(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}),Rd=Object.freeze({x:1,y:1}),Md=Object.freeze({x:1/0,y:1/0}),Ud=Object.freeze({x:NaN,y:NaN}),so=(t,e,r=0)=>{const n=M(t),a=M(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},Ld=t=>so(t,Ge),Us=(t,e,r)=>{const n=M(t),a=M(e,r);return{x:n.x*a.x,y:n.y*a.y}},ao=(t,e)=>{const r=M(t);return{x:r.x+e,y:r.y}},io=(t,e)=>{const r=M(t);return{x:r.x,y:r.y+e}},oo=(t,e,r,...n)=>{if(typeof e=="string"){if(typeof r!="number")throw new Error("The value must be a number.");return e==="x"?ao(t,r):io(t,r)}if(typeof e=="object"&&"x"in e&&typeof e.x=="string"){const a=M(r),i=M(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=M(i);return{x:a.x+o.x,y:a.y+o.y}},Ge)},Pd=(t,e,r)=>{const n=M(t);return e==="x"?{x:r,y:n.y}:{x:n.x,y:r}},Dd=(t,e)=>{const r=M(t),n=M(e);return Math.sqrt((r.x-n.x)**2+(r.y-n.y)**2)},$d=(t,e)=>{const r=M(t),n=M(e);return{x:n.x-r.x,y:n.y-r.y}},Bd=t=>{const e=M(t);return Number.isNaN(e.x)||Number.isNaN(e.y)},Zd=t=>{const e=M(t);return Number.isFinite(e.x)&&Number.isFinite(e.y)},Fd=t=>{const e=M(t);return[e.x,e.y]},qd=t=>{const e=M(t);return{left:e.x,top:e.y}},Yd=(t,e=0)=>{const r=M(t);return{x:Number(r.x.toFixed(e)),y:Number(r.y.toFixed(e))}},Ut=(t,e)=>{const r=M(t),n=M(e);return{x:r.x-n.x,y:r.y-n.y}},Lt=t=>{const e=M(t),r=Math.hypot(e.x,e.y);return r===0?{x:0,y:0}:{x:-e.y/r,y:e.x/r}},lo=t=>{const e=M(t),r=Math.hypot(e.x,e.y);return r===0?{x:0,y:0}:{x:e.x/r,y:e.y/r}},co=(...t)=>{const e=t.reduce((r,n)=>oo(r,n),Ge);return Us(e,1/t.length)},_d=(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=Ut(u,a);o=Lt(h),l=o,c=e}else if(n===t.length-1){const u=t[n-1],h=Ut(a,u);i=Lt(h),l=i,c=e}else{const u=t[n-1],h=t[n+1],f=Ut(a,u),d=Ut(h,a);i=Lt(f),o=Lt(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))),E=Math.sin(z/2);E===0?c=e:c=e/E,l=lo(co(i,o))}r.push(Us(l,c))}return r},Hd=t=>{const e=M(t);return{x:e.y,y:e.x}},Vd=t=>{const e=M(t);return{x:Math.round(e.x),y:Math.round(e.y)}},uo=Object.freeze(Object.defineProperty({__proto__:null,INFINITY:Md,NAN:Ud,ONE:Rd,ZERO:Ge,average:co,calculateMiters:_d,clientXY:qi,construct:M,couple:Fd,crudeZ:_n,css:qd,distance:Dd,equals:so,isFinite:Zd,isNan:Bd,isZero:Ld,normal:Lt,normalize:lo,round:Vd,scale:Us,set:Pd,sub:Ut,swap:Hd,translate:oo,translateX:ao,translateY:io,translation:$d,truncate:Yd,xy:Ft},Symbol.toStringTag,{value:"Module"})),vr=s.z.union([s.z.number(),s.z.string()]);s.z.object({top:vr,left:vr,width:vr,height:vr});s.z.object({left:s.z.number(),top:s.z.number(),right:s.z.number(),bottom:s.z.number()});s.z.object({one:Ft,two:Ft,root:Gi});const Ls=(t,e,r=0,n=0,a)=>{const i={one:{...Ge},two:{...Ge},root:a??Rs};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))},bn=t=>{const e=Ls(t);return{lower:e.one.x,upper:e.two.x}},vn=t=>{const e=Ls(t);return{lower:e.one.y,upper:e.two.y}},Wd=t=>typeof t!="object"||t==null?!1:"one"in t&&"two"in t&&"root"in t,Gd=s.z.object({signedWidth:s.z.number(),signedHeight:s.z.number()});s.z.union([Fi,Gd,Ft,Gr]);const Kd=(t,e,r)=>e!==void 0&&t<e?e:r!==void 0&&t>r?r:t;s.z.object({offset:_n,scale:_n});s.z.object({offset:s.z.number(),scale:s.z.number()});const Jd=t=>(e,r,n,a)=>r==="dimension"?[e,n]:[e,a?n-t:n+t],Xd=t=>(e,r,n,a)=>[e,a?n/t:n*t],Qd=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]},ef=t=>(e,r,n)=>[t,n],tf=()=>(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)]},rf=t=>(e,r,n)=>{const{lower:a,upper:i}=t;return n=Kd(n,a,i),[e,n]};let Ea=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=Jd(e);return n.type="translate",r.ops.push(n),r}magnify(e){const r=this.new(),n=Xd(e);return n.type="magnify",r.ops.push(n),r}scale(e,r){const n=Y(e,r),a=this.new(),i=Qd(n);return i.type="scale",a.ops.push(i),a}clamp(e,r){const n=Y(e,r),a=this.new(),i=rf(n);return i.type="clamp",a.ops.push(i),a}reBound(e,r){const n=Y(e,r),a=this.new(),i=ef(n);return i.type="re-bound",a.ops.push(i),a}invert(){const e=tf();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 ye{x;y;currRoot;constructor(e=new Ea,r=new Ea,n=null){this.x=e,this.y=r,this.currRoot=n}static translate(e,r){return new ye().translate(e,r)}static translateX(e){return new ye().translateX(e)}static translateY(e){return new ye().translateY(e)}static clamp(e){return new ye().clamp(e)}static magnify(e){return new ye().magnify(e)}static scale(e){return new ye().scale(e)}static reBound(e){return new ye().reBound(e)}translate(e,r){const n=M(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(Wd(e)){const n=this.currRoot;return r.currRoot=e.root,n!=null&&!no(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(bn(e)),r.y=r.y.scale(vn(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(bn(e)),r.y=this.y.reBound(vn(e)),r}clamp(e){const r=this.copy();return r.x=this.x.clamp(bn(e)),r.y=this.y.clamp(vn(e)),r}copy(){const e=new ye;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 Ls(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 ye});let ho=(t,e=21)=>(r=e)=>{let n="",a=r|0;for(;a--;)n+=t[Math.random()*t.length|0];return n};const fo="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",nf=`0123456789${fo}`,yo=11,sf=ho(fo,1),af=ho(nf,yo-1),Ps=()=>`${sf()}${af()}`,of=Object.freeze(Object.defineProperty({__proto__:null,LENGTH:yo,create:Ps},Symbol.toStringTag,{value:"Module"})),lf=(t,e)=>r=>r instanceof e||typeof r=="object"&&r!==null&&"discriminator"in r&&r.discriminator===t,cf=s.z.enum(["static","dynamic"]),uf=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)])]),po=(t,e)=>{const r=new y(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 y?new y(n):new S(n)};class y extends vt{constructor(e,r="UTC"){if(e==null)super(y.now().valueOf());else if(e instanceof Date)super(BigInt(e.getTime())*y.MILLISECOND.valueOf());else if(typeof e=="string")super(y.parseDateTimeString(e,r).valueOf());else if(Array.isArray(e))super(y.parseDate(e));else{let n=0n;e instanceof Number&&(e=e.valueOf()),r==="local"&&(n=y.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=y.MAX:e=y.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 y(BigInt(a.getTime())*y.MILLISECOND.valueOf()).truncate(y.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=y.hours(parseInt(n??"00")).add(y.minutes(parseInt(a??"00"))).add(y.seconds(parseInt(o??"00"))).add(y.milliseconds(parseInt(l??"00")));return r==="local"&&(c=c.add(y.utcOffset)),c.valueOf()}static parseDateTimeString(e,r="UTC"){if(!e.includes("/")&&!e.includes("-"))return y.parseTimeString(e,r);const n=new Date(e);return e.includes(":")||n.setUTCHours(0,0,0,0),new y(BigInt(n.getTime())*y.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(y.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())*y.MINUTE.valueOf())}static since(e){return new y().span(e)}date(){return new Date(this.milliseconds)}equals(e){return this.valueOf()===new y(e).valueOf()}span(e){return this.range(e).span}range(e){return new L(this,e).makeValid()}spanRange(e){return this.range(this.add(e)).makeValid()}get isZero(){return this.valueOf()===0n}after(e){return this.valueOf()>new y(e).valueOf()}afterEq(e){return this.valueOf()>=new y(e).valueOf()}before(e){return this.valueOf()<new y(e).valueOf()}beforeEq(e){return this.valueOf()<=new y(e).valueOf()}add(e){return new y(nr(this.valueOf(),new S(e).valueOf()))}sub(e){return new y(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(y.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(y.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 y(r)}get month(){return this.date().getUTCMonth()}setMonth(e){const r=this.date();return r.setUTCMonth(e),new y(r)}get day(){return this.date().getUTCDate()}setDay(e){const r=this.date();return r.setUTCDate(e),new y(r)}get hour(){return this.date().getUTCHours()}get localHour(){return this.date().getHours()}setLocalHour(e){const r=this.date();return r.setHours(e),new y(r)}setHour(e){const r=this.date();return r.setUTCHours(e),new y(r)}get minute(){return this.date().getUTCMinutes()}setMinute(e){const r=this.date();return r.setUTCMinutes(e),new y(r)}get second(){return this.date().getUTCSeconds()}setSecond(e){const r=this.date();return r.setUTCSeconds(e),new y(r)}get millisecond(){return this.date().getUTCMilliseconds()}setMillisecond(e){const r=this.date();return r.setUTCMilliseconds(e),new y(r)}toString(){return this.date().toISOString()}remainder(e){return po(this,e)}get isToday(){return this.truncate(S.DAY).equals(y.now().truncate(S.DAY))}truncate(e){return this.sub(this.remainder(e))}static now(){return new y(new Date)}static max(...e){let r=y.MIN;for(const n of e){const a=new y(n);a.after(r)&&(r=a)}return r}static min(...e){let r=y.MAX;for(const n of e){const a=new y(n);a.before(r)&&(r=a)}return r}static nanoseconds(e,r="UTC"){return new y(e,r)}static NANOSECOND=y.nanoseconds(1);static microseconds(e,r="UTC"){return y.nanoseconds(e*1e3,r)}static MICROSECOND=y.microseconds(1);static milliseconds(e,r="UTC"){return y.microseconds(e*1e3,r)}static MILLISECOND=y.milliseconds(1);static seconds(e,r="UTC"){return y.milliseconds(e*1e3,r)}static SECOND=y.seconds(1);static minutes(e,r="UTC"){return y.seconds(e*60,r)}static MINUTE=y.minutes(1);static hours(e,r="UTC"){return y.minutes(e*60,r)}static HOUR=y.hours(1);static days(e,r="UTC"){return y.hours(e*24,r)}static DAY=y.days(1);static MAX=new y((1n<<63n)-1n);static MIN=new y(0);static ZERO=new y(0);static z=s.z.union([s.z.instanceof(y),s.z.object({value:s.z.bigint()}).transform(e=>new y(e.value)),s.z.string().transform(e=>new y(BigInt(e))),s.z.number().transform(e=>new y(e)),s.z.bigint().transform(e=>new y(e)),s.z.date().transform(e=>new y(e)),s.z.custom(e=>e instanceof S).transform(e=>new y(e)),uf.transform(e=>new y(e))]);static sort(e,r){return Number(e.valueOf()-r.valueOf())}}let S=class T extends vt{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 Tn?e.period:e instanceof y?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 Tn?e.period:e instanceof y?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 po(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),E=l.sub(o);let C="";return c.isZero||(C+=`${c.days}d `),u.isZero||(C+=`${u.hours}h `),h.isZero||(C+=`${h.minutes}m `),f.isZero||(C+=`${f.seconds}s `),d.isZero||(C+=`${d.milliseconds}ms `),z.isZero||(C+=`${z.microseconds}µs `),E.isZero||(C+=`${E.nanoseconds}ns`),C.trim()}mult(e){return new T(ge(this.valueOf(),e))}div(e){return new T(Kr(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(y).transform(e=>new T(e)),s.z.custom(e=>e instanceof Tn).transform(e=>new T(e))])},Tn=class te extends vt{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 V(r).valueOf()}span(e){return S.seconds(e/this.valueOf())}byteSpan(e,r){return this.span(e.valueOf()/new V(r).valueOf())}add(e){return new te(nr(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(Kr(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)])},V=class G extends vt{constructor(e){se(e)&&(e=e.value),super(e.valueOf())}length(e){return e.valueOf()/this.valueOf()}size(e){return new ft(e*this.valueOf())}add(e){return new G(nr(this.valueOf(),new G(e).valueOf()))}sub(e){return new G(Ve(this.valueOf(),new G(e).valueOf()))}mult(e){return new G(ge(this.valueOf(),e))}div(e){return new G(Kr(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)])},L=class le{start;end;constructor(e,r){typeof e=="object"&&"start"in e?(this.start=new y(e.start),this.end=new y(e.end)):(this.start=new y(e),this.end=new y(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=y.max(n.start,e.start),i=y.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(y.min(...e.map(r=>r.start)),y.max(...e.map(r=>r.end)))}static MAX=new le(y.MIN,y.MAX);static MIN=new le(y.MAX,y.MIN);static ZERO=new le(y.ZERO,y.ZERO);static z=s.z.union([s.z.object({start:y.z,end:y.z}).transform(e=>new le(e.start,e.end)),s.z.instanceof(le)]);static sort(e,r){return y.sort(e.start,r.start)||y.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=y.max(a.end,n.end):r.push(n),r},[])}},k=class m extends vt{constructor(e){if(se(e)&&(e=e.value),e instanceof m||typeof e=="string"||typeof e.valueOf()=="string")super(e.valueOf());else{const r=m.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=m.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(m.JSON)||this.equals(m.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(m.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=m.DENSITIES.get(this.toString());if(e==null)throw new Error(`unable to find density for ${this.valueOf()}`);return e}get isUnsignedInteger(){return this.equals(m.UINT8)||this.equals(m.UINT16)||this.equals(m.UINT32)||this.equals(m.UINT64)}get isSignedInteger(){return this.equals(m.INT8)||this.equals(m.INT16)||this.equals(m.INT32)||this.equals(m.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(m.INT32)&&e.equals(m.FLOAT64)||this.equals(m.INT8)&&e.equals(m.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 m.BIG_INT_TYPES.some(e=>e.equals(this))}static UNKNOWN=new m("unknown");static FLOAT64=new m("float64");static FLOAT32=new m("float32");static INT64=new m("int64");static INT32=new m("int32");static INT16=new m("int16");static INT8=new m("int8");static UINT64=new m("uint64");static UINT32=new m("uint32");static UINT16=new m("uint16");static UINT8=new m("uint8");static BOOLEAN=this.UINT8;static TIMESTAMP=new m("timestamp");static UUID=new m("uuid");static STRING=new m("string");static JSON=new m("json");static ARRAY_CONSTRUCTORS=new Map([[m.UINT8.toString(),Uint8Array],[m.UINT16.toString(),Uint16Array],[m.UINT32.toString(),Uint32Array],[m.UINT64.toString(),BigUint64Array],[m.FLOAT32.toString(),Float32Array],[m.FLOAT64.toString(),Float64Array],[m.INT8.toString(),Int8Array],[m.INT16.toString(),Int16Array],[m.INT32.toString(),Int32Array],[m.INT64.toString(),BigInt64Array],[m.TIMESTAMP.toString(),BigInt64Array],[m.STRING.toString(),Uint8Array],[m.JSON.toString(),Uint8Array],[m.UUID.toString(),Uint8Array]]);static ARRAY_CONSTRUCTOR_DATA_TYPES=new Map([[Uint8Array.name,m.UINT8],[Uint16Array.name,m.UINT16],[Uint32Array.name,m.UINT32],[BigUint64Array.name,m.UINT64],[Float32Array.name,m.FLOAT32],[Float64Array.name,m.FLOAT64],[Int8Array.name,m.INT8],[Int16Array.name,m.INT16],[Int32Array.name,m.INT32],[BigInt64Array.name,m.INT64]]);static DENSITIES=new Map([[m.UINT8.toString(),V.BIT8],[m.UINT16.toString(),V.BIT16],[m.UINT32.toString(),V.BIT32],[m.UINT64.toString(),V.BIT64],[m.FLOAT32.toString(),V.BIT32],[m.FLOAT64.toString(),V.BIT64],[m.INT8.toString(),V.BIT8],[m.INT16.toString(),V.BIT16],[m.INT32.toString(),V.BIT32],[m.INT64.toString(),V.BIT64],[m.TIMESTAMP.toString(),V.BIT64],[m.STRING.toString(),V.UNKNOWN],[m.JSON.toString(),V.UNKNOWN],[m.UUID.toString(),V.BIT128]]);static ALL=[m.UNKNOWN,m.FLOAT64,m.FLOAT32,m.INT64,m.INT32,m.INT16,m.INT8,m.UINT64,m.UINT32,m.UINT16,m.UINT8,m.TIMESTAMP,m.UUID,m.STRING,m.JSON];static BIG_INT_TYPES=[m.INT64,m.UINT64,m.TIMESTAMP];static z=s.z.union([s.z.string().transform(e=>new m(e)),s.z.instanceof(m)])},ft=class x extends vt{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 x(nr(this.valueOf(),e.valueOf()))}sub(e){return se(e)&&(e=e.value),new x(Ve(this.valueOf(),e.valueOf()))}mult(e){return new x(ge(this.valueOf(),e))}div(e){return new x(Kr(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 go=t=>{const e=typeof t;return e==="string"||e==="number"||e==="boolean"||e==="bigint"||t instanceof y||t instanceof S||t instanceof Date},hf=(t,e,r,n=0)=>t.usesBigInt&&!e.usesBigInt?Number(r)-Number(n):!t.usesBigInt&&e.usesBigInt?BigInt(r.valueOf())-BigInt(n.valueOf()):Cr(r,-n),Cr=(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),df=/^(?:[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 ff(t){return typeof t=="string"&&df.test(t)}const q=[];for(let t=0;t<256;++t)q.push((t+256).toString(16).slice(1));function yf(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 pf(t,e=0){const r=yf(t,e);if(!ff(r))throw TypeError("Stringified UUID is invalid");return r}typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const mo=(t,e)=>pf(t,e),xe=-1,Hn={[Symbol.iterator]:()=>Hn,next:()=>({done:!0,value:void 0})},gf=s.z.string().transform(t=>new Uint8Array(atob(t).split("").map(e=>e.charCodeAt(0))).buffer),mf=s.z.union([s.z.null(),s.z.undefined()]).transform(()=>new Uint8Array().buffer),Vn=10,wo=(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`)},bo="sy_x_telem_series";let Me=class Ie{key;discriminator=bo;dataType;sampleOffset;gl;_data;timeRange=L.ZERO;alignment=0n;alignmentMultiple=1n;cachedMin;cachedMax;writePos=xe;_refCount=0;cachedLength;_cachedIndexes;static crudeZ=s.z.object({timeRange:L.z.optional(),dataType:k.z,alignment:s.z.coerce.bigint().optional(),data:s.z.union([gf,mf,s.z.instanceof(ArrayBuffer),s.z.instanceof(Uint8Array)]),glBufferUsage:cf.optional().default("static").optional()});static z=Ie.crudeZ.transform(e=>new Ie(e));constructor(e){wf(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=Ps(),data:u}=e;if(vo(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=go(u),f=Array.isArray(u);if(r!=null)this.dataType=new k(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=k.STRING;else if(typeof d=="number")this.dataType=k.FLOAT64;else if(typeof d=="bigint")this.dataType=k.INT64;else if(typeof d=="boolean")this.dataType=k.BOOLEAN;else if(d instanceof y||d instanceof Date||d instanceof y)this.dataType=k.TIMESTAMP;else if(typeof d=="object")this.dataType=k.JSON;else throw new Error(`cannot infer data type of ${typeof d} when constructing a Series from a JS array`)}else this.dataType=new k(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 y||z instanceof Date||z instanceof S)&&(d=d.map(E=>new y(E).valueOf())),this.dataType.equals(k.STRING)?(this.cachedLength=d.length,this._data=new TextEncoder().encode(`${d.join(`
|
|
9
|
-
`)}
|
|
10
|
-
`).buffer):this.dataType.equals(k.JSON)?(this.cachedLength=d.length,this._data=new TextEncoder().encode(`${d.map(E=>Zt.encodeString(E)).join(`
|
|
11
|
-
`)}
|
|
12
|
-
`).buffer):this.dataType.usesBigInt&&typeof z=="number"?this._data=new this.dataType.Array(d.map(E=>BigInt(Math.round(E)))).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??L.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 k(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(k.JSON))throw new Error("cannot parse non-JSON series as JSON");return this.toStrings().map(r=>e.parse(Zt.decodeString(r)))}get byteCapacity(){return new ft(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 ft(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===Vn&&(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]=hf(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(k.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(),Cr(this.cachedMax,this.sampleOffset))}calcRawMin(){if(this.length===0)return 1/0;if(this.dataType.equals(k.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(),Cr(this.cachedMin,this.sampleOffset))}get bounds(){return Y(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(k.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 Cr(n,this.sampleOffset)}atUUID(e,r){e<0&&(e=this.length+e);const n=mo(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]===Vn){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(k.STRING)?new TextDecoder().decode(i):xs(JSON.parse(new TextDecoder().decode(i)))}binarySearch(e){let r=0,n=this.length-1;const a=Wr(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(k.FLOAT32)&&!this.dataType.equals(k.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 wo(e,this.dataType),this}get digest(){return{key:this.key,dataType:this.dataType.toString(),sampleOffset:this.sampleOffset,alignment:{lower:xa(this.alignmentBounds.lower),upper:xa(this.alignmentBounds.upper),multiple:this.alignmentMultiple},timeRange:this.timeRange.toString(),length:this.length,capacity:this.capacity}}get alignmentBounds(){return Y(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 bf(this);return this.dataType.equals(k.JSON)?new vf(e):e}return this.dataType.equals(k.UUID)?new Tf(this):new Of(this)}slice(e,r){return this.sliceSub(!1,e,r)}sub(e,r){return this.sliceSub(!0,e,r)}subIterator(e,r){return new Na(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 Na(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:L.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 wf=t=>t==null?!1:Array.isArray(t)||t instanceof ArrayBuffer||ArrayBuffer.isView(t)&&!(t instanceof DataView)||t instanceof Me?!0:go(t),vo=lf(bo,Me);let Na=class{series;end;index;constructor(t,e,r){this.series=t;const n=Y(0,t.length+1);this.end=Sa(n,r),this.index=Sa(n,e)}next(){return this.index>=this.end?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}},bf=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]!==Vn;)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))})}},vf=class To{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:Zt.decodeString(e.value,To.schema)}}},Tf=class{series;index;data;density;constructor(t){if(!t.dataType.equals(k.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=k.UUID.density.valueOf()}next(){if(this.index>=this.series.length)return{done:!0,value:void 0};const t=mo(this.data,this.index*this.density);return this.index++,{done:!1,value:t}}},Of=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 zf{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 wo(e,this.dataType),this}get dataType(){return this.series.length===0?k.UNKNOWN:this.series[0].dataType}get timeRange(){return this.series.length===0?L.ZERO:new L(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?Y(0n,0n):Y(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(vo(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(br(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 On(this,e,r??this.length)}subAlignmentIterator(e,r){if(e>=this.alignmentBounds.upper||r<=this.alignmentBounds.lower)return Hn;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(br(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(br(o.alignmentBounds,r)){a+=Math.ceil(Number(r-o.alignment)/Number(o.alignmentMultiple));break}}return new On(this,n,a)}subAlignmentSpanIterator(e,r){if(e>=this.alignmentBounds.upper)return Hn;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(br(i.alignmentBounds,e)){n+=Number(e-i.alignment);break}}return new On(this,n,n+r)}updateGLBuffer(e){this.series.forEach(r=>r.updateGLBuffer(e))}get bounds(){return yd(this.series.map(e=>e.bounds))}get byteLength(){return new ft(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 pd(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 gd(n,e,r)}parseJSON(e){if(!this.dataType.equals(k.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 Sf(this.series)}toStrings(){return this.series.flatMap(e=>e.toStrings())}}let Sf=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}},On=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 xa=t=>{const e=t>>32n,r=t&0xffffffffn;return{domain:e,sample:r}},Ef=(t,e)=>{let r=null;return e===0?t:(...n)=>{r!==null&&(clearTimeout(r),r=null),r=setTimeout(()=>t(...n),e)}},Wn=".",Nf=(t,e,r=Wn)=>{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)},xf=(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)},Af=(t,e,r={optional:!1})=>{const{optional:n,getter:a=xf}=r;if(e==="")return t;const i=e.split(Wn);if(i.length===1){const l=a(t,i[0]);if(l===void 0){if(n)return null;throw new Error(`Path ${e} does not exist. ${i[0]} is undefined`)}return l}const o=(l,c)=>{if(c>=i.length)return l;for(let u=i.length-c;u>=1;u--){const h=i.slice(c,c+u).join(Wn),f=a(l,h);if(f!==void 0){if(c+u===i.length)return f;if(f===null){if(n)return null;throw new Error(`Path ${e} does not exist. ${h} is null`)}return o(f,c+u)}}if(n)return null;throw new Error(`Path ${e} does not exist. ${i[c]} is undefined`)};return o(t,0)};s.z.object({key:s.z.string(),value:s.z.string()});let kf=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?.()}},Cf=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 If=Object.freeze(Object.defineProperty({__proto__:null,BaseObserver:Cf,Observer:kf},Symbol.toStringTag,{value:"Module"})),jf=s.z.record(s.z.union([s.z.number(),s.z.string(),s.z.symbol()]),s.z.unknown()),Ds=t=>Object.entries(t),Rf=(t,e)=>Object.fromEntries(Ds(t).map(([r,n])=>[r,e(n,r)])),Mf=t=>Object.fromEntries(Ds(t).filter(([e,r])=>r!==void 0)),Uf=(t,...e)=>{const r={...t};for(const n of e)delete r[n];return r},ze=Object.freeze(Object.defineProperty({__proto__:null,entries:Ds,map:Rf,omit:Uf,purgeUndefined:Mf,unknownZ:jf},Symbol.toStringTag,{value:"Module"})),Lf=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser";Lf();const Pf=["macOS","Windows","Linux"],Df=["macos","windows","linux"],$f={macos:"macOS",windows:"Windows",linux:"Linux"};s.z.enum(Pf).or(s.z.enum(Df).transform(t=>$f[t]));const Bf=(...t)=>t.map(Oo).join(""),Oo=t=>(t.endsWith("/")||(t+="/"),t.startsWith("/")&&(t=t.slice(1)),t),Zf=t=>t.endsWith("/")?t.slice(0,-1):t;class Dt{protocol;host;port;path;constructor({host:e,port:r,protocol:n="",pathPrefix:a=""}){this.protocol=n,this.host=e,this.port=r,this.path=Oo(a)}replace(e){return new Dt({host:e.host??this.host,port:e.port??this.port,protocol:e.protocol??this.protocol,pathPrefix:e.pathPrefix??this.path})}child(e){return new Dt({...this,pathPrefix:Bf(this.path,e)})}toString(){return Zf(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}static UNKNOWN=new Dt({host:"unknown",port:0})}const Ff=t=>t.nullable().transform(e=>e===null?void 0:e).optional(),qf=t=>s.array(t).or(t.transform(e=>[e])),zo=t=>Nf(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"]}),Aa=(t,e)=>{if(t==null)return null;const r=t[e];return r==null&&typeof t=="object"&&"sourceType"in t?t.sourceType()[e]:r},Yf=(t,e,r)=>e===""?t:Af(Aa(t,"shape"),zo(e),{...r,getter:Aa}),$t=Object.freeze(Object.defineProperty({__proto__:null,getFieldSchema:Yf,getFieldSchemaPath:zo,nullToUndefined:Ff,toArray:qf},Symbol.toStringTag,{value:"Module"})),_f=async t=>await new Promise(e=>setTimeout(e,S.fromMilliseconds(t).milliseconds));class Hf{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??_f},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 Vf=s.z.object({baseInterval:S.z.optional(),maxRetries:s.z.number().optional(),scale:s.z.number().optional()}),So=Object.freeze(Object.defineProperty({__proto__:null,Breaker:Hf,breakerConfigZ:Vf},Symbol.toStringTag,{value:"Module"})),Wf=/^#?([0-9a-f]{6}|[0-9a-f]{8})$/i,Eo=s.z.string().regex(Wf),ht=s.z.number().min(0).max(255),No=s.z.number().min(0).max(1),xo=s.z.tuple([ht,ht,ht,No]),Gf=s.z.tuple([ht,ht,ht]),Kf=s.z.object({rgba255:xo}),Jf=s.z.number().min(0).max(360),Xf=s.z.number().min(0).max(100),Qf=s.z.number().min(0).max(100),ey=s.z.tuple([Jf,Xf,Qf,No]),$s=s.z.union([Eo,Gf,xo,ey,Kf]),ty=$s.transform(t=>Bs(t)),Bs=(t,e=1)=>{if(t=$s.parse(t),typeof t=="string")return ry(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},ry=(t,e=1)=>(t=Eo.parse(t),t=ny(t),[Tr(t,0),Tr(t,2),Tr(t,4),t.length===8?Tr(t,6)/255:e]),Tr=(t,e)=>parseInt(t.slice(e,e+2),16),ny=t=>t.startsWith("#")?t.slice(1):t;Bs("#000000");Bs("#ffffff");const sy=s.z.object({key:s.z.string(),color:$s,position:s.z.number(),switched:s.z.boolean().optional()});s.z.array(sy);const ay=s.z.object({key:s.z.string(),name:s.z.string(),color:ty});s.z.object({key:s.z.string(),name:s.z.string(),swatches:s.z.array(ay)});const Ao=s.z.int().min(0).max(255),ko=255,Co=0,iy={lower:Co,upper:ko+1},Io=s.z.object({name:s.z.string(),key:s.z.string()}),Yt=t=>s.z.object({subject:Io,resource:t,authority:Ao}),oy=(...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}),jo=t=>s.z.object({from:Yt(t),to:s.z.null()}),Ro=t=>s.z.object({from:s.z.null(),to:Yt(t)}),ly=t=>s.z.union([jo(t),Ro(t),s.z.object({from:Yt(t),to:Yt(t)})]),ae=Object.freeze(Object.defineProperty({__proto__:null,ABSOLUTE_AUTHORITY:ko,AUTHORITY_BOUNDS:iy,ZERO_AUTHORITY:Co,acquireZ:Ro,authorityZ:Ao,filterTransfersByChannelKey:oy,releaseZ:jo,stateZ:Yt,subjectZ:Io,transferZ:ly},Symbol.toStringTag,{value:"Module"})),cy=t=>Object.getOwnPropertySymbols(globalThis).includes(t),uy=(t,e)=>{const r=Symbol.for(t);if(!cy(r)){const n=e();Object.defineProperty(globalThis,r,{value:n})}return()=>globalThis[r]},Mo="sy_x_error",hy=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),sr=t=>class Pt extends Error{static discriminator=Mo;discriminator=Pt.discriminator;static TYPE=t;type=Pt.TYPE;static matches=hy(t);matches=Pt.matches;constructor(r,n){super(r,n),this.name=Pt.TYPE}static sub(r){return sr(`${t}.${r}`)}},Uo=t=>{if(t==null||typeof t!="object")return!1;const e=t;if(e.discriminator!==Mo)return!1;if(!("type"in e))throw new Error(`X Error is missing its type property: ${JSON.stringify(e)}`);return!0},st="unknown",Gn="nil";class dy{providers=[];register(e){this.providers.push(e)}encode(e){if(e==null)return{type:Gn,data:""};if(Uo(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===Gn)return null;if(e.type===st)return new Kn(e.data);for(const r of this.providers){const n=r.decode(e);if(n!=null)return n}return new Kn(e.data)}}const Zs=uy("synnax-error-registry",()=>new dy),fy=({encode:t,decode:e})=>Zs().register({encode:t,decode:e}),yy=t=>Zs().encode(t),py=t=>t==null?null:Zs().decode(t);class Kn extends sr("unknown"){}const gy=s.z.object({type:s.z.string(),data:s.z.string()});class my extends sr("canceled"){}class wy extends sr("not_implemented"){}const Oe=Object.freeze(Object.defineProperty({__proto__:null,Canceled:my,NONE:Gn,NotImplemented:wy,UNKNOWN:st,Unknown:Kn,createTyped:sr,decode:py,encode:yy,isTyped:Uo,payloadZ:gy,register:fy},Symbol.toStringTag,{value:"Module"})),by=s.object({jsonrpc:s.literal("2.0"),method:s.string(),params:s.any().optional(),id:s.union([s.string(),s.number(),s.null()]).optional()}),Lo=s.object({jsonrpc:s.literal("2.0"),id:s.union([s.string(),s.number(),s.null()])}),vy=Lo.extend({result:s.json()}),Ty=Lo.extend({error:s.object({code:s.number().int(),message:s.string().optional(),data:s.json().optional()})}),Oy=s.union([vy,Ty]);s.union([by,Oy]);const Jn=s.z.string().regex(/^\d+\.\d+\.\d+$/),ar=(t,e,r={})=>{r.checkMajor??=!0,r.checkMinor??=!0,r.checkPatch??=!0;const n=Jn.parse(t),a=Jn.parse(e),[i,o,l]=n.split(".").map(Number),[c,u,h]=a.split(".").map(Number);if(r.checkMajor){if(i<c)return xr;if(i>c)return Ar}if(r.checkMinor){if(o<u)return xr;if(o>u)return Ar}if(r.checkPatch){if(l<h)return xr;if(l>h)return Ar}return Tt},zy=(t,e,r={})=>Zi(ar(t,e,r)),Po=(t,e,r={})=>Bi(ar(t,e,r)),Sy=(t,e,r={})=>$i(ar(t,e,r)),Ey=({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}},Ny=({name:t,migrations:e,targetSchema:r,defaultVersion:n,def:a})=>{const i=Object.keys(e).sort(ar).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||Po(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}}},ka=Object.freeze(Object.defineProperty({__proto__:null,compareSemVer:ar,createMigration:Ey,migrator:Ny,semVerNewer:Po,semVerOlder:Sy,semVerZ:Jn,versionsEqual:zy},Symbol.toStringTag,{value:"Module"})),xy=["standard","scientific","engineering"];s.z.enum(xy);const Do=s.z.enum(["success","info","warning","error","loading","disabled"]),Ay=t=>s.z.object({key:s.z.string(),variant:Do,message:s.z.string(),description:s.z.string().optional(),time:y.z,details:t??s.z.unknown().optional()}),ky=(t,e)=>{if(!(t instanceof Error))throw t;return $o({variant:"error",message:e??t.message,description:e!=null?t.message:void 0,details:{stack:t.stack??""}})},$o=t=>({key:Ps(),time:y.now(),...t}),Cy=(t,e=[])=>{if(t!=null)return Array.isArray(e)?e.includes(t)?t:void 0:e===t?t:void 0},Iy=(t,e=[])=>{if(t!=null)return Array.isArray(e)?e.includes(t)?void 0:t:e===t?void 0:t},ir=Object.freeze(Object.defineProperty({__proto__:null,create:$o,fromException:ky,keepVariants:Cy,removeVariants:Iy,statusZ:Ay,variantZ:Do},Symbol.toStringTag,{value:"Module"})),jy=(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]}`},Ry=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))},My=(t,e)=>t.startsWith(e)?t.slice(e.length):t,Xn=Object.freeze(Object.defineProperty({__proto__:null,createShortIdentifiers:Ry,naturalLanguageJoin:jy,trimPrefix:My},Symbol.toStringTag,{value:"Module"})),Uy="all",Ly="create",Py="delete",Dy="retrieve",$y="update",Qn=s.z.enum([Uy,Ly,Py,Dy,$y]);let me=class extends Oe.createTyped("sy"){},B=class extends me.sub("validation"){};class _t extends B.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=_t.encodedSchema.parse(JSON.parse(e.data));return new _t(r.path,Oe.decode(r.error))}}class Ur extends me.sub("auth"){}class es extends Ur.sub("invalid_token"){}class ts extends Ur.sub("expired_token"){}class K 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 yt extends Be.sub("not_found"){}class Lr extends Be.sub("multiple_results"){}class Ca extends me.sub("route"){path;constructor(e,r){super(e),this.path=r}}class rs extends me.sub("control"){}class Ia extends rs.sub("unauthorized"){}class By extends me.sub("disconnected"){constructor(e="Operation failed because no cluster is connected."){super(e)}}class GO extends me.sub("contiguity"){}const Zy=t=>t.type.startsWith(me.TYPE)?t.type.startsWith(B.TYPE)?t.type===_t.TYPE?_t.decode(t):new B(t.data):t.type.startsWith(Ur.TYPE)?t.type.startsWith(es.TYPE)?new es(t.data):t.type.startsWith(ts.TYPE)?new ts(t.data):new Ur(t.data):t.type.startsWith(K.TYPE)?new K(t.data):t.type.startsWith(Be.TYPE)?t.type.startsWith(yt.TYPE)?new yt(t.data):t.type.startsWith(Lr.TYPE)?new Lr(t.data):new Be(t.data):t.type.startsWith(rs.TYPE)?t.type.startsWith(Ia.TYPE)?new Ia(t.data):new rs(t.data):t.type.startsWith(Ca.TYPE)?new Ca(t.data,t.data):new K(t.data):null,Fy=()=>{throw new Oe.NotImplemented};Oe.register({encode:Fy,decode:Zy});const qy=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 Fs{key;name;constructor(e,r){this.key=r,this.name=e}get ontologyID(){return Bo(this.key)}}const Bo=t=>({type:"group",key:t}),or=s.z.uuid(),Jr=s.z.string(),Xr=s.z.object({key:or,name:Jr}),Zo="builtin",Yy="cluster",_y="node",Qr=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"]),Hy=s.z.string().transform(t=>{const[e,r]=t.split(":");return{type:Qr.parse(e),key:r??""}}),R=s.z.object({type:Qr,key:s.z.string()}).or(Hy),Vy={type:Zo,key:"root"},Ht=t=>`${t.type}:${t.key}`,Wy=(t,e)=>t.type===e.type&&t.key===e.key,Fo=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=>R.parse(r))},qo=s.z.object({id:R,name:s.z.string(),data:ze.unknownZ.optional().nullable()}).transform(t=>({key:Ht(t.id),...t})),Gy=t=>t==="to"?"from":"to",Ky=s.z.object({from:R,type:s.z.string(),to:R}).or(s.z.string().transform(t=>{const[e,r,n]=t.split("->");return{from:R.parse(e),type:r,to:R.parse(n)}})),Jy=t=>`${Ht(t.from)}->${t.type}->${Ht(t.to)}`,Xy="parent",Qy=(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),ep=s.z.object({group:Xr}),tp=s.z.object({parent:R,key:or.optional(),name:Jr}),rp=s.z.object({key:or,name:Jr}),np=s.z.object({keys:s.z.array(or)});let sp=class Ir{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 w(this.client,Ir.CREATE_ENDPOINT,{parent:e,name:r,key:n},tp,ep)).group}async rename(e,r){await w(this.client,Ir.RENAME_ENDPOINT,{key:e,name:r},rp,s.z.object({}))}async delete(e){await w(this.client,Ir.DELETE_ENDPOINT,{keys:e},np,s.z.object({}))}};const ap="sy_group_set",ip="sy_group_delete";let Yo=class{creator;constructor(t){this.creator=new sp(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 Fs(t.name,t.key)}};const op=Object.freeze(Object.defineProperty({__proto__:null,Client:Yo,DELETE_CHANNEL_NAME:ip,Group:Fs,SET_CHANNEL_NAME:ap,groupZ:Xr,keyZ:or,nameZ:Jr,ontologyID:Bo},Symbol.toStringTag,{value:"Module"})),lp="/ontology/add-children",cp="/ontology/remove-children",up="/ontology/move-children",ja=s.z.object({id:R,children:R.array()}),hp=s.z.object({from:R,to:R,children:R.array()}),zn=s.z.object({});let dp=class{client;constructor(t){this.client=t}async addChildren(t,...e){await w(this.client,lp,{id:t,children:e},ja,zn)}async removeChildren(t,...e){await w(this.client,cp,{id:t,children:e},ja,zn)}async moveChildren(t,e,...r){await w(this.client,up,{from:t,to:e,children:r},hp,zn)}};const fp="/ontology/retrieve",yp=s.z.object({ids:R.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:Qr.array().optional()}),pp=s.z.object({resources:qo.array()});let _o=class{type="ontology";groups;client;writer;framer;constructor(t,e){this.client=t,this.writer=new dp(t),this.groups=new Yo(t),this.framer=e}async retrieve(t,e){if(!Array.isArray(t)&&typeof t=="object"&&!("key"in t))return this.execRetrieve(t);const r=Fo(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 ${Xn.naturalLanguageJoin(r.map(a=>Ht(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 w(this.client,fp,t,yp,pp);return e}};const gp="sy_ontology_resource_set",mp="sy_ontology_resource_delete",wp="sy_ontology_relationship_set",bp="sy_ontology_relationship_delete",vp=Object.freeze(Object.defineProperty({__proto__:null,BUILTIN_TYPE:Zo,CLUSTER_TYPE:Yy,Client:_o,NODE_TYPE:_y,PARENT_OF_RELATIONSHIP_TYPE:Xy,RELATIONSHIP_DELETE_CHANNEL_NAME:bp,RELATIONSHIP_SET_CHANNEL_NAME:wp,RESOURCE_DELETE_CHANNEL_NAME:mp,RESOURCE_SET_CHANNEL_NAME:gp,ROOT_ID:Vy,idToString:Ht,idZ:R,idsEqual:Wy,matchRelationship:Qy,oppositeRelationshipDirection:Gy,parseIDs:Fo,relationshipToString:Jy,relationshipZ:Ky,resourceTypeZ:Qr,resourceZ:qo},Symbol.toStringTag,{value:"Module"})),Z=t=>s.z.union([s.z.union([s.z.null(),s.z.undefined()]).transform(()=>[]),t.array()]),lr=s.z.uuid(),qs=s.z.object({key:lr,subjects:Z(R),objects:Z(R),actions:Z(Qn)}),Tp=s.z.object({key:lr.optional(),subjects:R.array().or(R),objects:R.array().or(R),actions:Qn.array().or(Qn)}),Op=s.z.object({keys:lr.array().optional(),subjects:R.array().optional()}),zp=s.z.object({key:lr}).transform(({key:t})=>({keys:[t]})),Sp=s.z.union([s.z.object({for:R}).transform(({for:t})=>({subjects:[t]})),s.z.object({for:R.array()}).transform(({for:t})=>({subjects:t})),Op]),Ep=s.z.union([zp,Sp]),Np=s.z.object({policies:Z(qs)}),xp=s.z.object({policies:qs.partial({key:!0}).array()}),Ap=s.z.object({policies:qs.array()}),kp=s.z.object({keys:lr.array()}),Cp=s.z.object({}),Ip="/access/policy/retrieve",jp="/access/policy/create",Rp="/access/policy/delete";let Mp=class{client;constructor(t){this.client=t}async create(t){const e=Array.isArray(t),r=Tp.array().parse(O.toArray(t)).map(a=>({objects:O.toArray(a.objects),actions:O.toArray(a.actions),subjects:O.toArray(a.subjects)})),n=await w(this.client,jp,{policies:r},xp,Ap);return e?n.policies:n.policies[0]}async retrieve(t){const e="key"in t,r=await w(this.client,Ip,t,Ep,Np);return e?r.policies[0]:r.policies}async delete(t){await w(this.client,Rp,{keys:O.toArray(t)},kp,Cp)}},Up=class{policy;constructor(t){this.policy=new Mp(t)}};const Ra="Channel key must be a valid uint32.",U=s.z.uint32().or(s.z.string().refine(t=>!isNaN(Number(t)),{message:Ra}).transform(Number).refine(t=>t<2**32-1,{message:Ra})),Te=s.z.string(),Ho=ir.statusZ(),Ot=s.z.object({name:Te,key:U,dataType:k.z,leaseholder:s.z.number(),index:U,isIndex:s.z.boolean(),internal:s.z.boolean(),virtual:s.z.boolean(),alias:s.z.string().optional(),expression:s.z.string().default(""),requires:Z(U),status:Ho.optional()}),Vo=Ot.extend({key:U.optional(),leaseholder:s.z.number().optional(),index:U.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:Z(U).optional().default([])}),Je=s.z.union([$t.toArray(U),$t.toArray(Te),$t.toArray(Ot).transform(t=>t.map(e=>e.key))]),Lp=new Error("request for lock canceled");var Pp=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 Dp{constructor(e,r=Lp){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=Wo(this._queue,l=>r<=l.priority);o===-1&&e<=this._value?this._dispatchItem(i):this._queue.splice(o+1,0,i)})}runExclusive(e){return Pp(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]=[]),$p(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 $p(t,e){const r=Wo(t,n=>e.priority<=n.priority);t.splice(r+1,0,e)}function Wo(t,e){for(let r=t.length-1;r>=0;r--)if(e(t[r]))return r;return-1}var Bp=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 Zp{constructor(e){this._semaphore=new Dp(1,e)}acquire(){return Bp(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 Fp=(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 yt(`${t} not found matching ${JSON.stringify(e)}`);if(r.length>1)throw new Lr(`Expected one ${t} matching ${JSON.stringify(e)}, but found ${r.length}`)}},qp=s.z.object({leaseholder:s.z.number().optional(),keys:U.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:k.z.array().optional(),notDataTypes:k.z.array().optional(),virtual:s.z.boolean().optional(),isIndex:s.z.boolean().optional(),internal:s.z.boolean().optional(),calculated:s.z.boolean().optional()}),Yp=s.z.object({channels:Z(Ot)}),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]),Fp(t,{number:"keys",string:"names"}));class cr{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(cr.ENDPOINT,e,qp,Yp);if(n!=null)throw n;return r.channels}}class Ys{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 Go{mu=new Zp;requests=new Map;wrapped;debouncedRun;constructor(e,r){this.wrapped=e,this.debouncedRun=Ef(()=>{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 Ko=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},_p="sy_channel_set",Hp="sy_channel_delete";class ns{_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=U.parse(a),this.name=r,this.dataType=new k(e),this.leaseholder=n,this.index=U.parse(o),this.isIndex=i,this.internal=l,this.alias=h,this.virtual=c,this.expression=d,this.requires=U.array().parse(z??[]),f!=null&&(this.status=ir.create(f)),this._frameClient=u??null}get framer(){if(this._frameClient==null)throw new B("cannot read from a channel that has not been created");return this._frameClient}get payload(){return Ot.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 Pr(this.payload)}get ontologyID(){return Qo(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 Vp="sy_calculation_status",Wp="/channel/retrieve-group",Gp=s.z.object({}),Kp=s.z.object({group:Xr});let Jo=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 Ys(new Go(new cr(this.client),t))}sugar(t){const{frameClient:e}=this;return Array.isArray(t)?t.map(r=>new ns({...r,frameClient:e})):new ns({...t,frameClient:e})}async retrieveGroup(){const t=await w(this.client,Wp,{},Gp,Kp);return new Fs(t.group.name,t.group.key)}};const Pr=({virtual:t,expression:e})=>t&&e!=="",Xo=async(t,e)=>{if(!Pr(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(Pr(n)){const a=await Xo(t,n);if(a!=null)return a}}return null},Qo=t=>({type:"channel",key:t.toString()}),Jp=s.z.object({channels:Vo.array()}),Xp=s.z.object({channels:Ot.array()}),Qp=s.z.object({keys:U.array().optional(),names:Te.array().optional()}),eg=s.z.object({}),tg=s.z.object({keys:U.array(),names:Te.array()}),rg=s.z.object({}),ng="/channel/create",sg="/channel/delete",ag="/channel/rename";let el=class{client;cache;constructor(t,e){this.client=t,this.cache=e}async create(t){const{channels:e}=await w(this.client,ng,{channels:t.map(r=>({...r,dataType:r.dataType}))},Jp,Xp);return this.cache.set(e),e}async delete(t){const e=U.array().parse(t.keys??[]);await w(this.client,sg,t,Qp,eg),e.length>0&&this.cache.delete(e),t.names!=null&&this.cache.delete(t.names)}async rename(t,e){await w(this.client,ag,{keys:t,names:e},tg,rg),this.cache.rename(t,e)}};const ig=Object.freeze(Object.defineProperty({__proto__:null,CALCULATION_STATUS_CHANNEL_NAME:Vp,CacheRetriever:Ys,Channel:ns,Client:Jo,ClusterRetriever:cr,DELETE_CHANNEL_NAME:Hp,DebouncedBatchRetriever:Go,SET_CHANNEL_NAME:_p,Writer:el,analyzeParams:ce,isCalculated:Pr,keyZ:U,nameZ:Te,newZ:Vo,ontologyID:Qo,paramsZ:Je,payloadZ:Ot,resolveCalculatedIndex:Xo,retrieveRequired:Ko,statusZ:Ho},Symbol.toStringTag,{value:"Module"})),Qe=s.z.uuid(),en=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)}),og=en.partial({key:!0,firstName:!0,lastName:!0}).omit({rootUser:!0}).extend({password:s.z.string().min(1)}),lg=s.z.object({keys:Qe.array().optional(),usernames:s.z.string().array().optional()}),cg=s.z.object({key:Qe}).transform(({key:t})=>({keys:[t]})),ug=s.z.object({username:s.z.string()}).transform(({username:t})=>({usernames:[t]})),hg=s.z.object({usernames:s.z.string().array()}).transform(({usernames:t})=>({usernames:t})),dg=s.z.union([cg,ug,hg,lg]),fg=s.z.object({users:Z(en)}),yg=s.z.object({users:og.array()}),pg=s.z.object({users:en.array()}),gg=s.z.object({key:Qe,username:s.z.string().min(1)}),mg=s.z.object({}),wg=s.z.object({key:Qe,firstName:s.z.string().optional(),lastName:s.z.string().optional()}),bg=s.z.object({}),vg=s.z.object({keys:Qe.array()}),Tg=s.z.object({}),Og="/user/retrieve",zg="/user/create",Sg="/user/change-username",Eg="/user/rename",Ng="/user/delete";let xg=class{client;constructor(t){this.client=t}async create(t){const e=Array.isArray(t),r=await w(this.client,zg,{users:O.toArray(t)},yg,pg);return e?r.users:r.users[0]}async changeUsername(t,e){await w(this.client,Sg,{key:t,username:e},gg,mg)}async retrieve(t){const e="key"in t||"username"in t,r=await w(this.client,Og,t,dg,fg);if(!e)return r.users;if(r.users.length===0){const n="key"in t?`key ${t.key}`:`username ${t.username}`;throw new yt(`No user with ${n} found`)}if(r.users.length>1){const n="key"in t?`key ${t.key}`:`username ${t.username}`;throw new Lr(`Multiple users found with ${n}`)}return r.users[0]}async rename(t,e,r){await w(this.client,Eg,{key:t,firstName:e,lastName:r},wg,bg)}async delete(t){await w(this.client,Ng,{keys:O.toArray(t)},vg,Tg)}};const Ag=s.z.object({username:s.z.string(),password:s.z.string()}),kg=s.z.object({token:s.z.string(),user:en}),Ma="/auth/login",Cg=3,Ig="/auth/change-password",jg=s.z.object({username:s.z.string(),password:s.z.string(),newPassword:s.z.string().min(1)}),Rg=s.z.object({}),Mg=[es,ts];let Ug=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 w(this.client,Ig,{username:this.credentials.username,password:this.credentials.password,newPassword:t},jg,Rg),this.credentials.password=t}middleware(){const t=async(e,r)=>{if(!this.authenticated&&!e.target.endsWith(Ma)){this.authenticating??=new Promise((o,l)=>{this.client.send(Ma,this.credentials,Ag,kg).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 Mg.some(i=>i.matches(a))&&this.retryCount<Cg?(this.authenticated=!1,this.authenticating=void 0,this.retryCount+=1,t(e,r)):(this.retryCount=0,[n,a])};return t}};const Lg=s.z.enum(["disconnected","connecting","connected","failed"]),Pg=s.z.object({status:Lg,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()}),Dg=s.z.object({clusterKey:s.z.string(),nodeVersion:s.z.string().optional()}),Ua={clusterKey:"",status:"disconnected",error:void 0,message:"Disconnected",clientServerCompatible:!1,clientVersion:"0.45.1"},La=(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 Dr{static ENDPOINT="/connectivity/check";static DEFAULT=Ua;_state;pollFrequency=S.seconds(30);client;name;interval;clientVersion;onChangeHandlers=[];static connectionStateZ=Pg;versionWarned=!1;constructor(e,r=S.seconds(30),n,a){this._state={...Ua},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(Dr.ENDPOINT,{},s.z.object({}),Dg);if(n!=null)throw n;const a=r.nodeVersion,i=this.clientVersion,o=this.versionWarned;a==null?(this._state.clientServerCompatible=!1,o||(console.warn(La(null,i,!0)),this.versionWarned=!0)):ka.versionsEqual(i,a,{checkMajor:!0,checkMinor:!0,checkPatch:!1})?this._state.clientServerCompatible=!0:(this._state.clientServerCompatible=!1,o||(console.warn(La(a,i,ka.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 $g=s.z.object({keys:U.array().optional(),bounds:L.z,names:Te.array().optional()}),Bg=s.z.object({}),Zg="/frame/delete";class Fg{client;constructor(e){this.client=e}async delete(e){await w(this.client,Zg,e,$g,Bg)}}const Pa=t=>{const e=O.toArray(t);return e.length===0?null:typeof e[0]=="number"||!isNaN(parseInt(e[0]))?"key":"name"},Da=(t,e)=>{const r=O.toArray(t);if(r.length===e.length)return;const n=Pa(t);throw Pa===null?new B("[Frame] - channel keys or names must be provided when constructing a frame."):new B(`[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=>tl(i));Da(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);Da(a,n),n.forEach((i,o)=>this.push(a[o],i));return}throw new B(`[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 K("colType is not key");return this.columns??[]}get uniqueKeys(){return Ta.unique(this.keys)}get names(){if(this.colType==="key")throw new K("colType is not name");return this.columns??[]}get uniqueNames(){return Ta.unique(this.names)}get uniqueColumns(){return this.colType==="key"?this.uniqueKeys:this.uniqueNames}toPayload(){return{series:this.series.map(e=>rl(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 L.ZERO;const n=y.min(...this.series.map(i=>i.timeRange.start)),a=y.max(...this.series.map(i=>i.timeRange.end));return new L(n,a)}const r=this.get(e);return r==null?L.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 zf(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 B("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 B("keyVariant must match");if(typeof e!="string"&&this.colType==="name")throw new B("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 ft(this.series.reduce((e,r)=>e.add(r.byteLength),ft.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 tn=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([])])}),tl=t=>{const{dataType:e,data:r,timeRange:n,alignment:a}=t;return new Me({data:r,dataType:e,timeRange:n,glBufferUsage:"static",alignment:a})},rl=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||{}),Vt=(t=>(t[t.PersistStream=1]="PersistStream",t[t.Persist=2]="Persist",t[t.Stream=3]="Stream",t))(Vt||{});const qg=new S(-1);class ss extends me.sub("writer_closed"){constructor(){super("WriterClosed")}}const Yg=s.z.enum(Vt).or(s.z.enum(["persist","stream","persistStream"]).transform(t=>{switch(t){case"persist":return 2;case"stream":return 3;case"persistStream":return 1}})),nl=s.z.object({start:y.z.optional(),controlSubject:ae.subjectZ.optional(),authorities:s.z.union([ae.authorityZ.transform(t=>[t]),ae.authorityZ.array()]).default([ae.ABSOLUTE_AUTHORITY]),mode:Yg.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)}),_g=nl.extend({keys:U.array().optional()}),$a=nl.extend({channels:Je}),sl=$a.or(Je.transform(t=>$a.parse({channels:t,start:y.now()}))),Hg=s.z.object({command:s.z.enum(pt),config:_g.optional(),frame:tn.optional(),buffer:s.z.instanceof(Uint8Array).optional()}),Vg=s.z.object({command:s.z.enum(pt),end:y.z,err:Oe.payloadZ.optional()}),Wg=s.z.tuple([s.z.union([s.z.record(U.or(Te),ae.authorityZ),U.or(Te),ae.authorityZ]),ae.authorityZ.optional()]).transform(([t,e])=>{if(ae.authorityZ.safeParse(t).success)return{keys:[],authorities:[t]};if(U.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 al=class as{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=sl.parse(n),i=await Hs.open(e,a.channels);a.useHighPerformanceCodec&&(r=r.withCodec(new em(i.codec)));const o=await r.stream(as.ENDPOINT,Hg,Vg),l=new as(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=Wg.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),y.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(ss.matches(this.closeErr))return null;throw this.closeErr}const[r,n]=await this.stream.receive();n!=null?this.closeErr=ue.matches(n)?new ss: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 Ba=t=>t.data.byteLength/t.dataType.density.valueOf(),Gg=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)},Za=5,Fa=4,qa=3,Ya=2,_a=1,Ha=0,de=k.TIMESTAMP.density.valueOf(),Ae=8,ke=4,Sn=4,En=4,Kg=1;class il{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 B(`
|
|
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()),Gg(n);let a=-1,i,o,l,c=r+Kg+En,u=!this.currState?.hasVariableDataTypes,h=!0,f=!0,d=!0,z=!0,E=!0;n.keys.length!==this.currState?.keys.length&&(d=!1,c+=n.keys.length*Sn),n.series.forEach((P,he)=>{const ie=Ba(P),xt=n.keys[he],Fe=this.currState?.keyDataTypes.get(xt);if(Fe==null)throw new B(`Channel ${xt} was not provided in the list of channels when opening the writer`);if(!Fe.equals(P.dataType))throw new B(`Series data type of ${P.dataType.toString()} does not match the data type of ${Fe.toString()} for channel ${xt}`);if(c+=P.data.byteLength,a===-1){a=ie,i=P.timeRange?.start,o=P.timeRange?.end,l=BigInt(P.alignment??0n);return}a!==ie&&(u=!1),(i?.valueOf()!==P.timeRange?.start.valueOf()||o?.valueOf()!==P.timeRange?.end.valueOf())&&(h=!1),l!==BigInt(P.alignment??0)&&(z=!1)}),f=h&&i==null&&o==null,E=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),E||(z?c+=Ae:c+=n.keys.length*Ae);const C=new Uint8Array(c),$=new DataView(C.buffer);let j=r;return C[j]=Number(E)<<Za|Number(z)<<Fa|Number(u)<<qa|Number(h)<<Ya|Number(f)<<_a|Number(d)<<Ha,j++,$.setUint32(j,this.seqNum,!0),j+=En,u&&($.setUint32(j,a,!0),j+=ke),h&&!f&&($.setBigUint64(j,i?.valueOf()??0n,!0),$.setBigUint64(j,o?.valueOf()??0n,!0),j+=de*2),z&&!E&&($.setBigUint64(j,l??0n,!0),j+=Ae),n.series.forEach((P,he)=>{if(d||($.setUint32(j,n.keys[he],!0),j+=Sn),!u){let ie=P.data.byteLength;P.dataType.isVariable||(ie=Ba(P)),$.setUint32(j,ie,!0),j+=ke}C.set(new Uint8Array(P.data),j),j+=P.data.byteLength,!h&&!f&&($.setBigUint64(j,P.timeRange?.start.valueOf()??0n,!0),$.setBigUint64(j,P.timeRange?.end.valueOf()??0n,!0),j+=de*2),!z&&!E&&($.setBigUint64(j,P.alignment??0n,!0),j+=Ae)}),C}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]>>Za&1),z=!!(n[i]>>Fa&1),E=!!(n[i]>>qa&1),C=!!(n[i]>>Ya&1),$=!!(n[i]>>_a&1),j=!!(n[i]>>Ha&1);i++;const P=f.getUint32(i,!0);i+=En;const he=this.states.get(P);if(he==null)return a;if(E){if(i+ke>f.byteLength)return a;o=f.getUint32(i,!0),i+=ke}if(C&&!$){if(i+de>f.byteLength)return a;c=new y(f.getBigUint64(i,!0)),i+=de,u=new y(f.getBigUint64(i,!0)),i+=de}if(z&&!d){if(i+Ae>f.byteLength)return a;h=f.getBigUint64(i,!0),i+=Ae}return j&&(a.keys=[...he.keys]),he.keys.forEach((ie,xt)=>{if(!j){if(i>=f.byteLength||f.getUint32(i,!0)!==ie)return;i+=Sn,a.keys.push(ie)}const Fe=he.keyDataTypes.get(ie);if(l=0,E)l=o;else{if(i+ke>f.byteLength)return;l=f.getUint32(i,!0),i+=ke}let gr=l;if(Fe.isVariable||(gr*=Fe.density.valueOf()),i+gr>f.byteLength){a.keys.splice(xt,1);return}const qe={dataType:Fe,data:n.slice(i,i+gr).buffer};if(i+=gr,!C&&!$){if(i+de*2>f.byteLength)return;const jc=f.getBigUint64(i,!0);i+=de;const Rc=f.getBigUint64(i,!0);i+=de,qe.timeRange=new L({start:jc,end:Rc})}else $?qe.timeRange=new L({start:0n,end:0n}):qe.timeRange=new L({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 _s=254,Jg=new Uint8Array([_s]),Xg=255,Qg=new Uint8Array([Xg]),ol="application/sy-framer";class em{contentType=ol;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(Jg,0),i.set(new Uint8Array(a),1),i}const n=this.base.encode(r.payload?.frame,1);return n.set(Qg,0),n}decode(e,r){if(new DataView(e instanceof Uint8Array?e.buffer:e).getUint8(0)===_s)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 tm{contentType=ol;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)===_s?this.lowPerfCodec.decode(e.slice(1),r):{type:"data",payload:{frame:this.base.decode(e,1)}}}}class rn{adapter;retriever;keys;codec;constructor(e){this.retriever=e,this.adapter=null,this.keys=[],this.codec=new il}static async open(e,r){const n=new rn(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(Oa.uniqueUnorderedPrimitiveArrays(this.keys,i)===Oa.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 Hs{adapter;retriever;keys;codec;constructor(e){this.retriever=e,this.adapter=null,this.keys=[],this.codec=new il}static async open(e,r){const n=new Hs(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 Ko(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 B(`
|
|
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 B(`
|
|
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 B(`
|
|
36
|
-
Received an array of channel names or keys but no series.
|
|
37
|
-
`);if(!Array.isArray(r))throw new B(`
|
|
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 B(`
|
|
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 B(`
|
|
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 ll{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 $r=new S(-1);var Vs=(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))(Vs||{}),cl=(t=>(t[t.None=0]="None",t[t.Ack=1]="Ack",t[t.Data=2]="Data",t))(cl||{});const rm=s.z.object({command:s.z.enum(Vs),span:S.z.optional(),bounds:L.z.optional(),stamp:y.z.optional(),keys:U.array().optional(),chunkSize:s.z.number().optional()}),nm=s.z.object({variant:s.z.enum(cl),ack:s.z.boolean(),command:s.z.enum(Vs),error:Oe.payloadZ.optional().nullable(),frame:tn.optional()});class Wt{static ENDPOINT="/frame/iterate";stream;adapter;value;constructor(e,r){this.stream=new ll("Iterator",e),this.value=new Q,this.adapter=r}static async _open(e,r,n,a,i={}){const o=await rn.open(n,r),l=await a.stream(Wt.ENDPOINT,rm,nm),c=new Wt(l,o);return await c.execute({command:0,keys:o.keys,bounds:new L(e),chunkSize:i.chunkSize??1e5}),c}async next(e=$r){return await this.execute({command:1,span:new S(e)})}async prev(e=$r){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 y(e)})}async seekGE(e){return await this.execute({command:6,stamp:new y(e)})}async valid(){return await this.execute({command:7})}async close(){await this.stream.closeAndAck()}[Symbol.asyncIterator](){return new sm(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 sm{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 am=s.z.object({keys:s.z.number().array(),downsampleFactor:s.z.number()}),im=s.z.object({frame:tn}),om="/frame/stream",Va=s.z.object({channels:Je,downsampleFactor:s.z.number().optional().default(1),useHighPerformanceCodec:s.z.boolean().optional().default(!0)}),Ws=Va.or(Je.transform(t=>Va.parse({channels:t}))),ul=(t,e)=>async r=>{const n=Ws.parse(r),a=await rn.open(t,n.channels);n.useHighPerformanceCodec&&(e=e.withCodec(new tm(a.codec)));const i=await e.stream(om,am,im),o=new lm(i,a);i.send({keys:a.keys,downsampleFactor:n.downsampleFactor??1});const[,l]=await i.receive();if(l!=null)throw l;return o},hl=async(t,e,r)=>await ul(t,e)(r);class lm{stream;adapter;downsampleFactor;constructor(e,r){this.stream=new ll("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 nn{wrapped_=null;breaker;opener;config;constructor(e,r,n={}){this.opener=e,this.config=Ws.parse(r);const{maxRetries:a=5e3,baseInterval:i=S.seconds(1),scale:o=1}=n??{};this.breaker=new So.Breaker({maxRetries:a,baseInterval:i,scale:o})}static async open(e,r,n){const a=new nn(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 dl extends If.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 cm=t=>({type:"framer",key:t.toString()});let fl=class{streamClient;retriever;deleter;constructor(t,e,r){this.streamClient=t,this.retriever=r,this.deleter=new Fg(e)}async openIterator(t,e,r){return await Wt._open(t,e,this.retriever,this.streamClient,r)}async openWriter(t){return await al._open(this.retriever,this.streamClient,t)}async openStreamer(t){return await hl(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:Vt.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:Vt.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(L.MAX,t,{chunkSize:e}),n=new Q;if(e>0)try{await r.seekLast(),await r.prev($r),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 um=Object.freeze(Object.defineProperty({__proto__:null,ALWAYS_INDEX_PERSIST_ON_AUTO_COMMIT:qg,AUTO_SPAN:$r,Client:fl,Frame:Q,HardenedStreamer:nn,Iterator:Wt,ObservableStreamer:dl,Writer:al,WriterClosedError:ss,WriterCommand:pt,WriterMode:Vt,createStreamOpener:ul,frameZ:tn,ontologyID:cm,openStreamer:hl,seriesFromPayload:tl,seriesToPayload:rl,streamerConfigZ:Ws,writerConfigZ:sl},Symbol.toStringTag,{value:"Module"})),hm=ae.ABSOLUTE_AUTHORITY,dm=ae.ZERO_AUTHORITY,fm=ae.stateZ(s.z.number()),ym=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()})`,pm=s.z.object({transfers:s.z.array(ae.transferZ(U))});class yl extends dl{states;codec;constructor(e){super(e,r=>{const n=this.codec.decode(r.series[0].buffer,pm);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 pl="sy_node_1_control";let gl=class{framer;constructor(t){this.framer=t}async openStateTracker(){const t=await nn.open(async e=>await this.framer.openStreamer(e),pl);return new yl(t)}};const gm=Object.freeze(Object.defineProperty({__proto__:null,ABSOLUTE_AUTHORITY:hm,CONTROL_STATE_CHANNEL_NAME:pl,Client:gl,StateTracker:yl,ZERO_AUTHORITY:dm,stateZ:fm,transferString:ym},Symbol.toStringTag,{value:"Module"}));let mm=class{tasks;racks;devices;constructor(t,e,r){this.tasks=t,this.racks=e,this.devices=r}};const we=s.z.uint32(),ml=ir.statusZ(s.z.object({rack:we})),sn=s.z.object({key:we,name:s.z.string(),status:$t.nullToUndefined(ml)}),wl=sn.partial({key:!0}),bl=t=>t?Ke.JSON_CODEC.decodeString(t,ze.unknownZ):{},zt=s.z.string(),vl=ir.statusZ(s.z.object({rack:we,device:zt})),an=s.z.object({key:zt,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(bl)),status:$t.nullToUndefined(vl)}),Tl=an.extend({properties:s.z.unknown().transform(t=>Ke.JSON_CODEC.encodeString(t))}),wm="sy_device_set",bm="sy_device_delete",vm="sy_device_status",Tm="/hardware/device/retrieve",Om="/hardware/device/create",zm="/hardware/device/delete",Sm=s.z.object({devices:Tl.array()}),Em=s.z.object({devices:an.array()}),Nm=s.z.object({keys:zt.array()}),xm=s.z.object({}),Am=s.z.object({keys:zt.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()}),km=s.z.object({devices:Z(an)}),Cm=s.z.object({key:zt,includeStatus:s.z.boolean().optional()}).transform(({key:t,includeStatus:e})=>({keys:[t],includeStatus:e})),Im=s.z.union([Cm,Am]);let Ol=class{type="device";client;constructor(t){this.client=t}async retrieve(t){const e=typeof t=="object"&&"key"in t,r=await w(this.client,Tm,t,Im,km);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 w(this.client,Om,{devices:O.toArray(t)},Sm,Em)).devices;return e?r[0]:r}async delete(t){await w(this.client,zm,{keys:O.toArray(t)},Nm,xm)}};const jm=t=>({type:"device",key:t}),Rm=Object.freeze(Object.defineProperty({__proto__:null,Client:Ol,DELETE_CHANNEL_NAME:bm,SET_CHANNEL_NAME:wm,STATUS_CHANNEL_NAME:vm,deviceZ:an,keyZ:zt,newZ:Tl,ontologyID:jm,statusZ:vl},Symbol.toStringTag,{value:"Module"})),Mm="/hardware/rack/retrieve",Um="/hardware/rack/create",Lm="/hardware/rack/delete",Pm="sy_rack_status",Dm="sy_rack_set",$m="sy_rack_delete",Bm=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()}),Zm=s.z.object({racks:Z(sn)}),Fm=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}))]),qm=Bm,Ym=s.z.union([Fm,qm]),_m=s.z.object({racks:wl.array()}),Hm=s.z.object({racks:sn.array()}),Vm=s.z.object({keys:we.array()}),Wm=s.z.object({});let zl=class{type="rack";client;tasks;constructor(t,e){this.client=t,this.tasks=e}async delete(t){await w(this.client,Lm,{keys:O.toArray(t)},Vm,Wm)}async create(t){const e=!Array.isArray(t),r=await w(this.client,Um,{racks:O.toArray(t)},_m,Hm),n=this.sugar(r.racks);return e?n[0]:n}async retrieve(t){const e="key"in t||"name"in t,r=await w(this.client,Mm,t,Ym,Zm),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 Sl(n,a,this.tasks,i));return e?r[0]:r}};class Sl{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 Gm=t=>({type:"rack",key:t.toString()}),Km=Object.freeze(Object.defineProperty({__proto__:null,Client:zl,DELETE_CHANNEL_NAME:$m,Rack:Sl,SET_CHANNEL_NAME:Dm,STATUS_CHANNEL_NAME:Pm,keyZ:we,newZ:wl,ontologyID:Gm,rackZ:sn,statusZ:ml},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())]),El=t=>s.z.object({task:Ee,running:s.z.boolean(),data:t}),Gs=t=>ir.statusZ(El(t)),ur=(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(bl).or(t.configSchema),status:Gs(t.statusDataSchema).optional().nullable(),snapshot:s.z.boolean().optional()}),Nl=t=>ur(t).omit({key:!0}).extend({key:Ee.transform(e=>e.toString()).optional(),config:s.z.unknown().transform(e=>Ke.JSON_CODEC.encodeString(e))}),Jm=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()}),Xm=t=>Number(BigInt(t)>>32n),is="sy_task_status",os="sy_task_cmd",Qm="sy_task_set",ew="sy_task_delete",Ye=new Error("Task not created"),xl=async(t,e)=>{const r=await e.retrieveParents(Ks(t));return r.length===0?null:r[0]};class Al{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 Ks(this.key)}async executeCommand(e,r){return await Cl(this.frameClient,this.key,e,r)}async executeCommandSync(e,r,n){return await Il(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 xl(this.key,this.ontologyClient):null}}const tw=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()}),rw=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}))]),nw=tw,sw=s.z.union([rw,nw]),aw=t=>s.z.object({tasks:Z(ur(t))}),iw="/hardware/task/retrieve",ow="/hardware/task/create",lw="/hardware/task/delete",cw="/hardware/task/copy",uw=t=>s.z.object({tasks:Nl(t).array()}),hw=t=>s.z.object({tasks:ur(t).array()}),dw=s.z.object({keys:Ee.array()}),fw=s.z.object({}),yw=s.z.object({key:Ee,name:s.z.string(),snapshot:s.z.boolean()}),pw=t=>s.z.object({task:ur(t)});let kl=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=uw(e),a=hw(e),i=await w(this.client,ow,{tasks:O.toArray(t)},n,a),o=this.sugar(i.tasks,e);return r?o[0]:o}async delete(t){await w(this.client,lw,{keys:O.toArray(t)},dw,fw)}async retrieve({schemas:t,...e}){const r="key"in e||"name"in e,n=(await w(this.client,iw,e,sw,aw(t))).tasks,a=this.sugar(n,t);return Xe("Task",e,a,r),r?a[0]:a}async copy(t,e,r){const n=pw(),a=await w(this.client,cw,{key:t,name:e,snapshot:r},yw,n);return this.sugar(a.task)}async retrieveSnapshottedTo(t){if(this.ontologyClient==null)throw Ye;return await xl(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 Al({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 Js(this.frameClient,t);if(e==null)throw new Error("Type is required");return await Cl(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 jl(this.frameClient,t,e,i,l)}const o=async()=>(await this.retrieve({key:t})).name;return await Il(this.frameClient,t,e,r,a??o,i,n)}};const Ks=t=>({type:"task",key:t}),Cl=async(t,e,r,n)=>(await Js(t,[{args:n,task:e,type:r}]))[0],Js=async(t,e)=>{if(t==null)throw Ye;const r=await t.openWriter(os),n=e.map(a=>({...a,key:of.create()}));return await r.write(os,n),await r.close(),n.map(a=>a.key)},Il=async(t,e,r,n,a,i,o)=>(await jl(t,[{args:o,task:e,type:r}],n,i,a))[0],jl=async(t,e,r,n,a)=>{if(t==null)throw Ye;const i=await t.openStreamer(is),o=await Js(t,e),l=new S(r);let c=[],u;const h=new Promise((f,d)=>{u=setTimeout(()=>{(async()=>{const z=e.map(E=>E.task);d(await gw("command",a,l,z))})()},l.milliseconds)});try{for(;;){const f=await Promise.race([i.read(),h]),d=Gs(n).parse(f.at(-1)[is]);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()}},gw=async(t,e,r,n)=>{const a=qh.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=Xn.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 ${Xn.naturalLanguageJoin(n)} timed out after ${i}`)}},mw=Object.freeze(Object.defineProperty({__proto__:null,COMMAND_CHANNEL_NAME:os,Client:kl,DELETE_CHANNEL_NAME:ew,SET_CHANNEL_NAME:Qm,STATUS_CHANNEL_NAME:is,Task:Al,commandZ:Jm,keyZ:Ee,newZ:Nl,ontologyID:Ks,rackKey:Xm,statusDetailsZ:El,statusZ:Gs,taskZ:ur},Symbol.toStringTag,{value:"Module"})),Ze=s.z.uuid(),hr=s.z.object({key:Ze,name:s.z.string().min(1),color:s.z.string()}),ww="labeled_by",bw="sy_label_set",vw="sy_label_delete",Rl=hr.extend({key:Ze.optional()}),Tw=s.object({labels:Rl.array()}),Ow=s.object({labels:hr.array()}),zw=s.object({keys:Ze.array()}),Ml=s.object({id:R,labels:Ze.array(),replace:s.boolean().optional()}),Sw=Ml.omit({replace:!0}),Nn=s.object({}),Ew="/label/create",Nw="/label/delete",xw="/label/set",Aw="/label/remove",kw="/label/retrieve",Cw=s.object({keys:Ze.array().optional(),for:R.optional(),searchTerm:s.string().optional(),offset:s.number().optional(),limit:s.number().optional()}),Iw=s.object({key:Ze}).transform(({key:t})=>({keys:[t]})),jw=s.union([Iw,Cw]),Rw=s.object({labels:Z(hr)});let Ul=class{type="label";client;constructor(t){this.client=t}async retrieve(t){const e="key"in t,r=await w(this.client,kw,t,jw,Rw);return Xe("Label",t,r.labels,e),e?r.labels[0]:r.labels}async label(t,e,r={}){await w(this.client,xw,{id:t,labels:e,replace:r.replace},Ml,Nn)}async remove(t,e){await w(this.client,Aw,{id:t,labels:e},Sw,Nn)}async create(t){const e=Array.isArray(t),r=await w(this.client,Ew,{labels:O.toArray(t)},Tw,Ow);return e?r.labels:r.labels[0]}async delete(t){await w(this.client,Nw,{keys:O.toArray(t)},zw,Nn)}};const Mw=t=>({type:"label",key:t}),Uw=Object.freeze(Object.defineProperty({__proto__:null,Client:Ul,DELETE_CHANNEL_NAME:vw,LABELED_BY_ONTOLOGY_RELATIONSHIP_TYPE:ww,SET_CHANNEL_NAME:bw,keyZ:Ze,labelZ:hr,newZ:Rl,ontologyID:Mw},Symbol.toStringTag,{value:"Module"})),_=s.z.uuid(),Xs=s.z.string().min(1),dr=s.z.object({key:_,name:Xs,timeRange:L.z,color:s.z.string().optional(),labels:hr.array().or(s.z.null().transform(()=>{})).optional(),get parent(){return dr.optional().nullable().transform(t=>t===void 0?null:t)}}),Ll=dr.omit({parent:!0,labels:!0}).partial({key:!0}),Lw="sy_range_alias_set",Pw="sy_range_alias_delete",Dw=s.z.object({range:_,aliases:s.z.string().array()}),$w=s.z.object({aliases:s.z.record(s.z.string(),U)}),Bw=s.z.object({range:_,aliases:s.z.record(U,s.z.string())}),Zw=s.z.unknown(),Fw=s.z.object({range:_,channels:U.array()}),qw=s.z.unknown(),Yw=s.z.object({range:_}),_w=s.z.object({aliases:s.z.record(s.z.string(),s.z.string())}),Hw=s.z.object({range:_,channels:U.array()}),Vw=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 w(this.client,ot.RESOLVE_ENDPOINT,{range:this.rangeKey,aliases:r},Dw,$w);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 w(this.client,ot.SET_ENDPOINT,{range:this.rangeKey,aliases:e},Bw,Zw)}async list(){return(await w(this.client,ot.LIST_ENDPOINT,{range:this.rangeKey},Yw,_w)).aliases}async retrieve(e){const r=typeof e=="number",n=await w(this.client,ot.RETRIEVE_ENDPOINT,{range:this.rangeKey,channels:O.toArray(e)},Hw,Vw);return r?n.aliases[e]:n.aliases}async delete(e){await w(this.client,ot.DELETE_ENDPOINT,{range:this.rangeKey,channels:e},Fw,qw)}};const Ww=s.z.object({alias:s.z.string().optional(),channel:U,range:_}),Pl="---",Gw=t=>`${t.range}${Pl}${t.channel}`,Kw=t=>{const[e,r]=t.split(Pl);return{range:e,channel:Number(r)}},Jw="sy_range_kv_set",Xw="sy_range_kv_delete",Qs=s.z.object({range:_,key:s.z.string(),value:s.z.string()}),Qw=({range:t,key:e})=>`${t}<--->${e}`,eb=s.z.object({range:_,keys:s.z.string().array()}),tb=s.z.object({pairs:Z(Qs)}),rb=s.z.object({range:_,pairs:Qs.array()}),nb=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 w(this.client,We.GET_ENDPOINT,{range:this.rangeKey,keys:O.toArray(e)},eb,tb);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;Ri(e)?n=Object.entries(e).map(([a,i])=>({range:this.rangeKey,key:a,value:i})):n=[{range:this.rangeKey,key:e,value:r}],await w(this.client,We.SET_ENDPOINT,{range:this.rangeKey,pairs:n},rb,s.z.unknown())}async delete(e){await w(this.client,We.DELETE_ENDPOINT,{range:this.rangeKey,keys:O.toArray(e)},nb,s.z.unknown())}}const sb="sy_range_set",ab="sy_range_delete";class Dl{key;name;kv;timeRange;color;parent;labels;channels;aliaser;frameClient;labelClient;ontologyClient;rangeClient;constructor({name:e,timeRange:r=L.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 ct(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:ct(this.key)})}async addLabel(...e){await this.labelClient.label(ct(this.key),e)}async removeLabel(...e){await this.labelClient.remove(ct(this.key),e)}static sort(e,r){return L.sort(e.timeRange,r.timeRange)}}const ib=s.z.object({keys:_.array().optional(),names:s.z.array(s.z.string()).optional(),searchTerm:s.z.string().optional(),overlapsWith:L.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()}),ob=ib.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(L.z.transform(t=>({overlapsWith:t}))),lb="/range/retrieve",cb=s.z.object({ranges:Z(dr)});let $l=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 w(this.unaryClient,lb,t,ob,cb);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(ct(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(Bl(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 Dl(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 L(t.data?.timeRange),color:t.data?.color,labels:[],parent:null})}};const ct=t=>({type:"range",key:t}),ub=t=>({type:"range-alias",key:t}),Bl=({data:t,id:{key:e},name:r})=>{const n=L.z.parse(t?.timeRange);return{key:e,name:r,timeRange:n,color:typeof t?.color=="string"?t.color:void 0,labels:[],parent:null}},hb=s.z.object({ranges:dr.array()}),db=s.z.object({parent:R.optional(),ranges:Ll.array()}),fb=s.z.object({keys:_.array()}),yb=s.z.object({}),pb=s.z.object({key:_,name:Xs}),gb=s.z.object({}),mb="/range/create",wb="/range/delete",bb="/range/rename";class Zl{client;constructor(e){this.client=e}async rename(e,r){await w(this.client,bb,{key:e,name:r},pb,gb)}async create(e,r){return(await w(this.client,mb,{ranges:e,...r},db,hb)).ranges}async delete(e){await w(this.client,wb,{keys:e},fb,yb)}}const vb=Object.freeze(Object.defineProperty({__proto__:null,Aliaser:it,Client:$l,DELETE_ALIAS_CHANNEL_NAME:Pw,DELETE_CHANNEL_NAME:ab,KV:We,KV_DELETE_CHANNEL:Xw,KV_SET_CHANNEL:Jw,Range:Dl,SET_ALIAS_CHANNEL_NAME:Lw,SET_CHANNEL_NAME:sb,Writer:Zl,aliasKey:Gw,aliasOntologyID:ub,aliasZ:Ww,convertOntologyResourceToPayload:Bl,decodeDeleteAliasChange:Kw,keyZ:_,kvPairKey:Qw,kvPairZ:Qs,nameZ:Xs,newZ:Ll,ontologyID:ct,payloadZ:dr},Symbol.toStringTag,{value:"Module"})),Tb="/api/v1/";class Ob{url;unary;stream;secure;constructor(e,r={},n=!1){this.secure=n,this.url=e.child(Tb);const a=new Ke.JSONCodec;this.unary=kh(new Ah(this.url,a,this.secure),r),this.stream=new Mr(this.url,a,this.secure)}use(...e){this.unary.use(...e),this.stream.use(...e)}}const fr=s.z.uuid(),ea=s.z.object({key:fr,name:s.z.string(),data:ze.unknownZ.or(s.z.string().transform(Se))}),zb=ea.partial({key:!0}).transform(t=>({...t,data:JSON.stringify(t.data)})),be=s.z.uuid(),on=s.z.object({key:be,name:s.z.string(),layout:ze.unknownZ.or(s.z.string().transform(Se))}),Fl=on.partial({key:!0}).transform(t=>({...t,layout:JSON.stringify(t.layout)})),ql=on.omit({layout:!0}).extend({layout:s.z.string().transform(Se)}),Sb="/workspace/lineplot/retrieve",Eb="/workspace/lineplot/create",Nb="/workspace/lineplot/rename",xb="/workspace/lineplot/set-data",Ab="/workspace/lineplot/delete",kb=s.z.object({keys:fr.array()}),Cb=s.z.object({workspace:be,linePlots:zb.array()}),Ib=s.z.object({key:fr,name:s.z.string()}),jb=s.z.object({key:fr,data:s.z.string()}),Rb=s.z.object({keys:fr.array()}),Mb=s.z.object({linePlots:Z(ea)}),Ub=s.z.object({linePlots:ea.array()}),xn=s.z.object({});let Lb=class{client;constructor(t){this.client=t}async create(t,e){const r=Array.isArray(e),n=await w(this.client,Eb,{workspace:t,linePlots:O.toArray(e)},Cb,Ub);return r?n.linePlots:n.linePlots[0]}async rename(t,e){await w(this.client,Nb,{key:t,name:e},Ib,xn)}async setData(t,e){await w(this.client,xb,{key:t,data:JSON.stringify(e)},jb,xn)}async retrieve(t){const e=Array.isArray(t),r=await w(this.client,Sb,{keys:O.toArray(t)},kb,Mb);return e?r.linePlots:r.linePlots[0]}async delete(t){await w(this.client,Ab,{keys:O.toArray(t)},Rb,xn)}};const yr=s.z.uuid(),ta=s.z.object({key:yr,name:s.z.string(),data:ze.unknownZ.or(s.z.string().transform(Se))}),Pb=ta.partial({key:!0}).transform(t=>({...t,data:JSON.stringify(t.data)})),Db="/workspace/log/retrieve",$b="/workspace/log/create",Bb="/workspace/log/rename",Zb="/workspace/log/set-data",Fb="/workspace/log/delete",qb=s.z.object({keys:yr.array()}),Yb=s.z.object({workspace:be,logs:Pb.array()}),_b=s.z.object({key:yr,name:s.z.string()}),Hb=s.z.object({key:yr,data:s.z.string()}),Vb=s.z.object({keys:yr.array()}),Wb=s.z.object({logs:ta.array()}),Gb=s.z.object({logs:ta.array()}),An=s.z.object({});let Kb=class{client;constructor(t){this.client=t}async create(t,e){const r=Array.isArray(e),n=await w(this.client,$b,{workspace:t,logs:O.toArray(e)},Yb,Gb);return r?n.logs:n.logs[0]}async rename(t,e){await w(this.client,Bb,{key:t,name:e},_b,An)}async setData(t,e){await w(this.client,Zb,{key:t,data:JSON.stringify(e)},Hb,An)}async retrieve(t){const e=Array.isArray(t),r=await w(this.client,Db,{keys:O.toArray(t)},qb,Wb);return e?r.logs:r.logs[0]}async delete(t){await w(this.client,Fb,{keys:O.toArray(t)},Vb,An)}};const et=s.z.uuid(),ln=s.z.object({key:et,name:s.z.string(),data:ze.unknownZ.or(s.z.string().transform(Se)),snapshot:s.z.boolean()}),Yl=ln.partial({key:!0,snapshot:!0}).transform(t=>({...t,data:JSON.stringify(t.data)})),ra=ln.extend({data:s.z.string().transform(Se)}),St=s.z.uuid(),_l=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()}),Hl=s.z.object({key:s.z.string(),name:s.z.string(),regions:_l.array()}),Vl=s.z.object({key:s.z.string(),position:uo.xy,orientation:jd.outer}),Jb=s.z.object({zoom:s.z.number().positive().default(1),position:uo.xy}),Wl=s.z.object({svg:s.z.string().min(1,"SVG is required"),states:Hl.array(),variant:s.z.string().min(1,"Variant is required"),handles:Vl.array(),scale:s.z.number().positive().default(1),scaleStroke:s.z.boolean().default(!1),previewViewport:Jb.default({zoom:1,position:{x:0,y:0}})}),cn=s.z.object({key:St,version:s.z.literal(1).optional().default(1),name:s.z.string().min(1,"Name is required"),data:Wl}),Gl=cn.partial({key:!0}),Xb="/workspace/schematic/symbol/retrieve",Qb="/workspace/schematic/symbol/create",ev="/workspace/schematic/symbol/rename",tv="/workspace/schematic/symbol/delete",rv="/workspace/schematic/symbol/retrieve_group",nv=s.z.object({symbols:Gl.array(),parent:R}),sv=s.z.object({key:St,name:s.z.string()}),av=s.z.object({keys:St.array()}),iv=s.z.object({keys:St.array().optional(),searchTerm:s.z.string().optional(),offset:s.z.number().optional(),limit:s.z.number().optional()}),ov=s.z.object({key:St}).transform(({key:t})=>({keys:[t]})),lv=s.z.union([ov,iv]),cv=s.z.object({symbols:Z(cn)}),uv=s.z.object({symbols:cn.array()}),Wa=s.z.object({}),hv=s.z.object({}),dv=s.z.object({group:Xr}),fv="sy_schematic_symbol_set",yv="sy_schematic_symbol_delete";let Kl=class{client;constructor(t){this.client=t}async create(t){const e="symbols"in t,r=e?t.symbols:[t],n=await w(this.client,Qb,{symbols:r,parent:t.parent},nv,uv);return e?n.symbols:n.symbols[0]}async rename(t,e){await w(this.client,ev,{key:t,name:e},sv,Wa)}async retrieve(t){const e="key"in t,r=await w(this.client,Xb,t,lv,cv);return Xe("Schematic Symbol",t,r.symbols,e),e?r.symbols[0]:r.symbols}async delete(t){await w(this.client,tv,{keys:O.toArray(t)},av,Wa)}async retrieveGroup(){return(await w(this.client,rv,{},hv,dv)).group}};const pv=t=>({type:"schematic_symbol",key:t}),gv=Object.freeze(Object.defineProperty({__proto__:null,Client:Kl,DELETE_CHANNEL_NAME:yv,SET_CHANNEL_NAME:fv,handleZ:Vl,keyZ:St,newZ:Gl,ontologyID:pv,regionZ:_l,specZ:Wl,stateZ:Hl,symbolZ:cn},Symbol.toStringTag,{value:"Module"})),mv="/workspace/schematic/retrieve",wv="/workspace/schematic/create",bv="/workspace/schematic/rename",vv="/workspace/schematic/set-data",Tv="/workspace/schematic/delete",Ov="/workspace/schematic/copy",zv=s.z.object({keys:et.array()}),Sv=s.z.object({workspace:be,schematics:Yl.array()}),Ev=s.z.object({key:et,name:s.z.string()}),Nv=s.z.object({key:et,data:s.z.string()}),xv=s.z.object({keys:et.array()}),Av=s.z.object({key:et,name:s.z.string(),snapshot:s.z.boolean()}),kv=s.z.object({schematics:Z(ra)}),Cv=s.z.object({schematics:ra.array()}),Iv=s.z.object({schematic:ln}),kn=s.z.object({});let Jl=class{symbols;client;constructor(t){this.client=t,this.symbols=new Kl(t)}async create(t,e){const r=Array.isArray(e),n=await w(this.client,wv,{workspace:t,schematics:O.toArray(e)},Sv,Cv);return r?n.schematics:n.schematics[0]}async rename(t,e){await w(this.client,bv,{key:t,name:e},Ev,kn)}async setData(t,e){await w(this.client,vv,{key:t,data:JSON.stringify(e)},Nv,kn)}async retrieve(t){const e=Array.isArray(t),r=await w(this.client,mv,{keys:O.toArray(t)},zv,kv);return e?r.schematics:r.schematics[0]}async delete(t){await w(this.client,Tv,{keys:O.toArray(t)},xv,kn)}async copy(t,e,r){return(await w(this.client,Ov,{key:t,name:e,snapshot:r},Av,Iv)).schematic}};const jv=t=>({type:"schematic",key:t}),Rv=Object.freeze(Object.defineProperty({__proto__:null,Client:Jl,keyZ:et,newZ:Yl,ontologyID:jv,remoteZ:ra,schematicZ:ln,symbol:gv},Symbol.toStringTag,{value:"Module"})),pr=s.z.uuid(),Xl=s.z.object({key:pr,name:s.z.string(),data:ze.unknownZ.or(s.z.string().transform(Se))}),Mv=Xl.partial({key:!0}).transform(t=>({...t,data:JSON.stringify(t.data)})),Ql=Xl.extend({data:s.z.string().transform(Se)}),Uv="/workspace/table/retrieve",Lv="/workspace/table/create",Pv="/workspace/table/rename",Dv="/workspace/table/set-data",$v="/workspace/table/delete",Bv=s.z.object({keys:pr.array()}),Zv=s.z.object({workspace:be,tables:Mv.array()}),Fv=s.z.object({key:pr,name:s.z.string()}),qv=s.z.object({key:pr,data:s.z.string()}),Yv=s.z.object({keys:pr.array()}),_v=s.z.object({tables:Ql.array()}),Hv=s.z.object({tables:Ql.array()}),Cn=s.z.object({});let Vv=class{client;constructor(t){this.client=t}async create(t,e){const r=Array.isArray(e),n=await w(this.client,Lv,{workspace:t,tables:O.toArray(e)},Zv,Hv);return r?n.tables:n.tables[0]}async rename(t,e){await w(this.client,Pv,{key:t,name:e},Fv,Cn)}async setData(t,e){await w(this.client,Dv,{key:t,data:JSON.stringify(e)},qv,Cn)}async retrieve(t){const e=Array.isArray(t),r=await w(this.client,Uv,{keys:O.toArray(t)},Bv,_v);return e?r.tables:r.tables[0]}async delete(t){await w(this.client,$v,{keys:O.toArray(t)},Yv,Cn)}};const Ga="/workspace/retrieve",Wv="/workspace/create",Gv="/workspace/rename",Kv="/workspace/set-layout",Jv="/workspace/delete",Ka=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()}),Xv=s.z.object({workspaces:Fl.array()}),Qv=s.z.object({key:be,name:s.z.string()}),eT=s.z.object({key:be,layout:s.z.string()}),tT=s.z.object({keys:be.array()}),Ja=s.z.object({workspaces:Z(on)}),rT=s.z.object({workspaces:ql.array()}),In=s.z.object({}),nT="sy_workspace_set",sT="sy_workspace_delete";class ec{type="workspace";schematic;linePlot;log;table;client;constructor(e){this.client=e,this.schematic=new Jl(e),this.linePlot=new Lb(e),this.log=new Kb(e),this.table=new Vv(e)}async create(e){const r=Array.isArray(e),n=await w(this.client,Wv,{workspaces:O.toArray(e)},Xv,rT);return r?n.workspaces:n.workspaces[0]}async rename(e,r){await w(this.client,Gv,{key:e,name:r},Qv,In)}async setLayout(e,r){await w(this.client,Kv,{key:e,layout:JSON.stringify(r)},eT,In)}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 w(this.client,Ga,r,Ka,Ja);return n?a.workspaces:a.workspaces[0]}async retrieveByAuthor(e){return(await w(this.client,Ga,{author:e},Ka,Ja)).workspaces}async delete(e){await w(this.client,Jv,{keys:O.toArray(e)},tT,In)}}const aT=t=>({type:"workspace",key:t}),iT=Object.freeze(Object.defineProperty({__proto__:null,Client:ec,DELETE_CHANNEL_NAME:sT,SET_CHANNEL_NAME:nT,keyZ:be,newZ:Fl,ontologyID:aT,remoteZ:ql,workspaceZ:on},Symbol.toStringTag,{value:"Module"})),tc=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:So.breakerConfigZ.optional()});class oT extends fl{createdAt;props;ranges;channels;auth;user;access;connectivity;ontology;workspaces;labels;hardware;control;static connectivity=Dr;transport;clientVersion="0.45.1";constructor(e){const r=tc.parse(e),{host:n,port:a,username:i,password:o,connectivityPollFrequency:l,secure:c,retry:u}=r,h=new Ob(new Dt({host:n,port:Number(a)}),u,c);h.use(qy);let f;i!=null&&o!=null&&(f=new Ug(h.unary,{username:i,password:o}),h.use(f.middleware()));const d=new Ys(new cr(h.unary)),z=new el(h.unary,d);super(h.stream,h.unary,d),this.createdAt=y.now(),this.props=r,this.auth=f,this.transport=h,this.channels=new Jo(this,d,h.unary,z),this.connectivity=new Dr(h.unary,l,this.clientVersion,r.name),this.control=new gl(this),this.ontology=new _o(h.unary,this);const E=new Zl(this.transport.unary);this.labels=new Ul(this.transport.unary),this.ranges=new $l(this,E,this.transport.unary,d,this.labels,this.ontology),this.access=new Up(this.transport.unary),this.user=new xg(this.transport.unary),this.workspaces=new ec(this.transport.unary);const C=new Ol(this.transport.unary),$=new kl(this.transport.unary,this,this.ontology,this.ranges),j=new zl(this.transport.unary,$);this.hardware=new mm($,j,C)}get key(){return this.createdAt.valueOf().toString()}close(){this.connectivity.stopChecking()}}S.seconds(1);const lT=t=>Array.isArray(t)?t:t==null?[]:[t],cT=Object.freeze(Object.defineProperty({__proto__:null,toArray:lT},Symbol.toStringTag,{value:"Module"})),jn=t=>t!=null&&typeof t=="object"&&!Array.isArray(t),uT=(t,e)=>{let r=null;return e===0?t:(...n)=>{r!==null&&(clearTimeout(r),r=null),r=setTimeout(()=>t(...n),e)}},hT=(t,e)=>{let r=null;return e===0?t:(...n)=>{r===null&&(r=setTimeout(()=>{t(...n),r=null},e))}},J=".",rc=(t,e,r=J)=>{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)},Et=(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)},dT=(t,e)=>{const r=t.split(J);return r.forEach((n,a)=>{e=Et(e,n),e!=null&&typeof e=="object"&&"key"in e&&(r[a]=e.key)}),r.join(J)},fT=(t,e)=>{const r=t.split(J);return e<0?r[r.length+e]:r[e]},yT=(t,e)=>{if(e.length===0)return!0;const r=t.split(J),n=e.split(J);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},lt=t=>{const e=parseInt(t);return isNaN(e)||e<0||e.toString()!==t?null:e},ls=(t,e)=>{for(let r=1;r<=e.length;r++){const n=e.slice(0,r).join(J);if(Et(t,n)!=null)return[n,r]}return null},na=(t,e,r={optional:!1})=>{const{optional:n,getter:a=Et}=r;if(e==="")return t;const i=e.split(J);if(i.length===1){const l=a(t,i[0]);if(l===void 0){if(n)return null;throw new Error(`Path ${e} does not exist. ${i[0]} is undefined`)}return l}const o=(l,c)=>{if(c>=i.length)return l;for(let u=i.length-c;u>=1;u--){const h=i.slice(c,c+u).join(J),f=a(l,h);if(f!==void 0){if(c+u===i.length)return f;if(f===null){if(n)return null;throw new Error(`Path ${e} does not exist. ${h} is null`)}return o(f,c+u)}}if(n)return null;throw new Error(`Path ${e} does not exist. ${i[c]} is undefined`)};return o(t,0)},pT=(t,e)=>na(t,e,{optional:!0})!==null,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,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},cs=(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(!cs(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(!cs(l,c))return!1}else if(l!==c)return!1}return!0},nc=(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(!nc(i,o))return!1}else if(i!==o)return!1}return!0},us=(t,...e)=>{if(e.length===0)return t;const r=e.shift();if(jn(t)&&jn(r))for(const n in r)try{jn(r[n])?(n in t||Object.assign(t,{[n]:{}}),us(t[n],r[n])):Object.assign(t,{[n]:r[n]})}catch(a){throw a instanceof TypeError?new TypeError(`.${n}: ${a.message}`):a}return us(t,...e)},wT=(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)},bT=(t,e)=>{const r=e.split(J);let n=t,a=0;for(;a<r.length;){if(a===r.length-1){const o=r[a];if(Array.isArray(n)){const l=parseInt(o);if(!isNaN(l)&&l<n.length){n.splice(l,1);return}const c=n[0];if(typeof c=="object"&&"key"in c){const u=n.findIndex(h=>h.key===o);if(u!==-1){n.splice(u,1);return}}return}delete n[o];return}let i=!1;if(Array.isArray(n)&&n.length>0){const o=n[0];if(typeof o=="object"&&"key"in o)for(let l=r.length-a;l>=1;l--){const c=r.slice(a,a+l).join(J),u=n.find(h=>h.key===c);if(u!=null){if(a+l===r.length){const h=n.findIndex(f=>f.key===c);h!==-1&&n.splice(h,1);return}n=u,a+=l,i=!0;break}}}if(!i)for(let o=r.length-a;o>=1;o--){const l=r.slice(a,a+o).join(J);if(!Array.isArray(n)&&typeof n=="object"&&n!==null&&l in n){if(a+o===r.length){delete n[l];return}n=n[l],a+=o,i=!0;break}}if(!i){const o=Et(n,r[a]);if(o==null)return;n=o,a++}}},vT=(t,e,r)=>{const n=e.split(J);let a=t,i=0;for(;i<n.length-1;){const o=ls(a,n.slice(i,n.length-1));let l;o!=null?[l,i]=[o[0],i+o[1]]:(l=n[i],i++);let c=Et(a,l);if(c==null){const u=n[i];let h=lt(u);h==null&&u.startsWith("-")&<(u.substring(1))!=null&&(h=0),c=h!=null?[]:{},a[l]=c}a=c}try{const o=n[n.length-1];if(Array.isArray(a)){let c=lt(o);if(c==null){if(o.startsWith("-")){const u=lt(o.substring(1));u!=null&&(c=a.length-u)}if(c==null){if(a.length===0){const h=lt(o);if(h!=null){a[h]=r;return}}const u=a[0];if(typeof u=="object"&&"key"in u){const h=a.findIndex(f=>f.key===o);if(h!==-1){a[h]=r;return}}return}}a[c]=r;return}const l=ls(a,[o]);if(l!=null){a[l[0]]=r;return}a[o]=r}catch(o){throw console.error("failed to set value",r,"at path",e,"on object",t),o}},sc=Object.freeze(Object.defineProperty({__proto__:null,SEPARATOR:J,copy:gT,defaultGetter:Et,difference:mT,element:fT,equal:cs,findBestKey:ls,get:na,getIndex:lt,has:pT,override:us,overrideValidItems:wT,partialEqual:nc,pathsMatch:yT,remove:bT,resolvePath:dT,set:vT,transformPath:rc},Symbol.toStringTag,{value:"Module"}));let TT=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=OT(e,this.sender),n=new zT(r);return this.handlers.set(e,n),n}};const OT=(t,e)=>(r,n)=>e({type:t,payload:r},n);class zT{_send;handler;constructor(e){this._send=e,this.handler=null}send(e,r=[]){this._send(e,r)}handle(e){this.handler=e}}const hs=(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}},ac=t=>typeof t=="function",sa=(t,e)=>ac(t)?t(e):t,un=t=>ic(t)?t():t,ic=t=>typeof t=="function",oc=({initial:t,value:e,onChange:r})=>{const[n,a]=Os.useState(e??t);return e!=null&&r!=null?[e,r]:[n,a]},lc=({initial:t,value:e,onChange:r})=>{const[n,a]=Os.useState(un(e??t));return e!=null&&r!=null?[e,r]:[n,a]},ST=(t,e)=>{const[r,n]=Os.useState(()=>{const a=localStorage.getItem(e);return a==null?un(t):JSON.parse(a)});return[r,a=>{n(a),localStorage.setItem(e,JSON.stringify(a))}]},ET=Object.freeze(Object.defineProperty({__proto__:null,executeInitialSetter:un,executeSetter:sa,isInitialSetter:ic,isSetter:ac,usePassthrough:oc,usePersisted:ST,usePurePassthrough:lc},Symbol.toStringTag,{value:"Module"}));let Xa=null;const NT=()=>(Xa??=document.createElement("canvas"),Xa),xT=(t,e,r)=>{if(p.S.RUNTIME==="node")return{width:0,height:0};r??=NT().getContext("2d"),r.font=e;const n=r.measureText(t);return hn(n)},hn=t=>({width:Math.trunc(Math.abs(t.actualBoundingBoxLeft)+Math.abs(t.actualBoundingBoxRight)),height:Math.trunc(Math.abs(t.actualBoundingBoxAscent)+Math.abs(t.actualBoundingBoxDescent))}),Bt=["h1","h2","h3","h4","h5","p","small"],AT=s.z.enum(Bt),kT=t=>{const e=Bt.indexOf(t);return e===-1||e===Bt.length-1?t:Bt[e+1]},CT=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()}),IT={tiny:"small",small:"small",medium:"p",large:"h5",huge:"h2"},jT={h1:"huge",h2:"huge",h3:"huge",h4:"large",h5:"small",p:"medium",small:"small"},RT=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]],MT=s.z.object({m2:p.fr.colorZ,m1:p.fr.colorZ,z:p.fr.colorZ,p1:p.fr.colorZ,p2:p.fr.colorZ}),Or=MT.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))}})),cc=s.z.object({name:s.z.string(),key:s.z.string(),colors:s.z.object({border:p.fr.colorZ,primary:Or,gray:RT,error:Or,secondary:Or,warning:Or,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)),UT="'Inter Variable', sans-serif",LT="'Geist Mono', monospace",PT=6,At=[357,91,55,1],kt=[48,90,55,1],DT=["#FEFEFE","#FAFAFA","#F2F2F2","#ECECEC","#E4E4E4","#D1D1D1","#BCBCBC","#ACACAC","#8F8F8F","#4F4F4F","#292929","#050505"],Ct=Object.fromEntries(DT.map((t,e)=>[`l${e}`,t])),$T=()=>typeof window>"u"?!1:window.devicePixelRatio>1,BT=$T(),ds={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:Ct,border:Ct.l4,error:{m2:p.fr.fromHSLA(re(At,30)),m1:p.fr.fromHSLA(re(At,40)),z:p.fr.fromHSLA(At),p1:p.fr.fromHSLA(re(At,65)),p2:p.fr.fromHSLA(re(At,77))},warning:{m2:p.fr.fromHSLA(re(kt,30)),m1:p.fr.fromHSLA(re(kt,40)),z:p.fr.fromHSLA(kt),p1:p.fr.fromHSLA(re(kt,65)),p2:p.fr.fromHSLA(re(kt,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:Ct.l11,textInverted:Ct.l0,textOnPrimary:Ct.l0},sizes:{base:PT,border:{radius:3,width:BT?.5:1,thickWidth:1},schematic:{elementStrokeWidth:2}},typography:{family:UT,codeFamily:LT,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}}},uc=Object.freeze({...ds,key:"synnaxLight",name:"Synnax Light"}),ZT=["#020202","#080808","#151515","#242424","#2F2F2F","#3B3B3B","#4A4A4A","#5C5C5C","#767676","#959595","#dadada","#FAFAFA"],It=Object.fromEntries(ZT.map((t,e)=>[`l${e}`,t])),hc=Object.freeze({...ds,key:"synnaxDark",name:"Synnax Dark",colors:{...ds.colors,gray:It,logo:"var(--pluto-text-color)",border:It.l3,text:It.l11,textInverted:It.l0,textOnPrimary:It.l11}}),FT={synnaxDark:hc,synnaxLight:uc},dc=["tiny","small","medium","large","huge"],fc=s.z.enum(dc),qT=t=>fc.safeParse(t).success;class gt{_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 gt(e,this.extendPath(e),this.serviceName,this.noop)}extendPath(e){return`${this.path}.${e}`}get noop(){return this._noop}static NOOP=new gt("","","")}const fs=["debug","info","warn","error"],yc=t=>{const e=fs.indexOf(t);return({level:r})=>fs.indexOf(r)>=e},YT=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 mt{meta=gt.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 mt({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,zr(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,zr(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,zr(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,zr(r)))}static NOOP=new mt}const zr=t=>typeof t=="function"?t():t;var _T=typeof globalThis=="object"?globalThis:typeof self=="object"?self:typeof window=="object"?window:typeof global=="object"?global:{},_e="1.9.0",Qa=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function HT(t){var e=new Set([t]),r=new Set,n=t.match(Qa);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(Qa);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 VT=HT(_e),WT=_e.split(".")[0],Gt=Symbol.for("opentelemetry.js.api."+WT),Kt=_T;function aa(t,e,r,n){var a;n===void 0&&(n=!1);var i=Kt[Gt]=(a=Kt[Gt])!==null&&a!==void 0?a:{version:_e};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!==_e){var o=new Error("@opentelemetry/api: Registration of version v"+i.version+" for "+t+" does not match previously registered API v"+_e);return r.error(o.stack||o.message),!1}return i[t]=e,r.debug("@opentelemetry/api: Registered a global for "+t+" v"+_e+"."),!0}function Jt(t){var e,r,n=(e=Kt[Gt])===null||e===void 0?void 0:e.version;if(!(!n||!VT(n)))return(r=Kt[Gt])===null||r===void 0?void 0:r[t]}function ia(t,e){e.debug("@opentelemetry/api: Unregistering a global for "+t+" v"+_e+".");var r=Kt[Gt];r&&delete r[t]}var GT=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},KT=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))},JT=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 jt("debug",this._namespace,e)},t.prototype.error=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return jt("error",this._namespace,e)},t.prototype.info=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return jt("info",this._namespace,e)},t.prototype.warn=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return jt("warn",this._namespace,e)},t.prototype.verbose=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return jt("verbose",this._namespace,e)},t}();function jt(t,e,r){var n=Jt("diag");if(n)return r.unshift(e),n[t].apply(n,KT([],GT(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 XT(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 QT=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},eO=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))},tO="diag",Xt=function(){function t(){function e(a){return function(){for(var i=[],o=0;o<arguments.length;o++)i[o]=arguments[o];var l=Jt("diag");if(l)return l[a].apply(l,eO([],QT(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=Jt("diag"),f=XT((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 aa("diag",f,r,!0)};r.setLogger=n,r.disable=function(){ia(tO,r)},r.createComponentLogger=function(a){return new JT(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}(),rO=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},nO=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.")},sO=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=rO(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=nO(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}();Xt.instance();function aO(t){return t===void 0&&(t={}),new sO(new Map(Object.entries(t)))}function iO(t){return Symbol.for(t)}var oO=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}(),lO=new oO,cO={get:function(t,e){if(t!=null)return t[e]},keys:function(t){return t==null?[]:Object.keys(t)}},uO={set:function(t,e,r){t!=null&&(t[e]=r)}},hO=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},dO=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))},fO=function(){function t(){}return t.prototype.active=function(){return lO},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,dO([n],hO(a),!1))},t.prototype.bind=function(e,r){return r},t.prototype.enable=function(){return this},t.prototype.disable=function(){return this},t}(),yO=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))},Rn="context",gO=new fO,pc=function(){function t(){}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalContextManager=function(e){return aa(Rn,e,Xt.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],yO(i),!1))},t.prototype.bind=function(e,r){return this._getContextManager().bind(e,r)},t.prototype._getContextManager=function(){return Jt(Rn)||gO},t.prototype.disable=function(){this._getContextManager().disable(),ia(Rn,Xt.instance())},t}(),ys;(function(t){t[t.UNSET=0]="UNSET",t[t.OK=1]="OK",t[t.ERROR=2]="ERROR"})(ys||(ys={}));var mO=pc.getInstance(),wO=function(){function t(){}return t.prototype.inject=function(e,r){},t.prototype.extract=function(e,r){return e},t.prototype.fields=function(){return[]},t}(),oa=iO("OpenTelemetry Baggage Key");function gc(t){return t.getValue(oa)||void 0}function bO(){return gc(pc.getInstance().active())}function vO(t,e){return t.setValue(oa,e)}function TO(t){return t.deleteValue(oa)}var Mn="propagation",OO=new wO,zO=function(){function t(){this.createBaggage=aO,this.getBaggage=gc,this.getActiveBaggage=bO,this.setBaggage=vO,this.deleteBaggage=TO}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalPropagator=function(e){return aa(Mn,e,Xt.instance())},t.prototype.inject=function(e,r,n){return n===void 0&&(n=uO),this._getGlobalPropagator().inject(e,r,n)},t.prototype.extract=function(e,r,n){return n===void 0&&(n=cO),this._getGlobalPropagator().extract(e,r,n)},t.prototype.fields=function(){return this._getGlobalPropagator().fields()},t.prototype.disable=function(){ia(Mn,Xt.instance())},t.prototype._getGlobalPropagator=function(){return Jt(Mn)||OO},t}(),SO=zO.getInstance();const ei=["bench","debug","prod"],EO=t=>e=>ei.indexOf(e)>=ei.indexOf(t);class Qt{meta=gt.NOOP;otelTracer;filter;constructor(e,r=EO("debug")){this.otelTracer=e,this.filter=r}child(e){const r=new Qt(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 ps(e,this.otelTracer.startSpan(e));return i.start(),()=>i.end()}return a?n(new mc(e)):this.otelTracer.startActiveSpan(e,i=>{const o=new ps(e,i);return n(o)})}propagate(e){if(this.meta.noop)return;const r=mO.active();SO.inject(r,e,{set:(n,a,i)=>{n[a]=i}})}static NOOP=new Qt}class ps{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:ys.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 mc{key;constructor(e){this.key=e}set(){}recordError(e){}}class wt{meta;T;L;constructor({key:e="",serviceName:r="",logger:n=mt.NOOP,tracer:a=Qt.NOOP,noop:i=!1,__meta:o}){this.meta=o??new gt(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 wt({__meta:r,tracer:this.T,logger:this.L})}static NOOP=new wt({noop:!0})}const NO=wt.NOOP,Ue=Object.freeze(Object.defineProperty({__proto__:null,Instrumentation:wt,LOG_LEVELS:fs,Logger:mt,NOOP:NO,NoopSpan:mc,Tracer:Qt,_Span:ps,logLevelKeyFiler:YT,logThresholdFilter:yc},Symbol.toStringTag,{value:"Module"})),Un=(t,e)=>t instanceof Error?(t.message=`[${e}] - ${t.message}`,t):new Error(e??"unknown error",{cause:t});class dn{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 B(`[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=sa(e,this.state);this._prevState=p.Sr(this._state),this._state=hs(this._schema,r,`${this.toString()}`),this.sender.send({variant:"update",key:this.key,state:this._state})}get state(){if(this._state==null)throw new K(`[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 yt(`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=hs(this._schema,r,`${this.toString()}`);this._state!=null?this.instrumentation.L.debug("updating state",()=>({diff:sc.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 Un(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 Un(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 Un(r,`[${this.toString()}:delete]`)}}afterUpdate(e){}afterDelete(e){}validatePath(e){if(e.length===0)throw new K(`[Leaf.setState] - ${this.toString()} received an empty path`);const r=e[e.length-1];if(e.length>1)throw new K(`[Leaf.setState] - ${this.toString()} received a subPath ${e.join(".")} but is a leaf`);if(r!==this.key)throw new K(`[Leaf.setState] - ${this.toString()} received a key ${r} but expected ${this.key}`)}}class Nt extends dn{_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 K(`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 K(`[Composite.getRequiredKey] - ${this.toString()} received a key ${n} but expected ${this.key}`);return a}}const xO=s.z.object({}),AO=()=>{throw new Error("should not call create")};class Le extends Nt{static TYPE="root";static KEY="root";comms;registry;schema=xO;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:AO}),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 K(`[Root.create] - ${r} not found in registry`);return new a({key:e,type:r,sender:this.comms,instrumentation:this.instrumentation,parentCtxValues:n})}}const wc=Le.render.bind(Le),kO=Object.freeze(Object.defineProperty({__proto__:null,Composite:Nt,Leaf:dn,Root:Le,render:wc},Symbol.toStringTag,{value:"Module"})),CO=(t,e)=>Array.isArray(e)?e.some(r=>r.matches(t)):e?.matches(t)??!1,bc=(t,e,r)=>{const n=p.xr.fromException(t,e);return console.error(n),CO(t,r)?null:n},vc=(t,e,r,n)=>{if(typeof t=="function")return!0;const a=bc(t,r,n);return a!=null&&e(a),!1},Tc=async(t,e,r,n)=>{try{const a=t();a!=null&&await a}catch(a){const i=bc(a,r,n);if(i!=null)return e(i)}},Oc=t=>(e,r,n)=>{vc(e,t,r,n)&&Tc(e,t,r,n)},zc=t=>async(e,r,n)=>{vc(e,t,r,n)&&await Tc(e,t,r,n)},Sc=s.z.object({statuses:p.xr.statusZ().array()}),Br="status.aggregator";class gs extends Nt{static TYPE="status.Aggregator";schema=Sc;afterUpdate(e){e.wasSetPreviously(Br)||e.set(Br,{add:this.add.bind(this),create:p.xr.create})}add(e){this.setState(r=>({...r,statuses:[...r.statuses,p.xr.create(e)]}))}}const fn=t=>t.get(Br).add,IO=t=>{const e=t.getOptional(Br);return e!=null?e.add:()=>{}},la=t=>Oc(fn(t)),jO=t=>zc(fn(t)),RO={[gs.TYPE]:gs},ms="pluto-theming-context",Ec=s.z.object({name:s.z.string(),url:s.z.string()}),MO=s.z.object({theme:cc,fontURLs:s.z.array(Ec)});let ws=class Nc extends Nt{static TYPE="theming.Provider";static z=MO;schema=Nc.z;afterUpdate(e){if(e.getOptional(ms)!=null&&this.state.theme.key===this.prevState.theme.key)return;e.set(ms,this.state.theme),la(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 UO=t=>t.get(ms),LO={[ws.TYPE]:ws},xc=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")}),bs="alamos-provider";class vs extends Nt{static TYPE="alamos.Provider";schema=xc;afterUpdate(e){if(e.getOptional(bs)!=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(bs,this.internal.ins)}}const Ac=(t,e)=>{const r=t.get(bs);if(r==null)throw new Error("No instrumentation provider");return e==null?r:r.child(e)},PO={[vs.TYPE]:vs},jr=(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 Zr{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 Zr(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):hn(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 DO(this.scale_);return e=jr(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 DO{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 $O=`precision mediump float;
|
|
54
|
-
|
|
55
|
-
void main(void) {
|
|
56
|
-
gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
|
|
57
|
-
}
|
|
58
|
-
`,BO=`attribute vec4 a_position;
|
|
59
|
-
|
|
60
|
-
void main(void) {
|
|
61
|
-
gl_Position = a_position;
|
|
62
|
-
}
|
|
63
|
-
`,ti=t=>new Error(`failed to compile webgl program: ${t}`),ZO=new Error("null shader encountered");let kc=class{renderCtx;prog;vertShader;fragShader;uniformLocCache=new Map;constructor(e,r,n){this.renderCtx=e;const a=e.gl.createProgram();if(a==null)throw ti("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 ZO;if(n.shaderSource(a,e),n.compileShader(a),!n.getShaderParameter(a,n.COMPILE_STATUS)){const o=n.getShaderInfoLog(a);throw n.deleteShader(a),ti(o??"unknown")}n.attachShader(this.prog,a)}};const FO=new Float32Array([0,0,0,0,0,0]);class qO extends kc{positionBuffer;constructor(e){super(e,BO,$O);const r=e.gl.createBuffer();if(r==null)throw new K("webgl: failed to create buffer");this.positionBuffer=r,e.gl.bindBuffer(e.gl.ARRAY_BUFFER,this.positionBuffer),e.gl.bufferData(e.gl.ARRAY_BUFFER,FO,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 ri={high:1,low:0};class Cc{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=ri[e.priority]>=ri[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 Sr=2,ve=2;class ca{atlas;charDims;charMap;static DEFAULT_CHARS="0123456789.:-µmsNa∞ᴇ";constructor(e){const{font:r,characters:n=ca.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=hn(c),this.charDims.width+=Sr,this.charDims.height+=Sr;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 E=this.atlas.getContext("2d");E.scale(ve,ve),E.font=r,E.textBaseline="alphabetic",E.textAlign="left",E.fillStyle=p.fr.hex(a),E.clearRect(0,0,this.atlas.width,this.atlas.height),i.forEach((C,$)=>{const j=$%d,P=Math.floor($/d),he=j*h,ie=(P+1)*f;E.fillText(C,he,ie),this.charMap.set(C,$)})}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+Sr,i*ve,o*ve,n+c*i,a-o-Sr/ve,i,o)}}measureText(e){return{width:e.length*this.charDims.width,height:this.charDims.height}}}class YO{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 ca(e);return this.atlases.set(r,n),n}}const ni=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=Ac(e,"render_context"),l=new Re(r,n,a,i,o,fn(e),la(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 YO;this.lower2d=ni(new Zr(c,u,this.dpr));const h=this.upper2dCanvas.getContext("2d");if(h==null)throw new Error("Could not get 2D context");this.upper2d=ni(new Zr(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 Cc({afterRender:z,instrumentation:this.instrumentation,handleError:l}),this.region=p.Ho.ZERO,this.os==="Windows"&&(this.clearProgram=new qO(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=jr(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(jr(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=jr(r,n);e.clearRect(...p.K.couple(p.Ho.topLeft(a)),...p._.couple(p.Ho.dims(a)))}}const Ic=s.z.object({region:p.Ho.box,enabled:s.z.boolean().optional().default(!1)}),si=["gl","lower2d","upper2d"];class Ts extends dn{static TYPE="eraser";schema=Ic;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:si})}render(){this.deleted||!this.state.enabled||this.internal.renderCtx.erase(this.state.region,p.K.construct(0),...si)}}const _O={[Ts.TYPE]:Ts};exports.Aggregator=gs;exports.COMPONENT_SIZE_LEVELS=IT;exports.Cb=op;exports.Composite=Nt;exports.Context=Re;exports.Eraser=Ts;exports.GLProgram=kc;exports.Gb=gm;exports.Ib=By;exports.L=B;exports.LEVELS=Bt;exports.LEVEL_COMPONENT_SIZES=jT;exports.Leaf=dn;exports.Loop=Cc;exports.Mb=vp;exports.O=wt;exports.O$1=S;exports.Provider=ws;exports.Provider$1=vs;exports.Qb=Rm;exports.REGISTRY=LO;exports.REGISTRY$1=RO;exports.REGISTRY$2=_O;exports.REGISTRY$3=PO;exports.SIZES=dc;exports.SYNNAX_DARK=hc;exports.SYNNAX_LIGHT=uc;exports.SYNNAX_THEMES=FT;exports.T=sc;exports.Tt=K;exports._=mt;exports._b=um;exports.ab=oT;exports.aether=kO;exports.aggregatorStateZ=Sc;exports.ar=yt;exports.be=yc;exports.createAsyncErrorHandler=zc;exports.createErrorHandler=Oc;exports.d=TT;exports.dimensions=xT;exports.dimensionsFromMetrics=hn;exports.downLevel=kT;exports.eraserStateZ=Ic;exports.executeInitialSetter=un;exports.executeSetter=sa;exports.f=y;exports.fontSpecZ=Ec;exports.g=Ue;exports.iT=Uw;exports.ib=tc;exports.isSize=qT;exports.k=k;exports.levelZ=AT;exports.mT=iT;exports.nT=mw;exports.o=uT;exports.oT=vb;exports.p=na;exports.prettyParse=hs;exports.providerStateZ=xc;exports.qb=ig;exports.qe=Be;exports.r=hT;exports.render=wc;exports.size=fc;exports.specZ=je;exports.state=ET;exports.t=cT;exports.tT=Km;exports.themeZ=cc;exports.use=UO;exports.useAdder=fn;exports.useAsyncErrorHandler=jO;exports.useErrorHandler=la;exports.useInstrumentation=Ac;exports.useOptionalAdder=IO;exports.usePassthrough=oc;exports.usePurePassthrough=lc;exports.weightZ=CT;exports.y=rc;exports.yT=Rv;
|