@toclocoinc/lattice-grid 1.115.0 → 1.115.2
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/CHANGELOG.md +12 -0
- package/README.md +1 -1
- package/angular/package.json +1 -1
- package/docs/API.html +4 -4
- package/docs/api/adapters.html +1 -1
- package/docs/api/ai.html +1 -1
- package/docs/api/alarms.html +1 -1
- package/docs/api/calendar.html +1 -1
- package/docs/api/charts.html +1 -1
- package/docs/api/dashboard.html +1 -1
- package/docs/api/data-router.html +1 -1
- package/docs/api/dataview.html +1 -1
- package/docs/api/deckgl.html +1 -1
- package/docs/api/designer.html +1 -1
- package/docs/api/form.html +1 -1
- package/docs/api/gantt.html +1 -1
- package/docs/api/geometry.html +1 -1
- package/docs/api/grid.html +2 -2
- package/docs/api/index.html +1 -1
- package/docs/api/kanban.html +1 -1
- package/docs/api/kpi.html +1 -1
- package/docs/api/layout.html +1 -1
- package/docs/api/leaflet.html +1 -1
- package/docs/api/list.html +1 -1
- package/docs/api/listview.html +1 -1
- package/docs/api/mapview.html +1 -1
- package/docs/api/mock-socket.html +1 -1
- package/docs/api/presets.html +1 -1
- package/docs/api/scheduler.html +1 -1
- package/docs/api/shell.html +1 -1
- package/docs/api/tabs.html +1 -1
- package/docs/api/tree.html +1 -1
- package/docs/api/types.html +1 -1
- package/docs/api-detail.html +5 -5
- package/docs/warnings.json +1 -1
- package/lattice-grid.d.ts +1 -1
- package/lattice-grid.esm.min.js +2 -2
- package/lattice-grid.min.cjs +2 -2
- package/lattice-grid.min.js +2 -2
- package/locales/all.d.ts +1 -1
- package/locales/all.esm.min.js +1 -1
- package/locales/all.min.cjs +1 -1
- package/locales/all.min.js +1 -1
- package/locales/ar.d.ts +1 -1
- package/locales/ar.esm.min.js +1 -1
- package/locales/ar.min.cjs +1 -1
- package/locales/ar.min.js +1 -1
- package/locales/cs-CZ.d.ts +1 -1
- package/locales/cs-CZ.esm.min.js +1 -1
- package/locales/cs-CZ.min.cjs +1 -1
- package/locales/cs-CZ.min.js +1 -1
- package/locales/da-DK.d.ts +1 -1
- package/locales/da-DK.esm.min.js +1 -1
- package/locales/da-DK.min.cjs +1 -1
- package/locales/da-DK.min.js +1 -1
- package/locales/de-DE.d.ts +1 -1
- package/locales/de-DE.esm.min.js +1 -1
- package/locales/de-DE.min.cjs +1 -1
- package/locales/de-DE.min.js +1 -1
- package/locales/el-GR.d.ts +1 -1
- package/locales/el-GR.esm.min.js +1 -1
- package/locales/el-GR.min.cjs +1 -1
- package/locales/el-GR.min.js +1 -1
- package/locales/en-US.d.ts +1 -1
- package/locales/en-US.esm.min.js +1 -1
- package/locales/en-US.min.cjs +1 -1
- package/locales/en-US.min.js +1 -1
- package/locales/es-ES.d.ts +1 -1
- package/locales/es-ES.esm.min.js +1 -1
- package/locales/es-ES.min.cjs +1 -1
- package/locales/es-ES.min.js +1 -1
- package/locales/fi-FI.d.ts +1 -1
- package/locales/fi-FI.esm.min.js +1 -1
- package/locales/fi-FI.min.cjs +1 -1
- package/locales/fi-FI.min.js +1 -1
- package/locales/fr-CA.d.ts +1 -1
- package/locales/fr-CA.esm.min.js +1 -1
- package/locales/fr-CA.min.cjs +1 -1
- package/locales/fr-CA.min.js +1 -1
- package/locales/fr-FR.d.ts +1 -1
- package/locales/fr-FR.esm.min.js +1 -1
- package/locales/fr-FR.min.cjs +1 -1
- package/locales/fr-FR.min.js +1 -1
- package/locales/hu-HU.d.ts +1 -1
- package/locales/hu-HU.esm.min.js +1 -1
- package/locales/hu-HU.min.cjs +1 -1
- package/locales/hu-HU.min.js +1 -1
- package/locales/it-IT.d.ts +1 -1
- package/locales/it-IT.esm.min.js +1 -1
- package/locales/it-IT.min.cjs +1 -1
- package/locales/it-IT.min.js +1 -1
- package/locales/ja-JP.d.ts +1 -1
- package/locales/ja-JP.esm.min.js +1 -1
- package/locales/ja-JP.min.cjs +1 -1
- package/locales/ja-JP.min.js +1 -1
- package/locales/nb-NO.d.ts +1 -1
- package/locales/nb-NO.esm.min.js +1 -1
- package/locales/nb-NO.min.cjs +1 -1
- package/locales/nb-NO.min.js +1 -1
- package/locales/nl-NL.d.ts +1 -1
- package/locales/nl-NL.esm.min.js +1 -1
- package/locales/nl-NL.min.cjs +1 -1
- package/locales/nl-NL.min.js +1 -1
- package/locales/pl-PL.d.ts +1 -1
- package/locales/pl-PL.esm.min.js +1 -1
- package/locales/pl-PL.min.cjs +1 -1
- package/locales/pl-PL.min.js +1 -1
- package/locales/pt-BR.d.ts +1 -1
- package/locales/pt-BR.esm.min.js +1 -1
- package/locales/pt-BR.min.cjs +1 -1
- package/locales/pt-BR.min.js +1 -1
- package/locales/ro-RO.d.ts +1 -1
- package/locales/ro-RO.esm.min.js +1 -1
- package/locales/ro-RO.min.cjs +1 -1
- package/locales/ro-RO.min.js +1 -1
- package/locales/sv-SE.d.ts +1 -1
- package/locales/sv-SE.esm.min.js +1 -1
- package/locales/sv-SE.min.cjs +1 -1
- package/locales/sv-SE.min.js +1 -1
- package/locales/uk-UA.d.ts +1 -1
- package/locales/uk-UA.esm.min.js +1 -1
- package/locales/uk-UA.min.cjs +1 -1
- package/locales/uk-UA.min.js +1 -1
- package/modules/ai.d.ts +1 -1
- package/modules/ai.esm.min.js +1 -1
- package/modules/ai.min.cjs +1 -1
- package/modules/ai.min.js +1 -1
- package/modules/alarms.d.ts +1 -1
- package/modules/alarms.esm.min.js +1 -1
- package/modules/alarms.min.cjs +1 -1
- package/modules/alarms.min.js +1 -1
- package/modules/angular.d.ts +1 -1
- package/modules/angular.esm.min.js +1 -1
- package/modules/angular.min.cjs +1 -1
- package/modules/angular.min.js +1 -1
- package/modules/calendar.d.ts +1 -1
- package/modules/calendar.esm.min.js +1 -1
- package/modules/calendar.min.cjs +1 -1
- package/modules/calendar.min.js +1 -1
- package/modules/chart-alluvial.d.ts +1 -1
- package/modules/chart-alluvial.esm.min.js +1 -1
- package/modules/chart-alluvial.min.cjs +1 -1
- package/modules/chart-alluvial.min.js +1 -1
- package/modules/chart-arc.d.ts +1 -1
- package/modules/chart-arc.esm.min.js +1 -1
- package/modules/chart-arc.min.cjs +1 -1
- package/modules/chart-arc.min.js +1 -1
- package/modules/chart-barrace.d.ts +1 -1
- package/modules/chart-barrace.esm.min.js +1 -1
- package/modules/chart-barrace.min.cjs +1 -1
- package/modules/chart-barrace.min.js +1 -1
- package/modules/chart-bubblemap.d.ts +1 -1
- package/modules/chart-bubblemap.esm.min.js +1 -1
- package/modules/chart-bubblemap.min.cjs +1 -1
- package/modules/chart-bubblemap.min.js +1 -1
- package/modules/chart-bump.d.ts +1 -1
- package/modules/chart-bump.esm.min.js +1 -1
- package/modules/chart-bump.min.cjs +1 -1
- package/modules/chart-bump.min.js +1 -1
- package/modules/chart-calendar.d.ts +1 -1
- package/modules/chart-calendar.esm.min.js +1 -1
- package/modules/chart-calendar.min.cjs +1 -1
- package/modules/chart-calendar.min.js +1 -1
- package/modules/chart-choropleth.d.ts +1 -1
- package/modules/chart-choropleth.esm.min.js +1 -1
- package/modules/chart-choropleth.min.cjs +1 -1
- package/modules/chart-choropleth.min.js +1 -1
- package/modules/chart-decomposition.d.ts +1 -1
- package/modules/chart-decomposition.esm.min.js +1 -1
- package/modules/chart-decomposition.min.cjs +1 -1
- package/modules/chart-decomposition.min.js +1 -1
- package/modules/chart-diverging.d.ts +1 -1
- package/modules/chart-diverging.esm.min.js +1 -1
- package/modules/chart-diverging.min.cjs +1 -1
- package/modules/chart-diverging.min.js +1 -1
- package/modules/chart-dumbbell.d.ts +1 -1
- package/modules/chart-dumbbell.esm.min.js +1 -1
- package/modules/chart-dumbbell.min.cjs +1 -1
- package/modules/chart-dumbbell.min.js +1 -1
- package/modules/chart-fan.d.ts +1 -1
- package/modules/chart-fan.esm.min.js +1 -1
- package/modules/chart-fan.min.cjs +1 -1
- package/modules/chart-fan.min.js +1 -1
- package/modules/chart-forcetree.d.ts +1 -1
- package/modules/chart-forcetree.esm.min.js +1 -1
- package/modules/chart-forcetree.min.cjs +1 -1
- package/modules/chart-forcetree.min.js +1 -1
- package/modules/chart-hexbin.d.ts +1 -1
- package/modules/chart-hexbin.esm.min.js +1 -1
- package/modules/chart-hexbin.min.cjs +1 -1
- package/modules/chart-hexbin.min.js +1 -1
- package/modules/chart-hexmap.d.ts +1 -1
- package/modules/chart-hexmap.esm.min.js +1 -1
- package/modules/chart-hexmap.min.cjs +1 -1
- package/modules/chart-hexmap.min.js +1 -1
- package/modules/chart-icicle.d.ts +1 -1
- package/modules/chart-icicle.esm.min.js +1 -1
- package/modules/chart-icicle.min.cjs +1 -1
- package/modules/chart-icicle.min.js +1 -1
- package/modules/chart-markermap.d.ts +1 -1
- package/modules/chart-markermap.esm.min.js +1 -1
- package/modules/chart-markermap.min.cjs +1 -1
- package/modules/chart-markermap.min.js +1 -1
- package/modules/chart-motion.d.ts +1 -1
- package/modules/chart-motion.esm.min.js +1 -1
- package/modules/chart-motion.min.cjs +1 -1
- package/modules/chart-motion.min.js +1 -1
- package/modules/chart-pack.d.ts +1 -1
- package/modules/chart-pack.esm.min.js +1 -1
- package/modules/chart-pack.min.cjs +1 -1
- package/modules/chart-pack.min.js +1 -1
- package/modules/chart-parallel.d.ts +1 -1
- package/modules/chart-parallel.esm.min.js +1 -1
- package/modules/chart-parallel.min.cjs +1 -1
- package/modules/chart-parallel.min.js +1 -1
- package/modules/chart-pictorial.d.ts +1 -1
- package/modules/chart-pictorial.esm.min.js +1 -1
- package/modules/chart-pictorial.min.cjs +1 -1
- package/modules/chart-pictorial.min.js +1 -1
- package/modules/chart-polararea.d.ts +1 -1
- package/modules/chart-polararea.esm.min.js +1 -1
- package/modules/chart-polararea.min.cjs +1 -1
- package/modules/chart-polararea.min.js +1 -1
- package/modules/chart-polarscatter.d.ts +1 -1
- package/modules/chart-polarscatter.esm.min.js +1 -1
- package/modules/chart-polarscatter.min.cjs +1 -1
- package/modules/chart-polarscatter.min.js +1 -1
- package/modules/chart-pyramid.d.ts +1 -1
- package/modules/chart-pyramid.esm.min.js +1 -1
- package/modules/chart-pyramid.min.cjs +1 -1
- package/modules/chart-pyramid.min.js +1 -1
- package/modules/chart-radialbar.d.ts +1 -1
- package/modules/chart-radialbar.esm.min.js +1 -1
- package/modules/chart-radialbar.min.cjs +1 -1
- package/modules/chart-radialbar.min.js +1 -1
- package/modules/chart-ridgeline.d.ts +1 -1
- package/modules/chart-ridgeline.esm.min.js +1 -1
- package/modules/chart-ridgeline.min.cjs +1 -1
- package/modules/chart-ridgeline.min.js +1 -1
- package/modules/chart-roc.d.ts +1 -1
- package/modules/chart-roc.esm.min.js +1 -1
- package/modules/chart-roc.min.cjs +1 -1
- package/modules/chart-roc.min.js +1 -1
- package/modules/chart-scatter3d.d.ts +1 -1
- package/modules/chart-scatter3d.esm.min.js +1 -1
- package/modules/chart-scatter3d.min.cjs +1 -1
- package/modules/chart-scatter3d.min.js +1 -1
- package/modules/chart-serpentine.d.ts +1 -1
- package/modules/chart-serpentine.esm.min.js +1 -1
- package/modules/chart-serpentine.min.cjs +1 -1
- package/modules/chart-serpentine.min.js +1 -1
- package/modules/chart-slope.d.ts +1 -1
- package/modules/chart-slope.esm.min.js +1 -1
- package/modules/chart-slope.min.cjs +1 -1
- package/modules/chart-slope.min.js +1 -1
- package/modules/chart-spiral.d.ts +1 -1
- package/modules/chart-spiral.esm.min.js +1 -1
- package/modules/chart-spiral.min.cjs +1 -1
- package/modules/chart-spiral.min.js +1 -1
- package/modules/chart-splom.d.ts +1 -1
- package/modules/chart-splom.esm.min.js +1 -1
- package/modules/chart-splom.min.cjs +1 -1
- package/modules/chart-splom.min.js +1 -1
- package/modules/chart-tree.d.ts +1 -1
- package/modules/chart-tree.esm.min.js +1 -1
- package/modules/chart-tree.min.cjs +1 -1
- package/modules/chart-tree.min.js +1 -1
- package/modules/chart-venn.d.ts +1 -1
- package/modules/chart-venn.esm.min.js +1 -1
- package/modules/chart-venn.min.cjs +1 -1
- package/modules/chart-venn.min.js +1 -1
- package/modules/chart-voronoi.d.ts +1 -1
- package/modules/chart-voronoi.esm.min.js +1 -1
- package/modules/chart-voronoi.min.cjs +1 -1
- package/modules/chart-voronoi.min.js +1 -1
- package/modules/chart-waffle.d.ts +1 -1
- package/modules/chart-waffle.esm.min.js +1 -1
- package/modules/chart-waffle.min.cjs +1 -1
- package/modules/chart-waffle.min.js +1 -1
- package/modules/chart-wordcloud.d.ts +1 -1
- package/modules/chart-wordcloud.esm.min.js +1 -1
- package/modules/chart-wordcloud.min.cjs +1 -1
- package/modules/chart-wordcloud.min.js +1 -1
- package/modules/charts.d.ts +1 -1
- package/modules/charts.esm.min.js +1 -1
- package/modules/charts.min.cjs +1 -1
- package/modules/charts.min.js +1 -1
- package/modules/contextmenu.d.ts +1 -1
- package/modules/contextmenu.esm.min.js +1 -1
- package/modules/contextmenu.min.cjs +1 -1
- package/modules/contextmenu.min.js +1 -1
- package/modules/dashboard.d.ts +1 -1
- package/modules/dashboard.esm.min.js +1 -1
- package/modules/dashboard.min.cjs +1 -1
- package/modules/dashboard.min.js +1 -1
- package/modules/data-router.d.ts +1 -1
- package/modules/data-router.esm.min.js +1 -1
- package/modules/data-router.min.cjs +1 -1
- package/modules/data-router.min.js +1 -1
- package/modules/dataview.d.ts +1 -1
- package/modules/dataview.esm.min.js +1 -1
- package/modules/dataview.min.cjs +1 -1
- package/modules/dataview.min.js +1 -1
- package/modules/deckgl.d.ts +1 -1
- package/modules/deckgl.esm.min.js +1 -1
- package/modules/deckgl.min.cjs +1 -1
- package/modules/deckgl.min.js +1 -1
- package/modules/designer.d.ts +1 -1
- package/modules/designer.esm.min.js +1 -1
- package/modules/designer.min.cjs +1 -1
- package/modules/designer.min.js +1 -1
- package/modules/devtools.d.ts +1 -1
- package/modules/devtools.esm.min.js +1 -1
- package/modules/devtools.min.cjs +1 -1
- package/modules/devtools.min.js +1 -1
- package/modules/dhtmlx-compat.d.ts +1 -1
- package/modules/dhtmlx-compat.esm.min.js +1 -1
- package/modules/dhtmlx-compat.min.cjs +1 -1
- package/modules/dhtmlx-compat.min.js +1 -1
- package/modules/form.d.ts +1 -1
- package/modules/form.esm.min.js +1 -1
- package/modules/form.min.cjs +1 -1
- package/modules/form.min.js +1 -1
- package/modules/gantt.d.ts +1 -1
- package/modules/gantt.esm.min.js +1 -1
- package/modules/gantt.min.cjs +1 -1
- package/modules/gantt.min.js +1 -1
- package/modules/geo-europe-nuts.d.ts +1 -1
- package/modules/geo-europe-nuts.esm.min.js +1 -1
- package/modules/geo-europe-nuts.min.cjs +1 -1
- package/modules/geo-europe-nuts.min.js +1 -1
- package/modules/geo-uk.d.ts +1 -1
- package/modules/geo-uk.esm.min.js +1 -1
- package/modules/geo-uk.min.cjs +1 -1
- package/modules/geo-uk.min.js +1 -1
- package/modules/geo-us-states.d.ts +1 -1
- package/modules/geo-us-states.esm.min.js +1 -1
- package/modules/geo-us-states.min.cjs +1 -1
- package/modules/geo-us-states.min.js +1 -1
- package/modules/geo-world-110m.d.ts +1 -1
- package/modules/geo-world-110m.esm.min.js +1 -1
- package/modules/geo-world-110m.min.cjs +1 -1
- package/modules/geo-world-110m.min.js +1 -1
- package/modules/geo-world-50m.d.ts +1 -1
- package/modules/geo-world-50m.esm.min.js +1 -1
- package/modules/geo-world-50m.min.cjs +1 -1
- package/modules/geo-world-50m.min.js +1 -1
- package/modules/geometry.d.ts +1 -1
- package/modules/geometry.esm.min.js +1 -1
- package/modules/geometry.min.cjs +1 -1
- package/modules/geometry.min.js +1 -1
- package/modules/htmx.d.ts +1 -1
- package/modules/htmx.esm.min.js +2 -2
- package/modules/htmx.min.cjs +2 -2
- package/modules/htmx.min.js +2 -2
- package/modules/htmx.shared.esm.min.js +1 -1
- package/modules/htmx.shared.min.cjs +1 -1
- package/modules/htmx.shared.min.js +1 -1
- package/modules/kanban.d.ts +1 -1
- package/modules/kanban.esm.min.js +7 -4
- package/modules/kanban.esm.min.js.map +2 -2
- package/modules/kanban.min.cjs +7 -4
- package/modules/kanban.min.js +7 -4
- package/modules/kanban.min.js.map +2 -2
- package/modules/kpi.d.ts +1 -1
- package/modules/kpi.esm.min.js +1 -1
- package/modules/kpi.min.cjs +1 -1
- package/modules/kpi.min.js +1 -1
- package/modules/layout.d.ts +1 -1
- package/modules/layout.esm.min.js +1 -1
- package/modules/layout.min.cjs +1 -1
- package/modules/layout.min.js +1 -1
- package/modules/leaflet.d.ts +1 -1
- package/modules/leaflet.esm.min.js +1 -1
- package/modules/leaflet.min.cjs +1 -1
- package/modules/leaflet.min.js +1 -1
- package/modules/list.d.ts +1 -1
- package/modules/list.esm.min.js +1 -1
- package/modules/list.min.cjs +1 -1
- package/modules/list.min.js +1 -1
- package/modules/listview.d.ts +1 -1
- package/modules/listview.esm.min.js +1 -1
- package/modules/listview.min.cjs +1 -1
- package/modules/listview.min.js +1 -1
- package/modules/mapview.d.ts +1 -1
- package/modules/mapview.esm.min.js +1 -1
- package/modules/mapview.min.cjs +1 -1
- package/modules/mapview.min.js +1 -1
- package/modules/mock-socket.d.ts +1 -1
- package/modules/mock-socket.esm.min.js +1 -1
- package/modules/mock-socket.min.cjs +1 -1
- package/modules/mock-socket.min.js +1 -1
- package/modules/presets.d.ts +1 -1
- package/modules/presets.esm.min.js +1 -1
- package/modules/presets.min.cjs +1 -1
- package/modules/presets.min.js +1 -1
- package/modules/react.d.ts +1 -1
- package/modules/react.esm.min.js +1 -1
- package/modules/react.min.cjs +1 -1
- package/modules/react.min.js +1 -1
- package/modules/recordeditor.d.ts +1 -1
- package/modules/recordeditor.esm.min.js +1 -1
- package/modules/recordeditor.min.cjs +1 -1
- package/modules/recordeditor.min.js +1 -1
- package/modules/scheduler.d.ts +1 -1
- package/modules/scheduler.esm.min.js +1 -1
- package/modules/scheduler.min.cjs +1 -1
- package/modules/scheduler.min.js +1 -1
- package/modules/shell.d.ts +1 -1
- package/modules/shell.esm.min.js +1 -1
- package/modules/shell.min.cjs +1 -1
- package/modules/shell.min.js +1 -1
- package/modules/sidebar.d.ts +1 -1
- package/modules/sidebar.esm.min.js +1 -1
- package/modules/sidebar.min.cjs +1 -1
- package/modules/sidebar.min.js +1 -1
- package/modules/svelte.d.ts +1 -1
- package/modules/svelte.esm.min.js +1 -1
- package/modules/svelte.min.cjs +1 -1
- package/modules/svelte.min.js +1 -1
- package/modules/tabs.d.ts +1 -1
- package/modules/tabs.esm.min.js +1 -1
- package/modules/tabs.min.cjs +1 -1
- package/modules/tabs.min.js +1 -1
- package/modules/toolbar.d.ts +1 -1
- package/modules/toolbar.esm.min.js +1 -1
- package/modules/toolbar.min.cjs +1 -1
- package/modules/toolbar.min.js +1 -1
- package/modules/tree.d.ts +1 -1
- package/modules/tree.esm.min.js +1 -1
- package/modules/tree.min.cjs +1 -1
- package/modules/tree.min.js +1 -1
- package/modules/vue.d.ts +1 -1
- package/modules/vue.esm.min.js +1 -1
- package/modules/vue.min.cjs +1 -1
- package/modules/vue.min.js +1 -1
- package/modules/webcomponent.d.ts +1 -1
- package/modules/webcomponent.esm.min.js +2 -2
- package/modules/webcomponent.min.cjs +2 -2
- package/modules/webcomponent.min.js +2 -2
- package/package.json +1 -1
package/modules/htmx.min.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Lattice Grid 1.115.
|
|
2
|
+
* Lattice Grid 1.115.2, htmx module
|
|
3
3
|
* Copyright (c) 2026 TOCLOCO Inc. All rights reserved.
|
|
4
4
|
* https://latticegrid.dev
|
|
5
5
|
*/
|
|
6
6
|
(function(xr){"use strict";var gs=!0,ar=Object.create(null),lr=Object.create(null);function ze(e,B){ar[e]=B}function Kn(e){var B=lr[e];if(B)return B;var ne=Object.create(null);lr[e]=ne;var A=ar[e];if(!A)throw new Error("[lattice] missing module: "+e);return A(ne,Kn),ne}ze("packages/core/src/internal/predicates.js",function(e,B){"use strict";Object.defineProperty(e,"isObject",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"isFunction",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"isNil",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"isBlank",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"isCtor",{enumerable:!0,get:function(){return I}});function ne(J){return J!==null&&typeof J=="object"&&!Array.isArray(J)}function A(J){return typeof J=="function"}function V(J){return J==null}function U(J){return J==null||J===""}function I(J){return typeof J!="function"?!1:/^class[\s{]/.test(Function.prototype.toString.call(J))?!0:!!(J.prototype&&Object.getOwnPropertyNames(J.prototype).length>1)}}),ze("packages/core/src/internal/warn.js",function(e,B){"use strict";Object.defineProperty(e,"reportedWarnings",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"warnOnce",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"infoOnce",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"resetWarnings",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"fail",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"invariant",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"DEV",{enumerable:!0,get:function(){return g}});const ne=new Set,A=2e3;function V(o){if(ne.add(o),ne.size>A){const t=ne.values().next().value;t!==void 0&&ne.delete(t)}}const U=[],I=500;function J(o,t,s){U.push({key:o,level:t,message:s.map(l=>typeof l=="string"?l:H(l)).join(" "),at:Date.now()}),U.length>I&&U.shift()}function H(o){if(o instanceof Error)return o.message;try{return JSON.stringify(o)}catch{return String(o)}}function L(){return U.map(o=>({...o}))}function Y(o){if(o.length===0||typeof o[0]!="string")return o;const t=o[0].replace(/^\[lattice\]\s*/,"");return t===o[0]?o:[t,...o.slice(1)]}function _(o,...t){if(ne.has(o))return;V(o);const s=Y(t);J(o,"warn",s),console.warn("[lattice]",...s)}function O(o,...t){if(ne.has(o))return;V(o);const s=Y(t);J(o,"info",s),console.info("[lattice]",...s)}function v(){ne.clear(),U.length=0}function b(o,t){const s=new Error(`[lattice] ${o}`);throw t!==void 0&&(s.cause=t),s}function c(o,t){o||b(t)}const g=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})()}),ze("packages/core/src/formatting/rules.js",function(e,B){"use strict";Object.defineProperty(e,"RULE_OPS",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"DISTRIBUTION_OPS",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"DISTRIBUTION_LABELS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"testRule",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"mixColour",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"summariseColumn",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"quantileOf",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"needsDistribution",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"resolveDistribution",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"ICON_SETS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"compileRules",{enumerable:!0,get:function(){return X}});const A=B("packages/core/src/internal/predicates.js").isFunction,U=B("packages/core/src/internal/warn.js").warnOnce,I=Object.freeze(["eq","ne","gt","gte","lt","lte","between","outside","contains","notContains","startsWith","endsWith","blank","notBlank","true","false"]),J=Object.freeze(["topPercent","bottomPercent","topN","bottomN","aboveMean","belowMean","aboveMedian","belowMedian","zAbove","zBelow","outlier"]),H=Object.freeze({topPercent:"In the top %",bottomPercent:"In the bottom %",topN:"In the top N",bottomN:"In the bottom N",aboveMean:"Above average",belowMean:"Below average",aboveMedian:"Above the median",belowMedian:"Below the median",zAbove:"Standard deviations above the mean",zBelow:"Standard deviations below the mean",outlier:"An outlier"});function L(E,C){const x=Number(E),j=Number(C);if(E!==null&&E!==""&&C!==null&&C!==""&&Number.isFinite(x)&&Number.isFinite(j))return x<j?-1:x>j?1:0;const F=String(E??"").toLowerCase(),$=String(C??"").toLowerCase();return F<$?-1:F>$?1:0}function Y(E){return E==null||E===""}function _(E,C){if(!C||typeof C!="object")return!1;const{op:x}=C,j=C.value,T=C.value2;switch(x){case"blank":return Y(E);case"notBlank":return!Y(E);case"true":return E===!0;case"false":return E===!1;default:break}if(Y(E))return!1;switch(x){case"eq":return L(E,j)===0;case"ne":return L(E,j)!==0;case"gt":return L(E,j)>0;case"gte":return L(E,j)>=0;case"lt":return L(E,j)<0;case"lte":return L(E,j)<=0;case"between":return L(E,j)>=0&&L(E,T)<=0;case"outside":return L(E,j)<0||L(E,T)>0;case"contains":return String(E).toLowerCase().includes(String(j??"").toLowerCase());case"notContains":return!String(E).toLowerCase().includes(String(j??"").toLowerCase());case"startsWith":return String(E).toLowerCase().startsWith(String(j??"").toLowerCase());case"endsWith":return String(E).toLowerCase().endsWith(String(j??"").toLowerCase());default:return!1}}function O(E,C,x){const j=Q=>{const ee=String(Q).replace("#",""),re=ee.length===3?ee.split("").map(ie=>ie+ie).join(""):ee;return[0,2,4].map(ie=>parseInt(re.slice(ie,ie+2),16)||0)},[T,F,$]=j(E),[D,z,G]=j(C),N=Math.max(0,Math.min(1,x)),Z=(Q,ee)=>Math.round(Q+(ee-Q)*N);return`#${[Z(T,D),Z(F,z),Z($,G)].map(Q=>Q.toString(16).padStart(2,"0")).join("")}`}function v(E){const C=[];for(const D of E||[]){if(D==null||D==="")continue;const z=D instanceof Date?D.getTime():Number(D);Number.isFinite(z)&&C.push(z)}if(!C.length)return null;C.sort((D,z)=>D-z);let x=0,j=0,T=0;for(const D of C){x++;const z=D-j;j+=z/x,T+=z*(D-j)}const F=b(C,.25),$=b(C,.75);return{n:C.length,min:C[0],max:C[C.length-1],mean:j,stddev:C.length>1?Math.sqrt(T/(C.length-1)):0,median:b(C,.5),q1:F,q3:$,iqr:$-F,sorted:C}}function b(E,C){if(!E.length)return 0;const x=(E.length-1)*Math.max(0,Math.min(1,C)),j=Math.floor(x),T=Math.ceil(x);return j===T?E[j]:E[j]+(x-j)*(E[T]-E[j])}function c(E){for(const C of Array.isArray(E)?E:[])if(!(!C||typeof C!="object")&&(C.when&&J.includes(C.when.op)||C.scale&&C.scale.from||C.dataBar&&!(Number.isFinite(Number(C.dataBar.min))&&Number.isFinite(Number(C.dataBar.max)))||C.iconSet&&!Array.isArray(C.iconSet.thresholds)))return!0;return!1}function g(E,C){const x=Number(E.value),j=T=>b(C.sorted,T);switch(E.op){case"topPercent":{const T=o(x,10);return{op:"gte",value:j(1-T)}}case"bottomPercent":{const T=o(x,10);return{op:"lte",value:j(T)}}case"topN":{const T=Math.max(1,Math.floor(x)||1),F=Math.max(0,C.sorted.length-T);return{op:"gte",value:C.sorted[F]}}case"bottomN":{const T=Math.max(1,Math.floor(x)||1),F=Math.min(C.sorted.length-1,T-1);return{op:"lte",value:C.sorted[F]}}case"aboveMean":return{op:"gt",value:C.mean};case"belowMean":return{op:"lt",value:C.mean};case"aboveMedian":return{op:"gt",value:C.median};case"belowMedian":return{op:"lt",value:C.median};case"zAbove":return C.stddev?{op:"gte",value:C.mean+(Number.isFinite(x)?x:2)*C.stddev}:null;case"zBelow":return C.stddev?{op:"lte",value:C.mean-(Number.isFinite(x)?x:2)*C.stddev}:null;case"outlier":{const T=(Number.isFinite(x)&&x>0?x:1.5)*C.iqr;return C.iqr?{op:"outside",value:C.q1-T,value2:C.q3+T}:null}default:return null}}function o(E,C){const x=Number.isFinite(E)?E:C,j=x>1?x/100:x;return Math.max(0,Math.min(1,j))}function t(E,C){if(E.from==="minmax")return{...E,min:C.min,max:C.max};if(E.from==="quantile")return{...E,min:b(C.sorted,o(Number(E.low),5)),max:b(C.sorted,o(Number(E.high),95))};if(E.from==="stddev"){const x=Number.isFinite(Number(E.deviations))?Number(E.deviations):2;return{...E,min:C.mean-x*C.stddev,max:C.mean+x*C.stddev}}return E}function s(E,C){const x=Array.isArray(E)?E:[];return!C||!C.n?x.map(j=>j&&c([j])?{...j,enabled:!1}:j):x.map(j=>{if(!j||typeof j!="object")return j;if(j.scale&&j.scale.from)return{...j,scale:t(j.scale,C)};if(j.dataBar)return{...j,dataBar:l(j.dataBar,C)};if(j.iconSet)return{...j,iconSet:u(j.iconSet,C)};if(!j.when||!J.includes(j.when.op))return j;const T=g(j.when,C);return T?{...j,when:T}:{...j,enabled:!1}})}function l(E,C){const x=Number.isFinite(Number(E.min))?Number(E.min):void 0,j=Number.isFinite(Number(E.max))?Number(E.max):void 0;if(x!==void 0&&j!==void 0)return{...E,min:x,max:j};if(E.from==="quantile")return{...E,min:x??b(C.sorted,o(Number(E.low),5)),max:j??b(C.sorted,o(Number(E.high),95))};if(E.from==="stddev"){const T=Number.isFinite(Number(E.deviations))?Number(E.deviations):2;return{...E,min:x??C.mean-T*C.stddev,max:j??C.mean+T*C.stddev}}return{...E,min:x??C.min,max:j??C.max}}function u(E,C){if(Array.isArray(E.thresholds))return E;const x=n(E),j=[];for(let T=1;T<x;T++)j.push(b(C.sorted,T/x));return{...E,thresholds:j}}function n(E){if(Array.isArray(E.icons)&&E.icons.length>=2)return E.icons.length;if(Number.isFinite(Number(E.count))&&Number(E.count)>=2)return Math.floor(Number(E.count));const C=y[E.set];return C?C.length:3}function p(E){return`url("data:image/svg+xml,${encodeURIComponent(E)}")`}function r(E){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><circle cx="8" cy="8" r="6" fill="${E}"/></svg>`}function i(E,C){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><polygon points="${C==="up"?"8,2 14,13 2,13":C==="down"?"2,3 14,3 8,14":"4,2 14,8 4,14"}" fill="${E}"/></svg>`}function d(E,C){const x="M8 1l1.9 3.9 4.3.6-3.1 3 .7 4.3L8 13.8 4.2 15.8l.7-4.3-3.1-3 4.3-.6z";let j=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${C*16} 16">`;for(let T=0;T<C;T++){const F=T<E?"#f5a623":"#d0d0d0";j+=`<path transform="translate(${T*16},0)" d="${x}" fill="${F}"/>`}return`${j}</svg>`}const h=Object.freeze([i("#c0392b","down"),i("#e0a800","right"),i("#2e7d32","up")]),a=Object.freeze([r("#d13438"),r("#f5a623"),r("#2e9e44")]),y=Object.freeze({arrows:h,trafficLights:a,ratings:Object.freeze([1,2,3,4,5].map(E=>d(E,5)))}),f=Object.freeze({arrows:"Arrows",trafficLights:"Traffic lights",ratings:"Ratings"});function m(E){if(Array.isArray(E.icons)&&E.icons.length>=2)return E.icons.map(j=>/^\s*(url\(|data:|<)/.test(String(j))&&String(j).trim().startsWith("<")?p(String(j)):String(j));const C=E.set||"arrows";if(C==="ratings"){const j=n(E),T=[];for(let F=1;F<=j;F++)T.push(p(d(F,j)));return T}const x=y[C];return x?x.map(p):(U(`iconSet:${C}`,`unknown icon set '${C}'; falling back to arrows.`),h.map(p))}function w(E){const C=Number(E.min),j=Number(E.max)-C,T=E.colour||E.color||"#5b9bd5",F=E.negativeColour||E.negativeColor||"#d13438",$=E.direction==="rtl"?"left":"right",D=G=>Math.max(0,Math.min(1,(G-C)/j))*100,z=j?Math.max(0,Math.min(100,(0-C)/j*100)):0;return G=>{if(Y(G))return null;const N=Number(G);if(!Number.isFinite(N)||!j)return null;const Z=D(N),Q=Math.min(Z,z),ee=Math.max(Z,z),re=N>=0?T:F;return{backgroundImage:`linear-gradient(to ${$}, transparent ${Q}%, ${re} ${Q}%, ${re} ${ee}%, transparent ${ee}%)`,backgroundRepeat:"no-repeat",backgroundPosition:"0 0"}}}function S(E){const C=m(E),x=E.reverse?[...C].reverse():C,j=(Array.isArray(E.thresholds)?E.thresholds:[]).map(Number).filter(Number.isFinite),T=Number.isFinite(Number(E.size))?Number(E.size):16,F=E.set==="ratings"?T*n(E):T;return $=>{if(Y($))return null;const D=Number($);if(!Number.isFinite(D))return null;let z=0;for(const N of j)D>=N&&z++;const G=x[Math.min(z,x.length-1)];return G?{backgroundImage:G,backgroundRepeat:"no-repeat",backgroundPosition:"left center",backgroundSize:`${F}px ${T}px`,paddingLeft:`${F+4}px`}:null}}function M(E){const C=Array.isArray(E.colours)&&E.colours.length>=2?E.colours:["#f8f9fa","#1a6bc7"],x=Number(E.min),j=Number(E.max),T=j-x,F=C.length-1,$=[];for(let z=0;z<=F;z++)$.push(F?z/F:0);const D=Number(E.mid);if(E.mid!==void 0&&E.mid!==null)if(C.length%2===0)U("formatting.scale.mid.even",`a scale's "mid" needs an odd number of colours (a middle stop to pin); ${C.length} were given, so "mid" was ignored.`);else if(Number.isFinite(D)&&T&&D>Math.min(x,j)&&D<Math.max(x,j)){const z=F/2,G=Math.max(0,Math.min(1,(D-x)/T));for(let N=0;N<=F;N++)$[N]=N<=z?z?N/z*G:G:G+(N-z)/(F-z)*(1-G)}else Number.isFinite(D)&&U("formatting.scale.mid.range",`a scale's "mid" (${D}) is outside its min..max range, so it was ignored.`);return z=>{const G=Number(z);if(!Number.isFinite(G)||!T)return null;const N=Math.max(0,Math.min(1,(G-x)/T));let Z=0;for(;Z<F-1&&N>$[Z+1];)Z++;const Q=$[Z+1]-$[Z],ee=Q>0?(N-$[Z])/Q:0;return{background:O(C[Z],C[Z+1],Math.max(0,Math.min(1,ee)))}}}function X(E,C=null){const x=c(E)?s(E,C):E,j=(Array.isArray(x)?x:[]).filter($=>$&&typeof $=="object");if(!j.length)return()=>null;const T=j.map($=>$.scale?{scale:M($.scale),enabled:$.enabled!==!1}:$.dataBar?{scale:w($.dataBar),enabled:$.enabled!==!1}:$.iconSet?{scale:S($.iconSet),enabled:$.enabled!==!1}:{when:$.when,style:$.style,stop:$.stopIfTrue!==!1,enabled:$.enabled!==!1}),F=q(T)?k():null;return($,D)=>{const z=$?$.value:void 0;let G=null;D&&(D.mode=0);for(const N of T){if(!N.enabled)continue;if(N.scale){const ee=N.scale(z);ee&&(G={...G||{},...ee});continue}if(!_(z,N.when))continue;let Z;const Q=A(N.style);if(Q?D&&F?(Z=N.style(F.enter($)),F.mode>D.mode&&(D.mode=F.mode)):Z=N.style($):Z=N.style,Z&&(G=G?{...G,...Z}:Q?Z:{...Z}),N.stop)break}return G}}function q(E){return E.some(C=>C.enabled&&!C.scale&&A(C.style))}const K=new Set(["value","colId","column"]),P=new Set(["row","data","index"]);function k(){let E={};const C={mode:0,enter(T){return E=T||{},C.mode=0,j}},x=T=>{if(K.has(T))return;const F=P.has(T)?1:2;F>C.mode&&(C.mode=F)},j=new Proxy({},{get(T,F){return x(F),E[F]},has(T,F){return x(F),F in E},set(T,F,$){return C.mode=2,E[F]=$,!0},ownKeys(){return C.mode=2,Reflect.ownKeys(E)},getOwnPropertyDescriptor(T,F){C.mode=2;const $=Object.getOwnPropertyDescriptor(E,F);return $?{value:E[F],enumerable:$.enumerable,configurable:!0,writable:!0}:void 0}});return C}}),ze("packages/core/src/formula/parse.js",function(e,B){"use strict";Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"tokenise",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return s}});const ne="num",A="str",V="ref",U="name",I="op",J="end",H=["<=",">=","<>","!="],L="+-*/^%(),<>=";class Y extends Error{constructor(u,n){super(u),this.name="FormulaError",this.at=n}}function _(l){const u=[];let n=0;for(;n<l.length;){const p=l[n];if(p===" "||p===" "||p===`
|
|
7
|
-
`||p==="\r"){n++;continue}if(p>="0"&&p<="9"){n=v(l,n,u);continue}if(p==="."&&l[n+1]>="0"&&l[n+1]<="9"){n=v(l,n,u);continue}if(p==='"'||p==="'"){n=b(l,n,u);continue}if(p==="["){const i=l.indexOf("]",n+1);if(i<0)throw new Y("a [column reference] was opened and never closed",n);u.push({kind:V,value:l.slice(n+1,i).trim(),at:n}),n=i+1;continue}if(O(p)){n=c(l,n,u);continue}const r=l.slice(n,n+2);if(H.includes(r)){u.push({kind:I,value:r==="!="?"<>":r,at:n}),n+=2;continue}if(L.includes(p)){u.push({kind:I,value:p,at:n}),n++;continue}throw new Y(`unexpected character ${JSON.stringify(p)}`,n)}return u.push({kind:J,value:null,at:l.length}),u}function O(l){return/[A-Za-z_À-]/.test(l)}function v(l,u,n){let p=u,r=!1;for(;p<l.length;){const i=l[p];if(i>="0"&&i<="9"){p++;continue}if(i==="."&&!r){r=!0,p++;continue}if((i==="e"||i==="E")&&/[0-9+-]/.test(l[p+1]||"")){for(p+=2;p<l.length&&l[p]>="0"&&l[p]<="9";)p++;break}break}return n.push({kind:ne,value:Number(l.slice(u,p)),at:u}),p}function b(l,u,n){const p=l[u];let r=u+1,i="";for(;r<l.length;){if(l[r]===p){if(l[r+1]===p){i+=p,r+=2;continue}return n.push({kind:A,value:i,at:u}),r+1}i+=l[r],r++}throw new Y("a string was opened and never closed",u)}function c(l,u,n){let p=u;for(;p<l.length&&/[A-Za-z0-9_.À-]/.test(l[p]);)p++;const r=l.slice(u,p);let i=p;for(;i<l.length&&l[i]===" ";)i++;return n.push({kind:l[i]==="("?U:V,value:r,at:u}),p}const g={"=":1,"<>":1,"<":1,"<=":1,">":1,">=":1,"+":2,"-":2,"*":3,"/":3,"^":4};function o(l){const u=String(l??"").replace(/^\s*=/,"");if(!u.trim())throw new Y("the formula is empty");const n=_(u);let p=0;const r=()=>n[p],i=()=>n[p++],d=S=>{const M=r();if(M.kind!==I||M.value!==S)throw new Y(`expected ${JSON.stringify(S)}`,M.at);p++},h=S=>{let M=a();for(;;){const X=r();if(X.kind!==I)break;const q=g[X.value];if(!q||q<S)break;p++;const K=h(X.value==="^"?q:q+1);M={kind:"bin",op:X.value,left:M,right:K}}return M},a=()=>{const S=r();return S.kind===I&&(S.value==="-"||S.value==="+")?(p++,{kind:"unary",op:S.value,arg:a()}):y()},y=()=>{let S=f();for(;r().kind===I&&r().value==="%";)p++,S={kind:"unary",op:"%",arg:S};return S},f=()=>{const S=i();if(S.kind===ne)return{kind:"num",value:S.value};if(S.kind===A)return{kind:"str",value:S.value};if(S.kind===V)return{kind:"ref",name:S.value};if(S.kind===U){d("(");const M=[];if(!(r().kind===I&&r().value===")"))for(;;){if(M.push(h(1)),r().kind===I&&r().value===","){p++;continue}break}return d(")"),{kind:"call",name:String(S.value).toUpperCase(),args:M}}if(S.kind===I&&S.value==="("){const M=h(1);return d(")"),M}throw S.kind===J?new Y("the formula ends unexpectedly",S.at):new Y(`unexpected ${JSON.stringify(S.value)}`,S.at)},m=h(1),w=r();if(w.kind!==J)throw new Y(`unexpected ${JSON.stringify(w.value)}: is an operator missing?`,w.at);return m}function t(l){const u=new Set,n=p=>{if(!(!p||typeof p!="object")){if(p.kind==="ref"){u.add(String(p.name));return}if(p.kind==="bin"){n(p.left),n(p.right);return}if(p.kind==="unary"){n(p.arg);return}if(p.kind==="call")for(const r of p.args)n(r)}};return n(l),[...u]}function s(l){return typeof l=="string"&&/^\s*=/.test(l)&&l.trim()!=="="}}),ze("packages/core/src/formula/evaluate.js",function(e,B){"use strict";Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"evaluateAst",{enumerable:!0,get:function(){return v}});const A=B("packages/core/src/formula/parse.js").FormulaError;function V(b){if(b==null||b==="")return 0;if(typeof b=="boolean")return b?1:0;if(b instanceof Date)return b.getTime();const c=typeof b=="number"?b:Number(String(b).replace(/[,\s]/g,""));if(!Number.isFinite(c))throw new A(`${JSON.stringify(b)} is not a number`);return c}function U(b){return b==null?"":String(b)}function I(b){if(typeof b=="boolean")return b;if(b==null||b==="")return!1;if(typeof b=="number")return b!==0;const c=String(b).trim().toLowerCase();return c==="false"||c==="no"||c==="0"?!1:c!==""}function J(b){const c=[];for(const g of b){if(Array.isArray(g)){for(const o of g)o!=null&&o!==""&&c.push(V(o));continue}g==null||g===""||c.push(V(g))}return c}function H(b,c){const g=10**c,o=b*g;return Math.sign(o)*Math.round(Math.abs(o)+Number.EPSILON*Math.abs(o))/g}function L(b,c){if(!b.length)return 0;const g=b.slice().sort((l,u)=>l-u),o=(g.length-1)*Math.min(1,Math.max(0,c)),t=Math.floor(o),s=Math.ceil(o);return t===s?g[t]:g[t]+(o-t)*(g[s]-g[t])}function Y(b,c){let g=0,o=0,t=0;for(const l of b){g++;const u=l-o;o+=u/g,t+=u*(l-o)}const s=c?g-1:g;return s>0?Math.sqrt(t/s):0}const _={SUM:b=>J(b).reduce((c,g)=>c+g,0),AVERAGE:b=>{const c=J(b);return c.length?c.reduce((g,o)=>g+o,0)/c.length:0},MIN:b=>{const c=J(b);return c.length?Math.min(...c):0},MAX:b=>{const c=J(b);return c.length?Math.max(...c):0},COUNT:b=>J(b).length,PRODUCT:b=>J(b).reduce((c,g)=>c*g,1),ROUND:b=>H(V(b[0]),b.length>1?V(b[1]):0),ROUNDDOWN:b=>{const c=10**(b.length>1?V(b[1]):0),g=V(b[0])*c;return(g<0?Math.ceil(g):Math.floor(g))/c},ROUNDUP:b=>{const c=10**(b.length>1?V(b[1]):0),g=V(b[0])*c;return(g<0?Math.floor(g):Math.ceil(g))/c},ABS:b=>Math.abs(V(b[0])),FLOOR:b=>Math.floor(V(b[0])),CEILING:b=>Math.ceil(V(b[0])),SQRT:b=>Math.sqrt(V(b[0])),POWER:b=>V(b[0])**V(b[1]),MOD:b=>{const c=V(b[1]);if(c===0)throw new A("MOD by zero");return(V(b[0])%c+c)%c},IF:b=>I(b[0])?b[1]:b.length>2?b[2]:!1,AND:b=>b.every(I),OR:b=>b.some(I),NOT:b=>!I(b[0]),COALESCE:b=>b.find(c=>c!=null&&c!=="")??null,CONCAT:b=>b.map(U).join(""),LEN:b=>U(b[0]).length,UPPER:b=>U(b[0]).toUpperCase(),LOWER:b=>U(b[0]).toLowerCase(),TRIM:b=>U(b[0]).trim(),LEFT:b=>U(b[0]).slice(0,b.length>1?V(b[1]):1),RIGHT:b=>{const c=b.length>1?V(b[1]):1;return c<=0?"":U(b[0]).slice(-c)},MEDIAN:b=>L(J(b),.5),PERCENTILE:b=>{const c=V(b[b.length-1]);return L(J(b.slice(0,-1)),c>1?c/100:c)},QUARTILE1:b=>L(J(b),.25),QUARTILE3:b=>L(J(b),.75),STDEV:b=>Y(J(b),!0),STDEVP:b=>Y(J(b),!1),VAR:b=>{const c=Y(J(b),!0);return c*c},VARP:b=>{const c=Y(J(b),!1);return c*c},COUNTDISTINCT:b=>{const c=new Set;for(const g of b){const o=Array.isArray(g)?g:[g];for(const t of o)t!=null&&t!==""&&c.add(t)}return c.size},IQR:b=>{const c=J(b);return L(c,.75)-L(c,.25)}};_.AVG=_.AVERAGE,_.CEIL=_.CEILING,_.POW=_.POWER,_.STDEVS=_.STDEV,_.PERCENTILEINC=_.PERCENTILE;function O(b,c){const g=Number(b),o=Number(c);if(b!==null&&b!==""&&c!==null&&c!==""&&Number.isFinite(g)&&Number.isFinite(o))return g<o?-1:g>o?1:0;const s=U(b).toLowerCase(),l=U(c).toLowerCase();return s<l?-1:s>l?1:0}function v(b,c={}){const g=typeof c.lookup=="function"?c.lookup:null,o=c.functions?{..._,...c.functions}:_,t=s=>{switch(s.kind){case"num":return s.value;case"str":return s.value;case"ref":{if(!g)throw new A(`there is no column called ${JSON.stringify(s.name)} here`);const l=g(String(s.name));if(l===void 0)throw new A(`there is no column called ${JSON.stringify(s.name)}`);return l}case"unary":{if(s.op==="%")return V(t(s.arg))/100;const l=V(t(s.arg));return s.op==="-"?-l:l}case"bin":{const l=s.op;if(l==="=")return O(t(s.left),t(s.right))===0;if(l==="<>")return O(t(s.left),t(s.right))!==0;if(l==="<")return O(t(s.left),t(s.right))<0;if(l==="<=")return O(t(s.left),t(s.right))<=0;if(l===">")return O(t(s.left),t(s.right))>0;if(l===">=")return O(t(s.left),t(s.right))>=0;const u=V(t(s.left)),n=V(t(s.right));if(l==="+")return u+n;if(l==="-")return u-n;if(l==="*")return u*n;if(l==="^")return u**n;if(l==="/"){if(n===0)throw new A("division by zero");return u/n}throw new A(`unknown operator ${JSON.stringify(l)}`)}case"call":{const l=c.lazy&&c.lazy[s.name];if(typeof l=="function")return l(s.args,t,c);const u=o[s.name];if(typeof u!="function")throw new A(`there is no function called ${s.name}`);return u(s.args.map(t),c)}default:throw new A("the formula could not be read")}};return t(b)}}),ze("packages/core/src/formula/index.js",function(e,B){"use strict";Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"tokenise",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"evaluateAst",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"rowLookup",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"evaluateFormula",{enumerable:!0,get:function(){return O}});const ne=B("packages/core/src/formula/parse.js"),A=ne.parseFormula,V=ne.referencesOf,U=ne.looksLikeFormula,I=ne.FormulaError,J=ne.tokenise,H=B("packages/core/src/formula/evaluate.js"),L=H.evaluateAst,Y=H.FUNCTIONS;function _(v){const{grid:b,row:c,data:g}=v||{},o=n=>String(n).toLowerCase().replace(/[\s_-]/g,""),t=b&&b.columns&&typeof b.columns.all=="function"?b.columns.all():[],s=b&&b.permissions,l=s&&typeof s.isReadable=="function"?n=>s.isReadable(n):()=>!0,u=new Set;for(const n of t)l(n)||(u.add(o(n.id)),n.field&&u.add(o(n.field)),n.title&&u.add(o(n.title)));return n=>{const p=o(n);if(u.has(p))throw new I(`"${n}" cannot be read`);for(const r of t)if(o(r.id)===p||r.field&&o(r.field)===p||r.title&&o(r.title)===p)return c&&b.rows&&typeof b.rows.value=="function"?b.rows.value(c.key,r.id):g?g[r.field||r.id]:void 0;if(g&&typeof g=="object"){for(const r of Object.keys(g))if(o(r)===p){if(!l(r))throw new I(`"${n}" cannot be read`);return g[r]}}}}function O(v,b={}){try{const c=A(v);return{ok:!0,value:L(c,{lookup:_(b),functions:b.formulaFunctions}),references:V(c)}}catch(c){return{ok:!1,error:c instanceof I?c.message:"the formula could not be read",at:c instanceof I?c.at:void 0}}}}),ze("packages/core/src/internal/version.js",function(e,B){"use strict";Object.defineProperty(e,"VERSION",{enumerable:!0,get:function(){return V}});const ne="1.115.0";async function A(){return ne}const V="1.115.0"}),ze("packages/core/src/internal/merge.js",function(e,B){"use strict";Object.defineProperty(e,"expand",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"toArray",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"merge",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"mergeRow",{enumerable:!0,get:function(){return H}});const A=B("packages/core/src/internal/predicates.js").isObject;function V(L,Y,_){if(L!==void 0)return L===!0?{enabled:!0,..._}:L===!1?{enabled:!1}:A(L)?L:{[Y]:L,enabled:!0}}function U(L){return L==null?[]:Array.isArray(L)?L:[L]}const I=Object.freeze(new Set(["__proto__","constructor","prototype"]));function J(L,Y){if(!A(L))return A(Y)?{...Y}:Y;if(!A(Y))return Y===void 0?L:Y;const _={...L};for(const O of Object.keys(Y)){if(I.has(O))continue;const v=Y[O];v!==void 0&&(_[O]=A(v)&&A(_[O])?J(_[O],v):v)}return _}function H(L,Y){if(!A(L)||!A(Y)||L===Y)return Y;const _=Object.create(Object.getPrototypeOf(L));return Object.assign(_,L,Y),_}}),ze("packages/core/src/internal/schedule.js",function(e,B){"use strict";Object.defineProperty(e,"now",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"nextFrame",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"cancelFrame",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"frameBatched",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"settleDebounce",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"whenIdle",{enumerable:!0,get:function(){return H}});function ne(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const A=typeof requestAnimationFrame=="function";function V(L){return A?requestAnimationFrame(L):setTimeout(()=>L(ne()),16)}function U(L){L!=null&&(A?cancelAnimationFrame(L):clearTimeout(L))}function I(L){let Y=null,_=null;const O=()=>{Y=null;const b=_;_=null,L(...b||[])},v=(...b)=>{_=b,Y===null&&(Y=V(O))};return v.cancel=()=>{U(Y),Y=null,_=null},v.flush=()=>{Y!==null&&(U(Y),O())},v}function J(L,Y){let _=null,O=null;const v=()=>{if(_=null,O===null)return;const g=O;O=null,L(...g),b()},b=()=>{_=setTimeout(v,Y),typeof _?.unref=="function"&&_.unref()},c=(...g)=>{_===null?(L(...g),b()):(O=g,clearTimeout(_),b())};return c.flush=()=>{if(_!==null&&clearTimeout(_),_=null,O===null)return;const g=O;O=null,L(...g)},c.cancel=()=>{_!==null&&clearTimeout(_),_=null,O=null},c.pending=()=>_!==null||O!==null,c}function H(L,Y=50){return typeof requestIdleCallback=="function"?requestIdleCallback(L,{timeout:Y}):setTimeout(()=>L({timeRemaining:()=>0,didTimeout:!0}),1)}}),ze("packages/core/src/internal/paths.js",function(e,B){"use strict";Object.defineProperty(e,"pathGetter",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"pathSetter",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"getPath",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"setPath",{enumerable:!0,get:function(){return J}});const ne=new Map;function A(H){let L=ne.get(H);if(L)return L;if(!H.includes("."))L=Y=>Y?.[H];else{const Y=H.split("."),_=Y.length;L=O=>{let v=O;for(let b=0;b<_;b++){if(v==null)return;v=v[Y[b]]}return v}}return ne.set(H,L),L}const V=new Map;function U(H){let L=V.get(H);if(L)return L;if(!H.includes("."))L=(Y,_)=>{Y!=null&&(Y[H]=_)};else{const Y=H.split("."),_=Y.length-1;L=(O,v)=>{let b=O;for(let c=0;c<_;c++){if(b==null)return;const g=Y[c];b[g]==null&&(b[g]={}),b=b[g]}b!=null&&(b[Y[_]]=v)}}return V.set(H,L),L}function I(H,L){return A(L)(H)}function J(H,L,Y){U(L)(H,Y)}}),ze("packages/core/src/internal/compare.js",function(e,B){"use strict";Object.defineProperty(e,"collator",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"defaultCompare",{enumerable:!0,get:function(){return V}});const ne=new Map;function A(U,I){const J=`${U||""}|${I?JSON.stringify(I):""}`;let H=ne.get(J);return H||(H=new Intl.Collator(U||void 0,{numeric:!0,sensitivity:"variant",...I}),ne.set(J,H)),H}function V(U,I){if(U===I)return 0;if(U==null)return 1;if(I==null)return-1;if(typeof U=="number"&&typeof I=="number")return Number.isNaN(U)?Number.isNaN(I)?0:1:Number.isNaN(I)||U<I?-1:U>I?1:0;const J=String(U),H=String(I);return J<H?-1:J>H?1:0}}),ze("packages/core/src/defaults.js",function(e,B){"use strict";Object.defineProperty(e,"defaults",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"applyDefaults",{enumerable:!0,get:function(){return O}});const A=B("packages/core/src/internal/predicates.js").isObject,U=B("packages/core/src/internal/merge.js").merge,J=B("packages/core/src/internal/warn.js").warnOnce;let H=null;class L extends Error{}function Y(v,b=new Set){if(Array.isArray(v)){if(b.has(v))throw new L;b.add(v);const g=v.map(o=>Y(o,b));return b.delete(v),g}if(!A(v)||Object.getPrototypeOf(v)!==Object.prototype&&Object.getPrototypeOf(v)!==null)return v;if(b.has(v))throw new L;b.add(v);const c={};for(const[g,o]of Object.entries(v))c[g]=Y(o,b);return b.delete(v),c}function _(v){if(v===void 0)return Y(H??{});if(v===null)return H=null,{};if(!A(v))return J("defaults:type",`defaults() expects a configuration object, or null to clear it, but got ${Array.isArray(v)?"an array":typeof v}. The call was ignored and the defaults are unchanged.`),Y(H??{});try{H=Y(v)}catch(b){if(!(b instanceof L))throw b;return J("defaults:cyclic","defaults() expects a configuration object with no circular references, but the object passed refers back to itself. The call was ignored and the defaults are unchanged."),Y(H??{})}return Y(H)}function O(v){return H===null?v:U(Y(H),v)}}),ze("packages/core/src/internal/uid.js",function(e,B){"use strict";Object.defineProperty(e,"uid",{enumerable:!0,get:function(){return A}});let ne=0;function A(V="l"){return`${V}${(++ne).toString(36)}`}}),ze("packages/core/src/events/names.js",function(e,B){"use strict";Object.defineProperty(e,"EVENT_NAMES",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"isKnownEvent",{enumerable:!0,get:function(){return V}});const ne=Object.freeze(["ready","destroy","render:first","render:done","config:changed","licence:changed","model:changed","rows:changed","rows:queued","rows:deferred","rows:paused","rows:resumed","row:received","row:sent","row:copied","row:moved","source:error","source:total","stream:chunk","stream:end","stream:evicted","rowDrag:started","rowDrag:moved","rowDrag:left","rowDrag:ended","beforeRowDrop","rowDrop:cancelled","rowDrop","cell:changed","cell:pending","cell:confirmed","cell:reverted","cell:conflict","cell:clicked","cell:dblclicked","cell:contextmenu","cell:mouseover","cell:mouseout","cell:mousedown","cell:mouseup","cell:edit:start","cell:edit:end","row:edit:start","row:edit:end","row:clicked","row:dblclicked","row:pending","row:confirmed","row:reverted","row:conflict","form:opened","form:closed","form:saved","form:error","sort:changed","filter:changed","group:toggled","facet:computed","facet:filtered","facet:expanded","facet:failed","column:moved","column:resized","column:visible","column:pinned","column:grouped","column:pivoted","column:filter:open","column:profile:open","column:compareGroups:open","column:menu:open","explain:open","columns:changed","columns:tagged","columngroup:changed","header:contextmenu","totals:contextmenu","pivot:drill","selection:changed","range:changed","clipboard:copy","page:changed","scroll","scroll:end","size:changed","detail:toggled","detail:cell:edit:start","detail:cell:edit:end","detail:row:edit:start","detail:row:edit:end","detail:cell:changed","toolpanel:focus","highlight:changed","find:changed","tree:loading","tree:loaded","tree:loadFailed","tree:loadAborted","state:changed","state:reset","history:changed","history:applied","views:changed","view:applied","view:saved","view:removed","view:renamed","view:default","validation:failed","validation:cleared","formatting:changed","redaction:changed","permissions:changed","presentation:changed","presentation:started","presentation:ended","presentation:view","presentation:scale","presentation:spotlight","presentation:captured","comment:added","comment:edited","comment:deleted","comment:failed","comment:resolved","comment:unresolved","comment:threadOpened","comment:threadClosed","comment:indexLoaded","presence:published","presence:joined","presence:updated","presence:left","presence:failed","presence:lockRefused","diff:changed","diff:swapped","timeline:attached","timeline:detached","timeline:seek","timeline:seeking","annotation:changed","export:progress","export:request","export:done","shortcuts:opened","shortcuts:closed","print:before","print:after","beforeEdit","beforeSort","beforeFilter","beforeColumnMove","beforeColumnResize","beforeColumnHide","beforeSelect","beforeRowAdd","beforeDelete","beforeRowMove","beforeGroup","beforeRowReceive","edit:cancelled","sort:cancelled","filter:cancelled","columnMove:cancelled","columnResize:cancelled","columnHide:cancelled","selection:cancelled","rowAdd:cancelled","delete:cancelled","rowMove:cancelled","group:cancelled","rowReceive:cancelled"]),A=new Set(ne);function V(U){return U==="*"||A.has(U)}}),ze("packages/core/src/events/bus.js",function(e,B){"use strict";Object.defineProperty(e,"WILDCARD",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"EventBus",{enumerable:!0,get:function(){return g}});const ne=B("packages/core/src/internal/warn.js"),A=ne.warnOnce,V=ne.DEV,I=B("packages/core/src/internal/uid.js").uid,H=B("packages/core/src/events/names.js").isKnownEvent,L="*";function Y(o,t){!V||H(t)||A(`bus.unknown:${t}`,`${o}('${t}') subscribes to an event the grid never raises, so the handler will never fire. Check the name against the EventName list — a common cause is a near miss such as 'row:click' for 'row:clicked'.`)}const _=new Set(["api","user","init","ai"]),O=new WeakMap;function v(o){let t=O.get(o);return t||(t=I("h"),O.set(o,t)),t}function b(){return typeof performance=="object"&&performance?performance.now():Date.now()}function c(o){if(!o||typeof o!="object")return{};const t={};for(const[s,l]of Object.entries(o))s!=="grid"&&(l==null?t[s]=String(l):Array.isArray(l)?t[s]=`[${l.length}]`:typeof l=="object"?t[s]=l.key?`row ${l.key}`:"{…}":typeof l=="function"?t[s]="[function]":t[s]=String(l).slice(0,60));return t}class g{#e=new Map;#t=!1;#n=[];#r=200;#s=new Map;#i=null;#a=!1;#l=0;constructor(t=null){this.#i=t}attach(t){this.#i=t}get grid(){return this.#i}get destroyed(){return this.#a}on(t,s){if(typeof s!="function")return A(`bus.handler:${t}`,`on('${t}') needs a function; ignored.`),()=>{};Y("on",t);let l=this.#e.get(t);return l||(l=[],this.#e.set(t,l)),l.push(s),()=>this.off(t,s)}once(t,s){if(typeof s!="function")return A(`bus.handler:${t}`,`once('${t}') needs a function; ignored.`),()=>{};Y("once",t);const l=u=>{this.off(t,s),s(u)};return this.#s.set(s,l),this.on(t,l)}off(t,s){if(s===void 0){this.#e.delete(t);return}const l=this.#e.get(t);if(!l)return;const u=this.#s.get(s),n=u&&l.includes(u)?u:s,p=l.indexOf(n);p>=0&&l.splice(p,1),u&&n===u&&this.#s.delete(s),l.length===0&&this.#e.delete(t)}count(t){const s=this.#e.get(t),l=t===L?null:this.#e.get(L);return(s?s.length:0)+(l?l.length:0)}#o(t,s,l,u,n){this.#n.push({type:t,origin:s,listeners:(u?u.length:0)+(n?n.length:0),payload:c(l),at:Date.now(),ms:0}),this.#n.length>this.#r&&this.#n.shift()}recordEvents(t,s){this.#t=!!t,Number.isFinite(s)&&s>0&&(this.#r=Math.floor(s)),t||(this.#n=[])}eventLog(){return this.#n.map(t=>({...t}))}clearEventLog(){this.#n=[]}counts(){const t={};for(const[s,l]of this.#e)t[s]=l.length;return t}emit(t,s,l){const u=l??(s&&s.origin),n=_.has(u)?u:"api",p={...s||null,type:t,origin:n,grid:this.#i};if(this.#a)return p;const r=this.#e.get(t),i=t===L?void 0:this.#e.get(L);if(this.#t&&this.#o(t,n,s,r,i),!r&&!i)return p;const d=this.#t?b():0;this.#l++;try{r&&this.#c(r.slice(),p,t),i&&this.#c(i.slice(),p,L)}finally{this.#l--,this.#t&&this.#n.length&&(this.#n[this.#n.length-1].ms=b()-d)}return p}emitBefore(t,s,l){const u=l??(s&&s.origin),n=_.has(u)?u:"user";let p=!1,r=null;const i=m=>{p=!0,m!=null&&r===null&&(r=String(m))},d={...s||null,type:t,origin:n,grid:this.#i,get defaultPrevented(){return p},get reason(){return r},preventDefault(m){i(m)}};if(this.#a)return!0;const h=this.#e.get(t);this.#t&&this.#o(t,n,s,h,void 0);const a=h?h.slice():[];if(a.length===0)return!0;const y=()=>(p&&r===null&&(r="prevented"),p&&s&&typeof s=="object"&&(s.reason=r),!p),f=[];for(const m of a)try{const w=m(d);w&&typeof w.then=="function"?f.push(w):w===!1&&i("prevented")}catch(w){i("error"),A(`bus.beforeThrow:${t}:${v(m)}`,`a '${t}' before-handler threw; the action was cancelled.`,w)}return f.length===0?y():Promise.allSettled(f).then(m=>{for(const w of m)w.status==="rejected"?(i("error"),A(`bus.beforeReject:${t}`,`a '${t}' before-handler rejected; the action was cancelled.`,w.reason)):w.value===!1&&i("prevented");return y()})}#c(t,s,l){for(let u=0;u<t.length;u++)try{t[u](s)}catch(n){A(`bus.throw:${l}:${v(t[u])}`,`a '${l}' handler threw; other handlers were unaffected.`,n)}}clear(){this.#e.clear(),this.#s.clear()}destroy(){this.clear(),this.#a=!0,this.#i=null}}}),ze("packages/core/src/registry/free-tier-notice.js",function(e,B){"use strict";Object.defineProperty(e,"FREE_TIER_NOTICE",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"WATERMARK_TEXT",{enumerable:!0,get:function(){return A}});const ne="Free for non-commercial use: latticegrid.dev/free",A="Unlicensed: Lattice Grid trial"}),ze("packages/core/src/registry/licence.js",function(e,B){"use strict";Object.defineProperty(e,"PRODUCT",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"LICENCE_VERSION",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"PUBLIC_KEY",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"fromBase64Url",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"toBase64Url",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"asciiBytes",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"parseLicence",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"hasEd25519",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"verifyLicence",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"isLocalHost",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"currentHost",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"matchesDomain",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"LicenceHolder",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"setLicence",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"licenceInfo",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"watermark",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"licenceState",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"sharedLicence",{enumerable:!0,get:function(){return k}});const A=B("packages/core/src/internal/warn.js").warnOnce,V=B("packages/core/src/registry/free-tier-notice.js"),U=V.FREE_TIER_NOTICE;Object.defineProperty(e,"FREE_TIER_NOTICE",{enumerable:!0,get:function(){return V.FREE_TIER_NOTICE}});const I="lattice-grid",J=1,H="LG1",L=64,Y="GwmaCOkGedHulqsa-DOV1TU8On1rsalWv519c_dW4j4",_="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",O=(()=>{const E=new Int16Array(128).fill(-1);for(let C=0;C<_.length;C++)E[_.charCodeAt(C)]=C;return E[43]=62,E[47]=63,E})();function v(E){if(typeof E!="string")return null;let C="";for(let D=0;D<E.length;D++){const z=E.charCodeAt(D);if(z!==61){if(z>127||O[z]<0)return null;C+=E[D]}}const x=C.length;if(x%4===1)return null;const j=new Uint8Array(Math.floor(x*3/4));let T=0,F=0,$=0;for(let D=0;D<x;D++)T=T<<6|O[C.charCodeAt(D)],F+=6,F>=8&&(F-=8,j[$++]=T>>F&255);return $===j.length?j:j.subarray(0,$)}function b(E){let C="",x=0;for(;x+2<E.length;x+=3){const T=E[x]<<16|E[x+1]<<8|E[x+2];C+=_[T>>18&63]+_[T>>12&63]+_[T>>6&63]+_[T&63]}const j=E.length-x;if(j===1){const T=E[x]<<16;C+=_[T>>18&63]+_[T>>12&63]}else if(j===2){const T=E[x]<<16|E[x+1]<<8;C+=_[T>>18&63]+_[T>>12&63]+_[T>>6&63]}return C}function c(E){const C=new Uint8Array(E.length);for(let x=0;x<E.length;x++)C[x]=E.charCodeAt(x)&127;return C}function g(E){if(typeof TextDecoder=="function")return new TextDecoder().decode(E);let C="";for(let x=0;x<E.length;x++)C+=String.fromCharCode(E[x]);return C}function o(E){const C={ok:!1,reason:"malformed",product:null,issuedTo:null,expires:null,terms:null,features:[],deployments:[],version:0,message:null,signature:null,raw:typeof E=="string"?E:""};if(typeof E!="string"||E.length===0)return{...C,reason:"missing"};const x=E.trim(),j=x.split(".");if(j.length!==3)return C;const[T,F,$]=j;if(T!==H)return{...C,reason:"prefix"};const D=v(F),z=v($);if(!D||!z)return C;let G;try{G=JSON.parse(g(D))}catch{return C}return G===null||typeof G!="object"?C:{ok:!0,reason:null,product:typeof G.p=="string"?G.p:null,issuedTo:typeof G.t=="string"?G.t:null,expires:typeof G.e=="string"?G.e:null,terms:typeof G.terms=="string"?G.terms:null,features:Array.isArray(G.f)?G.f.slice():[],deployments:Array.isArray(G.d)?G.d.slice():[],version:typeof G.v=="number"?G.v:0,message:c(F),signature:z,raw:x}}function t(E,C){if(!E)return!1;const x=Date.parse(/^\d{4}-\d{2}-\d{2}$/.test(E)?`${E}T23:59:59.999Z`:E);return Number.isNaN(x)?!0:C>x}function s(E){return E==="non-commercial"?"non-commercial":"commercial"}let l=null,u=null,n=null;function p(){const E=globalThis.crypto;return E&&E.subtle?E.subtle:null}async function r(E){if(l&&u===E)return l;const C=p();if(!C)return null;const x=v(E);if(!x)return null;try{const j=await C.importKey("raw",x,{name:"Ed25519"},!1,["verify"]);return l=j,u=E,j}catch{return null}}async function i(){return n!==null||(n=await r(Y)!==null),n}async function d(E,C={}){const x=C.warn!==!1,j=C.product||I,T=C.publicKey||Y,F=C.now??Date.now(),$=C.host??a(),D=h($)?"":` ${U}`,z=o(E);if(!z.ok){const ee=z.reason==="missing"?"missing":"malformed";return x&&A(`licence.${ee}`,ee==="missing"?`no licence key supplied. The grid renders in full and carries a trial watermark on any host other than localhost. Get a key at latticegrid.dev.${D}`:`licence key could not be read. The grid will render with a watermark.${D}`),{valid:!1,reason:ee,terms:"commercial"}}const G={product:z.product||void 0,issuedTo:z.issuedTo||void 0,expires:z.expires||void 0,terms:s(z.terms)};if(z.product!==j)return x&&A("licence.product",`licence key is for '${z.product}', not '${j}'. The grid will render with a watermark.`),{valid:!1,...G,reason:"product"};if(t(z.expires,F))return x&&A("licence.expired",`licence expired on ${z.expires}. The grid will render with a watermark. Renew at latticegrid.dev.`),{valid:!1,...G,reason:"expired"};const N=z.deployments||[];if(N.length&&$&&!h($)&&!y($,N))return x&&A("licence.domain",`licence key is not valid for ${$}; it covers ${N.join(", ")}. The grid will render with a watermark.`),{valid:!1,...G,reason:"domain"};const Z=await r(T);if(!Z){const ee=!!z.signature&&z.signature.length===L;return x&&A("licence.algorithm","this host does not provide crypto.subtle Ed25519, so the licence signature could not be verified. A structural check was used instead."),ee?{valid:!0,...G,reason:"unverified"}:{valid:!1,...G,reason:"signature"}}let Q=!1;try{Q=await p().verify({name:"Ed25519"},Z,z.signature,z.message)}catch{Q=!1}return Q?{valid:!0,...G}:(x&&A("licence.signature","licence signature is not valid. The grid will render with a watermark."),{valid:!1,...G,reason:"signature"})}function h(E){const C=String(E??a()??"").trim().toLowerCase().replace(/^\[/,"").replace(/\]$/,"");return!C||C==="localhost"||C.endsWith(".localhost")||C==="::1"||C==="0:0:0:0:0:0:0:1"?!0:/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(C)}function a(){const E=globalThis.location;return E&&typeof E.hostname=="string"?E.hostname:null}function y(E,C){const x=f(E);return!x||!Array.isArray(C)?!1:C.some(j=>{const T=f(j);if(!T)return!1;if(T==="*")return!0;if(T.startsWith("*.")){const F=T.slice(2);return x===F||x.endsWith(`.${F}`)}return x===T})}function f(E){return String(E??"").trim().toLowerCase().replace(/\.$/,"")}class m{#e="";#t={valid:!1,reason:"missing",terms:"commercial"};#n=null;#r=null;#s;#i=new Set;constructor(C={}){this.#s=C}set(C){this.#e=typeof C=="string"?C.trim():"";const x=o(this.#e);return this.#t=x.ok?{valid:!t(x.expires,Date.now())&&x.product===(this.#s.product||I),product:x.product||void 0,issuedTo:x.issuedTo||void 0,expires:x.expires||void 0,terms:s(x.terms),reason:"pending"}:{valid:!1,reason:x.reason||"malformed",terms:"commercial"},this.#n=null,this.#e&&this.verify(),this.#t}verify(){if(this.#n)return this.#n;const C=this.#e;return this.#n=d(C,this.#s).then(x=>{if(this.#e===C){this.#t=x;for(const j of this.#i)j(x)}return x}),this.#n}onSettled(C){return this.#i.add(C),()=>this.#i.delete(C)}info(){return{...this.#t}}watermark(){return this.#t.valid?!1:!h(this.#r)}setHost(C){this.#r=C}state(){return this.#t.valid?"licensed":h(this.#r)?"localhost":"trial"}reset(){this.#e="",this.#t={valid:!1,reason:"missing",terms:"commercial"},this.#n=null,this.#i.clear()}}const w=Symbol.for("lattice-grid/licence/holder");function S(){const E=globalThis,C=E&&E[w];if(C&&typeof C.set=="function"&&typeof C.watermark=="function")return C;const x=new m;if(E)try{E[w]=x}catch{}return x}const M=S();function X(E){return M.set(E)}function q(){return M.info()}function K(){return M.watermark()}function P(){return M.state()}function k(){return M}}),ze("packages/core/src/registry/registry.js",function(e,B){"use strict";Object.defineProperty(e,"KINDS",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"REGIONS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"Registry",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"sharedRegistry",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"registerModules",{enumerable:!0,get:function(){return l}});const ne=B("packages/core/src/internal/warn.js"),A=ne.warnOnce,V=ne.DEV,I=B("packages/core/src/internal/predicates.js").isFunction,J=B("packages/core/src/registry/licence.js"),H=J.LicenceHolder,L=J.sharedLicence,Y=["renderer","editor","filter","dataType","totalFn","pipe","component"],_=["all","header","body","totals","panels"];class O{#e=new Map;#t=new Map;#n=new Set;#r=new Set;#s;#i=null;#a=null;#l=new Set;#o=new Map;constructor(n={}){for(const p of Y)this.#t.set(p,new Map);this.#s=n.holder||L(),this.#a=n.grid??null,this.#i=this.#s.onSettled(()=>{this.#f({reason:"licence",name:"licence",capabilities:this.capabilities(),regions:["all"]})}),n.licence&&this.setLicence(n.licence)}registerModules(n,p={}){p.licence&&this.setLicence(p.licence),p.grid!==void 0&&(this.#a=p.grid);const r=Array.isArray(n)?n:[n],i=[];for(const d of r){if(!d||typeof d!="object"||typeof d.name!="string"||!d.name){A("registry.module.shape","registerModules received something that is not a module; ignored.");continue}if(this.#e.has(d.name)){V&&this.#u(this.#e.get(d.name),d);continue}if(!I(d.install)){A(`registry.module.install:${d.name}`,`module '${d.name}' has no install() and was ignored.`);continue}const h={registry:this,grid:this.#a};try{d.install(h)}catch(a){A(`registry.module.throw:${d.name}`,`module '${d.name}' threw during install; it was not registered.`,a);continue}this.#e.set(d.name,d);for(const a of v(d))this.#n.add(a);i.push(d.name),this.#f({reason:"module",name:d.name,capabilities:this.capabilities(),regions:g(d)})}return i}unregisterModule(n){const p=this.#e.get(n);if(!p)return!1;if(I(p.uninstall))try{p.uninstall({registry:this,grid:this.#a})}catch(r){A(`registry.module.uninstall:${n}`,`module '${n}' threw during uninstall.`,r)}return this.#e.delete(n),this.#c(),this.#f({reason:"unmodule",name:n,capabilities:this.capabilities(),regions:g(p)}),!0}modules(){return[...this.#e.values()]}has(n){return this.#e.has(n)}#c(){this.#n.clear();for(const n of this.#e.values())for(const p of v(n))this.#n.add(p)}#u(n,p){!n||n===p||b(n,p)||A(`registry.module.reconfigure:${p.name}`,`module '${p.name}' was re-registered with different options; the first registration is kept and this call was ignored. Unregister it first if you mean to replace it.`)}capabilities(){return[...this.#n].sort()}can(n){return this.#n.has(n)}onChange(n){return I(n)?(this.#r.add(n),this.#o.set(n,this.#a),()=>{this.#r.delete(n),this.#o.delete(n)}):()=>{}}#f(n){for(const p of[...this.#r])try{p(n)}catch(r){A("registry.onChange.throw","a registry change handler threw.",r)}}register(n,p,r){const i=this.#t.get(n);if(!i){A(`registry.kind:${n}`,`unknown registry kind '${n}'; expected one of ${Y.join(", ")}.`);return}if(!p||typeof p!="string"){A(`registry.name:${n}`,`register('${n}', ...) needs a name.`);return}i.has(p)&&i.get(p)!==r&&A(`registry.replace:${n}:${p}`,`'${p}' was already registered as a ${n} and has been replaced.`),i.set(p,r),this.#f({reason:"register",name:p,kind:n,capabilities:this.capabilities(),regions:o(n)})}registerAll(n,p){if(p)for(const r of Object.keys(p))this.register(n,r,p[r])}get(n,p){const r=this.#t.get(n);return r?r.get(p):void 0}names(n){const p=this.#t.get(n);return p?[...p.keys()]:[]}#d(n,p){const r=this.#t.get(n).get(p);return r!==void 0?r:this.#t.get("component").get(p)}renderer(n){return this.#d("renderer",n)}editor(n){return this.#d("editor",n)}filter(n){return this.#d("filter",n)}dataType(n){return this.get("dataType",n)}totalFn(n){return this.get("totalFn",n)}pipe(n){return this.get("pipe",n)}setLicence(n){return this.#s.set(n)}licence(){return this.#s.info()}licenceVerified(){return this.#s.verify()}watermark(){return this.#s.watermark()}attach(n){n!=null&&(this.#l.add(n),this.#a=n)}detach(n){if(n!=null){this.#l.delete(n);for(const[p,r]of[...this.#o])r===n&&(this.#r.delete(p),this.#o.delete(p));if(this.#a===n){const p=this.#l.size?[...this.#l][this.#l.size-1]:null;this.#a=p}this.#l.size===0&&this.#i&&(this.#i(),this.#i=null)}}destroy(n){if(n!=null){this.detach(n);return}for(const p of[...this.#e.keys()])this.unregisterModule(p);this.#r.clear(),this.#o.clear(),this.#l.clear(),this.#i&&this.#i(),this.#i=null,this.#a=null}}function v(u){const n=u.capabilities,p=Array.isArray(n)?n.filter(r=>typeof r=="string"):[];return[u.name,...p]}function b(u,n){return u.install!==n.install||u.uninstall!==n.uninstall||(u.version||"")!==(n.version||"")?!1:c(v(u),v(n))&&c(g(u),g(n))}function c(u,n){const p=new Set(u),r=new Set(n);if(p.size!==r.size)return!1;for(const i of p)if(!r.has(i))return!1;return!0}function g(u){const n=u.regions;return!Array.isArray(n)||n.length===0?["all"]:n.filter(p=>_.includes(p))}function o(u){switch(u){case"filter":return["header"];case"totalFn":return["totals"];case"renderer":case"editor":case"pipe":return["body"];default:return["all"]}}const t=new O;function s(){return t}function l(u,n={}){return t.registerModules(u,n)}}),ze("packages/core/src/internal/text.js",function(e,B){"use strict";Object.defineProperty(e,"humanise",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"escapeHtml",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"titleCase",{enumerable:!0,get:function(){return U}});function ne(I){return I?(I.includes(".")?I.slice(I.lastIndexOf(".")+1):I).replace(/[_-]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").replace(/\s+/g," ").trim().replace(/^./,H=>H.toUpperCase()):""}const A={"&":"&","<":"<",">":">",'"':""","'":"'"};function V(I){const J=I==null?"":String(I);return/[&<>"']/.test(J)?J.replace(/[&<>"']/g,H=>A[H]):J}function U(I){return String(I).replace(/\w\S*/g,J=>J[0].toUpperCase()+J.slice(1).toLowerCase())}}),ze("packages/core/src/format/mask.js",function(e,B){"use strict";Object.defineProperty(e,"splitSections",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"parseSection",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return J}});const ne=new Set(["0","#","?",",","."]),A="\0";function V(L){const Y=[];let _="",O=!1;for(let v=0;v<L.length;v++){const b=L[v];if(b==="\\"){_+=b+(L[v+1]??""),v+=1;continue}if(b==='"'){O=!O,_+=b;continue}if(b===";"&&!O){Y.push(_),_="";continue}_+=b}return Y.push(_),Y}function U(L){let Y="",_="",O="",v=1,b=!1,c=!1;const g=i=>{c?_+=i:Y+=i};for(let i=0;i<L.length;i++){const d=L[i];if(d==="\\"){g(L[i+1]??""),i+=1;continue}if(d==='"'){const h=L.indexOf('"',i+1);g(h===-1?L.slice(i+1):L.slice(i+1,h)),i=h===-1?L.length:h;continue}if(d==="%"){v*=100,g("%");continue}if(d==="@"){b=!0,g("\0");continue}if(ne.has(d)){O+=d,c=!0;continue}g(d)}let o=-1;for(let i=O.length-1;i>=0;i--){const d=O[i];if(d==="0"||d==="#"||d==="?"){o=i;break}}let t=!1,s="";for(let i=0;i<O.length;i++){const d=O[i];if(d===","){i>o?v/=1e3:t=!0;continue}s+=d}const l=s.indexOf("."),u=l===-1?s:s.slice(0,l),n=l===-1?"":s.slice(l+1);let p=0;for(const i of u)i==="0"&&(p+=1);let r=0;for(const i of n)i==="0"&&(r+=1);return{prefix:Y,suffix:_,minInt:p,minDec:r,maxDec:n.length,grouping:t,scale:v,hasNumber:o!==-1,isText:b}}function I(L,Y){const _=new Intl.NumberFormat(Y,{minimumIntegerDigits:Math.max(L.minInt,1),minimumFractionDigits:L.minDec,maximumFractionDigits:Math.max(L.maxDec,L.minDec),useGrouping:L.grouping}),{prefix:O,suffix:v,scale:b,hasNumber:c}=L;return g=>{if(!c)return O+v;const o=b===1?g:g*b;return O+_.format(o)+v}}function J(L,Y){const O=V(String(L)).map(U),v=O.map(s=>I(s,Y)),b=0,c=O.length>1?1:-1,g=O.length>2?2:-1,o=O.length>3?3:-1,t=s=>{if(s==null||s==="")return"";if(typeof s!="number"||Number.isNaN(s)){const l=Number(s);if(Number.isNaN(l))return o===-1?String(s):(O[o].prefix+O[o].suffix).split("\0").join(String(s));s=l}return s===0&&g!==-1?v[g](0):s<0&&c!==-1?v[c](-s):v[b](s)};return t.spec={mask:L},{format:t,ooxml:H(String(L))}}function H(L){return L.trim()}}),ze("packages/core/src/format/pattern.js",function(e,B){"use strict";Object.defineProperty(e,"parseNumberPattern",{enumerable:!0,get:function(){return I}});const A=B("packages/core/src/format/mask.js").splitSections;function V(J){let H="",L="",Y="",_="",O=!1,v=!1,b=!1,c=!1;const g=t=>{b?L+=t:H+=t};for(let t=0;t<J.length;t++){const s=J[t];if(s==="\\"){g(J[t+1]??""),t+=1;continue}if(s==='"'){const l=J.indexOf('"',t+1);g(l===-1?J.slice(t+1):J.slice(t+1,l)),t=l===-1?J.length:l;continue}if(s==="%"){v=!0;continue}if(s==="0"||s==="#"){b=!0,c?_+=s:Y+=s;continue}if(s===","){c||(O=!0);continue}if(s==="."&&!c){c=!0;continue}g(s)}if(!b)return{hasDigit:!1,prefix:H,suffix:L,minDec:0,maxDec:0,grouping:!1,percent:v};let o=0;for(const t of _)t==="0"&&(o+=1);return{hasDigit:!0,prefix:H,suffix:L,minDec:o,maxDec:_.length,grouping:O,percent:v}}function U(J,H){const L=H.trim(),Y=J.trim();return L.startsWith("(")&&L.endsWith(")")&&L.slice(1,-1).trim()===Y?"parentheses":L.endsWith("-")?"suffix":"minus"}function I(J){if(typeof J!="string")return null;const H=A(J);if(H.length===0)return null;const L=V(H[0]);if(!L.hasDigit)return null;const Y={style:L.percent?"percent":"decimal",prefix:L.prefix,suffix:L.suffix,minDecimals:L.minDec,maxDecimals:Math.max(L.maxDec,L.minDec),thousandsSeparator:L.grouping?void 0:!1};if(H.length>1&&(Y.negative=U(H[0],H[1])),H.length>2){const _=V(H[2]);_.hasDigit||(Y.zeroDisplay=_.prefix+_.suffix)}return Y}}),ze("packages/core/src/format/number.js",function(e,B){"use strict";Object.defineProperty(e,"compileNumber",{enumerable:!0,get:function(){return H}});const A=B("packages/core/src/internal/predicates.js").isNil,U=B("packages/core/src/internal/warn.js").warnOnce,J=B("packages/core/src/format/pattern.js").parseNumberPattern;function H(L,Y){const _=typeof L=="string"?{pattern:L}:L||{};let O=_;if(typeof _.pattern=="string"){const S=J(_.pattern);if(S){const{pattern:M,...X}=_;O={...S,...X}}else U(`format:pattern:${_.pattern}`,`invalid number format pattern "${_.pattern}"; the value will use the default number format`)}const v=O.locale||Y||void 0,b=O.style||"decimal",c=typeof O.scale=="number"?O.scale:1,g=O.nullDisplay??"",o=O.zeroDisplay,t=O.prefix||"",s=O.suffix||"",l=O.negative||"minus",u=O.signed===!0,n={style:b,notation:O.notation||"standard"};b==="currency"&&(n.currency=O.currency||"USD",O.currencyDisplay&&(n.currencyDisplay=O.currencyDisplay)),typeof O.decimals=="number"?(n.minimumFractionDigits=O.decimals,n.maximumFractionDigits=O.decimals):(typeof O.minDecimals=="number"&&(n.minimumFractionDigits=O.minDecimals),typeof O.maxDecimals=="number"&&(n.maximumFractionDigits=O.maxDecimals),n.minimumFractionDigits>(n.maximumFractionDigits??20)&&(n.maximumFractionDigits=n.minimumFractionDigits)),O.thousandsSeparator===!1&&(n.useGrouping=!1),n.notation==="compact"&&(n.compactDisplay=O.compactDisplay||"short");const p=new Intl.NumberFormat(v,n),r=typeof O.thousandsSeparator=="string"?O.thousandsSeparator:null,i=typeof O.decimalSeparator=="string"?O.decimalSeparator:null;let d=",",h=".";if(r||i)for(const S of p.formatToParts(12345.6))S.type==="group"?d=S.value:S.type==="decimal"&&(h=S.value);const a=S=>{let M=S;return r&&(M=M.split(d).join("")),i&&(M=M.split(h).join("")),r&&(M=M.split("").join(r)),i&&(M=M.split("").join(i)),M},y=!!(r||i),f=t!==""&&b==="currency",m=S=>{let M;if(f){const X=p.formatToParts(S);let q=!1;M="";for(const K of X)M+=K.value,!q&&K.type==="currency"&&(M+=t,q=!0);q||(M=t+M)}else M=t+p.format(S);return y&&(M=a(M)),M+s},w=S=>{if(A(S)||S==="")return g;const M=typeof S=="number"?S:Number(S);if(Number.isNaN(M))return g;const X=c===1?M:M*c;return X===0&&o!==void 0?o:X<0?l==="parentheses"?`(${m(-X)})`:l==="suffix"?`${m(-X)}-`:m(X):u&&X>0?`+${m(X)}`:m(X)};return w.negativeClass=O.negativeClass||null,w.spec=O,w}}),ze("packages/core/src/format/date.js",function(e,B){"use strict";Object.defineProperty(e,"scanPattern",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"toDate",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"compilePattern",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"compileDate",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"toIsoDate",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"toIsoDateTime",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"compareIso",{enumerable:!0,get:function(){return s}});const A=B("packages/core/src/internal/predicates.js").isNil,U=B("packages/core/src/internal/warn.js").warnOnce,I=["yyyy","yy","MMMM","MMM","MM","M","dd","d","EEEE","EEE","HH","H","hh","h","mm","m","ss","s","SSS","a"];function J(l){const u=[];let n=0,p="";const r=()=>{p&&(u.push({token:null,text:p}),p="")};for(;n<l.length;){const i=l[n];if(i==="'"){if(l[n+1]==="'"){p+="'",n+=2;continue}const h=l.indexOf("'",n+1);if(h===-1){p+=l.slice(n+1),n=l.length;continue}p+=l.slice(n+1,h),n=h+1;continue}const d=I.find(h=>l.startsWith(h,n));if(d){r(),u.push({token:d,text:d}),n+=d.length;continue}/[A-Za-z]/.test(i)&&U(`date.pattern.token:${i}`,`the date pattern "${l}" contains '${i}', which is not a supported token, so it is rendered as text. Quote it as a literal to silence this. Supported: ${I.join(" ")}.`),p+=i,n+=1}return r(),u}const H=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?)?$/;function L(l){if(A(l)||l==="")return null;if(l instanceof Date)return Number.isNaN(l.getTime())?null:l;if(typeof l=="number")return Number.isNaN(l)?null:new Date(l);if(typeof l=="string"){const u=H.exec(l.trim());if(u){const[,p,r,i,d="0",h="0",a="0"]=u;return new Date(+p,+r-1,+i,+d,+h,+a)}const n=new Date(l);return Number.isNaN(n.getTime())?null:n}return null}function Y(l,u){return String(l).padStart(u,"0")}function _(l){if(!l)return p=>({year:p.getFullYear(),month:p.getMonth()+1,day:p.getDate(),hour:p.getHours(),minute:p.getMinutes(),second:p.getSeconds(),ms:p.getMilliseconds(),weekday:p.getDay()});const u=new Intl.DateTimeFormat("en-US",{timeZone:l,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,weekday:"short"}),n={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6};return p=>{const r={year:0,month:1,day:1,hour:0,minute:0,second:0,ms:p.getMilliseconds(),weekday:0};for(const i of u.formatToParts(p))switch(i.type){case"year":r.year=Number(i.value);break;case"month":r.month=Number(i.value);break;case"day":r.day=Number(i.value);break;case"hour":r.hour=Number(i.value)%24;break;case"minute":r.minute=Number(i.value);break;case"second":r.second=Number(i.value);break;case"weekday":r.weekday=n[i.value]??0;break;default:break}return r}}function O(l,u,n){const p=J(l),r=_(n),i=new Set(p.filter(f=>f.token).map(f=>f.token)),d=i.has("MMM")?new Intl.DateTimeFormat(u,{month:"short",timeZone:n}):null,h=i.has("MMMM")?new Intl.DateTimeFormat(u,{month:"long",timeZone:n}):null,a=i.has("EEE")?new Intl.DateTimeFormat(u,{weekday:"short",timeZone:n}):null,y=i.has("EEEE")?new Intl.DateTimeFormat(u,{weekday:"long",timeZone:n}):null;return f=>{const m=r(f);let w="";for(const S of p){if(!S.token){w+=S.text;continue}switch(S.token){case"yyyy":w+=Y(m.year,4);break;case"yy":w+=Y(m.year%100,2);break;case"MMMM":w+=h.format(f);break;case"MMM":w+=d.format(f);break;case"MM":w+=Y(m.month,2);break;case"M":w+=String(m.month);break;case"dd":w+=Y(m.day,2);break;case"d":w+=String(m.day);break;case"EEEE":w+=y.format(f);break;case"EEE":w+=a.format(f);break;case"HH":w+=Y(m.hour,2);break;case"H":w+=String(m.hour);break;case"hh":w+=Y(m.hour%12===0?12:m.hour%12,2);break;case"h":w+=String(m.hour%12===0?12:m.hour%12);break;case"mm":w+=Y(m.minute,2);break;case"m":w+=String(m.minute);break;case"ss":w+=Y(m.second,2);break;case"s":w+=String(m.second);break;case"SSS":w+=Y(m.ms,3);break;case"a":w+=m.hour<12?"AM":"PM";break;default:w+=S.text;break}}return w}}const v=[["year",365*24*36e5],["month",720*36e5],["week",168*36e5],["day",24*36e5],["hour",36e5],["minute",6e4],["second",1e3]];function b(l,u){const n=l||{},p=n.locale||u||void 0,r=n.nullDisplay??"",i=n.timeZone;let d;if(n.pattern)d=O(n.pattern,p,i);else if(n.dateStyle||n.timeStyle){const m={timeZone:i};n.dateStyle&&(m.dateStyle=n.dateStyle),n.timeStyle&&(m.timeStyle=n.timeStyle);const w=new Intl.DateTimeFormat(p,m);d=S=>w.format(S)}else{const m=new Intl.DateTimeFormat(p,{dateStyle:"medium",timeZone:i});d=w=>m.format(w)}const h=n.relative?new Intl.RelativeTimeFormat(p,{numeric:"auto"}):null,y=(typeof n.relative=="object"&&n.relative?n.relative.threshold??7:7)*24*36e5,f=(m,w)=>{const S=L(m);if(!S)return r;if(h){const M=w&&typeof w.now=="number"?w.now:Date.now(),X=S.getTime()-M;if(Math.abs(X)<y){for(const[q,K]of v)if(Math.abs(X)>=K||q==="second")return h.format(Math.round(X/K),q)}}return d(S)};return f.spec=n,f}function c(l){if(A(l)||l==="")return null;if(typeof l=="string"){const p=/^(\d{4}-\d{2}-\d{2})/.exec(l.trim());if(p)return p[1];const r=L(l);return r?c(r):null}const u=L(l);if(!u)return null;const n=p=>String(p).padStart(2,"0");return`${u.getFullYear()}-${n(u.getMonth()+1)}-${n(u.getDate())}`}function g(l,u){if(A(l)||l==="")return null;if(typeof l=="string"){const p=l.trim();if(o.test(p)){const d=L(p);return d?t(d,u):null}const r=/^(\d{4}-\d{2}-\d{2})[T ](\d{2}):(\d{2})(?::(\d{2}))?/.exec(p);if(r){const[,d,h,a,y]=r;return`${d}T${h}:${a}${y&&y!=="00"?`:${y}`:""}`}if(/^\d{4}-\d{2}-\d{2}$/.test(p))return`${p}T00:00`;const i=L(p);return i?g(i):null}const n=L(l);return n?t(n,u):null}const o=/(?:Z|[+-]\d{2}:?\d{2})$/i;function t(l,u){const n=d=>String(d).padStart(2,"0");if(u)try{const d=new Intl.DateTimeFormat("en-CA",{timeZone:u,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(l).reduce((y,f)=>(f.type!=="literal"&&(y[f.type]=f.value),y),{}),h=d.hour==="24"?"00":d.hour,a=Number(d.second);return`${d.year}-${d.month}-${d.day}T${h}:${d.minute}`+(a?`:${d.second}`:"")}catch{}const p=`${l.getFullYear()}-${n(l.getMonth()+1)}-${n(l.getDate())}`,r=l.getSeconds(),i=`${n(l.getHours())}:${n(l.getMinutes())}${r?`:${n(r)}`:""}`;return`${p}T${i}`}function s(l,u){const n=A(l)||l===""?null:String(l),p=A(u)||u===""?null:String(u);return n===null?p===null?0:1:p===null||n<p?-1:n>p?1:0}}),ze("packages/core/src/format/boolean.js",function(e,B){"use strict";Object.defineProperty(e,"toTriState",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"compileBoolean",{enumerable:!0,get:function(){return J}});const A=B("packages/core/src/internal/predicates.js").isNil,V={true:"☑",false:"☐",null:""},U={true:"◉",false:"◯",null:""};function I(H){if(A(H)||H==="")return null;if(typeof H=="boolean")return H;if(typeof H=="number")return H!==0;const L=String(H).trim().toLowerCase();return L==="true"||L==="yes"||L==="y"||L==="1"?!0:L==="false"||L==="no"||L==="n"||L==="0"?!1:null}function J(H,L){const Y=H||{},_=Y.display||"text",O=Y.trueLabel??"Yes",v=Y.falseLabel??"No",b=Y.nullLabel??"";let c=O,g=v;const o=b;_==="checkbox"?(c=V.true,g=V.false):_==="switch"?(c=U.true,g=U.false):_==="icon"&&(c=Y.trueIcon??O,g=Y.falseIcon??v);const t=s=>{const l=I(s);return l===null?o:l?c:g};return t.display=_,t.labels={true:O,false:v,null:b},t.locale=L,t.spec=Y,t}}),ze("packages/core/src/format/text.js",function(e,B){"use strict";Object.defineProperty(e,"compileText",{enumerable:!0,get:function(){return I}});const A=B("packages/core/src/internal/predicates.js").isNil,U=B("packages/core/src/internal/text.js").titleCase;function I(J,H){const L=J||{},Y=L.locale||H||void 0,_=L.nullDisplay??"",O=L.emptyDisplay??"",v=L.transform||"none",b=typeof L.truncate=="number"?{chars:L.truncate}:L.truncate||null,c=b?b.chars:0,g=b?b.ellipsis??"…":"",o=s=>{switch(v){case"upper":return Y?s.toLocaleUpperCase(Y):s.toUpperCase();case"lower":return Y?s.toLocaleLowerCase(Y):s.toLowerCase();case"title":return U(s);default:return s}},t=s=>{if(A(s))return _;let l=typeof s=="string"?s:String(s);return l===""?O:(v!=="none"&&(l=o(l)),c>0&&l.length>c&&(l=l.slice(0,c)+g),l)};return t.spec=L,t}}),ze("packages/core/src/format/shorthand.js",function(e,B){"use strict";Object.defineProperty(e,"looksLikeMask",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"looksLikeDatePattern",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"parseShorthand",{enumerable:!0,get:function(){return H}});const ne=["currency","number","percent","date","boolean","text","relative"],A=/[#0?@;"\\]/,V=/(yyyy|yy|MMMM|MMM|MM|EEEE|EEE|dd|HH|hh|mm|ss|SSS)/;function U(L){return typeof L!="string"||L===""||J(L)?!1:A.test(L)}function I(L){return typeof L!="string"||L===""||J(L)?!1:V.test(L)}function J(L){const Y=L.indexOf(":"),_=Y===-1?L:L.slice(0,Y);return ne.includes(_)?_:null}function H(L){const Y=J(L);if(!Y)return null;const _=L.indexOf(":"),O=_===-1?"":L.slice(_+1),v=O===""?[]:O.split(":");switch(Y){case"currency":{const b={type:"number",style:"currency",currency:v[0]||"USD"};return v[1]!==void 0&&v[1]!==""&&(b.decimals=Number(v[1])),b}case"number":{const b={type:"number",style:"decimal"};return v[0]!==void 0&&v[0]!==""&&(b.decimals=Number(v[0])),b}case"percent":{const b={type:"number",style:"percent"};return v[0]!==void 0&&v[0]!==""&&(b.decimals=Number(v[0])),b}case"date":return{type:"date",pattern:O||void 0};case"relative":return{type:"date",relative:!0};case"boolean":{const b=O.split("/"),c={type:"boolean",display:"text"};return b[0]!==void 0&&b[0]!==""&&(c.trueLabel=b[0]),b[1]!==void 0&&b[1]!==""&&(c.falseLabel=b[1]),b[2]!==void 0&&(c.nullLabel=b[2]),c}case"text":{const b={type:"text"};return v[0]&&(b.transform=v[0]),v[1]!==void 0&&v[1]!==""&&(b.truncate=Number(v[1])),b}default:return null}}}),ze("packages/core/src/format/index.js",function(e,B){"use strict";Object.defineProperty(e,"compileFormat",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"specToOoxml",{enumerable:!0,get:function(){return M}});const ne=B("packages/core/src/internal/predicates.js"),A=ne.isFunction,V=ne.isObject,I=B("packages/core/src/internal/warn.js").warnOnce,J=B("packages/core/src/format/number.js"),H=J.compileNumber,L=B("packages/core/src/format/date.js"),Y=L.compileDate,_=L.scanPattern,O=B("packages/core/src/format/boolean.js"),v=O.compileBoolean,b=B("packages/core/src/format/text.js"),c=b.compileText,g=B("packages/core/src/format/mask.js"),o=g.compileMask,t=B("packages/core/src/format/shorthand.js"),s=t.parseShorthand,l=t.looksLikeMask,u=t.looksLikeDatePattern,p=B("packages/core/src/format/pattern.js").parseNumberPattern;Object.defineProperty(e,"compileNumber",{enumerable:!0,get:function(){return J.compileNumber}}),Object.defineProperty(e,"compileDate",{enumerable:!0,get:function(){return L.compileDate}}),Object.defineProperty(e,"compilePattern",{enumerable:!0,get:function(){return L.compilePattern}}),Object.defineProperty(e,"scanPattern",{enumerable:!0,get:function(){return L.scanPattern}}),Object.defineProperty(e,"toDate",{enumerable:!0,get:function(){return L.toDate}}),Object.defineProperty(e,"compileBoolean",{enumerable:!0,get:function(){return O.compileBoolean}}),Object.defineProperty(e,"toTriState",{enumerable:!0,get:function(){return O.toTriState}}),Object.defineProperty(e,"compileText",{enumerable:!0,get:function(){return b.compileText}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return g.compileMask}}),Object.defineProperty(e,"splitSections",{enumerable:!0,get:function(){return g.splitSections}}),Object.defineProperty(e,"parseSection",{enumerable:!0,get:function(){return g.parseSection}}),Object.defineProperty(e,"parseShorthand",{enumerable:!0,get:function(){return t.parseShorthand}}),Object.defineProperty(e,"looksLikeMask",{enumerable:!0,get:function(){return t.looksLikeMask}}),Object.defineProperty(e,"looksLikeDatePattern",{enumerable:!0,get:function(){return t.looksLikeDatePattern}});const r=new Set(["decimal","currency","percent","unit"]),i=new Set(["type","locale"]),d={number:new Set(["style","currency","currencyDisplay","decimals","minDecimals","maxDecimals","thousandsSeparator","decimalSeparator","notation","compactDisplay","negative","negativeClass","signed","prefix","suffix","zeroDisplay","nullDisplay","messages","scale","pattern"]),date:new Set(["pattern","dateStyle","timeStyle","timeZone","relative","nullDisplay"]),boolean:new Set(["display","trueLabel","falseLabel","nullLabel","trueIcon","falseIcon"]),text:new Set(["transform","truncate","nullDisplay","emptyDisplay"])},h=new Set(["number","date","boolean","text"]);function a(P,k){const E=P.type;if(E===void 0||h.has(E)||!r.has(String(E)))return;const C=k?`"${k}"`:"with no id";I(`format:unknown-style-key:${k||""}:${E}`,`column ${C} has format: { type: "${E}" }, which is not a valid format type ("number", "date", "boolean" or "text") and is ignored; did you mean style: "${E}" instead?`)}function y(P,k,E){const C=d[k],x=E?`"${E}"`:"with no id";for(const j of P){if(i.has(j)||C.has(j))continue;const T=Object.keys(d).find(F=>F!==k&&d[F].has(j));T?I(`format:inapplicable:${E||""}:${j}`,`column ${x} has format key "${j}", which applies to a ${T} column, not the ${k} column it was applied to; it is ignored.`):I(`format:unknown:${E||""}:${j}`,`column ${x} has an unrecognised format key "${j}" for its ${k} format; it is ignored.`)}}function f(P){if(P.type==="number"||P.type==="date"||P.type==="boolean"||P.type==="text")return!0;const k=r.has(String(P.style));return!!(P.pattern||P.dateStyle||P.timeStyle||P.relative||P.timeZone||P.trueLabel||P.falseLabel||P.display||P.trueIcon||P.falseIcon||P.transform||P.truncate||P.emptyDisplay||k||P.currency||P.decimals!==void 0||P.minDecimals!==void 0||P.maxDecimals!==void 0||P.notation||P.negative||P.scale!==void 0||P.prefix||P.suffix||P.zeroDisplay!==void 0)}function m(P,k){if(P.type==="number"||P.type==="date"||P.type==="boolean"||P.type==="text")return P.type;if(P.pattern){if(l(P.pattern))return"number";if(u(P.pattern))return"date"}if(P.dateStyle||P.timeStyle||P.relative||P.timeZone)return"date";if(P.trueLabel||P.falseLabel||P.display||P.trueIcon||P.falseIcon)return"boolean";if(P.transform||P.truncate||P.emptyDisplay)return"text";if(P.style||P.currency||P.decimals!==void 0||P.minDecimals!==void 0||P.maxDecimals!==void 0||P.notation||P.negative||P.scale!==void 0||P.prefix||P.suffix||P.zeroDisplay!==void 0)return"number";const E=k&&k.base;return E==="number"?"number":E==="date"||E==="dateString"?"date":E==="boolean"?"boolean":"text"}function w(P,k=null,E=void 0,C=void 0,x=void 0){if(P==null||P==="")return null;const j=V(P)?Object.keys(P):null;if(typeof P=="function"){const $=(D,z)=>String(P({...z||{},value:D,locale:E})??"");return $.ooxml=k&&k.excel||"General",$}if(typeof P=="string"){if(l(P)){const{format:D,ooxml:z}=o(P,E);return D.ooxml=z,D}const $=s(P)||(u(P)?{type:"date",pattern:P}:null);return $?w($,k,E,C,x):(I(`format:${P}`,`unrecognised format string "${P}"; the value will be stringified`),null)}if(!V(P))return I("format:shape","format must be a spec object or a string; ignoring",P),null;if(k&&A(k.format)&&!f(P)||k&&A(k.format)&&Array.isArray(k.formatPatterns)&&P.type===void 0)return null;const T=m(P,k);T==="date"&&C&&P.timeZone===void 0&&(P={...P,timeZone:C}),a(P,x),y(j||Object.keys(P),T,x);let F;switch(T){case"number":F=H(P,E);break;case"date":F=Y(P,E);break;case"boolean":F=v(P,E);break;default:F=c(P,E);break}return F.ooxml=M(P,T,E,k),F.kind=T,F}const S={yyyy:"yyyy",yy:"yy",MMMM:"mmmm",MMM:"mmm",MM:"mm",M:"m",dd:"dd",d:"d",EEEE:"dddd",EEE:"ddd",HH:"hh",H:"h",hh:"hh",h:"h",mm:"mm",m:"m",ss:"ss",s:"s",SSS:"000",a:"AM/PM"};function M(P,k,E=void 0,C=null){if(k==="date"){if(P.pattern){let $="";for(const D of _(P.pattern))$+=D.token?S[D.token]??D.text:D.text;return $}return C&&C.excel||"yyyy-mm-dd"}if(k==="boolean")return"General";if(k==="text")return"@";if(typeof P.pattern=="string"&&p(P.pattern))return String(P.pattern).trim();if(P.notation==="compact"||P.notation==="scientific")return"General";const x=typeof P.decimals=="number"?P.decimals:typeof P.minDecimals=="number"?P.minDecimals:P.style==="currency"?2:0;let T=`${P.thousandsSeparator===!1?"":"#,#"}#0${x>0?`.${"0".repeat(x)}`:""}`,F="";return P.style==="currency"&&(F+=X(K(P.currency||"USD",E))),P.prefix&&(F+=X(P.prefix)),T=F+T,P.style==="percent"&&(T=`${T}%`),P.suffix&&(T+=X(P.suffix)),P.negative==="parentheses"?`${T};(${T})`:P.negative==="suffix"?`${T};${T}-`:T}function X(P){return`"${String(P).split('"').join("")}"`}const q=new Map;function K(P,k){const E=`${P}|${k||""}`;let C=q.get(E);if(C!==void 0)return C;C=P;try{const j=new Intl.NumberFormat(k,{style:"currency",currency:P}).formatToParts(0).find(T=>T.type==="currency");j&&(C=j.value)}catch{}return q.set(E,C),C}}),ze("packages/core/src/columns/types/temporal.js",function(e,B){"use strict";Object.defineProperty(e,"MS_SECOND",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"MS_MINUTE",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"MS_HOUR",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"MS_DAY",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"MS_WEEK",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"parseTime",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"toTimeMs",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"formatTime",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"zonedParts",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"zoneOffsetAt",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"instantFromParts",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"parseDateTime",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"toEpochMs",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"formatDateTime",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"parseDuration",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(e,"toDurationMs",{enumerable:!0,get:function(){return re}}),Object.defineProperty(e,"formatDuration",{enumerable:!0,get:function(){return he}}),Object.defineProperty(e,"zoneAbbrev",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(e,"resolveZoneName",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(e,"zoneLabel",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(e,"formatInstant",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(e,"bucketInstant",{enumerable:!0,get:function(){return we}}),Object.defineProperty(e,"timestampGroupProjector",{enumerable:!0,get:function(){return Te}}),Object.defineProperty(e,"TEMPORAL_TYPES",{enumerable:!0,get:function(){return Ne}}),Object.defineProperty(e,"TEMPORAL_INFERENCE_ORDER",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return $e}});const ne=B("packages/core/src/internal/predicates.js"),A=ne.isNil,V=ne.isFunction,U=B("packages/core/src/format/date.js"),I=U.toDate,J=U.compilePattern,H=U.compileDate,L=U.toIsoDateTime,Y=U.compareIso,_=864e5,O=Object.freeze({}),v=1e3,b=60*v,c=60*b,g=24*c,o=7*g,t=new WeakMap;function s(je,Ge){const Fe=je&&je.locale||"",Pe=je&&je.column;if(!Pe)return Fe?{locale:Fe}:O;const Ee=t.get(Pe);if(Ee&&Ee.locale===Fe)return Ee.bag;const Me=Pe.typeOptions||Pe[Ge]||(l(Pe.format)?Pe.format:null),Ie={...Me||O,locale:Me&&Me.locale||Fe||void 0};return t.set(Pe,{locale:Fe,bag:Ie}),Ie}function l(je){return je!==null&&typeof je=="object"&&!Array.isArray(je)&&!(je instanceof Date)}function u(je,Ge){const Fe=je===null||Number.isNaN(je)?null:je,Pe=Ge===null||Number.isNaN(Ge)?null:Ge;return Fe===null?Pe===null?0:1:Pe===null||Fe<Pe?-1:Fe>Pe?1:0}const n=/^(\d{1,2})(?:\s*[:.h]\s*(\d{1,2})(?:\s*[:.]\s*(\d{1,2})(?:[.,](\d{1,3}))?)?)?\s*(a\.?m\.?|p\.?m\.?|a|p)?$/i,p=/^(\d{3,6})$/;function r(je,Ge,Fe,Pe){return!(je>=0&&je<=23)||!(Ge>=0&&Ge<=59)||!(Fe>=0&&Fe<=59)||!(Pe>=0&&Pe<=999)?null:je*c+Ge*b+Fe*v+Pe}function i(je){if(A(je))return null;const Ge=String(je).trim();if(Ge==="")return null;const Fe=p.exec(Ge);if(Fe){const nt=Fe[1];if(nt.length===5)return null;const Qe=nt.length===3?1:2;return r(Number(nt.slice(0,Qe)),Number(nt.slice(Qe,Qe+2)),Number(nt.slice(Qe+2,Qe+4)||0),0)}const Pe=n.exec(Ge);if(!Pe)return null;let Ee=Number(Pe[1]);const Me=Number(Pe[2]||0),Ie=Number(Pe[3]||0),We=Pe[4]?Number(Pe[4].padEnd(3,"0")):0,Ye=Pe[5]?Pe[5][0].toLowerCase():null;if(Ye){if(Ee<1||Ee>12)return null;Ee=Ee%12,Ye==="p"&&(Ee+=12)}return r(Ee,Me,Ie,We)}function d(je){return A(je)||je===""?null:typeof je=="number"?Number.isFinite(je)?(je%g+g)%g:null:je instanceof Date?Number.isNaN(je.getTime())?null:je.getHours()*c+je.getMinutes()*b+je.getSeconds()*v+je.getMilliseconds():i(je)}const h=new Map;function a(je){const Ge=je.pattern||"",Fe=je.timeStyle||(je.seconds?"medium":"short"),Pe=`${je.locale||""}|${Ge}|${Fe}`;let Ee=h.get(Pe);if(Ee)return Ee;if(Ge)Ee=J(Ge,je.locale||void 0,"UTC");else{const Me=new Intl.DateTimeFormat(je.locale||void 0,{timeStyle:Fe,timeZone:"UTC"});Ee=Ie=>Me.format(Ie)}return h.set(Pe,Ee),Ee}function y(je,Ge){const Fe=Ge||O;if(je==null||typeof je!="number"||!Number.isFinite(je))return Fe.nullDisplay??"";const Pe=(je%g+g)%g;return a(Fe)(new Date(Pe))}function f(je){return je instanceof Date?!Number.isNaN(je.getTime()):typeof je=="number"?Number.isFinite(je)&&je>=0&&je<g:typeof je!="string"||!je.includes(":")?!1:i(je)!==null}function m(je){const Ge=d(je);return Ge==null?"":y(Ge,{pattern:Ge%v===0?"HH:mm:ss":"HH:mm:ss.SSS"})}const w=new Map;function S(je){const Ge=je||"";let Fe=w.get(Ge);return Fe||(Fe=new Intl.DateTimeFormat("en-GB",{timeZone:je||void 0,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}),w.set(Ge,Fe)),Fe}function M(je,Ge){const Fe={year:1970,month:1,day:1,hour:0,minute:0,second:0};for(const Pe of S(Ge).formatToParts(new Date(je)))Pe.type==="year"?Fe.year=Number(Pe.value):Pe.type==="month"?Fe.month=Number(Pe.value):Pe.type==="day"?Fe.day=Number(Pe.value):Pe.type==="hour"?Fe.hour=Number(Pe.value)%24:Pe.type==="minute"?Fe.minute=Number(Pe.value):Pe.type==="second"&&(Fe.second=Number(Pe.value));return Fe}function X(je,Ge){const Fe=M(je,Ge);return Date.UTC(Fe.year,Fe.month-1,Fe.day,Fe.hour,Fe.minute,Fe.second,0)-Math.floor(je/1e3)*1e3}function q(je,Ge){const Fe=je.hour||0,Pe=je.minute||0,Ee=je.second||0,Me=je.ms||0;if(!Ge)return new Date(je.year,je.month-1,je.day,Fe,Pe,Ee,Me).getTime();const Ie=Date.UTC(je.year,je.month-1,je.day,Fe,Pe,Ee,Me);let We=Ie-X(Ie,Ge);return We=Ie-X(We,Ge),We}const K=/(?:Z|[+-]\d{2}:?\d{2})$/i,P=/^(\d{4})-(\d{1,2})-(\d{1,2})(?:[T\s]+(.*))?$/;function k(je,Ge){if(A(je))return null;const Fe=String(je).trim();if(Fe==="")return null;const Pe=Ge&&Ge.timeZone||void 0;if(!K.test(Fe)){const Ee=P.exec(Fe);if(Ee){const Me=(Ee[4]||"").trim(),Ie=Me===""?0:i(Me);if(Ie===null)return null;const We=q({year:Number(Ee[1]),month:Number(Ee[2]),day:Number(Ee[3]),hour:Math.floor(Ie/c),minute:Math.floor(Ie/b)%60,second:Math.floor(Ie/v)%60,ms:Ie%v},Pe);return Number.isNaN(We)?null:new Date(We)}}return I(Fe)}function E(je){if(typeof je=="number")return Number.isFinite(je)?je:null;const Ge=I(je);return Ge?Ge.getTime():null}const C=new Map;function x(je){const Ge=[je.locale||"",je.pattern||"",je.dateStyle||"",je.timeStyle||"",je.timeZone||"",je.seconds?"1":""].join("|");let Fe=C.get(Ge);if(Fe)return Fe;const Pe=je.pattern?{type:"date",pattern:je.pattern,timeZone:je.timeZone}:{type:"date",dateStyle:je.dateStyle||"medium",timeStyle:je.timeStyle||(je.seconds?"medium":"short"),timeZone:je.timeZone};return Fe=H(Pe,je.locale||void 0),C.set(Ge,Fe),Fe}function j(je,Ge){const Fe=Ge||O,Pe=E(je);return Pe==null?Fe.nullDisplay??"":x(Fe)(Pe)}function T(je){return je instanceof Date?!Number.isNaN(je.getTime()):typeof je!="string"||!P.test(je.trim())?!1:k(je)!==null}const F=Object.freeze([{key:"w",ms:o,intl:"week",long:["week","weeks"],names:["w","wk","wks","week","weeks"]},{key:"d",ms:g,intl:"day",long:["day","days"],names:["d","dy","day","days"]},{key:"h",ms:c,intl:"hour",long:["hour","hours"],names:["h","hr","hrs","hour","hours"]},{key:"m",ms:b,intl:"minute",long:["minute","minutes"],names:["m","min","mins","minute","minutes"]},{key:"s",ms:v,intl:"second",long:["second","seconds"],names:["s","sec","secs","second","seconds"]},{key:"ms",ms:1,intl:"millisecond",long:["millisecond","milliseconds"],names:["ms","msec","msecs","milli","millis","millisecond","milliseconds"]}]),$=new Map;for(const je of F)for(const Ge of je.names)$.set(Ge,je);const D=Object.freeze(F.filter(je=>je.key!=="w")),z=/^(\d+(?:\.\d+)?)\s*([a-z]+)\s*(?:,\s*)?/,G=/^\d+(?:\.\d+)?$/,N=/^(\d+):([0-5]?\d)(?::([0-5]?\d))?(?:\.(\d{1,3}))?$/;function Z(je){const Ge=je&&je.defaultUnit?$.get(String(je.defaultUnit).toLowerCase()):null;return Ge?Ge.ms:b}function Q(je){return(je&&je.defaultUnit?$.get(String(je.defaultUnit).toLowerCase()):null)||$.get("m")}function ee(je,Ge){if(A(je))return null;let Fe=String(je).trim().toLowerCase();if(Fe==="")return null;let Pe=1;if(Fe[0]==="-"?(Pe=-1,Fe=Fe.slice(1).trim()):Fe[0]==="+"&&(Fe=Fe.slice(1).trim()),Fe==="")return null;const Ee=N.exec(Fe);if(Ee){const Ye=Ee[3]!==void 0,nt=Number(Ee[1])*c+Number(Ee[2])*b+(Ye?Number(Ee[3])*v:0)+(Ee[4]?Number(Ee[4].padEnd(3,"0")):0);return Pe*nt}if(G.test(Fe))return Math.round(Pe*Number(Fe)*Z(Ge||O));let Me=Fe,Ie=0,We=0;for(;Me!=="";){const Ye=z.exec(Me);if(!Ye)return null;const nt=$.get(Ye[2]);if(!nt)return null;Ie+=Number(Ye[1])*nt.ms,Me=Me.slice(Ye[0].length),We++}return We===0?null:Math.round(Pe*Ie)}function re(je){return A(je)||je===""?null:typeof je=="number"?Number.isFinite(je)?je:null:ee(je)}const ie=new Map;function ce(je,Ge,Fe){const Pe=`${Fe||""}|${Ge.intl}`;let Ee=ie.get(Pe);if(Ee===void 0){try{Ee=new Intl.NumberFormat(Fe||void 0,{style:"unit",unit:Ge.intl,unitDisplay:"long"})}catch{Ee=null}ie.set(Pe,Ee)}return Ee?Ee.format(je):`${je} ${je===1?Ge.long[0]:Ge.long[1]}`}function ve(je,Ge){return String(je).padStart(Ge,"0")}function he(je,Ge){const Fe=Ge||O;if(je==null||typeof je!="number"||!Number.isFinite(je))return Fe.nullDisplay??"";const Pe=Fe.style||"short",Ee=je<0;let Me=Math.round(Math.abs(je));const Ie=Ee?"-":"";if(Me===0&&Fe.zeroDisplay!=null)return Fe.zeroDisplay;if(Pe==="clock"){const Qe=Math.floor(Me/c),dt=Math.floor(Me/b)%60,jt=Math.floor(Me/v)%60;return`${Ie}${ve(Qe,2)}:${ve(dt,2)}:${ve(jt,2)}`}if(Me===0){const Qe=Q(Fe);return Pe==="long"?ce(0,Qe,Fe.locale):`0${Qe.key}`}const We=Fe.weeks===!0?F:D,Ye=typeof Fe.maxUnits=="number"&&Fe.maxUnits>0?Fe.maxUnits:Fe.maxUnits===void 0?2:1/0,nt=[];for(const Qe of We){if(nt.length>=Ye)break;const dt=Math.floor(Me/Qe.ms);dt!==0&&(Me-=dt*Qe.ms,nt.push(Pe==="long"?ce(dt,Qe,Fe.locale):`${dt}${Qe.key}`))}return Ie+nt.join(" ")}function ye(je){if(typeof je!="string")return!1;const Ge=je.trim();return Ge===""||N.test(Ge)||!/[a-z]/i.test(Ge)?!1:ee(Ge)!==null}const Oe=Date.UTC(1899,11,30),Le=new Map;function fe(je,Ge){const Fe=je||"";let Pe=Le.get(Fe);Pe||(Pe=new Intl.DateTimeFormat("en-GB",{timeZone:je||void 0,timeZoneName:"short",hour:"2-digit",hour12:!1}),Le.set(Fe,Pe));const Ee=typeof Ge=="number"?Ge:Date.now();for(const Me of Pe.formatToParts(new Date(Ee)))if(Me.type==="timeZoneName")return Me.value;return""}function ae(je){if(je)return je;try{return new Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function ke(je,Ge){const Fe=ae(je),Pe=fe(je,Ge);return Pe?`${Fe} (${Pe})`:Fe}function pe(je,Ge){if(je&&je.timeZone)return je.timeZone;const Fe=Ge&&Ge.grid;return(Fe&&V(Fe.get)?Fe.get("timeZone"):void 0)||void 0}function ue(je,Ge){const Fe=Ge||O,Pe=E(je);if(Pe==null)return Fe.nullDisplay??"";const Ee=x(Fe)(Pe);if(!Fe.showOrigin)return Ee;const Me=Fe.originZone;return Me?Me===(Fe.timeZone||ae(Fe.timeZone))?Ee:`${Ee} (${ke(Me,Pe)})`:`${Ee} (no origin recorded)`}function we(je,Ge,Fe,Pe){if(Ge==="instant"||!Ge)return je;const Ee=M(je,Fe);if(Ge==="month")return q({year:Ee.year,month:Ee.month,day:1},Fe);if(Ge==="week"){const Me=Pe>=1&&Pe<=7?Pe:1,We=((new Date(Date.UTC(Ee.year,Ee.month-1,Ee.day)).getUTCDay()+6)%7+1-Me+7)%7,Ye=new Date(Date.UTC(Ee.year,Ee.month-1,Ee.day-We));return q({year:Ye.getUTCFullYear(),month:Ye.getUTCMonth()+1,day:Ye.getUTCDate()},Fe)}return q({year:Ee.year,month:Ee.month,day:Ee.day},Fe)}function Te(je,Ge){const Fe=je&&je.group,Pe=Fe&&Fe.granularity||"day";if(Pe==="instant")return null;const Ee=Fe&&Fe.weekStart;return Me=>typeof Me=="number"?we(Me,Pe,Ge,Ee):Me}const Ne={time:{base:"number",storage:"float64",matches:f,format:je=>y(d(je.value),s(je,"time")),parse:je=>i(je.text),compare:(je,Ge)=>u(d(je),d(Ge)),defaults:{filter:"number",editor:"time",align:"start"},excel:"hh:mm:ss",excelKind:"number",toExcelValue:je=>{const Ge=d(je);return Ge===null?null:Ge/_},toStorage:je=>d(je),toClipboard:m,fromClipboard:i},datetime:{base:"dateString",storage:"dictionary",matches:T,format:je=>j(je.value,s(je,"datetime")),parse:je=>L(k(je.text,s(je,"datetime"))??je.text),compare:Y,defaults:{filter:"date",editor:"datetime",align:"start"},excel:"yyyy-mm-dd hh:mm",toStorage:(je,Ge)=>L(je,Ge&&Ge.timeZone),toClipboard:je=>A(je)?"":String(je),fromClipboard:je=>L(je)},duration:{base:"number",storage:"float64",matches:ye,format:je=>he(re(je.value),s(je,"duration")),parse:je=>ee(je.text,s(je,"duration")),compare:(je,Ge)=>u(re(je),re(Ge)),defaults:{filter:"number",editor:"duration",align:"end",total:"sum"},excel:"[h]:mm:ss",excelKind:"number",toExcelValue:je=>{const Ge=re(je);return Ge===null?null:Ge/_},toStorage:je=>re(je),toClipboard:je=>he(re(je),{style:"short",maxUnits:-1}),fromClipboard:je=>ee(je)},timestamp:{base:"number",storage:"float64",format:je=>{const Ge=s(je,"timestamp");return ue(je.value,{...Ge,timeZone:pe(Ge,je)})},parse:je=>{const Ge=s(je,"timestamp"),Fe=k(je.text,{timeZone:pe(Ge,je)});return Fe?Fe.getTime():null},compare:(je,Ge)=>u(E(je),E(Ge)),groupProjector:(je,Ge)=>Te(je,Ge),defaults:{filter:"date",editor:"datetime",align:"start"},excel:"yyyy-mm-dd hh:mm",excelKind:"number",toExcelValue:(je,Ge)=>{const Fe=E(je);if(Fe==null)return null;const Pe=M(Fe,Ge&&Ge.timeZone||void 0);return(Date.UTC(Pe.year,Pe.month-1,Pe.day,Pe.hour,Pe.minute,Pe.second)-Oe)/_},toStorage:je=>E(je),toClipboard:je=>{const Ge=E(je);return Ge==null?"":new Date(Ge).toISOString()},fromClipboard:je=>E(je)}},_e=["datetime","time","duration"],$e=Ne}),ze("packages/core/src/internal/lru.js",function(e,B){"use strict";Object.defineProperty(e,"Lru",{enumerable:!0,get:function(){return ne}});class ne{#e;#t=new Map;#n;constructor(V=256,U=null){this.#e=V,this.#n=U}get size(){return this.#t.size}get max(){return this.#e}set max(V){this.#e=V,this.#r()}has(V){return this.#t.has(V)}get(V){const U=this.#t;if(!U.has(V))return;const I=U.get(V);return U.delete(V),U.set(V,I),I}peek(V){return this.#t.get(V)}set(V,U){const I=this.#t;return I.has(V)&&I.delete(V),I.set(V,U),this.#r(),U}delete(V){const U=this.#t.get(V);return this.#t.delete(V)&&this.#n&&this.#n(U,V),U}clear(){if(this.#n)for(const[V,U]of this.#t)this.#n(U,V);this.#t.clear()}keys(){return this.#t.keys()}values(){return this.#t.values()}#r(){const V=this.#t;for(;V.size>this.#e;){const U=V.keys().next().value,I=V.get(U);V.delete(U),this.#n&&this.#n(I,U)}}}}),ze("packages/core/src/columns/types/network.js",function(e,B){"use strict";Object.defineProperty(e,"toUint32",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"parseIpv4",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"formatIpv4",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"isIpv4",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"compareIpv4",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"packCidr",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"cidrParts",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"parseCidr",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"formatCidr",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"isCidr",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"compareCidr",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"netmask",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"networkAddress",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"broadcastAddress",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"addressCount",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"hostCount",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"containsAddress",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"overlaps",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"ipv6Groups",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"parseIpv6",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"formatIpv6",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"isIpv6",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"compareIpv6",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"NETWORK_TYPES",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return E}});const A=B("packages/core/src/internal/predicates.js").isNil,U=B("packages/core/src/internal/lru.js").Lru,I=4294967295,J=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;function H(C){if(A(C))return null;if(typeof C=="string")return L(C);const x=Number(C);return Number.isFinite(x)?x<0?x<-2147483648?null:x>>>0:x>I?null:Math.trunc(x)>>>0:null}function L(C){if(A(C))return null;const x=String(C).trim();if(x==="")return null;const j=J.exec(x);if(!j)return null;let T=0;for(let F=1;F<=4;F++){const $=j[F];if($.length>1&&$.charCodeAt(0)===48)return null;const D=Number($);if(D>255)return null;T=T*256+D}return T}function Y(C){const x=H(C);return x===null?"":`${x>>>24&255}.${x>>>16&255}.${x>>>8&255}.${x&255}`}function _(C){return typeof C=="string"&&L(C)!==null}function O(C,x){const j=H(C),T=H(x);return j===null?T===null?0:1:T===null||j<T?-1:j>T?1:0}const v=64,b=I*v+32,c=/^(?:0|[1-9]\d?)$/;function g(C,x){return C*v+x}function o(C){if(A(C))return null;if(typeof C=="string"){const T=t(C);return T===null?null:o(T)}if(typeof C=="object"){const T=H(C.address),F=Number(C.prefix);return T===null||!Number.isInteger(F)||F<0||F>32?null:{address:T,prefix:F}}const x=Number(C);if(!Number.isInteger(x)||x<0||x>b)return null;const j=x%v;return j>32?null:{address:(x-j)/v,prefix:j}}function t(C){if(A(C))return null;const x=String(C).trim();if(x==="")return null;const j=x.indexOf("/");if(j<0)return null;const T=L(x.slice(0,j));if(T===null)return null;const F=x.slice(j+1).trim();if(!c.test(F))return null;const $=Number(F);return $>32?null:g(T,$)}function s(C){const x=o(C);return x?`${Y(x.address)}/${x.prefix}`:""}function l(C){return typeof C=="string"&&t(C)!==null}function u(C,x){const j=o(C),T=o(x);return j?T?j.address!==T.address?j.address<T.address?-1:1:j.prefix-T.prefix:-1:T?1:0}function n(C){return C===0?0:4294967295<<32-C>>>0}function p(C){const x=o(C);return x?(x.address&n(x.prefix))>>>0:null}function r(C){const x=o(C);return x?(x.address&n(x.prefix)|~n(x.prefix)>>>0)>>>0:null}function i(C){const x=o(C);return x?2**(32-x.prefix):null}function d(C){const x=o(C);return x?x.prefix===32?1:x.prefix===31?2:2**(32-x.prefix)-2:null}function h(C,x){const j=o(C);if(!j)return!1;const T=H(x);if(T===null)return!1;const F=n(j.prefix);return(T&F)>>>0===(j.address&F)>>>0}function a(C,x){const j=p(C),T=p(x);return j===null||T===null?!1:j<=r(x)&&T<=r(C)}const y=/^[0-9a-fA-F]{1,4}$/,f=new U(512);function m(C){if(A(C))return null;let x=String(C).trim();if(x==="")return null;const j=x.indexOf("%");if(j>=0&&(x=x.slice(0,j)),x==="")return null;if(x.indexOf(".")>=0){const G=x.lastIndexOf(":");if(G<0)return null;const N=L(x.slice(G+1));if(N===null)return null;x=`${x.slice(0,G+1)}${(N>>>16&65535).toString(16)}:${(N&65535).toString(16)}`}const T=x.split("::");if(T.length>2)return null;const F=w(T[0]);if(F===null)return null;if(T.length===1)return F.length===8?F:null;const $=w(T[1]);if($===null)return null;const D=8-F.length-$.length;if(D<1)return null;const z=F.slice();for(let G=0;G<D;G++)z.push(0);for(const G of $)z.push(G);return z}function w(C){if(C==="")return[];const x=[];for(const j of C.split(":")){if(!y.test(j))return null;x.push(parseInt(j,16))}return x}function S(C){if(typeof C!="string")return m(C);if(f.has(C))return f.get(C);const x=m(C);return f.set(C,x),x}function M(C){if(C[0]===0&&C[1]===0&&C[2]===0&&C[3]===0&&C[4]===0&&C[5]===65535)return`::ffff:${Y((C[6]<<16|C[7])>>>0)}`;let x=-1,j=0,T=-1,F=0;for(let z=0;z<8;z++)C[z]===0?(T<0?(T=z,F=1):F++,F>j&&(j=F,x=T)):(T=-1,F=0);if(j<2)return C.map(z=>z.toString(16)).join(":");const $=C.slice(0,x).map(z=>z.toString(16)).join(":"),D=C.slice(x+j).map(z=>z.toString(16)).join(":");return`${$}::${D}`}function X(C){const x=m(C);return x===null?null:M(x)}function q(C){return X(C)??""}function K(C){return typeof C=="string"&&C.indexOf(":")>=0&&m(C)!==null}function P(C,x){const j=S(C),T=S(x);if(!j)return T?1:0;if(!T)return-1;for(let F=0;F<8;F++)if(j[F]!==T[F])return j[F]<T[F]?-1:1;return 0}const k=Object.freeze({ipv4:{base:"number",storage:"int32",unsignedInt32:!0,matches:_,parse:C=>L(C.text),compare:O,format:C=>Y(C.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",excelKind:"string",toStorage:C=>H(C),toClipboard:C=>Y(C),fromClipboard:C=>L(C)},cidr:{base:"number",storage:"float64",matches:l,parse:C=>t(C.text),compare:u,format:C=>s(C.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",excelKind:"string",toStorage:C=>{const x=o(C);return x===null?null:g(x.address,x.prefix)},toClipboard:C=>s(C),fromClipboard:C=>t(C)},ipv6:{base:"text",storage:"dictionary",matches:K,parse:C=>X(C.text),compare:P,format:C=>q(C.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",toStorage:C=>X(C),toClipboard:C=>q(C),fromClipboard:C=>X(C)}}),E=k}),ze("packages/core/src/i18n/catalogue.js",function(e,B){"use strict";Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return I}});const ne=B("packages/core/src/registry/free-tier-notice.js"),A=ne.FREE_TIER_NOTICE,V=ne.WATERMARK_TEXT,U=Object.freeze({"count.rows":{one:"{count} row",other:"{count} rows"},"count.comments":{one:"{count} comment",other:"{count} comments"},"comments.someUnresolved":"{comments}, {unresolved} unresolved","comments.allResolved":"{comments}, all resolved","count.unresolvedComments":{one:"{count} unresolved comment",other:"{count} unresolved comments"},"count.items":{one:"{count} item",other:"{count} items"},"count.keys":{one:"{count} key",other:"{count} keys"},"count.values":{one:"value",other:"values"},"count.waiting":{one:"{count} waiting",other:"{count} waiting"},"count.rowsAdded":{one:"{count} row added",other:"{count} rows added"},"count.rowsRemoved":{one:"{count} row removed",other:"{count} rows removed"},"value.empty":"empty","a11y.sort.cleared":"Sort cleared","a11y.sort.by":"Sorted by {columns}","a11y.sort.column":"{column} {direction}","a11y.sort.ascending":"ascending","a11y.sort.descending":"descending","a11y.filter.cleared":"Filter cleared, {rows}","a11y.filter.applied":"Filtered to {shown} of {total}","a11y.find.count":{one:"{current} of {count} match",other:"{current} of {count} matches"},"a11y.find.countLoaded":{one:"{current} of {count} match in loaded rows",other:"{current} of {count} matches in loaded rows"},"a11y.find.none":"No matches","a11y.find.noneLoaded":"No matches in loaded rows","a11y.selection.cleared":"Selection cleared","a11y.selection.count":{one:"{count} row selected",other:"{count} rows selected"},"tabs.tablist":"Tabs","a11y.tabs.selected":"{label} tab selected","a11y.scrollbar.horizontal":"Horizontal scrollbar","a11y.scrollbar.vertical":"Vertical scrollbar","designer.canvas":"Dashboard canvas","designer.chrome":"Designer tools","designer.page":"Page {n}","a11y.designer.edit":"Edit mode","a11y.designer.view":"View mode","layout.region":"Dashboard layout","layout.move":"Move {title}","layout.resize":"Resize {title}","layout.close":"Close {title}","a11y.layout.grabbed":"{title} grabbed, column {x} of {columns}, row {y}","a11y.layout.position":"{title}, column {x} of {columns}, row {y}","a11y.layout.dropped":"{title} dropped, column {x} of {columns}, row {y}","a11y.layout.cancelled":"{title} move cancelled","a11y.layout.resizeCancelled":"{title} resize cancelled","a11y.layout.reverted":"{title} returned to column {x}, row {y}","a11y.layout.resizeGrabbed":"{title} resize grabbed, {w} by {h} cells","a11y.layout.resizeStep":"{title}, {w} by {h} cells","a11y.layout.resized":"{title} resized to {w} by {h} cells","a11y.layout.closed":"{title} closed","layout.maximise":"Maximise {title}","layout.minimise":"Minimise {title}","layout.restore":"Restore {title}","a11y.layout.maximised":"{title} maximised, filling the dashboard; press Escape to restore it","a11y.layout.minimised":"{title} minimised","a11y.layout.restored":"{title} restored to column {x}, row {y}","a11y.group.cleared":"Grouping cleared","a11y.group.by":"Grouped by {columns}","a11y.group.expanded":"{label} expanded, {rows} shown","a11y.group.collapsed":"{label} collapsed, {rows} shown","a11y.page.position":"Page {page} of {pages}","a11y.updates.paused":"Updates paused","a11y.updates.resumed":"Updates resumed","a11y.edit.refusedOne":"Edit to {column} was refused and put back to {value}{reason}","a11y.edit.refusedMany":{one:"{count} edit was refused and put back{reason}",other:"{count} edits were refused and put back{reason}"},"a11y.edit.reason":", {reason}","a11y.history.undo":"Undid {label}","a11y.history.redo":"Redid {label}","a11y.history.undoLast":"Undid the last change","a11y.history.redoLast":"Redid the last change","a11y.column.cannotResize":"{column} cannot be resized","a11y.column.resized":"{column} is {width} pixels wide","a11y.column.atMinimum":"{column} is at its narrowest, {width} pixels","a11y.column.atMaximum":"{column} is at its widest, {width} pixels","a11y.column.cannotMove":"{column} cannot be moved","a11y.column.alreadyFirst":"{column} is already first in its group","a11y.column.alreadyLast":"{column} is already last in its group","a11y.column.cannotMoveThere":"{column} cannot be moved there","a11y.column.moved":"{column} moved to position {at} of {of}","a11y.column.hidden":"{column} hidden","a11y.group.formed":"{column} grouped with {other} in a new band","a11y.group.dissolved":"band {group} dissolved","a11y.group.renamed":"band renamed to {group}","a11y.group.moved":"band {group} moved to position {at} of {of}","a11y.column.addedToGroup":"{column} added to band {group}","a11y.column.removedFromGroup":"{column} removed from its band","a11y.column.notInGroup":"{column} is not in a band","a11y.column.cannotGroup":"{column} cannot be grouped","a11y.group.cannotMove":"band {group} cannot be moved there","columngroup.newGroup":"New group","columngroup.rename":"Rename band","columngroup.dissolve":"Dissolve band","columngroup.group":"Group with adjacent column","columngroup.untitled":"Untitled band","panel.bandCollapse":"Collapse band {band}","panel.bandExpand":"Expand band {band}","panel.bandVisible":"Show or hide every column in band {band}","panel.bandRenameFor":"Rename band {band}","panel.bandDissolveFor":"Dissolve band {band}","header.filter":"Filter {column}","header.menu":"Column menu for {column}","header.toggleGroup":"Toggle {group}","header.dragHint":"Drag {column} to reorder, or onto another column to group","header.dragRole":"draggable column header","header.group":"group","header.selectAllRows":"Select all rows","header.clearSelection":"Clear selection","cell.selectRow":"Select row","cell.detail.show":"Show detail","cell.detail.hide":"Hide detail","cell.detail.showInPane":"Show in the detail pane","cell.detail.showingInPane":"Showing in the detail pane","cell.group.expand":"Expand","cell.group.collapse":"Collapse","cell.delta.up":"up","cell.delta.down":"down","cell.delta.unchanged":"unchanged","cell.delta.moved":"{direction} {magnitude}","cell.delta.describedUnchanged":"{label}, unchanged","cell.delta.described":"{label}, {direction} by {magnitude}","cell.qr.of":"QR code for {text}","cell.qr.empty":"No QR code","cell.barcode.of":"Barcode for {text}","cell.barcode.empty":"No barcode","cell.barcode.invalid":"Invalid value for this barcode","cell.rating.of":"{rating} of {max}","cell.rating.empty":"Not rated","cell.stage.of":"Stage {current} of {total}: {label}","cell.stage.empty":"No stage","a11y.panel.cannotMove":"{column} cannot be moved","a11y.panel.alreadyFirst":"{column} is already first","a11y.panel.alreadyLast":"{column} is already last","a11y.panel.moved":"{column} moved to position {at} of {of}","a11y.panel.removedFrom":"{column} removed from {list}","a11y.panel.addedTo":"{column} added to {list}","a11y.panel.cannotAddTo":"{column} cannot be added to {list}","a11y.annotate.erased":"Annotation removed","a11y.annotate.noMarks":"No annotations to erase","a11y.annotate.focusedMark":"Mark {at} of {of} selected","a11y.annotate.confirmClear":"Clear all annotations? Choose Clear or Keep.","a11y.annotate.cleared":"All annotations cleared","a11y.range.written":{one:"{count} cell updated",other:"{count} cells updated"},"a11y.range.cleared":{one:"{count} cell cleared",other:"{count} cells cleared"},"paste.preview.title":"Review paste","paste.preview.summary":{one:"{changes} cell will change, {rejected} rejected.",other:"{changes} cells will change, {rejected} rejected."},"paste.preview.changesHeading":{one:"{count} change",other:"{count} changes"},"paste.preview.rejectedHeading":{one:"{count} rejected",other:"{count} rejected"},"paste.preview.colOld":"Current","paste.preview.colNew":"New","paste.preview.colCell":"Cell","paste.preview.colReason":"Reason","paste.preview.empty":"This paste would change nothing.","paste.preview.confirm":"Apply","paste.preview.cancel":"Cancel","paste.preview.reason.permission":"Not permitted","paste.preview.reason.readOnly":"Read-only","paste.preview.reason.validation":"Invalid value","paste.preview.reason.locked":"Being edited","paste.preview.reason.missing":"No such cell","a11y.paste.previewOpened":{one:"Paste preview: {changes} cell changes, {rejected} rejected. Review, then apply or cancel.",other:"Paste preview: {changes} cell changes, {rejected} rejected. Review, then apply or cancel."},"a11y.paste.cancelled":"Paste cancelled; nothing changed","status.total":"{rows}","status.counting":"Counting rows…","status.shownOfTotal":"{shown} of {total}","status.selected":"{count} selected","status.selectedAcrossSource":"{count} selected across the source","status.selectedAcrossSourceCounting":"All matching rows selected, counting…","status.count":"Count {count}","status.loading":"Loading {count}…","status.loadingOf":"Loading {loaded} of {total} ({percent}%)","status.stat.sum":"Sum","status.stat.min":"Min","status.stat.max":"Max","status.stat.avg":"Avg","status.paused":"Paused","status.pausedWaiting":"Paused · {waiting}","status.coalesced":"{count} coalesced","status.hiddenComments":"{comments} on hidden rows","pagination.label":"Pagination","pagination.first":"First page","pagination.previous":"Previous page","pagination.next":"Next page","pagination.last":"Last page","pagination.page":"Page","pagination.ofPages":"of {pages}","pagination.summary":"{from}–{to} of {total}","pagination.pageSize":"Rows per page","pagination.range":"{from}–{to}","pagination.counting":"{from}–{to}, counting…","pagination.jump":"Page number, press Enter to jump","pagination.jumpBounded":"Page number, 1 to {pages}, press Enter to jump","panel.columns":"Columns","panel.filters":"Filters","panel.views":"Views","panel.quickFilter":"Quick filter","find.label":"Find in grid","find.placeholder":"Find in grid","find.next":"Next match","find.previous":"Previous match","find.close":"Close find","find.matchCase":"Match case","find.wholeCell":"Whole cell","find.columnScope":"Search in","find.allColumns":"All columns","find.count":"{current} of {total}","find.countPartial":"{current} of {total} so far","find.none":"No matches","find.searching":"Searching…","find.loadedRows":"in loaded rows","rowCap.more":"+ {count} more","panel.formatting":"Formatting","panel.statistics":"Statistics","stat.noData":"No data","stat.unavailable":"Not available on this source","stat.tone.good":"good","stat.tone.bad":"bad","stat.tone.flat":"flat","stat.target":"target {target}","meter.target":"target {value}","panel.regression":"Regression","panel.compare":"Compare","panel.insights":"Insights","panel.compareGroups":"Compare groups","panel.explain":"Explain","insights.subset":"Filtered subset vs whole","insights.dataset":"This grid vs another dataset","insights.groups":"Group comparison","insights.noFilter":"Filter the grid to compare the subset against the whole.","insights.by":"Group by","insights.test":"Test","insights.effect":"Effect size","insights.interval":"Confidence interval","insights.pValue":"p-value","insights.smallSample":"small sample — interpret with care","insights.needGroups":"Choose two columns with groups to compare.","compareGroups.noTest":"Not enough readings, or no variation, in at least one group.","insights.empty":"No columns to analyse.","insights.anomalies":"Anomalies","insights.anomalyCount":"{count} flagged of {n}","insights.anomalyMethod":"Method","insights.anomalyThreshold":"Threshold","anomaly.chip":"{count} anomalies flagged","anomaly.chipActive":"Showing {count} anomalies — clear","compare.first":"First column","compare.second":"Second column","compare.needTwo":"Two numeric columns are needed to compare","compare.noPairs":"No rows have a value in both","compare.pairs":"{count} pairs","compare.pearson":"Correlation (Pearson)","compare.spearman":"Rank correlation (Spearman)","compare.kendall":"Kendall’s tau","compare.covariance":"Covariance","compare.slope":"Slope","compare.intercept":"Intercept","compare.r2":"R²","compare.stdError":"Standard error","compare.weighted":"Weighted average","panel.zone.group":"row groups","panel.zone.values":"values","panel.zone.pivot":"pivot columns","groupZone.label":"Row groups","groupZone.title":"Group by","groupZone.hint":"Drag a column here to group rows by its values","groupZone.chip":"{column}, group {at} of {of}","groupZone.remove":"Stop grouping by {column}","groupZone.add":"Add a group","total.sum":"Sum","total.avg":"Average","total.min":"Min","total.max":"Max","total.count":"Count","total.countValues":"Count of values","total.first":"First","total.last":"Last","total.custom":"Total","total.median":"Median","total.p25":"25th percentile","total.p75":"75th percentile","total.p90":"90th percentile","total.p95":"95th percentile","total.p99":"99th percentile","total.iqr":"Interquartile range","total.mad":"Median absolute deviation","total.variance":"Variance","total.varianceP":"Variance (population)","total.stddev":"Standard deviation","total.stddevP":"Standard deviation (population)","total.range":"Range","total.distinct":"Distinct","total.mode":"Mode","total.skewness":"Skewness","total.kurtosis":"Kurtosis","total.geomean":"Geometric mean","total.harmean":"Harmonic mean","total.sumSquares":"Sum of squares","total.weightedAvg":"Weighted average","total.argmin":"Lowest by","total.argmax":"Highest by","total.hhi":"Concentration (HHI)","total.entropy":"Entropy","total.evenness":"Evenness","total.top3Share":"Top 3 share","total.top10Share":"Top 10 share","total.gini":"Gini coefficient","total.trimmedMean":"Trimmed mean","total.winsorizedMean":"Winsorized mean","total.robustOutliers":"Outliers (robust)","total.jarqueBera":"Jarque–Bera","total.passRate":"Pass rate","total.failureCount":"Failures","stats.column":"Column","stats.choose":"Choose a column to profile","stats.noColumns":"No numeric columns to profile","stats.noValues":"Nothing numeric in this column","stats.count":"Count","stats.present":"Present","stats.missing":"Missing","stats.distinct":"Distinct","stats.min":"Minimum","stats.max":"Maximum","stats.mean":"Mean","stats.median":"Median","stats.q1":"Lower quartile","stats.q3":"Upper quartile","stats.iqr":"Interquartile range","stats.stddev":"Standard deviation","stats.outliers":"Outliers","stats.distribution":"Distribution","stats.distribution.detail":"Distribution: rows per range","stats.bin":"{count} between {from} and {to}","stats.topValues":"Top values","stats.section.shape":"Shape","stats.section.robust":"Robust","stats.section.concentration":"Concentration","stats.section.capability":"Capability","stats.cp":"Cp","stats.cpk":"Cpk","stats.pp":"Pp","stats.ppk":"Ppk","stats.outOfSpec":"Out of specification","stats.filtered":"Over the {count} filtered rows","stats.unavailable":"Not computed by the source: {stats}.","stats.unavailable.notPlain":"`{column}` is not a plain column the engine can name","stats.unavailable.where":"a `where` predicate is in force ({list}), which only the browser can run","stats.unavailable.filter":"the grid's filter did not fully push to the engine","stats.unavailable.quick":"the quick search did not push to the engine","stats.unavailable.client":'the source did not compute "{fn}" in the engine ({reason}); set the pushdown source\'s `{setting}`',"stats.unavailable.outliers":"the count of values outside Tukey's fences is not an engine aggregate","stats.unavailable.histogram":"the shape of the column is not an engine aggregate","stats.unavailable.topValues":"the source did not answer a grouped count in the engine","explain.column":"Value","explain.by":"Break down by","explain.byRow":"Each row","explain.noColumns":"No numeric columns to explain","explain.unavailable":"Nothing to explain in this column","explain.total":"{fn}: {total}","explain.weighted":"weighted effects","explain.single":"one contributor","explain.delta":"was {before}, now {after} (Δ {delta})","explain.breakdown":"Contributors","explain.contributor":"Contributor","explain.count":"Rows","explain.value":"Value","explain.contribution":"Contribution","explain.share":"Share","explain.change":"Change","explain.before":"Before","explain.after":"After","explain.effect":"Effect","explain.kind.new":"New","explain.kind.dropped":"Dropped","explain.kind.changed":"Changed","explain.narrative":"Explanation","explain.narrative.lead":"{top} accounts for {share}; the {fn} is {total}.","explain.narrative.next":"{next} follows at {share}.","explain.narrative.driver":"The change of {delta} was driven most by {top} ({effect}).","explain.narrative.driverNext":"{next} ({kind}) moved it {effect}.","explain.narrative.none":"Nothing contributed to this total.","explain.narrative.noChange":"Nothing changed between the two states.","regression.noModel":"No model configured. Set predictors and a response on the panel.","regression.cannotFit":"The model cannot be fitted over the current rows.","regression.observations":"Fitted over {count} rows","regression.r2":"R²","regression.adjR2":"Adjusted R²","regression.coefficients":"Coefficients","regression.term":"Term","regression.estimate":"Estimate ± SE","regression.stdError":"Std error","regression.t":"t","regression.p":"p","regression.vif":"Variance inflation (VIF)","regression.heteroscedasticity":"Heteroscedasticity (Breusch–Pagan)","regression.heteroscedastic":"Heteroscedastic: BP {statistic}, p {p}","regression.homoscedastic":"No heteroscedasticity detected: BP {statistic}, p {p}","menu.sortAscending":"Sort ascending","menu.sortDescending":"Sort descending","menu.clearSort":"Clear sort","menu.groupBy":"Group by this column","menu.ungroup":"Stop grouping by this column","menu.hideColumn":"Hide column","menu.pinStart":"Pin to start","menu.pinEnd":"Pin to end","menu.unpin":"Unpin","menu.autosize":"Fit to content","ai.valuesNotAmongOptions":'{values} {shown} not among the options for "{column}"',"menu.clearCells":{one:"Clear cell",other:"Clear {count} cells"},"menu.fillDown":"Fill down","menu.copy":"Copy","menu.copyWithHeaders":"Copy with headers","menu.paste":"Paste","menu.filterEllipsis":"Filter…","menu.columnStatistics":"Column statistics","menu.compareGroups":"Compare groups","menu.explain":"Explain this number","menu.pinColumn":"Pin column","menu.sizeToFit":"Size to fit content","menu.sizeAllToFit":"Size all columns to fit","menu.width":"Width","menu.narrower":"Narrower","menu.wider":"Wider","menu.moveColumn":"Move column","menu.moveLeft":"Move left","menu.moveRight":"Move right","menu.moveToStart":"Move to start","menu.moveToEnd":"Move to end","menu.unpivot":"Remove from pivot","menu.pivotBy":"Pivot by this column","menu.stopTotalling":"Stop totalling","menu.totalColumn":"Total this column","menu.aggregate":"Aggregate","menu.aggregateNone":"None","menu.aggregateGroup":"Group subtotals","menu.aggregateGrand":"Grand total","menu.aggregateSame":"Same as total","menu.redactColumn":"Redact column","menu.stopRedacting":"Stop redacting","menu.stopRedactingAll":"Stop redacting everything","menu.sortGroupsAscending":"Sort groups ascending","menu.sortGroupsDescending":"Sort groups descending","menu.filterGroups":"Filter groups…","menu.expandAll":"Expand all","menu.collapseAll":"Collapse all","menu.clearGrouping":"Clear grouping","menu.colour":"Colour","menu.importCsv":"Import rows from CSV…","import.title":"Import rows","import.clipboard":"the clipboard","import.summary":{one:"{count} row from {name}",other:"{count} rows from {name}"},"import.opened":{one:"Import preview open, {count} row",other:"Import preview open, {count} rows"},"import.done":{one:"{count} row imported",other:"{count} rows imported"},"import.confirm":"Import","import.cancel":"Cancel","import.colSource":"Column","import.colField":"Maps to","import.colType":"Type","import.skip":"— skip —","import.mapLabel":'Map "{source}" to a field',"import.modeLabel":"On import","import.sheetLabel":"Sheet","import.append":"Add to existing rows","import.replace":"Replace all rows","menu.deleteRow":{one:"Delete row",other:"Delete {count} rows"},"toolbar.undo":"Undo","toolbar.redo":"Redo","toolbar.undoLabelled":"Undo {label}","toolbar.redoLabelled":"Redo {label}","toolbar.exportCsv":"Export to CSV","toolbar.exportExcel":"Export to Excel","toolbar.clipboard":"Copy visible rows to the clipboard","toolbar.print":"Print","toolbar.pause":"Hold incoming updates","toolbar.resume":"Resume updates","toolbar.applyHeld":{one:"Apply {count} held update",other:"Apply {count} held updates"},"toolbar.restoreView":"Restore the default view","toolbar.maximiseGrid":"Maximise the grid to fill the window","toolbar.restoreSize":"Restore the grid to the page (Esc)","toolbar.annotate.pen":"Draw freehand","toolbar.annotate.arrow":"Draw an arrow","toolbar.annotate.rect":"Draw a rectangle","toolbar.annotate.highlight":"Highlight","toolbar.annotate.erase":"Erase","toolbar.annotate.clearAll":"Clear all annotations","toolbar.annotate.clearAllConfirm":"Clear","toolbar.annotate.clearAllKeep":"Keep","overlay.noRows":"No rows to show","overlay.noResults":"No rows match the current filters","overlay.loading":"Loading…","overlay.error":"Something went wrong","listview.pullToRefresh.pull":"Pull to refresh","listview.pullToRefresh.release":"Release to refresh","listview.pullToRefresh.refreshing":"Refreshing…","overlay.loadingRows":"Loading rows {from} to {to}","overlay.rowError":"Failed to load","comments.panel":"Cell comments","comments.close":"Close comments","comments.write":"Write a comment","comments.post":"Comment","comments.delete":"Delete","comments.valueMoved":"Written when the value was {was}: it is now {now}.","comments.resolve":"Resolve","comments.reopen":"Reopen","comments.loading":"Loading…","comments.empty":"No comments yet.","comments.unknownAuthor":"Unknown","comments.edited":"{time} (edited)","comments.cellTitle":"{column}: {row}","presence.hidden":{one:"{count} not in view",other:"{count} not in view"},"presence.someoneElse":"someone else","a11y.presence.refused":"This cell is being edited by {name}","presence.peer":"{name}: jump to their cursor","presence.peerIdle":"{name}, idle: jump to their cursor","presence.peerHidden":"{name}, not in the current view","facets.filter":"{column} distribution filter","header.totalOf":"{total} of {column}","diff.before":"Was: {value}","diff.empty":"(empty)","kanban.columnCards":{one:"{title}, {count} card",other:"{title}, {count} cards"},"kanban.laneCards":{one:"{lane}, {title}, {count} card",other:"{lane}, {title}, {count} cards"},"kanban.blocked":"Blocked","kanban.ready":"Ready","kanban.columnMenu":"Column menu","kanban.blockedBy":{one:"blocked by {count} card",other:"blocked by {count} cards"},"kanban.card.assignedTo":"Assigned to {names}","kanban.card.overdue":"Overdue","kanban.card.dueSoon":"Due soon","kanban.card.progress":"{percent}% complete","kanban.card.checklist":"{done} of {total} done","gantt.lag":"+{days}d","gantt.lead":"{days}d","gantt.a11y.moved":"{name} moved to {date}","gantt.a11y.day":"day {day}","gantt.a11y.resized":"{name} resized to {days} days","gantt.a11y.linkFrom":"Linking from {name}. Focus the successor and press L.","gantt.a11y.linked":"Linked {from} to {to}, finish to start.","gantt.a11y.linkCancelled":"Link cancelled.","gantt.a11y.deleted":"{name} deleted.","gantt.a11y.readOnly":"Read-only.","gantt.row.moveHandle":"Drag to reorder or re-parent {name}","gantt.a11y.rowMoved":"{name} moved.","gantt.a11y.rowReparented":"{name} moved under {parent}.","gantt.a11y.rowPromoted":"{name} moved to the top level.","gantt.a11y.rowMoveCancelled":"Move cancelled.","gantt.a11y.copied":"{count} tasks copied.","gantt.a11y.cut":"{count} tasks cut.","gantt.a11y.pasted":"{count} tasks pasted.","gantt.task.newName":"New task","gantt.a11y.taskAdded":"{name} added.","gantt.menu.addAbove":"Add task above","gantt.menu.addBelow":"Add task below","gantt.menu.addChild":"Add subtask","gantt.menu.addSuccessor":"Add successor","gantt.menu.addPredecessor":"Add predecessor","gantt.menu.toMilestone":"Convert to milestone","gantt.menu.toTask":"Convert to task","gantt.menu.delete":"Delete task","gantt.a11y.linkCycle":"Linking {from} to {to} would create a cycle; link not created.","gantt.a11y.linkCreated":"{from} linked to {to}, {type}.","gantt.a11y.linkDeleted":"Link from {from} to {to} deleted.","gantt.a11y.linkLabel":"Link, {from} to {to}, {type}","gantt.linkEditor.title":"Edit link from {from} to {to}","gantt.linkEditor.type":"Link type","gantt.linkEditor.lag":"Lag, in days","gantt.linkEditor.apply":"Apply","gantt.linkEditor.delete":"Delete link","gantt.linkEditor.cancel":"Cancel","gantt.a11y.undone":"Undone.","gantt.a11y.redone":"Redone.","gantt.a11y.nothingToUndo":"Nothing to undo.","gantt.a11y.nothingToRedo":"Nothing to redo.","gantt.workload.title":"Resource workload","gantt.workload.resource":"Resource","gantt.workload.total":"Total","gantt.workload.unassigned":"Unassigned","gantt.workload.ungrouped":"No group","gantt.workload.cell":"{hours} h from {date}","gantt.workload.over":"{hours} h from {date}, over a capacity of {capacity} h","gantt.workload.expand":"Show {name}’s tasks","gantt.workload.collapse":"Hide {name}’s tasks","gantt.workload.expandGroup":"Show the {name} group","gantt.workload.collapseGroup":"Hide the {name} group","gantt.workload.unitToggle":"Hours / % / Cost","gantt.workload.unitHours":"Showing hours","gantt.workload.unitPercent":"Showing percent of capacity","gantt.workload.unitCost":"Showing cost","gantt.workload.cellPercent":"{percent}% from {date}","gantt.workload.overPercent":"{percent}% from {date}, over capacity","gantt.workload.cellNoCapacity":"No available hours from {date}","gantt.workload.cellCost":"{cost} from {date}","gantt.workload.otherProjectLabel":"{name} (other project)","gantt.workload.external":"External booking","gantt.a11y.hoursSet":"{name}: {hours} h from {date}","gantt.a11y.hoursCleared":"{name}: no hours from {date}","gantt.a11y.hoursRefused":"{date} is not a working day; {name} was not changed.","gantt.histogram.title":"Resource histogram","gantt.histogram.tableTitle":"Resource histogram data","gantt.histogram.resource":"Resource","gantt.histogram.period":"Period","gantt.histogram.hours":"Hours","gantt.histogram.percent":"Percent of capacity","gantt.histogram.cost":"Cost","gantt.histogram.capacity":"Capacity","gantt.histogram.overAllocated":"Over-allocated","gantt.histogram.yes":"Yes","gantt.histogram.no":"No","gantt.histogram.tip":"{name}, {from} to {to}: {value}{capacity}{tasks}","gantt.histogram.tipHours":"{hours} h","gantt.histogram.tipPercent":"{percent}% of capacity","gantt.histogram.tipCost":"{cost}","gantt.histogram.tipCapacity":", capacity {hours} h","gantt.histogram.tipTasks":" ({tasks})","gantt.histogram.tipOver":", over capacity","gantt.histogram.tipNoCapacity":"no available hours","gantt.picker.title":"Assign resources to {name}","gantt.picker.open":"Edit assignments for {name}","gantt.picker.search":"Search resources","gantt.picker.list":"Resources","gantt.picker.selected":"Assigned resources","gantt.picker.load":"{load}% booked of {capacity}% over these dates","gantt.picker.none":"No matching resources","gantt.picker.units":"{name}, units in percent","gantt.picker.remove":"Remove {name}","gantt.picker.apply":"Apply","gantt.picker.cancel":"Cancel","gantt.picker.warn":"{name} would be over-allocated: {load}% booked of {capacity}%","gantt.picker.ok":"No resource would be over-allocated","gantt.picker.assign":"Assign","gantt.col.effort":"Effort","gantt.col.units":"Units","gantt.unscheduled":"Unscheduled","gantt.col.unscheduled":"Unscheduled","gantt.inactive":"Inactive","gantt.col.inactive":"Inactive","gantt.col.slack":"Slack","gantt.col.deadline":"Deadline","gantt.col.constraint":"Constraint","gantt.col.constraintDate":"Constraint date","gantt.col.earlyStart":"Early start","gantt.col.lateStart":"Late start","gantt.col.lateFinish":"Late finish","gantt.col.baselineStart":"Baseline start","gantt.col.baselineEnd":"Baseline finish","gantt.col.variance":"Variance","gantt.col.note":"Note","gantt.col.sequence":"#","gantt.col.predecessors":"Predecessors","gantt.col.successors":"Successors","gantt.link.invalid":"Cannot read “{token}” as a link. Write a task number, a type and a lag, like 3FS+2; links not changed.","gantt.link.unknownRef":"No task is numbered “{token}”; links not changed.","gantt.link.self":"“{token}” links a task to itself; links not changed.","gantt.link.duplicate":"“{token}” repeats a link already listed; links not changed.","gantt.link.cycle":"“{token}” would create a cycle; links not changed.","gantt.constraint.ASAP":"As soon as possible","gantt.constraint.MSO":"Must start on","gantt.constraint.MFO":"Must finish on","gantt.constraint.ALAP":"As late as possible","gantt.constraint.SNET":"Start no earlier than","gantt.constraint.SNLT":"Start no later than","gantt.constraint.FNET":"Finish no earlier than","gantt.constraint.FNLT":"Finish no later than","gantt.row.ancestor":"Shown because a task inside it matches the filter","gantt.progress.handle":"Drag to set the progress of {name}","gantt.a11y.progress":"{name} {percent}% complete","gantt.col.name":"Task name","gantt.col.start":"Start","gantt.col.end":"Finish","gantt.col.duration":"Duration","gantt.col.assignee":"Assignee","gantt.col.progress":"%","gantt.col.wbs":"WBS","gantt.zoom.label":"Zoom","gantt.zoom.day":"Day","gantt.zoom.week":"Week","gantt.zoom.month":"Month","gantt.zoom.quarter":"Quarter","gantt.zoom.fit":"Fit to plan","gantt.tip.range":"{from} to {to}","gantt.tip.duration":"{days}d","gantt.tip.slack":"slack {days}d","gantt.tip.effort":"{hours}h","gantt.tip.row":"{label}: {value}","gantt.tip.start":"Start","gantt.tip.end":"End","gantt.tip.date":"Date","gantt.tip.durationLabel":"Duration","gantt.tip.durationValue":"{days} days","gantt.tip.complete":"Complete","gantt.tip.effortLabel":"Effort","gantt.tip.effortValue":"{hours} h","gantt.tip.assigned":"Assigned","gantt.tip.cost":"Cost","gantt.tip.slackLabel":"Slack","gantt.tip.slackValue":"{days} days","gantt.tip.deadline":"Deadline","gantt.mode.fixedDuration":"Fixed duration","gantt.mode.fixedEffort":"Fixed effort","gantt.mode.fixedUnits":"Fixed units","gantt.scurve.spi":"SPI {index}","gantt.scurve.cpi":"CPI {index}","gantt.print.page":"Page {page} of {pages}","gantt.print.printed":"Printed {date}","gantt.dataBand.title":"Data band","gantt.dataBand.name":"Task","gantt.dataBand.resource":"Resource","gantt.dataBand.total":"Total","gantt.dataBand.unassigned":"Unassigned","gantt.dataBand.collapse":"Collapse {name}","gantt.dataBand.expand":"Expand {name}","gantt.dataBand.cell":"{name}, {date}: {value}","gantt.issues.title":"Scheduling conflicts","gantt.issues.empty":"No scheduling conflicts","gantt.issues.count":"{count} scheduling conflicts","gantt.issues.toggle":"Toggle the conflicts panel","gantt.issues.cycle":"Circular dependency: {tasks}","gantt.issues.constraint":"{task} cannot meet its {constraint} constraint of {date}","gantt.issues.lock":"{task} is locked but a dependency would move it","gantt.issues.deadline":"{task} finishes after its deadline of {date}","gantt.issues.fixRemoveLink":"Remove link","gantt.issues.fixAsap":"Set as soon as possible","gantt.issues.fixUnlock":"Unlock task","gantt.issues.fixClearDeadline":"Clear deadline","gantt.resize.startHandle":"Drag to change the start of {name}","gantt.a11y.resizedStart":"{name} start moved to {date}, now {days} days","gantt.a11y.startEdge":"Start edge can be resized: drag the left edge, or press Ctrl+Shift+Left or Right.","gantt.a11y.chain":"Dependency chain highlighted: {preds} predecessors, {succs} successors.","timeline.scrub":"Scrub through recent changes","timeline.goLive":"Go live","timeline.returnToPresent":"Return to the present","a11y.fillHandle":"Drag to fill","panel.icons":"Icons","value.tooLong":"Too long","dataview.label":"Items","dataview.empty":"No items","dataview.reorder.sorted":"Items cannot be reordered while the view is sorted","dataview.reorder.filtered":"Items cannot be reordered while a filter is applied","shortcuts.title":"Keyboard shortcuts","shortcuts.close":"Close keyboard shortcuts","shortcuts.hint":"Press Escape to close.","shortcuts.or":"or","a11y.reorder.moved":"Moved to position {position} of {total}","a11y.reorder.sorted":"Rows cannot be reordered while the grid is sorted","a11y.reorder.filtered":"Rows cannot be reordered while a filter is applied","a11y.reorder.grouped":"Rows cannot be reordered while the grid is grouped","a11y.reorder.grab":"Reorder row","a11y.reorder.sortedManual":"Rows cannot be reordered while the grid is sorted. Press Alt+Shift+M, or the Manual order button in the heading, to order them by hand","a11y.reorder.groupDerived":"The row cannot join that group: the group is worked out from the value, so there is no single value to give it","a11y.reorder.groupReadOnly":"The row cannot join that group: its grouping value cannot be edited","a11y.reorder.invalid":"The row cannot join that group: the new value was not valid","a11y.reorder.vetoed":"The move was declined; the row stays where it was","a11y.reorder.vetoedBecause":"The move was declined ({reason}); the row stays where it was","a11y.reorder.refused":"The row cannot be moved there","a11y.reorder.regrouped":"Moved into {group}","a11y.tree.dropRefusedDescendant":"A row cannot be dropped into one of its own descendants; the row stays where it was","a11y.rowOrder.entered":"Manual order: the rows keep their places and can be moved by hand","a11y.rowOrder.exited":"Manual order ended; the rows follow the sort","rowOrder.button":"Manual order","rowOrder.enter":"Order the rows by hand instead of by the sort","rowOrder.exit":"Return to the sorted order","a11y.transfer.moved":"Row moved to the other grid","a11y.transfer.copied":"Row copied to the other grid","a11y.transfer.refused":"That grid does not accept this row","a11y.transfer.declined":"The drop was declined; the row stays where it was","a11y.transfer.stale":"The drop target changed while it was being confirmed; the row stays where it was","shortcuts.group.grid":"In the data","shortcuts.group.header":"On a column heading","shortcuts.group.panel":"In the column list","shortcut.moveCell":"Move the focused cell","shortcut.rowEnds":"First / last cell of the row","shortcut.gridEnds":"First cell of the first row / last cell of the last row","shortcut.pageRows":"Move one viewport of rows","shortcut.nextCell":"Leave the grid for the next / previous focusable element (arrows move between cells)","shortcut.undo":"Undo the last edit, paste, fill or clear","shortcut.redo":"Redo the step that was undone","shortcut.startEdit":"Start editing the focused cell; while editing, commit and open the cell below (Shift+Enter: above)","shortcut.toggleRow":"Toggle selection of the focused row","shortcut.cancel":"Cancel the current edit or drag","shortcut.expandCollapse":"Expand / collapse a group or tree row","shortcut.focusHeader":"Move focus to the column header","shortcut.focusPanel":"Move focus to the tool panel","shortcut.explain":"Explain the focused column","shortcut.contextMenu":"Open the context menu for the focused cell","shortcut.moveRow":"Move the focused row, when row reorder is enabled","shortcut.manualOrder":"Order the rows by hand, or return to the sort, when row reorder allows a manual order","shortcut.headingMove":"Move between headings","shortcut.headingEnds":"First / last heading","shortcut.headingSort":"Sort by the column, Shift to add to the sort","shortcut.headingResize":"Resize the column, Ctrl for a coarse step","shortcut.headingAutosize":"Size the column to its content","shortcut.headingReorder":"Move the column","shortcut.headingMenu":"Open the column menu","shortcut.headingExit":"Return focus to the data","shortcut.listGroup":"Group by the column, or stop grouping by it","shortcut.listValues":"Add the column to values, or take it out","shortcut.listPivot":"Pivot by the column, or stop pivoting by it","shortcut.listMove":"Move the column","shortcut.find":"Find in the grid","tags.label":"Show columns","tags.all":"All columns","tags.showing":"Showing {tag}","form.title":"Edit row","form.save":"Save","form.cancel":"Cancel","form.loading":"Loading…","form.loadFailed":"Could not load this record.","form.loadTimeout":"The record did not arrive in time.","form.retry":"Try again","form.choose":"Choose…","form.newTitle":"New row","form.createFailed":"Could not add this record.","form.grid.cellInvalid":"Row {row}, {column}: {message}","form.grid.required":"Add at least one row.","form.grid.addRow":"Add row","form.grid.deleteRow":"Delete row","form.grid.total":"Total","form.grid.rowControls":"Row controls","presentation.cards":"Showing records as cards","presentation.table":"Showing records as a table","editor.format":"Format","editor.codeHint":"Tab indents · Esc cancels · Ctrl+Enter saves","editor.colours":"Colours","editor.customColour":"Custom colour","editor.hexValue":"Hex value","editor.hexPlaceholder":"#rrggbb","editor.clearColour":"Clear colour","editor.time":"Time","editor.noIcon":"No icon","editor.selectAll":"Select all","editor.passwordHint":"Enter the value twice to save it.","editor.clearRating":"Clear rating","editor.clear":"Clear","editor.value":"Value","editor.currency":"Currency","editor.richtext.formatting":"Formatting","editor.richtext.richText":"Rich text","editor.richtext.placeholder":"Start writing…","editor.richtext.linkLabel":"Link address","editor.richtext.linkPlaceholder":"https://","editor.richtext.linkAdd":"Add link","editor.richtext.bold":"Bold (Ctrl+B)","editor.richtext.italic":"Italic (Ctrl+I)","editor.richtext.underline":"Underline (Ctrl+U)","editor.richtext.strike":"Strikethrough","editor.richtext.heading":"Paragraph style","editor.richtext.alignLeft":"Align left","editor.richtext.alignCenter":"Align centre","editor.richtext.alignRight":"Align right","editor.richtext.ul":"Bulleted list","editor.richtext.ol":"Numbered list","editor.richtext.color":"Text colour","editor.richtext.link":"Link (Ctrl+K)","editor.richtext.image":"Insert image","editor.richtext.clear":"Clear formatting","editor.richtext.source":"HTML source","editor.richtext.undo":"Undo (Ctrl+Z)","editor.richtext.redo":"Redo (Ctrl+Y)","formatting.format":"Format","formatting.noRules":"No rules yet. The first one that matches a cell wins.","formatting.clearAll":"Clear all","formatting.addRule":"Add rule","formatting.condition":"Condition","formatting.value":"Value","formatting.secondValue":"Second value","formatting.moveEarlier":"Move earlier","formatting.moveLater":"Move later","formatting.ruleKind":"Rule type","formatting.aCondition":"A condition","formatting.aColourScale":"A colour scale","formatting.compare":"Compare a value","formatting.distribution":"By the distribution","formatting.colourScale":"Colour scale","formatting.scaleBounds":"Scale bounds","formatting.preview":"Preview","formatting.livePreview":"Live preview","history.title":"History","history.show":"Show history","history.empty":"Nothing to undo yet.","prompt.ask":"Ask","prompt.apply":"Apply","prompt.discard":"Discard","panel.searchColumns":"Search columns","panel.searchColumnsPlaceholder":"Search columns…","panel.searchColumnsToFilter":"Search columns to filter","panel.showAll":"Show all","panel.hideAll":"Hide all","panel.clearAll":"Clear all","panel.clear":"Clear","panel.filterAllColumns":"Filter all columns","panel.columnFiltered":"This column is filtered","panel.clearFilterOn":"Clear the filter on {column}","panel.clearFilter":"Clear this filter","panel.filterEmptyNoMatch":"No column matches “{query}”.","panel.filterEmptyNone":"No column on this grid can be filtered.","panel.filterSummaryActive":"{active} of {total} columns filtered","panel.filterSummaryNone":"No filters · {total} columns available","panel.filterBy":"Filter by {column}","panel.filteredBy":"Filtered by {column}","panel.columnDragHint":"Drag {column} into a zone above, or onto another column to reorder","panel.gridActions":"Grid actions","panel.tabActiveCount":{one:"{title}, {count} active",other:"{title}, {count} active"},"panel.tabActive":"{title}, active","views.default":"Default","views.namePlaceholder":"Name this view…","views.nameLabel":"Name for the current layout","views.save":"Save view","licence.watermark":V,"licence.watermark.free":A,"filter.op.contains":"Contains","filter.op.notContains":"Does not contain","filter.op.equals":"Equals","filter.op.notEqual":"Does not equal","filter.op.startsWith":"Starts with","filter.op.endsWith":"Ends with","filter.op.blank":"Is blank","filter.op.notBlank":"Is not blank","filter.op.lessThan":"Less than","filter.op.lessThanOrEqual":"Less than or equal","filter.op.greaterThan":"Greater than","filter.op.greaterThanOrEqual":"Greater than or equal","filter.op.inRange":"In range","filter.op.matches":"Matches","filter.op.before":"Before","filter.op.after":"After","filter.op.relative":"Relative to today","filter.rel.today":"Today","filter.rel.yesterday":"Yesterday","filter.rel.tomorrow":"Tomorrow","filter.rel.lastNDays":"Last N days","filter.rel.nextNDays":"Next N days","filter.rel.thisWeek":"This week","filter.rel.lastWeek":"Last week","filter.rel.thisMonth":"This month","filter.rel.lastMonth":"Last month","filter.rel.thisQuarter":"This quarter","filter.rel.quarterToDate":"Quarter to date","filter.rel.thisYear":"This year","filter.rel.yearToDate":"Year to date","filter.operator":"Operator","filter.join":"Join","filter.value":"Value","filter.from":"From","filter.to":"To","filter.addCondition":"Add condition","filter.noConditions":"No conditions","filter.removeCondition":"Remove condition","filter.search":"Search","filter.searchValues":"Search values","filter.noMatches":"No values match","filter.selectAll":"Select all","filter.clear":"Clear","filter.order":"Order values","filter.orderAz":"A to Z","filter.orderCount":"Count","filter.all":"All","filter.allExcept":"All but {count}","filter.loadingValues":"Loading values…","filter.topValues":"Top {shown} of {total} values","filter.valuesFailed":"Values could not be loaded: {error}","filter.valuesUnsupported":"This source cannot list the values of {column}; filter by condition instead.","filter.true":"True","filter.false":"False","filter.expression":"Filter expression","filter.column":"Column","filter.relativePeriod":"Relative period","filter.days":"Number of days","filter.tab.set":"Values","filter.tab.text":"Text","filter.tab.number":"Number","filter.tab.date":"Date","filter.tab.advanced":"Advanced","filterRow.label":"Filter row","filterRow.conditions":{one:"{count} condition",other:"{count} conditions"},"chart.empty":"Nothing to chart","chart.summary":"{type} chart of {measure} by {dimension}","chart.summaryShare":"{type} chart of {measure}","chart.summaryType":"{type} chart","chart.summaryGauge":"{type} chart of {measure}, {fn}: {value}","chart.waterfallTotal":"Total","chart.summaryEngine":"Figures computed by the data engine over every matching row","chart.summaryEngineViewport":"{count} points in this view, fetched from the data engine","chart.summaryEngineDensity":"{count} rows in this view, more than the {cap} drawn as points, so shown as {cells} density cells counted by the data engine","chart.summaryClientDensity":"{count} rows in this view, more than the {cap} drawn as points, so shown as {cells} density cells computed in the browser","chart.viewportOverCap":"{count} rows in this view, more than the {cap} this map draws; zoom in or narrow the filter","chart.dataTable":"Chart data","chart.viewportFilter.label":"Map view","chart.annotate.rail":"Drawing tools","chart.annotate.select":"Select and move a drawing","chart.annotate.trendLine":"Trend line","chart.annotate.horizontalLine":"Horizontal line","chart.annotate.verticalLine":"Vertical line","chart.annotate.channel":"Parallel channel","chart.annotate.fibonacci":"Fibonacci retracement","chart.annotate.arrow":"Arrow","chart.annotate.pen":"Freehand pen","chart.annotate.pen.described":"Freehand drawing from {from} to {to}","chart.annotate.measure-x":"Date range","chart.annotate.measure-y":"Price range","chart.annotate.measure-xy":"Date and price range","chart.annotate.measure.bars":{one:"{count} bar",other:"{count} bars"},"chart.annotate.measure.points":{one:"{count} point",other:"{count} points"},"chart.annotate.measure.volume":"Vol {value}","chart.annotate.measure.seconds":"{count}s","chart.annotate.measure.minutes":"{count}m","chart.annotate.measure.hours":"{count}h","chart.annotate.measure.days":"{count}d","chart.annotate.measure.weeks":"{count}w","chart.annotate.measure.months":"{count}mo","chart.annotate.measure.years":"{count}y","chart.annotate.measure":"Measure","chart.annotate.measure.dx":"Δx {value}","chart.annotate.measure.dy":"Δy {value}","chart.annotate.measure.pct":"{value}%","chart.annotate.measure.categories":{one:"{count} category",other:"{count} categories"},"chart.annotate.measure.slope.perDay":"Slope {value} per day","chart.annotate.measure.slope.perCategory":"Slope {value} per category","chart.annotate.measure.slope.perUnit":"Slope {value} per unit","chart.annotate.measure.dur.d":"{count} d","chart.annotate.measure.dur.h":"{count} h","chart.annotate.measure.dur.min":"{count} min","chart.annotate.measure.dur.s":"{count} s","chart.annotate.measure.dur.ms":"{count} ms","chart.annotate.measure.announce":"Measurement: {readout}","chart.annotate.measure.start":"Measure start: {x}, {y}","chart.annotate.text":"Text","chart.annotate.callout":"Callout","chart.annotate.note":"Note","chart.annotate.delete":"Delete the selected drawing","chart.annotate.editLabel":"Annotation text","chart.zoom.toolbar":"Zoom controls","chart.zoom.in":"Zoom in","chart.zoom.out":"Zoom out","chart.zoom.left":"Pan left","chart.zoom.right":"Pan right","chart.zoom.reset":"Reset the zoom","chart.legendMore":{one:"+{count} more",other:"+{count} more"},"chart.type.line":"Line","chart.type.area":"Area","chart.type.bar":"Bar","chart.type.pie":"Pie","chart.type.donut":"Donut","chart.type.sunburst":"Sunburst","chart.type.scatter":"Scatter","chart.type.step":"Step","chart.type.rangeArea":"Range","chart.type.horizontalBar":"Horizontal bar","chart.type.waterfall":"Waterfall","chart.type.floatingBar":"Floating bar","chart.type.horizontalFloatingBar":"Horizontal floating bar","chart.type.populationPyramid":"Population pyramid","chart.type.bullet":"Bullet","chart.type.bubble":"Bubble","chart.type.histogram":"Histogram","chart.type.boxplot":"Box plot","chart.type.forest":"Forest plot","chart.type.qq":"QQ plot","chart.type.ecdf":"ECDF","chart.type.lorenz":"Lorenz","chart.type.correlogram":"Correlogram","chart.type.control":"Control","chart.type.capability":"Capability","chart.type.movingRange":"Moving range","chart.type.treemap":"Treemap","chart.type.combo":"Combination","chart.type.pareto":"Pareto","chart.type.heatmap":"Heat map","chart.type.radar":"Radar","chart.type.gauge":"Gauge","chart.type.funnel":"Funnel","chart.type.candlestick":"Candlestick","chart.type.ohlc":"OHLC","chart.type.polarArea":"Polar area","chart.type.nightingale":"Nightingale rose","chart.type.rose":"Rose","chart.type.radialBar":"Radial bar","chart.type.polarScatter":"Polar scatter","chart.type.geomap":"Map","chart.type.sankey":"Sankey","chart.type.chord":"Chord","chart.type.pyramid":"Pyramid","chart.type.pictorial":"Pictorial","chart.type.serpentine":"Serpentine timeline","chart.type.spiral":"Spiral timeline","chart.edit.aggregated":"This value is a total of several rows, so it cannot be dragged.","chart.edit.refused":"That change was not applied.","chart.edit.refusedWhy":"That change was not applied: {reason}","chart.type.network":"Network","chart.type.stream":"Stream","chart.type.marimekko":"Marimekko","chart.type.violin":"Violin","chart.type.gantt":"Gantt","chart.type.forceTree":"Force-directed tree","chart.type.pack":"Packed circles","chart.type.tree":"Tree","chart.type.voronoiTreemap":"Voronoi treemap","chart.type.alluvial":"Alluvial","chart.type.arc":"Arc diagram","chart.type.barRace":"Bar chart race","chart.type.bubblemap":"Bubble map","chart.type.bump":"Bump chart","chart.type.calendar":"Calendar heat map","chart.type.choropleth":"Choropleth map","chart.type.decomposition":"Decomposition tree","chart.type.diverging":"Diverging bar","chart.type.dumbbell":"Dumbbell","chart.type.fan":"Fan chart","chart.type.hexbin":"Hexagonal bin","chart.type.hexmap":"Hex map","chart.type.icicle":"Icicle","chart.type.markermap":"Marker map","chart.type.motion":"Motion chart","chart.type.parallel":"Parallel coordinates","chart.type.ridgeline":"Ridgeline","chart.type.roc":"ROC curve","chart.type.scatter3d":"3D scatter","chart.type.slope":"Slope chart","chart.type.splom":"Scatter plot matrix","chart.type.venn":"Venn diagram","chart.type.waffle":"Waffle","chart.type.wordCloud":"Word cloud","chart.tasksDropped":{one:"{count} more task not shown",other:"{count} more tasks not shown"},"chart.geoUnmatched":{one:"{count} row could not be placed on the map",other:"{count} rows could not be placed on the map"},"chart.r2":"R² {value}","ai.insights":"Insights","ai.explainView":"Explain this view","ai.explain":"Explain","ai.ask":"Ask","ai.apply":"Apply","ai.discard":"Discard","ai.propose":"Propose","ai.approve":"Approve","ai.thinking":"Thinking…","ai.applying":"Applying…","ai.applied":"Applied: {what}","ai.couldNotApply":"Could not apply: {why}","ai.applyFailed":"it failed","ai.discarded":"Discarded.","ai.discardedNothingWritten":"Discarded. Nothing was written.","ai.nothingWritten":"Nothing was written.","ai.nothingWrittenVetoed":"Nothing was written — a before-handler vetoed it.","ai.scope":"Scope: {scope}","ai.unsafeQuery":"I could not turn that into a safe query: {why}","ai.nothingToDo":"nothing to do","ai.insightsFailed":"Could not generate insights right now. The grid is unaffected.","ai.modelUnreachable":"Could not reach the model right now. The grid is unaffected.","ai.flagged":{one:"{count} unverified figure was removed as ungrounded.",other:"{count} unverified figures were removed as ungrounded."},"ai.askPlaceholder":"Ask your data: “EMEA deals over 50k, biggest first”","ai.askLabel":"Ask your data","ai.actorPlaceholder":"Ask AI to change data: “set the Network Upgrade project to In Progress”","ai.actorLabel":"Ask AI to change data","editor.password.show":"Show value","editor.password.hide":"Hide value","editor.password.showField":"Show {column}","editor.password.hideField":"Hide {column}","facets.computing":"Computing…","facets.suppressed.cardinality":"Too many distinct values to chart","facets.suppressed.rows":"Too many rows to chart","facets.suppressed.streaming":"Paused while live data is streaming","facets.suppressed.noProvider":"No distribution available for this data source","facets.suppressed.type":"This column has no chartable distribution","facets.suppressed.unavailable":"Histogram unavailable","facets.bucketOf":"{count} of {whole} rows","history.undo":"Undo","history.redo":"Redo","history.described":"{action} {label}","history.nothingToUndo":"Nothing to undo","history.nothingToRedo":"Nothing to redo","history.undoDisabled":"Undo (nothing to undo)","history.redoDisabled":"Redo (nothing to redo)","a11y.presence.joined":"{name} joined","a11y.presence.left":"{name} left","prompt.asking":"Asking…","prompt.moreNotes":{one:"and {count} more",other:"and {count} more"},"shortcuts.key.cmd":"Cmd","timeline.live":"Live","timeline.recording":"recording…","panel.zoneHint.group":"Drag a column here to group rows by its values","panel.zoneHint.values":"Drag a column here to total it","panel.zoneHint.pivot":"Drag a column here to pivot across its values","panel.zoneHint.any":"Drag a column here","panel.rowsOf":"{shown} of {total} rows","views.empty":"No saved views yet. Set the grid up as you want it, then save it below.","views.applied":"Applied","views.matchesGrid":"Matches the grid as it is","views.delete":"Delete","views.confirmDelete":"Delete {name}?","views.confirmDeleteLabel":"Confirm deleting {name}","views.shared":"View copied to the clipboard","views.sharedDownload":"Clipboard unavailable; the view was downloaded as {name}","views.sharedFailed":"The view could not be copied or downloaded","views.rename":"Rename","views.ownedBy":"Owned by {name}","views.ownerOnlyReason":"Only {name} or an admin can do that","views.noOwnerReason":"Only an admin can do that — this view has no recorded owner","views.unshare":"Unshare","views.unshareTitle":"Stop sharing {name}","views.duplicate":"Duplicate","views.duplicateTitle":"Duplicate {name}","views.copyName":"{name} (copy)","gantt.row.expand":"Expand {name}","gantt.row.collapse":"Collapse {name}","gantt.resource.over":"{name} — over-allocated","kanban.board":"Board","kanban.requiredTitle":"Required fields","kanban.requiredSave":"Save","kanban.requiredCancel":"Cancel","kanban.moveRefused":'Move refused: a card in "{from}" cannot move to "{to}".',"kpi.status.good":"good","kpi.status.warn":"warn","kpi.status.critical":"critical","kpi.status.unknown":"No data","kpi.node.item":"{count} item","kpi.node.items":"{count} items","kpi.node.worst":"worst status {status}","kpi.node.unknown":"{count} unknown","sidebar.nav":"Main navigation","sidebar.search":"Search","sidebar.collapse":"Collapse sidebar","sidebar.expand":"Expand sidebar","toolbar.more":"More"}),I=Object.freeze(Object.keys(U))}),ze("packages/core/src/i18n/format.js",function(e,B){"use strict";Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"formatMessage",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"lookup",{enumerable:!0,get:function(){return v}});const A=B("packages/core/src/internal/predicates.js").isFunction,V=/\{(\w+)\}/g,U=new Map,I=new Map;function J(b){const c=b||"";if(U.has(c))return U.get(c);let g=null;try{g=new Intl.PluralRules(b||void 0)}catch{g=null}return U.set(c,g),g}function H(b,c,g="conjunction"){const o=Array.isArray(b)?b.filter(l=>l!=null&&l!==""):[];if(o.length===0)return"";if(o.length===1)return String(o[0]);const t=`${c||""}|${g}`;let s=I.get(t);if(s===void 0){try{s=new Intl.ListFormat(c||void 0,{style:"long",type:g})}catch{s=null}I.set(t,s)}return s?s.format(o.map(String)):o.map(String).join(", ")}function L(b,c){return b==null?"":typeof b=="number"?Number.isFinite(b)?b.toLocaleString(c||void 0,{maximumFractionDigits:20}):"":String(b)}function Y(b,c,g){if(typeof b=="string")return b;if(!b||typeof b!="object")return"";const o=c&&typeof c.count=="number"?c.count:null;if(o===null)return b.other??"";const t=J(g),s=t?t.select(o):o===1?"one":"other";return b[s]??b.other??""}function _(b,c={},g){const o=Y(b,c,g);return o?o.replace(V,(t,s)=>Object.prototype.hasOwnProperty.call(c,s)?L(c[s],g):t):""}function O(b,c,g="en-GB"){return typeof b=="string"&&b?b:typeof c=="string"&&c?c:g}function v(b,c){const g=b?b[c]:void 0;return g==null||A(g)?c:g}}),ze("packages/core/src/i18n/registry.js",function(e,B){"use strict";Object.defineProperty(e,"registerLocale",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"localeCatalogue",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"registeredTags",{enumerable:!0,get:function(){return J}});const A=B("packages/core/src/i18n/catalogue.js").EN_GB,V=new Map([["en-gb",A]]);function U(H,L){const Y=typeof H=="string"?H.toLowerCase():"";return!Y||!L||typeof L!="object"?!1:(V.set(Y,L),!0)}function I(H){if(typeof H!="string"||!H)return null;const L=H.toLowerCase(),Y=V.get(L);if(Y)return Y;const _=L.split("-")[0],O=V.get(_);if(O)return O;for(const[v,b]of V)if(v.split("-")[0]===_)return b;return null}function J(){return[...V.keys()]}}),ze("packages/core/src/i18n/index.js",function(e,B){"use strict";Object.defineProperty(e,"DEFAULT_LOCALE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"Messages",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"defaultMessages",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"createMessages",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"auditCatalogue",{enumerable:!0,get:function(){return u}});const ne=B("packages/core/src/i18n/catalogue.js"),A=ne.EN_GB,V=ne.MESSAGE_KEYS,U=B("packages/core/src/i18n/format.js"),I=U.formatMessage,J=U.formatList,H=U.lookup,L=U.resolveLocale,_=B("packages/core/src/internal/predicates.js").isFunction,v=B("packages/core/src/internal/warn.js").warnOnce,b=B("packages/core/src/i18n/registry.js"),c=b.registerLocale,g=b.localeCatalogue;Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return ne.EN_GB}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return ne.MESSAGE_KEYS}}),Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return U.formatList}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return U.resolveLocale}}),Object.defineProperty(e,"registerLocale",{enumerable:!0,get:function(){return b.registerLocale}});const o="en-GB";class t{#e=o;#t=A;constructor(p={}){this.configure(p)}configure(p={}){this.#e=L(p.locale,p.declared,o);const r=p.messages,i=g(this.#e);if(!i&&this.#e.toLowerCase()!=="en-gb"&&(!r||typeof r!="object")&&v(`i18n:locale:not-loaded:${this.#e.toLowerCase()}`,`locale "${this.#e}" is not loaded: import "@toclocoinc/lattice-grid/locales/${this.#e}" to add its text; English is used until then.`),!r||typeof r!="object"){this.#t=i?{...A,...i}:A;return}const h=Object.keys(r).filter(a=>!(a in A));h.length&&v(`i18n:unknown:${h[0]}`,`message keys not in the catalogue and so ignored: ${h.slice(0,5).join(", ")}${h.length>5?`, and ${h.length-5} more`:""}`),this.#t={...A,...i||{},...r}}get locale(){return this.#e}t(p,r){return I(H(this.#t,p),r||{},this.#e)}list(p,r){return J(p,this.#e,r)}number(p,r){const i=Number(p);return Number.isFinite(i)?i.toLocaleString(this.#e,r||{maximumFractionDigits:20}):""}}const s=new t;function l(n){return n instanceof t?n:new t(n||{})}function u(n){const p=n&&typeof n=="object"?n:{},r=V.filter(d=>{const h=p[d];return h==null||h===""||_(h)}),i=Object.keys(p).filter(d=>!(d in A));return{missing:r,unknown:i}}}),ze("packages/core/src/columns/types/structured.js",function(e,B){"use strict";Object.defineProperty(e,"MASK_DEFAULTS",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"maskValue",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"summariseJson",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"canonicalJson",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"parseJsonText",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"STRUCTURED_TYPES",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return o}});const ne=B("packages/core/src/internal/predicates.js"),A=ne.isNil,V=ne.isObject,I=B("packages/core/src/i18n/index.js").defaultMessages,J=Object.freeze({char:"•",length:8,fixedLength:!0,lastVisible:0,emptyDisplay:""});function H(t,s){const l=s||{},u=l.emptyDisplay??J.emptyDisplay;if(A(t)||t==="")return u;const p=[...typeof l.char=="string"&&l.char!==""?l.char:J.char][0]||J.char,r=l.fixedLength??J.fixedLength,i=Number.isFinite(l.length)&&Number(l.length)>0?Math.floor(Number(l.length)):J.length,d=typeof t=="string"?t:typeof t=="number"||typeof t=="boolean"||typeof t=="bigint"?String(t):null;let h=0;if(d!==null){const a=Number.isFinite(l.lastVisible)?Math.floor(Number(l.lastVisible)):J.lastVisible,y=[...d];if(h=a>0&&a<y.length?a:0,h>0){const f=y.slice(y.length-h).join(""),m=Math.max(1,(r?i:y.length)-h);return p.repeat(m)+f}return p.repeat(r?i:Math.max(1,y.length))}return p.repeat(i)}const L=48;function Y(t){try{const s=JSON.stringify(t);return s===void 0?null:s}catch{return null}}function _(t,s){if(A(t))return"";const l=Number.isFinite(s&&s.inlineLimit)?Number(s.inlineLimit):L;if(typeof t=="string")return t.length>l?`${t.slice(0,l-1)}…`:t;if(typeof t!="object")return String(t);const u=Y(t);if(u!==null&&u.length<=l)return u;if(Array.isArray(t)){const p=t.length;return`[${I.t("count.items",{count:p})}]`}const n=Object.keys(t).length;return`{${I.t("count.keys",{count:n})}}`}function O(t,s){if(t==null)return"null";const l=typeof t;if(l==="number"||l==="boolean"||l==="bigint")return String(t);if(l==="string")return JSON.stringify(t);if(l!=="object")return JSON.stringify(String(t));const u=s||new WeakSet;return u.has(t)?'"[circular]"':(u.add(t),t instanceof Date?JSON.stringify(t.toISOString()):Array.isArray(t)?`[${t.map(r=>O(r,u)).join(",")}]`:`{${Object.keys(t).sort().map(r=>`${JSON.stringify(r)}:${O(t[r],u)}`).join(",")}}`)}function v(t,s){if(A(t))return A(s)?0:1;if(A(s))return-1;const l=O(t),u=O(s);return l<u?-1:l>u?1:0}function b(t){if(A(t))return null;const s=String(t);if(s.trim()==="")return null;try{return JSON.parse(s)}catch{return s}}function c(t){const s=t&&t.cell&&t.cell.props;return V(s)?s:{}}const g=Object.freeze({json:{base:"object",storage:"object",format:t=>_(t&&t.value,c(t&&t.column)),parse:t=>b(t&&t.text),compare:v,defaults:{editor:"code",filter:"text",align:"start"},excel:"@",toClipboard:t=>{if(A(t))return"";if(typeof t=="string")return t;try{const s=JSON.stringify(t,null,2);return s===void 0?String(t):s}catch{return String(t)}},fromClipboard:t=>b(t)},secret:{base:"text",storage:"object",format:t=>H(t&&t.value,c(t&&t.column)),parse:t=>{const s=t&&t.text;return A(s)||String(s)===""?null:String(s)},compare:(t,s)=>{const l=A(t)||t==="",u=A(s)||s==="";return l===u?0:l?1:-1},defaults:{editor:"password",filter:"none",align:"start"},excel:"@",export:{csv:!1,excel:!1},toClipboard:t=>H(t),fromClipboard:t=>A(t)||String(t)===""?null:String(t)}}),o=g}),ze("packages/core/src/columns/types/unit.js",function(e,B){"use strict";Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"unitSystemNames",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"unitsOf",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"findUnit",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"localeSeparators",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return T}});const A=B("packages/core/src/internal/predicates.js").isNil,U=B("packages/core/src/internal/warn.js").warnOnce;function I(F,$,D,z){return Object.freeze({symbol:F,factor:$,aliases:Object.freeze(D||[]),binary:!!(z&&z.binary),prefix:z&&z.prefix||null,auto:!(z&&z.auto===!1)})}function J(F,$,D,z){return I(F,$,D,z)}const H=Object.freeze({data:Object.freeze([I("B",1,["byte","bytes"]),I("kB",1e3,["kilobyte","kilobytes"],{prefix:"k"}),I("KiB",1024,["kibibyte","kibibytes"],{binary:!0,prefix:"k"}),I("MB",1e6,["megabyte","megabytes"],{prefix:"m"}),I("MiB",1024**2,["mebibyte","mebibytes"],{binary:!0,prefix:"m"}),I("GB",1e9,["gigabyte","gigabytes"],{prefix:"g"}),I("GiB",1024**3,["gibibyte","gibibytes"],{binary:!0,prefix:"g"}),I("TB",1e12,["terabyte","terabytes"],{prefix:"t"}),I("TiB",1024**4,["tebibyte","tebibytes"],{binary:!0,prefix:"t"}),I("PB",1e15,["petabyte","petabytes"],{prefix:"p"})]),bitrate:Object.freeze([I("bps",1,["bit","bits","bit/s","b/s"]),I("kbps",1e3,["kbit","kbits","kbit/s","kb/s","kilobit","kilobits"],{prefix:"k"}),I("Mbps",1e6,["mbit","mbits","mbit/s","mb/s","megabit","megabits"],{prefix:"m"}),I("Gbps",1e9,["gbit","gbits","gbit/s","gb/s","gigabit","gigabits"],{prefix:"g"}),I("Tbps",1e12,["tbit","tbits","tbit/s","tb/s","terabit","terabits"],{prefix:"t"})]),length:Object.freeze([I("nm",1e-9,["nanometre","nanometres","nanometer","nanometers"]),I("µm",1e-6,["um","micrometre","micrometres","micrometer","micrometers","micron","microns"]),I("mm",.001,["millimetre","millimetres","millimeter","millimeters"]),I("cm",.01,["centimetre","centimetres","centimeter","centimeters"]),I("in",.0254,["inch","inches"],{auto:!1}),I("ft",.3048,["foot","feet"],{auto:!1}),I("yd",.9144,["yard","yards"],{auto:!1}),I("m",1,["metre","metres","meter","meters"]),I("km",1e3,["kilometre","kilometres","kilometer","kilometers"]),I("mi",1609.344,["mile","miles"],{auto:!1}),I("nmi",1852,["nauticalmile","nauticalmiles"],{auto:!1})]),mass:Object.freeze([I("mg",.001,["milligram","milligrams"]),I("g",1,["gram","grams"]),I("oz",28.349523125,["ounce","ounces"],{auto:!1}),I("lb",453.59237,["pound","pounds","lbs"],{auto:!1}),I("kg",1e3,["kilogram","kilograms"]),I("st",6350.29318,["stone"],{auto:!1}),I("t",1e6,["tonne","tonnes","ton"],{auto:!1}),I("ton (US)",907184.74,["ton","shortton"],{auto:!1}),I("ton (UK)",10160469088e-4,["ton","longton"],{auto:!1})]),duration:Object.freeze([I("ns",1e-9,["nsec","nsecs","nanosecond","nanoseconds"]),I("µs",1e-6,["us","usec","usecs","microsecond","microseconds"]),I("ms",.001,["msec","msecs","millisecond","milliseconds"]),I("s",1,["sec","secs","second","seconds"]),I("m",60,["min","mins","minute","minutes"]),I("h",3600,["hr","hrs","hour","hours"]),I("d",86400,["day","days"])]),speed:Object.freeze([I("mm/s",.001,["millimetre/s","millimeter/s"]),I("ft/s",.3048,["fps","foot/s","feet/s"],{auto:!1}),I("km/h",1/3.6,["kph","kmh","kilometre/h","kilometer/h"],{auto:!1}),I("mph",.44704,["mile/h","miles/h"],{auto:!1}),I("kn",1852/3600,["knot","knots"],{auto:!1}),I("m/s",1,["metre/s","meter/s","mps"]),I("km/s",1e3,["kilometre/s","kilometer/s"])]),acceleration:Object.freeze([I("mm/s²",.001,["mm/s2"]),I("ft/s²",.3048,["ft/s2"],{auto:!1}),I("m/s²",1,["m/s2","metre/s2","meter/s2"]),I("g",9.80665,["gee","gravity"],{auto:!1})]),area:Object.freeze([I("mm²",1e-6,["mm2"]),I("cm²",1e-4,["cm2"]),I("in²",64516e-8,["in2","sqin"],{auto:!1}),I("ft²",.09290304,["ft2","sqft"],{auto:!1}),I("yd²",.83612736,["yd2","sqyd"],{auto:!1}),I("m²",1,["m2","sqm"]),I("ha",1e4,["hectare","hectares"],{auto:!1}),I("ac",4046.8564224,["acre","acres"],{auto:!1}),I("km²",1e6,["km2","sqkm"])]),volume:Object.freeze([I("µL",1e-6,["ul","microlitre","microliter"]),I("mL",.001,["millilitre","milliliter"]),I("fl oz (US)",.0295735295625,["fl oz","usfloz"],{auto:!1}),I("fl oz (imp)",.0284130625,["fl oz","impfloz"],{auto:!1}),I("L",1,["litre","litres","liter","liters"]),I("gal (US)",3.785411784,["gal","usgal","usgallon"],{auto:!1}),I("gal (imp)",4.54609,["gal","impgal","impgallon"],{auto:!1}),I("m³",1e3,["m3","cubicmetre","cubicmeter","kl"],{auto:!1}),I("bbl",158.987294928,["barrel","barrels"],{auto:!1})]),energy:Object.freeze([I("eV",1602176634e-28,["electronvolt","electronvolts"],{auto:!1}),I("J",1,["joule","joules"]),I("cal",4.184,["calorie","calories"],{auto:!1}),I("kJ",1e3,["kilojoule","kilojoules"]),I("BTU",1055.05585262,["btu"],{auto:!1}),I("kcal",4184,["kilocalorie","kilocalories","Cal"],{auto:!1}),I("MJ",1e6,["megajoule","megajoules"]),I("kWh",36e5,["kilowatthour","kilowatthours"],{auto:!1}),I("GJ",1e9,["gigajoule","gigajoules"]),I("MWh",36e8,["megawatthour","megawatthours"],{auto:!1})]),power:Object.freeze([I("mW",.001,["milliwatt","milliwatts"]),I("W",1,["watt","watts"]),I("BTU/h",1055.05585262/3600,["btuh","btu/h"],{auto:!1}),I("kW",1e3,["kilowatt","kilowatts"]),I("hp",745.6998715822702,["horsepower"],{auto:!1}),I("MW",1e6,["megawatt","megawatts"]),I("GW",1e9,["gigawatt","gigawatts"])]),force:Object.freeze([I("mN",.001,["millinewton","millinewtons"]),I("N",1,["newton","newtons"]),I("lbf",4.4482216152605,["poundforce"],{auto:!1}),I("kgf",9.80665,["kilogramforce"],{auto:!1}),I("kN",1e3,["kilonewton","kilonewtons"]),I("MN",1e6,["meganewton","meganewtons"])]),pressure:Object.freeze([I("Pa",1,["pascal","pascals"]),I("mbar",100,["millibar"],{auto:!1}),I("inH₂O",249.0889,["inh2o"],{auto:!1}),I("mmHg",133.322387415,["torr"],{auto:!1}),I("kPa",1e3,["kilopascal","kilopascals"]),I("inHg",3386.388640341,["inhg"],{auto:!1}),I("psi",6894.757293168361,["lbf/in2"],{auto:!1}),I("bar",1e5,[],{auto:!1}),I("atm",101325,["atmosphere","atmospheres"],{auto:!1}),I("MPa",1e6,["megapascal","megapascals"]),I("GPa",1e9,["gigapascal","gigapascals"])]),torque:Object.freeze([I("N·m",1,["nm","n.m","newtonmetre","newtonmeter"]),I("lbf·ft",1.3558179483314003,["lbfft","lbf.ft","ftlb","ft-lb"],{auto:!1}),I("kN·m",1e3,["knm","kn.m"],{auto:!1}),I("MN·m",1e6,["mnm","mn.m"],{auto:!1})]),density:Object.freeze([I("kg/m³",1,["kg/m3"]),I("lb/ft³",16.01846337396014,["lb/ft3","pcf"],{auto:!1}),I("g/cm³",1e3,["g/cm3","g/ml","kg/l"],{auto:!1}),I("t/m³",1e3,["t/m3"],{auto:!1})]),flow:Object.freeze([I("L/min",1/6e4,["lpm","l/min"],{auto:!1}),I("m³/h",1/3600,["m3/h","cmh"],{auto:!1}),I("gpm (US)",.003785411784/60,["gpm","usgpm"],{auto:!1}),I("gpm (imp)",.00454609/60,["gpm","impgpm"],{auto:!1}),I("cfm",.0004719474432,["ft3/min"],{auto:!1}),I("L/s",.001,["lps","l/s"],{auto:!1}),I("m³/s",1,["m3/s","cms"])]),angle:Object.freeze([I("″",Math.PI/648e3,["arcsec","arcsecond","arcseconds"],{auto:!1}),I("′",Math.PI/10800,["arcmin","arcminute","arcminutes"],{auto:!1}),I("mrad",.001,["milliradian","milliradians"],{auto:!1}),I("mil",Math.PI/3200,["nato-mil"],{auto:!1}),I("°",Math.PI/180,["deg","degree","degrees"],{auto:!1}),I("gon",Math.PI/200,["grad","gradian","gradians"],{auto:!1}),I("rad",1,["radian","radians"]),I("turn",2*Math.PI,["rev","revolution","revolutions"],{auto:!1})]),angularVelocity:Object.freeze([I("°/s",Math.PI/180,["degps","deg/s","degrees/s"],{auto:!1}),I("rad/s",1,["radps","radians/s"]),I("rpm",2*Math.PI/60,["rev/min","r/min","revolutions/min"],{auto:!1}),I("rps",2*Math.PI,["rev/s","r/s","revolutions/s"],{auto:!1})]),fraction:Object.freeze([I("ppt",1e-12,["partspertrillion"],{auto:!1}),I("ppb",1e-9,["partsperbillion"]),I("ppm",1e-6,["partspermillion"]),I("bp",1e-4,["bps-finance","basispoint","basispoints","bips"],{auto:!1}),I("‰",.001,["permille","permil"],{auto:!1}),I("%",.01,["pct","percent"]),I("×",1,["x","ratio","times"])]),molarity:Object.freeze([I("pM",1e-12,["picomolar","picomolarity"]),I("nM",1e-9,["nanomolar","nanomolarity"]),I("µM",1e-6,["um-molar","micromolar","micromolarity"]),I("mM",.001,["millimolar","millimolarity"]),I("M",1,["molar","mol/l","mol/L","molarity"]),I("mol/m³",.001,["mol/m3"],{auto:!1})]),massFlow:Object.freeze([I("mg/s",1e-6,["milligrams/s"]),I("g/s",.001,["grams/s"]),I("kg/h",1/3600,["kilograms/h","kgph"],{auto:!1}),I("kg/s",1,["kilograms/s","kgps"]),I("t/h",1e3/3600,["tonnes/h","tph"],{auto:!1}),I("lb/h",.45359237/3600,["pounds/h","pph"],{auto:!1}),I("t/s",1e3,["tonnes/s"],{auto:!1})]),viscosity:Object.freeze([I("µPa·s",1e-6,["upas","micropascalsecond"]),I("cP",.001,["centipoise"],{auto:!1}),I("mPa·s",.001,["mpas","millipascalsecond"]),I("P",.1,["poise"],{auto:!1}),I("Pa·s",1,["pas","pascalsecond"])]),kinematicViscosity:Object.freeze([I("cSt",1e-6,["centistokes","centistoke"]),I("mm²/s",1e-6,["mm2/s"],{auto:!1}),I("St",1e-4,["stokes","stoke"],{auto:!1}),I("m²/s",1,["m2/s"])]),thermalConductivity:Object.freeze([I("mW/(m·K)",.001,["mw/mk"]),I("W/(m·K)",1,["w/mk","wmk"]),I("kW/(m·K)",1e3,["kw/mk"],{auto:!1}),I("BTU/(hr·ft·°F)",1.730734666,["btu/hrftf"],{auto:!1})]),specificHeat:Object.freeze([I("J/(kg·K)",1,["j/kgk","jkgk"]),I("kJ/(kg·K)",1e3,["kj/kgk"]),I("cal/(g·°C)",4184,["cal/gc"],{auto:!1})]),doseRate:Object.freeze([I("nSv/h",1e-9,["nsvh"]),I("µSv/h",1e-6,["usv/h","usvh"]),I("mSv/h",.001,["msvh"]),I("Sv/h",1,["svh"]),I("mSv/a",.001/8766,["msv/year","msvpa"],{auto:!1})])}),L=Symbol("ambiguous"),Y=new Map,_=new Map;function O(F,$){const D=String(F||"").trim();if(!D)throw new Error("[lattice] a unit system needs a name");if(H[D]||_.has(D))throw new Error(`[lattice] unit system "${D}" already exists`);const z=[...$||[]];if(!z.length)throw new Error(`[lattice] unit system "${D}" has no units`);if(!z.some(N=>N.factor===1))throw new Error(`[lattice] unit system "${D}" has no base unit (none with factor 1)`);const G=new Set;for(const N of z){if(G.has(N.symbol))throw new Error(`[lattice] unit system "${D}" declares "${N.symbol}" twice`);G.add(N.symbol)}return _.set(D,Object.freeze(z)),Y.delete(D),D}function v(){return[...Object.keys(H),..._.keys()]}function b(F){const $=c(F);return $?$.units:[]}function c(F){const $=String(F||""),D=Y.get($);if(D!==void 0)return D;const z=H[$]||_.get($);if(!z)return Y.set($,null),null;const G=Object.freeze([...z].sort((re,ie)=>re.factor-ie.factor)),N=new Map,Z=new Map,Q=(re,ie)=>{const ce=N.get(re);ce===void 0?N.set(re,ie):ce!==ie&&N.set(re,L)};for(const re of G){Q(re.symbol.toLowerCase(),re);for(const ie of re.aliases)Q(ie.toLowerCase(),re);if(re.prefix){const ie=Z.get(re.prefix)||[];ie.push(re),Z.set(re.prefix,ie)}}const ee={units:G,byToken:N,byPrefix:Z,decimal:G.filter(re=>!re.binary&&re.auto),binary:G.some(re=>re.binary)?G.filter(re=>(re.binary||re.factor===1)&&re.auto):null};return Y.set($,ee),ee}function g(F,$){return $&&F.binary||F.decimal}function o(F,$){const D=c(F);if(!D||A($))return null;const z=D.units.find(N=>N.symbol===String($));if(z)return z;const G=D.byToken.get(String($).trim().toLowerCase());return G&&G!==L?G:null}const t=new WeakMap;function s(F){const $=F||{};if(typeof $=="object"&&$!==null){const N=t.get($);if(N!==void 0)return N}const D=$.system||"data",z=c(D);let G=null;if(!z)U(`unit:system:${D}`,`unknown unit system "${D}"; known systems are ${v().join(", ")}`);else{let N=$.unit?o(D,$.unit):null;N||($.unit&&U(`unit:unit:${D}:${$.unit}`,`unknown unit "${$.unit}" in system "${D}"; falling back to ${z.units[0].symbol}`),N=z.units.find(Z=>Z.factor===1)||z.units[0]),G={index:z,base:N,binary:$.binary===!0}}return typeof $=="object"&&$!==null&&t.set($,G),G}const l=new WeakMap;function u(F,$){if(!F||!$||!Array.isArray(F.compound)||F.compound.length===0)return null;const D=l.get(F);if(D!==void 0)return D;const z=new Set,G=[];for(const Z of F.compound){const Q=o(F.system||"data",Z);if(!Q){U(`unit:compound:${F.system}:${Z}`,`unknown compound unit "${Z}" in system "${F.system||"data"}"; ignoring it`);continue}z.has(Q.symbol)||(z.add(Q.symbol),G.push(Q))}G.sort((Z,Q)=>Q.factor-Z.factor);const N=G.length>=2?G:null;return l.set(F,N),N}function n(F,$,D){return $===D||$.factor===D.factor?F:F*$.factor/D.factor}const p=new Map;function r(F){const $=F||"",D=p.get($);if(D)return D;const z={group:",",decimal:"."};try{for(const G of new Intl.NumberFormat(F||void 0).formatToParts(12345.6))G.type==="group"?z.group=G.value:G.type==="decimal"&&(z.decimal=G.value)}catch{}return p.set($,z),z}const i=/[\s ]/g,d=/^[+-]?[\d '’ .,]*(?:[eE][+-]?\d+)?/,h=/^[^\d+\-(.,\s]+\s*/,a=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/;function y(F,$){const{group:D,decimal:z}=r($);let G=String(F).replace(i,"");if(G==="")return null;const N=z?G.indexOf(z):-1;if(D&&D!==z){if(N>=0&&G.indexOf(D,N+z.length)>=0)return null;G=G.split(D).join("")}if(z&&z!=="."&&(G=G.split(z).join(".")),!a.test(G))return null;const Z=Number(G);return Number.isFinite(Z)?Z:null}function f(F,$,D){const z=String(F).trim().replace(/\.$/,"");if(z==="")return null;const G=$.units.find(ie=>ie.symbol===z);if(G)return G;const N=z.toLowerCase(),Z=$.byToken.get(N);if(Z===L)return null;if(Z)return Z;const Q=$.byPrefix.get(N);if(!Q||!Q.length)return null;const ee=g($,D),re=Q.filter(ie=>ee.includes(ie));return re.length===1?re[0]:null}function m(F,$,D,z){let G=F,N=0,Z=!1,Q=!1;for(;G!=="";){const ee=d.exec(G)[0];if(ee==="")return null;const re=y(ee,z&&z.locale);if(re===null)return null;G=G.slice(ee.length).trim();const ie=G.search(/[+-]?[\d]/),ce=(ie>=0?G.slice(0,ie):G).trim();if(G=ie>=0?G.slice(ie).trim():"",ce===""){if(Z)return null;Q=!0,N+=n(re,D[0],$.base)}else{const ve=f(ce,$.index,$.binary);if(!ve)return null;N+=n(re,ve,$.base)}if(Z=!0,Q&&G!=="")return null}return Z?N:null}function w(F,$){if(A(F))return null;if(typeof F=="number")return Number.isFinite(F)?F:null;const D=s($);if(!D)return null;let z=String(F).trim();if(z==="")return null;let G=!1;z.startsWith("(")&&z.endsWith(")")&&(G=!0,z=z.slice(1,-1).trim());const N=u($,D);if(N){z.startsWith("-")&&(G=!0,z=z.slice(1).trim());const he=m(z,D,N,$);return he===null?null:G?-he:he}let Z=null;const Q=h.exec(z);if(Q&&Q[0]){const he=f(Q[0].trim(),D.index,D.binary);he&&(Z=he,z=z.slice(Q[0].length).trim())}const ee=d.exec(z)[0],re=y(ee,$&&$.locale);if(re===null)return null;const ie=z.slice(ee.length).trim();if(Z&&ie!=="")return null;const ce=Z||(ie===""?D.base:f(ie,D.index,D.binary));if(!ce)return null;const ve=n(re,ce,D.base);return G?-ve:ve}const S=new Map;function M(F,$,D,z){const G=`${F||""}|${$}|${D}|${z?1:0}`;let N=S.get(G);return N||(N=new Intl.NumberFormat(F||void 0,{minimumFractionDigits:$,maximumFractionDigits:D,useGrouping:z}),S.set(G,N)),N}function X(F,$){if(!Number.isFinite(F)||F===0)return Math.max(0,$-1);const D=Math.floor(Math.log10(Math.abs(F)));return Math.min(20,Math.max(0,$-1-D))}function q(F,$){if(!Number.isFinite(F)||F===0)return F;const D=Math.ceil(Math.log10(Math.abs(F))),z=10**($-D);return Math.round(F*z)/z}function K(F,$,D){if(!D||D===$.base.symbol)return $.base;if(D!=="auto")return P($,D);if(F===0||!Number.isFinite(F))return $.base;const z=Math.abs(F)*$.base.factor,G=g($.index,$.binary);let N=G[0];for(const ee of G)z>=ee.factor&&(N=ee);if(z>=N.factor)return N;let Z=N;for(const ee of $.index.units)ee.binary!==$.binary&&ee.factor!==1||ee.factor<=z&&ee.factor>(Z===N?0:Z.factor)&&(Z=ee);if(Z!==N)return Z;let Q=N;for(const ee of $.index.units)ee.binary!==$.binary&&ee.factor!==1||ee.factor<Q.factor&&(Q=ee);return Q.factor<$.base.factor?Q:$.base}function P(F,$){const D=F.index.units.find(G=>G.symbol===$);if(D)return D;const z=F.index.byToken.get(String($).toLowerCase());return z&&z!==L?z:(U(`unit:display:${$}`,`unknown display unit "${$}"; rendering in ${F.base.symbol}`),F.base)}function k(F,$,D,z){const G=F<0;let N=Math.abs(F)*$.base.factor;const Z=typeof z.decimals=="number"?z.decimals:z.minDecimals??0,Q=typeof z.decimals=="number"?z.decimals:z.maxDecimals??Math.max(Z,2),ee=z.space??" ",re=[];for(let ce=0;ce<D.length;ce++){const ve=D[ce],he=ce===D.length-1;let ye=he?N/ve.factor:Math.floor(N/ve.factor);if(N-=ye*ve.factor,he){const Le=10**Q;ye=Math.round(ye*Le)/Le+0}const Oe=he?M(z.locale,Z,Q,z.group!==!1):M(z.locale,0,0,z.group!==!1);re.push(`${Oe.format(ye)}${ee}${ve.symbol}`)}const ie=re.join(" ");return G?`-${ie}`:ie}function E(F,$){const D=$||{},z=D.nullDisplay??"";if(A(F)||F==="")return z;const G=typeof F=="number"?F:Number(F);if(!Number.isFinite(G))return z;const N=s(D);if(!N)return String(G);const Z=u(D,N);if(Z)return k(G,N,Z,D);const Q=typeof D.significantFigures=="number"&&D.significantFigures>0?D.significantFigures:0,ee=Q?q(G,Q):G,re=K(ee,N,D.display),ie=n(ee,N.base,re);let ce=typeof D.decimals=="number"?D.decimals:D.minDecimals??0,ve=typeof D.decimals=="number"?D.decimals:D.maxDecimals??Math.max(ce,2);Q&&(ce=X(ie,Q),ve=ce);const he=M(D.locale,ce,ve,D.group!==!1).format(ie),ye=D.space??" ";return D.placement==="prefix"?`${re.symbol}${D.space??""}${he}`:`${he}${ye}${re.symbol}`}function C(F,$){const D=A(F)||Number.isNaN(F)?null:Number(F),z=A($)||Number.isNaN($)?null:Number($);return D===null||Number.isNaN(D)?z===null||Number.isNaN(z)?0:1:z===null||Number.isNaN(z)||D<z?-1:D>z?1:0}function x(F){const $=typeof F.decimals=="number"&&F.decimals>0?`.${"0".repeat(F.decimals)}`:"";return`${typeof F.decimals=="number"?`#,##0${$}`:"#,##0.##"}" ${F.symbol}"`}function j(F){const $={system:"data",...F||{}},D=s($),z=D?D.base.symbol:String($.unit||""),G=Object.freeze({...$,unit:z}),N=Object.freeze({...G,display:z,decimals:void 0,minDecimals:0,maxDecimals:20,group:!1}),Z=new Map([[G.locale||"",G]]),Q=ee=>{const re=ee||"";let ie=Z.get(re);return ie||(ie=Object.freeze({...G,locale:ee||void 0}),Z.set(re,ie)),ie};return{base:"number",extends:"number",storage:"float64",unitConfig:G,format:ee=>E(ee.value,ee.locale?Q(ee.locale):G),parse:ee=>w(ee.text,ee.locale?Q(ee.locale):G),compare:C,defaults:{filter:"number",editor:"unit",align:"end",total:$.total||"sum"},...$.totals?{totals:$.totals}:{},excel:$.excel||x({decimals:$.decimals,symbol:z}),toStorage:ee=>typeof ee=="number"?Number.isFinite(ee)?ee:null:typeof ee=="string"?w(ee,G):A(ee)?null:w(String(ee),G),toClipboard:ee=>E(ee,N),fromClipboard:ee=>w(ee,G)}}const T=j}),ze("packages/core/src/columns/types/engineering.js",function(e,B){"use strict";Object.defineProperty(e,"ENGINEERING_TYPES",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"circularMean",{enumerable:!0,get:function(){return I}});const A=B("packages/core/src/internal/predicates.js").isNil,U=B("packages/core/src/columns/types/unit.js").createUnitType;function I(L){const Y=2*Math.PI/L;return _=>{let O=0,v=0,b=0;for(const g of _||[]){if(A(g))continue;const o=Number(g);Number.isFinite(o)&&(O+=Math.cos(o*Y),v+=Math.sin(o*Y),b+=1)}return!b||Math.hypot(O,v)/b<1e-12?null:(Math.atan2(v,O)/Y%L+L)%L}}function J(L){return{supported:["sum","avg","min","max","count","countValues"],implement:{avg:I(L)}}}const H=Object.freeze({metres:U({system:"length",unit:"m",display:"auto",maxDecimals:3}),millimetres:U({system:"length",unit:"mm",maxDecimals:2}),kilometres:U({system:"length",unit:"km",maxDecimals:3}),grams:U({system:"mass",unit:"g",display:"auto",maxDecimals:3}),kilograms:U({system:"mass",unit:"kg",maxDecimals:3}),tonnes:U({system:"mass",unit:"t",maxDecimals:3}),seconds:U({system:"duration",unit:"s",display:"auto",maxDecimals:3}),milliseconds:U({system:"duration",unit:"ms",maxDecimals:3}),hours:U({system:"duration",unit:"h",maxDecimals:2}),speed:U({system:"speed",unit:"m/s",display:"auto",maxDecimals:2}),kph:U({system:"speed",unit:"km/h",maxDecimals:1}),mph:U({system:"speed",unit:"mph",maxDecimals:1}),knots:U({system:"speed",unit:"kn",maxDecimals:1}),acceleration:U({system:"acceleration",unit:"m/s²",maxDecimals:3}),area:U({system:"area",unit:"m²",display:"auto",maxDecimals:2}),hectares:U({system:"area",unit:"ha",maxDecimals:4}),volume:U({system:"volume",unit:"L",display:"auto",maxDecimals:3}),cubicMetres:U({system:"volume",unit:"m³",maxDecimals:3}),energy:U({system:"energy",unit:"J",display:"auto",maxDecimals:3}),kilowattHours:U({system:"energy",unit:"kWh",maxDecimals:2}),power:U({system:"power",unit:"W",display:"auto",maxDecimals:2}),kilowatts:U({system:"power",unit:"kW",maxDecimals:2}),force:U({system:"force",unit:"N",display:"auto",maxDecimals:2}),pressure:U({system:"pressure",unit:"Pa",display:"auto",maxDecimals:2}),bar:U({system:"pressure",unit:"bar",maxDecimals:3}),psi:U({system:"pressure",unit:"psi",maxDecimals:1}),torque:U({system:"torque",unit:"N·m",maxDecimals:2}),density:U({system:"density",unit:"kg/m³",maxDecimals:2}),flow:U({system:"flow",unit:"m³/s",maxDecimals:4}),litresPerMinute:U({system:"flow",unit:"L/min",maxDecimals:1}),radians:U({system:"angle",unit:"rad",maxDecimals:4,totals:J(2*Math.PI)}),degrees:U({system:"angle",unit:"°",maxDecimals:2,totals:J(360)}),rpm:U({system:"angularVelocity",unit:"rpm",maxDecimals:0}),angularVelocity:U({system:"angularVelocity",unit:"rad/s",maxDecimals:3}),ppm:U({system:"fraction",unit:"ppm",maxDecimals:2}),ppb:U({system:"fraction",unit:"ppb",maxDecimals:2}),basisPoints:U({system:"fraction",unit:"bp",maxDecimals:1}),molarity:U({system:"molarity",unit:"M",display:"auto",maxDecimals:3}),massFlow:U({system:"massFlow",unit:"kg/s",maxDecimals:3}),tonnesPerHour:U({system:"massFlow",unit:"t/h",maxDecimals:2}),viscosity:U({system:"viscosity",unit:"Pa·s",display:"auto",maxDecimals:3}),kinematicViscosity:U({system:"kinematicViscosity",unit:"cSt",maxDecimals:2}),thermalConductivity:U({system:"thermalConductivity",unit:"W/(m·K)",maxDecimals:3}),specificHeat:U({system:"specificHeat",unit:"J/(kg·K)",maxDecimals:1}),doseRate:U({system:"doseRate",unit:"µSv/h",display:"auto",maxDecimals:2})})}),ze("packages/core/src/columns/types/si.js",function(e,B){"use strict";Object.defineProperty(e,"SI_PREFIXES",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"siUnits",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"createSiSystem",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"createSiType",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"SI_TYPES",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return O}});const ne=B("packages/core/src/columns/types/unit.js"),A=ne.defineUnit,V=ne.registerUnitSystem,U=ne.createUnitType,I=Object.freeze([Object.freeze({symbol:"f",name:"femto",factor:1e-15}),Object.freeze({symbol:"p",name:"pico",factor:1e-12}),Object.freeze({symbol:"n",name:"nano",factor:1e-9}),Object.freeze({symbol:"µ",name:"micro",factor:1e-6}),Object.freeze({symbol:"m",name:"milli",factor:.001}),Object.freeze({symbol:"c",name:"centi",factor:.01}),Object.freeze({symbol:"",name:"",factor:1}),Object.freeze({symbol:"k",name:"kilo",factor:1e3}),Object.freeze({symbol:"M",name:"mega",factor:1e6}),Object.freeze({symbol:"G",name:"giga",factor:1e9}),Object.freeze({symbol:"T",name:"tera",factor:1e12}),Object.freeze({symbol:"P",name:"peta",factor:1e15})]),J=Object.freeze(["p","n","µ","m","","k","M","G"]);function H(v){const b=String(v.base),c=new Set([...v.prefixes||J,""]),g=[];for(const o of I){if(!c.has(o.symbol))continue;const t=`${o.symbol}${b}`,s=[];if(v.name){s.push(`${o.name}${v.name}`,`${o.name}${v.name}s`);const l=o.name.slice(-1);if(l&&v.name.startsWith(l)){const u=`${o.name.slice(0,-1)}${v.name}`;s.push(u,`${u}s`)}}o.symbol==="µ"&&s.push(`u${b}`),o.factor===1&&v.aliases&&s.push(...v.aliases),g.push(A(t,o.factor,s))}for(const o of v.extra||[])g.push(o);return g}function L(v,b){const c=H(b);return V(v,c)}function Y(v,b,c){return L(v,b),U({system:v,unit:b.base,display:"auto",maxDecimals:3,...c||{}})}const _=Object.freeze({voltage:Y("voltage",{base:"V",name:"volt"}),current:Y("current",{base:"A",name:"amp",aliases:["ampere","amperes"]}),resistance:Y("resistance",{base:"Ω",name:"ohm",aliases:["ohm","ohms","R"],prefixes:["m","","k","M","G"]}),capacitance:Y("capacitance",{base:"F",name:"farad",prefixes:["f","p","n","µ","m",""]}),inductance:Y("inductance",{base:"H",name:"henry",prefixes:["p","n","µ","m",""]}),charge:Y("charge",{base:"C",name:"coulomb",prefixes:["p","n","µ","m",""],extra:[A("mAh",3.6,["milliamphour","milliamphours"],{auto:!1}),A("Ah",3600,["amphour","amphours"],{auto:!1})]}),conductance:Y("conductance",{base:"S",name:"siemens",prefixes:["n","µ","m","","k"]}),fluxDensity:Y("fluxDensity",{base:"T",name:"tesla",prefixes:["n","µ","m",""],extra:[A("G",1e-4,["gauss"],{auto:!1})]}),luminousFlux:Y("luminousFlux",{base:"lm",name:"lumen",prefixes:["m","","k"]}),illuminance:Y("illuminance",{base:"lx",name:"lux",prefixes:["m","","k"]}),luminousIntensity:Y("luminousIntensity",{base:"cd",name:"candela",prefixes:["m","","k"]}),substance:Y("substance",{base:"mol",name:"mole",prefixes:["n","µ","m","","k"]}),absorbedDose:Y("absorbedDose",{base:"Gy",name:"gray",prefixes:["µ","m",""]}),equivalentDose:Y("equivalentDose",{base:"Sv",name:"sievert",prefixes:["n","µ","m",""]}),radioactivity:Y("radioactivity",{base:"Bq",name:"becquerel",prefixes:["","k","M","G","T"],extra:[A("Ci",37e9,["curie","curies"],{auto:!1})]}),frequency:Y("frequency",{base:"Hz",name:"hertz",prefixes:["m","","k","M","G","T"]})}),O=Y}),ze("packages/core/src/columns/types/temperature.js",function(e,B){"use strict";Object.defineProperty(e,"TEMPERATURE_SCALES",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"findScale",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"convertTemperature",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"formatTemperature",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"parseTemperature",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"createTemperatureType",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"TEMPERATURE_TYPES",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});const A=B("packages/core/src/internal/predicates.js").isNil,V=Object.freeze({C:Object.freeze({symbol:"°C",aliases:["c","°c","celsius","centigrade"],toKelvin:g=>g+273.15,fromKelvin:g=>g-273.15}),F:Object.freeze({symbol:"°F",aliases:["f","°f","fahrenheit"],toKelvin:g=>(g+459.67)*(5/9),fromKelvin:g=>g*(9/5)-459.67}),K:Object.freeze({symbol:"K",aliases:["k","kelvin"],toKelvin:g=>g,fromKelvin:g=>g}),R:Object.freeze({symbol:"°R",aliases:["r","°r","rankine"],toKelvin:g=>g*(5/9),fromKelvin:g=>g*(9/5)})});function U(g){if(A(g))return null;const o=String(g).trim();if(o==="")return null;for(const[s,l]of Object.entries(V))if(o===s||o===l.symbol)return{key:s,scale:l};const t=o.toLowerCase();for(const[s,l]of Object.entries(V))if(l.aliases.includes(t))return{key:s,scale:l};return null}function I(g,o,t){const s=U(o),l=U(t);return!s||!l||!Number.isFinite(Number(g))?null:s.key===l.key?Number(g):l.scale.fromKelvin(s.scale.toKelvin(Number(g)))}const J=new Map;function H(g,o,t){const s=`${g||""}|${o}|${t}`;let l=J.get(s);return l||(l=new Intl.NumberFormat(g||void 0,{minimumFractionDigits:o,maximumFractionDigits:t}),J.set(s,l)),l}function L(g,o){const t=o||{},s=t.nullDisplay??"";if(A(g)||g==="")return s;const l=Number(g);if(!Number.isFinite(l))return s;const u=U(t.scale||"C");if(!u)return String(l);const n=U(t.display||t.scale||"C")||u,p=n.key===u.key?l:n.scale.fromKelvin(u.scale.toKelvin(l)),r=typeof t.decimals=="number"?t.decimals:null,i=r??t.minDecimals??0,d=r??t.maxDecimals??1;return`${H(t.locale,i,d).format(p)}${t.space??" "}${n.scale.symbol}`}const Y=/^[+-]?[\d\s., ]*\d/;function _(g,o){const t=String(g).trim();if(t==="")return null;const s=new Intl.NumberFormat(o||void 0).formatToParts(1.1).find(p=>p.type==="decimal")?.value||".",l=s===","?".":",",u=t.split(l).join("").split(/[\s ]/).join("").replace(s,"."),n=Number(u);return Number.isFinite(n)?n:null}function O(g,o){if(A(g))return null;const t=o||{},s=U(t.scale||"C");if(!s)return null;if(typeof g=="number")return Number.isFinite(g)?g:null;let l=String(g).trim();if(l==="")return null;let u=!1;l.startsWith("(")&&l.endsWith(")")&&(u=!0,l=l.slice(1,-1).trim());const n=Y.exec(l);if(!n)return null;const p=_(n[0],t.locale);if(p===null)return null;const r=l.slice(n[0].length).trim();if(r==="")return u?-p:p;const i=U(r);if(!i)return null;const d=i.key===s.key?p:s.scale.fromKelvin(i.scale.toKelvin(p));return u?-d:d}function v(g){const o=Object.freeze({scale:"C",...g||{}}),s=(U(o.scale)||U("C")).scale.symbol,l=Object.freeze({...o,display:o.scale,decimals:void 0,minDecimals:0,maxDecimals:20}),u=new Map([[o.locale||"",o]]),n=p=>{const r=p||"";let i=u.get(r);return i||(i=Object.freeze({...o,locale:p||void 0}),u.set(r,i)),i};return{base:"number",extends:"number",storage:"float64",temperatureConfig:o,format:p=>L(p.value,p.locale?n(p.locale):o),parse:p=>O(p.text,p.locale?n(p.locale):o),defaults:{filter:"number",editor:"temperature",align:"end",total:"avg"},totals:{supported:["avg","min","max","count","countValues"]},excel:o.excel||`#,##0${typeof o.decimals=="number"&&o.decimals>0?`.${"0".repeat(o.decimals)}`:".#"}" ${s}"`,toStorage:p=>typeof p=="number"?Number.isFinite(p)?p:null:typeof p=="string"?O(p,o):A(p)?null:O(String(p),o),toClipboard:p=>L(p,l),fromClipboard:p=>O(p,o)}}const b=Object.freeze({celsius:v({scale:"C"}),fahrenheit:v({scale:"F"}),kelvin:v({scale:"K"})}),c=v}),ze("packages/core/src/columns/types/radix.js",function(e,B){"use strict";Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"digitsForWidth",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"radixRange",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"radixName",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"normaliseRadixOptions",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"compileRadixFormat",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"compileRadixParse",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"parseRadixResult",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return k}});const A=B("packages/core/src/internal/predicates.js").isNil,U=B("packages/core/src/internal/warn.js").warnOnce,I=Object.freeze({2:2,8:8,16:16,bin:2,binary:2,base2:2,oct:8,octal:8,base8:8,hex:16,hexadecimal:16,base16:16}),J=Object.freeze({2:1,8:3,16:4}),H=Object.freeze({2:"0b",8:"0o",16:"0x"}),L=Object.freeze({2:4,8:3,16:2}),Y=Object.freeze({2:/^[01]+$/,8:/^[0-7]+$/,16:/^[0-9a-f]+$/i}),_=Object.freeze({2:"binary",8:"octal",16:"hexadecimal"}),O=Object.freeze([[/^0x/i,16],[/^0b/i,2],[/^0o/i,8],[/^#/,16]]),v=/[\s\u00a0\u202f_,']/g,b=/^\d+(?:\.\d+)?(?:e[+-]?\d+)?$/i,c=Object.freeze([8,16,32,53]),g=new WeakSet,o=new WeakMap,t=new Map,s=new WeakMap,l=new WeakMap,u=Object.freeze({hex:Object.freeze({radix:16}),hex8:Object.freeze({radix:16,bitWidth:8,pad:!0,signed:!1}),hex16:Object.freeze({radix:16,bitWidth:16,pad:!0,signed:!1}),hex32:Object.freeze({radix:16,bitWidth:32,pad:!0,signed:!1}),binary:Object.freeze({radix:2}),binary8:Object.freeze({radix:2,bitWidth:8,pad:!0,signed:!1,group:4}),octal:Object.freeze({radix:8})});function n(E){if(E==null)return 16;const C=typeof E=="string"?E.toLowerCase():E,x=I[C];return x||(U(`radix:base:${String(E)}`,`unsupported radix ${String(E)}; use 2, 8, 16, 'binary', 'octal' or 'hex'. Falling back to hex`),16)}function p(E,C){return Math.ceil(E/J[C])}function r(E,C){if(!E)return C?{min:-Number.MAX_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER}:{min:0,max:Number.MAX_SAFE_INTEGER};if(!C)return{min:0,max:2**E-1};const x=2**(E-1);return{min:-x,max:x-1}}function i(E){return _[E]||"hexadecimal"}function d(E){if(typeof E=="string"){const C=u[E];return C||U(`radix:preset:${E}`,`unknown radix preset "${E}"; known presets are ${Object.keys(u).join(", ")}`),{...C||{}}}if(E&&typeof E.preset=="string"){const C=u[E.preset];return C||U(`radix:preset:${E.preset}`,`unknown radix preset "${E.preset}"; known presets are ${Object.keys(u).join(", ")}`),{...C||{},...E}}return E||{}}function h(E){const C=d(E),x=n(C.radix),j=J[x];let T=null;if(C.bitWidth!==void 0&&C.bitWidth!==null&&C.bitWidth!==!1){const ee=Number(C.bitWidth);c.includes(ee)?T=ee:U(`radix:width:${String(C.bitWidth)}`,`unsupported bitWidth ${String(C.bitWidth)}; use 8, 16, 32 or 53. Ignoring it`)}let F=C.signed!==!1;!F&&T===null&&(U("radix:unsigned:width","signed: false needs a bitWidth to render a two's-complement pattern; defaulting to 32"),T=32);const $=C.prefix===void 0||C.prefix===!0?H[x]:C.prefix===!1?"":String(C.prefix);let D=0;C.pad===!0?D=T?p(T,x):0:typeof C.pad=="number"&&C.pad>0&&(D=Math.floor(C.pad));let z=0;C.group===!0?z=L[x]:typeof C.group=="number"&&C.group>0&&(z=Math.floor(C.group));const G=r(T,F),N=typeof C.min=="number"?Math.max(G.min,C.min):G.min,Z=typeof C.max=="number"?Math.min(G.max,C.max):G.max,Q=Object.freeze({radix:x,bits:j,prefix:$,uppercase:C.uppercase!==!1,pad:D,group:z,groupSeparator:typeof C.groupSeparator=="string"?C.groupSeparator:" ",bitWidth:T,signed:F,min:N,max:Z<N?N:Z,nullDisplay:typeof C.nullDisplay=="string"?C.nullDisplay:"",name:i(x)});return g.add(Q),Q}function a(E){if(E&&g.has(E))return E;if(typeof E=="string"){let C=t.get(E);return C||(C=h(E),t.set(E,C)),C}if(E&&typeof E=="object"){let C=o.get(E);return C||(C=h(E),o.set(E,C)),C}return a("hex")}function y(E){return E<0?-Math.round(-E):Math.round(E)}function f(E,C,x){if(C<=0||E.length<=C)return E;const j=E.length%C||C,T=[E.slice(0,j)];for(let F=j;F<E.length;F+=C)T.push(E.slice(F,F+C));return T.join(x)}function m(E){const C=a(E),{radix:x,prefix:j,uppercase:T,pad:F,group:$,groupSeparator:D,signed:z,bitWidth:G,nullDisplay:N}=C,Z=G?2**G:0,Q=ee=>{if(A(ee)||ee==="")return N;const re=typeof ee=="number"?ee:Number(ee);if(!Number.isFinite(re))return N;const ie=y(re);let ce="",ve=ie;ie<0&&(z?(ce="-",ve=-ie):ve=(ie%Z+Z)%Z);let he=ve.toString(x);return he=T?he.toUpperCase():he.toLowerCase(),F>0&&he.length<F&&(he=he.padStart(F,"0")),$>0&&(he=f(he,$,D)),ce+j+he};return Q.options=C,Q}function w(E,C){const x=a(C);let j=s.get(x);return j||(j=m(x),s.set(x,j)),j(E)}function S(E){const C=a(E),{radix:x,groupSeparator:j,signed:T,min:F,max:$}=C,D=Y[x],z=G=>{if(A(G))return{ok:!0,value:null,reason:"blank"};let N=String(G);if(j&&j!==""&&(N=N.split(j).join("")),N=N.replace(v,""),N==="")return{ok:!0,value:null,reason:"blank"};let Z=!1;if((N[0]==="-"||N[0]==="+")&&(Z=N[0]==="-",N=N.slice(1)),N==="")return{ok:!1,value:null,reason:"digits"};let Q=null;for(const[re,ie]of O){const ce=re.exec(N);if(!ce)continue;const ve=N.slice(ce[0].length);if(ve==="")break;if(!Y[ie].test(ve))return{ok:!1,value:null,reason:"digits"};Q=parseInt(ve,ie);break}if(Q===null)if(D.test(N))Q=parseInt(N,x);else if(b.test(N))Q=Number(N);else return{ok:!1,value:null,reason:"digits"};if(!Number.isFinite(Q))return{ok:!1,value:null,reason:"digits"};const ee=y(Z?-Q:Q);return!T&&ee<0?{ok:!1,value:ee,reason:"negative"}:ee<F||ee>$?{ok:!1,value:ee,reason:"range"}:{ok:!0,value:ee,reason:"ok"}};return z.options=C,z}function M(E,C){const x=a(C);let j=l.get(x);return j||(j=S(x),l.set(x,j)),j(E)}function X(E,C){const x=M(E,C);return x.ok?x.value:null}function q(E,C){const x=A(E)||Number.isNaN(E)?null:Number(E),j=A(C)||Number.isNaN(C)?null:Number(C);return x===null?j===null?0:1:j===null||x<j?-1:x>j?1:0}function K(E){const C=E.min>=-2147483648&&E.max<=2147483647;return E.bitWidth&&C?"int32":"float64"}function P(E){const C=h(E),x=m(C),j=S(C);return{base:"number",extends:"number",storage:K(C),matches:null,format:T=>x(T.value),parse:T=>{const F=j(T.text);return F.ok?F.value:null},compare:q,defaults:{filter:"number",editor:"radix",total:"sum",align:"end"},excel:"General",toClipboard:T=>x(T),fromClipboard:T=>{const F=j(T);return F.ok?F.value:null},radix:C,formatValue:x,parseText:j}}const k=P}),ze("packages/core/src/columns/types/aggregable.js",function(e,B){"use strict";Object.defineProperty(e,"createLogarithmicType",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"createRatioType",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"AGGREGABLE_TYPES",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"weightedMean",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"logarithmicSum",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"logarithmicMean",{enumerable:!0,get:function(){return I}});const A=B("packages/core/src/internal/predicates.js").isNil;function V(_){const O=[];for(const v of _||[]){if(A(v))continue;const b=Number(v);Number.isFinite(b)&&O.push(b)}return O}function U(_){return O=>{const v=V(O);if(!v.length)return null;let b=0;for(const c of v)b+=10**(c/_);return _*Math.log10(b)}}function I(_){return O=>{const v=V(O);if(!v.length)return null;let b=0;for(const c of v)b+=10**(c/_);return _*Math.log10(b/v.length)}}function J(_,O){const v=O&&O.column,c=(v&&v.typeOptions||{}).weight,g=O&&O.valueAt;if(!c||typeof g!="function")return null;let o=0,t=0;for(let s=0;s<_.length;s++){if(A(_[s]))continue;const l=Number(_[s]);if(!Number.isFinite(l))continue;const u=g(c,s);if(A(u))continue;const n=Number(u);!Number.isFinite(n)||n<=0||(o+=l*n,t+=n)}return t===0?null:o/t}function H(_={}){const O=_.factor===20?20:10,v=typeof _.suffix=="string"?_.suffix:"",b=Number.isInteger(_.decimals)?_.decimals:1;return{base:"number",storage:"float64",name:_.name||"logarithmic",format:c=>{const g=c&&c.value;return A(g)||!Number.isFinite(Number(g))?"":`${Number(g).toFixed(b)}${v}`},parse:c=>{const g=String((c&&c.text)??"").replace(v,"").trim();if(!g)return null;const o=Number(g);return Number.isFinite(o)?o:null},defaults:{align:"end",filter:"number"},totals:{supported:["sum","avg","min","max","count","countValues"],implement:{sum:U(O),avg:I(O)}}}}function L(_={}){const O=Number.isInteger(_.decimals)?_.decimals:1,v=_.percent===!0;return{base:"number",storage:"float64",name:_.name||"ratio",format:b=>{const c=b&&b.value;return A(c)||!Number.isFinite(Number(c))?"":v?`${Number(c).toFixed(O)}%`:Number(c).toFixed(O)},parse:b=>{const c=String((b&&b.text)??"").replace("%","").trim();if(!c)return null;const g=Number(c);return Number.isFinite(g)?g:null},defaults:{align:"end",filter:"number"},totals:{supported:["avg","min","max","count","countValues"],implement:{avg:J}}}}const Y=Object.freeze({decibel:H({name:"decibel",factor:10,suffix:" dB"}),decibelAmplitude:H({name:"decibelAmplitude",factor:20,suffix:" dB"}),ratio:L({name:"ratio"}),percentRate:L({name:"percentRate",percent:!0})})}),ze("packages/core/src/columns/types/currency.js",function(e,B){"use strict";Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"normaliseCode",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"toMoney",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"moneyToText",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"moneyComparator",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"CURRENCY_TYPES",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return n}});const A=B("packages/core/src/internal/predicates.js").isNil,V="⚠ no rate";function U(p){if(A(p))return null;const r=String(p).trim().toUpperCase();return r===""?null:r}function I(p){if(A(p))return null;if(typeof p=="object"&&!Array.isArray(p)){const r=Number(p.amount),i=U(p.code);return!i||!Number.isFinite(r)?null:{amount:r,code:i}}if(Array.isArray(p)&&p.length===2){const r=Number(p[0]),i=U(p[1]);return!i||!Number.isFinite(r)?null:{amount:r,code:i}}return null}const J=Object.freeze({$:"USD","€":"EUR","£":"GBP","¥":"JPY","₹":"INR","₩":"KRW","₽":"RUB","₺":"TRY","₴":"UAH","₪":"ILS"}),H=Object.freeze({USD:"$",EUR:"€",GBP:"£",JPY:"¥",INR:"₹",KRW:"₩",RUB:"₽",TRY:"₺",UAH:"₴",ILS:"₪"}),L=/[+-]?[\d\s., ]*\d/;function Y(p,r){const i=String(p).trim();if(i==="")return null;const d=new Intl.NumberFormat(r||void 0).formatToParts(1.1).find(f=>f.type==="decimal")?.value||".",h=d===","?".":",",a=i.split(h).join("").split(/[\s ]/).join("").replace(d,"."),y=Number(a);return Number.isFinite(y)?y:null}function _(p,r){const i=r||{},d=U(i.code);if(A(p))return null;const h=I(p);if(h)return h;if(typeof p=="number")return Number.isFinite(p)&&d?{amount:p,code:d}:null;let a=String(p).trim();if(a==="")return null;let y=!1;a.startsWith("(")&&a.endsWith(")")&&(y=!0,a=a.slice(1,-1).trim());let f=null;for(const[q,K]of Object.entries(J)){if(a.startsWith(q)){f=K,a=a.slice(q.length).trim();break}if(a.endsWith(q)){f=K,a=a.slice(0,-q.length).trim();break}}const m=L.exec(a);if(!m)return null;const w=Y(m[0],i.locale);if(w===null)return null;const S=(a.slice(0,m.index)+" "+a.slice(m.index+m[0].length)).trim();!f&&S!==""&&(f=U(S));const M=f||d;return M?{amount:y?-w:w,code:M}:null}function O(p,r){if(typeof p=="function")return(i,d)=>{if(i===d)return 1;const h=p(i,d);return typeof h=="number"&&Number.isFinite(h)&&h>0?h:null};if(p&&typeof p=="object"){const i=p;return(d,h)=>{if(d===h)return 1;const a=Number(i[d]),y=Number(i[h]);return!Number.isFinite(a)||!Number.isFinite(y)||a<=0||y<=0?null:y/a}}return(i,d)=>i===d?1:null}function v(p,r,i){if(!p)return null;if(p.code===r)return p.amount;const d=i(p.code,r);return d===null?null:p.amount*d}const b=new Map;function c(p,r,i){const d=`${p||""}|${r}|${i??""}`;let h=b.get(d);if(!h){const a={style:"currency",currency:r};typeof i=="number"&&(a.minimumFractionDigits=i,a.maximumFractionDigits=i);try{h={fmt:new Intl.NumberFormat(p||void 0,a),currency:!0}}catch{h={fmt:new Intl.NumberFormat(p||void 0,typeof i=="number"?{minimumFractionDigits:i,maximumFractionDigits:i}:{}),currency:!1}}b.set(d,h)}return h}function g(p,r){const i=r||{},d=i.nullDisplay??"",h=I(p);if(!h)return d;const a=U(i.display)||h.code;let y=h.amount,f=h.code;if(a!==h.code){const S=i.rateFn||O(i.rates,i.rateBase),M=v(h,a,S);if(M===null)return`${i.missingRate??V} ${h.code}→${a}`;y=M,f=a}const{fmt:m,currency:w}=c(i.locale,f,i.decimals);return w?m.format(y):`${m.format(y)} ${f}`}function o(p){const r=I(p);return r?`${r.amount} ${r.code}`:""}function t(p){const r=p||{},i=U(r.display),d=r.rateFn||O(r.rates,r.rateBase);return(h,a)=>{const y=I(h),f=I(a);if(!y&&!f)return 0;if(!y)return 1;if(!f)return-1;if(i){const m=v(y,i,d),w=v(f,i,d);if(m!==null&&w!==null)return m===w?0:m<w?-1:1}return y.code===f.code?y.amount===f.amount?0:y.amount<f.amount?-1:1:y.code<f.code?-1:1}}function s(p){const r=p||{},i=(h,a)=>{const y=[];for(const M of h||[]){const X=I(M);X&&y.push(X)}if(!y.length)return null;if(new Set(y.map(M=>M.code)).size===1){const M=y[0].code;return{amount:a(y.map(X=>X.amount)),code:M}}const m=U(r.display);if(!m)return`${r.missingRate??V}: mixed currencies, no display currency set`;const w=r.rateFn||O(r.rates,r.rateBase),S=[];for(const M of y){const X=v(M,m,w);if(X===null)return`${r.missingRate??V}: ${M.code}→${m}`;S.push(X)}return{amount:a(S),code:m}},d=h=>h.reduce((a,y)=>a+y,0);return{sum:h=>i(h,d),avg:h=>i(h,a=>d(a)/a.length),min:h=>i(h,a=>Math.min(...a)),max:h=>i(h,a=>Math.max(...a))}}function l(p){const r=Object.freeze({code:"USD",...p||{}}),i=O(r.rates,r.rateBase),d=Object.freeze({...r,rateFn:i}),h=s(d),a=t(d),y=new Map([[r.locale||"",d]]),f=S=>{const M=S||"";let X=y.get(M);return X||(X=Object.freeze({...d,locale:S||void 0}),y.set(M,X)),X},m=H[U(r.display||r.code)]||"",w=typeof r.decimals=="number"&&r.decimals>0?`.${"0".repeat(r.decimals)}`:".00";return{base:"object",extends:"object",storage:"object",name:"currency",currencyConfig:d,format:S=>g(S.value,S.locale?f(S.locale):d),parse:S=>_(S.text,S.locale?f(S.locale):d),compare:a,defaults:{filter:"number",editor:"currency",align:"end",total:"sum"},totals:{supported:["sum","avg","min","max","count","countValues"],implement:h},excel:r.excel||(m?`"${m}"#,##0${w}`:`#,##0${w}`),toStorage:S=>{const M=I(S);return M||(typeof S=="string"||typeof S=="number"?_(S,d):null)},toClipboard:S=>o(S),fromClipboard:S=>_(S,d)}}const u=Object.freeze({currency:l({code:"USD"}),usd:l({code:"USD"}),eur:l({code:"EUR"}),gbp:l({code:"GBP"}),jpy:l({code:"JPY",decimals:0})}),n=l}),ze("packages/core/src/columns/types/index.js",function(e,B){"use strict";Object.defineProperty(e,"EXTENDED_TYPES",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"unitSystemNames",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"unitsOf",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"SI_TYPES",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"createSiType",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"createSiSystem",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"siUnits",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"SI_PREFIXES",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return q}});const ne=B("packages/core/src/columns/types/temporal.js"),A=ne.TEMPORAL_TYPES,V=B("packages/core/src/columns/types/network.js"),U=V.NETWORK_TYPES,I=B("packages/core/src/columns/types/structured.js"),J=I.STRUCTURED_TYPES,H=B("packages/core/src/columns/types/unit.js"),L=H.createUnitType,Y=H.UNIT_SYSTEMS,_=H.parseUnit,O=H.formatUnit,v=H.registerUnitSystem,b=H.unitSystemNames,c=H.unitsOf,g=H.defineUnit,o=B("packages/core/src/columns/types/engineering.js"),t=o.ENGINEERING_TYPES,s=B("packages/core/src/columns/types/si.js"),l=s.SI_TYPES,u=s.createSiType,n=s.createSiSystem,p=s.siUnits,r=s.SI_PREFIXES,i=B("packages/core/src/columns/types/temperature.js"),d=i.TEMPERATURE_TYPES,h=i.createTemperatureType,a=i.convertTemperature,y=i.formatTemperature,f=i.parseTemperature,m=i.TEMPERATURE_SCALES,w=B("packages/core/src/columns/types/radix.js"),S=w.createRadixType,M=w.RADIX_PRESETS,X=w.parseRadix,q=w.formatRadix,K=B("packages/core/src/columns/types/aggregable.js"),P=K.AGGREGABLE_TYPES,k=B("packages/core/src/columns/types/currency.js"),E=k.CURRENCY_TYPES,C=k.createCurrencyType,x=k.parseMoney,j=k.formatMoney,T=k.convertMoney,F=k.toMoney,$=k.rateFunction,D=k.moneyComparator,z=k.normaliseCode,G=k.MISSING_RATE;Object.defineProperty(e,"findUnit",{enumerable:!0,get:function(){return H.findUnit}}),Object.defineProperty(e,"ENGINEERING_TYPES",{enumerable:!0,get:function(){return o.ENGINEERING_TYPES}}),Object.defineProperty(e,"circularMean",{enumerable:!0,get:function(){return o.circularMean}}),Object.defineProperty(e,"TEMPERATURE_TYPES",{enumerable:!0,get:function(){return i.TEMPERATURE_TYPES}}),Object.defineProperty(e,"createTemperatureType",{enumerable:!0,get:function(){return i.createTemperatureType}}),Object.defineProperty(e,"convertTemperature",{enumerable:!0,get:function(){return i.convertTemperature}}),Object.defineProperty(e,"formatTemperature",{enumerable:!0,get:function(){return i.formatTemperature}}),Object.defineProperty(e,"parseTemperature",{enumerable:!0,get:function(){return i.parseTemperature}}),Object.defineProperty(e,"TEMPERATURE_SCALES",{enumerable:!0,get:function(){return i.TEMPERATURE_SCALES}}),Object.defineProperty(e,"findScale",{enumerable:!0,get:function(){return i.findScale}}),Object.defineProperty(e,"CURRENCY_TYPES",{enumerable:!0,get:function(){return k.CURRENCY_TYPES}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return k.createCurrencyType}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return k.parseMoney}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return k.formatMoney}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return k.convertMoney}}),Object.defineProperty(e,"toMoney",{enumerable:!0,get:function(){return k.toMoney}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return k.rateFunction}}),Object.defineProperty(e,"moneyComparator",{enumerable:!0,get:function(){return k.moneyComparator}}),Object.defineProperty(e,"normaliseCode",{enumerable:!0,get:function(){return k.normaliseCode}}),Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return k.MISSING_RATE}}),Object.defineProperty(e,"TEMPORAL_TYPES",{enumerable:!0,get:function(){return ne.TEMPORAL_TYPES}}),Object.defineProperty(e,"NETWORK_TYPES",{enumerable:!0,get:function(){return V.NETWORK_TYPES}}),Object.defineProperty(e,"STRUCTURED_TYPES",{enumerable:!0,get:function(){return I.STRUCTURED_TYPES}}),Object.defineProperty(e,"AGGREGABLE_TYPES",{enumerable:!0,get:function(){return K.AGGREGABLE_TYPES}}),Object.defineProperty(e,"createLogarithmicType",{enumerable:!0,get:function(){return K.createLogarithmicType}}),Object.defineProperty(e,"createRatioType",{enumerable:!0,get:function(){return K.createRatioType}}),Object.defineProperty(e,"parseTime",{enumerable:!0,get:function(){return ne.parseTime}}),Object.defineProperty(e,"formatTime",{enumerable:!0,get:function(){return ne.formatTime}}),Object.defineProperty(e,"parseDateTime",{enumerable:!0,get:function(){return ne.parseDateTime}}),Object.defineProperty(e,"formatDateTime",{enumerable:!0,get:function(){return ne.formatDateTime}}),Object.defineProperty(e,"parseDuration",{enumerable:!0,get:function(){return ne.parseDuration}}),Object.defineProperty(e,"formatDuration",{enumerable:!0,get:function(){return ne.formatDuration}}),Object.defineProperty(e,"parseIpv4",{enumerable:!0,get:function(){return V.parseIpv4}}),Object.defineProperty(e,"formatIpv4",{enumerable:!0,get:function(){return V.formatIpv4}}),Object.defineProperty(e,"parseCidr",{enumerable:!0,get:function(){return V.parseCidr}}),Object.defineProperty(e,"formatCidr",{enumerable:!0,get:function(){return V.formatCidr}}),Object.defineProperty(e,"parseIpv6",{enumerable:!0,get:function(){return V.parseIpv6}}),Object.defineProperty(e,"formatIpv6",{enumerable:!0,get:function(){return V.formatIpv6}}),Object.defineProperty(e,"networkAddress",{enumerable:!0,get:function(){return V.networkAddress}}),Object.defineProperty(e,"broadcastAddress",{enumerable:!0,get:function(){return V.broadcastAddress}}),Object.defineProperty(e,"hostCount",{enumerable:!0,get:function(){return V.hostCount}}),Object.defineProperty(e,"containsAddress",{enumerable:!0,get:function(){return V.containsAddress}}),Object.defineProperty(e,"overlaps",{enumerable:!0,get:function(){return V.overlaps}}),Object.defineProperty(e,"maskValue",{enumerable:!0,get:function(){return I.maskValue}}),Object.defineProperty(e,"summariseJson",{enumerable:!0,get:function(){return I.summariseJson}});const N=Object.freeze({...A,...U,...J,...P,hex:S(M.hex),hex8:S(M.hex8),hex16:S(M.hex16),hex32:S(M.hex32),binary:S(M.binary),binary8:S(M.binary8),octal:S(M.octal),bytes:L({system:"data",unit:"B",display:"auto"}),megabytes:L({system:"data",unit:"MB"}),gigabytes:L({system:"data",unit:"GB"}),bitrate:L({system:"bitrate",unit:"Mbps"}),gigabits:L({system:"bitrate",unit:"Gbps"}),...t,...l,...d,...E});{const Z=new Set;for(const Q of[A,U,J,P,t,l,d,E])for(const ee of Object.keys(Q)){if(Z.has(ee))throw new Error(`[lattice] data type "${ee}" is declared twice`);Z.add(ee)}}}),ze("packages/core/src/compute/handle.js",function(e,B){"use strict";Object.defineProperty(e,"identity",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"rowCount",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"bitReader",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"presenceReader",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"dictSize",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"dictValue",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"multiValue",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"valueReader",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"numericTotalOrder",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"valueComparator",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"dictRanks",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"isMissing",{enumerable:!0,get:function(){return l}});const ne=B("packages/core/src/internal/compare.js"),A=ne.collator,V=ne.defaultCompare,I=B("packages/core/src/internal/warn.js").warnOnce;function J(u){const n=new Uint32Array(u);for(let p=0;p<u;p++)n[p]=p;return n}function H(u,n){if(n&&typeof n.count=="number")return n.count;if(!u)return 0;if(typeof u.count=="number")return u.count;if(typeof u.length=="number")return u.length;const p=u.values;return u.kind==="multi"&&u.offsets?Math.max(0,u.offsets.length-1):p?u.kind==="bitset"?typeof p.size=="number"?p.size:u.presence&&typeof u.presence.size=="number"?u.presence.size:(I(`count:${u.id}`,`column "${u.id}" is bitset-backed with no declared row count; assuming ${p.length*8}`),p.length*8):p.length:u.presence&&typeof u.presence.size=="number"?u.presence.size:0}const L=new WeakMap;function Y(u){const n=u.constructor;if(!n)return"unknown";const p=L.get(n);if(p)return p;let r="unknown";try{let i=null;typeof n.from=="function"?i=n.from([!1,!0]):(i=new n(8),i.set(1));const d=i&&i.words;d&&d.length&&(d[0]===2?r="lsb":d[0]===64&&(r="msb"))}catch{r="unknown"}return L.set(n,r),r}function _(u){if(!u)return()=>0;const n=u instanceof Uint8Array?u:u.words;if(n instanceof Uint8Array){const p=u instanceof Uint8Array?"lsb":Y(u);if(p==="lsb")return r=>n[r>>>3]>>>(r&7)&1;if(p==="msb")return r=>n[r>>>3]>>>7-(r&7)&1}return typeof u.get=="function"?p=>u.get(p)?1:0:()=>0}function O(u){return!u||!u.presence?null:_(u.presence)}function v(u){return u?typeof u.size=="number"?u.size:typeof u.values=="function"?u.values().length:0:0}function b(u,n){return u?typeof u.valueOf=="function"?u.valueOf(n):typeof u.values=="function"?u.values()[n]:null:null}function c(u,n){const p=u.offsets,r=u.values;if(!p||!r)return[];const i=p[n],d=p[n+1];if(!(d>i))return[];const h=u.dict,a=new Array(d-i);for(let y=i;y<d;y++)a[y-i]=h?b(h,r[y]):r[y];return a}function g(u){if(!u)return()=>{};const n=u.values,p=O(u),r=u.kind;if(r==="dictionary"){const i=u.dict;return p?d=>p(d)?b(i,n[d]):null:d=>b(i,n[d])}if(r==="bitset"){const i=_(n);return p?d=>p(d)?i(d)===1:null:d=>i(d)===1}if(r==="multi")return p?i=>p(i)?c(u,i):null:i=>c(u,i);if(!n&&typeof u.get=="function"){const i=u.get.bind(u);return d=>{const h=i(d);return h===void 0?null:h}}return p?i=>{if(!p(i))return null;const d=n[i];return d===void 0?null:d}:i=>{const d=n[i];return d===void 0?null:d}}function o(u,n){if(u<n)return-1;if(u>n)return 1;if(u===n){const i=Object.is(u,-0),d=Object.is(n,-0);return i===d?0:i?-1:1}const p=Number.isNaN(u),r=Number.isNaN(n);return p&&r?0:p?1:-1}function t(u){const n=A(u);return(p,r)=>{if(p===r)return 0;const i=typeof p,d=typeof r;if(i==="string"&&d==="string")return n.compare(p,r);if(i==="number"&&d==="number")return o(p,r);if(i==="boolean"&&d==="boolean")return p===r?0:p?1:-1;if(p instanceof Date||r instanceof Date){const h=p instanceof Date?p.getTime():Number(p),a=r instanceof Date?r.getTime():Number(r);return o(h,a)}return V(p,r)}}function s(u,n){if(u&&typeof u.ranks=="function")return u.ranks(n);const p=u&&typeof u.values=="function"?u.values():[],r=p.length,i=t(n),d=new Array(r);for(let a=0;a<r;a++)d[a]=a;d.sort((a,y)=>i(p[a],p[y])||a-y);const h=new Uint32Array(r);for(let a=0;a<r;a++)h[d[a]]=a;return h}function l(u){return u==null||typeof u=="number"&&Number.isNaN(u)}}),ze("packages/core/src/compute/filter.js",function(e,B){"use strict";Object.defineProperty(e,"releaseMask",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"compilePredicate",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"wallMs",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"itemwisePredicate",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"evaluateCondition",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"pruneColumn",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"mentionsColumn",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return re}}),Object.defineProperty(e,"declareOperators",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(e,"declaredOperator",{enumerable:!0,get:function(){return ve}});const A=B("packages/core/src/internal/predicates.js").isBlank,U=B("packages/core/src/internal/merge.js").toArray,J=B("packages/core/src/internal/warn.js").warnOnce,H=B("packages/core/src/format/date.js"),L=H.toDate,Y=H.toIsoDate,_=B("packages/core/src/compute/handle.js"),O=_.bitReader,v=_.dictSize,b=_.dictValue,c=_.presenceReader,g=_.valueComparator,o=_.valueReader,t=/^\d{4}-\d{2}-\d{2}$/,s="\0null\0";function l(he,ye){const Oe=he&&he.pool;if(Oe){const Le=Oe.mask||Oe.acquireMask||Oe.acquire||Oe.take;if(typeof Le=="function"){const fe=Le.call(Oe,ye);if(fe&&fe.length>=ye)return fe}}return new Uint8Array(ye)}function u(he,ye){const Oe=he&&he.pool;if(!Oe||!ye)return;const Le=Oe.release||Oe.releaseMask||Oe.free||Oe.recycle;typeof Le=="function"&&Le.call(Oe,ye)}function n(he,ye,Oe){return he.fill(Oe,0,ye),he}function p(he){return he==null||typeof he=="number"&&Number.isNaN(he)}function r(he,ye){if(he==null)return he;if(ye==="number")return typeof he=="number"?he:Number(he);if(ye==="date"||ye==="dateString"){const Oe=Y(he);return Oe===null?i(he):Oe}return ye==="boolean"?typeof he=="boolean"?he:he==="true"||he===1?!0:he==="false"||he===0?!1:!!he:he}function i(he){return he instanceof Date?he.getTime():typeof he=="number"?he:Date.parse(String(he))}function d(he){return typeof he=="number"?he:he instanceof Date?he.getTime():he==null||he===""?NaN:Number(he)}function h(he,ye){const Oe=typeof he=="string"?he:String(he);return ye?Oe:Oe.toLowerCase()}function a(he,ye){return he==null?s:typeof he=="string"?ye?he:he.toLowerCase():he instanceof Date?he.getTime():he}function y(he,ye,Oe){const Le=new Set;for(const fe of U(he)){const ae=r(fe,Oe);Le.add(a(ae,ye)),typeof ae=="string"&&ae!==""&&Number.isFinite(Number(ae))?Le.add(Number(ae)):typeof ae=="number"&&Number.isFinite(ae)&&Le.add(a(String(ae),ye))}return Le}function f(he,ye,Oe){if(he==null||ye===null||ye===void 0)return he==null&&ye==null;const Le=typeof he,fe=typeof ye;return Le==="string"&&fe==="string"?Oe?he===ye:he.toLowerCase()===ye.toLowerCase():he instanceof Date||ye instanceof Date?i(he)===i(ye):Le==="number"&&fe==="number"?he===ye||Number.isNaN(he)&&Number.isNaN(ye):Le==="number"&&fe==="string"?he===Number(ye):Le==="string"&&fe==="number"?Number(he)===ye:Le==="boolean"||fe==="boolean"?he===ye:Array.isArray(he)&&Array.isArray(ye)?he.length===ye.length&&he.every((ae,ke)=>f(ae,ye[ke],Oe)):he===ye}function m(he,ye){try{if(he instanceof RegExp){const Oe=he.flags.replace(/[gy]/g,"");return new RegExp(he.source,ye||Oe.includes("i")?Oe:`${Oe}i`)}return new RegExp(String(he),ye?"":"i")}catch(Oe){return J(`regex:${String(he)}`,`filter operator "matches" received an invalid pattern: ${String(he)}`,Oe),null}}function w(he,ye){if(he&&he.type==="datetime"&&S.has(he.op))return P(he,ye);const Oe=k(he,ye),Le=he&&he.type;return Le!=="date"&&Le!=="dateString"?Oe:fe=>Oe(typeof fe=="string"&&t.test(fe)?fe:Y(fe)??fe)}const S=new Set(["eq","ne","lt","lte","gt","gte","between","notBetween","in","notIn"]),M=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3})\d*)?)?)?$/,X=new Map;function q(he,ye){let Oe=X.get(ye);if(Oe===void 0){try{Oe=new Intl.DateTimeFormat("en-CA",{timeZone:ye,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})}catch{Oe=null}X.set(ye,Oe)}if(!Oe)return null;const Le={};for(const fe of Oe.formatToParts(he))fe.type!=="literal"&&(Le[fe.type]=fe.value);return Le}function K(he,ye){if(he==null||he==="")return null;if(typeof he=="string"){const ae=M.exec(he.trim());if(ae)return Date.UTC(+ae[1],+ae[2]-1,+ae[3],+(ae[4]||0),+(ae[5]||0),+(ae[6]||0),+(ae[7]||"0").padEnd(3,"0"))}const Oe=L(he);if(!Oe)return null;const Le=Oe.getUTCMilliseconds(),fe=ye?q(Oe,ye):null;return fe?Date.UTC(+fe.year,+fe.month-1,+fe.day,fe.hour==="24"?0:+fe.hour,+fe.minute,+fe.second,Le):Date.UTC(Oe.getFullYear(),Oe.getMonth(),Oe.getDate(),Oe.getHours(),Oe.getMinutes(),Oe.getSeconds(),Le)}function P(he,ye){const Oe=typeof he.timeZone=="string"&&he.timeZone?he.timeZone:void 0,Le=ke=>K(ke,Oe),fe=Array.isArray(he.value)?he.value.map(Le):Le(he.value),ae=k({...he,type:"number",value:fe},ye);return ke=>ae(K(ke))}function k(he,ye){const Oe=he&&he.op,Le=!!(he&&he.caseSensitive),fe=he&&he.type,ae=g(ye),ke=pe=>ue=>!pe(ue);switch(Oe){case"eq":{const pe=r(he.value,fe);return ue=>f(ue,pe,Le)}case"ne":{const pe=r(he.value,fe);return ue=>!f(ue,pe,Le)}case"lt":case"lte":case"gt":case"gte":{const pe=r(he.value,fe);if(p(pe))return()=>!1;const ue=Oe==="lt"?-1:Oe==="lte"?0:Oe==="gt"?1:2;return we=>{if(p(we))return!1;const Te=ae(we,pe);return ue===-1?Te<0:ue===0?Te<=0:ue===1?Te>0:Te>=0}}case"between":case"notBetween":{const pe=U(he.value),ue=r(pe[0],fe),we=r(pe[1],fe),Te=he.bounds||"[]",Ne=Te.charAt(0)!=="(",_e=Te.charAt(1)!==")";if(p(ue)||p(we))return Oe==="between"?()=>!1:()=>!0;const $e=je=>{if(p(je))return!1;const Ge=ae(je,ue),Fe=ae(je,we);return(Ne?Ge>=0:Ge>0)&&(_e?Fe<=0:Fe<0)};return Oe==="between"?$e:ke($e)}case"in":case"notIn":{const pe=y(he.value,Le,fe),ue=we=>pe.has(a(we,Le));return Oe==="in"?ue:ke(ue)}case"contains":case"notContains":{const pe=h(r(he.value,fe),Le),ue=we=>we==null?!1:h(we,Le).includes(pe);return Oe==="contains"?ue:ke(ue)}case"startsWith":{const pe=h(r(he.value,fe),Le);return ue=>ue==null?!1:h(ue,Le).startsWith(pe)}case"endsWith":{const pe=h(r(he.value,fe),Le);return ue=>ue==null?!1:h(ue,Le).endsWith(pe)}case"matches":{const pe=m(he.value,Le);return pe?ue=>ue==null?!1:pe.test(String(ue)):()=>!1}case"blank":case"notBlank":{const pe=he.trim===!0,ue=we=>A(we)||Array.isArray(we)&&we.length===0||pe&&typeof we=="string"&&we.trim()==="";return Oe==="blank"?ue:we=>!ue(we)}case"containsAny":case"containsNone":{const pe=y(he.value,Le,fe),ue=we=>{const Te=we==null?[]:U(we);for(let Ne=0;Ne<Te.length;Ne++)if(pe.has(a(Te[Ne],Le)))return!0;return!1};return Oe==="containsAny"?ue:ke(ue)}case"containsAll":{const pe=U(he.value).map(ue=>a(r(ue,fe),Le));return ue=>{const we=ue==null?[]:U(ue);if(pe.length===0)return!0;const Te=new Set(we.map(Ne=>a(Ne,Le)));for(let Ne=0;Ne<pe.length;Ne++)if(!Te.has(pe[Ne]))return!1;return!0}}default:{const pe=ve(Oe);return pe?pe.compile(he.value):(J(`op:${String(Oe)}`,`unknown filter operator "${String(Oe)}"; the condition is refused rather than matching every row`),()=>!1)}}}function E(he,ye,Oe){return w(ye,Oe)(he)}const C=Object.freeze({ne:"eq",notIn:"in",notBetween:"between",notContains:"contains"}),x=new Set(["containsAny","containsAll","containsNone"]);function j(he,ye,Oe){const Le=he&&he.op,fe=C[Le]||Le,ae=w({...he,op:fe,type:ye.type},Oe),ke=ye.items,pe=ue=>{const we=ke(ue);if(!we)return!1;for(let Te=0;Te<we.length;Te++)if(ae(we[Te]))return!0;return!1};return C[Le]?ue=>!pe(ue):pe}function T(he,ye,Oe,Le,fe){const ae=fe?null:c(he);if(ae){const ue=ye?1:0;for(let we=0;we<Le;we++)Oe[we]=ae(we)===ue?1:0;return Oe}const ke=he.kind;if(ke==="float64"||ke==="int32"||ke==="bitset")return n(Oe,Le,ye?1:0);const pe=o(he);for(let ue=0;ue<Le;ue++){const we=pe(ue),Te=A(we)||Array.isArray(we)&&we.length===0||fe&&typeof we=="string"&&we.trim()==="";Oe[ue]=Te===ye?0:1}return Oe}function F(he,ye,Oe,Le){const fe=he.dict,ae=v(fe),ke=new Uint8Array(ae);for(let Te=0;Te<ae;Te++)ke[Te]=ye(b(fe,Te))?1:0;const pe=he.values,ue=c(he);if(!ue){for(let Te=0;Te<Le;Te++)Oe[Te]=ke[pe[Te]];return Oe}const we=ye(null)?1:0;for(let Te=0;Te<Le;Te++)Oe[Te]=ue(Te)===1?ke[pe[Te]]:we;return Oe}function $(he,ye,Oe,Le){const fe=O(he.values),ae=ye(!0)?1:0,ke=ye(!1)?1:0,pe=c(he);if(!pe){for(let we=0;we<Le;we++)Oe[we]=fe(we)===1?ae:ke;return Oe}const ue=ye(null)?1:0;for(let we=0;we<Le;we++)Oe[we]=pe(we)===0?ue:fe(we)===1?ae:ke;return Oe}function D(he,ye,Oe,Le,fe){const ae=he.values,ke=ye.type,pe=ye.op;let ue=!0;switch(pe){case"eq":case"ne":{const Te=d(r(ye.value,ke)),Ne=typeof ye.value=="number"&&Number.isNaN(ye.value),_e=pe==="ne"?1:0;if(Ne)for(let $e=0;$e<fe;$e++)Le[$e]=(Number.isNaN(ae[$e])?1:0)^_e;else for(let $e=0;$e<fe;$e++)Le[$e]=(ae[$e]===Te?1:0)^_e;break}case"lt":{const Te=d(r(ye.value,ke));for(let Ne=0;Ne<fe;Ne++)Le[Ne]=ae[Ne]<Te?1:0;break}case"lte":{const Te=d(r(ye.value,ke));for(let Ne=0;Ne<fe;Ne++)Le[Ne]=ae[Ne]<=Te?1:0;break}case"gt":{const Te=d(r(ye.value,ke));for(let Ne=0;Ne<fe;Ne++)Le[Ne]=ae[Ne]>Te?1:0;break}case"gte":{const Te=d(r(ye.value,ke));for(let Ne=0;Ne<fe;Ne++)Le[Ne]=ae[Ne]>=Te?1:0;break}case"between":case"notBetween":{const Te=U(ye.value),Ne=d(r(Te[0],ke)),_e=d(r(Te[1],ke)),$e=ye.bounds||"[]",je=$e.charAt(0)!=="(",Ge=$e.charAt(1)!==")",Fe=pe==="notBetween"?1:0;if(je&&Ge)for(let Pe=0;Pe<fe;Pe++)Le[Pe]=(ae[Pe]>=Ne&ae[Pe]<=_e?1:0)^Fe;else if(je)for(let Pe=0;Pe<fe;Pe++)Le[Pe]=(ae[Pe]>=Ne&ae[Pe]<_e?1:0)^Fe;else if(Ge)for(let Pe=0;Pe<fe;Pe++)Le[Pe]=(ae[Pe]>Ne&ae[Pe]<=_e?1:0)^Fe;else for(let Pe=0;Pe<fe;Pe++)Le[Pe]=(ae[Pe]>Ne&ae[Pe]<_e?1:0)^Fe;break}case"in":case"notIn":{const Te=new Set;for(const _e of U(ye.value)){const $e=d(r(_e,ke));Number.isNaN($e)||Te.add($e)}const Ne=pe==="notIn"?1:0;for(let _e=0;_e<fe;_e++)Le[_e]=(Te.has(ae[_e])?1:0)^Ne;break}default:ue=!1;break}if(!ue)return!1;const we=c(he);if(we){const Te=Oe(null)?1:0;for(let Ne=0;Ne<fe;Ne++)we(Ne)===0&&(Le[Ne]=Te)}return!0}function z(he,ye,Oe,Le){const fe=o(he);for(let ae=0;ae<Le;ae++)Oe[ae]=ye(fe(ae))?1:0;return Oe}function G(he,ye,Oe){const Le=ye.count|0,fe=Oe||l(ye,Le);if(!he)return n(fe,Le,1);const ae=typeof ye.handle=="function"?ye.handle(he.col):void 0,ke=typeof ye.custom=="function"?ye.custom:null;if(!ae){if(ke){for(let Te=0;Te<Le;Te++)fe[Te]=ke(he,Te)?1:0;return fe}return J(`filter:col:${String(he.col)}`,`filter references unknown column "${String(he.col)}"; the condition is refused rather than matching every row`),n(fe,Le,0)}const pe=he.op;if(pe==="blank"||pe==="notBlank")return T(ae,pe==="notBlank",fe,Le,he.trim===!0);const ue=typeof ye.itemwise=="function"?ye.itemwise(he.col):null;if(ue&&!ve(pe)&&!x.has(pe))return z(ae,j(he,ue,ye.locale),fe,Le);const we=w(he,ye.locale);switch(ae.kind){case"dictionary":return F(ae,we,fe,Le);case"bitset":return $(ae,we,fe,Le);case"float64":case"int32":return D(ae,he,we,fe,Le)?fe:z(ae,we,fe,Le);default:return z(ae,we,fe,Le)}}function N(he,ye,Oe){if(!he)return n(l(ye,Oe),Oe,1);if(Array.isArray(he.conditions)){const Le=he.conditions.filter(ke=>ke!=null),fe=he.op==="or"?"or":he.op==="not"?"not":"and";if(Le.length===0)return n(l(ye,Oe),Oe,1);const ae=N(Le[0],ye,Oe);for(let ke=1;ke<Le.length;ke++){const pe=N(Le[ke],ye,Oe);if(fe==="or")for(let ue=0;ue<Oe;ue++)ae[ue]|=pe[ue];else for(let ue=0;ue<Oe;ue++)ae[ue]&=pe[ue];u(ye,pe)}if(fe==="not")for(let ke=0;ke<Oe;ke++)ae[ke]^=1;return ae}return G(he,ye,l(ye,Oe))}function Z(he,ye){return N(he,ye,ye.count|0)}function Q(he,ye){if(!he||!ye)return he||null;const Oe=he;if(Array.isArray(Oe.conditions)){if((Oe.op==="or"?"or":Oe.op==="not"?"not":"and")!=="and")return ee(Oe,ye)?null:he;const fe=[];for(const ae of Oe.conditions){const ke=Q(ae,ye);ke&&fe.push(ke)}return fe.length?{...Oe,op:"and",conditions:fe}:null}return Oe.col===ye?null:he}function ee(he,ye){if(!he||typeof he!="object")return!1;const Oe=he;if(Oe.col===ye)return!0;if(Array.isArray(Oe.conditions)){for(const Le of Oe.conditions)if(ee(Le,ye))return!0}return!1}function re(he,ye,Oe){if(Oe&&Oe.length>=ye){let ke=0;for(let pe=0;pe<ye;pe++)he[pe]&&(Oe[ke++]=pe);return Oe.subarray(0,ke)}let Le=0;for(let ke=0;ke<ye;ke++)Le+=he[ke]?1:0;const fe=new Uint32Array(Le);let ae=0;for(let ke=0;ke<ye;ke++)he[ke]&&(fe[ae++]=ke);return fe}const ie=new Map;function ce(he){if(!(!he||typeof he!="object"))for(const[ye,Oe]of Object.entries(he))Oe&&typeof Oe.compile=="function"&&ie.set(ye,Oe)}function ve(he){return typeof he=="string"?ie.get(he):void 0}}),ze("packages/core/src/columns/datatypes.js",function(e,B){"use strict";Object.defineProperty(e,"localeSeparators",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"parseNumberText",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"BUILTIN_TYPES",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"INFERENCE_ORDER",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"createTypeRegistry",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"comparatorFor",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"storageKind",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"typeLabel",{enumerable:!0,get:function(){return T}});const ne=B("packages/core/src/internal/compare.js"),A=ne.collator,V=ne.defaultCompare,U=B("packages/core/src/internal/predicates.js"),I=U.isNil,J=U.isObject,H=U.isFunction,L=B("packages/core/src/internal/warn.js"),Y=L.fail,_=L.infoOnce,v=B("packages/core/src/internal/text.js").titleCase,b=B("packages/core/src/format/date.js"),c=b.toDate,g=b.toIsoDate,o=b.compareIso,s=B("packages/core/src/format/boolean.js").toTriState,u=B("packages/core/src/columns/types/index.js").EXTENDED_TYPES,n=B("packages/core/src/formula/index.js"),p=n.evaluateFormula,r=n.looksLikeFormula,d=B("packages/core/src/compute/filter.js").declareOperators,h=/^\d{4}-\d{2}-\d{2}$/;function a(F){return F.getHours()===0&&F.getMinutes()===0&&F.getSeconds()===0&&F.getMilliseconds()===0}const y=new Map;function f(F){const $=F||"",D=y.get($);if(D)return D;const z={group:",",decimal:"."};try{for(const G of new Intl.NumberFormat(F||void 0).formatToParts(12345.6))G.type==="group"?z.group=G.value:G.type==="decimal"&&(z.decimal=G.value)}catch{}return y.set($,z),z}const m=/\d\s*[*/^]\s*[\d.(]/;function w(F,$){if(I(F))return null;let D=String(F).trim();if(D===""||D.startsWith("=")||m.test(D))return null;let z=1;D.startsWith("(")&&D.endsWith(")")&&(z=-1,D=D.slice(1,-1));const G=D.endsWith("%"),{group:N,decimal:Z}=f($);if(D=D.replace(/[\s\u00a0\u202f\u2009']/g,""),N&&N!=="."&&N!==","&&(D=D.split(N).join("")),D=D.replace(/[^0-9eE+\-.,]/g,""),Z===","?D=D.split(".").join("").replace(",","."):D=D.split(",").join(""),D===""||D==="-"||D==="+")return null;const Q=Number(D);return Number.isNaN(Q)?null:z*(G?Q/100:Q)}function S(F,$){const D=I(F)||Number.isNaN(F)?null:Number(F),z=I($)||Number.isNaN($)?null:Number($);return D===null?z===null?0:1:z===null||D<z?-1:D>z?1:0}function M(F,$){const D=s(F),z=s($);return D===null?z===null?0:1:z===null?-1:D===z?0:D?1:-1}function X(F,$){const D=c(F),z=c($);if(!D)return z?1:0;if(!z)return-1;const G=D.getTime(),N=z.getTime();return G<N?-1:G>N?1:0}const q=new Map;function K(F){const $=c(F.value);if(!$)return"";const D=F.locale||"";let z=q.get(D);return z||(z=new Intl.DateTimeFormat(F.locale||void 0,{dateStyle:"medium"}),q.set(D,z)),z.format($)}const P={boolean:{base:"boolean",storage:"bitset",matches:F=>typeof F=="boolean",parse:F=>s(F.text),compare:M,format:F=>s(F.value)===null?"":s(F.value)?"Yes":"No",defaults:{filter:"set",editor:"checkbox",align:"center"},excel:"General",toClipboard:F=>s(F)===null?"":String(s(F)),fromClipboard:F=>s(F)},number:{base:"number",storage:"float64",matches:F=>typeof F=="number"&&!Number.isNaN(F),parse:F=>{if(r(F.text)){const $=p(F.text,F);if(!$.ok)return null;const D=Number($.value);return Number.isFinite(D)?D:null}return w(F.text,F.locale)},compare:S,defaults:{filter:"number",editor:"number",align:"end"},excel:"General",toClipboard:F=>I(F)?"":String(F),fromClipboard:(F,$)=>w(F,$&&$.locale),toStorage:(F,$)=>{if(typeof F!="string")return F;const D=w(F,$&&$.locale);return D!==null?D:(_(`type.number.unparsed.${$&&$.colId||""}`,`column "${$&&$.colId||"?"}" is declared type "number" but holds a value that is not a number in its locale; storing it as NaN, excluded from sorts and totals.`),NaN)}},date:{base:"dateString",storage:"dictionary",matches:F=>typeof F=="string"&&h.test(F)&&!Number.isNaN(Date.parse(F))||F instanceof Date&&!Number.isNaN(F.getTime())&&a(F),parse:F=>g(F.text),compare:o,format:K,defaults:{filter:"date",editor:"date",align:"start"},excel:"yyyy-mm-dd",toStorage:F=>g(F),toClipboard:F=>I(F)?"":String(F),fromClipboard:F=>g(F)},dateString:{base:"dateString",storage:"dictionary",matches:F=>typeof F=="string"&&h.test(F)&&!Number.isNaN(Date.parse(F)),parse:F=>g(F.text),compare:o,format:K,defaults:{filter:"date",editor:"date",align:"start"},excel:"yyyy-mm-dd",toStorage:F=>g(F),toClipboard:F=>I(F)?"":String(F),fromClipboard:F=>g(F)},text:{base:"text",storage:"dictionary",matches:F=>typeof F=="string",parse:F=>F.text===""?null:String(F.text),compare:(F,$)=>I(F)?I($)?0:1:I($)?-1:A().compare(String(F),String($)),defaults:{filter:"text",editor:"text",align:"start"},excel:"@",toClipboard:F=>I(F)?"":String(F),fromClipboard:F=>F},image:{base:"text",storage:"dictionary",parse:F=>F.text===""||F.text==null?null:String(F.text).trim(),compare:(F,$)=>I(F)?I($)?0:1:I($)?-1:A().compare(String(F),String($)),defaults:{filter:"text",editor:"text",align:"center",render:"image"},excel:"@",toClipboard:F=>I(F)?"":String(F),fromClipboard:F=>F},lookup:{base:"text",storage:"dictionary",parse:F=>{if(F.text===""||F.text==null)return null;const $=F.column&&F.column.lookup,D=$&&H($.options)?$.options():null;if(!D)return F.text;const z=String(F.text),G=D.find(Q=>String(Q.id)===z);if(G)return G.id;const N=z.trim().toLowerCase(),Z=D.find(Q=>String(Q.label).toLowerCase()===N);return Z?Z.id:F.text},compare:V,defaults:{filter:"set",editor:"select",align:"start"},excel:"@",multiStorage:"multi",toClipboard:F=>I(F)?"":String(F),fromClipboard:F=>F},object:{base:"object",storage:"object",matches:F=>F!==null&&typeof F=="object"&&!(F instanceof Date),parse:F=>{try{return F.text===""?null:JSON.parse(F.text)}catch{return F.text}},compare:(F,$)=>V(F,$),format:F=>{const $=F.value;if(I($))return"";if(typeof $=="string")return $;try{return JSON.stringify($)}catch{return String($)}},defaults:{filter:"none",editor:"none",align:"start"},excel:"@",toClipboard:F=>I(F)?"":typeof F=="string"?F:JSON.stringify(F),fromClipboard:F=>F}},k=["boolean","number","date","dateString","datetime","text","object"];function E(F,$,D,z){const G=D.get(F);if(G)return G;z.includes(F)&&Y(`circular data type extends chain: ${[...z,F].join(" → ")}`);const N=$[F];N||Y(`unknown data type "${F}"`);let Z=null;N.extends&&(Z=E(N.extends,$,D,[...z,F]));const Q={...Z||{},...N,name:F,defaults:{...Z&&Z.defaults||{},...N.defaults||{}}};return Q.base||(Q.base=Z&&Z.base||"text"),Q.storage||(Q.storage=Z&&Z.storage||"object"),D.set(F,Q),Q}function C(F,$){const D={...P,...u};if($&&typeof $.dataType=="function"&&typeof $.names=="function")for(const G of $.names("dataType")){const N=$.dataType(G);N&&(D[G]=N)}if(J(F))for(const[G,N]of Object.entries(F))D[G]=N;const z=new Map;for(const G of k)E(G,D,z,[]);E("lookup",D,z,[]);for(const G of Object.keys(D))E(G,D,z,[]);for(const G of z.values())d(G.operators);return z}function x(F,$){if(F.base==="text"&&(!F.compare||F.compare===P.text.compare)){const D=A($);return(z,G)=>I(z)?I(G)?0:1:I(G)?-1:D.compare(String(z),String(G))}return F.compare||V}function j(F,$){return $?F.multiStorage||"multi":F.storage||"object"}function T(F){return v(String(F).replace(/([a-z])([A-Z])/g,"$1 $2"))}}),ze("packages/core/src/columns/infer.js",function(e,B){"use strict";Object.defineProperty(e,"DEFAULT_SAMPLE",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"inferFromValues",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"inferColumnType",{enumerable:!0,get:function(){return H}});const A=B("packages/core/src/internal/warn.js").infoOnce,U=B("packages/core/src/internal/predicates.js").isNil,I=100;function J(L,Y,_={}){const O=_.sampleSize??I,v=[];for(let b=0;b<L.length&&v.length<O;b++){const c=L[b];U(c)||typeof c=="number"&&Number.isNaN(c)||v.push(c)}if(v.length===0)return{type:"text",unanimous:!1,sampled:0};for(const[b,c]of Y){if(typeof c.matches!="function")continue;let g=!0;for(let o=0;o<v.length;o++)if(!c.matches(v[o])){g=!1;break}if(g)return{type:b,unanimous:!0,sampled:v.length}}return _.quiet||A(`infer:${_.colId||"?"}`,`column "${_.colId||"?"}" has mixed or ambiguous values and was inferred as "text". Declare \`type\` on the column to get correct sorting, filtering and export.`),{type:"text",unanimous:!1,sampled:v.length}}function H(L,Y,_,O,v={}){const b=v.sampleSize??I,c=[];for(let g=0;g<Y.length&&c.length<b;g++){const o=_(Y[g]);U(o)||typeof o=="number"&&Number.isNaN(o)||c.push(o)}return J(c,O,{...v,colId:L}).type}}),ze("packages/core/src/columns/graph.js",function(e,B){"use strict";Object.defineProperty(e,"WHOLE_ROW",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"declarationOf",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"buildGraph",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"affectedBy",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"depsProxy",{enumerable:!0,get:function(){return O}});const ne=B("packages/core/src/internal/warn.js"),A=ne.DEV,V=ne.fail,U=ne.warnOnce,J=B("packages/core/src/internal/predicates.js").isFunction,H="*";function L(v){const b=v.value||{};if(!J(b.compute))return{computed:!1,wholeRow:!1,deps:[],pure:!0};const g=b.pure!==!1;return b.deps===H?{computed:!0,wholeRow:!0,deps:[],pure:g}:Array.isArray(b.deps)?{computed:!0,wholeRow:!1,deps:b.deps.slice(),pure:g}:(U(`deps:missing:${v.id}`,`computed column "${v.id}" declares no \`value.deps\`; treating it as \`deps: '*'\` (a whole-row dependency). Declare the dependencies to get precise invalidation.`),{computed:!0,wholeRow:!0,deps:[],pure:g})}function Y(v){const b=new Map;for(const d of v)b.set(d.id,d);const c=new Map,g=new Map,o=new Set,t=new Set,s=new Set,l=new Set;for(const d of v){const h=L(d);if(!h.computed){c.set(d.id,[]);continue}t.add(d.id),(h.pure?s:l).add(d.id),h.wholeRow&&o.add(d.id);const a=[],y=[];for(const f of h.deps)(b.has(f)?a:y).push(f);c.set(d.id,a),y.length&&g.set(d.id,y)}for(const d of s)for(const h of c.get(d))l.has(h)&&V(`pure computed column "${d}" depends on impure column "${h}". Mark it \`value.pure: false\` or make the dependency pure.`);const u=[],n=new Map,p=[],r=d=>{const h=n.get(d);if(h!=="done"){if(h==="open"){const a=p.indexOf(d);V(`circular column dependency: ${[...p.slice(a),d].join(" → ")}`)}n.set(d,"open"),p.push(d);for(const a of c.get(d)||[])b.has(a)&&r(a);p.pop(),n.set(d,"done"),u.push(d)}};for(const d of v)r(d.id);const i=new Map;for(const d of v)i.set(d.id,[]);for(const d of v)for(const h of c.get(d.id)||[]){const a=i.get(h);a&&!a.includes(d.id)&&a.push(d.id)}if(o.size)for(const d of v){if(t.has(d.id))continue;const h=i.get(d.id);for(const a of o)h.includes(a)||h.push(a)}return{order:u,dependents:i,pure:s,impure:l,computed:t,deps:c,wholeRow:o,external:g,index:b}}function _(v,b){const c=Array.isArray(b)?b:[b],g=new Set,o=[...c];for(;o.length;){const t=o.shift();for(const s of v.dependents.get(t)||[])g.has(s)||(g.add(s),o.push(s))}for(const t of c)g.delete(t);return v.order.filter(t=>g.has(t))}function O(v,b,c){if(!A)return v;const g=b instanceof Set?b:new Set(b);return new Proxy(v,{get(o,t){return typeof t=="string"&&!g.has(t)&&!Object.hasOwn(o,t)&&U(`undeclared:${c}:${t}`,`computed column "${c}" read undeclared dependency "${t}". Add it to \`value.deps\` or the value will go stale.`),o[t]}})}}),ze("packages/core/src/model/rowkey.js",function(e,B){"use strict";Object.defineProperty(e,"KEY_DEPENDENT_FEATURES",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"compositeKey",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"createRowKey",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"warnMissingKeys",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"groupPathKey",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"splitPathKey",{enumerable:!0,get:function(){return t}});const A=B("packages/core/src/internal/warn.js").warnOnce,U=B("packages/core/src/internal/paths.js").pathGetter,I=B("packages/core/src/internal/predicates.js"),J=I.isFunction,H=I.isBlank,L=["changes (rows.apply / rows.queue)","streaming dedupe","selection persistence","remote reload","cell comments"],Y="";function _(s){if(s===null)return"\0n";if(s===void 0)return"\0u";const l=typeof s;if(l==="string")return s;if(l==="number"||l==="bigint"||l==="boolean")return String(s);if(s instanceof Date)return`\0d${s.getTime()}`;try{return`\0o${JSON.stringify(s)}`}catch{return"\0o?"}}function O(s){if(s.length===1)return _(s[0]);let l="";for(let u=0;u<s.length;u++)u&&(l+=Y),l+=_(s[u]);return l}function v(s,l={}){const u=l.warn!==!1;if(J(s)){const n=s;return{stable:!0,fields:[],disabled:[],key(p,r){try{const i=n(p);return Array.isArray(i)?O(i):_(i)}catch(i){return A("rowKey.throw","rowKey function threw; falling back to index identity for the affected rows.",i),`#${r??-1}`}},keyEmpty(p){try{const r=n(p);return Array.isArray(r)?r.length===0||r.some(H):H(r)}catch{return!1}},missingFields(){return[]}}}if(Array.isArray(s)&&s.length>0){const n=s.filter(i=>typeof i=="string"),p=n.map(i=>U(i)),r=p.length;return{stable:!0,fields:n,disabled:[],key(i){const d=new Array(r);for(let h=0;h<r;h++)d[h]=p[h](i);return O(d)},keyEmpty(i){for(let d=0;d<r;d++)if(H(p[d](i)))return!0;return!1},missingFields(i){const d=[];for(let h=0;h<r;h++)H(p[h](i))&&d.push(n[h]);return d}}}if(typeof s=="string"&&s.length>0){const n=U(s);return{stable:!0,fields:[s],disabled:[],key(p){return _(n(p))},keyEmpty(p){return H(n(p))},missingFields(p){return H(n(p))?[s]:[]}}}return u&&A("rowKey.missing",`no rowKey configured, so rows are identified by object identity. This disables: ${L.join(", ")}. Set rowKey to a field name, an array of field names, or a function.`),{stable:!1,fields:[],disabled:L.slice(),key(n,p){if(n===null||typeof n!="object")return`#${p??0}:${String(n)}`;let r=b.get(n);return r===void 0&&(r=`#${c++}`,b.set(n,r)),r}}}const b=new WeakMap;let c=0;function g(s,l){if(!s||s.stable===!1||!J(s.keyEmpty)||!Array.isArray(l)||l.length===0)return;let u=0,n=null,p;for(let h=0;h<l.length;h++){const a=l[h];s.keyEmpty(a)&&(u++,n===null&&(n=J(s.missingFields)?s.missingFields(a):[],p=a))}if(u===0)return;const r=s.fields.length?s.fields.join(","):"(function)",i=n&&n.length?n.join(", "):s.fields.length?s.fields.join(", "):"the rowKey function",d=p!==null&&typeof p=="object"?Object.keys(p).join(", ")||"(no fields)":String(p);A(`rowKey.emptyValue:${r}`,`rowKey ${i} is missing on ${u} of ${l.length} rows; the first such row has: ${d}. Rows without a key value collapse onto one key, so selection, edits and rows.apply updates land on whichever row now shares it. Set rowKey to a field present on every row, or fix the source data.`)}function o(s){return O(s)}function t(s){return s.split(Y)}}),ze("packages/core/src/columns/lookup.js",function(e,B){"use strict";Object.defineProperty(e,"DEFAULT_SEPARATOR",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"normaliseOption",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"flattenOptions",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"Lookup",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"toValueArray",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"createLookup",{enumerable:!0,get:function(){return s}});const ne=B("packages/core/src/internal/compare.js"),A=ne.collator,V=ne.defaultCompare,U=B("packages/core/src/internal/predicates.js"),I=U.isFunction,J=U.isNil,L=B("packages/core/src/internal/warn.js").warnOnce,_=B("packages/core/src/model/rowkey.js").compositeKey,O=", ",v="";function b(l,u,n,p){if(l===null||typeof l!="object")return{id:l,label:l==null?"":String(l)};const r=l[u],i=l[n],d={id:r,label:i==null?String(r??""):String(i)};l.disabled&&(d.disabled=!0),l.variant&&(d.variant=l.variant),l.icon&&(d.icon=l.icon);const h=p?l[p]:l.group;return h!==void 0&&(d.group=h),d}function c(l,u,n=0,p=[],r=[]){for(const i of l||[]){const d=i&&typeof i=="object"?i[u]:null;if(r.push({raw:i,depth:n,path:p}),Array.isArray(d)&&d.length){const h=String(i&&typeof i=="object"?i.label??i.name??i.id??"":i);c(d,u,n+1,[...p,h],r)}}return r}function g(l){return!!l&&typeof l=="object"&&!Array.isArray(l)&&I(l.router&&l.router.subscribe)}class o{#e;#t;#n;#r;#s=[];#i=new Map;#a=new Map;#l=0;#o="idle";#c=null;#u;#f=null;#d=new Map;constructor(u,n={}){this.#e=u||{},this.#t=n.colId||"?",this.#n=n.locale,this.#r=n.onChange||null,this.#u=A(this.#n),Array.isArray(this.#e.options)?this.#h(this.#e.options):this.#e.options===void 0&&(this.#o="ready")}get colId(){return this.#t}get version(){return this.#l}get state(){return this.#o}get ready(){return this.#o==="ready"}get multiple(){return this.#e.multiple===!0}get separator(){return this.#e.separator??O}get allowCustom(){return this.#e.allowCustom===!0}get sortBy(){return this.#e.sortBy||"label"}get spec(){return this.#e}options(){return this.#s}setLocale(u){this.#n=u,this.#u=A(u)}#h(u){const n=this.#e,p=n.valueKey||"id",r=n.labelKey||"label",i=n.childrenKey||"children";this.#s=c(u,i).map(d=>{const h=b(d.raw,p,r,n.groupKey);return d.depth&&(h.depth=d.depth,h.path=d.path),h}),this.#i=new Map,this.#a=new Map,this.#s.forEach((d,h)=>{this.#i.set(d.id,d),this.#a.set(d.id,h)}),this.#o="ready",this.#l+=1}load(){if(this.#c)return this.#c;const u=this.#e.options;if(Array.isArray(u)||u===void 0)return this.#c=Promise.resolve(this.#s),this.#c;if(g(u))return this.#c=this.#p(u),this.#c;if(!I(u))return L(`lookup:options:${this.#t}`,`column "${this.#t}" has an invalid \`lookup.options\`; expected an array, a function, or a router route`),this.#o="ready",this.#c=Promise.resolve([]),this.#c;this.#o="loading";let n;try{n=u()}catch(p){return this.#o="error",L(`lookup:load:${this.#t}`,`column "${this.#t}" failed to load lookup options`,p),this.#c=Promise.resolve([]),this.#c}return!n||!I(n.then)?(this.#h(n),this.#c=Promise.resolve(this.#s),this.#r&&this.#r(this),this.#c):(this.#c=n.then(p=>(this.#h(p),this.#r&&this.#r(this),this.#s),p=>(this.#o="error",L(`lookup:load:${this.#t}`,`column "${this.#t}" failed to load lookup options`,p),[])),this.#c)}refresh(){return this.#c=null,Array.isArray(this.#e.options)?(this.#h(this.#e.options),this.#r&&this.#r(this),Promise.resolve(this.#s)):this.load()}#p(u){if(this.#f)return Promise.resolve(this.#s);const n=this.#e,p=n.valueKey||"id",r=n.labelKey||"label",i=n.groupKey,d=I(u.map)?u.map:null,h=y=>b(d?d(y):y,p,r,i).id,a=y=>this.#m(y,d,p,r,i);return u.router.subscribe(u.predicate,a,{rowKey:h}),this.#f=()=>{I(u.router.detach)&&u.router.detach(a)},this.#o="ready",Promise.resolve(this.#s)}#m(u,n,p,r,i){const d=u&&u.add||[],h=u&&u.update||[],a=u&&u.remove||[];if(!(!d.length&&!h.length&&!a.length)){for(const y of d)this.#g(y,n,p,r,i);for(const y of h)this.#g(y,n,p,r,i);for(const y of a){if(!this.#d.has(y))continue;const f=this.#d.get(y);this.#d.delete(y),this.#i.delete(f);const m=this.#s.findIndex(w=>w.id===f);m>=0&&this.#s.splice(m,1)}this.#a=new Map(this.#s.map((y,f)=>[y.id,f])),this.#o="ready",this.#l+=1,this.#r&&this.#r(this)}}#g(u,n,p,r,i){const d=b(n?n(u):u,p,r,i);this.#d.set(_([d.id]),d.id);const h=this.#s.findIndex(a=>a.id===d.id);h>=0?this.#s[h]=d:this.#s.push(d),this.#i.set(d.id,d)}destroy(){this.#f&&(this.#f(),this.#f=null)}search(u,n){const p=this.#e;if(!I(p.search)){const d=String(u||"").toLowerCase();return Promise.resolve(d===""?this.#s:this.#s.filter(h=>h.label.toLowerCase().includes(d)))}const r=p.valueKey||"id",i=p.labelKey||"label";return Promise.resolve(p.search(u,n)).then(d=>(d||[]).map(h=>b(h,r,i,p.groupKey)))}option(u){return this.#i.get(u)}has(u){return this.#i.has(u)}label(u){if(J(u)||u==="")return"";const n=this.#i.get(u);if(n)return n.label;if(this.#o==="loading"||this.#o==="idle")return"";this.allowCustom||L(`lookup:unknown:${this.#t}`,`column "${this.#t}" holds value ${JSON.stringify(u)} which is not in its lookup options. Showing the raw value; set \`lookup.unknownLabel\` or \`lookup.allowCustom\` to change that.`);const p=this.#e.unknownLabel;return I(p)?String(p(u)??""):typeof p=="string"?p:String(u)}text(u){if(this.multiple){const n=t(u);return n.length===0?"":n.map(p=>this.label(p)).join(this.separator)}return this.label(u)}dictionary(){return this.#s.map(u=>u.id)}sorted(){const u=this.sortBy;if(u==="optionOrder"||u==="count")return this.#s.slice();if(u==="value")return this.#s.slice().sort((p,r)=>V(p.id,r.id));const n=this.#u;return this.#s.slice().sort((p,r)=>n.compare(p.label,r.label))}comparator(){const u=this.sortBy,n=this.multiple,p=this.#u,r=this.#a;if(n&&u==="count")return(d,h)=>t(d).length-t(h).length;const i=n?d=>t(d)[0]:d=>d;return u==="value"?(d,h)=>V(i(d),i(h)):u==="optionOrder"?(d,h)=>{const a=r.has(i(d))?r.get(i(d)):Number.MAX_SAFE_INTEGER,y=r.has(i(h))?r.get(i(h)):Number.MAX_SAFE_INTEGER;return a-y}:(d,h)=>{const a=i(d),y=i(h);return J(a)?J(y)?0:1:J(y)?-1:p.compare(this.label(a),this.label(y))}}groupKey(u){return this.multiple?t(u).map(p=>String(p)).sort().join(v):J(u)?"":String(u)}countValues(u){return this.multiple?t(u).length:J(u)?0:1}contains(u,n,p){const r=this.multiple?t(u):J(u)?[]:[u],i=Array.isArray(n)?n:[n];switch(p){case"containsAll":return i.every(d=>r.includes(d));case"containsNone":return!i.some(d=>r.includes(d));default:return i.some(d=>r.includes(d))}}exportText(u,n="label"){return n==="value"?this.multiple?t(u).join(this.separator):J(u)?"":String(u):this.text(u)}exportColumns(){const u=this.multiple;return this.#s.map(n=>({id:n.id,label:n.label,has:p=>u?t(p).includes(n.id):p===n.id}))}}function t(l){return Array.isArray(l)?l:J(l)||l===""?[]:[l]}function s(l,u={}){const n=l.lookup;if(!n)return null;const p=new o(n,{colId:l.id,locale:u.locale,onChange:u.onChange});return!Array.isArray(n.options)&&n.options!==void 0&&p.load(),p}}),ze("packages/core/src/columns/value.js",function(e,B){"use strict";Object.defineProperty(e,"compileDisplay",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"warnImpureUse",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"ValuePipeline",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"defaultRowKey",{enumerable:!0,get:function(){return l}});const A=B("packages/core/src/internal/paths.js").getPath,V=B("packages/core/src/internal/predicates.js"),U=V.isFunction,I=V.isNil,J=V.isObject,L=B("packages/core/src/internal/lru.js").Lru,_=B("packages/core/src/internal/warn.js").warnOnce,v=B("packages/core/src/format/number.js").compileNumber,c=B("packages/core/src/columns/graph.js").depsProxy,g="\0";function o(r,i={}){const d=i.locale,h=i.grid??null,a=i.context,y=r.value&&r.value.format,f=r.formatter||null,m=r.dataType&&r.dataType.format,w=r.lookup||null,S=(M,X,q)=>({value:M,data:q,row:X,column:r,colId:r.id,grid:h,context:a,locale:d});if(U(y))return(M,X,q)=>{const K=y(S(M,X,q));return K==null?"":String(K)};if(f){if(w){const M=f.kind==="text";return(X,q,K)=>f(M?w.text(X):X,S(X,q,K))}return(M,X,q)=>f(M,S(M,X,q))}if(U(m))return(M,X,q)=>{const K=m(S(M,X,q));return K==null?"":String(K)};if(r.dataType&&r.dataType.base==="number"&&J(r.typeOptions)&&typeof r.typeOptions.decimals=="number"){const M=v({decimals:r.typeOptions.decimals},d);return X=>M(X)}return w?M=>w.text(M):M=>I(M)?"":typeof M=="string"?M:String(M)}function t(r,i){!r||!r.value||r.value.pure!==!1||_(`impure:${i}:${r.id}`,`column "${r.id}" is an impure computed column (\`value.pure: false\`) and is being used to ${i}. The result is not stable across passes.`)}class s{#e;#t;#n;#r;#s;#i;#a=new L(4096);constructor(i){this.#e=i.columns instanceof Map?i.columns:new Map((i.columns||[]).map(d=>[d.id,d])),this.#t=i.graph,this.#n=i.grid??null,this.#r=i.context,this.#i=i.stored||null,this.#s=i.rowKey||l}get graph(){return this.#t}setGraph(i){this.#t=i,this.#a.clear()}beginPass(){this.#a.clear()}endPass(){this.#a.clear()}invalidate(i){if(this.#a.size===0)return;const d=i&&i.rows?new Set([...i.rows].map(String)):null,h=i&&i.columns?[...i.columns]:null;if(!d&&!h){this.#a.clear();return}const a=h?this.#l(h):null;for(const y of[...this.#a.keys()]){const f=String(y).split(g);f.length===3&&(d&&!d.has(f[0])||a&&!a.has(f[2])||this.#a.delete(y))}}#l(i){const d=new Set,h=this.#t,a=[...i];for(;a.length;){const y=a.pop();if(!d.has(y)){d.add(y);for(const f of h?h.dependents.get(y)||[]:[])a.push(f)}}return d}value(i,d,h){const a=typeof i=="string"?this.#e.get(i):i;if(!a)return;if(!a.computed)return this.#c(a,d,h);if(a.value.pure!==!1&&this.#i&&h&&h.physical!=null&&this.#i.has(a.id))return this.#i.get(a.id,h.physical);if(a.volatile)return this.compute(a,d,h);if(a.value.pure===!1)return this.compute(a,d,h);const y=`${this.#o(d,h)}${g}${a.id}`;if(this.#a.has(y))return this.#a.get(y);const f=this.compute(a,d,h);return this.#a.set(y,f),f}#o(i,d){return`${this.#s(i,d)}${g}${u(i)}`}#c(i,d,h){if(this.#i&&h&&h.physical!=null&&this.#i.has(i.id))return this.#i.get(i.id,h.physical);if(i.field)return i.read?i.read(d):A(d,i.field)}compute(i,d,h){const a=this.#t,y=a&&a.wholeRow.has(i.id);let f;if(y)f=d??{};else{f={};const w=a&&a.deps.get(i.id)||[];for(const M of w)f[M]=this.value(M,d,h);const S=a&&a.external.get(i.id)||[];for(const M of S)f[M]=A(d,M);f=c(f,[...w,...S],i.id)}const m={data:d,row:h,column:i,grid:this.#n,context:this.#r};return i.value.compute(f,m)}values(i,d){const h={},a=this.#t?this.#t.order:[...this.#e.keys()];for(const y of a)h[y]=this.value(y,i,d);return h}text(i,d,h){const a=typeof i=="string"?this.#e.get(i):i;return a?a.formatValue(this.value(a,d,h),h,d):""}key(i,d,h){const a=typeof i=="string"?this.#e.get(i):i;if(!a)return"";const y=this.value(a,d,h);return U(a.value.key)?String(a.value.key(this.#u(a,y,d,h))):a.lookup?a.lookup.groupKey(y):I(y)?"":String(y)}quickFilterText(i,d,h){const a=typeof i=="string"?this.#e.get(i):i;if(!a)return"";if(U(a.value.quickFilterText)){const y=this.value(a,d,h);return String(a.value.quickFilterText(this.#u(a,y,d,h))??"")}return this.text(a,d,h)}#u(i,d,h,a){return{value:d,data:h,row:a,column:i,colId:i.id,grid:this.#n,context:this.#r}}parse(i,d,h,a){const y=typeof i=="string"?this.#e.get(i):i;if(!y)return d;const f={text:d,value:this.value(y,h,a),data:h,row:a,column:y,grid:this.#n,context:this.#r,locale:this.#n&&U(this.#n.get)?this.#n.get("locale"):void 0,formulaFunctions:this.#n&&U(this.#n.get)?this.#n.get("formulaFunctions"):void 0};return U(y.value.parse)?y.value.parse(f):y.dataType&&U(y.dataType.parse)?y.dataType.parse(f):d}validate(i,d,h,a,y){const f=typeof i=="string"?this.#e.get(i):i;if(!f||!U(f.edit.validate))return!0;const m=f.edit.validate({value:d,oldValue:h,data:a,row:y,column:f,grid:this.#n,context:this.#r});return m===!0||m===void 0?!0:String(m)}apply(i,d,h,a){const y=typeof i=="string"?this.#e.get(i):i;if(!y)return!1;const f=this.value(y,h,a);if(U(y.value.apply)){const m=y.value.apply({value:d,oldValue:f,data:h,row:a,column:y,grid:this.#n,context:this.#r});return this.#f(y,h,a),m!==!1}return y.field?f===d?!1:(y.write(h,d),this.#f(y,h,a),!0):(_(`apply:${y.id}`,`column "${y.id}" has no \`field\` and no \`value.apply\`, so an edit cannot be written back.`),!1)}commit(i,d,h,a){const y=typeof i=="string"?this.#e.get(i):i;if(!y)return{ok:!1,value:void 0,oldValue:void 0,changed:!1,error:"unknown column"};const f=this.value(y,h,a),m=this.parse(y,d,h,a),w=this.validate(y,m,f,h,a);if(w!==!0)return{ok:!1,value:m,oldValue:f,changed:!1,error:w};const S=this.apply(y,m,h,a);return{ok:!0,value:m,oldValue:f,changed:S}}#f(i,d,h){if(this.#a.size===0)return;const a=this.#o(d,h);this.#a.delete(`${a}${g}${i.id}`);for(const y of this.#t?this.#t.dependents.get(i.id)||[]:[])this.#a.delete(`${a}${g}${y}`)}}function l(r,i){return i&&i.key!=null?String(i.key):u(r)}function u(r){if(r&&typeof r=="object"){let i=n.get(r);return i===void 0&&(i=`#${p++}`,n.set(r,i)),i}return String(r)}const n=new WeakMap;let p=0}),ze("packages/core/src/model/shadow.js",function(e,B){"use strict";Object.defineProperty(e,"MAX_TRACKED",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"DEFAULT_DEPTH",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"HISTORY_TICK_MAX_MS",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"HISTORY_TICK_MIN_MS",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"historyTickFor",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"SHADOW_KINDS",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"ROLLING_KINDS",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"FIT_SHADOW_KINDS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"CLUSTER_SHADOW_KINDS",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"MAD_SCALE",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"DEFAULT_ANOMALY_THRESHOLD",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"SPEC_STATUS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"POSITIONAL_KINDS",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"SHADOW_LABELS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"specStatusOf",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"ShadowTracker",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"shadowsIn",{enumerable:!0,get:function(){return i}});const A=B("packages/core/src/internal/warn.js").warnOnce,V=2e5,U=20,I=1e3,J=50;function H(d){return Math.min(I,Math.max(J,Math.floor(d)))}const L=Object.freeze(["updates","updatedAt","sinceUpdate","delta","deltaPercent","rate","history","firstValue","streak","rank","rankAsc","rankChange","percentile","quartile","zScore","shareOfTotal","anomalyScore","anomalyFlag","specStatus","rollingSum","rollingAvg","rollingMin","rollingMax","windowCoverage","cumulativeToDate","periodOverPeriod","rollingQuantile","windowApproximate","tsTrend","tsSeasonal","tsResidual","tsCoverage","tsSmoothed","tsSmoothingAlpha","tsSmoothingBeta","fitPredicted","fitResidual","fitInfluence","fitStdResidual","fitLeverage","fitCooksD","cluster","clusterDistance"]),Y=Object.freeze(["rollingSum","rollingAvg","rollingMin","rollingMax","windowCoverage","cumulativeToDate","periodOverPeriod","rollingQuantile","windowApproximate","tsTrend","tsSeasonal","tsResidual","tsCoverage","tsSmoothed","tsSmoothingAlpha","tsSmoothingBeta"]),_=Object.freeze(["fitPredicted","fitResidual","fitInfluence","fitStdResidual","fitLeverage","fitCooksD"]),O=Object.freeze(["cluster","clusterDistance"]),v=.6745,b=3.5,c=Object.freeze({PASS:"PASS",WARN:"WARN",FAIL:"FAIL"}),g=Object.freeze(["rank","rankAsc","rankChange","percentile","quartile","zScore","shareOfTotal","anomalyScore","anomalyFlag"]),o=Object.freeze({updates:"Updates",updatedAt:"Updated at",sinceUpdate:"Since update",delta:"Change",deltaPercent:"Change %",rate:"Rate of change",history:"History",firstValue:"Baseline",streak:"Streak",rank:"Rank",rankAsc:"Rank, ascending",rankChange:"Rank change",percentile:"Percentile",quartile:"Quartile",zScore:"Z-score",shareOfTotal:"Share of total",anomalyScore:"Anomaly score",anomalyFlag:"Anomaly",specStatus:"Spec status",rollingSum:"Rolling sum",rollingAvg:"Rolling average",rollingMin:"Rolling minimum",rollingMax:"Rolling maximum",windowCoverage:"Window coverage",cumulativeToDate:"Cumulative to date",periodOverPeriod:"Period over period",rollingQuantile:"Rolling quantile",windowApproximate:"Window approximate",tsTrend:"Trend",tsSeasonal:"Seasonal",tsResidual:"Seasonal residual",tsCoverage:"Decomposition coverage",tsSmoothed:"Smoothed",tsSmoothingAlpha:"Smoothing α",tsSmoothingBeta:"Smoothing β",fitPredicted:"Predicted",fitResidual:"Residual",fitInfluence:"Influence",fitStdResidual:"Std. residual",fitLeverage:"Leverage",fitCooksD:"Cook's D",cluster:"Cluster",clusterDistance:"Cluster distance"});function t(d,h){if(!h)return null;const a=Number.isFinite(Number(h.lower))?Number(h.lower):null,y=Number.isFinite(Number(h.upper))?Number(h.upper):null;if(a===null&&y===null||!Number.isFinite(d))return null;if(a!==null&&d<a||y!==null&&d>y)return c.FAIL;const f=Number.isFinite(Number(h.warnLower))?Number(h.warnLower):null,m=Number.isFinite(Number(h.warnUpper))?Number(h.warnUpper):null;return f!==null&&d<f||m!==null&&d>m?c.WARN:c.PASS}function s(d,h,a){if(!h||typeof h!="object")return null;if(h.kind!=="time")return h.kind!==void 0&&A(`shadow.history.window.kind:${d}`,`a 'history' shadow's 'window' only accepts {kind: 'time', span}; '${h.kind}' is not honoured (a plain count is already what 'depth' means, and a session has no span to divide into buckets), so it reported the original, unwindowed history.`),null;const y=h.minutes!=null?Number(h.minutes)*6e4:Number(h.span);if(!(y>0))return A(`shadow.history.window.span:${d}`,"a 'history' shadow's time window needs a positive 'span' (ms) or 'minutes'; it had none, so it reported the original, unwindowed history."),null;const f=Math.max(2,Math.floor(a)||U);return{span:y,bucketMs:Math.max(1,Math.floor(y/f))}}class l{#e;#t=new Map;#n=new Map;#r=new Map;#s=new Map;#i=new Map;#a=new Map;#l=0;#o;#c;#u;#f;#d=new Map;#h=null;#p=null;#m=null;constructor(h){this.#e=h.colId,this.#o=Math.max(2,h.depth||U),this.#c=Math.max(1,h.max||V),this.#u=h.now||(()=>Date.now()),this.#f=s(this.#e,h.historyWindow,this.#o),this.#f&&(this.#h=Math.floor(this.#u()/this.#f.bucketMs))}get colId(){return this.#e}get forgotten(){return this.#l}get size(){return this.#n.size}get historyWindow(){return this.#f}observe(h,a){const y=r(a);if(y===null)return;if(!this.#n.has(h)){this.#p=null,this.#m=null,this.#g(),this.#t.set(h,y),this.#n.set(h,y),this.#r.set(h,0),this.#s.set(h,this.#u()),this.#i.set(h,[y]),this.#f&&this.#d.set(h,[y]),this.#a.set(h,0);return}const f=this.#n.get(h);if(f===y)return;this.#p=null,this.#m=null,this.#n.set(h,y),this.#r.set(h,(this.#r.get(h)||0)+1),this.#s.set(h,this.#u());const m=this.#i.get(h)||[];m.push(y),m.length>this.#o&&m.splice(0,m.length-this.#o),this.#i.set(h,m);const w=Math.sign(y-f),S=this.#a.get(h)||0;this.#a.set(h,Math.sign(S)===w?S+w:w)}#g(){if(this.#n.size<this.#c)return;const h=this.#n.keys().next().value;h!==void 0&&(this.#t.delete(h),this.#n.delete(h),this.#r.delete(h),this.#s.delete(h),this.#i.delete(h),this.#d.delete(h),this.#a.delete(h),this.#l++)}rebase(){for(const[h,a]of this.#n)this.#t.set(h,a);this.#p=null,this.#m=null}reset(){this.#t.clear(),this.#n.clear(),this.#r.clear(),this.#s.clear(),this.#i.clear(),this.#d.clear(),this.#a.clear(),this.#l=0,this.#p=null,this.#m=null,this.#f&&(this.#h=Math.floor(this.#u()/this.#f.bucketMs))}retain(h){const a=h instanceof Set?h:new Set(h);let y=0;for(const f of[...this.#n.keys()])a.has(f)||(this.#t.delete(f),this.#n.delete(f),this.#r.delete(f),this.#s.delete(f),this.#i.delete(f),this.#d.delete(f),this.#a.delete(f),y++);return y&&(this.#p=null,this.#m=null),y}advanceHistoryWindow(h=this.#u()){const a=this.#f;if(!a)return 0;const y=Math.floor(h/a.bucketMs),f=y-this.#h;if(!(f>0))return 0;const m=Math.min(f,this.#o);for(const[w,S]of this.#d){const M=this.#n.get(w);for(let X=0;X<m;X++)S.push(M);S.length>this.#o&&S.splice(0,S.length-this.#o)}return this.#h=y,f}read(h,a,y,f){switch(h){case"updates":return this.#r.has(a)?this.#r.get(a):0;case"updatedAt":{const m=this.#s.get(a);return m===void 0?null:new Date(m)}case"sinceUpdate":{const m=this.#s.get(a);return m===void 0?null:this.#u()-m}case"firstValue":return this.#t.has(a)?this.#t.get(a):null;case"delta":return this.#n.has(a)?this.#n.get(a)-this.#t.get(a):null;case"deltaPercent":{if(!this.#n.has(a))return null;const m=this.#t.get(a);return m?(this.#n.get(a)-m)/Math.abs(m)*100:null}case"rate":{const m=this.#i.get(a),w=this.#s.get(a);if(!m||m.length<2||w===void 0)return null;const S=this.#u()-w,M=m[m.length-1]-m[m.length-2];return S>0?M/S*1e3:M}case"history":return this.#f?this.#d.has(a)?[...this.#d.get(a)]:null:this.#i.has(a)?[...this.#i.get(a)]:null;case"streak":return this.#a.has(a)?this.#a.get(a):0;case"specStatus":return this.#n.has(a)?t(this.#n.get(a),f):null;default:return g.includes(h)?this.#S(h,a,y,f):null}}#b(h){if(h){if(this.#m&&this.#m.only===h)return this.#m.view;const a=this.#y(h);return this.#m={only:h,view:a},a}return this.#p?this.#p:(this.#p=this.#y(null),this.#p)}#y(h){const a=[];for(const[P,k]of this.#n)h&&!h.has(P)||a.push(k);const y=a.sort((P,k)=>P-k);let f=0,m=0,w=0,S=0;for(const P of y){S+=P,f++;const k=P-m;m+=k/f,w+=k*(P-m)}const M=[];for(const[P,k]of this.#t)h&&!h.has(P)||M.push(k);const X=f?u(y):0,q=y.map(P=>Math.abs(P-X)).sort((P,k)=>P-k),K=f?u(q):0;return{sorted:y,baseline:M.sort((P,k)=>P-k),sum:S,mean:f?m:0,sd:f>1?Math.sqrt(w/(f-1)):0,median:X,mad:K}}#S(h,a,y,f){if(!this.#n.has(a)||y&&!y.has(a))return null;const m=this.#n.get(a),w=this.#b(y),S=w.sorted.length;if(!S)return null;switch(h){case"rank":return S-p(w.sorted,m)+1;case"rankAsc":return n(w.sorted,m)+1;case"rankChange":{if(!this.#t.has(a)||!w.baseline.length)return null;const M=w.baseline.length-p(w.baseline,this.#t.get(a))+1,X=S-p(w.sorted,m)+1;return M-X}case"percentile":return p(w.sorted,m)/S*100;case"quartile":{const M=p(w.sorted,m)/S;return Math.min(4,Math.max(1,Math.ceil(M*4)))}case"zScore":return w.sd?(m-w.mean)/w.sd:null;case"anomalyScore":return w.mad?v*(m-w.median)/w.mad:null;case"anomalyFlag":{if(!w.mad)return null;const M=f&&Number.isFinite(Number(f.threshold))?Number(f.threshold):b;return Math.abs(v*(m-w.median)/w.mad)>M}case"shareOfTotal":return w.sum?m/w.sum*100:null;default:return null}}}function u(d){const h=d.length;if(!h)return 0;const a=(h-1)*.5,y=Math.floor(a),f=Math.ceil(a);return y===f?d[y]:d[y]+(a-y)*(d[f]-d[y])}function n(d,h){let a=0,y=d.length;for(;a<y;){const f=a+y>>1;d[f]<h?a=f+1:y=f}return a}function p(d,h){let a=0,y=d.length;for(;a<y;){const f=a+y>>1;d[f]<=h?a=f+1:y=f}return a}function r(d){if(d==null||d==="")return null;if(d instanceof Date){const a=d.getTime();return Number.isFinite(a)?a:null}const h=typeof d=="number"?d:Number(d);return Number.isFinite(h)?h:null}function i(d){const h=[];for(const a of d||[]){const y=a.shadow;if(!y)continue;const f=typeof y=="string"?{kind:y}:y,m=f.kind;L.includes(m)&&(Y.includes(m)||_.includes(m)||O.includes(m)||h.push({colId:a.id||a.field,of:f.of||a.field||a.id,kind:m,depth:f.depth,historyWindow:m==="history"?f.window:void 0}))}return h}}),ze("packages/core/src/columns/model.js",function(e,B){"use strict";Object.defineProperty(e,"BUILTIN_DEFAULTS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"normaliseAlign",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"normaliseVAlign",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"expandColumn",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"ColumnModel",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(e,"flattenTree",{enumerable:!0,get:function(){return Oe}});const ne=B("packages/core/src/internal/merge.js"),A=ne.expand,V=ne.merge,U=ne.toArray,I=B("packages/core/src/internal/warn.js"),J=I.fail,H=I.warnOnce,L=B("packages/core/src/internal/paths.js"),Y=L.getPath,_=L.pathGetter,O=L.pathSetter,b=B("packages/core/src/internal/text.js").humanise,c=B("packages/core/src/internal/predicates.js"),g=c.isFunction,o=c.isObject,s=B("packages/core/src/internal/uid.js").uid,u=B("packages/core/src/format/index.js").compileFormat,n=B("packages/core/src/columns/datatypes.js"),p=n.comparatorFor,r=n.createTypeRegistry,i=n.storageKind,d=B("packages/core/src/columns/infer.js"),h=d.inferColumnType,a=d.DEFAULT_SAMPLE,y=B("packages/core/src/columns/graph.js"),f=y.buildGraph,m=y.affectedBy,S=B("packages/core/src/columns/lookup.js").createLookup,M=B("packages/core/src/columns/value.js"),X=M.compileDisplay,q=M.ValuePipeline,K=M.warnImpureUse,P=B("packages/core/src/model/shadow.js"),k=P.FIT_SHADOW_KINDS,E=P.CLUSTER_SHADOW_KINDS,C=Object.freeze({geometry:"geometry",list:"list"}),x={value:{pure:!0},cell:{},edit:{enabled:!1},sort:{enabled:!0,direction:null,order:0,nullsFirst:!1},filter:{enabled:!0,type:"text"},group:{enabled:!1,index:-1,explode:!1},pivot:{enabled:!1,index:-1},total:null,layout:{width:150,min:40,max:null,flex:0,pin:null,hidden:!1,resizable:!0,movable:!0,lockVisible:!1,lockPosition:!1},header:{},facet:{},export:{lookup:"label",csv:!0,excel:!0},allowGroup:!0,allowPivot:!0,allowTotal:!0,nullable:!0,quickFilter:!0},j={centre:"center"},T=new Set(["start","center","end","left","right"]);function F(fe){if(typeof fe!="string")return;const ae=fe.toLowerCase();return j[ae]?j[ae]:T.has(ae)?ae:void 0}function $(fe){if(typeof fe!="string")return;const ae=fe.toLowerCase();return ae==="center"||ae==="centre"?"middle":ae==="top"||ae==="middle"||ae==="bottom"?ae:void 0}const D=["cell","layout","header"];function z(fe){if(!o(fe))return{};const ae={...fe},ke=(pe,ue)=>{if(fe[pe]===void 0)return;const we=A(fe[pe],ue);we&&D.includes(pe)&&!o(fe[pe])&&delete we.enabled,ae[pe]=we};return ke("sort","direction"),ke("filter","type"),ke("cell","render"),ke("edit","editor"),ke("layout","width"),ke("group","index"),ke("pivot","index"),ke("header","render"),ke("facet","strategy"),ae}function G(fe,ae){const ke={...fe||{}},pe=o(ae)&&o(ae.layout)&&ae.layout.width!==void 0;return ke.fit==="content"&&!pe&&delete ke.width,ke}const N=new Set(["allowGroup","allowPivot","allowTotal","cell","colSpan","contextMenu","diff","edit","export","facet","field","filter","filterRow","format","grandTotal","group","groupTotal","header","headerControls","id","layout","lookup","nullable","pivot","preset","quickFilter","rowSpan","running","shadow","showWhen","sort","spec","tags","title","total","type","typeOptions","validation","value","verticalAlign"]),Z=new Set(["collapsible","columns","facet","header","id","marryChildren","openByDefault","showWhen","title"]);function Q(fe,ae,ke,pe){const ue=ke==="columnGroup"?"column group":"column";for(const we of Object.keys(fe))if(!ae.has(we)){if(we==="timeZone"&&ke==="column"){H("column.timeZone",`\`timeZone\` is not a column option, so it had no effect on column "${pe}". A date column stores, displays, sorts and filters in the grid-level \`timeZone\` (else the viewer's); set \`timeZone\` on the grid, not the column.`);continue}H(`${ke}.unknown:${we}`,`'${we}' is not a configuration key this grid recognises, so it had no effect on ${ue} "${pe}". Check the spelling against the reference.`)}}function ee(fe){o(fe.cell)&&fe.cell.autoHeight!==void 0&&H("column.cell.autoHeight",`\`cell.autoHeight\` is not a column option, so it had no effect on column "${fe.id||fe.field||"(unnamed)"}". Rows grow to fit with the grid-level \`autoHeight\`; \`cell.wrap\` lets this column's text wrap.`)}function re(fe,ae){const ke=ae&&g(fe.defaultsFor)?fe.defaultsFor(ae):null,pe={...fe.defaults||{},...o(ke)?ke:{}},ue={};return pe.align&&(ue.align=pe.align,ue.cell={align:pe.align},ue.header={align:pe.align}),pe.filter&&(ue.filter=pe.filter==="none"?{enabled:!1,type:"none"}:{enabled:!0,type:pe.filter}),pe.editor&&(ue.edit=pe.editor==="none"?{editor:null}:{editor:pe.editor}),pe.total&&(ue.total=pe.total),pe.render&&(ue.cell={...ue.cell||{},render:pe.render}),fe.export&&(ue.export={...fe.export}),ue}function ie(fe){if(typeof fe=="string")return fe.trim()?[fe.trim()]:[];if(!Array.isArray(fe))return[];const ae=[];for(const ke of fe){if(typeof ke!="string")continue;const pe=ke.trim();pe&&!ae.includes(pe)&&ae.push(pe)}return ae}class ce{#e=new Map;#t=[];#n=[];#r=new WeakMap;#s;#i;#a;#l;#o;#c;#u(ae,ke,pe){if(ae&&typeof ae=="object"&&!g(ae)){const Ne=ae;return(typeof Ne.fn!="string"||!Ne.fn)&&J(`column "${pe}": a total given as an object needs a \`fn\` name, such as { fn: 'percentile', p: 0.9 }.`),Ne.fn==="percentile"&&!(typeof Ne.p=="number"&&Ne.p>=0&&Ne.p<=1)&&J(`column "${pe}": { fn: 'percentile' } needs \`p\`, a number from 0 to 1 (0.9 for the 90th percentile).`),this.#f(Ne.fn,ke,pe),Object.freeze({...Ne})}const ue=this.#f(ae,ke,pe);if(typeof ue!="string"||!this.#d)return ue??null;const we=ke&&ke.totals&&ke.totals.implement;if(we&&g(we[ue])){const Ne=we[ue];return Ne.totalName=ue,Ne}const Te=this.#d.totalFn?.(ue);return g(Te)?Te:ue}#f(ae,ke,pe){if(typeof ae!="string")return ae;const ue=ke&&ke.totals&&ke.totals.supported;if(!Array.isArray(ue)||ue.includes(ae))return ae;const we=ue.length?ue.join(", "):"none";return J(`column "${pe}" is typed ${ke.name||"a type"}, for which the total "${ae}" is not meaningful. Supported: ${we}. Aggregating it anyway would produce a confident wrong number.`),ae}#d;#h;#p;#m;#g;#b;#y=!1;#S;#w;constructor(ae={}){this.#i=z(ae.columnDefaults||{}),this.#a=ae.columnPresets||{},this.#o=ae.locale,this.#l=ae.timeZone,this.#c=$(ae.verticalAlign),this.#d=ae.registry||null,this.#h=ae.grid||null,this.#p=ae.context,this.#S=ae.sampleSize??a,this.#w=ae.onChange||null,this.#b=g(ae.rowKey)?ae.rowKey:void 0,this.#s=r(ae.dataTypes,this.#d);const{leaves:ke,groups:pe}=Oe(ae.columns||[]);this.#n=pe;for(const ue of ke){ue.facet!==void 0&&this.#r.set(ue.def,ue.facet);const we=this.#A(ue.def,null);if(we.groupPath=ue.path,this.#e.has(we.id)){H(`columns.duplicate:${we.id}`,`two columns resolve to the id '${we.id}', so the second is ignored. An id defaults to the column's field, so declare an explicit \`id\` when two columns read the same field.`);continue}ue.column=we,this.#e.set(we.id,we),this.#t.push(we.id)}this.#P(ae.stored||null)}#A(ae,ke){Q(ae,N,"column",ae.id||ae.field||"(unnamed)"),ee(ae);const pe=z(ae),ue=U(ae.preset),we=ue.map(Ie=>{const We=this.#a[Ie];return We?z(We):(H(`preset:${Ie}`,`unknown column preset "${Ie}"; ignoring`),{})}),Te=this.#O(pe,we,ke),Ne=this.#s.get(Te)||this.#s.get("text");if(!this.#s.has(Te)&&ae.type){const Ie=C[Te];H(`type:${Te}`,`unknown data type "${Te}"; falling back to "text"`+(Ie?`. It is registered by importing '@toclocoinc/lattice-grid/modules/${Ie}'.`:""))}const _e=g(Ne.items)?this.#C(pe,we,ae.id||ae.field||"(unnamed)"):null;let $e=x;$e=V($e,this.#i),ae.type!==!1&&($e=V($e,re(Ne,_e)));for(const Ie of we)$e=V($e,Ie);this.#r.has(ae)&&($e=V($e,z({facet:this.#r.get(ae)}))),$e=V($e,pe);const je=$e.edit;je&&je.editor&&je.enabled!==!0&&!g(je.enabled)&&(ae.edit||{}).editor&&H(`column.editor-not-enabled:${ae.id||ae.field}`,`column '${ae.id||ae.field}' names the editor '${je.editor}' but does not enable editing, so it stays read-only. Add \`enabled: true\`, or use \`edit: true\` and set \`editor\` alongside it.`);const Ge=ae.id||ae.field||s("col");if(ae.shadow&&!g($e.value&&$e.value.compute)){const Ie=typeof ae.shadow=="string"?{kind:ae.shadow}:ae.shadow,We=Ie.of||ae.field||Ge,Ye=k.includes(Ie.kind),nt=E.includes(Ie.kind),Qe=Ye?Ie.model||Ie:null,dt=Ye&&Qe?[...Array.isArray(Qe.predictors)?Qe.predictors:[],Qe.response].filter(Boolean):null,jt=nt?(Array.isArray(Ie.columns)?Ie.columns:[]).filter(Boolean):null;$e.value={...$e.value||{},deps:jt&&jt.length?jt:dt&&dt.length?dt:Ie.orderBy&&Ie.orderBy!==We?[We,Ie.orderBy]:[We],pure:!1,compute:(Et,it)=>{const ft=it.grid&&it.grid.statistics;if(!ft)return null;const pt=it.row&&it.row.key||ft.keyOf(it.data);if(!pt)return null;if(Ye){if(!g(ft.fitShadow))return null;const Tt=Ie.model?{...Ie.model,threshold:Ie.threshold}:Ie;return ft.fitShadow(Ie.kind,pt,Tt)}return nt?g(ft.clusterShadow)?ft.clusterShadow(Ie.kind,pt,Ie):null:ft.shadow(We,Ie.kind,pt,Ie.scope,Ie)}}}if(ae.running&&!g($e.value&&$e.value.compute)){const Ie=typeof ae.running=="string"?{kind:ae.running}:ae.running,We=Ie.of||ae.field||Ge;$e.value={...$e.value||{},deps:[We],pure:!1,compute:(Ye,nt)=>{const Qe=nt.grid&&nt.grid.statistics;if(!Qe||!g(Qe.running))return null;const dt=nt.row&&nt.row.key||Qe.keyOf(nt.data);return dt?Qe.running(We,Ie.kind||"total",dt):null}},ae.sort===void 0&&($e.sort={...$e.sort||{},enabled:!1})}const Fe=ae.field??(g($e.value&&$e.value.compute)?null:ae.id??null),Pe=g($e.value&&$e.value.compute),Ee={id:Ge,field:Fe,shadow:ae.shadow||null,running:ae.running||null,spec:ae.spec||null,validation:ae.validation||null,volatile:!!(ae.shadow||ae.running),title:$e.title??b(Fe||Ge),type:Ne.name,dataType:Ne,itemType:_e,nullable:$e.nullable!==!1,align:F(pe.cell&&pe.cell.align||pe.align||$e.cell&&$e.cell.align||$e.align||Ne.defaults&&Ne.defaults.align)||"start",verticalAlign:$(pe.cell&&pe.cell.verticalAlign||pe.verticalAlign||$e.cell&&$e.cell.verticalAlign||$e.verticalAlign)||this.#c,rowSpan:g($e.rowSpan)?$e.rowSpan:null,colSpan:g($e.colSpan)?$e.colSpan:null,value:{pure:!0,...$e.value||{}},cell:{...$e.cell||{}},edit:{...$e.edit||{}},sort:{...$e.sort||{}},filter:{...$e.filter||{}},group:{enabled:!1,index:-1,explode:!1,...$e.group||{}},pivot:{enabled:!1,index:-1,...$e.pivot||{}},total:this.#u($e.total,Ne,ae.id||ae.field||"(unnamed)"),groupTotal:$e.groupTotal===void 0?null:this.#u($e.groupTotal,Ne,ae.id||ae.field||"(unnamed)"),grandTotal:$e.grandTotal===void 0?null:this.#u($e.grandTotal,Ne,ae.id||ae.field||"(unnamed)"),tags:ie($e.tags),typeOptions:$e.typeOptions??null,...o($e[Te])?{[Te]:$e[Te]}:{},layout:G($e.layout,pe),header:{...$e.header||{}},contextMenu:$e.contextMenu===void 0?null:$e.contextMenu,facet:{...$e.facet||{}},export:{...$e.export||{}},allowGroup:$e.allowGroup!==!1,allowPivot:$e.allowPivot!==!1,allowTotal:$e.allowTotal!==!1,quickFilter:$e.quickFilter!==!1,def:ae,format:$e.format,presets:ue,inferred:ke!=null&&!ae.type,computed:Pe,diff:ae.diff===void 0?void 0:!!ae.diff,read:Fe?_(Fe):null,write:Fe?O(Fe):null};Ee.cell.align=F(pe.cell&&pe.cell.align)||Ee.align,Ee.header.align=F(pe.header&&pe.header.align)||Ee.align;const Me=$e.lookup||null;return Ee.lookup=Me?S({id:Ge,lookup:Me},{locale:this.#o,onChange:()=>{this.#w&&this.#w("lookup",{colId:Ge})}}):null,Ee.group.explode&&Ee.lookup&&Ee.lookup.multiple&&H(`explode:${Ge}`,`column "${Ge}" has \`group.explode\`, so rows appear under each of their values and totals double-count. Group footers should be annotated accordingly.`),this.#v(Ee),Ee}#v(ae){ae.formatter=u(ae.format,ae.dataType,this.#o,this.#l,ae.id),ae.formatValue=X(ae,{locale:this.#o,grid:this.#h,context:this.#p}),ae.itemCompare=ae.itemType?p(ae.itemType,this.#o):null,ae.compare=g(ae.value.compare)?ae.value.compare:ae.lookup?ae.lookup.comparator():g(ae.dataType.compareFor)?ae.dataType.compareFor(ae):p(ae.dataType,this.#o),ae.excel=ae.formatter&&ae.formatter.ooxml||ae.dataType&&ae.dataType.excel||"General",ae.storeKind=i(ae.dataType,!!(ae.lookup&&ae.lookup.multiple))}#C(ae,ke,pe){let ue=o(ae.typeOptions)?ae.typeOptions:null;for(let _e=ke.length-1;!ue&&_e>=0;_e--)o(ke[_e].typeOptions)&&(ue=ke[_e].typeOptions);!ue&&o(this.#i.typeOptions)&&(ue=this.#i.typeOptions);const we=ue&&ue.of!==void 0?ue.of:"text",Te=typeof we=="string"?this.#s.get(we):void 0;return Te&&!g(Te.items)&&Te.storage!=="object"?Te:(H(`type:of:${String(we)}`,`column "${pe}" names "${String(we)}" as its item type (typeOptions.of), which is not ${Te?"a scalar data type":"a known data type"}; its items are read as text.`),this.#s.get("text"))}#O(ae,ke,pe){if(ae.type===!1)return"text";if(ae.type)return ae.type;for(let ue=ke.length-1;ue>=0;ue--)if(ke[ue].type)return ke[ue].type;if(this.#i.type)return this.#i.type;if(ae.shadow){const ue=typeof ae.shadow=="string"?ae.shadow:ae.shadow.kind;if(ue==="fitInfluence")return"boolean";if(ue==="fitPredicted"||ue==="fitResidual"||ue==="fitStdResidual"||ue==="fitLeverage"||ue==="fitCooksD"||ue==="tsTrend"||ue==="tsSeasonal"||ue==="tsResidual"||ue==="tsCoverage"||ue==="tsSmoothed"||ue==="tsSmoothingAlpha"||ue==="tsSmoothingBeta"||ue==="cluster"||ue==="clusterDistance")return"number"}return pe||(ae.lookup?"lookup":"text")}#P(ae){const ke=this.all();this.#m=f(ke),this.#g?this.#g.setGraph(this.#m):this.#g=new q({columns:this.#e,graph:this.#m,grid:this.#h,context:this.#p,stored:ae||null,rowKey:this.#b});const pe=this.#g;for(const ue of ke)ue.getValue=(we,Te)=>pe.value(ue,we,Te)}all(){return this.#t.map(ae=>this.#e.get(ae))}visible(){return this.all().filter(ae=>!ae.layout.hidden)}get(ae){return this.#e.get(ae)}groups(){const ae=ke=>{const pe=[];for(const ue of ke)Array.isArray(ue.columns)?pe.push({...ue,columns:ae(ue.columns)}):ue.column&&pe.push(ue.column);return pe};return ae(this.#n)}graph(){return this.#m}pipeline(){return this.#g}types(){return this.#s}affectedBy(ae){return m(this.#m,ae)}value(ae,ke,pe){return this.#g.value(ae,ke,pe)}text(ae,ke,pe){return this.#g.text(ae,ke,pe)}checkImpure(ae,ke){K(this.#e.get(ae),ke)}setLocale(ae){this.#o=ae;for(const ke of this.all())ke.lookup&&ke.lookup.setLocale(ae),this.#v(ke);this.#w&&this.#w("locale",{locale:ae})}infer(ae){const ke={};if(this.#y||!Array.isArray(ae)||ae.length===0)return ke;this.#y=!0;let pe=!1;for(const ue of this.all()){const we=ue.def;if(we.type!==void 0||!ue.field||ue.computed||ue.lookup||this.#E(ue))continue;const Te=ue.read||($e=>Y($e,ue.field)),Ne=h(ue.id,ae,Te,this.#s,{sampleSize:this.#S});if(Ne===ue.type)continue;ke[ue.id]=Ne;const _e=this.#A(we,Ne);_e.groupPath=ue.groupPath,_e.layout={..._e.layout,...ve(ue.layout)},this.#e.set(ue.id,_e),Le(this.#n,ue.id,_e),pe=!0}return pe&&this.#P(null),ke}redecorate(ae,ke,pe={}){const ue=this.#e.get(ae);if(!ue){H(`redecorate:${ae}`,`columns.decorate('${ae}', …): no column with id '${ae}'.`);return}const we=ue.def||{},Te={...o(we.cell)?we.cell:{}};Te.decoration=ke??void 0,pe&&"variant"in pe&&(Te.variant=pe.variant);const Ne={...we,cell:Te};this.#r.has(we)&&this.#r.set(Ne,this.#r.get(we));const _e=this.#A(Ne,ue.type);return _e.groupPath=ue.groupPath,_e.layout={..._e.layout,...ve(ue.layout)},ue.lookup&&ue.lookup!==_e.lookup&&g(ue.lookup.destroy)&&ue.lookup.destroy(),this.#e.set(ae,_e),Le(this.#n,ae,_e),this.#P(null),this.#w&&this.#w("decorate",{colId:ae}),_e}destroy(){for(const ae of this.#e.values())ae.lookup&&g(ae.lookup.destroy)&&ae.lookup.destroy()}#E(ae){for(const ke of ae.presets){const pe=this.#a[ke];if(pe&&pe.type)return!0}return!!this.#i.type}#T(ae){return!ae.computed&&g(ae.dataType&&ae.dataType.toStorage)}storeReader(ae){if(ae.computed)return ke=>this.#g.value(ae,ke,null);if(this.#T(ae)){const ke=ae.dataType.toStorage,pe=ae.format&&typeof ae.format=="object"&&!Array.isArray(ae.format)?ae.format.locale:void 0,ue={timeZone:this.#l,colId:ae.id,itemType:ae.itemType||null,locale:pe||this.#o};return we=>ke(ae.read(we),ue)}return ae.read}storeValue(ae,ke){if(!(!ae||ae.computed)&&g(ae.read))return this.storeReader(ae)(ke)}storeSchema(){const ae=[];for(const ke of this.all()){if(ke.computed&&ke.value.pure===!1||!ke.computed&&!ke.field)continue;const pe=this.storeReader(ke);let ue=null;!ke.computed&&!this.#T(ke)&&typeof ke.field=="string"&&!ke.lookup&&(ue=ke.field);const we={id:ke.id,kind:ke.storeKind,nullable:ke.nullable,read:pe};ue!==null&&(we.field=ue),ke.lookup&&(we.dictionary=ke.lookup.dictionary()),ae.push(we)}return ae}state(){return this.all().map(ae=>({id:ae.id,width:ae.layout.width,flex:ae.layout.flex||void 0,hidden:!!ae.layout.hidden,headerWrap:ae.header?.wrap===!0?!0:void 0,headerOrientation:ae.header?.orientation==="vertical"?"vertical":void 0,pin:ae.layout.pin??null,sort:ae.sort.direction??null,sortIndex:ae.sort.direction?ae.sort.order??0:null,groupIndex:ae.group.enabled?ae.group.index??0:null,pivotIndex:ae.pivot.enabled?ae.pivot.index??0:null,total:typeof ae.total=="string"?ae.total:null,groupTotal:typeof ae.groupTotal=="string"?ae.groupTotal:void 0,grandTotal:typeof ae.grandTotal=="string"?ae.grandTotal:void 0,decoration:ae.cell&&ae.cell.decoration!=null?he(ae.cell.decoration):void 0,variant:ae.cell&&ae.cell.variant!=null?he(ae.cell.variant):void 0}))}applyState(ae,ke={}){const pe={applied:[],skipped:[]},ue=Array.isArray(ae)?ae:ae&&ae.columns||[],we=!Array.isArray(ae)&&ae&&ae.columnOrder||null;for(const Ne of ue){if(!Ne||!Ne.id){pe.skipped.push({key:"?",reason:"no id"});continue}let _e=this.#e.get(Ne.id);if(!_e){pe.skipped.push({key:Ne.id,reason:"unknown column"});continue}if(Object.hasOwn(Ne,"decoration")||Object.hasOwn(Ne,"variant")){const $e=_e.cell?_e.cell.decoration:void 0,je=Ne.decoration??null,Ge=Object.hasOwn(Ne,"variant"),Fe=Ge&&!ye(_e.cell?_e.cell.variant:void 0,Ne.variant);(!ye($e,je)||Fe)&&(this.redecorate(Ne.id,je,Ge?{variant:Ne.variant??void 0}:{}),_e=this.#e.get(Ne.id)||_e)}Ne.width!=null&&(_e.layout.width=Ne.width),Ne.flex!=null&&(_e.layout.flex=Ne.flex),Ne.hidden!=null&&(_e.layout.hidden=!!Ne.hidden),Ne.headerWrap!==void 0&&(_e.header.wrap=!!Ne.headerWrap),Ne.headerOrientation!==void 0&&(_e.header.orientation=Ne.headerOrientation==="vertical"?"vertical":"horizontal"),Ne.pin!==void 0&&(_e.layout.pin=Ne.pin),Ne.sort!==void 0&&(_e.sort.direction=Ne.sort),Ne.sortIndex!=null&&(_e.sort.order=Ne.sortIndex),Ne.groupIndex!=null&&(_e.group.enabled=!0,_e.group.index=Ne.groupIndex),Ne.pivotIndex!=null&&(_e.pivot.enabled=!0,_e.pivot.index=Ne.pivotIndex),Ne.total!==void 0&&(_e.total=Ne.total),Ne.groupTotal!==void 0&&(_e.groupTotal=Ne.groupTotal),Ne.grandTotal!==void 0&&(_e.grandTotal=Ne.grandTotal),pe.applied.push(Ne.id)}const Te=we||(ke&&ke.keepOrder?[]:ue.map(Ne=>Ne&&Ne.id).filter(Boolean));if(Te.length){const Ne=Te.filter($e=>this.#e.has($e)),_e=this.#t.filter($e=>!Ne.includes($e));this.#t=[...Ne,..._e]}return this.#w&&this.#w("state",pe),pe}move(ae,ke){this.#M(ae,ke)&&(this.#R(),this.#w&&this.#w("move",{id:ae,to:ke}))}reorder(ae){const ke={applied:[],skipped:[]},pe=[];let ue=0;for(const we of Array.isArray(ae)?ae:[]){const Te=ue++;this.#M(we,Te)&&(ke.applied.push(we),pe.push({id:we,to:Te}))}if(!pe.length)return ke;if(this.#R(),this.#w)for(const we of pe)this.#w("move",we);return ke}#M(ae,ke){const pe=this.#t.indexOf(ae);if(pe===-1||Math.max(0,Math.min(Number(ke)||0,this.#t.length-1))===pe)return!1;const we=this.#e.get(ae);if(we.layout.movable===!1||we.layout.lockPosition)return H(`move:${ae}`,`column "${ae}" is not movable; the move was ignored`),!1;const Te=this.#N(ae,ke);return Te?(H(`move.married:${Te}`,`band "${Te}" declares marryChildren, so its columns stay together; the move was ignored`),!1):(this.#t.splice(pe,1),this.#t.splice(Math.max(0,Math.min(ke,this.#t.length)),0,ae),!0)}#N(ae,ke){if(!this.#n||!this.#n.length)return null;const pe=this.#t.filter(Ne=>Ne!==ae),ue=Math.max(0,Math.min(ke,pe.length)),we=(Ne,_e)=>{if(Array.isArray(Ne.columns)){for(const je of Ne.columns)we(je,_e);return _e}const $e=Ne.column?Ne.column.id:Ne.id;return $e&&_e.push($e),_e},Te=Ne=>{for(const _e of Ne){if(!Array.isArray(_e.columns))continue;if(_e.marryChildren===!0){const je=we(_e,[]),Ge=je.includes(ae),Fe=je.map(Pe=>pe.indexOf(Pe)).filter(Pe=>Pe>=0);if(Fe.length){const Pe=Math.min(...Fe),Ee=Math.max(...Fe);if(Ge?ue<Pe||ue>Ee+1:ue>Pe&&ue<=Ee)return _e.id}}const $e=Te(_e.columns);if($e)return $e}return null};return Te(this.#n)}#R(){const ae=new Map(this.#t.map((ue,we)=>[ue,we])),ke=ue=>{if(!Array.isArray(ue.columns)){const Te=ue.column?ue.column.id:ue.id;return ae.has(Te)?ae.get(Te):1/0}let we=1/0;for(const Te of ue.columns)we=Math.min(we,ke(Te));return we},pe=ue=>{ue.sort((we,Te)=>ke(we)-ke(Te));for(const we of ue)Array.isArray(we.columns)&&pe(we.columns)};pe(this.#n)}#D(ae){const ke=pe=>{for(let ue=0;ue<pe.length;ue++){const we=pe[ue];if(Array.isArray(we.columns)){const Te=ke(we.columns);if(Te)return Te}else if(we.column&&we.column.id===ae)return pe.splice(ue,1)[0]}return null};return ke(this.#n)}#G(ae){const ke=[];for(let pe=ae.length-1;pe>=0;pe--){const ue=ae[pe];Array.isArray(ue.columns)&&(ke.push(...this.#G(ue.columns)),ue.columns.length===0&&(ke.push(ue.id),ae.splice(pe,1)))}return ke}#K(){const ae=(ke,pe,ue)=>{for(const we of ke)Array.isArray(we.columns)?ae(we.columns,[...pe,we.id]):we.column&&(we.column.groupPath=pe)};ae(this.#n,[])}#L(ae){const ke=new Set(ae),pe=this.#t.filter(Ne=>ke.has(Ne));if(!pe.length)return;const ue=Math.min(...pe.map(Ne=>this.#t.indexOf(Ne))),we=this.#t.slice(0,ue).filter(Ne=>!ke.has(Ne)),Te=this.#t.slice(ue).filter(Ne=>!ke.has(Ne));this.#t=[...we,...pe,...Te]}#q(ae){const ke=[],pe=ue=>{if(Array.isArray(ue.columns))for(const we of ue.columns)pe(we);else ue.column&&ke.push(ue.column.id)};return pe(ae),ke}#B(ae){const ke=pe=>{for(const ue of pe){if(!Array.isArray(ue.columns))continue;if(ue.id===ae)return{node:ue,parent:pe};const we=ke(ue.columns);if(we)return we}return null};return ke(this.#n)}groupColumns(ae,ke={}){const pe=U(ae).filter(_e=>this.#e.has(_e));if(!pe.length)return H("columns.group.empty","groupColumns was given no known column ids; nothing was grouped."),null;for(const _e of pe)if(this.#e.get(_e).layout.lockPosition)return H(`columns.group.locked:${_e}`,`column "${_e}" is position-locked and cannot be grouped.`),null;const ue=ke.groupId?this.#B(ke.groupId):null;if(ke.groupId&&!ue)return H(`columns.group.unknown:${ke.groupId}`,`no band "${ke.groupId}" to add to; nothing was grouped.`),null;let we=null;if(!ue&&ke.id!=null&&(we=String(ke.id),this.#B(we)||this.#e.has(we)))return H(`columns.group.idtaken:${we}`,`band id "${we}" is already in use; nothing was grouped.`),null;const Te=pe.map(_e=>this.#D(_e)).filter(Boolean);if(!Te.length)return null;let Ne;if(ue)ue.node.columns.push(...Te),Ne=ue.node.id;else{const _e={id:we||s("grp"),title:ke.title||"",collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!1,header:{},def:{},columns:Te},$e=Number.isInteger(ke.at)?Math.max(0,Math.min(ke.at,this.#n.length)):this.#n.length;this.#n.splice($e,0,_e),Ne=_e.id}return this.#G(this.#n),this.#L(pe),this.#K(),this.#R(),this.#w&&this.#w("columngroup",{action:"formed",groupId:Ne,ids:pe}),Ne}ungroupColumn(ae){const ke=this.#e.get(ae);if(!ke){H(`columns.ungroup.unknown:${ae}`,`no column "${ae}" to ungroup.`);return}const pe=ke.groupPath||[];if(!pe.length)return;const ue=pe[pe.length-1],we=this.#B(ue);if(!we)return;const Te=this.#D(ae);if(!Te)return;const Ne=we.parent.indexOf(we.node);we.parent.splice(Ne+1,0,Te);const _e=this.#G(this.#n),$e=this.#q(we.node);if($e.length){this.#L($e);const je=Math.max(...$e.map(Fe=>this.#t.indexOf(Fe))),Ge=this.#t.filter(Fe=>Fe!==ae);Ge.splice(je+1,0,ae),this.#t=Ge}this.#K(),this.#R(),this.#w&&this.#w("columngroup",{action:"removed",id:ae,dissolved:_e})}renameGroup(ae,ke){const pe=this.#B(ae);if(!pe){H(`columns.group.rename:${ae}`,`no band "${ae}" to rename.`);return}pe.node.title=String(ke??""),this.#w&&this.#w("columngroup",{action:"renamed",groupId:ae,title:pe.node.title})}dissolveGroup(ae){const ke=this.#B(ae);if(!ke){H(`columns.group.dissolve:${ae}`,`no band "${ae}" to dissolve.`);return}const pe=ke.parent.indexOf(ke.node);ke.parent.splice(pe,1,...ke.node.columns),this.#K(),this.#R(),this.#w&&this.#w("columngroup",{action:"dissolved",groupId:ae})}moveGroup(ae,ke){const pe=this.#B(ae);if(!pe){H(`columns.group.move:${ae}`,`no band "${ae}" to move.`);return}const ue=pe.parent,we=ue.indexOf(pe.node);we!==-1&&(ue.splice(we,1),ue.splice(Math.max(0,Math.min(ke,ue.length)),0,pe.node),this.#Y(),this.#K(),this.#w&&this.#w("columngroup",{action:"moved",groupId:ae,to:ke}))}#Y(){const ae=[],ke=ue=>{for(const we of ue)Array.isArray(we.columns)?ke(we.columns):we.column&&ae.push(we.column.id)};ke(this.#n);const pe=new Set(ae);this.#t=[...ae,...this.#t.filter(ue=>!pe.has(ue))]}groupTree(){const ae=pe=>pe.map(ue=>Array.isArray(ue.columns)?{id:ue.id,title:ue.title||"",collapsible:!!ue.collapsible,openByDefault:ue.openByDefault!==!1,columns:ae(ue.columns)}:ue.column?ue.column.id:null).filter(ue=>ue!==null),ke=ae(this.#n);return ke.some(pe=>pe&&typeof pe=="object")?ke:[]}applyGroupTree(ae){if(!Array.isArray(ae))return;const ke=new Set,pe=we=>{const Te=[];for(const Ne of we)if(Ne&&typeof Ne=="object"&&Array.isArray(Ne.columns)){const _e=pe(Ne.columns);if(!_e.length)continue;Te.push({id:Ne.id||s("grp"),title:Ne.title||"",collapsible:Ne.collapsible===!0,openByDefault:Ne.openByDefault!==!1,showWhen:"always",marryChildren:!1,header:{},def:{},columns:_e})}else if(typeof Ne=="string"){const _e=this.#e.get(Ne);_e&&!ke.has(Ne)&&(ke.add(Ne),Te.push({column:_e,path:[]}))}return Te},ue=pe(ae);for(const we of this.#t){if(ke.has(we))continue;const Te=this.#e.get(we);Te&&ue.push({column:Te,path:[]})}this.#n=ue,this.#K(),this.#R(),this.#w&&this.#w("columngroup",{action:"applied"})}show(ae){this.#z(ae,!1)}hide(ae){this.#z(ae,!0)}#z(ae,ke){const pe=[];for(const ue of U(ae)){const we=this.#e.get(ue);if(we){if(ke&&we.layout.lockVisible){H(`lockVisible:${ue}`,`column "${ue}" is \`layout.lockVisible\` and cannot be hidden`);continue}we.layout.hidden!==ke&&(we.layout.hidden=ke,pe.push(ue))}}pe.length&&this.#w&&this.#w("visible",{ids:pe,hidden:ke})}pin(ae,ke){const pe=this.#e.get(ae);pe&&(pe.layout.pin=ke??null,this.#w&&this.#w("pin",{id:ae,side:pe.layout.pin}))}pinMany(ae){const ke={};for(const[ue,we]of ae){const Te=this.#e.get(ue);Te&&(Te.layout.pin=we??null,ke[ue]=Te.layout.pin)}const pe=Object.keys(ke);pe.length&&this.#w&&this.#w("pin",{ids:pe,pins:ke})}#I(ae,ke){const pe=ae.layout.min??0,ue=ae.layout.max;let we=Math.max(pe,ke);return ue!=null&&(we=Math.min(ue,we)),ae.layout.width=we,ae.layout.flex=0,we}resize(ae,ke){const pe=this.#e.get(ae);if(!pe)return;if(pe.layout.resizable===!1){H(`resize:${ae}`,`column "${ae}" is not resizable; the resize was ignored`);return}const ue=this.#I(pe,ke);this.#w&&this.#w("resize",{id:ae,width:ue})}resizeMany(ae){const ke={};for(const[ue,we]of ae){const Te=this.#e.get(ue);if(Te){if(Te.layout.resizable===!1){H(`resize:${ue}`,`column "${ue}" is not resizable; the resize was ignored`);continue}ke[ue]=this.#I(Te,we)}}const pe=Object.keys(ke);pe.length&&this.#w&&this.#w("resize",{ids:pe,widths:ke})}}function ve(fe){const ae={};return fe.width!=null&&(ae.width=fe.width),fe.hidden!=null&&(ae.hidden=fe.hidden),fe.pin!==void 0&&(ae.pin=fe.pin),ae}function he(fe){if(fe===null||typeof fe!="object")return fe;try{return structuredClone(fe)}catch{}try{return JSON.parse(JSON.stringify(fe))}catch{return fe}}function ye(fe,ae){const ke=fe??null,pe=ae??null;if(ke===pe)return!0;if(ke===null||pe===null)return!1;if(typeof ke!="object"||typeof pe!="object")return ke===pe;try{return JSON.stringify(ke)===JSON.stringify(pe)}catch{return!1}}function Oe(fe){const ae=[],ke=(ue,we,Te)=>{const Ne=[];for(const _e of ue){if(!o(_e)){J("a column definition must be an object");continue}if(Array.isArray(_e.columns)){Q(_e,Z,"columnGroup",_e.title||_e.id||"(unnamed)");const $e={id:_e.id||s("grp"),title:_e.title||"",collapsible:_e.collapsible===!0,openByDefault:_e.openByDefault!==!1,showWhen:_e.showWhen||"always",marryChildren:_e.marryChildren===!0,header:_e.header||{},def:_e,columns:[]};$e.columns=ke(_e.columns,[...we,$e.id],_e.facet!==void 0?_e.facet:Te),Ne.push($e)}else{const $e={def:_e,path:we,facet:Te};ae.push($e),Ne.push($e)}}return Ne},pe=ke(fe,[],void 0);return{leaves:ae,groups:pe}}function Le(fe,ae,ke){for(const pe of fe){if(pe.columns){if(Le(pe.columns,ae,ke))return!0;continue}if(pe.column&&pe.column.id===ae)return pe.column=ke,!0}return!1}}),ze("packages/core/src/columns/autogroup.js",function(e,B){"use strict";Object.defineProperty(e,"AUTO_GROUP_ID",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"createAutoGroupColumn",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"warnOnAbsurdGrouping",{enumerable:!0,get:function(){return Y}});const A=B("packages/core/src/internal/warn.js").warnOnce,V="__lattice_group",U=240,I=.5;function J(_){const O=_.def&&_.def.layout;return(typeof O=="number"||O&&O.width!=null||_.def&&_.def.width!=null)&&Number.isFinite(_.layout.width)?_.layout.width:null}function H(_){const O=_.def&&_.def.layout;return!!(O&&O.min!=null)||_.def&&_.def.minWidth!=null}function L(_){const{columns:O,groupBy:v}=_,b=v.map(l=>O.get(l)).filter(Boolean),c=b.length?b.map(l=>l.title||l.id).join(" > "):"Group",g=b.find(l=>J(l)!=null),o=_.config&&_.config.autoGroupColumnWidth||(g?J(g):U);let t=g&&H(g)?g.layout.min:120;g&&!H(g)&&(t=Math.min(t,o));const s=g&&g.layout.max!=null?g.layout.max:null;return{id:V,field:null,title:c,type:"text",dataType:{base:"text"},nullable:!0,align:"start",generated:!0,value:{pure:!0},cell:{render:"group"},edit:{enabled:!1},sort:{enabled:!0,direction:null},filter:{enabled:!0},groupedIds:v.slice(),group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:o,min:t,max:s,pin:_.config&&_.config.autoGroupColumnPin||null,hidden:!1,resizable:!0,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(l,u){return u&&u.group?u.groupValue:null},formatValue(l,u){if(!u||!u.group)return"";if(u.grandTotal)return _.config&&_.config.grandTotalLabel||"Total";const n=b[Math.min(u.level||0,b.length-1)];return n&&typeof n.formatValue=="function"?n.formatValue(l,u):l==null?"":String(l)}}}function Y(_,O,v){!_.length||v<100||O<v*I||A(`grouping.cardinality:${_.join(",")}`,`grouping by ${_.join(", ")} produced ${O} groups for ${v} rows: nearly one group per row. Grouping a continuous value such as a percentage or a timestamp rarely reads usefully; consider a computed banding column.`)}}),ze("packages/core/src/columns/selectcolumn.js",function(e,B){"use strict";Object.defineProperty(e,"SELECT_COLUMN_ID",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"createSelectionColumn",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return U}});const ne="__lattice_select",A=44;function V(I){const J=I.selection||{},H=I.config&&I.config.selectionColumnWidth||A;return{id:ne,field:null,title:"",type:"boolean",dataType:{base:"boolean"},nullable:!1,align:"center",generated:!0,control:!0,value:{pure:!0},cell:{render:"checkbox",props:{mode:"selection"},align:"center"},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:H,min:H,max:H,pin:I.config&&I.config.selectionColumnPin||"start",hidden:!1,resizable:!1,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,headerCheckbox:J.headerCheckbox===!0,def:{},getValue(L,Y){return Y?Y.selected:!1},formatValue(){return""}}}const U=V}),ze("packages/core/src/columns/rownumbercolumn.js",function(e,B){"use strict";Object.defineProperty(e,"ROW_NUMBER_COLUMN_ID",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"createRowNumberColumn",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Y}});const A=B("packages/core/src/internal/predicates.js").isFunction,V="__lattice_rownumber",U=40,I=9,J=22;function H(_){const O=String(Math.max(1,Math.trunc(Math.abs(_))||1)).length;return Math.max(U,O*I+J)}function L(_){const O=_.rowNumbers,v=O&&typeof O=="object"?O:{},b=Number.isFinite(v.start)?v.start:1,c=Number.isFinite(v.width)?v.width:H((_.maxNumber||0)+b),g=A(_.rank)?_.rank:()=>null;return{id:V,field:null,title:typeof v.title=="string"?v.title:"",type:"number",dataType:{base:"number"},nullable:!0,align:"end",generated:!0,control:!0,value:{pure:!0},cell:{align:"end"},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:c,min:c,max:c,pin:"start",hidden:!1,resizable:v.width==null,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(o,t){const s=g(t);return s==null?null:s-1+b},formatValue(o){return o==null?"":String(o)}}}const Y=L}),ze("packages/core/src/model/detail.js",function(e,B){"use strict";Object.defineProperty(e,"DEFAULT_DETAIL_HEIGHT",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"DEFAULT_CACHE_LIMIT",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"resolveDetail",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"DetailModel",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Y}});const A=B("packages/core/src/internal/predicates.js").isFunction,U=B("packages/core/src/internal/warn.js").warnOnce,I=240,J=10;function H(_){if(!_)return null;const O=_===!0?{}:_;return O.enabled===!1?null:!A(O.rows)&&!O.render?(U("detail.rows","detail is enabled but neither `rows` nor `render` was supplied; expanding a master would show an empty region, so it stays off."),null):{render:O.render||null,config:O.config||null,rows:A(O.rows)?O.rows:null,height:O.height??I,maxHeight:O.maxHeight??null,cacheLimit:Number.isFinite(O.cacheLimit)?Math.max(0,O.cacheLimit):J,isMaster:A(O.isMaster)?O.isMaster:null,target:O.target||null,onCreate:A(O.onCreate)?O.onCreate:null,path:typeof O.path=="string"?O.path:null}}class L{#e;#t=new Set;#n;#r=0;constructor(O){this.#e=O.config,this.#n=A(O.onChange)?O.onChange:()=>{}}get config(){return this.#e}get inline(){return!this.#e.target}isMaster(O){if(!O||O.group||O.detail)return!1;const v=this.#e.isMaster;return v?!!v(O.data,O):!0}isOpen(O){return this.#t.has(O)}keys(){return[...this.#t]}activeKey(){for(const O of this.#t)return O;return null}heightOf(O){const v=this.#e.height;return A(v)?Number(v(O))||I:v==="auto"?I:Number(v)||I}open(O){return this.#t.has(O)?!1:(this.inline||this.#t.clear(),this.#t.add(O),this.#s(),!0)}close(O){return this.#t.delete(O)?(this.#s(),!0):!1}toggle(O){return this.#t.has(O)?(this.close(O),!1):(this.open(O),!0)}closeAll(){this.#t.size&&(this.#t.clear(),this.#s())}prune(O){if(!this.#t.size||!A(O))return;let v=!1;for(const b of[...this.#t])O(b)||(this.#t.delete(b),v=!0);v&&this.#s()}signature(){return`${this.#r}`}set(O){this.#t.clear();const v=Array.isArray(O)?O:[];for(const b of this.inline?v:v.slice(0,1))this.#t.add(b);this.#s()}#s(){this.#r++,this.#n()}}const Y=L}),ze("packages/core/src/compute/special.js",function(e,B){"use strict";Object.defineProperty(e,"logGamma",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"incompleteBeta",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"normalQuantile",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"normalCdf",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"studentT",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"studentTQuantile",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"regularizedGammaP",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"chiSquareCdf",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"chiSquareUpperTail",{enumerable:!0,get:function(){return o}});const ne=Object.freeze([676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23]),A=3e-12,V=1e-300;function U(t){if(t<.5)return Math.log(Math.PI/Math.sin(Math.PI*t))-U(1-t);const s=t-1;let l=.9999999999998099;const u=s+7.5;for(let n=0;n<ne.length;n++)l+=ne[n]/(s+n+1);return .5*Math.log(2*Math.PI)+(s+.5)*Math.log(u)-u+Math.log(l)}function I(t,s,l){const u=t+s,n=t+1,p=t-1;let r=1,i=1-u*l/n;Math.abs(i)<V&&(i=V),i=1/i;let d=i;for(let h=1;h<=300;h++){const a=2*h;let y=h*(s-h)*l/((p+a)*(t+a));i=1+y*i,Math.abs(i)<V&&(i=V),r=1+y/r,Math.abs(r)<V&&(r=V),i=1/i,d*=i*r,y=-(t+h)*(u+h)*l/((t+a)*(n+a)),i=1+y*i,Math.abs(i)<V&&(i=V),r=1+y/r,Math.abs(r)<V&&(r=V),i=1/i;const f=i*r;if(d*=f,Math.abs(f-1)<A)break}return d}function J(t,s,l){if(!(t>0)||!(s>0)||!Number.isFinite(l))return Number.NaN;if(l<=0)return 0;if(l>=1)return 1;const u=Math.exp(U(t+s)-U(t)-U(s)+t*Math.log(l)+s*Math.log(1-l));return l<(t+1)/(t+s+2)?u*I(t,s,l)/t:1-u*I(s,t,1-l)/s}function H(t){if(!(t>0)||!(t<1))return t===0?-1/0:t===1?1/0:Number.NaN;const s=[-39.69683028665376,220.9460984245205,-275.9285104469687,138.357751867269,-30.66479806614716,2.506628277459239],l=[-54.47609879822406,161.5858368580409,-155.6989798598866,66.80131188771972,-13.28068155288572],u=[-.007784894002430293,-.3223964580411365,-2.400758277161838,-2.549732539343734,4.374664141464968,2.938163982698783],n=[.007784695709041462,.3224671290700398,2.445134137142996,3.754408661907416],p=.02425;let r,i,d;t<p?(r=Math.sqrt(-2*Math.log(t)),d=(((((u[0]*r+u[1])*r+u[2])*r+u[3])*r+u[4])*r+u[5])/((((n[0]*r+n[1])*r+n[2])*r+n[3])*r+1)):t<=1-p?(r=t-.5,i=r*r,d=(((((s[0]*i+s[1])*i+s[2])*i+s[3])*i+s[4])*i+s[5])*r/(((((l[0]*i+l[1])*i+l[2])*i+l[3])*i+l[4])*i+1)):(r=Math.sqrt(-2*Math.log(1-t)),d=-(((((u[0]*r+u[1])*r+u[2])*r+u[3])*r+u[4])*r+u[5])/((((n[0]*r+n[1])*r+n[2])*r+n[3])*r+1));const a=(.5*L(-d/Math.SQRT2)-t)*Math.sqrt(2*Math.PI)*Math.exp(d*d/2);return d-a/(1+d*a/2)}function L(t){const s=Math.abs(t),l=2/(2+s),u=4*l-2,n=[-1.3026537197817094,.6419697923564902,.019476473204185836,-.00956151478680863,-.000946595344482036,.000366839497852761,42523324806907e-18,-20278578112534e-18,-1624290004647e-18,130365583558e-17,15626441722e-18,-85238095915e-18,6529054439e-18,5059343495e-18,-991364156e-18,-227365122e-18,96467911e-18,2394038e-18,-6886027e-18,894487e-18,313092e-18,-112708e-18,381e-18,7106e-18];let p=0,r=0,i;for(let h=n.length-1;h>0;h--)i=r,r=u*r-p+n[h],p=i;const d=l*Math.exp(-s*s+.5*(n[0]+u*r)-p);return t>=0?d:2-d}function Y(t){return .5*L(-t/Math.SQRT2)}function _(t,s){if(!(s>0)||!Number.isFinite(t))return Number.NaN;const l=.5*J(s/2,.5,s/(s+t*t));return t>0?1-l:l}function O(t,s){if(!(t>0)||!(t<1)||!(s>0))return Number.NaN;if(s>1e7)return H(t);let l=-1e4,u=1e4,n=H(t);const p=U(s/2)+U(.5)-U((s+1)/2);for(let r=0;r<60;r++){const i=_(n,s);i<t?l=n:u=n;const d=Math.exp(-((s+1)/2)*Math.log(1+n*n/s)-p)/Math.sqrt(s),h=d>0?(i-t)/d:0;if(Math.abs(h)<1e-12)break;const a=n-h;if(n=a>l&&a<u&&Number.isFinite(a)?a:(l+u)/2,u-l<1e-12)break}return n}function v(t,s){let l=t,u=1/t,n=u;for(let p=0;p<300&&(l+=1,n*=s/l,u+=n,!(Math.abs(n)<Math.abs(u)*A));p++);return u*Math.exp(-s+t*Math.log(s)-U(t))}function b(t,s){let l=s+1-t,u=1/V,n=1/l,p=n;for(let r=1;r<=300;r++){const i=-r*(r-t);l+=2,n=i*n+l,Math.abs(n)<V&&(n=V),u=l+i/u,Math.abs(u)<V&&(u=V),n=1/n;const d=n*u;if(p*=d,Math.abs(d-1)<A)break}return Math.exp(-s+t*Math.log(s)-U(t))*p}function c(t,s){return!(t>0)||!(s>=0)||!Number.isFinite(s)?Number.NaN:s===0?0:s<t+1?v(t,s):1-b(t,s)}function g(t,s){return s>0?c(s/2,t/2):Number.NaN}function o(t,s){const l=g(t,s);return Number.isNaN(l)?Number.NaN:Math.min(1,Math.max(0,1-l))}}),ze("packages/core/src/compute/linalg.js",function(e,B){"use strict";Object.defineProperty(e,"cholesky",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"choleskySolve",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"choleskyInverse",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"normalEquations",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"matVec",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"quadForm",{enumerable:!0,get:function(){return J}});function ne(H){const L=H.length,Y=Array.from({length:L},()=>new Array(L).fill(0));for(let _=0;_<L;_++)for(let O=0;O<=_;O++){let v=H[_][O];for(let b=0;b<O;b++)v-=Y[_][b]*Y[O][b];if(_===O){if(!(v>0))return null;Y[_][O]=Math.sqrt(v)}else Y[_][O]=v/Y[O][O]}return Y}function A(H,L){const Y=H.length,_=new Array(Y).fill(0);for(let v=0;v<Y;v++){let b=L[v];for(let c=0;c<v;c++)b-=H[v][c]*_[c];_[v]=b/H[v][v]}const O=new Array(Y).fill(0);for(let v=Y-1;v>=0;v--){let b=_[v];for(let c=v+1;c<Y;c++)b-=H[c][v]*O[c];O[v]=b/H[v][v]}return O}function V(H){const L=H.length,Y=Array.from({length:L},()=>new Array(L).fill(0));for(let _=0;_<L;_++){const O=new Array(L).fill(0);O[_]=1;const v=A(H,O);for(let b=0;b<L;b++)Y[b][_]=v[b]}return Y}function U(H,L,Y){const _=H.length,O=_?H[0].length:0,v=Array.from({length:O},()=>new Array(O).fill(0)),b=new Array(O).fill(0);for(let c=0;c<_;c++){const g=Y?Y[c]:1,o=H[c];for(let t=0;t<O;t++){const s=g*o[t];b[t]+=s*L[c];for(let l=t;l<O;l++)v[t][l]+=s*o[l]}}for(let c=0;c<O;c++)for(let g=0;g<c;g++)v[c][g]=v[g][c];return{xtwx:v,xtwy:b}}function I(H,L){return H.map(Y=>Y.reduce((_,O,v)=>_+O*L[v],0))}function J(H,L){let Y=0;for(let _=0;_<H.length;_++){let O=0;for(let v=0;v<H.length;v++)O+=L[_][v]*H[v];Y+=H[_]*O}return Y}}),ze("packages/core/src/compute/sketch.js",function(e,B){"use strict";Object.defineProperty(e,"Welford",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"Reservoir",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"hash32",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"HyperLogLog",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"SpaceSaving",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"KLL",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return v}});class ne{#e=0;#t=0;#n=0;static get errorBound(){return Object.freeze({kind:"exact",metric:"none",value:0,statement:"mean and variance match a full recompute to float rounding"})}get count(){return this.#e}add(c){if(!Number.isFinite(c))return;this.#e++;const g=c-this.#t;this.#t+=g/this.#e,this.#n+=g*(c-this.#t)}merge(c){if(c.#e===0)return;if(this.#e===0){this.#e=c.#e,this.#t=c.#t,this.#n=c.#n;return}const g=this.#e+c.#e,o=c.#t-this.#t;this.#t+=o*(c.#e/g),this.#n+=c.#n+o*o*(this.#e*c.#e/g),this.#e=g}mean(){return this.#e?this.#t:null}variance(){return this.#e>1?this.#n/(this.#e-1):null}varianceP(){return this.#e?this.#n/this.#e:null}stddev(){const c=this.variance();return c===null?null:Math.sqrt(c)}stddevP(){const c=this.varianceP();return c===null?null:Math.sqrt(c)}}class A{#e=[];#t=0;#n;#r;constructor(c,g=Math.random){if(!(c>0))throw new RangeError("reservoir capacity must be positive");this.#n=Math.floor(c),this.#r=g}static get errorBound(){return Object.freeze({kind:"probabilistic",metric:"none",value:0,statement:"uniform sample: each element included with probability capacity/n; sample statistics are unbiased estimators"})}get seen(){return this.#t}get size(){return this.#e.length}add(c){if(!Number.isFinite(c))return;if(this.#t++,this.#e.length<this.#n){this.#e.push(c);return}const g=Math.floor(this.#r()*this.#t);g<this.#n&&(this.#e[g]=c)}sample(){return this.#e.slice()}mean(){if(!this.#e.length)return null;let c=0;for(const g of this.#e)c+=g;return c/this.#e.length}quantile(c){const g=this.#e.length;if(!g)return null;const o=this.#e.slice().sort((u,n)=>u-n);if(g===1)return o[0];const t=(g-1)*Math.min(1,Math.max(0,c)),s=Math.floor(t),l=Math.ceil(t);return s===l?o[s]:o[s]+(t-s)*(o[l]-o[s])}}function V(b){return b^=b>>>16,b=Math.imul(b,2246822507),b^=b>>>13,b=Math.imul(b,3266489909),b^=b>>>15,b>>>0}function U(b){if(typeof b=="number"){const o=new DataView(new ArrayBuffer(8));return o.setFloat64(0,b===0?0:b),V(o.getUint32(0)^o.getUint32(4))}const c=typeof b=="string"?b:String(b);let g=2166136261;for(let o=0;o<c.length;o++)g^=c.charCodeAt(o),g=Math.imul(g,16777619);return V(g)}class I{#e;#t;#n;constructor(c=14){const g=Math.floor(c);if(g<4||g>16)throw new RangeError("HLL precision must be 4..16");this.#e=g,this.#t=1<<g,this.#n=new Uint8Array(this.#t)}static errorBoundFor(c=14){const g=1<<Math.floor(c),o=1.04/Math.sqrt(g);return Object.freeze({kind:"probabilistic",metric:"relative",value:o,statement:`distinct count within ~${(o*100).toFixed(2)}% relative standard error (m=${g} buckets)`})}errorBound(){return I.errorBoundFor(this.#e)}add(c){const g=U(c),o=g&this.#t-1,t=g>>>this.#e|1<<32-this.#e;let s=1,l=t;for(;(l&1)===0;)s++,l>>>=1;s>this.#n[o]&&(this.#n[o]=s)}count(){const c=this.#t,g=32-this.#e,o=new Float64Array(g+2);for(let l=0;l<c;l++)o[this.#n[l]]++;let t=c*L(1-o[g+1]/c);for(let l=g;l>=1;l--)t=.5*(t+o[l]);t+=c*H(o[0]/c);const s=J*c*c/t;return Math.round(s)}}const J=.5/Math.log(2);function H(b){if(b===1)return 1/0;let c=1,g=b,o;do b*=b,o=g,g+=b*c,c+=c;while(g!==o);return g}function L(b){if(b===0||b===1)return 0;let c=1,g=1-b,o;do b=Math.sqrt(b),o=g,c*=.5,g-=(1-b)**2*c;while(g!==o);return g/3}class Y{#e=new Map;#t;#n=0;constructor(c){if(!(c>0))throw new RangeError("Space-Saving capacity must be positive");this.#t=Math.floor(c)}errorBoundFor(c){const g=c/this.#t;return Object.freeze({kind:"deterministic",metric:"absolute",value:g,statement:`each count overestimates the truth by at most N/m = ${g.toFixed(2)} (N=${c}, m=${this.#t})`})}get seen(){return this.#n}add(c){this.#n++;const g=this.#e.get(c);if(g){g.count++;return}if(this.#e.size<this.#t){this.#e.set(c,{count:1,error:0});return}let o,t=1/0;for(const[s,l]of this.#e)l.count<t&&(t=l.count,o=s);this.#e.delete(o),this.#e.set(c,{count:t+1,error:t})}top(c=this.#t){return[...this.#e.entries()].map(([o,t])=>({item:o,count:t.count,error:t.error})).sort((o,t)=>t.count-o.count).slice(0,Math.max(0,Math.floor(c)))}}class _{#e;#t=[[]];#n=0;#r;#s;constructor(c=200,g=Math.random){this.#e=Math.max(8,Math.floor(c)),this.#r=g,this.#s=2/3}static errorBoundFor(c=200){const g=1/Math.max(8,Math.floor(c));return Object.freeze({kind:"probabilistic",metric:"rank",value:g,statement:`queried quantile's true rank within ~${(g*100).toFixed(2)}% of N of the requested rank (k=${c})`})}errorBound(){return _.errorBoundFor(this.#e)}get count(){return this.#n}#i(c){const o=this.#t.length-1-c,t=Math.ceil(this.#e*this.#s**o);return Math.max(2,t)}add(c){Number.isFinite(c)&&(this.#n++,this.#t[0].push(c),this.#t[0].length>=this.#i(0)&&this.#a(0))}#a(c){const g=this.#t[c];g.sort((s,l)=>s-l),c+1>=this.#t.length&&this.#t.push([]);const o=this.#t[c+1],t=this.#r()<.5?0:1;for(let s=t;s<g.length;s+=2)o.push(g[s]);this.#t[c]=[];for(let s=0;s<this.#t.length;s++)if(this.#t[s].length>=this.#i(s)){this.#a(s);return}}#l(){const c=[];for(let g=0;g<this.#t.length;g++){const o=1<<g;for(const t of this.#t[g])c.push({v:t,w:o})}return c}quantile(c){const g=this.#l();if(!g.length)return null;g.sort((l,u)=>l.v-u.v);let o=0;for(const l of g)o+=l.w;const t=Math.min(1,Math.max(0,c))*o;let s=0;for(const l of g)if(s+=l.w,s>=t)return l.v;return g[g.length-1].v}rank(c){let g=0;for(let o=0;o<this.#t.length;o++){const t=1<<o;for(const s of this.#t[o])s<=c&&(g+=t)}return g}}const O=Object.freeze({distinct:I.errorBoundFor(14),median:_.errorBoundFor(200),p25:_.errorBoundFor(200),p75:_.errorBoundFor(200),p90:_.errorBoundFor(200),p95:_.errorBoundFor(200),p99:_.errorBoundFor(200),iqr:_.errorBoundFor(200),topK:Object.freeze({kind:"deterministic",metric:"absolute",value:0,statement:"each count overestimates the truth by at most N/m; top-K exact when the K-th item exceeds N/m"})}),v={Welford:ne,Reservoir:A,HyperLogLog:I,SpaceSaving:Y,KLL:_,hash32:U,SKETCH_BOUNDS:O}}),ze("packages/core/src/compute/statistics.js",function(e,B){"use strict";Object.defineProperty(e,"KENDALL_LIMIT",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"MAINTENANCE",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"APPROXIMATE",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"maintenanceOf",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"numbers",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"frequencies",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"herfindahl",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"entropy",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"evenness",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"topShare",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"gini",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"moments",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"quantileSorted",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"quantile",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"STAT_FNS",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"STAT_LABELS",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"weightedAverage",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"extremeRow",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"correlation",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"trimmedMean",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"winsorizedMean",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"modifiedZOutliers",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"jarqueBera",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"weightedQuantile",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"pairs",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"covariance",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"regression",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"fitLinearModel",{enumerable:!0,get:function(){return ve}}),Object.defineProperty(e,"ADF_CT_CRITICAL",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(e,"augmentedDickeyFuller",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(e,"autocorrelations",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(e,"spearman",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(e,"kendall",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(e,"seriesStats",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(e,"D2_N2",{enumerable:!0,get:function(){return we}}),Object.defineProperty(e,"D4_N2",{enumerable:!0,get:function(){return Te}}),Object.defineProperty(e,"movingRanges",{enumerable:!0,get:function(){return Ne}}),Object.defineProperty(e,"withinSigma",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(e,"capability",{enumerable:!0,get:function(){return $e}}),Object.defineProperty(e,"controlLimits",{enumerable:!0,get:function(){return je}}),Object.defineProperty(e,"westernElectricViolations",{enumerable:!0,get:function(){return Ge}}),Object.defineProperty(e,"nelsonViolations",{enumerable:!0,get:function(){return Fe}}),Object.defineProperty(e,"CONTROL_RULE_SETS",{enumerable:!0,get:function(){return Pe}}),Object.defineProperty(e,"controlViolations",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(e,"countOutside",{enumerable:!0,get:function(){return Me}}),Object.defineProperty(e,"histogram",{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(e,"DEFAULT_CONFIDENCE",{enumerable:!0,get:function(){return We}}),Object.defineProperty(e,"meanInterval",{enumerable:!0,get:function(){return nt}}),Object.defineProperty(e,"proportionInterval",{enumerable:!0,get:function(){return Qe}}),Object.defineProperty(e,"slopeInterval",{enumerable:!0,get:function(){return dt}}),Object.defineProperty(e,"capabilityInterval",{enumerable:!0,get:function(){return jt}}),Object.defineProperty(e,"standardizedMeanDifference",{enumerable:!0,get:function(){return Et}}),Object.defineProperty(e,"normalTotalVariation",{enumerable:!0,get:function(){return it}}),Object.defineProperty(e,"frequencyMap",{enumerable:!0,get:function(){return ft}}),Object.defineProperty(e,"categoricalDistance",{enumerable:!0,get:function(){return pt}}),Object.defineProperty(e,"SUBSET_RELIABILITY_FLOOR",{enumerable:!0,get:function(){return Tt}}),Object.defineProperty(e,"compareColumn",{enumerable:!0,get:function(){return Nt}}),Object.defineProperty(e,"isNumericColumn",{enumerable:!0,get:function(){return Lt}}),Object.defineProperty(e,"populationRead",{enumerable:!0,get:function(){return Je}});const ne=B("packages/core/src/compute/handle.js"),A=ne.presenceReader,V=ne.valueReader,U=B("packages/core/src/compute/special.js"),I=U.studentTQuantile,J=U.studentT,H=U.normalQuantile,L=U.normalCdf,Y=U.chiSquareUpperTail,_=B("packages/core/src/compute/linalg.js"),O=_.cholesky,v=_.choleskySolve,b=_.choleskyInverse,c=_.normalEquations,g=_.quadForm,t=B("packages/core/src/compute/sketch.js").SKETCH_BOUNDS,s=5e3,l=Object.freeze({variance:"rescan",varianceP:"rescan",stddev:"rescan",stddevP:"rescan",sumSquares:"rescan",weightedAvg:"rescan",median:"rescan",percentile:"rescan",p25:"rescan",p75:"rescan",p90:"rescan",p95:"rescan",p99:"rescan",iqr:"rescan",mode:"rescan",distinct:"rescan",range:"rescan",skewness:"rescan",kurtosis:"rescan",geomean:"rescan",harmean:"rescan",mad:"rescan",argmin:"rescan",argmax:"rescan",hhi:"rescan",entropy:"rescan",evenness:"rescan",top3Share:"rescan",top10Share:"rescan",gini:"rescan",trimmedMean:"rescan",winsorizedMean:"rescan",robustOutliers:"rescan",jarqueBera:"rescan",passRate:"rescan",failureCount:"rescan"}),u=Object.freeze({distinct:Object.freeze({sketch:"HyperLogLog",bound:t.distinct}),median:Object.freeze({sketch:"KLL",bound:t.median}),p25:Object.freeze({sketch:"KLL",bound:t.p25}),p75:Object.freeze({sketch:"KLL",bound:t.p75}),p90:Object.freeze({sketch:"KLL",bound:t.p90}),p95:Object.freeze({sketch:"KLL",bound:t.p95}),p99:Object.freeze({sketch:"KLL",bound:t.p99}),iqr:Object.freeze({sketch:"KLL",bound:t.iqr}),top3Share:Object.freeze({sketch:"SpaceSaving",bound:t.topK}),top10Share:Object.freeze({sketch:"SpaceSaving",bound:t.topK})});function n(se){const ge=se==="sum"||se==="avg"||se==="countValues"||se==="min"||se==="max"?"maintained":Object.prototype.hasOwnProperty.call(l,se)?l[se]:null,Se=Object.prototype.hasOwnProperty.call(u,se)?u[se]:null;return{stat:se,exact:ge,approximate:Se}}function p(se,ge){const Se=ge.length,Re=new Float64Array(Se);let xe=0;if(se&&(se.kind==="float64"||se.kind==="int32")){const Ae=se.values,Ce=A(se);for(let De=0;De<Se;De++){const Ue=ge[De];if(Ce&&Ce(Ue)!==1)continue;const qe=Ae[Ue];Number.isNaN(qe)||(Re[xe++]=qe)}return Re.subarray(0,xe)}const de=V(se);for(let Ae=0;Ae<Se;Ae++){const Ce=de(ge[Ae]);if(Ce==null||Ce==="")continue;const De=typeof Ce=="number"?Ce:Number(Ce);Number.isFinite(De)&&(Re[xe++]=De)}return Re.subarray(0,xe)}function r(se,ge){const Se=new Map,Re=V(se);let xe=0;for(let de=0;de<ge.length;de++){const Ae=Re(ge[de]);if(Ae==null||Ae===""||typeof Ae=="number"&&Number.isNaN(Ae))continue;const Ce=typeof Ae=="object"?String(Ae):Ae;Se.set(Ce,(Se.get(Ce)||0)+1),xe++}const oe=[...Se.values()].sort((de,Ae)=>Ae-de);return{counts:oe,total:xe,distinct:oe.length}}function i(se){return se.total>0?se.counts.map(ge=>ge/se.total):[]}function d(se,ge){const Se=r(se,ge);if(!Se.total)return null;let Re=0;for(const xe of i(Se))Re+=xe*xe;return Re}function h(se,ge){const Se=r(se,ge);if(!Se.total)return null;let Re=0;for(const xe of i(Se))xe>0&&(Re-=xe*Math.log2(xe));return Re}function a(se,ge){const Se=r(se,ge);if(!Se.total||Se.distinct<2)return Se.total?1:null;let Re=0;for(const xe of i(Se))xe>0&&(Re-=xe*Math.log2(xe));return Re/Math.log2(Se.distinct)}function y(se,ge,Se=3){const Re=r(se,ge);if(!Re.total)return null;const xe=Math.max(1,Math.floor(Se));let oe=0;for(let de=0;de<Math.min(xe,Re.counts.length);de++)oe+=Re.counts[de];return oe/Re.total}function f(se,ge){const Se=p(se,ge),Re=Se.length;if(!Re)return null;const xe=Se.slice().sort();if(xe[0]<0)return null;let oe=0,de=0;for(let Ae=0;Ae<Re;Ae++)oe+=xe[Ae],de+=(Ae+1)*xe[Ae];return oe===0?0:2*de/(Re*oe)-(Re+1)/Re}function m(se){let ge=0,Se=0,Re=0;for(let xe=0;xe<se.length;xe++){const oe=se[xe];ge++;const de=oe-Se;Se+=de/ge,Re+=de*(oe-Se)}return{n:ge,mean:Se,m2:Re}}function w(se,ge){const Se=se.length;if(!Se)return NaN;if(Se===1)return se[0];const Re=(Se-1)*Math.min(1,Math.max(0,ge)),xe=Math.floor(Re),oe=Math.ceil(Re);return xe===oe?se[xe]:se[xe]+(Re-xe)*(se[oe]-se[xe])}function S(se,ge){if(!se.length)return NaN;const Se=se.slice().sort();return w(Se,ge)}function M(se,ge){const Se=V(se);let Re=0,xe=0,oe=0;for(let de=0;de<ge.length;de++){const Ae=Se(ge[de]);if(Ae==null||Ae==="")continue;const Ce=String(Ae).toUpperCase();Ce==="PASS"?Re++:Ce==="FAIL"?xe++:Ce==="WARN"&&oe++}return{pass:Re+oe,fail:xe,warn:oe,judged:Re+oe+xe}}const X=Object.freeze({hhi:(se,ge)=>d(se,ge),entropy:(se,ge)=>h(se,ge),evenness:(se,ge)=>a(se,ge),top3Share:(se,ge)=>y(se,ge,3),top10Share:(se,ge)=>y(se,ge,10),gini:(se,ge)=>f(se,ge),trimmedMean:(se,ge)=>E(p(se,ge),.1),winsorizedMean:(se,ge)=>C(p(se,ge),.1),robustOutliers:(se,ge)=>x(p(se,ge),3.5),jarqueBera:(se,ge)=>j(p(se,ge)),variance:(se,ge)=>{const{n:Se,m2:Re}=m(p(se,ge));return Se>1?Re/(Se-1):null},varianceP:(se,ge)=>{const{n:Se,m2:Re}=m(p(se,ge));return Se>0?Re/Se:null},stddev:(se,ge)=>{const{n:Se,m2:Re}=m(p(se,ge));return Se>1?Math.sqrt(Re/(Se-1)):null},stddevP:(se,ge)=>{const{n:Se,m2:Re}=m(p(se,ge));return Se>0?Math.sqrt(Re/Se):null},median:(se,ge)=>{const Se=p(se,ge);return Se.length?S(Se,.5):null},percentile:(se,ge,Se)=>{const Re=Se?Se.p:void 0;if(typeof Re!="number"||!(Re>=0&&Re<=1))return null;const xe=p(se,ge);return xe.length?S(xe,Re):null},p25:(se,ge)=>{const Se=p(se,ge);return Se.length?S(Se,.25):null},p75:(se,ge)=>{const Se=p(se,ge);return Se.length?S(Se,.75):null},p90:(se,ge)=>{const Se=p(se,ge);return Se.length?S(Se,.9):null},p95:(se,ge)=>{const Se=p(se,ge);return Se.length?S(Se,.95):null},p99:(se,ge)=>{const Se=p(se,ge);return Se.length?S(Se,.99):null},iqr:(se,ge)=>{const Se=p(se,ge);if(!Se.length)return null;const Re=Se.slice().sort();return w(Re,.75)-w(Re,.25)},mad:(se,ge)=>{const Se=p(se,ge);if(!Se.length)return null;const Re=S(Se,.5),xe=new Float64Array(Se.length);for(let oe=0;oe<Se.length;oe++)xe[oe]=Math.abs(Se[oe]-Re);return S(xe,.5)},range:(se,ge)=>{const Se=p(se,ge);if(!Se.length)return null;let Re=1/0,xe=-1/0;for(let oe=0;oe<Se.length;oe++)Se[oe]<Re&&(Re=Se[oe]),Se[oe]>xe&&(xe=Se[oe]);return xe-Re},distinct:(se,ge)=>{const Se=V(se),Re=new Set;for(let xe=0;xe<ge.length;xe++){const oe=Se(ge[xe]);oe==null||oe===""||Re.add(oe instanceof Date?oe.getTime():oe)}return Re.size},mode:(se,ge)=>{const Se=V(se),Re=new Map;for(let de=0;de<ge.length;de++){const Ae=Se(ge[de]);if(Ae==null||Ae==="")continue;const Ce=Ae instanceof Date?Ae.getTime():Ae;Re.set(Ce,(Re.get(Ce)||0)+1)}let xe=null,oe=1;for(const[de,Ae]of Re)Ae>oe&&(oe=Ae,xe=de);return xe},skewness:(se,ge)=>{const Se=p(se,ge),{n:Re,mean:xe,m2:oe}=m(Se);if(Re<3||oe<=0)return null;const de=Math.sqrt(oe/(Re-1));let Ae=0;for(let Ce=0;Ce<Se.length;Ce++)Ae+=((Se[Ce]-xe)/de)**3;return Re/((Re-1)*(Re-2))*Ae},kurtosis:(se,ge)=>{const Se=p(se,ge),{n:Re,mean:xe,m2:oe}=m(Se);if(Re<4||oe<=0)return null;const de=Math.sqrt(oe/(Re-1));let Ae=0;for(let Ue=0;Ue<Se.length;Ue++)Ae+=((Se[Ue]-xe)/de)**4;const Ce=Re*(Re+1)/((Re-1)*(Re-2)*(Re-3)),De=3*(Re-1)**2/((Re-2)*(Re-3));return Ce*Ae-De},geomean:(se,ge)=>{const Se=p(se,ge);if(!Se.length)return null;let Re=0;for(let xe=0;xe<Se.length;xe++){if(Se[xe]<=0)return null;Re+=Math.log(Se[xe])}return Math.exp(Re/Se.length)},harmean:(se,ge)=>{const Se=p(se,ge);if(!Se.length)return null;let Re=0;for(let xe=0;xe<Se.length;xe++){if(Se[xe]===0)return null;Re+=1/Se[xe]}return Se.length/Re},sumSquares:(se,ge)=>{const Se=p(se,ge);let Re=0;for(let xe=0;xe<Se.length;xe++)Re+=Se[xe]*Se[xe];return Re},passRate:(se,ge)=>{const{pass:Se,judged:Re}=M(se,ge);return Re?Se/Re:null},failureCount:(se,ge)=>M(se,ge).fail}),q=Object.freeze({hhi:"Concentration (HHI)",entropy:"Entropy",evenness:"Evenness",top3Share:"Top 3 share",top10Share:"Top 10 share",gini:"Gini coefficient",trimmedMean:"Trimmed mean",winsorizedMean:"Winsorized mean",robustOutliers:"Outliers (robust)",jarqueBera:"Jarque–Bera",median:"Median",percentile:"Percentile",p25:"25th percentile",p75:"75th percentile",p90:"90th percentile",p95:"95th percentile",p99:"99th percentile",iqr:"Interquartile range",mad:"Median absolute deviation",variance:"Variance",varianceP:"Variance (population)",stddev:"Standard deviation",stddevP:"Standard deviation (population)",range:"Range",distinct:"Distinct",mode:"Mode",skewness:"Skewness",kurtosis:"Kurtosis",geomean:"Geometric mean",harmean:"Harmonic mean",sumSquares:"Sum of squares",weightedAvg:"Weighted average",argmin:"Lowest by",argmax:"Highest by",passRate:"Pass rate",failureCount:"Failures"});function K(se,ge,Se){const Re=V(se),xe=V(ge);let oe=0,de=0;for(let Ae=0;Ae<Se.length;Ae++){const Ce=Se[Ae],De=Number(Re(Ce)),Ue=Number(xe(Ce));!Number.isFinite(De)||!Number.isFinite(Ue)||(oe+=De*Ue,de+=Ue)}return de===0?null:oe/de}function P(se,ge,Se){const Re=V(se);let xe=null,oe=Se?-1/0:1/0;for(let de=0;de<ge.length;de++){const Ae=ge[de],Ce=Number(Re(Ae));Number.isFinite(Ce)&&(Se?Ce>oe:Ce<oe)&&(oe=Ce,xe=Ae)}return xe}function k(se,ge,Se){const Re=V(se),xe=V(ge);let oe=0,de=0,Ae=0,Ce=0,De=0,Ue=0;for(let ot=0;ot<Se.length;ot++){const vt=Se[ot],Rt=Number(Re(vt)),At=Number(xe(vt));!Number.isFinite(Rt)||!Number.isFinite(At)||(oe++,de+=Rt,Ae+=At,Ce+=Rt*Rt,De+=At*At,Ue+=Rt*At)}if(oe<2)return null;const qe=oe*Ue-de*Ae,rt=Math.sqrt((oe*Ce-de*de)*(oe*De-Ae*Ae));if(rt===0)return null;const ct=qe/rt;return Math.max(-1,Math.min(1,ct))}function E(se,ge=.1){const Se=se.length;if(!Se)return null;const Re=Array.from(se).sort((Ae,Ce)=>Ae-Ce),xe=Math.floor(Se*Math.min(.49,Math.max(0,ge))),oe=Re.slice(xe,Se-xe);if(!oe.length)return w(Re,.5);let de=0;for(const Ae of oe)de+=Ae;return de/oe.length}function C(se,ge=.1){const Se=se.length;if(!Se)return null;const Re=Array.from(se).sort((Ce,De)=>Ce-De),xe=Math.floor(Se*Math.min(.49,Math.max(0,ge))),oe=Re[xe],de=Re[Se-1-xe];let Ae=0;for(const Ce of Re)Ae+=Math.min(de,Math.max(oe,Ce));return Ae/Se}function x(se,ge=3.5){if(!se.length)return null;const Re=Array.from(se).sort((Ce,De)=>Ce-De),xe=w(Re,.5),oe=Re.map(Ce=>Math.abs(Ce-xe)).sort((Ce,De)=>Ce-De),de=w(oe,.5);if(de===0)return null;let Ae=0;for(const Ce of Re)Math.abs(.6745*(Ce-xe)/de)>ge&&Ae++;return Ae}function j(se){const ge=se.length;if(ge<8)return null;let Se=0;for(const Ce of se)Se+=Ce;Se/=ge;let Re=0,xe=0,oe=0;for(const Ce of se){const De=Ce-Se;Re+=De*De,xe+=De*De*De,oe+=De*De*De*De}if(Re/=ge,xe/=ge,oe/=ge,Re===0)return null;const de=xe/Re**1.5,Ae=oe/(Re*Re)-3;return ge/6*(de*de+Ae*Ae/4)}function T(se,ge,Se){const Re=[];let xe=0;for(let Ce=0;Ce<se.length;Ce++){const De=Number(se[Ce]),Ue=Number(ge[Ce]);!Number.isFinite(De)||!Number.isFinite(Ue)||Ue<=0||(Re.push([De,Ue]),xe+=Ue)}if(!Re.length||xe<=0)return null;if(Re.sort((Ce,De)=>Ce[0]-De[0]),Re.length===1)return Re[0][0];const oe=[];let de=0;for(const[,Ce]of Re)oe.push((de+Ce/2)/xe),de+=Ce;const Ae=Math.max(0,Math.min(1,Se));if(Ae<=oe[0])return Re[0][0];if(Ae>=oe[oe.length-1])return Re[Re.length-1][0];for(let Ce=1;Ce<oe.length;Ce++){if(Ae>oe[Ce])continue;const De=oe[Ce]-oe[Ce-1],Ue=De>0?(Ae-oe[Ce-1])/De:0;return Re[Ce-1][0]+(Re[Ce][0]-Re[Ce-1][0])*Ue}return Re[Re.length-1][0]}function F(se,ge,Se){const Re=V(se),xe=V(ge),oe=new Float64Array(Se.length),de=new Float64Array(Se.length);let Ae=0;for(let Ce=0;Ce<Se.length;Ce++){const De=Se[Ce],Ue=Number(Re(De)),qe=Number(xe(De));!Number.isFinite(Ue)||!Number.isFinite(qe)||(oe[Ae]=Ue,de[Ae]=qe,Ae++)}return{xs:oe.subarray(0,Ae),ys:de.subarray(0,Ae),n:Ae}}function $(se,ge,Se,Re=!1){const{xs:xe,ys:oe,n:de}=F(se,ge,Se);if(de<2)return null;let Ae=0,Ce=0;for(let Ue=0;Ue<de;Ue++)Ae+=xe[Ue],Ce+=oe[Ue];Ae/=de,Ce/=de;let De=0;for(let Ue=0;Ue<de;Ue++)De+=(xe[Ue]-Ae)*(oe[Ue]-Ce);return De/(Re?de:de-1)}function D(se,ge,Se){const{xs:Re,ys:xe,n:oe}=F(se,ge,Se);if(oe<2)return null;let de=0,Ae=0;for(let Rt=0;Rt<oe;Rt++)de+=Re[Rt],Ae+=xe[Rt];de/=oe,Ae/=oe;let Ce=0,De=0,Ue=0;for(let Rt=0;Rt<oe;Rt++){const At=Re[Rt]-de,_t=xe[Rt]-Ae;Ce+=At*At,De+=At*_t,Ue+=_t*_t}if(Ce===0)return null;const qe=De/Ce,rt=Ae-qe*de,ct=Ue===0?1:Math.max(0,Math.min(1,De*De/(Ce*Ue))),ot=Math.max(0,Ue-qe*De),vt=oe>2?Math.sqrt(ot/(oe-2)/Ce):0;return{slope:qe,intercept:rt,r2:ct,stdError:vt,n:oe}}const z=new Set(["ols","wls","robust"]),G=new Set(["quantile"]),N=new Set(["ridge","lasso","elasticnet","mixed","gls"]),Z=1.345;function Q(se,ge,Se){const{xtwx:Re,xtwy:xe}=c(se,ge,Se),oe=O(Re);if(!oe)return null;const de=v(oe,xe),Ae=b(oe),Ce=ee(se,de),De=ge.map((Ue,qe)=>Ue-Ce[qe]);return{beta:de,cov:Ae,fitted:Ce,residuals:De}}function ee(se,ge){return se.map(Se=>Se.reduce((Re,xe,oe)=>Re+xe*ge[oe],0))}function re(se,ge){const Se=se.length,Re=se.map(De=>De[ge]),xe=se.map(De=>[1,...De.filter((Ue,qe)=>qe!==ge)]),oe=Q(xe,Re,null);if(!oe)return 1;const de=Re.reduce((De,Ue)=>De+Ue,0)/Se;let Ae=0,Ce=0;for(let De=0;De<Se;De++)Ae+=oe.residuals[De]**2,Ce+=(Re[De]-de)**2;return Ce===0?1:Math.max(0,Math.min(1,1-Ae/Ce))}function ie(se){const ge=[...se].sort((xe,oe)=>xe-oe),Se=ce(ge),Re=se.map(xe=>Math.abs(xe-Se)).sort((xe,oe)=>xe-oe);return ce(Re)/.6745}function ce(se){const ge=se.length;if(!ge)return 0;const Se=Math.floor(ge/2);return ge%2?se[Se]:(se[Se-1]+se[Se])/2}function ve(se,ge,Se={}){const Re=Se.method||"ols";if(N.has(Re))throw new Error(`[lattice] regression method "${Re}" is out of scope; use ols, wls or robust.`);if(G.has(Re))throw new Error("[lattice] quantile regression is coming next and not yet available; use ols, wls or robust.");if(!z.has(Re))throw new Error(`[lattice] unknown regression method "${Re}"; use ols, wls or robust.`);const xe=Array.isArray(ge)?ge.length:0,oe=xe&&Array.isArray(se[0])?se[0].length:0,de=oe+1;if(!(xe>de))return null;for(let Ct=0;Ct<xe;Ct++){if(!Number.isFinite(ge[Ct])||!Array.isArray(se[Ct])||se[Ct].length!==oe)return null;for(let $t=0;$t<oe;$t++)if(!Number.isFinite(se[Ct][$t]))return null}let Ae=null;if(Re==="wls"){if(Ae=Se.weights,!Array.isArray(Ae)||Ae.length!==xe)return null;for(let Ct=0;Ct<xe;Ct++)if(!(Ae[Ct]>0)||!Number.isFinite(Ae[Ct]))return null}const Ce=se.map(Ct=>[1,...Ct]);let De,Ue=null;if(Re==="robust"){if(De=Q(Ce,ge,null),!De)return null;for(let Ct=0;Ct<50;Ct++){const $t=ie(De.residuals);if(!($t>0))break;const Vt=De.residuals.map(Ut=>{const Gt=Math.abs(Ut/$t);return Gt<=Z?1:Z/Gt}),zt=Q(Ce,ge,Vt);if(!zt)return null;const Wt=zt.beta.reduce((Ut,Gt,It)=>Math.max(Ut,Math.abs(Gt-De.beta[It])),0);if(De=zt,Ue=Vt,Wt<1e-10)break}}else if(De=Q(Ce,ge,Ae),!De)return null;const qe=Re==="robust"?Ue:Ae,{beta:rt,cov:ct,fitted:ot,residuals:vt}=De;let Rt=0,At=0,_t=0;for(let Ct=0;Ct<xe;Ct++){const $t=qe?qe[Ct]:1;Rt+=$t*vt[Ct]**2,At+=$t,_t+=$t*ge[Ct]}const tn=_t/At;let Ht=0;for(let Ct=0;Ct<xe;Ct++){const $t=qe?qe[Ct]:1;Ht+=$t*(ge[Ct]-tn)**2}const Xt=xe-de,Ze=Rt/Xt,lt=Ht===0?1:Math.max(0,Math.min(1,1-Rt/Ht)),St=1-(1-lt)*(xe-1)/Xt,bt=Array.isArray(Se.names)&&Se.names.length===oe?Se.names:se[0].map((Ct,$t)=>`x${$t+1}`),wt=Ye(Se.confidence),Ke=Xt>0?I(1-(1-wt)/2,Xt):1/0,ht=rt.map((Ct,$t)=>{const Vt=Math.sqrt(Math.max(0,Ze*ct[$t][$t])),zt=Vt>0?Ct/Vt:Ct===0?0:1/0,Wt=Number.isFinite(zt)?2*(1-J(Math.abs(zt),Xt)):0,Ut=Number.isFinite(Ke)?Ke*Vt:null;return{name:$t===0?"(intercept)":bt[$t-1],estimate:Ct,stdError:Vt,t:zt,p:Math.max(0,Math.min(1,Wt)),lower:Ut===null?null:Ct-Ut,upper:Ut===null?null:Ct+Ut}}),at=new Array(xe),mt=new Array(xe);for(let Ct=0;Ct<xe;Ct++){const $t=qe?qe[Ct]:1,Vt=Math.max(0,Math.min(1,$t*g(Ce[Ct],ct)));at[Ct]=Vt;const zt=(1-Vt)**2;mt[Ct]=zt>0&&Ze>0?vt[Ct]**2/(de*Ze)*(Vt/zt):null}const xt=se[0].map((Ct,$t)=>{if(oe<2)return 1;const Vt=re(se,$t);return Vt>=1?1/0:1/(1-Vt)});let Ft=null;{const Ct=vt.map(Vt=>Vt*Vt),$t=Q(Ce,Ct,null);if($t){const Vt=Ct.reduce((Jt,ln)=>Jt+ln,0)/xe;let zt=0,Wt=0;for(let Jt=0;Jt<xe;Jt++)zt+=$t.residuals[Jt]**2,Wt+=(Ct[Jt]-Vt)**2;const Ut=Wt===0?0:Math.max(0,Math.min(1,1-zt/Wt)),Gt=xe*Ut,It=Y(Gt,oe);Ft={statistic:Gt,df:oe,p:It,heteroscedastic:It<.05}}}let yt=null;if(oe===1){const Ct=se.map(($t,Vt)=>Vt).sort(($t,Vt)=>se[$t][0]-se[Vt][0]);yt={confidence:wt,points:Ct.map($t=>{const Vt=Ce[$t],zt=Math.sqrt(Math.max(0,Ze*g(Vt,ct)));return{x:se[$t][0],yhat:ot[$t],lower:ot[$t]-Ke*zt,upper:ot[$t]+Ke*zt}})}}return{method:Re,coefficients:ht,r2:lt,adjR2:St,n:xe,df:Xt,sigma2:Ze,fitted:ot,residuals:vt,leverage:at,cooksD:mt,vif:xt,heteroscedasticity:Ft,band:yt,weights:qe?[...qe]:null}}function he(se){const ge=se.length,Se=Array.from({length:ge},(oe,de)=>de).sort((oe,de)=>se[oe]-se[de]),Re=new Float64Array(ge);let xe=0;for(;xe<ge;){let oe=xe;for(;oe+1<ge&&se[Se[oe+1]]===se[Se[xe]];)oe++;const de=(xe+oe)/2+1;for(let Ae=xe;Ae<=oe;Ae++)Re[Se[Ae]]=de;xe=oe+1}return Re}const ye=Object.freeze({"1%":-3.9638,"5%":-3.4126,"10%":-3.1279});function Oe(se){const ge=[.01,.05,.1],Se=[ye["1%"],ye["5%"],ye["10%"]];if(se<=Se[0]){const oe=(Math.log(ge[1])-Math.log(ge[0]))/(Se[1]-Se[0]);return Math.max(1e-4,Math.min(.01,Math.exp(Math.log(ge[0])+oe*(se-Se[0]))))}if(se>=Se[2]){const oe=(Math.log(ge[2])-Math.log(ge[1]))/(Se[2]-Se[1]);return Math.max(.1,Math.min(.999,Math.exp(Math.log(ge[2])+oe*(se-Se[2]))))}const Re=se<Se[1]?0:1,xe=(se-Se[Re])/(Se[Re+1]-Se[Re]);return Math.exp(Math.log(ge[Re])+xe*(Math.log(ge[Re+1])-Math.log(ge[Re])))}function Le(se,ge,Se,Re){const xe=Se-Re,oe=Re+3,de=new Array(xe),Ae=new Array(xe);let Ce=!0,De=Re;for(let ot=0;ot<xe;ot++){const vt=Re+ot,Rt=new Float64Array(oe);Rt[0]=1,Rt[1]=ot+1,Rt[2]=se[vt];for(let At=1;At<=Re;At++)Rt[2+At]=ge[vt-At];for(let At=1;At<oe;At++)Number.isFinite(Rt[At])||(De=Math.min(De,At-3));de[ot]=Rt,Ae[ot]=ge[vt],Number.isFinite(Ae[ot])||(Ce=!1)}if(!Ce)return 0;const{xtwx:Ue,xtwy:qe}=c(de,Ae,null);let rt=0,ct=1/0;for(let ot=0;ot<=De;ot++){const vt=ot+3;if(!(xe>vt))continue;const Rt=new Array(vt);for(let lt=0;lt<vt;lt++)Rt[lt]=Ue[lt].slice(0,vt);const At=O(Rt);if(!At)continue;const _t=v(At,qe.slice(0,vt));let tn=0;for(let lt=0;lt<xe;lt++){const St=de[lt];let bt=0;for(let wt=0;wt<vt;wt++)bt+=St[wt]*_t[wt];tn+=(Ae[lt]-bt)**2}const Xt=tn/(xe-vt)*(xe-vt);if(!(Xt>0))continue;const Ze=xe*Math.log(Xt/xe)+2*vt;Ze<ct&&(ct=Ze,rt=ot)}return rt}function fe(se,ge={}){const Se=[];for(let ct=0;ct<se.length;ct++){const ot=Number(se[ct]);Number.isFinite(ot)&&Se.push(ot)}const Re=Se.length,xe=Re-1;if(Re<8||xe<6)return null;const oe=new Array(xe);for(let ct=0;ct<xe;ct++)oe[ct]=Se[ct+1]-Se[ct];let de=Number.isFinite(ge.maxlag)?Math.floor(ge.maxlag):Math.ceil(12*(Re/100)**.25);de=Math.max(0,Math.min(de,Math.floor((xe-5)/2)));const Ae=(ct,ot)=>{const vt=[],Rt=[];for(let At=ot;At<xe;At++){const _t=[At-ot+1,Se[At]];for(let tn=1;tn<=ct;tn++)_t.push(oe[At-tn]);vt.push(_t),Rt.push(oe[At])}return ve(vt,Rt,{method:"ols"})},Ce=Le(Se,oe,xe,de),De=Ae(Ce,Ce);if(!De||!De.coefficients[2])return null;const Ue=De.coefficients[2].t,qe=Oe(Ue),rt=Ue<ye["5%"];return{statistic:Ue,usedLag:Ce,nobs:xe-Ce,criticalValues:{...ye},pValue:qe,pApproximate:!0,stationary:rt,verdict:rt?"stationary":"non-stationary",regression:"ct"}}function ae(se,ge={}){const Se=[];for(let rt=0;rt<se.length;rt++){const ct=Number(se[rt]);Number.isFinite(ct)&&Se.push(ct)}const Re=Se.length;if(Re<3)return null;let xe=Number.isFinite(ge.maxlag)?Math.floor(ge.maxlag):Math.min(10,Re-1);xe=Math.max(1,Math.min(xe,Re-1));let oe=0;for(const rt of Se)oe+=rt;oe/=Re;const de=Se.map(rt=>rt-oe);let Ae=0;for(const rt of de)Ae+=rt*rt;Ae/=Re;const Ce=new Array(xe+1).fill(0);Ce[0]=1;for(let rt=1;rt<=xe;rt++){let ct=0;for(let ot=rt;ot<Re;ot++)ct+=de[ot]*de[ot-rt];Ce[rt]=Ae>0?ct/Re/Ae:0}const De=new Array(xe+1).fill(0);De[0]=1;let Ue=[];for(let rt=1;rt<=xe;rt++){let ct=Ce[rt];for(let At=1;At<rt;At++)ct-=Ue[At-1]*Ce[rt-At];let ot=1;for(let At=1;At<rt;At++)ot-=Ue[At-1]*Ce[At];const vt=ot!==0?ct/ot:0,Rt=new Array(rt);for(let At=1;At<rt;At++)Rt[At-1]=Ue[At-1]-vt*Ue[rt-1-At];Rt[rt-1]=vt,De[rt]=vt,Ue=Rt}const qe=1.96/Math.sqrt(Re);return{acf:Ce,pacf:De,bounds:{upper:qe,lower:-qe},n:Re,nlags:xe,approximate:!0}}function ke(se,ge,Se){const{xs:Re,ys:xe,n:oe}=F(se,ge,Se);if(oe<2)return null;const de=he(Re),Ae=he(xe);let Ce=0,De=0;for(let ct=0;ct<oe;ct++)Ce+=de[ct],De+=Ae[ct];Ce/=oe,De/=oe;let Ue=0,qe=0,rt=0;for(let ct=0;ct<oe;ct++){const ot=de[ct]-Ce,vt=Ae[ct]-De;Ue+=ot*vt,qe+=ot*ot,rt+=vt*vt}return qe===0||rt===0?null:Math.max(-1,Math.min(1,Ue/Math.sqrt(qe*rt)))}function pe(se,ge,Se){const{xs:Re,ys:xe,n:oe}=F(se,ge,Se);if(oe<2||oe>s)return null;let de=0,Ae=0,Ce=0,De=0;for(let rt=0;rt<oe;rt++)for(let ct=rt+1;ct<oe;ct++){const ot=Math.sign(Re[rt]-Re[ct]),vt=Math.sign(xe[rt]-xe[ct]),Rt=ot*vt;Rt>0?de++:Rt<0?Ae++:ot===0&&vt===0||(ot===0?Ce++:De++)}const Ue=de+Ae+De,qe=de+Ae+Ce;return Ue===0||qe===0?null:(de-Ae)/Math.sqrt(Ue*qe)}function ue(se,ge={}){const Se=se.length;if(Se<2)return null;const Re=se[0],xe=se[Se-1],oe=[];for(let At=1;At<Se;At++){const _t=se[At-1];_t!==0&&oe.push((se[At]-_t)/Math.abs(_t))}let de=null;if(oe.length>1){let At=0;for(const tn of oe)At+=tn;At/=oe.length;let _t=0;for(const tn of oe)_t+=(tn-At)**2;de=Math.sqrt(_t/(oe.length-1))}const Ae=Number(ge.periodsPerYear)>0?Number(ge.periodsPerYear):null;let Ce=se[0],De=0,Ue=0,qe=0,rt=0;for(let At=1;At<Se;At++){if(se[At]>Ce){Ce=se[At],De=At;continue}if(Ce<=0)continue;const _t=(Ce-se[At])/Ce;_t>Ue&&(Ue=_t,qe=De,rt=At)}let ct=null;if(Se>2){let At=0;for(let Ht=0;Ht<Se;Ht++)At+=se[Ht];At/=Se;let _t=0,tn=0;for(let Ht=0;Ht<Se;Ht++){const Xt=se[Ht]-At;tn+=Xt*Xt,Ht>0&&(_t+=Xt*(se[Ht-1]-At))}ct=tn>0?_t/tn:null}let ot=0,vt=0;for(const At of oe)At>0?ot++:At<0&&vt++;let Rt=null;if(Re>0&&xe>0){const At=(xe/Re)**(1/(Se-1))-1;Rt=Ae?(1+At)**Ae-1:At}return{n:Se,first:Re,last:xe,change:xe-Re,changePercent:Re===0?null:(xe-Re)/Math.abs(Re)*100,volatility:de,annualisedVolatility:de!==null&&Ae?de*Math.sqrt(Ae):null,growth:Rt,maxDrawdown:Ue,maxDrawdownFrom:qe,maxDrawdownTo:rt,autocorrelation:ct,upDays:ot,downDays:vt}}const we=1.128,Te=3.267;function Ne(se){const ge=se.length;if(ge<2)return null;const Se=[];for(let xe=1;xe<ge;xe++)Se.push(Math.abs(se[xe]-se[xe-1]));const Re=Se.reduce((xe,oe)=>xe+oe,0)/Se.length;return{ranges:Se,centre:Re,upper:Te*Re,lower:0}}function _e(se){const ge=se.length;if(ge<2)return null;let Se=0;for(let xe=1;xe<ge;xe++)Se+=Math.abs(se[xe]-se[xe-1]);const Re=Se/(ge-1);return{sigma:Re/we,meanRange:Re}}function $e(se,ge){const Se=se.length;if(Se<2||!ge)return null;const Re=Number.isFinite(Number(ge.lower))?Number(ge.lower):null,xe=Number.isFinite(Number(ge.upper))?Number(ge.upper):null;if(Re===null&&xe===null)return null;let oe=0;for(let ot=0;ot<Se;ot++)oe+=se[ot];oe/=Se;let de=0;for(let ot=0;ot<Se;ot++)de+=(se[ot]-oe)**2;const Ae=Math.sqrt(de/(Se-1)),Ce=_e(se),De=Ce?Ce.sigma:null,Ue=ot=>{if(!ot||ot<=0)return{index:null,k:null};const Rt=Re!==null&&xe!==null?(xe-Re)/(6*ot):null,At=xe!==null?(xe-oe)/(3*ot):1/0,_t=Re!==null?(oe-Re)/(3*ot):1/0;return{index:Rt,k:Math.min(At,_t)}},qe=Ue(De),rt=Ue(Ae);let ct=0;for(let ot=0;ot<Se;ot++){if(Re!==null&&se[ot]<Re){ct++;continue}xe!==null&&se[ot]>xe&&ct++}return{n:Se,mean:oe,lower:Re,upper:xe,target:Number.isFinite(Number(ge.target))?Number(ge.target):null,sigmaWithin:De,sigmaOverall:Ae,cp:qe.index,cpk:qe.k,pp:rt.index,ppk:rt.k,outOfSpec:ct,defectRate:Se?ct/Se:null}}function je(se){const ge=se.length;if(ge<2)return null;const Se=_e(se);if(!Se||!(Se.sigma>0))return null;let Re=0;for(let xe=0;xe<ge;xe++)Re+=se[xe];return Re/=ge,{centre:Re,sigma:Se.sigma,upper:Re+3*Se.sigma,lower:Re-3*Se.sigma}}function Ge(se,ge){if(!ge||!(ge.sigma>0))return[];const Se=se.length,{centre:Re,sigma:xe}=ge,oe=Ae=>(se[Ae]-Re)/xe,de=[];for(let Ae=0;Ae<Se;Ae++){if(Math.abs(oe(Ae))>3&&de.push({index:Ae,rule:1,description:"beyond three sigma"}),Ae>=2)for(const Ce of[1,-1]){let De=0;for(let Ue=Ae-2;Ue<=Ae;Ue++)oe(Ue)*Ce>2&&De++;if(De>=2){de.push({index:Ae,rule:2,description:"two of three past two sigma"});break}}if(Ae>=4)for(const Ce of[1,-1]){let De=0;for(let Ue=Ae-4;Ue<=Ae;Ue++)oe(Ue)*Ce>1&&De++;if(De>=4){de.push({index:Ae,rule:3,description:"four of five past one sigma"});break}}if(Ae>=7)for(const Ce of[1,-1]){let De=!0;for(let Ue=Ae-7;Ue<=Ae;Ue++)if(oe(Ue)*Ce<=0){De=!1;break}if(De){de.push({index:Ae,rule:4,description:"eight in a row on one side"});break}}}return de}function Fe(se,ge){if(!ge||!(ge.sigma>0))return[];const Se=se.length,{centre:Re,sigma:xe}=ge,oe=Ce=>(se[Ce]-Re)/xe,de=(Ce,De,Ue,qe)=>{for(const rt of[1,-1]){let ct=0;for(let ot=Ce;ot<=De;ot++)oe(ot)*rt>Ue&&ct++;if(ct>=qe)return!0}return!1},Ae=[];for(let Ce=0;Ce<Se;Ce++){if(Math.abs(oe(Ce))>3&&Ae.push({index:Ce,rule:1,description:"beyond three sigma"}),Ce>=8)for(const De of[1,-1]){let Ue=!0;for(let qe=Ce-8;qe<=Ce;qe++)if(oe(qe)*De<=0){Ue=!1;break}if(Ue){Ae.push({index:Ce,rule:2,description:"nine in a row on one side"});break}}if(Ce>=5)for(const De of[1,-1]){let Ue=!0;for(let qe=Ce-4;qe<=Ce;qe++)if((se[qe]-se[qe-1])*De<=0){Ue=!1;break}if(Ue){Ae.push({index:Ce,rule:3,description:De>0?"six rising":"six falling"});break}}if(Ce>=13){let De=!0;for(let Ue=Ce-12;Ue<=Ce;Ue++){const qe=se[Ue]-se[Ue-1],rt=se[Ue+1<=Ce?Ue+1:Ue]-se[Ue];if(Ue+1>Ce)break;if(qe===0||rt===0||qe>0==rt>0){De=!1;break}}De&&Ae.push({index:Ce,rule:4,description:"fourteen alternating"})}if(Ce>=2&&de(Ce-2,Ce,2,2)&&Ae.push({index:Ce,rule:5,description:"two of three past two sigma"}),Ce>=4&&de(Ce-4,Ce,1,4)&&Ae.push({index:Ce,rule:6,description:"four of five past one sigma"}),Ce>=14){let De=!0;for(let Ue=Ce-14;Ue<=Ce;Ue++)if(Math.abs(oe(Ue))>=1){De=!1;break}De&&Ae.push({index:Ce,rule:7,description:"fifteen within one sigma"})}if(Ce>=7){let De=!0;for(let Ue=Ce-7;Ue<=Ce;Ue++)if(Math.abs(oe(Ue))<=1){De=!1;break}De&&Ae.push({index:Ce,rule:8,description:"eight beyond one sigma"})}}return Ae}const Pe=Object.freeze(["westernElectric","nelson"]);function Ee(se,ge,Se="westernElectric"){return String(Se)==="nelson"?Fe(se,ge):Ge(se,ge)}function Me(se,ge,Se){let Re=0;for(let xe=0;xe<se.length;xe++)(se[xe]<ge||se[xe]>Se)&&Re++;return Re}function Ie(se,ge,Se,Re=20){const xe=se.length;if(!xe)return[];const oe=se[0],de=se[xe-1];if(de===oe)return[{from:oe,to:de,count:xe}];const Ae=Se-ge,Ce=1.5*Ae;let De=Ae>0?Math.max(oe,ge-Ce):oe,Ue=Ae>0?Math.min(de,Se+Ce):de;Ue>De||(De=oe,Ue=de);const qe=Ae>0?2*Ae/Math.cbrt(xe):(Ue-De)/(Math.ceil(Math.log2(xe))+1),rt=qe>0?Math.min(Re,Math.max(1,Math.ceil((Ue-De)/qe))):1,ct=(Ue-De)/rt,ot=[];for(let vt=0;vt<rt;vt++)ot.push({from:De+vt*ct,to:De+(vt+1)*ct,count:0});for(let vt=0;vt<xe;vt++){const Rt=Math.min(rt-1,Math.max(0,Math.floor((se[vt]-De)/ct)));ot[Rt].count++}return ot[0].from=oe,ot[rt-1].to=de,ot}const We=.95;function Ye(se){const ge=Number(se);return Number.isFinite(ge)&&ge>0&&ge<1?ge:We}function nt(se,ge=We){const Se=se.length;if(Se<2)return null;let Re=0;for(let Ue=0;Ue<Se;Ue++)Re+=se[Ue];const xe=Re/Se;let oe=0;for(let Ue=0;Ue<Se;Ue++){const qe=se[Ue]-xe;oe+=qe*qe}const de=Math.sqrt(oe/(Se-1)),Ae=Ye(ge),De=I(1-(1-Ae)/2,Se-1)*de/Math.sqrt(Se);return{mean:xe,lower:xe-De,upper:xe+De,margin:De,n:Se,confidence:Ae}}function Qe(se,ge,Se=We){const Re=Number(se),xe=Number(ge);if(!(xe>0)||!(Re>=0)||Re>xe)return null;const oe=Ye(Se),de=H(1-(1-oe)/2),Ae=Re/xe,Ce=de*de,De=1+Ce/xe,Ue=(Ae+Ce/(2*xe))/De,qe=de/De*Math.sqrt(Ae*(1-Ae)/xe+Ce/(4*xe*xe));return{proportion:Ae,lower:Math.max(0,Ue-qe),upper:Math.min(1,Ue+qe),n:xe,confidence:oe}}function dt(se,ge=We){if(!se||!(se.n>2)||!Number.isFinite(se.stdError))return null;const Se=Ye(ge),xe=I(1-(1-Se)/2,se.n-2)*se.stdError;return{slope:se.slope,lower:se.slope-xe,upper:se.slope+xe,margin:xe,confidence:Se}}function jt(se,ge,Se=We){const Re=Number(se),xe=Number(ge);if(!Number.isFinite(Re)||!(xe>1))return null;const oe=Ye(Se),Ae=H(1-(1-oe)/2)*Math.sqrt(1/(9*xe)+Re*Re/(2*(xe-1)));return{index:Re,lower:Re-Ae,upper:Re+Ae,margin:Ae,n:xe,confidence:oe}}function Et(se,ge){return!se||!(se.sd>0)||!Number.isFinite(ge)||!Number.isFinite(se.mean)?null:(ge-se.mean)/se.sd}function it(se){return Number.isFinite(se)?Math.min(1,Math.max(0,2*L(Math.abs(se)/2)-1)):0}function ft(se,ge){const Se=new Map,Re=V(se);let xe=0;for(let oe=0;oe<ge.length;oe++){const de=Re(ge[oe]);if(de==null||de===""||typeof de=="number"&&Number.isNaN(de))continue;const Ae=de instanceof Date?de.getTime():typeof de=="object"?String(de):de;Se.set(Ae,(Se.get(Ae)||0)+1),xe++}return{map:Se,total:xe}}function pt(se,ge,Se,Re){if(!(ge>0)||!(Re>0))return null;let xe=0;const oe=new Set(se.keys());for(const de of Se.keys())oe.add(de);for(const de of oe){const Ae=(se.get(de)||0)/ge,Ce=(Se.get(de)||0)/Re;xe+=Math.abs(Ae-Ce)}return xe/2}const Tt=10;function Nt(se,ge,Se){if(Se&&Se.numeric){const Ae=p(se,ge),{n:Ce,mean:De}=m(Ae),Ue=Ce>0?Et({mean:Se.mean,sd:Se.sd},De):null;return{measure:"standardizedMeanDifference",magnitude:Ue,distance:Ue===null?0:it(Ue),direction:Ue===null?0:Math.sign(Ue),subsetN:Ce,populationN:Se.n||0,reliable:Ce>=Tt}}const{map:xe,total:oe}=ft(se,ge),de=pt(xe,oe,Se.map,Se.total);return{measure:"categoricalTotalVariation",magnitude:de,distance:de===null?0:de,direction:0,subsetN:oe,populationN:Se.total||0,reliable:oe>=Tt}}function Lt(se,ge){if(se&&(se.kind==="float64"||se.kind==="int32"))return!0;const Se=V(se);let Re=0,xe=0;for(let oe=0;oe<ge.length&&Re<200;oe++){const de=Se(ge[oe]);if(de==null||de==="")continue;if(de instanceof Date)return!1;Re++;const Ae=typeof de=="number"?de:Number(de);Number.isFinite(Ae)&&xe++}return Re===0?!1:xe/Re>=.9}function Je(se,ge){if(Lt(se,ge)){const xe=p(se,ge),{n:oe,mean:de,m2:Ae}=m(xe);return{numeric:!0,mean:de,sd:oe>0?Math.sqrt(Ae/oe):0,n:oe}}const{map:Se,total:Re}=ft(se,ge);return{numeric:!1,map:Se,total:Re}}}),ze("packages/core/src/compute/total.js",function(e,B){"use strict";Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"TOTAL_LABELS",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"totalLabel",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"aggregatesFor",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"aggregateAllowed",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"collectValues",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return m}});const A=B("packages/core/src/internal/predicates.js").isFunction,U=B("packages/core/src/internal/warn.js").warnOnce,I=B("packages/core/src/compute/handle.js"),J=I.presenceReader,H=I.valueComparator,L=I.valueReader,Y=B("packages/core/src/compute/statistics.js"),_=Y.STAT_FNS,O=Y.STAT_LABELS;function v(w){return!!w&&(w.kind==="float64"||w.kind==="int32")}function b(w,S){const M=S.length;let X=0;if(v(w)){const K=w.values,P=J(w);if(!P){for(let k=0;k<M;k++){const E=K[S[k]];Number.isNaN(E)||(X+=E)}return X}for(let k=0;k<M;k++){const E=S[k];if(P(E)===1){const C=K[E];Number.isNaN(C)||(X+=C)}}return X}const q=L(w);for(let K=0;K<M;K++){const P=p(q(S[K]));P!==null&&(X+=P)}return X}b.kernel=!0;function c(w,S){const M=S.length;let X=0;if(v(w)){const K=w.values,P=J(w);if(!P){for(let k=0;k<M;k++)Number.isNaN(K[S[k]])||X++;return X}for(let k=0;k<M;k++){const E=S[k];P(E)===1&&!Number.isNaN(K[E])&&X++}return X}const q=L(w);for(let K=0;K<M;K++){const P=q(S[K]);P!=null&&!(typeof P=="number"&&Number.isNaN(P))&&X++}return X}c.kernel=!0;function g(w,S){return S.length}g.kernel=!0;function o(w,S){const M=c(w,S);return M===0?null:b(w,S)/M}o.kernel=!0;function t(w,S,M,X){const q=S.length;if(v(w)){const E=w.values,C=J(w);let x=null;if(!C){for(let j=0;j<q;j++){const T=E[S[j]];Number.isNaN(T)||(x===null||(M<0?T<x:T>x))&&(x=T)}return x}for(let j=0;j<q;j++){const T=S[j];if(C(T)===0)continue;const F=E[T];Number.isNaN(F)||(x===null||(M<0?F<x:F>x))&&(x=F)}return x}const K=L(w),P=H(X);let k=null;for(let E=0;E<q;E++){const C=K(S[E]);C==null||typeof C=="number"&&Number.isNaN(C)||(k===null||(M<0?P(C,k)<0:P(C,k)>0))&&(k=C)}return k}function s(w,S,M){return t(w,S,-1,M&&M.locale)}s.kernel=!0;function l(w,S,M){return t(w,S,1,M&&M.locale)}l.kernel=!0;function u(w,S){return S.length===0?null:L(w)(S[0])}u.kernel=!0;function n(w,S){return S.length===0?null:L(w)(S[S.length-1])}n.kernel=!0;function p(w){if(typeof w=="number")return Number.isNaN(w)?null:w;if(w==null||w===""||typeof w=="boolean")return null;if(w instanceof Date)return w.getTime();const S=Number(w);return Number.isNaN(S)?null:S}const r={sum:b,min:s,max:l,avg:o,count:g,first:u,last:n,countValues:c,..._},i=Object.freeze({...O,sum:"Sum",avg:"Average",min:"Min",max:"Max",count:"Count",countValues:"Count of values",first:"First",last:"Last"});function d(w){return w?typeof w=="string"?i[w]||w:"Total":""}const h=Object.freeze(["sum","avg","min","max","count","countValues","first","last"]);function a(w){const S=w&&w.dataType&&w.dataType.totals&&w.dataType.totals.supported;if(Array.isArray(S))return S.slice();const M=h.filter(X=>X in r);for(const X of Object.keys(r))M.includes(X)||M.push(X);return M}function y(w,S){return typeof S!="string"?!0:a(w).includes(S)}function f(w,S){const M=L(w),X=[];for(let q=0;q<S.length;q++){const K=M(S[q]);K!=null&&X.push(K)}return X}function m(w,S,M,X){const q=S||[];if(M&&typeof M=="object"&&typeof M.fn=="string"){const{fn:K,...P}=M,k=r[K];return k?k(w,q,{...X,...P}):(U(`total:${K}`,`unknown total function "${K}"; register it in config.totalFns`),null)}if(typeof M=="string"){const K=r[M];return K?K(w,q,X):(U(`total:${M}`,`unknown total function "${M}"; register it in config.totalFns`),null)}return A(M)?M.kernel===!0?M(w,q,X):M(f(w,q),X||{}):null}}),ze("packages/core/src/compute/windowed.js",function(e,B){"use strict";Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return J}});const A=B("packages/core/src/compute/sketch.js").Welford;class V{#e;#t;#n=[];#r;#s;constructor(L,Y=0,_=Date.now){if(L!=="count"&&L!=="time"&&L!=="session")throw new RangeError(`unknown window kind: ${L}`);if((L==="count"||L==="time")&&!(Y>0))throw new RangeError(`a ${L} window needs a positive span`);this.#e=L,this.#t=Math.floor(Y),this.#r=_,this.#s=_()}get size(){return this.#n.length}push(L,Y=this.#r()){Number.isFinite(L)&&(this.#n.push({t:Y,v:L}),this.#i(Y))}#i(L){if(this.#e==="count")for(;this.#n.length>this.#t;)this.#n.shift();else if(this.#e==="time"){const Y=L-this.#t;for(;this.#n.length&&this.#n[0].t<Y;)this.#n.shift()}}spec(){const L=this.#e==="session"?this.#r()-this.#s:this.#t;return{kind:this.#e,span:L,size:this.#n.length}}values(){return this.#n.map(L=>L.v)}aggregate(){const L=this.spec();if(!this.#n.length)return{over:L,count:0,sum:null,mean:null,min:null,max:null,variance:null,stddev:null};const Y=new A;let _=0,O=1/0,v=-1/0;for(const{v:b}of this.#n)_+=b,b<O&&(O=b),b>v&&(v=b),Y.add(b);return{over:L,count:this.#n.length,sum:_,mean:Y.mean(),min:O,max:v,variance:Y.variance(),stddev:Y.stddev()}}reduce(L){const Y=this.aggregate(),_={sum:Y.sum,avg:Y.mean,mean:Y.mean,min:Y.min,max:Y.max,count:Y.count,variance:Y.variance,stddev:Y.stddev};if(!(L in _))throw new RangeError(`unknown windowed aggregate: ${L}`);return{value:_[L],over:Y.over}}}const U=Object.freeze(["count","time","session"]);function I(H,L=Date.now){const Y=H.kind==="time"&&H.minutes!=null?H.minutes*6e4:H.span??0;return new V(H.kind,Y,L)}const J={Window:V,WINDOW_KINDS:U,openWindow:I}}),ze("packages/core/src/compute/rolling.js",function(e,B){"use strict";Object.defineProperty(e,"ROLLING_WINDOW_FIELDS",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"rollingWindow",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"cumulativeToDate",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"periodOverPeriod",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"QUANTILE_SPAN_CAP",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"rollingQuantile",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"seasonalDecompose",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"exponentialSmoothing",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return p}});const A=B("packages/core/src/compute/windowed.js").openWindow,U=B("packages/core/src/compute/sketch.js").KLL,I=Object.freeze({rollingSum:"sum",rollingAvg:"avg",rollingMin:"min",rollingMax:"max"});function J(r,i,d,h){if(r.kind==="count"){const a=Math.max(1,Math.floor(r.span||0));return{coverage:Math.min(1,i/a),partial:i<a}}if(r.kind==="time"){const a=r.minutes!=null?r.minutes*6e4:r.span||0;if(!(a>0))return{coverage:1,partial:!1};const y=d-h;return{coverage:Math.min(1,y/a),partial:y<a}}return{coverage:null,partial:!1}}function H(r,i){const d=A(i),h=new Map,a=r.length?r[0].at:0;for(let y=0;y<r.length;y++){const{key:f,at:m,value:w}=r[y];Number.isFinite(w)&&d.push(w,m);const S=d.aggregate(),M=J(i,S.count,m,a);f!=null&&h.set(String(f),{sum:S.sum,avg:S.mean,min:S.min,max:S.max,count:S.count,coverage:M.coverage,partial:M.partial})}return h}function L(r){const i=new Map;let d=0;for(const{key:h,value:a}of r)Number.isFinite(a)&&(d+=a),h!=null&&i.set(String(h),d);return i}function Y(r,i=1){const d=new Map,h=Math.max(1,Math.floor(i));for(let a=0;a<r.length;a++){const{key:y,value:f}=r[a];if(y==null)continue;const m=a>=h?r[a-h].value:null,w=Number.isFinite(f)?f:null,S=Number.isFinite(m)?m:null;d.set(String(y),w!==null&&S!==null?w-S:null)}return d}const _=4096;function O(r){let i=r>>>0;return()=>{i+=1831565813;let d=i;return d=Math.imul(d^d>>>15,d|1),d^=d+Math.imul(d^d>>>7,d|61),((d^d>>>14)>>>0)/4294967296}}function v(r,i){const d=r.length;if(d===1)return r[0];const h=(d-1)*i,a=Math.floor(h),y=Math.ceil(h);return a===y?r[a]:r[a]+(h-a)*(r[y]-r[a])}function b(r,i,d={}){const h=Math.min(1,Math.max(0,d.q==null?.5:d.q)),a=Math.max(1,Math.floor(d.cap==null?_:d.cap)),y=O(d.seed==null?2654435769:d.seed),f=new Map,m=r.length?r[0].at:0;if(i.kind==="session"){const S=new U(200,y);let M=0;for(const{key:X,value:q}of r)Number.isFinite(q)&&(S.add(q),M++),X!=null&&f.set(String(X),{value:M?S.quantile(h):null,approx:M>0,count:M,coverage:null,partial:!1});return f}const w=A(i);for(const{key:S,at:M,value:X}of r){Number.isFinite(X)&&w.push(X,M);const q=w.values(),K=q.length;let P=null,k=!1;if(K)if(K<=a)P=v([...q].sort((C,x)=>C-x),h);else{const C=new U(200,y);for(const x of q)C.add(x);P=C.quantile(h),k=!0}const E=J(i,K,M,m);S!=null&&f.set(String(S),{value:P,approx:k,count:K,coverage:E.coverage,partial:E.partial})}return f}function c(r,i){const d=r.length,h=new Array(d).fill(null),a=Math.floor(i/2),y=i%2===0;for(let f=0;f<d;f++){if(f-a<0||f+a>=d)continue;let m=0,w=!0;if(y)for(let S=-a;S<=a;S++){const M=r[f+S];if(!Number.isFinite(M)){w=!1;break}m+=S===-a||S===a?M*.5:M}else for(let S=-a;S<=a;S++){const M=r[f+S];if(!Number.isFinite(M)){w=!1;break}m+=M}w&&(h[f]=m/i)}return h}function g(r,i){const d=new Map,h=Math.floor(Number(i&&i.period));if(!(h>=2))return d;const a=i&&i.model==="multiplicative",y=r.length,f=r.map(k=>Number.isFinite(k.value)?k.value:null),m=c(f,h),w=new Array(y).fill(null);for(let k=0;k<y;k++){const E=m[k],C=f[k];E===null||C===null||(a?E!==0&&(w[k]=C/E):w[k]=C-E)}const S=new Array(h).fill(0),M=new Array(h).fill(0);for(let k=0;k<y;k++){if(w[k]===null)continue;const E=k%h;S[E]+=w[k],M[E]+=1}const X=a?1:0,q=S.map((k,E)=>M[E]?k/M[E]:X),K=q.reduce((k,E)=>k+E,0)/h,P=a?q.map(k=>K!==0?k/K:1):q.map(k=>k-K);for(let k=0;k<y;k++){const{key:E}=r[k];if(E==null)continue;const C=m[k],x=P[k%h],j=f[k];let T=null;C!==null&&j!==null&&(T=a?C*x!==0?j/(C*x):null:j-C-x),d.set(String(E),{trend:C,seasonal:j===null?null:x,residual:T,coverage:C===null?0:1,partial:C===null})}return d}function o(r,i,d,h=80){const a=(Math.sqrt(5)-1)/2;let y=i,f=d,m=f-a*(f-y),w=y+a*(f-y),S=r(m),M=r(w);for(let X=0;X<h;X++)S<M?(f=w,w=m,M=S,m=f-a*(f-y),S=r(m)):(y=m,m=w,S=M,w=y+a*(f-y),M=r(w));return(y+f)/2}const t=1e-4,s=1-1e-4;function l(r,i){const d=r.length,h=new Array(d).fill(null),a=new Array(d).fill(null);let y=null,f=0;for(let m=0;m<d;m++){const w=r[m];if(!Number.isFinite(w)){y!==null&&(a[m]=y,h[m]=y);continue}if(y===null){y=w,a[m]=w,h[m]=w;continue}a[m]=y,f+=(w-y)**2,y=i*w+(1-i)*y,h[m]=y}return{smoothed:h,fitted:a,sse:f}}function u(r,i,d){const h=r.length,a=new Array(h).fill(null),y=new Array(h).fill(null);let f=null,m=null,w=0;for(let S=0;S<h;S++){const M=r[S];if(!Number.isFinite(M)){f!==null&&(f+=m,a[S]=f);continue}if(f===null){f=M,a[S]=M;continue}if(m===null){m=M-f;const K=f+m;y[S]=K,w+=(M-K)**2;const P=f;f=i*M+(1-i)*(P+m),m=d*(f-P)+(1-d)*m,a[S]=f;continue}const X=f+m;y[S]=X,w+=(M-X)**2;const q=f;f=i*M+(1-i)*(q+m),m=d*(f-q)+(1-d)*m,a[S]=f}return{smoothed:a,fitted:y,sse:w}}function n(r,i={}){const d=new Map,h=i.method==="holt",a=r.map(X=>Number.isFinite(X.value)?X.value:null),y=a.filter(X=>X!==null).length,f=X=>Math.min(s,Math.max(t,X)),m=()=>{for(const{key:X}of r)X!=null&&d.set(String(X),{smoothed:null,fitted:null,alpha:null,beta:null,sse:null});return d};if(y<(h?2:1))return m();let w=Number.isFinite(i.alpha)?f(i.alpha):null,S=h&&Number.isFinite(i.beta)?f(i.beta):null;if(h){if(w===null||S===null){let X=w===null?.5:w,q=S===null?.5:S;for(let K=0;K<6;K++)w===null&&(X=o(P=>u(a,P,q).sse,t,s)),S===null&&(q=o(P=>u(a,X,P).sse,t,s));w=w===null?X:w,S=S===null?q:S}}else w===null&&(w=o(X=>l(a,X).sse,t,s));const M=h?u(a,w,S):l(a,w);for(let X=0;X<r.length;X++){const{key:q}=r[X];q!=null&&d.set(String(q),{smoothed:M.smoothed[X],fitted:M.fitted[X],alpha:w,beta:h?S:null,sse:M.sse})}return d}const p={ROLLING_WINDOW_FIELDS:I,QUANTILE_SPAN_CAP:_,rollingWindow:H,rollingQuantile:b,cumulativeToDate:L,periodOverPeriod:Y,seasonalDecompose:g,exponentialSmoothing:n}}),ze("packages/core/src/compute/cluster.js",function(e,B){"use strict";Object.defineProperty(e,"CLUSTER_ROW_CAP",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"DBSCAN_ROW_CAP",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"DEFAULT_K",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"DEFAULT_MIN_POINTS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"orderByCentre",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"kmeans",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"dbscan",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"autoK",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"standardise",{enumerable:!0,get:function(){return t}});const ne=1e5,A=2e4,V=3,U=5,I=100;function J(s){let l=s>>>0;return function(){l=l+1831565813|0;let n=Math.imul(l^l>>>15,1|l);return n=n+Math.imul(n^n>>>7,61|n)^n,((n^n>>>14)>>>0)/4294967296}}function H(s,l){let u=0;for(let n=0;n<s.length;n++){const p=s[n]-l[n];u+=p*p}return u}function L(s,l){return Math.sqrt(H(s,l))}function Y(s,l){let u=-1,n=1/0;for(let p=0;p<l.length;p++){const r=H(s,l[p]);r<n&&(n=r,u=p)}return u}function _(s,l,u){const n=J(u),p=s.length,r=[Array.from(s[Math.floor(n()*p)])],i=new Float64Array(p).fill(1/0);for(let d=1;d<l;d++){let h=0;for(let m=0;m<p;m++){const w=H(s[m],r[r.length-1]);w<i[m]&&(i[m]=w),h+=i[m]}const a=n()*(h||p);let y=0,f=p-1;for(let m=0;m<p;m++)if(y+=h?i[m]:1,y>=a){f=m;break}r.push(Array.from(s[f]))}return r}function O(s,l){for(let u=0;u<s.length;u++){const n=s[u]-l[u];if(n!==0)return n}return 0}function v(s,l,u,n){const p=l.map((i,d)=>({centre:i,i:d})).sort((i,d)=>O(i.centre,d.centre)),r=new Int32Array(l.length);for(let i=0;i<p.length;i++)r[p[i].i]=i;for(let i=0;i<s.length;i++)s[i]>=0&&(s[i]=r[s[i]]);return{assignments:s,centres:p.map(i=>i.centre),sizes:p.map(i=>u[i.i]),distances:n}}function b(s,l={}){const u=s.length,n=u?s[0].length:0,p=Math.floor(l.k||V);if(!(u>=p)||p<1||n<1)return null;let r=_(s,p,l.seed===void 0?1:l.seed);const i=new Int32Array(u);let d=!0;for(let f=0;f<I&&d;f++){d=!1;for(let S=0;S<u;S++){const M=Y(s[S],r);i[S]!==M&&(i[S]=M,d=!0)}const m=r.map(()=>new Float64Array(n)),w=new Array(p).fill(0);for(let S=0;S<u;S++){const M=i[S];for(let X=0;X<n;X++)m[M][X]+=s[S][X];w[M]++}for(let S=0;S<p;S++)if(w[S])for(let M=0;M<n;M++)r[S][M]=m[S][M]/w[S];else{let M=0,X=-1/0;for(let q=0;q<u;q++){const K=H(s[q],r[S]);K>X&&(X=K,M=q)}r[S]=Array.from(s[M]),d=!0}}const h=new Array(p).fill(0),a=new Float64Array(u);let y=0;for(let f=0;f<u;f++){const m=i[f];h[m]++;const w=H(s[f],r[m]);a[f]=Math.sqrt(w),y+=w}return{assignments:i,centres:r,sizes:h,inertia:y,distances:a}}function c(s,l={}){const u=s.length,n=u?s[0].length:0,p=Number(l.eps),r=Math.max(1,Math.floor(l.minPoints||U));if(!(p>0)||u===0||n<1)return null;const i=new Array(u);for(let w=0;w<u;w++){const S=[];for(let M=0;M<u;M++)w!==M&&L(s[w],s[M])<=p&&S.push(M);i[w]=S}const d=new Int32Array(u).fill(-1);let h=0;for(let w=0;w<u;w++){if(d[w]!==-1||i[w].length<r)continue;d[w]=h;const S=[...i[w]];for(let M=0;M<S.length;M++){const X=S[M];d[X]===-1&&(d[X]=h,i[X].length>=r&&S.push(...i[X]))}h++}if(!h)return{assignments:d,centres:[],sizes:[],distances:new Float64Array(u).fill(NaN)};const a=[],y=new Array(h).fill(0),f=Array.from({length:h},()=>new Float64Array(n));for(let w=0;w<u;w++){const S=d[w];if(!(S<0)){y[S]++;for(let M=0;M<n;M++)f[S][M]+=s[w][M]}}for(let w=0;w<h;w++){const S=new Array(n);for(let M=0;M<n;M++)S[M]=f[w][M]/y[w];a.push(S)}const m=new Float64Array(u).fill(NaN);for(let w=0;w<u;w++){const S=d[w];S>=0&&(m[w]=L(s[w],a[S]))}return{assignments:d,centres:a,sizes:y,distances:m}}function g(s,l,u){const n=s.length;if(n===0)return 0;const p=new Int32Array(u);for(let i=0;i<n;i++)p[l[i]]++;let r=0;for(let i=0;i<n;i++){const d=l[i],h=new Float64Array(u);for(let f=0;f<n;f++)i!==f&&(h[l[f]]+=L(s[i],s[f]));const a=p[d]>1?h[d]/(p[d]-1):0;let y=1/0;for(let f=0;f<u;f++){if(f===d||p[f]===0)continue;const m=h[f]/p[f];m<y&&(y=m)}y!==1/0&&(r+=(y-a)/Math.max(a,y))}return r/n}function o(s,l={}){const u=s.length;if(!u)return null;const n=l.criterion==="silhouette"?"silhouette":"elbow",p=Math.max(2,Math.floor(l.maxK||8)),r=l.seed===void 0?1:l.seed;if(n==="silhouette"){const w=[],S=[];for(let X=2;X<=Math.min(p,u);X++){const q=b(s,{k:X,seed:r});q&&(w.push(X),S.push(g(s,q.assignments,X)))}if(!w.length)return null;let M=0;for(let X=1;X<S.length;X++)S[X]>S[M]&&(M=X);return{k:w[M],criterion:n,scores:S,ks:w}}const i=[],d=[];for(let w=1;w<=Math.min(p,u);w++){const S=b(s,{k:w,seed:r});S&&(i.push(w),d.push(S.inertia))}if(d.length<2)return null;const h={k:i[0],y:d[0]},a={k:i[i.length-1],y:d[d.length-1]},y=Math.hypot(a.k-h.k,a.y-h.y)||1;let f=0,m=-1/0;for(let w=0;w<d.length;w++){const S=Math.abs((a.k-h.k)*(h.y-d[w])-(h.k-i[w])*(a.y-h.y))/y;S>m&&(m=S,f=w)}return{k:i[f],criterion:n,scores:d,ks:i}}function t(s){const l=s.length,u=l?s[0].length:0;if(!l||!u)return null;const n=new Array(u).fill(0);for(let r=0;r<l;r++)for(let i=0;i<u;i++)n[i]+=s[r][i];for(let r=0;r<u;r++)n[r]/=l;const p=new Array(u).fill(0);for(let r=0;r<l;r++)for(let i=0;i<u;i++){const d=s[r][i]-n[i];p[i]+=d*d}for(let r=0;r<u;r++)p[r]=l>1?Math.sqrt(p[r]/(l-1)):0;for(let r=0;r<l;r++)for(let i=0;i<u;i++)p[i]>0?s[r][i]=(s[r][i]-n[i])/p[i]:s[r][i]=s[r][i]-n[i];return{mean:n,sd:p}}}),ze("packages/core/src/compute/compare.js",function(e,B){"use strict";Object.defineProperty(e,"COMPARE_MEASURES",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"pooledStandardMeanDifference",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"numericSummary",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"bothNumeric",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"compareColumnAcross",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"compareDatasets",{enumerable:!0,get:function(){return c}});const ne=B("packages/core/src/compute/statistics.js"),A=ne.numbers,V=ne.moments,U=ne.frequencyMap,I=ne.categoricalDistance,J=ne.normalTotalVariation,H=ne.isNumericColumn,L=ne.SUBSET_RELIABILITY_FLOOR,Y=Object.freeze({numeric:"pooledStandardMeanDifference",categorical:"categoricalTotalVariation",common:"totalVariationDistance"});function _(g,o){if(!g||!o||!(g.n>0)||!(o.n>0)||!Number.isFinite(g.mean)||!Number.isFinite(o.mean))return null;const t=(g.n*g.sd*g.sd+o.n*o.sd*o.sd)/(g.n+o.n);return t>0?(g.mean-o.mean)/Math.sqrt(t):null}function O(g,o){const t=A(g,o),{n:s,mean:l,m2:u}=V(t),n=s>0?Math.sqrt(u/s):0;return{mean:l,sd:n,n:s}}function v(g,o,t,s){return H(g,o)&&H(t,s)}function b(g,o,t,s){if(v(g,o,t,s)){const p=O(g,o),r=O(t,s),i=_(p,r);return{measure:Y.numeric,magnitude:i,distance:i===null?0:J(i),direction:i===null?0:Math.sign(i),nA:p.n,nB:r.n,meanA:p.mean,meanB:r.mean,reliable:p.n>=L&&r.n>=L}}const l=U(g,o),u=U(t,s),n=I(l.map,l.total,u.map,u.total);return{measure:Y.categorical,magnitude:n,distance:n===null?0:n,direction:0,nA:l.total,nB:u.total,meanA:null,meanB:null,reliable:l.total>=L&&u.total>=L}}function c(g,o,t={}){const s=new Set(g.columns),l=new Set(o.columns),u=g.columns.filter(d=>l.has(d)),n=Array.isArray(t.columns)&&t.columns.length?u.filter(d=>t.columns.includes(d)):u,p=g.indices(),r=o.indices(),i=[];for(const d of n){const h=g.handle(d),a=o.handle(d);if(!h||!a)continue;const y=b(h,p,a,r);i.push({column:d,name:g.name&&g.name(d)||o.name&&o.name(d)||d,measure:y.measure,magnitude:y.magnitude,distance:y.distance,direction:y.direction,nA:y.nA,nB:y.nB,meanA:y.meanA,meanB:y.meanB,reliable:y.reliable})}return i.sort((d,h)=>h.distance-d.distance||Math.abs(h.magnitude||0)-Math.abs(d.magnitude||0)),{ranked:i,nA:p.length,nB:r.length,unmatched:{onlyA:g.columns.filter(d=>!l.has(d)),onlyB:o.columns.filter(d=>!s.has(d))},measures:Y}}}),ze("packages/core/src/compute/anomaly.js",function(e,B){"use strict";Object.defineProperty(e,"MAD_SCALE",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"DEFAULT_MODIFIED_Z_THRESHOLD",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"DEFAULT_IQR_K",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"DEFAULT_CHI_SQUARE_P",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"ANOMALY_METHODS",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"robustSpread",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"modifiedZScores",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"iqrFences",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"chiSquareCdf",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"chiSquareQuantile",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"mahalanobis",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"DEFAULT_ROLLING_WINDOW",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"rollingAnomalies",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"anomalyCondition",{enumerable:!0,get:function(){return p}});const A=B("packages/core/src/compute/statistics.js").quantileSorted,U=B("packages/core/src/compute/special.js").logGamma,I=.6745,J=3.5,H=1.5,L=.975,Y=Object.freeze(["modifiedZScore","iqr","mahalanobis"]);function _(r){if(!r.length)return null;const d=Array.from(r,Number).sort((f,m)=>f-m),h=A(d,.5),a=d.map(f=>Math.abs(f-h)).sort((f,m)=>f-m),y=A(a,.5);return{median:h,mad:y}}function O(r,i={}){const d=Number.isFinite(i.threshold)?i.threshold:J,h=r.length,a=new Array(h).fill(null),y=new Array(h).fill(!1),f=[];for(let S=0;S<h;S++){const M=Number(r[S]);Number.isFinite(M)&&f.push(M)}if(!f.length)return{median:null,mad:null,threshold:d,scores:a,flags:y,flagged:0};const m=_(f);if(m.mad===0)return{median:m.median,mad:0,threshold:d,scores:a,flags:y,flagged:0};let w=0;for(let S=0;S<h;S++){const M=Number(r[S]);if(!Number.isFinite(M))continue;const X=I*(M-m.median)/m.mad;a[S]=X,Math.abs(X)>d&&(y[S]=!0,w++)}return{median:m.median,mad:m.mad,threshold:d,scores:a,flags:y,flagged:w}}function v(r,i={}){const d=Number.isFinite(i.k)?i.k:H,h=[];for(let w=0;w<r.length;w++){const S=Number(r[w]);Number.isFinite(S)&&h.push(S)}if(!h.length)return null;const a=h.sort((w,S)=>w-S),y=A(a,.25),f=A(a,.75),m=f-y;return{q1:y,q3:f,iqr:m,lower:y-d*m,upper:f+d*m,k:d}}function b(r,i){if(i<=0)return 0;const d=U(r);if(i<r+1){let S=r,M=1/r,X=M;for(let q=0;q<1e3&&(S+=1,X*=i/S,M+=X,!(Math.abs(X)<Math.abs(M)*1e-15));q++);return M*Math.exp(-i+r*Math.log(i)-d)}const h=1e-300;let a=i+1-r,y=1/h,f=1/a,m=f;for(let S=1;S<1e3;S++){const M=-S*(S-r);a+=2,f=M*f+a,Math.abs(f)<h&&(f=h),y=a+M/y,Math.abs(y)<h&&(y=h),f=1/f;const X=f*y;if(m*=X,Math.abs(X-1)<1e-15)break}return 1-Math.exp(-i+r*Math.log(i)-d)*m}function c(r,i){return r<=0?0:b(i/2,r/2)}function g(r,i=L){if(!(i>0)||!(i<1))return NaN;let d=0,h=Math.max(1,r);for(;c(h,r)<i;)h*=2;for(let a=0;a<200;a++){const y=(d+h)/2;if(c(y,r)<i?d=y:h=y,h-d<1e-10)break}return(d+h)/2}function o(r){const i=r.length,d=r.map((h,a)=>{const y=h.slice();for(let f=0;f<i;f++)y.push(a===f?1:0);return y});for(let h=0;h<i;h++){let a=h;for(let f=h+1;f<i;f++)Math.abs(d[f][h])>Math.abs(d[a][h])&&(a=f);if(Math.abs(d[a][h])<1e-12)return null;if(a!==h){const f=d[a];d[a]=d[h],d[h]=f}const y=d[h][h];for(let f=0;f<2*i;f++)d[h][f]/=y;for(let f=0;f<i;f++){if(f===h)continue;const m=d[f][h];if(m!==0)for(let w=0;w<2*i;w++)d[f][w]-=m*d[h][w]}}return d.map(h=>h.slice(i))}function t(r,i){const d=r.length,h=new Array(i).fill(0);for(const f of r)for(let m=0;m<i;m++)h[m]+=f[m];for(let f=0;f<i;f++)h[f]/=d;const a=Array.from({length:i},()=>new Array(i).fill(0));for(const f of r)for(let m=0;m<i;m++){const w=f[m]-h[m];for(let S=m;S<i;S++)a[m][S]+=w*(f[S]-h[S])}const y=d>1?d-1:1;for(let f=0;f<i;f++)for(let m=f;m<i;m++)a[f][m]/=y,a[m][f]=a[f][m];return{mean:h,cov:a}}function s(r,i={}){const d=Number.isFinite(i.p)?i.p:L,h=Number.isFinite(i.ridge)?i.ridge:1e-6,a=r.length;if(!a)return null;const y=r[0].length;if(!y)return null;const f=new Array(a).fill(null),m=new Array(a).fill(null),w=new Array(a).fill(!1),S=[],M=[];for(let x=0;x<a;x++){const j=r[x];let T=j.length===y;const F=new Array(y);for(let $=0;T&&$<y;$++){const D=Number(j[$]);Number.isFinite(D)?F[$]=D:T=!1}T&&(S.push(x),M.push(F))}const X=y,q=g(X,d);if(M.length<=y)return{center:[],df:X,cutoff:q,singular:!0,used:M.length,distances:f,squared:m,flags:w,flagged:0};const{mean:K,cov:P}=t(M,y);let k=o(P),E=!1;if(!k){E=!0;let x=0;for(let F=0;F<y;F++)x+=P[F][F];const j=x/y*h||h,T=P.map((F,$)=>F.map((D,z)=>$===z?D+j:D));if(k=o(T),!k)return{center:K,df:X,cutoff:q,singular:!0,used:M.length,distances:f,squared:m,flags:w,flagged:0}}let C=0;for(let x=0;x<M.length;x++){const j=M[x],T=new Array(y);for(let D=0;D<y;D++)T[D]=j[D]-K[D];let F=0;for(let D=0;D<y;D++){let z=0;for(let G=0;G<y;G++)z+=k[D][G]*T[G];F+=T[D]*z}F<0&&(F=0);const $=S[x];m[$]=F,f[$]=Math.sqrt(F),F>q&&(w[$]=!0,C++)}return{center:K,df:X,cutoff:q,singular:E,used:M.length,distances:f,squared:m,flags:w,flagged:C}}const l=20,u=Object.freeze(["rollingModifiedZScore","rollingIqr"]);function n(r,i={}){const d=i.method==="rollingIqr"?"rollingIqr":"rollingModifiedZScore",h=Number.isFinite(i.windowLen)&&i.windowLen>=1?Math.floor(i.windowLen):l,a=Number.isFinite(i.threshold)?i.threshold:J,y=Number.isFinite(i.k)?i.k:H,f=Number.isFinite(i.minPeriods)&&i.minPeriods>=1?Math.floor(i.minPeriods):h,m=r.length,w=new Array(m).fill(null),S=new Array(m).fill(!1);let M=0;for(let X=0;X<m;X++){const q=Number(r[X]);if(!Number.isFinite(q))continue;const K=Math.max(0,X-h+1),P=[];for(let k=K;k<=X;k++){const E=Number(r[k]);Number.isFinite(E)&&P.push(E)}if(!(P.length<f))if(d==="rollingIqr"){const k=v(P,{k:y});if(!k)continue;(q<k.lower||q>k.upper)&&(S[X]=!0,M++)}else{const k=_(P);if(!k||k.mad===0)continue;const E=I*(q-k.median)/k.mad;w[X]=E,Math.abs(E)>a&&(S[X]=!0,M++)}}return{method:d,windowLen:h,minPeriods:f,threshold:a,k:y,scores:w,flags:S,flagged:M}}function p(r={}){const i=r||{},d=i.field;if(typeof d!="string"||!d)throw new TypeError("[lattice] anomalyCondition: a string `field` naming the numeric property to monitor is required");const h=i.method||"modifiedZScore";if(!(Y.includes(h)||u.includes(h))||h==="mahalanobis")throw new RangeError(`[lattice] anomalyCondition: unknown or unsupported method '${h}'`);const y=typeof i.orderBy=="string"?i.orderBy:null,f=i.latest===!0,m=u.includes(h),w=S=>Number(S==null?NaN:S[d]);return S=>{const M=Array.isArray(S)?S.slice():[...S];y&&M.sort((k,E)=>{const C=k?.[y],x=E?.[y];return C===x?0:C==null?-1:x==null?1:C<x?-1:1});const X=M.map(w);let q,K;if(m)({flags:q,scores:K}=n(X,{method:h,windowLen:i.windowLen,threshold:i.threshold,k:i.k,minPeriods:i.minPeriods}));else if(h==="iqr"){const k=v(X,{k:i.k});q=X.map(E=>k?Number.isFinite(E)&&(E<k.lower||E>k.upper):!1),K=X.map(()=>null)}else({flags:q,scores:K}=O(X,{threshold:i.threshold}));if(f){const k=q.length-1;return k<0||!q[k]?!1:{method:h,field:d,flagged:[{row:M[k],score:K[k]}]}}const P=[];for(let k=0;k<q.length;k++)q[k]&&P.push({row:M[k],score:K[k]});return P.length?{method:h,field:d,flagged:P}:!1}}}),ze("packages/core/src/compute/forecast.js",function(e,B){"use strict";Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return r}});const ne=B("packages/core/src/compute/special.js"),A=ne.normalQuantile,V=ne.studentTQuantile,I=B("packages/core/src/internal/warn.js").warnOnce,J=Object.freeze(["movingAverage","ses","holt","holtWinters","linear"]),H=1e-4,L=1-1e-4;function Y(i){const d=[];for(let h=0;h<i.length;h++){const a=i[h];if(a!==null&&typeof a=="object"){const y=Number.isFinite(a.at)?a.at:h,f=Number.isFinite(a.value)?a.value:null;d.push({at:y,value:f})}else d.push({at:h,value:Number.isFinite(a)?Number(a):null})}return d}function _(i){const d=i.filter(m=>m.value!==null),h=d[0],a=d[d.length-1],y=a.at-h.at,f=d.length>1&&y>0?y/(d.length-1):1;return{lastAt:a.at,step:f}}function O(i){return Math.min(L,Math.max(H,i))}function v(i,d=H,h=L,a=80){const y=(Math.sqrt(5)-1)/2;let f=d,m=h,w=m-y*(m-f),S=f+y*(m-f),M=i(w),X=i(S);for(let q=0;q<a;q++)M<X?(m=S,S=w,X=M,w=m-y*(m-f),M=i(w)):(f=w,w=S,M=X,S=f+y*(m-f),X=i(S));return(f+m)/2}function b(i,d){let h=null,a=0,y=0;for(let f=0;f<i.length;f++){const m=i[f];if(m!==null){if(h===null){h=m;continue}a+=(m-h)**2,y+=1,h=d*m+(1-d)*h}}return{level:h,sse:a,m:y}}function c(i,d,h){let a=null,y=null,f=0,m=0;for(let w=0;w<i.length;w++){const S=i[w];if(S===null){a!==null&&y!==null&&(a+=y);continue}if(a===null){a=S;continue}y===null&&(y=S-a);const M=a+y;f+=(S-M)**2,m+=1;const X=a;a=d*S+(1-d)*(X+y),y=h*(a-X)+(1-h)*y}return{level:a,trend:y,sse:f,m}}function g(i,d,h,a,y){const f=i.length;if(f<2*d)return null;const m=E=>{let C=0,x=0;for(let j=E;j<E+d&&j<f;j++)i[j]!==null&&(C+=i[j],x+=1);return x?C/x:null},w=m(0),S=m(d);if(w===null||S===null)return null;let M=w,X=(S-w)/d;const q=new Array(d).fill(0);for(let E=0;E<d;E++)q[E]=i[E]===null?0:i[E]-M;const K=q.reduce((E,C)=>E+C,0)/d;for(let E=0;E<d;E++)q[E]-=K;let P=0,k=0;for(let E=d;E<f;E++){const C=E%d,x=q[C],j=i[E];if(j===null){M+=X;continue}const T=M+X+x;P+=(j-T)**2,k+=1;const F=M;M=h*(j-x)+(1-h)*(M+X),X=a*(M-F)+(1-a)*X,q[C]=y*(j-M)+(1-y)*x}return{level:M,trend:X,season:q,phase:(f-1)%d,sse:P,count:k}}function o(i,d,h){let a=1;for(const f of d)a+=f*f;const y=Math.sqrt(i*a);return{se:y,margin:h*y}}function t(i,d={}){if(!i||typeof i.length!="number"||i.length===0)return null;const h=J.includes(d.method)?d.method:"linear",a=Math.max(1,Math.floor(Number(d.horizon)||1)),y=Number.isFinite(d.confidence)&&d.confidence>0&&d.confidence<1?d.confidence:.95,f=1-(1-y)/2,m=Y(i),w=m.map(P=>P.value),S=w.filter(P=>P!==null),M=S.length,{lastAt:X,step:q}=M?_(m):{lastAt:0,step:1},K=P=>X+P*q;return h==="linear"?s(m,M,a,y,f,K):h==="movingAverage"?l(S,M,a,y,f,d,K):h==="ses"?u(w,M,a,y,f,d,K):h==="holt"?n(w,M,a,y,f,d,K):p(w,M,a,y,f,d,K)}function s(i,d,h,a,y,f){if(d<2)return null;let m=0,w=0;for(const j of i)j.value!==null&&(m+=j.at,w+=j.value);m/=d,w/=d;let S=0,M=0,X=0;for(const j of i){if(j.value===null)continue;const T=j.at-m,F=j.value-w;S+=T*T,M+=T*F,X+=F*F}if(S===0)return null;const q=M/S,K=w-q*m,P=X===0?1:Math.max(0,Math.min(1,M*M/(S*X))),k=Math.max(0,X-q*M),E=d>2?Math.sqrt(k/(d-2)):null,C=d>2?V(y,d-2):null,x=[];for(let j=1;j<=h;j++){const T=f(j),F=K+q*T;let $=null,D=null,z=null,G=null,N=null;if(E!==null){const Z=1/d+(T-m)**2/S,Q=E*Math.sqrt(1+Z),ee=E*Math.sqrt(Z);N=Q,$=F-C*Q,D=F+C*Q,z=F-C*ee,G=F+C*ee}x.push({step:j,at:T,mean:F,lower:$,upper:D,lowerMean:z,upperMean:G,se:N})}return{method:"linear",horizon:h,confidence:a,n:d,sigma:E,r2:P,params:{slope:q,intercept:K},points:x}}function l(i,d,h,a,y,f,m){if(d<1)return null;const w=Math.max(1,Math.min(d,Math.floor(Number(f.windowLen)||d))),S=i.slice(d-w);let M=0;for(const E of S)M+=E;const X=M/w;let q=null,K=null;if(w>1){let E=0;for(const x of S)E+=(x-X)**2;q=Math.sqrt(E/(w-1))*Math.sqrt(1+1/w),K=V(y,w-1)}const P=q===null?null:K*q,k=[];for(let E=1;E<=h;E++)k.push({step:E,at:m(E),mean:X,lower:P===null?null:X-P,upper:P===null?null:X+P,se:q});return{method:"movingAverage",horizon:h,confidence:a,n:d,sigma:q===null?null:q,params:{windowLen:w},points:k}}function u(i,d,h,a,y,f,m){if(d<1)return null;let w=Number.isFinite(f.alpha)?O(f.alpha):null;w===null&&(w=v(K=>b(i,K).sse));const S=b(i,w),M=A(y),X=S.m>0?S.sse/S.m:null,q=[];for(let K=1;K<=h;K++){const P=S.level;let k=null,E=null,C=null;if(X!==null){const x=[];for(let T=1;T<K;T++)x.push(w);const j=o(X,x,M);C=j.se,k=P-j.margin,E=P+j.margin}q.push({step:K,at:m(K),mean:P,lower:k,upper:E,se:C})}return{method:"ses",horizon:h,confidence:a,n:d,sigma:X===null?null:Math.sqrt(X),params:{alpha:w},points:q}}function n(i,d,h,a,y,f,m){if(d<2)return null;let w=Number.isFinite(f.alpha)?O(f.alpha):null,S=Number.isFinite(f.beta)?O(f.beta):null;if(w===null||S===null){let k=w===null?.5:w,E=S===null?.5:S;for(let C=0;C<6;C++)w===null&&(k=v(x=>c(i,x,E).sse)),S===null&&(E=v(x=>c(i,k,x).sse));w=w===null?k:w,S=S===null?E:S}const M=c(i,w,S),X=A(y),q=M.m>0?M.sse/M.m:null,K=w*S,P=[];for(let k=1;k<=h;k++){const E=M.level+k*M.trend;let C=null,x=null,j=null;if(q!==null){const T=[];for(let $=1;$<k;$++)T.push(w+$*K);const F=o(q,T,X);j=F.se,C=E-F.margin,x=E+F.margin}P.push({step:k,at:m(k),mean:E,lower:C,upper:x,se:j})}return{method:"holt",horizon:h,confidence:a,n:d,sigma:q===null?null:Math.sqrt(q),params:{alpha:w,beta:S},points:P}}function p(i,d,h,a,y,f,m){const w=Math.floor(Number(f.period));if(!(w>=2))return I("forecast.holtWinters.period","forecast: holtWinters needs a period (opts.period >= 2)"),null;if(d<2*w)return null;let S=Number.isFinite(f.alpha)?O(f.alpha):null,M=Number.isFinite(f.beta)?O(f.beta):null,X=Number.isFinite(f.gamma)?O(f.gamma):null;const q=(j,T,F)=>{const $=g(i,w,j,T,F);return $?$.sse:1/0};if(S===null||M===null||X===null){let j=S===null?.5:S,T=M===null?.5:M,F=X===null?.5:X;for(let $=0;$<8;$++)S===null&&(j=v(D=>q(D,T,F))),M===null&&(T=v(D=>q(j,D,F))),X===null&&(F=v(D=>q(j,T,D)));S=S===null?j:S,M=M===null?T:M,X=X===null?F:X}const K=g(i,w,S,M,X);if(!K)return null;const P=A(y),k=K.count>0?K.sse/K.count:null,E=S*M,C=X*(1-S),x=[];for(let j=1;j<=h;j++){const T=K.season[(K.phase+j)%w],F=K.level+j*K.trend+T;let $=null,D=null,z=null;if(k!==null){const G=[];for(let Z=1;Z<j;Z++)G.push(S+Z*E+(Z%w===0?C:0));const N=o(k,G,P);z=N.se,$=F-N.margin,D=F+N.margin}x.push({step:j,at:m(j),mean:F,lower:$,upper:D,se:z})}return{method:"holtWinters",horizon:h,confidence:a,n:d,sigma:k===null?null:Math.sqrt(k),params:{alpha:S,beta:M,gamma:X,period:w},points:x}}const r={FORECAST_METHODS:J,forecast:t}}),ze("packages/core/src/compute/hypothesis.js",function(e,B){"use strict";Object.defineProperty(e,"GROUP_TESTS",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"NORMALITY_ALPHA",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"HL_PAIR_LIMIT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"welchTTest",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"mannWhitneyUTest",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"chiSquareTest",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"compareGroups",{enumerable:!0,get:function(){return P}});const A=B("packages/core/src/internal/warn.js").warnOnce,U=B("packages/core/src/compute/handle.js").valueReader,I=B("packages/core/src/compute/statistics.js"),J=I.numbers,H=I.moments,L=I.frequencyMap,Y=I.categoricalDistance,_=I.isNumericColumn,O=I.jarqueBera,v=I.proportionInterval,b=I.SUBSET_RELIABILITY_FLOOR,g=B("packages/core/src/compute/compare.js").pooledStandardMeanDifference,o=B("packages/core/src/compute/special.js"),t=o.studentT,s=o.studentTQuantile,l=o.normalCdf,u=o.normalQuantile,n=o.chiSquareUpperTail,p=Object.freeze({WELCH:"welch",MANN_WHITNEY:"mannWhitney",CHI_SQUARE:"chiSquare"}),r=.05,i=2e6;function d(k){const E=Number(k);return Number.isFinite(E)&&E>0&&E<1?E:.95}function h(k){const{n:E,mean:C,m2:x}=H(k);return{mean:C,sd:E>0?Math.sqrt(x/E):0,n:E}}function a(k,E){const C=k.length;if(C<2)return 0;let x=0;for(let j=0;j<C;j++){const T=k[j]-E;x+=T*T}return x/(C-1)}function y(k,E){return{name:"pooledStandardMeanDifference",value:g(h(k),h(E))}}function f(k,E,C){const x=k.length,j=E.length;if(x<2||j<2)return null;const T=d(C),{mean:F}=H(k),{mean:$}=H(E),D=a(k,F),z=a(E,$),G=D/x+z/j;if(!(G>0))return null;const N=Math.sqrt(G),Z=(F-$)/N,Q=D/x*(D/x)/(x-1),ee=z/j*(z/j)/(j-1),re=G*G/(Q+ee),ie=Math.min(1,Math.max(0,2*(1-t(Math.abs(Z),re)))),ce=F-$,ve=s(1-(1-T)/2,re)*N;return{test:p.WELCH,statistic:Z,statisticName:"t",df:re,pValue:ie,interval:{estimate:ce,lower:ce-ve,upper:ce+ve,confidence:T,method:"welch-t (difference of means)"},effectSize:y(k,E),nA:x,nB:j,reliable:x>=b&&j>=b,method:"Welch's t-test (unequal variances; Welch–Satterthwaite df)"}}function m(k){const E=k.length;if(E===0)return Number.NaN;const C=E>>1;return E%2?k[C]:(k[C-1]+k[C])/2}function w(k,E,C){const x=k.length,j=E.length,T=x*j;if(T===0||T>i)return null;const F=new Float64Array(T);let $=0;for(let Q=0;Q<x;Q++)for(let ee=0;ee<j;ee++)F[$++]=k[Q]-E[ee];F.sort();const D=m(F),z=Math.sqrt(x*j*(x+j+1)/12),G=u(1-(1-C)/2);let N=Math.round(T/2-G*z);N>=0||(N=0);const Z=Math.floor((T-1)/2);return N>Z&&(N=Z),{estimate:D,lower:F[N],upper:F[T-1-N],confidence:C,method:"hodges-lehmann (normal approximation)"}}function S(k,E,C){const x=k.length,j=E.length;if(x<1||j<1)return null;const T=d(C),F=x+j,$=new Array(F);for(let ie=0;ie<x;ie++)$[ie]={v:k[ie],g:0};for(let ie=0;ie<j;ie++)$[x+ie]={v:E[ie],g:1};$.sort((ie,ce)=>ie.v-ce.v);let D=0,z=0,G=0;for(;G<F;){let ie=G;for(;ie<F&&$[ie].v===$[G].v;)ie++;const ce=ie-G,ve=(G+1+ie)/2;for(let he=G;he<ie;he++)$[he].g===0&&(D+=ve);z+=ce*ce*ce-ce,G=ie}const N=D-x*(x+1)/2,Z=x*j/2,Q=x*j/12*(F+1-z/(F*(F-1)));let ee=1;if(Q>0){const ie=Math.max(0,Math.abs(N-Z)-.5);ee=Math.min(1,2*l(-ie/Math.sqrt(Q)))}const re=w(k,E,T);return{test:p.MANN_WHITNEY,statistic:N,statisticName:"U",df:null,pValue:ee,interval:re,effectSize:y(k,E),nA:x,nB:j,reliable:x>=b&&j>=b,method:"Mann-Whitney U (normal approximation, tie- and continuity-corrected)"}}function M(k,E,C,x,j){const T=v(k,E,j),F=v(C,x,j);if(!T||!F)return null;const $=T.proportion-F.proportion,D=$-Math.sqrt((T.proportion-T.lower)**2+(F.upper-F.proportion)**2),z=$+Math.sqrt((T.upper-T.proportion)**2+(F.proportion-F.lower)**2);return{lower:D,upper:z}}function X(k,E,C,x,j,T={}){if(!(E>0)||!(x>0))return null;const F=new Set([...k.keys(),...C.keys()]),$=F.size;if($<2)return null;const D=E+x;let z=0;for(const ee of F){const re=k.get(ee)||0,ie=C.get(ee)||0,ce=re+ie,ve=E*ce/D,he=x*ce/D;ve>0&&(z+=(re-ve)*(re-ve)/ve),he>0&&(z+=(ie-he)*(ie-he)/he)}const G=$-1,N=n(z,G);let Z=null;T.category!==void 0&&F.has(T.category)?Z=T.category:$===2&&([Z]=[...F]);let Q=null;if(Z!==null){const ee=M(k.get(Z)||0,E,C.get(Z)||0,x,d(j));ee&&(Q={estimate:(k.get(Z)||0)/E-(C.get(Z)||0)/x,lower:ee.lower,upper:ee.upper,confidence:d(j),method:"newcombe (difference in this category's share)",category:Z})}return{test:p.CHI_SQUARE,statistic:z,statisticName:"chiSquare",df:G,pValue:N,interval:Q,effectSize:{name:"categoricalTotalVariation",value:Y(k,E,C,x)},nA:E,nB:x,reliable:E>=b&&x>=b,method:"Pearson chi-square test of independence (2×k, no continuity correction)"}}function q(k){return k==null||k===""||typeof k=="number"&&Number.isNaN(k)?null:k instanceof Date?k.getTime():typeof k=="object"?String(k):k}function K(k,E,C){if(C===p.WELCH||C===p.MANN_WHITNEY)return{test:C,chosenBy:"override",reason:`caller override: ${C}`};const x=O(k),j=O(E),T=x===null?null:Math.exp(-x/2),F=j===null?null:Math.exp(-j/2);return T!==null&&T<r||F!==null&&F<r?{test:p.MANN_WHITNEY,chosenBy:"auto",reason:`column family: numeric, non-normal by Jarque-Bera (p < ${r})`}:{test:p.WELCH,chosenBy:"auto",reason:T!==null||F!==null?"column family: numeric, no departure from normality detected":"column family: numeric (too few rows to screen normality)"}}function P(k,E,C,x={}){if(!k||!E)return null;const j=d(x.confidence),T=U(E);let F;if(Array.isArray(x.groups)&&x.groups.length===2)F=[q(x.groups[0]),q(x.groups[1])];else{const{map:ie}=L(E,C),ce=[...ie.entries()].sort((ve,he)=>he[1]-ve[1]).slice(0,2).map(ve=>ve[0]);if(ce.length<2)return A("compareGroups:groups",'[lattice] compareGroups: the "by" column has fewer than two distinct values to group by.'),null;F=ce}const[$,D]=F;if($===null||D===null||$===D)return A("compareGroups:distinct","[lattice] compareGroups: the two groups must be two distinct, present values."),null;const z=[],G=[];for(let ie=0;ie<C.length;ie++){const ce=q(T(C[ie]));ce===$?z.push(C[ie]):ce===D&&G.push(C[ie])}if(z.length===0||G.length===0)return A("compareGroups:empty","[lattice] compareGroups: one of the two groups has no rows in the current set."),null;const N=x.test&&x.test!=="auto"?String(x.test):null,Z=_(k,z.concat(G));let Q,ee,re;if(N===p.CHI_SQUARE||!N&&!Z){ee=N?"override":"auto",re=N?"caller override: chiSquare":"column family: categorical";const ie=L(k,z),ce=L(k,G);Q=X(ie.map,ie.total,ce.map,ce.total,j,{category:x.category})}else{if((N===p.WELCH||N===p.MANN_WHITNEY)&&!Z)return A("compareGroups:numeric-override",`[lattice] compareGroups: ${N} needs a numeric column, but the column is not numeric.`),null;const ie=J(k,z),ce=J(k,G),ve=K(ie,ce,N);ee=ve.chosenBy,re=ve.reason,Q=ve.test===p.MANN_WHITNEY?S(ie,ce,j):f(ie,ce,j)}return Q?{...Q,chosenBy:ee,reason:re,groups:[$,D]}:(A("compareGroups:degenerate","[lattice] compareGroups: the chosen test had too little to work with (too few values, or no variation)."),null)}}),ze("packages/core/src/compute/significance.js",function(e,B){"use strict";Object.defineProperty(e,"COMPARE_TESTS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"compare",{enumerable:!0,get:function(){return ye}});const A=B("packages/core/src/internal/warn.js").warnOnce,U=B("packages/core/src/compute/handle.js").valueReader,I=B("packages/core/src/compute/statistics.js"),J=I.numbers,H=I.moments,L=I.frequencyMap,Y=I.isNumericColumn,_=I.jarqueBera,O=I.proportionInterval,v=B("packages/core/src/compute/special.js"),b=v.studentT,c=v.studentTQuantile,g=v.normalCdf,o=v.normalQuantile,t=v.chiSquareUpperTail,s=v.incompleteBeta,l=Object.freeze({T:"t",WELCH:"welch",MANN_WHITNEY:"mannWhitney",ANOVA:"anova",KRUSKAL:"kruskal",CHI_SQUARE:"chiSquare",PROPORTIONS:"proportions"}),u=new Set([l.T,l.WELCH,l.MANN_WHITNEY]),n=new Set([l.ANOVA,l.KRUSKAL]),p=new Set([l.CHI_SQUARE,l.PROPORTIONS]),r=.05,i=[.2,.5,.8],d=[.147,.33,.474],h=[.01,.06,.14],a=[[.1,.3,.5],[.07,.21,.35],[.06,.17,.29],[.05,.15,.25]];function y(fe){const ae=Number(fe);return Number.isFinite(ae)&&ae>0&&ae<1?ae:.05}function f(fe){return fe==null||fe===""||typeof fe=="number"&&Number.isNaN(fe)?null:fe instanceof Date?fe.getTime():typeof fe=="object"?String(fe):fe}function m(fe,ae){const ke=U(fe),pe=[],ue=new Map;for(let we=0;we<ae.length;we++){const Te=f(ke(ae[we]));if(Te===null)continue;let Ne=ue.get(Te);Ne||(Ne={value:Te,rows:[]},ue.set(Te,Ne),pe.push(Ne)),Ne.rows.push(ae[we])}return pe}function w(fe){const{n:ae,mean:ke,m2:pe}=H(fe),ue=ae>1?pe/(ae-1):0;return{n:ae,mean:ke,sd:Math.sqrt(ue),variance:ue}}function S(fe,ae,ke){if(!(ae>0)||!(ke>0)||!(fe>=0)||!Number.isFinite(fe))return Number.NaN;if(fe===0)return 1;const pe=ae*fe/(ae*fe+ke);return 1-s(ae/2,ke/2,pe)}function M(fe,ae){const ke=Math.abs(fe);return Number.isFinite(ke)?ke>=ae[2]?"large":ke>=ae[1]?"medium":ke>=ae[0]?"small":"negligible":"negligible"}function X(fe,ae,ke){if(fe==="cohensD")return M(ae,i);if(fe==="cliffsDelta")return M(ae,d);if(fe==="etaSquared")return M(ae,h);const pe=Math.max(1,Math.min(a.length,Math.floor(ke||1)));return M(ae,a[pe-1])}function q(fe,ae){if(!(fe.n>1)||!(ae.n>1))return null;const ke=((fe.n-1)*fe.variance+(ae.n-1)*ae.variance)/(fe.n+ae.n-2);return ke>0?(fe.mean-ae.mean)/Math.sqrt(ke):null}function K(fe,ae){const ke=fe.length,pe=ae.length;if(!ke||!pe)return null;const ue=Array.from(ae).sort((Ne,_e)=>Ne-_e);let we=0,Te=0;for(let Ne=0;Ne<ke;Ne++){const _e=fe[Ne];let $e=0,je=pe;for(;$e<je;){const Ee=$e+je>>1;ue[Ee]<_e?$e=Ee+1:je=Ee}const Ge=$e;let Fe=$e;for(;Fe<pe&&ue[Fe]===_e;)Fe++;const Pe=Fe-$e;we+=Ge,Te+=pe-Fe}return(we-Te)/(ke*pe)}function P(fe,ae,ke,pe){const ue=Math.min(ke-1,pe-1);return!(ae>0)||!(ue>0)?null:Math.sqrt(fe/(ae*ue))}function k(fe){return Number.isFinite(fe)?fe<.001?"p < 0.001":fe>=.995?"p > 0.995":`p = ${fe.toFixed(3)}`:"p = —"}function E(fe){if(!Number.isFinite(fe))return"0";const ae=Math.abs(fe);return ae===0?"0":ae>=1e3?String(Math.round(fe)):ae>=100?String(Number(fe.toFixed(0))):ae>=10?String(Number(fe.toFixed(1))):ae>=1?String(Number(fe.toFixed(2))):String(Number(fe.toPrecision(2)))}const C=new Set(["cohensD","cliffsDelta"]);function x(fe){if(fe.difference!=null&&Math.abs(fe.difference)>=1e-12)return Math.sign(fe.difference);const ae=fe.effectSize;if(ae&&C.has(ae.name)&&Number.isFinite(ae.value)&&Math.abs(ae.value)>=1e-12)return Math.sign(ae.value);const[ke,pe]=fe.groups;return Number.isFinite(ke.mean)&&Number.isFinite(pe.mean)&&ke.mean!==pe.mean?Math.sign(ke.mean-pe.mean):0}function j(fe){const ae=fe.measureName||"values";return{subject:ae.charAt(0).toUpperCase()+ae.slice(1),be:ae==="values"?"are":"is",name:ae}}function T(fe,ae){const ke=ae.unit?` ${ae.unit}`:"",{subject:pe,be:ue}=j(ae),we=fe.groups[0].label,Te=fe.groups[1].label,Ne=fe.effectSize?fe.effectSize.label:"negligible",_e=fe.pValue<fe.alpha,$e=_e?"unlikely to be chance":"consistent with chance";if(!_e&&Ne==="negligible")return`${pe} ${ue} essentially the same for ${we} and ${Te} (${k(fe.pValue)}); the effect is ${Ne}.`;const je=x(fe),Ge=`the difference is ${$e} (${k(fe.pValue)}) and the effect is ${Ne}.`;if(je===0)return`${pe} ${ue} different between ${we} and ${Te}; ${Ge}`;const Fe=je>0?we:Te,Pe=je>0?Te:we,Ee=fe.difference!=null&&Math.abs(fe.difference)>=1e-12,Me=Math.abs(fe.difference),Ie=Ee?typeof ae.formatValue=="function"?` by about ${ae.formatValue(Me)}${ke}`:` by about ${E(Me)}${ke}`:"";return`${pe} ${ue} higher for ${Fe} than for ${Pe}${Ie}; ${Ge}`}function F(fe,ae){const{name:ke}=j(ae),pe=fe.effectSize?fe.effectSize.label:"negligible",ue=k(fe.pValue);return fe.pValue<fe.alpha?`The groups differ in ${ke}; the difference is unlikely to be chance (${ue}) and the effect is ${pe}.`:pe==="negligible"?`The groups are essentially the same in ${ke} (${ue}); the effect is ${pe}.`:`The groups show a ${pe} effect in ${ke}, but the difference is consistent with chance (${ue}).`}function $(fe,ae){const ke=fe.length;if(ke<2)return null;const{mean:pe,m2:ue}=H(fe),we=ue/(ke-1);if(!(we>0))return null;const Te=Math.sqrt(we),Ne=Te/Math.sqrt(ke),_e=pe/Ne,$e=ke-1,je=Math.min(1,Math.max(0,2*(1-b(Math.abs(_e),$e)))),Ge=c(1-ae/2,$e)*Ne,Fe=pe/Te;return{test:l.T,statistic:_e,statisticName:"t",df:$e,pValue:je,difference:pe,interval:{estimate:pe,lower:pe-Ge,upper:pe+Ge,confidence:1-ae,method:"paired-t (mean of the pair differences)"},effectSize:{name:"cohensD",label:M(Fe,i),value:Fe}}}function D(fe,ae){const ke=Array.from(fe).filter(Me=>Me!==0),pe=ke.length;if(!pe)return null;const ue=Array.from({length:pe},(Me,Ie)=>Ie).sort((Me,Ie)=>Math.abs(ke[Me])-Math.abs(ke[Ie])),we=new Array(pe);let Te=0;for(;Te<pe;){let Me=Te;for(;Me+1<pe&&Math.abs(ke[ue[Me+1]])===Math.abs(ke[ue[Te]]);)Me++;const Ie=(Te+Me)/2+1;for(let We=Te;We<=Me;We++)we[ue[We]]=Ie;Te=Me+1}let Ne=0,_e=0;for(let Me=0;Me<pe;Me++)_e+=we[Me],ke[Me]>0&&(Ne+=we[Me]);const $e=_e-Ne,je=pe*(pe+1)/4,Ge=Math.sqrt(pe*(pe+1)*(2*pe+1)/24),Fe=Ge>0?(Math.abs(Ne-je)-.5)/Ge:0,Pe=Math.min(1,Math.max(0,2*g(-Math.max(0,Fe)))),Ee=_e>0?(Ne-$e)/_e:0;return{test:l.MANN_WHITNEY,statistic:Ne,statisticName:"W",df:null,pValue:Pe,difference:null,interval:null,effectSize:{name:"cliffsDelta",label:M(Ee,d),value:Ee}}}function z(fe,ae,ke){const pe=w(fe),ue=w(ae);if(pe.n<2||ue.n<2)return null;const we=((pe.n-1)*pe.variance+(ue.n-1)*ue.variance)/(pe.n+ue.n-2);if(!(we>0))return null;const Te=Math.sqrt(we*(1/pe.n+1/ue.n)),Ne=(pe.mean-ue.mean)/Te,_e=pe.n+ue.n-2,$e=Math.min(1,Math.max(0,2*(1-b(Math.abs(Ne),_e)))),je=pe.mean-ue.mean,Ge=c(1-ke/2,_e)*Te,Fe=q(pe,ue);return{test:l.T,statistic:Ne,statisticName:"t",df:_e,pValue:$e,difference:je,interval:{estimate:je,lower:je-Ge,upper:je+Ge,confidence:1-ke,method:"student-t (pooled variance, difference of means)"},effectSize:{name:"cohensD",label:M(Fe,i),value:Fe},summaries:[pe,ue]}}function G(fe,ae,ke){const pe=w(fe),ue=w(ae);if(pe.n<2||ue.n<2)return null;const we=pe.variance/pe.n+ue.variance/ue.n;if(!(we>0))return null;const Te=Math.sqrt(we),Ne=(pe.mean-ue.mean)/Te,_e=pe.variance/pe.n*(pe.variance/pe.n)/(pe.n-1),$e=ue.variance/ue.n*(ue.variance/ue.n)/(ue.n-1),je=we*we/(_e+$e),Ge=Math.min(1,Math.max(0,2*(1-b(Math.abs(Ne),je)))),Fe=pe.mean-ue.mean,Pe=c(1-ke/2,je)*Te,Ee=q(pe,ue);return{test:l.WELCH,statistic:Ne,statisticName:"t",df:je,pValue:Ge,difference:Fe,interval:{estimate:Fe,lower:Fe-Pe,upper:Fe+Pe,confidence:1-ke,method:"welch-t (unequal variances, difference of means)"},effectSize:{name:"cohensD",label:M(Ee,i),value:Ee},summaries:[pe,ue]}}function N(fe,ae,ke){const pe=fe.length,ue=ae.length;if(pe<1||ue<1)return null;const we=w(fe),Te=w(ae),Ne=pe+ue,_e=new Array(Ne);for(let We=0;We<pe;We++)_e[We]={v:fe[We],g:0};for(let We=0;We<ue;We++)_e[pe+We]={v:ae[We],g:1};_e.sort((We,Ye)=>We.v-Ye.v);let $e=0,je=0,Ge=0;for(;Ge<Ne;){let We=Ge;for(;We<Ne&&_e[We].v===_e[Ge].v;)We++;const Ye=(Ge+1+We)/2;for(let Qe=Ge;Qe<We;Qe++)_e[Qe].g===0&&($e+=Ye);const nt=We-Ge;je+=nt*nt*nt-nt,Ge=We}const Fe=$e-pe*(pe+1)/2,Pe=pe*ue/2,Ee=pe*ue/12*(Ne+1-je/(Ne*(Ne-1)));let Me=1;if(Ee>0){const We=Math.max(0,Math.abs(Fe-Pe)-.5);Me=Math.min(1,2*g(-We/Math.sqrt(Ee)))}const Ie=K(fe,ae);return{test:l.MANN_WHITNEY,statistic:Fe,statisticName:"U",df:null,pValue:Me,difference:null,interval:Z(fe,ae,1-ke),effectSize:{name:"cliffsDelta",label:M(Ie,d),value:Ie},summaries:[we,Te]}}function Z(fe,ae,ke){const pe=fe.length,ue=ae.length,we=pe*ue;if(we===0||we>2e6)return null;const Te=new Float64Array(we);let Ne=0;for(let Ee=0;Ee<pe;Ee++)for(let Me=0;Me<ue;Me++)Te[Ne++]=fe[Ee]-ae[Me];Te.sort();const _e=we>>1,$e=we%2?Te[_e]:(Te[_e-1]+Te[_e])/2,je=Math.sqrt(pe*ue*(pe+ue+1)/12),Ge=o(1-(1-ke)/2);let Fe=Math.round(we/2-Ge*je);Fe>=0||(Fe=0);const Pe=Math.floor((we-1)/2);return Fe>Pe&&(Fe=Pe),{estimate:$e,lower:Te[Fe],upper:Te[we-1-Fe],confidence:ke,method:"hodges-lehmann (location shift)"}}function Q(fe,ae){const ke=fe.length,pe=fe.map(w);if(pe.some(Me=>Me.n<2))return null;const ue=pe.reduce((Me,Ie)=>Me+Ie.n,0),we=pe.reduce((Me,Ie)=>Me+Ie.mean*Ie.n,0)/ue;let Te=0,Ne=0;for(let Me=0;Me<ke;Me++)Te+=pe[Me].n*(pe[Me].mean-we)**2,Ne+=(pe[Me].n-1)*pe[Me].variance;const _e=ke-1,$e=ue-ke;if(!(Ne>0)||$e<1)return null;const je=Te/_e,Ge=Ne/$e,Fe=je/Ge,Pe=Math.min(1,Math.max(0,S(Fe,_e,$e))),Ee=Te/(Te+Ne);return{test:l.ANOVA,statistic:Fe,statisticName:"F",df:{between:_e,within:$e},pValue:Pe,difference:null,interval:null,effectSize:{name:"etaSquared",label:M(Ee,h),value:Ee},summaries:pe}}function ee(fe,ae){const ke=fe.length,pe=fe.map(w);if(ke<2)return null;const ue=pe.reduce((Ie,We)=>Ie+We.n,0),we=[];for(let Ie=0;Ie<ke;Ie++)for(let We=0;We<fe[Ie].length;We++)we.push({v:fe[Ie][We],g:Ie});we.sort((Ie,We)=>Ie.v-We.v);const Te=new Array(we.length);let Ne=0,_e=0;for(;_e<we.length;){let Ie=_e;for(;Ie<we.length&&we[Ie].v===we[_e].v;)Ie++;const We=(_e+1+Ie)/2;for(let nt=_e;nt<Ie;nt++)Te[nt]=We;const Ye=Ie-_e;Ne+=Ye*Ye*Ye-Ye,_e=Ie}const $e=new Array(ke).fill(0);for(let Ie=0;Ie<we.length;Ie++)$e[we[Ie].g]+=Te[Ie];let je=0;for(let Ie=0;Ie<ke;Ie++)je+=$e[Ie]*$e[Ie]/pe[Ie].n;je=12/(ue*(ue+1))*je-3*(ue+1);const Ge=1-Ne/(ue*ue*ue-ue),Fe=Ge>0?je/Ge:je,Pe=ke-1,Ee=Math.min(1,Math.max(0,t(Fe,Pe))),Me=(Fe-ke+1)/(ue-ke);return{test:l.KRUSKAL,statistic:Fe,statisticName:"H",df:Pe,pValue:Ee,difference:null,interval:null,effectSize:{name:"etaSquared",label:M(Me,h),value:Math.max(0,Me)},summaries:pe}}function re(fe,ae,ke,pe,ue){const we=O(fe,ae,ue),Te=O(ke,pe,ue);if(!we||!Te)return null;const Ne=we.proportion-Te.proportion,_e=Ne-Math.sqrt((we.proportion-we.lower)**2+(Te.upper-Te.proportion)**2),$e=Ne+Math.sqrt((we.upper-we.proportion)**2+(Te.proportion-Te.lower)**2);return{estimate:Ne,lower:_e,upper:$e}}function ie(fe,ae,ke,pe){const ue=U(ae),we=new Set,Te=[];for(const We of fe){const Ye=new Map;let nt=0;for(const Qe of We.rows){const dt=f(ue(Qe));dt!==null&&(Ye.set(dt,(Ye.get(dt)||0)+1),nt++,we.add(dt))}Te.push(Ye),We.total=nt}const Ne=[...we];if(Ne.length<2)return null;const _e=fe.reduce((We,Ye)=>We+Ye.total,0);if(!(_e>0))return null;let $e=0;for(const We of fe)for(const Ye of Ne){const nt=Te[fe.indexOf(We)].get(Ye)||0,Qe=fe.reduce((jt,Et)=>jt+(Te[fe.indexOf(Et)].get(Ye)||0),0),dt=We.total*Qe/_e;dt>0&&($e+=(nt-dt)*(nt-dt)/dt)}const je=fe.length,Ge=Ne.length,Fe=(je-1)*(Ge-1),Pe=Math.min(1,Math.max(0,t($e,Fe))),Ee=P($e,_e,je,Ge);let Me=null;if(je===2&&Ge===2){const[We]=Ne,Ye=Te[0].get(We)||0,nt=Te[1].get(We)||0,Qe=re(Ye,fe[0].total,nt,fe[1].total,pe);Qe&&(Me={...Qe,confidence:pe,method:"newcombe (difference in this category's share)",category:We})}const Ie=fe.map((We,Ye)=>{const nt={};for(const Qe of Ne)nt[String(Qe)]=(Te[Ye].get(Qe)||0)/We.total;return nt});return{test:l.CHI_SQUARE,statistic:$e,statisticName:"chiSquare",df:Fe,pValue:Pe,difference:null,interval:Me,effectSize:{name:"cramersV",label:X("cramersV",Ee,Math.min(je-1,Ge-1)),value:Ee},proportions:Ie}}function ce(fe,ae,ke,pe){const ue=U(ae),we=new Set;for(const Qe of fe)for(const dt of Qe.rows){const jt=f(ue(dt));jt!==null&&we.add(jt)}if(we.size!==2)return null;const[Te]=[...we],Ne=fe[0].rows.reduce((Qe,dt)=>Qe+(f(ue(dt))===Te?1:0),0),_e=fe[1].rows.reduce((Qe,dt)=>Qe+(f(ue(dt))===Te?1:0),0),$e=fe[0].rows.length,je=fe[1].rows.length;if(!($e>0)||!(je>0))return null;const Ge=Ne/$e,Fe=_e/je,Pe=(Ne+_e)/($e+je);if(!(Pe>0)||!(Pe<1))return null;const Ee=Math.sqrt(Pe*(1-Pe)*(1/$e+1/je)),Me=(Ge-Fe)/Ee,Ie=Math.min(1,Math.max(0,2*g(-Math.abs(Me)))),We=Ge-Fe,Ye=re(Ne,$e,_e,je,pe),nt=P(Me*Me,$e+je,2,2);return{test:l.PROPORTIONS,statistic:Me,statisticName:"z",df:null,pValue:Ie,difference:We,interval:Ye?{...Ye,confidence:pe,method:"newcombe (difference in proportions)",category:Te}:null,effectSize:{name:"cramersV",label:X("cramersV",nt,1),value:nt},proportions:[{[String(Te)]:Ge},{[String(Te)]:Fe}],focalCategory:Te}}function ve(fe,ae,ke,pe){if(ke&&u.has(ke))return{test:ke,reason:`caller override: ${ke}`};const ue=_(fe),we=_(ae),Te=ue===null?null:Math.exp(-ue/2),Ne=we===null?null:Math.exp(-we/2);if(Te!==null&&Te<r||Ne!==null&&Ne<r)return{test:l.MANN_WHITNEY,reason:"two numeric groups, non-normal by Jarque-Bera"};const _e=w(fe),$e=w(ae);if(_e.n>=3&&$e.n>=3&&_e.variance>0&&$e.variance>0){const je=Math.max(_e.variance,$e.variance)/Math.min(_e.variance,$e.variance),Ge=_e.variance>=$e.variance?_e.n-1:$e.n-1,Fe=_e.variance>=$e.variance?$e.n-1:_e.n-1;if(2*Math.min(S(je,Ge,Fe),1-S(je,Ge,Fe))<pe)return{test:l.WELCH,reason:"two numeric groups, unequal variances (F-test)"}}return{test:l.T,reason:Te!==null||Ne!==null?"two numeric groups, equal variances and no departure from normality":"two numeric groups (too few rows to screen normality)"}}function he(fe,ae){if(ae&&n.has(ae))return{test:ae,reason:`caller override: ${ae}`};for(const ke of fe){const pe=_(ke),ue=pe===null?null:Math.exp(-pe/2);if(ue!==null&&ue<r)return{test:l.KRUSKAL,reason:"three or more numeric groups, non-normal by Jarque-Bera"}}return{test:l.ANOVA,reason:"three or more numeric groups, no departure from normality detected"}}function ye(fe,ae,ke,pe={},ue=null){if(!fe||!ae)return null;const we=y(pe.alpha),Te=1-we,Ne=pe.test&&pe.test!=="auto"?String(pe.test):null,_e=m(ae,ke);if(_e.length<2)return A("compare:groups",'[lattice] statistics.compare: the "by" column has fewer than two distinct values to group by.'),null;let $e;if(Array.isArray(pe.groups)&&pe.groups.length===2){const Ye=[f(pe.groups[0]),f(pe.groups[1])];if(Ye[0]===null||Ye[1]===null||Ye[0]===Ye[1])return A("compare:distinct","[lattice] statistics.compare: the two groups must be two distinct, present values."),null;if($e=_e.filter(nt=>nt.value===Ye[0]||nt.value===Ye[1]),$e.length!==2)return A("compare:empty","[lattice] statistics.compare: one of the two groups has no rows in the current set."),null;$e.sort((nt,Qe)=>nt.value===Ye[0]?-1:1)}else _e.length===2||Ne&&u.has(Ne)||Ne&&p.has(Ne)?$e=_e.slice(0,2):(Ne&&n.has(Ne),$e=_e);const Ge=Y(fe,ke),Fe=!!pe.paired&&ue&&$e.length===2&&Ge;let Pe,Ee,Me;if(Ge)if($e.length===2&&!(Ne&&n.has(Ne))){const Ye=J(fe,$e[0].rows),nt=J(fe,$e[1].rows);if(Ye.length<3||nt.length<3)return A("compare:small","[lattice] statistics.compare: each group needs at least three readings to compare."),null;if(w(Ye).variance===0||w(nt).variance===0)return A("compare:zero-variance","[lattice] statistics.compare: a group has zero variance, so the difference has no scale to test."),null;if(Fe){const dt=Le(fe,ue,$e[0].rows,$e[1].rows);return dt?(Ee=Ne?"override":"auto",Me=Ne?`caller override: ${Ne} (paired)`:"two numeric groups, paired",Pe=Ne===l.MANN_WHITNEY?D(dt.diffs,we):$(dt.diffs,we),Pe?(Pe.paired=!0,Pe.chosenBy=Ee,Pe.reason=Me,Pe.groups=[{value:$e[0].value,label:String($e[0].value),n:dt.n},{value:$e[1].value,label:String($e[1].value),n:dt.n}],Pe.alpha=we,Pe.method=Pe.test===l.MANN_WHITNEY?"Wilcoxon signed-rank test (paired)":"Student's paired t-test (difference of pairs)",Pe.verdict=T(Pe,pe),Pe.categorical=!1,Pe):(A("compare:degenerate","[lattice] statistics.compare: the paired test had too little to work with."),null)):(A("compare:paired","[lattice] statistics.compare: not enough matched pairs to run a paired test."),null)}const Qe=ve(Ye,nt,Ne,we);Ee=Ne?"override":"auto",Me=Qe.reason,Qe.test===l.MANN_WHITNEY?Pe=N(Ye,nt,we):Qe.test===l.WELCH?Pe=G(Ye,nt,we):Pe=z(Ye,nt,we),Pe&&Pe.interval&&Pe.difference===null&&(Pe.difference=Pe.interval.estimate)}else{const Ye=$e.map(Qe=>J(fe,Qe.rows));if(Ye.some(Qe=>Qe.length<3))return A("compare:small","[lattice] statistics.compare: each group needs at least three readings to compare."),null;const nt=he(Ye,Ne);Ee=Ne?"override":"auto",Me=nt.reason,Pe=nt.test===l.KRUSKAL?ee(Ye,we):Q(Ye,we)}else if($e.length===2){const Ye=Oe(fe,$e).size===2;if(Ne===l.PROPORTIONS||Ye&&!Ne)Ee=Ne?"override":"auto",Me=Ne?"caller override: proportions":"categorical measure with two categories (binary)",Pe=ce($e,fe,we,Te);else if(Ne===l.CHI_SQUARE||!Ye&&!Ne)Ee=Ne?"override":"auto",Me=Ne?"caller override: chiSquare":`categorical measure with ${Oe(fe,$e).size} categories`,Pe=ie($e,fe,we,Te);else return A("compare:numeric-needed",`[lattice] statistics.compare: ${Ne} needs a numeric measure, but the column is categorical.`),null}else Ee=Ne?"override":"auto",Me=Ne?`caller override: ${Ne}`:`categorical measure with ${Oe(fe,$e).size} categories`,Pe=ie($e,fe,we,Te);if(!Pe)return A("compare:degenerate","[lattice] statistics.compare: the chosen test had too little to work with (too few values, or no variation)."),null;const Ie=Pe.summaries,We=Pe.proportions;return{test:Pe.test,chosenBy:Ee,reason:Me,statistic:Pe.statistic,statisticName:Pe.statisticName,df:Pe.df===void 0?null:Pe.df,pValue:Pe.pValue,alpha:we,paired:!1,interval:Pe.interval||null,effectSize:Pe.effectSize,groups:$e.map((Ye,nt)=>({value:Ye.value,label:String(Ye.value),n:Ie?Ie[nt].n:Ye.total,...Ie?{mean:Ie[nt].mean,sd:Ie[nt].sd}:{},...We?{proportions:We[nt]}:{}})),difference:Pe.difference===void 0?null:Pe.difference,method:Pe.test,categorical:!Ge,verdict:$e.length===2?T({...Pe,alpha:we,groups:[{value:$e[0].value,label:String($e[0].value),mean:Ie?Ie[0].mean:void 0},{value:$e[1].value,label:String($e[1].value),mean:Ie?Ie[1].mean:void 0}],categorical:!Ge,difference:Pe.difference===void 0?null:Pe.difference},pe):F({...Pe,alpha:we},pe)}}function Oe(fe,ae){const ke=U(fe),pe=new Set;for(const ue of ae)for(const we of ue.rows){const Te=f(ke(we));Te!==null&&pe.add(Te)}return pe}function Le(fe,ae,ke,pe){const ue=U(ae),we=U(fe),Te=new Map;for(const _e of pe){const $e=f(ue(_e));$e!==null&&Te.set($e,we(_e))}const Ne=[];for(const _e of ke){const $e=f(ue(_e));if($e===null||!Te.has($e))continue;const je=Number(we(_e)),Ge=Number(Te.get($e));!Number.isFinite(je)||!Number.isFinite(Ge)||Ne.push(je-Ge)}return Ne.length<2?null:{diffs:Float64Array.from(Ne),n:Ne.length}}}),ze("packages/core/src/columns/detailcolumn.js",function(e,B){"use strict";Object.defineProperty(e,"DETAIL_COLUMN_ID",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"createDetailColumn",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return U}});const ne="__lattice_detail",A=36;function V(I){const J=I.config&&I.config.detailColumnWidth||A;return{id:ne,field:null,title:"",type:"text",dataType:{base:"text"},nullable:!0,align:"center",generated:!0,control:!0,detailExpander:!0,value:{pure:!0},cell:{render:"detailExpander",align:"center"},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:J,min:J,max:J,pin:I.config&&I.config.detailColumnPin||"start",hidden:!1,resizable:!1,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(H,L){return!!(L&&L.expanded)},formatValue(){return""}}}const U=V}),ze("packages/core/src/columns/treecolumn.js",function(e,B){"use strict";Object.defineProperty(e,"TREE_COLUMN_ID",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"createTreeColumn",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return J}});const A=B("packages/core/src/internal/predicates.js").isFunction,V="__lattice_tree",U=260;function I(H){const L=H.tree||{},Y=H.config&&H.config.treeColumnWidth||U,_=!!(H.config&&H.config.treeColumnFlex),O=()=>(H.columns&&A(H.columns.visible)?H.columns.visible():[]).find(g=>!g.generated)||null,v=(c,g)=>{if(g&&g.group)return g.groupValue;if(A(L.label))return L.label(c,g);if(typeof L.label=="string")return c==null?null:c[L.label];const o=O();return o&&A(o.getValue)?o.getValue(c,g):null},b=()=>{if(L.title)return L.title;const c=typeof L.label=="string"?H.columns&&A(H.columns.get)?H.columns.get(L.label):null:O();return c&&(c.title||c.id)||"Hierarchy"};return{id:V,get title(){return b()},field:null,type:"text",dataType:{base:"text"},nullable:!0,align:"start",generated:!0,value:{pure:!0},cell:{render:"group",props:{icon:L.icon,iconClass:L.iconClass,content:L.content,checkbox:L.checkbox,onCheck:L.onCheck}},edit:{enabled:!1},sort:{enabled:!0,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:_?{flex:1,min:0,pin:H.config&&H.config.treeColumnPin||null,hidden:!1,resizable:!1,movable:!1,lockPosition:!0}:{width:Y,min:140,pin:H.config&&H.config.treeColumnPin||null,hidden:!1,resizable:!0,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(c,g){return v(c,g)},formatValue(c,g){if(g&&g.grandTotal)return H.config&&H.config.grandTotalLabel||"Total";if(c==null)return"";if(!L.label){const o=O();if(o&&A(o.formatValue))return o.formatValue(c,g)}return String(c)}}}const J=I}),ze("packages/core/src/columns/pivotcolumns.js",function(e,B){"use strict";Object.defineProperty(e,"PIVOT_PREFIX",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"createPivotColumns",{enumerable:!0,get:function(){return I}});const A=B("packages/core/src/internal/warn.js").warnOnce,V="__lattice_pivot",U=500;function I(Y){const{pivot:_,valueColumns:O,config:v}=Y,b=_&&_.paths||[],c=Y.separator||v&&v.pivot&&v.pivot.separator||" | ",g=v&&v.pivot&&v.pivot.maxColumns||U;if(!b.length||!O.length)return{tree:[],leaves:[],error:null};const o=J(v),t=b.length*O.length+(o?O.length:0);if(t>g){const u=`pivot would generate ${t} columns, above the limit of ${g}. Pivot on a lower-cardinality column, or raise pivot.maxColumns.`;return A(`pivot.maxColumns:${t}`,u),{tree:[],leaves:[],error:u}}const s=[],l=[];for(const u of b){const n=[];for(const p of O){const r=L(u,p,c);n.push(r),l.push(r)}n.length===1?(n[0].title=String(u),s.push(n[0])):s.push({id:`${V}:group:${u}`,title:String(u),columns:n,collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!0,generated:!0})}if(o){const u=O.map(p=>H(p,v));l.push(...u);const n=v&&v.pivot&&v.pivot.totalsLabel||"Total";if(u.length===1)u[0].title=n,o==="before"?s.unshift(u[0]):s.push(u[0]);else{const p={id:`${V}:group:__totals`,title:n,columns:u,collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!0,generated:!0};o==="before"?s.unshift(p):s.push(p)}}return{tree:s,leaves:l,error:null}}function J(Y){const _=Y&&Y.pivot&&Y.pivot.groupTotals;return _==="before"||_==="after"?_:null}function H(Y,_){return{id:`${V}:__total${_&&_.pivot&&_.pivot.separator||" | "}${Y.id}`,field:null,title:Y.title||Y.id,type:Y.type,dataType:Y.dataType,nullable:!0,align:Y.align,generated:!0,pivot:{enabled:!1,index:0,sourceId:Y.id,total:!0},value:{pure:!0},cell:{align:Y.align},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},total:Y.total,lookup:null,layout:{width:Y.layout&&Y.layout.width||120,min:80,pin:null,hidden:!1,resizable:!0,movable:!1},header:{},export:{csv:!0,excel:!0},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(O,v){const b=v&&v.totals;return b&&Object.hasOwn(b,Y.id)?b[Y.id]:null},formatValue(O,v){return O==null?"":Y.formatValue?Y.formatValue(O,v):String(O)}}}function L(Y,_,O){return{id:`${V}:${Y}${O}${_.id}`,field:null,title:_.title||_.id,type:_.type,dataType:_.dataType,nullable:!0,align:_.align,generated:!0,pivot:{enabled:!1,index:0,path:Y,sourceId:_.id},value:{pure:!0},cell:{align:_.align},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},total:_.total,lookup:null,layout:{width:_.layout&&_.layout.width||120,min:80,pin:null,hidden:!1,resizable:!0,movable:!1},header:{},export:{csv:!0,excel:!0},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(){return null},formatValue(v,b){return v==null?"":_.formatValue?_.formatValue(v,b):String(v)}}}}),ze("packages/core/src/compute/group.js",function(e,B){"use strict";Object.defineProperty(e,"packKeys",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return v}});const ne=B("packages/core/src/compute/handle.js"),A=ne.dictSize,V=ne.identity,U=ne.presenceReader,I=ne.rowCount,J=ne.valueReader,H="",L="\0",Y=1<<20;function _(b,c,g,o){const t=b.length,s=b.map(i=>J(i)),l=Array.isArray(o)&&o.some(Boolean),u=l?s.map((i,d)=>o[d]?h=>o[d](i(h)):i):s;if(!l&&t>0&&b.every(i=>i&&i.kind==="dictionary"&&i.dict)){const i=b.map(h=>A(h.dict)+1);let d=1;for(let h=0;h<t;h++)d*=i[h];if(d<=Number.MAX_SAFE_INTEGER){const h=b.map(m=>m.values),a=b.map(m=>U(m)),y=m=>{let w=0;for(let S=0;S<t;S++){const M=a[S],X=M&&M(m)===0?i[S]-1:h[S][m];w=w*i[S]+X}return w},f=new Float64Array(g);for(let m=0;m<g;m++)f[m]=y(c[m]);return{packed:f,strings:null,product:d,readers:u,keyOf:y}}}const p=i=>{let d="";for(let h=0;h<t;h++){const a=u[h](i);d+=(h===0?"":H)+(a==null?L:String(a))}return d},r=new Array(g);for(let i=0;i<g;i++)r[i]=p(c[i]);return{packed:null,strings:r,product:1/0,readers:u,keyOf:p}}function O(b,c,g,o){const t=new Uint32Array(o+1);for(let n=0;n<g;n++)t[c[n]+1]++;for(let n=0;n<o;n++)t[n+1]+=t[n];const s=new Uint32Array(g),l=t.slice(0,o);for(let n=0;n<g;n++)s[l[c[n]]++]=b[n];const u=new Array(o);for(let n=0;n<o;n++)u[n]=s.subarray(t[n],t[n+1]);return u}function v(b,c,g={}){const o=b||[],t=c||V(I(o[0],g)),s=t.length;if(o.length===0||s===0)return{keys:[],buckets:[]};const{packed:l,strings:u,product:n,readers:p}=_(o,t,s,g.project),r=new Uint32Array(s);let i=0,d=null;if(l&&n<=Math.max(1024,Math.min(Y,s*4))){const f=n,m=new Int32Array(f).fill(-1);for(let w=0;w<s;w++)m[l[w]]=0;for(let w=0;w<f;w++)m[w]===0&&(m[w]=i++);for(let w=0;w<s;w++)r[w]=m[l[w]];d=new Float64Array(i);for(let w=0;w<f;w++)m[w]>=0&&(d[m[w]]=w)}else if(l){const f=new Map;for(let m=0;m<s;m++){const w=l[m];let S=f.get(w);S===void 0&&(S=i++,f.set(w,S)),r[m]=S}d=new Float64Array(i);for(const[m,w]of f)d[w]=m}else{const f=new Map;for(let m=0;m<s;m++){const w=u[m];let S=f.get(w);S===void 0&&(S=i++,f.set(w,S)),r[m]=S}}const h=O(t,r,s,i),a=new Array(i);for(let f=0;f<i;f++){const m=h[f][0],w=new Array(p.length);for(let S=0;S<p.length;S++)w[S]=p[S](m);a[f]=w}const y={keys:a,buckets:h};return d&&(y.packed=d),y}}),ze("packages/core/src/compute/pivot.js",function(e,B){"use strict";Object.defineProperty(e,"KEY_DELIMITER",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"pivotKey",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"joinPath",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"resolvePivotKeys",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return s}});const A=B("packages/core/src/internal/warn.js").warnOnce,U=B("packages/core/src/compute/handle.js").valueComparator,J=B("packages/core/src/compute/group.js").packKeys,L=B("packages/core/src/compute/total.js").total,Y="|",_="/",O=2e3;function v(n,p,r){return`${n}${Y}${p}${Y}${r}`}function b(n,p){let r="";for(let i=0;i<n.length;i++){const d=n[i];r+=(i===0?"":p)+(d==null?"":String(d))}return r}function c(n,p,r={}){const i=r.separator||_,d=p.length,{keyOf:h,readers:a}=J(n,p,0),y=new Map,f=[],m=[];for(let P=0;P<d;P++){const k=p[P],E=h(k);if(y.has(E))continue;y.set(E,f.length),m.push(E);const C=new Array(a.length);for(let x=0;x<a.length;x++)C[x]=a[x](k);f.push(C)}const w=U(r.locale),S=f.map((P,k)=>k);S.sort((P,k)=>{const E=f[P],C=f[k];for(let x=0;x<E.length;x++){const j=g(E[x],C[x],w);if(j!==0)return j}return P-k});const M=new Array(S.length),X=new Array(S.length),q=new Map;for(let P=0;P<S.length;P++){const k=S[P];M[P]=f[k],X[P]=b(f[k],i),q.set(m[k],P)}return{keys:M,paths:X,idOf:P=>{const k=q.get(h(P));return k===void 0?-1:k}}}function g(n,p,r){const i=n==null,d=p==null;return i||d?i&&d?0:i?1:-1:r(n,p)}function o(n){const p=n.values||n.totals||[];if(p.length&&typeof p[0]=="object"&&p[0]!==null)return p.filter(h=>h&&h.handle);const r=typeof n.handle=="function"?n.handle:null;if(!r)return p.length&&A("pivot:handles","pivot was given total column ids but no handle(colId) resolver, so no cell values were reduced. Pass values: [{ colId, handle, fn }] or opts.handle."),[];const i=typeof n.totalOf=="function"?n.totalOf:null,d=[];for(const h of p){const a=r(h);a&&d.push({colId:h,handle:a,fn:i?i(h):"sum"})}return d}function t(n,p,r){if(Array.isArray(n)){const i=r||{};return{...i,pivotHandles:n,order:p||null,groups:i.groups||null}}return n||{}}function s(n,p,r){const i=t(n,p,r),d=i.separator||_,h=o(i),a=i.maxColumns===void 0?O:i.maxColumns,y=i.groups&&i.groups.buckets?i.groups:null,f=y?y.buckets:[i.order||new Uint32Array(0)],m=i.groupPaths||(y?y.keys.map(E=>b(E,d)):[""]),w=u(f),{keys:S,paths:M,idOf:X}=c(i.pivotHandles||[],w,i),q=M.length*Math.max(1,h.length),K=l(M,h,d);if(a&&q>a){const E=new Map;return{keys:S,paths:M,fields:K,groupPaths:m,columns:q,values:E,cells:E,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${q} columns, above pivot.maxColumns of ${a}. Narrow the pivot columns or raise the limit.`,columns:q,maxColumns:a}}}const P=new Map,k=M.length;for(let E=0;E<f.length;E++){const C=f[E],x=m[E]===void 0?"":m[E],j=C.length;if(j===0)continue;const T=new Int32Array(j),F=new Uint32Array(k+1);for(let z=0;z<j;z++){const G=X(C[z]);T[z]=G,G>=0&&F[G+1]++}for(let z=0;z<k;z++)F[z+1]+=F[z];const $=new Uint32Array(j),D=F.slice(0,k);for(let z=0;z<j;z++){const G=T[z];G>=0&&($[D[G]++]=C[z])}for(let z=0;z<k;z++){const G=F[z],N=F[z+1];if(N===G)continue;const Z=$.subarray(G,N);for(let Q=0;Q<h.length;Q++){const ee=h[Q],re=L(ee.handle,Z,ee.fn,i.totalContext||{locale:i.locale});P.set(v(x,M[z],ee.colId),re)}}}return{keys:S,paths:M,fields:K,groupPaths:m,columns:q,values:P,cells:P,error:null}}function l(n,p,r){if(p.length===0)return n.slice();const i=[];for(const d of n)for(const h of p)i.push(`${d}${r}${h.colId}`);return i}function u(n){if(n.length===1)return n[0]||new Uint32Array(0);let p=0;for(const d of n)p+=d?d.length:0;const r=new Uint32Array(p);let i=0;for(const d of n)!d||d.length===0||(r.set(d,i),i+=d.length);return r}}),ze("packages/core/src/compute/explain.js",function(e,B){"use strict";Object.defineProperty(e,"explainContributors",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"explainChange",{enumerable:!0,get:function(){return v}});const A=B("packages/core/src/compute/total.js").total,U=B("packages/core/src/compute/group.js").groupByColumns,I=new Set(["sum","count","countValues"]),J=new Set(["min","max"]),H=new Set(["avg"]);function L(b){return typeof b=="string"?b:typeof b=="function"&&b.totalName?b.totalName:null}function Y(b,c,g,o){return A(b,c,g,o||{})}function _(b,c){if(c)try{return c(b)}catch{}return b==null?"":String(b)}function O(b){const{handle:c,fn:g,leaves:o,by:t,labelOf:s,rowLabel:l}=b,u={locale:b.locale},n=o&&o.length?o:[],p=L(g),r=Y(c,n,g,u),i=J.has(p);let d;if(i){let y=-1;for(let f=0;f<n.length;f++){const m=Y(c,[n[f]],g,u);if(Object.is(m,r)){y=n[f];break}}d=y<0?[]:[{key:y,indices:[y],label:l?l(y):String(y)}]}else if(t){const y=U([t],n);d=y.keys.map((f,m)=>({key:f[0],indices:y.buckets[m],label:_(f[0],s)}))}else d=Array.from({length:n.length},(y,f)=>{const m=n[f];return{key:m,indices:[m],label:l?l(m):String(m)}});const h=n.length,a=[];for(const y of d){const f=Y(c,y.indices,g,u),m=y.indices.length;let w,S;if(p==="avg")w=((typeof f=="number"?f:0)-(typeof r=="number"?r:0))*m,S=h?m/h:0;else if(i)w=typeof f=="number"?f:0,S=1;else{w=typeof f=="number"?f:0;const M=typeof r=="number"?r:0;S=M?w/M:0}a.push({key:y.key,label:y.label,count:m,value:f,contribution:w,share:S})}return a.sort((y,f)=>Math.abs(f.contribution)-Math.abs(y.contribution)||(y.label<f.label?-1:y.label>f.label?1:0)),{total:r,fn:p,weighted:H.has(p),single:i,contributors:a}}function v(b){const c=O({...b,leaves:b.after}),g=O({...b,leaves:b.before}),o=typeof c.total=="number"?c.total:0,t=typeof g.total=="number"?g.total:0,s=new Map;for(const n of c.contributors)s.set(n.key,n);const l=[],u=new Set;for(const n of g.contributors){u.add(n.key);const p=s.get(n.key);if(p===void 0)l.push({key:n.key,label:n.label,before:n.value,after:null,effect:-n.contribution,kind:"dropped",count:n.count});else{const r=p.contribution-n.contribution;r!==0&&l.push({key:n.key,label:n.label,before:n.value,after:p.value,effect:r,kind:"changed",count:p.count})}}for(const n of c.contributors)u.has(n.key)||l.push({key:n.key,label:n.label,before:null,after:n.value,effect:n.contribution,kind:"new",count:n.count});return l.sort((n,p)=>Math.abs(p.effect)-Math.abs(n.effect)||(n.label<p.label?-1:n.label>p.label?1:0)),{before:g.total,after:c.total,delta:o-t,weighted:c.weighted||g.weighted,single:c.single||g.single,drivers:l}}}),ze("packages/core/src/store/bitset.js",function(e,B){"use strict";Object.defineProperty(e,"Bitset",{enumerable:!0,get:function(){return A}});const ne=8;class A{static#e=new Uint8Array(256);static{for(let U=1;U<256;U++)A.#e[U]=A.#e[U>>1]+(U&1)}#t;#n;constructor(U=0){const I=Math.max(0,U|0);this.#n=I,this.#t=new Uint8Array(Math.ceil(I/ne))}get size(){return this.#n}get words(){return this.#t}get bytes(){return this.#t?this.#t.byteLength:0}get(U){return U<0||U>=this.#n?0:this.#t[U>>3]>>(U&7)&1}set(U){return U>=0&&U<this.#n&&(this.#t[U>>3]|=1<<(U&7)),this}clear(U){return U>=0&&U<this.#n&&(this.#t[U>>3]&=~(1<<(U&7))),this}assign(U,I){return I?this.set(U):this.clear(U)}fill(U=!1){return this.#t.fill(U?255:0),U&&this.#r(),this}grow(U){const I=Math.max(0,U|0);if(I<=this.#n)return this;const J=Math.ceil(I/ne);if(J>this.#t.length){const H=new Uint8Array(J);H.set(this.#t),this.#t=H}return this.#n=I,this}count(){const U=this.#t,I=A.#e;let J=0;for(let H=0;H<U.length;H++)J+=I[U[H]];return J}and(U){const I=U instanceof A?U.words:U,J=this.#t,H=Math.min(J.length,I.length);for(let L=0;L<H;L++)J[L]&=I[L];for(let L=H;L<J.length;L++)J[L]=0;return this}or(U){const I=U instanceof A?U.words:U,J=this.#t,H=Math.min(J.length,I.length);for(let L=0;L<H;L++)J[L]|=I[L];return this}not(){const U=this.#t;for(let I=0;I<U.length;I++)U[I]=~U[I]&255;return this.#r(),this}clone(){const U=new A(this.#n);return U.words.set(this.#t.subarray(0,U.words.length)),U}release(){this.#t=new Uint8Array(0),this.#n=0}#r(){const U=this.#n&7;if(U===0)return;const I=this.#n>>3;I<this.#t.length&&(this.#t[I]&=(1<<U)-1)}static from(U){const I=Array.isArray(U)?U:Array.from(U),J=new A(I.length);for(let H=0;H<I.length;H++)I[H]&&J.set(H);return J}}}),ze("packages/core/src/store/dictionary.js",function(e,B){"use strict";Object.defineProperty(e,"Dictionary",{enumerable:!0,get:function(){return U}});const ne=B("packages/core/src/internal/compare.js"),A=ne.collator,V=ne.defaultCompare;class U{#e;#t=new Map;#n=0;#r=null;#s=-1;#i="\0";constructor(J=[]){this.#e=[];for(let H=0;H<J.length;H++){const L=J[H];this.#t.has(L)||(this.#t.set(L,this.#e.length),this.#e.push(L))}}get size(){return this.#e.length}get version(){return this.#n}get bytes(){let J=this.#e.length*8;for(let H=0;H<this.#e.length;H++){const L=this.#e[H];typeof L=="string"&&(J+=L.length*2),J+=16}return J}codeOf(J){const H=this.#t.get(J);if(H!==void 0)return H;const L=this.#e.length;return this.#e.push(J),this.#t.set(J,L),this.#n++,L}lookup(J){const H=this.#t.get(J);return H===void 0?-1:H}has(J){return this.#t.has(J)}valueOf(J){return this.#e[J]}values(){return this.#e}ranks(J){const H=J||"";if(this.#r&&this.#s===this.#n&&this.#i===H)return this.#r;const L=this.#e.length,Y=new Array(L);for(let b=0;b<L;b++)Y[b]=b;const _=A(J).compare,O=this.#e;Y.sort((b,c)=>this.#a(O[b],O[c],_));const v=new Uint32Array(L);for(let b=0;b<L;b++)v[Y[b]]=b;return this.#r=v,this.#s=this.#n,this.#i=H,v}#a(J,H,L){return typeof J=="string"&&typeof H=="string"?L(J,H):V(J,H)}}}),ze("packages/core/src/store/multivalue.js",function(e,B){"use strict";Object.defineProperty(e,"MultiValue",{enumerable:!0,get:function(){return ne}});class ne{#e;#t;#n=0;#r=0;constructor(V={}){const U=Math.max(1,V.rows??16),I=Math.max(1,V.values??U);this.#e=new Int32Array(I),this.#t=new Uint32Array(U+1)}get values(){return this.#e}get offsets(){return this.#t}get rows(){return this.#n}get length(){return this.#r}get bytes(){return this.#e.byteLength+this.#t.byteLength}count(V){return V<0||V>=this.#n?0:this.#t[V+1]-this.#t[V]}at(V){return V<0||V>=this.#n?this.#e.subarray(0,0):this.#e.subarray(this.#t[V],this.#t[V+1])}has(V,U){if(V<0||V>=this.#n)return!1;const I=this.#e,J=this.#t[V+1];for(let H=this.#t[V];H<J;H++)if(I[H]===U)return!0;return!1}hasAny(V,U){for(let I=0;I<U.length;I++)if(this.has(V,U[I]))return!0;return!1}hasAll(V,U){for(let I=0;I<U.length;I++)if(!this.has(V,U[I]))return!1;return!0}hasNone(V,U){return!this.hasAny(V,U)}push(V){const U=this.#n,I=V.length;this.#s(U+1),this.#i(this.#r+I);const J=this.#r;for(let H=0;H<I;H++)this.#e[J+H]=V[H]|0;return this.#r+=I,this.#n=U+1,this.#t[U]=J,this.#t[U+1]=this.#r,U}write(V,U){if(V===this.#n){this.push(U);return}if(V<0||V>this.#n)return;const I=this.#t[V],J=this.#t[V+1],H=U.length;if(J-I===H){for(let L=0;L<H;L++)this.#e[I+L]=U[L]|0;return}this.#a(V,U)}compact(V,U,I){const J=this.#e,H=this.#t,L=this.#n,Y=new Int32Array(Math.max(1,this.#r)),_=new Uint32Array(U+1);let O=0;for(let v=0;v<L;v++){if(V[v]===I)continue;const b=H[v],c=H[v+1];_[V[v]]=O;for(let g=b;g<c;g++)Y[O++]=J[g];_[V[v]+1]=O}this.#e=Y,this.#t=_,this.#n=U,this.#r=O}release(){this.#e=new Int32Array(0),this.#t=new Uint32Array(1),this.#n=0,this.#r=0}#s(V){if(V+1<=this.#t.length)return;let U=this.#t.length-1;for(;U<V;)U=U*2||16;const I=new Uint32Array(U+1);I.set(this.#t),this.#t=I}#i(V){if(V<=this.#e.length)return;let U=this.#e.length;for(;U<V;)U=U*2||16;const I=new Int32Array(U);I.set(this.#e),this.#e=I}#a(V,U){const I=this.#e,J=this.#t,H=this.#n,L=U.length-(J[V+1]-J[V]),Y=new Int32Array(Math.max(1,this.#r+L)),_=new Uint32Array(J.length);let O=0;for(let v=0;v<H;v++){if(_[v]=O,v===V)for(let b=0;b<U.length;b++)Y[O++]=U[b]|0;else for(let b=J[v];b<J[v+1];b++)Y[O++]=I[b];_[v+1]=O}this.#e=Y,this.#t=_,this.#r=O}}}),ze("packages/core/src/compute/sort.js",function(e,B){"use strict";Object.defineProperty(e,"radixSortFloat64",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"radixSortInt32",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"rankSortDictionary",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"mergeSortComparator",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"rankSortStrings",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"collateStringRanks",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return k}});const ne=B("packages/core/src/compute/handle.js"),A=ne.bitReader,V=ne.dictRanks,U=ne.dictSize,I=ne.identity,J=ne.isMissing,H=ne.presenceReader,L=ne.rowCount,Y=ne.valueComparator,_=ne.valueReader,O=new Uint32Array(0),v=new ArrayBuffer(8),b=new Float64Array(v),c=new Uint32Array(v),g=(b[0]=-1,(c[1]&2147483648)!==0?1:0),o=g===1?0:1;function t(C,x){b[0]=C;let j=c[g],T=c[o];(j&2147483648)!==0?(j=~j>>>0,T=~T>>>0):j=(j^2147483648)>>>0,x[0]=T,x[1]=j}function s(C,x,j,T){if(T<2)return C;const F=new Uint32Array(256*8);for(let ee=0;ee<T;ee++){const re=x[ee],ie=j[ee];F[re&255]++,F[256+(re>>>8&255)]++,F[512+(re>>>16&255)]++,F[768+(re>>>24&255)]++,F[1024+(ie&255)]++,F[1280+(ie>>>8&255)]++,F[1536+(ie>>>16&255)]++,F[1792+(ie>>>24&255)]++}let $=C,D=x,z=j,G=new Uint32Array(T),N=new Uint32Array(T),Z=new Uint32Array(T);const Q=new Uint32Array(256);for(let ee=0;ee<8;ee++){const re=ee<<8,ie=(ee&3)<<3,ce=ee>=4;let ve=!1;for(let Oe=0;Oe<256;Oe++)if(F[re+Oe]===T){ve=!0;break}if(ve)continue;let he=0;for(let Oe=0;Oe<256;Oe++)Q[Oe]=he,he+=F[re+Oe];for(let Oe=0;Oe<T;Oe++){const Le=D[Oe],fe=z[Oe],ae=(ce?fe:Le)>>>ie&255,ke=Q[ae]++;G[ke]=$[Oe],N[ke]=Le,Z[ke]=fe}let ye=$;$=G,G=ye,ye=D,D=N,N=ye,ye=z,z=Z,Z=ye}return $}function l(C,x,j){if(j<2)return C;const T=new Uint32Array(256*4);for(let N=0;N<j;N++){const Z=x[N];T[Z&255]++,T[256+(Z>>>8&255)]++,T[512+(Z>>>16&255)]++,T[768+(Z>>>24&255)]++}let F=C,$=x,D=new Uint32Array(j),z=new Uint32Array(j);const G=new Uint32Array(256);for(let N=0;N<4;N++){const Z=N<<8,Q=N<<3;let ee=!1;for(let ce=0;ce<256;ce++)if(T[Z+ce]===j){ee=!0;break}if(ee)continue;let re=0;for(let ce=0;ce<256;ce++)G[ce]=re,re+=T[Z+ce];for(let ce=0;ce<j;ce++){const ve=$[ce],he=G[ve>>>Q&255]++;D[he]=F[ce],z[he]=ve}let ie=F;F=D,D=ie,ie=$,$=z,z=ie}return F}function u(C,x,j,T){const F=new Uint32Array(T+1);for(let z=0;z<j;z++)F[x[z]]++;let $=0;for(let z=0;z<=T;z++){const G=F[z];F[z]=$,$+=G}const D=new Uint32Array(j);for(let z=0;z<j;z++)D[F[x[z]]++]=C[z];return D}function n(C,x,j,T){return j<2?C:T<=65536||T<=j*2?u(C,x,j,T):l(C,x,j)}function p(C,x){return C.length===x&&C.byteOffset===0?C:Uint32Array.prototype.slice.call(C,0,x)}function r(C,x,j=!1){const T=x||I(C.length),F=T.length;if(F<2)return Uint32Array.from(T);const $=new Uint32Array(F),D=new Uint32Array(F),z=new Uint32Array(F),G=new Uint32Array(F),N=new Uint32Array(2);let Z=0,Q=0;for(let ie=0;ie<F;ie++){const ce=T[ie],ve=C[ce];if(Number.isNaN(ve)){G[Q++]=ce;continue}t(ve,N),j?(D[Z]=~N[0]>>>0,z[Z]=~N[1]>>>0):(D[Z]=N[0],z[Z]=N[1]),$[Z++]=ce}const ee=s($.subarray(0,Z),D.subarray(0,Z),z.subarray(0,Z),Z);if(Q===0)return p(ee,Z);const re=new Uint32Array(F);return re.set(ee.subarray(0,Z),0),re.set(G.subarray(0,Q),Z),re}function i(C,x,j=!1){const T=x||I(C.length),F=T.length;if(F<2)return Uint32Array.from(T);const $=Uint32Array.from(T),D=new Uint32Array(F);for(let z=0;z<F;z++){const G=(C[$[z]]^2147483648)>>>0;D[z]=j?~G>>>0:G}return p(l($,D,F),F)}function d(C,x,j={}){const T=x||I(L(C,j)),F=T.length;if(F<2)return Uint32Array.from(T);const $=V(C.dict,j.locale),D=C.values,z=H(C),G=Math.max(U(C.dict),$.length),N=G,Z=Uint32Array.from(T),Q=new Uint32Array(F),ee=!!j.descending;for(let re=0;re<F;re++){const ie=Z[re];let ce=z&&z(ie)===0?N:$[D[ie]];ce===void 0&&(ce=N),Q[re]=ee?N-ce:ce}return p(n(Z,Q,F,G+1),F)}function h(C,x,j){const T=x.length;let F=Uint32Array.from(x);if(T<2)return F;let $=new Uint32Array(T);for(let D=1;D<T;D<<=1){for(let G=0;G<T;G+=D<<1){const N=Math.min(G+D,T),Z=Math.min(G+(D<<1),T);let Q=G,ee=N,re=G;for(;Q<N&&ee<Z;)$[re++]=j(C[F[Q]],C[F[ee]])<=0?F[Q++]:F[ee++];for(;Q<N;)$[re++]=F[Q++];for(;ee<Z;)$[re++]=F[ee++]}const z=F;F=$,$=z}return F}function a(C,x,j){const T=A(C.values),F=x.length,$=new Uint32Array(F),D=j?1:0;let z=0;for(let G=0;G<F;G++)T(x[G])===D&&($[z++]=x[G]);for(let G=0;G<F;G++)T(x[G])!==D&&($[z++]=x[G]);return $}function y(C,x){const j=C.values,T=C.kind;if((T==="object"||T===void 0)&&(Array.isArray(j)||ArrayBuffer.isView(j))&&!C.presence)return j;const $=_(C),D=new Array(L(C)||0);for(let z=0;z<x.length;z++){const G=x[z];D[G]=$(G)}return D}function f(C,x){for(let j=0;j<x.length;j++)if(typeof C[x[j]]!="string")return!1;return!0}function m(C,x,j,T,F){const $=C.length,D=Uint32Array.from(C);if($<2||T<1)return D;const z=new Uint32Array($),G=T-1;for(let N=0;N<$;N++){const Z=j[x[N]];z[N]=F?G-Z:Z}return p(n(D,z,$,T),$)}function w(C,x,j){const T=Y(j),F=new Array(x);for(let D=0;D<x;D++)F[D]=D;F.sort((D,z)=>T(C[D],C[z])||D-z);const $=new Uint32Array(x);for(let D=0;D<x;D++)$[F[D]]=D;return $}function S(C,x,j){const T=x.length,F=new Map,$=[],D=new Uint32Array(T);for(let N=0;N<T;N++){const Z=C[x[N]];let Q=F.get(Z);Q===void 0&&(Q=$.length,F.set(Z,Q),$.push(Z)),D[N]=Q}const z=$.length,G=w($,z,j.locale);return m(x,D,G,z,!!j.descending)}function M(C,x,j){const T=y(C,x);if(x.length>=2&&f(T,x)){const D=C.stringRank;return D&&D.version===C.version&&D.usable(x,T,j.locale)?D.sort(x,j):S(T,x,j)}const F=Y(j.locale),$=j.descending?(D,z)=>F(z,D):F;return h(T,x,$)}function X(C,x,j){const T=y(C,x),F=j.compare,D=!!j.descending?(z,G)=>-F(z,G,void 0,void 0,!0):(z,G)=>F(z,G,void 0,void 0,!1);return h(T,x,D)}function q(C,x){const j=x.length,T=H(C),F=C.values,$=C.kind==="float64"&&!!F,D=C.kind==="object"||C.kind==="multi"||C.kind===void 0;if(!T&&!$&&!D)return{present:x,absent:O};const z=new Uint32Array(j),G=new Uint32Array(j);let N=0,Z=0;if(T&&$)for(let Q=0;Q<j;Q++){const ee=x[Q];T(ee)===1&&!Number.isNaN(F[ee])?z[N++]=ee:G[Z++]=ee}else if($&&!T)for(let Q=0;Q<j;Q++){const ee=x[Q];Number.isNaN(F[ee])?G[Z++]=ee:z[N++]=ee}else if(T&&!D)for(let Q=0;Q<j;Q++){const ee=x[Q];T(ee)===1?z[N++]=ee:G[Z++]=ee}else{const Q=_(C);for(let ee=0;ee<j;ee++){const re=x[ee];J(Q(re))?G[Z++]=re:z[N++]=re}}return Z===0?{present:x,absent:O}:{present:z.subarray(0,N),absent:G.subarray(0,Z)}}function K(C,x,j){if(x.length===0)return C;const T=new Uint32Array(C.length+x.length);return j?(T.set(x,0),T.set(C,x.length)):(T.set(C,0),T.set(x,C.length)),T}function P(C,x,j={}){const T=x||I(L(C,j));if(!C||T.length<2)return Uint32Array.from(T);const{present:F,absent:$}=q(C,T);if(F.length===0)return Uint32Array.from(T);const D=!!j.descending;let z;if(typeof j.compare=="function")z=X(C,F,j);else switch(C.kind){case"float64":z=r(C.values,F,D);break;case"int32":z=i(C.values,F,D);break;case"dictionary":z=d(C,F,j);break;case"bitset":z=a(C,F,D);break;default:z=M(C,F,j);break}return K(z,$,!!j.nullsFirst)}function k(C,x,j,T={}){const F=x||[],$=F.length&&(F[0].handle||E(C,F[0].col))||C&&C[0];let D=j||I(L($,T));for(let z=F.length-1;z>=0;z--){const G=F[z],N=G.handle||E(C,G.col)||C&&C[z];N&&(D=P(N,D,{descending:G.descending!==void 0?!!G.descending:G.dir==="desc",nullsFirst:!!G.nullsFirst,locale:G.locale!==void 0?G.locale:T.locale,compare:G.compare}))}return D instanceof Uint32Array?D:Uint32Array.from(D)}function E(C,x){if(!(!C||x===void 0)){for(let j=0;j<C.length;j++)if(C[j]&&C[j].id===x)return C[j]}}}),ze("packages/core/src/store/stringrank.js",function(e,B){"use strict";Object.defineProperty(e,"DEFAULT_MAX_DISTINCT",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"StringRankIndex",{enumerable:!0,get:function(){return I}});const ne=B("packages/core/src/compute/sort.js"),A=ne.collateStringRanks,V=ne.rankSortStrings,U=1e5;class I{#e=[];#t=new Map;#n;#r=0;#s=0;#i=-1;#a;#l=!1;#o=null;#c=-1;#u="\0";constructor(H=U){this.#a=H>0?H:U,this.#n=new Uint32Array(0)}get version(){return this.#i}set version(H){this.#i=H}get generation(){return this.#s}get size(){return this.#e.length}get capped(){return this.#l}get length(){return this.#r}get bytes(){let H=this.#n.byteLength;const L=this.#e;for(let Y=0;Y<L.length;Y++)H+=L[Y].length*2+24;return H}#f(H,L){const Y=this.#t.get(H);if(Y!==void 0)return Y;if(this.#l)return-1;if(L&&this.#e.length>=this.#a)return this.#l=!0,-1;const _=this.#e.length;return this.#e.push(H),this.#t.set(H,_),this.#s++,_}build(H,L){const Y=L|0;this.#e=[],this.#t=new Map,this.#s=0,this.#l=!1,this.#o=null,this.#c=-1,this.#n=new Uint32Array(Y);for(let _=0;_<Y;_++){const O=H[_],v=typeof O=="string"?this.#f(O,!1):-1;this.#n[_]=v<0?0:v}this.#r=Y}append(H,L,Y){const _=(L|0)+(Y|0);if(_>this.#n.length){const O=new Uint32Array(_);O.set(this.#n.subarray(0,this.#r)),this.#n=O}for(let O=L|0;O<_;O++){const v=H[O],b=typeof v=="string"?this.#f(v,!0):-1;this.#n[O]=b<0?0:b}this.#r=Math.max(this.#r,_)}ranks(H){const L=H||"";if(this.#o&&this.#c===this.#s&&this.#u===L)return this.#o;const Y=A(this.#e,this.#e.length,H);return this.#o=Y,this.#c=this.#s,this.#u=L,Y}usable(H,L,Y){if(this.#l||this.#e.length===0)return!1;const _=this.#n,O=this.#e,v=this.#r;for(let b=0;b<H.length;b++){const c=H[b];if(c>=v||O[_[c]]!==L[c])return!1}return!0}sort(H,L){const Y=this.ranks(L.locale),_=this.#e.length,O=H.length,v=new Uint32Array(O),b=this.#n;for(let c=0;c<O;c++)v[c]=b[H[c]];return V(H,v,Y,_,!!L.descending)}}}),ze("packages/core/src/store/columnstore.js",function(e,B){"use strict";Object.defineProperty(e,"REMOVED",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"toFloat",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ColumnHandle",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"ColumnStore",{enumerable:!0,get:function(){return a}});const A=B("packages/core/src/internal/warn.js").warnOnce,U=B("packages/core/src/internal/predicates.js").isFunction,J=B("packages/core/src/internal/paths.js").pathGetter,L=B("packages/core/src/store/bitset.js").Bitset,_=B("packages/core/src/store/dictionary.js").Dictionary,v=B("packages/core/src/store/multivalue.js").MultiValue,c=B("packages/core/src/store/stringrank.js").StringRankIndex,g=4294967295,o=1024,t=5e3,s=.2,l=new Set(["float64","int32","bitset","dictionary","object","multi"]);function u(y){return y==null}function n(y){return typeof y=="number"?y:y instanceof Date?y.getTime():typeof y=="boolean"?y?1:0:Number(y)}function p(y){const f=n(y);return Number.isFinite(f)?f|0:0}function r(y){return u(y)?[]:Array.isArray(y)?y:[y]}function i(y,f){switch(y.kind){case"float64":case"int32":return y.buf[f];case"bitset":return y.bits.get(f)===1;case"dictionary":return y.dict.valueOf(y.buf[f]);case"multi":{const m=y.mv.at(f),w=new Array(m.length);for(let S=0;S<m.length;S++)w[S]=y.dict.valueOf(m[S]);return w}default:return y.buf[f]}}function d(y,f){switch(y.kind){case"float64":case"int32":return y.values[f];case"bitset":return(y.values[f>>3]&1<<(f&7))!==0;case"dictionary":return(y.table||[])[y.values[f]];case"multi":{const m=y.offsets[f],w=y.offsets[f+1],S=y.table||[],M=new Array(w-m);for(let X=m;X<w;X++)M[X-m]=S[y.values[X]];return M}default:return y.values[f]}}class h{#e;#t;#n;#r;#s;#i;#a;#l=!1;#o=null;#c=null;#u=null;#f=null;#d=null;#h;#p;#m=-1;#g=null;#b=0;#y=0;#S=null;#w=null;#A=!1;constructor(f,m){this.#e=f.id;const w=l.has(f.kind)?f.kind:"object";f.kind&&!l.has(f.kind)&&A(`store.kind.${f.id}`,`column "${f.id}" declares unknown storage kind "${f.kind}"; falling back to object`),this.#n=w,this.#t=w,this.#r=f.nullable!==!1,this.#a=f.dictionary??null,this.#i=m,this.#s=U(f.read)?f.read:J(f.field||f.id),this.#h=f.stringRankIndex!=="off",this.#p=typeof f.stringRankMaxDistinct=="number"?f.stringRankMaxDistinct:0,this.#S=new Map}get id(){return this.#e}get kind(){return this.#l?this.#t:"object"}get target(){return this.#n}get nullable(){return this.#r}get values(){return this.#A?null:this.#l?this.#t==="bitset"?this.#c.words:this.#t==="multi"?this.#u.values:this.#o:this.#T().values}get presence(){return this.#A||!this.#r?null:this.#l?this.#g:this.#T().presence}get dict(){return this.#A||!this.#l?null:this.#t==="dictionary"||this.#t==="multi"?this.#f:null}get stringRank(){if(this.#A||!this.#h||this.kind!=="object")return null;const f=this.values,m=this.#i.physical();if(!f||m===0)return null;if(this.#d===null){if(typeof f[0]!="string")return null;const w=new c(this.#v());return w.build(f,m),w.version=this.#y,this.#d=w,this.#m=this.#y,w.capped?null:w}return this.#d.length<m&&this.#d.append(f,this.#d.length,m-this.#d.length),this.#d.version=this.#y,this.#m=this.#y,this.#d.capped?null:this.#d}#v(){return this.#p}#C(){this.#d=null,this.#m=-1}get offsets(){return this.#A||!this.#l||this.#t!=="multi"?null:this.#u.offsets}get version(){return this.#y}get bytes(){let f=0;return this.#o&&(f+=this.#o.byteLength??this.#o.length*8),this.#c&&(f+=this.#c.bytes),this.#u&&(f+=this.#u.bytes),this.#g&&(f+=this.#g.bytes),this.#f&&(f+=this.#f.bytes),this.#S&&(f+=this.#S.size*24),f}get(f){if(!this.#A&&!(f<0||f>=this.#i.physical())){if(!this.#l)return this.#E(f);if(this.#r&&this.#g.get(f)===0)return null;switch(this.#t){case"float64":case"int32":return this.#o[f];case"bitset":return this.#c.get(f)===1;case"dictionary":return this.#f.valueOf(this.#o[f]);case"multi":{const m=this.#u.at(f),w=new Array(m.length);for(let S=0;S<m.length;S++)w[S]=this.#f.valueOf(m[S]);return w}default:return this.#o[f]}}}set(f,m){this.#A||(this.#l?this.#P(f,m):this.#S.set(f,m===void 0?null:m),this.#d&&this.#C(),this.#y++)}read(f){return this.#s(f)}appendColumn(f,m,w){if(this.#A||w<=0)return;if(!this.#l){this.#y++;return}const S=this.#s,M=this.#r,X=this.#g;let q=!1;switch(this.#t){case"float64":{const K=this.#o;for(let P=0;P<w;P++){const k=S(f[P]);if(typeof k=="number"){M&&X.set(m+P),K[m+P]=k;continue}const E=k==null;M?X.assign(m+P,!E):E&&(q=!0),K[m+P]=E?NaN:n(k)}break}case"int32":{const K=this.#o;for(let P=0;P<w;P++){const k=S(f[P]),E=k==null;M?X.assign(m+P,!E):E&&(q=!0),K[m+P]=E?0:p(k)}break}case"bitset":{const K=this.#c;for(let P=0;P<w;P++){const k=S(f[P]),E=k==null;M?X.assign(m+P,!E):E&&(q=!0),K.assign(m+P,!E&&!!k)}break}case"dictionary":{const K=this.#o,P=this.#f;for(let k=0;k<w;k++){const E=S(f[k]),C=E==null;M?X.assign(m+k,!C):C&&(q=!0),K[m+k]=C?0:P.codeOf(E)}break}case"multi":{const K=this.#u,P=this.#f;for(let k=0;k<w;k++){const E=S(f[k]),C=E==null;M?X.assign(m+k,!C):C&&(q=!0);const x=r(E),j=new Array(x.length);for(let T=0;T<x.length;T++)j[T]=P.codeOf(x[T]);K.write(m+k,j)}break}default:{const K=this.#o;for(let P=0;P<w;P++){const k=S(f[P]),E=k==null;M?X.assign(m+P,!E):E&&(q=!0),K[m+P]=E?null:k}break}}q&&A(`store.null.${this.#e}`,`column "${this.#e}" is declared non-nullable but received null; storing a filler value`),this.#d&&this.#t==="object"&&(this.#d.append(this.#o,m,w),this.#d.version=this.#y+1,this.#m=this.#y+1),this.#y++}appendPacked(f,m,w){if(this.#A||w<=0||!f)return;if(!this.#l){this.#y++;return}const S=this.#g,M=f.presence;if(S)if(M)for(let q=0;q<w;q++)S.assign(m+q,(M[q>>3]&1<<(q&7))!==0);else for(let q=0;q<w;q++)S.set(m+q);const X=f.kind===this.#t;if(X&&(this.#t==="float64"||this.#t==="int32")){this.#o.set(f.values,m),this.#y++;return}if(X&&this.#t==="bitset"){const q=f.values;for(let K=0;K<w;K++)this.#c.assign(m+K,(q[K>>3]&1<<(K&7))!==0);this.#y++;return}if(X&&this.#t==="dictionary"){const q=f.table||[],K=new Uint32Array(q.length);for(let C=0;C<q.length;C++)K[C]=this.#f.codeOf(q[C]);const P=f.values,k=this.#o,E=S;for(let C=0;C<w;C++){if(E&&(M&&(M[C>>3]&1<<(C&7))===0)){k[m+C]=0;continue}k[m+C]=K[P[C]]??0}this.#y++;return}if(X&&this.#t==="multi"){const q=f.table||[],K=new Uint32Array(q.length);for(let E=0;E<q.length;E++)K[E]=this.#f.codeOf(q[E]);const P=f.values,k=f.offsets;for(let E=0;E<w;E++){const C=k[E],x=k[E+1],j=new Array(x-C);for(let T=C;T<x;T++)j[T-C]=K[P[T]]??0;this.#u.write(m+E,j)}this.#y++;return}for(let q=0;q<w;q++){const K=M?(M[q>>3]&1<<(q&7))===0:f.kind==="object"?f.values[q]===null:!1;this.#P(m+q,K?null:d(f,q))}this.#y++}touch(){this.#y++}columnarise(f,m){if(this.#l||this.#A)return;const w=new Array(m);for(let S=0;S<m;S++)w[S]=this.#E(S);this.#t=this.#n,this.#l=!0,this.#O(f);for(let S=0;S<m;S++)this.#P(S,w[S]);this.#S.clear(),this.#w=null,this.#C(),this.#y++}grow(f){if(!(!this.#l||this.#A||f<=this.#b)){switch(this.#t){case"float64":case"int32":case"dictionary":{const m=new this.#o.constructor(f);m.set(this.#o),this.#o=m;break}case"bitset":this.#c.grow(f);break;case"multi":break;default:this.#o.length=f;break}this.#g&&this.#g.grow(f),this.#b=f,this.#y++}}convert(f){if(this.#A||!l.has(f)||(this.#n=f,!this.#l||f===this.#t))return!1;const m={kind:this.#t,buf:this.#o,bits:this.#c,mv:this.#u,dict:this.#f},w=this.#i.physical(),S=this.#g;this.#t=f,this.#O(this.#b);for(let M=0;M<w;M++){const X=S!==null&&S.get(M)===0;X&&f!=="multi"||this.#P(M,X?null:i(m,M))}return this.#C(),this.#y++,!0}compact(f,m,w){if(!this.#A){if(this.#C(),!this.#l){const S=this.#S;if(S.size){const M=new Map;for(const[X,q]of S)f[X]!==g&&M.set(f[X],q);this.#S=M}this.#w=null,this.#y++;return}switch(this.#t){case"float64":case"int32":case"dictionary":case"object":{const S=this.#o;for(let M=0;M<m;M++)f[M]!==g&&(S[f[M]]=S[M]);if(this.#t==="object")for(let M=w;M<m;M++)S[M]=void 0;break}case"bitset":{const S=this.#c;for(let M=0;M<m;M++)f[M]!==g&&S.assign(f[M],S.get(M)===1);for(let M=w;M<m;M++)S.clear(M);break}case"multi":this.#u.compact(f,w,g);break;default:break}if(this.#g){const S=this.#g;for(let M=0;M<m;M++)f[M]!==g&&S.assign(f[M],S.get(M)===1);for(let M=w;M<m;M++)S.clear(M)}this.#y++}}release(){this.#A||(this.#A=!0,this.#o=null,this.#c&&this.#c.release(),this.#c=null,this.#u&&this.#u.release(),this.#u=null,this.#g&&this.#g.release(),this.#g=null,this.#f=null,this.#d=null,this.#S=new Map,this.#w=null,this.#b=0,this.#y++)}#O(f){const m=Math.max(1,f);switch(this.#o=null,this.#c=null,this.#u=null,this.#t){case"float64":this.#o=new Float64Array(m);break;case"int32":this.#o=new Int32Array(m);break;case"bitset":this.#c=new L(m);break;case"dictionary":this.#o=new Uint32Array(m),this.#f=this.#f??new _(this.#a??[]);break;case"multi":this.#u=new v({rows:m,values:m}),this.#f=this.#f??new _(this.#a??[]);break;default:this.#o=new Array(m);break}this.#t!=="dictionary"&&this.#t!=="multi"&&(this.#f=null),this.#r&&(this.#g?this.#g.grow(m):this.#g=new L(m)),this.#b=m}#P(f,m){const w=u(m);switch(this.#r?this.#g.assign(f,!w):w&&A(`store.null.${this.#e}`,`column "${this.#e}" is declared non-nullable but received null; storing a filler value`),this.#t){case"float64":this.#o[f]=w?NaN:n(m);break;case"int32":this.#o[f]=w?0:p(m);break;case"bitset":this.#c.assign(f,!w&&!!m);break;case"dictionary":this.#o[f]=w?0:this.#f.codeOf(m);break;case"multi":{const S=r(m),M=new Array(S.length);for(let X=0;X<S.length;X++)M[X]=this.#f.codeOf(S[X]);this.#u.write(f,M);break}default:this.#o[f]=w?null:m;break}}#E(f){if(this.#S.has(f))return this.#S.get(f);const m=this.#s(this.#i.rowAt(f));return m===void 0?null:m}#T(){if(this.#w&&this.#w.version===this.#y)return this.#w;const f=this.#i.physical(),m=new Array(f),w=this.#r?new L(f):null;for(let S=0;S<f;S++){const M=this.#E(S);m[S]=M,w&&!u(M)&&w.set(S)}return this.#w={version:this.#y,values:m,presence:w},this.#w}}class a{#e;#t=new Map;#n=[];#r=[];#s=0;#i=0;#a=0;#l=0;#o=new L(0);#c=!1;#u=!0;#f;#d;#h;#p=!1;constructor(f,m={}){this.#e=Array.isArray(f)?f:[],this.#d=Math.max(1,m.initialCapacity??o),this.#u=m.retainSource!==!1,this.#f=this.#u?m.columnarBelow??t:0,this.#h=m.compactRatio??s;const w={rowAt:S=>this.#r[S],physical:()=>this.#s};for(const S of this.#e){if(!S||!S.id)continue;if(this.#t.has(S.id)){A(`store.dup.${S.id}`,`duplicate column id "${S.id}" in the store schema; ignoring the second`);continue}const M=new h(S,w);this.#t.set(S.id,M),this.#n.push(M)}this.#f<=0&&this.#b()}get count(){return this.#a}get physical(){return this.#s}get capacity(){return this.#c?this.#i:this.#r.length}get tombstones(){return this.#l}get columnar(){return this.#c}get destroyed(){return this.#p}get bytes(){let f=this.#o.bytes+this.#r.length*8;for(const m of this.#n)f+=m.bytes;return f}append(f){const m=this.#s;if(this.#p||!f)return{from:m,to:m};const w=f.length|0;if(w===0)return{from:m,to:m};if(this.#u)for(let M=0;M<w;M++)this.#r[m+M]=f[M];if(this.#s=m+w,this.#a+=w,this.#o.grow(this.#s),!this.#c){if(this.#s>=this.#f)this.#b();else for(const M of this.#n)M.touch();return{from:m,to:this.#s}}this.#m(this.#s);const S=this.#n;for(let M=0;M<S.length;M++)S[M].appendColumn(f,m,w);return{from:m,to:this.#s}}appendPacked(f,m){const w=this.#s;if(this.#p||!f)return{from:w,to:w};const S=f.count|0;if(S===0)return{from:w,to:w};if(this.#u&&m)for(let X=0;X<S;X++)this.#r[w+X]=m[X];this.#s=w+S,this.#a+=S,this.#o.grow(this.#s),this.#c||this.#b(),this.#m(this.#s);const M=new Map;for(const X of f.columns)M.set(X.id,X);for(const X of this.#n){const q=M.get(X.id);q?X.appendPacked(q,w,S):X.grow(this.#i)}return{from:w,to:this.#s}}source(f){if(this.#u)return this.#r[f];if(!(f<0||f>=this.#s))return this.#g(f)}setSource(f,m){this.#p||f<0||f>=this.#s||this.#u&&(this.#r[f]=m)}get(f,m){const w=this.#t.get(f);return w?w.get(m):void 0}set(f,m,w){if(this.#p||m<0||m>=this.#s)return;const S=this.#t.get(f);if(!S){A(`store.set.${f}`,`set() on unknown column "${f}"`);return}S.set(m,w)}remove(f){return this.#p||f<0||f>=this.#s||this.#o.get(f)===1?!1:(this.#o.set(f),this.#l++,this.#a--,!0)}live(f){return f<0||f>=this.#s?!1:this.#o.get(f)===0}compact(f={}){if(this.#p||this.#l===0||!f.force&&this.#l/this.#s<this.#h)return null;const m=this.#s,w=new Uint32Array(m);let S=0;for(let M=0;M<m;M++)w[M]=this.#o.get(M)===1?g:S++;for(const M of this.#n)M.compact(w,m,S);if(this.#u){const M=this.#r;for(let X=0;X<m;X++)w[X]!==g&&(M[w[X]]=M[X]);M.length=S}return this.#s=S,this.#a=S,this.#l=0,this.#o=new L(Math.max(this.#i,S)),w}column(f){return this.#t.get(f)}columns(){return this.#n.slice()}liveIndices(){const f=new Uint32Array(this.#a);if(this.#l===0){for(let w=0;w<this.#s;w++)f[w]=w;return f}let m=0;for(let w=0;w<this.#s;w++)this.#o.get(w)===0&&(f[m++]=w);return f}convert(f,m){const w=this.#t.get(f);return w?w.convert(m):!1}destroy(){if(!this.#p){this.#p=!0;for(const f of this.#n)f.release();this.#t.clear(),this.#n.length=0,this.#r.length=0,this.#o.release(),this.#s=0,this.#a=0,this.#l=0,this.#i=0}}#m(f){if(f<=this.#i)return;let m=this.#i||this.#d;for(;m<f;)m*=2;for(const w of this.#n)w.grow(m);this.#o.grow(m),this.#i=m}#g(f){const m={};for(const w of this.#n)m[w.id]=w.get(f);return m}#b(){if(this.#c)return;let f=this.#d;for(;f<this.#s;)f*=2;this.#c=!0,this.#i=f,this.#o.grow(f);for(const m of this.#n)m.columnarise(f,this.#s)}}}),ze("packages/core/src/store/pool.js",function(e,B){"use strict";Object.defineProperty(e,"MaskPool",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"sharedPool",{enumerable:!0,get:function(){return I}});const ne=64,A=8;function V(H){let L=ne;for(;L<H;)L*=2;return L}class U{#e=new Map;#t=new WeakSet;#n;#r=0;#s={acquired:0,reused:0,released:0};constructor(L={}){this.#n=L.limit??A}get bytes(){return this.#r}mask(L){const Y=new Uint8Array(this.#i(L),0,L);return Y.fill(0),Y}indices(L){return new Uint32Array(this.#i(L*4),0,L)}release(L){if(!L||!L.buffer)return!1;const Y=L.buffer;if(!this.#t.has(Y))return!1;this.#t.delete(Y),this.#s.released++;const _=Y.byteLength;let O=this.#e.get(_);return O||this.#e.set(_,O=[]),O.length>=this.#n||(O.push(Y),this.#r+=_),!0}releaseAll(L){for(const Y of L)this.release(Y)}clear(){this.#e.clear(),this.#r=0}stats(){return{...this.#s,retained:this.#r}}#i(L){const Y=V(L),_=this.#e.get(Y);this.#s.acquired++;let O;return _&&_.length?(O=_.pop(),this.#r-=Y,this.#s.reused++):O=new ArrayBuffer(Y),this.#t.add(O),O}}function I(){return J??=new U,J}let J=null}),ze("packages/core/src/compute/sortspec.js",function(e,B){"use strict";Object.defineProperty(e,"collationDescriptor",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"isPortableSort",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"isPortableSortSet",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"describeSortEntry",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"describeSort",{enumerable:!0,get:function(){return I}});function ne(J){return{locale:J===void 0?void 0:String(J),numeric:!0,sensitivity:"variant"}}function A(J){return!!J&&typeof J.compare!="function"}function V(J){if(!J)return!0;for(let H=0;H<J.length;H++)if(!A(J[H]))return!1;return!0}function U(J,H){const L=J.col!==void 0?J.col:J.handle&&J.handle.id,Y=J.locale!==void 0?J.locale:H;return{col:L,descending:J.descending!==void 0?!!J.descending:J.dir==="desc",nullsFirst:!!J.nullsFirst,collation:ne(Y)}}function I(J,H){const L=J||[],Y=new Array(L.length);for(let _=0;_<L.length;_++)Y[_]=U(L[_],H);return Y}}),ze("packages/core/src/compute/facet.js",function(e,B){"use strict";Object.defineProperty(e,"STRATEGIES",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"GRANULARITIES",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"facetKind",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"orderedReader",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"toNumeric",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"cardinalityOf",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"pickGranularity",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"floorTo",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"advance",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"computeBounds",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"countInto",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"bucketOf",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"facet",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return w}});const ne=B("packages/core/src/compute/handle.js"),A=ne.presenceReader,V=ne.valueReader,U=ne.dictSize,I=ne.dictValue,J=Object.freeze(["equal","quantile","log"]),H=Object.freeze(["hour","day","week","month","quarter","year"]),L=20,Y=50,_=1e4;function O(S,M){if(!S)return"none";const X=M;if(X&&(X.multi===!0||typeof X.items=="function"))return"category";const q=M&&M.base;if(q==="date"||q==="datetime"||q==="time"||q==="dateString")return"date";switch(S.kind){case"bitset":return"boolean";case"float64":case"int32":return"numeric";case"dictionary":return"category";case"multi":return"category";default:return q==="number"?"numeric":q==="boolean"?"boolean":q==="text"?"category":"none"}}function v(S){const M=S.values,X=S.kind;if((X==="float64"||X==="int32")&&M)return K=>M[K];const q=V(S);return K=>b(q(K))}function b(S){if(typeof S=="number")return S;if(S instanceof Date)return S.getTime();if(S==null||S==="")return NaN;if(typeof S=="boolean")return S?1:0;if(typeof S=="string"){const M=Number(S);if(Number.isFinite(M))return M;const X=Date.parse(S);return Number.isFinite(X)?X:NaN}return NaN}function c(S,M,X,q=Y){if(!S)return{cardinality:0,exact:!0};if(S.dict)return{cardinality:U(S.dict),exact:!0};if(S.kind==="bitset")return{cardinality:2,exact:!0};const K=V(S),P=M?M.length:X,k=new Set;for(let E=0;E<P;E++){const C=K(M?M[E]:E);if(C!=null&&(k.add(C),k.size>q))return{cardinality:k.size,exact:!1}}return{cardinality:k.size,exact:!0}}const g=36e5,o=864e5;function t(S,M=L){const X=Number.isFinite(S)&&S>0?S:0,q=Math.max(1,M)*2;return X/g<=q?"hour":X/o<=q?"day":X/(7*o)<=q?"week":X/(30*o)<=q?"month":X/(91*o)<=q?"quarter":"year"}function s(S,M){if(!Number.isFinite(S))return NaN;const X=new Date(S);switch(M){case"hour":return X.setMinutes(0,0,0),X.getTime();case"day":return X.setHours(0,0,0,0),X.getTime();case"week":{X.setHours(0,0,0,0);const q=(X.getDay()+6)%7;return X.setDate(X.getDate()-q),X.getTime()}case"month":return X.setDate(1),X.setHours(0,0,0,0),X.getTime();case"quarter":return X.setMonth(Math.floor(X.getMonth()/3)*3,1),X.setHours(0,0,0,0),X.getTime();default:return X.setMonth(0,1),X.setHours(0,0,0,0),X.getTime()}}function l(S,M){const X=new Date(S);switch(M){case"hour":X.setHours(X.getHours()+1);break;case"day":X.setDate(X.getDate()+1);break;case"week":X.setDate(X.getDate()+7);break;case"month":X.setMonth(X.getMonth()+1);break;case"quarter":X.setMonth(X.getMonth()+3);break;default:X.setFullYear(X.getFullYear()+1);break}return X.getTime()}function u(S,M,X){const q=v(S),K=A(S),P=M?M.length:X;let k=1/0,E=-1/0,C=0,x=0;for(let j=0;j<P;j++){const T=M?M[j]:j;if(K&&!K(T)){C++;continue}const F=q(T);if(!Number.isFinite(F)){C++;continue}F<k&&(k=F),F>E&&(E=F),x++}return{min:k,max:E,nulls:C,finite:x}}function n(S,M,X,q){const K=v(S),P=A(S),k=M?M.length:X,E=k>q?k/q:1,C=[];for(let j=0;j<k;j+=E){const T=M?M[Math.floor(j)]:Math.floor(j);if(P&&!P(T))continue;const F=K(T);Number.isFinite(F)&&C.push(F)}const x=Float64Array.from(C);return x.sort(),x}function p(S,M,X,q={}){const K=q.kind||O(S,q.type);return K==="none"||!S?{kind:"none",buckets:[],suppressed:"type"}:K==="boolean"?r(S,M,X,q):K==="category"?i(S,M,X,q):h(S,M,X,K,q)}function r(S,M,X,q={}){const K=A(S);let P=0;if(K){const E=M?M.length:X;for(let C=0;C<E;C++)K(M?M[C]:C)||P++}const k=[{value:!1,label:"false"},{value:!0,label:"true"}];return P>0&&q.blanks!==!1&&k.push({null:!0,label:"Empty"}),{kind:"boolean",buckets:k}}function i(S,M,X,q){const K=q.cardinalityLimit??Y,{cardinality:P}=c(S,M,X,K);if(P>K&&(q.aboveLimit||"suppress")==="suppress")return{kind:"category",buckets:[],suppressed:"cardinality",cardinality:P};const k=V(S),E=M?M.length:X,C=new Map;let x=0;for(let D=0;D<E;D++){const z=k(M?M[D]:D);if(z==null||z===""){x++;continue}if(Array.isArray(z)){if(!z.length){x++;continue}for(const G of z)C.set(G,(C.get(G)||0)+1);continue}C.set(z,(C.get(z)||0)+1)}let j=[...C.entries()];q.order==="alpha"?j.sort((D,z)=>String(D[0]).localeCompare(String(z[0]))):j.sort((D,z)=>z[1]-D[1]);let T=0,F=0;if(j.length>K){F=j.length-K;for(let D=K;D<j.length;D++)T+=j[D][1];j=j.slice(0,K)}const $=j.map(([D])=>({value:D,label:String(D)}));return T>0&&$.push({remainder:!0,label:`Other (${F} values)`}),x>0&&q.blanks!==!1&&$.push({null:!0,label:"Empty"}),{kind:"category",buckets:$,cardinality:P}}function d(S,M,X,q,K){const P=n(S,M,X,_),k=P.length;if(k<100)return null;const E=P[Math.floor(.01*k)],C=P[Math.ceil(.99*k)-1];return!(C>E)||K-q<=2*(C-E)?null:{lo:E,hi:C}}function h(S,M,X,q,K){const{min:P,max:k,nulls:E,finite:C}=u(S,M,X);if(!C)return{kind:q,buckets:E&&K.blanks!==!1?[{null:!0,label:"Empty"}]:[],empty:!0};const x=Math.max(1,Math.floor(K.buckets||L));let j=[];if(q==="date"){const F=H.includes(K.granularity)?K.granularity:t(k-P,x);let $=s(P,F);for(;$<=k&&j.length<4096;){const D=l($,F);if(!(D>$))break;j.push({from:$,to:D}),$=D}return{kind:q,buckets:a(j,K.blanks===!1?0:E),granularity:F}}const T=J.includes(K.strategy)?K.strategy:"equal";if(T==="quantile"){const F=n(S,M,X,_);if(F.length){const $=[F[0]];for(let D=1;D<x;D++){const z=F[Math.min(F.length-1,Math.floor(D/x*F.length))];z>$[$.length-1]&&$.push(z)}$.push(k);for(let D=0;D<$.length-1;D++)j.push({from:$[D],to:$[D+1]})}}else if(T==="log"&&P>0){const F=Math.log10(P),D=(Math.log10(k)-F)/x||1;for(let z=0;z<x;z++)j.push({from:10**(F+z*D),to:10**(F+(z+1)*D)})}if(!j.length&&T==="equal"){const F=d(S,M,X,P,k);if(F){const $=(F.hi-F.lo)/x;F.lo>P&&j.push({from:P,to:F.lo,overflow:"low"});for(let D=0;D<x;D++)j.push({from:F.lo+D*$,to:F.lo+(D+1)*$});j[j.length-1].to=F.hi,F.hi<k&&j.push({from:F.hi,to:k,overflow:"high"})}}if(!j.length){const F=(k-P)/x||1;for(let $=0;$<x;$++)j.push({from:P+$*F,to:P+($+1)*F})}return j[j.length-1].to=k,{kind:q,buckets:a(j,K.blanks===!1?0:E),strategy:T,min:P,max:k}}function a(S,M){return M>0?[...S,{null:!0,label:"Empty"}]:S}function y(S,M,X,q,K){const P=q&&q.buckets||[],k=K&&K.length>=P.length?K.subarray(0,P.length):new Uint32Array(P.length);if(k.fill(0),!S||!P.length)return k;const E=P.length-1,C=!!P[E]&&P[E].null===!0,x=M?M.length:X;if(q.kind==="boolean"){const D=V(S);for(let z=0;z<x;z++){const G=D(M?M[z]:z);if(G==null){C&&k[E]++;continue}k[G?1:0]++}return k}if(q.kind==="category"){const D=new Map;for(let N=0;N<P.length;N++)!P[N].null&&!P[N].remainder&&D.set(P[N].value,N);const z=P.findIndex(N=>N.remainder),G=V(S);for(let N=0;N<x;N++){const Z=G(M?M[N]:N);if(Z==null||Z===""){C&&k[E]++;continue}if(Array.isArray(Z)){if(!Z.length){C&&k[E]++;continue}for(const ee of Z){const re=D.get(ee);re!==void 0?k[re]++:z>=0&&k[z]++}continue}const Q=D.get(Z);Q!==void 0?k[Q]++:z>=0&&k[z]++}return k}const j=C?P.length-1:P.length,T=new Float64Array(j+1);for(let D=0;D<j;D++)T[D]=P[D].from;T[j]=j?P[j-1].to:0;const F=v(S),$=A(S);for(let D=0;D<x;D++){const z=M?M[D]:D;if($&&!$(z)){C&&k[E]++;continue}const G=F(z);if(!Number.isFinite(G)){C&&k[E]++;continue}const N=f(T,j,G);N>=0&&k[N]++}return k}function f(S,M,X){if(!M||X<S[0])return-1;if(X>=S[M])return X===S[M]?M-1:-1;let q=0,K=M-1;for(;q<K;){const P=q+K+1>>>1;X>=S[P]?q=P:K=P-1}return q}function m(S,M,X,q={}){const K=q.bounds||p(S,q.boundsIndices??M,X,q);return{bounds:K,counts:y(S,M,X,K)}}const w=m}),ze("packages/core/src/compute/pivotmatrix.js",function(e,B){"use strict";Object.defineProperty(e,"GRAND_PATH",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"resolveAxis",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"pivotMatrix",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"cellKey",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"marginKey",{enumerable:!0,get:function(){return s}});const A=B("packages/core/src/compute/handle.js").valueComparator,U=B("packages/core/src/compute/total.js").total,J=B("packages/core/src/compute/group.js").packKeys,H=B("packages/core/src/compute/pivot.js"),L=H.joinPath,Y=H.DEFAULT_PATH_SEPARATOR,_=H.DEFAULT_MAX_COLUMNS,O="";function v(l,u,n={}){const p=n.separator||Y,r=l||[],i=u instanceof Uint32Array?u:Uint32Array.from(u||[]),d=i.length;if(r.length===0)return{tuples:[[]],paths:[O],buckets:[i]};const{keyOf:h,readers:a}=J(r,i,0),y=new Map,f=[],m=[],w=[];for(let P=0;P<d;P++){const k=i[P],E=h(k);let C=y.get(E);if(C===void 0){C=f.length,y.set(E,C),m.push(E);const x=new Array(a.length);for(let j=0;j<a.length;j++)x[j]=a[j](k);f.push(x),w.push([])}w[C].push(k)}const S=A(n.locale),M=f.map((P,k)=>k);M.sort((P,k)=>{const E=f[P],C=f[k];for(let x=0;x<E.length;x++){const j=b(E[x],C[x],S);if(j!==0)return j}return P-k});const X=new Array(M.length),q=new Array(M.length),K=new Array(M.length);for(let P=0;P<M.length;P++){const k=M[P];X[P]=f[k],q[P]=L(f[k],p),K[P]=Uint32Array.from(w[k])}return{tuples:X,paths:q,buckets:K}}function b(l,u,n){const p=l==null,r=u==null;return p||r?p&&r?0:p?1:-1:n(l,u)}function c(l,u,n){const p=[];for(let r=0;r<l.length;r++)n.has(l[r])&&p.push(l[r]);return Uint32Array.from(p)}function g(l,u,n,p){return{value:u.length?U(l,u,n,p):null,leaves:u,count:u.length}}function o(l){const u=l&&l.opts||{},n=u.separator||Y,p=u.totalContext||{locale:u.locale},r=(l.measures||[]).filter(q=>q&&q.handle),i=l.leaves instanceof Uint32Array?l.leaves:Uint32Array.from(l.leaves||[]),d=v(l.rowHandles||[],i,{...u,separator:n}),h=v(l.columnHandles||[],i,{...u,separator:n}),a=u.maxColumns===void 0?_:u.maxColumns,y=h.paths.length*Math.max(1,r.length),f=new Map;if(a&&y>a)return{rowAxis:d,columnAxis:h,measures:r.map(q=>({colId:q.colId,fn:q.fn})),body:f,rowMargin:f,columnMargin:f,grand:f,columns:y,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${y} columns, above pivot.maxColumns of ${a}. Narrow the pivot columns or raise the limit.`,columns:y,maxColumns:a}};const m=new Map,w=new Map,S=new Map,M=new Map,X=h.buckets.map(q=>new Set(q));for(let q=0;q<h.paths.length;q++){const K=h.buckets[q],P=h.paths[q];for(const k of r)S.set(s(P,k.colId),g(k.handle,K,k.fn,p))}for(let q=0;q<d.paths.length;q++){const K=d.buckets[q],P=d.paths[q];for(const k of r)w.set(s(P,k.colId),g(k.handle,K,k.fn,p));for(let k=0;k<h.paths.length;k++){const E=c(K,h.buckets[k],X[k]);if(E.length===0)continue;const C=h.paths[k];for(const x of r)m.set(t(P,C,x.colId),g(x.handle,E,x.fn,p))}}for(const q of r)M.set(q.colId,g(q.handle,i,q.fn,p));return{rowAxis:d,columnAxis:h,measures:r.map(q=>({colId:q.colId,fn:q.fn})),body:m,rowMargin:w,columnMargin:S,grand:M,columns:y,error:null}}function t(l,u,n){return`${l}\0${u}\0${n}`}function s(l,u){return`${l}\0${u}`}}),ze("packages/core/src/compute/reference.js",function(e,B){"use strict";Object.defineProperty(e,"referenceValue",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"referenceSort",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"referenceFilter",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"referencePasses",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"referenceGroup",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"referenceTotal",{enumerable:!0,get:function(){return o}});const A=B("packages/core/src/internal/paths.js").getPath,V=B("packages/core/src/compute/handle.js"),U=V.isMissing,I=V.valueComparator,H=B("packages/core/src/compute/filter.js").testValue,L="",Y="\0";function _(l,u){const n=u.includes(".")?A(l,u):l?.[u];return n===void 0?null:n}function O(l,u,n={}){const p=u||[];let r=l.map((i,d)=>d);if(p.length===0)return r;for(let i=p.length-1;i>=0;i--)r=v(l,r,p[i],n);return r}function v(l,u,n,p){const r=n.locale!==void 0?n.locale:p.locale,i=I(r),d=n.descending!==void 0?!!n.descending:n.dir==="desc",h=[],a=[];for(const m of u){const w=_(l[m],n.col);U(w)?a.push(m):h.push(m)}const y=new Map;for(let m=0;m<h.length;m++)y.set(h[m],m);const f=(m,w)=>{const S=_(l[m],n.col),M=_(l[w],n.col);let X;return typeof n.compare=="function"?(X=n.compare(S,M,l[m],l[w],d),d&&(X=-X)):X=d?i(M,S):i(S,M),X!==0?X:y.get(m)-y.get(w)};return h.sort(f),n.nullsFirst?a.concat(h):h.concat(a)}function b(l,u,n={}){const p=[];for(let r=0;r<l.length;r++)c(l[r],u,n,r)&&p.push(r);return p}function c(l,u,n,p){if(!u)return!0;if(Array.isArray(u.conditions)){const r=u.conditions.filter(d=>d!=null);if(r.length===0)return!0;if(u.op==="or")return r.some(d=>c(l,d,n,p));const i=r.every(d=>c(l,d,n,p));return u.op==="not"?!i:i}return u.col===void 0&&typeof n.custom=="function"?!!n.custom(u,l,p):H(_(l,u.col),u,n.locale)}function g(l,u,n,p){const r=n||l.map((a,y)=>y),i=new Map,d=[],h=[];for(const a of r){const y=u.map((w,S)=>{const M=_(l[a],w);return p&&p[S]?p[S](M):M}),f=y.map(w=>w==null?Y:String(w)).join(L);let m=i.get(f);m===void 0&&(m=d.length,i.set(f,m),d.push(y),h.push([])),h[m].push(a)}return{keys:d,buckets:h}}function o(l,u,n={}){const p=I(n.locale),r=l.filter(d=>!U(d)),i=r.map(t).filter(d=>d!==null);switch(u){case"count":return l.length;case"countValues":return r.length;case"sum":return i.reduce((d,h)=>d+h,0);case"avg":return r.length===0?null:i.reduce((d,h)=>d+h,0)/r.length;case"min":return r.length===0?null:r.reduce((d,h)=>p(h,d)<0?h:d);case"max":return r.length===0?null:r.reduce((d,h)=>p(h,d)>0?h:d);case"first":return l.length===0?null:s(l[0]);case"last":return l.length===0?null:s(l[l.length-1]);default:return null}}function t(l){if(typeof l=="number")return Number.isNaN(l)?null:l;if(l==null||l===""||typeof l=="boolean")return null;if(l instanceof Date)return l.getTime();const u=Number(l);return Number.isNaN(u)?null:u}function s(l){return l===void 0?null:l}}),ze("packages/core/src/compute/index.js",function(e,B){"use strict";const ne=B("packages/core/src/compute/sort.js");Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return ne.sortColumn}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return ne.sortMulti}}),Object.defineProperty(e,"radixSortFloat64",{enumerable:!0,get:function(){return ne.radixSortFloat64}}),Object.defineProperty(e,"radixSortInt32",{enumerable:!0,get:function(){return ne.radixSortInt32}}),Object.defineProperty(e,"rankSortDictionary",{enumerable:!0,get:function(){return ne.rankSortDictionary}}),Object.defineProperty(e,"mergeSortComparator",{enumerable:!0,get:function(){return ne.mergeSortComparator}}),Object.defineProperty(e,"collateStringRanks",{enumerable:!0,get:function(){return ne.collateStringRanks}}),Object.defineProperty(e,"rankSortStrings",{enumerable:!0,get:function(){return ne.rankSortStrings}});const A=B("packages/core/src/compute/sortspec.js");Object.defineProperty(e,"collationDescriptor",{enumerable:!0,get:function(){return A.collationDescriptor}}),Object.defineProperty(e,"isPortableSort",{enumerable:!0,get:function(){return A.isPortableSort}}),Object.defineProperty(e,"isPortableSortSet",{enumerable:!0,get:function(){return A.isPortableSortSet}}),Object.defineProperty(e,"describeSortEntry",{enumerable:!0,get:function(){return A.describeSortEntry}}),Object.defineProperty(e,"describeSort",{enumerable:!0,get:function(){return A.describeSort}});const V=B("packages/core/src/compute/filter.js");Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return V.evaluateFilters}}),Object.defineProperty(e,"evaluateCondition",{enumerable:!0,get:function(){return V.evaluateCondition}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return V.compact}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return V.testValue}}),Object.defineProperty(e,"compilePredicate",{enumerable:!0,get:function(){return V.compilePredicate}}),Object.defineProperty(e,"releaseMask",{enumerable:!0,get:function(){return V.releaseMask}}),Object.defineProperty(e,"pruneColumn",{enumerable:!0,get:function(){return V.pruneColumn}}),Object.defineProperty(e,"mentionsColumn",{enumerable:!0,get:function(){return V.mentionsColumn}});const U=B("packages/core/src/compute/group.js");Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return U.groupByColumns}}),Object.defineProperty(e,"packKeys",{enumerable:!0,get:function(){return U.packKeys}});const I=B("packages/core/src/compute/facet.js");Object.defineProperty(e,"facet",{enumerable:!0,get:function(){return I.facet}}),Object.defineProperty(e,"computeBounds",{enumerable:!0,get:function(){return I.computeBounds}}),Object.defineProperty(e,"countInto",{enumerable:!0,get:function(){return I.countInto}}),Object.defineProperty(e,"bucketOf",{enumerable:!0,get:function(){return I.bucketOf}}),Object.defineProperty(e,"facetKind",{enumerable:!0,get:function(){return I.facetKind}}),Object.defineProperty(e,"cardinalityOf",{enumerable:!0,get:function(){return I.cardinalityOf}}),Object.defineProperty(e,"pickGranularity",{enumerable:!0,get:function(){return I.pickGranularity}}),Object.defineProperty(e,"floorTo",{enumerable:!0,get:function(){return I.floorTo}}),Object.defineProperty(e,"advance",{enumerable:!0,get:function(){return I.advance}}),Object.defineProperty(e,"STRATEGIES",{enumerable:!0,get:function(){return I.STRATEGIES}}),Object.defineProperty(e,"GRANULARITIES",{enumerable:!0,get:function(){return I.GRANULARITIES}}),Object.defineProperty(e,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return I.DEFAULT_BUCKETS}}),Object.defineProperty(e,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return I.DEFAULT_CARDINALITY_LIMIT}}),Object.defineProperty(e,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return I.QUANTILE_SAMPLE}});const J=B("packages/core/src/compute/total.js");Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return J.TOTAL_FNS}}),Object.defineProperty(e,"TOTAL_LABELS",{enumerable:!0,get:function(){return J.TOTAL_LABELS}}),Object.defineProperty(e,"totalLabel",{enumerable:!0,get:function(){return J.totalLabel}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return J.total}}),Object.defineProperty(e,"collectValues",{enumerable:!0,get:function(){return J.collectValues}});const H=B("packages/core/src/compute/pivot.js");Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return H.pivot}}),Object.defineProperty(e,"resolvePivotKeys",{enumerable:!0,get:function(){return H.resolvePivotKeys}}),Object.defineProperty(e,"pivotKey",{enumerable:!0,get:function(){return H.pivotKey}}),Object.defineProperty(e,"joinPath",{enumerable:!0,get:function(){return H.joinPath}}),Object.defineProperty(e,"KEY_DELIMITER",{enumerable:!0,get:function(){return H.KEY_DELIMITER}}),Object.defineProperty(e,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return H.DEFAULT_PATH_SEPARATOR}}),Object.defineProperty(e,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return H.DEFAULT_MAX_COLUMNS}});const L=B("packages/core/src/compute/pivotmatrix.js");Object.defineProperty(e,"pivotMatrix",{enumerable:!0,get:function(){return L.pivotMatrix}}),Object.defineProperty(e,"resolveAxis",{enumerable:!0,get:function(){return L.resolveAxis}}),Object.defineProperty(e,"cellKey",{enumerable:!0,get:function(){return L.cellKey}}),Object.defineProperty(e,"marginKey",{enumerable:!0,get:function(){return L.marginKey}}),Object.defineProperty(e,"GRAND_PATH",{enumerable:!0,get:function(){return L.GRAND_PATH}});const Y=B("packages/core/src/compute/reference.js");Object.defineProperty(e,"referenceSort",{enumerable:!0,get:function(){return Y.referenceSort}}),Object.defineProperty(e,"referenceFilter",{enumerable:!0,get:function(){return Y.referenceFilter}}),Object.defineProperty(e,"referenceGroup",{enumerable:!0,get:function(){return Y.referenceGroup}}),Object.defineProperty(e,"referenceTotal",{enumerable:!0,get:function(){return Y.referenceTotal}}),Object.defineProperty(e,"referencePasses",{enumerable:!0,get:function(){return Y.referencePasses}}),Object.defineProperty(e,"referenceValue",{enumerable:!0,get:function(){return Y.referenceValue}});const _=B("packages/core/src/compute/handle.js");Object.defineProperty(e,"identity",{enumerable:!0,get:function(){return _.identity}}),Object.defineProperty(e,"rowCount",{enumerable:!0,get:function(){return _.rowCount}}),Object.defineProperty(e,"presenceReader",{enumerable:!0,get:function(){return _.presenceReader}}),Object.defineProperty(e,"bitReader",{enumerable:!0,get:function(){return _.bitReader}}),Object.defineProperty(e,"valueReader",{enumerable:!0,get:function(){return _.valueReader}}),Object.defineProperty(e,"valueComparator",{enumerable:!0,get:function(){return _.valueComparator}}),Object.defineProperty(e,"numericTotalOrder",{enumerable:!0,get:function(){return _.numericTotalOrder}}),Object.defineProperty(e,"dictRanks",{enumerable:!0,get:function(){return _.dictRanks}}),Object.defineProperty(e,"dictSize",{enumerable:!0,get:function(){return _.dictSize}}),Object.defineProperty(e,"dictValue",{enumerable:!0,get:function(){return _.dictValue}}),Object.defineProperty(e,"multiValue",{enumerable:!0,get:function(){return _.multiValue}}),Object.defineProperty(e,"isMissing",{enumerable:!0,get:function(){return _.isMissing}});const O=B("packages/core/src/compute/sketch.js");Object.defineProperty(e,"Welford",{enumerable:!0,get:function(){return O.Welford}}),Object.defineProperty(e,"Reservoir",{enumerable:!0,get:function(){return O.Reservoir}}),Object.defineProperty(e,"HyperLogLog",{enumerable:!0,get:function(){return O.HyperLogLog}}),Object.defineProperty(e,"SpaceSaving",{enumerable:!0,get:function(){return O.SpaceSaving}}),Object.defineProperty(e,"KLL",{enumerable:!0,get:function(){return O.KLL}}),Object.defineProperty(e,"hash32",{enumerable:!0,get:function(){return O.hash32}}),Object.defineProperty(e,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return O.SKETCH_BOUNDS}});const v=B("packages/core/src/compute/windowed.js");Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return v.Window}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return v.WINDOW_KINDS}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return v.openWindow}});const b=B("packages/core/src/compute/statistics.js");Object.defineProperty(e,"MAINTENANCE",{enumerable:!0,get:function(){return b.MAINTENANCE}}),Object.defineProperty(e,"APPROXIMATE",{enumerable:!0,get:function(){return b.APPROXIMATE}}),Object.defineProperty(e,"maintenanceOf",{enumerable:!0,get:function(){return b.maintenanceOf}});const c=B("packages/core/src/compute/anomaly.js");Object.defineProperty(e,"ANOMALY_METHODS",{enumerable:!0,get:function(){return c.ANOMALY_METHODS}}),Object.defineProperty(e,"modifiedZScores",{enumerable:!0,get:function(){return c.modifiedZScores}}),Object.defineProperty(e,"iqrFences",{enumerable:!0,get:function(){return c.iqrFences}}),Object.defineProperty(e,"mahalanobis",{enumerable:!0,get:function(){return c.mahalanobis}}),Object.defineProperty(e,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return c.ROLLING_ANOMALY_METHODS}}),Object.defineProperty(e,"rollingAnomalies",{enumerable:!0,get:function(){return c.rollingAnomalies}}),Object.defineProperty(e,"anomalyCondition",{enumerable:!0,get:function(){return c.anomalyCondition}});const g=B("packages/core/src/compute/forecast.js");Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return g.FORECAST_METHODS}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return g.forecast}})}),ze("packages/core/src/source/rows.js",function(e,B){"use strict";Object.defineProperty(e,"DEFAULT_ROW_HEIGHT",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"KEY_SEP",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"createRowFactory",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"RowFactory",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"pinnedRow",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"lazyRowView",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"groupPathElement",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"groupKey",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"groupPrefixKeys",{enumerable:!0,get:function(){return g}});const A=B("packages/core/src/internal/warn.js").warnOnce,U=B("packages/core/src/internal/predicates.js").isFunction,I=32,J="\0";function H(o){return new L(o)}class L{#e;#t;constructor(t){this.#e=U(t&&t.rowKey)?t.rowKey:null;const s=t&&t.config?t.config.rowHeight:void 0;this.#t=typeof s=="number"||U(s)?s:I}get keyed(){return this.#e!==null}keyOf(t,s){if(this.#e){const l=this.#e(t);if(l!=null)return String(l)}else A("source.rowKey.missing","no config.rowKey; falling back to index identity.","Row changes, streaming dedupe, selection persistence and remote reload are disabled.");return`#${s}`}heightOf(t){return U(this.#t)?Number(this.#t(t))||I:this.#t}leaf(t,s,l=0,u=null){const n={key:this.keyOf(t,s),data:t,level:l,parent:u,group:!1,expanded:!1,leafCount:1,height:0,index:null,selected:!1,physical:s};return n.height=this.heightOf(n),n}group(t){const s={key:c(t.keyPath||t.path),data:null,level:t.level,parent:t.parent||null,children:[],group:!0,expanded:t.expanded!==!1,leafCount:t.leafCount||0,height:0,index:null,selected:!1,physical:null,groupColumn:t.column,groupValue:t.value,groupPath:t.path,hasChildren:t.hasChildren!==!1};return t.totals&&(s.totals=t.totals),s.height=this.heightOf(s),s}footer(t){const s={key:`${t.key}${J}footer`,data:null,level:t.level,parent:t,group:!0,footer:!0,expanded:!1,leafCount:t.leafCount||0,height:0,index:null,selected:!1,physical:null,groupColumn:t.groupColumn,groupValue:t.groupValue,groupPath:t.groupPath,hasChildren:!1,totals:t.totals};return s.height=this.heightOf(s),s}detail(t,s){return{key:`${t.key}${J}detail`,data:t.data,level:t.level+1,parent:t,group:!1,detail:!0,expanded:!1,leafCount:0,height:s,index:null,selected:!1,physical:null,hasChildren:!1,masterKey:t.key}}grandTotal(t,s){const l={key:`${J}grandTotal`,data:null,level:0,parent:null,group:!0,grandTotal:!0,expanded:!1,leafCount:s,height:0,index:null,selected:!1,physical:null,groupPath:[],hasChildren:!1,totals:t};return l.height=this.heightOf(l),l}skeleton(t,s=0,l=!1){const u={key:`${J}pending${J}${t}`,data:null,level:s,parent:null,group:!1,expanded:!1,leafCount:1,height:0,index:t,selected:!1,physical:null,pending:!0};return l&&(u.loadError=!0),u.height=this.heightOf(u),u}}function Y(o,t,s,l){return{key:`${J}pinned${J}${s}${J}${t}`,data:o,level:0,parent:null,group:!1,expanded:!1,leafCount:0,height:l,index:null,selected:!1,physical:null,hasChildren:!1,pinned:s}}function _(o,t){return new Proxy([],{get(s,l,u){if(l==="length")return o();if(typeof l=="string"){const n=Number(l);if(Number.isInteger(n)&&n>=0)return t(n)}return Reflect.get(s,l,u)},has(s,l){if(typeof l=="string"){const u=Number(l);if(Number.isInteger(u)&&u>=0)return u<o()}return Reflect.has(s,l)}})}function O(o){return o==null?"":String(o)}const v="";function b(o){if(o==null)return v;const t=String(o);return t.startsWith(v)?v+t:t}function c(o){const t=o||[];let s="g";for(let l=0;l<t.length;l++)s+=J+b(t[l]);return s}function g(o){const t=new Array(o.length),s=[];for(let l=0;l<o.length;l++)s.push(o[l]),t[l]=c(s);return t}}),ze("packages/core/src/source/handles.js",function(e,B){"use strict";Object.defineProperty(e,"HandleProvider",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"createHandleProvider",{enumerable:!0,get:function(){return J}});const A=B("packages/core/src/internal/predicates.js").isFunction,U=B("packages/core/src/internal/warn.js").warnOnce;class I{#e;#t;#n;#r=new Map;#s=0;constructor(L,Y,_){this.#e=L,this.#t=Y,this.#n=A(_)?_:()=>!1}get store(){const L=this.#e.store;return L&&A(L.column)?L:null}invalidate(){this.#s++}handle(L){const Y=this.store;if(Y){const b=Y.column(L);if(b)return b}const _=this.#r.get(L);if(_&&_.builtAt===this.#s)return _.handle;const O=this.#i(L);if(!O)return;if(Y&&this.#n()){U(`source.dropped.${L}`,`column "${L}" cannot be served under ingest.dropSourceRows: it is an impure computed column (a shadow or a positional/rank column) that is never stored, so it can only be read from the caller's row objects — which dropSourceRows has released. Do not sort, filter, group or total on such a column with dropSourceRows enabled.`);return}const v=this.#a(O);return this.#r.set(L,{handle:v,builtAt:this.#s}),v}#i(L){const Y=this.#e.columns;return Y&&A(Y.get)?Y.get(L):void 0}#a(L){const Y=this.#t()||[],_=Y.length,O=new Array(_),v=A(L.getValue)?c=>L.getValue(c):c=>c?.[L.field||L.id];for(let c=0;c<_;c++)O[c]=Y[c]===void 0?void 0:v(Y[c]);const b=this.#s;return{id:L.id,kind:"object",nullable:!1,values:O,presence:null,dict:null,offsets:null,get(c){return O[c]},version:b}}}function J(H,L,Y){return new I(H,L,Y)}}),ze("packages/core/src/compute/incremental.js",function(e,B){"use strict";Object.defineProperty(e,"INCREMENTAL_FNS",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"INCREMENTAL_KINDS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"MAGNITUDE_LIMIT",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"isIncremental",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"RunningTotal",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Y}});const A=B("packages/core/src/store/columnstore.js").toFloat,V=Object.freeze(["sum","avg","countValues","min","max"]),U=Object.freeze(["float64"]),I=1e15;function J(_,O){return typeof _!="string"||!V.includes(_)?!1:!!O&&U.includes(O.kind)}function H(_){if(_==null)return null;const O=A(_);return Number.isNaN(O)?null:O}class L{#e;#t=0;#n=0;#r=0;#s=1/0;#i=-1/0;#a=!1;#l=!1;constructor(O){this.#e=O}get valid(){return this.#a&&!this.#l}get fn(){return this.#e}seed(O){this.#o();for(let v=0;v<O.length;v++){const b=H(O[v]);b!==null&&this.#c(b)}this.#a=!0}seedColumn(O,v,b){this.#o();for(let c=0;c<b.length;c++){const g=b[c];if(v&&v(g)===0)continue;const o=O[g];Number.isNaN(o)||this.#c(o)}this.#a=!0}#o(){this.#t=0,this.#n=0,this.#r=0,this.#s=1/0,this.#i=-1/0,this.#l=!1}#c(O){if(!Number.isFinite(O)){this.#l=!0;return}const v=this.#t+O;this.#n+=Math.abs(this.#t)>=Math.abs(O)?this.#t-v+O:O-v+this.#t,this.#t=v,this.#r++,O<this.#s&&(this.#s=O),O>this.#i&&(this.#i=O)}#u(O){const v=this.#t-O;this.#n+=Math.abs(this.#t)>=Math.abs(O)?this.#t-v-O:-O-v+this.#t,this.#t=v,this.#r--}update(O,v){if(!this.#a)return!1;const b=H(O),c=H(v);return b===null&&c===null?!0:b!==null&&!Number.isFinite(b)||c!==null&&!Number.isFinite(c)?!1:this.#e==="min"||this.#e==="max"?b===null||c===null?!1:this.#e==="min"?c<this.#s?(this.#s=c,!0):b>this.#s:c>this.#i?(this.#i=c,!0):b<this.#i:Math.abs(this.#t)>I?!1:(b!==null&&this.#u(b),c!==null&&this.#c(c),!0)}value(){switch(this.#e){case"countValues":return this.#r;case"avg":return this.#r?(this.#t+this.#n)/this.#r:null;case"min":return this.#r?this.#s:null;case"max":return this.#r?this.#i:null;default:return this.#t+this.#n}}invalidate(){this.#a=!1}}const Y=L}),ze("packages/core/src/source/filterwire.js",function(e,B){"use strict";Object.defineProperty(e,"HOST_FILTER_WARN_ID",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"WHERE_PAGE_RELATIVE_WARN_ID",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"warnWherePageRelative",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"warnHostFilterNotApplied",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"WHERE_NOT_APPLIED_WARN_ID",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"warnWhereNotApplied",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"WHERE_OVER_THRESHOLD_WARN_ID",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"warnWhereOverThreshold",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"RELATIVE_TOKENS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"parseRelativeToken",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"resolveRelativeRange",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"relativeTokenOf",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"relativeTokenHelp",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"isResolvableRelative",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"resolveRelativeCondition",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"isGroup",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"forEachCondition",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"mapConditions",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"normaliseFilterSet",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"buildFilterSet",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"wireFilters",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"querySignature",{enumerable:!0,get:function(){return S}});const A=B("packages/core/src/internal/warn.js").warnOnce,V="source.remote.hostFilter",U="source.where.pageRelative";function I(q,K){!Array.isArray(q)||!q.length||A(U,`filters.where (${q.join(", ")}) runs over the rows the ${K} source fetched,`,"not the whole dataset: match counts and totals are page-relative.","Give the predicate a { condition } twin so the engine can narrow the fetch itself.")}function J(q){const K=(q||{}).config;!K||!K.hostFilter||A(V,"config.hostFilter is not sent to a server-delegated source (paged/remote) and is not applied:","filtering only the fetched window would give wrong counts and totals.","Express the filter as a FilterSet condition, or send it through config.context.")}const H="source.where.notApplied";function L(q,K){A(`${H}:${q}`,`filters.where("${q}") is registered but the ${K} source holds only its fetched window`,"and cannot run the predicate over it: the predicate is not applied there, and rows it would","exclude stay on screen.","Give it a { condition } twin so the engine can narrow the fetch itself — that is the","supported route for a paged or remote source.")}const Y="source.where.overThreshold";function _(q,K,P,k){!Array.isArray(q)||!q.length||A(`${Y}:${K}`,`filters.where (${q.join(", ")}) is not applied to the ${K} pushdown source:`,P===null?"the adapter reports no row total, so the size of the matching set is unknown.":`its matching set is ${P.toLocaleString()} rows, at or past the whereRowLimit of ${k.toLocaleString()}.`,"Running the predicate needs every matching row fetched and held here, which is the whole","download a pushdown source exists to avoid, so it is refused and the rows the predicate","would exclude stay on screen.","Give the predicate a { condition } twin so the engine narrows the fetch itself — that is the","route that works at any size — or raise `whereRowLimit` on the source config if you want the","download.")}const O=new Map;function v(q){let K=O.get(q);return K||(K=new Intl.DateTimeFormat("en-US",{timeZone:q,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}),O.set(q,K)),K}function b(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function c(q,K){const P=v(K).formatToParts(new Date(q)),k={y:1970,m:1,d:1,h:0,mi:0,s:0};for(const E of P)E.type==="year"?k.y=+E.value:E.type==="month"?k.m=+E.value:E.type==="day"?k.d=+E.value:E.type==="hour"?k.h=+E.value%24:E.type==="minute"?k.mi=+E.value:E.type==="second"&&(k.s=+E.value);return k}function g(q,K){const P=c(q,K);return Date.UTC(P.y,P.m-1,P.d,P.h,P.mi,P.s)-Math.floor(q/1e3)*1e3}function o(q,K,P,k){const E=Date.UTC(q,K-1,P),C=E-g(E,k);return E-g(C,k)}function t(q,K,P){const k=new Date(Date.UTC(q.y,q.m-1,q.d+K));return o(k.getUTCFullYear(),k.getUTCMonth()+1,k.getUTCDate(),P)}const s=Object.freeze(["today","yesterday","lastNDays","thisWeek","thisMonth","thisQuarter","thisYear","quarterToDate","yearToDate"]);function l(q,K){if(typeof q!="string")return null;const P=q.trim().toLowerCase().replace(/[\s_-]+/g,""),k=/^last(\d*|n)days?$/.exec(P);if(k){const E=k[1]==="n"?"":k[1],C=Number(E||K);return!Number.isFinite(C)||C<=0?null:{kind:"lastNDays",n:Math.floor(C)}}switch(P){case"today":return{kind:"today",n:0};case"yesterday":return{kind:"yesterday",n:0};case"thisweek":return{kind:"thisWeek",n:0};case"thismonth":return{kind:"thisMonth",n:0};case"thisquarter":return{kind:"thisQuarter",n:0};case"thisyear":return{kind:"thisYear",n:0};case"quartertodate":case"qtd":return{kind:"quarterToDate",n:0};case"yeartodate":case"ytd":return{kind:"yearToDate",n:0};default:return null}}function u(q,K={}){const P=l(q,K.n);if(!P)return null;const k=K.tz||b(),E=K.now instanceof Date?K.now.getTime():typeof K.now=="number"?K.now:Date.now(),C=c(E,k),x=o(C.y,C.m,C.d,k),j=t(C,1,k);let T=x,F=j;switch(P.kind){case"today":break;case"yesterday":T=t(C,-1,k),F=x;break;case"lastNDays":F=K.includeToday?j:x,T=t(C,K.includeToday?-(P.n-1):-P.n,k);break;case"thisWeek":{const $=Number.isFinite(K.weekStartsOn)?Number(K.weekStartsOn):1,z=(new Date(Date.UTC(C.y,C.m-1,C.d)).getUTCDay()-$+7)%7;T=t(C,-z,k),F=t(C,-z+7,k);break}case"thisMonth":T=o(C.y,C.m,1,k),F=o(C.m===12?C.y+1:C.y,C.m===12?1:C.m+1,1,k);break;case"thisQuarter":case"quarterToDate":{const $=Math.floor((C.m-1)/3)*3+1;T=o(C.y,$,1,k),F=P.kind==="quarterToDate"?j:$===10?o(C.y+1,1,1,k):o(C.y,$+3,1,k);break}case"thisYear":case"yearToDate":T=o(C.y,1,1,k),F=P.kind==="yearToDate"?j:o(C.y+1,1,1,k);break;default:return null}return{from:new Date(T).toISOString(),to:new Date(F).toISOString(),bounds:"[)",tz:k,relative:P.kind==="lastNDays"?`last${P.n}Days`:P.kind,n:P.n}}function n(q){if(!q||typeof q!="object")return null;const K=q.value;if(K&&typeof K=="object"&&!Array.isArray(K)&&"relative"in K)return{token:String(K.relative),n:typeof K.n=="number"?K.n:void 0};if(q.op==="relative"&&typeof q.value=="string")return{token:q.value,n:void 0};const P=q.meta;return P&&typeof P.relative=="string"&&q.value===void 0?{token:P.relative,n:typeof P.n=="number"?P.n:void 0}:null}function p(){return`Known tokens: ${s.filter(K=>K!=="lastNDays").join(", ")}. "lastNDays" needs a count: pass "last7Days", or the value object { relative: 'lastNDays', n: 7 }.`}function r(q){const K=n(q);return K?l(K.token,K.n)!==null:!1}function i(q,K={}){const P=n(q);if(!P)return q;const k=u(P.token,{...K,n:P.n});return k?{...q,type:q.type||"date",op:"between",value:[k.from,k.to],bounds:q.bounds||k.bounds,meta:{...q.meta||{},relative:k.relative,tz:k.tz}}:(A(`source.relative.${P.token}`,`unknown relative date token "${P.token}"; sending the condition unresolved.`,p()),q)}function d(q){return!!q&&typeof q=="object"&&Array.isArray(q.conditions)}function h(q,K){if(q){if(d(q)){for(const P of q.conditions)h(P,K);return}K(q)}}function a(q,K){if(!q)return null;if(!d(q))return K(q);const P=q;let k=!1;const E=[];for(const C of P.conditions){const x=a(C,K);x!==C&&(k=!0),x&&E.push(x)}return!k&&E.length===P.conditions.length?q:E.length?{...P,conditions:E}:null}function y(q){if(!q)return null;if(!d(q))return q;const K=q,P=[];for(const k of K.conditions){const E=y(k);E&&P.push(E)}return P.length?{op:K.op,conditions:P}:null}function f(q){const K=y(q);return K?d(K)&&K.op==="and"?K:{op:"and",conditions:[K]}:null}function m(q){const K=(q||[]).filter(Boolean);return K.length?{op:"and",conditions:K}:null}function w(q,K={}){const P=a(q,k=>i(k,K));return f(P)}function S(q){const K=M(q.filters??null);return JSON.stringify([K,q.sort??null,q.quick??"",q.groupBy??null,q.pivotBy??null,X(q.context)])}function M(q){if(!q)return null;if(d(q)){const k=q;return{op:k.op,conditions:k.conditions.map(M)}}const K=q,P=K.meta&&typeof K.meta.relative=="string"?K.meta.relative:n(K)?.token;return{col:K.col,op:K.op,bounds:K.bounds??null,caseSensitive:K.caseSensitive??!1,value:P?`rel:${P}`:K.value??null}}function X(q){if(q==null)return null;try{return JSON.parse(JSON.stringify(q))}catch{return A("source.context.unserialisable","config.context is not JSON-serialisable; cache keys ignore it."),"[unserialisable]"}}}),ze("packages/core/src/source/tree.js",function(e,B){"use strict";Object.defineProperty(e,"SYNTHETIC",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"buildFromPath",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"buildFromParentKey",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"assignLevels",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"resolveTree",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"buildTree",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"indexTree",{enumerable:!0,get:function(){return c}});const A=B("packages/core/src/internal/predicates.js").isFunction,U=B("packages/core/src/internal/warn.js").warnOnce,I="",J="\0tree:";function H(g,o){return{physical:g,key:o,level:0,children:[],value:void 0}}function L(g,o){const t=[],s=new Map;for(let l=0;l<g.length;l++){const u=g[l],n=o.pathOf(u),p=Array.isArray(n)?n.map(i=>String(i)):[];if(!p.length){const i=H(u,o.keyOf(u));t.push(i);continue}let r=null;for(let i=0;i<p.length;i++){const d=p.slice(0,i+1).join(I),h=i===p.length-1;let a=s.get(d);a&&h&&a.physical===-1&&(a.physical=u,a.key=o.keyOf(u)),a||(a=H(h?u:-1,h?o.keyOf(u):J+d),a.level=i,a.value=p[i],s.set(d,a),r?r.children.push(a):t.push(a)),r=a}}return{roots:t,nodes:s}}function Y(g,o){const t=new Map,s=[];for(let p=0;p<g.length;p++){const r=g[p],i=o.keyOf(r),d=H(r,i);t.set(i,d);const h=o.parentOf(r);h!=null&&h!==""&&s.push({node:d,parent:String(h)})}let l=null;const u=new Map;for(const{node:p,parent:r}of s){const i=t.get(r);if(i){u.set(p.key,i);continue}o.orphans&&o.orphans!=="root"&&(l||(l=H(-1,`${J}orphans`),l.value=o.orphans),u.set(p.key,l))}const n=[];for(const p of t.values()){const r=u.get(p.key);r?r.children.push(p):n.push(p)}return l&&l.children.length&&n.push(l),{roots:_(n,t,o.orphans,l),nodes:t}}function _(g,o,t,s){const l=new Set,u=[...g];for(;u.length;){const d=u.pop();if(!l.has(d.key)){l.add(d.key);for(const h of d.children)u.push(h)}}const n=[];for(const d of o.values())l.has(d.key)||n.push(d);if(!n.length)return g;const p=!!t&&t!=="root";U("tree.cycle",`tree.parentKey produced ${n.length} row(s) inside a parent cycle; `+(p?`they are shown under "${t}".`:"they are shown at the root."));for(const d of n)d.children=d.children.filter(h=>l.has(h.key));if(!p)return[...g,...n];let r=s;const i=[...g];return r||(r=H(-1,`${J}orphans`),r.value=t,i.push(r)),r.children.push(...n),i}function O(g){let o=0;const t=(s,l)=>{for(const u of s)u.level=l,l>o&&(o=l),u.children.length&&t(u.children,l+1)};return t(g,0),o}function v(g,o){if(!g||typeof g!="object")return null;const t=g.path,s=g.parentKey,l=A(g.hasChildren)?u=>!!g.hasChildren(o.dataAt(u)):null;if(A(t))return{mode:"path",pathOf:u=>t(o.dataAt(u)),keyOf:o.keyOf,declaresChildren:l};if(s!=null){const u=A(s)?s:n=>n?.[s];return{mode:"parentKey",parentOf:n=>u(o.dataAt(n)),keyOf:o.keyOf,orphans:g.orphans||"root",declaresChildren:l}}return U("tree.shape","tree is configured with neither `path` nor `parentKey`; rows stay flat."),null}function b(g,o){const t=o.mode==="path"?L(g,o):Y(g,o),s=O(t.roots);return{...t,depth:s}}function c(g,o){const t=new Map,s=l=>{for(let u=0;u<l.length;u++){const n=l[u];if(n.physical>=0){const p=o?o(n.physical):!1,r=p&&n.children.length===0;t.set(n.physical,{level:n.level,posinset:u+1,setsize:l.length,hasChildren:n.children.length>0||p,lazy:r})}n.children.length&&s(n.children)}};return s(g),t}}),ze("packages/core/src/source/settle.js",function(e,B){"use strict";Object.defineProperty(e,"PIPELINE_SETTLE_REASONS",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"isPipelineSettle",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"ARRIVAL_REASONS",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"isArrival",{enumerable:!0,get:function(){return U}});const ne=Object.freeze(["pipeline:sort","pipeline:sort:error"]);function A(I){const J=I&&typeof I=="object"?I.reason:null;return typeof J=="string"&&ne.includes(J)}const V=Object.freeze(["page","total"]);function U(I){const J=I&&typeof I=="object"?I.reason:null;return typeof J=="string"&&V.includes(J)}}),ze("packages/core/src/source/memory.js",function(e,B){"use strict";Object.defineProperty(e,"STAGES",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"PIPELINE_SETTLE_REASONS",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"isPipelineSettle",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"createMemorySource",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"quickMatcher",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"MemorySource",{enumerable:!0,get:function(){return z}});const A=B("packages/core/src/internal/lru.js").Lru,V=B("packages/core/src/internal/warn.js"),U=V.warnOnce,I=V.fail,H=B("packages/core/src/internal/predicates.js").isFunction,Y=B("packages/core/src/internal/compare.js").defaultCompare,O=B("packages/core/src/internal/merge.js").mergeRow,v=B("packages/core/src/source/rows.js"),b=v.createRowFactory,c=v.groupKey,g=v.groupPathElement,o=v.groupPrefixKeys,t=v.lazyRowView,l=B("packages/core/src/source/handles.js").createHandleProvider,u=B("packages/core/src/compute/incremental.js"),n=u.RunningTotal,p=u.isIncremental,i=B("packages/core/src/compute/handle.js").presenceReader,d=B("packages/core/src/source/filterwire.js"),h=d.querySignature,a=d.mapConditions,y=d.resolveRelativeCondition,f=B("packages/core/src/source/tree.js"),m=f.buildTree,w=f.resolveTree,S=f.indexTree,M=B("packages/core/src/source/settle.js"),X=M.PIPELINE_SETTLE_REASONS,q=M.isPipelineSettle,K=Object.freeze(["filter","sort","group","total","pivot","flatten"]),P=Object.freeze([]);function k(G,N){if(!G)return null;const Z=N==="grand"?G.grandTotal:G.groupTotal;return Z??G.total}function E(G){return!!G&&!G.running}function C(G){if(G)return G.value&&H(G.value.compare)?G.value.compare:H(G.compare)?G.compare:void 0}function x(G){const N=G&&G.dataType;return!N||!H(N.items)?null:{items:N.items,type:G.itemType&&G.itemType.name||"text"}}function j(G){return!!G&&(typeof G=="object"||typeof G=="function")&&H(G.then)}const T=new Uint32Array(0),F=4096;function $(G,N){return new z(G,N)}function D(G,N){if(N==="regex")try{const Z=new RegExp(G,"iu");return Q=>Z.test(Q)}catch{return Z=>Z.includes(G)}if(N==="fuzzy"){const Z=[...G].filter(Q=>Q!==" ");return Z.length?Q=>{let ee=0;for(let re=0;re<Q.length&&ee<Z.length;re++)Q[re]===Z[ee]&&ee++;return ee===Z.length}:()=>!0}if(N==="words"){const Z=G.split(/\s+/).filter(Boolean);return Z.length?Q=>Z.every(ee=>Q.includes(ee)):()=>!0}return Z=>Z.includes(G)}class z{mode="memory";#e;#t;#n;#r=!1;#s=null;#i;#a;#l=new Map;#o=!1;#c=0;#u=0;#f=new Map;#d=new Map;#h;#p=null;#m=z.#g();static#g(){return{slots:[],groupHeadings:P,unnumbered:P,pivot:null,inlineLeaves:null,matchCount:0,grand:null,grandLeaves:0,groupLeaves:null}}#b=new Map;#y=null;#S=new Map;#w=-1;#A=[];#v=new Map;#C=-1;#O=[];#P=null;#E=null;#T=null;#M=null;#N=null;#R=null;#D=null;#G=null;#K=Symbol("unset");#L=new Map;#q=null;get#B(){return this.#m.slots}set#B(N){this.#m.slots=N}get#Y(){return this.#m.inlineLeaves}set#Y(N){this.#m.inlineLeaves=N}get#z(){return this.#m.groupHeadings}set#z(N){this.#m.groupHeadings=N}get#I(){return this.#m.unnumbered}set#I(N){this.#m.unnumbered=N}get#W(){return this.#m.pivot}set#W(N){this.#m.pivot=N}constructor(N,Z){this.#t=N||{mode:"memory"},this.#e=Z||{};const Q=this.#e.config||{};this.#n=this.#t.rows||Q.rows||[],this.#i=b(this.#e),this.#a=l(this.#e,()=>this.#n,()=>this.#r),this.#h=new A(Number(Q.rowCacheSize)||F);for(const ee of K)this.#l.set(ee,{key:null,result:null,id:0,computed:!1})}count(){this.#_();const N=this.#ge();return N?N.length:this.#B.length}#ge(){const N=Number(this.#H("pageSize",0))||0;if(N<=0)return null;const Z=this.#B.length,Q=Math.max(1,Math.ceil(Z/N)),re=Math.min(Math.max(0,Number(this.#H("page",0))||0),Q-1)*N;return{offset:re,length:Math.max(0,Math.min(N,Z-re))}}pageInfo(){this.#_();const N=Number(this.#H("pageSize",0))||0,Z=this.#B.length;if(N<=0)return{page:0,pageSize:0,total:Z,pageCount:1};const Q=Math.max(1,Math.ceil(Z/N));return{page:Math.min(Math.max(0,Number(this.#H("page",0))||0),Q-1),pageSize:N,total:Z,pageCount:Q}}totalCount(){return this.#et().length}matchCount(){return this.#_(),this.#m.matchCount}at(N){this.#_();const Z=this.#ge();if(Z)return N<0||N>=Z.length?void 0:this.#He(Z.offset+N,N);if(!(N<0||N>=this.#B.length))return this.#He(N,N)}byKey(N){this.#_(),this.#p||this.#Ae();const Z=this.#p.get(N);if(Z!==void 0)return this.#ce(Z);for(let Q=0;Q<this.#B.length;Q++){const ee=this.#B[Q];if(typeof ee!="number"&&ee&&ee.key===N)return this.#He(Q)}}loaded(N){return N>=0&&N<this.count()}hint(N,Z){}display(){return this.#_(),this.#q||(this.#q=this.#$e()),this.#q}invalidateQuickText(){this.#L.clear(),this.invalidate("filter")}invalidate(N){const Z=K.indexOf(N);Z<0&&I(`unknown pipeline stage "${N}"; expected one of ${K.join(", ")}`);for(let Q=Z;Q<K.length;Q++){const ee=this.#l.get(K[Q]);ee.key=null,ee.computed=!1}this.#q=null}apply(N){const Z=[],Q={added:[],updated:[],removed:[],rejected:Z};if(!N)return Q;let ee=!1;const re=new Set;if(N.remove&&N.remove.length)for(const ie of N.remove){const ce=this.#Pe(ie);if(ce===void 0){Z.push({operation:"remove",id:this.#Ue(ie),reason:"unknown-id"});continue}Q.removed.push(this.#i.keyOf(this.#r?this.#Je(ce):this.#n[ce],ce)),this.#r||(this.#n[ce]=void 0),this.#h.delete(ce),this.#L.delete(ce),ee=!0}if(N.update&&N.update.length){const ie=this.#S.size||this.#at()?this.#Ke():null,ce=this.#v.size?this.#ht():null,ve=ce&&ce.length?this.#Ke():null;for(const he of N.update){const ye=this.#Pe(he);if(ye===void 0){Z.push({operation:"update",id:this.#xe(he),reason:"unknown-id"});continue}const Oe=this.#r?this.#s&&this.#s.has(ye)?this.#s.get(ye):this.#Je(ye):this.#n[ye],Le=O(Oe,he);for(const fe of this.#le(Oe,Le))re.add(fe);if(this.#r||(this.#n[ye]=Le),ie&&this.#Qe(ie,ye,Oe,Le),ve&&this.#Ve(ce,ve,ye,Oe,Le),this.#p){const fe=this.#i.keyOf(Oe,ye),ae=this.#i.keyOf(Le,ye);fe!==ae&&(this.#p.delete(fe),this.#p.set(ae,ye))}this.#h.delete(ye),this.#L.delete(ye),Q.updated.push(this.#ce(ye))}}if(N.add&&N.add.length&&this.#r){typeof N.at=="number"&&N.at<this.#j()&&(this.#h.clear(),this.#L.clear()),this.#p=null;for(const ie of N.add){const ce=this.#ae(this.#xe(ie));ce!==void 0&&Q.added.push(this.#ce(ce))}ee=!0}else if(N.add&&N.add.length){let ie=typeof N.at=="number"?N.at:this.#n.length;if(ie<this.#n.length){let he=0;for(let ye=0;ye<this.#n.length;ye++)this.#n[ye]!==void 0&&he++;if(he!==this.#n.length){let ye=0;for(let Oe=0;Oe<this.#n.length;Oe++)this.#n[Oe]!==void 0&&(this.#n[ye++]=this.#n[Oe]);this.#n.length=ye,this.#p=null,this.#h.clear(),this.#L.clear()}}const ce=this.#n.length;ie=Math.max(0,ie);let ve=N.add===this.#n?N.add.slice():N.add;if(this.#i.keyed){const he=[];for(const ye of ve){const Oe=this.#xe(ye);if(this.#Pe(Oe)!==void 0){Z.push({operation:"add",id:Oe,reason:"duplicate-id"});continue}he.push(ye)}he.length!==ve.length&&(ve=he)}if(!ve.length)return Q;if(ie>=ce)for(let he=0;he<ve.length;he++)this.#n.push(ve[he]);else this.#n.splice(ie,0,...ve),this.#h.clear(),this.#L.clear();for(let he=0;he<ve.length;he++)Q.added.push(this.#ce(ie>=ce?ce+he:ie+he));ee=!0}return this.#c++,ee&&(this.#p=null,this.#lt()),this.#a.invalidate(),this.#q=null,ee||this.#ne(re)?(this.#u++,this.invalidate("filter")):this.invalidate("total"),this.#bt("rows:changed",{companion:!0,added:Q.added.length,updated:Q.updated.length,removed:Q.removed.length}),this.#s=null,Q}groupHeadingsAt(N){this.#_();const Z=this.#z;if(!Z.length||!Number.isInteger(N)||N<0)return P;let Q=0,ee=Z.length-1,re=-1;for(;Q<=ee;){const ce=Q+ee>>1;Z[ce].at<=N?(re=ce,Q=ce+1):ee=ce-1}if(re<0)return P;const ie=[];for(let ce=Z[re].row;ce;ce=ce.parent)ie.push(ce);return ie.reverse(),ie}unnumberedRowCount(N){this.#_();const Z=this.#I;if(!Z.length||!Number.isInteger(N)||N<0)return 0;let Q=0,ee=Z.length-1,re=-1;for(;Q<=ee;){const ie=Q+ee>>1;Z[ie].at<=N?(re=ie,Q=ie+1):ee=ie-1}return re+1}moveRow(N,Z){if(this.#r)return U("source.moveRow.dropped","rows.move() is not supported under ingest.dropSourceRows: the source objects have been released and the store cannot reorder its columns in place. Enable retainSource (leave dropSourceRows off) to reorder rows."),!1;const Q=this.#n;if(!Number.isInteger(N)||!Number.isInteger(Z))return!1;let ee=0;for(let ce=0;ce<Q.length;ce++)Q[ce]!==void 0&&ee++;if(N<0||N>=ee)return!1;const re=Math.max(0,Math.min(ee-1,Z));if(re===N)return!1;if(ee!==Q.length){let ce=0;for(let ve=0;ve<Q.length;ve++)Q[ve]!==void 0&&(Q[ce++]=Q[ve]);Q.length=ce}const[ie]=Q.splice(N,1);return Q.splice(re,0,ie),this.#c++,this.#u++,this.#p=null,this.#h.clear(),this.#L.clear(),this.#lt(),this.#a.invalidate(),this.#q=null,this.invalidate("filter"),this.#bt("rows:changed",{companion:!0,added:0,updated:0,removed:0,moved:1}),!0}reload(N){this.#ue(),this.#c++,this.#u++,this.#p=null,this.#L.clear(),this.#h.clear(),this.#lt(),this.#a.invalidate(),this.invalidate("filter"),this.#bt("model:changed",{reason:"reload"})}destroy(){this.#ue(),this.#h.clear(),this.#L.clear(),this.#p=null,this.#B=[],this.#Y=null,this.#q=null,this.#lt();for(const N of K)this.#l.set(N,{key:null,result:null,id:0,computed:!1})}#ie(N){const Z=this.#e.sortPending;H(Z)&&Z(N)}#ue(){this.#b.has("sort")&&this.#ie(!1);for(const{controller:N}of this.#b.values())try{N.abort()}catch{}this.#b.clear()}setRows(N){this.#n=N||[],this.#r=!1,this.#c++,this.#u++,this.#p=null,this.#L.clear(),this.#h.clear(),this.#lt(),this.#a.invalidate(),this.invalidate("filter")}notePriorRows(N){this.#s=N||null}releaseSource(){this.#r=!0,this.#n=[],this.#p=null,this.#h.clear(),this.#L.clear(),this.#a.invalidate()}data(){if(!this.#r)return this.#n;const N=this.#e.store;if(!N||!H(N.source))return this.#n;const Z=N.physical||0,Q=new Array(Z);for(let ee=0;ee<Z;ee++)Q[ee]=N.live&&!N.live(ee)?void 0:N.source(ee);return Q}#Me(){const N=this.#H("detail",null);return!N||!H(N.isOpen)||N.inline===!1?null:N}#fe(){const N=(this.#e.config||{}).tree;return this.#K!==N&&(this.#K=N,this.#G=w(N,{dataAt:Z=>this.#Je(Z),keyOf:Z=>this.#i.keyOf(this.#Je(Z),Z)})),this.#G}#oe(){return(this.#e.config||{}).grandTotalRow==="bottom"}grandTotalRow(){if(!this.#oe())return null;this.#_();const N=this.#m.grand;return N?this.#i.grandTotal(N,this.#te(this.#m.grandLeaves)):null}pivot(){return this.#_(),this.#W}pivotMatrix(){this.#_();const N=this.#m.groupLeaves,Z=(this.#e.compute||{}).pivotMatrix;if(!H(Z))return null;const Q=this.#H("groupBy",[]),ee=this.#H("pivotBy",[]);if(!Q.length&&!ee.length)return U("pivotView.no-dimension","pivotView is on but the grid has no pivot dimension, so there is no matrix to draw. Put a column on the pivot (its `pivot` setting, or `pivotBy` in the query) for the columns across the top, and group by a column for the rows down the side."),null;const re=this.#Ke().map(ce=>({colId:ce.id,handle:this.#a.handle(ce.id),fn:k(ce,"group")})).filter(ce=>ce.handle&&ce.fn),ie=this.#e.config||{};return Z({rowHandles:Q.map(ce=>this.#a.handle(ce)).filter(Boolean),columnHandles:ee.map(ce=>this.#a.handle(ce)).filter(Boolean),measures:re,leaves:N||new Uint32Array(0),opts:{locale:ie.locale,separator:(ie.pivot||{}).separator,maxColumns:(ie.pivot||{}).maxColumns}})}keysForLeaves(N){const Z=[];if(!N)return Z;for(let Q=0;Q<N.length;Q++){const ee=this.#ce(N[Q]);ee&&ee.key!=null&&Z.push(String(ee.key))}return Z}leavesOf(N){this.#_();const Z=this.#l.get("group"),Q=Z&&Z.result;if(!Q||!Q.nodes)return[];const ee=Q.nodes.get(N);if(!ee)return[];const re=[],ie=ce=>{const ve=ce.row&&ce.row.children;if(ve&&ve.length){for(const he of ve){const ye=Q.nodes.get(he.key);ye&&ie(ye)}return}if(ce.leaves)for(let he=0;he<ce.leaves.length;he++)re.push(this.#ce(ce.leaves[he]))};return ie(ee),re}#Ue(N){return typeof N=="string"?N:this.#xe(N)}#xe(N){try{return this.#i.keyOf(N,-1)}catch{return"(unkeyed)"}}#Pe(N){if(typeof N=="string")return this.#ae(N);if(this.#i.keyed){const Q=this.#i.keyOf(N,-1),ee=this.#ae(Q);if(ee!==void 0)return ee}if(this.#r)return;const Z=this.#n.indexOf(N);return Z>=0?Z:void 0}#ae(N){return this.#p||this.#Ae(),this.#p.get(N)}#Ae(){this.#p=new Map;const N=this.#j(),Z=this.#e.store,Q=Z&&H(Z.live)?ee=>Z.live(ee):null;for(let ee=0;ee<N;ee++){if(Q&&!Q(ee))continue;const re=this.#Je(ee);re!==void 0&&this.#p.set(this.#i.keyOf(re,ee),ee)}}#le(N,Z){const Q=[];for(const ee of this.#V())this.#_e(ee)&&this.#Z(ee,N,Z,new Set)&&Q.push(ee);return Q}#Z(N,Z,Q,ee){if(ee.has(N))return!1;ee.add(N);const re=this.#_e(N);if(!re)return!1;const ie=re.value&&re.value.deps;return Array.isArray(ie)&&ie.length?ie.some(ce=>this.#Z(String(ce),Z,Q,ee)):H(re.getValue)?!Object.is(re.getValue(Z),re.getValue(Q)):!1}#V(){const N=new Set;for(const Q of this.#H("sort",[]))N.add(Q.col);for(const Q of this.#H("groupBy",[]))N.add(Q);const Z=Q=>{if(Q){if(Array.isArray(Q.conditions)){Q.conditions.forEach(Z);return}Q.col&&N.add(Q.col)}};return Z(this.#H("filters",null)),[...N]}#ne(N){if(!N.size)return!1;if(this.#H("quick",""))return!0;for(const Z of this.#V())if(N.has(Z))return!0;return!1}#_(){if(!this.#o){this.#o=!0;try{this.#Ee()}finally{this.#o=!1}}}pipelineRunning(){return this.#o}#Ee(){const N=this.#de("filter",()=>this.#$(),()=>this.#We()),Z=this.#re(N),Q=this.#de("group",()=>this.#F(),()=>this.#Fe(Z)),ee=this.#de("total",()=>this.#ke(),()=>this.#qe(Q));this.#de("pivot",()=>this.#ee(),()=>this.#Ge(Q)),this.#de("flatten",()=>this.#Le(),()=>this.#kt(Q)),this.#ye(Q,ee)}#re(N){const Z=this.#l.get("sort"),Q=this.#U();if(Z.computed&&Z.key===Q&&!this.#b.has("sort"))return Z.result;const ee=this.#b.get("sort");return ee&&ee.key===Q?Z.result:Z.result&&this.#Te(N)?(this.#we(N,Q),Z.result):this.#de("sort",()=>Q,()=>this.#k(N))}#pe(){if(this.#y===null){const N=this.#e.pipelineWorker,Z=H(N)?N():null;this.#y=Z||!1}return this.#y||null}#be(){const N=this.#H("sort",[]);if(!Array.isArray(N)||!N.length)return null;const Z=(this.#e.config||{}).locale,Q=[],ee=[];for(const re of N){const ie=this.#_e(re.col);if(ie&&ie.running)continue;if(ie&&ie.value&&H(ie.value.compare))return null;const ce=this.#a.handle(re.col);if(!ce)return null;Q.push({col:re.col,descending:re.dir==="desc",nullsFirst:!!re.nullsFirst,locale:Z}),ee.push(ce)}return Q.length?{entries:Q,handles:ee,locale:Z}:null}#Te(N){if(this.#he())return!1;const Z=this.#pe();if(!Z)return!1;const Q=Number(Z.threshold);return Number.isFinite(Q)&&N.length<Q?!1:!!this.#be()}#we(N,Z){const Q=this.#pe(),ee=Q&&this.#be();if(!ee){this.#de("sort",()=>Z,()=>this.#k(N));return}const re=new AbortController;this.#b.set("sort",{key:Z,controller:re});const ie=ee.entries.length===1?Q.sortColumn(ee.handles[0],N,{descending:ee.entries[0].descending,nullsFirst:ee.entries[0].nullsFirst,locale:ee.locale,signal:re.signal,key:"sort"}):Q.sortMulti(ee.handles,ee.entries.map((ce,ve)=>({...ce,handle:ee.handles[ve]})),N,{signal:re.signal,key:"sort"});if(!j(ie)){this.#b.delete("sort"),this.#de("sort",()=>Z,()=>ie),this.#ie(!1);return}this.#ie(!0),ie.then(ce=>this.#ve(Z,ce),ce=>this.#Oe("sort",Z,ce))}#ve(N,Z){const Q=this.#b.get("sort");if(!(!Q||Q.key!==N)){if(this.#U()!==N){this.#b.delete("sort"),this.#ie(!1);return}this.#b.delete("sort"),this.#de("sort",()=>N,()=>Z),this.#q=null,this.#_(),this.#bt("model:changed",{reason:X[0]}),this.#ie(!1)}}#Oe(N,Z,Q){const ee=this.#b.get(N);if(!(!ee||ee.key!==Z)){if(this.#b.delete(N),Q&&Q.name==="AbortError"){N==="sort"&&this.#ie(!1);return}if(N==="sort"&&this.#U()===Z){const re=this.#de("filter",()=>this.#$(),()=>this.#We());this.#de("sort",()=>Z,()=>this.#k(re)),this.#q=null,this.#_(),U("source.pipeline.sort","off-thread sort failed; recomputed on the main thread.",Q),this.#bt("model:changed",{reason:X[1]})}N==="sort"&&this.#ie(!1)}}#ye(N,Z){const Q=N&&N.leaves?N.leaves.length:this.#m.slots.length;this.#m.matchCount=Q,this.#m.grand=Z&&Z.grand||null,this.#m.grandLeaves=N&&N.leaves?N.leaves.length:0,this.#m.groupLeaves=N&&N.leaves?N.leaves:null}#de(N,Z,Q){const ee=this.#l.get(N),re=Z();return ee.computed&&ee.key===re||(ee.result=Q(),ee.key=re,ee.computed=!0,ee.id++,N==="flatten"&&(this.#q=null)),ee.result}#Q(N){return this.#l.get(N).id}#$(){const N=(this.#e.config||{}).hostFilter,Z=N&&H(N.active)&&N.active()?1:0,Q=this.#H("where",null),ee=Q?Q.version:0,re=this.#st("filter.sig",`${this.#Ot()}`,()=>h({filters:this.#H("filters",null),quick:this.#H("quick",""),quickMode:this.#H("quickMode","contains")}));return`${this.#u}|${re}|${Z}|${ee}`}#U(){const N=this.#he();return`${this.#Q("filter")}|${JSON.stringify(this.#H("sort",[]))}`+(N?`|manual:${N.version}`:"")}#he(){const N=this.#H("rowOrder",null);return N&&Array.isArray(N.keys)?N:null}#se(N,Z){this.#p||this.#Ae();const Q=this.#p,ee=this.#j(),re=Z.keys.length,ie=new Float64Array(ee);for(let ce=0;ce<ee;ce++)ie[ce]=re+ce;for(let ce=0;ce<re;ce++){const ve=Q.get(Z.keys[ce]);ve!==void 0&&(ie[ve]=ce)}return Uint32Array.from(N).sort((ce,ve)=>ie[ce]-ie[ve])}orderedKeys(){this.#p||this.#Ae();const N=this.#p,Z=new Map;for(const[ce,ve]of N)Z.set(ve,ce);const Q=Uint32Array.from([...Z.keys()]).sort(),ee=this.#he(),re=ee?this.#se(Q,ee):this.#k(Q),ie=new Array(re.length);for(let ce=0;ce<re.length;ce++)ie[ce]=Z.get(re[ce]);return ie}#F(){const N=this.#H("pivotBy",[]).length>0?"p":"u";return`${this.#Q("sort")}|${JSON.stringify(this.#H("groupBy",[]))}|${N}`}#ke(){const N=this.#rt()?"f":"a",Z=(this.#e.config||{}).totalOnlyChangedColumns?"n":"w";return`${this.#Q("group")}|${JSON.stringify(this.#H("totals",[]))}|${N}${Z}|${this.#c}`}#ee(){return`${this.#Q("group")}|${JSON.stringify(this.#H("pivotBy",[]))}`}#Le(){const Z=this.#je()||!this.#oe()?this.#Q("total"):"x",Q=`${this.#Ot()}`,ee=this.#st("flatten.keys",Q,()=>{const ie=this.#H("expanded",null);return ie?[...ie].sort().join(""):"*"}),re=this.#st("flatten.detail",Q,()=>{const ie=this.#H("detail",null);return ie&&H(ie.signature)?ie.signature():""});return`${Z}|${this.#Q("pivot")}|${ee}|${re}`}#je(){const N=this.#H("groupBy",[]);return Array.isArray(N)&&N.length>0}stageState(){const N=[];for(const[Z,Q]of this.#l){const ee=Q.result;N.push({stage:Z,materialised:!!Q.computed,bytes:ee&&typeof ee.byteLength=="number"?ee.byteLength:null,rows:ee&&typeof ee.length=="number"?ee.length:null,rebuilds:Q.id})}return N}facetIndices(N){return this.#We(N||null)}facetRows(N){const Z=this.facetIndices(N),Q=[];for(let ee=0;ee<Z.length;ee++){const re=this.#ce(Z[ee]);re&&Q.push(re)}return Q}invalidateRows(){this.#h.clear(),this.#L.clear(),this.#q=null}invalidateHandles(){this.#a.invalidate()}rows(){return this.#n}unfilteredIndices(){return this.#et()}filteredIndices(){const N=this.#l.get("filter");if(N&&N.computed&&N.key===this.#$())return N.result||this.#et();this.#_();const Z=this.#l.get("filter");return(Z&&Z.computed?Z.result:null)||this.#et()}unfilteredRows(){const N=this.#et(),Z=[];for(let Q=0;Q<N.length;Q++){const ee=this.#ce(N[Q]);ee&&Z.push(ee)}return Z}#We(N=null){const Z=this.#et(),Q=this.#H("filters",null),ee=N?this.#ft("pruneColumn")(Q,N):Q,re=this.#mt(ee),ie=String(this.#H("quick","")||"").trim().toLowerCase(),ce=ie?D(ie,String(this.#H("quickMode","contains")||"contains")):null,ve=(this.#e.config||{}).hostFilter,he=!!(ve&&H(ve.active)&&ve.active()),ye=this.#H("where",null),Oe=!!(ye&&ye.active);if(!re&&!ie&&!he&&!Oe)return Z;let Le=null;re&&(Le=this.#ft("evaluateFilters")(re,{handle:pe=>this.#a.handle(pe),count:this.#j(),pool:this.#e.pool,locale:(this.#e.config||{}).locale,itemwise:pe=>x(this.#_e(pe))}));const fe=new Uint32Array(Z.length);let ae=0;for(let ke=0;ke<Z.length;ke++){const pe=Z[ke];if(!(Le&&!Le[pe])&&!(ce&&!this.#Ie(pe,ce))){if(he||Oe){const ue=this.#ce(pe);if(he&&!ve.passes(ue)||Oe&&!ye.passes(ue.data,ue.key))continue}fe[ae++]=pe}}if(Le){const ke=(this.#e.compute||{}).releaseMask;H(ke)&&ke({pool:this.#e.pool},Le)}return fe.subarray(0,ae)}handleFor(N){return this.#a.handle(N)}#k(N){const Z=this.#he();if(Z)return this.#se(N,Z);const Q=this.#H("sort",[]).filter(ie=>{const ce=this.#_e(ie.col);return!ce||!ce.running?!0:(U(`source.sort.running.${ie.col}`,`sort ignores "${ie.col}": a running total is a function of the sort order, so it cannot also decide it. Sort by the column it runs over instead.`),!1)});if(!Q.length)return N;const ee=(this.#e.config||{}).locale;if(Q.length===1){const ie=Q[0],ce=this.#a.handle(ie.col);if(!ce)return U(`source.sort.${ie.col}`,`sort ignores unknown column "${ie.col}".`),N;const ve=this.#_e(ie.col);return this.#ft("sortColumn")(ce,N,{descending:ie.dir==="desc",nullsFirst:ie.nullsFirst,locale:ee,compare:C(ve)})}const re=[];for(const ie of Q){const ce=this.#a.handle(ie.col);if(!ce){U(`source.sort.${ie.col}`,`sort ignores unknown column "${ie.col}".`);continue}re.push({handle:ce,descending:ie.dir==="desc",nullsFirst:ie.nullsFirst,locale:ee,compare:C(this.#_e(ie.col))})}return re.length?this.#ft("sortMulti")(re.map(ie=>ie.handle),re,N):N}#Fe(N){const Z=this.#H("groupBy",[]),Q=this.#fe();if(Q&&!Z.length){const ke=m(N,Q);return this.#R=S(ke.roots,Q.declaresChildren),{roots:null,leaves:N,nodes:new Map,tree:ke}}if(this.#R=null,Q&&Z.length&&U("tree.grouped","grouping is active on a grid configured with `tree`; the grouping wins and the hierarchy is not shown."),!Z.length)return{roots:null,leaves:N,nodes:new Map};const ee=(this.#e.config||{}).timeZone,re=[],ie=[];let ce=!1;for(const ke of Z){const pe=this.#a.handle(ke);if(!pe){U(`source.group.${ke}`,`grouping ignores unknown column "${ke}".`);continue}re.push(pe);const ue=this.#_e(ke),we=ue&&ue.dataType;if(we&&H(we.groupProjector)){const Te=ue.typeOptions&&ue.typeOptions.timeZone||ee||void 0,Ne=we.groupProjector(ue,Te);ie.push(Ne||null),Ne&&(ce=!0)}else ie.push(null)}if(!re.length)return{roots:null,leaves:N,nodes:new Map};const{keys:ve,buckets:he}=this.#ft("groupByColumns")(re,N,{locale:(this.#e.config||{}).locale,project:ce?ie:void 0}),ye=this.#H("pivotBy",[]).length>0,Oe=[],Le=new Map;for(let ke=0;ke<he.length;ke++){const pe=ve[ke];let ue=null;const we=[];for(let Te=0;Te<pe.length;Te++){we.push(g(pe[Te]));const Ne=c(we),_e=Te===pe.length-1;let $e=Le.get(Ne);if(!$e){const je=this.#i.group({path:[...we],column:Z[Te],value:pe[Te],level:Te,parent:ue,expanded:ye&&_e?!1:this.#gt(Ne,{key:Ne,column:Z[Te],value:pe[Te],level:Te,path:[...we]}),hasChildren:!(ye&&_e)});$e={row:je,leaves:null},Le.set(Ne,$e),ue?ue.children.push(je):Oe.push(je)}$e.row.leafCount+=he[ke].length,Te===pe.length-1&&($e.leaves=he[ke]),ue=$e.row}}const fe=this.#H("sort",[])||[],ae=(ke,pe)=>{if(!ke||ke.length<2){if(ke)for(const Ne of ke)ae(Ne.children,pe+1);return}const ue=Z[pe],we=fe.find(Ne=>Ne.col===ue),Te=we&&we.dir==="desc"?-1:1;ke.sort((Ne,_e)=>Te*Y(Ne.groupValue,_e.groupValue));for(const Ne of ke)ae(Ne.children,pe+1)};return ae(Oe,0),{roots:Oe,leaves:N,nodes:Le,keys:ve,buckets:he}}#Ye(N,Z){const Q=new Map,ee=new Map,re=ie=>{const ce=ie.physical>=0?[ie.physical]:[];for(const ve of ie.children)ce.push(...re(ve));if(ie.children.length){const ve=this.#Xe(Z,Uint32Array.from(ce),null);ie.physical>=0?Q.set(ie.physical,ve):ee.set(ie.key,ve)}return ce};for(const ie of N.roots)re(ie);return{byPhysical:Q,byKey:ee}}#qe(N){const Z=this.#Ke();if(!Z.length)return this.#E=null,this.#T=null,{grand:null};const Q={id:this.#Q("group"),columns:Z.map(fe=>fe.id).join("")},ee=this.#E&&this.#E.id===Q.id&&this.#E.columns===Q.columns,re=this.#at()&&ee?this.#P:null,ie=re?Z.filter(fe=>re.has(fe.id)):Z,ce=ee?this.#T:null,ve=this.#rt()?null:this.#Tt(),he=this.#Ce(Z),ye=fe=>{const ae=N.nodes.get(fe.key);let ke=ae&&ae.leaves?ae.leaves:null;if(fe.children&&fe.children.length){const we=fe.children.map(ye);let Te=0;for(const $e of we)Te+=$e.length;const Ne=new Uint32Array(Te);let _e=0;for(const $e of we)Ne.set($e,_e),_e+=$e.length;ke=Ne}ke=ke||new Uint32Array(0);const pe=ve?ve.get(fe.key)||T:ke,ue=this.#Ze(fe,re?ie:Z,pe,he);return fe.totals=re?{...fe.totals,...ue}:ue,ke};if(N.roots&&ie.length)for(const fe of N.roots)ye(fe);if(this.#D=N.tree?this.#Ye(N.tree,Z):null,this.#E=Q,this.#P=this.#at()?new Set:null,!(this.#e.config||{}).grandTotalRow)return this.#A.length=0,this.#T=null,{grand:null};const Le=ve?this.#it():N.leaves;return this.#T=this.#Se(Z,Le,re,ce),{grand:this.#T}}#Se(N,Z,Q,ee){const re={},ie=this.#Q("group");ie!==this.#w&&(this.#ct(),this.#w=ie);const ce=this.#A;this.#A=[];for(const ve of N){if(!E(ve))continue;const he=this.#a.handle(ve.id);if(!he)continue;const ye=k(ve,"grand");if(!p(ye,he)){if(Q&&!Q.has(ve.id)&&ee&&ve.id in ee){re[ve.id]=ee[ve.id];continue}re[ve.id]=this.#Xe([ve],Z,null,"grand")[ve.id];continue}let Oe=this.#S.get(ve.id);if((!Oe||Oe.fn!==ye)&&(Oe=new n(ye),this.#S.set(ve.id,Oe)),Oe.valid){let Le=!0;for(const fe of ce)if(fe.colId===ve.id&&!Oe.update(fe.before,fe.after)){Le=!1;break}if(Le){re[ve.id]=Oe.value();continue}Oe.invalidate()}Oe.seedColumn(he.values,i(he),Z),re[ve.id]=Oe.valid?Oe.value():this.#Xe([ve],Z,null,"grand")[ve.id]}return re}#Ce(N){const Z=this.#Q("group");Z!==this.#C&&(this.#v.clear(),this.#C=Z);const Q=new Map;for(const re of N){if(!E(re))continue;const ie=this.#a.handle(re.id),ce=k(re,"group");p(ce,ie)&&Q.set(re.id,{fn:ce})}if(!Q.size)return this.#O.length=0,Q;const ee=this.#O;this.#O=[];for(const re of ee){const{beforeKeys:ie,afterKeys:ce,colDeltas:ve}=re,he=ie.length?new Set(ie):null,ye=ce.length?new Set(ce):null;for(const{colId:Oe,before:Le,after:fe}of ve)if(Q.has(Oe)){for(const ae of ie)ye&&ye.has(ae)||this.#dt(ae,Oe,Le,null);for(const ae of ce)he&&he.has(ae)||this.#dt(ae,Oe,null,fe);for(const ae of ie)ye&&!ye.has(ae)||this.#dt(ae,Oe,Le,fe)}}return Q}#dt(N,Z,Q,ee){const re=this.#v.get(N),ie=re&&re.get(Z);!ie||!ie.valid||ie.update(Q,ee)||ie.invalidate()}#Ze(N,Z,Q,ee){if(!ee||!ee.size)return this.#Xe(Z,Q,N);const re={};let ie=null,ce=this.#v.get(N.key);for(const ve of Z){const he=ee.get(ve.id);if(!he){(ie||(ie=[])).push(ve);continue}const ye=this.#a.handle(ve.id);if(!ye)continue;ce||(ce=new Map,this.#v.set(N.key,ce));let Oe=ce.get(ve.id);if((!Oe||Oe.fn!==he.fn)&&(Oe=new n(he.fn),ce.set(ve.id,Oe)),Oe.valid||Oe.seedColumn(ye.values,i(ye),Q),Oe.valid){re[ve.id]=Oe.value();continue}(ie||(ie=[])).push(ve)}return ie&&Object.assign(re,this.#Xe(ie,Q,N)),re}#Qe(N,Z,Q,ee){const re=!this.#rt()||this.#Et(Z);for(const ie of N){const ce=ie.getValue;if(!H(ce))continue;const ve=ce(Q),he=ce(ee);Object.is(ve,he)||(this.#P&&this.#P.add(ie.id),re&&this.#S.has(ie.id)&&this.#A.push({colId:ie.id,before:ve,after:he}))}}#ht(){const N=this.#H("groupBy",[]),Z=[];for(const Q of N){const ee=this.#_e(Q);ee&&Z.push(ee)}return Z}#pt(N,Z){const Q=new Array(N.length);for(let ee=0;ee<N.length;ee++){const re=N[ee].getValue;Q[ee]=g(H(re)?re(Z):void 0)}return Q}#Ve(N,Z,Q,ee,re){if(this.#rt()&&!this.#Et(Q))return;const ie=o(this.#pt(N,ee)),ce=o(this.#pt(N,re)),ve=ie.length!==ce.length||ie.some((ye,Oe)=>ye!==ce[Oe]),he=[];for(const ye of Z){const Oe=ye.getValue;if(!H(Oe))continue;const Le=Oe(ee),fe=Oe(re);!ve&&Object.is(Le,fe)||he.push({colId:ye.id,before:Le,after:fe})}!he.length&&!ve||this.#O.push({beforeKeys:ie,afterKeys:ce,colDeltas:he})}#Et(N){const Z=this.#l.get("filter"),Q=Z&&Z.computed?Z.result:null;if(!Q)return!0;let ee=0,re=Q.length-1;for(;ee<=re;){const ie=ee+re>>1,ce=Q[ie];if(ce===N)return!0;ce<N?ee=ie+1:re=ie-1}return!1}#rt(){return(this.#e.config||{}).totalFilteredOnly!==!1}#te(N){return this.#rt()?N:this.#it().length}#it(){return(!this.#M||this.#M.version!==this.#u)&&(this.#M={version:this.#u,indices:this.#et()}),this.#M.indices}#Tt(){const N=this.#H("groupBy",[]),Z=`${this.#u}|${JSON.stringify(N)}`;if(this.#N&&this.#N.key===Z)return this.#N.map;const Q=new Map,ee=[];for(const re of N){const ie=this.#a.handle(re);ie&&ee.push(ie)}if(ee.length){const re=this.#it(),{keys:ie,buckets:ce}=this.#ft("groupByColumns")(ee,re,{locale:(this.#e.config||{}).locale}),ve=new Map;for(let he=0;he<ce.length;he++){const ye=ie[he],Oe=[];for(let Le=0;Le<ye.length;Le++){Oe.push(g(ye[Le]));const fe=c(Oe);let ae=ve.get(fe);ae||(ae=[],ve.set(fe,ae));for(let ke=0;ke<ce[he].length;ke++)ae.push(ce[he][ke])}}for(const[he,ye]of ve)Q.set(he,Uint32Array.from(ye))}return this.#N={key:Z,map:Q},Q}#at(){return!!(this.#e.config||{}).totalOnlyChangedColumns}#lt(){this.#ct(),this.#vt(),this.#P=null,this.#E=null,this.#T=null}#ct(){this.#S.clear(),this.#A.length=0,this.#w=-1}#vt(){this.#v.clear(),this.#O.length=0,this.#C=-1}#Ge(N){const Z=this.#H("pivotBy",[]);if(!Z.length)return this.#W=null,null;const Q=(this.#e.compute||{}).pivot;if(!H(Q))return U("source.pivot.kernel","pivot requested but ctx.compute.pivot is not available; showing unpivoted rows."),this.#W=null,null;const ee=Z.map(ie=>this.#a.handle(ie)).filter(Boolean),re=this.#Ke();return this.#W=Q(ee,N.leaves,{groups:N.keys&&N.buckets?{keys:N.keys,buckets:N.buckets}:null,totals:re.map(ie=>ie.id),handle:ie=>this.#a.handle(ie),totalOf:ie=>k(re.find(ce=>ce.id===ie),"group"),separator:((this.#e.config||{}).pivot||{}).separator,maxColumns:((this.#e.config||{}).pivot||{}).maxColumns})||null,this.#W}#kt(N){const Z=this.#l.get("total").result,Q=!!(this.#e.config||{}).groupFooter,ee=this.#Me();if(N.tree)return this.#Re(N,Z,ee);if(!N.roots&&!ee){if(Z&&Z.grand&&!this.#oe()){const ye=this.#i.grandTotal(Z.grand,this.#te(N.leaves.length));if(this.#Y===N.leaves&&Array.isArray(this.#B))this.#B[this.#B.length-1]=ye;else{const Oe=Array.from(N.leaves);Oe.push(ye),this.#B=Oe,this.#Y=N.leaves}this.#I=[{at:this.#B.length-1}]}else this.#Y=null,this.#B=N.leaves,this.#I=P;return this.#z=P,this.#B}const re=[],ie=[],ce=[],ve=ye=>{if(re.push(ye),!ee)return;const Oe=this.#ce(ye);!Oe||!ee.isOpen(Oe.key)||(Oe.master=!0,Oe.expanded=!0,ce.push({at:re.length}),re.push(this.#i.detail(Oe,ee.heightOf(Oe))))};if(!N.roots){for(let ye=0;ye<N.leaves.length;ye++)ve(N.leaves[ye]);return Z&&Z.grand&&!this.#oe()&&(ce.push({at:re.length}),re.push(this.#i.grandTotal(Z.grand,this.#te(N.leaves.length)))),this.#Y=null,this.#z=P,this.#I=ce.length?ce:P,this.#B=re,re}const he=(ye,Oe,Le)=>{if(ye.expanded=ye.hasChildren===!1?!1:this.#gt(ye.key,{key:ye.key,column:ye.groupColumn,value:ye.groupValue,level:ye.level,path:ye.groupPath}),ye.posinset=Oe+1,ye.setsize=Le,ie.push({at:re.length,row:ye}),ce.push({at:re.length}),re.push(ye),!!ye.expanded){if(ye.children&&ye.children.length)for(let fe=0;fe<ye.children.length;fe++)he(ye.children[fe],fe,ye.children.length);else{const fe=N.nodes.get(ye.key),ae=fe&&fe.leaves?fe.leaves:null;if(ae)for(let ke=0;ke<ae.length;ke++)ve(ae[ke])}Q&&ye.totals&&(ce.push({at:re.length}),re.push(this.#i.footer(ye)))}};for(let ye=0;ye<N.roots.length;ye++)he(N.roots[ye],ye,N.roots.length);return Z&&Z.grand&&!this.#oe()&&(ce.push({at:re.length}),re.push(this.#i.grandTotal(Z.grand,this.#te(N.leaves.length)))),this.#z=ie,this.#I=ce,this.#B=re,re}#et(){const N=this.#e.store;if(N&&H(N.liveIndices))return N.liveIndices();const Z=new Uint32Array(this.#n.length);let Q=0;for(let ee=0;ee<this.#n.length;ee++)this.#n[ee]!==void 0&&(Z[Q++]=ee);return Z.subarray(0,Q)}#j(){const N=this.#e.store;return N&&typeof N.physical=="number"?N.physical:this.#n.length}#Je(N){const Z=this.#e.store;return Z&&H(Z.source)?Z.source(N):this.#n[N]}#He(N,Z=N){const Q=this.#B[N];if(typeof Q!="number")return Q.index=Z,Q;const ee=this.#ce(Q);return ee.index=Z,ee}#ce(N){let Z=this.#h.get(N);Z||(Z=this.#i.leaf(this.#Je(N),N),this.#h.set(N,Z));const Q=this.#R?this.#R.get(N):null;if(Q){Z.level=Q.level,Z.posinset=Q.posinset,Z.setsize=Q.setsize,Z.hasChildren=Q.hasChildren,Z.expanded=Q.hasChildren&&!Q.lazy&&this.#gt(Z.key);const ee=this.#D?this.#D.byPhysical.get(N):void 0;ee?Z.totals=ee:Z.totals&&(Z.totals=null)}else Z.hasChildren&&(Z.level=0,Z.hasChildren=!1,Z.expanded=!1,Z.posinset=void 0,Z.setsize=void 0);return Z}#Re(N,Z,Q){const ee=[],re=[],ie=ve=>{if(ve.leafCount!==void 0)return ve.leafCount;let he=ve.physical>=0?1:0;for(const ye of ve.children)he+=ie(ye);return ve.leafCount=he,he},ce=ve=>{const he=this.#gt(ve.key);if(ve.physical>=0){if(ee.push(ve.physical),Q&&Q.isOpen(this.#ce(ve.physical).key)){const ye=this.#ce(ve.physical);re.push({at:ee.length}),ee.push(this.#i.detail(ye,Q.heightOf(ye)))}}else ee.push(this.#i.group({path:[ve.key],column:null,value:ve.value,level:ve.level,parent:null,expanded:he,hasChildren:ve.children.length>0,leafCount:ie(ve),totals:this.#D?this.#D.byKey.get(ve.key):void 0}));if(he)for(const ye of ve.children)ce(ye)};for(const ve of N.tree.roots)ce(ve);return Z&&Z.grand&&!this.#oe()&&(re.push({at:ee.length}),ee.push(this.#i.grandTotal(Z.grand,this.#te(N.leaves.length)))),this.#Y=null,this.#z=P,this.#I=re.length?re:P,this.#B=ee,ee}#$e(){return t(()=>this.count(),N=>this.at(N))}#Ie(N,Z){let Q=this.#L.get(N);if(Q===void 0){const ee=this.#Je(N),re=this.#At(),ie=[],ce=this.#e.columnHidden;for(const ve of re){if(ve.quickFilter===!1||H(ce)&&ce(ve.id))continue;const he=ve.value&&H(ve.value.quickFilterText)?ve.value.quickFilterText({value:void 0,data:ee,row:null,column:ve,colId:ve.id,grid:null,context:this.#H("context",null)}):null,ye=he??(H(ve.formatValue)?ve.formatValue(H(ve.getValue)?ve.getValue(ee):void 0):"");ye!=null&&ye!==""&&ie.push(String(ye))}Q=ie.join(" ").toLowerCase(),this.#L.set(N,Q)}return Z(Q)}#Ke(){const N=this.#H("totals",[]),Z=N&&N.length?new Set(N):null;return this.#At().filter(Q=>Z?Z.has(Q.id):!!(Q.total||Q.groupTotal||Q.grandTotal))}#Xe(N,Z,Q,ee="group"){const re={},ie=(this.#e.compute||{}).total;for(const ce of N){if(!E(ce))continue;const ve=this.#a.handle(ce.id);if(!ve)continue;const he=k(ce,ee);if(he)if(H(he)){const ye=new Array(Z.length);for(let Oe=0;Oe<Z.length;Oe++)ye[Oe]=ve.get(Z[Oe]);re[ce.id]=he(ye,{row:Q,column:ce,grid:this.#e.grid||null,context:this.#H("context",null),valueAt:(Oe,Le)=>{const fe=this.#a.handle(Oe);return fe&&Le>=0&&Le<Z.length?fe.get(Z[Le]):null}})}else H(ie)&&(re[ce.id]=ie(ve,Z,he))}return re}#mt(N){if(!N)return N;const Z=this.#e.config||{},Q={tz:Z.timeZone,weekStartsOn:Z.weekStartsOn};return a(N,ee=>{const re=y(ee,Q),ie=this.#_e(re&&re.col),ce=ie&&ie.type==="datetime";if(re&&re.type)return re.type==="datetime"&&!re.timeZone&&ie?{...re,timeZone:Z.timeZone||void 0}:re;if(ce)return{...re,type:"datetime",timeZone:Z.timeZone||void 0};const ve=ie&&(ie.dataType?.base||ie.type);return ve?{...re,type:ve}:re})}#gt(N,Z){const Q=this.#H("expanded",null);return Q?H(Q.has)?Q.has(N,Z):Array.prototype.includes.call(Q,N):!0}#H(N,Z){if(N==="context"||!H(this.#e.stateVersion))return this.#St(N,Z);const Q=this.#_t(N),ee=this.#f.get(N);if(ee&&ee.version===Q)return ee.value;const re=this.#St(N,Z);return this.#f.set(N,{version:Q,value:re}),re}#St(N,Z){const Q=this.#e.state;if(Q&&H(Q[N])){const ee=Q[N]();return ee??Z}return Z}#Ot(){const N=this.#e.stateVersion;return H(N)?N():0}#ut(){const N=this.#e.columnsVersion,Z=this.#e.permissionsVersion;return`${H(N)?N():0}|${H(Z)?Z():0}`}#_t(N){return N==="totals"?this.#ut():`${this.#Ot()}`}#st(N,Z,Q){if(!H(this.#e.stateVersion))return Q();const ee=this.#d.get(N);if(ee&&ee.version===Z)return ee.key;const re=Q();return this.#d.set(N,{version:Z,key:re}),re}#ft(N){const Z=(this.#e.compute||{})[N];return H(Z)||I(`ctx.compute.${N} is required by the memory source pipeline`),Z}#At(){const N=this.#e.columns;return N&&H(N.all)?N.all():[]}#_e(N){const Z=this.#e.columns;return Z&&H(Z.get)?Z.get(N):void 0}#bt(N,Z){const Q=this.#e.emit;H(Q)&&Q(N,Z)}}}),ze("packages/core/src/source/abort.js",function(e,B){"use strict";Object.defineProperty(e,"SupersededError",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"RequestToken",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"AbortScope",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"createAbortScope",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"isAbortError",{enumerable:!0,get:function(){return I}});class ne extends Error{constructor(H,L="superseded"){super(`[lattice] request ${H?`"${H}" `:""}${L}`),this.name="SupersededError",this.superseded=!0,this.key=H}}class A{#e;constructor(H,L,Y,_){this.#e=H,this.key=L,this.controller=Y,this.signal=Y.signal,this.seq=_}get current(){return!this.signal.aborted&&this.#e.tokenFor(this.key)===this}settle(){this.#e.settle(this)}abort(H){this.signal.aborted||this.controller.abort(new ne(this.key,H)),this.#e.settle(this)}}class V{#e=new Map;#t=0;begin(H="",L="superseded"){const Y=this.#e.get(H);Y&&!Y.signal.aborted&&Y.controller.abort(new ne(H,L));const _=new A(this,H,new AbortController,++this.#t);return this.#e.set(H,_),_}tokenFor(H){return this.#e.get(H)}pending(H=""){const L=this.#e.get(H);return!!L&&!L.signal.aborted}get size(){return this.#e.size}settle(H){this.#e.get(H.key)===H&&this.#e.delete(H.key)}abort(H="",L="superseded"){const Y=this.#e.get(H);Y&&Y.abort(L)}abortAll(H="superseded"){for(const L of[...this.#e.values()])L.abort(H);this.#e.clear()}}function U(){return new V}function I(J){if(!J||typeof J!="object")return!1;const H=J;return H.superseded===!0||H.name==="AbortError"||H.name==="SupersededError"}}),ze("packages/core/src/source/blockcache.js",function(e,B){"use strict";Object.defineProperty(e,"DEFAULT_PAGE_SIZE",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"DEFAULT_MAX_CACHED_PAGES",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"BlockCache",{enumerable:!0,get:function(){return U}});const ne=100,A=32;class V{constructor(J){this.id=J,this.rows=null,this.state="pending",this.token=null,this.error=null}}class U{#e=new Map;#t;#n;#r=0;#s=-1;constructor(J={}){this.#t=Math.max(1,Math.floor(Number(J.pageSize)||ne)),this.#n=Math.max(1,Math.floor(Number(J.maxCachedPages)||A))}get pageSize(){return this.#t}get maxBlocks(){return this.#n}get size(){return this.#e.size}blockOf(J){return Math.floor(J/this.#t)}rangeOf(J){return{start:J*this.#t,end:(J+1)*this.#t}}has(J){return this.#e.has(J)}pending(J){const H=this.#e.get(J);return!!H&&H.state==="pending"}loaded(J){const H=this.#e.get(J);return!!H&&H.state==="loaded"}begin(J,H){let L=this.#e.get(J);return L||(L=new V(J)),L.state="pending",L.token=H,L.error=null,this.#i(J,L),L}fill(J,H){const L=this.#e.get(J)||new V(J);L.rows=H,L.state="loaded",L.token=null,this.#i(J,L)}failed(J,H){const L=this.#e.get(J)||new V(J);L.state="error",L.error=H,L.token=null,this.#i(J,L)}delete(J){return this.#e.delete(J)}rowAt(J){const H=this.blockOf(J),L=this.#e.get(H);if(!(!L||L.state!=="loaded"||!L.rows))return this.#i(H,L),L.rows[J-H*this.#t]}rowLoaded(J){const H=this.blockOf(J),L=this.#e.get(H);return!!L&&L.state==="loaded"&&!!L.rows&&J-H*this.#t<L.rows.length}erroredAt(J){const H=this.#e.get(this.blockOf(J));return!!H&&H.state==="error"}loadedExtent(){let J=0;for(const H of this.#e.values()){if(H.state!=="loaded"||!H.rows)continue;const L=H.id*this.#t+H.rows.length;L>J&&(J=L)}return J}fillOf(J){const H=this.#e.get(J);return H&&H.state==="loaded"&&H.rows?H.rows.length:null}protect(J,H){this.#r=this.blockOf(Math.max(0,J)),this.#s=this.blockOf(Math.max(0,H))}evict(){const J=[];if(this.#e.size<=this.#n)return J;for(const[H,L]of this.#e){if(this.#e.size-J.length<=this.#n)break;H>=this.#r&&H<=this.#s||L.state!=="pending"&&J.push(H)}for(const H of J)this.#e.delete(H);return J}ids(){return[...this.#e.keys()]}clear(){this.#e.clear()}#i(J,H){this.#e.delete(J),this.#e.set(J,H)}}}),ze("packages/core/src/source/pagewindow.js",function(e,B){"use strict";Object.defineProperty(e,"pageWindow",{enumerable:!0,get:function(){return ne}});function ne(A,V,U,I){const J=Math.floor(Number(A)||0);if(J<=0)return null;const H=Math.max(0,Math.floor(Number(V)||0)),L=Math.max(0,Math.floor(Number(U)||0));if(I){const Y=Math.max(1,Math.ceil(L/J)),_=Math.min(H,Y-1),O=_*J;return{page:_,pageSize:J,offset:O,length:Math.max(0,Math.min(J,L-O)),pageCount:Y,total:L}}return{page:H,pageSize:J,offset:H*J,length:J,pageCount:Math.max(H+2,Math.ceil(L/J)),total:null}}}),ze("packages/core/src/source/paged.js",function(e,B){"use strict";Object.defineProperty(e,"HINT_SETTLE_MS",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"createPagedSource",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"PagedSource",{enumerable:!0,get:function(){return h}});const A=B("packages/core/src/internal/lru.js").Lru,U=B("packages/core/src/internal/predicates.js").isFunction,J=B("packages/core/src/internal/warn.js").warnOnce,L=B("packages/core/src/internal/schedule.js").settleDebounce,Y=B("packages/core/src/source/abort.js"),_=Y.createAbortScope,O=Y.isAbortError,v=B("packages/core/src/source/blockcache.js"),b=v.BlockCache,c=v.DEFAULT_PAGE_SIZE,g=v.DEFAULT_MAX_CACHED_PAGES,t=B("packages/core/src/source/rows.js").createRowFactory,s=B("packages/core/src/source/filterwire.js"),l=s.wireFilters,u=s.querySignature,n=s.warnHostFilterNotApplied,r=B("packages/core/src/source/pagewindow.js").pageWindow,i=120;function d(a,y){return new h(a,y)}class h{mode="paged";#e;#t;#n;#r=_();#s;#i;#a=new Map;#l=null;#o=null;#c=!1;#u=0;#f="";#d={start:0,end:0};#h;#p=!1;#m=0;#g="";constructor(y,f){this.#e=y||{mode:"paged"},this.#t=f||{},this.#n=new b({pageSize:this.#e.pageSize||c,maxCachedPages:this.#e.maxCachedPages||g}),this.#s=t(this.#t),this.#i=new A(this.#n.pageSize*4),this.#h=L((m,w)=>this.#w(m,w),i),this.#f=this.#P(),U(this.#e.fetch)||J("source.paged.fetch",'source.mode "paged" requires a fetch function; the grid will stay empty.'),n(this.#t)}count(){const y=this.#y();return y?y.length:this.#b()}#b(){if(this.#C(),this.#l!==null)return this.#l;const y=Math.max(this.#u,this.#n.loadedExtent());return this.#c?y:y+this.#n.pageSize}matchCount(){return this.#b()}totalCount(){return this.#b()}pageInfo(){const y=this.#y();if(!y){const f=this.#b();return{page:0,pageSize:0,total:this.exact()?f:null,pageCount:1,counting:!1}}return{page:y.page,pageSize:y.pageSize,total:y.total,pageCount:y.pageCount,counting:y.total===null&&this.#r.size>0&&this.#u===0&&this.#n.loadedExtent()===0}}#y(){const y=this.#b(),f=r(this.#T("pageSize",0),this.#T("page",0),y,this.exact());if(!f)return this.#g="",null;const m=`${this.#m}:${f.offset}:${f.length}`;if(m!==this.#g&&!this.#p&&(this.#g=m,f.length>0)){const w=f.offset+f.length-1;this.#d={start:f.offset,end:w},this.#w(f.offset,w)}return f}at(y){const f=this.#y();if(f){if(y<0||y>=f.length)return;const m=this.#S(f.offset+y);return m&&(m.index=y),m}return this.#S(y)}#S(y){if(y<0||y>=this.#b())return;const f=this.#i.get(y);if(f&&(f.data!==null||!this.#n.rowLoaded(y)))return f;const m=this.#n.rowAt(y);if(m===void 0){const S=this.#s.skeleton(y,0,this.#n.erroredAt(y));return this.#i.set(y,S),S}const w=this.#s.leaf(m,y);return w.index=y,this.#i.set(y,w),this.#a.set(w.key,y),w}byKey(y){const f=this.#a.get(y);return f===void 0?void 0:this.#S(f)}loaded(y){const f=this.#y();return f?y>=0&&y<f.length&&this.#n.rowLoaded(f.offset+y):this.#n.rowLoaded(y)}loadedCount(){this.#C();let y=0;for(const f of this.#n.ids()){if(!this.#n.loaded(f))continue;const m=this.#n.fillOf(f);typeof m=="number"&&(y+=m)}return y}residentRows(){this.#C();const y=this.#y(),f=y?y.offset:0,m=y?y.offset+y.length:1/0,w=[],S=this.#n.ids().sort((M,X)=>M-X);for(const M of S){if(!this.#n.loaded(M))continue;const{start:X}=this.#n.rangeOf(M),q=this.#n.fillOf(M)||0;for(let K=X;K<X+q;K++){if(K<f||K>=m)continue;const P=this.#i.peek(K);if(P&&P.data!==null&&P.data!==void 0){w.push(P);continue}const k=this.#n.rowAt(K);if(k===void 0)continue;const E=this.#s.leaf(k,K);E.index=K,this.#i.set(K,E),this.#a.set(E.key,K),w.push(E)}}return w}hint(y,f){if(this.#p)return;const m=this.#C();let w=Math.max(0,Math.floor(y)),S=Math.max(w,Math.floor(f));const M=this.#y();if(M){if(M.length===0)return;w=M.offset,S=M.offset+M.length-1}this.#d={start:w,end:S},this.#n.protect(w,S);for(const X of this.#n.evict())this.#v(X);this.#h(w,S),m&&this.#h.flush()}#w(y,f){if(this.#p)return;this.#n.protect(y,f);const m=this.#n.blockOf(y),w=this.#n.blockOf(f);for(let S=m;S<=w&&!(this.#l!==null&&S*this.#n.pageSize>=this.#l);S++)this.#n.has(S)||this.#A(S)}apply(y){const f={added:[],updated:[],removed:[]};if(!y)return f;if(y.update)for(const m of y.update){const w=this.#s.keyOf(m,-1),S=this.#a.get(w);if(S===void 0)continue;const M=this.#s.leaf(m,S);M.index=S,this.#i.set(S,M),f.updated.push(M)}return(y.add&&y.add.length||y.remove&&y.remove.length)&&this.reload(),f}reload(y){this.#O("reload"),this.#h.cancel(),this.hint(this.#d.start,this.#d.end)}destroy(){this.#p=!0,this.#h.cancel(),this.#r.abortAll("destroyed"),this.#n.clear(),this.#i.clear(),this.#a.clear()}exact(){return this.#l!==null||this.#c}pending(){return this.#r.size}async#A(y){if(!U(this.#e.fetch))return;const f=this.#r.begin(`block:${y}`);this.#n.begin(y,f);const{start:m,end:w}=this.#n.rangeOf(y),S=this.#f;try{const M=await this.#e.fetch({range:{start:m,end:w},sort:this.#T("sort",[]),filters:l(this.#T("filters",null),this.#E()),quick:this.#T("quick","")||void 0,context:this.#T("context",null),signal:f.signal});if(!f.current||S!==this.#f||this.#p)return;f.settle();const X=M&&M.rows||[];this.#n.fill(y,X);for(let K=0;K<X.length;K++)this.#i.delete(m+K);const q=M&&typeof M.total=="number"?M.total:M&&typeof M.count=="number"?M.count:null;q!==null?(this.#l=q,this.#c=!0):X.length<this.#n.pageSize?(this.#c=!0,this.#l=m+X.length):this.#u=Math.max(this.#u,m+X.length),this.#M("model:changed",{reason:"page",block:y,from:m,to:m+X.length}),this.#M("rows:changed",{companion:!0,reason:"page",block:y,from:m,to:m+X.length}),this.#l!==null&&this.#l!==this.#o&&(this.#o=this.#l,this.#M("source:total",{total:this.#l,groupPath:[]}))}catch(M){if(f.settle(),O(M))return;this.#n.failed(y,M);for(let X=m;X<w;X++)this.#i.delete(X);this.#M("model:changed",{reason:"page-error",block:y,range:{start:m,end:w}}),this.#M("source:error",{error:M,block:y,range:{start:m,end:w}})}}#v(y){const{start:f,end:m}=this.#n.rangeOf(y);for(let w=f;w<m;w++){const S=this.#i.peek(w);S&&this.#a.delete(S.key),this.#i.delete(w)}}#C(){const y=this.#P();return y===this.#f?!1:(this.#f=y,this.#O("query"),!0)}#O(y){this.#r.abortAll(y),this.#n.clear(),this.#i.clear(),this.#a.clear(),this.#l=null,this.#o=null,this.#c=!1,this.#u=0,this.#m++,this.#M("model:changed",{reason:y})}#P(){return u({filters:this.#T("filters",null),sort:this.#T("sort",[]),quick:this.#T("quick",""),context:this.#T("context",null)})}#E(){const y=this.#t.config||{};return{tz:y.timeZone,weekStartsOn:y.weekStartsOn}}#T(y,f){const m=this.#t.state;if(m&&U(m[y])){const w=m[y]();return w??f}return f}#M(y,f){const m=this.#t.emit;U(m)&&m(y,f)}}}),ze("packages/core/src/source/aggregates.js",function(e,B){"use strict";Object.defineProperty(e,"STAT_PUSHDOWN",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"pushableAggregates",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"fillAggregateSql",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"aggregateP",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"resolveAggregatesConfig",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"routeAggregate",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"resolveAggregatePlan",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"groupKeysPushable",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"pushdownDocRows",{enumerable:!0,get:function(){return _}});const ne=Object.freeze({sum:{pushable:!0,class:"identical",sql:"sum(%c)"},avg:{pushable:!0,class:"identical",sql:"avg(%c)"},min:{pushable:!0,class:"identical",sql:"min(%c)"},max:{pushable:!0,class:"identical",sql:"max(%c)"},count:{pushable:!0,class:"identical",sql:"count(*)"},countValues:{pushable:!0,class:"identical",sql:"count(%c)",blankAware:!0},range:{pushable:!0,class:"identical",sql:"(max(%c) - min(%c))"},variance:{pushable:!0,class:"identical",sql:"var_samp(%c)"},varianceP:{pushable:!0,class:"identical",sql:"var_pop(%c)"},stddev:{pushable:!0,class:"identical",sql:"stddev_samp(%c)"},stddevP:{pushable:!0,class:"identical",sql:"stddev_pop(%c)"},sumSquares:{pushable:!0,class:"identical",sql:"sum(%c * %c)"},median:{pushable:!0,class:"identical",sql:"median(%c)"},percentile:{pushable:!0,class:"identical",sql:"quantile_cont(%c, %p)",parametric:!0},p25:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.25)"},p75:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.75)"},p90:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.9)"},p95:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.95)"},p99:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.99)"},iqr:{pushable:!0,class:"identical",sql:"(quantile_cont(%c, 0.75) - quantile_cont(%c, 0.25))"},mad:{pushable:!0,class:"identical",sql:"mad(%c)"},distinct:{pushable:!0,class:"identical",sql:"count(DISTINCT %c)",blankAware:!0},skewness:{pushable:!0,class:"identical",sql:"skewness(%c)"},kurtosis:{pushable:!0,class:"identical",sql:"kurtosis(%c)"},geomean:{pushable:!0,class:"identical",sql:"exp(avg(ln(%c)))"},harmean:{pushable:!0,class:"identical",sql:"(count(%c) / sum(1.0 / %c))"},entropy:{pushable:!0,class:"identical",sql:"entropy(%c)",blankAware:!0},correlation:{pushable:!0,class:"identical",sql:"corr(%w, %c)",twoColumn:!0},hhi:{pushable:!0,class:"identical",blankAware:!0,sql:"CASE WHEN count(%c)=0 THEN NULL ELSE list_sum(list_transform(map_values(histogram(%c)), lambda v: (v::DOUBLE/count(%c))*(v::DOUBLE/count(%c)))) END"},evenness:{pushable:!0,class:"identical",blankAware:!0,sql:"CASE WHEN count(%c)=0 THEN NULL WHEN count(DISTINCT %c)<2 THEN 1.0 ELSE entropy(%c)/log2(count(DISTINCT %c)) END"},top3Share:{pushable:!0,class:"identical",blankAware:!0,sql:"CASE WHEN count(%c)=0 THEN NULL ELSE list_sum(list_slice(list_sort(map_values(histogram(%c)),'DESC'),1,3))::DOUBLE/count(%c) END"},top10Share:{pushable:!0,class:"identical",blankAware:!0,sql:"CASE WHEN count(%c)=0 THEN NULL ELSE list_sum(list_slice(list_sort(map_values(histogram(%c)),'DESC'),1,10))::DOUBLE/count(%c) END"},gini:{pushable:!0,class:"identical",sql:"CASE WHEN list_min(list(%c) FILTER (WHERE isfinite(%c)))<0 THEN NULL WHEN len(list(%c) FILTER (WHERE isfinite(%c)))=0 THEN NULL WHEN list_sum(list(%c) FILTER (WHERE isfinite(%c)))=0 THEN 0 ELSE 2.0*list_sum(list_transform(list_sort(list(%c) FILTER (WHERE isfinite(%c))), lambda v, i: i*v))/(len(list(%c) FILTER (WHERE isfinite(%c)))*list_sum(list(%c) FILTER (WHERE isfinite(%c))))-(len(list(%c) FILTER (WHERE isfinite(%c)))+1.0)/len(list(%c) FILTER (WHERE isfinite(%c))) END"},trimmedMean:{pushable:!0,class:"identical",sql:"CASE WHEN len(list(%c) FILTER (WHERE isfinite(%c)))=0 THEN NULL ELSE list_avg(list_slice(list_sort(list(%c) FILTER (WHERE isfinite(%c))), floor(len(list(%c) FILTER (WHERE isfinite(%c)))*0.1)::BIGINT+1, len(list(%c) FILTER (WHERE isfinite(%c)))-floor(len(list(%c) FILTER (WHERE isfinite(%c)))*0.1)::BIGINT)) END"},winsorizedMean:{pushable:!0,class:"identical",sql:"CASE WHEN len(list(%c) FILTER (WHERE isfinite(%c)))=0 THEN NULL ELSE list_avg(list_transform(list_sort(list(%c) FILTER (WHERE isfinite(%c))), lambda v: least(list_sort(list(%c) FILTER (WHERE isfinite(%c)))[len(list(%c) FILTER (WHERE isfinite(%c)))-floor(len(list(%c) FILTER (WHERE isfinite(%c)))*0.1)::BIGINT], greatest(list_sort(list(%c) FILTER (WHERE isfinite(%c)))[floor(len(list(%c) FILTER (WHERE isfinite(%c)))*0.1)::BIGINT+1], v)))) END"},robustOutliers:{pushable:!0,class:"identical",sql:"(SELECT CASE WHEN len(d.a)=0 THEN NULL WHEN d.mad=0 THEN NULL ELSE len(list_filter(d.a, lambda v: abs(0.6745*(v-d.med)/d.mad)>3.5)) END FROM (SELECT xs AS a, list_median(xs) AS med, list_median(list_transform(xs, lambda w: abs(w-list_median(xs)))) AS mad FROM (SELECT list(%c) FILTER (WHERE isfinite(%c)) AS xs)) d)"},jarqueBera:{pushable:!0,class:"identical",sql:"CASE WHEN len(list(%c) FILTER (WHERE isfinite(%c)))<8 THEN NULL WHEN list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),2)))=0 THEN NULL ELSE (len(list(%c) FILTER (WHERE isfinite(%c)))/6.0)*(power(list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),3)))/power(list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),2))),1.5),2)+power(list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),4)))/power(list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),2))),2)-3,2)/4.0) END"},weightedAvg:{pushable:!0,class:"identical",twoColumn:!0,sql:"sum(%c*%w) FILTER (WHERE isfinite(%c) AND isfinite(%w))/nullif(sum(%w) FILTER (WHERE isfinite(%c) AND isfinite(%w)),0)"},mode:{pushable:!0,class:"may-differ",sql:"mode(%c)",note:"DuckDB returns a modal value even for an all-distinct column; the grid returns null. Tie-breaking can also differ, and on a text column an empty string counts as a value. Under pushdown you will see a value."},weightedQuantile:{pushable:!1,class:"fallback",note:"No SQL equivalent for the grid's weighted-quantile midpoint convention; always computed client-side (needs a full-dataset pull for a correct figure over a remote source)."}});function A(){const O=new Set;for(const[v,b]of Object.entries(ne))b.pushable&&O.add(v);return O}function V(O,v,b,c="?"){let g=O.split("%c").join(v);return b!==void 0&&(g=g.split("%w").join(b)),g.split("%p").join(c)}function U(O){const v=O&&(O.p!==void 0?O.p:O.params&&O.params.p);return typeof v=="number"&&v>=0&&v<=1?v:void 0}function I(O){const v=O||{},b=v.default==="engine"||v.default==="engine-if-identical"?v.default:"client",c={};if(v.overrides&&typeof v.overrides=="object")for(const[g,o]of Object.entries(v.overrides))(o==="engine"||o==="client")&&(c[g]=o);return{default:b,overrides:c}}function J(O,v){const b=ne[O];if(!b||!b.pushable)return"client";const c=v.overrides[O];return c==="engine"||c==="client"?c:v.default==="client"?"client":v.default==="engine-if-identical"?b.class==="identical"?"engine":"client":"engine"}function H(O,v){const b=I(v),c=[],g=[];for(const o of O||[]){const t=ne[o.fn],s=J(o.fn,b),l={id:o.id,col:o.col,fn:o.fn,class:t?t.class:"fallback"};if(o.weight!==void 0&&(l.weight=o.weight),o.params!==void 0&&(l.params=o.params),t&&t.parametric){const u=U(o);u!==void 0&&(l.p=u)}if(s==="engine"&&t&&t.parametric&&l.p===void 0){g.push({...l,reason:`"${o.fn}" needs \`p\`, a number from 0 to 1`});continue}s==="engine"?c.push(l):(l.reason=t&&!t.pushable?t.note||"the engine cannot express this stat":"client by config",g.push(l))}return{engine:c,client:g,config:b}}const L=/^[A-Za-z_][A-Za-z0-9_$]*$/;function Y(O,v=[]){return(O||[]).every(c=>{if(typeof c=="string")return L.test(c);if(!c||typeof c!="object")return!1;const g=c;return Array.isArray(v)&&v.includes(g.bucket)&&typeof g.col=="string"&&L.test(g.col)&&typeof g.size=="number"&&Number.isFinite(g.size)&&g.size>0})}function _(){return Object.entries(ne).map(([O,v])=>({stat:O,class:v.class,sql:v.sql?V(v.sql,"col",v.twoColumn?"weight":void 0):"",note:v.note||(v.class==="identical"?"Pushes to DuckDB with the same result.":"")}))}}),ze("packages/core/src/source/pushdown.js",function(e,B){"use strict";Object.defineProperty(e,"FOREGROUND_WAIT_MS",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"NO_CAPABILITIES",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"resolveMutate",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"capabilitiesOf",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"splitFilters",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"LEAF_COUNT_ID",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"PIVOT_UNSUPPORTED",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"GROUP_UNSUPPORTED",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"UNGROUPED_LEVEL",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"planQuery",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"applyResidual",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"DEFAULT_WHERE_ROW_LIMIT",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"createPushdownSource",{enumerable:!0,get:function(){return Q}});const A=B("packages/core/src/internal/compare.js").defaultCompare,U=B("packages/core/src/internal/predicates.js").isFunction,J=B("packages/core/src/internal/merge.js").toArray,L=B("packages/core/src/internal/warn.js").warnOnce,Y=B("packages/core/src/source/filterwire.js"),_=Y.isGroup,O=Y.warnWherePageRelative,v=Y.warnWhereOverThreshold,b=Y.wireFilters,c=B("packages/core/src/source/aggregates.js"),g=c.resolveAggregatePlan,o=c.groupKeysPushable,t=c.STAT_PUSHDOWN,s=c.aggregateP,l=c.fillAggregateSql,n=B("packages/core/src/source/abort.js").SupersededError,p=1e3;function r(ee){const re=ee&&ee.signal;if(!re||!re.aborted)return;const ie=re.reason;throw ie instanceof Error?ie:new n("","superseded before it was sent")}const i=Object.freeze({filter:!1,operators:Object.freeze([]),sort:!1,quick:!1,range:!1,total:!1,group:!1,pivot:!1,mutate:!1});function d(ee){if(!ee||typeof ee!="object")return!1;const re=ee.returning==="row"||ee.returning==="key"?ee.returning:"none";return{append:ee.append===!0,update:ee.update===!0,delete:ee.delete===!0,returning:re}}function h(ee,re){if(!ee||typeof re!="string")return;if(!re.includes("."))return ee[re];let ie=ee;for(const ce of re.split(".")){if(ie===null||typeof ie!="object")return;ie=ie[ce]}return ie}function a(ee){if(ee===!0)return!0;if(!ee||typeof ee!="object")return!1;const re=ee;return re.enabled===!1?!1:re.enabled===!0||U(re.commit)}function y(ee){const re={...i,...ee||{}};return re.operators=new Set(re.operators||[]),re.mutate=d(re.mutate),re}function f(ee,re){return!ee||!ee.op||!re.operators.size?!1:re.operators.has(ee.op)}function m(ee,re){if(!ee)return{pushed:null,residual:null};if(!re.filter)return{pushed:null,residual:ee};if(re.filter==="term"){if(_(ee)){const he=ee.conditions||[];if(String(ee.op)!=="and")return{pushed:null,residual:ee};const ye=he.findIndex(Le=>!_(Le)&&f(Le,re));if(ye<0)return{pushed:null,residual:ee};const Oe=he.filter((Le,fe)=>fe!==ye);return{pushed:he[ye],residual:Oe.length?{op:"and",conditions:Oe}:null}}return f(ee,re)?{pushed:ee,residual:null}:{pushed:null,residual:ee}}if(!_(ee))return f(ee,re)?{pushed:ee,residual:null}:{pushed:null,residual:ee};if(String(ee.op)!=="and")return(ee.conditions||[]).every(ye=>_(ye)?m(ye,re).residual===null:f(ye,re))?{pushed:ee,residual:null}:{pushed:null,residual:ee};const ie=[],ce=[];for(const he of ee.conditions||[]){if(_(he)){if(re.filter==="flat"){ce.push(he);continue}const ye=m(he,re);ye.pushed&&ie.push(ye.pushed),ye.residual&&ce.push(ye.residual);continue}(f(he,re)?ie:ce).push(he)}const ve=he=>he.length===0?null:he.length===1?he[0]:{op:"and",conditions:he};return{pushed:ve(ie),residual:ve(ce)}}const w="__lattice_leaves";function S(ee){return ee.aggregates?ee.aggregates instanceof Set?ee.aggregates:new Set(J(ee.aggregates)):new Set}function M(ee){const re=S(ee);return re.size?re.has("count")?ee.filter!=="tree"||!ee.operators||!ee.operators.has("eq")?"the adapter does not declare the `group` capability, and cannot narrow a group's rows by its key (that needs a `tree` filter with the `eq` operator)":"":"the adapter does not declare the `group` capability, and its declared aggregates have no `count` to give each group its row count":"the adapter does not declare the `group` capability"}function X(ee,re,ie,ce,ve,he,ye){const Oe=Array.isArray(ee.groupBy)?ee.groupBy:[],Le=Array.isArray(ee.groupPath)?ee.groupPath:[],fe=Array.isArray(ee.groupValues)?ee.groupValues:null;if(!re.group){const ae=M(re);if(ae)return ae}return o(Oe)?ie.residual?"the filter did not fully push, so the engine would group a superset of the matching rows":ce?ve?he&&!he.conditioned?"a host `where` predicate can only run in the browser, over rows the engine grouped":ye?"fullDataset holds the whole matching set, so the grid groups it itself":!fe||fe.length!==Le.length?"the request carries no typed `groupValues` for its group path, and the string `groupPath` cannot be compared against a typed column":"":"a quick search did not push, so the engine would group unsearched rows":"the sort did not push, so the engine would order the groups differently":"a grouping key is not a plain column the engine can name in a GROUP BY"}const q="pushdown:pivot-unsupported",K="pushdown:group-unsupported",P=Symbol("lattice.remote.ungroupedLevel");function k(ee,re,ie,ce,ve,he){const ye=Array.isArray(ee.pivotBy)?ee.pivotBy:[],Oe=Array.isArray(ee.groupBy)?ee.groupBy:[],Le=Array.isArray(ee.groupPath)?ee.groupPath:[],fe=Array.isArray(ee.groupValues)?ee.groupValues:null;return re.pivot?o(ye)?Oe.length&&!o(Oe)?"a grouping key is not a plain column the engine can name in a GROUP BY":ie.residual?"the filter did not fully push, so the engine would pivot a superset of the matching rows":ce?ve?he&&!he.conditioned?"a host `where` predicate can only run in the browser, over rows the engine pivoted":!fe||fe.length!==Le.length?"the request carries no typed `groupValues` for its group path, and the string `groupPath` cannot be compared against a typed column":"":"a quick search did not push, so the engine would pivot unsearched rows":"the sort did not push, so the engine would order the rows differently":"a pivot column is not a plain column the engine can name in a GROUP BY":"the adapter does not declare the `pivot` capability"}function E(ee,re,ie=!1){const ce=m(ee.filters||null,re),ve=[];ce.residual&&ve.push("filter");const he=ee.sort||[],ye=he.length===0||re.sort==="multi"&&he.length>=1||re.sort==="single"&&he.length===1;!ye&&he.length&&ve.push("sort");const Oe=ee.quick?String(ee.quick):"",Le=!Oe||!!re.quick;Le||ve.push("quick");const fe=ee.where&&ee.where.active?ee.where:null;fe&&ve.push("where");const ae={filters:ce.residual,sort:ye?null:he,quick:Le?"":Oe,where:fe},ke=!!ie,pe=Array.isArray(ee.groupBy)&&ee.groupBy.length>0,ue=pe?X(ee,re,ce,ye,Le,fe,ke):"",we=ee.pivotMode!==!1&&Array.isArray(ee.pivotBy)&&ee.pivotBy.length>0,Te=we?k(ee,re,ce,ye,Le,fe):"",Ne=we&&Te==="";we&&!Ne&&ve.push("pivot");const _e=we?Ne&&pe:pe&&ue==="";pe&&!we&&!_e&&ve.push("group");const $e=(_e||Ne)&&Array.isArray(ee.groupValues)?ee.groupValues.length:0;fe&&fe.conditioned&&(_e||Ne)&&(ae.where=null,ve.splice(ve.indexOf("where"),1));const je=_e||we?!1:ke||!!(ae.filters||ae.sort||ae.quick||ae.where)||!re.range;return{pushed:{...ee,filters:ce.pushed,sort:ye?he:[],quick:Le?Oe:"",range:je?null:ee.range},residual:ae,needsAll:je,unpushed:ve,full:ke,grouped:_e,groupLevel:$e,groupReason:we?"":ue,pivoted:Ne,pivotReason:Te}}function C(ee){const re=Array.isArray(ee.totals)?ee.totals:[],ie=ee.totalFns&&typeof ee.totalFns=="object"?ee.totalFns:{},ce=[],ve=[];for(const he of re){const ye=String(he),Oe=ie[ye],Le=typeof Oe=="string"?Oe:Oe&&typeof Oe.fn=="string"?Oe.fn:null,fe=Oe&&typeof Oe=="object"?s(Oe):void 0,ae=Le?t[Le]:null;ae&&ae.parametric&&fe===void 0?ve.push({id:ye,fn:Le,class:ae.class,reason:`"${Le}" needs \`p\`, a number from 0 to 1`}):Le?!ae||!ae.pushable||!ae.sql?ve.push({id:ye,fn:Le,class:ae?ae.class:"fallback",reason:ae&&ae.note?ae.note:`the pushdown map cannot express "${Le}"`}):ae.twoColumn?ve.push({id:ye,fn:Le,class:ae.class,reason:`"${Le}" reduces two columns, and a grouped request carries no weight column`}):ce.push({id:ye,col:ye,fn:Le,class:ae.class,...fe!==void 0?{p:fe}:{}}):ve.push({id:ye,fn:null,class:"fallback",reason:"the column totals with a host function, so there is no named statistic to push"})}return{engine:ce,client:ve}}function x(ee){return{...ee,engine:ee.engine.map(re=>{const ie=t[re.fn];if(!ie||!ie.sql)return re;const ce=ve=>`"${ve}"`;return{...re,sql:l(ie.sql,ce(re.col),re.weight!==void 0?ce(re.weight):void 0)}})}}const j=Object.freeze({items:ee=>ee==null?[]:Array.isArray(ee)?ee:[ee]});function T(ee,re,ie){if(!re)return ee;let ce=ee;if(re.filters&&U(ie.evaluateFilters)){const ve=ce,he={count:ce.length,handle:Le=>({id:Le,get:fe=>h(ve[fe],Le)}),itemwise:Le=>ve.some(fe=>Array.isArray(h(fe,Le)))?j:null},ye=ie.evaluateFilters(re.filters,he),Oe=[];for(let Le=0;Le<ce.length;Le++)ye[Le]&&Oe.push(ce[Le]);ce=Oe}if(re.where&&re.where.active&&(re.whole||O(re.where.names,"pushdown"),ce=ce.filter(ve=>re.where.passes(ve))),re.quick){const ve=re.quick.toLowerCase();ce=ce.filter(he=>{if(!he||typeof he!="object")return!1;for(const ye of Object.values(he))if(ye!=null&&String(ye).toLowerCase().includes(ve))return!0;return!1})}if(re.sort&&re.sort.length&&U(ie.sortMulti)){const ve=[...new Set(re.sort.map(Le=>Le.col))],he=ce,ye=ve.map(Le=>({id:Le,get:fe=>h(he[fe],Le)})),Oe=ie.sortMulti(ye,re.sort.map(Le=>({col:Le.col,dir:Le.dir})),Uint32Array.from({length:ce.length},(Le,fe)=>fe),{});ce=Array.from(Oe,Le=>he[Le])}return ce}function F(ee){return JSON.stringify({filters:ee.filters||null,sort:ee.sort||[],quick:ee.quick||"",groupBy:ee.groupBy||[],groupPath:ee.groupPath||[],context:ee.context??null})}function $(ee){if(!ee||typeof ee!="object")return 16;let re="";try{re=JSON.stringify(ee)}catch{return 200}return re.length*2+64}function D(ee){const re=ee||{};return{enabled:!!re.enabled,maxRows:Number.isFinite(re.maxRows)?re.maxRows:1e6,maxBytesEstimate:Number.isFinite(re.maxBytesEstimate)?re.maxBytesEstimate:512*1024*1024}}const z=5e4;function G(ee){return Number.isFinite(ee)&&ee>=0?ee:z}function N(ee){return!!ee&&U(ee.then)}async function Z(ee){if(!ee||ee.total!==void 0||!N(ee.pendingTotal))return ee;const re=await ee.pendingTotal,{pendingTotal:ie,...ce}=ee;return typeof re=="number"?{...ce,total:re}:ce}function Q(ee={}){const re=ee.adapter;if(!re||!U(re.execute))return L("source.pushdown.adapter","createPushdownSource needs an `adapter` with an `execute(query)` function."),{...ee,mode:"remote",fetch:async()=>({rows:[],total:0})};const ie=y(re.capabilities),ce=re.capabilities&&Object.getOwnPropertyDescriptor(re.capabilities,"operators");ce&&U(ce.get)&&Object.defineProperty(ie,"operators",{enumerable:!0,configurable:!0,get:()=>new Set(re.capabilities.operators||[]),set:()=>{}});const ve=re.name||"adapter";let he=null;const ye=()=>U(re.ready)?(he||(he=Promise.resolve(re.ready()).then(()=>{Object.assign(ie,y(re.capabilities))},oe=>{throw he=null,oe})),he):null,Oe=D(ee.fullDataset),Le=!!ee.allowPartialResults,fe=G(ee.whereRowLimit);let ae=null;const ke=ee.aggregates;let pe=null,ue=null,we=null,Te=null,Ne=null,_e=null,$e=0,je=null;const Ge=()=>!Oe.enabled||!pe?null:(je!==pe.key&&($e++,je=pe.key),{rows:pe.rows,version:$e}),Fe=async oe=>{const de=oe.where&&oe.where.active?oe.where:null;if(!de)return{request:oe,probe:null};if(de.conditioned){const rt=E(oe,ie,Oe.enabled);if(rt.grouped||rt.pivoted)return{request:oe,probe:null}}const{where:Ae,...Ce}=oe,De=E(Ce,ie,Oe.enabled);if(De.needsAll)return{request:oe,probe:null};const Ue=F(De.pushed);let qe=null;return(!ae||ae.key!==Ue)&&(ie.total?(r(oe),qe=await Z(await re.execute(De.pushed,oe)),ae={key:Ue,size:qe&&typeof qe.total=="number"?qe.total:null}):ae={key:Ue,size:null}),ae.size!==null&&ae.size<fe?{request:oe,probe:null}:(v(de.names,ve,ae.size,fe),{request:Ce,probe:qe})},Pe=async(oe,de)=>{_e=null;const Ae=C(oe.pushed);we={engine:Ae.engine,client:Ae.client,groupBy:oe.pushed.groupBy},Ae.client.length&&L(`source.pushdown.group.totals.${ve}.${Ae.client.map(Ue=>Ue.id).join(".")}`,`the ${ve} adapter cannot compute the group subtotal for ${Ae.client.map(Ue=>`"${Ue.id}" (${Ue.reason})`).join(", ")}, so those group rows carry no value for that column. A figure computed over anything other than the group would be wrong, so none is shown; \`lastPlan().aggregates.client\` names them.`);const Ce=await re.executeGroupLevel(oe.pushed,Ae.engine,de)||{};let De=Ce.rows||[];return!ie.range&&de.range&&(De=De.slice(de.range.start,de.range.end)),We(Ce),Ce.total===void 0?{rows:De}:{rows:De,total:Ce.total}},Ee=new Map,Me=64,Ie=async(oe,de)=>{_e=null;const Ae=oe.pushed,Ce=Ae.groupBy,De=Array.isArray(Ae.groupValues)?Ae.groupValues:[],Ue=De.length,qe=[...Ae.filters?[Ae.filters]:[],...Ce.slice(0,Ue).map((at,mt)=>({col:at,op:"eq",value:De[mt]===void 0?null:De[mt],caseSensitive:!0}))],rt=qe.length===0?null:qe.length===1?qe[0]:{op:"and",conditions:qe},ct=de.range?de.range.start:0;if(Ue>=Ce.length){const at={...Ae,filters:rt,groupBy:[],groupPath:[],groupValues:[],totals:[],totalFns:{}},mt=await Z(await re.execute(at,de))||{};let xt=mt.rows||[];return!ie.range&&de.range&&(xt=xt.slice(de.range.start,de.range.end)),typeof mt.total=="number"?{rows:xt,total:mt.total}:{rows:xt}}const ot=Ce[Ue],vt=C(Ae),Rt=S(ie),At=vt.engine.filter(at=>Rt.has(at.fn)),_t=[...vt.engine.filter(at=>!Rt.has(at.fn)).map(at=>({id:at.id,fn:at.fn,class:at.class,reason:`the ${ve} adapter does not compute "${at.fn}"`})),...vt.client];we={engine:At,client:_t,groupBy:Ce},_t.length&&L(`source.pushdown.group.totals.${ve}.${_t.map(at=>at.id).join(".")}`,`the ${ve} adapter cannot compute the group subtotal for ${_t.map(at=>`"${at.id}" (${at.reason})`).join(", ")}, so those group rows carry no value for that column. A figure computed over anything other than the group would be wrong, so none is shown; \`lastPlan().aggregates.client\` names them.`);const tn=[...At.map(at=>({id:at.id,col:at.col,fn:at.fn,...at.p!==void 0?{p:at.p}:{}})),{id:w,col:ot,fn:"count"}],Ht={...Ae,filters:rt,range:null},Xt=JSON.stringify([F(Ht),De,ot,tn]);let Ze=ct>0?Ee.get(Xt):void 0;if(!Ze){for(Ze=Promise.resolve(re.executeGroupedAggregates(Ht,[ot],tn)),Ee.delete(Xt),Ee.set(Xt,Ze);Ee.size>Me;)Ee.delete(Ee.keys().next().value);Ze.catch(()=>{Ee.get(Xt)===Ze&&Ee.delete(Xt)})}const lt=await Ze||[];r(de);const St=at=>{const mt={};for(const xt of At)mt[xt.id]=at?at[xt.id]:void 0;return mt},bt=(Ae.sort||[]).find(at=>at&&at.col===ot),wt=bt&&bt.dir==="desc"?-1:1,Ke=lt.filter(at=>at&&at.level===1).map(at=>({[ot]:at.keys[0]===void 0?null:at.keys[0],leafCount:Number(at.values&&at.values[w])||0,totals:St(at.values)})).sort((at,mt)=>wt*A(at[ot],mt[ot]));if(Ue===0){const at=lt.find(xt=>xt&&xt.level===0),mt=at?Number(at.values&&at.values[w]):NaN;We({matchCount:Number.isFinite(mt)?mt:Ke.reduce((xt,Ft)=>xt+Ft.leafCount,0),...at?{grand:St(at.values)}:{}})}const ht=de.range?de.range.end:Ke.length;return{rows:Ke.slice(ct,ht),total:Ke.length}},We=oe=>{typeof oe.matchCount=="number"&&(Te=oe.matchCount,Ne=oe.grand?{totals:oe.grand,leafCount:oe.matchCount}:null)},Ye=async(oe,de)=>{_e=null;const Ae=C(oe.pushed);we={engine:Ae.engine,client:Ae.client,groupBy:oe.pushed.groupBy,pivotBy:oe.pushed.pivotBy},Ae.client.length&&L(`source.pushdown.pivot.totals.${ve}.${Ae.client.map(rt=>rt.id).join(".")}`,`the ${ve} adapter cannot compute the pivot cells for ${Ae.client.map(rt=>`"${rt.id}" (${rt.reason})`).join(", ")}, so those cells are empty. A figure computed over anything other than the cell would be wrong, so none is shown; \`lastPlan().aggregates.client\` names them.`);const Ce=await re.executePivotLevel(oe.pushed,Ae.engine,de)||{};let De=Ce.rows||[];!ie.range&&de.range&&(De=De.slice(de.range.start,de.range.end)),We(Ce);const Ue=Ce.pivot&&typeof Ce.pivot=="object"?Ce.pivot:{},qe={cells:Array.isArray(Ue.cells)?Ue.cells:[],...Array.isArray(Ue.axis)?{axis:Ue.axis}:{}};return Ce.total===void 0?{rows:De,pivot:qe}:{rows:De,total:Ce.total,pivot:qe}},nt=oe=>{L(`source.pushdown.pivot.${ve}.${oe}`,`pushdown:pivot-unsupported: the ${ve} adapter cannot pivot this query because ${oe}, so no rows are fetched rather than every leaf row being pulled into the browser to pivot there. \`lastPlan().pivotReason\` says the same.`);const de=new Error(`[lattice] ${q}: the ${ve} adapter cannot pivot this query because ${oe}, so no rows are fetched rather than every leaf row being pulled into the browser to pivot there. \`lastPlan().pivotReason\` says the same.`);throw de.code=q,de.reason=oe,de},Qe=(oe,de)=>{const Ae={key:de,state:"pending",value:null};return _e=Ae,oe.then(Ce=>(_e===Ae&&(_e={key:de,state:"settled",value:typeof Ce=="number"?Ce:null}),Ce),Ce=>{throw _e===Ae&&(_e={key:de,state:"failed",value:null}),Ce})};let dt=0,jt=[];const Et=()=>dt===0?null:new Promise(oe=>{const de=setTimeout(oe,p);jt.push(()=>{clearTimeout(de),oe()})});let it;const ft=async oe=>{const de=ye();de&&await de;const Ce=oe&&oe.pivotMode!==!1&&Array.isArray(oe.pivotBy)&&oe.pivotBy.length>0?{request:oe,probe:null}:await Fe(oe);r(oe);let De=E(Ce.request,ie,Oe.enabled);if(ie.group&&De.grouped&&!De.pivoted&&!U(re.executeGroupLevel)&&(L(`source.pushdown.group.method.${ve}`,`the ${ve} adapter declares the \`group\` capability but has no \`executeGroupLevel(query, aggregates, request)\`, so grouping is not pushed and the grid stays ungrouped unless it holds the whole matching set. Implement the method or drop the capability.`),De=E(Ce.request,{...ie,group:!1,aggregates:null},Oe.enabled)),De.pivoted&&!U(re.executePivotLevel)&&(De=E(Ce.request,{...ie,pivot:!1},Oe.enabled),De.pivotReason="the adapter declares the `pivot` capability but has no `executePivotLevel(query, aggregates, request)`"),De.grouped&&!De.pivoted&&!ie.group&&!U(re.executeGroupedAggregates)&&(L(`source.pushdown.group.aggregates.method.${ve}`,`the ${ve} adapter declares \`aggregates\` but has no \`executeGroupedAggregates(query, groupBy, aggregates)\`, so the grouped view cannot be built from grouped aggregates and the grid stays ungrouped unless it holds the whole matching set. Implement the method, or declare \`group\` and implement \`executeGroupLevel\`.`),De=E(Ce.request,{...ie,aggregates:null},Oe.enabled)),ue=De,De.pivoted)return Ye(De,oe);if(De.pivotReason&&nt(De.pivotReason),De.grouped)return ie.group?Pe(De,oe):Ie(De,oe);const qe=!!De.groupReason&&!De.full;qe?L(`source.pushdown.group-unsupported.${ve}.${De.groupReason}`,`pushdown:group-unsupported: the ${ve} adapter was not asked to group this query because ${De.groupReason}, so the grid stays ungrouped rather than building group rows, counts and subtotals from a window of leaf rows. \`lastPlan().groupReason\` says the same.`):De.groupReason&&L(`source.pushdown.group.${ve}.${De.groupReason}`,`the ${ve} adapter was not asked to group this query because ${De.groupReason}. The engine returns rows and the grouping is the grid's to do, which needs every matching row in the browser — correct where the grid holds them, and wrong-looking where it holds a window. \`lastPlan().unpushed\` names it.`);const rt=Ht=>qe?{...Ht,[P]:!0}:Ht;if(!De.needsAll){const Ht=Ce.probe||await re.execute(De.pushed,oe),Xt=Ht.rows||[];return N(Ht.pendingTotal)&&Ht.total===void 0?rt({rows:Xt,pendingTotal:Qe(Ht.pendingTotal,F(De.pushed))}):(_e=null,!ie.total&&Ht.total===void 0?rt({rows:Xt}):rt({rows:Xt,total:Ht.total??Xt.length}))}const ct=De.unpushed.filter(Ht=>!(Ht==="where"&&De.residual.where&&De.residual.where.anyConditioned));ct.length&&L(`source.pushdown.residual.${ve}.${ct.join(".")}`,`the ${ve} adapter cannot push ${ct.join(" or ")}, so every matching row is fetched and the rest is applied in the browser. Correct, and slower than it needs to be: widening the adapter is the fix.`);const ot=F(De.pushed);if(!pe||pe.key!==ot){const Ht=await Z(await re.execute(De.pushed,oe));_e=null;const Xt=Ht.rows||[];if(De.full){const Ze=typeof Ht.total=="number"?Math.max(Ht.total,Xt.length):Xt.length;if(Ze>Oe.maxRows)throw new Error(`[lattice] fullDataset refused: the ${ve} adapter's matching set is ${Ze.toLocaleString()} rows, past the configured maxRows of ${Oe.maxRows.toLocaleString()}. The whole set cannot be held client-side, so it is refused rather than truncated — a fraction shown as the whole would make every total and statistic silently wrong. Narrow the filter or raise maxRows.`);const lt=Xt.length*$(Xt[0]);if(lt>Oe.maxBytesEstimate)throw new Error(`[lattice] fullDataset refused: the ${ve} adapter's matching set is an estimated ${Math.round(lt/(1024*1024)).toLocaleString()} MB across ${Xt.length.toLocaleString()} rows, past the configured maxBytesEstimate of ${Math.round(Oe.maxBytesEstimate/(1024*1024)).toLocaleString()} MB. The whole set cannot be held client-side, so it is refused rather than truncated. Narrow the filter or raise maxBytesEstimate.`)}if(typeof Ht.total=="number"&&Xt.length<Ht.total){const Ze=!!(De.residual.filters||De.residual.quick||De.residual.sort&&De.residual.sort.length);if(Ze&&!Le)throw new Error(`[lattice] the ${ve} adapter returned ${Xt.length} of ${Ht.total} matching rows when asked for the whole result, and the query has residual ${De.unpushed.join(" and ")||"work"} to finish in the browser. Filtering or sorting a fraction of the result would return wrong rows, so the result is refused. Fix the adapter to follow the engine's own paging before returning, hold the data in memory, or set \`allowPartialResults: true\` on the source config to accept this knowingly.`);Ze?L(`source.pushdown.partial.residual.${ve}`,`the ${ve} adapter returned ${Xt.length} of ${Ht.total} matching rows when asked for the whole result, and residual work will run over that fraction. allowPartialResults is set, so the result is used as-is — it may be wrong. The adapter must follow the engine's own paging to be correct.`):L(`source.pushdown.partial.${ve}`,`the ${ve} adapter returned ${Xt.length} of ${Ht.total} matching rows when asked for the whole result. The adapter must follow the engine's own paging before returning.`)}pe={key:ot,rows:Xt,total:typeof Ht.total=="number"?Ht.total:null}}let vt=De;if(De.residual.where){const Ht=pe.total??pe.rows.length;if(Ht>=fe){v(De.residual.where.names,ve,Ht,fe);const{where:Xt,...Ze}=Ce.request;vt=E(Ze,ie,Oe.enabled),ue=vt}}const Rt=pe.total!==null&&pe.rows.length>=pe.total,At=T(pe.rows,{...vt.residual,whole:Rt},ee.compute||{}),_t=oe.range?oe.range.start:0,tn=oe.range?oe.range.end:At.length;return rt({rows:At.slice(_t,tn),total:At.length})},pt=async(oe,de,Ae)=>{const De=Ae&&Ae.waitForPage&&it&&U(it.pageForegroundIdle)?it.pageForegroundIdle():Et();De&&await De;const Ue=ye();Ue&&await Ue;const qe=E(oe,ie,Oe.enabled);ue=qe;const rt=g(de,Ae&&Ae.engine?{default:"engine"}:ke),ct=Array.isArray(oe.groupBy)?oe.groupBy:[],ot=ct.length>0,vt=!qe.residual.filters&&!qe.residual.quick,Rt=!ot||o(ct,ie.buckets);let At=rt.engine,_t=rt.client;if(ie.aggregates&&At.length){const lt=ie.aggregates instanceof Set?ie.aggregates:new Set(J(ie.aggregates)),St=At.filter(bt=>!lt.has(bt.fn));St.length&&(At=At.filter(bt=>lt.has(bt.fn)),_t=[...St.map(bt=>({...bt,reason:`the ${ve} adapter does not compute "${bt.fn}"`})),..._t])}const tn=lt=>{_t=[...At.map(St=>({...St,reason:lt})),..._t],At=[]};let Ht="";if(At.length&&!vt){const lt=qe.residual.quick&&!qe.residual.filters?"a quick search the adapter cannot push forces all-client (no mixed provenance)":"residual filter forces all-client (no mixed provenance)";tn(lt),ot&&(Ht=lt)}else if(At.length&&!Rt){const lt="a grouping key the engine cannot form forces all-client (no mixed provenance)";tn(lt),Ht=lt}let Xt={},Ze;if(At.length&&(U(ot?re.executeGroupedAggregates:re.executeAggregates)?ot?Ze=await re.executeGroupedAggregates(qe.pushed,ct,At)||[]:Xt=await re.executeAggregates(qe.pushed,At)||{}:(L(`source.pushdown.aggregates.${ve}${ot?".grouped":""}`,`the ${ve} adapter cannot compute ${ot?"grouped ":""}aggregates, so every requested statistic is computed client-side. Correct, and slower than it needs to be.`),tn(`adapter cannot compute ${ot?"grouped ":""}aggregates`),ot&&(Ht=`the ${ve} adapter cannot compute grouped aggregates`))),ot){const lt=Ze!==void 0;lt!==qe.grouped&&(ue={...qe,grouped:lt,groupReason:lt?"":Ht||qe.groupReason,unpushed:lt?qe.unpushed.filter(St=>St!=="group"):qe.unpushed.includes("group")?qe.unpushed:[...qe.unpushed,"group"]})}return we={engine:At,client:_t,...ot?{groupBy:ct}:{}},{values:Xt,engine:At,client:_t,...Ze!==void 0?{groups:Ze}:{}}},Tt=async oe=>{dt++;try{return await ft(oe)}finally{if(dt--,dt===0&&jt.length){const de=jt;jt=[];for(const Ae of de)Ae()}}},Nt=a(ee.edit),Lt=ee.edit&&typeof ee.edit=="object"&&U(ee.edit.commit);let Je=ee.edit;if(Nt&&!Lt)if(ie.mutate&&ie.mutate.update){const oe=de=>{if(!ie.mutate||!ie.mutate.update)throw new Error(`[lattice] the ${ve} adapter cannot update rows (mutate.update is not declared), so this edit cannot be persisted. The cell is reverted rather than left looking saved.`);const Ae={kind:"update",key:String(de.key),patch:{[de.colId]:de.value}};return re.mutate(Ae,de.request||{})};Je={...ee.edit===!0?{}:ee.edit,commit:oe}}else L(`source.pushdown.readonly.${ve}`,`edit is enabled but the ${ve} adapter declares mutate: ${ie.mutate?"without update":"false"} (read-only by declaration), so no commit is synthesised and the grid stays read-only. Declare \`mutate: { update: true }\` on the adapter to allow cell edits.`);const se=Nt&&ie.mutate&&(ie.mutate.append||ie.mutate.delete)?{append:ie.mutate.append===!0,remove:ie.mutate.delete===!0,returning:ie.mutate.returning,mutate:(oe,de)=>re.mutate(oe,de||{})}:null,ge=async oe=>{const de=ye();de&&await de;const{range:Ae,signal:Ce,export:De,...Ue}=oe||{},qe={...Ue,groupBy:[],groupPath:[],groupValues:[],pivotBy:[],pivotMode:!1,totals:[]};return{plan:E(qe,ie,Oe.enabled),signal:Ce}};async function*Se(oe,de={}){const{plan:Ae,signal:Ce}=await ge(oe),De=Math.max(1,Math.floor(Number(de.pageSize))||5e3),Ue={signal:Ce,stream:!0},qe=oe&&oe.range&&Number.isFinite(Number(oe.range.start))&&Number.isFinite(Number(oe.range.end))?{start:Math.max(0,Number(oe.range.start)),end:Math.max(0,Number(oe.range.end))}:null;if(!Ae.needsAll){const ot=qe?qe.start:0,vt=qe?qe.end:1/0;for(let Rt=ot;Rt<vt;Rt+=De){r(Ue);const At=Math.min(Rt+De,vt),_t=await re.execute({...Ae.pushed,range:{start:Rt,end:At}},Ue);_t&&N(_t.pendingTotal)&&_t.pendingTotal.then(null,()=>{});const tn=_t&&_t.rows||[];if(tn.length&&(yield tn),tn.length<At-Rt)return}return}r(Ue);const rt=await Z(await re.execute({...Ae.pushed,range:void 0},Ue));let ct=T(rt&&rt.rows||[],{...Ae.residual,whole:!0},ee.compute||{});qe&&(ct=ct.slice(qe.start,qe.end));for(let ot=0;ot<ct.length;ot+=De)yield ct.slice(ot,ot+De)}const Re=async oe=>{const{plan:de,signal:Ae}=await ge(oe);if(!de.needsAll&&ie.total){r({signal:Ae});const De=await Z(await re.execute({...de.pushed,range:{start:0,end:0}},{signal:Ae}));if(De&&typeof De.total=="number")return De.total}let Ce=0;for await(const De of Se({...oe,range:void 0}))Ce+=De.length;return Ce},xe=async oe=>{await ye();const de=b(oe.filters||null,{tz:ee.timeZone,weekStartsOn:ee.weekStartsOn}),Ae=oe.quick?String(oe.quick):"";return m(de,ie).residual||Ae&&!ie.quick?null:re.facets({...oe,filters:de,quick:Ae})};return it={...ee,edit:Je,rowMutate:se,mode:"remote",fetch:Tt,foregroundIdle:Et,facetProvider:U(re.facets)?xe:void 0,aggregate:pt,countMatching:Re,streamMatching:Se,capabilitiesOf:y,planQuery:E,wireFilters:b,resolveAggregatePlan:(oe,de)=>g(oe,de&&de.engine?{default:"engine"}:ke),STAT_PUSHDOWN:t,lastPlan:()=>ue?{...ue,...we?{aggregates:x(we)}:{},..._e?{total:{deferred:!0,state:_e.state,value:_e.value}}:{}}:null,fullFrame:Ge,counts:()=>({match:Te,total:Te,pending:!!_e&&_e.state==="pending"}),grandTotals:()=>Ne},it}}),ze("packages/core/src/source/remote.js",function(e,B){"use strict";Object.defineProperty(e,"PROTOCOL",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"HINT_SETTLE_MS",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"createRemoteSource",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"RemoteSource",{enumerable:!0,get:function(){return x}});const A=B("packages/core/src/internal/lru.js").Lru,U=B("packages/core/src/internal/predicates.js").isFunction,J=B("packages/core/src/internal/warn.js").warnOnce,L=B("packages/core/src/internal/schedule.js").settleDebounce,Y=B("packages/core/src/source/abort.js"),_=Y.createAbortScope,O=Y.isAbortError,v=B("packages/core/src/source/blockcache.js"),b=v.BlockCache,c=v.DEFAULT_PAGE_SIZE,g=v.DEFAULT_MAX_CACHED_PAGES,o=B("packages/core/src/source/rows.js"),t=o.createRowFactory,s=o.groupKey,l=B("packages/core/src/source/filterwire.js"),u=l.wireFilters,n=l.querySignature,p=l.warnHostFilterNotApplied,i=B("packages/core/src/source/pagewindow.js").pageWindow,h=B("packages/core/src/source/memory.js").MemorySource,y=B("packages/core/src/compute/handle.js").valueComparator,f=B("packages/core/src/compute/pivot.js"),m=f.pivotKey,w=f.joinPath,S=f.DEFAULT_PATH_SEPARATOR,X=B("packages/core/src/source/pushdown.js").UNGROUPED_LEVEL,q=1,K=120,P=1e3;function k(j,T,F){for(let $=0;$<Math.max(j.length,T.length);$++){const D=j[$],z=T[$],G=D==null,N=z==null;if(G||N){if(G&&N)continue;return G?1:-1}const Z=F(D,z);if(Z!==0)return Z}return 0}function E(j,T){return new x(j,T)}class C{constructor(T,F,$,D){this.path=T,this.keyPath=D||T,this.values=[],this.level=F,this.key=s(this.keyPath),this.cache=new b($),this.count=null,this.complete=!1,this.announced=null,this.counting=!1,this.failed=!1,this.children=new Map,this.row=null,this.flat=!1}}class x{mode="remote";#e;#t;#n;#r;#s=new Map;#i=new Set;#a=_();#l;#o;#c=new Map;#u=[];#f=null;#d="";#h;#p=!1;#m=!1;#g=[];#b=!1;#y=0;#S="";#w=null;#A=-1;constructor(T,F){this.#e=T||{mode:"remote"},this.#t=F||{},U(this.#e.fullFrame)&&(this.filteredIndices=()=>this.#D(),this.unfilteredIndices=()=>this.#G(),this.handleFor=Z=>this.#K(Z),this.display=()=>this.#L(),this.grandTotalRow=()=>this.#B(),this.unfilteredRows=()=>this.#I(),this.facetIndices=Z=>this.#q(Z));const $=this.#e.counts;U($)&&(this.matchCount=()=>this.#Y("match"),this.totalCount=()=>this.#Y("total"));const D=this.#e.grandTotals;U(D)&&(this.grandTotalRow=()=>this.#z());const z=this.#e.foregroundIdle;U(z)&&(this.foregroundIdle=()=>this.#oe(z),this.#e.pageForegroundIdle=()=>this.#b?this.#oe(z):null);const G=this.#e.facetProvider;U(G)&&(this.facetProvider=G);const N=this.#e;U(N.countMatching)&&U(N.streamMatching)&&(this.selectionQuery=()=>this.#W(),this.countMatching=Z=>N.countMatching(Z),this.streamMatching=(Z,Q)=>N.streamMatching(Z,Q),this.loadedRows=()=>this.#ge(),this.resident=()=>this.#N()!==null),this.#n={pageSize:this.#e.pageSize||c,maxCachedPages:this.#e.maxCachedPages||g},this.#l=t(this.#t),this.#o=new A(this.#n.pageSize*4),this.#h=L((Z,Q)=>this.#T(Z,Q),K),this.#r=new C([],0,this.#n),this.#s.set(this.#r.key,this.#r),this.#d=this.#be(),U(this.#e.fetch)||J("source.remote.fetch",'source.mode "remote" requires a fetch function; the grid will stay empty.'),this.#de()}count(){const T=this.#O();return T?T.length:this.#v()}#v(){const T=this.#N();return T?T.count():(this.#re(),this.#Ae(this.#r))}#C(){if(this.#N())return!0;const T=F=>{if(F.count===null&&!F.complete)return!1;for(const $ of F.children.values())if(this.#Te($.key,this.#we($))&&!T($))return!1;return!0};return T(this.#r)}pageInfo(){const T=this.#O(),F=this.totalPending();if(!T){const $=this.#v();return{page:0,pageSize:0,total:this.#C()?$:null,pageCount:1,counting:F}}return{page:T.page,pageSize:T.pageSize,total:T.total,pageCount:T.pageCount,counting:F||T.total===null&&this.#a.size>0&&this.#r.cache.loadedExtent()===0}}#O(){const T=this.#v(),F=i(this.#$("pageSize",0),this.#$("page",0),T,this.#C());if(!F)return this.#S="",null;const $=`${this.#y}:${F.offset}:${F.length}`;return $!==this.#S&&!this.#p&&(this.#S=$,F.length>0&&!this.#N()&&this.#T(F.offset,F.offset+F.length-1)),F}at(T){const F=this.#O();if(F){if(T<0||T>=F.length)return;const $=this.#P(F.offset+T);return $&&($.index=T),$}return this.#P(T)}#P(T){const F=this.#N();if(F)return F.at(T);if(this.#re(),T<0||T>=this.#v())return;const $=this.#Z(this.#r,T);if(!$)return;const D=this.#V($.node,$.local);return D&&(D.index=T),D||this.#l.skeleton(T,$.node.level,$.node.cache.erroredAt($.local))}byKey(T){const F=this.#N();if(F)return F.byKey(T);const $=this.#c.get(T);if(!$)return;const D=$.lastIndexOf(":"),z=this.#s.get($.slice(0,D));return z&&this.#V(z,Number($.slice(D+1)))||void 0}loaded(T){const F=this.#O();if(F){if(T<0||T>=F.length)return!1;T+=F.offset}const $=this.#N();if($)return $.loaded(T);if(T<0||T>=this.#v())return!1;const D=this.#Z(this.#r,T);return!!D&&D.node.cache.rowLoaded(D.local)}hint(T,F){if(this.#p)return;this.#b=!0;const $=this.#re();let D=Math.max(0,Math.floor(T)),z=Math.max(D,Math.floor(F));const G=this.#O();if(G){if(G.length===0)return;D=G.offset,z=G.offset+G.length-1}for(const[N,Z]of this.#E(D,z)){N.cache.protect(Z.min,Z.max);for(const Q of N.cache.evict())this.#Ee(N,Q)}this.#h(D,z),$&&this.#h.flush()}#E(T,F){const $=this.#v(),D=new Map;for(let z=T;z<=F&&z<$;z++){const G=this.#Z(this.#r,z);if(!G)continue;const N=D.get(G.node);N?(N.min=Math.min(N.min,G.local),N.max=Math.max(N.max,G.local)):D.set(G.node,{min:G.local,max:G.local})}return D.size||D.set(this.#r,{min:T,max:T}),D}#T(T,F){if(!this.#p)for(const[$,D]of this.#E(T,F)){$.cache.protect(D.min,D.max);const z=$.cache.blockOf(D.min),G=$.cache.blockOf(D.max);for(let N=z;N<=G&&!($.count!==null&&N*$.cache.pageSize>=$.count);N++)$.cache.has(N)||this.#ue($,N)}}apply(T){const F={added:[],updated:[],removed:[]};if(!T)return F;if(T.update)for(const $ of T.update){const D=this.#c.get(this.#l.keyOf($,-1));if(!D)continue;this.#o.delete(D);const z=D.lastIndexOf(":"),G=this.#s.get(D.slice(0,z));if(!G)continue;const N=Number(D.slice(z+1)),Z=G.cache.blockOf(N);if(!G.cache.loaded(Z))continue;const{start:Q}=G.cache.rangeOf(Z),ee=[];for(let ie=Q;ie<Q+G.cache.pageSize;ie++){const ce=G.cache.rowAt(ie);if(ce===void 0)break;ee.push(ie===N?$:ce)}G.cache.fill(Z,ee);const re=this.#V(G,N);re&&F.updated.push(re)}return(T.add&&T.add.length||T.remove&&T.remove.length)&&this.reload({keepExpanded:!0}),F}reload(T){this.#a.abortAll("reload"),this.#h.cancel(),T&&T.keepExpanded===!1&&this.#i.clear(),this.#pe(),this.#U("model:changed",{reason:"reload"})}destroy(){this.#p=!0,this.#h.cancel(),this.#a.abortAll("destroyed"),this.#pe(),this.#s.clear(),this.#i.clear(),this.#w&&U(this.#w.destroy)&&this.#w.destroy(),this.#w=null}expand(T){this.#i.has(T)||(this.#i.add(T),this.#U("group:toggled",{key:T,expanded:!0}),this.#U("model:changed",{reason:"expand",key:T}))}collapse(T){this.#i.delete(T)&&(this.#U("group:toggled",{key:T,expanded:!1}),this.#U("model:changed",{reason:"collapse",key:T}))}expandedKeys(){return[...this.#i]}pivotFields(){return this.#u}pivot(){this.#re();const T=this.#f;if(!T||!T.keys.size||!this.#$("pivotBy",[]).length)return null;if(!T.result){const F=y((this.#t.config||{}).locale),$=[...T.keys.entries()].sort((z,G)=>k(z[1],G[1],F)),D=$.map(([z])=>z);T.result={keys:$.map(([,z])=>z),paths:D,fields:this.#Pe(D),groupPaths:[],columns:D.length*Math.max(1,this.#ve().length),values:T.cells,cells:T.cells,error:null}}return T.result}invalidateHandles(){this.#w&&(U(this.#w.invalidateHandles)&&this.#w.invalidateHandles(),U(this.#w.invalidate)&&this.#w.invalidate("filter"))}#M(){const T=this.#e.fullFrame;return U(T)?T():null}#N(){const T=this.#M();return T?(this.#w||(this.#w=new h({mode:"memory"},this.#R())),T.version!==this.#A&&(this.#w.setRows(T.rows),this.#A=T.version),this.#w):null}#R(){const T=this.#t,F=T.state||{};return{...T,state:{...F,page:()=>0,pageSize:()=>0}}}#D(){const T=this.#N();return T?T.filteredIndices():new Uint32Array(0)}#G(){const T=this.#N();return T?T.unfilteredIndices():new Uint32Array(0)}#K(T){const F=this.#N();return F?F.handleFor(T):void 0}#L(){const T=this.#N();return T?T.display():[]}#q(T){const F=this.#N();return F&&U(F.facetIndices)?F.facetIndices(T):new Uint32Array(0)}#B(){const T=this.#N();return T&&U(T.grandTotalRow)?T.grandTotalRow():null}#Y(T){const F=this.#N();if(F){const G=T==="match"?F.matchCount:F.totalCount;if(U(G))return G.call(F)}const $=this.#e.counts,D=U($)?$():null,z=D?D[T]:null;return typeof z=="number"?z:this.#v()}#z(){const T=this.#N();if(T&&U(T.grandTotalRow))return T.grandTotalRow();if((this.#t.config||{}).grandTotalRow!=="bottom")return null;const $=this.#e.grandTotals,D=U($)?$():null;return!D||!D.totals?null:this.#l.grandTotal(D.totals,D.leafCount||0)}#I(){const T=this.#N();if(T&&U(T.unfilteredRows))return T.unfilteredRows();const F=[],$=this.count();for(let D=0;D<$;D++){const z=this.at(D);z&&F.push(z)}return F}#W(){const T=this.#$("quick",""),F={protocol:q,groupPath:[],groupValues:[],groupBy:[],totals:[],totalFns:{},pivotBy:[],pivotMode:!1,filters:u(this.#$("filters",null),this.#Q()),sort:this.#$("sort",[]),context:this.#$("context",null)};T&&(F.quick=T);const $=this.#$("where",null);return $&&$.active&&(F.where=$),F}#ge(){const T=this.#$("groupBy",[]).length,F=[];for(const $ of this.#s.values())if(!($.level!==T&&!$.flat))for(const D of $.cache.ids()){if(!$.cache.loaded(D))continue;const{start:z,end:G}=$.cache.rangeOf(D);for(let N=z;N<G&&$.cache.rowLoaded(N);N++){const Z=this.#V($,N);Z&&!Z.group&&F.push(Z)}}return F}loadedCount(){const T=this.#N();if(T){const D=T.matchCount();return typeof D=="number"?D:T.count()}this.#re();const F=this.#$("groupBy",[]).length;let $=0;for(const D of this.#s.values())if(!(D.level!==F&&!D.flat))for(const z of D.cache.ids()){if(!D.cache.loaded(z))continue;const G=D.cache.fillOf(z);typeof G=="number"&&($+=G)}return $}residentRows(){const T=this.#N();return T?T.display():this.#$("groupBy",[]).length>0?null:(this.#re(),this.#ge())}#ie(T,F,$){const{start:D,end:z}=T.cache.rangeOf(F),G=this.#$("groupBy",[]),N=this.#$("pivotBy",[]),Z=this.#$("quick",""),Q=this.#ve(),ee={protocol:q,range:{start:D,end:z},groupPath:T.path,groupValues:T.values,groupBy:G,totals:Q,totalFns:this.#Oe(Q),pivotBy:N,pivotMode:N.length>0,filters:u(this.#$("filters",null),this.#Q()),sort:this.#$("sort",[]),context:this.#$("context",null),signal:$};Z&&(ee.quick=Z);const re=this.#$("where",null);return re&&re.active&&(ee.where=re),ee}async#ue(T,F){if(!U(this.#e.fetch))return;if(!this.#m){this.#m=!0;const G=this.#g;this.#g=[],queueMicrotask(()=>{for(const N of G)N()})}const $=this.#a.begin(`${T.key}:${F}`);T.cache.begin(F,$);const D=this.#d,{start:z}=T.cache.rangeOf(F);try{const G=await this.#e.fetch(this.#ie(T,F,$.signal));if(!$.current||D!==this.#d||this.#p)return;$.settle();const N=G&&G.rows||[];if(!!(G&&G[X])&&!T.flat){T.flat=!0,T.children.clear();for(const[re,ie]of[...this.#c])ie.startsWith(`${T.key}:`)&&(this.#o.delete(ie),this.#c.delete(re))}T.cache.fill(F,N),T.failed=!1;for(let re=0;re<N.length;re++)this.#o.delete(`${T.key}:${z+re}`);const Q=G&&typeof G.count=="number"?G.count:G&&typeof G.total=="number"?G.total:null,ee=G&&U(G.pendingTotal?.then)?G.pendingTotal:null;Q!==null?(T.count=Q,T.complete=!0):N.length<T.cache.pageSize?(T.count=z+N.length,T.complete=!0):ee&&(T.counting=!0,T.announced=null),G&&Array.isArray(G.pivotFields)&&this.#Ue(G.pivotFields),G&&G.pivot&&typeof G.pivot=="object"&&this.#ae(G.pivot),this.#U("model:changed",{reason:"page",groupPath:T.path,block:F}),this.#U("rows:changed",{companion:!0,reason:"page",groupPath:T.path,block:F}),this.#fe(T),ee&&this.#Me(T,ee,D)}catch(G){if($.settle(),O(G))return;T.cache.failed(F,G),T.failed=!0;const{end:N}=T.cache.rangeOf(F);for(let Z=z;Z<N;Z++)this.#o.delete(`${T.key}:${Z}`);this.#U("model:changed",{reason:"page-error",groupPath:T.path,block:F}),this.#U("source:error",{error:G,groupPath:T.path,block:F})}}async#Me(T,F,$){let D;try{D=await F}catch(z){if($!==this.#d||this.#p)return;T.counting=!1,O(z)||(T.failed=!0),O(z)||this.#U("source:error",{error:z,groupPath:T.path});return}$!==this.#d||this.#p||(T.counting=!1,typeof D=="number"&&(T.count=D,T.complete=!0,this.#fe(T),this.#U("model:changed",{reason:"total",count:D,groupPath:T.path})))}#fe(T){typeof T.count!="number"||!T.complete||T.announced!==T.count&&(T.announced=T.count,this.#U("source:total",{total:T.count,groupPath:T.path}))}#oe(T){if(this.#p)return null;this.#re();const F=this.#m?null:new Promise(N=>{this.#g.push(N),setTimeout(N,P)}),$=T();if(!F&&!$)return null;const D=(async()=>{F&&await F;for(let N=T();N;N=T())await N})();let z;const G=new Promise(N=>{z=setTimeout(N,P)});return Promise.race([D,G]).then(()=>clearTimeout(z))}totalPending(){if(this.#r.failed)return!1;if(this.#r.counting===!0)return!0;if(this.#N())return!1;this.#re();const T=this.#r;return T.count===null&&!T.complete&&T.cache.loadedExtent()===0}totalFailed(){return this.#r.failed===!0}#Ue(T){T.length===this.#u.length&&T.every((F,$)=>F===this.#u[$])||(this.#u=T,this.#U("column:pivoted",{pivotFields:T,remote:!0}))}#xe(){const T=this.#t.config||{};return T.pivot&&T.pivot.separator||S}#Pe(T){const F=this.#xe(),$=this.#ve();if(!$.length)return T.slice();const D=[];for(const z of T)for(const G of $)D.push(`${z}${F}${G}`);return D}#ae(T){const F=this.#xe();this.#f||(this.#f={keys:new Map,cells:new Map,result:null});const $=this.#f;let D=!1;const z=N=>{const Z=Array.isArray(N)?N:[N],Q=w(Z,F);return $.keys.has(Q)||($.keys.set(Q,Z),D=!0),Q},G=this.#$("groupBy",[]).length>0;for(const N of Array.isArray(T.axis)?T.axis:[])z(N);for(const N of Array.isArray(T.cells)?T.cells:[]){if(!N||typeof N!="object")continue;const Z=z(N.pivot);if(G&&!(Array.isArray(N.group)&&N.group.length))continue;const Q=w(Array.isArray(N.group)?N.group:[],F);for(const[ee,re]of Object.entries(N.values||{}))$.cells.set(m(Q,Z,ee),re)}$.result=null,D&&this.#Ue((this.pivot()||{fields:[]}).fields)}#Ae(T){let F=this.#le(T);for(const $ of T.children.values())this.#Te($.key,this.#we($))&&(F+=this.#Ae($));return F}#le(T){if(T.count!==null)return T.count;const F=T.cache.loadedExtent();return T.complete?F:T.row&&T.row.leafCount>0?T.level>=this.#$("groupBy",[]).length?Math.max(F,T.row.leafCount):F===0?1:Math.min(F+T.cache.pageSize,Math.max(F,T.row.leafCount)):F+T.cache.pageSize}#Z(T,F){let $=F,D=0;const z=[...T.children.entries()].filter(([,N])=>this.#Te(N.key,this.#we(N))).sort((N,Z)=>N[0]-Z[0]);for(const[N,Z]of z){const Q=N-D+1;if($<Q)return{node:T,local:D+$};$-=Q,D=N+1;const ee=this.#Ae(Z);if($<ee)return this.#Z(Z,$);$-=ee}const G=this.#le(T);return D+$<G?{node:T,local:D+$}:null}#V(T,F){const $=`${T.key}:${F}`,D=this.#o.get($);if(D)return D.group===!0?this.#_(D):D;const z=T.cache.rowAt(F);if(z===void 0)return null;const G=this.#$("groupBy",[]);let N;if(T.level<G.length&&!T.flat){const Z=G[T.level],Q=this.#f!==null&&T.level===G.length-1&&this.#$("pivotBy",[]).length>0,ee=this.#ye(z,Z),re=ee==null,ie=[...T.path,re?"":String(ee)],ce=[...T.keyPath,re?null:String(ee)];if(N=this.#l.group({path:ie,keyPath:ce,column:Z,value:ee,level:T.level,parent:T.row,leafCount:Number(z.leafCount)||0,expanded:Q?!1:this.#Te(s(ce),{key:s(ce),column:Z,value:ee,level:T.level,path:ie}),...Q?{hasChildren:!1}:{}}),N.totals=this.#ne(z),N.data=z,!Q){let ve=this.#s.get(N.key);ve?ve.row=N:(ve=new C(ie,T.level+1,this.#n,ce),ve.row=N,this.#s.set(ve.key,ve)),ve.values=[...T.values,ee],T.children.set(F,ve)}}else N=this.#l.leaf(z,F,T.level,T.row);return this.#o.set($,N),this.#c.set(N.key,$),N}#ne(T){const F=T||{};if(F.totals&&typeof F.totals=="object")return F.totals;const $={};for(const D of this.#ve())Object.hasOwn(F,D)&&($[D]=F[D]);return $}#_(T){const F=this.#s.get(T.key);if(!F||F.row!==T||T.hasChildren===!1)return T;const $=this.#Te(T.key,this.#we(F));return T.expanded!==$&&(T.expanded=$),T}#Ee(T,F){const{start:$,end:D}=T.cache.rangeOf(F);for(let z=$;z<D;z++){const G=`${T.key}:${z}`,N=this.#o.peek(G);N&&this.#c.delete(N.key),this.#o.delete(G)}}#re(){const T=this.#be();return T===this.#d?!1:(this.#d=T,this.#a.abortAll("query"),this.#pe(),this.#m=!1,this.#U("model:changed",{reason:"query"}),!0)}#pe(){for(const T of this.#s.values())T.cache.clear(),T.count=null,T.complete=!1,T.announced=null,T.counting=!1,T.failed=!1,T.children.clear(),T.flat=!1;this.#o.clear(),this.#c.clear(),this.#y++,this.#f=null}#be(){const T=this.#$("where",null);return`${n({filters:this.#$("filters",null),sort:this.#$("sort",[]),quick:this.#$("quick",""),groupBy:this.#$("groupBy",[]),pivotBy:this.#$("pivotBy",[]),context:this.#$("context",null)})}|${T?T.version:0}`}#Te(T,F){const $=this.#$("expanded",null);return $?U($.has)?$.has(T,F):Array.prototype.includes.call($,T):this.#i.has(T)}#we(T){if(T.row)return{key:T.key,column:T.row.column,value:T.row.value,level:T.level-1,path:T.path}}#ve(){const T=this.#$("totals",[]);if(T&&T.length)return[...T];const F=this.#t.columns;return!F||!U(F.all)?[]:F.all().filter($=>!!$.total).map($=>$.id)}#Oe(T){const F=this.#t.columns,$={};if(!F||!U(F.get))return $;for(const D of T){const z=F.get(D);if(!z)continue;const G=z.groupTotal!=null?z.groupTotal:z.total;typeof G=="string"?$[D]=G:G&&typeof G=="object"&&typeof G.fn=="string"&&($[D]={...G})}return $}#ye(T,F){const $=this.#t.columns,D=$&&U($.get)?$.get(F):void 0;return D&&U(D.getValue)?D.getValue(T):T?.[F]}#de(){p(this.#t)}#Q(){const T=this.#t.config||{};return{tz:T.timeZone,weekStartsOn:T.weekStartsOn}}#$(T,F){const $=this.#t.state;if($&&U($[T])){const D=$[T]();return D??F}return F}#U(T,F){const $=this.#t.emit;U($)&&$(T,F)}}}),ze("packages/core/src/source/gapbuffer.js",function(e,B){"use strict";Object.defineProperty(e,"GapBuffer",{enumerable:!0,get:function(){return A}});const ne=64;class A{#e;#t=0;#n=0;constructor(U=ne){this.#e=new Uint32Array(Math.max(1,U)),this.#n=this.#e.length}static from(U,I=ne){const J=new A(U.length+Math.max(1,I));return J.#e.set(U,0),J.#t=U.length,J.#n=J.#e.length,J}get length(){return this.#t+(this.#e.length-this.#n)}get capacity(){return this.#e.length}at(U){return U<0||U>=this.length?0:U<this.#t?this.#e[U]:this.#e[U+(this.#n-this.#t)]}insert(U,I){const J=U<0?0:U>this.length?this.length:U;this.#r(J),this.#t===this.#n&&this.#s(),this.#e[this.#t++]=I}push(U){this.insert(this.length,U)}removeAt(U){return!Number.isInteger(U)||U<0||U>=this.length?!1:(this.#r(U),this.#n++,!0)}toArray(){const U=new Uint32Array(this.length);return U.set(this.#e.subarray(0,this.#t),0),U.set(this.#e.subarray(this.#n),this.#t),U}clear(){this.#t=0,this.#n=this.#e.length}#r(U){if(U!==this.#t)if(U<this.#t){const I=this.#t-U;this.#e.copyWithin(this.#n-I,U,this.#t),this.#t=U,this.#n-=I}else{const I=U-this.#t;this.#e.copyWithin(this.#t,this.#n,this.#n+I),this.#t=U,this.#n+=I}}#s(){const U=this.#e.length-this.#n,I=new Uint32Array(Math.max(this.#e.length*2,this.#e.length+ne));I.set(this.#e.subarray(0,this.#t),0),I.set(this.#e.subarray(this.#n),I.length-U),this.#e=I,this.#n=I.length-U}}}),ze("packages/core/src/store/ingest.js",function(e,B){"use strict";Object.defineProperty(e,"INGEST_DEFAULTS",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"inferKind",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"decideText",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"createReaders",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"Ingest",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"ingest",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"ingestSync",{enumerable:!0,get:function(){return u}});const ne=B("packages/core/src/internal/schedule.js"),A=ne.now,V=ne.nextFrame,U=B("packages/core/src/internal/warn.js"),I=U.infoOnce,J=U.warnOnce,L=B("packages/core/src/internal/predicates.js").isFunction,_=B("packages/core/src/internal/paths.js").pathGetter,v=B("packages/core/src/store/columnstore.js").ColumnStore,b=Object.freeze({chunkMs:8,chunkRows:512,sampleSize:100,dictionaryRatio:.1,columnarBelow:5e3,initialCapacity:1024});function c(n,p={}){if(p.multi)return"multi";if(n.length===0)return"object";let r=0,i=0,d=0,h=0,a=0;for(let f=0;f<n.length;f++){const m=n[f];typeof m=="number"?r++:typeof m=="boolean"?i++:typeof m=="string"?d++:m instanceof Date?h++:Array.isArray(m)&&a++}const y=n.length;return r===y?"float64":i===y?"bitset":h===y?"float64":d===y?"text":a===y?"multi":"object"}function g(n,p,r){return p<=0||n<r*p?"dictionary":"object"}function o(n,p,r){const i=new Map,d=new Map;for(const q of n){if(q.computed)continue;const K=L(q.read)?q.read:_(q.field||q.id);d.set(q.id,K),i.set(q.id,K)}const h=p?.order??[],a=p?.fns??{},y=p?.deps??{},f=p?.wrapDeps??null,m=h.filter(q=>L(a[q])),w=m.some(q=>y[q]==="*");let S=new WeakMap;const M=q=>{const K={};if(w)for(const[P,k]of d)K[P]=k(q);for(const P of m){const k=y[P];let E;if(k==="*")E=K;else{E={};const C=k||[];for(let x=0;x<C.length;x++){const j=C[x];E[j]=j in K?K[j]:d.get(j)?.(q)}}K[P]=a[P](f?f(E,P):E,{data:q,row:null,column:null,grid:null,context:r})}return K},X=q=>{if(q===null||typeof q!="object"&&typeof q!="function")return M(q);let K=S.get(q);return K===void 0&&(K=M(q),S.set(q,K)),K};for(const q of m)i.set(q,K=>X(K)[q]);return{readers:i,reset(){S=new WeakMap}}}class t{spec;read;kind;inferred;nullable;candidate=!1;distinct=null;change=null;reason="";constructor(p,r){this.spec=p,this.read=r,this.kind="object",this.inferred=!1,this.nullable=p.nullable!==!1}}class s{#e;#t=[];#n=null;#r;#s=0;#i;#a=!1;#l=!1;#o=0;#c;constructor(p,r={},i={}){this.#e=Array.isArray(p)?p:Array.from(p||[]),this.#i={...b,...i};const d=r.columns??[];this.#r=o(d,r.computed??null,r.context),this.#c=this.#e.length>=this.#i.columnarBelow,this.#u(d,r.computed??null),this.#n=new v(this.#t.map(h=>({id:h.spec.id,kind:h.kind,nullable:h.nullable,read:h.read,dictionary:h.spec.dictionary})),{initialCapacity:this.#i.initialCapacity,columnarBelow:this.#i.columnarBelow})}get store(){return this.#n}get done(){return this.#a||this.#l}get progress(){return this.#s}slice(){if(this.done)return!1;if(this.#i.signal?.aborted)return this.#l=!0,!1;const p=A(),{chunkMs:r,chunkRows:i}=this.#i,d=this.#e.length;do{const h=Math.min(this.#s+i,d);this.#n.append(this.#e.slice(this.#s,h)),this.#f(this.#s,h),this.#s=h,this.#r.reset(),this.#h(!1)}while(this.#s<d&&A()-p<r);return this.#o+=A()-p,this.#i.onProgress?.({loaded:this.#s,total:d}),this.#s>=d?(this.#h(!0),this.#a=!0,!1):!0}cancel(){this.#l=!0}result(){return{store:this.#n,schema:this.#t.map(p=>({id:p.spec.id,kind:p.kind,nullable:p.nullable,read:p.read,dictionary:p.spec.dictionary})),decisions:this.#t.map(p=>({id:p.spec.id,kind:p.kind,nullable:p.nullable,inferred:p.inferred,distinct:p.candidate||p.change?this.#d(p):null,change:p.change,reason:p.reason})),count:this.#n.count,elapsed:this.#o,cancelled:this.#l}}#u(p,r){const i=this.#e,d=Math.min(this.#i.sampleSize,i.length),h=this.#i.dictionaryRatio,a=r?.pure instanceof Set?r.pure:new Set(r?.pure??r?.order??[]);for(const y of p){if(!y||!y.id)continue;if(y.computed&&(y.pure===!1||r&&!a.has(y.id))){J(`ingest.impure.${y.id}`,`column "${y.id}" is an impure computed column and is not materialised into the store`);continue}const f=this.#r.readers.get(y.id)??(L(y.read)?y.read:_(y.field||y.id)),m=new t(y,f);if(y.kind)m.kind=y.kind,m.reason="declared by the caller";else if(y.dictionary)m.kind=y.multi?"multi":"dictionary",m.reason="value table supplied (lookup column)";else{const w=[];for(let M=0;M<d&&w.length<this.#i.sampleSize;M++){const X=f(i[M]);X!=null&&w.push(X)}m.inferred=!0;const S=c(w,{multi:y.multi});if(S==="text"){const M=new Set(w).size;m.kind=g(M,w.length,h),m.candidate=this.#c,m.reason=`sampled ${M} distinct in ${w.length}`}else m.kind=S,m.reason=`inferred from ${w.length} sampled values`,S==="object"&&w.length&&I(`ingest.mixed.${y.id}`,`column "${y.id}" holds mixed or unrecognised value types; storing as an object array. Declare a type to avoid this.`);m.kind==="object"&&m.candidate&&(m.distinct=new Set(w))}this.#t.push(m)}}#f(p,r){const i=this.#e;for(const d of this.#t){if(!d.candidate||!d.distinct)continue;const h=d.distinct;for(let a=p;a<r;a++){const y=d.read(i[a]);y!=null&&h.add(y)}}}#d(p){if(p.distinct)return p.distinct.size;const r=this.#n.column(p.spec.id);return r?.dict?r.dict.size:0}#h(p){const r=this.#i.dictionaryRatio,i=this.#e.length;for(const d of this.#t){if(!d.candidate)continue;const h=this.#d(d);if(d.kind==="dictionary"&&h>=r*i){const a=this.#n.column(d.spec.id);d.distinct=new Set(a?.dict?a.dict.values():[]),this.#n.convert(d.spec.id,"object"),d.kind="object",d.change="demoted",d.reason=`${h} distinct values is at or above ${r*100}% of ${i} rows`;continue}if(d.kind==="object"&&h>=r*i){d.candidate=!1,d.distinct=null,d.reason=`${h} distinct values is at or above ${r*100}% of ${i} rows`;continue}p&&d.kind==="object"&&h<r*i&&(this.#n.convert(d.spec.id,"dictionary"),d.kind="dictionary",d.change=d.change==="demoted"?null:"promoted",d.reason=`${h} distinct values is below ${r*100}% of ${i} rows`,d.distinct=null),p&&(d.candidate=!1)}}}async function l(n,p={},r={}){const i=new s(n,p,r),d=r.scheduler?.frame??V;for(;i.slice();)await new Promise(h=>{d(h)});return i.result()}function u(n,p={},r={}){const i=new s(n,p,{...r,chunkMs:1/0});for(;i.slice(););return i.result()}}),ze("packages/core/src/store/columnpack.js",function(e,B){"use strict";Object.defineProperty(e,"isPortableSchema",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"packChunk",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"packedTransfers",{enumerable:!0,get:function(){return g}});const A=B("packages/core/src/internal/paths.js").pathGetter,V=B("packages/core/src/store/ingest.js"),U=V.inferKind,I=V.decideText,J=V.INGEST_DEFAULTS,L=B("packages/core/src/store/columnstore.js").toFloat,Y=new Set(["float64","int32","bitset","dictionary","object","multi"]);function _(o){if(!Array.isArray(o)||o.length===0)return!1;for(const t of o)if(!t||typeof t.id!="string"||typeof t.field!="string"||t.field===""||t.kind&&!Y.has(t.kind))return!1;return!0}function O(o){const t=L(o);return Number.isFinite(t)?t|0:0}function v(o){return o==null?[]:Array.isArray(o)?o:[o]}function b(o,t,s,l){if(o.kind)return o.kind;const u=[];for(let r=0;r<t.length&&u.length<J.sampleSize;r++){const i=t[r];i!=null&&u.push(i)}const n=U(u,{multi:o.multi});if(n!=="text")return n;const p=new Set(u).size;return I(p,u.length,l)}function c(o,t,s={}){const l=t.length|0,u=s.dictionaryRatio??J.dictionaryRatio,n=[];for(const p of o){const r=A(p.field||p.id),i=p.nullable!==!1,d=new Array(l);for(let m=0;m<l;m++){const w=r(t[m]);d[m]=w===void 0?null:w}const h=b(p,d,l,u),a=i?new Uint8Array(l+7>>3):null,y=m=>{a&&(a[m>>3]|=1<<(m&7))};let f;switch(h){case"float64":{const m=new Float64Array(l);for(let w=0;w<l;w++){const S=d[w],M=S===null;M||y(w),m[w]=M?NaN:L(S)}f={id:p.id,kind:h,nullable:i,values:m,presence:a,offsets:null,table:null};break}case"int32":{const m=new Int32Array(l);for(let w=0;w<l;w++){const S=d[w],M=S===null;M||y(w),m[w]=M?0:O(S)}f={id:p.id,kind:h,nullable:i,values:m,presence:a,offsets:null,table:null};break}case"bitset":{const m=new Uint8Array(l+7>>3);for(let w=0;w<l;w++){const S=d[w],M=S===null;M||y(w),!M&&S&&(m[w>>3]|=1<<(w&7))}f={id:p.id,kind:h,nullable:i,values:m,presence:a,offsets:null,table:null};break}case"dictionary":{const m=new Uint32Array(l),w=[],S=new Map;for(let M=0;M<l;M++){const X=d[M];if(X===null){m[M]=0;continue}y(M);let q=S.get(X);q===void 0&&(q=w.length,w.push(X),S.set(X,q)),m[M]=q}f={id:p.id,kind:h,nullable:i,values:m,presence:a,offsets:null,table:w};break}case"multi":{const m=[],w=new Map,S=new Uint32Array(l+1),M=[];for(let X=0;X<l;X++){const q=d[X];S[X]=M.length,q===null||y(X);const P=v(q);for(let k=0;k<P.length;k++){const E=P[k];let C=w.get(E);C===void 0&&(C=m.length,m.push(E),w.set(E,C)),M.push(C)}}S[l]=M.length,f={id:p.id,kind:h,nullable:i,values:Int32Array.from(M),presence:a,offsets:S,table:m};break}default:{const m=new Array(l);for(let w=0;w<l;w++){const S=d[w];S!==null&&y(w),m[w]=S}f={id:p.id,kind:"object",nullable:i,values:m,presence:a,offsets:null,table:null};break}}n.push(f)}return{count:l,columns:n}}function g(o){const t=[];if(!o||!Array.isArray(o.columns))return t;const s=l=>{ArrayBuffer.isView(l)&&l.buffer&&!t.includes(l.buffer)&&t.push(l.buffer)};for(const l of o.columns)s(l.values),s(l.presence),s(l.offsets);return t}}),ze("packages/core/src/source/stream.js",function(e,B){"use strict";Object.defineProperty(e,"DEFAULT_PROMOTE_BELOW",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"createStreamSource",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"StreamSource",{enumerable:!0,get:function(){return C}});const A=B("packages/core/src/internal/lru.js").Lru,U=B("packages/core/src/internal/predicates.js").isFunction,I=B("packages/core/src/internal/schedule.js"),J=I.now,H=I.nextFrame,L=I.cancelFrame,Y=I.whenIdle,O=B("packages/core/src/internal/compare.js").defaultCompare,v=B("packages/core/src/internal/warn.js"),b=v.warnOnce,c=v.infoOnce,o=B("packages/core/src/internal/paths.js").getPath,t=B("packages/core/src/source/abort.js"),s=t.createAbortScope,l=t.isAbortError,u=B("packages/core/src/source/rows.js"),n=u.createRowFactory,p=u.lazyRowView,i=B("packages/core/src/source/gapbuffer.js").GapBuffer,h=B("packages/core/src/source/memory.js").createMemorySource,y=B("packages/core/src/source/filterwire.js").querySignature,m=B("packages/core/src/store/columnpack.js").isPortableSchema,w=25e4,S=Symbol("lattice.stream.storeBacked"),M=8,X=.1,q=1e3,K=50;function P(x){return Math.min(q,Math.max(K,Math.floor(x/4)))}function k(x){if(x instanceof Date)return x.getTime();if(typeof x=="number")return Number.isFinite(x)?x:NaN;if(typeof x=="string"){const j=x.trim();if(!j)return NaN;const T=Date.parse(j);return Number.isNaN(T)?Number(j):T}return NaN}function E(x,j){return new C(x,j)}class C{mode="stream";writesStore=!0;#e;#t;#n=[];#r=null;#s=[];#i=null;#a;#l;#o=new Map;#c=s();#u={loaded:0,estimated:void 0};#f=null;#d=0;#h=0;#p=0;#m=0;#g=null;#b=null;#y=null;#S=!1;#w=!1;#A=!1;#v=!1;#C="";#O=0;#P=0;#E=0;#T=null;#M=1/0;#N=!1;#R=null;#D=null;#G=null;#K=null;#L=!1;#q=0;#B=0;#Y=!1;constructor(j,T){this.#e=j||{mode:"stream"},this.#t=T||{},this.#a=n(this.#t),this.#l=new A(4096),this.#C=this.#qe();const F=(this.#t.config||{}).ingest;this.#L=!!F&&F.retainSource===!1,U(this.#e.open)||b("source.stream.open",'source.mode "stream" requires an open function; the grid will stay empty.'),this.#e.autoStart!==!1&&queueMicrotask(()=>this.start());const $=Number(this.#e.poll);Number.isFinite($)&&$>0&&(this.#K=setInterval(()=>{this.#v||this.reload()},$),this.#K&&U(this.#K.unref)&&this.#K.unref()),this.#I()}#z(){const j=Number(this.#e.maxAge);return Number.isFinite(j)&&j>0?j:0}#I(){const j=this.#z();if(!j)return;const T=this.#e.ageBy;U(T)?this.#D=T:typeof T=="string"&&T?this.#D=F=>o(F,T):this.#D=null,this.#T=[],this.#R=setInterval(()=>{this.#v||this.#W()&&(this.#Ee(),this.#U())},P(j)),this.#R&&U(this.#R.unref)&&this.#R.unref()}#W(){const j=this.#z();return!j||!this.#T?!1:this.#N?!0:this.#M<Date.now()-j*(1+X)}#ge(j,T){if(!this.#T)return;const F=this.#D?k(this.#D(T)):Date.now();this.#T[j]=F,Number.isNaN(F)||(F<this.#M&&(this.#M=F),F<Date.now()-this.#z()&&(this.#N=!0))}#ie(){return this.#Se("groupBy",[]).length>0?!0:!!this.#Se("pivotMode",!1)&&this.#Se("pivotBy",[]).length>0}#ue(){if(this.#g||this.#v)return;const j=this.#ie();if(j&&!this.#b){this.#b=h({mode:"memory",rows:this.#n},this.#Me()),this.#S=!1;return}!j&&this.#b&&(this.#b.destroy(),this.#b=null)}#Me(){if(this.#y)return this.#y;const j=this,T={liveIndices:()=>j.#fe(),live:F=>j.#n[F]!==void 0,source:F=>j.#ee(F),get physical(){return j.#n.length}};return this.#L&&(T.column=F=>{const $=j.#t.store;return $&&U($.column)?$.column(F):void 0}),this.#y=Object.create(this.#t,{store:{value:T,enumerable:!0,configurable:!0}}),this.#y}#fe(){const j=new Uint32Array(this.#n.length);let T=0;for(let F=0;F<this.#n.length;F++)this.#n[F]!==void 0&&(j[T++]=F);return j.subarray(0,T)}#oe(){return this.#g?this.#g:this.#b?(this.#S&&(this.#S=!1,this.#b.setRows(this.#n)),this.#b):null}invalidate(j="filter"){if(this.#g){this.#g.invalidate(j);return}this.#ue(),this.#b&&this.#b.invalidate(j),(j==="filter"||j==="sort")&&this.#Te()}count(){const j=this.#oe();return j?j.count():this.#r?this.#r.length:this.#O}matchCount(){const j=this.#oe();return j&&U(j.matchCount)?j.matchCount():this.#r?this.#r.length:this.#O}totalCount(){const j=this.#oe();return j&&U(j.totalCount)?j.totalCount():this.#O}unfilteredRows(){const j=this.#oe();if(j&&U(j.unfilteredRows))return j.unfilteredRows();const T=[];for(let F=0;F<this.#n.length;F++){if(!this.#n[F])continue;const $=this.#je(F);$&&T.push($)}return T}at(j){const T=this.#oe();if(T)return T.at(j);if(j<0||j>=this.count())return;const F=this.#r?this.#r.at(j):j,$=this.#je(F);return $.index=j,$}byKey(j){const T=this.#oe();if(T)return T.byKey(j);const F=this.#o.get(j);return F===void 0?void 0:this.#je(F)}leavesOf(j){const T=this.#oe();return T&&U(T.leavesOf)?T.leavesOf(j):[]}loaded(j){return j>=0&&j<this.count()}hint(j,T){if(this.#g){this.#g.hint(j,T);return}this.#Ue(),this.#p=Math.max(0,Math.floor(j))}#Ue(){this.#v||this.#qe()===this.#C||this.reload()}display(){const j=this.#oe();return j?j.display():p(()=>this.count(),T=>this.at(T))}apply(j){if(this.#g)return this.#g.apply(j);const T={added:[],updated:[],removed:[]};if(!j)return T;if(j.update){let F=!1;for(const $ of j.update){const D=this.#o.get(this.#a.keyOf($,-1));if(D===void 0)continue;const z=this.#Oe(D);this.#L?this.#Le(D,$):this.#n[D]=$,this.#l.delete(D),this.#ye(D,z),this.#T&&(this.#ge(D,$),F=!0),this.#S=!0,T.updated.push(this.#je(D))}F&&this.#Ee()}if(j.add&&j.add.length){const F=this.#ne(j.add);for(const $ of F)T.added.push(this.#je($))}return j.remove&&j.remove.length&&b("source.stream.remove","removing rows from a live stream is not supported; reload instead."),this.#U(),T}reload(j){this.#c.abortAll("reload"),this.#Ye(),this.#b&&(this.#b.destroy(),this.#b=null),this.#S=!1,this.#n=[],this.#r=null,this.#o.clear(),this.#l.clear(),this.#g=null,this.#O=0,this.#P=0,this.#E=0,this.#T&&(this.#T=[]),this.#M=1/0,this.#N=!1,this.#w=!1,this.#A=!1,this.#u={loaded:0,estimated:void 0},this.#C=this.#qe(),this.#Ce("model:changed",{reason:"reload"}),this.start()}destroy(){this.#v=!0,this.#K!==null&&(clearInterval(this.#K),this.#K=null),this.#R!==null&&(clearInterval(this.#R),this.#R=null),this.#T=null,this.#c.abortAll("destroyed"),this.#Ye(),this.#f!==null&&(this.#ke(this.#f),this.#f=null),this.#b&&(this.#b.destroy(),this.#b=null),this.#g&&this.#g.destroy(),this.#n=[],this.#r=null,this.#o.clear(),this.#l.clear()}async start(){if(this.#A||this.#v||!U(this.#e.open))return;this.#A=!0;const j=this.#c.begin("stream");this.#Te(),this.#ue();let T;try{T=this.#e.open({sort:this.#Se("sort",[]),filters:this.#Se("filters",null),quick:this.#Se("quick","")||void 0,context:this.#Se("context",null),signal:j.signal})}catch($){this.#Ce("source:error",{error:$});return}const F=U(T[Symbol.asyncIterator])?T[Symbol.asyncIterator]():T[Symbol.iterator]();this.#G=F;try{for(;;){const $=await F.next();if(!j.current||this.#v)return;if($.done){this.#$();return}if(await this.#xe($.value,j),!j.current||this.#v)return;if($.value&&$.value.done){this.#$();return}if(await this.#he(),!j.current||this.#v)return}}catch($){if(l($))return;this.#Ce("source:error",{error:$})}finally{j.settle()}}progress(){return{loaded:this.#u.loaded,estimated:this.#u.estimated,done:this.#w,live:this.#O,evicted:this.#P}}promoted(){return this.#g!==null}memorySource(){return this.#g}invalidateHandles(){const j=this.#oe();j&&(U(j.invalidateHandles)&&j.invalidateHandles(),U(j.invalidate)&&j.invalidate("sort"))}renderCount(){return this.#d}ingestStats(){return{worker:this.#q,inline:this.#B,storeBacked:this.#L}}#xe(j,T){if(!j)return;const F=j.rows;if(F&&F.length&&this.#ae(F))return this.#le(j,T);const $=J();F&&F.length&&(this.#ne(F),this.#B++),this.#Pe(j),this.#h+=J()-$,this.#U()}#Pe(j){this.#u.loaded=j.progress&&typeof j.progress.loaded=="number"?j.progress.loaded:this.#n.length,j.progress&&typeof j.progress.estimated=="number"&&(this.#u.estimated=j.progress.estimated)}#ae(j){if(this.#Y||this.#g)return!1;const T=this.#Z();if(!T)return!1;const F=this.#t.store;if(!F||!U(F.appendPacked))return!1;const $=this.#V();return!$||!m($)?(this.#Y=!0,c("source.stream.ingest-worker","stream ingest.useWorker is on but a column reads through a closure (a computed or date column); columnizing on the main thread instead."),!1):j.length<T.threshold?!1:!this.#Ae(j)}#Ae(j){if(!this.#a.keyed)return!1;const T=new Set;for(let F=0;F<j.length;F++){const $=this.#a.keyOf(j[F],this.#n.length+F);if($!=null){if(T.has($)||this.#o.has($))return!0;T.add($)}}return!1}async#le(j,T){const F=j.rows,$=this.#Z(),D=this.#V();let z;try{z=await $.columnize(D,F,{key:"ingest:stream",signal:T&&T.signal})}catch(ee){if(l(ee)||(b("source.stream.columnize","worker columnization failed; columnizing on the main thread",ee),this.#Y=!0,T&&(!T.current||this.#v)))return;this.#ne(F),this.#B++,this.#Pe(j),this.#U();return}if(T&&(!T.current||this.#v))return;const G=this.#t.store,N=this.#L?void 0:F,{from:Z}=G.appendPacked(z,N),Q=z.count|0;for(let ee=0;ee<Q;ee++){const re=Z+ee,ie=F[ee],ce=this.#a.keyed?this.#a.keyOf(ie,re):null;if(this.#n[re]=this.#L?S:ie,this.#O++,this.#ge(re,ie),ce!==null&&this.#o.set(ce,re),!this.#r||!this.#we(re))continue;const ve=this.#de(re);this.#r.insert(ve,re),ve<=this.#p&&this.#m++}this.#S=!0,this.#Ee(),this.#q++,this.#Pe(j),this.#U()}#Z(){const j=this.#t.ingestWorker;return U(j)?j():null}#V(){const j=this.#t.storeSchema;return U(j)?j():null}#ne(j){const T=[],F=this.#t.store,$=new Array(j.length),D=[],z=new Set;for(let N=0;N<j.length;N++){const Z=this.#a.keyed?this.#a.keyOf(j[N],this.#n.length+D.length):null;$[N]=Z,!(Z!==null&&(this.#o.has(Z)||z.has(Z)))&&(Z!==null&&z.add(Z),D.push(j[N]))}let G=D.length&&F&&U(F.append)?F.append(D).from:this.#n.length;for(let N=0;N<j.length;N++){const Z=j[N],Q=$[N];if(Q!==null&&this.#o.has(Q)){const ie=this.#o.get(Q),ce=this.#Oe(ie);this.#L||(this.#n[ie]=Z,F&&U(F.setSource)&&F.setSource(ie,Z)),this.#Le(ie,Z),this.#l.delete(ie),this.#ge(ie,Z),this.#ye(ie,ce);continue}const ee=G++;if(this.#n[ee]=this.#L?S:Z,this.#O++,this.#ge(ee,Z),Q!==null&&this.#o.set(Q,ee),T.push(ee),!this.#r||!this.#we(ee))continue;const re=this.#de(ee);this.#r.insert(re,ee),re<=this.#p&&this.#m++}return this.#S=!0,this.#Ee(),T}#_(j){const T=this.#n[j];let F=!1;if(this.#r){const G=this.#be(j);G>=0&&G<=this.#p&&(F=!0)}else j<=this.#p&&(F=!0);const $=T===S?this.#ee(j):T,D=this.#a.keyed?this.#a.keyOf($,j):null;D!==null&&this.#o.get(D)===j&&this.#o.delete(D),this.#n[j]=void 0,this.#T&&(this.#T[j]=NaN),this.#l.delete(j);const z=this.#t.store;return z&&U(z.remove)&&z.remove(j),this.#O--,F}#Ee(){let j=0,T=0;const F=this.#pe();j+=F.dropped,T+=F.aboveAnchor;const $=this.#re();j+=$.dropped,T+=$.aboveAnchor,j&&(this.#S=!0,this.#P+=j,this.#Te(),this.#m-=T,this.#Ce("stream:evicted",{evicted:j,total:this.#P,live:this.#O}))}#re(){const j=this.#e.maxRows;if(!Number.isFinite(j)||j<=0||this.#O<=j)return{dropped:0,aboveAnchor:0};const T=Math.max(1,Math.floor(j*(1-X)));let F=0,$=0;for(;this.#O>T&&this.#E<this.#n.length;){const D=this.#E++;this.#n[D]!==void 0&&(this.#_(D)&&$++,F++)}return{dropped:F,aboveAnchor:$}}#pe(){const j=this.#z();if(!j||!this.#T||!this.#W())return{dropped:0,aboveAnchor:0};const T=Date.now()-j;let F=0,$=0,D=1/0;for(let z=this.#E;z<this.#n.length;z++){if(this.#n[z]===void 0)continue;const G=this.#T[z];if(!(Number.isNaN(G)||G===void 0)){if(G>=T){G<D&&(D=G);continue}this.#_(z)&&$++,F++}}for(this.#M=D,this.#N=!1;this.#E<this.#n.length&&this.#n[this.#E]===void 0;)this.#E++;return{dropped:F,aboveAnchor:$}}#be(j){if(!this.#r)return j;for(let T=0;T<this.#r.length;T++)if(this.#r.at(T)===j)return T;return-1}#Te(){this.#s=this.#Se("sort",[]),this.#i=this.#Se("filters",null);const j=Number.isFinite(this.#e.maxRows)&&this.#e.maxRows>0||this.#z()>0,T=this.#Se("where",null),F=(this.#t.config||{}).hostFilter,$=!!(T&&T.active)||!!(F&&U(F.active)&&F.active());if(!(j||this.#s.length>0||!!this.#i||!!this.#Se("quick","")||$)){this.#r=null;return}this.#r=new i(Math.max(64,this.#n.length+64));for(let z=0;z<this.#n.length;z++)this.#n[z]!==void 0&&this.#we(z)&&this.#r.insert(this.#de(z),z)}#we(j){const T=this.#ee(j);if(this.#i&&!this.#ve(this.#i,T))return!1;const F=String(this.#Se("quick","")||"").toLowerCase();if(F&&!this.#k(T).includes(F))return!1;const $=(this.#t.config||{}).hostFilter;if($&&U($.active)&&$.active()&&!$.passes(this.#je(j)))return!1;const D=this.#Se("where",null);if(D&&D.active){const z=this.#je(j);if(!D.passes(z.data,z.key))return!1}return!0}#ve(j,T){if(!j)return!0;const F=j;if(Array.isArray(F.conditions))return F.op==="or"?F.conditions.some(z=>this.#ve(z,T)):F.op==="not"?!F.conditions.some(z=>this.#ve(z,T)):F.conditions.every(z=>this.#ve(z,T));const $=j,D=(this.#t.compute||{}).testValue;return U(D)?!!D(this.#We(T,$.col),$,(this.#t.config||{}).locale):(b("source.stream.testValue","ctx.compute.testValue is unavailable; streamed rows are not filtered client-side."),!0)}#Oe(j){if(!this.#r)return-1;if(!this.#s.length)return this.#be(j);let T=0,F=this.#r.length;for(;T<F;){const $=T+F>>>1;this.#Q(this.#r.at($),j)<0?T=$+1:F=$}for(let $=T;$<this.#r.length;$++){const D=this.#r.at($);if(D===j)return $;if(this.#Q(D,j)>0)break}return this.#be(j)}#ye(j,T){if(!this.#r||!this.#s.length)return;const F=this.#we(j);if(T>=0&&this.#r.at(T)===j)this.#r.removeAt(T),T<=this.#p&&this.#m--;else if(T>=0)return;if(!F)return;const $=this.#de(j);this.#r.insert($,j),$<=this.#p&&this.#m++}#de(j){if(!this.#r||!this.#s.length)return this.#r?this.#r.length:0;let T=0,F=this.#r.length;for(;T<F;){const $=T+F>>>1;this.#Q(j,this.#r.at($))<0?F=$:T=$+1}return T}#Q(j,T){const F=this.#ee(j),$=this.#ee(T);for(const D of this.#s){const z=this.#Fe(D.col),G=this.#We(F,D.col),N=this.#We($,D.col),Q=(z&&z.value&&U(z.value.compare)?z.value.compare:O)(G,N);if(Q!==0)return D.dir==="desc"?-Q:Q}return 0}#$(){this.#w=!0,this.#u.loaded=this.#u.loaded||this.#n.length;const j=typeof this.#e.promoteToMemoryBelow=="number"?this.#e.promoteToMemoryBelow:w;!this.#L&&this.#n.length<j&&(this.#g=h({mode:"memory",rows:this.#n},this.#t),this.#R!==null&&(clearInterval(this.#R),this.#R=null),this.#b&&(this.#b.destroy(),this.#b=null)),this.#U(),this.#Ce("stream:end",{loaded:this.#n.length,promoted:this.#g!==null,threshold:j})}#U(){this.#f!==null||this.#v||(this.#f=this.#F(()=>{this.#f=null,this.#d++;const j=this.#m;this.#m=0,this.#h=0,this.#Ce("stream:chunk",{loaded:this.#u.loaded,estimated:this.#u.estimated,count:this.count(),renders:this.#d}),this.#Ce("model:changed",{reason:"stream",shiftAboveViewport:j,anchor:this.#p}),this.#Ce("rows:changed",{companion:!0,reason:"stream"})}))}#he(){return this.#d===0||this.#h<this.#se()?Promise.resolve():(this.#h=0,new Promise(j=>{const T=(this.#t.scheduler||{}).idle;U(T)?T(()=>j()):Y(()=>j())}))}#se(){return typeof this.#e.coalesceMs=="number"&&this.#e.coalesceMs>0?this.#e.coalesceMs:M}#F(j){const T=this.#t.scheduler||{};return U(T.frame)?T.frame(j):H(j)}#ke(j){const T=this.#t.scheduler||{};U(T.cancel)?T.cancel(j):L(j)}#ee(j){const T=this.#n[j];if(T!==void 0&&T!==S)return T;if(T===void 0)return;const F=this.#t.store;return F&&U(F.source)?F.source(j):void 0}#Le(j,T){const F=this.#t.store;if(!F||!U(F.set))return;const $=this.#V();if(Array.isArray($))for(const D of $){if(!D||!D.id)continue;const z=U(D.read)?D.read:G=>o(G,D.field||D.id);F.set(D.id,j,z(T))}}#je(j){let T=this.#l.get(j);return T||(T=this.#a.leaf(this.#ee(j),j),this.#l.set(j,T)),T}#We(j,T){const F=this.#Fe(T);return F&&U(F.getValue)?F.getValue(j):j?.[T]}#k(j){const T=this.#t.columns,F=T&&U(T.all)?T.all():[],$=[];for(const D of F){const z=U(D.getValue)?D.getValue(j):void 0;z!=null&&z!==""&&$.push(String(z))}return $.join(" ").toLowerCase()}#Fe(j){const T=this.#t.columns;return T&&U(T.get)?T.get(j):void 0}#Ye(){const j=this.#G;if(this.#G=null,j&&U(j.return))try{j.return()}catch{}}#qe(){return y({context:this.#Se("context",null)})}#Se(j,T){const F=this.#t.state;if(F&&U(F[j])){const $=F[j]();return $??T}return T}#Ce(j,T){const F=this.#t.emit;U(F)&&F(j,T)}}}),ze("packages/core/src/source/url.js",function(e,B){"use strict";Object.defineProperty(e,"DEFAULT_URL_BATCH",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"createUrlSource",{enumerable:!0,get:function(){return b}});const A=B("packages/core/src/internal/warn.js").warnOnce,V=B("packages/core/src/internal/predicates.js"),U=V.isObject,I=V.isFunction,H=B("packages/core/src/internal/paths.js").getPath,Y=B("packages/core/src/source/abort.js").isAbortError,_=500,O=new Set(["application/x-ndjson","application/ndjson","application/jsonlines","application/jsonl","application/x-jsonlines","text/x-ndjson"]),v=Symbol("lattice.url.skip");function b(a,y={}){const f=U(y)?y:{},m=I(f.fetch)?f.fetch:typeof globalThis<"u"&&I(globalThis.fetch)?globalThis.fetch:null,w=f.format==="json"||f.format==="ndjson"?f.format:void 0,S=typeof f.rowsPath=="string"&&f.rowsPath?f.rowsPath:void 0,M=I(f.map)?f.map:void 0,X=U(f.headers)?f.headers:void 0,q=Number.isFinite(f.batchSize)&&f.batchSize>0?Math.floor(f.batchSize):_,K=f.lenient===!0,P=Number.isFinite(f.poll)&&f.poll>0?Math.floor(f.poll):void 0,k=typeof a=="string"&&a.length>0;k||A("source.url.url","createUrlSource needs a URL string; the grid will stay empty.");async function*E(x={}){if(!k)return;if(!m)throw new Error("[lattice] createUrlSource: no fetch available — pass opts.fetch or run where globalThis.fetch exists.");const j=x&&x.signal;let T;try{T=await m(a,X?{signal:j,headers:X}:{signal:j})}catch(D){throw Y(D)?D:new Error(`[lattice] createUrlSource: request to ${a} failed — ${D&&D.message||D}`)}if(!T||!T.ok){const D=T?T.status:"no response";throw new Error(`[lattice] createUrlSource: ${D} for ${a}`)}const F=c(a,w,T),$=T.body&&I(T.body.getReader)?T.body.getReader():null;try{if(!$){const G=await T.text();(F||t(G,a))==="ndjson"?yield*r(null,null,G,0,T,a,q,K):yield*p(G,a,S,M);return}const D=new TextDecoder("utf-8");if(F==="json"){yield*p(await n($,D,""),a,S,M);return}if(F==="ndjson"){yield*r($,D,"",0,T,a,q,K);return}const z=await s($,D,a);z.format==="json"?yield*p(await n($,D,z.seed),a,S,M):yield*r($,D,z.seed,z.bytes,T,a,q,K)}finally{if($&&I($.cancel))try{await $.cancel()}catch{}}}const C={mode:"stream",open:E,autoStart:f.autoStart!==!1};return P!==void 0&&(C.poll=P),Number.isFinite(f.maxRows)&&(C.maxRows=f.maxRows),Number.isFinite(f.maxAge)&&(C.maxAge=f.maxAge),(typeof f.ageBy=="string"||I(f.ageBy))&&(C.ageBy=f.ageBy),Number.isFinite(f.coalesceMs)&&(C.coalesceMs=f.coalesceMs),Number.isFinite(f.promoteToMemoryBelow)&&(C.promoteToMemoryBelow=f.promoteToMemoryBelow),C}function c(a,y,f){if(y)return y;const m=g(a);if(m)return m;const w=f&&f.headers&&I(f.headers.get)?f.headers.get("content-type"):null;return o(w)}function g(a){const y=String(a).split(/[?#]/)[0].toLowerCase();if(y.endsWith(".ndjson")||y.endsWith(".jsonl"))return"ndjson";if(y.endsWith(".json"))return"json"}function o(a){if(!a)return;const y=a.split(";")[0].trim().toLowerCase();if(O.has(y))return"ndjson";if(y==="application/json"||y==="text/json"||y.endsWith("+json"))return"json"}function t(a,y){const f=a.replace(/^\s+/,""),m=l(f);if(m==="error")throw new Error(`[lattice] createUrlSource: could not tell JSON from NDJSON for ${y} — pass opts.format: 'json' | 'ndjson'.`);return m}async function s(a,y,f){let m="",w=0;for(;;){const{value:M,done:X}=await a.read();if(M&&(w+=M.byteLength,m+=y.decode(M,{stream:!0})),X){m+=y.decode();break}const q=m.replace(/^\s+/,"");if(q){if(q[0]==="[")return{format:"json",seed:m,bytes:w};if(q[0]!=="{"||m.indexOf(`
|
|
7
|
+
`||p==="\r"){n++;continue}if(p>="0"&&p<="9"){n=v(l,n,u);continue}if(p==="."&&l[n+1]>="0"&&l[n+1]<="9"){n=v(l,n,u);continue}if(p==='"'||p==="'"){n=b(l,n,u);continue}if(p==="["){const i=l.indexOf("]",n+1);if(i<0)throw new Y("a [column reference] was opened and never closed",n);u.push({kind:V,value:l.slice(n+1,i).trim(),at:n}),n=i+1;continue}if(O(p)){n=c(l,n,u);continue}const r=l.slice(n,n+2);if(H.includes(r)){u.push({kind:I,value:r==="!="?"<>":r,at:n}),n+=2;continue}if(L.includes(p)){u.push({kind:I,value:p,at:n}),n++;continue}throw new Y(`unexpected character ${JSON.stringify(p)}`,n)}return u.push({kind:J,value:null,at:l.length}),u}function O(l){return/[A-Za-z_À-]/.test(l)}function v(l,u,n){let p=u,r=!1;for(;p<l.length;){const i=l[p];if(i>="0"&&i<="9"){p++;continue}if(i==="."&&!r){r=!0,p++;continue}if((i==="e"||i==="E")&&/[0-9+-]/.test(l[p+1]||"")){for(p+=2;p<l.length&&l[p]>="0"&&l[p]<="9";)p++;break}break}return n.push({kind:ne,value:Number(l.slice(u,p)),at:u}),p}function b(l,u,n){const p=l[u];let r=u+1,i="";for(;r<l.length;){if(l[r]===p){if(l[r+1]===p){i+=p,r+=2;continue}return n.push({kind:A,value:i,at:u}),r+1}i+=l[r],r++}throw new Y("a string was opened and never closed",u)}function c(l,u,n){let p=u;for(;p<l.length&&/[A-Za-z0-9_.À-]/.test(l[p]);)p++;const r=l.slice(u,p);let i=p;for(;i<l.length&&l[i]===" ";)i++;return n.push({kind:l[i]==="("?U:V,value:r,at:u}),p}const g={"=":1,"<>":1,"<":1,"<=":1,">":1,">=":1,"+":2,"-":2,"*":3,"/":3,"^":4};function o(l){const u=String(l??"").replace(/^\s*=/,"");if(!u.trim())throw new Y("the formula is empty");const n=_(u);let p=0;const r=()=>n[p],i=()=>n[p++],d=S=>{const M=r();if(M.kind!==I||M.value!==S)throw new Y(`expected ${JSON.stringify(S)}`,M.at);p++},h=S=>{let M=a();for(;;){const X=r();if(X.kind!==I)break;const q=g[X.value];if(!q||q<S)break;p++;const K=h(X.value==="^"?q:q+1);M={kind:"bin",op:X.value,left:M,right:K}}return M},a=()=>{const S=r();return S.kind===I&&(S.value==="-"||S.value==="+")?(p++,{kind:"unary",op:S.value,arg:a()}):y()},y=()=>{let S=f();for(;r().kind===I&&r().value==="%";)p++,S={kind:"unary",op:"%",arg:S};return S},f=()=>{const S=i();if(S.kind===ne)return{kind:"num",value:S.value};if(S.kind===A)return{kind:"str",value:S.value};if(S.kind===V)return{kind:"ref",name:S.value};if(S.kind===U){d("(");const M=[];if(!(r().kind===I&&r().value===")"))for(;;){if(M.push(h(1)),r().kind===I&&r().value===","){p++;continue}break}return d(")"),{kind:"call",name:String(S.value).toUpperCase(),args:M}}if(S.kind===I&&S.value==="("){const M=h(1);return d(")"),M}throw S.kind===J?new Y("the formula ends unexpectedly",S.at):new Y(`unexpected ${JSON.stringify(S.value)}`,S.at)},m=h(1),w=r();if(w.kind!==J)throw new Y(`unexpected ${JSON.stringify(w.value)}: is an operator missing?`,w.at);return m}function t(l){const u=new Set,n=p=>{if(!(!p||typeof p!="object")){if(p.kind==="ref"){u.add(String(p.name));return}if(p.kind==="bin"){n(p.left),n(p.right);return}if(p.kind==="unary"){n(p.arg);return}if(p.kind==="call")for(const r of p.args)n(r)}};return n(l),[...u]}function s(l){return typeof l=="string"&&/^\s*=/.test(l)&&l.trim()!=="="}}),ze("packages/core/src/formula/evaluate.js",function(e,B){"use strict";Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"evaluateAst",{enumerable:!0,get:function(){return v}});const A=B("packages/core/src/formula/parse.js").FormulaError;function V(b){if(b==null||b==="")return 0;if(typeof b=="boolean")return b?1:0;if(b instanceof Date)return b.getTime();const c=typeof b=="number"?b:Number(String(b).replace(/[,\s]/g,""));if(!Number.isFinite(c))throw new A(`${JSON.stringify(b)} is not a number`);return c}function U(b){return b==null?"":String(b)}function I(b){if(typeof b=="boolean")return b;if(b==null||b==="")return!1;if(typeof b=="number")return b!==0;const c=String(b).trim().toLowerCase();return c==="false"||c==="no"||c==="0"?!1:c!==""}function J(b){const c=[];for(const g of b){if(Array.isArray(g)){for(const o of g)o!=null&&o!==""&&c.push(V(o));continue}g==null||g===""||c.push(V(g))}return c}function H(b,c){const g=10**c,o=b*g;return Math.sign(o)*Math.round(Math.abs(o)+Number.EPSILON*Math.abs(o))/g}function L(b,c){if(!b.length)return 0;const g=b.slice().sort((l,u)=>l-u),o=(g.length-1)*Math.min(1,Math.max(0,c)),t=Math.floor(o),s=Math.ceil(o);return t===s?g[t]:g[t]+(o-t)*(g[s]-g[t])}function Y(b,c){let g=0,o=0,t=0;for(const l of b){g++;const u=l-o;o+=u/g,t+=u*(l-o)}const s=c?g-1:g;return s>0?Math.sqrt(t/s):0}const _={SUM:b=>J(b).reduce((c,g)=>c+g,0),AVERAGE:b=>{const c=J(b);return c.length?c.reduce((g,o)=>g+o,0)/c.length:0},MIN:b=>{const c=J(b);return c.length?Math.min(...c):0},MAX:b=>{const c=J(b);return c.length?Math.max(...c):0},COUNT:b=>J(b).length,PRODUCT:b=>J(b).reduce((c,g)=>c*g,1),ROUND:b=>H(V(b[0]),b.length>1?V(b[1]):0),ROUNDDOWN:b=>{const c=10**(b.length>1?V(b[1]):0),g=V(b[0])*c;return(g<0?Math.ceil(g):Math.floor(g))/c},ROUNDUP:b=>{const c=10**(b.length>1?V(b[1]):0),g=V(b[0])*c;return(g<0?Math.floor(g):Math.ceil(g))/c},ABS:b=>Math.abs(V(b[0])),FLOOR:b=>Math.floor(V(b[0])),CEILING:b=>Math.ceil(V(b[0])),SQRT:b=>Math.sqrt(V(b[0])),POWER:b=>V(b[0])**V(b[1]),MOD:b=>{const c=V(b[1]);if(c===0)throw new A("MOD by zero");return(V(b[0])%c+c)%c},IF:b=>I(b[0])?b[1]:b.length>2?b[2]:!1,AND:b=>b.every(I),OR:b=>b.some(I),NOT:b=>!I(b[0]),COALESCE:b=>b.find(c=>c!=null&&c!=="")??null,CONCAT:b=>b.map(U).join(""),LEN:b=>U(b[0]).length,UPPER:b=>U(b[0]).toUpperCase(),LOWER:b=>U(b[0]).toLowerCase(),TRIM:b=>U(b[0]).trim(),LEFT:b=>U(b[0]).slice(0,b.length>1?V(b[1]):1),RIGHT:b=>{const c=b.length>1?V(b[1]):1;return c<=0?"":U(b[0]).slice(-c)},MEDIAN:b=>L(J(b),.5),PERCENTILE:b=>{const c=V(b[b.length-1]);return L(J(b.slice(0,-1)),c>1?c/100:c)},QUARTILE1:b=>L(J(b),.25),QUARTILE3:b=>L(J(b),.75),STDEV:b=>Y(J(b),!0),STDEVP:b=>Y(J(b),!1),VAR:b=>{const c=Y(J(b),!0);return c*c},VARP:b=>{const c=Y(J(b),!1);return c*c},COUNTDISTINCT:b=>{const c=new Set;for(const g of b){const o=Array.isArray(g)?g:[g];for(const t of o)t!=null&&t!==""&&c.add(t)}return c.size},IQR:b=>{const c=J(b);return L(c,.75)-L(c,.25)}};_.AVG=_.AVERAGE,_.CEIL=_.CEILING,_.POW=_.POWER,_.STDEVS=_.STDEV,_.PERCENTILEINC=_.PERCENTILE;function O(b,c){const g=Number(b),o=Number(c);if(b!==null&&b!==""&&c!==null&&c!==""&&Number.isFinite(g)&&Number.isFinite(o))return g<o?-1:g>o?1:0;const s=U(b).toLowerCase(),l=U(c).toLowerCase();return s<l?-1:s>l?1:0}function v(b,c={}){const g=typeof c.lookup=="function"?c.lookup:null,o=c.functions?{..._,...c.functions}:_,t=s=>{switch(s.kind){case"num":return s.value;case"str":return s.value;case"ref":{if(!g)throw new A(`there is no column called ${JSON.stringify(s.name)} here`);const l=g(String(s.name));if(l===void 0)throw new A(`there is no column called ${JSON.stringify(s.name)}`);return l}case"unary":{if(s.op==="%")return V(t(s.arg))/100;const l=V(t(s.arg));return s.op==="-"?-l:l}case"bin":{const l=s.op;if(l==="=")return O(t(s.left),t(s.right))===0;if(l==="<>")return O(t(s.left),t(s.right))!==0;if(l==="<")return O(t(s.left),t(s.right))<0;if(l==="<=")return O(t(s.left),t(s.right))<=0;if(l===">")return O(t(s.left),t(s.right))>0;if(l===">=")return O(t(s.left),t(s.right))>=0;const u=V(t(s.left)),n=V(t(s.right));if(l==="+")return u+n;if(l==="-")return u-n;if(l==="*")return u*n;if(l==="^")return u**n;if(l==="/"){if(n===0)throw new A("division by zero");return u/n}throw new A(`unknown operator ${JSON.stringify(l)}`)}case"call":{const l=c.lazy&&c.lazy[s.name];if(typeof l=="function")return l(s.args,t,c);const u=o[s.name];if(typeof u!="function")throw new A(`there is no function called ${s.name}`);return u(s.args.map(t),c)}default:throw new A("the formula could not be read")}};return t(b)}}),ze("packages/core/src/formula/index.js",function(e,B){"use strict";Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"tokenise",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"evaluateAst",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"rowLookup",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"evaluateFormula",{enumerable:!0,get:function(){return O}});const ne=B("packages/core/src/formula/parse.js"),A=ne.parseFormula,V=ne.referencesOf,U=ne.looksLikeFormula,I=ne.FormulaError,J=ne.tokenise,H=B("packages/core/src/formula/evaluate.js"),L=H.evaluateAst,Y=H.FUNCTIONS;function _(v){const{grid:b,row:c,data:g}=v||{},o=n=>String(n).toLowerCase().replace(/[\s_-]/g,""),t=b&&b.columns&&typeof b.columns.all=="function"?b.columns.all():[],s=b&&b.permissions,l=s&&typeof s.isReadable=="function"?n=>s.isReadable(n):()=>!0,u=new Set;for(const n of t)l(n)||(u.add(o(n.id)),n.field&&u.add(o(n.field)),n.title&&u.add(o(n.title)));return n=>{const p=o(n);if(u.has(p))throw new I(`"${n}" cannot be read`);for(const r of t)if(o(r.id)===p||r.field&&o(r.field)===p||r.title&&o(r.title)===p)return c&&b.rows&&typeof b.rows.value=="function"?b.rows.value(c.key,r.id):g?g[r.field||r.id]:void 0;if(g&&typeof g=="object"){for(const r of Object.keys(g))if(o(r)===p){if(!l(r))throw new I(`"${n}" cannot be read`);return g[r]}}}}function O(v,b={}){try{const c=A(v);return{ok:!0,value:L(c,{lookup:_(b),functions:b.formulaFunctions}),references:V(c)}}catch(c){return{ok:!1,error:c instanceof I?c.message:"the formula could not be read",at:c instanceof I?c.at:void 0}}}}),ze("packages/core/src/internal/version.js",function(e,B){"use strict";Object.defineProperty(e,"VERSION",{enumerable:!0,get:function(){return V}});const ne="1.115.2";async function A(){return ne}const V="1.115.2"}),ze("packages/core/src/internal/merge.js",function(e,B){"use strict";Object.defineProperty(e,"expand",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"toArray",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"merge",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"mergeRow",{enumerable:!0,get:function(){return H}});const A=B("packages/core/src/internal/predicates.js").isObject;function V(L,Y,_){if(L!==void 0)return L===!0?{enabled:!0,..._}:L===!1?{enabled:!1}:A(L)?L:{[Y]:L,enabled:!0}}function U(L){return L==null?[]:Array.isArray(L)?L:[L]}const I=Object.freeze(new Set(["__proto__","constructor","prototype"]));function J(L,Y){if(!A(L))return A(Y)?{...Y}:Y;if(!A(Y))return Y===void 0?L:Y;const _={...L};for(const O of Object.keys(Y)){if(I.has(O))continue;const v=Y[O];v!==void 0&&(_[O]=A(v)&&A(_[O])?J(_[O],v):v)}return _}function H(L,Y){if(!A(L)||!A(Y)||L===Y)return Y;const _=Object.create(Object.getPrototypeOf(L));return Object.assign(_,L,Y),_}}),ze("packages/core/src/internal/schedule.js",function(e,B){"use strict";Object.defineProperty(e,"now",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"nextFrame",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"cancelFrame",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"frameBatched",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"settleDebounce",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"whenIdle",{enumerable:!0,get:function(){return H}});function ne(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const A=typeof requestAnimationFrame=="function";function V(L){return A?requestAnimationFrame(L):setTimeout(()=>L(ne()),16)}function U(L){L!=null&&(A?cancelAnimationFrame(L):clearTimeout(L))}function I(L){let Y=null,_=null;const O=()=>{Y=null;const b=_;_=null,L(...b||[])},v=(...b)=>{_=b,Y===null&&(Y=V(O))};return v.cancel=()=>{U(Y),Y=null,_=null},v.flush=()=>{Y!==null&&(U(Y),O())},v}function J(L,Y){let _=null,O=null;const v=()=>{if(_=null,O===null)return;const g=O;O=null,L(...g),b()},b=()=>{_=setTimeout(v,Y),typeof _?.unref=="function"&&_.unref()},c=(...g)=>{_===null?(L(...g),b()):(O=g,clearTimeout(_),b())};return c.flush=()=>{if(_!==null&&clearTimeout(_),_=null,O===null)return;const g=O;O=null,L(...g)},c.cancel=()=>{_!==null&&clearTimeout(_),_=null,O=null},c.pending=()=>_!==null||O!==null,c}function H(L,Y=50){return typeof requestIdleCallback=="function"?requestIdleCallback(L,{timeout:Y}):setTimeout(()=>L({timeRemaining:()=>0,didTimeout:!0}),1)}}),ze("packages/core/src/internal/paths.js",function(e,B){"use strict";Object.defineProperty(e,"pathGetter",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"pathSetter",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"getPath",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"setPath",{enumerable:!0,get:function(){return J}});const ne=new Map;function A(H){let L=ne.get(H);if(L)return L;if(!H.includes("."))L=Y=>Y?.[H];else{const Y=H.split("."),_=Y.length;L=O=>{let v=O;for(let b=0;b<_;b++){if(v==null)return;v=v[Y[b]]}return v}}return ne.set(H,L),L}const V=new Map;function U(H){let L=V.get(H);if(L)return L;if(!H.includes("."))L=(Y,_)=>{Y!=null&&(Y[H]=_)};else{const Y=H.split("."),_=Y.length-1;L=(O,v)=>{let b=O;for(let c=0;c<_;c++){if(b==null)return;const g=Y[c];b[g]==null&&(b[g]={}),b=b[g]}b!=null&&(b[Y[_]]=v)}}return V.set(H,L),L}function I(H,L){return A(L)(H)}function J(H,L,Y){U(L)(H,Y)}}),ze("packages/core/src/internal/compare.js",function(e,B){"use strict";Object.defineProperty(e,"collator",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"defaultCompare",{enumerable:!0,get:function(){return V}});const ne=new Map;function A(U,I){const J=`${U||""}|${I?JSON.stringify(I):""}`;let H=ne.get(J);return H||(H=new Intl.Collator(U||void 0,{numeric:!0,sensitivity:"variant",...I}),ne.set(J,H)),H}function V(U,I){if(U===I)return 0;if(U==null)return 1;if(I==null)return-1;if(typeof U=="number"&&typeof I=="number")return Number.isNaN(U)?Number.isNaN(I)?0:1:Number.isNaN(I)||U<I?-1:U>I?1:0;const J=String(U),H=String(I);return J<H?-1:J>H?1:0}}),ze("packages/core/src/defaults.js",function(e,B){"use strict";Object.defineProperty(e,"defaults",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"applyDefaults",{enumerable:!0,get:function(){return O}});const A=B("packages/core/src/internal/predicates.js").isObject,U=B("packages/core/src/internal/merge.js").merge,J=B("packages/core/src/internal/warn.js").warnOnce;let H=null;class L extends Error{}function Y(v,b=new Set){if(Array.isArray(v)){if(b.has(v))throw new L;b.add(v);const g=v.map(o=>Y(o,b));return b.delete(v),g}if(!A(v)||Object.getPrototypeOf(v)!==Object.prototype&&Object.getPrototypeOf(v)!==null)return v;if(b.has(v))throw new L;b.add(v);const c={};for(const[g,o]of Object.entries(v))c[g]=Y(o,b);return b.delete(v),c}function _(v){if(v===void 0)return Y(H??{});if(v===null)return H=null,{};if(!A(v))return J("defaults:type",`defaults() expects a configuration object, or null to clear it, but got ${Array.isArray(v)?"an array":typeof v}. The call was ignored and the defaults are unchanged.`),Y(H??{});try{H=Y(v)}catch(b){if(!(b instanceof L))throw b;return J("defaults:cyclic","defaults() expects a configuration object with no circular references, but the object passed refers back to itself. The call was ignored and the defaults are unchanged."),Y(H??{})}return Y(H)}function O(v){return H===null?v:U(Y(H),v)}}),ze("packages/core/src/internal/uid.js",function(e,B){"use strict";Object.defineProperty(e,"uid",{enumerable:!0,get:function(){return A}});let ne=0;function A(V="l"){return`${V}${(++ne).toString(36)}`}}),ze("packages/core/src/events/names.js",function(e,B){"use strict";Object.defineProperty(e,"EVENT_NAMES",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"isKnownEvent",{enumerable:!0,get:function(){return V}});const ne=Object.freeze(["ready","destroy","render:first","render:done","config:changed","licence:changed","model:changed","rows:changed","rows:queued","rows:deferred","rows:paused","rows:resumed","row:received","row:sent","row:copied","row:moved","source:error","source:total","stream:chunk","stream:end","stream:evicted","rowDrag:started","rowDrag:moved","rowDrag:left","rowDrag:ended","beforeRowDrop","rowDrop:cancelled","rowDrop","cell:changed","cell:pending","cell:confirmed","cell:reverted","cell:conflict","cell:clicked","cell:dblclicked","cell:contextmenu","cell:mouseover","cell:mouseout","cell:mousedown","cell:mouseup","cell:edit:start","cell:edit:end","row:edit:start","row:edit:end","row:clicked","row:dblclicked","row:pending","row:confirmed","row:reverted","row:conflict","form:opened","form:closed","form:saved","form:error","sort:changed","filter:changed","group:toggled","facet:computed","facet:filtered","facet:expanded","facet:failed","column:moved","column:resized","column:visible","column:pinned","column:grouped","column:pivoted","column:filter:open","column:profile:open","column:compareGroups:open","column:menu:open","explain:open","columns:changed","columns:tagged","columngroup:changed","header:contextmenu","totals:contextmenu","pivot:drill","selection:changed","range:changed","clipboard:copy","page:changed","scroll","scroll:end","size:changed","detail:toggled","detail:cell:edit:start","detail:cell:edit:end","detail:row:edit:start","detail:row:edit:end","detail:cell:changed","toolpanel:focus","highlight:changed","find:changed","tree:loading","tree:loaded","tree:loadFailed","tree:loadAborted","state:changed","state:reset","history:changed","history:applied","views:changed","view:applied","view:saved","view:removed","view:renamed","view:default","validation:failed","validation:cleared","formatting:changed","redaction:changed","permissions:changed","presentation:changed","presentation:started","presentation:ended","presentation:view","presentation:scale","presentation:spotlight","presentation:captured","comment:added","comment:edited","comment:deleted","comment:failed","comment:resolved","comment:unresolved","comment:threadOpened","comment:threadClosed","comment:indexLoaded","presence:published","presence:joined","presence:updated","presence:left","presence:failed","presence:lockRefused","diff:changed","diff:swapped","timeline:attached","timeline:detached","timeline:seek","timeline:seeking","annotation:changed","export:progress","export:request","export:done","shortcuts:opened","shortcuts:closed","print:before","print:after","beforeEdit","beforeSort","beforeFilter","beforeColumnMove","beforeColumnResize","beforeColumnHide","beforeSelect","beforeRowAdd","beforeDelete","beforeRowMove","beforeGroup","beforeRowReceive","edit:cancelled","sort:cancelled","filter:cancelled","columnMove:cancelled","columnResize:cancelled","columnHide:cancelled","selection:cancelled","rowAdd:cancelled","delete:cancelled","rowMove:cancelled","group:cancelled","rowReceive:cancelled"]),A=new Set(ne);function V(U){return U==="*"||A.has(U)}}),ze("packages/core/src/events/bus.js",function(e,B){"use strict";Object.defineProperty(e,"WILDCARD",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"EventBus",{enumerable:!0,get:function(){return g}});const ne=B("packages/core/src/internal/warn.js"),A=ne.warnOnce,V=ne.DEV,I=B("packages/core/src/internal/uid.js").uid,H=B("packages/core/src/events/names.js").isKnownEvent,L="*";function Y(o,t){!V||H(t)||A(`bus.unknown:${t}`,`${o}('${t}') subscribes to an event the grid never raises, so the handler will never fire. Check the name against the EventName list — a common cause is a near miss such as 'row:click' for 'row:clicked'.`)}const _=new Set(["api","user","init","ai"]),O=new WeakMap;function v(o){let t=O.get(o);return t||(t=I("h"),O.set(o,t)),t}function b(){return typeof performance=="object"&&performance?performance.now():Date.now()}function c(o){if(!o||typeof o!="object")return{};const t={};for(const[s,l]of Object.entries(o))s!=="grid"&&(l==null?t[s]=String(l):Array.isArray(l)?t[s]=`[${l.length}]`:typeof l=="object"?t[s]=l.key?`row ${l.key}`:"{…}":typeof l=="function"?t[s]="[function]":t[s]=String(l).slice(0,60));return t}class g{#e=new Map;#t=!1;#n=[];#r=200;#s=new Map;#i=null;#a=!1;#l=0;constructor(t=null){this.#i=t}attach(t){this.#i=t}get grid(){return this.#i}get destroyed(){return this.#a}on(t,s){if(typeof s!="function")return A(`bus.handler:${t}`,`on('${t}') needs a function; ignored.`),()=>{};Y("on",t);let l=this.#e.get(t);return l||(l=[],this.#e.set(t,l)),l.push(s),()=>this.off(t,s)}once(t,s){if(typeof s!="function")return A(`bus.handler:${t}`,`once('${t}') needs a function; ignored.`),()=>{};Y("once",t);const l=u=>{this.off(t,s),s(u)};return this.#s.set(s,l),this.on(t,l)}off(t,s){if(s===void 0){this.#e.delete(t);return}const l=this.#e.get(t);if(!l)return;const u=this.#s.get(s),n=u&&l.includes(u)?u:s,p=l.indexOf(n);p>=0&&l.splice(p,1),u&&n===u&&this.#s.delete(s),l.length===0&&this.#e.delete(t)}count(t){const s=this.#e.get(t),l=t===L?null:this.#e.get(L);return(s?s.length:0)+(l?l.length:0)}#o(t,s,l,u,n){this.#n.push({type:t,origin:s,listeners:(u?u.length:0)+(n?n.length:0),payload:c(l),at:Date.now(),ms:0}),this.#n.length>this.#r&&this.#n.shift()}recordEvents(t,s){this.#t=!!t,Number.isFinite(s)&&s>0&&(this.#r=Math.floor(s)),t||(this.#n=[])}eventLog(){return this.#n.map(t=>({...t}))}clearEventLog(){this.#n=[]}counts(){const t={};for(const[s,l]of this.#e)t[s]=l.length;return t}emit(t,s,l){const u=l??(s&&s.origin),n=_.has(u)?u:"api",p={...s||null,type:t,origin:n,grid:this.#i};if(this.#a)return p;const r=this.#e.get(t),i=t===L?void 0:this.#e.get(L);if(this.#t&&this.#o(t,n,s,r,i),!r&&!i)return p;const d=this.#t?b():0;this.#l++;try{r&&this.#c(r.slice(),p,t),i&&this.#c(i.slice(),p,L)}finally{this.#l--,this.#t&&this.#n.length&&(this.#n[this.#n.length-1].ms=b()-d)}return p}emitBefore(t,s,l){const u=l??(s&&s.origin),n=_.has(u)?u:"user";let p=!1,r=null;const i=m=>{p=!0,m!=null&&r===null&&(r=String(m))},d={...s||null,type:t,origin:n,grid:this.#i,get defaultPrevented(){return p},get reason(){return r},preventDefault(m){i(m)}};if(this.#a)return!0;const h=this.#e.get(t);this.#t&&this.#o(t,n,s,h,void 0);const a=h?h.slice():[];if(a.length===0)return!0;const y=()=>(p&&r===null&&(r="prevented"),p&&s&&typeof s=="object"&&(s.reason=r),!p),f=[];for(const m of a)try{const w=m(d);w&&typeof w.then=="function"?f.push(w):w===!1&&i("prevented")}catch(w){i("error"),A(`bus.beforeThrow:${t}:${v(m)}`,`a '${t}' before-handler threw; the action was cancelled.`,w)}return f.length===0?y():Promise.allSettled(f).then(m=>{for(const w of m)w.status==="rejected"?(i("error"),A(`bus.beforeReject:${t}`,`a '${t}' before-handler rejected; the action was cancelled.`,w.reason)):w.value===!1&&i("prevented");return y()})}#c(t,s,l){for(let u=0;u<t.length;u++)try{t[u](s)}catch(n){A(`bus.throw:${l}:${v(t[u])}`,`a '${l}' handler threw; other handlers were unaffected.`,n)}}clear(){this.#e.clear(),this.#s.clear()}destroy(){this.clear(),this.#a=!0,this.#i=null}}}),ze("packages/core/src/registry/free-tier-notice.js",function(e,B){"use strict";Object.defineProperty(e,"FREE_TIER_NOTICE",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"WATERMARK_TEXT",{enumerable:!0,get:function(){return A}});const ne="Free for non-commercial use: latticegrid.dev/free",A="Unlicensed: Lattice Grid trial"}),ze("packages/core/src/registry/licence.js",function(e,B){"use strict";Object.defineProperty(e,"PRODUCT",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"LICENCE_VERSION",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"PUBLIC_KEY",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"fromBase64Url",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"toBase64Url",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"asciiBytes",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"parseLicence",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"hasEd25519",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"verifyLicence",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"isLocalHost",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"currentHost",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"matchesDomain",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"LicenceHolder",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"setLicence",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"licenceInfo",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"watermark",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"licenceState",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"sharedLicence",{enumerable:!0,get:function(){return k}});const A=B("packages/core/src/internal/warn.js").warnOnce,V=B("packages/core/src/registry/free-tier-notice.js"),U=V.FREE_TIER_NOTICE;Object.defineProperty(e,"FREE_TIER_NOTICE",{enumerable:!0,get:function(){return V.FREE_TIER_NOTICE}});const I="lattice-grid",J=1,H="LG1",L=64,Y="GwmaCOkGedHulqsa-DOV1TU8On1rsalWv519c_dW4j4",_="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",O=(()=>{const E=new Int16Array(128).fill(-1);for(let C=0;C<_.length;C++)E[_.charCodeAt(C)]=C;return E[43]=62,E[47]=63,E})();function v(E){if(typeof E!="string")return null;let C="";for(let D=0;D<E.length;D++){const z=E.charCodeAt(D);if(z!==61){if(z>127||O[z]<0)return null;C+=E[D]}}const x=C.length;if(x%4===1)return null;const j=new Uint8Array(Math.floor(x*3/4));let T=0,F=0,$=0;for(let D=0;D<x;D++)T=T<<6|O[C.charCodeAt(D)],F+=6,F>=8&&(F-=8,j[$++]=T>>F&255);return $===j.length?j:j.subarray(0,$)}function b(E){let C="",x=0;for(;x+2<E.length;x+=3){const T=E[x]<<16|E[x+1]<<8|E[x+2];C+=_[T>>18&63]+_[T>>12&63]+_[T>>6&63]+_[T&63]}const j=E.length-x;if(j===1){const T=E[x]<<16;C+=_[T>>18&63]+_[T>>12&63]}else if(j===2){const T=E[x]<<16|E[x+1]<<8;C+=_[T>>18&63]+_[T>>12&63]+_[T>>6&63]}return C}function c(E){const C=new Uint8Array(E.length);for(let x=0;x<E.length;x++)C[x]=E.charCodeAt(x)&127;return C}function g(E){if(typeof TextDecoder=="function")return new TextDecoder().decode(E);let C="";for(let x=0;x<E.length;x++)C+=String.fromCharCode(E[x]);return C}function o(E){const C={ok:!1,reason:"malformed",product:null,issuedTo:null,expires:null,terms:null,features:[],deployments:[],version:0,message:null,signature:null,raw:typeof E=="string"?E:""};if(typeof E!="string"||E.length===0)return{...C,reason:"missing"};const x=E.trim(),j=x.split(".");if(j.length!==3)return C;const[T,F,$]=j;if(T!==H)return{...C,reason:"prefix"};const D=v(F),z=v($);if(!D||!z)return C;let G;try{G=JSON.parse(g(D))}catch{return C}return G===null||typeof G!="object"?C:{ok:!0,reason:null,product:typeof G.p=="string"?G.p:null,issuedTo:typeof G.t=="string"?G.t:null,expires:typeof G.e=="string"?G.e:null,terms:typeof G.terms=="string"?G.terms:null,features:Array.isArray(G.f)?G.f.slice():[],deployments:Array.isArray(G.d)?G.d.slice():[],version:typeof G.v=="number"?G.v:0,message:c(F),signature:z,raw:x}}function t(E,C){if(!E)return!1;const x=Date.parse(/^\d{4}-\d{2}-\d{2}$/.test(E)?`${E}T23:59:59.999Z`:E);return Number.isNaN(x)?!0:C>x}function s(E){return E==="non-commercial"?"non-commercial":"commercial"}let l=null,u=null,n=null;function p(){const E=globalThis.crypto;return E&&E.subtle?E.subtle:null}async function r(E){if(l&&u===E)return l;const C=p();if(!C)return null;const x=v(E);if(!x)return null;try{const j=await C.importKey("raw",x,{name:"Ed25519"},!1,["verify"]);return l=j,u=E,j}catch{return null}}async function i(){return n!==null||(n=await r(Y)!==null),n}async function d(E,C={}){const x=C.warn!==!1,j=C.product||I,T=C.publicKey||Y,F=C.now??Date.now(),$=C.host??a(),D=h($)?"":` ${U}`,z=o(E);if(!z.ok){const ee=z.reason==="missing"?"missing":"malformed";return x&&A(`licence.${ee}`,ee==="missing"?`no licence key supplied. The grid renders in full and carries a trial watermark on any host other than localhost. Get a key at latticegrid.dev.${D}`:`licence key could not be read. The grid will render with a watermark.${D}`),{valid:!1,reason:ee,terms:"commercial"}}const G={product:z.product||void 0,issuedTo:z.issuedTo||void 0,expires:z.expires||void 0,terms:s(z.terms)};if(z.product!==j)return x&&A("licence.product",`licence key is for '${z.product}', not '${j}'. The grid will render with a watermark.`),{valid:!1,...G,reason:"product"};if(t(z.expires,F))return x&&A("licence.expired",`licence expired on ${z.expires}. The grid will render with a watermark. Renew at latticegrid.dev.`),{valid:!1,...G,reason:"expired"};const N=z.deployments||[];if(N.length&&$&&!h($)&&!y($,N))return x&&A("licence.domain",`licence key is not valid for ${$}; it covers ${N.join(", ")}. The grid will render with a watermark.`),{valid:!1,...G,reason:"domain"};const Z=await r(T);if(!Z){const ee=!!z.signature&&z.signature.length===L;return x&&A("licence.algorithm","this host does not provide crypto.subtle Ed25519, so the licence signature could not be verified. A structural check was used instead."),ee?{valid:!0,...G,reason:"unverified"}:{valid:!1,...G,reason:"signature"}}let Q=!1;try{Q=await p().verify({name:"Ed25519"},Z,z.signature,z.message)}catch{Q=!1}return Q?{valid:!0,...G}:(x&&A("licence.signature","licence signature is not valid. The grid will render with a watermark."),{valid:!1,...G,reason:"signature"})}function h(E){const C=String(E??a()??"").trim().toLowerCase().replace(/^\[/,"").replace(/\]$/,"");return!C||C==="localhost"||C.endsWith(".localhost")||C==="::1"||C==="0:0:0:0:0:0:0:1"?!0:/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(C)}function a(){const E=globalThis.location;return E&&typeof E.hostname=="string"?E.hostname:null}function y(E,C){const x=f(E);return!x||!Array.isArray(C)?!1:C.some(j=>{const T=f(j);if(!T)return!1;if(T==="*")return!0;if(T.startsWith("*.")){const F=T.slice(2);return x===F||x.endsWith(`.${F}`)}return x===T})}function f(E){return String(E??"").trim().toLowerCase().replace(/\.$/,"")}class m{#e="";#t={valid:!1,reason:"missing",terms:"commercial"};#n=null;#r=null;#s;#i=new Set;constructor(C={}){this.#s=C}set(C){this.#e=typeof C=="string"?C.trim():"";const x=o(this.#e);return this.#t=x.ok?{valid:!t(x.expires,Date.now())&&x.product===(this.#s.product||I),product:x.product||void 0,issuedTo:x.issuedTo||void 0,expires:x.expires||void 0,terms:s(x.terms),reason:"pending"}:{valid:!1,reason:x.reason||"malformed",terms:"commercial"},this.#n=null,this.#e&&this.verify(),this.#t}verify(){if(this.#n)return this.#n;const C=this.#e;return this.#n=d(C,this.#s).then(x=>{if(this.#e===C){this.#t=x;for(const j of this.#i)j(x)}return x}),this.#n}onSettled(C){return this.#i.add(C),()=>this.#i.delete(C)}info(){return{...this.#t}}watermark(){return this.#t.valid?!1:!h(this.#r)}setHost(C){this.#r=C}state(){return this.#t.valid?"licensed":h(this.#r)?"localhost":"trial"}reset(){this.#e="",this.#t={valid:!1,reason:"missing",terms:"commercial"},this.#n=null,this.#i.clear()}}const w=Symbol.for("lattice-grid/licence/holder");function S(){const E=globalThis,C=E&&E[w];if(C&&typeof C.set=="function"&&typeof C.watermark=="function")return C;const x=new m;if(E)try{E[w]=x}catch{}return x}const M=S();function X(E){return M.set(E)}function q(){return M.info()}function K(){return M.watermark()}function P(){return M.state()}function k(){return M}}),ze("packages/core/src/registry/registry.js",function(e,B){"use strict";Object.defineProperty(e,"KINDS",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"REGIONS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"Registry",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"sharedRegistry",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"registerModules",{enumerable:!0,get:function(){return l}});const ne=B("packages/core/src/internal/warn.js"),A=ne.warnOnce,V=ne.DEV,I=B("packages/core/src/internal/predicates.js").isFunction,J=B("packages/core/src/registry/licence.js"),H=J.LicenceHolder,L=J.sharedLicence,Y=["renderer","editor","filter","dataType","totalFn","pipe","component"],_=["all","header","body","totals","panels"];class O{#e=new Map;#t=new Map;#n=new Set;#r=new Set;#s;#i=null;#a=null;#l=new Set;#o=new Map;constructor(n={}){for(const p of Y)this.#t.set(p,new Map);this.#s=n.holder||L(),this.#a=n.grid??null,this.#i=this.#s.onSettled(()=>{this.#f({reason:"licence",name:"licence",capabilities:this.capabilities(),regions:["all"]})}),n.licence&&this.setLicence(n.licence)}registerModules(n,p={}){p.licence&&this.setLicence(p.licence),p.grid!==void 0&&(this.#a=p.grid);const r=Array.isArray(n)?n:[n],i=[];for(const d of r){if(!d||typeof d!="object"||typeof d.name!="string"||!d.name){A("registry.module.shape","registerModules received something that is not a module; ignored.");continue}if(this.#e.has(d.name)){V&&this.#u(this.#e.get(d.name),d);continue}if(!I(d.install)){A(`registry.module.install:${d.name}`,`module '${d.name}' has no install() and was ignored.`);continue}const h={registry:this,grid:this.#a};try{d.install(h)}catch(a){A(`registry.module.throw:${d.name}`,`module '${d.name}' threw during install; it was not registered.`,a);continue}this.#e.set(d.name,d);for(const a of v(d))this.#n.add(a);i.push(d.name),this.#f({reason:"module",name:d.name,capabilities:this.capabilities(),regions:g(d)})}return i}unregisterModule(n){const p=this.#e.get(n);if(!p)return!1;if(I(p.uninstall))try{p.uninstall({registry:this,grid:this.#a})}catch(r){A(`registry.module.uninstall:${n}`,`module '${n}' threw during uninstall.`,r)}return this.#e.delete(n),this.#c(),this.#f({reason:"unmodule",name:n,capabilities:this.capabilities(),regions:g(p)}),!0}modules(){return[...this.#e.values()]}has(n){return this.#e.has(n)}#c(){this.#n.clear();for(const n of this.#e.values())for(const p of v(n))this.#n.add(p)}#u(n,p){!n||n===p||b(n,p)||A(`registry.module.reconfigure:${p.name}`,`module '${p.name}' was re-registered with different options; the first registration is kept and this call was ignored. Unregister it first if you mean to replace it.`)}capabilities(){return[...this.#n].sort()}can(n){return this.#n.has(n)}onChange(n){return I(n)?(this.#r.add(n),this.#o.set(n,this.#a),()=>{this.#r.delete(n),this.#o.delete(n)}):()=>{}}#f(n){for(const p of[...this.#r])try{p(n)}catch(r){A("registry.onChange.throw","a registry change handler threw.",r)}}register(n,p,r){const i=this.#t.get(n);if(!i){A(`registry.kind:${n}`,`unknown registry kind '${n}'; expected one of ${Y.join(", ")}.`);return}if(!p||typeof p!="string"){A(`registry.name:${n}`,`register('${n}', ...) needs a name.`);return}i.has(p)&&i.get(p)!==r&&A(`registry.replace:${n}:${p}`,`'${p}' was already registered as a ${n} and has been replaced.`),i.set(p,r),this.#f({reason:"register",name:p,kind:n,capabilities:this.capabilities(),regions:o(n)})}registerAll(n,p){if(p)for(const r of Object.keys(p))this.register(n,r,p[r])}get(n,p){const r=this.#t.get(n);return r?r.get(p):void 0}names(n){const p=this.#t.get(n);return p?[...p.keys()]:[]}#d(n,p){const r=this.#t.get(n).get(p);return r!==void 0?r:this.#t.get("component").get(p)}renderer(n){return this.#d("renderer",n)}editor(n){return this.#d("editor",n)}filter(n){return this.#d("filter",n)}dataType(n){return this.get("dataType",n)}totalFn(n){return this.get("totalFn",n)}pipe(n){return this.get("pipe",n)}setLicence(n){return this.#s.set(n)}licence(){return this.#s.info()}licenceVerified(){return this.#s.verify()}watermark(){return this.#s.watermark()}attach(n){n!=null&&(this.#l.add(n),this.#a=n)}detach(n){if(n!=null){this.#l.delete(n);for(const[p,r]of[...this.#o])r===n&&(this.#r.delete(p),this.#o.delete(p));if(this.#a===n){const p=this.#l.size?[...this.#l][this.#l.size-1]:null;this.#a=p}this.#l.size===0&&this.#i&&(this.#i(),this.#i=null)}}destroy(n){if(n!=null){this.detach(n);return}for(const p of[...this.#e.keys()])this.unregisterModule(p);this.#r.clear(),this.#o.clear(),this.#l.clear(),this.#i&&this.#i(),this.#i=null,this.#a=null}}function v(u){const n=u.capabilities,p=Array.isArray(n)?n.filter(r=>typeof r=="string"):[];return[u.name,...p]}function b(u,n){return u.install!==n.install||u.uninstall!==n.uninstall||(u.version||"")!==(n.version||"")?!1:c(v(u),v(n))&&c(g(u),g(n))}function c(u,n){const p=new Set(u),r=new Set(n);if(p.size!==r.size)return!1;for(const i of p)if(!r.has(i))return!1;return!0}function g(u){const n=u.regions;return!Array.isArray(n)||n.length===0?["all"]:n.filter(p=>_.includes(p))}function o(u){switch(u){case"filter":return["header"];case"totalFn":return["totals"];case"renderer":case"editor":case"pipe":return["body"];default:return["all"]}}const t=new O;function s(){return t}function l(u,n={}){return t.registerModules(u,n)}}),ze("packages/core/src/internal/text.js",function(e,B){"use strict";Object.defineProperty(e,"humanise",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"escapeHtml",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"titleCase",{enumerable:!0,get:function(){return U}});function ne(I){return I?(I.includes(".")?I.slice(I.lastIndexOf(".")+1):I).replace(/[_-]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").replace(/\s+/g," ").trim().replace(/^./,H=>H.toUpperCase()):""}const A={"&":"&","<":"<",">":">",'"':""","'":"'"};function V(I){const J=I==null?"":String(I);return/[&<>"']/.test(J)?J.replace(/[&<>"']/g,H=>A[H]):J}function U(I){return String(I).replace(/\w\S*/g,J=>J[0].toUpperCase()+J.slice(1).toLowerCase())}}),ze("packages/core/src/format/mask.js",function(e,B){"use strict";Object.defineProperty(e,"splitSections",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"parseSection",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return J}});const ne=new Set(["0","#","?",",","."]),A="\0";function V(L){const Y=[];let _="",O=!1;for(let v=0;v<L.length;v++){const b=L[v];if(b==="\\"){_+=b+(L[v+1]??""),v+=1;continue}if(b==='"'){O=!O,_+=b;continue}if(b===";"&&!O){Y.push(_),_="";continue}_+=b}return Y.push(_),Y}function U(L){let Y="",_="",O="",v=1,b=!1,c=!1;const g=i=>{c?_+=i:Y+=i};for(let i=0;i<L.length;i++){const d=L[i];if(d==="\\"){g(L[i+1]??""),i+=1;continue}if(d==='"'){const h=L.indexOf('"',i+1);g(h===-1?L.slice(i+1):L.slice(i+1,h)),i=h===-1?L.length:h;continue}if(d==="%"){v*=100,g("%");continue}if(d==="@"){b=!0,g("\0");continue}if(ne.has(d)){O+=d,c=!0;continue}g(d)}let o=-1;for(let i=O.length-1;i>=0;i--){const d=O[i];if(d==="0"||d==="#"||d==="?"){o=i;break}}let t=!1,s="";for(let i=0;i<O.length;i++){const d=O[i];if(d===","){i>o?v/=1e3:t=!0;continue}s+=d}const l=s.indexOf("."),u=l===-1?s:s.slice(0,l),n=l===-1?"":s.slice(l+1);let p=0;for(const i of u)i==="0"&&(p+=1);let r=0;for(const i of n)i==="0"&&(r+=1);return{prefix:Y,suffix:_,minInt:p,minDec:r,maxDec:n.length,grouping:t,scale:v,hasNumber:o!==-1,isText:b}}function I(L,Y){const _=new Intl.NumberFormat(Y,{minimumIntegerDigits:Math.max(L.minInt,1),minimumFractionDigits:L.minDec,maximumFractionDigits:Math.max(L.maxDec,L.minDec),useGrouping:L.grouping}),{prefix:O,suffix:v,scale:b,hasNumber:c}=L;return g=>{if(!c)return O+v;const o=b===1?g:g*b;return O+_.format(o)+v}}function J(L,Y){const O=V(String(L)).map(U),v=O.map(s=>I(s,Y)),b=0,c=O.length>1?1:-1,g=O.length>2?2:-1,o=O.length>3?3:-1,t=s=>{if(s==null||s==="")return"";if(typeof s!="number"||Number.isNaN(s)){const l=Number(s);if(Number.isNaN(l))return o===-1?String(s):(O[o].prefix+O[o].suffix).split("\0").join(String(s));s=l}return s===0&&g!==-1?v[g](0):s<0&&c!==-1?v[c](-s):v[b](s)};return t.spec={mask:L},{format:t,ooxml:H(String(L))}}function H(L){return L.trim()}}),ze("packages/core/src/format/pattern.js",function(e,B){"use strict";Object.defineProperty(e,"parseNumberPattern",{enumerable:!0,get:function(){return I}});const A=B("packages/core/src/format/mask.js").splitSections;function V(J){let H="",L="",Y="",_="",O=!1,v=!1,b=!1,c=!1;const g=t=>{b?L+=t:H+=t};for(let t=0;t<J.length;t++){const s=J[t];if(s==="\\"){g(J[t+1]??""),t+=1;continue}if(s==='"'){const l=J.indexOf('"',t+1);g(l===-1?J.slice(t+1):J.slice(t+1,l)),t=l===-1?J.length:l;continue}if(s==="%"){v=!0;continue}if(s==="0"||s==="#"){b=!0,c?_+=s:Y+=s;continue}if(s===","){c||(O=!0);continue}if(s==="."&&!c){c=!0;continue}g(s)}if(!b)return{hasDigit:!1,prefix:H,suffix:L,minDec:0,maxDec:0,grouping:!1,percent:v};let o=0;for(const t of _)t==="0"&&(o+=1);return{hasDigit:!0,prefix:H,suffix:L,minDec:o,maxDec:_.length,grouping:O,percent:v}}function U(J,H){const L=H.trim(),Y=J.trim();return L.startsWith("(")&&L.endsWith(")")&&L.slice(1,-1).trim()===Y?"parentheses":L.endsWith("-")?"suffix":"minus"}function I(J){if(typeof J!="string")return null;const H=A(J);if(H.length===0)return null;const L=V(H[0]);if(!L.hasDigit)return null;const Y={style:L.percent?"percent":"decimal",prefix:L.prefix,suffix:L.suffix,minDecimals:L.minDec,maxDecimals:Math.max(L.maxDec,L.minDec),thousandsSeparator:L.grouping?void 0:!1};if(H.length>1&&(Y.negative=U(H[0],H[1])),H.length>2){const _=V(H[2]);_.hasDigit||(Y.zeroDisplay=_.prefix+_.suffix)}return Y}}),ze("packages/core/src/format/number.js",function(e,B){"use strict";Object.defineProperty(e,"compileNumber",{enumerable:!0,get:function(){return H}});const A=B("packages/core/src/internal/predicates.js").isNil,U=B("packages/core/src/internal/warn.js").warnOnce,J=B("packages/core/src/format/pattern.js").parseNumberPattern;function H(L,Y){const _=typeof L=="string"?{pattern:L}:L||{};let O=_;if(typeof _.pattern=="string"){const S=J(_.pattern);if(S){const{pattern:M,...X}=_;O={...S,...X}}else U(`format:pattern:${_.pattern}`,`invalid number format pattern "${_.pattern}"; the value will use the default number format`)}const v=O.locale||Y||void 0,b=O.style||"decimal",c=typeof O.scale=="number"?O.scale:1,g=O.nullDisplay??"",o=O.zeroDisplay,t=O.prefix||"",s=O.suffix||"",l=O.negative||"minus",u=O.signed===!0,n={style:b,notation:O.notation||"standard"};b==="currency"&&(n.currency=O.currency||"USD",O.currencyDisplay&&(n.currencyDisplay=O.currencyDisplay)),typeof O.decimals=="number"?(n.minimumFractionDigits=O.decimals,n.maximumFractionDigits=O.decimals):(typeof O.minDecimals=="number"&&(n.minimumFractionDigits=O.minDecimals),typeof O.maxDecimals=="number"&&(n.maximumFractionDigits=O.maxDecimals),n.minimumFractionDigits>(n.maximumFractionDigits??20)&&(n.maximumFractionDigits=n.minimumFractionDigits)),O.thousandsSeparator===!1&&(n.useGrouping=!1),n.notation==="compact"&&(n.compactDisplay=O.compactDisplay||"short");const p=new Intl.NumberFormat(v,n),r=typeof O.thousandsSeparator=="string"?O.thousandsSeparator:null,i=typeof O.decimalSeparator=="string"?O.decimalSeparator:null;let d=",",h=".";if(r||i)for(const S of p.formatToParts(12345.6))S.type==="group"?d=S.value:S.type==="decimal"&&(h=S.value);const a=S=>{let M=S;return r&&(M=M.split(d).join("")),i&&(M=M.split(h).join("")),r&&(M=M.split("").join(r)),i&&(M=M.split("").join(i)),M},y=!!(r||i),f=t!==""&&b==="currency",m=S=>{let M;if(f){const X=p.formatToParts(S);let q=!1;M="";for(const K of X)M+=K.value,!q&&K.type==="currency"&&(M+=t,q=!0);q||(M=t+M)}else M=t+p.format(S);return y&&(M=a(M)),M+s},w=S=>{if(A(S)||S==="")return g;const M=typeof S=="number"?S:Number(S);if(Number.isNaN(M))return g;const X=c===1?M:M*c;return X===0&&o!==void 0?o:X<0?l==="parentheses"?`(${m(-X)})`:l==="suffix"?`${m(-X)}-`:m(X):u&&X>0?`+${m(X)}`:m(X)};return w.negativeClass=O.negativeClass||null,w.spec=O,w}}),ze("packages/core/src/format/date.js",function(e,B){"use strict";Object.defineProperty(e,"scanPattern",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"toDate",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"compilePattern",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"compileDate",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"toIsoDate",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"toIsoDateTime",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"compareIso",{enumerable:!0,get:function(){return s}});const A=B("packages/core/src/internal/predicates.js").isNil,U=B("packages/core/src/internal/warn.js").warnOnce,I=["yyyy","yy","MMMM","MMM","MM","M","dd","d","EEEE","EEE","HH","H","hh","h","mm","m","ss","s","SSS","a"];function J(l){const u=[];let n=0,p="";const r=()=>{p&&(u.push({token:null,text:p}),p="")};for(;n<l.length;){const i=l[n];if(i==="'"){if(l[n+1]==="'"){p+="'",n+=2;continue}const h=l.indexOf("'",n+1);if(h===-1){p+=l.slice(n+1),n=l.length;continue}p+=l.slice(n+1,h),n=h+1;continue}const d=I.find(h=>l.startsWith(h,n));if(d){r(),u.push({token:d,text:d}),n+=d.length;continue}/[A-Za-z]/.test(i)&&U(`date.pattern.token:${i}`,`the date pattern "${l}" contains '${i}', which is not a supported token, so it is rendered as text. Quote it as a literal to silence this. Supported: ${I.join(" ")}.`),p+=i,n+=1}return r(),u}const H=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?)?$/;function L(l){if(A(l)||l==="")return null;if(l instanceof Date)return Number.isNaN(l.getTime())?null:l;if(typeof l=="number")return Number.isNaN(l)?null:new Date(l);if(typeof l=="string"){const u=H.exec(l.trim());if(u){const[,p,r,i,d="0",h="0",a="0"]=u;return new Date(+p,+r-1,+i,+d,+h,+a)}const n=new Date(l);return Number.isNaN(n.getTime())?null:n}return null}function Y(l,u){return String(l).padStart(u,"0")}function _(l){if(!l)return p=>({year:p.getFullYear(),month:p.getMonth()+1,day:p.getDate(),hour:p.getHours(),minute:p.getMinutes(),second:p.getSeconds(),ms:p.getMilliseconds(),weekday:p.getDay()});const u=new Intl.DateTimeFormat("en-US",{timeZone:l,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,weekday:"short"}),n={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6};return p=>{const r={year:0,month:1,day:1,hour:0,minute:0,second:0,ms:p.getMilliseconds(),weekday:0};for(const i of u.formatToParts(p))switch(i.type){case"year":r.year=Number(i.value);break;case"month":r.month=Number(i.value);break;case"day":r.day=Number(i.value);break;case"hour":r.hour=Number(i.value)%24;break;case"minute":r.minute=Number(i.value);break;case"second":r.second=Number(i.value);break;case"weekday":r.weekday=n[i.value]??0;break;default:break}return r}}function O(l,u,n){const p=J(l),r=_(n),i=new Set(p.filter(f=>f.token).map(f=>f.token)),d=i.has("MMM")?new Intl.DateTimeFormat(u,{month:"short",timeZone:n}):null,h=i.has("MMMM")?new Intl.DateTimeFormat(u,{month:"long",timeZone:n}):null,a=i.has("EEE")?new Intl.DateTimeFormat(u,{weekday:"short",timeZone:n}):null,y=i.has("EEEE")?new Intl.DateTimeFormat(u,{weekday:"long",timeZone:n}):null;return f=>{const m=r(f);let w="";for(const S of p){if(!S.token){w+=S.text;continue}switch(S.token){case"yyyy":w+=Y(m.year,4);break;case"yy":w+=Y(m.year%100,2);break;case"MMMM":w+=h.format(f);break;case"MMM":w+=d.format(f);break;case"MM":w+=Y(m.month,2);break;case"M":w+=String(m.month);break;case"dd":w+=Y(m.day,2);break;case"d":w+=String(m.day);break;case"EEEE":w+=y.format(f);break;case"EEE":w+=a.format(f);break;case"HH":w+=Y(m.hour,2);break;case"H":w+=String(m.hour);break;case"hh":w+=Y(m.hour%12===0?12:m.hour%12,2);break;case"h":w+=String(m.hour%12===0?12:m.hour%12);break;case"mm":w+=Y(m.minute,2);break;case"m":w+=String(m.minute);break;case"ss":w+=Y(m.second,2);break;case"s":w+=String(m.second);break;case"SSS":w+=Y(m.ms,3);break;case"a":w+=m.hour<12?"AM":"PM";break;default:w+=S.text;break}}return w}}const v=[["year",365*24*36e5],["month",720*36e5],["week",168*36e5],["day",24*36e5],["hour",36e5],["minute",6e4],["second",1e3]];function b(l,u){const n=l||{},p=n.locale||u||void 0,r=n.nullDisplay??"",i=n.timeZone;let d;if(n.pattern)d=O(n.pattern,p,i);else if(n.dateStyle||n.timeStyle){const m={timeZone:i};n.dateStyle&&(m.dateStyle=n.dateStyle),n.timeStyle&&(m.timeStyle=n.timeStyle);const w=new Intl.DateTimeFormat(p,m);d=S=>w.format(S)}else{const m=new Intl.DateTimeFormat(p,{dateStyle:"medium",timeZone:i});d=w=>m.format(w)}const h=n.relative?new Intl.RelativeTimeFormat(p,{numeric:"auto"}):null,y=(typeof n.relative=="object"&&n.relative?n.relative.threshold??7:7)*24*36e5,f=(m,w)=>{const S=L(m);if(!S)return r;if(h){const M=w&&typeof w.now=="number"?w.now:Date.now(),X=S.getTime()-M;if(Math.abs(X)<y){for(const[q,K]of v)if(Math.abs(X)>=K||q==="second")return h.format(Math.round(X/K),q)}}return d(S)};return f.spec=n,f}function c(l){if(A(l)||l==="")return null;if(typeof l=="string"){const p=/^(\d{4}-\d{2}-\d{2})/.exec(l.trim());if(p)return p[1];const r=L(l);return r?c(r):null}const u=L(l);if(!u)return null;const n=p=>String(p).padStart(2,"0");return`${u.getFullYear()}-${n(u.getMonth()+1)}-${n(u.getDate())}`}function g(l,u){if(A(l)||l==="")return null;if(typeof l=="string"){const p=l.trim();if(o.test(p)){const d=L(p);return d?t(d,u):null}const r=/^(\d{4}-\d{2}-\d{2})[T ](\d{2}):(\d{2})(?::(\d{2}))?/.exec(p);if(r){const[,d,h,a,y]=r;return`${d}T${h}:${a}${y&&y!=="00"?`:${y}`:""}`}if(/^\d{4}-\d{2}-\d{2}$/.test(p))return`${p}T00:00`;const i=L(p);return i?g(i):null}const n=L(l);return n?t(n,u):null}const o=/(?:Z|[+-]\d{2}:?\d{2})$/i;function t(l,u){const n=d=>String(d).padStart(2,"0");if(u)try{const d=new Intl.DateTimeFormat("en-CA",{timeZone:u,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(l).reduce((y,f)=>(f.type!=="literal"&&(y[f.type]=f.value),y),{}),h=d.hour==="24"?"00":d.hour,a=Number(d.second);return`${d.year}-${d.month}-${d.day}T${h}:${d.minute}`+(a?`:${d.second}`:"")}catch{}const p=`${l.getFullYear()}-${n(l.getMonth()+1)}-${n(l.getDate())}`,r=l.getSeconds(),i=`${n(l.getHours())}:${n(l.getMinutes())}${r?`:${n(r)}`:""}`;return`${p}T${i}`}function s(l,u){const n=A(l)||l===""?null:String(l),p=A(u)||u===""?null:String(u);return n===null?p===null?0:1:p===null||n<p?-1:n>p?1:0}}),ze("packages/core/src/format/boolean.js",function(e,B){"use strict";Object.defineProperty(e,"toTriState",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"compileBoolean",{enumerable:!0,get:function(){return J}});const A=B("packages/core/src/internal/predicates.js").isNil,V={true:"☑",false:"☐",null:""},U={true:"◉",false:"◯",null:""};function I(H){if(A(H)||H==="")return null;if(typeof H=="boolean")return H;if(typeof H=="number")return H!==0;const L=String(H).trim().toLowerCase();return L==="true"||L==="yes"||L==="y"||L==="1"?!0:L==="false"||L==="no"||L==="n"||L==="0"?!1:null}function J(H,L){const Y=H||{},_=Y.display||"text",O=Y.trueLabel??"Yes",v=Y.falseLabel??"No",b=Y.nullLabel??"";let c=O,g=v;const o=b;_==="checkbox"?(c=V.true,g=V.false):_==="switch"?(c=U.true,g=U.false):_==="icon"&&(c=Y.trueIcon??O,g=Y.falseIcon??v);const t=s=>{const l=I(s);return l===null?o:l?c:g};return t.display=_,t.labels={true:O,false:v,null:b},t.locale=L,t.spec=Y,t}}),ze("packages/core/src/format/text.js",function(e,B){"use strict";Object.defineProperty(e,"compileText",{enumerable:!0,get:function(){return I}});const A=B("packages/core/src/internal/predicates.js").isNil,U=B("packages/core/src/internal/text.js").titleCase;function I(J,H){const L=J||{},Y=L.locale||H||void 0,_=L.nullDisplay??"",O=L.emptyDisplay??"",v=L.transform||"none",b=typeof L.truncate=="number"?{chars:L.truncate}:L.truncate||null,c=b?b.chars:0,g=b?b.ellipsis??"…":"",o=s=>{switch(v){case"upper":return Y?s.toLocaleUpperCase(Y):s.toUpperCase();case"lower":return Y?s.toLocaleLowerCase(Y):s.toLowerCase();case"title":return U(s);default:return s}},t=s=>{if(A(s))return _;let l=typeof s=="string"?s:String(s);return l===""?O:(v!=="none"&&(l=o(l)),c>0&&l.length>c&&(l=l.slice(0,c)+g),l)};return t.spec=L,t}}),ze("packages/core/src/format/shorthand.js",function(e,B){"use strict";Object.defineProperty(e,"looksLikeMask",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"looksLikeDatePattern",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"parseShorthand",{enumerable:!0,get:function(){return H}});const ne=["currency","number","percent","date","boolean","text","relative"],A=/[#0?@;"\\]/,V=/(yyyy|yy|MMMM|MMM|MM|EEEE|EEE|dd|HH|hh|mm|ss|SSS)/;function U(L){return typeof L!="string"||L===""||J(L)?!1:A.test(L)}function I(L){return typeof L!="string"||L===""||J(L)?!1:V.test(L)}function J(L){const Y=L.indexOf(":"),_=Y===-1?L:L.slice(0,Y);return ne.includes(_)?_:null}function H(L){const Y=J(L);if(!Y)return null;const _=L.indexOf(":"),O=_===-1?"":L.slice(_+1),v=O===""?[]:O.split(":");switch(Y){case"currency":{const b={type:"number",style:"currency",currency:v[0]||"USD"};return v[1]!==void 0&&v[1]!==""&&(b.decimals=Number(v[1])),b}case"number":{const b={type:"number",style:"decimal"};return v[0]!==void 0&&v[0]!==""&&(b.decimals=Number(v[0])),b}case"percent":{const b={type:"number",style:"percent"};return v[0]!==void 0&&v[0]!==""&&(b.decimals=Number(v[0])),b}case"date":return{type:"date",pattern:O||void 0};case"relative":return{type:"date",relative:!0};case"boolean":{const b=O.split("/"),c={type:"boolean",display:"text"};return b[0]!==void 0&&b[0]!==""&&(c.trueLabel=b[0]),b[1]!==void 0&&b[1]!==""&&(c.falseLabel=b[1]),b[2]!==void 0&&(c.nullLabel=b[2]),c}case"text":{const b={type:"text"};return v[0]&&(b.transform=v[0]),v[1]!==void 0&&v[1]!==""&&(b.truncate=Number(v[1])),b}default:return null}}}),ze("packages/core/src/format/index.js",function(e,B){"use strict";Object.defineProperty(e,"compileFormat",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"specToOoxml",{enumerable:!0,get:function(){return M}});const ne=B("packages/core/src/internal/predicates.js"),A=ne.isFunction,V=ne.isObject,I=B("packages/core/src/internal/warn.js").warnOnce,J=B("packages/core/src/format/number.js"),H=J.compileNumber,L=B("packages/core/src/format/date.js"),Y=L.compileDate,_=L.scanPattern,O=B("packages/core/src/format/boolean.js"),v=O.compileBoolean,b=B("packages/core/src/format/text.js"),c=b.compileText,g=B("packages/core/src/format/mask.js"),o=g.compileMask,t=B("packages/core/src/format/shorthand.js"),s=t.parseShorthand,l=t.looksLikeMask,u=t.looksLikeDatePattern,p=B("packages/core/src/format/pattern.js").parseNumberPattern;Object.defineProperty(e,"compileNumber",{enumerable:!0,get:function(){return J.compileNumber}}),Object.defineProperty(e,"compileDate",{enumerable:!0,get:function(){return L.compileDate}}),Object.defineProperty(e,"compilePattern",{enumerable:!0,get:function(){return L.compilePattern}}),Object.defineProperty(e,"scanPattern",{enumerable:!0,get:function(){return L.scanPattern}}),Object.defineProperty(e,"toDate",{enumerable:!0,get:function(){return L.toDate}}),Object.defineProperty(e,"compileBoolean",{enumerable:!0,get:function(){return O.compileBoolean}}),Object.defineProperty(e,"toTriState",{enumerable:!0,get:function(){return O.toTriState}}),Object.defineProperty(e,"compileText",{enumerable:!0,get:function(){return b.compileText}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return g.compileMask}}),Object.defineProperty(e,"splitSections",{enumerable:!0,get:function(){return g.splitSections}}),Object.defineProperty(e,"parseSection",{enumerable:!0,get:function(){return g.parseSection}}),Object.defineProperty(e,"parseShorthand",{enumerable:!0,get:function(){return t.parseShorthand}}),Object.defineProperty(e,"looksLikeMask",{enumerable:!0,get:function(){return t.looksLikeMask}}),Object.defineProperty(e,"looksLikeDatePattern",{enumerable:!0,get:function(){return t.looksLikeDatePattern}});const r=new Set(["decimal","currency","percent","unit"]),i=new Set(["type","locale"]),d={number:new Set(["style","currency","currencyDisplay","decimals","minDecimals","maxDecimals","thousandsSeparator","decimalSeparator","notation","compactDisplay","negative","negativeClass","signed","prefix","suffix","zeroDisplay","nullDisplay","messages","scale","pattern"]),date:new Set(["pattern","dateStyle","timeStyle","timeZone","relative","nullDisplay"]),boolean:new Set(["display","trueLabel","falseLabel","nullLabel","trueIcon","falseIcon"]),text:new Set(["transform","truncate","nullDisplay","emptyDisplay"])},h=new Set(["number","date","boolean","text"]);function a(P,k){const E=P.type;if(E===void 0||h.has(E)||!r.has(String(E)))return;const C=k?`"${k}"`:"with no id";I(`format:unknown-style-key:${k||""}:${E}`,`column ${C} has format: { type: "${E}" }, which is not a valid format type ("number", "date", "boolean" or "text") and is ignored; did you mean style: "${E}" instead?`)}function y(P,k,E){const C=d[k],x=E?`"${E}"`:"with no id";for(const j of P){if(i.has(j)||C.has(j))continue;const T=Object.keys(d).find(F=>F!==k&&d[F].has(j));T?I(`format:inapplicable:${E||""}:${j}`,`column ${x} has format key "${j}", which applies to a ${T} column, not the ${k} column it was applied to; it is ignored.`):I(`format:unknown:${E||""}:${j}`,`column ${x} has an unrecognised format key "${j}" for its ${k} format; it is ignored.`)}}function f(P){if(P.type==="number"||P.type==="date"||P.type==="boolean"||P.type==="text")return!0;const k=r.has(String(P.style));return!!(P.pattern||P.dateStyle||P.timeStyle||P.relative||P.timeZone||P.trueLabel||P.falseLabel||P.display||P.trueIcon||P.falseIcon||P.transform||P.truncate||P.emptyDisplay||k||P.currency||P.decimals!==void 0||P.minDecimals!==void 0||P.maxDecimals!==void 0||P.notation||P.negative||P.scale!==void 0||P.prefix||P.suffix||P.zeroDisplay!==void 0)}function m(P,k){if(P.type==="number"||P.type==="date"||P.type==="boolean"||P.type==="text")return P.type;if(P.pattern){if(l(P.pattern))return"number";if(u(P.pattern))return"date"}if(P.dateStyle||P.timeStyle||P.relative||P.timeZone)return"date";if(P.trueLabel||P.falseLabel||P.display||P.trueIcon||P.falseIcon)return"boolean";if(P.transform||P.truncate||P.emptyDisplay)return"text";if(P.style||P.currency||P.decimals!==void 0||P.minDecimals!==void 0||P.maxDecimals!==void 0||P.notation||P.negative||P.scale!==void 0||P.prefix||P.suffix||P.zeroDisplay!==void 0)return"number";const E=k&&k.base;return E==="number"?"number":E==="date"||E==="dateString"?"date":E==="boolean"?"boolean":"text"}function w(P,k=null,E=void 0,C=void 0,x=void 0){if(P==null||P==="")return null;const j=V(P)?Object.keys(P):null;if(typeof P=="function"){const $=(D,z)=>String(P({...z||{},value:D,locale:E})??"");return $.ooxml=k&&k.excel||"General",$}if(typeof P=="string"){if(l(P)){const{format:D,ooxml:z}=o(P,E);return D.ooxml=z,D}const $=s(P)||(u(P)?{type:"date",pattern:P}:null);return $?w($,k,E,C,x):(I(`format:${P}`,`unrecognised format string "${P}"; the value will be stringified`),null)}if(!V(P))return I("format:shape","format must be a spec object or a string; ignoring",P),null;if(k&&A(k.format)&&!f(P)||k&&A(k.format)&&Array.isArray(k.formatPatterns)&&P.type===void 0)return null;const T=m(P,k);T==="date"&&C&&P.timeZone===void 0&&(P={...P,timeZone:C}),a(P,x),y(j||Object.keys(P),T,x);let F;switch(T){case"number":F=H(P,E);break;case"date":F=Y(P,E);break;case"boolean":F=v(P,E);break;default:F=c(P,E);break}return F.ooxml=M(P,T,E,k),F.kind=T,F}const S={yyyy:"yyyy",yy:"yy",MMMM:"mmmm",MMM:"mmm",MM:"mm",M:"m",dd:"dd",d:"d",EEEE:"dddd",EEE:"ddd",HH:"hh",H:"h",hh:"hh",h:"h",mm:"mm",m:"m",ss:"ss",s:"s",SSS:"000",a:"AM/PM"};function M(P,k,E=void 0,C=null){if(k==="date"){if(P.pattern){let $="";for(const D of _(P.pattern))$+=D.token?S[D.token]??D.text:D.text;return $}return C&&C.excel||"yyyy-mm-dd"}if(k==="boolean")return"General";if(k==="text")return"@";if(typeof P.pattern=="string"&&p(P.pattern))return String(P.pattern).trim();if(P.notation==="compact"||P.notation==="scientific")return"General";const x=typeof P.decimals=="number"?P.decimals:typeof P.minDecimals=="number"?P.minDecimals:P.style==="currency"?2:0;let T=`${P.thousandsSeparator===!1?"":"#,#"}#0${x>0?`.${"0".repeat(x)}`:""}`,F="";return P.style==="currency"&&(F+=X(K(P.currency||"USD",E))),P.prefix&&(F+=X(P.prefix)),T=F+T,P.style==="percent"&&(T=`${T}%`),P.suffix&&(T+=X(P.suffix)),P.negative==="parentheses"?`${T};(${T})`:P.negative==="suffix"?`${T};${T}-`:T}function X(P){return`"${String(P).split('"').join("")}"`}const q=new Map;function K(P,k){const E=`${P}|${k||""}`;let C=q.get(E);if(C!==void 0)return C;C=P;try{const j=new Intl.NumberFormat(k,{style:"currency",currency:P}).formatToParts(0).find(T=>T.type==="currency");j&&(C=j.value)}catch{}return q.set(E,C),C}}),ze("packages/core/src/columns/types/temporal.js",function(e,B){"use strict";Object.defineProperty(e,"MS_SECOND",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"MS_MINUTE",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"MS_HOUR",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"MS_DAY",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"MS_WEEK",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"parseTime",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"toTimeMs",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"formatTime",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"zonedParts",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"zoneOffsetAt",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"instantFromParts",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"parseDateTime",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"toEpochMs",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"formatDateTime",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"parseDuration",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(e,"toDurationMs",{enumerable:!0,get:function(){return re}}),Object.defineProperty(e,"formatDuration",{enumerable:!0,get:function(){return he}}),Object.defineProperty(e,"zoneAbbrev",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(e,"resolveZoneName",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(e,"zoneLabel",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(e,"formatInstant",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(e,"bucketInstant",{enumerable:!0,get:function(){return we}}),Object.defineProperty(e,"timestampGroupProjector",{enumerable:!0,get:function(){return Te}}),Object.defineProperty(e,"TEMPORAL_TYPES",{enumerable:!0,get:function(){return Ne}}),Object.defineProperty(e,"TEMPORAL_INFERENCE_ORDER",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return $e}});const ne=B("packages/core/src/internal/predicates.js"),A=ne.isNil,V=ne.isFunction,U=B("packages/core/src/format/date.js"),I=U.toDate,J=U.compilePattern,H=U.compileDate,L=U.toIsoDateTime,Y=U.compareIso,_=864e5,O=Object.freeze({}),v=1e3,b=60*v,c=60*b,g=24*c,o=7*g,t=new WeakMap;function s(je,Ge){const Fe=je&&je.locale||"",Pe=je&&je.column;if(!Pe)return Fe?{locale:Fe}:O;const Ee=t.get(Pe);if(Ee&&Ee.locale===Fe)return Ee.bag;const Me=Pe.typeOptions||Pe[Ge]||(l(Pe.format)?Pe.format:null),Ie={...Me||O,locale:Me&&Me.locale||Fe||void 0};return t.set(Pe,{locale:Fe,bag:Ie}),Ie}function l(je){return je!==null&&typeof je=="object"&&!Array.isArray(je)&&!(je instanceof Date)}function u(je,Ge){const Fe=je===null||Number.isNaN(je)?null:je,Pe=Ge===null||Number.isNaN(Ge)?null:Ge;return Fe===null?Pe===null?0:1:Pe===null||Fe<Pe?-1:Fe>Pe?1:0}const n=/^(\d{1,2})(?:\s*[:.h]\s*(\d{1,2})(?:\s*[:.]\s*(\d{1,2})(?:[.,](\d{1,3}))?)?)?\s*(a\.?m\.?|p\.?m\.?|a|p)?$/i,p=/^(\d{3,6})$/;function r(je,Ge,Fe,Pe){return!(je>=0&&je<=23)||!(Ge>=0&&Ge<=59)||!(Fe>=0&&Fe<=59)||!(Pe>=0&&Pe<=999)?null:je*c+Ge*b+Fe*v+Pe}function i(je){if(A(je))return null;const Ge=String(je).trim();if(Ge==="")return null;const Fe=p.exec(Ge);if(Fe){const nt=Fe[1];if(nt.length===5)return null;const Qe=nt.length===3?1:2;return r(Number(nt.slice(0,Qe)),Number(nt.slice(Qe,Qe+2)),Number(nt.slice(Qe+2,Qe+4)||0),0)}const Pe=n.exec(Ge);if(!Pe)return null;let Ee=Number(Pe[1]);const Me=Number(Pe[2]||0),Ie=Number(Pe[3]||0),We=Pe[4]?Number(Pe[4].padEnd(3,"0")):0,Ye=Pe[5]?Pe[5][0].toLowerCase():null;if(Ye){if(Ee<1||Ee>12)return null;Ee=Ee%12,Ye==="p"&&(Ee+=12)}return r(Ee,Me,Ie,We)}function d(je){return A(je)||je===""?null:typeof je=="number"?Number.isFinite(je)?(je%g+g)%g:null:je instanceof Date?Number.isNaN(je.getTime())?null:je.getHours()*c+je.getMinutes()*b+je.getSeconds()*v+je.getMilliseconds():i(je)}const h=new Map;function a(je){const Ge=je.pattern||"",Fe=je.timeStyle||(je.seconds?"medium":"short"),Pe=`${je.locale||""}|${Ge}|${Fe}`;let Ee=h.get(Pe);if(Ee)return Ee;if(Ge)Ee=J(Ge,je.locale||void 0,"UTC");else{const Me=new Intl.DateTimeFormat(je.locale||void 0,{timeStyle:Fe,timeZone:"UTC"});Ee=Ie=>Me.format(Ie)}return h.set(Pe,Ee),Ee}function y(je,Ge){const Fe=Ge||O;if(je==null||typeof je!="number"||!Number.isFinite(je))return Fe.nullDisplay??"";const Pe=(je%g+g)%g;return a(Fe)(new Date(Pe))}function f(je){return je instanceof Date?!Number.isNaN(je.getTime()):typeof je=="number"?Number.isFinite(je)&&je>=0&&je<g:typeof je!="string"||!je.includes(":")?!1:i(je)!==null}function m(je){const Ge=d(je);return Ge==null?"":y(Ge,{pattern:Ge%v===0?"HH:mm:ss":"HH:mm:ss.SSS"})}const w=new Map;function S(je){const Ge=je||"";let Fe=w.get(Ge);return Fe||(Fe=new Intl.DateTimeFormat("en-GB",{timeZone:je||void 0,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}),w.set(Ge,Fe)),Fe}function M(je,Ge){const Fe={year:1970,month:1,day:1,hour:0,minute:0,second:0};for(const Pe of S(Ge).formatToParts(new Date(je)))Pe.type==="year"?Fe.year=Number(Pe.value):Pe.type==="month"?Fe.month=Number(Pe.value):Pe.type==="day"?Fe.day=Number(Pe.value):Pe.type==="hour"?Fe.hour=Number(Pe.value)%24:Pe.type==="minute"?Fe.minute=Number(Pe.value):Pe.type==="second"&&(Fe.second=Number(Pe.value));return Fe}function X(je,Ge){const Fe=M(je,Ge);return Date.UTC(Fe.year,Fe.month-1,Fe.day,Fe.hour,Fe.minute,Fe.second,0)-Math.floor(je/1e3)*1e3}function q(je,Ge){const Fe=je.hour||0,Pe=je.minute||0,Ee=je.second||0,Me=je.ms||0;if(!Ge)return new Date(je.year,je.month-1,je.day,Fe,Pe,Ee,Me).getTime();const Ie=Date.UTC(je.year,je.month-1,je.day,Fe,Pe,Ee,Me);let We=Ie-X(Ie,Ge);return We=Ie-X(We,Ge),We}const K=/(?:Z|[+-]\d{2}:?\d{2})$/i,P=/^(\d{4})-(\d{1,2})-(\d{1,2})(?:[T\s]+(.*))?$/;function k(je,Ge){if(A(je))return null;const Fe=String(je).trim();if(Fe==="")return null;const Pe=Ge&&Ge.timeZone||void 0;if(!K.test(Fe)){const Ee=P.exec(Fe);if(Ee){const Me=(Ee[4]||"").trim(),Ie=Me===""?0:i(Me);if(Ie===null)return null;const We=q({year:Number(Ee[1]),month:Number(Ee[2]),day:Number(Ee[3]),hour:Math.floor(Ie/c),minute:Math.floor(Ie/b)%60,second:Math.floor(Ie/v)%60,ms:Ie%v},Pe);return Number.isNaN(We)?null:new Date(We)}}return I(Fe)}function E(je){if(typeof je=="number")return Number.isFinite(je)?je:null;const Ge=I(je);return Ge?Ge.getTime():null}const C=new Map;function x(je){const Ge=[je.locale||"",je.pattern||"",je.dateStyle||"",je.timeStyle||"",je.timeZone||"",je.seconds?"1":""].join("|");let Fe=C.get(Ge);if(Fe)return Fe;const Pe=je.pattern?{type:"date",pattern:je.pattern,timeZone:je.timeZone}:{type:"date",dateStyle:je.dateStyle||"medium",timeStyle:je.timeStyle||(je.seconds?"medium":"short"),timeZone:je.timeZone};return Fe=H(Pe,je.locale||void 0),C.set(Ge,Fe),Fe}function j(je,Ge){const Fe=Ge||O,Pe=E(je);return Pe==null?Fe.nullDisplay??"":x(Fe)(Pe)}function T(je){return je instanceof Date?!Number.isNaN(je.getTime()):typeof je!="string"||!P.test(je.trim())?!1:k(je)!==null}const F=Object.freeze([{key:"w",ms:o,intl:"week",long:["week","weeks"],names:["w","wk","wks","week","weeks"]},{key:"d",ms:g,intl:"day",long:["day","days"],names:["d","dy","day","days"]},{key:"h",ms:c,intl:"hour",long:["hour","hours"],names:["h","hr","hrs","hour","hours"]},{key:"m",ms:b,intl:"minute",long:["minute","minutes"],names:["m","min","mins","minute","minutes"]},{key:"s",ms:v,intl:"second",long:["second","seconds"],names:["s","sec","secs","second","seconds"]},{key:"ms",ms:1,intl:"millisecond",long:["millisecond","milliseconds"],names:["ms","msec","msecs","milli","millis","millisecond","milliseconds"]}]),$=new Map;for(const je of F)for(const Ge of je.names)$.set(Ge,je);const D=Object.freeze(F.filter(je=>je.key!=="w")),z=/^(\d+(?:\.\d+)?)\s*([a-z]+)\s*(?:,\s*)?/,G=/^\d+(?:\.\d+)?$/,N=/^(\d+):([0-5]?\d)(?::([0-5]?\d))?(?:\.(\d{1,3}))?$/;function Z(je){const Ge=je&&je.defaultUnit?$.get(String(je.defaultUnit).toLowerCase()):null;return Ge?Ge.ms:b}function Q(je){return(je&&je.defaultUnit?$.get(String(je.defaultUnit).toLowerCase()):null)||$.get("m")}function ee(je,Ge){if(A(je))return null;let Fe=String(je).trim().toLowerCase();if(Fe==="")return null;let Pe=1;if(Fe[0]==="-"?(Pe=-1,Fe=Fe.slice(1).trim()):Fe[0]==="+"&&(Fe=Fe.slice(1).trim()),Fe==="")return null;const Ee=N.exec(Fe);if(Ee){const Ye=Ee[3]!==void 0,nt=Number(Ee[1])*c+Number(Ee[2])*b+(Ye?Number(Ee[3])*v:0)+(Ee[4]?Number(Ee[4].padEnd(3,"0")):0);return Pe*nt}if(G.test(Fe))return Math.round(Pe*Number(Fe)*Z(Ge||O));let Me=Fe,Ie=0,We=0;for(;Me!=="";){const Ye=z.exec(Me);if(!Ye)return null;const nt=$.get(Ye[2]);if(!nt)return null;Ie+=Number(Ye[1])*nt.ms,Me=Me.slice(Ye[0].length),We++}return We===0?null:Math.round(Pe*Ie)}function re(je){return A(je)||je===""?null:typeof je=="number"?Number.isFinite(je)?je:null:ee(je)}const ie=new Map;function ce(je,Ge,Fe){const Pe=`${Fe||""}|${Ge.intl}`;let Ee=ie.get(Pe);if(Ee===void 0){try{Ee=new Intl.NumberFormat(Fe||void 0,{style:"unit",unit:Ge.intl,unitDisplay:"long"})}catch{Ee=null}ie.set(Pe,Ee)}return Ee?Ee.format(je):`${je} ${je===1?Ge.long[0]:Ge.long[1]}`}function ve(je,Ge){return String(je).padStart(Ge,"0")}function he(je,Ge){const Fe=Ge||O;if(je==null||typeof je!="number"||!Number.isFinite(je))return Fe.nullDisplay??"";const Pe=Fe.style||"short",Ee=je<0;let Me=Math.round(Math.abs(je));const Ie=Ee?"-":"";if(Me===0&&Fe.zeroDisplay!=null)return Fe.zeroDisplay;if(Pe==="clock"){const Qe=Math.floor(Me/c),dt=Math.floor(Me/b)%60,jt=Math.floor(Me/v)%60;return`${Ie}${ve(Qe,2)}:${ve(dt,2)}:${ve(jt,2)}`}if(Me===0){const Qe=Q(Fe);return Pe==="long"?ce(0,Qe,Fe.locale):`0${Qe.key}`}const We=Fe.weeks===!0?F:D,Ye=typeof Fe.maxUnits=="number"&&Fe.maxUnits>0?Fe.maxUnits:Fe.maxUnits===void 0?2:1/0,nt=[];for(const Qe of We){if(nt.length>=Ye)break;const dt=Math.floor(Me/Qe.ms);dt!==0&&(Me-=dt*Qe.ms,nt.push(Pe==="long"?ce(dt,Qe,Fe.locale):`${dt}${Qe.key}`))}return Ie+nt.join(" ")}function ye(je){if(typeof je!="string")return!1;const Ge=je.trim();return Ge===""||N.test(Ge)||!/[a-z]/i.test(Ge)?!1:ee(Ge)!==null}const Oe=Date.UTC(1899,11,30),Le=new Map;function fe(je,Ge){const Fe=je||"";let Pe=Le.get(Fe);Pe||(Pe=new Intl.DateTimeFormat("en-GB",{timeZone:je||void 0,timeZoneName:"short",hour:"2-digit",hour12:!1}),Le.set(Fe,Pe));const Ee=typeof Ge=="number"?Ge:Date.now();for(const Me of Pe.formatToParts(new Date(Ee)))if(Me.type==="timeZoneName")return Me.value;return""}function ae(je){if(je)return je;try{return new Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function ke(je,Ge){const Fe=ae(je),Pe=fe(je,Ge);return Pe?`${Fe} (${Pe})`:Fe}function pe(je,Ge){if(je&&je.timeZone)return je.timeZone;const Fe=Ge&&Ge.grid;return(Fe&&V(Fe.get)?Fe.get("timeZone"):void 0)||void 0}function ue(je,Ge){const Fe=Ge||O,Pe=E(je);if(Pe==null)return Fe.nullDisplay??"";const Ee=x(Fe)(Pe);if(!Fe.showOrigin)return Ee;const Me=Fe.originZone;return Me?Me===(Fe.timeZone||ae(Fe.timeZone))?Ee:`${Ee} (${ke(Me,Pe)})`:`${Ee} (no origin recorded)`}function we(je,Ge,Fe,Pe){if(Ge==="instant"||!Ge)return je;const Ee=M(je,Fe);if(Ge==="month")return q({year:Ee.year,month:Ee.month,day:1},Fe);if(Ge==="week"){const Me=Pe>=1&&Pe<=7?Pe:1,We=((new Date(Date.UTC(Ee.year,Ee.month-1,Ee.day)).getUTCDay()+6)%7+1-Me+7)%7,Ye=new Date(Date.UTC(Ee.year,Ee.month-1,Ee.day-We));return q({year:Ye.getUTCFullYear(),month:Ye.getUTCMonth()+1,day:Ye.getUTCDate()},Fe)}return q({year:Ee.year,month:Ee.month,day:Ee.day},Fe)}function Te(je,Ge){const Fe=je&&je.group,Pe=Fe&&Fe.granularity||"day";if(Pe==="instant")return null;const Ee=Fe&&Fe.weekStart;return Me=>typeof Me=="number"?we(Me,Pe,Ge,Ee):Me}const Ne={time:{base:"number",storage:"float64",matches:f,format:je=>y(d(je.value),s(je,"time")),parse:je=>i(je.text),compare:(je,Ge)=>u(d(je),d(Ge)),defaults:{filter:"number",editor:"time",align:"start"},excel:"hh:mm:ss",excelKind:"number",toExcelValue:je=>{const Ge=d(je);return Ge===null?null:Ge/_},toStorage:je=>d(je),toClipboard:m,fromClipboard:i},datetime:{base:"dateString",storage:"dictionary",matches:T,format:je=>j(je.value,s(je,"datetime")),parse:je=>L(k(je.text,s(je,"datetime"))??je.text),compare:Y,defaults:{filter:"date",editor:"datetime",align:"start"},excel:"yyyy-mm-dd hh:mm",toStorage:(je,Ge)=>L(je,Ge&&Ge.timeZone),toClipboard:je=>A(je)?"":String(je),fromClipboard:je=>L(je)},duration:{base:"number",storage:"float64",matches:ye,format:je=>he(re(je.value),s(je,"duration")),parse:je=>ee(je.text,s(je,"duration")),compare:(je,Ge)=>u(re(je),re(Ge)),defaults:{filter:"number",editor:"duration",align:"end",total:"sum"},excel:"[h]:mm:ss",excelKind:"number",toExcelValue:je=>{const Ge=re(je);return Ge===null?null:Ge/_},toStorage:je=>re(je),toClipboard:je=>he(re(je),{style:"short",maxUnits:-1}),fromClipboard:je=>ee(je)},timestamp:{base:"number",storage:"float64",format:je=>{const Ge=s(je,"timestamp");return ue(je.value,{...Ge,timeZone:pe(Ge,je)})},parse:je=>{const Ge=s(je,"timestamp"),Fe=k(je.text,{timeZone:pe(Ge,je)});return Fe?Fe.getTime():null},compare:(je,Ge)=>u(E(je),E(Ge)),groupProjector:(je,Ge)=>Te(je,Ge),defaults:{filter:"date",editor:"datetime",align:"start"},excel:"yyyy-mm-dd hh:mm",excelKind:"number",toExcelValue:(je,Ge)=>{const Fe=E(je);if(Fe==null)return null;const Pe=M(Fe,Ge&&Ge.timeZone||void 0);return(Date.UTC(Pe.year,Pe.month-1,Pe.day,Pe.hour,Pe.minute,Pe.second)-Oe)/_},toStorage:je=>E(je),toClipboard:je=>{const Ge=E(je);return Ge==null?"":new Date(Ge).toISOString()},fromClipboard:je=>E(je)}},_e=["datetime","time","duration"],$e=Ne}),ze("packages/core/src/internal/lru.js",function(e,B){"use strict";Object.defineProperty(e,"Lru",{enumerable:!0,get:function(){return ne}});class ne{#e;#t=new Map;#n;constructor(V=256,U=null){this.#e=V,this.#n=U}get size(){return this.#t.size}get max(){return this.#e}set max(V){this.#e=V,this.#r()}has(V){return this.#t.has(V)}get(V){const U=this.#t;if(!U.has(V))return;const I=U.get(V);return U.delete(V),U.set(V,I),I}peek(V){return this.#t.get(V)}set(V,U){const I=this.#t;return I.has(V)&&I.delete(V),I.set(V,U),this.#r(),U}delete(V){const U=this.#t.get(V);return this.#t.delete(V)&&this.#n&&this.#n(U,V),U}clear(){if(this.#n)for(const[V,U]of this.#t)this.#n(U,V);this.#t.clear()}keys(){return this.#t.keys()}values(){return this.#t.values()}#r(){const V=this.#t;for(;V.size>this.#e;){const U=V.keys().next().value,I=V.get(U);V.delete(U),this.#n&&this.#n(I,U)}}}}),ze("packages/core/src/columns/types/network.js",function(e,B){"use strict";Object.defineProperty(e,"toUint32",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"parseIpv4",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"formatIpv4",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"isIpv4",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"compareIpv4",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"packCidr",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"cidrParts",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"parseCidr",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"formatCidr",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"isCidr",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"compareCidr",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"netmask",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"networkAddress",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"broadcastAddress",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"addressCount",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"hostCount",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"containsAddress",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"overlaps",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"ipv6Groups",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"parseIpv6",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"formatIpv6",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"isIpv6",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"compareIpv6",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"NETWORK_TYPES",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return E}});const A=B("packages/core/src/internal/predicates.js").isNil,U=B("packages/core/src/internal/lru.js").Lru,I=4294967295,J=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;function H(C){if(A(C))return null;if(typeof C=="string")return L(C);const x=Number(C);return Number.isFinite(x)?x<0?x<-2147483648?null:x>>>0:x>I?null:Math.trunc(x)>>>0:null}function L(C){if(A(C))return null;const x=String(C).trim();if(x==="")return null;const j=J.exec(x);if(!j)return null;let T=0;for(let F=1;F<=4;F++){const $=j[F];if($.length>1&&$.charCodeAt(0)===48)return null;const D=Number($);if(D>255)return null;T=T*256+D}return T}function Y(C){const x=H(C);return x===null?"":`${x>>>24&255}.${x>>>16&255}.${x>>>8&255}.${x&255}`}function _(C){return typeof C=="string"&&L(C)!==null}function O(C,x){const j=H(C),T=H(x);return j===null?T===null?0:1:T===null||j<T?-1:j>T?1:0}const v=64,b=I*v+32,c=/^(?:0|[1-9]\d?)$/;function g(C,x){return C*v+x}function o(C){if(A(C))return null;if(typeof C=="string"){const T=t(C);return T===null?null:o(T)}if(typeof C=="object"){const T=H(C.address),F=Number(C.prefix);return T===null||!Number.isInteger(F)||F<0||F>32?null:{address:T,prefix:F}}const x=Number(C);if(!Number.isInteger(x)||x<0||x>b)return null;const j=x%v;return j>32?null:{address:(x-j)/v,prefix:j}}function t(C){if(A(C))return null;const x=String(C).trim();if(x==="")return null;const j=x.indexOf("/");if(j<0)return null;const T=L(x.slice(0,j));if(T===null)return null;const F=x.slice(j+1).trim();if(!c.test(F))return null;const $=Number(F);return $>32?null:g(T,$)}function s(C){const x=o(C);return x?`${Y(x.address)}/${x.prefix}`:""}function l(C){return typeof C=="string"&&t(C)!==null}function u(C,x){const j=o(C),T=o(x);return j?T?j.address!==T.address?j.address<T.address?-1:1:j.prefix-T.prefix:-1:T?1:0}function n(C){return C===0?0:4294967295<<32-C>>>0}function p(C){const x=o(C);return x?(x.address&n(x.prefix))>>>0:null}function r(C){const x=o(C);return x?(x.address&n(x.prefix)|~n(x.prefix)>>>0)>>>0:null}function i(C){const x=o(C);return x?2**(32-x.prefix):null}function d(C){const x=o(C);return x?x.prefix===32?1:x.prefix===31?2:2**(32-x.prefix)-2:null}function h(C,x){const j=o(C);if(!j)return!1;const T=H(x);if(T===null)return!1;const F=n(j.prefix);return(T&F)>>>0===(j.address&F)>>>0}function a(C,x){const j=p(C),T=p(x);return j===null||T===null?!1:j<=r(x)&&T<=r(C)}const y=/^[0-9a-fA-F]{1,4}$/,f=new U(512);function m(C){if(A(C))return null;let x=String(C).trim();if(x==="")return null;const j=x.indexOf("%");if(j>=0&&(x=x.slice(0,j)),x==="")return null;if(x.indexOf(".")>=0){const G=x.lastIndexOf(":");if(G<0)return null;const N=L(x.slice(G+1));if(N===null)return null;x=`${x.slice(0,G+1)}${(N>>>16&65535).toString(16)}:${(N&65535).toString(16)}`}const T=x.split("::");if(T.length>2)return null;const F=w(T[0]);if(F===null)return null;if(T.length===1)return F.length===8?F:null;const $=w(T[1]);if($===null)return null;const D=8-F.length-$.length;if(D<1)return null;const z=F.slice();for(let G=0;G<D;G++)z.push(0);for(const G of $)z.push(G);return z}function w(C){if(C==="")return[];const x=[];for(const j of C.split(":")){if(!y.test(j))return null;x.push(parseInt(j,16))}return x}function S(C){if(typeof C!="string")return m(C);if(f.has(C))return f.get(C);const x=m(C);return f.set(C,x),x}function M(C){if(C[0]===0&&C[1]===0&&C[2]===0&&C[3]===0&&C[4]===0&&C[5]===65535)return`::ffff:${Y((C[6]<<16|C[7])>>>0)}`;let x=-1,j=0,T=-1,F=0;for(let z=0;z<8;z++)C[z]===0?(T<0?(T=z,F=1):F++,F>j&&(j=F,x=T)):(T=-1,F=0);if(j<2)return C.map(z=>z.toString(16)).join(":");const $=C.slice(0,x).map(z=>z.toString(16)).join(":"),D=C.slice(x+j).map(z=>z.toString(16)).join(":");return`${$}::${D}`}function X(C){const x=m(C);return x===null?null:M(x)}function q(C){return X(C)??""}function K(C){return typeof C=="string"&&C.indexOf(":")>=0&&m(C)!==null}function P(C,x){const j=S(C),T=S(x);if(!j)return T?1:0;if(!T)return-1;for(let F=0;F<8;F++)if(j[F]!==T[F])return j[F]<T[F]?-1:1;return 0}const k=Object.freeze({ipv4:{base:"number",storage:"int32",unsignedInt32:!0,matches:_,parse:C=>L(C.text),compare:O,format:C=>Y(C.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",excelKind:"string",toStorage:C=>H(C),toClipboard:C=>Y(C),fromClipboard:C=>L(C)},cidr:{base:"number",storage:"float64",matches:l,parse:C=>t(C.text),compare:u,format:C=>s(C.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",excelKind:"string",toStorage:C=>{const x=o(C);return x===null?null:g(x.address,x.prefix)},toClipboard:C=>s(C),fromClipboard:C=>t(C)},ipv6:{base:"text",storage:"dictionary",matches:K,parse:C=>X(C.text),compare:P,format:C=>q(C.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",toStorage:C=>X(C),toClipboard:C=>q(C),fromClipboard:C=>X(C)}}),E=k}),ze("packages/core/src/i18n/catalogue.js",function(e,B){"use strict";Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return I}});const ne=B("packages/core/src/registry/free-tier-notice.js"),A=ne.FREE_TIER_NOTICE,V=ne.WATERMARK_TEXT,U=Object.freeze({"count.rows":{one:"{count} row",other:"{count} rows"},"count.comments":{one:"{count} comment",other:"{count} comments"},"comments.someUnresolved":"{comments}, {unresolved} unresolved","comments.allResolved":"{comments}, all resolved","count.unresolvedComments":{one:"{count} unresolved comment",other:"{count} unresolved comments"},"count.items":{one:"{count} item",other:"{count} items"},"count.keys":{one:"{count} key",other:"{count} keys"},"count.values":{one:"value",other:"values"},"count.waiting":{one:"{count} waiting",other:"{count} waiting"},"count.rowsAdded":{one:"{count} row added",other:"{count} rows added"},"count.rowsRemoved":{one:"{count} row removed",other:"{count} rows removed"},"value.empty":"empty","a11y.sort.cleared":"Sort cleared","a11y.sort.by":"Sorted by {columns}","a11y.sort.column":"{column} {direction}","a11y.sort.ascending":"ascending","a11y.sort.descending":"descending","a11y.filter.cleared":"Filter cleared, {rows}","a11y.filter.applied":"Filtered to {shown} of {total}","a11y.find.count":{one:"{current} of {count} match",other:"{current} of {count} matches"},"a11y.find.countLoaded":{one:"{current} of {count} match in loaded rows",other:"{current} of {count} matches in loaded rows"},"a11y.find.none":"No matches","a11y.find.noneLoaded":"No matches in loaded rows","a11y.selection.cleared":"Selection cleared","a11y.selection.count":{one:"{count} row selected",other:"{count} rows selected"},"tabs.tablist":"Tabs","a11y.tabs.selected":"{label} tab selected","a11y.scrollbar.horizontal":"Horizontal scrollbar","a11y.scrollbar.vertical":"Vertical scrollbar","designer.canvas":"Dashboard canvas","designer.chrome":"Designer tools","designer.page":"Page {n}","a11y.designer.edit":"Edit mode","a11y.designer.view":"View mode","layout.region":"Dashboard layout","layout.move":"Move {title}","layout.resize":"Resize {title}","layout.close":"Close {title}","a11y.layout.grabbed":"{title} grabbed, column {x} of {columns}, row {y}","a11y.layout.position":"{title}, column {x} of {columns}, row {y}","a11y.layout.dropped":"{title} dropped, column {x} of {columns}, row {y}","a11y.layout.cancelled":"{title} move cancelled","a11y.layout.resizeCancelled":"{title} resize cancelled","a11y.layout.reverted":"{title} returned to column {x}, row {y}","a11y.layout.resizeGrabbed":"{title} resize grabbed, {w} by {h} cells","a11y.layout.resizeStep":"{title}, {w} by {h} cells","a11y.layout.resized":"{title} resized to {w} by {h} cells","a11y.layout.closed":"{title} closed","layout.maximise":"Maximise {title}","layout.minimise":"Minimise {title}","layout.restore":"Restore {title}","a11y.layout.maximised":"{title} maximised, filling the dashboard; press Escape to restore it","a11y.layout.minimised":"{title} minimised","a11y.layout.restored":"{title} restored to column {x}, row {y}","a11y.group.cleared":"Grouping cleared","a11y.group.by":"Grouped by {columns}","a11y.group.expanded":"{label} expanded, {rows} shown","a11y.group.collapsed":"{label} collapsed, {rows} shown","a11y.page.position":"Page {page} of {pages}","a11y.updates.paused":"Updates paused","a11y.updates.resumed":"Updates resumed","a11y.edit.refusedOne":"Edit to {column} was refused and put back to {value}{reason}","a11y.edit.refusedMany":{one:"{count} edit was refused and put back{reason}",other:"{count} edits were refused and put back{reason}"},"a11y.edit.reason":", {reason}","a11y.history.undo":"Undid {label}","a11y.history.redo":"Redid {label}","a11y.history.undoLast":"Undid the last change","a11y.history.redoLast":"Redid the last change","a11y.column.cannotResize":"{column} cannot be resized","a11y.column.resized":"{column} is {width} pixels wide","a11y.column.atMinimum":"{column} is at its narrowest, {width} pixels","a11y.column.atMaximum":"{column} is at its widest, {width} pixels","a11y.column.cannotMove":"{column} cannot be moved","a11y.column.alreadyFirst":"{column} is already first in its group","a11y.column.alreadyLast":"{column} is already last in its group","a11y.column.cannotMoveThere":"{column} cannot be moved there","a11y.column.moved":"{column} moved to position {at} of {of}","a11y.column.hidden":"{column} hidden","a11y.group.formed":"{column} grouped with {other} in a new band","a11y.group.dissolved":"band {group} dissolved","a11y.group.renamed":"band renamed to {group}","a11y.group.moved":"band {group} moved to position {at} of {of}","a11y.column.addedToGroup":"{column} added to band {group}","a11y.column.removedFromGroup":"{column} removed from its band","a11y.column.notInGroup":"{column} is not in a band","a11y.column.cannotGroup":"{column} cannot be grouped","a11y.group.cannotMove":"band {group} cannot be moved there","columngroup.newGroup":"New group","columngroup.rename":"Rename band","columngroup.dissolve":"Dissolve band","columngroup.group":"Group with adjacent column","columngroup.untitled":"Untitled band","panel.bandCollapse":"Collapse band {band}","panel.bandExpand":"Expand band {band}","panel.bandVisible":"Show or hide every column in band {band}","panel.bandRenameFor":"Rename band {band}","panel.bandDissolveFor":"Dissolve band {band}","header.filter":"Filter {column}","header.menu":"Column menu for {column}","header.toggleGroup":"Toggle {group}","header.dragHint":"Drag {column} to reorder, or onto another column to group","header.dragRole":"draggable column header","header.group":"group","header.selectAllRows":"Select all rows","header.clearSelection":"Clear selection","cell.selectRow":"Select row","cell.detail.show":"Show detail","cell.detail.hide":"Hide detail","cell.detail.showInPane":"Show in the detail pane","cell.detail.showingInPane":"Showing in the detail pane","cell.group.expand":"Expand","cell.group.collapse":"Collapse","cell.delta.up":"up","cell.delta.down":"down","cell.delta.unchanged":"unchanged","cell.delta.moved":"{direction} {magnitude}","cell.delta.describedUnchanged":"{label}, unchanged","cell.delta.described":"{label}, {direction} by {magnitude}","cell.qr.of":"QR code for {text}","cell.qr.empty":"No QR code","cell.barcode.of":"Barcode for {text}","cell.barcode.empty":"No barcode","cell.barcode.invalid":"Invalid value for this barcode","cell.rating.of":"{rating} of {max}","cell.rating.empty":"Not rated","cell.stage.of":"Stage {current} of {total}: {label}","cell.stage.empty":"No stage","a11y.panel.cannotMove":"{column} cannot be moved","a11y.panel.alreadyFirst":"{column} is already first","a11y.panel.alreadyLast":"{column} is already last","a11y.panel.moved":"{column} moved to position {at} of {of}","a11y.panel.removedFrom":"{column} removed from {list}","a11y.panel.addedTo":"{column} added to {list}","a11y.panel.cannotAddTo":"{column} cannot be added to {list}","a11y.annotate.erased":"Annotation removed","a11y.annotate.noMarks":"No annotations to erase","a11y.annotate.focusedMark":"Mark {at} of {of} selected","a11y.annotate.confirmClear":"Clear all annotations? Choose Clear or Keep.","a11y.annotate.cleared":"All annotations cleared","a11y.range.written":{one:"{count} cell updated",other:"{count} cells updated"},"a11y.range.cleared":{one:"{count} cell cleared",other:"{count} cells cleared"},"paste.preview.title":"Review paste","paste.preview.summary":{one:"{changes} cell will change, {rejected} rejected.",other:"{changes} cells will change, {rejected} rejected."},"paste.preview.changesHeading":{one:"{count} change",other:"{count} changes"},"paste.preview.rejectedHeading":{one:"{count} rejected",other:"{count} rejected"},"paste.preview.colOld":"Current","paste.preview.colNew":"New","paste.preview.colCell":"Cell","paste.preview.colReason":"Reason","paste.preview.empty":"This paste would change nothing.","paste.preview.confirm":"Apply","paste.preview.cancel":"Cancel","paste.preview.reason.permission":"Not permitted","paste.preview.reason.readOnly":"Read-only","paste.preview.reason.validation":"Invalid value","paste.preview.reason.locked":"Being edited","paste.preview.reason.missing":"No such cell","a11y.paste.previewOpened":{one:"Paste preview: {changes} cell changes, {rejected} rejected. Review, then apply or cancel.",other:"Paste preview: {changes} cell changes, {rejected} rejected. Review, then apply or cancel."},"a11y.paste.cancelled":"Paste cancelled; nothing changed","status.total":"{rows}","status.counting":"Counting rows…","status.shownOfTotal":"{shown} of {total}","status.selected":"{count} selected","status.selectedAcrossSource":"{count} selected across the source","status.selectedAcrossSourceCounting":"All matching rows selected, counting…","status.count":"Count {count}","status.loading":"Loading {count}…","status.loadingOf":"Loading {loaded} of {total} ({percent}%)","status.stat.sum":"Sum","status.stat.min":"Min","status.stat.max":"Max","status.stat.avg":"Avg","status.paused":"Paused","status.pausedWaiting":"Paused · {waiting}","status.coalesced":"{count} coalesced","status.hiddenComments":"{comments} on hidden rows","pagination.label":"Pagination","pagination.first":"First page","pagination.previous":"Previous page","pagination.next":"Next page","pagination.last":"Last page","pagination.page":"Page","pagination.ofPages":"of {pages}","pagination.summary":"{from}–{to} of {total}","pagination.pageSize":"Rows per page","pagination.range":"{from}–{to}","pagination.counting":"{from}–{to}, counting…","pagination.jump":"Page number, press Enter to jump","pagination.jumpBounded":"Page number, 1 to {pages}, press Enter to jump","panel.columns":"Columns","panel.filters":"Filters","panel.views":"Views","panel.quickFilter":"Quick filter","find.label":"Find in grid","find.placeholder":"Find in grid","find.next":"Next match","find.previous":"Previous match","find.close":"Close find","find.matchCase":"Match case","find.wholeCell":"Whole cell","find.columnScope":"Search in","find.allColumns":"All columns","find.count":"{current} of {total}","find.countPartial":"{current} of {total} so far","find.none":"No matches","find.searching":"Searching…","find.loadedRows":"in loaded rows","rowCap.more":"+ {count} more","panel.formatting":"Formatting","panel.statistics":"Statistics","stat.noData":"No data","stat.unavailable":"Not available on this source","stat.tone.good":"good","stat.tone.bad":"bad","stat.tone.flat":"flat","stat.target":"target {target}","meter.target":"target {value}","panel.regression":"Regression","panel.compare":"Compare","panel.insights":"Insights","panel.compareGroups":"Compare groups","panel.explain":"Explain","insights.subset":"Filtered subset vs whole","insights.dataset":"This grid vs another dataset","insights.groups":"Group comparison","insights.noFilter":"Filter the grid to compare the subset against the whole.","insights.by":"Group by","insights.test":"Test","insights.effect":"Effect size","insights.interval":"Confidence interval","insights.pValue":"p-value","insights.smallSample":"small sample — interpret with care","insights.needGroups":"Choose two columns with groups to compare.","compareGroups.noTest":"Not enough readings, or no variation, in at least one group.","insights.empty":"No columns to analyse.","insights.anomalies":"Anomalies","insights.anomalyCount":"{count} flagged of {n}","insights.anomalyMethod":"Method","insights.anomalyThreshold":"Threshold","anomaly.chip":"{count} anomalies flagged","anomaly.chipActive":"Showing {count} anomalies — clear","compare.first":"First column","compare.second":"Second column","compare.needTwo":"Two numeric columns are needed to compare","compare.noPairs":"No rows have a value in both","compare.pairs":"{count} pairs","compare.pearson":"Correlation (Pearson)","compare.spearman":"Rank correlation (Spearman)","compare.kendall":"Kendall’s tau","compare.covariance":"Covariance","compare.slope":"Slope","compare.intercept":"Intercept","compare.r2":"R²","compare.stdError":"Standard error","compare.weighted":"Weighted average","panel.zone.group":"row groups","panel.zone.values":"values","panel.zone.pivot":"pivot columns","groupZone.label":"Row groups","groupZone.title":"Group by","groupZone.hint":"Drag a column here to group rows by its values","groupZone.chip":"{column}, group {at} of {of}","groupZone.remove":"Stop grouping by {column}","groupZone.add":"Add a group","total.sum":"Sum","total.avg":"Average","total.min":"Min","total.max":"Max","total.count":"Count","total.countValues":"Count of values","total.first":"First","total.last":"Last","total.custom":"Total","total.median":"Median","total.p25":"25th percentile","total.p75":"75th percentile","total.p90":"90th percentile","total.p95":"95th percentile","total.p99":"99th percentile","total.iqr":"Interquartile range","total.mad":"Median absolute deviation","total.variance":"Variance","total.varianceP":"Variance (population)","total.stddev":"Standard deviation","total.stddevP":"Standard deviation (population)","total.range":"Range","total.distinct":"Distinct","total.mode":"Mode","total.skewness":"Skewness","total.kurtosis":"Kurtosis","total.geomean":"Geometric mean","total.harmean":"Harmonic mean","total.sumSquares":"Sum of squares","total.weightedAvg":"Weighted average","total.argmin":"Lowest by","total.argmax":"Highest by","total.hhi":"Concentration (HHI)","total.entropy":"Entropy","total.evenness":"Evenness","total.top3Share":"Top 3 share","total.top10Share":"Top 10 share","total.gini":"Gini coefficient","total.trimmedMean":"Trimmed mean","total.winsorizedMean":"Winsorized mean","total.robustOutliers":"Outliers (robust)","total.jarqueBera":"Jarque–Bera","total.passRate":"Pass rate","total.failureCount":"Failures","stats.column":"Column","stats.choose":"Choose a column to profile","stats.noColumns":"No numeric columns to profile","stats.noValues":"Nothing numeric in this column","stats.count":"Count","stats.present":"Present","stats.missing":"Missing","stats.distinct":"Distinct","stats.min":"Minimum","stats.max":"Maximum","stats.mean":"Mean","stats.median":"Median","stats.q1":"Lower quartile","stats.q3":"Upper quartile","stats.iqr":"Interquartile range","stats.stddev":"Standard deviation","stats.outliers":"Outliers","stats.distribution":"Distribution","stats.distribution.detail":"Distribution: rows per range","stats.bin":"{count} between {from} and {to}","stats.topValues":"Top values","stats.section.shape":"Shape","stats.section.robust":"Robust","stats.section.concentration":"Concentration","stats.section.capability":"Capability","stats.cp":"Cp","stats.cpk":"Cpk","stats.pp":"Pp","stats.ppk":"Ppk","stats.outOfSpec":"Out of specification","stats.filtered":"Over the {count} filtered rows","stats.unavailable":"Not computed by the source: {stats}.","stats.unavailable.notPlain":"`{column}` is not a plain column the engine can name","stats.unavailable.where":"a `where` predicate is in force ({list}), which only the browser can run","stats.unavailable.filter":"the grid's filter did not fully push to the engine","stats.unavailable.quick":"the quick search did not push to the engine","stats.unavailable.client":'the source did not compute "{fn}" in the engine ({reason}); set the pushdown source\'s `{setting}`',"stats.unavailable.outliers":"the count of values outside Tukey's fences is not an engine aggregate","stats.unavailable.histogram":"the shape of the column is not an engine aggregate","stats.unavailable.topValues":"the source did not answer a grouped count in the engine","explain.column":"Value","explain.by":"Break down by","explain.byRow":"Each row","explain.noColumns":"No numeric columns to explain","explain.unavailable":"Nothing to explain in this column","explain.total":"{fn}: {total}","explain.weighted":"weighted effects","explain.single":"one contributor","explain.delta":"was {before}, now {after} (Δ {delta})","explain.breakdown":"Contributors","explain.contributor":"Contributor","explain.count":"Rows","explain.value":"Value","explain.contribution":"Contribution","explain.share":"Share","explain.change":"Change","explain.before":"Before","explain.after":"After","explain.effect":"Effect","explain.kind.new":"New","explain.kind.dropped":"Dropped","explain.kind.changed":"Changed","explain.narrative":"Explanation","explain.narrative.lead":"{top} accounts for {share}; the {fn} is {total}.","explain.narrative.next":"{next} follows at {share}.","explain.narrative.driver":"The change of {delta} was driven most by {top} ({effect}).","explain.narrative.driverNext":"{next} ({kind}) moved it {effect}.","explain.narrative.none":"Nothing contributed to this total.","explain.narrative.noChange":"Nothing changed between the two states.","regression.noModel":"No model configured. Set predictors and a response on the panel.","regression.cannotFit":"The model cannot be fitted over the current rows.","regression.observations":"Fitted over {count} rows","regression.r2":"R²","regression.adjR2":"Adjusted R²","regression.coefficients":"Coefficients","regression.term":"Term","regression.estimate":"Estimate ± SE","regression.stdError":"Std error","regression.t":"t","regression.p":"p","regression.vif":"Variance inflation (VIF)","regression.heteroscedasticity":"Heteroscedasticity (Breusch–Pagan)","regression.heteroscedastic":"Heteroscedastic: BP {statistic}, p {p}","regression.homoscedastic":"No heteroscedasticity detected: BP {statistic}, p {p}","menu.sortAscending":"Sort ascending","menu.sortDescending":"Sort descending","menu.clearSort":"Clear sort","menu.groupBy":"Group by this column","menu.ungroup":"Stop grouping by this column","menu.hideColumn":"Hide column","menu.pinStart":"Pin to start","menu.pinEnd":"Pin to end","menu.unpin":"Unpin","menu.autosize":"Fit to content","ai.valuesNotAmongOptions":'{values} {shown} not among the options for "{column}"',"menu.clearCells":{one:"Clear cell",other:"Clear {count} cells"},"menu.fillDown":"Fill down","menu.copy":"Copy","menu.copyWithHeaders":"Copy with headers","menu.paste":"Paste","menu.filterEllipsis":"Filter…","menu.columnStatistics":"Column statistics","menu.compareGroups":"Compare groups","menu.explain":"Explain this number","menu.pinColumn":"Pin column","menu.sizeToFit":"Size to fit content","menu.sizeAllToFit":"Size all columns to fit","menu.width":"Width","menu.narrower":"Narrower","menu.wider":"Wider","menu.moveColumn":"Move column","menu.moveLeft":"Move left","menu.moveRight":"Move right","menu.moveToStart":"Move to start","menu.moveToEnd":"Move to end","menu.unpivot":"Remove from pivot","menu.pivotBy":"Pivot by this column","menu.stopTotalling":"Stop totalling","menu.totalColumn":"Total this column","menu.aggregate":"Aggregate","menu.aggregateNone":"None","menu.aggregateGroup":"Group subtotals","menu.aggregateGrand":"Grand total","menu.aggregateSame":"Same as total","menu.redactColumn":"Redact column","menu.stopRedacting":"Stop redacting","menu.stopRedactingAll":"Stop redacting everything","menu.sortGroupsAscending":"Sort groups ascending","menu.sortGroupsDescending":"Sort groups descending","menu.filterGroups":"Filter groups…","menu.expandAll":"Expand all","menu.collapseAll":"Collapse all","menu.clearGrouping":"Clear grouping","menu.colour":"Colour","menu.importCsv":"Import rows from CSV…","import.title":"Import rows","import.clipboard":"the clipboard","import.summary":{one:"{count} row from {name}",other:"{count} rows from {name}"},"import.opened":{one:"Import preview open, {count} row",other:"Import preview open, {count} rows"},"import.done":{one:"{count} row imported",other:"{count} rows imported"},"import.confirm":"Import","import.cancel":"Cancel","import.colSource":"Column","import.colField":"Maps to","import.colType":"Type","import.skip":"— skip —","import.mapLabel":'Map "{source}" to a field',"import.modeLabel":"On import","import.sheetLabel":"Sheet","import.append":"Add to existing rows","import.replace":"Replace all rows","menu.deleteRow":{one:"Delete row",other:"Delete {count} rows"},"toolbar.undo":"Undo","toolbar.redo":"Redo","toolbar.undoLabelled":"Undo {label}","toolbar.redoLabelled":"Redo {label}","toolbar.exportCsv":"Export to CSV","toolbar.exportExcel":"Export to Excel","toolbar.clipboard":"Copy visible rows to the clipboard","toolbar.print":"Print","toolbar.pause":"Hold incoming updates","toolbar.resume":"Resume updates","toolbar.applyHeld":{one:"Apply {count} held update",other:"Apply {count} held updates"},"toolbar.restoreView":"Restore the default view","toolbar.maximiseGrid":"Maximise the grid to fill the window","toolbar.restoreSize":"Restore the grid to the page (Esc)","toolbar.annotate.pen":"Draw freehand","toolbar.annotate.arrow":"Draw an arrow","toolbar.annotate.rect":"Draw a rectangle","toolbar.annotate.highlight":"Highlight","toolbar.annotate.erase":"Erase","toolbar.annotate.clearAll":"Clear all annotations","toolbar.annotate.clearAllConfirm":"Clear","toolbar.annotate.clearAllKeep":"Keep","overlay.noRows":"No rows to show","overlay.noResults":"No rows match the current filters","overlay.loading":"Loading…","overlay.error":"Something went wrong","listview.pullToRefresh.pull":"Pull to refresh","listview.pullToRefresh.release":"Release to refresh","listview.pullToRefresh.refreshing":"Refreshing…","overlay.loadingRows":"Loading rows {from} to {to}","overlay.rowError":"Failed to load","comments.panel":"Cell comments","comments.close":"Close comments","comments.write":"Write a comment","comments.post":"Comment","comments.delete":"Delete","comments.valueMoved":"Written when the value was {was}: it is now {now}.","comments.resolve":"Resolve","comments.reopen":"Reopen","comments.loading":"Loading…","comments.empty":"No comments yet.","comments.unknownAuthor":"Unknown","comments.edited":"{time} (edited)","comments.cellTitle":"{column}: {row}","presence.hidden":{one:"{count} not in view",other:"{count} not in view"},"presence.someoneElse":"someone else","a11y.presence.refused":"This cell is being edited by {name}","presence.peer":"{name}: jump to their cursor","presence.peerIdle":"{name}, idle: jump to their cursor","presence.peerHidden":"{name}, not in the current view","facets.filter":"{column} distribution filter","header.totalOf":"{total} of {column}","diff.before":"Was: {value}","diff.empty":"(empty)","kanban.columnCards":{one:"{title}, {count} card",other:"{title}, {count} cards"},"kanban.laneCards":{one:"{lane}, {title}, {count} card",other:"{lane}, {title}, {count} cards"},"kanban.blocked":"Blocked","kanban.ready":"Ready","kanban.columnMenu":"Column menu","kanban.blockedBy":{one:"blocked by {count} card",other:"blocked by {count} cards"},"kanban.card.assignedTo":"Assigned to {names}","kanban.card.overdue":"Overdue","kanban.card.dueSoon":"Due soon","kanban.card.progress":"{percent}% complete","kanban.card.checklist":"{done} of {total} done","gantt.lag":"+{days}d","gantt.lead":"{days}d","gantt.a11y.moved":"{name} moved to {date}","gantt.a11y.day":"day {day}","gantt.a11y.resized":"{name} resized to {days} days","gantt.a11y.linkFrom":"Linking from {name}. Focus the successor and press L.","gantt.a11y.linked":"Linked {from} to {to}, finish to start.","gantt.a11y.linkCancelled":"Link cancelled.","gantt.a11y.deleted":"{name} deleted.","gantt.a11y.readOnly":"Read-only.","gantt.row.moveHandle":"Drag to reorder or re-parent {name}","gantt.a11y.rowMoved":"{name} moved.","gantt.a11y.rowReparented":"{name} moved under {parent}.","gantt.a11y.rowPromoted":"{name} moved to the top level.","gantt.a11y.rowMoveCancelled":"Move cancelled.","gantt.a11y.copied":"{count} tasks copied.","gantt.a11y.cut":"{count} tasks cut.","gantt.a11y.pasted":"{count} tasks pasted.","gantt.task.newName":"New task","gantt.a11y.taskAdded":"{name} added.","gantt.menu.addAbove":"Add task above","gantt.menu.addBelow":"Add task below","gantt.menu.addChild":"Add subtask","gantt.menu.addSuccessor":"Add successor","gantt.menu.addPredecessor":"Add predecessor","gantt.menu.toMilestone":"Convert to milestone","gantt.menu.toTask":"Convert to task","gantt.menu.delete":"Delete task","gantt.a11y.linkCycle":"Linking {from} to {to} would create a cycle; link not created.","gantt.a11y.linkCreated":"{from} linked to {to}, {type}.","gantt.a11y.linkDeleted":"Link from {from} to {to} deleted.","gantt.a11y.linkLabel":"Link, {from} to {to}, {type}","gantt.linkEditor.title":"Edit link from {from} to {to}","gantt.linkEditor.type":"Link type","gantt.linkEditor.lag":"Lag, in days","gantt.linkEditor.apply":"Apply","gantt.linkEditor.delete":"Delete link","gantt.linkEditor.cancel":"Cancel","gantt.a11y.undone":"Undone.","gantt.a11y.redone":"Redone.","gantt.a11y.nothingToUndo":"Nothing to undo.","gantt.a11y.nothingToRedo":"Nothing to redo.","gantt.workload.title":"Resource workload","gantt.workload.resource":"Resource","gantt.workload.total":"Total","gantt.workload.unassigned":"Unassigned","gantt.workload.ungrouped":"No group","gantt.workload.cell":"{hours} h from {date}","gantt.workload.over":"{hours} h from {date}, over a capacity of {capacity} h","gantt.workload.expand":"Show {name}’s tasks","gantt.workload.collapse":"Hide {name}’s tasks","gantt.workload.expandGroup":"Show the {name} group","gantt.workload.collapseGroup":"Hide the {name} group","gantt.workload.unitToggle":"Hours / % / Cost","gantt.workload.unitHours":"Showing hours","gantt.workload.unitPercent":"Showing percent of capacity","gantt.workload.unitCost":"Showing cost","gantt.workload.cellPercent":"{percent}% from {date}","gantt.workload.overPercent":"{percent}% from {date}, over capacity","gantt.workload.cellNoCapacity":"No available hours from {date}","gantt.workload.cellCost":"{cost} from {date}","gantt.workload.otherProjectLabel":"{name} (other project)","gantt.workload.external":"External booking","gantt.a11y.hoursSet":"{name}: {hours} h from {date}","gantt.a11y.hoursCleared":"{name}: no hours from {date}","gantt.a11y.hoursRefused":"{date} is not a working day; {name} was not changed.","gantt.histogram.title":"Resource histogram","gantt.histogram.tableTitle":"Resource histogram data","gantt.histogram.resource":"Resource","gantt.histogram.period":"Period","gantt.histogram.hours":"Hours","gantt.histogram.percent":"Percent of capacity","gantt.histogram.cost":"Cost","gantt.histogram.capacity":"Capacity","gantt.histogram.overAllocated":"Over-allocated","gantt.histogram.yes":"Yes","gantt.histogram.no":"No","gantt.histogram.tip":"{name}, {from} to {to}: {value}{capacity}{tasks}","gantt.histogram.tipHours":"{hours} h","gantt.histogram.tipPercent":"{percent}% of capacity","gantt.histogram.tipCost":"{cost}","gantt.histogram.tipCapacity":", capacity {hours} h","gantt.histogram.tipTasks":" ({tasks})","gantt.histogram.tipOver":", over capacity","gantt.histogram.tipNoCapacity":"no available hours","gantt.picker.title":"Assign resources to {name}","gantt.picker.open":"Edit assignments for {name}","gantt.picker.search":"Search resources","gantt.picker.list":"Resources","gantt.picker.selected":"Assigned resources","gantt.picker.load":"{load}% booked of {capacity}% over these dates","gantt.picker.none":"No matching resources","gantt.picker.units":"{name}, units in percent","gantt.picker.remove":"Remove {name}","gantt.picker.apply":"Apply","gantt.picker.cancel":"Cancel","gantt.picker.warn":"{name} would be over-allocated: {load}% booked of {capacity}%","gantt.picker.ok":"No resource would be over-allocated","gantt.picker.assign":"Assign","gantt.col.effort":"Effort","gantt.col.units":"Units","gantt.unscheduled":"Unscheduled","gantt.col.unscheduled":"Unscheduled","gantt.inactive":"Inactive","gantt.col.inactive":"Inactive","gantt.col.slack":"Slack","gantt.col.deadline":"Deadline","gantt.col.constraint":"Constraint","gantt.col.constraintDate":"Constraint date","gantt.col.earlyStart":"Early start","gantt.col.lateStart":"Late start","gantt.col.lateFinish":"Late finish","gantt.col.baselineStart":"Baseline start","gantt.col.baselineEnd":"Baseline finish","gantt.col.variance":"Variance","gantt.col.note":"Note","gantt.col.sequence":"#","gantt.col.predecessors":"Predecessors","gantt.col.successors":"Successors","gantt.link.invalid":"Cannot read “{token}” as a link. Write a task number, a type and a lag, like 3FS+2; links not changed.","gantt.link.unknownRef":"No task is numbered “{token}”; links not changed.","gantt.link.self":"“{token}” links a task to itself; links not changed.","gantt.link.duplicate":"“{token}” repeats a link already listed; links not changed.","gantt.link.cycle":"“{token}” would create a cycle; links not changed.","gantt.constraint.ASAP":"As soon as possible","gantt.constraint.MSO":"Must start on","gantt.constraint.MFO":"Must finish on","gantt.constraint.ALAP":"As late as possible","gantt.constraint.SNET":"Start no earlier than","gantt.constraint.SNLT":"Start no later than","gantt.constraint.FNET":"Finish no earlier than","gantt.constraint.FNLT":"Finish no later than","gantt.row.ancestor":"Shown because a task inside it matches the filter","gantt.progress.handle":"Drag to set the progress of {name}","gantt.a11y.progress":"{name} {percent}% complete","gantt.col.name":"Task name","gantt.col.start":"Start","gantt.col.end":"Finish","gantt.col.duration":"Duration","gantt.col.assignee":"Assignee","gantt.col.progress":"%","gantt.col.wbs":"WBS","gantt.zoom.label":"Zoom","gantt.zoom.day":"Day","gantt.zoom.week":"Week","gantt.zoom.month":"Month","gantt.zoom.quarter":"Quarter","gantt.zoom.fit":"Fit to plan","gantt.tip.range":"{from} to {to}","gantt.tip.duration":"{days}d","gantt.tip.slack":"slack {days}d","gantt.tip.effort":"{hours}h","gantt.tip.row":"{label}: {value}","gantt.tip.start":"Start","gantt.tip.end":"End","gantt.tip.date":"Date","gantt.tip.durationLabel":"Duration","gantt.tip.durationValue":"{days} days","gantt.tip.complete":"Complete","gantt.tip.effortLabel":"Effort","gantt.tip.effortValue":"{hours} h","gantt.tip.assigned":"Assigned","gantt.tip.cost":"Cost","gantt.tip.slackLabel":"Slack","gantt.tip.slackValue":"{days} days","gantt.tip.deadline":"Deadline","gantt.mode.fixedDuration":"Fixed duration","gantt.mode.fixedEffort":"Fixed effort","gantt.mode.fixedUnits":"Fixed units","gantt.scurve.spi":"SPI {index}","gantt.scurve.cpi":"CPI {index}","gantt.print.page":"Page {page} of {pages}","gantt.print.printed":"Printed {date}","gantt.dataBand.title":"Data band","gantt.dataBand.name":"Task","gantt.dataBand.resource":"Resource","gantt.dataBand.total":"Total","gantt.dataBand.unassigned":"Unassigned","gantt.dataBand.collapse":"Collapse {name}","gantt.dataBand.expand":"Expand {name}","gantt.dataBand.cell":"{name}, {date}: {value}","gantt.issues.title":"Scheduling conflicts","gantt.issues.empty":"No scheduling conflicts","gantt.issues.count":"{count} scheduling conflicts","gantt.issues.toggle":"Toggle the conflicts panel","gantt.issues.cycle":"Circular dependency: {tasks}","gantt.issues.constraint":"{task} cannot meet its {constraint} constraint of {date}","gantt.issues.lock":"{task} is locked but a dependency would move it","gantt.issues.deadline":"{task} finishes after its deadline of {date}","gantt.issues.fixRemoveLink":"Remove link","gantt.issues.fixAsap":"Set as soon as possible","gantt.issues.fixUnlock":"Unlock task","gantt.issues.fixClearDeadline":"Clear deadline","gantt.resize.startHandle":"Drag to change the start of {name}","gantt.a11y.resizedStart":"{name} start moved to {date}, now {days} days","gantt.a11y.startEdge":"Start edge can be resized: drag the left edge, or press Ctrl+Shift+Left or Right.","gantt.a11y.chain":"Dependency chain highlighted: {preds} predecessors, {succs} successors.","timeline.scrub":"Scrub through recent changes","timeline.goLive":"Go live","timeline.returnToPresent":"Return to the present","a11y.fillHandle":"Drag to fill","panel.icons":"Icons","value.tooLong":"Too long","dataview.label":"Items","dataview.empty":"No items","dataview.reorder.sorted":"Items cannot be reordered while the view is sorted","dataview.reorder.filtered":"Items cannot be reordered while a filter is applied","shortcuts.title":"Keyboard shortcuts","shortcuts.close":"Close keyboard shortcuts","shortcuts.hint":"Press Escape to close.","shortcuts.or":"or","a11y.reorder.moved":"Moved to position {position} of {total}","a11y.reorder.sorted":"Rows cannot be reordered while the grid is sorted","a11y.reorder.filtered":"Rows cannot be reordered while a filter is applied","a11y.reorder.grouped":"Rows cannot be reordered while the grid is grouped","a11y.reorder.grab":"Reorder row","a11y.reorder.sortedManual":"Rows cannot be reordered while the grid is sorted. Press Alt+Shift+M, or the Manual order button in the heading, to order them by hand","a11y.reorder.groupDerived":"The row cannot join that group: the group is worked out from the value, so there is no single value to give it","a11y.reorder.groupReadOnly":"The row cannot join that group: its grouping value cannot be edited","a11y.reorder.invalid":"The row cannot join that group: the new value was not valid","a11y.reorder.vetoed":"The move was declined; the row stays where it was","a11y.reorder.vetoedBecause":"The move was declined ({reason}); the row stays where it was","a11y.reorder.refused":"The row cannot be moved there","a11y.reorder.regrouped":"Moved into {group}","a11y.tree.dropRefusedDescendant":"A row cannot be dropped into one of its own descendants; the row stays where it was","a11y.rowOrder.entered":"Manual order: the rows keep their places and can be moved by hand","a11y.rowOrder.exited":"Manual order ended; the rows follow the sort","rowOrder.button":"Manual order","rowOrder.enter":"Order the rows by hand instead of by the sort","rowOrder.exit":"Return to the sorted order","a11y.transfer.moved":"Row moved to the other grid","a11y.transfer.copied":"Row copied to the other grid","a11y.transfer.refused":"That grid does not accept this row","a11y.transfer.declined":"The drop was declined; the row stays where it was","a11y.transfer.stale":"The drop target changed while it was being confirmed; the row stays where it was","shortcuts.group.grid":"In the data","shortcuts.group.header":"On a column heading","shortcuts.group.panel":"In the column list","shortcut.moveCell":"Move the focused cell","shortcut.rowEnds":"First / last cell of the row","shortcut.gridEnds":"First cell of the first row / last cell of the last row","shortcut.pageRows":"Move one viewport of rows","shortcut.nextCell":"Leave the grid for the next / previous focusable element (arrows move between cells)","shortcut.undo":"Undo the last edit, paste, fill or clear","shortcut.redo":"Redo the step that was undone","shortcut.startEdit":"Start editing the focused cell; while editing, commit and open the cell below (Shift+Enter: above)","shortcut.toggleRow":"Toggle selection of the focused row","shortcut.cancel":"Cancel the current edit or drag","shortcut.expandCollapse":"Expand / collapse a group or tree row","shortcut.focusHeader":"Move focus to the column header","shortcut.focusPanel":"Move focus to the tool panel","shortcut.explain":"Explain the focused column","shortcut.contextMenu":"Open the context menu for the focused cell","shortcut.moveRow":"Move the focused row, when row reorder is enabled","shortcut.manualOrder":"Order the rows by hand, or return to the sort, when row reorder allows a manual order","shortcut.headingMove":"Move between headings","shortcut.headingEnds":"First / last heading","shortcut.headingSort":"Sort by the column, Shift to add to the sort","shortcut.headingResize":"Resize the column, Ctrl for a coarse step","shortcut.headingAutosize":"Size the column to its content","shortcut.headingReorder":"Move the column","shortcut.headingMenu":"Open the column menu","shortcut.headingExit":"Return focus to the data","shortcut.listGroup":"Group by the column, or stop grouping by it","shortcut.listValues":"Add the column to values, or take it out","shortcut.listPivot":"Pivot by the column, or stop pivoting by it","shortcut.listMove":"Move the column","shortcut.find":"Find in the grid","tags.label":"Show columns","tags.all":"All columns","tags.showing":"Showing {tag}","form.title":"Edit row","form.save":"Save","form.cancel":"Cancel","form.loading":"Loading…","form.loadFailed":"Could not load this record.","form.loadTimeout":"The record did not arrive in time.","form.retry":"Try again","form.choose":"Choose…","form.newTitle":"New row","form.createFailed":"Could not add this record.","form.grid.cellInvalid":"Row {row}, {column}: {message}","form.grid.required":"Add at least one row.","form.grid.addRow":"Add row","form.grid.deleteRow":"Delete row","form.grid.total":"Total","form.grid.rowControls":"Row controls","presentation.cards":"Showing records as cards","presentation.table":"Showing records as a table","editor.format":"Format","editor.codeHint":"Tab indents · Esc cancels · Ctrl+Enter saves","editor.colours":"Colours","editor.customColour":"Custom colour","editor.hexValue":"Hex value","editor.hexPlaceholder":"#rrggbb","editor.clearColour":"Clear colour","editor.time":"Time","editor.noIcon":"No icon","editor.selectAll":"Select all","editor.passwordHint":"Enter the value twice to save it.","editor.clearRating":"Clear rating","editor.clear":"Clear","editor.value":"Value","editor.currency":"Currency","editor.richtext.formatting":"Formatting","editor.richtext.richText":"Rich text","editor.richtext.placeholder":"Start writing…","editor.richtext.linkLabel":"Link address","editor.richtext.linkPlaceholder":"https://","editor.richtext.linkAdd":"Add link","editor.richtext.bold":"Bold (Ctrl+B)","editor.richtext.italic":"Italic (Ctrl+I)","editor.richtext.underline":"Underline (Ctrl+U)","editor.richtext.strike":"Strikethrough","editor.richtext.heading":"Paragraph style","editor.richtext.alignLeft":"Align left","editor.richtext.alignCenter":"Align centre","editor.richtext.alignRight":"Align right","editor.richtext.ul":"Bulleted list","editor.richtext.ol":"Numbered list","editor.richtext.color":"Text colour","editor.richtext.link":"Link (Ctrl+K)","editor.richtext.image":"Insert image","editor.richtext.clear":"Clear formatting","editor.richtext.source":"HTML source","editor.richtext.undo":"Undo (Ctrl+Z)","editor.richtext.redo":"Redo (Ctrl+Y)","formatting.format":"Format","formatting.noRules":"No rules yet. The first one that matches a cell wins.","formatting.clearAll":"Clear all","formatting.addRule":"Add rule","formatting.condition":"Condition","formatting.value":"Value","formatting.secondValue":"Second value","formatting.moveEarlier":"Move earlier","formatting.moveLater":"Move later","formatting.ruleKind":"Rule type","formatting.aCondition":"A condition","formatting.aColourScale":"A colour scale","formatting.compare":"Compare a value","formatting.distribution":"By the distribution","formatting.colourScale":"Colour scale","formatting.scaleBounds":"Scale bounds","formatting.preview":"Preview","formatting.livePreview":"Live preview","history.title":"History","history.show":"Show history","history.empty":"Nothing to undo yet.","prompt.ask":"Ask","prompt.apply":"Apply","prompt.discard":"Discard","panel.searchColumns":"Search columns","panel.searchColumnsPlaceholder":"Search columns…","panel.searchColumnsToFilter":"Search columns to filter","panel.showAll":"Show all","panel.hideAll":"Hide all","panel.clearAll":"Clear all","panel.clear":"Clear","panel.filterAllColumns":"Filter all columns","panel.columnFiltered":"This column is filtered","panel.clearFilterOn":"Clear the filter on {column}","panel.clearFilter":"Clear this filter","panel.filterEmptyNoMatch":"No column matches “{query}”.","panel.filterEmptyNone":"No column on this grid can be filtered.","panel.filterSummaryActive":"{active} of {total} columns filtered","panel.filterSummaryNone":"No filters · {total} columns available","panel.filterBy":"Filter by {column}","panel.filteredBy":"Filtered by {column}","panel.columnDragHint":"Drag {column} into a zone above, or onto another column to reorder","panel.gridActions":"Grid actions","panel.tabActiveCount":{one:"{title}, {count} active",other:"{title}, {count} active"},"panel.tabActive":"{title}, active","views.default":"Default","views.namePlaceholder":"Name this view…","views.nameLabel":"Name for the current layout","views.save":"Save view","licence.watermark":V,"licence.watermark.free":A,"filter.op.contains":"Contains","filter.op.notContains":"Does not contain","filter.op.equals":"Equals","filter.op.notEqual":"Does not equal","filter.op.startsWith":"Starts with","filter.op.endsWith":"Ends with","filter.op.blank":"Is blank","filter.op.notBlank":"Is not blank","filter.op.lessThan":"Less than","filter.op.lessThanOrEqual":"Less than or equal","filter.op.greaterThan":"Greater than","filter.op.greaterThanOrEqual":"Greater than or equal","filter.op.inRange":"In range","filter.op.matches":"Matches","filter.op.before":"Before","filter.op.after":"After","filter.op.relative":"Relative to today","filter.rel.today":"Today","filter.rel.yesterday":"Yesterday","filter.rel.tomorrow":"Tomorrow","filter.rel.lastNDays":"Last N days","filter.rel.nextNDays":"Next N days","filter.rel.thisWeek":"This week","filter.rel.lastWeek":"Last week","filter.rel.thisMonth":"This month","filter.rel.lastMonth":"Last month","filter.rel.thisQuarter":"This quarter","filter.rel.quarterToDate":"Quarter to date","filter.rel.thisYear":"This year","filter.rel.yearToDate":"Year to date","filter.operator":"Operator","filter.join":"Join","filter.value":"Value","filter.from":"From","filter.to":"To","filter.addCondition":"Add condition","filter.noConditions":"No conditions","filter.removeCondition":"Remove condition","filter.search":"Search","filter.searchValues":"Search values","filter.noMatches":"No values match","filter.selectAll":"Select all","filter.clear":"Clear","filter.order":"Order values","filter.orderAz":"A to Z","filter.orderCount":"Count","filter.all":"All","filter.allExcept":"All but {count}","filter.loadingValues":"Loading values…","filter.topValues":"Top {shown} of {total} values","filter.valuesFailed":"Values could not be loaded: {error}","filter.valuesUnsupported":"This source cannot list the values of {column}; filter by condition instead.","filter.true":"True","filter.false":"False","filter.expression":"Filter expression","filter.column":"Column","filter.relativePeriod":"Relative period","filter.days":"Number of days","filter.tab.set":"Values","filter.tab.text":"Text","filter.tab.number":"Number","filter.tab.date":"Date","filter.tab.advanced":"Advanced","filterRow.label":"Filter row","filterRow.conditions":{one:"{count} condition",other:"{count} conditions"},"chart.empty":"Nothing to chart","chart.summary":"{type} chart of {measure} by {dimension}","chart.summaryShare":"{type} chart of {measure}","chart.summaryType":"{type} chart","chart.summaryGauge":"{type} chart of {measure}, {fn}: {value}","chart.waterfallTotal":"Total","chart.summaryEngine":"Figures computed by the data engine over every matching row","chart.summaryEngineViewport":"{count} points in this view, fetched from the data engine","chart.summaryEngineDensity":"{count} rows in this view, more than the {cap} drawn as points, so shown as {cells} density cells counted by the data engine","chart.summaryClientDensity":"{count} rows in this view, more than the {cap} drawn as points, so shown as {cells} density cells computed in the browser","chart.viewportOverCap":"{count} rows in this view, more than the {cap} this map draws; zoom in or narrow the filter","chart.dataTable":"Chart data","chart.viewportFilter.label":"Map view","chart.annotate.rail":"Drawing tools","chart.annotate.select":"Select and move a drawing","chart.annotate.trendLine":"Trend line","chart.annotate.horizontalLine":"Horizontal line","chart.annotate.verticalLine":"Vertical line","chart.annotate.channel":"Parallel channel","chart.annotate.fibonacci":"Fibonacci retracement","chart.annotate.arrow":"Arrow","chart.annotate.pen":"Freehand pen","chart.annotate.pen.described":"Freehand drawing from {from} to {to}","chart.annotate.measure-x":"Date range","chart.annotate.measure-y":"Price range","chart.annotate.measure-xy":"Date and price range","chart.annotate.measure.bars":{one:"{count} bar",other:"{count} bars"},"chart.annotate.measure.points":{one:"{count} point",other:"{count} points"},"chart.annotate.measure.volume":"Vol {value}","chart.annotate.measure.seconds":"{count}s","chart.annotate.measure.minutes":"{count}m","chart.annotate.measure.hours":"{count}h","chart.annotate.measure.days":"{count}d","chart.annotate.measure.weeks":"{count}w","chart.annotate.measure.months":"{count}mo","chart.annotate.measure.years":"{count}y","chart.annotate.measure":"Measure","chart.annotate.measure.dx":"Δx {value}","chart.annotate.measure.dy":"Δy {value}","chart.annotate.measure.pct":"{value}%","chart.annotate.measure.categories":{one:"{count} category",other:"{count} categories"},"chart.annotate.measure.slope.perDay":"Slope {value} per day","chart.annotate.measure.slope.perCategory":"Slope {value} per category","chart.annotate.measure.slope.perUnit":"Slope {value} per unit","chart.annotate.measure.dur.d":"{count} d","chart.annotate.measure.dur.h":"{count} h","chart.annotate.measure.dur.min":"{count} min","chart.annotate.measure.dur.s":"{count} s","chart.annotate.measure.dur.ms":"{count} ms","chart.annotate.measure.announce":"Measurement: {readout}","chart.annotate.measure.start":"Measure start: {x}, {y}","chart.annotate.text":"Text","chart.annotate.callout":"Callout","chart.annotate.note":"Note","chart.annotate.delete":"Delete the selected drawing","chart.annotate.editLabel":"Annotation text","chart.zoom.toolbar":"Zoom controls","chart.zoom.in":"Zoom in","chart.zoom.out":"Zoom out","chart.zoom.left":"Pan left","chart.zoom.right":"Pan right","chart.zoom.reset":"Reset the zoom","chart.legendMore":{one:"+{count} more",other:"+{count} more"},"chart.type.line":"Line","chart.type.area":"Area","chart.type.bar":"Bar","chart.type.pie":"Pie","chart.type.donut":"Donut","chart.type.sunburst":"Sunburst","chart.type.scatter":"Scatter","chart.type.step":"Step","chart.type.rangeArea":"Range","chart.type.horizontalBar":"Horizontal bar","chart.type.waterfall":"Waterfall","chart.type.floatingBar":"Floating bar","chart.type.horizontalFloatingBar":"Horizontal floating bar","chart.type.populationPyramid":"Population pyramid","chart.type.bullet":"Bullet","chart.type.bubble":"Bubble","chart.type.histogram":"Histogram","chart.type.boxplot":"Box plot","chart.type.forest":"Forest plot","chart.type.qq":"QQ plot","chart.type.ecdf":"ECDF","chart.type.lorenz":"Lorenz","chart.type.correlogram":"Correlogram","chart.type.control":"Control","chart.type.capability":"Capability","chart.type.movingRange":"Moving range","chart.type.treemap":"Treemap","chart.type.combo":"Combination","chart.type.pareto":"Pareto","chart.type.heatmap":"Heat map","chart.type.radar":"Radar","chart.type.gauge":"Gauge","chart.type.funnel":"Funnel","chart.type.candlestick":"Candlestick","chart.type.ohlc":"OHLC","chart.type.polarArea":"Polar area","chart.type.nightingale":"Nightingale rose","chart.type.rose":"Rose","chart.type.radialBar":"Radial bar","chart.type.polarScatter":"Polar scatter","chart.type.geomap":"Map","chart.type.sankey":"Sankey","chart.type.chord":"Chord","chart.type.pyramid":"Pyramid","chart.type.pictorial":"Pictorial","chart.type.serpentine":"Serpentine timeline","chart.type.spiral":"Spiral timeline","chart.edit.aggregated":"This value is a total of several rows, so it cannot be dragged.","chart.edit.refused":"That change was not applied.","chart.edit.refusedWhy":"That change was not applied: {reason}","chart.type.network":"Network","chart.type.stream":"Stream","chart.type.marimekko":"Marimekko","chart.type.violin":"Violin","chart.type.gantt":"Gantt","chart.type.forceTree":"Force-directed tree","chart.type.pack":"Packed circles","chart.type.tree":"Tree","chart.type.voronoiTreemap":"Voronoi treemap","chart.type.alluvial":"Alluvial","chart.type.arc":"Arc diagram","chart.type.barRace":"Bar chart race","chart.type.bubblemap":"Bubble map","chart.type.bump":"Bump chart","chart.type.calendar":"Calendar heat map","chart.type.choropleth":"Choropleth map","chart.type.decomposition":"Decomposition tree","chart.type.diverging":"Diverging bar","chart.type.dumbbell":"Dumbbell","chart.type.fan":"Fan chart","chart.type.hexbin":"Hexagonal bin","chart.type.hexmap":"Hex map","chart.type.icicle":"Icicle","chart.type.markermap":"Marker map","chart.type.motion":"Motion chart","chart.type.parallel":"Parallel coordinates","chart.type.ridgeline":"Ridgeline","chart.type.roc":"ROC curve","chart.type.scatter3d":"3D scatter","chart.type.slope":"Slope chart","chart.type.splom":"Scatter plot matrix","chart.type.venn":"Venn diagram","chart.type.waffle":"Waffle","chart.type.wordCloud":"Word cloud","chart.tasksDropped":{one:"{count} more task not shown",other:"{count} more tasks not shown"},"chart.geoUnmatched":{one:"{count} row could not be placed on the map",other:"{count} rows could not be placed on the map"},"chart.r2":"R² {value}","ai.insights":"Insights","ai.explainView":"Explain this view","ai.explain":"Explain","ai.ask":"Ask","ai.apply":"Apply","ai.discard":"Discard","ai.propose":"Propose","ai.approve":"Approve","ai.thinking":"Thinking…","ai.applying":"Applying…","ai.applied":"Applied: {what}","ai.couldNotApply":"Could not apply: {why}","ai.applyFailed":"it failed","ai.discarded":"Discarded.","ai.discardedNothingWritten":"Discarded. Nothing was written.","ai.nothingWritten":"Nothing was written.","ai.nothingWrittenVetoed":"Nothing was written — a before-handler vetoed it.","ai.scope":"Scope: {scope}","ai.unsafeQuery":"I could not turn that into a safe query: {why}","ai.nothingToDo":"nothing to do","ai.insightsFailed":"Could not generate insights right now. The grid is unaffected.","ai.modelUnreachable":"Could not reach the model right now. The grid is unaffected.","ai.flagged":{one:"{count} unverified figure was removed as ungrounded.",other:"{count} unverified figures were removed as ungrounded."},"ai.askPlaceholder":"Ask your data: “EMEA deals over 50k, biggest first”","ai.askLabel":"Ask your data","ai.actorPlaceholder":"Ask AI to change data: “set the Network Upgrade project to In Progress”","ai.actorLabel":"Ask AI to change data","editor.password.show":"Show value","editor.password.hide":"Hide value","editor.password.showField":"Show {column}","editor.password.hideField":"Hide {column}","facets.computing":"Computing…","facets.suppressed.cardinality":"Too many distinct values to chart","facets.suppressed.rows":"Too many rows to chart","facets.suppressed.streaming":"Paused while live data is streaming","facets.suppressed.noProvider":"No distribution available for this data source","facets.suppressed.type":"This column has no chartable distribution","facets.suppressed.unavailable":"Histogram unavailable","facets.bucketOf":"{count} of {whole} rows","history.undo":"Undo","history.redo":"Redo","history.described":"{action} {label}","history.nothingToUndo":"Nothing to undo","history.nothingToRedo":"Nothing to redo","history.undoDisabled":"Undo (nothing to undo)","history.redoDisabled":"Redo (nothing to redo)","a11y.presence.joined":"{name} joined","a11y.presence.left":"{name} left","prompt.asking":"Asking…","prompt.moreNotes":{one:"and {count} more",other:"and {count} more"},"shortcuts.key.cmd":"Cmd","timeline.live":"Live","timeline.recording":"recording…","panel.zoneHint.group":"Drag a column here to group rows by its values","panel.zoneHint.values":"Drag a column here to total it","panel.zoneHint.pivot":"Drag a column here to pivot across its values","panel.zoneHint.any":"Drag a column here","panel.rowsOf":"{shown} of {total} rows","views.empty":"No saved views yet. Set the grid up as you want it, then save it below.","views.applied":"Applied","views.matchesGrid":"Matches the grid as it is","views.delete":"Delete","views.confirmDelete":"Delete {name}?","views.confirmDeleteLabel":"Confirm deleting {name}","views.shared":"View copied to the clipboard","views.sharedDownload":"Clipboard unavailable; the view was downloaded as {name}","views.sharedFailed":"The view could not be copied or downloaded","views.rename":"Rename","views.ownedBy":"Owned by {name}","views.ownerOnlyReason":"Only {name} or an admin can do that","views.noOwnerReason":"Only an admin can do that — this view has no recorded owner","views.unshare":"Unshare","views.unshareTitle":"Stop sharing {name}","views.duplicate":"Duplicate","views.duplicateTitle":"Duplicate {name}","views.copyName":"{name} (copy)","gantt.row.expand":"Expand {name}","gantt.row.collapse":"Collapse {name}","gantt.resource.over":"{name} — over-allocated","kanban.board":"Board","kanban.requiredTitle":"Required fields","kanban.requiredSave":"Save","kanban.requiredCancel":"Cancel","kanban.moveRefused":'Move refused: a card in "{from}" cannot move to "{to}".',"kpi.status.good":"good","kpi.status.warn":"warn","kpi.status.critical":"critical","kpi.status.unknown":"No data","kpi.node.item":"{count} item","kpi.node.items":"{count} items","kpi.node.worst":"worst status {status}","kpi.node.unknown":"{count} unknown","sidebar.nav":"Main navigation","sidebar.search":"Search","sidebar.collapse":"Collapse sidebar","sidebar.expand":"Expand sidebar","toolbar.more":"More"}),I=Object.freeze(Object.keys(U))}),ze("packages/core/src/i18n/format.js",function(e,B){"use strict";Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"formatMessage",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"lookup",{enumerable:!0,get:function(){return v}});const A=B("packages/core/src/internal/predicates.js").isFunction,V=/\{(\w+)\}/g,U=new Map,I=new Map;function J(b){const c=b||"";if(U.has(c))return U.get(c);let g=null;try{g=new Intl.PluralRules(b||void 0)}catch{g=null}return U.set(c,g),g}function H(b,c,g="conjunction"){const o=Array.isArray(b)?b.filter(l=>l!=null&&l!==""):[];if(o.length===0)return"";if(o.length===1)return String(o[0]);const t=`${c||""}|${g}`;let s=I.get(t);if(s===void 0){try{s=new Intl.ListFormat(c||void 0,{style:"long",type:g})}catch{s=null}I.set(t,s)}return s?s.format(o.map(String)):o.map(String).join(", ")}function L(b,c){return b==null?"":typeof b=="number"?Number.isFinite(b)?b.toLocaleString(c||void 0,{maximumFractionDigits:20}):"":String(b)}function Y(b,c,g){if(typeof b=="string")return b;if(!b||typeof b!="object")return"";const o=c&&typeof c.count=="number"?c.count:null;if(o===null)return b.other??"";const t=J(g),s=t?t.select(o):o===1?"one":"other";return b[s]??b.other??""}function _(b,c={},g){const o=Y(b,c,g);return o?o.replace(V,(t,s)=>Object.prototype.hasOwnProperty.call(c,s)?L(c[s],g):t):""}function O(b,c,g="en-GB"){return typeof b=="string"&&b?b:typeof c=="string"&&c?c:g}function v(b,c){const g=b?b[c]:void 0;return g==null||A(g)?c:g}}),ze("packages/core/src/i18n/registry.js",function(e,B){"use strict";Object.defineProperty(e,"registerLocale",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"localeCatalogue",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"registeredTags",{enumerable:!0,get:function(){return J}});const A=B("packages/core/src/i18n/catalogue.js").EN_GB,V=new Map([["en-gb",A]]);function U(H,L){const Y=typeof H=="string"?H.toLowerCase():"";return!Y||!L||typeof L!="object"?!1:(V.set(Y,L),!0)}function I(H){if(typeof H!="string"||!H)return null;const L=H.toLowerCase(),Y=V.get(L);if(Y)return Y;const _=L.split("-")[0],O=V.get(_);if(O)return O;for(const[v,b]of V)if(v.split("-")[0]===_)return b;return null}function J(){return[...V.keys()]}}),ze("packages/core/src/i18n/index.js",function(e,B){"use strict";Object.defineProperty(e,"DEFAULT_LOCALE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"Messages",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"defaultMessages",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"createMessages",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"auditCatalogue",{enumerable:!0,get:function(){return u}});const ne=B("packages/core/src/i18n/catalogue.js"),A=ne.EN_GB,V=ne.MESSAGE_KEYS,U=B("packages/core/src/i18n/format.js"),I=U.formatMessage,J=U.formatList,H=U.lookup,L=U.resolveLocale,_=B("packages/core/src/internal/predicates.js").isFunction,v=B("packages/core/src/internal/warn.js").warnOnce,b=B("packages/core/src/i18n/registry.js"),c=b.registerLocale,g=b.localeCatalogue;Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return ne.EN_GB}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return ne.MESSAGE_KEYS}}),Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return U.formatList}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return U.resolveLocale}}),Object.defineProperty(e,"registerLocale",{enumerable:!0,get:function(){return b.registerLocale}});const o="en-GB";class t{#e=o;#t=A;constructor(p={}){this.configure(p)}configure(p={}){this.#e=L(p.locale,p.declared,o);const r=p.messages,i=g(this.#e);if(!i&&this.#e.toLowerCase()!=="en-gb"&&(!r||typeof r!="object")&&v(`i18n:locale:not-loaded:${this.#e.toLowerCase()}`,`locale "${this.#e}" is not loaded: import "@toclocoinc/lattice-grid/locales/${this.#e}" to add its text; English is used until then.`),!r||typeof r!="object"){this.#t=i?{...A,...i}:A;return}const h=Object.keys(r).filter(a=>!(a in A));h.length&&v(`i18n:unknown:${h[0]}`,`message keys not in the catalogue and so ignored: ${h.slice(0,5).join(", ")}${h.length>5?`, and ${h.length-5} more`:""}`),this.#t={...A,...i||{},...r}}get locale(){return this.#e}t(p,r){return I(H(this.#t,p),r||{},this.#e)}list(p,r){return J(p,this.#e,r)}number(p,r){const i=Number(p);return Number.isFinite(i)?i.toLocaleString(this.#e,r||{maximumFractionDigits:20}):""}}const s=new t;function l(n){return n instanceof t?n:new t(n||{})}function u(n){const p=n&&typeof n=="object"?n:{},r=V.filter(d=>{const h=p[d];return h==null||h===""||_(h)}),i=Object.keys(p).filter(d=>!(d in A));return{missing:r,unknown:i}}}),ze("packages/core/src/columns/types/structured.js",function(e,B){"use strict";Object.defineProperty(e,"MASK_DEFAULTS",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"maskValue",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"summariseJson",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"canonicalJson",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"parseJsonText",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"STRUCTURED_TYPES",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return o}});const ne=B("packages/core/src/internal/predicates.js"),A=ne.isNil,V=ne.isObject,I=B("packages/core/src/i18n/index.js").defaultMessages,J=Object.freeze({char:"•",length:8,fixedLength:!0,lastVisible:0,emptyDisplay:""});function H(t,s){const l=s||{},u=l.emptyDisplay??J.emptyDisplay;if(A(t)||t==="")return u;const p=[...typeof l.char=="string"&&l.char!==""?l.char:J.char][0]||J.char,r=l.fixedLength??J.fixedLength,i=Number.isFinite(l.length)&&Number(l.length)>0?Math.floor(Number(l.length)):J.length,d=typeof t=="string"?t:typeof t=="number"||typeof t=="boolean"||typeof t=="bigint"?String(t):null;let h=0;if(d!==null){const a=Number.isFinite(l.lastVisible)?Math.floor(Number(l.lastVisible)):J.lastVisible,y=[...d];if(h=a>0&&a<y.length?a:0,h>0){const f=y.slice(y.length-h).join(""),m=Math.max(1,(r?i:y.length)-h);return p.repeat(m)+f}return p.repeat(r?i:Math.max(1,y.length))}return p.repeat(i)}const L=48;function Y(t){try{const s=JSON.stringify(t);return s===void 0?null:s}catch{return null}}function _(t,s){if(A(t))return"";const l=Number.isFinite(s&&s.inlineLimit)?Number(s.inlineLimit):L;if(typeof t=="string")return t.length>l?`${t.slice(0,l-1)}…`:t;if(typeof t!="object")return String(t);const u=Y(t);if(u!==null&&u.length<=l)return u;if(Array.isArray(t)){const p=t.length;return`[${I.t("count.items",{count:p})}]`}const n=Object.keys(t).length;return`{${I.t("count.keys",{count:n})}}`}function O(t,s){if(t==null)return"null";const l=typeof t;if(l==="number"||l==="boolean"||l==="bigint")return String(t);if(l==="string")return JSON.stringify(t);if(l!=="object")return JSON.stringify(String(t));const u=s||new WeakSet;return u.has(t)?'"[circular]"':(u.add(t),t instanceof Date?JSON.stringify(t.toISOString()):Array.isArray(t)?`[${t.map(r=>O(r,u)).join(",")}]`:`{${Object.keys(t).sort().map(r=>`${JSON.stringify(r)}:${O(t[r],u)}`).join(",")}}`)}function v(t,s){if(A(t))return A(s)?0:1;if(A(s))return-1;const l=O(t),u=O(s);return l<u?-1:l>u?1:0}function b(t){if(A(t))return null;const s=String(t);if(s.trim()==="")return null;try{return JSON.parse(s)}catch{return s}}function c(t){const s=t&&t.cell&&t.cell.props;return V(s)?s:{}}const g=Object.freeze({json:{base:"object",storage:"object",format:t=>_(t&&t.value,c(t&&t.column)),parse:t=>b(t&&t.text),compare:v,defaults:{editor:"code",filter:"text",align:"start"},excel:"@",toClipboard:t=>{if(A(t))return"";if(typeof t=="string")return t;try{const s=JSON.stringify(t,null,2);return s===void 0?String(t):s}catch{return String(t)}},fromClipboard:t=>b(t)},secret:{base:"text",storage:"object",format:t=>H(t&&t.value,c(t&&t.column)),parse:t=>{const s=t&&t.text;return A(s)||String(s)===""?null:String(s)},compare:(t,s)=>{const l=A(t)||t==="",u=A(s)||s==="";return l===u?0:l?1:-1},defaults:{editor:"password",filter:"none",align:"start"},excel:"@",export:{csv:!1,excel:!1},toClipboard:t=>H(t),fromClipboard:t=>A(t)||String(t)===""?null:String(t)}}),o=g}),ze("packages/core/src/columns/types/unit.js",function(e,B){"use strict";Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"unitSystemNames",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"unitsOf",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"findUnit",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"localeSeparators",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return T}});const A=B("packages/core/src/internal/predicates.js").isNil,U=B("packages/core/src/internal/warn.js").warnOnce;function I(F,$,D,z){return Object.freeze({symbol:F,factor:$,aliases:Object.freeze(D||[]),binary:!!(z&&z.binary),prefix:z&&z.prefix||null,auto:!(z&&z.auto===!1)})}function J(F,$,D,z){return I(F,$,D,z)}const H=Object.freeze({data:Object.freeze([I("B",1,["byte","bytes"]),I("kB",1e3,["kilobyte","kilobytes"],{prefix:"k"}),I("KiB",1024,["kibibyte","kibibytes"],{binary:!0,prefix:"k"}),I("MB",1e6,["megabyte","megabytes"],{prefix:"m"}),I("MiB",1024**2,["mebibyte","mebibytes"],{binary:!0,prefix:"m"}),I("GB",1e9,["gigabyte","gigabytes"],{prefix:"g"}),I("GiB",1024**3,["gibibyte","gibibytes"],{binary:!0,prefix:"g"}),I("TB",1e12,["terabyte","terabytes"],{prefix:"t"}),I("TiB",1024**4,["tebibyte","tebibytes"],{binary:!0,prefix:"t"}),I("PB",1e15,["petabyte","petabytes"],{prefix:"p"})]),bitrate:Object.freeze([I("bps",1,["bit","bits","bit/s","b/s"]),I("kbps",1e3,["kbit","kbits","kbit/s","kb/s","kilobit","kilobits"],{prefix:"k"}),I("Mbps",1e6,["mbit","mbits","mbit/s","mb/s","megabit","megabits"],{prefix:"m"}),I("Gbps",1e9,["gbit","gbits","gbit/s","gb/s","gigabit","gigabits"],{prefix:"g"}),I("Tbps",1e12,["tbit","tbits","tbit/s","tb/s","terabit","terabits"],{prefix:"t"})]),length:Object.freeze([I("nm",1e-9,["nanometre","nanometres","nanometer","nanometers"]),I("µm",1e-6,["um","micrometre","micrometres","micrometer","micrometers","micron","microns"]),I("mm",.001,["millimetre","millimetres","millimeter","millimeters"]),I("cm",.01,["centimetre","centimetres","centimeter","centimeters"]),I("in",.0254,["inch","inches"],{auto:!1}),I("ft",.3048,["foot","feet"],{auto:!1}),I("yd",.9144,["yard","yards"],{auto:!1}),I("m",1,["metre","metres","meter","meters"]),I("km",1e3,["kilometre","kilometres","kilometer","kilometers"]),I("mi",1609.344,["mile","miles"],{auto:!1}),I("nmi",1852,["nauticalmile","nauticalmiles"],{auto:!1})]),mass:Object.freeze([I("mg",.001,["milligram","milligrams"]),I("g",1,["gram","grams"]),I("oz",28.349523125,["ounce","ounces"],{auto:!1}),I("lb",453.59237,["pound","pounds","lbs"],{auto:!1}),I("kg",1e3,["kilogram","kilograms"]),I("st",6350.29318,["stone"],{auto:!1}),I("t",1e6,["tonne","tonnes","ton"],{auto:!1}),I("ton (US)",907184.74,["ton","shortton"],{auto:!1}),I("ton (UK)",10160469088e-4,["ton","longton"],{auto:!1})]),duration:Object.freeze([I("ns",1e-9,["nsec","nsecs","nanosecond","nanoseconds"]),I("µs",1e-6,["us","usec","usecs","microsecond","microseconds"]),I("ms",.001,["msec","msecs","millisecond","milliseconds"]),I("s",1,["sec","secs","second","seconds"]),I("m",60,["min","mins","minute","minutes"]),I("h",3600,["hr","hrs","hour","hours"]),I("d",86400,["day","days"])]),speed:Object.freeze([I("mm/s",.001,["millimetre/s","millimeter/s"]),I("ft/s",.3048,["fps","foot/s","feet/s"],{auto:!1}),I("km/h",1/3.6,["kph","kmh","kilometre/h","kilometer/h"],{auto:!1}),I("mph",.44704,["mile/h","miles/h"],{auto:!1}),I("kn",1852/3600,["knot","knots"],{auto:!1}),I("m/s",1,["metre/s","meter/s","mps"]),I("km/s",1e3,["kilometre/s","kilometer/s"])]),acceleration:Object.freeze([I("mm/s²",.001,["mm/s2"]),I("ft/s²",.3048,["ft/s2"],{auto:!1}),I("m/s²",1,["m/s2","metre/s2","meter/s2"]),I("g",9.80665,["gee","gravity"],{auto:!1})]),area:Object.freeze([I("mm²",1e-6,["mm2"]),I("cm²",1e-4,["cm2"]),I("in²",64516e-8,["in2","sqin"],{auto:!1}),I("ft²",.09290304,["ft2","sqft"],{auto:!1}),I("yd²",.83612736,["yd2","sqyd"],{auto:!1}),I("m²",1,["m2","sqm"]),I("ha",1e4,["hectare","hectares"],{auto:!1}),I("ac",4046.8564224,["acre","acres"],{auto:!1}),I("km²",1e6,["km2","sqkm"])]),volume:Object.freeze([I("µL",1e-6,["ul","microlitre","microliter"]),I("mL",.001,["millilitre","milliliter"]),I("fl oz (US)",.0295735295625,["fl oz","usfloz"],{auto:!1}),I("fl oz (imp)",.0284130625,["fl oz","impfloz"],{auto:!1}),I("L",1,["litre","litres","liter","liters"]),I("gal (US)",3.785411784,["gal","usgal","usgallon"],{auto:!1}),I("gal (imp)",4.54609,["gal","impgal","impgallon"],{auto:!1}),I("m³",1e3,["m3","cubicmetre","cubicmeter","kl"],{auto:!1}),I("bbl",158.987294928,["barrel","barrels"],{auto:!1})]),energy:Object.freeze([I("eV",1602176634e-28,["electronvolt","electronvolts"],{auto:!1}),I("J",1,["joule","joules"]),I("cal",4.184,["calorie","calories"],{auto:!1}),I("kJ",1e3,["kilojoule","kilojoules"]),I("BTU",1055.05585262,["btu"],{auto:!1}),I("kcal",4184,["kilocalorie","kilocalories","Cal"],{auto:!1}),I("MJ",1e6,["megajoule","megajoules"]),I("kWh",36e5,["kilowatthour","kilowatthours"],{auto:!1}),I("GJ",1e9,["gigajoule","gigajoules"]),I("MWh",36e8,["megawatthour","megawatthours"],{auto:!1})]),power:Object.freeze([I("mW",.001,["milliwatt","milliwatts"]),I("W",1,["watt","watts"]),I("BTU/h",1055.05585262/3600,["btuh","btu/h"],{auto:!1}),I("kW",1e3,["kilowatt","kilowatts"]),I("hp",745.6998715822702,["horsepower"],{auto:!1}),I("MW",1e6,["megawatt","megawatts"]),I("GW",1e9,["gigawatt","gigawatts"])]),force:Object.freeze([I("mN",.001,["millinewton","millinewtons"]),I("N",1,["newton","newtons"]),I("lbf",4.4482216152605,["poundforce"],{auto:!1}),I("kgf",9.80665,["kilogramforce"],{auto:!1}),I("kN",1e3,["kilonewton","kilonewtons"]),I("MN",1e6,["meganewton","meganewtons"])]),pressure:Object.freeze([I("Pa",1,["pascal","pascals"]),I("mbar",100,["millibar"],{auto:!1}),I("inH₂O",249.0889,["inh2o"],{auto:!1}),I("mmHg",133.322387415,["torr"],{auto:!1}),I("kPa",1e3,["kilopascal","kilopascals"]),I("inHg",3386.388640341,["inhg"],{auto:!1}),I("psi",6894.757293168361,["lbf/in2"],{auto:!1}),I("bar",1e5,[],{auto:!1}),I("atm",101325,["atmosphere","atmospheres"],{auto:!1}),I("MPa",1e6,["megapascal","megapascals"]),I("GPa",1e9,["gigapascal","gigapascals"])]),torque:Object.freeze([I("N·m",1,["nm","n.m","newtonmetre","newtonmeter"]),I("lbf·ft",1.3558179483314003,["lbfft","lbf.ft","ftlb","ft-lb"],{auto:!1}),I("kN·m",1e3,["knm","kn.m"],{auto:!1}),I("MN·m",1e6,["mnm","mn.m"],{auto:!1})]),density:Object.freeze([I("kg/m³",1,["kg/m3"]),I("lb/ft³",16.01846337396014,["lb/ft3","pcf"],{auto:!1}),I("g/cm³",1e3,["g/cm3","g/ml","kg/l"],{auto:!1}),I("t/m³",1e3,["t/m3"],{auto:!1})]),flow:Object.freeze([I("L/min",1/6e4,["lpm","l/min"],{auto:!1}),I("m³/h",1/3600,["m3/h","cmh"],{auto:!1}),I("gpm (US)",.003785411784/60,["gpm","usgpm"],{auto:!1}),I("gpm (imp)",.00454609/60,["gpm","impgpm"],{auto:!1}),I("cfm",.0004719474432,["ft3/min"],{auto:!1}),I("L/s",.001,["lps","l/s"],{auto:!1}),I("m³/s",1,["m3/s","cms"])]),angle:Object.freeze([I("″",Math.PI/648e3,["arcsec","arcsecond","arcseconds"],{auto:!1}),I("′",Math.PI/10800,["arcmin","arcminute","arcminutes"],{auto:!1}),I("mrad",.001,["milliradian","milliradians"],{auto:!1}),I("mil",Math.PI/3200,["nato-mil"],{auto:!1}),I("°",Math.PI/180,["deg","degree","degrees"],{auto:!1}),I("gon",Math.PI/200,["grad","gradian","gradians"],{auto:!1}),I("rad",1,["radian","radians"]),I("turn",2*Math.PI,["rev","revolution","revolutions"],{auto:!1})]),angularVelocity:Object.freeze([I("°/s",Math.PI/180,["degps","deg/s","degrees/s"],{auto:!1}),I("rad/s",1,["radps","radians/s"]),I("rpm",2*Math.PI/60,["rev/min","r/min","revolutions/min"],{auto:!1}),I("rps",2*Math.PI,["rev/s","r/s","revolutions/s"],{auto:!1})]),fraction:Object.freeze([I("ppt",1e-12,["partspertrillion"],{auto:!1}),I("ppb",1e-9,["partsperbillion"]),I("ppm",1e-6,["partspermillion"]),I("bp",1e-4,["bps-finance","basispoint","basispoints","bips"],{auto:!1}),I("‰",.001,["permille","permil"],{auto:!1}),I("%",.01,["pct","percent"]),I("×",1,["x","ratio","times"])]),molarity:Object.freeze([I("pM",1e-12,["picomolar","picomolarity"]),I("nM",1e-9,["nanomolar","nanomolarity"]),I("µM",1e-6,["um-molar","micromolar","micromolarity"]),I("mM",.001,["millimolar","millimolarity"]),I("M",1,["molar","mol/l","mol/L","molarity"]),I("mol/m³",.001,["mol/m3"],{auto:!1})]),massFlow:Object.freeze([I("mg/s",1e-6,["milligrams/s"]),I("g/s",.001,["grams/s"]),I("kg/h",1/3600,["kilograms/h","kgph"],{auto:!1}),I("kg/s",1,["kilograms/s","kgps"]),I("t/h",1e3/3600,["tonnes/h","tph"],{auto:!1}),I("lb/h",.45359237/3600,["pounds/h","pph"],{auto:!1}),I("t/s",1e3,["tonnes/s"],{auto:!1})]),viscosity:Object.freeze([I("µPa·s",1e-6,["upas","micropascalsecond"]),I("cP",.001,["centipoise"],{auto:!1}),I("mPa·s",.001,["mpas","millipascalsecond"]),I("P",.1,["poise"],{auto:!1}),I("Pa·s",1,["pas","pascalsecond"])]),kinematicViscosity:Object.freeze([I("cSt",1e-6,["centistokes","centistoke"]),I("mm²/s",1e-6,["mm2/s"],{auto:!1}),I("St",1e-4,["stokes","stoke"],{auto:!1}),I("m²/s",1,["m2/s"])]),thermalConductivity:Object.freeze([I("mW/(m·K)",.001,["mw/mk"]),I("W/(m·K)",1,["w/mk","wmk"]),I("kW/(m·K)",1e3,["kw/mk"],{auto:!1}),I("BTU/(hr·ft·°F)",1.730734666,["btu/hrftf"],{auto:!1})]),specificHeat:Object.freeze([I("J/(kg·K)",1,["j/kgk","jkgk"]),I("kJ/(kg·K)",1e3,["kj/kgk"]),I("cal/(g·°C)",4184,["cal/gc"],{auto:!1})]),doseRate:Object.freeze([I("nSv/h",1e-9,["nsvh"]),I("µSv/h",1e-6,["usv/h","usvh"]),I("mSv/h",.001,["msvh"]),I("Sv/h",1,["svh"]),I("mSv/a",.001/8766,["msv/year","msvpa"],{auto:!1})])}),L=Symbol("ambiguous"),Y=new Map,_=new Map;function O(F,$){const D=String(F||"").trim();if(!D)throw new Error("[lattice] a unit system needs a name");if(H[D]||_.has(D))throw new Error(`[lattice] unit system "${D}" already exists`);const z=[...$||[]];if(!z.length)throw new Error(`[lattice] unit system "${D}" has no units`);if(!z.some(N=>N.factor===1))throw new Error(`[lattice] unit system "${D}" has no base unit (none with factor 1)`);const G=new Set;for(const N of z){if(G.has(N.symbol))throw new Error(`[lattice] unit system "${D}" declares "${N.symbol}" twice`);G.add(N.symbol)}return _.set(D,Object.freeze(z)),Y.delete(D),D}function v(){return[...Object.keys(H),..._.keys()]}function b(F){const $=c(F);return $?$.units:[]}function c(F){const $=String(F||""),D=Y.get($);if(D!==void 0)return D;const z=H[$]||_.get($);if(!z)return Y.set($,null),null;const G=Object.freeze([...z].sort((re,ie)=>re.factor-ie.factor)),N=new Map,Z=new Map,Q=(re,ie)=>{const ce=N.get(re);ce===void 0?N.set(re,ie):ce!==ie&&N.set(re,L)};for(const re of G){Q(re.symbol.toLowerCase(),re);for(const ie of re.aliases)Q(ie.toLowerCase(),re);if(re.prefix){const ie=Z.get(re.prefix)||[];ie.push(re),Z.set(re.prefix,ie)}}const ee={units:G,byToken:N,byPrefix:Z,decimal:G.filter(re=>!re.binary&&re.auto),binary:G.some(re=>re.binary)?G.filter(re=>(re.binary||re.factor===1)&&re.auto):null};return Y.set($,ee),ee}function g(F,$){return $&&F.binary||F.decimal}function o(F,$){const D=c(F);if(!D||A($))return null;const z=D.units.find(N=>N.symbol===String($));if(z)return z;const G=D.byToken.get(String($).trim().toLowerCase());return G&&G!==L?G:null}const t=new WeakMap;function s(F){const $=F||{};if(typeof $=="object"&&$!==null){const N=t.get($);if(N!==void 0)return N}const D=$.system||"data",z=c(D);let G=null;if(!z)U(`unit:system:${D}`,`unknown unit system "${D}"; known systems are ${v().join(", ")}`);else{let N=$.unit?o(D,$.unit):null;N||($.unit&&U(`unit:unit:${D}:${$.unit}`,`unknown unit "${$.unit}" in system "${D}"; falling back to ${z.units[0].symbol}`),N=z.units.find(Z=>Z.factor===1)||z.units[0]),G={index:z,base:N,binary:$.binary===!0}}return typeof $=="object"&&$!==null&&t.set($,G),G}const l=new WeakMap;function u(F,$){if(!F||!$||!Array.isArray(F.compound)||F.compound.length===0)return null;const D=l.get(F);if(D!==void 0)return D;const z=new Set,G=[];for(const Z of F.compound){const Q=o(F.system||"data",Z);if(!Q){U(`unit:compound:${F.system}:${Z}`,`unknown compound unit "${Z}" in system "${F.system||"data"}"; ignoring it`);continue}z.has(Q.symbol)||(z.add(Q.symbol),G.push(Q))}G.sort((Z,Q)=>Q.factor-Z.factor);const N=G.length>=2?G:null;return l.set(F,N),N}function n(F,$,D){return $===D||$.factor===D.factor?F:F*$.factor/D.factor}const p=new Map;function r(F){const $=F||"",D=p.get($);if(D)return D;const z={group:",",decimal:"."};try{for(const G of new Intl.NumberFormat(F||void 0).formatToParts(12345.6))G.type==="group"?z.group=G.value:G.type==="decimal"&&(z.decimal=G.value)}catch{}return p.set($,z),z}const i=/[\s ]/g,d=/^[+-]?[\d '’ .,]*(?:[eE][+-]?\d+)?/,h=/^[^\d+\-(.,\s]+\s*/,a=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/;function y(F,$){const{group:D,decimal:z}=r($);let G=String(F).replace(i,"");if(G==="")return null;const N=z?G.indexOf(z):-1;if(D&&D!==z){if(N>=0&&G.indexOf(D,N+z.length)>=0)return null;G=G.split(D).join("")}if(z&&z!=="."&&(G=G.split(z).join(".")),!a.test(G))return null;const Z=Number(G);return Number.isFinite(Z)?Z:null}function f(F,$,D){const z=String(F).trim().replace(/\.$/,"");if(z==="")return null;const G=$.units.find(ie=>ie.symbol===z);if(G)return G;const N=z.toLowerCase(),Z=$.byToken.get(N);if(Z===L)return null;if(Z)return Z;const Q=$.byPrefix.get(N);if(!Q||!Q.length)return null;const ee=g($,D),re=Q.filter(ie=>ee.includes(ie));return re.length===1?re[0]:null}function m(F,$,D,z){let G=F,N=0,Z=!1,Q=!1;for(;G!=="";){const ee=d.exec(G)[0];if(ee==="")return null;const re=y(ee,z&&z.locale);if(re===null)return null;G=G.slice(ee.length).trim();const ie=G.search(/[+-]?[\d]/),ce=(ie>=0?G.slice(0,ie):G).trim();if(G=ie>=0?G.slice(ie).trim():"",ce===""){if(Z)return null;Q=!0,N+=n(re,D[0],$.base)}else{const ve=f(ce,$.index,$.binary);if(!ve)return null;N+=n(re,ve,$.base)}if(Z=!0,Q&&G!=="")return null}return Z?N:null}function w(F,$){if(A(F))return null;if(typeof F=="number")return Number.isFinite(F)?F:null;const D=s($);if(!D)return null;let z=String(F).trim();if(z==="")return null;let G=!1;z.startsWith("(")&&z.endsWith(")")&&(G=!0,z=z.slice(1,-1).trim());const N=u($,D);if(N){z.startsWith("-")&&(G=!0,z=z.slice(1).trim());const he=m(z,D,N,$);return he===null?null:G?-he:he}let Z=null;const Q=h.exec(z);if(Q&&Q[0]){const he=f(Q[0].trim(),D.index,D.binary);he&&(Z=he,z=z.slice(Q[0].length).trim())}const ee=d.exec(z)[0],re=y(ee,$&&$.locale);if(re===null)return null;const ie=z.slice(ee.length).trim();if(Z&&ie!=="")return null;const ce=Z||(ie===""?D.base:f(ie,D.index,D.binary));if(!ce)return null;const ve=n(re,ce,D.base);return G?-ve:ve}const S=new Map;function M(F,$,D,z){const G=`${F||""}|${$}|${D}|${z?1:0}`;let N=S.get(G);return N||(N=new Intl.NumberFormat(F||void 0,{minimumFractionDigits:$,maximumFractionDigits:D,useGrouping:z}),S.set(G,N)),N}function X(F,$){if(!Number.isFinite(F)||F===0)return Math.max(0,$-1);const D=Math.floor(Math.log10(Math.abs(F)));return Math.min(20,Math.max(0,$-1-D))}function q(F,$){if(!Number.isFinite(F)||F===0)return F;const D=Math.ceil(Math.log10(Math.abs(F))),z=10**($-D);return Math.round(F*z)/z}function K(F,$,D){if(!D||D===$.base.symbol)return $.base;if(D!=="auto")return P($,D);if(F===0||!Number.isFinite(F))return $.base;const z=Math.abs(F)*$.base.factor,G=g($.index,$.binary);let N=G[0];for(const ee of G)z>=ee.factor&&(N=ee);if(z>=N.factor)return N;let Z=N;for(const ee of $.index.units)ee.binary!==$.binary&&ee.factor!==1||ee.factor<=z&&ee.factor>(Z===N?0:Z.factor)&&(Z=ee);if(Z!==N)return Z;let Q=N;for(const ee of $.index.units)ee.binary!==$.binary&&ee.factor!==1||ee.factor<Q.factor&&(Q=ee);return Q.factor<$.base.factor?Q:$.base}function P(F,$){const D=F.index.units.find(G=>G.symbol===$);if(D)return D;const z=F.index.byToken.get(String($).toLowerCase());return z&&z!==L?z:(U(`unit:display:${$}`,`unknown display unit "${$}"; rendering in ${F.base.symbol}`),F.base)}function k(F,$,D,z){const G=F<0;let N=Math.abs(F)*$.base.factor;const Z=typeof z.decimals=="number"?z.decimals:z.minDecimals??0,Q=typeof z.decimals=="number"?z.decimals:z.maxDecimals??Math.max(Z,2),ee=z.space??" ",re=[];for(let ce=0;ce<D.length;ce++){const ve=D[ce],he=ce===D.length-1;let ye=he?N/ve.factor:Math.floor(N/ve.factor);if(N-=ye*ve.factor,he){const Le=10**Q;ye=Math.round(ye*Le)/Le+0}const Oe=he?M(z.locale,Z,Q,z.group!==!1):M(z.locale,0,0,z.group!==!1);re.push(`${Oe.format(ye)}${ee}${ve.symbol}`)}const ie=re.join(" ");return G?`-${ie}`:ie}function E(F,$){const D=$||{},z=D.nullDisplay??"";if(A(F)||F==="")return z;const G=typeof F=="number"?F:Number(F);if(!Number.isFinite(G))return z;const N=s(D);if(!N)return String(G);const Z=u(D,N);if(Z)return k(G,N,Z,D);const Q=typeof D.significantFigures=="number"&&D.significantFigures>0?D.significantFigures:0,ee=Q?q(G,Q):G,re=K(ee,N,D.display),ie=n(ee,N.base,re);let ce=typeof D.decimals=="number"?D.decimals:D.minDecimals??0,ve=typeof D.decimals=="number"?D.decimals:D.maxDecimals??Math.max(ce,2);Q&&(ce=X(ie,Q),ve=ce);const he=M(D.locale,ce,ve,D.group!==!1).format(ie),ye=D.space??" ";return D.placement==="prefix"?`${re.symbol}${D.space??""}${he}`:`${he}${ye}${re.symbol}`}function C(F,$){const D=A(F)||Number.isNaN(F)?null:Number(F),z=A($)||Number.isNaN($)?null:Number($);return D===null||Number.isNaN(D)?z===null||Number.isNaN(z)?0:1:z===null||Number.isNaN(z)||D<z?-1:D>z?1:0}function x(F){const $=typeof F.decimals=="number"&&F.decimals>0?`.${"0".repeat(F.decimals)}`:"";return`${typeof F.decimals=="number"?`#,##0${$}`:"#,##0.##"}" ${F.symbol}"`}function j(F){const $={system:"data",...F||{}},D=s($),z=D?D.base.symbol:String($.unit||""),G=Object.freeze({...$,unit:z}),N=Object.freeze({...G,display:z,decimals:void 0,minDecimals:0,maxDecimals:20,group:!1}),Z=new Map([[G.locale||"",G]]),Q=ee=>{const re=ee||"";let ie=Z.get(re);return ie||(ie=Object.freeze({...G,locale:ee||void 0}),Z.set(re,ie)),ie};return{base:"number",extends:"number",storage:"float64",unitConfig:G,format:ee=>E(ee.value,ee.locale?Q(ee.locale):G),parse:ee=>w(ee.text,ee.locale?Q(ee.locale):G),compare:C,defaults:{filter:"number",editor:"unit",align:"end",total:$.total||"sum"},...$.totals?{totals:$.totals}:{},excel:$.excel||x({decimals:$.decimals,symbol:z}),toStorage:ee=>typeof ee=="number"?Number.isFinite(ee)?ee:null:typeof ee=="string"?w(ee,G):A(ee)?null:w(String(ee),G),toClipboard:ee=>E(ee,N),fromClipboard:ee=>w(ee,G)}}const T=j}),ze("packages/core/src/columns/types/engineering.js",function(e,B){"use strict";Object.defineProperty(e,"ENGINEERING_TYPES",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"circularMean",{enumerable:!0,get:function(){return I}});const A=B("packages/core/src/internal/predicates.js").isNil,U=B("packages/core/src/columns/types/unit.js").createUnitType;function I(L){const Y=2*Math.PI/L;return _=>{let O=0,v=0,b=0;for(const g of _||[]){if(A(g))continue;const o=Number(g);Number.isFinite(o)&&(O+=Math.cos(o*Y),v+=Math.sin(o*Y),b+=1)}return!b||Math.hypot(O,v)/b<1e-12?null:(Math.atan2(v,O)/Y%L+L)%L}}function J(L){return{supported:["sum","avg","min","max","count","countValues"],implement:{avg:I(L)}}}const H=Object.freeze({metres:U({system:"length",unit:"m",display:"auto",maxDecimals:3}),millimetres:U({system:"length",unit:"mm",maxDecimals:2}),kilometres:U({system:"length",unit:"km",maxDecimals:3}),grams:U({system:"mass",unit:"g",display:"auto",maxDecimals:3}),kilograms:U({system:"mass",unit:"kg",maxDecimals:3}),tonnes:U({system:"mass",unit:"t",maxDecimals:3}),seconds:U({system:"duration",unit:"s",display:"auto",maxDecimals:3}),milliseconds:U({system:"duration",unit:"ms",maxDecimals:3}),hours:U({system:"duration",unit:"h",maxDecimals:2}),speed:U({system:"speed",unit:"m/s",display:"auto",maxDecimals:2}),kph:U({system:"speed",unit:"km/h",maxDecimals:1}),mph:U({system:"speed",unit:"mph",maxDecimals:1}),knots:U({system:"speed",unit:"kn",maxDecimals:1}),acceleration:U({system:"acceleration",unit:"m/s²",maxDecimals:3}),area:U({system:"area",unit:"m²",display:"auto",maxDecimals:2}),hectares:U({system:"area",unit:"ha",maxDecimals:4}),volume:U({system:"volume",unit:"L",display:"auto",maxDecimals:3}),cubicMetres:U({system:"volume",unit:"m³",maxDecimals:3}),energy:U({system:"energy",unit:"J",display:"auto",maxDecimals:3}),kilowattHours:U({system:"energy",unit:"kWh",maxDecimals:2}),power:U({system:"power",unit:"W",display:"auto",maxDecimals:2}),kilowatts:U({system:"power",unit:"kW",maxDecimals:2}),force:U({system:"force",unit:"N",display:"auto",maxDecimals:2}),pressure:U({system:"pressure",unit:"Pa",display:"auto",maxDecimals:2}),bar:U({system:"pressure",unit:"bar",maxDecimals:3}),psi:U({system:"pressure",unit:"psi",maxDecimals:1}),torque:U({system:"torque",unit:"N·m",maxDecimals:2}),density:U({system:"density",unit:"kg/m³",maxDecimals:2}),flow:U({system:"flow",unit:"m³/s",maxDecimals:4}),litresPerMinute:U({system:"flow",unit:"L/min",maxDecimals:1}),radians:U({system:"angle",unit:"rad",maxDecimals:4,totals:J(2*Math.PI)}),degrees:U({system:"angle",unit:"°",maxDecimals:2,totals:J(360)}),rpm:U({system:"angularVelocity",unit:"rpm",maxDecimals:0}),angularVelocity:U({system:"angularVelocity",unit:"rad/s",maxDecimals:3}),ppm:U({system:"fraction",unit:"ppm",maxDecimals:2}),ppb:U({system:"fraction",unit:"ppb",maxDecimals:2}),basisPoints:U({system:"fraction",unit:"bp",maxDecimals:1}),molarity:U({system:"molarity",unit:"M",display:"auto",maxDecimals:3}),massFlow:U({system:"massFlow",unit:"kg/s",maxDecimals:3}),tonnesPerHour:U({system:"massFlow",unit:"t/h",maxDecimals:2}),viscosity:U({system:"viscosity",unit:"Pa·s",display:"auto",maxDecimals:3}),kinematicViscosity:U({system:"kinematicViscosity",unit:"cSt",maxDecimals:2}),thermalConductivity:U({system:"thermalConductivity",unit:"W/(m·K)",maxDecimals:3}),specificHeat:U({system:"specificHeat",unit:"J/(kg·K)",maxDecimals:1}),doseRate:U({system:"doseRate",unit:"µSv/h",display:"auto",maxDecimals:2})})}),ze("packages/core/src/columns/types/si.js",function(e,B){"use strict";Object.defineProperty(e,"SI_PREFIXES",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"siUnits",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"createSiSystem",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"createSiType",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"SI_TYPES",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return O}});const ne=B("packages/core/src/columns/types/unit.js"),A=ne.defineUnit,V=ne.registerUnitSystem,U=ne.createUnitType,I=Object.freeze([Object.freeze({symbol:"f",name:"femto",factor:1e-15}),Object.freeze({symbol:"p",name:"pico",factor:1e-12}),Object.freeze({symbol:"n",name:"nano",factor:1e-9}),Object.freeze({symbol:"µ",name:"micro",factor:1e-6}),Object.freeze({symbol:"m",name:"milli",factor:.001}),Object.freeze({symbol:"c",name:"centi",factor:.01}),Object.freeze({symbol:"",name:"",factor:1}),Object.freeze({symbol:"k",name:"kilo",factor:1e3}),Object.freeze({symbol:"M",name:"mega",factor:1e6}),Object.freeze({symbol:"G",name:"giga",factor:1e9}),Object.freeze({symbol:"T",name:"tera",factor:1e12}),Object.freeze({symbol:"P",name:"peta",factor:1e15})]),J=Object.freeze(["p","n","µ","m","","k","M","G"]);function H(v){const b=String(v.base),c=new Set([...v.prefixes||J,""]),g=[];for(const o of I){if(!c.has(o.symbol))continue;const t=`${o.symbol}${b}`,s=[];if(v.name){s.push(`${o.name}${v.name}`,`${o.name}${v.name}s`);const l=o.name.slice(-1);if(l&&v.name.startsWith(l)){const u=`${o.name.slice(0,-1)}${v.name}`;s.push(u,`${u}s`)}}o.symbol==="µ"&&s.push(`u${b}`),o.factor===1&&v.aliases&&s.push(...v.aliases),g.push(A(t,o.factor,s))}for(const o of v.extra||[])g.push(o);return g}function L(v,b){const c=H(b);return V(v,c)}function Y(v,b,c){return L(v,b),U({system:v,unit:b.base,display:"auto",maxDecimals:3,...c||{}})}const _=Object.freeze({voltage:Y("voltage",{base:"V",name:"volt"}),current:Y("current",{base:"A",name:"amp",aliases:["ampere","amperes"]}),resistance:Y("resistance",{base:"Ω",name:"ohm",aliases:["ohm","ohms","R"],prefixes:["m","","k","M","G"]}),capacitance:Y("capacitance",{base:"F",name:"farad",prefixes:["f","p","n","µ","m",""]}),inductance:Y("inductance",{base:"H",name:"henry",prefixes:["p","n","µ","m",""]}),charge:Y("charge",{base:"C",name:"coulomb",prefixes:["p","n","µ","m",""],extra:[A("mAh",3.6,["milliamphour","milliamphours"],{auto:!1}),A("Ah",3600,["amphour","amphours"],{auto:!1})]}),conductance:Y("conductance",{base:"S",name:"siemens",prefixes:["n","µ","m","","k"]}),fluxDensity:Y("fluxDensity",{base:"T",name:"tesla",prefixes:["n","µ","m",""],extra:[A("G",1e-4,["gauss"],{auto:!1})]}),luminousFlux:Y("luminousFlux",{base:"lm",name:"lumen",prefixes:["m","","k"]}),illuminance:Y("illuminance",{base:"lx",name:"lux",prefixes:["m","","k"]}),luminousIntensity:Y("luminousIntensity",{base:"cd",name:"candela",prefixes:["m","","k"]}),substance:Y("substance",{base:"mol",name:"mole",prefixes:["n","µ","m","","k"]}),absorbedDose:Y("absorbedDose",{base:"Gy",name:"gray",prefixes:["µ","m",""]}),equivalentDose:Y("equivalentDose",{base:"Sv",name:"sievert",prefixes:["n","µ","m",""]}),radioactivity:Y("radioactivity",{base:"Bq",name:"becquerel",prefixes:["","k","M","G","T"],extra:[A("Ci",37e9,["curie","curies"],{auto:!1})]}),frequency:Y("frequency",{base:"Hz",name:"hertz",prefixes:["m","","k","M","G","T"]})}),O=Y}),ze("packages/core/src/columns/types/temperature.js",function(e,B){"use strict";Object.defineProperty(e,"TEMPERATURE_SCALES",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"findScale",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"convertTemperature",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"formatTemperature",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"parseTemperature",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"createTemperatureType",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"TEMPERATURE_TYPES",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});const A=B("packages/core/src/internal/predicates.js").isNil,V=Object.freeze({C:Object.freeze({symbol:"°C",aliases:["c","°c","celsius","centigrade"],toKelvin:g=>g+273.15,fromKelvin:g=>g-273.15}),F:Object.freeze({symbol:"°F",aliases:["f","°f","fahrenheit"],toKelvin:g=>(g+459.67)*(5/9),fromKelvin:g=>g*(9/5)-459.67}),K:Object.freeze({symbol:"K",aliases:["k","kelvin"],toKelvin:g=>g,fromKelvin:g=>g}),R:Object.freeze({symbol:"°R",aliases:["r","°r","rankine"],toKelvin:g=>g*(5/9),fromKelvin:g=>g*(9/5)})});function U(g){if(A(g))return null;const o=String(g).trim();if(o==="")return null;for(const[s,l]of Object.entries(V))if(o===s||o===l.symbol)return{key:s,scale:l};const t=o.toLowerCase();for(const[s,l]of Object.entries(V))if(l.aliases.includes(t))return{key:s,scale:l};return null}function I(g,o,t){const s=U(o),l=U(t);return!s||!l||!Number.isFinite(Number(g))?null:s.key===l.key?Number(g):l.scale.fromKelvin(s.scale.toKelvin(Number(g)))}const J=new Map;function H(g,o,t){const s=`${g||""}|${o}|${t}`;let l=J.get(s);return l||(l=new Intl.NumberFormat(g||void 0,{minimumFractionDigits:o,maximumFractionDigits:t}),J.set(s,l)),l}function L(g,o){const t=o||{},s=t.nullDisplay??"";if(A(g)||g==="")return s;const l=Number(g);if(!Number.isFinite(l))return s;const u=U(t.scale||"C");if(!u)return String(l);const n=U(t.display||t.scale||"C")||u,p=n.key===u.key?l:n.scale.fromKelvin(u.scale.toKelvin(l)),r=typeof t.decimals=="number"?t.decimals:null,i=r??t.minDecimals??0,d=r??t.maxDecimals??1;return`${H(t.locale,i,d).format(p)}${t.space??" "}${n.scale.symbol}`}const Y=/^[+-]?[\d\s., ]*\d/;function _(g,o){const t=String(g).trim();if(t==="")return null;const s=new Intl.NumberFormat(o||void 0).formatToParts(1.1).find(p=>p.type==="decimal")?.value||".",l=s===","?".":",",u=t.split(l).join("").split(/[\s ]/).join("").replace(s,"."),n=Number(u);return Number.isFinite(n)?n:null}function O(g,o){if(A(g))return null;const t=o||{},s=U(t.scale||"C");if(!s)return null;if(typeof g=="number")return Number.isFinite(g)?g:null;let l=String(g).trim();if(l==="")return null;let u=!1;l.startsWith("(")&&l.endsWith(")")&&(u=!0,l=l.slice(1,-1).trim());const n=Y.exec(l);if(!n)return null;const p=_(n[0],t.locale);if(p===null)return null;const r=l.slice(n[0].length).trim();if(r==="")return u?-p:p;const i=U(r);if(!i)return null;const d=i.key===s.key?p:s.scale.fromKelvin(i.scale.toKelvin(p));return u?-d:d}function v(g){const o=Object.freeze({scale:"C",...g||{}}),s=(U(o.scale)||U("C")).scale.symbol,l=Object.freeze({...o,display:o.scale,decimals:void 0,minDecimals:0,maxDecimals:20}),u=new Map([[o.locale||"",o]]),n=p=>{const r=p||"";let i=u.get(r);return i||(i=Object.freeze({...o,locale:p||void 0}),u.set(r,i)),i};return{base:"number",extends:"number",storage:"float64",temperatureConfig:o,format:p=>L(p.value,p.locale?n(p.locale):o),parse:p=>O(p.text,p.locale?n(p.locale):o),defaults:{filter:"number",editor:"temperature",align:"end",total:"avg"},totals:{supported:["avg","min","max","count","countValues"]},excel:o.excel||`#,##0${typeof o.decimals=="number"&&o.decimals>0?`.${"0".repeat(o.decimals)}`:".#"}" ${s}"`,toStorage:p=>typeof p=="number"?Number.isFinite(p)?p:null:typeof p=="string"?O(p,o):A(p)?null:O(String(p),o),toClipboard:p=>L(p,l),fromClipboard:p=>O(p,o)}}const b=Object.freeze({celsius:v({scale:"C"}),fahrenheit:v({scale:"F"}),kelvin:v({scale:"K"})}),c=v}),ze("packages/core/src/columns/types/radix.js",function(e,B){"use strict";Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"digitsForWidth",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"radixRange",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"radixName",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"normaliseRadixOptions",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"compileRadixFormat",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"compileRadixParse",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"parseRadixResult",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return k}});const A=B("packages/core/src/internal/predicates.js").isNil,U=B("packages/core/src/internal/warn.js").warnOnce,I=Object.freeze({2:2,8:8,16:16,bin:2,binary:2,base2:2,oct:8,octal:8,base8:8,hex:16,hexadecimal:16,base16:16}),J=Object.freeze({2:1,8:3,16:4}),H=Object.freeze({2:"0b",8:"0o",16:"0x"}),L=Object.freeze({2:4,8:3,16:2}),Y=Object.freeze({2:/^[01]+$/,8:/^[0-7]+$/,16:/^[0-9a-f]+$/i}),_=Object.freeze({2:"binary",8:"octal",16:"hexadecimal"}),O=Object.freeze([[/^0x/i,16],[/^0b/i,2],[/^0o/i,8],[/^#/,16]]),v=/[\s\u00a0\u202f_,']/g,b=/^\d+(?:\.\d+)?(?:e[+-]?\d+)?$/i,c=Object.freeze([8,16,32,53]),g=new WeakSet,o=new WeakMap,t=new Map,s=new WeakMap,l=new WeakMap,u=Object.freeze({hex:Object.freeze({radix:16}),hex8:Object.freeze({radix:16,bitWidth:8,pad:!0,signed:!1}),hex16:Object.freeze({radix:16,bitWidth:16,pad:!0,signed:!1}),hex32:Object.freeze({radix:16,bitWidth:32,pad:!0,signed:!1}),binary:Object.freeze({radix:2}),binary8:Object.freeze({radix:2,bitWidth:8,pad:!0,signed:!1,group:4}),octal:Object.freeze({radix:8})});function n(E){if(E==null)return 16;const C=typeof E=="string"?E.toLowerCase():E,x=I[C];return x||(U(`radix:base:${String(E)}`,`unsupported radix ${String(E)}; use 2, 8, 16, 'binary', 'octal' or 'hex'. Falling back to hex`),16)}function p(E,C){return Math.ceil(E/J[C])}function r(E,C){if(!E)return C?{min:-Number.MAX_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER}:{min:0,max:Number.MAX_SAFE_INTEGER};if(!C)return{min:0,max:2**E-1};const x=2**(E-1);return{min:-x,max:x-1}}function i(E){return _[E]||"hexadecimal"}function d(E){if(typeof E=="string"){const C=u[E];return C||U(`radix:preset:${E}`,`unknown radix preset "${E}"; known presets are ${Object.keys(u).join(", ")}`),{...C||{}}}if(E&&typeof E.preset=="string"){const C=u[E.preset];return C||U(`radix:preset:${E.preset}`,`unknown radix preset "${E.preset}"; known presets are ${Object.keys(u).join(", ")}`),{...C||{},...E}}return E||{}}function h(E){const C=d(E),x=n(C.radix),j=J[x];let T=null;if(C.bitWidth!==void 0&&C.bitWidth!==null&&C.bitWidth!==!1){const ee=Number(C.bitWidth);c.includes(ee)?T=ee:U(`radix:width:${String(C.bitWidth)}`,`unsupported bitWidth ${String(C.bitWidth)}; use 8, 16, 32 or 53. Ignoring it`)}let F=C.signed!==!1;!F&&T===null&&(U("radix:unsigned:width","signed: false needs a bitWidth to render a two's-complement pattern; defaulting to 32"),T=32);const $=C.prefix===void 0||C.prefix===!0?H[x]:C.prefix===!1?"":String(C.prefix);let D=0;C.pad===!0?D=T?p(T,x):0:typeof C.pad=="number"&&C.pad>0&&(D=Math.floor(C.pad));let z=0;C.group===!0?z=L[x]:typeof C.group=="number"&&C.group>0&&(z=Math.floor(C.group));const G=r(T,F),N=typeof C.min=="number"?Math.max(G.min,C.min):G.min,Z=typeof C.max=="number"?Math.min(G.max,C.max):G.max,Q=Object.freeze({radix:x,bits:j,prefix:$,uppercase:C.uppercase!==!1,pad:D,group:z,groupSeparator:typeof C.groupSeparator=="string"?C.groupSeparator:" ",bitWidth:T,signed:F,min:N,max:Z<N?N:Z,nullDisplay:typeof C.nullDisplay=="string"?C.nullDisplay:"",name:i(x)});return g.add(Q),Q}function a(E){if(E&&g.has(E))return E;if(typeof E=="string"){let C=t.get(E);return C||(C=h(E),t.set(E,C)),C}if(E&&typeof E=="object"){let C=o.get(E);return C||(C=h(E),o.set(E,C)),C}return a("hex")}function y(E){return E<0?-Math.round(-E):Math.round(E)}function f(E,C,x){if(C<=0||E.length<=C)return E;const j=E.length%C||C,T=[E.slice(0,j)];for(let F=j;F<E.length;F+=C)T.push(E.slice(F,F+C));return T.join(x)}function m(E){const C=a(E),{radix:x,prefix:j,uppercase:T,pad:F,group:$,groupSeparator:D,signed:z,bitWidth:G,nullDisplay:N}=C,Z=G?2**G:0,Q=ee=>{if(A(ee)||ee==="")return N;const re=typeof ee=="number"?ee:Number(ee);if(!Number.isFinite(re))return N;const ie=y(re);let ce="",ve=ie;ie<0&&(z?(ce="-",ve=-ie):ve=(ie%Z+Z)%Z);let he=ve.toString(x);return he=T?he.toUpperCase():he.toLowerCase(),F>0&&he.length<F&&(he=he.padStart(F,"0")),$>0&&(he=f(he,$,D)),ce+j+he};return Q.options=C,Q}function w(E,C){const x=a(C);let j=s.get(x);return j||(j=m(x),s.set(x,j)),j(E)}function S(E){const C=a(E),{radix:x,groupSeparator:j,signed:T,min:F,max:$}=C,D=Y[x],z=G=>{if(A(G))return{ok:!0,value:null,reason:"blank"};let N=String(G);if(j&&j!==""&&(N=N.split(j).join("")),N=N.replace(v,""),N==="")return{ok:!0,value:null,reason:"blank"};let Z=!1;if((N[0]==="-"||N[0]==="+")&&(Z=N[0]==="-",N=N.slice(1)),N==="")return{ok:!1,value:null,reason:"digits"};let Q=null;for(const[re,ie]of O){const ce=re.exec(N);if(!ce)continue;const ve=N.slice(ce[0].length);if(ve==="")break;if(!Y[ie].test(ve))return{ok:!1,value:null,reason:"digits"};Q=parseInt(ve,ie);break}if(Q===null)if(D.test(N))Q=parseInt(N,x);else if(b.test(N))Q=Number(N);else return{ok:!1,value:null,reason:"digits"};if(!Number.isFinite(Q))return{ok:!1,value:null,reason:"digits"};const ee=y(Z?-Q:Q);return!T&&ee<0?{ok:!1,value:ee,reason:"negative"}:ee<F||ee>$?{ok:!1,value:ee,reason:"range"}:{ok:!0,value:ee,reason:"ok"}};return z.options=C,z}function M(E,C){const x=a(C);let j=l.get(x);return j||(j=S(x),l.set(x,j)),j(E)}function X(E,C){const x=M(E,C);return x.ok?x.value:null}function q(E,C){const x=A(E)||Number.isNaN(E)?null:Number(E),j=A(C)||Number.isNaN(C)?null:Number(C);return x===null?j===null?0:1:j===null||x<j?-1:x>j?1:0}function K(E){const C=E.min>=-2147483648&&E.max<=2147483647;return E.bitWidth&&C?"int32":"float64"}function P(E){const C=h(E),x=m(C),j=S(C);return{base:"number",extends:"number",storage:K(C),matches:null,format:T=>x(T.value),parse:T=>{const F=j(T.text);return F.ok?F.value:null},compare:q,defaults:{filter:"number",editor:"radix",total:"sum",align:"end"},excel:"General",toClipboard:T=>x(T),fromClipboard:T=>{const F=j(T);return F.ok?F.value:null},radix:C,formatValue:x,parseText:j}}const k=P}),ze("packages/core/src/columns/types/aggregable.js",function(e,B){"use strict";Object.defineProperty(e,"createLogarithmicType",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"createRatioType",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"AGGREGABLE_TYPES",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"weightedMean",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"logarithmicSum",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"logarithmicMean",{enumerable:!0,get:function(){return I}});const A=B("packages/core/src/internal/predicates.js").isNil;function V(_){const O=[];for(const v of _||[]){if(A(v))continue;const b=Number(v);Number.isFinite(b)&&O.push(b)}return O}function U(_){return O=>{const v=V(O);if(!v.length)return null;let b=0;for(const c of v)b+=10**(c/_);return _*Math.log10(b)}}function I(_){return O=>{const v=V(O);if(!v.length)return null;let b=0;for(const c of v)b+=10**(c/_);return _*Math.log10(b/v.length)}}function J(_,O){const v=O&&O.column,c=(v&&v.typeOptions||{}).weight,g=O&&O.valueAt;if(!c||typeof g!="function")return null;let o=0,t=0;for(let s=0;s<_.length;s++){if(A(_[s]))continue;const l=Number(_[s]);if(!Number.isFinite(l))continue;const u=g(c,s);if(A(u))continue;const n=Number(u);!Number.isFinite(n)||n<=0||(o+=l*n,t+=n)}return t===0?null:o/t}function H(_={}){const O=_.factor===20?20:10,v=typeof _.suffix=="string"?_.suffix:"",b=Number.isInteger(_.decimals)?_.decimals:1;return{base:"number",storage:"float64",name:_.name||"logarithmic",format:c=>{const g=c&&c.value;return A(g)||!Number.isFinite(Number(g))?"":`${Number(g).toFixed(b)}${v}`},parse:c=>{const g=String((c&&c.text)??"").replace(v,"").trim();if(!g)return null;const o=Number(g);return Number.isFinite(o)?o:null},defaults:{align:"end",filter:"number"},totals:{supported:["sum","avg","min","max","count","countValues"],implement:{sum:U(O),avg:I(O)}}}}function L(_={}){const O=Number.isInteger(_.decimals)?_.decimals:1,v=_.percent===!0;return{base:"number",storage:"float64",name:_.name||"ratio",format:b=>{const c=b&&b.value;return A(c)||!Number.isFinite(Number(c))?"":v?`${Number(c).toFixed(O)}%`:Number(c).toFixed(O)},parse:b=>{const c=String((b&&b.text)??"").replace("%","").trim();if(!c)return null;const g=Number(c);return Number.isFinite(g)?g:null},defaults:{align:"end",filter:"number"},totals:{supported:["avg","min","max","count","countValues"],implement:{avg:J}}}}const Y=Object.freeze({decibel:H({name:"decibel",factor:10,suffix:" dB"}),decibelAmplitude:H({name:"decibelAmplitude",factor:20,suffix:" dB"}),ratio:L({name:"ratio"}),percentRate:L({name:"percentRate",percent:!0})})}),ze("packages/core/src/columns/types/currency.js",function(e,B){"use strict";Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"normaliseCode",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"toMoney",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"moneyToText",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"moneyComparator",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"CURRENCY_TYPES",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return n}});const A=B("packages/core/src/internal/predicates.js").isNil,V="⚠ no rate";function U(p){if(A(p))return null;const r=String(p).trim().toUpperCase();return r===""?null:r}function I(p){if(A(p))return null;if(typeof p=="object"&&!Array.isArray(p)){const r=Number(p.amount),i=U(p.code);return!i||!Number.isFinite(r)?null:{amount:r,code:i}}if(Array.isArray(p)&&p.length===2){const r=Number(p[0]),i=U(p[1]);return!i||!Number.isFinite(r)?null:{amount:r,code:i}}return null}const J=Object.freeze({$:"USD","€":"EUR","£":"GBP","¥":"JPY","₹":"INR","₩":"KRW","₽":"RUB","₺":"TRY","₴":"UAH","₪":"ILS"}),H=Object.freeze({USD:"$",EUR:"€",GBP:"£",JPY:"¥",INR:"₹",KRW:"₩",RUB:"₽",TRY:"₺",UAH:"₴",ILS:"₪"}),L=/[+-]?[\d\s., ]*\d/;function Y(p,r){const i=String(p).trim();if(i==="")return null;const d=new Intl.NumberFormat(r||void 0).formatToParts(1.1).find(f=>f.type==="decimal")?.value||".",h=d===","?".":",",a=i.split(h).join("").split(/[\s ]/).join("").replace(d,"."),y=Number(a);return Number.isFinite(y)?y:null}function _(p,r){const i=r||{},d=U(i.code);if(A(p))return null;const h=I(p);if(h)return h;if(typeof p=="number")return Number.isFinite(p)&&d?{amount:p,code:d}:null;let a=String(p).trim();if(a==="")return null;let y=!1;a.startsWith("(")&&a.endsWith(")")&&(y=!0,a=a.slice(1,-1).trim());let f=null;for(const[q,K]of Object.entries(J)){if(a.startsWith(q)){f=K,a=a.slice(q.length).trim();break}if(a.endsWith(q)){f=K,a=a.slice(0,-q.length).trim();break}}const m=L.exec(a);if(!m)return null;const w=Y(m[0],i.locale);if(w===null)return null;const S=(a.slice(0,m.index)+" "+a.slice(m.index+m[0].length)).trim();!f&&S!==""&&(f=U(S));const M=f||d;return M?{amount:y?-w:w,code:M}:null}function O(p,r){if(typeof p=="function")return(i,d)=>{if(i===d)return 1;const h=p(i,d);return typeof h=="number"&&Number.isFinite(h)&&h>0?h:null};if(p&&typeof p=="object"){const i=p;return(d,h)=>{if(d===h)return 1;const a=Number(i[d]),y=Number(i[h]);return!Number.isFinite(a)||!Number.isFinite(y)||a<=0||y<=0?null:y/a}}return(i,d)=>i===d?1:null}function v(p,r,i){if(!p)return null;if(p.code===r)return p.amount;const d=i(p.code,r);return d===null?null:p.amount*d}const b=new Map;function c(p,r,i){const d=`${p||""}|${r}|${i??""}`;let h=b.get(d);if(!h){const a={style:"currency",currency:r};typeof i=="number"&&(a.minimumFractionDigits=i,a.maximumFractionDigits=i);try{h={fmt:new Intl.NumberFormat(p||void 0,a),currency:!0}}catch{h={fmt:new Intl.NumberFormat(p||void 0,typeof i=="number"?{minimumFractionDigits:i,maximumFractionDigits:i}:{}),currency:!1}}b.set(d,h)}return h}function g(p,r){const i=r||{},d=i.nullDisplay??"",h=I(p);if(!h)return d;const a=U(i.display)||h.code;let y=h.amount,f=h.code;if(a!==h.code){const S=i.rateFn||O(i.rates,i.rateBase),M=v(h,a,S);if(M===null)return`${i.missingRate??V} ${h.code}→${a}`;y=M,f=a}const{fmt:m,currency:w}=c(i.locale,f,i.decimals);return w?m.format(y):`${m.format(y)} ${f}`}function o(p){const r=I(p);return r?`${r.amount} ${r.code}`:""}function t(p){const r=p||{},i=U(r.display),d=r.rateFn||O(r.rates,r.rateBase);return(h,a)=>{const y=I(h),f=I(a);if(!y&&!f)return 0;if(!y)return 1;if(!f)return-1;if(i){const m=v(y,i,d),w=v(f,i,d);if(m!==null&&w!==null)return m===w?0:m<w?-1:1}return y.code===f.code?y.amount===f.amount?0:y.amount<f.amount?-1:1:y.code<f.code?-1:1}}function s(p){const r=p||{},i=(h,a)=>{const y=[];for(const M of h||[]){const X=I(M);X&&y.push(X)}if(!y.length)return null;if(new Set(y.map(M=>M.code)).size===1){const M=y[0].code;return{amount:a(y.map(X=>X.amount)),code:M}}const m=U(r.display);if(!m)return`${r.missingRate??V}: mixed currencies, no display currency set`;const w=r.rateFn||O(r.rates,r.rateBase),S=[];for(const M of y){const X=v(M,m,w);if(X===null)return`${r.missingRate??V}: ${M.code}→${m}`;S.push(X)}return{amount:a(S),code:m}},d=h=>h.reduce((a,y)=>a+y,0);return{sum:h=>i(h,d),avg:h=>i(h,a=>d(a)/a.length),min:h=>i(h,a=>Math.min(...a)),max:h=>i(h,a=>Math.max(...a))}}function l(p){const r=Object.freeze({code:"USD",...p||{}}),i=O(r.rates,r.rateBase),d=Object.freeze({...r,rateFn:i}),h=s(d),a=t(d),y=new Map([[r.locale||"",d]]),f=S=>{const M=S||"";let X=y.get(M);return X||(X=Object.freeze({...d,locale:S||void 0}),y.set(M,X)),X},m=H[U(r.display||r.code)]||"",w=typeof r.decimals=="number"&&r.decimals>0?`.${"0".repeat(r.decimals)}`:".00";return{base:"object",extends:"object",storage:"object",name:"currency",currencyConfig:d,format:S=>g(S.value,S.locale?f(S.locale):d),parse:S=>_(S.text,S.locale?f(S.locale):d),compare:a,defaults:{filter:"number",editor:"currency",align:"end",total:"sum"},totals:{supported:["sum","avg","min","max","count","countValues"],implement:h},excel:r.excel||(m?`"${m}"#,##0${w}`:`#,##0${w}`),toStorage:S=>{const M=I(S);return M||(typeof S=="string"||typeof S=="number"?_(S,d):null)},toClipboard:S=>o(S),fromClipboard:S=>_(S,d)}}const u=Object.freeze({currency:l({code:"USD"}),usd:l({code:"USD"}),eur:l({code:"EUR"}),gbp:l({code:"GBP"}),jpy:l({code:"JPY",decimals:0})}),n=l}),ze("packages/core/src/columns/types/index.js",function(e,B){"use strict";Object.defineProperty(e,"EXTENDED_TYPES",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"unitSystemNames",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"unitsOf",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"SI_TYPES",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"createSiType",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"createSiSystem",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"siUnits",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"SI_PREFIXES",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return q}});const ne=B("packages/core/src/columns/types/temporal.js"),A=ne.TEMPORAL_TYPES,V=B("packages/core/src/columns/types/network.js"),U=V.NETWORK_TYPES,I=B("packages/core/src/columns/types/structured.js"),J=I.STRUCTURED_TYPES,H=B("packages/core/src/columns/types/unit.js"),L=H.createUnitType,Y=H.UNIT_SYSTEMS,_=H.parseUnit,O=H.formatUnit,v=H.registerUnitSystem,b=H.unitSystemNames,c=H.unitsOf,g=H.defineUnit,o=B("packages/core/src/columns/types/engineering.js"),t=o.ENGINEERING_TYPES,s=B("packages/core/src/columns/types/si.js"),l=s.SI_TYPES,u=s.createSiType,n=s.createSiSystem,p=s.siUnits,r=s.SI_PREFIXES,i=B("packages/core/src/columns/types/temperature.js"),d=i.TEMPERATURE_TYPES,h=i.createTemperatureType,a=i.convertTemperature,y=i.formatTemperature,f=i.parseTemperature,m=i.TEMPERATURE_SCALES,w=B("packages/core/src/columns/types/radix.js"),S=w.createRadixType,M=w.RADIX_PRESETS,X=w.parseRadix,q=w.formatRadix,K=B("packages/core/src/columns/types/aggregable.js"),P=K.AGGREGABLE_TYPES,k=B("packages/core/src/columns/types/currency.js"),E=k.CURRENCY_TYPES,C=k.createCurrencyType,x=k.parseMoney,j=k.formatMoney,T=k.convertMoney,F=k.toMoney,$=k.rateFunction,D=k.moneyComparator,z=k.normaliseCode,G=k.MISSING_RATE;Object.defineProperty(e,"findUnit",{enumerable:!0,get:function(){return H.findUnit}}),Object.defineProperty(e,"ENGINEERING_TYPES",{enumerable:!0,get:function(){return o.ENGINEERING_TYPES}}),Object.defineProperty(e,"circularMean",{enumerable:!0,get:function(){return o.circularMean}}),Object.defineProperty(e,"TEMPERATURE_TYPES",{enumerable:!0,get:function(){return i.TEMPERATURE_TYPES}}),Object.defineProperty(e,"createTemperatureType",{enumerable:!0,get:function(){return i.createTemperatureType}}),Object.defineProperty(e,"convertTemperature",{enumerable:!0,get:function(){return i.convertTemperature}}),Object.defineProperty(e,"formatTemperature",{enumerable:!0,get:function(){return i.formatTemperature}}),Object.defineProperty(e,"parseTemperature",{enumerable:!0,get:function(){return i.parseTemperature}}),Object.defineProperty(e,"TEMPERATURE_SCALES",{enumerable:!0,get:function(){return i.TEMPERATURE_SCALES}}),Object.defineProperty(e,"findScale",{enumerable:!0,get:function(){return i.findScale}}),Object.defineProperty(e,"CURRENCY_TYPES",{enumerable:!0,get:function(){return k.CURRENCY_TYPES}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return k.createCurrencyType}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return k.parseMoney}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return k.formatMoney}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return k.convertMoney}}),Object.defineProperty(e,"toMoney",{enumerable:!0,get:function(){return k.toMoney}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return k.rateFunction}}),Object.defineProperty(e,"moneyComparator",{enumerable:!0,get:function(){return k.moneyComparator}}),Object.defineProperty(e,"normaliseCode",{enumerable:!0,get:function(){return k.normaliseCode}}),Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return k.MISSING_RATE}}),Object.defineProperty(e,"TEMPORAL_TYPES",{enumerable:!0,get:function(){return ne.TEMPORAL_TYPES}}),Object.defineProperty(e,"NETWORK_TYPES",{enumerable:!0,get:function(){return V.NETWORK_TYPES}}),Object.defineProperty(e,"STRUCTURED_TYPES",{enumerable:!0,get:function(){return I.STRUCTURED_TYPES}}),Object.defineProperty(e,"AGGREGABLE_TYPES",{enumerable:!0,get:function(){return K.AGGREGABLE_TYPES}}),Object.defineProperty(e,"createLogarithmicType",{enumerable:!0,get:function(){return K.createLogarithmicType}}),Object.defineProperty(e,"createRatioType",{enumerable:!0,get:function(){return K.createRatioType}}),Object.defineProperty(e,"parseTime",{enumerable:!0,get:function(){return ne.parseTime}}),Object.defineProperty(e,"formatTime",{enumerable:!0,get:function(){return ne.formatTime}}),Object.defineProperty(e,"parseDateTime",{enumerable:!0,get:function(){return ne.parseDateTime}}),Object.defineProperty(e,"formatDateTime",{enumerable:!0,get:function(){return ne.formatDateTime}}),Object.defineProperty(e,"parseDuration",{enumerable:!0,get:function(){return ne.parseDuration}}),Object.defineProperty(e,"formatDuration",{enumerable:!0,get:function(){return ne.formatDuration}}),Object.defineProperty(e,"parseIpv4",{enumerable:!0,get:function(){return V.parseIpv4}}),Object.defineProperty(e,"formatIpv4",{enumerable:!0,get:function(){return V.formatIpv4}}),Object.defineProperty(e,"parseCidr",{enumerable:!0,get:function(){return V.parseCidr}}),Object.defineProperty(e,"formatCidr",{enumerable:!0,get:function(){return V.formatCidr}}),Object.defineProperty(e,"parseIpv6",{enumerable:!0,get:function(){return V.parseIpv6}}),Object.defineProperty(e,"formatIpv6",{enumerable:!0,get:function(){return V.formatIpv6}}),Object.defineProperty(e,"networkAddress",{enumerable:!0,get:function(){return V.networkAddress}}),Object.defineProperty(e,"broadcastAddress",{enumerable:!0,get:function(){return V.broadcastAddress}}),Object.defineProperty(e,"hostCount",{enumerable:!0,get:function(){return V.hostCount}}),Object.defineProperty(e,"containsAddress",{enumerable:!0,get:function(){return V.containsAddress}}),Object.defineProperty(e,"overlaps",{enumerable:!0,get:function(){return V.overlaps}}),Object.defineProperty(e,"maskValue",{enumerable:!0,get:function(){return I.maskValue}}),Object.defineProperty(e,"summariseJson",{enumerable:!0,get:function(){return I.summariseJson}});const N=Object.freeze({...A,...U,...J,...P,hex:S(M.hex),hex8:S(M.hex8),hex16:S(M.hex16),hex32:S(M.hex32),binary:S(M.binary),binary8:S(M.binary8),octal:S(M.octal),bytes:L({system:"data",unit:"B",display:"auto"}),megabytes:L({system:"data",unit:"MB"}),gigabytes:L({system:"data",unit:"GB"}),bitrate:L({system:"bitrate",unit:"Mbps"}),gigabits:L({system:"bitrate",unit:"Gbps"}),...t,...l,...d,...E});{const Z=new Set;for(const Q of[A,U,J,P,t,l,d,E])for(const ee of Object.keys(Q)){if(Z.has(ee))throw new Error(`[lattice] data type "${ee}" is declared twice`);Z.add(ee)}}}),ze("packages/core/src/compute/handle.js",function(e,B){"use strict";Object.defineProperty(e,"identity",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"rowCount",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"bitReader",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"presenceReader",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"dictSize",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"dictValue",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"multiValue",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"valueReader",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"numericTotalOrder",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"valueComparator",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"dictRanks",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"isMissing",{enumerable:!0,get:function(){return l}});const ne=B("packages/core/src/internal/compare.js"),A=ne.collator,V=ne.defaultCompare,I=B("packages/core/src/internal/warn.js").warnOnce;function J(u){const n=new Uint32Array(u);for(let p=0;p<u;p++)n[p]=p;return n}function H(u,n){if(n&&typeof n.count=="number")return n.count;if(!u)return 0;if(typeof u.count=="number")return u.count;if(typeof u.length=="number")return u.length;const p=u.values;return u.kind==="multi"&&u.offsets?Math.max(0,u.offsets.length-1):p?u.kind==="bitset"?typeof p.size=="number"?p.size:u.presence&&typeof u.presence.size=="number"?u.presence.size:(I(`count:${u.id}`,`column "${u.id}" is bitset-backed with no declared row count; assuming ${p.length*8}`),p.length*8):p.length:u.presence&&typeof u.presence.size=="number"?u.presence.size:0}const L=new WeakMap;function Y(u){const n=u.constructor;if(!n)return"unknown";const p=L.get(n);if(p)return p;let r="unknown";try{let i=null;typeof n.from=="function"?i=n.from([!1,!0]):(i=new n(8),i.set(1));const d=i&&i.words;d&&d.length&&(d[0]===2?r="lsb":d[0]===64&&(r="msb"))}catch{r="unknown"}return L.set(n,r),r}function _(u){if(!u)return()=>0;const n=u instanceof Uint8Array?u:u.words;if(n instanceof Uint8Array){const p=u instanceof Uint8Array?"lsb":Y(u);if(p==="lsb")return r=>n[r>>>3]>>>(r&7)&1;if(p==="msb")return r=>n[r>>>3]>>>7-(r&7)&1}return typeof u.get=="function"?p=>u.get(p)?1:0:()=>0}function O(u){return!u||!u.presence?null:_(u.presence)}function v(u){return u?typeof u.size=="number"?u.size:typeof u.values=="function"?u.values().length:0:0}function b(u,n){return u?typeof u.valueOf=="function"?u.valueOf(n):typeof u.values=="function"?u.values()[n]:null:null}function c(u,n){const p=u.offsets,r=u.values;if(!p||!r)return[];const i=p[n],d=p[n+1];if(!(d>i))return[];const h=u.dict,a=new Array(d-i);for(let y=i;y<d;y++)a[y-i]=h?b(h,r[y]):r[y];return a}function g(u){if(!u)return()=>{};const n=u.values,p=O(u),r=u.kind;if(r==="dictionary"){const i=u.dict;return p?d=>p(d)?b(i,n[d]):null:d=>b(i,n[d])}if(r==="bitset"){const i=_(n);return p?d=>p(d)?i(d)===1:null:d=>i(d)===1}if(r==="multi")return p?i=>p(i)?c(u,i):null:i=>c(u,i);if(!n&&typeof u.get=="function"){const i=u.get.bind(u);return d=>{const h=i(d);return h===void 0?null:h}}return p?i=>{if(!p(i))return null;const d=n[i];return d===void 0?null:d}:i=>{const d=n[i];return d===void 0?null:d}}function o(u,n){if(u<n)return-1;if(u>n)return 1;if(u===n){const i=Object.is(u,-0),d=Object.is(n,-0);return i===d?0:i?-1:1}const p=Number.isNaN(u),r=Number.isNaN(n);return p&&r?0:p?1:-1}function t(u){const n=A(u);return(p,r)=>{if(p===r)return 0;const i=typeof p,d=typeof r;if(i==="string"&&d==="string")return n.compare(p,r);if(i==="number"&&d==="number")return o(p,r);if(i==="boolean"&&d==="boolean")return p===r?0:p?1:-1;if(p instanceof Date||r instanceof Date){const h=p instanceof Date?p.getTime():Number(p),a=r instanceof Date?r.getTime():Number(r);return o(h,a)}return V(p,r)}}function s(u,n){if(u&&typeof u.ranks=="function")return u.ranks(n);const p=u&&typeof u.values=="function"?u.values():[],r=p.length,i=t(n),d=new Array(r);for(let a=0;a<r;a++)d[a]=a;d.sort((a,y)=>i(p[a],p[y])||a-y);const h=new Uint32Array(r);for(let a=0;a<r;a++)h[d[a]]=a;return h}function l(u){return u==null||typeof u=="number"&&Number.isNaN(u)}}),ze("packages/core/src/compute/filter.js",function(e,B){"use strict";Object.defineProperty(e,"releaseMask",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"compilePredicate",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"wallMs",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"itemwisePredicate",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"evaluateCondition",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"pruneColumn",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"mentionsColumn",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return re}}),Object.defineProperty(e,"declareOperators",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(e,"declaredOperator",{enumerable:!0,get:function(){return ve}});const A=B("packages/core/src/internal/predicates.js").isBlank,U=B("packages/core/src/internal/merge.js").toArray,J=B("packages/core/src/internal/warn.js").warnOnce,H=B("packages/core/src/format/date.js"),L=H.toDate,Y=H.toIsoDate,_=B("packages/core/src/compute/handle.js"),O=_.bitReader,v=_.dictSize,b=_.dictValue,c=_.presenceReader,g=_.valueComparator,o=_.valueReader,t=/^\d{4}-\d{2}-\d{2}$/,s="\0null\0";function l(he,ye){const Oe=he&&he.pool;if(Oe){const Le=Oe.mask||Oe.acquireMask||Oe.acquire||Oe.take;if(typeof Le=="function"){const fe=Le.call(Oe,ye);if(fe&&fe.length>=ye)return fe}}return new Uint8Array(ye)}function u(he,ye){const Oe=he&&he.pool;if(!Oe||!ye)return;const Le=Oe.release||Oe.releaseMask||Oe.free||Oe.recycle;typeof Le=="function"&&Le.call(Oe,ye)}function n(he,ye,Oe){return he.fill(Oe,0,ye),he}function p(he){return he==null||typeof he=="number"&&Number.isNaN(he)}function r(he,ye){if(he==null)return he;if(ye==="number")return typeof he=="number"?he:Number(he);if(ye==="date"||ye==="dateString"){const Oe=Y(he);return Oe===null?i(he):Oe}return ye==="boolean"?typeof he=="boolean"?he:he==="true"||he===1?!0:he==="false"||he===0?!1:!!he:he}function i(he){return he instanceof Date?he.getTime():typeof he=="number"?he:Date.parse(String(he))}function d(he){return typeof he=="number"?he:he instanceof Date?he.getTime():he==null||he===""?NaN:Number(he)}function h(he,ye){const Oe=typeof he=="string"?he:String(he);return ye?Oe:Oe.toLowerCase()}function a(he,ye){return he==null?s:typeof he=="string"?ye?he:he.toLowerCase():he instanceof Date?he.getTime():he}function y(he,ye,Oe){const Le=new Set;for(const fe of U(he)){const ae=r(fe,Oe);Le.add(a(ae,ye)),typeof ae=="string"&&ae!==""&&Number.isFinite(Number(ae))?Le.add(Number(ae)):typeof ae=="number"&&Number.isFinite(ae)&&Le.add(a(String(ae),ye))}return Le}function f(he,ye,Oe){if(he==null||ye===null||ye===void 0)return he==null&&ye==null;const Le=typeof he,fe=typeof ye;return Le==="string"&&fe==="string"?Oe?he===ye:he.toLowerCase()===ye.toLowerCase():he instanceof Date||ye instanceof Date?i(he)===i(ye):Le==="number"&&fe==="number"?he===ye||Number.isNaN(he)&&Number.isNaN(ye):Le==="number"&&fe==="string"?he===Number(ye):Le==="string"&&fe==="number"?Number(he)===ye:Le==="boolean"||fe==="boolean"?he===ye:Array.isArray(he)&&Array.isArray(ye)?he.length===ye.length&&he.every((ae,ke)=>f(ae,ye[ke],Oe)):he===ye}function m(he,ye){try{if(he instanceof RegExp){const Oe=he.flags.replace(/[gy]/g,"");return new RegExp(he.source,ye||Oe.includes("i")?Oe:`${Oe}i`)}return new RegExp(String(he),ye?"":"i")}catch(Oe){return J(`regex:${String(he)}`,`filter operator "matches" received an invalid pattern: ${String(he)}`,Oe),null}}function w(he,ye){if(he&&he.type==="datetime"&&S.has(he.op))return P(he,ye);const Oe=k(he,ye),Le=he&&he.type;return Le!=="date"&&Le!=="dateString"?Oe:fe=>Oe(typeof fe=="string"&&t.test(fe)?fe:Y(fe)??fe)}const S=new Set(["eq","ne","lt","lte","gt","gte","between","notBetween","in","notIn"]),M=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3})\d*)?)?)?$/,X=new Map;function q(he,ye){let Oe=X.get(ye);if(Oe===void 0){try{Oe=new Intl.DateTimeFormat("en-CA",{timeZone:ye,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})}catch{Oe=null}X.set(ye,Oe)}if(!Oe)return null;const Le={};for(const fe of Oe.formatToParts(he))fe.type!=="literal"&&(Le[fe.type]=fe.value);return Le}function K(he,ye){if(he==null||he==="")return null;if(typeof he=="string"){const ae=M.exec(he.trim());if(ae)return Date.UTC(+ae[1],+ae[2]-1,+ae[3],+(ae[4]||0),+(ae[5]||0),+(ae[6]||0),+(ae[7]||"0").padEnd(3,"0"))}const Oe=L(he);if(!Oe)return null;const Le=Oe.getUTCMilliseconds(),fe=ye?q(Oe,ye):null;return fe?Date.UTC(+fe.year,+fe.month-1,+fe.day,fe.hour==="24"?0:+fe.hour,+fe.minute,+fe.second,Le):Date.UTC(Oe.getFullYear(),Oe.getMonth(),Oe.getDate(),Oe.getHours(),Oe.getMinutes(),Oe.getSeconds(),Le)}function P(he,ye){const Oe=typeof he.timeZone=="string"&&he.timeZone?he.timeZone:void 0,Le=ke=>K(ke,Oe),fe=Array.isArray(he.value)?he.value.map(Le):Le(he.value),ae=k({...he,type:"number",value:fe},ye);return ke=>ae(K(ke))}function k(he,ye){const Oe=he&&he.op,Le=!!(he&&he.caseSensitive),fe=he&&he.type,ae=g(ye),ke=pe=>ue=>!pe(ue);switch(Oe){case"eq":{const pe=r(he.value,fe);return ue=>f(ue,pe,Le)}case"ne":{const pe=r(he.value,fe);return ue=>!f(ue,pe,Le)}case"lt":case"lte":case"gt":case"gte":{const pe=r(he.value,fe);if(p(pe))return()=>!1;const ue=Oe==="lt"?-1:Oe==="lte"?0:Oe==="gt"?1:2;return we=>{if(p(we))return!1;const Te=ae(we,pe);return ue===-1?Te<0:ue===0?Te<=0:ue===1?Te>0:Te>=0}}case"between":case"notBetween":{const pe=U(he.value),ue=r(pe[0],fe),we=r(pe[1],fe),Te=he.bounds||"[]",Ne=Te.charAt(0)!=="(",_e=Te.charAt(1)!==")";if(p(ue)||p(we))return Oe==="between"?()=>!1:()=>!0;const $e=je=>{if(p(je))return!1;const Ge=ae(je,ue),Fe=ae(je,we);return(Ne?Ge>=0:Ge>0)&&(_e?Fe<=0:Fe<0)};return Oe==="between"?$e:ke($e)}case"in":case"notIn":{const pe=y(he.value,Le,fe),ue=we=>pe.has(a(we,Le));return Oe==="in"?ue:ke(ue)}case"contains":case"notContains":{const pe=h(r(he.value,fe),Le),ue=we=>we==null?!1:h(we,Le).includes(pe);return Oe==="contains"?ue:ke(ue)}case"startsWith":{const pe=h(r(he.value,fe),Le);return ue=>ue==null?!1:h(ue,Le).startsWith(pe)}case"endsWith":{const pe=h(r(he.value,fe),Le);return ue=>ue==null?!1:h(ue,Le).endsWith(pe)}case"matches":{const pe=m(he.value,Le);return pe?ue=>ue==null?!1:pe.test(String(ue)):()=>!1}case"blank":case"notBlank":{const pe=he.trim===!0,ue=we=>A(we)||Array.isArray(we)&&we.length===0||pe&&typeof we=="string"&&we.trim()==="";return Oe==="blank"?ue:we=>!ue(we)}case"containsAny":case"containsNone":{const pe=y(he.value,Le,fe),ue=we=>{const Te=we==null?[]:U(we);for(let Ne=0;Ne<Te.length;Ne++)if(pe.has(a(Te[Ne],Le)))return!0;return!1};return Oe==="containsAny"?ue:ke(ue)}case"containsAll":{const pe=U(he.value).map(ue=>a(r(ue,fe),Le));return ue=>{const we=ue==null?[]:U(ue);if(pe.length===0)return!0;const Te=new Set(we.map(Ne=>a(Ne,Le)));for(let Ne=0;Ne<pe.length;Ne++)if(!Te.has(pe[Ne]))return!1;return!0}}default:{const pe=ve(Oe);return pe?pe.compile(he.value):(J(`op:${String(Oe)}`,`unknown filter operator "${String(Oe)}"; the condition is refused rather than matching every row`),()=>!1)}}}function E(he,ye,Oe){return w(ye,Oe)(he)}const C=Object.freeze({ne:"eq",notIn:"in",notBetween:"between",notContains:"contains"}),x=new Set(["containsAny","containsAll","containsNone"]);function j(he,ye,Oe){const Le=he&&he.op,fe=C[Le]||Le,ae=w({...he,op:fe,type:ye.type},Oe),ke=ye.items,pe=ue=>{const we=ke(ue);if(!we)return!1;for(let Te=0;Te<we.length;Te++)if(ae(we[Te]))return!0;return!1};return C[Le]?ue=>!pe(ue):pe}function T(he,ye,Oe,Le,fe){const ae=fe?null:c(he);if(ae){const ue=ye?1:0;for(let we=0;we<Le;we++)Oe[we]=ae(we)===ue?1:0;return Oe}const ke=he.kind;if(ke==="float64"||ke==="int32"||ke==="bitset")return n(Oe,Le,ye?1:0);const pe=o(he);for(let ue=0;ue<Le;ue++){const we=pe(ue),Te=A(we)||Array.isArray(we)&&we.length===0||fe&&typeof we=="string"&&we.trim()==="";Oe[ue]=Te===ye?0:1}return Oe}function F(he,ye,Oe,Le){const fe=he.dict,ae=v(fe),ke=new Uint8Array(ae);for(let Te=0;Te<ae;Te++)ke[Te]=ye(b(fe,Te))?1:0;const pe=he.values,ue=c(he);if(!ue){for(let Te=0;Te<Le;Te++)Oe[Te]=ke[pe[Te]];return Oe}const we=ye(null)?1:0;for(let Te=0;Te<Le;Te++)Oe[Te]=ue(Te)===1?ke[pe[Te]]:we;return Oe}function $(he,ye,Oe,Le){const fe=O(he.values),ae=ye(!0)?1:0,ke=ye(!1)?1:0,pe=c(he);if(!pe){for(let we=0;we<Le;we++)Oe[we]=fe(we)===1?ae:ke;return Oe}const ue=ye(null)?1:0;for(let we=0;we<Le;we++)Oe[we]=pe(we)===0?ue:fe(we)===1?ae:ke;return Oe}function D(he,ye,Oe,Le,fe){const ae=he.values,ke=ye.type,pe=ye.op;let ue=!0;switch(pe){case"eq":case"ne":{const Te=d(r(ye.value,ke)),Ne=typeof ye.value=="number"&&Number.isNaN(ye.value),_e=pe==="ne"?1:0;if(Ne)for(let $e=0;$e<fe;$e++)Le[$e]=(Number.isNaN(ae[$e])?1:0)^_e;else for(let $e=0;$e<fe;$e++)Le[$e]=(ae[$e]===Te?1:0)^_e;break}case"lt":{const Te=d(r(ye.value,ke));for(let Ne=0;Ne<fe;Ne++)Le[Ne]=ae[Ne]<Te?1:0;break}case"lte":{const Te=d(r(ye.value,ke));for(let Ne=0;Ne<fe;Ne++)Le[Ne]=ae[Ne]<=Te?1:0;break}case"gt":{const Te=d(r(ye.value,ke));for(let Ne=0;Ne<fe;Ne++)Le[Ne]=ae[Ne]>Te?1:0;break}case"gte":{const Te=d(r(ye.value,ke));for(let Ne=0;Ne<fe;Ne++)Le[Ne]=ae[Ne]>=Te?1:0;break}case"between":case"notBetween":{const Te=U(ye.value),Ne=d(r(Te[0],ke)),_e=d(r(Te[1],ke)),$e=ye.bounds||"[]",je=$e.charAt(0)!=="(",Ge=$e.charAt(1)!==")",Fe=pe==="notBetween"?1:0;if(je&&Ge)for(let Pe=0;Pe<fe;Pe++)Le[Pe]=(ae[Pe]>=Ne&ae[Pe]<=_e?1:0)^Fe;else if(je)for(let Pe=0;Pe<fe;Pe++)Le[Pe]=(ae[Pe]>=Ne&ae[Pe]<_e?1:0)^Fe;else if(Ge)for(let Pe=0;Pe<fe;Pe++)Le[Pe]=(ae[Pe]>Ne&ae[Pe]<=_e?1:0)^Fe;else for(let Pe=0;Pe<fe;Pe++)Le[Pe]=(ae[Pe]>Ne&ae[Pe]<_e?1:0)^Fe;break}case"in":case"notIn":{const Te=new Set;for(const _e of U(ye.value)){const $e=d(r(_e,ke));Number.isNaN($e)||Te.add($e)}const Ne=pe==="notIn"?1:0;for(let _e=0;_e<fe;_e++)Le[_e]=(Te.has(ae[_e])?1:0)^Ne;break}default:ue=!1;break}if(!ue)return!1;const we=c(he);if(we){const Te=Oe(null)?1:0;for(let Ne=0;Ne<fe;Ne++)we(Ne)===0&&(Le[Ne]=Te)}return!0}function z(he,ye,Oe,Le){const fe=o(he);for(let ae=0;ae<Le;ae++)Oe[ae]=ye(fe(ae))?1:0;return Oe}function G(he,ye,Oe){const Le=ye.count|0,fe=Oe||l(ye,Le);if(!he)return n(fe,Le,1);const ae=typeof ye.handle=="function"?ye.handle(he.col):void 0,ke=typeof ye.custom=="function"?ye.custom:null;if(!ae){if(ke){for(let Te=0;Te<Le;Te++)fe[Te]=ke(he,Te)?1:0;return fe}return J(`filter:col:${String(he.col)}`,`filter references unknown column "${String(he.col)}"; the condition is refused rather than matching every row`),n(fe,Le,0)}const pe=he.op;if(pe==="blank"||pe==="notBlank")return T(ae,pe==="notBlank",fe,Le,he.trim===!0);const ue=typeof ye.itemwise=="function"?ye.itemwise(he.col):null;if(ue&&!ve(pe)&&!x.has(pe))return z(ae,j(he,ue,ye.locale),fe,Le);const we=w(he,ye.locale);switch(ae.kind){case"dictionary":return F(ae,we,fe,Le);case"bitset":return $(ae,we,fe,Le);case"float64":case"int32":return D(ae,he,we,fe,Le)?fe:z(ae,we,fe,Le);default:return z(ae,we,fe,Le)}}function N(he,ye,Oe){if(!he)return n(l(ye,Oe),Oe,1);if(Array.isArray(he.conditions)){const Le=he.conditions.filter(ke=>ke!=null),fe=he.op==="or"?"or":he.op==="not"?"not":"and";if(Le.length===0)return n(l(ye,Oe),Oe,1);const ae=N(Le[0],ye,Oe);for(let ke=1;ke<Le.length;ke++){const pe=N(Le[ke],ye,Oe);if(fe==="or")for(let ue=0;ue<Oe;ue++)ae[ue]|=pe[ue];else for(let ue=0;ue<Oe;ue++)ae[ue]&=pe[ue];u(ye,pe)}if(fe==="not")for(let ke=0;ke<Oe;ke++)ae[ke]^=1;return ae}return G(he,ye,l(ye,Oe))}function Z(he,ye){return N(he,ye,ye.count|0)}function Q(he,ye){if(!he||!ye)return he||null;const Oe=he;if(Array.isArray(Oe.conditions)){if((Oe.op==="or"?"or":Oe.op==="not"?"not":"and")!=="and")return ee(Oe,ye)?null:he;const fe=[];for(const ae of Oe.conditions){const ke=Q(ae,ye);ke&&fe.push(ke)}return fe.length?{...Oe,op:"and",conditions:fe}:null}return Oe.col===ye?null:he}function ee(he,ye){if(!he||typeof he!="object")return!1;const Oe=he;if(Oe.col===ye)return!0;if(Array.isArray(Oe.conditions)){for(const Le of Oe.conditions)if(ee(Le,ye))return!0}return!1}function re(he,ye,Oe){if(Oe&&Oe.length>=ye){let ke=0;for(let pe=0;pe<ye;pe++)he[pe]&&(Oe[ke++]=pe);return Oe.subarray(0,ke)}let Le=0;for(let ke=0;ke<ye;ke++)Le+=he[ke]?1:0;const fe=new Uint32Array(Le);let ae=0;for(let ke=0;ke<ye;ke++)he[ke]&&(fe[ae++]=ke);return fe}const ie=new Map;function ce(he){if(!(!he||typeof he!="object"))for(const[ye,Oe]of Object.entries(he))Oe&&typeof Oe.compile=="function"&&ie.set(ye,Oe)}function ve(he){return typeof he=="string"?ie.get(he):void 0}}),ze("packages/core/src/columns/datatypes.js",function(e,B){"use strict";Object.defineProperty(e,"localeSeparators",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"parseNumberText",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"BUILTIN_TYPES",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"INFERENCE_ORDER",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"createTypeRegistry",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"comparatorFor",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"storageKind",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"typeLabel",{enumerable:!0,get:function(){return T}});const ne=B("packages/core/src/internal/compare.js"),A=ne.collator,V=ne.defaultCompare,U=B("packages/core/src/internal/predicates.js"),I=U.isNil,J=U.isObject,H=U.isFunction,L=B("packages/core/src/internal/warn.js"),Y=L.fail,_=L.infoOnce,v=B("packages/core/src/internal/text.js").titleCase,b=B("packages/core/src/format/date.js"),c=b.toDate,g=b.toIsoDate,o=b.compareIso,s=B("packages/core/src/format/boolean.js").toTriState,u=B("packages/core/src/columns/types/index.js").EXTENDED_TYPES,n=B("packages/core/src/formula/index.js"),p=n.evaluateFormula,r=n.looksLikeFormula,d=B("packages/core/src/compute/filter.js").declareOperators,h=/^\d{4}-\d{2}-\d{2}$/;function a(F){return F.getHours()===0&&F.getMinutes()===0&&F.getSeconds()===0&&F.getMilliseconds()===0}const y=new Map;function f(F){const $=F||"",D=y.get($);if(D)return D;const z={group:",",decimal:"."};try{for(const G of new Intl.NumberFormat(F||void 0).formatToParts(12345.6))G.type==="group"?z.group=G.value:G.type==="decimal"&&(z.decimal=G.value)}catch{}return y.set($,z),z}const m=/\d\s*[*/^]\s*[\d.(]/;function w(F,$){if(I(F))return null;let D=String(F).trim();if(D===""||D.startsWith("=")||m.test(D))return null;let z=1;D.startsWith("(")&&D.endsWith(")")&&(z=-1,D=D.slice(1,-1));const G=D.endsWith("%"),{group:N,decimal:Z}=f($);if(D=D.replace(/[\s\u00a0\u202f\u2009']/g,""),N&&N!=="."&&N!==","&&(D=D.split(N).join("")),D=D.replace(/[^0-9eE+\-.,]/g,""),Z===","?D=D.split(".").join("").replace(",","."):D=D.split(",").join(""),D===""||D==="-"||D==="+")return null;const Q=Number(D);return Number.isNaN(Q)?null:z*(G?Q/100:Q)}function S(F,$){const D=I(F)||Number.isNaN(F)?null:Number(F),z=I($)||Number.isNaN($)?null:Number($);return D===null?z===null?0:1:z===null||D<z?-1:D>z?1:0}function M(F,$){const D=s(F),z=s($);return D===null?z===null?0:1:z===null?-1:D===z?0:D?1:-1}function X(F,$){const D=c(F),z=c($);if(!D)return z?1:0;if(!z)return-1;const G=D.getTime(),N=z.getTime();return G<N?-1:G>N?1:0}const q=new Map;function K(F){const $=c(F.value);if(!$)return"";const D=F.locale||"";let z=q.get(D);return z||(z=new Intl.DateTimeFormat(F.locale||void 0,{dateStyle:"medium"}),q.set(D,z)),z.format($)}const P={boolean:{base:"boolean",storage:"bitset",matches:F=>typeof F=="boolean",parse:F=>s(F.text),compare:M,format:F=>s(F.value)===null?"":s(F.value)?"Yes":"No",defaults:{filter:"set",editor:"checkbox",align:"center"},excel:"General",toClipboard:F=>s(F)===null?"":String(s(F)),fromClipboard:F=>s(F)},number:{base:"number",storage:"float64",matches:F=>typeof F=="number"&&!Number.isNaN(F),parse:F=>{if(r(F.text)){const $=p(F.text,F);if(!$.ok)return null;const D=Number($.value);return Number.isFinite(D)?D:null}return w(F.text,F.locale)},compare:S,defaults:{filter:"number",editor:"number",align:"end"},excel:"General",toClipboard:F=>I(F)?"":String(F),fromClipboard:(F,$)=>w(F,$&&$.locale),toStorage:(F,$)=>{if(typeof F!="string")return F;const D=w(F,$&&$.locale);return D!==null?D:(_(`type.number.unparsed.${$&&$.colId||""}`,`column "${$&&$.colId||"?"}" is declared type "number" but holds a value that is not a number in its locale; storing it as NaN, excluded from sorts and totals.`),NaN)}},date:{base:"dateString",storage:"dictionary",matches:F=>typeof F=="string"&&h.test(F)&&!Number.isNaN(Date.parse(F))||F instanceof Date&&!Number.isNaN(F.getTime())&&a(F),parse:F=>g(F.text),compare:o,format:K,defaults:{filter:"date",editor:"date",align:"start"},excel:"yyyy-mm-dd",toStorage:F=>g(F),toClipboard:F=>I(F)?"":String(F),fromClipboard:F=>g(F)},dateString:{base:"dateString",storage:"dictionary",matches:F=>typeof F=="string"&&h.test(F)&&!Number.isNaN(Date.parse(F)),parse:F=>g(F.text),compare:o,format:K,defaults:{filter:"date",editor:"date",align:"start"},excel:"yyyy-mm-dd",toStorage:F=>g(F),toClipboard:F=>I(F)?"":String(F),fromClipboard:F=>g(F)},text:{base:"text",storage:"dictionary",matches:F=>typeof F=="string",parse:F=>F.text===""?null:String(F.text),compare:(F,$)=>I(F)?I($)?0:1:I($)?-1:A().compare(String(F),String($)),defaults:{filter:"text",editor:"text",align:"start"},excel:"@",toClipboard:F=>I(F)?"":String(F),fromClipboard:F=>F},image:{base:"text",storage:"dictionary",parse:F=>F.text===""||F.text==null?null:String(F.text).trim(),compare:(F,$)=>I(F)?I($)?0:1:I($)?-1:A().compare(String(F),String($)),defaults:{filter:"text",editor:"text",align:"center",render:"image"},excel:"@",toClipboard:F=>I(F)?"":String(F),fromClipboard:F=>F},lookup:{base:"text",storage:"dictionary",parse:F=>{if(F.text===""||F.text==null)return null;const $=F.column&&F.column.lookup,D=$&&H($.options)?$.options():null;if(!D)return F.text;const z=String(F.text),G=D.find(Q=>String(Q.id)===z);if(G)return G.id;const N=z.trim().toLowerCase(),Z=D.find(Q=>String(Q.label).toLowerCase()===N);return Z?Z.id:F.text},compare:V,defaults:{filter:"set",editor:"select",align:"start"},excel:"@",multiStorage:"multi",toClipboard:F=>I(F)?"":String(F),fromClipboard:F=>F},object:{base:"object",storage:"object",matches:F=>F!==null&&typeof F=="object"&&!(F instanceof Date),parse:F=>{try{return F.text===""?null:JSON.parse(F.text)}catch{return F.text}},compare:(F,$)=>V(F,$),format:F=>{const $=F.value;if(I($))return"";if(typeof $=="string")return $;try{return JSON.stringify($)}catch{return String($)}},defaults:{filter:"none",editor:"none",align:"start"},excel:"@",toClipboard:F=>I(F)?"":typeof F=="string"?F:JSON.stringify(F),fromClipboard:F=>F}},k=["boolean","number","date","dateString","datetime","text","object"];function E(F,$,D,z){const G=D.get(F);if(G)return G;z.includes(F)&&Y(`circular data type extends chain: ${[...z,F].join(" → ")}`);const N=$[F];N||Y(`unknown data type "${F}"`);let Z=null;N.extends&&(Z=E(N.extends,$,D,[...z,F]));const Q={...Z||{},...N,name:F,defaults:{...Z&&Z.defaults||{},...N.defaults||{}}};return Q.base||(Q.base=Z&&Z.base||"text"),Q.storage||(Q.storage=Z&&Z.storage||"object"),D.set(F,Q),Q}function C(F,$){const D={...P,...u};if($&&typeof $.dataType=="function"&&typeof $.names=="function")for(const G of $.names("dataType")){const N=$.dataType(G);N&&(D[G]=N)}if(J(F))for(const[G,N]of Object.entries(F))D[G]=N;const z=new Map;for(const G of k)E(G,D,z,[]);E("lookup",D,z,[]);for(const G of Object.keys(D))E(G,D,z,[]);for(const G of z.values())d(G.operators);return z}function x(F,$){if(F.base==="text"&&(!F.compare||F.compare===P.text.compare)){const D=A($);return(z,G)=>I(z)?I(G)?0:1:I(G)?-1:D.compare(String(z),String(G))}return F.compare||V}function j(F,$){return $?F.multiStorage||"multi":F.storage||"object"}function T(F){return v(String(F).replace(/([a-z])([A-Z])/g,"$1 $2"))}}),ze("packages/core/src/columns/infer.js",function(e,B){"use strict";Object.defineProperty(e,"DEFAULT_SAMPLE",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"inferFromValues",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"inferColumnType",{enumerable:!0,get:function(){return H}});const A=B("packages/core/src/internal/warn.js").infoOnce,U=B("packages/core/src/internal/predicates.js").isNil,I=100;function J(L,Y,_={}){const O=_.sampleSize??I,v=[];for(let b=0;b<L.length&&v.length<O;b++){const c=L[b];U(c)||typeof c=="number"&&Number.isNaN(c)||v.push(c)}if(v.length===0)return{type:"text",unanimous:!1,sampled:0};for(const[b,c]of Y){if(typeof c.matches!="function")continue;let g=!0;for(let o=0;o<v.length;o++)if(!c.matches(v[o])){g=!1;break}if(g)return{type:b,unanimous:!0,sampled:v.length}}return _.quiet||A(`infer:${_.colId||"?"}`,`column "${_.colId||"?"}" has mixed or ambiguous values and was inferred as "text". Declare \`type\` on the column to get correct sorting, filtering and export.`),{type:"text",unanimous:!1,sampled:v.length}}function H(L,Y,_,O,v={}){const b=v.sampleSize??I,c=[];for(let g=0;g<Y.length&&c.length<b;g++){const o=_(Y[g]);U(o)||typeof o=="number"&&Number.isNaN(o)||c.push(o)}return J(c,O,{...v,colId:L}).type}}),ze("packages/core/src/columns/graph.js",function(e,B){"use strict";Object.defineProperty(e,"WHOLE_ROW",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"declarationOf",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"buildGraph",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"affectedBy",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"depsProxy",{enumerable:!0,get:function(){return O}});const ne=B("packages/core/src/internal/warn.js"),A=ne.DEV,V=ne.fail,U=ne.warnOnce,J=B("packages/core/src/internal/predicates.js").isFunction,H="*";function L(v){const b=v.value||{};if(!J(b.compute))return{computed:!1,wholeRow:!1,deps:[],pure:!0};const g=b.pure!==!1;return b.deps===H?{computed:!0,wholeRow:!0,deps:[],pure:g}:Array.isArray(b.deps)?{computed:!0,wholeRow:!1,deps:b.deps.slice(),pure:g}:(U(`deps:missing:${v.id}`,`computed column "${v.id}" declares no \`value.deps\`; treating it as \`deps: '*'\` (a whole-row dependency). Declare the dependencies to get precise invalidation.`),{computed:!0,wholeRow:!0,deps:[],pure:g})}function Y(v){const b=new Map;for(const d of v)b.set(d.id,d);const c=new Map,g=new Map,o=new Set,t=new Set,s=new Set,l=new Set;for(const d of v){const h=L(d);if(!h.computed){c.set(d.id,[]);continue}t.add(d.id),(h.pure?s:l).add(d.id),h.wholeRow&&o.add(d.id);const a=[],y=[];for(const f of h.deps)(b.has(f)?a:y).push(f);c.set(d.id,a),y.length&&g.set(d.id,y)}for(const d of s)for(const h of c.get(d))l.has(h)&&V(`pure computed column "${d}" depends on impure column "${h}". Mark it \`value.pure: false\` or make the dependency pure.`);const u=[],n=new Map,p=[],r=d=>{const h=n.get(d);if(h!=="done"){if(h==="open"){const a=p.indexOf(d);V(`circular column dependency: ${[...p.slice(a),d].join(" → ")}`)}n.set(d,"open"),p.push(d);for(const a of c.get(d)||[])b.has(a)&&r(a);p.pop(),n.set(d,"done"),u.push(d)}};for(const d of v)r(d.id);const i=new Map;for(const d of v)i.set(d.id,[]);for(const d of v)for(const h of c.get(d.id)||[]){const a=i.get(h);a&&!a.includes(d.id)&&a.push(d.id)}if(o.size)for(const d of v){if(t.has(d.id))continue;const h=i.get(d.id);for(const a of o)h.includes(a)||h.push(a)}return{order:u,dependents:i,pure:s,impure:l,computed:t,deps:c,wholeRow:o,external:g,index:b}}function _(v,b){const c=Array.isArray(b)?b:[b],g=new Set,o=[...c];for(;o.length;){const t=o.shift();for(const s of v.dependents.get(t)||[])g.has(s)||(g.add(s),o.push(s))}for(const t of c)g.delete(t);return v.order.filter(t=>g.has(t))}function O(v,b,c){if(!A)return v;const g=b instanceof Set?b:new Set(b);return new Proxy(v,{get(o,t){return typeof t=="string"&&!g.has(t)&&!Object.hasOwn(o,t)&&U(`undeclared:${c}:${t}`,`computed column "${c}" read undeclared dependency "${t}". Add it to \`value.deps\` or the value will go stale.`),o[t]}})}}),ze("packages/core/src/model/rowkey.js",function(e,B){"use strict";Object.defineProperty(e,"KEY_DEPENDENT_FEATURES",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"compositeKey",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"createRowKey",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"warnMissingKeys",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"groupPathKey",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"splitPathKey",{enumerable:!0,get:function(){return t}});const A=B("packages/core/src/internal/warn.js").warnOnce,U=B("packages/core/src/internal/paths.js").pathGetter,I=B("packages/core/src/internal/predicates.js"),J=I.isFunction,H=I.isBlank,L=["changes (rows.apply / rows.queue)","streaming dedupe","selection persistence","remote reload","cell comments"],Y="";function _(s){if(s===null)return"\0n";if(s===void 0)return"\0u";const l=typeof s;if(l==="string")return s;if(l==="number"||l==="bigint"||l==="boolean")return String(s);if(s instanceof Date)return`\0d${s.getTime()}`;try{return`\0o${JSON.stringify(s)}`}catch{return"\0o?"}}function O(s){if(s.length===1)return _(s[0]);let l="";for(let u=0;u<s.length;u++)u&&(l+=Y),l+=_(s[u]);return l}function v(s,l={}){const u=l.warn!==!1;if(J(s)){const n=s;return{stable:!0,fields:[],disabled:[],key(p,r){try{const i=n(p);return Array.isArray(i)?O(i):_(i)}catch(i){return A("rowKey.throw","rowKey function threw; falling back to index identity for the affected rows.",i),`#${r??-1}`}},keyEmpty(p){try{const r=n(p);return Array.isArray(r)?r.length===0||r.some(H):H(r)}catch{return!1}},missingFields(){return[]}}}if(Array.isArray(s)&&s.length>0){const n=s.filter(i=>typeof i=="string"),p=n.map(i=>U(i)),r=p.length;return{stable:!0,fields:n,disabled:[],key(i){const d=new Array(r);for(let h=0;h<r;h++)d[h]=p[h](i);return O(d)},keyEmpty(i){for(let d=0;d<r;d++)if(H(p[d](i)))return!0;return!1},missingFields(i){const d=[];for(let h=0;h<r;h++)H(p[h](i))&&d.push(n[h]);return d}}}if(typeof s=="string"&&s.length>0){const n=U(s);return{stable:!0,fields:[s],disabled:[],key(p){return _(n(p))},keyEmpty(p){return H(n(p))},missingFields(p){return H(n(p))?[s]:[]}}}return u&&A("rowKey.missing",`no rowKey configured, so rows are identified by object identity. This disables: ${L.join(", ")}. Set rowKey to a field name, an array of field names, or a function.`),{stable:!1,fields:[],disabled:L.slice(),key(n,p){if(n===null||typeof n!="object")return`#${p??0}:${String(n)}`;let r=b.get(n);return r===void 0&&(r=`#${c++}`,b.set(n,r)),r}}}const b=new WeakMap;let c=0;function g(s,l){if(!s||s.stable===!1||!J(s.keyEmpty)||!Array.isArray(l)||l.length===0)return;let u=0,n=null,p;for(let h=0;h<l.length;h++){const a=l[h];s.keyEmpty(a)&&(u++,n===null&&(n=J(s.missingFields)?s.missingFields(a):[],p=a))}if(u===0)return;const r=s.fields.length?s.fields.join(","):"(function)",i=n&&n.length?n.join(", "):s.fields.length?s.fields.join(", "):"the rowKey function",d=p!==null&&typeof p=="object"?Object.keys(p).join(", ")||"(no fields)":String(p);A(`rowKey.emptyValue:${r}`,`rowKey ${i} is missing on ${u} of ${l.length} rows; the first such row has: ${d}. Rows without a key value collapse onto one key, so selection, edits and rows.apply updates land on whichever row now shares it. Set rowKey to a field present on every row, or fix the source data.`)}function o(s){return O(s)}function t(s){return s.split(Y)}}),ze("packages/core/src/columns/lookup.js",function(e,B){"use strict";Object.defineProperty(e,"DEFAULT_SEPARATOR",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"normaliseOption",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"flattenOptions",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"Lookup",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"toValueArray",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"createLookup",{enumerable:!0,get:function(){return s}});const ne=B("packages/core/src/internal/compare.js"),A=ne.collator,V=ne.defaultCompare,U=B("packages/core/src/internal/predicates.js"),I=U.isFunction,J=U.isNil,L=B("packages/core/src/internal/warn.js").warnOnce,_=B("packages/core/src/model/rowkey.js").compositeKey,O=", ",v="";function b(l,u,n,p){if(l===null||typeof l!="object")return{id:l,label:l==null?"":String(l)};const r=l[u],i=l[n],d={id:r,label:i==null?String(r??""):String(i)};l.disabled&&(d.disabled=!0),l.variant&&(d.variant=l.variant),l.icon&&(d.icon=l.icon);const h=p?l[p]:l.group;return h!==void 0&&(d.group=h),d}function c(l,u,n=0,p=[],r=[]){for(const i of l||[]){const d=i&&typeof i=="object"?i[u]:null;if(r.push({raw:i,depth:n,path:p}),Array.isArray(d)&&d.length){const h=String(i&&typeof i=="object"?i.label??i.name??i.id??"":i);c(d,u,n+1,[...p,h],r)}}return r}function g(l){return!!l&&typeof l=="object"&&!Array.isArray(l)&&I(l.router&&l.router.subscribe)}class o{#e;#t;#n;#r;#s=[];#i=new Map;#a=new Map;#l=0;#o="idle";#c=null;#u;#f=null;#d=new Map;constructor(u,n={}){this.#e=u||{},this.#t=n.colId||"?",this.#n=n.locale,this.#r=n.onChange||null,this.#u=A(this.#n),Array.isArray(this.#e.options)?this.#h(this.#e.options):this.#e.options===void 0&&(this.#o="ready")}get colId(){return this.#t}get version(){return this.#l}get state(){return this.#o}get ready(){return this.#o==="ready"}get multiple(){return this.#e.multiple===!0}get separator(){return this.#e.separator??O}get allowCustom(){return this.#e.allowCustom===!0}get sortBy(){return this.#e.sortBy||"label"}get spec(){return this.#e}options(){return this.#s}setLocale(u){this.#n=u,this.#u=A(u)}#h(u){const n=this.#e,p=n.valueKey||"id",r=n.labelKey||"label",i=n.childrenKey||"children";this.#s=c(u,i).map(d=>{const h=b(d.raw,p,r,n.groupKey);return d.depth&&(h.depth=d.depth,h.path=d.path),h}),this.#i=new Map,this.#a=new Map,this.#s.forEach((d,h)=>{this.#i.set(d.id,d),this.#a.set(d.id,h)}),this.#o="ready",this.#l+=1}load(){if(this.#c)return this.#c;const u=this.#e.options;if(Array.isArray(u)||u===void 0)return this.#c=Promise.resolve(this.#s),this.#c;if(g(u))return this.#c=this.#p(u),this.#c;if(!I(u))return L(`lookup:options:${this.#t}`,`column "${this.#t}" has an invalid \`lookup.options\`; expected an array, a function, or a router route`),this.#o="ready",this.#c=Promise.resolve([]),this.#c;this.#o="loading";let n;try{n=u()}catch(p){return this.#o="error",L(`lookup:load:${this.#t}`,`column "${this.#t}" failed to load lookup options`,p),this.#c=Promise.resolve([]),this.#c}return!n||!I(n.then)?(this.#h(n),this.#c=Promise.resolve(this.#s),this.#r&&this.#r(this),this.#c):(this.#c=n.then(p=>(this.#h(p),this.#r&&this.#r(this),this.#s),p=>(this.#o="error",L(`lookup:load:${this.#t}`,`column "${this.#t}" failed to load lookup options`,p),[])),this.#c)}refresh(){return this.#c=null,Array.isArray(this.#e.options)?(this.#h(this.#e.options),this.#r&&this.#r(this),Promise.resolve(this.#s)):this.load()}#p(u){if(this.#f)return Promise.resolve(this.#s);const n=this.#e,p=n.valueKey||"id",r=n.labelKey||"label",i=n.groupKey,d=I(u.map)?u.map:null,h=y=>b(d?d(y):y,p,r,i).id,a=y=>this.#m(y,d,p,r,i);return u.router.subscribe(u.predicate,a,{rowKey:h}),this.#f=()=>{I(u.router.detach)&&u.router.detach(a)},this.#o="ready",Promise.resolve(this.#s)}#m(u,n,p,r,i){const d=u&&u.add||[],h=u&&u.update||[],a=u&&u.remove||[];if(!(!d.length&&!h.length&&!a.length)){for(const y of d)this.#g(y,n,p,r,i);for(const y of h)this.#g(y,n,p,r,i);for(const y of a){if(!this.#d.has(y))continue;const f=this.#d.get(y);this.#d.delete(y),this.#i.delete(f);const m=this.#s.findIndex(w=>w.id===f);m>=0&&this.#s.splice(m,1)}this.#a=new Map(this.#s.map((y,f)=>[y.id,f])),this.#o="ready",this.#l+=1,this.#r&&this.#r(this)}}#g(u,n,p,r,i){const d=b(n?n(u):u,p,r,i);this.#d.set(_([d.id]),d.id);const h=this.#s.findIndex(a=>a.id===d.id);h>=0?this.#s[h]=d:this.#s.push(d),this.#i.set(d.id,d)}destroy(){this.#f&&(this.#f(),this.#f=null)}search(u,n){const p=this.#e;if(!I(p.search)){const d=String(u||"").toLowerCase();return Promise.resolve(d===""?this.#s:this.#s.filter(h=>h.label.toLowerCase().includes(d)))}const r=p.valueKey||"id",i=p.labelKey||"label";return Promise.resolve(p.search(u,n)).then(d=>(d||[]).map(h=>b(h,r,i,p.groupKey)))}option(u){return this.#i.get(u)}has(u){return this.#i.has(u)}label(u){if(J(u)||u==="")return"";const n=this.#i.get(u);if(n)return n.label;if(this.#o==="loading"||this.#o==="idle")return"";this.allowCustom||L(`lookup:unknown:${this.#t}`,`column "${this.#t}" holds value ${JSON.stringify(u)} which is not in its lookup options. Showing the raw value; set \`lookup.unknownLabel\` or \`lookup.allowCustom\` to change that.`);const p=this.#e.unknownLabel;return I(p)?String(p(u)??""):typeof p=="string"?p:String(u)}text(u){if(this.multiple){const n=t(u);return n.length===0?"":n.map(p=>this.label(p)).join(this.separator)}return this.label(u)}dictionary(){return this.#s.map(u=>u.id)}sorted(){const u=this.sortBy;if(u==="optionOrder"||u==="count")return this.#s.slice();if(u==="value")return this.#s.slice().sort((p,r)=>V(p.id,r.id));const n=this.#u;return this.#s.slice().sort((p,r)=>n.compare(p.label,r.label))}comparator(){const u=this.sortBy,n=this.multiple,p=this.#u,r=this.#a;if(n&&u==="count")return(d,h)=>t(d).length-t(h).length;const i=n?d=>t(d)[0]:d=>d;return u==="value"?(d,h)=>V(i(d),i(h)):u==="optionOrder"?(d,h)=>{const a=r.has(i(d))?r.get(i(d)):Number.MAX_SAFE_INTEGER,y=r.has(i(h))?r.get(i(h)):Number.MAX_SAFE_INTEGER;return a-y}:(d,h)=>{const a=i(d),y=i(h);return J(a)?J(y)?0:1:J(y)?-1:p.compare(this.label(a),this.label(y))}}groupKey(u){return this.multiple?t(u).map(p=>String(p)).sort().join(v):J(u)?"":String(u)}countValues(u){return this.multiple?t(u).length:J(u)?0:1}contains(u,n,p){const r=this.multiple?t(u):J(u)?[]:[u],i=Array.isArray(n)?n:[n];switch(p){case"containsAll":return i.every(d=>r.includes(d));case"containsNone":return!i.some(d=>r.includes(d));default:return i.some(d=>r.includes(d))}}exportText(u,n="label"){return n==="value"?this.multiple?t(u).join(this.separator):J(u)?"":String(u):this.text(u)}exportColumns(){const u=this.multiple;return this.#s.map(n=>({id:n.id,label:n.label,has:p=>u?t(p).includes(n.id):p===n.id}))}}function t(l){return Array.isArray(l)?l:J(l)||l===""?[]:[l]}function s(l,u={}){const n=l.lookup;if(!n)return null;const p=new o(n,{colId:l.id,locale:u.locale,onChange:u.onChange});return!Array.isArray(n.options)&&n.options!==void 0&&p.load(),p}}),ze("packages/core/src/columns/value.js",function(e,B){"use strict";Object.defineProperty(e,"compileDisplay",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"warnImpureUse",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"ValuePipeline",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"defaultRowKey",{enumerable:!0,get:function(){return l}});const A=B("packages/core/src/internal/paths.js").getPath,V=B("packages/core/src/internal/predicates.js"),U=V.isFunction,I=V.isNil,J=V.isObject,L=B("packages/core/src/internal/lru.js").Lru,_=B("packages/core/src/internal/warn.js").warnOnce,v=B("packages/core/src/format/number.js").compileNumber,c=B("packages/core/src/columns/graph.js").depsProxy,g="\0";function o(r,i={}){const d=i.locale,h=i.grid??null,a=i.context,y=r.value&&r.value.format,f=r.formatter||null,m=r.dataType&&r.dataType.format,w=r.lookup||null,S=(M,X,q)=>({value:M,data:q,row:X,column:r,colId:r.id,grid:h,context:a,locale:d});if(U(y))return(M,X,q)=>{const K=y(S(M,X,q));return K==null?"":String(K)};if(f){if(w){const M=f.kind==="text";return(X,q,K)=>f(M?w.text(X):X,S(X,q,K))}return(M,X,q)=>f(M,S(M,X,q))}if(U(m))return(M,X,q)=>{const K=m(S(M,X,q));return K==null?"":String(K)};if(r.dataType&&r.dataType.base==="number"&&J(r.typeOptions)&&typeof r.typeOptions.decimals=="number"){const M=v({decimals:r.typeOptions.decimals},d);return X=>M(X)}return w?M=>w.text(M):M=>I(M)?"":typeof M=="string"?M:String(M)}function t(r,i){!r||!r.value||r.value.pure!==!1||_(`impure:${i}:${r.id}`,`column "${r.id}" is an impure computed column (\`value.pure: false\`) and is being used to ${i}. The result is not stable across passes.`)}class s{#e;#t;#n;#r;#s;#i;#a=new L(4096);constructor(i){this.#e=i.columns instanceof Map?i.columns:new Map((i.columns||[]).map(d=>[d.id,d])),this.#t=i.graph,this.#n=i.grid??null,this.#r=i.context,this.#i=i.stored||null,this.#s=i.rowKey||l}get graph(){return this.#t}setGraph(i){this.#t=i,this.#a.clear()}beginPass(){this.#a.clear()}endPass(){this.#a.clear()}invalidate(i){if(this.#a.size===0)return;const d=i&&i.rows?new Set([...i.rows].map(String)):null,h=i&&i.columns?[...i.columns]:null;if(!d&&!h){this.#a.clear();return}const a=h?this.#l(h):null;for(const y of[...this.#a.keys()]){const f=String(y).split(g);f.length===3&&(d&&!d.has(f[0])||a&&!a.has(f[2])||this.#a.delete(y))}}#l(i){const d=new Set,h=this.#t,a=[...i];for(;a.length;){const y=a.pop();if(!d.has(y)){d.add(y);for(const f of h?h.dependents.get(y)||[]:[])a.push(f)}}return d}value(i,d,h){const a=typeof i=="string"?this.#e.get(i):i;if(!a)return;if(!a.computed)return this.#c(a,d,h);if(a.value.pure!==!1&&this.#i&&h&&h.physical!=null&&this.#i.has(a.id))return this.#i.get(a.id,h.physical);if(a.volatile)return this.compute(a,d,h);if(a.value.pure===!1)return this.compute(a,d,h);const y=`${this.#o(d,h)}${g}${a.id}`;if(this.#a.has(y))return this.#a.get(y);const f=this.compute(a,d,h);return this.#a.set(y,f),f}#o(i,d){return`${this.#s(i,d)}${g}${u(i)}`}#c(i,d,h){if(this.#i&&h&&h.physical!=null&&this.#i.has(i.id))return this.#i.get(i.id,h.physical);if(i.field)return i.read?i.read(d):A(d,i.field)}compute(i,d,h){const a=this.#t,y=a&&a.wholeRow.has(i.id);let f;if(y)f=d??{};else{f={};const w=a&&a.deps.get(i.id)||[];for(const M of w)f[M]=this.value(M,d,h);const S=a&&a.external.get(i.id)||[];for(const M of S)f[M]=A(d,M);f=c(f,[...w,...S],i.id)}const m={data:d,row:h,column:i,grid:this.#n,context:this.#r};return i.value.compute(f,m)}values(i,d){const h={},a=this.#t?this.#t.order:[...this.#e.keys()];for(const y of a)h[y]=this.value(y,i,d);return h}text(i,d,h){const a=typeof i=="string"?this.#e.get(i):i;return a?a.formatValue(this.value(a,d,h),h,d):""}key(i,d,h){const a=typeof i=="string"?this.#e.get(i):i;if(!a)return"";const y=this.value(a,d,h);return U(a.value.key)?String(a.value.key(this.#u(a,y,d,h))):a.lookup?a.lookup.groupKey(y):I(y)?"":String(y)}quickFilterText(i,d,h){const a=typeof i=="string"?this.#e.get(i):i;if(!a)return"";if(U(a.value.quickFilterText)){const y=this.value(a,d,h);return String(a.value.quickFilterText(this.#u(a,y,d,h))??"")}return this.text(a,d,h)}#u(i,d,h,a){return{value:d,data:h,row:a,column:i,colId:i.id,grid:this.#n,context:this.#r}}parse(i,d,h,a){const y=typeof i=="string"?this.#e.get(i):i;if(!y)return d;const f={text:d,value:this.value(y,h,a),data:h,row:a,column:y,grid:this.#n,context:this.#r,locale:this.#n&&U(this.#n.get)?this.#n.get("locale"):void 0,formulaFunctions:this.#n&&U(this.#n.get)?this.#n.get("formulaFunctions"):void 0};return U(y.value.parse)?y.value.parse(f):y.dataType&&U(y.dataType.parse)?y.dataType.parse(f):d}validate(i,d,h,a,y){const f=typeof i=="string"?this.#e.get(i):i;if(!f||!U(f.edit.validate))return!0;const m=f.edit.validate({value:d,oldValue:h,data:a,row:y,column:f,grid:this.#n,context:this.#r});return m===!0||m===void 0?!0:String(m)}apply(i,d,h,a){const y=typeof i=="string"?this.#e.get(i):i;if(!y)return!1;const f=this.value(y,h,a);if(U(y.value.apply)){const m=y.value.apply({value:d,oldValue:f,data:h,row:a,column:y,grid:this.#n,context:this.#r});return this.#f(y,h,a),m!==!1}return y.field?f===d?!1:(y.write(h,d),this.#f(y,h,a),!0):(_(`apply:${y.id}`,`column "${y.id}" has no \`field\` and no \`value.apply\`, so an edit cannot be written back.`),!1)}commit(i,d,h,a){const y=typeof i=="string"?this.#e.get(i):i;if(!y)return{ok:!1,value:void 0,oldValue:void 0,changed:!1,error:"unknown column"};const f=this.value(y,h,a),m=this.parse(y,d,h,a),w=this.validate(y,m,f,h,a);if(w!==!0)return{ok:!1,value:m,oldValue:f,changed:!1,error:w};const S=this.apply(y,m,h,a);return{ok:!0,value:m,oldValue:f,changed:S}}#f(i,d,h){if(this.#a.size===0)return;const a=this.#o(d,h);this.#a.delete(`${a}${g}${i.id}`);for(const y of this.#t?this.#t.dependents.get(i.id)||[]:[])this.#a.delete(`${a}${g}${y}`)}}function l(r,i){return i&&i.key!=null?String(i.key):u(r)}function u(r){if(r&&typeof r=="object"){let i=n.get(r);return i===void 0&&(i=`#${p++}`,n.set(r,i)),i}return String(r)}const n=new WeakMap;let p=0}),ze("packages/core/src/model/shadow.js",function(e,B){"use strict";Object.defineProperty(e,"MAX_TRACKED",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"DEFAULT_DEPTH",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"HISTORY_TICK_MAX_MS",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"HISTORY_TICK_MIN_MS",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"historyTickFor",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"SHADOW_KINDS",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"ROLLING_KINDS",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"FIT_SHADOW_KINDS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"CLUSTER_SHADOW_KINDS",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"MAD_SCALE",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"DEFAULT_ANOMALY_THRESHOLD",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"SPEC_STATUS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"POSITIONAL_KINDS",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"SHADOW_LABELS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"specStatusOf",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"ShadowTracker",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"shadowsIn",{enumerable:!0,get:function(){return i}});const A=B("packages/core/src/internal/warn.js").warnOnce,V=2e5,U=20,I=1e3,J=50;function H(d){return Math.min(I,Math.max(J,Math.floor(d)))}const L=Object.freeze(["updates","updatedAt","sinceUpdate","delta","deltaPercent","rate","history","firstValue","streak","rank","rankAsc","rankChange","percentile","quartile","zScore","shareOfTotal","anomalyScore","anomalyFlag","specStatus","rollingSum","rollingAvg","rollingMin","rollingMax","windowCoverage","cumulativeToDate","periodOverPeriod","rollingQuantile","windowApproximate","tsTrend","tsSeasonal","tsResidual","tsCoverage","tsSmoothed","tsSmoothingAlpha","tsSmoothingBeta","fitPredicted","fitResidual","fitInfluence","fitStdResidual","fitLeverage","fitCooksD","cluster","clusterDistance"]),Y=Object.freeze(["rollingSum","rollingAvg","rollingMin","rollingMax","windowCoverage","cumulativeToDate","periodOverPeriod","rollingQuantile","windowApproximate","tsTrend","tsSeasonal","tsResidual","tsCoverage","tsSmoothed","tsSmoothingAlpha","tsSmoothingBeta"]),_=Object.freeze(["fitPredicted","fitResidual","fitInfluence","fitStdResidual","fitLeverage","fitCooksD"]),O=Object.freeze(["cluster","clusterDistance"]),v=.6745,b=3.5,c=Object.freeze({PASS:"PASS",WARN:"WARN",FAIL:"FAIL"}),g=Object.freeze(["rank","rankAsc","rankChange","percentile","quartile","zScore","shareOfTotal","anomalyScore","anomalyFlag"]),o=Object.freeze({updates:"Updates",updatedAt:"Updated at",sinceUpdate:"Since update",delta:"Change",deltaPercent:"Change %",rate:"Rate of change",history:"History",firstValue:"Baseline",streak:"Streak",rank:"Rank",rankAsc:"Rank, ascending",rankChange:"Rank change",percentile:"Percentile",quartile:"Quartile",zScore:"Z-score",shareOfTotal:"Share of total",anomalyScore:"Anomaly score",anomalyFlag:"Anomaly",specStatus:"Spec status",rollingSum:"Rolling sum",rollingAvg:"Rolling average",rollingMin:"Rolling minimum",rollingMax:"Rolling maximum",windowCoverage:"Window coverage",cumulativeToDate:"Cumulative to date",periodOverPeriod:"Period over period",rollingQuantile:"Rolling quantile",windowApproximate:"Window approximate",tsTrend:"Trend",tsSeasonal:"Seasonal",tsResidual:"Seasonal residual",tsCoverage:"Decomposition coverage",tsSmoothed:"Smoothed",tsSmoothingAlpha:"Smoothing α",tsSmoothingBeta:"Smoothing β",fitPredicted:"Predicted",fitResidual:"Residual",fitInfluence:"Influence",fitStdResidual:"Std. residual",fitLeverage:"Leverage",fitCooksD:"Cook's D",cluster:"Cluster",clusterDistance:"Cluster distance"});function t(d,h){if(!h)return null;const a=Number.isFinite(Number(h.lower))?Number(h.lower):null,y=Number.isFinite(Number(h.upper))?Number(h.upper):null;if(a===null&&y===null||!Number.isFinite(d))return null;if(a!==null&&d<a||y!==null&&d>y)return c.FAIL;const f=Number.isFinite(Number(h.warnLower))?Number(h.warnLower):null,m=Number.isFinite(Number(h.warnUpper))?Number(h.warnUpper):null;return f!==null&&d<f||m!==null&&d>m?c.WARN:c.PASS}function s(d,h,a){if(!h||typeof h!="object")return null;if(h.kind!=="time")return h.kind!==void 0&&A(`shadow.history.window.kind:${d}`,`a 'history' shadow's 'window' only accepts {kind: 'time', span}; '${h.kind}' is not honoured (a plain count is already what 'depth' means, and a session has no span to divide into buckets), so it reported the original, unwindowed history.`),null;const y=h.minutes!=null?Number(h.minutes)*6e4:Number(h.span);if(!(y>0))return A(`shadow.history.window.span:${d}`,"a 'history' shadow's time window needs a positive 'span' (ms) or 'minutes'; it had none, so it reported the original, unwindowed history."),null;const f=Math.max(2,Math.floor(a)||U);return{span:y,bucketMs:Math.max(1,Math.floor(y/f))}}class l{#e;#t=new Map;#n=new Map;#r=new Map;#s=new Map;#i=new Map;#a=new Map;#l=0;#o;#c;#u;#f;#d=new Map;#h=null;#p=null;#m=null;constructor(h){this.#e=h.colId,this.#o=Math.max(2,h.depth||U),this.#c=Math.max(1,h.max||V),this.#u=h.now||(()=>Date.now()),this.#f=s(this.#e,h.historyWindow,this.#o),this.#f&&(this.#h=Math.floor(this.#u()/this.#f.bucketMs))}get colId(){return this.#e}get forgotten(){return this.#l}get size(){return this.#n.size}get historyWindow(){return this.#f}observe(h,a){const y=r(a);if(y===null)return;if(!this.#n.has(h)){this.#p=null,this.#m=null,this.#g(),this.#t.set(h,y),this.#n.set(h,y),this.#r.set(h,0),this.#s.set(h,this.#u()),this.#i.set(h,[y]),this.#f&&this.#d.set(h,[y]),this.#a.set(h,0);return}const f=this.#n.get(h);if(f===y)return;this.#p=null,this.#m=null,this.#n.set(h,y),this.#r.set(h,(this.#r.get(h)||0)+1),this.#s.set(h,this.#u());const m=this.#i.get(h)||[];m.push(y),m.length>this.#o&&m.splice(0,m.length-this.#o),this.#i.set(h,m);const w=Math.sign(y-f),S=this.#a.get(h)||0;this.#a.set(h,Math.sign(S)===w?S+w:w)}#g(){if(this.#n.size<this.#c)return;const h=this.#n.keys().next().value;h!==void 0&&(this.#t.delete(h),this.#n.delete(h),this.#r.delete(h),this.#s.delete(h),this.#i.delete(h),this.#d.delete(h),this.#a.delete(h),this.#l++)}rebase(){for(const[h,a]of this.#n)this.#t.set(h,a);this.#p=null,this.#m=null}reset(){this.#t.clear(),this.#n.clear(),this.#r.clear(),this.#s.clear(),this.#i.clear(),this.#d.clear(),this.#a.clear(),this.#l=0,this.#p=null,this.#m=null,this.#f&&(this.#h=Math.floor(this.#u()/this.#f.bucketMs))}retain(h){const a=h instanceof Set?h:new Set(h);let y=0;for(const f of[...this.#n.keys()])a.has(f)||(this.#t.delete(f),this.#n.delete(f),this.#r.delete(f),this.#s.delete(f),this.#i.delete(f),this.#d.delete(f),this.#a.delete(f),y++);return y&&(this.#p=null,this.#m=null),y}advanceHistoryWindow(h=this.#u()){const a=this.#f;if(!a)return 0;const y=Math.floor(h/a.bucketMs),f=y-this.#h;if(!(f>0))return 0;const m=Math.min(f,this.#o);for(const[w,S]of this.#d){const M=this.#n.get(w);for(let X=0;X<m;X++)S.push(M);S.length>this.#o&&S.splice(0,S.length-this.#o)}return this.#h=y,f}read(h,a,y,f){switch(h){case"updates":return this.#r.has(a)?this.#r.get(a):0;case"updatedAt":{const m=this.#s.get(a);return m===void 0?null:new Date(m)}case"sinceUpdate":{const m=this.#s.get(a);return m===void 0?null:this.#u()-m}case"firstValue":return this.#t.has(a)?this.#t.get(a):null;case"delta":return this.#n.has(a)?this.#n.get(a)-this.#t.get(a):null;case"deltaPercent":{if(!this.#n.has(a))return null;const m=this.#t.get(a);return m?(this.#n.get(a)-m)/Math.abs(m)*100:null}case"rate":{const m=this.#i.get(a),w=this.#s.get(a);if(!m||m.length<2||w===void 0)return null;const S=this.#u()-w,M=m[m.length-1]-m[m.length-2];return S>0?M/S*1e3:M}case"history":return this.#f?this.#d.has(a)?[...this.#d.get(a)]:null:this.#i.has(a)?[...this.#i.get(a)]:null;case"streak":return this.#a.has(a)?this.#a.get(a):0;case"specStatus":return this.#n.has(a)?t(this.#n.get(a),f):null;default:return g.includes(h)?this.#S(h,a,y,f):null}}#b(h){if(h){if(this.#m&&this.#m.only===h)return this.#m.view;const a=this.#y(h);return this.#m={only:h,view:a},a}return this.#p?this.#p:(this.#p=this.#y(null),this.#p)}#y(h){const a=[];for(const[P,k]of this.#n)h&&!h.has(P)||a.push(k);const y=a.sort((P,k)=>P-k);let f=0,m=0,w=0,S=0;for(const P of y){S+=P,f++;const k=P-m;m+=k/f,w+=k*(P-m)}const M=[];for(const[P,k]of this.#t)h&&!h.has(P)||M.push(k);const X=f?u(y):0,q=y.map(P=>Math.abs(P-X)).sort((P,k)=>P-k),K=f?u(q):0;return{sorted:y,baseline:M.sort((P,k)=>P-k),sum:S,mean:f?m:0,sd:f>1?Math.sqrt(w/(f-1)):0,median:X,mad:K}}#S(h,a,y,f){if(!this.#n.has(a)||y&&!y.has(a))return null;const m=this.#n.get(a),w=this.#b(y),S=w.sorted.length;if(!S)return null;switch(h){case"rank":return S-p(w.sorted,m)+1;case"rankAsc":return n(w.sorted,m)+1;case"rankChange":{if(!this.#t.has(a)||!w.baseline.length)return null;const M=w.baseline.length-p(w.baseline,this.#t.get(a))+1,X=S-p(w.sorted,m)+1;return M-X}case"percentile":return p(w.sorted,m)/S*100;case"quartile":{const M=p(w.sorted,m)/S;return Math.min(4,Math.max(1,Math.ceil(M*4)))}case"zScore":return w.sd?(m-w.mean)/w.sd:null;case"anomalyScore":return w.mad?v*(m-w.median)/w.mad:null;case"anomalyFlag":{if(!w.mad)return null;const M=f&&Number.isFinite(Number(f.threshold))?Number(f.threshold):b;return Math.abs(v*(m-w.median)/w.mad)>M}case"shareOfTotal":return w.sum?m/w.sum*100:null;default:return null}}}function u(d){const h=d.length;if(!h)return 0;const a=(h-1)*.5,y=Math.floor(a),f=Math.ceil(a);return y===f?d[y]:d[y]+(a-y)*(d[f]-d[y])}function n(d,h){let a=0,y=d.length;for(;a<y;){const f=a+y>>1;d[f]<h?a=f+1:y=f}return a}function p(d,h){let a=0,y=d.length;for(;a<y;){const f=a+y>>1;d[f]<=h?a=f+1:y=f}return a}function r(d){if(d==null||d==="")return null;if(d instanceof Date){const a=d.getTime();return Number.isFinite(a)?a:null}const h=typeof d=="number"?d:Number(d);return Number.isFinite(h)?h:null}function i(d){const h=[];for(const a of d||[]){const y=a.shadow;if(!y)continue;const f=typeof y=="string"?{kind:y}:y,m=f.kind;L.includes(m)&&(Y.includes(m)||_.includes(m)||O.includes(m)||h.push({colId:a.id||a.field,of:f.of||a.field||a.id,kind:m,depth:f.depth,historyWindow:m==="history"?f.window:void 0}))}return h}}),ze("packages/core/src/columns/model.js",function(e,B){"use strict";Object.defineProperty(e,"BUILTIN_DEFAULTS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"normaliseAlign",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"normaliseVAlign",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"expandColumn",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"ColumnModel",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(e,"flattenTree",{enumerable:!0,get:function(){return Oe}});const ne=B("packages/core/src/internal/merge.js"),A=ne.expand,V=ne.merge,U=ne.toArray,I=B("packages/core/src/internal/warn.js"),J=I.fail,H=I.warnOnce,L=B("packages/core/src/internal/paths.js"),Y=L.getPath,_=L.pathGetter,O=L.pathSetter,b=B("packages/core/src/internal/text.js").humanise,c=B("packages/core/src/internal/predicates.js"),g=c.isFunction,o=c.isObject,s=B("packages/core/src/internal/uid.js").uid,u=B("packages/core/src/format/index.js").compileFormat,n=B("packages/core/src/columns/datatypes.js"),p=n.comparatorFor,r=n.createTypeRegistry,i=n.storageKind,d=B("packages/core/src/columns/infer.js"),h=d.inferColumnType,a=d.DEFAULT_SAMPLE,y=B("packages/core/src/columns/graph.js"),f=y.buildGraph,m=y.affectedBy,S=B("packages/core/src/columns/lookup.js").createLookup,M=B("packages/core/src/columns/value.js"),X=M.compileDisplay,q=M.ValuePipeline,K=M.warnImpureUse,P=B("packages/core/src/model/shadow.js"),k=P.FIT_SHADOW_KINDS,E=P.CLUSTER_SHADOW_KINDS,C=Object.freeze({geometry:"geometry",list:"list"}),x={value:{pure:!0},cell:{},edit:{enabled:!1},sort:{enabled:!0,direction:null,order:0,nullsFirst:!1},filter:{enabled:!0,type:"text"},group:{enabled:!1,index:-1,explode:!1},pivot:{enabled:!1,index:-1},total:null,layout:{width:150,min:40,max:null,flex:0,pin:null,hidden:!1,resizable:!0,movable:!0,lockVisible:!1,lockPosition:!1},header:{},facet:{},export:{lookup:"label",csv:!0,excel:!0},allowGroup:!0,allowPivot:!0,allowTotal:!0,nullable:!0,quickFilter:!0},j={centre:"center"},T=new Set(["start","center","end","left","right"]);function F(fe){if(typeof fe!="string")return;const ae=fe.toLowerCase();return j[ae]?j[ae]:T.has(ae)?ae:void 0}function $(fe){if(typeof fe!="string")return;const ae=fe.toLowerCase();return ae==="center"||ae==="centre"?"middle":ae==="top"||ae==="middle"||ae==="bottom"?ae:void 0}const D=["cell","layout","header"];function z(fe){if(!o(fe))return{};const ae={...fe},ke=(pe,ue)=>{if(fe[pe]===void 0)return;const we=A(fe[pe],ue);we&&D.includes(pe)&&!o(fe[pe])&&delete we.enabled,ae[pe]=we};return ke("sort","direction"),ke("filter","type"),ke("cell","render"),ke("edit","editor"),ke("layout","width"),ke("group","index"),ke("pivot","index"),ke("header","render"),ke("facet","strategy"),ae}function G(fe,ae){const ke={...fe||{}},pe=o(ae)&&o(ae.layout)&&ae.layout.width!==void 0;return ke.fit==="content"&&!pe&&delete ke.width,ke}const N=new Set(["allowGroup","allowPivot","allowTotal","cell","colSpan","contextMenu","diff","edit","export","facet","field","filter","filterRow","format","grandTotal","group","groupTotal","header","headerControls","id","layout","lookup","nullable","pivot","preset","quickFilter","rowSpan","running","shadow","showWhen","sort","spec","tags","title","total","type","typeOptions","validation","value","verticalAlign"]),Z=new Set(["collapsible","columns","facet","header","id","marryChildren","openByDefault","showWhen","title"]);function Q(fe,ae,ke,pe){const ue=ke==="columnGroup"?"column group":"column";for(const we of Object.keys(fe))if(!ae.has(we)){if(we==="timeZone"&&ke==="column"){H("column.timeZone",`\`timeZone\` is not a column option, so it had no effect on column "${pe}". A date column stores, displays, sorts and filters in the grid-level \`timeZone\` (else the viewer's); set \`timeZone\` on the grid, not the column.`);continue}H(`${ke}.unknown:${we}`,`'${we}' is not a configuration key this grid recognises, so it had no effect on ${ue} "${pe}". Check the spelling against the reference.`)}}function ee(fe){o(fe.cell)&&fe.cell.autoHeight!==void 0&&H("column.cell.autoHeight",`\`cell.autoHeight\` is not a column option, so it had no effect on column "${fe.id||fe.field||"(unnamed)"}". Rows grow to fit with the grid-level \`autoHeight\`; \`cell.wrap\` lets this column's text wrap.`)}function re(fe,ae){const ke=ae&&g(fe.defaultsFor)?fe.defaultsFor(ae):null,pe={...fe.defaults||{},...o(ke)?ke:{}},ue={};return pe.align&&(ue.align=pe.align,ue.cell={align:pe.align},ue.header={align:pe.align}),pe.filter&&(ue.filter=pe.filter==="none"?{enabled:!1,type:"none"}:{enabled:!0,type:pe.filter}),pe.editor&&(ue.edit=pe.editor==="none"?{editor:null}:{editor:pe.editor}),pe.total&&(ue.total=pe.total),pe.render&&(ue.cell={...ue.cell||{},render:pe.render}),fe.export&&(ue.export={...fe.export}),ue}function ie(fe){if(typeof fe=="string")return fe.trim()?[fe.trim()]:[];if(!Array.isArray(fe))return[];const ae=[];for(const ke of fe){if(typeof ke!="string")continue;const pe=ke.trim();pe&&!ae.includes(pe)&&ae.push(pe)}return ae}class ce{#e=new Map;#t=[];#n=[];#r=new WeakMap;#s;#i;#a;#l;#o;#c;#u(ae,ke,pe){if(ae&&typeof ae=="object"&&!g(ae)){const Ne=ae;return(typeof Ne.fn!="string"||!Ne.fn)&&J(`column "${pe}": a total given as an object needs a \`fn\` name, such as { fn: 'percentile', p: 0.9 }.`),Ne.fn==="percentile"&&!(typeof Ne.p=="number"&&Ne.p>=0&&Ne.p<=1)&&J(`column "${pe}": { fn: 'percentile' } needs \`p\`, a number from 0 to 1 (0.9 for the 90th percentile).`),this.#f(Ne.fn,ke,pe),Object.freeze({...Ne})}const ue=this.#f(ae,ke,pe);if(typeof ue!="string"||!this.#d)return ue??null;const we=ke&&ke.totals&&ke.totals.implement;if(we&&g(we[ue])){const Ne=we[ue];return Ne.totalName=ue,Ne}const Te=this.#d.totalFn?.(ue);return g(Te)?Te:ue}#f(ae,ke,pe){if(typeof ae!="string")return ae;const ue=ke&&ke.totals&&ke.totals.supported;if(!Array.isArray(ue)||ue.includes(ae))return ae;const we=ue.length?ue.join(", "):"none";return J(`column "${pe}" is typed ${ke.name||"a type"}, for which the total "${ae}" is not meaningful. Supported: ${we}. Aggregating it anyway would produce a confident wrong number.`),ae}#d;#h;#p;#m;#g;#b;#y=!1;#S;#w;constructor(ae={}){this.#i=z(ae.columnDefaults||{}),this.#a=ae.columnPresets||{},this.#o=ae.locale,this.#l=ae.timeZone,this.#c=$(ae.verticalAlign),this.#d=ae.registry||null,this.#h=ae.grid||null,this.#p=ae.context,this.#S=ae.sampleSize??a,this.#w=ae.onChange||null,this.#b=g(ae.rowKey)?ae.rowKey:void 0,this.#s=r(ae.dataTypes,this.#d);const{leaves:ke,groups:pe}=Oe(ae.columns||[]);this.#n=pe;for(const ue of ke){ue.facet!==void 0&&this.#r.set(ue.def,ue.facet);const we=this.#A(ue.def,null);if(we.groupPath=ue.path,this.#e.has(we.id)){H(`columns.duplicate:${we.id}`,`two columns resolve to the id '${we.id}', so the second is ignored. An id defaults to the column's field, so declare an explicit \`id\` when two columns read the same field.`);continue}ue.column=we,this.#e.set(we.id,we),this.#t.push(we.id)}this.#P(ae.stored||null)}#A(ae,ke){Q(ae,N,"column",ae.id||ae.field||"(unnamed)"),ee(ae);const pe=z(ae),ue=U(ae.preset),we=ue.map(Ie=>{const We=this.#a[Ie];return We?z(We):(H(`preset:${Ie}`,`unknown column preset "${Ie}"; ignoring`),{})}),Te=this.#O(pe,we,ke),Ne=this.#s.get(Te)||this.#s.get("text");if(!this.#s.has(Te)&&ae.type){const Ie=C[Te];H(`type:${Te}`,`unknown data type "${Te}"; falling back to "text"`+(Ie?`. It is registered by importing '@toclocoinc/lattice-grid/modules/${Ie}'.`:""))}const _e=g(Ne.items)?this.#C(pe,we,ae.id||ae.field||"(unnamed)"):null;let $e=x;$e=V($e,this.#i),ae.type!==!1&&($e=V($e,re(Ne,_e)));for(const Ie of we)$e=V($e,Ie);this.#r.has(ae)&&($e=V($e,z({facet:this.#r.get(ae)}))),$e=V($e,pe);const je=$e.edit;je&&je.editor&&je.enabled!==!0&&!g(je.enabled)&&(ae.edit||{}).editor&&H(`column.editor-not-enabled:${ae.id||ae.field}`,`column '${ae.id||ae.field}' names the editor '${je.editor}' but does not enable editing, so it stays read-only. Add \`enabled: true\`, or use \`edit: true\` and set \`editor\` alongside it.`);const Ge=ae.id||ae.field||s("col");if(ae.shadow&&!g($e.value&&$e.value.compute)){const Ie=typeof ae.shadow=="string"?{kind:ae.shadow}:ae.shadow,We=Ie.of||ae.field||Ge,Ye=k.includes(Ie.kind),nt=E.includes(Ie.kind),Qe=Ye?Ie.model||Ie:null,dt=Ye&&Qe?[...Array.isArray(Qe.predictors)?Qe.predictors:[],Qe.response].filter(Boolean):null,jt=nt?(Array.isArray(Ie.columns)?Ie.columns:[]).filter(Boolean):null;$e.value={...$e.value||{},deps:jt&&jt.length?jt:dt&&dt.length?dt:Ie.orderBy&&Ie.orderBy!==We?[We,Ie.orderBy]:[We],pure:!1,compute:(Et,it)=>{const ft=it.grid&&it.grid.statistics;if(!ft)return null;const pt=it.row&&it.row.key||ft.keyOf(it.data);if(!pt)return null;if(Ye){if(!g(ft.fitShadow))return null;const Tt=Ie.model?{...Ie.model,threshold:Ie.threshold}:Ie;return ft.fitShadow(Ie.kind,pt,Tt)}return nt?g(ft.clusterShadow)?ft.clusterShadow(Ie.kind,pt,Ie):null:ft.shadow(We,Ie.kind,pt,Ie.scope,Ie)}}}if(ae.running&&!g($e.value&&$e.value.compute)){const Ie=typeof ae.running=="string"?{kind:ae.running}:ae.running,We=Ie.of||ae.field||Ge;$e.value={...$e.value||{},deps:[We],pure:!1,compute:(Ye,nt)=>{const Qe=nt.grid&&nt.grid.statistics;if(!Qe||!g(Qe.running))return null;const dt=nt.row&&nt.row.key||Qe.keyOf(nt.data);return dt?Qe.running(We,Ie.kind||"total",dt):null}},ae.sort===void 0&&($e.sort={...$e.sort||{},enabled:!1})}const Fe=ae.field??(g($e.value&&$e.value.compute)?null:ae.id??null),Pe=g($e.value&&$e.value.compute),Ee={id:Ge,field:Fe,shadow:ae.shadow||null,running:ae.running||null,spec:ae.spec||null,validation:ae.validation||null,volatile:!!(ae.shadow||ae.running),title:$e.title??b(Fe||Ge),type:Ne.name,dataType:Ne,itemType:_e,nullable:$e.nullable!==!1,align:F(pe.cell&&pe.cell.align||pe.align||$e.cell&&$e.cell.align||$e.align||Ne.defaults&&Ne.defaults.align)||"start",verticalAlign:$(pe.cell&&pe.cell.verticalAlign||pe.verticalAlign||$e.cell&&$e.cell.verticalAlign||$e.verticalAlign)||this.#c,rowSpan:g($e.rowSpan)?$e.rowSpan:null,colSpan:g($e.colSpan)?$e.colSpan:null,value:{pure:!0,...$e.value||{}},cell:{...$e.cell||{}},edit:{...$e.edit||{}},sort:{...$e.sort||{}},filter:{...$e.filter||{}},group:{enabled:!1,index:-1,explode:!1,...$e.group||{}},pivot:{enabled:!1,index:-1,...$e.pivot||{}},total:this.#u($e.total,Ne,ae.id||ae.field||"(unnamed)"),groupTotal:$e.groupTotal===void 0?null:this.#u($e.groupTotal,Ne,ae.id||ae.field||"(unnamed)"),grandTotal:$e.grandTotal===void 0?null:this.#u($e.grandTotal,Ne,ae.id||ae.field||"(unnamed)"),tags:ie($e.tags),typeOptions:$e.typeOptions??null,...o($e[Te])?{[Te]:$e[Te]}:{},layout:G($e.layout,pe),header:{...$e.header||{}},contextMenu:$e.contextMenu===void 0?null:$e.contextMenu,facet:{...$e.facet||{}},export:{...$e.export||{}},allowGroup:$e.allowGroup!==!1,allowPivot:$e.allowPivot!==!1,allowTotal:$e.allowTotal!==!1,quickFilter:$e.quickFilter!==!1,def:ae,format:$e.format,presets:ue,inferred:ke!=null&&!ae.type,computed:Pe,diff:ae.diff===void 0?void 0:!!ae.diff,read:Fe?_(Fe):null,write:Fe?O(Fe):null};Ee.cell.align=F(pe.cell&&pe.cell.align)||Ee.align,Ee.header.align=F(pe.header&&pe.header.align)||Ee.align;const Me=$e.lookup||null;return Ee.lookup=Me?S({id:Ge,lookup:Me},{locale:this.#o,onChange:()=>{this.#w&&this.#w("lookup",{colId:Ge})}}):null,Ee.group.explode&&Ee.lookup&&Ee.lookup.multiple&&H(`explode:${Ge}`,`column "${Ge}" has \`group.explode\`, so rows appear under each of their values and totals double-count. Group footers should be annotated accordingly.`),this.#v(Ee),Ee}#v(ae){ae.formatter=u(ae.format,ae.dataType,this.#o,this.#l,ae.id),ae.formatValue=X(ae,{locale:this.#o,grid:this.#h,context:this.#p}),ae.itemCompare=ae.itemType?p(ae.itemType,this.#o):null,ae.compare=g(ae.value.compare)?ae.value.compare:ae.lookup?ae.lookup.comparator():g(ae.dataType.compareFor)?ae.dataType.compareFor(ae):p(ae.dataType,this.#o),ae.excel=ae.formatter&&ae.formatter.ooxml||ae.dataType&&ae.dataType.excel||"General",ae.storeKind=i(ae.dataType,!!(ae.lookup&&ae.lookup.multiple))}#C(ae,ke,pe){let ue=o(ae.typeOptions)?ae.typeOptions:null;for(let _e=ke.length-1;!ue&&_e>=0;_e--)o(ke[_e].typeOptions)&&(ue=ke[_e].typeOptions);!ue&&o(this.#i.typeOptions)&&(ue=this.#i.typeOptions);const we=ue&&ue.of!==void 0?ue.of:"text",Te=typeof we=="string"?this.#s.get(we):void 0;return Te&&!g(Te.items)&&Te.storage!=="object"?Te:(H(`type:of:${String(we)}`,`column "${pe}" names "${String(we)}" as its item type (typeOptions.of), which is not ${Te?"a scalar data type":"a known data type"}; its items are read as text.`),this.#s.get("text"))}#O(ae,ke,pe){if(ae.type===!1)return"text";if(ae.type)return ae.type;for(let ue=ke.length-1;ue>=0;ue--)if(ke[ue].type)return ke[ue].type;if(this.#i.type)return this.#i.type;if(ae.shadow){const ue=typeof ae.shadow=="string"?ae.shadow:ae.shadow.kind;if(ue==="fitInfluence")return"boolean";if(ue==="fitPredicted"||ue==="fitResidual"||ue==="fitStdResidual"||ue==="fitLeverage"||ue==="fitCooksD"||ue==="tsTrend"||ue==="tsSeasonal"||ue==="tsResidual"||ue==="tsCoverage"||ue==="tsSmoothed"||ue==="tsSmoothingAlpha"||ue==="tsSmoothingBeta"||ue==="cluster"||ue==="clusterDistance")return"number"}return pe||(ae.lookup?"lookup":"text")}#P(ae){const ke=this.all();this.#m=f(ke),this.#g?this.#g.setGraph(this.#m):this.#g=new q({columns:this.#e,graph:this.#m,grid:this.#h,context:this.#p,stored:ae||null,rowKey:this.#b});const pe=this.#g;for(const ue of ke)ue.getValue=(we,Te)=>pe.value(ue,we,Te)}all(){return this.#t.map(ae=>this.#e.get(ae))}visible(){return this.all().filter(ae=>!ae.layout.hidden)}get(ae){return this.#e.get(ae)}groups(){const ae=ke=>{const pe=[];for(const ue of ke)Array.isArray(ue.columns)?pe.push({...ue,columns:ae(ue.columns)}):ue.column&&pe.push(ue.column);return pe};return ae(this.#n)}graph(){return this.#m}pipeline(){return this.#g}types(){return this.#s}affectedBy(ae){return m(this.#m,ae)}value(ae,ke,pe){return this.#g.value(ae,ke,pe)}text(ae,ke,pe){return this.#g.text(ae,ke,pe)}checkImpure(ae,ke){K(this.#e.get(ae),ke)}setLocale(ae){this.#o=ae;for(const ke of this.all())ke.lookup&&ke.lookup.setLocale(ae),this.#v(ke);this.#w&&this.#w("locale",{locale:ae})}infer(ae){const ke={};if(this.#y||!Array.isArray(ae)||ae.length===0)return ke;this.#y=!0;let pe=!1;for(const ue of this.all()){const we=ue.def;if(we.type!==void 0||!ue.field||ue.computed||ue.lookup||this.#E(ue))continue;const Te=ue.read||($e=>Y($e,ue.field)),Ne=h(ue.id,ae,Te,this.#s,{sampleSize:this.#S});if(Ne===ue.type)continue;ke[ue.id]=Ne;const _e=this.#A(we,Ne);_e.groupPath=ue.groupPath,_e.layout={..._e.layout,...ve(ue.layout)},this.#e.set(ue.id,_e),Le(this.#n,ue.id,_e),pe=!0}return pe&&this.#P(null),ke}redecorate(ae,ke,pe={}){const ue=this.#e.get(ae);if(!ue){H(`redecorate:${ae}`,`columns.decorate('${ae}', …): no column with id '${ae}'.`);return}const we=ue.def||{},Te={...o(we.cell)?we.cell:{}};Te.decoration=ke??void 0,pe&&"variant"in pe&&(Te.variant=pe.variant);const Ne={...we,cell:Te};this.#r.has(we)&&this.#r.set(Ne,this.#r.get(we));const _e=this.#A(Ne,ue.type);return _e.groupPath=ue.groupPath,_e.layout={..._e.layout,...ve(ue.layout)},ue.lookup&&ue.lookup!==_e.lookup&&g(ue.lookup.destroy)&&ue.lookup.destroy(),this.#e.set(ae,_e),Le(this.#n,ae,_e),this.#P(null),this.#w&&this.#w("decorate",{colId:ae}),_e}destroy(){for(const ae of this.#e.values())ae.lookup&&g(ae.lookup.destroy)&&ae.lookup.destroy()}#E(ae){for(const ke of ae.presets){const pe=this.#a[ke];if(pe&&pe.type)return!0}return!!this.#i.type}#T(ae){return!ae.computed&&g(ae.dataType&&ae.dataType.toStorage)}storeReader(ae){if(ae.computed)return ke=>this.#g.value(ae,ke,null);if(this.#T(ae)){const ke=ae.dataType.toStorage,pe=ae.format&&typeof ae.format=="object"&&!Array.isArray(ae.format)?ae.format.locale:void 0,ue={timeZone:this.#l,colId:ae.id,itemType:ae.itemType||null,locale:pe||this.#o};return we=>ke(ae.read(we),ue)}return ae.read}storeValue(ae,ke){if(!(!ae||ae.computed)&&g(ae.read))return this.storeReader(ae)(ke)}storeSchema(){const ae=[];for(const ke of this.all()){if(ke.computed&&ke.value.pure===!1||!ke.computed&&!ke.field)continue;const pe=this.storeReader(ke);let ue=null;!ke.computed&&!this.#T(ke)&&typeof ke.field=="string"&&!ke.lookup&&(ue=ke.field);const we={id:ke.id,kind:ke.storeKind,nullable:ke.nullable,read:pe};ue!==null&&(we.field=ue),ke.lookup&&(we.dictionary=ke.lookup.dictionary()),ae.push(we)}return ae}state(){return this.all().map(ae=>({id:ae.id,width:ae.layout.width,flex:ae.layout.flex||void 0,hidden:!!ae.layout.hidden,headerWrap:ae.header?.wrap===!0?!0:void 0,headerOrientation:ae.header?.orientation==="vertical"?"vertical":void 0,pin:ae.layout.pin??null,sort:ae.sort.direction??null,sortIndex:ae.sort.direction?ae.sort.order??0:null,groupIndex:ae.group.enabled?ae.group.index??0:null,pivotIndex:ae.pivot.enabled?ae.pivot.index??0:null,total:typeof ae.total=="string"?ae.total:null,groupTotal:typeof ae.groupTotal=="string"?ae.groupTotal:void 0,grandTotal:typeof ae.grandTotal=="string"?ae.grandTotal:void 0,decoration:ae.cell&&ae.cell.decoration!=null?he(ae.cell.decoration):void 0,variant:ae.cell&&ae.cell.variant!=null?he(ae.cell.variant):void 0}))}applyState(ae,ke={}){const pe={applied:[],skipped:[]},ue=Array.isArray(ae)?ae:ae&&ae.columns||[],we=!Array.isArray(ae)&&ae&&ae.columnOrder||null;for(const Ne of ue){if(!Ne||!Ne.id){pe.skipped.push({key:"?",reason:"no id"});continue}let _e=this.#e.get(Ne.id);if(!_e){pe.skipped.push({key:Ne.id,reason:"unknown column"});continue}if(Object.hasOwn(Ne,"decoration")||Object.hasOwn(Ne,"variant")){const $e=_e.cell?_e.cell.decoration:void 0,je=Ne.decoration??null,Ge=Object.hasOwn(Ne,"variant"),Fe=Ge&&!ye(_e.cell?_e.cell.variant:void 0,Ne.variant);(!ye($e,je)||Fe)&&(this.redecorate(Ne.id,je,Ge?{variant:Ne.variant??void 0}:{}),_e=this.#e.get(Ne.id)||_e)}Ne.width!=null&&(_e.layout.width=Ne.width),Ne.flex!=null&&(_e.layout.flex=Ne.flex),Ne.hidden!=null&&(_e.layout.hidden=!!Ne.hidden),Ne.headerWrap!==void 0&&(_e.header.wrap=!!Ne.headerWrap),Ne.headerOrientation!==void 0&&(_e.header.orientation=Ne.headerOrientation==="vertical"?"vertical":"horizontal"),Ne.pin!==void 0&&(_e.layout.pin=Ne.pin),Ne.sort!==void 0&&(_e.sort.direction=Ne.sort),Ne.sortIndex!=null&&(_e.sort.order=Ne.sortIndex),Ne.groupIndex!=null&&(_e.group.enabled=!0,_e.group.index=Ne.groupIndex),Ne.pivotIndex!=null&&(_e.pivot.enabled=!0,_e.pivot.index=Ne.pivotIndex),Ne.total!==void 0&&(_e.total=Ne.total),Ne.groupTotal!==void 0&&(_e.groupTotal=Ne.groupTotal),Ne.grandTotal!==void 0&&(_e.grandTotal=Ne.grandTotal),pe.applied.push(Ne.id)}const Te=we||(ke&&ke.keepOrder?[]:ue.map(Ne=>Ne&&Ne.id).filter(Boolean));if(Te.length){const Ne=Te.filter($e=>this.#e.has($e)),_e=this.#t.filter($e=>!Ne.includes($e));this.#t=[...Ne,..._e]}return this.#w&&this.#w("state",pe),pe}move(ae,ke){this.#M(ae,ke)&&(this.#R(),this.#w&&this.#w("move",{id:ae,to:ke}))}reorder(ae){const ke={applied:[],skipped:[]},pe=[];let ue=0;for(const we of Array.isArray(ae)?ae:[]){const Te=ue++;this.#M(we,Te)&&(ke.applied.push(we),pe.push({id:we,to:Te}))}if(!pe.length)return ke;if(this.#R(),this.#w)for(const we of pe)this.#w("move",we);return ke}#M(ae,ke){const pe=this.#t.indexOf(ae);if(pe===-1||Math.max(0,Math.min(Number(ke)||0,this.#t.length-1))===pe)return!1;const we=this.#e.get(ae);if(we.layout.movable===!1||we.layout.lockPosition)return H(`move:${ae}`,`column "${ae}" is not movable; the move was ignored`),!1;const Te=this.#N(ae,ke);return Te?(H(`move.married:${Te}`,`band "${Te}" declares marryChildren, so its columns stay together; the move was ignored`),!1):(this.#t.splice(pe,1),this.#t.splice(Math.max(0,Math.min(ke,this.#t.length)),0,ae),!0)}#N(ae,ke){if(!this.#n||!this.#n.length)return null;const pe=this.#t.filter(Ne=>Ne!==ae),ue=Math.max(0,Math.min(ke,pe.length)),we=(Ne,_e)=>{if(Array.isArray(Ne.columns)){for(const je of Ne.columns)we(je,_e);return _e}const $e=Ne.column?Ne.column.id:Ne.id;return $e&&_e.push($e),_e},Te=Ne=>{for(const _e of Ne){if(!Array.isArray(_e.columns))continue;if(_e.marryChildren===!0){const je=we(_e,[]),Ge=je.includes(ae),Fe=je.map(Pe=>pe.indexOf(Pe)).filter(Pe=>Pe>=0);if(Fe.length){const Pe=Math.min(...Fe),Ee=Math.max(...Fe);if(Ge?ue<Pe||ue>Ee+1:ue>Pe&&ue<=Ee)return _e.id}}const $e=Te(_e.columns);if($e)return $e}return null};return Te(this.#n)}#R(){const ae=new Map(this.#t.map((ue,we)=>[ue,we])),ke=ue=>{if(!Array.isArray(ue.columns)){const Te=ue.column?ue.column.id:ue.id;return ae.has(Te)?ae.get(Te):1/0}let we=1/0;for(const Te of ue.columns)we=Math.min(we,ke(Te));return we},pe=ue=>{ue.sort((we,Te)=>ke(we)-ke(Te));for(const we of ue)Array.isArray(we.columns)&&pe(we.columns)};pe(this.#n)}#D(ae){const ke=pe=>{for(let ue=0;ue<pe.length;ue++){const we=pe[ue];if(Array.isArray(we.columns)){const Te=ke(we.columns);if(Te)return Te}else if(we.column&&we.column.id===ae)return pe.splice(ue,1)[0]}return null};return ke(this.#n)}#G(ae){const ke=[];for(let pe=ae.length-1;pe>=0;pe--){const ue=ae[pe];Array.isArray(ue.columns)&&(ke.push(...this.#G(ue.columns)),ue.columns.length===0&&(ke.push(ue.id),ae.splice(pe,1)))}return ke}#K(){const ae=(ke,pe,ue)=>{for(const we of ke)Array.isArray(we.columns)?ae(we.columns,[...pe,we.id]):we.column&&(we.column.groupPath=pe)};ae(this.#n,[])}#L(ae){const ke=new Set(ae),pe=this.#t.filter(Ne=>ke.has(Ne));if(!pe.length)return;const ue=Math.min(...pe.map(Ne=>this.#t.indexOf(Ne))),we=this.#t.slice(0,ue).filter(Ne=>!ke.has(Ne)),Te=this.#t.slice(ue).filter(Ne=>!ke.has(Ne));this.#t=[...we,...pe,...Te]}#q(ae){const ke=[],pe=ue=>{if(Array.isArray(ue.columns))for(const we of ue.columns)pe(we);else ue.column&&ke.push(ue.column.id)};return pe(ae),ke}#B(ae){const ke=pe=>{for(const ue of pe){if(!Array.isArray(ue.columns))continue;if(ue.id===ae)return{node:ue,parent:pe};const we=ke(ue.columns);if(we)return we}return null};return ke(this.#n)}groupColumns(ae,ke={}){const pe=U(ae).filter(_e=>this.#e.has(_e));if(!pe.length)return H("columns.group.empty","groupColumns was given no known column ids; nothing was grouped."),null;for(const _e of pe)if(this.#e.get(_e).layout.lockPosition)return H(`columns.group.locked:${_e}`,`column "${_e}" is position-locked and cannot be grouped.`),null;const ue=ke.groupId?this.#B(ke.groupId):null;if(ke.groupId&&!ue)return H(`columns.group.unknown:${ke.groupId}`,`no band "${ke.groupId}" to add to; nothing was grouped.`),null;let we=null;if(!ue&&ke.id!=null&&(we=String(ke.id),this.#B(we)||this.#e.has(we)))return H(`columns.group.idtaken:${we}`,`band id "${we}" is already in use; nothing was grouped.`),null;const Te=pe.map(_e=>this.#D(_e)).filter(Boolean);if(!Te.length)return null;let Ne;if(ue)ue.node.columns.push(...Te),Ne=ue.node.id;else{const _e={id:we||s("grp"),title:ke.title||"",collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!1,header:{},def:{},columns:Te},$e=Number.isInteger(ke.at)?Math.max(0,Math.min(ke.at,this.#n.length)):this.#n.length;this.#n.splice($e,0,_e),Ne=_e.id}return this.#G(this.#n),this.#L(pe),this.#K(),this.#R(),this.#w&&this.#w("columngroup",{action:"formed",groupId:Ne,ids:pe}),Ne}ungroupColumn(ae){const ke=this.#e.get(ae);if(!ke){H(`columns.ungroup.unknown:${ae}`,`no column "${ae}" to ungroup.`);return}const pe=ke.groupPath||[];if(!pe.length)return;const ue=pe[pe.length-1],we=this.#B(ue);if(!we)return;const Te=this.#D(ae);if(!Te)return;const Ne=we.parent.indexOf(we.node);we.parent.splice(Ne+1,0,Te);const _e=this.#G(this.#n),$e=this.#q(we.node);if($e.length){this.#L($e);const je=Math.max(...$e.map(Fe=>this.#t.indexOf(Fe))),Ge=this.#t.filter(Fe=>Fe!==ae);Ge.splice(je+1,0,ae),this.#t=Ge}this.#K(),this.#R(),this.#w&&this.#w("columngroup",{action:"removed",id:ae,dissolved:_e})}renameGroup(ae,ke){const pe=this.#B(ae);if(!pe){H(`columns.group.rename:${ae}`,`no band "${ae}" to rename.`);return}pe.node.title=String(ke??""),this.#w&&this.#w("columngroup",{action:"renamed",groupId:ae,title:pe.node.title})}dissolveGroup(ae){const ke=this.#B(ae);if(!ke){H(`columns.group.dissolve:${ae}`,`no band "${ae}" to dissolve.`);return}const pe=ke.parent.indexOf(ke.node);ke.parent.splice(pe,1,...ke.node.columns),this.#K(),this.#R(),this.#w&&this.#w("columngroup",{action:"dissolved",groupId:ae})}moveGroup(ae,ke){const pe=this.#B(ae);if(!pe){H(`columns.group.move:${ae}`,`no band "${ae}" to move.`);return}const ue=pe.parent,we=ue.indexOf(pe.node);we!==-1&&(ue.splice(we,1),ue.splice(Math.max(0,Math.min(ke,ue.length)),0,pe.node),this.#Y(),this.#K(),this.#w&&this.#w("columngroup",{action:"moved",groupId:ae,to:ke}))}#Y(){const ae=[],ke=ue=>{for(const we of ue)Array.isArray(we.columns)?ke(we.columns):we.column&&ae.push(we.column.id)};ke(this.#n);const pe=new Set(ae);this.#t=[...ae,...this.#t.filter(ue=>!pe.has(ue))]}groupTree(){const ae=pe=>pe.map(ue=>Array.isArray(ue.columns)?{id:ue.id,title:ue.title||"",collapsible:!!ue.collapsible,openByDefault:ue.openByDefault!==!1,columns:ae(ue.columns)}:ue.column?ue.column.id:null).filter(ue=>ue!==null),ke=ae(this.#n);return ke.some(pe=>pe&&typeof pe=="object")?ke:[]}applyGroupTree(ae){if(!Array.isArray(ae))return;const ke=new Set,pe=we=>{const Te=[];for(const Ne of we)if(Ne&&typeof Ne=="object"&&Array.isArray(Ne.columns)){const _e=pe(Ne.columns);if(!_e.length)continue;Te.push({id:Ne.id||s("grp"),title:Ne.title||"",collapsible:Ne.collapsible===!0,openByDefault:Ne.openByDefault!==!1,showWhen:"always",marryChildren:!1,header:{},def:{},columns:_e})}else if(typeof Ne=="string"){const _e=this.#e.get(Ne);_e&&!ke.has(Ne)&&(ke.add(Ne),Te.push({column:_e,path:[]}))}return Te},ue=pe(ae);for(const we of this.#t){if(ke.has(we))continue;const Te=this.#e.get(we);Te&&ue.push({column:Te,path:[]})}this.#n=ue,this.#K(),this.#R(),this.#w&&this.#w("columngroup",{action:"applied"})}show(ae){this.#z(ae,!1)}hide(ae){this.#z(ae,!0)}#z(ae,ke){const pe=[];for(const ue of U(ae)){const we=this.#e.get(ue);if(we){if(ke&&we.layout.lockVisible){H(`lockVisible:${ue}`,`column "${ue}" is \`layout.lockVisible\` and cannot be hidden`);continue}we.layout.hidden!==ke&&(we.layout.hidden=ke,pe.push(ue))}}pe.length&&this.#w&&this.#w("visible",{ids:pe,hidden:ke})}pin(ae,ke){const pe=this.#e.get(ae);pe&&(pe.layout.pin=ke??null,this.#w&&this.#w("pin",{id:ae,side:pe.layout.pin}))}pinMany(ae){const ke={};for(const[ue,we]of ae){const Te=this.#e.get(ue);Te&&(Te.layout.pin=we??null,ke[ue]=Te.layout.pin)}const pe=Object.keys(ke);pe.length&&this.#w&&this.#w("pin",{ids:pe,pins:ke})}#I(ae,ke){const pe=ae.layout.min??0,ue=ae.layout.max;let we=Math.max(pe,ke);return ue!=null&&(we=Math.min(ue,we)),ae.layout.width=we,ae.layout.flex=0,we}resize(ae,ke){const pe=this.#e.get(ae);if(!pe)return;if(pe.layout.resizable===!1){H(`resize:${ae}`,`column "${ae}" is not resizable; the resize was ignored`);return}const ue=this.#I(pe,ke);this.#w&&this.#w("resize",{id:ae,width:ue})}resizeMany(ae){const ke={};for(const[ue,we]of ae){const Te=this.#e.get(ue);if(Te){if(Te.layout.resizable===!1){H(`resize:${ue}`,`column "${ue}" is not resizable; the resize was ignored`);continue}ke[ue]=this.#I(Te,we)}}const pe=Object.keys(ke);pe.length&&this.#w&&this.#w("resize",{ids:pe,widths:ke})}}function ve(fe){const ae={};return fe.width!=null&&(ae.width=fe.width),fe.hidden!=null&&(ae.hidden=fe.hidden),fe.pin!==void 0&&(ae.pin=fe.pin),ae}function he(fe){if(fe===null||typeof fe!="object")return fe;try{return structuredClone(fe)}catch{}try{return JSON.parse(JSON.stringify(fe))}catch{return fe}}function ye(fe,ae){const ke=fe??null,pe=ae??null;if(ke===pe)return!0;if(ke===null||pe===null)return!1;if(typeof ke!="object"||typeof pe!="object")return ke===pe;try{return JSON.stringify(ke)===JSON.stringify(pe)}catch{return!1}}function Oe(fe){const ae=[],ke=(ue,we,Te)=>{const Ne=[];for(const _e of ue){if(!o(_e)){J("a column definition must be an object");continue}if(Array.isArray(_e.columns)){Q(_e,Z,"columnGroup",_e.title||_e.id||"(unnamed)");const $e={id:_e.id||s("grp"),title:_e.title||"",collapsible:_e.collapsible===!0,openByDefault:_e.openByDefault!==!1,showWhen:_e.showWhen||"always",marryChildren:_e.marryChildren===!0,header:_e.header||{},def:_e,columns:[]};$e.columns=ke(_e.columns,[...we,$e.id],_e.facet!==void 0?_e.facet:Te),Ne.push($e)}else{const $e={def:_e,path:we,facet:Te};ae.push($e),Ne.push($e)}}return Ne},pe=ke(fe,[],void 0);return{leaves:ae,groups:pe}}function Le(fe,ae,ke){for(const pe of fe){if(pe.columns){if(Le(pe.columns,ae,ke))return!0;continue}if(pe.column&&pe.column.id===ae)return pe.column=ke,!0}return!1}}),ze("packages/core/src/columns/autogroup.js",function(e,B){"use strict";Object.defineProperty(e,"AUTO_GROUP_ID",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"createAutoGroupColumn",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"warnOnAbsurdGrouping",{enumerable:!0,get:function(){return Y}});const A=B("packages/core/src/internal/warn.js").warnOnce,V="__lattice_group",U=240,I=.5;function J(_){const O=_.def&&_.def.layout;return(typeof O=="number"||O&&O.width!=null||_.def&&_.def.width!=null)&&Number.isFinite(_.layout.width)?_.layout.width:null}function H(_){const O=_.def&&_.def.layout;return!!(O&&O.min!=null)||_.def&&_.def.minWidth!=null}function L(_){const{columns:O,groupBy:v}=_,b=v.map(l=>O.get(l)).filter(Boolean),c=b.length?b.map(l=>l.title||l.id).join(" > "):"Group",g=b.find(l=>J(l)!=null),o=_.config&&_.config.autoGroupColumnWidth||(g?J(g):U);let t=g&&H(g)?g.layout.min:120;g&&!H(g)&&(t=Math.min(t,o));const s=g&&g.layout.max!=null?g.layout.max:null;return{id:V,field:null,title:c,type:"text",dataType:{base:"text"},nullable:!0,align:"start",generated:!0,value:{pure:!0},cell:{render:"group"},edit:{enabled:!1},sort:{enabled:!0,direction:null},filter:{enabled:!0},groupedIds:v.slice(),group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:o,min:t,max:s,pin:_.config&&_.config.autoGroupColumnPin||null,hidden:!1,resizable:!0,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(l,u){return u&&u.group?u.groupValue:null},formatValue(l,u){if(!u||!u.group)return"";if(u.grandTotal)return _.config&&_.config.grandTotalLabel||"Total";const n=b[Math.min(u.level||0,b.length-1)];return n&&typeof n.formatValue=="function"?n.formatValue(l,u):l==null?"":String(l)}}}function Y(_,O,v){!_.length||v<100||O<v*I||A(`grouping.cardinality:${_.join(",")}`,`grouping by ${_.join(", ")} produced ${O} groups for ${v} rows: nearly one group per row. Grouping a continuous value such as a percentage or a timestamp rarely reads usefully; consider a computed banding column.`)}}),ze("packages/core/src/columns/selectcolumn.js",function(e,B){"use strict";Object.defineProperty(e,"SELECT_COLUMN_ID",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"createSelectionColumn",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return U}});const ne="__lattice_select",A=44;function V(I){const J=I.selection||{},H=I.config&&I.config.selectionColumnWidth||A;return{id:ne,field:null,title:"",type:"boolean",dataType:{base:"boolean"},nullable:!1,align:"center",generated:!0,control:!0,value:{pure:!0},cell:{render:"checkbox",props:{mode:"selection"},align:"center"},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:H,min:H,max:H,pin:I.config&&I.config.selectionColumnPin||"start",hidden:!1,resizable:!1,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,headerCheckbox:J.headerCheckbox===!0,def:{},getValue(L,Y){return Y?Y.selected:!1},formatValue(){return""}}}const U=V}),ze("packages/core/src/columns/rownumbercolumn.js",function(e,B){"use strict";Object.defineProperty(e,"ROW_NUMBER_COLUMN_ID",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"createRowNumberColumn",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Y}});const A=B("packages/core/src/internal/predicates.js").isFunction,V="__lattice_rownumber",U=40,I=9,J=22;function H(_){const O=String(Math.max(1,Math.trunc(Math.abs(_))||1)).length;return Math.max(U,O*I+J)}function L(_){const O=_.rowNumbers,v=O&&typeof O=="object"?O:{},b=Number.isFinite(v.start)?v.start:1,c=Number.isFinite(v.width)?v.width:H((_.maxNumber||0)+b),g=A(_.rank)?_.rank:()=>null;return{id:V,field:null,title:typeof v.title=="string"?v.title:"",type:"number",dataType:{base:"number"},nullable:!0,align:"end",generated:!0,control:!0,value:{pure:!0},cell:{align:"end"},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:c,min:c,max:c,pin:"start",hidden:!1,resizable:v.width==null,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(o,t){const s=g(t);return s==null?null:s-1+b},formatValue(o){return o==null?"":String(o)}}}const Y=L}),ze("packages/core/src/model/detail.js",function(e,B){"use strict";Object.defineProperty(e,"DEFAULT_DETAIL_HEIGHT",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"DEFAULT_CACHE_LIMIT",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"resolveDetail",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"DetailModel",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Y}});const A=B("packages/core/src/internal/predicates.js").isFunction,U=B("packages/core/src/internal/warn.js").warnOnce,I=240,J=10;function H(_){if(!_)return null;const O=_===!0?{}:_;return O.enabled===!1?null:!A(O.rows)&&!O.render?(U("detail.rows","detail is enabled but neither `rows` nor `render` was supplied; expanding a master would show an empty region, so it stays off."),null):{render:O.render||null,config:O.config||null,rows:A(O.rows)?O.rows:null,height:O.height??I,maxHeight:O.maxHeight??null,cacheLimit:Number.isFinite(O.cacheLimit)?Math.max(0,O.cacheLimit):J,isMaster:A(O.isMaster)?O.isMaster:null,target:O.target||null,onCreate:A(O.onCreate)?O.onCreate:null,path:typeof O.path=="string"?O.path:null}}class L{#e;#t=new Set;#n;#r=0;constructor(O){this.#e=O.config,this.#n=A(O.onChange)?O.onChange:()=>{}}get config(){return this.#e}get inline(){return!this.#e.target}isMaster(O){if(!O||O.group||O.detail)return!1;const v=this.#e.isMaster;return v?!!v(O.data,O):!0}isOpen(O){return this.#t.has(O)}keys(){return[...this.#t]}activeKey(){for(const O of this.#t)return O;return null}heightOf(O){const v=this.#e.height;return A(v)?Number(v(O))||I:v==="auto"?I:Number(v)||I}open(O){return this.#t.has(O)?!1:(this.inline||this.#t.clear(),this.#t.add(O),this.#s(),!0)}close(O){return this.#t.delete(O)?(this.#s(),!0):!1}toggle(O){return this.#t.has(O)?(this.close(O),!1):(this.open(O),!0)}closeAll(){this.#t.size&&(this.#t.clear(),this.#s())}prune(O){if(!this.#t.size||!A(O))return;let v=!1;for(const b of[...this.#t])O(b)||(this.#t.delete(b),v=!0);v&&this.#s()}signature(){return`${this.#r}`}set(O){this.#t.clear();const v=Array.isArray(O)?O:[];for(const b of this.inline?v:v.slice(0,1))this.#t.add(b);this.#s()}#s(){this.#r++,this.#n()}}const Y=L}),ze("packages/core/src/compute/special.js",function(e,B){"use strict";Object.defineProperty(e,"logGamma",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"incompleteBeta",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"normalQuantile",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"normalCdf",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"studentT",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"studentTQuantile",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"regularizedGammaP",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"chiSquareCdf",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"chiSquareUpperTail",{enumerable:!0,get:function(){return o}});const ne=Object.freeze([676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23]),A=3e-12,V=1e-300;function U(t){if(t<.5)return Math.log(Math.PI/Math.sin(Math.PI*t))-U(1-t);const s=t-1;let l=.9999999999998099;const u=s+7.5;for(let n=0;n<ne.length;n++)l+=ne[n]/(s+n+1);return .5*Math.log(2*Math.PI)+(s+.5)*Math.log(u)-u+Math.log(l)}function I(t,s,l){const u=t+s,n=t+1,p=t-1;let r=1,i=1-u*l/n;Math.abs(i)<V&&(i=V),i=1/i;let d=i;for(let h=1;h<=300;h++){const a=2*h;let y=h*(s-h)*l/((p+a)*(t+a));i=1+y*i,Math.abs(i)<V&&(i=V),r=1+y/r,Math.abs(r)<V&&(r=V),i=1/i,d*=i*r,y=-(t+h)*(u+h)*l/((t+a)*(n+a)),i=1+y*i,Math.abs(i)<V&&(i=V),r=1+y/r,Math.abs(r)<V&&(r=V),i=1/i;const f=i*r;if(d*=f,Math.abs(f-1)<A)break}return d}function J(t,s,l){if(!(t>0)||!(s>0)||!Number.isFinite(l))return Number.NaN;if(l<=0)return 0;if(l>=1)return 1;const u=Math.exp(U(t+s)-U(t)-U(s)+t*Math.log(l)+s*Math.log(1-l));return l<(t+1)/(t+s+2)?u*I(t,s,l)/t:1-u*I(s,t,1-l)/s}function H(t){if(!(t>0)||!(t<1))return t===0?-1/0:t===1?1/0:Number.NaN;const s=[-39.69683028665376,220.9460984245205,-275.9285104469687,138.357751867269,-30.66479806614716,2.506628277459239],l=[-54.47609879822406,161.5858368580409,-155.6989798598866,66.80131188771972,-13.28068155288572],u=[-.007784894002430293,-.3223964580411365,-2.400758277161838,-2.549732539343734,4.374664141464968,2.938163982698783],n=[.007784695709041462,.3224671290700398,2.445134137142996,3.754408661907416],p=.02425;let r,i,d;t<p?(r=Math.sqrt(-2*Math.log(t)),d=(((((u[0]*r+u[1])*r+u[2])*r+u[3])*r+u[4])*r+u[5])/((((n[0]*r+n[1])*r+n[2])*r+n[3])*r+1)):t<=1-p?(r=t-.5,i=r*r,d=(((((s[0]*i+s[1])*i+s[2])*i+s[3])*i+s[4])*i+s[5])*r/(((((l[0]*i+l[1])*i+l[2])*i+l[3])*i+l[4])*i+1)):(r=Math.sqrt(-2*Math.log(1-t)),d=-(((((u[0]*r+u[1])*r+u[2])*r+u[3])*r+u[4])*r+u[5])/((((n[0]*r+n[1])*r+n[2])*r+n[3])*r+1));const a=(.5*L(-d/Math.SQRT2)-t)*Math.sqrt(2*Math.PI)*Math.exp(d*d/2);return d-a/(1+d*a/2)}function L(t){const s=Math.abs(t),l=2/(2+s),u=4*l-2,n=[-1.3026537197817094,.6419697923564902,.019476473204185836,-.00956151478680863,-.000946595344482036,.000366839497852761,42523324806907e-18,-20278578112534e-18,-1624290004647e-18,130365583558e-17,15626441722e-18,-85238095915e-18,6529054439e-18,5059343495e-18,-991364156e-18,-227365122e-18,96467911e-18,2394038e-18,-6886027e-18,894487e-18,313092e-18,-112708e-18,381e-18,7106e-18];let p=0,r=0,i;for(let h=n.length-1;h>0;h--)i=r,r=u*r-p+n[h],p=i;const d=l*Math.exp(-s*s+.5*(n[0]+u*r)-p);return t>=0?d:2-d}function Y(t){return .5*L(-t/Math.SQRT2)}function _(t,s){if(!(s>0)||!Number.isFinite(t))return Number.NaN;const l=.5*J(s/2,.5,s/(s+t*t));return t>0?1-l:l}function O(t,s){if(!(t>0)||!(t<1)||!(s>0))return Number.NaN;if(s>1e7)return H(t);let l=-1e4,u=1e4,n=H(t);const p=U(s/2)+U(.5)-U((s+1)/2);for(let r=0;r<60;r++){const i=_(n,s);i<t?l=n:u=n;const d=Math.exp(-((s+1)/2)*Math.log(1+n*n/s)-p)/Math.sqrt(s),h=d>0?(i-t)/d:0;if(Math.abs(h)<1e-12)break;const a=n-h;if(n=a>l&&a<u&&Number.isFinite(a)?a:(l+u)/2,u-l<1e-12)break}return n}function v(t,s){let l=t,u=1/t,n=u;for(let p=0;p<300&&(l+=1,n*=s/l,u+=n,!(Math.abs(n)<Math.abs(u)*A));p++);return u*Math.exp(-s+t*Math.log(s)-U(t))}function b(t,s){let l=s+1-t,u=1/V,n=1/l,p=n;for(let r=1;r<=300;r++){const i=-r*(r-t);l+=2,n=i*n+l,Math.abs(n)<V&&(n=V),u=l+i/u,Math.abs(u)<V&&(u=V),n=1/n;const d=n*u;if(p*=d,Math.abs(d-1)<A)break}return Math.exp(-s+t*Math.log(s)-U(t))*p}function c(t,s){return!(t>0)||!(s>=0)||!Number.isFinite(s)?Number.NaN:s===0?0:s<t+1?v(t,s):1-b(t,s)}function g(t,s){return s>0?c(s/2,t/2):Number.NaN}function o(t,s){const l=g(t,s);return Number.isNaN(l)?Number.NaN:Math.min(1,Math.max(0,1-l))}}),ze("packages/core/src/compute/linalg.js",function(e,B){"use strict";Object.defineProperty(e,"cholesky",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"choleskySolve",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"choleskyInverse",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"normalEquations",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"matVec",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"quadForm",{enumerable:!0,get:function(){return J}});function ne(H){const L=H.length,Y=Array.from({length:L},()=>new Array(L).fill(0));for(let _=0;_<L;_++)for(let O=0;O<=_;O++){let v=H[_][O];for(let b=0;b<O;b++)v-=Y[_][b]*Y[O][b];if(_===O){if(!(v>0))return null;Y[_][O]=Math.sqrt(v)}else Y[_][O]=v/Y[O][O]}return Y}function A(H,L){const Y=H.length,_=new Array(Y).fill(0);for(let v=0;v<Y;v++){let b=L[v];for(let c=0;c<v;c++)b-=H[v][c]*_[c];_[v]=b/H[v][v]}const O=new Array(Y).fill(0);for(let v=Y-1;v>=0;v--){let b=_[v];for(let c=v+1;c<Y;c++)b-=H[c][v]*O[c];O[v]=b/H[v][v]}return O}function V(H){const L=H.length,Y=Array.from({length:L},()=>new Array(L).fill(0));for(let _=0;_<L;_++){const O=new Array(L).fill(0);O[_]=1;const v=A(H,O);for(let b=0;b<L;b++)Y[b][_]=v[b]}return Y}function U(H,L,Y){const _=H.length,O=_?H[0].length:0,v=Array.from({length:O},()=>new Array(O).fill(0)),b=new Array(O).fill(0);for(let c=0;c<_;c++){const g=Y?Y[c]:1,o=H[c];for(let t=0;t<O;t++){const s=g*o[t];b[t]+=s*L[c];for(let l=t;l<O;l++)v[t][l]+=s*o[l]}}for(let c=0;c<O;c++)for(let g=0;g<c;g++)v[c][g]=v[g][c];return{xtwx:v,xtwy:b}}function I(H,L){return H.map(Y=>Y.reduce((_,O,v)=>_+O*L[v],0))}function J(H,L){let Y=0;for(let _=0;_<H.length;_++){let O=0;for(let v=0;v<H.length;v++)O+=L[_][v]*H[v];Y+=H[_]*O}return Y}}),ze("packages/core/src/compute/sketch.js",function(e,B){"use strict";Object.defineProperty(e,"Welford",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"Reservoir",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"hash32",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"HyperLogLog",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"SpaceSaving",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"KLL",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return v}});class ne{#e=0;#t=0;#n=0;static get errorBound(){return Object.freeze({kind:"exact",metric:"none",value:0,statement:"mean and variance match a full recompute to float rounding"})}get count(){return this.#e}add(c){if(!Number.isFinite(c))return;this.#e++;const g=c-this.#t;this.#t+=g/this.#e,this.#n+=g*(c-this.#t)}merge(c){if(c.#e===0)return;if(this.#e===0){this.#e=c.#e,this.#t=c.#t,this.#n=c.#n;return}const g=this.#e+c.#e,o=c.#t-this.#t;this.#t+=o*(c.#e/g),this.#n+=c.#n+o*o*(this.#e*c.#e/g),this.#e=g}mean(){return this.#e?this.#t:null}variance(){return this.#e>1?this.#n/(this.#e-1):null}varianceP(){return this.#e?this.#n/this.#e:null}stddev(){const c=this.variance();return c===null?null:Math.sqrt(c)}stddevP(){const c=this.varianceP();return c===null?null:Math.sqrt(c)}}class A{#e=[];#t=0;#n;#r;constructor(c,g=Math.random){if(!(c>0))throw new RangeError("reservoir capacity must be positive");this.#n=Math.floor(c),this.#r=g}static get errorBound(){return Object.freeze({kind:"probabilistic",metric:"none",value:0,statement:"uniform sample: each element included with probability capacity/n; sample statistics are unbiased estimators"})}get seen(){return this.#t}get size(){return this.#e.length}add(c){if(!Number.isFinite(c))return;if(this.#t++,this.#e.length<this.#n){this.#e.push(c);return}const g=Math.floor(this.#r()*this.#t);g<this.#n&&(this.#e[g]=c)}sample(){return this.#e.slice()}mean(){if(!this.#e.length)return null;let c=0;for(const g of this.#e)c+=g;return c/this.#e.length}quantile(c){const g=this.#e.length;if(!g)return null;const o=this.#e.slice().sort((u,n)=>u-n);if(g===1)return o[0];const t=(g-1)*Math.min(1,Math.max(0,c)),s=Math.floor(t),l=Math.ceil(t);return s===l?o[s]:o[s]+(t-s)*(o[l]-o[s])}}function V(b){return b^=b>>>16,b=Math.imul(b,2246822507),b^=b>>>13,b=Math.imul(b,3266489909),b^=b>>>15,b>>>0}function U(b){if(typeof b=="number"){const o=new DataView(new ArrayBuffer(8));return o.setFloat64(0,b===0?0:b),V(o.getUint32(0)^o.getUint32(4))}const c=typeof b=="string"?b:String(b);let g=2166136261;for(let o=0;o<c.length;o++)g^=c.charCodeAt(o),g=Math.imul(g,16777619);return V(g)}class I{#e;#t;#n;constructor(c=14){const g=Math.floor(c);if(g<4||g>16)throw new RangeError("HLL precision must be 4..16");this.#e=g,this.#t=1<<g,this.#n=new Uint8Array(this.#t)}static errorBoundFor(c=14){const g=1<<Math.floor(c),o=1.04/Math.sqrt(g);return Object.freeze({kind:"probabilistic",metric:"relative",value:o,statement:`distinct count within ~${(o*100).toFixed(2)}% relative standard error (m=${g} buckets)`})}errorBound(){return I.errorBoundFor(this.#e)}add(c){const g=U(c),o=g&this.#t-1,t=g>>>this.#e|1<<32-this.#e;let s=1,l=t;for(;(l&1)===0;)s++,l>>>=1;s>this.#n[o]&&(this.#n[o]=s)}count(){const c=this.#t,g=32-this.#e,o=new Float64Array(g+2);for(let l=0;l<c;l++)o[this.#n[l]]++;let t=c*L(1-o[g+1]/c);for(let l=g;l>=1;l--)t=.5*(t+o[l]);t+=c*H(o[0]/c);const s=J*c*c/t;return Math.round(s)}}const J=.5/Math.log(2);function H(b){if(b===1)return 1/0;let c=1,g=b,o;do b*=b,o=g,g+=b*c,c+=c;while(g!==o);return g}function L(b){if(b===0||b===1)return 0;let c=1,g=1-b,o;do b=Math.sqrt(b),o=g,c*=.5,g-=(1-b)**2*c;while(g!==o);return g/3}class Y{#e=new Map;#t;#n=0;constructor(c){if(!(c>0))throw new RangeError("Space-Saving capacity must be positive");this.#t=Math.floor(c)}errorBoundFor(c){const g=c/this.#t;return Object.freeze({kind:"deterministic",metric:"absolute",value:g,statement:`each count overestimates the truth by at most N/m = ${g.toFixed(2)} (N=${c}, m=${this.#t})`})}get seen(){return this.#n}add(c){this.#n++;const g=this.#e.get(c);if(g){g.count++;return}if(this.#e.size<this.#t){this.#e.set(c,{count:1,error:0});return}let o,t=1/0;for(const[s,l]of this.#e)l.count<t&&(t=l.count,o=s);this.#e.delete(o),this.#e.set(c,{count:t+1,error:t})}top(c=this.#t){return[...this.#e.entries()].map(([o,t])=>({item:o,count:t.count,error:t.error})).sort((o,t)=>t.count-o.count).slice(0,Math.max(0,Math.floor(c)))}}class _{#e;#t=[[]];#n=0;#r;#s;constructor(c=200,g=Math.random){this.#e=Math.max(8,Math.floor(c)),this.#r=g,this.#s=2/3}static errorBoundFor(c=200){const g=1/Math.max(8,Math.floor(c));return Object.freeze({kind:"probabilistic",metric:"rank",value:g,statement:`queried quantile's true rank within ~${(g*100).toFixed(2)}% of N of the requested rank (k=${c})`})}errorBound(){return _.errorBoundFor(this.#e)}get count(){return this.#n}#i(c){const o=this.#t.length-1-c,t=Math.ceil(this.#e*this.#s**o);return Math.max(2,t)}add(c){Number.isFinite(c)&&(this.#n++,this.#t[0].push(c),this.#t[0].length>=this.#i(0)&&this.#a(0))}#a(c){const g=this.#t[c];g.sort((s,l)=>s-l),c+1>=this.#t.length&&this.#t.push([]);const o=this.#t[c+1],t=this.#r()<.5?0:1;for(let s=t;s<g.length;s+=2)o.push(g[s]);this.#t[c]=[];for(let s=0;s<this.#t.length;s++)if(this.#t[s].length>=this.#i(s)){this.#a(s);return}}#l(){const c=[];for(let g=0;g<this.#t.length;g++){const o=1<<g;for(const t of this.#t[g])c.push({v:t,w:o})}return c}quantile(c){const g=this.#l();if(!g.length)return null;g.sort((l,u)=>l.v-u.v);let o=0;for(const l of g)o+=l.w;const t=Math.min(1,Math.max(0,c))*o;let s=0;for(const l of g)if(s+=l.w,s>=t)return l.v;return g[g.length-1].v}rank(c){let g=0;for(let o=0;o<this.#t.length;o++){const t=1<<o;for(const s of this.#t[o])s<=c&&(g+=t)}return g}}const O=Object.freeze({distinct:I.errorBoundFor(14),median:_.errorBoundFor(200),p25:_.errorBoundFor(200),p75:_.errorBoundFor(200),p90:_.errorBoundFor(200),p95:_.errorBoundFor(200),p99:_.errorBoundFor(200),iqr:_.errorBoundFor(200),topK:Object.freeze({kind:"deterministic",metric:"absolute",value:0,statement:"each count overestimates the truth by at most N/m; top-K exact when the K-th item exceeds N/m"})}),v={Welford:ne,Reservoir:A,HyperLogLog:I,SpaceSaving:Y,KLL:_,hash32:U,SKETCH_BOUNDS:O}}),ze("packages/core/src/compute/statistics.js",function(e,B){"use strict";Object.defineProperty(e,"KENDALL_LIMIT",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"MAINTENANCE",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"APPROXIMATE",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"maintenanceOf",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"numbers",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"frequencies",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"herfindahl",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"entropy",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"evenness",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"topShare",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"gini",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"moments",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"quantileSorted",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"quantile",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"STAT_FNS",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"STAT_LABELS",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"weightedAverage",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"extremeRow",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"correlation",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"trimmedMean",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"winsorizedMean",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"modifiedZOutliers",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"jarqueBera",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"weightedQuantile",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"pairs",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"covariance",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"regression",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"fitLinearModel",{enumerable:!0,get:function(){return ve}}),Object.defineProperty(e,"ADF_CT_CRITICAL",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(e,"augmentedDickeyFuller",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(e,"autocorrelations",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(e,"spearman",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(e,"kendall",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(e,"seriesStats",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(e,"D2_N2",{enumerable:!0,get:function(){return we}}),Object.defineProperty(e,"D4_N2",{enumerable:!0,get:function(){return Te}}),Object.defineProperty(e,"movingRanges",{enumerable:!0,get:function(){return Ne}}),Object.defineProperty(e,"withinSigma",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(e,"capability",{enumerable:!0,get:function(){return $e}}),Object.defineProperty(e,"controlLimits",{enumerable:!0,get:function(){return je}}),Object.defineProperty(e,"westernElectricViolations",{enumerable:!0,get:function(){return Ge}}),Object.defineProperty(e,"nelsonViolations",{enumerable:!0,get:function(){return Fe}}),Object.defineProperty(e,"CONTROL_RULE_SETS",{enumerable:!0,get:function(){return Pe}}),Object.defineProperty(e,"controlViolations",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(e,"countOutside",{enumerable:!0,get:function(){return Me}}),Object.defineProperty(e,"histogram",{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(e,"DEFAULT_CONFIDENCE",{enumerable:!0,get:function(){return We}}),Object.defineProperty(e,"meanInterval",{enumerable:!0,get:function(){return nt}}),Object.defineProperty(e,"proportionInterval",{enumerable:!0,get:function(){return Qe}}),Object.defineProperty(e,"slopeInterval",{enumerable:!0,get:function(){return dt}}),Object.defineProperty(e,"capabilityInterval",{enumerable:!0,get:function(){return jt}}),Object.defineProperty(e,"standardizedMeanDifference",{enumerable:!0,get:function(){return Et}}),Object.defineProperty(e,"normalTotalVariation",{enumerable:!0,get:function(){return it}}),Object.defineProperty(e,"frequencyMap",{enumerable:!0,get:function(){return ft}}),Object.defineProperty(e,"categoricalDistance",{enumerable:!0,get:function(){return pt}}),Object.defineProperty(e,"SUBSET_RELIABILITY_FLOOR",{enumerable:!0,get:function(){return Tt}}),Object.defineProperty(e,"compareColumn",{enumerable:!0,get:function(){return Nt}}),Object.defineProperty(e,"isNumericColumn",{enumerable:!0,get:function(){return Lt}}),Object.defineProperty(e,"populationRead",{enumerable:!0,get:function(){return Je}});const ne=B("packages/core/src/compute/handle.js"),A=ne.presenceReader,V=ne.valueReader,U=B("packages/core/src/compute/special.js"),I=U.studentTQuantile,J=U.studentT,H=U.normalQuantile,L=U.normalCdf,Y=U.chiSquareUpperTail,_=B("packages/core/src/compute/linalg.js"),O=_.cholesky,v=_.choleskySolve,b=_.choleskyInverse,c=_.normalEquations,g=_.quadForm,t=B("packages/core/src/compute/sketch.js").SKETCH_BOUNDS,s=5e3,l=Object.freeze({variance:"rescan",varianceP:"rescan",stddev:"rescan",stddevP:"rescan",sumSquares:"rescan",weightedAvg:"rescan",median:"rescan",percentile:"rescan",p25:"rescan",p75:"rescan",p90:"rescan",p95:"rescan",p99:"rescan",iqr:"rescan",mode:"rescan",distinct:"rescan",range:"rescan",skewness:"rescan",kurtosis:"rescan",geomean:"rescan",harmean:"rescan",mad:"rescan",argmin:"rescan",argmax:"rescan",hhi:"rescan",entropy:"rescan",evenness:"rescan",top3Share:"rescan",top10Share:"rescan",gini:"rescan",trimmedMean:"rescan",winsorizedMean:"rescan",robustOutliers:"rescan",jarqueBera:"rescan",passRate:"rescan",failureCount:"rescan"}),u=Object.freeze({distinct:Object.freeze({sketch:"HyperLogLog",bound:t.distinct}),median:Object.freeze({sketch:"KLL",bound:t.median}),p25:Object.freeze({sketch:"KLL",bound:t.p25}),p75:Object.freeze({sketch:"KLL",bound:t.p75}),p90:Object.freeze({sketch:"KLL",bound:t.p90}),p95:Object.freeze({sketch:"KLL",bound:t.p95}),p99:Object.freeze({sketch:"KLL",bound:t.p99}),iqr:Object.freeze({sketch:"KLL",bound:t.iqr}),top3Share:Object.freeze({sketch:"SpaceSaving",bound:t.topK}),top10Share:Object.freeze({sketch:"SpaceSaving",bound:t.topK})});function n(se){const ge=se==="sum"||se==="avg"||se==="countValues"||se==="min"||se==="max"?"maintained":Object.prototype.hasOwnProperty.call(l,se)?l[se]:null,Se=Object.prototype.hasOwnProperty.call(u,se)?u[se]:null;return{stat:se,exact:ge,approximate:Se}}function p(se,ge){const Se=ge.length,Re=new Float64Array(Se);let xe=0;if(se&&(se.kind==="float64"||se.kind==="int32")){const Ae=se.values,Ce=A(se);for(let De=0;De<Se;De++){const Ue=ge[De];if(Ce&&Ce(Ue)!==1)continue;const qe=Ae[Ue];Number.isNaN(qe)||(Re[xe++]=qe)}return Re.subarray(0,xe)}const de=V(se);for(let Ae=0;Ae<Se;Ae++){const Ce=de(ge[Ae]);if(Ce==null||Ce==="")continue;const De=typeof Ce=="number"?Ce:Number(Ce);Number.isFinite(De)&&(Re[xe++]=De)}return Re.subarray(0,xe)}function r(se,ge){const Se=new Map,Re=V(se);let xe=0;for(let de=0;de<ge.length;de++){const Ae=Re(ge[de]);if(Ae==null||Ae===""||typeof Ae=="number"&&Number.isNaN(Ae))continue;const Ce=typeof Ae=="object"?String(Ae):Ae;Se.set(Ce,(Se.get(Ce)||0)+1),xe++}const oe=[...Se.values()].sort((de,Ae)=>Ae-de);return{counts:oe,total:xe,distinct:oe.length}}function i(se){return se.total>0?se.counts.map(ge=>ge/se.total):[]}function d(se,ge){const Se=r(se,ge);if(!Se.total)return null;let Re=0;for(const xe of i(Se))Re+=xe*xe;return Re}function h(se,ge){const Se=r(se,ge);if(!Se.total)return null;let Re=0;for(const xe of i(Se))xe>0&&(Re-=xe*Math.log2(xe));return Re}function a(se,ge){const Se=r(se,ge);if(!Se.total||Se.distinct<2)return Se.total?1:null;let Re=0;for(const xe of i(Se))xe>0&&(Re-=xe*Math.log2(xe));return Re/Math.log2(Se.distinct)}function y(se,ge,Se=3){const Re=r(se,ge);if(!Re.total)return null;const xe=Math.max(1,Math.floor(Se));let oe=0;for(let de=0;de<Math.min(xe,Re.counts.length);de++)oe+=Re.counts[de];return oe/Re.total}function f(se,ge){const Se=p(se,ge),Re=Se.length;if(!Re)return null;const xe=Se.slice().sort();if(xe[0]<0)return null;let oe=0,de=0;for(let Ae=0;Ae<Re;Ae++)oe+=xe[Ae],de+=(Ae+1)*xe[Ae];return oe===0?0:2*de/(Re*oe)-(Re+1)/Re}function m(se){let ge=0,Se=0,Re=0;for(let xe=0;xe<se.length;xe++){const oe=se[xe];ge++;const de=oe-Se;Se+=de/ge,Re+=de*(oe-Se)}return{n:ge,mean:Se,m2:Re}}function w(se,ge){const Se=se.length;if(!Se)return NaN;if(Se===1)return se[0];const Re=(Se-1)*Math.min(1,Math.max(0,ge)),xe=Math.floor(Re),oe=Math.ceil(Re);return xe===oe?se[xe]:se[xe]+(Re-xe)*(se[oe]-se[xe])}function S(se,ge){if(!se.length)return NaN;const Se=se.slice().sort();return w(Se,ge)}function M(se,ge){const Se=V(se);let Re=0,xe=0,oe=0;for(let de=0;de<ge.length;de++){const Ae=Se(ge[de]);if(Ae==null||Ae==="")continue;const Ce=String(Ae).toUpperCase();Ce==="PASS"?Re++:Ce==="FAIL"?xe++:Ce==="WARN"&&oe++}return{pass:Re+oe,fail:xe,warn:oe,judged:Re+oe+xe}}const X=Object.freeze({hhi:(se,ge)=>d(se,ge),entropy:(se,ge)=>h(se,ge),evenness:(se,ge)=>a(se,ge),top3Share:(se,ge)=>y(se,ge,3),top10Share:(se,ge)=>y(se,ge,10),gini:(se,ge)=>f(se,ge),trimmedMean:(se,ge)=>E(p(se,ge),.1),winsorizedMean:(se,ge)=>C(p(se,ge),.1),robustOutliers:(se,ge)=>x(p(se,ge),3.5),jarqueBera:(se,ge)=>j(p(se,ge)),variance:(se,ge)=>{const{n:Se,m2:Re}=m(p(se,ge));return Se>1?Re/(Se-1):null},varianceP:(se,ge)=>{const{n:Se,m2:Re}=m(p(se,ge));return Se>0?Re/Se:null},stddev:(se,ge)=>{const{n:Se,m2:Re}=m(p(se,ge));return Se>1?Math.sqrt(Re/(Se-1)):null},stddevP:(se,ge)=>{const{n:Se,m2:Re}=m(p(se,ge));return Se>0?Math.sqrt(Re/Se):null},median:(se,ge)=>{const Se=p(se,ge);return Se.length?S(Se,.5):null},percentile:(se,ge,Se)=>{const Re=Se?Se.p:void 0;if(typeof Re!="number"||!(Re>=0&&Re<=1))return null;const xe=p(se,ge);return xe.length?S(xe,Re):null},p25:(se,ge)=>{const Se=p(se,ge);return Se.length?S(Se,.25):null},p75:(se,ge)=>{const Se=p(se,ge);return Se.length?S(Se,.75):null},p90:(se,ge)=>{const Se=p(se,ge);return Se.length?S(Se,.9):null},p95:(se,ge)=>{const Se=p(se,ge);return Se.length?S(Se,.95):null},p99:(se,ge)=>{const Se=p(se,ge);return Se.length?S(Se,.99):null},iqr:(se,ge)=>{const Se=p(se,ge);if(!Se.length)return null;const Re=Se.slice().sort();return w(Re,.75)-w(Re,.25)},mad:(se,ge)=>{const Se=p(se,ge);if(!Se.length)return null;const Re=S(Se,.5),xe=new Float64Array(Se.length);for(let oe=0;oe<Se.length;oe++)xe[oe]=Math.abs(Se[oe]-Re);return S(xe,.5)},range:(se,ge)=>{const Se=p(se,ge);if(!Se.length)return null;let Re=1/0,xe=-1/0;for(let oe=0;oe<Se.length;oe++)Se[oe]<Re&&(Re=Se[oe]),Se[oe]>xe&&(xe=Se[oe]);return xe-Re},distinct:(se,ge)=>{const Se=V(se),Re=new Set;for(let xe=0;xe<ge.length;xe++){const oe=Se(ge[xe]);oe==null||oe===""||Re.add(oe instanceof Date?oe.getTime():oe)}return Re.size},mode:(se,ge)=>{const Se=V(se),Re=new Map;for(let de=0;de<ge.length;de++){const Ae=Se(ge[de]);if(Ae==null||Ae==="")continue;const Ce=Ae instanceof Date?Ae.getTime():Ae;Re.set(Ce,(Re.get(Ce)||0)+1)}let xe=null,oe=1;for(const[de,Ae]of Re)Ae>oe&&(oe=Ae,xe=de);return xe},skewness:(se,ge)=>{const Se=p(se,ge),{n:Re,mean:xe,m2:oe}=m(Se);if(Re<3||oe<=0)return null;const de=Math.sqrt(oe/(Re-1));let Ae=0;for(let Ce=0;Ce<Se.length;Ce++)Ae+=((Se[Ce]-xe)/de)**3;return Re/((Re-1)*(Re-2))*Ae},kurtosis:(se,ge)=>{const Se=p(se,ge),{n:Re,mean:xe,m2:oe}=m(Se);if(Re<4||oe<=0)return null;const de=Math.sqrt(oe/(Re-1));let Ae=0;for(let Ue=0;Ue<Se.length;Ue++)Ae+=((Se[Ue]-xe)/de)**4;const Ce=Re*(Re+1)/((Re-1)*(Re-2)*(Re-3)),De=3*(Re-1)**2/((Re-2)*(Re-3));return Ce*Ae-De},geomean:(se,ge)=>{const Se=p(se,ge);if(!Se.length)return null;let Re=0;for(let xe=0;xe<Se.length;xe++){if(Se[xe]<=0)return null;Re+=Math.log(Se[xe])}return Math.exp(Re/Se.length)},harmean:(se,ge)=>{const Se=p(se,ge);if(!Se.length)return null;let Re=0;for(let xe=0;xe<Se.length;xe++){if(Se[xe]===0)return null;Re+=1/Se[xe]}return Se.length/Re},sumSquares:(se,ge)=>{const Se=p(se,ge);let Re=0;for(let xe=0;xe<Se.length;xe++)Re+=Se[xe]*Se[xe];return Re},passRate:(se,ge)=>{const{pass:Se,judged:Re}=M(se,ge);return Re?Se/Re:null},failureCount:(se,ge)=>M(se,ge).fail}),q=Object.freeze({hhi:"Concentration (HHI)",entropy:"Entropy",evenness:"Evenness",top3Share:"Top 3 share",top10Share:"Top 10 share",gini:"Gini coefficient",trimmedMean:"Trimmed mean",winsorizedMean:"Winsorized mean",robustOutliers:"Outliers (robust)",jarqueBera:"Jarque–Bera",median:"Median",percentile:"Percentile",p25:"25th percentile",p75:"75th percentile",p90:"90th percentile",p95:"95th percentile",p99:"99th percentile",iqr:"Interquartile range",mad:"Median absolute deviation",variance:"Variance",varianceP:"Variance (population)",stddev:"Standard deviation",stddevP:"Standard deviation (population)",range:"Range",distinct:"Distinct",mode:"Mode",skewness:"Skewness",kurtosis:"Kurtosis",geomean:"Geometric mean",harmean:"Harmonic mean",sumSquares:"Sum of squares",weightedAvg:"Weighted average",argmin:"Lowest by",argmax:"Highest by",passRate:"Pass rate",failureCount:"Failures"});function K(se,ge,Se){const Re=V(se),xe=V(ge);let oe=0,de=0;for(let Ae=0;Ae<Se.length;Ae++){const Ce=Se[Ae],De=Number(Re(Ce)),Ue=Number(xe(Ce));!Number.isFinite(De)||!Number.isFinite(Ue)||(oe+=De*Ue,de+=Ue)}return de===0?null:oe/de}function P(se,ge,Se){const Re=V(se);let xe=null,oe=Se?-1/0:1/0;for(let de=0;de<ge.length;de++){const Ae=ge[de],Ce=Number(Re(Ae));Number.isFinite(Ce)&&(Se?Ce>oe:Ce<oe)&&(oe=Ce,xe=Ae)}return xe}function k(se,ge,Se){const Re=V(se),xe=V(ge);let oe=0,de=0,Ae=0,Ce=0,De=0,Ue=0;for(let ot=0;ot<Se.length;ot++){const vt=Se[ot],Rt=Number(Re(vt)),At=Number(xe(vt));!Number.isFinite(Rt)||!Number.isFinite(At)||(oe++,de+=Rt,Ae+=At,Ce+=Rt*Rt,De+=At*At,Ue+=Rt*At)}if(oe<2)return null;const qe=oe*Ue-de*Ae,rt=Math.sqrt((oe*Ce-de*de)*(oe*De-Ae*Ae));if(rt===0)return null;const ct=qe/rt;return Math.max(-1,Math.min(1,ct))}function E(se,ge=.1){const Se=se.length;if(!Se)return null;const Re=Array.from(se).sort((Ae,Ce)=>Ae-Ce),xe=Math.floor(Se*Math.min(.49,Math.max(0,ge))),oe=Re.slice(xe,Se-xe);if(!oe.length)return w(Re,.5);let de=0;for(const Ae of oe)de+=Ae;return de/oe.length}function C(se,ge=.1){const Se=se.length;if(!Se)return null;const Re=Array.from(se).sort((Ce,De)=>Ce-De),xe=Math.floor(Se*Math.min(.49,Math.max(0,ge))),oe=Re[xe],de=Re[Se-1-xe];let Ae=0;for(const Ce of Re)Ae+=Math.min(de,Math.max(oe,Ce));return Ae/Se}function x(se,ge=3.5){if(!se.length)return null;const Re=Array.from(se).sort((Ce,De)=>Ce-De),xe=w(Re,.5),oe=Re.map(Ce=>Math.abs(Ce-xe)).sort((Ce,De)=>Ce-De),de=w(oe,.5);if(de===0)return null;let Ae=0;for(const Ce of Re)Math.abs(.6745*(Ce-xe)/de)>ge&&Ae++;return Ae}function j(se){const ge=se.length;if(ge<8)return null;let Se=0;for(const Ce of se)Se+=Ce;Se/=ge;let Re=0,xe=0,oe=0;for(const Ce of se){const De=Ce-Se;Re+=De*De,xe+=De*De*De,oe+=De*De*De*De}if(Re/=ge,xe/=ge,oe/=ge,Re===0)return null;const de=xe/Re**1.5,Ae=oe/(Re*Re)-3;return ge/6*(de*de+Ae*Ae/4)}function T(se,ge,Se){const Re=[];let xe=0;for(let Ce=0;Ce<se.length;Ce++){const De=Number(se[Ce]),Ue=Number(ge[Ce]);!Number.isFinite(De)||!Number.isFinite(Ue)||Ue<=0||(Re.push([De,Ue]),xe+=Ue)}if(!Re.length||xe<=0)return null;if(Re.sort((Ce,De)=>Ce[0]-De[0]),Re.length===1)return Re[0][0];const oe=[];let de=0;for(const[,Ce]of Re)oe.push((de+Ce/2)/xe),de+=Ce;const Ae=Math.max(0,Math.min(1,Se));if(Ae<=oe[0])return Re[0][0];if(Ae>=oe[oe.length-1])return Re[Re.length-1][0];for(let Ce=1;Ce<oe.length;Ce++){if(Ae>oe[Ce])continue;const De=oe[Ce]-oe[Ce-1],Ue=De>0?(Ae-oe[Ce-1])/De:0;return Re[Ce-1][0]+(Re[Ce][0]-Re[Ce-1][0])*Ue}return Re[Re.length-1][0]}function F(se,ge,Se){const Re=V(se),xe=V(ge),oe=new Float64Array(Se.length),de=new Float64Array(Se.length);let Ae=0;for(let Ce=0;Ce<Se.length;Ce++){const De=Se[Ce],Ue=Number(Re(De)),qe=Number(xe(De));!Number.isFinite(Ue)||!Number.isFinite(qe)||(oe[Ae]=Ue,de[Ae]=qe,Ae++)}return{xs:oe.subarray(0,Ae),ys:de.subarray(0,Ae),n:Ae}}function $(se,ge,Se,Re=!1){const{xs:xe,ys:oe,n:de}=F(se,ge,Se);if(de<2)return null;let Ae=0,Ce=0;for(let Ue=0;Ue<de;Ue++)Ae+=xe[Ue],Ce+=oe[Ue];Ae/=de,Ce/=de;let De=0;for(let Ue=0;Ue<de;Ue++)De+=(xe[Ue]-Ae)*(oe[Ue]-Ce);return De/(Re?de:de-1)}function D(se,ge,Se){const{xs:Re,ys:xe,n:oe}=F(se,ge,Se);if(oe<2)return null;let de=0,Ae=0;for(let Rt=0;Rt<oe;Rt++)de+=Re[Rt],Ae+=xe[Rt];de/=oe,Ae/=oe;let Ce=0,De=0,Ue=0;for(let Rt=0;Rt<oe;Rt++){const At=Re[Rt]-de,_t=xe[Rt]-Ae;Ce+=At*At,De+=At*_t,Ue+=_t*_t}if(Ce===0)return null;const qe=De/Ce,rt=Ae-qe*de,ct=Ue===0?1:Math.max(0,Math.min(1,De*De/(Ce*Ue))),ot=Math.max(0,Ue-qe*De),vt=oe>2?Math.sqrt(ot/(oe-2)/Ce):0;return{slope:qe,intercept:rt,r2:ct,stdError:vt,n:oe}}const z=new Set(["ols","wls","robust"]),G=new Set(["quantile"]),N=new Set(["ridge","lasso","elasticnet","mixed","gls"]),Z=1.345;function Q(se,ge,Se){const{xtwx:Re,xtwy:xe}=c(se,ge,Se),oe=O(Re);if(!oe)return null;const de=v(oe,xe),Ae=b(oe),Ce=ee(se,de),De=ge.map((Ue,qe)=>Ue-Ce[qe]);return{beta:de,cov:Ae,fitted:Ce,residuals:De}}function ee(se,ge){return se.map(Se=>Se.reduce((Re,xe,oe)=>Re+xe*ge[oe],0))}function re(se,ge){const Se=se.length,Re=se.map(De=>De[ge]),xe=se.map(De=>[1,...De.filter((Ue,qe)=>qe!==ge)]),oe=Q(xe,Re,null);if(!oe)return 1;const de=Re.reduce((De,Ue)=>De+Ue,0)/Se;let Ae=0,Ce=0;for(let De=0;De<Se;De++)Ae+=oe.residuals[De]**2,Ce+=(Re[De]-de)**2;return Ce===0?1:Math.max(0,Math.min(1,1-Ae/Ce))}function ie(se){const ge=[...se].sort((xe,oe)=>xe-oe),Se=ce(ge),Re=se.map(xe=>Math.abs(xe-Se)).sort((xe,oe)=>xe-oe);return ce(Re)/.6745}function ce(se){const ge=se.length;if(!ge)return 0;const Se=Math.floor(ge/2);return ge%2?se[Se]:(se[Se-1]+se[Se])/2}function ve(se,ge,Se={}){const Re=Se.method||"ols";if(N.has(Re))throw new Error(`[lattice] regression method "${Re}" is out of scope; use ols, wls or robust.`);if(G.has(Re))throw new Error("[lattice] quantile regression is coming next and not yet available; use ols, wls or robust.");if(!z.has(Re))throw new Error(`[lattice] unknown regression method "${Re}"; use ols, wls or robust.`);const xe=Array.isArray(ge)?ge.length:0,oe=xe&&Array.isArray(se[0])?se[0].length:0,de=oe+1;if(!(xe>de))return null;for(let Ct=0;Ct<xe;Ct++){if(!Number.isFinite(ge[Ct])||!Array.isArray(se[Ct])||se[Ct].length!==oe)return null;for(let $t=0;$t<oe;$t++)if(!Number.isFinite(se[Ct][$t]))return null}let Ae=null;if(Re==="wls"){if(Ae=Se.weights,!Array.isArray(Ae)||Ae.length!==xe)return null;for(let Ct=0;Ct<xe;Ct++)if(!(Ae[Ct]>0)||!Number.isFinite(Ae[Ct]))return null}const Ce=se.map(Ct=>[1,...Ct]);let De,Ue=null;if(Re==="robust"){if(De=Q(Ce,ge,null),!De)return null;for(let Ct=0;Ct<50;Ct++){const $t=ie(De.residuals);if(!($t>0))break;const Vt=De.residuals.map(Ut=>{const Gt=Math.abs(Ut/$t);return Gt<=Z?1:Z/Gt}),zt=Q(Ce,ge,Vt);if(!zt)return null;const Wt=zt.beta.reduce((Ut,Gt,It)=>Math.max(Ut,Math.abs(Gt-De.beta[It])),0);if(De=zt,Ue=Vt,Wt<1e-10)break}}else if(De=Q(Ce,ge,Ae),!De)return null;const qe=Re==="robust"?Ue:Ae,{beta:rt,cov:ct,fitted:ot,residuals:vt}=De;let Rt=0,At=0,_t=0;for(let Ct=0;Ct<xe;Ct++){const $t=qe?qe[Ct]:1;Rt+=$t*vt[Ct]**2,At+=$t,_t+=$t*ge[Ct]}const tn=_t/At;let Ht=0;for(let Ct=0;Ct<xe;Ct++){const $t=qe?qe[Ct]:1;Ht+=$t*(ge[Ct]-tn)**2}const Xt=xe-de,Ze=Rt/Xt,lt=Ht===0?1:Math.max(0,Math.min(1,1-Rt/Ht)),St=1-(1-lt)*(xe-1)/Xt,bt=Array.isArray(Se.names)&&Se.names.length===oe?Se.names:se[0].map((Ct,$t)=>`x${$t+1}`),wt=Ye(Se.confidence),Ke=Xt>0?I(1-(1-wt)/2,Xt):1/0,ht=rt.map((Ct,$t)=>{const Vt=Math.sqrt(Math.max(0,Ze*ct[$t][$t])),zt=Vt>0?Ct/Vt:Ct===0?0:1/0,Wt=Number.isFinite(zt)?2*(1-J(Math.abs(zt),Xt)):0,Ut=Number.isFinite(Ke)?Ke*Vt:null;return{name:$t===0?"(intercept)":bt[$t-1],estimate:Ct,stdError:Vt,t:zt,p:Math.max(0,Math.min(1,Wt)),lower:Ut===null?null:Ct-Ut,upper:Ut===null?null:Ct+Ut}}),at=new Array(xe),mt=new Array(xe);for(let Ct=0;Ct<xe;Ct++){const $t=qe?qe[Ct]:1,Vt=Math.max(0,Math.min(1,$t*g(Ce[Ct],ct)));at[Ct]=Vt;const zt=(1-Vt)**2;mt[Ct]=zt>0&&Ze>0?vt[Ct]**2/(de*Ze)*(Vt/zt):null}const xt=se[0].map((Ct,$t)=>{if(oe<2)return 1;const Vt=re(se,$t);return Vt>=1?1/0:1/(1-Vt)});let Ft=null;{const Ct=vt.map(Vt=>Vt*Vt),$t=Q(Ce,Ct,null);if($t){const Vt=Ct.reduce((Jt,ln)=>Jt+ln,0)/xe;let zt=0,Wt=0;for(let Jt=0;Jt<xe;Jt++)zt+=$t.residuals[Jt]**2,Wt+=(Ct[Jt]-Vt)**2;const Ut=Wt===0?0:Math.max(0,Math.min(1,1-zt/Wt)),Gt=xe*Ut,It=Y(Gt,oe);Ft={statistic:Gt,df:oe,p:It,heteroscedastic:It<.05}}}let yt=null;if(oe===1){const Ct=se.map(($t,Vt)=>Vt).sort(($t,Vt)=>se[$t][0]-se[Vt][0]);yt={confidence:wt,points:Ct.map($t=>{const Vt=Ce[$t],zt=Math.sqrt(Math.max(0,Ze*g(Vt,ct)));return{x:se[$t][0],yhat:ot[$t],lower:ot[$t]-Ke*zt,upper:ot[$t]+Ke*zt}})}}return{method:Re,coefficients:ht,r2:lt,adjR2:St,n:xe,df:Xt,sigma2:Ze,fitted:ot,residuals:vt,leverage:at,cooksD:mt,vif:xt,heteroscedasticity:Ft,band:yt,weights:qe?[...qe]:null}}function he(se){const ge=se.length,Se=Array.from({length:ge},(oe,de)=>de).sort((oe,de)=>se[oe]-se[de]),Re=new Float64Array(ge);let xe=0;for(;xe<ge;){let oe=xe;for(;oe+1<ge&&se[Se[oe+1]]===se[Se[xe]];)oe++;const de=(xe+oe)/2+1;for(let Ae=xe;Ae<=oe;Ae++)Re[Se[Ae]]=de;xe=oe+1}return Re}const ye=Object.freeze({"1%":-3.9638,"5%":-3.4126,"10%":-3.1279});function Oe(se){const ge=[.01,.05,.1],Se=[ye["1%"],ye["5%"],ye["10%"]];if(se<=Se[0]){const oe=(Math.log(ge[1])-Math.log(ge[0]))/(Se[1]-Se[0]);return Math.max(1e-4,Math.min(.01,Math.exp(Math.log(ge[0])+oe*(se-Se[0]))))}if(se>=Se[2]){const oe=(Math.log(ge[2])-Math.log(ge[1]))/(Se[2]-Se[1]);return Math.max(.1,Math.min(.999,Math.exp(Math.log(ge[2])+oe*(se-Se[2]))))}const Re=se<Se[1]?0:1,xe=(se-Se[Re])/(Se[Re+1]-Se[Re]);return Math.exp(Math.log(ge[Re])+xe*(Math.log(ge[Re+1])-Math.log(ge[Re])))}function Le(se,ge,Se,Re){const xe=Se-Re,oe=Re+3,de=new Array(xe),Ae=new Array(xe);let Ce=!0,De=Re;for(let ot=0;ot<xe;ot++){const vt=Re+ot,Rt=new Float64Array(oe);Rt[0]=1,Rt[1]=ot+1,Rt[2]=se[vt];for(let At=1;At<=Re;At++)Rt[2+At]=ge[vt-At];for(let At=1;At<oe;At++)Number.isFinite(Rt[At])||(De=Math.min(De,At-3));de[ot]=Rt,Ae[ot]=ge[vt],Number.isFinite(Ae[ot])||(Ce=!1)}if(!Ce)return 0;const{xtwx:Ue,xtwy:qe}=c(de,Ae,null);let rt=0,ct=1/0;for(let ot=0;ot<=De;ot++){const vt=ot+3;if(!(xe>vt))continue;const Rt=new Array(vt);for(let lt=0;lt<vt;lt++)Rt[lt]=Ue[lt].slice(0,vt);const At=O(Rt);if(!At)continue;const _t=v(At,qe.slice(0,vt));let tn=0;for(let lt=0;lt<xe;lt++){const St=de[lt];let bt=0;for(let wt=0;wt<vt;wt++)bt+=St[wt]*_t[wt];tn+=(Ae[lt]-bt)**2}const Xt=tn/(xe-vt)*(xe-vt);if(!(Xt>0))continue;const Ze=xe*Math.log(Xt/xe)+2*vt;Ze<ct&&(ct=Ze,rt=ot)}return rt}function fe(se,ge={}){const Se=[];for(let ct=0;ct<se.length;ct++){const ot=Number(se[ct]);Number.isFinite(ot)&&Se.push(ot)}const Re=Se.length,xe=Re-1;if(Re<8||xe<6)return null;const oe=new Array(xe);for(let ct=0;ct<xe;ct++)oe[ct]=Se[ct+1]-Se[ct];let de=Number.isFinite(ge.maxlag)?Math.floor(ge.maxlag):Math.ceil(12*(Re/100)**.25);de=Math.max(0,Math.min(de,Math.floor((xe-5)/2)));const Ae=(ct,ot)=>{const vt=[],Rt=[];for(let At=ot;At<xe;At++){const _t=[At-ot+1,Se[At]];for(let tn=1;tn<=ct;tn++)_t.push(oe[At-tn]);vt.push(_t),Rt.push(oe[At])}return ve(vt,Rt,{method:"ols"})},Ce=Le(Se,oe,xe,de),De=Ae(Ce,Ce);if(!De||!De.coefficients[2])return null;const Ue=De.coefficients[2].t,qe=Oe(Ue),rt=Ue<ye["5%"];return{statistic:Ue,usedLag:Ce,nobs:xe-Ce,criticalValues:{...ye},pValue:qe,pApproximate:!0,stationary:rt,verdict:rt?"stationary":"non-stationary",regression:"ct"}}function ae(se,ge={}){const Se=[];for(let rt=0;rt<se.length;rt++){const ct=Number(se[rt]);Number.isFinite(ct)&&Se.push(ct)}const Re=Se.length;if(Re<3)return null;let xe=Number.isFinite(ge.maxlag)?Math.floor(ge.maxlag):Math.min(10,Re-1);xe=Math.max(1,Math.min(xe,Re-1));let oe=0;for(const rt of Se)oe+=rt;oe/=Re;const de=Se.map(rt=>rt-oe);let Ae=0;for(const rt of de)Ae+=rt*rt;Ae/=Re;const Ce=new Array(xe+1).fill(0);Ce[0]=1;for(let rt=1;rt<=xe;rt++){let ct=0;for(let ot=rt;ot<Re;ot++)ct+=de[ot]*de[ot-rt];Ce[rt]=Ae>0?ct/Re/Ae:0}const De=new Array(xe+1).fill(0);De[0]=1;let Ue=[];for(let rt=1;rt<=xe;rt++){let ct=Ce[rt];for(let At=1;At<rt;At++)ct-=Ue[At-1]*Ce[rt-At];let ot=1;for(let At=1;At<rt;At++)ot-=Ue[At-1]*Ce[At];const vt=ot!==0?ct/ot:0,Rt=new Array(rt);for(let At=1;At<rt;At++)Rt[At-1]=Ue[At-1]-vt*Ue[rt-1-At];Rt[rt-1]=vt,De[rt]=vt,Ue=Rt}const qe=1.96/Math.sqrt(Re);return{acf:Ce,pacf:De,bounds:{upper:qe,lower:-qe},n:Re,nlags:xe,approximate:!0}}function ke(se,ge,Se){const{xs:Re,ys:xe,n:oe}=F(se,ge,Se);if(oe<2)return null;const de=he(Re),Ae=he(xe);let Ce=0,De=0;for(let ct=0;ct<oe;ct++)Ce+=de[ct],De+=Ae[ct];Ce/=oe,De/=oe;let Ue=0,qe=0,rt=0;for(let ct=0;ct<oe;ct++){const ot=de[ct]-Ce,vt=Ae[ct]-De;Ue+=ot*vt,qe+=ot*ot,rt+=vt*vt}return qe===0||rt===0?null:Math.max(-1,Math.min(1,Ue/Math.sqrt(qe*rt)))}function pe(se,ge,Se){const{xs:Re,ys:xe,n:oe}=F(se,ge,Se);if(oe<2||oe>s)return null;let de=0,Ae=0,Ce=0,De=0;for(let rt=0;rt<oe;rt++)for(let ct=rt+1;ct<oe;ct++){const ot=Math.sign(Re[rt]-Re[ct]),vt=Math.sign(xe[rt]-xe[ct]),Rt=ot*vt;Rt>0?de++:Rt<0?Ae++:ot===0&&vt===0||(ot===0?Ce++:De++)}const Ue=de+Ae+De,qe=de+Ae+Ce;return Ue===0||qe===0?null:(de-Ae)/Math.sqrt(Ue*qe)}function ue(se,ge={}){const Se=se.length;if(Se<2)return null;const Re=se[0],xe=se[Se-1],oe=[];for(let At=1;At<Se;At++){const _t=se[At-1];_t!==0&&oe.push((se[At]-_t)/Math.abs(_t))}let de=null;if(oe.length>1){let At=0;for(const tn of oe)At+=tn;At/=oe.length;let _t=0;for(const tn of oe)_t+=(tn-At)**2;de=Math.sqrt(_t/(oe.length-1))}const Ae=Number(ge.periodsPerYear)>0?Number(ge.periodsPerYear):null;let Ce=se[0],De=0,Ue=0,qe=0,rt=0;for(let At=1;At<Se;At++){if(se[At]>Ce){Ce=se[At],De=At;continue}if(Ce<=0)continue;const _t=(Ce-se[At])/Ce;_t>Ue&&(Ue=_t,qe=De,rt=At)}let ct=null;if(Se>2){let At=0;for(let Ht=0;Ht<Se;Ht++)At+=se[Ht];At/=Se;let _t=0,tn=0;for(let Ht=0;Ht<Se;Ht++){const Xt=se[Ht]-At;tn+=Xt*Xt,Ht>0&&(_t+=Xt*(se[Ht-1]-At))}ct=tn>0?_t/tn:null}let ot=0,vt=0;for(const At of oe)At>0?ot++:At<0&&vt++;let Rt=null;if(Re>0&&xe>0){const At=(xe/Re)**(1/(Se-1))-1;Rt=Ae?(1+At)**Ae-1:At}return{n:Se,first:Re,last:xe,change:xe-Re,changePercent:Re===0?null:(xe-Re)/Math.abs(Re)*100,volatility:de,annualisedVolatility:de!==null&&Ae?de*Math.sqrt(Ae):null,growth:Rt,maxDrawdown:Ue,maxDrawdownFrom:qe,maxDrawdownTo:rt,autocorrelation:ct,upDays:ot,downDays:vt}}const we=1.128,Te=3.267;function Ne(se){const ge=se.length;if(ge<2)return null;const Se=[];for(let xe=1;xe<ge;xe++)Se.push(Math.abs(se[xe]-se[xe-1]));const Re=Se.reduce((xe,oe)=>xe+oe,0)/Se.length;return{ranges:Se,centre:Re,upper:Te*Re,lower:0}}function _e(se){const ge=se.length;if(ge<2)return null;let Se=0;for(let xe=1;xe<ge;xe++)Se+=Math.abs(se[xe]-se[xe-1]);const Re=Se/(ge-1);return{sigma:Re/we,meanRange:Re}}function $e(se,ge){const Se=se.length;if(Se<2||!ge)return null;const Re=Number.isFinite(Number(ge.lower))?Number(ge.lower):null,xe=Number.isFinite(Number(ge.upper))?Number(ge.upper):null;if(Re===null&&xe===null)return null;let oe=0;for(let ot=0;ot<Se;ot++)oe+=se[ot];oe/=Se;let de=0;for(let ot=0;ot<Se;ot++)de+=(se[ot]-oe)**2;const Ae=Math.sqrt(de/(Se-1)),Ce=_e(se),De=Ce?Ce.sigma:null,Ue=ot=>{if(!ot||ot<=0)return{index:null,k:null};const Rt=Re!==null&&xe!==null?(xe-Re)/(6*ot):null,At=xe!==null?(xe-oe)/(3*ot):1/0,_t=Re!==null?(oe-Re)/(3*ot):1/0;return{index:Rt,k:Math.min(At,_t)}},qe=Ue(De),rt=Ue(Ae);let ct=0;for(let ot=0;ot<Se;ot++){if(Re!==null&&se[ot]<Re){ct++;continue}xe!==null&&se[ot]>xe&&ct++}return{n:Se,mean:oe,lower:Re,upper:xe,target:Number.isFinite(Number(ge.target))?Number(ge.target):null,sigmaWithin:De,sigmaOverall:Ae,cp:qe.index,cpk:qe.k,pp:rt.index,ppk:rt.k,outOfSpec:ct,defectRate:Se?ct/Se:null}}function je(se){const ge=se.length;if(ge<2)return null;const Se=_e(se);if(!Se||!(Se.sigma>0))return null;let Re=0;for(let xe=0;xe<ge;xe++)Re+=se[xe];return Re/=ge,{centre:Re,sigma:Se.sigma,upper:Re+3*Se.sigma,lower:Re-3*Se.sigma}}function Ge(se,ge){if(!ge||!(ge.sigma>0))return[];const Se=se.length,{centre:Re,sigma:xe}=ge,oe=Ae=>(se[Ae]-Re)/xe,de=[];for(let Ae=0;Ae<Se;Ae++){if(Math.abs(oe(Ae))>3&&de.push({index:Ae,rule:1,description:"beyond three sigma"}),Ae>=2)for(const Ce of[1,-1]){let De=0;for(let Ue=Ae-2;Ue<=Ae;Ue++)oe(Ue)*Ce>2&&De++;if(De>=2){de.push({index:Ae,rule:2,description:"two of three past two sigma"});break}}if(Ae>=4)for(const Ce of[1,-1]){let De=0;for(let Ue=Ae-4;Ue<=Ae;Ue++)oe(Ue)*Ce>1&&De++;if(De>=4){de.push({index:Ae,rule:3,description:"four of five past one sigma"});break}}if(Ae>=7)for(const Ce of[1,-1]){let De=!0;for(let Ue=Ae-7;Ue<=Ae;Ue++)if(oe(Ue)*Ce<=0){De=!1;break}if(De){de.push({index:Ae,rule:4,description:"eight in a row on one side"});break}}}return de}function Fe(se,ge){if(!ge||!(ge.sigma>0))return[];const Se=se.length,{centre:Re,sigma:xe}=ge,oe=Ce=>(se[Ce]-Re)/xe,de=(Ce,De,Ue,qe)=>{for(const rt of[1,-1]){let ct=0;for(let ot=Ce;ot<=De;ot++)oe(ot)*rt>Ue&&ct++;if(ct>=qe)return!0}return!1},Ae=[];for(let Ce=0;Ce<Se;Ce++){if(Math.abs(oe(Ce))>3&&Ae.push({index:Ce,rule:1,description:"beyond three sigma"}),Ce>=8)for(const De of[1,-1]){let Ue=!0;for(let qe=Ce-8;qe<=Ce;qe++)if(oe(qe)*De<=0){Ue=!1;break}if(Ue){Ae.push({index:Ce,rule:2,description:"nine in a row on one side"});break}}if(Ce>=5)for(const De of[1,-1]){let Ue=!0;for(let qe=Ce-4;qe<=Ce;qe++)if((se[qe]-se[qe-1])*De<=0){Ue=!1;break}if(Ue){Ae.push({index:Ce,rule:3,description:De>0?"six rising":"six falling"});break}}if(Ce>=13){let De=!0;for(let Ue=Ce-12;Ue<=Ce;Ue++){const qe=se[Ue]-se[Ue-1],rt=se[Ue+1<=Ce?Ue+1:Ue]-se[Ue];if(Ue+1>Ce)break;if(qe===0||rt===0||qe>0==rt>0){De=!1;break}}De&&Ae.push({index:Ce,rule:4,description:"fourteen alternating"})}if(Ce>=2&&de(Ce-2,Ce,2,2)&&Ae.push({index:Ce,rule:5,description:"two of three past two sigma"}),Ce>=4&&de(Ce-4,Ce,1,4)&&Ae.push({index:Ce,rule:6,description:"four of five past one sigma"}),Ce>=14){let De=!0;for(let Ue=Ce-14;Ue<=Ce;Ue++)if(Math.abs(oe(Ue))>=1){De=!1;break}De&&Ae.push({index:Ce,rule:7,description:"fifteen within one sigma"})}if(Ce>=7){let De=!0;for(let Ue=Ce-7;Ue<=Ce;Ue++)if(Math.abs(oe(Ue))<=1){De=!1;break}De&&Ae.push({index:Ce,rule:8,description:"eight beyond one sigma"})}}return Ae}const Pe=Object.freeze(["westernElectric","nelson"]);function Ee(se,ge,Se="westernElectric"){return String(Se)==="nelson"?Fe(se,ge):Ge(se,ge)}function Me(se,ge,Se){let Re=0;for(let xe=0;xe<se.length;xe++)(se[xe]<ge||se[xe]>Se)&&Re++;return Re}function Ie(se,ge,Se,Re=20){const xe=se.length;if(!xe)return[];const oe=se[0],de=se[xe-1];if(de===oe)return[{from:oe,to:de,count:xe}];const Ae=Se-ge,Ce=1.5*Ae;let De=Ae>0?Math.max(oe,ge-Ce):oe,Ue=Ae>0?Math.min(de,Se+Ce):de;Ue>De||(De=oe,Ue=de);const qe=Ae>0?2*Ae/Math.cbrt(xe):(Ue-De)/(Math.ceil(Math.log2(xe))+1),rt=qe>0?Math.min(Re,Math.max(1,Math.ceil((Ue-De)/qe))):1,ct=(Ue-De)/rt,ot=[];for(let vt=0;vt<rt;vt++)ot.push({from:De+vt*ct,to:De+(vt+1)*ct,count:0});for(let vt=0;vt<xe;vt++){const Rt=Math.min(rt-1,Math.max(0,Math.floor((se[vt]-De)/ct)));ot[Rt].count++}return ot[0].from=oe,ot[rt-1].to=de,ot}const We=.95;function Ye(se){const ge=Number(se);return Number.isFinite(ge)&&ge>0&&ge<1?ge:We}function nt(se,ge=We){const Se=se.length;if(Se<2)return null;let Re=0;for(let Ue=0;Ue<Se;Ue++)Re+=se[Ue];const xe=Re/Se;let oe=0;for(let Ue=0;Ue<Se;Ue++){const qe=se[Ue]-xe;oe+=qe*qe}const de=Math.sqrt(oe/(Se-1)),Ae=Ye(ge),De=I(1-(1-Ae)/2,Se-1)*de/Math.sqrt(Se);return{mean:xe,lower:xe-De,upper:xe+De,margin:De,n:Se,confidence:Ae}}function Qe(se,ge,Se=We){const Re=Number(se),xe=Number(ge);if(!(xe>0)||!(Re>=0)||Re>xe)return null;const oe=Ye(Se),de=H(1-(1-oe)/2),Ae=Re/xe,Ce=de*de,De=1+Ce/xe,Ue=(Ae+Ce/(2*xe))/De,qe=de/De*Math.sqrt(Ae*(1-Ae)/xe+Ce/(4*xe*xe));return{proportion:Ae,lower:Math.max(0,Ue-qe),upper:Math.min(1,Ue+qe),n:xe,confidence:oe}}function dt(se,ge=We){if(!se||!(se.n>2)||!Number.isFinite(se.stdError))return null;const Se=Ye(ge),xe=I(1-(1-Se)/2,se.n-2)*se.stdError;return{slope:se.slope,lower:se.slope-xe,upper:se.slope+xe,margin:xe,confidence:Se}}function jt(se,ge,Se=We){const Re=Number(se),xe=Number(ge);if(!Number.isFinite(Re)||!(xe>1))return null;const oe=Ye(Se),Ae=H(1-(1-oe)/2)*Math.sqrt(1/(9*xe)+Re*Re/(2*(xe-1)));return{index:Re,lower:Re-Ae,upper:Re+Ae,margin:Ae,n:xe,confidence:oe}}function Et(se,ge){return!se||!(se.sd>0)||!Number.isFinite(ge)||!Number.isFinite(se.mean)?null:(ge-se.mean)/se.sd}function it(se){return Number.isFinite(se)?Math.min(1,Math.max(0,2*L(Math.abs(se)/2)-1)):0}function ft(se,ge){const Se=new Map,Re=V(se);let xe=0;for(let oe=0;oe<ge.length;oe++){const de=Re(ge[oe]);if(de==null||de===""||typeof de=="number"&&Number.isNaN(de))continue;const Ae=de instanceof Date?de.getTime():typeof de=="object"?String(de):de;Se.set(Ae,(Se.get(Ae)||0)+1),xe++}return{map:Se,total:xe}}function pt(se,ge,Se,Re){if(!(ge>0)||!(Re>0))return null;let xe=0;const oe=new Set(se.keys());for(const de of Se.keys())oe.add(de);for(const de of oe){const Ae=(se.get(de)||0)/ge,Ce=(Se.get(de)||0)/Re;xe+=Math.abs(Ae-Ce)}return xe/2}const Tt=10;function Nt(se,ge,Se){if(Se&&Se.numeric){const Ae=p(se,ge),{n:Ce,mean:De}=m(Ae),Ue=Ce>0?Et({mean:Se.mean,sd:Se.sd},De):null;return{measure:"standardizedMeanDifference",magnitude:Ue,distance:Ue===null?0:it(Ue),direction:Ue===null?0:Math.sign(Ue),subsetN:Ce,populationN:Se.n||0,reliable:Ce>=Tt}}const{map:xe,total:oe}=ft(se,ge),de=pt(xe,oe,Se.map,Se.total);return{measure:"categoricalTotalVariation",magnitude:de,distance:de===null?0:de,direction:0,subsetN:oe,populationN:Se.total||0,reliable:oe>=Tt}}function Lt(se,ge){if(se&&(se.kind==="float64"||se.kind==="int32"))return!0;const Se=V(se);let Re=0,xe=0;for(let oe=0;oe<ge.length&&Re<200;oe++){const de=Se(ge[oe]);if(de==null||de==="")continue;if(de instanceof Date)return!1;Re++;const Ae=typeof de=="number"?de:Number(de);Number.isFinite(Ae)&&xe++}return Re===0?!1:xe/Re>=.9}function Je(se,ge){if(Lt(se,ge)){const xe=p(se,ge),{n:oe,mean:de,m2:Ae}=m(xe);return{numeric:!0,mean:de,sd:oe>0?Math.sqrt(Ae/oe):0,n:oe}}const{map:Se,total:Re}=ft(se,ge);return{numeric:!1,map:Se,total:Re}}}),ze("packages/core/src/compute/total.js",function(e,B){"use strict";Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"TOTAL_LABELS",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"totalLabel",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"aggregatesFor",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"aggregateAllowed",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"collectValues",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return m}});const A=B("packages/core/src/internal/predicates.js").isFunction,U=B("packages/core/src/internal/warn.js").warnOnce,I=B("packages/core/src/compute/handle.js"),J=I.presenceReader,H=I.valueComparator,L=I.valueReader,Y=B("packages/core/src/compute/statistics.js"),_=Y.STAT_FNS,O=Y.STAT_LABELS;function v(w){return!!w&&(w.kind==="float64"||w.kind==="int32")}function b(w,S){const M=S.length;let X=0;if(v(w)){const K=w.values,P=J(w);if(!P){for(let k=0;k<M;k++){const E=K[S[k]];Number.isNaN(E)||(X+=E)}return X}for(let k=0;k<M;k++){const E=S[k];if(P(E)===1){const C=K[E];Number.isNaN(C)||(X+=C)}}return X}const q=L(w);for(let K=0;K<M;K++){const P=p(q(S[K]));P!==null&&(X+=P)}return X}b.kernel=!0;function c(w,S){const M=S.length;let X=0;if(v(w)){const K=w.values,P=J(w);if(!P){for(let k=0;k<M;k++)Number.isNaN(K[S[k]])||X++;return X}for(let k=0;k<M;k++){const E=S[k];P(E)===1&&!Number.isNaN(K[E])&&X++}return X}const q=L(w);for(let K=0;K<M;K++){const P=q(S[K]);P!=null&&!(typeof P=="number"&&Number.isNaN(P))&&X++}return X}c.kernel=!0;function g(w,S){return S.length}g.kernel=!0;function o(w,S){const M=c(w,S);return M===0?null:b(w,S)/M}o.kernel=!0;function t(w,S,M,X){const q=S.length;if(v(w)){const E=w.values,C=J(w);let x=null;if(!C){for(let j=0;j<q;j++){const T=E[S[j]];Number.isNaN(T)||(x===null||(M<0?T<x:T>x))&&(x=T)}return x}for(let j=0;j<q;j++){const T=S[j];if(C(T)===0)continue;const F=E[T];Number.isNaN(F)||(x===null||(M<0?F<x:F>x))&&(x=F)}return x}const K=L(w),P=H(X);let k=null;for(let E=0;E<q;E++){const C=K(S[E]);C==null||typeof C=="number"&&Number.isNaN(C)||(k===null||(M<0?P(C,k)<0:P(C,k)>0))&&(k=C)}return k}function s(w,S,M){return t(w,S,-1,M&&M.locale)}s.kernel=!0;function l(w,S,M){return t(w,S,1,M&&M.locale)}l.kernel=!0;function u(w,S){return S.length===0?null:L(w)(S[0])}u.kernel=!0;function n(w,S){return S.length===0?null:L(w)(S[S.length-1])}n.kernel=!0;function p(w){if(typeof w=="number")return Number.isNaN(w)?null:w;if(w==null||w===""||typeof w=="boolean")return null;if(w instanceof Date)return w.getTime();const S=Number(w);return Number.isNaN(S)?null:S}const r={sum:b,min:s,max:l,avg:o,count:g,first:u,last:n,countValues:c,..._},i=Object.freeze({...O,sum:"Sum",avg:"Average",min:"Min",max:"Max",count:"Count",countValues:"Count of values",first:"First",last:"Last"});function d(w){return w?typeof w=="string"?i[w]||w:"Total":""}const h=Object.freeze(["sum","avg","min","max","count","countValues","first","last"]);function a(w){const S=w&&w.dataType&&w.dataType.totals&&w.dataType.totals.supported;if(Array.isArray(S))return S.slice();const M=h.filter(X=>X in r);for(const X of Object.keys(r))M.includes(X)||M.push(X);return M}function y(w,S){return typeof S!="string"?!0:a(w).includes(S)}function f(w,S){const M=L(w),X=[];for(let q=0;q<S.length;q++){const K=M(S[q]);K!=null&&X.push(K)}return X}function m(w,S,M,X){const q=S||[];if(M&&typeof M=="object"&&typeof M.fn=="string"){const{fn:K,...P}=M,k=r[K];return k?k(w,q,{...X,...P}):(U(`total:${K}`,`unknown total function "${K}"; register it in config.totalFns`),null)}if(typeof M=="string"){const K=r[M];return K?K(w,q,X):(U(`total:${M}`,`unknown total function "${M}"; register it in config.totalFns`),null)}return A(M)?M.kernel===!0?M(w,q,X):M(f(w,q),X||{}):null}}),ze("packages/core/src/compute/windowed.js",function(e,B){"use strict";Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return J}});const A=B("packages/core/src/compute/sketch.js").Welford;class V{#e;#t;#n=[];#r;#s;constructor(L,Y=0,_=Date.now){if(L!=="count"&&L!=="time"&&L!=="session")throw new RangeError(`unknown window kind: ${L}`);if((L==="count"||L==="time")&&!(Y>0))throw new RangeError(`a ${L} window needs a positive span`);this.#e=L,this.#t=Math.floor(Y),this.#r=_,this.#s=_()}get size(){return this.#n.length}push(L,Y=this.#r()){Number.isFinite(L)&&(this.#n.push({t:Y,v:L}),this.#i(Y))}#i(L){if(this.#e==="count")for(;this.#n.length>this.#t;)this.#n.shift();else if(this.#e==="time"){const Y=L-this.#t;for(;this.#n.length&&this.#n[0].t<Y;)this.#n.shift()}}spec(){const L=this.#e==="session"?this.#r()-this.#s:this.#t;return{kind:this.#e,span:L,size:this.#n.length}}values(){return this.#n.map(L=>L.v)}aggregate(){const L=this.spec();if(!this.#n.length)return{over:L,count:0,sum:null,mean:null,min:null,max:null,variance:null,stddev:null};const Y=new A;let _=0,O=1/0,v=-1/0;for(const{v:b}of this.#n)_+=b,b<O&&(O=b),b>v&&(v=b),Y.add(b);return{over:L,count:this.#n.length,sum:_,mean:Y.mean(),min:O,max:v,variance:Y.variance(),stddev:Y.stddev()}}reduce(L){const Y=this.aggregate(),_={sum:Y.sum,avg:Y.mean,mean:Y.mean,min:Y.min,max:Y.max,count:Y.count,variance:Y.variance,stddev:Y.stddev};if(!(L in _))throw new RangeError(`unknown windowed aggregate: ${L}`);return{value:_[L],over:Y.over}}}const U=Object.freeze(["count","time","session"]);function I(H,L=Date.now){const Y=H.kind==="time"&&H.minutes!=null?H.minutes*6e4:H.span??0;return new V(H.kind,Y,L)}const J={Window:V,WINDOW_KINDS:U,openWindow:I}}),ze("packages/core/src/compute/rolling.js",function(e,B){"use strict";Object.defineProperty(e,"ROLLING_WINDOW_FIELDS",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"rollingWindow",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"cumulativeToDate",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"periodOverPeriod",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"QUANTILE_SPAN_CAP",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"rollingQuantile",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"seasonalDecompose",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"exponentialSmoothing",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return p}});const A=B("packages/core/src/compute/windowed.js").openWindow,U=B("packages/core/src/compute/sketch.js").KLL,I=Object.freeze({rollingSum:"sum",rollingAvg:"avg",rollingMin:"min",rollingMax:"max"});function J(r,i,d,h){if(r.kind==="count"){const a=Math.max(1,Math.floor(r.span||0));return{coverage:Math.min(1,i/a),partial:i<a}}if(r.kind==="time"){const a=r.minutes!=null?r.minutes*6e4:r.span||0;if(!(a>0))return{coverage:1,partial:!1};const y=d-h;return{coverage:Math.min(1,y/a),partial:y<a}}return{coverage:null,partial:!1}}function H(r,i){const d=A(i),h=new Map,a=r.length?r[0].at:0;for(let y=0;y<r.length;y++){const{key:f,at:m,value:w}=r[y];Number.isFinite(w)&&d.push(w,m);const S=d.aggregate(),M=J(i,S.count,m,a);f!=null&&h.set(String(f),{sum:S.sum,avg:S.mean,min:S.min,max:S.max,count:S.count,coverage:M.coverage,partial:M.partial})}return h}function L(r){const i=new Map;let d=0;for(const{key:h,value:a}of r)Number.isFinite(a)&&(d+=a),h!=null&&i.set(String(h),d);return i}function Y(r,i=1){const d=new Map,h=Math.max(1,Math.floor(i));for(let a=0;a<r.length;a++){const{key:y,value:f}=r[a];if(y==null)continue;const m=a>=h?r[a-h].value:null,w=Number.isFinite(f)?f:null,S=Number.isFinite(m)?m:null;d.set(String(y),w!==null&&S!==null?w-S:null)}return d}const _=4096;function O(r){let i=r>>>0;return()=>{i+=1831565813;let d=i;return d=Math.imul(d^d>>>15,d|1),d^=d+Math.imul(d^d>>>7,d|61),((d^d>>>14)>>>0)/4294967296}}function v(r,i){const d=r.length;if(d===1)return r[0];const h=(d-1)*i,a=Math.floor(h),y=Math.ceil(h);return a===y?r[a]:r[a]+(h-a)*(r[y]-r[a])}function b(r,i,d={}){const h=Math.min(1,Math.max(0,d.q==null?.5:d.q)),a=Math.max(1,Math.floor(d.cap==null?_:d.cap)),y=O(d.seed==null?2654435769:d.seed),f=new Map,m=r.length?r[0].at:0;if(i.kind==="session"){const S=new U(200,y);let M=0;for(const{key:X,value:q}of r)Number.isFinite(q)&&(S.add(q),M++),X!=null&&f.set(String(X),{value:M?S.quantile(h):null,approx:M>0,count:M,coverage:null,partial:!1});return f}const w=A(i);for(const{key:S,at:M,value:X}of r){Number.isFinite(X)&&w.push(X,M);const q=w.values(),K=q.length;let P=null,k=!1;if(K)if(K<=a)P=v([...q].sort((C,x)=>C-x),h);else{const C=new U(200,y);for(const x of q)C.add(x);P=C.quantile(h),k=!0}const E=J(i,K,M,m);S!=null&&f.set(String(S),{value:P,approx:k,count:K,coverage:E.coverage,partial:E.partial})}return f}function c(r,i){const d=r.length,h=new Array(d).fill(null),a=Math.floor(i/2),y=i%2===0;for(let f=0;f<d;f++){if(f-a<0||f+a>=d)continue;let m=0,w=!0;if(y)for(let S=-a;S<=a;S++){const M=r[f+S];if(!Number.isFinite(M)){w=!1;break}m+=S===-a||S===a?M*.5:M}else for(let S=-a;S<=a;S++){const M=r[f+S];if(!Number.isFinite(M)){w=!1;break}m+=M}w&&(h[f]=m/i)}return h}function g(r,i){const d=new Map,h=Math.floor(Number(i&&i.period));if(!(h>=2))return d;const a=i&&i.model==="multiplicative",y=r.length,f=r.map(k=>Number.isFinite(k.value)?k.value:null),m=c(f,h),w=new Array(y).fill(null);for(let k=0;k<y;k++){const E=m[k],C=f[k];E===null||C===null||(a?E!==0&&(w[k]=C/E):w[k]=C-E)}const S=new Array(h).fill(0),M=new Array(h).fill(0);for(let k=0;k<y;k++){if(w[k]===null)continue;const E=k%h;S[E]+=w[k],M[E]+=1}const X=a?1:0,q=S.map((k,E)=>M[E]?k/M[E]:X),K=q.reduce((k,E)=>k+E,0)/h,P=a?q.map(k=>K!==0?k/K:1):q.map(k=>k-K);for(let k=0;k<y;k++){const{key:E}=r[k];if(E==null)continue;const C=m[k],x=P[k%h],j=f[k];let T=null;C!==null&&j!==null&&(T=a?C*x!==0?j/(C*x):null:j-C-x),d.set(String(E),{trend:C,seasonal:j===null?null:x,residual:T,coverage:C===null?0:1,partial:C===null})}return d}function o(r,i,d,h=80){const a=(Math.sqrt(5)-1)/2;let y=i,f=d,m=f-a*(f-y),w=y+a*(f-y),S=r(m),M=r(w);for(let X=0;X<h;X++)S<M?(f=w,w=m,M=S,m=f-a*(f-y),S=r(m)):(y=m,m=w,S=M,w=y+a*(f-y),M=r(w));return(y+f)/2}const t=1e-4,s=1-1e-4;function l(r,i){const d=r.length,h=new Array(d).fill(null),a=new Array(d).fill(null);let y=null,f=0;for(let m=0;m<d;m++){const w=r[m];if(!Number.isFinite(w)){y!==null&&(a[m]=y,h[m]=y);continue}if(y===null){y=w,a[m]=w,h[m]=w;continue}a[m]=y,f+=(w-y)**2,y=i*w+(1-i)*y,h[m]=y}return{smoothed:h,fitted:a,sse:f}}function u(r,i,d){const h=r.length,a=new Array(h).fill(null),y=new Array(h).fill(null);let f=null,m=null,w=0;for(let S=0;S<h;S++){const M=r[S];if(!Number.isFinite(M)){f!==null&&(f+=m,a[S]=f);continue}if(f===null){f=M,a[S]=M;continue}if(m===null){m=M-f;const K=f+m;y[S]=K,w+=(M-K)**2;const P=f;f=i*M+(1-i)*(P+m),m=d*(f-P)+(1-d)*m,a[S]=f;continue}const X=f+m;y[S]=X,w+=(M-X)**2;const q=f;f=i*M+(1-i)*(q+m),m=d*(f-q)+(1-d)*m,a[S]=f}return{smoothed:a,fitted:y,sse:w}}function n(r,i={}){const d=new Map,h=i.method==="holt",a=r.map(X=>Number.isFinite(X.value)?X.value:null),y=a.filter(X=>X!==null).length,f=X=>Math.min(s,Math.max(t,X)),m=()=>{for(const{key:X}of r)X!=null&&d.set(String(X),{smoothed:null,fitted:null,alpha:null,beta:null,sse:null});return d};if(y<(h?2:1))return m();let w=Number.isFinite(i.alpha)?f(i.alpha):null,S=h&&Number.isFinite(i.beta)?f(i.beta):null;if(h){if(w===null||S===null){let X=w===null?.5:w,q=S===null?.5:S;for(let K=0;K<6;K++)w===null&&(X=o(P=>u(a,P,q).sse,t,s)),S===null&&(q=o(P=>u(a,X,P).sse,t,s));w=w===null?X:w,S=S===null?q:S}}else w===null&&(w=o(X=>l(a,X).sse,t,s));const M=h?u(a,w,S):l(a,w);for(let X=0;X<r.length;X++){const{key:q}=r[X];q!=null&&d.set(String(q),{smoothed:M.smoothed[X],fitted:M.fitted[X],alpha:w,beta:h?S:null,sse:M.sse})}return d}const p={ROLLING_WINDOW_FIELDS:I,QUANTILE_SPAN_CAP:_,rollingWindow:H,rollingQuantile:b,cumulativeToDate:L,periodOverPeriod:Y,seasonalDecompose:g,exponentialSmoothing:n}}),ze("packages/core/src/compute/cluster.js",function(e,B){"use strict";Object.defineProperty(e,"CLUSTER_ROW_CAP",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"DBSCAN_ROW_CAP",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"DEFAULT_K",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"DEFAULT_MIN_POINTS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"orderByCentre",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"kmeans",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"dbscan",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"autoK",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"standardise",{enumerable:!0,get:function(){return t}});const ne=1e5,A=2e4,V=3,U=5,I=100;function J(s){let l=s>>>0;return function(){l=l+1831565813|0;let n=Math.imul(l^l>>>15,1|l);return n=n+Math.imul(n^n>>>7,61|n)^n,((n^n>>>14)>>>0)/4294967296}}function H(s,l){let u=0;for(let n=0;n<s.length;n++){const p=s[n]-l[n];u+=p*p}return u}function L(s,l){return Math.sqrt(H(s,l))}function Y(s,l){let u=-1,n=1/0;for(let p=0;p<l.length;p++){const r=H(s,l[p]);r<n&&(n=r,u=p)}return u}function _(s,l,u){const n=J(u),p=s.length,r=[Array.from(s[Math.floor(n()*p)])],i=new Float64Array(p).fill(1/0);for(let d=1;d<l;d++){let h=0;for(let m=0;m<p;m++){const w=H(s[m],r[r.length-1]);w<i[m]&&(i[m]=w),h+=i[m]}const a=n()*(h||p);let y=0,f=p-1;for(let m=0;m<p;m++)if(y+=h?i[m]:1,y>=a){f=m;break}r.push(Array.from(s[f]))}return r}function O(s,l){for(let u=0;u<s.length;u++){const n=s[u]-l[u];if(n!==0)return n}return 0}function v(s,l,u,n){const p=l.map((i,d)=>({centre:i,i:d})).sort((i,d)=>O(i.centre,d.centre)),r=new Int32Array(l.length);for(let i=0;i<p.length;i++)r[p[i].i]=i;for(let i=0;i<s.length;i++)s[i]>=0&&(s[i]=r[s[i]]);return{assignments:s,centres:p.map(i=>i.centre),sizes:p.map(i=>u[i.i]),distances:n}}function b(s,l={}){const u=s.length,n=u?s[0].length:0,p=Math.floor(l.k||V);if(!(u>=p)||p<1||n<1)return null;let r=_(s,p,l.seed===void 0?1:l.seed);const i=new Int32Array(u);let d=!0;for(let f=0;f<I&&d;f++){d=!1;for(let S=0;S<u;S++){const M=Y(s[S],r);i[S]!==M&&(i[S]=M,d=!0)}const m=r.map(()=>new Float64Array(n)),w=new Array(p).fill(0);for(let S=0;S<u;S++){const M=i[S];for(let X=0;X<n;X++)m[M][X]+=s[S][X];w[M]++}for(let S=0;S<p;S++)if(w[S])for(let M=0;M<n;M++)r[S][M]=m[S][M]/w[S];else{let M=0,X=-1/0;for(let q=0;q<u;q++){const K=H(s[q],r[S]);K>X&&(X=K,M=q)}r[S]=Array.from(s[M]),d=!0}}const h=new Array(p).fill(0),a=new Float64Array(u);let y=0;for(let f=0;f<u;f++){const m=i[f];h[m]++;const w=H(s[f],r[m]);a[f]=Math.sqrt(w),y+=w}return{assignments:i,centres:r,sizes:h,inertia:y,distances:a}}function c(s,l={}){const u=s.length,n=u?s[0].length:0,p=Number(l.eps),r=Math.max(1,Math.floor(l.minPoints||U));if(!(p>0)||u===0||n<1)return null;const i=new Array(u);for(let w=0;w<u;w++){const S=[];for(let M=0;M<u;M++)w!==M&&L(s[w],s[M])<=p&&S.push(M);i[w]=S}const d=new Int32Array(u).fill(-1);let h=0;for(let w=0;w<u;w++){if(d[w]!==-1||i[w].length<r)continue;d[w]=h;const S=[...i[w]];for(let M=0;M<S.length;M++){const X=S[M];d[X]===-1&&(d[X]=h,i[X].length>=r&&S.push(...i[X]))}h++}if(!h)return{assignments:d,centres:[],sizes:[],distances:new Float64Array(u).fill(NaN)};const a=[],y=new Array(h).fill(0),f=Array.from({length:h},()=>new Float64Array(n));for(let w=0;w<u;w++){const S=d[w];if(!(S<0)){y[S]++;for(let M=0;M<n;M++)f[S][M]+=s[w][M]}}for(let w=0;w<h;w++){const S=new Array(n);for(let M=0;M<n;M++)S[M]=f[w][M]/y[w];a.push(S)}const m=new Float64Array(u).fill(NaN);for(let w=0;w<u;w++){const S=d[w];S>=0&&(m[w]=L(s[w],a[S]))}return{assignments:d,centres:a,sizes:y,distances:m}}function g(s,l,u){const n=s.length;if(n===0)return 0;const p=new Int32Array(u);for(let i=0;i<n;i++)p[l[i]]++;let r=0;for(let i=0;i<n;i++){const d=l[i],h=new Float64Array(u);for(let f=0;f<n;f++)i!==f&&(h[l[f]]+=L(s[i],s[f]));const a=p[d]>1?h[d]/(p[d]-1):0;let y=1/0;for(let f=0;f<u;f++){if(f===d||p[f]===0)continue;const m=h[f]/p[f];m<y&&(y=m)}y!==1/0&&(r+=(y-a)/Math.max(a,y))}return r/n}function o(s,l={}){const u=s.length;if(!u)return null;const n=l.criterion==="silhouette"?"silhouette":"elbow",p=Math.max(2,Math.floor(l.maxK||8)),r=l.seed===void 0?1:l.seed;if(n==="silhouette"){const w=[],S=[];for(let X=2;X<=Math.min(p,u);X++){const q=b(s,{k:X,seed:r});q&&(w.push(X),S.push(g(s,q.assignments,X)))}if(!w.length)return null;let M=0;for(let X=1;X<S.length;X++)S[X]>S[M]&&(M=X);return{k:w[M],criterion:n,scores:S,ks:w}}const i=[],d=[];for(let w=1;w<=Math.min(p,u);w++){const S=b(s,{k:w,seed:r});S&&(i.push(w),d.push(S.inertia))}if(d.length<2)return null;const h={k:i[0],y:d[0]},a={k:i[i.length-1],y:d[d.length-1]},y=Math.hypot(a.k-h.k,a.y-h.y)||1;let f=0,m=-1/0;for(let w=0;w<d.length;w++){const S=Math.abs((a.k-h.k)*(h.y-d[w])-(h.k-i[w])*(a.y-h.y))/y;S>m&&(m=S,f=w)}return{k:i[f],criterion:n,scores:d,ks:i}}function t(s){const l=s.length,u=l?s[0].length:0;if(!l||!u)return null;const n=new Array(u).fill(0);for(let r=0;r<l;r++)for(let i=0;i<u;i++)n[i]+=s[r][i];for(let r=0;r<u;r++)n[r]/=l;const p=new Array(u).fill(0);for(let r=0;r<l;r++)for(let i=0;i<u;i++){const d=s[r][i]-n[i];p[i]+=d*d}for(let r=0;r<u;r++)p[r]=l>1?Math.sqrt(p[r]/(l-1)):0;for(let r=0;r<l;r++)for(let i=0;i<u;i++)p[i]>0?s[r][i]=(s[r][i]-n[i])/p[i]:s[r][i]=s[r][i]-n[i];return{mean:n,sd:p}}}),ze("packages/core/src/compute/compare.js",function(e,B){"use strict";Object.defineProperty(e,"COMPARE_MEASURES",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"pooledStandardMeanDifference",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"numericSummary",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"bothNumeric",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"compareColumnAcross",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"compareDatasets",{enumerable:!0,get:function(){return c}});const ne=B("packages/core/src/compute/statistics.js"),A=ne.numbers,V=ne.moments,U=ne.frequencyMap,I=ne.categoricalDistance,J=ne.normalTotalVariation,H=ne.isNumericColumn,L=ne.SUBSET_RELIABILITY_FLOOR,Y=Object.freeze({numeric:"pooledStandardMeanDifference",categorical:"categoricalTotalVariation",common:"totalVariationDistance"});function _(g,o){if(!g||!o||!(g.n>0)||!(o.n>0)||!Number.isFinite(g.mean)||!Number.isFinite(o.mean))return null;const t=(g.n*g.sd*g.sd+o.n*o.sd*o.sd)/(g.n+o.n);return t>0?(g.mean-o.mean)/Math.sqrt(t):null}function O(g,o){const t=A(g,o),{n:s,mean:l,m2:u}=V(t),n=s>0?Math.sqrt(u/s):0;return{mean:l,sd:n,n:s}}function v(g,o,t,s){return H(g,o)&&H(t,s)}function b(g,o,t,s){if(v(g,o,t,s)){const p=O(g,o),r=O(t,s),i=_(p,r);return{measure:Y.numeric,magnitude:i,distance:i===null?0:J(i),direction:i===null?0:Math.sign(i),nA:p.n,nB:r.n,meanA:p.mean,meanB:r.mean,reliable:p.n>=L&&r.n>=L}}const l=U(g,o),u=U(t,s),n=I(l.map,l.total,u.map,u.total);return{measure:Y.categorical,magnitude:n,distance:n===null?0:n,direction:0,nA:l.total,nB:u.total,meanA:null,meanB:null,reliable:l.total>=L&&u.total>=L}}function c(g,o,t={}){const s=new Set(g.columns),l=new Set(o.columns),u=g.columns.filter(d=>l.has(d)),n=Array.isArray(t.columns)&&t.columns.length?u.filter(d=>t.columns.includes(d)):u,p=g.indices(),r=o.indices(),i=[];for(const d of n){const h=g.handle(d),a=o.handle(d);if(!h||!a)continue;const y=b(h,p,a,r);i.push({column:d,name:g.name&&g.name(d)||o.name&&o.name(d)||d,measure:y.measure,magnitude:y.magnitude,distance:y.distance,direction:y.direction,nA:y.nA,nB:y.nB,meanA:y.meanA,meanB:y.meanB,reliable:y.reliable})}return i.sort((d,h)=>h.distance-d.distance||Math.abs(h.magnitude||0)-Math.abs(d.magnitude||0)),{ranked:i,nA:p.length,nB:r.length,unmatched:{onlyA:g.columns.filter(d=>!l.has(d)),onlyB:o.columns.filter(d=>!s.has(d))},measures:Y}}}),ze("packages/core/src/compute/anomaly.js",function(e,B){"use strict";Object.defineProperty(e,"MAD_SCALE",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"DEFAULT_MODIFIED_Z_THRESHOLD",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"DEFAULT_IQR_K",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"DEFAULT_CHI_SQUARE_P",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"ANOMALY_METHODS",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"robustSpread",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"modifiedZScores",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"iqrFences",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"chiSquareCdf",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"chiSquareQuantile",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"mahalanobis",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"DEFAULT_ROLLING_WINDOW",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"rollingAnomalies",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"anomalyCondition",{enumerable:!0,get:function(){return p}});const A=B("packages/core/src/compute/statistics.js").quantileSorted,U=B("packages/core/src/compute/special.js").logGamma,I=.6745,J=3.5,H=1.5,L=.975,Y=Object.freeze(["modifiedZScore","iqr","mahalanobis"]);function _(r){if(!r.length)return null;const d=Array.from(r,Number).sort((f,m)=>f-m),h=A(d,.5),a=d.map(f=>Math.abs(f-h)).sort((f,m)=>f-m),y=A(a,.5);return{median:h,mad:y}}function O(r,i={}){const d=Number.isFinite(i.threshold)?i.threshold:J,h=r.length,a=new Array(h).fill(null),y=new Array(h).fill(!1),f=[];for(let S=0;S<h;S++){const M=Number(r[S]);Number.isFinite(M)&&f.push(M)}if(!f.length)return{median:null,mad:null,threshold:d,scores:a,flags:y,flagged:0};const m=_(f);if(m.mad===0)return{median:m.median,mad:0,threshold:d,scores:a,flags:y,flagged:0};let w=0;for(let S=0;S<h;S++){const M=Number(r[S]);if(!Number.isFinite(M))continue;const X=I*(M-m.median)/m.mad;a[S]=X,Math.abs(X)>d&&(y[S]=!0,w++)}return{median:m.median,mad:m.mad,threshold:d,scores:a,flags:y,flagged:w}}function v(r,i={}){const d=Number.isFinite(i.k)?i.k:H,h=[];for(let w=0;w<r.length;w++){const S=Number(r[w]);Number.isFinite(S)&&h.push(S)}if(!h.length)return null;const a=h.sort((w,S)=>w-S),y=A(a,.25),f=A(a,.75),m=f-y;return{q1:y,q3:f,iqr:m,lower:y-d*m,upper:f+d*m,k:d}}function b(r,i){if(i<=0)return 0;const d=U(r);if(i<r+1){let S=r,M=1/r,X=M;for(let q=0;q<1e3&&(S+=1,X*=i/S,M+=X,!(Math.abs(X)<Math.abs(M)*1e-15));q++);return M*Math.exp(-i+r*Math.log(i)-d)}const h=1e-300;let a=i+1-r,y=1/h,f=1/a,m=f;for(let S=1;S<1e3;S++){const M=-S*(S-r);a+=2,f=M*f+a,Math.abs(f)<h&&(f=h),y=a+M/y,Math.abs(y)<h&&(y=h),f=1/f;const X=f*y;if(m*=X,Math.abs(X-1)<1e-15)break}return 1-Math.exp(-i+r*Math.log(i)-d)*m}function c(r,i){return r<=0?0:b(i/2,r/2)}function g(r,i=L){if(!(i>0)||!(i<1))return NaN;let d=0,h=Math.max(1,r);for(;c(h,r)<i;)h*=2;for(let a=0;a<200;a++){const y=(d+h)/2;if(c(y,r)<i?d=y:h=y,h-d<1e-10)break}return(d+h)/2}function o(r){const i=r.length,d=r.map((h,a)=>{const y=h.slice();for(let f=0;f<i;f++)y.push(a===f?1:0);return y});for(let h=0;h<i;h++){let a=h;for(let f=h+1;f<i;f++)Math.abs(d[f][h])>Math.abs(d[a][h])&&(a=f);if(Math.abs(d[a][h])<1e-12)return null;if(a!==h){const f=d[a];d[a]=d[h],d[h]=f}const y=d[h][h];for(let f=0;f<2*i;f++)d[h][f]/=y;for(let f=0;f<i;f++){if(f===h)continue;const m=d[f][h];if(m!==0)for(let w=0;w<2*i;w++)d[f][w]-=m*d[h][w]}}return d.map(h=>h.slice(i))}function t(r,i){const d=r.length,h=new Array(i).fill(0);for(const f of r)for(let m=0;m<i;m++)h[m]+=f[m];for(let f=0;f<i;f++)h[f]/=d;const a=Array.from({length:i},()=>new Array(i).fill(0));for(const f of r)for(let m=0;m<i;m++){const w=f[m]-h[m];for(let S=m;S<i;S++)a[m][S]+=w*(f[S]-h[S])}const y=d>1?d-1:1;for(let f=0;f<i;f++)for(let m=f;m<i;m++)a[f][m]/=y,a[m][f]=a[f][m];return{mean:h,cov:a}}function s(r,i={}){const d=Number.isFinite(i.p)?i.p:L,h=Number.isFinite(i.ridge)?i.ridge:1e-6,a=r.length;if(!a)return null;const y=r[0].length;if(!y)return null;const f=new Array(a).fill(null),m=new Array(a).fill(null),w=new Array(a).fill(!1),S=[],M=[];for(let x=0;x<a;x++){const j=r[x];let T=j.length===y;const F=new Array(y);for(let $=0;T&&$<y;$++){const D=Number(j[$]);Number.isFinite(D)?F[$]=D:T=!1}T&&(S.push(x),M.push(F))}const X=y,q=g(X,d);if(M.length<=y)return{center:[],df:X,cutoff:q,singular:!0,used:M.length,distances:f,squared:m,flags:w,flagged:0};const{mean:K,cov:P}=t(M,y);let k=o(P),E=!1;if(!k){E=!0;let x=0;for(let F=0;F<y;F++)x+=P[F][F];const j=x/y*h||h,T=P.map((F,$)=>F.map((D,z)=>$===z?D+j:D));if(k=o(T),!k)return{center:K,df:X,cutoff:q,singular:!0,used:M.length,distances:f,squared:m,flags:w,flagged:0}}let C=0;for(let x=0;x<M.length;x++){const j=M[x],T=new Array(y);for(let D=0;D<y;D++)T[D]=j[D]-K[D];let F=0;for(let D=0;D<y;D++){let z=0;for(let G=0;G<y;G++)z+=k[D][G]*T[G];F+=T[D]*z}F<0&&(F=0);const $=S[x];m[$]=F,f[$]=Math.sqrt(F),F>q&&(w[$]=!0,C++)}return{center:K,df:X,cutoff:q,singular:E,used:M.length,distances:f,squared:m,flags:w,flagged:C}}const l=20,u=Object.freeze(["rollingModifiedZScore","rollingIqr"]);function n(r,i={}){const d=i.method==="rollingIqr"?"rollingIqr":"rollingModifiedZScore",h=Number.isFinite(i.windowLen)&&i.windowLen>=1?Math.floor(i.windowLen):l,a=Number.isFinite(i.threshold)?i.threshold:J,y=Number.isFinite(i.k)?i.k:H,f=Number.isFinite(i.minPeriods)&&i.minPeriods>=1?Math.floor(i.minPeriods):h,m=r.length,w=new Array(m).fill(null),S=new Array(m).fill(!1);let M=0;for(let X=0;X<m;X++){const q=Number(r[X]);if(!Number.isFinite(q))continue;const K=Math.max(0,X-h+1),P=[];for(let k=K;k<=X;k++){const E=Number(r[k]);Number.isFinite(E)&&P.push(E)}if(!(P.length<f))if(d==="rollingIqr"){const k=v(P,{k:y});if(!k)continue;(q<k.lower||q>k.upper)&&(S[X]=!0,M++)}else{const k=_(P);if(!k||k.mad===0)continue;const E=I*(q-k.median)/k.mad;w[X]=E,Math.abs(E)>a&&(S[X]=!0,M++)}}return{method:d,windowLen:h,minPeriods:f,threshold:a,k:y,scores:w,flags:S,flagged:M}}function p(r={}){const i=r||{},d=i.field;if(typeof d!="string"||!d)throw new TypeError("[lattice] anomalyCondition: a string `field` naming the numeric property to monitor is required");const h=i.method||"modifiedZScore";if(!(Y.includes(h)||u.includes(h))||h==="mahalanobis")throw new RangeError(`[lattice] anomalyCondition: unknown or unsupported method '${h}'`);const y=typeof i.orderBy=="string"?i.orderBy:null,f=i.latest===!0,m=u.includes(h),w=S=>Number(S==null?NaN:S[d]);return S=>{const M=Array.isArray(S)?S.slice():[...S];y&&M.sort((k,E)=>{const C=k?.[y],x=E?.[y];return C===x?0:C==null?-1:x==null?1:C<x?-1:1});const X=M.map(w);let q,K;if(m)({flags:q,scores:K}=n(X,{method:h,windowLen:i.windowLen,threshold:i.threshold,k:i.k,minPeriods:i.minPeriods}));else if(h==="iqr"){const k=v(X,{k:i.k});q=X.map(E=>k?Number.isFinite(E)&&(E<k.lower||E>k.upper):!1),K=X.map(()=>null)}else({flags:q,scores:K}=O(X,{threshold:i.threshold}));if(f){const k=q.length-1;return k<0||!q[k]?!1:{method:h,field:d,flagged:[{row:M[k],score:K[k]}]}}const P=[];for(let k=0;k<q.length;k++)q[k]&&P.push({row:M[k],score:K[k]});return P.length?{method:h,field:d,flagged:P}:!1}}}),ze("packages/core/src/compute/forecast.js",function(e,B){"use strict";Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return r}});const ne=B("packages/core/src/compute/special.js"),A=ne.normalQuantile,V=ne.studentTQuantile,I=B("packages/core/src/internal/warn.js").warnOnce,J=Object.freeze(["movingAverage","ses","holt","holtWinters","linear"]),H=1e-4,L=1-1e-4;function Y(i){const d=[];for(let h=0;h<i.length;h++){const a=i[h];if(a!==null&&typeof a=="object"){const y=Number.isFinite(a.at)?a.at:h,f=Number.isFinite(a.value)?a.value:null;d.push({at:y,value:f})}else d.push({at:h,value:Number.isFinite(a)?Number(a):null})}return d}function _(i){const d=i.filter(m=>m.value!==null),h=d[0],a=d[d.length-1],y=a.at-h.at,f=d.length>1&&y>0?y/(d.length-1):1;return{lastAt:a.at,step:f}}function O(i){return Math.min(L,Math.max(H,i))}function v(i,d=H,h=L,a=80){const y=(Math.sqrt(5)-1)/2;let f=d,m=h,w=m-y*(m-f),S=f+y*(m-f),M=i(w),X=i(S);for(let q=0;q<a;q++)M<X?(m=S,S=w,X=M,w=m-y*(m-f),M=i(w)):(f=w,w=S,M=X,S=f+y*(m-f),X=i(S));return(f+m)/2}function b(i,d){let h=null,a=0,y=0;for(let f=0;f<i.length;f++){const m=i[f];if(m!==null){if(h===null){h=m;continue}a+=(m-h)**2,y+=1,h=d*m+(1-d)*h}}return{level:h,sse:a,m:y}}function c(i,d,h){let a=null,y=null,f=0,m=0;for(let w=0;w<i.length;w++){const S=i[w];if(S===null){a!==null&&y!==null&&(a+=y);continue}if(a===null){a=S;continue}y===null&&(y=S-a);const M=a+y;f+=(S-M)**2,m+=1;const X=a;a=d*S+(1-d)*(X+y),y=h*(a-X)+(1-h)*y}return{level:a,trend:y,sse:f,m}}function g(i,d,h,a,y){const f=i.length;if(f<2*d)return null;const m=E=>{let C=0,x=0;for(let j=E;j<E+d&&j<f;j++)i[j]!==null&&(C+=i[j],x+=1);return x?C/x:null},w=m(0),S=m(d);if(w===null||S===null)return null;let M=w,X=(S-w)/d;const q=new Array(d).fill(0);for(let E=0;E<d;E++)q[E]=i[E]===null?0:i[E]-M;const K=q.reduce((E,C)=>E+C,0)/d;for(let E=0;E<d;E++)q[E]-=K;let P=0,k=0;for(let E=d;E<f;E++){const C=E%d,x=q[C],j=i[E];if(j===null){M+=X;continue}const T=M+X+x;P+=(j-T)**2,k+=1;const F=M;M=h*(j-x)+(1-h)*(M+X),X=a*(M-F)+(1-a)*X,q[C]=y*(j-M)+(1-y)*x}return{level:M,trend:X,season:q,phase:(f-1)%d,sse:P,count:k}}function o(i,d,h){let a=1;for(const f of d)a+=f*f;const y=Math.sqrt(i*a);return{se:y,margin:h*y}}function t(i,d={}){if(!i||typeof i.length!="number"||i.length===0)return null;const h=J.includes(d.method)?d.method:"linear",a=Math.max(1,Math.floor(Number(d.horizon)||1)),y=Number.isFinite(d.confidence)&&d.confidence>0&&d.confidence<1?d.confidence:.95,f=1-(1-y)/2,m=Y(i),w=m.map(P=>P.value),S=w.filter(P=>P!==null),M=S.length,{lastAt:X,step:q}=M?_(m):{lastAt:0,step:1},K=P=>X+P*q;return h==="linear"?s(m,M,a,y,f,K):h==="movingAverage"?l(S,M,a,y,f,d,K):h==="ses"?u(w,M,a,y,f,d,K):h==="holt"?n(w,M,a,y,f,d,K):p(w,M,a,y,f,d,K)}function s(i,d,h,a,y,f){if(d<2)return null;let m=0,w=0;for(const j of i)j.value!==null&&(m+=j.at,w+=j.value);m/=d,w/=d;let S=0,M=0,X=0;for(const j of i){if(j.value===null)continue;const T=j.at-m,F=j.value-w;S+=T*T,M+=T*F,X+=F*F}if(S===0)return null;const q=M/S,K=w-q*m,P=X===0?1:Math.max(0,Math.min(1,M*M/(S*X))),k=Math.max(0,X-q*M),E=d>2?Math.sqrt(k/(d-2)):null,C=d>2?V(y,d-2):null,x=[];for(let j=1;j<=h;j++){const T=f(j),F=K+q*T;let $=null,D=null,z=null,G=null,N=null;if(E!==null){const Z=1/d+(T-m)**2/S,Q=E*Math.sqrt(1+Z),ee=E*Math.sqrt(Z);N=Q,$=F-C*Q,D=F+C*Q,z=F-C*ee,G=F+C*ee}x.push({step:j,at:T,mean:F,lower:$,upper:D,lowerMean:z,upperMean:G,se:N})}return{method:"linear",horizon:h,confidence:a,n:d,sigma:E,r2:P,params:{slope:q,intercept:K},points:x}}function l(i,d,h,a,y,f,m){if(d<1)return null;const w=Math.max(1,Math.min(d,Math.floor(Number(f.windowLen)||d))),S=i.slice(d-w);let M=0;for(const E of S)M+=E;const X=M/w;let q=null,K=null;if(w>1){let E=0;for(const x of S)E+=(x-X)**2;q=Math.sqrt(E/(w-1))*Math.sqrt(1+1/w),K=V(y,w-1)}const P=q===null?null:K*q,k=[];for(let E=1;E<=h;E++)k.push({step:E,at:m(E),mean:X,lower:P===null?null:X-P,upper:P===null?null:X+P,se:q});return{method:"movingAverage",horizon:h,confidence:a,n:d,sigma:q===null?null:q,params:{windowLen:w},points:k}}function u(i,d,h,a,y,f,m){if(d<1)return null;let w=Number.isFinite(f.alpha)?O(f.alpha):null;w===null&&(w=v(K=>b(i,K).sse));const S=b(i,w),M=A(y),X=S.m>0?S.sse/S.m:null,q=[];for(let K=1;K<=h;K++){const P=S.level;let k=null,E=null,C=null;if(X!==null){const x=[];for(let T=1;T<K;T++)x.push(w);const j=o(X,x,M);C=j.se,k=P-j.margin,E=P+j.margin}q.push({step:K,at:m(K),mean:P,lower:k,upper:E,se:C})}return{method:"ses",horizon:h,confidence:a,n:d,sigma:X===null?null:Math.sqrt(X),params:{alpha:w},points:q}}function n(i,d,h,a,y,f,m){if(d<2)return null;let w=Number.isFinite(f.alpha)?O(f.alpha):null,S=Number.isFinite(f.beta)?O(f.beta):null;if(w===null||S===null){let k=w===null?.5:w,E=S===null?.5:S;for(let C=0;C<6;C++)w===null&&(k=v(x=>c(i,x,E).sse)),S===null&&(E=v(x=>c(i,k,x).sse));w=w===null?k:w,S=S===null?E:S}const M=c(i,w,S),X=A(y),q=M.m>0?M.sse/M.m:null,K=w*S,P=[];for(let k=1;k<=h;k++){const E=M.level+k*M.trend;let C=null,x=null,j=null;if(q!==null){const T=[];for(let $=1;$<k;$++)T.push(w+$*K);const F=o(q,T,X);j=F.se,C=E-F.margin,x=E+F.margin}P.push({step:k,at:m(k),mean:E,lower:C,upper:x,se:j})}return{method:"holt",horizon:h,confidence:a,n:d,sigma:q===null?null:Math.sqrt(q),params:{alpha:w,beta:S},points:P}}function p(i,d,h,a,y,f,m){const w=Math.floor(Number(f.period));if(!(w>=2))return I("forecast.holtWinters.period","forecast: holtWinters needs a period (opts.period >= 2)"),null;if(d<2*w)return null;let S=Number.isFinite(f.alpha)?O(f.alpha):null,M=Number.isFinite(f.beta)?O(f.beta):null,X=Number.isFinite(f.gamma)?O(f.gamma):null;const q=(j,T,F)=>{const $=g(i,w,j,T,F);return $?$.sse:1/0};if(S===null||M===null||X===null){let j=S===null?.5:S,T=M===null?.5:M,F=X===null?.5:X;for(let $=0;$<8;$++)S===null&&(j=v(D=>q(D,T,F))),M===null&&(T=v(D=>q(j,D,F))),X===null&&(F=v(D=>q(j,T,D)));S=S===null?j:S,M=M===null?T:M,X=X===null?F:X}const K=g(i,w,S,M,X);if(!K)return null;const P=A(y),k=K.count>0?K.sse/K.count:null,E=S*M,C=X*(1-S),x=[];for(let j=1;j<=h;j++){const T=K.season[(K.phase+j)%w],F=K.level+j*K.trend+T;let $=null,D=null,z=null;if(k!==null){const G=[];for(let Z=1;Z<j;Z++)G.push(S+Z*E+(Z%w===0?C:0));const N=o(k,G,P);z=N.se,$=F-N.margin,D=F+N.margin}x.push({step:j,at:m(j),mean:F,lower:$,upper:D,se:z})}return{method:"holtWinters",horizon:h,confidence:a,n:d,sigma:k===null?null:Math.sqrt(k),params:{alpha:S,beta:M,gamma:X,period:w},points:x}}const r={FORECAST_METHODS:J,forecast:t}}),ze("packages/core/src/compute/hypothesis.js",function(e,B){"use strict";Object.defineProperty(e,"GROUP_TESTS",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"NORMALITY_ALPHA",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"HL_PAIR_LIMIT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"welchTTest",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"mannWhitneyUTest",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"chiSquareTest",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"compareGroups",{enumerable:!0,get:function(){return P}});const A=B("packages/core/src/internal/warn.js").warnOnce,U=B("packages/core/src/compute/handle.js").valueReader,I=B("packages/core/src/compute/statistics.js"),J=I.numbers,H=I.moments,L=I.frequencyMap,Y=I.categoricalDistance,_=I.isNumericColumn,O=I.jarqueBera,v=I.proportionInterval,b=I.SUBSET_RELIABILITY_FLOOR,g=B("packages/core/src/compute/compare.js").pooledStandardMeanDifference,o=B("packages/core/src/compute/special.js"),t=o.studentT,s=o.studentTQuantile,l=o.normalCdf,u=o.normalQuantile,n=o.chiSquareUpperTail,p=Object.freeze({WELCH:"welch",MANN_WHITNEY:"mannWhitney",CHI_SQUARE:"chiSquare"}),r=.05,i=2e6;function d(k){const E=Number(k);return Number.isFinite(E)&&E>0&&E<1?E:.95}function h(k){const{n:E,mean:C,m2:x}=H(k);return{mean:C,sd:E>0?Math.sqrt(x/E):0,n:E}}function a(k,E){const C=k.length;if(C<2)return 0;let x=0;for(let j=0;j<C;j++){const T=k[j]-E;x+=T*T}return x/(C-1)}function y(k,E){return{name:"pooledStandardMeanDifference",value:g(h(k),h(E))}}function f(k,E,C){const x=k.length,j=E.length;if(x<2||j<2)return null;const T=d(C),{mean:F}=H(k),{mean:$}=H(E),D=a(k,F),z=a(E,$),G=D/x+z/j;if(!(G>0))return null;const N=Math.sqrt(G),Z=(F-$)/N,Q=D/x*(D/x)/(x-1),ee=z/j*(z/j)/(j-1),re=G*G/(Q+ee),ie=Math.min(1,Math.max(0,2*(1-t(Math.abs(Z),re)))),ce=F-$,ve=s(1-(1-T)/2,re)*N;return{test:p.WELCH,statistic:Z,statisticName:"t",df:re,pValue:ie,interval:{estimate:ce,lower:ce-ve,upper:ce+ve,confidence:T,method:"welch-t (difference of means)"},effectSize:y(k,E),nA:x,nB:j,reliable:x>=b&&j>=b,method:"Welch's t-test (unequal variances; Welch–Satterthwaite df)"}}function m(k){const E=k.length;if(E===0)return Number.NaN;const C=E>>1;return E%2?k[C]:(k[C-1]+k[C])/2}function w(k,E,C){const x=k.length,j=E.length,T=x*j;if(T===0||T>i)return null;const F=new Float64Array(T);let $=0;for(let Q=0;Q<x;Q++)for(let ee=0;ee<j;ee++)F[$++]=k[Q]-E[ee];F.sort();const D=m(F),z=Math.sqrt(x*j*(x+j+1)/12),G=u(1-(1-C)/2);let N=Math.round(T/2-G*z);N>=0||(N=0);const Z=Math.floor((T-1)/2);return N>Z&&(N=Z),{estimate:D,lower:F[N],upper:F[T-1-N],confidence:C,method:"hodges-lehmann (normal approximation)"}}function S(k,E,C){const x=k.length,j=E.length;if(x<1||j<1)return null;const T=d(C),F=x+j,$=new Array(F);for(let ie=0;ie<x;ie++)$[ie]={v:k[ie],g:0};for(let ie=0;ie<j;ie++)$[x+ie]={v:E[ie],g:1};$.sort((ie,ce)=>ie.v-ce.v);let D=0,z=0,G=0;for(;G<F;){let ie=G;for(;ie<F&&$[ie].v===$[G].v;)ie++;const ce=ie-G,ve=(G+1+ie)/2;for(let he=G;he<ie;he++)$[he].g===0&&(D+=ve);z+=ce*ce*ce-ce,G=ie}const N=D-x*(x+1)/2,Z=x*j/2,Q=x*j/12*(F+1-z/(F*(F-1)));let ee=1;if(Q>0){const ie=Math.max(0,Math.abs(N-Z)-.5);ee=Math.min(1,2*l(-ie/Math.sqrt(Q)))}const re=w(k,E,T);return{test:p.MANN_WHITNEY,statistic:N,statisticName:"U",df:null,pValue:ee,interval:re,effectSize:y(k,E),nA:x,nB:j,reliable:x>=b&&j>=b,method:"Mann-Whitney U (normal approximation, tie- and continuity-corrected)"}}function M(k,E,C,x,j){const T=v(k,E,j),F=v(C,x,j);if(!T||!F)return null;const $=T.proportion-F.proportion,D=$-Math.sqrt((T.proportion-T.lower)**2+(F.upper-F.proportion)**2),z=$+Math.sqrt((T.upper-T.proportion)**2+(F.proportion-F.lower)**2);return{lower:D,upper:z}}function X(k,E,C,x,j,T={}){if(!(E>0)||!(x>0))return null;const F=new Set([...k.keys(),...C.keys()]),$=F.size;if($<2)return null;const D=E+x;let z=0;for(const ee of F){const re=k.get(ee)||0,ie=C.get(ee)||0,ce=re+ie,ve=E*ce/D,he=x*ce/D;ve>0&&(z+=(re-ve)*(re-ve)/ve),he>0&&(z+=(ie-he)*(ie-he)/he)}const G=$-1,N=n(z,G);let Z=null;T.category!==void 0&&F.has(T.category)?Z=T.category:$===2&&([Z]=[...F]);let Q=null;if(Z!==null){const ee=M(k.get(Z)||0,E,C.get(Z)||0,x,d(j));ee&&(Q={estimate:(k.get(Z)||0)/E-(C.get(Z)||0)/x,lower:ee.lower,upper:ee.upper,confidence:d(j),method:"newcombe (difference in this category's share)",category:Z})}return{test:p.CHI_SQUARE,statistic:z,statisticName:"chiSquare",df:G,pValue:N,interval:Q,effectSize:{name:"categoricalTotalVariation",value:Y(k,E,C,x)},nA:E,nB:x,reliable:E>=b&&x>=b,method:"Pearson chi-square test of independence (2×k, no continuity correction)"}}function q(k){return k==null||k===""||typeof k=="number"&&Number.isNaN(k)?null:k instanceof Date?k.getTime():typeof k=="object"?String(k):k}function K(k,E,C){if(C===p.WELCH||C===p.MANN_WHITNEY)return{test:C,chosenBy:"override",reason:`caller override: ${C}`};const x=O(k),j=O(E),T=x===null?null:Math.exp(-x/2),F=j===null?null:Math.exp(-j/2);return T!==null&&T<r||F!==null&&F<r?{test:p.MANN_WHITNEY,chosenBy:"auto",reason:`column family: numeric, non-normal by Jarque-Bera (p < ${r})`}:{test:p.WELCH,chosenBy:"auto",reason:T!==null||F!==null?"column family: numeric, no departure from normality detected":"column family: numeric (too few rows to screen normality)"}}function P(k,E,C,x={}){if(!k||!E)return null;const j=d(x.confidence),T=U(E);let F;if(Array.isArray(x.groups)&&x.groups.length===2)F=[q(x.groups[0]),q(x.groups[1])];else{const{map:ie}=L(E,C),ce=[...ie.entries()].sort((ve,he)=>he[1]-ve[1]).slice(0,2).map(ve=>ve[0]);if(ce.length<2)return A("compareGroups:groups",'[lattice] compareGroups: the "by" column has fewer than two distinct values to group by.'),null;F=ce}const[$,D]=F;if($===null||D===null||$===D)return A("compareGroups:distinct","[lattice] compareGroups: the two groups must be two distinct, present values."),null;const z=[],G=[];for(let ie=0;ie<C.length;ie++){const ce=q(T(C[ie]));ce===$?z.push(C[ie]):ce===D&&G.push(C[ie])}if(z.length===0||G.length===0)return A("compareGroups:empty","[lattice] compareGroups: one of the two groups has no rows in the current set."),null;const N=x.test&&x.test!=="auto"?String(x.test):null,Z=_(k,z.concat(G));let Q,ee,re;if(N===p.CHI_SQUARE||!N&&!Z){ee=N?"override":"auto",re=N?"caller override: chiSquare":"column family: categorical";const ie=L(k,z),ce=L(k,G);Q=X(ie.map,ie.total,ce.map,ce.total,j,{category:x.category})}else{if((N===p.WELCH||N===p.MANN_WHITNEY)&&!Z)return A("compareGroups:numeric-override",`[lattice] compareGroups: ${N} needs a numeric column, but the column is not numeric.`),null;const ie=J(k,z),ce=J(k,G),ve=K(ie,ce,N);ee=ve.chosenBy,re=ve.reason,Q=ve.test===p.MANN_WHITNEY?S(ie,ce,j):f(ie,ce,j)}return Q?{...Q,chosenBy:ee,reason:re,groups:[$,D]}:(A("compareGroups:degenerate","[lattice] compareGroups: the chosen test had too little to work with (too few values, or no variation)."),null)}}),ze("packages/core/src/compute/significance.js",function(e,B){"use strict";Object.defineProperty(e,"COMPARE_TESTS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"compare",{enumerable:!0,get:function(){return ye}});const A=B("packages/core/src/internal/warn.js").warnOnce,U=B("packages/core/src/compute/handle.js").valueReader,I=B("packages/core/src/compute/statistics.js"),J=I.numbers,H=I.moments,L=I.frequencyMap,Y=I.isNumericColumn,_=I.jarqueBera,O=I.proportionInterval,v=B("packages/core/src/compute/special.js"),b=v.studentT,c=v.studentTQuantile,g=v.normalCdf,o=v.normalQuantile,t=v.chiSquareUpperTail,s=v.incompleteBeta,l=Object.freeze({T:"t",WELCH:"welch",MANN_WHITNEY:"mannWhitney",ANOVA:"anova",KRUSKAL:"kruskal",CHI_SQUARE:"chiSquare",PROPORTIONS:"proportions"}),u=new Set([l.T,l.WELCH,l.MANN_WHITNEY]),n=new Set([l.ANOVA,l.KRUSKAL]),p=new Set([l.CHI_SQUARE,l.PROPORTIONS]),r=.05,i=[.2,.5,.8],d=[.147,.33,.474],h=[.01,.06,.14],a=[[.1,.3,.5],[.07,.21,.35],[.06,.17,.29],[.05,.15,.25]];function y(fe){const ae=Number(fe);return Number.isFinite(ae)&&ae>0&&ae<1?ae:.05}function f(fe){return fe==null||fe===""||typeof fe=="number"&&Number.isNaN(fe)?null:fe instanceof Date?fe.getTime():typeof fe=="object"?String(fe):fe}function m(fe,ae){const ke=U(fe),pe=[],ue=new Map;for(let we=0;we<ae.length;we++){const Te=f(ke(ae[we]));if(Te===null)continue;let Ne=ue.get(Te);Ne||(Ne={value:Te,rows:[]},ue.set(Te,Ne),pe.push(Ne)),Ne.rows.push(ae[we])}return pe}function w(fe){const{n:ae,mean:ke,m2:pe}=H(fe),ue=ae>1?pe/(ae-1):0;return{n:ae,mean:ke,sd:Math.sqrt(ue),variance:ue}}function S(fe,ae,ke){if(!(ae>0)||!(ke>0)||!(fe>=0)||!Number.isFinite(fe))return Number.NaN;if(fe===0)return 1;const pe=ae*fe/(ae*fe+ke);return 1-s(ae/2,ke/2,pe)}function M(fe,ae){const ke=Math.abs(fe);return Number.isFinite(ke)?ke>=ae[2]?"large":ke>=ae[1]?"medium":ke>=ae[0]?"small":"negligible":"negligible"}function X(fe,ae,ke){if(fe==="cohensD")return M(ae,i);if(fe==="cliffsDelta")return M(ae,d);if(fe==="etaSquared")return M(ae,h);const pe=Math.max(1,Math.min(a.length,Math.floor(ke||1)));return M(ae,a[pe-1])}function q(fe,ae){if(!(fe.n>1)||!(ae.n>1))return null;const ke=((fe.n-1)*fe.variance+(ae.n-1)*ae.variance)/(fe.n+ae.n-2);return ke>0?(fe.mean-ae.mean)/Math.sqrt(ke):null}function K(fe,ae){const ke=fe.length,pe=ae.length;if(!ke||!pe)return null;const ue=Array.from(ae).sort((Ne,_e)=>Ne-_e);let we=0,Te=0;for(let Ne=0;Ne<ke;Ne++){const _e=fe[Ne];let $e=0,je=pe;for(;$e<je;){const Ee=$e+je>>1;ue[Ee]<_e?$e=Ee+1:je=Ee}const Ge=$e;let Fe=$e;for(;Fe<pe&&ue[Fe]===_e;)Fe++;const Pe=Fe-$e;we+=Ge,Te+=pe-Fe}return(we-Te)/(ke*pe)}function P(fe,ae,ke,pe){const ue=Math.min(ke-1,pe-1);return!(ae>0)||!(ue>0)?null:Math.sqrt(fe/(ae*ue))}function k(fe){return Number.isFinite(fe)?fe<.001?"p < 0.001":fe>=.995?"p > 0.995":`p = ${fe.toFixed(3)}`:"p = —"}function E(fe){if(!Number.isFinite(fe))return"0";const ae=Math.abs(fe);return ae===0?"0":ae>=1e3?String(Math.round(fe)):ae>=100?String(Number(fe.toFixed(0))):ae>=10?String(Number(fe.toFixed(1))):ae>=1?String(Number(fe.toFixed(2))):String(Number(fe.toPrecision(2)))}const C=new Set(["cohensD","cliffsDelta"]);function x(fe){if(fe.difference!=null&&Math.abs(fe.difference)>=1e-12)return Math.sign(fe.difference);const ae=fe.effectSize;if(ae&&C.has(ae.name)&&Number.isFinite(ae.value)&&Math.abs(ae.value)>=1e-12)return Math.sign(ae.value);const[ke,pe]=fe.groups;return Number.isFinite(ke.mean)&&Number.isFinite(pe.mean)&&ke.mean!==pe.mean?Math.sign(ke.mean-pe.mean):0}function j(fe){const ae=fe.measureName||"values";return{subject:ae.charAt(0).toUpperCase()+ae.slice(1),be:ae==="values"?"are":"is",name:ae}}function T(fe,ae){const ke=ae.unit?` ${ae.unit}`:"",{subject:pe,be:ue}=j(ae),we=fe.groups[0].label,Te=fe.groups[1].label,Ne=fe.effectSize?fe.effectSize.label:"negligible",_e=fe.pValue<fe.alpha,$e=_e?"unlikely to be chance":"consistent with chance";if(!_e&&Ne==="negligible")return`${pe} ${ue} essentially the same for ${we} and ${Te} (${k(fe.pValue)}); the effect is ${Ne}.`;const je=x(fe),Ge=`the difference is ${$e} (${k(fe.pValue)}) and the effect is ${Ne}.`;if(je===0)return`${pe} ${ue} different between ${we} and ${Te}; ${Ge}`;const Fe=je>0?we:Te,Pe=je>0?Te:we,Ee=fe.difference!=null&&Math.abs(fe.difference)>=1e-12,Me=Math.abs(fe.difference),Ie=Ee?typeof ae.formatValue=="function"?` by about ${ae.formatValue(Me)}${ke}`:` by about ${E(Me)}${ke}`:"";return`${pe} ${ue} higher for ${Fe} than for ${Pe}${Ie}; ${Ge}`}function F(fe,ae){const{name:ke}=j(ae),pe=fe.effectSize?fe.effectSize.label:"negligible",ue=k(fe.pValue);return fe.pValue<fe.alpha?`The groups differ in ${ke}; the difference is unlikely to be chance (${ue}) and the effect is ${pe}.`:pe==="negligible"?`The groups are essentially the same in ${ke} (${ue}); the effect is ${pe}.`:`The groups show a ${pe} effect in ${ke}, but the difference is consistent with chance (${ue}).`}function $(fe,ae){const ke=fe.length;if(ke<2)return null;const{mean:pe,m2:ue}=H(fe),we=ue/(ke-1);if(!(we>0))return null;const Te=Math.sqrt(we),Ne=Te/Math.sqrt(ke),_e=pe/Ne,$e=ke-1,je=Math.min(1,Math.max(0,2*(1-b(Math.abs(_e),$e)))),Ge=c(1-ae/2,$e)*Ne,Fe=pe/Te;return{test:l.T,statistic:_e,statisticName:"t",df:$e,pValue:je,difference:pe,interval:{estimate:pe,lower:pe-Ge,upper:pe+Ge,confidence:1-ae,method:"paired-t (mean of the pair differences)"},effectSize:{name:"cohensD",label:M(Fe,i),value:Fe}}}function D(fe,ae){const ke=Array.from(fe).filter(Me=>Me!==0),pe=ke.length;if(!pe)return null;const ue=Array.from({length:pe},(Me,Ie)=>Ie).sort((Me,Ie)=>Math.abs(ke[Me])-Math.abs(ke[Ie])),we=new Array(pe);let Te=0;for(;Te<pe;){let Me=Te;for(;Me+1<pe&&Math.abs(ke[ue[Me+1]])===Math.abs(ke[ue[Te]]);)Me++;const Ie=(Te+Me)/2+1;for(let We=Te;We<=Me;We++)we[ue[We]]=Ie;Te=Me+1}let Ne=0,_e=0;for(let Me=0;Me<pe;Me++)_e+=we[Me],ke[Me]>0&&(Ne+=we[Me]);const $e=_e-Ne,je=pe*(pe+1)/4,Ge=Math.sqrt(pe*(pe+1)*(2*pe+1)/24),Fe=Ge>0?(Math.abs(Ne-je)-.5)/Ge:0,Pe=Math.min(1,Math.max(0,2*g(-Math.max(0,Fe)))),Ee=_e>0?(Ne-$e)/_e:0;return{test:l.MANN_WHITNEY,statistic:Ne,statisticName:"W",df:null,pValue:Pe,difference:null,interval:null,effectSize:{name:"cliffsDelta",label:M(Ee,d),value:Ee}}}function z(fe,ae,ke){const pe=w(fe),ue=w(ae);if(pe.n<2||ue.n<2)return null;const we=((pe.n-1)*pe.variance+(ue.n-1)*ue.variance)/(pe.n+ue.n-2);if(!(we>0))return null;const Te=Math.sqrt(we*(1/pe.n+1/ue.n)),Ne=(pe.mean-ue.mean)/Te,_e=pe.n+ue.n-2,$e=Math.min(1,Math.max(0,2*(1-b(Math.abs(Ne),_e)))),je=pe.mean-ue.mean,Ge=c(1-ke/2,_e)*Te,Fe=q(pe,ue);return{test:l.T,statistic:Ne,statisticName:"t",df:_e,pValue:$e,difference:je,interval:{estimate:je,lower:je-Ge,upper:je+Ge,confidence:1-ke,method:"student-t (pooled variance, difference of means)"},effectSize:{name:"cohensD",label:M(Fe,i),value:Fe},summaries:[pe,ue]}}function G(fe,ae,ke){const pe=w(fe),ue=w(ae);if(pe.n<2||ue.n<2)return null;const we=pe.variance/pe.n+ue.variance/ue.n;if(!(we>0))return null;const Te=Math.sqrt(we),Ne=(pe.mean-ue.mean)/Te,_e=pe.variance/pe.n*(pe.variance/pe.n)/(pe.n-1),$e=ue.variance/ue.n*(ue.variance/ue.n)/(ue.n-1),je=we*we/(_e+$e),Ge=Math.min(1,Math.max(0,2*(1-b(Math.abs(Ne),je)))),Fe=pe.mean-ue.mean,Pe=c(1-ke/2,je)*Te,Ee=q(pe,ue);return{test:l.WELCH,statistic:Ne,statisticName:"t",df:je,pValue:Ge,difference:Fe,interval:{estimate:Fe,lower:Fe-Pe,upper:Fe+Pe,confidence:1-ke,method:"welch-t (unequal variances, difference of means)"},effectSize:{name:"cohensD",label:M(Ee,i),value:Ee},summaries:[pe,ue]}}function N(fe,ae,ke){const pe=fe.length,ue=ae.length;if(pe<1||ue<1)return null;const we=w(fe),Te=w(ae),Ne=pe+ue,_e=new Array(Ne);for(let We=0;We<pe;We++)_e[We]={v:fe[We],g:0};for(let We=0;We<ue;We++)_e[pe+We]={v:ae[We],g:1};_e.sort((We,Ye)=>We.v-Ye.v);let $e=0,je=0,Ge=0;for(;Ge<Ne;){let We=Ge;for(;We<Ne&&_e[We].v===_e[Ge].v;)We++;const Ye=(Ge+1+We)/2;for(let Qe=Ge;Qe<We;Qe++)_e[Qe].g===0&&($e+=Ye);const nt=We-Ge;je+=nt*nt*nt-nt,Ge=We}const Fe=$e-pe*(pe+1)/2,Pe=pe*ue/2,Ee=pe*ue/12*(Ne+1-je/(Ne*(Ne-1)));let Me=1;if(Ee>0){const We=Math.max(0,Math.abs(Fe-Pe)-.5);Me=Math.min(1,2*g(-We/Math.sqrt(Ee)))}const Ie=K(fe,ae);return{test:l.MANN_WHITNEY,statistic:Fe,statisticName:"U",df:null,pValue:Me,difference:null,interval:Z(fe,ae,1-ke),effectSize:{name:"cliffsDelta",label:M(Ie,d),value:Ie},summaries:[we,Te]}}function Z(fe,ae,ke){const pe=fe.length,ue=ae.length,we=pe*ue;if(we===0||we>2e6)return null;const Te=new Float64Array(we);let Ne=0;for(let Ee=0;Ee<pe;Ee++)for(let Me=0;Me<ue;Me++)Te[Ne++]=fe[Ee]-ae[Me];Te.sort();const _e=we>>1,$e=we%2?Te[_e]:(Te[_e-1]+Te[_e])/2,je=Math.sqrt(pe*ue*(pe+ue+1)/12),Ge=o(1-(1-ke)/2);let Fe=Math.round(we/2-Ge*je);Fe>=0||(Fe=0);const Pe=Math.floor((we-1)/2);return Fe>Pe&&(Fe=Pe),{estimate:$e,lower:Te[Fe],upper:Te[we-1-Fe],confidence:ke,method:"hodges-lehmann (location shift)"}}function Q(fe,ae){const ke=fe.length,pe=fe.map(w);if(pe.some(Me=>Me.n<2))return null;const ue=pe.reduce((Me,Ie)=>Me+Ie.n,0),we=pe.reduce((Me,Ie)=>Me+Ie.mean*Ie.n,0)/ue;let Te=0,Ne=0;for(let Me=0;Me<ke;Me++)Te+=pe[Me].n*(pe[Me].mean-we)**2,Ne+=(pe[Me].n-1)*pe[Me].variance;const _e=ke-1,$e=ue-ke;if(!(Ne>0)||$e<1)return null;const je=Te/_e,Ge=Ne/$e,Fe=je/Ge,Pe=Math.min(1,Math.max(0,S(Fe,_e,$e))),Ee=Te/(Te+Ne);return{test:l.ANOVA,statistic:Fe,statisticName:"F",df:{between:_e,within:$e},pValue:Pe,difference:null,interval:null,effectSize:{name:"etaSquared",label:M(Ee,h),value:Ee},summaries:pe}}function ee(fe,ae){const ke=fe.length,pe=fe.map(w);if(ke<2)return null;const ue=pe.reduce((Ie,We)=>Ie+We.n,0),we=[];for(let Ie=0;Ie<ke;Ie++)for(let We=0;We<fe[Ie].length;We++)we.push({v:fe[Ie][We],g:Ie});we.sort((Ie,We)=>Ie.v-We.v);const Te=new Array(we.length);let Ne=0,_e=0;for(;_e<we.length;){let Ie=_e;for(;Ie<we.length&&we[Ie].v===we[_e].v;)Ie++;const We=(_e+1+Ie)/2;for(let nt=_e;nt<Ie;nt++)Te[nt]=We;const Ye=Ie-_e;Ne+=Ye*Ye*Ye-Ye,_e=Ie}const $e=new Array(ke).fill(0);for(let Ie=0;Ie<we.length;Ie++)$e[we[Ie].g]+=Te[Ie];let je=0;for(let Ie=0;Ie<ke;Ie++)je+=$e[Ie]*$e[Ie]/pe[Ie].n;je=12/(ue*(ue+1))*je-3*(ue+1);const Ge=1-Ne/(ue*ue*ue-ue),Fe=Ge>0?je/Ge:je,Pe=ke-1,Ee=Math.min(1,Math.max(0,t(Fe,Pe))),Me=(Fe-ke+1)/(ue-ke);return{test:l.KRUSKAL,statistic:Fe,statisticName:"H",df:Pe,pValue:Ee,difference:null,interval:null,effectSize:{name:"etaSquared",label:M(Me,h),value:Math.max(0,Me)},summaries:pe}}function re(fe,ae,ke,pe,ue){const we=O(fe,ae,ue),Te=O(ke,pe,ue);if(!we||!Te)return null;const Ne=we.proportion-Te.proportion,_e=Ne-Math.sqrt((we.proportion-we.lower)**2+(Te.upper-Te.proportion)**2),$e=Ne+Math.sqrt((we.upper-we.proportion)**2+(Te.proportion-Te.lower)**2);return{estimate:Ne,lower:_e,upper:$e}}function ie(fe,ae,ke,pe){const ue=U(ae),we=new Set,Te=[];for(const We of fe){const Ye=new Map;let nt=0;for(const Qe of We.rows){const dt=f(ue(Qe));dt!==null&&(Ye.set(dt,(Ye.get(dt)||0)+1),nt++,we.add(dt))}Te.push(Ye),We.total=nt}const Ne=[...we];if(Ne.length<2)return null;const _e=fe.reduce((We,Ye)=>We+Ye.total,0);if(!(_e>0))return null;let $e=0;for(const We of fe)for(const Ye of Ne){const nt=Te[fe.indexOf(We)].get(Ye)||0,Qe=fe.reduce((jt,Et)=>jt+(Te[fe.indexOf(Et)].get(Ye)||0),0),dt=We.total*Qe/_e;dt>0&&($e+=(nt-dt)*(nt-dt)/dt)}const je=fe.length,Ge=Ne.length,Fe=(je-1)*(Ge-1),Pe=Math.min(1,Math.max(0,t($e,Fe))),Ee=P($e,_e,je,Ge);let Me=null;if(je===2&&Ge===2){const[We]=Ne,Ye=Te[0].get(We)||0,nt=Te[1].get(We)||0,Qe=re(Ye,fe[0].total,nt,fe[1].total,pe);Qe&&(Me={...Qe,confidence:pe,method:"newcombe (difference in this category's share)",category:We})}const Ie=fe.map((We,Ye)=>{const nt={};for(const Qe of Ne)nt[String(Qe)]=(Te[Ye].get(Qe)||0)/We.total;return nt});return{test:l.CHI_SQUARE,statistic:$e,statisticName:"chiSquare",df:Fe,pValue:Pe,difference:null,interval:Me,effectSize:{name:"cramersV",label:X("cramersV",Ee,Math.min(je-1,Ge-1)),value:Ee},proportions:Ie}}function ce(fe,ae,ke,pe){const ue=U(ae),we=new Set;for(const Qe of fe)for(const dt of Qe.rows){const jt=f(ue(dt));jt!==null&&we.add(jt)}if(we.size!==2)return null;const[Te]=[...we],Ne=fe[0].rows.reduce((Qe,dt)=>Qe+(f(ue(dt))===Te?1:0),0),_e=fe[1].rows.reduce((Qe,dt)=>Qe+(f(ue(dt))===Te?1:0),0),$e=fe[0].rows.length,je=fe[1].rows.length;if(!($e>0)||!(je>0))return null;const Ge=Ne/$e,Fe=_e/je,Pe=(Ne+_e)/($e+je);if(!(Pe>0)||!(Pe<1))return null;const Ee=Math.sqrt(Pe*(1-Pe)*(1/$e+1/je)),Me=(Ge-Fe)/Ee,Ie=Math.min(1,Math.max(0,2*g(-Math.abs(Me)))),We=Ge-Fe,Ye=re(Ne,$e,_e,je,pe),nt=P(Me*Me,$e+je,2,2);return{test:l.PROPORTIONS,statistic:Me,statisticName:"z",df:null,pValue:Ie,difference:We,interval:Ye?{...Ye,confidence:pe,method:"newcombe (difference in proportions)",category:Te}:null,effectSize:{name:"cramersV",label:X("cramersV",nt,1),value:nt},proportions:[{[String(Te)]:Ge},{[String(Te)]:Fe}],focalCategory:Te}}function ve(fe,ae,ke,pe){if(ke&&u.has(ke))return{test:ke,reason:`caller override: ${ke}`};const ue=_(fe),we=_(ae),Te=ue===null?null:Math.exp(-ue/2),Ne=we===null?null:Math.exp(-we/2);if(Te!==null&&Te<r||Ne!==null&&Ne<r)return{test:l.MANN_WHITNEY,reason:"two numeric groups, non-normal by Jarque-Bera"};const _e=w(fe),$e=w(ae);if(_e.n>=3&&$e.n>=3&&_e.variance>0&&$e.variance>0){const je=Math.max(_e.variance,$e.variance)/Math.min(_e.variance,$e.variance),Ge=_e.variance>=$e.variance?_e.n-1:$e.n-1,Fe=_e.variance>=$e.variance?$e.n-1:_e.n-1;if(2*Math.min(S(je,Ge,Fe),1-S(je,Ge,Fe))<pe)return{test:l.WELCH,reason:"two numeric groups, unequal variances (F-test)"}}return{test:l.T,reason:Te!==null||Ne!==null?"two numeric groups, equal variances and no departure from normality":"two numeric groups (too few rows to screen normality)"}}function he(fe,ae){if(ae&&n.has(ae))return{test:ae,reason:`caller override: ${ae}`};for(const ke of fe){const pe=_(ke),ue=pe===null?null:Math.exp(-pe/2);if(ue!==null&&ue<r)return{test:l.KRUSKAL,reason:"three or more numeric groups, non-normal by Jarque-Bera"}}return{test:l.ANOVA,reason:"three or more numeric groups, no departure from normality detected"}}function ye(fe,ae,ke,pe={},ue=null){if(!fe||!ae)return null;const we=y(pe.alpha),Te=1-we,Ne=pe.test&&pe.test!=="auto"?String(pe.test):null,_e=m(ae,ke);if(_e.length<2)return A("compare:groups",'[lattice] statistics.compare: the "by" column has fewer than two distinct values to group by.'),null;let $e;if(Array.isArray(pe.groups)&&pe.groups.length===2){const Ye=[f(pe.groups[0]),f(pe.groups[1])];if(Ye[0]===null||Ye[1]===null||Ye[0]===Ye[1])return A("compare:distinct","[lattice] statistics.compare: the two groups must be two distinct, present values."),null;if($e=_e.filter(nt=>nt.value===Ye[0]||nt.value===Ye[1]),$e.length!==2)return A("compare:empty","[lattice] statistics.compare: one of the two groups has no rows in the current set."),null;$e.sort((nt,Qe)=>nt.value===Ye[0]?-1:1)}else _e.length===2||Ne&&u.has(Ne)||Ne&&p.has(Ne)?$e=_e.slice(0,2):(Ne&&n.has(Ne),$e=_e);const Ge=Y(fe,ke),Fe=!!pe.paired&&ue&&$e.length===2&&Ge;let Pe,Ee,Me;if(Ge)if($e.length===2&&!(Ne&&n.has(Ne))){const Ye=J(fe,$e[0].rows),nt=J(fe,$e[1].rows);if(Ye.length<3||nt.length<3)return A("compare:small","[lattice] statistics.compare: each group needs at least three readings to compare."),null;if(w(Ye).variance===0||w(nt).variance===0)return A("compare:zero-variance","[lattice] statistics.compare: a group has zero variance, so the difference has no scale to test."),null;if(Fe){const dt=Le(fe,ue,$e[0].rows,$e[1].rows);return dt?(Ee=Ne?"override":"auto",Me=Ne?`caller override: ${Ne} (paired)`:"two numeric groups, paired",Pe=Ne===l.MANN_WHITNEY?D(dt.diffs,we):$(dt.diffs,we),Pe?(Pe.paired=!0,Pe.chosenBy=Ee,Pe.reason=Me,Pe.groups=[{value:$e[0].value,label:String($e[0].value),n:dt.n},{value:$e[1].value,label:String($e[1].value),n:dt.n}],Pe.alpha=we,Pe.method=Pe.test===l.MANN_WHITNEY?"Wilcoxon signed-rank test (paired)":"Student's paired t-test (difference of pairs)",Pe.verdict=T(Pe,pe),Pe.categorical=!1,Pe):(A("compare:degenerate","[lattice] statistics.compare: the paired test had too little to work with."),null)):(A("compare:paired","[lattice] statistics.compare: not enough matched pairs to run a paired test."),null)}const Qe=ve(Ye,nt,Ne,we);Ee=Ne?"override":"auto",Me=Qe.reason,Qe.test===l.MANN_WHITNEY?Pe=N(Ye,nt,we):Qe.test===l.WELCH?Pe=G(Ye,nt,we):Pe=z(Ye,nt,we),Pe&&Pe.interval&&Pe.difference===null&&(Pe.difference=Pe.interval.estimate)}else{const Ye=$e.map(Qe=>J(fe,Qe.rows));if(Ye.some(Qe=>Qe.length<3))return A("compare:small","[lattice] statistics.compare: each group needs at least three readings to compare."),null;const nt=he(Ye,Ne);Ee=Ne?"override":"auto",Me=nt.reason,Pe=nt.test===l.KRUSKAL?ee(Ye,we):Q(Ye,we)}else if($e.length===2){const Ye=Oe(fe,$e).size===2;if(Ne===l.PROPORTIONS||Ye&&!Ne)Ee=Ne?"override":"auto",Me=Ne?"caller override: proportions":"categorical measure with two categories (binary)",Pe=ce($e,fe,we,Te);else if(Ne===l.CHI_SQUARE||!Ye&&!Ne)Ee=Ne?"override":"auto",Me=Ne?"caller override: chiSquare":`categorical measure with ${Oe(fe,$e).size} categories`,Pe=ie($e,fe,we,Te);else return A("compare:numeric-needed",`[lattice] statistics.compare: ${Ne} needs a numeric measure, but the column is categorical.`),null}else Ee=Ne?"override":"auto",Me=Ne?`caller override: ${Ne}`:`categorical measure with ${Oe(fe,$e).size} categories`,Pe=ie($e,fe,we,Te);if(!Pe)return A("compare:degenerate","[lattice] statistics.compare: the chosen test had too little to work with (too few values, or no variation)."),null;const Ie=Pe.summaries,We=Pe.proportions;return{test:Pe.test,chosenBy:Ee,reason:Me,statistic:Pe.statistic,statisticName:Pe.statisticName,df:Pe.df===void 0?null:Pe.df,pValue:Pe.pValue,alpha:we,paired:!1,interval:Pe.interval||null,effectSize:Pe.effectSize,groups:$e.map((Ye,nt)=>({value:Ye.value,label:String(Ye.value),n:Ie?Ie[nt].n:Ye.total,...Ie?{mean:Ie[nt].mean,sd:Ie[nt].sd}:{},...We?{proportions:We[nt]}:{}})),difference:Pe.difference===void 0?null:Pe.difference,method:Pe.test,categorical:!Ge,verdict:$e.length===2?T({...Pe,alpha:we,groups:[{value:$e[0].value,label:String($e[0].value),mean:Ie?Ie[0].mean:void 0},{value:$e[1].value,label:String($e[1].value),mean:Ie?Ie[1].mean:void 0}],categorical:!Ge,difference:Pe.difference===void 0?null:Pe.difference},pe):F({...Pe,alpha:we},pe)}}function Oe(fe,ae){const ke=U(fe),pe=new Set;for(const ue of ae)for(const we of ue.rows){const Te=f(ke(we));Te!==null&&pe.add(Te)}return pe}function Le(fe,ae,ke,pe){const ue=U(ae),we=U(fe),Te=new Map;for(const _e of pe){const $e=f(ue(_e));$e!==null&&Te.set($e,we(_e))}const Ne=[];for(const _e of ke){const $e=f(ue(_e));if($e===null||!Te.has($e))continue;const je=Number(we(_e)),Ge=Number(Te.get($e));!Number.isFinite(je)||!Number.isFinite(Ge)||Ne.push(je-Ge)}return Ne.length<2?null:{diffs:Float64Array.from(Ne),n:Ne.length}}}),ze("packages/core/src/columns/detailcolumn.js",function(e,B){"use strict";Object.defineProperty(e,"DETAIL_COLUMN_ID",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"createDetailColumn",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return U}});const ne="__lattice_detail",A=36;function V(I){const J=I.config&&I.config.detailColumnWidth||A;return{id:ne,field:null,title:"",type:"text",dataType:{base:"text"},nullable:!0,align:"center",generated:!0,control:!0,detailExpander:!0,value:{pure:!0},cell:{render:"detailExpander",align:"center"},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:J,min:J,max:J,pin:I.config&&I.config.detailColumnPin||"start",hidden:!1,resizable:!1,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(H,L){return!!(L&&L.expanded)},formatValue(){return""}}}const U=V}),ze("packages/core/src/columns/treecolumn.js",function(e,B){"use strict";Object.defineProperty(e,"TREE_COLUMN_ID",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"createTreeColumn",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return J}});const A=B("packages/core/src/internal/predicates.js").isFunction,V="__lattice_tree",U=260;function I(H){const L=H.tree||{},Y=H.config&&H.config.treeColumnWidth||U,_=!!(H.config&&H.config.treeColumnFlex),O=()=>(H.columns&&A(H.columns.visible)?H.columns.visible():[]).find(g=>!g.generated)||null,v=(c,g)=>{if(g&&g.group)return g.groupValue;if(A(L.label))return L.label(c,g);if(typeof L.label=="string")return c==null?null:c[L.label];const o=O();return o&&A(o.getValue)?o.getValue(c,g):null},b=()=>{if(L.title)return L.title;const c=typeof L.label=="string"?H.columns&&A(H.columns.get)?H.columns.get(L.label):null:O();return c&&(c.title||c.id)||"Hierarchy"};return{id:V,get title(){return b()},field:null,type:"text",dataType:{base:"text"},nullable:!0,align:"start",generated:!0,value:{pure:!0},cell:{render:"group",props:{icon:L.icon,iconClass:L.iconClass,content:L.content,checkbox:L.checkbox,onCheck:L.onCheck}},edit:{enabled:!1},sort:{enabled:!0,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:_?{flex:1,min:0,pin:H.config&&H.config.treeColumnPin||null,hidden:!1,resizable:!1,movable:!1,lockPosition:!0}:{width:Y,min:140,pin:H.config&&H.config.treeColumnPin||null,hidden:!1,resizable:!0,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(c,g){return v(c,g)},formatValue(c,g){if(g&&g.grandTotal)return H.config&&H.config.grandTotalLabel||"Total";if(c==null)return"";if(!L.label){const o=O();if(o&&A(o.formatValue))return o.formatValue(c,g)}return String(c)}}}const J=I}),ze("packages/core/src/columns/pivotcolumns.js",function(e,B){"use strict";Object.defineProperty(e,"PIVOT_PREFIX",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"createPivotColumns",{enumerable:!0,get:function(){return I}});const A=B("packages/core/src/internal/warn.js").warnOnce,V="__lattice_pivot",U=500;function I(Y){const{pivot:_,valueColumns:O,config:v}=Y,b=_&&_.paths||[],c=Y.separator||v&&v.pivot&&v.pivot.separator||" | ",g=v&&v.pivot&&v.pivot.maxColumns||U;if(!b.length||!O.length)return{tree:[],leaves:[],error:null};const o=J(v),t=b.length*O.length+(o?O.length:0);if(t>g){const u=`pivot would generate ${t} columns, above the limit of ${g}. Pivot on a lower-cardinality column, or raise pivot.maxColumns.`;return A(`pivot.maxColumns:${t}`,u),{tree:[],leaves:[],error:u}}const s=[],l=[];for(const u of b){const n=[];for(const p of O){const r=L(u,p,c);n.push(r),l.push(r)}n.length===1?(n[0].title=String(u),s.push(n[0])):s.push({id:`${V}:group:${u}`,title:String(u),columns:n,collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!0,generated:!0})}if(o){const u=O.map(p=>H(p,v));l.push(...u);const n=v&&v.pivot&&v.pivot.totalsLabel||"Total";if(u.length===1)u[0].title=n,o==="before"?s.unshift(u[0]):s.push(u[0]);else{const p={id:`${V}:group:__totals`,title:n,columns:u,collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!0,generated:!0};o==="before"?s.unshift(p):s.push(p)}}return{tree:s,leaves:l,error:null}}function J(Y){const _=Y&&Y.pivot&&Y.pivot.groupTotals;return _==="before"||_==="after"?_:null}function H(Y,_){return{id:`${V}:__total${_&&_.pivot&&_.pivot.separator||" | "}${Y.id}`,field:null,title:Y.title||Y.id,type:Y.type,dataType:Y.dataType,nullable:!0,align:Y.align,generated:!0,pivot:{enabled:!1,index:0,sourceId:Y.id,total:!0},value:{pure:!0},cell:{align:Y.align},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},total:Y.total,lookup:null,layout:{width:Y.layout&&Y.layout.width||120,min:80,pin:null,hidden:!1,resizable:!0,movable:!1},header:{},export:{csv:!0,excel:!0},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(O,v){const b=v&&v.totals;return b&&Object.hasOwn(b,Y.id)?b[Y.id]:null},formatValue(O,v){return O==null?"":Y.formatValue?Y.formatValue(O,v):String(O)}}}function L(Y,_,O){return{id:`${V}:${Y}${O}${_.id}`,field:null,title:_.title||_.id,type:_.type,dataType:_.dataType,nullable:!0,align:_.align,generated:!0,pivot:{enabled:!1,index:0,path:Y,sourceId:_.id},value:{pure:!0},cell:{align:_.align},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},total:_.total,lookup:null,layout:{width:_.layout&&_.layout.width||120,min:80,pin:null,hidden:!1,resizable:!0,movable:!1},header:{},export:{csv:!0,excel:!0},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(){return null},formatValue(v,b){return v==null?"":_.formatValue?_.formatValue(v,b):String(v)}}}}),ze("packages/core/src/compute/group.js",function(e,B){"use strict";Object.defineProperty(e,"packKeys",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return v}});const ne=B("packages/core/src/compute/handle.js"),A=ne.dictSize,V=ne.identity,U=ne.presenceReader,I=ne.rowCount,J=ne.valueReader,H="",L="\0",Y=1<<20;function _(b,c,g,o){const t=b.length,s=b.map(i=>J(i)),l=Array.isArray(o)&&o.some(Boolean),u=l?s.map((i,d)=>o[d]?h=>o[d](i(h)):i):s;if(!l&&t>0&&b.every(i=>i&&i.kind==="dictionary"&&i.dict)){const i=b.map(h=>A(h.dict)+1);let d=1;for(let h=0;h<t;h++)d*=i[h];if(d<=Number.MAX_SAFE_INTEGER){const h=b.map(m=>m.values),a=b.map(m=>U(m)),y=m=>{let w=0;for(let S=0;S<t;S++){const M=a[S],X=M&&M(m)===0?i[S]-1:h[S][m];w=w*i[S]+X}return w},f=new Float64Array(g);for(let m=0;m<g;m++)f[m]=y(c[m]);return{packed:f,strings:null,product:d,readers:u,keyOf:y}}}const p=i=>{let d="";for(let h=0;h<t;h++){const a=u[h](i);d+=(h===0?"":H)+(a==null?L:String(a))}return d},r=new Array(g);for(let i=0;i<g;i++)r[i]=p(c[i]);return{packed:null,strings:r,product:1/0,readers:u,keyOf:p}}function O(b,c,g,o){const t=new Uint32Array(o+1);for(let n=0;n<g;n++)t[c[n]+1]++;for(let n=0;n<o;n++)t[n+1]+=t[n];const s=new Uint32Array(g),l=t.slice(0,o);for(let n=0;n<g;n++)s[l[c[n]]++]=b[n];const u=new Array(o);for(let n=0;n<o;n++)u[n]=s.subarray(t[n],t[n+1]);return u}function v(b,c,g={}){const o=b||[],t=c||V(I(o[0],g)),s=t.length;if(o.length===0||s===0)return{keys:[],buckets:[]};const{packed:l,strings:u,product:n,readers:p}=_(o,t,s,g.project),r=new Uint32Array(s);let i=0,d=null;if(l&&n<=Math.max(1024,Math.min(Y,s*4))){const f=n,m=new Int32Array(f).fill(-1);for(let w=0;w<s;w++)m[l[w]]=0;for(let w=0;w<f;w++)m[w]===0&&(m[w]=i++);for(let w=0;w<s;w++)r[w]=m[l[w]];d=new Float64Array(i);for(let w=0;w<f;w++)m[w]>=0&&(d[m[w]]=w)}else if(l){const f=new Map;for(let m=0;m<s;m++){const w=l[m];let S=f.get(w);S===void 0&&(S=i++,f.set(w,S)),r[m]=S}d=new Float64Array(i);for(const[m,w]of f)d[w]=m}else{const f=new Map;for(let m=0;m<s;m++){const w=u[m];let S=f.get(w);S===void 0&&(S=i++,f.set(w,S)),r[m]=S}}const h=O(t,r,s,i),a=new Array(i);for(let f=0;f<i;f++){const m=h[f][0],w=new Array(p.length);for(let S=0;S<p.length;S++)w[S]=p[S](m);a[f]=w}const y={keys:a,buckets:h};return d&&(y.packed=d),y}}),ze("packages/core/src/compute/pivot.js",function(e,B){"use strict";Object.defineProperty(e,"KEY_DELIMITER",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"pivotKey",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"joinPath",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"resolvePivotKeys",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return s}});const A=B("packages/core/src/internal/warn.js").warnOnce,U=B("packages/core/src/compute/handle.js").valueComparator,J=B("packages/core/src/compute/group.js").packKeys,L=B("packages/core/src/compute/total.js").total,Y="|",_="/",O=2e3;function v(n,p,r){return`${n}${Y}${p}${Y}${r}`}function b(n,p){let r="";for(let i=0;i<n.length;i++){const d=n[i];r+=(i===0?"":p)+(d==null?"":String(d))}return r}function c(n,p,r={}){const i=r.separator||_,d=p.length,{keyOf:h,readers:a}=J(n,p,0),y=new Map,f=[],m=[];for(let P=0;P<d;P++){const k=p[P],E=h(k);if(y.has(E))continue;y.set(E,f.length),m.push(E);const C=new Array(a.length);for(let x=0;x<a.length;x++)C[x]=a[x](k);f.push(C)}const w=U(r.locale),S=f.map((P,k)=>k);S.sort((P,k)=>{const E=f[P],C=f[k];for(let x=0;x<E.length;x++){const j=g(E[x],C[x],w);if(j!==0)return j}return P-k});const M=new Array(S.length),X=new Array(S.length),q=new Map;for(let P=0;P<S.length;P++){const k=S[P];M[P]=f[k],X[P]=b(f[k],i),q.set(m[k],P)}return{keys:M,paths:X,idOf:P=>{const k=q.get(h(P));return k===void 0?-1:k}}}function g(n,p,r){const i=n==null,d=p==null;return i||d?i&&d?0:i?1:-1:r(n,p)}function o(n){const p=n.values||n.totals||[];if(p.length&&typeof p[0]=="object"&&p[0]!==null)return p.filter(h=>h&&h.handle);const r=typeof n.handle=="function"?n.handle:null;if(!r)return p.length&&A("pivot:handles","pivot was given total column ids but no handle(colId) resolver, so no cell values were reduced. Pass values: [{ colId, handle, fn }] or opts.handle."),[];const i=typeof n.totalOf=="function"?n.totalOf:null,d=[];for(const h of p){const a=r(h);a&&d.push({colId:h,handle:a,fn:i?i(h):"sum"})}return d}function t(n,p,r){if(Array.isArray(n)){const i=r||{};return{...i,pivotHandles:n,order:p||null,groups:i.groups||null}}return n||{}}function s(n,p,r){const i=t(n,p,r),d=i.separator||_,h=o(i),a=i.maxColumns===void 0?O:i.maxColumns,y=i.groups&&i.groups.buckets?i.groups:null,f=y?y.buckets:[i.order||new Uint32Array(0)],m=i.groupPaths||(y?y.keys.map(E=>b(E,d)):[""]),w=u(f),{keys:S,paths:M,idOf:X}=c(i.pivotHandles||[],w,i),q=M.length*Math.max(1,h.length),K=l(M,h,d);if(a&&q>a){const E=new Map;return{keys:S,paths:M,fields:K,groupPaths:m,columns:q,values:E,cells:E,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${q} columns, above pivot.maxColumns of ${a}. Narrow the pivot columns or raise the limit.`,columns:q,maxColumns:a}}}const P=new Map,k=M.length;for(let E=0;E<f.length;E++){const C=f[E],x=m[E]===void 0?"":m[E],j=C.length;if(j===0)continue;const T=new Int32Array(j),F=new Uint32Array(k+1);for(let z=0;z<j;z++){const G=X(C[z]);T[z]=G,G>=0&&F[G+1]++}for(let z=0;z<k;z++)F[z+1]+=F[z];const $=new Uint32Array(j),D=F.slice(0,k);for(let z=0;z<j;z++){const G=T[z];G>=0&&($[D[G]++]=C[z])}for(let z=0;z<k;z++){const G=F[z],N=F[z+1];if(N===G)continue;const Z=$.subarray(G,N);for(let Q=0;Q<h.length;Q++){const ee=h[Q],re=L(ee.handle,Z,ee.fn,i.totalContext||{locale:i.locale});P.set(v(x,M[z],ee.colId),re)}}}return{keys:S,paths:M,fields:K,groupPaths:m,columns:q,values:P,cells:P,error:null}}function l(n,p,r){if(p.length===0)return n.slice();const i=[];for(const d of n)for(const h of p)i.push(`${d}${r}${h.colId}`);return i}function u(n){if(n.length===1)return n[0]||new Uint32Array(0);let p=0;for(const d of n)p+=d?d.length:0;const r=new Uint32Array(p);let i=0;for(const d of n)!d||d.length===0||(r.set(d,i),i+=d.length);return r}}),ze("packages/core/src/compute/explain.js",function(e,B){"use strict";Object.defineProperty(e,"explainContributors",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"explainChange",{enumerable:!0,get:function(){return v}});const A=B("packages/core/src/compute/total.js").total,U=B("packages/core/src/compute/group.js").groupByColumns,I=new Set(["sum","count","countValues"]),J=new Set(["min","max"]),H=new Set(["avg"]);function L(b){return typeof b=="string"?b:typeof b=="function"&&b.totalName?b.totalName:null}function Y(b,c,g,o){return A(b,c,g,o||{})}function _(b,c){if(c)try{return c(b)}catch{}return b==null?"":String(b)}function O(b){const{handle:c,fn:g,leaves:o,by:t,labelOf:s,rowLabel:l}=b,u={locale:b.locale},n=o&&o.length?o:[],p=L(g),r=Y(c,n,g,u),i=J.has(p);let d;if(i){let y=-1;for(let f=0;f<n.length;f++){const m=Y(c,[n[f]],g,u);if(Object.is(m,r)){y=n[f];break}}d=y<0?[]:[{key:y,indices:[y],label:l?l(y):String(y)}]}else if(t){const y=U([t],n);d=y.keys.map((f,m)=>({key:f[0],indices:y.buckets[m],label:_(f[0],s)}))}else d=Array.from({length:n.length},(y,f)=>{const m=n[f];return{key:m,indices:[m],label:l?l(m):String(m)}});const h=n.length,a=[];for(const y of d){const f=Y(c,y.indices,g,u),m=y.indices.length;let w,S;if(p==="avg")w=((typeof f=="number"?f:0)-(typeof r=="number"?r:0))*m,S=h?m/h:0;else if(i)w=typeof f=="number"?f:0,S=1;else{w=typeof f=="number"?f:0;const M=typeof r=="number"?r:0;S=M?w/M:0}a.push({key:y.key,label:y.label,count:m,value:f,contribution:w,share:S})}return a.sort((y,f)=>Math.abs(f.contribution)-Math.abs(y.contribution)||(y.label<f.label?-1:y.label>f.label?1:0)),{total:r,fn:p,weighted:H.has(p),single:i,contributors:a}}function v(b){const c=O({...b,leaves:b.after}),g=O({...b,leaves:b.before}),o=typeof c.total=="number"?c.total:0,t=typeof g.total=="number"?g.total:0,s=new Map;for(const n of c.contributors)s.set(n.key,n);const l=[],u=new Set;for(const n of g.contributors){u.add(n.key);const p=s.get(n.key);if(p===void 0)l.push({key:n.key,label:n.label,before:n.value,after:null,effect:-n.contribution,kind:"dropped",count:n.count});else{const r=p.contribution-n.contribution;r!==0&&l.push({key:n.key,label:n.label,before:n.value,after:p.value,effect:r,kind:"changed",count:p.count})}}for(const n of c.contributors)u.has(n.key)||l.push({key:n.key,label:n.label,before:null,after:n.value,effect:n.contribution,kind:"new",count:n.count});return l.sort((n,p)=>Math.abs(p.effect)-Math.abs(n.effect)||(n.label<p.label?-1:n.label>p.label?1:0)),{before:g.total,after:c.total,delta:o-t,weighted:c.weighted||g.weighted,single:c.single||g.single,drivers:l}}}),ze("packages/core/src/store/bitset.js",function(e,B){"use strict";Object.defineProperty(e,"Bitset",{enumerable:!0,get:function(){return A}});const ne=8;class A{static#e=new Uint8Array(256);static{for(let U=1;U<256;U++)A.#e[U]=A.#e[U>>1]+(U&1)}#t;#n;constructor(U=0){const I=Math.max(0,U|0);this.#n=I,this.#t=new Uint8Array(Math.ceil(I/ne))}get size(){return this.#n}get words(){return this.#t}get bytes(){return this.#t?this.#t.byteLength:0}get(U){return U<0||U>=this.#n?0:this.#t[U>>3]>>(U&7)&1}set(U){return U>=0&&U<this.#n&&(this.#t[U>>3]|=1<<(U&7)),this}clear(U){return U>=0&&U<this.#n&&(this.#t[U>>3]&=~(1<<(U&7))),this}assign(U,I){return I?this.set(U):this.clear(U)}fill(U=!1){return this.#t.fill(U?255:0),U&&this.#r(),this}grow(U){const I=Math.max(0,U|0);if(I<=this.#n)return this;const J=Math.ceil(I/ne);if(J>this.#t.length){const H=new Uint8Array(J);H.set(this.#t),this.#t=H}return this.#n=I,this}count(){const U=this.#t,I=A.#e;let J=0;for(let H=0;H<U.length;H++)J+=I[U[H]];return J}and(U){const I=U instanceof A?U.words:U,J=this.#t,H=Math.min(J.length,I.length);for(let L=0;L<H;L++)J[L]&=I[L];for(let L=H;L<J.length;L++)J[L]=0;return this}or(U){const I=U instanceof A?U.words:U,J=this.#t,H=Math.min(J.length,I.length);for(let L=0;L<H;L++)J[L]|=I[L];return this}not(){const U=this.#t;for(let I=0;I<U.length;I++)U[I]=~U[I]&255;return this.#r(),this}clone(){const U=new A(this.#n);return U.words.set(this.#t.subarray(0,U.words.length)),U}release(){this.#t=new Uint8Array(0),this.#n=0}#r(){const U=this.#n&7;if(U===0)return;const I=this.#n>>3;I<this.#t.length&&(this.#t[I]&=(1<<U)-1)}static from(U){const I=Array.isArray(U)?U:Array.from(U),J=new A(I.length);for(let H=0;H<I.length;H++)I[H]&&J.set(H);return J}}}),ze("packages/core/src/store/dictionary.js",function(e,B){"use strict";Object.defineProperty(e,"Dictionary",{enumerable:!0,get:function(){return U}});const ne=B("packages/core/src/internal/compare.js"),A=ne.collator,V=ne.defaultCompare;class U{#e;#t=new Map;#n=0;#r=null;#s=-1;#i="\0";constructor(J=[]){this.#e=[];for(let H=0;H<J.length;H++){const L=J[H];this.#t.has(L)||(this.#t.set(L,this.#e.length),this.#e.push(L))}}get size(){return this.#e.length}get version(){return this.#n}get bytes(){let J=this.#e.length*8;for(let H=0;H<this.#e.length;H++){const L=this.#e[H];typeof L=="string"&&(J+=L.length*2),J+=16}return J}codeOf(J){const H=this.#t.get(J);if(H!==void 0)return H;const L=this.#e.length;return this.#e.push(J),this.#t.set(J,L),this.#n++,L}lookup(J){const H=this.#t.get(J);return H===void 0?-1:H}has(J){return this.#t.has(J)}valueOf(J){return this.#e[J]}values(){return this.#e}ranks(J){const H=J||"";if(this.#r&&this.#s===this.#n&&this.#i===H)return this.#r;const L=this.#e.length,Y=new Array(L);for(let b=0;b<L;b++)Y[b]=b;const _=A(J).compare,O=this.#e;Y.sort((b,c)=>this.#a(O[b],O[c],_));const v=new Uint32Array(L);for(let b=0;b<L;b++)v[Y[b]]=b;return this.#r=v,this.#s=this.#n,this.#i=H,v}#a(J,H,L){return typeof J=="string"&&typeof H=="string"?L(J,H):V(J,H)}}}),ze("packages/core/src/store/multivalue.js",function(e,B){"use strict";Object.defineProperty(e,"MultiValue",{enumerable:!0,get:function(){return ne}});class ne{#e;#t;#n=0;#r=0;constructor(V={}){const U=Math.max(1,V.rows??16),I=Math.max(1,V.values??U);this.#e=new Int32Array(I),this.#t=new Uint32Array(U+1)}get values(){return this.#e}get offsets(){return this.#t}get rows(){return this.#n}get length(){return this.#r}get bytes(){return this.#e.byteLength+this.#t.byteLength}count(V){return V<0||V>=this.#n?0:this.#t[V+1]-this.#t[V]}at(V){return V<0||V>=this.#n?this.#e.subarray(0,0):this.#e.subarray(this.#t[V],this.#t[V+1])}has(V,U){if(V<0||V>=this.#n)return!1;const I=this.#e,J=this.#t[V+1];for(let H=this.#t[V];H<J;H++)if(I[H]===U)return!0;return!1}hasAny(V,U){for(let I=0;I<U.length;I++)if(this.has(V,U[I]))return!0;return!1}hasAll(V,U){for(let I=0;I<U.length;I++)if(!this.has(V,U[I]))return!1;return!0}hasNone(V,U){return!this.hasAny(V,U)}push(V){const U=this.#n,I=V.length;this.#s(U+1),this.#i(this.#r+I);const J=this.#r;for(let H=0;H<I;H++)this.#e[J+H]=V[H]|0;return this.#r+=I,this.#n=U+1,this.#t[U]=J,this.#t[U+1]=this.#r,U}write(V,U){if(V===this.#n){this.push(U);return}if(V<0||V>this.#n)return;const I=this.#t[V],J=this.#t[V+1],H=U.length;if(J-I===H){for(let L=0;L<H;L++)this.#e[I+L]=U[L]|0;return}this.#a(V,U)}compact(V,U,I){const J=this.#e,H=this.#t,L=this.#n,Y=new Int32Array(Math.max(1,this.#r)),_=new Uint32Array(U+1);let O=0;for(let v=0;v<L;v++){if(V[v]===I)continue;const b=H[v],c=H[v+1];_[V[v]]=O;for(let g=b;g<c;g++)Y[O++]=J[g];_[V[v]+1]=O}this.#e=Y,this.#t=_,this.#n=U,this.#r=O}release(){this.#e=new Int32Array(0),this.#t=new Uint32Array(1),this.#n=0,this.#r=0}#s(V){if(V+1<=this.#t.length)return;let U=this.#t.length-1;for(;U<V;)U=U*2||16;const I=new Uint32Array(U+1);I.set(this.#t),this.#t=I}#i(V){if(V<=this.#e.length)return;let U=this.#e.length;for(;U<V;)U=U*2||16;const I=new Int32Array(U);I.set(this.#e),this.#e=I}#a(V,U){const I=this.#e,J=this.#t,H=this.#n,L=U.length-(J[V+1]-J[V]),Y=new Int32Array(Math.max(1,this.#r+L)),_=new Uint32Array(J.length);let O=0;for(let v=0;v<H;v++){if(_[v]=O,v===V)for(let b=0;b<U.length;b++)Y[O++]=U[b]|0;else for(let b=J[v];b<J[v+1];b++)Y[O++]=I[b];_[v+1]=O}this.#e=Y,this.#t=_,this.#r=O}}}),ze("packages/core/src/compute/sort.js",function(e,B){"use strict";Object.defineProperty(e,"radixSortFloat64",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"radixSortInt32",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"rankSortDictionary",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"mergeSortComparator",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"rankSortStrings",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"collateStringRanks",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return k}});const ne=B("packages/core/src/compute/handle.js"),A=ne.bitReader,V=ne.dictRanks,U=ne.dictSize,I=ne.identity,J=ne.isMissing,H=ne.presenceReader,L=ne.rowCount,Y=ne.valueComparator,_=ne.valueReader,O=new Uint32Array(0),v=new ArrayBuffer(8),b=new Float64Array(v),c=new Uint32Array(v),g=(b[0]=-1,(c[1]&2147483648)!==0?1:0),o=g===1?0:1;function t(C,x){b[0]=C;let j=c[g],T=c[o];(j&2147483648)!==0?(j=~j>>>0,T=~T>>>0):j=(j^2147483648)>>>0,x[0]=T,x[1]=j}function s(C,x,j,T){if(T<2)return C;const F=new Uint32Array(256*8);for(let ee=0;ee<T;ee++){const re=x[ee],ie=j[ee];F[re&255]++,F[256+(re>>>8&255)]++,F[512+(re>>>16&255)]++,F[768+(re>>>24&255)]++,F[1024+(ie&255)]++,F[1280+(ie>>>8&255)]++,F[1536+(ie>>>16&255)]++,F[1792+(ie>>>24&255)]++}let $=C,D=x,z=j,G=new Uint32Array(T),N=new Uint32Array(T),Z=new Uint32Array(T);const Q=new Uint32Array(256);for(let ee=0;ee<8;ee++){const re=ee<<8,ie=(ee&3)<<3,ce=ee>=4;let ve=!1;for(let Oe=0;Oe<256;Oe++)if(F[re+Oe]===T){ve=!0;break}if(ve)continue;let he=0;for(let Oe=0;Oe<256;Oe++)Q[Oe]=he,he+=F[re+Oe];for(let Oe=0;Oe<T;Oe++){const Le=D[Oe],fe=z[Oe],ae=(ce?fe:Le)>>>ie&255,ke=Q[ae]++;G[ke]=$[Oe],N[ke]=Le,Z[ke]=fe}let ye=$;$=G,G=ye,ye=D,D=N,N=ye,ye=z,z=Z,Z=ye}return $}function l(C,x,j){if(j<2)return C;const T=new Uint32Array(256*4);for(let N=0;N<j;N++){const Z=x[N];T[Z&255]++,T[256+(Z>>>8&255)]++,T[512+(Z>>>16&255)]++,T[768+(Z>>>24&255)]++}let F=C,$=x,D=new Uint32Array(j),z=new Uint32Array(j);const G=new Uint32Array(256);for(let N=0;N<4;N++){const Z=N<<8,Q=N<<3;let ee=!1;for(let ce=0;ce<256;ce++)if(T[Z+ce]===j){ee=!0;break}if(ee)continue;let re=0;for(let ce=0;ce<256;ce++)G[ce]=re,re+=T[Z+ce];for(let ce=0;ce<j;ce++){const ve=$[ce],he=G[ve>>>Q&255]++;D[he]=F[ce],z[he]=ve}let ie=F;F=D,D=ie,ie=$,$=z,z=ie}return F}function u(C,x,j,T){const F=new Uint32Array(T+1);for(let z=0;z<j;z++)F[x[z]]++;let $=0;for(let z=0;z<=T;z++){const G=F[z];F[z]=$,$+=G}const D=new Uint32Array(j);for(let z=0;z<j;z++)D[F[x[z]]++]=C[z];return D}function n(C,x,j,T){return j<2?C:T<=65536||T<=j*2?u(C,x,j,T):l(C,x,j)}function p(C,x){return C.length===x&&C.byteOffset===0?C:Uint32Array.prototype.slice.call(C,0,x)}function r(C,x,j=!1){const T=x||I(C.length),F=T.length;if(F<2)return Uint32Array.from(T);const $=new Uint32Array(F),D=new Uint32Array(F),z=new Uint32Array(F),G=new Uint32Array(F),N=new Uint32Array(2);let Z=0,Q=0;for(let ie=0;ie<F;ie++){const ce=T[ie],ve=C[ce];if(Number.isNaN(ve)){G[Q++]=ce;continue}t(ve,N),j?(D[Z]=~N[0]>>>0,z[Z]=~N[1]>>>0):(D[Z]=N[0],z[Z]=N[1]),$[Z++]=ce}const ee=s($.subarray(0,Z),D.subarray(0,Z),z.subarray(0,Z),Z);if(Q===0)return p(ee,Z);const re=new Uint32Array(F);return re.set(ee.subarray(0,Z),0),re.set(G.subarray(0,Q),Z),re}function i(C,x,j=!1){const T=x||I(C.length),F=T.length;if(F<2)return Uint32Array.from(T);const $=Uint32Array.from(T),D=new Uint32Array(F);for(let z=0;z<F;z++){const G=(C[$[z]]^2147483648)>>>0;D[z]=j?~G>>>0:G}return p(l($,D,F),F)}function d(C,x,j={}){const T=x||I(L(C,j)),F=T.length;if(F<2)return Uint32Array.from(T);const $=V(C.dict,j.locale),D=C.values,z=H(C),G=Math.max(U(C.dict),$.length),N=G,Z=Uint32Array.from(T),Q=new Uint32Array(F),ee=!!j.descending;for(let re=0;re<F;re++){const ie=Z[re];let ce=z&&z(ie)===0?N:$[D[ie]];ce===void 0&&(ce=N),Q[re]=ee?N-ce:ce}return p(n(Z,Q,F,G+1),F)}function h(C,x,j){const T=x.length;let F=Uint32Array.from(x);if(T<2)return F;let $=new Uint32Array(T);for(let D=1;D<T;D<<=1){for(let G=0;G<T;G+=D<<1){const N=Math.min(G+D,T),Z=Math.min(G+(D<<1),T);let Q=G,ee=N,re=G;for(;Q<N&&ee<Z;)$[re++]=j(C[F[Q]],C[F[ee]])<=0?F[Q++]:F[ee++];for(;Q<N;)$[re++]=F[Q++];for(;ee<Z;)$[re++]=F[ee++]}const z=F;F=$,$=z}return F}function a(C,x,j){const T=A(C.values),F=x.length,$=new Uint32Array(F),D=j?1:0;let z=0;for(let G=0;G<F;G++)T(x[G])===D&&($[z++]=x[G]);for(let G=0;G<F;G++)T(x[G])!==D&&($[z++]=x[G]);return $}function y(C,x){const j=C.values,T=C.kind;if((T==="object"||T===void 0)&&(Array.isArray(j)||ArrayBuffer.isView(j))&&!C.presence)return j;const $=_(C),D=new Array(L(C)||0);for(let z=0;z<x.length;z++){const G=x[z];D[G]=$(G)}return D}function f(C,x){for(let j=0;j<x.length;j++)if(typeof C[x[j]]!="string")return!1;return!0}function m(C,x,j,T,F){const $=C.length,D=Uint32Array.from(C);if($<2||T<1)return D;const z=new Uint32Array($),G=T-1;for(let N=0;N<$;N++){const Z=j[x[N]];z[N]=F?G-Z:Z}return p(n(D,z,$,T),$)}function w(C,x,j){const T=Y(j),F=new Array(x);for(let D=0;D<x;D++)F[D]=D;F.sort((D,z)=>T(C[D],C[z])||D-z);const $=new Uint32Array(x);for(let D=0;D<x;D++)$[F[D]]=D;return $}function S(C,x,j){const T=x.length,F=new Map,$=[],D=new Uint32Array(T);for(let N=0;N<T;N++){const Z=C[x[N]];let Q=F.get(Z);Q===void 0&&(Q=$.length,F.set(Z,Q),$.push(Z)),D[N]=Q}const z=$.length,G=w($,z,j.locale);return m(x,D,G,z,!!j.descending)}function M(C,x,j){const T=y(C,x);if(x.length>=2&&f(T,x)){const D=C.stringRank;return D&&D.version===C.version&&D.usable(x,T,j.locale)?D.sort(x,j):S(T,x,j)}const F=Y(j.locale),$=j.descending?(D,z)=>F(z,D):F;return h(T,x,$)}function X(C,x,j){const T=y(C,x),F=j.compare,D=!!j.descending?(z,G)=>-F(z,G,void 0,void 0,!0):(z,G)=>F(z,G,void 0,void 0,!1);return h(T,x,D)}function q(C,x){const j=x.length,T=H(C),F=C.values,$=C.kind==="float64"&&!!F,D=C.kind==="object"||C.kind==="multi"||C.kind===void 0;if(!T&&!$&&!D)return{present:x,absent:O};const z=new Uint32Array(j),G=new Uint32Array(j);let N=0,Z=0;if(T&&$)for(let Q=0;Q<j;Q++){const ee=x[Q];T(ee)===1&&!Number.isNaN(F[ee])?z[N++]=ee:G[Z++]=ee}else if($&&!T)for(let Q=0;Q<j;Q++){const ee=x[Q];Number.isNaN(F[ee])?G[Z++]=ee:z[N++]=ee}else if(T&&!D)for(let Q=0;Q<j;Q++){const ee=x[Q];T(ee)===1?z[N++]=ee:G[Z++]=ee}else{const Q=_(C);for(let ee=0;ee<j;ee++){const re=x[ee];J(Q(re))?G[Z++]=re:z[N++]=re}}return Z===0?{present:x,absent:O}:{present:z.subarray(0,N),absent:G.subarray(0,Z)}}function K(C,x,j){if(x.length===0)return C;const T=new Uint32Array(C.length+x.length);return j?(T.set(x,0),T.set(C,x.length)):(T.set(C,0),T.set(x,C.length)),T}function P(C,x,j={}){const T=x||I(L(C,j));if(!C||T.length<2)return Uint32Array.from(T);const{present:F,absent:$}=q(C,T);if(F.length===0)return Uint32Array.from(T);const D=!!j.descending;let z;if(typeof j.compare=="function")z=X(C,F,j);else switch(C.kind){case"float64":z=r(C.values,F,D);break;case"int32":z=i(C.values,F,D);break;case"dictionary":z=d(C,F,j);break;case"bitset":z=a(C,F,D);break;default:z=M(C,F,j);break}return K(z,$,!!j.nullsFirst)}function k(C,x,j,T={}){const F=x||[],$=F.length&&(F[0].handle||E(C,F[0].col))||C&&C[0];let D=j||I(L($,T));for(let z=F.length-1;z>=0;z--){const G=F[z],N=G.handle||E(C,G.col)||C&&C[z];N&&(D=P(N,D,{descending:G.descending!==void 0?!!G.descending:G.dir==="desc",nullsFirst:!!G.nullsFirst,locale:G.locale!==void 0?G.locale:T.locale,compare:G.compare}))}return D instanceof Uint32Array?D:Uint32Array.from(D)}function E(C,x){if(!(!C||x===void 0)){for(let j=0;j<C.length;j++)if(C[j]&&C[j].id===x)return C[j]}}}),ze("packages/core/src/store/stringrank.js",function(e,B){"use strict";Object.defineProperty(e,"DEFAULT_MAX_DISTINCT",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"StringRankIndex",{enumerable:!0,get:function(){return I}});const ne=B("packages/core/src/compute/sort.js"),A=ne.collateStringRanks,V=ne.rankSortStrings,U=1e5;class I{#e=[];#t=new Map;#n;#r=0;#s=0;#i=-1;#a;#l=!1;#o=null;#c=-1;#u="\0";constructor(H=U){this.#a=H>0?H:U,this.#n=new Uint32Array(0)}get version(){return this.#i}set version(H){this.#i=H}get generation(){return this.#s}get size(){return this.#e.length}get capped(){return this.#l}get length(){return this.#r}get bytes(){let H=this.#n.byteLength;const L=this.#e;for(let Y=0;Y<L.length;Y++)H+=L[Y].length*2+24;return H}#f(H,L){const Y=this.#t.get(H);if(Y!==void 0)return Y;if(this.#l)return-1;if(L&&this.#e.length>=this.#a)return this.#l=!0,-1;const _=this.#e.length;return this.#e.push(H),this.#t.set(H,_),this.#s++,_}build(H,L){const Y=L|0;this.#e=[],this.#t=new Map,this.#s=0,this.#l=!1,this.#o=null,this.#c=-1,this.#n=new Uint32Array(Y);for(let _=0;_<Y;_++){const O=H[_],v=typeof O=="string"?this.#f(O,!1):-1;this.#n[_]=v<0?0:v}this.#r=Y}append(H,L,Y){const _=(L|0)+(Y|0);if(_>this.#n.length){const O=new Uint32Array(_);O.set(this.#n.subarray(0,this.#r)),this.#n=O}for(let O=L|0;O<_;O++){const v=H[O],b=typeof v=="string"?this.#f(v,!0):-1;this.#n[O]=b<0?0:b}this.#r=Math.max(this.#r,_)}ranks(H){const L=H||"";if(this.#o&&this.#c===this.#s&&this.#u===L)return this.#o;const Y=A(this.#e,this.#e.length,H);return this.#o=Y,this.#c=this.#s,this.#u=L,Y}usable(H,L,Y){if(this.#l||this.#e.length===0)return!1;const _=this.#n,O=this.#e,v=this.#r;for(let b=0;b<H.length;b++){const c=H[b];if(c>=v||O[_[c]]!==L[c])return!1}return!0}sort(H,L){const Y=this.ranks(L.locale),_=this.#e.length,O=H.length,v=new Uint32Array(O),b=this.#n;for(let c=0;c<O;c++)v[c]=b[H[c]];return V(H,v,Y,_,!!L.descending)}}}),ze("packages/core/src/store/columnstore.js",function(e,B){"use strict";Object.defineProperty(e,"REMOVED",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"toFloat",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ColumnHandle",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"ColumnStore",{enumerable:!0,get:function(){return a}});const A=B("packages/core/src/internal/warn.js").warnOnce,U=B("packages/core/src/internal/predicates.js").isFunction,J=B("packages/core/src/internal/paths.js").pathGetter,L=B("packages/core/src/store/bitset.js").Bitset,_=B("packages/core/src/store/dictionary.js").Dictionary,v=B("packages/core/src/store/multivalue.js").MultiValue,c=B("packages/core/src/store/stringrank.js").StringRankIndex,g=4294967295,o=1024,t=5e3,s=.2,l=new Set(["float64","int32","bitset","dictionary","object","multi"]);function u(y){return y==null}function n(y){return typeof y=="number"?y:y instanceof Date?y.getTime():typeof y=="boolean"?y?1:0:Number(y)}function p(y){const f=n(y);return Number.isFinite(f)?f|0:0}function r(y){return u(y)?[]:Array.isArray(y)?y:[y]}function i(y,f){switch(y.kind){case"float64":case"int32":return y.buf[f];case"bitset":return y.bits.get(f)===1;case"dictionary":return y.dict.valueOf(y.buf[f]);case"multi":{const m=y.mv.at(f),w=new Array(m.length);for(let S=0;S<m.length;S++)w[S]=y.dict.valueOf(m[S]);return w}default:return y.buf[f]}}function d(y,f){switch(y.kind){case"float64":case"int32":return y.values[f];case"bitset":return(y.values[f>>3]&1<<(f&7))!==0;case"dictionary":return(y.table||[])[y.values[f]];case"multi":{const m=y.offsets[f],w=y.offsets[f+1],S=y.table||[],M=new Array(w-m);for(let X=m;X<w;X++)M[X-m]=S[y.values[X]];return M}default:return y.values[f]}}class h{#e;#t;#n;#r;#s;#i;#a;#l=!1;#o=null;#c=null;#u=null;#f=null;#d=null;#h;#p;#m=-1;#g=null;#b=0;#y=0;#S=null;#w=null;#A=!1;constructor(f,m){this.#e=f.id;const w=l.has(f.kind)?f.kind:"object";f.kind&&!l.has(f.kind)&&A(`store.kind.${f.id}`,`column "${f.id}" declares unknown storage kind "${f.kind}"; falling back to object`),this.#n=w,this.#t=w,this.#r=f.nullable!==!1,this.#a=f.dictionary??null,this.#i=m,this.#s=U(f.read)?f.read:J(f.field||f.id),this.#h=f.stringRankIndex!=="off",this.#p=typeof f.stringRankMaxDistinct=="number"?f.stringRankMaxDistinct:0,this.#S=new Map}get id(){return this.#e}get kind(){return this.#l?this.#t:"object"}get target(){return this.#n}get nullable(){return this.#r}get values(){return this.#A?null:this.#l?this.#t==="bitset"?this.#c.words:this.#t==="multi"?this.#u.values:this.#o:this.#T().values}get presence(){return this.#A||!this.#r?null:this.#l?this.#g:this.#T().presence}get dict(){return this.#A||!this.#l?null:this.#t==="dictionary"||this.#t==="multi"?this.#f:null}get stringRank(){if(this.#A||!this.#h||this.kind!=="object")return null;const f=this.values,m=this.#i.physical();if(!f||m===0)return null;if(this.#d===null){if(typeof f[0]!="string")return null;const w=new c(this.#v());return w.build(f,m),w.version=this.#y,this.#d=w,this.#m=this.#y,w.capped?null:w}return this.#d.length<m&&this.#d.append(f,this.#d.length,m-this.#d.length),this.#d.version=this.#y,this.#m=this.#y,this.#d.capped?null:this.#d}#v(){return this.#p}#C(){this.#d=null,this.#m=-1}get offsets(){return this.#A||!this.#l||this.#t!=="multi"?null:this.#u.offsets}get version(){return this.#y}get bytes(){let f=0;return this.#o&&(f+=this.#o.byteLength??this.#o.length*8),this.#c&&(f+=this.#c.bytes),this.#u&&(f+=this.#u.bytes),this.#g&&(f+=this.#g.bytes),this.#f&&(f+=this.#f.bytes),this.#S&&(f+=this.#S.size*24),f}get(f){if(!this.#A&&!(f<0||f>=this.#i.physical())){if(!this.#l)return this.#E(f);if(this.#r&&this.#g.get(f)===0)return null;switch(this.#t){case"float64":case"int32":return this.#o[f];case"bitset":return this.#c.get(f)===1;case"dictionary":return this.#f.valueOf(this.#o[f]);case"multi":{const m=this.#u.at(f),w=new Array(m.length);for(let S=0;S<m.length;S++)w[S]=this.#f.valueOf(m[S]);return w}default:return this.#o[f]}}}set(f,m){this.#A||(this.#l?this.#P(f,m):this.#S.set(f,m===void 0?null:m),this.#d&&this.#C(),this.#y++)}read(f){return this.#s(f)}appendColumn(f,m,w){if(this.#A||w<=0)return;if(!this.#l){this.#y++;return}const S=this.#s,M=this.#r,X=this.#g;let q=!1;switch(this.#t){case"float64":{const K=this.#o;for(let P=0;P<w;P++){const k=S(f[P]);if(typeof k=="number"){M&&X.set(m+P),K[m+P]=k;continue}const E=k==null;M?X.assign(m+P,!E):E&&(q=!0),K[m+P]=E?NaN:n(k)}break}case"int32":{const K=this.#o;for(let P=0;P<w;P++){const k=S(f[P]),E=k==null;M?X.assign(m+P,!E):E&&(q=!0),K[m+P]=E?0:p(k)}break}case"bitset":{const K=this.#c;for(let P=0;P<w;P++){const k=S(f[P]),E=k==null;M?X.assign(m+P,!E):E&&(q=!0),K.assign(m+P,!E&&!!k)}break}case"dictionary":{const K=this.#o,P=this.#f;for(let k=0;k<w;k++){const E=S(f[k]),C=E==null;M?X.assign(m+k,!C):C&&(q=!0),K[m+k]=C?0:P.codeOf(E)}break}case"multi":{const K=this.#u,P=this.#f;for(let k=0;k<w;k++){const E=S(f[k]),C=E==null;M?X.assign(m+k,!C):C&&(q=!0);const x=r(E),j=new Array(x.length);for(let T=0;T<x.length;T++)j[T]=P.codeOf(x[T]);K.write(m+k,j)}break}default:{const K=this.#o;for(let P=0;P<w;P++){const k=S(f[P]),E=k==null;M?X.assign(m+P,!E):E&&(q=!0),K[m+P]=E?null:k}break}}q&&A(`store.null.${this.#e}`,`column "${this.#e}" is declared non-nullable but received null; storing a filler value`),this.#d&&this.#t==="object"&&(this.#d.append(this.#o,m,w),this.#d.version=this.#y+1,this.#m=this.#y+1),this.#y++}appendPacked(f,m,w){if(this.#A||w<=0||!f)return;if(!this.#l){this.#y++;return}const S=this.#g,M=f.presence;if(S)if(M)for(let q=0;q<w;q++)S.assign(m+q,(M[q>>3]&1<<(q&7))!==0);else for(let q=0;q<w;q++)S.set(m+q);const X=f.kind===this.#t;if(X&&(this.#t==="float64"||this.#t==="int32")){this.#o.set(f.values,m),this.#y++;return}if(X&&this.#t==="bitset"){const q=f.values;for(let K=0;K<w;K++)this.#c.assign(m+K,(q[K>>3]&1<<(K&7))!==0);this.#y++;return}if(X&&this.#t==="dictionary"){const q=f.table||[],K=new Uint32Array(q.length);for(let C=0;C<q.length;C++)K[C]=this.#f.codeOf(q[C]);const P=f.values,k=this.#o,E=S;for(let C=0;C<w;C++){if(E&&(M&&(M[C>>3]&1<<(C&7))===0)){k[m+C]=0;continue}k[m+C]=K[P[C]]??0}this.#y++;return}if(X&&this.#t==="multi"){const q=f.table||[],K=new Uint32Array(q.length);for(let E=0;E<q.length;E++)K[E]=this.#f.codeOf(q[E]);const P=f.values,k=f.offsets;for(let E=0;E<w;E++){const C=k[E],x=k[E+1],j=new Array(x-C);for(let T=C;T<x;T++)j[T-C]=K[P[T]]??0;this.#u.write(m+E,j)}this.#y++;return}for(let q=0;q<w;q++){const K=M?(M[q>>3]&1<<(q&7))===0:f.kind==="object"?f.values[q]===null:!1;this.#P(m+q,K?null:d(f,q))}this.#y++}touch(){this.#y++}columnarise(f,m){if(this.#l||this.#A)return;const w=new Array(m);for(let S=0;S<m;S++)w[S]=this.#E(S);this.#t=this.#n,this.#l=!0,this.#O(f);for(let S=0;S<m;S++)this.#P(S,w[S]);this.#S.clear(),this.#w=null,this.#C(),this.#y++}grow(f){if(!(!this.#l||this.#A||f<=this.#b)){switch(this.#t){case"float64":case"int32":case"dictionary":{const m=new this.#o.constructor(f);m.set(this.#o),this.#o=m;break}case"bitset":this.#c.grow(f);break;case"multi":break;default:this.#o.length=f;break}this.#g&&this.#g.grow(f),this.#b=f,this.#y++}}convert(f){if(this.#A||!l.has(f)||(this.#n=f,!this.#l||f===this.#t))return!1;const m={kind:this.#t,buf:this.#o,bits:this.#c,mv:this.#u,dict:this.#f},w=this.#i.physical(),S=this.#g;this.#t=f,this.#O(this.#b);for(let M=0;M<w;M++){const X=S!==null&&S.get(M)===0;X&&f!=="multi"||this.#P(M,X?null:i(m,M))}return this.#C(),this.#y++,!0}compact(f,m,w){if(!this.#A){if(this.#C(),!this.#l){const S=this.#S;if(S.size){const M=new Map;for(const[X,q]of S)f[X]!==g&&M.set(f[X],q);this.#S=M}this.#w=null,this.#y++;return}switch(this.#t){case"float64":case"int32":case"dictionary":case"object":{const S=this.#o;for(let M=0;M<m;M++)f[M]!==g&&(S[f[M]]=S[M]);if(this.#t==="object")for(let M=w;M<m;M++)S[M]=void 0;break}case"bitset":{const S=this.#c;for(let M=0;M<m;M++)f[M]!==g&&S.assign(f[M],S.get(M)===1);for(let M=w;M<m;M++)S.clear(M);break}case"multi":this.#u.compact(f,w,g);break;default:break}if(this.#g){const S=this.#g;for(let M=0;M<m;M++)f[M]!==g&&S.assign(f[M],S.get(M)===1);for(let M=w;M<m;M++)S.clear(M)}this.#y++}}release(){this.#A||(this.#A=!0,this.#o=null,this.#c&&this.#c.release(),this.#c=null,this.#u&&this.#u.release(),this.#u=null,this.#g&&this.#g.release(),this.#g=null,this.#f=null,this.#d=null,this.#S=new Map,this.#w=null,this.#b=0,this.#y++)}#O(f){const m=Math.max(1,f);switch(this.#o=null,this.#c=null,this.#u=null,this.#t){case"float64":this.#o=new Float64Array(m);break;case"int32":this.#o=new Int32Array(m);break;case"bitset":this.#c=new L(m);break;case"dictionary":this.#o=new Uint32Array(m),this.#f=this.#f??new _(this.#a??[]);break;case"multi":this.#u=new v({rows:m,values:m}),this.#f=this.#f??new _(this.#a??[]);break;default:this.#o=new Array(m);break}this.#t!=="dictionary"&&this.#t!=="multi"&&(this.#f=null),this.#r&&(this.#g?this.#g.grow(m):this.#g=new L(m)),this.#b=m}#P(f,m){const w=u(m);switch(this.#r?this.#g.assign(f,!w):w&&A(`store.null.${this.#e}`,`column "${this.#e}" is declared non-nullable but received null; storing a filler value`),this.#t){case"float64":this.#o[f]=w?NaN:n(m);break;case"int32":this.#o[f]=w?0:p(m);break;case"bitset":this.#c.assign(f,!w&&!!m);break;case"dictionary":this.#o[f]=w?0:this.#f.codeOf(m);break;case"multi":{const S=r(m),M=new Array(S.length);for(let X=0;X<S.length;X++)M[X]=this.#f.codeOf(S[X]);this.#u.write(f,M);break}default:this.#o[f]=w?null:m;break}}#E(f){if(this.#S.has(f))return this.#S.get(f);const m=this.#s(this.#i.rowAt(f));return m===void 0?null:m}#T(){if(this.#w&&this.#w.version===this.#y)return this.#w;const f=this.#i.physical(),m=new Array(f),w=this.#r?new L(f):null;for(let S=0;S<f;S++){const M=this.#E(S);m[S]=M,w&&!u(M)&&w.set(S)}return this.#w={version:this.#y,values:m,presence:w},this.#w}}class a{#e;#t=new Map;#n=[];#r=[];#s=0;#i=0;#a=0;#l=0;#o=new L(0);#c=!1;#u=!0;#f;#d;#h;#p=!1;constructor(f,m={}){this.#e=Array.isArray(f)?f:[],this.#d=Math.max(1,m.initialCapacity??o),this.#u=m.retainSource!==!1,this.#f=this.#u?m.columnarBelow??t:0,this.#h=m.compactRatio??s;const w={rowAt:S=>this.#r[S],physical:()=>this.#s};for(const S of this.#e){if(!S||!S.id)continue;if(this.#t.has(S.id)){A(`store.dup.${S.id}`,`duplicate column id "${S.id}" in the store schema; ignoring the second`);continue}const M=new h(S,w);this.#t.set(S.id,M),this.#n.push(M)}this.#f<=0&&this.#b()}get count(){return this.#a}get physical(){return this.#s}get capacity(){return this.#c?this.#i:this.#r.length}get tombstones(){return this.#l}get columnar(){return this.#c}get destroyed(){return this.#p}get bytes(){let f=this.#o.bytes+this.#r.length*8;for(const m of this.#n)f+=m.bytes;return f}append(f){const m=this.#s;if(this.#p||!f)return{from:m,to:m};const w=f.length|0;if(w===0)return{from:m,to:m};if(this.#u)for(let M=0;M<w;M++)this.#r[m+M]=f[M];if(this.#s=m+w,this.#a+=w,this.#o.grow(this.#s),!this.#c){if(this.#s>=this.#f)this.#b();else for(const M of this.#n)M.touch();return{from:m,to:this.#s}}this.#m(this.#s);const S=this.#n;for(let M=0;M<S.length;M++)S[M].appendColumn(f,m,w);return{from:m,to:this.#s}}appendPacked(f,m){const w=this.#s;if(this.#p||!f)return{from:w,to:w};const S=f.count|0;if(S===0)return{from:w,to:w};if(this.#u&&m)for(let X=0;X<S;X++)this.#r[w+X]=m[X];this.#s=w+S,this.#a+=S,this.#o.grow(this.#s),this.#c||this.#b(),this.#m(this.#s);const M=new Map;for(const X of f.columns)M.set(X.id,X);for(const X of this.#n){const q=M.get(X.id);q?X.appendPacked(q,w,S):X.grow(this.#i)}return{from:w,to:this.#s}}source(f){if(this.#u)return this.#r[f];if(!(f<0||f>=this.#s))return this.#g(f)}setSource(f,m){this.#p||f<0||f>=this.#s||this.#u&&(this.#r[f]=m)}get(f,m){const w=this.#t.get(f);return w?w.get(m):void 0}set(f,m,w){if(this.#p||m<0||m>=this.#s)return;const S=this.#t.get(f);if(!S){A(`store.set.${f}`,`set() on unknown column "${f}"`);return}S.set(m,w)}remove(f){return this.#p||f<0||f>=this.#s||this.#o.get(f)===1?!1:(this.#o.set(f),this.#l++,this.#a--,!0)}live(f){return f<0||f>=this.#s?!1:this.#o.get(f)===0}compact(f={}){if(this.#p||this.#l===0||!f.force&&this.#l/this.#s<this.#h)return null;const m=this.#s,w=new Uint32Array(m);let S=0;for(let M=0;M<m;M++)w[M]=this.#o.get(M)===1?g:S++;for(const M of this.#n)M.compact(w,m,S);if(this.#u){const M=this.#r;for(let X=0;X<m;X++)w[X]!==g&&(M[w[X]]=M[X]);M.length=S}return this.#s=S,this.#a=S,this.#l=0,this.#o=new L(Math.max(this.#i,S)),w}column(f){return this.#t.get(f)}columns(){return this.#n.slice()}liveIndices(){const f=new Uint32Array(this.#a);if(this.#l===0){for(let w=0;w<this.#s;w++)f[w]=w;return f}let m=0;for(let w=0;w<this.#s;w++)this.#o.get(w)===0&&(f[m++]=w);return f}convert(f,m){const w=this.#t.get(f);return w?w.convert(m):!1}destroy(){if(!this.#p){this.#p=!0;for(const f of this.#n)f.release();this.#t.clear(),this.#n.length=0,this.#r.length=0,this.#o.release(),this.#s=0,this.#a=0,this.#l=0,this.#i=0}}#m(f){if(f<=this.#i)return;let m=this.#i||this.#d;for(;m<f;)m*=2;for(const w of this.#n)w.grow(m);this.#o.grow(m),this.#i=m}#g(f){const m={};for(const w of this.#n)m[w.id]=w.get(f);return m}#b(){if(this.#c)return;let f=this.#d;for(;f<this.#s;)f*=2;this.#c=!0,this.#i=f,this.#o.grow(f);for(const m of this.#n)m.columnarise(f,this.#s)}}}),ze("packages/core/src/store/pool.js",function(e,B){"use strict";Object.defineProperty(e,"MaskPool",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"sharedPool",{enumerable:!0,get:function(){return I}});const ne=64,A=8;function V(H){let L=ne;for(;L<H;)L*=2;return L}class U{#e=new Map;#t=new WeakSet;#n;#r=0;#s={acquired:0,reused:0,released:0};constructor(L={}){this.#n=L.limit??A}get bytes(){return this.#r}mask(L){const Y=new Uint8Array(this.#i(L),0,L);return Y.fill(0),Y}indices(L){return new Uint32Array(this.#i(L*4),0,L)}release(L){if(!L||!L.buffer)return!1;const Y=L.buffer;if(!this.#t.has(Y))return!1;this.#t.delete(Y),this.#s.released++;const _=Y.byteLength;let O=this.#e.get(_);return O||this.#e.set(_,O=[]),O.length>=this.#n||(O.push(Y),this.#r+=_),!0}releaseAll(L){for(const Y of L)this.release(Y)}clear(){this.#e.clear(),this.#r=0}stats(){return{...this.#s,retained:this.#r}}#i(L){const Y=V(L),_=this.#e.get(Y);this.#s.acquired++;let O;return _&&_.length?(O=_.pop(),this.#r-=Y,this.#s.reused++):O=new ArrayBuffer(Y),this.#t.add(O),O}}function I(){return J??=new U,J}let J=null}),ze("packages/core/src/compute/sortspec.js",function(e,B){"use strict";Object.defineProperty(e,"collationDescriptor",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"isPortableSort",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"isPortableSortSet",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"describeSortEntry",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"describeSort",{enumerable:!0,get:function(){return I}});function ne(J){return{locale:J===void 0?void 0:String(J),numeric:!0,sensitivity:"variant"}}function A(J){return!!J&&typeof J.compare!="function"}function V(J){if(!J)return!0;for(let H=0;H<J.length;H++)if(!A(J[H]))return!1;return!0}function U(J,H){const L=J.col!==void 0?J.col:J.handle&&J.handle.id,Y=J.locale!==void 0?J.locale:H;return{col:L,descending:J.descending!==void 0?!!J.descending:J.dir==="desc",nullsFirst:!!J.nullsFirst,collation:ne(Y)}}function I(J,H){const L=J||[],Y=new Array(L.length);for(let _=0;_<L.length;_++)Y[_]=U(L[_],H);return Y}}),ze("packages/core/src/compute/facet.js",function(e,B){"use strict";Object.defineProperty(e,"STRATEGIES",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"GRANULARITIES",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"facetKind",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"orderedReader",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"toNumeric",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"cardinalityOf",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"pickGranularity",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"floorTo",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"advance",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"computeBounds",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"countInto",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"bucketOf",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"facet",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return w}});const ne=B("packages/core/src/compute/handle.js"),A=ne.presenceReader,V=ne.valueReader,U=ne.dictSize,I=ne.dictValue,J=Object.freeze(["equal","quantile","log"]),H=Object.freeze(["hour","day","week","month","quarter","year"]),L=20,Y=50,_=1e4;function O(S,M){if(!S)return"none";const X=M;if(X&&(X.multi===!0||typeof X.items=="function"))return"category";const q=M&&M.base;if(q==="date"||q==="datetime"||q==="time"||q==="dateString")return"date";switch(S.kind){case"bitset":return"boolean";case"float64":case"int32":return"numeric";case"dictionary":return"category";case"multi":return"category";default:return q==="number"?"numeric":q==="boolean"?"boolean":q==="text"?"category":"none"}}function v(S){const M=S.values,X=S.kind;if((X==="float64"||X==="int32")&&M)return K=>M[K];const q=V(S);return K=>b(q(K))}function b(S){if(typeof S=="number")return S;if(S instanceof Date)return S.getTime();if(S==null||S==="")return NaN;if(typeof S=="boolean")return S?1:0;if(typeof S=="string"){const M=Number(S);if(Number.isFinite(M))return M;const X=Date.parse(S);return Number.isFinite(X)?X:NaN}return NaN}function c(S,M,X,q=Y){if(!S)return{cardinality:0,exact:!0};if(S.dict)return{cardinality:U(S.dict),exact:!0};if(S.kind==="bitset")return{cardinality:2,exact:!0};const K=V(S),P=M?M.length:X,k=new Set;for(let E=0;E<P;E++){const C=K(M?M[E]:E);if(C!=null&&(k.add(C),k.size>q))return{cardinality:k.size,exact:!1}}return{cardinality:k.size,exact:!0}}const g=36e5,o=864e5;function t(S,M=L){const X=Number.isFinite(S)&&S>0?S:0,q=Math.max(1,M)*2;return X/g<=q?"hour":X/o<=q?"day":X/(7*o)<=q?"week":X/(30*o)<=q?"month":X/(91*o)<=q?"quarter":"year"}function s(S,M){if(!Number.isFinite(S))return NaN;const X=new Date(S);switch(M){case"hour":return X.setMinutes(0,0,0),X.getTime();case"day":return X.setHours(0,0,0,0),X.getTime();case"week":{X.setHours(0,0,0,0);const q=(X.getDay()+6)%7;return X.setDate(X.getDate()-q),X.getTime()}case"month":return X.setDate(1),X.setHours(0,0,0,0),X.getTime();case"quarter":return X.setMonth(Math.floor(X.getMonth()/3)*3,1),X.setHours(0,0,0,0),X.getTime();default:return X.setMonth(0,1),X.setHours(0,0,0,0),X.getTime()}}function l(S,M){const X=new Date(S);switch(M){case"hour":X.setHours(X.getHours()+1);break;case"day":X.setDate(X.getDate()+1);break;case"week":X.setDate(X.getDate()+7);break;case"month":X.setMonth(X.getMonth()+1);break;case"quarter":X.setMonth(X.getMonth()+3);break;default:X.setFullYear(X.getFullYear()+1);break}return X.getTime()}function u(S,M,X){const q=v(S),K=A(S),P=M?M.length:X;let k=1/0,E=-1/0,C=0,x=0;for(let j=0;j<P;j++){const T=M?M[j]:j;if(K&&!K(T)){C++;continue}const F=q(T);if(!Number.isFinite(F)){C++;continue}F<k&&(k=F),F>E&&(E=F),x++}return{min:k,max:E,nulls:C,finite:x}}function n(S,M,X,q){const K=v(S),P=A(S),k=M?M.length:X,E=k>q?k/q:1,C=[];for(let j=0;j<k;j+=E){const T=M?M[Math.floor(j)]:Math.floor(j);if(P&&!P(T))continue;const F=K(T);Number.isFinite(F)&&C.push(F)}const x=Float64Array.from(C);return x.sort(),x}function p(S,M,X,q={}){const K=q.kind||O(S,q.type);return K==="none"||!S?{kind:"none",buckets:[],suppressed:"type"}:K==="boolean"?r(S,M,X,q):K==="category"?i(S,M,X,q):h(S,M,X,K,q)}function r(S,M,X,q={}){const K=A(S);let P=0;if(K){const E=M?M.length:X;for(let C=0;C<E;C++)K(M?M[C]:C)||P++}const k=[{value:!1,label:"false"},{value:!0,label:"true"}];return P>0&&q.blanks!==!1&&k.push({null:!0,label:"Empty"}),{kind:"boolean",buckets:k}}function i(S,M,X,q){const K=q.cardinalityLimit??Y,{cardinality:P}=c(S,M,X,K);if(P>K&&(q.aboveLimit||"suppress")==="suppress")return{kind:"category",buckets:[],suppressed:"cardinality",cardinality:P};const k=V(S),E=M?M.length:X,C=new Map;let x=0;for(let D=0;D<E;D++){const z=k(M?M[D]:D);if(z==null||z===""){x++;continue}if(Array.isArray(z)){if(!z.length){x++;continue}for(const G of z)C.set(G,(C.get(G)||0)+1);continue}C.set(z,(C.get(z)||0)+1)}let j=[...C.entries()];q.order==="alpha"?j.sort((D,z)=>String(D[0]).localeCompare(String(z[0]))):j.sort((D,z)=>z[1]-D[1]);let T=0,F=0;if(j.length>K){F=j.length-K;for(let D=K;D<j.length;D++)T+=j[D][1];j=j.slice(0,K)}const $=j.map(([D])=>({value:D,label:String(D)}));return T>0&&$.push({remainder:!0,label:`Other (${F} values)`}),x>0&&q.blanks!==!1&&$.push({null:!0,label:"Empty"}),{kind:"category",buckets:$,cardinality:P}}function d(S,M,X,q,K){const P=n(S,M,X,_),k=P.length;if(k<100)return null;const E=P[Math.floor(.01*k)],C=P[Math.ceil(.99*k)-1];return!(C>E)||K-q<=2*(C-E)?null:{lo:E,hi:C}}function h(S,M,X,q,K){const{min:P,max:k,nulls:E,finite:C}=u(S,M,X);if(!C)return{kind:q,buckets:E&&K.blanks!==!1?[{null:!0,label:"Empty"}]:[],empty:!0};const x=Math.max(1,Math.floor(K.buckets||L));let j=[];if(q==="date"){const F=H.includes(K.granularity)?K.granularity:t(k-P,x);let $=s(P,F);for(;$<=k&&j.length<4096;){const D=l($,F);if(!(D>$))break;j.push({from:$,to:D}),$=D}return{kind:q,buckets:a(j,K.blanks===!1?0:E),granularity:F}}const T=J.includes(K.strategy)?K.strategy:"equal";if(T==="quantile"){const F=n(S,M,X,_);if(F.length){const $=[F[0]];for(let D=1;D<x;D++){const z=F[Math.min(F.length-1,Math.floor(D/x*F.length))];z>$[$.length-1]&&$.push(z)}$.push(k);for(let D=0;D<$.length-1;D++)j.push({from:$[D],to:$[D+1]})}}else if(T==="log"&&P>0){const F=Math.log10(P),D=(Math.log10(k)-F)/x||1;for(let z=0;z<x;z++)j.push({from:10**(F+z*D),to:10**(F+(z+1)*D)})}if(!j.length&&T==="equal"){const F=d(S,M,X,P,k);if(F){const $=(F.hi-F.lo)/x;F.lo>P&&j.push({from:P,to:F.lo,overflow:"low"});for(let D=0;D<x;D++)j.push({from:F.lo+D*$,to:F.lo+(D+1)*$});j[j.length-1].to=F.hi,F.hi<k&&j.push({from:F.hi,to:k,overflow:"high"})}}if(!j.length){const F=(k-P)/x||1;for(let $=0;$<x;$++)j.push({from:P+$*F,to:P+($+1)*F})}return j[j.length-1].to=k,{kind:q,buckets:a(j,K.blanks===!1?0:E),strategy:T,min:P,max:k}}function a(S,M){return M>0?[...S,{null:!0,label:"Empty"}]:S}function y(S,M,X,q,K){const P=q&&q.buckets||[],k=K&&K.length>=P.length?K.subarray(0,P.length):new Uint32Array(P.length);if(k.fill(0),!S||!P.length)return k;const E=P.length-1,C=!!P[E]&&P[E].null===!0,x=M?M.length:X;if(q.kind==="boolean"){const D=V(S);for(let z=0;z<x;z++){const G=D(M?M[z]:z);if(G==null){C&&k[E]++;continue}k[G?1:0]++}return k}if(q.kind==="category"){const D=new Map;for(let N=0;N<P.length;N++)!P[N].null&&!P[N].remainder&&D.set(P[N].value,N);const z=P.findIndex(N=>N.remainder),G=V(S);for(let N=0;N<x;N++){const Z=G(M?M[N]:N);if(Z==null||Z===""){C&&k[E]++;continue}if(Array.isArray(Z)){if(!Z.length){C&&k[E]++;continue}for(const ee of Z){const re=D.get(ee);re!==void 0?k[re]++:z>=0&&k[z]++}continue}const Q=D.get(Z);Q!==void 0?k[Q]++:z>=0&&k[z]++}return k}const j=C?P.length-1:P.length,T=new Float64Array(j+1);for(let D=0;D<j;D++)T[D]=P[D].from;T[j]=j?P[j-1].to:0;const F=v(S),$=A(S);for(let D=0;D<x;D++){const z=M?M[D]:D;if($&&!$(z)){C&&k[E]++;continue}const G=F(z);if(!Number.isFinite(G)){C&&k[E]++;continue}const N=f(T,j,G);N>=0&&k[N]++}return k}function f(S,M,X){if(!M||X<S[0])return-1;if(X>=S[M])return X===S[M]?M-1:-1;let q=0,K=M-1;for(;q<K;){const P=q+K+1>>>1;X>=S[P]?q=P:K=P-1}return q}function m(S,M,X,q={}){const K=q.bounds||p(S,q.boundsIndices??M,X,q);return{bounds:K,counts:y(S,M,X,K)}}const w=m}),ze("packages/core/src/compute/pivotmatrix.js",function(e,B){"use strict";Object.defineProperty(e,"GRAND_PATH",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"resolveAxis",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"pivotMatrix",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"cellKey",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"marginKey",{enumerable:!0,get:function(){return s}});const A=B("packages/core/src/compute/handle.js").valueComparator,U=B("packages/core/src/compute/total.js").total,J=B("packages/core/src/compute/group.js").packKeys,H=B("packages/core/src/compute/pivot.js"),L=H.joinPath,Y=H.DEFAULT_PATH_SEPARATOR,_=H.DEFAULT_MAX_COLUMNS,O="";function v(l,u,n={}){const p=n.separator||Y,r=l||[],i=u instanceof Uint32Array?u:Uint32Array.from(u||[]),d=i.length;if(r.length===0)return{tuples:[[]],paths:[O],buckets:[i]};const{keyOf:h,readers:a}=J(r,i,0),y=new Map,f=[],m=[],w=[];for(let P=0;P<d;P++){const k=i[P],E=h(k);let C=y.get(E);if(C===void 0){C=f.length,y.set(E,C),m.push(E);const x=new Array(a.length);for(let j=0;j<a.length;j++)x[j]=a[j](k);f.push(x),w.push([])}w[C].push(k)}const S=A(n.locale),M=f.map((P,k)=>k);M.sort((P,k)=>{const E=f[P],C=f[k];for(let x=0;x<E.length;x++){const j=b(E[x],C[x],S);if(j!==0)return j}return P-k});const X=new Array(M.length),q=new Array(M.length),K=new Array(M.length);for(let P=0;P<M.length;P++){const k=M[P];X[P]=f[k],q[P]=L(f[k],p),K[P]=Uint32Array.from(w[k])}return{tuples:X,paths:q,buckets:K}}function b(l,u,n){const p=l==null,r=u==null;return p||r?p&&r?0:p?1:-1:n(l,u)}function c(l,u,n){const p=[];for(let r=0;r<l.length;r++)n.has(l[r])&&p.push(l[r]);return Uint32Array.from(p)}function g(l,u,n,p){return{value:u.length?U(l,u,n,p):null,leaves:u,count:u.length}}function o(l){const u=l&&l.opts||{},n=u.separator||Y,p=u.totalContext||{locale:u.locale},r=(l.measures||[]).filter(q=>q&&q.handle),i=l.leaves instanceof Uint32Array?l.leaves:Uint32Array.from(l.leaves||[]),d=v(l.rowHandles||[],i,{...u,separator:n}),h=v(l.columnHandles||[],i,{...u,separator:n}),a=u.maxColumns===void 0?_:u.maxColumns,y=h.paths.length*Math.max(1,r.length),f=new Map;if(a&&y>a)return{rowAxis:d,columnAxis:h,measures:r.map(q=>({colId:q.colId,fn:q.fn})),body:f,rowMargin:f,columnMargin:f,grand:f,columns:y,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${y} columns, above pivot.maxColumns of ${a}. Narrow the pivot columns or raise the limit.`,columns:y,maxColumns:a}};const m=new Map,w=new Map,S=new Map,M=new Map,X=h.buckets.map(q=>new Set(q));for(let q=0;q<h.paths.length;q++){const K=h.buckets[q],P=h.paths[q];for(const k of r)S.set(s(P,k.colId),g(k.handle,K,k.fn,p))}for(let q=0;q<d.paths.length;q++){const K=d.buckets[q],P=d.paths[q];for(const k of r)w.set(s(P,k.colId),g(k.handle,K,k.fn,p));for(let k=0;k<h.paths.length;k++){const E=c(K,h.buckets[k],X[k]);if(E.length===0)continue;const C=h.paths[k];for(const x of r)m.set(t(P,C,x.colId),g(x.handle,E,x.fn,p))}}for(const q of r)M.set(q.colId,g(q.handle,i,q.fn,p));return{rowAxis:d,columnAxis:h,measures:r.map(q=>({colId:q.colId,fn:q.fn})),body:m,rowMargin:w,columnMargin:S,grand:M,columns:y,error:null}}function t(l,u,n){return`${l}\0${u}\0${n}`}function s(l,u){return`${l}\0${u}`}}),ze("packages/core/src/compute/reference.js",function(e,B){"use strict";Object.defineProperty(e,"referenceValue",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"referenceSort",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"referenceFilter",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"referencePasses",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"referenceGroup",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"referenceTotal",{enumerable:!0,get:function(){return o}});const A=B("packages/core/src/internal/paths.js").getPath,V=B("packages/core/src/compute/handle.js"),U=V.isMissing,I=V.valueComparator,H=B("packages/core/src/compute/filter.js").testValue,L="",Y="\0";function _(l,u){const n=u.includes(".")?A(l,u):l?.[u];return n===void 0?null:n}function O(l,u,n={}){const p=u||[];let r=l.map((i,d)=>d);if(p.length===0)return r;for(let i=p.length-1;i>=0;i--)r=v(l,r,p[i],n);return r}function v(l,u,n,p){const r=n.locale!==void 0?n.locale:p.locale,i=I(r),d=n.descending!==void 0?!!n.descending:n.dir==="desc",h=[],a=[];for(const m of u){const w=_(l[m],n.col);U(w)?a.push(m):h.push(m)}const y=new Map;for(let m=0;m<h.length;m++)y.set(h[m],m);const f=(m,w)=>{const S=_(l[m],n.col),M=_(l[w],n.col);let X;return typeof n.compare=="function"?(X=n.compare(S,M,l[m],l[w],d),d&&(X=-X)):X=d?i(M,S):i(S,M),X!==0?X:y.get(m)-y.get(w)};return h.sort(f),n.nullsFirst?a.concat(h):h.concat(a)}function b(l,u,n={}){const p=[];for(let r=0;r<l.length;r++)c(l[r],u,n,r)&&p.push(r);return p}function c(l,u,n,p){if(!u)return!0;if(Array.isArray(u.conditions)){const r=u.conditions.filter(d=>d!=null);if(r.length===0)return!0;if(u.op==="or")return r.some(d=>c(l,d,n,p));const i=r.every(d=>c(l,d,n,p));return u.op==="not"?!i:i}return u.col===void 0&&typeof n.custom=="function"?!!n.custom(u,l,p):H(_(l,u.col),u,n.locale)}function g(l,u,n,p){const r=n||l.map((a,y)=>y),i=new Map,d=[],h=[];for(const a of r){const y=u.map((w,S)=>{const M=_(l[a],w);return p&&p[S]?p[S](M):M}),f=y.map(w=>w==null?Y:String(w)).join(L);let m=i.get(f);m===void 0&&(m=d.length,i.set(f,m),d.push(y),h.push([])),h[m].push(a)}return{keys:d,buckets:h}}function o(l,u,n={}){const p=I(n.locale),r=l.filter(d=>!U(d)),i=r.map(t).filter(d=>d!==null);switch(u){case"count":return l.length;case"countValues":return r.length;case"sum":return i.reduce((d,h)=>d+h,0);case"avg":return r.length===0?null:i.reduce((d,h)=>d+h,0)/r.length;case"min":return r.length===0?null:r.reduce((d,h)=>p(h,d)<0?h:d);case"max":return r.length===0?null:r.reduce((d,h)=>p(h,d)>0?h:d);case"first":return l.length===0?null:s(l[0]);case"last":return l.length===0?null:s(l[l.length-1]);default:return null}}function t(l){if(typeof l=="number")return Number.isNaN(l)?null:l;if(l==null||l===""||typeof l=="boolean")return null;if(l instanceof Date)return l.getTime();const u=Number(l);return Number.isNaN(u)?null:u}function s(l){return l===void 0?null:l}}),ze("packages/core/src/compute/index.js",function(e,B){"use strict";const ne=B("packages/core/src/compute/sort.js");Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return ne.sortColumn}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return ne.sortMulti}}),Object.defineProperty(e,"radixSortFloat64",{enumerable:!0,get:function(){return ne.radixSortFloat64}}),Object.defineProperty(e,"radixSortInt32",{enumerable:!0,get:function(){return ne.radixSortInt32}}),Object.defineProperty(e,"rankSortDictionary",{enumerable:!0,get:function(){return ne.rankSortDictionary}}),Object.defineProperty(e,"mergeSortComparator",{enumerable:!0,get:function(){return ne.mergeSortComparator}}),Object.defineProperty(e,"collateStringRanks",{enumerable:!0,get:function(){return ne.collateStringRanks}}),Object.defineProperty(e,"rankSortStrings",{enumerable:!0,get:function(){return ne.rankSortStrings}});const A=B("packages/core/src/compute/sortspec.js");Object.defineProperty(e,"collationDescriptor",{enumerable:!0,get:function(){return A.collationDescriptor}}),Object.defineProperty(e,"isPortableSort",{enumerable:!0,get:function(){return A.isPortableSort}}),Object.defineProperty(e,"isPortableSortSet",{enumerable:!0,get:function(){return A.isPortableSortSet}}),Object.defineProperty(e,"describeSortEntry",{enumerable:!0,get:function(){return A.describeSortEntry}}),Object.defineProperty(e,"describeSort",{enumerable:!0,get:function(){return A.describeSort}});const V=B("packages/core/src/compute/filter.js");Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return V.evaluateFilters}}),Object.defineProperty(e,"evaluateCondition",{enumerable:!0,get:function(){return V.evaluateCondition}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return V.compact}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return V.testValue}}),Object.defineProperty(e,"compilePredicate",{enumerable:!0,get:function(){return V.compilePredicate}}),Object.defineProperty(e,"releaseMask",{enumerable:!0,get:function(){return V.releaseMask}}),Object.defineProperty(e,"pruneColumn",{enumerable:!0,get:function(){return V.pruneColumn}}),Object.defineProperty(e,"mentionsColumn",{enumerable:!0,get:function(){return V.mentionsColumn}});const U=B("packages/core/src/compute/group.js");Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return U.groupByColumns}}),Object.defineProperty(e,"packKeys",{enumerable:!0,get:function(){return U.packKeys}});const I=B("packages/core/src/compute/facet.js");Object.defineProperty(e,"facet",{enumerable:!0,get:function(){return I.facet}}),Object.defineProperty(e,"computeBounds",{enumerable:!0,get:function(){return I.computeBounds}}),Object.defineProperty(e,"countInto",{enumerable:!0,get:function(){return I.countInto}}),Object.defineProperty(e,"bucketOf",{enumerable:!0,get:function(){return I.bucketOf}}),Object.defineProperty(e,"facetKind",{enumerable:!0,get:function(){return I.facetKind}}),Object.defineProperty(e,"cardinalityOf",{enumerable:!0,get:function(){return I.cardinalityOf}}),Object.defineProperty(e,"pickGranularity",{enumerable:!0,get:function(){return I.pickGranularity}}),Object.defineProperty(e,"floorTo",{enumerable:!0,get:function(){return I.floorTo}}),Object.defineProperty(e,"advance",{enumerable:!0,get:function(){return I.advance}}),Object.defineProperty(e,"STRATEGIES",{enumerable:!0,get:function(){return I.STRATEGIES}}),Object.defineProperty(e,"GRANULARITIES",{enumerable:!0,get:function(){return I.GRANULARITIES}}),Object.defineProperty(e,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return I.DEFAULT_BUCKETS}}),Object.defineProperty(e,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return I.DEFAULT_CARDINALITY_LIMIT}}),Object.defineProperty(e,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return I.QUANTILE_SAMPLE}});const J=B("packages/core/src/compute/total.js");Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return J.TOTAL_FNS}}),Object.defineProperty(e,"TOTAL_LABELS",{enumerable:!0,get:function(){return J.TOTAL_LABELS}}),Object.defineProperty(e,"totalLabel",{enumerable:!0,get:function(){return J.totalLabel}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return J.total}}),Object.defineProperty(e,"collectValues",{enumerable:!0,get:function(){return J.collectValues}});const H=B("packages/core/src/compute/pivot.js");Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return H.pivot}}),Object.defineProperty(e,"resolvePivotKeys",{enumerable:!0,get:function(){return H.resolvePivotKeys}}),Object.defineProperty(e,"pivotKey",{enumerable:!0,get:function(){return H.pivotKey}}),Object.defineProperty(e,"joinPath",{enumerable:!0,get:function(){return H.joinPath}}),Object.defineProperty(e,"KEY_DELIMITER",{enumerable:!0,get:function(){return H.KEY_DELIMITER}}),Object.defineProperty(e,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return H.DEFAULT_PATH_SEPARATOR}}),Object.defineProperty(e,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return H.DEFAULT_MAX_COLUMNS}});const L=B("packages/core/src/compute/pivotmatrix.js");Object.defineProperty(e,"pivotMatrix",{enumerable:!0,get:function(){return L.pivotMatrix}}),Object.defineProperty(e,"resolveAxis",{enumerable:!0,get:function(){return L.resolveAxis}}),Object.defineProperty(e,"cellKey",{enumerable:!0,get:function(){return L.cellKey}}),Object.defineProperty(e,"marginKey",{enumerable:!0,get:function(){return L.marginKey}}),Object.defineProperty(e,"GRAND_PATH",{enumerable:!0,get:function(){return L.GRAND_PATH}});const Y=B("packages/core/src/compute/reference.js");Object.defineProperty(e,"referenceSort",{enumerable:!0,get:function(){return Y.referenceSort}}),Object.defineProperty(e,"referenceFilter",{enumerable:!0,get:function(){return Y.referenceFilter}}),Object.defineProperty(e,"referenceGroup",{enumerable:!0,get:function(){return Y.referenceGroup}}),Object.defineProperty(e,"referenceTotal",{enumerable:!0,get:function(){return Y.referenceTotal}}),Object.defineProperty(e,"referencePasses",{enumerable:!0,get:function(){return Y.referencePasses}}),Object.defineProperty(e,"referenceValue",{enumerable:!0,get:function(){return Y.referenceValue}});const _=B("packages/core/src/compute/handle.js");Object.defineProperty(e,"identity",{enumerable:!0,get:function(){return _.identity}}),Object.defineProperty(e,"rowCount",{enumerable:!0,get:function(){return _.rowCount}}),Object.defineProperty(e,"presenceReader",{enumerable:!0,get:function(){return _.presenceReader}}),Object.defineProperty(e,"bitReader",{enumerable:!0,get:function(){return _.bitReader}}),Object.defineProperty(e,"valueReader",{enumerable:!0,get:function(){return _.valueReader}}),Object.defineProperty(e,"valueComparator",{enumerable:!0,get:function(){return _.valueComparator}}),Object.defineProperty(e,"numericTotalOrder",{enumerable:!0,get:function(){return _.numericTotalOrder}}),Object.defineProperty(e,"dictRanks",{enumerable:!0,get:function(){return _.dictRanks}}),Object.defineProperty(e,"dictSize",{enumerable:!0,get:function(){return _.dictSize}}),Object.defineProperty(e,"dictValue",{enumerable:!0,get:function(){return _.dictValue}}),Object.defineProperty(e,"multiValue",{enumerable:!0,get:function(){return _.multiValue}}),Object.defineProperty(e,"isMissing",{enumerable:!0,get:function(){return _.isMissing}});const O=B("packages/core/src/compute/sketch.js");Object.defineProperty(e,"Welford",{enumerable:!0,get:function(){return O.Welford}}),Object.defineProperty(e,"Reservoir",{enumerable:!0,get:function(){return O.Reservoir}}),Object.defineProperty(e,"HyperLogLog",{enumerable:!0,get:function(){return O.HyperLogLog}}),Object.defineProperty(e,"SpaceSaving",{enumerable:!0,get:function(){return O.SpaceSaving}}),Object.defineProperty(e,"KLL",{enumerable:!0,get:function(){return O.KLL}}),Object.defineProperty(e,"hash32",{enumerable:!0,get:function(){return O.hash32}}),Object.defineProperty(e,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return O.SKETCH_BOUNDS}});const v=B("packages/core/src/compute/windowed.js");Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return v.Window}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return v.WINDOW_KINDS}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return v.openWindow}});const b=B("packages/core/src/compute/statistics.js");Object.defineProperty(e,"MAINTENANCE",{enumerable:!0,get:function(){return b.MAINTENANCE}}),Object.defineProperty(e,"APPROXIMATE",{enumerable:!0,get:function(){return b.APPROXIMATE}}),Object.defineProperty(e,"maintenanceOf",{enumerable:!0,get:function(){return b.maintenanceOf}});const c=B("packages/core/src/compute/anomaly.js");Object.defineProperty(e,"ANOMALY_METHODS",{enumerable:!0,get:function(){return c.ANOMALY_METHODS}}),Object.defineProperty(e,"modifiedZScores",{enumerable:!0,get:function(){return c.modifiedZScores}}),Object.defineProperty(e,"iqrFences",{enumerable:!0,get:function(){return c.iqrFences}}),Object.defineProperty(e,"mahalanobis",{enumerable:!0,get:function(){return c.mahalanobis}}),Object.defineProperty(e,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return c.ROLLING_ANOMALY_METHODS}}),Object.defineProperty(e,"rollingAnomalies",{enumerable:!0,get:function(){return c.rollingAnomalies}}),Object.defineProperty(e,"anomalyCondition",{enumerable:!0,get:function(){return c.anomalyCondition}});const g=B("packages/core/src/compute/forecast.js");Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return g.FORECAST_METHODS}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return g.forecast}})}),ze("packages/core/src/source/rows.js",function(e,B){"use strict";Object.defineProperty(e,"DEFAULT_ROW_HEIGHT",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"KEY_SEP",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"createRowFactory",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"RowFactory",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"pinnedRow",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"lazyRowView",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"groupPathElement",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"groupKey",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"groupPrefixKeys",{enumerable:!0,get:function(){return g}});const A=B("packages/core/src/internal/warn.js").warnOnce,U=B("packages/core/src/internal/predicates.js").isFunction,I=32,J="\0";function H(o){return new L(o)}class L{#e;#t;constructor(t){this.#e=U(t&&t.rowKey)?t.rowKey:null;const s=t&&t.config?t.config.rowHeight:void 0;this.#t=typeof s=="number"||U(s)?s:I}get keyed(){return this.#e!==null}keyOf(t,s){if(this.#e){const l=this.#e(t);if(l!=null)return String(l)}else A("source.rowKey.missing","no config.rowKey; falling back to index identity.","Row changes, streaming dedupe, selection persistence and remote reload are disabled.");return`#${s}`}heightOf(t){return U(this.#t)?Number(this.#t(t))||I:this.#t}leaf(t,s,l=0,u=null){const n={key:this.keyOf(t,s),data:t,level:l,parent:u,group:!1,expanded:!1,leafCount:1,height:0,index:null,selected:!1,physical:s};return n.height=this.heightOf(n),n}group(t){const s={key:c(t.keyPath||t.path),data:null,level:t.level,parent:t.parent||null,children:[],group:!0,expanded:t.expanded!==!1,leafCount:t.leafCount||0,height:0,index:null,selected:!1,physical:null,groupColumn:t.column,groupValue:t.value,groupPath:t.path,hasChildren:t.hasChildren!==!1};return t.totals&&(s.totals=t.totals),s.height=this.heightOf(s),s}footer(t){const s={key:`${t.key}${J}footer`,data:null,level:t.level,parent:t,group:!0,footer:!0,expanded:!1,leafCount:t.leafCount||0,height:0,index:null,selected:!1,physical:null,groupColumn:t.groupColumn,groupValue:t.groupValue,groupPath:t.groupPath,hasChildren:!1,totals:t.totals};return s.height=this.heightOf(s),s}detail(t,s){return{key:`${t.key}${J}detail`,data:t.data,level:t.level+1,parent:t,group:!1,detail:!0,expanded:!1,leafCount:0,height:s,index:null,selected:!1,physical:null,hasChildren:!1,masterKey:t.key}}grandTotal(t,s){const l={key:`${J}grandTotal`,data:null,level:0,parent:null,group:!0,grandTotal:!0,expanded:!1,leafCount:s,height:0,index:null,selected:!1,physical:null,groupPath:[],hasChildren:!1,totals:t};return l.height=this.heightOf(l),l}skeleton(t,s=0,l=!1){const u={key:`${J}pending${J}${t}`,data:null,level:s,parent:null,group:!1,expanded:!1,leafCount:1,height:0,index:t,selected:!1,physical:null,pending:!0};return l&&(u.loadError=!0),u.height=this.heightOf(u),u}}function Y(o,t,s,l){return{key:`${J}pinned${J}${s}${J}${t}`,data:o,level:0,parent:null,group:!1,expanded:!1,leafCount:0,height:l,index:null,selected:!1,physical:null,hasChildren:!1,pinned:s}}function _(o,t){return new Proxy([],{get(s,l,u){if(l==="length")return o();if(typeof l=="string"){const n=Number(l);if(Number.isInteger(n)&&n>=0)return t(n)}return Reflect.get(s,l,u)},has(s,l){if(typeof l=="string"){const u=Number(l);if(Number.isInteger(u)&&u>=0)return u<o()}return Reflect.has(s,l)}})}function O(o){return o==null?"":String(o)}const v="";function b(o){if(o==null)return v;const t=String(o);return t.startsWith(v)?v+t:t}function c(o){const t=o||[];let s="g";for(let l=0;l<t.length;l++)s+=J+b(t[l]);return s}function g(o){const t=new Array(o.length),s=[];for(let l=0;l<o.length;l++)s.push(o[l]),t[l]=c(s);return t}}),ze("packages/core/src/source/handles.js",function(e,B){"use strict";Object.defineProperty(e,"HandleProvider",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"createHandleProvider",{enumerable:!0,get:function(){return J}});const A=B("packages/core/src/internal/predicates.js").isFunction,U=B("packages/core/src/internal/warn.js").warnOnce;class I{#e;#t;#n;#r=new Map;#s=0;constructor(L,Y,_){this.#e=L,this.#t=Y,this.#n=A(_)?_:()=>!1}get store(){const L=this.#e.store;return L&&A(L.column)?L:null}invalidate(){this.#s++}handle(L){const Y=this.store;if(Y){const b=Y.column(L);if(b)return b}const _=this.#r.get(L);if(_&&_.builtAt===this.#s)return _.handle;const O=this.#i(L);if(!O)return;if(Y&&this.#n()){U(`source.dropped.${L}`,`column "${L}" cannot be served under ingest.dropSourceRows: it is an impure computed column (a shadow or a positional/rank column) that is never stored, so it can only be read from the caller's row objects — which dropSourceRows has released. Do not sort, filter, group or total on such a column with dropSourceRows enabled.`);return}const v=this.#a(O);return this.#r.set(L,{handle:v,builtAt:this.#s}),v}#i(L){const Y=this.#e.columns;return Y&&A(Y.get)?Y.get(L):void 0}#a(L){const Y=this.#t()||[],_=Y.length,O=new Array(_),v=A(L.getValue)?c=>L.getValue(c):c=>c?.[L.field||L.id];for(let c=0;c<_;c++)O[c]=Y[c]===void 0?void 0:v(Y[c]);const b=this.#s;return{id:L.id,kind:"object",nullable:!1,values:O,presence:null,dict:null,offsets:null,get(c){return O[c]},version:b}}}function J(H,L,Y){return new I(H,L,Y)}}),ze("packages/core/src/compute/incremental.js",function(e,B){"use strict";Object.defineProperty(e,"INCREMENTAL_FNS",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"INCREMENTAL_KINDS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"MAGNITUDE_LIMIT",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"isIncremental",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"RunningTotal",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Y}});const A=B("packages/core/src/store/columnstore.js").toFloat,V=Object.freeze(["sum","avg","countValues","min","max"]),U=Object.freeze(["float64"]),I=1e15;function J(_,O){return typeof _!="string"||!V.includes(_)?!1:!!O&&U.includes(O.kind)}function H(_){if(_==null)return null;const O=A(_);return Number.isNaN(O)?null:O}class L{#e;#t=0;#n=0;#r=0;#s=1/0;#i=-1/0;#a=!1;#l=!1;constructor(O){this.#e=O}get valid(){return this.#a&&!this.#l}get fn(){return this.#e}seed(O){this.#o();for(let v=0;v<O.length;v++){const b=H(O[v]);b!==null&&this.#c(b)}this.#a=!0}seedColumn(O,v,b){this.#o();for(let c=0;c<b.length;c++){const g=b[c];if(v&&v(g)===0)continue;const o=O[g];Number.isNaN(o)||this.#c(o)}this.#a=!0}#o(){this.#t=0,this.#n=0,this.#r=0,this.#s=1/0,this.#i=-1/0,this.#l=!1}#c(O){if(!Number.isFinite(O)){this.#l=!0;return}const v=this.#t+O;this.#n+=Math.abs(this.#t)>=Math.abs(O)?this.#t-v+O:O-v+this.#t,this.#t=v,this.#r++,O<this.#s&&(this.#s=O),O>this.#i&&(this.#i=O)}#u(O){const v=this.#t-O;this.#n+=Math.abs(this.#t)>=Math.abs(O)?this.#t-v-O:-O-v+this.#t,this.#t=v,this.#r--}update(O,v){if(!this.#a)return!1;const b=H(O),c=H(v);return b===null&&c===null?!0:b!==null&&!Number.isFinite(b)||c!==null&&!Number.isFinite(c)?!1:this.#e==="min"||this.#e==="max"?b===null||c===null?!1:this.#e==="min"?c<this.#s?(this.#s=c,!0):b>this.#s:c>this.#i?(this.#i=c,!0):b<this.#i:Math.abs(this.#t)>I?!1:(b!==null&&this.#u(b),c!==null&&this.#c(c),!0)}value(){switch(this.#e){case"countValues":return this.#r;case"avg":return this.#r?(this.#t+this.#n)/this.#r:null;case"min":return this.#r?this.#s:null;case"max":return this.#r?this.#i:null;default:return this.#t+this.#n}}invalidate(){this.#a=!1}}const Y=L}),ze("packages/core/src/source/filterwire.js",function(e,B){"use strict";Object.defineProperty(e,"HOST_FILTER_WARN_ID",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"WHERE_PAGE_RELATIVE_WARN_ID",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"warnWherePageRelative",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"warnHostFilterNotApplied",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"WHERE_NOT_APPLIED_WARN_ID",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"warnWhereNotApplied",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"WHERE_OVER_THRESHOLD_WARN_ID",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"warnWhereOverThreshold",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"RELATIVE_TOKENS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"parseRelativeToken",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"resolveRelativeRange",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"relativeTokenOf",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"relativeTokenHelp",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"isResolvableRelative",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"resolveRelativeCondition",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"isGroup",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"forEachCondition",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"mapConditions",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"normaliseFilterSet",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"buildFilterSet",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"wireFilters",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"querySignature",{enumerable:!0,get:function(){return S}});const A=B("packages/core/src/internal/warn.js").warnOnce,V="source.remote.hostFilter",U="source.where.pageRelative";function I(q,K){!Array.isArray(q)||!q.length||A(U,`filters.where (${q.join(", ")}) runs over the rows the ${K} source fetched,`,"not the whole dataset: match counts and totals are page-relative.","Give the predicate a { condition } twin so the engine can narrow the fetch itself.")}function J(q){const K=(q||{}).config;!K||!K.hostFilter||A(V,"config.hostFilter is not sent to a server-delegated source (paged/remote) and is not applied:","filtering only the fetched window would give wrong counts and totals.","Express the filter as a FilterSet condition, or send it through config.context.")}const H="source.where.notApplied";function L(q,K){A(`${H}:${q}`,`filters.where("${q}") is registered but the ${K} source holds only its fetched window`,"and cannot run the predicate over it: the predicate is not applied there, and rows it would","exclude stay on screen.","Give it a { condition } twin so the engine can narrow the fetch itself — that is the","supported route for a paged or remote source.")}const Y="source.where.overThreshold";function _(q,K,P,k){!Array.isArray(q)||!q.length||A(`${Y}:${K}`,`filters.where (${q.join(", ")}) is not applied to the ${K} pushdown source:`,P===null?"the adapter reports no row total, so the size of the matching set is unknown.":`its matching set is ${P.toLocaleString()} rows, at or past the whereRowLimit of ${k.toLocaleString()}.`,"Running the predicate needs every matching row fetched and held here, which is the whole","download a pushdown source exists to avoid, so it is refused and the rows the predicate","would exclude stay on screen.","Give the predicate a { condition } twin so the engine narrows the fetch itself — that is the","route that works at any size — or raise `whereRowLimit` on the source config if you want the","download.")}const O=new Map;function v(q){let K=O.get(q);return K||(K=new Intl.DateTimeFormat("en-US",{timeZone:q,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}),O.set(q,K)),K}function b(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function c(q,K){const P=v(K).formatToParts(new Date(q)),k={y:1970,m:1,d:1,h:0,mi:0,s:0};for(const E of P)E.type==="year"?k.y=+E.value:E.type==="month"?k.m=+E.value:E.type==="day"?k.d=+E.value:E.type==="hour"?k.h=+E.value%24:E.type==="minute"?k.mi=+E.value:E.type==="second"&&(k.s=+E.value);return k}function g(q,K){const P=c(q,K);return Date.UTC(P.y,P.m-1,P.d,P.h,P.mi,P.s)-Math.floor(q/1e3)*1e3}function o(q,K,P,k){const E=Date.UTC(q,K-1,P),C=E-g(E,k);return E-g(C,k)}function t(q,K,P){const k=new Date(Date.UTC(q.y,q.m-1,q.d+K));return o(k.getUTCFullYear(),k.getUTCMonth()+1,k.getUTCDate(),P)}const s=Object.freeze(["today","yesterday","lastNDays","thisWeek","thisMonth","thisQuarter","thisYear","quarterToDate","yearToDate"]);function l(q,K){if(typeof q!="string")return null;const P=q.trim().toLowerCase().replace(/[\s_-]+/g,""),k=/^last(\d*|n)days?$/.exec(P);if(k){const E=k[1]==="n"?"":k[1],C=Number(E||K);return!Number.isFinite(C)||C<=0?null:{kind:"lastNDays",n:Math.floor(C)}}switch(P){case"today":return{kind:"today",n:0};case"yesterday":return{kind:"yesterday",n:0};case"thisweek":return{kind:"thisWeek",n:0};case"thismonth":return{kind:"thisMonth",n:0};case"thisquarter":return{kind:"thisQuarter",n:0};case"thisyear":return{kind:"thisYear",n:0};case"quartertodate":case"qtd":return{kind:"quarterToDate",n:0};case"yeartodate":case"ytd":return{kind:"yearToDate",n:0};default:return null}}function u(q,K={}){const P=l(q,K.n);if(!P)return null;const k=K.tz||b(),E=K.now instanceof Date?K.now.getTime():typeof K.now=="number"?K.now:Date.now(),C=c(E,k),x=o(C.y,C.m,C.d,k),j=t(C,1,k);let T=x,F=j;switch(P.kind){case"today":break;case"yesterday":T=t(C,-1,k),F=x;break;case"lastNDays":F=K.includeToday?j:x,T=t(C,K.includeToday?-(P.n-1):-P.n,k);break;case"thisWeek":{const $=Number.isFinite(K.weekStartsOn)?Number(K.weekStartsOn):1,z=(new Date(Date.UTC(C.y,C.m-1,C.d)).getUTCDay()-$+7)%7;T=t(C,-z,k),F=t(C,-z+7,k);break}case"thisMonth":T=o(C.y,C.m,1,k),F=o(C.m===12?C.y+1:C.y,C.m===12?1:C.m+1,1,k);break;case"thisQuarter":case"quarterToDate":{const $=Math.floor((C.m-1)/3)*3+1;T=o(C.y,$,1,k),F=P.kind==="quarterToDate"?j:$===10?o(C.y+1,1,1,k):o(C.y,$+3,1,k);break}case"thisYear":case"yearToDate":T=o(C.y,1,1,k),F=P.kind==="yearToDate"?j:o(C.y+1,1,1,k);break;default:return null}return{from:new Date(T).toISOString(),to:new Date(F).toISOString(),bounds:"[)",tz:k,relative:P.kind==="lastNDays"?`last${P.n}Days`:P.kind,n:P.n}}function n(q){if(!q||typeof q!="object")return null;const K=q.value;if(K&&typeof K=="object"&&!Array.isArray(K)&&"relative"in K)return{token:String(K.relative),n:typeof K.n=="number"?K.n:void 0};if(q.op==="relative"&&typeof q.value=="string")return{token:q.value,n:void 0};const P=q.meta;return P&&typeof P.relative=="string"&&q.value===void 0?{token:P.relative,n:typeof P.n=="number"?P.n:void 0}:null}function p(){return`Known tokens: ${s.filter(K=>K!=="lastNDays").join(", ")}. "lastNDays" needs a count: pass "last7Days", or the value object { relative: 'lastNDays', n: 7 }.`}function r(q){const K=n(q);return K?l(K.token,K.n)!==null:!1}function i(q,K={}){const P=n(q);if(!P)return q;const k=u(P.token,{...K,n:P.n});return k?{...q,type:q.type||"date",op:"between",value:[k.from,k.to],bounds:q.bounds||k.bounds,meta:{...q.meta||{},relative:k.relative,tz:k.tz}}:(A(`source.relative.${P.token}`,`unknown relative date token "${P.token}"; sending the condition unresolved.`,p()),q)}function d(q){return!!q&&typeof q=="object"&&Array.isArray(q.conditions)}function h(q,K){if(q){if(d(q)){for(const P of q.conditions)h(P,K);return}K(q)}}function a(q,K){if(!q)return null;if(!d(q))return K(q);const P=q;let k=!1;const E=[];for(const C of P.conditions){const x=a(C,K);x!==C&&(k=!0),x&&E.push(x)}return!k&&E.length===P.conditions.length?q:E.length?{...P,conditions:E}:null}function y(q){if(!q)return null;if(!d(q))return q;const K=q,P=[];for(const k of K.conditions){const E=y(k);E&&P.push(E)}return P.length?{op:K.op,conditions:P}:null}function f(q){const K=y(q);return K?d(K)&&K.op==="and"?K:{op:"and",conditions:[K]}:null}function m(q){const K=(q||[]).filter(Boolean);return K.length?{op:"and",conditions:K}:null}function w(q,K={}){const P=a(q,k=>i(k,K));return f(P)}function S(q){const K=M(q.filters??null);return JSON.stringify([K,q.sort??null,q.quick??"",q.groupBy??null,q.pivotBy??null,X(q.context)])}function M(q){if(!q)return null;if(d(q)){const k=q;return{op:k.op,conditions:k.conditions.map(M)}}const K=q,P=K.meta&&typeof K.meta.relative=="string"?K.meta.relative:n(K)?.token;return{col:K.col,op:K.op,bounds:K.bounds??null,caseSensitive:K.caseSensitive??!1,value:P?`rel:${P}`:K.value??null}}function X(q){if(q==null)return null;try{return JSON.parse(JSON.stringify(q))}catch{return A("source.context.unserialisable","config.context is not JSON-serialisable; cache keys ignore it."),"[unserialisable]"}}}),ze("packages/core/src/source/tree.js",function(e,B){"use strict";Object.defineProperty(e,"SYNTHETIC",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"buildFromPath",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"buildFromParentKey",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"assignLevels",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"resolveTree",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"buildTree",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"indexTree",{enumerable:!0,get:function(){return c}});const A=B("packages/core/src/internal/predicates.js").isFunction,U=B("packages/core/src/internal/warn.js").warnOnce,I="",J="\0tree:";function H(g,o){return{physical:g,key:o,level:0,children:[],value:void 0}}function L(g,o){const t=[],s=new Map;for(let l=0;l<g.length;l++){const u=g[l],n=o.pathOf(u),p=Array.isArray(n)?n.map(i=>String(i)):[];if(!p.length){const i=H(u,o.keyOf(u));t.push(i);continue}let r=null;for(let i=0;i<p.length;i++){const d=p.slice(0,i+1).join(I),h=i===p.length-1;let a=s.get(d);a&&h&&a.physical===-1&&(a.physical=u,a.key=o.keyOf(u)),a||(a=H(h?u:-1,h?o.keyOf(u):J+d),a.level=i,a.value=p[i],s.set(d,a),r?r.children.push(a):t.push(a)),r=a}}return{roots:t,nodes:s}}function Y(g,o){const t=new Map,s=[];for(let p=0;p<g.length;p++){const r=g[p],i=o.keyOf(r),d=H(r,i);t.set(i,d);const h=o.parentOf(r);h!=null&&h!==""&&s.push({node:d,parent:String(h)})}let l=null;const u=new Map;for(const{node:p,parent:r}of s){const i=t.get(r);if(i){u.set(p.key,i);continue}o.orphans&&o.orphans!=="root"&&(l||(l=H(-1,`${J}orphans`),l.value=o.orphans),u.set(p.key,l))}const n=[];for(const p of t.values()){const r=u.get(p.key);r?r.children.push(p):n.push(p)}return l&&l.children.length&&n.push(l),{roots:_(n,t,o.orphans,l),nodes:t}}function _(g,o,t,s){const l=new Set,u=[...g];for(;u.length;){const d=u.pop();if(!l.has(d.key)){l.add(d.key);for(const h of d.children)u.push(h)}}const n=[];for(const d of o.values())l.has(d.key)||n.push(d);if(!n.length)return g;const p=!!t&&t!=="root";U("tree.cycle",`tree.parentKey produced ${n.length} row(s) inside a parent cycle; `+(p?`they are shown under "${t}".`:"they are shown at the root."));for(const d of n)d.children=d.children.filter(h=>l.has(h.key));if(!p)return[...g,...n];let r=s;const i=[...g];return r||(r=H(-1,`${J}orphans`),r.value=t,i.push(r)),r.children.push(...n),i}function O(g){let o=0;const t=(s,l)=>{for(const u of s)u.level=l,l>o&&(o=l),u.children.length&&t(u.children,l+1)};return t(g,0),o}function v(g,o){if(!g||typeof g!="object")return null;const t=g.path,s=g.parentKey,l=A(g.hasChildren)?u=>!!g.hasChildren(o.dataAt(u)):null;if(A(t))return{mode:"path",pathOf:u=>t(o.dataAt(u)),keyOf:o.keyOf,declaresChildren:l};if(s!=null){const u=A(s)?s:n=>n?.[s];return{mode:"parentKey",parentOf:n=>u(o.dataAt(n)),keyOf:o.keyOf,orphans:g.orphans||"root",declaresChildren:l}}return U("tree.shape","tree is configured with neither `path` nor `parentKey`; rows stay flat."),null}function b(g,o){const t=o.mode==="path"?L(g,o):Y(g,o),s=O(t.roots);return{...t,depth:s}}function c(g,o){const t=new Map,s=l=>{for(let u=0;u<l.length;u++){const n=l[u];if(n.physical>=0){const p=o?o(n.physical):!1,r=p&&n.children.length===0;t.set(n.physical,{level:n.level,posinset:u+1,setsize:l.length,hasChildren:n.children.length>0||p,lazy:r})}n.children.length&&s(n.children)}};return s(g),t}}),ze("packages/core/src/source/settle.js",function(e,B){"use strict";Object.defineProperty(e,"PIPELINE_SETTLE_REASONS",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"isPipelineSettle",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"ARRIVAL_REASONS",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"isArrival",{enumerable:!0,get:function(){return U}});const ne=Object.freeze(["pipeline:sort","pipeline:sort:error"]);function A(I){const J=I&&typeof I=="object"?I.reason:null;return typeof J=="string"&&ne.includes(J)}const V=Object.freeze(["page","total"]);function U(I){const J=I&&typeof I=="object"?I.reason:null;return typeof J=="string"&&V.includes(J)}}),ze("packages/core/src/source/memory.js",function(e,B){"use strict";Object.defineProperty(e,"STAGES",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"PIPELINE_SETTLE_REASONS",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"isPipelineSettle",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"createMemorySource",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"quickMatcher",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"MemorySource",{enumerable:!0,get:function(){return z}});const A=B("packages/core/src/internal/lru.js").Lru,V=B("packages/core/src/internal/warn.js"),U=V.warnOnce,I=V.fail,H=B("packages/core/src/internal/predicates.js").isFunction,Y=B("packages/core/src/internal/compare.js").defaultCompare,O=B("packages/core/src/internal/merge.js").mergeRow,v=B("packages/core/src/source/rows.js"),b=v.createRowFactory,c=v.groupKey,g=v.groupPathElement,o=v.groupPrefixKeys,t=v.lazyRowView,l=B("packages/core/src/source/handles.js").createHandleProvider,u=B("packages/core/src/compute/incremental.js"),n=u.RunningTotal,p=u.isIncremental,i=B("packages/core/src/compute/handle.js").presenceReader,d=B("packages/core/src/source/filterwire.js"),h=d.querySignature,a=d.mapConditions,y=d.resolveRelativeCondition,f=B("packages/core/src/source/tree.js"),m=f.buildTree,w=f.resolveTree,S=f.indexTree,M=B("packages/core/src/source/settle.js"),X=M.PIPELINE_SETTLE_REASONS,q=M.isPipelineSettle,K=Object.freeze(["filter","sort","group","total","pivot","flatten"]),P=Object.freeze([]);function k(G,N){if(!G)return null;const Z=N==="grand"?G.grandTotal:G.groupTotal;return Z??G.total}function E(G){return!!G&&!G.running}function C(G){if(G)return G.value&&H(G.value.compare)?G.value.compare:H(G.compare)?G.compare:void 0}function x(G){const N=G&&G.dataType;return!N||!H(N.items)?null:{items:N.items,type:G.itemType&&G.itemType.name||"text"}}function j(G){return!!G&&(typeof G=="object"||typeof G=="function")&&H(G.then)}const T=new Uint32Array(0),F=4096;function $(G,N){return new z(G,N)}function D(G,N){if(N==="regex")try{const Z=new RegExp(G,"iu");return Q=>Z.test(Q)}catch{return Z=>Z.includes(G)}if(N==="fuzzy"){const Z=[...G].filter(Q=>Q!==" ");return Z.length?Q=>{let ee=0;for(let re=0;re<Q.length&&ee<Z.length;re++)Q[re]===Z[ee]&&ee++;return ee===Z.length}:()=>!0}if(N==="words"){const Z=G.split(/\s+/).filter(Boolean);return Z.length?Q=>Z.every(ee=>Q.includes(ee)):()=>!0}return Z=>Z.includes(G)}class z{mode="memory";#e;#t;#n;#r=!1;#s=null;#i;#a;#l=new Map;#o=!1;#c=0;#u=0;#f=new Map;#d=new Map;#h;#p=null;#m=z.#g();static#g(){return{slots:[],groupHeadings:P,unnumbered:P,pivot:null,inlineLeaves:null,matchCount:0,grand:null,grandLeaves:0,groupLeaves:null}}#b=new Map;#y=null;#S=new Map;#w=-1;#A=[];#v=new Map;#C=-1;#O=[];#P=null;#E=null;#T=null;#M=null;#N=null;#R=null;#D=null;#G=null;#K=Symbol("unset");#L=new Map;#q=null;get#B(){return this.#m.slots}set#B(N){this.#m.slots=N}get#Y(){return this.#m.inlineLeaves}set#Y(N){this.#m.inlineLeaves=N}get#z(){return this.#m.groupHeadings}set#z(N){this.#m.groupHeadings=N}get#I(){return this.#m.unnumbered}set#I(N){this.#m.unnumbered=N}get#W(){return this.#m.pivot}set#W(N){this.#m.pivot=N}constructor(N,Z){this.#t=N||{mode:"memory"},this.#e=Z||{};const Q=this.#e.config||{};this.#n=this.#t.rows||Q.rows||[],this.#i=b(this.#e),this.#a=l(this.#e,()=>this.#n,()=>this.#r),this.#h=new A(Number(Q.rowCacheSize)||F);for(const ee of K)this.#l.set(ee,{key:null,result:null,id:0,computed:!1})}count(){this.#_();const N=this.#ge();return N?N.length:this.#B.length}#ge(){const N=Number(this.#H("pageSize",0))||0;if(N<=0)return null;const Z=this.#B.length,Q=Math.max(1,Math.ceil(Z/N)),re=Math.min(Math.max(0,Number(this.#H("page",0))||0),Q-1)*N;return{offset:re,length:Math.max(0,Math.min(N,Z-re))}}pageInfo(){this.#_();const N=Number(this.#H("pageSize",0))||0,Z=this.#B.length;if(N<=0)return{page:0,pageSize:0,total:Z,pageCount:1};const Q=Math.max(1,Math.ceil(Z/N));return{page:Math.min(Math.max(0,Number(this.#H("page",0))||0),Q-1),pageSize:N,total:Z,pageCount:Q}}totalCount(){return this.#et().length}matchCount(){return this.#_(),this.#m.matchCount}at(N){this.#_();const Z=this.#ge();if(Z)return N<0||N>=Z.length?void 0:this.#He(Z.offset+N,N);if(!(N<0||N>=this.#B.length))return this.#He(N,N)}byKey(N){this.#_(),this.#p||this.#Ae();const Z=this.#p.get(N);if(Z!==void 0)return this.#ce(Z);for(let Q=0;Q<this.#B.length;Q++){const ee=this.#B[Q];if(typeof ee!="number"&&ee&&ee.key===N)return this.#He(Q)}}loaded(N){return N>=0&&N<this.count()}hint(N,Z){}display(){return this.#_(),this.#q||(this.#q=this.#$e()),this.#q}invalidateQuickText(){this.#L.clear(),this.invalidate("filter")}invalidate(N){const Z=K.indexOf(N);Z<0&&I(`unknown pipeline stage "${N}"; expected one of ${K.join(", ")}`);for(let Q=Z;Q<K.length;Q++){const ee=this.#l.get(K[Q]);ee.key=null,ee.computed=!1}this.#q=null}apply(N){const Z=[],Q={added:[],updated:[],removed:[],rejected:Z};if(!N)return Q;let ee=!1;const re=new Set;if(N.remove&&N.remove.length)for(const ie of N.remove){const ce=this.#Pe(ie);if(ce===void 0){Z.push({operation:"remove",id:this.#Ue(ie),reason:"unknown-id"});continue}Q.removed.push(this.#i.keyOf(this.#r?this.#Je(ce):this.#n[ce],ce)),this.#r||(this.#n[ce]=void 0),this.#h.delete(ce),this.#L.delete(ce),ee=!0}if(N.update&&N.update.length){const ie=this.#S.size||this.#at()?this.#Ke():null,ce=this.#v.size?this.#ht():null,ve=ce&&ce.length?this.#Ke():null;for(const he of N.update){const ye=this.#Pe(he);if(ye===void 0){Z.push({operation:"update",id:this.#xe(he),reason:"unknown-id"});continue}const Oe=this.#r?this.#s&&this.#s.has(ye)?this.#s.get(ye):this.#Je(ye):this.#n[ye],Le=O(Oe,he);for(const fe of this.#le(Oe,Le))re.add(fe);if(this.#r||(this.#n[ye]=Le),ie&&this.#Qe(ie,ye,Oe,Le),ve&&this.#Ve(ce,ve,ye,Oe,Le),this.#p){const fe=this.#i.keyOf(Oe,ye),ae=this.#i.keyOf(Le,ye);fe!==ae&&(this.#p.delete(fe),this.#p.set(ae,ye))}this.#h.delete(ye),this.#L.delete(ye),Q.updated.push(this.#ce(ye))}}if(N.add&&N.add.length&&this.#r){typeof N.at=="number"&&N.at<this.#j()&&(this.#h.clear(),this.#L.clear()),this.#p=null;for(const ie of N.add){const ce=this.#ae(this.#xe(ie));ce!==void 0&&Q.added.push(this.#ce(ce))}ee=!0}else if(N.add&&N.add.length){let ie=typeof N.at=="number"?N.at:this.#n.length;if(ie<this.#n.length){let he=0;for(let ye=0;ye<this.#n.length;ye++)this.#n[ye]!==void 0&&he++;if(he!==this.#n.length){let ye=0;for(let Oe=0;Oe<this.#n.length;Oe++)this.#n[Oe]!==void 0&&(this.#n[ye++]=this.#n[Oe]);this.#n.length=ye,this.#p=null,this.#h.clear(),this.#L.clear()}}const ce=this.#n.length;ie=Math.max(0,ie);let ve=N.add===this.#n?N.add.slice():N.add;if(this.#i.keyed){const he=[];for(const ye of ve){const Oe=this.#xe(ye);if(this.#Pe(Oe)!==void 0){Z.push({operation:"add",id:Oe,reason:"duplicate-id"});continue}he.push(ye)}he.length!==ve.length&&(ve=he)}if(!ve.length)return Q;if(ie>=ce)for(let he=0;he<ve.length;he++)this.#n.push(ve[he]);else this.#n.splice(ie,0,...ve),this.#h.clear(),this.#L.clear();for(let he=0;he<ve.length;he++)Q.added.push(this.#ce(ie>=ce?ce+he:ie+he));ee=!0}return this.#c++,ee&&(this.#p=null,this.#lt()),this.#a.invalidate(),this.#q=null,ee||this.#ne(re)?(this.#u++,this.invalidate("filter")):this.invalidate("total"),this.#bt("rows:changed",{companion:!0,added:Q.added.length,updated:Q.updated.length,removed:Q.removed.length}),this.#s=null,Q}groupHeadingsAt(N){this.#_();const Z=this.#z;if(!Z.length||!Number.isInteger(N)||N<0)return P;let Q=0,ee=Z.length-1,re=-1;for(;Q<=ee;){const ce=Q+ee>>1;Z[ce].at<=N?(re=ce,Q=ce+1):ee=ce-1}if(re<0)return P;const ie=[];for(let ce=Z[re].row;ce;ce=ce.parent)ie.push(ce);return ie.reverse(),ie}unnumberedRowCount(N){this.#_();const Z=this.#I;if(!Z.length||!Number.isInteger(N)||N<0)return 0;let Q=0,ee=Z.length-1,re=-1;for(;Q<=ee;){const ie=Q+ee>>1;Z[ie].at<=N?(re=ie,Q=ie+1):ee=ie-1}return re+1}moveRow(N,Z){if(this.#r)return U("source.moveRow.dropped","rows.move() is not supported under ingest.dropSourceRows: the source objects have been released and the store cannot reorder its columns in place. Enable retainSource (leave dropSourceRows off) to reorder rows."),!1;const Q=this.#n;if(!Number.isInteger(N)||!Number.isInteger(Z))return!1;let ee=0;for(let ce=0;ce<Q.length;ce++)Q[ce]!==void 0&&ee++;if(N<0||N>=ee)return!1;const re=Math.max(0,Math.min(ee-1,Z));if(re===N)return!1;if(ee!==Q.length){let ce=0;for(let ve=0;ve<Q.length;ve++)Q[ve]!==void 0&&(Q[ce++]=Q[ve]);Q.length=ce}const[ie]=Q.splice(N,1);return Q.splice(re,0,ie),this.#c++,this.#u++,this.#p=null,this.#h.clear(),this.#L.clear(),this.#lt(),this.#a.invalidate(),this.#q=null,this.invalidate("filter"),this.#bt("rows:changed",{companion:!0,added:0,updated:0,removed:0,moved:1}),!0}reload(N){this.#ue(),this.#c++,this.#u++,this.#p=null,this.#L.clear(),this.#h.clear(),this.#lt(),this.#a.invalidate(),this.invalidate("filter"),this.#bt("model:changed",{reason:"reload"})}destroy(){this.#ue(),this.#h.clear(),this.#L.clear(),this.#p=null,this.#B=[],this.#Y=null,this.#q=null,this.#lt();for(const N of K)this.#l.set(N,{key:null,result:null,id:0,computed:!1})}#ie(N){const Z=this.#e.sortPending;H(Z)&&Z(N)}#ue(){this.#b.has("sort")&&this.#ie(!1);for(const{controller:N}of this.#b.values())try{N.abort()}catch{}this.#b.clear()}setRows(N){this.#n=N||[],this.#r=!1,this.#c++,this.#u++,this.#p=null,this.#L.clear(),this.#h.clear(),this.#lt(),this.#a.invalidate(),this.invalidate("filter")}notePriorRows(N){this.#s=N||null}releaseSource(){this.#r=!0,this.#n=[],this.#p=null,this.#h.clear(),this.#L.clear(),this.#a.invalidate()}data(){if(!this.#r)return this.#n;const N=this.#e.store;if(!N||!H(N.source))return this.#n;const Z=N.physical||0,Q=new Array(Z);for(let ee=0;ee<Z;ee++)Q[ee]=N.live&&!N.live(ee)?void 0:N.source(ee);return Q}#Me(){const N=this.#H("detail",null);return!N||!H(N.isOpen)||N.inline===!1?null:N}#fe(){const N=(this.#e.config||{}).tree;return this.#K!==N&&(this.#K=N,this.#G=w(N,{dataAt:Z=>this.#Je(Z),keyOf:Z=>this.#i.keyOf(this.#Je(Z),Z)})),this.#G}#oe(){return(this.#e.config||{}).grandTotalRow==="bottom"}grandTotalRow(){if(!this.#oe())return null;this.#_();const N=this.#m.grand;return N?this.#i.grandTotal(N,this.#te(this.#m.grandLeaves)):null}pivot(){return this.#_(),this.#W}pivotMatrix(){this.#_();const N=this.#m.groupLeaves,Z=(this.#e.compute||{}).pivotMatrix;if(!H(Z))return null;const Q=this.#H("groupBy",[]),ee=this.#H("pivotBy",[]);if(!Q.length&&!ee.length)return U("pivotView.no-dimension","pivotView is on but the grid has no pivot dimension, so there is no matrix to draw. Put a column on the pivot (its `pivot` setting, or `pivotBy` in the query) for the columns across the top, and group by a column for the rows down the side."),null;const re=this.#Ke().map(ce=>({colId:ce.id,handle:this.#a.handle(ce.id),fn:k(ce,"group")})).filter(ce=>ce.handle&&ce.fn),ie=this.#e.config||{};return Z({rowHandles:Q.map(ce=>this.#a.handle(ce)).filter(Boolean),columnHandles:ee.map(ce=>this.#a.handle(ce)).filter(Boolean),measures:re,leaves:N||new Uint32Array(0),opts:{locale:ie.locale,separator:(ie.pivot||{}).separator,maxColumns:(ie.pivot||{}).maxColumns}})}keysForLeaves(N){const Z=[];if(!N)return Z;for(let Q=0;Q<N.length;Q++){const ee=this.#ce(N[Q]);ee&&ee.key!=null&&Z.push(String(ee.key))}return Z}leavesOf(N){this.#_();const Z=this.#l.get("group"),Q=Z&&Z.result;if(!Q||!Q.nodes)return[];const ee=Q.nodes.get(N);if(!ee)return[];const re=[],ie=ce=>{const ve=ce.row&&ce.row.children;if(ve&&ve.length){for(const he of ve){const ye=Q.nodes.get(he.key);ye&&ie(ye)}return}if(ce.leaves)for(let he=0;he<ce.leaves.length;he++)re.push(this.#ce(ce.leaves[he]))};return ie(ee),re}#Ue(N){return typeof N=="string"?N:this.#xe(N)}#xe(N){try{return this.#i.keyOf(N,-1)}catch{return"(unkeyed)"}}#Pe(N){if(typeof N=="string")return this.#ae(N);if(this.#i.keyed){const Q=this.#i.keyOf(N,-1),ee=this.#ae(Q);if(ee!==void 0)return ee}if(this.#r)return;const Z=this.#n.indexOf(N);return Z>=0?Z:void 0}#ae(N){return this.#p||this.#Ae(),this.#p.get(N)}#Ae(){this.#p=new Map;const N=this.#j(),Z=this.#e.store,Q=Z&&H(Z.live)?ee=>Z.live(ee):null;for(let ee=0;ee<N;ee++){if(Q&&!Q(ee))continue;const re=this.#Je(ee);re!==void 0&&this.#p.set(this.#i.keyOf(re,ee),ee)}}#le(N,Z){const Q=[];for(const ee of this.#V())this.#_e(ee)&&this.#Z(ee,N,Z,new Set)&&Q.push(ee);return Q}#Z(N,Z,Q,ee){if(ee.has(N))return!1;ee.add(N);const re=this.#_e(N);if(!re)return!1;const ie=re.value&&re.value.deps;return Array.isArray(ie)&&ie.length?ie.some(ce=>this.#Z(String(ce),Z,Q,ee)):H(re.getValue)?!Object.is(re.getValue(Z),re.getValue(Q)):!1}#V(){const N=new Set;for(const Q of this.#H("sort",[]))N.add(Q.col);for(const Q of this.#H("groupBy",[]))N.add(Q);const Z=Q=>{if(Q){if(Array.isArray(Q.conditions)){Q.conditions.forEach(Z);return}Q.col&&N.add(Q.col)}};return Z(this.#H("filters",null)),[...N]}#ne(N){if(!N.size)return!1;if(this.#H("quick",""))return!0;for(const Z of this.#V())if(N.has(Z))return!0;return!1}#_(){if(!this.#o){this.#o=!0;try{this.#Ee()}finally{this.#o=!1}}}pipelineRunning(){return this.#o}#Ee(){const N=this.#de("filter",()=>this.#$(),()=>this.#We()),Z=this.#re(N),Q=this.#de("group",()=>this.#F(),()=>this.#Fe(Z)),ee=this.#de("total",()=>this.#ke(),()=>this.#qe(Q));this.#de("pivot",()=>this.#ee(),()=>this.#Ge(Q)),this.#de("flatten",()=>this.#Le(),()=>this.#kt(Q)),this.#ye(Q,ee)}#re(N){const Z=this.#l.get("sort"),Q=this.#U();if(Z.computed&&Z.key===Q&&!this.#b.has("sort"))return Z.result;const ee=this.#b.get("sort");return ee&&ee.key===Q?Z.result:Z.result&&this.#Te(N)?(this.#we(N,Q),Z.result):this.#de("sort",()=>Q,()=>this.#k(N))}#pe(){if(this.#y===null){const N=this.#e.pipelineWorker,Z=H(N)?N():null;this.#y=Z||!1}return this.#y||null}#be(){const N=this.#H("sort",[]);if(!Array.isArray(N)||!N.length)return null;const Z=(this.#e.config||{}).locale,Q=[],ee=[];for(const re of N){const ie=this.#_e(re.col);if(ie&&ie.running)continue;if(ie&&ie.value&&H(ie.value.compare))return null;const ce=this.#a.handle(re.col);if(!ce)return null;Q.push({col:re.col,descending:re.dir==="desc",nullsFirst:!!re.nullsFirst,locale:Z}),ee.push(ce)}return Q.length?{entries:Q,handles:ee,locale:Z}:null}#Te(N){if(this.#he())return!1;const Z=this.#pe();if(!Z)return!1;const Q=Number(Z.threshold);return Number.isFinite(Q)&&N.length<Q?!1:!!this.#be()}#we(N,Z){const Q=this.#pe(),ee=Q&&this.#be();if(!ee){this.#de("sort",()=>Z,()=>this.#k(N));return}const re=new AbortController;this.#b.set("sort",{key:Z,controller:re});const ie=ee.entries.length===1?Q.sortColumn(ee.handles[0],N,{descending:ee.entries[0].descending,nullsFirst:ee.entries[0].nullsFirst,locale:ee.locale,signal:re.signal,key:"sort"}):Q.sortMulti(ee.handles,ee.entries.map((ce,ve)=>({...ce,handle:ee.handles[ve]})),N,{signal:re.signal,key:"sort"});if(!j(ie)){this.#b.delete("sort"),this.#de("sort",()=>Z,()=>ie),this.#ie(!1);return}this.#ie(!0),ie.then(ce=>this.#ve(Z,ce),ce=>this.#Oe("sort",Z,ce))}#ve(N,Z){const Q=this.#b.get("sort");if(!(!Q||Q.key!==N)){if(this.#U()!==N){this.#b.delete("sort"),this.#ie(!1);return}this.#b.delete("sort"),this.#de("sort",()=>N,()=>Z),this.#q=null,this.#_(),this.#bt("model:changed",{reason:X[0]}),this.#ie(!1)}}#Oe(N,Z,Q){const ee=this.#b.get(N);if(!(!ee||ee.key!==Z)){if(this.#b.delete(N),Q&&Q.name==="AbortError"){N==="sort"&&this.#ie(!1);return}if(N==="sort"&&this.#U()===Z){const re=this.#de("filter",()=>this.#$(),()=>this.#We());this.#de("sort",()=>Z,()=>this.#k(re)),this.#q=null,this.#_(),U("source.pipeline.sort","off-thread sort failed; recomputed on the main thread.",Q),this.#bt("model:changed",{reason:X[1]})}N==="sort"&&this.#ie(!1)}}#ye(N,Z){const Q=N&&N.leaves?N.leaves.length:this.#m.slots.length;this.#m.matchCount=Q,this.#m.grand=Z&&Z.grand||null,this.#m.grandLeaves=N&&N.leaves?N.leaves.length:0,this.#m.groupLeaves=N&&N.leaves?N.leaves:null}#de(N,Z,Q){const ee=this.#l.get(N),re=Z();return ee.computed&&ee.key===re||(ee.result=Q(),ee.key=re,ee.computed=!0,ee.id++,N==="flatten"&&(this.#q=null)),ee.result}#Q(N){return this.#l.get(N).id}#$(){const N=(this.#e.config||{}).hostFilter,Z=N&&H(N.active)&&N.active()?1:0,Q=this.#H("where",null),ee=Q?Q.version:0,re=this.#st("filter.sig",`${this.#Ot()}`,()=>h({filters:this.#H("filters",null),quick:this.#H("quick",""),quickMode:this.#H("quickMode","contains")}));return`${this.#u}|${re}|${Z}|${ee}`}#U(){const N=this.#he();return`${this.#Q("filter")}|${JSON.stringify(this.#H("sort",[]))}`+(N?`|manual:${N.version}`:"")}#he(){const N=this.#H("rowOrder",null);return N&&Array.isArray(N.keys)?N:null}#se(N,Z){this.#p||this.#Ae();const Q=this.#p,ee=this.#j(),re=Z.keys.length,ie=new Float64Array(ee);for(let ce=0;ce<ee;ce++)ie[ce]=re+ce;for(let ce=0;ce<re;ce++){const ve=Q.get(Z.keys[ce]);ve!==void 0&&(ie[ve]=ce)}return Uint32Array.from(N).sort((ce,ve)=>ie[ce]-ie[ve])}orderedKeys(){this.#p||this.#Ae();const N=this.#p,Z=new Map;for(const[ce,ve]of N)Z.set(ve,ce);const Q=Uint32Array.from([...Z.keys()]).sort(),ee=this.#he(),re=ee?this.#se(Q,ee):this.#k(Q),ie=new Array(re.length);for(let ce=0;ce<re.length;ce++)ie[ce]=Z.get(re[ce]);return ie}#F(){const N=this.#H("pivotBy",[]).length>0?"p":"u";return`${this.#Q("sort")}|${JSON.stringify(this.#H("groupBy",[]))}|${N}`}#ke(){const N=this.#rt()?"f":"a",Z=(this.#e.config||{}).totalOnlyChangedColumns?"n":"w";return`${this.#Q("group")}|${JSON.stringify(this.#H("totals",[]))}|${N}${Z}|${this.#c}`}#ee(){return`${this.#Q("group")}|${JSON.stringify(this.#H("pivotBy",[]))}`}#Le(){const Z=this.#je()||!this.#oe()?this.#Q("total"):"x",Q=`${this.#Ot()}`,ee=this.#st("flatten.keys",Q,()=>{const ie=this.#H("expanded",null);return ie?[...ie].sort().join(""):"*"}),re=this.#st("flatten.detail",Q,()=>{const ie=this.#H("detail",null);return ie&&H(ie.signature)?ie.signature():""});return`${Z}|${this.#Q("pivot")}|${ee}|${re}`}#je(){const N=this.#H("groupBy",[]);return Array.isArray(N)&&N.length>0}stageState(){const N=[];for(const[Z,Q]of this.#l){const ee=Q.result;N.push({stage:Z,materialised:!!Q.computed,bytes:ee&&typeof ee.byteLength=="number"?ee.byteLength:null,rows:ee&&typeof ee.length=="number"?ee.length:null,rebuilds:Q.id})}return N}facetIndices(N){return this.#We(N||null)}facetRows(N){const Z=this.facetIndices(N),Q=[];for(let ee=0;ee<Z.length;ee++){const re=this.#ce(Z[ee]);re&&Q.push(re)}return Q}invalidateRows(){this.#h.clear(),this.#L.clear(),this.#q=null}invalidateHandles(){this.#a.invalidate()}rows(){return this.#n}unfilteredIndices(){return this.#et()}filteredIndices(){const N=this.#l.get("filter");if(N&&N.computed&&N.key===this.#$())return N.result||this.#et();this.#_();const Z=this.#l.get("filter");return(Z&&Z.computed?Z.result:null)||this.#et()}unfilteredRows(){const N=this.#et(),Z=[];for(let Q=0;Q<N.length;Q++){const ee=this.#ce(N[Q]);ee&&Z.push(ee)}return Z}#We(N=null){const Z=this.#et(),Q=this.#H("filters",null),ee=N?this.#ft("pruneColumn")(Q,N):Q,re=this.#mt(ee),ie=String(this.#H("quick","")||"").trim().toLowerCase(),ce=ie?D(ie,String(this.#H("quickMode","contains")||"contains")):null,ve=(this.#e.config||{}).hostFilter,he=!!(ve&&H(ve.active)&&ve.active()),ye=this.#H("where",null),Oe=!!(ye&&ye.active);if(!re&&!ie&&!he&&!Oe)return Z;let Le=null;re&&(Le=this.#ft("evaluateFilters")(re,{handle:pe=>this.#a.handle(pe),count:this.#j(),pool:this.#e.pool,locale:(this.#e.config||{}).locale,itemwise:pe=>x(this.#_e(pe))}));const fe=new Uint32Array(Z.length);let ae=0;for(let ke=0;ke<Z.length;ke++){const pe=Z[ke];if(!(Le&&!Le[pe])&&!(ce&&!this.#Ie(pe,ce))){if(he||Oe){const ue=this.#ce(pe);if(he&&!ve.passes(ue)||Oe&&!ye.passes(ue.data,ue.key))continue}fe[ae++]=pe}}if(Le){const ke=(this.#e.compute||{}).releaseMask;H(ke)&&ke({pool:this.#e.pool},Le)}return fe.subarray(0,ae)}handleFor(N){return this.#a.handle(N)}#k(N){const Z=this.#he();if(Z)return this.#se(N,Z);const Q=this.#H("sort",[]).filter(ie=>{const ce=this.#_e(ie.col);return!ce||!ce.running?!0:(U(`source.sort.running.${ie.col}`,`sort ignores "${ie.col}": a running total is a function of the sort order, so it cannot also decide it. Sort by the column it runs over instead.`),!1)});if(!Q.length)return N;const ee=(this.#e.config||{}).locale;if(Q.length===1){const ie=Q[0],ce=this.#a.handle(ie.col);if(!ce)return U(`source.sort.${ie.col}`,`sort ignores unknown column "${ie.col}".`),N;const ve=this.#_e(ie.col);return this.#ft("sortColumn")(ce,N,{descending:ie.dir==="desc",nullsFirst:ie.nullsFirst,locale:ee,compare:C(ve)})}const re=[];for(const ie of Q){const ce=this.#a.handle(ie.col);if(!ce){U(`source.sort.${ie.col}`,`sort ignores unknown column "${ie.col}".`);continue}re.push({handle:ce,descending:ie.dir==="desc",nullsFirst:ie.nullsFirst,locale:ee,compare:C(this.#_e(ie.col))})}return re.length?this.#ft("sortMulti")(re.map(ie=>ie.handle),re,N):N}#Fe(N){const Z=this.#H("groupBy",[]),Q=this.#fe();if(Q&&!Z.length){const ke=m(N,Q);return this.#R=S(ke.roots,Q.declaresChildren),{roots:null,leaves:N,nodes:new Map,tree:ke}}if(this.#R=null,Q&&Z.length&&U("tree.grouped","grouping is active on a grid configured with `tree`; the grouping wins and the hierarchy is not shown."),!Z.length)return{roots:null,leaves:N,nodes:new Map};const ee=(this.#e.config||{}).timeZone,re=[],ie=[];let ce=!1;for(const ke of Z){const pe=this.#a.handle(ke);if(!pe){U(`source.group.${ke}`,`grouping ignores unknown column "${ke}".`);continue}re.push(pe);const ue=this.#_e(ke),we=ue&&ue.dataType;if(we&&H(we.groupProjector)){const Te=ue.typeOptions&&ue.typeOptions.timeZone||ee||void 0,Ne=we.groupProjector(ue,Te);ie.push(Ne||null),Ne&&(ce=!0)}else ie.push(null)}if(!re.length)return{roots:null,leaves:N,nodes:new Map};const{keys:ve,buckets:he}=this.#ft("groupByColumns")(re,N,{locale:(this.#e.config||{}).locale,project:ce?ie:void 0}),ye=this.#H("pivotBy",[]).length>0,Oe=[],Le=new Map;for(let ke=0;ke<he.length;ke++){const pe=ve[ke];let ue=null;const we=[];for(let Te=0;Te<pe.length;Te++){we.push(g(pe[Te]));const Ne=c(we),_e=Te===pe.length-1;let $e=Le.get(Ne);if(!$e){const je=this.#i.group({path:[...we],column:Z[Te],value:pe[Te],level:Te,parent:ue,expanded:ye&&_e?!1:this.#gt(Ne,{key:Ne,column:Z[Te],value:pe[Te],level:Te,path:[...we]}),hasChildren:!(ye&&_e)});$e={row:je,leaves:null},Le.set(Ne,$e),ue?ue.children.push(je):Oe.push(je)}$e.row.leafCount+=he[ke].length,Te===pe.length-1&&($e.leaves=he[ke]),ue=$e.row}}const fe=this.#H("sort",[])||[],ae=(ke,pe)=>{if(!ke||ke.length<2){if(ke)for(const Ne of ke)ae(Ne.children,pe+1);return}const ue=Z[pe],we=fe.find(Ne=>Ne.col===ue),Te=we&&we.dir==="desc"?-1:1;ke.sort((Ne,_e)=>Te*Y(Ne.groupValue,_e.groupValue));for(const Ne of ke)ae(Ne.children,pe+1)};return ae(Oe,0),{roots:Oe,leaves:N,nodes:Le,keys:ve,buckets:he}}#Ye(N,Z){const Q=new Map,ee=new Map,re=ie=>{const ce=ie.physical>=0?[ie.physical]:[];for(const ve of ie.children)ce.push(...re(ve));if(ie.children.length){const ve=this.#Xe(Z,Uint32Array.from(ce),null);ie.physical>=0?Q.set(ie.physical,ve):ee.set(ie.key,ve)}return ce};for(const ie of N.roots)re(ie);return{byPhysical:Q,byKey:ee}}#qe(N){const Z=this.#Ke();if(!Z.length)return this.#E=null,this.#T=null,{grand:null};const Q={id:this.#Q("group"),columns:Z.map(fe=>fe.id).join("")},ee=this.#E&&this.#E.id===Q.id&&this.#E.columns===Q.columns,re=this.#at()&&ee?this.#P:null,ie=re?Z.filter(fe=>re.has(fe.id)):Z,ce=ee?this.#T:null,ve=this.#rt()?null:this.#Tt(),he=this.#Ce(Z),ye=fe=>{const ae=N.nodes.get(fe.key);let ke=ae&&ae.leaves?ae.leaves:null;if(fe.children&&fe.children.length){const we=fe.children.map(ye);let Te=0;for(const $e of we)Te+=$e.length;const Ne=new Uint32Array(Te);let _e=0;for(const $e of we)Ne.set($e,_e),_e+=$e.length;ke=Ne}ke=ke||new Uint32Array(0);const pe=ve?ve.get(fe.key)||T:ke,ue=this.#Ze(fe,re?ie:Z,pe,he);return fe.totals=re?{...fe.totals,...ue}:ue,ke};if(N.roots&&ie.length)for(const fe of N.roots)ye(fe);if(this.#D=N.tree?this.#Ye(N.tree,Z):null,this.#E=Q,this.#P=this.#at()?new Set:null,!(this.#e.config||{}).grandTotalRow)return this.#A.length=0,this.#T=null,{grand:null};const Le=ve?this.#it():N.leaves;return this.#T=this.#Se(Z,Le,re,ce),{grand:this.#T}}#Se(N,Z,Q,ee){const re={},ie=this.#Q("group");ie!==this.#w&&(this.#ct(),this.#w=ie);const ce=this.#A;this.#A=[];for(const ve of N){if(!E(ve))continue;const he=this.#a.handle(ve.id);if(!he)continue;const ye=k(ve,"grand");if(!p(ye,he)){if(Q&&!Q.has(ve.id)&&ee&&ve.id in ee){re[ve.id]=ee[ve.id];continue}re[ve.id]=this.#Xe([ve],Z,null,"grand")[ve.id];continue}let Oe=this.#S.get(ve.id);if((!Oe||Oe.fn!==ye)&&(Oe=new n(ye),this.#S.set(ve.id,Oe)),Oe.valid){let Le=!0;for(const fe of ce)if(fe.colId===ve.id&&!Oe.update(fe.before,fe.after)){Le=!1;break}if(Le){re[ve.id]=Oe.value();continue}Oe.invalidate()}Oe.seedColumn(he.values,i(he),Z),re[ve.id]=Oe.valid?Oe.value():this.#Xe([ve],Z,null,"grand")[ve.id]}return re}#Ce(N){const Z=this.#Q("group");Z!==this.#C&&(this.#v.clear(),this.#C=Z);const Q=new Map;for(const re of N){if(!E(re))continue;const ie=this.#a.handle(re.id),ce=k(re,"group");p(ce,ie)&&Q.set(re.id,{fn:ce})}if(!Q.size)return this.#O.length=0,Q;const ee=this.#O;this.#O=[];for(const re of ee){const{beforeKeys:ie,afterKeys:ce,colDeltas:ve}=re,he=ie.length?new Set(ie):null,ye=ce.length?new Set(ce):null;for(const{colId:Oe,before:Le,after:fe}of ve)if(Q.has(Oe)){for(const ae of ie)ye&&ye.has(ae)||this.#dt(ae,Oe,Le,null);for(const ae of ce)he&&he.has(ae)||this.#dt(ae,Oe,null,fe);for(const ae of ie)ye&&!ye.has(ae)||this.#dt(ae,Oe,Le,fe)}}return Q}#dt(N,Z,Q,ee){const re=this.#v.get(N),ie=re&&re.get(Z);!ie||!ie.valid||ie.update(Q,ee)||ie.invalidate()}#Ze(N,Z,Q,ee){if(!ee||!ee.size)return this.#Xe(Z,Q,N);const re={};let ie=null,ce=this.#v.get(N.key);for(const ve of Z){const he=ee.get(ve.id);if(!he){(ie||(ie=[])).push(ve);continue}const ye=this.#a.handle(ve.id);if(!ye)continue;ce||(ce=new Map,this.#v.set(N.key,ce));let Oe=ce.get(ve.id);if((!Oe||Oe.fn!==he.fn)&&(Oe=new n(he.fn),ce.set(ve.id,Oe)),Oe.valid||Oe.seedColumn(ye.values,i(ye),Q),Oe.valid){re[ve.id]=Oe.value();continue}(ie||(ie=[])).push(ve)}return ie&&Object.assign(re,this.#Xe(ie,Q,N)),re}#Qe(N,Z,Q,ee){const re=!this.#rt()||this.#Et(Z);for(const ie of N){const ce=ie.getValue;if(!H(ce))continue;const ve=ce(Q),he=ce(ee);Object.is(ve,he)||(this.#P&&this.#P.add(ie.id),re&&this.#S.has(ie.id)&&this.#A.push({colId:ie.id,before:ve,after:he}))}}#ht(){const N=this.#H("groupBy",[]),Z=[];for(const Q of N){const ee=this.#_e(Q);ee&&Z.push(ee)}return Z}#pt(N,Z){const Q=new Array(N.length);for(let ee=0;ee<N.length;ee++){const re=N[ee].getValue;Q[ee]=g(H(re)?re(Z):void 0)}return Q}#Ve(N,Z,Q,ee,re){if(this.#rt()&&!this.#Et(Q))return;const ie=o(this.#pt(N,ee)),ce=o(this.#pt(N,re)),ve=ie.length!==ce.length||ie.some((ye,Oe)=>ye!==ce[Oe]),he=[];for(const ye of Z){const Oe=ye.getValue;if(!H(Oe))continue;const Le=Oe(ee),fe=Oe(re);!ve&&Object.is(Le,fe)||he.push({colId:ye.id,before:Le,after:fe})}!he.length&&!ve||this.#O.push({beforeKeys:ie,afterKeys:ce,colDeltas:he})}#Et(N){const Z=this.#l.get("filter"),Q=Z&&Z.computed?Z.result:null;if(!Q)return!0;let ee=0,re=Q.length-1;for(;ee<=re;){const ie=ee+re>>1,ce=Q[ie];if(ce===N)return!0;ce<N?ee=ie+1:re=ie-1}return!1}#rt(){return(this.#e.config||{}).totalFilteredOnly!==!1}#te(N){return this.#rt()?N:this.#it().length}#it(){return(!this.#M||this.#M.version!==this.#u)&&(this.#M={version:this.#u,indices:this.#et()}),this.#M.indices}#Tt(){const N=this.#H("groupBy",[]),Z=`${this.#u}|${JSON.stringify(N)}`;if(this.#N&&this.#N.key===Z)return this.#N.map;const Q=new Map,ee=[];for(const re of N){const ie=this.#a.handle(re);ie&&ee.push(ie)}if(ee.length){const re=this.#it(),{keys:ie,buckets:ce}=this.#ft("groupByColumns")(ee,re,{locale:(this.#e.config||{}).locale}),ve=new Map;for(let he=0;he<ce.length;he++){const ye=ie[he],Oe=[];for(let Le=0;Le<ye.length;Le++){Oe.push(g(ye[Le]));const fe=c(Oe);let ae=ve.get(fe);ae||(ae=[],ve.set(fe,ae));for(let ke=0;ke<ce[he].length;ke++)ae.push(ce[he][ke])}}for(const[he,ye]of ve)Q.set(he,Uint32Array.from(ye))}return this.#N={key:Z,map:Q},Q}#at(){return!!(this.#e.config||{}).totalOnlyChangedColumns}#lt(){this.#ct(),this.#vt(),this.#P=null,this.#E=null,this.#T=null}#ct(){this.#S.clear(),this.#A.length=0,this.#w=-1}#vt(){this.#v.clear(),this.#O.length=0,this.#C=-1}#Ge(N){const Z=this.#H("pivotBy",[]);if(!Z.length)return this.#W=null,null;const Q=(this.#e.compute||{}).pivot;if(!H(Q))return U("source.pivot.kernel","pivot requested but ctx.compute.pivot is not available; showing unpivoted rows."),this.#W=null,null;const ee=Z.map(ie=>this.#a.handle(ie)).filter(Boolean),re=this.#Ke();return this.#W=Q(ee,N.leaves,{groups:N.keys&&N.buckets?{keys:N.keys,buckets:N.buckets}:null,totals:re.map(ie=>ie.id),handle:ie=>this.#a.handle(ie),totalOf:ie=>k(re.find(ce=>ce.id===ie),"group"),separator:((this.#e.config||{}).pivot||{}).separator,maxColumns:((this.#e.config||{}).pivot||{}).maxColumns})||null,this.#W}#kt(N){const Z=this.#l.get("total").result,Q=!!(this.#e.config||{}).groupFooter,ee=this.#Me();if(N.tree)return this.#Re(N,Z,ee);if(!N.roots&&!ee){if(Z&&Z.grand&&!this.#oe()){const ye=this.#i.grandTotal(Z.grand,this.#te(N.leaves.length));if(this.#Y===N.leaves&&Array.isArray(this.#B))this.#B[this.#B.length-1]=ye;else{const Oe=Array.from(N.leaves);Oe.push(ye),this.#B=Oe,this.#Y=N.leaves}this.#I=[{at:this.#B.length-1}]}else this.#Y=null,this.#B=N.leaves,this.#I=P;return this.#z=P,this.#B}const re=[],ie=[],ce=[],ve=ye=>{if(re.push(ye),!ee)return;const Oe=this.#ce(ye);!Oe||!ee.isOpen(Oe.key)||(Oe.master=!0,Oe.expanded=!0,ce.push({at:re.length}),re.push(this.#i.detail(Oe,ee.heightOf(Oe))))};if(!N.roots){for(let ye=0;ye<N.leaves.length;ye++)ve(N.leaves[ye]);return Z&&Z.grand&&!this.#oe()&&(ce.push({at:re.length}),re.push(this.#i.grandTotal(Z.grand,this.#te(N.leaves.length)))),this.#Y=null,this.#z=P,this.#I=ce.length?ce:P,this.#B=re,re}const he=(ye,Oe,Le)=>{if(ye.expanded=ye.hasChildren===!1?!1:this.#gt(ye.key,{key:ye.key,column:ye.groupColumn,value:ye.groupValue,level:ye.level,path:ye.groupPath}),ye.posinset=Oe+1,ye.setsize=Le,ie.push({at:re.length,row:ye}),ce.push({at:re.length}),re.push(ye),!!ye.expanded){if(ye.children&&ye.children.length)for(let fe=0;fe<ye.children.length;fe++)he(ye.children[fe],fe,ye.children.length);else{const fe=N.nodes.get(ye.key),ae=fe&&fe.leaves?fe.leaves:null;if(ae)for(let ke=0;ke<ae.length;ke++)ve(ae[ke])}Q&&ye.totals&&(ce.push({at:re.length}),re.push(this.#i.footer(ye)))}};for(let ye=0;ye<N.roots.length;ye++)he(N.roots[ye],ye,N.roots.length);return Z&&Z.grand&&!this.#oe()&&(ce.push({at:re.length}),re.push(this.#i.grandTotal(Z.grand,this.#te(N.leaves.length)))),this.#z=ie,this.#I=ce,this.#B=re,re}#et(){const N=this.#e.store;if(N&&H(N.liveIndices))return N.liveIndices();const Z=new Uint32Array(this.#n.length);let Q=0;for(let ee=0;ee<this.#n.length;ee++)this.#n[ee]!==void 0&&(Z[Q++]=ee);return Z.subarray(0,Q)}#j(){const N=this.#e.store;return N&&typeof N.physical=="number"?N.physical:this.#n.length}#Je(N){const Z=this.#e.store;return Z&&H(Z.source)?Z.source(N):this.#n[N]}#He(N,Z=N){const Q=this.#B[N];if(typeof Q!="number")return Q.index=Z,Q;const ee=this.#ce(Q);return ee.index=Z,ee}#ce(N){let Z=this.#h.get(N);Z||(Z=this.#i.leaf(this.#Je(N),N),this.#h.set(N,Z));const Q=this.#R?this.#R.get(N):null;if(Q){Z.level=Q.level,Z.posinset=Q.posinset,Z.setsize=Q.setsize,Z.hasChildren=Q.hasChildren,Z.expanded=Q.hasChildren&&!Q.lazy&&this.#gt(Z.key);const ee=this.#D?this.#D.byPhysical.get(N):void 0;ee?Z.totals=ee:Z.totals&&(Z.totals=null)}else Z.hasChildren&&(Z.level=0,Z.hasChildren=!1,Z.expanded=!1,Z.posinset=void 0,Z.setsize=void 0);return Z}#Re(N,Z,Q){const ee=[],re=[],ie=ve=>{if(ve.leafCount!==void 0)return ve.leafCount;let he=ve.physical>=0?1:0;for(const ye of ve.children)he+=ie(ye);return ve.leafCount=he,he},ce=ve=>{const he=this.#gt(ve.key);if(ve.physical>=0){if(ee.push(ve.physical),Q&&Q.isOpen(this.#ce(ve.physical).key)){const ye=this.#ce(ve.physical);re.push({at:ee.length}),ee.push(this.#i.detail(ye,Q.heightOf(ye)))}}else ee.push(this.#i.group({path:[ve.key],column:null,value:ve.value,level:ve.level,parent:null,expanded:he,hasChildren:ve.children.length>0,leafCount:ie(ve),totals:this.#D?this.#D.byKey.get(ve.key):void 0}));if(he)for(const ye of ve.children)ce(ye)};for(const ve of N.tree.roots)ce(ve);return Z&&Z.grand&&!this.#oe()&&(re.push({at:ee.length}),ee.push(this.#i.grandTotal(Z.grand,this.#te(N.leaves.length)))),this.#Y=null,this.#z=P,this.#I=re.length?re:P,this.#B=ee,ee}#$e(){return t(()=>this.count(),N=>this.at(N))}#Ie(N,Z){let Q=this.#L.get(N);if(Q===void 0){const ee=this.#Je(N),re=this.#At(),ie=[],ce=this.#e.columnHidden;for(const ve of re){if(ve.quickFilter===!1||H(ce)&&ce(ve.id))continue;const he=ve.value&&H(ve.value.quickFilterText)?ve.value.quickFilterText({value:void 0,data:ee,row:null,column:ve,colId:ve.id,grid:null,context:this.#H("context",null)}):null,ye=he??(H(ve.formatValue)?ve.formatValue(H(ve.getValue)?ve.getValue(ee):void 0):"");ye!=null&&ye!==""&&ie.push(String(ye))}Q=ie.join(" ").toLowerCase(),this.#L.set(N,Q)}return Z(Q)}#Ke(){const N=this.#H("totals",[]),Z=N&&N.length?new Set(N):null;return this.#At().filter(Q=>Z?Z.has(Q.id):!!(Q.total||Q.groupTotal||Q.grandTotal))}#Xe(N,Z,Q,ee="group"){const re={},ie=(this.#e.compute||{}).total;for(const ce of N){if(!E(ce))continue;const ve=this.#a.handle(ce.id);if(!ve)continue;const he=k(ce,ee);if(he)if(H(he)){const ye=new Array(Z.length);for(let Oe=0;Oe<Z.length;Oe++)ye[Oe]=ve.get(Z[Oe]);re[ce.id]=he(ye,{row:Q,column:ce,grid:this.#e.grid||null,context:this.#H("context",null),valueAt:(Oe,Le)=>{const fe=this.#a.handle(Oe);return fe&&Le>=0&&Le<Z.length?fe.get(Z[Le]):null}})}else H(ie)&&(re[ce.id]=ie(ve,Z,he))}return re}#mt(N){if(!N)return N;const Z=this.#e.config||{},Q={tz:Z.timeZone,weekStartsOn:Z.weekStartsOn};return a(N,ee=>{const re=y(ee,Q),ie=this.#_e(re&&re.col),ce=ie&&ie.type==="datetime";if(re&&re.type)return re.type==="datetime"&&!re.timeZone&&ie?{...re,timeZone:Z.timeZone||void 0}:re;if(ce)return{...re,type:"datetime",timeZone:Z.timeZone||void 0};const ve=ie&&(ie.dataType?.base||ie.type);return ve?{...re,type:ve}:re})}#gt(N,Z){const Q=this.#H("expanded",null);return Q?H(Q.has)?Q.has(N,Z):Array.prototype.includes.call(Q,N):!0}#H(N,Z){if(N==="context"||!H(this.#e.stateVersion))return this.#St(N,Z);const Q=this.#_t(N),ee=this.#f.get(N);if(ee&&ee.version===Q)return ee.value;const re=this.#St(N,Z);return this.#f.set(N,{version:Q,value:re}),re}#St(N,Z){const Q=this.#e.state;if(Q&&H(Q[N])){const ee=Q[N]();return ee??Z}return Z}#Ot(){const N=this.#e.stateVersion;return H(N)?N():0}#ut(){const N=this.#e.columnsVersion,Z=this.#e.permissionsVersion;return`${H(N)?N():0}|${H(Z)?Z():0}`}#_t(N){return N==="totals"?this.#ut():`${this.#Ot()}`}#st(N,Z,Q){if(!H(this.#e.stateVersion))return Q();const ee=this.#d.get(N);if(ee&&ee.version===Z)return ee.key;const re=Q();return this.#d.set(N,{version:Z,key:re}),re}#ft(N){const Z=(this.#e.compute||{})[N];return H(Z)||I(`ctx.compute.${N} is required by the memory source pipeline`),Z}#At(){const N=this.#e.columns;return N&&H(N.all)?N.all():[]}#_e(N){const Z=this.#e.columns;return Z&&H(Z.get)?Z.get(N):void 0}#bt(N,Z){const Q=this.#e.emit;H(Q)&&Q(N,Z)}}}),ze("packages/core/src/source/abort.js",function(e,B){"use strict";Object.defineProperty(e,"SupersededError",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"RequestToken",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"AbortScope",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"createAbortScope",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"isAbortError",{enumerable:!0,get:function(){return I}});class ne extends Error{constructor(H,L="superseded"){super(`[lattice] request ${H?`"${H}" `:""}${L}`),this.name="SupersededError",this.superseded=!0,this.key=H}}class A{#e;constructor(H,L,Y,_){this.#e=H,this.key=L,this.controller=Y,this.signal=Y.signal,this.seq=_}get current(){return!this.signal.aborted&&this.#e.tokenFor(this.key)===this}settle(){this.#e.settle(this)}abort(H){this.signal.aborted||this.controller.abort(new ne(this.key,H)),this.#e.settle(this)}}class V{#e=new Map;#t=0;begin(H="",L="superseded"){const Y=this.#e.get(H);Y&&!Y.signal.aborted&&Y.controller.abort(new ne(H,L));const _=new A(this,H,new AbortController,++this.#t);return this.#e.set(H,_),_}tokenFor(H){return this.#e.get(H)}pending(H=""){const L=this.#e.get(H);return!!L&&!L.signal.aborted}get size(){return this.#e.size}settle(H){this.#e.get(H.key)===H&&this.#e.delete(H.key)}abort(H="",L="superseded"){const Y=this.#e.get(H);Y&&Y.abort(L)}abortAll(H="superseded"){for(const L of[...this.#e.values()])L.abort(H);this.#e.clear()}}function U(){return new V}function I(J){if(!J||typeof J!="object")return!1;const H=J;return H.superseded===!0||H.name==="AbortError"||H.name==="SupersededError"}}),ze("packages/core/src/source/blockcache.js",function(e,B){"use strict";Object.defineProperty(e,"DEFAULT_PAGE_SIZE",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"DEFAULT_MAX_CACHED_PAGES",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"BlockCache",{enumerable:!0,get:function(){return U}});const ne=100,A=32;class V{constructor(J){this.id=J,this.rows=null,this.state="pending",this.token=null,this.error=null}}class U{#e=new Map;#t;#n;#r=0;#s=-1;constructor(J={}){this.#t=Math.max(1,Math.floor(Number(J.pageSize)||ne)),this.#n=Math.max(1,Math.floor(Number(J.maxCachedPages)||A))}get pageSize(){return this.#t}get maxBlocks(){return this.#n}get size(){return this.#e.size}blockOf(J){return Math.floor(J/this.#t)}rangeOf(J){return{start:J*this.#t,end:(J+1)*this.#t}}has(J){return this.#e.has(J)}pending(J){const H=this.#e.get(J);return!!H&&H.state==="pending"}loaded(J){const H=this.#e.get(J);return!!H&&H.state==="loaded"}begin(J,H){let L=this.#e.get(J);return L||(L=new V(J)),L.state="pending",L.token=H,L.error=null,this.#i(J,L),L}fill(J,H){const L=this.#e.get(J)||new V(J);L.rows=H,L.state="loaded",L.token=null,this.#i(J,L)}failed(J,H){const L=this.#e.get(J)||new V(J);L.state="error",L.error=H,L.token=null,this.#i(J,L)}delete(J){return this.#e.delete(J)}rowAt(J){const H=this.blockOf(J),L=this.#e.get(H);if(!(!L||L.state!=="loaded"||!L.rows))return this.#i(H,L),L.rows[J-H*this.#t]}rowLoaded(J){const H=this.blockOf(J),L=this.#e.get(H);return!!L&&L.state==="loaded"&&!!L.rows&&J-H*this.#t<L.rows.length}erroredAt(J){const H=this.#e.get(this.blockOf(J));return!!H&&H.state==="error"}loadedExtent(){let J=0;for(const H of this.#e.values()){if(H.state!=="loaded"||!H.rows)continue;const L=H.id*this.#t+H.rows.length;L>J&&(J=L)}return J}fillOf(J){const H=this.#e.get(J);return H&&H.state==="loaded"&&H.rows?H.rows.length:null}protect(J,H){this.#r=this.blockOf(Math.max(0,J)),this.#s=this.blockOf(Math.max(0,H))}evict(){const J=[];if(this.#e.size<=this.#n)return J;for(const[H,L]of this.#e){if(this.#e.size-J.length<=this.#n)break;H>=this.#r&&H<=this.#s||L.state!=="pending"&&J.push(H)}for(const H of J)this.#e.delete(H);return J}ids(){return[...this.#e.keys()]}clear(){this.#e.clear()}#i(J,H){this.#e.delete(J),this.#e.set(J,H)}}}),ze("packages/core/src/source/pagewindow.js",function(e,B){"use strict";Object.defineProperty(e,"pageWindow",{enumerable:!0,get:function(){return ne}});function ne(A,V,U,I){const J=Math.floor(Number(A)||0);if(J<=0)return null;const H=Math.max(0,Math.floor(Number(V)||0)),L=Math.max(0,Math.floor(Number(U)||0));if(I){const Y=Math.max(1,Math.ceil(L/J)),_=Math.min(H,Y-1),O=_*J;return{page:_,pageSize:J,offset:O,length:Math.max(0,Math.min(J,L-O)),pageCount:Y,total:L}}return{page:H,pageSize:J,offset:H*J,length:J,pageCount:Math.max(H+2,Math.ceil(L/J)),total:null}}}),ze("packages/core/src/source/paged.js",function(e,B){"use strict";Object.defineProperty(e,"HINT_SETTLE_MS",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"createPagedSource",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"PagedSource",{enumerable:!0,get:function(){return h}});const A=B("packages/core/src/internal/lru.js").Lru,U=B("packages/core/src/internal/predicates.js").isFunction,J=B("packages/core/src/internal/warn.js").warnOnce,L=B("packages/core/src/internal/schedule.js").settleDebounce,Y=B("packages/core/src/source/abort.js"),_=Y.createAbortScope,O=Y.isAbortError,v=B("packages/core/src/source/blockcache.js"),b=v.BlockCache,c=v.DEFAULT_PAGE_SIZE,g=v.DEFAULT_MAX_CACHED_PAGES,t=B("packages/core/src/source/rows.js").createRowFactory,s=B("packages/core/src/source/filterwire.js"),l=s.wireFilters,u=s.querySignature,n=s.warnHostFilterNotApplied,r=B("packages/core/src/source/pagewindow.js").pageWindow,i=120;function d(a,y){return new h(a,y)}class h{mode="paged";#e;#t;#n;#r=_();#s;#i;#a=new Map;#l=null;#o=null;#c=!1;#u=0;#f="";#d={start:0,end:0};#h;#p=!1;#m=0;#g="";constructor(y,f){this.#e=y||{mode:"paged"},this.#t=f||{},this.#n=new b({pageSize:this.#e.pageSize||c,maxCachedPages:this.#e.maxCachedPages||g}),this.#s=t(this.#t),this.#i=new A(this.#n.pageSize*4),this.#h=L((m,w)=>this.#w(m,w),i),this.#f=this.#P(),U(this.#e.fetch)||J("source.paged.fetch",'source.mode "paged" requires a fetch function; the grid will stay empty.'),n(this.#t)}count(){const y=this.#y();return y?y.length:this.#b()}#b(){if(this.#C(),this.#l!==null)return this.#l;const y=Math.max(this.#u,this.#n.loadedExtent());return this.#c?y:y+this.#n.pageSize}matchCount(){return this.#b()}totalCount(){return this.#b()}pageInfo(){const y=this.#y();if(!y){const f=this.#b();return{page:0,pageSize:0,total:this.exact()?f:null,pageCount:1,counting:!1}}return{page:y.page,pageSize:y.pageSize,total:y.total,pageCount:y.pageCount,counting:y.total===null&&this.#r.size>0&&this.#u===0&&this.#n.loadedExtent()===0}}#y(){const y=this.#b(),f=r(this.#T("pageSize",0),this.#T("page",0),y,this.exact());if(!f)return this.#g="",null;const m=`${this.#m}:${f.offset}:${f.length}`;if(m!==this.#g&&!this.#p&&(this.#g=m,f.length>0)){const w=f.offset+f.length-1;this.#d={start:f.offset,end:w},this.#w(f.offset,w)}return f}at(y){const f=this.#y();if(f){if(y<0||y>=f.length)return;const m=this.#S(f.offset+y);return m&&(m.index=y),m}return this.#S(y)}#S(y){if(y<0||y>=this.#b())return;const f=this.#i.get(y);if(f&&(f.data!==null||!this.#n.rowLoaded(y)))return f;const m=this.#n.rowAt(y);if(m===void 0){const S=this.#s.skeleton(y,0,this.#n.erroredAt(y));return this.#i.set(y,S),S}const w=this.#s.leaf(m,y);return w.index=y,this.#i.set(y,w),this.#a.set(w.key,y),w}byKey(y){const f=this.#a.get(y);return f===void 0?void 0:this.#S(f)}loaded(y){const f=this.#y();return f?y>=0&&y<f.length&&this.#n.rowLoaded(f.offset+y):this.#n.rowLoaded(y)}loadedCount(){this.#C();let y=0;for(const f of this.#n.ids()){if(!this.#n.loaded(f))continue;const m=this.#n.fillOf(f);typeof m=="number"&&(y+=m)}return y}residentRows(){this.#C();const y=this.#y(),f=y?y.offset:0,m=y?y.offset+y.length:1/0,w=[],S=this.#n.ids().sort((M,X)=>M-X);for(const M of S){if(!this.#n.loaded(M))continue;const{start:X}=this.#n.rangeOf(M),q=this.#n.fillOf(M)||0;for(let K=X;K<X+q;K++){if(K<f||K>=m)continue;const P=this.#i.peek(K);if(P&&P.data!==null&&P.data!==void 0){w.push(P);continue}const k=this.#n.rowAt(K);if(k===void 0)continue;const E=this.#s.leaf(k,K);E.index=K,this.#i.set(K,E),this.#a.set(E.key,K),w.push(E)}}return w}hint(y,f){if(this.#p)return;const m=this.#C();let w=Math.max(0,Math.floor(y)),S=Math.max(w,Math.floor(f));const M=this.#y();if(M){if(M.length===0)return;w=M.offset,S=M.offset+M.length-1}this.#d={start:w,end:S},this.#n.protect(w,S);for(const X of this.#n.evict())this.#v(X);this.#h(w,S),m&&this.#h.flush()}#w(y,f){if(this.#p)return;this.#n.protect(y,f);const m=this.#n.blockOf(y),w=this.#n.blockOf(f);for(let S=m;S<=w&&!(this.#l!==null&&S*this.#n.pageSize>=this.#l);S++)this.#n.has(S)||this.#A(S)}apply(y){const f={added:[],updated:[],removed:[]};if(!y)return f;if(y.update)for(const m of y.update){const w=this.#s.keyOf(m,-1),S=this.#a.get(w);if(S===void 0)continue;const M=this.#s.leaf(m,S);M.index=S,this.#i.set(S,M),f.updated.push(M)}return(y.add&&y.add.length||y.remove&&y.remove.length)&&this.reload(),f}reload(y){this.#O("reload"),this.#h.cancel(),this.hint(this.#d.start,this.#d.end)}destroy(){this.#p=!0,this.#h.cancel(),this.#r.abortAll("destroyed"),this.#n.clear(),this.#i.clear(),this.#a.clear()}exact(){return this.#l!==null||this.#c}pending(){return this.#r.size}async#A(y){if(!U(this.#e.fetch))return;const f=this.#r.begin(`block:${y}`);this.#n.begin(y,f);const{start:m,end:w}=this.#n.rangeOf(y),S=this.#f;try{const M=await this.#e.fetch({range:{start:m,end:w},sort:this.#T("sort",[]),filters:l(this.#T("filters",null),this.#E()),quick:this.#T("quick","")||void 0,context:this.#T("context",null),signal:f.signal});if(!f.current||S!==this.#f||this.#p)return;f.settle();const X=M&&M.rows||[];this.#n.fill(y,X);for(let K=0;K<X.length;K++)this.#i.delete(m+K);const q=M&&typeof M.total=="number"?M.total:M&&typeof M.count=="number"?M.count:null;q!==null?(this.#l=q,this.#c=!0):X.length<this.#n.pageSize?(this.#c=!0,this.#l=m+X.length):this.#u=Math.max(this.#u,m+X.length),this.#M("model:changed",{reason:"page",block:y,from:m,to:m+X.length}),this.#M("rows:changed",{companion:!0,reason:"page",block:y,from:m,to:m+X.length}),this.#l!==null&&this.#l!==this.#o&&(this.#o=this.#l,this.#M("source:total",{total:this.#l,groupPath:[]}))}catch(M){if(f.settle(),O(M))return;this.#n.failed(y,M);for(let X=m;X<w;X++)this.#i.delete(X);this.#M("model:changed",{reason:"page-error",block:y,range:{start:m,end:w}}),this.#M("source:error",{error:M,block:y,range:{start:m,end:w}})}}#v(y){const{start:f,end:m}=this.#n.rangeOf(y);for(let w=f;w<m;w++){const S=this.#i.peek(w);S&&this.#a.delete(S.key),this.#i.delete(w)}}#C(){const y=this.#P();return y===this.#f?!1:(this.#f=y,this.#O("query"),!0)}#O(y){this.#r.abortAll(y),this.#n.clear(),this.#i.clear(),this.#a.clear(),this.#l=null,this.#o=null,this.#c=!1,this.#u=0,this.#m++,this.#M("model:changed",{reason:y})}#P(){return u({filters:this.#T("filters",null),sort:this.#T("sort",[]),quick:this.#T("quick",""),context:this.#T("context",null)})}#E(){const y=this.#t.config||{};return{tz:y.timeZone,weekStartsOn:y.weekStartsOn}}#T(y,f){const m=this.#t.state;if(m&&U(m[y])){const w=m[y]();return w??f}return f}#M(y,f){const m=this.#t.emit;U(m)&&m(y,f)}}}),ze("packages/core/src/source/aggregates.js",function(e,B){"use strict";Object.defineProperty(e,"STAT_PUSHDOWN",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"pushableAggregates",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"fillAggregateSql",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"aggregateP",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"resolveAggregatesConfig",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"routeAggregate",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"resolveAggregatePlan",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"groupKeysPushable",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"pushdownDocRows",{enumerable:!0,get:function(){return _}});const ne=Object.freeze({sum:{pushable:!0,class:"identical",sql:"sum(%c)"},avg:{pushable:!0,class:"identical",sql:"avg(%c)"},min:{pushable:!0,class:"identical",sql:"min(%c)"},max:{pushable:!0,class:"identical",sql:"max(%c)"},count:{pushable:!0,class:"identical",sql:"count(*)"},countValues:{pushable:!0,class:"identical",sql:"count(%c)",blankAware:!0},range:{pushable:!0,class:"identical",sql:"(max(%c) - min(%c))"},variance:{pushable:!0,class:"identical",sql:"var_samp(%c)"},varianceP:{pushable:!0,class:"identical",sql:"var_pop(%c)"},stddev:{pushable:!0,class:"identical",sql:"stddev_samp(%c)"},stddevP:{pushable:!0,class:"identical",sql:"stddev_pop(%c)"},sumSquares:{pushable:!0,class:"identical",sql:"sum(%c * %c)"},median:{pushable:!0,class:"identical",sql:"median(%c)"},percentile:{pushable:!0,class:"identical",sql:"quantile_cont(%c, %p)",parametric:!0},p25:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.25)"},p75:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.75)"},p90:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.9)"},p95:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.95)"},p99:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.99)"},iqr:{pushable:!0,class:"identical",sql:"(quantile_cont(%c, 0.75) - quantile_cont(%c, 0.25))"},mad:{pushable:!0,class:"identical",sql:"mad(%c)"},distinct:{pushable:!0,class:"identical",sql:"count(DISTINCT %c)",blankAware:!0},skewness:{pushable:!0,class:"identical",sql:"skewness(%c)"},kurtosis:{pushable:!0,class:"identical",sql:"kurtosis(%c)"},geomean:{pushable:!0,class:"identical",sql:"exp(avg(ln(%c)))"},harmean:{pushable:!0,class:"identical",sql:"(count(%c) / sum(1.0 / %c))"},entropy:{pushable:!0,class:"identical",sql:"entropy(%c)",blankAware:!0},correlation:{pushable:!0,class:"identical",sql:"corr(%w, %c)",twoColumn:!0},hhi:{pushable:!0,class:"identical",blankAware:!0,sql:"CASE WHEN count(%c)=0 THEN NULL ELSE list_sum(list_transform(map_values(histogram(%c)), lambda v: (v::DOUBLE/count(%c))*(v::DOUBLE/count(%c)))) END"},evenness:{pushable:!0,class:"identical",blankAware:!0,sql:"CASE WHEN count(%c)=0 THEN NULL WHEN count(DISTINCT %c)<2 THEN 1.0 ELSE entropy(%c)/log2(count(DISTINCT %c)) END"},top3Share:{pushable:!0,class:"identical",blankAware:!0,sql:"CASE WHEN count(%c)=0 THEN NULL ELSE list_sum(list_slice(list_sort(map_values(histogram(%c)),'DESC'),1,3))::DOUBLE/count(%c) END"},top10Share:{pushable:!0,class:"identical",blankAware:!0,sql:"CASE WHEN count(%c)=0 THEN NULL ELSE list_sum(list_slice(list_sort(map_values(histogram(%c)),'DESC'),1,10))::DOUBLE/count(%c) END"},gini:{pushable:!0,class:"identical",sql:"CASE WHEN list_min(list(%c) FILTER (WHERE isfinite(%c)))<0 THEN NULL WHEN len(list(%c) FILTER (WHERE isfinite(%c)))=0 THEN NULL WHEN list_sum(list(%c) FILTER (WHERE isfinite(%c)))=0 THEN 0 ELSE 2.0*list_sum(list_transform(list_sort(list(%c) FILTER (WHERE isfinite(%c))), lambda v, i: i*v))/(len(list(%c) FILTER (WHERE isfinite(%c)))*list_sum(list(%c) FILTER (WHERE isfinite(%c))))-(len(list(%c) FILTER (WHERE isfinite(%c)))+1.0)/len(list(%c) FILTER (WHERE isfinite(%c))) END"},trimmedMean:{pushable:!0,class:"identical",sql:"CASE WHEN len(list(%c) FILTER (WHERE isfinite(%c)))=0 THEN NULL ELSE list_avg(list_slice(list_sort(list(%c) FILTER (WHERE isfinite(%c))), floor(len(list(%c) FILTER (WHERE isfinite(%c)))*0.1)::BIGINT+1, len(list(%c) FILTER (WHERE isfinite(%c)))-floor(len(list(%c) FILTER (WHERE isfinite(%c)))*0.1)::BIGINT)) END"},winsorizedMean:{pushable:!0,class:"identical",sql:"CASE WHEN len(list(%c) FILTER (WHERE isfinite(%c)))=0 THEN NULL ELSE list_avg(list_transform(list_sort(list(%c) FILTER (WHERE isfinite(%c))), lambda v: least(list_sort(list(%c) FILTER (WHERE isfinite(%c)))[len(list(%c) FILTER (WHERE isfinite(%c)))-floor(len(list(%c) FILTER (WHERE isfinite(%c)))*0.1)::BIGINT], greatest(list_sort(list(%c) FILTER (WHERE isfinite(%c)))[floor(len(list(%c) FILTER (WHERE isfinite(%c)))*0.1)::BIGINT+1], v)))) END"},robustOutliers:{pushable:!0,class:"identical",sql:"(SELECT CASE WHEN len(d.a)=0 THEN NULL WHEN d.mad=0 THEN NULL ELSE len(list_filter(d.a, lambda v: abs(0.6745*(v-d.med)/d.mad)>3.5)) END FROM (SELECT xs AS a, list_median(xs) AS med, list_median(list_transform(xs, lambda w: abs(w-list_median(xs)))) AS mad FROM (SELECT list(%c) FILTER (WHERE isfinite(%c)) AS xs)) d)"},jarqueBera:{pushable:!0,class:"identical",sql:"CASE WHEN len(list(%c) FILTER (WHERE isfinite(%c)))<8 THEN NULL WHEN list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),2)))=0 THEN NULL ELSE (len(list(%c) FILTER (WHERE isfinite(%c)))/6.0)*(power(list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),3)))/power(list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),2))),1.5),2)+power(list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),4)))/power(list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),2))),2)-3,2)/4.0) END"},weightedAvg:{pushable:!0,class:"identical",twoColumn:!0,sql:"sum(%c*%w) FILTER (WHERE isfinite(%c) AND isfinite(%w))/nullif(sum(%w) FILTER (WHERE isfinite(%c) AND isfinite(%w)),0)"},mode:{pushable:!0,class:"may-differ",sql:"mode(%c)",note:"DuckDB returns a modal value even for an all-distinct column; the grid returns null. Tie-breaking can also differ, and on a text column an empty string counts as a value. Under pushdown you will see a value."},weightedQuantile:{pushable:!1,class:"fallback",note:"No SQL equivalent for the grid's weighted-quantile midpoint convention; always computed client-side (needs a full-dataset pull for a correct figure over a remote source)."}});function A(){const O=new Set;for(const[v,b]of Object.entries(ne))b.pushable&&O.add(v);return O}function V(O,v,b,c="?"){let g=O.split("%c").join(v);return b!==void 0&&(g=g.split("%w").join(b)),g.split("%p").join(c)}function U(O){const v=O&&(O.p!==void 0?O.p:O.params&&O.params.p);return typeof v=="number"&&v>=0&&v<=1?v:void 0}function I(O){const v=O||{},b=v.default==="engine"||v.default==="engine-if-identical"?v.default:"client",c={};if(v.overrides&&typeof v.overrides=="object")for(const[g,o]of Object.entries(v.overrides))(o==="engine"||o==="client")&&(c[g]=o);return{default:b,overrides:c}}function J(O,v){const b=ne[O];if(!b||!b.pushable)return"client";const c=v.overrides[O];return c==="engine"||c==="client"?c:v.default==="client"?"client":v.default==="engine-if-identical"?b.class==="identical"?"engine":"client":"engine"}function H(O,v){const b=I(v),c=[],g=[];for(const o of O||[]){const t=ne[o.fn],s=J(o.fn,b),l={id:o.id,col:o.col,fn:o.fn,class:t?t.class:"fallback"};if(o.weight!==void 0&&(l.weight=o.weight),o.params!==void 0&&(l.params=o.params),t&&t.parametric){const u=U(o);u!==void 0&&(l.p=u)}if(s==="engine"&&t&&t.parametric&&l.p===void 0){g.push({...l,reason:`"${o.fn}" needs \`p\`, a number from 0 to 1`});continue}s==="engine"?c.push(l):(l.reason=t&&!t.pushable?t.note||"the engine cannot express this stat":"client by config",g.push(l))}return{engine:c,client:g,config:b}}const L=/^[A-Za-z_][A-Za-z0-9_$]*$/;function Y(O,v=[]){return(O||[]).every(c=>{if(typeof c=="string")return L.test(c);if(!c||typeof c!="object")return!1;const g=c;return Array.isArray(v)&&v.includes(g.bucket)&&typeof g.col=="string"&&L.test(g.col)&&typeof g.size=="number"&&Number.isFinite(g.size)&&g.size>0})}function _(){return Object.entries(ne).map(([O,v])=>({stat:O,class:v.class,sql:v.sql?V(v.sql,"col",v.twoColumn?"weight":void 0):"",note:v.note||(v.class==="identical"?"Pushes to DuckDB with the same result.":"")}))}}),ze("packages/core/src/source/pushdown.js",function(e,B){"use strict";Object.defineProperty(e,"FOREGROUND_WAIT_MS",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"NO_CAPABILITIES",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"resolveMutate",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"capabilitiesOf",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"splitFilters",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"LEAF_COUNT_ID",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"PIVOT_UNSUPPORTED",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"GROUP_UNSUPPORTED",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"UNGROUPED_LEVEL",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"planQuery",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"applyResidual",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"DEFAULT_WHERE_ROW_LIMIT",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"createPushdownSource",{enumerable:!0,get:function(){return Q}});const A=B("packages/core/src/internal/compare.js").defaultCompare,U=B("packages/core/src/internal/predicates.js").isFunction,J=B("packages/core/src/internal/merge.js").toArray,L=B("packages/core/src/internal/warn.js").warnOnce,Y=B("packages/core/src/source/filterwire.js"),_=Y.isGroup,O=Y.warnWherePageRelative,v=Y.warnWhereOverThreshold,b=Y.wireFilters,c=B("packages/core/src/source/aggregates.js"),g=c.resolveAggregatePlan,o=c.groupKeysPushable,t=c.STAT_PUSHDOWN,s=c.aggregateP,l=c.fillAggregateSql,n=B("packages/core/src/source/abort.js").SupersededError,p=1e3;function r(ee){const re=ee&&ee.signal;if(!re||!re.aborted)return;const ie=re.reason;throw ie instanceof Error?ie:new n("","superseded before it was sent")}const i=Object.freeze({filter:!1,operators:Object.freeze([]),sort:!1,quick:!1,range:!1,total:!1,group:!1,pivot:!1,mutate:!1});function d(ee){if(!ee||typeof ee!="object")return!1;const re=ee.returning==="row"||ee.returning==="key"?ee.returning:"none";return{append:ee.append===!0,update:ee.update===!0,delete:ee.delete===!0,returning:re}}function h(ee,re){if(!ee||typeof re!="string")return;if(!re.includes("."))return ee[re];let ie=ee;for(const ce of re.split(".")){if(ie===null||typeof ie!="object")return;ie=ie[ce]}return ie}function a(ee){if(ee===!0)return!0;if(!ee||typeof ee!="object")return!1;const re=ee;return re.enabled===!1?!1:re.enabled===!0||U(re.commit)}function y(ee){const re={...i,...ee||{}};return re.operators=new Set(re.operators||[]),re.mutate=d(re.mutate),re}function f(ee,re){return!ee||!ee.op||!re.operators.size?!1:re.operators.has(ee.op)}function m(ee,re){if(!ee)return{pushed:null,residual:null};if(!re.filter)return{pushed:null,residual:ee};if(re.filter==="term"){if(_(ee)){const he=ee.conditions||[];if(String(ee.op)!=="and")return{pushed:null,residual:ee};const ye=he.findIndex(Le=>!_(Le)&&f(Le,re));if(ye<0)return{pushed:null,residual:ee};const Oe=he.filter((Le,fe)=>fe!==ye);return{pushed:he[ye],residual:Oe.length?{op:"and",conditions:Oe}:null}}return f(ee,re)?{pushed:ee,residual:null}:{pushed:null,residual:ee}}if(!_(ee))return f(ee,re)?{pushed:ee,residual:null}:{pushed:null,residual:ee};if(String(ee.op)!=="and")return(ee.conditions||[]).every(ye=>_(ye)?m(ye,re).residual===null:f(ye,re))?{pushed:ee,residual:null}:{pushed:null,residual:ee};const ie=[],ce=[];for(const he of ee.conditions||[]){if(_(he)){if(re.filter==="flat"){ce.push(he);continue}const ye=m(he,re);ye.pushed&&ie.push(ye.pushed),ye.residual&&ce.push(ye.residual);continue}(f(he,re)?ie:ce).push(he)}const ve=he=>he.length===0?null:he.length===1?he[0]:{op:"and",conditions:he};return{pushed:ve(ie),residual:ve(ce)}}const w="__lattice_leaves";function S(ee){return ee.aggregates?ee.aggregates instanceof Set?ee.aggregates:new Set(J(ee.aggregates)):new Set}function M(ee){const re=S(ee);return re.size?re.has("count")?ee.filter!=="tree"||!ee.operators||!ee.operators.has("eq")?"the adapter does not declare the `group` capability, and cannot narrow a group's rows by its key (that needs a `tree` filter with the `eq` operator)":"":"the adapter does not declare the `group` capability, and its declared aggregates have no `count` to give each group its row count":"the adapter does not declare the `group` capability"}function X(ee,re,ie,ce,ve,he,ye){const Oe=Array.isArray(ee.groupBy)?ee.groupBy:[],Le=Array.isArray(ee.groupPath)?ee.groupPath:[],fe=Array.isArray(ee.groupValues)?ee.groupValues:null;if(!re.group){const ae=M(re);if(ae)return ae}return o(Oe)?ie.residual?"the filter did not fully push, so the engine would group a superset of the matching rows":ce?ve?he&&!he.conditioned?"a host `where` predicate can only run in the browser, over rows the engine grouped":ye?"fullDataset holds the whole matching set, so the grid groups it itself":!fe||fe.length!==Le.length?"the request carries no typed `groupValues` for its group path, and the string `groupPath` cannot be compared against a typed column":"":"a quick search did not push, so the engine would group unsearched rows":"the sort did not push, so the engine would order the groups differently":"a grouping key is not a plain column the engine can name in a GROUP BY"}const q="pushdown:pivot-unsupported",K="pushdown:group-unsupported",P=Symbol("lattice.remote.ungroupedLevel");function k(ee,re,ie,ce,ve,he){const ye=Array.isArray(ee.pivotBy)?ee.pivotBy:[],Oe=Array.isArray(ee.groupBy)?ee.groupBy:[],Le=Array.isArray(ee.groupPath)?ee.groupPath:[],fe=Array.isArray(ee.groupValues)?ee.groupValues:null;return re.pivot?o(ye)?Oe.length&&!o(Oe)?"a grouping key is not a plain column the engine can name in a GROUP BY":ie.residual?"the filter did not fully push, so the engine would pivot a superset of the matching rows":ce?ve?he&&!he.conditioned?"a host `where` predicate can only run in the browser, over rows the engine pivoted":!fe||fe.length!==Le.length?"the request carries no typed `groupValues` for its group path, and the string `groupPath` cannot be compared against a typed column":"":"a quick search did not push, so the engine would pivot unsearched rows":"the sort did not push, so the engine would order the rows differently":"a pivot column is not a plain column the engine can name in a GROUP BY":"the adapter does not declare the `pivot` capability"}function E(ee,re,ie=!1){const ce=m(ee.filters||null,re),ve=[];ce.residual&&ve.push("filter");const he=ee.sort||[],ye=he.length===0||re.sort==="multi"&&he.length>=1||re.sort==="single"&&he.length===1;!ye&&he.length&&ve.push("sort");const Oe=ee.quick?String(ee.quick):"",Le=!Oe||!!re.quick;Le||ve.push("quick");const fe=ee.where&&ee.where.active?ee.where:null;fe&&ve.push("where");const ae={filters:ce.residual,sort:ye?null:he,quick:Le?"":Oe,where:fe},ke=!!ie,pe=Array.isArray(ee.groupBy)&&ee.groupBy.length>0,ue=pe?X(ee,re,ce,ye,Le,fe,ke):"",we=ee.pivotMode!==!1&&Array.isArray(ee.pivotBy)&&ee.pivotBy.length>0,Te=we?k(ee,re,ce,ye,Le,fe):"",Ne=we&&Te==="";we&&!Ne&&ve.push("pivot");const _e=we?Ne&&pe:pe&&ue==="";pe&&!we&&!_e&&ve.push("group");const $e=(_e||Ne)&&Array.isArray(ee.groupValues)?ee.groupValues.length:0;fe&&fe.conditioned&&(_e||Ne)&&(ae.where=null,ve.splice(ve.indexOf("where"),1));const je=_e||we?!1:ke||!!(ae.filters||ae.sort||ae.quick||ae.where)||!re.range;return{pushed:{...ee,filters:ce.pushed,sort:ye?he:[],quick:Le?Oe:"",range:je?null:ee.range},residual:ae,needsAll:je,unpushed:ve,full:ke,grouped:_e,groupLevel:$e,groupReason:we?"":ue,pivoted:Ne,pivotReason:Te}}function C(ee){const re=Array.isArray(ee.totals)?ee.totals:[],ie=ee.totalFns&&typeof ee.totalFns=="object"?ee.totalFns:{},ce=[],ve=[];for(const he of re){const ye=String(he),Oe=ie[ye],Le=typeof Oe=="string"?Oe:Oe&&typeof Oe.fn=="string"?Oe.fn:null,fe=Oe&&typeof Oe=="object"?s(Oe):void 0,ae=Le?t[Le]:null;ae&&ae.parametric&&fe===void 0?ve.push({id:ye,fn:Le,class:ae.class,reason:`"${Le}" needs \`p\`, a number from 0 to 1`}):Le?!ae||!ae.pushable||!ae.sql?ve.push({id:ye,fn:Le,class:ae?ae.class:"fallback",reason:ae&&ae.note?ae.note:`the pushdown map cannot express "${Le}"`}):ae.twoColumn?ve.push({id:ye,fn:Le,class:ae.class,reason:`"${Le}" reduces two columns, and a grouped request carries no weight column`}):ce.push({id:ye,col:ye,fn:Le,class:ae.class,...fe!==void 0?{p:fe}:{}}):ve.push({id:ye,fn:null,class:"fallback",reason:"the column totals with a host function, so there is no named statistic to push"})}return{engine:ce,client:ve}}function x(ee){return{...ee,engine:ee.engine.map(re=>{const ie=t[re.fn];if(!ie||!ie.sql)return re;const ce=ve=>`"${ve}"`;return{...re,sql:l(ie.sql,ce(re.col),re.weight!==void 0?ce(re.weight):void 0)}})}}const j=Object.freeze({items:ee=>ee==null?[]:Array.isArray(ee)?ee:[ee]});function T(ee,re,ie){if(!re)return ee;let ce=ee;if(re.filters&&U(ie.evaluateFilters)){const ve=ce,he={count:ce.length,handle:Le=>({id:Le,get:fe=>h(ve[fe],Le)}),itemwise:Le=>ve.some(fe=>Array.isArray(h(fe,Le)))?j:null},ye=ie.evaluateFilters(re.filters,he),Oe=[];for(let Le=0;Le<ce.length;Le++)ye[Le]&&Oe.push(ce[Le]);ce=Oe}if(re.where&&re.where.active&&(re.whole||O(re.where.names,"pushdown"),ce=ce.filter(ve=>re.where.passes(ve))),re.quick){const ve=re.quick.toLowerCase();ce=ce.filter(he=>{if(!he||typeof he!="object")return!1;for(const ye of Object.values(he))if(ye!=null&&String(ye).toLowerCase().includes(ve))return!0;return!1})}if(re.sort&&re.sort.length&&U(ie.sortMulti)){const ve=[...new Set(re.sort.map(Le=>Le.col))],he=ce,ye=ve.map(Le=>({id:Le,get:fe=>h(he[fe],Le)})),Oe=ie.sortMulti(ye,re.sort.map(Le=>({col:Le.col,dir:Le.dir})),Uint32Array.from({length:ce.length},(Le,fe)=>fe),{});ce=Array.from(Oe,Le=>he[Le])}return ce}function F(ee){return JSON.stringify({filters:ee.filters||null,sort:ee.sort||[],quick:ee.quick||"",groupBy:ee.groupBy||[],groupPath:ee.groupPath||[],context:ee.context??null})}function $(ee){if(!ee||typeof ee!="object")return 16;let re="";try{re=JSON.stringify(ee)}catch{return 200}return re.length*2+64}function D(ee){const re=ee||{};return{enabled:!!re.enabled,maxRows:Number.isFinite(re.maxRows)?re.maxRows:1e6,maxBytesEstimate:Number.isFinite(re.maxBytesEstimate)?re.maxBytesEstimate:512*1024*1024}}const z=5e4;function G(ee){return Number.isFinite(ee)&&ee>=0?ee:z}function N(ee){return!!ee&&U(ee.then)}async function Z(ee){if(!ee||ee.total!==void 0||!N(ee.pendingTotal))return ee;const re=await ee.pendingTotal,{pendingTotal:ie,...ce}=ee;return typeof re=="number"?{...ce,total:re}:ce}function Q(ee={}){const re=ee.adapter;if(!re||!U(re.execute))return L("source.pushdown.adapter","createPushdownSource needs an `adapter` with an `execute(query)` function."),{...ee,mode:"remote",fetch:async()=>({rows:[],total:0})};const ie=y(re.capabilities),ce=re.capabilities&&Object.getOwnPropertyDescriptor(re.capabilities,"operators");ce&&U(ce.get)&&Object.defineProperty(ie,"operators",{enumerable:!0,configurable:!0,get:()=>new Set(re.capabilities.operators||[]),set:()=>{}});const ve=re.name||"adapter";let he=null;const ye=()=>U(re.ready)?(he||(he=Promise.resolve(re.ready()).then(()=>{Object.assign(ie,y(re.capabilities))},oe=>{throw he=null,oe})),he):null,Oe=D(ee.fullDataset),Le=!!ee.allowPartialResults,fe=G(ee.whereRowLimit);let ae=null;const ke=ee.aggregates;let pe=null,ue=null,we=null,Te=null,Ne=null,_e=null,$e=0,je=null;const Ge=()=>!Oe.enabled||!pe?null:(je!==pe.key&&($e++,je=pe.key),{rows:pe.rows,version:$e}),Fe=async oe=>{const de=oe.where&&oe.where.active?oe.where:null;if(!de)return{request:oe,probe:null};if(de.conditioned){const rt=E(oe,ie,Oe.enabled);if(rt.grouped||rt.pivoted)return{request:oe,probe:null}}const{where:Ae,...Ce}=oe,De=E(Ce,ie,Oe.enabled);if(De.needsAll)return{request:oe,probe:null};const Ue=F(De.pushed);let qe=null;return(!ae||ae.key!==Ue)&&(ie.total?(r(oe),qe=await Z(await re.execute(De.pushed,oe)),ae={key:Ue,size:qe&&typeof qe.total=="number"?qe.total:null}):ae={key:Ue,size:null}),ae.size!==null&&ae.size<fe?{request:oe,probe:null}:(v(de.names,ve,ae.size,fe),{request:Ce,probe:qe})},Pe=async(oe,de)=>{_e=null;const Ae=C(oe.pushed);we={engine:Ae.engine,client:Ae.client,groupBy:oe.pushed.groupBy},Ae.client.length&&L(`source.pushdown.group.totals.${ve}.${Ae.client.map(Ue=>Ue.id).join(".")}`,`the ${ve} adapter cannot compute the group subtotal for ${Ae.client.map(Ue=>`"${Ue.id}" (${Ue.reason})`).join(", ")}, so those group rows carry no value for that column. A figure computed over anything other than the group would be wrong, so none is shown; \`lastPlan().aggregates.client\` names them.`);const Ce=await re.executeGroupLevel(oe.pushed,Ae.engine,de)||{};let De=Ce.rows||[];return!ie.range&&de.range&&(De=De.slice(de.range.start,de.range.end)),We(Ce),Ce.total===void 0?{rows:De}:{rows:De,total:Ce.total}},Ee=new Map,Me=64,Ie=async(oe,de)=>{_e=null;const Ae=oe.pushed,Ce=Ae.groupBy,De=Array.isArray(Ae.groupValues)?Ae.groupValues:[],Ue=De.length,qe=[...Ae.filters?[Ae.filters]:[],...Ce.slice(0,Ue).map((at,mt)=>({col:at,op:"eq",value:De[mt]===void 0?null:De[mt],caseSensitive:!0}))],rt=qe.length===0?null:qe.length===1?qe[0]:{op:"and",conditions:qe},ct=de.range?de.range.start:0;if(Ue>=Ce.length){const at={...Ae,filters:rt,groupBy:[],groupPath:[],groupValues:[],totals:[],totalFns:{}},mt=await Z(await re.execute(at,de))||{};let xt=mt.rows||[];return!ie.range&&de.range&&(xt=xt.slice(de.range.start,de.range.end)),typeof mt.total=="number"?{rows:xt,total:mt.total}:{rows:xt}}const ot=Ce[Ue],vt=C(Ae),Rt=S(ie),At=vt.engine.filter(at=>Rt.has(at.fn)),_t=[...vt.engine.filter(at=>!Rt.has(at.fn)).map(at=>({id:at.id,fn:at.fn,class:at.class,reason:`the ${ve} adapter does not compute "${at.fn}"`})),...vt.client];we={engine:At,client:_t,groupBy:Ce},_t.length&&L(`source.pushdown.group.totals.${ve}.${_t.map(at=>at.id).join(".")}`,`the ${ve} adapter cannot compute the group subtotal for ${_t.map(at=>`"${at.id}" (${at.reason})`).join(", ")}, so those group rows carry no value for that column. A figure computed over anything other than the group would be wrong, so none is shown; \`lastPlan().aggregates.client\` names them.`);const tn=[...At.map(at=>({id:at.id,col:at.col,fn:at.fn,...at.p!==void 0?{p:at.p}:{}})),{id:w,col:ot,fn:"count"}],Ht={...Ae,filters:rt,range:null},Xt=JSON.stringify([F(Ht),De,ot,tn]);let Ze=ct>0?Ee.get(Xt):void 0;if(!Ze){for(Ze=Promise.resolve(re.executeGroupedAggregates(Ht,[ot],tn)),Ee.delete(Xt),Ee.set(Xt,Ze);Ee.size>Me;)Ee.delete(Ee.keys().next().value);Ze.catch(()=>{Ee.get(Xt)===Ze&&Ee.delete(Xt)})}const lt=await Ze||[];r(de);const St=at=>{const mt={};for(const xt of At)mt[xt.id]=at?at[xt.id]:void 0;return mt},bt=(Ae.sort||[]).find(at=>at&&at.col===ot),wt=bt&&bt.dir==="desc"?-1:1,Ke=lt.filter(at=>at&&at.level===1).map(at=>({[ot]:at.keys[0]===void 0?null:at.keys[0],leafCount:Number(at.values&&at.values[w])||0,totals:St(at.values)})).sort((at,mt)=>wt*A(at[ot],mt[ot]));if(Ue===0){const at=lt.find(xt=>xt&&xt.level===0),mt=at?Number(at.values&&at.values[w]):NaN;We({matchCount:Number.isFinite(mt)?mt:Ke.reduce((xt,Ft)=>xt+Ft.leafCount,0),...at?{grand:St(at.values)}:{}})}const ht=de.range?de.range.end:Ke.length;return{rows:Ke.slice(ct,ht),total:Ke.length}},We=oe=>{typeof oe.matchCount=="number"&&(Te=oe.matchCount,Ne=oe.grand?{totals:oe.grand,leafCount:oe.matchCount}:null)},Ye=async(oe,de)=>{_e=null;const Ae=C(oe.pushed);we={engine:Ae.engine,client:Ae.client,groupBy:oe.pushed.groupBy,pivotBy:oe.pushed.pivotBy},Ae.client.length&&L(`source.pushdown.pivot.totals.${ve}.${Ae.client.map(rt=>rt.id).join(".")}`,`the ${ve} adapter cannot compute the pivot cells for ${Ae.client.map(rt=>`"${rt.id}" (${rt.reason})`).join(", ")}, so those cells are empty. A figure computed over anything other than the cell would be wrong, so none is shown; \`lastPlan().aggregates.client\` names them.`);const Ce=await re.executePivotLevel(oe.pushed,Ae.engine,de)||{};let De=Ce.rows||[];!ie.range&&de.range&&(De=De.slice(de.range.start,de.range.end)),We(Ce);const Ue=Ce.pivot&&typeof Ce.pivot=="object"?Ce.pivot:{},qe={cells:Array.isArray(Ue.cells)?Ue.cells:[],...Array.isArray(Ue.axis)?{axis:Ue.axis}:{}};return Ce.total===void 0?{rows:De,pivot:qe}:{rows:De,total:Ce.total,pivot:qe}},nt=oe=>{L(`source.pushdown.pivot.${ve}.${oe}`,`pushdown:pivot-unsupported: the ${ve} adapter cannot pivot this query because ${oe}, so no rows are fetched rather than every leaf row being pulled into the browser to pivot there. \`lastPlan().pivotReason\` says the same.`);const de=new Error(`[lattice] ${q}: the ${ve} adapter cannot pivot this query because ${oe}, so no rows are fetched rather than every leaf row being pulled into the browser to pivot there. \`lastPlan().pivotReason\` says the same.`);throw de.code=q,de.reason=oe,de},Qe=(oe,de)=>{const Ae={key:de,state:"pending",value:null};return _e=Ae,oe.then(Ce=>(_e===Ae&&(_e={key:de,state:"settled",value:typeof Ce=="number"?Ce:null}),Ce),Ce=>{throw _e===Ae&&(_e={key:de,state:"failed",value:null}),Ce})};let dt=0,jt=[];const Et=()=>dt===0?null:new Promise(oe=>{const de=setTimeout(oe,p);jt.push(()=>{clearTimeout(de),oe()})});let it;const ft=async oe=>{const de=ye();de&&await de;const Ce=oe&&oe.pivotMode!==!1&&Array.isArray(oe.pivotBy)&&oe.pivotBy.length>0?{request:oe,probe:null}:await Fe(oe);r(oe);let De=E(Ce.request,ie,Oe.enabled);if(ie.group&&De.grouped&&!De.pivoted&&!U(re.executeGroupLevel)&&(L(`source.pushdown.group.method.${ve}`,`the ${ve} adapter declares the \`group\` capability but has no \`executeGroupLevel(query, aggregates, request)\`, so grouping is not pushed and the grid stays ungrouped unless it holds the whole matching set. Implement the method or drop the capability.`),De=E(Ce.request,{...ie,group:!1,aggregates:null},Oe.enabled)),De.pivoted&&!U(re.executePivotLevel)&&(De=E(Ce.request,{...ie,pivot:!1},Oe.enabled),De.pivotReason="the adapter declares the `pivot` capability but has no `executePivotLevel(query, aggregates, request)`"),De.grouped&&!De.pivoted&&!ie.group&&!U(re.executeGroupedAggregates)&&(L(`source.pushdown.group.aggregates.method.${ve}`,`the ${ve} adapter declares \`aggregates\` but has no \`executeGroupedAggregates(query, groupBy, aggregates)\`, so the grouped view cannot be built from grouped aggregates and the grid stays ungrouped unless it holds the whole matching set. Implement the method, or declare \`group\` and implement \`executeGroupLevel\`.`),De=E(Ce.request,{...ie,aggregates:null},Oe.enabled)),ue=De,De.pivoted)return Ye(De,oe);if(De.pivotReason&&nt(De.pivotReason),De.grouped)return ie.group?Pe(De,oe):Ie(De,oe);const qe=!!De.groupReason&&!De.full;qe?L(`source.pushdown.group-unsupported.${ve}.${De.groupReason}`,`pushdown:group-unsupported: the ${ve} adapter was not asked to group this query because ${De.groupReason}, so the grid stays ungrouped rather than building group rows, counts and subtotals from a window of leaf rows. \`lastPlan().groupReason\` says the same.`):De.groupReason&&L(`source.pushdown.group.${ve}.${De.groupReason}`,`the ${ve} adapter was not asked to group this query because ${De.groupReason}. The engine returns rows and the grouping is the grid's to do, which needs every matching row in the browser — correct where the grid holds them, and wrong-looking where it holds a window. \`lastPlan().unpushed\` names it.`);const rt=Ht=>qe?{...Ht,[P]:!0}:Ht;if(!De.needsAll){const Ht=Ce.probe||await re.execute(De.pushed,oe),Xt=Ht.rows||[];return N(Ht.pendingTotal)&&Ht.total===void 0?rt({rows:Xt,pendingTotal:Qe(Ht.pendingTotal,F(De.pushed))}):(_e=null,!ie.total&&Ht.total===void 0?rt({rows:Xt}):rt({rows:Xt,total:Ht.total??Xt.length}))}const ct=De.unpushed.filter(Ht=>!(Ht==="where"&&De.residual.where&&De.residual.where.anyConditioned));ct.length&&L(`source.pushdown.residual.${ve}.${ct.join(".")}`,`the ${ve} adapter cannot push ${ct.join(" or ")}, so every matching row is fetched and the rest is applied in the browser. Correct, and slower than it needs to be: widening the adapter is the fix.`);const ot=F(De.pushed);if(!pe||pe.key!==ot){const Ht=await Z(await re.execute(De.pushed,oe));_e=null;const Xt=Ht.rows||[];if(De.full){const Ze=typeof Ht.total=="number"?Math.max(Ht.total,Xt.length):Xt.length;if(Ze>Oe.maxRows)throw new Error(`[lattice] fullDataset refused: the ${ve} adapter's matching set is ${Ze.toLocaleString()} rows, past the configured maxRows of ${Oe.maxRows.toLocaleString()}. The whole set cannot be held client-side, so it is refused rather than truncated — a fraction shown as the whole would make every total and statistic silently wrong. Narrow the filter or raise maxRows.`);const lt=Xt.length*$(Xt[0]);if(lt>Oe.maxBytesEstimate)throw new Error(`[lattice] fullDataset refused: the ${ve} adapter's matching set is an estimated ${Math.round(lt/(1024*1024)).toLocaleString()} MB across ${Xt.length.toLocaleString()} rows, past the configured maxBytesEstimate of ${Math.round(Oe.maxBytesEstimate/(1024*1024)).toLocaleString()} MB. The whole set cannot be held client-side, so it is refused rather than truncated. Narrow the filter or raise maxBytesEstimate.`)}if(typeof Ht.total=="number"&&Xt.length<Ht.total){const Ze=!!(De.residual.filters||De.residual.quick||De.residual.sort&&De.residual.sort.length);if(Ze&&!Le)throw new Error(`[lattice] the ${ve} adapter returned ${Xt.length} of ${Ht.total} matching rows when asked for the whole result, and the query has residual ${De.unpushed.join(" and ")||"work"} to finish in the browser. Filtering or sorting a fraction of the result would return wrong rows, so the result is refused. Fix the adapter to follow the engine's own paging before returning, hold the data in memory, or set \`allowPartialResults: true\` on the source config to accept this knowingly.`);Ze?L(`source.pushdown.partial.residual.${ve}`,`the ${ve} adapter returned ${Xt.length} of ${Ht.total} matching rows when asked for the whole result, and residual work will run over that fraction. allowPartialResults is set, so the result is used as-is — it may be wrong. The adapter must follow the engine's own paging to be correct.`):L(`source.pushdown.partial.${ve}`,`the ${ve} adapter returned ${Xt.length} of ${Ht.total} matching rows when asked for the whole result. The adapter must follow the engine's own paging before returning.`)}pe={key:ot,rows:Xt,total:typeof Ht.total=="number"?Ht.total:null}}let vt=De;if(De.residual.where){const Ht=pe.total??pe.rows.length;if(Ht>=fe){v(De.residual.where.names,ve,Ht,fe);const{where:Xt,...Ze}=Ce.request;vt=E(Ze,ie,Oe.enabled),ue=vt}}const Rt=pe.total!==null&&pe.rows.length>=pe.total,At=T(pe.rows,{...vt.residual,whole:Rt},ee.compute||{}),_t=oe.range?oe.range.start:0,tn=oe.range?oe.range.end:At.length;return rt({rows:At.slice(_t,tn),total:At.length})},pt=async(oe,de,Ae)=>{const De=Ae&&Ae.waitForPage&&it&&U(it.pageForegroundIdle)?it.pageForegroundIdle():Et();De&&await De;const Ue=ye();Ue&&await Ue;const qe=E(oe,ie,Oe.enabled);ue=qe;const rt=g(de,Ae&&Ae.engine?{default:"engine"}:ke),ct=Array.isArray(oe.groupBy)?oe.groupBy:[],ot=ct.length>0,vt=!qe.residual.filters&&!qe.residual.quick,Rt=!ot||o(ct,ie.buckets);let At=rt.engine,_t=rt.client;if(ie.aggregates&&At.length){const lt=ie.aggregates instanceof Set?ie.aggregates:new Set(J(ie.aggregates)),St=At.filter(bt=>!lt.has(bt.fn));St.length&&(At=At.filter(bt=>lt.has(bt.fn)),_t=[...St.map(bt=>({...bt,reason:`the ${ve} adapter does not compute "${bt.fn}"`})),..._t])}const tn=lt=>{_t=[...At.map(St=>({...St,reason:lt})),..._t],At=[]};let Ht="";if(At.length&&!vt){const lt=qe.residual.quick&&!qe.residual.filters?"a quick search the adapter cannot push forces all-client (no mixed provenance)":"residual filter forces all-client (no mixed provenance)";tn(lt),ot&&(Ht=lt)}else if(At.length&&!Rt){const lt="a grouping key the engine cannot form forces all-client (no mixed provenance)";tn(lt),Ht=lt}let Xt={},Ze;if(At.length&&(U(ot?re.executeGroupedAggregates:re.executeAggregates)?ot?Ze=await re.executeGroupedAggregates(qe.pushed,ct,At)||[]:Xt=await re.executeAggregates(qe.pushed,At)||{}:(L(`source.pushdown.aggregates.${ve}${ot?".grouped":""}`,`the ${ve} adapter cannot compute ${ot?"grouped ":""}aggregates, so every requested statistic is computed client-side. Correct, and slower than it needs to be.`),tn(`adapter cannot compute ${ot?"grouped ":""}aggregates`),ot&&(Ht=`the ${ve} adapter cannot compute grouped aggregates`))),ot){const lt=Ze!==void 0;lt!==qe.grouped&&(ue={...qe,grouped:lt,groupReason:lt?"":Ht||qe.groupReason,unpushed:lt?qe.unpushed.filter(St=>St!=="group"):qe.unpushed.includes("group")?qe.unpushed:[...qe.unpushed,"group"]})}return we={engine:At,client:_t,...ot?{groupBy:ct}:{}},{values:Xt,engine:At,client:_t,...Ze!==void 0?{groups:Ze}:{}}},Tt=async oe=>{dt++;try{return await ft(oe)}finally{if(dt--,dt===0&&jt.length){const de=jt;jt=[];for(const Ae of de)Ae()}}},Nt=a(ee.edit),Lt=ee.edit&&typeof ee.edit=="object"&&U(ee.edit.commit);let Je=ee.edit;if(Nt&&!Lt)if(ie.mutate&&ie.mutate.update){const oe=de=>{if(!ie.mutate||!ie.mutate.update)throw new Error(`[lattice] the ${ve} adapter cannot update rows (mutate.update is not declared), so this edit cannot be persisted. The cell is reverted rather than left looking saved.`);const Ae={kind:"update",key:String(de.key),patch:{[de.colId]:de.value}};return re.mutate(Ae,de.request||{})};Je={...ee.edit===!0?{}:ee.edit,commit:oe}}else L(`source.pushdown.readonly.${ve}`,`edit is enabled but the ${ve} adapter declares mutate: ${ie.mutate?"without update":"false"} (read-only by declaration), so no commit is synthesised and the grid stays read-only. Declare \`mutate: { update: true }\` on the adapter to allow cell edits.`);const se=Nt&&ie.mutate&&(ie.mutate.append||ie.mutate.delete)?{append:ie.mutate.append===!0,remove:ie.mutate.delete===!0,returning:ie.mutate.returning,mutate:(oe,de)=>re.mutate(oe,de||{})}:null,ge=async oe=>{const de=ye();de&&await de;const{range:Ae,signal:Ce,export:De,...Ue}=oe||{},qe={...Ue,groupBy:[],groupPath:[],groupValues:[],pivotBy:[],pivotMode:!1,totals:[]};return{plan:E(qe,ie,Oe.enabled),signal:Ce}};async function*Se(oe,de={}){const{plan:Ae,signal:Ce}=await ge(oe),De=Math.max(1,Math.floor(Number(de.pageSize))||5e3),Ue={signal:Ce,stream:!0},qe=oe&&oe.range&&Number.isFinite(Number(oe.range.start))&&Number.isFinite(Number(oe.range.end))?{start:Math.max(0,Number(oe.range.start)),end:Math.max(0,Number(oe.range.end))}:null;if(!Ae.needsAll){const ot=qe?qe.start:0,vt=qe?qe.end:1/0;for(let Rt=ot;Rt<vt;Rt+=De){r(Ue);const At=Math.min(Rt+De,vt),_t=await re.execute({...Ae.pushed,range:{start:Rt,end:At}},Ue);_t&&N(_t.pendingTotal)&&_t.pendingTotal.then(null,()=>{});const tn=_t&&_t.rows||[];if(tn.length&&(yield tn),tn.length<At-Rt)return}return}r(Ue);const rt=await Z(await re.execute({...Ae.pushed,range:void 0},Ue));let ct=T(rt&&rt.rows||[],{...Ae.residual,whole:!0},ee.compute||{});qe&&(ct=ct.slice(qe.start,qe.end));for(let ot=0;ot<ct.length;ot+=De)yield ct.slice(ot,ot+De)}const Re=async oe=>{const{plan:de,signal:Ae}=await ge(oe);if(!de.needsAll&&ie.total){r({signal:Ae});const De=await Z(await re.execute({...de.pushed,range:{start:0,end:0}},{signal:Ae}));if(De&&typeof De.total=="number")return De.total}let Ce=0;for await(const De of Se({...oe,range:void 0}))Ce+=De.length;return Ce},xe=async oe=>{await ye();const de=b(oe.filters||null,{tz:ee.timeZone,weekStartsOn:ee.weekStartsOn}),Ae=oe.quick?String(oe.quick):"";return m(de,ie).residual||Ae&&!ie.quick?null:re.facets({...oe,filters:de,quick:Ae})};return it={...ee,edit:Je,rowMutate:se,mode:"remote",fetch:Tt,foregroundIdle:Et,facetProvider:U(re.facets)?xe:void 0,aggregate:pt,countMatching:Re,streamMatching:Se,capabilitiesOf:y,planQuery:E,wireFilters:b,resolveAggregatePlan:(oe,de)=>g(oe,de&&de.engine?{default:"engine"}:ke),STAT_PUSHDOWN:t,lastPlan:()=>ue?{...ue,...we?{aggregates:x(we)}:{},..._e?{total:{deferred:!0,state:_e.state,value:_e.value}}:{}}:null,fullFrame:Ge,counts:()=>({match:Te,total:Te,pending:!!_e&&_e.state==="pending"}),grandTotals:()=>Ne},it}}),ze("packages/core/src/source/remote.js",function(e,B){"use strict";Object.defineProperty(e,"PROTOCOL",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"HINT_SETTLE_MS",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"createRemoteSource",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"RemoteSource",{enumerable:!0,get:function(){return x}});const A=B("packages/core/src/internal/lru.js").Lru,U=B("packages/core/src/internal/predicates.js").isFunction,J=B("packages/core/src/internal/warn.js").warnOnce,L=B("packages/core/src/internal/schedule.js").settleDebounce,Y=B("packages/core/src/source/abort.js"),_=Y.createAbortScope,O=Y.isAbortError,v=B("packages/core/src/source/blockcache.js"),b=v.BlockCache,c=v.DEFAULT_PAGE_SIZE,g=v.DEFAULT_MAX_CACHED_PAGES,o=B("packages/core/src/source/rows.js"),t=o.createRowFactory,s=o.groupKey,l=B("packages/core/src/source/filterwire.js"),u=l.wireFilters,n=l.querySignature,p=l.warnHostFilterNotApplied,i=B("packages/core/src/source/pagewindow.js").pageWindow,h=B("packages/core/src/source/memory.js").MemorySource,y=B("packages/core/src/compute/handle.js").valueComparator,f=B("packages/core/src/compute/pivot.js"),m=f.pivotKey,w=f.joinPath,S=f.DEFAULT_PATH_SEPARATOR,X=B("packages/core/src/source/pushdown.js").UNGROUPED_LEVEL,q=1,K=120,P=1e3;function k(j,T,F){for(let $=0;$<Math.max(j.length,T.length);$++){const D=j[$],z=T[$],G=D==null,N=z==null;if(G||N){if(G&&N)continue;return G?1:-1}const Z=F(D,z);if(Z!==0)return Z}return 0}function E(j,T){return new x(j,T)}class C{constructor(T,F,$,D){this.path=T,this.keyPath=D||T,this.values=[],this.level=F,this.key=s(this.keyPath),this.cache=new b($),this.count=null,this.complete=!1,this.announced=null,this.counting=!1,this.failed=!1,this.children=new Map,this.row=null,this.flat=!1}}class x{mode="remote";#e;#t;#n;#r;#s=new Map;#i=new Set;#a=_();#l;#o;#c=new Map;#u=[];#f=null;#d="";#h;#p=!1;#m=!1;#g=[];#b=!1;#y=0;#S="";#w=null;#A=-1;constructor(T,F){this.#e=T||{mode:"remote"},this.#t=F||{},U(this.#e.fullFrame)&&(this.filteredIndices=()=>this.#D(),this.unfilteredIndices=()=>this.#G(),this.handleFor=Z=>this.#K(Z),this.display=()=>this.#L(),this.grandTotalRow=()=>this.#B(),this.unfilteredRows=()=>this.#I(),this.facetIndices=Z=>this.#q(Z));const $=this.#e.counts;U($)&&(this.matchCount=()=>this.#Y("match"),this.totalCount=()=>this.#Y("total"));const D=this.#e.grandTotals;U(D)&&(this.grandTotalRow=()=>this.#z());const z=this.#e.foregroundIdle;U(z)&&(this.foregroundIdle=()=>this.#oe(z),this.#e.pageForegroundIdle=()=>this.#b?this.#oe(z):null);const G=this.#e.facetProvider;U(G)&&(this.facetProvider=G);const N=this.#e;U(N.countMatching)&&U(N.streamMatching)&&(this.selectionQuery=()=>this.#W(),this.countMatching=Z=>N.countMatching(Z),this.streamMatching=(Z,Q)=>N.streamMatching(Z,Q),this.loadedRows=()=>this.#ge(),this.resident=()=>this.#N()!==null),this.#n={pageSize:this.#e.pageSize||c,maxCachedPages:this.#e.maxCachedPages||g},this.#l=t(this.#t),this.#o=new A(this.#n.pageSize*4),this.#h=L((Z,Q)=>this.#T(Z,Q),K),this.#r=new C([],0,this.#n),this.#s.set(this.#r.key,this.#r),this.#d=this.#be(),U(this.#e.fetch)||J("source.remote.fetch",'source.mode "remote" requires a fetch function; the grid will stay empty.'),this.#de()}count(){const T=this.#O();return T?T.length:this.#v()}#v(){const T=this.#N();return T?T.count():(this.#re(),this.#Ae(this.#r))}#C(){if(this.#N())return!0;const T=F=>{if(F.count===null&&!F.complete)return!1;for(const $ of F.children.values())if(this.#Te($.key,this.#we($))&&!T($))return!1;return!0};return T(this.#r)}pageInfo(){const T=this.#O(),F=this.totalPending();if(!T){const $=this.#v();return{page:0,pageSize:0,total:this.#C()?$:null,pageCount:1,counting:F}}return{page:T.page,pageSize:T.pageSize,total:T.total,pageCount:T.pageCount,counting:F||T.total===null&&this.#a.size>0&&this.#r.cache.loadedExtent()===0}}#O(){const T=this.#v(),F=i(this.#$("pageSize",0),this.#$("page",0),T,this.#C());if(!F)return this.#S="",null;const $=`${this.#y}:${F.offset}:${F.length}`;return $!==this.#S&&!this.#p&&(this.#S=$,F.length>0&&!this.#N()&&this.#T(F.offset,F.offset+F.length-1)),F}at(T){const F=this.#O();if(F){if(T<0||T>=F.length)return;const $=this.#P(F.offset+T);return $&&($.index=T),$}return this.#P(T)}#P(T){const F=this.#N();if(F)return F.at(T);if(this.#re(),T<0||T>=this.#v())return;const $=this.#Z(this.#r,T);if(!$)return;const D=this.#V($.node,$.local);return D&&(D.index=T),D||this.#l.skeleton(T,$.node.level,$.node.cache.erroredAt($.local))}byKey(T){const F=this.#N();if(F)return F.byKey(T);const $=this.#c.get(T);if(!$)return;const D=$.lastIndexOf(":"),z=this.#s.get($.slice(0,D));return z&&this.#V(z,Number($.slice(D+1)))||void 0}loaded(T){const F=this.#O();if(F){if(T<0||T>=F.length)return!1;T+=F.offset}const $=this.#N();if($)return $.loaded(T);if(T<0||T>=this.#v())return!1;const D=this.#Z(this.#r,T);return!!D&&D.node.cache.rowLoaded(D.local)}hint(T,F){if(this.#p)return;this.#b=!0;const $=this.#re();let D=Math.max(0,Math.floor(T)),z=Math.max(D,Math.floor(F));const G=this.#O();if(G){if(G.length===0)return;D=G.offset,z=G.offset+G.length-1}for(const[N,Z]of this.#E(D,z)){N.cache.protect(Z.min,Z.max);for(const Q of N.cache.evict())this.#Ee(N,Q)}this.#h(D,z),$&&this.#h.flush()}#E(T,F){const $=this.#v(),D=new Map;for(let z=T;z<=F&&z<$;z++){const G=this.#Z(this.#r,z);if(!G)continue;const N=D.get(G.node);N?(N.min=Math.min(N.min,G.local),N.max=Math.max(N.max,G.local)):D.set(G.node,{min:G.local,max:G.local})}return D.size||D.set(this.#r,{min:T,max:T}),D}#T(T,F){if(!this.#p)for(const[$,D]of this.#E(T,F)){$.cache.protect(D.min,D.max);const z=$.cache.blockOf(D.min),G=$.cache.blockOf(D.max);for(let N=z;N<=G&&!($.count!==null&&N*$.cache.pageSize>=$.count);N++)$.cache.has(N)||this.#ue($,N)}}apply(T){const F={added:[],updated:[],removed:[]};if(!T)return F;if(T.update)for(const $ of T.update){const D=this.#c.get(this.#l.keyOf($,-1));if(!D)continue;this.#o.delete(D);const z=D.lastIndexOf(":"),G=this.#s.get(D.slice(0,z));if(!G)continue;const N=Number(D.slice(z+1)),Z=G.cache.blockOf(N);if(!G.cache.loaded(Z))continue;const{start:Q}=G.cache.rangeOf(Z),ee=[];for(let ie=Q;ie<Q+G.cache.pageSize;ie++){const ce=G.cache.rowAt(ie);if(ce===void 0)break;ee.push(ie===N?$:ce)}G.cache.fill(Z,ee);const re=this.#V(G,N);re&&F.updated.push(re)}return(T.add&&T.add.length||T.remove&&T.remove.length)&&this.reload({keepExpanded:!0}),F}reload(T){this.#a.abortAll("reload"),this.#h.cancel(),T&&T.keepExpanded===!1&&this.#i.clear(),this.#pe(),this.#U("model:changed",{reason:"reload"})}destroy(){this.#p=!0,this.#h.cancel(),this.#a.abortAll("destroyed"),this.#pe(),this.#s.clear(),this.#i.clear(),this.#w&&U(this.#w.destroy)&&this.#w.destroy(),this.#w=null}expand(T){this.#i.has(T)||(this.#i.add(T),this.#U("group:toggled",{key:T,expanded:!0}),this.#U("model:changed",{reason:"expand",key:T}))}collapse(T){this.#i.delete(T)&&(this.#U("group:toggled",{key:T,expanded:!1}),this.#U("model:changed",{reason:"collapse",key:T}))}expandedKeys(){return[...this.#i]}pivotFields(){return this.#u}pivot(){this.#re();const T=this.#f;if(!T||!T.keys.size||!this.#$("pivotBy",[]).length)return null;if(!T.result){const F=y((this.#t.config||{}).locale),$=[...T.keys.entries()].sort((z,G)=>k(z[1],G[1],F)),D=$.map(([z])=>z);T.result={keys:$.map(([,z])=>z),paths:D,fields:this.#Pe(D),groupPaths:[],columns:D.length*Math.max(1,this.#ve().length),values:T.cells,cells:T.cells,error:null}}return T.result}invalidateHandles(){this.#w&&(U(this.#w.invalidateHandles)&&this.#w.invalidateHandles(),U(this.#w.invalidate)&&this.#w.invalidate("filter"))}#M(){const T=this.#e.fullFrame;return U(T)?T():null}#N(){const T=this.#M();return T?(this.#w||(this.#w=new h({mode:"memory"},this.#R())),T.version!==this.#A&&(this.#w.setRows(T.rows),this.#A=T.version),this.#w):null}#R(){const T=this.#t,F=T.state||{};return{...T,state:{...F,page:()=>0,pageSize:()=>0}}}#D(){const T=this.#N();return T?T.filteredIndices():new Uint32Array(0)}#G(){const T=this.#N();return T?T.unfilteredIndices():new Uint32Array(0)}#K(T){const F=this.#N();return F?F.handleFor(T):void 0}#L(){const T=this.#N();return T?T.display():[]}#q(T){const F=this.#N();return F&&U(F.facetIndices)?F.facetIndices(T):new Uint32Array(0)}#B(){const T=this.#N();return T&&U(T.grandTotalRow)?T.grandTotalRow():null}#Y(T){const F=this.#N();if(F){const G=T==="match"?F.matchCount:F.totalCount;if(U(G))return G.call(F)}const $=this.#e.counts,D=U($)?$():null,z=D?D[T]:null;return typeof z=="number"?z:this.#v()}#z(){const T=this.#N();if(T&&U(T.grandTotalRow))return T.grandTotalRow();if((this.#t.config||{}).grandTotalRow!=="bottom")return null;const $=this.#e.grandTotals,D=U($)?$():null;return!D||!D.totals?null:this.#l.grandTotal(D.totals,D.leafCount||0)}#I(){const T=this.#N();if(T&&U(T.unfilteredRows))return T.unfilteredRows();const F=[],$=this.count();for(let D=0;D<$;D++){const z=this.at(D);z&&F.push(z)}return F}#W(){const T=this.#$("quick",""),F={protocol:q,groupPath:[],groupValues:[],groupBy:[],totals:[],totalFns:{},pivotBy:[],pivotMode:!1,filters:u(this.#$("filters",null),this.#Q()),sort:this.#$("sort",[]),context:this.#$("context",null)};T&&(F.quick=T);const $=this.#$("where",null);return $&&$.active&&(F.where=$),F}#ge(){const T=this.#$("groupBy",[]).length,F=[];for(const $ of this.#s.values())if(!($.level!==T&&!$.flat))for(const D of $.cache.ids()){if(!$.cache.loaded(D))continue;const{start:z,end:G}=$.cache.rangeOf(D);for(let N=z;N<G&&$.cache.rowLoaded(N);N++){const Z=this.#V($,N);Z&&!Z.group&&F.push(Z)}}return F}loadedCount(){const T=this.#N();if(T){const D=T.matchCount();return typeof D=="number"?D:T.count()}this.#re();const F=this.#$("groupBy",[]).length;let $=0;for(const D of this.#s.values())if(!(D.level!==F&&!D.flat))for(const z of D.cache.ids()){if(!D.cache.loaded(z))continue;const G=D.cache.fillOf(z);typeof G=="number"&&($+=G)}return $}residentRows(){const T=this.#N();return T?T.display():this.#$("groupBy",[]).length>0?null:(this.#re(),this.#ge())}#ie(T,F,$){const{start:D,end:z}=T.cache.rangeOf(F),G=this.#$("groupBy",[]),N=this.#$("pivotBy",[]),Z=this.#$("quick",""),Q=this.#ve(),ee={protocol:q,range:{start:D,end:z},groupPath:T.path,groupValues:T.values,groupBy:G,totals:Q,totalFns:this.#Oe(Q),pivotBy:N,pivotMode:N.length>0,filters:u(this.#$("filters",null),this.#Q()),sort:this.#$("sort",[]),context:this.#$("context",null),signal:$};Z&&(ee.quick=Z);const re=this.#$("where",null);return re&&re.active&&(ee.where=re),ee}async#ue(T,F){if(!U(this.#e.fetch))return;if(!this.#m){this.#m=!0;const G=this.#g;this.#g=[],queueMicrotask(()=>{for(const N of G)N()})}const $=this.#a.begin(`${T.key}:${F}`);T.cache.begin(F,$);const D=this.#d,{start:z}=T.cache.rangeOf(F);try{const G=await this.#e.fetch(this.#ie(T,F,$.signal));if(!$.current||D!==this.#d||this.#p)return;$.settle();const N=G&&G.rows||[];if(!!(G&&G[X])&&!T.flat){T.flat=!0,T.children.clear();for(const[re,ie]of[...this.#c])ie.startsWith(`${T.key}:`)&&(this.#o.delete(ie),this.#c.delete(re))}T.cache.fill(F,N),T.failed=!1;for(let re=0;re<N.length;re++)this.#o.delete(`${T.key}:${z+re}`);const Q=G&&typeof G.count=="number"?G.count:G&&typeof G.total=="number"?G.total:null,ee=G&&U(G.pendingTotal?.then)?G.pendingTotal:null;Q!==null?(T.count=Q,T.complete=!0):N.length<T.cache.pageSize?(T.count=z+N.length,T.complete=!0):ee&&(T.counting=!0,T.announced=null),G&&Array.isArray(G.pivotFields)&&this.#Ue(G.pivotFields),G&&G.pivot&&typeof G.pivot=="object"&&this.#ae(G.pivot),this.#U("model:changed",{reason:"page",groupPath:T.path,block:F}),this.#U("rows:changed",{companion:!0,reason:"page",groupPath:T.path,block:F}),this.#fe(T),ee&&this.#Me(T,ee,D)}catch(G){if($.settle(),O(G))return;T.cache.failed(F,G),T.failed=!0;const{end:N}=T.cache.rangeOf(F);for(let Z=z;Z<N;Z++)this.#o.delete(`${T.key}:${Z}`);this.#U("model:changed",{reason:"page-error",groupPath:T.path,block:F}),this.#U("source:error",{error:G,groupPath:T.path,block:F})}}async#Me(T,F,$){let D;try{D=await F}catch(z){if($!==this.#d||this.#p)return;T.counting=!1,O(z)||(T.failed=!0),O(z)||this.#U("source:error",{error:z,groupPath:T.path});return}$!==this.#d||this.#p||(T.counting=!1,typeof D=="number"&&(T.count=D,T.complete=!0,this.#fe(T),this.#U("model:changed",{reason:"total",count:D,groupPath:T.path})))}#fe(T){typeof T.count!="number"||!T.complete||T.announced!==T.count&&(T.announced=T.count,this.#U("source:total",{total:T.count,groupPath:T.path}))}#oe(T){if(this.#p)return null;this.#re();const F=this.#m?null:new Promise(N=>{this.#g.push(N),setTimeout(N,P)}),$=T();if(!F&&!$)return null;const D=(async()=>{F&&await F;for(let N=T();N;N=T())await N})();let z;const G=new Promise(N=>{z=setTimeout(N,P)});return Promise.race([D,G]).then(()=>clearTimeout(z))}totalPending(){if(this.#r.failed)return!1;if(this.#r.counting===!0)return!0;if(this.#N())return!1;this.#re();const T=this.#r;return T.count===null&&!T.complete&&T.cache.loadedExtent()===0}totalFailed(){return this.#r.failed===!0}#Ue(T){T.length===this.#u.length&&T.every((F,$)=>F===this.#u[$])||(this.#u=T,this.#U("column:pivoted",{pivotFields:T,remote:!0}))}#xe(){const T=this.#t.config||{};return T.pivot&&T.pivot.separator||S}#Pe(T){const F=this.#xe(),$=this.#ve();if(!$.length)return T.slice();const D=[];for(const z of T)for(const G of $)D.push(`${z}${F}${G}`);return D}#ae(T){const F=this.#xe();this.#f||(this.#f={keys:new Map,cells:new Map,result:null});const $=this.#f;let D=!1;const z=N=>{const Z=Array.isArray(N)?N:[N],Q=w(Z,F);return $.keys.has(Q)||($.keys.set(Q,Z),D=!0),Q},G=this.#$("groupBy",[]).length>0;for(const N of Array.isArray(T.axis)?T.axis:[])z(N);for(const N of Array.isArray(T.cells)?T.cells:[]){if(!N||typeof N!="object")continue;const Z=z(N.pivot);if(G&&!(Array.isArray(N.group)&&N.group.length))continue;const Q=w(Array.isArray(N.group)?N.group:[],F);for(const[ee,re]of Object.entries(N.values||{}))$.cells.set(m(Q,Z,ee),re)}$.result=null,D&&this.#Ue((this.pivot()||{fields:[]}).fields)}#Ae(T){let F=this.#le(T);for(const $ of T.children.values())this.#Te($.key,this.#we($))&&(F+=this.#Ae($));return F}#le(T){if(T.count!==null)return T.count;const F=T.cache.loadedExtent();return T.complete?F:T.row&&T.row.leafCount>0?T.level>=this.#$("groupBy",[]).length?Math.max(F,T.row.leafCount):F===0?1:Math.min(F+T.cache.pageSize,Math.max(F,T.row.leafCount)):F+T.cache.pageSize}#Z(T,F){let $=F,D=0;const z=[...T.children.entries()].filter(([,N])=>this.#Te(N.key,this.#we(N))).sort((N,Z)=>N[0]-Z[0]);for(const[N,Z]of z){const Q=N-D+1;if($<Q)return{node:T,local:D+$};$-=Q,D=N+1;const ee=this.#Ae(Z);if($<ee)return this.#Z(Z,$);$-=ee}const G=this.#le(T);return D+$<G?{node:T,local:D+$}:null}#V(T,F){const $=`${T.key}:${F}`,D=this.#o.get($);if(D)return D.group===!0?this.#_(D):D;const z=T.cache.rowAt(F);if(z===void 0)return null;const G=this.#$("groupBy",[]);let N;if(T.level<G.length&&!T.flat){const Z=G[T.level],Q=this.#f!==null&&T.level===G.length-1&&this.#$("pivotBy",[]).length>0,ee=this.#ye(z,Z),re=ee==null,ie=[...T.path,re?"":String(ee)],ce=[...T.keyPath,re?null:String(ee)];if(N=this.#l.group({path:ie,keyPath:ce,column:Z,value:ee,level:T.level,parent:T.row,leafCount:Number(z.leafCount)||0,expanded:Q?!1:this.#Te(s(ce),{key:s(ce),column:Z,value:ee,level:T.level,path:ie}),...Q?{hasChildren:!1}:{}}),N.totals=this.#ne(z),N.data=z,!Q){let ve=this.#s.get(N.key);ve?ve.row=N:(ve=new C(ie,T.level+1,this.#n,ce),ve.row=N,this.#s.set(ve.key,ve)),ve.values=[...T.values,ee],T.children.set(F,ve)}}else N=this.#l.leaf(z,F,T.level,T.row);return this.#o.set($,N),this.#c.set(N.key,$),N}#ne(T){const F=T||{};if(F.totals&&typeof F.totals=="object")return F.totals;const $={};for(const D of this.#ve())Object.hasOwn(F,D)&&($[D]=F[D]);return $}#_(T){const F=this.#s.get(T.key);if(!F||F.row!==T||T.hasChildren===!1)return T;const $=this.#Te(T.key,this.#we(F));return T.expanded!==$&&(T.expanded=$),T}#Ee(T,F){const{start:$,end:D}=T.cache.rangeOf(F);for(let z=$;z<D;z++){const G=`${T.key}:${z}`,N=this.#o.peek(G);N&&this.#c.delete(N.key),this.#o.delete(G)}}#re(){const T=this.#be();return T===this.#d?!1:(this.#d=T,this.#a.abortAll("query"),this.#pe(),this.#m=!1,this.#U("model:changed",{reason:"query"}),!0)}#pe(){for(const T of this.#s.values())T.cache.clear(),T.count=null,T.complete=!1,T.announced=null,T.counting=!1,T.failed=!1,T.children.clear(),T.flat=!1;this.#o.clear(),this.#c.clear(),this.#y++,this.#f=null}#be(){const T=this.#$("where",null);return`${n({filters:this.#$("filters",null),sort:this.#$("sort",[]),quick:this.#$("quick",""),groupBy:this.#$("groupBy",[]),pivotBy:this.#$("pivotBy",[]),context:this.#$("context",null)})}|${T?T.version:0}`}#Te(T,F){const $=this.#$("expanded",null);return $?U($.has)?$.has(T,F):Array.prototype.includes.call($,T):this.#i.has(T)}#we(T){if(T.row)return{key:T.key,column:T.row.column,value:T.row.value,level:T.level-1,path:T.path}}#ve(){const T=this.#$("totals",[]);if(T&&T.length)return[...T];const F=this.#t.columns;return!F||!U(F.all)?[]:F.all().filter($=>!!$.total).map($=>$.id)}#Oe(T){const F=this.#t.columns,$={};if(!F||!U(F.get))return $;for(const D of T){const z=F.get(D);if(!z)continue;const G=z.groupTotal!=null?z.groupTotal:z.total;typeof G=="string"?$[D]=G:G&&typeof G=="object"&&typeof G.fn=="string"&&($[D]={...G})}return $}#ye(T,F){const $=this.#t.columns,D=$&&U($.get)?$.get(F):void 0;return D&&U(D.getValue)?D.getValue(T):T?.[F]}#de(){p(this.#t)}#Q(){const T=this.#t.config||{};return{tz:T.timeZone,weekStartsOn:T.weekStartsOn}}#$(T,F){const $=this.#t.state;if($&&U($[T])){const D=$[T]();return D??F}return F}#U(T,F){const $=this.#t.emit;U($)&&$(T,F)}}}),ze("packages/core/src/source/gapbuffer.js",function(e,B){"use strict";Object.defineProperty(e,"GapBuffer",{enumerable:!0,get:function(){return A}});const ne=64;class A{#e;#t=0;#n=0;constructor(U=ne){this.#e=new Uint32Array(Math.max(1,U)),this.#n=this.#e.length}static from(U,I=ne){const J=new A(U.length+Math.max(1,I));return J.#e.set(U,0),J.#t=U.length,J.#n=J.#e.length,J}get length(){return this.#t+(this.#e.length-this.#n)}get capacity(){return this.#e.length}at(U){return U<0||U>=this.length?0:U<this.#t?this.#e[U]:this.#e[U+(this.#n-this.#t)]}insert(U,I){const J=U<0?0:U>this.length?this.length:U;this.#r(J),this.#t===this.#n&&this.#s(),this.#e[this.#t++]=I}push(U){this.insert(this.length,U)}removeAt(U){return!Number.isInteger(U)||U<0||U>=this.length?!1:(this.#r(U),this.#n++,!0)}toArray(){const U=new Uint32Array(this.length);return U.set(this.#e.subarray(0,this.#t),0),U.set(this.#e.subarray(this.#n),this.#t),U}clear(){this.#t=0,this.#n=this.#e.length}#r(U){if(U!==this.#t)if(U<this.#t){const I=this.#t-U;this.#e.copyWithin(this.#n-I,U,this.#t),this.#t=U,this.#n-=I}else{const I=U-this.#t;this.#e.copyWithin(this.#t,this.#n,this.#n+I),this.#t=U,this.#n+=I}}#s(){const U=this.#e.length-this.#n,I=new Uint32Array(Math.max(this.#e.length*2,this.#e.length+ne));I.set(this.#e.subarray(0,this.#t),0),I.set(this.#e.subarray(this.#n),I.length-U),this.#e=I,this.#n=I.length-U}}}),ze("packages/core/src/store/ingest.js",function(e,B){"use strict";Object.defineProperty(e,"INGEST_DEFAULTS",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"inferKind",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"decideText",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"createReaders",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"Ingest",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"ingest",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"ingestSync",{enumerable:!0,get:function(){return u}});const ne=B("packages/core/src/internal/schedule.js"),A=ne.now,V=ne.nextFrame,U=B("packages/core/src/internal/warn.js"),I=U.infoOnce,J=U.warnOnce,L=B("packages/core/src/internal/predicates.js").isFunction,_=B("packages/core/src/internal/paths.js").pathGetter,v=B("packages/core/src/store/columnstore.js").ColumnStore,b=Object.freeze({chunkMs:8,chunkRows:512,sampleSize:100,dictionaryRatio:.1,columnarBelow:5e3,initialCapacity:1024});function c(n,p={}){if(p.multi)return"multi";if(n.length===0)return"object";let r=0,i=0,d=0,h=0,a=0;for(let f=0;f<n.length;f++){const m=n[f];typeof m=="number"?r++:typeof m=="boolean"?i++:typeof m=="string"?d++:m instanceof Date?h++:Array.isArray(m)&&a++}const y=n.length;return r===y?"float64":i===y?"bitset":h===y?"float64":d===y?"text":a===y?"multi":"object"}function g(n,p,r){return p<=0||n<r*p?"dictionary":"object"}function o(n,p,r){const i=new Map,d=new Map;for(const q of n){if(q.computed)continue;const K=L(q.read)?q.read:_(q.field||q.id);d.set(q.id,K),i.set(q.id,K)}const h=p?.order??[],a=p?.fns??{},y=p?.deps??{},f=p?.wrapDeps??null,m=h.filter(q=>L(a[q])),w=m.some(q=>y[q]==="*");let S=new WeakMap;const M=q=>{const K={};if(w)for(const[P,k]of d)K[P]=k(q);for(const P of m){const k=y[P];let E;if(k==="*")E=K;else{E={};const C=k||[];for(let x=0;x<C.length;x++){const j=C[x];E[j]=j in K?K[j]:d.get(j)?.(q)}}K[P]=a[P](f?f(E,P):E,{data:q,row:null,column:null,grid:null,context:r})}return K},X=q=>{if(q===null||typeof q!="object"&&typeof q!="function")return M(q);let K=S.get(q);return K===void 0&&(K=M(q),S.set(q,K)),K};for(const q of m)i.set(q,K=>X(K)[q]);return{readers:i,reset(){S=new WeakMap}}}class t{spec;read;kind;inferred;nullable;candidate=!1;distinct=null;change=null;reason="";constructor(p,r){this.spec=p,this.read=r,this.kind="object",this.inferred=!1,this.nullable=p.nullable!==!1}}class s{#e;#t=[];#n=null;#r;#s=0;#i;#a=!1;#l=!1;#o=0;#c;constructor(p,r={},i={}){this.#e=Array.isArray(p)?p:Array.from(p||[]),this.#i={...b,...i};const d=r.columns??[];this.#r=o(d,r.computed??null,r.context),this.#c=this.#e.length>=this.#i.columnarBelow,this.#u(d,r.computed??null),this.#n=new v(this.#t.map(h=>({id:h.spec.id,kind:h.kind,nullable:h.nullable,read:h.read,dictionary:h.spec.dictionary})),{initialCapacity:this.#i.initialCapacity,columnarBelow:this.#i.columnarBelow})}get store(){return this.#n}get done(){return this.#a||this.#l}get progress(){return this.#s}slice(){if(this.done)return!1;if(this.#i.signal?.aborted)return this.#l=!0,!1;const p=A(),{chunkMs:r,chunkRows:i}=this.#i,d=this.#e.length;do{const h=Math.min(this.#s+i,d);this.#n.append(this.#e.slice(this.#s,h)),this.#f(this.#s,h),this.#s=h,this.#r.reset(),this.#h(!1)}while(this.#s<d&&A()-p<r);return this.#o+=A()-p,this.#i.onProgress?.({loaded:this.#s,total:d}),this.#s>=d?(this.#h(!0),this.#a=!0,!1):!0}cancel(){this.#l=!0}result(){return{store:this.#n,schema:this.#t.map(p=>({id:p.spec.id,kind:p.kind,nullable:p.nullable,read:p.read,dictionary:p.spec.dictionary})),decisions:this.#t.map(p=>({id:p.spec.id,kind:p.kind,nullable:p.nullable,inferred:p.inferred,distinct:p.candidate||p.change?this.#d(p):null,change:p.change,reason:p.reason})),count:this.#n.count,elapsed:this.#o,cancelled:this.#l}}#u(p,r){const i=this.#e,d=Math.min(this.#i.sampleSize,i.length),h=this.#i.dictionaryRatio,a=r?.pure instanceof Set?r.pure:new Set(r?.pure??r?.order??[]);for(const y of p){if(!y||!y.id)continue;if(y.computed&&(y.pure===!1||r&&!a.has(y.id))){J(`ingest.impure.${y.id}`,`column "${y.id}" is an impure computed column and is not materialised into the store`);continue}const f=this.#r.readers.get(y.id)??(L(y.read)?y.read:_(y.field||y.id)),m=new t(y,f);if(y.kind)m.kind=y.kind,m.reason="declared by the caller";else if(y.dictionary)m.kind=y.multi?"multi":"dictionary",m.reason="value table supplied (lookup column)";else{const w=[];for(let M=0;M<d&&w.length<this.#i.sampleSize;M++){const X=f(i[M]);X!=null&&w.push(X)}m.inferred=!0;const S=c(w,{multi:y.multi});if(S==="text"){const M=new Set(w).size;m.kind=g(M,w.length,h),m.candidate=this.#c,m.reason=`sampled ${M} distinct in ${w.length}`}else m.kind=S,m.reason=`inferred from ${w.length} sampled values`,S==="object"&&w.length&&I(`ingest.mixed.${y.id}`,`column "${y.id}" holds mixed or unrecognised value types; storing as an object array. Declare a type to avoid this.`);m.kind==="object"&&m.candidate&&(m.distinct=new Set(w))}this.#t.push(m)}}#f(p,r){const i=this.#e;for(const d of this.#t){if(!d.candidate||!d.distinct)continue;const h=d.distinct;for(let a=p;a<r;a++){const y=d.read(i[a]);y!=null&&h.add(y)}}}#d(p){if(p.distinct)return p.distinct.size;const r=this.#n.column(p.spec.id);return r?.dict?r.dict.size:0}#h(p){const r=this.#i.dictionaryRatio,i=this.#e.length;for(const d of this.#t){if(!d.candidate)continue;const h=this.#d(d);if(d.kind==="dictionary"&&h>=r*i){const a=this.#n.column(d.spec.id);d.distinct=new Set(a?.dict?a.dict.values():[]),this.#n.convert(d.spec.id,"object"),d.kind="object",d.change="demoted",d.reason=`${h} distinct values is at or above ${r*100}% of ${i} rows`;continue}if(d.kind==="object"&&h>=r*i){d.candidate=!1,d.distinct=null,d.reason=`${h} distinct values is at or above ${r*100}% of ${i} rows`;continue}p&&d.kind==="object"&&h<r*i&&(this.#n.convert(d.spec.id,"dictionary"),d.kind="dictionary",d.change=d.change==="demoted"?null:"promoted",d.reason=`${h} distinct values is below ${r*100}% of ${i} rows`,d.distinct=null),p&&(d.candidate=!1)}}}async function l(n,p={},r={}){const i=new s(n,p,r),d=r.scheduler?.frame??V;for(;i.slice();)await new Promise(h=>{d(h)});return i.result()}function u(n,p={},r={}){const i=new s(n,p,{...r,chunkMs:1/0});for(;i.slice(););return i.result()}}),ze("packages/core/src/store/columnpack.js",function(e,B){"use strict";Object.defineProperty(e,"isPortableSchema",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"packChunk",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"packedTransfers",{enumerable:!0,get:function(){return g}});const A=B("packages/core/src/internal/paths.js").pathGetter,V=B("packages/core/src/store/ingest.js"),U=V.inferKind,I=V.decideText,J=V.INGEST_DEFAULTS,L=B("packages/core/src/store/columnstore.js").toFloat,Y=new Set(["float64","int32","bitset","dictionary","object","multi"]);function _(o){if(!Array.isArray(o)||o.length===0)return!1;for(const t of o)if(!t||typeof t.id!="string"||typeof t.field!="string"||t.field===""||t.kind&&!Y.has(t.kind))return!1;return!0}function O(o){const t=L(o);return Number.isFinite(t)?t|0:0}function v(o){return o==null?[]:Array.isArray(o)?o:[o]}function b(o,t,s,l){if(o.kind)return o.kind;const u=[];for(let r=0;r<t.length&&u.length<J.sampleSize;r++){const i=t[r];i!=null&&u.push(i)}const n=U(u,{multi:o.multi});if(n!=="text")return n;const p=new Set(u).size;return I(p,u.length,l)}function c(o,t,s={}){const l=t.length|0,u=s.dictionaryRatio??J.dictionaryRatio,n=[];for(const p of o){const r=A(p.field||p.id),i=p.nullable!==!1,d=new Array(l);for(let m=0;m<l;m++){const w=r(t[m]);d[m]=w===void 0?null:w}const h=b(p,d,l,u),a=i?new Uint8Array(l+7>>3):null,y=m=>{a&&(a[m>>3]|=1<<(m&7))};let f;switch(h){case"float64":{const m=new Float64Array(l);for(let w=0;w<l;w++){const S=d[w],M=S===null;M||y(w),m[w]=M?NaN:L(S)}f={id:p.id,kind:h,nullable:i,values:m,presence:a,offsets:null,table:null};break}case"int32":{const m=new Int32Array(l);for(let w=0;w<l;w++){const S=d[w],M=S===null;M||y(w),m[w]=M?0:O(S)}f={id:p.id,kind:h,nullable:i,values:m,presence:a,offsets:null,table:null};break}case"bitset":{const m=new Uint8Array(l+7>>3);for(let w=0;w<l;w++){const S=d[w],M=S===null;M||y(w),!M&&S&&(m[w>>3]|=1<<(w&7))}f={id:p.id,kind:h,nullable:i,values:m,presence:a,offsets:null,table:null};break}case"dictionary":{const m=new Uint32Array(l),w=[],S=new Map;for(let M=0;M<l;M++){const X=d[M];if(X===null){m[M]=0;continue}y(M);let q=S.get(X);q===void 0&&(q=w.length,w.push(X),S.set(X,q)),m[M]=q}f={id:p.id,kind:h,nullable:i,values:m,presence:a,offsets:null,table:w};break}case"multi":{const m=[],w=new Map,S=new Uint32Array(l+1),M=[];for(let X=0;X<l;X++){const q=d[X];S[X]=M.length,q===null||y(X);const P=v(q);for(let k=0;k<P.length;k++){const E=P[k];let C=w.get(E);C===void 0&&(C=m.length,m.push(E),w.set(E,C)),M.push(C)}}S[l]=M.length,f={id:p.id,kind:h,nullable:i,values:Int32Array.from(M),presence:a,offsets:S,table:m};break}default:{const m=new Array(l);for(let w=0;w<l;w++){const S=d[w];S!==null&&y(w),m[w]=S}f={id:p.id,kind:"object",nullable:i,values:m,presence:a,offsets:null,table:null};break}}n.push(f)}return{count:l,columns:n}}function g(o){const t=[];if(!o||!Array.isArray(o.columns))return t;const s=l=>{ArrayBuffer.isView(l)&&l.buffer&&!t.includes(l.buffer)&&t.push(l.buffer)};for(const l of o.columns)s(l.values),s(l.presence),s(l.offsets);return t}}),ze("packages/core/src/source/stream.js",function(e,B){"use strict";Object.defineProperty(e,"DEFAULT_PROMOTE_BELOW",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"createStreamSource",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"StreamSource",{enumerable:!0,get:function(){return C}});const A=B("packages/core/src/internal/lru.js").Lru,U=B("packages/core/src/internal/predicates.js").isFunction,I=B("packages/core/src/internal/schedule.js"),J=I.now,H=I.nextFrame,L=I.cancelFrame,Y=I.whenIdle,O=B("packages/core/src/internal/compare.js").defaultCompare,v=B("packages/core/src/internal/warn.js"),b=v.warnOnce,c=v.infoOnce,o=B("packages/core/src/internal/paths.js").getPath,t=B("packages/core/src/source/abort.js"),s=t.createAbortScope,l=t.isAbortError,u=B("packages/core/src/source/rows.js"),n=u.createRowFactory,p=u.lazyRowView,i=B("packages/core/src/source/gapbuffer.js").GapBuffer,h=B("packages/core/src/source/memory.js").createMemorySource,y=B("packages/core/src/source/filterwire.js").querySignature,m=B("packages/core/src/store/columnpack.js").isPortableSchema,w=25e4,S=Symbol("lattice.stream.storeBacked"),M=8,X=.1,q=1e3,K=50;function P(x){return Math.min(q,Math.max(K,Math.floor(x/4)))}function k(x){if(x instanceof Date)return x.getTime();if(typeof x=="number")return Number.isFinite(x)?x:NaN;if(typeof x=="string"){const j=x.trim();if(!j)return NaN;const T=Date.parse(j);return Number.isNaN(T)?Number(j):T}return NaN}function E(x,j){return new C(x,j)}class C{mode="stream";writesStore=!0;#e;#t;#n=[];#r=null;#s=[];#i=null;#a;#l;#o=new Map;#c=s();#u={loaded:0,estimated:void 0};#f=null;#d=0;#h=0;#p=0;#m=0;#g=null;#b=null;#y=null;#S=!1;#w=!1;#A=!1;#v=!1;#C="";#O=0;#P=0;#E=0;#T=null;#M=1/0;#N=!1;#R=null;#D=null;#G=null;#K=null;#L=!1;#q=0;#B=0;#Y=!1;constructor(j,T){this.#e=j||{mode:"stream"},this.#t=T||{},this.#a=n(this.#t),this.#l=new A(4096),this.#C=this.#qe();const F=(this.#t.config||{}).ingest;this.#L=!!F&&F.retainSource===!1,U(this.#e.open)||b("source.stream.open",'source.mode "stream" requires an open function; the grid will stay empty.'),this.#e.autoStart!==!1&&queueMicrotask(()=>this.start());const $=Number(this.#e.poll);Number.isFinite($)&&$>0&&(this.#K=setInterval(()=>{this.#v||this.reload()},$),this.#K&&U(this.#K.unref)&&this.#K.unref()),this.#I()}#z(){const j=Number(this.#e.maxAge);return Number.isFinite(j)&&j>0?j:0}#I(){const j=this.#z();if(!j)return;const T=this.#e.ageBy;U(T)?this.#D=T:typeof T=="string"&&T?this.#D=F=>o(F,T):this.#D=null,this.#T=[],this.#R=setInterval(()=>{this.#v||this.#W()&&(this.#Ee(),this.#U())},P(j)),this.#R&&U(this.#R.unref)&&this.#R.unref()}#W(){const j=this.#z();return!j||!this.#T?!1:this.#N?!0:this.#M<Date.now()-j*(1+X)}#ge(j,T){if(!this.#T)return;const F=this.#D?k(this.#D(T)):Date.now();this.#T[j]=F,Number.isNaN(F)||(F<this.#M&&(this.#M=F),F<Date.now()-this.#z()&&(this.#N=!0))}#ie(){return this.#Se("groupBy",[]).length>0?!0:!!this.#Se("pivotMode",!1)&&this.#Se("pivotBy",[]).length>0}#ue(){if(this.#g||this.#v)return;const j=this.#ie();if(j&&!this.#b){this.#b=h({mode:"memory",rows:this.#n},this.#Me()),this.#S=!1;return}!j&&this.#b&&(this.#b.destroy(),this.#b=null)}#Me(){if(this.#y)return this.#y;const j=this,T={liveIndices:()=>j.#fe(),live:F=>j.#n[F]!==void 0,source:F=>j.#ee(F),get physical(){return j.#n.length}};return this.#L&&(T.column=F=>{const $=j.#t.store;return $&&U($.column)?$.column(F):void 0}),this.#y=Object.create(this.#t,{store:{value:T,enumerable:!0,configurable:!0}}),this.#y}#fe(){const j=new Uint32Array(this.#n.length);let T=0;for(let F=0;F<this.#n.length;F++)this.#n[F]!==void 0&&(j[T++]=F);return j.subarray(0,T)}#oe(){return this.#g?this.#g:this.#b?(this.#S&&(this.#S=!1,this.#b.setRows(this.#n)),this.#b):null}invalidate(j="filter"){if(this.#g){this.#g.invalidate(j);return}this.#ue(),this.#b&&this.#b.invalidate(j),(j==="filter"||j==="sort")&&this.#Te()}count(){const j=this.#oe();return j?j.count():this.#r?this.#r.length:this.#O}matchCount(){const j=this.#oe();return j&&U(j.matchCount)?j.matchCount():this.#r?this.#r.length:this.#O}totalCount(){const j=this.#oe();return j&&U(j.totalCount)?j.totalCount():this.#O}unfilteredRows(){const j=this.#oe();if(j&&U(j.unfilteredRows))return j.unfilteredRows();const T=[];for(let F=0;F<this.#n.length;F++){if(!this.#n[F])continue;const $=this.#je(F);$&&T.push($)}return T}at(j){const T=this.#oe();if(T)return T.at(j);if(j<0||j>=this.count())return;const F=this.#r?this.#r.at(j):j,$=this.#je(F);return $.index=j,$}byKey(j){const T=this.#oe();if(T)return T.byKey(j);const F=this.#o.get(j);return F===void 0?void 0:this.#je(F)}leavesOf(j){const T=this.#oe();return T&&U(T.leavesOf)?T.leavesOf(j):[]}loaded(j){return j>=0&&j<this.count()}hint(j,T){if(this.#g){this.#g.hint(j,T);return}this.#Ue(),this.#p=Math.max(0,Math.floor(j))}#Ue(){this.#v||this.#qe()===this.#C||this.reload()}display(){const j=this.#oe();return j?j.display():p(()=>this.count(),T=>this.at(T))}apply(j){if(this.#g)return this.#g.apply(j);const T={added:[],updated:[],removed:[]};if(!j)return T;if(j.update){let F=!1;for(const $ of j.update){const D=this.#o.get(this.#a.keyOf($,-1));if(D===void 0)continue;const z=this.#Oe(D);this.#L?this.#Le(D,$):this.#n[D]=$,this.#l.delete(D),this.#ye(D,z),this.#T&&(this.#ge(D,$),F=!0),this.#S=!0,T.updated.push(this.#je(D))}F&&this.#Ee()}if(j.add&&j.add.length){const F=this.#ne(j.add);for(const $ of F)T.added.push(this.#je($))}return j.remove&&j.remove.length&&b("source.stream.remove","removing rows from a live stream is not supported; reload instead."),this.#U(),T}reload(j){this.#c.abortAll("reload"),this.#Ye(),this.#b&&(this.#b.destroy(),this.#b=null),this.#S=!1,this.#n=[],this.#r=null,this.#o.clear(),this.#l.clear(),this.#g=null,this.#O=0,this.#P=0,this.#E=0,this.#T&&(this.#T=[]),this.#M=1/0,this.#N=!1,this.#w=!1,this.#A=!1,this.#u={loaded:0,estimated:void 0},this.#C=this.#qe(),this.#Ce("model:changed",{reason:"reload"}),this.start()}destroy(){this.#v=!0,this.#K!==null&&(clearInterval(this.#K),this.#K=null),this.#R!==null&&(clearInterval(this.#R),this.#R=null),this.#T=null,this.#c.abortAll("destroyed"),this.#Ye(),this.#f!==null&&(this.#ke(this.#f),this.#f=null),this.#b&&(this.#b.destroy(),this.#b=null),this.#g&&this.#g.destroy(),this.#n=[],this.#r=null,this.#o.clear(),this.#l.clear()}async start(){if(this.#A||this.#v||!U(this.#e.open))return;this.#A=!0;const j=this.#c.begin("stream");this.#Te(),this.#ue();let T;try{T=this.#e.open({sort:this.#Se("sort",[]),filters:this.#Se("filters",null),quick:this.#Se("quick","")||void 0,context:this.#Se("context",null),signal:j.signal})}catch($){this.#Ce("source:error",{error:$});return}const F=U(T[Symbol.asyncIterator])?T[Symbol.asyncIterator]():T[Symbol.iterator]();this.#G=F;try{for(;;){const $=await F.next();if(!j.current||this.#v)return;if($.done){this.#$();return}if(await this.#xe($.value,j),!j.current||this.#v)return;if($.value&&$.value.done){this.#$();return}if(await this.#he(),!j.current||this.#v)return}}catch($){if(l($))return;this.#Ce("source:error",{error:$})}finally{j.settle()}}progress(){return{loaded:this.#u.loaded,estimated:this.#u.estimated,done:this.#w,live:this.#O,evicted:this.#P}}promoted(){return this.#g!==null}memorySource(){return this.#g}invalidateHandles(){const j=this.#oe();j&&(U(j.invalidateHandles)&&j.invalidateHandles(),U(j.invalidate)&&j.invalidate("sort"))}renderCount(){return this.#d}ingestStats(){return{worker:this.#q,inline:this.#B,storeBacked:this.#L}}#xe(j,T){if(!j)return;const F=j.rows;if(F&&F.length&&this.#ae(F))return this.#le(j,T);const $=J();F&&F.length&&(this.#ne(F),this.#B++),this.#Pe(j),this.#h+=J()-$,this.#U()}#Pe(j){this.#u.loaded=j.progress&&typeof j.progress.loaded=="number"?j.progress.loaded:this.#n.length,j.progress&&typeof j.progress.estimated=="number"&&(this.#u.estimated=j.progress.estimated)}#ae(j){if(this.#Y||this.#g)return!1;const T=this.#Z();if(!T)return!1;const F=this.#t.store;if(!F||!U(F.appendPacked))return!1;const $=this.#V();return!$||!m($)?(this.#Y=!0,c("source.stream.ingest-worker","stream ingest.useWorker is on but a column reads through a closure (a computed or date column); columnizing on the main thread instead."),!1):j.length<T.threshold?!1:!this.#Ae(j)}#Ae(j){if(!this.#a.keyed)return!1;const T=new Set;for(let F=0;F<j.length;F++){const $=this.#a.keyOf(j[F],this.#n.length+F);if($!=null){if(T.has($)||this.#o.has($))return!0;T.add($)}}return!1}async#le(j,T){const F=j.rows,$=this.#Z(),D=this.#V();let z;try{z=await $.columnize(D,F,{key:"ingest:stream",signal:T&&T.signal})}catch(ee){if(l(ee)||(b("source.stream.columnize","worker columnization failed; columnizing on the main thread",ee),this.#Y=!0,T&&(!T.current||this.#v)))return;this.#ne(F),this.#B++,this.#Pe(j),this.#U();return}if(T&&(!T.current||this.#v))return;const G=this.#t.store,N=this.#L?void 0:F,{from:Z}=G.appendPacked(z,N),Q=z.count|0;for(let ee=0;ee<Q;ee++){const re=Z+ee,ie=F[ee],ce=this.#a.keyed?this.#a.keyOf(ie,re):null;if(this.#n[re]=this.#L?S:ie,this.#O++,this.#ge(re,ie),ce!==null&&this.#o.set(ce,re),!this.#r||!this.#we(re))continue;const ve=this.#de(re);this.#r.insert(ve,re),ve<=this.#p&&this.#m++}this.#S=!0,this.#Ee(),this.#q++,this.#Pe(j),this.#U()}#Z(){const j=this.#t.ingestWorker;return U(j)?j():null}#V(){const j=this.#t.storeSchema;return U(j)?j():null}#ne(j){const T=[],F=this.#t.store,$=new Array(j.length),D=[],z=new Set;for(let N=0;N<j.length;N++){const Z=this.#a.keyed?this.#a.keyOf(j[N],this.#n.length+D.length):null;$[N]=Z,!(Z!==null&&(this.#o.has(Z)||z.has(Z)))&&(Z!==null&&z.add(Z),D.push(j[N]))}let G=D.length&&F&&U(F.append)?F.append(D).from:this.#n.length;for(let N=0;N<j.length;N++){const Z=j[N],Q=$[N];if(Q!==null&&this.#o.has(Q)){const ie=this.#o.get(Q),ce=this.#Oe(ie);this.#L||(this.#n[ie]=Z,F&&U(F.setSource)&&F.setSource(ie,Z)),this.#Le(ie,Z),this.#l.delete(ie),this.#ge(ie,Z),this.#ye(ie,ce);continue}const ee=G++;if(this.#n[ee]=this.#L?S:Z,this.#O++,this.#ge(ee,Z),Q!==null&&this.#o.set(Q,ee),T.push(ee),!this.#r||!this.#we(ee))continue;const re=this.#de(ee);this.#r.insert(re,ee),re<=this.#p&&this.#m++}return this.#S=!0,this.#Ee(),T}#_(j){const T=this.#n[j];let F=!1;if(this.#r){const G=this.#be(j);G>=0&&G<=this.#p&&(F=!0)}else j<=this.#p&&(F=!0);const $=T===S?this.#ee(j):T,D=this.#a.keyed?this.#a.keyOf($,j):null;D!==null&&this.#o.get(D)===j&&this.#o.delete(D),this.#n[j]=void 0,this.#T&&(this.#T[j]=NaN),this.#l.delete(j);const z=this.#t.store;return z&&U(z.remove)&&z.remove(j),this.#O--,F}#Ee(){let j=0,T=0;const F=this.#pe();j+=F.dropped,T+=F.aboveAnchor;const $=this.#re();j+=$.dropped,T+=$.aboveAnchor,j&&(this.#S=!0,this.#P+=j,this.#Te(),this.#m-=T,this.#Ce("stream:evicted",{evicted:j,total:this.#P,live:this.#O}))}#re(){const j=this.#e.maxRows;if(!Number.isFinite(j)||j<=0||this.#O<=j)return{dropped:0,aboveAnchor:0};const T=Math.max(1,Math.floor(j*(1-X)));let F=0,$=0;for(;this.#O>T&&this.#E<this.#n.length;){const D=this.#E++;this.#n[D]!==void 0&&(this.#_(D)&&$++,F++)}return{dropped:F,aboveAnchor:$}}#pe(){const j=this.#z();if(!j||!this.#T||!this.#W())return{dropped:0,aboveAnchor:0};const T=Date.now()-j;let F=0,$=0,D=1/0;for(let z=this.#E;z<this.#n.length;z++){if(this.#n[z]===void 0)continue;const G=this.#T[z];if(!(Number.isNaN(G)||G===void 0)){if(G>=T){G<D&&(D=G);continue}this.#_(z)&&$++,F++}}for(this.#M=D,this.#N=!1;this.#E<this.#n.length&&this.#n[this.#E]===void 0;)this.#E++;return{dropped:F,aboveAnchor:$}}#be(j){if(!this.#r)return j;for(let T=0;T<this.#r.length;T++)if(this.#r.at(T)===j)return T;return-1}#Te(){this.#s=this.#Se("sort",[]),this.#i=this.#Se("filters",null);const j=Number.isFinite(this.#e.maxRows)&&this.#e.maxRows>0||this.#z()>0,T=this.#Se("where",null),F=(this.#t.config||{}).hostFilter,$=!!(T&&T.active)||!!(F&&U(F.active)&&F.active());if(!(j||this.#s.length>0||!!this.#i||!!this.#Se("quick","")||$)){this.#r=null;return}this.#r=new i(Math.max(64,this.#n.length+64));for(let z=0;z<this.#n.length;z++)this.#n[z]!==void 0&&this.#we(z)&&this.#r.insert(this.#de(z),z)}#we(j){const T=this.#ee(j);if(this.#i&&!this.#ve(this.#i,T))return!1;const F=String(this.#Se("quick","")||"").toLowerCase();if(F&&!this.#k(T).includes(F))return!1;const $=(this.#t.config||{}).hostFilter;if($&&U($.active)&&$.active()&&!$.passes(this.#je(j)))return!1;const D=this.#Se("where",null);if(D&&D.active){const z=this.#je(j);if(!D.passes(z.data,z.key))return!1}return!0}#ve(j,T){if(!j)return!0;const F=j;if(Array.isArray(F.conditions))return F.op==="or"?F.conditions.some(z=>this.#ve(z,T)):F.op==="not"?!F.conditions.some(z=>this.#ve(z,T)):F.conditions.every(z=>this.#ve(z,T));const $=j,D=(this.#t.compute||{}).testValue;return U(D)?!!D(this.#We(T,$.col),$,(this.#t.config||{}).locale):(b("source.stream.testValue","ctx.compute.testValue is unavailable; streamed rows are not filtered client-side."),!0)}#Oe(j){if(!this.#r)return-1;if(!this.#s.length)return this.#be(j);let T=0,F=this.#r.length;for(;T<F;){const $=T+F>>>1;this.#Q(this.#r.at($),j)<0?T=$+1:F=$}for(let $=T;$<this.#r.length;$++){const D=this.#r.at($);if(D===j)return $;if(this.#Q(D,j)>0)break}return this.#be(j)}#ye(j,T){if(!this.#r||!this.#s.length)return;const F=this.#we(j);if(T>=0&&this.#r.at(T)===j)this.#r.removeAt(T),T<=this.#p&&this.#m--;else if(T>=0)return;if(!F)return;const $=this.#de(j);this.#r.insert($,j),$<=this.#p&&this.#m++}#de(j){if(!this.#r||!this.#s.length)return this.#r?this.#r.length:0;let T=0,F=this.#r.length;for(;T<F;){const $=T+F>>>1;this.#Q(j,this.#r.at($))<0?F=$:T=$+1}return T}#Q(j,T){const F=this.#ee(j),$=this.#ee(T);for(const D of this.#s){const z=this.#Fe(D.col),G=this.#We(F,D.col),N=this.#We($,D.col),Q=(z&&z.value&&U(z.value.compare)?z.value.compare:O)(G,N);if(Q!==0)return D.dir==="desc"?-Q:Q}return 0}#$(){this.#w=!0,this.#u.loaded=this.#u.loaded||this.#n.length;const j=typeof this.#e.promoteToMemoryBelow=="number"?this.#e.promoteToMemoryBelow:w;!this.#L&&this.#n.length<j&&(this.#g=h({mode:"memory",rows:this.#n},this.#t),this.#R!==null&&(clearInterval(this.#R),this.#R=null),this.#b&&(this.#b.destroy(),this.#b=null)),this.#U(),this.#Ce("stream:end",{loaded:this.#n.length,promoted:this.#g!==null,threshold:j})}#U(){this.#f!==null||this.#v||(this.#f=this.#F(()=>{this.#f=null,this.#d++;const j=this.#m;this.#m=0,this.#h=0,this.#Ce("stream:chunk",{loaded:this.#u.loaded,estimated:this.#u.estimated,count:this.count(),renders:this.#d}),this.#Ce("model:changed",{reason:"stream",shiftAboveViewport:j,anchor:this.#p}),this.#Ce("rows:changed",{companion:!0,reason:"stream"})}))}#he(){return this.#d===0||this.#h<this.#se()?Promise.resolve():(this.#h=0,new Promise(j=>{const T=(this.#t.scheduler||{}).idle;U(T)?T(()=>j()):Y(()=>j())}))}#se(){return typeof this.#e.coalesceMs=="number"&&this.#e.coalesceMs>0?this.#e.coalesceMs:M}#F(j){const T=this.#t.scheduler||{};return U(T.frame)?T.frame(j):H(j)}#ke(j){const T=this.#t.scheduler||{};U(T.cancel)?T.cancel(j):L(j)}#ee(j){const T=this.#n[j];if(T!==void 0&&T!==S)return T;if(T===void 0)return;const F=this.#t.store;return F&&U(F.source)?F.source(j):void 0}#Le(j,T){const F=this.#t.store;if(!F||!U(F.set))return;const $=this.#V();if(Array.isArray($))for(const D of $){if(!D||!D.id)continue;const z=U(D.read)?D.read:G=>o(G,D.field||D.id);F.set(D.id,j,z(T))}}#je(j){let T=this.#l.get(j);return T||(T=this.#a.leaf(this.#ee(j),j),this.#l.set(j,T)),T}#We(j,T){const F=this.#Fe(T);return F&&U(F.getValue)?F.getValue(j):j?.[T]}#k(j){const T=this.#t.columns,F=T&&U(T.all)?T.all():[],$=[];for(const D of F){const z=U(D.getValue)?D.getValue(j):void 0;z!=null&&z!==""&&$.push(String(z))}return $.join(" ").toLowerCase()}#Fe(j){const T=this.#t.columns;return T&&U(T.get)?T.get(j):void 0}#Ye(){const j=this.#G;if(this.#G=null,j&&U(j.return))try{j.return()}catch{}}#qe(){return y({context:this.#Se("context",null)})}#Se(j,T){const F=this.#t.state;if(F&&U(F[j])){const $=F[j]();return $??T}return T}#Ce(j,T){const F=this.#t.emit;U(F)&&F(j,T)}}}),ze("packages/core/src/source/url.js",function(e,B){"use strict";Object.defineProperty(e,"DEFAULT_URL_BATCH",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"createUrlSource",{enumerable:!0,get:function(){return b}});const A=B("packages/core/src/internal/warn.js").warnOnce,V=B("packages/core/src/internal/predicates.js"),U=V.isObject,I=V.isFunction,H=B("packages/core/src/internal/paths.js").getPath,Y=B("packages/core/src/source/abort.js").isAbortError,_=500,O=new Set(["application/x-ndjson","application/ndjson","application/jsonlines","application/jsonl","application/x-jsonlines","text/x-ndjson"]),v=Symbol("lattice.url.skip");function b(a,y={}){const f=U(y)?y:{},m=I(f.fetch)?f.fetch:typeof globalThis<"u"&&I(globalThis.fetch)?globalThis.fetch:null,w=f.format==="json"||f.format==="ndjson"?f.format:void 0,S=typeof f.rowsPath=="string"&&f.rowsPath?f.rowsPath:void 0,M=I(f.map)?f.map:void 0,X=U(f.headers)?f.headers:void 0,q=Number.isFinite(f.batchSize)&&f.batchSize>0?Math.floor(f.batchSize):_,K=f.lenient===!0,P=Number.isFinite(f.poll)&&f.poll>0?Math.floor(f.poll):void 0,k=typeof a=="string"&&a.length>0;k||A("source.url.url","createUrlSource needs a URL string; the grid will stay empty.");async function*E(x={}){if(!k)return;if(!m)throw new Error("[lattice] createUrlSource: no fetch available — pass opts.fetch or run where globalThis.fetch exists.");const j=x&&x.signal;let T;try{T=await m(a,X?{signal:j,headers:X}:{signal:j})}catch(D){throw Y(D)?D:new Error(`[lattice] createUrlSource: request to ${a} failed — ${D&&D.message||D}`)}if(!T||!T.ok){const D=T?T.status:"no response";throw new Error(`[lattice] createUrlSource: ${D} for ${a}`)}const F=c(a,w,T),$=T.body&&I(T.body.getReader)?T.body.getReader():null;try{if(!$){const G=await T.text();(F||t(G,a))==="ndjson"?yield*r(null,null,G,0,T,a,q,K):yield*p(G,a,S,M);return}const D=new TextDecoder("utf-8");if(F==="json"){yield*p(await n($,D,""),a,S,M);return}if(F==="ndjson"){yield*r($,D,"",0,T,a,q,K);return}const z=await s($,D,a);z.format==="json"?yield*p(await n($,D,z.seed),a,S,M):yield*r($,D,z.seed,z.bytes,T,a,q,K)}finally{if($&&I($.cancel))try{await $.cancel()}catch{}}}const C={mode:"stream",open:E,autoStart:f.autoStart!==!1};return P!==void 0&&(C.poll=P),Number.isFinite(f.maxRows)&&(C.maxRows=f.maxRows),Number.isFinite(f.maxAge)&&(C.maxAge=f.maxAge),(typeof f.ageBy=="string"||I(f.ageBy))&&(C.ageBy=f.ageBy),Number.isFinite(f.coalesceMs)&&(C.coalesceMs=f.coalesceMs),Number.isFinite(f.promoteToMemoryBelow)&&(C.promoteToMemoryBelow=f.promoteToMemoryBelow),C}function c(a,y,f){if(y)return y;const m=g(a);if(m)return m;const w=f&&f.headers&&I(f.headers.get)?f.headers.get("content-type"):null;return o(w)}function g(a){const y=String(a).split(/[?#]/)[0].toLowerCase();if(y.endsWith(".ndjson")||y.endsWith(".jsonl"))return"ndjson";if(y.endsWith(".json"))return"json"}function o(a){if(!a)return;const y=a.split(";")[0].trim().toLowerCase();if(O.has(y))return"ndjson";if(y==="application/json"||y==="text/json"||y.endsWith("+json"))return"json"}function t(a,y){const f=a.replace(/^\s+/,""),m=l(f);if(m==="error")throw new Error(`[lattice] createUrlSource: could not tell JSON from NDJSON for ${y} — pass opts.format: 'json' | 'ndjson'.`);return m}async function s(a,y,f){let m="",w=0;for(;;){const{value:M,done:X}=await a.read();if(M&&(w+=M.byteLength,m+=y.decode(M,{stream:!0})),X){m+=y.decode();break}const q=m.replace(/^\s+/,"");if(q){if(q[0]==="[")return{format:"json",seed:m,bytes:w};if(q[0]!=="{"||m.indexOf(`
|
|
8
8
|
`)!==-1)break}}const S=l(m.replace(/^\s+/,""));if(S==="error")throw new Error(`[lattice] createUrlSource: could not tell JSON from NDJSON for ${f} — pass opts.format: 'json' | 'ndjson'.`);return{format:S,seed:m,bytes:w}}function l(a){if(!a||a[0]==="[")return"json";if(a[0]!=="{")return"error";const y=a.indexOf(`
|
|
9
9
|
`);if(y===-1)return"json";let f=a.slice(0,y);return f.endsWith("\r")&&(f=f.slice(0,-1)),u(f)?"ndjson":"json"}function u(a){try{return JSON.parse(a),!0}catch{return!1}}async function n(a,y,f){let m=f;for(;;){const{value:w,done:S}=await a.read();if(w&&(m+=y.decode(w,{stream:!0})),S)break}return m+=y.decode(),m}function*p(a,y,f,m){let w;try{w=JSON.parse(a)}catch(M){throw new Error(`[lattice] createUrlSource: ${y} is not valid JSON — ${M.message}`)}let S=f!==void 0?H(w,f):w;if(m&&(S=m(S)),!Array.isArray(S)){const M=f!==void 0||m?"":"; pass opts.rowsPath or opts.map to select the array";throw new Error(`[lattice] createUrlSource: ${y} did not resolve to an array${M}.`)}yield{rows:S,progress:{loaded:S.length,estimated:S.length}}}async function*r(a,y,f,m,w,S,M,X){const q=h(w);let K=f||"",P=m||0,k=0,E=0,C=[];function*x(){let T;for(;(T=K.indexOf(`
|
|
10
10
|
`))!==-1;){const F=K.slice(0,T);K=K.slice(T+1),E++;const $=i(F,E,S,X);$!==v&&(C.push($),C.length>=M&&(k+=C.length,yield d(C,k,q,P),C=[]))}}if(a){for(;;){const{value:T,done:F}=await a.read();if(T&&(P+=T.byteLength,K+=y.decode(T,{stream:!0}),yield*x()),F)break}K+=y.decode()}yield*x(),E++;const j=i(K,E,S,X);j!==v&&C.push(j),C.length&&(k+=C.length,yield d(C,k,q,P))}function i(a,y,f,m){let w=a;if(w.endsWith("\r")&&(w=w.slice(0,-1)),!w.trim())return v;try{return JSON.parse(w)}catch(S){if(m)return A(`source.url.badline.${f}`,`skipping a malformed NDJSON line (line ${y}) from ${f} — ${S.message}`),v;throw new Error(`[lattice] createUrlSource: malformed NDJSON at line ${y} of ${f} — ${S.message}`)}}function d(a,y,f,m){const w=f&&m>0&&y>0?Math.max(y,Math.round(f/(m/y))):void 0;return{rows:a,progress:{loaded:y,estimated:w}}}function h(a){const y=a&&a.headers&&I(a.headers.get)?a.headers.get("content-length"):null,f=y!=null?Number(y):NaN;return Number.isFinite(f)&&f>0?f:void 0}}),ze("packages/core/src/source/derive.js",function(e,B){"use strict";Object.defineProperty(e,"FOLLOW_MODES",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"BUCKETS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"DERIVED_ROW_KEY",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"DERIVED_SOURCE_KEY",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"UNION_KEY_SEP",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"readPath",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"unnest",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"bucketOf",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"reduceValues",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"applyLimit",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"applyCumulative",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"groupRows",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"finishGroups",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"derive",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"normalizeUnionSource",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"namespaceUnionKeys",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"joinRows",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"preGroup",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"buildJoinIndex",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"joinOne",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"joinKeyOf",{enumerable:!0,get:function(){return w}});const ne=B("packages/core/src/internal/predicates.js"),A=ne.isFunction,V=ne.isObject,I=B("packages/core/src/compute/total.js").TOTAL_FNS,J=Object.freeze(["filtered","all","selected","grouped"]),H=Object.freeze(["day","week","month","quarter","year"]),L="__key",Y="__source",_="";function O(S,M){if(!V(S)||typeof M!="string")return;if(!M.includes("."))return S[M];let X=S;for(const q of M.split(".")){if(!V(X))return;X=X[q]}return X}function v(S,M){const X=[];for(const q of S){const K=O(q,M);if(!(!Array.isArray(K)||!K.length))for(const P of K)X.push({...q,[M]:P})}return X}function b(S,M){const X=S instanceof Date?S:new Date(S),q=X.getTime();if(!Number.isFinite(q))return null;const K=X.getUTCFullYear(),P=X.getUTCMonth(),k=X.getUTCDate(),E=C=>C.toISOString().slice(0,10);switch(M){case"year":return E(new Date(Date.UTC(K,0,1)));case"quarter":return E(new Date(Date.UTC(K,Math.floor(P/3)*3,1)));case"month":return E(new Date(Date.UTC(K,P,1)));case"week":{const C=(X.getUTCDay()+6)%7;return E(new Date(Date.UTC(K,P,k-C)))}default:return E(new Date(Date.UTC(K,P,k)))}}function c(S,M,X){const q=M.map(K=>X&&X.of===K?b(O(S,K),X.by):O(S,K));return{key:q.map(K=>K==null?"\0":String(K)).join(""),values:q}}function g(S,M){const X=I[M];return X?X({get:q=>S[q]},s(S.length)):null}function o(S,M){return!M||typeof M.of!="string"||M.of===""||S&&S.includes(M.of)?S:[M.of,...S||[]]}function t(S,M){const X={},q=s(S.length);for(const[K,P]of Object.entries(M)){const k=P.fn||"count",E=I[k];if(!E){X[K]=null;continue}const C=P.of?S.map(x=>O(x,P.of)):[];X[K]=E({get:x=>C[x]},q)}return X}const s=(()=>{const S=new Map;return M=>{let X=S.get(M);if(!X){X=new Uint32Array(M);for(let q=0;q<M;q++)X[q]=q;S.size<512&&S.set(M,X)}return X}})();function l(S,M,X){if(!Number.isFinite(M)||M<=0)return S;if(!X)return S.slice(0,M);const q=new Map,K=[];for(const P of S){const k=String(O(P,X)),E=q.get(k)||0;E>=M||(q.set(k,E+1),K.push(P))}return K}function u(S,M){const X=S.reduce((k,E)=>k+(Number(O(E,M.of))||0),0);if(!X)return S;const q=X*M.upTo;let K=0;const P=[];for(const k of S)if(P.push(k),K+=Number(O(k,M.of))||0,K>=q)break;return P}function n(S,M){return!Array.isArray(M)||!M.length?S:[...S].sort((X,q)=>{for(const K of M){const P=O(X,K.col),k=O(q,K.col);if(P===k)continue;return P==null?1:k==null?-1:((typeof P=="number"&&typeof k=="number"?P<k:String(P)<String(k))?-1:1)*(K.dir==="desc"?-1:1)}return 0})}function p(S,M,X){const q=M.groupBy?Array.isArray(M.groupBy)?M.groupBy:[M.groupBy]:null,K=V(M.bucket)?M.bucket:null,P=o(q,K),k=new Map,E=new Map;if(!P)return{groups:k,rowGroup:E};for(const C of S){const{key:x,values:j}=c(C,P,K);let T=k.get(x);T||(T={values:j,rows:new Map},k.set(x,T));const F=X(C);T.rows.set(F,C),E.set(F,x)}return{groups:k,rowGroup:E}}function r(S,M,X=null,q=null){const K=M.groupBy?Array.isArray(M.groupBy)?M.groupBy:[M.groupBy]:null,P=V(M.bucket)?M.bucket:null,k=o(K,P);let E=[...S.entries()].map(([C,x])=>{if(X&&q&&!q.has(C)){const T=X.get(C);if(T)return T}const j={[L]:C};return k.forEach((T,F)=>{j[T.includes(".")?T.split(".").pop():T]=x.values[F]}),Object.assign(j,t([...x.rows.values()],M.select||{})),X&&X.set(C,j),j});return E=n(E,M.sort),V(M.cumulative)&&(E=u(E,M.cumulative)),l(E,M.limit,M.limitPer||null)}function i(S,M){const X=y(S,M),q=M.groupBy?Array.isArray(M.groupBy)?M.groupBy:[M.groupBy]:null,K=V(M.bucket)?M.bucket:null,P=o(q,K);let k;if(!P)k=X.map((E,C)=>({...E,[L]:String(O(E,M.rowKey||"id")??C)}));else{const E=new Map;for(const C of X){const{key:x,values:j}=c(C,P,K);let T=E.get(x);T||(T={values:j,rows:[]},E.set(x,T)),T.rows.push(C)}k=[...E.entries()].map(([C,x])=>{const j={[L]:C};return P.forEach((T,F)=>{j[T.includes(".")?T.split(".").pop():T]=x.values[F]}),Object.assign(j,t(x.rows,M.select||{})),j})}return k=n(k,M.sort),V(M.cumulative)&&(k=u(k,M.cumulative)),l(k,M.limit,M.limitPer||null)}function d(S,M){const q=V(S)&&V(S.grid)?S:{grid:S};return{grid:V(q.grid)?q.grid:null,label:q.label!=null&&q.label!==""?String(q.label):String(M),follow:typeof q.follow=="string"?q.follow:void 0,map:A(q.map)?q.map:null}}function h(S){for(const M of S){const X=M[Y];X!==void 0&&(M[L]=`${X}${_}${M[L]}`)}return S}function a(S,M){const X=M.on,q=V(X)?String(X.left||X.right||""):String(X||""),K=V(X)?String(X.right||X.left||""):String(X||"");if(!q||!K)return S;const P=M.index instanceof Map?M.index:f(Array.isArray(M.rows)?M.rows:[],K),k=Array.isArray(M.select)?M.select.map(String):null,E=M.prefix?String(M.prefix):"",C=String(M.type||"inner")==="left",x=[];for(const j of S){const T=O(j,q),F=T==null?void 0:P.get(String(T));if(!F){C&&x.push(j);continue}const $={...j},D=k||Object.keys(F);for(const z of D)!E&&z===q||($[E?E+z:z]=O(F,z));x.push($)}return x}function y(S,M){let X=Array.isArray(S)?S:[];return M.unnest&&(X=v(X,M.unnest)),V(M.join)&&(Array.isArray(M.join.rows)||M.join.index instanceof Map)&&(X=a(X,M.join)),A(M.where)&&(X=X.filter(q=>!!M.where(q))),X}function f(S,M){const X=new Map;for(const q of S){const K=O(q,M);if(K==null)continue;const P=String(K);X.has(P)||X.set(P,q)}return X}function m(S,M){const X=M.on,q=V(X)?String(X.left||X.right||""):String(X||""),K=V(X)?String(X.right||X.left||""):String(X||"");if(!q||!K)return S;const P=M.index instanceof Map?M.index:new Map,k=O(S,q),E=k==null?void 0:P.get(String(k));if(!E)return String(M.type||"inner")==="left"?S:null;const C=Array.isArray(M.select)?M.select.map(String):null,x=M.prefix?String(M.prefix):"",j={...S};for(const T of C||Object.keys(E))!x&&T===q||(j[x?x+T:T]=O(E,T));return j}function w(S,M){const X=O(S,M);return X==null?null:String(X)}}),ze("packages/core/src/source/derived.js",function(e,B){"use strict";Object.defineProperty(e,"IDLE_REFRESH_MS",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"PROFILE_FIELDS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"ALERT_THRESHOLDS",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"STATISTICS_FNS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"SERIES_METRICS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"PRODUCER_IGNORED_KEYS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"profileAlerts",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"DerivedSource",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"createDerivedSource",{enumerable:!0,get:function(){return K}});const ne=B("packages/core/src/internal/predicates.js"),A=ne.isFunction,V=ne.isObject,I=B("packages/core/src/internal/warn.js").warnOnce,H=B("packages/core/src/source/memory.js").MemorySource,Y=B("packages/core/src/source/settle.js").isPipelineSettle,_=B("packages/core/src/source/derive.js"),O=_.derive,v=_.preGroup,b=_.groupRows,c=_.finishGroups,g=_.readPath,o=_.buildJoinIndex,t=_.joinOne,s=_.joinKeyOf,l=_.FOLLOW_MODES,u=_.DERIVED_ROW_KEY,n=_.DERIVED_SOURCE_KEY,p=_.normalizeUnionSource,r=_.namespaceUnionKeys,i=16,d=Object.freeze(["column","rows","present","missing","numeric","distinct","min","max","mean","median","q1","q3","iqr","stddev","outliers","alerts","alertCount"]),h=Object.freeze({missing:.2,cardinality:.9,skew:1,outliers:.05}),a=Object.freeze(["correlation","series","datasetVsDataset"]),y=Object.freeze(["n","first","last","change","changePercent","volatility","annualisedVolatility","growth","maxDrawdown","maxDrawdownFrom","maxDrawdownTo","autocorrelation","upDays","downDays"]),f=Object.freeze(["unnest","join","where","bucket","groupBy","select","sort","limit","limitPer","cumulative"]);function m(P,k={}){const E={...h,...V(k)?k:{}},C=Q=>typeof Q=="number"&&Number.isFinite(Q)?Q:null,x=C(P.rows)??0,j=C(P.numeric)??0,T=C(P.missing)??0,F=C(P.distinct),$=C(P.mean),D=C(P.median),z=C(P.stddev),G=C(Array.isArray(P.outliers)?P.outliers.length:P.outliers),N=j>0,Z=[];return F===0?["empty"]:(F===1&&Z.push("constant"),x>0&&T/x>=E.missing&&Z.push("high-missing"),!N&&F!==null&&x>1&&F===x&&T===0?Z.push("unique"):F!==null&&x>0&&F/x>=E.cardinality&&Z.push("high-cardinality"),N&&$!==null&&D!==null&&z!==null&&z>0&&Math.abs(3*($-D)/z)>=E.skew&&Z.push("skewed"),N&&G!==null&&G/j>=E.outliers&&Z.push("outliers"),Z)}class w extends H{#e=null;#t={};#n=[];#r=null;#s=!1;#i={};#a=!1;#l=null;#o=null;#c=!1;#u=null;#f=!1;#d=null;constructor(k,E){super({mode:"memory",rows:[]},E),this.#i=E||{},this.#t=V(k)?k:{};const C=this.#t.from;if(Array.isArray(C)){if(this.#e=null,this.#d=this.#g(C),!this.#d.length){I("source.derived.from",'source.mode "derived" needs `from`: at least one grid to derive from.');return}this.#t.follow!==void 0&&I("source.derived.union.follow",'source.mode "derived": `follow` is ignored when `from` is a union of several grids (BACKLOG-0001045) — each entry carries its own `follow` instead.'),this.#t.crossFilter&&I("source.derived.union.crossfilter",'source.mode "derived": `crossFilter` is not supported when `from` is a union of several grids (BACKLOG-0001045) — it has no single target once there is more than one parent. Push a filter onto the individual source grid you mean instead.'),this.#t.statistics!==void 0&&(I("source.derived.union.statistics",'source.mode "derived": `statistics` is not supported when `from` is a union of several grids (BACKLOG-0001046) — a relational statistic reduces one grid\'s own columns, and a union has no single set of them. Derive the statistics of a single grid instead.'),this.#f=!0),this.#m(),this.#b(),this.refresh();return}if(this.#e=C||null,!this.#e){I("source.derived.from",'source.mode "derived" needs `from`: the grid to derive from.');return}this.#t.follow&&!l.includes(String(this.#t.follow))&&I(`source.derived.follow.${this.#t.follow}`,`unknown follow "${this.#t.follow}"; using "filtered". Known: ${l.join(", ")}.`),this.#h()||(this.#f=!0),this.#m(),this.#b(),this.refresh()}#h(){const k=this.#t.statistics;if(k===void 0)return!0;if(this.#t.profile!==void 0)return I("source.derived.producer.conflict",'source.mode "derived": `profile` and `statistics` are both terminal producers and cannot be used together — each replaces the pipeline with its own output builder. Declare one, or chain a second derived grid whose `from` is the first.'),!1;if(!V(k))return I("source.derived.statistics.shape",`source.mode "derived": \`statistics\` needs an object naming the statistic, e.g. \`{ fn: 'correlation', columns: ['a', 'b'] }\`. Known fn: ${a.join(", ")}.`),!1;const E=String(k.fn||"");return a.includes(E)?this.#p(E,k):(I(`source.derived.statistics.fn.${E}`,`source.mode "derived": unknown \`statistics.fn\` "${E}". Known: ${a.join(", ")}. Every *single-column* statistic is reached through \`select\` instead, e.g. \`select: { p95: { of: 'amount', fn: 'p95' } }\`.`),!1)}#p(k,E){if(k==="correlation"){if((Array.isArray(E.columns)?E.columns.filter(Boolean):[]).length<2)return I("source.derived.statistics.columns","source.mode \"derived\": `statistics: { fn: 'correlation' }` needs `columns`: at least two column ids to correlate pairwise."),!1;const x=E.orient===void 0?"pairs":String(E.orient);return x!=="pairs"&&x!=="matrix"&&I(`source.derived.statistics.orient.${x}`,`source.mode "derived": unknown \`statistics.orient\` "${x}" for \`fn: 'correlation'\`; using "pairs". Known: pairs, matrix.`),!0}return k==="series"?!E.of||!E.by?(I("source.derived.statistics.series","source.mode \"derived\": `statistics: { fn: 'series' }` needs both `of` (the column to summarise) and `by` (the column that orders it). `by` is never guessed — kernels see rows in arrival order, which is not the grid's sort."),!1):!0:V(E.with)?!0:(I("source.derived.statistics.with","source.mode \"derived\": `statistics: { fn: 'datasetVsDataset' }` needs `with`: the second grid to compare this one against."),!1)}#m(){const k=this.#t.statistics!==void 0?"statistics":this.#t.profile!==void 0?"profile":null;if(!k)return;const E=f.filter(C=>this.#t[C]!==void 0);E.length&&I(`source.derived.producer.ignored.${k}`,`source.mode "derived": \`${k}\` is a terminal producer and replaces the pipeline, so ${E.map(C=>`\`${C}\``).join(", ")} ${E.length>1?"are":"is"} ignored. Sort, filter or limit the derived grid itself, or chain a second derived grid whose \`from\` is this one.`)}#g(k){const E=this.#i&&this.#i.grid,C=new Set,x=[];return k.forEach((j,T)=>{const F=p(j,T);if(C.has(F.label)&&I(`source.derived.union.label.${F.label}`,`source.mode "derived": two union sources share the label "${F.label}"; give each a distinct \`label\` or __source/__key will not distinguish them.`),C.add(F.label),!F.grid){I(`source.derived.union.missing.${F.label}`,`source.mode "derived": union source "${F.label}" has no grid and was skipped.`),x.push(F);return}if(E&&A(F.grid.on)){const $=M(E,F.grid,[F.label]);if($){I(`source.derived.union.cycle.${F.label}`,`source.mode "derived": union source "${F.label}" was refused — it derives from the grid being derived, directly or through a chain (${$.join(" → ")}). Remove it from \`from\`.`),x.push({...F,grid:null});return}}x.push(F)}),x}#b(){if(this.#d){this.#S(),this.#w();return}const k=this.#e;if(!k||!A(k.on))return;const E=String(this.#t.follow||"filtered"),C=["rows:changed"];(E==="filtered"||E==="grouped")&&C.push("filter:changed","model:changed"),E==="selected"&&C.push("selection:changed"),E==="grouped"&&C.push("column:grouped");for(const x of C){const j=T=>{x==="rows:changed"&&S(T)||x==="model:changed"&&!Y(T)||this.schedule(x==="rows:changed"?T:null)};k.on(x,j),this.#n.push(()=>A(k.off)&&k.off(x,j))}this.#w(),this.#y()}#y(){const k=this.#t.statistics,E=V(k)?k.with:null;if(!V(E)||!A(E.on))return;const C=E;for(const x of["rows:changed","filter:changed","model:changed"]){const j=T=>{x==="rows:changed"&&S(T)||x==="model:changed"&&!Y(T)||this.schedule(null)};C.on(x,j),this.#n.push(()=>A(C.off)&&C.off(x,j))}}#S(){for(const k of this.#d){const E=k.grid;if(!E||!A(E.on))continue;const C=l.includes(String(k.follow))?String(k.follow):"filtered",x=["rows:changed"];(C==="filtered"||C==="grouped")&&x.push("filter:changed","model:changed"),C==="selected"&&x.push("selection:changed"),C==="grouped"&&x.push("column:grouped");for(const j of x){const T=F=>{j==="rows:changed"&&S(F)||j==="model:changed"&&!Y(F)||this.schedule(null)};E.on(j,T),this.#n.push(()=>A(E.off)&&E.off(j,T))}}}#w(){const k=this.#t.join,E=k&&k.with;if(!E||!A(E.on))return;const x=String(k.follow||"all")==="all"?["rows:changed"]:["rows:changed","filter:changed","model:changed"];for(const j of x){const T=F=>{j==="rows:changed"&&S(F)||j==="model:changed"&&!Y(F)||this.schedule({partner:!0})};E.on(j,T),this.#n.push(()=>A(E.off)&&E.off(j,T))}}#A(){const k=this.#t.join;if(!k||!k.with)return null;const E=k.on,C=V(E)?String(E.left||E.right||""):String(E||""),x=V(E)?String(E.right||E.left||""):String(E||"");return C&&x?{left:C,right:x}:null}#v(){const k=this.#A();if(!k)return this.#u=null,null;const E=this.#u;if(this.#u=o(this.#P(),k.right),!E)return null;const C=this.#t.join||{},x=Array.isArray(C.select)?C.select.map(String):null,j=$=>$?(x||Object.keys($)).map(z=>String(g($,z))).join(""):null,T=new Set,F=new Set;for(const[$,D]of this.#u)j(D)!==j(E.get($))&&(T.add($),E.has($)||F.add($));for(const $ of E.keys())this.#u.has($)||T.add($);return{affected:T,gained:F}}#C(k,E){const C=this.#l;if(!C||!C.leftByJoinKey)return null;const x=[];for(const j of k){const T=C.leftByJoinKey.get(j);if(T)for(const F of T){const $=C.rowData.get(F);$!==void 0&&x.push({key:F,data:$})}}return this.#M({updated:x,added:[],removed:[]},E)}#O(k,E){if(!this.#l||!this.#l.leftByJoinKey||k.unnest||k.where||String(k.follow||"filtered")==="grouped")return!1;const C=k.join||{};return String(C.type||"inner")==="left"?!0:E.size===0}#P(){const k=this.#t.join,E=k&&k.with;if(!E||!E.rows)return[];const C=[],x=j=>{j.group||C.push(X(j))};return String(k.follow||"all")==="filtered"&&A(E.rows.forEach)?E.rows.forEach(x):A(E.rows.forEachAll)&&E.rows.forEachAll(x),C}schedule(k){const E=this.#t.refresh===void 0?"idle":this.#t.refresh;if(E==="manual")return;if(E==="live"){this.refresh(k);return}const C=typeof E=="number"&&Number.isFinite(E)?E:i;if(this.#r){this.#c=!0;return}this.#c=!1,this.#r=setTimeout(()=>{this.#r=null,this.refresh(this.#c?null:k)},C)}refresh(k){if(!(this.#s||!this.#e&&!this.#d)){if(this.#a){I("source.derived.cycle","a derived grid is deriving from itself, directly or through a chain. The cycle was refused; check the `from` of each grid in the chain.");return}this.#a=!0;try{const E=this.#f?[]:this.#d?this.#t.profile?this.#q():this.#L():this.#t.statistics!==void 0?this.#ge():this.#t.profile?this.#fe():this.#E(k);this.setRows(E),this.invalidate("filter"),A(this.#i.emit)&&this.#i.emit("rows:changed",{derived:!0},"derived")}finally{this.#a=!1}}}#E(k){const C=V(k)&&k.partner===!0?this.#v():null,x=this.#D();if(C&&this.#l){if(!C.affected.size)return c(this.#l.groups,x,this.#l.reduced,new Set);if(this.#O(x,C.gained)){const ee=this.#C(C.affected,x);if(ee)return c(this.#l.groups,x,this.#l.reduced,ee)}}const j=this.#T(x,k);if(j&&this.#l){const ee=this.#M(j,x);return c(this.#l.groups,x,this.#l.reduced,ee)}const T=v(this.#B(),x);if(this.#o=this.#R(),!x.groupBy)return this.#l=null,O(T,x);const F=this.#N(),{groups:$,rowGroup:D}=b(T,x,F),z=new Map;for(const[ee,re]of D){const ie=$.get(re);ie&&z.set(ee,ie.rows.get(ee))}const G=new Map,N=this.#A(),Z=new Map,Q=new Map;if(N)for(const[ee,re]of z){const ie=s(re,N.left);if(ie===null)continue;Z.set(ee,ie);let ce=Q.get(ie);ce||(ce=new Set,Q.set(ie,ce)),ce.add(ee)}return this.#l={groups:$,rowGroup:D,rowData:z,reduced:G,leftJoinKey:Z,leftByJoinKey:Q},c($,x,G,null)}#T(k,E){if(!this.#l||!k.groupBy||k.unnest||k.where||String(k.follow||"filtered")==="grouped"||V(k.join)&&k.join.with&&!(k.join.index instanceof Map)||!V(E))return null;const C=Array.isArray(E.updated)?E.updated:null,x=Array.isArray(E.added)?E.added:null,j=Array.isArray(E.removed)?E.removed:null;if(!C&&!x&&!j)return null;const T=this.#o;if(T&&T.size&&String(k.follow||"filtered")!=="all"){if(E.edit===!0&&Array.isArray(E.columns)){for(const F of E.columns)if(T.has(String(F)))return null}for(const F of C||[]){const $=F&&F.key,D=$===void 0?void 0:this.#l.rowData.get(String($)),z=X(F);for(const G of T)if(g(D,G)!==g(z,G))return null}}return{updated:C||[],added:x||[],removed:j||[]}}#M(k,E){const C=this.#l,x=this.#N(),j=new Set,T=V(E.join)&&E.join.index instanceof Map?E.join:null,F=this.#A(),$=z=>{const G=C.rowGroup.get(z);if(G===void 0)return;j.add(G);const N=C.groups.get(G);if(N&&(N.rows.delete(z),N.rows.size||C.groups.delete(G)),C.rowGroup.delete(z),C.rowData.delete(z),C.leftJoinKey){const Z=C.leftJoinKey.get(z);if(Z!==void 0){const Q=C.leftByJoinKey.get(Z);Q&&(Q.delete(z),Q.size||C.leftByJoinKey.delete(Z)),C.leftJoinKey.delete(z)}}},D=z=>{const G=T?t(z,T):z;if(!G)return;const N=x(G),Z=b([G],E,x);for(const[Q,ee]of Z.groups){let re=C.groups.get(Q);re||(re={values:ee.values,rows:new Map},C.groups.set(Q,re)),re.rows.set(N,G),C.rowGroup.set(N,Q),j.add(Q)}if(C.rowData.set(N,G),F&&C.leftByJoinKey){const Q=s(G,F.left);if(Q!==null){C.leftJoinKey.set(N,Q);let ee=C.leftByJoinKey.get(Q);ee||(ee=new Set,C.leftByJoinKey.set(Q,ee)),ee.add(N)}}};for(const z of k.removed)$(String(z));for(const z of k.updated)$(String(z.key)),D(X(z));for(const z of k.added)D(X(z));return j}#N(){const k=this.#e,E=k&&k.config&&k.config.rowKey||"id";return C=>String(g(C,typeof E=="string"?E:"id")??"")}#R(){const k=this.#e,E=k&&k.state&&A(k.state.get)?k.state.get():null,C=new Set,x=j=>{if(j){if(Array.isArray(j.conditions)){j.conditions.forEach(x);return}j.col&&C.add(String(j.col))}};return E&&x(E.filters),C}#D(){let k=this.#t;if(k.join&&k.join.with&&(this.#u||this.#v(),k={...k,join:{...k.join,index:this.#u}}),this.#d||String(k.follow||"filtered")!=="grouped")return k;const E=this.#e,C=E&&E.state&&A(E.state.get)?E.state.get():null,x=C&&Array.isArray(C.group)?C.group:[];return x.length?{...k,groupBy:[...x]}:k}#G(){const k=[];for(const E of this.#d)if(E.grid)try{const C=l.includes(String(E.follow))?String(E.follow):"filtered",x=this.#K(E.grid,C);for(const j of x){const T=E.map?E.map(j):j;V(T)&&k.push({...T,[n]:E.label})}}catch(C){I(`source.derived.union.failed.${E.label}`,`source.mode "derived": union source "${E.label}" failed to read (${C&&C.message?C.message:C}) and was skipped this pass.`)}return k}#K(k,E){if(!k||!k.rows)return[];if(E==="all"){const x=[];return A(k.rows.forEachAll)&&k.rows.forEachAll(j=>{j.group||x.push(X(j))}),x}if(E==="selected")return(k.selection&&A(k.selection.rows)?k.selection.rows():[]).filter(Boolean).map(X);const C=[];return A(k.rows.forEach)&&k.rows.forEach(x=>{x.group||C.push(X(x))}),C}#L(){const k=this.#D(),E=this.#G(),C=O(E,k);return k.groupBy?C:r(C)}#q(){return I("source.derived.union.profile",'source.mode "derived": `profile` is not supported when `from` is a union of several grids (BACKLOG-0001045); profile a single grid instead.'),[]}#B(){const k=this.#e,E=String(this.#t.follow||"filtered");if(!k||!k.rows)return[];if(E==="all"){const j=[];return A(k.rows.forEachAll)&&k.rows.forEachAll(T=>{T.group||j.push(X(T))}),j}if(E==="selected")return(k.selection&&A(k.selection.rows)?k.selection.rows():[]).filter(Boolean).map(X);const C=this.#Y(),x=[];return C&&this.#z().length&&A(k.rows.forEachExcept)?(k.rows.forEachExcept(C,j=>{j.group||x.push(X(j))}),x):(A(k.rows.forEach)&&k.rows.forEach(j=>{j.group||x.push(X(j))}),x)}#Y(){const k=this.#t.crossFilter;if(!k||this.#d)return null;if(typeof k=="string")return k;if(k.col)return String(k.col);const E=this.#t.groupBy,C=Array.isArray(E)?E[0]:E;return C?String(C):null}#z(){const k=this.#Y(),E=this.#e;if(!k||!E||!E.filters||!A(E.filters.get))return[];const C=q(E.filters.get(),k);return C?C.op==="in"&&Array.isArray(C.value)?C.value.map(String):C.op==="eq"&&C.value!==void 0?[String(C.value)]:[]:[]}#I(k){const E=this.#Y(),C=this.#e;if(!E||!C||!C.filters||!A(C.filters.set))return;const x=this.#i.compute||{},j=A(C.filters.get)?C.filters.get():null,T=A(x.pruneColumn)?x.pruneColumn(j,E):null;if(!k.length){C.filters.set(T||null);return}const F=k.length===1?{col:E,op:"eq",value:k[0]}:{col:E,op:"in",value:k.slice()},$=T?T.conditions&&T.op?T.conditions:[T]:[];C.filters.set($.length?{op:"and",conditions:[...$,F]}:F)}crossFilter(){const k=this;return{enabled(){return!!k.#Y()},column(){return k.#Y()},get(){return k.#z()},set(E){const C=E==null?[]:(Array.isArray(E)?E:[E]).map(x=>String(x));k.#I(C)},toggle(E){const C=String(E),x=k.#z(),T=x.indexOf(C)>=0?x.filter(F=>F!==C):[...x,C];k.#I(T)},clear(){k.#I([])}}}#W(k){const E=k&&k.rows;if(E&&A(E.matchCount)){const C=E.matchCount(),x=Number(C);if(C!==null&&Number.isFinite(x))return x}if(E&&A(E.count)){const C=Number(E.count());if(Number.isFinite(C))return C}return 0}#ge(){const k=this.#e,E=this.#t.statistics;if(!k||!k.statistics||!V(E))return[];switch(String(E.fn)){case"correlation":return this.#ie(k,E);case"series":return this.#ue(k,E);case"datasetVsDataset":return this.#Me(k,E);default:return[]}}#ie(k,E){const C=E.columns.filter(Boolean).map(String),x=this.#W(k),j=(T,F)=>{const $=k.statistics.correlation(T,F);return typeof $=="number"&&Number.isFinite($)?$:null};if(String(E.orient||"pairs")!=="matrix"){const T=[];for(let F=0;F<C.length;F++)for(let $=F+1;$<C.length;$++)T.push({[u]:`${C[F]}${C[$]}`,a:C[F],b:C[$],coefficient:j(C[F],C[$]),n:x});return T}return C.map(T=>{const F={[u]:T,column:T};for(const $ of C)F[$]=T===$?1:j(T,$);return F.n=x,F})}#ue(k,E){const C=this.#W(k),x={by:String(E.by)};E.periodsPerYear!==void 0&&(x.periodsPerYear=Number(E.periodsPerYear));const j=k.statistics.series(String(E.of),x)||{};return y.map(T=>({[u]:T,metric:T,value:j[T]??null,n:C}))}#Me(k,E){const C=E.with,x=Array.isArray(E.columns)?{columns:E.columns.map(String)}:void 0,j=k.statistics.datasetVsDataset(C,x);if(!V(j))return[];const F=(Array.isArray(j.ranked)?j.ranked:[]).map(z=>({[u]:String(z.column),column:z.column,measure:z.measure??null,magnitude:z.magnitude??null,distance:z.distance??null,direction:z.direction??null,nA:z.nA??null,nB:z.nB??null,meanA:z.meanA??null,meanB:z.meanB??null,reliable:z.reliable??null,unmatched:""})),$=j.unmatched,D=[["A",$&&$.onlyA],["B",$&&$.onlyB]];for(const[z,G]of D)for(const N of G||[])F.push({[u]:`${z}${N}`,column:N,measure:null,magnitude:null,distance:null,direction:null,nA:null,nB:null,meanA:null,meanB:null,reliable:!1,unmatched:z});return F}#fe(){const k=this.#e;if(!k||!k.statistics||!A(k.statistics.profile))return[];const C=(Array.isArray(this.#t.profile)?this.#t.profile:[this.#t.profile]).filter(Boolean).map(j=>{const T=k.statistics.profile(String(j))||{},F={[u]:String(j)};for(const D of d)F[D]=D==="column"?String(j):T[D]??null;F.outliers=Array.isArray(T.outliers)?T.outliers.length:T.outliers??null;const $=m({...T,rows:F.rows,outliers:F.outliers,numeric:T.numeric},this.#t.alerts);return F.alerts=$.join(", "),F.alertCount=$.length,F});if(this.#t.orient!=="metrics")return C;const x=C[0];return x?d.filter(j=>j!=="column").map(j=>({[u]:j,metric:j,value:x[j]})):[]}apply(k){const E=["add","update","remove"],C=[];for(const x of E)for(const j of k&&k[x]||[])C.push({operation:x,id:j&&j.id,reason:"derived-read-only"});return C.length&&I("source.derived.readonly","a derived grid is read-only: its rows are computed from another grid. Write to the source grid instead, and the derived one follows."),{added:[],updated:[],removed:[],rejected:C}}destroy(){this.#s=!0,this.#r&&(clearTimeout(this.#r),this.#r=null),this.#Y()&&this.#z().length&&this.#I([]);for(const k of this.#n)try{k()}catch{}this.#n=[],this.#e=null,this.#d=null,super.destroy()}}function S(P){return V(P)&&P.companion===!0}function M(P,k,E,C=new Set){if(k===P)return E;if(C.has(k))return null;C.add(k);let x=null;try{x=A(k.config)?k.config():null}catch{x=null}const j=x&&V(x.source)?x.source:null;if(!j||j.mode!=="derived")return null;const T=j.from;if(Array.isArray(T)){for(let F=0;F<T.length;F++){const $=p(T[F],F);if(!$.grid||!A($.grid.on))continue;const D=M(P,$.grid,[...E,$.label],C);if(D)return D}return null}return V(T)&&A(T.on)?M(P,T,[...E,"(from)"],C):null}function X(P){return V(P)&&"data"in P?P.data:P}function q(P,k){if(!P||typeof P!="object")return null;if(Array.isArray(P.conditions)){for(const C of P.conditions){const x=q(C,k);if(x)return x}return null}return P.col===k?P:null}function K(P,k){return new w(P,k)}}),ze("packages/core/src/source/adapters/odata.js",function(e,B){"use strict";Object.defineProperty(e,"conditionToOData",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"filtersToOData",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"odataAdapter",{enumerable:!0,get:function(){return d}});const A=B("packages/core/src/internal/warn.js").warnOnce,U=B("packages/core/src/source/filterwire.js").isGroup,I=Object.freeze(["eq","ne","gt","gte","lt","lte","contains","startsWith","endsWith","blank","notBlank","between","notBetween"]),J=/^\d{4}-\d{2}-\d{2}$/,H=/^\d{2}:\d{2}(:\d{2}(\.\d+)?)?$/,L=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})$/;function Y(h){const a=h instanceof Date?h:typeof h=="number"&&Number.isFinite(h)?new Date(h):typeof h=="string"&&L.test(h)?new Date(h):null;return a&&!Number.isNaN(a.getTime())?a:null}const _=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2}(\.\d+)?)?$/;function O(h,a){throw typeof a=="string"&&_.test(a)?new Error(`odataAdapter: "${a}" needs a zone designator to be used as a ${h} value — add "Z" for UTC or a "+HH:MM"/"-HH:MM" offset. A date-time with no zone is ambiguous (whose local time?) and would otherwise silently become the wrong instant rather than the one intended.`):new Error(`odataAdapter: "${String(a)}" is not a usable ${h} value`)}function v(h){const a=Y(h);return a||O("DateTimeOffset",h),a.toISOString()}function b(h){if(typeof h=="string"&&J.test(h))return h;const a=Y(h);return a||O("Date",h),a.toISOString().slice(0,10)}function c(h){if(typeof h=="string"&&H.test(h))return h.length===5?`${h}:00`:h;if(typeof h=="number"&&Number.isFinite(h)&&h>=0&&h<864e5){const a=Math.floor(h),y=f=>String(f).padStart(2,"0");return`${y(Math.floor(a/36e5))}:${y(Math.floor(a%36e5/6e4))}:${y(Math.floor(a%6e4/1e3))}`}throw new Error(`odataAdapter: "${String(h)}" is not a usable TimeOfDay value`)}const g=Object.freeze({timestamp:v,datetime:v,date:b,dateString:b,time:c}),o=200,t=1e3,s=Object.freeze({eq:"eq",ne:"ne",gt:"gt",gte:"ge",lt:"lt",lte:"le"});function l(h,a){if(h==null)return"null";const y=a&&g[String(a)];return y?y(h):typeof h=="number"||typeof h=="boolean"?String(h):h instanceof Date?h.toISOString():`'${String(h).replace(/'/g,"''")}'`}function u(h){const a=String(h),y=/^[A-Za-z_][A-Za-z0-9_]*$/;if(!a||!a.split("/").every(f=>y.test(f)))throw new Error(`odataAdapter: "${a}" is not a usable column name`);return a}const n=Object.freeze({lo:{incl:"ge",excl:"gt"},hi:{incl:"le",excl:"lt"}});function p(h){const a=u(h.col),y=String(h.op),f=h.type;if(s[y])return`${a} ${s[y]} ${l(h.value,f)}`;if(y==="contains")return`contains(${a},${l(h.value,f)})`;if(y==="startsWith")return`startswith(${a},${l(h.value,f)})`;if(y==="endsWith")return`endswith(${a},${l(h.value,f)})`;if(y==="blank")return`(${a} eq null)`;if(y==="notBlank")return`(${a} ne null)`;if(y==="between"||y==="notBetween"){const m=Array.isArray(h.value)?h.value:[h.value,h.value],w=String(h.bounds||"[]"),S=w.charAt(0)==="("?n.lo.excl:n.lo.incl,M=w.charAt(1)===")"?n.hi.excl:n.hi.incl,X=`(${a} ${S} ${l(m[0],f)} and ${a} ${M} ${l(m[1],f)})`;return y==="between"?X:`(${a} eq null or not ${X})`}return null}function r(h){const a=String(h&&h.op);throw A(`source.odata.filter.refuse.${a}`,`a "${a}" filter condition cannot be written as an OData $filter expression, so the request was refused rather than sent without it — silently dropping it would have matched more or fewer rows than the filter asked for. Route this condition through a source that can pushdown-split it as residual (source.filter capability), or drop it from the tree before building the URL.`),new Error(`odataAdapter: a "${a}" filter condition cannot be expressed in OData and was refused`)}function i(h){if(!h)return"";if(!U(h)){const f=p(h);return f===null?r(h):f}const a=String(h.op)==="or"?" or ":" and ",y=(h.conditions||[]).map(f=>{if(U(f))return i(f);const m=p(f);return m===null?r(f):m}).filter(Boolean);return y.length?y.length===1?y[0]:`(${y.join(a)})`:""}function d(h={}){const a=String(h.url||""),y=h.fetch||(typeof fetch=="function"?fetch:null),f=h.count!==!1,m=u(h.key||"id"),w=h.edit===!0;return{name:"odata",capabilities:{filter:"tree",operators:I,sort:"multi",quick:h.search===!0,range:!0,total:f,mutate:w?{update:!0,delete:!0,append:!0,returning:"row"}:!1},urlFor(S){const M=[],X=(K,P)=>M.push(`${K}=${encodeURIComponent(P)}`),q=i(S.filters);return q&&X("$filter",q),S.sort&&S.sort.length&&X("$orderby",S.sort.map(K=>`${u(K.col)}${K.dir==="desc"?" desc":" asc"}`).join(",")),S.range&&(X("$skip",String(S.range.start)),X("$top",String(S.range.end-S.range.start))),S.quick&&X("$search",`"${String(S.quick).replace(/"/g,"")}"`),f&&X("$count","true"),M.length?`${a}?${M.join("&")}`:a},async execute(S,M){if(!y)throw new Error("odataAdapter needs a fetch implementation");const X={Accept:"application/json",...h.headers||{}},q=M&&M.signal,K=async C=>{const x=await y(C,{headers:X,signal:q});if(!x.ok)throw new Error(`OData request failed: ${x.status}`);return x.json()};let P=await K(this.urlFor(S)),k=P.value||P.rows||[];const E=P["@odata.count"]??P.count;if(!S.range){let C=P["@odata.nextLink"];for(;C&&k.length<o*t;)P=await K(C),k=k.concat(P.value||P.rows||[]),C=P["@odata.nextLink"]}return E==null?(f&&A("source.odata.nocount",`${a} was asked for $count=true and answered without an @odata.count, so the grid has no total for this query and will scroll open-ended rather than present the page size as the whole. The endpoint does not support $count, or filters it out.`),{rows:k}):{rows:k,total:Number(E)}},urlForKey(S){return`${a}(${l(S)})`},async mutate(S,M){if(!y)throw new Error("odataAdapter needs a fetch implementation");if(!S||S.kind!=="update"&&S.kind!=="delete"&&S.kind!=="append")throw new Error(`odataAdapter: mutation kind "${S&&S.kind}" is not supported (update, delete and append are wired)`);const X={Accept:"application/json","Content-Type":"application/json",...h.headers||{}},q=M&&M.signal;if(S.kind==="delete"){const C=Array.isArray(S.keys)&&S.keys.length?S.keys[0]:S.key;if(C==null)throw new Error("odataAdapter: a delete needs a row key");const x=await y(this.urlForKey(C),{method:"DELETE",headers:X,signal:q});if(!x.ok)throw new Error(`OData delete failed: ${x.status}`);return{ok:!0}}if(S.kind==="append"){const C=Array.isArray(S.rows)?S.rows.filter($=>$&&typeof $=="object"):[];if(C.length!==1)throw new Error("odataAdapter: an append needs exactly one row object (OData creates one entity per POST)");const x=await y(a,{method:"POST",headers:X,signal:q,body:JSON.stringify(C[0])});if(!x.ok)throw new Error(`OData add-row failed: ${x.status}`);const j=x.status===204?null:await x.json().catch(()=>null),T=j&&typeof j=="object"&&"value"in j?j.value:j;if(!T||typeof T!="object")throw new Error("odataAdapter: the POST returned no created entity to rekey the appended row by. Have the service return the created entity (Prefer: return=representation).");const F=T[m];if(F==null)throw new Error(`odataAdapter: the created entity carried no ${m} to rekey the appended row by.`);return{ok:!0,keys:[String(F)],rows:[T]}}const K=this.urlForKey(S.key),P=await y(K,{method:"PATCH",headers:X,signal:q,body:JSON.stringify(S.patch||{})});if(!P.ok)throw new Error(`OData update failed: ${P.status}`);if(P.status===204)return{ok:!0};const k=await P.json(),E=k&&typeof k=="object"&&"value"in k?k.value:k;return E==null?{ok:!0}:{ok:!0,rows:[E]}}}}}),ze("packages/core/src/source/adapters/rest.js",function(e,B){"use strict";Object.defineProperty(e,"DEFAULT_PARAMS",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"DEFAULT_VERBS",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"restAdapter",{enumerable:!0,get:function(){return V}});const ne=Object.freeze({offset:"offset",limit:"limit",sort:"sort",order:"order",filter:"filter",search:"q"}),A=Object.freeze({update:"PATCH",delete:"DELETE",append:"POST"});function V(U={}){const I=String(U.url||""),J=U.fetch||(typeof fetch=="function"?fetch:null),H={...ne,...U.params||{}},L=U.encodeFilter||(t=>JSON.stringify(t)),Y=U.rows||(t=>Array.isArray(t)?t:t.rows||t.data||[]),_=U.total||((t,s)=>Array.isArray(t)?s.length:t.total??t.count??s.length),O=U.edit===!0,v=U.returning==="row"?"row":U.returning==="key"?"key":"none",b=U.keyField||"id",c=U.writeUrlFor||(t=>`${I}/${encodeURIComponent(String(t.key??(t.keys&&t.keys[0])))}`),g=U.encodeMutation||(t=>{const s=A[t.kind];if(t.kind==="update")return{method:s,url:c(t),headers:{"Content-Type":"application/json"},body:JSON.stringify(t.patch||{})};if(t.kind==="append"){const l=Array.isArray(t.rows)?t.rows:t.rows?[t.rows]:[];return{method:s,url:I,headers:{"Content-Type":"application/json"},body:JSON.stringify(l.length===1?l[0]:l)}}return{method:s,url:c(t)}}),o=U.writeRow||(t=>{if(t===null||typeof t!="object")return null;if(Array.isArray(t))return t.length?t[0]:null;const s=t;return s.row??s.data??t});return{name:"rest",capabilities:{range:!0,total:!0,sort:"multi",filter:!1,quick:!1,mutate:O?{update:!0,delete:!0,append:!0,returning:v}:!1,...U.capabilities||{},...U.operators?{filter:"tree",operators:U.operators}:{}},urlFor(t){const s=new URLSearchParams;t.range&&(s.set(H.offset,String(t.range.start)),s.set(H.limit,String(t.range.end-t.range.start))),t.sort&&t.sort.length&&(s.set(H.sort,t.sort.map(u=>u.col).join(",")),s.set(H.order,t.sort.map(u=>u.dir||"asc").join(","))),t.filters&&s.set(H.filter,L(t.filters)),t.quick&&s.set(H.search,String(t.quick));const l=s.toString();return l?`${I}?${l}`:I},async execute(t,s){if(!J)throw new Error("restAdapter needs a fetch implementation");const l=await J(this.urlFor(t),{headers:{Accept:"application/json",...U.headers||{}},signal:s&&s.signal});if(!l.ok)throw new Error(`request failed: ${l.status}`);const u=await l.json(),n=Y(u);return{rows:n,total:_(u,n)}},writeUrlFor(t){return c(t)},encodeMutation(t){return g(t)},async mutate(t,s){if(!J)throw new Error("restAdapter needs a fetch implementation");if(!t||t.kind!=="update"&&t.kind!=="delete"&&t.kind!=="append")throw new Error(`restAdapter: mutation kind "${t&&t.kind}" is not supported (update, delete and append are wired)`);const l=g(t);if(!l||!l.url||!l.method)throw new Error("restAdapter: encodeMutation must return { method, url }");const u={Accept:"application/json",...U.headers||{},...l.headers||{}},n=await J(l.url,{method:l.method,headers:u,signal:s&&s.signal,...l.body!==void 0?{body:l.body}:{}});if(!n.ok)throw new Error(`REST ${t.kind} failed: ${n.status}`);if(t.kind==="append"){if(v==="none")return{ok:!0};if(n.status===204)throw new Error("restAdapter: the add-row POST returned 204 with no body, so the appended row has no server key to rekey by. Declare returning: 'row'/'key' and have the endpoint return the created row.");const i=await n.json(),d=o(i),h=d&&typeof d=="object"?d[b]:void 0;if(h==null)throw new Error(`restAdapter: the add-row response carried no ${b} to rekey the appended row by. Point \`keyField\` at the primary key the endpoint returns, or override \`writeRow\`.`);return v==="row"?{ok:!0,keys:[String(h)],rows:[d]}:{ok:!0,keys:[String(h)]}}if(v!=="row"||n.status===204)return{ok:!0};const p=await n.json(),r=o(p);return r==null?{ok:!0}:{ok:!0,rows:[r]}}}}}),ze("packages/core/src/source/adapters/dfql.js",function(e,B){"use strict";Object.defineProperty(e,"DFQL_BASE",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"DFQL_WRITE_URL",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"dfqlAdapter",{enumerable:!0,get:function(){return O}});const A=B("packages/core/src/internal/predicates.js").isFunction,U=B("packages/core/src/internal/warn.js").warnOnce,I="https://rest.demandflow.com",J="https://stream.demandflow.com/dfql",H=Object.freeze(["id","created","updated","ownerId","entity"]);function L(v){const b={},c=[];for(const[g,o]of Object.entries(v||{})){if(H.includes(g)){c.push(g);continue}b[g]=o}return c.length&&U("source.dfql.protected",`a DFQL update tried to write protected field(s) ${c.join(", ")}; they are server-assigned and immutable, so they were dropped from the PATCH.`),b}function Y(v){if(!v||typeof v!="object"||Array.isArray(v))return["fields (must be an object)"];const b=v,c=[];return(typeof b.entity!="string"||!b.entity)&&c.push("entity (uppercase code)"),Number.isFinite(Number(b.level))||c.push("level (numeric)"),(typeof b.comboKey!="string"||!b.comboKey.endsWith("|ENT:"))&&c.push("comboKey (a string ending '|ENT:')"),c}async function _(v){const b=[],c=s=>{const l=s.trim();if(l)try{b.push(JSON.parse(l))}catch{}};if(!v.body||typeof v.body.getReader!="function")return(await v.text()).split(`
|