@synnaxlabs/pluto 0.47.1 → 0.49.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/{Animated-CUFx-eAB.js → Animated-38tdmPR0.js} +112 -116
- package/dist/{Animated-CEx4LoLs.js → Animated-Bp6IK3ct.js} +4 -4
- package/dist/Animated-D-pQ3CYh.cjs +1 -0
- package/dist/{Animated-NfnNvlbz.cjs → Animated-Dsn1pmhz.cjs} +1 -1
- package/dist/Box-4l6DWG-3.cjs +1 -0
- package/dist/{Box-D5Qv__kr.js → Box-BVyAHr2f.js} +17 -17
- package/dist/Button-CoOYEk1J.js +308 -0
- package/dist/Button-D5aoG3sV.cjs +1 -0
- package/dist/Dialog-JwJQD3xZ.cjs +1 -0
- package/dist/{Dialog-Bi1Sf3oc.js → Dialog-puVY-0Mt.js} +14 -14
- package/dist/Editable-DEbVpi5i.js +201 -0
- package/dist/Editable-DI0-D1K5.cjs +1 -0
- package/dist/Haul-9RVCn3cI.cjs +1 -0
- package/dist/{Haul-BuI0PZpo.js → Haul-Db9j45Fu.js} +53 -49
- package/dist/Items-BCG7kyaR.cjs +4 -0
- package/dist/{Items-Cmc6otoS.js → Items-BVKW0udb.js} +277 -215
- package/dist/Menu-BYca9tGe.cjs +1 -0
- package/dist/Menu-CQsrN_mP.js +134 -0
- package/dist/Provider-DBg-Li_7.cjs +5 -0
- package/dist/{Provider-D0P_lzCo.js → Provider-DQM7IBoi.js} +183 -178
- package/dist/Tags-B8l5Dvw-.js +919 -0
- package/dist/Tags-CQFa3kY-.cjs +1 -0
- package/dist/{Text-BnUGzpJq.js → Text-90J6p5Uj.js} +993 -926
- package/dist/Text-DeWvfrdF.cjs +1 -0
- package/dist/{Video-VlT7jSYk.cjs → Video-Bmg4gwom.cjs} +1 -1
- package/dist/{Video-CITi2j07.js → Video-CLpcYcKf.js} +2 -2
- package/dist/button.cjs +1 -1
- package/dist/button.js +1 -1
- package/dist/color.cjs +1 -1
- package/dist/color.js +1 -1
- package/dist/css-BVgFAmaj.cjs +8 -0
- package/dist/{css-D6ZBcSwh.js → css-bahPRiQI.js} +2128 -1593
- package/dist/css.cjs +1 -1
- package/dist/css.js +2 -2
- package/dist/dialog.cjs +1 -1
- package/dist/dialog.js +1 -1
- package/dist/dimensions-SDA3fM2T.cjs +1 -0
- package/dist/{dimensions-BFCMI7yN.js → dimensions-qcyzaTKI.js} +5 -5
- package/dist/eraser-Cbfc1frM.cjs +11 -0
- package/dist/{eraser-DvzR9kLf.js → eraser-Dz6nZuPp.js} +25 -25
- package/dist/ether.cjs +1 -1
- package/dist/ether.js +64 -62
- package/dist/{_commonjsHelpers-BH3jXuIh.cjs → event-BxvV3arE.cjs} +1 -1
- package/dist/{_commonjsHelpers-ByX85dGu.js → event-nNH_pXSr.js} +17 -14
- package/dist/{external-OzDazbiJ.js → external-04ve_X21.js} +105 -112
- package/dist/external-B3b7kdID.cjs +1 -0
- package/dist/{external-BcZE443U.cjs → external-Bixqkw5N.cjs} +1 -1
- package/dist/{external-CAcL3DJP.js → external-CB3VxPJp.js} +18 -19
- package/dist/external-CMs_BCc5.cjs +28 -0
- package/dist/{external-CtiE4JLk.js → external-CnWQzZlQ.js} +118 -116
- package/dist/{external-DGNBXSAj.js → external-CrXS1qj_.js} +16067 -15783
- package/dist/{external-OLyg-4Ab.cjs → external-CwYoEhB2.cjs} +1 -1
- package/dist/{external-Bo9Dyf8v.js → external-Cxojc4yT.js} +19 -19
- package/dist/external-D2deiHyL.js +69 -0
- package/dist/{external-CTrkvlmd.cjs → external-D2tzyCDs.cjs} +1 -1
- package/dist/external-DDHknds-.cjs +1 -0
- package/dist/{external-6RyUkYAB.js → external-DJWZ43k0.js} +2 -2
- package/dist/{external-BhOvtmPt.js → external-DP9FiRHq.js} +3 -3
- package/dist/{external-CSntN1is.cjs → external-DUVDOJfj.cjs} +1 -1
- package/dist/external-DcMOF1Je.cjs +1 -0
- package/dist/{external-Daiy-vZ3.js → external-Hhx8JoAS.js} +793 -815
- package/dist/external-JpvbclD8.cjs +79 -0
- package/dist/external-PA6ulZR9.cjs +1 -0
- package/dist/external-RkrrZXG5.cjs +1 -0
- package/dist/external-TI-6Umwm.js +92 -0
- package/dist/external-kwuGKgyL.cjs +1 -0
- package/dist/external-m-0q-0os.js +46 -0
- package/dist/{external-BTlfU938.js → external-xJ67ivgR.js} +3 -3
- package/dist/flex.cjs +1 -1
- package/dist/flex.js +1 -1
- package/dist/{fontString-yPlq8smc.cjs → fontString-62eEvw4b.cjs} +1 -1
- package/dist/{fontString-CGd4NYXa.js → fontString-qfWSw62X.js} +3 -3
- package/dist/header.cjs +1 -1
- package/dist/header.js +1 -1
- package/dist/hooks-CRSphXSb.cjs +1 -0
- package/dist/hooks-Dh0v1QWQ.js +73 -0
- package/dist/index.cjs +8 -40
- package/dist/index.js +23997 -23284
- package/dist/input.cjs +1 -1
- package/dist/input.js +1 -1
- package/dist/{jsx-runtime-OVHDjVDe.js → jsx-runtime-BbD0H88J.js} +108 -128
- package/dist/jsx-runtime-nZSsnGb7.cjs +6 -0
- 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-C8In649C.js → provider-ClhgBr_F.js} +6582 -6310
- package/dist/provider-DHDqgF1B.cjs +76 -0
- package/dist/src/access/aether/external.d.ts +3 -0
- package/dist/src/access/aether/external.d.ts.map +1 -0
- package/dist/src/access/aether/index.d.ts +2 -0
- package/dist/src/access/aether/index.d.ts.map +1 -0
- package/dist/src/access/external.d.ts +4 -0
- package/dist/src/access/external.d.ts.map +1 -0
- package/dist/src/access/index.d.ts +2 -0
- package/dist/src/access/index.d.ts.map +1 -0
- package/dist/src/access/policy/CreateIcon.d.ts +3 -0
- package/dist/src/access/policy/CreateIcon.d.ts.map +1 -0
- package/dist/src/access/policy/Select.d.ts +12 -0
- package/dist/src/access/policy/Select.d.ts.map +1 -0
- package/dist/src/access/policy/aether/index.d.ts +2 -0
- package/dist/src/access/policy/aether/index.d.ts.map +1 -0
- package/dist/src/access/policy/aether/queries.d.ts +18 -0
- package/dist/src/access/policy/aether/queries.d.ts.map +1 -0
- package/dist/src/access/policy/external.d.ts +5 -0
- package/dist/src/access/policy/external.d.ts.map +1 -0
- package/dist/src/access/policy/index.d.ts +2 -0
- package/dist/src/access/policy/index.d.ts.map +1 -0
- package/dist/src/access/policy/queries.d.ts +102 -0
- package/dist/src/access/policy/queries.d.ts.map +1 -0
- package/dist/src/access/policy/queries.spec.d.ts.map +1 -0
- package/dist/src/access/policy/types.d.ts +2 -0
- package/dist/src/access/policy/types.d.ts.map +1 -0
- package/dist/src/access/queries.d.ts +36 -0
- package/dist/src/access/queries.d.ts.map +1 -0
- package/dist/src/access/queries.spec.d.ts.map +1 -0
- package/dist/src/access/role/CreateIcon.d.ts +3 -0
- package/dist/src/access/role/CreateIcon.d.ts.map +1 -0
- package/dist/src/access/role/Select.d.ts +9 -0
- package/dist/src/access/role/Select.d.ts.map +1 -0
- package/dist/src/access/role/aether/index.d.ts +2 -0
- package/dist/src/access/role/aether/index.d.ts.map +1 -0
- package/dist/src/access/role/aether/queries.d.ts +14 -0
- package/dist/src/access/role/aether/queries.d.ts.map +1 -0
- package/dist/src/access/role/external.d.ts +4 -0
- package/dist/src/access/role/external.d.ts.map +1 -0
- package/dist/src/access/role/index.d.ts +2 -0
- package/dist/src/access/role/index.d.ts.map +1 -0
- package/dist/src/access/role/queries.d.ts +57 -0
- package/dist/src/access/role/queries.d.ts.map +1 -0
- package/dist/src/access/role/queries.spec.d.ts.map +1 -0
- package/dist/src/aether/main.d.ts +0 -1
- package/dist/src/aether/main.d.ts.map +1 -1
- package/dist/src/alamos/Provider.d.ts +0 -5
- package/dist/src/alamos/Provider.d.ts.map +1 -1
- package/dist/src/alamos/aether/alamos.d.ts +4 -4
- package/dist/src/arc/queries.d.ts +6 -6
- package/dist/src/arc/queries.d.ts.map +1 -1
- package/dist/src/button/Button.d.ts +2 -1
- package/dist/src/button/Button.d.ts.map +1 -1
- package/dist/src/channel/LinePlot.d.ts +4 -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/channel/queries.d.ts +25 -25
- package/dist/src/channel/queries.d.ts.map +1 -1
- package/dist/src/cluster/index.d.ts +2 -0
- package/dist/src/cluster/index.d.ts.map +1 -0
- package/dist/src/cluster/queries.d.ts +6 -0
- package/dist/src/cluster/queries.d.ts.map +1 -0
- package/dist/src/cluster/queries.spec.d.ts +2 -0
- package/dist/src/cluster/queries.spec.d.ts.map +1 -0
- package/dist/src/color/GradientPicker.d.ts.map +1 -1
- package/dist/src/color/Provider.d.ts +2 -1
- package/dist/src/color/Provider.d.ts.map +1 -1
- package/dist/src/context/context.d.ts +28 -0
- package/dist/src/context/context.d.ts.map +1 -0
- package/dist/src/context/context.spec.d.ts +2 -0
- package/dist/src/context/context.spec.d.ts.map +1 -0
- package/dist/src/context/index.d.ts +2 -0
- package/dist/src/context/index.d.ts.map +1 -0
- package/dist/src/{hardware/device → device}/Select.d.ts +3 -3
- package/dist/src/device/Select.d.ts.map +1 -0
- package/dist/src/{hardware/device → device}/StatusIndicator.d.ts +1 -1
- package/dist/src/device/StatusIndicator.d.ts.map +1 -0
- package/dist/src/device/external.d.ts.map +1 -0
- package/dist/src/device/index.d.ts.map +1 -0
- package/dist/src/{hardware/device → device}/queries.d.ts +10 -14
- package/dist/src/device/queries.d.ts.map +1 -0
- package/dist/src/device/queries.spec.d.ts +2 -0
- package/dist/src/device/queries.spec.d.ts.map +1 -0
- package/dist/src/dialog/Frame.d.ts +8 -7
- package/dist/src/dialog/Frame.d.ts.map +1 -1
- package/dist/src/flex/Box.d.ts +4 -4
- package/dist/src/flux/Provider.d.ts.map +1 -1
- package/dist/src/flux/core/client.d.ts.map +1 -1
- package/dist/src/flux/core/store.d.ts +7 -7
- package/dist/src/flux/core/store.d.ts.map +1 -1
- package/dist/src/flux/core/streamer.d.ts +2 -2
- package/dist/src/flux/core/streamer.d.ts.map +1 -1
- package/dist/src/flux/form.d.ts +2 -2
- package/dist/src/flux/form.d.ts.map +1 -1
- package/dist/src/flux/list.d.ts +3 -3
- package/dist/src/flux/list.d.ts.map +1 -1
- package/dist/src/flux/retrieve.d.ts +10 -9
- package/dist/src/flux/retrieve.d.ts.map +1 -1
- package/dist/src/flux/update.d.ts +27 -26
- package/dist/src/flux/update.d.ts.map +1 -1
- package/dist/src/form/Context.d.ts +4 -3
- package/dist/src/form/Context.d.ts.map +1 -1
- package/dist/src/form/Field.d.ts +2 -2
- package/dist/src/form/Field.d.ts.map +1 -1
- package/dist/src/form/use.d.ts.map +1 -1
- package/dist/src/form/useField.d.ts.map +1 -1
- package/dist/src/group/queries.d.ts +3 -3
- package/dist/src/group/queries.d.ts.map +1 -1
- package/dist/src/haul/Haul.d.ts +7 -7
- package/dist/src/haul/Haul.d.ts.map +1 -1
- package/dist/src/header/Header.d.ts +2 -1
- package/dist/src/header/Header.d.ts.map +1 -1
- package/dist/src/hooks/index.d.ts +0 -1
- package/dist/src/hooks/index.d.ts.map +1 -1
- package/dist/src/hooks/useAsyncEffect.d.ts +2 -2
- package/dist/src/hooks/useAsyncEffect.d.ts.map +1 -1
- package/dist/src/hooks/useDestructors.d.ts +2 -2
- package/dist/src/hooks/useDestructors.d.ts.map +1 -1
- package/dist/src/icon/registry.d.ts +16 -0
- package/dist/src/icon/registry.d.ts.map +1 -1
- package/dist/src/index.d.ts +6 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/input/DateTime.d.ts.map +1 -1
- package/dist/src/input/DateTime.spec.d.ts +2 -0
- package/dist/src/input/DateTime.spec.d.ts.map +1 -0
- package/dist/src/input/Text.d.ts +1 -1
- package/dist/src/input/Text.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/label/queries.d.ts +6 -6
- package/dist/src/label/queries.d.ts.map +1 -1
- package/dist/src/lineplot/Legend.d.ts +2 -2
- package/dist/src/lineplot/Legend.d.ts.map +1 -1
- package/dist/src/lineplot/LinePlot.d.ts +5 -5
- package/dist/src/lineplot/LinePlot.d.ts.map +1 -1
- package/dist/src/lineplot/aether/LinePlot.d.ts +8 -8
- package/dist/src/lineplot/aether/XAxis.d.ts +26 -26
- package/dist/src/lineplot/aether/YAxis.d.ts +28 -28
- package/dist/src/lineplot/aether/axis.d.ts +13 -13
- package/dist/src/lineplot/queries.d.ts +3 -3
- package/dist/src/lineplot/queries.d.ts.map +1 -1
- package/dist/src/lineplot/range/aether/annotation.d.ts +4 -4
- package/dist/src/lineplot/range/aether/provider.d.ts +2 -2
- package/dist/src/lineplot/range/aether/provider.d.ts.map +1 -1
- package/dist/src/lineplot/tooltip/aether/tooltip.d.ts +26 -26
- package/dist/src/list/Frame.d.ts +2 -1
- package/dist/src/list/Frame.d.ts.map +1 -1
- package/dist/src/list/Items.d.ts.map +1 -1
- package/dist/src/log/Log.d.ts +2 -2
- package/dist/src/log/Log.d.ts.map +1 -1
- package/dist/src/log/aether/Log.d.ts +32 -32
- package/dist/src/log/aether/Log.d.ts.map +1 -1
- package/dist/src/log/queries.d.ts +3 -3
- package/dist/src/log/queries.d.ts.map +1 -1
- package/dist/src/menu/Divider.d.ts +3 -0
- package/dist/src/menu/Divider.d.ts.map +1 -0
- package/dist/src/menu/Item.d.ts.map +1 -1
- package/dist/src/menu/Menu.d.ts +2 -2
- package/dist/src/menu/Menu.d.ts.map +1 -1
- package/dist/src/menu/external.d.ts +1 -0
- package/dist/src/menu/external.d.ts.map +1 -1
- package/dist/src/mosaic/Mosaic.d.ts.map +1 -1
- package/dist/src/ontology/queries.d.ts +7 -7
- package/dist/src/ontology/queries.d.ts.map +1 -1
- package/dist/src/pluto/Pluto.d.ts +9 -5
- package/dist/src/pluto/Pluto.d.ts.map +1 -1
- package/dist/src/pluto/aether/pluto.d.ts.map +1 -1
- package/dist/src/{hardware/rack → rack}/Select.d.ts +4 -4
- package/dist/src/rack/Select.d.ts.map +1 -0
- package/dist/src/{hardware/rack → rack}/StatusIndicator.d.ts +1 -1
- package/dist/src/rack/StatusIndicator.d.ts.map +1 -0
- package/dist/src/rack/external.d.ts.map +1 -0
- package/dist/src/rack/index.d.ts.map +1 -0
- package/dist/src/{hardware/rack → rack}/queries.d.ts +7 -9
- package/dist/src/rack/queries.d.ts.map +1 -0
- package/dist/src/rack/queries.spec.d.ts +2 -0
- package/dist/src/rack/queries.spec.d.ts.map +1 -0
- package/dist/src/ranger/queries.d.ts +7 -7
- package/dist/src/ranger/queries.d.ts.map +1 -1
- package/dist/src/schematic/queries.d.ts +5 -5
- package/dist/src/schematic/queries.d.ts.map +1 -1
- package/dist/src/schematic/symbol/Primitives.d.ts +2 -2
- package/dist/src/schematic/symbol/Primitives.d.ts.map +1 -1
- package/dist/src/schematic/symbol/queries.d.ts +8 -8
- package/dist/src/schematic/symbol/queries.d.ts.map +1 -1
- package/dist/src/schematic/symbol/registry.d.ts +2 -2
- package/dist/src/select/Dialog.d.ts +2 -3
- package/dist/src/select/Dialog.d.ts.map +1 -1
- package/dist/src/select/Frame.d.ts.map +1 -1
- package/dist/src/select/Multiple.d.ts.map +1 -1
- package/dist/src/select/MultipleTrigger.d.ts.map +1 -1
- package/dist/src/select/Static.d.ts +2 -2
- package/dist/src/select/Static.d.ts.map +1 -1
- package/dist/src/select/use.d.ts +2 -2
- package/dist/src/select/use.d.ts.map +1 -1
- package/dist/src/showcase/InputShowcase.d.ts +7 -7
- package/dist/src/showcase/InputShowcase.d.ts.map +1 -1
- package/dist/src/showcase/TagShowcase.d.ts.map +1 -1
- package/dist/src/state/state.d.ts +2 -1
- package/dist/src/state/state.d.ts.map +1 -1
- package/dist/src/state/state.spec.d.ts +2 -0
- package/dist/src/state/state.spec.d.ts.map +1 -0
- package/dist/src/status/Select.d.ts +1 -1
- package/dist/src/status/Select.d.ts.map +1 -1
- package/dist/src/status/aether/errorHandler.d.ts.map +1 -1
- package/dist/src/status/core/Aggregator.d.ts +2 -2
- package/dist/src/status/core/Aggregator.d.ts.map +1 -1
- package/dist/src/status/core/Notification.d.ts.map +1 -1
- package/dist/src/status/queries.d.ts +24 -11
- package/dist/src/status/queries.d.ts.map +1 -1
- package/dist/src/store/store.d.ts +2 -2
- package/dist/src/store/store.d.ts.map +1 -1
- package/dist/src/synnax/Provider.d.ts +2 -2
- package/dist/src/synnax/Provider.d.ts.map +1 -1
- package/dist/src/synnax/aether/provider.d.ts +3 -3
- package/dist/src/synnax/aether/provider.d.ts.map +1 -1
- package/dist/src/table/Table.d.ts.map +1 -1
- package/dist/src/table/aether/Table.d.ts +12 -12
- package/dist/src/table/cells/Cells.d.ts +7 -7
- package/dist/src/table/queries.d.ts +3 -3
- package/dist/src/table/queries.d.ts.map +1 -1
- package/dist/src/tabs/useContext.d.ts +4 -4
- package/dist/src/tabs/useContext.d.ts.map +1 -1
- package/dist/src/tag/Tag.d.ts +2 -2
- package/dist/src/tag/Tag.d.ts.map +1 -1
- package/dist/src/task/index.d.ts.map +1 -0
- package/dist/src/{hardware/task → task}/queries.d.ts +14 -33
- package/dist/src/task/queries.d.ts.map +1 -0
- package/dist/src/task/queries.spec.d.ts +2 -0
- package/dist/src/task/queries.spec.d.ts.map +1 -0
- package/dist/src/telem/aether/context.d.ts +2 -2
- package/dist/src/telem/aether/context.d.ts.map +1 -1
- package/dist/src/telem/aether/pipeline.d.ts +2 -2
- package/dist/src/telem/aether/pipeline.d.ts.map +1 -1
- package/dist/src/telem/aether/remote.d.ts +4 -4
- package/dist/src/telem/aether/remote.d.ts.map +1 -1
- package/dist/src/telem/aether/static.d.ts +11 -11
- package/dist/src/telem/aether/telem.d.ts +2 -2
- package/dist/src/telem/aether/telem.d.ts.map +1 -1
- package/dist/src/telem/aether/transformers.d.ts +30 -30
- package/dist/src/telem/client/client.d.ts +4 -4
- package/dist/src/telem/client/client.d.ts.map +1 -1
- package/dist/src/telem/client/streamer.d.ts +2 -2
- package/dist/src/telem/client/streamer.d.ts.map +1 -1
- package/dist/src/telem/control/Controller.d.ts +2 -1
- package/dist/src/telem/control/Controller.d.ts.map +1 -1
- package/dist/src/telem/control/aether/chip.d.ts +10 -10
- package/dist/src/telem/control/aether/chip.d.ts.map +1 -1
- package/dist/src/telem/control/aether/controller.d.ts +3 -3
- package/dist/src/telem/control/aether/controller.d.ts.map +1 -1
- package/dist/src/telem/control/aether/indicator.d.ts +13 -13
- package/dist/src/telem/control/aether/legend.d.ts +4 -4
- package/dist/src/telem/control/aether/legend.d.ts.map +1 -1
- package/dist/src/telem/control/aether/state.d.ts +3 -3
- package/dist/src/telem/control/aether/state.d.ts.map +1 -1
- package/dist/src/testutil/Synnax.d.ts +0 -5
- package/dist/src/testutil/Synnax.d.ts.map +1 -1
- package/dist/src/text/Text.d.ts +2 -1
- package/dist/src/text/Text.d.ts.map +1 -1
- package/dist/src/text/core/types.d.ts +2 -2
- package/dist/src/theming/Provider.d.ts +2 -1
- package/dist/src/theming/Provider.d.ts.map +1 -1
- package/dist/src/theming/aether/provider.d.ts +141 -141
- package/dist/src/theming/core/theme.d.ts +135 -135
- package/dist/src/theming/core/theme.d.ts.map +1 -1
- package/dist/src/tooltip/Config.d.ts +4 -3
- package/dist/src/tooltip/Config.d.ts.map +1 -1
- package/dist/src/tree/Context.d.ts +2 -12
- package/dist/src/tree/Context.d.ts.map +1 -1
- package/dist/src/tree/Tree.d.ts.map +1 -1
- package/dist/src/triggers/Provider.d.ts +4 -3
- package/dist/src/triggers/Provider.d.ts.map +1 -1
- package/dist/src/triggers/triggers.d.ts +21 -21
- package/dist/src/user/Avatar.d.ts +7 -0
- package/dist/src/user/Avatar.d.ts.map +1 -0
- package/dist/src/user/CreateIcon.d.ts +3 -0
- package/dist/src/user/CreateIcon.d.ts.map +1 -0
- package/dist/src/user/external.d.ts +4 -0
- package/dist/src/user/external.d.ts.map +1 -0
- package/dist/src/user/index.d.ts +1 -1
- package/dist/src/user/index.d.ts.map +1 -1
- package/dist/src/user/queries.d.ts +7 -4
- package/dist/src/user/queries.d.ts.map +1 -1
- package/dist/src/viewport/use.d.ts +1 -1
- package/dist/src/vis/axis/axis.d.ts +5 -5
- package/dist/src/vis/axis/ticks.d.ts +2 -2
- package/dist/src/vis/button/aether/button.d.ts +8 -8
- package/dist/src/vis/canvas/aether/canvas.d.ts +4 -4
- package/dist/src/vis/diagram/Diagram.d.ts +2 -6
- package/dist/src/vis/diagram/Diagram.d.ts.map +1 -1
- package/dist/src/vis/diagram/aether/Diagram.d.ts +9 -9
- package/dist/src/vis/diagram/align.d.ts +7 -2
- package/dist/src/vis/diagram/align.d.ts.map +1 -1
- package/dist/src/vis/draw2d/canvas.d.ts +2 -2
- package/dist/src/vis/draw2d/canvas.d.ts.map +1 -1
- package/dist/src/vis/draw2d/index.d.ts +2 -1
- package/dist/src/vis/draw2d/index.d.ts.map +1 -1
- package/dist/src/vis/eraser/aether/eraser.d.ts +2 -2
- package/dist/src/vis/gauge/aether/gauge.d.ts +60 -60
- package/dist/src/vis/gauge/use.d.ts +18 -18
- package/dist/src/vis/legend/Container.d.ts +3 -29
- package/dist/src/vis/legend/Container.d.ts.map +1 -1
- package/dist/src/vis/legend/Entries.d.ts +2 -2
- package/dist/src/vis/legend/Entries.d.ts.map +1 -1
- package/dist/src/vis/legend/Simple.d.ts +2 -2
- package/dist/src/vis/legend/Simple.d.ts.map +1 -1
- package/dist/src/vis/light/aether/light.d.ts +6 -6
- package/dist/src/vis/light/aether/light.d.ts.map +1 -1
- package/dist/src/vis/line/Line.d.ts +2 -2
- package/dist/src/vis/line/Line.d.ts.map +1 -1
- package/dist/src/vis/line/aether/line.d.ts +5 -5
- package/dist/src/vis/line/aether/line.d.ts.map +1 -1
- package/dist/src/vis/measure/Measure.d.ts +4 -1
- package/dist/src/vis/measure/Measure.d.ts.map +1 -1
- package/dist/src/vis/measure/aether/measure.d.ts +51 -25
- package/dist/src/vis/measure/aether/measure.d.ts.map +1 -1
- package/dist/src/vis/render/GLProgram.d.ts +2 -2
- package/dist/src/vis/render/GLProgram.d.ts.map +1 -1
- package/dist/src/vis/render/context.d.ts +2 -2
- package/dist/src/vis/render/context.d.ts.map +1 -1
- package/dist/src/vis/render/performance.d.ts +2 -2
- package/dist/src/vis/render/performance.d.ts.map +1 -1
- package/dist/src/vis/rule/aether/aether.d.ts +6 -6
- package/dist/src/vis/setpoint/aether/setpoint.d.ts +10 -10
- package/dist/src/vis/setpoint/aether/setpoint.d.ts.map +1 -1
- package/dist/src/vis/toggle/aether/toggle.d.ts +10 -10
- package/dist/src/vis/toggle/aether/toggle.d.ts.map +1 -1
- package/dist/src/vis/value/aether/value.d.ts +75 -75
- package/dist/src/vis/value/use.d.ts +23 -23
- package/dist/src/worker/Context.d.ts +2 -0
- package/dist/src/worker/Context.d.ts.map +1 -1
- package/dist/src/workspace/queries.d.ts +10 -8
- package/dist/src/workspace/queries.d.ts.map +1 -1
- package/dist/tabs.cjs +1 -1
- package/dist/tabs.js +1 -1
- package/dist/text.cjs +1 -1
- package/dist/text.js +2 -2
- package/dist/theming.cjs +1 -1
- package/dist/theming.js +2 -2
- package/dist/tree.cjs +1 -1
- package/dist/tree.js +1 -1
- package/dist/triggers.cjs +1 -1
- package/dist/triggers.js +1 -1
- package/dist/types-8-Mr79SF.cjs +1 -0
- package/dist/types-DGaZ_JZb.js +82 -0
- package/dist/{units-BqIfn6VX.js → units-CgMHbHoA.js} +1 -1
- package/dist/units-InoNiVrK.cjs +1 -0
- package/dist/{value-ChGMEPP3.js → value-CzFrd9p6.js} +3006 -2776
- package/dist/value-QHhF9WPA.cjs +53 -0
- package/dist/video.cjs +1 -1
- package/dist/video.js +1 -1
- package/package.json +24 -22
- package/dist/Animated-Bq6z2XkH.cjs +0 -1
- package/dist/Box-BvqALodh.cjs +0 -1
- package/dist/Button-BMeq9Z2I.cjs +0 -1
- package/dist/Button-CMRdj9Ti.js +0 -305
- package/dist/Dialog-BnPvG5WQ.cjs +0 -1
- package/dist/Editable-BXFY3-UW.cjs +0 -1
- package/dist/Editable-CxgdRDPb.js +0 -193
- package/dist/Haul-2Xa_nMgc.cjs +0 -1
- package/dist/Items-CHAbP2ZL.cjs +0 -4
- package/dist/Menu-BImhHf24.cjs +0 -1
- package/dist/Menu-CQ_GMgB9.js +0 -156
- package/dist/Provider-BV7nN39a.cjs +0 -5
- package/dist/Tags-6IUFBvU-.js +0 -604
- package/dist/Tags-DtnStTuF.cjs +0 -1
- package/dist/Text-DY08sSZe.cjs +0 -1
- package/dist/css-HnNQMUzV.cjs +0 -8
- package/dist/debounce-CW9Q-DsR.js +0 -17
- package/dist/debounce-heEWeOqL.cjs +0 -1
- package/dist/deep-DRVLw7iw.js +0 -349
- package/dist/deep-DtdcJG4q.cjs +0 -1
- package/dist/dimensions-CGLhBwVq.cjs +0 -1
- package/dist/eraser-Dm5Du4PL.cjs +0 -11
- package/dist/external-6vmyay3h.js +0 -46
- package/dist/external-BSjAne2q.js +0 -88
- package/dist/external-BrQU-ZN8.cjs +0 -1
- package/dist/external-CMBnwYR4.cjs +0 -1
- package/dist/external-CTsR6bs9.cjs +0 -46
- package/dist/external-Clec0nDH.cjs +0 -1
- package/dist/external-D7EEjQaR.js +0 -44
- package/dist/external-DDzR-j7b.cjs +0 -1
- package/dist/external-Ddn3rc_Q.cjs +0 -85
- package/dist/external-Dl0l3iHN.cjs +0 -1
- package/dist/external-Eaj0hgzm.cjs +0 -1
- package/dist/hooks-Bvv-S6WC.js +0 -74
- package/dist/hooks-CoF3Fkrn.cjs +0 -1
- package/dist/jsx-runtime-Dszzpdy0.cjs +0 -22
- package/dist/provider-lNhTlIWj.cjs +0 -72
- package/dist/src/hardware/device/Select.d.ts.map +0 -1
- package/dist/src/hardware/device/StatusIndicator.d.ts.map +0 -1
- package/dist/src/hardware/device/external.d.ts.map +0 -1
- package/dist/src/hardware/device/index.d.ts.map +0 -1
- package/dist/src/hardware/device/queries.d.ts.map +0 -1
- package/dist/src/hardware/device/queries.spec.d.ts.map +0 -1
- package/dist/src/hardware/rack/Select.d.ts.map +0 -1
- package/dist/src/hardware/rack/StatusIndicator.d.ts.map +0 -1
- package/dist/src/hardware/rack/external.d.ts.map +0 -1
- package/dist/src/hardware/rack/index.d.ts.map +0 -1
- package/dist/src/hardware/rack/queries.d.ts.map +0 -1
- package/dist/src/hardware/rack/queries.spec.d.ts.map +0 -1
- package/dist/src/hardware/task/index.d.ts.map +0 -1
- package/dist/src/hardware/task/queries.d.ts.map +0 -1
- package/dist/src/hardware/task/queries.spec.d.ts.map +0 -1
- package/dist/src/hooks/useRequiredContext.d.ts +0 -2
- package/dist/src/hooks/useRequiredContext.d.ts.map +0 -1
- package/dist/src/hooks/useRequiredContext.spec.d.ts +0 -2
- package/dist/src/hooks/useRequiredContext.spec.d.ts.map +0 -1
- package/dist/types-BNX_Jj6k.js +0 -80
- package/dist/types-D-yz1qsT.cjs +0 -1
- package/dist/units-DCifOxd9.cjs +0 -1
- package/dist/value-B3LTg1lE.cjs +0 -53
- /package/dist/src/{hardware/device → access/policy}/queries.spec.d.ts +0 -0
- /package/dist/src/{hardware/rack → access}/queries.spec.d.ts +0 -0
- /package/dist/src/{hardware/task → access/role}/queries.spec.d.ts +0 -0
- /package/dist/src/{hardware/device → device}/external.d.ts +0 -0
- /package/dist/src/{hardware/device → device}/index.d.ts +0 -0
- /package/dist/src/{hardware/rack → rack}/external.d.ts +0 -0
- /package/dist/src/{hardware/rack → rack}/index.d.ts +0 -0
- /package/dist/src/{hardware/task → task}/index.d.ts +0 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";const g=require("./provider-DHDqgF1B.cjs"),r=require("./css-BVgFAmaj.cjs"),d=require("zod"),M=require("./eraser-Cbfc1frM.cjs"),Qe=require("./fontString-62eEvw4b.cjs"),pe=require("./types-8-Mr79SF.cjs");require("react");const Ws=require("./dimensions-SDA3fM2T.cjs");class kr{entries=new Map;setListeners=new Map;deleteListeners=new Map;handleError;equal;constructor(e,t=()=>!1){this.handleError=e,this.equal=t}setOne(e,t,s,i){const a=this.entries.get(t),o=pe.executeSetter(s,a);if(!(o==null||a!=null&&this.equal(o,a,t)))return this.entries.set(t,o),this.notifySet(e,t,o,i),()=>{a===void 0?(this.entries.delete(t),this.notifyDelete(e,t)):(this.entries.set(t,a),this.notifySet(e,t,a,i))}}set(e,t,s,i){const a=[];if(Array.isArray(t))t.forEach(o=>{const l=this.setOne(e,o.key,o,s);l!=null&&a.push(l)});else if(typeof t=="object"&&"key"in t){const o=t,l=this.setOne(e,o.key,o,s);l!=null&&a.push(l)}else{const o=this.setOne(e,t,s,i);o!=null&&a.push(o)}return()=>a.reverse().forEach(o=>o())}get(e){return typeof e=="function"?Array.from(this.entries.values()).filter(e):Array.isArray(e)?e.map(t=>this.entries.get(t)).filter(t=>t!=null):this.entries.get(e)}list(){return Array.from(this.entries.values())}has(e){return Array.isArray(e)?e.every(t=>this.entries.has(t)):this.entries.has(e)}delete(e,t,s){const i=[];return typeof t=="function"?this.entries.forEach((a,o)=>{t(a,o)&&i.push({key:o,value:a})}):r.lu.toArray(t).forEach(a=>{const o=this.entries.get(a);i.push({key:a,value:o})}),i.forEach(({key:a})=>{this.entries.delete(a),this.notifyDelete(e,a)}),()=>i.forEach(({key:a,value:o})=>{o!=null&&(this.entries.set(a,o),this.notifySet(e,a,o,s))})}clear(){this.entries.clear()}onSet(e,t,s){return this.setListeners.set(t,{scope:e,key:s}),()=>this.setListeners.delete(t)}onDelete(e,t,s){return this.deleteListeners.set(t,{scope:e,key:s}),()=>this.deleteListeners.delete(t)}notifySet(e,t,s,i){this.setListeners.forEach((a,o)=>{const l=a.key==null||a.key===t,u=a.scope!==e;l&&u&&this.handleError(async()=>await o(s,i),"Failed to notify set listener")})}notifyDelete(e,t){this.deleteListeners.forEach((s,i)=>{const a=s.key==null||s.key===t,o=s.scope!==e;a&&o&&this.handleError(async()=>await i(t),"Failed to notify delete listener")})}scope(e){return{set:(t,s,i)=>this.set(e,t,s,i),get:(t=>this.get(t)),list:()=>this.list(),has:t=>this.has(t),delete:(t,s)=>this.delete(e,t,s),onSet:(t,s)=>this.onSet(e,t,s),onDelete:(t,s)=>this.onDelete(e,t,s)}}}const _r=(n,e)=>Object.fromEntries(Object.entries(n).map(([t,{equal:s}])=>[t,new kr(e,s)])),_n=(n,e)=>Object.fromEntries(Object.entries(n).map(([t])=>[t,n[t].scope(e)])),zo=(n,e,t)=>n.set(e,s=>s==null?void 0:{...s,...t}),Zo=(n,e)=>{const t=n.includes("delete"),s=e.includes("delete");return t&&!s?-1:!t&&s?1:0},Uo=async({openStreamer:n,storeConfig:e,handleError:t,client:s,store:i})=>{const a=Object.values(e),o=r.yu.unique(a.flatMap(({listeners:f})=>f.map(({channel:p})=>p))),l={};a.forEach(({listeners:f})=>f.forEach(p=>{const{channel:y}=p;l[y]=[...l[y]||[],p]}));const u=await g.Hk.HardenedStreamer.open(n,o),c=new g.Hk.ObservableStreamer(u),h=f=>{const p=[...f.uniqueNames];p.sort(Zo),t(async()=>{for(const y of p){const b=f.get(y),v=l[y];if(v!=null)for(const{onChange:w,schema:E}of v)await t(async()=>{let R;b.dataType.equals(r.f.JSON)?R=b.parseJSON(E):R=Array.from(b).map(C=>E.parse(C));for(const C of R)await t(()=>w({changed:C,client:s,store:i}),`Failed to handle streamer change for ${y}`,g.An)},`Failed to parse streamer change for ${y}`)}},`Failed to handle streamer change for ${r.sl.naturalLanguageJoin(p)}`)};return c.onChange(h),c.close.bind(c)};class Or{store;streamCloser=null;client;constructor({client:e,openStreamer:t,storeConfig:s,handleError:i,handleAsyncError:a}){this.store=_r(s,i),this.client=e,e!=null&&(t??=e?.openStreamer.bind(e),this.streamCloser=Uo({client:e,storeConfig:s,handleError:a,store:_n(this.store,""),openStreamer:t}))}async awaitInitialized(){this.streamCloser!=null&&await this.streamCloser}scopedStore(e){return _n(this.store,e)}async close(){if(this.streamCloser==null)return;await(await this.streamCloser)()}}const Bo=d.z.object({props:g.ik.nullable(),state:g.ak.connectivity.connectionStateZ.nullable()}),as={client:null};let Nt=class Ar extends g.Composite{static TYPE="synnax.Provider";static stateZ=Bo;schema=Ar.stateZ;afterUpdate(e){if(e.wasSetPreviously(ls)||Tn(e,as),this.state.props==null){this.internal.client!=null&&(this.internal.client?.close(),this.internal.client=null),Tn(e,this.internal);return}this.prevState.props!=null&&r.qu.equal(this.state.props,this.prevState.props)&&this.internal.client!=null||(this.internal.client=new g.ak(this.state.props),Tn(e,this.internal))}};const ls="pluto-client-context",Tn=(n,e)=>n.set(ls,e),$e=n=>n.get(ls)?.client??null,Ir={[Nt.TYPE]:Nt},Fo=Object.freeze(Object.defineProperty({__proto__:null,Provider:Nt,REGISTRY:Ir,ZERO_CONTEXT_VALUE:as,use:$e},Symbol.toStringTag,{value:"Module"})),Mr=d.object({}),On="flux-context",cs="flux.Provider",$o=(n,e)=>n.get(On).scopedStore(e),qo=n=>{const e=(t,s)=>{if("client"in n)return n.client;const i=$e(t);return s!=null&&s?.client?.key===i?.key?s:new Or({client:i,storeConfig:n.storeConfig,handleError:g.useErrorHandler(t),handleAsyncError:g.useAsyncErrorHandler(t)})};return class Dr extends g.Composite{static TYPE=cs;static stateZ=Mr;schema=Dr.stateZ;afterUpdate(s){const{internal:i}=this;i.store=e(s,i.store),s.wasSetPreviously(On)||s.set(On,i.store)}}},Ho=n=>({[cs]:qo(n)}),us="pluto-vis-renderer",sn=(n,e)=>{n.set(us,e,!1)},rn=n=>n.get(us),hs=n=>n.getOptional(us),ie=(n,e)=>rn(n)(e),jo="relationships",Wo="resources",Vo={channel:g.Ik.RELATIONSHIP_SET_CHANNEL_NAME,schema:g.Ik.relationshipZ,onChange:({store:n,changed:e})=>n.relationships.set(g.Ik.relationshipToString(e),e)},Xo={channel:g.Ik.RELATIONSHIP_DELETE_CHANNEL_NAME,schema:g.Ik.relationshipZ,onChange:({store:n,changed:e})=>{n.relationships.delete(g.Ik.relationshipToString(e))}},Go={equal:(n,e)=>g.Ik.idsEqual(n.from,e.from)&&g.Ik.idsEqual(n.to,e.to)&&n.type===e.type,listeners:[Vo,Xo]},Ko={channel:g.Ik.RESOURCE_SET_CHANNEL_NAME,schema:g.Ik.resourceZ,onChange:async({store:n,changed:e})=>{n.resources.set(e.key,t=>t==null?e:{...t,...e})}},Qo={channel:g.Ik.RESOURCE_DELETE_CHANNEL_NAME,schema:g.Ik.idZ,onChange:({store:n,changed:e})=>n.resources.delete(e.key)},Jo={equal:(n,e)=>r.qu.equal(n,e),listeners:[Ko,Qo]},ea="policies",ta={channel:g.Mk.policy.SET_CHANNEL_NAME,schema:g.Mk.policy.policyZ,onChange:({store:n,changed:e})=>n.policies.set(e.key,e)},na={channel:g.Mk.policy.DELETE_CHANNEL_NAME,schema:g.Mk.policy.keyZ,onChange:({store:n,changed:e})=>n.policies.delete(e)},sa={listeners:[ta,na]},Yr=(n,e)=>{const t=n.relationships.get(a=>g.Ik.matchRelationship(a,{from:{type:"role"},type:g.Ik.PARENT_OF_RELATIONSHIP_TYPE,to:e})),i=n.relationships.get(a=>t.some(o=>g.Ik.matchRelationship(a,{from:o.from,type:g.Ik.PARENT_OF_RELATIONSHIP_TYPE,to:{type:"policy"}}))).map(a=>a.to.key);return n.policies.get(i)},ra=async({client:n,store:e,subject:t})=>{let s=Yr(e,t);if(s.length>0)return s;s=await n.access.policies.retrieve({for:t}),e.policies.set(s);for(const i of s)(await n.ontology.retrieveParents([g.Mk.policy.ontologyID(i.key)],{types:["role"]})).forEach(o=>{const l={from:o.id,type:g.Ik.PARENT_OF_RELATIONSHIP_TYPE,to:g.Mk.policy.ontologyID(i.key)};e.relationships.set(g.Ik.relationshipToString(l),l);const u={from:o.id,type:g.Ik.PARENT_OF_RELATIONSHIP_TYPE,to:t};e.relationships.set(g.Ik.relationshipToString(u),u)});return s};function ds(n,e,t){n.prototype=e.prototype=t,t.constructor=n}function zr(n,e){var t=Object.create(n.prototype);for(var s in e)t[s]=e[s];return t}function ut(){}var Je=.7,Lt=1/Je,Re="\\s*([+-]?\\d+)\\s*",et="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",ee="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",ia=/^#([0-9a-f]{3,8})$/,oa=new RegExp(`^rgb\\(${Re},${Re},${Re}\\)$`),aa=new RegExp(`^rgb\\(${ee},${ee},${ee}\\)$`),la=new RegExp(`^rgba\\(${Re},${Re},${Re},${et}\\)$`),ca=new RegExp(`^rgba\\(${ee},${ee},${ee},${et}\\)$`),ua=new RegExp(`^hsl\\(${et},${ee},${ee}\\)$`),ha=new RegExp(`^hsla\\(${et},${ee},${ee},${et}\\)$`),Vs={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};ds(ut,Le,{copy(n){return Object.assign(new this.constructor,this,n)},displayable(){return this.rgb().displayable()},hex:Xs,formatHex:Xs,formatHex8:da,formatHsl:fa,formatRgb:Gs,toString:Gs});function Xs(){return this.rgb().formatHex()}function da(){return this.rgb().formatHex8()}function fa(){return Zr(this).formatHsl()}function Gs(){return this.rgb().formatRgb()}function Le(n){var e,t;return n=(n+"").trim().toLowerCase(),(e=ia.exec(n))?(t=e[1].length,e=parseInt(e[1],16),t===6?Ks(e):t===3?new B(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):t===8?bt(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):t===4?bt(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=oa.exec(n))?new B(e[1],e[2],e[3],1):(e=aa.exec(n))?new B(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=la.exec(n))?bt(e[1],e[2],e[3],e[4]):(e=ca.exec(n))?bt(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=ua.exec(n))?er(e[1],e[2]/100,e[3]/100,1):(e=ha.exec(n))?er(e[1],e[2]/100,e[3]/100,e[4]):Vs.hasOwnProperty(n)?Ks(Vs[n]):n==="transparent"?new B(NaN,NaN,NaN,0):null}function Ks(n){return new B(n>>16&255,n>>8&255,n&255,1)}function bt(n,e,t,s){return s<=0&&(n=e=t=NaN),new B(n,e,t,s)}function pa(n){return n instanceof ut||(n=Le(n)),n?(n=n.rgb(),new B(n.r,n.g,n.b,n.opacity)):new B}function An(n,e,t,s){return arguments.length===1?pa(n):new B(n,e,t,s??1)}function B(n,e,t,s){this.r=+n,this.g=+e,this.b=+t,this.opacity=+s}ds(B,An,zr(ut,{brighter(n){return n=n==null?Lt:Math.pow(Lt,n),new B(this.r*n,this.g*n,this.b*n,this.opacity)},darker(n){return n=n==null?Je:Math.pow(Je,n),new B(this.r*n,this.g*n,this.b*n,this.opacity)},rgb(){return this},clamp(){return new B(ge(this.r),ge(this.g),ge(this.b),kt(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Qs,formatHex:Qs,formatHex8:ga,formatRgb:Js,toString:Js}));function Qs(){return`#${de(this.r)}${de(this.g)}${de(this.b)}`}function ga(){return`#${de(this.r)}${de(this.g)}${de(this.b)}${de((isNaN(this.opacity)?1:this.opacity)*255)}`}function Js(){const n=kt(this.opacity);return`${n===1?"rgb(":"rgba("}${ge(this.r)}, ${ge(this.g)}, ${ge(this.b)}${n===1?")":`, ${n})`}`}function kt(n){return isNaN(n)?1:Math.max(0,Math.min(1,n))}function ge(n){return Math.max(0,Math.min(255,Math.round(n)||0))}function de(n){return n=ge(n),(n<16?"0":"")+n.toString(16)}function er(n,e,t,s){return s<=0?n=e=t=NaN:t<=0||t>=1?n=e=NaN:e<=0&&(n=NaN),new J(n,e,t,s)}function Zr(n){if(n instanceof J)return new J(n.h,n.s,n.l,n.opacity);if(n instanceof ut||(n=Le(n)),!n)return new J;if(n instanceof J)return n;n=n.rgb();var e=n.r/255,t=n.g/255,s=n.b/255,i=Math.min(e,t,s),a=Math.max(e,t,s),o=NaN,l=a-i,u=(a+i)/2;return l?(e===a?o=(t-s)/l+(t<s)*6:t===a?o=(s-e)/l+2:o=(e-t)/l+4,l/=u<.5?a+i:2-a-i,o*=60):l=u>0&&u<1?0:o,new J(o,l,u,n.opacity)}function ma(n,e,t,s){return arguments.length===1?Zr(n):new J(n,e,t,s??1)}function J(n,e,t,s){this.h=+n,this.s=+e,this.l=+t,this.opacity=+s}ds(J,ma,zr(ut,{brighter(n){return n=n==null?Lt:Math.pow(Lt,n),new J(this.h,this.s,this.l*n,this.opacity)},darker(n){return n=n==null?Je:Math.pow(Je,n),new J(this.h,this.s,this.l*n,this.opacity)},rgb(){var n=this.h%360+(this.h<0)*360,e=isNaN(n)||isNaN(this.s)?0:this.s,t=this.l,s=t+(t<.5?t:1-t)*e,i=2*t-s;return new B(xn(n>=240?n-240:n+120,i,s),xn(n,i,s),xn(n<120?n+240:n-120,i,s),this.opacity)},clamp(){return new J(tr(this.h),St(this.s),St(this.l),kt(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const n=kt(this.opacity);return`${n===1?"hsl(":"hsla("}${tr(this.h)}, ${St(this.s)*100}%, ${St(this.l)*100}%${n===1?")":`, ${n})`}`}}));function tr(n){return n=(n||0)%360,n<0?n+360:n}function St(n){return Math.max(0,Math.min(1,n||0))}function xn(n,e,t){return(n<60?e+(t-e)*n/60:n<180?t:n<240?e+(t-e)*(240-n)/60:e)*255}const fs=n=>()=>n;function ya(n,e){return function(t){return n+t*e}}function va(n,e,t){return n=Math.pow(n,t),e=Math.pow(e,t)-n,t=1/t,function(s){return Math.pow(n+s*e,t)}}function ba(n){return(n=+n)==1?Ur:function(e,t){return t-e?va(e,t,n):fs(isNaN(e)?t:e)}}function Ur(n,e){var t=e-n;return t?ya(n,t):fs(isNaN(n)?e:n)}const In=(function n(e){var t=ba(e);function s(i,a){var o=t((i=An(i)).r,(a=An(a)).r),l=t(i.g,a.g),u=t(i.b,a.b),c=Ur(i.opacity,a.opacity);return function(h){return i.r=o(h),i.g=l(h),i.b=u(h),i.opacity=c(h),i+""}}return s.gamma=n,s})(1);function Sa(n,e){e||(e=[]);var t=n?Math.min(e.length,n.length):0,s=e.slice(),i;return function(a){for(i=0;i<t;++i)s[i]=n[i]*(1-a)+e[i]*a;return s}}function wa(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function Ta(n,e){var t=e?e.length:0,s=n?Math.min(t,n.length):0,i=new Array(s),a=new Array(t),o;for(o=0;o<s;++o)i[o]=on(n[o],e[o]);for(;o<t;++o)a[o]=e[o];return function(l){for(o=0;o<s;++o)a[o]=i[o](l);return a}}function xa(n,e){var t=new Date;return n=+n,e=+e,function(s){return t.setTime(n*(1-s)+e*s),t}}function tt(n,e){return n=+n,e=+e,function(t){return n*(1-t)+e*t}}function Ea(n,e){var t={},s={},i;(n===null||typeof n!="object")&&(n={}),(e===null||typeof e!="object")&&(e={});for(i in e)i in n?t[i]=on(n[i],e[i]):s[i]=e[i];return function(a){for(i in t)s[i]=t[i](a);return s}}var Mn=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,En=new RegExp(Mn.source,"g");function Ca(n){return function(){return n}}function Pa(n){return function(e){return n(e)+""}}function Br(n,e){var t=Mn.lastIndex=En.lastIndex=0,s,i,a,o=-1,l=[],u=[];for(n=n+"",e=e+"";(s=Mn.exec(n))&&(i=En.exec(e));)(a=i.index)>t&&(a=e.slice(t,a),l[o]?l[o]+=a:l[++o]=a),(s=s[0])===(i=i[0])?l[o]?l[o]+=i:l[++o]=i:(l[++o]=null,u.push({i:o,x:tt(s,i)})),t=En.lastIndex;return t<e.length&&(a=e.slice(t),l[o]?l[o]+=a:l[++o]=a),l.length<2?u[0]?Pa(u[0].x):Ca(e):(e=u.length,function(c){for(var h=0,f;h<e;++h)l[(f=u[h]).i]=f.x(c);return l.join("")})}function on(n,e){var t=typeof e,s;return e==null||t==="boolean"?fs(e):(t==="number"?tt:t==="string"?(s=Le(e))?(e=s,In):Br:e instanceof Le?In:e instanceof Date?xa:wa(e)?Sa:Array.isArray(e)?Ta:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?Ea:tt)(n,e)}function Ra(n,e){return n=+n,e=+e,function(t){return Math.round(n*(1-t)+e*t)}}class le extends r.Xu.Observer{cleanup(){}}class Dn extends le{static TYPE="noop-boolean-sink";set(){}}const an={type:Dn.TYPE,props:{},variant:"sink",valueType:"boolean"};class Yn extends le{static TYPE="noop-numeric-sink";set(){}}const Fr={type:Yn.TYPE,props:{},variant:"sink",valueType:"number"};class zn extends le{static TYPE="noop-boolean-source";value(){return!1}}const ps={type:zn.TYPE,props:{},variant:"source",valueType:"boolean"};class Zn extends le{static TYPE="noop-numeric-source";value(){return 0}}const $r={type:Zn.TYPE,props:{},variant:"source",valueType:"number"};class Un extends le{static TYPE="noop-string-sink";set(){}}const qr={type:Un.TYPE,props:{},variant:"sink",valueType:"string"};class Bn extends le{static TYPE="noop-string-source";value(){return""}}const gs={type:Bn.TYPE,props:{},variant:"source",valueType:"string"};class Fn extends le{static TYPE="noop-status-source";value(){return{key:"noop",name:"noop",variant:"disabled",message:"unknown",time:r.d.now()}}}const ms={type:Fn.TYPE,props:{},variant:"source",valueType:"status"};class $n extends le{static TYPE="noop-color-source";value(){return r.Pu.ZERO}}const ht={type:$n.TYPE,props:{},variant:"source",valueType:"color"};class qn extends le{static TYPE="noop-series";value(){return[r.wu.ZERO,new r.ju([])]}}const Hr={type:qn.TYPE,props:{},variant:"source",valueType:"series"},Na={[Dn.TYPE]:Dn,[Yn.TYPE]:Yn,[Un.TYPE]:Un,[zn.TYPE]:zn,[Zn.TYPE]:Zn,[Fn.TYPE]:Fn,[$n.TYPE]:$n,[Bn.TYPE]:Bn,[qn.TYPE]:qn};class jr{type="noop";create(e){const t=Na[e.type];return t==null?null:new t}}const La=d.z.instanceof(ArrayBuffer),dt=d.z.object({type:d.z.string(),variant:d.z.enum(["source","sink","source-transformer","sink-transformer"]),valueType:d.z.string(),props:d.z.any(),transfer:d.z.array(La).optional()}),ce=dt.extend({variant:d.z.literal("source")}),ft=dt.extend({variant:d.z.literal("sink")}),Wr=dt.extend({variant:d.z.literal("source-transformer")}),Vr=dt.extend({variant:d.z.literal("sink-transformer")}),_t=ce.extend({valueType:d.z.literal("series")}),ys=ce.extend({valueType:d.z.literal("boolean")}),ln=ft.extend({valueType:d.z.literal("boolean")}),ka=Vr.extend({valueType:d.z.literal("boolean")}),_a=Wr.extend({valueType:d.z.literal("boolean")}),Xr=ce.extend({valueType:d.z.literal("number")}),Gr=ft.extend({valueType:d.z.literal("number")}),cn=ce.extend({valueType:d.z.literal("color")}),vs=ce.extend({valueType:d.z.literal("status")}),un=ce.extend({valueType:d.z.literal("string")}),Kr=ft.extend({valueType:d.z.literal("string")});let hn=class extends r.Xu.BaseObserver{props_=void 0;uProps_=void 0;constructor(e){super(),this.uProps_=e}get props(){if(this.props_==null){const e=this.schema.safeParse(this.uProps_);if(e.success)this.props_=e.data;else throw new g.V(`[BaseTelem] - expected props to be valid, but found the following errors:
|
|
2
|
+
${e.error.message}`)}return this.props_}cleanup(){}};class j extends hn{}class dn extends hn{}class ve extends j{source_=void 0;get source(){if(this.source_==null)throw new g.V("[UnarySourceTransformer] - expected source to exist, but none was found.");return this.source_}value(){return this.transform(this.source.value())}onChange(e){return this.source.onChange(()=>{this.shouldNotify(this.source.value())&&e()})}setSources(e){this.source_=Object.values(e)[0]}shouldNotify(e){return!0}}class Qr extends j{sources={};value(){const e=Object.fromEntries(Object.entries(this.sources).map(([t,s])=>[t,s.value()]));return this.transform(e)}setSources(e){this.sources={...this.sources,...e}}}class Jr extends hn{sinks={};get sink(){const[e]=Object.values(this.sinks);if(e==null)throw new g.V("[UnarySinkTransformer] - expected sink to exist, but none was found.");return e}set(...e){return this.sink.set(...this.transform(...e))}setSinks(e){this.sinks={...this.sinks,...e}}}const bs=d.z.object({from:d.z.string(),to:d.z.string()}),Ss=d.z.object({connections:d.z.array(bs),outlet:d.z.string(),segments:d.z.record(d.z.string(),ce)});class ws{type="pipeline";factory;constructor(e){this.factory=e}create(e){switch(e.type){case Ot.TYPE:return new Ot(e.props,this.factory);case At.TYPE:return new At(e.props,this.factory);default:return null}}}class Ot extends j{static TYPE="source-pipeline";schema=Ss;sources={};get outlet(){const{outlet:e}=this.props,t=this.sources[e];if(t==null)throw new g.V(`[SourcePipeline] - expected source to exist at outlet '${e}', but none was found.`);return t}constructor(e,t){super(e);const{connections:s,segments:i}=this.props;Object.entries(i).forEach(([a,o])=>{const l=t.create(o);l!=null&&(this.sources[a]=l)}),s.forEach(({from:a,to:o})=>{const l=this.sources[a],u=this.sources[o];l==null||u==null||"setSources"in u&&u.setSources({[a]:l})})}value(){return this.outlet.value()}onChange(e){return this.outlet.onChange(e)}cleanup(){Object.values(this.sources).forEach(e=>e.cleanup?.())}}const ei=(n,e)=>({variant:"source",props:e,type:Ot.TYPE,valueType:n}),Ts=d.z.object({connections:d.z.array(bs),inlet:d.z.string(),segments:d.z.record(d.z.string(),ft)});class At extends dn{static TYPE="sink-pipeline";schema=Ts;sinks={};get inlet(){const{inlet:e}=this.props,t=this.sinks[e];if(t==null)throw new g.V(`[SinkPipeline] - expected source to exist at inlet '${e}', but none was found.`);return t}constructor(e,t){super(e);const{connections:s,segments:i}=this.props;Object.entries(i).forEach(([a,o])=>{const l=t.create(o);l!=null&&(this.sinks[a]=l)}),s.forEach(({from:a,to:o})=>{const l=this.sinks[a],u=this.sinks[o];l==null||u==null||"setSinks"in l&&l.setSinks({[o]:u})})}set(...e){return this.inlet.set(...e)}cleanup(){Object.values(this.sinks).forEach(e=>e.cleanup?.())}}const ti=(n,e)=>({variant:"sink",props:e,type:At.TYPE,valueType:n}),xs=d.z.object({channel:d.z.number().or(d.z.string())});class It extends j{static TYPE="stream-channel-value";schema=xs;client;removeStreamHandler=null;leadingBuffer=null;valid=!1;onStatusChange;constructor(e,t,s){super(t),this.client=e,this.onStatusChange=s?.onStatusChange}get testingOnlyLeadingBuffer(){return this.leadingBuffer}get testingOnlyValid(){return this.valid}cleanup(){this.removeStreamHandler?.(),this.valid=!1,this.leadingBuffer?.release(),this.leadingBuffer=null,this.removeStreamHandler=null}value(){return r.gu.isZero(this.props.channel)?NaN:(this.valid||this.read(),this.leadingBuffer==null||this.leadingBuffer.length===0?NaN:this.leadingBuffer.at(-1,!0))}async read(){try{this.valid=!0,this.removeStreamHandler?.();const e=await this.client.retrieveChannel(this.props.channel),t=s=>{const i=s.get(e.key);if(i==null)return;const a=i.series.at(-1);a!=null&&(a.acquire(),this.leadingBuffer?.release(),this.leadingBuffer=a),this.notify()};this.removeStreamHandler=await this.client.stream(t,[e.key]),this.notify()}catch(e){this.valid=!1,this.onStatusChange?.(r.rl.fromException(e,"failed to stream channel value"))}}}const ni=async(n,e,t)=>{const s=await n.retrieveChannel(e),i=g.Bk.isCalculated(s),a=g.Bk.isLegacyCalculated(s);if(!t||s.isIndex)return{key:s.key,dataType:s.dataType,virtual:s.virtual,isCalculated:i};if(a){const o=await g.Bk.resolveLegacyCalculatedIndex(n.retrieveChannel.bind(n),s);if(o==null)throw new g.An("Failed to resolve calculated index");return{key:(await n.retrieveChannel(o)).key,dataType:r.f.TIMESTAMP,virtual:!1,isCalculated:i}}if(s.virtual&&!i)throw new g.An("cannot use virtual channels as a data source");return{key:s.index,dataType:r.f.TIMESTAMP,virtual:!1,isCalculated:i}},Oa=d.z.object({timeRange:r.S.z,channel:d.z.number().or(d.z.string()),useIndexOfChannel:d.z.boolean().default(!1)});class Mt extends j{static TYPE="series-source";client;schema=Oa;data=new r.ju;valid=!1;channel=null;onStatusChange;constructor(e,t,s){super(t),this.client=e,this.onStatusChange=s?.onStatusChange}cleanup(){this.data.release(),this.valid=!1,this.channel=null}value(){const{channel:e,timeRange:t}=this.props;if(t.span.isZero||e===0)return[r.wu.ZERO,this.data];this.valid||this.read();const{channel:s,data:i}=this;if(s==null)return[r.wu.ZERO,this.data];let a=i.bounds;return s.dataType.equals(r.f.TIMESTAMP)&&(a=r.wu.min([a,t.numericBounds])),[a,i]}async read(){try{this.valid=!0;const{timeRange:e,channel:t,useIndexOfChannel:s}=this.props;this.channel=await ni(this.client,t,s);const i=await this.client.read(e,this.channel.key);i.acquire(),this.data=i,this.notify()}catch(e){this.valid=!1,this.onStatusChange?.(r.rl.fromException(e,"failed to read channel data"))}}}const Aa=d.z.object({channel:d.z.number().or(d.z.string()),useIndexOfChannel:d.z.boolean().default(!1),timeSpan:r.g.z,keepFor:r.g.z.optional()});class Dt extends j{static TYPE="dynamic-series-source";client;data=new r.ju([]);now;onStatusChange;channel=null;stopStreaming;valid=!1;schema=Aa;constructor(e,t,s,i=()=>r.d.now()){super(t),this.client=e,this.now=i,this.onStatusChange=s?.onStatusChange}value(){const{channel:e,timeSpan:t}=this.props;if(e===0)return[r.wu.ZERO,this.data];this.valid||this.read();const{data:s,channel:i}=this,a=this.now();if(i!=null&&i.dataType.isVariable)return[r.wu.ZERO,this.data];const o=s.series.filter(u=>u.timeRange.end.after(a.sub(t))).map(u=>u.bounds),l=r.wu.max(o);return i!=null&&i.dataType.equals(r.f.TIMESTAMP)&&(l.lower=Math.max(l.lower,l.upper-Number(t.valueOf()))),[l,this.data]}async read(){try{this.valid=!0;const{channel:e,useIndexOfChannel:t,timeSpan:s}=this.props;this.channel=await ni(this.client,e,t);const i=this.now().spanRange(-s);if(!this.channel.virtual||this.channel.isCalculated)try{const o=await this.client.read(i,this.channel.key);o.acquire(),this.data.push(o)}catch(o){if(o instanceof Error&&(o.message.includes("cannot open iterator on virtual channel")||o.message.includes("cannot read from free channel")))console.warn("failed to read calculated channel data",o);else throw o}this.stopStreaming?.();const a=o=>{if(this.channel==null)return;const l=o.get(this.channel.key);l!=null&&(l.acquire(),this.data.push(l),this.notify(),this.gcOutOfRangeData())};this.stopStreaming=await this.client.stream(a,[this.channel.key]),this.notify()}catch(e){this.valid=!1,this.onStatusChange?.(r.rl.fromException(e,"failed to stream channel data"))}}gcOutOfRangeData(){const e=this.now().sub(this.props.keepFor??this.props.timeSpan),t=this.data.series.findIndex(s=>s.timeRange.end.before(e));t!==-1&&(this.data.series.splice(t,1).forEach(s=>s.release()),this.gcOutOfRangeData())}cleanup(){this.stopStreaming?.(),this.stopStreaming=void 0,this.data.release(),this.valid=!1}}const Ia={[Mt.TYPE]:Mt,[Dt.TYPE]:Dt,[It.TYPE]:It};class si{type="remote";client;constructor(e){this.client=e}create(e,t){const s=Ia[e.type];return s==null?null:new s(this.client,e.props,t)}}const ri=n=>({type:Mt.TYPE,props:n,variant:"source",valueType:"series"}),ii=n=>({type:Dt.TYPE,props:n,variant:"source",valueType:"series"}),oi=n=>({type:It.TYPE,props:n,variant:"source",valueType:"number"});class ai{type="static";create(e){switch(e.type){case Hn.TYPE:return new Hn(e.props);case Yt.TYPE:return new Yt(e.props);case zt.TYPE:return new zt(e.props);case Zt.TYPE:return new Zt(e.props);case Ut.TYPE:return new Ut(e.props);default:return null}}}const Es=d.z.object({data:d.z.array(r.$u),offsets:d.z.array(d.z.number()).default([])});class Hn extends j{data;schema=Es;static TYPE="static-series";constructor(e){super(e),this.data=this.props.data.map((t,s)=>new r.q({data:t,dataType:r.f.FLOAT32,timeRange:r.S.ZERO,sampleOffset:this.props.offsets[s]??0}))}value(){return[r.wu.max(this.data.map(t=>t.bounds)),this.data]}}const li=Es.extend({rate:r.$.z,yOffset:d.z.number().default(0),scroll:d.z.number().default(0),startPosition:d.z.number().default(0),scrollBounds:d.z.boolean().default(!1)});class Yt extends j{static TYPE="iterative-series";schema=li;position;interval;data;constructor(e){super(e),this.position=this.props.startPosition,this.start(this.props.rate),this.data=this.props.data.map((t,s)=>new r.q({data:t,dataType:r.f.FLOAT32,timeRange:r.S.ZERO,sampleOffset:this.props.offsets[s]??0}))}value(){const e=this.data.map(s=>s.slice(0,this.position));if(this.props.scrollBounds){const s=e[0].data[this.position-this.props.scroll<0?0:this.position-this.props.scroll],i=e[0].data[this.position-1];return[{lower:Number(s),upper:Number(i)},new r.ju(e)]}return[r.wu.max(e.map(s=>s.bounds)),new r.ju(e)]}start(e){this.interval!=null&&clearInterval(this.interval),this.interval=setInterval(()=>{this.notify?.(),this.position++},e.period.milliseconds)}cleanup(){clearInterval(this.interval),this.interval=void 0}}const ci=d.z.number();class zt extends j{static TYPE="static-numeric";schema=ci;value(){return this.props}}const ui=d.z.string();class Zt extends j{static TYPE="static-string";schema=ui;value(){return this.props}}const hi=r.Pu.crudeZ;class Ut extends j{static TYPE="static-color";schema=hi;value(){return r.Pu.construct(this.props)}}const Ma=n=>({type:Hn.TYPE,props:n,variant:"source",valueType:"series"}),Da=n=>({type:Yt.TYPE,props:n,variant:"source",valueType:"series"}),Ya=n=>({type:zt.TYPE,props:n,variant:"source",valueType:"number"}),za=n=>({type:Zt.TYPE,props:n,variant:"source",valueType:"string"}),Za=n=>({type:Ut.TYPE,props:n,variant:"source",valueType:"color"});class di{type="transformer";create(e){switch(e.type){case ke.TYPE:return new ke(e.props);case _e.TYPE:return new _e(e.props);case Oe.TYPE:return new Oe(e.props);case Ae.TYPE:return new Ae(e.props);case Ie.TYPE:return new Ie(e.props);case Bt.TYPE:return new Bt(e.props);case Me.TYPE:return new Me(e.props);case De.TYPE:return new De(e.props)}return null}}const Ua=d.z.object({truthy:d.z.number().default(1),falsy:d.z.number().default(0)}),fi=n=>({props:n,type:ke.TYPE,variant:"sink",valueType:"boolean"});class ke extends Jr{static TYPE="boolean-numeric-converter-sink";static propsZ=Ua;schema=ke.propsZ;transform(...e){return e.map(t=>t?this.props.truthy:this.props.falsy)}}const Cs=d.z.object({trueBound:r.wu.bounds}),pi=n=>({props:n,type:_e.TYPE,variant:"source",valueType:"boolean"});class _e extends ve{static TYPE="boolean-source";static propsZ=Cs;schema=_e.propsZ;curr=null;shouldNotify(e){const t=r.wu.contains(this.props.trueBound,e)!==this.curr;return this.curr=r.wu.contains(this.props.trueBound,e),t}transform(e){return this.curr=r.wu.contains(this.props.trueBound,e),this.curr}}const gi=d.z.object({});class Oe extends Qr{static TYPE="mean";static propsZ=gi;schema=Oe.propsZ;transform(e){return Object.values(e).reduce((t,s)=>t+s,0)/Object.keys(e).length}}const Ba=n=>({props:n,type:Oe.TYPE,variant:"source",valueType:"boolean"}),mi=d.z.object({trueVariant:r.rl.variantZ.default("success")});class Ae extends ve{static TYPE="boolean-status";static propsZ=mi;schema=Ae.propsZ;transform(e){return e.variant===this.props.trueVariant}}const Fa=n=>({props:n,type:Ae.TYPE,variant:"source",valueType:"boolean"}),Ps=d.z.object({precision:d.z.number().default(2),prefix:d.z.string().default(""),suffix:d.z.string().default(""),notation:r.Ju.notationZ.default("standard")});class Ie extends ve{static TYPE="stringify-number";static propsZ=Ps;schema=Ie.propsZ;transform(e){if(isNaN(e))return"";const{precision:t,prefix:s,suffix:i,notation:a}=this.props;return`${s}${r.Ju.stringifyNumber(e,t,a)}${i}`}}const yi=n=>({props:n,type:Ie.TYPE,variant:"source",valueType:"string"}),Rs=d.z.object({windowSize:d.z.number().default(5)});class Bt extends ve{static TYPE="rolling-average";static propsZ=gi;schema=Rs;values=[];transform(e){return this.props.windowSize<2||isNaN(e)?e:this.values.reduce((t,s)=>t+s,0)/this.values.length}shouldNotify(e){return this.props.windowSize<2?!0:(this.values.length>this.props.windowSize&&(this.values=[]),this.values.push(e),this.values.length===this.props.windowSize)}}const vi=n=>({props:n,type:Bt.TYPE,variant:"source",valueType:"number"}),bi=d.z.object({gradient:r.Pu.gradientZ});class Me extends ve{static TYPE="color-gradient";static propsZ=bi;schema=Me.propsZ;transform(e){return r.Pu.fromGradient(this.props.gradient,e)}}const Si=n=>({props:n,type:Me.TYPE,variant:"source",valueType:"color"}),wi=d.z.object({scale:r.Au.transform});class De extends ve{static TYPE="scale-number";static propsZ=wi;schema=De.propsZ;transform(e){if(isNaN(e))return e;const{offset:t,scale:s}=this.props.scale;return e*s+t}}const Ti=n=>({props:n,type:De.TYPE,variant:"source",valueType:"number"}),Ns=d.z.enum(["average","decimate"]),$a=d.z.object({mode:Ns,windowSize:d.z.number().default(5)}),qa=n=>({props:n,type:nt.TYPE,variant:"source",valueType:"number"}),xi=(n,e,t)=>{const s=e.length*t;for(let i=s;i<n.length;i+=t){const a=n.sub(i,i+1);a!==void 0&&e.write(a)}},Ha=(n,e,t)=>{const s=e.length*t;for(let i=s;i<n.length&&!(i+t>n.length);i+=t){const a=Math.min(i+t,n.length);let o=0,l=0;for(let u=i;u<a;u++){const c=n.at(u);c!==void 0&&typeof c=="number"&&(o+=c,l++)}l>0&&e.write(new r.q({data:[o/l],dataType:n.dataType}))}},ja={decimate:xi,average:Ha};class nt{static TYPE="series-downsampler";_downsample=null;cache=new r.ju;props;constructor(e){this.props=e}downsample(e){return this._downsample==null&&(e.series[0].sampleOffset!==0?this._downsample=xi:this._downsample=ja[this.props.mode]),this._downsample}transform(e){if(this.props.mode==="decimate"||this.props.windowSize<=1)return e;if(e.series.length===0)return this.cache;for(;this.cache.series.length>0&&!this.cache.series[0].key.startsWith(e.series[0].key);)this.cache.series.shift();return e.series.forEach((t,s)=>{let i=this.cache.series.at(s);if(i==null){const a=Math.ceil(t.capacity/this.props.windowSize);i=r.q.alloc({key:t.key+r.pu.create(),dataType:t.dataType,capacity:a,alignment:t.alignment,alignmentMultiple:BigInt(this.props.windowSize),sampleOffset:t.sampleOffset,timeRange:t.timeRange}),this.cache.push(i)}else if(!i.key.startsWith(t.key))throw new g.Ut(`[SeriesDownsampler] - expected series with key ${t.key} to be in cache, but found ${i.key}`);this.downsample(e)(t,i,this.props.windowSize)}),this.cache}}const Wa=n=>({props:n,type:nt.TYPE,variant:"source",valueType:"series"});class Ls{factories;type="compound";constructor(e){this.factories=e}add(e){this.factories=[...this.factories.filter(t=>t.type!==e.type),e]}create(e,t){for(const s of this.factories){const i=s.create(e,t);if(i!=null)return i}return null}}const Ei=n=>{const e=[new di,new ai,new jr],t=new Ls(e);return n!=null&&t.add(new si(n)),t.add(new ws(t)),t};let Ci=class Pi{factory;key;parent;constructor(e,t){this.factory=e,this.key=r.pu.create(),this.parent=t}child(e,t){const s=new Ls([...this.factory.factories,...r.lu.toArray(e)]);return s.add(new ws(s)),new Pi(s,t)}create(e,t){const s=this.factory.create(e,t);if(s==null)throw new g.Ut(`Telemetry service could not find a source for type ${e.type}`);return s}};const pt="pluto-telem-context",fn=n=>n.get(pt),Ri=(n,e)=>n.set(pt,e),Ni=(n,e,t)=>{const s=fn(n);if(s!=null&&t!=null&&s.key===t?.parent?.key)return t;const i=s.child(e,s);return n.set(pt,i),i};class Li{spec;wrapped;prevProv;constructor(e,t,s){this.wrapped=e,this.spec=s,this.prevProv=t}shouldUpdate(e,t){return this.prevProv.key!==e.key||!r.qu.equal(this.spec,t)}}class nr extends Li{value(){return this.wrapped.value()}cleanup(){this.wrapped.cleanup?.()}onChange(e){return this.wrapped.onChange(e)}}class sr extends Li{set(...e){this.wrapped.set(...e)}cleanup(){this.wrapped.cleanup?.()}}const F=(n,e,t,s)=>{const i=fn(n);if(t instanceof nr){if(!t.shouldUpdate(i,e))return t;t.cleanup?.()}return new nr(i.create(e,s),i,e)},qe=(n,e,t,s)=>{const i=fn(n);if(t instanceof sr){if(!t.shouldUpdate(i,e))return t;t.cleanup?.()}return new sr(i.create(e,s),i,e)},ki=(n,e)=>n.dataType.isVariable||n.dataType.equals(r.f.UINT8)?n:(e==null&&n.dataType.equals(r.f.TIMESTAMP)&&(e=BigInt(n.data[0])),n.convert(r.f.FLOAT32,e)),Va=n=>n.isVariable||n.equals(r.f.UINT8)?n:r.f.FLOAT32,_i=()=>({purgedSeries:0,purgedBytes:r.p.bytes(0)}),Oi={instrumentation:g.g.NOOP,staleEntryThreshold:r.g.seconds(20)};class Xa{data=[];props;constructor(e){this.props={...Oi,...e}}write(e){e.length!==0&&(e.series.forEach(t=>this.writeOne(ki(t))),this.checkIntegrity(e))}dirtyRead(e){const t=this.data.filter(({data:o})=>o.timeRange.overlapsWith(e)).map(({data:o})=>o);if(t.length===0)return{series:new r.ju([]),gaps:[e]};const s=t.map((o,l)=>l===0?r.S.ZERO:new r.S(t[l-1].timeRange.end,o.timeRange.start)).filter(o=>!o.span.isZero&&o.isValid),i=new r.S(e.start,t[0].timeRange.start),a=new r.S(t[t.length-1].timeRange.end,e.end);return i.isValid&&!i.span.isZero&&s.unshift(i),a.isValid&&!a.span.isZero&&s.push(a),{series:new r.ju(t),gaps:s}}gc(){const{staleEntryThreshold:e}=this.props,t=_i(),s=this.data.filter(i=>{const a=i.data.refCount>0||r.d.since(i.addedAt).lessThan(e);return a||(t.purgedBytes=t.purgedBytes.add(i.data.byteCapacity)),a});return t.purgedSeries=this.data.length-s.length,this.data=s,t}close(){this.data=[]}writeOne(e){const{instrumentation:{L:t}}=this.props;if(e.length===0)return;const s=r.wu.buildInsertionPlan(this.data.map(u=>u.data.alignmentBounds),e.alignmentBounds);if(s===null)return t.debug("Found no viable insertion plan",{inserting:e.digest,cacheContents:this.data.map(u=>u.data.digest)});const{removeBefore:i,removeAfter:a,insertInto:o,deleteInBetween:l}=s;e=e.slice(i,e.data.length-a),e.length!==0&&this.data.splice(o,l,{data:e,addedAt:r.d.now()})}checkIntegrity(e){const{instrumentation:{L:t}}=this.props,s=this.data.map(a=>a.data.alignmentBounds);if(s.some((a,o)=>s.some((l,u)=>o===u?!1:r.wu.overlapsWith(a,l))))throw t.debug("Cache is in an invalid state - bounds overlap!",()=>({write:e.series.map(a=>a.digest),cacheContents:this.data.map(a=>a.data.digest)})),new Error("Invalid state")}}const Ga=100,Ka=1e6,Qa=1e4,Ja=100,el=40;class tl{props;counter=0;curr;avgRate=0;timeOfLastWrite;totalWrites=0;now=()=>r.d.now();constructor(e){this.props=e,this.curr=null,e.now!=null&&(this.now=e.now),this.timeOfLastWrite=this.now()}get length(){return this.curr?.length??0}get leadingBuffer(){return this.curr}write(e){const t=e.series.flatMap(s=>this._write(s));return{flushed:new r.ju(t.flatMap(s=>s.flushed.series)),allocated:new r.ju(t.flatMap(s=>s.allocated.series))}}allocate(e,t,s){this.counter++;const i=this.props.dataType.isVariable,a=this.props.dataType.equals(r.f.TIMESTAMP);return r.q.alloc({capacity:i?e*el:e,dataType:Va(this.props.dataType),timeRange:s.range(r.d.MAX),sampleOffset:a?s.valueOf():0,glBufferUsage:"dynamic",alignment:t,key:`dynamic-${this.counter}`})}_write(e){const t=this.nextBufferSize(),s={flushed:new r.ju([]),allocated:new r.ju([])};if(this.curr==null)this.curr=this.allocate(t,e.alignment,this.now()),s.allocated.push(this.curr);else if(Math.abs(Number(this.curr.alignment+BigInt(this.curr.length)-e.alignment))>1){const u=this.now();this.curr.timeRange.end=u,s.flushed.push(this.curr),this.curr=this.allocate(t,e.alignment,u),s.allocated.push(this.curr)}const i=ki(e,this.curr.sampleOffset),a=this.curr.write(i);if(a===e.length)return this.updateAvgRate(e),s;const o=this.now();this.curr.timeRange.end=o,s.flushed.push(this.curr),this.curr=this.allocate(t,e.alignment+BigInt(a),o),s.allocated.push(this.curr);const l=this._write(e.slice(a));return s.flushed.push(l.flushed),s.allocated.push(l.allocated),s}updateAvgRate(e){if(typeof this.props.dynamicBufferSize=="number")return;const t=e.length/this.now().span(this.timeOfLastWrite).seconds;this.totalWrites>0&&isFinite(t)&&t>0&&(this.avgRate=(this.avgRate*(this.totalWrites-1)+t)/this.totalWrites),this.totalWrites++,this.timeOfLastWrite=this.now()}nextBufferSize(){const{dynamicBufferSize:e}=this.props;if(typeof e=="number")return e;if(this.totalWrites<Ja)return Qa;const t=r.Ou.roundToNearestMagnitude(this.avgRate*e.seconds);return Math.round(Math.max(Math.min(t,Ka),Ga))}close(){this.curr=null}}class nl{channel;closed=!1;ins;static;dynamic;constructor(e){this.channel=e.channel,this.ins=e.instrumentation??g.g.NOOP,this.static=new Xa(e),this.dynamic=new tl({dynamicBufferSize:e.dynamicBufferSize,dataType:this.channel.dataType})}writeDynamic(e){if(this.closed)return this.ins.L.warn(`Ignoring attempted dynamic write to a closed cache for channel ${this.channel.name}`),new r.ju([]);const{flushed:t,allocated:s}=this.dynamic.write(e);return t.length>0&&this.static.write(t),s}get leadingBuffer(){return this.dynamic.leadingBuffer}writeStatic(e){if(this.closed)return this.ins.L.warn(`Ignoring attempted static write to a closed cache for channel ${this.channel.name}`);this.static.write(e)}read(e){return this.closed?(this.ins.L.warn(`Ignoring attempted dirty read from a closed cache for channel ${this.channel.name}`),{series:new r.ju([]),gaps:[e]}):this.static.dirtyRead(e)}gc(){return this.closed?(this.ins.L.warn(`Ignoring attempted garbage collection on a closed cache for channel ${this.channel.name}`),{purgedSeries:0,purgedBytes:r.p.bytes(0)}):this.static.gc()}close(){this.closed=!0,this.dynamic.close(),this.static.close()}}const sl=g.g$1.seconds(60);class rl{props;cache=new Map;gcInterval;constructor(e){this.props={dynamicBufferSize:sl,gcInterval:g.g$1.seconds(30),...Oi,...e},this.gcInterval=setInterval(()=>this.gc(),this.props.gcInterval.milliseconds)}async populateMissing(e){const{instrumentation:t,channelRetriever:s,dynamicBufferSize:i}=this.props,a=[];for(const l of e)this.cache.has(l)||a.push(l);if(a.length===0)return;(await s.retrieve(a)).forEach(l=>{if(this.cache.has(l.key))return;const u=new nl({channel:l,dynamicBufferSize:i,instrumentation:t.child(`cache-${l.name}-${l.key}`)});this.cache.set(l.key,u)})}get(e){const t=this.cache.get(e);if(t!=null)return t;throw new g.Ut(`cache entry for ${e} not found`)}gc(){const{instrumentation:{L:e}}=this.props;e.info("starting garbage collection");const t=_i();this.cache.forEach(s=>{const i=s.gc();t.purgedSeries+=i.purgedSeries,t.purgedBytes=t.purgedBytes.add(i.purgedBytes)}),e.info("garbage collection complete",{purgedSeries:t.purgedSeries,purgedBytes:t.purgedBytes.toString()},!0)}close(){clearInterval(this.gcInterval),this.cache.forEach(e=>e.close()),this.cache.clear()}}class il{args;debouncedRead;mu=r.il.newMutex({requests:new Set,closed:!1});constructor(e){this.args={...e,instrumentation:e.instrumentation??g.g.NOOP,batchDebounce:e.batchDebounce??r.g.milliseconds(50),overlapThreshold:e.overlapThreshold??r.g.milliseconds(5)};const t=this.args.batchDebounce.milliseconds;this.debouncedRead=r.Zu(()=>void this.batchRead(),t)}async read(e,t){const{cache:s}=this.args;await s.populateMissing([t]);const i=s.get(t),{series:a,gaps:o}=i.read(e);if(o.length===0)return a;const{mu:l}=this;return await new Promise((u,c)=>{l.runExclusive(async()=>{l.closed||l.requests.add({channel:t,gaps:o,resolve:u,reject:c})}),this.debouncedRead()}),i.read(e).series}async batchRead(){const{readRemote:e,cache:t,overlapThreshold:s}=this.args,{mu:i}=this;await i.runExclusive(async()=>{const a=o=>i.requests.forEach(({resolve:l,reject:u})=>o==null?l():u(o));try{if(i.closed)return a();const o=[];i.requests.forEach(({channel:l,gaps:u})=>u.forEach(c=>{const h=o.find(f=>f.gap.equals(c,s));h==null?o.push({gap:c,channels:new Set([l])}):(h.channels.add(l),h.gap=r.S.max(h.gap,c))})),await Promise.all(o.map(async({gap:l,channels:u})=>{const c=await e(l,Array.from(u));u.forEach(h=>t.get(h).writeStatic(c.get(h)))})),a()}catch(o){a(o)}finally{i.requests.clear()}})}async close(){await this.mu.runExclusive(async()=>{this.mu.closed=!0})}}const ol=new Error("request for lock canceled");var al=function(n,e,t,s){function i(a){return a instanceof t?a:new t(function(o){o(a)})}return new(t||(t=Promise))(function(a,o){function l(h){try{c(s.next(h))}catch(f){o(f)}}function u(h){try{c(s.throw(h))}catch(f){o(f)}}function c(h){h.done?a(h.value):i(h.value).then(l,u)}c((s=s.apply(n,e||[])).next())})};class ll{constructor(e,t=ol){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,i)=>{const a={resolve:s,reject:i,weight:e,priority:t},o=Ai(this._queue,l=>t<=l.priority);o===-1&&e<=this._value?this._dispatchItem(a):this._queue.splice(o+1,0,a)})}runExclusive(e){return al(this,arguments,void 0,function*(t,s=1,i=0){const[a,o]=yield this.acquire(s,i);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]=[]),cl(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 i=s.findIndex(a=>a.priority<=e);(i===-1?s:s.splice(0,i)).forEach((a=>a.resolve()))}}}_couldLockImmediately(e,t){return(this._queue.length===0||this._queue[0].priority<t)&&e<=this._value}}function cl(n,e){const t=Ai(n,s=>e.priority<=s.priority);n.splice(t+1,0,e)}function Ai(n,e){for(let t=n.length-1;t>=0;t--)if(e(n[t]))return t;return-1}var ul=function(n,e,t,s){function i(a){return a instanceof t?a:new t(function(o){o(a)})}return new(t||(t=Promise))(function(a,o){function l(h){try{c(s.next(h))}catch(f){o(f)}}function u(h){try{c(s.throw(h))}catch(f){o(f)}}function c(h){h.done?a(h.value):i(h.value).then(l,u)}c((s=s.apply(n,e||[])).next())})};class hl{constructor(e){this._semaphore=new ll(1,e)}acquire(){return ul(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 dl=r.g.milliseconds(100).milliseconds,fl=r.$.hz(60).valueOf();class pl{props;mu=new hl;listeners=new Map;debouncedUpdateStreamer;streamerRunLoop=null;streamer=null;closed=!1;constructor(e){this.props={instrumentation:g.g.NOOP,...e,streamUpdateDelay:new r.g(e.streamUpdateDelay??r.g.seconds(5))},this.debouncedUpdateStreamer=r.Zu(()=>void this.updateStreamer(),dl)}async stream(e,t){const{cache:s,instrumentation:i}=this.props;return this.closed?()=>{}:(await s.populateMissing(t),await this.mu.runExclusive(async()=>{i.L.debug("adding stream handler",{keys:t}),this.listeners.set(e,{valid:!0,keys:new Set(t)});const a=new Map(t.map(o=>{const l=s.get(o);return[o,new r.ju(r.lu.toArray(l.leadingBuffer))]}));return e(a),this.debouncedUpdateStreamer(),()=>this.removeStreamHandler(e)}))}removeStreamHandler(e){const{instrumentation:t}=this.props;this.mu.runExclusive(()=>{const s=this.listeners.get(e);s!=null&&(s.valid=!1)}),setTimeout(()=>{this.mu.runExclusive(async()=>{if(t.L.debug("removing stream handler"),this.listeners.delete(e))return this.debouncedUpdateStreamer();t.L.warn("attempted to remove non-existent stream handler")})},this.props.streamUpdateDelay.milliseconds)}async updateStreamer(){if(this.closed)return;const{instrumentation:e}=this.props;try{const t=new Set;if(this.listeners.forEach(a=>a.keys.forEach(o=>t.add(o))),t.size===0){e.L.info("no keys to stream, closing streamer"),this.streamer?.close(),this.streamerRunLoop!=null&&await this.streamerRunLoop,this.streamer=null,e.L.info("streamer closed successfully");return}const s=Array.from(t);if(r.mu.primitiveArrays(s,this.streamer?.keys??[])===r.mu.EQUAL){e.L.debug("streamer keys unchanged",{keys:s});return}this.streamer==null&&(e.L.info("creating new streamer",{keys:s}),this.streamer=await this.props.openStreamer({channels:s,throttleRate:fl}),this.streamerRunLoop=this.runStreamer(this.streamer)),e.L.debug("updating streamer",{prev:this.streamer.keys,next:s}),await this.streamer.update(s)}catch(t){throw e.L.error("failed to update streamer",{error:t}),t}}async runStreamer(e){const{cache:t,instrumentation:s}=this.props;try{for await(const i of e){const a=new Map;for(const o of i.keys){const l=i.get(o),c=t.get(o).writeDynamic(l);a.set(o,c)}a.size!==0&&this.listeners.forEach(({valid:o},l)=>o&&l(a))}}catch(i){throw s.L.error("streamer run loop failed",{error:i},!0),i}}async close(){const{instrumentation:e}=this.props;try{this.streamer?.close(),this.streamerRunLoop!=null&&await this.streamerRunLoop}catch(t){e.L.error("failed to close streamer",{error:t})}this.closed=!0}}class gl{async retrieveChannel(){throw new g.An("NoopClient does not support retrieving channels")}async read(){return new r.ju([])}async stream(){return async()=>{}}async close(){}}class ml{ins;cache;reader;streamer;channelRetriever;constructor({instrumentation:e,core:t}){this.ins=e,this.channelRetriever=t.channels.createDebouncedBatchRetriever(10),this.cache=new rl({channelRetriever:this.channelRetriever,instrumentation:this.ins.child("cache")}),this.reader=new il({cache:this.cache,readRemote:t.read.bind(t),instrumentation:this.ins.child("reader")}),this.streamer=new pl({cache:this.cache,openStreamer:async s=>g.Hk.HardenedStreamer.open(t.openStreamer.bind(t),s),instrumentation:this.ins.child("streamer")})}async retrieveChannel(e){const t=await this.channelRetriever.retrieve([e]);if(t.length===0)throw new g.rt(`channel ${e} not found`);return t[0]}async read(e,t){return await this.reader.read(e,t)}async stream(e,t){return await this.streamer.stream(e,t)}async close(){this.ins.L.info("closing client"),await this.streamer.close(),await this.reader.close(),this.cache.close()}}const ks=d.z.object({});class Ye extends g.Composite{static TYPE="telem.Provider";static stateZ=ks;schema=Ye.stateZ;prevCore=null;client=null;afterUpdate(e){const{internal:t}=this,s=$e(e),i=g.useErrorHandler(e);if(t.instrumentation=M.useInstrumentation(e,"telem").child("provider"),!(s!==this.prevCore||!e.wasSetPreviously(pt)))return;this.prevCore=s,this.client!=null&&i(async()=>{if(this.client==null)throw new Error("no client to close");await this.client.close()},"failed to close client"),this.client=s==null?new gl:new ml({core:s,instrumentation:t.instrumentation});const o=Ei(this.client),l=new Ci(o);Ri(e,l)}}const Ii={[Ye.TYPE]:Ye},yl=Object.freeze(Object.defineProperty({__proto__:null,AbstractSink:dn,AbstractSource:j,Base:hn,BaseProvider:Ye,BooleanStatus:Ae,CONTEXT_KEY:pt,ChannelData:Mt,ColorGradient:Me,CompoundTelemFactory:Ls,Context:Ci,FixedColorSource:Ut,FixedNumber:zt,FixedString:Zt,IterativeSeries:Yt,Mean:Oe,MultiSourceTransformer:Qr,NoopFactory:jr,PipelineFactory:ws,REGISTRY:Ii,RemoteFactory:si,RollingAverage:Bt,ScaleNumber:De,SeriesDownsampler:nt,SetPoint:ke,SinkPipeline:At,SourcePipeline:Ot,StaticFactory:ai,StreamChannelData:Dt,StreamChannelValue:It,StringifyNumber:Ie,TransformerFactory:di,UnarySinkTransformer:Jr,UnarySourceTransformer:ve,WithinBounds:_e,booleanSinkSpecZ:ln,booleanSinkTransformerSpecZ:ka,booleanSourceSpecZ:ys,booleanSourceTransformerSpecZ:_a,booleanStatus:Fa,booleanStatusProps:mi,channelData:ri,colorGradient:Si,colorGradientProps:bi,colorSourceSpecZ:cn,connectionZ:bs,createFactory:Ei,downsampleMode:qa,downsampleModeProps:$a,downsampleModeZ:Ns,fixedArray:Ma,fixedColor:Za,fixedColorSourcePropsZ:hi,fixedNumber:Ya,fixedNumberPropsZ:ci,fixedSeriesPropsZ:Es,fixedString:za,fixedStringPropsZ:ui,iterativeArray:Da,iterativeSeriesPropsZ:li,mean:Ba,noopBooleanSinkSpec:an,noopBooleanSourceSpec:ps,noopColorSourceSpec:ht,noopNumericSinkSpec:Fr,noopNumericSourceSpec:$r,noopSeriesSourceSpec:Hr,noopStatusSourceSpec:ms,noopStringSinkSpec:qr,noopStringSourceSpec:gs,numberSinkSpecZ:Gr,numberSourceSpecZ:Xr,providerStateZ:ks,rollingAverage:vi,rollingAverageProps:Rs,scaleNumber:Ti,scaleNumberProps:wi,seriesDownsampler:Wa,seriesSourceSpecZ:_t,setContext:Ri,setpoint:fi,sinkPipeline:ti,sinkPipelinePropsZ:Ts,sinkSpecZ:ft,sinkTransformerSpecZ:Vr,sourcePipeline:ei,sourcePipelinePropsZ:Ss,sourceSpecZ:ce,sourceTransformerSpecZ:Wr,specZ:dt,statusSourceSpecZ:vs,streamChannelData:ii,streamChannelValue:oi,streamChannelValuePropsZ:xs,stringSinkSpecZ:Kr,stringSourceSpecZ:un,stringifyNumber:yi,stringifyNumberProps:Ps,useChildContext:Ni,useContext:fn,useSink:qe,useSource:F,withinBounds:pi,withinBoundsProps:Cs},Symbol.toStringTag,{value:"Module"})),rr=`#version 300 es
|
|
3
|
+
precision lowp float;
|
|
4
|
+
|
|
5
|
+
uniform lowp vec4 u_color;
|
|
6
|
+
out vec4 fragColor;
|
|
7
|
+
|
|
8
|
+
void main(void) {
|
|
9
|
+
fragColor = u_color;
|
|
10
|
+
}
|
|
11
|
+
`,vl=`#version 300 es
|
|
12
|
+
|
|
13
|
+
// Copyright 2025 Synnax Labs, Inc.
|
|
14
|
+
//
|
|
15
|
+
// Use of this software is governed by the Business Source License included in the file
|
|
16
|
+
// licenses/BSL.txt.
|
|
17
|
+
//
|
|
18
|
+
// As of the Change Date specified in that file, in accordance with the Business Source
|
|
19
|
+
// License, use of this software will be governed by the Apache License, Version 2.0,
|
|
20
|
+
// included in the file licenses/APL.txt.
|
|
21
|
+
|
|
22
|
+
in mediump float a_x;
|
|
23
|
+
in mediump float a_y;
|
|
24
|
+
in mediump vec2 a_translate;
|
|
25
|
+
|
|
26
|
+
uniform mediump vec2 u_scale_aggregate;
|
|
27
|
+
uniform mediump vec2 u_offset_aggregate;
|
|
28
|
+
|
|
29
|
+
void main(void) {
|
|
30
|
+
gl_Position = vec4((u_scale_aggregate * vec2(a_x, a_y) + u_offset_aggregate) + a_translate, 0.0, 1.0);
|
|
31
|
+
}
|
|
32
|
+
`,bl=`#version 300 es
|
|
33
|
+
|
|
34
|
+
// Copyright 2025 Synnax Labs, Inc.
|
|
35
|
+
//
|
|
36
|
+
// Use of this software is governed by the Business Source License included in the file
|
|
37
|
+
// licenses/BSL.txt.
|
|
38
|
+
//
|
|
39
|
+
// As of the Change Date specified in that file, in accordance with the Business Source
|
|
40
|
+
// License, use of this software will be governed by the Apache License, Version 2.0,
|
|
41
|
+
// included in the file licenses/APL.txt.
|
|
42
|
+
|
|
43
|
+
in mediump float a_x;
|
|
44
|
+
in mediump uint a_y;
|
|
45
|
+
in mediump vec2 a_translate;
|
|
46
|
+
|
|
47
|
+
uniform mediump vec2 u_scale_aggregate;
|
|
48
|
+
uniform mediump vec2 u_offset_aggregate;
|
|
49
|
+
|
|
50
|
+
void main(void) {
|
|
51
|
+
gl_Position = vec4((u_scale_aggregate * vec2(a_x, float(a_y)) + u_offset_aggregate) + a_translate, 0.0, 1.0);
|
|
52
|
+
}
|
|
53
|
+
`,Mi=d.z.object({x:_t,y:_t,label:d.z.string().optional(),color:r.Pu.colorZ,strokeWidth:d.z.number().default(1),downsample:d.z.number().min(1).max(50).default(1),downsampleMode:Ns.default("decimate"),visible:d.z.boolean().default(!0)}),Sl=(n,e,t)=>n===-1||e===-1||n>=t.series.length?NaN:Number(t.series[n].at(e)),wl=r.g.milliseconds(2);r.Nu.NAN,r.Nu.NAN,r.Pu.ZERO,r.wu.ZERO;const Tl=(n,e)=>e.equals(r.f.UINT8)?n.UNSIGNED_BYTE:n.FLOAT;class ir extends M.GLProgram{translationBufferCache=new Map;constructor(e,t,s){super(e,t,s),this.translationBufferCache=new Map}bindState({strokeWidth:e,color:t}){return this.uniformColor("u_color",t),this.attrStrokeWidth(e)}bindScale(e,t){const s=r.Nu.scale(e.scale,t.scale),i=r.Nu.translate(r.Nu.scale(t.scale,e.offset),t.offset);this.uniformXY("u_scale_aggregate",s),this.uniformXY("u_offset_aggregate",i)}draw({x:e,y:t,count:s,downsample:i,xOffset:a,yOffset:o},l,u,c){const{gl:h}=this.renderCtx;this.bindAttrBuffer("x",e.glBuffer,i,a,u),this.bindAttrBuffer("y",t.glBuffer,i,o,c),h.drawArraysInstanced(h.LINE_STRIP,0,s/i,l)}bindAttrBuffer(e,t,s,i=0,a){const{gl:o}=this.renderCtx;o.bindBuffer(o.ARRAY_BUFFER,t);const l=o.getAttribLocation(this.prog,`a_${e}`),u=Tl(o,a),c=a.density.valueOf();a.equals(r.f.UINT8)?o.vertexAttribIPointer(l,1,u,c*s,c*i):o.vertexAttribPointer(l,1,u,!1,c*s,c*i),o.enableVertexAttribArray(l)}getAndBindTranslationBuffer(e){const{gl:t}=this.renderCtx,s=`${this.renderCtx.aspect}:${e}`,i=this.translationBufferCache.get(s);if(i!=null)return t.bindBuffer(t.ARRAY_BUFFER,i.glBuffer),i;const a=t.createBuffer();if(a==null)throw new g.Ut("Failed to create buffer from WebGL context");const o=El(this.renderCtx.aspect,e);t.bindBuffer(t.ARRAY_BUFFER,a),t.bufferData(t.ARRAY_BUFFER,o,t.DYNAMIC_DRAW);const l={glBuffer:a,jsBuffer:o};return this.translationBufferCache.set(s,l),l}attrStrokeWidth(e){const{gl:t}=this.renderCtx,{jsBuffer:s}=this.getAndBindTranslationBuffer(e),i=t.getAttribLocation(this.prog,"a_translate");return t.vertexAttribPointer(i,2,t.FLOAT,!1,0,0),t.enableVertexAttribArray(i),t.vertexAttribDivisor(i,1),s.length/2}}class Ne{static CONTEXT_KEY="pluto-line-gl-program";uint8HybridProgram;float32Program;constructor(e){this.uint8HybridProgram=new ir(e,bl,rr),this.float32Program=new ir(e,vl,rr)}get gl(){return this.uint8HybridProgram.renderCtx.gl}getProgram(e){return e.equals(r.f.UINT8)?this.uint8HybridProgram:this.float32Program}static create(e,t){const s=new Ne(t);return e.set(Ne.CONTEXT_KEY,s),s}static use(e){const t=e.get(Ne.CONTEXT_KEY);if(t==null)throw new g.Ut("GLProgram not found");return t}}class Ft extends g.Leaf{static TYPE="line";schema=Mi;afterUpdate(e){const{internal:t}=this,s={onStatusChange:g.useAdder(e)};t.xTelem=F(e,this.state.x,t.xTelem,s),t.yTelem=F(e,this.state.y,t.yTelem,s),t.instrumentation=M.useInstrumentation(e,"line"),t.lineCtx=Ne.use(e),t.requestRender=rn(e),t.stopListeningXTelem?.(),t.stopListeningYTelem?.(),t.stopListeningXTelem=t.xTelem.onChange(()=>t.requestRender("data")),t.stopListeningYTelem=t.yTelem.onChange(()=>t.requestRender("data")),t.requestRender("layout"),(t.xDownsampler?.props.mode!==this.state.downsampleMode||t.xDownsampler?.props.windowSize!==this.state.downsample)&&(t.xDownsampler=new nt({mode:this.state.downsampleMode,windowSize:this.state.downsample}),t.yDownsampler=new nt({mode:this.state.downsampleMode,windowSize:this.state.downsample}))}afterDelete(){const{internal:e}=this;e.xTelem.cleanup?.(),e.yTelem.cleanup?.(),e.requestRender("layout")}xBounds(){return this.internal.xTelem.value()[0]}yBounds(){return this.internal.yTelem.value()[0]}findByXValue(e,t){const{xTelem:s,yTelem:i}=this.internal;let[,a]=s.value();a=this.internal.xDownsampler.transform(a);let[o,l]=[-1,-1];a.series.find((w,E)=>{const R=w.binarySearch(t),C=R>=0&&R<w.length;return C&&([o,l]=[R,E]),C});const{key:u}=this,{color:c,label:h}=this.state,f={key:u,color:c,label:h,position:{x:0,y:0},value:{x:NaN,y:NaN},bounds:{lower:0,upper:0}};if(o===-1||l===-1||!this.state.visible)return f;const p=a.series[l];f.value.x=Sl(l,o,a);let[,y]=i.value();y=this.internal.yDownsampler.transform(y);const b=y.series.find(w=>r.wu.contains(w.alignmentBounds,p.alignment+BigInt(o)));if(b==null)return f;const v=Number(b.alignment-p.alignment);return f.value.y=Number(b.at(o-v)),f.bounds={...b.bounds},f.position={x:e.dataToDecimalScale.x.pos(f.value.x),y:e.dataToDecimalScale.y.pos(f.value.y)},f}render(e){if(this.deleted||!this.state.visible)return;const{downsample:t}=this.state,{xTelem:s,yTelem:i,lineCtx:a,xDownsampler:o,yDownsampler:l}=this.internal,{dataToDecimalScale:u,exposure:c}=e;let[[,h],[,f]]=[s.value(),i.value()];if(h=o.transform(h),f=l.transform(f),h.updateGLBuffer(a.gl),f.updateGLBuffer(a.gl),h.length===0||f.length===0)return;const p=a.getProgram(f.dataType),y=kl(h,f,c,t,this.state.downsampleMode,wl);this.internal.instrumentation.L.debug("render",()=>({key:this.key,downsample:t,scale:u.transform,props:e.region,ops:_l(y)}));const b=p.setAsActive(),v=p.bindState(this.state),w=p.renderCtx.scaleRegion(e.region).transform;y.forEach(E=>{const R=Nl(u,E).transform;p.bindScale(R,w),p.draw(E,v,h.dataType,f.dataType)}),b()}}const xl=5e3,El=(n,e)=>Rl(Pl(n),e).map((t,s)=>Math.floor(s/Cl)*(1/(xl*n))*t),Cl=5,Pl=n=>new Float32Array([0,0,0,n,0,-n,1,0,-1,0]),Rl=(n,e)=>{const t=new Float32Array(n.length*e);for(let s=0;s<e;s++)t.set(n,s*n.length);return t},Nl=(n,e)=>n.translate(n.x.dim(Number(e.x.sampleOffset)),n.y.dim(Number(e.y.sampleOffset))),Ll={[Ft.TYPE]:Ft},kl=(n,e,t,s,i,a)=>{if(n.series.length===0||e.series.length===0)return[];const o=[];return n.series.forEach(l=>e.series.forEach(u=>{if(!Ol(l,u,a))return;let c=0n,h=0n;l.alignment<u.alignment?c=u.alignment-l.alignment:u.alignment<l.alignment&&(h=l.alignment-u.alignment);const f=r.Ou.min(r.wu.span(l.alignmentBounds)-c,r.wu.span(u.alignmentBounds)-h);if(f===0n)return;let p=r.Io(Math.round(t*4*Number(f)),s,51);i!=="decimate"&&(p=1);const y=Number(f/l.alignmentMultiple),b=Number(c/l.alignmentMultiple),v=Number(h/u.alignmentMultiple);o.push({x:l,y:u,xOffset:b,yOffset:v,count:y,downsample:p})})),o},_l=n=>n.map(e=>({...e,x:e.x.digest,y:e.y.digest})),Ol=(n,e,t)=>{if(n.alignmentMultiple!==e.alignmentMultiple)return console.warn("encountered two series with different alignment multiples in draw operations",{x:n.digest,y:e.digest}),!1;const s=n.timeRange.overlapsWith(e.timeRange,t),i=r.wu.overlapsWith(n.alignmentBounds,e.alignmentBounds);return s&&i},_s=d.z.object({dpr:d.z.number(),region:r.vu.box,bootstrap:d.z.boolean().default(!1),bootstrapped:d.z.boolean().default(!1),glCanvas:d.z.any().optional(),upper2dCanvas:d.z.any().optional(),lower2dCanvas:d.z.any().optional(),os:r.tl.osZ});class $t extends g.Composite{static TYPE="Canvas";schema=_s;renderCtx=null;afterUpdate(e){if(this.renderCtx==null){if(!this.state.bootstrap)return;const{glCanvas:t,lower2dCanvas:s,upper2dCanvas:i,os:a}=this.state;if(t==null||s==null||i==null)throw new g.Ut("[vis.worker.Canvas] - expected render context bootstrap to include all canvases");this.renderCtx=M.Context.create(e,t,s,i,a),Ne.create(e,this.renderCtx),this.setState(o=>({...o,bootstrap:!1,bootstrapped:!0,glCanvas:void 0,lower2dCanvas:void 0,upper2dCanvas:void 0}))}else this.renderCtx.update(e);this.renderCtx.resize(this.state.region,this.state.dpr)}}const Di={[$t.TYPE]:$t},Al=Object.freeze(Object.defineProperty({__proto__:null,Canvas:$t,REGISTRY:Di,canvasStateZ:_s},Symbol.toStringTag,{value:"Module"})),Os=d.z.object({position:r.Nu.xy,zoom:d.z.number(),region:r.vu.box,clearOverScan:r.Nu.crudeZ.default(5),visible:d.z.boolean().default(!0),autoRenderInterval:d.z.number().optional()}),wt=["upper2d","lower2d"];class me extends g.Composite{static TYPE="Diagram";static stateZ=Os;schema=me.stateZ;afterUpdate(e){this.internal.renderCtx=M.Context.use(e),this.internal.handleError=g.useErrorHandler(e),r.gu.isNonZero(this.state.autoRenderInterval)&&(this.internal.autoRenderInterval??=setInterval(()=>{this.state.visible&&this.requestRender("low")},this.state.autoRenderInterval)),sn(e,()=>{this.state.visible&&this.requestRender("low")}),!(!this.state.visible&&!this.prevState.visible)&&(this.internal.viewportScale=r.Au.XY.magnify(r.Nu.construct(this.state.zoom)).translate(r.vu.topLeft(this.state.region)).translate(this.state.position),this.requestRender("high"))}afterDelete(){this.internal.autoRenderInterval!=null&&clearInterval(this.internal.autoRenderInterval),this.requestRender("high")}render(){if(this.deleted)return;const{renderCtx:e,handleError:t,viewportScale:s}=this.internal,i=r.vu.construct(this.state.region);if(!this.state.visible)return()=>e.erase(i,this.state.clearOverScan,...wt);const a=e.scissor(i,r.Nu.ZERO,wt);try{this.children.forEach(l=>l.render?.({viewportScale:s}))}catch(l){t(l,"failed to render diagram")}finally{a()}const o=r.vu.copy(this.state.region);return()=>{e.lower2d.fillStyle=r.Pu.hex(r.Pu.BLACK),e.lower2d.fillRect(...r.Nu.couple(r.vu.topLeft(o)),r.vu.width(o),r.vu.height(o)),e.erase(o,this.state.clearOverScan,...wt)}}requestRender(e){const{renderCtx:t}=this.internal;t.loop.set({key:`${me.TYPE}-${this.key}`,render:this.render.bind(this),priority:e,canvases:wt})}}const Yi={[me.TYPE]:me},Il=Object.freeze(Object.defineProperty({__proto__:null,Diagram:me,REGISTRY:Yi,diagramStateZ:Os},Symbol.toStringTag,{value:"Module"})),Ml=d.object({request:d.string(),bounds:d.record(d.string(),r.wu.bounds)}),zi=d.object({request:d.string(),response:Ml});class qt extends g.Leaf{static TYPE="Bounds";schema=zi;afterUpdate(e){this.state.request!==this.prevState.request&&this.setState(t=>({...t,response:{request:t.request,bounds:this.internal.getBounds()}}))}render(e){this.internal.getBounds=e.getBounds}}function Rt(n,e){return n==null||e==null?NaN:n<e?-1:n>e?1:n>=e?0:NaN}function Dl(n,e){return n==null||e==null?NaN:e<n?-1:e>n?1:e>=n?0:NaN}function As(n){let e,t,s;n.length!==2?(e=Rt,t=(l,u)=>Rt(n(l),u),s=(l,u)=>n(l)-u):(e=n===Rt||n===Dl?n:Yl,t=n,s=n);function i(l,u,c=0,h=l.length){if(c<h){if(e(u,u)!==0)return h;do{const f=c+h>>>1;t(l[f],u)<0?c=f+1:h=f}while(c<h)}return c}function a(l,u,c=0,h=l.length){if(c<h){if(e(u,u)!==0)return h;do{const f=c+h>>>1;t(l[f],u)<=0?c=f+1:h=f}while(c<h)}return c}function o(l,u,c=0,h=l.length){const f=i(l,u,c,h-1);return f>c&&s(l[f-1],u)>-s(l[f],u)?f-1:f}return{left:i,center:o,right:a}}function Yl(){return 0}function zl(n){return n===null?NaN:+n}const Zl=As(Rt),Ul=Zl.right;As(zl).center;const Bl=Math.sqrt(50),Fl=Math.sqrt(10),$l=Math.sqrt(2);function Ht(n,e,t){const s=(e-n)/Math.max(0,t),i=Math.floor(Math.log10(s)),a=s/Math.pow(10,i),o=a>=Bl?10:a>=Fl?5:a>=$l?2:1;let l,u,c;return i<0?(c=Math.pow(10,-i)/o,l=Math.round(n*c),u=Math.round(e*c),l/c<n&&++l,u/c>e&&--u,c=-c):(c=Math.pow(10,i)*o,l=Math.round(n/c),u=Math.round(e/c),l*c<n&&++l,u*c>e&&--u),u<l&&.5<=t&&t<2?Ht(n,e,t*2):[l,u,c]}function ql(n,e,t){if(e=+e,n=+n,t=+t,!(t>0))return[];if(n===e)return[n];const s=e<n,[i,a,o]=s?Ht(e,n,t):Ht(n,e,t);if(!(a>=i))return[];const l=a-i+1,u=new Array(l);if(s)if(o<0)for(let c=0;c<l;++c)u[c]=(a-c)/-o;else for(let c=0;c<l;++c)u[c]=(a-c)*o;else if(o<0)for(let c=0;c<l;++c)u[c]=(i+c)/-o;else for(let c=0;c<l;++c)u[c]=(i+c)*o;return u}function jn(n,e,t){return e=+e,n=+n,t=+t,Ht(n,e,t)[2]}function Wn(n,e,t){e=+e,n=+n,t=+t;const s=e<n,i=s?jn(e,n,t):jn(n,e,t);return(s?-1:1)*(i<0?1/-i:i)}function Zi(n,e){switch(arguments.length){case 0:break;case 1:this.range(n);break;default:this.range(e).domain(n);break}return this}function Hl(n){return function(){return n}}function jl(n){return+n}var or=[0,1];function Ce(n){return n}function Vn(n,e){return(e-=n=+n)?function(t){return(t-n)/e}:Hl(isNaN(e)?NaN:.5)}function Wl(n,e){var t;return n>e&&(t=n,n=e,e=t),function(s){return Math.max(n,Math.min(e,s))}}function Vl(n,e,t){var s=n[0],i=n[1],a=e[0],o=e[1];return i<s?(s=Vn(i,s),a=t(o,a)):(s=Vn(s,i),a=t(a,o)),function(l){return a(s(l))}}function Xl(n,e,t){var s=Math.min(n.length,e.length)-1,i=new Array(s),a=new Array(s),o=-1;for(n[s]<n[0]&&(n=n.slice().reverse(),e=e.slice().reverse());++o<s;)i[o]=Vn(n[o],n[o+1]),a[o]=t(e[o],e[o+1]);return function(l){var u=Ul(n,l,1,s)-1;return a[u](i[u](l))}}function Ui(n,e){return e.domain(n.domain()).range(n.range()).interpolate(n.interpolate()).clamp(n.clamp()).unknown(n.unknown())}function Gl(){var n=or,e=or,t=on,s,i,a,o=Ce,l,u,c;function h(){var p=Math.min(n.length,e.length);return o!==Ce&&(o=Wl(n[0],n[p-1])),l=p>2?Xl:Vl,u=c=null,f}function f(p){return p==null||isNaN(p=+p)?a:(u||(u=l(n.map(s),e,t)))(s(o(p)))}return f.invert=function(p){return o(i((c||(c=l(e,n.map(s),tt)))(p)))},f.domain=function(p){return arguments.length?(n=Array.from(p,jl),h()):n.slice()},f.range=function(p){return arguments.length?(e=Array.from(p),h()):e.slice()},f.rangeRound=function(p){return e=Array.from(p),t=Ra,h()},f.clamp=function(p){return arguments.length?(o=p?!0:Ce,h()):o!==Ce},f.interpolate=function(p){return arguments.length?(t=p,h()):t},f.unknown=function(p){return arguments.length?(a=p,f):a},function(p,y){return s=p,i=y,h()}}function Bi(){return Gl()(Ce,Ce)}function Kl(n){return Math.abs(n=Math.round(n))>=1e21?n.toLocaleString("en").replace(/,/g,""):n.toString(10)}function jt(n,e){if((t=(n=e?n.toExponential(e-1):n.toExponential()).indexOf("e"))<0)return null;var t,s=n.slice(0,t);return[s.length>1?s[0]+s.slice(2):s,+n.slice(t+1)]}function ze(n){return n=jt(Math.abs(n)),n?n[1]:NaN}function Ql(n,e){return function(t,s){for(var i=t.length,a=[],o=0,l=n[0],u=0;i>0&&l>0&&(u+l+1>s&&(l=Math.max(1,s-u)),a.push(t.substring(i-=l,i+l)),!((u+=l+1)>s));)l=n[o=(o+1)%n.length];return a.reverse().join(e)}}function Jl(n){return function(e){return e.replace(/[0-9]/g,function(t){return n[+t]})}}var ec=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Wt(n){if(!(e=ec.exec(n)))throw new Error("invalid format: "+n);var e;return new Is({fill:e[1],align:e[2],sign:e[3],symbol:e[4],zero:e[5],width:e[6],comma:e[7],precision:e[8]&&e[8].slice(1),trim:e[9],type:e[10]})}Wt.prototype=Is.prototype;function Is(n){this.fill=n.fill===void 0?" ":n.fill+"",this.align=n.align===void 0?">":n.align+"",this.sign=n.sign===void 0?"-":n.sign+"",this.symbol=n.symbol===void 0?"":n.symbol+"",this.zero=!!n.zero,this.width=n.width===void 0?void 0:+n.width,this.comma=!!n.comma,this.precision=n.precision===void 0?void 0:+n.precision,this.trim=!!n.trim,this.type=n.type===void 0?"":n.type+""}Is.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function tc(n){e:for(var e=n.length,t=1,s=-1,i;t<e;++t)switch(n[t]){case".":s=i=t;break;case"0":s===0&&(s=t),i=t;break;default:if(!+n[t])break e;s>0&&(s=0);break}return s>0?n.slice(0,s)+n.slice(i+1):n}var Fi;function nc(n,e){var t=jt(n,e);if(!t)return n+"";var s=t[0],i=t[1],a=i-(Fi=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,o=s.length;return a===o?s:a>o?s+new Array(a-o+1).join("0"):a>0?s.slice(0,a)+"."+s.slice(a):"0."+new Array(1-a).join("0")+jt(n,Math.max(0,e+a-1))[0]}function ar(n,e){var t=jt(n,e);if(!t)return n+"";var s=t[0],i=t[1];return i<0?"0."+new Array(-i).join("0")+s:s.length>i+1?s.slice(0,i+1)+"."+s.slice(i+1):s+new Array(i-s.length+2).join("0")}const lr={"%":(n,e)=>(n*100).toFixed(e),b:n=>Math.round(n).toString(2),c:n=>n+"",d:Kl,e:(n,e)=>n.toExponential(e),f:(n,e)=>n.toFixed(e),g:(n,e)=>n.toPrecision(e),o:n=>Math.round(n).toString(8),p:(n,e)=>ar(n*100,e),r:ar,s:nc,X:n=>Math.round(n).toString(16).toUpperCase(),x:n=>Math.round(n).toString(16)};function cr(n){return n}var ur=Array.prototype.map,hr=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function sc(n){var e=n.grouping===void 0||n.thousands===void 0?cr:Ql(ur.call(n.grouping,Number),n.thousands+""),t=n.currency===void 0?"":n.currency[0]+"",s=n.currency===void 0?"":n.currency[1]+"",i=n.decimal===void 0?".":n.decimal+"",a=n.numerals===void 0?cr:Jl(ur.call(n.numerals,String)),o=n.percent===void 0?"%":n.percent+"",l=n.minus===void 0?"−":n.minus+"",u=n.nan===void 0?"NaN":n.nan+"";function c(f){f=Wt(f);var p=f.fill,y=f.align,b=f.sign,v=f.symbol,w=f.zero,E=f.width,R=f.comma,C=f.precision,N=f.trim,O=f.type;O==="n"?(R=!0,O="g"):lr[O]||(C===void 0&&(C=12),N=!0,O="g"),(w||p==="0"&&y==="=")&&(w=!0,p="0",y="=");var T=v==="$"?t:v==="#"&&/[boxX]/.test(O)?"0"+O.toLowerCase():"",_=v==="$"?s:/[%p]/.test(O)?o:"",I=lr[O],G=/[defgprs%]/.test(O);C=C===void 0?6:/[gprs]/.test(O)?Math.max(1,Math.min(21,C)):Math.max(0,Math.min(20,C));function W(x){var $=T,Y=_,K,ue,te;if(O==="c")Y=I(x)+Y,x="";else{x=+x;var ne=x<0||1/x<0;if(x=isNaN(x)?u:I(Math.abs(x),C),N&&(x=tc(x)),ne&&+x==0&&b!=="+"&&(ne=!1),$=(ne?b==="("?b:l:b==="-"||b==="("?"":b)+$,Y=(O==="s"?hr[8+Fi/3]:"")+Y+(ne&&b==="("?")":""),G){for(K=-1,ue=x.length;++K<ue;)if(te=x.charCodeAt(K),48>te||te>57){Y=(te===46?i+x.slice(K+1):x.slice(K))+Y,x=x.slice(0,K);break}}}R&&!w&&(x=e(x,1/0));var Q=$.length+x.length+Y.length,Z=Q<E?new Array(E-Q+1).join(p):"";switch(R&&w&&(x=e(Z+x,Z.length?E-Y.length:1/0),Z=""),y){case"<":x=$+x+Y+Z;break;case"=":x=$+Z+x+Y;break;case"^":x=Z.slice(0,Q=Z.length>>1)+$+x+Y+Z.slice(Q);break;default:x=Z+$+x+Y;break}return a(x)}return W.toString=function(){return f+""},W}function h(f,p){var y=c((f=Wt(f),f.type="f",f)),b=Math.max(-8,Math.min(8,Math.floor(ze(p)/3)))*3,v=Math.pow(10,-b),w=hr[8+b/3];return function(E){return y(v*E)+w}}return{format:c,formatPrefix:h}}var Tt,$i,qi;rc({thousands:",",grouping:[3],currency:["$",""]});function rc(n){return Tt=sc(n),$i=Tt.format,qi=Tt.formatPrefix,Tt}function ic(n){return Math.max(0,-ze(Math.abs(n)))}function oc(n,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(ze(e)/3)))*3-ze(Math.abs(n)))}function ac(n,e){return n=Math.abs(n),e=Math.abs(e)-n,Math.max(0,ze(e)-ze(n))+1}function lc(n,e,t,s){var i=Wn(n,e,t),a;switch(s=Wt(s??",f"),s.type){case"s":{var o=Math.max(Math.abs(n),Math.abs(e));return s.precision==null&&!isNaN(a=oc(i,o))&&(s.precision=a),qi(s,o)}case"":case"e":case"g":case"p":case"r":{s.precision==null&&!isNaN(a=ac(i,Math.max(Math.abs(n),Math.abs(e))))&&(s.precision=a-(s.type==="e"));break}case"f":case"%":{s.precision==null&&!isNaN(a=ic(i))&&(s.precision=a-(s.type==="%")*2);break}}return $i(s)}function cc(n){var e=n.domain;return n.ticks=function(t){var s=e();return ql(s[0],s[s.length-1],t??10)},n.tickFormat=function(t,s){var i=e();return lc(i[0],i[i.length-1],t??10,s)},n.nice=function(t){t==null&&(t=10);var s=e(),i=0,a=s.length-1,o=s[i],l=s[a],u,c,h=10;for(l<o&&(c=o,o=l,l=c,c=i,i=a,a=c);h-- >0;){if(c=jn(o,l,t),c===u)return s[i]=o,s[a]=l,e(s);if(c>0)o=Math.floor(o/c)*c,l=Math.ceil(l/c)*c;else if(c<0)o=Math.ceil(o*c)/c,l=Math.floor(l*c)/c;else break;u=c}return n},n}function Hi(){var n=Bi();return n.copy=function(){return Ui(n,Hi())},Zi.apply(n,arguments),cc(n)}function uc(n,e){n=n.slice();var t=0,s=n.length-1,i=n[t],a=n[s],o;return a<i&&(o=t,t=s,s=o,o=i,i=a,a=o),n[t]=e.floor(i),n[s]=e.ceil(a),n}const Cn=new Date,Pn=new Date;function D(n,e,t,s){function i(a){return n(a=arguments.length===0?new Date:new Date(+a)),a}return i.floor=a=>(n(a=new Date(+a)),a),i.ceil=a=>(n(a=new Date(a-1)),e(a,1),n(a),a),i.round=a=>{const o=i(a),l=i.ceil(a);return a-o<l-a?o:l},i.offset=(a,o)=>(e(a=new Date(+a),o==null?1:Math.floor(o)),a),i.range=(a,o,l)=>{const u=[];if(a=i.ceil(a),l=l==null?1:Math.floor(l),!(a<o)||!(l>0))return u;let c;do u.push(c=new Date(+a)),e(a,l),n(a);while(c<a&&a<o);return u},i.filter=a=>D(o=>{if(o>=o)for(;n(o),!a(o);)o.setTime(o-1)},(o,l)=>{if(o>=o)if(l<0)for(;++l<=0;)for(;e(o,-1),!a(o););else for(;--l>=0;)for(;e(o,1),!a(o););}),t&&(i.count=(a,o)=>(Cn.setTime(+a),Pn.setTime(+o),n(Cn),n(Pn),Math.floor(t(Cn,Pn))),i.every=a=>(a=Math.floor(a),!isFinite(a)||!(a>0)?null:a>1?i.filter(s?o=>s(o)%a===0:o=>i.count(0,o)%a===0):i)),i}const Vt=D(()=>{},(n,e)=>{n.setTime(+n+e)},(n,e)=>e-n);Vt.every=n=>(n=Math.floor(n),!isFinite(n)||!(n>0)?null:n>1?D(e=>{e.setTime(Math.floor(e/n)*n)},(e,t)=>{e.setTime(+e+t*n)},(e,t)=>(t-e)/n):Vt);Vt.range;const se=1e3,V=se*60,re=V*60,oe=re*24,Ms=oe*7,dr=oe*30,Rn=oe*365,Pe=D(n=>{n.setTime(n-n.getMilliseconds())},(n,e)=>{n.setTime(+n+e*se)},(n,e)=>(e-n)/se,n=>n.getUTCSeconds());Pe.range;const Ds=D(n=>{n.setTime(n-n.getMilliseconds()-n.getSeconds()*se)},(n,e)=>{n.setTime(+n+e*V)},(n,e)=>(e-n)/V,n=>n.getMinutes());Ds.range;const hc=D(n=>{n.setUTCSeconds(0,0)},(n,e)=>{n.setTime(+n+e*V)},(n,e)=>(e-n)/V,n=>n.getUTCMinutes());hc.range;const Ys=D(n=>{n.setTime(n-n.getMilliseconds()-n.getSeconds()*se-n.getMinutes()*V)},(n,e)=>{n.setTime(+n+e*re)},(n,e)=>(e-n)/re,n=>n.getHours());Ys.range;const dc=D(n=>{n.setUTCMinutes(0,0,0)},(n,e)=>{n.setTime(+n+e*re)},(n,e)=>(e-n)/re,n=>n.getUTCHours());dc.range;const gt=D(n=>n.setHours(0,0,0,0),(n,e)=>n.setDate(n.getDate()+e),(n,e)=>(e-n-(e.getTimezoneOffset()-n.getTimezoneOffset())*V)/oe,n=>n.getDate()-1);gt.range;const zs=D(n=>{n.setUTCHours(0,0,0,0)},(n,e)=>{n.setUTCDate(n.getUTCDate()+e)},(n,e)=>(e-n)/oe,n=>n.getUTCDate()-1);zs.range;const fc=D(n=>{n.setUTCHours(0,0,0,0)},(n,e)=>{n.setUTCDate(n.getUTCDate()+e)},(n,e)=>(e-n)/oe,n=>Math.floor(n/oe));fc.range;function be(n){return D(e=>{e.setDate(e.getDate()-(e.getDay()+7-n)%7),e.setHours(0,0,0,0)},(e,t)=>{e.setDate(e.getDate()+t*7)},(e,t)=>(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*V)/Ms)}const pn=be(0),Xt=be(1),pc=be(2),gc=be(3),Ze=be(4),mc=be(5),yc=be(6);pn.range;Xt.range;pc.range;gc.range;Ze.range;mc.range;yc.range;function Se(n){return D(e=>{e.setUTCDate(e.getUTCDate()-(e.getUTCDay()+7-n)%7),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t*7)},(e,t)=>(t-e)/Ms)}const ji=Se(0),Gt=Se(1),vc=Se(2),bc=Se(3),Ue=Se(4),Sc=Se(5),wc=Se(6);ji.range;Gt.range;vc.range;bc.range;Ue.range;Sc.range;wc.range;const Zs=D(n=>{n.setDate(1),n.setHours(0,0,0,0)},(n,e)=>{n.setMonth(n.getMonth()+e)},(n,e)=>e.getMonth()-n.getMonth()+(e.getFullYear()-n.getFullYear())*12,n=>n.getMonth());Zs.range;const Tc=D(n=>{n.setUTCDate(1),n.setUTCHours(0,0,0,0)},(n,e)=>{n.setUTCMonth(n.getUTCMonth()+e)},(n,e)=>e.getUTCMonth()-n.getUTCMonth()+(e.getUTCFullYear()-n.getUTCFullYear())*12,n=>n.getUTCMonth());Tc.range;const ae=D(n=>{n.setMonth(0,1),n.setHours(0,0,0,0)},(n,e)=>{n.setFullYear(n.getFullYear()+e)},(n,e)=>e.getFullYear()-n.getFullYear(),n=>n.getFullYear());ae.every=n=>!isFinite(n=Math.floor(n))||!(n>0)?null:D(e=>{e.setFullYear(Math.floor(e.getFullYear()/n)*n),e.setMonth(0,1),e.setHours(0,0,0,0)},(e,t)=>{e.setFullYear(e.getFullYear()+t*n)});ae.range;const ye=D(n=>{n.setUTCMonth(0,1),n.setUTCHours(0,0,0,0)},(n,e)=>{n.setUTCFullYear(n.getUTCFullYear()+e)},(n,e)=>e.getUTCFullYear()-n.getUTCFullYear(),n=>n.getUTCFullYear());ye.every=n=>!isFinite(n=Math.floor(n))||!(n>0)?null:D(e=>{e.setUTCFullYear(Math.floor(e.getUTCFullYear()/n)*n),e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCFullYear(e.getUTCFullYear()+t*n)});ye.range;function xc(n,e,t,s,i,a){const o=[[Pe,1,se],[Pe,5,5*se],[Pe,15,15*se],[Pe,30,30*se],[a,1,V],[a,5,5*V],[a,15,15*V],[a,30,30*V],[i,1,re],[i,3,3*re],[i,6,6*re],[i,12,12*re],[s,1,oe],[s,2,2*oe],[t,1,Ms],[e,1,dr],[e,3,3*dr],[n,1,Rn]];function l(c,h,f){const p=h<c;p&&([c,h]=[h,c]);const y=f&&typeof f.range=="function"?f:u(c,h,f),b=y?y.range(c,+h+1):[];return p?b.reverse():b}function u(c,h,f){const p=Math.abs(h-c)/f,y=As(([,,w])=>w).right(o,p);if(y===o.length)return n.every(Wn(c/Rn,h/Rn,f));if(y===0)return Vt.every(Math.max(Wn(c,h,f),1));const[b,v]=o[p/o[y-1][2]<o[y][2]/p?y-1:y];return b.every(v)}return[l,u]}const[Ec,Cc]=xc(ae,Zs,pn,gt,Ys,Ds);function Nn(n){if(0<=n.y&&n.y<100){var e=new Date(-1,n.m,n.d,n.H,n.M,n.S,n.L);return e.setFullYear(n.y),e}return new Date(n.y,n.m,n.d,n.H,n.M,n.S,n.L)}function Ln(n){if(0<=n.y&&n.y<100){var e=new Date(Date.UTC(-1,n.m,n.d,n.H,n.M,n.S,n.L));return e.setUTCFullYear(n.y),e}return new Date(Date.UTC(n.y,n.m,n.d,n.H,n.M,n.S,n.L))}function He(n,e,t){return{y:n,m:e,d:t,H:0,M:0,S:0,L:0}}function Pc(n){var e=n.dateTime,t=n.date,s=n.time,i=n.periods,a=n.days,o=n.shortDays,l=n.months,u=n.shortMonths,c=je(i),h=We(i),f=je(a),p=We(a),y=je(o),b=We(o),v=je(l),w=We(l),E=je(u),R=We(u),C={a:ne,A:Q,b:Z,B:gn,c:null,d:vr,e:vr,f:Xc,g:iu,G:au,H:jc,I:Wc,j:Vc,L:Wi,m:Gc,M:Kc,p:mn,q:yn,Q:wr,s:Tr,S:Qc,u:Jc,U:eu,V:tu,w:nu,W:su,x:null,X:null,y:ru,Y:ou,Z:lu,"%":Sr},N={a:vn,A:bn,b:Sn,B:vt,c:null,d:br,e:br,f:du,g:Tu,G:Eu,H:cu,I:uu,j:hu,L:Xi,m:fu,M:pu,p:wn,q:Yo,Q:wr,s:Tr,S:gu,u:mu,U:yu,V:vu,w:bu,W:Su,x:null,X:null,y:wu,Y:xu,Z:Cu,"%":Sr},O={a:W,A:x,b:$,B:Y,c:K,d:mr,e:mr,f:Fc,g:gr,G:pr,H:yr,I:yr,j:zc,L:Bc,m:Yc,M:Zc,p:G,q:Dc,Q:qc,s:Hc,S:Uc,u:_c,U:Oc,V:Ac,w:kc,W:Ic,x:ue,X:te,y:gr,Y:pr,Z:Mc,"%":$c};C.x=T(t,C),C.X=T(s,C),C.c=T(e,C),N.x=T(t,N),N.X=T(s,N),N.c=T(e,N);function T(S,P){return function(L){var m=[],U=-1,A=0,q=S.length,H,he,js;for(L instanceof Date||(L=new Date(+L));++U<q;)S.charCodeAt(U)===37&&(m.push(S.slice(A,U)),(he=fr[H=S.charAt(++U)])!=null?H=S.charAt(++U):he=H==="e"?" ":"0",(js=P[H])&&(H=js(L,he)),m.push(H),A=U+1);return m.push(S.slice(A,U)),m.join("")}}function _(S,P){return function(L){var m=He(1900,void 0,1),U=I(m,S,L+="",0),A,q;if(U!=L.length)return null;if("Q"in m)return new Date(m.Q);if("s"in m)return new Date(m.s*1e3+("L"in m?m.L:0));if(P&&!("Z"in m)&&(m.Z=0),"p"in m&&(m.H=m.H%12+m.p*12),m.m===void 0&&(m.m="q"in m?m.q:0),"V"in m){if(m.V<1||m.V>53)return null;"w"in m||(m.w=1),"Z"in m?(A=Ln(He(m.y,0,1)),q=A.getUTCDay(),A=q>4||q===0?Gt.ceil(A):Gt(A),A=zs.offset(A,(m.V-1)*7),m.y=A.getUTCFullYear(),m.m=A.getUTCMonth(),m.d=A.getUTCDate()+(m.w+6)%7):(A=Nn(He(m.y,0,1)),q=A.getDay(),A=q>4||q===0?Xt.ceil(A):Xt(A),A=gt.offset(A,(m.V-1)*7),m.y=A.getFullYear(),m.m=A.getMonth(),m.d=A.getDate()+(m.w+6)%7)}else("W"in m||"U"in m)&&("w"in m||(m.w="u"in m?m.u%7:"W"in m?1:0),q="Z"in m?Ln(He(m.y,0,1)).getUTCDay():Nn(He(m.y,0,1)).getDay(),m.m=0,m.d="W"in m?(m.w+6)%7+m.W*7-(q+5)%7:m.w+m.U*7-(q+6)%7);return"Z"in m?(m.H+=m.Z/100|0,m.M+=m.Z%100,Ln(m)):Nn(m)}}function I(S,P,L,m){for(var U=0,A=P.length,q=L.length,H,he;U<A;){if(m>=q)return-1;if(H=P.charCodeAt(U++),H===37){if(H=P.charAt(U++),he=O[H in fr?P.charAt(U++):H],!he||(m=he(S,L,m))<0)return-1}else if(H!=L.charCodeAt(m++))return-1}return m}function G(S,P,L){var m=c.exec(P.slice(L));return m?(S.p=h.get(m[0].toLowerCase()),L+m[0].length):-1}function W(S,P,L){var m=y.exec(P.slice(L));return m?(S.w=b.get(m[0].toLowerCase()),L+m[0].length):-1}function x(S,P,L){var m=f.exec(P.slice(L));return m?(S.w=p.get(m[0].toLowerCase()),L+m[0].length):-1}function $(S,P,L){var m=E.exec(P.slice(L));return m?(S.m=R.get(m[0].toLowerCase()),L+m[0].length):-1}function Y(S,P,L){var m=v.exec(P.slice(L));return m?(S.m=w.get(m[0].toLowerCase()),L+m[0].length):-1}function K(S,P,L){return I(S,e,P,L)}function ue(S,P,L){return I(S,t,P,L)}function te(S,P,L){return I(S,s,P,L)}function ne(S){return o[S.getDay()]}function Q(S){return a[S.getDay()]}function Z(S){return u[S.getMonth()]}function gn(S){return l[S.getMonth()]}function mn(S){return i[+(S.getHours()>=12)]}function yn(S){return 1+~~(S.getMonth()/3)}function vn(S){return o[S.getUTCDay()]}function bn(S){return a[S.getUTCDay()]}function Sn(S){return u[S.getUTCMonth()]}function vt(S){return l[S.getUTCMonth()]}function wn(S){return i[+(S.getUTCHours()>=12)]}function Yo(S){return 1+~~(S.getUTCMonth()/3)}return{format:function(S){var P=T(S+="",C);return P.toString=function(){return S},P},parse:function(S){var P=_(S+="",!1);return P.toString=function(){return S},P},utcFormat:function(S){var P=T(S+="",N);return P.toString=function(){return S},P},utcParse:function(S){var P=_(S+="",!0);return P.toString=function(){return S},P}}}var fr={"-":"",_:" ",0:"0"},z=/^\s*\d+/,Rc=/^%/,Nc=/[\\^$*+?|[\]().{}]/g;function k(n,e,t){var s=n<0?"-":"",i=(s?-n:n)+"",a=i.length;return s+(a<t?new Array(t-a+1).join(e)+i:i)}function Lc(n){return n.replace(Nc,"\\$&")}function je(n){return new RegExp("^(?:"+n.map(Lc).join("|")+")","i")}function We(n){return new Map(n.map((e,t)=>[e.toLowerCase(),t]))}function kc(n,e,t){var s=z.exec(e.slice(t,t+1));return s?(n.w=+s[0],t+s[0].length):-1}function _c(n,e,t){var s=z.exec(e.slice(t,t+1));return s?(n.u=+s[0],t+s[0].length):-1}function Oc(n,e,t){var s=z.exec(e.slice(t,t+2));return s?(n.U=+s[0],t+s[0].length):-1}function Ac(n,e,t){var s=z.exec(e.slice(t,t+2));return s?(n.V=+s[0],t+s[0].length):-1}function Ic(n,e,t){var s=z.exec(e.slice(t,t+2));return s?(n.W=+s[0],t+s[0].length):-1}function pr(n,e,t){var s=z.exec(e.slice(t,t+4));return s?(n.y=+s[0],t+s[0].length):-1}function gr(n,e,t){var s=z.exec(e.slice(t,t+2));return s?(n.y=+s[0]+(+s[0]>68?1900:2e3),t+s[0].length):-1}function Mc(n,e,t){var s=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(e.slice(t,t+6));return s?(n.Z=s[1]?0:-(s[2]+(s[3]||"00")),t+s[0].length):-1}function Dc(n,e,t){var s=z.exec(e.slice(t,t+1));return s?(n.q=s[0]*3-3,t+s[0].length):-1}function Yc(n,e,t){var s=z.exec(e.slice(t,t+2));return s?(n.m=s[0]-1,t+s[0].length):-1}function mr(n,e,t){var s=z.exec(e.slice(t,t+2));return s?(n.d=+s[0],t+s[0].length):-1}function zc(n,e,t){var s=z.exec(e.slice(t,t+3));return s?(n.m=0,n.d=+s[0],t+s[0].length):-1}function yr(n,e,t){var s=z.exec(e.slice(t,t+2));return s?(n.H=+s[0],t+s[0].length):-1}function Zc(n,e,t){var s=z.exec(e.slice(t,t+2));return s?(n.M=+s[0],t+s[0].length):-1}function Uc(n,e,t){var s=z.exec(e.slice(t,t+2));return s?(n.S=+s[0],t+s[0].length):-1}function Bc(n,e,t){var s=z.exec(e.slice(t,t+3));return s?(n.L=+s[0],t+s[0].length):-1}function Fc(n,e,t){var s=z.exec(e.slice(t,t+6));return s?(n.L=Math.floor(s[0]/1e3),t+s[0].length):-1}function $c(n,e,t){var s=Rc.exec(e.slice(t,t+1));return s?t+s[0].length:-1}function qc(n,e,t){var s=z.exec(e.slice(t));return s?(n.Q=+s[0],t+s[0].length):-1}function Hc(n,e,t){var s=z.exec(e.slice(t));return s?(n.s=+s[0],t+s[0].length):-1}function vr(n,e){return k(n.getDate(),e,2)}function jc(n,e){return k(n.getHours(),e,2)}function Wc(n,e){return k(n.getHours()%12||12,e,2)}function Vc(n,e){return k(1+gt.count(ae(n),n),e,3)}function Wi(n,e){return k(n.getMilliseconds(),e,3)}function Xc(n,e){return Wi(n,e)+"000"}function Gc(n,e){return k(n.getMonth()+1,e,2)}function Kc(n,e){return k(n.getMinutes(),e,2)}function Qc(n,e){return k(n.getSeconds(),e,2)}function Jc(n){var e=n.getDay();return e===0?7:e}function eu(n,e){return k(pn.count(ae(n)-1,n),e,2)}function Vi(n){var e=n.getDay();return e>=4||e===0?Ze(n):Ze.ceil(n)}function tu(n,e){return n=Vi(n),k(Ze.count(ae(n),n)+(ae(n).getDay()===4),e,2)}function nu(n){return n.getDay()}function su(n,e){return k(Xt.count(ae(n)-1,n),e,2)}function ru(n,e){return k(n.getFullYear()%100,e,2)}function iu(n,e){return n=Vi(n),k(n.getFullYear()%100,e,2)}function ou(n,e){return k(n.getFullYear()%1e4,e,4)}function au(n,e){var t=n.getDay();return n=t>=4||t===0?Ze(n):Ze.ceil(n),k(n.getFullYear()%1e4,e,4)}function lu(n){var e=n.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+k(e/60|0,"0",2)+k(e%60,"0",2)}function br(n,e){return k(n.getUTCDate(),e,2)}function cu(n,e){return k(n.getUTCHours(),e,2)}function uu(n,e){return k(n.getUTCHours()%12||12,e,2)}function hu(n,e){return k(1+zs.count(ye(n),n),e,3)}function Xi(n,e){return k(n.getUTCMilliseconds(),e,3)}function du(n,e){return Xi(n,e)+"000"}function fu(n,e){return k(n.getUTCMonth()+1,e,2)}function pu(n,e){return k(n.getUTCMinutes(),e,2)}function gu(n,e){return k(n.getUTCSeconds(),e,2)}function mu(n){var e=n.getUTCDay();return e===0?7:e}function yu(n,e){return k(ji.count(ye(n)-1,n),e,2)}function Gi(n){var e=n.getUTCDay();return e>=4||e===0?Ue(n):Ue.ceil(n)}function vu(n,e){return n=Gi(n),k(Ue.count(ye(n),n)+(ye(n).getUTCDay()===4),e,2)}function bu(n){return n.getUTCDay()}function Su(n,e){return k(Gt.count(ye(n)-1,n),e,2)}function wu(n,e){return k(n.getUTCFullYear()%100,e,2)}function Tu(n,e){return n=Gi(n),k(n.getUTCFullYear()%100,e,2)}function xu(n,e){return k(n.getUTCFullYear()%1e4,e,4)}function Eu(n,e){var t=n.getUTCDay();return n=t>=4||t===0?Ue(n):Ue.ceil(n),k(n.getUTCFullYear()%1e4,e,4)}function Cu(){return"+0000"}function Sr(){return"%"}function wr(n){return+n}function Tr(n){return Math.floor(+n/1e3)}var xe,Ki;Pu({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function Pu(n){return xe=Pc(n),Ki=xe.format,xe.parse,xe.utcFormat,xe.utcParse,xe}function Ru(n){return new Date(n)}function Nu(n){return n instanceof Date?+n:+new Date(+n)}function Qi(n,e,t,s,i,a,o,l,u,c){var h=Bi(),f=h.invert,p=h.domain,y=c(".%L"),b=c(":%S"),v=c("%I:%M"),w=c("%I %p"),E=c("%a %d"),R=c("%b %d"),C=c("%B"),N=c("%Y");function O(T){return(u(T)<T?y:l(T)<T?b:o(T)<T?v:a(T)<T?w:s(T)<T?i(T)<T?E:R:t(T)<T?C:N)(T)}return h.invert=function(T){return new Date(f(T))},h.domain=function(T){return arguments.length?p(Array.from(T,Nu)):p().map(Ru)},h.ticks=function(T){var _=p();return n(_[0],_[_.length-1],T??10)},h.tickFormat=function(T,_){return _==null?O:c(_)},h.nice=function(T){var _=p();return(!T||typeof T.range!="function")&&(T=e(_[0],_[_.length-1],T??10)),T?p(uc(_,T)):h},h.copy=function(){return Ui(h,Qi(n,e,t,s,i,a,o,l,u,c))},h}function Lu(){return Zi.apply(Qi(Ec,Cc,ae,Zs,pn,gt,Ys,Ds,Pe,Ki).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}const xr=[r.g.NANOSECOND,r.g.nanoseconds(2),r.g.nanoseconds(5),r.g.nanoseconds(10),r.g.nanoseconds(20),r.g.nanoseconds(50),r.g.nanoseconds(100),r.g.nanoseconds(200),r.g.nanoseconds(500),r.g.MICROSECOND,r.g.microseconds(2),r.g.microseconds(5),r.g.microseconds(10),r.g.microseconds(20),r.g.microseconds(50),r.g.microseconds(100),r.g.microseconds(200),r.g.microseconds(500),r.g.MILLISECOND,r.g.milliseconds(2),r.g.milliseconds(5),r.g.milliseconds(10),r.g.milliseconds(20),r.g.milliseconds(50),r.g.milliseconds(100),r.g.milliseconds(200),r.g.milliseconds(500),r.g.SECOND];class ku{_domain;_range;_span;constructor(){this._domain=[new r.d(0n),new r.d(1n)],this._range=[0,1],this._span=this._domain[1].span(this._domain[0])}domain(e){return e===void 0?this._domain:(this._domain=[new r.d(e[0]),new r.d(e[1])],this._span=this._domain[1].span(this._domain[0]),this)}range(e){return e===void 0?this._range:(this._range=e,this)}scale(e){const s=new r.d(e).valueOf(),i=this._domain[0].valueOf(),a=this._domain[1].valueOf()-i,o=this._range[1]-this._range[0];return Number(s-i)/Number(a)*o+this._range[0]}ticks(e){const t=this.calculateOptimalStep(e).valueOf(),s=this._domain[0].valueOf(),i=this._domain[1].valueOf(),a=(s+t-1n)/t*t,o=Number((i-a)/t);return Array.from({length:o+1},(l,u)=>{const c=a+BigInt(u)*t;return new r.d(c)}).filter(l=>l.afterEq(this._domain[0])&&l.beforeEq(this._domain[1]))}calculateOptimalStep(e){const t=this._span.valueOf()/BigInt(Math.ceil(e));let s=xr[0];for(const i of xr){if(i.valueOf()>t)break;s=i}return s}formatTick(e){return this._span.lessThan(r.g.microseconds(50))?`${e.remainder(r.g.MILLISECOND).microseconds.toString()}µs`:`${e.remainder(r.g.SECOND).milliseconds.toString()}ms`}}const _u=()=>new ku,Us=d.z.enum(["linear","time"]),Bs=d.z.object({tickSpacing:d.z.number().default(75),type:Us.default("linear")}),Xn=n=>{const e=Bs.parse(n);return Iu[e.type](e)};class Ou{props;prevScaleSize;prevDomain;currTicks;normalScale;preciseScale;constructor(e){this.props=e,this.normalScale=Lu(),this.preciseScale=_u(),this.prevScaleSize=0,this.prevDomain=new r.S(new r.d(0),new r.d(0)),this.currTicks=[]}create({decimalToDataScale:e,size:t}){const s=new r.S(new r.d(e.pos(0)),new r.d(e.pos(1)));if(this.prevDomain.equals(s)&&this.prevScaleSize===t)return this.currTicks;if(this.prevDomain=s,this.prevScaleSize!==t){const i=[0,t];this.preciseScale.range(i),this.normalScale.range(i),this.prevScaleSize=t}if(s.span.milliseconds<5){this.preciseScale.domain([s.start,s.end]);const i=Gn(t,this.props.tickSpacing)/2,a=this.preciseScale.ticks(i);this.currTicks=a.map(o=>({label:this.preciseScale.formatTick(o),position:this.preciseScale.scale(o)}))}else{this.normalScale.domain([s.start.date(),s.end.date()]);const i=this.normalScale.ticks(Gn(t,this.props.tickSpacing));this.currTicks=i.map(a=>({label:this.normalTickLabel(a),position:this.normalScale(a)}))}return this.currTicks}normalTickLabel(e){let t=`:${e.getSeconds()}`;const s=e.getMilliseconds();if(s!==0){const i=Math.round(e.getMilliseconds()).toString().padStart(3,"0").replace(/0+$/,"");t+=`.${i}`}return e.getSeconds()===0&&s===0&&(t=`${e.getHours()}:${e.getMinutes().toString().padStart(2,"0")}`),t}}class Au{props;prevDomain;prevScaleSize;currTicks;d3Scale;constructor(e){this.props=e,this.prevDomain=r.wu.construct(0,0),this.prevScaleSize=0,this.currTicks=[],this.d3Scale=Hi()}create({decimalToDataScale:e,size:t}){const s={lower:e.pos(0),upper:e.pos(1)};if(r.wu.equals(this.prevDomain,s)&&this.prevScaleSize===t)return this.currTicks;r.wu.equals(this.prevDomain,s)||(this.d3Scale=this.d3Scale.domain([s.lower,s.upper])),this.prevScaleSize!==t&&(this.d3Scale=this.d3Scale.range([0,t])),this.prevDomain=s,this.prevScaleSize=t;const i=Gn(t,this.props.tickSpacing),a=this.d3Scale.ticks(i);return this.currTicks=a.map(o=>({label:this.tickLabel(o),position:this.d3Scale(o)})),this.currTicks}tickLabel(e){return e.toString()}}const Gn=(n,e)=>{const t=Math.floor(n/e);return t>0?t:1},Iu={linear:n=>new Au(n),time:n=>new Ou(n)},Fs=Bs.extend({color:r.Pu.colorZ,type:Us.default("linear"),font:d.z.string(),showGrid:d.z.boolean().default(!0),location:r.Iu.outer,gridColor:r.Pu.colorZ}),X=5,st=6,mt={useAtlas:!0},Mu={bottom:(n,e)=>new eo(n,e),top:(n,e)=>new to(n,e),left:(n,e)=>new Du(n,e),right:(n,e)=>new no(n,e)},Ji=(n,e,t)=>Mu[n](e,t);class we{renderCtx;state;tickFactory;constructor(e,t){this.renderCtx=e,this.state=t,this.tickFactory=Xn(this.state)}setState(e){this.state=g.prettyParse(Fs,e),this.tickFactory=Xn(e)}drawLine(e,t){const{lower2d:s}=this.renderCtx;s.moveTo(...r.Nu.couple(e)),s.lineTo(...r.Nu.couple(t))}drawTicks(e,t){let s=r.Mu.ZERO;return e.forEach(i=>{const a=this.renderCtx.lower2d.textDimensions(i.label,mt);s=r.Mu.max([s,a]),t(a,i)}),s}static START_BOUND=r.wu.construct(-1,1);maybeDrawGrid(e,t,s){const{showGrid:i,gridColor:a}=this.state;if(i){const o=we.START_BOUND,l=r.wu.construct(e-1,e+1),{lower2d:u}=this.renderCtx;u.beginPath(),u.strokeStyle=r.Pu.hex(a),t.forEach(c=>{r.wu.contains(o,c.position)||r.wu.contains(l,c.position)||this.drawLine(...s(c))}),u.stroke()}}setColor(e){const t=r.Pu.hex(e);this.renderCtx.lower2d.strokeStyle=t,this.renderCtx.lower2d.fillStyle=t,this.renderCtx.lower2d.font=this.state.font}}class eo extends we{render(e){const{lower2d:t}=this.renderCtx,{plot:s,position:i}=e,{width:a,height:o}=r.vu.dims(s),l=this.tickFactory.create({...e,size:a});t.beginPath(),this.setColor(this.state.color),this.drawLine(i,r.Nu.translate(i,"x",a));const u=this.drawTicks(l,(c,h)=>{this.drawLine(r.Nu.translateX(i,h.position),r.Nu.translate(i,{x:h.position,y:X})),t.fillText(h.label,i.x+h.position-c.width/2,i.y+X+c.height+st,void 0,mt)});return t.stroke(),this.maybeDrawGrid(a,l,c=>[r.Nu.translate(i,"x",c.position),r.Nu.translate(i,{x:c.position,y:-o})]),{size:u.height+X+st}}}class to extends we{render(e){const{lower2d:t}=this.renderCtx,{plot:s}=e,{width:i,height:a}=r.vu.dims(s),o=r.Nu.translate(e.position,"y",e.size),l=this.tickFactory.create({...e,size:i});t.beginPath(),this.setColor(this.state.color),this.drawLine(o,r.Nu.translate(o,"x",i));const u=this.drawTicks(l,(c,h)=>{this.drawLine(r.Nu.translateX(o,h.position),r.Nu.translate(o,{x:h.position,y:-X})),t.fillText(h.label,o.x+h.position-c.width/2,o.y-X-c.height-st,void 0,mt)});return t.stroke(),this.maybeDrawGrid(i,l,c=>[r.Nu.translate(o,"x",c.position),r.Nu.translate(o,{x:c.position,y:a})]),{size:u.height+X}}}class Du extends we{render(e){const{lower2d:t}=this.renderCtx,{plot:s,position:i}=e,{height:a,width:o}=r.vu.dims(s),l=r.Nu.translate(i,"x",e.size),u=this.tickFactory.create({...e,size:a});t.beginPath(),this.setColor(this.state.color),this.drawLine(l,r.Nu.translate(l,"y",a));const c=this.drawTicks(u,(h,f)=>{this.drawLine(r.Nu.translateY(l,f.position),r.Nu.translate(l,{x:-X,y:f.position})),t.fillText(f.label,l.x-h.width-X*2,l.y+f.position+h.height/2,void 0,mt)});return t.stroke(),this.maybeDrawGrid(a,u,h=>[r.Nu.translate(l,"y",h.position),r.Nu.translate(l,{x:o,y:h.position})]),{size:c.width+X*2}}}class no extends we{render(e){const{lower2d:t}=this.renderCtx,{plot:s,position:i}=e,{height:a,width:o}=r.vu.dims(s),l=this.tickFactory.create({...e,size:a});t.beginPath(),this.setColor(this.state.color),this.drawLine(i,r.Nu.translateY(i,a));const u=this.drawTicks(l,(c,h)=>{this.drawLine(r.Nu.translateY(i,h.position),r.Nu.translate(i,{x:X,y:h.position})),t.fillText(h.label,i.x+X+st,i.y+h.position+c.height/2,void 0,mt)});return t.stroke(),this.maybeDrawGrid(a,l,c=>[r.Nu.translateY(i,c.position),r.Nu.translate(i,{x:-o,y:c.position})]),{size:u.width+X+st}}}const so=d.z.object({key:d.z.string(),size:d.z.number(),order:d.z.number(),loc:r.Iu.outer});d.z.record(d.z.string(),so);const fe=(n,e)=>Object.values(e).filter(({loc:t})=>t===n).sort((t,s)=>s.order-t.order),Yu=(n,e,t)=>{const s=e[n];if(s==null)return r.Nu.ZERO;const i=r.Iu.construct(s.loc),a=fe(i,e),o=r.Iu.construct(r.xu.swap(r.Iu.direction(i))),l=fe(o,e),u=a.findIndex(({key:f})=>f===n),c=a.slice(0,u).reduce((f,{size:p})=>f+p,0),h=l.reduce((f,{size:p})=>f+p,0);switch(i){case"left":return r.Nu.translate(r.vu.topLeft(t),[c,h]);case"right":return r.Nu.translate(r.vu.topRight(t),[c-s.size,h]);case"top":return r.Nu.translate(r.vu.topLeft(t),[h,c]);default:return r.Nu.translate(r.vu.bottomLeft(t),[h,-c-s.size])}},zu=(n,e)=>{const t=fe("left",n),s=fe("right",n),i=fe("top",n),a=fe("bottom",n),o=t.reduce((h,{size:f})=>h+f,0),l=s.reduce((h,{size:f})=>h+f,0),u=i.reduce((h,{size:f})=>h+f,0),c=a.reduce((h,{size:f})=>h+f,0);return r.vu.construct(r.Nu.translate(r.vu.topLeft(e),{x:o,y:u}),r.vu.width(e)-o-l,r.vu.height(e)-u-c)},yt=Fs.extend({axisKey:d.z.string().optional(),bounds:r.wu.bounds.optional(),autoBounds:d.z.object({lower:d.z.boolean().default(!0),upper:d.z.boolean().default(!0)}).or(d.z.boolean().default(!0)),autoBoundPadding:d.z.number().optional(),autoBoundUpdateInterval:r.g.z.default(r.g.seconds(10)),size:d.z.number().default(0),label:d.z.string().default(""),labelSize:d.z.number().default(0)}).partial({color:!0,font:!0,gridColor:!0}),Zu=2,Uu=7,ro=(n,e)=>r.wu.contains({lower:n-Uu,upper:n+Zu},e),Bu=r.wu.DECIMAL,Er=r.d.now(),Fu={lower:Number(Er.valueOf()),upper:Number(Er.add(r.g.HOUR).valueOf())},io=n=>n==="linear"?Bu:Fu,$u=(n,e=.1,t)=>{const s=r.wu.max(n.filter(r.wu.isFinite));if(!r.wu.isFinite(s))return io(t);const{lower:i,upper:a}=s;if(a===i)return{lower:i-1,upper:a+1};const o=(a-i)*e;return{lower:i-o,upper:a+o}},qu=.01,Hu=.1;class oo extends g.Composite{afterUpdate(e){const{internal:t}=this,{location:s,autoBoundUpdateInterval:i}=this.state;t.render=M.Context.use(e);const a=g.use(e),o=r.xu.construct(s);this.state.autoBoundPadding??=o==="x"?Hu:qu,t.core=Ji(s,t.render,{color:a.colors.gray.l10,font:Qe.fontString(a,{level:"small",code:!0}),gridColor:a.colors.gray.l1,...this.state}),ie(e,"layout"),t.updateBounds??=r._u(l=>this.setState(u=>({...u,bounds:l})),i.milliseconds)}afterDelete(e){ie(e,"layout")}renderAxis(e,t){if(!e.canvases.includes("lower2d"))return;const{core:s}=this.internal,{grid:i,container:a}=e,o=Yu(`${this.type}-${this.key}`,i,a),l={...e,position:o,decimalToDataScale:t,size:this.state.size+this.state.labelSize},{size:u}=s.render(l);ro(this.state.size,u)||this.setState(c=>({...c,size:u}))}iBounds(e,t){if(e&&this.internal.boundSnapshot!=null)return[this.internal.boundSnapshot,null];const{lower:s,upper:i}=ao(this.state.autoBounds);if(!s&&!i&&this.state.bounds!=null)return this.internal.boundSnapshot=this.state.bounds,[this.state.bounds,null];const a=c=>({upper:i||this.state.bounds==null?c.upper:this.state.bounds.upper,lower:s||this.state.bounds==null?c.lower:this.state.bounds.lower});let o,l=null;try{const c=t();o=$u(c,this.state.autoBoundPadding,this.state.type)}catch(c){o=io(this.state.type),l=c}const u=a(o);return this.internal.boundSnapshot=u,(this.state.bounds==null||s&&this.state.bounds.lower!==u.lower||i&&this.state.bounds.upper!==u.upper)&&this.internal.updateBounds?.(u),[u,l]}dataToDecimalScale(e,t,s){const[i,a]=this.iBounds(e,t),o=r.xu.swap(r.xu.construct(this.state.location));return[r.Au.Scale.scale(i).scale(1).translate(-r.vu.root(s)[o]).magnify(1/r.vu.dim(s,o)),a]}}const ao=n=>typeof n=="boolean"?{lower:n,upper:n}:{lower:n?.lower??!0,upper:n?.upper??!0};class Te{canvas;theme;constructor(e,t){this.canvas=e,this.theme=t}rule({direction:e,region:t,position:s,...i}){return e==="x"?this.line({start:r.Nu.construct(r.vu.left(t),s),end:r.Nu.construct(r.vu.right(t),s),...i}):this.line({start:r.Nu.construct(s,r.vu.top(t)),end:r.Nu.construct(s,r.vu.bottom(t)),...i})}line({stroke:e,lineWidth:t,lineDash:s,start:i,end:a}){const o=this.canvas;o.strokeStyle=r.Pu.hex(e),o.lineWidth=t,o.setLineDash([s]),o.beginPath(),o.moveTo(...r.Nu.couple(i)),o.lineTo(...r.Nu.couple(a)),o.stroke()}circle({fill:e,stroke:t,strokeWidth:s,lineDash:i,radius:a,position:o,angle:l,lineCap:u}){const c=this.canvas;c.beginPath();const h=l?.lower??0,f=l?.upper??2*Math.PI;if(t!=null&&typeof a=="object"){const{inner:p,outer:y}=a,b=(p+y)/2,v=y-p;c.arc(...r.Nu.couple(o),b,h,f,!1),c.strokeStyle=r.Pu.hex(t),c.lineWidth=s??v,u&&(c.lineCap=u),i!=null&&c.setLineDash([i]),c.stroke(),i!=null&&c.setLineDash([])}else if(t!=null&&typeof a=="number")c.arc(...r.Nu.couple(o),a,h,f,!1),c.strokeStyle=r.Pu.hex(t),c.lineWidth=s??1,u&&(c.lineCap=u),i!=null&&c.setLineDash([i]),c.stroke(),i!=null&&c.setLineDash([]);else if(e!=null)if(c.fillStyle=r.Pu.hex(e),typeof a=="number")c.arc(...r.Nu.couple(o),a,h,f),c.fill();else{const{inner:p,outer:y}=a;c.arc(...r.Nu.couple(o),y,h,f,!1);const b=o.x+p*Math.cos(f),v=o.y+p*Math.sin(f);c.lineTo(b,v),c.arc(...r.Nu.couple(o),p,f,h,!0),c.closePath(),c.fill()}}resolveColor(e,t){return e==null?t==null?this.theme.colors.text:this.resolveColor(t):typeof e=="function"?e(this.theme):r.Pu.construct(e)}border({region:e,color:t,width:s,radius:i,location:a}){const o=this.canvas;o.strokeStyle=r.Pu.hex(this.resolveColor(t,this.theme.colors.border)),o.lineWidth=s??this.theme.sizes.border.width,i??=this.theme.sizes.border.radius,a==null||a===!0?i>0?(o.roundRect(...r.Nu.couple(r.vu.topLeft(e)),...r.Nu.couple(r.vu.dims(e)),i),o.stroke()):(o.rect(...r.Nu.couple(r.vu.topLeft(e)),...r.Nu.couple(r.vu.dims(e))),o.stroke()):r.lu.toArray(a).forEach(l=>{const[u,c]=r.vu.edgePoints(e,l);o.beginPath(),o.moveTo(...r.Nu.couple(u)),o.lineTo(...r.Nu.couple(c)),o.stroke()})}container({region:e,bordered:t=!0,rounded:s=!0,borderColor:i,borderRadius:a,borderWidth:o,backgroundColor:l}){a??=this.theme.sizes.border.radius,o??=1;const u=this.canvas;u.fillStyle=r.Pu.hex(this.resolveColor(l,this.theme.colors.gray.l1)),u.strokeStyle=r.Pu.hex(this.resolveColor(i,this.theme.colors.border)),u.setLineDash([]),u.lineWidth=1,u.beginPath(),s?u.roundRect(...r.Nu.couple(r.vu.topLeft(e)),...r.Nu.couple(r.vu.dims(e)),a):u.rect(...r.Nu.couple(r.vu.topLeft(e)),...r.Nu.couple(r.vu.dims(e))),u.fill(),t&&this.border({region:e,color:i,radius:a,width:o,location:t})}textContainer(e){const[t,s]=this.spacedTextDrawF(e);t.width+=12,t.height+=12;const{root:i=r.Iu.TOP_LEFT,offset:a=r.Nu.ZERO}=e,o={...e.position};i.x==="right"?o.x-=t.width+a.x:o.x+=a.x,i.y==="bottom"?o.y-=t.height+a.y:o.y+=a.y,this.container({region:r.vu.construct(o,t.width,t.height),...e}),this.canvas.filter="none",s(r.Nu.translate(o,[6,6]))}spacedTextDrawF({text:e,direction:t,spacing:s=1,level:i="p"}){const a=Qe.fontString(this.theme,{level:i}),o=e.map(c=>Ws.dimensions(c,a,this.canvas)),l=this.theme.sizes.base*s,u=Math.max(...o.map(c=>c[r.xu.dimension(t)]))+l;return[{[r.xu.dimension(r.xu.swap(t))]:Math.max(...o.map(c=>c[r.xu.dimension(r.xu.swap(t))])),[r.xu.dimension(t)]:u*e.length-l},c=>{const h=Qe.fontString(this.theme,{level:i});this.canvas.font=h,this.canvas.fillStyle=r.Pu.hex(this.theme.colors.text),this.canvas.textBaseline="top",this.canvas.textAlign="start",e.forEach((f,p)=>{this.canvas.fillText(f,c.x,c.y+u*p)})}]}list({length:e,itemHeight:t,width:s,spacing:i=0,position:a,draw:o,root:l=r.Iu.TOP_LEFT,offset:u=r.Nu.ZERO,padding:c=r.Nu.ZERO}){const h=e*t+c.y*2+i*(e-1),f=s+c.x*2,p={...a};l.x==="right"?p.x-=s+u.x*2:p.x+=u.x,l.y==="top"?p.y-=h+u.y*2:p.y+=u.y,this.container({region:r.vu.construct(p,{width:f,height:h}),backgroundColor:y=>y.colors.gray.l1});for(let y=0;y<e;y++){const b=r.vu.construct(r.Nu.construct(p.x+c.x,p.y+y*t+c.y+i*y),s,t);o(y,b)}}drawTextInCenter({box:e,text:t,level:s}){const i=Ws.dimensions(t,this.canvas.font,this.canvas),a=r.vu.positionInCenter(r.vu.construct(r.Nu.ZERO,i),e);return this.text({text:t,position:r.vu.topLeft(a),level:s})}text({text:e,position:t,level:s="p",weight:i,shade:a,maxWidth:o,code:l,justify:u="left",align:c="top",useAtlas:h,color:f}){this.canvas.font=Qe.fontString(this.theme,{level:s,weight:i,code:l}),f!=null?this.canvas.fillStyle=r.Pu.hex(this.resolveColor(f)):a==null?this.canvas.fillStyle=r.Pu.hex(this.theme.colors.text):this.canvas.fillStyle=r.Pu.hex(this.theme.colors.gray[`l${a}`]),this.canvas.textAlign=u,this.canvas.textBaseline=c;let p;o!=null&&(p=this.canvas.scissor(r.vu.construct(t,o,1e3))),this.canvas.fillText(e,t.x,t.y,void 0,{useAtlas:h}),p?.()}}const $s=d.z.object({position:d.z.number().optional(),pixelPosition:d.z.number().optional(),dragging:d.z.boolean(),lineWidth:d.z.number().default(1),lineDash:d.z.number().default(20),color:r.Pu.colorZ}),ju=3;class rt extends g.Leaf{static TYPE="Rule";schema=$s;lastUpdateRef=null;afterUpdate(e){this.internal.renderCtx=M.Context.use(e);const t=g.use(e);this.internal.draw=new Te(this.internal.renderCtx.upper2d,t),ie(e,"tool")}afterDelete(e){ie(e,"tool")}updatePositions({decimalToDataScale:e,plot:t}){const s=this.state.dragging,i=this.prevState.dragging&&!s;if((s||i)&&this.state.pixelPosition!=null){if(this.lastUpdateRef??=this.state.pixelPosition,Math.abs(this.state.pixelPosition-this.lastUpdateRef)<ju&&!i)return this.state.pixelPosition;this.lastUpdateRef=this.state.pixelPosition;const l=e.pos(this.state.pixelPosition/r.vu.height(t));return this.setState(u=>({...u,position:l})),this.state.pixelPosition}if(this.state.position==null){const o=e.pos(.5);this.setState(l=>({...l,position:o}))}const a=e.reverse().pos(this.state.position)*r.vu.height(t);if(!isNaN(a)){if(this.state.pixelPosition!=null&&Math.abs(a-this.state.pixelPosition)<1)return this.state.pixelPosition;this.setState(o=>({...o,pixelPosition:a}))}return a}render(e){if(this.deleted)return;const{renderCtx:t}=this.internal,{location:s,plot:i}=e,a=r.Iu.direction(s),{upper2d:o}=t,l=this.internal.draw,u=this.updatePositions(e)+r.vu.top(e.plot);l.rule({stroke:this.state.color,lineWidth:this.state.lineWidth,lineDash:this.state.lineDash,direction:a,region:i,position:u}),o.fillStyle=r.Pu.hex(this.state.color),o.lineJoin="round",o.lineWidth=3.5,o.lineCap="round",o.beginPath();const c=4;if(s==="left"){const h=r.vu.left(i)-1;o.moveTo(h,u),o.lineTo(h-c,u-c),o.lineTo(h-c,u+c)}else s==="right"&&(o.moveTo(r.vu.right(i),u),o.lineTo(r.vu.right(i)+c,u-c),o.lineTo(r.vu.right(i)+c,u+c));o.closePath(),o.stroke()}}const lo={[rt.TYPE]:rt},Wu=Object.freeze(Object.defineProperty({__proto__:null,REGISTRY:lo,Rule:rt,ruleStateZ:$s},Symbol.toStringTag,{value:"Module"})),Vu=yt.extend({location:r.Iu.x.default("left")}),Cr=2,Xu=n=>r.vu.signedWidth(n)<Cr||r.vu.signedHeight(n)<Cr;class Kt extends oo{static TYPE="YAxis";schema=yt;xBounds(){return r.wu.max(this.lines.map(e=>e.xBounds()).filter(e=>r.wu.isFinite(e)))}bounds(e){const[t,s]=this.iBounds(e,this.dataBounds.bind(this));if(s!=null)throw s;return t}render(e){if(this.deleted)return;const[t,s]=this.dataToDecimalScale(e.hold,this.dataBounds.bind(this),e.viewport),i=t.invert().reverse();if(this.renderAxis(e,i),this.renderLines(e,t),this.renderRules(e,i),s!=null)throw s}renderLines({xDataToDecimalScale:e,plot:t,canvases:s,exposure:i},a){if(!s.includes("gl")||Xu(t))return;const o={region:t,dataToDecimalScale:new r.Au.XY(e,a),exposure:i};this.lines.forEach(l=>l.render(o))}renderRules({container:e,plot:t,canvases:s},i){if(!s.includes("upper2d"))return;const{location:a}=this.state,{render:o}=this.internal,l=r.vu.construct(r.vu.left(e),r.vu.top(t),r.vu.width(e),r.vu.height(t)),u=o.scissor(l,r.Nu.ZERO,["upper2d"]),c={container:e,plot:t,decimalToDataScale:i,location:a};this.rules.map(h=>h.render(c)),u()}findByXValue({xDataToDecimalScale:e,plot:t,viewport:s,hold:i,exposure:a},o){const[l,u]=this.dataToDecimalScale(i,this.dataBounds.bind(this),s);if(u!=null)throw u;const c=new r.Au.XY(e,l),h={region:t,dataToDecimalScale:c,exposure:a};return this.lines.map(f=>({...f.findByXValue(h,o),units:this.state.label}))}dataBounds(){return this.lines.map(e=>e.yBounds())}get lines(){return this.childrenOfType(Ft.TYPE)}get rules(){return this.childrenOfType(rt.TYPE)}}const Gu=d.z.object({start:r.d.z,end:r.d.z});class Pr extends g.Leaf{static TYPE="range-annotation";schema=Gu;afterUpdate(e){this.internal.render=M.Context.use(e),this.internal.draw=new Te(this.internal.render.upper2d,g.use(e))}}const Ku=g.eA.payloadZ.extend({viewport:r.wu.bounds}),co=d.z.object({cursor:r.Nu.xy.or(d.z.null()),hovered:Ku.or(d.z.null()),count:d.z.number()});class Qt extends g.Leaf{static TYPE="range-provider";schema=co;fetchedInitial=r.S.ZERO;afterUpdate(e){const{internal:t}=this;t.render=M.Context.use(e),t.draw=new Te(t.render.upper2d,g.use(e)),t.requestRender=rn(e),t.runAsync=g.useErrorHandler(e),t.ranges??=new Map;const s=$e(e);if(t.requestRender("tool"),s==null)return;t.client=s;const i=$o(e,this.key);t.removeListener?.();const a=i.ranges.onSet(l=>{t.client!=null&&(r.Pu.isCrude(l.color)&&t.ranges.set(l.key,t.client.ranges.sugarOne(l)),this.setState(u=>({...u,count:t.ranges.size})),t.requestRender("tool"))}),o=i.ranges.onDelete(async l=>{t.ranges.delete(l),this.setState(u=>({...u,count:t.ranges.size})),t.requestRender("tool")});t.removeListener=()=>{a(),o()}}fetchInitial(e){const{internal:t}=this,{client:s,runAsync:i}=t;s==null||this.fetchedInitial.equals(e,r.g.minutes(1))||(this.fetchedInitial=e,i(async()=>{(await s.ranges.retrieve(e)).forEach(o=>{r.Pu.isCrude(o.color)&&t.ranges.set(o.key,o)}),this.setState(o=>({...o,count:t.ranges.size}))},"failed to fetch initial ranges"))}render(e){const{dataToDecimalScale:t,region:s,viewport:i,timeRange:a}=e;this.fetchInitial(a);const{draw:o,ranges:l}=this.internal,u=t.scale(r.vu.xBounds(s)),c=this.state.cursor==null?null:this.state.cursor.x;let h=null;const f=o.canvas.scissor(r.vu.construct({x:r.vu.left(s),y:r.vu.top(s)-35},{x:r.vu.right(s),y:r.vu.bottom(s)}));l.forEach(p=>{const y=r.Pu.colorZ.safeParse(p.color);if(!y.success)return;const b=y.data;let v=u.pos(Number(p.timeRange.start.valueOf()));const w=u.pos(Number(p.timeRange.end.valueOf()));if(w<r.vu.left(s)||v>r.vu.right(s))return;v=r.Io(v,r.vu.left(s)-2,r.vu.right(s)-1);let E=!1;c!=null&&(E=r.wu.contains({lower:v,upper:w},c)),E&&(h={key:p.key,parent:p.parent,name:p.name,color:p.color,labels:p.labels,timeRange:p.timeRange,viewport:{lower:t.scale(r.vu.xBounds(i)).pos(Number(p.timeRange.start.valueOf())),upper:t.scale(r.vu.xBounds(i)).pos(Number(p.timeRange.end.valueOf()))}}),o.container({region:r.vu.construct({x:v,y:r.vu.top(s)-1},{x:w,y:r.vu.bottom(s)-1}),backgroundColor:r.Pu.setAlpha(b,.2),bordered:!1});const R=r.vu.construct({x:v+1,y:r.vu.top(s)-34},{x:w-1,y:r.vu.top(s)-12});o.container({region:R,backgroundColor:r.vu.width(R)<20?r.Pu.setAlpha(b,.4):C=>E?C.colors.gray.l2:C.colors.gray.l0,bordered:!0,borderWidth:1,borderRadius:2,borderColor:r.Pu.setAlpha(b,.8)}),o.text({text:p.name,position:{x:v+8,y:r.vu.top(s)-30},level:"small",shade:10,weight:500,maxWidth:w-v-16})}),f(),h!=null?this.setState(p=>({...p,hovered:h})):this.state.hovered&&this.setState(p=>({...p,hovered:null}))}}const Qu={[Pr.TYPE]:Pr,[Qt.TYPE]:Qt},Ju=yt;class Jt extends oo{static TYPE="XAxis";schema=yt;render(e){if(this.deleted)return;const[t,s]=this.dataToDecimalScale(e.hold,this.dataBounds.bind(this),e.viewport);if(this.renderAxis(e,t.reverse()),this.renderYAxes(e,t),this.renderRanges(e,t),s!=null)throw s}findByXDecimal(e,t){const[s,i]=this.dataToDecimalScale(e.hold,this.dataBounds.bind(this),e.viewport);if(i!=null)throw i;return this.findByXValue(e,s.reverse().pos(t))}findByXValue(e,t){const[s,i]=this.dataToDecimalScale(e.hold,this.dataBounds.bind(this),e.viewport);if(i!=null)throw i;const a={...e,xDataToDecimalScale:s};return this.yAxes.map(o=>o.findByXValue(a,t)).flat()}renderYAxes(e,t){const s={...e,xDataToDecimalScale:t};this.yAxes.forEach(i=>i.render(s))}get yAxes(){return this.childrenOfType(Kt.TYPE)}get ranges(){return this.childrenOfType(Qt.TYPE)}bounds(e){const[t,s]=this.iBounds(e,this.dataBounds.bind(this));if(s!=null)throw s;return t}renderRanges(e,t){const s=this.bounds(e.hold),i=r.wu.min([s,r.S.MAX.numericBounds]),a=new r.S(i.lower,i.upper);this.ranges.forEach(o=>o.render({dataToDecimalScale:t,region:e.plot,viewport:e.viewport,timeRange:a}))}dataBounds(){return this.yAxes.map(e=>e.xBounds())}}const eh=r.Nu.construct(12),th=3,nh=14,sh=r.Nu.construct(6),qs=d.z.object({position:r.Nu.xy.or(d.z.null()),textColor:r.Pu.colorZ.default(r.Pu.ZERO),backgroundColor:r.Pu.colorZ.default(r.Pu.ZERO),borderColor:r.Pu.colorZ.default(r.Pu.ZERO),ruleColor:r.Pu.colorZ.default(r.Pu.ZERO),ruleStrokeWidth:d.z.number().default(1),ruleStrokeDash:d.z.number().default(0)});class it extends g.Leaf{static TYPE="tooltip";schema=qs;afterUpdate(e){const t=g.use(e);r.Pu.isZero(this.state.textColor)&&(this.state.textColor=t.colors.text),r.Pu.isZero(this.state.backgroundColor)&&(this.state.backgroundColor=t.colors.gray.l1),r.Pu.isZero(this.state.borderColor)&&(this.state.borderColor=t.colors.border),r.Pu.isZero(this.state.ruleColor)&&(this.state.ruleColor=t.colors.gray.l7),this.internal.dotColor=t.colors.text,this.internal.dotColorContrast=t.colors.textInverted,this.internal.render=M.Context.use(e),this.internal.draw=new Te(this.internal.render.upper2d,t),ie(e,"tool")}afterDelete(e){ie(e,"tool")}render(e){if(this.deleted||this.state.position==null)return;const{region:t}=e,s=r.Au.XY.scale(r.vu.DECIMAL).scale(t),i=r.Au.XY.scale(t).scale(r.vu.DECIMAL),a=e.findByXDecimal(i.x.pos(this.state.position.x)),o=a.filter(v=>r.Nu.isFinite(v.value)),{draw:l}=this.internal,u=o.reduce((v,w)=>v+w.position.x,0)/o.length,c=new r.d(o.reduce((v,w)=>v+w.value.x,0)/o.length),h=s.x.pos(u);if(!r.wu.contains(r.vu.xBounds(t),h))return;l.rule({stroke:this.state.ruleColor,lineWidth:this.state.ruleStrokeWidth,lineDash:this.state.ruleStrokeDash,direction:"y",region:t,position:h}),o.forEach(v=>{const w=s.pos(v.position);l.circle({fill:r.Pu.setAlpha(v.color,.5),radius:8,position:w}),l.circle({fill:r.Pu.setAlpha(v.color,.8),radius:5,position:w}),l.circle({fill:r.Pu.pickByContrast(v.color,this.internal.dotColor,this.internal.dotColorContrast),radius:2,position:w})});const f=i.pos(this.state.position),p={...r.Iu.TOP_LEFT};f.x>.6&&(p.x="right"),f.y>.6&&(p.y="bottom");let y=a.reduce((v,w)=>Math.max(v,w.label?.length??0),0);const b=c.toString("preciseDate","local").length;b>y&&(y=b),l.list({root:p,offset:eh,length:o.length+1,padding:sh,itemHeight:nh,spacing:th,width:y*7+48,position:this.state.position,draw:(v,w)=>{let E="",R="",C=this.state.textColor;if(v===0)E="Time",R=c.toString("preciseDate","local");else{const N=o[v-1];E=N.label??"",R=r.Ou.roundBySpan(N.value.y,N.bounds).toString(),C=N.color}l.text({position:r.vu.topLeft(w),text:E,level:"small",weight:500,color:C}),l.text({position:r.Nu.translateY(r.vu.topRight(w),-1),text:R,level:"small",justify:"right",code:!0,shade:10})}})}}const uo={[it.TYPE]:it},rh=Object.freeze(Object.defineProperty({__proto__:null,REGISTRY:uo,Tooltip:it,tooltipStateZ:qs},Symbol.toStringTag,{value:"Module"})),ho=d.z.enum(["one","two"]),Hs=d.z.object({one:r.Nu.xy.nullable(),two:r.Nu.xy.nullable(),hover:r.Nu.xy.nullable(),mode:ho.default("one"),color:d.z.union([r.Pu.colorZ,d.z.object({verticalLine:r.Pu.colorZ.default(r.Pu.ZERO),horizontalLine:r.Pu.colorZ.default(r.Pu.ZERO),obliqueLine:r.Pu.colorZ.default(r.Pu.ZERO)})]).optional().default(r.Pu.ZERO),strokeWidth:d.z.number().default(1),strokeDash:d.z.number().default(2)}),ih=n=>n==="one"?"1":"2",oh=n=>n.colors.error.z,ah=n=>n.colors.secondary.z,lh=n=>n.colors.gray.l9,Ve=6,Xe=14,Ge=8,xt=8,Et=3,ch=9,uh=8,hh=2,dh=2,fh=8,ph=5,gh=2,mh=.5,yh=.8,Ct=50,Pt=80,vh=30,bh=30,Sh=10,wh=40,Th=100,xh=30,Ee=15,Rr=8,Eh=10;class ot extends g.Leaf{static TYPE="measure";schema=Hs;afterUpdate(e){const t=M.Context.use(e);this.internal.theme=g.use(e),this.internal.renderCtx=t,this.internal.draw=new Te(t.upper2d,this.internal.theme),ie(e,"tool"),this.internal.dotColor=this.internal.theme.colors.text,this.internal.dotColorContrast=this.internal.theme.colors.textInverted}afterDelete(e){ie(e,"layout")}get verticalLineColor(){return r.Pu.isColor(this.state.color)?r.Pu.isZero(this.state.color)?this.internal.theme.colors.gray.l8:this.state.color:r.Pu.isZero(this.state.color.verticalLine)?this.internal.theme.colors.gray.l8:this.state.color.verticalLine}get horizontalLineColor(){return r.Pu.isColor(this.state.color)?r.Pu.isZero(this.state.color)?this.internal.theme.colors.gray.l8:this.state.color:r.Pu.isZero(this.state.color.horizontalLine)?this.internal.theme.colors.gray.l8:this.state.color.horizontalLine}get obliqueLineColor(){return r.Pu.isColor(this.state.color)?r.Pu.isZero(this.state.color)?this.internal.theme.colors.gray.l8:this.state.color:r.Pu.isZero(this.state.color.obliqueLine)?this.internal.theme.colors.gray.l8:this.state.color.obliqueLine}findPoint(e,t,s,i,a){const o=i!=null&&!r.Nu.equals(t,i);if(s!=null&&!o){const c=e.findByXValue(s.x).filter(h=>Number.isFinite(h.value.x)&&Number.isFinite(h.value.y));return c.length>0?c.sort((h,f)=>r.Nu.distance(s,h.value)-r.Nu.distance(s,f.value))[0]:null}const l=a.pos(t),u=e.findByXDecimal(l.x).filter(c=>Number.isFinite(c.value.x)&&Number.isFinite(c.value.y));return u.length===0?null:u.sort((c,h)=>r.Nu.distance(l,c.position)-r.Nu.distance(l,h.position))[0]}find(e){const{one:t,two:s}=this.state;if(t==null||s==null)return null;const{dataOne:i,dataTwo:a,clickOne:o,clickTwo:l}=this.internal,u=r.Au.XY.scale(e.region).scale(r.vu.DECIMAL),c=this.findPoint(e,t,i,o,u);if(c==null)return null;(o==null||!r.Nu.equals(t,o))&&(this.internal.dataOne={...c.value},this.internal.clickOne={...t});const h=this.findPoint(e,s,a,l,u);return h==null?null:((l==null||!r.Nu.equals(s,l))&&(this.internal.dataTwo={...h.value},this.internal.clickTwo={...s}),[c,h])}drawLabelValue(e,t,s,i){const{draw:a}=this.internal,o=r.Nu.construct(Ve),l=e.length*Ge,u=t.length*xt,c=l+u+o.x*Et,h=Xe+o.y*2,f=r.vu.construct(s,c,h);a.container({region:f,backgroundColor:p=>p.colors.gray.l1}),a.text({text:e,position:r.Nu.translate(r.vu.topLeft(f),o),level:"small",weight:500,color:i(this.internal.theme)}),a.text({text:t,position:r.Nu.translate(r.vu.topRight(f),[-o.x-1,o.y-1]),level:"small",justify:"right",code:!0,shade:10})}drawCombinedDeltaLabel(e,t,s,i,a,o){const{draw:l,theme:u}=this.internal,c=r.Nu.construct(Ve),h=Ge*5,f=Math.max(t.length,s.length,i.length),p=h+f*xt+c.x*Et,y=Xe,b=y*3+c.y*2;let v;if(o){const w=r.Nu.translate(e,[-p/2,-b/2]);v=r.vu.construct(w,p,b)}else if(v=r.vu.construct(e,p,b),r.vu.right(v)>r.vu.right(a)){const w=r.Nu.translateX(e,-p-Pt*2);v=r.vu.construct(w,p,b)}l.container({region:v,backgroundColor:w=>w.colors.gray.l1}),this.drawPointLabelRow({region:v,label:"ΔX",value:t,labelColor:u.colors.error.z,yOffset:0,leftOffset:0}),this.drawPointLabelRow({region:v,label:"ΔY",value:s,labelColor:u.colors.secondary.z,yOffset:y,leftOffset:0}),this.drawPointLabelRow({region:v,label:"Slope",value:i,labelColor:u.colors.gray.l9,yOffset:y*2,leftOffset:0})}drawPointLabelRow(e){const{region:t,label:s,value:i,labelColor:a,yOffset:o,leftOffset:l}=e,{draw:u}=this.internal,c=r.Nu.construct(Ve);u.text({text:s,position:r.Nu.translate(r.vu.topLeft(t),[c.x+l,c.y+o]),level:"small",weight:500,color:a}),u.text({text:i,position:r.Nu.translate(r.vu.topRight(t),[-c.x-1,c.y+o-1]),level:"small",justify:"right",code:!0,shade:10})}drawPointLabel(e){const{pointNumber:t,position:s,value:i,units:a,bounds:o,toTop:l,viewRegion:u,xDist:c}=e,{draw:h,theme:f}=this.internal,p=new r.d(i.x),y=p.toString(p.formatBySpan(c),"local"),b=`${r.Ou.roundBySpan(i.y,o)} ${a??""}`,v=`${t}`,w=v.length*Ge,E=r.Nu.construct(Ve),R=Ge,C=Math.max(y.length,b.length),N=w+Rr+R+C*xt+E.x*Et,O=Xe,T=O*2+E.y*2;let _=l?-(T+Ee):Ee,I=r.vu.construct(r.Nu.translate(s,[-N/2,_]),N,T);(l&&r.vu.top(I)<r.vu.top(u)||!l&&r.vu.bottom(I)>r.vu.bottom(u))&&(_=l?Ee:-(T+Ee),I=r.vu.construct(r.Nu.translate(s,[-N/2,_]),N,T)),h.container({region:I,backgroundColor:W=>W.colors.gray.l1}),h.text({text:v,position:r.Nu.translate(r.vu.topLeft(I),[E.x,E.y]),level:"small",weight:500,color:f.colors.gray.l9});const G=w+Rr;this.drawPointLabelRow({region:I,label:"X",value:y,labelColor:f.colors.error.z,yOffset:0,leftOffset:G}),this.drawPointLabelRow({region:I,label:"Y",value:b,labelColor:f.colors.secondary.z,yOffset:O,leftOffset:G})}drawPointMarker(e,t){const{draw:s}=this.internal;s.circle({fill:r.Pu.setAlpha(t,mh),radius:fh,position:e}),s.circle({fill:r.Pu.setAlpha(t,yh),radius:ph,position:e}),s.circle({fill:r.Pu.pickByContrast(t,this.internal.dotColor,this.internal.dotColorContrast),radius:gh,position:e})}calculateYLabelPosition(e,t,s){return t?r.Nu.translateX(e,vh):s?r.Nu.translateX(e,bh):e}calculateXLabelPosition(e,t,s){return t?r.Nu.translateY(e,wh):s?r.Nu.translateY(e,Sh):e}calculateSlopeLabelPosition(e){const{basePos:t,yLabelPos:s,isVeryClose:i,isHorizontal:a,xPixelDist:o,yPixelDist:l}=e;return i?r.Nu.translateX(t,Pt):a?r.Nu.translateY(t,-35):Math.abs(t.x-s.x)<Th&&Math.abs(t.y-s.y)<xh?o<l?r.Nu.translateY(t,-35):r.Nu.translateX(t,Pt):t}renderHover(e){if(this.state.hover==null)return;const t=this.state.hover,s=r.Au.XY.scale(e.region).scale(r.vu.DECIMAL),i=s.pos(t),a=e.findByXDecimal(s.pos(t).x);if(a.length===0)return;const o=a.sort((c,h)=>r.Nu.distance(i,c.position)-r.Nu.distance(i,h.position))[0],{draw:l}=this.internal,u=s.reverse().pos(o.position);l.circle({stroke:r.Pu.setAlpha(o.color,1),strokeWidth:hh,lineDash:dh,radius:ch,position:u}),l.circle({fill:this.internal.theme.colors.gray.l3,radius:uh,position:u}),l.text({text:ih(this.state.mode),position:u,level:"small",align:"middle",justify:"center"})}render(e){if(this.deleted)return;this.renderHover(e);const t=this.find(e);if(t==null)return;const[s,i]=t,{draw:a}=this.internal,{strokeDash:o,strokeWidth:l}=this.state,u=r.Au.XY.scale(r.vu.DECIMAL).scale(e.region),c=u.pos(s.position),h=u.pos(i.position),f=Math.abs(s.value.x-i.value.x),p=i.value.y-s.value.y,y=Math.abs(p);if(!Number.isFinite(f)||!Number.isFinite(y))return;const b=new r.g(f),v=p/b.seconds,w=Math.abs(c.x-h.x),E=Math.abs(c.y-h.y),R=E<Ct,C=w<Ct,N=w<Ct||E<Ct;a.line({start:r.Nu.construct(c.x,c.y),end:r.Nu.construct(c.x,h.y),stroke:this.verticalLineColor,lineDash:o,lineWidth:l}),a.line({start:r.Nu.construct(c.x,h.y),end:r.Nu.construct(h.x,h.y),stroke:this.horizontalLineColor,lineDash:o,lineWidth:l}),a.line({start:r.Nu.construct(c.x,c.y),end:r.Nu.construct(h.x,h.y),stroke:this.obliqueLineColor,lineDash:o,lineWidth:l}),this.drawPointMarker(c,s.color),this.drawPointMarker(h,i.color);const O=`${r.Ou.roundBySpan(y,r.wu.construct(y))} ${s.units??""}`,T=b.lessThan(r.g.milliseconds(Eh))?r.g.MICROSECOND:r.g.MILLISECOND,_=b.truncate(T).toString();let I=r.Ou.roundBySpan(v,r.wu.construct(Math.abs(v))).toString();if(s.units!=null&&s.units.length>0&&(I+=` ${s.units} / s`),N){const W=r.Nu.construct((c.x+h.x)/2,(c.y+h.y)/2),x=Ge*6,$=Math.max(_.length,O.length,I.length),Y=Ve,K=x+$*xt+Y*Et,ue=Xe*3+Y*2,te=r.vu.construct(r.Nu.translate(W,[-K/2,-ue/2]),K,ue),ne=c.y<h.y,Q=150,Z=Xe*2+Y*2,gn=ne?-55:Ee,mn=r.vu.construct(r.Nu.translate(c,[-Q/2,gn]),Q,Z),yn=ne?Ee:-55,vn=r.vu.construct(r.Nu.translate(h,[-Q/2,yn]),Q,Z),bn=r.vu.area(r.vu.intersection(te,mn))>0,Sn=r.vu.area(r.vu.intersection(te,vn))>0,vt=!bn&&!Sn,wn=vt?W:r.Nu.construct(Math.max(c.x,h.x)+Pt,(c.y+h.y)/2);this.drawCombinedDeltaLabel(wn,_,O,I,e.region,vt)}else{const W=this.calculateYLabelPosition(r.Nu.construct(c.x,(c.y+h.y)/2),N,C);this.drawLabelValue("ΔY",O,W,ah);const x=this.calculateXLabelPosition(r.Nu.construct((c.x+h.x)/2,h.y),N,R);this.drawLabelValue("ΔX",_,r.Nu.translateX(x,-15),oh);const $=this.calculateSlopeLabelPosition({basePos:r.Nu.construct((c.x+h.x)/2,(c.y+h.y)/2),yLabelPos:W,isVeryClose:N,isHorizontal:R,xPixelDist:w,yPixelDist:E});this.drawLabelValue("Slope",I,$,lh)}const G=c.y<h.y;this.drawPointLabel({pointNumber:1,position:c,value:s.value,units:s.units??null,bounds:s.bounds,toTop:G,viewRegion:e.region,xDist:b}),this.drawPointLabel({pointNumber:2,position:h,value:i.value,units:i.units??null,bounds:i.bounds,toTop:!G,viewRegion:e.region,xDist:b})}}const fo={[ot.TYPE]:ot},Ch=Object.freeze(Object.defineProperty({__proto__:null,Measure:ot,REGISTRY:fo,measureStateZ:Hs,modeZ:ho},Symbol.toStringTag,{value:"Module"})),po=d.z.object({container:r.vu.box,viewport:r.vu.box,hold:d.z.boolean().default(!1),grid:d.z.record(d.z.string(),so),visible:d.z.boolean().default(!0),clearOverScan:r.Nu.crudeZ.default(r.Nu.ZERO)}),Ph=(n,e)=>{const t=r.vu.width(n)*Math.sqrt(r.vu.height(n)),s=r.vu.width(e)*Math.sqrt(r.vu.height(e));return t/s},Rh=["upper2d","lower2d","gl"],Nh=["upper2d"];class Kn extends g.Composite{static TYPE="LinePlot";schema=po;afterUpdate(e){this.internal.instrumentation=M.useInstrumentation(e,"lineplot"),this.internal.handleError=g.useErrorHandler(e),this.internal.renderCtx=M.Context.use(e),sn(e,t=>{this.state.visible&&this.requestRender("low",t)}),!(!this.state.visible&&!this.prevState.visible)&&this.requestRender("high","layout")}afterDelete(e){this.internal.renderCtx=M.Context.use(e),this.requestRender("high","layout")}findByXDecimal(e){const t={...this.state,plot:this.calculatePlot(),exposure:this.exposure};return this.axes.flatMap(s=>s.findByXDecimal(t,e)).flat()}findByXValue(e){const t={...this.state,plot:this.calculatePlot(),exposure:this.exposure};return this.axes.flatMap(s=>s.findByXValue(t,e)).flat()}get axes(){return this.childrenOfType(Jt.TYPE)}get tooltips(){return this.childrenOfType(it.TYPE)}get measures(){return this.childrenOfType(ot.TYPE)}get bounds(){return this.childrenOfType(qt.TYPE)}get exposure(){return Ph(this.state.viewport,this.state.container)}renderAxes(e,t){const s={...this.state,plot:e,canvases:t,exposure:this.exposure};this.axes.forEach(i=>i.render(s))}renderTooltips(e,t){const s={findByXDecimal:this.findByXDecimal.bind(this),region:e,canvases:t};this.tooltips.forEach(i=>i.render(s))}renderBounds(){this.bounds.forEach(e=>e.render({getBounds:()=>{const t={};return this.axes.forEach(s=>{const i=s.state.axisKey??s.key;t[i]=s.bounds(this.state.hold),s.yAxes.forEach(a=>{const o=a.state.axisKey??a.key;t[o]=a.bounds(this.state.hold)})}),t}}))}renderMeasures(e){const t={findByXDecimal:this.findByXDecimal.bind(this),findByXValue:this.findByXValue.bind(this),region:e};this.measures.forEach(s=>s.render(t))}calculatePlot(){return zu(this.state.grid,this.state.container)}render(e){const{instrumentation:t,renderCtx:s,handleError:i}=this.internal;if(this.deleted){t.L.debug("deleted, skipping render",{key:this.key});return}if(!this.state.visible)return t.L.debug("not visible, skipping render",{key:this.key}),({canvases:h})=>s.erase(this.state.container,this.state.clearOverScan,...h);const a=this.calculatePlot();t.L.debug("rendering",{key:this.key,viewport:this.state.viewport,container:this.state.container,grid:this.state.grid,plot:a,canvases:e});const o=r.Nu.construct(this.state.clearOverScan),l=s.scissor(this.state.container,o,e.filter(h=>h!=="gl")),u=s.scissor(a,r.Nu.ZERO,e.filter(h=>h==="gl"));try{this.renderAxes(a,e),this.renderTooltips(a,e),this.renderMeasures(a),this.renderBounds()}catch(h){i(h,"failed to render line plot")}finally{l(),u()}t.L.debug("rendered",{key:this.key});const c=r.vu.copy(this.state.container);return({canvases:h})=>s.erase(c,this.state.clearOverScan,...h)}requestRender(e,t){const{renderCtx:s}=this.internal;let i=Rh;t==="tool"&&(i=Nh),s.loop.set({key:`${this.type}-${this.key}`,render:()=>this.render(i),priority:e,canvases:i})}}const Lh={[Kn.TYPE]:Kn,[Jt.TYPE]:Jt,[Kt.TYPE]:Kt,[qt.TYPE]:qt},go=d.z.object({region:r.vu.box,wheelPos:d.z.number(),scrolling:d.z.boolean(),empty:d.z.boolean(),visible:d.z.boolean(),telem:_t.default(Hr),font:pe.levelZ.default("p"),color:r.Pu.colorZ.default(r.Pu.ZERO),overshoot:r.Nu.xy.default({x:0,y:0})}),kh=.98,Ke="lower2d",_h={offset:0n,offsetRef:0n,scrollRef:0};class at extends g.Leaf{static TYPE="log";static z=go;schema=at.z;values=new r.ju([]);scrollState=_h;afterUpdate(e){const{internal:t}=this;t.render=M.Context.use(e),t.theme=g.use(e),r.Pu.isZero(this.state.color)?this.internal.textColor=t.theme.colors.gray.l11:t.textColor=this.state.color,t.telem=F(e,this.state.telem,t.telem);const{scrolling:s,wheelPos:i}=this.state;if(this.state.scrolling&&!this.prevState.scrolling){const u=this.values.alignmentBounds.upper-1n;this.scrollState={offset:u,offsetRef:u,scrollRef:this.state.wheelPos}}else if(s){const{scrollState:u,values:c}=this,h=Math.ceil((i-this.scrollState.scrollRef)/this.lineHeight);u.offset=this.values.traverseAlignment(u.offsetRef,-BigInt(h)),u.offset<c.alignmentBounds.lower+BigInt(this.visibleLineCount)&&(u.offset=c.alignmentBounds.lower,this.setState(f=>({...f,wheelPos:this.prevState.wheelPos}))),u.offset>=c.alignmentBounds.upper&&this.setState(f=>({...f,scrolling:!1}))}const[o,l]=this.internal.telem.value();this.values=l,this.checkEmpty(),t.stopListeningTelem?.(),t.stopListeningTelem=t.telem.onChange(()=>{const[u,c]=this.internal.telem.value();this.checkEmpty(),this.values=c,this.requestRender()}),!(!this.state.visible&&!this.prevState.visible)&&this.requestRender()}checkEmpty(){const e=this.values.length===0;e!==this.state.empty&&this.setState(t=>({...t,empty:e}))}afterDelete(){const{telem:e,render:t}=this.internal;e.cleanup?.(),t.erase(r.vu.construct(this.state.region),r.Nu.ZERO,Ke)}requestRender(){const{render:e}=this.internal;e.loop.set({key:`${this.type}-${this.key}`,render:()=>this.render(),priority:"high",canvases:[Ke]})}get lineHeight(){return this.internal.theme.typography[this.state.font].size*this.internal.theme.sizes.base}get totalHeight(){return Math.ceil(this.values.length*this.lineHeight)}get visibleLineCount(){return Math.min(Math.floor((r.vu.height(this.state.region)-12)/this.lineHeight),this.values.length)}render(){const{render:e}=this.internal,t=this.state.region;if(r.vu.areaIsZero(t))return;if(!this.state.visible)return()=>e.erase(t,r.Nu.ZERO,Ke);let s;if(!this.state.scrolling)s=this.values.subIterator(this.values.length-this.visibleLineCount,this.values.length);else{const c=this.values.traverseAlignment(this.scrollState.offset,-BigInt(this.visibleLineCount));s=this.values.subAlignmentSpanIterator(c,this.visibleLineCount)}const i=this.state.region,a=e[Ke],o=new Te(a,this.internal.theme),l=e.scissor(i,r.Nu.ZERO,[Ke]);this.renderElements(o,s),this.renderScrollbar(o),l();const u=r.vu.copy(this.state.region);return({canvases:c})=>e.erase(u,this.state.overshoot,...c)}renderScrollbar(e){const t=this.state.region,s=r.vu.height(t)/this.totalHeight*r.vu.height(t);if(s>=r.vu.height(t)*kh)return;let i=r.vu.bottom(t)-s;this.state.scrolling&&(i-=Number(this.values.distance(this.values.alignmentBounds.upper,this.scrollState.offset))/this.values.length*r.vu.height(t)),i<0&&(i=r.vu.top(t)),e.container({region:r.vu.construct({x:r.vu.right(t)-6,y:i},{width:6,height:s}),bordered:!1,backgroundColor:a=>a.colors.gray.l6})}renderElements(e,t){const s=this.state.region;let i=0;for(const a of t){const o=this.values.dataType.equals(r.f.JSON)?JSON.stringify(a):a.toString();e.text({text:o,level:this.state.font,shade:11,position:r.Nu.translate(r.vu.topLeft(s),{x:6,y:i*this.lineHeight+6}),code:!0}),i++}}}const Oh={[at.TYPE]:at},Ah="roles",Ih={channel:g.Mk.role.SET_CHANNEL_NAME,schema:g.Mk.role.roleZ,onChange:({store:n,changed:e})=>{n.roles.set(e.key,e)}},Mh={channel:g.Mk.role.DELETE_CHANNEL_NAME,schema:g.Mk.role.keyZ,onChange:({store:n,changed:e})=>n.roles.delete(e)},Dh={listeners:[Ih,Mh]},Yh="ranges",zh={channel:g.eA.SET_CHANNEL_NAME,schema:g.eA.payloadZ,onChange:async({store:n,changed:e,client:t})=>{const s=t.ranges.sugarOne(e),i=n.ranges.get(e.key);let a;i?.labels==null&&(a=await s.retrieveLabels());let o=null;i?.parent==null&&(o=await s.retrieveParent()),n.ranges.set(e.key,l=>t.ranges.sugarOne({...s.payload,labels:l?.labels??a,parent:l?.parent??o}))}},Zh={channel:g.eA.DELETE_CHANNEL_NAME,schema:g.eA.keyZ,onChange:({store:n,changed:e})=>n.ranges.delete(e)},Uh={equal:(n,e)=>r.qu.equal(n.payload,e.payload),listeners:[zh,Zh]},mo=d.z.object({authority:r.Lu.authorityZ.optional(),valid:d.z.boolean().optional()}).default({authority:void 0,valid:!1}),yo=d.z.object({triggered:d.z.boolean(),status:r.rl.statusZ(mo),sink:ln.default(an),source:vs.default(ms)});class Qn extends g.Leaf{static TYPE="Chip";schema=yo;afterUpdate(e){const{internal:t}=this,{sink:s,source:i}=this.state;t.source=F(e,i,t.source),t.sink=qe(e,s,t.sink),this.state.triggered&&!this.prevState.triggered&&t.sink.set(this.state.status.details?.authority!==r.Lu.ABSOLUTE_AUTHORITY),this.updateEnabledState(),t.stopListening?.(),t.stopListening=t.source.onChange(()=>this.updateEnabledState())}updateEnabledState(){const e=this.internal.source.value();r.qu.equal(e,this.state.status)||this.setState(t=>({...t,status:e,triggered:!1}))}afterDelete(){this.internal.stopListening(),this.internal.source.cleanup?.(),this.internal.sink.cleanup?.()}render(){}}const vo=d.z.object({}),Nr="control-state-provider",bo=g.Vk.stateZ.extend({subjectColor:r.Pu.colorZ});class lt extends g.Composite{static TYPE="StateProvider";schema=vo;colors=new Map;tracker;disconnectTrackerChange;obs=new r.Xu.Observer;static use(e){return e.get(Nr)}afterUpdate(e){const{internal:t}=this;t.instrumentation=M.useInstrumentation(e,"control-state");const s=g.use(e);t.palette=s.colors.visualization.palettes.default,t.defaultColor=s.colors.gray.l8;const i=$e(e);if(t.client!=null&&i===t.client)return;t.client=i,e.set(Nr,this),g.useErrorHandler(e)(async()=>{await this.maybeCloseTracker(),t.client!=null&&(this.internal.instrumentation.L.debug("starting state tracker"),await this.openTracker(t.client))},"failed to open control state tracker")}async maybeCloseTracker(){this.tracker!=null&&(this.internal.instrumentation.L.debug("stopping state tracker"),this.disconnectTrackerChange?.(),await this.tracker.close(),this.tracker=void 0)}afterDelete(e){g.useErrorHandler(e)(async()=>{await this.maybeCloseTracker()},"failed to close control state tracker")}onChange(e){return this.obs.onChange(e)}get(e){return Array.isArray(e)?r.yu.unique(e).map(t=>this.getOne(t)).filter(t=>t!=null):this.getOne(e)}getOne(e){if(this.tracker==null)return;const t=this.tracker.states.get(e);if(t!=null)return{...t,subjectColor:this.colors.get(t.subject.key)??this.internal.defaultColor}}async openTracker(e){const{internal:t}=this,{instrumentation:s}=t;try{this.tracker=await e.control.openStateTracker()}catch{s.L.error("failed to open state tracker");return}this.disconnectTrackerChange?.(),this.disconnectTrackerChange=this.tracker.onChange(i=>{if(s.L.debug("transfer",{transfers:i.map(a=>g.Vk.transferString(a))}),this.tracker==null)throw new g.Ut("tracker is null inside it's own onChange callback!");this.updateColors(this.tracker),this.obs.notify(i)})}updateColors(e){const t=e.subjects(),s=t.map(o=>o.key),i=Array.from(this.colors.values());this.colors.forEach((o,l)=>!s.includes(l)&&this.colors.delete(l));const{palette:a}=this.internal;t.forEach(o=>{if(this.colors.has(o.key))return;const l=a.find(u=>!i.includes(u))??a[0];this.colors.set(o.key,l),i.push(l)})}}const So=d.z.enum(["acquired","released","overridden","failed"]),wo=d.z.object({name:d.z.string(),authority:d.z.number().default(0),acquireTrigger:d.z.number(),status:So.optional(),needsControlOf:g.Bk.keyZ.array().default([])});class Jn extends g.Composite{static TYPE="Controller";schema=wo;registry=new Map;writer;afterUpdate(e){const{internal:t}=this;t.instrumentation=M.useInstrumentation(e),t.addStatus=g.useAdder(e),t.runAsync=g.useErrorHandler(e),(t.prevTrigger==null||Math.abs(this.state.acquireTrigger-t.prevTrigger)>1)&&(t.prevTrigger=this.state.acquireTrigger);const s=$e(e),i=lt.use(e);t.stateProv=i,t.telemCtx=Ni(e,this,t.telemCtx),t.client=s,t.runAsync(async()=>{t.client==null&&await this.release(),this.state.acquireTrigger>t.prevTrigger?await this.acquire():this.state.acquireTrigger<t.prevTrigger&&await this.release()},"failed to acquire control")}afterDelete(){const{internal:e}=this;e.runAsync(async()=>await this.release(),"failed to release control")}async updateNeedsControlOf(){const{client:e}=this.internal;if(e==null)return;const t=new Set([]);for(const i of this.registry.keys())(await i.needsControlOf(e)).forEach(o=>o!==0&&t.add(o));const s=Array.from(t);r.mu.unorderedPrimitiveArrays(this.state.needsControlOf,s)!==r.mu.EQUAL&&this.setState(i=>({...i,needsControlOf:s}))}async acquire(){this.internal.prevTrigger=this.state.acquireTrigger;const{client:e,addStatus:t}=this.internal;if(e==null)return t({message:`Cannot acquire control on ${this.state.name} because no Core has been connected.`,variant:"warning"});try{await this.updateNeedsControlOf();const s=this.state.needsControlOf;if(s.length===0)return t({message:`Cannot acquire control on ${this.state.name} because there are no channels to control.`,variant:"warning"});const i=g.m.now().sub(r.g.milliseconds(1));this.writer=await e.openWriter({start:i,channels:s,controlSubject:{key:this.key,name:this.state.name},authorities:this.state.authority}),this.setState(a=>({...a,status:"acquired"}))}catch(s){if(this.setState(i=>({...i,status:"failed"})),!(s instanceof Error))throw s;t({variant:"error",message:`${this.state.name} failed to acquire control`,description:s.message})}}async release(){this.internal.prevTrigger=this.state.acquireTrigger;try{await this.writer?.close()}catch(e){this.internal.addStatus({message:`${this.state.name} failed to release control: ${e.message}`,variant:"error"})}finally{this.setState(e=>({...e,status:"released"})),this.writer=void 0}}async set(e){this.writer==null&&await this.acquire(),await this.writer?.write(e)}async setAuthority(e,t){this.writer==null&&await this.acquire(),await this.writer?.setAuthority(Object.fromEntries(e.map(s=>[s,t])))}async releaseAuthority(e){this.writer==null&&await this.acquire(),await this.writer?.setAuthority(Object.fromEntries(e.map(t=>[t,this.state.authority])))}deleteTelem(e){this.registry.delete(e),this.updateNeedsControlOf()}create(e){const{internal:t}=this,i=(()=>{switch(e.type){case en.TYPE:{const a=new en(this,t.runAsync,e.props);return this.registry.set(a,null),a}case nn.TYPE:{const a=new nn(this,this.internal.stateProv,e.props);return this.registry.set(a,null),a}case tn.TYPE:return new tn(this,t.runAsync,e.props);default:return null}})();return i!=null&&this.updateNeedsControlOf(),i}}const To=d.z.object({channel:d.z.number()});class en extends dn{static TYPE="controlled-numeric-telem-sink";controller;runAsync;schema=To;constructor(e,t,s){super(s),this.controller=e,this.runAsync=t}invalidate(){}cleanup(){this.controller.deleteTelem(this)}async needsControlOf(e){if(this.props.channel===0)return[];const t=await e.channels.retrieve(this.props.channel),s=[t.key];return t.index!==0&&s.push(t.index),s}set(...e){this.runAsync(async()=>{const{client:t}=this.controller.internal;if(t==null)throw new g.Nk("No Core connected");if(this.props.channel===0)throw new g.V("No command channel specified for actuator");const s=await t.channels.retrieve(this.props.channel),i={[s.key]:e};if(s.index!==0){const a=await t.channels.retrieve(s.index),o=g.m.now();i[a.key]=Array.from({length:e.length},(l,u)=>o.add(r.g.nanoseconds(u)))}await this.controller.set(i)},"Failed to command channel")}}const Bh=n=>({type:en.TYPE,props:n,variant:"sink",valueType:"number"}),xo=d.z.object({authority:d.z.number().default(g.Vk.ABSOLUTE_AUTHORITY),channel:d.z.number()});class tn extends dn{static TYPE="acquire-channel-control";controller;runAsync;schema=xo;constructor(e,t,s){super(s),this.controller=e,this.runAsync=t}cleanup(){this.controller.deleteTelem(this)}async needsControlOf(e){const t=await e.channels.retrieve(this.props.channel),s=[t.key];return t.index!==0&&s.push(t.index),s}set(e){this.runAsync(async()=>{const{controller:t}=this,{client:s}=t.internal;if(s==null)return;const i=await s.channels.retrieve(this.props.channel),a=[i.key];i.index!==0&&a.push(i.index),e?await this.controller.setAuthority(a,this.props.authority):await this.controller.releaseAuthority(a)},"failed to set channel authority")}}const Fh=n=>({type:tn.TYPE,props:n,variant:"sink",valueType:"boolean"}),Eo=d.z.object({channel:d.z.number()}),$h=d.z.object({valid:d.z.boolean(),color:r.Pu.colorZ.optional(),authority:d.z.number()});class nn extends j{static TYPE="controlled-status-source";prov;valid=!1;stopListening;controller;schema=Eo;constructor(e,t,s){super(s),this.prov=t,this.controller=e}async needsControlOf(){return[]}maybeRevalidate(){if(this.valid)return;const{channel:e}=this.props;this.stopListening?.();const t=r.Lu.filterTransfersByChannelKey(e);this.stopListening=this.prov.onChange(s=>{t(s).length!==0&&this.notify?.()}),this.valid=!0}value(){this.maybeRevalidate();const e=g.m.now();if(this.props.channel===0)return{name:this.controller.key,key:this.controller.key,variant:"disabled",message:"No Channel",time:e,details:{valid:!1,authority:0}};const t=this.prov.get(this.props.channel);return t==null?{name:this.controller.key,key:this.controller.key,variant:"disabled",message:"Uncontrolled",time:e,details:{valid:!0,color:void 0,authority:0}}:{name:this.controller.key,key:t.subject.key,variant:t.subject.key===this.controller.key?"success":"error",message:`Controlled by ${t.subject.name}`,time:e,details:{valid:!0,color:t.subjectColor,authority:t.authority}}}cleanup(){this.controller.deleteTelem(this),this.stopListening?.()}}const qh=n=>({type:nn.TYPE,props:n,variant:"source",valueType:"status"}),Co=d.z.object({color:r.Pu.colorZ.optional()}).default({color:void 0}),Po=d.z.object({statusSource:vs.default(ms),colorSource:cn.default(ht),status:r.rl.statusZ(Co),color:r.Pu.colorZ.optional()});class es extends g.Leaf{static TYPE="Indicator";schema=Po;stopListeningStatus;stopListeningColor;afterUpdate(e){const{internal:t}=this,{statusSource:s,colorSource:i}=this.state;t.statusSource=F(e,s,t.statusSource),t.colorSource=F(e,i,t.colorSource),this.updateState(),this.stopListeningStatus?.(),this.stopListeningColor?.(),this.stopListeningStatus=t.statusSource.onChange(this.updateState.bind(this)),this.stopListeningColor=t.colorSource.onChange(this.updateState.bind(this))}afterDelete(){this.internal.statusSource.cleanup?.(),this.internal.colorSource.cleanup?.()}render(){}updateState(){const e=this.internal.colorSource.value(),t=this.internal.statusSource.value();r.Pu.equals(e,this.state.color)&&t.message===this.state.status.message||this.setState(s=>({...s,color:e,status:t}))}}const Ro=d.z.object({needsControlOf:g.Bk.keyZ.array(),states:bo.array()});class ts extends g.Leaf{static TYPE="Legend";schema=Ro;afterUpdate(e){const{internal:t}=this;t.stateProv=lt.use(e);const s=this.state.needsControlOf;t.disconnectStateProv?.();const i=r.Lu.filterTransfersByChannelKey(...s),a=t.stateProv.get(s);this.setState(o=>({...o,states:a})),t.disconnectStateProv=t.stateProv.onChange(o=>{if(i(o).length===0)return;const l=t.stateProv.get(s);this.setState(u=>({...u,states:l}))})}afterDelete(){const{internal:e}=this;e.disconnectStateProv?.()}render(){}}const Hh={[Jn.TYPE]:Jn,[lt.TYPE]:lt,[es.TYPE]:es,[Qn.TYPE]:Qn,[ts.TYPE]:ts},No=["fire","momentary","pulse"],jh=d.z.enum(No),Lo=d.z.object({trigger:d.z.number(),sink:ln.default(an),mode:jh.default("fire")}),ko=2,_o=1;class ns extends g.Leaf{static TYPE="Button";schema=Lo;afterUpdate(e){const{sink:t,mode:s,trigger:i}=this.state,{internal:a}=this;a.prevTrigger??=i,a.sink=qe(e,t,a.sink);const o=a.prevTrigger;a.prevTrigger=i;const l=i===o+ko;i===o+_o?s=="fire"?this.internal.sink.set(!0):s=="momentary"&&this.internal.sink.set(!1):l&&(s=="momentary"?this.internal.sink.set(!0):s=="pulse"&&this.internal.sink.set(!0,!1))}afterDelete(){this.internal.sink.cleanup?.()}}const Wh={[ns.TYPE]:ns},Vh=d.z.object({region:r.vu.box,clearOverScan:r.Nu.crudeZ.default(0),visible:d.z.boolean().default(!0),autoRenderInterval:d.z.number().default(1e3)}),Lr=["upper2d","lower2d"];class Be extends g.Composite{static TYPE="Table";static stateZ=Vh;schema=Be.stateZ;afterUpdate(e){const{internal:t}=this;t.renderCtx=M.Context.use(e),t.handleError=g.useErrorHandler(e),t.autoRenderInterval??=setInterval(()=>this.state.visible&&this.requestRender("low"),this.state.autoRenderInterval),sn(e,()=>{this.state.visible&&this.requestRender("low")}),!(!this.state.visible&&!this.prevState.visible)&&this.requestRender("high")}afterDelete(){this.internal.autoRenderInterval!=null&&clearInterval(this.internal.autoRenderInterval),this.requestRender("high")}render(){if(this.deleted)return;const e=r.vu.copy(this.state.region);if(!this.state.visible)return()=>this.internal.renderCtx.erase(e,this.state.clearOverScan);const{renderCtx:t,handleError:s}=this.internal,i=r.Au.XY.translate(r.vu.topLeft(this.state.region)),a=t.scissor(this.state.region,r.Nu.construct(this.state.clearOverScan),Lr);try{for(const o of this.children)o.render({viewportScale:i})}catch(o){s(o,"Failed to render table")}finally{a()}return()=>this.internal.renderCtx.erase(e,this.state.clearOverScan)}requestRender(e){const{renderCtx:t}=this.internal;t.loop.set({key:`${Be.TYPE}-${this.key}`,render:this.render.bind(this),priority:e,canvases:Lr})}}const Xh={[Be.TYPE]:Be};d.z.enum(["small","medium","large","huge"]);const Gh=d.z.object({box:r.vu.box,telem:un.default(gs),backgroundTelem:cn.default(ht),level:pe.levelZ.default("p"),color:r.Pu.colorZ.default(r.Pu.ZERO),precision:d.z.number().default(2),minWidth:d.z.number().default(60),width:d.z.number().optional(),notation:r.Ju.notationZ.default("standard"),location:r.Iu.xy.default({x:"left",y:"center"}),units:d.z.string().default("RPM"),bounds:r.wu.bounds.default(r.wu.construct(0,100)),barWidth:d.z.number().default(12)}),Kh=["upper2d","lower2d"];class ct extends g.Leaf{static TYPE="gauge";static z=Gh;schema=ct.z;afterUpdate(e){const{internal:t}=this;t.render=M.Context.use(e),t.theme=g.use(e),r.Pu.isZero(this.state.color)?t.textColor=t.theme.colors.gray.l8:t.textColor=this.state.color,t.telem=F(e,this.state.telem,t.telem),t.stopListening?.(),t.stopListening=t.telem.onChange(()=>this.requestRender()),t.backgroundTelem=F(e,this.state.backgroundTelem,t.backgroundTelem),t.stopListeningBackground?.(),t.stopListeningBackground=t.backgroundTelem.onChange(()=>this.requestRender()),t.requestRender=hs(e),t.strokeColor=r.Pu.isZero(this.state.color)?t.theme.colors.visualization.palettes.default[0]:this.state.color;const s=this.state.box,i=r.vu.width(s)/2,{barWidth:a}=this.state;t.outerRadius=i-8,t.innerRadius=t.outerRadius-a;const o=Math.PI/2;t.gaugeStartAngle=3*Math.PI/4,t.gaugeAngleRange=2*Math.PI-o,t.gaugeEndAngle=t.gaugeStartAngle+t.gaugeAngleRange,t.labelRadius=t.outerRadius+12,t.labelInwardShift=12,t.centerPos=r.vu.center(s);const l=t.centerPos.y+t.labelRadius*Math.sin(t.gaugeStartAngle)+6;t.minLabelPos=r.Nu.construct(t.centerPos.x+t.labelRadius*Math.cos(t.gaugeStartAngle)+t.labelInwardShift,l),t.maxLabelPos=r.Nu.construct(t.centerPos.x+t.labelRadius*Math.cos(t.gaugeEndAngle)-t.labelInwardShift,l),t.valueTextPos=r.Nu.translateY(t.centerPos,-6),t.unitsTextPos=r.Nu.translateY(t.centerPos,r.vu.height(s)/9),t.textLevel=this.state.level,t.labelLevel=pe.downLevel(pe.downLevel(t.textLevel)),this.requestRender()}afterDelete(){const{internal:e}=this;e.stopListening?.(),e.stopListeningBackground?.(),e.telem.cleanup?.(),e.backgroundTelem.cleanup?.(),e.requestRender==null?e.render.erase(r.vu.construct(this.state.box),r.Nu.ZERO,...Kh):e.requestRender("layout")}requestRender(){const{requestRender:e}=this.internal;e!=null?e("layout"):this.render({})}render({viewportScale:e=r.Au.XY.IDENTITY}){const{internal:t}=this,s=t.render.upper2d.applyScale(e),i=new Te(s,t.theme),a=t.telem.value(),{lower:o,upper:l}=this.state.bounds,u=Number(a),c=r.wu.clamp(this.state.bounds,u),h=l-o,f=h===0?0:(c-o)/h,p=t.gaugeStartAngle+f*t.gaugeAngleRange;i.text({text:a,position:t.valueTextPos,shade:10,level:t.textLevel,align:"middle",justify:"center",weight:450,code:!0,useAtlas:!0}),i.text({text:this.state.units,position:t.unitsTextPos,shade:8,level:pe.downLevel(t.textLevel),align:"middle",justify:"center",code:!0,useAtlas:!0}),i.text({text:o.toString(),position:t.minLabelPos,shade:7,level:t.labelLevel,align:"middle",justify:"center",code:!0,useAtlas:!0}),i.text({text:l.toString(),position:t.maxLabelPos,shade:7,level:t.labelLevel,align:"middle",justify:"center",code:!0,useAtlas:!0}),i.circle({stroke:t.theme.colors.gray.l5,radius:{inner:t.innerRadius,outer:t.outerRadius},position:t.centerPos,angle:{lower:t.gaugeStartAngle,upper:t.gaugeEndAngle},lineCap:"round"}),i.circle({stroke:t.strokeColor,radius:{inner:t.innerRadius,outer:t.outerRadius},position:t.centerPos,angle:{lower:t.gaugeStartAngle,upper:p},lineCap:"round"})}}const Qh={[ct.TYPE]:ct},Oo=d.z.object({trigger:d.z.number(),command:d.z.string().optional(),sink:Kr.default(qr)});class ss extends g.Leaf{static TYPE="Input";schema=Oo;afterUpdate(e){const{sink:t,trigger:s,command:i}=this.state,{internal:a}=this;a.sink=qe(e,t,a.sink);const o=a.prevTrigger??s;s>o&&i!=null&&this.internal.sink.set(i),a.prevTrigger=s}afterDelete(){this.internal.sink.cleanup?.()}}const Jh={[ss.TYPE]:ss},Ao=d.z.object({enabled:d.z.boolean(),source:ys.default(ps)});class rs extends g.Leaf{static TYPE="Light";schema=Ao;afterUpdate(e){const{internal:t}=this;this.internal.source=F(e,this.state.source,t.source),this.updateEnabledState(),t.stopListening?.(),t.stopListening=t.source.onChange(()=>this.updateEnabledState())}updateEnabledState(){const e=this.internal.source.value();e!==this.state.enabled&&this.setState(t=>({...t,enabled:e}))}afterDelete(){this.internal.stopListening?.(),this.internal.source.cleanup?.()}}const ed={[rs.TYPE]:rs},Io=d.z.object({trigger:d.z.number(),command:d.z.number().optional(),value:d.z.number(),sink:Gr.default(Fr),source:Xr.default($r)});class is extends g.Leaf{static TYPE="Setpoint";schema=Io;afterUpdate(e){const{sink:t,source:s,trigger:i,command:a}=this.state,{internal:o}=this;o.prevTrigger??=i,this.internal.source=F(e,s,this.internal.source),o.sink=qe(e,t,o.sink);const l=o.prevTrigger;o.prevTrigger=i,i>l&&a!=null&&this.internal.sink.set(a),this.updateValue(),o.stopListening?.(),o.stopListening=o.source.onChange(()=>this.updateValue())}updateValue(){const e=this.internal.source.value();e===this.state.value||isNaN(e)||this.setState(t=>({...t,value:e,triggered:!1}))}afterDelete(){const{internal:e}=this;e.stopListening?.(),e.source.cleanup?.(),e.sink.cleanup?.()}}const td={[is.TYPE]:is},Mo=d.z.object({triggered:d.z.boolean(),enabled:d.z.boolean(),sink:ln.default(an),source:ys.default(ps)});class os extends g.Leaf{static TYPE="Toggle";schema=Mo;afterUpdate(e){this.internal.addStatus=g.useOptionalAdder(e);const{sink:t,source:s,triggered:i,enabled:a}=this.state,{triggered:o}=this.prevState,{internal:l}=this;l.source=F(e,s,l.source),l.sink=qe(e,t,l.sink),i&&!o&&l.sink.set(!a),this.updateEnabledState(),l.stopListening?.(),l.stopListening=l.source.onChange(()=>this.updateEnabledState())}updateEnabledState(){const e=this.internal.source.value();e!==this.state.enabled&&this.setState(t=>({...t,enabled:e,triggered:!1}))}afterDelete(){this.internal.stopListening?.(),this.internal.source.cleanup?.(),this.internal.sink.cleanup?.()}}const nd={[os.TYPE]:os},kn={useAtlas:!0},sd=d.z.object({box:r.vu.box,telem:un.default(gs),backgroundTelem:cn.default(ht),level:pe.levelZ.default("p"),color:r.Pu.colorZ.default(r.Pu.ZERO),precision:d.z.number().default(2),stalenessTimeout:d.z.number().default(5),stalenessColor:r.Pu.colorZ.default(r.Pu.ZERO),minWidth:d.z.number().default(60),width:d.z.number().optional(),notation:r.Ju.notationZ.default("standard"),location:r.Iu.xy.default({x:"left",y:"center"}),useWidthForBackground:d.z.boolean().default(!1),valueBackgroundShift:r.Nu.xy.default(r.Nu.ZERO),valueBackgroundOverScan:r.Nu.xy.default(r.Nu.ZERO)}),rd=["upper2d","lower2d"];class Fe extends g.Leaf{static TYPE="value";static z=sd;schema=Fe.z;afterUpdate(e){const{internal:t}=this;t.renderCtx=M.Context.use(e),t.theme=g.use(e),t.telem=F(e,this.state.telem,t.telem),t.stopListening?.(),t.stopListening=t.telem.onChange(()=>{t.lastReceived=performance.now(),this.requestRender()}),t.fontString=Qe.fontString(t.theme,{level:this.state.level,code:!0}),t.backgroundTelem=F(e,this.state.backgroundTelem,t.backgroundTelem),t.stopListeningBackground?.(),t.stopListeningBackground=t.backgroundTelem.onChange(()=>this.requestRender()),t.requestRender=hs(e),this.requestRender()}afterDelete(){const{internal:e}=this;e.stopListening?.(),e.stopListeningBackground?.(),e.telem.cleanup?.(),e.backgroundTelem.cleanup?.(),e.requestRender==null?e.renderCtx.erase(r.vu.construct(this.state.box),r.Nu.ZERO,...rd):e.requestRender("layout")}requestRender(){const{requestRender:e}=this.internal;e!=null?e("layout"):this.render({})}get fontHeight(){const{theme:e}=this.internal;return e.typography[this.state.level].size*e.sizes.base}maybeUpdateWidth(e){const{theme:t}=this.internal,s=e+t.sizes.base+this.fontHeight;this.state.width==null||this.state.width+this.fontHeight*.5<s||this.state.minWidth>s&&this.state.width!==this.state.minWidth?this.setState(i=>({...i,width:Math.max(s,i.minWidth)})):this.state.width-this.fontHeight>s&&this.setState(i=>({...i,width:Math.max(s,i.minWidth)}))}getTextColor(){const{theme:e}=this.internal;return performance.now()-this.internal.lastReceived>this.state.stalenessTimeout*1e3?r.Pu.isZero(this.state.stalenessColor)?e.colors.warning.m1:this.state.stalenessColor:r.Pu.isZero(this.state.color)?r.Pu.pickByContrast(e.colors.border,e.colors.gray.l11,e.colors.gray.l0):r.Pu.pickByContrast(e.colors.border,e.colors.gray.l11,this.state.color)}render({viewportScale:e=r.Au.XY.IDENTITY}){const{renderCtx:t,telem:s,backgroundTelem:i,fontString:a,requestRender:o}=this.internal,{location:l,box:u}=this.state;if(r.vu.areaIsZero(u))return;const c=r.vu.topLeft(u),h=r.vu.width(u),f=r.vu.height(u),p=t.lower2d.applyScale(e);let y=s.value();p.font=a;const b=this.fontHeight,v=y[0]=="-";v&&(y=y.slice(1));const{theme:w}=this.internal,E=p.textDimensions(y,kn),R=E.width+w.sizes.base,C=E.height;o==null&&t.erase(r.vu.construct(this.prevState.box)),this.maybeUpdateWidth(R);const N={...r.Nu.ZERO};l.x==="left"?N.x=6+b*.75:l.x==="center"&&(N.x=h/2-R/2),l.y==="center"&&(N.y=f/2+C/2);const O=r.Nu.translate(c,N);if(this.state.backgroundTelem.type!=ht.type){const _=i.value();if(!r.Pu.isZero(_)){p.fillStyle=r.Pu.hex(_);const G=this.state.useWidthForBackground?this.state.width??this.state.minWidth:r.vu.width(u);p.fillRect(...r.Nu.couple(r.Nu.translate(c,this.state.valueBackgroundShift)),G+this.state.valueBackgroundOverScan.x,f+this.state.valueBackgroundOverScan.y)}}const T=this.getTextColor();p.fillStyle=r.Pu.hex(T),v&&p.fillText("-",...r.Nu.couple(r.Nu.translateX(O,-b*.6)),void 0,kn),p.fillText(y,...r.Nu.couple(O),void 0,kn)}}const Do={[Fe.TYPE]:Fe},id=Object.freeze(Object.defineProperty({__proto__:null,REGISTRY:Do,Value:Fe},Symbol.toStringTag,{value:"Module"}));exports.AcquireChannelControl=tn;exports.AuthoritySource=nn;exports.Base=we;exports.BaseProvider=Ye;exports.Bottom=eo;exports.BoundQuerier=qt;exports.Button=ns;exports.Canvas=$t;exports.Chip=Qn;exports.Client=Or;exports.Controller=Jn;exports.Diagram=Il;exports.Diagram$1=me;exports.FLUX_STORE_CONFIG=Dh;exports.FLUX_STORE_CONFIG$1=sa;exports.FLUX_STORE_CONFIG$2=Uh;exports.FLUX_STORE_KEY=Ah;exports.FLUX_STORE_KEY$1=ea;exports.FLUX_STORE_KEY$2=Yh;exports.Gauge=ct;exports.Indicator=es;exports.Input=ss;exports.Legend=ts;exports.Light=rs;exports.Line=Ft;exports.LinePlot=Kn;exports.Log=at;exports.MODES=No;exports.MOUSE_DOWN_INCREMENT=ko;exports.MOUSE_UP_INCREMENT=_o;exports.Measure=ot;exports.PROVIDER_TYPE=cs;exports.Provider=Nt;exports.Provider$1=Qt;exports.REGISTRY=Lh;exports.REGISTRY$1=Qh;exports.REGISTRY$10=lo;exports.REGISTRY$11=Qu;exports.REGISTRY$12=fo;exports.REGISTRY$13=Ll;exports.REGISTRY$14=ed;exports.REGISTRY$15=Jh;exports.REGISTRY$16=Yi;exports.REGISTRY$17=Hh;exports.REGISTRY$18=Di;exports.REGISTRY$19=Wh;exports.REGISTRY$2=Xh;exports.REGISTRY$3=Oh;exports.REGISTRY$4=Do;exports.REGISTRY$5=uo;exports.REGISTRY$6=nd;exports.REGISTRY$7=Ii;exports.REGISTRY$8=Ir;exports.REGISTRY$9=td;exports.RELATIONSHIPS_FLUX_STORE_KEY=jo;exports.RELATIONSHIP_FLUX_STORE_CONFIG=Go;exports.RESOURCES_FLUX_STORE_KEY=Wo;exports.RESOURCE_FLUX_STORE_CONFIG=Jo;exports.Right=no;exports.Rule=rt;exports.ScopedUnaryStore=kr;exports.SetChannelValue=en;exports.Setpoint=is;exports.StateProvider=lt;exports.Table=Be;exports.Toggle=os;exports.Tooltip=it;exports.Top=to;exports.Value=Fe;exports.XAxis=Jt;exports.YAxis=Kt;exports.ZERO_CONTEXT_VALUE=as;exports.acquireChannelControl=Fh;exports.acquireChannelControlPropsZ=xo;exports.aether=Wu;exports.authoritySource=qh;exports.authoritySourceDetailsZ=$h;exports.authoritySourceProps=Eo;exports.axisStateZ=Fs;exports.boundQuerierStateZ=zi;exports.buttonStateZ=Lo;exports.cachedRetrieveForSubject=Yr;exports.canvas=Al;exports.canvasStateZ=_s;exports.channelData=ri;exports.chipStateZ=yo;exports.chipStatusDetailsZ=mo;exports.color=Le;exports.colorGradient=Si;exports.control=sn;exports.controllerStateZ=wo;exports.coreAxisStateZ=yt;exports.createRegistry=Ho;exports.createStore=_r;exports.diagramStateZ=Os;exports.external=yl;exports.indicatorStateZ=Po;exports.indicatorStatusDetailsZ=Co;exports.interpolate=on;exports.interpolateNumber=tt;exports.interpolateRgb=In;exports.interpolateString=Br;exports.legendStateZ=Ro;exports.linePlotStateZ=po;exports.logState=go;exports.measure=Ch;exports.measureStateZ=Hs;exports.newCanvas=Ji;exports.newTickFactory=Xn;exports.parseAutoBounds=ao;exports.partialUpdate=zo;exports.provider=Fo;exports.providerStateZ=Mr;exports.providerStateZ$1=co;exports.providerStateZ$2=ks;exports.regions=fe;exports.request=ie;exports.retrieveForSubject=ra;exports.rollingAverage=vi;exports.rollingAverageProps=Rs;exports.ruleStateZ=$s;exports.scaleNumber=Ti;exports.scopeStore=_n;exports.setChannelValue=Bh;exports.setChannelValuePropsZ=To;exports.setpoint=fi;exports.sinkPipeline=ti;exports.sinkPipelinePropsZ=Ts;exports.sourcePipeline=ei;exports.sourcePipelinePropsZ=Ss;exports.stateProviderStateZ=vo;exports.stateZ=Mi;exports.stateZ$1=Oo;exports.stateZ$2=Ao;exports.stateZ$3=Io;exports.statusZ=So;exports.streamChannelData=ii;exports.streamChannelValue=oi;exports.streamChannelValuePropsZ=xs;exports.stringSourceSpecZ=un;exports.stringifyNumber=yi;exports.stringifyNumberProps=Ps;exports.sugaredStateZ=bo;exports.tickFactoryProps=Bs;exports.tickType=Us;exports.toggleStateZ=Mo;exports.tooltip=rh;exports.tooltipStateZ=qs;exports.useOptionalRequestor=hs;exports.useRequestor=rn;exports.value=id;exports.withinBounds=pi;exports.withinBoundsProps=Cs;exports.withinSizeThreshold=ro;exports.xAxisStateZ=Ju;exports.yAxisStateZ=Vu;
|
package/dist/video.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./Video-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./Video-Bmg4gwom.cjs");exports.Video=e.Video;
|
package/dist/video.js
CHANGED
package/package.json
CHANGED
|
@@ -1,29 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synnaxlabs/pluto",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.49.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@fontsource-variable/inter": "^5.2.
|
|
7
|
-
"@fontsource/geist-mono": "^5.2.
|
|
8
|
-
"@fontsource/inter": "^5.2.
|
|
6
|
+
"@fontsource-variable/inter": "^5.2.8",
|
|
7
|
+
"@fontsource/geist-mono": "^5.2.7",
|
|
8
|
+
"@fontsource/inter": "^5.2.8",
|
|
9
9
|
"@tanstack/react-virtual": "3.13.6",
|
|
10
|
-
"@xyflow/react": "^12.
|
|
10
|
+
"@xyflow/react": "^12.9.2",
|
|
11
11
|
"async-mutex": "^0.5.0",
|
|
12
12
|
"clsx": "^2.1.1",
|
|
13
13
|
"compromise": "^14.14.4",
|
|
14
14
|
"compromise-dates": "^3.7.1",
|
|
15
15
|
"d3-scale": "^4.0.2",
|
|
16
16
|
"fuse.js": "^7.1.0",
|
|
17
|
-
"mathjs": "^
|
|
17
|
+
"mathjs": "^15.1.0",
|
|
18
|
+
"pluralize": "^8.0.0",
|
|
18
19
|
"proxy-memoize": "2.0.3",
|
|
19
|
-
"react": "^19.
|
|
20
|
+
"react": "^19.2.0",
|
|
20
21
|
"react-color": "^2.19.3",
|
|
21
22
|
"react-icons": "^5.5.0",
|
|
22
|
-
"zod": "^4.1.
|
|
23
|
-
"@synnaxlabs/
|
|
24
|
-
"@synnaxlabs/
|
|
25
|
-
"@synnaxlabs/
|
|
26
|
-
"@synnaxlabs/
|
|
23
|
+
"zod": "^4.1.12",
|
|
24
|
+
"@synnaxlabs/freighter": "0.49.0",
|
|
25
|
+
"@synnaxlabs/alamos": "^0.49.0",
|
|
26
|
+
"@synnaxlabs/client": "^0.49.0",
|
|
27
|
+
"@synnaxlabs/x": "^0.49.0"
|
|
27
28
|
},
|
|
28
29
|
"devDependencies": {
|
|
29
30
|
"@juggle/resize-observer": "^3.4.0",
|
|
@@ -31,23 +32,24 @@
|
|
|
31
32
|
"@testing-library/user-event": "^14.6.1",
|
|
32
33
|
"@types/d3-scale": "^4.0.9",
|
|
33
34
|
"@types/offscreencanvas": "^2019.7.3",
|
|
34
|
-
"@types/
|
|
35
|
+
"@types/pluralize": "^0.0.33",
|
|
36
|
+
"@types/react": "^19.2.2",
|
|
35
37
|
"@types/react-color": "^3.0.13",
|
|
36
|
-
"@types/react-dom": "^19.
|
|
38
|
+
"@types/react-dom": "^19.2.2",
|
|
37
39
|
"@types/webgl2": "^0.0.11",
|
|
38
|
-
"@vitejs/plugin-react": "^5.0
|
|
40
|
+
"@vitejs/plugin-react": "^5.1.0",
|
|
39
41
|
"@vitest/coverage-v8": "^3.2.4",
|
|
40
|
-
"eslint": "^9.
|
|
41
|
-
"jsdom": "^27.
|
|
42
|
+
"eslint": "^9.39.1",
|
|
43
|
+
"jsdom": "^27.1.0",
|
|
42
44
|
"madge": "^8.0.0",
|
|
43
|
-
"react-dom": "^19.
|
|
44
|
-
"typescript": "^5.9.
|
|
45
|
-
"vite": "^7.1.
|
|
45
|
+
"react-dom": "^19.2.0",
|
|
46
|
+
"typescript": "^5.9.3",
|
|
47
|
+
"vite": "^7.1.12",
|
|
46
48
|
"vitest": "^3.2.4",
|
|
49
|
+
"@synnaxlabs/tsconfig": "^0.43.0",
|
|
47
50
|
"@synnaxlabs/vite-plugin": "^0.43.0",
|
|
48
51
|
"eslint-config-synnaxlabs": "^0.43.0",
|
|
49
|
-
"stylelint-config-synnaxlabs": "^0.43.0"
|
|
50
|
-
"@synnaxlabs/tsconfig": "^0.43.0"
|
|
52
|
+
"stylelint-config-synnaxlabs": "^0.43.0"
|
|
51
53
|
},
|
|
52
54
|
"files": [
|
|
53
55
|
"dist"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const q=require("./jsx-runtime-Dszzpdy0.cjs"),e=require("./css-HnNQMUzV.cjs"),l=require("react"),U=require("./Box-BvqALodh.cjs"),L=require("./Editable-BXFY3-UW.cjs"),Ce=require("./hooks-CoF3Fkrn.cjs"),$=require("./Text-DY08sSZe.cjs"),Ee=require("./types-D-yz1qsT.cjs");require("./Provider-BV7nN39a.cjs");const xe=require("./provider-lNhTlIWj.cjs"),Te=require("./debounce-heEWeOqL.cjs"),J=({ref:t,onClickOutside:n,exclude:o})=>{const g=L.useSyncedRef(o),r=l.useCallback(c=>{const s=t.current,u=e.jt.construct(window.document.documentElement),d=e.Q.construct(c),i=g.current;if(i!=null){if(typeof i=="function"){if(i(c))return}else if(i.some(a=>a.current?.contains(c.target)))return}s==null||s.contains(c.target)||e.jt.contains(s,d)||!e.jt.contains(u,d)||n()},[n]);l.useEffect(()=>(document.addEventListener("mousedown",r),()=>document.removeEventListener("mousedown",r)),[r])},ee=t=>{const n=l.use(t);if(n==null)throw new xe.Pr(`useRequiredContext: context value is null for ${t.displayName}`);return n},D=(t,n={})=>{const{triggers:o=[],debounce:g=0,enabled:r=!0}=n,c=l.useRef(e.jt.ZERO),s=l.useRef(null),u=l.useRef(null),d=$.useMemoCompare(()=>o,$.compareArrayDeps,[o]),i=l.useCallback(a=>{u.current!=null&&u.current.disconnect(),c.current??=e.jt.ZERO;const C=Te.o(()=>{const f=e.jt.construct(a);me(d,c.current,f)&&(c.current=f,t(f,s.current))},g);u.current=new ResizeObserver(C),u.current.observe(a)},[d,t,g]);return l.useEffect(()=>(s.current!=null&&r&&i(s.current),()=>u.current?.disconnect()),[i,r]),l.useCallback(a=>{s.current=a,a!=null&&r&&i(a)},[i])},me=(t,n,o)=>t.length===0?!e.jt.equals(o,n):!!(t.includes("x")&&e.jt.width(n)!==e.jt.width(o)||t.includes("y")&&e.jt.height(n)!==e.jt.height(o)),te=t=>{const n=L.useSyncedRef(t);l.useEffect(()=>{const o=()=>n.current(e.jt.construct(window.innerWidth,window.innerHeight),window.document.documentElement);return window.addEventListener("resize",o),()=>window.removeEventListener("resize",o)},[])},z=e.CSS.BE("dialog","bg"),he=({children:t,visible:n,...o})=>q.jsxRuntimeExports.jsx(U.Box$1,{className:e.CSS(z,e.CSS.visible(n)),empty:!0,align:"center",...o,children:t}),b=t=>t==null?{x:void 0,y:void 0}:typeof t!="string"?t:e.p.isX(t)?{x:t,y:void 0}:{x:void 0,y:t},A=t=>typeof t=="string"||"x"in t||"y"in t?{targetCorner:t,dialogCorner:void 0}:t,ye=({initial:t,prefer:n=[],disable:o=[]})=>{const g=e.a.toArray(n).map(A),r=e.a.toArray(o).map(A),c=[];if(t!=null){const s=A(t),u=b(s.targetCorner),d=b(s.dialogCorner);e.K.XY_LOCATIONS.forEach(a=>{e.K.xyEquals(a,e.K.CENTER)||u.x!=null&&a.x!==u.x||u.y!=null&&a.y!==u.y||e.K.XY_LOCATIONS.forEach(C=>{if(e.K.xyEquals(C,e.K.CENTER)||d.x!=null&&C.x!==d.x||d.y!=null&&C.y!==d.y)return;const f={targetCorner:a,dialogCorner:C};c.push(f)})});const i=c.filter(a=>!k(a,r));return i.length==0?c.slice(0,1):i}return g.forEach(s=>{const u=b(s.targetCorner),d=b(s.dialogCorner);e.K.XY_LOCATIONS.forEach(i=>{e.K.xyEquals(i,e.K.CENTER)||e.K.xyMatches(i,u)&&e.K.XY_LOCATIONS.forEach(a=>{if(e.K.xyEquals(a,e.K.CENTER)||!e.K.xyMatches(a,d))return;const C={targetCorner:i,dialogCorner:a};!k(C,r)&&!c.some(f=>e.K.xyEquals(f.targetCorner,i)&&e.K.xyEquals(f.dialogCorner,a))&&c.push(C)})})}),e.K.XY_LOCATIONS.forEach(s=>{e.K.xyEquals(s,e.K.CENTER)||e.K.XY_LOCATIONS.forEach(u=>{if(e.K.xyEquals(u,e.K.CENTER))return;const d={targetCorner:s,dialogCorner:u};!k(d,r)&&!c.some(i=>e.K.xyEquals(i.targetCorner,s)&&e.K.xyEquals(i.dialogCorner,u))&&c.push(d)})}),c},k=(t,n)=>n.some(o=>{const g=b(o.targetCorner),r=b(o.dialogCorner);return e.K.xyEquals(o.dialogCorner,e.K.CENTER)?e.K.xyMatches(t.targetCorner,g):e.K.xyMatches(t.targetCorner,g)&&e.K.xyMatches(t.dialogCorner,r)}),ne=({container:t,target:n,dialog:o,initial:g,prefer:r,disable:c,offset:s})=>{const u=ye({initial:g,prefer:r,disable:c}),d=e.jt.construct(t),i=e.jt.construct(n),a=e.jt.construct(o),C=u.reduce((f,T)=>{const m=Re({...T,container:d,target:i,dialog:a,offset:s});return m.area>f.area?m:f},{area:-1/0,targetCorner:e.K.CENTER,dialogCorner:e.K.CENTER,adjustedDialog:a});return{targetCorner:C.targetCorner,dialogCorner:C.dialogCorner,adjustedDialog:C.adjustedDialog}},Re=({targetCorner:t,dialogCorner:n,container:o,target:g,dialog:r,offset:c})=>{let s=e.jt.xyLoc(g,t);if(c!=null){const i=e.Q.construct(c);t.x===n.x&&(i.x=0),t.y===n.y&&(i.y=0),s=e.Q.translate(s,t,i)}const u=e.jt.constructWithAlternateRoot(s.x,s.y,e.jt.width(r),e.jt.height(r),n,e.K.TOP_LEFT);let d=e.jt.area(e.jt.intersection(u,o));return e.jt.area(e.jt.intersection(g,u))!==0&&(d=0),{targetCorner:t,dialogCorner:n,adjustedDialog:u,area:d}},je=e.CSS.BM("context","selected"),Se=e.CSS.BE("context","target"),re=e.CSS.B("menu-context"),Oe={targetCorner:e.K.BOTTOM_LEFT,dialogCorner:e.K.BOTTOM_LEFT,style:{},modalPosition:"base"},oe=l.createContext({close:()=>{},open:()=>{},toggle:()=>{},variant:"floating",visible:!1,location:e.K.BOTTOM_LEFT}),se=l.createContext(null),be=()=>ee(se),Ke=()=>l.useContext(oe),pe=[["Escape"]],Ne=(t,n,o)=>{if(o==null)return!1;const r=Math.abs(e.jt.left(n)-e.jt.left(o))<=1&&Math.abs(e.jt.top(n)-e.jt.top(o))<=1;if(t==="floating")return r;const c=Math.abs(e.jt.width(n)-e.jt.width(o))<=1;return r&&c},Q=[{targetCorner:e.K.BOTTOM_LEFT,dialogCorner:e.K.TOP_LEFT},{targetCorner:e.K.TOP_LEFT,dialogCorner:e.K.BOTTOM_LEFT},{targetCorner:e.K.BOTTOM_RIGHT,dialogCorner:e.K.TOP_RIGHT},{targetCorner:e.K.TOP_RIGHT,dialogCorner:e.K.BOTTOM_RIGHT},{targetCorner:e.K.TOP_RIGHT,dialogCorner:e.K.TOP_LEFT}],Le=(t,n)=>t/n>.8?"slammed":t/n>.6?"shifted":"base",ie=({children:t,location:n,onPointerEnter:o,className:g,variant:r="floating",maxHeight:c,zIndex:s,initialVisible:u=!1,visible:d,onVisibleChange:i,modalPosition:a="base",...C})=>{const[f,T]=Ee.usePassthrough({initial:u,value:d,onChange:i}),m=l.useCallback(()=>T(!1),[T]),F=l.useCallback(()=>T(!0),[T]),X=l.useCallback(()=>T(E=>!E),[T]),w=L.useSyncedRef(f),p=l.useRef(null),P=l.useRef(void 0),G=l.useRef(void 0),h=l.useRef(null),[{targetCorner:R,dialogCorner:B,style:H,modalPosition:Y},W]=l.useState({...Oe,modalPosition:a}),v=l.useCallback(()=>{if(p.current==null||h.current==null||!w.current)return;const E=e.jt.construct(p.current);if(e.jt.areaIsZero(E)&&r!=="modal")return T(!1);let x=e.jt.construct(h.current);r==="connected"&&(x=e.jt.resize(x,"x",e.jt.width(E)));const j=e.jt.construct(0,0,window.innerWidth,window.innerHeight);if(r==="modal"){const M=Le(e.jt.height(x),e.jt.height(j));return W(I=>M===I.modalPosition?I:{...I,modalPosition:M})}let S=Q;P.current!=null&&(S=[P.current,...Q]);const{adjustedDialog:y,...N}=ne({target:E,dialog:x,container:j,prefer:S,initial:n,offset:3});P.current=N;const{targetCorner:_,dialogCorner:Z}=N,K=e.jt.round(y);if(Ne(r,K,G.current))return;G.current=K;const O={};O.left=e.jt.left(K),_.y==="top"&&Z.x===_.x?O.bottom=e.jt.height(j)-e.jt.bottom(K):O.top=e.jt.top(K),r==="connected"&&(O.width=e.jt.width(K)),typeof c=="number"&&(O.maxHeight=c),f&&(O.zIndex=s),W(M=>({...M,targetCorner:_,dialogCorner:Z,style:O}))},[n,r]),ce=D(v,{enabled:f}),V=L.useCombinedRefs(h,ce),ue=D(v,{enabled:f}),le=L.useCombinedRefs(p,ue);te(v);const ae=l.useCallback(E=>{if(!w.current||h.current==null||p.current==null)return!0;if(r!=="modal"){const S=h.current.getElementsByClassName(e.CSS.visible(!0));let y=S!=null&&S.length>0;return y||(y=p.current.contains(E.target)),document.getElementsByClassName(re).length>0&&(y=!0),y||E.stopImmediatePropagation(),y}if(!(E.target instanceof HTMLElement))return!0;let x=E.target;return x.className.includes(z)&&(x=x.children[0]),x!==h.current},[s,w]),de=l.useCallback(({stage:E})=>{if(E!=="start"||w.current===!1||h.current==null)return;if(r!=="modal")return m();const x=h.current,j=Array.from(document.getElementsByClassName(z)),S=j.findIndex(N=>N.contains(x)),y=x.getElementsByClassName(e.CSS.visible(!0));if(S===j.length-1&&y.length===0)return m()},[m,r]);J({ref:h,exclude:ae,onClickOutside:m}),Ce.use({triggers:pe,callback:de,loose:!0});const fe=l.useMemo(()=>({ref:V,targetCorner:R,dialogCorner:B,style:H,modalPosition:Y}),[V,R,B,H,Y]),ge=l.useMemo(()=>({close:m,open:F,toggle:X,visible:f,onPointerEnter:o,variant:r,location:R}),[m,F,X,f,R]);return q.jsxRuntimeExports.jsx(oe.Provider,{value:ge,children:q.jsxRuntimeExports.jsx(se.Provider,{value:fe,children:q.jsxRuntimeExports.jsx(U.Box$1,{...C,ref:le,className:e.CSS(g,e.CSS.BE("dialog","frame"),e.CSS.visible(f),e.CSS.M(r),e.CSS.loc(R.x),e.CSS.loc(R.y),e.CSS.BEM("dialog","dialog",B.x),e.CSS.BEM("dialog","dialog",B.y)),y:!0,reverse:R.y==="top",children:t})})})};ie.displayName="Dialog.Frame";exports.Background=he;exports.CONTEXT_MENU_CLASS=re;exports.CONTEXT_SELECTED=je;exports.CONTEXT_TARGET=Se;exports.Frame=ie;exports.parseLocationOptions=b;exports.position=ne;exports.useClickOutside=J;exports.useContext=Ke;exports.useInternalContext=be;exports.useRequiredContext=ee;exports.useResize=D;exports.useWindowResize=te;
|
package/dist/Box-BvqALodh.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const w=require("./jsx-runtime-Dszzpdy0.cjs"),e=require("./css-HnNQMUzV.cjs"),j=require("zod"),A=require("react"),a=({el:r,children:t,...u})=>A.createElement(r,u,t),V=Object.freeze(Object.defineProperty({__proto__:null,Element:a},Symbol.toStringTag,{value:"Module"})),p=["start","center","end","stretch"],D=j.enum(p),_=["start","center","end","between","around","evenly"],F=j.enum(_),N=(r,t)=>t??(r==="right"||r==="bottom"),C=(r,t,u,S)=>{if(t===!0)return"x";if(u===!0)return"y";if(r!=null)return e.p.construct(r);if(S==!0)return"x"},L=r=>r==null||r===!1?!1:r===!0?e.CSS.M("full"):e.CSS.M("full",r),g=({style:r,align:t,className:u,grow:S,shrink:f,gap:i,color:o,justify:M,reverse:v,empty:E,pack:m,wrap:T,center:q,direction:b,rounded:c,sharp:y,borderWidth:B,borderColor:l,full:G,background:s,bordered:I,x:O,y:R,size:h,square:$=!1,...x})=>{const d=C(b,O,R,m),n=[u,e.CSS.B("flex"),d!=null&&e.CSS.M("direction",d),N(b,v)&&e.CSS.M("reverse"),L(G),m&&e.CSS.M("pack"),M!=null&&e.CSS.M("justify",M),t!=null&&e.CSS.M("align",t),T===!0&&e.CSS.M("wrap"),E===!0&&e.CSS.M("empty"),q===!0&&e.CSS.M("center"),I===!0&&e.CSS.M("bordered"),y===!0&&e.CSS.M("sharp"),h!=null&&e.CSS.M("height",h),$===!0&&e.CSS.M("square")];return r={borderWidth:B,...r},typeof o=="number"?n.push(e.CSS.M("color",o.toString())):o!=null&&o!==!1&&(r.color=e.CSS.colorVar(o)),typeof s=="number"?n.push(e.CSS.M("bg",s.toString())):s!=null&&s!==!1&&(r.backgroundColor=e.CSS.colorVar(s)),typeof l=="number"?n.push(e.CSS.M("border-color",l.toString())):l!=null&&(r.borderColor=e.CSS.colorVar(l)),c===!0?n.push(e.CSS.M("rounded")):typeof c=="number"&&(r.borderRadius=`${c}rem`),typeof i=="number"?r.gap=`${i}rem`:i!=null&&n.push(e.CSS.M("gap",i)),typeof S=="number"?r.flexGrow=S:S===!0&&n.push(e.CSS.M("grow")),typeof f=="number"?r.flexShrink=f:f===!0&&n.push(e.CSS.M("shrink")),w.jsxRuntimeExports.jsx(a,{className:e.CSS(...n),style:r,...x,el:x.el??"div"})},P=Object.freeze(Object.defineProperty({__proto__:null,ALIGNMENTS:p,Box:g,JUSTIFICATIONS:_,alignmentZ:D,justificationZ:F,parseDirection:C,shouldReverse:N},Symbol.toStringTag,{value:"Module"}));exports.ALIGNMENTS=p;exports.Box=P;exports.Box$1=g;exports.Element=a;exports.Generic=V;exports.parseDirection=C;
|
package/dist/Button-BMeq9Z2I.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const f=require("./jsx-runtime-Dszzpdy0.cjs"),e=require("./css-HnNQMUzV.cjs"),l=require("react"),F=require("./Text-DY08sSZe.cjs"),q=require("./Editable-BXFY3-UW.cjs"),k=require("./types-D-yz1qsT.cjs"),ee=require("./Provider-BV7nN39a.cjs");require("./provider-lNhTlIWj.cjs");const te=require("react-dom"),ne=require("./hooks-CoF3Fkrn.cjs"),oe={delay:e.a$1.milliseconds(750),startAccelerating:()=>{}},Z=l.createContext(oe),X=()=>l.use(Z),se=({delay:t=e.a$1.milliseconds(700),accelerate:n=!0,acceleratedDelay:r=e.a$1.minutes(60),accelerationDelay:c=e.a$1.seconds(0),children:i})=>{const[u,o]=l.useState(!1),a=l.useRef(null),E=l.useCallback(()=>{u||!n||(o(!0),a.current=setTimeout(()=>{o(!1)},new e.a$1(c).milliseconds))},[u,c]),T=l.useMemo(()=>u?r:t,[u,r,t]),O=l.useMemo(()=>({delay:T,startAccelerating:E}),[T,E]);return f.jsxRuntimeExports.jsx(Z,{value:O,children:i})},re=t=>({key:n,...r})=>l.createElement(t,{...r,key:n}),H=t=>typeof t=="function",le=150,V=["top","bottom"],Y=["left","right"],G=[...Y,...V],Q=[...G,"center"],ce={[e.K.xyToString(e.K.TOP_RIGHT)]:(t,n)=>e.Q.translate(t,"x",-e.jt.width(n)),[e.K.xyToString(e.K.TOP_LEFT)]:(t,n)=>e.Q.translate(t,"x",e.jt.width(n)),[e.K.xyToString(e.K.BOTTOM_RIGHT)]:(t,n)=>e.Q.translate(t,"x",-e.jt.width(n)),[e.K.xyToString(e.K.BOTTOM_LEFT)]:(t,n)=>e.Q.translate(t,"x",e.jt.width(n))},$=(t,n,r)=>{for(const c of r)if(Math.abs(e.jt.loc(n,c)-e.jt.loc(t,c))>le)return c;return r[0]},U=(t,n,r)=>{const c=e.K.location.safeParse(t),i=o=>{let a;return o==="center"?a=G:e.K.isX(o)?a=["center",...V]:a=["center",...Y],e.K.construct($(n,r,a))};if(c.success)return e.K.constructXY(c.data,i(c.data));if(t!=null){const o={...t};return o.x==null&&o.y!=null?o.x=i(e.K.construct(o.y)):o.y==null&&o.x!=null?o.y=i(e.K.construct(o.x)):o.x==null&&o.y==null&&(o.x=$(n,r,Q),o.y=i(e.K.construct(o.x))),e.K.constructXY(o)}const u=$(n,r,Q);return e.K.constructXY(u,i(u))},ue=(t,n)=>{let r=t;for(;r!=null;){if(r.id===n)return r;r=r.parentElement}return t},W=({delay:t,children:n,location:r,hide:c=!1})=>{const{startAccelerating:i,delay:u}=X(),o=new e.a$1(t??u),[a,E,T]=q.useCombinedStateAndRef(null),[O,g]=l.useState(""),L=l.useRef(null),w=l.useId(),p=l.useRef(null),R=l.useRef(null),d=l.useCallback(s=>{s==null&&T.current==null||R.current!=null||(s!=null?(E(s),R.current=setTimeout(()=>{g(e.CSS.M("loaded")),R.current=null},1)):(g(""),R.current=setTimeout(()=>{E(null),R.current=null},500)))},[]),C=l.useCallback((s,y)=>{if(!y||c)return p.current?.(),d(null);i();const m=e.jt.construct(ue(s.target,w));e.jt.contains(m,e.Q.construct(s))||(p.current?.(),d(null));const M=e.jt.construct(document.documentElement),K=U(r,m,M);let x=e.jt.xyLoc(m,K);const b=ce[e.K.xyToString(K)];b!=null&&(x=b(x,m));const A=e.jt.construct(document.body);d({location:K,position:e.Q.translate(x,e.Q.scale(e.jt.topLeft(A),-1)),triggerDims:e.jt.dims(m)}),p.current?.();const h=B=>{const D=e.Q.construct(B);e.jt.contains(m,D)||(d(null),document.removeEventListener("mousemove",h),p.current=null,L.current!=null&&clearTimeout(L.current))};document.addEventListener("mousemove",h),p.current=()=>document.removeEventListener("mousemove",h),document.addEventListener("mousedown",()=>{d(null),p.current?.()},{once:!0})},[i,r,c,w,o.milliseconds]);c&&a!=null&&d(null);const P=l.useCallback(s=>{L.current=setTimeout(()=>C(s,!0),o.milliseconds)},[C,o.milliseconds]),N=l.useCallback(s=>{L.current!=null&&clearTimeout(L.current),C(s,!1)},[C]),[_,j]=n,I=document.body;return f.jsxRuntimeExports.jsxs(f.jsxRuntimeExports.Fragment,{children:[a!=null&&te.createPortal(f.jsxRuntimeExports.jsx("div",{className:e.CSS(e.CSS.B("tooltip"),e.CSS.loc(a.location.x),e.CSS.loc(a.location.y),O),style:{[e.CSS.var("pos-x")]:e.CSS.px(a.position.x),[e.CSS.var("pos-y")]:e.CSS.px(a.position.y)},children:H(_)?_(a):J(_)},w),I),l.cloneElement(j,{onMouseEnter:s=>{P(s),j.props.onMouseEnter?.(s)},onMouseLeave:s=>{N(s),j.props.onMouseLeave?.(s)},onMouseDown:l.useCallback(s=>{N(s),j.props.onMouseDown?.(s)},[C])})]})},J=t=>typeof t=="string"||typeof t=="number"||!l.isValidElement(t)?f.jsxRuntimeExports.jsx(q.Text,{level:"small",color:11,weight:450,children:t}):t,z=t=>{const n=({tooltipDelay:r,tooltip:c,tooltipLocation:i,...u})=>{const o=f.jsxRuntimeExports.jsx(t,{...u});return c==null?o:f.jsxRuntimeExports.jsxs(W,{delay:r,location:i,children:[c,o]})};return n.displayName=`Tooltip.Wrap(${t.displayName??t.name})`,n},v="btn",ie=(t,n)=>{if(t===!0)return n;if(t!=null&&t!==!1)return t},ae=({size:t,variant:n="outlined",className:r,disabled:c,preventClick:i,level:u,trigger:o,triggerIndicator:a,onClickDelay:E=0,onClick:T,color:O,status:g,style:L,onMouseDown:w,textColor:p,textVariant:R,tabIndex:d,contrast:C,children:P,defaultEl:N="button",el:_,ghost:j,...I})=>{const s=e.a$1.fromMilliseconds(E),y=c===!0||g==="loading"||g==="disabled";n==="preview"&&(i=!0),(c||i&&d==null)&&(d=-1);const m=S=>{if(!(y||n==="preview"||i===!0)&&s.isZero)return T?.(S)},M=l.useRef(null),K=S=>{d==-1&&S.preventDefault(),w?.(S),!(y||n==="preview"||s.isZero)&&(document.addEventListener("mouseup",()=>M.current!=null&&clearTimeout(M.current)),M.current=setTimeout(()=>{T?.(S),M.current=null},s.milliseconds))};ne.use({triggers:o,callback:l.useCallback(({stage:S})=>{S!=="end"||y||n==="preview"||m(new MouseEvent("click"))},[m,y])});let x=L;const b=e.Lr.colorZ.safeParse(O),A=b.success&&(n==="filled"||n==="outlined");if(A){const S=ee.use();x={...x,[e.CSS.var("btn-color")]:e.Lr.rgbString(b.data),[e.CSS.var("btn-text-color")]:e.Lr.rgbCSS(e.Lr.pickByContrast(b.data,S.colors.text,S.colors.textInverted))}}s.isZero||(x={...x,[e.CSS.var("btn-delay")]:`${s.seconds.toString()}s`}),t==null&&u!=null?t=k.LEVEL_COMPONENT_SIZES[u]:t!=null&&u==null?u=k.COMPONENT_SIZE_LEVELS[t]:N!=="div"&&(t??="medium"),u??="p";const h=g==="loading",B=q.isSquare(P),D=ie(a,o);return f.jsxRuntimeExports.jsxs(q.Text,{el:_,defaultEl:N,direction:"x",className:e.CSS(e.CSS.B(v),C!=null&&e.CSS.BM(v,`contrast-${C}`),i===!0&&e.CSS.BM(v,"prevent-click"),n!=="preview"&&e.CSS.disabled(y),e.CSS.BM(v,n),A&&e.CSS.BM(v,"custom-color"),j&&e.CSS.BM(v,"ghost"),r),size:t,tabIndex:d,onClick:m,onMouseDown:K,style:x,color:p,gap:t==="small"||t==="tiny"?"small":void 0,bordered:n!=="text",level:u,variant:R,square:B,overflow:"nowrap",status:g,...e.l.purgeUndefined(I),children:[(!h||!B)&&P,h&&f.jsxRuntimeExports.jsx(F.Loading,{}),D!=null&&f.jsxRuntimeExports.jsx(F.Text,{className:e.CSS.B("trigger-indicator"),"aria-label":"trigger-indicator",trigger:D,color:9,gap:"tiny",level:k.downLevel(u)})]})},de=z(ae);exports.Button=de;exports.Config=se;exports.Dialog=W;exports.chooseLocation=U;exports.formatTip=J;exports.isRenderProp=H;exports.renderProp=re;exports.useConfig=X;exports.wrap=z;
|