@synnaxlabs/pluto 0.38.2 → 0.39.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/Center-BjxFDxgi.cjs +1 -0
- package/dist/Center-DoAxDY5V.js +24 -0
- package/dist/ContextMenu-BWGS1vXl.cjs +1 -0
- package/dist/ContextMenu-DX6j7Wwi.js +101 -0
- package/dist/DateTime-DUuYjZr8.cjs +1 -0
- package/dist/DateTime-sO15tvDD.js +17 -0
- package/dist/Divider-C5m3c4pv.js +1428 -0
- package/dist/Divider-MIbyu5ZH.cjs +31 -0
- package/dist/Dropdown-DurKTABg.cjs +1 -0
- package/dist/Dropdown-FSmdakic.js +261 -0
- package/dist/Haul-CoG7Jmz6.cjs +1 -0
- package/dist/Haul-DrdXQaTq.js +125 -0
- package/dist/Item-CZAsnOoO.js +108 -0
- package/dist/Item-Dj7cQJ8t.cjs +1 -0
- package/dist/Keyboard-D4FRdVej.cjs +1 -0
- package/dist/Keyboard-lwCx7plR.js +29 -0
- package/dist/{Link-DO2YbtQM.cjs → Link-BSZ-HrRf.cjs} +1 -1
- package/dist/{Link-BIWA4Kdj.js → Link-lleSh5eG.js} +2 -2
- package/dist/Pack-BbwDtaE6.cjs +1 -0
- package/dist/Pack-CzZzxA2R.cjs +1 -0
- package/dist/Pack-D50qN0Vu.js +13 -0
- package/dist/Pack-Dlj4dZzQ.js +46 -0
- package/dist/Provider-CCZPt2M5.js +436 -0
- package/dist/Provider-YIru1nvE.cjs +1 -0
- package/dist/Space-DBmhvGQL.js +76 -0
- package/dist/Space-NNqCWFbg.cjs +1 -0
- package/dist/Text-B3pNXYhh.js +124 -0
- package/dist/Text-D1GKnp9s.cjs +1 -0
- package/dist/Text-DT2rIwXL.js +1199 -0
- package/dist/Text-DrXyKZwR.cjs +1 -0
- package/dist/Text-Hnsb1fus.cjs +4 -0
- package/dist/Text-g6btwQ6E.js +32 -0
- package/dist/Toggle-BzORI5sE.cjs +1 -0
- package/dist/Toggle-DZMcFiiI.js +356 -0
- package/dist/{Video-usN9Roxq.cjs → Video-BJudMCoc.cjs} +1 -1
- package/dist/{Video-CAbdyjCE.js → Video-DPIAdJ-g.js} +2 -2
- package/dist/WithIcon-C6COgbZq.js +92 -0
- package/dist/WithIcon-CJvuPkSy.cjs +1 -0
- package/dist/aggregator-5XpEdQtr.js +83 -0
- package/dist/aggregator-BAdXZfPY.cjs +1 -0
- package/dist/align.cjs +1 -1
- package/dist/align.js +1 -1
- 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-CU7tous7.cjs +1 -0
- package/dist/{css-Bbri4zkj.js → css-rxwBYwM1.js} +136 -136
- package/dist/css.cjs +1 -1
- package/dist/css.js +2 -2
- package/dist/debounce-CW9Q-DsR.js +17 -0
- package/dist/debounce-heEWeOqL.cjs +1 -0
- package/dist/deep-BjupBYvk.cjs +1 -0
- package/dist/deep-ChDJVfub.js +105 -0
- package/dist/dimensions-Bt1NqWz6.js +18 -0
- package/dist/dimensions-IEzi7AOM.cjs +1 -0
- package/dist/dropdown.cjs +1 -1
- package/dist/dropdown.js +1 -1
- package/dist/eraser-CnbMvm7W.cjs +11 -0
- package/dist/eraser-DKQ5u3sz.js +823 -0
- package/dist/ether.cjs +1 -1
- package/dist/ether.js +89 -85
- package/dist/external-AOOzgEKd.cjs +1 -0
- package/dist/external-B8Z-4vz2.cjs +46 -0
- package/dist/external-BJulb-Hm.cjs +1 -0
- package/dist/external-BOOtUi1D.js +20 -0
- package/dist/external-BQtPGUNg.cjs +1 -0
- package/dist/external-BTGfIw_K.cjs +1 -0
- package/dist/external-Bxg2-RDn.js +13 -0
- package/dist/{Toggle-DvdBHJvZ.js → external-C710XUvC.js} +17484 -30626
- package/dist/external-C8i1PCpN.js +59 -0
- package/dist/external-CL_RlqOT.cjs +1 -0
- package/dist/external-CNyc2Q9k.cjs +1 -0
- package/dist/{external-CWIwuJks.cjs → external-CRbERCqd.cjs} +1 -1
- package/dist/external-CjZqwgDh.js +1265 -0
- package/dist/external-D18IGHXh.js +77 -0
- package/dist/external-DF0wHYUj.js +8990 -0
- package/dist/external-DK_wU08V.js +19 -0
- package/dist/external-DNC1e6Hi.js +343 -0
- package/dist/external-DYn3iC-U.js +418 -0
- package/dist/external-DhX0dZoF.cjs +1 -0
- package/dist/external-Dmr3e50U.js +15 -0
- package/dist/external-DrwngojV.cjs +1 -0
- package/dist/external-GUQ0NMxY.js +111 -0
- package/dist/external-Vjn4WKwt.cjs +85 -0
- package/dist/external-vVwTqni5.cjs +1 -0
- package/dist/font-CD9W5Tsh.js +15 -0
- package/dist/font-MRTGIokZ.cjs +1 -0
- package/dist/fontString-MM82zgKY.cjs +1 -0
- package/dist/fontString-p8gMjlA1.js +12 -0
- package/dist/header.cjs +1 -1
- package/dist/header.js +1 -1
- package/dist/hooks-BKLtEDxx.cjs +1 -0
- package/dist/hooks-CwSxEEAh.js +293 -0
- package/dist/index.cjs +7 -7
- package/dist/index.js +7520 -7281
- package/dist/input.cjs +1 -1
- package/dist/input.js +1 -1
- package/dist/{jsx-runtime-Bdg6XQ1m.js → jsx-runtime-CYK1ROHF.js} +98 -98
- package/dist/{jsx-runtime-D8EVjfnb.cjs → jsx-runtime-UYeBbnYT.cjs} +8 -8
- package/dist/list.cjs +1 -1
- package/dist/list.js +1 -1
- package/dist/menu.cjs +1 -1
- package/dist/menu.js +1 -1
- package/dist/pluto.css +1 -1
- package/dist/provider-D3MPSb7n.cjs +53 -0
- package/dist/provider-DfVWtUxZ.js +10299 -0
- package/dist/src/accordion/Accordion.d.ts +1 -1
- package/dist/src/accordion/Accordion.d.ts.map +1 -1
- package/dist/src/aether/main.d.ts +8 -9
- package/dist/src/aether/main.d.ts.map +1 -1
- package/dist/src/alamos/Provider.d.ts +1 -1
- package/dist/src/alamos/Provider.d.ts.map +1 -1
- package/dist/src/alamos/aether/alamos.d.ts.map +1 -1
- package/dist/src/align/Center.d.ts +1 -1
- package/dist/src/align/Center.d.ts.map +1 -1
- package/dist/src/align/Pack.d.ts +1 -1
- package/dist/src/align/Pack.d.ts.map +1 -1
- package/dist/src/align/Space.d.ts +1 -1
- package/dist/src/align/Space.d.ts.map +1 -1
- package/dist/src/breadcrumb/Breadcrumb.d.ts +1 -1
- package/dist/src/breadcrumb/Breadcrumb.d.ts.map +1 -1
- package/dist/src/button/Button.d.ts +8 -9
- package/dist/src/button/Button.d.ts.map +1 -1
- package/dist/src/button/Icon.d.ts.map +1 -1
- package/dist/src/button/Link.d.ts +1 -1
- package/dist/src/button/Link.d.ts.map +1 -1
- package/dist/src/button/Toggle.d.ts +2 -2
- package/dist/src/button/Toggle.d.ts.map +1 -1
- package/dist/src/button/color.d.ts +1 -1
- package/dist/src/button/color.d.ts.map +1 -1
- package/dist/src/caret/Animated.d.ts.map +1 -1
- package/dist/src/channel/AliasProvider.d.ts +5 -6
- package/dist/src/channel/AliasProvider.d.ts.map +1 -1
- package/dist/src/channel/LinePlot.d.ts +1 -1
- package/dist/src/channel/LinePlot.d.ts.map +1 -1
- package/dist/src/channel/Select.d.ts +2 -2
- package/dist/src/channel/Select.d.ts.map +1 -1
- package/dist/src/color/BaseSwatch.d.ts +10 -0
- package/dist/src/color/BaseSwatch.d.ts.map +1 -0
- package/dist/src/color/GradientPicker.d.ts.map +1 -1
- package/dist/src/color/Picker.d.ts +1 -1
- package/dist/src/color/Picker.d.ts.map +1 -1
- package/dist/src/color/Provider.d.ts +14 -12
- package/dist/src/color/Provider.d.ts.map +1 -1
- package/dist/src/color/Swatch.d.ts +3 -7
- package/dist/src/color/Swatch.d.ts.map +1 -1
- package/dist/src/color/core/color.d.ts.map +1 -1
- package/dist/src/color/core/gradient.d.ts.map +1 -1
- package/dist/src/color/core/transformColorsToHex.d.ts.map +1 -1
- package/dist/src/css/bem.d.ts.map +1 -1
- package/dist/src/css/color.d.ts +3 -4
- package/dist/src/css/color.d.ts.map +1 -1
- package/dist/src/css/units.d.ts.map +1 -1
- package/dist/src/css/vars.d.ts.map +1 -1
- package/dist/src/cursor/cursor.d.ts.map +1 -1
- package/dist/src/dialog/use.d.ts +36 -17
- package/dist/src/dialog/use.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/dropdown/Dropdown.d.ts +3 -3
- package/dist/src/dropdown/Dropdown.d.ts.map +1 -1
- package/dist/src/form/Field.d.ts +9 -1
- package/dist/src/form/Field.d.ts.map +1 -1
- package/dist/src/form/Form.d.ts +19 -9
- package/dist/src/form/Form.d.ts.map +1 -1
- package/dist/src/form/synced.d.ts +1 -1
- package/dist/src/form/synced.d.ts.map +1 -1
- package/dist/src/generic/Generic.d.ts +1 -1
- package/dist/src/generic/Generic.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/rack/Select.d.ts +7 -0
- package/dist/src/hardware/rack/Select.d.ts.map +1 -0
- package/dist/src/hardware/rack/index.d.ts +2 -0
- package/dist/src/hardware/rack/index.d.ts.map +1 -0
- package/dist/src/haul/Haul.d.ts +13 -5
- package/dist/src/haul/Haul.d.ts.map +1 -1
- package/dist/src/header/Actions.d.ts +3 -2
- package/dist/src/header/Actions.d.ts.map +1 -1
- package/dist/src/header/ButtonTitle.d.ts +1 -1
- package/dist/src/header/ButtonTitle.d.ts.map +1 -1
- package/dist/src/header/Header.d.ts +1 -1
- package/dist/src/header/Header.d.ts.map +1 -1
- package/dist/src/header/Title.d.ts +1 -1
- package/dist/src/header/Title.d.ts.map +1 -1
- package/dist/src/hooks/effect.d.ts.map +1 -1
- package/dist/src/hooks/ref.d.ts +3 -2
- package/dist/src/hooks/ref.d.ts.map +1 -1
- package/dist/src/hooks/useClickOutside.d.ts.map +1 -1
- package/dist/src/hooks/useCursorDrag/useCursorDrag.d.ts.map +1 -1
- package/dist/src/hooks/useCursorDrag/useVirtualCursorDragWebKit.d.ts.map +1 -1
- package/dist/src/hooks/useCursorDrag/useVirtualCursorDragWebView.d.ts.map +1 -1
- package/dist/src/hooks/useDebouncedCallback.d.ts.map +1 -1
- package/dist/src/hooks/useDelayedState.d.ts.map +1 -1
- package/dist/src/hooks/useFilter.d.ts.map +1 -1
- package/dist/src/hooks/useRequiredContext.d.ts.map +1 -1
- package/dist/src/hooks/useResize.d.ts.map +1 -1
- package/dist/src/hooks/useTransforms.d.ts.map +1 -1
- package/dist/src/hooks/useUniqueKey.d.ts +2 -2
- package/dist/src/hooks/useUniqueKey.d.ts.map +1 -1
- package/dist/src/icon/Icon.d.ts +1 -1
- package/dist/src/icon/Icon.d.ts.map +1 -1
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/input/Date.d.ts +1 -1
- package/dist/src/input/Date.d.ts.map +1 -1
- package/dist/src/input/DateTime.d.ts +1 -2
- package/dist/src/input/DateTime.d.ts.map +1 -1
- package/dist/src/input/DragButton.d.ts +1 -1
- package/dist/src/input/DragButton.d.ts.map +1 -1
- package/dist/src/input/HelpText.d.ts +1 -1
- package/dist/src/input/HelpText.d.ts.map +1 -1
- package/dist/src/input/Item.d.ts +1 -1
- package/dist/src/input/Item.d.ts.map +1 -1
- package/dist/src/input/Label.d.ts +1 -1
- package/dist/src/input/Label.d.ts.map +1 -1
- package/dist/src/input/Numeric.d.ts +1 -1
- package/dist/src/input/Numeric.d.ts.map +1 -1
- package/dist/src/input/Switch.d.ts +1 -1
- package/dist/src/input/Switch.d.ts.map +1 -1
- package/dist/src/input/Text.d.ts +2 -2
- package/dist/src/input/Text.d.ts.map +1 -1
- package/dist/src/input/TextArea.d.ts +1 -1
- package/dist/src/input/TextArea.d.ts.map +1 -1
- package/dist/src/input/Time.d.ts +1 -1
- package/dist/src/input/Time.d.ts.map +1 -1
- package/dist/src/label/Select.d.ts +3 -3
- package/dist/src/label/Select.d.ts.map +1 -1
- package/dist/src/list/Column.d.ts +4 -7
- package/dist/src/list/Column.d.ts.map +1 -1
- package/dist/src/list/Core.d.ts +3 -3
- package/dist/src/list/Core.d.ts.map +1 -1
- package/dist/src/list/Data.d.ts +2 -2
- package/dist/src/list/Data.d.ts.map +1 -1
- package/dist/src/list/Filter.d.ts +1 -1
- package/dist/src/list/Filter.d.ts.map +1 -1
- package/dist/src/list/Hover.d.ts.map +1 -1
- package/dist/src/list/Infinite.d.ts +2 -2
- package/dist/src/list/Infinite.d.ts.map +1 -1
- package/dist/src/list/Item.d.ts +1 -1
- package/dist/src/list/Item.d.ts.map +1 -1
- package/dist/src/list/List.d.ts.map +1 -1
- package/dist/src/list/Search.d.ts +1 -1
- package/dist/src/list/Search.d.ts.map +1 -1
- package/dist/src/list/Selector.d.ts +2 -2
- package/dist/src/list/Selector.d.ts.map +1 -1
- package/dist/src/list/useSelect.d.ts.map +1 -1
- package/dist/src/memo/useMemoCompare.d.ts.map +1 -1
- package/dist/src/menu/ContextMenu.d.ts +1 -1
- package/dist/src/menu/ContextMenu.d.ts.map +1 -1
- package/dist/src/menu/Menu.d.ts +3 -5
- package/dist/src/menu/Menu.d.ts.map +1 -1
- package/dist/src/modal/Modal.d.ts +2 -2
- package/dist/src/modal/Modal.d.ts.map +1 -1
- package/dist/src/mosaic/Mosaic.d.ts.map +1 -1
- package/dist/src/mosaic/tree.d.ts.map +1 -1
- package/dist/src/mosaic/types.d.ts +5 -0
- package/dist/src/mosaic/types.d.ts.map +1 -1
- package/dist/src/mosaic/use.d.ts.map +1 -1
- package/dist/src/nav/Bar.d.ts +1 -1
- package/dist/src/nav/Bar.d.ts.map +1 -1
- package/dist/src/nav/Drawer.d.ts +1 -1
- package/dist/src/nav/Drawer.d.ts.map +1 -1
- package/dist/src/notation/Select.d.ts +1 -1
- package/dist/src/notation/Select.d.ts.map +1 -1
- package/dist/src/notation/notation.d.ts.map +1 -1
- package/dist/src/note/Note.d.ts +1 -1
- package/dist/src/note/Note.d.ts.map +1 -1
- package/dist/src/observe/use.d.ts.map +1 -1
- package/dist/src/os/Controls/Controls.d.ts +1 -1
- package/dist/src/os/Controls/Controls.d.ts.map +1 -1
- package/dist/src/os/Controls/Mac.d.ts +1 -1
- package/dist/src/os/Controls/Mac.d.ts.map +1 -1
- package/dist/src/os/Controls/Windows.d.ts +1 -1
- package/dist/src/os/Controls/Windows.d.ts.map +1 -1
- package/dist/src/override/factory.d.ts.map +1 -1
- package/dist/src/pluto/Pluto.d.ts.map +1 -1
- package/dist/src/portal/Portal.d.ts.map +1 -1
- package/dist/src/progress/Progress.d.ts.map +1 -1
- package/dist/src/ranger/Select.d.ts +3 -3
- package/dist/src/ranger/Select.d.ts.map +1 -1
- package/dist/src/ranger/SelectLabel.d.ts.map +1 -1
- package/dist/src/ranger/TimeRangeChip.d.ts +1 -1
- package/dist/src/ranger/TimeRangeChip.d.ts.map +1 -1
- package/dist/src/resize/Core.d.ts +1 -1
- package/dist/src/resize/Core.d.ts.map +1 -1
- package/dist/src/resize/Multiple.d.ts +1 -1
- package/dist/src/resize/Multiple.d.ts.map +1 -1
- package/dist/src/resize/Single.d.ts +1 -1
- package/dist/src/resize/Single.d.ts.map +1 -1
- package/dist/src/select/Alignment.d.ts +1 -1
- package/dist/src/select/Alignment.d.ts.map +1 -1
- package/dist/src/select/Button.d.ts +3 -3
- package/dist/src/select/Button.d.ts.map +1 -1
- package/dist/src/select/ClearButton.d.ts.map +1 -1
- package/dist/src/select/ComponentSize.d.ts +1 -1
- package/dist/src/select/ComponentSize.d.ts.map +1 -1
- package/dist/src/select/DataType.d.ts +1 -1
- package/dist/src/select/DataType.d.ts.map +1 -1
- package/dist/src/select/Direction.d.ts +1 -1
- package/dist/src/select/Direction.d.ts.map +1 -1
- package/dist/src/select/List.d.ts +1 -1
- package/dist/src/select/List.d.ts.map +1 -1
- package/dist/src/select/Multiple.d.ts +2 -2
- package/dist/src/select/Multiple.d.ts.map +1 -1
- package/dist/src/select/Single.d.ts +1 -1
- package/dist/src/select/Single.d.ts.map +1 -1
- package/dist/src/select/external.d.ts +1 -0
- package/dist/src/select/external.d.ts.map +1 -1
- package/dist/src/select/text/Level.d.ts +11 -0
- package/dist/src/select/text/Level.d.ts.map +1 -0
- package/dist/src/select/text/Weight.d.ts +11 -0
- package/dist/src/select/text/Weight.d.ts.map +1 -0
- package/dist/src/select/text/external.d.ts +3 -0
- package/dist/src/select/text/external.d.ts.map +1 -0
- package/dist/src/select/text/index.d.ts +2 -0
- package/dist/src/select/text/index.d.ts.map +1 -0
- package/dist/src/state/state.d.ts.map +1 -1
- package/dist/src/status/Aggregator.d.ts +13 -10
- package/dist/src/status/Aggregator.d.ts.map +1 -1
- package/dist/src/status/Aggregator.spec.d.ts +2 -0
- package/dist/src/status/Aggregator.spec.d.ts.map +1 -0
- package/dist/src/status/Circle.d.ts +1 -1
- package/dist/src/status/Circle.d.ts.map +1 -1
- package/dist/src/status/Notification.d.ts +1 -1
- package/dist/src/status/Notification.d.ts.map +1 -1
- package/dist/src/status/Notification.spec.d.ts +2 -0
- package/dist/src/status/Notification.spec.d.ts.map +1 -0
- package/dist/src/status/Text.d.ts +6 -8
- package/dist/src/status/Text.d.ts.map +1 -1
- package/dist/src/status/aether/aggregator.d.ts +18 -8
- package/dist/src/status/aether/aggregator.d.ts.map +1 -1
- package/dist/src/status/aether/types.d.ts +4 -2
- package/dist/src/status/aether/types.d.ts.map +1 -1
- package/dist/src/status/external.d.ts +1 -0
- package/dist/src/status/external.d.ts.map +1 -1
- package/dist/src/steps/Steps.d.ts +1 -1
- package/dist/src/steps/Steps.d.ts.map +1 -1
- package/dist/src/synnax/Provider.d.ts.map +1 -1
- package/dist/src/synnax/aether/provider.d.ts +30 -30
- package/dist/src/synnax/aether/provider.d.ts.map +1 -1
- package/dist/src/table/Table.d.ts +3 -3
- package/dist/src/table/Table.d.ts.map +1 -1
- package/dist/src/table/aether/Table.d.ts +1 -1
- package/dist/src/table/aether/Table.d.ts.map +1 -1
- package/dist/src/table/cells/Cells.d.ts.map +1 -1
- package/dist/src/table/cells/Forms.d.ts.map +1 -1
- package/dist/src/tabs/Selector.d.ts +1 -1
- package/dist/src/tabs/Selector.d.ts.map +1 -1
- package/dist/src/tabs/Tabs.d.ts +6 -71
- package/dist/src/tabs/Tabs.d.ts.map +1 -1
- package/dist/src/tabs/external.d.ts +1 -0
- package/dist/src/tabs/external.d.ts.map +1 -1
- package/dist/src/tabs/types.d.ts +6 -0
- package/dist/src/tabs/types.d.ts.map +1 -1
- package/dist/src/tabs/useContext.d.ts +64 -0
- package/dist/src/tabs/useContext.d.ts.map +1 -0
- package/dist/src/tag/Tag.d.ts +1 -1
- package/dist/src/tag/Tag.d.ts.map +1 -1
- package/dist/src/telem/Provider.d.ts.map +1 -1
- package/dist/src/telem/aether/context.d.ts.map +1 -1
- package/dist/src/telem/aether/convertSeries.d.ts.map +1 -1
- package/dist/src/telem/aether/factory.d.ts.map +1 -1
- package/dist/src/telem/aether/pipeline.d.ts.map +1 -1
- package/dist/src/telem/aether/remote.d.ts.map +1 -1
- package/dist/src/telem/aether/static.d.ts.map +1 -1
- package/dist/src/telem/aether/transformers.d.ts.map +1 -1
- package/dist/src/telem/client/client.d.ts.map +1 -1
- package/dist/src/telem/client/types.d.ts.map +1 -1
- package/dist/src/telem/control/Chip.d.ts +1 -1
- package/dist/src/telem/control/Chip.d.ts.map +1 -1
- package/dist/src/telem/control/Controller.d.ts.map +1 -1
- package/dist/src/telem/control/Indicator.d.ts.map +1 -1
- package/dist/src/telem/control/Legend.d.ts +1 -1
- package/dist/src/telem/control/Legend.d.ts.map +1 -1
- package/dist/src/telem/control/StateProvider.d.ts.map +1 -1
- package/dist/src/telem/control/aether/chip.d.ts.map +1 -1
- package/dist/src/telem/control/aether/controller.d.ts +4 -4
- package/dist/src/telem/control/aether/controller.d.ts.map +1 -1
- package/dist/src/telem/control/aether/legend.d.ts.map +1 -1
- package/dist/src/telem/control/aether/state.d.ts.map +1 -1
- package/dist/src/testutil/dom.d.ts.map +1 -1
- package/dist/src/text/DateTime.d.ts +1 -1
- package/dist/src/text/DateTime.d.ts.map +1 -1
- package/dist/src/text/Editable.d.ts +2 -2
- package/dist/src/text/Editable.d.ts.map +1 -1
- package/dist/src/text/Keyboard.d.ts +1 -1
- package/dist/src/text/Keyboard.d.ts.map +1 -1
- package/dist/src/text/Link.d.ts +1 -1
- package/dist/src/text/Link.d.ts.map +1 -1
- package/dist/src/text/Text.d.ts +2 -2
- package/dist/src/text/Text.d.ts.map +1 -1
- package/dist/src/text/WithIcon.d.ts +1 -1
- package/dist/src/text/WithIcon.d.ts.map +1 -1
- package/dist/src/text/core/types.d.ts.map +1 -1
- package/dist/src/text/dimensions.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/theming/Provider.d.ts +3 -4
- package/dist/src/theming/Provider.d.ts.map +1 -1
- package/dist/src/theming/aether/provider.d.ts.map +1 -1
- package/dist/src/theming/core/fontString.d.ts.map +1 -1
- package/dist/src/theming/css.d.ts.map +1 -1
- package/dist/src/theming/external.d.ts +0 -1
- package/dist/src/theming/external.d.ts.map +1 -1
- package/dist/src/theming/font.d.ts.map +1 -1
- package/dist/src/theming/index.d.ts.map +1 -1
- package/dist/src/tooltip/Config.d.ts +0 -1
- package/dist/src/tooltip/Config.d.ts.map +1 -1
- package/dist/src/tooltip/Dialog.d.ts.map +1 -1
- package/dist/src/tooltip/wrap.d.ts.map +1 -1
- package/dist/src/tree/Tree.d.ts +4 -3
- package/dist/src/tree/Tree.d.ts.map +1 -1
- package/dist/src/tree/core.d.ts +3 -1
- package/dist/src/tree/core.d.ts.map +1 -1
- package/dist/src/triggers/Provider.d.ts +3 -2
- package/dist/src/triggers/Provider.d.ts.map +1 -1
- package/dist/src/triggers/Status.d.ts.map +1 -1
- package/dist/src/triggers/Text.d.ts +1 -1
- package/dist/src/triggers/Text.d.ts.map +1 -1
- package/dist/src/triggers/hooks.d.ts +1 -1
- package/dist/src/triggers/hooks.d.ts.map +1 -1
- package/dist/src/triggers/triggers.d.ts.map +1 -1
- package/dist/src/triggers/useDrag.d.ts.map +1 -1
- package/dist/src/util/canDisable.d.ts.map +1 -1
- package/dist/src/util/children.d.ts +2 -2
- package/dist/src/util/children.d.ts.map +1 -1
- package/dist/src/util/component.d.ts.map +1 -1
- package/dist/src/util/event.d.ts.map +1 -1
- package/dist/src/util/findParent.d.ts.map +1 -1
- package/dist/src/util/reflow.d.ts.map +1 -1
- package/dist/src/util/removeProps.d.ts.map +1 -1
- package/dist/src/util/renderProp.d.ts +1 -1
- package/dist/src/util/renderProp.d.ts.map +1 -1
- package/dist/src/util/rootElement.d.ts.map +1 -1
- package/dist/src/util/zod.d.ts.map +1 -1
- package/dist/src/video/Video.d.ts +1 -1
- package/dist/src/video/Video.d.ts.map +1 -1
- package/dist/src/viewport/Mask.d.ts +1 -1
- package/dist/src/viewport/Mask.d.ts.map +1 -1
- package/dist/src/viewport/SelectMode.d.ts +1 -1
- package/dist/src/viewport/SelectMode.d.ts.map +1 -1
- package/dist/src/viewport/use.d.ts.map +1 -1
- package/dist/src/vis/axis/ticks.d.ts +1 -1
- package/dist/src/vis/axis/ticks.d.ts.map +1 -1
- package/dist/src/vis/button/use.d.ts.map +1 -1
- package/dist/src/vis/canvas/Canvas.d.ts +1 -1
- package/dist/src/vis/canvas/Canvas.d.ts.map +1 -1
- package/dist/src/vis/diagram/Diagram.d.ts +7 -5
- package/dist/src/vis/diagram/Diagram.d.ts.map +1 -1
- package/dist/src/vis/diagram/aether/Diagram.d.ts +1 -1
- package/dist/src/vis/diagram/aether/Diagram.d.ts.map +1 -1
- package/dist/src/vis/diagram/aether/types.d.ts.map +1 -1
- package/dist/src/vis/diagram/align.d.ts.map +1 -1
- package/dist/src/vis/diagram/edge/Edge.d.ts +1 -1
- package/dist/src/vis/diagram/edge/Edge.d.ts.map +1 -1
- package/dist/src/vis/diagram/edge/connector/connector.d.ts.map +1 -1
- package/dist/src/vis/diagram/edge/paths.d.ts +1 -1
- package/dist/src/vis/diagram/edge/paths.d.ts.map +1 -1
- package/dist/src/vis/diagram/util.d.ts.map +1 -1
- package/dist/src/vis/draw2d/index.d.ts +1 -1
- package/dist/src/vis/draw2d/index.d.ts.map +1 -1
- package/dist/src/vis/eraser/use.d.ts.map +1 -1
- package/dist/src/vis/grid/grid.d.ts.map +1 -1
- package/dist/src/vis/legend/Container.d.ts +1 -1
- package/dist/src/vis/legend/Container.d.ts.map +1 -1
- package/dist/src/vis/legend/Simple.d.ts +1 -1
- package/dist/src/vis/legend/Simple.d.ts.map +1 -1
- package/dist/src/vis/light/aether/light.d.ts +1 -1
- package/dist/src/vis/light/aether/light.d.ts.map +1 -1
- package/dist/src/vis/light/use.d.ts.map +1 -1
- package/dist/src/vis/line/Line.d.ts +1 -1
- package/dist/src/vis/line/Line.d.ts.map +1 -1
- package/dist/src/vis/line/aether/line.d.ts.map +1 -1
- package/dist/src/vis/lineplot/Axis.d.ts.map +1 -1
- package/dist/src/vis/lineplot/Legend.d.ts +2 -2
- package/dist/src/vis/lineplot/Legend.d.ts.map +1 -1
- package/dist/src/vis/lineplot/Line.d.ts +1 -1
- package/dist/src/vis/lineplot/Line.d.ts.map +1 -1
- package/dist/src/vis/lineplot/LinePlot.d.ts +3 -3
- package/dist/src/vis/lineplot/LinePlot.d.ts.map +1 -1
- package/dist/src/vis/lineplot/Title.d.ts +1 -1
- package/dist/src/vis/lineplot/Title.d.ts.map +1 -1
- package/dist/src/vis/lineplot/Viewport.d.ts +1 -1
- package/dist/src/vis/lineplot/Viewport.d.ts.map +1 -1
- package/dist/src/vis/lineplot/aether/LinePlot.d.ts +1 -1
- package/dist/src/vis/lineplot/aether/LinePlot.d.ts.map +1 -1
- package/dist/src/vis/lineplot/aether/axis.d.ts.map +1 -1
- package/dist/src/vis/lineplot/range/Annotation.d.ts +1 -1
- package/dist/src/vis/lineplot/range/Annotation.d.ts.map +1 -1
- package/dist/src/vis/lineplot/range/Provider.d.ts +1 -1
- package/dist/src/vis/lineplot/range/Provider.d.ts.map +1 -1
- package/dist/src/vis/lineplot/range/aether/provider.d.ts +1 -1
- package/dist/src/vis/lineplot/range/aether/provider.d.ts.map +1 -1
- package/dist/src/vis/lineplot/tooltip/Tooltip.d.ts +1 -1
- package/dist/src/vis/lineplot/tooltip/Tooltip.d.ts.map +1 -1
- package/dist/src/vis/log/Log.d.ts +1 -1
- package/dist/src/vis/log/Log.d.ts.map +1 -1
- package/dist/src/vis/measure/Measure.d.ts.map +1 -1
- package/dist/src/vis/render/util.d.ts.map +1 -1
- package/dist/src/vis/rule/Rule.d.ts +1 -1
- package/dist/src/vis/rule/Rule.d.ts.map +1 -1
- package/dist/src/vis/schematic/Forms.d.ts.map +1 -1
- package/dist/src/vis/schematic/Grid.d.ts +1 -1
- package/dist/src/vis/schematic/Grid.d.ts.map +1 -1
- package/dist/src/vis/schematic/SelectOrientation.d.ts +1 -1
- package/dist/src/vis/schematic/SelectOrientation.d.ts.map +1 -1
- package/dist/src/vis/schematic/Symbols.d.ts +3 -3
- package/dist/src/vis/schematic/Symbols.d.ts.map +1 -1
- package/dist/src/vis/schematic/primitives/Primitives.d.ts +80 -80
- package/dist/src/vis/schematic/primitives/Primitives.d.ts.map +1 -1
- package/dist/src/vis/setpoint/aether/setpoint.d.ts +1 -2
- package/dist/src/vis/setpoint/aether/setpoint.d.ts.map +1 -1
- package/dist/src/vis/setpoint/use.d.ts.map +1 -1
- package/dist/src/vis/toggle/aether/toggle.d.ts +1 -1
- package/dist/src/vis/toggle/aether/toggle.d.ts.map +1 -1
- package/dist/src/vis/toggle/use.d.ts.map +1 -1
- package/dist/src/vis/value/Form.d.ts.map +1 -1
- package/dist/src/vis/value/use.d.ts.map +1 -1
- package/dist/src/worker/Context.d.ts.map +1 -1
- package/dist/state-BKyv_jWZ.cjs +15 -0
- package/dist/state-w46WTrh-.js +2399 -0
- 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/theming.cjs +1 -1
- package/dist/theming.js +2 -2
- package/dist/toArray-DRKOku1s.cjs +1 -0
- package/dist/toArray-Dvn9FA_3.js +5 -0
- package/dist/{transformColorsToHex-CDwcIPob.cjs → transformColorsToHex-B2Bui-Wf.cjs} +1 -1
- package/dist/{transformColorsToHex-CnZpPlL2.js → transformColorsToHex-B6dG2LA6.js} +1 -1
- 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-BpKy5yTv.cjs → units-CvIf5nF_.cjs} +1 -1
- package/dist/{units-CNGjg1NV.js → units-D7qkgH-s.js} +1 -1
- package/dist/useClickOutside-EJHWO4Q9.cjs +1 -0
- package/dist/useClickOutside-vpv_GiBw.js +107 -0
- package/dist/useDebouncedCallback-CVLx7N1s.cjs +1 -0
- package/dist/useDebouncedCallback-DDLuEZa8.js +7 -0
- package/dist/useMemoCompare-B-Y9Ft2w.js +19 -0
- package/dist/useMemoCompare-ONEAVO05.cjs +1 -0
- package/dist/useVirtualCursorDragWebKit-BLtwRQY7.cjs +1 -0
- package/dist/useVirtualCursorDragWebKit-DFC-XFfl.js +65 -0
- package/dist/value-DQqKhQvt.cjs +57 -0
- package/dist/{LinePlot-tqJ3Um1S.js → value-DbcZ1sQB.js} +1998 -1994
- package/dist/video.cjs +1 -1
- package/dist/video.js +1 -1
- package/package.json +27 -25
- package/dist/Animated-BWcO40x5.js +0 -19
- package/dist/Animated-Cxl7iHik.cjs +0 -1
- package/dist/Item-BZvmqn4h.js +0 -109
- package/dist/Item-C4SOBynl.cjs +0 -1
- package/dist/LinePlot-Cys9-mEC.cjs +0 -56
- package/dist/Pack-B7_tAsYd.cjs +0 -1
- package/dist/Pack-Di5J8hmU.js +0 -143
- package/dist/Toggle-BOWYgKry.cjs +0 -163
- package/dist/aggregator-B4RWbN9h.cjs +0 -77
- package/dist/aggregator-Bl15iClv.js +0 -13712
- package/dist/css-DT9dIVAb.cjs +0 -1
- package/dist/external-8OKX45Jc.cjs +0 -1
- package/dist/external-9Q86X8hc.cjs +0 -1
- package/dist/external-B45MvYg8.js +0 -111
- package/dist/external-BP5euc4j.js +0 -34
- package/dist/external-Ba8go3wq.cjs +0 -1
- package/dist/external-C59dex28.js +0 -13
- package/dist/external-CKXRIr4_.cjs +0 -1
- package/dist/external-CML3oqyJ.js +0 -22
- package/dist/external-CW61uh4b.cjs +0 -1
- package/dist/external-CcuRxo0Z.js +0 -323
- package/dist/external-CigHe3w_.cjs +0 -1
- package/dist/external-Cm1kldLr.js +0 -123
- package/dist/external-DNjLBxYA.js +0 -1189
- package/dist/external-DTDBfIqD.js +0 -13
- package/dist/external-DkXE1VK8.cjs +0 -1
- package/dist/external-Dt4ggRt2.cjs +0 -1
- package/dist/external-DuGCS_ZD.js +0 -20
- package/dist/external-DuK5v_sl.js +0 -375
- package/dist/external-SsIgRo40.cjs +0 -1
- package/dist/external-U33eEFR3.js +0 -75
- package/dist/external-bw66TR6V.js +0 -277
- package/dist/external-kZBV4X9L.cjs +0 -1
- package/dist/external-ok_ye4LF.cjs +0 -1
- package/dist/src/telem/Pipeline.d.ts +0 -3
- package/dist/src/telem/Pipeline.d.ts.map +0 -1
- package/dist/src/text/Select.d.ts +0 -19
- package/dist/src/text/Select.d.ts.map +0 -1
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
"use strict";var ju=Object.defineProperty;var Bu=(r,e,t)=>e in r?ju(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var S=(r,e,t)=>Bu(r,typeof e!="symbol"?e+"":e,t);const i=require("zod"),p=require("./css-DT9dIVAb.cjs"),Gn=require("react"),Gt=r=>r!=null&&typeof r=="object"&&!Array.isArray(r);var Pu=Object.defineProperty,Du=(r,e,t)=>e in r?Pu(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Wt=(r,e,t)=>Du(r,typeof e!="symbol"?e+"":e,t);let Uu=class{constructor(){Wt(this,"contentType","application/json"),Wt(this,"decoder"),Wt(this,"encoder"),this.decoder=new TextDecoder,this.encoder=new TextEncoder}encode(e){return this.encoder.encode(this.encodeString(e)).buffer}decode(e,t){return this.decodeString(this.decoder.decode(e),t)}decodeString(e,t){const s=JSON.parse(e),n=p.C(s);return t!=null?t.parse(n):n}encodeString(e){const t=p.k(e);return JSON.stringify(t,(s,n)=>ArrayBuffer.isView(n)?Array.from(n):Gt(n)&&"encode_value"in n?typeof n.value=="bigint"?n.value.toString():n.value:typeof n=="bigint"?n.toString():n)}static registerCustomType(){}},Lu=class{constructor(){Wt(this,"contentType","text/csv")}encode(e){const t=this.encodeString(e);return new TextEncoder().encode(t).buffer}decode(e,t){const s=new TextDecoder().decode(e);return this.decodeString(s,t)}encodeString(e){if(!Array.isArray(e)||e.length===0||!Gt(e[0]))throw new Error("Payload must be an array of objects");const t=Object.keys(e[0]),s=[t.join(",")];return e.forEach(n=>{const a=t.map(o=>JSON.stringify(n[o]??""));s.push(a.join(","))}),s.join(`
|
|
2
|
-
`)}decodeString(e,t){const[s,...n]=e.trim().split(`
|
|
3
|
-
`).map(u=>u.trim());if(s.length===0)return t!=null?t.parse({}):{};const a=s.split(",").map(u=>u.trim()),o={};return a.forEach(u=>{o[u]=[]}),n.forEach(u=>{const l=u.split(",").map(h=>h.trim());a.forEach((h,f)=>{const d=this.parseValue(l[f]);d!=null&&o[h].push(d)})}),t!=null?t.parse(o):o}parseValue(e){if(e==null||e.length===0)return null;const t=Number(e);return isNaN(t)?e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1):e:t}static registerCustomType(){}},_u=class{constructor(){Wt(this,"contentType","text/plain")}encode(e){return new TextEncoder().encode(e).buffer}decode(e,t){const s=new TextDecoder().decode(e);return t!=null?t.parse(s):s}};const Er=new Uu;new Lu;new _u;const fn=r=>[...new Set(r)],qu=(r,e,t=!0)=>{const s=new Map;return r.forEach(n=>{const a=e(n);if(s.has(a)){if(t)return;s.delete(a)}s.set(a,n)}),Array.from(s.values())},Yu=Object.freeze(Object.defineProperty({__proto__:null,by:qu,unique:fn},Symbol.toStringTag,{value:"Module"})),Fa=r=>r!=null&&typeof r=="object"&&"toString"in r,Fu=r=>{if(Fa(r))return(r==null?void 0:r.toString().length)===0;switch(typeof r){case"string":return r.length===0;case"number":return r===0;case"bigint":return r===0n;case"boolean":return!r;case"undefined":return!0;case"object":return r===null}},ws=(r,e=!1)=>{const t=Fa(r)?"stringer":typeof r;let s;switch(t){case"string":s=(n,a)=>n.localeCompare(a);break;case"stringer":s=(n,a)=>n.toString().localeCompare(a.toString());break;case"number":s=(n,a)=>Number(n)-Number(a);break;case"bigint":s=(n,a)=>BigInt(n)-BigInt(a)>0n?1:-1;break;case"boolean":s=(n,a)=>Number(n)-Number(a);break;case"undefined":s=()=>0;break;default:return console.warn(`sortFunc: unknown type ${t}`),()=>-1}return e?Ga(s):s},Vu=(r,e,t)=>{const s=ws(e[r],t);return(n,a)=>s(n[r],a[r])},Gu=(r,e)=>r.length!==e.length?r.length-e.length:r.every((t,s)=>t===e[s])?0:-1,Va=(r,e)=>{if(r.length!==e.length)return r.length-e.length;if(r.length===0)return 0;const t=ws(r[0]),s=[...r].sort(t),n=[...e].sort(t);return s.every((a,o)=>a===n[o])?0:-1},Wu=(r,e)=>{const t=fn(r),s=fn(e);return Va(t,s)},Zu=(r,e)=>r===e?0:r==="first"&&e==="last"?1:-1,Ga=r=>(e,t)=>r(t,e),pt=0,Ir=-1,xr=1,Wa=r=>r<pt,Za=r=>r>pt,Ju=r=>r>=pt,Ja=r=>r===pt,Ku=(r,e)=>{const t=/([a-zA-Z]+)|(\d+)/g,s=r.replace(/[\s_.-]+/g,"").match(t),n=e.replace(/[\s_.-]+/g,"").match(t);if(!s||!n)return 0;for(let a=0;a<Math.min(s.length,n.length);a++){const o=s[a],u=n[a];if(isNaN(Number(o))&&isNaN(Number(u))){const l=o.localeCompare(u);if(l!==0)return l}else if(!isNaN(Number(o))&&!isNaN(Number(u))){const l=Number(o)-Number(u);if(l!==0)return l}else return isNaN(Number(o))?-1:1}return s.length-n.length},Hu=Object.freeze(Object.defineProperty({__proto__:null,EQUAL:pt,GREATER_THAN:xr,LESS_THAN:Ir,isEqualTo:Ja,isGreaterThan:Za,isGreaterThanEqual:Ju,isLessThan:Wa,newF:ws,newFieldF:Vu,order:Zu,primitiveArrays:Gu,reverseF:Ga,stringsWithNumbers:Ku,uniqueUnorderedPrimitiveArrays:Wu,unorderedPrimitiveArrays:Va},Symbol.toStringTag,{value:"Module"})),Ka=(r,e,t=".")=>{const s=r.split(t);return s.map((n,a)=>{const o=e(n,a,s);return o==null?null:typeof o=="string"?o:o.join(t)}).filter(n=>n!=null).join(t)},Wn=(r,e,t={optional:!1,separator:"."})=>{t.separator??(t.separator=".");const{optional:s,getter:n=(u,l)=>u[l]}=t,a=e.split(t.separator);if(a.length===1&&a[0]==="")return r;let o=r;for(const u of a){const l=n(o,u);if(l==null){if(s)return null;throw new Error(`Path ${e} does not exist. ${u} is null`)}o=l}return o},Xu=(r,e,t)=>{const s=e.split(".");let n=r;for(let a=0;a<s.length-1;a++){const o=s[a];n[o]??(n[o]={}),n=n[o]}try{n[s[s.length-1]]=t}catch(a){throw console.error("failed to set value",t,"at path",e,"on object",r),a}},Qu=(r,e)=>{const t=e.split(".");let s=r;for(let n=0;n<t.length-1;n++){const a=t[n];if(s[a]==null)return;s=s[a]}if(Array.isArray(s)){const n=parseInt(t[t.length-1]);if(isNaN(n))return;s.splice(n,1);return}delete s[t[t.length-1]]},ec=(r,e)=>{const t=r.split(".");return e<0?t[t.length+e]:t[e]},tc=(r,e)=>{try{return Wn(r,e),!0}catch{return!1}},rc=(r,e)=>{if(e.length===0)return!0;const t=r.split("."),s=e.split(".");if(s.length>t.length)return!1;for(let n=0;n<s.length;n++){const a=t[n],o=s[n];if(o!=="*"&&a!==o)return!1}return!0},Ha=r=>Ka(r,(e,t,s)=>{const n=t===s.length-1,a=!isNaN(parseInt(e)),o=!isNaN(parseInt(s[t+1]));return a&&(e="element"),n||o?e:[e,"shape"]}),zi=(r,e)=>{if(r==null)return null;const t=r[e];return t==null&&typeof r=="object"&&"sourceType"in r?r.sourceType()[e]:t},sc=(r,e,t)=>Wn(zi(r,"shape"),Ha(e),{...t,getter:zi}),Xa=i.z.bigint().or(i.z.string().transform(BigInt)),nc=Object.freeze(Object.defineProperty({__proto__:null,bigInt:Xa,getFieldSchema:sc,getFieldSchemaPath:Ha},Symbol.toStringTag,{value:"Module"}));var ic=Object.defineProperty,ac=(r,e,t)=>e in r?ic(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,g=(r,e,t)=>ac(r,typeof e!="symbol"?e+"":e,t);let oc=(r,e=21)=>(t=e)=>{let s="",n=t|0;for(;n--;)s+=r[Math.random()*r.length|0];return s};const lc="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",Qa=oc(lc,11),eo=Object.freeze(Object.defineProperty({__proto__:null,id:Qa},Symbol.toStringTag,{value:"Module"})),uc=i.z.enum(["static","dynamic"]),to=(r,e)=>{const t=new G(e);if(![Z.DAY,Z.HOUR,Z.MINUTE,Z.SECOND,Z.MILLISECOND,Z.MICROSECOND,Z.NANOSECOND].some(n=>n.equals(t)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const s=r.valueOf()%t.valueOf();return r instanceof G?new G(s):new Z(s)},L=class z{constructor(e,t="UTC"){if(g(this,"value"),g(this,"encodeValue",!0),e==null)this.value=z.now().valueOf();else if(e instanceof Date)this.value=BigInt(e.getTime())*z.MILLISECOND.valueOf();else if(typeof e=="string")this.value=z.parseDateTimeString(e,t).valueOf();else if(Array.isArray(e))this.value=z.parseDate(e);else{let s=BigInt(0);e instanceof Number&&(e=e.valueOf()),t==="local"&&(s=z.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=z.MAX:e=z.MIN)),this.value=BigInt(e.valueOf())+s}}static parseDate([e=1970,t=1,s=1]){const n=new Date(e,t-1,s,0,0,0,0);return new z(BigInt(n.getTime())*z.MILLISECOND.valueOf()).truncate(z.DAY).valueOf()}encode(){return this.value.toString()}valueOf(){return this.value}static parseTimeString(e,t="UTC"){const[s,n,a]=e.split(":");let o="00",u="00";a!=null&&([o,u]=a.split("."));let l=z.hours(parseInt(s??"00")).add(z.minutes(parseInt(n??"00"))).add(z.seconds(parseInt(o??"00"))).add(z.milliseconds(parseInt(u??"00")));return t==="local"&&(l=l.add(z.utcOffset)),l.valueOf()}static parseDateTimeString(e,t="UTC"){if(!e.includes("/")&&!e.includes("-"))return z.parseTimeString(e,t);const s=new Date(e);return e.includes(":")||s.setUTCHours(0,0,0,0),new z(BigInt(s.getTime())*z.MILLISECOND.valueOf(),t).valueOf()}fString(e="ISO",t="UTC"){switch(e){case"ISODate":return this.toISOString(t).slice(0,10);case"ISOTime":return this.toISOString(t).slice(11,23);case"time":return this.timeString(!1,t);case"preciseTime":return this.timeString(!0,t);case"date":return this.dateString();case"preciseDate":return`${this.dateString()} ${this.timeString(!0,t)}`;case"dateTime":return`${this.dateString()} ${this.timeString(!1,t)}`;default:return this.toISOString(t)}}toISOString(e="UTC"){return e==="UTC"?this.date().toISOString():this.sub(z.utcOffset).date().toISOString()}timeString(e=!1,t="UTC"){const s=this.toISOString(t);return e?s.slice(11,23):s.slice(11,19)}dateString(){const e=this.date(),t=e.toLocaleString("default",{month:"short"}),s=e.toLocaleString("default",{day:"numeric"});return`${t} ${s}`}static get utcOffset(){return new Z(BigInt(new Date().getTimezoneOffset())*z.MINUTE.valueOf())}static since(e){return new z().span(e)}date(){return new Date(this.milliseconds)}equals(e){return this.valueOf()===new z(e).valueOf()}span(e){return this.range(e).span}range(e){return new ot(this,e).makeValid()}spanRange(e){return this.range(this.add(e)).makeValid()}get isZero(){return this.valueOf()===BigInt(0)}after(e){return this.valueOf()>new z(e).valueOf()}afterEq(e){return this.valueOf()>=new z(e).valueOf()}before(e){return this.valueOf()<new z(e).valueOf()}beforeEq(e){return this.valueOf()<=new z(e).valueOf()}add(e){return new z(this.valueOf()+BigInt(e.valueOf()))}sub(e){return new z(this.valueOf()-BigInt(e.valueOf()))}get hours(){return Number(this.valueOf())/Number(Z.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(Z.MINUTE.valueOf())}get days(){return Number(this.valueOf())/Number(Z.DAY.valueOf())}get seconds(){return Number(this.valueOf())/Number(Z.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(z.MILLISECOND.valueOf())}get year(){return this.date().getFullYear()}setYear(e){const t=this.date();return t.setFullYear(e),new z(t)}get month(){return this.date().getMonth()}setMonth(e){const t=this.date();return t.setMonth(e),new z(t)}get day(){return this.date().getDate()}setDay(e){const t=this.date();return t.setDate(e),new z(t)}get hour(){return this.date().getHours()}setHour(e){const t=this.date();return t.setHours(e),new z(t)}get minute(){return this.date().getMinutes()}setMinute(e){const t=this.date();return t.setMinutes(e),new z(t)}get second(){return this.date().getSeconds()}setSecond(e){const t=this.date();return t.setSeconds(e),new z(t)}get millisecond(){return this.date().getMilliseconds()}setMillisecond(e){const t=this.date();return t.setMilliseconds(e),new z(t)}toString(){return this.date().toISOString()}remainder(e){return to(this,e)}get isToday(){return this.truncate(Z.DAY).equals(z.now().truncate(Z.DAY))}truncate(e){return this.sub(this.remainder(e))}static now(){return new z(new Date)}static max(...e){let t=z.MIN;for(const s of e){const n=new z(s);n.after(t)&&(t=n)}return t}static min(...e){let t=z.MAX;for(const s of e){const n=new z(s);n.before(t)&&(t=n)}return t}static nanoseconds(e){return new z(e)}static microseconds(e){return z.nanoseconds(e*1e3)}static milliseconds(e){return z.microseconds(e*1e3)}static seconds(e){return z.milliseconds(e*1e3)}static minutes(e){return z.seconds(e*60)}static hours(e){return z.minutes(e*60)}static days(e){return z.hours(e*24)}};g(L,"NANOSECOND",L.nanoseconds(1)),g(L,"MICROSECOND",L.microseconds(1)),g(L,"MILLISECOND",L.milliseconds(1)),g(L,"SECOND",L.seconds(1)),g(L,"MINUTE",L.minutes(1)),g(L,"HOUR",L.hours(1)),g(L,"DAY",L.days(1)),g(L,"MAX",new L((1n<<63n)-1n)),g(L,"MIN",new L(0)),g(L,"ZERO",new L(0)),g(L,"z",i.z.union([i.z.object({value:i.z.bigint()}).transform(r=>new L(r.value)),i.z.string().transform(r=>new L(BigInt(r))),i.z.instanceof(Number).transform(r=>new L(r)),i.z.number().transform(r=>new L(r)),i.z.instanceof(L)]));let G=L;const _=class A{constructor(e){g(this,"value"),g(this,"encodeValue",!0),typeof e=="number"&&(e=Math.trunc(e.valueOf())),this.value=BigInt(e.valueOf())}static fromSeconds(e){return e instanceof A?e:e instanceof is?e.period:e instanceof G?new A(e):["number","bigint"].includes(typeof e)?A.seconds(e):new A(e)}static fromMilliseconds(e){return e instanceof A?e:e instanceof is?e.period:e instanceof G?new A(e):["number","bigint"].includes(typeof e)?A.milliseconds(e):new A(e)}encode(){return this.value.toString()}valueOf(){return this.value}lessThan(e){return this.valueOf()<new A(e).valueOf()}greaterThan(e){return this.valueOf()>new A(e).valueOf()}lessThanOrEqual(e){return this.valueOf()<=new A(e).valueOf()}greaterThanOrEqual(e){return this.valueOf()>=new A(e).valueOf()}remainder(e){return to(this,e)}truncate(e){return new A(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(){const e=this.truncate(A.DAY),t=this.truncate(A.HOUR),s=this.truncate(A.MINUTE),n=this.truncate(A.SECOND),a=this.truncate(A.MILLISECOND),o=this.truncate(A.MICROSECOND),u=this.truncate(A.NANOSECOND),l=e,h=t.sub(e),f=s.sub(t),d=n.sub(s),I=a.sub(n),j=o.sub(a),ue=u.sub(o);let D="";return l.isZero||(D+=`${l.days}d `),h.isZero||(D+=`${h.hours}h `),f.isZero||(D+=`${f.minutes}m `),d.isZero||(D+=`${d.seconds}s `),I.isZero||(D+=`${I.milliseconds}ms `),j.isZero||(D+=`${j.microseconds}µs `),ue.isZero||(D+=`${ue.nanoseconds}ns`),D.trim()}mult(e){return new A(this.valueOf()*BigInt(e))}get days(){return Number(this.valueOf())/Number(A.DAY.valueOf())}get hours(){return Number(this.valueOf())/Number(A.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(A.MINUTE.valueOf())}get seconds(){return Number(this.valueOf())/Number(A.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(A.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(A.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===BigInt(0)}equals(e){return this.valueOf()===new A(e).valueOf()}add(e){return new A(this.valueOf()+new A(e).valueOf())}sub(e){return new A(this.valueOf()-new A(e).valueOf())}static nanoseconds(e=1){return new A(e)}static microseconds(e=1){return A.nanoseconds(p.M(e,1e3))}static milliseconds(e=1){return A.microseconds(p.M(e,1e3))}static seconds(e=1){return A.milliseconds(p.M(e,1e3))}static minutes(e=1){return A.seconds(p.M(e,60))}static hours(e){return A.minutes(p.M(e,60))}static days(e){return A.hours(p.M(e,24))}};g(_,"NANOSECOND",_.nanoseconds(1)),g(_,"MICROSECOND",_.microseconds(1)),g(_,"MILLISECOND",_.milliseconds(1)),g(_,"SECOND",_.seconds(1)),g(_,"MINUTE",_.minutes(1)),g(_,"HOUR",_.hours(1)),g(_,"DAY",_.days(1)),g(_,"MAX",new _((1n<<63n)-1n)),g(_,"MIN",new _(0)),g(_,"ZERO",new _(0)),g(_,"z",i.z.union([i.z.object({value:i.z.bigint()}).transform(r=>new _(r.value)),i.z.string().transform(r=>new _(BigInt(r))),i.z.instanceof(Number).transform(r=>new _(r)),i.z.number().transform(r=>new _(r)),i.z.instanceof(_)]));let Z=_;const Et=class Ar extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new Ar(e).valueOf()}get period(){return Z.seconds(1/this.valueOf())}sampleCount(e){return new Z(e).seconds*this.valueOf()}byteCount(e,t){return this.sampleCount(e)*new fe(t).valueOf()}span(e){return Z.seconds(e/this.valueOf())}byteSpan(e,t){return this.span(e.valueOf()/t.valueOf())}static hz(e){return new Ar(e)}static khz(e){return Ar.hz(e*1e3)}};g(Et,"z",i.z.union([i.z.number().transform(r=>new Et(r)),i.z.instanceof(Number).transform(r=>new Et(r)),i.z.instanceof(Et)]));let is=Et;const ne=class extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}length(e){return e.valueOf()/this.valueOf()}size(e){return new Xt(e*this.valueOf())}};g(ne,"UNKNOWN",new ne(0)),g(ne,"BIT128",new ne(16)),g(ne,"BIT64",new ne(8)),g(ne,"BIT32",new ne(4)),g(ne,"BIT16",new ne(2)),g(ne,"BIT8",new ne(1)),g(ne,"z",i.z.union([i.z.number().transform(r=>new ne(r)),i.z.instanceof(Number).transform(r=>new ne(r)),i.z.instanceof(ne)]));let fe=ne;const Ee=class kr{constructor(e,t){g(this,"start"),g(this,"end"),typeof e=="object"&&"start"in e?(this.start=new G(e.start),this.end=new G(e.end)):(this.start=new G(e),this.end=new G(t))}get span(){return new Z(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 kr(this.end,this.start)}equals(e){return this.start.equals(e.start)&&this.end.equals(e.end)}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.fString("preciseDate")} - ${this.span.toString()}`}overlapsWith(e,t=Z.ZERO){e=e.makeValid();const s=this.makeValid();if(this.equals(e))return!0;if(e.end.equals(s.start)||s.end.equals(e.start))return!1;const n=G.max(s.start,e.start),a=G.min(s.end,e.end);return a.before(n)?!1:new Z(a.sub(n)).greaterThanOrEqual(t)}roughlyEquals(e,t){let s=this.start.sub(e.start).valueOf(),n=this.end.sub(e.end).valueOf();return s<0&&(s=-s),n<0&&(n=-n),s<=t.valueOf()&&n<=t.valueOf()}contains(e){return e instanceof kr?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const t=new kr(this.start,this.end);return e.start.after(this.start)&&(t.start=e.start),e.start.after(this.end)&&(t.end=e.start),e.end.before(this.end)&&(t.end=e.end),e.end.before(this.start)&&(t.start=e.end),t}};g(Ee,"MAX",new Ee(G.MIN,G.MAX)),g(Ee,"MIN",new Ee(G.MAX,G.MIN)),g(Ee,"ZERO",new Ee(G.ZERO,G.ZERO)),g(Ee,"z",i.z.union([i.z.object({start:G.z,end:G.z}).transform(r=>new Ee(r.start,r.end)),i.z.instanceof(Ee)]));let ot=Ee;const m=class K extends String{constructor(e){if(e instanceof K||typeof e=="string"||typeof e.valueOf()=="string"){super(e.valueOf());return}const t=K.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(t!=null){super(t.valueOf());return}throw super(K.UNKNOWN.valueOf()),new Error(`unable to find data type for ${e.toString()}`)}get Array(){const e=K.ARRAY_CONSTRUCTORS.get(this.toString());if(e==null)throw new Error(`unable to find array constructor for ${this.valueOf()}`);return e}equals(e){return this.valueOf()===e.valueOf()}matches(...e){return e.some(t=>this.equals(t))}toString(){return this.valueOf()}get isVariable(){return this.equals(K.JSON)||this.equals(K.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(K.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=K.DENSITIES.get(this.toString());if(e==null)throw new Error(`unable to find density for ${this.valueOf()}`);return e}get isUnsigned(){return this.equals(K.UINT8)||this.equals(K.UINT16)||this.equals(K.UINT32)||this.equals(K.UINT64)}get isSigned(){return this.equals(K.INT8)||this.equals(K.INT16)||this.equals(K.INT32)||this.equals(K.INT64)}canSafelyCastTo(e){return this.equals(e)?!0:!this.isNumeric||!e.isNumeric||this.isVariable||e.isVariable||this.isUnsigned&&e.isSigned?!1:this.isFloat?e.isFloat&&this.density.valueOf()<=e.density.valueOf():this.equals(K.INT32)&&e.equals(K.FLOAT64)||this.equals(K.INT8)&&e.equals(K.FLOAT32)?!0:this.isInteger&&e.isInteger?this.density.valueOf()<=e.density.valueOf()&&this.isUnsigned===e.isUnsigned:!1}canCastTo(e){return this.isNumeric&&e.isNumeric?!0:this.equals(e)}checkArray(e){return e.constructor===this.Array}toJSON(){return this.toString()}get usesBigInt(){return K.BIG_INT_TYPES.some(e=>e.equals(this))}};g(m,"UNKNOWN",new m("unknown")),g(m,"FLOAT64",new m("float64")),g(m,"FLOAT32",new m("float32")),g(m,"INT64",new m("int64")),g(m,"INT32",new m("int32")),g(m,"INT16",new m("int16")),g(m,"INT8",new m("int8")),g(m,"UINT64",new m("uint64")),g(m,"UINT32",new m("uint32")),g(m,"UINT16",new m("uint16")),g(m,"UINT8",new m("uint8")),g(m,"BOOLEAN",m.UINT8),g(m,"TIMESTAMP",new m("timestamp")),g(m,"UUID",new m("uuid")),g(m,"STRING",new m("string")),g(m,"JSON",new m("json")),g(m,"ARRAY_CONSTRUCTORS",new Map([[m.UINT8.toString(),Uint8Array],[m.UINT16.toString(),Uint16Array],[m.UINT32.toString(),Uint32Array],[m.UINT64.toString(),BigUint64Array],[m.FLOAT32.toString(),Float32Array],[m.FLOAT64.toString(),Float64Array],[m.INT8.toString(),Int8Array],[m.INT16.toString(),Int16Array],[m.INT32.toString(),Int32Array],[m.INT64.toString(),BigInt64Array],[m.TIMESTAMP.toString(),BigInt64Array],[m.STRING.toString(),Uint8Array],[m.JSON.toString(),Uint8Array],[m.UUID.toString(),Uint8Array]])),g(m,"ARRAY_CONSTRUCTOR_DATA_TYPES",new Map([[Uint8Array.name,m.UINT8],[Uint16Array.name,m.UINT16],[Uint32Array.name,m.UINT32],[BigUint64Array.name,m.UINT64],[Float32Array.name,m.FLOAT32],[Float64Array.name,m.FLOAT64],[Int8Array.name,m.INT8],[Int16Array.name,m.INT16],[Int32Array.name,m.INT32],[BigInt64Array.name,m.INT64]])),g(m,"DENSITIES",new Map([[m.UINT8.toString(),fe.BIT8],[m.UINT16.toString(),fe.BIT16],[m.UINT32.toString(),fe.BIT32],[m.UINT64.toString(),fe.BIT64],[m.FLOAT32.toString(),fe.BIT32],[m.FLOAT64.toString(),fe.BIT64],[m.INT8.toString(),fe.BIT8],[m.INT16.toString(),fe.BIT16],[m.INT32.toString(),fe.BIT32],[m.INT64.toString(),fe.BIT64],[m.TIMESTAMP.toString(),fe.BIT64],[m.STRING.toString(),fe.UNKNOWN],[m.JSON.toString(),fe.UNKNOWN],[m.UUID.toString(),fe.BIT128]])),g(m,"ALL",[m.UNKNOWN,m.FLOAT64,m.FLOAT32,m.INT64,m.INT32,m.INT16,m.INT8,m.UINT64,m.UINT32,m.UINT16,m.UINT8,m.TIMESTAMP,m.UUID,m.STRING,m.JSON]),g(m,"BIG_INT_TYPES",[m.INT64,m.UINT64,m.TIMESTAMP]),g(m,"z",i.z.union([i.z.string().transform(r=>new m(r)),i.z.instanceof(m)]));let M=m;const ce=class ee extends Number{constructor(e){super(e.valueOf())}largerThan(e){return this.valueOf()>e.valueOf()}smallerThan(e){return this.valueOf()<e.valueOf()}add(e){return ee.bytes(this.valueOf()+e.valueOf())}sub(e){return ee.bytes(this.valueOf()-e.valueOf())}truncate(e){return new ee(Math.trunc(this.valueOf()/e.valueOf())*e.valueOf())}remainder(e){return ee.bytes(this.valueOf()%e.valueOf())}get gigabytes(){return this.valueOf()/ee.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/ee.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/ee.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/ee.TERABYTE.valueOf()}toString(){const e=this.truncate(ee.TERABYTE),t=this.truncate(ee.GIGABYTE),s=this.truncate(ee.MEGABYTE),n=this.truncate(ee.KILOBYTE),a=this.truncate(ee.BYTE),o=e,u=t.sub(e),l=s.sub(t),h=n.sub(s),f=a.sub(n);let d="";return o.isZero||(d+=`${o.terabytes}TB `),u.isZero||(d+=`${u.gigabytes}GB `),l.isZero||(d+=`${l.megabytes}MB `),h.isZero||(d+=`${h.kilobytes}KB `),(!f.isZero||d==="")&&(d+=`${f.valueOf()}B`),d.trim()}static bytes(e=1){return new ee(e)}static kilobytes(e=1){return ee.bytes(e.valueOf()*1e3)}static megabytes(e=1){return ee.kilobytes(e.valueOf()*1e3)}static gigabytes(e=1){return ee.megabytes(e.valueOf()*1e3)}static terabytes(e){return ee.gigabytes(e.valueOf()*1e3)}get isZero(){return this.valueOf()===0}};g(ce,"BYTE",new ce(1)),g(ce,"KILOBYTE",ce.kilobytes(1)),g(ce,"MEGABYTE",ce.megabytes(1)),g(ce,"GIGABYTE",ce.gigabytes(1)),g(ce,"TERABYTE",ce.terabytes(1)),g(ce,"ZERO",new ce(0)),g(ce,"z",i.z.union([i.z.number().transform(r=>new ce(r)),i.z.instanceof(ce)]));let Xt=ce;const cc=i.z.union([i.z.instanceof(Uint8Array),i.z.instanceof(Uint16Array),i.z.instanceof(Uint32Array),i.z.instanceof(BigUint64Array),i.z.instanceof(Float32Array),i.z.instanceof(Float64Array),i.z.instanceof(Int8Array),i.z.instanceof(Int16Array),i.z.instanceof(Int32Array),i.z.instanceof(BigInt64Array)]),ro=r=>{const e=typeof r;return e==="string"||e==="number"||e==="boolean"||e==="bigint"||r instanceof G||r instanceof Z||r instanceof Date},hc=(r,e,t,s=0)=>r.usesBigInt&&!e.usesBigInt?Number(t)-Number(s):!r.usesBigInt&&e.usesBigInt?BigInt(t.valueOf())-BigInt(s.valueOf()):xt(t,-s).valueOf(),dc=r=>r==null?!1:Array.isArray(r)||r instanceof ArrayBuffer||ArrayBuffer.isView(r)&&!(r instanceof DataView)||r instanceof so?!0:ro(r),De=-1,pn={[Symbol.iterator]:()=>pn,next:()=>({done:!0,value:void 0})},fc=i.z.string().transform(r=>new Uint8Array(atob(r).split("").map(e=>e.charCodeAt(0))).buffer),pc=i.z.union([i.z.null(),i.z.undefined()]).transform(()=>new Uint8Array().buffer),gn=10,It=class Ie{constructor(e){g(this,"key",""),g(this,"isSynnaxSeries",!0),g(this,"dataType"),g(this,"sampleOffset"),g(this,"gl"),g(this,"_data"),g(this,"_timeRange"),g(this,"alignment",0n),g(this,"_cachedMin"),g(this,"_cachedMax"),g(this,"writePos",De),g(this,"_refCount",0),g(this,"_cachedLength"),g(this,"_cachedIndexes"),dc(e)&&(e={data:e});const{dataType:t,timeRange:s,sampleOffset:n=0,glBufferUsage:a="static",alignment:o=0n,key:u=Qa()}=e,l=e.data??[];if(l instanceof Ie||typeof l=="object"&&"isSynnaxSeries"in l&&l.isSynnaxSeries===!0){const d=l;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._cachedMin=d._cachedMin,this._cachedMax=d._cachedMax,this.writePos=d.writePos,this._refCount=d._refCount,this._cachedLength=d._cachedLength;return}const h=ro(l),f=Array.isArray(l);if(t!=null)this.dataType=new M(t);else{if(l 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=l;if(!h){if(l.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=l[0]}if(typeof d=="string")this.dataType=M.STRING;else if(typeof d=="number")this.dataType=M.FLOAT64;else if(typeof d=="bigint")this.dataType=M.INT64;else if(typeof d=="boolean")this.dataType=M.BOOLEAN;else if(d instanceof G||d instanceof Date||d instanceof G)this.dataType=M.TIMESTAMP;else if(typeof d=="object")this.dataType=M.JSON;else throw new Error(`cannot infer data type of ${typeof d} when constructing a Series from a JS array`)}else this.dataType=new M(l)}if(!f&&!h)this._data=l;else{let d=h?[l]:l;const I=d[0];(I instanceof G||I instanceof Date||I instanceof Z)&&(d=d.map(j=>new G(j).valueOf())),this.dataType.equals(M.STRING)?(this._cachedLength=d.length,this._data=new TextEncoder().encode(`${d.join(`
|
|
4
|
-
`)}
|
|
5
|
-
`).buffer):this.dataType.equals(M.JSON)?(this._cachedLength=d.length,this._data=new TextEncoder().encode(`${d.map(j=>Er.encodeString(j)).join(`
|
|
6
|
-
`)}
|
|
7
|
-
`).buffer):this._data=new this.dataType.Array(d).buffer}this.key=u,this.alignment=o,this.sampleOffset=n??0,this._timeRange=s,this.gl={control:null,buffer:null,prevBuffer:0,bufferUsage:a}}static alloc({capacity:e,dataType:t,...s}){if(e===0)throw new Error("[Series] - cannot allocate an array of length 0");const n=new new M(t).Array(e),a=new Ie({data:n.buffer,dataType:t,...s});return a.writePos=0,a}static generateTimestamps(e,t,s){const n=s.spanRange(t.span(e)),a=new BigInt64Array(e);for(let o=0;o<e;o++)a[o]=BigInt(s.add(t.span(o)).valueOf());return new Ie({data:a,dataType:M.TIMESTAMP,timeRange:n})}get refCount(){return this._refCount}static fromStrings(e,t){const s=new TextEncoder().encode(`${e.join(`
|
|
8
|
-
`)}
|
|
9
|
-
`);return new Ie({data:s,dataType:M.STRING,timeRange:t})}static fromJSON(e,t){const s=new TextEncoder().encode(`${e.map(n=>Er.encodeString(n)).join(`
|
|
10
|
-
`)}
|
|
11
|
-
`);return new Ie({data:s,dataType:M.JSON,timeRange:t})}acquire(e){this._refCount++,e!=null&&this.updateGLBuffer(e)}release(){if(this._refCount--,this._refCount===0&&this.gl.control!=null)this.maybeGarbageCollectGLBuffer(this.gl.control);else if(this._refCount<0)throw new Error("cannot release an array with a negative reference count")}write(e){if(!e.dataType.equals(this.dataType))throw new Error("buffer must be of the same type as this array");return this.dataType.isVariable?this.writeVariable(e):this.writeFixed(e)}writeVariable(e){if(this.writePos===De)return 0;const t=this.byteCapacity.valueOf()-this.writePos,s=e.subBytes(0,t);return this.writeToUnderlyingData(s),this.writePos+=s.byteLength.valueOf(),this._cachedLength!=null&&(this._cachedLength+=s.length,this.calculateCachedLength()),s.length}writeFixed(e){if(this.writePos===De)return 0;const t=this.capacity-this.writePos,s=e.sub(0,t);return this.writeToUnderlyingData(s),this._cachedLength=void 0,this.maybeRecomputeMinMax(s),this.writePos+=s.length,s.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===De?this.underlyingData:new this.dataType.Array(this._data,0,this.writePos)}toStrings(){if(!this.dataType.matches(M.STRING,M.UUID))throw new Error("cannot convert non-string series to strings");return new TextDecoder().decode(this.underlyingData).split(`
|
|
12
|
-
`).slice(0,-1)}toUUIDs(){if(!this.dataType.equals(M.UUID))throw new Error("cannot convert non-uuid series to uuids");const e=M.UUID.density.valueOf(),t=Array(this.length);for(let s=0;s<this.length;s++){const n=this.underlyingData.slice(s*e,(s+1)*e),a=Array.from(new Uint8Array(n.buffer),o=>o.toString(16).padStart(2,"0")).join("").replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/,"$1-$2-$3-$4-$5");t[s]=a}return t}parseJSON(e){if(!this.dataType.equals(M.JSON))throw new Error("cannot parse non-JSON series as JSON");return new TextDecoder().decode(this.underlyingData).split(`
|
|
13
|
-
`).slice(0,-1).map(t=>e.parse(Er.decodeString(t)))}get timeRange(){if(this._timeRange==null)throw new Error("time range not set on series");return this._timeRange}get byteCapacity(){return new Xt(this.underlyingData.byteLength)}get capacity(){return this.dataType.isVariable?this.byteCapacity.valueOf():this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===De?this.byteCapacity:this.dataType.isVariable?new Xt(this.writePos):this.dataType.density.size(this.writePos)}get length(){return this._cachedLength!=null?this._cachedLength:this.dataType.isVariable?this.calculateCachedLength():this.writePos===De?this.data.length:this.writePos}calculateCachedLength(){if(!this.dataType.isVariable)throw new Error("cannot calculate length of a non-variable length data type");let e=0;const t=[0];return this.data.forEach((s,n)=>{s===gn&&(e++,t.push(n+1))}),this._cachedIndexes=t,this._cachedLength=e,e}convert(e,t=0){if(this.dataType.equals(e))return this;const s=new e.Array(this.length);for(let n=0;n<this.length;n++)s[n]=hc(this.dataType,e,this.data[n],t);return new Ie({data:s.buffer,dataType:e,timeRange:this._timeRange,sampleOffset:t,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment})}calcRawMax(){if(this.length===0)return-1/0;if(this.dataType.equals(M.TIMESTAMP))this._cachedMax=this.data[this.data.length-1];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMax=e.reduce((t,s)=>t>s?t:s)}else{const e=this.data;this._cachedMax=e.reduce((t,s)=>t>s?t:s)}return this._cachedMax}get max(){if(this.dataType.isVariable)throw new Error("cannot calculate maximum on a variable length data type");return this.writePos===0?-1/0:(this._cachedMax??(this._cachedMax=this.calcRawMax()),xt(this._cachedMax,this.sampleOffset))}calcRawMin(){if(this.length===0)return 1/0;if(this.dataType.equals(M.TIMESTAMP))this._cachedMin=this.data[0];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMin=e.reduce((t,s)=>t<s?t:s)}else{const e=this.data;this._cachedMin=e.reduce((t,s)=>t<s?t:s)}return this._cachedMin}get min(){if(this.dataType.isVariable)throw new Error("cannot calculate minimum on a variable length data type");return this.writePos===0?1/0:(this._cachedMin??(this._cachedMin=this.calcRawMin()),xt(this._cachedMin,this.sampleOffset))}get bounds(){return p.i(Number(this.min),Number(this.max))}maybeRecomputeMinMax(e){if(this._cachedMin!=null){const t=e._cachedMin??e.calcRawMin();t<this._cachedMin&&(this._cachedMin=t)}if(this._cachedMax!=null){const t=e._cachedMax??e.calcRawMax();t>this._cachedMax&&(this._cachedMax=t)}}enrich(){this.max,this.min}get range(){return xt(this.max,-this.min)}atAlignment(e,t){const s=Number(e-this.alignment);if(s<0||s>=this.length){if(t===!0)throw new Error(`[series] - no value at index ${s}`);return}return this.at(s,t)}at(e,t){if(this.dataType.isVariable)return this.atVariable(e,t??!1);e<0&&(e=this.length+e);const s=this.data[e];if(s==null){if(t===!0)throw new Error(`[series] - no value at index ${e}`);return}return xt(s,this.sampleOffset)}atVariable(e,t){let s=0,n=0;if(this._cachedIndexes!=null)s=this._cachedIndexes[e],n=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]===gn){if(e===0){n=o;break}s=o+1,e--}if(n===0&&(n=this.data.length),s>=n||e>0){if(t)throw new Error(`[series] - no value at index ${e}`);return}}const a=this.data.slice(s,n);return this.dataType.equals(M.STRING)?new TextDecoder().decode(a):p.C(JSON.parse(new TextDecoder().decode(a)))}binarySearch(e){let t=0,s=this.length-1;const n=ws(e);for(;t<=s;){const a=Math.floor((t+s)/2),o=n(this.at(a,!0),e);if(o===0)return a;o<0?t=a+1:s=a-1}return t}updateGLBuffer(e){if(this.gl.control=e,!this.dataType.equals(M.FLOAT32)&&!this.dataType.equals(M.UINT8))throw new Error("Only FLOAT32 and UINT8 arrays can be used in WebGL");const{buffer:t,bufferUsage:s,prevBuffer:n}=this.gl;if(t==null&&(this.gl.buffer=e.createBuffer()),this.writePos!==n)if(e.bindBuffer(e.ARRAY_BUFFER,this.gl.buffer),this.writePos!==De){n===0&&e.bufferData(e.ARRAY_BUFFER,this.byteCapacity.valueOf(),e.STATIC_DRAW);const a=this.dataType.density.size(n).valueOf(),o=this.underlyingData.slice(this.gl.prevBuffer,this.writePos);e.bufferSubData(e.ARRAY_BUFFER,a,o.buffer),this.gl.prevBuffer=this.writePos}else e.bufferData(e.ARRAY_BUFFER,this.buffer,s==="static"?e.STATIC_DRAW:e.DYNAMIC_DRAW),this.gl.prevBuffer=De}as(e){if(e==="string"){if(!this.dataType.equals(M.STRING))throw new Error(`cannot convert series of type ${this.dataType.toString()} to string`);return this}if(e==="number"){if(!this.dataType.isNumeric)throw new Error(`cannot convert series of type ${this.dataType.toString()} to number`);return this}if(e==="bigint"){if(!this.dataType.equals(M.INT64))throw new Error(`cannot convert series of type ${this.dataType.toString()} to bigint`);return this}throw new Error(`cannot convert series to ${e}`)}get digest(){var e;return{key:this.key,dataType:this.dataType.toString(),sampleOffset:this.sampleOffset,alignment:{lower:Ri(this.alignmentBounds.lower),upper:Ri(this.alignmentBounds.upper)},timeRange:(e=this._timeRange)==null?void 0:e.toString(),length:this.length,capacity:this.capacity}}get memInfo(){return{key:this.key,length:this.length,byteLength:this.byteLength,glBuffer:this.gl.buffer!=null}}get alignmentBounds(){return p.i(this.alignment,this.alignment+BigInt(this.length))}maybeGarbageCollectGLBuffer(e){this.gl.buffer!=null&&(e.deleteBuffer(this.gl.buffer),this.gl.buffer=null,this.gl.prevBuffer=0,this.gl.control=null)}get glBuffer(){if(this.gl.buffer==null)throw new Error("gl buffer not initialized");return this.gl.prevBuffer!==this.writePos&&console.warn("buffer not updated"),this.gl.buffer}[Symbol.iterator](){if(this.dataType.isVariable){const e=new gc(this);return this.dataType.equals(M.JSON)?new yc(e):e}return new mc(this)}slice(e,t){return this.sliceSub(!1,e,t)}sub(e,t){return this.sliceSub(!0,e,t)}subIterator(e,t){return new Ni(this,e,t??this.length)}subAlignmentIterator(e,t){return new Ni(this,Number(e-this.alignment),Number(t-this.alignment))}subBytes(e,t){if(e>=0&&(t==null||t>=this.byteLength.valueOf()))return this;const s=this.data.subarray(e,t);return new Ie({data:s,dataType:this.dataType,timeRange:this._timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(e)})}sliceSub(e,t,s){if(t<=0&&(s==null||s>=this.length))return this;let n;return e?n=this.data.subarray(t,s):n=this.data.slice(t,s),new Ie({data:n,dataType:this.dataType,timeRange:this._timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(t)})}reAlign(e){return new Ie({data:this.buffer,dataType:this.dataType,timeRange:ot.ZERO,sampleOffset:this.sampleOffset,glBufferUsage:"static",alignment:e})}};g(It,"crudeZ",i.z.object({timeRange:ot.z.optional(),dataType:M.z,alignment:Xa.optional(),data:i.z.union([fc,pc,i.z.instanceof(ArrayBuffer),i.z.instanceof(Uint8Array)]),glBufferUsage:uc.optional().default("static").optional()})),g(It,"z",It.crudeZ.transform(r=>new It(r)));let so=It,Ni=class{constructor(e,t,s){g(this,"series"),g(this,"end"),g(this,"index"),this.series=e;const n=p.i(0,e.length);this.end=p.T(n,s),this.index=p.T(n,t)}next(){return this.index>=this.end?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}[Symbol.iterator](){return this}},gc=class{constructor(e){if(g(this,"series"),g(this,"index"),g(this,"decoder"),!e.dataType.isVariable)throw new Error("cannot create a variable series iterator for a non-variable series");this.series=e,this.index=0,this.decoder=new TextDecoder}next(){const e=this.index,t=this.series.data;for(;this.index<t.length&&t[this.index]!==gn;)this.index++;const s=this.index;return e===s?{done:!0,value:void 0}:(this.index++,{done:!1,value:this.decoder.decode(this.series.buffer.slice(e,s))})}[Symbol.iterator](){return this}};var Ei,Ii;let yc=class{constructor(e){g(this,"wrapped"),g(this,Ei,"JSONSeriesIterator"),this.wrapped=e}next(){const e=this.wrapped.next();return e.done===!0?{done:!0,value:void 0}:{done:!1,value:Er.decodeString(e.value)}}[(Ii=Symbol.iterator,Ei=Symbol.toStringTag,Ii)](){return this}};var xi,Ai;let mc=class{constructor(e){g(this,"series"),g(this,"index"),g(this,xi,"SeriesIterator"),this.series=e,this.index=0}next(){return this.index>=this.series.length?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}[(Ai=Symbol.iterator,xi=Symbol.toStringTag,Ai)](){return this}};const xt=(r,e)=>typeof r=="bigint"&&typeof e=="bigint"||typeof r=="number"&&typeof e=="number"?r+e:e===0?r:r===0?e:Number(r)+Number(e);let wc=class{constructor(e){if(g(this,"series"),e.length!==0){const t=e[0].dataType;for(let s=1;s<e.length;s++)if(!e[s].dataType.equals(t))throw new Error("[multi-series] - series must have the same data type")}this.series=e}as(e){if(!new M(e).equals(this.dataType))throw new Error(`cannot convert series of type ${this.dataType.toString()} to ${e.toString()}`);return this}get dataType(){return this.series.length===0?M.UNKNOWN:this.series[0].dataType}get timeRange(){return this.series.length===0?ot.ZERO:new ot(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?p.i(0n,0n):p.i(this.series[0].alignmentBounds.lower,this.series[this.series.length-1].alignmentBounds.upper)}push(e){this.series.push(e)}get length(){return this.series.reduce((e,t)=>e+t.length,0)}atAlignment(e,t){if(this.series.length===0){if(t)throw new Error(`[series] - no value at alignment ${e}`);return}for(const s of this.series)if(p.a(s.alignmentBounds,e))return s.atAlignment(e,t);if(t)throw new Error(`[series] - no value at alignment ${e}`)}at(e,t=!1){e<0&&(e=this.length+e);for(const s of this.series){if(e<s.length)return s.at(e,t);e-=s.length}if(t)throw new Error(`[series] - no value at index ${e}`)}subIterator(e,t){return new js(this,e,t??this.length)}subAlignmentIterator(e,t){if(e>=this.alignmentBounds.upper||t<=this.alignmentBounds.lower)return pn;let s=0;for(let a=0;a<this.series.length;a++){const o=this.series[a];if(e<o.alignment)break;if(e>=o.alignmentBounds.upper)s+=o.length;else if(p.a(o.alignmentBounds,e)){s+=Number(e-o.alignment);break}}let n=0;for(let a=0;a<this.series.length;a++){const o=this.series[a];if(t<o.alignment)break;if(t>=o.alignmentBounds.upper)n+=o.length;else if(p.a(o.alignmentBounds,t)){n+=Number(t-o.alignment);break}}return new js(this,s,n)}subAlignmentSpanIterator(e,t){if(e>=this.alignmentBounds.upper)return pn;let s=0;for(let n=0;n<this.series.length;n++){const a=this.series[n];if(e<a.alignment)break;if(e>=a.alignmentBounds.upper)s+=a.length;else if(p.a(a.alignmentBounds,e)){s+=Number(e-a.alignment);break}}return new js(this,s,s+t)}get byteLength(){return new Xt(this.series.reduce((e,t)=>e+t.byteLength.valueOf(),0))}get data(){const e=new this.dataType.Array(this.length);let t=0;for(const s of this.series)e.set(s.data,t),t+=s.length;return new this.dataType.Array(e.buffer)}traverseAlignment(e,t){const s=this.series.map(n=>n.alignmentBounds);return p.U(s,e,t)}distance(e,t){const s=this.series.map(n=>n.alignmentBounds);return p.V(s,e,t)}parseJSON(e){if(!this.dataType.equals(M.JSON))throw new Error("cannot parse non-JSON series as JSON");return this.series.flatMap(t=>t.parseJSON(e))}[Symbol.iterator](){return this.series.length===0?{next(){return{done:!0,value:void 0}}}:new bc(this.series)}};var ki,Ci;class bc{constructor(e){g(this,"series"),g(this,"seriesIndex"),g(this,"internal"),g(this,ki,"MultiSeriesIterator"),this.series=e,this.seriesIndex=0,this.internal=e[0][Symbol.iterator]()}next(){const e=this.internal.next();return e.done===!1?e:this.seriesIndex===this.series.length-1?{done:!0,value:void 0}:(this.internal=this.series[++this.seriesIndex][Symbol.iterator](),this.next())}[(Ci=Symbol.iterator,ki=Symbol.toStringTag,Ci)](){return this}}let js=class{constructor(e,t,s){g(this,"series"),g(this,"index"),g(this,"end"),this.series=e,this.end=s,this.index=t}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 Ri=r=>{const e=r>>32n,t=r&0xffffffffn;return{domain:e,sample:t}},vc=(r,e)=>{let t=null;return e===0?r:(...s)=>{t!==null&&(clearTimeout(t),t=null),t=setTimeout(()=>r(...s),e)}},Tc=(r,e)=>{let t=null;return e===0?r:(...s)=>{t===null&&(t=setTimeout(()=>{r(...s),t=null},e))}},Oc=r=>JSON.parse(JSON.stringify(r)),Sc=(r,...e)=>(e.forEach(t=>{let s=r;const n=t.split(".");n.forEach((a,o)=>{o===n.length-1?delete s[a]:a in s&&(s=s[a])})}),r),zc=(r,e,t="")=>{const s={},n=(a,o,u)=>{if(typeof a!=typeof o||a===null||o===null){s[u]=[a,o];return}if(typeof a=="object"&&typeof o=="object")if(Array.isArray(a)&&Array.isArray(o)){if(a.length!==o.length){s[u]=[a,o];return}for(let l=0;l<a.length;l++)n(a[l],o[l],`${u}[${l}]`)}else new Set([...Object.keys(a),...Object.keys(o)]).forEach(l=>{n(a[l],o[l],u!==""?`${u}.${l}`:l)});else a!==o&&(s[u]=[a,o])};return n(r,e,t),s},yn=(r,e)=>{const t=Array.isArray(r),s=Array.isArray(e);if(t!==s)return!1;if(t&&s){const o=r,u=e;if(o.length!==u.length)return!1;for(let l=0;l<o.length;l++)if(!yn(o[l],u[l]))return!1;return!0}if(r==null||e==null||typeof r!="object"||typeof e!="object")return r===e;if("equals"in r)return r.equals(e);const n=Object.keys(r),a=Object.keys(e);if(n.length!==a.length)return!1;for(const o of n){const u=r[o],l=e[o];if(typeof u=="object"&&typeof l=="object"){if(!yn(u,l))return!1}else if(u!==l)return!1}return!0},no=(r,e)=>{if(typeof r!="object"||r==null)return r===e;const t=Object.keys(r),s=Object.keys(e);if(s.length>t.length)return!1;for(const n of s){const a=r[n],o=e[n];if(typeof a=="object"&&typeof o=="object"){if(!no(a,o))return!1}else if(a!==o)return!1}return!0},mn=(r,...e)=>{if(e.length===0)return r;const t=e.shift();if(Gt(r)&&Gt(t))for(const s in t)try{Gt(t[s])?(s in r||Object.assign(r,{[s]:{}}),mn(r[s],t[s])):Object.assign(r,{[s]:t[s]})}catch(n){throw n instanceof TypeError?new TypeError(`.${s}: ${n.message}`):n}return mn(r,...e)},Nc=(r,e,t)=>{const s=(n,a,o)=>{for(const u in a){const l=a[u];if(o!=null&&o.shape[u]){const h=o.shape[u].safeParse(l);h.success&&(n[u]=h.data)}else typeof l=="object"&&!Array.isArray(l)&&l!==null&&o&&o.shape&&o.shape[u]&&(n[u]||(n[u]={}),s(n[u],l,o.shape[u]))}return n};return s({...r},e,t)},io=Object.freeze(Object.defineProperty({__proto__:null,copy:Oc,deleteD:Sc,difference:zc,element:ec,equal:yn,get:Wn,has:tc,override:mn,overrideValidItems:Nc,partialEqual:no,pathsMatch:rc,remove:Qu,set:Xu,transformPath:Ka},Symbol.toStringTag,{value:"Module"}));i.z.object({key:i.z.string(),value:i.z.string()});i.z.record(i.z.union([i.z.number(),i.z.string(),i.z.symbol()]),i.z.unknown());const ao=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser",Ec=ao(),oo=["macOS","Windows","Linux"],Ic=["macos","windows","linux"],xc={macos:"macOS",windows:"Windows",linux:"Linux"},Ac=i.z.enum(oo).or(i.z.enum(Ic).transform(r=>xc[r])),kc=()=>{if(typeof window>"u")return;const r=window.navigator.userAgent.toLowerCase();if(r.includes("mac"))return"macOS";if(r.includes("win"))return"Windows";if(r.includes("linux"))return"Linux"};let Bs;const Cc=(r={})=>{const{force:e,default:t}=r;return e??Bs??(Bs=kc(),Bs??t)},lo=Object.freeze(Object.defineProperty({__proto__:null,OPERATING_SYSTEMS:oo,RUNTIME:Ec,detect:ao,getOS:Cc,osZ:Ac},Symbol.toStringTag,{value:"Module"})),Rc=r=>Array.isArray(r)?r:[r],$c=r=>Array.isArray(r)?r:r===null?[]:[r];var Mc=Object.defineProperty,jc=(r,e,t)=>e in r?Mc(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,At=(r,e,t)=>jc(r,typeof e!="symbol"?e+"":e,t);const Bc=(...r)=>r.map(uo).join(""),uo=r=>(r.endsWith("/")||(r+="/"),r.startsWith("/")&&(r=r.slice(1)),r),Pc=r=>r.endsWith("/")?r.slice(0,-1):r,$i=class wn{constructor({host:e,port:t,protocol:s="",pathPrefix:n=""}){At(this,"protocol"),At(this,"host"),At(this,"port"),At(this,"path"),this.protocol=s,this.host=e,this.port=t,this.path=uo(n)}replace(e){return new wn({host:e.host??this.host,port:e.port??this.port,protocol:e.protocol??this.protocol,pathPrefix:e.pathPrefix??this.path})}child(e){return new wn({...this,pathPrefix:Bc(this.path,e)})}toString(){return Pc(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}};At($i,"UNKNOWN",new $i({host:"unknown",port:0}));var Dc=Object.defineProperty,Uc=(r,e,t)=>e in r?Dc(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,as=(r,e,t)=>Uc(r,typeof e!="symbol"?e+"":e,t);let Lc=class{constructor(e){as(this,"sender"),as(this,"handlers"),this.sender=e,this.handlers=new Map}handle({data:e}){var t;const s=(t=this.handlers.get(e.type))==null?void 0:t.handler;s==null?console.warn(`No handler for ${e.type}`):s(e.payload)}route(e){const t=_c(e,this.sender),s=new qc(t);return this.handlers.set(e,s),s}};const _c=(r,e)=>(t,s)=>e({type:r,payload:t},s);let qc=class{constructor(e){as(this,"_send"),as(this,"handler"),this._send=e,this.handler=null}send(e,t=[]){this._send(e,t)}handle(e){this.handler=e}};var Yc=Object.defineProperty,Fc=(r,e,t)=>e in r?Yc(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Cr=(r,e,t)=>Fc(r,typeof e!="symbol"?e+"":e,t);i.z.object({interval:Z.z.optional(),maxRetries:i.z.number().optional(),scale:i.z.number().optional()});const Je=class extends Number{};Cr(Je,"Absolute",255),Cr(Je,"Default",1),Cr(Je,"z",i.z.union([i.z.instanceof(Je),i.z.number().int().min(0).max(255).transform(r=>new Je(r)),i.z.instanceof(Number).transform(r=>new Je(r))]));let co=Je;const ho=i.z.object({name:i.z.string(),key:i.z.string()}),Vc=r=>i.z.object({subject:ho,resource:r,authority:co.z}),Gc=(...r)=>e=>e.filter(t=>{let s=!1;return t.to!=null&&(s=r.includes(t.to.resource)),t.from!=null&&!s&&(s=r.includes(t.from.resource)),s}),Wc=Object.freeze(Object.defineProperty({__proto__:null,Authority:co,filterTransfersByChannelKey:Gc,stateZ:Vc,subjectZ:ho},Symbol.toStringTag,{value:"Module"})),fo=class kt extends Error{constructor(){super(kt.MESSAGE)}matches(e){return typeof e=="string"?e.includes(kt.MESSAGE):e instanceof kt||e.message.includes(kt.MESSAGE)}};Cr(fo,"MESSAGE","canceled");let Zc=fo;new Zc;const Jc=r=>r?-1:1,bn=i.z.string().regex(/^\d+\.\d+\.\d+$/),or=(r,e,t={})=>{t.checkMajor??(t.checkMajor=!0),t.checkMinor??(t.checkMinor=!0),t.checkPatch??(t.checkPatch=!0);const s=bn.parse(r),n=bn.parse(e),[a,o,u]=s.split(".").map(Number),[l,h,f]=n.split(".").map(Number);if(t.checkMajor){if(a<l)return Ir;if(a>l)return xr}if(t.checkMinor){if(o<h)return Ir;if(o>h)return xr}if(t.checkPatch){if(u<f)return Ir;if(u>f)return xr}return pt},Kc=(r,e,t={})=>Ja(or(r,e,t)),po=(r,e,t={})=>Za(or(r,e,t)),Hc=(r,e,t={})=>Wa(or(r,e,t)),Xc=({name:r,migrate:e})=>t=>{try{const s=e(t);return console.log(`${r} migrated: ${t.version} -> ${s.version}`),s}catch(s){throw console.log(`${r} failed to migrate from ${t.version}`),console.error(s),s}},Qc=({name:r,migrations:e,targetSchema:t,defaultVersion:s,def:n})=>{const a=Object.keys(e).sort(or).pop();if(a==null)return h=>{if(h.version??(h.version=s),h.version!==n.version)return console.log(`${r} version ${h.version} is newer than latest version of ${n.version}.
|
|
14
|
-
Returning default instead.
|
|
15
|
-
`),n;try{return t!=null?t.parse(h):h}catch(f){return console.log(`${r} failed to parse default. Exiting with default`),console.error(f),n}};const o=Object.keys(e).length;let u=!1;const l=h=>{try{if(o===0||po(h.version,a))return console.log(u?`${r} ${h.version} now up to date`:`${r} version ${h.version} is up to date with target version ${n.version}`),h;const f=h.version,d=e[f],I=d(h);return u=!0,l(I)}catch(f){return console.log(`${r} failed to migrate from ${h.version} to ${a}`),console.error(f),n}};return h=>{try{if(h.version==null)if(s!=null)console.log(`${r} version is null. Setting version to default of ${s}`),h.version=s;else return console.log(`${r} version is null and no default version set. Exiting with default`),n;return l(h)}catch(f){return console.log(`${r} failed to parse final result. Exiting with default`),console.error(f),n}}},eh=Object.freeze(Object.defineProperty({__proto__:null,compareSemVer:or,createMigration:Xc,migrator:Qc,semVerNewer:po,semVerOlder:Hc,semVerZ:bn,versionsEqual:Kc},Symbol.toStringTag,{value:"Module"})),th=r=>{if(r===void 0||typeof r=="string"||typeof r=="number")return r;if(r.toString===void 0)throw new Error("invalid renderer");return r.toString()},rh=r=>Array.isArray(r)?[...r]:typeof r=="object"&&r!==null?{...r}:r,Zn=r=>typeof r=="function",Jn=(r,e)=>Zn(r)?r(e):r,lr=r=>go(r)?r():r,go=r=>typeof r=="function",yo=({initial:r,value:e,onChange:t})=>{const[s,n]=Gn.useState(lr(e??r));return e!=null&&t!=null?[e,t]:[s,n]},mo=({initial:r,value:e,onChange:t})=>{const[s,n]=Gn.useState(lr(e??r));return e!=null&&t!=null?[e,t]:[s,n]},sh=(r,e)=>{const[t,s]=Gn.useState(()=>{const n=localStorage.getItem(e);return n==null?lr(r):JSON.parse(n)});return[t,n=>{s(n),localStorage.setItem(e,JSON.stringify(n))}]},nh=Object.freeze(Object.defineProperty({__proto__:null,executeInitialSetter:lr,executeSetter:Jn,isInitialSetter:go,isSetter:Zn,usePassthrough:yo,usePersisted:sh,usePurePassthrough:mo},Symbol.toStringTag,{value:"Module"})),wo=["h1","h2","h3","h4","h5","p","small"],ih=i.z.enum(wo),ah={h1:"h2",h2:"h3",h3:"h4",h4:"h5",h5:"p",p:"small",small:"small"},oh=r=>ah[r],lh={h1:"h1",h2:"h1",h3:"h2",h4:"h3",h5:"h4",p:"h5",small:"p"},uh=r=>lh[r],ch=["normal","bold","bolder","lighter"],hh=i.z.union([i.z.number(),i.z.enum(ch)]),qe=i.z.object({size:i.z.number(),weight:i.z.union([i.z.number(),i.z.string()]),lineHeight:i.z.number(),textTransform:i.z.string().optional()}),bo={small:"small",medium:"p",large:"h5",huge:"h2"},dh={h1:"huge",h2:"huge",h3:"huge",h4:"large",h5:"small",p:"medium",small:"small"};let Mi=null;const fh=()=>(Mi??(Mi=document.createElement("canvas")),Mi),ph=(r,e,t)=>{if(lo.RUNTIME==="node")return{width:0,height:0};t??(t=fh().getContext("2d")),t.font=e;const s=t.measureText(r);return{width:Math.trunc(Math.abs(s.actualBoundingBoxLeft)+Math.abs(s.actualBoundingBoxRight)),height:Math.trunc(Math.abs(s.actualBoundingBoxAscent)+Math.abs(s.actualBoundingBoxDescent))}},gh=i.z.object({l0:p.Color.z,l1:p.Color.z,l2:p.Color.z,l3:p.Color.z,l4:p.Color.z,l5:p.Color.z,l6:p.Color.z,l7:p.Color.z,l8:p.Color.z,l9:p.Color.z,l10:p.Color.z}),Oe=(r,e)=>[r[0],r[1],e,r[3]],yh=i.z.object({m2:p.Color.z,m1:p.Color.z,z:p.Color.z,p1:p.Color.z,p2:p.Color.z}),wr=yh.or(p.Color.z.transform(r=>{const e=r.hsla;return{m2:new p.Color(p.fromHSLA(Oe(e,40))),m1:new p.Color(p.fromHSLA(Oe(e,45))),z:r,p1:new p.Color(p.fromHSLA(Oe(e,55))),p2:new p.Color(p.fromHSLA(Oe(e,65)))}})),vo=i.z.object({name:i.z.string(),key:i.z.string(),colors:i.z.object({border:p.Color.z,primary:wr,gray:gh,error:wr,secondary:wr,warning:wr,palettes:i.z.record(p.paletteZ),visualization:i.z.object({palettes:i.z.record(i.z.array(p.Color.z))}).optional().default({palettes:{}}),white:p.Color.z,black:p.Color.z,text:p.Color.z,textInverted:p.Color.z,textOnPrimary:p.Color.z.optional().default(p.ZERO),logo:i.z.string()}),sizes:i.z.object({base:i.z.number(),border:i.z.object({radius:i.z.number(),width:i.z.number()}),schematic:i.z.object({elementStrokeWidth:i.z.number()})}),typography:i.z.object({family:i.z.string(),codeFamily:i.z.string(),h1:qe,h2:qe,h3:qe,h4:qe,h5:qe,p:qe,small:qe})}).transform(r=>((r.colors.textOnPrimary==null||r.colors.textOnPrimary.isZero)&&(r.colors.textOnPrimary=r.colors.primary.z.pickByContrast(r.colors.text,r.colors.textInverted)),r)),mh="'Inter Variable', sans-serif",wh="'Geist Mono', monospace",bh=6,bt=[357,91,55,1],vt=[58,100,50,1],vh=["#FDFDFD","#FAFAFA","#F3F3F3","#EAEAEA","#D8D8D8","#ADADAD","#878787","#616161","#404040","#1C1C1C","#050505"],Tt=Object.fromEntries(vh.map((r,e)=>[`l${e}`,r])),vn={key:"synnaxBase",name:"Synnax Base",colors:{primary:{m2:"#041B3D",m1:"#164FA0",z:"#3774D0",p1:"#5E94EE",p2:"#8AB8FF"},secondary:{m2:"#2D8F4E",m1:"#38B261",z:"#50C878",p1:"#73D393",p2:"#96DEAE"},gray:Tt,border:Tt.l3,error:{m2:p.fromHSLA(Oe(bt,30)),m1:p.fromHSLA(Oe(bt,40)),z:p.fromHSLA(bt),p1:p.fromHSLA(Oe(bt,65)),p2:p.fromHSLA(Oe(bt,77))},warning:{m2:p.fromHSLA(Oe(vt,30)),m1:p.fromHSLA(Oe(vt,40)),z:p.fromHSLA(vt),p1:p.fromHSLA(Oe(vt,65)),p2:p.fromHSLA(Oe(vt,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:Tt.l9,textInverted:Tt.l0,textOnPrimary:Tt.l0},sizes:{base:bh,border:{radius:3,width:1},schematic:{elementStrokeWidth:2}},typography:{family:mh,codeFamily:wh,h1:{size:7,weight:"500",lineHeight:7*1.5},h2:{size:4.5,weight:"medium",lineHeight:4.5*1.5},h3:{size:3.5,weight:"medium",lineHeight:3.5*1.5},h4:{size:2.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:1.9166666*1.5}}},To=Object.freeze({...vn,key:"synnaxLight",name:"Synnax Light"}),Th=["#020202","#0A0A0A","#131313","#1E1E1E","#2E2E2E","#444444","#646464","#8A8A8A","#AFAFAF","#D5D5D5","#FDFDFD"],Ot=Object.fromEntries(Th.map((r,e)=>[`l${e}`,r])),Oo=Object.freeze({...vn,key:"synnaxDark",name:"Synnax Dark",colors:{...vn.colors,gray:Ot,logo:"var(--pluto-text-color)",border:Ot.l3,text:Ot.l9,textInverted:Ot.l0,textOnPrimary:Ot.l10}}),Oh={synnaxDark:Oo,synnaxLight:To},Sh=["small","medium","large","huge"],zh=i.z.enum(Sh),Nh=r=>zh.safeParse(r).success,Eh=(r,{level:e,weight:t,code:s})=>{const{typography:n,sizes:{base:a}}=r,o=n[Nh(e)?bo[e]:e].size,u=(a*o).toFixed(1),l=s?n.codeFamily:n.family,[h,f]=l.split(", ");return t!=null?` ${t} ${u}px ${h}, ${f}`:` ${u}px ${l}`};var Ih=Object.defineProperty,xh=(r,e,t)=>e in r?Ih(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,c=(r,e,t)=>xh(r,typeof e!="symbol"?e+"":e,t);const O=r=>Array.isArray(r)?r:[r];var Ah=Object.defineProperty,kh=(r,e,t)=>e in r?Ah(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,B=(r,e,t)=>kh(r,typeof e!="symbol"?e+"":e,t);const Ch=r=>{const e=r.replace(/_[a-z]/g,t=>t[1].toUpperCase());return e.length>1&&e[0]===e[0].toUpperCase()&&e[1]===e[1].toUpperCase()||e.length===0?e:e[0].toLowerCase()+e.slice(1)},So=r=>{const e=(t,s=Tn)=>{if(typeof t=="string")return r(t);if(Array.isArray(t))return t.map(o=>e(o,s));if(!Ps(t))return t;s=Mh(s);const n={},a=t;return Object.keys(a).forEach(o=>{let u=a[o];const l=r(o);s.recursive&&(Ps(u)?Bi(u,s.keepTypesOnRecursion)||(u=e(u,s)):s.recursiveInArray&&ji(u)&&(u=[...u].map(h=>{let f=h;return Ps(h)?Bi(f,s.keepTypesOnRecursion)||(f=e(h,s)):ji(h)&&(f=e({key:h},s).key),f}))),n[l]=u}),n};return e},zo=So(Ch),Rh=r=>r.replace(/([a-z0-9])([A-Z])/g,(e,t,s)=>`${t}_${s.toLowerCase()}`),$h=So(Rh),Tn={recursive:!0,recursiveInArray:!0,keepTypesOnRecursion:[Number,String,Uint8Array]},Mh=(r=Tn)=>(r.recursive==null?r=Tn:r.recursiveInArray??(r.recursiveInArray=!1),r),ji=r=>r!=null&&Array.isArray(r),Ps=r=>r!=null&&typeof r=="object"&&!Array.isArray(r),Bi=(r,e)=>(e||[]).some(t=>r instanceof t),No=r=>r!=null&&typeof r=="object"&&!Array.isArray(r);var jh=Object.defineProperty,Bh=(r,e,t)=>e in r?jh(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Zt=(r,e,t)=>Bh(r,typeof e!="symbol"?e+"":e,t);let Ph=class{constructor(){Zt(this,"contentType","application/json"),Zt(this,"decoder"),Zt(this,"encoder"),this.decoder=new TextDecoder,this.encoder=new TextEncoder}encode(r){return this.encoder.encode(this.encodeString(r)).buffer}decode(r,e){return this.decodeString(this.decoder.decode(r),e)}decodeString(r,e){const t=JSON.parse(r),s=zo(t);return e!=null?e.parse(s):s}encodeString(r){const e=$h(r);return JSON.stringify(e,(t,s)=>ArrayBuffer.isView(s)?Array.from(s):No(s)&&"encode_value"in s?typeof s.value=="bigint"?s.value.toString():s.value:typeof s=="bigint"?s.toString():s)}static registerCustomType(){}},Dh=class{constructor(){Zt(this,"contentType","text/csv")}encode(r){const e=this.encodeString(r);return new TextEncoder().encode(e).buffer}decode(r,e){const t=new TextDecoder().decode(r);return this.decodeString(t,e)}encodeString(r){if(!Array.isArray(r)||r.length===0||!No(r[0]))throw new Error("Payload must be an array of objects");const e=Object.keys(r[0]),t=[e.join(",")];return r.forEach(s=>{const n=e.map(a=>JSON.stringify(s[a]??""));t.push(n.join(","))}),t.join(`
|
|
16
|
-
`)}decodeString(r,e){const[t,...s]=r.trim().split(`
|
|
17
|
-
`).map(o=>o.trim());if(t.length===0)return e!=null?e.parse({}):{};const n=t.split(",").map(o=>o.trim()),a={};return n.forEach(o=>{a[o]=[]}),s.forEach(o=>{const u=o.split(",").map(l=>l.trim());n.forEach((l,h)=>{const f=this.parseValue(u[h]);f!=null&&a[l].push(f)})}),e!=null?e.parse(a):a}parseValue(r){if(r==null||r.length===0)return null;const e=Number(r);return isNaN(e)?r.startsWith('"')&&r.endsWith('"')?r.slice(1,-1):r:e}static registerCustomType(){}},Uh=class{constructor(){Zt(this,"contentType","text/plain")}encode(r){return new TextEncoder().encode(r).buffer}decode(r,e){const t=new TextDecoder().decode(r);return e!=null?e.parse(t):t}};const Rr=new Ph;new Dh;new Uh;const Lh=r=>r!=null&&typeof r=="object"&&"toString"in r,_h=(r,e=!1)=>{const t=Lh(r)?"stringer":typeof r;let s;switch(t){case"string":s=(n,a)=>n.localeCompare(a);break;case"stringer":s=(n,a)=>n.toString().localeCompare(a.toString());break;case"number":s=(n,a)=>Number(n)-Number(a);break;case"bigint":s=(n,a)=>BigInt(n)-BigInt(a)>0n?1:-1;break;case"boolean":s=(n,a)=>Number(n)-Number(a);break;case"undefined":s=()=>0;break;default:return console.warn(`sortFunc: unknown type ${t}`),()=>-1}return e?qh(s):s},qh=r=>(e,t)=>r(t,e),bs=i.z.tuple([i.z.number(),i.z.number()]);i.z.tuple([i.z.bigint(),i.z.bigint()]);const Eo=i.z.object({width:i.z.number(),height:i.z.number()}),Yh=i.z.object({signedWidth:i.z.number(),signedHeight:i.z.number()}),Fh=["width","height"];i.z.enum(Fh);const Vh=["start","center","end"],Gh=["signedWidth","signedHeight"];i.z.enum(Gh);const os=i.z.object({x:i.z.number(),y:i.z.number()}),Wh=i.z.object({clientX:i.z.number(),clientY:i.z.number()}),Zh=["x","y"],Io=i.z.enum(Zh),xo=["top","right","bottom","left"];i.z.enum(xo);const Jh=["left","right"],Ao=i.z.enum(Jh),Kh=["top","bottom"],ko=i.z.enum(Kh),Co=["center"],Pi=i.z.enum(Co),Hh=[...xo,...Co],Ro=i.z.enum(Hh);i.z.enum(Vh);const Xh=["first","last"];i.z.enum(Xh);const Qh=i.z.object({lower:i.z.number(),upper:i.z.number()}),ed=i.z.object({lower:i.z.bigint(),upper:i.z.bigint()});i.z.union([Qh,bs]);i.z.union([ed,bs]);i.z.union([Io,Ro]);i.z.union([Io,Ro,i.z.instanceof(String)]);const td=r=>typeof r=="bigint"||r instanceof BigInt,tt=(r,e)=>td(r)?r.valueOf()*BigInt(e.valueOf()):r.valueOf()*Number(e.valueOf()),Qe=(r,e)=>{const t={};if(typeof r=="number"||typeof r=="bigint")e!=null?(t.lower=r,t.upper=e):(t.lower=typeof r=="bigint"?0n:0,t.upper=r);else if(Array.isArray(r)){if(r.length!==2)throw new Error("bounds: expected array of length 2");[t.lower,t.upper]=r}else return Di(r);return Di(t)},Di=r=>r.lower>r.upper?{lower:r.upper,upper:r.lower}:r,Ui=(r,e)=>{const t=Qe(r);return e<t.lower?t.lower:e>=t.upper?t.upper-(typeof t.upper=="number"?1:1n):e};i.z.object({x:Ao.or(Pi),y:ko.or(Pi)});const rd=i.z.object({x:Ao,y:ko}),sd=Object.freeze({x:"left",y:"top"}),nd=(r,e)=>r.x===e.x&&r.y===e.y,Li=i.z.union([i.z.number(),os,bs,Eo,Yh,Wh]),id=(r,e)=>{if(typeof r=="string"){if(e===void 0)throw new Error("The y coordinate must be given.");return r==="x"?{x:e,y:0}:{x:0,y:e}}return typeof r=="number"?{x:r,y:e??r}:Array.isArray(r)?{x:r[0],y:r[1]}:"signedWidth"in r?{x:r.signedWidth,y:r.signedHeight}:"clientX"in r?{x:r.clientX,y:r.clientY}:"width"in r?{x:r.width,y:r.height}:{x:r.x,y:r.y}},_i=Object.freeze({x:0,y:0}),br=i.z.union([i.z.number(),i.z.string()]);i.z.object({top:br,left:br,width:br,height:br});i.z.object({left:i.z.number(),top:i.z.number(),right:i.z.number(),bottom:i.z.number()});i.z.object({one:os,two:os,root:rd});const Kn=(r,e,t=0,s=0,n)=>{const a={one:{..._i},two:{..._i},root:n??sd};if(typeof r=="number"){if(typeof e!="number")throw new Error("Box constructor called with invalid arguments");return a.one={x:r,y:e},a.two={x:a.one.x+t,y:a.one.y+s},a}return"one"in r&&"two"in r&&"root"in r?{...r,root:n??r.root}:("getBoundingClientRect"in r&&(r=r.getBoundingClientRect()),"left"in r?(a.one={x:r.left,y:r.top},a.two={x:r.right,y:r.bottom},a):(a.one=r,e==null?a.two={x:a.one.x+t,y:a.one.y+s}:typeof e=="number"?a.two={x:a.one.x+e,y:a.one.y+t}:"width"in e?a.two={x:a.one.x+e.width,y:a.one.y+e.height}:"signedWidth"in e?a.two={x:a.one.x+e.signedWidth,y:a.one.y+e.signedHeight}:a.two=e,a))},Ds=r=>{const e=Kn(r);return{lower:e.one.x,upper:e.two.x}},Us=r=>{const e=Kn(r);return{lower:e.one.y,upper:e.two.y}},ad=r=>typeof r!="object"||r==null?!1:"one"in r&&"two"in r&&"root"in r,od=i.z.object({signedWidth:i.z.number(),signedHeight:i.z.number()});i.z.union([Eo,od,os,bs]);var ld=Object.defineProperty,ud=(r,e,t)=>e in r?ld(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,je=(r,e,t)=>ud(r,typeof e!="symbol"?e+"":e,t);const cd=(r,e,t)=>e!==void 0&&r<e?e:t!==void 0&&r>t?t:r;i.z.object({offset:Li,scale:Li});i.z.object({offset:i.z.number(),scale:i.z.number()});const hd=r=>(e,t,s,n)=>t==="dimension"?[e,s]:[e,n?s-r:s+r],dd=r=>(e,t,s,n)=>[e,n?s/r:s*r],fd=r=>(e,t,s)=>{if(e===null)return[r,s];const{lower:n,upper:a}=e,{lower:o,upper:u}=r,l=a-n,h=u-o;if(t==="dimension")return[r,s*(h/l)];const f=(s-n)*(h/l)+o;return[r,f]},pd=r=>(e,t,s)=>[r,s],gd=()=>(r,e,t)=>{if(r===null)throw new Error("cannot invert without bounds");if(e==="dimension")return[r,t];const{lower:s,upper:n}=r;return[r,n-(t-s)]},yd=r=>(e,t,s)=>{const{lower:n,upper:a}=r;return s=cd(s,n,a),[e,s]},On=class Ct{constructor(){je(this,"ops",[]),je(this,"currBounds",null),je(this,"currType",null),je(this,"reversed",!1),this.ops=[]}static translate(e){return new Ct().translate(e)}static magnify(e){return new Ct().magnify(e)}static scale(e,t){return new Ct().scale(e,t)}translate(e){const t=this.new(),s=hd(e);return s.type="translate",t.ops.push(s),t}magnify(e){const t=this.new(),s=dd(e);return s.type="magnify",t.ops.push(s),t}scale(e,t){const s=Qe(e,t),n=this.new(),a=fd(s);return a.type="scale",n.ops.push(a),n}clamp(e,t){const s=Qe(e,t),n=this.new(),a=yd(s);return a.type="clamp",n.ops.push(a),n}reBound(e,t){const s=Qe(e,t),n=this.new(),a=pd(s);return a.type="re-bound",n.ops.push(a),n}invert(){const e=gd();e.type="invert";const t=this.new();return t.ops.push(e),t}pos(e){return this.exec("position",e)}dim(e){return this.exec("dimension",e)}new(){const e=new Ct;return e.ops=this.ops.slice(),e.reversed=this.reversed,e}exec(e,t){return this.currBounds=null,this.ops.reduce(([s,n],a)=>a(s,e,n,this.reversed),[null,t])[1]}reverse(){const e=this.new();e.ops.reverse();const t=[];return e.ops.forEach((s,n)=>{if(s.type==="scale"||t.some(([o,u])=>n>=o&&n<=u))return;const a=e.ops.findIndex((o,u)=>o.type==="scale"&&u>n);a!==-1&&t.push([n,a])}),t.forEach(([s,n])=>{const a=e.ops.slice(s,n);a.unshift(e.ops[n]),e.ops.splice(s,n-s+1,...a)}),e.reversed=!e.reversed,e}get transform(){return{scale:this.dim(1),offset:this.pos(0)}}};je(On,"IDENTITY",new On);let qi=On;const Yi=class $e{constructor(e=new qi,t=new qi,s=null){je(this,"x"),je(this,"y"),je(this,"currRoot"),this.x=e,this.y=t,this.currRoot=s}static translate(e,t){return new $e().translate(e,t)}static translateX(e){return new $e().translateX(e)}static translateY(e){return new $e().translateY(e)}static clamp(e){return new $e().clamp(e)}static magnify(e){return new $e().magnify(e)}static scale(e){return new $e().scale(e)}static reBound(e){return new $e().reBound(e)}translate(e,t){const s=id(e,t),n=this.copy();return n.x=this.x.translate(s.x),n.y=this.y.translate(s.y),n}translateX(e){const t=this.copy();return t.x=this.x.translate(e),t}translateY(e){const t=this.copy();return t.y=this.y.translate(e),t}magnify(e){const t=this.copy();return t.x=this.x.magnify(e.x),t.y=this.y.magnify(e.y),t}scale(e){const t=this.copy();if(ad(e)){const s=this.currRoot;return t.currRoot=e.root,s!=null&&!nd(s,e.root)&&(s.x!==e.root.x&&(t.x=t.x.invert()),s.y!==e.root.y&&(t.y=t.y.invert())),t.x=t.x.scale(Ds(e)),t.y=t.y.scale(Us(e)),t}return t.x=t.x.scale(e.width),t.y=t.y.scale(e.height),t}reBound(e){const t=this.copy();return t.x=this.x.reBound(Ds(e)),t.y=this.y.reBound(Us(e)),t}clamp(e){const t=this.copy();return t.x=this.x.clamp(Ds(e)),t.y=this.y.clamp(Us(e)),t}copy(){const e=new $e;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 Kn(this.pos(e.one),this.pos(e.two),0,0,this.currRoot??e.root)}get transform(){return{scale:this.dim({x:1,y:1}),offset:this.pos({x:0,y:0})}}};je(Yi,"IDENTITY",new Yi);const md=i.z.bigint().or(i.z.string().transform(BigInt));var wd=Object.defineProperty,bd=(r,e,t)=>e in r?wd(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,v=(r,e,t)=>bd(r,typeof e!="symbol"?e+"":e,t);let vd=(r,e=21)=>(t=e)=>{let s="",n=t|0;for(;n--;)s+=r[Math.random()*r.length|0];return s};const Td="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",Od=vd(Td,11),Sd=i.z.enum(["static","dynamic"]),$o=(r,e)=>{const t=new J(e);if(![W.DAY,W.HOUR,W.MINUTE,W.SECOND,W.MILLISECOND,W.MICROSECOND,W.NANOSECOND].some(n=>n.equals(t)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const s=r.valueOf()%t.valueOf();return r instanceof J?new J(s):new W(s)},q=class N{constructor(e,t="UTC"){if(v(this,"value"),v(this,"encodeValue",!0),e==null)this.value=N.now().valueOf();else if(e instanceof Date)this.value=BigInt(e.getTime())*N.MILLISECOND.valueOf();else if(typeof e=="string")this.value=N.parseDateTimeString(e,t).valueOf();else if(Array.isArray(e))this.value=N.parseDate(e);else{let s=BigInt(0);e instanceof Number&&(e=e.valueOf()),t==="local"&&(s=N.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=N.MAX:e=N.MIN)),this.value=BigInt(e.valueOf())+s}}static parseDate([e=1970,t=1,s=1]){const n=new Date(e,t-1,s,0,0,0,0);return new N(BigInt(n.getTime())*N.MILLISECOND.valueOf()).truncate(N.DAY).valueOf()}encode(){return this.value.toString()}valueOf(){return this.value}static parseTimeString(e,t="UTC"){const[s,n,a]=e.split(":");let o="00",u="00";a!=null&&([o,u]=a.split("."));let l=N.hours(parseInt(s??"00")).add(N.minutes(parseInt(n??"00"))).add(N.seconds(parseInt(o??"00"))).add(N.milliseconds(parseInt(u??"00")));return t==="local"&&(l=l.add(N.utcOffset)),l.valueOf()}static parseDateTimeString(e,t="UTC"){if(!e.includes("/")&&!e.includes("-"))return N.parseTimeString(e,t);const s=new Date(e);return e.includes(":")||s.setUTCHours(0,0,0,0),new N(BigInt(s.getTime())*N.MILLISECOND.valueOf(),t).valueOf()}fString(e="ISO",t="UTC"){switch(e){case"ISODate":return this.toISOString(t).slice(0,10);case"ISOTime":return this.toISOString(t).slice(11,23);case"time":return this.timeString(!1,t);case"preciseTime":return this.timeString(!0,t);case"date":return this.dateString();case"preciseDate":return`${this.dateString()} ${this.timeString(!0,t)}`;case"dateTime":return`${this.dateString()} ${this.timeString(!1,t)}`;default:return this.toISOString(t)}}toISOString(e="UTC"){return e==="UTC"?this.date().toISOString():this.sub(N.utcOffset).date().toISOString()}timeString(e=!1,t="UTC"){const s=this.toISOString(t);return e?s.slice(11,23):s.slice(11,19)}dateString(){const e=this.date(),t=e.toLocaleString("default",{month:"short"}),s=e.toLocaleString("default",{day:"numeric"});return`${t} ${s}`}static get utcOffset(){return new W(BigInt(new Date().getTimezoneOffset())*N.MINUTE.valueOf())}static since(e){return new N().span(e)}date(){return new Date(this.milliseconds)}equals(e){return this.valueOf()===new N(e).valueOf()}span(e){return this.range(e).span}range(e){return new Hn(this,e).makeValid()}spanRange(e){return this.range(this.add(e)).makeValid()}get isZero(){return this.valueOf()===BigInt(0)}after(e){return this.valueOf()>new N(e).valueOf()}afterEq(e){return this.valueOf()>=new N(e).valueOf()}before(e){return this.valueOf()<new N(e).valueOf()}beforeEq(e){return this.valueOf()<=new N(e).valueOf()}add(e){return new N(this.valueOf()+BigInt(e.valueOf()))}sub(e){return new N(this.valueOf()-BigInt(e.valueOf()))}get hours(){return Number(this.valueOf())/Number(W.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(W.MINUTE.valueOf())}get days(){return Number(this.valueOf())/Number(W.DAY.valueOf())}get seconds(){return Number(this.valueOf())/Number(W.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(N.MILLISECOND.valueOf())}get year(){return this.date().getFullYear()}setYear(e){const t=this.date();return t.setFullYear(e),new N(t)}get month(){return this.date().getMonth()}setMonth(e){const t=this.date();return t.setMonth(e),new N(t)}get day(){return this.date().getDate()}setDay(e){const t=this.date();return t.setDate(e),new N(t)}get hour(){return this.date().getHours()}setHour(e){const t=this.date();return t.setHours(e),new N(t)}get minute(){return this.date().getMinutes()}setMinute(e){const t=this.date();return t.setMinutes(e),new N(t)}get second(){return this.date().getSeconds()}setSecond(e){const t=this.date();return t.setSeconds(e),new N(t)}get millisecond(){return this.date().getMilliseconds()}setMillisecond(e){const t=this.date();return t.setMilliseconds(e),new N(t)}toString(){return this.date().toISOString()}remainder(e){return $o(this,e)}get isToday(){return this.truncate(W.DAY).equals(N.now().truncate(W.DAY))}truncate(e){return this.sub(this.remainder(e))}static now(){return new N(new Date)}static max(...e){let t=N.MIN;for(const s of e){const n=new N(s);n.after(t)&&(t=n)}return t}static min(...e){let t=N.MAX;for(const s of e){const n=new N(s);n.before(t)&&(t=n)}return t}static nanoseconds(e){return new N(e)}static microseconds(e){return N.nanoseconds(e*1e3)}static milliseconds(e){return N.microseconds(e*1e3)}static seconds(e){return N.milliseconds(e*1e3)}static minutes(e){return N.seconds(e*60)}static hours(e){return N.minutes(e*60)}static days(e){return N.hours(e*24)}};v(q,"NANOSECOND",q.nanoseconds(1)),v(q,"MICROSECOND",q.microseconds(1)),v(q,"MILLISECOND",q.milliseconds(1)),v(q,"SECOND",q.seconds(1)),v(q,"MINUTE",q.minutes(1)),v(q,"HOUR",q.hours(1)),v(q,"DAY",q.days(1)),v(q,"MAX",new q((1n<<63n)-1n)),v(q,"MIN",new q(0)),v(q,"ZERO",new q(0)),v(q,"z",i.z.union([i.z.object({value:i.z.bigint()}).transform(r=>new q(r.value)),i.z.string().transform(r=>new q(BigInt(r))),i.z.instanceof(Number).transform(r=>new q(r)),i.z.number().transform(r=>new q(r)),i.z.instanceof(q)]));let J=q;const Y=class k{constructor(e){v(this,"value"),v(this,"encodeValue",!0),typeof e=="number"&&(e=Math.trunc(e.valueOf())),this.value=BigInt(e.valueOf())}static fromSeconds(e){return e instanceof k?e:e instanceof Fi?e.period:e instanceof J?new k(e):["number","bigint"].includes(typeof e)?k.seconds(e):new k(e)}static fromMilliseconds(e){return e instanceof k?e:e instanceof Fi?e.period:e instanceof J?new k(e):["number","bigint"].includes(typeof e)?k.milliseconds(e):new k(e)}encode(){return this.value.toString()}valueOf(){return this.value}lessThan(e){return this.valueOf()<new k(e).valueOf()}greaterThan(e){return this.valueOf()>new k(e).valueOf()}lessThanOrEqual(e){return this.valueOf()<=new k(e).valueOf()}greaterThanOrEqual(e){return this.valueOf()>=new k(e).valueOf()}remainder(e){return $o(this,e)}truncate(e){return new k(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(){const e=this.truncate(k.DAY),t=this.truncate(k.HOUR),s=this.truncate(k.MINUTE),n=this.truncate(k.SECOND),a=this.truncate(k.MILLISECOND),o=this.truncate(k.MICROSECOND),u=this.truncate(k.NANOSECOND),l=e,h=t.sub(e),f=s.sub(t),d=n.sub(s),I=a.sub(n),j=o.sub(a),ue=u.sub(o);let D="";return l.isZero||(D+=`${l.days}d `),h.isZero||(D+=`${h.hours}h `),f.isZero||(D+=`${f.minutes}m `),d.isZero||(D+=`${d.seconds}s `),I.isZero||(D+=`${I.milliseconds}ms `),j.isZero||(D+=`${j.microseconds}µs `),ue.isZero||(D+=`${ue.nanoseconds}ns`),D.trim()}mult(e){return new k(this.valueOf()*BigInt(e))}get days(){return Number(this.valueOf())/Number(k.DAY.valueOf())}get hours(){return Number(this.valueOf())/Number(k.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(k.MINUTE.valueOf())}get seconds(){return Number(this.valueOf())/Number(k.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(k.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(k.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===BigInt(0)}equals(e){return this.valueOf()===new k(e).valueOf()}add(e){return new k(this.valueOf()+new k(e).valueOf())}sub(e){return new k(this.valueOf()-new k(e).valueOf())}static nanoseconds(e=1){return new k(e)}static microseconds(e=1){return k.nanoseconds(tt(e,1e3))}static milliseconds(e=1){return k.microseconds(tt(e,1e3))}static seconds(e=1){return k.milliseconds(tt(e,1e3))}static minutes(e=1){return k.seconds(tt(e,60))}static hours(e){return k.minutes(tt(e,60))}static days(e){return k.hours(tt(e,24))}};v(Y,"NANOSECOND",Y.nanoseconds(1)),v(Y,"MICROSECOND",Y.microseconds(1)),v(Y,"MILLISECOND",Y.milliseconds(1)),v(Y,"SECOND",Y.seconds(1)),v(Y,"MINUTE",Y.minutes(1)),v(Y,"HOUR",Y.hours(1)),v(Y,"DAY",Y.days(1)),v(Y,"MAX",new Y((1n<<63n)-1n)),v(Y,"MIN",new Y(0)),v(Y,"ZERO",new Y(0)),v(Y,"z",i.z.union([i.z.object({value:i.z.bigint()}).transform(r=>new Y(r.value)),i.z.string().transform(r=>new Y(BigInt(r))),i.z.instanceof(Number).transform(r=>new Y(r)),i.z.number().transform(r=>new Y(r)),i.z.instanceof(Y)]));let W=Y;const Rt=class $r extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new $r(e).valueOf()}get period(){return W.seconds(1/this.valueOf())}sampleCount(e){return new W(e).seconds*this.valueOf()}byteCount(e,t){return this.sampleCount(e)*new pe(t).valueOf()}span(e){return W.seconds(e/this.valueOf())}byteSpan(e,t){return this.span(e.valueOf()/t.valueOf())}static hz(e){return new $r(e)}static khz(e){return $r.hz(e*1e3)}};v(Rt,"z",i.z.union([i.z.number().transform(r=>new Rt(r)),i.z.instanceof(Number).transform(r=>new Rt(r)),i.z.instanceof(Rt)]));let Fi=Rt;const ie=class extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}length(e){return e.valueOf()/this.valueOf()}size(e){return new Sn(e*this.valueOf())}};v(ie,"UNKNOWN",new ie(0)),v(ie,"BIT128",new ie(16)),v(ie,"BIT64",new ie(8)),v(ie,"BIT32",new ie(4)),v(ie,"BIT16",new ie(2)),v(ie,"BIT8",new ie(1)),v(ie,"z",i.z.union([i.z.number().transform(r=>new ie(r)),i.z.instanceof(Number).transform(r=>new ie(r)),i.z.instanceof(ie)]));let pe=ie;const xe=class Mr{constructor(e,t){v(this,"start"),v(this,"end"),typeof e=="object"&&"start"in e?(this.start=new J(e.start),this.end=new J(e.end)):(this.start=new J(e),this.end=new J(t))}get span(){return new W(this.end.valueOf()-this.start.valueOf())}get isValid(){return this.start.valueOf()<=this.end.valueOf()}makeValid(){return this.isValid?this:this.swap()}get isZero(){return this.span.isZero}get numeric(){return{start:Number(this.start.valueOf()),end:Number(this.end.valueOf())}}swap(){return new Mr(this.end,this.start)}equals(e){return this.start.equals(e.start)&&this.end.equals(e.end)}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.fString("preciseDate")} - ${this.span.toString()}`}overlapsWith(e,t=W.ZERO){e=e.makeValid();const s=this.makeValid();if(this.equals(e))return!0;if(e.end.equals(s.start)||s.end.equals(e.start))return!1;const n=J.max(s.start,e.start),a=J.min(s.end,e.end);return a.before(n)?!1:new W(a.sub(n)).greaterThanOrEqual(t)}roughlyEquals(e,t){let s=this.start.sub(e.start).valueOf(),n=this.end.sub(e.end).valueOf();return s<0&&(s=-s),n<0&&(n=-n),s<=t.valueOf()&&n<=t.valueOf()}contains(e){return e instanceof Mr?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const t=new Mr(this.start,this.end);return e.start.after(this.start)&&(t.start=e.start),e.start.after(this.end)&&(t.end=e.start),e.end.before(this.end)&&(t.end=e.end),e.end.before(this.start)&&(t.start=e.end),t}};v(xe,"MAX",new xe(J.MIN,J.MAX)),v(xe,"MIN",new xe(J.MAX,J.MIN)),v(xe,"ZERO",new xe(J.ZERO,J.ZERO)),v(xe,"z",i.z.union([i.z.object({start:J.z,end:J.z}).transform(r=>new xe(r.start,r.end)),i.z.instanceof(xe)]));let Hn=xe;const w=class H extends String{constructor(e){if(e instanceof H||typeof e=="string"||typeof e.valueOf()=="string"){super(e.valueOf());return}const t=H.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(t!=null){super(t.valueOf());return}throw super(H.UNKNOWN.valueOf()),new Error(`unable to find data type for ${e.toString()}`)}get Array(){const e=H.ARRAY_CONSTRUCTORS.get(this.toString());if(e==null)throw new Error(`unable to find array constructor for ${this.valueOf()}`);return e}equals(e){return this.valueOf()===e.valueOf()}matches(...e){return e.some(t=>this.equals(t))}toString(){return this.valueOf()}get isVariable(){return this.equals(H.JSON)||this.equals(H.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(H.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=H.DENSITIES.get(this.toString());if(e==null)throw new Error(`unable to find density for ${this.valueOf()}`);return e}get isUnsigned(){return this.equals(H.UINT8)||this.equals(H.UINT16)||this.equals(H.UINT32)||this.equals(H.UINT64)}get isSigned(){return this.equals(H.INT8)||this.equals(H.INT16)||this.equals(H.INT32)||this.equals(H.INT64)}canSafelyCastTo(e){return this.equals(e)?!0:!this.isNumeric||!e.isNumeric||this.isVariable||e.isVariable||this.isUnsigned&&e.isSigned?!1:this.isFloat?e.isFloat&&this.density.valueOf()<=e.density.valueOf():this.equals(H.INT32)&&e.equals(H.FLOAT64)||this.equals(H.INT8)&&e.equals(H.FLOAT32)?!0:this.isInteger&&e.isInteger?this.density.valueOf()<=e.density.valueOf()&&this.isUnsigned===e.isUnsigned:!1}canCastTo(e){return this.isNumeric&&e.isNumeric?!0:this.equals(e)}checkArray(e){return e.constructor===this.Array}toJSON(){return this.toString()}get usesBigInt(){return H.BIG_INT_TYPES.some(e=>e.equals(this))}};v(w,"UNKNOWN",new w("unknown")),v(w,"FLOAT64",new w("float64")),v(w,"FLOAT32",new w("float32")),v(w,"INT64",new w("int64")),v(w,"INT32",new w("int32")),v(w,"INT16",new w("int16")),v(w,"INT8",new w("int8")),v(w,"UINT64",new w("uint64")),v(w,"UINT32",new w("uint32")),v(w,"UINT16",new w("uint16")),v(w,"UINT8",new w("uint8")),v(w,"BOOLEAN",w.UINT8),v(w,"TIMESTAMP",new w("timestamp")),v(w,"UUID",new w("uuid")),v(w,"STRING",new w("string")),v(w,"JSON",new w("json")),v(w,"ARRAY_CONSTRUCTORS",new Map([[w.UINT8.toString(),Uint8Array],[w.UINT16.toString(),Uint16Array],[w.UINT32.toString(),Uint32Array],[w.UINT64.toString(),BigUint64Array],[w.FLOAT32.toString(),Float32Array],[w.FLOAT64.toString(),Float64Array],[w.INT8.toString(),Int8Array],[w.INT16.toString(),Int16Array],[w.INT32.toString(),Int32Array],[w.INT64.toString(),BigInt64Array],[w.TIMESTAMP.toString(),BigInt64Array],[w.STRING.toString(),Uint8Array],[w.JSON.toString(),Uint8Array],[w.UUID.toString(),Uint8Array]])),v(w,"ARRAY_CONSTRUCTOR_DATA_TYPES",new Map([[Uint8Array.name,w.UINT8],[Uint16Array.name,w.UINT16],[Uint32Array.name,w.UINT32],[BigUint64Array.name,w.UINT64],[Float32Array.name,w.FLOAT32],[Float64Array.name,w.FLOAT64],[Int8Array.name,w.INT8],[Int16Array.name,w.INT16],[Int32Array.name,w.INT32],[BigInt64Array.name,w.INT64]])),v(w,"DENSITIES",new Map([[w.UINT8.toString(),pe.BIT8],[w.UINT16.toString(),pe.BIT16],[w.UINT32.toString(),pe.BIT32],[w.UINT64.toString(),pe.BIT64],[w.FLOAT32.toString(),pe.BIT32],[w.FLOAT64.toString(),pe.BIT64],[w.INT8.toString(),pe.BIT8],[w.INT16.toString(),pe.BIT16],[w.INT32.toString(),pe.BIT32],[w.INT64.toString(),pe.BIT64],[w.TIMESTAMP.toString(),pe.BIT64],[w.STRING.toString(),pe.UNKNOWN],[w.JSON.toString(),pe.UNKNOWN],[w.UUID.toString(),pe.BIT128]])),v(w,"ALL",[w.UNKNOWN,w.FLOAT64,w.FLOAT32,w.INT64,w.INT32,w.INT16,w.INT8,w.UINT64,w.UINT32,w.UINT16,w.UINT8,w.TIMESTAMP,w.UUID,w.STRING,w.JSON]),v(w,"BIG_INT_TYPES",[w.INT64,w.UINT64,w.TIMESTAMP]),v(w,"z",i.z.union([i.z.string().transform(r=>new w(r)),i.z.instanceof(w)]));let U=w;const he=class te extends Number{constructor(e){super(e.valueOf())}largerThan(e){return this.valueOf()>e.valueOf()}smallerThan(e){return this.valueOf()<e.valueOf()}add(e){return te.bytes(this.valueOf()+e.valueOf())}sub(e){return te.bytes(this.valueOf()-e.valueOf())}truncate(e){return new te(Math.trunc(this.valueOf()/e.valueOf())*e.valueOf())}remainder(e){return te.bytes(this.valueOf()%e.valueOf())}get gigabytes(){return this.valueOf()/te.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/te.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/te.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/te.TERABYTE.valueOf()}toString(){const e=this.truncate(te.TERABYTE),t=this.truncate(te.GIGABYTE),s=this.truncate(te.MEGABYTE),n=this.truncate(te.KILOBYTE),a=this.truncate(te.BYTE),o=e,u=t.sub(e),l=s.sub(t),h=n.sub(s),f=a.sub(n);let d="";return o.isZero||(d+=`${o.terabytes}TB `),u.isZero||(d+=`${u.gigabytes}GB `),l.isZero||(d+=`${l.megabytes}MB `),h.isZero||(d+=`${h.kilobytes}KB `),(!f.isZero||d==="")&&(d+=`${f.valueOf()}B`),d.trim()}static bytes(e=1){return new te(e)}static kilobytes(e=1){return te.bytes(e.valueOf()*1e3)}static megabytes(e=1){return te.kilobytes(e.valueOf()*1e3)}static gigabytes(e=1){return te.megabytes(e.valueOf()*1e3)}static terabytes(e){return te.gigabytes(e.valueOf()*1e3)}get isZero(){return this.valueOf()===0}};v(he,"BYTE",new he(1)),v(he,"KILOBYTE",he.kilobytes(1)),v(he,"MEGABYTE",he.megabytes(1)),v(he,"GIGABYTE",he.gigabytes(1)),v(he,"TERABYTE",he.terabytes(1)),v(he,"ZERO",new he(0)),v(he,"z",i.z.union([i.z.number().transform(r=>new he(r)),i.z.instanceof(he)]));let Sn=he;i.z.union([i.z.instanceof(Uint8Array),i.z.instanceof(Uint16Array),i.z.instanceof(Uint32Array),i.z.instanceof(BigUint64Array),i.z.instanceof(Float32Array),i.z.instanceof(Float64Array),i.z.instanceof(Int8Array),i.z.instanceof(Int16Array),i.z.instanceof(Int32Array),i.z.instanceof(BigInt64Array)]);const Mo=r=>{const e=typeof r;return e==="string"||e==="number"||e==="boolean"||e==="bigint"||r instanceof J||r instanceof W||r instanceof Date},zd=(r,e,t,s=0)=>r.usesBigInt&&!e.usesBigInt?Number(t)-Number(s):!r.usesBigInt&&e.usesBigInt?BigInt(t.valueOf())-BigInt(s.valueOf()):Mt(t,-s).valueOf(),Nd=r=>r==null?!1:Array.isArray(r)||r instanceof ArrayBuffer||ArrayBuffer.isView(r)&&!(r instanceof DataView)||r instanceof xd?!0:Mo(r),Ue=-1,Ed=i.z.string().transform(r=>new Uint8Array(atob(r).split("").map(e=>e.charCodeAt(0))).buffer),Id=i.z.union([i.z.null(),i.z.undefined()]).transform(()=>new Uint8Array().buffer),zn=10,$t=class Ae{constructor(e){v(this,"key",""),v(this,"isSynnaxSeries",!0),v(this,"dataType"),v(this,"sampleOffset"),v(this,"gl"),v(this,"_data"),v(this,"_timeRange"),v(this,"alignment",0n),v(this,"_cachedMin"),v(this,"_cachedMax"),v(this,"writePos",Ue),v(this,"_refCount",0),v(this,"_cachedLength"),v(this,"_cachedIndexes"),Nd(e)&&(e={data:e});const{dataType:t,timeRange:s,sampleOffset:n=0,glBufferUsage:a="static",alignment:o=0n,key:u=Od()}=e,l=e.data??[];if(l instanceof Ae||typeof l=="object"&&"isSynnaxSeries"in l&&l.isSynnaxSeries===!0){const d=l;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._cachedMin=d._cachedMin,this._cachedMax=d._cachedMax,this.writePos=d.writePos,this._refCount=d._refCount,this._cachedLength=d._cachedLength;return}const h=Mo(l),f=Array.isArray(l);if(t!=null)this.dataType=new U(t);else{if(l 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=l;if(!h){if(l.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=l[0]}if(typeof d=="string")this.dataType=U.STRING;else if(typeof d=="number")this.dataType=U.FLOAT64;else if(typeof d=="bigint")this.dataType=U.INT64;else if(typeof d=="boolean")this.dataType=U.BOOLEAN;else if(d instanceof J||d instanceof Date||d instanceof J)this.dataType=U.TIMESTAMP;else if(typeof d=="object")this.dataType=U.JSON;else throw new Error(`cannot infer data type of ${typeof d} when constructing a Series from a JS array`)}else this.dataType=new U(l)}if(!f&&!h)this._data=l;else{let d=h?[l]:l;const I=d[0];(I instanceof J||I instanceof Date||I instanceof W)&&(d=d.map(j=>new J(j).valueOf())),this.dataType.equals(U.STRING)?(this._cachedLength=d.length,this._data=new TextEncoder().encode(`${d.join(`
|
|
18
|
-
`)}
|
|
19
|
-
`).buffer):this.dataType.equals(U.JSON)?(this._cachedLength=d.length,this._data=new TextEncoder().encode(`${d.map(j=>Rr.encodeString(j)).join(`
|
|
20
|
-
`)}
|
|
21
|
-
`).buffer):this._data=new this.dataType.Array(d).buffer}this.key=u,this.alignment=o,this.sampleOffset=n??0,this._timeRange=s,this.gl={control:null,buffer:null,prevBuffer:0,bufferUsage:a}}static alloc({capacity:e,dataType:t,...s}){if(e===0)throw new Error("[Series] - cannot allocate an array of length 0");const n=new new U(t).Array(e),a=new Ae({data:n.buffer,dataType:t,...s});return a.writePos=0,a}static generateTimestamps(e,t,s){const n=s.spanRange(t.span(e)),a=new BigInt64Array(e);for(let o=0;o<e;o++)a[o]=BigInt(s.add(t.span(o)).valueOf());return new Ae({data:a,dataType:U.TIMESTAMP,timeRange:n})}get refCount(){return this._refCount}static fromStrings(e,t){const s=new TextEncoder().encode(`${e.join(`
|
|
22
|
-
`)}
|
|
23
|
-
`);return new Ae({data:s,dataType:U.STRING,timeRange:t})}static fromJSON(e,t){const s=new TextEncoder().encode(`${e.map(n=>Rr.encodeString(n)).join(`
|
|
24
|
-
`)}
|
|
25
|
-
`);return new Ae({data:s,dataType:U.JSON,timeRange:t})}acquire(e){this._refCount++,e!=null&&this.updateGLBuffer(e)}release(){if(this._refCount--,this._refCount===0&&this.gl.control!=null)this.maybeGarbageCollectGLBuffer(this.gl.control);else if(this._refCount<0)throw new Error("cannot release an array with a negative reference count")}write(e){if(!e.dataType.equals(this.dataType))throw new Error("buffer must be of the same type as this array");return this.dataType.isVariable?this.writeVariable(e):this.writeFixed(e)}writeVariable(e){if(this.writePos===Ue)return 0;const t=this.byteCapacity.valueOf()-this.writePos,s=e.subBytes(0,t);return this.writeToUnderlyingData(s),this.writePos+=s.byteLength.valueOf(),this._cachedLength!=null&&(this._cachedLength+=s.length,this.calculateCachedLength()),s.length}writeFixed(e){if(this.writePos===Ue)return 0;const t=this.capacity-this.writePos,s=e.sub(0,t);return this.writeToUnderlyingData(s),this._cachedLength=void 0,this.maybeRecomputeMinMax(s),this.writePos+=s.length,s.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===Ue?this.underlyingData:new this.dataType.Array(this._data,0,this.writePos)}toStrings(){if(!this.dataType.matches(U.STRING,U.UUID))throw new Error("cannot convert non-string series to strings");return new TextDecoder().decode(this.underlyingData).split(`
|
|
26
|
-
`).slice(0,-1)}toUUIDs(){if(!this.dataType.equals(U.UUID))throw new Error("cannot convert non-uuid series to uuids");const e=U.UUID.density.valueOf(),t=Array(this.length);for(let s=0;s<this.length;s++){const n=this.underlyingData.slice(s*e,(s+1)*e),a=Array.from(new Uint8Array(n.buffer),o=>o.toString(16).padStart(2,"0")).join("").replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/,"$1-$2-$3-$4-$5");t[s]=a}return t}parseJSON(e){if(!this.dataType.equals(U.JSON))throw new Error("cannot parse non-JSON series as JSON");return new TextDecoder().decode(this.underlyingData).split(`
|
|
27
|
-
`).slice(0,-1).map(t=>e.parse(Rr.decodeString(t)))}get timeRange(){if(this._timeRange==null)throw new Error("time range not set on series");return this._timeRange}get byteCapacity(){return new Sn(this.underlyingData.byteLength)}get capacity(){return this.dataType.isVariable?this.byteCapacity.valueOf():this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===Ue?this.byteCapacity:this.dataType.isVariable?new Sn(this.writePos):this.dataType.density.size(this.writePos)}get length(){return this._cachedLength!=null?this._cachedLength:this.dataType.isVariable?this.calculateCachedLength():this.writePos===Ue?this.data.length:this.writePos}calculateCachedLength(){if(!this.dataType.isVariable)throw new Error("cannot calculate length of a non-variable length data type");let e=0;const t=[0];return this.data.forEach((s,n)=>{s===zn&&(e++,t.push(n+1))}),this._cachedIndexes=t,this._cachedLength=e,e}convert(e,t=0){if(this.dataType.equals(e))return this;const s=new e.Array(this.length);for(let n=0;n<this.length;n++)s[n]=zd(this.dataType,e,this.data[n],t);return new Ae({data:s.buffer,dataType:e,timeRange:this._timeRange,sampleOffset:t,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment})}calcRawMax(){if(this.length===0)return-1/0;if(this.dataType.equals(U.TIMESTAMP))this._cachedMax=this.data[this.data.length-1];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMax=e.reduce((t,s)=>t>s?t:s)}else{const e=this.data;this._cachedMax=e.reduce((t,s)=>t>s?t:s)}return this._cachedMax}get max(){if(this.dataType.isVariable)throw new Error("cannot calculate maximum on a variable length data type");return this.writePos===0?-1/0:(this._cachedMax??(this._cachedMax=this.calcRawMax()),Mt(this._cachedMax,this.sampleOffset))}calcRawMin(){if(this.length===0)return 1/0;if(this.dataType.equals(U.TIMESTAMP))this._cachedMin=this.data[0];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMin=e.reduce((t,s)=>t<s?t:s)}else{const e=this.data;this._cachedMin=e.reduce((t,s)=>t<s?t:s)}return this._cachedMin}get min(){if(this.dataType.isVariable)throw new Error("cannot calculate minimum on a variable length data type");return this.writePos===0?1/0:(this._cachedMin??(this._cachedMin=this.calcRawMin()),Mt(this._cachedMin,this.sampleOffset))}get bounds(){return Qe(Number(this.min),Number(this.max))}maybeRecomputeMinMax(e){if(this._cachedMin!=null){const t=e._cachedMin??e.calcRawMin();t<this._cachedMin&&(this._cachedMin=t)}if(this._cachedMax!=null){const t=e._cachedMax??e.calcRawMax();t>this._cachedMax&&(this._cachedMax=t)}}enrich(){this.max,this.min}get range(){return Mt(this.max,-this.min)}atAlignment(e,t){const s=Number(e-this.alignment);if(s<0||s>=this.length){if(t===!0)throw new Error(`[series] - no value at index ${s}`);return}return this.at(s,t)}at(e,t){if(this.dataType.isVariable)return this.atVariable(e,t??!1);e<0&&(e=this.length+e);const s=this.data[e];if(s==null){if(t===!0)throw new Error(`[series] - no value at index ${e}`);return}return Mt(s,this.sampleOffset)}atVariable(e,t){let s=0,n=0;if(this._cachedIndexes!=null)s=this._cachedIndexes[e],n=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]===zn){if(e===0){n=o;break}s=o+1,e--}if(n===0&&(n=this.data.length),s>=n||e>0){if(t)throw new Error(`[series] - no value at index ${e}`);return}}const a=this.data.slice(s,n);return this.dataType.equals(U.STRING)?new TextDecoder().decode(a):zo(JSON.parse(new TextDecoder().decode(a)))}binarySearch(e){let t=0,s=this.length-1;const n=_h(e);for(;t<=s;){const a=Math.floor((t+s)/2),o=n(this.at(a,!0),e);if(o===0)return a;o<0?t=a+1:s=a-1}return t}updateGLBuffer(e){if(this.gl.control=e,!this.dataType.equals(U.FLOAT32)&&!this.dataType.equals(U.UINT8))throw new Error("Only FLOAT32 and UINT8 arrays can be used in WebGL");const{buffer:t,bufferUsage:s,prevBuffer:n}=this.gl;if(t==null&&(this.gl.buffer=e.createBuffer()),this.writePos!==n)if(e.bindBuffer(e.ARRAY_BUFFER,this.gl.buffer),this.writePos!==Ue){n===0&&e.bufferData(e.ARRAY_BUFFER,this.byteCapacity.valueOf(),e.STATIC_DRAW);const a=this.dataType.density.size(n).valueOf(),o=this.underlyingData.slice(this.gl.prevBuffer,this.writePos);e.bufferSubData(e.ARRAY_BUFFER,a,o.buffer),this.gl.prevBuffer=this.writePos}else e.bufferData(e.ARRAY_BUFFER,this.buffer,s==="static"?e.STATIC_DRAW:e.DYNAMIC_DRAW),this.gl.prevBuffer=Ue}as(e){if(e==="string"){if(!this.dataType.equals(U.STRING))throw new Error(`cannot convert series of type ${this.dataType.toString()} to string`);return this}if(e==="number"){if(!this.dataType.isNumeric)throw new Error(`cannot convert series of type ${this.dataType.toString()} to number`);return this}if(e==="bigint"){if(!this.dataType.equals(U.INT64))throw new Error(`cannot convert series of type ${this.dataType.toString()} to bigint`);return this}throw new Error(`cannot convert series to ${e}`)}get digest(){var e;return{key:this.key,dataType:this.dataType.toString(),sampleOffset:this.sampleOffset,alignment:{lower:Ki(this.alignmentBounds.lower),upper:Ki(this.alignmentBounds.upper)},timeRange:(e=this._timeRange)==null?void 0:e.toString(),length:this.length,capacity:this.capacity}}get memInfo(){return{key:this.key,length:this.length,byteLength:this.byteLength,glBuffer:this.gl.buffer!=null}}get alignmentBounds(){return Qe(this.alignment,this.alignment+BigInt(this.length))}maybeGarbageCollectGLBuffer(e){this.gl.buffer!=null&&(e.deleteBuffer(this.gl.buffer),this.gl.buffer=null,this.gl.prevBuffer=0,this.gl.control=null)}get glBuffer(){if(this.gl.buffer==null)throw new Error("gl buffer not initialized");return this.gl.prevBuffer!==this.writePos&&console.warn("buffer not updated"),this.gl.buffer}[Symbol.iterator](){if(this.dataType.isVariable){const e=new Ad(this);return this.dataType.equals(U.JSON)?new kd(e):e}return new Cd(this)}slice(e,t){return this.sliceSub(!1,e,t)}sub(e,t){return this.sliceSub(!0,e,t)}subIterator(e,t){return new Vi(this,e,t??this.length)}subAlignmentIterator(e,t){return new Vi(this,Number(e-this.alignment),Number(t-this.alignment))}subBytes(e,t){if(e>=0&&(t==null||t>=this.byteLength.valueOf()))return this;const s=this.data.subarray(e,t);return new Ae({data:s,dataType:this.dataType,timeRange:this._timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(e)})}sliceSub(e,t,s){if(t<=0&&(s==null||s>=this.length))return this;let n;return e?n=this.data.subarray(t,s):n=this.data.slice(t,s),new Ae({data:n,dataType:this.dataType,timeRange:this._timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(t)})}reAlign(e){return new Ae({data:this.buffer,dataType:this.dataType,timeRange:Hn.ZERO,sampleOffset:this.sampleOffset,glBufferUsage:"static",alignment:e})}};v($t,"crudeZ",i.z.object({timeRange:Hn.z.optional(),dataType:U.z,alignment:md.optional(),data:i.z.union([Ed,Id,i.z.instanceof(ArrayBuffer),i.z.instanceof(Uint8Array)]),glBufferUsage:Sd.optional().default("static").optional()})),v($t,"z",$t.crudeZ.transform(r=>new $t(r)));let xd=$t;class Vi{constructor(e,t,s){v(this,"series"),v(this,"end"),v(this,"index"),this.series=e;const n=Qe(0,e.length);this.end=Ui(n,s),this.index=Ui(n,t)}next(){return this.index>=this.end?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}[Symbol.iterator](){return this}}class Ad{constructor(e){if(v(this,"series"),v(this,"index"),v(this,"decoder"),!e.dataType.isVariable)throw new Error("cannot create a variable series iterator for a non-variable series");this.series=e,this.index=0,this.decoder=new TextDecoder}next(){const e=this.index,t=this.series.data;for(;this.index<t.length&&t[this.index]!==zn;)this.index++;const s=this.index;return e===s?{done:!0,value:void 0}:(this.index++,{done:!1,value:this.decoder.decode(this.series.buffer.slice(e,s))})}[Symbol.iterator](){return this}}var Gi,Wi;class kd{constructor(e){v(this,"wrapped"),v(this,Gi,"JSONSeriesIterator"),this.wrapped=e}next(){const e=this.wrapped.next();return e.done===!0?{done:!0,value:void 0}:{done:!1,value:Rr.decodeString(e.value)}}[(Wi=Symbol.iterator,Gi=Symbol.toStringTag,Wi)](){return this}}var Zi,Ji;class Cd{constructor(e){v(this,"series"),v(this,"index"),v(this,Zi,"SeriesIterator"),this.series=e,this.index=0}next(){return this.index>=this.series.length?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}[(Ji=Symbol.iterator,Zi=Symbol.toStringTag,Ji)](){return this}}const Mt=(r,e)=>typeof r=="bigint"&&typeof e=="bigint"||typeof r=="number"&&typeof e=="number"?r+e:e===0?r:r===0?e:Number(r)+Number(e),Ki=r=>{const e=r>>32n,t=r&0xffffffffn;return{domain:e,sample:t}};i.z.object({key:i.z.string(),value:i.z.string()});i.z.record(i.z.union([i.z.number(),i.z.string(),i.z.symbol()]),i.z.unknown());const jo=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser",Rd=jo(),Bo=["macOS","Windows","Linux"],$d=["macos","windows","linux"],Md={macos:"macOS",windows:"Windows",linux:"Linux"},jd=i.z.enum(Bo).or(i.z.enum($d).transform(r=>Md[r])),Bd=()=>{if(typeof window>"u")return;const r=window.navigator.userAgent.toLowerCase();if(r.includes("mac"))return"macOS";if(r.includes("win"))return"Windows";if(r.includes("linux"))return"Linux"};let Ls;const Pd=(r={})=>{const{force:e,default:t}=r;return e??Ls??(Ls=Bd(),Ls??t)},Po=Object.freeze(Object.defineProperty({__proto__:null,OPERATING_SYSTEMS:Bo,RUNTIME:Rd,detect:jo,getOS:Pd,osZ:jd},Symbol.toStringTag,{value:"Module"}));var Dd=Object.defineProperty,Ud=(r,e,t)=>e in r?Dd(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,jt=(r,e,t)=>Ud(r,typeof e!="symbol"?e+"":e,t);const Ld=(...r)=>r.map(Do).join(""),Do=r=>(r.endsWith("/")||(r+="/"),r.startsWith("/")&&(r=r.slice(1)),r),_d=r=>r.endsWith("/")?r.slice(0,-1):r,qd=(r,e="")=>r===null?"":`?${Object.entries(r).filter(([,t])=>t==null?!1:Array.isArray(t)?t.length>0:!0).map(([t,s])=>`${e}${t}=${s}`).join("&")}`,Nn=class En{constructor({host:e,port:t,protocol:s="",pathPrefix:n=""}){jt(this,"protocol"),jt(this,"host"),jt(this,"port"),jt(this,"path"),this.protocol=s,this.host=e,this.port=t,this.path=Do(n)}replace(e){return new En({host:e.host??this.host,port:e.port??this.port,protocol:e.protocol??this.protocol,pathPrefix:e.pathPrefix??this.path})}child(e){return new En({...this,pathPrefix:Ld(this.path,e)})}toString(){return _d(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}};jt(Nn,"UNKNOWN",new Nn({host:"unknown",port:0}));let Yd=Nn;var Fd=Object.defineProperty,Vd=(r,e,t)=>e in r?Fd(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,jr=(r,e,t)=>Vd(r,typeof e!="symbol"?e+"":e,t);const Gd=async r=>await new Promise(e=>setTimeout(e,W.fromMilliseconds(r).milliseconds)),Wd=i.z.object({interval:W.z.optional(),maxRetries:i.z.number().optional(),scale:i.z.number().optional()}),Zd=(r={})=>{const e=r.sleepFn||Gd,t=r.maxRetries??5,s=r.scale??1;let n=0,a=new W(r.interval??W.milliseconds(1));return async()=>n>=t?!1:(await e(a),a=a.mult(s),n++,!0)},Jd=Object.freeze(Object.defineProperty({__proto__:null,breakerConfig:Wd,create:Zd},Symbol.toStringTag,{value:"Module"})),rt=class extends Number{};jr(rt,"Absolute",255),jr(rt,"Default",1),jr(rt,"z",i.z.union([i.z.instanceof(rt),i.z.number().int().min(0).max(255).transform(r=>new rt(r)),i.z.instanceof(Number).transform(r=>new rt(r))]));i.z.object({name:i.z.string(),key:i.z.string()});const Uo=class Bt extends Error{constructor(){super(Bt.MESSAGE)}matches(e){return typeof e=="string"?e.includes(Bt.MESSAGE):e instanceof Bt||e.message.includes(Bt.MESSAGE)}};jr(Uo,"MESSAGE","canceled");let Kd=Uo;new Kd;i.z.string().regex(/^\d+\.\d+\.\d+$/);const me=r=>e=>e!=null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"?e.type.includes(r):e instanceof Error?e.message.includes(r):typeof e!="string"?!1:e.includes(r);let Ne=class extends Error{constructor(){super(...arguments),B(this,"discriminator","FreighterError"),B(this,"type","")}};const Hd=r=>{if(r==null||typeof r!="object")return!1;const e=r;if(e.discriminator!=="FreighterError")return!1;if(!("type"in e))throw new Error(`Freighter error is missing its type property: ${JSON.stringify(e)}`);return!0},Hi="unknown",Xi="nil",Xd="freighter",ur=i.z.object({type:i.z.string(),data:i.z.string()});class Qd{constructor(){B(this,"providers",[])}register(e){this.providers.push(e)}encode(e){if(e==null)return{type:Xi,data:""};if(Hd(e))for(const t of this.providers){const s=t.encode(e);if(s!=null)return s}return{type:Hi,data:JSON.stringify(e)}}decode(e){if(e==null||e.type===Xi)return null;if(e.type===Hi)return new Qi(e.data);for(const t of this.providers){const s=t.decode(e);if(s!=null)return s}return new Qi(e.data)}}const Lo=new Qd,_o=({encode:r,decode:e})=>Lo.register({encode:r,decode:e}),ls=r=>Lo.decode(r);class Qi extends Ne{constructor(){super(...arguments),B(this,"type","unknown")}}const vs="freighter.",Br=class qo extends Ne{constructor(){super("EOF"),B(this,"type",qo.TYPE)}};B(Br,"TYPE",`${vs}eof`),B(Br,"matches",me(Br.TYPE));let Ge=Br;const Pr=class Yo extends Ne{constructor(){super("StreamClosed"),B(this,"type",Yo.TYPE)}};B(Pr,"TYPE",`${vs}stream_closed`),B(Pr,"matches",me(Pr.TYPE));let lt=Pr;const Dr=class Fo extends Ne{constructor(e={}){const{message:t="Unreachable",url:s=Yd.UNKNOWN}=e;super(t),B(this,"type",Fo.TYPE),B(this,"url"),this.url=s}};B(Dr,"TYPE",`${vs}unreachable`),B(Dr,"matches",me(Dr.TYPE));let We=Dr;const ef=r=>{if(!r.type.startsWith(Xd))return null;if(Ge.matches(r))return{type:Ge.TYPE,data:"EOF"};if(lt.matches(r))return{type:lt.TYPE,data:"StreamClosed"};if(We.matches(r))return{type:We.TYPE,data:"Unreachable"};throw new Error(`Unknown error type: ${r.type}: ${r.message}`)},tf=r=>{if(!r.type.startsWith(vs))return null;switch(r.type){case Ge.TYPE:return new Ge;case lt.TYPE:return new lt;case We.TYPE:return new We;default:throw new Error(`Unknown error type: ${r.data}`)}};_o({encode:ef,decode:tf});let Vo=class{constructor(){B(this,"middleware",[])}use(...r){this.middleware.push(...r)}async executeMiddleware(r,e){let t=0;const s=async n=>{if(t===this.middleware.length)return await e(n);const a=this.middleware[t];return t++,await a(n,s)};return await s(r)}};const Go="Content-Type",ea=r=>{if(Po.RUNTIME!=="node")return fetch;const e=require("node-fetch");if(r==="http")return e;const t=require("https"),s=new t.Agent({rejectUnauthorized:!1});return async(n,a)=>await e(n,{...a,agent:s})};class rf extends Vo{constructor(e,t,s=!1){return super(),B(this,"endpoint"),B(this,"encoder"),B(this,"fetch"),this.endpoint=e.replace({protocol:s?"https":"http"}),this.encoder=t,this.fetch=ea(this.endpoint.protocol),new Proxy(this,{get:(n,a,o)=>a==="endpoint"?this.endpoint:Reflect.get(n,a,o)})}get headers(){return{[Go]:this.encoder.contentType}}async send(e,t,s,n){t=s==null?void 0:s.parse(t);let a=null;const o=this.endpoint.child(e),u={};u.method="POST",u.body=this.encoder.encode(t??{});const[,l]=await this.executeMiddleware({target:o.toString(),protocol:this.endpoint.protocol,params:{},role:"client"},async h=>{const f={...h,params:{}};u.headers={...this.headers,...h.params};let d;try{d=await ea(h.protocol)(h.target,u)}catch(j){let ue=j;return ue.message==="Load failed"&&(ue=new We({url:o})),[f,ue]}const I=await d.arrayBuffer();if(d!=null&&d.ok)return n!=null&&(a=this.encoder.decode(I,n)),[f,null];try{if(d.status!==400)return[f,new Error(d.statusText)];const j=this.encoder.decode(I,ur),ue=ls(j);return[f,ue]}catch(j){return[f,new Error(`[freighter] - failed to decode error: ${d.statusText}: ${j.message}`)]}});return[a,l]}}const sf=(r,e)=>{class t{constructor(n){B(this,"wrapped"),this.wrapped=n}use(...n){this.wrapped.use(...n)}async send(n,a,o,u){const l=Jd.create(e);do{const[h,f]=await this.wrapped.send(n,a,o,u);if(f==null||!We.matches(f))return[h,f];if(!await l())return[h,f]}while(!0)}}return new t(r)},T=async(r,e,t,s,n)=>{const[a,o]=await r.send(e,t,s,n);if(o!=null)throw o;return a},nf=()=>Po.RUNTIME!=="node"?r=>new WebSocket(r):r=>new(require("ws")).WebSocket(r,{rejectUnauthorized:!1}),af=i.z.object({type:i.z.union([i.z.literal("data"),i.z.literal("close"),i.z.literal("open")]),payload:i.z.unknown().optional(),error:i.z.optional(ur)});class of{constructor(e,t,s,n){B(this,"encoder"),B(this,"reqSchema"),B(this,"resSchema"),B(this,"ws"),B(this,"serverClosed"),B(this,"sendClosed"),B(this,"receiveDataQueue",[]),B(this,"receiveCallbacksQueue",[]),this.encoder=t,this.reqSchema=s,this.resSchema=n,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 ls(e.error)}return null}send(e){if(this.serverClosed!=null)return new Ge;if(this.sendClosed)throw new lt;return this.ws.send(this.encoder.encode({type:"data",payload:e})),null}async receive(){if(this.serverClosed!=null)return[null,this.serverClosed];const e=await this.receiveMsg();if(e.type==="close"){if(e.error==null)throw new Error("Message error must be defined");return this.serverClosed=ls(e.error),[null,this.serverClosed]}return[this.resSchema.parse(e.payload),null]}received(){return this.receiveDataQueue.length!==0}closeSend(){if(this.sendClosed||this.serverClosed!=null)return;const e={type:"close"};try{this.ws.send(this.encoder.encode(e))}finally{this.sendClosed=!0}}async receiveMsg(){return this.receiveDataQueue.shift()??await new Promise((e,t)=>this.receiveCallbacksQueue.push({resolve:e,reject:t}))}addMessage(e){const t=this.receiveCallbacksQueue.shift();t!=null?t.resolve(e):this.receiveDataQueue.push(e)}listenForMessages(){this.ws.onmessage=e=>this.addMessage(this.encoder.decode(e.data,af)),this.ws.onclose=e=>this.addMessage({type:"close",error:{type:df(e)?Ge.TYPE:lt.TYPE,data:""}})}}const lf="freighterctx",uf=1e3,cf=1001,hf=[uf,cf],df=r=>hf.includes(r.code),Wo=class Zo extends Vo{constructor(e,t,s=!1){super(),B(this,"baseUrl"),B(this,"encoder"),this.baseUrl=e.replace({protocol:s?"wss":"ws"}),this.encoder=t}async stream(e,t,s){const n=nf();let a;const[,o]=await this.executeMiddleware({target:e,protocol:"websocket",params:{},role:"client"},async u=>{const l=n(this.buildURL(e,u)),h={...u,params:{}};l.binaryType=Zo.MESSAGE_TYPE;const f=await this.wrapSocket(l,t,s);return f instanceof Error?[h,f]:(a=f,[h,null])});if(o!=null)throw o;return a}buildURL(e,t){const s=qd({[Go]:this.encoder.contentType,...t.params},lf);return this.baseUrl.child(e).toString()+s}async wrapSocket(e,t,s){return await new Promise(n=>{e.onopen=()=>{const a=new of(e,this.encoder,t,s);a.receiveOpenAck().then(o=>{o!=null?n(o):n(a)}).catch(o=>n(o))},e.onerror=a=>{const o=a;n(new Error(o.message))}})}};B(Wo,"MESSAGE_TYPE","arraybuffer");let ff=Wo;const In=i.z.union([i.z.literal("all"),i.z.literal("create"),i.z.literal("delete"),i.z.literal("retrieve"),i.z.literal("update")]),pf=r=>{const e=r.replace(/_[a-z]/g,t=>t[1].toUpperCase());return e.length>1&&e[0]===e[0].toUpperCase()&&e[1]===e[1].toUpperCase()||e.length===0?e:e[0].toLowerCase()+e.slice(1)},Jo=r=>{const e=(t,s=xn)=>{if(typeof t=="string")return r(t);if(Array.isArray(t))return t.map(o=>e(o,s));if(!_s(t))return t;s=mf(s);const n={},a=t;return Object.keys(a).forEach(o=>{let u=a[o];const l=r(o);s.recursive&&(_s(u)?ra(u,s.keepTypesOnRecursion)||(u=e(u,s)):s.recursiveInArray&&ta(u)&&(u=[...u].map(h=>{let f=h;return _s(h)?ra(f,s.keepTypesOnRecursion)||(f=e(h,s)):ta(h)&&(f=e({key:h},s).key),f}))),n[l]=u}),n};return e},Ko=Jo(pf),gf=r=>r.replace(/([a-z0-9])([A-Z])/g,(e,t,s)=>`${t}_${s.toLowerCase()}`),yf=Jo(gf),xn={recursive:!0,recursiveInArray:!0,keepTypesOnRecursion:[Number,String,Uint8Array]},mf=(r=xn)=>(r.recursive==null?r=xn:r.recursiveInArray??(r.recursiveInArray=!1),r),ta=r=>r!=null&&Array.isArray(r),_s=r=>r!=null&&typeof r=="object"&&!Array.isArray(r),ra=(r,e)=>(e||[]).some(t=>r instanceof t),Xn=r=>r!=null&&typeof r=="object"&&!Array.isArray(r);var wf=Object.defineProperty,bf=(r,e,t)=>e in r?wf(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Jt=(r,e,t)=>bf(r,typeof e!="symbol"?e+"":e,t);let Ho=class{constructor(){Jt(this,"contentType","application/json"),Jt(this,"decoder"),Jt(this,"encoder"),this.decoder=new TextDecoder,this.encoder=new TextEncoder}encode(r){return this.encoder.encode(this.encodeString(r)).buffer}decode(r,e){return this.decodeString(this.decoder.decode(r),e)}decodeString(r,e){const t=JSON.parse(r),s=Ko(t);return e!=null?e.parse(s):s}encodeString(r){const e=yf(r);return JSON.stringify(e,(t,s)=>ArrayBuffer.isView(s)?Array.from(s):Xn(s)&&"encode_value"in s?typeof s.value=="bigint"?s.value.toString():s.value:typeof s=="bigint"?s.toString():s)}static registerCustomType(){}},Xo=class{constructor(){Jt(this,"contentType","text/csv")}encode(r){const e=this.encodeString(r);return new TextEncoder().encode(e).buffer}decode(r,e){const t=new TextDecoder().decode(r);return this.decodeString(t,e)}encodeString(r){if(!Array.isArray(r)||r.length===0||!Xn(r[0]))throw new Error("Payload must be an array of objects");const e=Object.keys(r[0]),t=[e.join(",")];return r.forEach(s=>{const n=e.map(a=>JSON.stringify(s[a]??""));t.push(n.join(","))}),t.join(`
|
|
28
|
-
`)}decodeString(r,e){const[t,...s]=r.trim().split(`
|
|
29
|
-
`).map(o=>o.trim());if(t.length===0)return e!=null?e.parse({}):{};const n=t.split(",").map(o=>o.trim()),a={};return n.forEach(o=>{a[o]=[]}),s.forEach(o=>{const u=o.split(",").map(l=>l.trim());n.forEach((l,h)=>{const f=this.parseValue(u[h]);f!=null&&a[l].push(f)})}),e!=null?e.parse(a):a}parseValue(r){if(r==null||r.length===0)return null;const e=Number(r);return isNaN(e)?r.startsWith('"')&&r.endsWith('"')?r.slice(1,-1):r:e}static registerCustomType(){}},Qo=class{constructor(){Jt(this,"contentType","text/plain")}encode(r){return new TextEncoder().encode(r).buffer}decode(r,e){const t=new TextDecoder().decode(r);return e!=null?e.parse(t):t}};const at=new Ho,vf=new Xo,Tf=new Qo,Of=[at],gt=Object.freeze(Object.defineProperty({__proto__:null,CSVCodec:Xo,CSV_CODEC:vf,ENCODERS:Of,JSONCodec:Ho,JSON_CODEC:at,TEXT_CODEC:Tf,TextCodec:Qo},Symbol.toStringTag,{value:"Module"})),Sf=r=>[...new Set(r)],zf=(r,e,t=!0)=>{const s=new Map;return r.forEach(n=>{const a=e(n);if(s.has(a)){if(t)return;s.delete(a)}s.set(a,n)}),Array.from(s.values())},sa=Object.freeze(Object.defineProperty({__proto__:null,by:zf,unique:Sf},Symbol.toStringTag,{value:"Module"})),Nf=r=>r!=null&&typeof r=="object"&&"toString"in r,Ef=(r,e=!1)=>{const t=Nf(r)?"stringer":typeof r;let s;switch(t){case"string":s=(n,a)=>n.localeCompare(a);break;case"stringer":s=(n,a)=>n.toString().localeCompare(a.toString());break;case"number":s=(n,a)=>Number(n)-Number(a);break;case"bigint":s=(n,a)=>BigInt(n)-BigInt(a)>0n?1:-1;break;case"boolean":s=(n,a)=>Number(n)-Number(a);break;case"undefined":s=()=>0;break;default:return console.warn(`sortFunc: unknown type ${t}`),()=>-1}return e?If(s):s},If=r=>(e,t)=>r(t,e),Ts=0,qs=-1,Ys=1,xf=r=>r<Ts,Af=r=>r>Ts,kf=r=>r===Ts,Os=i.z.tuple([i.z.number(),i.z.number()]);i.z.tuple([i.z.bigint(),i.z.bigint()]);const el=i.z.object({width:i.z.number(),height:i.z.number()}),Cf=i.z.object({signedWidth:i.z.number(),signedHeight:i.z.number()}),Rf=["width","height"];i.z.enum(Rf);const $f=["start","center","end"],Mf=["signedWidth","signedHeight"];i.z.enum(Mf);const us=i.z.object({x:i.z.number(),y:i.z.number()}),jf=i.z.object({clientX:i.z.number(),clientY:i.z.number()}),Bf=["x","y"],tl=i.z.enum(Bf),rl=["top","right","bottom","left"];i.z.enum(rl);const Pf=["left","right"],sl=i.z.enum(Pf),Df=["top","bottom"],nl=i.z.enum(Df),il=["center"],na=i.z.enum(il),Uf=[...rl,...il],al=i.z.enum(Uf);i.z.enum($f);const Lf=["first","last"];i.z.enum(Lf);const _f=i.z.object({lower:i.z.number(),upper:i.z.number()}),qf=i.z.object({lower:i.z.bigint(),upper:i.z.bigint()});i.z.union([_f,Os]);i.z.union([qf,Os]);i.z.union([tl,al]);i.z.union([tl,al,i.z.instanceof(String)]);const yt=r=>typeof r=="bigint"||r instanceof BigInt,Fs=(r,e)=>yt(r)?r.valueOf()-BigInt(e.valueOf().valueOf()):r.valueOf()-Number(e.valueOf()),Yf=(r,e)=>yt(r)?r.valueOf()+BigInt(e.valueOf().valueOf()):r+Number(e.valueOf()),ia=(r,e)=>yt(r)?r===BigInt(e.valueOf().valueOf()):r===Number(e.valueOf()),Ff=(r,e)=>yt(r)?r.valueOf()<BigInt(e.valueOf())?r:BigInt(e.valueOf()):r.valueOf()<Number(e.valueOf())?r:Number(e.valueOf()),Vf=r=>yt(r)||r instanceof BigInt?r.valueOf()<0n?-r:r:r.valueOf()<0?-r:r,st=(r,e)=>yt(r)?r.valueOf()*BigInt(e.valueOf()):r.valueOf()*Number(e.valueOf()),ye=(r,e)=>{const t={};if(typeof r=="number"||typeof r=="bigint")e!=null?(t.lower=r,t.upper=e):(t.lower=typeof r=="bigint"?0n:0,t.upper=r);else if(Array.isArray(r)){if(r.length!==2)throw new Error("bounds: expected array of length 2");[t.lower,t.upper]=r}else return aa(r);return aa(t)},aa=r=>r.lower>r.upper?{lower:r.upper,upper:r.lower}:r,oa=(r,e)=>{const t=ye(r);return e<t.lower?t.lower:e>=t.upper?t.upper-(typeof t.upper=="number"?1:1n):e},vr=(r,e)=>{const t=ye(r);if(typeof e=="number"||typeof e=="bigint")return e>=t.lower&&e<t.upper;const s=ye(e);return s.lower>=t.lower&&s.upper<=t.upper},Gf=(r,e,t)=>{const s=r.map(u=>ye(u)),n=t>0?1:t<0?-1:0;if(n===0)return e;let a=t,o=e;for(;ia(a,0)===!1;){const u=s.findIndex(l=>n>0?o>=l.lower&&o<l.upper:o>l.lower&&o<=l.upper);if(u!==-1){const l=s[u];let h;if(n>0?h=Fs(l.upper,o):h=Fs(o,l.lower),h>0){const f=Ff(Vf(a),h);if(o=Yf(o,n>0?f:-f),a=Fs(a,n>0?f:-f),ia(a,0))return o;continue}}if(n>0){const l=s.filter(h=>h.lower>o);if(l.length>0)o=l[0].lower;else return o}else{const l=s.filter(h=>h.upper<o);if(l.length>0)o=l[l.length-1].upper;else return o}}return o},Wf=(r,e,t)=>{const s=r.map(o=>ye(o));if(e===t)return typeof e=="bigint"?0n:0;const n=e<t?ye([e,t]):ye([t,e]);let a=typeof e=="bigint"?0n:0;for(const o of s){const u=o.lower>n.lower?o.lower:n.lower,l=o.upper<n.upper?o.upper:n.upper;if(u<l){const h=l-u;a=a+h}}return a};i.z.object({x:sl.or(na),y:nl.or(na)});const Zf=i.z.object({x:sl,y:nl}),Jf=Object.freeze({x:"left",y:"top"}),Kf=(r,e)=>r.x===e.x&&r.y===e.y,la=i.z.union([i.z.number(),us,Os,el,Cf,jf]),Hf=(r,e)=>{if(typeof r=="string"){if(e===void 0)throw new Error("The y coordinate must be given.");return r==="x"?{x:e,y:0}:{x:0,y:e}}return typeof r=="number"?{x:r,y:e??r}:Array.isArray(r)?{x:r[0],y:r[1]}:"signedWidth"in r?{x:r.signedWidth,y:r.signedHeight}:"clientX"in r?{x:r.clientX,y:r.clientY}:"width"in r?{x:r.width,y:r.height}:{x:r.x,y:r.y}},ua=Object.freeze({x:0,y:0}),Tr=i.z.union([i.z.number(),i.z.string()]);i.z.object({top:Tr,left:Tr,width:Tr,height:Tr});i.z.object({left:i.z.number(),top:i.z.number(),right:i.z.number(),bottom:i.z.number()});i.z.object({one:us,two:us,root:Zf});const Qn=(r,e,t=0,s=0,n)=>{const a={one:{...ua},two:{...ua},root:n??Jf};if(typeof r=="number"){if(typeof e!="number")throw new Error("Box constructor called with invalid arguments");return a.one={x:r,y:e},a.two={x:a.one.x+t,y:a.one.y+s},a}return"one"in r&&"two"in r&&"root"in r?{...r,root:n??r.root}:("getBoundingClientRect"in r&&(r=r.getBoundingClientRect()),"left"in r?(a.one={x:r.left,y:r.top},a.two={x:r.right,y:r.bottom},a):(a.one=r,e==null?a.two={x:a.one.x+t,y:a.one.y+s}:typeof e=="number"?a.two={x:a.one.x+e,y:a.one.y+t}:"width"in e?a.two={x:a.one.x+e.width,y:a.one.y+e.height}:"signedWidth"in e?a.two={x:a.one.x+e.signedWidth,y:a.one.y+e.signedHeight}:a.two=e,a))},Vs=r=>{const e=Qn(r);return{lower:e.one.x,upper:e.two.x}},Gs=r=>{const e=Qn(r);return{lower:e.one.y,upper:e.two.y}},Xf=r=>typeof r!="object"||r==null?!1:"one"in r&&"two"in r&&"root"in r,Qf=i.z.object({signedWidth:i.z.number(),signedHeight:i.z.number()});i.z.union([el,Qf,us,Os]);var ep=Object.defineProperty,tp=(r,e,t)=>e in r?ep(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Be=(r,e,t)=>tp(r,typeof e!="symbol"?e+"":e,t);const rp=(r,e,t)=>e!==void 0&&r<e?e:t!==void 0&&r>t?t:r;i.z.object({offset:la,scale:la});i.z.object({offset:i.z.number(),scale:i.z.number()});const sp=r=>(e,t,s,n)=>t==="dimension"?[e,s]:[e,n?s-r:s+r],np=r=>(e,t,s,n)=>[e,n?s/r:s*r],ip=r=>(e,t,s)=>{if(e===null)return[r,s];const{lower:n,upper:a}=e,{lower:o,upper:u}=r,l=a-n,h=u-o;if(t==="dimension")return[r,s*(h/l)];const f=(s-n)*(h/l)+o;return[r,f]},ap=r=>(e,t,s)=>[r,s],op=()=>(r,e,t)=>{if(r===null)throw new Error("cannot invert without bounds");if(e==="dimension")return[r,t];const{lower:s,upper:n}=r;return[r,n-(t-s)]},lp=r=>(e,t,s)=>{const{lower:n,upper:a}=r;return s=rp(s,n,a),[e,s]},An=class Pt{constructor(){Be(this,"ops",[]),Be(this,"currBounds",null),Be(this,"currType",null),Be(this,"reversed",!1),this.ops=[]}static translate(e){return new Pt().translate(e)}static magnify(e){return new Pt().magnify(e)}static scale(e,t){return new Pt().scale(e,t)}translate(e){const t=this.new(),s=sp(e);return s.type="translate",t.ops.push(s),t}magnify(e){const t=this.new(),s=np(e);return s.type="magnify",t.ops.push(s),t}scale(e,t){const s=ye(e,t),n=this.new(),a=ip(s);return a.type="scale",n.ops.push(a),n}clamp(e,t){const s=ye(e,t),n=this.new(),a=lp(s);return a.type="clamp",n.ops.push(a),n}reBound(e,t){const s=ye(e,t),n=this.new(),a=ap(s);return a.type="re-bound",n.ops.push(a),n}invert(){const e=op();e.type="invert";const t=this.new();return t.ops.push(e),t}pos(e){return this.exec("position",e)}dim(e){return this.exec("dimension",e)}new(){const e=new Pt;return e.ops=this.ops.slice(),e.reversed=this.reversed,e}exec(e,t){return this.currBounds=null,this.ops.reduce(([s,n],a)=>a(s,e,n,this.reversed),[null,t])[1]}reverse(){const e=this.new();e.ops.reverse();const t=[];return e.ops.forEach((s,n)=>{if(s.type==="scale"||t.some(([o,u])=>n>=o&&n<=u))return;const a=e.ops.findIndex((o,u)=>o.type==="scale"&&u>n);a!==-1&&t.push([n,a])}),t.forEach(([s,n])=>{const a=e.ops.slice(s,n);a.unshift(e.ops[n]),e.ops.splice(s,n-s+1,...a)}),e.reversed=!e.reversed,e}get transform(){return{scale:this.dim(1),offset:this.pos(0)}}};Be(An,"IDENTITY",new An);let ca=An;const ha=class Me{constructor(e=new ca,t=new ca,s=null){Be(this,"x"),Be(this,"y"),Be(this,"currRoot"),this.x=e,this.y=t,this.currRoot=s}static translate(e,t){return new Me().translate(e,t)}static translateX(e){return new Me().translateX(e)}static translateY(e){return new Me().translateY(e)}static clamp(e){return new Me().clamp(e)}static magnify(e){return new Me().magnify(e)}static scale(e){return new Me().scale(e)}static reBound(e){return new Me().reBound(e)}translate(e,t){const s=Hf(e,t),n=this.copy();return n.x=this.x.translate(s.x),n.y=this.y.translate(s.y),n}translateX(e){const t=this.copy();return t.x=this.x.translate(e),t}translateY(e){const t=this.copy();return t.y=this.y.translate(e),t}magnify(e){const t=this.copy();return t.x=this.x.magnify(e.x),t.y=this.y.magnify(e.y),t}scale(e){const t=this.copy();if(Xf(e)){const s=this.currRoot;return t.currRoot=e.root,s!=null&&!Kf(s,e.root)&&(s.x!==e.root.x&&(t.x=t.x.invert()),s.y!==e.root.y&&(t.y=t.y.invert())),t.x=t.x.scale(Vs(e)),t.y=t.y.scale(Gs(e)),t}return t.x=t.x.scale(e.width),t.y=t.y.scale(e.height),t}reBound(e){const t=this.copy();return t.x=this.x.reBound(Vs(e)),t.y=this.y.reBound(Gs(e)),t}clamp(e){const t=this.copy();return t.x=this.x.clamp(Vs(e)),t.y=this.y.clamp(Gs(e)),t}copy(){const e=new Me;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 Qn(this.pos(e.one),this.pos(e.two),0,0,this.currRoot??e.root)}get transform(){return{scale:this.dim({x:1,y:1}),offset:this.pos({x:0,y:0})}}};Be(ha,"IDENTITY",new ha);const up=i.z.bigint().or(i.z.string().transform(BigInt));var cp=Object.defineProperty,hp=(r,e,t)=>e in r?cp(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,y=(r,e,t)=>hp(r,typeof e!="symbol"?e+"":e,t);let dp=(r,e=21)=>(t=e)=>{let s="",n=t|0;for(;n--;)s+=r[Math.random()*r.length|0];return s};const fp="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",ol=dp(fp,11),pp=Object.freeze(Object.defineProperty({__proto__:null,id:ol},Symbol.toStringTag,{value:"Module"})),gp=i.z.enum(["static","dynamic"]),ll=(r,e)=>{const t=new $(e);if(![x.DAY,x.HOUR,x.MINUTE,x.SECOND,x.MILLISECOND,x.MICROSECOND,x.NANOSECOND].some(n=>n.equals(t)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const s=r.valueOf()%t.valueOf();return r instanceof $?new $(s):new x(s)},F=class E{constructor(e,t="UTC"){if(y(this,"value"),y(this,"encodeValue",!0),e==null)this.value=E.now().valueOf();else if(e instanceof Date)this.value=BigInt(e.getTime())*E.MILLISECOND.valueOf();else if(typeof e=="string")this.value=E.parseDateTimeString(e,t).valueOf();else if(Array.isArray(e))this.value=E.parseDate(e);else{let s=BigInt(0);e instanceof Number&&(e=e.valueOf()),t==="local"&&(s=E.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=E.MAX:e=E.MIN)),this.value=BigInt(e.valueOf())+s}}static parseDate([e=1970,t=1,s=1]){const n=new Date(e,t-1,s,0,0,0,0);return new E(BigInt(n.getTime())*E.MILLISECOND.valueOf()).truncate(E.DAY).valueOf()}encode(){return this.value.toString()}valueOf(){return this.value}static parseTimeString(e,t="UTC"){const[s,n,a]=e.split(":");let o="00",u="00";a!=null&&([o,u]=a.split("."));let l=E.hours(parseInt(s??"00")).add(E.minutes(parseInt(n??"00"))).add(E.seconds(parseInt(o??"00"))).add(E.milliseconds(parseInt(u??"00")));return t==="local"&&(l=l.add(E.utcOffset)),l.valueOf()}static parseDateTimeString(e,t="UTC"){if(!e.includes("/")&&!e.includes("-"))return E.parseTimeString(e,t);const s=new Date(e);return e.includes(":")||s.setUTCHours(0,0,0,0),new E(BigInt(s.getTime())*E.MILLISECOND.valueOf(),t).valueOf()}fString(e="ISO",t="UTC"){switch(e){case"ISODate":return this.toISOString(t).slice(0,10);case"ISOTime":return this.toISOString(t).slice(11,23);case"time":return this.timeString(!1,t);case"preciseTime":return this.timeString(!0,t);case"date":return this.dateString();case"preciseDate":return`${this.dateString()} ${this.timeString(!0,t)}`;case"dateTime":return`${this.dateString()} ${this.timeString(!1,t)}`;default:return this.toISOString(t)}}toISOString(e="UTC"){return e==="UTC"?this.date().toISOString():this.sub(E.utcOffset).date().toISOString()}timeString(e=!1,t="UTC"){const s=this.toISOString(t);return e?s.slice(11,23):s.slice(11,19)}dateString(){const e=this.date(),t=e.toLocaleString("default",{month:"short"}),s=e.toLocaleString("default",{day:"numeric"});return`${t} ${s}`}static get utcOffset(){return new x(BigInt(new Date().getTimezoneOffset())*E.MINUTE.valueOf())}static since(e){return new E().span(e)}date(){return new Date(this.milliseconds)}equals(e){return this.valueOf()===new E(e).valueOf()}span(e){return this.range(e).span}range(e){return new oe(this,e).makeValid()}spanRange(e){return this.range(this.add(e)).makeValid()}get isZero(){return this.valueOf()===BigInt(0)}after(e){return this.valueOf()>new E(e).valueOf()}afterEq(e){return this.valueOf()>=new E(e).valueOf()}before(e){return this.valueOf()<new E(e).valueOf()}beforeEq(e){return this.valueOf()<=new E(e).valueOf()}add(e){return new E(this.valueOf()+BigInt(e.valueOf()))}sub(e){return new E(this.valueOf()-BigInt(e.valueOf()))}get hours(){return Number(this.valueOf())/Number(x.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(x.MINUTE.valueOf())}get days(){return Number(this.valueOf())/Number(x.DAY.valueOf())}get seconds(){return Number(this.valueOf())/Number(x.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(E.MILLISECOND.valueOf())}get year(){return this.date().getFullYear()}setYear(e){const t=this.date();return t.setFullYear(e),new E(t)}get month(){return this.date().getMonth()}setMonth(e){const t=this.date();return t.setMonth(e),new E(t)}get day(){return this.date().getDate()}setDay(e){const t=this.date();return t.setDate(e),new E(t)}get hour(){return this.date().getHours()}setHour(e){const t=this.date();return t.setHours(e),new E(t)}get minute(){return this.date().getMinutes()}setMinute(e){const t=this.date();return t.setMinutes(e),new E(t)}get second(){return this.date().getSeconds()}setSecond(e){const t=this.date();return t.setSeconds(e),new E(t)}get millisecond(){return this.date().getMilliseconds()}setMillisecond(e){const t=this.date();return t.setMilliseconds(e),new E(t)}toString(){return this.date().toISOString()}remainder(e){return ll(this,e)}get isToday(){return this.truncate(x.DAY).equals(E.now().truncate(x.DAY))}truncate(e){return this.sub(this.remainder(e))}static now(){return new E(new Date)}static max(...e){let t=E.MIN;for(const s of e){const n=new E(s);n.after(t)&&(t=n)}return t}static min(...e){let t=E.MAX;for(const s of e){const n=new E(s);n.before(t)&&(t=n)}return t}static nanoseconds(e){return new E(e)}static microseconds(e){return E.nanoseconds(e*1e3)}static milliseconds(e){return E.microseconds(e*1e3)}static seconds(e){return E.milliseconds(e*1e3)}static minutes(e){return E.seconds(e*60)}static hours(e){return E.minutes(e*60)}static days(e){return E.hours(e*24)}};y(F,"NANOSECOND",F.nanoseconds(1)),y(F,"MICROSECOND",F.microseconds(1)),y(F,"MILLISECOND",F.milliseconds(1)),y(F,"SECOND",F.seconds(1)),y(F,"MINUTE",F.minutes(1)),y(F,"HOUR",F.hours(1)),y(F,"DAY",F.days(1)),y(F,"MAX",new F((1n<<63n)-1n)),y(F,"MIN",new F(0)),y(F,"ZERO",new F(0)),y(F,"z",i.z.union([i.z.object({value:i.z.bigint()}).transform(r=>new F(r.value)),i.z.string().transform(r=>new F(BigInt(r))),i.z.instanceof(Number).transform(r=>new F(r)),i.z.number().transform(r=>new F(r)),i.z.instanceof(F)]));let $=F;const V=class C{constructor(e){y(this,"value"),y(this,"encodeValue",!0),typeof e=="number"&&(e=Math.trunc(e.valueOf())),this.value=BigInt(e.valueOf())}static fromSeconds(e){return e instanceof C?e:e instanceof Qt?e.period:e instanceof $?new C(e):["number","bigint"].includes(typeof e)?C.seconds(e):new C(e)}static fromMilliseconds(e){return e instanceof C?e:e instanceof Qt?e.period:e instanceof $?new C(e):["number","bigint"].includes(typeof e)?C.milliseconds(e):new C(e)}encode(){return this.value.toString()}valueOf(){return this.value}lessThan(e){return this.valueOf()<new C(e).valueOf()}greaterThan(e){return this.valueOf()>new C(e).valueOf()}lessThanOrEqual(e){return this.valueOf()<=new C(e).valueOf()}greaterThanOrEqual(e){return this.valueOf()>=new C(e).valueOf()}remainder(e){return ll(this,e)}truncate(e){return new C(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(){const e=this.truncate(C.DAY),t=this.truncate(C.HOUR),s=this.truncate(C.MINUTE),n=this.truncate(C.SECOND),a=this.truncate(C.MILLISECOND),o=this.truncate(C.MICROSECOND),u=this.truncate(C.NANOSECOND),l=e,h=t.sub(e),f=s.sub(t),d=n.sub(s),I=a.sub(n),j=o.sub(a),ue=u.sub(o);let D="";return l.isZero||(D+=`${l.days}d `),h.isZero||(D+=`${h.hours}h `),f.isZero||(D+=`${f.minutes}m `),d.isZero||(D+=`${d.seconds}s `),I.isZero||(D+=`${I.milliseconds}ms `),j.isZero||(D+=`${j.microseconds}µs `),ue.isZero||(D+=`${ue.nanoseconds}ns`),D.trim()}mult(e){return new C(this.valueOf()*BigInt(e))}get days(){return Number(this.valueOf())/Number(C.DAY.valueOf())}get hours(){return Number(this.valueOf())/Number(C.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(C.MINUTE.valueOf())}get seconds(){return Number(this.valueOf())/Number(C.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(C.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(C.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===BigInt(0)}equals(e){return this.valueOf()===new C(e).valueOf()}add(e){return new C(this.valueOf()+new C(e).valueOf())}sub(e){return new C(this.valueOf()-new C(e).valueOf())}static nanoseconds(e=1){return new C(e)}static microseconds(e=1){return C.nanoseconds(st(e,1e3))}static milliseconds(e=1){return C.microseconds(st(e,1e3))}static seconds(e=1){return C.milliseconds(st(e,1e3))}static minutes(e=1){return C.seconds(st(e,60))}static hours(e){return C.minutes(st(e,60))}static days(e){return C.hours(st(e,24))}};y(V,"NANOSECOND",V.nanoseconds(1)),y(V,"MICROSECOND",V.microseconds(1)),y(V,"MILLISECOND",V.milliseconds(1)),y(V,"SECOND",V.seconds(1)),y(V,"MINUTE",V.minutes(1)),y(V,"HOUR",V.hours(1)),y(V,"DAY",V.days(1)),y(V,"MAX",new V((1n<<63n)-1n)),y(V,"MIN",new V(0)),y(V,"ZERO",new V(0)),y(V,"z",i.z.union([i.z.object({value:i.z.bigint()}).transform(r=>new V(r.value)),i.z.string().transform(r=>new V(BigInt(r))),i.z.instanceof(Number).transform(r=>new V(r)),i.z.number().transform(r=>new V(r)),i.z.instanceof(V)]));let x=V;const Dt=class Ur extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new Ur(e).valueOf()}get period(){return x.seconds(1/this.valueOf())}sampleCount(e){return new x(e).seconds*this.valueOf()}byteCount(e,t){return this.sampleCount(e)*new ge(t).valueOf()}span(e){return x.seconds(e/this.valueOf())}byteSpan(e,t){return this.span(e.valueOf()/t.valueOf())}static hz(e){return new Ur(e)}static khz(e){return Ur.hz(e*1e3)}};y(Dt,"z",i.z.union([i.z.number().transform(r=>new Dt(r)),i.z.instanceof(Number).transform(r=>new Dt(r)),i.z.instanceof(Dt)]));let Qt=Dt;const ae=class extends Number{constructor(r){r instanceof Number?super(r.valueOf()):super(r)}length(r){return r.valueOf()/this.valueOf()}size(r){return new ut(r*this.valueOf())}};y(ae,"UNKNOWN",new ae(0)),y(ae,"BIT128",new ae(16)),y(ae,"BIT64",new ae(8)),y(ae,"BIT32",new ae(4)),y(ae,"BIT16",new ae(2)),y(ae,"BIT8",new ae(1)),y(ae,"z",i.z.union([i.z.number().transform(r=>new ae(r)),i.z.instanceof(Number).transform(r=>new ae(r)),i.z.instanceof(ae)]));let ge=ae;const ke=class Lr{constructor(e,t){y(this,"start"),y(this,"end"),typeof e=="object"&&"start"in e?(this.start=new $(e.start),this.end=new $(e.end)):(this.start=new $(e),this.end=new $(t))}get span(){return new x(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 Lr(this.end,this.start)}equals(e){return this.start.equals(e.start)&&this.end.equals(e.end)}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.fString("preciseDate")} - ${this.span.toString()}`}overlapsWith(e,t=x.ZERO){e=e.makeValid();const s=this.makeValid();if(this.equals(e))return!0;if(e.end.equals(s.start)||s.end.equals(e.start))return!1;const n=$.max(s.start,e.start),a=$.min(s.end,e.end);return a.before(n)?!1:new x(a.sub(n)).greaterThanOrEqual(t)}roughlyEquals(e,t){let s=this.start.sub(e.start).valueOf(),n=this.end.sub(e.end).valueOf();return s<0&&(s=-s),n<0&&(n=-n),s<=t.valueOf()&&n<=t.valueOf()}contains(e){return e instanceof Lr?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const t=new Lr(this.start,this.end);return e.start.after(this.start)&&(t.start=e.start),e.start.after(this.end)&&(t.end=e.start),e.end.before(this.end)&&(t.end=e.end),e.end.before(this.start)&&(t.start=e.end),t}};y(ke,"MAX",new ke($.MIN,$.MAX)),y(ke,"MIN",new ke($.MAX,$.MIN)),y(ke,"ZERO",new ke($.ZERO,$.ZERO)),y(ke,"z",i.z.union([i.z.object({start:$.z,end:$.z}).transform(r=>new ke(r.start,r.end)),i.z.instanceof(ke)]));let oe=ke;const yp=(r,e)=>r.start.before(e.start)?-1:r.start.after(e.start)?1:r.end.before(e.end)?-1:r.end.after(e.end)?1:0,b=class X extends String{constructor(e){if(e instanceof X||typeof e=="string"||typeof e.valueOf()=="string"){super(e.valueOf());return}const t=X.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(t!=null){super(t.valueOf());return}throw super(X.UNKNOWN.valueOf()),new Error(`unable to find data type for ${e.toString()}`)}get Array(){const e=X.ARRAY_CONSTRUCTORS.get(this.toString());if(e==null)throw new Error(`unable to find array constructor for ${this.valueOf()}`);return e}equals(e){return this.valueOf()===e.valueOf()}matches(...e){return e.some(t=>this.equals(t))}toString(){return this.valueOf()}get isVariable(){return this.equals(X.JSON)||this.equals(X.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(X.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=X.DENSITIES.get(this.toString());if(e==null)throw new Error(`unable to find density for ${this.valueOf()}`);return e}get isUnsigned(){return this.equals(X.UINT8)||this.equals(X.UINT16)||this.equals(X.UINT32)||this.equals(X.UINT64)}get isSigned(){return this.equals(X.INT8)||this.equals(X.INT16)||this.equals(X.INT32)||this.equals(X.INT64)}canSafelyCastTo(e){return this.equals(e)?!0:!this.isNumeric||!e.isNumeric||this.isVariable||e.isVariable||this.isUnsigned&&e.isSigned?!1:this.isFloat?e.isFloat&&this.density.valueOf()<=e.density.valueOf():this.equals(X.INT32)&&e.equals(X.FLOAT64)||this.equals(X.INT8)&&e.equals(X.FLOAT32)?!0:this.isInteger&&e.isInteger?this.density.valueOf()<=e.density.valueOf()&&this.isUnsigned===e.isUnsigned:!1}canCastTo(e){return this.isNumeric&&e.isNumeric?!0:this.equals(e)}checkArray(e){return e.constructor===this.Array}toJSON(){return this.toString()}get usesBigInt(){return X.BIG_INT_TYPES.some(e=>e.equals(this))}};y(b,"UNKNOWN",new b("unknown")),y(b,"FLOAT64",new b("float64")),y(b,"FLOAT32",new b("float32")),y(b,"INT64",new b("int64")),y(b,"INT32",new b("int32")),y(b,"INT16",new b("int16")),y(b,"INT8",new b("int8")),y(b,"UINT64",new b("uint64")),y(b,"UINT32",new b("uint32")),y(b,"UINT16",new b("uint16")),y(b,"UINT8",new b("uint8")),y(b,"BOOLEAN",b.UINT8),y(b,"TIMESTAMP",new b("timestamp")),y(b,"UUID",new b("uuid")),y(b,"STRING",new b("string")),y(b,"JSON",new b("json")),y(b,"ARRAY_CONSTRUCTORS",new Map([[b.UINT8.toString(),Uint8Array],[b.UINT16.toString(),Uint16Array],[b.UINT32.toString(),Uint32Array],[b.UINT64.toString(),BigUint64Array],[b.FLOAT32.toString(),Float32Array],[b.FLOAT64.toString(),Float64Array],[b.INT8.toString(),Int8Array],[b.INT16.toString(),Int16Array],[b.INT32.toString(),Int32Array],[b.INT64.toString(),BigInt64Array],[b.TIMESTAMP.toString(),BigInt64Array],[b.STRING.toString(),Uint8Array],[b.JSON.toString(),Uint8Array],[b.UUID.toString(),Uint8Array]])),y(b,"ARRAY_CONSTRUCTOR_DATA_TYPES",new Map([[Uint8Array.name,b.UINT8],[Uint16Array.name,b.UINT16],[Uint32Array.name,b.UINT32],[BigUint64Array.name,b.UINT64],[Float32Array.name,b.FLOAT32],[Float64Array.name,b.FLOAT64],[Int8Array.name,b.INT8],[Int16Array.name,b.INT16],[Int32Array.name,b.INT32],[BigInt64Array.name,b.INT64]])),y(b,"DENSITIES",new Map([[b.UINT8.toString(),ge.BIT8],[b.UINT16.toString(),ge.BIT16],[b.UINT32.toString(),ge.BIT32],[b.UINT64.toString(),ge.BIT64],[b.FLOAT32.toString(),ge.BIT32],[b.FLOAT64.toString(),ge.BIT64],[b.INT8.toString(),ge.BIT8],[b.INT16.toString(),ge.BIT16],[b.INT32.toString(),ge.BIT32],[b.INT64.toString(),ge.BIT64],[b.TIMESTAMP.toString(),ge.BIT64],[b.STRING.toString(),ge.UNKNOWN],[b.JSON.toString(),ge.UNKNOWN],[b.UUID.toString(),ge.BIT128]])),y(b,"ALL",[b.UNKNOWN,b.FLOAT64,b.FLOAT32,b.INT64,b.INT32,b.INT16,b.INT8,b.UINT64,b.UINT32,b.UINT16,b.UINT8,b.TIMESTAMP,b.UUID,b.STRING,b.JSON]),y(b,"BIG_INT_TYPES",[b.INT64,b.UINT64,b.TIMESTAMP]),y(b,"z",i.z.union([i.z.string().transform(r=>new b(r)),i.z.instanceof(b)]));let R=b;const de=class re extends Number{constructor(e){super(e.valueOf())}largerThan(e){return this.valueOf()>e.valueOf()}smallerThan(e){return this.valueOf()<e.valueOf()}add(e){return re.bytes(this.valueOf()+e.valueOf())}sub(e){return re.bytes(this.valueOf()-e.valueOf())}truncate(e){return new re(Math.trunc(this.valueOf()/e.valueOf())*e.valueOf())}remainder(e){return re.bytes(this.valueOf()%e.valueOf())}get gigabytes(){return this.valueOf()/re.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/re.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/re.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/re.TERABYTE.valueOf()}toString(){const e=this.truncate(re.TERABYTE),t=this.truncate(re.GIGABYTE),s=this.truncate(re.MEGABYTE),n=this.truncate(re.KILOBYTE),a=this.truncate(re.BYTE),o=e,u=t.sub(e),l=s.sub(t),h=n.sub(s),f=a.sub(n);let d="";return o.isZero||(d+=`${o.terabytes}TB `),u.isZero||(d+=`${u.gigabytes}GB `),l.isZero||(d+=`${l.megabytes}MB `),h.isZero||(d+=`${h.kilobytes}KB `),(!f.isZero||d==="")&&(d+=`${f.valueOf()}B`),d.trim()}static bytes(e=1){return new re(e)}static kilobytes(e=1){return re.bytes(e.valueOf()*1e3)}static megabytes(e=1){return re.kilobytes(e.valueOf()*1e3)}static gigabytes(e=1){return re.megabytes(e.valueOf()*1e3)}static terabytes(e){return re.gigabytes(e.valueOf()*1e3)}get isZero(){return this.valueOf()===0}};y(de,"BYTE",new de(1)),y(de,"KILOBYTE",de.kilobytes(1)),y(de,"MEGABYTE",de.megabytes(1)),y(de,"GIGABYTE",de.gigabytes(1)),y(de,"TERABYTE",de.terabytes(1)),y(de,"ZERO",new de(0)),y(de,"z",i.z.union([i.z.number().transform(r=>new de(r)),i.z.instanceof(de)]));let ut=de;i.z.union([i.z.instanceof(Uint8Array),i.z.instanceof(Uint16Array),i.z.instanceof(Uint32Array),i.z.instanceof(BigUint64Array),i.z.instanceof(Float32Array),i.z.instanceof(Float64Array),i.z.instanceof(Int8Array),i.z.instanceof(Int16Array),i.z.instanceof(Int32Array),i.z.instanceof(BigInt64Array)]);const ul=r=>{const e=typeof r;return e==="string"||e==="number"||e==="boolean"||e==="bigint"||r instanceof $||r instanceof x||r instanceof Date},mp=(r,e,t,s=0)=>r.usesBigInt&&!e.usesBigInt?Number(t)-Number(s):!r.usesBigInt&&e.usesBigInt?BigInt(t.valueOf())-BigInt(s.valueOf()):Lt(t,-s).valueOf(),wp=r=>r==null?!1:Array.isArray(r)||r instanceof ArrayBuffer||ArrayBuffer.isView(r)&&!(r instanceof DataView)||r instanceof He?!0:ul(r),Le=-1,kn={[Symbol.iterator]:()=>kn,next:()=>({done:!0,value:void 0})},bp=i.z.string().transform(r=>new Uint8Array(atob(r).split("").map(e=>e.charCodeAt(0))).buffer),vp=i.z.union([i.z.null(),i.z.undefined()]).transform(()=>new Uint8Array().buffer),Cn=10,Ut=class Ce{constructor(e){y(this,"key",""),y(this,"isSynnaxSeries",!0),y(this,"dataType"),y(this,"sampleOffset"),y(this,"gl"),y(this,"_data"),y(this,"_timeRange"),y(this,"alignment",0n),y(this,"_cachedMin"),y(this,"_cachedMax"),y(this,"writePos",Le),y(this,"_refCount",0),y(this,"_cachedLength"),y(this,"_cachedIndexes"),wp(e)&&(e={data:e});const{dataType:t,timeRange:s,sampleOffset:n=0,glBufferUsage:a="static",alignment:o=0n,key:u=ol()}=e,l=e.data??[];if(l instanceof Ce||typeof l=="object"&&"isSynnaxSeries"in l&&l.isSynnaxSeries===!0){const d=l;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._cachedMin=d._cachedMin,this._cachedMax=d._cachedMax,this.writePos=d.writePos,this._refCount=d._refCount,this._cachedLength=d._cachedLength;return}const h=ul(l),f=Array.isArray(l);if(t!=null)this.dataType=new R(t);else{if(l 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=l;if(!h){if(l.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=l[0]}if(typeof d=="string")this.dataType=R.STRING;else if(typeof d=="number")this.dataType=R.FLOAT64;else if(typeof d=="bigint")this.dataType=R.INT64;else if(typeof d=="boolean")this.dataType=R.BOOLEAN;else if(d instanceof $||d instanceof Date||d instanceof $)this.dataType=R.TIMESTAMP;else if(typeof d=="object")this.dataType=R.JSON;else throw new Error(`cannot infer data type of ${typeof d} when constructing a Series from a JS array`)}else this.dataType=new R(l)}if(!f&&!h)this._data=l;else{let d=h?[l]:l;const I=d[0];(I instanceof $||I instanceof Date||I instanceof x)&&(d=d.map(j=>new $(j).valueOf())),this.dataType.equals(R.STRING)?(this._cachedLength=d.length,this._data=new TextEncoder().encode(`${d.join(`
|
|
30
|
-
`)}
|
|
31
|
-
`).buffer):this.dataType.equals(R.JSON)?(this._cachedLength=d.length,this._data=new TextEncoder().encode(`${d.map(j=>at.encodeString(j)).join(`
|
|
32
|
-
`)}
|
|
33
|
-
`).buffer):this._data=new this.dataType.Array(d).buffer}this.key=u,this.alignment=o,this.sampleOffset=n??0,this._timeRange=s,this.gl={control:null,buffer:null,prevBuffer:0,bufferUsage:a}}static alloc({capacity:e,dataType:t,...s}){if(e===0)throw new Error("[Series] - cannot allocate an array of length 0");const n=new new R(t).Array(e),a=new Ce({data:n.buffer,dataType:t,...s});return a.writePos=0,a}static generateTimestamps(e,t,s){const n=s.spanRange(t.span(e)),a=new BigInt64Array(e);for(let o=0;o<e;o++)a[o]=BigInt(s.add(t.span(o)).valueOf());return new Ce({data:a,dataType:R.TIMESTAMP,timeRange:n})}get refCount(){return this._refCount}static fromStrings(e,t){const s=new TextEncoder().encode(`${e.join(`
|
|
34
|
-
`)}
|
|
35
|
-
`);return new Ce({data:s,dataType:R.STRING,timeRange:t})}static fromJSON(e,t){const s=new TextEncoder().encode(`${e.map(n=>at.encodeString(n)).join(`
|
|
36
|
-
`)}
|
|
37
|
-
`);return new Ce({data:s,dataType:R.JSON,timeRange:t})}acquire(e){this._refCount++,e!=null&&this.updateGLBuffer(e)}release(){if(this._refCount--,this._refCount===0&&this.gl.control!=null)this.maybeGarbageCollectGLBuffer(this.gl.control);else if(this._refCount<0)throw new Error("cannot release an array with a negative reference count")}write(e){if(!e.dataType.equals(this.dataType))throw new Error("buffer must be of the same type as this array");return this.dataType.isVariable?this.writeVariable(e):this.writeFixed(e)}writeVariable(e){if(this.writePos===Le)return 0;const t=this.byteCapacity.valueOf()-this.writePos,s=e.subBytes(0,t);return this.writeToUnderlyingData(s),this.writePos+=s.byteLength.valueOf(),this._cachedLength!=null&&(this._cachedLength+=s.length,this.calculateCachedLength()),s.length}writeFixed(e){if(this.writePos===Le)return 0;const t=this.capacity-this.writePos,s=e.sub(0,t);return this.writeToUnderlyingData(s),this._cachedLength=void 0,this.maybeRecomputeMinMax(s),this.writePos+=s.length,s.length}writeToUnderlyingData(e){this.underlyingData.set(e.data,this.writePos)}get buffer(){return typeof this._data=="object"&&"buffer"in this._data?this._data.buffer:this._data}get underlyingData(){return new this.dataType.Array(this._data)}get data(){return this.writePos===Le?this.underlyingData:new this.dataType.Array(this._data,0,this.writePos)}toStrings(){if(!this.dataType.matches(R.STRING,R.UUID))throw new Error("cannot convert non-string series to strings");return new TextDecoder().decode(this.underlyingData).split(`
|
|
38
|
-
`).slice(0,-1)}toUUIDs(){if(!this.dataType.equals(R.UUID))throw new Error("cannot convert non-uuid series to uuids");const e=R.UUID.density.valueOf(),t=Array(this.length);for(let s=0;s<this.length;s++){const n=this.underlyingData.slice(s*e,(s+1)*e),a=Array.from(new Uint8Array(n.buffer),o=>o.toString(16).padStart(2,"0")).join("").replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/,"$1-$2-$3-$4-$5");t[s]=a}return t}parseJSON(e){if(!this.dataType.equals(R.JSON))throw new Error("cannot parse non-JSON series as JSON");return new TextDecoder().decode(this.underlyingData).split(`
|
|
39
|
-
`).slice(0,-1).map(t=>e.parse(at.decodeString(t)))}get timeRange(){if(this._timeRange==null)throw new Error("time range not set on series");return this._timeRange}get byteCapacity(){return new ut(this.underlyingData.byteLength)}get capacity(){return this.dataType.isVariable?this.byteCapacity.valueOf():this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===Le?this.byteCapacity:this.dataType.isVariable?new ut(this.writePos):this.dataType.density.size(this.writePos)}get length(){return this._cachedLength!=null?this._cachedLength:this.dataType.isVariable?this.calculateCachedLength():this.writePos===Le?this.data.length:this.writePos}calculateCachedLength(){if(!this.dataType.isVariable)throw new Error("cannot calculate length of a non-variable length data type");let e=0;const t=[0];return this.data.forEach((s,n)=>{s===Cn&&(e++,t.push(n+1))}),this._cachedIndexes=t,this._cachedLength=e,e}convert(e,t=0){if(this.dataType.equals(e))return this;const s=new e.Array(this.length);for(let n=0;n<this.length;n++)s[n]=mp(this.dataType,e,this.data[n],t);return new Ce({data:s.buffer,dataType:e,timeRange:this._timeRange,sampleOffset:t,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment})}calcRawMax(){if(this.length===0)return-1/0;if(this.dataType.equals(R.TIMESTAMP))this._cachedMax=this.data[this.data.length-1];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMax=e.reduce((t,s)=>t>s?t:s)}else{const e=this.data;this._cachedMax=e.reduce((t,s)=>t>s?t:s)}return this._cachedMax}get max(){if(this.dataType.isVariable)throw new Error("cannot calculate maximum on a variable length data type");return this.writePos===0?-1/0:(this._cachedMax??(this._cachedMax=this.calcRawMax()),Lt(this._cachedMax,this.sampleOffset))}calcRawMin(){if(this.length===0)return 1/0;if(this.dataType.equals(R.TIMESTAMP))this._cachedMin=this.data[0];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMin=e.reduce((t,s)=>t<s?t:s)}else{const e=this.data;this._cachedMin=e.reduce((t,s)=>t<s?t:s)}return this._cachedMin}get min(){if(this.dataType.isVariable)throw new Error("cannot calculate minimum on a variable length data type");return this.writePos===0?1/0:(this._cachedMin??(this._cachedMin=this.calcRawMin()),Lt(this._cachedMin,this.sampleOffset))}get bounds(){return ye(Number(this.min),Number(this.max))}maybeRecomputeMinMax(e){if(this._cachedMin!=null){const t=e._cachedMin??e.calcRawMin();t<this._cachedMin&&(this._cachedMin=t)}if(this._cachedMax!=null){const t=e._cachedMax??e.calcRawMax();t>this._cachedMax&&(this._cachedMax=t)}}enrich(){this.max,this.min}get range(){return Lt(this.max,-this.min)}atAlignment(e,t){const s=Number(e-this.alignment);if(s<0||s>=this.length){if(t===!0)throw new Error(`[series] - no value at index ${s}`);return}return this.at(s,t)}at(e,t){if(this.dataType.isVariable)return this.atVariable(e,t??!1);e<0&&(e=this.length+e);const s=this.data[e];if(s==null){if(t===!0)throw new Error(`[series] - no value at index ${e}`);return}return Lt(s,this.sampleOffset)}atVariable(e,t){let s=0,n=0;if(this._cachedIndexes!=null)s=this._cachedIndexes[e],n=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]===Cn){if(e===0){n=o;break}s=o+1,e--}if(n===0&&(n=this.data.length),s>=n||e>0){if(t)throw new Error(`[series] - no value at index ${e}`);return}}const a=this.data.slice(s,n);return this.dataType.equals(R.STRING)?new TextDecoder().decode(a):Ko(JSON.parse(new TextDecoder().decode(a)))}binarySearch(e){let t=0,s=this.length-1;const n=Ef(e);for(;t<=s;){const a=Math.floor((t+s)/2),o=n(this.at(a,!0),e);if(o===0)return a;o<0?t=a+1:s=a-1}return t}updateGLBuffer(e){if(this.gl.control=e,!this.dataType.equals(R.FLOAT32)&&!this.dataType.equals(R.UINT8))throw new Error("Only FLOAT32 and UINT8 arrays can be used in WebGL");const{buffer:t,bufferUsage:s,prevBuffer:n}=this.gl;if(t==null&&(this.gl.buffer=e.createBuffer()),this.writePos!==n)if(e.bindBuffer(e.ARRAY_BUFFER,this.gl.buffer),this.writePos!==Le){n===0&&e.bufferData(e.ARRAY_BUFFER,this.byteCapacity.valueOf(),e.STATIC_DRAW);const a=this.dataType.density.size(n).valueOf(),o=this.underlyingData.slice(this.gl.prevBuffer,this.writePos);e.bufferSubData(e.ARRAY_BUFFER,a,o.buffer),this.gl.prevBuffer=this.writePos}else e.bufferData(e.ARRAY_BUFFER,this.buffer,s==="static"?e.STATIC_DRAW:e.DYNAMIC_DRAW),this.gl.prevBuffer=Le}as(e){if(e==="string"){if(!this.dataType.equals(R.STRING))throw new Error(`cannot convert series of type ${this.dataType.toString()} to string`);return this}if(e==="number"){if(!this.dataType.isNumeric)throw new Error(`cannot convert series of type ${this.dataType.toString()} to number`);return this}if(e==="bigint"){if(!this.dataType.equals(R.INT64))throw new Error(`cannot convert series of type ${this.dataType.toString()} to bigint`);return this}throw new Error(`cannot convert series to ${e}`)}get digest(){var e;return{key:this.key,dataType:this.dataType.toString(),sampleOffset:this.sampleOffset,alignment:{lower:ba(this.alignmentBounds.lower),upper:ba(this.alignmentBounds.upper)},timeRange:(e=this._timeRange)==null?void 0:e.toString(),length:this.length,capacity:this.capacity}}get memInfo(){return{key:this.key,length:this.length,byteLength:this.byteLength,glBuffer:this.gl.buffer!=null}}get alignmentBounds(){return ye(this.alignment,this.alignment+BigInt(this.length))}maybeGarbageCollectGLBuffer(e){this.gl.buffer!=null&&(e.deleteBuffer(this.gl.buffer),this.gl.buffer=null,this.gl.prevBuffer=0,this.gl.control=null)}get glBuffer(){if(this.gl.buffer==null)throw new Error("gl buffer not initialized");return this.gl.prevBuffer!==this.writePos&&console.warn("buffer not updated"),this.gl.buffer}[Symbol.iterator](){if(this.dataType.isVariable){const e=new Tp(this);return this.dataType.equals(R.JSON)?new Op(e):e}return new Sp(this)}slice(e,t){return this.sliceSub(!1,e,t)}sub(e,t){return this.sliceSub(!0,e,t)}subIterator(e,t){return new da(this,e,t??this.length)}subAlignmentIterator(e,t){return new da(this,Number(e-this.alignment),Number(t-this.alignment))}subBytes(e,t){if(e>=0&&(t==null||t>=this.byteLength.valueOf()))return this;const s=this.data.subarray(e,t);return new Ce({data:s,dataType:this.dataType,timeRange:this._timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(e)})}sliceSub(e,t,s){if(t<=0&&(s==null||s>=this.length))return this;let n;return e?n=this.data.subarray(t,s):n=this.data.slice(t,s),new Ce({data:n,dataType:this.dataType,timeRange:this._timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(t)})}reAlign(e){return new Ce({data:this.buffer,dataType:this.dataType,timeRange:oe.ZERO,sampleOffset:this.sampleOffset,glBufferUsage:"static",alignment:e})}};y(Ut,"crudeZ",i.z.object({timeRange:oe.z.optional(),dataType:R.z,alignment:up.optional(),data:i.z.union([bp,vp,i.z.instanceof(ArrayBuffer),i.z.instanceof(Uint8Array)]),glBufferUsage:gp.optional().default("static").optional()})),y(Ut,"z",Ut.crudeZ.transform(r=>new Ut(r)));let He=Ut,da=class{constructor(r,e,t){y(this,"series"),y(this,"end"),y(this,"index"),this.series=r;const s=ye(0,r.length);this.end=oa(s,t),this.index=oa(s,e)}next(){return this.index>=this.end?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}[Symbol.iterator](){return this}};class Tp{constructor(e){if(y(this,"series"),y(this,"index"),y(this,"decoder"),!e.dataType.isVariable)throw new Error("cannot create a variable series iterator for a non-variable series");this.series=e,this.index=0,this.decoder=new TextDecoder}next(){const e=this.index,t=this.series.data;for(;this.index<t.length&&t[this.index]!==Cn;)this.index++;const s=this.index;return e===s?{done:!0,value:void 0}:(this.index++,{done:!1,value:this.decoder.decode(this.series.buffer.slice(e,s))})}[Symbol.iterator](){return this}}var fa,pa;class Op{constructor(e){y(this,"wrapped"),y(this,fa,"JSONSeriesIterator"),this.wrapped=e}next(){const e=this.wrapped.next();return e.done===!0?{done:!0,value:void 0}:{done:!1,value:at.decodeString(e.value)}}[(pa=Symbol.iterator,fa=Symbol.toStringTag,pa)](){return this}}var ga,ya;class Sp{constructor(e){y(this,"series"),y(this,"index"),y(this,ga,"SeriesIterator"),this.series=e,this.index=0}next(){return this.index>=this.series.length?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}[(ya=Symbol.iterator,ga=Symbol.toStringTag,ya)](){return this}}const Lt=(r,e)=>typeof r=="bigint"&&typeof e=="bigint"||typeof r=="number"&&typeof e=="number"?r+e:e===0?r:r===0?e:Number(r)+Number(e);class zp{constructor(e){if(y(this,"series"),e.length!==0){const t=e[0].dataType;for(let s=1;s<e.length;s++)if(!e[s].dataType.equals(t))throw new Error("[multi-series] - series must have the same data type")}this.series=e}as(e){if(!new R(e).equals(this.dataType))throw new Error(`cannot convert series of type ${this.dataType.toString()} to ${e.toString()}`);return this}get dataType(){return this.series.length===0?R.UNKNOWN:this.series[0].dataType}get timeRange(){return this.series.length===0?oe.ZERO:new oe(this.series[0].timeRange.start,this.series[this.series.length-1].timeRange.end)}get alignment(){return this.series.length===0?0n:this.series[0].alignment}get alignmentBounds(){return this.series.length===0?ye(0n,0n):ye(this.series[0].alignmentBounds.lower,this.series[this.series.length-1].alignmentBounds.upper)}push(e){this.series.push(e)}get length(){return this.series.reduce((e,t)=>e+t.length,0)}atAlignment(e,t){if(this.series.length===0){if(t)throw new Error(`[series] - no value at alignment ${e}`);return}for(const s of this.series)if(vr(s.alignmentBounds,e))return s.atAlignment(e,t);if(t)throw new Error(`[series] - no value at alignment ${e}`)}at(e,t=!1){e<0&&(e=this.length+e);for(const s of this.series){if(e<s.length)return s.at(e,t);e-=s.length}if(t)throw new Error(`[series] - no value at index ${e}`)}subIterator(e,t){return new Ws(this,e,t??this.length)}subAlignmentIterator(e,t){if(e>=this.alignmentBounds.upper||t<=this.alignmentBounds.lower)return kn;let s=0;for(let a=0;a<this.series.length;a++){const o=this.series[a];if(e<o.alignment)break;if(e>=o.alignmentBounds.upper)s+=o.length;else if(vr(o.alignmentBounds,e)){s+=Number(e-o.alignment);break}}let n=0;for(let a=0;a<this.series.length;a++){const o=this.series[a];if(t<o.alignment)break;if(t>=o.alignmentBounds.upper)n+=o.length;else if(vr(o.alignmentBounds,t)){n+=Number(t-o.alignment);break}}return new Ws(this,s,n)}subAlignmentSpanIterator(e,t){if(e>=this.alignmentBounds.upper)return kn;let s=0;for(let n=0;n<this.series.length;n++){const a=this.series[n];if(e<a.alignment)break;if(e>=a.alignmentBounds.upper)s+=a.length;else if(vr(a.alignmentBounds,e)){s+=Number(e-a.alignment);break}}return new Ws(this,s,s+t)}get byteLength(){return new ut(this.series.reduce((e,t)=>e+t.byteLength.valueOf(),0))}get data(){const e=new this.dataType.Array(this.length);let t=0;for(const s of this.series)e.set(s.data,t),t+=s.length;return new this.dataType.Array(e.buffer)}traverseAlignment(e,t){const s=this.series.map(n=>n.alignmentBounds);return Gf(s,e,t)}distance(e,t){const s=this.series.map(n=>n.alignmentBounds);return Wf(s,e,t)}parseJSON(e){if(!this.dataType.equals(R.JSON))throw new Error("cannot parse non-JSON series as JSON");return this.series.flatMap(t=>t.parseJSON(e))}[Symbol.iterator](){return this.series.length===0?{next(){return{done:!0,value:void 0}}}:new Np(this.series)}}var ma,wa;class Np{constructor(e){y(this,"series"),y(this,"seriesIndex"),y(this,"internal"),y(this,ma,"MultiSeriesIterator"),this.series=e,this.seriesIndex=0,this.internal=e[0][Symbol.iterator]()}next(){const e=this.internal.next();return e.done===!1?e:this.seriesIndex===this.series.length-1?{done:!0,value:void 0}:(this.internal=this.series[++this.seriesIndex][Symbol.iterator](),this.next())}[(wa=Symbol.iterator,ma=Symbol.toStringTag,wa)](){return this}}class Ws{constructor(e,t,s){y(this,"series"),y(this,"index"),y(this,"end"),this.series=e,this.end=s,this.index=t}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 ba=r=>{const e=r>>32n,t=r&0xffffffffn;return{domain:e,sample:t}},Ep=(r,e)=>{let t=null;return e===0?r:(...s)=>{t!==null&&(clearTimeout(t),t=null),t=setTimeout(()=>r(...s),e)}};i.z.object({key:i.z.string(),value:i.z.string()});var Ip=Object.defineProperty,xp=(r,e,t)=>e in r?Ip(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,_r=(r,e,t)=>xp(r,typeof e!="symbol"?e+"":e,t);let Ap=class{constructor(r,e){_r(this,"handlers"),_r(this,"transform"),_r(this,"closer"),this.transform=r,this.handlers=e??new Map}onChange(r){return this.handlers.set(r,null),()=>this.handlers.delete(r)}notify(r){let e=r;if(this.transform!=null){const[t,s]=this.transform(r);if(!s)return;e=t}this.handlers.forEach((t,s)=>s(e))}setCloser(r){this.closer=r}async close(){var r;return await((r=this.closer)==null?void 0:r.call(this))}},kp=class{constructor(r){_r(this,"handlers"),this.handlers=r??new Map}onChange(r){return this.handlers.set(r,null),()=>this.handlers.delete(r)}notify(r){this.handlers.forEach((e,t)=>t(r))}};const et=Object.freeze(Object.defineProperty({__proto__:null,BaseObserver:kp,Observer:Ap},Symbol.toStringTag,{value:"Module"})),cr=i.z.record(i.z.union([i.z.number(),i.z.string(),i.z.symbol()]),i.z.unknown()),Cp=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser";Cp();const Rp=["macOS","Windows","Linux"],$p=["macos","windows","linux"],Mp={macos:"macOS",windows:"Windows",linux:"Linux"};i.z.enum(Rp).or(i.z.enum($p).transform(r=>Mp[r]));var jp=Object.defineProperty,Bp=(r,e,t)=>e in r?jp(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,_t=(r,e,t)=>Bp(r,typeof e!="symbol"?e+"":e,t);const Pp=(...r)=>r.map(cl).join(""),cl=r=>(r.endsWith("/")||(r+="/"),r.startsWith("/")&&(r=r.slice(1)),r),Dp=r=>r.endsWith("/")?r.slice(0,-1):r,Rn=class $n{constructor({host:e,port:t,protocol:s="",pathPrefix:n=""}){_t(this,"protocol"),_t(this,"host"),_t(this,"port"),_t(this,"path"),this.protocol=s,this.host=e,this.port=t,this.path=cl(n)}replace(e){return new $n({host:e.host??this.host,port:e.port??this.port,protocol:e.protocol??this.protocol,pathPrefix:e.pathPrefix??this.path})}child(e){return new $n({...this,pathPrefix:Pp(this.path,e)})}toString(){return Dp(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}};_t(Rn,"UNKNOWN",new Rn({host:"unknown",port:0}));let Up=Rn;var Lp=Object.defineProperty,_p=(r,e,t)=>e in r?Lp(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,qr=(r,e,t)=>_p(r,typeof e!="symbol"?e+"":e,t);const qp=async r=>await new Promise(e=>setTimeout(e,x.fromMilliseconds(r).milliseconds)),Yp=i.z.object({interval:x.z.optional(),maxRetries:i.z.number().optional(),scale:i.z.number().optional()}),Fp=(r={})=>{const e=r.sleepFn||qp,t=r.maxRetries??5,s=r.scale??1;let n=0,a=new x(r.interval??x.milliseconds(1));return async()=>n>=t?!1:(await e(a),a=a.mult(s),n++,!0)},Vp=Object.freeze(Object.defineProperty({__proto__:null,breakerConfig:Yp,create:Fp},Symbol.toStringTag,{value:"Module"})),Ke=class extends Number{};qr(Ke,"Absolute",255),qr(Ke,"Default",1),qr(Ke,"z",i.z.union([i.z.instanceof(Ke),i.z.number().int().min(0).max(255).transform(r=>new Ke(r)),i.z.instanceof(Number).transform(r=>new Ke(r))]));let hl=Ke;const dl=i.z.object({name:i.z.string(),key:i.z.string()}),Gp=r=>i.z.object({subject:dl,resource:r,authority:hl.z}),Wp=(...r)=>e=>e.filter(t=>{let s=!1;return t.to!=null&&(s=r.includes(t.to.resource)),t.from!=null&&!s&&(s=r.includes(t.from.resource)),s}),ct=Object.freeze(Object.defineProperty({__proto__:null,Authority:hl,filterTransfersByChannelKey:Wp,stateZ:Gp,subjectZ:dl},Symbol.toStringTag,{value:"Module"})),fl=class qt extends Error{constructor(){super(qt.MESSAGE)}matches(e){return typeof e=="string"?e.includes(qt.MESSAGE):e instanceof qt||e.message.includes(qt.MESSAGE)}};qr(fl,"MESSAGE","canceled");let Zp=fl;new Zp;const Mn=i.z.string().regex(/^\d+\.\d+\.\d+$/),hr=(r,e,t={})=>{t.checkMajor??(t.checkMajor=!0),t.checkMinor??(t.checkMinor=!0),t.checkPatch??(t.checkPatch=!0);const s=Mn.parse(r),n=Mn.parse(e),[a,o,u]=s.split(".").map(Number),[l,h,f]=n.split(".").map(Number);if(t.checkMajor){if(a<l)return qs;if(a>l)return Ys}if(t.checkMinor){if(o<h)return qs;if(o>h)return Ys}if(t.checkPatch){if(u<f)return qs;if(u>f)return Ys}return Ts},Jp=(r,e,t={})=>kf(hr(r,e,t)),pl=(r,e,t={})=>Af(hr(r,e,t)),Kp=(r,e,t={})=>xf(hr(r,e,t)),Hp=({name:r,migrate:e})=>t=>{try{const s=e(t);return console.log(`${r} migrated: ${t.version} -> ${s.version}`),s}catch(s){throw console.log(`${r} failed to migrate from ${t.version}`),console.error(s),s}},Xp=({name:r,migrations:e,targetSchema:t,defaultVersion:s,def:n})=>{const a=Object.keys(e).sort(hr).pop();if(a==null)return h=>{if(h.version??(h.version=s),h.version!==n.version)return console.log(`${r} version ${h.version} is newer than latest version of ${n.version}.
|
|
40
|
-
Returning default instead.
|
|
41
|
-
`),n;try{return t!=null?t.parse(h):h}catch(f){return console.log(`${r} failed to parse default. Exiting with default`),console.error(f),n}};const o=Object.keys(e).length;let u=!1;const l=h=>{try{if(o===0||pl(h.version,a))return console.log(u?`${r} ${h.version} now up to date`:`${r} version ${h.version} is up to date with target version ${n.version}`),h;const f=h.version,d=e[f],I=d(h);return u=!0,l(I)}catch(f){return console.log(`${r} failed to migrate from ${h.version} to ${a}`),console.error(f),n}};return h=>{try{if(h.version==null)if(s!=null)console.log(`${r} version is null. Setting version to default of ${s}`),h.version=s;else return console.log(`${r} version is null and no default version set. Exiting with default`),n;return l(h)}catch(f){return console.log(`${r} failed to parse final result. Exiting with default`),console.error(f),n}}},va=Object.freeze(Object.defineProperty({__proto__:null,compareSemVer:hr,createMigration:Hp,migrator:Xp,semVerNewer:pl,semVerOlder:Kp,semVerZ:Mn,versionsEqual:Jp},Symbol.toStringTag,{value:"Module"})),Qp=(r,e="")=>{const t=r.length;return t===0?e:t===1?r[0]:t===2?`${r[0]} and ${r[1]}`:`${r.slice(0,-1).join(", ")}, and ${r[t-1]}`},eg=r=>{const e=r.split(" "),t=new Set,s=e.map(o=>o.charAt(0).toLowerCase()).join("");t.add(s),t.add(s.replace(/(.)(.)/g,"$1_$2"));const n=/\d+/g;r.match(n)&&e.forEach((o,u)=>{if(n.test(o)){const l=e.map((h,f)=>f!==u?h.charAt(0).toLowerCase():h).join("");t.add(l),t.add(l.replace(/(.)(.)/g,"$1_$2"))}});const a=e.map(o=>(o.length>3?o.substring(0,3):o).toLowerCase());return t.add(a.join("")),t.add(a.join("_")),Array.from(t).filter(o=>o.length>=2&&o.length<=12)},tg=Object.freeze(Object.defineProperty({__proto__:null,generateShortIdentifiers:eg,naturalLanguageJoin:Qp},Symbol.toStringTag,{value:"Module"})),Ze="sy.",Yr=class gl extends Ne{constructor(){super(...arguments),c(this,"type",gl.TYPE)}};c(Yr,"TYPE",`${Ze}validation`),c(Yr,"matches",me(Yr.TYPE));let Q=Yr;const Fr=class yl extends Q{constructor(e,t){super(`${e}: ${t}`),c(this,"type",yl.TYPE),c(this,"field"),c(this,"message"),this.field=e,this.message=t}};c(Fr,"TYPE",`${Q.TYPE}.field`),c(Fr,"matches",me(Fr.TYPE));let Ta=Fr;const Vr=class ml extends Ne{constructor(){super(...arguments),c(this,"type",ml.TYPE)}};c(Vr,"TYPE",`${Ze}auth`),c(Vr,"matches",me(Vr.TYPE));let cs=Vr;const Gr=class wl extends cs{constructor(){super(...arguments),c(this,"type",wl.TYPE)}};c(Gr,"TYPE",`${cs.TYPE}.invalid-token`),c(Gr,"matches",me(Gr.TYPE));let jn=Gr;const Wr=class bl extends Ne{constructor(e){super(`
|
|
42
|
-
Unexpected error encountered:
|
|
43
|
-
|
|
44
|
-
${e}
|
|
45
|
-
|
|
46
|
-
Please report this to the Synnax team.
|
|
47
|
-
`),c(this,"type",bl.TYPE)}};c(Wr,"TYPE",`${Ze}unexpected`),c(Wr,"matches",me(Wr.TYPE));let be=Wr;const Zr=class vl extends Ne{constructor(){super(...arguments),c(this,"type",vl.TYPE)}};c(Zr,"TYPE",`${Ze}query`),c(Zr,"matches",me(Zr.TYPE));let ze=Zr;const Jr=class Tl extends ze{constructor(){super(...arguments),c(this,"type",Tl.TYPE)}};c(Jr,"TYPE",`${ze.TYPE}.not_found`),c(Jr,"matches",me(Jr.TYPE));let ht=Jr;const Kr=class Ol extends ze{constructor(){super(...arguments),c(this,"type",Ol.TYPE)}};c(Kr,"TYPE",`${ze.TYPE}.multiple_results`),c(Kr,"matches",me(Kr.TYPE));let dt=Kr;const Hr=class Sl extends Ne{constructor(e,t){super(e),c(this,"type",Sl.TYPE),c(this,"path"),this.path=t}};c(Hr,"TYPE",`${Ze}route`),c(Hr,"matches",me(Hr.TYPE));let Oa=Hr;const Xr=class zl extends Ne{constructor(){super(...arguments),c(this,"type",zl.TYPE)}};c(Xr,"TYPE",`${Ze}control`),c(Xr,"matches",me(Xr.TYPE));let hs=Xr;const Qr=class Nl extends hs{constructor(){super(...arguments),c(this,"type",Nl.TYPE)}};c(Qr,"TYPE",`${hs.TYPE}.unauthorized`),c(Qr,"matches",me(Qr.TYPE));let Sa=Qr;const Zs=class El extends Ne{constructor(){super(...arguments),c(this,"type",El.TYPE)}};c(Zs,"TYPE",`${Ze}contiguity`),c(Zs,"matches",me(Zs.TYPE));const rg=r=>{if(!r.type.startsWith(Ze))return null;if(r.type.startsWith(Q.TYPE)){if(r.type===Ta.TYPE){const e=r.data.split(": ");return e.length<2?new Q(r.data):new Ta(e[0],e[1])}return new Q(r.data)}return r.type.startsWith(cs.TYPE)?r.type.startsWith(jn.TYPE)?new jn(r.data):new cs(r.data):r.type.startsWith(be.TYPE)?new be(r.data):r.type.startsWith(ze.TYPE)?r.type.startsWith(ht.TYPE)?new ht(r.data):r.type.startsWith(dt.TYPE)?new dt(r.data):new ze(r.data):r.type.startsWith(hs.TYPE)?r.type.startsWith(Sa.TYPE)?new Sa(r.data):new hs(r.data):r.type.startsWith(Oa.TYPE)?new Oa(r.data,r.data):new be(r.data)},sg=()=>{throw new Error("Not implemented")};_o({encode:sg,decode:rg});const ng=async(r,e)=>{const[t,s]=await e(r);return s==null?[t,s]:s instanceof We?[t,new We({message:`Cannot reach cluster at ${s.url.host}:${s.url.port}`,url:s.url})]:[t,s]},ig=i.z.string().uuid(),Il=i.z.object({key:ig,name:i.z.string()}),ag="group",og=r=>new P({type:ag,key:r});class xl{constructor(e,t){c(this,"key"),c(this,"name"),this.key=t,this.name=e}get ontologyID(){return og(this.key)}}const Ss=i.z.union([i.z.literal("label"),i.z.literal("log"),i.z.literal("allow_all"),i.z.literal("builtin"),i.z.literal("cluster"),i.z.literal("channel"),i.z.literal("node"),i.z.literal("group"),i.z.literal("range"),i.z.literal("framer"),i.z.literal("range-alias"),i.z.literal("user"),i.z.literal("workspace"),i.z.literal("schematic"),i.z.literal("lineplot"),i.z.literal("rack"),i.z.literal("device"),i.z.literal("task"),i.z.literal("policy"),i.z.literal("table")]),lg="builtin",ve=i.z.object({type:Ss,key:i.z.string()}),ug=i.z.string().transform(r=>{const[e,t]=r.split(":");return{type:Ss.parse(e),key:t??""}}),Yt=i.z.union([ug,ve]),es=class Al{constructor(e){if(c(this,"type"),c(this,"key"),e instanceof Al){this.type=e.type,this.key=e.key;return}if(typeof e=="string"){const[t,s]=e.split(":");this.type=t,this.key=s??"";return}this.type=e.type,this.key=e.key}toString(){return`${this.type}:${this.key}`}isType(){return this.key===""}matchesType(e){return this.type===e&&this.isType()}get payload(){return{type:this.type,key:this.key}}};c(es,"z",i.z.union([i.z.instanceof(es),Yt.transform(r=>new es(r))]));let P=es;new P({type:lg,key:"root"});const cg=i.z.object({type:i.z.number()}),hg=i.z.object({type:Ss,fields:i.z.record(cg)}),dg=i.z.object({id:P.z,name:i.z.string(),schema:hg.optional().nullable(),data:i.z.record(i.z.unknown()).optional().nullable()}).transform(r=>({key:r.id.toString(),...r}));i.z.object({from:P.z,type:i.z.string(),to:P.z});const za=r=>{const[e,t,s]=r.split("->");return{from:new P(e),type:t,to:new P(s)}},fg=i.z.object({group:Il}),pg=i.z.object({parent:ve,key:i.z.string().uuid().optional(),name:i.z.string()}),gg=i.z.object({key:i.z.string(),name:i.z.string()}),yg=i.z.object({keys:i.z.array(i.z.string())});var _e;let mg=(_e=class{constructor(r){c(this,"client"),this.client=r}async create(r,e,t){return(await T(this.client,_e.ENDPOINT,{parent:r,name:e,key:t},pg,fg)).group}async rename(r,e){await T(this.client,_e.ENDPOINT_RENAME,{key:r,name:e},gg,i.z.object({}))}async delete(r){await T(this.client,_e.ENDPOINT_DELETE,{keys:r},yg,i.z.object({}))}},c(_e,"ENDPOINT","/ontology/create-group"),c(_e,"ENDPOINT_RENAME","/ontology/rename-group"),c(_e,"ENDPOINT_DELETE","/ontology/delete-group"),_e),wg=class{constructor(r){c(this,"creator"),this.creator=new mg(r)}async create(r,e,t){return this.sugar(await this.creator.create(r,e,t))}async rename(r,e){return await this.creator.rename(r,e)}async delete(...r){return await this.creator.delete(r)}sugar(r){return new xl(r.name,r.key)}};const Js={ADD_CHILDREN:"/ontology/add-children",REMOVE_CHILDREN:"/ontology/remove-children",MOVE_CHILDREN:"/ontology/move-children"},Na=i.z.object({id:ve,children:ve.array()}),bg=i.z.object({from:ve,to:ve,children:ve.array()});let vg=class{constructor(r){c(this,"client"),this.client=r}async addChildren(r,...e){await T(this.client,Js.ADD_CHILDREN,{id:new P(r).payload,children:e.map(t=>new P(t).payload)},Na,i.z.object({}))}async removeChildren(r,...e){await T(this.client,Js.REMOVE_CHILDREN,{id:new P(r).payload,children:e.map(t=>new P(t).payload)},Na,i.z.object({}))}async moveChildren(r,e,...t){const s={from:new P(r).payload,to:new P(e).payload,children:t.map(n=>new P(n).payload)};await T(this.client,Js.MOVE_CHILDREN,s,bg,i.z.object({}))}};const Tg="/ontology/retrieve",Og=i.z.object({ids:ve.array().optional(),children:i.z.boolean().optional(),parents:i.z.boolean().optional(),includeSchema:i.z.boolean().optional(),excludeFieldData:i.z.boolean().optional(),term:i.z.string().optional(),limit:i.z.number().optional(),offset:i.z.number().optional(),types:Ss.array().optional()}),Sg=i.z.object({resources:dg.array()}),Ks=r=>O(r).map(e=>new P(e).payload);let zg=class{constructor(r,e){c(this,"type","ontology"),c(this,"groups"),c(this,"client"),c(this,"writer"),c(this,"framer"),this.client=r,this.writer=new vg(r),this.groups=new wg(r),this.framer=e}async search(r,e){return await this.execRetrieve({term:r,...e})}async retrieve(r,e){const t=await this.execRetrieve({ids:Ks(r),...e});if(Array.isArray(r))return t;if(t.length===0)throw new ze(`No resource found with ID ${tg.naturalLanguageJoin(O(r).map(s=>new P(s).toString()))}`);return t[0]}async page(r,e,t){return await this.execRetrieve({offset:r,limit:e,...t})}async retrieveChildren(r,e){return await this.execRetrieve({ids:Ks(r),children:!0,...e})}async retrieveParents(r,e){return await this.execRetrieve({ids:Ks(r),parents:!0,...e})}async addChildren(r,...e){return await this.writer.addChildren(r,...e)}async removeChildren(r,...e){return await this.writer.removeChildren(r,...e)}async moveChildren(r,e,...t){return await this.writer.moveChildren(r,e,...t)}async openChangeTracker(){return await zs.open(this.framer,this)}async openDependentTracker(r){return await ei.open(r,this.framer,this)}newSearcherWithOptions(r){return{type:this.type,search:e=>this.search(e,r),retrieve:e=>this.retrieve(e,r),page:(e,t)=>this.page(e,t,r)}}async execRetrieve(r){const{resources:e}=await T(this.client,Tg,r,Og,Sg);return e}};const Ea="sy_ontology_resource_set",Ia="sy_ontology_resource_delete",xa="sy_ontology_relationship_set",Aa="sy_ontology_relationship_delete";class zs{constructor(e,t){c(this,"relationships"),c(this,"resources"),c(this,"resourceObs"),c(this,"relationshipObs"),c(this,"streamer"),c(this,"client"),c(this,"closePromise"),this.relationshipObs=new et.Observer,this.relationships=this.relationshipObs,this.resourceObs=new et.Observer,this.resources=this.resourceObs,this.client=t,this.streamer=e,this.closePromise=this.start()}async close(){this.streamer.close(),await this.closePromise}async start(){for await(const e of this.streamer)await this.update(e)}async update(e){const t=await this.parseResourceSets(e),s=this.parseResourceDeletes(e);t.concat(s).length>0&&this.resourceObs.notify(t.concat(s));const n=this.parseRelationshipSets(e),a=this.parseRelationshipDeletes(e);n.concat(a).length>0&&this.relationshipObs.notify(n.concat(a))}parseRelationshipSets(e){const t=e.get(xa);return t.length===0?[]:Array.from(t.as("string")).map(s=>({variant:"set",key:za(s),value:void 0}))}parseRelationshipDeletes(e){const t=e.get(Aa);return t.length===0?[]:Array.from(t.as("string")).map(s=>({variant:"delete",key:za(s)}))}async parseResourceSets(e){const t=e.get(Ea);if(t.length===0)return[];const s=Array.from(t.as("string")).map(n=>new P(n));try{return(await this.client.retrieve(s)).map(n=>({variant:"set",key:n.id,value:n}))}catch(n){if(n instanceof ze)return[];throw n}}parseResourceDeletes(e){const t=e.get(Ia);return t.length===0?[]:Array.from(t.as("string")).map(s=>({variant:"delete",key:new P(s)}))}static async open(e,t){const s=await e.openStreamer([Ea,Ia,xa,Aa]);return new zs(s,t)}}const ka=r=>r==="from"?"to":"from";class ei extends et.Observer{constructor({target:e,dependents:t,relationshipType:s="parent",relationshipDirection:n="from",resourceType:a},o,u){super(),c(this,"internal"),c(this,"target"),c(this,"relDir"),c(this,"resourceType"),c(this,"dependents"),c(this,"client"),c(this,"relType"),c(this,"handleResourceChange",l=>{this.dependents=this.dependents.map(h=>{const f=l.find(d=>d.key.toString()==h.id.toString());return f==null||f.variant==="delete"?h:f.value}),this.notify(this.dependents)}),c(this,"handleRelationshipChange",l=>{const h=l.filter(d=>d.variant==="delete"&&d.key[this.relDir].toString()===this.target.toString()&&(this.resourceType==null||d.key[ka(this.relDir)].type===this.resourceType));this.dependents=this.dependents.filter(d=>!h.some(I=>I.key.to.toString()===d.id.toString()&&I.key.type===this.relType));const f=l.filter(d=>d.variant==="set"&&d.key.type===this.relType&&d.key[this.relDir].toString()===this.target.toString()&&(this.resourceType==null||d.key[ka(this.relDir)].type===this.resourceType));if(f.length===0)return this.notify(this.dependents);this.client.retrieve(f.map(d=>d.key.to)).then(d=>{this.dependents=this.dependents.concat(d),this.notify(this.dependents)}).catch(console.error)}),this.resourceType=a,this.internal=o,this.target=e,this.dependents=t,this.resourceType!=null&&(this.dependents=this.dependents.filter(l=>l.id.type===this.resourceType)),this.client=u,this.relType=s,this.relDir=n,this.internal.resources.onChange(this.handleResourceChange),this.internal.relationships.onChange(this.handleRelationshipChange)}static async open(e,t,s){const n=await zs.open(t,s);return new ei(e,n,s)}async close(){await this.internal.close()}}const le=r=>i.z.union([i.z.union([i.z.null(),i.z.undefined()]).transform(()=>[]),r.array()]),Ns=i.z.string().uuid(),Ng=i.z.object({key:Ns.optional(),subjects:Yt.array().or(Yt),objects:Yt.array().or(Yt),actions:In.array().or(In)}),ti=i.z.object({key:Ns,subjects:le(ve),objects:le(ve),actions:le(In)}),Eg="allow_all";new P({type:Eg,key:""});const Ig=i.z.object({keys:Ns.array().optional(),subjects:ve.array().optional()}),xg=i.z.object({policies:le(ti)}),Ag="/access/policy/retrieve";let kg=class{constructor(r){c(this,"client"),this.client=r}async retrieve(r){return(await T(this.client,Ag,r,Ig,xg)).policies}};const Cg=i.z.object({policies:ti.partial({key:!0}).array()}),Rg=i.z.object({policies:ti.array()}),$g=i.z.object({keys:Ns.array()}),Mg=i.z.object({}),jg="/access/policy/create",Bg="/access/policy/delete";let Pg=class{constructor(r){c(this,"client"),this.client=r}async create(r){const e=Ng.array().parse(O(r)).map(t=>({objects:O(t.objects),actions:O(t.actions),subjects:O(t.subjects)}));return(await T(this.client,jg,{policies:e},Cg,Rg)).policies}async delete(r){await T(this.client,Bg,{keys:O(r)},$g,Mg)}},Dg=class{constructor(r){c(this,"retriever"),c(this,"writer"),this.retriever=new kg(r),this.writer=new Pg(r)}async create(r){const e=Array.isArray(r),t=await this.writer.create(r);return e?t:t[0]}async retrieve(r){const e=Array.isArray(r),t=await this.retriever.retrieve({keys:O(r)});return e?t:t[0]}async retrieveFor(r){const e=O(r).map(t=>new P(t).payload);return await this.retriever.retrieve({subjects:e})}async delete(r){await this.writer.delete(r)}},Ug=class{constructor(r){c(this,"policy"),this.policy=new Dg(r)}};const Re=i.z.number(),dr=i.z.object({name:i.z.string(),key:i.z.number(),rate:Qt.z,dataType:R.z,leaseholder:i.z.number(),index:i.z.number(),isIndex:i.z.boolean(),internal:i.z.boolean(),virtual:i.z.boolean(),alias:i.z.string().optional(),expression:i.z.string().default(""),requires:le(Re)}),kl=dr.extend({key:i.z.number().optional(),leaseholder:i.z.number().optional(),index:i.z.number().optional(),rate:Qt.z.optional().default(0),isIndex:i.z.boolean().optional(),internal:i.z.boolean().optional().default(!1),virtual:i.z.boolean().optional().default(!1),expression:i.z.string().optional().default(""),requires:le(Re).optional().default([])}),Cl="channel",Rl=r=>new P({type:Cl,key:r.toString()}),Lg=new Error("request for lock canceled");var _g=function(r,e,t,s){function n(a){return a instanceof t?a:new t(function(o){o(a)})}return new(t||(t=Promise))(function(a,o){function u(f){try{h(s.next(f))}catch(d){o(d)}}function l(f){try{h(s.throw(f))}catch(d){o(d)}}function h(f){f.done?a(f.value):n(f.value).then(u,l)}h((s=s.apply(r,e||[])).next())})};class qg{constructor(e,t=Lg){this._value=e,this._cancelError=t,this._queue=[],this._weightedWaiters=[]}acquire(e=1,t=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return new Promise((s,n)=>{const a={resolve:s,reject:n,weight:e,priority:t},o=$l(this._queue,u=>t<=u.priority);o===-1&&e<=this._value?this._dispatchItem(a):this._queue.splice(o+1,0,a)})}runExclusive(e){return _g(this,arguments,void 0,function*(t,s=1,n=0){const[a,o]=yield this.acquire(s,n);try{return yield t(a)}finally{o()}})}waitForUnlock(e=1,t=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return this._couldLockImmediately(e,t)?Promise.resolve():new Promise(s=>{this._weightedWaiters[e-1]||(this._weightedWaiters[e-1]=[]),Yg(this._weightedWaiters[e-1],{resolve:s,priority:t})})}isLocked(){return this._value<=0}getValue(){return this._value}setValue(e){this._value=e,this._dispatchQueue()}release(e=1){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);this._value+=e,this._dispatchQueue()}cancel(){this._queue.forEach(e=>e.reject(this._cancelError)),this._queue=[]}_dispatchQueue(){for(this._drainUnlockWaiters();this._queue.length>0&&this._queue[0].weight<=this._value;)this._dispatchItem(this._queue.shift()),this._drainUnlockWaiters()}_dispatchItem(e){const t=this._value;this._value-=e.weight,e.resolve([t,this._newReleaser(e.weight)])}_newReleaser(e){let t=!1;return()=>{t||(t=!0,this.release(e))}}_drainUnlockWaiters(){if(this._queue.length===0)for(let e=this._value;e>0;e--){const t=this._weightedWaiters[e-1];t&&(t.forEach(s=>s.resolve()),this._weightedWaiters[e-1]=[])}else{const e=this._queue[0].priority;for(let t=this._value;t>0;t--){const s=this._weightedWaiters[t-1];if(!s)continue;const n=s.findIndex(a=>a.priority<=e);(n===-1?s:s.splice(0,n)).forEach(a=>a.resolve())}}}_couldLockImmediately(e,t){return(this._queue.length===0||this._queue[0].priority<t)&&e<=this._value}}function Yg(r,e){const t=$l(r,s=>e.priority<=s.priority);r.splice(t+1,0,e)}function $l(r,e){for(let t=r.length-1;t>=0;t--)if(e(r[t]))return t;return-1}var Fg=function(r,e,t,s){function n(a){return a instanceof t?a:new t(function(o){o(a)})}return new(t||(t=Promise))(function(a,o){function u(f){try{h(s.next(f))}catch(d){o(d)}}function l(f){try{h(s.throw(f))}catch(d){o(d)}}function h(f){f.done?a(f.value):n(f.value).then(u,l)}h((s=s.apply(r,e||[])).next())})};class Vg{constructor(e){this._semaphore=new qg(1,e)}acquire(){return Fg(this,arguments,void 0,function*(e=0){const[,t]=yield this._semaphore.acquire(1,e);return t})}runExclusive(e,t=0){return this._semaphore.runExclusive(()=>e(),1,t)}isLocked(){return this._semaphore.isLocked()}waitForUnlock(e=0){return this._semaphore.waitForUnlock(1,e)}release(){this._semaphore.isLocked()&&this._semaphore.release()}cancel(){return this._semaphore.cancel()}}const Es=(r,e,{convertNumericStrings:t=!0}={})=>{const s=!Array.isArray(r);let n=O(r);const a=n[0],o=typeof a;let u;return o==="string"&&t&&!isNaN(parseInt(a))&&"number"in e?(u=e.number,n=n.map(l=>parseInt(l))):u=e[o],{single:s,variant:u,normalized:n,actual:r}},Is=(r,e,t,s)=>{if(s){if(t.length===0)throw new ht(`${r} not found matching ${JSON.stringify(e)}`);if(t.length>1)throw new dt(`Expected one ${r} matching ${JSON.stringify(e)}, but found ${t.length}`)}},Gg=i.z.object({leaseholder:i.z.number().optional(),keys:i.z.number().array().optional(),names:i.z.string().array().optional(),search:i.z.string().optional(),rangeKey:i.z.string().optional(),limit:i.z.number().optional(),offset:i.z.number().optional(),dataTypes:R.z.array().optional(),notDataTypes:R.z.array().optional(),virtual:i.z.boolean().optional(),isIndex:i.z.boolean().optional(),internal:i.z.boolean().optional()}),Wg=i.z.object({channels:le(dr)}),Pe=r=>Es(r,{number:"keys",string:"names"}),Ml=class jl{constructor(e){c(this,"client"),this.client=e}async search(e,t){return await this.execute({search:e,...t})}async retrieve(e,t){const s=Pe(e),{variant:n}=s;let{normalized:a}=s;return n==="keys"&&a.indexOf(0)!==-1&&(a=a.filter(o=>o!==0)),a.length===0?[]:await this.execute({[n]:a,...t})}async page(e,t,s){return await this.execute({offset:e,limit:t,...s})}async execute(e){const[t,s]=await this.client.send(jl.ENDPOINT,e,Gg,Wg);if(s!=null)throw s;return t.channels}};c(Ml,"ENDPOINT","/channel/retrieve");let ri=Ml;class si{constructor(e){c(this,"cache"),c(this,"namesToKeys"),c(this,"wrapped"),this.cache=new Map,this.namesToKeys=new Map,this.wrapped=e}async search(e,t){return await this.wrapped.search(e,t)}async page(e,t,s){return await this.wrapped.page(e,t,s)}async retrieve(e,t){const{normalized:s}=Es(e,{string:"names",number:"keys"}),n=[],a=[];if(s.forEach(u=>{const l=this.get(u);l!=null?n.push(...l):a.push(u)}),a.length===0)return n;const o=await this.wrapped.retrieve(a,t);return this.set(o),n.concat(o)}delete(e){const{variant:t,normalized:s}=Pe(e);t==="names"?s.forEach(n=>{const a=this.namesToKeys.get(n);a!=null&&(a.forEach(o=>this.cache.delete(o)),this.namesToKeys.delete(n))}):s.forEach(n=>{const a=this.cache.get(n);a!=null&&(this.cache.delete(n),this.namesToKeys.delete(a.name))})}rename(e,t){e.forEach((s,n)=>{const a=t[n],o=this.cache.get(s);if(o==null)return;this.cache.delete(s);const u=this.namesToKeys.get(o.name);u!=null&&(u.delete(s),u.size===0&&this.namesToKeys.delete(o.name)),o.name=a,this.cache.set(s,o);const l=this.namesToKeys.get(a);l==null?this.namesToKeys.set(a,new Set([s])):l.add(s)})}set(e){e.forEach(t=>{this.cache.set(t.key,t);const s=this.namesToKeys.get(t.name);s==null?this.namesToKeys.set(t.name,new Set([t.key])):s.add(t.key)})}get(e){if(typeof e=="number"){const n=this.cache.get(e);return n==null?void 0:[n]}const t=this.namesToKeys.get(e);if(t==null)return;const s=[];if(t.forEach(n=>{const a=this.cache.get(n);a!=null&&s.push(a)}),s.length!==0)return s}}class Bl{constructor(e,t){c(this,"mu",new Vg),c(this,"requests",new Map),c(this,"wrapped"),c(this,"debouncedRun"),this.wrapped=e,this.debouncedRun=Ep(()=>{this.run()},t)}async search(e,t){return await this.wrapped.search(e,t)}async page(e,t,s){return await this.wrapped.page(e,t,s)}async retrieve(e){const{normalized:t,variant:s}=Pe(e);return s==="names"?await this.wrapped.retrieve(t):await new Promise((n,a)=>{this.mu.runExclusive(()=>{this.requests.set(t,{resolve:n,reject:a}),this.debouncedRun()})})}async run(){await this.mu.runExclusive(async()=>{const e=new Set;this.requests.forEach((t,s)=>s.forEach(n=>e.add(n)));try{const t=await this.wrapped.retrieve(Array.from(e));this.requests.forEach((s,n)=>s.resolve(t.filter(a=>n.includes(a.key))))}catch(t){this.requests.forEach(s=>s.reject(t))}finally{this.requests.clear()}})}}const Pl=async(r,e)=>{const{normalized:t}=Pe(e),s=await r.retrieve(t),n=[];if(t.forEach(a=>{s.find(o=>o.name===a||o.key===a)==null&&n.push(a)}),n.length>0)throw new ze(`Could not find channels: ${JSON.stringify(n)}`);return s};class Dl{constructor({dataType:e,rate:t,name:s,leaseholder:n=0,key:a=0,isIndex:o=!1,index:u=0,internal:l=!1,virtual:h=!1,frameClient:f,alias:d,expression:I="",requires:j=[]}){c(this,"_frameClient"),c(this,"key"),c(this,"name"),c(this,"rate"),c(this,"dataType"),c(this,"leaseholder"),c(this,"index"),c(this,"isIndex"),c(this,"internal"),c(this,"alias"),c(this,"virtual"),c(this,"expression"),c(this,"requires"),this.key=a,this.name=s,this.rate=new Qt(t??0),this.dataType=new R(e),this.leaseholder=n,this.index=u,this.isIndex=o,this.internal=l,this.alias=d,this.virtual=h,this.expression=I,this.requires=j??[],this._frameClient=f??null}get framer(){if(this._frameClient==null)throw new Q("cannot read from a channel that has not been created");return this._frameClient}get payload(){return dr.parse({key:this.key,name:this.name,rate:this.rate.valueOf(),dataType:this.dataType.valueOf(),leaseholder:this.leaseholder,index:this.index,isIndex:this.isIndex,internal:this.internal,virtual:this.virtual,expression:this.expression,requires:this.requires})}get isCalculated(){return ds(this.payload)}get ontologyID(){return Rl(this.key)}async read(e){return await this.framer.read(e,this.key)}async write(e,t){return await this.framer.write(e,this.key,t)}}const Zg="/channel/retrieve-group",Jg=i.z.object({}),Kg=i.z.object({group:Il});let Ul=class{constructor(r,e,t,s){c(this,"type","channel"),c(this,"frameClient"),c(this,"client"),c(this,"retriever"),c(this,"writer"),this.frameClient=r,this.retriever=e,this.client=t,this.writer=s}async create(r,e={}){const{retrieveIfNameExists:t=!1}=e,s=!Array.isArray(r);let n=O(r),a=[];if(t){const o=await this.retriever.retrieve(n.map(l=>l.name)),u=new Set(o.map(l=>l.name));n=n.filter(l=>!u.has(l.name)),a=this.sugar(o)}return a=a.concat(this.sugar(await this.writer.create(n))),s?a[0]:a}async retrieve(r,e){const t=!Array.isArray(r),s=this.sugar(await this.retriever.retrieve(r,e));return Is("channel",r,s,t),t?s[0]:s}async search(r,e){return this.sugar(await this.retriever.search(r,e))}async delete(r){const{normalized:e,variant:t}=Pe(r);return t==="keys"?await this.writer.delete({keys:e}):await this.writer.delete({names:e})}async rename(r,e){return await this.writer.rename(O(r),O(e))}newSearcherWithOptions(r){return{type:this.type,search:async e=>await this.search(e,r),retrieve:async e=>await this.retrieve(e,r),page:async(e,t)=>await this.page(e,t,r)}}async page(r,e,t){return this.sugar(await this.retriever.page(r,e,t))}createDebouncedBatchRetriever(r=10){return new si(new Bl(new ri(this.client),r))}sugar(r){const{frameClient:e}=this;return r.map(t=>new Dl({...t,frameClient:e}))}async retrieveGroup(){const r=await T(this.client,Zg,{},Jg,Kg);return new xl(r.group.name,r.group.key)}};const ds=({virtual:r,expression:e})=>r&&e!=="",Ll=async(r,e)=>{if(!ds(e))return e.index;for(const t of e.requires){const s=await r(t);if(s==null)return null;if(!s.virtual)return s.index}for(const t of e.requires){const s=await r(t);if(s==null)return null;if(ds(s)){const n=await Ll(r,s);if(n!=null)return n}}return null},Hg=i.z.object({channels:kl.array()}),Xg=i.z.object({channels:dr.array()}),Qg=i.z.object({keys:Re.array().optional(),names:i.z.string().array().optional()}),ey=i.z.object({}),ty=i.z.object({keys:Re.array(),names:i.z.string().array()}),ry=i.z.object({}),sy="/channel/create",ny="/channel/delete",iy="/channel/rename";let _l=class{constructor(r,e){c(this,"client"),c(this,"cache"),this.client=r,this.cache=e}async create(r){const{channels:e}=await T(this.client,sy,{channels:r},Hg,Xg);return this.cache.set(e),e}async delete(r){await T(this.client,ny,r,Qg,ey),r.keys!=null&&this.cache.delete(r.keys),r.names!=null&&this.cache.delete(r.names)}async rename(r,e){await T(this.client,iy,{keys:r,names:e},ty,ry),this.cache.rename(r,e)}};const ay=Object.freeze(Object.defineProperty({__proto__:null,CacheRetriever:si,Channel:Dl,Client:Ul,ClusterRetriever:ri,DebouncedBatchRetriever:Bl,ONTOLOGY_TYPE:Cl,Writer:_l,analyzeChannelParams:Pe,isCalculated:ds,keyZ:Re,newPayload:kl,ontologyID:Rl,payload:dr,resolveCalculatedIndex:Ll,retrieveRequired:Pl},Symbol.toStringTag,{value:"Module"})),fr=i.z.string().uuid(),xs=i.z.object({key:fr,username:i.z.string().min(1),firstName:i.z.string().default(""),lastName:i.z.string().default(""),rootUser:i.z.boolean().default(!0)}),oy=xs.partial({key:!0,firstName:!0,lastName:!0}).omit({rootUser:!0}).extend({password:i.z.string().min(1)}),ly=i.z.object({keys:fr.array().optional(),usernames:i.z.string().array().optional()}),uy=i.z.object({users:le(xs)}),cy="/user/retrieve";let hy=class{constructor(r){c(this,"client"),this.client=r}async retrieve(r){return(await T(this.client,cy,r,ly,uy)).users}};const dy=i.z.object({users:oy.array()}),fy=i.z.object({users:xs.array()}),py=i.z.object({key:fr,username:i.z.string().min(1)}),gy=i.z.object({}),yy=i.z.object({key:fr,firstName:i.z.string().optional(),lastName:i.z.string().optional()}),my=i.z.object({}),wy=i.z.object({keys:fr.array()}),by=i.z.object({}),vy="/user/create",Ty="/user/change-username",Oy="/user/rename",Sy="/user/delete";let zy=class{constructor(r){c(this,"client"),this.client=r}async create(r){return(await T(this.client,vy,{users:O(r)},dy,fy)).users}async changeUsername(r,e){await T(this.client,Ty,{key:r,username:e},py,gy)}async rename(r,e,t){await T(this.client,Oy,{key:r,firstName:e,lastName:t},yy,my)}async delete(r){await T(this.client,Sy,{keys:O(r)},wy,by)}},Ny=class{constructor(r){c(this,"reader"),c(this,"writer"),this.writer=new zy(r),this.reader=new hy(r)}async create(r){const e=Array.isArray(r),t=await this.writer.create(r);return e?t:t[0]}async changeUsername(r,e){await this.writer.changeUsername(r,e)}async retrieve(r){const e=Array.isArray(r),t=await this.reader.retrieve({keys:O(r)});if(e)return t;if(t.length===0)throw new ht(`No user with key ${r} found`);if(t.length>1)throw new dt(`Multiple users found with key ${r}`);return t[0]}async retrieveByName(r){const e=Array.isArray(r),t=await this.reader.retrieve({usernames:O(r)});if(e)return t;if(t.length===0)throw new ht(`No user with username ${r} found`);if(t.length>1)throw new dt(`Multiple users found with username ${r}`);return t[0]}async rename(r,e,t){await this.writer.rename(r,e,t)}async delete(r){await this.writer.delete(r)}};const Ey=i.z.object({username:i.z.string(),password:i.z.string()}),Iy=i.z.object({token:i.z.string(),user:xs}),Ca="/auth/login",xy=3,Ay="/auth/change-password",ky=i.z.object({username:i.z.string(),password:i.z.string(),newPassword:i.z.string().min(1)}),Cy=i.z.object({});let Ry=class{constructor(r,e){c(this,"token"),c(this,"client"),c(this,"credentials"),c(this,"authenticating"),c(this,"authenticated"),c(this,"user"),c(this,"retryCount"),this.client=r,this.authenticated=!1,this.credentials=e,this.retryCount=0}async changePassword(r){if(!this.authenticated)throw new Error("Not authenticated");await T(this.client,Ay,{username:this.credentials.username,password:this.credentials.password,newPassword:r},ky,Cy),this.credentials.password=r}middleware(){const r=async(e,t)=>{if(!this.authenticated&&!e.target.endsWith(Ca)){this.authenticating??(this.authenticating=new Promise((o,u)=>{this.client.send(Ca,this.credentials,Ey,Iy).then(([l,h])=>{if(h!=null)return o(h);this.token=l==null?void 0:l.token,this.user=l==null?void 0:l.user,this.authenticated=!0,o(null)}).catch(u)}));const a=await this.authenticating;if(a!=null)return[e,a]}e.params.Authorization=`Bearer ${this.token}`;const[s,n]=await t(e);return jn.matches(n)&&this.retryCount<xy?(this.authenticated=!1,this.authenticating=void 0,this.retryCount+=1,r(e,t)):(this.retryCount=0,[s,n])};return r}};const $y=["disconnected","connecting","connected","failed"],My=i.z.enum($y),jy=i.z.object({status:My,error:i.z.instanceof(Error).optional(),message:i.z.string().optional(),clusterKey:i.z.string(),clientVersion:i.z.string(),clientServerCompatible:i.z.boolean(),nodeVersion:i.z.string().optional()}),By=i.z.object({clusterKey:i.z.string(),nodeVersion:i.z.string().optional()}),ql={clusterKey:"",status:"disconnected",error:void 0,message:"Disconnected",clientServerCompatible:!1,clientVersion:"0.38.1"},Ra=(r,e,t)=>{const s=t?"cluster":"client";return`Synnax cluster node version ${r!=null?`${r} `:""}is too ${t?"old":"new"} for client version ${e}.
|
|
48
|
-
This may cause compatibility issues. We recommend updating the ${s}. For more information, see
|
|
49
|
-
https://docs.synnaxlabs.com/reference/typescript-client/troubleshooting#old-${s}-version`},ts=class Yl{constructor(e,t=x.seconds(30),s,n){c(this,"_state"),c(this,"pollFrequency",x.seconds(30)),c(this,"client"),c(this,"name"),c(this,"interval"),c(this,"clientVersion"),c(this,"onChangeHandlers",[]),c(this,"versionWarned",!1),this._state={...ql},this.client=e,this.pollFrequency=t,this.clientVersion=s,this.name=n,this.check(),this.startChecking()}stopChecking(){this.interval!=null&&clearInterval(this.interval)}async check(){var e;const t=this._state.status;try{const[s,n]=await this.client.send(Yl.ENDPOINT,{},i.z.object({}),By);if(n!=null)throw n;const a=s.nodeVersion,o=this.clientVersion,u=this.versionWarned;a==null?(this._state.clientServerCompatible=!1,u||(console.warn(Ra(null,o,!0)),this.versionWarned=!0)):va.versionsEqual(o,a,{checkMajor:!0,checkMinor:!0,checkPatch:!1})?this._state.clientServerCompatible=!0:(this._state.clientServerCompatible=!1,u||(console.warn(Ra(a,o,va.semVerNewer(o,a))),this.versionWarned=!0)),this._state.status="connected",this._state.message=`Connected to ${this.name??"cluster"}`,this._state.clusterKey=s.clusterKey,this._state.nodeVersion=s.nodeVersion,this._state.clientVersion=this.clientVersion}catch(s){this._state.status="failed",this._state.error=s,this._state.message=(e=this.state.error)==null?void 0:e.message}return this.onChangeHandlers.length>0&&t!==this._state.status&&this.onChangeHandlers.forEach(s=>s(this.state)),this.state}get state(){return{...this._state}}onChange(e){this.onChangeHandlers.push(e)}startChecking(){this.interval=setInterval(()=>{this.check()},this.pollFrequency.milliseconds)}};c(ts,"ENDPOINT","/connectivity/check"),c(ts,"DEFAULT",ql),c(ts,"connectionStateZ",jy);let Fl=ts;const Py=i.z.object({keys:Re.array().optional(),bounds:oe.z,names:i.z.string().array().optional()}),Dy=i.z.object({}),Uy="/frame/delete";class Ly{constructor(e){c(this,"client"),this.client=e}async delete(e){await T(this.client,Uy,e,Py,Dy)}}const $a=r=>{const e=O(r);return e.length===0?null:typeof e[0]=="number"||!isNaN(parseInt(e[0]))?"key":"name"},Ma=(r,e)=>{const t=O(r);if(t.length===e.length)return;const s=$a(r);throw $a===null?new Q("[Frame] - channel keys or names must be provided when constructing a frame."):new Q(`[Frame] - ${s}s and series must be the same length.
|
|
50
|
-
Got ${t.length} ${s}s and ${e.length} series.`)};let Se=class nt{constructor(e=[],t=[]){if(c(this,"columns",[]),c(this,"series",[]),e instanceof nt){this.columns=e.columns,this.series=e.series;return}if(e instanceof Map){e.forEach((s,n)=>this.push(n,...O(s)));return}if(typeof e=="object"&&!Array.isArray(e)){if("keys"in e&&"series"in e){const s=e;s.series??(s.series=[]),s.keys??(s.keys=[]);const n=s.series.map(a=>_y(a));Ma(s.keys,n),s.keys.forEach((a,o)=>this.push(a,n[o]))}else Object.entries(e).forEach(([s,n])=>{const a=parseInt(s);if(!isNaN(a))return this.push(a,...O(n));this.push(s,...O(n))});return}if(Array.isArray(e)||["string","number"].includes(typeof e)){const s=O(t),n=O(e);Ma(n,s),s.forEach((a,o)=>this.push(n[o],a));return}throw new Q(`[Frame] - invalid frame construction parameters. data parameter ust be a frame
|
|
51
|
-
payload, a list of lazy series, a lazy array, a map, or a record keyed by channel
|
|
52
|
-
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 be("colType is not key");return this.columns??[]}get uniqueKeys(){return sa.unique(this.keys)}get names(){if(this.colType==="key")throw new be("colType is not name");return this.columns??[]}get uniqueNames(){return sa.unique(this.names)}get uniqueColumns(){return this.colType==="key"?this.uniqueKeys:this.uniqueNames}toPayload(){return{series:this.series.map(e=>qy(e)),keys:this.keys}}get isVertical(){return this.uniqueColumns.length===this.columns.length}get isHorizontal(){return this.uniqueColumns.length===1}get isSquare(){return this.isHorizontal&&this.isVertical}get isWeaklyAligned(){if(this.columns.length<=1)return!0;const e=this.timeRanges;return e.every(t=>t.equals(e[0]))}timeRange(e){if(e==null){if(this.columns.length===0)return oe.ZERO;const s=$.min(...this.series.map(a=>a.timeRange.start)),n=$.max(...this.series.map(a=>a.timeRange.end));return new oe(s,n)}const t=this.get(e);return t==null?oe.ZERO:t.timeRange}latest(){return this.at(-1)}get timeRanges(){return this.uniqueColumns.map(e=>this.timeRange(e))}get(e){return Array.isArray(e)?this.filter(t=>e.includes(t)):new zp(this.series.filter((t,s)=>this.columns[s]===e))}push(e,...t){if(e instanceof nt){if(this.colType!==null&&e.colType!==this.colType)throw new Q("keyVariant must match");this.series.push(...e.series),this.columns.push(...e.columns)}else{if(this.series.push(...t),typeof e=="string"&&this.colType==="key")throw new Q("keyVariant must match");if(typeof e!="string"&&this.colType==="name")throw new Q("keyVariant must match");this.columns.push(...Array.from({length:t.length},()=>e))}}concat(e){return new nt([...this.columns,...e.columns],[...this.series,...e.series])}has(e){return typeof e=="string"&&this.colType==="key"||typeof e=="number"&&this.colType==="name"?!1:this.columns.includes(e)}map(e){const t=new nt;return this.forEach((s,n,a)=>t.push(...e(s,n,a))),t}forEach(e){this.columns.forEach((t,s)=>{const n=this.series[s];e(t,n,s)})}at(e,t=!1){const s={};return this.uniqueColumns.forEach(n=>{s[n]=this.get(n).at(e,t)}),s}filter(e){const t=new nt;return this.columns.forEach((s,n)=>{const a=this.series[n];e(s,a,n)&&t.push(s,a)}),t}get byteLength(){return new ut(this.series.reduce((e,t)=>e.add(t.byteLength),ut.ZERO))}get digest(){const e={};return this.keys.forEach((t,s)=>{const n=this.series[s].digest;t in e?e[t].push(n):e[t]=[n]}),e}get length(){return this.series.reduce((e,t)=>e+t.length,0)}};const ni=i.z.object({keys:i.z.union([i.z.null().transform(()=>[]),i.z.number().array().optional().default([])]),series:i.z.union([i.z.null().transform(()=>[]),He.crudeZ.array().optional().default([])])}),_y=r=>{const{dataType:e,data:t,timeRange:s,alignment:n}=r;return new He({data:t,dataType:e,timeRange:s,glBufferUsage:"static",alignment:n})},qy=r=>({timeRange:r._timeRange,dataType:r.dataType,data:new Uint8Array(r.data.buffer),alignment:r.alignment});class As{constructor(e){c(this,"adapter"),c(this,"retriever"),c(this,"keys"),this.retriever=e,this.adapter=null,this.keys=[]}static async open(e,t){const s=new As(e);return await s.update(t),s}async update(e){const{variant:t,normalized:s}=Pe(e);if(t==="keys"){this.adapter=null,this.keys=s;return}const n=await this.retriever.retrieve(s),a=new Map;this.adapter=a,s.forEach(o=>{const u=n.find(l=>l.name===o);if(u==null)throw new Error(`Channel ${o} not found`);a.set(u.key,u.name)}),this.keys=Array.from(this.adapter.keys())}adapt(e){if(this.adapter==null)return e;const t=this.adapter;return e.map((s,n)=>{if(typeof s=="number"){const a=t.get(s);if(a==null)throw new Error(`Channel ${s} not found`);return[a,n]}return[s,n]})}}class ii{constructor(e){c(this,"adapter"),c(this,"retriever"),c(this,"keys"),this.retriever=e,this.adapter=null,this.keys=[]}static async open(e,t){const s=new ii(e);return await s.update(t),s}async adaptObjectKeys(e){const t={};for(const[s,n]of Object.entries(e))t[await this.adaptToKey(s)]=n;return t}async update(e){const t=await Pl(this.retriever,e);this.adapter=new Map(t.map(s=>[s.name,s.key])),this.keys=t.map(s=>s.key)}async fetchChannel(e){const t=await this.retriever.retrieve(e);if(t.length===0)throw new Error(`Channel ${e} not found`);return t[0]}async adaptToKey(e){return typeof e=="number"?e:(await this.fetchChannel(e)).key}async adapt(e,t){if(typeof e=="string"||typeof e=="number"){if(t==null)throw new Q(`
|
|
53
|
-
Received a single channel name or key but no series.
|
|
54
|
-
`);if(Array.isArray(t)){if(t.some(l=>l instanceof He||Array.isArray(l)))throw new Q(`
|
|
55
|
-
Received a single channel name or key but multiple series.
|
|
56
|
-
`);t=t}const o=await this.fetchChannel(e),u=new He({data:t,dataType:o.dataType});return new Se(o.key,u)}if(Array.isArray(e)){if(t==null)throw new Q(`
|
|
57
|
-
Received an array of channel names or keys but no series.
|
|
58
|
-
`);if(!Array.isArray(t))throw new Q(`
|
|
59
|
-
Received an array of channel names or keys but no array of series.
|
|
60
|
-
`);const o=[],u=[];for(let l=0;l<e.length;l++){const h=await this.fetchChannel(e[l]);if(l>=t.length)throw new Q(`
|
|
61
|
-
Received an array of channel names or keys but not enough series.
|
|
62
|
-
`);const f=new He({data:t[l],dataType:h.dataType});o.push(h.key),u.push(f)}return new Se(o,u)}if(e instanceof Se||e instanceof Map){const o=new Se(e);if(this.adapter==null)return o;const u=o.columns.map(l=>{var h;const f=typeof l=="string"?(h=this.adapter)==null?void 0:h.get(l):l;if(f==null)throw new Q(`
|
|
63
|
-
Channel ${l} was not provided in the list of channels when opening the writer
|
|
64
|
-
`);return f});return new Se(u,o.series)}const s=[],n=[],a=Object.entries(e);for(let o=0;o<a.length;o++){const[u,l]=a[o],h=await this.fetchChannel(u),f=new He({data:l,dataType:h.dataType});s.push(h.key),n.push(f)}return new Se(s,n)}}class ai{constructor(e,t){c(this,"name"),c(this,"stream"),this.stream=t,this.name=e}async receive(){const[e,t]=await this.stream.receive();if(t!=null)throw t;return e}received(){return this.stream.received()}async closeAndAck(){for(this.stream.closeSend();;){const[e,t]=await this.stream.receive();if(e!=null&&console.warn(`${this.name} received unexpected response on closure.
|
|
65
|
-
Please report this error to the Synnax team. ${JSON.stringify(e)}`),t!=null){if(Ge.matches(t))return;throw t}}}closeSend(){this.stream.closeSend()}send(e){const t=this.stream.send(e);if(t!=null)throw t}}const ja=new x(-1);var oi=(r=>(r[r.Open=0]="Open",r[r.Next=1]="Next",r[r.Prev=2]="Prev",r[r.SeekFirst=3]="SeekFirst",r[r.SeekLast=4]="SeekLast",r[r.SeekLE=5]="SeekLE",r[r.SeekGE=6]="SeekGE",r[r.Valid=7]="Valid",r[r.Error=8]="Error",r))(oi||{}),Vl=(r=>(r[r.None=0]="None",r[r.Ack=1]="Ack",r[r.Data=2]="Data",r))(Vl||{});const Yy=i.z.object({command:i.z.nativeEnum(oi),span:x.z.optional(),bounds:oe.z.optional(),stamp:$.z.optional(),keys:i.z.number().array().optional(),chunkSize:i.z.number().optional()}),Fy=i.z.object({variant:i.z.nativeEnum(Vl),ack:i.z.boolean(),command:i.z.nativeEnum(oi),error:ur.optional().nullable(),frame:ni.optional()}),Gl=class Bn{constructor(e,t){c(this,"stream"),c(this,"adapter"),c(this,"value"),this.stream=new ai("Iterator",e),this.value=new Se,this.adapter=t}static async _open(e,t,s,n,a={}){const o=await As.open(s,t),u=await n.stream(Bn.ENDPOINT,Yy,Fy),l=new Bn(u,o);return await l.execute({command:0,keys:o.keys,bounds:new oe(e),chunkSize:a.chunkSize??1e5}),l}async next(e=ja){return await this.execute({command:1,span:new x(e)})}async prev(e=ja){return await this.execute({command:2,span:new x(e)})}async seekFirst(){return await this.execute({command:3})}async seekLast(){return await this.execute({command:4})}async seekLE(e){return await this.execute({command:5,stamp:new $(e)})}async seekGE(e){return await this.execute({command:6,stamp:new $(e)})}async valid(){return await this.execute({command:7})}async close(){await this.stream.closeAndAck()}[Symbol.asyncIterator](){return new Gy(this)}async execute(e){for(this.stream.send(e),this.value=new Se;;){const t=await this.stream.receive();if(t.variant===1)return t.ack;this.value.push(this.adapter.adapt(new Se(t.frame)))}}};c(Gl,"ENDPOINT","/frame/iterate");let Vy=Gl;class Gy{constructor(e){c(this,"iter"),c(this,"open",!1),this.iter=e}async next(){try{let e=!0;return this.open||(await this.iter.seekFirst()||(e=!1),this.open=!0),await this.iter.next()||(e=!1),e||await this.iter.close(),{done:!e,value:this.iter.value}}catch(e){throw await this.iter.close(),e}}}const Wy=i.z.object({keys:i.z.number().array(),downsampleFactor:i.z.number()}),Zy=i.z.object({frame:ni,error:ur.optional().nullable()}),Jy="/frame/stream";class li{constructor(e,t){c(this,"stream"),c(this,"adapter"),c(this,"downsampleFactor"),this.stream=new ai("Streamer",e),this.adapter=t,this.downsampleFactor=1}get keys(){return this.adapter.keys}static async _open(e,t,{channels:s,downsampleFactor:n}){const a=await As.open(e,s),o=await t.stream(Jy,Wy,Zy),u=new li(o,a);o.send({keys:a.keys,downsampleFactor:n??1});const[,l]=await o.receive();if(l!=null)throw l;return u}async next(){try{return{done:!1,value:await this.read()}}catch(e){if(Ge.matches(e))return{done:!0,value:void 0};throw e}}async read(){return this.adapter.adapt(new Se((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}}let ft=class extends et.Observer{constructor(e,t){super(t),c(this,"streamer"),c(this,"closePromise"),this.streamer=e,this.closePromise=this.stream()}async close(){this.streamer.close(),await this.closePromise}async stream(){for await(const e of this.streamer)this.notify(e)}};var ui=(r=>(r[r.Open=0]="Open",r[r.Write=1]="Write",r[r.Commit=2]="Commit",r[r.Error=3]="Error",r[r.SetAuthority=4]="SetAuthority",r))(ui||{}),er=(r=>(r[r.PersistStream=1]="PersistStream",r[r.Persist=2]="Persist",r[r.Stream=3]="Stream",r))(er||{});const Ky=r=>{switch(r){case"persist":return 2;case"stream":return 3;case"persistStream":return 1;default:if(typeof r=="number"&&r in er)return r;throw new Error(`invalid writer mode: ${r}`)}};new x(-1);const Hy=i.z.object({start:$.z.optional(),controlSubject:ct.subjectZ.optional(),keys:i.z.number().array().optional(),authorities:ct.Authority.z.array().optional(),mode:i.z.nativeEnum(er).optional(),errOnUnauthorized:i.z.boolean().optional(),enableAutoCommit:i.z.boolean().optional(),autoIndexPersistInterval:x.z.optional()}),Xy=i.z.object({command:i.z.nativeEnum(ui),config:Hy.optional(),frame:ni.optional()}),Qy=i.z.object({ack:i.z.boolean(),command:i.z.nativeEnum(ui),error:ur.optional().nullable()});var St;let em=(St=class{constructor(r,e){c(this,"stream"),c(this,"adapter"),this.stream=new ai("Writer",r),this.adapter=e}static async _open(r,e,{channels:t,start:s=$.now(),authorities:n=ct.Authority.Absolute,controlSubject:a,mode:o=1,errOnUnauthorized:u=!1,enableAutoCommit:l=!1,autoIndexPersistInterval:h=x.SECOND}){const f=await ii.open(r,t),d=await e.stream(St.ENDPOINT,Xy,Qy),I=new St(d,f);return await I.execute({command:0,config:{start:new $(s),keys:f.keys,controlSubject:a,authorities:O(n),mode:Ky(o),errOnUnauthorized:u,enableAutoCommit:l,autoIndexPersistInterval:h}}),I}async write(r,e){const t=await this.adapter.adapt(r,e);return this.stream.send({command:1,frame:t.toPayload()}),!0}async setAuthority(r,e){let t;if(typeof r=="number"&&e==null)t={keys:[],authorities:[r]};else{let s;typeof r=="string"||typeof r=="number"?s={[r]:e}:s=r,s=await this.adapter.adaptObjectKeys(s),t={keys:Object.keys(s).map(n=>Number(n)),authorities:Object.values(s)}}return(await this.execute({command:4,config:t})).ack}async commit(){return this.errorAccumulated?!1:(await this.execute({command:2})).ack}async error(){this.stream.send({command:3});const r=await this.execute({command:3});return r.error!=null?ls(r.error):null}async close(){await this.stream.closeAndAck()}async execute(r){for(this.stream.send(r);;){const e=await this.stream.receive();if(e.command===r.command)return e;console.warn("writer received unexpected response",e)}}get errorAccumulated(){return this.stream.received()}},c(St,"ENDPOINT","/frame/write"),St),tm=class{constructor(r,e,t){c(this,"streamClient"),c(this,"retriever"),c(this,"deleter"),this.streamClient=r,this.retriever=t,this.deleter=new Ly(e)}async openIterator(r,e,t){return await Vy._open(r,e,this.retriever,this.streamClient,t)}async openWriter(r){return(Array.isArray(r)||typeof r!="object")&&(r={channels:r}),await em._open(this.retriever,this.streamClient,r)}async openStreamer(r){return(Array.isArray(r)||typeof r!="object")&&(r={channels:r,downsampleFactor:1}),await li._open(this.retriever,this.streamClient,r)}async write(r,e,t){if(t==null){const n=e,a=await this.openWriter({start:r,channels:Object.keys(n),mode:er.Persist});try{await a.write(n),await a.commit()}finally{await a.close()}return}const s=await this.openWriter({start:r,channels:e,mode:er.Persist,errOnUnauthorized:!0,enableAutoCommit:!0,autoIndexPersistInterval:x.MAX});try{await s.write(e,t)}finally{await s.close()}}async read(r,e){const{single:t}=Pe(e),s=await this.readFrame(r,e);return t?s.get(e):s}async readFrame(r,e){const t=await this.openIterator(r,e),s=new Se;try{for await(const n of t)s.push(n)}finally{await t.close()}return s}async delete(r,e){const{normalized:t,variant:s}=Pe(r);return s==="keys"?await this.deleter.delete({keys:t,bounds:e}):await this.deleter.delete({names:t,bounds:e})}};const rm=ct.Authority,sm=ct.stateZ(i.z.number()),nm=r=>{var e,t;return r.to==null?`${(e=r.from)==null?void 0:e.resource} - ${(t=r.from)==null?void 0:t.subject.name} -> released`:r.from==null?`${r.to.resource} - released -> ${r.to.subject.name} (${r.to.authority.toString()})`:`${r.to.resource} - ${r.from.subject.name} -> ${r.to.subject.name} (${r.to.authority.toString()})`};class Wl extends ft{constructor(e){super(e,t=>{const s=this.codec.decode(t.series[0].buffer);return this.merge(s),[s.transfers,!0]}),c(this,"states"),c(this,"codec"),this.states=new Map,this.codec=new gt.JSONCodec}subjects(){const e=new Map;return this.states.forEach(t=>e.set(t.subject.key,t.subject)),Array.from(e.values())}merge(e){e.transfers.forEach(t=>{t.from==null&&t.to==null&&console.warn("Invalid transfer: ",t),t.to==null?this.states.delete(t.from.resource):this.states.set(t.to.resource,t.to)})}}const im="sy_node_1_control";let Zl=class{constructor(r){c(this,"framer"),this.framer=r}async openStateTracker(){const r=await this.framer.openStreamer(im);return new Wl(r)}};const am=Object.freeze(Object.defineProperty({__proto__:null,Authority:rm,Client:Zl,StateTracker:Wl,stateZ:sm,transferString:nm},Symbol.toStringTag,{value:"Module"}));let om=class{constructor(r,e,t){c(this,"tasks"),c(this,"racks"),c(this,"devices"),this.tasks=r,this.racks=e,this.devices=t}};const pr=i.z.number(),ci=i.z.object({key:pr,name:i.z.string()}),lm=ci.partial({key:!0}),hi=i.z.string(),ks=i.z.object({key:hi,rack:pr,name:i.z.string(),make:i.z.string(),model:i.z.string(),location:i.z.string(),configured:i.z.boolean().optional(),properties:i.z.record(i.z.unknown()).or(i.z.string().transform(r=>r===""?{}:gt.JSON_CODEC.decodeString(r)))}),um=ks.extend({properties:i.z.unknown().transform(r=>gt.JSON_CODEC.encodeString(r))}),mt=async(r,e,t,s)=>{const n=await r.openStreamer([e,t]),a=o=>{const u=[];return t!=null&&u.push(...o.get(t).series.flatMap(l=>s("delete",l))),e!=null&&u.push(...o.get(e).series.flatMap(l=>s("set",l))),[u,u.length>0]};return new ft(n,a)},cm="sy_device_set",hm="sy_device_delete",Hs="/hardware/device/retrieve",dm="/hardware/device/create",fm="/hardware/device/delete",pm=i.z.object({devices:um.array()}),gm=i.z.object({devices:ks.array()}),ym=i.z.object({keys:hi.array()}),mm=i.z.object({}),Xs=i.z.object({search:i.z.string().optional(),limit:i.z.number().optional(),offset:i.z.number().optional(),keys:hi.array().optional(),names:i.z.string().array().optional(),makes:i.z.string().array().optional()}),Qs=i.z.object({devices:le(ks)});let wm=class{constructor(r,e){c(this,"type","device"),c(this,"client"),c(this,"frameClient"),this.client=r,this.frameClient=e}async retrieve(r,e){const t=!Array.isArray(r),s=await T(this.client,Hs,{keys:O(r),...e},Xs,Qs);return Is("Device",r,s.devices,t),t?s.devices[0]:s.devices}async search(r,e){return(await T(this.client,Hs,{search:r,...e},Xs,Qs)).devices}async page(r,e,t){return(await T(this.client,Hs,{offset:r,limit:e,...t},Xs,Qs)).devices}async create(r){const e=!Array.isArray(r),t=await T(this.client,dm,{devices:O(r)},pm,gm);return e?t.devices[0]:t.devices}async delete(r){await T(this.client,fm,{keys:O(r)},ym,mm)}async openDeviceTracker(){return await mt(this.frameClient,cm,hm,bm)}newSearcherWithOptions(r){return{type:this.type,search:async e=>await this.search(e,r),retrieve:async e=>await this.retrieve(e,r),page:async(e,t)=>await this.page(e,t,r)}}};const bm=(r,e)=>r==="delete"?e.toStrings().map(t=>({variant:r,key:t,value:void 0})):e.parseJSON(ks).map(t=>({variant:r,key:t.key,value:t})),en="/hardware/rack/retrieve",vm="/hardware/rack/create",Tm="/hardware/rack/delete",tn=i.z.object({keys:pr.array().optional(),names:i.z.string().array().optional(),search:i.z.string().optional(),offset:i.z.number().optional(),limit:i.z.number().optional()}),rn=i.z.object({racks:le(ci)}),Om=i.z.object({racks:lm.array()}),Sm=i.z.object({racks:ci.array()}),zm=i.z.object({keys:pr.array()}),Nm=i.z.object({});let Em=class{constructor(r,e,t){c(this,"type","rack"),c(this,"client"),c(this,"frameClient"),c(this,"tasks"),this.client=r,this.frameClient=e,this.tasks=t}async delete(r){await T(this.client,Tm,{keys:O(r)},zm,Nm)}async create(r){const e=!Array.isArray(r),t=await T(this.client,vm,{racks:O(r)},Om,Sm),s=this.sugar(t.racks);return e?s[0]:s}async search(r){const e=await T(this.client,en,{search:r},tn,rn);return this.sugar(e.racks)}async page(r,e){const t=await T(this.client,en,{offset:r,limit:e},tn,rn);return this.sugar(t.racks)}async retrieve(r){const{variant:e,normalized:t,single:s}=Es(r,{string:"names",number:"keys"}),n=await T(this.client,en,{[e]:t},tn,rn),a=this.sugar(n.racks);return Is("Rack",r,a,s),s?a[0]:a}sugar(r){return r.map(({key:e,name:t})=>new Im(e,t,this.tasks))}};class Im{constructor(e,t,s){c(this,"key"),c(this,"name"),c(this,"tasks"),this.key=e,this.name=t,this.tasks=s}async listTasks(){return await this.tasks.retrieve(this.key)}async retrieveTaskByName(e){return await this.tasks.retrieveByName(e,this.key)}async createTask(e){return e.key=((BigInt(this.key)<<32n)+(BigInt(e.key??0)&0xffffffffn)).toString(),await this.tasks.create(e)}async deleteTask(e){await this.tasks.delete([e])}}const wt=i.z.union([i.z.string(),i.z.bigint().transform(r=>r.toString()),i.z.number().transform(r=>r.toString())]),fs=i.z.object({task:wt,variant:i.z.string(),key:i.z.string().optional(),details:i.z.record(i.z.unknown()).or(i.z.string().transform(r=>r===""?{}:JSON.parse(r))).or(i.z.array(i.z.unknown())).or(i.z.null())}),Cs=i.z.object({key:wt,name:i.z.string(),type:i.z.string(),internal:i.z.boolean().optional(),config:i.z.record(i.z.unknown()).or(i.z.string().transform(r=>r===""?{}:gt.JSON_CODEC.decodeString(r))),state:fs.optional().nullable(),snapshot:i.z.boolean().optional()}),xm=Cs.omit({key:!0}).extend({key:wt.transform(r=>r.toString()).optional(),config:i.z.unknown().transform(r=>gt.JSON_CODEC.encodeString(r))}),Jl=i.z.object({task:wt,type:i.z.string(),key:i.z.string(),args:i.z.record(i.z.unknown()).or(i.z.string().transform(r=>r===""?{}:JSON.parse(r))).or(i.z.array(i.z.unknown())).or(i.z.null()).optional()}),Am="task",km=r=>new P({type:Am,key:r.toString()}),Kt="sy_task_state",it="sy_task_cmd",zt=new Error("Task not created");class Cm{constructor(e,t,s,n,a=!1,o=!1,u,l=null,h=null,f=null){c(this,"key"),c(this,"name"),c(this,"internal"),c(this,"type"),c(this,"config"),c(this,"snapshot"),c(this,"state"),c(this,"frameClient"),c(this,"ontologyClient"),c(this,"rangeClient"),this.key=e,this.name=t,this.type=s,this.config=n,this.internal=a,this.snapshot=o,u!==null&&(this.state=u),this.frameClient=l,this.ontologyClient=h,this.rangeClient=f}get payload(){return{key:this.key,name:this.name,type:this.type,config:this.config,state:this.state,internal:this.internal}}get ontologyID(){return km(this.key)}async executeCommand(e,t){if(this.frameClient==null)throw zt;const s=await this.frameClient.openWriter(it),n=pp.id();return await s.write(it,[{task:this.key,type:e,key:n,args:t}]),await s.close(),n}async executeCommandSync(e,t,s){if(this.frameClient==null)throw zt;const n=await this.frameClient.openStreamer(Kt),a=await this.executeCommand(e,t);let o;const u=new Promise(l=>setTimeout(()=>l(!1),new x(s).milliseconds));for(;;){const l=await Promise.any([n.read(),u]);if(l===!1)throw new Error("Command timed out");const h=fs.safeParse(l.at(-1).sy_task_state);if(h.success){if(o=h.data,o.key===a)break}else console.error(h.error)}return n.close(),o}async openStateObserver(){if(this.frameClient==null)throw zt;return new ft(await this.frameClient.openStreamer(Kt),e=>{const t=e.get(Kt);if(t.length===0)return[null,!1];const s=fs.safeParse(t.at(-1));if(!s.success)return console.error(s.error),[null,!1];const n=s.data;return n.task!==this.key?[null,!1]:[n,!0]})}async openCommandObserver(){if(this.frameClient==null)throw zt;return new ft(await this.frameClient.openStreamer(it),e=>{const t=e.get(it);if(t.length===0)return[null,!1];const s=Jl.safeParse(t.at(-1));if(!s.success)return console.error(s.error),[null,!1];const n=s.data;return n.task!==this.key?[null,!1]:[n,!0]})}async snapshottedTo(){if(this.ontologyClient==null||this.rangeClient==null)throw zt;if(!this.snapshot)return null;const e=await this.ontologyClient.retrieveParents(this.ontologyID);return e.length==0?null:e[0]}}const Rm=i.z.object({rack:pr.optional(),keys:i.z.string().array().optional(),names:i.z.string().array().optional(),offset:i.z.number().optional(),limit:i.z.number().optional(),includeState:i.z.boolean().optional()}),$m=i.z.object({tasks:le(Cs)}),Mm="/hardware/task/retrieve",jm="/hardware/task/create",Bm="/hardware/task/delete",Pm="/hardware/task/copy",Dm=i.z.object({tasks:xm.array()}),Um=i.z.object({tasks:Cs.array()}),Lm=i.z.object({keys:wt.array()}),_m=i.z.object({}),qm=i.z.object({key:wt,name:i.z.string(),snapshot:i.z.boolean()}),Ym=i.z.object({task:Cs});let Fm=class{constructor(r,e,t,s){c(this,"type","task"),c(this,"client"),c(this,"frameClient"),c(this,"ontologyClient"),c(this,"rangeClient"),this.client=r,this.frameClient=e,this.ontologyClient=t,this.rangeClient=s}async create(r){const e=!Array.isArray(r),t=await T(this.client,jm,{tasks:O(r)},Dm,Um),s=this.sugar(t.tasks);return e?s[0]:s}async delete(r){await T(this.client,Bm,{keys:O(r)},Lm,_m)}async search(r){return await this.execRetrieve({keys:[r]})}async page(r,e){return await this.execRetrieve({offset:r,limit:e})}async list(r={}){return this.sugar(await this.execRetrieve(r))}async retrieve(r,e){const{single:t,normalized:s,variant:n}=Es(r,{number:"rack",string:"keys"},{convertNumericStrings:!1}),a={...e};n==="rack"?a.rack=r:a.keys=s;const o=await this.execRetrieve(a),u=this.sugar(o);return t&&n!=="rack"?u[0]:u}async copy(r,e,t){const s=await T(this.client,Pm,{key:r,name:e,snapshot:t},qm,Ym);return this.sugar([s.task])[0]}async retrieveByName(r,e){const t=await this.execRetrieve({names:[r],rack:e});return Is("Task",r,t,!0),this.sugar(t)[0]}async execRetrieve(r){return(await T(this.client,Mm,r,Rm,$m)).tasks}sugar(r){return r.map(({key:e,name:t,type:s,config:n,state:a,internal:o,snapshot:u})=>new Cm(e,t,s,n,o,u,a,this.frameClient,this.ontologyClient,this.rangeClient))}async openTracker(){return await mt(this.frameClient,"sy_task_set","sy_task_delete",(r,e)=>Array.from(e).map(t=>({variant:r,key:t.toString(),value:t.toString()})))}async openStateObserver(){return new ft(await this.frameClient.openStreamer(Kt),r=>{const e=r.get(Kt);if(e.length===0)return[null,!1];const t=fs.safeParse(e.at(-1));return t.success?[t.data,!0]:(console.error(t.error),[null,!1])})}async openCommandObserver(){return new ft(await this.frameClient.openStreamer(it),r=>{const e=r.get(it);if(e.length===0)return[null,!1];const t=Jl.safeParse(e.at(-1));return t.success?[t.data,!0]:(console.error(t.error),[null,!1])})}};const gr=i.z.string().uuid(),Rs=i.z.object({key:gr,name:i.z.string().min(1),color:i.z.string()}),Vm="label",Gm=r=>new P({type:Vm,key:r}),Wm=i.z.object({keys:gr.array().optional(),for:ve.optional(),search:i.z.string().optional(),offset:i.z.number().optional(),limit:i.z.number().optional()}),Zm=i.z.object({labels:le(Rs)}),Kl=class Hl{constructor(e){c(this,"client"),this.client=e}async retrieve(e){const t=O(e);return await this.execute({keys:t})}async retrieveFor(e){return await this.execute({for:e})}async search(e){return await this.execute({search:e})}async page(e,t){return await this.execute({offset:e,limit:t})}async execute(e){const[t,s]=await this.client.send(Hl.ENDPOINT,e,Wm,Zm);if(s!=null)throw s;return t.labels}};c(Kl,"ENDPOINT","/label/retrieve");let Jm=Kl;const Km=Rs.extend({key:gr.optional()}),Hm=i.z.object({labels:Km.array()}),Xm=i.z.object({labels:Rs.array()}),Qm=i.z.object({keys:gr.array()}),Xl=i.z.object({id:ve,labels:gr.array(),replace:i.z.boolean().optional()}),ew=Xl.omit({replace:!0}),sn=i.z.object({}),tw="/label/create",rw="/label/delete",sw="/label/set",nw="/label/remove";let iw=class{constructor(r){c(this,"client"),this.client=r}async create(r){return(await T(this.client,tw,{labels:O(r)},Hm,Xm)).labels}async delete(r){await T(this.client,rw,{keys:O(r)},Qm,sn)}async set(r,e,{replace:t}={}){await T(this.client,sw,{id:r,labels:e,replace:t},Xl,sn)}async remove(r,e){await T(this.client,nw,{id:r,labels:e},ew,sn)}};const aw="sy_label_set",ow="sy_label_delete";let lw=class{constructor(r,e,t){c(this,"type","label"),c(this,"retriever"),c(this,"writer"),c(this,"frameClient"),c(this,"ontology"),this.writer=new iw(r),this.retriever=new Jm(r),this.frameClient=e,this.ontology=t}async search(r){return await this.retriever.search(r)}async retrieve(r){const e=Array.isArray(r),t=await this.retriever.retrieve(r);return e?t:t[0]}async retrieveFor(r){return await this.retriever.retrieveFor(new P(r))}async label(r,e,t={}){await this.writer.set(new P(r),e,t)}async removeLabels(r,e){await this.writer.remove(new P(r),e)}async page(r,e){return await this.retriever.page(r,e)}async create(r){const e=Array.isArray(r),t=await this.writer.create(r);return e?t:t[0]}async delete(r){await this.writer.delete(r)}async openChangeTracker(){return await mt(this.frameClient,aw,ow,uw)}async trackLabelsOf(r){const e=new et.Observer,t=(await this.retrieveFor(r)).map(s=>({id:Gm(s.key),key:s.key,name:s.name,data:s}));return(await this.ontology.openDependentTracker({target:new P(r),dependents:t,relationshipType:"labeled_by"})).onChange(s=>e.notify(s.map(n=>{var a,o;return{key:n.id.key,color:(a=n.data)==null?void 0:a.color,name:(o=n.data)==null?void 0:o.name}}))),e}};const uw=(r,e)=>r==="delete"?e.toUUIDs().map(t=>({variant:r,key:t})):e.parseJSON(Rs).map(t=>({variant:r,key:t.key,value:t})),we=i.z.string().uuid(),yr=i.z.object({key:we,name:i.z.string().min(1),timeRange:oe.z,color:i.z.string().optional()}),Ql=yr.extend({key:i.z.string().uuid().optional()}),eu=r=>{const e=O(r),t=e.length===0;let s=!1;return t||(s=we.safeParse(e[0]).success),{single:!Array.isArray(r),variant:s?"keys":"names",normalized:e,actual:r,empty:t}},tu="range",ru="range-alias",Ye=r=>new P({type:tu,key:r}),cw=r=>new P({type:ru,key:r}),hw="sy_range_alias_set",dw="sy_range_alias_delete",fw=i.z.object({range:we,aliases:i.z.string().array()}),pw=i.z.object({aliases:i.z.record(i.z.string(),Re)}),gw=i.z.object({range:we,aliases:i.z.record(Re.or(i.z.string()),i.z.string())}),yw=i.z.unknown(),mw=i.z.object({range:we,channels:Re.array()}),ww=i.z.unknown(),bw=i.z.object({range:we}),vw=i.z.object({aliases:i.z.record(i.z.string(),i.z.string())}),Ft=class Vt{constructor(e,t,s){c(this,"frameClient"),c(this,"cache",new Map),c(this,"client"),c(this,"rangeKey"),this.rangeKey=e,this.cache=new Map,this.client=s,this.frameClient=t}async resolve(e){const t=[],s=typeof e=="string",n={};if(s){const o=this.cache.get(e);if(o!=null)return o;t.push(e)}else e.forEach(o=>{const u=this.cache.get(o);u!=null?n[o]=u:t.push(o)});if(t.length===0)return n;const a=await T(this.client,Vt.RESOLVE_ENDPOINT,{range:this.rangeKey,aliases:t},fw,pw);return Object.entries(a.aliases).forEach(([o,u])=>this.cache.set(o,u)),s?a.aliases[t[0]]:{...n,...a.aliases}}async set(e){await T(this.client,Vt.SET_ENDPOINT,{range:this.rangeKey,aliases:e},gw,yw)}async list(){return(await T(this.client,Vt.LIST_ENDPOINT,{range:this.rangeKey},bw,vw)).aliases}async delete(e){await T(this.client,Vt.DELETE_ENDPOINT,{range:this.rangeKey,channels:e},mw,ww)}async openChangeTracker(){return await mt(this.frameClient,hw,dw,zw(this.rangeKey))}};c(Ft,"SET_ENDPOINT","/range/alias/set"),c(Ft,"RESOLVE_ENDPOINT","/range/alias/resolve"),c(Ft,"LIST_ENDPOINT","/range/alias/list"),c(Ft,"DELETE_ENDPOINT","/range/alias/delete");let Tw=Ft;const Ow=i.z.object({range:we,channel:Re,alias:i.z.string()}),Sw="---",zw=r=>(e,t)=>e==="delete"?t.toStrings().filter(s=>s.split(Sw)[0]===r).map(s=>({variant:e,key:s,value:void 0})):t.parseJSON(Ow).map(s=>({variant:e,key:s.alias,value:s})),Nw=i.z.object({range:we,keys:i.z.string().array()}),di=i.z.object({range:we,key:i.z.string(),value:i.z.string()}),Ew=i.z.object({pairs:le(di)}),Iw=i.z.object({range:we,pairs:di.array()}),xw=i.z.object({range:we,keys:i.z.string().array()}),rs=class ss{constructor(e,t,s){c(this,"rangeKey"),c(this,"client"),c(this,"frameClient"),this.rangeKey=e,this.client=t,this.frameClient=s}async get(e){const t=await T(this.client,ss.GET_ENDPOINT,{range:this.rangeKey,keys:O(e)},Nw,Ew);return typeof e=="string"?t.pairs[0].value:Object.fromEntries(t.pairs.map(s=>[s.key,s.value]))}async list(){return this.get([])}async set(e,t=""){let s;Xn(e)?s=Object.entries(e).map(([n,a])=>({range:this.rangeKey,key:n,value:a})):s=[{range:this.rangeKey,key:e,value:t}],await T(this.client,ss.SET_ENDPOINT,{range:this.rangeKey,pairs:s},Iw,i.z.unknown())}async delete(e){await T(this.client,ss.DELETE_ENDPOINT,{range:this.rangeKey,keys:O(e)},xw,i.z.unknown())}async openTracker(){return await mt(this.frameClient,"sy_range_kv_set","sy_range_kv_delete",(e,t)=>e==="delete"?t.toStrings().map(s=>{const[n,a]=s.split("<--->",2);return{variant:e,key:s,value:{range:n,key:a,value:""}}}):t.parseJSON(di).map(s=>({variant:e,key:`${s.range}${s.key}`,value:s})))}};c(rs,"GET_ENDPOINT","/range/kv/get"),c(rs,"SET_ENDPOINT","/range/kv/set"),c(rs,"DELETE_ENDPOINT","/range/kv/delete");let Pn=rs;class su{constructor(e,t=oe.ZERO,s,n,a,o,u,l,h,f,d){c(this,"key"),c(this,"name"),c(this,"kv"),c(this,"timeRange"),c(this,"color"),c(this,"channels"),c(this,"aliaser"),c(this,"frameClient"),c(this,"labelClient"),c(this,"ontologyClient"),c(this,"rangeClient"),this.key=s,this.name=e,this.timeRange=t,this.frameClient=a,this.color=n,this.kv=o,this.aliaser=u,this.channels=l,this.labelClient=h,this.ontologyClient=f,this.rangeClient=d}get ontologyID(){return Ye(this.key)}get payload(){return{key:this.key,name:this.name,timeRange:this.timeRange,color:this.color}}async setAlias(e,t){const s=await this.channels.retrieve(e);if(s.length===0)throw new ze(`Channel ${e} does not exist`);await this.aliaser.set({[s[0].key]:t})}async deleteAlias(...e){await this.aliaser.delete(e)}async listAliases(){return await this.aliaser.list()}async resolveAlias(e){return await this.aliaser.resolve(e)}async openAliasTracker(){return await this.aliaser.openChangeTracker()}async retrieveParent(){return this.rangeClient.retrieveParent(this.key)}async retrieveChildren(){const e=(await this.ontologyClient.retrieveChildren(this.ontologyID,{excludeFieldData:!0,types:["range"]})).map(t=>t.id.key);return await this.rangeClient.retrieve(e)}async read(e){return await this.frameClient.read(this.timeRange,e)}async labels(){return await this.labelClient.retrieveFor(Ye(this.key))}async addLabel(...e){await this.labelClient.label(Ye(this.key),e)}async removeLabel(...e){await this.labelClient.removeLabels(Ye(this.key),e)}async openChildRangeTracker(){const e=new et.Observer,t=(await this.retrieveChildren()).map(n=>{const a=Ye(n.key);return{id:a,key:a.toString(),name:n.name,data:n.payload}}),s=await this.ontologyClient.openDependentTracker({target:this.ontologyID,dependents:t,resourceType:"range"});return s.onChange(n=>e.notify(this.rangeClient.resourcesToRanges(n))),e.setCloser(async()=>await s.close()),e}async openParentRangeTracker(){const e=new et.Observer,t=await this.retrieveParent();if(t==null)return null;const s=Ye(t.key),n={id:s,key:s.toString(),name:t.name,data:t.payload},a=await this.ontologyClient.openDependentTracker({target:this.ontologyID,dependents:[n],relationshipDirection:"to"});return a.onChange(o=>{const u=this.rangeClient.resourcesToRanges(o);if(u.length===0)return;const l=u[0];e.notify(l)}),e.setCloser(async()=>await a.close()),e}}const Aw=(r,e)=>yp(r.timeRange,e.timeRange),kw=i.z.object({keys:we.array().optional(),names:i.z.array(i.z.string()).optional(),term:i.z.string().optional(),overlapsWith:oe.z.optional(),limit:i.z.number().int().optional(),offset:i.z.number().int().optional()}),Cw="/range/retrieve",Rw=i.z.object({ranges:le(yr)});let nu=class{constructor(r,e,t,s,n,a){c(this,"type","range"),c(this,"frameClient"),c(this,"writer"),c(this,"unaryClient"),c(this,"channels"),c(this,"labelClient"),c(this,"ontologyClient"),this.frameClient=r,this.writer=e,this.unaryClient=t,this.channels=s,this.labelClient=n,this.ontologyClient=a}async create(r,e){const t=!Array.isArray(r),s=this.sugarMany(await this.writer.create(O(r),e));return t?s[0]:s}async rename(r,e){await this.writer.rename(r,e)}async delete(r){await this.writer.delete(O(r))}async search(r){return this.sugarMany(await this.execRetrieve({term:r}))}async page(r,e){return this.sugarMany(await this.execRetrieve({offset:r,limit:e}))}async retrieve(r){if(typeof r=="object"&&"start"in r)return await this.execRetrieve({overlapsWith:new oe(r)});const{single:e,actual:t,variant:s,normalized:n,empty:a}=eu(r);if(a)return[];const o=await this.execRetrieve({[s]:n});if(!e)return o;if(o.length===0)throw new ht(`range matching ${t} not found`);if(o.length>1)throw new dt(`multiple ranges matching ${t} found`);return o[0]}getKV(r){return new Pn(r,this.unaryClient,this.frameClient)}async execRetrieve(r){const{ranges:e}=await T(this.unaryClient,Cw,r,kw,Rw);return this.sugarMany(e)}async retrieveParent(r){const e=await this.ontologyClient.retrieveParents(Ye(r));if(e.length===0)return null;const t=e[0];return t.id.type!=="range"?null:await this.retrieve(t.id.key)}sugarOne(r){return new su(r.name,r.timeRange,r.key,r.color,this.frameClient,new Pn(r.key,this.unaryClient,this.frameClient),new Tw(r.key,this.frameClient,this.unaryClient),this.channels,this.labelClient,this.ontologyClient,this)}sugarMany(r){return r.map(e=>this.sugarOne(e))}async openTracker(){return await mt(this.frameClient,"sy_range_set","sy_range_delete",(r,e)=>r==="delete"?e.toStrings().map(t=>({variant:r,key:t,value:void 0})):this.sugarMany(e.parseJSON(yr)).map(t=>({variant:r,key:t.key,value:t})))}resourcesToRanges(r){return r.map(e=>this.resourceToRange(e))}resourceToRange(r){var e,t,s;return this.sugarOne({key:r.id.key,name:(e=r.data)==null?void 0:e.name,timeRange:new oe((t=r.data)==null?void 0:t.timeRange),color:(s=r.data)==null?void 0:s.color})}};const $w=i.z.object({ranges:yr.array()}),Mw=i.z.object({parent:ve.optional(),ranges:Ql.array()}),jw=i.z.object({keys:we.array()}),Bw=i.z.object({}),Pw=i.z.object({key:we,name:i.z.string()}),Dw=i.z.object({}),Uw="/range/create",Lw="/range/delete",_w="/range/rename";class iu{constructor(e){c(this,"client"),this.client=e}async rename(e,t){await T(this.client,_w,{key:e,name:t},Pw,Dw)}async create(e,t){return(await T(this.client,Uw,{ranges:e,...t},Mw,$w)).ranges}async delete(e){await T(this.client,Lw,{keys:e},jw,Bw)}}const qw=Object.freeze(Object.defineProperty({__proto__:null,ALIAS_ONTOLOGY_TYPE:ru,Client:nu,KV:Pn,ONTOLOGY_TYPE:tu,Range:su,Writer:iu,aliasOntologyID:cw,analyzeParams:eu,keyZ:we,newPayloadZ:Ql,ontologyID:Ye,payloadZ:yr,sort:Aw},Symbol.toStringTag,{value:"Module"})),Yw="/api/v1/";class Fw{constructor(e,t={},s=!1){c(this,"url"),c(this,"unary"),c(this,"stream"),c(this,"secure"),this.secure=s,this.url=e.child(Yw);const n=new gt.JSONCodec;this.unary=sf(new rf(this.url,n,this.secure),t),this.stream=new ff(this.url,n,this.secure)}use(...e){this.unary.use(...e),this.stream.use(...e)}}const $s=i.z.string().uuid(),fi=i.z.object({key:i.z.string(),name:i.z.string(),data:cr.or(i.z.string().transform(r=>JSON.parse(r)))}),Vw="/workspace/lineplot/retrieve",Gw="/workspace/lineplot/create",Ww="/workspace/lineplot/rename",Zw="/workspace/lineplot/set-data",Jw="/workspace/lineplot/delete",Kw=fi.partial({key:!0}).transform(r=>({...r,data:JSON.stringify(r.data)})),Hw=i.z.object({keys:$s.array()}),Xw=i.z.object({workspace:i.z.string(),linePlots:Kw.array()}),Qw=i.z.object({key:$s,name:i.z.string()}),eb=i.z.object({key:$s,data:i.z.string()}),tb=i.z.object({keys:$s.array()}),rb=i.z.object({linePlots:le(fi)}),sb=i.z.object({linePlots:fi.array()}),nn=i.z.object({});let nb=class{constructor(r){c(this,"client"),this.client=r}async create(r,e){const t=Array.isArray(e),s=O(e),n=await T(this.client,Gw,{workspace:r,linePlots:s},Xw,sb);return t?n.linePlots:n.linePlots[0]}async rename(r,e){await T(this.client,Ww,{key:r,name:e},Qw,nn)}async setData(r,e){await T(this.client,Zw,{key:r,data:JSON.stringify(e)},eb,nn)}async retrieve(r){const e=Array.isArray(r),t=O(r),s=await T(this.client,Vw,{keys:t},Hw,rb);return e?s.linePlots:s.linePlots[0]}async delete(r){const e=O(r);await T(this.client,Jw,{keys:e},tb,nn)}};i.z.string().uuid();const pi=i.z.object({key:i.z.string(),name:i.z.string(),data:cr.or(i.z.string().transform(r=>JSON.parse(r)))}),ib="/workspace/log/retrieve",ab="/workspace/log/create",ob="/workspace/log/rename",lb="/workspace/log/set-data",ub="/workspace/log/delete",cb=pi.partial({key:!0}).transform(r=>({...r,data:JSON.stringify(r.data)})),hb=i.z.object({keys:i.z.string().array()}),db=i.z.object({workspace:i.z.string(),logs:cb.array()}),fb=i.z.object({key:i.z.string(),name:i.z.string()}),pb=i.z.object({key:i.z.string(),data:i.z.string()}),gb=i.z.object({keys:i.z.string().array()}),yb=i.z.object({logs:pi.array()}),mb=i.z.object({logs:pi.array()}),an=i.z.object({});let wb=class{constructor(r){c(this,"client"),this.client=r}async create(r,e){const t=Array.isArray(e),s=O(e),n=await T(this.client,ab,{workspace:r,logs:s},db,mb);return t?n.logs:n.logs[0]}async rename(r,e){await T(this.client,ob,{key:r,name:e},fb,an)}async setData(r,e){await T(this.client,lb,{key:r,data:JSON.stringify(e)},pb,an)}async retrieve(r){const e=Array.isArray(r),t=O(r),s=await T(this.client,ib,{keys:t},hb,yb);return e?s.logs:s.logs[0]}async delete(r){const e=O(r);await T(this.client,ub,{keys:e},gb,an)}};i.z.string().uuid();const au=i.z.object({key:i.z.string(),name:i.z.string(),data:cr.or(i.z.string().transform(r=>JSON.parse(r))),snapshot:i.z.boolean()}),ou=i.z.object({key:i.z.string(),name:i.z.string(),snapshot:i.z.boolean(),data:i.z.string().transform(r=>JSON.parse(r))}),bb="/workspace/schematic/retrieve",vb="/workspace/schematic/create",Tb="/workspace/schematic/rename",Ob="/workspace/schematic/set-data",Sb="/workspace/schematic/delete",zb="/workspace/schematic/copy",Nb=au.partial({key:!0,snapshot:!0}).transform(r=>({...r,data:JSON.stringify(r.data)})),Eb=i.z.object({keys:i.z.string().array()}),Ib=i.z.object({workspace:i.z.string(),schematics:Nb.array()}),xb=i.z.object({key:i.z.string(),name:i.z.string()}),Ab=i.z.object({key:i.z.string(),data:i.z.string()}),kb=i.z.object({keys:i.z.string().array()}),Cb=i.z.object({key:i.z.string(),name:i.z.string(),snapshot:i.z.boolean()}),Rb=i.z.object({schematics:le(ou)}),$b=i.z.object({schematics:ou.array()}),Mb=i.z.object({schematic:au}),on=i.z.object({});let jb=class{constructor(r){c(this,"client"),this.client=r}async create(r,e){const t=Array.isArray(e),s=O(e),n=await T(this.client,vb,{workspace:r,schematics:s},Ib,$b);return t?n.schematics:n.schematics[0]}async rename(r,e){await T(this.client,Tb,{key:r,name:e},xb,on)}async setData(r,e){await T(this.client,Ob,{key:r,data:JSON.stringify(e)},Ab,on)}async retrieve(r){const e=Array.isArray(r),t=O(r),s=await T(this.client,bb,{keys:t},Eb,Rb);return e?s.schematics:s.schematics[0]}async delete(r){const e=O(r);await T(this.client,Sb,{keys:e},kb,on)}async copy(r,e,t){return(await T(this.client,zb,{key:r,name:e,snapshot:t},Cb,Mb)).schematic}};i.z.string().uuid();const Bb=i.z.object({key:i.z.string(),name:i.z.string(),data:cr.or(i.z.string().transform(r=>JSON.parse(r)))}),Pb="/workspace/table/retrieve",Db="/workspace/table/create",Ub="/workspace/table/rename",Lb="/workspace/table/set-data",_b="/workspace/table/delete",qb=Bb.partial({key:!0}).transform(r=>({...r,data:JSON.stringify(r.data)})),lu=i.z.object({key:i.z.string(),name:i.z.string(),data:i.z.string().transform(r=>JSON.parse(r))}),Yb=i.z.object({keys:i.z.string().array()}),Fb=i.z.object({workspace:i.z.string(),tables:qb.array()}),Vb=i.z.object({key:i.z.string(),name:i.z.string()}),Gb=i.z.object({key:i.z.string(),data:i.z.string()}),Wb=i.z.object({keys:i.z.string().array()}),Zb=i.z.object({tables:lu.array()}),Jb=i.z.object({tables:lu.array()}),ln=i.z.object({});let Kb=class{constructor(r){c(this,"client"),this.client=r}async create(r,e){const t=Array.isArray(e),s=O(e),n=await T(this.client,Db,{workspace:r,tables:s},Fb,Jb);return t?n.tables:n.tables[0]}async rename(r,e){await T(this.client,Ub,{key:r,name:e},Vb,ln)}async setData(r,e){await T(this.client,Lb,{key:r,data:JSON.stringify(e)},Gb,ln)}async retrieve(r){const e=Array.isArray(r),t=O(r),s=await T(this.client,Pb,{keys:t},Yb,Zb);return e?s.tables:s.tables[0]}async delete(r){const e=O(r);await T(this.client,_b,{keys:e},Wb,ln)}};i.z.string().uuid();const uu=r=>JSON.parse(r),gi=i.z.object({key:i.z.string(),name:i.z.string(),layout:cr.or(i.z.string().transform(r=>uu(r)))}),Or="/workspace/retrieve",Hb="/workspace/create",Xb="/workspace/rename",Qb="/workspace/set-layout",ev="/workspace/delete",tv=gi.partial({key:!0}).transform(r=>({...r,layout:JSON.stringify(r.layout)})),rv=gi.omit({layout:!0}).extend({layout:i.z.string().transform(r=>uu(r))}),Sr=i.z.object({keys:i.z.string().array().optional(),search:i.z.string().optional(),author:i.z.string().uuid().optional(),offset:i.z.number().optional(),limit:i.z.number().optional()}),sv=i.z.object({workspaces:tv.array()}),nv=i.z.object({key:i.z.string(),name:i.z.string()}),iv=i.z.object({key:i.z.string(),layout:i.z.string()}),av=i.z.object({keys:i.z.string().array()}),zr=i.z.object({workspaces:le(gi)}),ov=i.z.object({workspaces:rv.array()}),un=i.z.object({});class lv{constructor(e){c(this,"type","workspace"),c(this,"schematic"),c(this,"linePlot"),c(this,"log"),c(this,"table"),c(this,"client"),this.client=e,this.schematic=new jb(e),this.linePlot=new nb(e),this.log=new wb(e),this.table=new Kb(e)}async create(e){const t=Array.isArray(e),s=O(e),n=await T(this.client,Hb,{workspaces:s},sv,ov);return t?n.workspaces:n.workspaces[0]}async rename(e,t){await T(this.client,Xb,{key:e,name:t},nv,un)}async setLayout(e,t){await T(this.client,Qb,{key:e,layout:JSON.stringify(t)},iv,un)}async retrieve(e){const t=Array.isArray(e),s=O(e),n=await T(this.client,Or,{keys:s},Sr,zr);return t?n.workspaces:n.workspaces[0]}async retrieveByAuthor(e){return(await T(this.client,Or,{author:e},Sr,zr)).workspaces}async search(e){return(await T(this.client,Or,{search:e},Sr,zr)).workspaces}async page(e,t){return(await T(this.client,Or,{offset:e,limit:t},Sr,zr)).workspaces}async delete(e){const t=O(e);await T(this.client,ev,{keys:t},av,un)}}const cu=i.z.object({host:i.z.string({required_error:"Host is required"}).min(1,"Host is required"),port:i.z.number({required_error:"Port is required"}).or(i.z.string({required_error:"Port is required"})),username:i.z.string().min(1,"Username is required"),password:i.z.string().min(1,"Password is required"),connectivityPollFrequency:x.z.default(x.seconds(30)),secure:i.z.boolean().optional().default(!1),name:i.z.string().optional(),retry:Vp.breakerConfig.optional()});class hu extends tm{constructor(e){const t=cu.parse(e),{host:s,port:n,username:a,password:o,connectivityPollFrequency:u,secure:l,retry:h}=t,f=new Fw(new Up({host:s,port:Number(n)}),h,l);f.use(ng);let d;a!=null&&o!=null&&(d=new Ry(f.unary,{username:a,password:o}),f.use(d.middleware()));const I=new si(new ri(f.unary)),j=new _l(f.unary,I);super(f.stream,f.unary,I),c(this,"createdAt"),c(this,"props"),c(this,"ranges"),c(this,"channels"),c(this,"auth"),c(this,"user"),c(this,"access"),c(this,"connectivity"),c(this,"ontology"),c(this,"workspaces"),c(this,"labels"),c(this,"hardware"),c(this,"control"),c(this,"transport"),c(this,"clientVersion","0.38.1"),this.createdAt=$.now(),this.props=t,this.auth=d,this.transport=f,this.channels=new Ul(this,I,f.unary,j),this.connectivity=new Fl(f.unary,u,this.clientVersion,t.name),this.control=new Zl(this),this.ontology=new zg(f.unary,this);const ue=new iu(this.transport.unary);this.labels=new lw(this.transport.unary,this,this.ontology),this.ranges=new nu(this,ue,this.transport.unary,I,this.labels,this.ontology),this.access=new Ug(this.transport.unary),this.user=new Ny(this.transport.unary),this.workspaces=new lv(this.transport.unary);const D=new wm(this.transport.unary,this),Si=new Fm(this.transport.unary,this,this.ontology,this.ranges),Mu=new Em(this.transport.unary,this,Si);this.hardware=new om(Si,Mu,D)}get key(){return this.createdAt.valueOf().toString()}close(){this.connectivity.stopChecking()}}c(hu,"connectivity",Fl);const uv=ct.Authority,Dn=(r,e,t="")=>{try{return r.parse(e)}catch(s){if(s instanceof i.z.ZodError){const n=s.errors.map(a=>a.path.length===0?a.message:`${a.path.join(".")}: ${a.message}`);throw new Error(`${t} - ${n.join(`
|
|
66
|
-
`)}`)}else throw s}};var cv=Object.defineProperty,hv=(r,e,t)=>e in r?cv(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,se=(r,e,t)=>hv(r,typeof e!="symbol"?e+"":e,t);const Un=class du{constructor(e,t,s="",n=!1){se(this,"_noop",!1),se(this,"key"),se(this,"path"),se(this,"serviceName"),this.key=e,this.path=t,this.serviceName=s,this._noop=n}child(e){return new du(e,this.extendPath(e),this.serviceName,this.noop)}extendPath(e){return`${this.path}.${e}`}get noop(){return this._noop}};se(Un,"NOOP",new Un("","",""));let yi=Un;const Ln=["debug","info","warn","error"],dv=r=>{const e=Ln.indexOf(r);return({level:t})=>Ln.indexOf(t)>=e},fv=r=>{const{include:e,exclude:t}=r;return({path:s})=>!(e!=null&&!e.some(n=>s.startsWith(n))||t!=null&&t.some(n=>s.startsWith(n)))},_n=class fu{constructor(e={}){se(this,"meta",yi.NOOP),se(this,"filters");const{filters:t=[]}=e;this.filters=t}filter(e){return!this.meta.noop&&this.filters.every(t=>t({key:this.meta.key,path:this.meta.path,level:e}))}child(e){const t=new fu({filters:this.filters});return t.meta=e,t}debug(e,t,s=!1){!this.filter("debug")&&!s||(t==null?console.log("%cDEBUG","color: #8c00f0;",this.meta.path,e):console.log("%cDEBUG","color: #8c00f0;",this.meta.path,e,Nr(t)))}info(e,t,s=!1){!this.filter("info")&&!s||(t==null?console.log("%cINFO","color: #005eff;",this.meta.path,e):console.log("%cINFO","color: #005eff;",this.meta.path,e,Nr(t)))}warn(e,t,s=!1){!this.filter("warn")&&!s||(t==null?console.warn("WARN",this.meta.path,e):console.warn("WARN",this.meta.path,e,Nr(t)))}error(e,t,s=!1){!this.filter("error")&&!s||(t==null?console.error("ERROR",this.meta.path,e):console.error("ERROR",this.meta.path,e,Nr(t)))}};se(_n,"NOOP",new _n);let pu=_n;const Nr=r=>typeof r=="function"?r():r;var pv=typeof globalThis=="object"?globalThis:typeof self=="object"?self:typeof window=="object"?window:typeof global=="object"?global:{},Xe="1.9.0",Ba=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function gv(r){var e=new Set([r]),t=new Set,s=r.match(Ba);if(!s)return function(){return!1};var n={major:+s[1],minor:+s[2],patch:+s[3],prerelease:s[4]};if(n.prerelease!=null)return function(u){return u===r};function a(u){return t.add(u),!1}function o(u){return e.add(u),!0}return function(u){if(e.has(u))return!0;if(t.has(u))return!1;var l=u.match(Ba);if(!l)return a(u);var h={major:+l[1],minor:+l[2],patch:+l[3],prerelease:l[4]};return h.prerelease!=null||n.major!==h.major?a(u):n.major===0?n.minor===h.minor&&n.patch<=h.patch?o(u):a(u):n.minor<=h.minor?o(u):a(u)}}var yv=gv(Xe),mv=Xe.split(".")[0],tr=Symbol.for("opentelemetry.js.api."+mv),rr=pv;function mi(r,e,t,s){var n;s===void 0&&(s=!1);var a=rr[tr]=(n=rr[tr])!==null&&n!==void 0?n:{version:Xe};if(!s&&a[r]){var o=new Error("@opentelemetry/api: Attempted duplicate registration of API: "+r);return t.error(o.stack||o.message),!1}if(a.version!==Xe){var o=new Error("@opentelemetry/api: Registration of version v"+a.version+" for "+r+" does not match previously registered API v"+Xe);return t.error(o.stack||o.message),!1}return a[r]=e,t.debug("@opentelemetry/api: Registered a global for "+r+" v"+Xe+"."),!0}function sr(r){var e,t,s=(e=rr[tr])===null||e===void 0?void 0:e.version;if(!(!s||!yv(s)))return(t=rr[tr])===null||t===void 0?void 0:t[r]}function wi(r,e){e.debug("@opentelemetry/api: Unregistering a global for "+r+" v"+Xe+".");var t=rr[tr];t&&delete t[r]}var wv=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var s=t.call(r),n,a=[],o;try{for(;(e===void 0||e-- >0)&&!(n=s.next()).done;)a.push(n.value)}catch(u){o={error:u}}finally{try{n&&!n.done&&(t=s.return)&&t.call(s)}finally{if(o)throw o.error}}return a},bv=function(r,e,t){if(arguments.length===2)for(var s=0,n=e.length,a;s<n;s++)(a||!(s in e))&&(a||(a=Array.prototype.slice.call(e,0,s)),a[s]=e[s]);return r.concat(a||Array.prototype.slice.call(e))},vv=function(){function r(e){this._namespace=e.namespace||"DiagComponentLogger"}return r.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Nt("debug",this._namespace,e)},r.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Nt("error",this._namespace,e)},r.prototype.info=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Nt("info",this._namespace,e)},r.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Nt("warn",this._namespace,e)},r.prototype.verbose=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Nt("verbose",this._namespace,e)},r}();function Nt(r,e,t){var s=sr("diag");if(s)return t.unshift(e),s[r].apply(s,bv([],wv(t),!1))}var Te;(function(r){r[r.NONE=0]="NONE",r[r.ERROR=30]="ERROR",r[r.WARN=50]="WARN",r[r.INFO=60]="INFO",r[r.DEBUG=70]="DEBUG",r[r.VERBOSE=80]="VERBOSE",r[r.ALL=9999]="ALL"})(Te||(Te={}));function Tv(r,e){r<Te.NONE?r=Te.NONE:r>Te.ALL&&(r=Te.ALL),e=e||{};function t(s,n){var a=e[s];return typeof a=="function"&&r>=n?a.bind(e):function(){}}return{error:t("error",Te.ERROR),warn:t("warn",Te.WARN),info:t("info",Te.INFO),debug:t("debug",Te.DEBUG),verbose:t("verbose",Te.VERBOSE)}}var Ov=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var s=t.call(r),n,a=[],o;try{for(;(e===void 0||e-- >0)&&!(n=s.next()).done;)a.push(n.value)}catch(u){o={error:u}}finally{try{n&&!n.done&&(t=s.return)&&t.call(s)}finally{if(o)throw o.error}}return a},Sv=function(r,e,t){if(arguments.length===2)for(var s=0,n=e.length,a;s<n;s++)(a||!(s in e))&&(a||(a=Array.prototype.slice.call(e,0,s)),a[s]=e[s]);return r.concat(a||Array.prototype.slice.call(e))},zv="diag",nr=function(){function r(){function e(n){return function(){for(var a=[],o=0;o<arguments.length;o++)a[o]=arguments[o];var u=sr("diag");if(u)return u[n].apply(u,Sv([],Ov(a),!1))}}var t=this,s=function(n,a){var o,u,l;if(a===void 0&&(a={logLevel:Te.INFO}),n===t){var h=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return t.error((o=h.stack)!==null&&o!==void 0?o:h.message),!1}typeof a=="number"&&(a={logLevel:a});var f=sr("diag"),d=Tv((u=a.logLevel)!==null&&u!==void 0?u:Te.INFO,n);if(f&&!a.suppressOverrideMessage){var I=(l=new Error().stack)!==null&&l!==void 0?l:"<failed to generate stacktrace>";f.warn("Current logger will be overwritten from "+I),d.warn("Current logger will overwrite one already registered from "+I)}return mi("diag",d,t,!0)};t.setLogger=s,t.disable=function(){wi(zv,t)},t.createComponentLogger=function(n){return new vv(n)},t.verbose=e("verbose"),t.debug=e("debug"),t.info=e("info"),t.warn=e("warn"),t.error=e("error")}return r.instance=function(){return this._instance||(this._instance=new r),this._instance},r}(),Nv=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var s=t.call(r),n,a=[],o;try{for(;(e===void 0||e-- >0)&&!(n=s.next()).done;)a.push(n.value)}catch(u){o={error:u}}finally{try{n&&!n.done&&(t=s.return)&&t.call(s)}finally{if(o)throw o.error}}return a},Ev=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],s=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&s>=r.length&&(r=void 0),{value:r&&r[s++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Iv=function(){function r(e){this._entries=e?new Map(e):new Map}return r.prototype.getEntry=function(e){var t=this._entries.get(e);if(t)return Object.assign({},t)},r.prototype.getAllEntries=function(){return Array.from(this._entries.entries()).map(function(e){var t=Nv(e,2),s=t[0],n=t[1];return[s,n]})},r.prototype.setEntry=function(e,t){var s=new r(this._entries);return s._entries.set(e,t),s},r.prototype.removeEntry=function(e){var t=new r(this._entries);return t._entries.delete(e),t},r.prototype.removeEntries=function(){for(var e,t,s=[],n=0;n<arguments.length;n++)s[n]=arguments[n];var a=new r(this._entries);try{for(var o=Ev(s),u=o.next();!u.done;u=o.next()){var l=u.value;a._entries.delete(l)}}catch(h){e={error:h}}finally{try{u&&!u.done&&(t=o.return)&&t.call(o)}finally{if(e)throw e.error}}return a},r.prototype.clear=function(){return new r},r}();nr.instance();function xv(r){return r===void 0&&(r={}),new Iv(new Map(Object.entries(r)))}function Av(r){return Symbol.for(r)}var kv=function(){function r(e){var t=this;t._currentContext=e?new Map(e):new Map,t.getValue=function(s){return t._currentContext.get(s)},t.setValue=function(s,n){var a=new r(t._currentContext);return a._currentContext.set(s,n),a},t.deleteValue=function(s){var n=new r(t._currentContext);return n._currentContext.delete(s),n}}return r}(),Cv=new kv,Rv={get:function(r,e){if(r!=null)return r[e]},keys:function(r){return r==null?[]:Object.keys(r)}},$v={set:function(r,e,t){r!=null&&(r[e]=t)}},Mv=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var s=t.call(r),n,a=[],o;try{for(;(e===void 0||e-- >0)&&!(n=s.next()).done;)a.push(n.value)}catch(u){o={error:u}}finally{try{n&&!n.done&&(t=s.return)&&t.call(s)}finally{if(o)throw o.error}}return a},jv=function(r,e,t){if(arguments.length===2)for(var s=0,n=e.length,a;s<n;s++)(a||!(s in e))&&(a||(a=Array.prototype.slice.call(e,0,s)),a[s]=e[s]);return r.concat(a||Array.prototype.slice.call(e))},Bv=function(){function r(){}return r.prototype.active=function(){return Cv},r.prototype.with=function(e,t,s){for(var n=[],a=3;a<arguments.length;a++)n[a-3]=arguments[a];return t.call.apply(t,jv([s],Mv(n),!1))},r.prototype.bind=function(e,t){return t},r.prototype.enable=function(){return this},r.prototype.disable=function(){return this},r}(),Pv=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var s=t.call(r),n,a=[],o;try{for(;(e===void 0||e-- >0)&&!(n=s.next()).done;)a.push(n.value)}catch(u){o={error:u}}finally{try{n&&!n.done&&(t=s.return)&&t.call(s)}finally{if(o)throw o.error}}return a},Dv=function(r,e,t){if(arguments.length===2)for(var s=0,n=e.length,a;s<n;s++)(a||!(s in e))&&(a||(a=Array.prototype.slice.call(e,0,s)),a[s]=e[s]);return r.concat(a||Array.prototype.slice.call(e))},cn="context",Uv=new Bv,gu=function(){function r(){}return r.getInstance=function(){return this._instance||(this._instance=new r),this._instance},r.prototype.setGlobalContextManager=function(e){return mi(cn,e,nr.instance())},r.prototype.active=function(){return this._getContextManager().active()},r.prototype.with=function(e,t,s){for(var n,a=[],o=3;o<arguments.length;o++)a[o-3]=arguments[o];return(n=this._getContextManager()).with.apply(n,Dv([e,t,s],Pv(a),!1))},r.prototype.bind=function(e,t){return this._getContextManager().bind(e,t)},r.prototype._getContextManager=function(){return sr(cn)||Uv},r.prototype.disable=function(){this._getContextManager().disable(),wi(cn,nr.instance())},r}(),qn;(function(r){r[r.UNSET=0]="UNSET",r[r.OK=1]="OK",r[r.ERROR=2]="ERROR"})(qn||(qn={}));var Lv=gu.getInstance(),_v=function(){function r(){}return r.prototype.inject=function(e,t){},r.prototype.extract=function(e,t){return e},r.prototype.fields=function(){return[]},r}(),bi=Av("OpenTelemetry Baggage Key");function yu(r){return r.getValue(bi)||void 0}function qv(){return yu(gu.getInstance().active())}function Yv(r,e){return r.setValue(bi,e)}function Fv(r){return r.deleteValue(bi)}var hn="propagation",Vv=new _v,Gv=function(){function r(){this.createBaggage=xv,this.getBaggage=yu,this.getActiveBaggage=qv,this.setBaggage=Yv,this.deleteBaggage=Fv}return r.getInstance=function(){return this._instance||(this._instance=new r),this._instance},r.prototype.setGlobalPropagator=function(e){return mi(hn,e,nr.instance())},r.prototype.inject=function(e,t,s){return s===void 0&&(s=$v),this._getGlobalPropagator().inject(e,t,s)},r.prototype.extract=function(e,t,s){return s===void 0&&(s=Rv),this._getGlobalPropagator().extract(e,t,s)},r.prototype.fields=function(){return this._getGlobalPropagator().fields()},r.prototype.disable=function(){wi(hn,nr.instance())},r.prototype._getGlobalPropagator=function(){return sr(hn)||Vv},r}(),Wv=Gv.getInstance();const Pa=["bench","debug","prod"],Zv=r=>e=>Pa.indexOf(e)>=Pa.indexOf(r),Yn=class mu{constructor(e,t=Zv("debug")){se(this,"meta",yi.NOOP),se(this,"tracer"),se(this,"filter"),this.tracer=e,this.filter=t}child(e){const t=new mu(this.tracer,this.filter);return t.meta=e,t}debug(e,t){return this.trace(e,"debug",t)}bench(e,t){return this.trace(e,"bench",t)}prod(e,t){return this.trace(e,"prod",t)}trace(e,t,s){return this.meta.noop||!this.filter(t)?s(new vu(e)):this.tracer.startActiveSpan(e,n=>{const a=new bu(e,n),o=s(a);return n.end(),o})}propagate(e){if(this.meta.noop)return;const t=Lv.active();Wv.inject(t,e,{set:(s,n,a)=>{s[n]=a}})}};se(Yn,"NOOP",new Yn);let wu=Yn;class bu{constructor(e,t){se(this,"key"),se(this,"otel"),this.key=e,this.otel=t}set(e,t){this.otel.setAttribute(e,t)}recordError(e){e!=null&&(this.otel.recordException(e),this.otel.setStatus({code:qn.ERROR}))}}class vu{constructor(e){se(this,"key"),this.key=e}set(){}recordError(e){}}const Fn=class Tu{constructor({key:e="",serviceName:t="",logger:s=pu.NOOP,tracer:n=wu.NOOP,noop:a=!1,__meta:o}){se(this,"meta"),se(this,"T"),se(this,"L"),this.meta=o??new yi(e,e,t,a),this.T=n.child(this.meta),this.L=s.child(this.meta)}child(e){const t=this.meta.child(e);return new Tu({__meta:t,tracer:this.T,logger:this.L})}};se(Fn,"NOOP",new Fn({noop:!0}));let vi=Fn;const Jv=vi.NOOP,Ou=Object.freeze(Object.defineProperty({__proto__:null,Instrumentation:vi,LOG_LEVELS:Ln,Logger:pu,NOOP:Jv,NoopSpan:vu,Tracer:wu,_Span:bu,logLevelKeyFiler:fv,logThresholdFilter:dv},Symbol.toStringTag,{value:"Module"})),Kv=new Error("request for lock canceled");var Hv=function(r,e,t,s){function n(a){return a instanceof t?a:new t(function(o){o(a)})}return new(t||(t=Promise))(function(a,o){function u(f){try{h(s.next(f))}catch(d){o(d)}}function l(f){try{h(s.throw(f))}catch(d){o(d)}}function h(f){f.done?a(f.value):n(f.value).then(u,l)}h((s=s.apply(r,e||[])).next())})};class Xv{constructor(e,t=Kv){this._value=e,this._cancelError=t,this._queue=[],this._weightedWaiters=[]}acquire(e=1,t=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return new Promise((s,n)=>{const a={resolve:s,reject:n,weight:e,priority:t},o=Su(this._queue,u=>t<=u.priority);o===-1&&e<=this._value?this._dispatchItem(a):this._queue.splice(o+1,0,a)})}runExclusive(e){return Hv(this,arguments,void 0,function*(t,s=1,n=0){const[a,o]=yield this.acquire(s,n);try{return yield t(a)}finally{o()}})}waitForUnlock(e=1,t=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return this._couldLockImmediately(e,t)?Promise.resolve():new Promise(s=>{this._weightedWaiters[e-1]||(this._weightedWaiters[e-1]=[]),Qv(this._weightedWaiters[e-1],{resolve:s,priority:t})})}isLocked(){return this._value<=0}getValue(){return this._value}setValue(e){this._value=e,this._dispatchQueue()}release(e=1){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);this._value+=e,this._dispatchQueue()}cancel(){this._queue.forEach(e=>e.reject(this._cancelError)),this._queue=[]}_dispatchQueue(){for(this._drainUnlockWaiters();this._queue.length>0&&this._queue[0].weight<=this._value;)this._dispatchItem(this._queue.shift()),this._drainUnlockWaiters()}_dispatchItem(e){const t=this._value;this._value-=e.weight,e.resolve([t,this._newReleaser(e.weight)])}_newReleaser(e){let t=!1;return()=>{t||(t=!0,this.release(e))}}_drainUnlockWaiters(){if(this._queue.length===0)for(let e=this._value;e>0;e--){const t=this._weightedWaiters[e-1];t&&(t.forEach(s=>s.resolve()),this._weightedWaiters[e-1]=[])}else{const e=this._queue[0].priority;for(let t=this._value;t>0;t--){const s=this._weightedWaiters[t-1];if(!s)continue;const n=s.findIndex(a=>a.priority<=e);(n===-1?s:s.splice(0,n)).forEach(a=>a.resolve())}}}_couldLockImmediately(e,t){return(this._queue.length===0||this._queue[0].priority<t)&&e<=this._value}}function Qv(r,e){const t=Su(r,s=>e.priority<=s.priority);r.splice(t+1,0,e)}function Su(r,e){for(let t=r.length-1;t>=0;t--)if(e(r[t]))return t;return-1}var eT=function(r,e,t,s){function n(a){return a instanceof t?a:new t(function(o){o(a)})}return new(t||(t=Promise))(function(a,o){function u(f){try{h(s.next(f))}catch(d){o(d)}}function l(f){try{h(s.throw(f))}catch(d){o(d)}}function h(f){f.done?a(f.value):n(f.value).then(u,l)}h((s=s.apply(r,e||[])).next())})};class Ti{constructor(e){this._semaphore=new Xv(1,e)}acquire(){return eT(this,arguments,void 0,function*(e=0){const[,t]=yield this._semaphore.acquire(1,e);return t})}runExclusive(e,t=0){return this._semaphore.runExclusive(()=>e(),1,t)}isLocked(){return this._semaphore.isLocked()}waitForUnlock(e=0){return this._semaphore.waitForUnlock(1,e)}release(){this._semaphore.isLocked()&&this._semaphore.release()}cancel(){return this._semaphore.cancel()}}class Ms{constructor({key:e,type:t,sender:s,instrumentation:n,parentCtxValues:a}){S(this,"type");S(this,"key");S(this,"sender");S(this,"_internalState");S(this,"_state");S(this,"_prevState");S(this,"_deleted",!1);S(this,"parentCtxValues");S(this,"childCtxValues");S(this,"childCtxChangedKeys");S(this,"instrumentation");S(this,"schema");this.type=t,this.key=e,this.sender=s,this._internalState={},this.instrumentation=n.child(`${this.type}(${this.key})`),this.parentCtxValues=new Map,a==null||a.forEach((o,u)=>this.parentCtxValues.set(u,o)),this.childCtxValues=new Map,this.childCtxChangedKeys=new Set}get _schema(){if(this.schema==null)throw new Q(`[AetherLeaf] - expected subclass to define component schema, but none was found.
|
|
67
|
-
Make sure to define a property 'schema' on the class.`);return this.schema}setState(e){const t=Jn(e,this._state);this._prevState={...this._state},this._state=Dn(this._schema,t,`${this.type}:${this.key}`),this.sender.send({key:this.key,state:t})}get state(){if(this._state==null)throw new be(`[AetherLeaf] - state not defined in ${this.type}:${this.key}`);return this._state}get internal(){return this._internalState}get prevState(){return this._prevState}get deleted(){return this._deleted}get ctx(){return{get:e=>this.parentCtxValues.get(e),getOptional:e=>this.parentCtxValues.get(e),has:e=>this.parentCtxValues.has(e),setPreviously:e=>this.childCtxValues.has(e),set:(e,t,s=!0)=>{this.childCtxValues.set(e,t),s&&this.childCtxChangedKeys.add(e)}}}async _updateState(e,t,s){if(this.deleted)return;this.validatePath(e);const n=Dn(this._schema,t,`${this.type}:${this.key}`);this._state!=null?this.instrumentation.L.debug("updating state",()=>({diff:io.difference(this.state,n)})):this.instrumentation.L.debug("setting initial state",{state:t}),this._prevState=this._state??n,this._state=n,await this.afterUpdate(this.ctx)}async _updateContext(e){e.forEach((t,s)=>this.parentCtxValues.set(s,t)),await this.afterUpdate(this.ctx)}async _delete(e){this.validatePath(e),this._deleted=!0,await this.afterDelete(this.ctx)}async afterUpdate(e){}async afterDelete(e){}validatePath(e){if(e.length===0)throw new be(`[Leaf.setState] - ${this.type}:${this.key} received an empty path`);const t=e[e.length-1];if(e.length>1)throw new be(`[Leaf.setState] - ${this.type}:${this.key} received a subPath ${e.join(".")} but is a leaf`);if(t!==this.key)throw new be(`[Leaf.setState] - ${this.type}:${this.key} received a key ${t} but expected ${this.key}`)}}class mr extends Ms{constructor(){super(...arguments);S(this,"_children",new Map)}get children(){return Array.from(this._children.values())}getChild(t){return this._children.get(t)??null}childrenOfType(...t){return this.children.filter(s=>t.includes(s.type))}async _updateState(t,s,n){if(this.deleted)return;const a=this.parsePath(t);if(a.length===0){if(this.childCtxChangedKeys.clear(),await super._updateState(t,s,n),this.childCtxChangedKeys.size==0)return;await this.updateChildContexts();return}const u=a[0],l=this.getChild(u);if(l!=null)return l._updateState(a,s,n);if(a.length>1)throw new be(`[Composite.update] - ${this.type}:${this.key} received a subPath ${a.join(".")} but found now child with key ${u}`);const h=n(this.childCtx());await h._updateState(a,s,n),this._children.set(u,h)}async _updateContext(t){await super._updateContext(t),await this.updateChildContexts()}childCtx(){return{get:t=>this.childCtxValues.get(t)??this.parentCtxValues.get(t),forEach:t=>{this.childCtxValues.forEach((s,n)=>t(s,n,this.childCtxValues)),this.parentCtxValues.forEach((s,n)=>{this.childCtxValues.has(n)||t(s,n,this.parentCtxValues)})}}}async updateChildContexts(){for(const t of this.children)await t._updateContext(this.childCtx())}async _delete(t){const s=this.parsePath(t);if(s.length===0){for(const a of this.children)await a._delete([a.key]);this._children.clear(),await super._delete([this.key])}const n=this.getChild(s[0]);if(n!=null){if(s.length>1)return await n._delete(s);this._children.delete(n.key),await n._delete(s)}}parsePath(t,s){const[n,...a]=t;if(n==null)throw new Error(`Composite ${this.type}:${this.key} received an empty path${s!=null?` for ${s}`:""}`);if(n!==this.key)throw new be(`[Composite.getRequiredKey] - ${this.type}:${this.key} received a key ${n} but expected ${this.key}`);return a}}const tT=i.z.object({}),rT=()=>{throw new Error("should not call create")},Fe=class Fe extends mr{constructor({comms:t,instrumentation:s=Ou.Instrumentation.NOOP,registry:n}){super({key:Fe.KEY,type:Fe.TYPE,sender:t,instrumentation:s,parentCtxValues:null});S(this,"comms");S(this,"registry");S(this,"mu",new Ti);S(this,"schema",tT);this.comms=t,this.registry=n}static async render(t){const s=new Fe(t);return await s._updateState([Fe.KEY],{},rT),s.comms.handle(n=>{s.mu.runExclusive(async()=>{await s.handle(n)})}),s}async handle(t){const{path:s,variant:n,type:a}=t;n==="delete"?await this._delete(s):await this._updateState(s,t.state,o=>{const u=s[s.length-1];return this.create({key:u,type:a,parentCtxValues:o})})}create({key:t,type:s,parentCtxValues:n}){const a=this.registry[s];if(a==null)throw new be(`[Root.create] - ${s} not found in registry`);return new a({key:t,type:s,sender:this.comms,instrumentation:this.instrumentation,parentCtxValues:n})}};S(Fe,"TYPE","root"),S(Fe,"KEY","root");let ir=Fe;const zu=ir.render.bind(ir),sT=Object.freeze(Object.defineProperty({__proto__:null,Composite:mr,Leaf:Ms,Root:ir,render:zu},Symbol.toStringTag,{value:"Module"})),ns=(r,e)=>p.Tt.construct(p.Tt.left(r)-e.x,p.Tt.top(r)-e.y,p.Tt.width(r)+e.x*2,p.Tt.height(r)+e.y*2);class ps{constructor(e,t=p.b.XY.IDENTITY){S(this,"scale_");S(this,"wrapped");this.wrapped=e,this.scale_=t}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}reset(){this.wrapped.reset()}applyScale(e){return new ps(this,e)}get canvas(){return this.wrapped.canvas}get miterLimit(){return this.wrapped.miterLimit}set miterLimit(e){this.wrapped.miterLimit=this.scale_.x.dim(e)}get globalAlpha(){return this.wrapped.globalAlpha}set globalAlpha(e){this.wrapped.globalAlpha=e}get globalCompositeOperation(){return this.wrapped.globalCompositeOperation}set globalCompositeOperation(e){this.wrapped.globalCompositeOperation=e}get fillStyle(){return this.wrapped.fillStyle}set fillStyle(e){this.wrapped.fillStyle=e}get strokeStyle(){return this.wrapped.strokeStyle}set strokeStyle(e){this.wrapped.strokeStyle=e}drawImage(e,t,s,n,a,o,u,l,h){this.wrapped.drawImage(e,t,s,n,a,o,u,l,h)}beginPath(){this.wrapped.beginPath()}clip(e,t){this.wrapped.clip(e,t)}fill(e,t){if(e==null)return this.wrapped.fill();this.wrapped.fill(e,t)}isPointInPath(e,t,s,n){return this.wrapped.isPointInPath(e,t,s,n)}isPointInStroke(e,t,s){return this.wrapped.isPointInStroke(e,t,s)}stroke(e){if(e==null)return this.wrapped.stroke();this.wrapped.stroke(e)}createConicGradient(e,t,s){return this.wrapped.createConicGradient(e,t,s)}createLinearGradient(e,t,s,n){return this.wrapped.createLinearGradient(e,t,s,n)}createPattern(e,t){return this.wrapped.createPattern(e,t)}createRadialGradient(e,t,s,n,a,o){return this.wrapped.createRadialGradient(e,t,s,n,a,o)}get filter(){return this.wrapped.filter}set filter(e){this.wrapped.filter=e}createImageData(e,t,s){return this.wrapped.createImageData(e,t,s)}getImageData(e,t,s,n,a){return this.wrapped.getImageData(e,t,s,n,a)}putImageData(e,t,s,n,a,o,u){this.wrapped.putImageData(e,t,s,n,a,o,u)}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,t,s,n,a,o){this.wrapped.arc(this.scale_.x.pos(e),this.scale_.y.pos(t),this.scale_.x.dim(s),n,a,o)}arcTo(e,t,s,n,a){this.wrapped.arcTo(this.scale_.x.pos(e),this.scale_.y.pos(t),this.scale_.x.pos(s),this.scale_.y.pos(n),this.scale_.x.dim(a))}bezierCurveTo(e,t,s,n,a,o){this.wrapped.bezierCurveTo(this.scale_.x.pos(e),this.scale_.y.pos(t),this.scale_.x.pos(s),this.scale_.y.pos(n),this.scale_.x.pos(a),this.scale_.y.pos(o))}closePath(){this.wrapped.closePath()}ellipse(e,t,s,n,a,o,u,l){this.wrapped.ellipse(this.scale_.x.pos(e),this.scale_.y.pos(t),this.scale_.x.dim(s),this.scale_.y.dim(n),a,o,u,l)}lineTo(e,t){this.wrapped.lineTo(this.scale_.x.pos(e),this.scale_.y.pos(t))}moveTo(e,t){this.wrapped.moveTo(this.scale_.x.pos(e),this.scale_.y.pos(t))}quadraticCurveTo(e,t,s,n){this.wrapped.quadraticCurveTo(this.scale_.x.pos(e),this.scale_.y.pos(t),this.scale_.x.pos(s),this.scale_.y.pos(n))}rect(e,t,s,n){this.wrapped.rect(this.scale_.x.pos(e),this.scale_.y.pos(t),this.scale_.x.dim(s),this.scale_.y.dim(n))}roundRect(e,t,s,n,a){this.wrapped.roundRect(this.scale_.x.pos(e),this.scale_.y.pos(t),this.scale_.x.dim(s),this.scale_.y.dim(n),typeof a=="number"?this.scale_.x.dim(a):a)}get lineCap(){return this.wrapped.lineCap}set lineCap(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.wrapped.lineJoin}set lineJoin(e){this.wrapped.lineJoin=e}get lineWidth(){return this.wrapped.lineWidth}set lineWidth(e){this.wrapped.lineWidth=this.scale_.x.dim(e)}getLineDash(){return this.wrapped.getLineDash()}setLineDash(e){const t=Array.from(e).map(s=>this.scale_.x.dim(s));this.wrapped.setLineDash(t)}clearRect(e,t,s,n){this.wrapped.clearRect(e,t,s,n)}fillRect(e,t,s,n){this.wrapped.fillRect(this.scale_.x.pos(e),this.scale_.y.pos(t),this.scale_.x.dim(s),this.scale_.y.dim(n))}strokeRect(e,t,s,n){this.wrapped.strokeRect(this.scale_.x.pos(e),this.scale_.y.pos(t),this.scale_.x.dim(s),this.scale_.y.dim(n))}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.wrapped.restore()}save(){this.wrapped.save()}fillText(e,t,s,n){this.wrapped.fillText(e,this.scale_.x.pos(t),this.scale_.y.pos(s),n!=null?this.scale_.x.dim(n):void 0)}measureText(e){this.wrapped.font=dn(this.wrapped.font,this.scale_.x.reverse());const t=this.wrapped.measureText(e);return this.wrapped.font=dn(this.wrapped.font,this.scale_.x),t}strokeText(e,t,s,n){this.wrapped.strokeText(e,this.scale_.x.pos(t),this.scale_.y.pos(s),n!=null?this.scale_.x.dim(n):void 0)}get direction(){return this.wrapped.direction}set direction(e){this.wrapped.direction=e}get font(){return this.wrapped.font}set font(e){this.wrapped.font=dn(e,this.scale_.x)}get fontKerning(){return this.wrapped.fontKerning}set fontKerning(e){this.wrapped.fontKerning=e}get textAlign(){return this.wrapped.textAlign}set textAlign(e){this.wrapped.textAlign=e}get textBaseline(){return this.wrapped.textBaseline}set textBaseline(e){this.wrapped.textBaseline=e}getTransform(){return this.wrapped.getTransform()}resetTransform(){this.wrapped.resetTransform()}rotate(e){this.wrapped.rotate(e)}scale(e,t){this.wrapped.scale(e,t)}scissor(e,t=p.G.ZERO){const s=new nT(this.scale_);return e=ns(e,t),s.rect(...p.G.couple(p.Tt.topLeft(e)),...p._.couple(p.Tt.dims(e))),this.save(),this.clip(s.getPath()),()=>this.restore()}setTransform(e,t,s,n,a,o){this.wrapped.setTransform(e,t,s,n,a,o)}transform(e,t,s,n,a,o){this.wrapped.transform(e,t,s,n,a,o)}translate(e,t){this.wrapped.translate(e,t)}}const Da=/(\d+(\.\d+)?)px/,dn=(r,e)=>{var n;const t=Number((n=r.match(Da))==null?void 0:n[1]);if(t==null)return r;const s=e.dim(t);return r.replace(Da,`${s}px`)};class nT{constructor(e=p.b.XY.IDENTITY,t){S(this,"scale_");S(this,"path");this.scale_=e,t instanceof Path2D||typeof t=="string"?this.path=new Path2D(t):this.path=new Path2D}addPath(e,t){this.path.addPath(e,t)}arc(e,t,s,n,a,o){this.path.arc(this.scale_.x.pos(e),this.scale_.y.pos(t),this.scale_.x.dim(s),n,a,o)}arcTo(e,t,s,n,a){this.path.arcTo(this.scale_.x.pos(e),this.scale_.y.pos(t),this.scale_.x.pos(s),this.scale_.y.pos(n),this.scale_.x.dim(a))}bezierCurveTo(e,t,s,n,a,o){this.path.bezierCurveTo(this.scale_.x.pos(e),this.scale_.y.pos(t),this.scale_.x.pos(s),this.scale_.y.pos(n),this.scale_.x.pos(a),this.scale_.y.pos(o))}closePath(){this.path.closePath()}ellipse(e,t,s,n,a,o,u,l){this.path.ellipse(this.scale_.x.pos(e),this.scale_.y.pos(t),this.scale_.x.dim(s),this.scale_.y.dim(n),a,o,u,l)}lineTo(e,t){this.path.lineTo(this.scale_.x.pos(e),this.scale_.y.pos(t))}moveTo(e,t){this.path.moveTo(this.scale_.x.pos(e),this.scale_.y.pos(t))}quadraticCurveTo(e,t,s,n){this.path.quadraticCurveTo(this.scale_.x.pos(e),this.scale_.y.pos(t),this.scale_.x.pos(s),this.scale_.y.pos(n))}rect(e,t,s,n){this.path.rect(this.scale_.x.pos(e),this.scale_.y.pos(t),this.scale_.x.dim(s),this.scale_.y.dim(n))}roundRect(e,t,s,n,a){const o=this.scaleRadii(a);this.path.roundRect(this.scale_.x.pos(e),this.scale_.y.pos(t),this.scale_.x.dim(s),this.scale_.y.dim(n),o)}scaleRadii(e){return e==null?e:typeof e=="number"?this.scale_.x.dim(e):Array.isArray(e)?e.map(t=>this.scaleRadius(t)):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 iT=`precision mediump float;
|
|
68
|
-
|
|
69
|
-
void main(void) {
|
|
70
|
-
gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
|
|
71
|
-
}
|
|
72
|
-
`,aT=`attribute vec4 a_position;
|
|
73
|
-
|
|
74
|
-
void main(void) {
|
|
75
|
-
gl_Position = a_position;
|
|
76
|
-
}
|
|
77
|
-
`,Ua=r=>new Error(`failed to compile webgl program: ${r}`),oT=new Error("null shader encountered");let Nu=class{constructor(e,t,s){S(this,"renderCtx");S(this,"prog");S(this,"vertShader");S(this,"fragShader");S(this,"uniformLocCache",new Map);this.renderCtx=e;const n=e.gl.createProgram();if(n==null)throw Ua("failed to create program");this.prog=n,this.vertShader=t,this.fragShader=s,this.compile()}setAsActive(){return this.renderCtx.gl.useProgram(this.prog),()=>this.renderCtx.gl.useProgram(null)}uniformXY(e,t){this.renderCtx.gl.uniform2fv(this.getUniformLoc(e),p.G.couple(t))}uniformColor(e,t){this.renderCtx.gl.uniform4fv(this.getUniformLoc(e),t.rgba1)}getUniformLoc(e){const t=this.uniformLocCache.get(e);if(t!=null)return t;const s=this.renderCtx.gl.getUniformLocation(this.prog,e);if(s==null)throw new Error(`unexpected missing uniform ${e}`);return this.uniformLocCache.set(e,s),s}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,t){const s=this.renderCtx.gl,n=s.createShader(t);if(n==null)throw oT;if(s.shaderSource(n,e),s.compileShader(n),!s.getShaderParameter(n,s.COMPILE_STATUS)){const o=s.getShaderInfoLog(n);throw s.deleteShader(n),Ua(o??"unknown")}s.attachShader(this.prog,n)}};const lT=new Float32Array([0,0,0,0,0,0]);class uT extends Nu{constructor(t){super(t,aT,iT);S(this,"positionBuffer");const s=t.gl.createBuffer();if(s==null)throw new be("webgl: failed to create buffer");this.positionBuffer=s,t.gl.bindBuffer(t.gl.ARRAY_BUFFER,this.positionBuffer),t.gl.bufferData(t.gl.ARRAY_BUFFER,lT,t.gl.STATIC_DRAW)}exec(){const{gl:t}=this.renderCtx,s=t.getAttribLocation(this.prog,"a_position");t.bindBuffer(t.ARRAY_BUFFER,this.positionBuffer);const n=t.createVertexArray();t.bindVertexArray(n),t.enableVertexAttribArray(s),t.vertexAttribPointer(s,2,t.FLOAT,!1,0,0),this.setAsActive(),t.drawArrays(t.TRIANGLES,0,3)}}const La={high:1,low:0},_a=is.hz(45);class Eu{constructor(e){S(this,"mutex",new Ti);S(this,"requests",new Map);S(this,"cleanup",new Map);S(this,"afterRender");this.start(),this.afterRender=e}async set(e){let t;e.priority==="high"&&(t=await this.mutex.acquire());const s=this.requests.get(e.key);if(s==null)this.requests.set(e.key,e);else{const n=La[e.priority]>=La[s.priority],a=e.canvases.length>=s.canvases.length;n&&a&&this.requests.set(e.key,e)}t==null||t()}async render(){await this.mutex.runExclusive(async()=>{var a;const e=performance.now(),{requests:t}=this;if(t.size===0)return;await this.runCleanupsSync(),await this.renderSync();const s=performance.now(),n=Z.milliseconds(s-e);n.greaterThan(_a.period)&&console.warn(`Render loop for ${this.requests.size} took longer than ${_a.period.toString()} to execute: ${n.milliseconds}`),this.requests.clear(),(a=this.afterRender)==null||a.call(this)})}async runCleanupsSync(){const{cleanup:e,requests:t}=this;for(const[s,n]of e.entries()){const a=t.get(s);a!=null&&(await n(a),e.delete(s))}}async renderSync(){const{requests:e}=this;for(const t of e.values())try{const s=await t.render();s!=null&&this.cleanup.set(t.key,s)}catch(s){console.error(s)}}async start(){do{try{await this.render()}catch(e){console.error(e)}await this.sleep()}while(!0)}async sleep(){return await new Promise(requestAnimationFrame)}}const qa=r=>(r.textRendering="optimizeSpeed",r.imageSmoothingEnabled=!1,r),Ve=class Ve{constructor(e,t,s,n){S(this,"glCanvas");S(this,"upper2dCanvas");S(this,"lower2dCanvas");S(this,"gl");S(this,"lower2d");S(this,"upper2d");S(this,"region");S(this,"dpr");S(this,"loop");S(this,"clearProgram");S(this,"os");this.upper2dCanvas=s,this.lower2dCanvas=t,this.glCanvas=e,this.os=n;const a=this.lower2dCanvas.getContext("2d");if(a==null)throw new Error("Could not get 2D context");this.lower2d=qa(new ps(a));const o=this.upper2dCanvas.getContext("2d");if(o==null)throw new Error("Could not get 2D context");this.upper2d=qa(new ps(o));const u={preserveDrawingBuffer:!0,powerPreference:"high-performance",stencil:!1,depth:!1},l=this.glCanvas.getContext("webgl2",u);if(l==null)throw new Error("Could not get WebGL context");l.disable(l.DEPTH_TEST),l.disable(l.STENCIL_TEST),l.disable(l.CULL_FACE),l.disable(l.DITHER),this.gl=l,this.glCanvas.oncontextlost=console.log;const h=()=>{this.gl.flush(),this.gl.finish()};this.loop=new Eu(h),this.region=p.Tt.ZERO,this.dpr=1,this.os==="Windows"&&(this.clearProgram=new uT(this))}static create(e,t,s,n,a){const o=new Ve(t,s,n,a);return e.set(Ve.CONTEXT_KEY,o),o}static useOptional(e){return e.getOptional(Ve.CONTEXT_KEY)}static use(e){return e.get(Ve.CONTEXT_KEY)}update(e){e.set(Ve.CONTEXT_KEY,this)}resize(e,t){p.Tt.equals(this.region,e)&&this.dpr===t||(this.region=e,this.dpr=t,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.Tt.width(e)*t,p.Tt.height(e)*t))}resizeCanvas(e){e.width=p.Tt.width(this.region)*this.dpr,e.height=p.Tt.height(this.region)*this.dpr}get aspect(){return p.Tt.aspect(this.region)}scaleRegion(e){return new p.b.XY(p.b.Scale.scale(0,1).scale(p.Tt.width(e)).translate(p.Tt.left(e)).reBound(p.Tt.width(this.region)).scale(-1,1),p.b.Scale.scale(0,1).scale(p.Tt.height(e)).invert().translate(p.Tt.top(e)).reBound(p.Tt.height(this.region)).scale(-1,1).invert())}scissor(e,t=p.G.ZERO,s){const n=[];return s.includes("upper2d")&&n.push(this.upper2d.scissor(e,t)),s.includes("lower2d")&&n.push(this.lower2d.scissor(e,t)),s.includes("gl")&&n.push(this.scissorGL(e,t)),()=>n.forEach(a=>a())}scissorGL(e,t=p.G.ZERO){return this.gl.enable(this.gl.SCISSOR_TEST),e=ns(e,t),this.gl.scissor(p.Tt.left(e)*this.dpr,(p.Tt.height(this.region)-p.Tt.bottom(e))*this.dpr,p.Tt.width(e)*this.dpr,p.Tt.height(e)*this.dpr),()=>this.gl.disable(this.gl.SCISSOR_TEST)}erase(e,t=p.G.ZERO,...s){t=p.G.construct(t),s.length===0&&(s=["upper2d","lower2d","gl"]),s.includes("upper2d")&&this.eraseCanvas(this.upper2d,e,t),s.includes("lower2d")&&this.eraseCanvas(this.lower2d,e,t),s.includes("gl")&&this.eraseGL(e,t)}eraseGL(e,t=p.G.ZERO){var a;const{gl:s}=this,n=this.scissorGL(ns(e,t));s.clearColor(...p.ZERO.rgba1),s.clear(s.COLOR_BUFFER_BIT),this.os==="Windows"&&((a=this.clearProgram)==null||a.exec()),n()}eraseCanvas(e,t,s=p.G.ZERO){const n=ns(t,s);e.clearRect(...p.G.couple(p.Tt.topLeft(n)),...p._.couple(p.Tt.dims(n)))}};S(Ve,"CONTEXT_KEY",p.CSS.B("render-context"));let gs=Ve;const Iu=i.z.object({region:p.Tt.box,enabled:i.z.boolean().optional().default(!1)}),Ya=["gl","lower2d","upper2d"];class ys extends Ms{constructor(){super(...arguments);S(this,"schema",Iu)}async afterUpdate(t){this.deleted||(this.internal.renderCtx=gs.use(t),await this.renderOnLifecycleChange())}async afterDelete(){await this.renderOnLifecycleChange()}async renderOnLifecycleChange(){await this.internal.renderCtx.loop.set({key:`${this.type}-${this.key}`,render:this.render.bind(this),priority:"high",canvases:Ya})}async render(){this.deleted||!this.state.enabled||this.internal.renderCtx.erase(this.state.region,p.G.construct(0),...Ya)}}S(ys,"TYPE","eraser");const cT={[ys.TYPE]:ys},Vn="pluto-theming-context",xu=i.z.object({name:i.z.string(),url:i.z.string()}),hT=i.z.object({theme:vo,fontURLs:i.z.array(xu)}),Ht=class Ht extends mr{constructor(){super(...arguments);S(this,"schema",Ht.z)}async afterUpdate(t){t.getOptional(Vn)!=null&&this.state.theme.key===this.prevState.theme.key||(t.set(Vn,this.state.theme),await this.loadFonts())}async loadFonts(){await Promise.all(this.state.fontURLs.map(async({name:t,url:s})=>{const n=new FontFace(t,`url(${s})`);await n.load(),self.fonts.add(n)}))}};S(Ht,"TYPE","theming.Provider"),S(Ht,"z",hT);let ar=Ht;const dT=r=>r.get(Vn),fT={[ar.TYPE]:ar},Au=["success","error","warning","info","loading","disabled","secondary"],ku=i.z.enum(Au),Cu=i.z.object({key:i.z.string(),variant:ku,message:i.z.string(),description:i.z.string().optional(),time:G.z,data:i.z.record(i.z.unknown()).optional()}),Ru=i.z.object({statuses:Cu.array()}),Oi="status.aggregator";class ms extends mr{constructor(){super(...arguments);S(this,"schema",Ru)}async afterUpdate(t){t.set(Oi,this)}add(t){this.setState(s=>({...s,statuses:[...s.statuses,{time:G.now(),...t,key:eo.id()}]}))}}S(ms,"TYPE","status.Aggregator");const $u=r=>{const e=r.get(Oi);return e.add.bind(e)},pT=r=>{const e=r.getOptional(Oi);return e!=null?e.add.bind(e):()=>{}},gT=r=>{const e=$u(r);return(t,s)=>{if(!(t instanceof Error))throw t;e({variant:"error",message:s??t.message,description:s!=null?t.message:void 0})}},yT={[ms.TYPE]:ms};exports.$=is;exports.A=Rc;exports.Aggregator=ms;exports.B=vi;exports.ComponentSizeLevels=bo;exports.Composite=mr;exports.Context=gs;exports.Dt=wc;exports.E=ot;exports.Eraser=ys;exports.F=Hu;exports.Fg=ay;exports.GLProgram=Nu;exports.K=oe;exports.K$1=Jc;exports.L=Q;exports.LEVELS=wo;exports.Leaf=Ms;exports.LevelComponentSizes=dh;exports.Loop=Eu;exports.Lt=cc;exports.Mutex=Ti;exports.Provider=ar;exports.REGISTRY=fT;exports.REGISTRY$1=cT;exports.REGISTRY$2=yT;exports.S=lo;exports.S$1=x;exports.SYNNAX_DARK=Oo;exports.SYNNAX_LIGHT=To;exports.SYNNAX_THEMES=Oh;exports.U=Wc;exports.VARIANTS=Au;exports.X=eh;exports.Y=th;exports.Z=so;exports._=io;exports.aether=sT;exports.aggregatorStateZ=Ru;exports.b=fe;exports.bg=hu;exports.c=Yu;exports.dimensions=ph;exports.downLevel=oh;exports.ee=rh;exports.eraserStateZ=Iu;exports.executeInitialSetter=lr;exports.executeSetter=Jn;exports.fontSpecZ=xu;exports.fontString=Eh;exports.g=M;exports.g$1=Ou;exports.isSetter=Zn;exports.k=$;exports.kp=uv;exports.l=Lc;exports.levelZ=ih;exports.m=G;exports.mp=qw;exports.o=vc;exports.o$1=$c;exports.prettyParse=Dn;exports.r=Tc;exports.render=zu;exports.rp=am;exports.se=ze;exports.specZ=qe;exports.specZ$1=Cu;exports.state=nh;exports.themeZ=vo;exports.upLevel=uh;exports.use=dT;exports.useAggregator=$u;exports.useExceptionHandler=gT;exports.useOptionalAggregator=pT;exports.usePassthrough=yo;exports.usePurePassthrough=mo;exports.variantZ=ku;exports.w=Z;exports.w$1=Fu;exports.weightZ=hh;exports.wg=cu;exports.x=Xt;exports.xe=be;exports.xt=eo;exports.y=nc;
|